mirror of https://github.com/ARMmbed/mbed-os.git
BLE: Add callback for scan started and stoped.
parent
b8549ec91d
commit
d8c6820cbd
|
@ -683,16 +683,34 @@ void PalGap::gap_handler(const wsfMsgHdr_t *msg)
|
||||||
} break;
|
} break;
|
||||||
#endif // BLE_FEATURE_EXTENDED_ADVERTISING && BLE_ROLE_BROADCASTER
|
#endif // BLE_FEATURE_EXTENDED_ADVERTISING && BLE_ROLE_BROADCASTER
|
||||||
|
|
||||||
#if BLE_FEATURE_EXTENDED_ADVERTISING && BLE_ROLE_OBSERVER
|
#if BLE_ROLE_OBSERVER
|
||||||
case DM_EXT_SCAN_STOP_IND: {
|
case DM_SCAN_START_IND:
|
||||||
if (!handler) {
|
if (!handler) { break; }
|
||||||
|
handler->on_scan_started(msg->status == HCI_SUCCESS);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
//const hciLeScanTimeoutEvt_t *evt = (const hciLeScanTimeoutEvt_t *) msg;
|
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) { 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();
|
handler->on_scan_timeout();
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
} break;
|
||||||
|
|
||||||
case DM_EXT_SCAN_REPORT_IND: {
|
case DM_EXT_SCAN_REPORT_IND: {
|
||||||
if (!handler) {
|
if (!handler) {
|
||||||
|
@ -718,9 +736,9 @@ void PalGap::gap_handler(const wsfMsgHdr_t *msg)
|
||||||
evt->len,
|
evt->len,
|
||||||
evt->pData
|
evt->pData
|
||||||
);
|
);
|
||||||
}
|
} break;
|
||||||
break;
|
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
|
||||||
#endif // BLE_FEATURE_EXTENDED_ADVERTISING && BLE_ROLE_OBSERVER
|
#endif // BLE_ROLE_OBSERVER
|
||||||
|
|
||||||
#if BLE_ROLE_CENTRAL || BLE_ROLE_PERIPHERAL
|
#if BLE_ROLE_CENTRAL || BLE_ROLE_PERIPHERAL
|
||||||
case DM_REM_CONN_PARAM_REQ_IND: {
|
case DM_REM_CONN_PARAM_REQ_IND: {
|
||||||
|
@ -1243,6 +1261,7 @@ ble_error_t PalGap::extended_scan_enable(
|
||||||
if (enable) {
|
if (enable) {
|
||||||
uint32_t duration_ms = duration * 10;
|
uint32_t duration_ms = duration * 10;
|
||||||
|
|
||||||
|
|
||||||
DmScanStart(
|
DmScanStart(
|
||||||
scanning_phys.value(),
|
scanning_phys.value(),
|
||||||
DM_DISC_MODE_NONE,
|
DM_DISC_MODE_NONE,
|
||||||
|
@ -1253,6 +1272,7 @@ ble_error_t PalGap::extended_scan_enable(
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
DmScanStop();
|
DmScanStop();
|
||||||
|
ext_scan_stopping = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return BLE_ERROR_NONE;
|
return BLE_ERROR_NONE;
|
||||||
|
|
|
@ -535,6 +535,7 @@ private:
|
||||||
uint8_t extended_scan_type[3];
|
uint8_t extended_scan_type[3];
|
||||||
phy_set_t scanning_phys;
|
phy_set_t scanning_phys;
|
||||||
direct_adv_cb_t direct_adv_cb[DM_NUM_ADV_SETS];
|
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.
|
* Callback called when an event is emitted by the LE subsystem.
|
||||||
|
|
|
@ -1051,6 +1051,14 @@ Gap::GapShutdownCallbackChain_t &Gap::onShutdown()
|
||||||
return shutdownCallChain;
|
return shutdownCallChain;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Gap::on_scan_started(bool success)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Gap::on_scan_stopped(bool success)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Gap::on_scan_timeout()
|
void Gap::on_scan_timeout()
|
||||||
{
|
{
|
||||||
|
|
|
@ -525,6 +525,10 @@ private:
|
||||||
uint16_t supervision_timeout
|
uint16_t supervision_timeout
|
||||||
) override;
|
) override;
|
||||||
|
|
||||||
|
void on_scan_started(bool success) override;
|
||||||
|
|
||||||
|
void on_scan_stopped(bool success) override;
|
||||||
|
|
||||||
void on_scan_timeout() override;
|
void on_scan_timeout() override;
|
||||||
|
|
||||||
void process_legacy_scan_timeout();
|
void process_legacy_scan_timeout();
|
||||||
|
|
|
@ -194,6 +194,17 @@ public:
|
||||||
sync_handle_t sync_handle
|
sync_handle_t sync_handle
|
||||||
) = 0;
|
) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when scanning start
|
||||||
|
*/
|
||||||
|
virtual void on_scan_started(bool success) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when scanning stop
|
||||||
|
*/
|
||||||
|
virtual void on_scan_stopped(bool success) = 0;
|
||||||
|
|
||||||
|
|
||||||
/** Called when scanning times out.
|
/** Called when scanning times out.
|
||||||
*/
|
*/
|
||||||
virtual void on_scan_timeout( ) = 0;
|
virtual void on_scan_timeout( ) = 0;
|
||||||
|
|
Loading…
Reference in New Issue