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>