Skip to content

Commit 6aa8866

Browse files
authored
chore: gap.hpp: add storage to GapAdvertisingReport (#812)
Gap.hpp: Add storage to GapAdvertisingReport
1 parent e3dcfe3 commit 6aa8866

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

services/ble/Gap.hpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33

44
#include "hal/interfaces/MacAddress.hpp"
55
#include "infra/timer/Timer.hpp"
6+
#include "infra/util/BoundedVector.hpp"
7+
#include "infra/util/ByteRange.hpp"
68
#include "infra/util/EnumCast.hpp"
79
#include "infra/util/Observer.hpp"
10+
#include <array>
811

912
namespace services
1013
{
@@ -68,15 +71,6 @@ namespace services
6871
static constexpr uint16_t connectionInitialMaxTxTime = 2120; // (connectionInitialMaxTxOctets + 14) * 8
6972
};
7073

71-
struct GapAdvertisingReport
72-
{
73-
GapAdvertisingEventType eventType;
74-
GapAdvertisingEventAddressType addressType;
75-
hal::MacAddress address;
76-
infra::ConstByteRange data;
77-
int8_t rssi;
78-
};
79-
8074
struct GapAddress
8175
{
8276
hal::MacAddress address;
@@ -295,6 +289,15 @@ namespace services
295289
return static_cast<GapPeripheral::AdvertisementFlags>(infra::enum_cast(lhs) | infra::enum_cast(rhs));
296290
}
297291

292+
struct GapAdvertisingReport
293+
{
294+
GapAdvertisingEventType eventType;
295+
GapAdvertisingEventAddressType addressType;
296+
hal::MacAddress address;
297+
infra::BoundedVector<uint8_t>::WithMaxSize<GapPeripheral::maxAdvertisementDataSize> data;
298+
int8_t rssi;
299+
};
300+
298301
class GapCentral;
299302

300303
class GapCentralObserver

services/ble/test/TestGapCentral.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "infra/stream/StringOutputStream.hpp"
22
#include "infra/util/ByteRange.hpp"
33
#include "infra/util/test_helper/MemoryRangeMatcher.hpp"
4+
#include "services/ble/Gap.hpp"
45
#include "services/ble/test_doubles/GapCentralMock.hpp"
56
#include "services/ble/test_doubles/GapCentralObserverMock.hpp"
67
#include "gmock/gmock.h"
@@ -48,7 +49,7 @@ namespace services
4849

4950
TEST_F(GapCentralDecoratorTest, forward_device_discovered_event_to_observers)
5051
{
51-
GapAdvertisingReport deviceDiscovered{ GapAdvertisingEventType::advInd, GapAdvertisingEventAddressType::publicDeviceAddress, hal::MacAddress{ 0, 1, 2, 3, 4, 5 }, infra::ConstByteRange(), -75 };
52+
GapAdvertisingReport deviceDiscovered{ GapAdvertisingEventType::advInd, GapAdvertisingEventAddressType::publicDeviceAddress, hal::MacAddress{ 0, 1, 2, 3, 4, 5 }, infra::BoundedVector<uint8_t>::WithMaxSize<GapPeripheral::maxAdvertisementDataSize>{}, -75 };
5253

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

0 commit comments

Comments
 (0)