version 0.2

BD release
removed some settings tempoarily
stable?!
This commit is contained in:
cschwinne 2016-09-14 22:32:57 +02:00
parent 5a26df0b94
commit 2a6b481592
4 changed files with 47 additions and 67 deletions

View File

@ -6,9 +6,8 @@ implement all settings setters
implement OTA implement OTA
implement OTA lock implement OTA lock
implement button implement button
implement LED Control (NeoPixelBus?) -- vip
implement HSB slider option implement HSB slider option
implement default color on boot implement default color on boot in settings
change color submit from get to post, rewrite with args, requires no buffer change color submit from get to post, rewrite with args, requires no buffer
change color submit from rgb to hex change color submit from rgb to hex

View File

@ -1,7 +1,6 @@
<!DOCTYPE html> <!DOCTYPE html>
<html><head><meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <html><head><meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>WLED 0.1c</title> <title>WLED 0.2</title>
<!--<meta name="viewport" content="width=device-width, initial-scale=1.5">-->
<script> <script>
strA = ""; strA = "";
strR = ""; strR = "";

View File

@ -15,33 +15,14 @@
if (this.responseXML != null) { if (this.responseXML != null) {
document.Settings_form.CSSID.value = this.responseXML.getElementsByTagName('cssid')[0].innerHTML; document.Settings_form.CSSID.value = this.responseXML.getElementsByTagName('cssid')[0].innerHTML;
document.Settings_form.CPASS.value = this.responseXML.getElementsByTagName('cpass')[0].innerHTML; //fake pass like ****** document.Settings_form.CPASS.value = this.responseXML.getElementsByTagName('cpass')[0].innerHTML; //fake pass like ******
document.Settings_form.CSIP0.value = this.responseXML.getElementsByTagName('csips')[0].innerHTML;
document.Settings_form.CSIP1.value = this.responseXML.getElementsByTagName('csips')[1].innerHTML;
document.Settings_form.CSIP2.value = this.responseXML.getElementsByTagName('csips')[2].innerHTML;
document.Settings_form.CSIP3.value = this.responseXML.getElementsByTagName('csips')[3].innerHTML;
document.Settings_form.CSGW0.value = this.responseXML.getElementsByTagName('csgws')[0].innerHTML;
document.Settings_form.CSGW1.value = this.responseXML.getElementsByTagName('csgws')[1].innerHTML;
document.Settings_form.CSGW2.value = this.responseXML.getElementsByTagName('csgws')[2].innerHTML;
document.Settings_form.CSGW3.value = this.responseXML.getElementsByTagName('csgws')[3].innerHTML;
document.Settings_form.CSSN0.value = this.responseXML.getElementsByTagName('cssns')[0].innerHTML;
document.Settings_form.CSSN1.value = this.responseXML.getElementsByTagName('cssns')[1].innerHTML;
document.Settings_form.CSSN2.value = this.responseXML.getElementsByTagName('cssns')[2].innerHTML;
document.Settings_form.CSSN3.value = this.responseXML.getElementsByTagName('cssns')[3].innerHTML;
document.Settings_form.CMDNS.value = this.responseXML.getElementsByTagName('cmdns')[0].innerHTML; document.Settings_form.CMDNS.value = this.responseXML.getElementsByTagName('cmdns')[0].innerHTML;
document.Settings_form.APSSID.value = this.responseXML.getElementsByTagName('apssid')[0].innerHTML; document.Settings_form.APSSID.value = this.responseXML.getElementsByTagName('apssid')[0].innerHTML;
document.Settings_form.APHSSID.checked = (this.responseXML.getElementsByTagName('aphssid')[0].innerHTML)!=0?true:false; document.Settings_form.APHSSID.checked = (this.responseXML.getElementsByTagName('aphssid')[0].innerHTML)!=0?true:false;
document.Settings_form.APPASS.value = this.responseXML.getElementsByTagName('appass')[0].innerHTML; //fake pass like ****** document.Settings_form.APPASS.value = this.responseXML.getElementsByTagName('appass')[0].innerHTML; //fake pass like ******
document.Settings_form.APCHAN.value = this.responseXML.getElementsByTagName('apchan')[0].innerHTML; document.Settings_form.APCHAN.value = this.responseXML.getElementsByTagName('apchan')[0].innerHTML;
document.Settings_form.LEDS.value = this.responseXML.getElementsByTagName('leds')[0].innerHTML;
document.Settings_form.PWRLED.checked = (this.responseXML.getElementsByTagName('pwrled')[0].innerHTML)!=0?true:false;
document.Settings_form.BTNP.value = this.responseXML.getElementsByTagName('btnp')[0].innerHTML;
document.Settings_form.NOOTA.checked = (this.responseXML.getElementsByTagName('noota')[0].innerHTML)!=0?true:false;
document.Settings_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")[0].innerHTML = this.responseXML.getElementsByTagName('sip')[0].innerHTML;
document.getElementsByClassName("sip")[1].innerHTML = this.responseXML.getElementsByTagName('sip')[1].innerHTML; document.getElementsByClassName("sip")[1].innerHTML = this.responseXML.getElementsByTagName('sip')[1].innerHTML;
document.getElementsByClassName("otastat")[0].innerHTML = this.responseXML.getElementsByTagName('otastat')[0].innerHTML;
document.getElementsByClassName("msg")[0].innerHTML = this.responseXML.getElementsByTagName('msg')[0].innerHTML; document.getElementsByClassName("msg")[0].innerHTML = this.responseXML.getElementsByTagName('msg')[0].innerHTML;
if (Settings_form.NOOTA.checked) {document.Settings_form.NOOTA.disabled="disabled";}
} }
} }
} }
@ -62,6 +43,7 @@
</style> </style>
</head> </head>
<body onload="GetCurrent()" class=" __plain_text_READY__"> <body onload="GetCurrent()" class=" __plain_text_READY__">
Und nein, ich mache die Einstellungsseite nicht Deutsch ;D <br>
<h1>WLED Settings</h1> <h1>WLED Settings</h1>
<form id="form_s" name="Settings_form" action="set-settings" method="post"> <form id="form_s" name="Settings_form" action="set-settings" method="post">
<input type="submit" name="SUBM" value="Save"> <input type="submit" name="SUBM" value="Save">
@ -70,21 +52,6 @@
<h3>Connect to existing network</h3> <h3>Connect to existing network</h3>
Network SSID (leave empty to not connect): <br> <input type="text" name="CSSID" maxlength="32"> <br> Network SSID (leave empty to not connect): <br> <input type="text" name="CSSID" maxlength="32"> <br>
Network password: <br> <input type="password" name="CPASS" maxlength="63"> <br> Network password: <br> <input type="password" name="CPASS" maxlength="63"> <br>
Static IP (leave at 0.0.0.0 for DHCP): <br>
<input type="text" name="CSIP0" maxlength="3" size="2"> .
<input type="text" name="CSIP1" maxlength="3" size="2"> .
<input type="text" name="CSIP2" maxlength="3" size="2"> .
<input type="text" name="CSIP3" maxlength="3" size="2"> <br>
Static gateway: <br>
<input type="text" name="CSGW0" maxlength="3" size="2"> .
<input type="text" name="CSGW1" maxlength="3" size="2"> .
<input type="text" name="CSGW2" maxlength="3" size="2"> .
<input type="text" name="CSGW3" maxlength="3" size="2"> <br>
Static subnet mask: <br>
<input type="text" name="CSSN0" maxlength="3" size="2"> .
<input type="text" name="CSSN1" maxlength="3" size="2"> .
<input type="text" name="CSSN2" maxlength="3" size="2"> .
<input type="text" 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 type="text" name="CMDNS" maxlength="32"> .local <br> http:// <input type="text" name="CMDNS" maxlength="32"> .local <br>
Client IP: <span class="sip"> Not connected </span> <br> Client IP: <span class="sip"> Not connected </span> <br>
@ -97,31 +64,15 @@
<h2>Application setup</h2> <h2>Application setup</h2>
<h3>LED setup</h3> <h3>LED setup</h3>
LED amount: <input type="text" name="LEDS" maxlength="3" size="2"> <br> The default boot LED color is the current color when settings are saved. <br>
Disable Power LED: <input type="checkbox" name="PWRLED" value="0"> <br>
<h3>Button setup</h3>
Button pin: <input type="text" name="BTNP" maxlength="2" size="2"> <br>
Button function: Toggle on/off <br>
<h3>Toolbar</h3>
<i>Not implemented</i> <br>
<h3>Animations</h3>
<i>Not implemented</i> <br>
<h3>Daisy chain</h3>
<i>Not implemented</i> <br>
<h3>Security</h3> <h3>Security</h3>
Disable OTA: <input type="checkbox" name="NOOTA" value="0"> <br>
ArduinoOTA and the edit page will be inaccessible until a SPIFFS reflash! <br>
Checking this is advised for added security if you don't need software changes. <br>
Current status: <span class="otastat"> Unknown </span> <br> <br>
Disable recovery AP: <input type="checkbox" name="NORAP" value="0"> <br>
In case of a connection error there will be no wireless recovery possible! <br>
Completely disables all Access Point functions. <br> <br>
Factory reset: <input type="checkbox" name="RESET" value="0"> <br> Factory reset: <input type="checkbox" name="RESET" value="0"> <br>
All EEPROM content (settings) will be erased. <br> <br> All EEPROM content (settings) will be erased. <br> <br>
HTTP traffic is not encrypted. An attacker in the same network could intercept form data!<br> HTTP traffic is not encrypted. An attacker in the same network could intercept form data!<br>
<h3>About</h3> <h3>About</h3>
WLED version 0.1c <br> WLED version 0.2 <br>
(c) 2016 Christian Schwinne <br>
Server message: <span class="msg"> XML response error! </span> Server message: <span class="msg"> XML response error! </span>
<br><br> <br><br>
<input type="submit" name="SUBM" value="Save"> <input type="submit" name="SUBM" value="Save">

