Skip to content

Commit

Permalink
Add support to resolve MAC address
Browse files Browse the repository at this point in the history
Return the resolved MAC address instead of the random public one
  • Loading branch information
cassio-lazaro committed Dec 16, 2024
1 parent 50860b1 commit 3038104
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions services/ble/Gap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ namespace services
GapPairingObserver::Subject().NumericComparisonConfirm(accept);
}

hal::MacAddress GapPairingDecorator::ResolveDeviceAddress(hal::MacAddress deviceAddress) const
{
return GapPairingObserver::Subject().ResolveDeviceAddress(deviceAddress);
}

void GapBondingDecorator::NumberOfBondsChanged(std::size_t nrBonds)
{
GapBonding::NotifyObservers([&nrBonds](auto& obs)
Expand Down
2 changes: 2 additions & 0 deletions services/ble/Gap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ namespace services

virtual void AuthenticateWithPasskey(uint32_t passkey) = 0;
virtual void NumericComparisonConfirm(bool accept) = 0;
virtual hal::MacAddress ResolveDeviceAddress(hal::MacAddress deviceAddress) const = 0;
};

class GapPairingDecorator
Expand All @@ -185,6 +186,7 @@ namespace services
void SetIoCapabilities(IoCapabilities caps) override;
void AuthenticateWithPasskey(uint32_t passkey) override;
void NumericComparisonConfirm(bool accept) override;
hal::MacAddress ResolveDeviceAddress(hal::MacAddress deviceAddress) const override;
};

class GapBonding;
Expand Down
4 changes: 4 additions & 0 deletions services/ble/test/TestGapPairing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,9 @@ namespace services

EXPECT_CALL(gapPairing, NumericComparisonConfirm(::testing::IsFalse()));
decorator.NumericComparisonConfirm(false);

hal::MacAddress mac = { 0x00, 0x1A, 0x7D, 0xDA, 0x71, 0x13 };
EXPECT_CALL(gapPairing, ResolveDeviceAddress(mac));
decorator.ResolveDeviceAddress(mac);
}
}
1 change: 1 addition & 0 deletions services/ble/test_doubles/GapPairingMock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace services
MOCK_METHOD(void, SetIoCapabilities, (IoCapabilities caps));
MOCK_METHOD(void, AuthenticateWithPasskey, (uint32_t passkey));
MOCK_METHOD(void, NumericComparisonConfirm, (bool accept));
MOCK_METHOD(hal::MacAddress, ResolveDeviceAddress, (hal::MacAddress deviceAddress), (const));
};
}

Expand Down

0 comments on commit 3038104

Please sign in to comment.