Skip to content

Commit

Permalink
fix code review
Browse files Browse the repository at this point in the history
  • Loading branch information
cassio-lazaro committed Jan 16, 2025
1 parent e2be1e7 commit 56834c3
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions services/ble/Gap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ namespace services
return GapBondingObserver::Subject().GetNumberOfBonds();
}

bool GapBondingDecorator::IsDeviceBonded(hal::MacAddress deviceAddress) const
bool GapBondingDecorator::IsDeviceBonded(hal::MacAddress identityAddress) const
{
return GapBondingObserver::Subject().IsDeviceBonded(deviceAddress);
return GapBondingObserver::Subject().IsDeviceBonded(identityAddress);
}

void GapPeripheralDecorator::StateChanged(GapState state)
Expand Down Expand Up @@ -183,9 +183,9 @@ namespace services
GapCentralObserver::Subject().StopDeviceDiscovery();
}

infra::Optional<hal::MacAddress> GapCentralDecorator::ResolveDeviceAddress(hal::MacAddress deviceAddress) const
infra::Optional<hal::MacAddress> GapCentralDecorator::ResolvePrivateAddress(hal::MacAddress address) const
{
return GapCentralObserver::Subject().ResolveDeviceAddress(deviceAddress);
return GapCentralObserver::Subject().ResolvePrivateAddress(address);
}

GapAdvertisingDataParser::GapAdvertisingDataParser(infra::ConstByteRange data)
Expand Down
8 changes: 4 additions & 4 deletions services/ble/Gap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ namespace services

virtual std::size_t GetMaxNumberOfBonds() const = 0;
virtual std::size_t GetNumberOfBonds() const = 0;
virtual bool IsDeviceBonded(hal::MacAddress deviceAddress) const = 0;
virtual bool IsDeviceBonded(hal::MacAddress identityAddress) const = 0;
};

class GapBondingDecorator
Expand All @@ -226,7 +226,7 @@ namespace services
void RemoveOldestBond() override;
std::size_t GetMaxNumberOfBonds() const override;
std::size_t GetNumberOfBonds() const override;
bool IsDeviceBonded(hal::MacAddress deviceAddress) const override;
bool IsDeviceBonded(hal::MacAddress identityAddress) const override;
};

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

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

Expand Down
4 changes: 2 additions & 2 deletions services/ble/Gap.proto
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ service GapCentral
rpc NumericComparisonConfirm(BoolValue) returns (Nothing) { option (method_id) = 10; }
rpc RemoveAllBonds(Nothing) returns (Nothing) { option (method_id) = 11; }
rpc SetDeviceDiscoveryFilter(DeviceDiscoveryFilter) returns (Nothing) { option (method_id) = 12; }
rpc ResolveDeviceAddress(Address) returns (Nothing) { option (method_id) = 13; }
rpc ResolvePrivateAddress(Address) returns (Nothing) { option (method_id) = 13; }
rpc IsDeviceBonded(Address) returns (Nothing) { option (method_id) = 14; }
}

Expand All @@ -220,6 +220,6 @@ service GapCentralResponse
rpc PairingFailed(PairingStatus) returns (Nothing) { option (method_id) = 5; }
rpc NumberOfBondsChanged(UInt32Value) returns (Nothing) { option (method_id) = 6; }
rpc DeviceStarted(Nothing) returns (Nothing) { option (method_id) = 7; }
rpc ResolveDeviceAddress(Address) returns (Nothing) { option (method_id) = 8; }
rpc ResolvePrivateAddress(Address) returns (Nothing) { option (method_id) = 8; }
rpc IsDeviceBonded(Address) returns (Nothing) { option (method_id) = 9; }
}
8 changes: 4 additions & 4 deletions services/ble/test/TestGapCentral.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ namespace services
decorator.StopDeviceDiscovery();

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

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

TEST(GapAdvertisingDataParserTest, payload_too_small)
Expand Down
2 changes: 1 addition & 1 deletion services/ble/test_doubles/GapBondingMock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace services
MOCK_METHOD(void, RemoveOldestBond, ());
MOCK_METHOD(std::size_t, GetMaxNumberOfBonds, (), (const));
MOCK_METHOD(std::size_t, GetNumberOfBonds, (), (const));
MOCK_METHOD(bool, IsDeviceBonded, (hal::MacAddress deviceAddress), (const));
MOCK_METHOD(bool, IsDeviceBonded, (hal::MacAddress identityAddress), (const));
};
}

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(infra::Optional<hal::MacAddress>, ResolveDeviceAddress, (hal::MacAddress deviceAddress), (const));
MOCK_METHOD(infra::Optional<hal::MacAddress>, ResolvePrivateAddress, (hal::MacAddress address), (const));
};
}

Expand Down

0 comments on commit 56834c3

Please sign in to comment.