Set extended advertising parameters upon first use of API v2

Previously, extended advertising parameters failed to be set
during BLE initialisation when the stack was not ready.

To work around this, we delay it to the first use of
useVersionTwoAPI.
pull/10952/head
Lingkai Dong 2019-06-05 09:40:31 +01:00 committed by Arto Kinnunen
parent 27e0944cec
commit ebede3d401
1 changed files with 13 additions and 12 deletions

View File

@ -457,17 +457,6 @@ GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::
_random_static_identity_address = _pal_gap.get_random_address();
_pal_gap.set_event_handler(this);
#if BLE_FEATURE_EXTENDED_ADVERTISING
if (is_extended_advertising_available()) {
setExtendedAdvertisingParameters(
LEGACY_ADVERTISING_HANDLE,
AdvertisingParameters()
);
}
_existing_sets.set(LEGACY_ADVERTISING_HANDLE);
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
}
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
@ -3470,7 +3459,19 @@ void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
if (_deprecated_scan_api_used) {
MBED_ERROR(mixed_scan_api_error, "Use of up to date scan API with deprecated API");
}
_non_deprecated_scan_api_used = true;
if (!_non_deprecated_scan_api_used) {
_non_deprecated_scan_api_used = true;
#if BLE_FEATURE_EXTENDED_ADVERTISING
if (const_cast<GenericGap*>(this)->is_extended_advertising_available()) {
const_cast<GenericGap*>(this)->setExtendedAdvertisingParameters(
LEGACY_ADVERTISING_HANDLE,
AdvertisingParameters()
);
}
const_cast<BitArray<MAX_ADVERTISING_SETS>*>(&_existing_sets)->set(LEGACY_ADVERTISING_HANDLE);
#endif
}
}
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>