From 7e16ee448e7bf027aa32e75e27c44f3621648d04 Mon Sep 17 00:00:00 2001 From: Vincent Coubard Date: Mon, 7 Sep 2020 09:30:18 +0100 Subject: [PATCH] BLE: Bind address controller with Gap --- .../cordio/source/BLEInstanceBaseImpl.cpp | 3 +- .../FEATURE_BLE/source/generic/GapImpl.cpp | 29 ++++++++++++++++++- .../FEATURE_BLE/source/generic/GapImpl.h | 23 +++++++++++++-- 3 files changed, 51 insertions(+), 4 deletions(-) diff --git a/connectivity/FEATURE_BLE/source/cordio/source/BLEInstanceBaseImpl.cpp b/connectivity/FEATURE_BLE/source/cordio/source/BLEInstanceBaseImpl.cpp index f048ba01f6..e32fbeeb4d 100644 --- a/connectivity/FEATURE_BLE/source/cordio/source/BLEInstanceBaseImpl.cpp +++ b/connectivity/FEATURE_BLE/source/cordio/source/BLEInstanceBaseImpl.cpp @@ -201,7 +201,8 @@ ble::impl::Gap &BLEInstanceBase::getGapImpl() _event_queue, ble::impl::PalGap::get_gap(), cordio_gap_service, - ble::impl::PalSecurityManager::get_security_manager() + ble::impl::PalSecurityManager::get_security_manager(), + getPrivateAddressRegistry() ); return gap; } diff --git a/connectivity/FEATURE_BLE/source/generic/GapImpl.cpp b/connectivity/FEATURE_BLE/source/generic/GapImpl.cpp index 4b66e98efd..25dba4e2f2 100644 --- a/connectivity/FEATURE_BLE/source/generic/GapImpl.cpp +++ b/connectivity/FEATURE_BLE/source/generic/GapImpl.cpp @@ -319,11 +319,13 @@ Gap::Gap( ble::PalEventQueue &event_queue, ble::PalGap &pal_gap, ble::PalGenericAccessService &generic_access_service, - ble::PalSecurityManager &pal_sm + ble::PalSecurityManager &pal_sm, + ble::PrivateAddressController &pal_addr_reg ) : _event_queue(event_queue), _pal_gap(pal_gap), _gap_service(generic_access_service), _pal_sm(pal_sm), + _address_registry(pal_addr_reg), _address_type(own_address_type_t::PUBLIC), _initiator_policy_mode(initiator_policy_t::NO_FILTER), _scanning_filter_policy(scanning_filter_policy_t::NO_FILTER), @@ -348,6 +350,7 @@ Gap::Gap( _random_static_identity_address = _pal_gap.get_random_address(); _pal_gap.set_event_handler(this); + _address_registry.set_event_handler(this); } @@ -2893,5 +2896,29 @@ void Gap::setEventHandler(Gap::EventHandler *handler) _event_handler = handler; } + +void Gap::on_resolvable_private_addresses_generated(const address_t &address) +{ +} + +void Gap::on_non_resolvable_private_addresses_generated(const address_t &address) +{ +} + +void Gap::on_private_address_generated(bool connectable) +{ +} + + +void Gap::on_address_resolution_completion( + const address_t &peer_resolvable_address, + bool resolved, + target_peer_address_type_t identity_address_type, + const address_t &identity_address +) +{ + // FIXME: Implement +} +} } // impl } // ble diff --git a/connectivity/FEATURE_BLE/source/generic/GapImpl.h b/connectivity/FEATURE_BLE/source/generic/GapImpl.h index 0f29786f2e..40b9be6752 100644 --- a/connectivity/FEATURE_BLE/source/generic/GapImpl.h +++ b/connectivity/FEATURE_BLE/source/generic/GapImpl.h @@ -38,6 +38,8 @@ #include "source/pal/PalGap.h" #include "source/pal/PalConnectionMonitor.h" +#include "source/pal/PalEventQueue.h" +#include "source/generic/PrivateAddressController.h" #include "ble/Gap.h" @@ -57,7 +59,8 @@ class BLEInstanceBase; class Gap : public ble::PalConnectionMonitor, - public PalGapEventHandler { + public PalGapEventHandler, + public PrivateAddressController::EventHandler { friend PalConnectionMonitor; friend PalGapEventHandler; friend PalGap; @@ -358,7 +361,8 @@ private: ble::PalEventQueue &event_queue, ble::PalGap &pal_gap, ble::PalGenericAccessService &generic_access_service, - ble::PalSecurityManager &pal_sm + ble::PalSecurityManager &pal_sm, + ble::PrivateAddressController &pal_addr_reg ); ~Gap(); @@ -533,6 +537,20 @@ private: void process_legacy_scan_timeout(); + /* Implement PrivateAddressController::EventHandler */ +private: + void on_resolvable_private_addresses_generated(const address_t &address) final; + + void on_non_resolvable_private_addresses_generated(const address_t &address) final; + + void on_private_address_generated(bool connectable); + + void on_address_resolution_completion( + const address_t &peer_resolvable_address, + bool resolved, + target_peer_address_type_t identity_address_type, + const address_t &identity_address + ) final; private: /** * Callchain containing all registered callback handlers for shutdown @@ -549,6 +567,7 @@ private: PalGap &_pal_gap; PalGenericAccessService &_gap_service; PalSecurityManager &_pal_sm; + PrivateAddressController &_address_registry; ble::own_address_type_t _address_type; ble::address_t _address; initiator_policy_t _initiator_policy_mode;