diff --git a/libs/BLEKit/include/AdvertisingData.h b/libs/BLEKit/include/AdvertisingData.h index 330ad5c0e7..0c093d2e52 100644 --- a/libs/BLEKit/include/AdvertisingData.h +++ b/libs/BLEKit/include/AdvertisingData.h @@ -11,11 +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 {}; - uint16_t version_revision {}; + uint8_t battery {}; + uint8_t is_charging {}; uint8_t is_deep_sleeping {}; auto data() @@ -30,17 +29,11 @@ struct AdvertisingData { void updateValues() { _internal_values = { - battery, - is_charging, - version_major, - version_minor, - static_cast(version_revision >> 8), - static_cast(version_revision), - is_deep_sleeping, + version_major, version_minor, battery, is_charging, is_deep_sleeping, }; } - std::array _internal_values = {}; + std::array _internal_values = {}; }; } // namespace leka diff --git a/libs/BLEKit/tests/AdvertisingData_test.cpp b/libs/BLEKit/tests/AdvertisingData_test.cpp index 641ad34c57..092e46c02a 100644 --- a/libs/BLEKit/tests/AdvertisingData_test.cpp +++ b/libs/BLEKit/tests/AdvertisingData_test.cpp @@ -20,22 +20,19 @@ TEST(AdvertisingDataTest, initialisation) TEST(AdvertisingDataTest, data) { auto advertising_data = AdvertisingData { - .battery = 0x2A, - .is_charging = 0x2B, - .version_major = 0x2C, - .version_minor = 0x2D, - .version_revision = 0x2E2F, - .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, - 0x2E, - 0x2F, - 0x30, + 0x3A, + 0x3B, + 0x3C, + 0x3D, + 0x3E, }); auto actual_data_array = std::span {advertising_data.data(), advertising_data.size()}; diff --git a/libs/BLEKit/tests/CoreGap_test.cpp b/libs/BLEKit/tests/CoreGap_test.cpp index 33ba464159..5de6d9b50f 100644 --- a/libs/BLEKit/tests/CoreGap_test.cpp +++ b/libs/BLEKit/tests/CoreGap_test.cpp @@ -103,16 +103,13 @@ TEST_F(CoreGapTest, defaultAdvertisingPayload) auto default_advertising_data = AdvertisingData {}; 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(default_advertising_data.version_revision >> 8), - static_cast(default_advertising_data.version_revision), - default_advertising_data.is_deep_sleeping, - }}); + data_builder.setServiceData(service::commands::uuid, {{ + 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, + }}); EXPECT_CALL(mbed_mock_gap, setAdvertisingPayload(LEGACY_ADVERTISING_HANDLE, compareAdvertisingPayload(data_builder))) diff --git a/libs/RobotKit/include/RobotController.h b/libs/RobotKit/include/RobotController.h index 024731593d..e52a263440 100644 --- a/libs/RobotKit/include/RobotController.h +++ b/libs/RobotKit/include/RobotController.h @@ -359,11 +359,10 @@ class RobotController : public interface::RobotController _service_config.setRobotName(_robot_name); - auto advertising_data = _ble.getAdvertisingData(); - advertising_data.name = reinterpret_cast(_robot_name.data()); - advertising_data.version_major = _os_version.major; - advertising_data.version_minor = _os_version.minor; - advertising_data.version_revision = _os_version.revision; + auto advertising_data = _ble.getAdvertisingData(); + advertising_data.name = reinterpret_cast(_robot_name.data()); + advertising_data.version_major = _os_version.major; + advertising_data.version_minor = _os_version.minor; _ble.setAdvertisingData(advertising_data); diff --git a/spikes/lk_ble/main.cpp b/spikes/lk_ble/main.cpp index 2c77a2f490..a990329615 100644 --- a/spikes/lk_ble/main.cpp +++ b/spikes/lk_ble/main.cpp @@ -99,13 +99,12 @@ auto main() -> int auto version = service_update.getVersion(); log_info("Requested version: %d.%d.%d", version.major, version.minor, version.revision); - auto advertising_data = blekit.getAdvertisingData(); - advertising_data.name = "NewLeka"; - advertising_data.battery = level; - advertising_data.is_charging = charging_status; - advertising_data.version_major = uint8_t {0x01}; - advertising_data.version_minor = uint8_t {0x02}; - advertising_data.version_revision = uint16_t {0x0304}; + auto advertising_data = blekit.getAdvertisingData(); + advertising_data.name = "NewLeka"; + advertising_data.battery = level; + advertising_data.is_charging = charging_status; + advertising_data.version_major = uint8_t {0x01}; + advertising_data.version_minor = uint8_t {0x02}; blekit.setAdvertisingData(advertising_data); }