Skip to content

Commit

Permalink
[nrf fromtree] Bluetooth: host: Fix advertise stop in adv_timeout()
Browse files Browse the repository at this point in the history
Call bt_le_adv_stop() if adv == bt_dev.adv (Meaning it is the legacy
advertiser and was started with bt_le_adv_start()), otherwise use
bt_le_ext_adv_stop(), because it was started with bt_le_ext_adv_start().

Failing to stop advertising shouldn't result in assert.

Signed-off-by: Michał Narajowski <[email protected]>
(cherry picked from commit cca76f1)
Signed-off-by: Martin Tverdal <[email protected]>
  • Loading branch information
Michał Narajowski authored and carlescufi committed Oct 26, 2021
1 parent b3440b1 commit 553ff26
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions subsys/bluetooth/host/adv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1367,12 +1367,15 @@ static void adv_timeout(struct k_work *work)
dwork = k_work_delayable_from_work(work);
adv = CONTAINER_OF(dwork, struct bt_le_ext_adv, timeout_work);

err = bt_le_ext_adv_stop(adv);
if (adv == bt_dev.adv) {
err = bt_le_adv_stop();
} else {
err = bt_le_ext_adv_stop(adv);
}
#else
err = bt_le_adv_stop();
#endif
__ASSERT(err == 0, "Limited Advertising timeout reached, "
"failed to stop advertising");
BT_WARN("Failed to stop advertising: %d", err);
}

#if defined(CONFIG_BT_PER_ADV)
Expand Down

0 comments on commit 553ff26

Please sign in to comment.