Skip to content

Commit cca76f1

Browse files
Michał Narajowskicarlescufi
authored andcommitted
Bluetooth: host: Fix advertise stop in adv_timeout()
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]>
1 parent a614fc0 commit cca76f1

File tree

1 file changed

+6
-3
lines changed
  • subsys/bluetooth/host

1 file changed

+6
-3
lines changed

subsys/bluetooth/host/adv.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1413,12 +1413,15 @@ static void adv_timeout(struct k_work *work)
14131413
dwork = k_work_delayable_from_work(work);
14141414
adv = CONTAINER_OF(dwork, struct bt_le_ext_adv, timeout_work);
14151415

1416-
err = bt_le_ext_adv_stop(adv);
1416+
if (adv == bt_dev.adv) {
1417+
err = bt_le_adv_stop();
1418+
} else {
1419+
err = bt_le_ext_adv_stop(adv);
1420+
}
14171421
#else
14181422
err = bt_le_adv_stop();
14191423
#endif
1420-
__ASSERT(err == 0, "Limited Advertising timeout reached, "
1421-
"failed to stop advertising");
1424+
BT_WARN("Failed to stop advertising: %d", err);
14221425
}
14231426

14241427
#if defined(CONFIG_BT_PER_ADV)

0 commit comments

Comments
 (0)