Interim Async Update
This commit is contained in:
parent
a371239172
commit
76f1c689c1
@ -6,7 +6,7 @@
|
|||||||
//see https://github.com/Aircoookie/WLED/issues/2 for flicker free ESP32 support
|
//see https://github.com/Aircoookie/WLED/issues/2 for flicker free ESP32 support
|
||||||
|
|
||||||
//PIN CONFIGURATION
|
//PIN CONFIGURATION
|
||||||
#define LEDPIN 2 //strip pin. Any for ESP32, gpio2 is recommended for ESP8266
|
#define LEDPIN 3 //strip pin. Any for ESP32, gpio2 is recommended for ESP8266
|
||||||
#define BTNPIN 0 //button pin. Needs to have pullup (gpio0 recommended)
|
#define BTNPIN 0 //button pin. Needs to have pullup (gpio0 recommended)
|
||||||
#define IR_PIN 4 //infrared pin.
|
#define IR_PIN 4 //infrared pin.
|
||||||
#define AUXPIN 15 //unused auxiliary output pin
|
#define AUXPIN 15 //unused auxiliary output pin
|
||||||
|
@ -33,15 +33,16 @@
|
|||||||
#ifdef ARDUINO_ARCH_ESP32
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
#include <ESPmDNS.h>
|
#include <ESPmDNS.h>
|
||||||
#include "src/dependencies/webserver/WebServer.h"
|
#include "src/dependencies/webserver/Webserver->h"
|
||||||
#include <HTTPClient.h>
|
#include <HTTPClient.h>
|
||||||
/*#ifndef WLED_DISABLE_INFRARED
|
/*#ifndef WLED_DISABLE_INFRARED
|
||||||
#include <IRremote.h>
|
#include <IRremote.h>
|
||||||
#endif*/ //there are issues with ESP32 infrared, so it is disabled for now
|
#endif*/ //there are issues with ESP32 infrared, so it is disabled for now
|
||||||
#else
|
#else
|
||||||
|
#define TEMPLATE_PLACEHOLDER '~'
|
||||||
#include <ESP8266WiFi.h>
|
#include <ESP8266WiFi.h>
|
||||||
#include <ESP8266mDNS.h>
|
#include <ESP8266mDNS.h>
|
||||||
#include <ESP8266WebServer.h>
|
#include <ESP8266Webserver.h>
|
||||||
#include <ESP8266HTTPClient.h>
|
#include <ESP8266HTTPClient.h>
|
||||||
#ifndef WLED_DISABLE_INFRARED
|
#ifndef WLED_DISABLE_INFRARED
|
||||||
#include <IRremoteESP8266.h>
|
#include <IRremoteESP8266.h>
|
||||||
@ -52,10 +53,10 @@
|
|||||||
|
|
||||||
#include <EEPROM.h>
|
#include <EEPROM.h>
|
||||||
#include <WiFiUdp.h>
|
#include <WiFiUdp.h>
|
||||||
#include <DNSServer.h>
|
#include <DNSserver.h>
|
||||||
#ifndef WLED_DISABLE_OTA
|
#ifndef WLED_DISABLE_OTA
|
||||||
#include <ArduinoOTA.h>
|
#include <ArduinoOTA.h>
|
||||||
#include "src/dependencies/webserver/ESP8266HTTPUpdateServer.h"
|
#include "src/dependencies/webserver/ESP8266HTTPUpdateserver->h"
|
||||||
#endif
|
#endif
|
||||||
#include "src/dependencies/time/Time.h"
|
#include "src/dependencies/time/Time.h"
|
||||||
#include "src/dependencies/time/TimeLib.h"
|
#include "src/dependencies/time/TimeLib.h"
|
||||||
@ -175,7 +176,7 @@ bool notifyTwice = false; //notifications use UDP: enable if
|
|||||||
bool alexaEnabled = true; //enable device discovery by Amazon Echo
|
bool alexaEnabled = true; //enable device discovery by Amazon Echo
|
||||||
char alexaInvocationName[33] = "Light"; //speech control name of device. Choose something voice-to-text can understand
|
char alexaInvocationName[33] = "Light"; //speech control name of device. Choose something voice-to-text can understand
|
||||||
|
|
||||||
char blynkApiKey[36] = ""; //Auth token for Blynk server. If empty, no connection will be made
|
char blynkApiKey[36] = ""; //Auth token for Blynk server-> If empty, no connection will be made
|
||||||
|
|
||||||
uint16_t realtimeTimeoutMs = 2500; //ms timeout of realtime mode before returning to normal mode
|
uint16_t realtimeTimeoutMs = 2500; //ms timeout of realtime mode before returning to normal mode
|
||||||
int arlsOffset = 0; //realtime LED offset
|
int arlsOffset = 0; //realtime LED offset
|
||||||
@ -499,7 +500,7 @@ void setup() {
|
|||||||
|
|
||||||
//main program loop
|
//main program loop
|
||||||
void loop() {
|
void loop() {
|
||||||
server.handleClient();
|
server->handleClient();
|
||||||
handleSerial();
|
handleSerial();
|
||||||
handleNotifications();
|
handleNotifications();
|
||||||
handleTransitions();
|
handleTransitions();
|
||||||
@ -521,7 +522,7 @@ void loop() {
|
|||||||
|
|
||||||
if (!realtimeActive) //block stuff if WARLS/Adalight is enabled
|
if (!realtimeActive) //block stuff if WARLS/Adalight is enabled
|
||||||
{
|
{
|
||||||
if (dnsActive) dnsServer.processNextRequest();
|
if (dnsActive) dnsserver.processNextRequest();
|
||||||
#ifndef WLED_DISABLE_OTA
|
#ifndef WLED_DISABLE_OTA
|
||||||
if (aOtaEnabled) ArduinoOTA.handle();
|
if (aOtaEnabled) ArduinoOTA.handle();
|
||||||
#endif
|
#endif
|
||||||
|
@ -79,7 +79,7 @@ void XML_response(bool isHTTP, bool includeTheme)
|
|||||||
oappend("</cf></th>");
|
oappend("</cf></th>");
|
||||||
}
|
}
|
||||||
oappend("</vs>");
|
oappend("</vs>");
|
||||||
if (isHTTP) server.send(200, "text/xml", obuf);
|
if (isHTTP) server->send(200, "text/xml", obuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
//append a numeric setting to string buffer
|
//append a numeric setting to string buffer
|
||||||
|
@ -23,16 +23,16 @@ void handleSettingsSet(byte subPage)
|
|||||||
//WIFI SETTINGS
|
//WIFI SETTINGS
|
||||||
if (subPage == 1)
|
if (subPage == 1)
|
||||||
{
|
{
|
||||||
strcpy(clientSSID,server.arg("CS").c_str());
|
strcpy(clientSSID,server->arg("CS").c_str());
|
||||||
if (server.arg("CP").charAt(0) != '*') strcpy(clientPass, server.arg("CP").c_str());
|
if (server->arg("CP").charAt(0) != '*') strcpy(clientPass, server->arg("CP").c_str());
|
||||||
|
|
||||||
strcpy(cmDNS, server.arg("CM").c_str());
|
strcpy(cmDNS, server->arg("CM").c_str());
|
||||||
|
|
||||||
int t = server.arg("AT").toInt(); if (t > 9 && t <= 255) apWaitTimeSecs = t;
|
int t = server->arg("AT").toInt(); if (t > 9 && t <= 255) apWaitTimeSecs = t;
|
||||||
strcpy(apSSID, server.arg("AS").c_str());
|
strcpy(apSSID, server->arg("AS").c_str());
|
||||||
apHide = server.hasArg("AH");
|
apHide = server->hasArg("AH");
|
||||||
if (server.arg("AP").charAt(0) != '*') strcpy(apPass, server.arg("AP").c_str());
|
if (server->arg("AP").charAt(0) != '*') strcpy(apPass, server->arg("AP").c_str());
|
||||||
t = server.arg("AC").toInt(); if (t > 0 && t < 14) apChannel = t;
|
t = server->arg("AC").toInt(); if (t > 0 && t < 14) apChannel = t;
|
||||||
|
|
||||||
char k[3]; k[2] = 0;
|
char k[3]; k[2] = 0;
|
||||||
for (int i = 0; i<4; i++)
|
for (int i = 0; i<4; i++)
|
||||||
@ -40,32 +40,32 @@ void handleSettingsSet(byte subPage)
|
|||||||
k[1] = i+48;//ascii 0,1,2,3
|
k[1] = i+48;//ascii 0,1,2,3
|
||||||
|
|
||||||
k[0] = 'I'; //static IP
|
k[0] = 'I'; //static IP
|
||||||
staticIP[i] = server.arg(k).toInt();
|
staticIP[i] = server->arg(k).toInt();
|
||||||
|
|
||||||
k[0] = 'G'; //gateway
|
k[0] = 'G'; //gateway
|
||||||
staticGateway[i] = server.arg(k).toInt();
|
staticGateway[i] = server->arg(k).toInt();
|
||||||
|
|
||||||
k[0] = 'S'; //subnet
|
k[0] = 'S'; //subnet
|
||||||
staticSubnet[i] = server.arg(k).toInt();
|
staticSubnet[i] = server->arg(k).toInt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//LED SETTINGS
|
//LED SETTINGS
|
||||||
if (subPage == 2)
|
if (subPage == 2)
|
||||||
{
|
{
|
||||||
int t = server.arg("LC").toInt();
|
int t = server->arg("LC").toInt();
|
||||||
if (t > 0 && t <= 1200) ledCount = t;
|
if (t > 0 && t <= 1200) ledCount = t;
|
||||||
//RMT eats up too much RAM
|
//RMT eats up too much RAM
|
||||||
#ifdef ARDUINO_ARCH_ESP32
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
if (ledCount > 600) ledCount = 600;
|
if (ledCount > 600) ledCount = 600;
|
||||||
#endif
|
#endif
|
||||||
strip.ablMilliampsMax = server.arg("MA").toInt();
|
strip.ablMilliampsMax = server->arg("MA").toInt();
|
||||||
useRGBW = server.hasArg("EW");
|
useRGBW = server->hasArg("EW");
|
||||||
strip.colorOrder = server.arg("CO").toInt();
|
strip.colorOrder = server->arg("CO").toInt();
|
||||||
autoRGBtoRGBW = server.hasArg("AW");
|
autoRGBtoRGBW = server->hasArg("AW");
|
||||||
|
|
||||||
//ignore settings and save current brightness, colors and fx as default
|
//ignore settings and save current brightness, colors and fx as default
|
||||||
if (server.hasArg("IS"))
|
if (server->hasArg("IS"))
|
||||||
{
|
{
|
||||||
for (byte i=0; i<4; i++)
|
for (byte i=0; i<4; i++)
|
||||||
{
|
{
|
||||||
@ -78,122 +78,122 @@ void handleSettingsSet(byte subPage)
|
|||||||
effectIntensityDefault = effectIntensity;
|
effectIntensityDefault = effectIntensity;
|
||||||
effectPaletteDefault = effectPalette;
|
effectPaletteDefault = effectPalette;
|
||||||
} else {
|
} else {
|
||||||
colS[0] = server.arg("CR").toInt();
|
colS[0] = server->arg("CR").toInt();
|
||||||
colS[1] = server.arg("CG").toInt();
|
colS[1] = server->arg("CG").toInt();
|
||||||
colS[2] = server.arg("CB").toInt();
|
colS[2] = server->arg("CB").toInt();
|
||||||
colSecS[0] = server.arg("SR").toInt();
|
colSecS[0] = server->arg("SR").toInt();
|
||||||
colSecS[1] = server.arg("SG").toInt();
|
colSecS[1] = server->arg("SG").toInt();
|
||||||
colSecS[2] = server.arg("SB").toInt();
|
colSecS[2] = server->arg("SB").toInt();
|
||||||
colS[3] = server.arg("CW").toInt();
|
colS[3] = server->arg("CW").toInt();
|
||||||
colSecS[3] = server.arg("SW").toInt();
|
colSecS[3] = server->arg("SW").toInt();
|
||||||
briS = server.arg("CA").toInt();
|
briS = server->arg("CA").toInt();
|
||||||
effectDefault = server.arg("FX").toInt();
|
effectDefault = server->arg("FX").toInt();
|
||||||
effectSpeedDefault = server.arg("SX").toInt();
|
effectSpeedDefault = server->arg("SX").toInt();
|
||||||
effectIntensityDefault = server.arg("IX").toInt();
|
effectIntensityDefault = server->arg("IX").toInt();
|
||||||
effectPaletteDefault = server.arg("FP").toInt();
|
effectPaletteDefault = server->arg("FP").toInt();
|
||||||
}
|
}
|
||||||
saveCurrPresetCycConf = server.hasArg("PC");
|
saveCurrPresetCycConf = server->hasArg("PC");
|
||||||
turnOnAtBoot = server.hasArg("BO");
|
turnOnAtBoot = server->hasArg("BO");
|
||||||
t = server.arg("BP").toInt();
|
t = server->arg("BP").toInt();
|
||||||
if (t <= 25) bootPreset = t;
|
if (t <= 25) bootPreset = t;
|
||||||
useGammaCorrectionBri = server.hasArg("GB");
|
useGammaCorrectionBri = server->hasArg("GB");
|
||||||
useGammaCorrectionRGB = server.hasArg("GC");
|
useGammaCorrectionRGB = server->hasArg("GC");
|
||||||
|
|
||||||
fadeTransition = server.hasArg("TF");
|
fadeTransition = server->hasArg("TF");
|
||||||
t = server.arg("TD").toInt();
|
t = server->arg("TD").toInt();
|
||||||
if (t > 0) transitionDelay = t;
|
if (t > 0) transitionDelay = t;
|
||||||
transitionDelayDefault = t;
|
transitionDelayDefault = t;
|
||||||
strip.paletteFade = server.hasArg("PF");
|
strip.paletteFade = server->hasArg("PF");
|
||||||
enableSecTransition = server.hasArg("T2");
|
enableSecTransition = server->hasArg("T2");
|
||||||
|
|
||||||
nightlightTargetBri = server.arg("TB").toInt();
|
nightlightTargetBri = server->arg("TB").toInt();
|
||||||
t = server.arg("TL").toInt();
|
t = server->arg("TL").toInt();
|
||||||
if (t > 0) nightlightDelayMinsDefault = t;
|
if (t > 0) nightlightDelayMinsDefault = t;
|
||||||
nightlightFade = server.hasArg("TW");
|
nightlightFade = server->hasArg("TW");
|
||||||
|
|
||||||
t = server.arg("PB").toInt();
|
t = server->arg("PB").toInt();
|
||||||
if (t >= 0 && t < 4) strip.paletteBlend = t;
|
if (t >= 0 && t < 4) strip.paletteBlend = t;
|
||||||
reverseMode = server.hasArg("RV");
|
reverseMode = server->hasArg("RV");
|
||||||
strip.setReverseMode(reverseMode);
|
strip.setReverseMode(reverseMode);
|
||||||
skipFirstLed = server.hasArg("SL");
|
skipFirstLed = server->hasArg("SL");
|
||||||
t = server.arg("BF").toInt();
|
t = server->arg("BF").toInt();
|
||||||
if (t > 0) briMultiplier = t;
|
if (t > 0) briMultiplier = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
//UI
|
//UI
|
||||||
if (subPage == 3)
|
if (subPage == 3)
|
||||||
{
|
{
|
||||||
int t = server.arg("UI").toInt();
|
int t = server->arg("UI").toInt();
|
||||||
if (t >= 0 && t < 3) uiConfiguration = t;
|
if (t >= 0 && t < 3) uiConfiguration = t;
|
||||||
strcpy(serverDescription, server.arg("DS").c_str());
|
strcpy(serverDescription, server->arg("DS").c_str());
|
||||||
useHSBDefault = server.hasArg("MD");
|
useHSBDefault = server->hasArg("MD");
|
||||||
useHSB = useHSBDefault;
|
useHSB = useHSBDefault;
|
||||||
currentTheme = server.arg("TH").toInt();
|
currentTheme = server->arg("TH").toInt();
|
||||||
char k[3]; k[0]='C'; k[2]=0;
|
char k[3]; k[0]='C'; k[2]=0;
|
||||||
for(int i=0;i<6;i++)
|
for(int i=0;i<6;i++)
|
||||||
{
|
{
|
||||||
k[1] = i+48;
|
k[1] = i+48;
|
||||||
strcpy(cssCol[i],server.arg(k).c_str());
|
strcpy(cssCol[i],server->arg(k).c_str());
|
||||||
}
|
}
|
||||||
strcpy(cssFont,server.arg("CF").c_str());
|
strcpy(cssFont,server->arg("CF").c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
//SYNC
|
//SYNC
|
||||||
if (subPage == 4)
|
if (subPage == 4)
|
||||||
{
|
{
|
||||||
buttonEnabled = server.hasArg("BT");
|
buttonEnabled = server->hasArg("BT");
|
||||||
irEnabled = server.hasArg("IR");
|
irEnabled = server->hasArg("IR");
|
||||||
int t = server.arg("UP").toInt();
|
int t = server->arg("UP").toInt();
|
||||||
if (t > 0) udpPort = t;
|
if (t > 0) udpPort = t;
|
||||||
receiveNotificationBrightness = server.hasArg("RB");
|
receiveNotificationBrightness = server->hasArg("RB");
|
||||||
receiveNotificationColor = server.hasArg("RC");
|
receiveNotificationColor = server->hasArg("RC");
|
||||||
receiveNotificationEffects = server.hasArg("RX");
|
receiveNotificationEffects = server->hasArg("RX");
|
||||||
receiveNotifications = (receiveNotificationBrightness || receiveNotificationColor || receiveNotificationEffects);
|
receiveNotifications = (receiveNotificationBrightness || receiveNotificationColor || receiveNotificationEffects);
|
||||||
notifyDirectDefault = server.hasArg("SD");
|
notifyDirectDefault = server->hasArg("SD");
|
||||||
notifyDirect = notifyDirectDefault;
|
notifyDirect = notifyDirectDefault;
|
||||||
notifyButton = server.hasArg("SB");
|
notifyButton = server->hasArg("SB");
|
||||||
notifyTwice = server.hasArg("S2");
|
notifyTwice = server->hasArg("S2");
|
||||||
|
|
||||||
receiveDirect = server.hasArg("RD");
|
receiveDirect = server->hasArg("RD");
|
||||||
e131Multicast = server.hasArg("EM");
|
e131Multicast = server->hasArg("EM");
|
||||||
t = server.arg("EU").toInt();
|
t = server->arg("EU").toInt();
|
||||||
if (t > 0 && t <= 63999) e131Universe = t;
|
if (t > 0 && t <= 63999) e131Universe = t;
|
||||||
t = server.arg("ET").toInt();
|
t = server->arg("ET").toInt();
|
||||||
if (t > 99 && t <= 65000) realtimeTimeoutMs = t;
|
if (t > 99 && t <= 65000) realtimeTimeoutMs = t;
|
||||||
arlsForceMaxBri = server.hasArg("FB");
|
arlsForceMaxBri = server->hasArg("FB");
|
||||||
arlsDisableGammaCorrection = server.hasArg("RG");
|
arlsDisableGammaCorrection = server->hasArg("RG");
|
||||||
t = server.arg("WO").toInt();
|
t = server->arg("WO").toInt();
|
||||||
if (t >= -255 && t <= 255) arlsOffset = t;
|
if (t >= -255 && t <= 255) arlsOffset = t;
|
||||||
enableRealtimeUI = server.hasArg("RU");
|
enableRealtimeUI = server->hasArg("RU");
|
||||||
|
|
||||||
alexaEnabled = server.hasArg("AL");
|
alexaEnabled = server->hasArg("AL");
|
||||||
strcpy(alexaInvocationName, server.arg("AI").c_str());
|
strcpy(alexaInvocationName, server->arg("AI").c_str());
|
||||||
notifyAlexa = server.hasArg("SA");
|
notifyAlexa = server->hasArg("SA");
|
||||||
|
|
||||||
if (server.hasArg("BK") && !server.arg("BK").equals("Hidden")) {
|
if (server->hasArg("BK") && !server->arg("BK").equals("Hidden")) {
|
||||||
strcpy(blynkApiKey,server.arg("BK").c_str()); initBlynk(blynkApiKey);
|
strcpy(blynkApiKey,server->arg("BK").c_str()); initBlynk(blynkApiKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(mqttServer, server.arg("MS").c_str());
|
strcpy(mqttServer, server->arg("MS").c_str());
|
||||||
strcpy(mqttDeviceTopic, server.arg("MD").c_str());
|
strcpy(mqttDeviceTopic, server->arg("MD").c_str());
|
||||||
strcpy(mqttGroupTopic, server.arg("MG").c_str());
|
strcpy(mqttGroupTopic, server->arg("MG").c_str());
|
||||||
|
|
||||||
notifyHue = server.hasArg("SH");
|
notifyHue = server->hasArg("SH");
|
||||||
for (int i=0;i<4;i++){
|
for (int i=0;i<4;i++){
|
||||||
String a = "H"+String(i);
|
String a = "H"+String(i);
|
||||||
hueIP[i] = server.arg(a).toInt();
|
hueIP[i] = server->arg(a).toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
t = server.arg("HL").toInt();
|
t = server->arg("HL").toInt();
|
||||||
if (t > 0) huePollLightId = t;
|
if (t > 0) huePollLightId = t;
|
||||||
|
|
||||||
t = server.arg("HI").toInt();
|
t = server->arg("HI").toInt();
|
||||||
if (t > 50) huePollIntervalMs = t;
|
if (t > 50) huePollIntervalMs = t;
|
||||||
|
|
||||||
hueApplyOnOff = server.hasArg("HO");
|
hueApplyOnOff = server->hasArg("HO");
|
||||||
hueApplyBri = server.hasArg("HB");
|
hueApplyBri = server->hasArg("HB");
|
||||||
hueApplyColor = server.hasArg("HC");
|
hueApplyColor = server->hasArg("HC");
|
||||||
if (server.hasArg("HP"))
|
if (server->hasArg("HP"))
|
||||||
{
|
{
|
||||||
if (!huePollingEnabled) hueAttempt = true;
|
if (!huePollingEnabled) hueAttempt = true;
|
||||||
if (!setupHue()) hueAttempt = true;
|
if (!setupHue()) hueAttempt = true;
|
||||||
@ -207,54 +207,54 @@ void handleSettingsSet(byte subPage)
|
|||||||
//TIME
|
//TIME
|
||||||
if (subPage == 5)
|
if (subPage == 5)
|
||||||
{
|
{
|
||||||
ntpEnabled = server.hasArg("NT");
|
ntpEnabled = server->hasArg("NT");
|
||||||
useAMPM = !server.hasArg("CF");
|
useAMPM = !server->hasArg("CF");
|
||||||
currentTimezone = server.arg("TZ").toInt();
|
currentTimezone = server->arg("TZ").toInt();
|
||||||
utcOffsetSecs = server.arg("UO").toInt();
|
utcOffsetSecs = server->arg("UO").toInt();
|
||||||
|
|
||||||
//start ntp if not already connected
|
//start ntp if not already connected
|
||||||
if (ntpEnabled && WiFi.status() == WL_CONNECTED && !ntpConnected) ntpConnected = ntpUdp.begin(ntpLocalPort);
|
if (ntpEnabled && WiFi.status() == WL_CONNECTED && !ntpConnected) ntpConnected = ntpUdp.begin(ntpLocalPort);
|
||||||
|
|
||||||
if (server.hasArg("OL")){
|
if (server->hasArg("OL")){
|
||||||
overlayDefault = server.arg("OL").toInt();
|
overlayDefault = server->arg("OL").toInt();
|
||||||
if (overlayCurrent != overlayDefault) strip.unlockAll();
|
if (overlayCurrent != overlayDefault) strip.unlockAll();
|
||||||
overlayCurrent = overlayDefault;
|
overlayCurrent = overlayDefault;
|
||||||
}
|
}
|
||||||
|
|
||||||
overlayMin = server.arg("O1").toInt();
|
overlayMin = server->arg("O1").toInt();
|
||||||
overlayMax = server.arg("O2").toInt();
|
overlayMax = server->arg("O2").toInt();
|
||||||
analogClock12pixel = server.arg("OM").toInt();
|
analogClock12pixel = server->arg("OM").toInt();
|
||||||
analogClock5MinuteMarks = server.hasArg("O5");
|
analogClock5MinuteMarks = server->hasArg("O5");
|
||||||
analogClockSecondsTrail = server.hasArg("OS");
|
analogClockSecondsTrail = server->hasArg("OS");
|
||||||
|
|
||||||
strcpy(cronixieDisplay,server.arg("CX").c_str());
|
strcpy(cronixieDisplay,server->arg("CX").c_str());
|
||||||
bool cbOld = cronixieBacklight;
|
bool cbOld = cronixieBacklight;
|
||||||
cronixieBacklight = server.hasArg("CB");
|
cronixieBacklight = server->hasArg("CB");
|
||||||
if (cbOld != cronixieBacklight && overlayCurrent == 3)
|
if (cbOld != cronixieBacklight && overlayCurrent == 3)
|
||||||
{
|
{
|
||||||
strip.setCronixieBacklight(cronixieBacklight); overlayRefreshedTime = 0;
|
strip.setCronixieBacklight(cronixieBacklight); overlayRefreshedTime = 0;
|
||||||
}
|
}
|
||||||
countdownMode = server.hasArg("CE");
|
countdownMode = server->hasArg("CE");
|
||||||
countdownYear = server.arg("CY").toInt();
|
countdownYear = server->arg("CY").toInt();
|
||||||
countdownMonth = server.arg("CI").toInt();
|
countdownMonth = server->arg("CI").toInt();
|
||||||
countdownDay = server.arg("CD").toInt();
|
countdownDay = server->arg("CD").toInt();
|
||||||
countdownHour = server.arg("CH").toInt();
|
countdownHour = server->arg("CH").toInt();
|
||||||
countdownMin = server.arg("CM").toInt();
|
countdownMin = server->arg("CM").toInt();
|
||||||
countdownSec = server.arg("CS").toInt();
|
countdownSec = server->arg("CS").toInt();
|
||||||
|
|
||||||
for (int i=1;i<17;i++)
|
for (int i=1;i<17;i++)
|
||||||
{
|
{
|
||||||
String a = "M"+String(i);
|
String a = "M"+String(i);
|
||||||
if (server.hasArg(a)) saveMacro(i,server.arg(a),false);
|
if (server->hasArg(a)) saveMacro(i,server->arg(a),false);
|
||||||
}
|
}
|
||||||
|
|
||||||
macroBoot = server.arg("MB").toInt();
|
macroBoot = server->arg("MB").toInt();
|
||||||
macroAlexaOn = server.arg("A0").toInt();
|
macroAlexaOn = server->arg("A0").toInt();
|
||||||
macroAlexaOff = server.arg("A1").toInt();
|
macroAlexaOff = server->arg("A1").toInt();
|
||||||
macroButton = server.arg("MP").toInt();
|
macroButton = server->arg("MP").toInt();
|
||||||
macroLongPress = server.arg("ML").toInt();
|
macroLongPress = server->arg("ML").toInt();
|
||||||
macroCountdown = server.arg("MC").toInt();
|
macroCountdown = server->arg("MC").toInt();
|
||||||
macroNl = server.arg("MN").toInt();
|
macroNl = server->arg("MN").toInt();
|
||||||
|
|
||||||
char k[3]; k[2] = 0;
|
char k[3]; k[2] = 0;
|
||||||
for (int i = 0; i<8; i++)
|
for (int i = 0; i<8; i++)
|
||||||
@ -262,23 +262,23 @@ void handleSettingsSet(byte subPage)
|
|||||||
k[1] = i+48;//ascii 0,1,2,3
|
k[1] = i+48;//ascii 0,1,2,3
|
||||||
|
|
||||||
k[0] = 'H'; //timer hours
|
k[0] = 'H'; //timer hours
|
||||||
timerHours[i] = server.arg(k).toInt();
|
timerHours[i] = server->arg(k).toInt();
|
||||||
|
|
||||||
k[0] = 'N'; //minutes
|
k[0] = 'N'; //minutes
|
||||||
timerMinutes[i] = server.arg(k).toInt();
|
timerMinutes[i] = server->arg(k).toInt();
|
||||||
|
|
||||||
k[0] = 'T'; //macros
|
k[0] = 'T'; //macros
|
||||||
timerMacro[i] = server.arg(k).toInt();
|
timerMacro[i] = server->arg(k).toInt();
|
||||||
|
|
||||||
k[0] = 'W'; //weekdays
|
k[0] = 'W'; //weekdays
|
||||||
timerWeekday[i] = server.arg(k).toInt();
|
timerWeekday[i] = server->arg(k).toInt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//SECURITY
|
//SECURITY
|
||||||
if (subPage == 6)
|
if (subPage == 6)
|
||||||
{
|
{
|
||||||
if (server.hasArg("RS")) //complete factory reset
|
if (server->hasArg("RS")) //complete factory reset
|
||||||
{
|
{
|
||||||
clearEEPROM();
|
clearEEPROM();
|
||||||
serveMessage(200, "All Settings erased.", "Connect to WLED-AP to setup again",255);
|
serveMessage(200, "All Settings erased.", "Connect to WLED-AP to setup again",255);
|
||||||
@ -286,24 +286,24 @@ void handleSettingsSet(byte subPage)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool pwdCorrect = !otaLock; //always allow access if ota not locked
|
bool pwdCorrect = !otaLock; //always allow access if ota not locked
|
||||||
if (server.hasArg("OP"))
|
if (server->hasArg("OP"))
|
||||||
{
|
{
|
||||||
if (otaLock && strcmp(otaPass,server.arg("OP").c_str()) == 0)
|
if (otaLock && strcmp(otaPass,server->arg("OP").c_str()) == 0)
|
||||||
{
|
{
|
||||||
pwdCorrect = true;
|
pwdCorrect = true;
|
||||||
}
|
}
|
||||||
if (!otaLock && server.arg("OP").length() > 0)
|
if (!otaLock && server->arg("OP").length() > 0)
|
||||||
{
|
{
|
||||||
strcpy(otaPass,server.arg("OP").c_str());
|
strcpy(otaPass,server->arg("OP").c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pwdCorrect) //allow changes if correct pwd or no ota active
|
if (pwdCorrect) //allow changes if correct pwd or no ota active
|
||||||
{
|
{
|
||||||
otaLock = server.hasArg("NO");
|
otaLock = server->hasArg("NO");
|
||||||
wifiLock = server.hasArg("OW");
|
wifiLock = server->hasArg("OW");
|
||||||
recoveryAPDisabled = server.hasArg("NA");
|
recoveryAPDisabled = server->hasArg("NA");
|
||||||
aOtaEnabled = server.hasArg("AO");
|
aOtaEnabled = server->hasArg("AO");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
saveSettingsToEEPROM();
|
saveSettingsToEEPROM();
|
||||||
|
@ -52,7 +52,7 @@ String formatBytes(size_t bytes){
|
|||||||
}
|
}
|
||||||
|
|
||||||
String getContentType(String filename){
|
String getContentType(String filename){
|
||||||
if(server.hasArg("download")) return "application/octet-stream";
|
if(server->hasArg("download")) return "application/octet-stream";
|
||||||
else if(filename.endsWith(".htm")) return "text/html";
|
else if(filename.endsWith(".htm")) return "text/html";
|
||||||
else if(filename.endsWith(".html")) return "text/html";
|
else if(filename.endsWith(".html")) return "text/html";
|
||||||
else if(filename.endsWith(".css")) return "text/css";
|
else if(filename.endsWith(".css")) return "text/css";
|
||||||
@ -77,7 +77,7 @@ bool handleFileRead(String path){
|
|||||||
if(SPIFFS.exists(pathWithGz))
|
if(SPIFFS.exists(pathWithGz))
|
||||||
path += ".gz";
|
path += ".gz";
|
||||||
File file = SPIFFS.open(path, "r");
|
File file = SPIFFS.open(path, "r");
|
||||||
size_t sent = server.streamFile(file, contentType);
|
size_t sent = server->streamFile(file, contentType);
|
||||||
file.close();
|
file.close();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -85,8 +85,8 @@ bool handleFileRead(String path){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void handleFileUpload(){
|
void handleFileUpload(){
|
||||||
if(server.uri() != "/edit") return;
|
if(server->uri() != "/edit") return;
|
||||||
HTTPUpload& upload = server.upload();
|
HTTPUpload& upload = server->upload();
|
||||||
if(upload.status == UPLOAD_FILE_START){
|
if(upload.status == UPLOAD_FILE_START){
|
||||||
String filename = upload.filename;
|
String filename = upload.filename;
|
||||||
if(!filename.startsWith("/")) filename = "/"+filename;
|
if(!filename.startsWith("/")) filename = "/"+filename;
|
||||||
@ -105,22 +105,22 @@ void handleFileUpload(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void handleFileDelete(){
|
void handleFileDelete(){
|
||||||
if(server.args() == 0) return server.send(500, "text/plain", "BAD ARGS");
|
if(server->args() == 0) return server->send(500, "text/plain", "BAD ARGS");
|
||||||
String path = server.arg(0);
|
String path = server->arg(0);
|
||||||
DEBUG_PRINTLN("handleFileDelete: " + path);
|
DEBUG_PRINTLN("handleFileDelete: " + path);
|
||||||
if(path == "/")
|
if(path == "/")
|
||||||
return server.send(500, "text/plain", "BAD PATH");
|
return server->send(500, "text/plain", "BAD PATH");
|
||||||
if(!SPIFFS.exists(path))
|
if(!SPIFFS.exists(path))
|
||||||
return server.send(404, "text/plain", "FileNotFound");
|
return server->send(404, "text/plain", "FileNotFound");
|
||||||
SPIFFS.remove(path);
|
SPIFFS.remove(path);
|
||||||
server.send(200, "text/plain", "");
|
server->send(200, "text/plain", "");
|
||||||
path = String();
|
path = String();
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleFileList() {
|
void handleFileList() {
|
||||||
if(!server.hasArg("dir")) {server.send(500, "text/plain", "BAD ARGS"); return;}
|
if(!server->hasArg("dir")) {server->send(500, "text/plain", "BAD ARGS"); return;}
|
||||||
|
|
||||||
String path = server.arg("dir");
|
String path = server->arg("dir");
|
||||||
DEBUG_PRINTLN("handleFileList: " + path);
|
DEBUG_PRINTLN("handleFileList: " + path);
|
||||||
Dir dir = SPIFFS.openDir(path);
|
Dir dir = SPIFFS.openDir(path);
|
||||||
path = String();
|
path = String();
|
||||||
@ -139,24 +139,24 @@ void handleFileList() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
output += "]";
|
output += "]";
|
||||||
server.send(200, "text/json", output);
|
server->send(200, "text/json", output);
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleFileCreate(){
|
void handleFileCreate(){
|
||||||
if(server.args() == 0)
|
if(server->args() == 0)
|
||||||
return server.send(500, "text/plain", "BAD ARGS");
|
return server->send(500, "text/plain", "BAD ARGS");
|
||||||
String path = server.arg(0);
|
String path = server->arg(0);
|
||||||
DEBUG_PRINTLN("handleFileCreate: " + path);
|
DEBUG_PRINTLN("handleFileCreate: " + path);
|
||||||
if(path == "/")
|
if(path == "/")
|
||||||
return server.send(500, "text/plain", "BAD PATH");
|
return server->send(500, "text/plain", "BAD PATH");
|
||||||
if(SPIFFS.exists(path))
|
if(SPIFFS.exists(path))
|
||||||
return server.send(500, "text/plain", "FILE EXISTS");
|
return server->send(500, "text/plain", "FILE EXISTS");
|
||||||
File file = SPIFFS.open(path, "w");
|
File file = SPIFFS.open(path, "w");
|
||||||
if(file)
|
if(file)
|
||||||
file.close();
|
file.close();
|
||||||
else
|
else
|
||||||
return server.send(500, "text/plain", "CREATE FAILED");
|
return server->send(500, "text/plain", "CREATE FAILED");
|
||||||
server.send(200, "text/plain", "");
|
server->send(200, "text/plain", "");
|
||||||
path = String();
|
path = String();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,8 +52,8 @@ void wledInit()
|
|||||||
//start captive portal if AP active
|
//start captive portal if AP active
|
||||||
if (onlyAP || strlen(apSSID) > 0)
|
if (onlyAP || strlen(apSSID) > 0)
|
||||||
{
|
{
|
||||||
dnsServer.setErrorReplyCode(DNSReplyCode::ServerFailure);
|
dnsserver.setErrorReplyCode(DNSReplyCode::ServerFailure);
|
||||||
dnsServer.start(53, "wled.me", WiFi.softAPIP());
|
dnsserver.start(53, "wled.me", WiFi.softAPIP());
|
||||||
dnsActive = true;
|
dnsActive = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ void wledInit()
|
|||||||
//init Alexa hue emulation
|
//init Alexa hue emulation
|
||||||
if (alexaEnabled && !onlyAP) alexaInit();
|
if (alexaEnabled && !onlyAP) alexaInit();
|
||||||
|
|
||||||
server.begin();
|
server->begin();
|
||||||
DEBUG_PRINTLN("HTTP server started");
|
DEBUG_PRINTLN("HTTP server started");
|
||||||
|
|
||||||
//init ArduinoOTA
|
//init ArduinoOTA
|
||||||
@ -272,7 +272,7 @@ void getBuildInfo()
|
|||||||
oappend("\r\nstrip-pin: gpio");
|
oappend("\r\nstrip-pin: gpio");
|
||||||
oappendi(LEDPIN);
|
oappendi(LEDPIN);
|
||||||
oappend("\r\nbrand: wled");
|
oappend("\r\nbrand: wled");
|
||||||
oappend("\r\nbuild-type: src\r\n");
|
oappend("\r\nbuild-type: dev\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,11 +4,14 @@
|
|||||||
|
|
||||||
void initServer()
|
void initServer()
|
||||||
{
|
{
|
||||||
|
//CORS compatiblity
|
||||||
|
DefaultHeaders::Instance().addHeader("Access-Control-Allow-Origin", "*");
|
||||||
|
|
||||||
//settings page
|
//settings page
|
||||||
server.on("/settings", HTTP_GET, [](){
|
server->on("/settings", HTTP_GET, [](AsyncWebServerRequest *request){
|
||||||
serveSettings(0);
|
serveSettings(0);
|
||||||
});
|
});
|
||||||
server.on("/settings/wifi", HTTP_GET, [](){
|
server->on("/settings/wifi", HTTP_GET, [](AsyncWebServerRequest *request){
|
||||||
if (!(wifiLock && otaLock))
|
if (!(wifiLock && otaLock))
|
||||||
{
|
{
|
||||||
serveSettings(1);
|
serveSettings(1);
|
||||||
@ -16,57 +19,57 @@ void initServer()
|
|||||||
serveMessage(500, "Access Denied", txd, 254);
|
serveMessage(500, "Access Denied", txd, 254);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
server.on("/settings/leds", HTTP_GET, [](){
|
server->on("/settings/leds", HTTP_GET, [](AsyncWebServerRequest *request){
|
||||||
serveSettings(2);
|
serveSettings(2);
|
||||||
});
|
});
|
||||||
server.on("/settings/ui", HTTP_GET, [](){
|
server->on("/settings/ui", HTTP_GET, [](AsyncWebServerRequest *request){
|
||||||
serveSettings(3);
|
serveSettings(3);
|
||||||
});
|
});
|
||||||
server.on("/settings/sync", HTTP_GET, [](){
|
server->on("/settings/sync", HTTP_GET, [](AsyncWebServerRequest *request){
|
||||||
serveSettings(4);
|
serveSettings(4);
|
||||||
});
|
});
|
||||||
server.on("/settings/time", HTTP_GET, [](){
|
server->on("/settings/time", HTTP_GET, [](AsyncWebServerRequest *request){
|
||||||
serveSettings(5);
|
serveSettings(5);
|
||||||
});
|
});
|
||||||
server.on("/settings/sec", HTTP_GET, [](){
|
server->on("/settings/sec", HTTP_GET, [](AsyncWebServerRequest *request){
|
||||||
serveSettings(6);
|
serveSettings(6);
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("/favicon.ico", HTTP_GET, [](){
|
server->on("/favicon.ico", HTTP_GET, [](AsyncWebServerRequest *request){
|
||||||
if(!handleFileRead("/favicon.ico"))
|
if(!handleFileRead("/favicon.ico"))
|
||||||
{
|
{
|
||||||
server.send_P(200, "image/x-icon", favicon, 156);
|
server->send_P(200, "image/x-icon", favicon, 156);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("/sliders", HTTP_GET, serveIndex);
|
server->on("/sliders", HTTP_GET, serveIndex);
|
||||||
|
|
||||||
server.on("/welcome", HTTP_GET, [](){
|
server->on("/welcome", HTTP_GET, [](AsyncWebServerRequest *request){
|
||||||
serveSettings(255);
|
serveSettings(255);
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("/reset", HTTP_GET, [](){
|
server->on("/reset", HTTP_GET, [](AsyncWebServerRequest *request){
|
||||||
serveMessage(200,"Rebooting now...","(takes ~20 seconds, wait for auto-redirect)",79);
|
serveMessage(200,"Rebooting now...","(takes ~20 seconds, wait for auto-redirect)",79);
|
||||||
reset();
|
reset();
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("/settings/wifi", HTTP_POST, [](){
|
server->on("/settings/wifi", HTTP_POST, [](AsyncWebServerRequest *request){
|
||||||
if (!(wifiLock && otaLock)) handleSettingsSet(1);
|
if (!(wifiLock && otaLock)) handleSettingsSet(1);
|
||||||
serveMessage(200,"WiFi settings saved.","Rebooting now...",255);
|
serveMessage(200,"WiFi settings saved.","Rebooting now...",255);
|
||||||
reset();
|
reset();
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("/settings/leds", HTTP_POST, [](){
|
server->on("/settings/leds", HTTP_POST, [](AsyncWebServerRequest *request){
|
||||||
handleSettingsSet(2);
|
handleSettingsSet(2);
|
||||||
serveMessage(200,"LED settings saved.","Redirecting...",1);
|
serveMessage(200,"LED settings saved.","Redirecting...",1);
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("/settings/ui", HTTP_POST, [](){
|
server->on("/settings/ui", HTTP_POST, [](AsyncWebServerRequest *request){
|
||||||
handleSettingsSet(3);
|
handleSettingsSet(3);
|
||||||
serveMessage(200,"UI settings saved.","Reloading to apply theme...",122);
|
serveMessage(200,"UI settings saved.","Reloading to apply theme...",122);
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("/settings/sync", HTTP_POST, [](){
|
server->on("/settings/sync", HTTP_POST, [](AsyncWebServerRequest *request){
|
||||||
handleSettingsSet(4);
|
handleSettingsSet(4);
|
||||||
if (hueAttempt)
|
if (hueAttempt)
|
||||||
{
|
{
|
||||||
@ -77,46 +80,46 @@ void initServer()
|
|||||||
hueAttempt = false;
|
hueAttempt = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("/settings/time", HTTP_POST, [](){
|
server->on("/settings/time", HTTP_POST, [](AsyncWebServerRequest *request){
|
||||||
handleSettingsSet(5);
|
handleSettingsSet(5);
|
||||||
serveMessage(200,"Time settings saved.","Redirecting...",1);
|
serveMessage(200,"Time settings saved.","Redirecting...",1);
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("/settings/sec", HTTP_POST, [](){
|
server->on("/settings/sec", HTTP_POST, [](AsyncWebServerRequest *request){
|
||||||
handleSettingsSet(6);
|
handleSettingsSet(6);
|
||||||
serveMessage(200,"Security settings saved.","Rebooting now... (takes ~20 seconds, wait for auto-redirect)",139);
|
serveMessage(200,"Security settings saved.","Rebooting now... (takes ~20 seconds, wait for auto-redirect)",139);
|
||||||
reset();
|
reset();
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("/json", HTTP_ANY, [](){
|
server->on("/json", HTTP_ANY, [](AsyncWebServerRequest *request){
|
||||||
server.send(500, "application/json", "{\"error\":\"Not implemented\"}");
|
server->send(500, "application/json", "{\"error\":\"Not implemented\"}");
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("/json/effects", HTTP_GET, [](){
|
server->on("/json/effects", HTTP_GET, [](AsyncWebServerRequest *request){
|
||||||
server.setContentLength(strlen_P(JSON_mode_names));
|
server->setContentLength(strlen_P(JSON_mode_names));
|
||||||
server.send(200, "application/json", "");
|
server->send(200, "application/json", "");
|
||||||
server.sendContent_P(JSON_mode_names);
|
server->sendContent_P(JSON_mode_names);
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("/json/palettes", HTTP_GET, [](){
|
server->on("/json/palettes", HTTP_GET, [](AsyncWebServerRequest *request){
|
||||||
server.setContentLength(strlen_P(JSON_palette_names));
|
server->setContentLength(strlen_P(JSON_palette_names));
|
||||||
server.send(200, "application/json", "");
|
server->send(200, "application/json", "");
|
||||||
server.sendContent_P(JSON_palette_names);
|
server->sendContent_P(JSON_palette_names);
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("/version", HTTP_GET, [](){
|
server->on("/version", HTTP_GET, [](AsyncWebServerRequest *request){
|
||||||
server.send(200, "text/plain", (String)VERSION);
|
request->send(200, "text/plain", (String)VERSION);
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("/uptime", HTTP_GET, [](){
|
server->on("/uptime", HTTP_GET, [](AsyncWebServerRequest *request){
|
||||||
server.send(200, "text/plain", (String)millis());
|
request->send(200, "text/plain", (String)millis());
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("/freeheap", HTTP_GET, [](){
|
server->on("/freeheap", HTTP_GET, [](AsyncWebServerRequest *request){
|
||||||
server.send(200, "text/plain", (String)ESP.getFreeHeap());
|
request->send(200, "text/plain", (String)ESP.getFreeHeap());
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("/power", HTTP_GET, [](){
|
server->on("/power", HTTP_GET, [](AsyncWebServerRequest *request){
|
||||||
String val = "";
|
String val = "";
|
||||||
if (strip.currentMilliamps == 0)
|
if (strip.currentMilliamps == 0)
|
||||||
{
|
{
|
||||||
@ -129,95 +132,95 @@ void initServer()
|
|||||||
serveMessage(200, val, "This is just an estimate (does not account for factors like wire resistance). It is NOT a measurement!", 254);
|
serveMessage(200, val, "This is just an estimate (does not account for factors like wire resistance). It is NOT a measurement!", 254);
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("/u", HTTP_GET, [](){
|
server->on("/u", HTTP_GET, [](AsyncWebServerRequest *request){
|
||||||
server.setContentLength(strlen_P(PAGE_usermod));
|
server->setContentLength(strlen_P(PAGE_usermod));
|
||||||
server.send(200, "text/html", "");
|
server->send(200, "text/html", "");
|
||||||
server.sendContent_P(PAGE_usermod);
|
server->sendContent_P(PAGE_usermod);
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("/teapot", HTTP_GET, [](){
|
server->on("/teapot", HTTP_GET, [](AsyncWebServerRequest *request){
|
||||||
serveMessage(418, "418. I'm a teapot.", "(Tangible Embedded Advanced Project Of Twinkling)", 254);
|
serveMessage(418, "418. I'm a teapot.", "(Tangible Embedded Advanced Project Of Twinkling)", 254);
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("/build", HTTP_GET, [](){
|
server->on("/build", HTTP_GET, [](AsyncWebServerRequest *request){
|
||||||
getBuildInfo();
|
getBuildInfo();
|
||||||
server.send(200, "text/plain", obuf);
|
request->send(200, "text/plain", obuf);
|
||||||
});
|
});
|
||||||
//if OTA is allowed
|
//if OTA is allowed
|
||||||
if (!otaLock){
|
if (!otaLock){
|
||||||
server.on("/edit", HTTP_GET, [](){
|
server->on("/edit", HTTP_GET, [](){
|
||||||
server.send(200, "text/html", PAGE_edit);
|
server->send(200, "text/html", PAGE_edit);
|
||||||
});
|
});
|
||||||
#ifdef USEFS
|
#ifdef USEFS
|
||||||
server.on("/edit", HTTP_PUT, handleFileCreate);
|
server->on("/edit", HTTP_PUT, handleFileCreate);
|
||||||
server.on("/edit", HTTP_DELETE, handleFileDelete);
|
server->on("/edit", HTTP_DELETE, handleFileDelete);
|
||||||
server.on("/edit", HTTP_POST, [](){ server.send(200, "text/plain", ""); }, handleFileUpload);
|
server->on("/edit", HTTP_POST, [](){ server->send(200, "text/plain", ""); }, handleFileUpload);
|
||||||
server.on("/list", HTTP_GET, handleFileList);
|
server->on("/list", HTTP_GET, handleFileList);
|
||||||
#endif
|
#endif
|
||||||
//init ota page
|
//init ota page
|
||||||
#ifndef WLED_DISABLE_OTA
|
#ifndef WLED_DISABLE_OTA
|
||||||
httpUpdater.setup(&server);
|
httpUpdater.setup(&server);
|
||||||
#else
|
#else
|
||||||
server.on("/update", HTTP_GET, [](){
|
server->on("/update", HTTP_GET, [](){
|
||||||
serveMessage(500, "Not implemented", "OTA updates are unsupported in this build.", 254);
|
serveMessage(500, "Not implemented", "OTA updates are unsupported in this build.", 254);
|
||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
server.on("/edit", HTTP_GET, [](){
|
server->on("/edit", HTTP_GET, [](){
|
||||||
serveMessage(500, "Access Denied", txd, 254);
|
serveMessage(500, "Access Denied", txd, 254);
|
||||||
});
|
});
|
||||||
server.on("/update", HTTP_GET, [](){
|
server->on("/update", HTTP_GET, [](){
|
||||||
serveMessage(500, "Access Denied", txd, 254);
|
serveMessage(500, "Access Denied", txd, 254);
|
||||||
});
|
});
|
||||||
server.on("/list", HTTP_GET, [](){
|
server->on("/list", HTTP_GET, [](){
|
||||||
serveMessage(500, "Access Denied", txd, 254);
|
serveMessage(500, "Access Denied", txd, 254);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//this ceased working somehow
|
//this ceased working somehow
|
||||||
/*server.on("/", HTTP_GET, [](){
|
/*server->on("/", HTTP_GET, [](){
|
||||||
serveIndexOrWelcome();
|
serveIndexOrWelcome();
|
||||||
});*/
|
});*/
|
||||||
|
|
||||||
//called when the url is not defined here, ajax-in; get-settings
|
//called when the url is not defined here, ajax-in; get-settings
|
||||||
server.onNotFound([](){
|
server->onNotFound([](){
|
||||||
DEBUG_PRINTLN("Not-Found HTTP call:");
|
DEBUG_PRINTLN("Not-Found HTTP call:");
|
||||||
DEBUG_PRINTLN("URI: " + server.uri());
|
DEBUG_PRINTLN("URI: " + server->uri());
|
||||||
DEBUG_PRINTLN("Body: " + server.arg(0));
|
DEBUG_PRINTLN("Body: " + server->arg(0));
|
||||||
|
|
||||||
//make API CORS compatible
|
//make API CORS compatible
|
||||||
if (server.method() == HTTP_OPTIONS)
|
if (server->method() == HTTP_OPTIONS)
|
||||||
{
|
{
|
||||||
server.sendHeader("Access-Control-Allow-Origin", "*");
|
server->sendHeader("Access-Control-Allow-Origin", "*");
|
||||||
server.sendHeader("Access-Control-Max-Age", "10000");
|
server->sendHeader("Access-Control-Max-Age", "10000");
|
||||||
server.sendHeader("Access-Control-Allow-Methods", "PUT,POST,GET,OPTIONS");
|
server->sendHeader("Access-Control-Allow-Methods", "PUT,POST,GET,OPTIONS");
|
||||||
server.sendHeader("Access-Control-Allow-Headers", "*");
|
server->sendHeader("Access-Control-Allow-Headers", "*");
|
||||||
server.send(200);
|
server->send(200);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//workaround for subpage issue
|
//workaround for subpage issue
|
||||||
if (server.uri().length() == 1)
|
if (server->uri().length() == 1)
|
||||||
{
|
{
|
||||||
serveIndexOrWelcome();
|
serveIndexOrWelcome();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!handleSet(server.uri())){
|
if(!handleSet(server->uri())){
|
||||||
#ifndef WLED_DISABLE_ALEXA
|
#ifndef WLED_DISABLE_ALEXA
|
||||||
if(!espalexa.handleAlexaApiCall(server.uri(),server.arg(0)))
|
if(!espalexa.handleAlexaApiCall(server->uri(),server->arg(0)))
|
||||||
#endif
|
#endif
|
||||||
server.send(404, "text/plain", "Not Found");
|
server->send(404, "text/plain", "Not Found");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
#ifndef ARDUINO_ARCH_ESP32
|
#ifndef ARDUINO_ARCH_ESP32
|
||||||
const char * headerkeys[] = {"User-Agent"};
|
const char * headerkeys[] = {"User-Agent"};
|
||||||
server.collectHeaders(headerkeys,sizeof(headerkeys)/sizeof(char*));
|
server->collectHeaders(headerkeys,sizeof(headerkeys)/sizeof(char*));
|
||||||
#else
|
#else
|
||||||
String ua = "User-Agent";
|
String ua = "User-Agent";
|
||||||
server.collectHeaders(ua);
|
server->collectHeaders(ua);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,7 +252,7 @@ void serveRealtimeError(bool settings)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
mesg += ").";
|
mesg += ").";
|
||||||
server.send(200, "text/plain", mesg);
|
server->send(200, "text/plain", mesg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -271,7 +274,7 @@ void getCSSColors()
|
|||||||
void serveIndex()
|
void serveIndex()
|
||||||
{
|
{
|
||||||
bool serveMobile = false;
|
bool serveMobile = false;
|
||||||
if (uiConfiguration == 0) serveMobile = checkClientIsMobile(server.header("User-Agent"));
|
if (uiConfiguration == 0) serveMobile = checkClientIsMobile(server->header("User-Agent"));
|
||||||
else if (uiConfiguration == 2) serveMobile = true;
|
else if (uiConfiguration == 2) serveMobile = true;
|
||||||
|
|
||||||
if (realtimeActive && !enableRealtimeUI) //do not serve while receiving realtime
|
if (realtimeActive && !enableRealtimeUI) //do not serve while receiving realtime
|
||||||
@ -282,12 +285,12 @@ void serveIndex()
|
|||||||
|
|
||||||
//error message is not gzipped
|
//error message is not gzipped
|
||||||
#ifdef WLED_DISABLE_MOBILE_UI
|
#ifdef WLED_DISABLE_MOBILE_UI
|
||||||
if (!serveMobile) server.sendHeader("Content-Encoding","gzip");
|
if (!serveMobile) server->sendHeader("Content-Encoding","gzip");
|
||||||
#else
|
#else
|
||||||
server.sendHeader("Content-Encoding","gzip");
|
server->sendHeader("Content-Encoding","gzip");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
server.send_P(200, "text/html",
|
server->send_P(200, "text/html",
|
||||||
(serveMobile) ? PAGE_indexM : PAGE_index0,
|
(serveMobile) ? PAGE_indexM : PAGE_index0,
|
||||||
(serveMobile) ? PAGE_indexM_L : PAGE_index0_L);
|
(serveMobile) ? PAGE_indexM_L : PAGE_index0_L);
|
||||||
}
|
}
|
||||||
@ -319,12 +322,12 @@ void serveMessage(int code, String headl, String subl="", int optionType)
|
|||||||
messageBody += "<script>setTimeout(RP," + String((optionType-120)*1000) + ")</script>";
|
messageBody += "<script>setTimeout(RP," + String((optionType-120)*1000) + ")</script>";
|
||||||
}
|
}
|
||||||
messageBody += "</body></html>";
|
messageBody += "</body></html>";
|
||||||
server.setContentLength(strlen_P(PAGE_msg0) + olen + strlen_P(PAGE_msg1) + messageBody.length());
|
server->setContentLength(strlen_P(PAGE_msg0) + olen + strlen_P(PAGE_msg1) + messageBody.length());
|
||||||
server.send(code, "text/html", "");
|
server->send(code, "text/html", "");
|
||||||
server.sendContent_P(PAGE_msg0);
|
server->sendContent_P(PAGE_msg0);
|
||||||
server.sendContent(obuf);
|
server->sendContent(obuf);
|
||||||
server.sendContent_P(PAGE_msg1);
|
server->sendContent_P(PAGE_msg1);
|
||||||
server.sendContent(messageBody);
|
server->sendContent(messageBody);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -359,32 +362,32 @@ void serveSettings(byte subPage)
|
|||||||
|
|
||||||
getCSSColors();
|
getCSSColors();
|
||||||
|
|
||||||
server.setContentLength(pl0 + olen + sCssLength + pl1);
|
server->setContentLength(pl0 + olen + sCssLength + pl1);
|
||||||
server.send(200, "text/html", "");
|
server->send(200, "text/html", "");
|
||||||
|
|
||||||
switch (subPage)
|
switch (subPage)
|
||||||
{
|
{
|
||||||
case 1: server.sendContent_P(PAGE_settings_wifi0); break;
|
case 1: server->sendContent_P(PAGE_settings_wifi0); break;
|
||||||
case 2: server.sendContent_P(PAGE_settings_leds0); break;
|
case 2: server->sendContent_P(PAGE_settings_leds0); break;
|
||||||
case 3: server.sendContent_P(PAGE_settings_ui0 ); break;
|
case 3: server->sendContent_P(PAGE_settings_ui0 ); break;
|
||||||
case 4: server.sendContent_P(PAGE_settings_sync0); break;
|
case 4: server->sendContent_P(PAGE_settings_sync0); break;
|
||||||
case 5: server.sendContent_P(PAGE_settings_time0); break;
|
case 5: server->sendContent_P(PAGE_settings_time0); break;
|
||||||
case 6: server.sendContent_P(PAGE_settings_sec0 ); break;
|
case 6: server->sendContent_P(PAGE_settings_sec0 ); break;
|
||||||
case 255: server.sendContent_P(PAGE_welcome0 ); break;
|
case 255: server->sendContent_P(PAGE_welcome0 ); break;
|
||||||
default: server.sendContent_P(PAGE_settings0 );
|
default: server->sendContent_P(PAGE_settings0 );
|
||||||
}
|
}
|
||||||
server.sendContent(obuf);
|
server->sendContent(obuf);
|
||||||
|
|
||||||
if (subPage >0 && subPage <7) server.sendContent_P(PAGE_settingsCss);
|
if (subPage >0 && subPage <7) server->sendContent_P(PAGE_settingsCss);
|
||||||
switch (subPage)
|
switch (subPage)
|
||||||
{
|
{
|
||||||
case 1: server.sendContent_P(PAGE_settings_wifi1); break;
|
case 1: server->sendContent_P(PAGE_settings_wifi1); break;
|
||||||
case 2: server.sendContent_P(PAGE_settings_leds1); break;
|
case 2: server->sendContent_P(PAGE_settings_leds1); break;
|
||||||
case 3: server.sendContent_P(PAGE_settings_ui1 ); break;
|
case 3: server->sendContent_P(PAGE_settings_ui1 ); break;
|
||||||
case 4: server.sendContent_P(PAGE_settings_sync1); break;
|
case 4: server->sendContent_P(PAGE_settings_sync1); break;
|
||||||
case 5: server.sendContent_P(PAGE_settings_time1); break;
|
case 5: server->sendContent_P(PAGE_settings_time1); break;
|
||||||
case 6: server.sendContent_P(PAGE_settings_sec1 ); break;
|
case 6: server->sendContent_P(PAGE_settings_sec1 ); break;
|
||||||
case 255: server.sendContent_P(PAGE_welcome1 ); break;
|
case 255: server->sendContent_P(PAGE_welcome1 ); break;
|
||||||
default: server.sendContent_P(PAGE_settings1 );
|
default: server->sendContent_P(PAGE_settings1 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user