diff --git a/wled00/WS2812FX.cpp b/wled00/WS2812FX.cpp index 53fba1091..d6c167d73 100644 --- a/wled00/WS2812FX.cpp +++ b/wled00/WS2812FX.cpp @@ -1548,6 +1548,10 @@ void WS2812FX::mode_circus_combustus(void) { _mode_delay = 100 + ((100 * (uint32_t)(SPEED_MAX - _speed)) / _led_count); } + + +//WLED specific methods + void WS2812FX::setIndividual(int i) { if (i >= 0 && i < _led_count) diff --git a/wled00/WS2812FX.h b/wled00/WS2812FX.h index dea89ff1e..8a512aab4 100644 --- a/wled00/WS2812FX.h +++ b/wled00/WS2812FX.h @@ -1,4 +1,4 @@ -#define RGBW +//#define RGBW /* WS2812FX.h - Library for WS2812 LED effects. diff --git a/wled00/data/settings-min.html b/wled00/data/settings-min.html deleted file mode 100644 index 939aba0f4..000000000 --- a/wled00/data/settings-min.html +++ /dev/null @@ -1,114 +0,0 @@ - - - - -Settings - - - - -

WLED Settings

-
-
-
-

WiFi setup

-

Connect to existing network

-Network SSID (leave empty to not connect):

-Network password:

-Static IP (leave at 0.0.0.0 for DHCP):
- . - . - . -
-Static gateway:
- . - . - . -
-Static subnet mask:
- . - . - . -
-mDNS address (leave empty for no mDNS):
-http:// .local
-Client IP: Not connected
-

Configure Access Point

-AP SSID (leave empty for no AP):

-Hide AP SSID:
-AP password (leave empty for open):

-AP channel:
-AP IP: Not active
-
-

Application setup

-

Web setup

-Server description:
-Use HSB sliders instead of RGB by default:
-

LED setup

-LED count (max. 255):
-Default RGB color: - - -
-Default brightness: (0-255)
-Default white value (only RGBW, -1 to disable):
-Default effect ID:
-Default effect speed:
-Ignore and use current color, brightness and effects:
-Turn on after power up/reset:
-Use Gamma correction for brightness:
-Use Gamma correction for color:
-Brightness factor: %
-

Button setup

-On/Off button enabled:
-

Transitions

-Fade:
-Sweep: Invert direction:
-Transition Delay: ms
-

Timed light

-Target brightness: (0-255)
-Change after: min
-Fade:
-

Broadcast

-UDP Port:
-Receive notifications:
-Send notifications on direct change:
-Send notifications on button press:
-

Interfaces

-Emulate Alexa device:
-Alexa invocation name:
-Send Alexa notifications:
-

Time (experimental!)

-NTP was updated but still causes crashes. Requires reboot.
-Get time from NTP server:
-Current local time is unknown
-

Advanced

-Default overlay ID:
-WARLS offset: negative
-

Security

-OTA locked:
-Passphrase:
-To enable OTA, for security reasons you need to also enter the correct password!
-The password may/should be changed when OTA is enabled.
-Disable OTA when not in use, otherwise an attacker could reflash device software!

-Disable recovery AP (Not implemented):
-In case of a connection error there will be no wireless recovery possible!
-Completely disables all Access Point functions.

-Factory reset:
-All EEPROM content (settings) will be erased.

-HTTP traffic is not encrypted. An attacker in the same network could intercept form data!
-

About

-WLED version 0.4p
-(c) 2016-2017 Christian Schwinne
-Licensed under the MIT license
-Uses libraries:
-ESP8266 Arduino Core
-WS2812FX by kitesurfer1404 (Aircoookie fork)
-Timezone library by JChristensen
-arduino-esp8266-alexa-multiple-wemo-switch by kakopappa
-Server message: XML response error! -


-
-
- - \ No newline at end of file diff --git a/wled00/data/settings.htm b/wled00/data/settings.htm index 019e92efa..035d23e9b 100644 --- a/wled00/data/settings.htm +++ b/wled00/data/settings.htm @@ -6,77 +6,10 @@

