diff --git a/nimble/controller/src/ble_ll_scan.c b/nimble/controller/src/ble_ll_scan.c index d9d351786..27f1e65a7 100644 --- a/nimble/controller/src/ble_ll_scan.c +++ b/nimble/controller/src/ble_ll_scan.c @@ -880,10 +880,6 @@ ble_ll_scan_sm_stop(int chk_disable) OS_ENTER_CRITICAL(sr); -#if MYNEWT_VAL(BLE_LL_ROLE_CENTRAL) - scansm->connsm = NULL; -#endif - /* Disable scanning state machine */ scansm->scan_enabled = 0; scansm->restart_timer_needed = 0; @@ -895,6 +891,10 @@ ble_ll_scan_sm_stop(int chk_disable) } #endif +#if MYNEWT_VAL(BLE_LL_ROLE_CENTRAL) + scansm->connsm = NULL; +#endif + /* Update backoff if we failed to receive scan response */ if (scansm->scan_rsp_pending) { scansm->scan_rsp_pending = 0; diff --git a/nimble/controller/src/ble_ll_scan_aux.c b/nimble/controller/src/ble_ll_scan_aux.c index 2eb915d0e..2967083b2 100644 --- a/nimble/controller/src/ble_ll_scan_aux.c +++ b/nimble/controller/src/ble_ll_scan_aux.c @@ -1237,7 +1237,10 @@ ble_ll_scan_aux_rx_isr_end(struct os_mbuf *rxpdu, uint8_t crcok) rxinfo = &rxhdr->rxinfo; rxinfo->user_data = aux; - if (!crcok) { + /* It's possible that we received aux while scan was just being disabled in + * LL task. In such case simply ignore aux. + */ + if (!crcok || !ble_ll_scan_enabled()) { rxinfo->flags |= BLE_MBUF_HDR_F_IGNORED; goto done; }