A semver-based OTA client SDK for the VoyagerOTA. That also supports structured way for GitHub Releases and custom JSON backend for ESP32 OTA.
For VoyagerOTA, define
__USE_STAGING_CHANNEL__astrueorfalsebefore includingVoyagerOTAClient.h. This macro determines which release channel the OTA client uses. When set totrue, it fetches the latest staging release for testing and development. When set tofalse, it uses the production channel for production devices.Kindly note that the firmware compiled with
__USE_STAGING_CHANNEL__set totrueis identified as a staging build and will be rejected during VoyagerOTA's artifact build inspection process. Therefore, always set__USE_STAGING_CHANNEL__tofalsebefore uploading the firmware to VoyagerOTA as a production release.
// Staging mode is for for staging environment builds for testing....
// Make sure to always disable the [__USE_STAGING_CHANNEL__] flag to false
// while uploading the Binary to VoyagerOTA Platform as staging builds are not
// allowed....And by disabling it the build is treated as production build...
#define __USE_STAGING_CHANNEL__ true
#define CURRENT_FIRMWARE_VERSION "1.0.0"
#include <VoyagerOTAClient.h>
#include <WiFi.h>
using namespace Voyager;
void connectToWifi() {
WiFi.begin("SSID", "PASSWORD");
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(50);
}
Serial.println("Connected to Internet");
}
void setup() {
Serial.begin(9600);
connectToWifi();
OTA<HTTPResponseData, VoyagerReleaseModel> ota(CURRENT_FIRMWARE_VERSION);
ota.setCredentials("voyager-project-id-here....", "voyager-api-key-here...");
ota.setBaseURL("voyager-base-url.....");
auto release = ota.fetchLatestRelease();
if (release && ota.isNewVersion(release->version)) {
Serial.println("New version available: " + release->version);
Serial.println("Changelog: " + release->changeLog);
ota.setDownloadURL(release->downloadURL);
ota.performUpdate();
} else {
Serial.println("No updates available");
}
}
void loop() {}Enable advanced mode for custom OTA backend support:
#define __ENABLE_ADVANCED_MODE__ true
#include <VoyagerOTAClient.h>All custom payload models must extend Voyager::BaseModel.
Each model inherits:
versionrelease used for semver comparison.downloadURLof the firmware binary.
Voyager-specific features are disabled in advanced mode.
- VoyagerOTA Example
- GitHub OTA Example - (Advanced Mode)
- Custom Backend Example - (Advanced Mode)
- C++17 or higher
- ArduinoJson version 7.0 or above
- cpp-semver v0.4.0
- HTTPUpdate v3.0.7
This project is licensed under the MIT License. See the LICENSE file for details.