drivers/nble: Implement bt_conn_lookup_addr_le
Change-Id: Ia22dfdc40b647e6f364fffec9963fb70609159f7 Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
parent
fd28fc1b00
commit
641d706597
2 changed files with 14 additions and 0 deletions
|
@ -86,6 +86,18 @@ struct bt_conn *bt_conn_lookup_handle(uint16_t handle)
|
||||||
|
|
||||||
struct bt_conn *bt_conn_lookup_addr_le(const bt_addr_le_t *peer)
|
struct bt_conn *bt_conn_lookup_addr_le(const bt_addr_le_t *peer)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < ARRAY_SIZE(conns); i++) {
|
||||||
|
if (!atomic_get(&conns[i].ref)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!bt_addr_le_cmp(peer, &conns[i].dst)) {
|
||||||
|
return bt_conn_ref(&conns[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,6 +189,7 @@ void on_ble_gap_connect_evt(const struct ble_gap_connect_evt *ev)
|
||||||
}
|
}
|
||||||
|
|
||||||
conn->handle = ev->conn_handle;
|
conn->handle = ev->conn_handle;
|
||||||
|
bt_addr_le_copy(&conn->dst, &ev->peer_bda);
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_ble_gap_disconnect_evt(const struct ble_gap_disconnect_evt *ev)
|
void on_ble_gap_disconnect_evt(const struct ble_gap_disconnect_evt *ev)
|
||||||
|
|
|
@ -17,4 +17,5 @@
|
||||||
struct bt_conn {
|
struct bt_conn {
|
||||||
uint16_t handle;
|
uint16_t handle;
|
||||||
atomic_t ref;
|
atomic_t ref;
|
||||||
|
bt_addr_le_t dst;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue