diff --git a/libs/BLEKit/include/AdvertisingData.h b/libs/BLEKit/include/AdvertisingData.h index 89add2161..330ad5c0e 100644 --- a/libs/BLEKit/include/AdvertisingData.h +++ b/libs/BLEKit/include/AdvertisingData.h @@ -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() { @@ -28,15 +29,18 @@ struct AdvertisingData { // private: void updateValues() { - _internal_values = {battery, - is_charging, - version_major, - version_minor, - static_cast(version_revision >> 8), - static_cast(version_revision)}; + _internal_values = { + battery, + is_charging, + version_major, + version_minor, + static_cast(version_revision >> 8), + static_cast(version_revision), + 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 31a260bc6..641ad34c5 100644 --- a/libs/BLEKit/tests/AdvertisingData_test.cpp +++ b/libs/BLEKit/tests/AdvertisingData_test.cpp @@ -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({ @@ -34,6 +35,7 @@ TEST(AdvertisingDataTest, data) 0x2D, 0x2E, 0x2F, + 0x30, }); 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 ec6aca7e1..33ba46415 100644 --- a/libs/BLEKit/tests/CoreGap_test.cpp +++ b/libs/BLEKit/tests/CoreGap_test.cpp @@ -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(default_advertising_data.version_revision >> 8), - static_cast(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(default_advertising_data.version_revision >> 8), + static_cast(default_advertising_data.version_revision), + 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 129bf28b0..d083a226e 100644 --- a/libs/RobotKit/include/RobotController.h +++ b/libs/RobotKit/include/RobotController.h @@ -315,6 +315,10 @@ class RobotController : public interface::RobotController component->enableDeepSleep(); } _ble.disconnect(); + + auto advertising_data = _ble.getAdvertisingData(); + advertising_data.is_deep_sleeping = true; + _ble.setAdvertisingData(advertising_data); } void wakeUp() final { system_reset(); }