mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #9549 from paul-szczepanek-arm/fix-scan-timeout
BLE: fix missing scan timeout for 4.2 controllers using new APIpull/9572/head
commit
94baadfc34
|
@ -570,31 +570,28 @@ ble_error_t GenericGap::stopScan()
|
|||
{
|
||||
ble_error_t err;
|
||||
|
||||
if (!_scan_enabled) {
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
_scan_enabled = false;
|
||||
|
||||
if (is_extended_advertising_available()) {
|
||||
if (!_scan_enabled) {
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
_scan_enabled = false;
|
||||
|
||||
err = _pal_gap.extended_scan_enable(false, pal::duplicates_filter_t::DISABLE, 0, 0);
|
||||
|
||||
if (err) {
|
||||
_scan_enabled = true;
|
||||
return err;
|
||||
}
|
||||
} else {
|
||||
err = _pal_gap.scan_enable(false, false);
|
||||
}
|
||||
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
if (err) {
|
||||
_scan_enabled = true;
|
||||
return err;
|
||||
}
|
||||
|
||||
// Stop address rotation if required
|
||||
set_random_address_rotation(false);
|
||||
|
||||
_scan_timeout.detach();
|
||||
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
|
@ -1210,6 +1207,8 @@ ble_error_t GenericGap::startRadioScan(const GapScanningParams &scanningParams)
|
|||
return err;
|
||||
}
|
||||
|
||||
_scan_enabled = true;
|
||||
|
||||
_scan_timeout.detach();
|
||||
uint16_t timeout = scanningParams.getTimeout();
|
||||
if (timeout) {
|
||||
|
@ -1488,6 +1487,12 @@ void GenericGap::on_scan_timeout()
|
|||
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);
|
||||
}
|
||||
|
||||
_scan_enabled = false;
|
||||
|
||||
if (!_eventHandler) {
|
||||
|
@ -2969,8 +2974,6 @@ ble_error_t GenericGap::startScan(
|
|||
}
|
||||
|
||||
if (is_extended_advertising_available()) {
|
||||
_scan_enabled = true;
|
||||
|
||||
ble_error_t err = _pal_gap.extended_scan_enable(
|
||||
/* enable */true,
|
||||
filtering,
|
||||
|
@ -2979,7 +2982,6 @@ ble_error_t GenericGap::startScan(
|
|||
);
|
||||
|
||||
if (err) {
|
||||
_scan_enabled = false;
|
||||
return err;
|
||||
}
|
||||
} else {
|
||||
|
@ -3005,6 +3007,8 @@ ble_error_t GenericGap::startScan(
|
|||
}
|
||||
}
|
||||
|
||||
_scan_enabled = true;
|
||||
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue