Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions Controller/Controller.ino
Original file line number Diff line number Diff line change
Expand Up @@ -3695,8 +3695,9 @@ void setup_OtaFirmware(){


/**
* Executes a pending forced OTA update using execOTA(JsonDocument&), matching
* the HW-Reg implementation exactly. onComplete handles the reboot on success.
* Executes a pending OTA update. If _otaPendingDoc is empty the update was
* triggered from HA via MQTT (non-forced); otherwise it is a forced update
* with a specific document from the HTTP API.
*/
void otaFirmware_checkPending(){

Expand All @@ -3705,6 +3706,14 @@ void otaFirmware_checkPending(){
}

_otaUpdateInProcess = true;
_otaCurrentPartition[0] = '\0';

if(_otaPendingDoc.size() == 0){
_otaPendingRequest = false;
otaFirmware.execOTA();
_otaUpdateInProcess = false;
return;
}

otaFirmware.setApplicationName(_otaPendingDoc["application_name"]);

Expand All @@ -3720,8 +3729,6 @@ void otaFirmware_checkPending(){
}
}

_otaCurrentPartition[0] = '\0';

otaFirmware.onProgress([](const char* partition, size_t written, size_t total){
_otaUpdateInProcess = true;
if(strcmp(partition, _otaCurrentPartition) != 0){
Expand Down Expand Up @@ -4375,7 +4382,7 @@ void eventHandler_mqttMessageReceived(char* topic, byte* pl, unsigned int length
mqttClient.publish(topic, buffer);

if(!_otaManifestUrl.isEmpty()){
otaFirmware.execOTA();
_otaPendingRequest = true;
}
return;
}
Expand Down
Loading