Skip to content

BLE: fix termination of periodic advertising sync #14264

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion connectivity/FEATURE_BLE/source/cordio/source/PalGapImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
}
}
Expand Down
4 changes: 4 additions & 0 deletions connectivity/FEATURE_BLE/source/cordio/source/PalGapImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down