Skip to content

Commit cab0b0c

Browse files
authored
Merge pull request #13582 from pan-/ble-privacy-scanning-initiating
Ble privacy scanning initiating
2 parents a8e3694 + aeba089 commit cab0b0c

File tree

5 files changed

+312
-90
lines changed

5 files changed

+312
-90
lines changed

connectivity/FEATURE_BLE/source/cordio/source/PalGapImpl.cpp

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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;

connectivity/FEATURE_BLE/source/cordio/source/PalGapImpl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,7 @@ class PalGap final : public ble::PalGap {
535535
uint8_t extended_scan_type[3];
536536
phy_set_t scanning_phys;
537537
direct_adv_cb_t direct_adv_cb[DM_NUM_ADV_SETS];
538+
bool ext_scan_stopping = false;
538539

539540
/**
540541
* Callback called when an event is emitted by the LE subsystem.

0 commit comments

Comments
 (0)