Skip to content

Commit 5371a45

Browse files
rymanluksjanc
authored andcommitted
nimble/ll: Fix restarting RX on wfr while scanning
With this patch we move restarting RX on wfr while scanning to interrupt context instead of LL context. It is because we want to restart RX as fast as possible while scanning. Also previous ble_phy_restart_rx call in LL context during interrupts enabled was incorrect.
1 parent a7ebf29 commit 5371a45

File tree

1 file changed

+37
-2
lines changed

1 file changed

+37
-2
lines changed

nimble/controller/src/ble_ll_scan.c

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,7 +1392,6 @@ ble_ll_scan_interrupted_event_cb(struct ble_npl_event *ev)
13921392
}
13931393

13941394
ble_ll_scan_chk_resume();
1395-
ble_phy_restart_rx();
13961395
}
13971396

13981397
/**
@@ -2512,9 +2511,45 @@ void
25122511
ble_ll_scan_wfr_timer_exp(void)
25132512
{
25142513
struct ble_ll_scan_sm *scansm;
2514+
uint8_t chan;
2515+
int phy;
2516+
int rc;
2517+
#if (BLE_LL_BT5_PHY_SUPPORTED == 1)
2518+
uint8_t phy_mode;
2519+
#endif
25152520

25162521
scansm = &g_ble_ll_scan_sm;
2517-
ble_ll_scan_interrupted(scansm);
2522+
if (scansm->cur_aux_data) {
2523+
/* We actually care about interrupted scan only for EXT ADV because only
2524+
* then we might consider to send truncated event to the host.
2525+
*/
2526+
ble_ll_scan_interrupted(scansm);
2527+
2528+
/* Need to disable phy since we are going to move to BLE_LL_STATE_STANDBY
2529+
* or we will need to change channel to primary one
2530+
*/
2531+
ble_phy_disable();
2532+
2533+
if (ble_ll_scan_window_chk(scansm, os_cputime_get32()) == 1) {
2534+
/* Outside the window scan */
2535+
ble_ll_state_set(BLE_LL_STATE_STANDBY);
2536+
return;
2537+
}
2538+
2539+
ble_ll_get_chan_to_scan(scansm, &chan, &phy);
2540+
#if (BLE_LL_BT5_PHY_SUPPORTED == 1)
2541+
phy_mode = ble_ll_phy_to_phy_mode(phy, BLE_HCI_LE_PHY_CODED_ANY);
2542+
ble_phy_mode_set(phy_mode, phy_mode);
2543+
#endif
2544+
rc = ble_phy_setchan(chan, BLE_ACCESS_ADDR_ADV, BLE_LL_CRCINIT_ADV);
2545+
BLE_LL_ASSERT(rc == 0);
2546+
}
2547+
2548+
if (scansm->scan_rsp_pending) {
2549+
ble_ll_scan_req_backoff(scansm, 0);
2550+
}
2551+
2552+
ble_phy_restart_rx();
25182553
}
25192554

25202555
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV)

0 commit comments

Comments
 (0)