Bluetooth: Refactor bt_conn_add() routine

Renames bt_conn_add() to bt_conn_add_le() to emphasize LE context.
Initializes link type to LE in early stage of setting LE connection.

Change-Id: Ica88764e1f3aba563ec7edc3b630e5e76ead249f
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
This commit is contained in:
Arkadiusz Lichwa 2015-11-25 10:48:33 +01:00 committed by Anas Nashif
commit 96fc48edb3
3 changed files with 7 additions and 7 deletions

View file

@ -492,7 +492,7 @@ static void conn_tx_fiber(int arg1, int arg2)
bt_conn_unref(conn);
}
struct bt_conn *bt_conn_add(const bt_addr_le_t *peer)
struct bt_conn *bt_conn_add_le(const bt_addr_le_t *peer)
{
struct bt_conn *conn = NULL;
int i;
@ -516,6 +516,7 @@ struct bt_conn *bt_conn_add(const bt_addr_le_t *peer)
conn->sec_level = BT_SECURITY_LOW;
conn->required_sec_level = BT_SECURITY_LOW;
#endif /* CONFIG_BLUETOOTH_SMP */
conn->type = BT_CONN_TYPE_LE;
return conn;
}
@ -549,7 +550,7 @@ void bt_conn_set_state(struct bt_conn *conn, bt_conn_state_t state)
switch (old_state) {
case BT_CONN_DISCONNECTED:
/* Take a reference for the first state transition after
* bt_conn_add() and keep it until reaching DISCONNECTED
* bt_conn_add_le() and keep it until reaching DISCONNECTED
* again.
*/
bt_conn_ref(conn);
@ -796,7 +797,7 @@ struct bt_conn *bt_conn_create_le(const bt_addr_le_t *peer)
}
}
conn = bt_conn_add(peer);
conn = bt_conn_add_le(peer);
if (!conn) {
return NULL;
}

View file

@ -106,8 +106,8 @@ void bt_conn_recv(struct bt_conn *conn, struct net_buf *buf, uint8_t flags);
/* Send data over a connection */
void bt_conn_send(struct bt_conn *conn, struct net_buf *buf);
/* Add a new connection */
struct bt_conn *bt_conn_add(const bt_addr_le_t *peer);
/* Add a new LE connection */
struct bt_conn *bt_conn_add_le(const bt_addr_le_t *peer);
/* Look up an existing connection */
struct bt_conn *bt_conn_lookup_handle(uint16_t handle);

View file

@ -542,7 +542,7 @@ static void le_conn_complete(struct net_buf *buf)
}
if (!conn) {
conn = bt_conn_add(id_addr);
conn = bt_conn_add_le(id_addr);
}
if (!conn) {
@ -550,7 +550,6 @@ static void le_conn_complete(struct net_buf *buf)
return;
}
conn->type = BT_CONN_TYPE_LE;
conn->handle = handle;
bt_addr_le_copy(&conn->le.dst, id_addr);
conn->le.conn_interval = sys_le16_to_cpu(evt->interval);