diff --git a/CMakeLists.txt b/CMakeLists.txt index 874d89de..468b5296 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,7 +26,7 @@ if (HALST_STANDALONE) FetchContent_Declare( emil GIT_REPOSITORY https://github.com/philips-software/amp-embedded-infra-lib.git - GIT_TAG c77731ba79bfbe8af22450cf33fcdf4fd30a3587 # unreleased + GIT_TAG 863b57558fa785625d96758a3cbdcbbdd73ac8bd # unreleased ) FetchContent_MakeAvailable(emil) diff --git a/hal_st/middlewares/ble_middleware/GapCentralSt.cpp b/hal_st/middlewares/ble_middleware/GapCentralSt.cpp index 7fea6144..54ef6c94 100644 --- a/hal_st/middlewares/ble_middleware/GapCentralSt.cpp +++ b/hal_st/middlewares/ble_middleware/GapCentralSt.cpp @@ -29,9 +29,21 @@ namespace hal return static_cast(eventType); } - services::GapAdvertisingEventAddressType ToAdvertisingAddressType(uint8_t addressType) + services::GapAdvertisingEventAddressType ToAdvertisingAddressType(uint8_t addressType, const uint8_t address[6]) { - return static_cast(addressType); + if (addressType == static_cast(services::GapDeviceAddressType::publicAddress)) + return services::GapAdvertisingEventAddressType::publicDeviceAddress; + else if (addressType == static_cast(services::GapDeviceAddressType::randomAddress)) + { + auto mode = address[5] >> 6; // Address in EUI-48 format + if (mode == 0x3) + return services::GapAdvertisingEventAddressType::randomDeviceAddress; + else if (mode == 0x01) + return services::GapAdvertisingEventAddressType::publicIdentityAddress; + else if (mode == 0x00) + return services::GapAdvertisingEventAddressType::randomIdentityAddress; + } + return services::GapAdvertisingEventAddressType::randomDeviceAddress; } bool IsTxDataLengthConfigured(const hci_le_data_length_change_event_rp0& dataLengthChangeEvent) @@ -298,7 +310,7 @@ namespace hal auto advertisementData = const_cast(&advertisingReport.Length_Data) + 1; std::copy_n(std::begin(advertisingReport.Address), discoveredDevice.address.size(), std::begin(discoveredDevice.address)); discoveredDevice.eventType = ToAdvertisingEventType(advertisingReport.Event_Type); - discoveredDevice.addressType = ToAdvertisingAddressType(advertisingReport.Address_Type); + discoveredDevice.addressType = ToAdvertisingAddressType(advertisingReport.Address_Type, advertisingReport.Address); discoveredDevice.data = infra::MemoryRange(advertisementData, advertisementData + advertisingReport.Length_Data); discoveredDevice.rssi = static_cast(*const_cast(advertisementData + advertisingReport.Length_Data)); diff --git a/hal_st/middlewares/ble_middleware/GapSt.cpp b/hal_st/middlewares/ble_middleware/GapSt.cpp index a3f0df66..1525ec06 100644 --- a/hal_st/middlewares/ble_middleware/GapSt.cpp +++ b/hal_st/middlewares/ble_middleware/GapSt.cpp @@ -1,8 +1,6 @@ #include "hal_st/middlewares/ble_middleware/GapSt.hpp" #include "ble_gap_aci.h" #include "services/ble/Gap.hpp" -#include -#include namespace hal { @@ -93,9 +91,9 @@ namespace hal return numberOfBondedAddress; } - bool GapSt::IsDeviceBounded(MacAddress deviceAddress) const + bool GapSt::IsDeviceBonded(MacAddress deviceAddress) const { - return (aci_gap_is_device_bonded(static_cast(PeerAddressType::PUBLIC), deviceAddress.data()) == BLE_STATUS_SUCCESS); + return aci_gap_is_device_bonded(static_cast(PeerAddressType::publicStatic), deviceAddress.data()) == BLE_STATUS_SUCCESS; } void GapSt::Pair() @@ -319,16 +317,16 @@ namespace hal switch (static_cast(peerAddressType)) { - case PeerAddressType::PUBLIC: - case PeerAddressType::RANDOM: + case PeerAddressType::publicStatic: + case PeerAddressType::randomStatic: return peerAddressType; - case PeerAddressType::RESOLVED_PUBLIC_IDENTITY: - return infra::enum_cast(PeerAddressType::PUBLIC); + case PeerAddressType::resolvablePrivate: + return infra::enum_cast(PeerAddressType::publicStatic); - case PeerAddressType::RESOLVED_RANDOM_STATIC_IDENTITY: + case PeerAddressType::nonResolvablePrivate: default: - return infra::enum_cast(PeerAddressType::RANDOM); + return infra::enum_cast(PeerAddressType::randomStatic); } }; diff --git a/hal_st/middlewares/ble_middleware/GapSt.hpp b/hal_st/middlewares/ble_middleware/GapSt.hpp index b2b02ef5..5244e53a 100644 --- a/hal_st/middlewares/ble_middleware/GapSt.hpp +++ b/hal_st/middlewares/ble_middleware/GapSt.hpp @@ -45,7 +45,7 @@ namespace hal void RemoveOldestBond() override; std::size_t GetMaxNumberOfBonds() const override; std::size_t GetNumberOfBonds() const override; - bool IsDeviceBounded(MacAddress deviceAddress) const override; + bool IsDeviceBonded(MacAddress deviceAddress) const override; // Implementation of GapPairing void Pair() override; @@ -88,10 +88,10 @@ namespace hal protected: enum class PeerAddressType : uint8_t { - PUBLIC, - RANDOM, - RESOLVED_PUBLIC_IDENTITY, - RESOLVED_RANDOM_STATIC_IDENTITY + publicStatic, + randomStatic, + resolvablePrivate, + nonResolvablePrivate }; struct ConnectionContext diff --git a/hal_st/middlewares/ble_middleware/TracingGapCentralSt.cpp b/hal_st/middlewares/ble_middleware/TracingGapCentralSt.cpp index 6f2b3a96..c3266c03 100644 --- a/hal_st/middlewares/ble_middleware/TracingGapCentralSt.cpp +++ b/hal_st/middlewares/ble_middleware/TracingGapCentralSt.cpp @@ -48,7 +48,11 @@ namespace hal infra::Optional TracingGapCentralSt::ResolveDeviceAddress(hal::MacAddress deviceAddress) const { auto resolvedMac = GapCentralSt::ResolveDeviceAddress(deviceAddress); - tracer.Trace() << "TracingGapCentralSt::ResolveDeviceAddress, MAC address: " << infra::AsMacAddress(deviceAddress) << " resolved MAC address " << infra::AsMacAddress(*resolvedMac); + tracer.Trace() << "TracingGapCentralSt::ResolveDeviceAddress, MAC address: " << infra::AsMacAddress(deviceAddress); + if (resolvedMac) + tracer.Continue() << ", resolved MAC address " << infra::AsMacAddress(*resolvedMac); + else + tracer.Continue() << ", could not resolve MAC address"; return resolvedMac; } @@ -76,10 +80,10 @@ namespace hal return GapCentralSt::GetNumberOfBonds(); } - bool TracingGapCentralSt::IsDeviceBounded(hal::MacAddress deviceAddress) const + bool TracingGapCentralSt::IsDeviceBonded(hal::MacAddress deviceAddress) const { - auto ret = GapCentralSt::IsDeviceBounded(deviceAddress); - tracer.Trace() << "TracingGapCentralSt::IsDeviceBounded " << infra::AsMacAddress(deviceAddress) << " -> " << (ret ? "true" : "false"); + auto ret = GapCentralSt::IsDeviceBonded(deviceAddress); + tracer.Trace() << "TracingGapCentralSt::IsDeviceBonded " << infra::AsMacAddress(deviceAddress) << " -> " << (ret ? "true" : "false"); return ret; } diff --git a/hal_st/middlewares/ble_middleware/TracingGapCentralSt.hpp b/hal_st/middlewares/ble_middleware/TracingGapCentralSt.hpp index f6268342..a3b8193c 100644 --- a/hal_st/middlewares/ble_middleware/TracingGapCentralSt.hpp +++ b/hal_st/middlewares/ble_middleware/TracingGapCentralSt.hpp @@ -25,7 +25,7 @@ namespace hal void RemoveOldestBond() override; std::size_t GetMaxNumberOfBonds() const override; std::size_t GetNumberOfBonds() const override; - bool IsDeviceBounded(hal::MacAddress deviceAddress) const override; + bool IsDeviceBonded(hal::MacAddress deviceAddress) const override; // Implementation of GapPairing void Pair() override;