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 18, 2022
1 parent 1d14ff5 commit c9536e7
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 @@ -10,6 +10,7 @@
#include "BLEServiceBattery.h"
#include "BLEServiceDeviceInformation.h"
#include "BLEServiceMonitoring.h"
#include "BLEServiceUpdate.h"

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

Expand All @@ -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<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 c9536e7

Please sign in to comment.