Skip to content

Commit

Permalink
🏗️ (BLE): Reorder advertising data with version first
Browse files Browse the repository at this point in the history
  • Loading branch information
YannLocatelli committed Aug 26, 2024
1 parent 41d0070 commit fed30ad
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions libs/BLEKit/include/AdvertisingData.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ namespace leka {

struct AdvertisingData {
const char *name = "Leka"; // TODO: Get default name from configuration files
uint8_t battery {};
uint8_t is_charging {};
uint8_t version_major {};
uint8_t version_minor {};
uint8_t battery {};
uint8_t is_charging {};
uint8_t is_deep_sleeping {};

auto data()
Expand All @@ -29,7 +29,7 @@ struct AdvertisingData {
void updateValues()
{
_internal_values = {
battery, is_charging, version_major, version_minor, is_deep_sleeping,
version_major, version_minor, battery, is_charging, is_deep_sleeping,
};
}

Expand Down
20 changes: 10 additions & 10 deletions libs/BLEKit/tests/AdvertisingData_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ TEST(AdvertisingDataTest, initialisation)
TEST(AdvertisingDataTest, data)
{
auto advertising_data = AdvertisingData {
.battery = 0x2A,
.is_charging = 0x2B,
.version_major = 0x2C,
.version_minor = 0x2D,
.is_deep_sleeping = 0x30,
.version_major = 0x3A,
.version_minor = 0x3B,
.battery = 0x3C,
.is_charging = 0x3D,
.is_deep_sleeping = 0x3E,
};

auto expected_data_array = std::to_array({
0x2A,
0x2B,
0x2C,
0x2D,
0x30,
0x3A,
0x3B,
0x3C,
0x3D,
0x3E,
});

auto actual_data_array = std::span {advertising_data.data(), advertising_data.size()};
Expand Down
4 changes: 2 additions & 2 deletions libs/BLEKit/tests/CoreGap_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ 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,
default_advertising_data.battery,
default_advertising_data.is_charging,
default_advertising_data.is_deep_sleeping,
}});

Expand Down

0 comments on commit fed30ad

Please sign in to comment.