Merge pull request #10219 from paul-szczepanek-arm/fix-legacy-scan-timeout

BLE: fix scan timeout being called from interrupt
pull/9995/head
Cruz Monrreal 2019-03-27 13:35:06 -05:00 committed by GitHub
commit 4cdc3b7cb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 12 deletions

View File

@ -782,7 +782,7 @@ private:
);
void on_scan_timeout_();
void process_legacy_scan_timeout();
private:
pal::EventQueue &_event_queue;

View File

@ -1605,21 +1605,36 @@ void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
return;
}
/* if timeout happened on a 4.2 chip we need to stop the scan manually */
if (!is_extended_advertising_available()) {
_pal_gap.scan_enable(false, false);
#if BLE_FEATURE_PRIVACY
set_random_address_rotation(false);
#endif
}
_scan_enabled = false;
if (!_eventHandler) {
return;
if (!is_extended_advertising_available()) {
/* if timeout happened on a 4.2 chip this means legacy scanning and a timer timeout
* but we need to handle the event from user context - use the event queue to handle it */
_event_queue.post(
mbed::callback(
this,
&GenericGap::process_legacy_scan_timeout
)
);
} else {
if (_eventHandler) {
_eventHandler->onScanTimeout(ScanTimeoutEvent());
}
}
}
_eventHandler->onScanTimeout(ScanTimeoutEvent());
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::process_legacy_scan_timeout()
{
/* legacy scanning timed out is based on timer so we need to stop the scan manually */
_pal_gap.scan_enable(false, false);
#if BLE_FEATURE_PRIVACY
set_random_address_rotation(false);
#endif
if (_eventHandler) {
_eventHandler->onScanTimeout(ScanTimeoutEvent());
}
}
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>