Skip to content

Commit fef81a2

Browse files
bounce scan timeout of the queue
1 parent b29b55a commit fef81a2

File tree

2 files changed

+28
-10
lines changed

2 files changed

+28
-10
lines changed

features/FEATURE_BLE/ble/generic/GenericGap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ class GenericGap :
782782
);
783783

784784
void on_scan_timeout_();
785-
785+
void process_legacy_scan_timeout();
786786

787787
private:
788788
pal::EventQueue &_event_queue;

features/FEATURE_BLE/source/generic/GenericGap.tpp

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1605,21 +1605,38 @@ void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
16051605
return;
16061606
}
16071607

1608+
_scan_enabled = false;
1609+
16081610
/* if timeout happened on a 4.2 chip we need to stop the scan manually */
16091611
if (!is_extended_advertising_available()) {
1610-
_pal_gap.scan_enable(false, false);
1611-
#if BLE_FEATURE_PRIVACY
1612-
set_random_address_rotation(false);
1613-
#endif
1612+
_event_queue.post(
1613+
mbed::callback(
1614+
this,
1615+
&GenericGap<
1616+
PalGapImpl,
1617+
PalSecurityManager,
1618+
ConnectionEventMonitorEventHandler
1619+
>::process_legacy_scan_timeout
1620+
)
1621+
);
1622+
} else {
1623+
if (_eventHandler) {
1624+
_eventHandler->onScanTimeout(ScanTimeoutEvent());
1625+
}
16141626
}
1627+
}
16151628

1616-
_scan_enabled = false;
1629+
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
1630+
void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::process_legacy_scan_timeout()
1631+
{
1632+
_pal_gap.scan_enable(false, false);
1633+
#if BLE_FEATURE_PRIVACY
1634+
set_random_address_rotation(false);
1635+
#endif
16171636

1618-
if (!_eventHandler) {
1619-
return;
1637+
if (_eventHandler) {
1638+
_eventHandler->onScanTimeout(ScanTimeoutEvent());
16201639
}
1621-
1622-
_eventHandler->onScanTimeout(ScanTimeoutEvent());
16231640
}
16241641

16251642
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
@@ -3263,6 +3280,7 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
32633280

32643281
_scan_timeout.detach();
32653282
if (duration.value()) {
3283+
/**/
32663284
_scan_timeout.attach_us(
32673285
mbed::callback(this, &GenericGap::on_scan_timeout_),
32683286
microsecond_t(duration).value()

0 commit comments

Comments
 (0)