diff --git a/libs/RobotKit/include/RobotController.h b/libs/RobotKit/include/RobotController.h index 4dca5af41b..7ec5c0109e 100644 --- a/libs/RobotKit/include/RobotController.h +++ b/libs/RobotKit/include/RobotController.h @@ -11,6 +11,7 @@ #include "BLEServiceBattery.h" #include "BLEServiceDeviceInformation.h" #include "BLEServiceMonitoring.h" +#include "BLEServiceUpdate.h" #include "BatteryKit.h" #include "BehaviorKit.h" @@ -125,7 +126,7 @@ class RobotController : public interface::RobotController void applyUpdate() final { - auto firmware_version = FirmwareVersion {.major = 1, .minor = 2, .revision = 3}; + auto firmware_version = _service_update.getVersion(); if (_firmware_update.loadUpdate(firmware_version) && _on_update_loaded_callback != nullptr) { _on_update_loaded_callback(); } @@ -194,6 +195,9 @@ class RobotController : public interface::RobotController _service_monitoring.onSoftReboot([] { system_reset(); }); + auto on_update_requested = [this]() { raise(event::update_requested {}); }; + _service_update.onApplyUpdateTrue(on_update_requested); + raise(event::setup_complete {}); }; @@ -224,8 +228,9 @@ class RobotController : public interface::RobotController inline static BLEServiceDeviceInformation _service_device_information {}; inline static BLEServiceBattery _service_battery {}; inline static BLEServiceMonitoring _service_monitoring {}; - inline static auto services = - std::to_array({&_service_device_information, &_service_battery, &_service_monitoring}); + inline static BLEServiceUpdate _service_update {}; + inline static auto services = std::to_array( + {&_service_device_information, &_service_battery, &_service_monitoring, &_service_update}); }; } // namespace leka