From ebede3d40189b43f23755fba58e2875e6adddf61 Mon Sep 17 00:00:00 2001 From: Lingkai Dong Date: Wed, 5 Jun 2019 09:40:31 +0100 Subject: [PATCH] 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. --- .../FEATURE_BLE/source/generic/GenericGap.tpp | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/features/FEATURE_BLE/source/generic/GenericGap.tpp b/features/FEATURE_BLE/source/generic/GenericGap.tpp index 0d0e4005cc..1009552105 100644 --- a/features/FEATURE_BLE/source/generic/GenericGap.tpp +++ b/features/FEATURE_BLE/source/generic/GenericGap.tpp @@ -457,17 +457,6 @@ GenericGap:: _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 class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler> @@ -3470,7 +3459,19 @@ void GenericGap(this)->is_extended_advertising_available()) { + const_cast(this)->setExtendedAdvertisingParameters( + LEGACY_ADVERTISING_HANDLE, + AdvertisingParameters() + ); + } + const_cast*>(&_existing_sets)->set(LEGACY_ADVERTISING_HANDLE); +#endif + } + } template class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>