ESP32-OTA-Updater
Loading...
Searching...
No Matches
Public Member Functions | List of all members
ESP32_OTA_Updater Class Reference

Class for performing Over-The-Air (OTA) updates on ESP32 devices, with Github Actions and Releases. More...

#include <ESP32_OTA_Updater.h>

Public Member Functions

 ESP32_OTA_Updater (const char *rootCertificate, const char *current_version)
 Constructor for the ESP32_OTA_Updater class.
 
bool begin (const char *owner, const char *repo, const char *firmware_path, const char *api_key)
 Initializes the ESP32 OTA Updater.
 
bool begin (const char *owner, const char *repo, const char *firmware_path)
 Initializes the ESP32 OTA Updater.
 
bool available ()
 Checks if a firmware update is available.
 
bool downloadAndInstall ()
 Downloads and installs the firmware update. Use 'reboot()' for the esp to reboot and the update to take effect!
 
void reboot ()
 Initiates a reboot of the esp32, which effectively finished a previously installed update.
 
ESP32_OTA_Updater_Error getErrorCode ()
 Get the error code.
 
String getErrorDescription ()
 Returns the description of the last error that occurred.
 
void setDebug (Print *debugStream)
 Sets the debug output stream for logging messages.
 

Detailed Description

Class for performing Over-The-Air (OTA) updates on ESP32 devices, with Github Actions and Releases.

This class checks for new Github Releases compares the semantic version and downloads/installs the firmware update. For now the System automatically uses the LittleFS file system, but a custom fs:FS can be specified on begin().

Constructor & Destructor Documentation

◆ ESP32_OTA_Updater()

ESP32_OTA_Updater::ESP32_OTA_Updater ( const char *  rootCertificate,
const char *  current_version 
)

Constructor for the ESP32_OTA_Updater class.

This constructor initializes the OTA updater with the specified root certificates for secure HTTPS communication.

Note
Please supply the all Certs for all Github endpoints concatenated in one string
Parameters
rootCertificateThe root certificates for GitHub's HTTPS server and Githubs Download Server.
current_versionThe semantic version of the fimware currently installed, should be "v.0.0.0" or "0.0.0"

Member Function Documentation

◆ available()

bool ESP32_OTA_Updater::available ( )

Checks if a firmware update is available.

This function checks if a new firmware update is available by comparing the current version with the version specified in the firmware update file.

Returns
True if a firmware update is available, false otherwise.

◆ begin() [1/2]

bool ESP32_OTA_Updater::begin ( const char *  owner,
const char *  repo,
const char *  firmware_path 
)

Initializes the ESP32 OTA Updater.

Parameters
ownerThe owner of the repository where the firmware is build an released.
repoThe name of the repository where the firmware is build an released.
firmware_pathThe path to the firmware binary file on the Github Release -> the asset name.
Returns
true if the initialization was successful, false otherwise.

◆ begin() [2/2]

bool ESP32_OTA_Updater::begin ( const char *  owner,
const char *  repo,
const char *  firmware_path,
const char *  api_key 
)

Initializes the ESP32 OTA Updater.

Parameters
ownerThe owner of the repository where the firmware is build an released.
repoThe name of the repository where the firmware is build an released.
firmware_pathThe path to the firmware binary file on the Github Release -> the asset name.
gh_api_keyThe (Fine Grained) Github Personal Access Token.
Returns
true if the initialization was successful, false otherwise.

◆ downloadAndInstall()

bool ESP32_OTA_Updater::downloadAndInstall ( )

Downloads and installs the firmware update. Use 'reboot()' for the esp to reboot and the update to take effect!

This function downloads the firmware update file from the specified URL and installs it on the ESP32 device.

Note
This function should only be called if a firmware update is available (i.e., available() returns true).

◆ getErrorCode()

ESP32_OTA_Updater_Error ESP32_OTA_Updater::getErrorCode ( )

Get the error code.

This function returns the error code associated with the last operation performed by the ESP32 OTA Updater.

Returns
The error code.

◆ getErrorDescription()

String ESP32_OTA_Updater::getErrorDescription ( )

Returns the description of the last error that occurred.

This function returns a string containing the description of the last error that occurred during the execution of the program.

Returns
A string containing the description of the last error.

◆ setDebug()

void ESP32_OTA_Updater::setDebug ( Print *  debugStream)

Sets the debug output stream for logging messages.

Parameters
debugStreamA pointer to a Print object, e.g. Serial. Pass NULL to disable debug logging.

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