Skip to content

Commit 42dbcbd

Browse files
authored
Merge pull request #10772 from LDong-Arm/GenericGap_advParams
Workarounds for GAP advertising issues on Cordio
2 parents 3c2dd9c + 6165204 commit 42dbcbd

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

features/FEATURE_BLE/source/generic/GenericGap.tpp

Lines changed: 24 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>
@@ -1435,6 +1424,17 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
14351424
return err;
14361425
}
14371426

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+
14381438
err = _pal_gap.advertising_enable(true);
14391439
if (err) {
14401440
return err;
@@ -3470,7 +3470,19 @@ void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
34703470
if (_deprecated_scan_api_used) {
34713471
MBED_ERROR(mixed_scan_api_error, "Use of up to date scan API with deprecated API");
34723472
}
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+
34743486
}
34753487

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

0 commit comments

Comments
 (0)