Bluetooth: Fix setting CONNECT_SCAN state for connections.
The state of auto-connectable bt_conn objects needs to be set to CONNECT_SCAN after init as well as whenever bt_le_set_auto_conn is called. Change-Id: Iad2ca32a00ee1b4259196dd20651d5bf94ba9f26 Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
parent
fb576fee7f
commit
914b553382
2 changed files with 24 additions and 0 deletions
|
@ -893,6 +893,25 @@ struct net_buf *bt_conn_create_pdu(struct nano_fifo *fifo, size_t reserve)
|
|||
return net_buf_get(fifo, head_reserve);
|
||||
}
|
||||
|
||||
static void background_scan_init(void)
|
||||
{
|
||||
#if defined(CONFIG_BLUETOOTH_CENTRAL)
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(conns); i++) {
|
||||
struct bt_conn *conn = &conns[i];
|
||||
|
||||
if (!atomic_get(&conn->ref)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (atomic_test_bit(conn->flags, BT_CONN_AUTO_CONNECT)) {
|
||||
bt_conn_set_state(conn, BT_CONN_CONNECT_SCAN);
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_BLUETOOTH_CENTRAL */
|
||||
}
|
||||
|
||||
int bt_conn_init(void)
|
||||
{
|
||||
int err;
|
||||
|
@ -909,5 +928,7 @@ int bt_conn_init(void)
|
|||
|
||||
bt_l2cap_init();
|
||||
|
||||
background_scan_init();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1244,6 +1244,9 @@ int bt_le_set_auto_conn(bt_addr_le_t *addr, bool auto_conn)
|
|||
|
||||
if (conn->state == BT_CONN_DISCONNECTED &&
|
||||
atomic_test_bit(bt_dev.flags, BT_DEV_READY)) {
|
||||
if (auto_conn) {
|
||||
bt_conn_set_state(conn, BT_CONN_CONNECT_SCAN);
|
||||
}
|
||||
bt_le_scan_update(false);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue