diff --git a/features/FEATURE_BLE/source/generic/GenericGap.cpp b/features/FEATURE_BLE/source/generic/GenericGap.cpp index 819857c684..fa9954c191 100644 --- a/features/FEATURE_BLE/source/generic/GenericGap.cpp +++ b/features/FEATURE_BLE/source/generic/GenericGap.cpp @@ -1480,16 +1480,16 @@ BLE_DEPRECATED_API_USE_END() void GenericGap::on_scan_timeout() { + if (!_scan_enabled) { + 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); set_random_address_rotation(false); } - if (!_scan_enabled) { - return; - } - _scan_enabled = false; if (!_eventHandler) {