replace StrContains and num functions
settings html now contains all fields planned for v0.3
This commit is contained in:
parent
d190964b95
commit
9baf2f3eb8
1
TODO.txt
1
TODO.txt
@ -12,7 +12,6 @@ do not reboot after settings set -> add reboot button
|
|||||||
svg icons in html
|
svg icons in html
|
||||||
notifier function -> send get request
|
notifier function -> send get request
|
||||||
nightlight function -> turns off after set time (+implement fading)
|
nightlight function -> turns off after set time (+implement fading)
|
||||||
(replace StrContains and num functions)
|
|
||||||
add preferred colors to settings -> quickly t. UI, button select,
|
add preferred colors to settings -> quickly t. UI, button select,
|
||||||
|
|
||||||
BUGS
|
BUGS
|
||||||
|
@ -104,14 +104,25 @@
|
|||||||
<h3>Transitions</h3>
|
<h3>Transitions</h3>
|
||||||
Fade: <input type="checkbox" name="TFADE" value="0"> <br>
|
Fade: <input type="checkbox" name="TFADE" value="0"> <br>
|
||||||
Transition Delay: <input type="text" name="TDLAY" maxlength="5" size="2"> ms <br>
|
Transition Delay: <input type="text" name="TDLAY" maxlength="5" size="2"> ms <br>
|
||||||
|
<h3>Timed light</h3>
|
||||||
|
Turn off after: <input type="text" name="TLDUR" maxlength="3" size="2"> min <br>
|
||||||
|
Fade down: <input type="checkbox" name="TLFDE" value="0"> <br>
|
||||||
<h3>Daisy chain</h3>
|
<h3>Daisy chain</h3>
|
||||||
<i>Not implemented</i> <br>
|
Receive notifications: <input type="checkbox" name="NRCVE" value="0"> <br>
|
||||||
|
Received brightness factor: <input type="text" name="NRBRI" maxlength="3" size="2"> % <br><br>
|
||||||
|
Send notifications on direct change: <input type="checkbox" name="NSDIR" value="0"> <br>
|
||||||
|
Send notifications on button press: <input type="checkbox" name="NSBTN" value="0"> <br>
|
||||||
|
Send received notifications: <input type="checkbox" name="NSRCV" value="0"> <br>
|
||||||
|
Hosts to send notifications to: (1 IP per line) <br>
|
||||||
|
<textarea name="NSIPS" rows="8" cols="16"></textarea>
|
||||||
<h3>Security</h3>
|
<h3>Security</h3>
|
||||||
Disable OTA: <input type="checkbox" name="NOOTA" value="0"> <br>
|
OTA enabled: <input type="checkbox" name="NOOTA" value="0"> <br>
|
||||||
ArduinoOTA and the edit page will be inaccessible until a SPIFFS reflash! <br>
|
Passphrase: <input type="password" name="OPASS" maxlength="32"> <br>
|
||||||
Checking this is advised for added security if you don't need software changes. <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>
|
||||||
|
Disable OTA when not in use, otherwise an attacker could reflash device software! <br>
|
||||||
Current status: <span class="otastat"> Unknown </span> <br> <br>
|
Current status: <span class="otastat"> Unknown </span> <br> <br>
|
||||||
Disable recovery AP: <input type="checkbox" name="NORAP" value="0"> <br>
|
Disable recovery AP (<i>Not implemented</i>): <input type="checkbox" name="NORAP" value="0"> <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> <br>
|
||||||
Factory reset: <input type="checkbox" name="RESET" value="0"> <br>
|
Factory reset: <input type="checkbox" name="RESET" value="0"> <br>
|
||||||
|
@ -48,8 +48,6 @@ boolean buttonPressedBefore = false;
|
|||||||
|
|
||||||
NeoPixelBus<NeoGrbFeature, NeoEsp8266Uart800KbpsMethod> strip(led_amount, 1);
|
NeoPixelBus<NeoGrbFeature, NeoEsp8266Uart800KbpsMethod> strip(led_amount, 1);
|
||||||
|
|
||||||
char HTTP_req[150];
|
|
||||||
|
|
||||||
ESP8266WebServer server(80);
|
ESP8266WebServer server(80);
|
||||||
ESP8266HTTPUpdateServer httpUpdater;
|
ESP8266HTTPUpdateServer httpUpdater;
|
||||||
|
|
||||||
@ -319,48 +317,6 @@ void XML_response_settings()
|
|||||||
server.send(200, "text/xml", resp);
|
server.send(200, "text/xml", resp);
|
||||||
}
|
}
|
||||||
|
|
||||||
char StrContains(char *str, char *sfind)
|
|
||||||
{
|
|
||||||
char found = 0;
|
|
||||||
char index = 0;
|
|
||||||
char len;
|
|
||||||
|
|
||||||
len = strlen(str);
|
|
||||||
|
|
||||||
if (strlen(sfind) > len) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
while (index < len) {
|
|
||||||
if (str[index] == sfind[found]) {
|
|
||||||
found++;
|
|
||||||
if (strlen(sfind) == found) {
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
found = 0;
|
|
||||||
}
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
uint8_t getNumberAfterStringPos(char str[], char spos)
|
|
||||||
{
|
|
||||||
String op;
|
|
||||||
boolean no_n = false;
|
|
||||||
int i = 0;
|
|
||||||
while (!no_n) {
|
|
||||||
if (str[spos + i + 1] > 47 && str[spos + i + 1] < 58)
|
|
||||||
{
|
|
||||||
op += str[spos + i + 1];
|
|
||||||
}
|
|
||||||
else {no_n = true;}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
return op.toInt();
|
|
||||||
}
|
|
||||||
|
|
||||||
void handleSettingsSet()
|
void handleSettingsSet()
|
||||||
{
|
{
|
||||||
if (server.hasArg("CSSID")) clientssid = server.arg("CSSID");
|
if (server.hasArg("CSSID")) clientssid = server.arg("CSSID");
|
||||||
@ -473,11 +429,8 @@ void handleSettingsSet()
|
|||||||
|
|
||||||
boolean handleSet(String req)
|
boolean handleSet(String req)
|
||||||
{
|
{
|
||||||
Serial.println("handleSet:");
|
if (!(req.indexOf("ajax_in") >= 0)) {
|
||||||
Serial.println(req);
|
if (req.indexOf("get-settings") >= 0)
|
||||||
req.toCharArray(HTTP_req, 150, 0);
|
|
||||||
if (!StrContains(HTTP_req, "ajax_in")) {
|
|
||||||
if (StrContains(HTTP_req, "get-settings"))
|
|
||||||
{
|
{
|
||||||
XML_response_settings();
|
XML_response_settings();
|
||||||
return true;
|
return true;
|
||||||
@ -485,21 +438,21 @@ boolean handleSet(String req)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
pos = StrContains(HTTP_req, "A=");
|
pos = req.indexOf("A=");
|
||||||
if (pos > 0) {
|
if (pos > 0) {
|
||||||
bri = getNumberAfterStringPos(HTTP_req, pos);
|
bri = req.substring(pos + 2).toInt();
|
||||||
}
|
}
|
||||||
pos = StrContains(HTTP_req, "R=");
|
pos = req.indexOf("R=");
|
||||||
if (pos > 0) {
|
if (pos > 0) {
|
||||||
col[0] = getNumberAfterStringPos(HTTP_req, pos);
|
col[0] = req.substring(pos + 2).toInt();
|
||||||
}
|
}
|
||||||
pos = StrContains(HTTP_req, "G=");
|
pos = req.indexOf("G=");
|
||||||
if (pos > 0) {
|
if (pos > 0) {
|
||||||
col[1] = getNumberAfterStringPos(HTTP_req, pos);
|
col[1] = req.substring(pos + 2).toInt();
|
||||||
}
|
}
|
||||||
pos = StrContains(HTTP_req, "B=");
|
pos = req.indexOf("B=");
|
||||||
if (pos > 0) {
|
if (pos > 0) {
|
||||||
col[2] = getNumberAfterStringPos(HTTP_req, pos);
|
col[2] = req.substring(pos + 2).toInt();
|
||||||
}
|
}
|
||||||
XML_response();
|
XML_response();
|
||||||
colorUpdated();
|
colorUpdated();
|
||||||
@ -708,6 +661,8 @@ void handleAnimations(){};
|
|||||||
|
|
||||||
void handleButton()
|
void handleButton()
|
||||||
{
|
{
|
||||||
|
if (buttonEnabled)
|
||||||
|
{
|
||||||
if (digitalRead(buttonPin) == LOW && !buttonPressedBefore)
|
if (digitalRead(buttonPin) == LOW && !buttonPressedBefore)
|
||||||
{
|
{
|
||||||
buttonPressedBefore = true;
|
buttonPressedBefore = true;
|
||||||
@ -729,6 +684,7 @@ void handleButton()
|
|||||||
buttonPressedBefore = false;
|
buttonPressedBefore = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
Loading…
Reference in New Issue
Block a user