feat(mqtt): implement deferred OTA update scheduling in MyMesh
Add functionality to schedule deferred OTA updates in the MyMesh class.
This includes a new member variable to track the update time and a method
to initiate the update process, allowing for a smoother OTA experience
by managing timing and state transitions effectively.
Cherry-picked from observer-firmware (76f44d7d). Resolved a conflict in
loop() where the WITH_WEBCONFIG block occupies the same anchor and shares
an identical closing tail; both blocks retained.
This commit is contained in:
1 parent
8cec341d78
commit
bd58d8af5b
2 files changed
+27
No files matched your search
@@ -1494,6 +1494,23 @@ void MyMesh::loop() {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(WITH_MQTT_BRIDGE) && defined(OTA_MANIFEST_BASE)
|
||||
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.
|
||||
Serial.println("OTA: starting update");
|
||||
setBridgeState(false);
|
||||
char ota_reply[160];
|
||||
if (!_cli.getBoard()->otaFromManifest(getFirmwareVer(), false, ota_reply)) {
|
||||
Serial.print("OTA: aborted, resuming bridge - "); Serial.println(ota_reply);
|
||||
setBridgeState(true);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// is pending dirty contacts write needed?
|
||||
if (dirty_contacts_expiry && millisHasNowPassed(dirty_contacts_expiry)) {
|
||||
acl.save(_fs, MyMesh::saveFilter);
|
||||
|
||||
Reference in new issue
Block a user