Skip to content

Commit

Permalink
🚸 (rc): Add Update BLE Service + Use get Firmware version and Apply u…
Browse files Browse the repository at this point in the history
…pdate
  • Loading branch information
YannLocatelli committed Mar 25, 2022
1 parent 846432d commit 8d1eb20
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions libs/RobotKit/include/RobotController.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "BLEServiceBattery.h"
#include "BLEServiceDeviceInformation.h"
#include "BLEServiceMonitoring.h"
#include "BLEServiceUpdate.h"

#include "BatteryKit.h"
#include "BehaviorKit.h"
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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 {});
};

Expand Down Expand Up @@ -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<interface::BLEService *>({&_service_device_information, &_service_battery, &_service_monitoring});
inline static BLEServiceUpdate _service_update {};
inline static auto services = std::to_array<interface::BLEService *>(
{&_service_device_information, &_service_battery, &_service_monitoring, &_service_update});
};

} // namespace leka

0 comments on commit 8d1eb20

Please sign in to comment.