Bluetooth: Refactor bt_conn_add_le() routine
Adds helper routine to get connection object from available pool. Change-Id: Ic6a7480bfbc35d297caceee3fd7eb53d6916b031 Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
This commit is contained in:
parent
96fc48edb3
commit
f30f0702dc
1 changed files with 13 additions and 1 deletions
|
@ -492,7 +492,7 @@ static void conn_tx_fiber(int arg1, int arg2)
|
||||||
bt_conn_unref(conn);
|
bt_conn_unref(conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct bt_conn *bt_conn_add_le(const bt_addr_le_t *peer)
|
static struct bt_conn *conn_new(void)
|
||||||
{
|
{
|
||||||
struct bt_conn *conn = NULL;
|
struct bt_conn *conn = NULL;
|
||||||
int i;
|
int i;
|
||||||
|
@ -511,6 +511,18 @@ struct bt_conn *bt_conn_add_le(const bt_addr_le_t *peer)
|
||||||
memset(conn, 0, sizeof(*conn));
|
memset(conn, 0, sizeof(*conn));
|
||||||
|
|
||||||
atomic_set(&conn->ref, 1);
|
atomic_set(&conn->ref, 1);
|
||||||
|
|
||||||
|
return conn;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct bt_conn *bt_conn_add_le(const bt_addr_le_t *peer)
|
||||||
|
{
|
||||||
|
struct bt_conn *conn = conn_new();
|
||||||
|
|
||||||
|
if (!conn) {
|
||||||
|
return NULL;
|
||||||
|
};
|
||||||
|
|
||||||
bt_addr_le_copy(&conn->le.dst, peer);
|
bt_addr_le_copy(&conn->le.dst, peer);
|
||||||
#if defined(CONFIG_BLUETOOTH_SMP)
|
#if defined(CONFIG_BLUETOOTH_SMP)
|
||||||
conn->sec_level = BT_SECURITY_LOW;
|
conn->sec_level = BT_SECURITY_LOW;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue