Skip to content

Commit

Permalink
Changes after sync up with Oguzcan
Browse files Browse the repository at this point in the history
  • Loading branch information
cassio-lazaro committed Dec 19, 2024
1 parent e7c9126 commit 132c841
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion services/ble/Gap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ namespace services
GapCentralObserver::Subject().StopDeviceDiscovery();
}

hal::MacAddress GapCentralDecorator::ResolveDeviceAddress(hal::MacAddress deviceAddress) const
infra::Optional<hal::MacAddress> GapCentralDecorator::ResolveDeviceAddress(hal::MacAddress deviceAddress) const
{
return GapCentralObserver::Subject().ResolveDeviceAddress(deviceAddress);
}
Expand Down
5 changes: 3 additions & 2 deletions services/ble/Gap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "infra/timer/Timer.hpp"
#include "infra/util/EnumCast.hpp"
#include "infra/util/Observer.hpp"
#include "infra/util/Optional.hpp"

namespace services
{
Expand Down Expand Up @@ -319,7 +320,7 @@ namespace services
virtual void SetAddress(hal::MacAddress macAddress, GapDeviceAddressType addressType) = 0;
virtual void StartDeviceDiscovery() = 0;
virtual void StopDeviceDiscovery() = 0;
virtual hal::MacAddress ResolveDeviceAddress(hal::MacAddress deviceAddress) const = 0;
virtual infra::Optional<hal::MacAddress> ResolveDeviceAddress(hal::MacAddress deviceAddress) const = 0;
};

class GapCentralDecorator
Expand All @@ -340,7 +341,7 @@ namespace services
void SetAddress(hal::MacAddress macAddress, GapDeviceAddressType addressType) override;
void StartDeviceDiscovery() override;
void StopDeviceDiscovery() override;
hal::MacAddress ResolveDeviceAddress(hal::MacAddress deviceAddress) const override;
infra::Optional<hal::MacAddress> ResolveDeviceAddress(hal::MacAddress deviceAddress) const override;
};
}

Expand Down
7 changes: 5 additions & 2 deletions services/ble/test/TestGapCentral.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,11 @@ namespace services
decorator.StopDeviceDiscovery();

hal::MacAddress mac = { 0x00, 0x1A, 0x7D, 0xDA, 0x71, 0x13 };
EXPECT_CALL(gap, ResolveDeviceAddress(mac));
decorator.ResolveDeviceAddress(mac);
EXPECT_CALL(gap, ResolveDeviceAddress(mac)).WillOnce(testing::Return(infra::none));
EXPECT_EQ(decorator.ResolveDeviceAddress(mac), infra::none);

EXPECT_CALL(gap, ResolveDeviceAddress(mac)).WillOnce(testing::Return(infra::MakeOptional(mac)));
EXPECT_EQ(decorator.ResolveDeviceAddress(mac), mac);
}

TEST(GapAdvertisingDataParserTest, payload_too_small)
Expand Down
2 changes: 1 addition & 1 deletion services/ble/test_doubles/GapCentralMock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace services
MOCK_METHOD(void, SetAddress, (hal::MacAddress macAddress, GapDeviceAddressType addressType));
MOCK_METHOD(void, StartDeviceDiscovery, ());
MOCK_METHOD(void, StopDeviceDiscovery, ());
MOCK_METHOD(hal::MacAddress, ResolveDeviceAddress, (hal::MacAddress deviceAddress), (const));
MOCK_METHOD(infra::Optional<hal::MacAddress>, ResolveDeviceAddress, (hal::MacAddress deviceAddress), (const));
};
}

Expand Down

0 comments on commit 132c841

Please sign in to comment.