diff --git a/README.md b/README.md index 0118d68..1430809 100644 --- a/README.md +++ b/README.md @@ -13,9 +13,9 @@ I started this project back in october 2019 and never expected it to become that * Partition-layout for ESP32 is changed along with this branch. This step was necessary in order to resize (enlarge) the memory-region where especially the assignments for the RFID-tags are saved. As all permanent settings (e.g. WiFi-settings) are saved there too, it's necessary to re-enter WiFi-credentials after update. But the most important thing is to recover the assignments for the RFID-tags. Please consult my [migration-document](https://forum.espuino.de/t/wechsel-zum-refactoring-branch-was-ist-zu-beachten/510). ## Changelog Last three events: +* 13.07.2021: Adding OTA-support via webGUI * 09.07.2021: Making branch `refactoring` the new master * 09.07.2021: Making master new branch `old` (not maintained any longer!) -* 08.07.2021: Added support to monitor WiFi's RSSI ## Known bugs * Some webstreams don't run. Guess it's a combination of saturated connection-pool and lack of heap-memory. Works probably better if ESP32-WROVER (e.g. Lolin D32 pro) is used, as this chip has PSRAM. Advice: Don't enable modules (e.g. MQTT) if you don't need them as this could save memory (and trouble). ## ESPuino - what's that? diff --git a/changelog.md b/changelog.md index aba272d..550f974 100644 --- a/changelog.md +++ b/changelog.md @@ -8,6 +8,7 @@ * 08.07.2021: Added support to monitor WiFi's RSSI * 09.07.2021: Making branch `refactoring` the the master * 09.07.2021: Making master the new branch `old` (not maintained any longer!) +* 13.07.2021: Adding OTA-support via webGUI ## Old (monolithic main.cpp) * 11.07.2020: Added support for reversed Neopixel addressing. diff --git a/html/management_DE.html b/html/management_DE.html index ded8547..6ad0c95 100644 --- a/html/management_DE.html +++ b/html/management_DE.html @@ -484,6 +484,18 @@ +
+
+
+ Firmware-Update +
+
+ + +
+ +
+
+
+
+
+ Firmware Update +
+
+ + +
+ +
+
\ +
\ +
\ +
\ + Firmware-Update\ +
\ +
\ + \ + \ +
\ + \ +
\ +
\
\
\ Forum\ diff --git a/src/HTMLmanagement_EN.h b/src/HTMLmanagement_EN.h index 4cd28df..4275ff6 100644 --- a/src/HTMLmanagement_EN.h +++ b/src/HTMLmanagement_EN.h @@ -484,6 +484,18 @@ static const char management_HTML[] PROGMEM = "\ \
\
\ +
\ +
\ +
\ + Firmware Update\ +
\ +
\ + \ + \ +
\ + \ +
\ +
\
\
\ Forum\ diff --git a/src/LogMessages_DE.cpp b/src/LogMessages_DE.cpp index a90b2f2..be95bd8 100644 --- a/src/LogMessages_DE.cpp +++ b/src/LogMessages_DE.cpp @@ -200,4 +200,9 @@ const char eraseRfidNvsWeb[] PROGMEM = "

Die NVS-RFID-Zuweisungen werden gelöscht...
Zur letzten Seite zurückkehren.

"; const char eraseRfidNvs[] PROGMEM = "NVS-RFID-Zuweisungen werden gelöscht..."; const char erasePlaylistCachefile[] PROGMEM = "Playlist-Cachefile gelöscht"; + const char fwStart[] PROGMEM = "Starte Firmware-update via OTA..."; + const char fwEnd[] PROGMEM = "Firmware-update beendet"; + const char otaNotSupported[] PROGMEM = "Firmware-update wird von diesem ESPuino nicht unterstuetzt!"; + const char otaNotSupportedWebsite[] PROGMEM = "

Firmware-update wird von diesem ESPuino nicht unterstuetzt!
Zur letzten Seite zurückkehren.

"; + #endif diff --git a/src/LogMessages_EN.cpp b/src/LogMessages_EN.cpp index f98b257..93bd9f3 100644 --- a/src/LogMessages_EN.cpp +++ b/src/LogMessages_EN.cpp @@ -200,4 +200,9 @@ const char eraseRfidNvsWeb[] PROGMEM = "

NVS-RFID-assignments are being deleted...
Back to last page.

"; const char eraseRfidNvs[] PROGMEM = "NVS-RFID-assignments are being deleted..."; const char erasePlaylistCachefile[] PROGMEM = "Playlist-cachefile deleted"; + const char fwStart[] PROGMEM = "Starting firmware-update via OTA..."; + const char fwEnd[] PROGMEM = "Firmware-update finished"; + const char otaNotSupported[] PROGMEM = "Firmware-update isn't supported by this ESPuino!"; + const char otaNotSupportedWebsite[] PROGMEM = "

FFirmware-update isn't supported by this ESPuino!
Back to last page.

"; + #endif diff --git a/src/Web.cpp b/src/Web.cpp index 23c16f5..67b9bf7 100644 --- a/src/Web.cpp +++ b/src/Web.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include #include "freertos/ringbuf.h" @@ -179,6 +180,36 @@ void webserverStart(void) { }, handleUpload); + // OTA-upload + wServer.on( + "/update", HTTP_POST, [](AsyncWebServerRequest *request) { + #ifdef BOARD_HAS_16MB_FLASH_AND_OTA_SUPPORT + request->send(200, "text/html", restartWebsite); }, + #else + request->send(200, "text/html", otaNotSupportedWebsite); }, + #endif + [](AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool final) { + #ifndef BOARD_HAS_16MB_FLASH_AND_OTA_SUPPORT + Log_Println((char *) FPSTR(otaNotSupported), LOGLEVEL_NOTICE); + return; + #endif + + if (!index) { + Update.begin(); + Log_Println((char *) FPSTR(fwStart), LOGLEVEL_NOTICE); + } + + Update.write(data, len); + Serial.print("."); + + if (final) { + Update.end(true); + Log_Println((char *) FPSTR(fwEnd), LOGLEVEL_NOTICE); + Serial.flush(); + ESP.restart(); + } + }); + // ESP-restart wServer.on("/restart", HTTP_GET, [](AsyncWebServerRequest *request) { request->send_P(200, "text/html", restartWebsite); diff --git a/src/logmessages.h b/src/logmessages.h index 8104c7a..883e31d 100644 --- a/src/logmessages.h +++ b/src/logmessages.h @@ -196,3 +196,7 @@ extern const char errorWritingTmpfile[]; extern const char eraseRfidNvsWeb[]; extern const char eraseRfidNvs[]; extern const char erasePlaylistCachefile[]; +extern const char fwStart[]; +extern const char fwEnd[]; +extern const char otaNotSupported[]; +extern const char otaNotSupportedWebsite[]; diff --git a/src/main.cpp b/src/main.cpp index c9c444d..a41c22d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -184,7 +184,7 @@ void setup() { Serial.println(F(" | |___ ___) | | __/ | |_| | | | | | | | | (_) |")); Serial.println(F(" |_____| |____/ |_| \\__,_| |_| |_| |_| \\___/ ")); Serial.println(F(" Rfid-controlled musicplayer\n")); - Serial.println(F(" Rev 20210712-1\n")); + Serial.println(F(" Rev 20210713-1\n")); // print wake-up reason printWakeUpReason();