Bluetooth: host: Fix resume failing with extended advertising
Fix advertising failing to resume with BT_ADV_PERSIST set in bt_hci_le_adv_set_terminated due to BT_ADV_ENABLED not getting cleared before bt_le_adv_resume gets called Signed-off-by: Troels Nilsson <trnn@demant.com>
This commit is contained in:
parent
0f892ff8c8
commit
eabdf16087
|
@ -1900,18 +1900,37 @@ void bt_hci_le_adv_set_terminated(struct net_buf *buf)
|
|||
struct bt_hci_evt_le_adv_set_terminated *evt;
|
||||
struct bt_le_ext_adv *adv;
|
||||
uint16_t conn_handle;
|
||||
#if (CONFIG_BT_ID_MAX > 1) && (CONFIG_BT_EXT_ADV_MAX_ADV_SET > 1)
|
||||
bool was_adv_enabled;
|
||||
#endif
|
||||
|
||||
evt = (void *)buf->data;
|
||||
adv = bt_adv_lookup_handle(evt->adv_handle);
|
||||
conn_handle = sys_le16_to_cpu(evt->conn_handle);
|
||||
|
||||
BT_DBG("status 0x%02x adv_handle %u conn_handle 0x%02x num %u",
|
||||
evt->status, evt->adv_handle, conn_handle,
|
||||
evt->num_completed_ext_adv_evts);
|
||||
|
||||
if (!adv) {
|
||||
BT_ERR("No valid adv");
|
||||
return;
|
||||
}
|
||||
|
||||
(void)bt_le_lim_adv_cancel_timeout(adv);
|
||||
|
||||
#if (CONFIG_BT_ID_MAX > 1) && (CONFIG_BT_EXT_ADV_MAX_ADV_SET > 1)
|
||||
was_adv_enabled = atomic_test_bit(adv->flags, BT_ADV_ENABLED);
|
||||
#endif
|
||||
|
||||
atomic_clear_bit(adv->flags, BT_ADV_ENABLED);
|
||||
|
||||
#if (CONFIG_BT_ID_MAX > 1) && (CONFIG_BT_EXT_ADV_MAX_ADV_SET > 1)
|
||||
bt_dev.adv_conn_id = adv->id;
|
||||
for (int i = 0; i < ARRAY_SIZE(bt_dev.cached_conn_complete); i++) {
|
||||
if (bt_dev.cached_conn_complete[i].valid &&
|
||||
bt_dev.cached_conn_complete[i].evt.handle == evt->conn_handle) {
|
||||
if (atomic_test_bit(adv->flags, BT_ADV_ENABLED)) {
|
||||
if (was_adv_enabled) {
|
||||
/* Process the cached connection complete event
|
||||
* now that the corresponding advertising set is known.
|
||||
*
|
||||
|
@ -1926,17 +1945,6 @@ void bt_hci_le_adv_set_terminated(struct net_buf *buf)
|
|||
}
|
||||
#endif
|
||||
|
||||
BT_DBG("status 0x%02x adv_handle %u conn_handle 0x%02x num %u",
|
||||
evt->status, evt->adv_handle, conn_handle,
|
||||
evt->num_completed_ext_adv_evts);
|
||||
|
||||
if (!adv) {
|
||||
BT_ERR("No valid adv");
|
||||
return;
|
||||
}
|
||||
|
||||
atomic_clear_bit(adv->flags, BT_ADV_ENABLED);
|
||||
|
||||
if (evt->status && IS_ENABLED(CONFIG_BT_PERIPHERAL) &&
|
||||
atomic_test_bit(adv->flags, BT_ADV_CONNECTABLE)) {
|
||||
/* Only set status for legacy advertising API.
|
||||
|
|
Loading…
Reference in a new issue