@@ -457,17 +457,6 @@ GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::
457
457
_random_static_identity_address = _pal_gap.get_random_address ();
458
458
459
459
_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
471
460
}
472
461
473
462
template <template <class > class PalGapImpl , class PalSecurityManager , class ConnectionEventMonitorEventHandler >
@@ -1435,6 +1424,17 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
1435
1424
return err;
1436
1425
}
1437
1426
1427
+ #if defined(TARGET_CORDIO_LL)
1428
+ // TODO: fix advertising set creation in the link layer.
1429
+ // The Cordio link layer implements legacy API on top of extended advertising
1430
+ // and has an issue that no advertising set is created until we set parameters.
1431
+ // As a workaround, set advertising data again to ensure it takes effect.
1432
+ err = setAdvertisingData_ (this ->_advPayload , this ->_scanResponse );
1433
+ if (err) {
1434
+ return err;
1435
+ }
1436
+ #endif
1437
+
1438
1438
err = _pal_gap.advertising_enable (true );
1439
1439
if (err) {
1440
1440
return err;
@@ -3470,7 +3470,19 @@ void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
3470
3470
if (_deprecated_scan_api_used) {
3471
3471
MBED_ERROR (mixed_scan_api_error, " Use of up to date scan API with deprecated API" );
3472
3472
}
3473
- _non_deprecated_scan_api_used = true ;
3473
+ if (!_non_deprecated_scan_api_used) {
3474
+ _non_deprecated_scan_api_used = true ;
3475
+ #if BLE_FEATURE_EXTENDED_ADVERTISING
3476
+ if (const_cast <GenericGap*>(this )->is_extended_advertising_available ()) {
3477
+ const_cast <GenericGap*>(this )->setExtendedAdvertisingParameters (
3478
+ LEGACY_ADVERTISING_HANDLE,
3479
+ AdvertisingParameters ()
3480
+ );
3481
+ }
3482
+ const_cast <BitArray<MAX_ADVERTISING_SETS>*>(&_existing_sets)->set (LEGACY_ADVERTISING_HANDLE);
3483
+ #endif
3484
+ }
3485
+
3474
3486
}
3475
3487
3476
3488
template <template <class > class PalGapImpl , class PalSecurityManager , class ConnectionEventMonitorEventHandler >
0 commit comments