Continued optimizing strings
This commit is contained in:
parent
72f203e4fa
commit
415dfd2750
Binary file not shown.
@ -353,6 +353,7 @@ Enable ArduinoOTA: <input type="checkbox" name="AO"><br>
|
|||||||
<a href="https://github.com/Aircoookie/WLED">WLED</a> version 0.7.1<br><br>
|
<a href="https://github.com/Aircoookie/WLED">WLED</a> version 0.7.1<br><br>
|
||||||
<b>Contributors:</b><br>
|
<b>Contributors:</b><br>
|
||||||
StormPie <i>(Mobile HTML UI)</i><br><br>
|
StormPie <i>(Mobile HTML UI)</i><br><br>
|
||||||
|
Thank you so much!<br><br>
|
||||||
(c) 2016-2018 Christian Schwinne <br>
|
(c) 2016-2018 Christian Schwinne <br>
|
||||||
<i>Licensed under the MIT license</i><br><br>
|
<i>Licensed under the MIT license</i><br><br>
|
||||||
<b>Uses libraries:</b><br>
|
<b>Uses libraries:</b><br>
|
||||||
@ -360,6 +361,7 @@ StormPie <i>(Mobile HTML UI)</i><br><br>
|
|||||||
<i>(ESP32) <a href="https://github.com/bbx10/WebServer_tng">WebServer_tng</a> by bbx10</i><br>
|
<i>(ESP32) <a href="https://github.com/bbx10/WebServer_tng">WebServer_tng</a> by bbx10</i><br>
|
||||||
<i><a href="https://github.com/kitesurfer1404/WS2812FX">WS2812FX</a> by kitesurfer1404 (modified)</i><br>
|
<i><a href="https://github.com/kitesurfer1404/WS2812FX">WS2812FX</a> by kitesurfer1404 (modified)</i><br>
|
||||||
<i><a href="https://github.com/JChristensen/Timezone">Timezone</a> library by JChristensen</i><br>
|
<i><a href="https://github.com/JChristensen/Timezone">Timezone</a> library by JChristensen</i><br>
|
||||||
|
<i><a href="https://github.com/blynkkk/blynk-library">Blynk</a> library (compacted)</i><br>
|
||||||
<i><a href="https://github.com/Aircoookie/Espalexa">Espalexa</a> by Aircoookie (modified)</i><br><br>
|
<i><a href="https://github.com/Aircoookie/Espalexa">Espalexa</a> by Aircoookie (modified)</i><br><br>
|
||||||
<i>UI icons by <a href="https://linearicons.com">Linearicons</a> created by <a href="https://perxis.com">Perxis</a>! (CC-BY-SA 4.0)</i> <br><br>
|
<i>UI icons by <a href="https://linearicons.com">Linearicons</a> created by <a href="https://perxis.com">Perxis</a>! (CC-BY-SA 4.0)</i> <br><br>
|
||||||
Server message: <span class="msg"> Response error! </span><hr>
|
Server message: <span class="msg"> Response error! </span><hr>
|
||||||
|
@ -38,12 +38,12 @@
|
|||||||
#include "src/dependencies/blynk/BlynkSimpleEsp.h"
|
#include "src/dependencies/blynk/BlynkSimpleEsp.h"
|
||||||
|
|
||||||
//version in format yymmddb (b = daily build)
|
//version in format yymmddb (b = daily build)
|
||||||
#define VERSION 1807201
|
#define VERSION 1807211
|
||||||
char versionString[] = "0.7.1";
|
char versionString[] = "0.7.1";
|
||||||
|
|
||||||
//AP and OTA default passwords (change them!)
|
//AP and OTA default passwords (change them!)
|
||||||
String apPass[65] = "wled1234";
|
char apPass[65] = "wled1234";
|
||||||
String otaPass[33] = "wledota";
|
char otaPass[33] = "wledota";
|
||||||
|
|
||||||
//spiffs FS only useful for debug (only ESP8266)
|
//spiffs FS only useful for debug (only ESP8266)
|
||||||
//#define USEFS
|
//#define USEFS
|
||||||
@ -59,14 +59,14 @@ byte auxDefaultState = 0; //0: input 1: high 2: low
|
|||||||
byte auxTriggeredState = 0; //0: input 1: high 2: low
|
byte auxTriggeredState = 0; //0: input 1: high 2: low
|
||||||
|
|
||||||
//Default CONFIG
|
//Default CONFIG
|
||||||
String serverDescription = "WLED Light";
|
char serverDescription[33] = "WLED Light";
|
||||||
byte currentTheme = 0;
|
byte currentTheme = 0;
|
||||||
byte uiConfiguration = 0; //0: auto 1: classic 2: mobile
|
byte uiConfiguration = 0; //0: auto 1: classic 2: mobile
|
||||||
String clientSSID = "Your_Network";
|
char clientSSID[33] = "Your_Network";
|
||||||
String clientPass = "";
|
char clientPass[65] = "";
|
||||||
String cmDNS = "led";
|
char cmDNS[33] = "led";
|
||||||
uint16_t ledCount = 10; //lowered to prevent accidental overcurrent
|
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 apChannel = 1;
|
||||||
byte apHide = 0;
|
byte apHide = 0;
|
||||||
byte apWaitTimeSecs = 32;
|
byte apWaitTimeSecs = 32;
|
||||||
@ -104,7 +104,7 @@ byte effectSpeedDefault = 75;
|
|||||||
byte effectIntensityDefault = 128;
|
byte effectIntensityDefault = 128;
|
||||||
//NTP stuff
|
//NTP stuff
|
||||||
bool ntpEnabled = false;
|
bool ntpEnabled = false;
|
||||||
String ntpServerName = "0.wled.pool.ntp.org";
|
char ntpServerName[] = "0.wled.pool.ntp.org";
|
||||||
//custom chase
|
//custom chase
|
||||||
byte ccNumPrimary = 2;
|
byte ccNumPrimary = 2;
|
||||||
byte ccNumSecondary = 4;
|
byte ccNumSecondary = 4;
|
||||||
@ -116,7 +116,7 @@ byte ccStart = 0;
|
|||||||
|
|
||||||
//alexa
|
//alexa
|
||||||
bool alexaEnabled = true;
|
bool alexaEnabled = true;
|
||||||
String alexaInvocationName = "Light";
|
char alexaInvocationName[33] = "Light";
|
||||||
|
|
||||||
byte macroBoot = 0, macroNl = 0;
|
byte macroBoot = 0, macroNl = 0;
|
||||||
byte macroAlexaOn = 0, macroAlexaOff = 0;
|
byte macroAlexaOn = 0, macroAlexaOff = 0;
|
||||||
@ -127,7 +127,7 @@ unsigned long countdownTime = 1514764800L;
|
|||||||
//hue
|
//hue
|
||||||
bool huePollingEnabled = false, hueAttempt = false;
|
bool huePollingEnabled = false, hueAttempt = false;
|
||||||
uint16_t huePollIntervalMs = 2500;
|
uint16_t huePollIntervalMs = 2500;
|
||||||
String hueApiKey = "api";
|
char hueApiKey[65] = "api";
|
||||||
byte huePollLightId = 1;
|
byte huePollLightId = 1;
|
||||||
IPAddress hueIP = (0,0,0,0);
|
IPAddress hueIP = (0,0,0,0);
|
||||||
bool notifyHue = true;
|
bool notifyHue = true;
|
||||||
@ -171,8 +171,8 @@ byte effectSpeed = 75;
|
|||||||
byte effectIntensity = 128;
|
byte effectIntensity = 128;
|
||||||
bool onlyAP = false;
|
bool onlyAP = false;
|
||||||
bool udpConnected = false, udpRgbConnected = false;
|
bool udpConnected = false, udpRgbConnected = false;
|
||||||
String cssCol[]={"","","","","",""};
|
char cssCol[9][5]={"","","","","",""};
|
||||||
String cssFont="Verdana";
|
char cssFont[33]="Verdana";
|
||||||
String cssColorString="";
|
String cssColorString="";
|
||||||
//NTP stuff
|
//NTP stuff
|
||||||
bool ntpConnected = false;
|
bool ntpConnected = false;
|
||||||
@ -181,7 +181,7 @@ time_t local = 0;
|
|||||||
int utcOffsetSecs = 0;
|
int utcOffsetSecs = 0;
|
||||||
|
|
||||||
//hue
|
//hue
|
||||||
String hueError = "Inactive";
|
char hueError[25] = "Inactive";
|
||||||
uint16_t hueFailCount = 0;
|
uint16_t hueFailCount = 0;
|
||||||
float hueXLast=0, hueYLast=0;
|
float hueXLast=0, hueYLast=0;
|
||||||
uint16_t hueHueLast=0, hueCtLast=0;
|
uint16_t hueHueLast=0, hueCtLast=0;
|
||||||
@ -190,7 +190,7 @@ long hueLastRequestSent = 0;
|
|||||||
uint32_t huePollIntervalMsTemp = huePollIntervalMs;
|
uint32_t huePollIntervalMsTemp = huePollIntervalMs;
|
||||||
|
|
||||||
//blynk
|
//blynk
|
||||||
String blynkApiKey = "";
|
char blynkApiKey[36] = "";
|
||||||
bool blynkEnabled = false;
|
bool blynkEnabled = false;
|
||||||
|
|
||||||
//overlay stuff
|
//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
|
byte countdownYear=19, countdownMonth=1, countdownDay=1, countdownHour=0, countdownMin=0, countdownSec=0; //year is actual year -2000
|
||||||
bool countdownOverTriggered = true;
|
bool countdownOverTriggered = true;
|
||||||
//cronixie
|
//cronixie
|
||||||
String cronixieDisplay = "HHMMSS";
|
char cronixieDisplay[] = "HHMMSS";
|
||||||
byte dP[]{0,0,0,0,0,0};
|
byte dP[]{0,0,0,0,0,0};
|
||||||
bool useAMPM = false;
|
bool useAMPM = false;
|
||||||
bool cronixieBacklight = true;
|
bool cronixieBacklight = true;
|
||||||
@ -242,7 +242,6 @@ int arlsOffset = -22; //10: -22 assuming arls52
|
|||||||
WiFiUDP UDP;
|
WiFiUDP UDP;
|
||||||
IPAddress ipMulti(239, 255, 255, 250);
|
IPAddress ipMulti(239, 255, 255, 250);
|
||||||
unsigned int portMulti = 1900;
|
unsigned int portMulti = 1900;
|
||||||
char packetBuffer[255];
|
|
||||||
String escapedMac;
|
String escapedMac;
|
||||||
|
|
||||||
//dns server
|
//dns server
|
||||||
|
@ -38,23 +38,23 @@ void saveSettingsToEEPROM()
|
|||||||
|
|
||||||
for (int i = 0; i < 32; ++i)
|
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)
|
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)
|
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)
|
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)
|
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(224, nightlightDelayMins);
|
||||||
EEPROM.write(225, nightlightFade);
|
EEPROM.write(225, nightlightFade);
|
||||||
@ -66,18 +66,12 @@ void saveSettingsToEEPROM()
|
|||||||
EEPROM.write(231, notifyTwice);
|
EEPROM.write(231, notifyTwice);
|
||||||
EEPROM.write(232, buttonEnabled);
|
EEPROM.write(232, buttonEnabled);
|
||||||
//233 reserved for first boot flag
|
//233 reserved for first boot flag
|
||||||
EEPROM.write(234, staticIP[0]);
|
for (int i = 0; i<4; i++) //ip addresses
|
||||||
EEPROM.write(235, staticIP[1]);
|
{
|
||||||
EEPROM.write(236, staticIP[2]);
|
EEPROM.write(234+i, staticIP[i]);
|
||||||
EEPROM.write(237, staticIP[3]);
|
EEPROM.write(238+i, staticGateway[i]);
|
||||||
EEPROM.write(238, staticGateway[0]);
|
EEPROM.write(242+i, staticSubnet[i]);
|
||||||
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]);
|
|
||||||
EEPROM.write(246, colS[0]);
|
EEPROM.write(246, colS[0]);
|
||||||
EEPROM.write(247, colS[1]);
|
EEPROM.write(247, colS[1]);
|
||||||
EEPROM.write(248, colS[2]);
|
EEPROM.write(248, colS[2]);
|
||||||
@ -91,7 +85,7 @@ void saveSettingsToEEPROM()
|
|||||||
//255,250,231,230,226 notifier bytes
|
//255,250,231,230,226 notifier bytes
|
||||||
for (int i = 256; i < 288; ++i)
|
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(288, nightlightTargetBri);
|
||||||
EEPROM.write(289, otaLock);
|
EEPROM.write(289, otaLock);
|
||||||
@ -99,7 +93,7 @@ void saveSettingsToEEPROM()
|
|||||||
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)
|
||||||
{
|
{
|
||||||
EEPROM.write(i, serverDescription.charAt(i-292));
|
EEPROM.write(i, serverDescription[i-292]);
|
||||||
}
|
}
|
||||||
EEPROM.write(324, effectDefault);
|
EEPROM.write(324, effectDefault);
|
||||||
EEPROM.write(325, effectSpeedDefault);
|
EEPROM.write(325, effectSpeedDefault);
|
||||||
@ -113,7 +107,7 @@ void saveSettingsToEEPROM()
|
|||||||
EEPROM.write(333, alexaEnabled);
|
EEPROM.write(333, alexaEnabled);
|
||||||
for (int i = 334; i < 366; ++i)
|
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(366, alexaNotify);
|
||||||
EEPROM.write(367, (arlsOffset>=0));
|
EEPROM.write(367, (arlsOffset>=0));
|
||||||
@ -154,13 +148,13 @@ void saveSettingsToEEPROM()
|
|||||||
int in = 900+k*8;
|
int in = 900+k*8;
|
||||||
for (int i=in; i < in+8; ++i)
|
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);
|
EEPROM.write(948,currentTheme);
|
||||||
for (int i = 950; i < 982; ++i)
|
for (int i = 950; i < 982; ++i)
|
||||||
{
|
{
|
||||||
EEPROM.write(i, cssFont.charAt(i-950));
|
EEPROM.write(i, cssFont[i-950]);
|
||||||
}
|
}
|
||||||
|
|
||||||
EEPROM.write(2048, huePollingEnabled);
|
EEPROM.write(2048, huePollingEnabled);
|
||||||
@ -171,7 +165,7 @@ void saveSettingsToEEPROM()
|
|||||||
}
|
}
|
||||||
for (int i = 2054; i < 2100; ++i)
|
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(2100, (huePollIntervalMs >> 0) & 0xFF);
|
||||||
EEPROM.write(2101, (huePollIntervalMs >> 8) & 0xFF);
|
EEPROM.write(2101, (huePollIntervalMs >> 8) & 0xFF);
|
||||||
@ -197,7 +191,7 @@ void saveSettingsToEEPROM()
|
|||||||
|
|
||||||
for (int i = 2165; i < 2171; ++i)
|
for (int i = 2165; i < 2171; ++i)
|
||||||
{
|
{
|
||||||
EEPROM.write(i, cronixieDisplay.charAt(i-2165));
|
EEPROM.write(i, cronixieDisplay[i-2165]);
|
||||||
}
|
}
|
||||||
EEPROM.write(2171, cronixieBacklight);
|
EEPROM.write(2171, cronixieBacklight);
|
||||||
setCronixie();
|
setCronixie();
|
||||||
@ -231,7 +225,7 @@ void saveSettingsToEEPROM()
|
|||||||
|
|
||||||
for (int i = 2220; i < 2255; ++i)
|
for (int i = 2220; i < 2255; ++i)
|
||||||
{
|
{
|
||||||
EEPROM.write(i, blynkApiKey.charAt(i-2220));
|
EEPROM.write(i, blynkApiKey[i-2220]);
|
||||||
}
|
}
|
||||||
|
|
||||||
EEPROM.commit();
|
EEPROM.commit();
|
||||||
@ -247,35 +241,34 @@ void loadSettingsFromEEPROM(bool first)
|
|||||||
}
|
}
|
||||||
int lastEEPROMversion = EEPROM.read(377); //last EEPROM version before update
|
int lastEEPROMversion = EEPROM.read(377); //last EEPROM version before update
|
||||||
|
|
||||||
clientSSID = "";
|
|
||||||
for (int i = 0; i < 32; ++i)
|
for (int i = 0; i < 32; ++i)
|
||||||
{
|
{
|
||||||
if (EEPROM.read(i) == 0) break;
|
clientSSID[i] = EEPROM.read(i);
|
||||||
clientSSID += char(EEPROM.read(i));
|
if (clientSSID[i] == 0) break;
|
||||||
}
|
}
|
||||||
clientPass = "";
|
|
||||||
for (int i = 32; i < 96; ++i)
|
for (int i = 32; i < 96; ++i)
|
||||||
{
|
{
|
||||||
if (EEPROM.read(i) == 0) break;
|
clientPass[i-32] = EEPROM.read(i);
|
||||||
clientPass += char(EEPROM.read(i));
|
if (clientPass[i-32] == 0) break;
|
||||||
}
|
}
|
||||||
cmDNS = "";
|
|
||||||
for (int i = 96; i < 128; ++i)
|
for (int i = 96; i < 128; ++i)
|
||||||
{
|
{
|
||||||
if (EEPROM.read(i) == 0) break;
|
cmDNS[i-96] = EEPROM.read(i);
|
||||||
cmDNS += char(EEPROM.read(i));
|
if (cmDNS[i-96] == 0) break;
|
||||||
}
|
}
|
||||||
apSSID = "";
|
|
||||||
for (int i = 128; i < 160; ++i)
|
for (int i = 128; i < 160; ++i)
|
||||||
{
|
{
|
||||||
if (EEPROM.read(i) == 0) break;
|
apSSID[i-128] = EEPROM.read(i);
|
||||||
apSSID += char(EEPROM.read(i));
|
if (apSSID[i-128] == 0) break;
|
||||||
}
|
}
|
||||||
apPass = "";
|
|
||||||
for (int i = 160; i < 224; ++i)
|
for (int i = 160; i < 224; ++i)
|
||||||
{
|
{
|
||||||
if (EEPROM.read(i) == 0) break;
|
apPass[i-160] = EEPROM.read(i);
|
||||||
apPass += char(EEPROM.read(i));
|
if (apPass[i-160] == 0) break;
|
||||||
}
|
}
|
||||||
nightlightDelayMins = EEPROM.read(224);
|
nightlightDelayMins = EEPROM.read(224);
|
||||||
nightlightFade = EEPROM.read(225);
|
nightlightFade = EEPROM.read(225);
|
||||||
@ -315,20 +308,20 @@ void loadSettingsFromEEPROM(bool first)
|
|||||||
transitionDelayDefault = ((EEPROM.read(253) << 0) & 0xFF) + ((EEPROM.read(254) << 8) & 0xFF00);
|
transitionDelayDefault = ((EEPROM.read(253) << 0) & 0xFF) + ((EEPROM.read(254) << 8) & 0xFF00);
|
||||||
transitionDelay = transitionDelayDefault;
|
transitionDelay = transitionDelayDefault;
|
||||||
briMultiplier = EEPROM.read(255);
|
briMultiplier = EEPROM.read(255);
|
||||||
otaPass = "";
|
|
||||||
for (int i = 256; i < 288; ++i)
|
for (int i = 256; i < 288; ++i)
|
||||||
{
|
{
|
||||||
if (EEPROM.read(i) == 0) break;
|
otaPass[i-256] = EEPROM.read(i);
|
||||||
otaPass += char(EEPROM.read(i));
|
if (otaPass[i-256] == 0) break;
|
||||||
}
|
}
|
||||||
nightlightTargetBri = EEPROM.read(288);
|
nightlightTargetBri = EEPROM.read(288);
|
||||||
otaLock = 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 = "";
|
|
||||||
for (int i = 292; i < 324; ++i)
|
for (int i = 292; i < 324; ++i)
|
||||||
{
|
{
|
||||||
if (EEPROM.read(i) == 0) break;
|
serverDescription[i-292] = EEPROM.read(i);
|
||||||
serverDescription += char(EEPROM.read(i));
|
if (serverDescription[i-292] == 0) break;
|
||||||
}
|
}
|
||||||
effectDefault = EEPROM.read(324); effectCurrent = effectDefault;
|
effectDefault = EEPROM.read(324); effectCurrent = effectDefault;
|
||||||
effectSpeedDefault = EEPROM.read(325); effectSpeed = effectSpeedDefault;
|
effectSpeedDefault = EEPROM.read(325); effectSpeed = effectSpeedDefault;
|
||||||
@ -339,11 +332,11 @@ void loadSettingsFromEEPROM(bool first)
|
|||||||
useGammaCorrectionRGB = EEPROM.read(331);
|
useGammaCorrectionRGB = EEPROM.read(331);
|
||||||
overlayDefault = EEPROM.read(332);
|
overlayDefault = EEPROM.read(332);
|
||||||
alexaEnabled = EEPROM.read(333);
|
alexaEnabled = EEPROM.read(333);
|
||||||
alexaInvocationName = "";
|
|
||||||
for (int i = 334; i < 366; ++i)
|
for (int i = 334; i < 366; ++i)
|
||||||
{
|
{
|
||||||
if (EEPROM.read(i) == 0) break;
|
alexaInvocationName[i-334] = EEPROM.read(i);
|
||||||
alexaInvocationName += char(EEPROM.read(i));
|
if (alexaInvocationName[i-334] == 0) break;
|
||||||
}
|
}
|
||||||
alexaNotify = EEPROM.read(366);
|
alexaNotify = EEPROM.read(366);
|
||||||
arlsOffset = EEPROM.read(368);
|
arlsOffset = EEPROM.read(368);
|
||||||
@ -378,11 +371,11 @@ void loadSettingsFromEEPROM(bool first)
|
|||||||
aOtaEnabled = EEPROM.read(390);
|
aOtaEnabled = EEPROM.read(390);
|
||||||
receiveNotificationColor = EEPROM.read(391);
|
receiveNotificationColor = EEPROM.read(391);
|
||||||
receiveNotificationEffects = EEPROM.read(392);
|
receiveNotificationEffects = EEPROM.read(392);
|
||||||
cssFont = "";
|
|
||||||
for (int i = 950; i < 982; ++i)
|
for (int i = 950; i < 982; ++i)
|
||||||
{
|
{
|
||||||
if (EEPROM.read(i) == 0) break;
|
cssFont[i-950] = EEPROM.read(i);
|
||||||
cssFont += char(EEPROM.read(i));
|
if (cssFont[i-950] == 0) break;
|
||||||
}
|
}
|
||||||
} else //keep receiving notification behavior from pre0.5.0 after update
|
} 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);
|
hueIP[i-2050] = EEPROM.read(i);
|
||||||
}
|
}
|
||||||
hueApiKey = "";
|
|
||||||
for (int i = 2054; i < 2100; ++i)
|
for (int i = 2054; i < 2100; ++i)
|
||||||
{
|
{
|
||||||
if (EEPROM.read(i) == 0) break;
|
hueApiKey[i-2054] = EEPROM.read(i);
|
||||||
hueApiKey += char(EEPROM.read(i));
|
if (hueApiKey[i-2054] == 0) break;
|
||||||
}
|
}
|
||||||
huePollIntervalMs = ((EEPROM.read(2100) << 0) & 0xFF) + ((EEPROM.read(2101) << 8) & 0xFF00);
|
huePollIntervalMs = ((EEPROM.read(2100) << 0) & 0xFF) + ((EEPROM.read(2101) << 8) & 0xFF00);
|
||||||
notifyHue = EEPROM.read(2102);
|
notifyHue = EEPROM.read(2102);
|
||||||
@ -425,11 +418,9 @@ void loadSettingsFromEEPROM(bool first)
|
|||||||
countdownSec = EEPROM.read(2161);
|
countdownSec = EEPROM.read(2161);
|
||||||
setCountdown();
|
setCountdown();
|
||||||
|
|
||||||
cronixieDisplay = "";
|
|
||||||
for (int i = 2165; i < 2171; ++i)
|
for (int i = 2165; i < 2171; ++i)
|
||||||
{
|
{
|
||||||
if (EEPROM.read(i) == 0) break;
|
cronixieDisplay[i-2165] = EEPROM.read(i);
|
||||||
cronixieDisplay += char(EEPROM.read(i));
|
|
||||||
}
|
}
|
||||||
cronixieBacklight = EEPROM.read(2171);
|
cronixieBacklight = EEPROM.read(2171);
|
||||||
|
|
||||||
@ -464,11 +455,10 @@ void loadSettingsFromEEPROM(bool first)
|
|||||||
presetApplyFx = EEPROM.read(2212);
|
presetApplyFx = EEPROM.read(2212);
|
||||||
}
|
}
|
||||||
|
|
||||||
blynkApiKey = "";
|
|
||||||
for (int i = 2220; i < 2255; ++i)
|
for (int i = 2220; i < 2255; ++i)
|
||||||
{
|
{
|
||||||
if (EEPROM.read(i) == 0) break;
|
blynkApiKey[i-2220] = EEPROM.read(i);
|
||||||
blynkApiKey += char(EEPROM.read(i));
|
if (blynkApiKey[i-2220] == 0) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
bootPreset = EEPROM.read(389);
|
bootPreset = EEPROM.read(389);
|
||||||
@ -487,7 +477,7 @@ void loadSettingsFromEEPROM(bool first)
|
|||||||
for (int i=in; i < in+8; ++i)
|
for (int i=in; i < in+8; ++i)
|
||||||
{
|
{
|
||||||
if (EEPROM.read(i) == 0) break;
|
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)
|
//custom macro memory (16 slots/ each 64byte)
|
||||||
|
@ -48,7 +48,7 @@ void XML_response()
|
|||||||
oappend("</wv><md>");
|
oappend("</wv><md>");
|
||||||
oappendi(useHSB);
|
oappendi(useHSB);
|
||||||
oappend("</md><ds>");
|
oappend("</md><ds>");
|
||||||
oappend((char*)serverDescription.c_str());
|
oappend(serverDescription);
|
||||||
oappend("</ds></vs>");
|
oappend("</ds></vs>");
|
||||||
server.send(200, "text/xml", obuf);
|
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 || subPage >6) return;
|
||||||
|
|
||||||
if (subPage == 1) {
|
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 ***
|
char fpass[l+1]; //fill password field with ***
|
||||||
fpass[l] = 0;
|
fpass[l] = 0;
|
||||||
memset(fpass,'*',l);
|
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]);
|
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('v',"AT",apWaitTimeSecs);
|
||||||
sappend('s',"AS",(int)apSSID.c_str());
|
sappend('s',"AS",(int)apSSID);
|
||||||
sappend('c',"AH",apHide);
|
sappend('c',"AH",apHide);
|
||||||
|
|
||||||
l = apPass.length();
|
l = strlen(apPass);
|
||||||
char fapass[l+1]; //fill password field with ***
|
char fapass[l+1]; //fill password field with ***
|
||||||
fapass[l] = 0;
|
fapass[l] = 0;
|
||||||
memset(fapass,'*',l);
|
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
|
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
|
} else
|
||||||
{
|
{
|
||||||
sappend('m',"(\"sip\")[0]",(int)"Not connected");
|
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
|
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
|
} else
|
||||||
{
|
{
|
||||||
sappend('m',"(\"sip\")[1]",(int)"Not active");
|
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)
|
if (subPage == 3)
|
||||||
{
|
{
|
||||||
sappend('i',"UI",uiConfiguration);
|
sappend('i',"UI",uiConfiguration);
|
||||||
sappend('s',"DS",(int)serverDescription.c_str());
|
sappend('s',"DS",(int)serverDescription);
|
||||||
sappend('c',"MD",useHSBDefault);
|
sappend('c',"MD",useHSBDefault);
|
||||||
sappend('i',"TH",currentTheme);
|
sappend('i',"TH",currentTheme);
|
||||||
char k[3]; k[0] = 'C'; k[2] = 0; //keys
|
char k[3]; k[0] = 'C'; k[2] = 0; //keys
|
||||||
for (int i=0; i<6; i++)
|
for (int i=0; i<6; i++)
|
||||||
{
|
{
|
||||||
k[1] = 48+i; //ascii 0,1,2,3,4,5
|
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)
|
if (subPage == 4)
|
||||||
@ -218,7 +224,7 @@ void getSettingsJS(byte subPage) //get values for settings form in javascript
|
|||||||
sappend('c',"RD",receiveDirect);
|
sappend('c',"RD",receiveDirect);
|
||||||
sappend('c',"RU",enableRealtimeUI);
|
sappend('c',"RU",enableRealtimeUI);
|
||||||
sappend('c',"AL",alexaEnabled);
|
sappend('c',"AL",alexaEnabled);
|
||||||
sappend('s',"AI",(int)alexaInvocationName.c_str());
|
sappend('s',"AI",(int)alexaInvocationName);
|
||||||
sappend('c',"SA",alexaNotify);
|
sappend('c',"SA",alexaNotify);
|
||||||
sappend('s',"BK",(int)((blynkEnabled)?"Hidden":""));
|
sappend('s',"BK",(int)((blynkEnabled)?"Hidden":""));
|
||||||
sappend('v',"H0",hueIP[0]);
|
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',"HO",hueApplyOnOff);
|
||||||
sappend('c',"HB",hueApplyBri);
|
sappend('c',"HB",hueApplyBri);
|
||||||
sappend('c',"HC",hueApplyColor);
|
sappend('c',"HC",hueApplyColor);
|
||||||
sappend('m',"(\"hms\")[0]",(int)hueError.c_str());
|
sappend('m',"(\"hms\")[0]",(int)hueError);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (subPage == 5)
|
if (subPage == 5)
|
||||||
@ -247,7 +253,7 @@ void getSettingsJS(byte subPage) //get values for settings form in javascript
|
|||||||
sappend('v',"OM",analogClock12pixel);
|
sappend('v',"OM",analogClock12pixel);
|
||||||
sappend('c',"OS",analogClockSecondsTrail);
|
sappend('c',"OS",analogClockSecondsTrail);
|
||||||
sappend('c',"O5",analogClock5MinuteMarks);
|
sappend('c',"O5",analogClock5MinuteMarks);
|
||||||
sappend('s',"CX",(int)cronixieDisplay.c_str());
|
sappend('s',"CX",(int)cronixieDisplay);
|
||||||
sappend('c',"CB",cronixieBacklight);
|
sappend('c',"CB",cronixieBacklight);
|
||||||
sappend('c',"CE",countdownMode);
|
sappend('c',"CE",countdownMode);
|
||||||
sappend('v',"CY",countdownYear);
|
sappend('v',"CY",countdownYear);
|
||||||
|
@ -21,91 +21,44 @@ void handleSettingsSet(byte subPage)
|
|||||||
//WIFI SETTINGS
|
//WIFI SETTINGS
|
||||||
if (subPage == 1)
|
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.hasArg("CP"))
|
||||||
{
|
{
|
||||||
if (!server.arg("CP").indexOf('*') == 0)
|
if (!server.arg("CP").indexOf('*') == 0)
|
||||||
{
|
{
|
||||||
DEBUG_PRINTLN("Setting pass");
|
strcpy(clientPass,server.arg("CP").c_str());
|
||||||
clientPass = server.arg("CP");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (server.hasArg("CM")) cmDNS = server.arg("CM");
|
if (server.hasArg("CM")) strcpy(cmDNS,server.arg("CM").c_str());
|
||||||
if (server.hasArg("AT"))
|
if (server.hasArg("AT"))
|
||||||
{
|
{
|
||||||
int i = server.arg("AT").toInt();
|
int i = server.arg("AT").toInt();
|
||||||
if (i >= 0 && i <= 255) apWaitTimeSecs = i;
|
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");
|
apHide = server.hasArg("AH");
|
||||||
if (server.hasArg("AP"))
|
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"))
|
if (server.hasArg("AC"))
|
||||||
{
|
{
|
||||||
int chan = server.arg("AC").toInt();
|
int chan = server.arg("AC").toInt();
|
||||||
if (chan > 0 && chan < 14) apChannel = chan;
|
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();
|
k[1] = i+48;
|
||||||
if (i >= 0 && i <= 255) staticIP[0] = i;
|
k[0] = 'I'; //static IP
|
||||||
}
|
if (server.hasArg(k)) j = server.arg(k).toInt();
|
||||||
if (server.hasArg("I1"))
|
if (j >= 0 && j <= 255) staticIP[i] = j;
|
||||||
{
|
k[0] = 'G'; //gateway
|
||||||
int i = server.arg("I1").toInt();
|
if (server.hasArg(k)) j = server.arg(k).toInt();
|
||||||
if (i >= 0 && i <= 255) staticIP[1] = i;
|
if (j >= 0 && j <= 255) staticGateway[i] = j;
|
||||||
}
|
k[0] = 'S'; //subnet
|
||||||
if (server.hasArg("I2"))
|
if (server.hasArg(k)) j = server.arg(k).toInt();
|
||||||
{
|
if (j >= 0 && j <= 255) staticSubnet[i] = j;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -245,15 +198,17 @@ void handleSettingsSet(byte subPage)
|
|||||||
if (subPage == 3)
|
if (subPage == 3)
|
||||||
{
|
{
|
||||||
if (server.hasArg("UI")) uiConfiguration = server.arg("UI").toInt();
|
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");
|
useHSBDefault = server.hasArg("MD");
|
||||||
useHSB = useHSBDefault;
|
useHSB = useHSBDefault;
|
||||||
if (server.hasArg("TH")) currentTheme = server.arg("TH").toInt();
|
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++)
|
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();
|
buildCssColorString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -276,9 +231,9 @@ void handleSettingsSet(byte subPage)
|
|||||||
receiveDirect = server.hasArg("RD");
|
receiveDirect = server.hasArg("RD");
|
||||||
enableRealtimeUI = server.hasArg("RU");
|
enableRealtimeUI = server.hasArg("RU");
|
||||||
alexaEnabled = server.hasArg("AL");
|
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");
|
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");
|
notifyHue = server.hasArg("SH");
|
||||||
for (int i=0;i<4;i++){
|
for (int i=0;i<4;i++){
|
||||||
String a = "H"+String(i);
|
String a = "H"+String(i);
|
||||||
@ -305,7 +260,7 @@ void handleSettingsSet(byte subPage)
|
|||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
huePollingEnabled = false;
|
huePollingEnabled = false;
|
||||||
hueError = "Inactive";
|
strcpy(hueError,"Inactive");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -329,7 +284,7 @@ void handleSettingsSet(byte subPage)
|
|||||||
analogClock5MinuteMarks = server.hasArg("O5");
|
analogClock5MinuteMarks = server.hasArg("O5");
|
||||||
analogClockSecondsTrail = server.hasArg("OS");
|
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;
|
bool cbOld = cronixieBacklight;
|
||||||
cronixieBacklight = server.hasArg("CB");
|
cronixieBacklight = server.hasArg("CB");
|
||||||
if (cbOld != cronixieBacklight && overlayCurrent == 4)
|
if (cbOld != cronixieBacklight && overlayCurrent == 4)
|
||||||
@ -371,13 +326,13 @@ void handleSettingsSet(byte subPage)
|
|||||||
bool pwdCorrect = !otaLock; //always allow access if ota not locked
|
bool pwdCorrect = !otaLock; //always allow access if ota not locked
|
||||||
if (server.hasArg("OP"))
|
if (server.hasArg("OP"))
|
||||||
{
|
{
|
||||||
if (otaLock && otaPass.equals(server.arg("OP")))
|
if (otaLock && strcmp(otaPass,server.arg("OP").c_str()) == 0)
|
||||||
{
|
{
|
||||||
pwdCorrect = true;
|
pwdCorrect = true;
|
||||||
}
|
}
|
||||||
if (!otaLock && server.arg("OP").length() > 0)
|
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
|
//cronixie
|
||||||
pos = req.indexOf("NX="); //sets digits to code
|
pos = req.indexOf("NX="); //sets digits to code
|
||||||
if (pos > 0) {
|
if (pos > 0) {
|
||||||
cronixieDisplay = req.substring(pos + 3, pos + 9);
|
strcpy(cronixieDisplay,req.substring(pos + 3, pos + 9).c_str());
|
||||||
setCronixie();
|
setCronixie();
|
||||||
}
|
}
|
||||||
pos = req.indexOf("NM="); //mode, 1 countdown
|
pos = req.indexOf("NM="); //mode, 1 countdown
|
||||||
|
@ -49,7 +49,7 @@ void wledInit()
|
|||||||
ntpConnected = ntpUdp.begin(ntpLocalPort);
|
ntpConnected = ntpUdp.begin(ntpLocalPort);
|
||||||
|
|
||||||
//start captive portal
|
//start captive portal
|
||||||
if (onlyAP || apSSID.length() > 0)
|
if (onlyAP || strlen(apSSID) > 0)
|
||||||
{
|
{
|
||||||
dnsServer.setErrorReplyCode(DNSReplyCode::NoError);
|
dnsServer.setErrorReplyCode(DNSReplyCode::NoError);
|
||||||
dnsServer.start(53, "*", WiFi.softAPIP());
|
dnsServer.start(53, "*", WiFi.softAPIP());
|
||||||
@ -245,21 +245,21 @@ void wledInit()
|
|||||||
#endif
|
#endif
|
||||||
DEBUG_PRINTLN("Start ArduinoOTA");
|
DEBUG_PRINTLN("Start ArduinoOTA");
|
||||||
});
|
});
|
||||||
if (cmDNS.length() > 0) ArduinoOTA.setHostname(cmDNS.c_str());
|
if (strlen(cmDNS) > 0) ArduinoOTA.setHostname(cmDNS);
|
||||||
ArduinoOTA.begin();
|
ArduinoOTA.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!initLedsLast) strip.service();
|
if (!initLedsLast) strip.service();
|
||||||
// Set up mDNS responder:
|
// 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");
|
DEBUG_PRINTLN("mDNS responder started");
|
||||||
// Add service to MDNS
|
// Add service to MDNS
|
||||||
MDNS.addService("http", "tcp", 80);
|
MDNS.addService("http", "tcp", 80);
|
||||||
}
|
}
|
||||||
|
|
||||||
initBlynk(blynkApiKey.c_str());
|
initBlynk(blynkApiKey);
|
||||||
|
|
||||||
if (initLedsLast) initStrip();
|
if (initLedsLast) initStrip();
|
||||||
userBegin();
|
userBegin();
|
||||||
@ -286,10 +286,10 @@ void initStrip()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void initAP(){
|
void initAP(){
|
||||||
String save = apSSID;
|
bool set = apSSID[0];
|
||||||
if (apSSID.length() <1) apSSID = "WLED-AP";
|
if (!set) strcpy(apSSID,"WLED-AP");
|
||||||
WiFi.softAP(apSSID.c_str(), apPass.c_str(), apChannel, apHide);
|
WiFi.softAP(apSSID, apPass, apChannel, apHide);
|
||||||
apSSID = save;
|
if (!set) apSSID[0] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void initCon()
|
void initCon()
|
||||||
@ -304,10 +304,10 @@ void initCon()
|
|||||||
WiFi.config(0U, 0U, 0U);
|
WiFi.config(0U, 0U, 0U);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (apSSID.length()>0)
|
if (strlen(apSSID)>0)
|
||||||
{
|
{
|
||||||
DEBUG_PRINT("USING AP");
|
DEBUG_PRINT("USING AP");
|
||||||
DEBUG_PRINTLN(apSSID.length());
|
DEBUG_PRINTLN(strlen(apSSID));
|
||||||
initAP();
|
initAP();
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
@ -315,13 +315,13 @@ void initCon()
|
|||||||
WiFi.softAPdisconnect(true);
|
WiFi.softAPdisconnect(true);
|
||||||
}
|
}
|
||||||
int fail_count = 0;
|
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
|
#ifndef ARDUINO_ARCH_ESP32
|
||||||
WiFi.hostname(serverDescription);
|
WiFi.hostname(serverDescription);
|
||||||
#endif
|
#endif
|
||||||
WiFi.begin(clientSSID.c_str(), clientPass.c_str());
|
WiFi.begin(clientSSID, clientPass);
|
||||||
#ifdef ARDUINO_ARCH_ESP32
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
WiFi.setHostname(serverDescription.c_str());
|
WiFi.setHostname(serverDescription);
|
||||||
#endif
|
#endif
|
||||||
unsigned long lastTry = 0;
|
unsigned long lastTry = 0;
|
||||||
bool con = false;
|
bool con = false;
|
||||||
|
@ -72,8 +72,7 @@ void handleNetworkTime()
|
|||||||
|
|
||||||
void sendNTPPacket()
|
void sendNTPPacket()
|
||||||
{
|
{
|
||||||
const char* ntpsrv = ntpServerName.c_str();
|
WiFi.hostByName(ntpServerName, ntpServerIP);
|
||||||
WiFi.hostByName(ntpsrv, ntpServerIP);
|
|
||||||
DEBUG_PRINTLN("send NTP packet");
|
DEBUG_PRINTLN("send NTP packet");
|
||||||
|
|
||||||
memset(ntpPacketBuffer, 0, NTP_PACKET_SIZE);
|
memset(ntpPacketBuffer, 0, NTP_PACKET_SIZE);
|
||||||
|
@ -27,14 +27,13 @@ void handleAlexa()
|
|||||||
int packetSize = UDP.parsePacket();
|
int packetSize = UDP.parsePacket();
|
||||||
if(packetSize>0) {
|
if(packetSize>0) {
|
||||||
IPAddress remote = UDP.remoteIP();
|
IPAddress remote = UDP.remoteIP();
|
||||||
int len = UDP.read(packetBuffer, 254);
|
int len = UDP.read(obuf, 254);
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
packetBuffer[len] = 0;
|
obuf[len] = 0;
|
||||||
}
|
}
|
||||||
String request = packetBuffer;
|
|
||||||
|
|
||||||
if(request.indexOf("M-SEARCH") >= 0) {
|
if(strstr(obuf,"M-SEARCH") > 0) {
|
||||||
if(request.indexOf("upnp:rootdevice") > 0 || request.indexOf("device:basic:1") > 0) {
|
if(strstr(obuf,"upnp:rootdevice") > 0 || strstr(obuf,"device:basic:1") > 0) {
|
||||||
DEBUG_PRINTLN("Responding search req...");
|
DEBUG_PRINTLN("Responding search req...");
|
||||||
respondToSearch();
|
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
|
if (req.indexOf("lights/1") > 0) //client wants light info
|
||||||
{
|
{
|
||||||
DEBUG_PRINTLN("l1");
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
if (req.indexOf("lights") > 0) //client wants all lights
|
if (req.indexOf("lights") > 0) //client wants all lights
|
||||||
{
|
{
|
||||||
DEBUG_PRINTLN("lAll");
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
/*
|
/*
|
||||||
* Support for the Cronixie clock
|
* 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;
|
byte counter = 0;
|
||||||
|
|
||||||
for (int i = index+1; i < 6; i++)
|
for (int i = index+1; i < 6; i++)
|
||||||
{
|
{
|
||||||
if (digits[i] == code)
|
if (cronixieDisplay[i] == code)
|
||||||
{
|
{
|
||||||
counter++;
|
counter++;
|
||||||
} else {
|
} else {
|
||||||
@ -19,7 +19,6 @@ byte getSameCodeLength(char code, int index, char const digits[])
|
|||||||
|
|
||||||
void setCronixie()
|
void setCronixie()
|
||||||
{
|
{
|
||||||
char digits[6]; for (int a=0;a<6;a++) digits[a]=cronixieDisplay.charAt(a);
|
|
||||||
/*
|
/*
|
||||||
* digit purpose index
|
* digit purpose index
|
||||||
* 0-9 | 0-9 (incl. random)
|
* 0-9 | 0-9 (incl. random)
|
||||||
@ -84,14 +83,14 @@ void setCronixie()
|
|||||||
//D Day of Week | DD Day Of Month | DDD Day Of Year
|
//D Day of Week | DD Day Of Month | DDD Day Of Year
|
||||||
|
|
||||||
DEBUG_PRINT("cset ");
|
DEBUG_PRINT("cset ");
|
||||||
DEBUG_PRINTLN(digits);
|
DEBUG_PRINTLN(cronixieDisplay);
|
||||||
|
|
||||||
overlayRefreshMs = 1997; //Only refresh every 2secs if no seconds are displayed
|
overlayRefreshMs = 1997; //Only refresh every 2secs if no seconds are displayed
|
||||||
|
|
||||||
for (int i = 0; i < 6; i++)
|
for (int i = 0; i < 6; i++)
|
||||||
{
|
{
|
||||||
dP[i] = 10;
|
dP[i] = 10;
|
||||||
switch (digits[i])
|
switch (cronixieDisplay[i])
|
||||||
{
|
{
|
||||||
case '_': dP[i] = 10; break;
|
case '_': dP[i] = 10; break;
|
||||||
case '-': dP[i] = 11; 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 'R': dP[i] = random(0,10); break; //random btw. 0-9
|
||||||
case 't': break; //Test upw.
|
case 't': break; //Test upw.
|
||||||
case 'T': break; //Test dnw.
|
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,cronixieDisplay); i = i+dP[i]-14; break;
|
||||||
case 'B': dP[i] = 14 + getSameCodeLength('B',i,digits); 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,digits); i = i+dP[i]-70; break;
|
case 'h': dP[i] = 70 + getSameCodeLength('h',i,cronixieDisplay); i = i+dP[i]-70; break;
|
||||||
case 'H': dP[i] = 20 + getSameCodeLength('H',i,digits); i = i+dP[i]-20; 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] = 108; i++; break;
|
||||||
case 'a': dP[i] = 58; 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] = 74 + getSameCodeLength('m',i,cronixieDisplay); i = i+dP[i]-74; break;
|
||||||
case 'M': dP[i] = 24 + getSameCodeLength('M',i,digits); i = i+dP[i]-24; break;
|
case 'M': dP[i] = 24 + getSameCodeLength('M',i,cronixieDisplay); 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] = 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,digits); i = i+dP[i]-30; overlayRefreshMs = 497; break;
|
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,digits); i = i+dP[i]-36; break;
|
case 'Y': dP[i] = 36 + getSameCodeLength('Y',i,cronixieDisplay); i = i+dP[i]-36; break;
|
||||||
case 'y': dP[i] = 86 + getSameCodeLength('y',i,digits); i = i+dP[i]-86; break;
|
case 'y': dP[i] = 86 + getSameCodeLength('y',i,cronixieDisplay); 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] = 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,digits); i = i+dP[i]-89; break;
|
case 'i': dP[i] = 89 + getSameCodeLength('i',i,cronixieDisplay); i = i+dP[i]-89; break;
|
||||||
case 'W': break;
|
case 'W': 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] = 43 + getSameCodeLength('D',i,cronixieDisplay); 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] = 93 + getSameCodeLength('d',i,cronixieDisplay); i = i+dP[i]-93; break;
|
||||||
case '0': dP[i] = 0; break;
|
case '0': dP[i] = 0; break;
|
||||||
case '1': dP[i] = 1; break;
|
case '1': dP[i] = 1; break;
|
||||||
case '2': dP[i] = 2; break;
|
case '2': dP[i] = 2; break;
|
||||||
|
@ -17,18 +17,18 @@ bool setupHue()
|
|||||||
{
|
{
|
||||||
if (WiFi.status() == WL_CONNECTED) //setup needed
|
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))
|
if (sendHuePoll(false))
|
||||||
{
|
{
|
||||||
huePollingEnabled = true;
|
huePollingEnabled = true;
|
||||||
return 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);
|
delay(20);
|
||||||
}
|
}
|
||||||
sendHuePoll(true); //new API key
|
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);
|
delay(20);
|
||||||
if (sendHuePoll(false))
|
if (sendHuePoll(false))
|
||||||
{
|
{
|
||||||
@ -60,7 +60,7 @@ bool sendHuePoll(bool sAuth)
|
|||||||
if (httpCode>0){
|
if (httpCode>0){
|
||||||
st = handleHueResponse(hueClient.getString(),sAuth);
|
st = handleHueResponse(hueClient.getString(),sAuth);
|
||||||
} else {
|
} else {
|
||||||
hueError = "Request timed out";
|
strcpy(hueError,"Request timed out");
|
||||||
st = false;
|
st = false;
|
||||||
}
|
}
|
||||||
if (!st){ //error
|
if (!st){ //error
|
||||||
@ -81,10 +81,13 @@ bool handleHueResponse(String hueResp, bool isAuth)
|
|||||||
int hueErrorCode = getJsonValue(&hueResp,"type").toInt();
|
int hueErrorCode = getJsonValue(&hueResp,"type").toInt();
|
||||||
switch (hueErrorCode)
|
switch (hueErrorCode)
|
||||||
{
|
{
|
||||||
case 1: hueError = "Unauthorized"; break;
|
case 1: strcpy(hueError,"Unauthorized"); break;
|
||||||
case 3: hueError = "Invalid light ID"; break;
|
case 3: strcpy(hueError,"Invalid light ID"); break;
|
||||||
case 101: hueError = "Link button not pressed"; break;
|
case 101: strcpy(hueError,"Link button not pressed"); break;
|
||||||
default: hueError = "Bridge Error " + String(hueErrorCode);
|
default:
|
||||||
|
char coerr[18];
|
||||||
|
sprintf(coerr,"Bridge Error %i",hueErrorCode);
|
||||||
|
strcpy(hueError,coerr);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -94,10 +97,10 @@ bool handleHueResponse(String hueResp, bool isAuth)
|
|||||||
String tempApi = getJsonValue(&hueResp,"username");
|
String tempApi = getJsonValue(&hueResp,"username");
|
||||||
if (tempApi.length()>0)
|
if (tempApi.length()>0)
|
||||||
{
|
{
|
||||||
hueApiKey = tempApi;
|
strcpy(hueApiKey,tempApi.c_str());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
hueError = "Invalid response";
|
strcpy(hueError,"Invalid response");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,7 +160,7 @@ bool handleHueResponse(String hueResp, bool isAuth)
|
|||||||
}
|
}
|
||||||
hueFailCount = 0;
|
hueFailCount = 0;
|
||||||
huePollIntervalMsTemp = huePollIntervalMs;
|
huePollIntervalMsTemp = huePollIntervalMs;
|
||||||
hueError = "Connected";
|
strcpy(hueError,"Connected");
|
||||||
//applying vals
|
//applying vals
|
||||||
if (hueBri != hueBriLast)
|
if (hueBri != hueBriLast)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user