View File

@ -21,10 +21,11 @@ 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);
byte col[]{256, 128, 0}; byte col[]{255, 127, 0};
byte bri = 128; byte bri = 127;
byte hue, sat; byte hue, sat;
boolean ota_lock = false; boolean ota_lock = false;
boolean only_ap = false;
int led_amount = 16; int led_amount = 16;
int nopwrled = 1; int nopwrled = 1;
@ -35,12 +36,16 @@ File fsUploadFile;
void down() void down()
{ {
bri = 0;
setLeds();
Serial.println("MODULE TERMINATED"); Serial.println("MODULE TERMINATED");
while (1) {delay(1000);} while (1) {delay(1000);}
} }
void reset() void reset()
{ {
bri = 0;
setLeds();
Serial.println("MODULE RESET"); Serial.println("MODULE RESET");
ESP.reset(); ESP.reset();
} }
@ -97,6 +102,10 @@ void saveSettingsToEEPROM()
EEPROM.write(243, staticsubnet[1]); EEPROM.write(243, staticsubnet[1]);
EEPROM.write(244, staticsubnet[2]); EEPROM.write(244, staticsubnet[2]);
EEPROM.write(245, staticsubnet[3]); EEPROM.write(245, staticsubnet[3]);
EEPROM.write(246, col[0]);
EEPROM.write(247, col[1]);
EEPROM.write(248, col[2]);
EEPROM.write(249, bri);
EEPROM.commit(); EEPROM.commit();
} }
@ -157,6 +166,10 @@ void loadSettingsFromEEPROM()
staticsubnet[1] = EEPROM.read(243); staticsubnet[1] = EEPROM.read(243);
staticsubnet[2] = EEPROM.read(244); staticsubnet[2] = EEPROM.read(244);
staticsubnet[3] = EEPROM.read(245); staticsubnet[3] = EEPROM.read(245);
col[0] = EEPROM.read(246);
col[1] = EEPROM.read(247);
col[2] = EEPROM.read(248);
bri = EEPROM.read(249);
} }
void XML_response() void XML_response()
@ -270,7 +283,7 @@ void XML_response_settings()
} }
resp = resp + "</sip>"; resp = resp + "</sip>";
resp = resp + "<otastat>Not implemented</otastat>"; resp = resp + "<otastat>Not implemented</otastat>";
resp = resp + "<msg>WLED 0.1c OK</msg>"; resp = resp + "<msg>WLED 0.2 OK</msg>";
resp = resp + "</vs>"; resp = resp + "</vs>";
Serial.println(resp); Serial.println(resp);
server.send(200, "text/xml", resp); server.send(200, "text/xml", resp);
@ -331,10 +344,28 @@ 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("APSSID")) apssid = server.arg("APSSID");
if (server.hasArg("APHSSID"))
{
aphide = 1;
} else
{
aphide = 0;
}
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");
} }
if (server.hasArg("APCHAN"))
{
int chan = server.arg("APCHAN").toInt();
if (chan > 0 && chan < 14) apchannel = chan;
}
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...");
reset();
}
saveSettingsToEEPROM(); saveSettingsToEEPROM();
} }
@ -502,7 +533,7 @@ void setLeds() {
double d = bri; double d = bri;
double val = d /256; double val = d /256;
for (int i=0; i<16; i++) { for (int i=0; i < led_amount; i++) {
strip.SetPixelColor(i, RgbColor(col[0]*val, col[1]*val, col[2]*val)); strip.SetPixelColor(i, RgbColor(col[0]*val, col[1]*val, col[2]*val));
} }
strip.Show(); strip.Show();
@ -534,8 +565,6 @@ void setup() {
Serial.print("CC: SSID: "); Serial.print("CC: SSID: ");
Serial.print(clientssid); Serial.print(clientssid);
Serial.print(" PASS: ");
Serial.println(clientpass);
WiFi.disconnect(); //close old connections WiFi.disconnect(); //close old connections
@ -565,7 +594,7 @@ void setup() {
Serial.println(WiFi.localIP()); Serial.println(WiFi.localIP());
// Set up mDNS responder: // Set up mDNS responder:
if (cmdns != NULL && WL_CONNECTED && !MDNS.begin(cmdns.c_str())) { if (cmdns != NULL && !only_ap && !MDNS.begin(cmdns.c_str())) {
Serial.println("Error setting up MDNS responder!"); Serial.println("Error setting up MDNS responder!");
down(); down();
} }
@ -588,7 +617,7 @@ void setup() {
server.on("/reset", HTTP_GET, reset); server.on("/reset", HTTP_GET, reset);
server.on("/set-settings", HTTP_POST, [](){ server.on("/set-settings", HTTP_POST, [](){
handleSettingsSet(); handleSettingsSet();
server.send(200, "text/plain", "Settings saved. Please wait a minute for module to reset, then go to main page..."); server.send(200, "text/plain", "Settings saved. Please wait for light to turn back on, then go to main page...");
reset(); reset();
}); });
if (!ota_lock){ if (!ota_lock){
@ -641,8 +670,9 @@ void initAP(){
void initCon() void initCon()
{ {
WiFi.begin(clientssid.c_str(), clientpass.c_str());
int fail_count = 0; int fail_count = 0;
if (clientssid.length() <1) fail_count = 33;
WiFi.begin(clientssid.c_str(), clientpass.c_str());
while(WiFi.status() != WL_CONNECTED) { while(WiFi.status() != WL_CONNECTED) {
delay(500); delay(500);
Serial.println("C_NC"); Serial.println("C_NC");
@ -652,7 +682,8 @@ void initCon()
WiFi.disconnect(); WiFi.disconnect();
Serial.println("Can't connect to network. Opening AP..."); Serial.println("Can't connect to network. Opening AP...");
String save = apssid; String save = apssid;
apssid = "WLED-RECOVERY"; only_ap = true;
if (apssid.length() <1) apssid = "WLED-AP";
initAP(); initAP();
apssid = save; apssid = save;
return; return;