Skip to content

Commit

Permalink
Add support to return resolve MAC address
Browse files Browse the repository at this point in the history
Return the resolved MAC address instead of the random one
  • Loading branch information
cassio-lazaro committed Feb 17, 2025
1 parent 24641b3 commit 225fb93
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 29 deletions.
9 changes: 0 additions & 9 deletions protobuf/echo/TracingEcho.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,6 @@ namespace services
tracer.Continue() << "]";
}

template<class T>
void PrintField(const infra::Optional<T>& value, services::Tracer& tracer)
{
if (value)
PrintField(*value, tracer);
else
tracer.Continue() << "null";
}

namespace detail
{
class TracingEchoOnStreamsDescendantHelper
Expand Down
13 changes: 2 additions & 11 deletions services/ble/Gap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,6 @@ namespace services
static constexpr uint16_t connectionInitialMaxTxTime = 2120; // (connectionInitialMaxTxOctets + 14) * 8
};

struct GapAdvertisingReport
{
GapAdvertisingEventType eventType;
GapDeviceAddressType addressType;
hal::MacAddress address;
infra::ConstByteRange data;
int8_t rssi;
};

struct GapAddress
{
hal::MacAddress address;
Expand Down Expand Up @@ -291,11 +282,11 @@ namespace services
{
return static_cast<GapPeripheral::AdvertisementFlags>(infra::enum_cast(lhs) | infra::enum_cast(rhs));
}

struct GapAdvertisingReport
{
GapAdvertisingEventType eventType;
GapAdvertisingEventAddressType addressType;
GapDeviceAddressType addressType;
hal::MacAddress address;
infra::BoundedVector<uint8_t>::WithMaxSize<GapPeripheral::maxAdvertisementDataSize> data;
int8_t rssi;
Expand Down
12 changes: 5 additions & 7 deletions services/ble/Gap.proto
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,6 @@ message UInt32Value
uint32 value = 1;
}

message OptionalAddress
{
optional Address address = 1;
}

service GapPeripheral
{
option (service_id) = 32;
Expand All @@ -200,6 +195,7 @@ service GapPeripheral

// Allowed states: advertising
rpc GetResolvableAddress(Nothing) returns (Nothing) { option (method_id) = 9; }
rpc GetIdentityAddress(Nothing) returns (Nothing) { option (method_id) = 10; }
}

service GapCentral
Expand Down Expand Up @@ -243,6 +239,7 @@ service GapPeripheralResponse
rpc StateChanged(State) returns (Nothing) { option (method_id) = 3; }
rpc ResolvableAddress(Address) returns (Nothing) { option (method_id) = 4; }
rpc DisplayPasskey(Passkey) returns (Nothing) { option (method_id) = 5; }
rpc IdentityAddress(Address) returns (Nothing) { option (method_id) = 6; }
}

service GapCentralResponse
Expand All @@ -256,6 +253,7 @@ 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 ResolvedPrivateAddress(OptionalAddress) returns (Nothing) { option (method_id) = 8; }
rpc DeviceBonded(BoolValue) returns (Nothing) { option (method_id) = 9; }
rpc ResolvedPrivateAddress(Address) returns (Nothing) { option (method_id) = 8; }
rpc ResolvePrivateAddressFailed(Nothing) returns (Nothing) { option (method_id) = 9; }
rpc DeviceBonded(BoolValue) returns (Nothing) { option (method_id) = 10; }
}
3 changes: 1 addition & 2 deletions services/ble/test/TestGapCentral.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "services/ble/test_doubles/GapCentralMock.hpp"
#include "services/ble/test_doubles/GapCentralObserverMock.hpp"
#include "gmock/gmock.h"
#include <chrono>

namespace services
{
Expand Down Expand Up @@ -49,7 +48,7 @@ namespace services

TEST_F(GapCentralDecoratorTest, forward_device_discovered_event_to_observers)
{
GapAdvertisingReport deviceDiscovered{ GapAdvertisingEventType::advInd, GapDeviceAddressType::publicAddress, hal::MacAddress{ 0, 1, 2, 3, 4, 5 }, infra::ConstByteRange(), -75 };
GapAdvertisingReport deviceDiscovered{ GapAdvertisingEventType::advInd, GapDeviceAddressType::publicAddress, hal::MacAddress{ 0, 1, 2, 3, 4, 5 }, infra::BoundedVector<uint8_t>::WithMaxSize<GapPeripheral::maxAdvertisementDataSize>{}, -75 };

EXPECT_CALL(gapObserver, DeviceDiscovered(ObjectContentsEqual(deviceDiscovered)));

Expand Down

0 comments on commit 225fb93

Please sign in to comment.