From 0625a098dad3729457adfb17eba411c36600c8cf Mon Sep 17 00:00:00 2001 From: Junior Date: Thu, 18 Dec 2025 10:34:22 -0500 Subject: [PATCH] Switch from PrettyOTA to ArduinoOTA since POTA was taken down due to DMCA --- platformio.ini | 1 - src/main.cpp | 44 ++++++-------------------------------------- 2 files changed, 6 insertions(+), 39 deletions(-) diff --git a/platformio.ini b/platformio.ini index 8e76d76..6328ad7 100644 --- a/platformio.ini +++ b/platformio.ini @@ -18,4 +18,3 @@ 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 694d893..1dd7093 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2,9 +2,9 @@ #include #include #include -#include +#include -#define BOARDFIRMWARE "2.2" +#define BOARDFIRMWARE "2.5" #define BUTTONPIN 22 #define DEBOUNCEMS 15 @@ -12,14 +12,13 @@ #define SERVICE "LEDsActionButton" #define STATUSINTERVAL 600000 +const char hostAddress[] = "moon.basement.lan"; +unsigned int hostPort = 80; String actionURL = "http://moon.basement.lan/l/actionbutton.php?state="; 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 sendActionMessage(bool state) { Serial.println("Action button triggered"); char webMsg[255] = ""; @@ -43,31 +42,6 @@ unsigned long sendDeviceStatus() { return millis(); } -// Gets called when update starts -// updateMode can be FILESYSTEM or FIRMWARE -void OnOTAStart(NSPrettyOTA::UPDATE_MODE updateMode) { - Serial.println("OTA update started"); - if(updateMode == NSPrettyOTA::UPDATE_MODE::FIRMWARE) - Serial.println("Mode: Firmware"); - else if(updateMode == NSPrettyOTA::UPDATE_MODE::FILESYSTEM) - Serial.println("Mode: Filesystem"); -} - -// Gets called while update is running -// currentSize: Number of bytes already processed -// totalSize: Total size of new firmware in bytes -void OnOTAProgress(uint32_t currentSize, uint32_t totalSize) { - Serial.printf("OTA Progress Current: %u bytes, Total: %u bytes\n", currentSize, totalSize); -} - -// Gets called when update finishes -void OnOTAEnd(bool successful) { - if (successful) - Serial.println("OTA update finished successfully"); - else - Serial.println("OTA update failed"); -} - void setup() { Serial.begin(115200); pinMode(BUTTONPIN, INPUT_PULLUP); @@ -75,14 +49,7 @@ void setup() { WiFiManager wifiManager; wifiManager.autoConnect("LEDsActionButton"); lastStatusTime = sendDeviceStatus(); - OTAUpdates.Begin(&server); - OTAUpdates.SetHardwareID(SERVICE); - OTAUpdates.OverwriteAppVersion(BOARDFIRMWARE); - PRETTY_OTA_SET_CURRENT_BUILD_TIME_AND_DATE(); - OTAUpdates.OnStart(OnOTAStart); - OTAUpdates.OnProgress(OnOTAProgress); - OTAUpdates.OnEnd(OnOTAEnd); - server.begin(); + ArduinoOTA.begin(); } unsigned long lastDebounceTime = 0; @@ -111,4 +78,5 @@ void loop() { } } lastButtonState = buttonCheck; + ArduinoOTA.handle(); }