WLED Settings

-
+

WiFi setup

@@ -36,6 +41,7 @@ Static subnet mask:

mDNS address (leave empty for no mDNS):
http:// .local
+Try connecting before opening AP for: s
Client IP: Not connected

Configure Access Point

AP SSID (leave empty for no AP):

@@ -95,9 +101,10 @@ Passphrase:
To enable OTA, for security reasons you need to also enter the correct password!
The password may/should be changed when OTA is enabled.
Disable OTA when not in use, otherwise an attacker could reflash device software!

-Disable recovery AP (Not implemented):
+Disable recovery AP:
In case of a connection error there will be no wireless recovery possible!
-Completely disables all Access Point functions.

+Completely disables all Access Point functions.
+Setting only changable if OTA is enabled!

Factory reset:
All EEPROM content (settings) will be erased.

HTTP traffic is not encrypted. An attacker in the same network could intercept form data!
@@ -117,6 +124,7 @@ Server message: XML response error! )====="; + /* * Settings set html */ diff --git a/wled00/wled00.ino b/wled00/wled00.ino index d19747619..db5b3d58f 100644 --- a/wled00/wled00.ino +++ b/wled00/wled00.ino @@ -20,7 +20,7 @@ #include "CallbackFunction.h" //version in format yymmddb (b = daily build) -#define VERSION 1711191 +#define VERSION 1711200 //If you have an RGBW strip, uncomment first line in WS2812FX.h! @@ -79,7 +79,8 @@ String cmdns = "led"; String apssid = "WLED-AP"; uint8_t apchannel = 1; uint8_t aphide = 0; -boolean useap = true; +uint8_t apWaitTimeSecs = 32; +boolean recoveryAPDisabled = false; IPAddress staticip(0, 0, 0, 0); IPAddress staticgateway(0, 0, 0, 0); IPAddress staticsubnet(255, 255, 255, 0); @@ -93,8 +94,8 @@ uint8_t bri_nl = 0, bri_nls; boolean fadeTransition = true; boolean sweepTransition = false; boolean sweepDirection = true; uint16_t transitionDelay = 1200; -boolean ota_lock = true; -boolean only_ap = false; +boolean otaLock = true; +boolean onlyAP = false; boolean buttonEnabled = true; boolean notifyDirect = true, notifyButton = true, notifyDirectDefault = true; boolean receiveNotifications = true, receiveNotificationsDefault = true; @@ -178,7 +179,7 @@ uint8_t auxTime = 0; unsigned long auxStartTime; boolean auxActive, auxActiveBefore; -boolean useGammaCorrectionBri = true; +boolean useGammaCorrectionBri = false; boolean useGammaCorrectionRGB = true; int arlsOffset = -22; //10: -22 assuming arls52 boolean realtimeEnabled = true; diff --git a/wled00/wled01_eeprom.ino b/wled00/wled01_eeprom.ino index 665eb68af..034e4374b 100644 --- a/wled00/wled01_eeprom.ino +++ b/wled00/wled01_eeprom.ino @@ -75,7 +75,7 @@ void saveSettingsToEEPROM() EEPROM.write(i, otapass.charAt(i-256)); } EEPROM.write(288, bri_nl); - EEPROM.write(289, ota_lock); + EEPROM.write(289, otaLock); EEPROM.write(290, (udpPort >> 0) & 0xFF); EEPROM.write(291, (udpPort >> 8) & 0xFF); for (int i = 292; i < 324; ++i) @@ -105,6 +105,8 @@ void saveSettingsToEEPROM() EEPROM.write(372, useRGBW); EEPROM.write(373, sweepTransition); EEPROM.write(374, sweepDirection); + EEPROM.write(375, apWaitTimeSecs); + EEPROM.write(376, recoveryAPDisabled); EEPROM.commit(); } @@ -189,7 +191,7 @@ void loadSettingsFromEEPROM() otapass += char(EEPROM.read(i)); } bri_nl = EEPROM.read(288); - ota_lock = EEPROM.read(289); + otaLock = EEPROM.read(289); udpPort = ((EEPROM.read(290) << 0) & 0xFF) + ((EEPROM.read(291) << 8) & 0xFF00); serverDescription = ""; for (int i = 292; i < 324; ++i) @@ -220,5 +222,7 @@ void loadSettingsFromEEPROM() useRGBW = EEPROM.read(372); sweepTransition = EEPROM.read(373); sweepDirection = EEPROM.read(374); + apWaitTimeSecs = EEPROM.read(375); + recoveryAPDisabled = EEPROM.read(376); useHSB = useHSBDefault; } diff --git a/wled00/wled02_xml.ino b/wled00/wled02_xml.ino index a9f34ed07..ef7132c0b 100644 --- a/wled00/wled02_xml.ino +++ b/wled00/wled02_xml.ino @@ -49,186 +49,119 @@ void XML_response() server.send(200, "text/xml", resp); } -void XML_response_settings() +String getSettings() { - DEBUG_PRINTLN("XML settings response"); - String resp; - resp = resp + ""; - resp = resp + ""; - resp = resp + ""; - resp = resp + clientssid; - resp = resp + ""; - resp = resp + ""; + DEBUG_PRINTLN("settings resp"); + + String resp = ""; + String ds = "d.Sf."; + String dg = "d.getElementsByClassName"; + String v = ".value="; + String c = ".checked="; + String ih = ".innerHTML="; + + resp += ds + "CSSID" + v + "\"" + clientssid + "\";"; + resp += ds + "CPASS" + v + "\""; for (int i = 0; i < clientpass.length(); i++) { - resp = resp + "*"; + resp += "*"; } - resp = resp + ""; - for (int i = 0; i < 4; i++) + resp += "\";"; + resp += ds + "CSIP0" + v + staticip[0] +";"; + resp += ds + "CSIP1" + v + staticip[1] +";"; + resp += ds + "CSIP2" + v + staticip[2] +";"; + resp += ds + "CSIP3" + v + staticip[3] +";"; + resp += ds + "CSGW0" + v + staticgateway[0] +";"; + resp += ds + "CSGW1" + v + staticgateway[1] +";"; + resp += ds + "CSGW2" + v + staticgateway[2] +";"; + resp += ds + "CSGW3" + v + staticgateway[3] +";"; + resp += ds + "CSSN0" + v + staticsubnet[0] +";"; + resp += ds + "CSSN1" + v + staticsubnet[1] +";"; + resp += ds + "CSSN2" + v + staticsubnet[2] +";"; + resp += ds + "CSSN3" + v + staticsubnet[3] +";"; + resp += ds + "CMDNS" + v + "\"" + cmdns + "\";"; + resp += ds + "APWTM" + v + apWaitTimeSecs +";"; + resp += ds + "APSSID" + v + "\"" + apssid + "\";"; + resp += ds + "APHSSID" + c + aphide + ";"; + resp += ds + "APPASS" + v + "\""; + for (int i = 0; i < clientpass.length(); i++) { - resp = resp + ""; - resp = resp + staticip[i]; - resp = resp + ""; + resp += "*"; } - for (int i = 0; i < 4; i++) - { - resp = resp + ""; - resp = resp + staticgateway[i]; - resp = resp + ""; - } - for (int i = 0; i < 4; i++) - { - resp = resp + ""; - resp = resp + staticsubnet[i]; - resp = resp + ""; - } - resp = resp + ""; - resp = resp + cmdns; - resp = resp + ""; - resp = resp + ""; - resp = resp + apssid; - resp = resp + ""; - resp = resp + ""; - resp = resp + aphide; - resp = resp + ""; - resp = resp + ""; - for (int i = 0; i < appass.length(); i++) - { - resp = resp + "*"; - } - resp = resp + ""; - resp = resp + ""; - resp = resp + apchannel; - resp = resp + ""; - resp = resp + ""; - resp = resp + serverDescription; - resp = resp + ""; - resp = resp + ""; - resp = resp + useHSBDefault; - resp = resp + ""; - resp = resp + ""; - resp = resp + ledcount; - resp = resp + ""; - for (int i = 0; i < 3; i++) - { - resp = resp + ""; - resp = resp + col_s[i]; - resp = resp + ""; - } - resp = resp + ""; + resp += "\";"; + resp += ds + "APCHAN" + v + apchannel +";"; + + resp += ds + "DESC" + v + "\"" + serverDescription + "\";"; + resp += ds + "COLMD" + c + useHSBDefault + ";"; + resp += ds + "LEDCN" + v + ledcount +";"; + resp += ds + "CLDFR" + v + col_s[0] +";"; + resp += ds + "CLDFG" + v + col_s[1] +";"; + resp += ds + "CLDFB" + v + col_s[2] +";"; + resp += ds + "CLDFA" + v + bri_s +";"; if (useRGBW) { - resp = resp + white_s; - } else { - resp = resp + "-1"; - } - resp = resp + ""; - resp = resp + bri_s; - resp = resp + ""; - resp = resp + ""; - resp = resp + turnOnAtBoot; - resp = resp + ""; - resp = resp + ""; - resp = resp + effectDefault; - resp = resp + ""; - resp = resp + ""; - resp = resp + effectSpeedDefault; - resp = resp + ""; - resp = resp + ""; - resp = resp + useGammaCorrectionBri; - resp = resp + ""; - resp = resp + useGammaCorrectionRGB; - resp = resp + ""; - resp = resp + ""; - resp = resp + buttonEnabled; - resp = resp + ""; - resp = resp + fadeTransition; - resp = resp + ""; - resp = resp + transitionDelay; - resp = resp + ""; - resp = resp + sweepTransition; - resp = resp + ""; - resp = resp + !sweepDirection; - resp = resp + ""; - resp = resp + bri_nl; - resp = resp + ""; - resp = resp + ""; - resp = resp + nightlightDelayMins; - resp = resp + ""; - resp = resp + ""; - resp = resp + nightlightFade; - resp = resp + ""; - resp = resp + ""; - resp = resp + udpPort; - resp = resp + ""; - resp = resp + ""; - resp = resp + receiveNotificationsDefault; - resp = resp + ""; - resp = resp + bri_n; - resp = resp + ""; - resp = resp + notifyDirectDefault; - resp = resp + ""; - resp = resp + notifyButton; - resp = resp + "0"; //legacy - resp = resp + ""; - resp = resp + ntpEnabled; - resp = resp + ""; - resp = resp + ""; - resp = resp + alexaEnabled; - resp = resp + ""; - resp = resp + alexaInvocationName; - resp = resp + ""; - resp = resp + alexaNotify; - resp = resp + ""; - DEBUG_PRINTLN("pretime"); - resp = resp + ""; - resp = resp + getTimeString(); - resp = resp + ""; - resp = resp + ""; - resp = resp + overlayDefault; - resp = resp + ""; - resp = resp + ""; - resp = resp + abs(arlsOffset); - resp = resp + ""; - resp = resp + ""; - resp = resp + !arlsSign; - resp = resp + ""; - resp = resp + ""; - resp = resp + ota_lock; - resp = resp +""; - resp = resp + "0"; //NI - resp = resp + ""; + resp += ds + "CLDFW" + v + white_s +";"; + } else { + resp += ds + "CLDFW" + v + "-1;"; + } + resp += ds + "BOOTN" + c + turnOnAtBoot +";"; + resp += ds + "FXDEF" + v + effectDefault +";"; + resp += ds + "FXDEF" + v + effectDefault +";"; + resp += ds + "GCBRI" + c + useGammaCorrectionBri +";"; + resp += ds + "GCRGB" + c + useGammaCorrectionRGB +";"; + resp += ds + "BTNON" + c + buttonEnabled +";"; + resp += ds + "TFADE" + c + fadeTransition +";"; + resp += ds + "TSWEE" + c + sweepTransition +";"; + resp += ds + "TSDIR" + c + !sweepDirection +";"; + resp += ds + "TDLAY" + v + transitionDelay +";"; + resp += ds + "TLBRI" + v + bri_nl +";"; + resp += ds + "TLDUR" + v + nightlightDelayMins +";"; + resp += ds + "TLFDE" + c + nightlightFade +";"; + resp += ds + "NUDPP" + v + udpPort +";"; + resp += ds + "NRBRI" + v + bri_n +";"; + resp += ds + "NRCVE" + c + receiveNotificationsDefault +";"; + resp += ds + "NSDIR" + c + notifyDirectDefault +";"; + resp += ds + "NSBTN" + c + notifyButton +";"; + resp += ds + "NTPON" + c + ntpEnabled +";"; + resp += ds + "ALEXA" + c + alexaEnabled +";"; + resp += ds + "AINVN" + v + "\"" + alexaInvocationName + "\";"; + resp += ds + "NSALX" + c + alexaNotify +";"; + resp += dg + "(\"times\")[0]" + ih + "\"" + getTimeString() + "\";"; + resp += ds + "OLDEF" + v + overlayDefault +";"; + resp += ds + "WOFFS" + v + abs(arlsOffset) +";"; + resp += ds + "WOFFN" + c + !arlsSign +";"; + resp += ds + "NOOTA" + c + otaLock +";"; + resp += ds + "NORAP" + c + recoveryAPDisabled +";"; + resp += dg + "(\"sip\")[0]" + ih + "\""; if (!WiFi.localIP()[0] == 0) { - resp = resp + WiFi.localIP()[0]; - resp = resp + "."; - resp = resp + WiFi.localIP()[1]; - resp = resp + "."; - resp = resp + WiFi.localIP()[2]; - resp = resp + "."; - resp = resp + WiFi.localIP()[3]; + resp += WiFi.localIP()[0]; + resp += + "."; + resp += WiFi.localIP()[1]; + resp += "."; + resp += WiFi.localIP()[2]; + resp += "."; + resp += WiFi.localIP()[3]; } else { - resp = resp + "Not connected"; + resp += "Not connected"; } - resp = resp + ""; + resp += "\";"; + resp += dg + "(\"sip\")[1]" + ih + "\""; if (!WiFi.softAPIP()[0] == 0) { - resp = resp + WiFi.softAPIP()[0]; - resp = resp + "."; - resp = resp + WiFi.softAPIP()[1]; - resp = resp + "."; - resp = resp + WiFi.softAPIP()[2]; - resp = resp + "."; - resp = resp + WiFi.softAPIP()[3]; + resp += WiFi.softAPIP()[0]; + resp += + "."; + resp += WiFi.softAPIP()[1]; + resp += "."; + resp += WiFi.softAPIP()[2]; + resp += "."; + resp += WiFi.softAPIP()[3]; } else { - resp = resp + "Not active"; + resp += "Not active"; } - resp = resp + ""; - resp = resp + "WLED 0.4p (build "; - resp = resp + VERSION; - resp = resp + ") OK"; - resp = resp + ""; - DEBUG_PRINTLN(resp); - server.send(200, "text/xml", resp); + resp += "\";"; + resp += dg + "(\"msg\")[0]" + ih + "\"WLED 0.4p (build " + VERSION + ") OK\";"; + + return resp; } diff --git a/wled00/wled03_set.ino b/wled00/wled03_set.ino index aecc1e987..3253822f4 100644 --- a/wled00/wled03_set.ino +++ b/wled00/wled03_set.ino @@ -14,14 +14,13 @@ void handleSettingsSet() } } if (server.hasArg("CMDNS")) cmdns = server.arg("CMDNS"); - if (server.hasArg("APSSID")) apssid = server.arg("APSSID"); - if (server.hasArg("APHSSID")) + if (server.hasArg("APWTM")) { - aphide = 1; - } else - { - aphide = 0; + int i = server.arg("APWTM").toInt(); + if (i >= 0 && i <= 255) apWaitTimeSecs = i; } + if (server.hasArg("APSSID")) apssid = server.arg("APSSID"); + aphide = server.hasArg("APHSSID"); if (server.hasArg("APPASS")) { if (!server.arg("APPASS").indexOf('*') == 0) appass = server.arg("APPASS"); @@ -34,7 +33,7 @@ void handleSettingsSet() if (server.hasArg("RESET")) //might be dangerous in case arg is always sent { clearEEPROM(); - server.send(200, "text/plain", "Settings erased. Please wait for light to turn back on, then go to main page..."); + server.send(200, "text/plain", "Settings erased. Rebooting..."); reset(); } if (server.hasArg("CSIP0")) @@ -218,7 +217,7 @@ void handleSettingsSet() } if (server.hasArg("OPASS")) { - if (!ota_lock) + if (!otaLock) { if (server.arg("OPASS").length() > 0) otapass = server.arg("OPASS"); @@ -226,11 +225,16 @@ void handleSettingsSet() { if (otapass.equals(server.arg("OPASS"))) { - ota_lock = false; + otaLock = false; } } } - if (server.hasArg("NOOTA")) ota_lock = true; + if (server.hasArg("NOOTA")) otaLock = true; + if (server.hasArg("NORAP")) { + if (!otaLock) recoveryAPDisabled = true; + } else { + recoveryAPDisabled = false; + } saveSettingsToEEPROM(); } @@ -238,11 +242,6 @@ boolean handleSet(String req) { boolean effectUpdated = false; if (!(req.indexOf("win") >= 0)) { - if (req.indexOf("get-settings") >= 0) - { - XML_response_settings(); - return true; - } return false; } int pos = 0; diff --git a/wled00/wled05_init.ino b/wled00/wled05_init.ino index 3029a673e..9ab9d82af 100644 --- a/wled00/wled05_init.ino +++ b/wled00/wled05_init.ino @@ -55,7 +55,7 @@ void wledInit() DEBUG_PRINTLN(WiFi.localIP()); // Set up mDNS responder: - if (cmdns != NULL && !only_ap && !MDNS.begin(cmdns.c_str())) { + if (cmdns != NULL && !onlyAP && !MDNS.begin(cmdns.c_str())) { DEBUG_PRINTLN("Error setting up MDNS responder!"); down(); } @@ -71,7 +71,12 @@ void wledInit() //SERVER INIT //settings page server.on("/settings", HTTP_GET, [](){ - if(!handleFileRead("/settings.htm")) server.send(200, "text/html", PAGE_settings); + String settingsBuffer = getSettings(); + server.setContentLength(strlen_P(PAGE_settings0) + strlen_P(PAGE_settings1) + settingsBuffer.length()); + server.send(200, "text/html", ""); + server.sendContent_P(PAGE_settings0); + server.sendContent(settingsBuffer); + server.sendContent_P(PAGE_settings1); }); server.on("/favicon.ico", HTTP_GET, [](){ if(!handleFileRead("/favicon.ico")) server.send(200, "image/x-icon", favicon); @@ -80,7 +85,7 @@ void wledInit() if(!handleFileRead("/index.htm")) server.send(200, "text/html", PAGE_index); }); server.on("/reset", HTTP_GET, [](){ - server.send(200, "text/plain", "Rebooting... Please wait a few seconds and refresh page."); + server.send(200, "text/plain", "Rebooting..."); reset(); }); server.on("/set-settings", HTTP_POST, [](){ @@ -96,7 +101,7 @@ void wledInit() server.on("/freeheap", HTTP_GET, [](){ server.send(200, "text/plain", (String)ESP.getFreeHeap()); }); - if (!ota_lock){ + if (!otaLock){ server.on("/edit", HTTP_GET, [](){ if(!handleFileRead("/edit.htm")) server.send(200, "text/html", PAGE_edit); }); @@ -168,12 +173,12 @@ void initCon() delay(500); DEBUG_PRINTLN("C_NC"); fail_count++; - if (fail_count > 32) + if (!recoveryAPDisabled && fail_count > apWaitTimeSecs*2) { WiFi.disconnect(); - DEBUG_PRINTLN("Can't connect to network. Opening AP..."); + DEBUG_PRINTLN("Can't connect. Opening AP..."); String save = apssid; - only_ap = true; + onlyAP = true; if (apssid.length() <1) apssid = "WLED-AP"; initAP(); apssid = save;