From 62b38cfbc837e5a74dec40598eb54cc8fb08f96c Mon Sep 17 00:00:00 2001 From: paul-szczepanek-arm <33840200+paul-szczepanek-arm@users.noreply.github.com> Date: Sun, 11 Nov 2018 22:15:11 +0000 Subject: [PATCH] connection complete event --- features/FEATURE_BLE/ble/Gap.h | 26 +++++++++++++++++++ .../FEATURE_BLE/source/generic/GenericGap.cpp | 20 +++++++++++--- 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/features/FEATURE_BLE/ble/Gap.h b/features/FEATURE_BLE/ble/Gap.h index 6c70531c15..a9e2b71158 100644 --- a/features/FEATURE_BLE/ble/Gap.h +++ b/features/FEATURE_BLE/ble/Gap.h @@ -1285,6 +1285,32 @@ public: (void)rxPhy; } + void onEnhancedConnectionComplete( + bool success, + Handle_t connectionHandle, + Role_t ownRole, + PeerAddressType_t peerAddressType, + const ble::address_t &peerAddress, + const ble::address_t &localResolvablePrivateAddress, + const ble::address_t &peerResolvablePrivateAddress, + uint16_t connectionInterval_us, + uint16_t connectionLatency, + uint16_t supervisionTimeout_ms, + uint16_t masterClockAccuracy_ppm + ) { + (void)success; + (void)connectionHandle; + (void)ownRole; + (void)peerAddressType; + (void)peerAddress; + (void)localResolvablePrivateAddress; + (void)peerResolvablePrivateAddress; + (void)connectionInterval_us; + (void)connectionLatency; + (void)supervisionTimeout_ms; + (void)masterClockAccuracy_ppm; + } + protected: /** * Prevent polymorphic deletion and avoid uncessery virtual destructor diff --git a/features/FEATURE_BLE/source/generic/GenericGap.cpp b/features/FEATURE_BLE/source/generic/GenericGap.cpp index cafd6c1453..1159f009dc 100644 --- a/features/FEATURE_BLE/source/generic/GenericGap.cpp +++ b/features/FEATURE_BLE/source/generic/GenericGap.cpp @@ -610,6 +610,7 @@ ble_error_t GenericGap::connect( if (!connectionParams.getNumberOfEnabledPhys()) { return BLE_ERROR_INVALID_PARAM; } + return _pal_gap.extended_create_connection( (ble::pal::initiator_policy_t::type)connectionParams.getFilterPolicy(), (ble::pal::own_address_type_t::type)connectionParams.getOwnAddressType().value(), @@ -2129,9 +2130,22 @@ void GenericGap::on_enhanced_connection_complete( uint16_t connection_latency, uint16_t supervision_timeout, pal::clock_accuracy_t master_clock_accuracy -) -{ - +) { + if (_eventHandler) { + _eventHandler->onEnhancedConnectionComplete( + (status==pal::hci_error_code_t::SUCCESS), + (ble::connection_handle_t)connection_handle, + (Gap::Role_t)own_role.value(), + (ble::peer_address_type_t::type)peer_address_type.value(), + peer_address, + local_resolvable_private_address, + peer_resolvable_private_address, + connection_interval * 1250, + connection_latency, + supervision_timeout * 10, + master_clock_accuracy.getPPM() + ); + } } void GenericGap::on_extended_advertising_report(