Skip to content

Commit 449d0b2

Browse files
cvinayakcarlescufi
authored andcommitted
Bluetooth: Controller: Fix extended advertising timeout
Fix extended advertising PDUs seen after the advertising duration has elapsed, by considering the events skipped due to overlap with other events which is provided by the ticker lazy parameter. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent 5659b00 commit 449d0b2

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

subsys/bluetooth/controller/ll_sw/ull_adv.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1657,7 +1657,7 @@ void ull_adv_done(struct node_rx_event_done *done)
16571657
rx_hdr = (void *)lll->node_rx_adv_term;
16581658
rx_hdr->rx_ftr.param_adv_term.status = BT_HCI_ERR_LIMIT_REACHED;
16591659
} else if (adv->ticks_remain_duration &&
1660-
(adv->ticks_remain_duration <
1660+
(adv->ticks_remain_duration <=
16611661
HAL_TICKER_US_TO_TICKS((uint64_t)adv->interval *
16621662
ADV_INT_UNIT_US))) {
16631663
adv->ticks_remain_duration = 0;
@@ -1933,13 +1933,17 @@ static void ticker_cb(uint32_t ticks_at_expire, uint32_t remainder, uint16_t laz
19331933
uint32_t ticks_interval =
19341934
HAL_TICKER_US_TO_TICKS((uint64_t)adv->interval *
19351935
ADV_INT_UNIT_US);
1936-
if (adv->ticks_remain_duration > ticks_interval) {
1937-
adv->ticks_remain_duration -= ticks_interval;
1936+
uint32_t ticks_elapsed = ticks_interval * (lazy + 1);
1937+
1938+
if (adv->ticks_remain_duration > ticks_elapsed) {
1939+
adv->ticks_remain_duration -= ticks_elapsed;
19381940

19391941
if (adv->ticks_remain_duration > random_delay) {
19401942
adv->ticks_remain_duration -=
19411943
random_delay;
19421944
}
1945+
} else {
1946+
adv->ticks_remain_duration = ticks_interval;
19431947
}
19441948
}
19451949
#endif /* CONFIG_BT_CTLR_ADV_EXT */

0 commit comments

Comments
 (0)