Bluetooth: Pass local identity to bt_conn_add_le()
This makes the identity initialization consistent and actually catches a few branches where it may not have properly happened. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
parent
0ce7dad5b2
commit
73baaaa3dc
3 changed files with 10 additions and 16 deletions
|
@ -1525,7 +1525,7 @@ void bt_conn_process_tx(struct bt_conn *conn)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct bt_conn *bt_conn_add_le(const bt_addr_le_t *peer)
|
struct bt_conn *bt_conn_add_le(u8_t id, const bt_addr_le_t *peer)
|
||||||
{
|
{
|
||||||
struct bt_conn *conn = conn_new();
|
struct bt_conn *conn = conn_new();
|
||||||
|
|
||||||
|
@ -1533,6 +1533,7 @@ struct bt_conn *bt_conn_add_le(const bt_addr_le_t *peer)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
conn->id = id;
|
||||||
bt_addr_le_copy(&conn->le.dst, peer);
|
bt_addr_le_copy(&conn->le.dst, peer);
|
||||||
#if defined(CONFIG_BT_SMP)
|
#if defined(CONFIG_BT_SMP)
|
||||||
conn->sec_level = BT_SECURITY_L1;
|
conn->sec_level = BT_SECURITY_L1;
|
||||||
|
@ -2204,14 +2205,12 @@ struct bt_conn *bt_conn_create_le(const bt_addr_le_t *peer,
|
||||||
bt_addr_le_copy(&dst, bt_lookup_id_addr(BT_ID_DEFAULT, peer));
|
bt_addr_le_copy(&dst, bt_lookup_id_addr(BT_ID_DEFAULT, peer));
|
||||||
}
|
}
|
||||||
|
|
||||||
conn = bt_conn_add_le(&dst);
|
/* Only default identity supported for now */
|
||||||
|
conn = bt_conn_add_le(BT_ID_DEFAULT, &dst);
|
||||||
if (!conn) {
|
if (!conn) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Only default identity supported for now */
|
|
||||||
conn->id = BT_ID_DEFAULT;
|
|
||||||
|
|
||||||
start_scan:
|
start_scan:
|
||||||
bt_conn_set_param_le(conn, param);
|
bt_conn_set_param_le(conn, param);
|
||||||
|
|
||||||
|
@ -2232,18 +2231,16 @@ int bt_le_set_auto_conn(const bt_addr_le_t *addr,
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Only default identity is supported */
|
||||||
conn = bt_conn_lookup_addr_le(BT_ID_DEFAULT, addr);
|
conn = bt_conn_lookup_addr_le(BT_ID_DEFAULT, addr);
|
||||||
if (!conn) {
|
if (!conn) {
|
||||||
conn = bt_conn_add_le(addr);
|
conn = bt_conn_add_le(BT_ID_DEFAULT, addr);
|
||||||
if (!conn) {
|
if (!conn) {
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (param) {
|
if (param) {
|
||||||
/* Only default identity is supported */
|
|
||||||
conn->id = BT_ID_DEFAULT;
|
|
||||||
|
|
||||||
bt_conn_set_param_le(conn, param);
|
bt_conn_set_param_le(conn, param);
|
||||||
|
|
||||||
if (!atomic_test_and_set_bit(conn->flags,
|
if (!atomic_test_and_set_bit(conn->flags,
|
||||||
|
@ -2315,13 +2312,11 @@ struct bt_conn *bt_conn_create_slave_le(const bt_addr_le_t *peer,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
conn = bt_conn_add_le(peer);
|
conn = bt_conn_add_le(param->id, peer);
|
||||||
if (!conn) {
|
if (!conn) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
conn->id = param->id;
|
|
||||||
|
|
||||||
start_adv:
|
start_adv:
|
||||||
bt_conn_set_state(conn, BT_CONN_CONNECT_DIR_ADV);
|
bt_conn_set_state(conn, BT_CONN_CONNECT_DIR_ADV);
|
||||||
|
|
||||||
|
|
|
@ -153,7 +153,7 @@ static inline int bt_conn_send(struct bt_conn *conn, struct net_buf *buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add a new LE connection */
|
/* Add a new LE connection */
|
||||||
struct bt_conn *bt_conn_add_le(const bt_addr_le_t *peer);
|
struct bt_conn *bt_conn_add_le(u8_t id, const bt_addr_le_t *peer);
|
||||||
|
|
||||||
/* 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);
|
||||||
|
|
|
@ -1124,7 +1124,7 @@ static void enh_conn_complete(struct bt_hci_evt_le_enh_conn_complete *evt)
|
||||||
|
|
||||||
/* for slave we may need to add new connection */
|
/* for slave we may need to add new connection */
|
||||||
if (!conn) {
|
if (!conn) {
|
||||||
conn = bt_conn_add_le(&id_addr);
|
conn = bt_conn_add_le(bt_dev.adv_id, &id_addr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1133,7 +1133,7 @@ static void enh_conn_complete(struct bt_hci_evt_le_enh_conn_complete *evt)
|
||||||
evt->role == BT_HCI_ROLE_MASTER) {
|
evt->role == BT_HCI_ROLE_MASTER) {
|
||||||
/* for whitelist initiator me may need to add new connection. */
|
/* for whitelist initiator me may need to add new connection. */
|
||||||
if (!conn) {
|
if (!conn) {
|
||||||
conn = bt_conn_add_le(&id_addr);
|
conn = bt_conn_add_le(BT_ID_DEFAULT, &id_addr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1157,7 +1157,6 @@ static void enh_conn_complete(struct bt_hci_evt_le_enh_conn_complete *evt)
|
||||||
*/
|
*/
|
||||||
if (IS_ENABLED(CONFIG_BT_PERIPHERAL) &&
|
if (IS_ENABLED(CONFIG_BT_PERIPHERAL) &&
|
||||||
conn->role == BT_HCI_ROLE_SLAVE) {
|
conn->role == BT_HCI_ROLE_SLAVE) {
|
||||||
conn->id = bt_dev.adv_id;
|
|
||||||
bt_addr_le_copy(&conn->le.init_addr, &peer_addr);
|
bt_addr_le_copy(&conn->le.init_addr, &peer_addr);
|
||||||
|
|
||||||
if (IS_ENABLED(CONFIG_BT_PRIVACY)) {
|
if (IS_ENABLED(CONFIG_BT_PRIVACY)) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue