Skip to content

Commit c74fe1f

Browse files
cvinayakcfriedt
authored andcommitted
Bluetooth: Controller: Fix scan window resume after extended scan
Fix implementation to not to put back the primary channel scanning to resume state when Extended Scan has used ULL scheduling which pre-empts the scan window. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent 72e3bfe commit c74fe1f

File tree

1 file changed

+27
-11
lines changed
  • subsys/bluetooth/controller/ll_sw/nordic/lll

1 file changed

+27
-11
lines changed

subsys/bluetooth/controller/ll_sw/nordic/lll/lll_scan.c

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -501,34 +501,50 @@ static int is_abort_cb(void *next, void *curr, lll_prepare_cb_t *resume_cb)
501501
{
502502
struct lll_scan *lll = curr;
503503

504-
/* TODO: check prio */
504+
/* Check if pre-emption by a different state/role radio event */
505505
if (next != curr) {
506506
#if defined(CONFIG_BT_CTLR_ADV_EXT)
507+
/* Resume not to be used if duration being used */
507508
if (unlikely(!lll->duration_reload || lll->duration_expire))
508509
#endif /* CONFIG_BT_CTLR_ADV_EXT */
509510
{
510-
int err;
511-
512-
/* wrap back after the pre-empter */
513-
*resume_cb = resume_prepare_cb;
514-
515-
/* Retain HF clock */
516-
err = lll_hfclock_on();
517-
LL_ASSERT(err >= 0);
511+
/* Put back to resume state for continuous scanning */
512+
if (!lll->ticks_window) {
513+
int err;
514+
515+
/* Set the resume prepare function to use for
516+
* resumption after the pre-emptor is done.
517+
*/
518+
*resume_cb = resume_prepare_cb;
519+
520+
/* Retain HF clock */
521+
err = lll_hfclock_on();
522+
LL_ASSERT(err >= 0);
523+
524+
/* Yield to the pre-emptor, but be
525+
* resumed thereafter.
526+
*/
527+
return -EAGAIN;
528+
}
518529

519-
return -EAGAIN;
530+
/* Yield to the pre-emptor */
531+
return -ECANCELED;
520532
}
521533
}
522534

523535
if (0) {
524536
#if defined(CONFIG_BT_CTLR_ADV_EXT)
525537
} else if (unlikely(lll->duration_reload && !lll->duration_expire)) {
538+
/* Duration expired, do not continue, close and generate
539+
* done event.
540+
*/
526541
radio_isr_set(isr_done_cleanup, lll);
527542
} else if (lll->is_aux_sched) {
528-
/* as a continuous scanner, let us not abort aux PDU scan */
543+
/* Do not abort LLL scheduled auxiliary PDU scan */
529544
return 0;
530545
#endif /* CONFIG_BT_CTLR_ADV_EXT */
531546
} else {
547+
/* Switch scan window to next radio channel */
532548
radio_isr_set(isr_window, lll);
533549
}
534550

0 commit comments

Comments
 (0)