From 14759902be755bb282564ffd4faa9f6ed9dc880a Mon Sep 17 00:00:00 2001 From: Junior Date: Tue, 8 Apr 2025 18:43:00 -0400 Subject: [PATCH] Initial conversion to PrettyOTA --- platformio.ini | 9 ++++++--- src/main.cpp | 15 ++++++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/platformio.ini b/platformio.ini index 15860ad..8e76d76 100644 --- a/platformio.ini +++ b/platformio.ini @@ -13,6 +13,9 @@ platform = espressif32 board = esp32doit-devkit-v1 framework = arduino monitor_speed = 115200 -lib_deps = tzapu/WiFiManager@^2.0.17 -;upload_protocol = espota -;upload_port = 192.168.2.233 +upload_protocol = espota +upload_port = 192.168.2.232 +lib_compat_mode = strict +lib_deps = + tzapu/WiFiManager@^2.0.17 + lostincompilation/PrettyOTA@^1.1.2 diff --git a/src/main.cpp b/src/main.cpp index bc34cb7..8866b92 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,8 +3,9 @@ #include #include #include +#include -#define FIRMWARE "2.0" +#define FIRMWARE "2.1b" #define BUTTONPIN 23 #define DEBOUNCEMS 15 @@ -17,6 +18,9 @@ String statusURL = "http://moon.basement.lan/l/boardstatus.php"; unsigned short buttonState = HIGH, lastButtonState = HIGH; unsigned long lastStatusTime = 0; +AsyncWebServer server(80); +PrettyOTA OTAUpdates; + void sendToggleMessage(bool state) { Serial.println("Action button triggered"); char webMsg[255] = ""; @@ -47,7 +51,7 @@ void setup() { WiFiManager wifiManager; wifiManager.autoConnect("LEDsActionButton"); lastStatusTime = sendDeviceStatus(); - ArduinoOTA.onStart([]() { + /*ArduinoOTA.onStart([]() { String type; if ( ArduinoOTA.getCommand() == U_FLASH ) type = "sketch"; @@ -66,7 +70,12 @@ void setup() { else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed"); else if (error == OTA_END_ERROR) Serial.println("End Failed"); }); - ArduinoOTA.begin(); + ArduinoOTA.begin();*/ + OTAUpdates.Begin(&server); + OTAUpdates.SetHardwareID(SERVICE); + OTAUpdates.OverwriteAppVersion(FIRMWARE); + PRETTY_OTA_SET_CURRENT_BUILD_TIME_AND_DATE(); + server.begin(); } unsigned long lastDebounceTime = 0;