Switch from PrettyOTA to ArduinoOTA since POTA was taken down due to DMCA
This commit is contained in:
parent
8310fd0a17
commit
0625a098da
|
|
@ -18,4 +18,3 @@ upload_port = 192.168.2.232
|
||||||
lib_compat_mode = strict
|
lib_compat_mode = strict
|
||||||
lib_deps =
|
lib_deps =
|
||||||
tzapu/WiFiManager@^2.0.17
|
tzapu/WiFiManager@^2.0.17
|
||||||
lostincompilation/PrettyOTA@^1.1.2
|
|
||||||
|
|
|
||||||
44
src/main.cpp
44
src/main.cpp
|
|
@ -2,9 +2,9 @@
|
||||||
#include <WiFiManager.h>
|
#include <WiFiManager.h>
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
#include <HTTPClient.h>
|
#include <HTTPClient.h>
|
||||||
#include <PrettyOTA.h>
|
#include <ArduinoOTA.h>
|
||||||
|
|
||||||
#define BOARDFIRMWARE "2.2"
|
#define BOARDFIRMWARE "2.5"
|
||||||
|
|
||||||
#define BUTTONPIN 22
|
#define BUTTONPIN 22
|
||||||
#define DEBOUNCEMS 15
|
#define DEBOUNCEMS 15
|
||||||
|
|
@ -12,14 +12,13 @@
|
||||||
#define SERVICE "LEDsActionButton"
|
#define SERVICE "LEDsActionButton"
|
||||||
#define STATUSINTERVAL 600000
|
#define STATUSINTERVAL 600000
|
||||||
|
|
||||||
|
const char hostAddress[] = "moon.basement.lan";
|
||||||
|
unsigned int hostPort = 80;
|
||||||
String actionURL = "http://moon.basement.lan/l/actionbutton.php?state=";
|
String actionURL = "http://moon.basement.lan/l/actionbutton.php?state=";
|
||||||
String statusURL = "http://moon.basement.lan/l/boardstatus.php";
|
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 sendActionMessage(bool state) {
|
void sendActionMessage(bool state) {
|
||||||
Serial.println("Action button triggered");
|
Serial.println("Action button triggered");
|
||||||
char webMsg[255] = "";
|
char webMsg[255] = "";
|
||||||
|
|
@ -43,31 +42,6 @@ unsigned long sendDeviceStatus() {
|
||||||
return millis();
|
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() {
|
void setup() {
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
pinMode(BUTTONPIN, INPUT_PULLUP);
|
pinMode(BUTTONPIN, INPUT_PULLUP);
|
||||||
|
|
@ -75,14 +49,7 @@ void setup() {
|
||||||
WiFiManager wifiManager;
|
WiFiManager wifiManager;
|
||||||
wifiManager.autoConnect("LEDsActionButton");
|
wifiManager.autoConnect("LEDsActionButton");
|
||||||
lastStatusTime = sendDeviceStatus();
|
lastStatusTime = sendDeviceStatus();
|
||||||
OTAUpdates.Begin(&server);
|
ArduinoOTA.begin();
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long lastDebounceTime = 0;
|
unsigned long lastDebounceTime = 0;
|
||||||
|
|
@ -111,4 +78,5 @@ void loop() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lastButtonState = buttonCheck;
|
lastButtonState = buttonCheck;
|
||||||
|
ArduinoOTA.handle();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user