mirror of
https://github.com/espressif/esp-nimble.git
synced 2026-08-17 07:20:01 +00:00
Merge pull request #215 from michal-narajowski/gap-find-by-addr
host/gap: Add connection find by address API
This commit is contained in:
@@ -736,6 +736,22 @@ typedef int ble_gap_event_fn(struct ble_gap_event *event, void *arg);
|
||||
*/
|
||||
int ble_gap_conn_find(uint16_t handle, struct ble_gap_conn_desc *out_desc);
|
||||
|
||||
/**
|
||||
* Searches for a connection with a peer with the specified address.
|
||||
* If a matching connection is found, the supplied connection descriptor
|
||||
* is filled correspondingly.
|
||||
*
|
||||
* @param addr The ble address of a connected peer device to search for.
|
||||
* @param out_desc On success, this is populated with information relating to
|
||||
* the matching connection. Pass NULL if you don't need this
|
||||
* information.
|
||||
*
|
||||
* @return 0 on success, BLE_HS_ENOTCONN if no matching connection was
|
||||
* found.
|
||||
*/
|
||||
int ble_gap_conn_find_by_addr(const ble_addr_t *addr,
|
||||
struct ble_gap_conn_desc *out_desc);
|
||||
|
||||
/**
|
||||
* Configures a connection to use the specified GAP event callback. A
|
||||
* connection's GAP event callback is first specified when the connection is
|
||||
|
||||
@@ -436,6 +436,28 @@ ble_gap_conn_find(uint16_t handle, struct ble_gap_conn_desc *out_desc)
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
ble_gap_conn_find_by_addr(const ble_addr_t *addr,
|
||||
struct ble_gap_conn_desc *out_desc)
|
||||
{
|
||||
struct ble_hs_conn *conn;
|
||||
|
||||
ble_hs_lock();
|
||||
|
||||
conn = ble_hs_conn_find_by_addr(addr);
|
||||
if (conn != NULL && out_desc != NULL) {
|
||||
ble_gap_fill_conn_desc(conn, out_desc);
|
||||
}
|
||||
|
||||
ble_hs_unlock();
|
||||
|
||||
if (conn == NULL) {
|
||||
return BLE_HS_ENOTCONN;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
ble_gap_extract_conn_cb(uint16_t conn_handle,
|
||||
ble_gap_event_fn **out_cb, void **out_cb_arg)
|
||||
|
||||
Reference in New Issue
Block a user