feat(ota): implement deferred OTA update scheduling and handling

Added support for deferred OTA updates in the MyMesh class, allowing
the system to schedule firmware updates to occur after a confirmation
reply is sent. This change improves the user experience by ensuring
that the update process does not block the main application loop,
allowing for smoother operation during firmware updates.
This commit is contained in:
agessaman committed 2026-06-22 22:33:57 -07:00
1 parent dec668386a
commit c1885fcc15
8 files changed
+136 -29

No files matched your search

+16
View File
@@ -1445,6 +1445,22 @@ void MyMesh::loop() {
MESH_DEBUG_PRINTLN("Radio params restored");
}
#if defined(WITH_MQTT_BRIDGE) && defined(OTA_MANIFEST_URL)
if (_ota_update_at && millisHasNowPassed(_ota_update_at)) { // deferred `ota update`
_ota_update_at = 0; // clear timer
// The "Beginning update..." reply has now gone out. Free the bridge for heap
// headroom, then flash: otaFromManifest reboots into the new image on success
// (so this never returns); on any abort (already up to date, partition change,
// download error) it returns and we resume the bridge.
setBridgeState(false);
char ota_reply[160];
if (!_cli.getBoard()->otaFromManifest(getFirmwareVer(), false, ota_reply)) {
MESH_DEBUG_PRINTLN("ota update aborted: %s", ota_reply);
setBridgeState(true);
}
}
#endif
// is pending dirty contacts write needed?
if (dirty_contacts_expiry && millisHasNowPassed(dirty_contacts_expiry)) {
acl.save(_fs);