Skip to content

Class UpdateClass

ClassList > UpdateClass

Public Types

Type Name
typedef std::function< void(size_t, size_t)> THandlerFunction_Progress

Public Functions

Type Name
UpdateClass ()
void abort ()
Abort the update with UPDATE_ERROR_ABORT reason.
bool begin (size_t size=UPDATE_SIZE_UNKNOWN, int command=U_FLASH, int unused2=-1, uint8_t unused3=LOW, const char * unused4=NULL)
Initialize the update process.
bool canRollBack ()
Check if OTA rollback is possible (switching the stored index to another partition).
void clearError ()
bool end (bool evenIfRemaining=false)
Finalize the update process. Check for errors and update completion, then activate the new firmware image.
const char * errorString ()
Get string representation of the error in format "ard=..,uf2=..". Returns "" if no error.
const char * getBoardName ()
Get target board name from UF2 info.
uint8_t getError ()
uint16_t getErrorCode ()
const char * getFirmwareName ()
Get firmware name from UF2 info.
const char * getFirmwareVersion ()
Get firmware version from UF2 info.
const char * getLibreTinyVersion ()
Get LibreTiny version from UF2 info.
uf2_err_t getUF2Error ()
bool hasError ()
bool isFinished ()
bool isRunning ()
void md5 (uint8_t * result)
String md5String (void)
UpdateClass & onProgress (THandlerFunction_Progress callback)
Set the callback invoked after writing data to flash.
void printError (Print & out)
Print string error info to the stream.
size_t progress ()
size_t remaining ()
bool rollBack ()
Try to switch OTA index to the other image. For single-OTA chips, only check if the upgrade image is valid.
size_t size ()
size_t write (uint8_t * data, size_t len)
Write a chunk of data to the buffer or flash memory.
size_t writeStream (Stream & data)

Public Types Documentation

typedef THandlerFunction_Progress

typedef std::function<void(size_t, size_t)> UpdateClass::THandlerFunction_Progress;

Public Functions Documentation

function UpdateClass

UpdateClass::UpdateClass () 

function abort

void UpdateClass::abort () 

function begin

Initialize the update process.

bool UpdateClass::begin (
    size_t size=UPDATE_SIZE_UNKNOWN,
    int command=U_FLASH,
    int unused2=-1,
    uint8_t unused3=LOW,
    const char * unused4=NULL
) 

Parameters:

  • size total UF2 file size
  • command must be U_FLASH

Returns:

false if parameters are invalid or update is running, true otherwise

function canRollBack

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

bool UpdateClass::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 clearError

inline void UpdateClass::clearError () 

function end

Finalize the update process. Check for errors and update completion, then activate the new firmware image.

bool UpdateClass::end (
    bool evenIfRemaining=false
) 

Parameters:

  • evenIfRemaining no idea

Returns:

false in case of errors or no update running, true otherwise

function errorString

const char * UpdateClass::errorString () 

function getBoardName

const char * UpdateClass::getBoardName () 

function getError

inline uint8_t UpdateClass::getError () 

function getErrorCode

inline uint16_t UpdateClass::getErrorCode () 

function getFirmwareName

const char * UpdateClass::getFirmwareName () 

function getFirmwareVersion

const char * UpdateClass::getFirmwareVersion () 

function getLibreTinyVersion

const char * UpdateClass::getLibreTinyVersion () 

function getUF2Error

inline uf2_err_t UpdateClass::getUF2Error () 

function hasError

inline bool UpdateClass::hasError () 

function isFinished

inline bool UpdateClass::isFinished () 

function isRunning

inline bool UpdateClass::isRunning () 

function md5

inline void UpdateClass::md5 (
    uint8_t * result
) 

function md5String

inline String UpdateClass::md5String (
    void
) 

function onProgress

UpdateClass & UpdateClass::onProgress (
    THandlerFunction_Progress callback
) 

function printError

void UpdateClass::printError (
    Print & out
) 

function progress

inline size_t UpdateClass::progress () 

function remaining

inline size_t UpdateClass::remaining () 

function rollBack

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

bool UpdateClass::rollBack () 

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

function size

inline size_t UpdateClass::size () 

function write

Write a chunk of data to the buffer or flash memory.

size_t UpdateClass::write (
    uint8_t * data,
    size_t len
) 

It's advised to write in 512-byte chunks (or its multiples).

Parameters:

  • data
  • len

Returns:

size_t

function writeStream

size_t UpdateClass::writeStream (
    Stream & data
) 

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