Initial conversion to PrettyOTA

This commit is contained in:
Junior 2025-04-08 18:43:00 -04:00
parent 49a9b45ab9
commit 14759902be
2 changed files with 18 additions and 6 deletions

View File

@ -13,6 +13,9 @@ platform = espressif32
board = esp32doit-devkit-v1 board = esp32doit-devkit-v1
framework = arduino framework = arduino
monitor_speed = 115200 monitor_speed = 115200
lib_deps = tzapu/WiFiManager@^2.0.17 upload_protocol = espota
;upload_protocol = espota upload_port = 192.168.2.232
;upload_port = 192.168.2.233 lib_compat_mode = strict
lib_deps =
tzapu/WiFiManager@^2.0.17
lostincompilation/PrettyOTA@^1.1.2

View File

@ -3,8 +3,9 @@
#include <WiFi.h> #include <WiFi.h>
#include <HTTPClient.h> #include <HTTPClient.h>
#include <ArduinoOTA.h> #include <ArduinoOTA.h>
#include <PrettyOTA.h>
#define FIRMWARE "2.0" #define FIRMWARE "2.1b"
#define BUTTONPIN 23 #define BUTTONPIN 23
#define DEBOUNCEMS 15 #define DEBOUNCEMS 15
@ -17,6 +18,9 @@ String statusURL = "http://moon.basement.lan/l/boardstatus.php";
unsigned short buttonState = HIGH, lastButtonState = HIGH; unsigned short buttonState = HIGH, lastButtonState = HIGH;
unsigned long lastStatusTime = 0; unsigned long lastStatusTime = 0;
AsyncWebServer server(80);
PrettyOTA OTAUpdates;
void sendToggleMessage(bool state) { void sendToggleMessage(bool state) {
Serial.println("Action button triggered"); Serial.println("Action button triggered");
char webMsg[255] = ""; char webMsg[255] = "";
@ -47,7 +51,7 @@ void setup() {
WiFiManager wifiManager; WiFiManager wifiManager;
wifiManager.autoConnect("LEDsActionButton"); wifiManager.autoConnect("LEDsActionButton");
lastStatusTime = sendDeviceStatus(); lastStatusTime = sendDeviceStatus();
ArduinoOTA.onStart([]() { /*ArduinoOTA.onStart([]() {
String type; String type;
if ( ArduinoOTA.getCommand() == U_FLASH ) if ( ArduinoOTA.getCommand() == U_FLASH )
type = "sketch"; type = "sketch";
@ -66,7 +70,12 @@ void setup() {
else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed"); else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed");
else if (error == OTA_END_ERROR) Serial.println("End 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; unsigned long lastDebounceTime = 0;