2016-12-31 00:38:51 +01:00
|
|
|
/*
|
|
|
|
* Sending XML status files to client
|
|
|
|
*/
|
|
|
|
|
2016-11-19 19:39:17 +01:00
|
|
|
void XML_response()
|
|
|
|
{
|
2018-07-20 19:35:31 +02:00
|
|
|
olen = 0;
|
|
|
|
oappend("<?xml version = \"1.0\" ?><vs><ac>");
|
2016-11-27 16:45:54 +01:00
|
|
|
if (nightlightActive && nightlightFade)
|
|
|
|
{
|
2018-07-20 19:35:31 +02:00
|
|
|
oappendi(briT);
|
2016-11-27 16:45:54 +01:00
|
|
|
} else
|
|
|
|
{
|
2018-07-20 19:35:31 +02:00
|
|
|
oappendi(bri);
|
2016-11-27 16:45:54 +01:00
|
|
|
}
|
2018-07-20 19:35:31 +02:00
|
|
|
oappend("</ac>");
|
2016-11-19 19:39:17 +01:00
|
|
|
|
|
|
|
for (int i = 0; i < 3; i++)
|
|
|
|
{
|
2018-07-20 19:35:31 +02:00
|
|
|
oappend("<cl>");
|
|
|
|
oappendi(col[i]);
|
|
|
|
oappend("</cl>");
|
2016-11-19 19:39:17 +01:00
|
|
|
}
|
2018-07-20 19:35:31 +02:00
|
|
|
oappend("<ns>");
|
|
|
|
oappendi(notifyDirect);
|
|
|
|
oappend("</ns><nr>");
|
|
|
|
oappendi(receiveNotifications);
|
|
|
|
oappend("</nr><nl>");
|
|
|
|
oappendi(nightlightActive);
|
|
|
|
oappend("</nl><nf>");
|
|
|
|
oappendi(nightlightFade);
|
|
|
|
oappend("</nf><nd>");
|
|
|
|
oappendi(nightlightDelayMins);
|
|
|
|
oappend("</nd><nt>");
|
|
|
|
oappendi(nightlightTargetBri);
|
|
|
|
oappend("</nt><fx>");
|
|
|
|
oappendi(effectCurrent);
|
|
|
|
oappend("</fx><sx>");
|
|
|
|
oappendi(effectSpeed);
|
|
|
|
oappend("</sx><ix>");
|
|
|
|
oappendi(effectIntensity);
|
2018-09-06 02:05:56 +02:00
|
|
|
oappend("</ix><fp>");
|
|
|
|
oappendi(effectPalette);
|
|
|
|
oappend("</fp><wv>");
|
2018-07-16 11:50:09 +02:00
|
|
|
if (useRGBW && !autoRGBtoRGBW) {
|
2018-07-20 19:35:31 +02:00
|
|
|
oappendi(white);
|
2017-10-12 22:20:37 +02:00
|
|
|
} else {
|
2018-07-20 19:35:31 +02:00
|
|
|
oappend("-1");
|
2017-10-12 22:20:37 +02:00
|
|
|
}
|
2018-07-20 19:35:31 +02:00
|
|
|
oappend("</wv><md>");
|
|
|
|
oappendi(useHSB);
|
|
|
|
oappend("</md><ds>");
|
2018-07-21 23:21:07 +02:00
|
|
|
oappend(serverDescription);
|
2018-07-20 19:35:31 +02:00
|
|
|
oappend("</ds></vs>");
|
|
|
|
server.send(200, "text/xml", obuf);
|
2016-11-19 19:39:17 +01:00
|
|
|
}
|
|
|
|
|
2018-07-20 19:35:31 +02:00
|
|
|
void sappend(char stype, char* key, int val) //append a setting to string buffer
|
|
|
|
{
|
|
|
|
char ds[] = "d.Sf.";
|
|
|
|
|
|
|
|
switch(stype)
|
|
|
|
{
|
|
|
|
case 'c': //checkbox
|
|
|
|
oappend(ds);
|
|
|
|
oappend(key);
|
|
|
|
oappend(".checked=");
|
|
|
|
oappendi(val);
|
|
|
|
oappend(";");
|
|
|
|
break;
|
|
|
|
case 'v': //numeric
|
|
|
|
oappend(ds);
|
|
|
|
oappend(key);
|
|
|
|
oappend(".value=");
|
|
|
|
oappendi(val);
|
|
|
|
oappend(";");
|
|
|
|
break;
|
|
|
|
case 'i': //selectedIndex
|
|
|
|
oappend(ds);
|
|
|
|
oappend(key);
|
|
|
|
oappend(".selectedIndex=");
|
|
|
|
oappendi(val);
|
|
|
|
oappend(";");
|
|
|
|
break;
|
2018-07-22 21:21:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void sappends(char stype, char* key, char* val) //append a string setting
|
|
|
|
{
|
|
|
|
switch(stype)
|
|
|
|
{
|
|
|
|
case 's': //string (we can interpret val as char*)
|
|
|
|
oappend("d.Sf.");
|
|
|
|
oappend(key);
|
|
|
|
oappend(".value=\"");
|
|
|
|
oappend(val);
|
|
|
|
oappend("\";");
|
|
|
|
break;
|
2018-07-20 19:35:31 +02:00
|
|
|
case 'm': //message
|
2018-07-22 21:21:18 +02:00
|
|
|
oappend("d.getElementsByClassName");
|
|
|
|
oappend(key);
|
|
|
|
oappend(".innerHTML=\"");
|
|
|
|
oappend(val);
|
|
|
|
oappend("\";");
|
|
|
|
break;
|
2018-07-20 19:35:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void getSettingsJS(byte subPage) //get values for settings form in javascript
|
2016-11-19 19:39:17 +01:00
|
|
|
{
|
2018-01-27 23:28:20 +01:00
|
|
|
//0: menu 1: wifi 2: leds 3: ui 4: sync 5: time 6: sec
|
|
|
|
DEBUG_PRINT("settings resp");
|
|
|
|
DEBUG_PRINTLN(subPage);
|
2017-11-20 00:07:37 +01:00
|
|
|
|
2018-07-20 19:35:31 +02:00
|
|
|
olen = 0; obuf[0] = 0; //clear buffer
|
|
|
|
if (subPage <1 || subPage >6) return;
|
2018-02-20 22:29:48 +01:00
|
|
|
|
|
|
|
if (subPage == 1) {
|
2018-07-22 21:21:18 +02:00
|
|
|
sappends('s',"CS",clientSSID);
|
2018-07-20 19:35:31 +02:00
|
|
|
|
2018-07-21 23:21:07 +02:00
|
|
|
byte l = strlen(clientPass);
|
2018-07-20 19:35:31 +02:00
|
|
|
char fpass[l+1]; //fill password field with ***
|
|
|
|
fpass[l] = 0;
|
|
|
|
memset(fpass,'*',l);
|
2018-07-22 21:21:18 +02:00
|
|
|
sappends('s',"CP",fpass);
|
2018-07-20 19:35:31 +02:00
|
|
|
|
|
|
|
char k[3]; k[2] = 0; //IP addresses
|
|
|
|
for (int i = 0; i<4; i++)
|
2018-02-20 22:29:48 +01:00
|
|
|
{
|
2018-07-20 19:35:31 +02:00
|
|
|
k[1] = 48+i; //ascii 0,1,2,3
|
|
|
|
k[0] = 'I'; sappend('v',k,staticIP[i]);
|
|
|
|
k[0] = 'G'; sappend('v',k,staticGateway[i]);
|
|
|
|
k[0] = 'S'; sappend('v',k,staticSubnet[i]);
|
2018-02-20 22:29:48 +01:00
|
|
|
}
|
2018-07-20 19:35:31 +02:00
|
|
|
|
2018-07-22 21:21:18 +02:00
|
|
|
sappends('s',"CM",cmDNS);
|
2018-07-20 19:35:31 +02:00
|
|
|
sappend('v',"AT",apWaitTimeSecs);
|
2018-07-22 21:21:18 +02:00
|
|
|
sappends('s',"AS",apSSID);
|
2018-07-20 19:35:31 +02:00
|
|
|
sappend('c',"AH",apHide);
|
|
|
|
|
2018-07-21 23:21:07 +02:00
|
|
|
l = strlen(apPass);
|
2018-07-20 19:35:31 +02:00
|
|
|
char fapass[l+1]; //fill password field with ***
|
|
|
|
fapass[l] = 0;
|
|
|
|
memset(fapass,'*',l);
|
2018-07-22 21:21:18 +02:00
|
|
|
sappends('s',"AP",fapass);
|
2018-07-20 19:35:31 +02:00
|
|
|
|
|
|
|
sappend('v',"AC",apChannel);
|
|
|
|
|
|
|
|
if (WiFi.localIP()[0] != 0) //is connected
|
2018-02-20 22:29:48 +01:00
|
|
|
{
|
2018-07-21 23:21:07 +02:00
|
|
|
char s[16];
|
|
|
|
IPAddress localIP = WiFi.localIP();
|
|
|
|
sprintf(s, "%d.%d.%d.%d", localIP[0], localIP[1], localIP[2], localIP[3]);
|
2018-07-22 21:21:18 +02:00
|
|
|
sappends('m',"(\"sip\")[0]",s);
|
2018-02-20 22:29:48 +01:00
|
|
|
} else
|
|
|
|
{
|
2018-07-22 21:21:18 +02:00
|
|
|
sappends('m',"(\"sip\")[0]","Not connected");
|
2018-02-20 22:29:48 +01:00
|
|
|
}
|
2018-07-20 19:35:31 +02:00
|
|
|
|
|
|
|
if (WiFi.softAPIP()[0] != 0) //is active
|
2018-02-20 22:29:48 +01:00
|
|
|
{
|
2018-07-21 23:21:07 +02:00
|
|
|
char s[16];
|
|
|
|
IPAddress apIP = WiFi.softAPIP();
|
|
|
|
sprintf(s, "%d.%d.%d.%d", apIP[0], apIP[1], apIP[2], apIP[3]);
|
2018-07-22 21:21:18 +02:00
|
|
|
sappends('m',"(\"sip\")[1]",s);
|
2018-02-20 22:29:48 +01:00
|
|
|
} else
|
|
|
|
{
|
2018-07-22 21:21:18 +02:00
|
|
|
sappends('m',"(\"sip\")[1]","Not active");
|
2018-02-20 22:29:48 +01:00
|
|
|
}
|
2016-11-19 19:39:17 +01:00
|
|
|
}
|
2018-02-20 22:29:48 +01:00
|
|
|
|
|
|
|
if (subPage == 2) {
|
2018-07-20 19:35:31 +02:00
|
|
|
sappend('v',"LC",ledCount);
|
|
|
|
sappend('v',"CR",colS[0]);
|
|
|
|
sappend('v',"CG",colS[1]);
|
|
|
|
sappend('v',"CB",colS[2]);
|
|
|
|
sappend('v',"CA",briS);
|
|
|
|
sappend('c',"EW",useRGBW);
|
|
|
|
sappend('c',"AW",autoRGBtoRGBW);
|
|
|
|
sappend('v',"CW",whiteS);
|
|
|
|
sappend('v',"SR",colSecS[0]);
|
|
|
|
sappend('v',"SG",colSecS[1]);
|
|
|
|
sappend('v',"SB",colSecS[2]);
|
|
|
|
sappend('v',"SW",whiteSecS);
|
|
|
|
sappend('c',"BO",turnOnAtBoot);
|
|
|
|
sappend('v',"BP",bootPreset);
|
|
|
|
sappend('v',"FX",effectDefault);
|
|
|
|
sappend('v',"SX",effectSpeedDefault);
|
|
|
|
sappend('v',"IX",effectIntensityDefault);
|
2018-09-06 02:05:56 +02:00
|
|
|
sappend('v',"FP",effectPaletteDefault);
|
2018-07-20 19:35:31 +02:00
|
|
|
sappend('c',"GB",useGammaCorrectionBri);
|
|
|
|
sappend('c',"GC",useGammaCorrectionRGB);
|
|
|
|
sappend('c',"TF",fadeTransition);
|
|
|
|
sappend('v',"TD",transitionDelay);
|
2018-09-08 16:21:44 +02:00
|
|
|
sappend('c',"PF",strip.paletteFade);
|
2018-09-15 17:29:01 +02:00
|
|
|
sappend('c',"T2",enableSecTransition);
|
2018-07-20 19:35:31 +02:00
|
|
|
sappend('v',"BF",briMultiplier);
|
|
|
|
sappend('v',"TB",nightlightTargetBri);
|
|
|
|
sappend('v',"TL",nightlightDelayMins);
|
|
|
|
sappend('c',"TW",nightlightFade);
|
2018-09-11 00:20:12 +02:00
|
|
|
sappend('i',"PB",strip.paletteBlend);
|
2018-07-20 19:35:31 +02:00
|
|
|
sappend('c',"RV",reverseMode);
|
|
|
|
sappend('c',"EI",initLedsLast);
|
|
|
|
sappend('c',"SL",skipFirstLed);
|
2016-12-29 00:03:58 +01:00
|
|
|
}
|
2017-11-20 00:07:37 +01:00
|
|
|
|
2018-02-20 22:29:48 +01:00
|
|
|
if (subPage == 3)
|
|
|
|
{
|
2018-07-20 19:35:31 +02:00
|
|
|
sappend('i',"UI",uiConfiguration);
|
2018-07-22 21:21:18 +02:00
|
|
|
sappends('s',"DS",serverDescription);
|
2018-07-20 19:35:31 +02:00
|
|
|
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
|
2018-07-22 21:21:18 +02:00
|
|
|
sappends('s',k,cssCol[i]);
|
2018-07-20 19:35:31 +02:00
|
|
|
}
|
2018-07-22 21:21:18 +02:00
|
|
|
sappends('s',"CF",cssFont);
|
2017-11-20 00:07:37 +01:00
|
|
|
}
|
2018-02-20 22:29:48 +01:00
|
|
|
|
|
|
|
if (subPage == 4)
|
2016-11-19 19:39:17 +01:00
|
|
|
{
|
2018-07-20 19:35:31 +02:00
|
|
|
sappend('c',"BT",buttonEnabled);
|
|
|
|
sappend('v',"UP",udpPort);
|
|
|
|
sappend('c',"RB",receiveNotificationBrightness);
|
|
|
|
sappend('c',"RC",receiveNotificationColor);
|
|
|
|
sappend('c',"RX",receiveNotificationEffects);
|
|
|
|
sappend('c',"SD",notifyDirectDefault);
|
|
|
|
sappend('c',"SB",notifyButton);
|
|
|
|
sappend('c',"SH",notifyHue);
|
|
|
|
sappend('c',"S2",notifyTwice);
|
|
|
|
sappend('c',"RD",receiveDirect);
|
2018-08-11 22:57:13 +02:00
|
|
|
sappend('c',"EM",e131Multicast);
|
|
|
|
sappend('v',"EU",e131Universe);
|
2018-09-15 17:29:01 +02:00
|
|
|
sappend('v',"ET",realtimeTimeoutMs);
|
2018-08-11 22:57:13 +02:00
|
|
|
sappend('c',"FB",arlsForceMaxBri);
|
|
|
|
sappend('c',"RG",arlsDisableGammaCorrection);
|
|
|
|
sappend('v',"WO",arlsOffset);
|
2018-07-20 19:35:31 +02:00
|
|
|
sappend('c',"RU",enableRealtimeUI);
|
|
|
|
sappend('c',"AL",alexaEnabled);
|
2018-07-22 21:21:18 +02:00
|
|
|
sappends('s',"AI",alexaInvocationName);
|
2018-09-15 17:29:01 +02:00
|
|
|
sappend('c',"SA",notifyAlexa);
|
2018-07-22 21:21:18 +02:00
|
|
|
sappends('s',"BK",(char*)((blynkEnabled)?"Hidden":""));
|
2018-07-20 19:35:31 +02:00
|
|
|
sappend('v',"H0",hueIP[0]);
|
|
|
|
sappend('v',"H1",hueIP[1]);
|
|
|
|
sappend('v',"H2",hueIP[2]);
|
|
|
|
sappend('v',"H3",hueIP[3]);
|
|
|
|
sappend('v',"HL",huePollLightId);
|
|
|
|
sappend('v',"HI",huePollIntervalMs);
|
|
|
|
sappend('c',"HP",huePollingEnabled);
|
|
|
|
sappend('c',"HO",hueApplyOnOff);
|
|
|
|
sappend('c',"HB",hueApplyBri);
|
|
|
|
sappend('c',"HC",hueApplyColor);
|
2018-07-22 21:21:18 +02:00
|
|
|
sappends('m',"(\"hms\")[0]",hueError);
|
2016-11-19 19:39:17 +01:00
|
|
|
}
|
2018-02-20 22:29:48 +01:00
|
|
|
|
|
|
|
if (subPage == 5)
|
2016-11-19 19:39:17 +01:00
|
|
|
{
|
2018-07-20 19:35:31 +02:00
|
|
|
sappend('c',"NT",ntpEnabled);
|
|
|
|
sappend('c',"CF",!useAMPM);
|
|
|
|
sappend('i',"TZ",currentTimezone);
|
|
|
|
sappend('v',"UO",utcOffsetSecs);
|
2018-07-22 21:21:18 +02:00
|
|
|
sappends('m',"(\"times\")[0]",(char*)getTimeString().c_str());
|
2018-07-20 19:35:31 +02:00
|
|
|
sappend('i',"OL",overlayCurrent);
|
|
|
|
sappend('v',"O1",overlayMin);
|
|
|
|
sappend('v',"O2",overlayMax);
|
|
|
|
sappend('v',"OM",analogClock12pixel);
|
|
|
|
sappend('c',"OS",analogClockSecondsTrail);
|
|
|
|
sappend('c',"O5",analogClock5MinuteMarks);
|
2018-07-22 21:21:18 +02:00
|
|
|
sappends('s',"CX",cronixieDisplay);
|
2018-07-20 19:35:31 +02:00
|
|
|
sappend('c',"CB",cronixieBacklight);
|
|
|
|
sappend('c',"CE",countdownMode);
|
|
|
|
sappend('v',"CY",countdownYear);
|
|
|
|
sappend('v',"CI",countdownMonth);
|
|
|
|
sappend('v',"CD",countdownDay);
|
|
|
|
sappend('v',"CH",countdownHour);
|
|
|
|
sappend('v',"CM",countdownMin);
|
|
|
|
sappend('v',"CS",countdownSec);
|
|
|
|
|
|
|
|
char k[4]; k[0]= 'M';
|
2018-03-06 23:47:08 +01:00
|
|
|
for (int i=1;i<17;i++)
|
|
|
|
{
|
2018-07-20 19:35:31 +02:00
|
|
|
sprintf(k+1,"%i",i);
|
2018-07-22 21:21:18 +02:00
|
|
|
sappends('s',k,(char*)loadMacro(i).c_str());
|
2018-03-06 23:47:08 +01:00
|
|
|
}
|
2018-07-20 19:35:31 +02:00
|
|
|
|
|
|
|
sappend('v',"MB",macroBoot);
|
|
|
|
sappend('v',"A0",macroAlexaOn);
|
|
|
|
sappend('v',"A1",macroAlexaOff);
|
|
|
|
sappend('v',"MP",macroButton);
|
|
|
|
sappend('v',"ML",macroLongPress);
|
|
|
|
sappend('v',"MC",macroCountdown);
|
|
|
|
sappend('v',"MN",macroNl);
|
2018-02-20 22:29:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (subPage == 6)
|
2016-11-19 19:39:17 +01:00
|
|
|
{
|
2018-07-20 19:35:31 +02:00
|
|
|
sappend('c',"NO",otaLock);
|
|
|
|
sappend('c',"OW",wifiLock);
|
|
|
|
sappend('c',"AO",aOtaEnabled);
|
|
|
|
sappend('c',"NA",recoveryAPDisabled);
|
2018-07-22 21:21:18 +02:00
|
|
|
sappends('m',"(\"msg\")[0]","WLED ");
|
2018-07-20 19:35:31 +02:00
|
|
|
olen -= 2; //delete ";
|
|
|
|
oappend(versionString);
|
|
|
|
oappend(" (build ");
|
|
|
|
oappendi(VERSION);
|
|
|
|
oappend(") OK\";");
|
2016-11-19 19:39:17 +01:00
|
|
|
}
|
2018-07-20 19:35:31 +02:00
|
|
|
oappend("}</script>");
|
2016-11-19 19:39:17 +01:00
|
|
|
}
|