@@ -683,16 +683,37 @@ void PalGap::gap_handler(const wsfMsgHdr_t *msg)
683683 } break ;
684684#endif // BLE_FEATURE_EXTENDED_ADVERTISING && BLE_ROLE_BROADCASTER
685685
686- #if BLE_FEATURE_EXTENDED_ADVERTISING && BLE_ROLE_OBSERVER
686+ #if BLE_ROLE_OBSERVER
687+ case DM_SCAN_START_IND:
688+ if (!handler) { break ; }
689+ handler->on_scan_started (msg->status == HCI_SUCCESS);
690+ break ;
691+
692+ case DM_SCAN_STOP_IND:
693+ if (!handler) { break ; }
694+ handler->on_scan_stopped (msg->status == HCI_SUCCESS);
695+ break ;
696+
697+ #if BLE_FEATURE_EXTENDED_ADVERTISING
698+ case DM_EXT_SCAN_START_IND:
699+ if (!handler) { break ; }
700+ handler->on_scan_started (msg->status == HCI_SUCCESS);
701+ break ;
702+
687703 case DM_EXT_SCAN_STOP_IND: {
688704 if (!handler) {
705+ get_gap ().ext_scan_stopping = false ;
689706 break ;
690707 }
691708
692- // const hciLeScanTimeoutEvt_t *evt = (const hciLeScanTimeoutEvt_t *) msg;
693- handler->on_scan_timeout ();
694- }
695- break ;
709+ if (get_gap ().ext_scan_stopping ) {
710+ get_gap ().ext_scan_stopping = false ;
711+ handler->on_scan_stopped (msg->status == HCI_SUCCESS);
712+ } else {
713+ handler->on_scan_timeout ();
714+ }
715+
716+ } break ;
696717
697718 case DM_EXT_SCAN_REPORT_IND: {
698719 if (!handler) {
@@ -718,9 +739,9 @@ void PalGap::gap_handler(const wsfMsgHdr_t *msg)
718739 evt->len ,
719740 evt->pData
720741 );
721- }
722- break ;
723- #endif // BLE_FEATURE_EXTENDED_ADVERTISING && BLE_ROLE_OBSERVER
742+ } break ;
743+ # endif // BLE_FEATURE_EXTENDED_ADVERTISING
744+ #endif // BLE_ROLE_OBSERVER
724745
725746#if BLE_ROLE_CENTRAL || BLE_ROLE_PERIPHERAL
726747 case DM_REM_CONN_PARAM_REQ_IND: {
@@ -1243,6 +1264,7 @@ ble_error_t PalGap::extended_scan_enable(
12431264 if (enable) {
12441265 uint32_t duration_ms = duration * 10 ;
12451266
1267+
12461268 DmScanStart (
12471269 scanning_phys.value (),
12481270 DM_DISC_MODE_NONE,
@@ -1253,6 +1275,7 @@ ble_error_t PalGap::extended_scan_enable(
12531275 );
12541276 } else {
12551277 DmScanStop ();
1278+ ext_scan_stopping = true ;
12561279 }
12571280
12581281 return BLE_ERROR_NONE;
0 commit comments