Skip to content

Commit

Permalink
Merge pull request #13582 from pan-/ble-privacy-scanning-initiating
Browse files Browse the repository at this point in the history
Ble privacy scanning initiating
  • Loading branch information
pan- authored Sep 10, 2020
2 parents a8e3694 + aeba089 commit cab0b0c
Show file tree
Hide file tree
Showing 5 changed files with 312 additions and 90 deletions.
39 changes: 31 additions & 8 deletions connectivity/FEATURE_BLE/source/cordio/source/PalGapImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -683,16 +683,37 @@ void PalGap::gap_handler(const wsfMsgHdr_t *msg)
} break;
#endif // BLE_FEATURE_EXTENDED_ADVERTISING && BLE_ROLE_BROADCASTER

#if BLE_FEATURE_EXTENDED_ADVERTISING && BLE_ROLE_OBSERVER
#if BLE_ROLE_OBSERVER
case DM_SCAN_START_IND:
if (!handler) { break; }
handler->on_scan_started(msg->status == HCI_SUCCESS);
break;

case DM_SCAN_STOP_IND:
if (!handler) { break; }
handler->on_scan_stopped(msg->status == HCI_SUCCESS);
break;

#if BLE_FEATURE_EXTENDED_ADVERTISING
case DM_EXT_SCAN_START_IND:
if (!handler) { break; }
handler->on_scan_started(msg->status == HCI_SUCCESS);
break;

case DM_EXT_SCAN_STOP_IND: {
if (!handler) {
get_gap().ext_scan_stopping = false;
break;
}

//const hciLeScanTimeoutEvt_t *evt = (const hciLeScanTimeoutEvt_t *) msg;
handler->on_scan_timeout();
}
break;
if (get_gap().ext_scan_stopping) {
get_gap().ext_scan_stopping = false;
handler->on_scan_stopped(msg->status == HCI_SUCCESS);
} else {
handler->on_scan_timeout();
}

} break;

case DM_EXT_SCAN_REPORT_IND: {
if (!handler) {
Expand All @@ -718,9 +739,9 @@ void PalGap::gap_handler(const wsfMsgHdr_t *msg)
evt->len,
evt->pData
);
}
break;
#endif // BLE_FEATURE_EXTENDED_ADVERTISING && BLE_ROLE_OBSERVER
} break;
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
#endif // BLE_ROLE_OBSERVER

#if BLE_ROLE_CENTRAL || BLE_ROLE_PERIPHERAL
case DM_REM_CONN_PARAM_REQ_IND: {
Expand Down Expand Up @@ -1243,6 +1264,7 @@ ble_error_t PalGap::extended_scan_enable(
if (enable) {
uint32_t duration_ms = duration * 10;


DmScanStart(
scanning_phys.value(),
DM_DISC_MODE_NONE,
Expand All @@ -1253,6 +1275,7 @@ ble_error_t PalGap::extended_scan_enable(
);
} else {
DmScanStop();
ext_scan_stopping = true;
}

return BLE_ERROR_NONE;
Expand Down
1 change: 1 addition & 0 deletions connectivity/FEATURE_BLE/source/cordio/source/PalGapImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,7 @@ class PalGap final : public ble::PalGap {
uint8_t extended_scan_type[3];
phy_set_t scanning_phys;
direct_adv_cb_t direct_adv_cb[DM_NUM_ADV_SETS];
bool ext_scan_stopping = false;

/**
* Callback called when an event is emitted by the LE subsystem.
Expand Down
Loading

0 comments on commit cab0b0c

Please sign in to comment.