Significantly altered settings page logic to improve network and memory payloads

Added setting to entirely disable recovery AP (if OTA is enabled)
Added setting to specify time to try connecting before opening AP
This commit is contained in:
cschwinne 2017-11-20 00:07:37 +01:00
parent a33386c672
commit a4cf0e0e2e
10 changed files with 164 additions and 389 deletions

View File

@ -1548,6 +1548,10 @@ void WS2812FX::mode_circus_combustus(void) {
_mode_delay = 100 + ((100 * (uint32_t)(SPEED_MAX - _speed)) / _led_count); _mode_delay = 100 + ((100 * (uint32_t)(SPEED_MAX - _speed)) / _led_count);
} }
//WLED specific methods
void WS2812FX::setIndividual(int i) void WS2812FX::setIndividual(int i)
{ {
if (i >= 0 && i < _led_count) if (i >= 0 && i < _led_count)

View File

@ -1,4 +1,4 @@
#define RGBW //#define RGBW
/* /*
WS2812FX.h - Library for WS2812 LED effects. WS2812FX.h - Library for WS2812 LED effects.

File diff suppressed because one or more lines are too long

View File

@ -6,77 +6,10 @@
<script> <script>
function GetCurrent() function GetCurrent()
{ {
var request = new XMLHttpRequest(); var d = document;
request.onreadystatechange = function() //values injected by server while sending HTML
{ d.Sf.CSSID.value = "DONT put settings.htm in SPIFFS!";
if (this.readyState == 4) { d.getElementsByClassName("msg")[0].innerHTML = "Response Error";
if (this.status == 200) {
if (this.responseXML != null) {
document.S_form.CSSID.value = this.responseXML.getElementsByTagName('cssid')[0].innerHTML;
document.S_form.CPASS.value = this.responseXML.getElementsByTagName('cpass')[0].innerHTML; //fake pass like ******
document.S_form.CSIP0.value = this.responseXML.getElementsByTagName('csips')[0].innerHTML;
document.S_form.CSIP1.value = this.responseXML.getElementsByTagName('csips')[1].innerHTML;
document.S_form.CSIP2.value = this.responseXML.getElementsByTagName('csips')[2].innerHTML;
document.S_form.CSIP3.value = this.responseXML.getElementsByTagName('csips')[3].innerHTML;
document.S_form.CSGW0.value = this.responseXML.getElementsByTagName('csgws')[0].innerHTML;
document.S_form.CSGW1.value = this.responseXML.getElementsByTagName('csgws')[1].innerHTML;
document.S_form.CSGW2.value = this.responseXML.getElementsByTagName('csgws')[2].innerHTML;
document.S_form.CSGW3.value = this.responseXML.getElementsByTagName('csgws')[3].innerHTML;
document.S_form.CSSN0.value = this.responseXML.getElementsByTagName('cssns')[0].innerHTML;
document.S_form.CSSN1.value = this.responseXML.getElementsByTagName('cssns')[1].innerHTML;
document.S_form.CSSN2.value = this.responseXML.getElementsByTagName('cssns')[2].innerHTML;
document.S_form.CSSN3.value = this.responseXML.getElementsByTagName('cssns')[3].innerHTML;
document.S_form.CMDNS.value = this.responseXML.getElementsByTagName('cmdns')[0].innerHTML;
document.S_form.APSSID.value = this.responseXML.getElementsByTagName('apssid')[0].innerHTML;
document.S_form.APHSSID.checked = (this.responseXML.getElementsByTagName('aphssid')[0].innerHTML)!=0?true:false;
document.S_form.APPASS.value = this.responseXML.getElementsByTagName('appass')[0].innerHTML; //fake pass
document.S_form.APCHAN.value = this.responseXML.getElementsByTagName('apchan')[0].innerHTML;
document.S_form.DESC.value = this.responseXML.getElementsByTagName('desc')[0].innerHTML;
document.S_form.COLMD.checked = (this.responseXML.getElementsByTagName('colmd')[0].innerHTML)!=0?true:false;
document.S_form.LEDCN.value = this.responseXML.getElementsByTagName('ledcn')[0].innerHTML;
document.S_form.CLDFR.value = this.responseXML.getElementsByTagName('cldef')[0].innerHTML;
document.S_form.CLDFG.value = this.responseXML.getElementsByTagName('cldef')[1].innerHTML;
document.S_form.CLDFB.value = this.responseXML.getElementsByTagName('cldef')[2].innerHTML;
document.S_form.CLDFA.value = this.responseXML.getElementsByTagName('cldfa')[0].innerHTML;
document.S_form.CLDFW.value = this.responseXML.getElementsByTagName('cldfw')[0].innerHTML;
document.S_form.FXDEF.value = this.responseXML.getElementsByTagName('fxdef')[0].innerHTML;
document.S_form.SXDEF.value = this.responseXML.getElementsByTagName('sxdef')[0].innerHTML;
document.S_form.BOOTN.checked = (this.responseXML.getElementsByTagName('bootn')[0].innerHTML)!=0?true:false;
document.S_form.GCBRI.checked = (this.responseXML.getElementsByTagName('gcbri')[0].innerHTML)!=0?true:false;
document.S_form.GCRGB.checked = (this.responseXML.getElementsByTagName('gcrgb')[0].innerHTML)!=0?true:false;
document.S_form.BTNON.checked = (this.responseXML.getElementsByTagName('btnon')[0].innerHTML)!=0?true:false;
document.S_form.TFADE.checked = (this.responseXML.getElementsByTagName('tfade')[0].innerHTML)!=0?true:false;
document.S_form.TSWEE.checked = (this.responseXML.getElementsByTagName('tswee')[0].innerHTML)!=0?true:false;
document.S_form.TSDIR.checked = (this.responseXML.getElementsByTagName('tsdir')[0].innerHTML)!=0?true:false;
document.S_form.TDLAY.value = this.responseXML.getElementsByTagName('tdlay')[0].innerHTML;
document.S_form.TLBRI.value = this.responseXML.getElementsByTagName('tlbri')[0].innerHTML;
document.S_form.TLDUR.value = this.responseXML.getElementsByTagName('tldur')[0].innerHTML;
document.S_form.TLFDE.checked = (this.responseXML.getElementsByTagName('tlfde')[0].innerHTML)!=0?true:false;
document.S_form.NUDPP.value = this.responseXML.getElementsByTagName('nudpp')[0].innerHTML;
document.S_form.NRCVE.checked = (this.responseXML.getElementsByTagName('nrcve')[0].innerHTML)!=0?true:false;
document.S_form.NRBRI.value = this.responseXML.getElementsByTagName('nrbri')[0].innerHTML;
document.S_form.NSDIR.checked = (this.responseXML.getElementsByTagName('nsdir')[0].innerHTML)!=0?true:false;
document.S_form.NSBTN.checked = (this.responseXML.getElementsByTagName('nsbtn')[0].innerHTML)!=0?true:false;
document.S_form.ALEXA.checked = (this.responseXML.getElementsByTagName('alexa')[0].innerHTML)!=0?true:false;
document.S_form.AINVN.value = this.responseXML.getElementsByTagName('ainvn')[0].innerHTML;
document.S_form.NSALX.checked = (this.responseXML.getElementsByTagName('nsalx')[0].innerHTML)!=0?true:false;
document.S_form.NTPON.checked = (this.responseXML.getElementsByTagName('ntpon')[0].innerHTML)!=0?true:false;
document.getElementsByClassName("times")[0].innerHTML = this.responseXML.getElementsByTagName('times')[0].innerHTML;
document.S_form.OLDEF.value = this.responseXML.getElementsByTagName('oldef')[0].innerHTML;
document.S_form.WOFFS.value = this.responseXML.getElementsByTagName('woffs')[0].innerHTML;
document.S_form.WOFFN.checked = (this.responseXML.getElementsByTagName('woffn')[0].innerHTML)!=0?true:false;
document.S_form.NOOTA.checked = (this.responseXML.getElementsByTagName('noota')[0].innerHTML)!=0?true:false;
document.S_form.NORAP.checked = (this.responseXML.getElementsByTagName('norap')[0].innerHTML)!=0?true:false;
document.getElementsByClassName("sip")[0].innerHTML = this.responseXML.getElementsByTagName('sip')[0].innerHTML;
document.getElementsByClassName("sip")[1].innerHTML = this.responseXML.getElementsByTagName('sip')[1].innerHTML;
document.getElementsByClassName("msg")[0].innerHTML = this.responseXML.getElementsByTagName('msg')[0].innerHTML;
}
}
}
}
// send HTTP request
request.open("GET", "/get-settings", true);
request.send(null);
} }
</script> </script>
<style> <style>
@ -87,7 +20,7 @@
</head> </head>
<body onload="GetCurrent()" class=" __plain_text_READY__"> <body onload="GetCurrent()" class=" __plain_text_READY__">
<h1 style="text-align:center">WLED Settings</h1> <h1 style="text-align:center">WLED Settings</h1>
<form id="form_s" name="S_form" action="set-settings" method="post"> <form id="form_s" name="Sf" action="set-settings" method="post">
<div align="center"><input type="submit" name="SUBM" value="Save"></div> <div align="center"><input type="submit" name="SUBM" value="Save"></div>
<hr> <hr>
<h2>WiFi setup</h2> <h2>WiFi setup</h2>
@ -111,6 +44,7 @@
<input name="CSSN3" maxlength="3" size="2"> <br> <input name="CSSN3" maxlength="3" size="2"> <br>
mDNS address (leave empty for no mDNS): <br/> mDNS address (leave empty for no mDNS): <br/>
http:// <input name="CMDNS" maxlength="32"> .local <br> http:// <input name="CMDNS" maxlength="32"> .local <br>
Try connecting before opening AP for: <input name="APWTM" maxlength="3" size="2"> s <br>
Client IP: <span class="sip"> Not connected </span> <br> Client IP: <span class="sip"> Not connected </span> <br>
<h3>Configure Access Point</h3> <h3>Configure Access Point</h3>
AP SSID (leave empty for no AP): <br> <input name="APSSID" maxlength="32"> <br> AP SSID (leave empty for no AP): <br> <input name="APSSID" maxlength="32"> <br>
@ -170,9 +104,10 @@
To enable OTA, for security reasons you need to also enter the correct password! <br> To enable OTA, for security reasons you need to also enter the correct password! <br>
The password may/should be changed when OTA is enabled. <br> The password may/should be changed when OTA is enabled. <br>
Disable OTA when not in use, otherwise an attacker could reflash device software! <br> <br> Disable OTA when not in use, otherwise an attacker could reflash device software! <br> <br>
Disable recovery AP (<i>Not implemented</i>): <input type="checkbox" name="NORAP"> <br> Disable recovery AP: <input type="checkbox" name="NORAP"> <br>
In case of a connection error there will be no wireless recovery possible! <br> In case of a connection error there will be no wireless recovery possible! <br>
Completely disables all Access Point functions. <br> <br> Completely disables all Access Point functions. <br>
Setting only changable if OTA is enabled! <br><br>
Factory reset: <input type="checkbox" name="RESET"> <br> Factory reset: <input type="checkbox" name="RESET"> <br>
All EEPROM content (settings) will be erased. <br> <br> All EEPROM content (settings) will be erased. <br> <br>

File diff suppressed because one or more lines are too long

View File

@ -20,7 +20,7 @@
#include "CallbackFunction.h" #include "CallbackFunction.h"
//version in format yymmddb (b = daily build) //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! //If you have an RGBW strip, uncomment first line in WS2812FX.h!
@ -79,7 +79,8 @@ String cmdns = "led";
String apssid = "WLED-AP"; String apssid = "WLED-AP";
uint8_t apchannel = 1; uint8_t apchannel = 1;
uint8_t aphide = 0; uint8_t aphide = 0;
boolean useap = true; uint8_t apWaitTimeSecs = 32;
boolean recoveryAPDisabled = false;
IPAddress staticip(0, 0, 0, 0); IPAddress staticip(0, 0, 0, 0);
IPAddress staticgateway(0, 0, 0, 0); IPAddress staticgateway(0, 0, 0, 0);
IPAddress staticsubnet(255, 255, 255, 0); IPAddress staticsubnet(255, 255, 255, 0);
@ -93,8 +94,8 @@ uint8_t bri_nl = 0, bri_nls;
boolean fadeTransition = true; boolean fadeTransition = true;
boolean sweepTransition = false; boolean sweepDirection = true; boolean sweepTransition = false; boolean sweepDirection = true;
uint16_t transitionDelay = 1200; uint16_t transitionDelay = 1200;
boolean ota_lock = true; boolean otaLock = true;
boolean only_ap = false; boolean onlyAP = false;
boolean buttonEnabled = true; boolean buttonEnabled = true;
boolean notifyDirect = true, notifyButton = true, notifyDirectDefault = true; boolean notifyDirect = true, notifyButton = true, notifyDirectDefault = true;
boolean receiveNotifications = true, receiveNotificationsDefault = true; boolean receiveNotifications = true, receiveNotificationsDefault = true;
@ -178,7 +179,7 @@ uint8_t auxTime = 0;
unsigned long auxStartTime; unsigned long auxStartTime;
boolean auxActive, auxActiveBefore; boolean auxActive, auxActiveBefore;
boolean useGammaCorrectionBri = true; boolean useGammaCorrectionBri = false;
boolean useGammaCorrectionRGB = true; boolean useGammaCorrectionRGB = true;
int arlsOffset = -22; //10: -22 assuming arls52 int arlsOffset = -22; //10: -22 assuming arls52
boolean realtimeEnabled = true; boolean realtimeEnabled = true;

View File

@ -75,7 +75,7 @@ void saveSettingsToEEPROM()
EEPROM.write(i, otapass.charAt(i-256)); EEPROM.write(i, otapass.charAt(i-256));
} }
EEPROM.write(288, bri_nl); EEPROM.write(288, bri_nl);
EEPROM.write(289, ota_lock); EEPROM.write(289, otaLock);
EEPROM.write(290, (udpPort >> 0) & 0xFF); EEPROM.write(290, (udpPort >> 0) & 0xFF);
EEPROM.write(291, (udpPort >> 8) & 0xFF); EEPROM.write(291, (udpPort >> 8) & 0xFF);
for (int i = 292; i < 324; ++i) for (int i = 292; i < 324; ++i)
@ -105,6 +105,8 @@ void saveSettingsToEEPROM()
EEPROM.write(372, useRGBW); EEPROM.write(372, useRGBW);
EEPROM.write(373, sweepTransition); EEPROM.write(373, sweepTransition);
EEPROM.write(374, sweepDirection); EEPROM.write(374, sweepDirection);
EEPROM.write(375, apWaitTimeSecs);
EEPROM.write(376, recoveryAPDisabled);
EEPROM.commit(); EEPROM.commit();
} }
@ -189,7 +191,7 @@ void loadSettingsFromEEPROM()
otapass += char(EEPROM.read(i)); otapass += char(EEPROM.read(i));
} }
bri_nl = EEPROM.read(288); 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); udpPort = ((EEPROM.read(290) << 0) & 0xFF) + ((EEPROM.read(291) << 8) & 0xFF00);
serverDescription = ""; serverDescription = "";
for (int i = 292; i < 324; ++i) for (int i = 292; i < 324; ++i)
@ -220,5 +222,7 @@ void loadSettingsFromEEPROM()
useRGBW = EEPROM.read(372); useRGBW = EEPROM.read(372);
sweepTransition = EEPROM.read(373); sweepTransition = EEPROM.read(373);
sweepDirection = EEPROM.read(374); sweepDirection = EEPROM.read(374);
apWaitTimeSecs = EEPROM.read(375);
recoveryAPDisabled = EEPROM.read(376);
useHSB = useHSBDefault; useHSB = useHSBDefault;
} }

View File

@ -49,186 +49,119 @@ void XML_response()
server.send(200, "text/xml", resp); server.send(200, "text/xml", resp);
} }
void XML_response_settings() String getSettings()
{ {
DEBUG_PRINTLN("XML settings response"); DEBUG_PRINTLN("settings resp");
String resp;
resp = resp + "<?xml version = \"1.0\" ?>"; String resp = "";
resp = resp + "<vs>"; String ds = "d.Sf.";
resp = resp + "<cssid>"; String dg = "d.getElementsByClassName";
resp = resp + clientssid; String v = ".value=";
resp = resp + "</cssid>"; String c = ".checked=";
resp = resp + "<cpass>"; String ih = ".innerHTML=";
resp += ds + "CSSID" + v + "\"" + clientssid + "\";";
resp += ds + "CPASS" + v + "\"";
for (int i = 0; i < clientpass.length(); i++) for (int i = 0; i < clientpass.length(); i++)
{ {
resp = resp + "*"; resp += "*";
} }
resp = resp + "</cpass>"; resp += "\";";
for (int i = 0; i < 4; i++) 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 + "<csips>"; resp += "*";
resp = resp + staticip[i];
resp = resp + "</csips>";
} }
for (int i = 0; i < 4; i++) resp += "\";";
{ resp += ds + "APCHAN" + v + apchannel +";";
resp = resp + "<csgws>";
resp = resp + staticgateway[i]; resp += ds + "DESC" + v + "\"" + serverDescription + "\";";
resp = resp + "</csgws>"; resp += ds + "COLMD" + c + useHSBDefault + ";";
} resp += ds + "LEDCN" + v + ledcount +";";
for (int i = 0; i < 4; i++) resp += ds + "CLDFR" + v + col_s[0] +";";
{ resp += ds + "CLDFG" + v + col_s[1] +";";
resp = resp + "<cssns>"; resp += ds + "CLDFB" + v + col_s[2] +";";
resp = resp + staticsubnet[i]; resp += ds + "CLDFA" + v + bri_s +";";
resp = resp + "</cssns>";
}
resp = resp + "<cmdns>";
resp = resp + cmdns;
resp = resp + "</cmdns>";
resp = resp + "<apssid>";
resp = resp + apssid;
resp = resp + "</apssid>";
resp = resp + "<aphssid>";
resp = resp + aphide;
resp = resp + "</aphssid>";
resp = resp + "<appass>";
for (int i = 0; i < appass.length(); i++)
{
resp = resp + "*";
}
resp = resp + "</appass>";
resp = resp + "<apchan>";
resp = resp + apchannel;
resp = resp + "</apchan>";
resp = resp + "<desc>";
resp = resp + serverDescription;
resp = resp + "</desc>";
resp = resp + "<colmd>";
resp = resp + useHSBDefault;
resp = resp + "</colmd>";
resp = resp + "<ledcn>";
resp = resp + ledcount;
resp = resp + "</ledcn>";
for (int i = 0; i < 3; i++)
{
resp = resp + "<cldef>";
resp = resp + col_s[i];
resp = resp + "</cldef>";
}
resp = resp + "<cldfw>";
if (useRGBW) { if (useRGBW) {
resp = resp + white_s; resp += ds + "CLDFW" + v + white_s +";";
} else { } else {
resp = resp + "-1"; resp += ds + "CLDFW" + v + "-1;";
} }
resp = resp + "</cldfw><cldfa>"; resp += ds + "BOOTN" + c + turnOnAtBoot +";";
resp = resp + bri_s; resp += ds + "FXDEF" + v + effectDefault +";";
resp = resp + "</cldfa>"; resp += ds + "FXDEF" + v + effectDefault +";";
resp = resp + "<bootn>"; resp += ds + "GCBRI" + c + useGammaCorrectionBri +";";
resp = resp + turnOnAtBoot; resp += ds + "GCRGB" + c + useGammaCorrectionRGB +";";
resp = resp + "</bootn>"; resp += ds + "BTNON" + c + buttonEnabled +";";
resp = resp + "<fxdef>"; resp += ds + "TFADE" + c + fadeTransition +";";
resp = resp + effectDefault; resp += ds + "TSWEE" + c + sweepTransition +";";
resp = resp + "</fxdef>"; resp += ds + "TSDIR" + c + !sweepDirection +";";
resp = resp + "<sxdef>"; resp += ds + "TDLAY" + v + transitionDelay +";";
resp = resp + effectSpeedDefault; resp += ds + "TLBRI" + v + bri_nl +";";
resp = resp + "</sxdef>"; resp += ds + "TLDUR" + v + nightlightDelayMins +";";
resp = resp + "<gcbri>"; resp += ds + "TLFDE" + c + nightlightFade +";";
resp = resp + useGammaCorrectionBri; resp += ds + "NUDPP" + v + udpPort +";";
resp = resp + "</gcbri><gcrgb>"; resp += ds + "NRBRI" + v + bri_n +";";
resp = resp + useGammaCorrectionRGB; resp += ds + "NRCVE" + c + receiveNotificationsDefault +";";
resp = resp + "</gcrgb>"; resp += ds + "NSDIR" + c + notifyDirectDefault +";";
resp = resp + "<btnon>"; resp += ds + "NSBTN" + c + notifyButton +";";
resp = resp + buttonEnabled; resp += ds + "NTPON" + c + ntpEnabled +";";
resp = resp + "</btnon><tfade>"; resp += ds + "ALEXA" + c + alexaEnabled +";";
resp = resp + fadeTransition; resp += ds + "AINVN" + v + "\"" + alexaInvocationName + "\";";
resp = resp + "</tfade><tdlay>"; resp += ds + "NSALX" + c + alexaNotify +";";
resp = resp + transitionDelay; resp += dg + "(\"times\")[0]" + ih + "\"" + getTimeString() + "\";";
resp = resp + "</tdlay><tswee>"; resp += ds + "OLDEF" + v + overlayDefault +";";
resp = resp + sweepTransition; resp += ds + "WOFFS" + v + abs(arlsOffset) +";";
resp = resp + "</tswee><tsdir>"; resp += ds + "WOFFN" + c + !arlsSign +";";
resp = resp + !sweepDirection; resp += ds + "NOOTA" + c + otaLock +";";
resp = resp + "</tsdir><tlbri>"; resp += ds + "NORAP" + c + recoveryAPDisabled +";";
resp = resp + bri_nl; resp += dg + "(\"sip\")[0]" + ih + "\"";
resp = resp + "</tlbri>";
resp = resp + "<tldur>";
resp = resp + nightlightDelayMins;
resp = resp + "</tldur>";
resp = resp + "<tlfde>";
resp = resp + nightlightFade;
resp = resp + "</tlfde>";
resp = resp + "<nudpp>";
resp = resp + udpPort;
resp = resp + "</nudpp>";
resp = resp + "<nrcve>";
resp = resp + receiveNotificationsDefault;
resp = resp + "</nrcve><nrbri>";
resp = resp + bri_n;
resp = resp + "</nrbri><nsdir>";
resp = resp + notifyDirectDefault;
resp = resp + "</nsdir><nsbtn>";
resp = resp + notifyButton;
resp = resp + "</nsbtn><nsfwd>0</nsfwd>"; //legacy
resp = resp + "<ntpon>";
resp = resp + ntpEnabled;
resp = resp + "</ntpon>";
resp = resp + "<alexa>";
resp = resp + alexaEnabled;
resp = resp + "</alexa><ainvn>";
resp = resp + alexaInvocationName;
resp = resp + "</ainvn><nsalx>";
resp = resp + alexaNotify;
resp = resp + "</nsalx>";
DEBUG_PRINTLN("pretime");
resp = resp + "<times>";
resp = resp + getTimeString();
resp = resp + "</times>";
resp = resp + "<oldef>";
resp = resp + overlayDefault;
resp = resp + "</oldef>";
resp = resp + "<woffs>";
resp = resp + abs(arlsOffset);
resp = resp + "</woffs>";
resp = resp + "<woffn>";
resp = resp + !arlsSign;
resp = resp + "</woffn>";
resp = resp + "<noota>";
resp = resp + ota_lock;
resp = resp +"</noota>";
resp = resp + "<norap>0</norap>"; //NI
resp = resp + "<sip>";
if (!WiFi.localIP()[0] == 0) if (!WiFi.localIP()[0] == 0)
{ {
resp = resp + WiFi.localIP()[0]; resp += WiFi.localIP()[0];
resp = resp + "."; resp += + ".";
resp = resp + WiFi.localIP()[1]; resp += WiFi.localIP()[1];
resp = resp + "."; resp += ".";
resp = resp + WiFi.localIP()[2]; resp += WiFi.localIP()[2];
resp = resp + "."; resp += ".";
resp = resp + WiFi.localIP()[3]; resp += WiFi.localIP()[3];
} else } else
{ {
resp = resp + "Not connected"; resp += "Not connected";
} }
resp = resp + "</sip><sip>"; resp += "\";";
resp += dg + "(\"sip\")[1]" + ih + "\"";
if (!WiFi.softAPIP()[0] == 0) if (!WiFi.softAPIP()[0] == 0)
{ {
resp = resp + WiFi.softAPIP()[0]; resp += WiFi.softAPIP()[0];
resp = resp + "."; resp += + ".";
resp = resp + WiFi.softAPIP()[1]; resp += WiFi.softAPIP()[1];
resp = resp + "."; resp += ".";
resp = resp + WiFi.softAPIP()[2]; resp += WiFi.softAPIP()[2];
resp = resp + "."; resp += ".";
resp = resp + WiFi.softAPIP()[3]; resp += WiFi.softAPIP()[3];
} else } else
{ {
resp = resp + "Not active"; resp += "Not active";
} }
resp = resp + "</sip>"; resp += "\";";
resp = resp + "<msg>WLED 0.4p (build "; resp += dg + "(\"msg\")[0]" + ih + "\"WLED 0.4p (build " + VERSION + ") OK\";";
resp = resp + VERSION;
resp = resp + ") OK</msg>"; return resp;
resp = resp + "</vs>";
DEBUG_PRINTLN(resp);
server.send(200, "text/xml", resp);
} }

View File

@ -14,14 +14,13 @@ void handleSettingsSet()
} }
} }
if (server.hasArg("CMDNS")) cmdns = server.arg("CMDNS"); if (server.hasArg("CMDNS")) cmdns = server.arg("CMDNS");
if (server.hasArg("APSSID")) apssid = server.arg("APSSID"); if (server.hasArg("APWTM"))
if (server.hasArg("APHSSID"))
{ {
aphide = 1; int i = server.arg("APWTM").toInt();
} else if (i >= 0 && i <= 255) apWaitTimeSecs = i;
{
aphide = 0;
} }
if (server.hasArg("APSSID")) apssid = server.arg("APSSID");
aphide = server.hasArg("APHSSID");
if (server.hasArg("APPASS")) if (server.hasArg("APPASS"))
{ {
if (!server.arg("APPASS").indexOf('*') == 0) appass = server.arg("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 if (server.hasArg("RESET")) //might be dangerous in case arg is always sent
{ {
clearEEPROM(); 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(); reset();
} }
if (server.hasArg("CSIP0")) if (server.hasArg("CSIP0"))
@ -218,7 +217,7 @@ void handleSettingsSet()
} }
if (server.hasArg("OPASS")) if (server.hasArg("OPASS"))
{ {
if (!ota_lock) if (!otaLock)
{ {
if (server.arg("OPASS").length() > 0) if (server.arg("OPASS").length() > 0)
otapass = server.arg("OPASS"); otapass = server.arg("OPASS");
@ -226,11 +225,16 @@ void handleSettingsSet()
{ {
if (otapass.equals(server.arg("OPASS"))) 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(); saveSettingsToEEPROM();
} }
@ -238,11 +242,6 @@ boolean handleSet(String req)
{ {
boolean effectUpdated = false; boolean effectUpdated = false;
if (!(req.indexOf("win") >= 0)) { if (!(req.indexOf("win") >= 0)) {
if (req.indexOf("get-settings") >= 0)
{
XML_response_settings();
return true;
}
return false; return false;
} }
int pos = 0; int pos = 0;

View File

@ -55,7 +55,7 @@ void wledInit()
DEBUG_PRINTLN(WiFi.localIP()); DEBUG_PRINTLN(WiFi.localIP());
// Set up mDNS responder: // 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!"); DEBUG_PRINTLN("Error setting up MDNS responder!");
down(); down();
} }
@ -71,7 +71,12 @@ void wledInit()
//SERVER INIT //SERVER INIT
//settings page //settings page
server.on("/settings", HTTP_GET, [](){ 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, [](){ server.on("/favicon.ico", HTTP_GET, [](){
if(!handleFileRead("/favicon.ico")) server.send(200, "image/x-icon", favicon); 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); if(!handleFileRead("/index.htm")) server.send(200, "text/html", PAGE_index);
}); });
server.on("/reset", HTTP_GET, [](){ 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(); reset();
}); });
server.on("/set-settings", HTTP_POST, [](){ server.on("/set-settings", HTTP_POST, [](){
@ -96,7 +101,7 @@ void wledInit()
server.on("/freeheap", HTTP_GET, [](){ server.on("/freeheap", HTTP_GET, [](){
server.send(200, "text/plain", (String)ESP.getFreeHeap()); server.send(200, "text/plain", (String)ESP.getFreeHeap());
}); });
if (!ota_lock){ if (!otaLock){
server.on("/edit", HTTP_GET, [](){ server.on("/edit", HTTP_GET, [](){
if(!handleFileRead("/edit.htm")) server.send(200, "text/html", PAGE_edit); if(!handleFileRead("/edit.htm")) server.send(200, "text/html", PAGE_edit);
}); });
@ -168,12 +173,12 @@ void initCon()
delay(500); delay(500);
DEBUG_PRINTLN("C_NC"); DEBUG_PRINTLN("C_NC");
fail_count++; fail_count++;
if (fail_count > 32) if (!recoveryAPDisabled && fail_count > apWaitTimeSecs*2)
{ {
WiFi.disconnect(); WiFi.disconnect();
DEBUG_PRINTLN("Can't connect to network. Opening AP..."); DEBUG_PRINTLN("Can't connect. Opening AP...");
String save = apssid; String save = apssid;
only_ap = true; onlyAP = true;
if (apssid.length() <1) apssid = "WLED-AP"; if (apssid.length() <1) apssid = "WLED-AP";
initAP(); initAP();
apssid = save; apssid = save;