diff --git a/libs/RobotKit/include/RobotController.h b/libs/RobotKit/include/RobotController.h index 28712ed8ff..1c8263db5b 100644 --- a/libs/RobotKit/include/RobotController.h +++ b/libs/RobotKit/include/RobotController.h @@ -10,6 +10,7 @@ #include "BLEServiceBattery.h" #include "BLEServiceDeviceInformation.h" #include "BLEServiceMonitoring.h" +#include "BLEServiceUpdate.h" #include "BatteryKit.h" #include "BehaviorKit.h" @@ -87,7 +88,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(); } @@ -131,6 +132,9 @@ class RobotController : public interface::RobotController auto on_charge_did_stop = [this]() { raise(event::charge_did_stop {}); }; _battery.onChargeDidStop(on_charge_did_stop); + auto on_update_requested = [this]() { raise(event::update_requested {}); }; + _service_update.onApplyUpdateTrue(on_update_requested); + raise(event::setup_complete {}); }; @@ -154,8 +158,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