WLED/wled00/xml.cpp

586 lines
18 KiB
C++
Raw Normal View History

2020-04-10 12:30:08 +02:00
#include "wled.h"
/*
* Sending XML status files to client
*/
2020-09-20 01:18:31 +02:00
//macro to convert F to const
#define SET_F(x) (const char*)F(x)
//build XML response to HTTP /win API request
2020-05-28 02:20:02 +02:00
void XML_response(AsyncWebServerRequest *request, char* dest)
{
2019-03-19 12:19:48 +01:00
char sbuf[(dest == nullptr)?1024:1]; //allocate local buffer if none passed
obuf = (dest == nullptr)? sbuf:dest;
2019-08-17 12:27:06 +02:00
2019-03-16 02:09:37 +01:00
olen = 0;
2020-09-20 01:18:31 +02:00
oappend(SET_F("<?xml version=\"1.0\" ?><vs><ac>"));
oappendi((nightlightActive && nightlightMode > NL_MODE_SET) ? briT : bri);
2020-09-20 01:18:31 +02:00
oappend(SET_F("</ac>"));
2019-08-17 12:27:06 +02:00
for (int i = 0; i < 3; i++)
{
oappend("<cl>");
oappendi(col[i]);
oappend("</cl>");
}
for (int i = 0; i < 3; i++)
{
oappend("<cs>");
oappendi(colSec[i]);
oappend("</cs>");
}
2020-09-20 01:18:31 +02:00
oappend(SET_F("<ns>"));
oappendi(notifyDirect);
2020-09-20 01:18:31 +02:00
oappend(SET_F("</ns><nr>"));
oappendi(receiveNotifications);
2020-09-20 01:18:31 +02:00
oappend(SET_F("</nr><nl>"));
oappendi(nightlightActive);
2020-09-20 01:18:31 +02:00
oappend(SET_F("</nl><nf>"));
oappendi(nightlightMode > NL_MODE_SET);
2020-09-20 01:18:31 +02:00
oappend(SET_F("</nf><nd>"));
oappendi(nightlightDelayMins);
2020-09-20 01:18:31 +02:00
oappend(SET_F("</nd><nt>"));
oappendi(nightlightTargetBri);
2020-09-20 01:18:31 +02:00
oappend(SET_F("</nt><fx>"));
oappendi(effectCurrent);
2020-09-20 01:18:31 +02:00
oappend(SET_F("</fx><sx>"));
oappendi(effectSpeed);
2020-09-20 01:18:31 +02:00
oappend(SET_F("</sx><ix>"));
oappendi(effectIntensity);
2020-09-20 01:18:31 +02:00
oappend(SET_F("</ix><fp>"));
oappendi(effectPalette);
2020-09-20 01:18:31 +02:00
oappend(SET_F("</fp><wv>"));
if (strip.isRgbw) {
oappendi(col[3]);
} else {
oappend("-1");
}
2020-09-20 01:18:31 +02:00
oappend(SET_F("</wv><ws>"));
oappendi(colSec[3]);
2020-09-20 01:18:31 +02:00
oappend(SET_F("</ws><ps>"));
oappendi((currentPreset < 1) ? 0:currentPreset);
2020-09-20 01:18:31 +02:00
oappend(SET_F("</ps><cy>"));
2021-06-30 01:48:38 +02:00
oappendi(currentPlaylist > 0);
2020-09-20 01:18:31 +02:00
oappend(SET_F("</cy><ds>"));
oappend(serverDescription);
2020-02-09 19:10:29 +01:00
if (realtimeMode)
{
2020-09-20 01:18:31 +02:00
oappend(SET_F(" (live)"));
}
2020-09-20 01:18:31 +02:00
oappend(SET_F("</ds><ss>"));
2019-12-01 01:42:52 +01:00
oappendi(strip.getMainSegmentId());
2020-09-20 01:18:31 +02:00
oappend(SET_F("</ss></vs>"));
2019-03-16 02:09:37 +01:00
if (request != nullptr) request->send(200, "text/xml", obuf);
}
2020-05-28 02:20:02 +02:00
void URL_response(AsyncWebServerRequest *request)
{
2020-05-28 02:20:02 +02:00
char sbuf[256];
char s2buf[100];
obuf = s2buf;
olen = 0;
char s[16];
2020-09-20 01:18:31 +02:00
oappend(SET_F("http://"));
IPAddress localIP = Network.localIP();
sprintf(s, "%d.%d.%d.%d", localIP[0], localIP[1], localIP[2], localIP[3]);
oappend(s);
2020-09-20 01:18:31 +02:00
oappend(SET_F("/win&A="));
oappendi(bri);
2020-09-20 01:18:31 +02:00
oappend(SET_F("&CL=h"));
for (int i = 0; i < 3; i++)
{
sprintf(s,"%02X", col[i]);
oappend(s);
}
2020-09-20 01:18:31 +02:00
oappend(SET_F("&C2=h"));
for (int i = 0; i < 3; i++)
{
sprintf(s,"%02X", colSec[i]);
oappend(s);
}
2020-09-20 01:18:31 +02:00
oappend(SET_F("&FX="));
oappendi(effectCurrent);
2020-09-20 01:18:31 +02:00
oappend(SET_F("&SX="));
oappendi(effectSpeed);
2020-09-20 01:18:31 +02:00
oappend(SET_F("&IX="));
oappendi(effectIntensity);
2020-09-20 01:18:31 +02:00
oappend(SET_F("&FP="));
oappendi(effectPalette);
obuf = sbuf;
olen = 0;
2020-09-20 01:18:31 +02:00
oappend(SET_F("<html><body><a href=\""));
oappend(s2buf);
2020-09-20 01:18:31 +02:00
oappend(SET_F("\" target=\"_blank\">"));
oappend(s2buf);
2020-09-20 01:18:31 +02:00
oappend(SET_F("</a></body></html>"));
if (request != nullptr) request->send(200, "text/html", obuf);
}
//append a numeric setting to string buffer
void sappend(char stype, const char* key, int val)
{
char ds[] = "d.Sf.";
2019-08-17 12:27:06 +02:00
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);
2020-09-20 01:18:31 +02:00
oappend(SET_F(".selectedIndex="));
oappendi(val);
oappend(";");
break;
}
}
//append a string setting to buffer
void sappends(char stype, const char* key, char* val)
{
switch(stype)
{
case 's': { //string (we can interpret val as char*)
oappend("d.Sf.");
oappend(key);
oappend(".value=\"");
//convert "%" to "%%" to make EspAsyncWebServer happy
char buf[130];
uint8_t len = strlen(val) +1;
uint8_t s = 0;
for (uint8_t i = 0; i < len; i++) {
buf[i+s] = val[i];
if (val[i] == '%') {
s++; buf[i+s] = '%';
}
}
oappend(buf);
oappend("\";");
break; }
case 'm': //message
2020-09-20 01:18:31 +02:00
oappend(SET_F("d.getElementsByClassName"));
oappend(key);
2020-09-20 01:18:31 +02:00
oappend(SET_F(".innerHTML=\""));
oappend(val);
oappend("\";");
break;
}
}
2019-03-11 17:57:06 +01:00
//get values for settings form in javascript
2019-03-16 02:09:37 +01:00
void getSettingsJS(byte subPage, char* dest)
{
//0: menu 1: wifi 2: leds 3: ui 4: sync 5: time 6: sec
2020-09-20 01:18:31 +02:00
DEBUG_PRINT(F("settings resp"));
DEBUG_PRINTLN(subPage);
2019-03-16 02:09:37 +01:00
obuf = dest;
olen = 0;
2019-08-17 12:27:06 +02:00
2021-05-11 23:21:57 +02:00
if (subPage <1 || subPage >8) return;
2018-02-20 22:29:48 +01:00
if (subPage == 1) {
2020-09-20 01:18:31 +02:00
sappends('s',SET_F("CS"),clientSSID);
2018-07-21 23:21:07 +02:00
byte l = strlen(clientPass);
char fpass[l+1]; //fill password field with ***
fpass[l] = 0;
2019-08-17 12:27:06 +02:00
memset(fpass,'*',l);
2020-09-20 01:18:31 +02:00
sappends('s',SET_F("CP"),fpass);
char k[3]; k[2] = 0; //IP addresses
for (int i = 0; i<4; i++)
2018-02-20 22:29:48 +01: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
}
2020-09-20 01:18:31 +02:00
sappends('s',SET_F("CM"),cmDNS);
sappend('i',SET_F("AB"),apBehavior);
sappends('s',SET_F("AS"),apSSID);
sappend('c',SET_F("AH"),apHide);
2019-08-17 12:27:06 +02:00
2018-07-21 23:21:07 +02:00
l = strlen(apPass);
char fapass[l+1]; //fill password field with ***
fapass[l] = 0;
2019-08-17 12:27:06 +02:00
memset(fapass,'*',l);
2020-09-20 01:18:31 +02:00
sappends('s',SET_F("AP"),fapass);
2019-08-17 12:27:06 +02:00
2020-09-20 01:18:31 +02:00
sappend('v',SET_F("AC"),apChannel);
sappend('c',SET_F("WS"),noWifiSleep);
#ifdef WLED_USE_ETHERNET
sappend('v',SET_F("ETH"),ethernetType);
#else
//hide ethernet setting if not compiled in
oappend(SET_F("document.getElementById('ethd').style.display='none';"));
#endif
if (Network.isConnected()) //is connected
2018-02-20 22:29:48 +01:00
{
char s[32];
IPAddress localIP = Network.localIP();
2018-07-21 23:21:07 +02:00
sprintf(s, "%d.%d.%d.%d", localIP[0], localIP[1], localIP[2], localIP[3]);
#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_ETHERNET)
if (Network.isEthernet()) strcat_P(s ,SET_F(" (Ethernet)"));
#endif
2020-09-20 01:18:31 +02:00
sappends('m',SET_F("(\"sip\")[0]"),s);
2018-02-20 22:29:48 +01:00
} else
{
2020-09-20 01:18:31 +02:00
sappends('m',SET_F("(\"sip\")[0]"),(char*)F("Not connected"));
2018-02-20 22:29:48 +01:00
}
2019-08-17 12:27:06 +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]);
2020-09-20 01:18:31 +02:00
sappends('m',SET_F("(\"sip\")[1]"),s);
2018-02-20 22:29:48 +01:00
} else
{
2020-09-20 01:18:31 +02:00
sappends('m',SET_F("(\"sip\")[1]"),(char*)F("Not active"));
2018-02-20 22:29:48 +01:00
}
}
2019-08-17 12:27:06 +02:00
2018-02-20 22:29:48 +01:00
if (subPage == 2) {
char nS[8];
2021-01-17 00:20:31 +01:00
2021-05-20 19:54:07 +02:00
// add reserved and usermod pins as d.um_p array
DynamicJsonDocument doc(JSON_BUFFER_SIZE/2);
JsonObject mods = doc.createNestedObject(F("um"));
usermods.addToConfig(mods);
oappend(SET_F("d.um_p=["));
2021-01-17 00:20:31 +01:00
if (!mods.isNull()) {
uint8_t i=0;
for (JsonPair kv : mods) {
2021-05-20 19:54:07 +02:00
if (!kv.value().isNull()) {
// element is an JsonObject
JsonObject obj = kv.value();
if (obj["pin"] != nullptr) {
if (obj["pin"].is<JsonArray>()) {
JsonArray pins = obj["pin"].as<JsonArray>();
for (JsonVariant pv : pins) {
if (i++) oappend(SET_F(","));
oappendi(pv.as<int>());
}
} else {
if (i++) oappend(SET_F(","));
oappendi(obj["pin"].as<int>());
}
}
2021-01-17 00:20:31 +01:00
}
}
2021-05-20 19:54:07 +02:00
if (i) oappend(SET_F(","));
oappend(SET_F("6,7,8,9,10,11")); // flash memory pins
#ifdef WLED_ENABLE_DMX
oappend(SET_F(",2")); // DMX hardcoded pin
#endif
//Adalight / Serial in requires pin 3 to be unused. However, Serial input can not be prevented by WLED
2021-05-20 19:54:07 +02:00
#ifdef WLED_DEBUG
oappend(SET_F(",1")); // debug output (TX) pin
#endif
#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_PSRAM)
2021-05-20 19:54:07 +02:00
if (psramFound()) oappend(SET_F(",16,17")); // GPIO16 & GPIO17 reserved for SPI RAM
#endif
//TODO: add reservations for Ethernet shield pins
#ifdef WLED_USE_ETHERNET
#endif
}
oappend(SET_F("];"));
2021-01-17 00:20:31 +01:00
2021-05-20 19:54:07 +02:00
// set limits
oappend(SET_F("bLimits("));
2021-05-20 19:54:07 +02:00
oappend(itoa(WLED_MAX_BUSSES,nS,10)); oappend(",");
oappend(itoa(MAX_LEDS_PER_BUS,nS,10)); oappend(",");
oappend(itoa(MAX_LED_MEMORY,nS,10));
oappend(SET_F(");"));
2021-01-17 00:20:31 +01:00
2021-01-18 21:03:10 +01:00
oappend(SET_F("d.Sf.LC.max=")); //TODO Formula for max LEDs on ESP8266 depending on types. 500 DMA or 1500 UART (about 4kB mem usage)
2021-01-18 20:51:32 +01:00
oappendi(MAX_LEDS);
oappend(";");
2020-09-20 01:18:31 +02:00
sappend('v',SET_F("LC"),ledCount);
2021-05-20 19:54:07 +02:00
for (uint8_t s=0; s < busses.getNumBusses(); s++) {
Bus* bus = busses.getBus(s);
char lp[4] = "L0"; lp[2] = 48+s; lp[3] = 0; //ascii 0-9 //strip data pin
2021-01-26 00:19:41 +01:00
char lc[4] = "LC"; lc[2] = 48+s; lc[3] = 0; //strip length
char co[4] = "CO"; co[2] = 48+s; co[3] = 0; //strip color order
char lt[4] = "LT"; lt[2] = 48+s; lt[3] = 0; //strip type
char ls[4] = "LS"; ls[2] = 48+s; ls[3] = 0; //strip start LED
char cv[4] = "CV"; cv[2] = 48+s; cv[3] = 0; //strip reverse
char sl[4] = "SL"; sl[2] = 48+s; sl[3] = 0; //skip 1st LED
2021-01-17 00:20:31 +01:00
oappend(SET_F("addLEDs(1);"));
uint8_t pins[5];
uint8_t nPins = bus->getPins(pins);
for (uint8_t i = 0; i < nPins; i++) {
lp[1] = 48+i;
if (pinManager.isPinOk(pins[i])) sappend('v', lp, pins[i]);
}
sappend('v', lc, bus->getLength());
sappend('v',lt,bus->getType());
sappend('v',co,bus->getColorOrder());
2021-01-26 00:19:41 +01:00
sappend('v',ls,bus->getStart());
2021-01-31 00:38:27 +01:00
sappend('c',cv,bus->reversed);
sappend('c',sl,bus->skippedLeds());
2021-01-17 00:20:31 +01:00
}
2020-09-20 01:18:31 +02:00
sappend('v',SET_F("MA"),strip.ablMilliampsMax);
sappend('v',SET_F("LA"),strip.milliampsPerLed);
if (strip.currentMilliamps)
{
Fix Warnings (#1744) * Remove -w (Suppress all warnings, including those which GNU CPP issues by default.) and add back in -Wall (Turn on all optional warnings which are desirable for normal code.) from build_flags * Fixes warning: suggest parentheses around '+' in operand of '&' [-Wparentheses] * Fixes warning: "CONFIG_LITTLEFS_FOR_IDF_3_2" redefined * Fixes warning: format '%x' expects argument of type 'unsigned int', but argument 3 has type 'uint64_t {aka long long unsigned int}' [-Wformat=] * Fixes warning: enumeration value 'onoff' not handled in switch [-Wswitch] * Fixes warning: "ntohl" redefined, warning: "ntohs" redefined, warning: "htonl" redefined, warning: "htons" redefined - Original fix: https://github.com/blynkkk/blynk-library/commit/858f8f4ee93246c2550e3f61857681dc87ac43eb * Fixes warning: unused variable 'mainSeg' [-Wunused-variable] * Fixes warning: unused variable 'start' [-Wunused-variable] * (untested!) Fixes warning: operation on '...' may be undefined [-Wsequence-point] * Fixes warning: unused variable * Fixes warning: unused variable and warning: narrowing conversion * Fixes warning: unused variable * Fixes warning: unused variable * (untested!) Fixes warning: statement has no effect [-Wunused-value] * Fixes warning: control reaches end of non-void function * Fixes warning: unused variable * Fixes warning: left operand of comma operator has no effect * Fixes warning: no return statement in function returning non-void * (untested!) Fixes warning: ISO C++ forbids converting a string constant to 'char*' and fixes warning: unused variable 'nPins' * Fixes warning: deleting array 'dmxData' * Fixes warning: unused variable * Remove all warning suppression buildflags Co-authored-by: Louis Beaudoin <louis@embedded-creations.com> Co-authored-by: Aircoookie <dev.aircoookie@gmail.com>
2021-02-27 00:20:31 +01:00
sappends('m',SET_F("(\"pow\")[0]"),(char*)"");
olen -= 2; //delete ";
oappendi(strip.currentMilliamps);
2020-09-20 01:18:31 +02:00
oappend(SET_F("mA\";"));
}
2020-09-20 01:18:31 +02:00
sappend('v',SET_F("CA"),briS);
sappend('v',SET_F("AW"),strip.rgbwMode);
sappend('c',SET_F("BO"),turnOnAtBoot);
sappend('v',SET_F("BP"),bootPreset);
sappend('c',SET_F("GB"),strip.gammaCorrectBri);
sappend('c',SET_F("GC"),strip.gammaCorrectCol);
sappend('c',SET_F("TF"),fadeTransition);
sappend('v',SET_F("TD"),transitionDelayDefault);
sappend('c',SET_F("PF"),strip.paletteFade);
sappend('v',SET_F("BF"),briMultiplier);
sappend('v',SET_F("TB"),nightlightTargetBri);
sappend('v',SET_F("TL"),nightlightDelayMinsDefault);
sappend('v',SET_F("TW"),nightlightMode);
sappend('i',SET_F("PB"),strip.paletteBlend);
2021-01-17 00:20:31 +01:00
sappend('v',SET_F("RL"),rlyPin);
sappend('c',SET_F("RM"),rlyMde);
2021-05-20 19:54:07 +02:00
for (uint8_t i=0; i<WLED_MAX_BUTTONS; i++) {
oappend(SET_F("addBtn("));
oappend(itoa(i,nS,10)); oappend(",");
oappend(itoa(btnPin[i],nS,10)); oappend(",");
oappend(itoa(buttonType[i],nS,10));
oappend(SET_F(");"));
}
sappend('v',SET_F("TT"),touchThreshold);
2021-01-17 00:20:31 +01:00
sappend('v',SET_F("IR"),irPin);
2021-05-20 19:54:07 +02:00
sappend('v',SET_F("IT"),irEnabled);
}
2018-02-20 22:29:48 +01:00
if (subPage == 3)
2019-08-17 12:27:06 +02:00
{
2020-09-20 01:18:31 +02:00
sappends('s',SET_F("DS"),serverDescription);
sappend('c',SET_F("ST"),syncToggleReceive);
}
2018-02-20 22:29:48 +01:00
if (subPage == 4)
{
2020-09-20 01:18:31 +02:00
sappend('v',SET_F("UP"),udpPort);
sappend('v',SET_F("U2"),udpPort2);
2020-09-20 01:18:31 +02:00
sappend('c',SET_F("RB"),receiveNotificationBrightness);
sappend('c',SET_F("RC"),receiveNotificationColor);
sappend('c',SET_F("RX"),receiveNotificationEffects);
sappend('c',SET_F("SD"),notifyDirectDefault);
sappend('c',SET_F("SB"),notifyButton);
sappend('c',SET_F("SH"),notifyHue);
sappend('c',SET_F("SM"),notifyMacro);
sappend('c',SET_F("S2"),notifyTwice);
sappend('c',SET_F("NL"),nodeListEnabled);
sappend('c',SET_F("NB"),nodeBroadcastEnabled);
2020-09-20 01:18:31 +02:00
sappend('c',SET_F("RD"),receiveDirect);
sappend('v',SET_F("EP"),e131Port);
sappend('c',SET_F("ES"),e131SkipOutOfSequence);
sappend('c',SET_F("EM"),e131Multicast);
sappend('v',SET_F("EU"),e131Universe);
sappend('v',SET_F("DA"),DMXAddress);
sappend('v',SET_F("DM"),DMXMode);
sappend('v',SET_F("ET"),realtimeTimeoutMs);
sappend('c',SET_F("FB"),arlsForceMaxBri);
sappend('c',SET_F("RG"),arlsDisableGammaCorrection);
sappend('v',SET_F("WO"),arlsOffset);
sappend('c',SET_F("AL"),alexaEnabled);
sappends('s',SET_F("AI"),alexaInvocationName);
sappend('c',SET_F("SA"),notifyAlexa);
sappends('s',SET_F("BK"),(char*)((blynkEnabled)?SET_F("Hidden"):""));
2021-05-20 19:54:07 +02:00
#ifndef WLED_DISABLE_BLYNK
sappends('s',SET_F("BH"),blynkHost);
sappend('v',SET_F("BP"),blynkPort);
2021-05-20 19:54:07 +02:00
#endif
#ifdef WLED_ENABLE_MQTT
2020-09-20 01:18:31 +02:00
sappend('c',SET_F("MQ"),mqttEnabled);
sappends('s',SET_F("MS"),mqttServer);
sappend('v',SET_F("MQPORT"),mqttPort);
sappends('s',SET_F("MQUSER"),mqttUser);
byte l = strlen(mqttPass);
char fpass[l+1]; //fill password field with ***
fpass[l] = 0;
memset(fpass,'*',l);
2020-09-20 01:18:31 +02:00
sappends('s',SET_F("MQPASS"),fpass);
sappends('s',SET_F("MQCID"),mqttClientID);
sappends('s',SET_F("MD"),mqttDeviceTopic);
sappends('s',SET_F("MG"),mqttGroupTopic);
2021-07-01 20:51:52 +02:00
sappend('c',SET_F("BM"),buttonPublishMqtt);
#endif
#ifndef WLED_DISABLE_HUESYNC
2020-09-20 01:18:31 +02:00
sappend('v',SET_F("H0"),hueIP[0]);
sappend('v',SET_F("H1"),hueIP[1]);
sappend('v',SET_F("H2"),hueIP[2]);
sappend('v',SET_F("H3"),hueIP[3]);
sappend('v',SET_F("HL"),huePollLightId);
sappend('v',SET_F("HI"),huePollIntervalMs);
sappend('c',SET_F("HP"),huePollingEnabled);
sappend('c',SET_F("HO"),hueApplyOnOff);
sappend('c',SET_F("HB"),hueApplyBri);
sappend('c',SET_F("HC"),hueApplyColor);
char hueErrorString[25];
switch (hueError)
{
case HUE_ERROR_INACTIVE : strcpy(hueErrorString,(char*)F("Inactive")); break;
case HUE_ERROR_ACTIVE : strcpy(hueErrorString,(char*)F("Active")); break;
case HUE_ERROR_UNAUTHORIZED : strcpy(hueErrorString,(char*)F("Unauthorized")); break;
case HUE_ERROR_LIGHTID : strcpy(hueErrorString,(char*)F("Invalid light ID")); break;
case HUE_ERROR_PUSHLINK : strcpy(hueErrorString,(char*)F("Link button not pressed")); break;
case HUE_ERROR_JSON_PARSING : strcpy(hueErrorString,(char*)F("JSON parsing error")); break;
case HUE_ERROR_TIMEOUT : strcpy(hueErrorString,(char*)F("Timeout")); break;
2020-09-20 01:18:31 +02:00
default: sprintf(hueErrorString,(char*)F("Bridge Error %i"),hueError);
}
2020-09-20 01:18:31 +02:00
sappends('m',SET_F("(\"sip\")[0]"),hueErrorString);
#endif
}
2018-02-20 22:29:48 +01:00
if (subPage == 5)
{
2020-09-20 01:18:31 +02:00
sappend('c',SET_F("NT"),ntpEnabled);
sappends('s',SET_F("NS"),ntpServerName);
sappend('c',SET_F("CF"),!useAMPM);
sappend('i',SET_F("TZ"),currentTimezone);
sappend('v',SET_F("UO"),utcOffsetSecs);
2019-03-16 02:09:37 +01:00
char tm[32];
dtostrf(longitude,4,2,tm);
sappends('s',SET_F("LN"),tm);
dtostrf(latitude,4,2,tm);
sappends('s',SET_F("LT"),tm);
2019-08-17 12:27:06 +02:00
getTimeString(tm);
2020-09-20 01:18:31 +02:00
sappends('m',SET_F("(\"times\")[0]"),tm);
if ((int)(longitude*10.) || (int)(latitude*10.)) {
sprintf_P(tm, PSTR("Sunrise: %02d:%02d Sunset: %02d:%02d"), hour(sunrise), minute(sunrise), hour(sunset), minute(sunset));
sappends('m',SET_F("(\"times\")[1]"),tm);
}
2020-09-20 01:18:31 +02:00
sappend('i',SET_F("OL"),overlayCurrent);
sappend('v',SET_F("O1"),overlayMin);
sappend('v',SET_F("O2"),overlayMax);
sappend('v',SET_F("OM"),analogClock12pixel);
sappend('c',SET_F("OS"),analogClockSecondsTrail);
sappend('c',SET_F("O5"),analogClock5MinuteMarks);
2021-05-20 19:54:07 +02:00
#ifndef WLED_DISABLE_CRONIXIE
2020-09-20 01:18:31 +02:00
sappends('s',SET_F("CX"),cronixieDisplay);
sappend('c',SET_F("CB"),cronixieBacklight);
2021-05-20 19:54:07 +02:00
#endif
2020-09-20 01:18:31 +02:00
sappend('c',SET_F("CE"),countdownMode);
sappend('v',SET_F("CY"),countdownYear);
sappend('v',SET_F("CI"),countdownMonth);
sappend('v',SET_F("CD"),countdownDay);
sappend('v',SET_F("CH"),countdownHour);
sappend('v',SET_F("CM"),countdownMin);
sappend('v',SET_F("CS"),countdownSec);
2019-08-17 12:27:06 +02:00
2020-09-20 01:18:31 +02:00
sappend('v',SET_F("A0"),macroAlexaOn);
sappend('v',SET_F("A1"),macroAlexaOff);
sappend('v',SET_F("MC"),macroCountdown);
sappend('v',SET_F("MN"),macroNl);
2021-05-20 19:54:07 +02:00
for (uint8_t i=0; i<WLED_MAX_BUTTONS; i++) {
oappend(SET_F("addRow("));
oappend(itoa(i,tm,10)); oappend(",");
oappend(itoa(macroButton[i],tm,10)); oappend(",");
oappend(itoa(macroLongPress[i],tm,10)); oappend(",");
oappend(itoa(macroDoublePress[i],tm,10));
oappend(SET_F(");"));
}
2020-11-06 22:12:48 +01:00
char k[4];
k[2] = 0; //Time macros
for (int i = 0; i<10; i++)
{
k[1] = 48+i; //ascii 0,1,2,3
if (i<8) { k[0] = 'H'; sappend('v',k,timerHours[i]); }
k[0] = 'N'; sappend('v',k,timerMinutes[i]);
k[0] = 'T'; sappend('v',k,timerMacro[i]);
2019-01-31 00:09:44 +01:00
k[0] = 'W'; sappend('v',k,timerWeekday[i]);
}
2018-02-20 22:29:48 +01:00
}
if (subPage == 6)
{
2020-09-20 01:18:31 +02:00
sappend('c',SET_F("NO"),otaLock);
sappend('c',SET_F("OW"),wifiLock);
sappend('c',SET_F("AO"),aOtaEnabled);
sappends('m',SET_F("(\"sip\")[0]"),(char*)F("WLED "));
olen -= 2; //delete ";
oappend(versionString);
2020-09-20 01:18:31 +02:00
oappend(SET_F(" (build "));
oappendi(VERSION);
2020-09-20 01:18:31 +02:00
oappend(SET_F(")\";"));
}
#ifdef WLED_ENABLE_DMX // include only if DMX is enabled
if (subPage == 7)
{
2020-09-20 01:18:31 +02:00
sappend('v',SET_F("PU"),e131ProxyUniverse);
2020-09-20 01:18:31 +02:00
sappend('v',SET_F("CN"),DMXChannels);
sappend('v',SET_F("CG"),DMXGap);
sappend('v',SET_F("CS"),DMXStart);
sappend('v',SET_F("SL"),DMXStartLED);
2020-09-20 01:18:31 +02:00
sappend('i',SET_F("CH1"),DMXFixtureMap[0]);
sappend('i',SET_F("CH2"),DMXFixtureMap[1]);
sappend('i',SET_F("CH3"),DMXFixtureMap[2]);
sappend('i',SET_F("CH4"),DMXFixtureMap[3]);
sappend('i',SET_F("CH5"),DMXFixtureMap[4]);
sappend('i',SET_F("CH6"),DMXFixtureMap[5]);
sappend('i',SET_F("CH7"),DMXFixtureMap[6]);
sappend('i',SET_F("CH8"),DMXFixtureMap[7]);
sappend('i',SET_F("CH9"),DMXFixtureMap[8]);
sappend('i',SET_F("CH10"),DMXFixtureMap[9]);
sappend('i',SET_F("CH11"),DMXFixtureMap[10]);
sappend('i',SET_F("CH12"),DMXFixtureMap[11]);
sappend('i',SET_F("CH13"),DMXFixtureMap[12]);
sappend('i',SET_F("CH14"),DMXFixtureMap[13]);
sappend('i',SET_F("CH15"),DMXFixtureMap[14]);
2021-05-11 23:21:57 +02:00
}
#endif
2021-05-11 23:21:57 +02:00
if (subPage == 8) //usermods
{
oappend(SET_F("numM="));
oappendi(usermods.getModCount());
oappend(";");
}
2020-09-20 01:18:31 +02:00
oappend(SET_F("}</script>"));
}