diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index 36ddea2..97d92e0 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -1,4 +1,3 @@ -//#include #include #include #include @@ -21,7 +20,7 @@ Configuration Config; WiFiClient espClient; -String versionDate = "2023.12.19"; +String versionDate = "2023.12.20"; int myWiFiAPIndex = 0; int myWiFiAPSize = Config.wifiAPs.size(); WiFi_AP *currentWiFi = &Config.wifiAPs[myWiFiAPIndex]; @@ -90,5 +89,4 @@ void loop() { DIGI_Utils::loop(); } } - //ElegantOTA.loop(); } \ No newline at end of file diff --git a/src/aprs_is_utils.cpp b/src/aprs_is_utils.cpp index cb8eac4..4cbb3cb 100644 --- a/src/aprs_is_utils.cpp +++ b/src/aprs_is_utils.cpp @@ -1,5 +1,5 @@ +#include #include -//#include #include "configuration.h" #include "aprs_is_utils.h" #include "station_utils.h" @@ -220,8 +220,7 @@ namespace APRS_IS_Utils { aprsisPacket.concat(espClient.readStringUntil('\r')); processAPRSISPacket(aprsisPacket); } + ElegantOTA.loop(); } - //ElegantOTA.loop(); } - } \ No newline at end of file diff --git a/src/utils.cpp b/src/utils.cpp index 2c8271f..d290163 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -46,6 +46,8 @@ extern bool WiFiConnect; String name; String email; +unsigned long ota_progress_millis = 0; + namespace Utils { void notFound(AsyncWebServerRequest *request) { @@ -316,7 +318,17 @@ namespace Utils { Serial.println("OTA update started!"); display_toggle(true); lastScreenOn = millis(); - show_display("", "***** *", "", " OTA update started!", "", "", "", 1000); + show_display("", "", "", " OTA update started!", "", "", "", 1000); + } + + void onOTAProgress(size_t current, size_t final) { + if (millis() - ota_progress_millis > 1000) { + display_toggle(true); + lastScreenOn = millis(); + ota_progress_millis = millis(); + Serial.printf("OTA Progress Current: %u bytes, Final: %u bytes\n", current, final); + show_display("", "", " OTA Progress : " + String((current*100)/final) + "%", "", "", "", "", 100); + } } void onOTAEnd(bool success) { @@ -324,17 +336,17 @@ namespace Utils { lastScreenOn = millis(); if (success) { Serial.println("OTA update finished successfully!"); - show_display("", "", " OTA update success!", "", " Rebooting ...", "", "", 2000); + show_display("", "", " OTA update success!", "", " Rebooting ...", "", "", 4000); } else { Serial.println("There was an error during OTA update!"); - show_display("", "", " OTA update fail!", "", "", "", "", 2000); + show_display("", "", " OTA update fail!", "", "", "", "", 4000); } } void startServer() { if (stationMode==1 || stationMode==2 || (stationMode==5 && WiFi.status()==WL_CONNECTED)) { server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) { - request->send(200, "text/plain", "*Hi " + Config.callsign + ", \n\nthis is your (Richonguzman/CA2RXU) LoRa iGate , version " + versionDate + "\n\nTo update your firmware or filesystem go to: http://" + getLocalIP().substring(getLocalIP().indexOf(":")+3) + "/update\n\n\n73!"); + request->send(200, "text/plain", "Hi " + Config.callsign + ", \n\nthis is your (Richonguzman/CA2RXU) LoRa APRS iGate , version " + versionDate + "\n\nTo update your firmware or filesystem go to: http://" + getLocalIP().substring(getLocalIP().indexOf(":")+3) + "/update\n\n\n73!"); }); server.on("/test", HTTP_GET, [](AsyncWebServerRequest *request) { @@ -350,11 +362,10 @@ namespace Utils { } else { ElegantOTA.begin(&server); } - // + ElegantOTA.setAutoReboot(true); ElegantOTA.onStart(onOTAStart); - //ElegantOTA.onProgress(onOTAProgress); - //ElegantOTA.onEnd(onOTAEnd); - // + ElegantOTA.onProgress(onOTAProgress); + ElegantOTA.onEnd(onOTAEnd); server.on("/process_form.php", HTTP_POST, [](AsyncWebServerRequest *request){ String message; @@ -378,8 +389,7 @@ namespace Utils { server.serveStatic("/", SPIFFS, "/"); server.begin(); - Serial.println("init : OTA Server ... done!"); - ElegantOTA.loop(); + Serial.println("init : OTA Server ... done!"); } } diff --git a/src/utils.h b/src/utils.h index 031f022..701ea1d 100644 --- a/src/utils.h +++ b/src/utils.h @@ -15,6 +15,7 @@ namespace Utils { void validateDigiFreqs(); void typeOfPacket(String packet, String packetType); void onOTAStart(); + void onOTAProgress(size_t current, size_t final); void onOTAEnd(bool success); void startServer();