Skip to content

Class LibreTinyOTA

ClassList > LibreTinyOTA

Over-the-Air updates helper class. More...

  • #include <OTA.h>

Public Functions

Type Name
bool canRollback ()
Check if OTA rollback is possible (switching the stored index to another partition).
uint8_t getCurrentIndex ()
Get the currently running firmware's OTA index.
uint8_t getStoredIndex ()
Read the currently active OTA index, i.e. the one that will boot upon restart.
lt_ota_type_t getType ()
Get OTA type of the device's chip.
uf2_ota_scheme_t getUF2Scheme ()
Check which UF2 OTA scheme should be used for applying firmware updates.
bool isValid (uint8_t index)
Check if the specified OTA image is valid.
bool switchImage (bool revert=false)
Try to switch OTA index to the other image. For single-OTA chips, only check if the upgrade image is valid.

Detailed Description

This class only consists of inline functions, which wrap the LibreTiny C API (lt_api.h). Refer to the docs of the C API for more information.

The class is accessible using the OTA global object.

Public Functions Documentation

function canRollback

Check if OTA rollback is possible (switching the stored index to another partition).

inline bool LibreTinyOTA::canRollback () 

Note that this is not the same as "switching" OTA with revert=true.

Returns:

true if 2nd image is valid and the chip is dual-OTA; false otherwise

function getCurrentIndex

Get the currently running firmware's OTA index.

inline uint8_t LibreTinyOTA::getCurrentIndex () 

Returns:

OTA index if dual-OTA is supported, 0 otherwise

function getStoredIndex

Read the currently active OTA index, i.e. the one that will boot upon restart.

inline uint8_t LibreTinyOTA::getStoredIndex () 

Returns:

OTA index if dual-OTA is supported, 0 otherwise

function getType

inline lt_ota_type_t LibreTinyOTA::getType () 

function getUF2Scheme

Check which UF2 OTA scheme should be used for applying firmware updates.

inline uf2_ota_scheme_t LibreTinyOTA::getUF2Scheme () 

Returns:

OTA scheme of the target partition

function isValid

Check if the specified OTA image is valid.

inline bool LibreTinyOTA::isValid (
    uint8_t index
) 

Parameters:

  • index OTA index to check; 0 for single-OTA chips, 1 or 2 for dual-OTA chips

Returns:

true if index is valid for the chip's OTA type, and there is a valid image; false otherwise

function switchImage

Try to switch OTA index to the other image. For single-OTA chips, only check if the upgrade image is valid.

inline bool LibreTinyOTA::switchImage (
    bool revert=false
) 

This can be used to "activate" the upgrade after flashing.

Parameters:

  • revert switch if (and only if) the other image is already marked as active (i.e. switch back to the running image)

Returns:

false if the second image (or upgrade image) is not valid; false if writing failed; true otherwise


The documentation for this class was generated from the following file cores/common/arduino/libraries/inline/OTA/OTA.h