Ersa Wearable Platform
Embedded smartwatch firmware and application framework
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
ersa::services::OtaService Class Reference

#include <ota_service.h>

Public Types

enum class  UpdateState : uint8_t {
  Idle , Checking , UpToDate , Available ,
  Installing , Failed
}
 

Public Member Functions

void begin ()
 
void tick ()
 
bool checkForUpdate ()
 
bool installUpdate ()
 
void resumeAfterCheck ()
 
UpdateState updateState () const
 Return the current update state.
 
const char * updateVersion () const
 Return the version being checked or installed.
 
const char * updateMessage () const
 Return a concise status or failure message for the current update.
 
const char * runningSlot () const
 Return the active application slot name.
 
const char * runningImageState () const
 Return the bootloader state of the active image.
 
const char * runningVersion () const
 Return the firmware version embedded in the active image.
 
const char * otherSlot () const
 Return the alternate application slot name.
 
const char * otherImageState () const
 Return the bootloader state of the alternate image.
 
bool otherSlotBootable () const
 Return whether the alternate image passes bootability validation.
 
bool selectOtherSlot ()
 

Static Public Member Functions

static OtaService & instance ()
 Return the installed process-wide OTA service.
 

Private Member Functions

void runUpdate (bool install)
 

Static Private Member Functions

static void updateTask (void *context)
 

Private Attributes

bool pendingConfirmation_ {false}
 
uint32_t confirmationStartedMs_ {0}
 
std::atomic< UpdateState > updateState_ {UpdateState::Idle}
 
std::atomic< bool > updateTaskActive_ {false}
 
std::atomic< bool > resumeComponentsRequested_ {false}
 
char updateVersion_ [32] {}
 

Detailed Description

Coordinates release checks, inactive-slot image installation, and rollback safety.

Network download runs outside the UI tick. The bootloader records whether an image is pending validation; this service confirms it only after firmware startup checks pass. Keeping slot selection and confirmation here prevents app code from writing arbitrary flash addresses or bypassing rollback.

Member Enumeration Documentation

◆ UpdateState

enum class ersa::services::OtaService::UpdateState : uint8_t
strong

User-visible OTA lifecycle state, updated atomically by worker tasks.

Enumerator
Idle 
Checking 
UpToDate 
Available 
Installing 
Failed 

Member Function Documentation

◆ begin()

void ersa::services::OtaService::begin ( )

Inspect boot metadata and begin the pending-image validation window.

◆ checkForUpdate()

bool ersa::services::OtaService::checkForUpdate ( )

Start a bounded background manifest check; inspect updateState() for result.

◆ installUpdate()

bool ersa::services::OtaService::installUpdate ( )

Start image download and validation into the inactive OTA slot. The active image remains selected until bootloader metadata is updated.

◆ instance()

OtaService & ersa::services::OtaService::instance ( )
static

Return the installed process-wide OTA service.

◆ otherImageState()

const char * ersa::services::OtaService::otherImageState ( ) const

Return the bootloader state of the alternate image.

◆ otherSlot()

const char * ersa::services::OtaService::otherSlot ( ) const

Return the alternate application slot name.

◆ otherSlotBootable()

bool ersa::services::OtaService::otherSlotBootable ( ) const

Return whether the alternate image passes bootability validation.

◆ resumeAfterCheck()

void ersa::services::OtaService::resumeAfterCheck ( )

Resume suspended providers after check/install work releases resources.

◆ runningImageState()

const char * ersa::services::OtaService::runningImageState ( ) const

Return the bootloader state of the active image.

◆ runningSlot()

const char * ersa::services::OtaService::runningSlot ( ) const

Return the active application slot name.

◆ runningVersion()

const char * ersa::services::OtaService::runningVersion ( ) const

Return the firmware version embedded in the active image.

◆ runUpdate()

void ersa::services::OtaService::runUpdate ( bool  install)
private

◆ selectOtherSlot()

bool ersa::services::OtaService::selectOtherSlot ( )

Select the alternate slot only after verifying its image state is bootable.

◆ tick()

void ersa::services::OtaService::tick ( )

Confirm a healthy boot or apply worker completion without blocking UI.

◆ updateMessage()

const char * ersa::services::OtaService::updateMessage ( ) const

Return a concise status or failure message for the current update.

◆ updateState()

UpdateState ersa::services::OtaService::updateState ( ) const
inline

Return the current update state.

◆ updateTask()

void ersa::services::OtaService::updateTask ( void *  context)
staticprivate

◆ updateVersion()

const char * ersa::services::OtaService::updateVersion ( ) const
inline

Return the version being checked or installed.

Member Data Documentation

◆ confirmationStartedMs_

uint32_t ersa::services::OtaService::confirmationStartedMs_ {0}
private

◆ pendingConfirmation_

bool ersa::services::OtaService::pendingConfirmation_ {false}
private

◆ resumeComponentsRequested_

std::atomic<bool> ersa::services::OtaService::resumeComponentsRequested_ {false}
private

◆ updateState_

std::atomic<UpdateState> ersa::services::OtaService::updateState_ {UpdateState::Idle}
private

◆ updateTaskActive_

std::atomic<bool> ersa::services::OtaService::updateTaskActive_ {false}
private

◆ updateVersion_

char ersa::services::OtaService::updateVersion_[32] {}
private

The documentation for this class was generated from the following files: