diff --git a/wled00/data/settings_sec.htm b/wled00/data/settings_sec.htm index 155f9e46..4e3a0556 100644 Binary files a/wled00/data/settings_sec.htm and b/wled00/data/settings_sec.htm differ diff --git a/wled00/htmls01.h b/wled00/htmls01.h index 1aa1141a..a96a681d 100644 --- a/wled00/htmls01.h +++ b/wled00/htmls01.h @@ -353,6 +353,7 @@ Enable ArduinoOTA:
WLED version 0.7.1

Contributors:
StormPie (Mobile HTML UI)

+Thank you so much!

(c) 2016-2018 Christian Schwinne
Licensed under the MIT license

Uses libraries:
@@ -360,6 +361,7 @@ StormPie (Mobile HTML UI)

(ESP32) WebServer_tng by bbx10
WS2812FX by kitesurfer1404 (modified)
Timezone library by JChristensen
+Blynk library (compacted)
Espalexa by Aircoookie (modified)

UI icons by Linearicons created by Perxis! (CC-BY-SA 4.0)

Server message: Response error!
diff --git a/wled00/wled00.ino b/wled00/wled00.ino index 2bf18c50..2b6b0343 100644 --- a/wled00/wled00.ino +++ b/wled00/wled00.ino @@ -38,12 +38,12 @@ #include "src/dependencies/blynk/BlynkSimpleEsp.h" //version in format yymmddb (b = daily build) -#define VERSION 1807201 +#define VERSION 1807211 char versionString[] = "0.7.1"; //AP and OTA default passwords (change them!) -String apPass[65] = "wled1234"; -String otaPass[33] = "wledota"; +char apPass[65] = "wled1234"; +char otaPass[33] = "wledota"; //spiffs FS only useful for debug (only ESP8266) //#define USEFS @@ -59,14 +59,14 @@ byte auxDefaultState = 0; //0: input 1: high 2: low byte auxTriggeredState = 0; //0: input 1: high 2: low //Default CONFIG -String serverDescription = "WLED Light"; +char serverDescription[33] = "WLED Light"; byte currentTheme = 0; byte uiConfiguration = 0; //0: auto 1: classic 2: mobile -String clientSSID = "Your_Network"; -String clientPass = ""; -String cmDNS = "led"; +char clientSSID[33] = "Your_Network"; +char clientPass[65] = ""; +char cmDNS[33] = "led"; uint16_t ledCount = 10; //lowered to prevent accidental overcurrent -String apSSID = ""; //AP off by default (unless setup) +char apSSID[65] = ""; //AP off by default (unless setup) byte apChannel = 1; byte apHide = 0; byte apWaitTimeSecs = 32; @@ -104,7 +104,7 @@ byte effectSpeedDefault = 75; byte effectIntensityDefault = 128; //NTP stuff bool ntpEnabled = false; -String ntpServerName = "0.wled.pool.ntp.org"; +char ntpServerName[] = "0.wled.pool.ntp.org"; //custom chase byte ccNumPrimary = 2; byte ccNumSecondary = 4; @@ -116,7 +116,7 @@ byte ccStart = 0; //alexa bool alexaEnabled = true; -String alexaInvocationName = "Light"; +char alexaInvocationName[33] = "Light"; byte macroBoot = 0, macroNl = 0; byte macroAlexaOn = 0, macroAlexaOff = 0; @@ -127,7 +127,7 @@ unsigned long countdownTime = 1514764800L; //hue bool huePollingEnabled = false, hueAttempt = false; uint16_t huePollIntervalMs = 2500; -String hueApiKey = "api"; +char hueApiKey[65] = "api"; byte huePollLightId = 1; IPAddress hueIP = (0,0,0,0); bool notifyHue = true; @@ -171,8 +171,8 @@ byte effectSpeed = 75; byte effectIntensity = 128; bool onlyAP = false; bool udpConnected = false, udpRgbConnected = false; -String cssCol[]={"","","","","",""}; -String cssFont="Verdana"; +char cssCol[9][5]={"","","","","",""}; +char cssFont[33]="Verdana"; String cssColorString=""; //NTP stuff bool ntpConnected = false; @@ -181,7 +181,7 @@ time_t local = 0; int utcOffsetSecs = 0; //hue -String hueError = "Inactive"; +char hueError[25] = "Inactive"; uint16_t hueFailCount = 0; float hueXLast=0, hueYLast=0; uint16_t hueHueLast=0, hueCtLast=0; @@ -190,7 +190,7 @@ long hueLastRequestSent = 0; uint32_t huePollIntervalMsTemp = huePollIntervalMs; //blynk -String blynkApiKey = ""; +char blynkApiKey[36] = ""; bool blynkEnabled = false; //overlay stuff @@ -211,7 +211,7 @@ bool nixiePause; byte countdownYear=19, countdownMonth=1, countdownDay=1, countdownHour=0, countdownMin=0, countdownSec=0; //year is actual year -2000 bool countdownOverTriggered = true; //cronixie -String cronixieDisplay = "HHMMSS"; +char cronixieDisplay[] = "HHMMSS"; byte dP[]{0,0,0,0,0,0}; bool useAMPM = false; bool cronixieBacklight = true; @@ -242,7 +242,6 @@ int arlsOffset = -22; //10: -22 assuming arls52 WiFiUDP UDP; IPAddress ipMulti(239, 255, 255, 250); unsigned int portMulti = 1900; -char packetBuffer[255]; String escapedMac; //dns server diff --git a/wled00/wled01_eeprom.ino b/wled00/wled01_eeprom.ino index 0046d851..74ff413c 100644 --- a/wled00/wled01_eeprom.ino +++ b/wled00/wled01_eeprom.ino @@ -38,23 +38,23 @@ void saveSettingsToEEPROM() for (int i = 0; i < 32; ++i) { - EEPROM.write(i, clientSSID.charAt(i)); + EEPROM.write(i, clientSSID[i]); } for (int i = 32; i < 96; ++i) { - EEPROM.write(i, clientPass.charAt(i-32)); + EEPROM.write(i, clientPass[i-32]); } for (int i = 96; i < 128; ++i) { - EEPROM.write(i, cmDNS.charAt(i-96)); + EEPROM.write(i, cmDNS[i-96]); } for (int i = 128; i < 160; ++i) { - EEPROM.write(i, apSSID.charAt(i-128)); + EEPROM.write(i, apSSID[i-128]); } for (int i = 160; i < 224; ++i) { - EEPROM.write(i, apPass.charAt(i-160)); + EEPROM.write(i, apPass[i-160]); } EEPROM.write(224, nightlightDelayMins); EEPROM.write(225, nightlightFade); @@ -66,18 +66,12 @@ void saveSettingsToEEPROM() EEPROM.write(231, notifyTwice); EEPROM.write(232, buttonEnabled); //233 reserved for first boot flag - EEPROM.write(234, staticIP[0]); - EEPROM.write(235, staticIP[1]); - EEPROM.write(236, staticIP[2]); - EEPROM.write(237, staticIP[3]); - EEPROM.write(238, staticGateway[0]); - EEPROM.write(239, staticGateway[1]); - EEPROM.write(240, staticGateway[2]); - EEPROM.write(241, staticGateway[3]); - EEPROM.write(242, staticSubnet[0]); - EEPROM.write(243, staticSubnet[1]); - EEPROM.write(244, staticSubnet[2]); - EEPROM.write(245, staticSubnet[3]); + for (int i = 0; i<4; i++) //ip addresses + { + EEPROM.write(234+i, staticIP[i]); + EEPROM.write(238+i, staticGateway[i]); + EEPROM.write(242+i, staticSubnet[i]); + } EEPROM.write(246, colS[0]); EEPROM.write(247, colS[1]); EEPROM.write(248, colS[2]); @@ -91,7 +85,7 @@ void saveSettingsToEEPROM() //255,250,231,230,226 notifier bytes for (int i = 256; i < 288; ++i) { - EEPROM.write(i, otaPass.charAt(i-256)); + EEPROM.write(i, otaPass[i-256]); } EEPROM.write(288, nightlightTargetBri); EEPROM.write(289, otaLock); @@ -99,7 +93,7 @@ void saveSettingsToEEPROM() EEPROM.write(291, (udpPort >> 8) & 0xFF); for (int i = 292; i < 324; ++i) { - EEPROM.write(i, serverDescription.charAt(i-292)); + EEPROM.write(i, serverDescription[i-292]); } EEPROM.write(324, effectDefault); EEPROM.write(325, effectSpeedDefault); @@ -113,7 +107,7 @@ void saveSettingsToEEPROM() EEPROM.write(333, alexaEnabled); for (int i = 334; i < 366; ++i) { - EEPROM.write(i, alexaInvocationName.charAt(i-334)); + EEPROM.write(i, alexaInvocationName[i-334]); } EEPROM.write(366, alexaNotify); EEPROM.write(367, (arlsOffset>=0)); @@ -154,13 +148,13 @@ void saveSettingsToEEPROM() int in = 900+k*8; for (int i=in; i < in+8; ++i) { - EEPROM.write(i, cssCol[k].charAt(i-in)); + EEPROM.write(i, cssCol[i-in][k]); }} EEPROM.write(948,currentTheme); for (int i = 950; i < 982; ++i) { - EEPROM.write(i, cssFont.charAt(i-950)); + EEPROM.write(i, cssFont[i-950]); } EEPROM.write(2048, huePollingEnabled); @@ -171,7 +165,7 @@ void saveSettingsToEEPROM() } for (int i = 2054; i < 2100; ++i) { - EEPROM.write(i, hueApiKey.charAt(i-2054)); + EEPROM.write(i, hueApiKey[i-2054]); } EEPROM.write(2100, (huePollIntervalMs >> 0) & 0xFF); EEPROM.write(2101, (huePollIntervalMs >> 8) & 0xFF); @@ -197,7 +191,7 @@ void saveSettingsToEEPROM() for (int i = 2165; i < 2171; ++i) { - EEPROM.write(i, cronixieDisplay.charAt(i-2165)); + EEPROM.write(i, cronixieDisplay[i-2165]); } EEPROM.write(2171, cronixieBacklight); setCronixie(); @@ -231,7 +225,7 @@ void saveSettingsToEEPROM() for (int i = 2220; i < 2255; ++i) { - EEPROM.write(i, blynkApiKey.charAt(i-2220)); + EEPROM.write(i, blynkApiKey[i-2220]); } EEPROM.commit(); @@ -247,35 +241,34 @@ void loadSettingsFromEEPROM(bool first) } int lastEEPROMversion = EEPROM.read(377); //last EEPROM version before update - clientSSID = ""; for (int i = 0; i < 32; ++i) { - if (EEPROM.read(i) == 0) break; - clientSSID += char(EEPROM.read(i)); + clientSSID[i] = EEPROM.read(i); + if (clientSSID[i] == 0) break; } - clientPass = ""; + for (int i = 32; i < 96; ++i) { - if (EEPROM.read(i) == 0) break; - clientPass += char(EEPROM.read(i)); + clientPass[i-32] = EEPROM.read(i); + if (clientPass[i-32] == 0) break; } - cmDNS = ""; + for (int i = 96; i < 128; ++i) { - if (EEPROM.read(i) == 0) break; - cmDNS += char(EEPROM.read(i)); + cmDNS[i-96] = EEPROM.read(i); + if (cmDNS[i-96] == 0) break; } - apSSID = ""; + for (int i = 128; i < 160; ++i) { - if (EEPROM.read(i) == 0) break; - apSSID += char(EEPROM.read(i)); + apSSID[i-128] = EEPROM.read(i); + if (apSSID[i-128] == 0) break; } - apPass = ""; + for (int i = 160; i < 224; ++i) { - if (EEPROM.read(i) == 0) break; - apPass += char(EEPROM.read(i)); + apPass[i-160] = EEPROM.read(i); + if (apPass[i-160] == 0) break; } nightlightDelayMins = EEPROM.read(224); nightlightFade = EEPROM.read(225); @@ -315,20 +308,20 @@ void loadSettingsFromEEPROM(bool first) transitionDelayDefault = ((EEPROM.read(253) << 0) & 0xFF) + ((EEPROM.read(254) << 8) & 0xFF00); transitionDelay = transitionDelayDefault; briMultiplier = EEPROM.read(255); - otaPass = ""; + for (int i = 256; i < 288; ++i) { - if (EEPROM.read(i) == 0) break; - otaPass += char(EEPROM.read(i)); + otaPass[i-256] = EEPROM.read(i); + if (otaPass[i-256] == 0) break; } nightlightTargetBri = EEPROM.read(288); otaLock = EEPROM.read(289); udpPort = ((EEPROM.read(290) << 0) & 0xFF) + ((EEPROM.read(291) << 8) & 0xFF00); - serverDescription = ""; + for (int i = 292; i < 324; ++i) { - if (EEPROM.read(i) == 0) break; - serverDescription += char(EEPROM.read(i)); + serverDescription[i-292] = EEPROM.read(i); + if (serverDescription[i-292] == 0) break; } effectDefault = EEPROM.read(324); effectCurrent = effectDefault; effectSpeedDefault = EEPROM.read(325); effectSpeed = effectSpeedDefault; @@ -339,11 +332,11 @@ void loadSettingsFromEEPROM(bool first) useGammaCorrectionRGB = EEPROM.read(331); overlayDefault = EEPROM.read(332); alexaEnabled = EEPROM.read(333); - alexaInvocationName = ""; + for (int i = 334; i < 366; ++i) { - if (EEPROM.read(i) == 0) break; - alexaInvocationName += char(EEPROM.read(i)); + alexaInvocationName[i-334] = EEPROM.read(i); + if (alexaInvocationName[i-334] == 0) break; } alexaNotify = EEPROM.read(366); arlsOffset = EEPROM.read(368); @@ -378,11 +371,11 @@ void loadSettingsFromEEPROM(bool first) aOtaEnabled = EEPROM.read(390); receiveNotificationColor = EEPROM.read(391); receiveNotificationEffects = EEPROM.read(392); - cssFont = ""; + for (int i = 950; i < 982; ++i) { - if (EEPROM.read(i) == 0) break; - cssFont += char(EEPROM.read(i)); + cssFont[i-950] = EEPROM.read(i); + if (cssFont[i-950] == 0) break; } } else //keep receiving notification behavior from pre0.5.0 after update { @@ -397,11 +390,11 @@ void loadSettingsFromEEPROM(bool first) { hueIP[i-2050] = EEPROM.read(i); } - hueApiKey = ""; + for (int i = 2054; i < 2100; ++i) { - if (EEPROM.read(i) == 0) break; - hueApiKey += char(EEPROM.read(i)); + hueApiKey[i-2054] = EEPROM.read(i); + if (hueApiKey[i-2054] == 0) break; } huePollIntervalMs = ((EEPROM.read(2100) << 0) & 0xFF) + ((EEPROM.read(2101) << 8) & 0xFF00); notifyHue = EEPROM.read(2102); @@ -425,11 +418,9 @@ void loadSettingsFromEEPROM(bool first) countdownSec = EEPROM.read(2161); setCountdown(); - cronixieDisplay = ""; for (int i = 2165; i < 2171; ++i) { - if (EEPROM.read(i) == 0) break; - cronixieDisplay += char(EEPROM.read(i)); + cronixieDisplay[i-2165] = EEPROM.read(i); } cronixieBacklight = EEPROM.read(2171); @@ -464,11 +455,10 @@ void loadSettingsFromEEPROM(bool first) presetApplyFx = EEPROM.read(2212); } - blynkApiKey = ""; for (int i = 2220; i < 2255; ++i) { - if (EEPROM.read(i) == 0) break; - blynkApiKey += char(EEPROM.read(i)); + blynkApiKey[i-2220] = EEPROM.read(i); + if (blynkApiKey[i-2220] == 0) break; } bootPreset = EEPROM.read(389); @@ -487,7 +477,7 @@ void loadSettingsFromEEPROM(bool first) for (int i=in; i < in+8; ++i) { if (EEPROM.read(i) == 0) break; - cssCol[k] += char(EEPROM.read(i)); + cssCol[i-in][k] =EEPROM.read(i); }} //custom macro memory (16 slots/ each 64byte) diff --git a/wled00/wled02_xml.ino b/wled00/wled02_xml.ino index 31592a98..93568ec4 100644 --- a/wled00/wled02_xml.ino +++ b/wled00/wled02_xml.ino @@ -48,7 +48,7 @@ void XML_response() oappend(""); oappendi(useHSB); oappend(""); - oappend((char*)serverDescription.c_str()); + oappend(serverDescription); oappend(""); server.send(200, "text/xml", obuf); } @@ -107,9 +107,9 @@ void getSettingsJS(byte subPage) //get values for settings form in javascript if (subPage <1 || subPage >6) return; if (subPage == 1) { - sappend('s',"CS",(int)clientSSID.c_str()); + sappend('s',"CS",(int)clientSSID); - byte l = clientPass.length(); + byte l = strlen(clientPass); char fpass[l+1]; //fill password field with *** fpass[l] = 0; memset(fpass,'*',l); @@ -124,12 +124,12 @@ void getSettingsJS(byte subPage) //get values for settings form in javascript k[0] = 'S'; sappend('v',k,staticSubnet[i]); } - sappend('s',"CM",(int)cmDNS.c_str()); + sappend('s',"CM",(int)cmDNS); sappend('v',"AT",apWaitTimeSecs); - sappend('s',"AS",(int)apSSID.c_str()); + sappend('s',"AS",(int)apSSID); sappend('c',"AH",apHide); - l = apPass.length(); + l = strlen(apPass); char fapass[l+1]; //fill password field with *** fapass[l] = 0; memset(fapass,'*',l); @@ -139,7 +139,10 @@ void getSettingsJS(byte subPage) //get values for settings form in javascript if (WiFi.localIP()[0] != 0) //is connected { - sappend('m',"(\"sip\")[0]",(int)WiFi.localIP().toString().c_str()); + char s[16]; + IPAddress localIP = WiFi.localIP(); + sprintf(s, "%d.%d.%d.%d", localIP[0], localIP[1], localIP[2], localIP[3]); + sappend('m',"(\"sip\")[0]",(int)s); } else { sappend('m',"(\"sip\")[0]",(int)"Not connected"); @@ -147,7 +150,10 @@ void getSettingsJS(byte subPage) //get values for settings form in javascript if (WiFi.softAPIP()[0] != 0) //is active { - sappend('m',"(\"sip\")[1]",(int)WiFi.softAPIP().toString().c_str()); + char s[16]; + IPAddress apIP = WiFi.softAPIP(); + sprintf(s, "%d.%d.%d.%d", apIP[0], apIP[1], apIP[2], apIP[3]); + sappend('m',"(\"sip\")[1]",(int)apIP); } else { sappend('m',"(\"sip\")[1]",(int)"Not active"); @@ -192,16 +198,16 @@ void getSettingsJS(byte subPage) //get values for settings form in javascript if (subPage == 3) { sappend('i',"UI",uiConfiguration); - sappend('s',"DS",(int)serverDescription.c_str()); + sappend('s',"DS",(int)serverDescription); sappend('c',"MD",useHSBDefault); sappend('i',"TH",currentTheme); char k[3]; k[0] = 'C'; k[2] = 0; //keys for (int i=0; i<6; i++) { k[1] = 48+i; //ascii 0,1,2,3,4,5 - sappend('s',k,(int)cssCol[i].c_str()); + sappend('s',k,(int)cssCol[i]); } - sappend('s',"CF",(int)cssFont.c_str()); + sappend('s',"CF",(int)cssFont); } if (subPage == 4) @@ -218,7 +224,7 @@ void getSettingsJS(byte subPage) //get values for settings form in javascript sappend('c',"RD",receiveDirect); sappend('c',"RU",enableRealtimeUI); sappend('c',"AL",alexaEnabled); - sappend('s',"AI",(int)alexaInvocationName.c_str()); + sappend('s',"AI",(int)alexaInvocationName); sappend('c',"SA",alexaNotify); sappend('s',"BK",(int)((blynkEnabled)?"Hidden":"")); sappend('v',"H0",hueIP[0]); @@ -231,7 +237,7 @@ void getSettingsJS(byte subPage) //get values for settings form in javascript sappend('c',"HO",hueApplyOnOff); sappend('c',"HB",hueApplyBri); sappend('c',"HC",hueApplyColor); - sappend('m',"(\"hms\")[0]",(int)hueError.c_str()); + sappend('m',"(\"hms\")[0]",(int)hueError); } if (subPage == 5) @@ -247,7 +253,7 @@ void getSettingsJS(byte subPage) //get values for settings form in javascript sappend('v',"OM",analogClock12pixel); sappend('c',"OS",analogClockSecondsTrail); sappend('c',"O5",analogClock5MinuteMarks); - sappend('s',"CX",(int)cronixieDisplay.c_str()); + sappend('s',"CX",(int)cronixieDisplay); sappend('c',"CB",cronixieBacklight); sappend('c',"CE",countdownMode); sappend('v',"CY",countdownYear); diff --git a/wled00/wled03_set.ino b/wled00/wled03_set.ino index a0ebaddf..9ddacbfc 100644 --- a/wled00/wled03_set.ino +++ b/wled00/wled03_set.ino @@ -21,91 +21,44 @@ void handleSettingsSet(byte subPage) //WIFI SETTINGS if (subPage == 1) { - if (server.hasArg("CS")) clientSSID = server.arg("CS"); + if (server.hasArg("CS")) strcpy(clientSSID,server.arg("CS").c_str()); if (server.hasArg("CP")) { if (!server.arg("CP").indexOf('*') == 0) { - DEBUG_PRINTLN("Setting pass"); - clientPass = server.arg("CP"); + strcpy(clientPass,server.arg("CP").c_str()); } } - if (server.hasArg("CM")) cmDNS = server.arg("CM"); + if (server.hasArg("CM")) strcpy(cmDNS,server.arg("CM").c_str()); if (server.hasArg("AT")) { int i = server.arg("AT").toInt(); if (i >= 0 && i <= 255) apWaitTimeSecs = i; } - if (server.hasArg("AS")) apSSID = server.arg("AS"); + if (server.hasArg("AS")) strcpy(apSSID,server.arg("AS").c_str()); apHide = server.hasArg("AH"); if (server.hasArg("AP")) { - if (!server.arg("AP").indexOf('*') == 0) apPass = server.arg("AP"); + if (server.arg("AP").charAt(0) != '*') strcpy(apPass,server.arg("AP").c_str()); } if (server.hasArg("AC")) { int chan = server.arg("AC").toInt(); if (chan > 0 && chan < 14) apChannel = chan; } - if (server.hasArg("I0")) + char k[3]; k[2] = 0; int j = 0; + for (int i = 0; i<4; i++) { - int i = server.arg("I0").toInt(); - if (i >= 0 && i <= 255) staticIP[0] = i; - } - if (server.hasArg("I1")) - { - int i = server.arg("I1").toInt(); - if (i >= 0 && i <= 255) staticIP[1] = i; - } - if (server.hasArg("I2")) - { - int i = server.arg("I2").toInt(); - if (i >= 0 && i <= 255) staticIP[2] = i; - } - if (server.hasArg("I3")) - { - int i = server.arg("I3").toInt(); - if (i >= 0 && i <= 255) staticIP[3] = i; - } - if (server.hasArg("G0")) - { - int i = server.arg("G0").toInt(); - if (i >= 0 && i <= 255) staticGateway[0] = i; - } - if (server.hasArg("G1")) - { - int i = server.arg("G1").toInt(); - if (i >= 0 && i <= 255) staticGateway[1] = i; - } - if (server.hasArg("G2")) - { - int i = server.arg("G2").toInt(); - if (i >= 0 && i <= 255) staticGateway[2] = i; - } - if (server.hasArg("G3")) - { - int i = server.arg("G3").toInt(); - if (i >= 0 && i <= 255) staticGateway[3] = i; - } - if (server.hasArg("S0")) - { - int i = server.arg("S0").toInt(); - if (i >= 0 && i <= 255) staticSubnet[0] = i; - } - if (server.hasArg("S1")) - { - int i = server.arg("S1").toInt(); - if (i >= 0 && i <= 255) staticSubnet[1] = i; - } - if (server.hasArg("S2")) - { - int i = server.arg("S2").toInt(); - if (i >= 0 && i <= 255) staticSubnet[2] = i; - } - if (server.hasArg("S3")) - { - int i = server.arg("S3").toInt(); - if (i >= 0 && i <= 255) staticSubnet[3] = i; + k[1] = i+48; + k[0] = 'I'; //static IP + if (server.hasArg(k)) j = server.arg(k).toInt(); + if (j >= 0 && j <= 255) staticIP[i] = j; + k[0] = 'G'; //gateway + if (server.hasArg(k)) j = server.arg(k).toInt(); + if (j >= 0 && j <= 255) staticGateway[i] = j; + k[0] = 'S'; //subnet + if (server.hasArg(k)) j = server.arg(k).toInt(); + if (j >= 0 && j <= 255) staticSubnet[i] = j; } } @@ -245,15 +198,17 @@ void handleSettingsSet(byte subPage) if (subPage == 3) { if (server.hasArg("UI")) uiConfiguration = server.arg("UI").toInt(); - if (server.hasArg("DS")) serverDescription = server.arg("DS"); + if (server.hasArg("DS")) strcpy(serverDescription,server.arg("DS").c_str()); useHSBDefault = server.hasArg("MD"); useHSB = useHSBDefault; if (server.hasArg("TH")) currentTheme = server.arg("TH").toInt(); + char k[3]; k[0]='C'; k[2]=0; for(int i=0;i<6;i++) { - if (server.hasArg("C"+String(i))) cssCol[i] = server.arg("C"+String(i)); + k[1] = i+48; + if (server.hasArg(k)) strcpy(cssCol[i],server.arg(k).c_str()); } - if (server.hasArg("CF")) cssFont = server.arg("CF"); + if (server.hasArg("CF")) strcpy(cssFont,server.arg("CF").c_str()); buildCssColorString(); } @@ -276,9 +231,9 @@ void handleSettingsSet(byte subPage) receiveDirect = server.hasArg("RD"); enableRealtimeUI = server.hasArg("RU"); alexaEnabled = server.hasArg("AL"); - if (server.hasArg("AI")) alexaInvocationName = server.arg("AI"); + if (server.hasArg("AI")) strcpy(alexaInvocationName,server.arg("AI").c_str()); alexaNotify = server.hasArg("SA"); - if (server.hasArg("BK") && !server.arg("BK").equals("Hidden")) {blynkApiKey = server.arg("BK"); initBlynk(blynkApiKey.c_str());} + if (server.hasArg("BK") && !server.arg("BK").equals("Hidden")) {strcpy(blynkApiKey,server.arg("BK").c_str()); initBlynk(blynkApiKey);} notifyHue = server.hasArg("SH"); for (int i=0;i<4;i++){ String a = "H"+String(i); @@ -305,7 +260,7 @@ void handleSettingsSet(byte subPage) } else { huePollingEnabled = false; - hueError = "Inactive"; + strcpy(hueError,"Inactive"); } } @@ -329,7 +284,7 @@ void handleSettingsSet(byte subPage) analogClock5MinuteMarks = server.hasArg("O5"); analogClockSecondsTrail = server.hasArg("OS"); - if (server.hasArg("CX")) cronixieDisplay = server.arg("CX"); + if (server.hasArg("CX")) strcpy(cronixieDisplay,server.arg("CX").c_str()); bool cbOld = cronixieBacklight; cronixieBacklight = server.hasArg("CB"); if (cbOld != cronixieBacklight && overlayCurrent == 4) @@ -371,13 +326,13 @@ void handleSettingsSet(byte subPage) bool pwdCorrect = !otaLock; //always allow access if ota not locked if (server.hasArg("OP")) { - if (otaLock && otaPass.equals(server.arg("OP"))) + if (otaLock && strcmp(otaPass,server.arg("OP").c_str()) == 0) { pwdCorrect = true; } if (!otaLock && server.arg("OP").length() > 0) { - otaPass = server.arg("OP"); + strcpy(otaPass,server.arg("OP").c_str()); } } @@ -788,7 +743,7 @@ bool handleSet(String req) //cronixie pos = req.indexOf("NX="); //sets digits to code if (pos > 0) { - cronixieDisplay = req.substring(pos + 3, pos + 9); + strcpy(cronixieDisplay,req.substring(pos + 3, pos + 9).c_str()); setCronixie(); } pos = req.indexOf("NM="); //mode, 1 countdown diff --git a/wled00/wled05_init.ino b/wled00/wled05_init.ino index 9b58affe..dea81ad8 100644 --- a/wled00/wled05_init.ino +++ b/wled00/wled05_init.ino @@ -49,7 +49,7 @@ void wledInit() ntpConnected = ntpUdp.begin(ntpLocalPort); //start captive portal - if (onlyAP || apSSID.length() > 0) + if (onlyAP || strlen(apSSID) > 0) { dnsServer.setErrorReplyCode(DNSReplyCode::NoError); dnsServer.start(53, "*", WiFi.softAPIP()); @@ -245,21 +245,21 @@ void wledInit() #endif DEBUG_PRINTLN("Start ArduinoOTA"); }); - if (cmDNS.length() > 0) ArduinoOTA.setHostname(cmDNS.c_str()); + if (strlen(cmDNS) > 0) ArduinoOTA.setHostname(cmDNS); ArduinoOTA.begin(); } if (!initLedsLast) strip.service(); // Set up mDNS responder: - if (cmDNS.length() > 0 && !onlyAP) + if (strlen(cmDNS) > 0 && !onlyAP) { - MDNS.begin(cmDNS.c_str()); + MDNS.begin(cmDNS); DEBUG_PRINTLN("mDNS responder started"); // Add service to MDNS MDNS.addService("http", "tcp", 80); } - initBlynk(blynkApiKey.c_str()); + initBlynk(blynkApiKey); if (initLedsLast) initStrip(); userBegin(); @@ -286,10 +286,10 @@ void initStrip() } void initAP(){ - String save = apSSID; - if (apSSID.length() <1) apSSID = "WLED-AP"; - WiFi.softAP(apSSID.c_str(), apPass.c_str(), apChannel, apHide); - apSSID = save; + bool set = apSSID[0]; + if (!set) strcpy(apSSID,"WLED-AP"); + WiFi.softAP(apSSID, apPass, apChannel, apHide); + if (!set) apSSID[0] = 0; } void initCon() @@ -304,10 +304,10 @@ void initCon() WiFi.config(0U, 0U, 0U); } - if (apSSID.length()>0) + if (strlen(apSSID)>0) { DEBUG_PRINT("USING AP"); - DEBUG_PRINTLN(apSSID.length()); + DEBUG_PRINTLN(strlen(apSSID)); initAP(); } else { @@ -315,13 +315,13 @@ void initCon() WiFi.softAPdisconnect(true); } int fail_count = 0; - if (clientSSID.length() <1 || clientSSID.equals("Your_Network")) fail_count = apWaitTimeSecs*2; + if (strlen(clientSSID) <1 || strcmp(clientSSID,"Your_Network") == 0) fail_count = apWaitTimeSecs*2; //instantly go to ap mode #ifndef ARDUINO_ARCH_ESP32 WiFi.hostname(serverDescription); #endif - WiFi.begin(clientSSID.c_str(), clientPass.c_str()); + WiFi.begin(clientSSID, clientPass); #ifdef ARDUINO_ARCH_ESP32 - WiFi.setHostname(serverDescription.c_str()); + WiFi.setHostname(serverDescription); #endif unsigned long lastTry = 0; bool con = false; diff --git a/wled00/wled10_ntp.ino b/wled00/wled10_ntp.ino index 30eba409..61e0c7f6 100644 --- a/wled00/wled10_ntp.ino +++ b/wled00/wled10_ntp.ino @@ -72,8 +72,7 @@ void handleNetworkTime() void sendNTPPacket() { - const char* ntpsrv = ntpServerName.c_str(); - WiFi.hostByName(ntpsrv, ntpServerIP); + WiFi.hostByName(ntpServerName, ntpServerIP); DEBUG_PRINTLN("send NTP packet"); memset(ntpPacketBuffer, 0, NTP_PACKET_SIZE); diff --git a/wled00/wled12_alexa.ino b/wled00/wled12_alexa.ino index 1c0fedb6..8297edad 100644 --- a/wled00/wled12_alexa.ino +++ b/wled00/wled12_alexa.ino @@ -27,14 +27,13 @@ void handleAlexa() int packetSize = UDP.parsePacket(); if(packetSize>0) { IPAddress remote = UDP.remoteIP(); - int len = UDP.read(packetBuffer, 254); + int len = UDP.read(obuf, 254); if (len > 0) { - packetBuffer[len] = 0; + obuf[len] = 0; } - String request = packetBuffer; - if(request.indexOf("M-SEARCH") >= 0) { - if(request.indexOf("upnp:rootdevice") > 0 || request.indexOf("device:basic:1") > 0) { + if(strstr(obuf,"M-SEARCH") > 0) { + if(strstr(obuf,"upnp:rootdevice") > 0 || strstr(obuf,"device:basic:1") > 0) { DEBUG_PRINTLN("Responding search req..."); respondToSearch(); } @@ -246,14 +245,14 @@ bool handleAlexaApiCall(String req, String body) //basic implementation of Phili if (req.indexOf("lights/1") > 0) //client wants light info { DEBUG_PRINTLN("l1"); - server.send(200, "application/json", "{\"manufacturername\":\"OpenSource\",\"modelid\":\"LST001\",\"name\":\""+ alexaInvocationName +"\",\"state\":{\"on\":"+ boolString(bri) +",\"hue\":0,\"bri\":"+ briForHue(bri) +",\"sat\":0,\"xy\":[0.00000,0.00000],\"ct\":500,\"alert\":\"none\",\"effect\":\"none\",\"colormode\":\"hs\",\"reachable\":true},\"swversion\":\"0.1\",\"type\":\"Extended color light\",\"uniqueid\":\"2\"}"); + server.send(200, "application/json", "{\"manufacturername\":\"OpenSource\",\"modelid\":\"LST001\",\"name\":\""+ String(alexaInvocationName) +"\",\"state\":{\"on\":"+ boolString(bri) +",\"hue\":0,\"bri\":"+ briForHue(bri) +",\"sat\":0,\"xy\":[0.00000,0.00000],\"ct\":500,\"alert\":\"none\",\"effect\":\"none\",\"colormode\":\"hs\",\"reachable\":true},\"swversion\":\"0.1\",\"type\":\"Extended color light\",\"uniqueid\":\"2\"}"); return true; } if (req.indexOf("lights") > 0) //client wants all lights { DEBUG_PRINTLN("lAll"); - server.send(200, "application/json", "{\"1\":{\"type\":\"Extended color light\",\"manufacturername\":\"OpenSource\",\"swversion\":\"0.1\",\"name\":\""+ alexaInvocationName +"\",\"uniqueid\":\""+ WiFi.macAddress() +"-2\",\"modelid\":\"LST001\",\"state\":{\"on\":"+ boolString(bri) +",\"bri\":"+ briForHue(bri) +",\"xy\":[0.00000,0.00000],\"colormode\":\"hs\",\"effect\":\"none\",\"ct\":500,\"hue\":0,\"sat\":0,\"alert\":\"none\",\"reachable\":true}}}"); + server.send(200, "application/json", "{\"1\":{\"type\":\"Extended color light\",\"manufacturername\":\"OpenSource\",\"swversion\":\"0.1\",\"name\":\""+ String(alexaInvocationName) +"\",\"uniqueid\":\""+ WiFi.macAddress() +"-2\",\"modelid\":\"LST001\",\"state\":{\"on\":"+ boolString(bri) +",\"bri\":"+ briForHue(bri) +",\"xy\":[0.00000,0.00000],\"colormode\":\"hs\",\"effect\":\"none\",\"ct\":500,\"hue\":0,\"sat\":0,\"alert\":\"none\",\"reachable\":true}}}"); return true; } diff --git a/wled00/wled13_cronixie.ino b/wled00/wled13_cronixie.ino index f1dea952..ae31072a 100644 --- a/wled00/wled13_cronixie.ino +++ b/wled00/wled13_cronixie.ino @@ -1,13 +1,13 @@ /* * Support for the Cronixie clock */ -byte getSameCodeLength(char code, int index, char const digits[]) +byte getSameCodeLength(char code, int index, char const cronixieDisplay[]) { byte counter = 0; for (int i = index+1; i < 6; i++) { - if (digits[i] == code) + if (cronixieDisplay[i] == code) { counter++; } else { @@ -19,7 +19,6 @@ byte getSameCodeLength(char code, int index, char const digits[]) void setCronixie() { - char digits[6]; for (int a=0;a<6;a++) digits[a]=cronixieDisplay.charAt(a); /* * digit purpose index * 0-9 | 0-9 (incl. random) @@ -84,14 +83,14 @@ void setCronixie() //D Day of Week | DD Day Of Month | DDD Day Of Year DEBUG_PRINT("cset "); - DEBUG_PRINTLN(digits); + DEBUG_PRINTLN(cronixieDisplay); overlayRefreshMs = 1997; //Only refresh every 2secs if no seconds are displayed for (int i = 0; i < 6; i++) { dP[i] = 10; - switch (digits[i]) + switch (cronixieDisplay[i]) { case '_': dP[i] = 10; break; case '-': dP[i] = 11; break; @@ -99,24 +98,24 @@ void setCronixie() case 'R': dP[i] = random(0,10); break; //random btw. 0-9 case 't': break; //Test upw. case 'T': break; //Test dnw. - case 'b': dP[i] = 14 + getSameCodeLength('b',i,digits); i = i+dP[i]-14; break; - case 'B': dP[i] = 14 + getSameCodeLength('B',i,digits); i = i+dP[i]-14; break; - case 'h': dP[i] = 70 + getSameCodeLength('h',i,digits); i = i+dP[i]-70; break; - case 'H': dP[i] = 20 + getSameCodeLength('H',i,digits); i = i+dP[i]-20; break; + case 'b': dP[i] = 14 + getSameCodeLength('b',i,cronixieDisplay); i = i+dP[i]-14; break; + case 'B': dP[i] = 14 + getSameCodeLength('B',i,cronixieDisplay); i = i+dP[i]-14; break; + case 'h': dP[i] = 70 + getSameCodeLength('h',i,cronixieDisplay); i = i+dP[i]-70; break; + case 'H': dP[i] = 20 + getSameCodeLength('H',i,cronixieDisplay); i = i+dP[i]-20; break; case 'A': dP[i] = 108; i++; break; case 'a': dP[i] = 58; i++; break; - case 'm': dP[i] = 74 + getSameCodeLength('m',i,digits); i = i+dP[i]-74; break; - case 'M': dP[i] = 24 + getSameCodeLength('M',i,digits); i = i+dP[i]-24; break; - case 's': dP[i] = 80 + getSameCodeLength('s',i,digits); i = i+dP[i]-80; overlayRefreshMs = 497; break; //refresh more often bc. of secs - case 'S': dP[i] = 30 + getSameCodeLength('S',i,digits); i = i+dP[i]-30; overlayRefreshMs = 497; break; - case 'Y': dP[i] = 36 + getSameCodeLength('Y',i,digits); i = i+dP[i]-36; break; - case 'y': dP[i] = 86 + getSameCodeLength('y',i,digits); i = i+dP[i]-86; break; - case 'I': dP[i] = 39 + getSameCodeLength('I',i,digits); i = i+dP[i]-39; break; //Month. Don't ask me why month and minute both start with M. - case 'i': dP[i] = 89 + getSameCodeLength('i',i,digits); i = i+dP[i]-89; break; + case 'm': dP[i] = 74 + getSameCodeLength('m',i,cronixieDisplay); i = i+dP[i]-74; break; + case 'M': dP[i] = 24 + getSameCodeLength('M',i,cronixieDisplay); i = i+dP[i]-24; break; + case 's': dP[i] = 80 + getSameCodeLength('s',i,cronixieDisplay); i = i+dP[i]-80; overlayRefreshMs = 497; break; //refresh more often bc. of secs + case 'S': dP[i] = 30 + getSameCodeLength('S',i,cronixieDisplay); i = i+dP[i]-30; overlayRefreshMs = 497; break; + case 'Y': dP[i] = 36 + getSameCodeLength('Y',i,cronixieDisplay); i = i+dP[i]-36; break; + case 'y': dP[i] = 86 + getSameCodeLength('y',i,cronixieDisplay); i = i+dP[i]-86; break; + case 'I': dP[i] = 39 + getSameCodeLength('I',i,cronixieDisplay); i = i+dP[i]-39; break; //Month. Don't ask me why month and minute both start with M. + case 'i': dP[i] = 89 + getSameCodeLength('i',i,cronixieDisplay); i = i+dP[i]-89; break; case 'W': break; case 'w': break; - case 'D': dP[i] = 43 + getSameCodeLength('D',i,digits); i = i+dP[i]-43; break; - case 'd': dP[i] = 93 + getSameCodeLength('d',i,digits); i = i+dP[i]-93; break; + case 'D': dP[i] = 43 + getSameCodeLength('D',i,cronixieDisplay); i = i+dP[i]-43; break; + case 'd': dP[i] = 93 + getSameCodeLength('d',i,cronixieDisplay); i = i+dP[i]-93; break; case '0': dP[i] = 0; break; case '1': dP[i] = 1; break; case '2': dP[i] = 2; break; diff --git a/wled00/wled15_hue.ino b/wled00/wled15_hue.ino index 68793d20..b7f56545 100644 --- a/wled00/wled15_hue.ino +++ b/wled00/wled15_hue.ino @@ -17,18 +17,18 @@ bool setupHue() { if (WiFi.status() == WL_CONNECTED) //setup needed { - if (hueApiKey.length()>20) //api key is probably ok + if (strlen(hueApiKey)>20) //api key is probably ok { if (sendHuePoll(false)) { huePollingEnabled = true; return true; } - if (hueError.charAt(0) == 'R' || hueError.charAt(0) == 'I') return false; //can't connect + if (hueError[0] == 'R' || hueError[0] == 'I') return false; //can't connect delay(20); } sendHuePoll(true); //new API key - if (hueError.charAt(0) != 'C') return false; //still some error + if (hueError[0] != 'C') return false; //still some error delay(20); if (sendHuePoll(false)) { @@ -60,7 +60,7 @@ bool sendHuePoll(bool sAuth) if (httpCode>0){ st = handleHueResponse(hueClient.getString(),sAuth); } else { - hueError = "Request timed out"; + strcpy(hueError,"Request timed out"); st = false; } if (!st){ //error @@ -81,10 +81,13 @@ bool handleHueResponse(String hueResp, bool isAuth) int hueErrorCode = getJsonValue(&hueResp,"type").toInt(); switch (hueErrorCode) { - case 1: hueError = "Unauthorized"; break; - case 3: hueError = "Invalid light ID"; break; - case 101: hueError = "Link button not pressed"; break; - default: hueError = "Bridge Error " + String(hueErrorCode); + case 1: strcpy(hueError,"Unauthorized"); break; + case 3: strcpy(hueError,"Invalid light ID"); break; + case 101: strcpy(hueError,"Link button not pressed"); break; + default: + char coerr[18]; + sprintf(coerr,"Bridge Error %i",hueErrorCode); + strcpy(hueError,coerr); } return false; } @@ -94,10 +97,10 @@ bool handleHueResponse(String hueResp, bool isAuth) String tempApi = getJsonValue(&hueResp,"username"); if (tempApi.length()>0) { - hueApiKey = tempApi; + strcpy(hueApiKey,tempApi.c_str()); return true; } - hueError = "Invalid response"; + strcpy(hueError,"Invalid response"); return false; } @@ -157,7 +160,7 @@ bool handleHueResponse(String hueResp, bool isAuth) } hueFailCount = 0; huePollIntervalMsTemp = huePollIntervalMs; - hueError = "Connected"; + strcpy(hueError,"Connected"); //applying vals if (hueBri != hueBriLast) {