Ersa Wearable Platform
Embedded smartwatch firmware and application framework
Loading...
Searching...
No Matches
ota_service.h
Go to the documentation of this file.
1#pragma once
2
3#include <stdint.h>
4#include <atomic>
5
6namespace ersa {
7namespace services {
8
18public:
20 enum class UpdateState : uint8_t {
22 };
23
25 void begin();
26
28 void tick();
29
31 bool checkForUpdate();
36 bool installUpdate();
38 void resumeAfterCheck();
40 UpdateState updateState() const { return updateState_.load(); }
42 const char* updateVersion() const { return updateVersion_; }
44 const char* updateMessage() const;
46 const char* runningSlot() const;
48 const char* runningImageState() const;
50 const char* runningVersion() const;
52 const char* otherSlot() const;
54 const char* otherImageState() const;
56 bool otherSlotBootable() const;
58 bool selectOtherSlot();
60 static OtaService& instance();
61
62private:
63 static void updateTask(void* context);
64 void runUpdate(bool install);
67 std::atomic<UpdateState> updateState_{UpdateState::Idle};
68 std::atomic<bool> updateTaskActive_{false};
69 std::atomic<bool> resumeComponentsRequested_{false};
70 char updateVersion_[32]{};
71};
72
73} // namespace services
74} // namespace ersa
Definition ota_service.h:17
UpdateState
Definition ota_service.h:20
uint32_t confirmationStartedMs_
Definition ota_service.h:66
void runUpdate(bool install)
Definition ota_service.cpp:527
bool checkForUpdate()
Definition ota_service.cpp:481
const char * runningVersion() const
Return the firmware version embedded in the active image.
Definition ota_service.cpp:685
bool selectOtherSlot()
Definition ota_service.cpp:708
bool installUpdate()
Definition ota_service.cpp:492
std::atomic< UpdateState > updateState_
Definition ota_service.h:67
std::atomic< bool > updateTaskActive_
Definition ota_service.h:68
static OtaService & instance()
Return the installed process-wide OTA service.
Definition ota_service.cpp:448
static void updateTask(void *context)
Definition ota_service.cpp:513
void tick()
Definition ota_service.cpp:466
const char * otherSlot() const
Return the alternate application slot name.
Definition ota_service.cpp:690
char updateVersion_[32]
Definition ota_service.h:70
const char * updateMessage() const
Return a concise status or failure message for the current update.
Definition ota_service.cpp:659
std::atomic< bool > resumeComponentsRequested_
Definition ota_service.h:69
void begin()
Definition ota_service.cpp:453
UpdateState updateState() const
Return the current update state.
Definition ota_service.h:40
const char * runningSlot() const
Return the active application slot name.
Definition ota_service.cpp:670
bool otherSlotBootable() const
Return whether the alternate image passes bootability validation.
Definition ota_service.cpp:704
const char * otherImageState() const
Return the bootloader state of the alternate image.
Definition ota_service.cpp:696
void resumeAfterCheck()
Definition ota_service.cpp:502
bool pendingConfirmation_
Definition ota_service.h:65
const char * updateVersion() const
Return the version being checked or installed.
Definition ota_service.h:42
const char * runningImageState() const
Return the bootloader state of the active image.
Definition ota_service.cpp:678
Definition application.h:10