Skip to content

Commit

Permalink
✨ (BLEKit): Add is_deep_sleeping in advertising data
Browse files Browse the repository at this point in the history
  • Loading branch information
YannLocatelli committed Aug 19, 2024
1 parent 06ee44e commit 9a5a166
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
18 changes: 11 additions & 7 deletions libs/BLEKit/include/AdvertisingData.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ struct AdvertisingData {
uint8_t version_major {};
uint8_t version_minor {};
uint16_t version_revision {};
uint8_t is_deep_sleeping {};

auto data()
{
Expand All @@ -28,15 +29,18 @@ struct AdvertisingData {
// private:
void updateValues()
{
_internal_values = {battery,
is_charging,
version_major,
version_minor,
static_cast<uint8_t>(version_revision >> 8),
static_cast<uint8_t>(version_revision)};
_internal_values = {
battery,
is_charging,
version_major,
version_minor,
static_cast<uint8_t>(version_revision >> 8),
static_cast<uint8_t>(version_revision),
is_deep_sleeping,
};
}

std::array<uint8_t, 6> _internal_values = {};
std::array<uint8_t, 7> _internal_values = {};
};

} // namespace leka
2 changes: 2 additions & 0 deletions libs/BLEKit/tests/AdvertisingData_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ TEST(AdvertisingDataTest, data)
.version_major = 0x2C,
.version_minor = 0x2D,
.version_revision = 0x2E2F,
.is_deep_sleeping = 0x30,
};

auto expected_data_array = std::to_array({
Expand All @@ -34,6 +35,7 @@ TEST(AdvertisingDataTest, data)
0x2D,
0x2E,
0x2F,
0x30,
});

auto actual_data_array = std::span {advertising_data.data(), advertising_data.size()};
Expand Down
13 changes: 9 additions & 4 deletions libs/BLEKit/tests/CoreGap_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,15 @@ TEST_F(CoreGapTest, defaultAdvertisingPayload)

data_builder.setName(default_advertising_data.name);
data_builder.setServiceData(service::commands::uuid,
{{default_advertising_data.battery, default_advertising_data.is_charging,
default_advertising_data.version_major, default_advertising_data.version_minor,
static_cast<uint8_t>(default_advertising_data.version_revision >> 8),
static_cast<uint8_t>(default_advertising_data.version_revision)}});
{{
default_advertising_data.battery,
default_advertising_data.is_charging,
default_advertising_data.version_major,
default_advertising_data.version_minor,
static_cast<uint8_t>(default_advertising_data.version_revision >> 8),
static_cast<uint8_t>(default_advertising_data.version_revision),
default_advertising_data.is_deep_sleeping,
}});

EXPECT_CALL(mbed_mock_gap,
setAdvertisingPayload(LEGACY_ADVERTISING_HANDLE, compareAdvertisingPayload(data_builder)))
Expand Down

0 comments on commit 9a5a166

Please sign in to comment.