Skip to content

Commit f78364c

Browse files
committed
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.
1 parent 2b354a4 commit f78364c

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

features/FEATURE_BLE/source/generic/GenericGap.tpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -457,17 +457,6 @@ GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::
457457
_random_static_identity_address = _pal_gap.get_random_address();
458458

459459
_pal_gap.set_event_handler(this);
460-
461-
#if BLE_FEATURE_EXTENDED_ADVERTISING
462-
if (is_extended_advertising_available()) {
463-
setExtendedAdvertisingParameters(
464-
LEGACY_ADVERTISING_HANDLE,
465-
AdvertisingParameters()
466-
);
467-
}
468-
469-
_existing_sets.set(LEGACY_ADVERTISING_HANDLE);
470-
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
471460
}
472461

473462
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
@@ -3470,7 +3459,19 @@ void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
34703459
if (_deprecated_scan_api_used) {
34713460
MBED_ERROR(mixed_scan_api_error, "Use of up to date scan API with deprecated API");
34723461
}
3473-
_non_deprecated_scan_api_used = true;
3462+
if (!_non_deprecated_scan_api_used) {
3463+
_non_deprecated_scan_api_used = true;
3464+
#if BLE_FEATURE_EXTENDED_ADVERTISING
3465+
if (const_cast<GenericGap*>(this)->is_extended_advertising_available()) {
3466+
const_cast<GenericGap*>(this)->setExtendedAdvertisingParameters(
3467+
LEGACY_ADVERTISING_HANDLE,
3468+
AdvertisingParameters()
3469+
);
3470+
}
3471+
const_cast<BitArray<MAX_ADVERTISING_SETS>*>(&_existing_sets)->set(LEGACY_ADVERTISING_HANDLE);
3472+
#endif
3473+
}
3474+
34743475
}
34753476

34763477
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>

0 commit comments

Comments
 (0)