From 938aedac9165c7720db3565a62690f1af33fa9df Mon Sep 17 00:00:00 2001 From: Paul Szczepanek Date: Wed, 10 Feb 2021 11:57:30 +0000 Subject: [PATCH] use the correct id to identify sync --- .../FEATURE_BLE/source/cordio/source/PalGapImpl.cpp | 8 +++++++- .../FEATURE_BLE/source/cordio/source/PalGapImpl.h | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/connectivity/FEATURE_BLE/source/cordio/source/PalGapImpl.cpp b/connectivity/FEATURE_BLE/source/cordio/source/PalGapImpl.cpp index eac7ad7710d..411ea8da64d 100644 --- a/connectivity/FEATURE_BLE/source/cordio/source/PalGapImpl.cpp +++ b/connectivity/FEATURE_BLE/source/cordio/source/PalGapImpl.cpp @@ -32,6 +32,9 @@ bool dummy_gap_event_handler(const wsfMsgHdr_t *msg) } } +#if BLE_FEATURE_PERIODIC_ADVERTISING && BLE_ROLE_OBSERVER +sync_handle_t PalGap::_pending_periodic_sync_handle = 0; +#endif bool PalGap::is_feature_supported( ble::controller_supported_features_t feature @@ -592,7 +595,8 @@ void PalGap::gap_handler(const wsfMsgHdr_t *msg) handler->on_periodic_advertising_sync_established( hci_error_code_t(evt->status), - evt->syncHandle, + /* the Cordio host stack uses a different ID to identify the control block */ + _pending_periodic_sync_handle, evt->advSid, connection_peer_address_type_t(evt->advAddrType), evt->advAddr, @@ -1343,6 +1347,8 @@ ble_error_t PalGap::periodic_advertising_create_sync( if (sync_id == DM_SYNC_ID_NONE) { return BLE_ERROR_INTERNAL_STACK_FAILURE; } else { + /* this is not the real handle, this is CORDIO internal handle but the user doesn't need to know that */ + _pending_periodic_sync_handle = sync_id; return BLE_ERROR_NONE; } } diff --git a/connectivity/FEATURE_BLE/source/cordio/source/PalGapImpl.h b/connectivity/FEATURE_BLE/source/cordio/source/PalGapImpl.h index a78868e8397..6348cb370d3 100644 --- a/connectivity/FEATURE_BLE/source/cordio/source/PalGapImpl.h +++ b/connectivity/FEATURE_BLE/source/cordio/source/PalGapImpl.h @@ -566,6 +566,10 @@ class PalGap final : public ble::PalGap { } private: +#if BLE_FEATURE_PERIODIC_ADVERTISING && BLE_ROLE_OBSERVER + /* must be static because is needed in a static handler, there can only be one sync in progress */ + static sync_handle_t _pending_periodic_sync_handle; +#endif PalGapEventHandler *_pal_event_handler; address_t device_random_address; bool use_active_scanning;