From c2f8c07b5a0aea0ee59c373331024e2c9c101f7a Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Sun, 1 Oct 2023 12:32:12 +0700 Subject: [PATCH] ota update --- src/espmega_iot_core.cpp | 11 +++- src/espmega_iot_ota.cpp | 3 + src/espmega_iot_ota.hpp | 3 +- src/ota_html/ota-part1.html | 2 +- src/ota_html/ota-part3.html | 2 +- src/ota_html/ota-part4.html | 2 +- src/ota_html/ota-part5.html | 2 +- src/ota_html/ota-part6.html | 2 +- src/ota_html/ota-part7.html | 121 +--------------------------------- src/ota_html/ota-part8.html | 125 ++++++++++++++++++++++++++++++++++++ 10 files changed, 147 insertions(+), 126 deletions(-) create mode 100644 src/ota_html/ota-part8.html diff --git a/src/espmega_iot_core.cpp b/src/espmega_iot_core.cpp index bb1001b..50bf3c7 100644 --- a/src/espmega_iot_core.cpp +++ b/src/espmega_iot_core.cpp @@ -247,12 +247,12 @@ void ota_begin() otaserver.on("/", HTTP_GET, []() { otaserver.sendHeader("Connection", "close"); - String otabuffer = ota_part1+HOSTNAME+ota_part2+IP.toString()+ota_part3+ESPMEGA_REV+ota_part4+MQTT_SERVER.toString()+ota_part5+String(MQTT_BASE_TOPIC)+ota_part6; + String otabuffer = ota_part1+HOSTNAME+ota_part2+IP.toString()+ota_part3+ETH.macAddress()+ota_part4+ESPMEGA_REV+ota_part5+MQTT_SERVER.toString()+ota_part6+String(MQTT_BASE_TOPIC)+ota_part7; if(standalone) otabuffer+=String("No"); else otabuffer+=String("Yes"); - otabuffer+=ota_part7; + otabuffer+=ota_part8; otaserver.send(200, "text/html", otabuffer); }); otaserver.on( "/update", HTTP_POST, []() @@ -265,9 +265,13 @@ void ota_begin() HTTPUpload &upload = otaserver.upload(); if (upload.status == UPLOAD_FILE_START) { + lcd_send_command("page ota"); + String otafiletxt = "Downloading File : " + upload.filename; + panel.writeStr("otatxt.txt",otafiletxt); Serial.printf("Update: %s\n", upload.filename.c_str()); if (!Update.begin(UPDATE_SIZE_UNKNOWN)) { + panel.writeStr("otatxt.txt","Update Failed, Rebooting . . ."); Update.printError(Serial); } } @@ -275,6 +279,7 @@ void ota_begin() { if (Update.write(upload.buf, upload.currentSize) != upload.currentSize) { + panel.writeStr("otatxt.txt","Update Failed, Rebooting . . ."); Update.printError(Serial); } } @@ -282,10 +287,12 @@ void ota_begin() { if (Update.end(true)) { + panel.writeStr("otatxt.txt","Update Completed, Rebooting . . ."); Serial.printf("Update Success: %u\nRebooting...\n", upload.totalSize); } else { + panel.writeStr("otatxt.txt","Update Failed, Rebooting . . ."); Update.printError(Serial); } } diff --git a/src/espmega_iot_ota.cpp b/src/espmega_iot_ota.cpp index 20444fa..282ffd5 100644 --- a/src/espmega_iot_ota.cpp +++ b/src/espmega_iot_ota.cpp @@ -20,4 +20,7 @@ const String ota_part6 = { }; const String ota_part7 = { #include "ota_html/ota-part7.html" +}; +const String ota_part8 = { +#include "ota_html/ota-part8.html" }; \ No newline at end of file diff --git a/src/espmega_iot_ota.hpp b/src/espmega_iot_ota.hpp index 6147e2e..8ca414b 100644 --- a/src/espmega_iot_ota.hpp +++ b/src/espmega_iot_ota.hpp @@ -6,4 +6,5 @@ extern const String ota_part3; extern const String ota_part4; extern const String ota_part5; extern const String ota_part6; -extern const String ota_part7; \ No newline at end of file +extern const String ota_part7; +extern const String ota_part8; \ No newline at end of file diff --git a/src/ota_html/ota-part1.html b/src/ota_html/ota-part1.html index 70f5d26..a63d855 100644 --- a/src/ota_html/ota-part1.html +++ b/src/ota_html/ota-part1.html @@ -1,7 +1,7 @@ R"=====(

ESPMega PRO

-

Programming Tool

+

Software Management

Hostname diff --git a/src/ota_html/ota-part3.html b/src/ota_html/ota-part3.html index 76b974c..d92b7e1 100644 --- a/src/ota_html/ota-part3.html +++ b/src/ota_html/ota-part3.html @@ -1,5 +1,5 @@ R"=====(

- Device + MAC Address )=====" \ No newline at end of file diff --git a/src/ota_html/ota-part4.html b/src/ota_html/ota-part4.html index d7745f3..76b974c 100644 --- a/src/ota_html/ota-part4.html +++ b/src/ota_html/ota-part4.html @@ -1,5 +1,5 @@ R"=====(

- API Server + Device )=====" \ No newline at end of file diff --git a/src/ota_html/ota-part5.html b/src/ota_html/ota-part5.html index 743ba2a..d7745f3 100644 --- a/src/ota_html/ota-part5.html +++ b/src/ota_html/ota-part5.html @@ -1,5 +1,5 @@ R"=====(

- API Endpoint + API Server )=====" \ No newline at end of file diff --git a/src/ota_html/ota-part6.html b/src/ota_html/ota-part6.html index 567deb3..743ba2a 100644 --- a/src/ota_html/ota-part6.html +++ b/src/ota_html/ota-part6.html @@ -1,5 +1,5 @@ R"=====(

- Centrally Managed + API Endpoint )=====" \ No newline at end of file diff --git a/src/ota_html/ota-part7.html b/src/ota_html/ota-part7.html index c6768c3..567deb3 100644 --- a/src/ota_html/ota-part7.html +++ b/src/ota_html/ota-part7.html @@ -1,120 +1,5 @@ R"=====(

- - - -

-
-
-
-
-
-
-SIWAT SYSTEM 2023 -
- -)=====" \ No newline at end of file +

+ Centrally Managed + )=====" \ No newline at end of file diff --git a/src/ota_html/ota-part8.html b/src/ota_html/ota-part8.html new file mode 100644 index 0000000..4f94bee --- /dev/null +++ b/src/ota_html/ota-part8.html @@ -0,0 +1,125 @@ +R"=====( +

+ + + +

+
+
+
+
+
+
+SIWAT SYSTEM 2023 + + +)=====" \ No newline at end of file