Bluetooth: BR/EDR: Look up conn by BT address helper

Defines helper routine to look up conn pool object for existance
of instance matching requested bluetooth address.

Change-Id: I31e05afb2346c7dab14e7ba1bd2f4e1378876ae0
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
This commit is contained in:
Arkadiusz Lichwa 2015-12-03 17:05:51 +01:00 committed by Anas Nashif
commit 7abddd2bdf
2 changed files with 24 additions and 0 deletions

View file

@ -534,6 +534,27 @@ struct bt_conn *bt_conn_add_le(const bt_addr_le_t *peer)
} }
#if defined(CONFIG_BLUETOOTH_BREDR) #if defined(CONFIG_BLUETOOTH_BREDR)
struct bt_conn *bt_conn_lookup_addr_br(const bt_addr_t *peer)
{
int i;
for (i = 0; i < ARRAY_SIZE(conns); i++) {
if (!atomic_get(&conns[i].ref)) {
continue;
}
if (conns[i].type != BT_CONN_TYPE_BR) {
continue;
}
if (!bt_addr_cmp(peer, &conns[i].br.dst)) {
return bt_conn_ref(&conns[i]);
}
}
return NULL;
}
struct bt_conn *bt_conn_add_br(const bt_addr_t *peer) struct bt_conn *bt_conn_add_br(const bt_addr_t *peer)
{ {
struct bt_conn *conn = conn_new(); struct bt_conn *conn = conn_new();

View file

@ -112,6 +112,9 @@ struct bt_conn *bt_conn_add_le(const bt_addr_le_t *peer);
#if defined(CONFIG_BLUETOOTH_BREDR) #if defined(CONFIG_BLUETOOTH_BREDR)
/* Add a new BR/EDR connection */ /* Add a new BR/EDR connection */
struct bt_conn *bt_conn_add_br(const bt_addr_t *peer); struct bt_conn *bt_conn_add_br(const bt_addr_t *peer);
/* Look up an existing connection by BT address */
struct bt_conn *bt_conn_lookup_addr_br(const bt_addr_t *peer);
#endif #endif
/* Look up an existing connection */ /* Look up an existing connection */