Skip to content

Commit

Permalink
chore: gap.hpp: add storage to GapAdvertisingReport (#812)
Browse files Browse the repository at this point in the history
Gap.hpp: Add storage to GapAdvertisingReport
  • Loading branch information
oguzcanoguz authored Jan 27, 2025
1 parent e3dcfe3 commit 6aa8866
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
21 changes: 12 additions & 9 deletions services/ble/Gap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@

#include "hal/interfaces/MacAddress.hpp"
#include "infra/timer/Timer.hpp"
#include "infra/util/BoundedVector.hpp"
#include "infra/util/ByteRange.hpp"
#include "infra/util/EnumCast.hpp"
#include "infra/util/Observer.hpp"
#include <array>

namespace services
{
Expand Down Expand Up @@ -68,15 +71,6 @@ namespace services
static constexpr uint16_t connectionInitialMaxTxTime = 2120; // (connectionInitialMaxTxOctets + 14) * 8
};

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

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

struct GapAdvertisingReport
{
GapAdvertisingEventType eventType;
GapAdvertisingEventAddressType addressType;
hal::MacAddress address;
infra::BoundedVector<uint8_t>::WithMaxSize<GapPeripheral::maxAdvertisementDataSize> data;
int8_t rssi;
};

class GapCentral;

class GapCentralObserver
Expand Down
3 changes: 2 additions & 1 deletion services/ble/test/TestGapCentral.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "infra/stream/StringOutputStream.hpp"
#include "infra/util/ByteRange.hpp"
#include "infra/util/test_helper/MemoryRangeMatcher.hpp"
#include "services/ble/Gap.hpp"
#include "services/ble/test_doubles/GapCentralMock.hpp"
#include "services/ble/test_doubles/GapCentralObserverMock.hpp"
#include "gmock/gmock.h"
Expand Down Expand Up @@ -48,7 +49,7 @@ namespace services

TEST_F(GapCentralDecoratorTest, forward_device_discovered_event_to_observers)
{
GapAdvertisingReport deviceDiscovered{ GapAdvertisingEventType::advInd, GapAdvertisingEventAddressType::publicDeviceAddress, hal::MacAddress{ 0, 1, 2, 3, 4, 5 }, infra::ConstByteRange(), -75 };
GapAdvertisingReport deviceDiscovered{ GapAdvertisingEventType::advInd, GapAdvertisingEventAddressType::publicDeviceAddress, 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 6aa8866

Please sign in to comment.