Skip to content

Commit

Permalink
Merge pull request ARMmbed#14264 from paul-szczepanek-arm/fix-termina…
Browse files Browse the repository at this point in the history
…te-sync

BLE: fix termination of periodic advertising sync
  • Loading branch information
0xc0170 committed Feb 12, 2021
2 parents d041654 + 938aeda commit 3174a4c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
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

0 comments on commit 3174a4c

Please sign in to comment.