From f78364cb5a5e437ebcbf0f30638fa5a51219ee02 Mon Sep 17 00:00:00 2001 From: Lingkai Dong Date: Wed, 5 Jun 2019 09:40:31 +0100 Subject: [PATCH 1/2] 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> From 6165204b1537d50c3d089dba16ebd17c31162813 Mon Sep 17 00:00:00 2001 From: Lingkai Dong Date: Wed, 5 Jun 2019 14:59:20 +0100 Subject: [PATCH 2/2] Workaround for legacy GAP advertising issue on Cordio LL Due to some issue in Cordio link layer, advertising data does not take effect unless we set it (or set it again) after advertising parameters are set. --- features/FEATURE_BLE/source/generic/GenericGap.tpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/features/FEATURE_BLE/source/generic/GenericGap.tpp b/features/FEATURE_BLE/source/generic/GenericGap.tpp index 1009552105..3c991ecd23 100644 --- a/features/FEATURE_BLE/source/generic/GenericGap.tpp +++ b/features/FEATURE_BLE/source/generic/GenericGap.tpp @@ -1424,6 +1424,17 @@ ble_error_t GenericGap_advPayload, this->_scanResponse); + if (err) { + return err; + } +#endif + err = _pal_gap.advertising_enable(true); if (err) { return err;