Bluetooth: Fix autoconnect if cancelled pending connection
bt_conn_disconnect removes device from autoconnect list and thus should not be called from le_conn_update when timeouting pending connection. Also auto connect flag needs to be check on connection failure to make sure scan is restarted. Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
This commit is contained in:
parent
685da02354
commit
861bae22b8
2 changed files with 10 additions and 10 deletions
|
@ -223,10 +223,11 @@ static void conn_le_update_timeout(struct k_work *work)
|
||||||
|
|
||||||
if (IS_ENABLED(CONFIG_BT_CENTRAL) &&
|
if (IS_ENABLED(CONFIG_BT_CENTRAL) &&
|
||||||
conn->role == BT_CONN_ROLE_MASTER) {
|
conn->role == BT_CONN_ROLE_MASTER) {
|
||||||
if (conn->state == BT_CONN_CONNECT) {
|
/* we don't call bt_conn_disconnect as it would also clear
|
||||||
bt_conn_disconnect(conn,
|
* auto connect flag if it was set, instead just cancel
|
||||||
BT_HCI_ERR_REMOTE_USER_TERM_CONN);
|
* connection directly
|
||||||
}
|
*/
|
||||||
|
bt_hci_cmd_send(BT_HCI_OP_LE_CREATE_CONN_CANCEL, NULL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -829,13 +829,12 @@ static void le_enh_conn_complete(struct bt_hci_evt_le_enh_conn_complete *evt)
|
||||||
|
|
||||||
bt_conn_set_state(conn, BT_CONN_DISCONNECTED);
|
bt_conn_set_state(conn, BT_CONN_DISCONNECTED);
|
||||||
|
|
||||||
/* Drop the reference got by lookup call in CONNECT state.
|
/* check if device is market for auto connect */
|
||||||
* We are now in DISCONNECTED state since no successful LE
|
if (atomic_test_bit(conn->flags, BT_CONN_AUTO_CONNECT)) {
|
||||||
* link been made.
|
bt_conn_set_state(conn, BT_CONN_CONNECT_SCAN);
|
||||||
*/
|
}
|
||||||
bt_conn_unref(conn);
|
|
||||||
|
|
||||||
return;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
bt_addr_le_copy(&id_addr, &evt->peer_addr);
|
bt_addr_le_copy(&id_addr, &evt->peer_addr);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue