I was trying to understand if it is possible(if yes how) to continue the OTA process after downloading the bin file hosted in a remote IP (within the network) ? The code is to be running on ESP32. (Edit) i am trying to introduce a method of self OTA update..which can also be triggered by hitting an end point of the esp webserver (either through mqtt, http etc etc)
I am referring to How to enable the server to automatically download files using arduino for ESP32 WebServer without using SPIFFS and instead using SDcard file but it focusses on downloading from sd card but not network.
Currently, I am following the code mentioned in https://randomnerdtutorials.com/esp32-over-the-air-ota-programming/ which currently deals in uploading the bin file through browser, which I am trying to automate. If somehow I can trigger this part of the code with the data programmatically then I think my question will still be solved.
server.on("/update", HTTP_POST, []() {
server.sendHeader("Connection", "close");
server.send(200, "text/plain", (Update.hasError()) ? "FAIL" : "OK");
ESP.restart();
}, []() {
HTTPUpload& upload = server.upload();
if (upload.status == UPLOAD_FILE_START) {
Serial.printf("Update: %s\n", upload.filename.c_str());
if (!Update.begin(UPDATE_SIZE_UNKNOWN)) { //start with max available size
Update.printError(Serial);
}
} else if (upload.status == UPLOAD_FILE_WRITE) {
/* flashing firmware to ESP*/
if (Update.write(upload.buf, upload.currentSize) != upload.currentSize) {
Update.printError(Serial);
}
} else if (upload.status == UPLOAD_FILE_END) {
if (Update.end(true)) { //true to set the size to the current progress
Serial.printf("Update Success: %u\nRebooting...\n", upload.totalSize);
} else {
Update.printError(Serial);
}
}
});
Regards, Shariq