Added options for Auto Node discovery

Optimized strings (no string both F() and raw)
This commit is contained in:
cschwinne 2021-03-13 22:04:37 +01:00
parent 3460f9d9cc
commit 26096bc136
15 changed files with 2215 additions and 2180 deletions

View File

@ -2,6 +2,11 @@
### Development versions after 0.11.1 release ### Development versions after 0.11.1 release
#### Build 2103130
- Added options for Auto Node discovery
- Optimized strings (no string both F() and raw)
#### Build 2103090 #### Build 2103090
- Added Auto Node discovery (PR #1683) - Added Auto Node discovery (PR #1683)

View File

@ -35,7 +35,7 @@ void deserializeConfig() {
//long vid = doc[F("vid")]; // 2010020 //long vid = doc[F("vid")]; // 2010020
JsonObject id = doc[F("id")]; JsonObject id = doc["id"];
getStringFromJson(cmDNS, id[F("mdns")], 33); getStringFromJson(cmDNS, id[F("mdns")], 33);
getStringFromJson(serverDescription, id[F("name")], 33); getStringFromJson(serverDescription, id[F("name")], 33);
getStringFromJson(alexaInvocationName, id[F("inv")], 33); getStringFromJson(alexaInvocationName, id[F("inv")], 33);
@ -47,9 +47,9 @@ void deserializeConfig() {
//If it is present however, we will use it //If it is present however, we will use it
getStringFromJson(clientPass, nw_ins_0["psk"], 65); getStringFromJson(clientPass, nw_ins_0["psk"], 65);
JsonArray nw_ins_0_ip = nw_ins_0[F("ip")]; JsonArray nw_ins_0_ip = nw_ins_0["ip"];
JsonArray nw_ins_0_gw = nw_ins_0[F("gw")]; JsonArray nw_ins_0_gw = nw_ins_0["gw"];
JsonArray nw_ins_0_sn = nw_ins_0[F("sn")]; JsonArray nw_ins_0_sn = nw_ins_0["sn"];
for (byte i = 0; i < 4; i++) { for (byte i = 0; i < 4; i++) {
CJSON(staticIP[i], nw_ins_0_ip[i]); CJSON(staticIP[i], nw_ins_0_ip[i]);
@ -57,7 +57,7 @@ void deserializeConfig() {
CJSON(staticSubnet[i], nw_ins_0_sn[i]); CJSON(staticSubnet[i], nw_ins_0_sn[i]);
} }
JsonObject ap = doc[F("ap")]; JsonObject ap = doc["ap"];
getStringFromJson(apSSID, ap[F("ssid")], 33); getStringFromJson(apSSID, ap[F("ssid")], 33);
getStringFromJson(apPass, ap["psk"] , 65); //normally not present due to security getStringFromJson(apPass, ap["psk"] , 65); //normally not present due to security
//int ap_pskl = ap[F("pskl")]; //int ap_pskl = ap[F("pskl")];
@ -72,11 +72,11 @@ void deserializeConfig() {
#ifdef WLED_USE_ETHERNET #ifdef WLED_USE_ETHERNET
JsonObject ethernet = doc[F("eth")]; JsonObject ethernet = doc[F("eth")];
CJSON(ethernetType, ethernet[F("type")]); CJSON(ethernetType, ethernet["type"]);
#endif #endif
/* /*
JsonArray ap_ip = ap[F("ip")]; JsonArray ap_ip = ap["ip"];
for (byte i = 0; i < 4; i++) { for (byte i = 0; i < 4; i++) {
apIP[i] = ap_ip; apIP[i] = ap_ip;
}*/ }*/
@ -125,7 +125,7 @@ void deserializeConfig() {
if (start >= ledCount) continue; if (start >= ledCount) continue;
//limit length of strip if it would exceed total configured LEDs //limit length of strip if it would exceed total configured LEDs
if (start + length > ledCount) length = ledCount - start; if (start + length > ledCount) length = ledCount - start;
uint8_t ledType = elm[F("type")] | TYPE_WS2812_RGB; uint8_t ledType = elm["type"] | TYPE_WS2812_RGB;
bool reversed = elm["rev"]; bool reversed = elm["rev"];
//RGBW mode is enabled if at least one of the strips is RGBW //RGBW mode is enabled if at least one of the strips is RGBW
useRGBW = (useRGBW || BusManager::isRgbw(ledType)); useRGBW = (useRGBW || BusManager::isRgbw(ledType));
@ -137,7 +137,7 @@ void deserializeConfig() {
strip.finalizeInit(useRGBW, ledCount, skipFirstLed); strip.finalizeInit(useRGBW, ledCount, skipFirstLed);
JsonObject hw_btn_ins_0 = hw[F("btn")][F("ins")][0]; JsonObject hw_btn_ins_0 = hw[F("btn")][F("ins")][0];
CJSON(buttonEnabled, hw_btn_ins_0[F("type")]); CJSON(buttonEnabled, hw_btn_ins_0["type"]);
int hw_btn_pin = hw_btn_ins_0[F("pin")][0]; int hw_btn_pin = hw_btn_ins_0[F("pin")][0];
if (pinManager.allocatePin(hw_btn_pin,false)) { if (pinManager.allocatePin(hw_btn_pin,false)) {
btnPin = hw_btn_pin; btnPin = hw_btn_pin;
@ -151,21 +151,21 @@ void deserializeConfig() {
CJSON(macroLongPress,hw_btn_ins_0_macros[1]); CJSON(macroLongPress,hw_btn_ins_0_macros[1]);
CJSON(macroDoublePress, hw_btn_ins_0_macros[2]); CJSON(macroDoublePress, hw_btn_ins_0_macros[2]);
//int hw_btn_ins_0_type = hw_btn_ins_0[F("type")]; // 0 //int hw_btn_ins_0_type = hw_btn_ins_0["type"]; // 0
#ifndef WLED_DISABLE_INFRARED #ifndef WLED_DISABLE_INFRARED
int hw_ir_pin = hw[F("ir")][F("pin")]; // 4 int hw_ir_pin = hw["ir"]["pin"]; // 4
if (pinManager.allocatePin(hw_ir_pin,false)) { if (pinManager.allocatePin(hw_ir_pin,false)) {
irPin = hw_ir_pin; irPin = hw_ir_pin;
} else { } else {
irPin = -1; irPin = -1;
} }
#endif #endif
CJSON(irEnabled, hw[F("ir")][F("type")]); CJSON(irEnabled, hw["ir"]["type"]);
JsonObject relay = hw[F("relay")]; JsonObject relay = hw[F("relay")];
int hw_relay_pin = relay[F("pin")]; int hw_relay_pin = relay["pin"];
if (pinManager.allocatePin(hw_relay_pin,true)) { if (pinManager.allocatePin(hw_relay_pin,true)) {
rlyPin = hw_relay_pin; rlyPin = hw_relay_pin;
pinMode(rlyPin, OUTPUT); pinMode(rlyPin, OUTPUT);
@ -183,7 +183,7 @@ void deserializeConfig() {
CJSON(strip.paletteBlend, light[F("pal-mode")]); CJSON(strip.paletteBlend, light[F("pal-mode")]);
float light_gc_bri = light[F("gc")]["bri"]; float light_gc_bri = light[F("gc")]["bri"];
float light_gc_col = light[F("gc")][F("col")]; // 2.8 float light_gc_col = light[F("gc")]["col"]; // 2.8
if (light_gc_bri > 1.5) strip.gammaCorrectBri = true; if (light_gc_bri > 1.5) strip.gammaCorrectBri = true;
else if (light_gc_bri > 0.5) strip.gammaCorrectBri = false; else if (light_gc_bri > 0.5) strip.gammaCorrectBri = false;
if (light_gc_col > 1.5) strip.gammaCorrectCol = true; if (light_gc_col > 1.5) strip.gammaCorrectCol = true;
@ -223,13 +223,13 @@ void deserializeConfig() {
CJSON(udpPort, if_sync[F("port0")]); // 21324 CJSON(udpPort, if_sync[F("port0")]); // 21324
CJSON(udpPort2, if_sync[F("port1")]); // 65506 CJSON(udpPort2, if_sync[F("port1")]); // 65506
JsonObject if_sync_recv = if_sync[F("recv")]; JsonObject if_sync_recv = if_sync["recv"];
CJSON(receiveNotificationBrightness, if_sync_recv["bri"]); CJSON(receiveNotificationBrightness, if_sync_recv["bri"]);
CJSON(receiveNotificationColor, if_sync_recv[F("col")]); CJSON(receiveNotificationColor, if_sync_recv["col"]);
CJSON(receiveNotificationEffects, if_sync_recv[F("fx")]); CJSON(receiveNotificationEffects, if_sync_recv[F("fx")]);
receiveNotifications = (receiveNotificationBrightness || receiveNotificationColor || receiveNotificationEffects); receiveNotifications = (receiveNotificationBrightness || receiveNotificationColor || receiveNotificationEffects);
JsonObject if_sync_send = if_sync[F("send")]; JsonObject if_sync_send = if_sync["send"];
CJSON(notifyDirectDefault, if_sync_send[F("dir")]); CJSON(notifyDirectDefault, if_sync_send[F("dir")]);
notifyDirect = notifyDirectDefault; notifyDirect = notifyDirectDefault;
CJSON(notifyButton, if_sync_send[F("btn")]); CJSON(notifyButton, if_sync_send[F("btn")]);
@ -238,9 +238,13 @@ void deserializeConfig() {
CJSON(notifyMacro, if_sync_send[F("macro")]); CJSON(notifyMacro, if_sync_send[F("macro")]);
CJSON(notifyTwice, if_sync_send[F("twice")]); CJSON(notifyTwice, if_sync_send[F("twice")]);
JsonObject if_live = interfaces[F("live")]; JsonObject if_nodes = interfaces["nodes"];
CJSON(receiveDirect, if_live[F("en")]); CJSON(nodeListEnabled, if_nodes[F("list")]);
CJSON(e131Port, if_live[F("port")]); // 5568 CJSON(nodeBroadcastEnabled, if_nodes[F("bcast")]);
JsonObject if_live = interfaces["live"];
CJSON(receiveDirect, if_live["en"]);
CJSON(e131Port, if_live["port"]); // 5568
CJSON(e131Multicast, if_live[F("mc")]); CJSON(e131Multicast, if_live[F("mc")]);
JsonObject if_live_dmx = if_live[F("dmx")]; JsonObject if_live_dmx = if_live[F("dmx")];
@ -260,19 +264,19 @@ void deserializeConfig() {
CJSON(macroAlexaOn, interfaces[F("va")][F("macros")][0]); CJSON(macroAlexaOn, interfaces[F("va")][F("macros")][0]);
CJSON(macroAlexaOff, interfaces[F("va")][F("macros")][1]); CJSON(macroAlexaOff, interfaces[F("va")][F("macros")][1]);
const char* apikey = interfaces[F("blynk")][F("token")] | "Hidden"; const char* apikey = interfaces["blynk"][F("token")] | "Hidden";
tdd = strnlen(apikey, 36); tdd = strnlen(apikey, 36);
if (tdd > 20 || tdd == 0) if (tdd > 20 || tdd == 0)
getStringFromJson(blynkApiKey, apikey, 36); //normally not present due to security getStringFromJson(blynkApiKey, apikey, 36); //normally not present due to security
JsonObject if_blynk = interfaces[F("blynk")]; JsonObject if_blynk = interfaces["blynk"];
getStringFromJson(blynkHost, if_blynk[F("host")], 33); getStringFromJson(blynkHost, if_blynk[F("host")], 33);
CJSON(blynkPort, if_blynk[F("port")]); CJSON(blynkPort, if_blynk["port"]);
JsonObject if_mqtt = interfaces[F("mqtt")]; JsonObject if_mqtt = interfaces["mqtt"];
CJSON(mqttEnabled, if_mqtt[F("en")]); CJSON(mqttEnabled, if_mqtt["en"]);
getStringFromJson(mqttServer, if_mqtt[F("broker")], 33); getStringFromJson(mqttServer, if_mqtt[F("broker")], 33);
CJSON(mqttPort, if_mqtt[F("port")]); // 1883 CJSON(mqttPort, if_mqtt["port"]); // 1883
getStringFromJson(mqttUser, if_mqtt[F("user")], 41); getStringFromJson(mqttUser, if_mqtt[F("user")], 41);
getStringFromJson(mqttPass, if_mqtt["psk"], 41); //normally not present due to security getStringFromJson(mqttPass, if_mqtt["psk"], 41); //normally not present due to security
getStringFromJson(mqttClientID, if_mqtt[F("cid")], 41); getStringFromJson(mqttClientID, if_mqtt[F("cid")], 41);
@ -281,23 +285,23 @@ void deserializeConfig() {
getStringFromJson(mqttGroupTopic, if_mqtt[F("topics")][F("group")], 33); // "" getStringFromJson(mqttGroupTopic, if_mqtt[F("topics")][F("group")], 33); // ""
JsonObject if_hue = interfaces[F("hue")]; JsonObject if_hue = interfaces[F("hue")];
CJSON(huePollingEnabled, if_hue[F("en")]); CJSON(huePollingEnabled, if_hue["en"]);
CJSON(huePollLightId, if_hue[F("id")]); CJSON(huePollLightId, if_hue["id"]);
tdd = if_hue[F("iv")] | -1; tdd = if_hue[F("iv")] | -1;
if (tdd >= 2) huePollIntervalMs = tdd * 100; if (tdd >= 2) huePollIntervalMs = tdd * 100;
JsonObject if_hue_recv = if_hue[F("recv")]; JsonObject if_hue_recv = if_hue["recv"];
CJSON(hueApplyOnOff, if_hue_recv["on"]); CJSON(hueApplyOnOff, if_hue_recv["on"]);
CJSON(hueApplyBri, if_hue_recv["bri"]); CJSON(hueApplyBri, if_hue_recv["bri"]);
CJSON(hueApplyColor, if_hue_recv[F("col")]); CJSON(hueApplyColor, if_hue_recv["col"]);
JsonArray if_hue_ip = if_hue[F("ip")]; JsonArray if_hue_ip = if_hue["ip"];
for (byte i = 0; i < 4; i++) for (byte i = 0; i < 4; i++)
CJSON(hueIP[i], if_hue_ip[i]); CJSON(hueIP[i], if_hue_ip[i]);
JsonObject if_ntp = interfaces[F("ntp")]; JsonObject if_ntp = interfaces[F("ntp")];
CJSON(ntpEnabled, if_ntp[F("en")]); CJSON(ntpEnabled, if_ntp["en"]);
getStringFromJson(ntpServerName, if_ntp[F("host")], 33); // "1.wled.pool.ntp.org" getStringFromJson(ntpServerName, if_ntp[F("host")], 33); // "1.wled.pool.ntp.org"
CJSON(currentTimezone, if_ntp[F("tz")]); CJSON(currentTimezone, if_ntp[F("tz")]);
CJSON(utcOffsetSecs, if_ntp[F("offset")]); CJSON(utcOffsetSecs, if_ntp[F("offset")]);
@ -342,7 +346,7 @@ void deserializeConfig() {
CJSON(timerWeekday[it], timer[F("dow")]); CJSON(timerWeekday[it], timer[F("dow")]);
if (timerWeekday[it] != dowPrev) { //present in JSON if (timerWeekday[it] != dowPrev) { //present in JSON
timerWeekday[it] <<= 1; //add active bit timerWeekday[it] <<= 1; //add active bit
int act = timer[F("en")] | actPrev; int act = timer["en"] | actPrev;
if (act) timerWeekday[it]++; if (act) timerWeekday[it]++;
} }
@ -389,7 +393,6 @@ void serializeConfig() {
DynamicJsonDocument doc(JSON_BUFFER_SIZE); DynamicJsonDocument doc(JSON_BUFFER_SIZE);
//{ //scope this to reduce stack size
JsonArray rev = doc.createNestedArray("rev"); JsonArray rev = doc.createNestedArray("rev");
rev.add(1); //major settings revision rev.add(1); //major settings revision
rev.add(0); //minor settings revision rev.add(0); //minor settings revision
@ -438,7 +441,7 @@ void serializeConfig() {
#ifdef WLED_USE_ETHERNET #ifdef WLED_USE_ETHERNET
JsonObject ethernet = doc.createNestedObject("eth"); JsonObject ethernet = doc.createNestedObject("eth");
ethernet[F("type")] = ethernetType; ethernet["type"] = ethernetType;
#endif #endif
JsonObject hw = doc.createNestedObject("hw"); JsonObject hw = doc.createNestedObject("hw");
@ -456,7 +459,7 @@ void serializeConfig() {
Bus *bus = busses.getBus(s); Bus *bus = busses.getBus(s);
if (!bus || bus->getLength()==0) break; if (!bus || bus->getLength()==0) break;
JsonObject ins = hw_led_ins.createNestedObject(); JsonObject ins = hw_led_ins.createNestedObject();
ins[F("en")] = true; ins["en"] = true;
ins[F("start")] = bus->getStart(); ins[F("start")] = bus->getStart();
ins[F("len")] = bus->getLength(); ins[F("len")] = bus->getLength();
JsonArray ins_pin = ins.createNestedArray("pin"); JsonArray ins_pin = ins.createNestedArray("pin");
@ -466,7 +469,7 @@ void serializeConfig() {
ins[F("order")] = bus->getColorOrder(); ins[F("order")] = bus->getColorOrder();
ins["rev"] = bus->reversed; ins["rev"] = bus->reversed;
ins[F("skip")] = (skipFirstLed && s == 0) ? 1 : 0; ins[F("skip")] = (skipFirstLed && s == 0) ? 1 : 0;
ins[F("type")] = bus->getType(); ins["type"] = bus->getType();
} }
JsonObject hw_btn = hw.createNestedObject("btn"); JsonObject hw_btn = hw.createNestedObject("btn");
@ -475,7 +478,7 @@ void serializeConfig() {
// button BTNPIN // button BTNPIN
JsonObject hw_btn_ins_0 = hw_btn_ins.createNestedObject(); JsonObject hw_btn_ins_0 = hw_btn_ins.createNestedObject();
hw_btn_ins_0[F("type")] = (buttonEnabled) ? BTN_TYPE_PUSH : BTN_TYPE_NONE; hw_btn_ins_0["type"] = (buttonEnabled) ? BTN_TYPE_PUSH : BTN_TYPE_NONE;
JsonArray hw_btn_ins_0_pin = hw_btn_ins_0.createNestedArray("pin"); JsonArray hw_btn_ins_0_pin = hw_btn_ins_0.createNestedArray("pin");
hw_btn_ins_0_pin.add(btnPin); hw_btn_ins_0_pin.add(btnPin);
@ -488,28 +491,28 @@ void serializeConfig() {
#ifndef WLED_DISABLE_INFRARED #ifndef WLED_DISABLE_INFRARED
if (irPin>=0) { if (irPin>=0) {
JsonObject hw_ir = hw.createNestedObject("ir"); JsonObject hw_ir = hw.createNestedObject("ir");
hw_ir[F("pin")] = irPin; hw_ir["pin"] = irPin;
hw_ir[F("type")] = irEnabled; // the byte 'irEnabled' does contain the IR-Remote Type ( 0=disabled ) hw_ir[F("type"] = irEnabled; // the byte 'irEnabled' does contain the IR-Remote Type ( 0=disabled )
} }
#endif #endif
JsonObject hw_relay = hw.createNestedObject("relay"); JsonObject hw_relay = hw.createNestedObject(F("relay"));
hw_relay[F("pin")] = rlyPin; hw_relay["pin"] = rlyPin;
hw_relay["rev"] = !rlyMde; hw_relay["rev"] = !rlyMde;
//JsonObject hw_status = hw.createNestedObject("status"); //JsonObject hw_status = hw.createNestedObject("status");
//hw_status[F("pin")] = -1; //hw_status["pin"] = -1;
JsonObject hw_aux = hw.createNestedObject("aux"); JsonObject hw_aux = hw.createNestedObject("aux");
hw_aux[F("pin")] = auxPin; hw_aux["pin"] = auxPin;
JsonObject light = doc.createNestedObject("light"); JsonObject light = doc.createNestedObject(F("light"));
light[F("scale-bri")] = briMultiplier; light[F("scale-bri")] = briMultiplier;
light[F("pal-mode")] = strip.paletteBlend; light[F("pal-mode")] = strip.paletteBlend;
JsonObject light_gc = light.createNestedObject("gc"); JsonObject light_gc = light.createNestedObject("gc");
light_gc["bri"] = (strip.gammaCorrectBri) ? 2.8 : 1.0; light_gc["bri"] = (strip.gammaCorrectBri) ? 2.8 : 1.0;
light_gc[F("col")] = (strip.gammaCorrectCol) ? 2.8 : 1.0; light_gc["col"] = (strip.gammaCorrectCol) ? 2.8 : 1.0;
JsonObject light_tr = light.createNestedObject("tr"); JsonObject light_tr = light.createNestedObject("tr");
light_tr[F("mode")] = fadeTransition; light_tr[F("mode")] = fadeTransition;
@ -532,7 +535,7 @@ void serializeConfig() {
JsonObject def_cy = def.createNestedObject("cy"); JsonObject def_cy = def.createNestedObject("cy");
def_cy["on"] = presetCyclingEnabled; def_cy["on"] = presetCyclingEnabled;
JsonArray def_cy_range = def_cy.createNestedArray("range"); JsonArray def_cy_range = def_cy.createNestedArray(F("range"));
def_cy_range.add(presetCycleMin); def_cy_range.add(presetCycleMin);
def_cy_range.add(presetCycleMax); def_cy_range.add(presetCycleMax);
def_cy[F("dur")] = presetCycleTime; def_cy[F("dur")] = presetCycleTime;
@ -546,7 +549,7 @@ void serializeConfig() {
JsonObject if_sync_recv = if_sync.createNestedObject("recv"); JsonObject if_sync_recv = if_sync.createNestedObject("recv");
if_sync_recv["bri"] = receiveNotificationBrightness; if_sync_recv["bri"] = receiveNotificationBrightness;
if_sync_recv[F("col")] = receiveNotificationColor; if_sync_recv["col"] = receiveNotificationColor;
if_sync_recv[F("fx")] = receiveNotificationEffects; if_sync_recv[F("fx")] = receiveNotificationEffects;
JsonObject if_sync_send = if_sync.createNestedObject("send"); JsonObject if_sync_send = if_sync.createNestedObject("send");
@ -557,9 +560,13 @@ void serializeConfig() {
if_sync_send[F("macro")] = notifyMacro; if_sync_send[F("macro")] = notifyMacro;
if_sync_send[F("twice")] = notifyTwice; if_sync_send[F("twice")] = notifyTwice;
JsonObject if_nodes = interfaces.createNestedObject("nodes");
if_nodes[F("list")] = nodeListEnabled;
if_nodes[F("bcast")] = nodeBroadcastEnabled;
JsonObject if_live = interfaces.createNestedObject("live"); JsonObject if_live = interfaces.createNestedObject("live");
if_live[F("en")] = receiveDirect; if_live["en"] = receiveDirect;
if_live[F("port")] = e131Port; if_live["port"] = e131Port;
if_live[F("mc")] = e131Multicast; if_live[F("mc")] = e131Multicast;
JsonObject if_live_dmx = if_live.createNestedObject("dmx"); JsonObject if_live_dmx = if_live.createNestedObject("dmx");
@ -581,29 +588,29 @@ void serializeConfig() {
JsonObject if_blynk = interfaces.createNestedObject("blynk"); JsonObject if_blynk = interfaces.createNestedObject("blynk");
if_blynk[F("token")] = strlen(blynkApiKey) ? "Hidden":""; if_blynk[F("token")] = strlen(blynkApiKey) ? "Hidden":"";
if_blynk[F("host")] = blynkHost; if_blynk[F("host")] = blynkHost;
if_blynk[F("port")] = blynkPort; if_blynk["port"] = blynkPort;
JsonObject if_mqtt = interfaces.createNestedObject("mqtt"); JsonObject if_mqtt = interfaces.createNestedObject("mqtt");
if_mqtt[F("en")] = mqttEnabled; if_mqtt["en"] = mqttEnabled;
if_mqtt[F("broker")] = mqttServer; if_mqtt[F("broker")] = mqttServer;
if_mqtt[F("port")] = mqttPort; if_mqtt["port"] = mqttPort;
if_mqtt[F("user")] = mqttUser; if_mqtt[F("user")] = mqttUser;
if_mqtt[F("pskl")] = strlen(mqttPass); if_mqtt[F("pskl")] = strlen(mqttPass);
if_mqtt[F("cid")] = mqttClientID; if_mqtt[F("cid")] = mqttClientID;
JsonObject if_mqtt_topics = if_mqtt.createNestedObject("topics"); JsonObject if_mqtt_topics = if_mqtt.createNestedObject(F("topics"));
if_mqtt_topics[F("device")] = mqttDeviceTopic; if_mqtt_topics[F("device")] = mqttDeviceTopic;
if_mqtt_topics[F("group")] = mqttGroupTopic; if_mqtt_topics[F("group")] = mqttGroupTopic;
JsonObject if_hue = interfaces.createNestedObject("hue"); JsonObject if_hue = interfaces.createNestedObject("hue");
if_hue[F("en")] = huePollingEnabled; if_hue["en"] = huePollingEnabled;
if_hue[F("id")] = huePollLightId; if_hue["id"] = huePollLightId;
if_hue[F("iv")] = huePollIntervalMs / 100; if_hue[F("iv")] = huePollIntervalMs / 100;
JsonObject if_hue_recv = if_hue.createNestedObject("recv"); JsonObject if_hue_recv = if_hue.createNestedObject("recv");
if_hue_recv["on"] = hueApplyOnOff; if_hue_recv["on"] = hueApplyOnOff;
if_hue_recv["bri"] = hueApplyBri; if_hue_recv["bri"] = hueApplyBri;
if_hue_recv[F("col")] = hueApplyColor; if_hue_recv["col"] = hueApplyColor;
JsonArray if_hue_ip = if_hue.createNestedArray("ip"); JsonArray if_hue_ip = if_hue.createNestedArray("ip");
for (byte i = 0; i < 4; i++) { for (byte i = 0; i < 4; i++) {
@ -611,7 +618,7 @@ void serializeConfig() {
} }
JsonObject if_ntp = interfaces.createNestedObject("ntp"); JsonObject if_ntp = interfaces.createNestedObject("ntp");
if_ntp[F("en")] = ntpEnabled; if_ntp["en"] = ntpEnabled;
if_ntp[F("host")] = ntpServerName; if_ntp[F("host")] = ntpServerName;
if_ntp[F("tz")] = currentTimezone; if_ntp[F("tz")] = currentTimezone;
if_ntp[F("offset")] = utcOffsetSecs; if_ntp[F("offset")] = utcOffsetSecs;
@ -627,10 +634,10 @@ void serializeConfig() {
ol[F("o5m")] = analogClock5MinuteMarks; ol[F("o5m")] = analogClock5MinuteMarks;
ol[F("osec")] = analogClockSecondsTrail; ol[F("osec")] = analogClockSecondsTrail;
JsonObject timers = doc.createNestedObject("timers"); JsonObject timers = doc.createNestedObject(F("timers"));
JsonObject cntdwn = timers.createNestedObject("cntdwn"); JsonObject cntdwn = timers.createNestedObject(F("cntdwn"));
JsonArray goal = cntdwn.createNestedArray("goal"); JsonArray goal = cntdwn.createNestedArray(F("goal"));
goal.add(countdownYear); goal.add(countdownMonth); goal.add(countdownDay); goal.add(countdownYear); goal.add(countdownMonth); goal.add(countdownDay);
goal.add(countdownHour); goal.add(countdownMin); goal.add(countdownSec); goal.add(countdownHour); goal.add(countdownMin); goal.add(countdownSec);
cntdwn[F("macro")] = macroCountdown; cntdwn[F("macro")] = macroCountdown;
@ -640,7 +647,7 @@ void serializeConfig() {
for (byte i = 0; i < 8; i++) { for (byte i = 0; i < 8; i++) {
if (timerMacro[i] == 0 && timerHours[i] == 0 && timerMinutes[i] == 0) continue; if (timerMacro[i] == 0 && timerHours[i] == 0 && timerMinutes[i] == 0) continue;
JsonObject timers_ins0 = timers_ins.createNestedObject(); JsonObject timers_ins0 = timers_ins.createNestedObject();
timers_ins0[F("en")] = (timerWeekday[i] & 0x01); timers_ins0["en"] = (timerWeekday[i] & 0x01);
timers_ins0[F("hour")] = timerHours[i]; timers_ins0[F("hour")] = timerHours[i];
timers_ins0[F("min")] = timerMinutes[i]; timers_ins0[F("min")] = timerMinutes[i];
timers_ins0[F("macro")] = timerMacro[i]; timers_ins0[F("macro")] = timerMacro[i];
@ -660,7 +667,7 @@ void serializeConfig() {
dmx[F("start")] = DMXStart; dmx[F("start")] = DMXStart;
dmx[F("start-led")] = DMXStartLED; dmx[F("start-led")] = DMXStartLED;
JsonArray dmx_fixmap = dmx.createNestedArray("fixmap"); JsonArray dmx_fixmap = dmx.createNestedArray(F("fixmap"));
for (byte i = 0; i < 15; i++) for (byte i = 0; i < 15; i++)
dmx_fixmap.add(DMXFixtureMap[i]); dmx_fixmap.add(DMXFixtureMap[i]);
#endif #endif
@ -686,7 +693,7 @@ bool deserializeConfigSec() {
JsonObject nw_ins_0 = doc["nw"][F("ins")][0]; JsonObject nw_ins_0 = doc["nw"][F("ins")][0];
getStringFromJson(clientPass, nw_ins_0["psk"], 65); getStringFromJson(clientPass, nw_ins_0["psk"], 65);
JsonObject ap = doc[F("ap")]; JsonObject ap = doc["ap"];
getStringFromJson(apPass, ap["psk"] , 65); getStringFromJson(apPass, ap["psk"] , 65);
JsonObject interfaces = doc["if"]; JsonObject interfaces = doc["if"];
@ -696,7 +703,7 @@ bool deserializeConfigSec() {
if (tdd > 20 || tdd == 0) if (tdd > 20 || tdd == 0)
getStringFromJson(blynkApiKey, apikey, 36); getStringFromJson(blynkApiKey, apikey, 36);
JsonObject if_mqtt = interfaces[F("mqtt")]; JsonObject if_mqtt = interfaces["mqtt"];
getStringFromJson(mqttPass, if_mqtt["psk"], 41); getStringFromJson(mqttPass, if_mqtt["psk"], 41);
getStringFromJson(hueApiKey, interfaces[F("hue")][F("key")], 47); getStringFromJson(hueApiKey, interfaces[F("hue")][F("key")], 47);

View File

@ -243,4 +243,12 @@
#define LEDPIN 2 #define LEDPIN 2
#endif #endif
#ifdef WLED_ENABLE_DMX
#if (LEDPIN == 2)
#undef LEDPIN
#define LEDPIN 3
#warning "Pin conflict compiling with DMX and LEDs on pin 2. The default LED pin has been changed to pin 3."
#endif
#endif
#endif #endif

View File

@ -943,12 +943,6 @@ input[type=number]::-webkit-outer-spin-button {
} }
} }
@media all and (max-width: 770px) {
#buttonNodes {
display: none;
}
}
@media all and (max-width: 1249px) { @media all and (max-width: 1249px) {
#buttonPcm { #buttonPcm {
display: none; display: none;

View File

@ -51,7 +51,7 @@ var cpick = new iro.ColorPicker("#picker", {
}); });
function handleVisibilityChange() { function handleVisibilityChange() {
if (!document.hidden && new Date () - lastUpdate > 3000) { if (!d.hidden && new Date () - lastUpdate > 3000) {
requestJson(null); requestJson(null);
} }
} }
@ -148,8 +148,8 @@ function cTheme(light) {
} }
function loadBg(iUrl) { function loadBg(iUrl) {
let bg = document.getElementById('bg'); let bg = d.getElementById('bg');
let img = document.createElement("img"); let img = d.createElement("img");
img.src = iUrl; img.src = iUrl;
if (iUrl == "") { if (iUrl == "") {
var today = new Date(); var today = new Date();
@ -305,12 +305,12 @@ function qlName(i) {
} }
function cpBck() { function cpBck() {
var copyText = document.getElementById("bck"); var copyText = d.getElementById("bck");
copyText.select(); copyText.select();
copyText.setSelectionRange(0, 999999); copyText.setSelectionRange(0, 999999);
document.execCommand("copy"); d.execCommand("copy");
showToast("Copied to clipboard!"); showToast("Copied to clipboard!");
} }
@ -595,7 +595,8 @@ function populateNodes(i,n)
} }
} }
} }
if (nnodes == 0) cn += `No other instances found.`; if (i.ndc < 0) cn += `Instance List is disabled.`;
else if (nnodes == 0) cn += `No other instances found.`;
cn += `<table class="infot"> cn += `<table class="infot">
${urows} ${urows}
${inforow("Current instance:",i.name)} ${inforow("Current instance:",i.name)}
@ -824,6 +825,7 @@ function requestJson(command, rinfo = true, verbose = true) {
pmt = info.fs.pmt; pmt = info.fs.pmt;
if (!command && pmt != pmtLast) setTimeout(loadPresets,99); if (!command && pmt != pmtLast) setTimeout(loadPresets,99);
pmtLast = pmt; pmtLast = pmt;
d.getElementById('buttonNodes').style.display = (info.ndc > 0 && window.innerWidth > 770) ? "block":"none";
lastinfo = info; lastinfo = info;
if (isInfo) populateInfo(info); if (isInfo) populateInfo(info);
s = json.state; s = json.state;
@ -1376,7 +1378,7 @@ function unfocusSliders() {
} }
//sliding UI //sliding UI
const _C = document.querySelector('.container'), N = 4; const _C = d.querySelector('.container'), N = 4;
let iSlide = 0, x0 = null, scrollS = 0, locked = false, w; let iSlide = 0, x0 = null, scrollS = 0, locked = false, w;
@ -1427,6 +1429,7 @@ function move(e) {
function size() { function size() {
w = window.innerWidth; w = window.innerWidth;
d.getElementById('buttonNodes').style.display = (lastinfo.ndc > 0 && w > 770) ? "block":"none";
var h = d.getElementById('top').clientHeight; var h = d.getElementById('top').clientHeight;
sCol('--th', h + "px"); sCol('--th', h + "px");
sCol('--bh', d.getElementById('bot').clientHeight + "px"); sCol('--bh', d.getElementById('bot').clientHeight + "px");

View File

@ -40,6 +40,9 @@ Send Philips Hue change notifications: <input type="checkbox" name="SH"><br>
Send Macro notifications: <input type="checkbox" name="SM"><br> Send Macro notifications: <input type="checkbox" name="SM"><br>
Send notifications twice: <input type="checkbox" name="S2"><br> Send notifications twice: <input type="checkbox" name="S2"><br>
<i>Reboot required to apply changes. </i> <i>Reboot required to apply changes. </i>
<h3>Instance List</h3>
Enable instance list: <input type="checkbox" name="NL"><br>
Make this instance discoverable: <input type="checkbox" name="NB"><br>
<h3>Realtime</h3> <h3>Realtime</h3>
Receive UDP realtime: <input type="checkbox" name="RD"><br><br> Receive UDP realtime: <input type="checkbox" name="RD"><br><br>
<i>Network DMX input</i><br> <i>Network DMX input</i><br>

View File

@ -62,10 +62,6 @@ void initDMX() {
dmx.init(512); // initialize with bus length dmx.init(512); // initialize with bus length
} }
#if (LEDPIN == 2)
#pragma message "Pin conflict compiling with DMX and LEDs on pin 2. Please set a different LEDPIN."
#endif
#else #else
void handleDMX() {} void handleDMX() {}
void initDMX() {} void initDMX() {}

View File

@ -239,22 +239,24 @@ Send Alexa notifications: <input type="checkbox" name="SA"><br>
Send Philips Hue change notifications: <input type="checkbox" name="SH"><br> Send Philips Hue change notifications: <input type="checkbox" name="SH"><br>
Send Macro notifications: <input type="checkbox" name="SM"><br> Send Macro notifications: <input type="checkbox" name="SM"><br>
Send notifications twice: <input type="checkbox" name="S2"><br><i> Send notifications twice: <input type="checkbox" name="S2"><br><i>
Reboot required to apply changes.</i><h3>Realtime</h3>Receive UDP realtime: Reboot required to apply changes.</i><h3>Instance List</h3>
<input type="checkbox" name="RD"><br><br><i>Network DMX input</i><br>Type: Enable instance list: <input type="checkbox" name="NL"><br>
<select name="DI" onchange="SP(),adj()"><option value="5568">E1.31 (sACN) Make this instance discoverable: <input type="checkbox" name="NB"><br><h3>
</option><option value="6454">Art-Net</option><option value="4048">DDP</option> Realtime</h3>Receive UDP realtime: <input type="checkbox" name="RD"><br><br><i>
<option value="0" selected="selected">Custom port</option></select><br><div Network DMX input</i><br>Type: <select name="DI" onchange="SP(),adj()"><option
id="xp">Port: <input name="EP" type="number" min="1" max="65535" value="5568" value="5568">E1.31 (sACN)</option><option value="6454">Art-Net</option><option
class="d5" required><br></div>Multicast: <input type="checkbox" name="EM"><br> value="4048">DDP</option><option value="0" selected="selected">Custom port
Start universe: <input name="EU" type="number" min="0" max="63999" required><br> </option></select><br><div id="xp">Port: <input name="EP" type="number" min="1"
<i>Reboot required.</i> Check out <a href="https://github.com/LedFx/LedFx" max="65535" value="5568" class="d5" required><br></div>Multicast: <input
target="_blank">LedFx</a>!<br>Skip out-of-sequence packets: <input type="checkbox" name="EM"><br>Start universe: <input name="EU" type="number"
type="checkbox" name="ES"><br>DMX start address: <input name="DA" type="number" min="0" max="63999" required><br><i>Reboot required.</i> Check out <a
min="0" max="510" required><br>DMX mode: <select name="DM"><option value="0"> href="https://github.com/LedFx/LedFx" target="_blank">LedFx</a>!<br>
Disabled</option><option value="1">Single RGB</option><option value="2"> Skip out-of-sequence packets: <input type="checkbox" name="ES"><br>
Single DRGB</option><option value="3">Effect</option><option value="4">Multi RGB DMX start address: <input name="DA" type="number" min="0" max="510" required>
</option><option value="5">Dimmer + Multi RGB</option><option value="6"> <br>DMX mode: <select name="DM"><option value="0">Disabled</option><option
Multi RGBW</option></select><br><a value="1">Single RGB</option><option value="2">Single DRGB</option><option
value="3">Effect</option><option value="4">Multi RGB</option><option value="5">
Dimmer + Multi RGB</option><option value="6">Multi RGBW</option></select><br><a
href="https://github.com/Aircoookie/WLED/wiki/E1.31-DMX" target="_blank"> href="https://github.com/Aircoookie/WLED/wiki/E1.31-DMX" target="_blank">
E1.31 info</a><br>Timeout: <input name="ET" type="number" min="1" max="65000" E1.31 info</a><br>Timeout: <input name="ET" type="number" min="1" max="65000"
required> ms<br>Force max brightness: <input type="checkbox" name="FB"><br> required> ms<br>Force max brightness: <input type="checkbox" name="FB"><br>

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,7 @@
void deserializeSegment(JsonObject elem, byte it) void deserializeSegment(JsonObject elem, byte it)
{ {
byte id = elem[F("id")] | it; byte id = elem["id"] | it;
if (id < strip.getMaxSegments()) if (id < strip.getMaxSegments())
{ {
WS2812FX::Segment& seg = strip.getSegment(id); WS2812FX::Segment& seg = strip.getSegment(id);
@ -31,7 +31,7 @@ void deserializeSegment(JsonObject elem, byte it)
seg.setOption(SEG_OPTION_ON, elem["on"] | seg.getOption(SEG_OPTION_ON), id); seg.setOption(SEG_OPTION_ON, elem["on"] | seg.getOption(SEG_OPTION_ON), id);
JsonArray colarr = elem[F("col")]; JsonArray colarr = elem["col"];
if (!colarr.isNull()) if (!colarr.isNull())
{ {
for (uint8_t i = 0; i < 3; i++) for (uint8_t i = 0; i < 3; i++)
@ -196,8 +196,8 @@ bool deserializeState(JsonObject root)
nightlightTargetBri = nl[F("tbri")] | nightlightTargetBri; nightlightTargetBri = nl[F("tbri")] | nightlightTargetBri;
JsonObject udpn = root["udpn"]; JsonObject udpn = root["udpn"];
notifyDirect = udpn[F("send")] | notifyDirect; notifyDirect = udpn["send"] | notifyDirect;
receiveNotifications = udpn[F("recv")] | receiveNotifications; receiveNotifications = udpn["recv"] | receiveNotifications;
bool noNotification = udpn[F("nn")]; //send no notification just for this request bool noNotification = udpn[F("nn")]; //send no notification just for this request
unsigned long timein = root[F("time")] | UINT32_MAX; unsigned long timein = root[F("time")] | UINT32_MAX;
@ -225,7 +225,7 @@ bool deserializeState(JsonObject root)
JsonVariant segVar = root["seg"]; JsonVariant segVar = root["seg"];
if (segVar.is<JsonObject>()) if (segVar.is<JsonObject>())
{ {
int id = segVar[F("id")] | -1; int id = segVar["id"] | -1;
if (id < 0) { //set all selected segments if (id < 0) { //set all selected segments
bool didSet = false; bool didSet = false;
@ -289,7 +289,7 @@ bool deserializeState(JsonObject root)
void serializeSegment(JsonObject& root, WS2812FX::Segment& seg, byte id, bool forPreset, bool segmentBounds) void serializeSegment(JsonObject& root, WS2812FX::Segment& seg, byte id, bool forPreset, bool segmentBounds)
{ {
root[F("id")] = id; root["id"] = id;
if (segmentBounds) { if (segmentBounds) {
root[F("start")] = seg.start; root[F("start")] = seg.start;
root["stop"] = seg.stop; root["stop"] = seg.stop;
@ -366,8 +366,8 @@ void serializeState(JsonObject root, bool forPreset, bool includeBri, bool segme
} }
JsonObject udpn = root.createNestedObject("udpn"); JsonObject udpn = root.createNestedObject("udpn");
udpn[F("send")] = notifyDirect; udpn["send"] = notifyDirect;
udpn[F("recv")] = receiveNotifications; udpn["recv"] = receiveNotifications;
root[F("lor")] = realtimeOverride; root[F("lor")] = realtimeOverride;
} }
@ -474,7 +474,7 @@ void serializeInfo(JsonObject root)
fs_info["t"] = fsBytesTotal / 1000; fs_info["t"] = fsBytesTotal / 1000;
fs_info[F("pmt")] = presetsModifiedTime; fs_info[F("pmt")] = presetsModifiedTime;
root[F("ndc")] = Nodes.size(); root[F("ndc")] = nodeListEnabled ? (int)Nodes.size() : -1;
#ifdef ARDUINO_ARCH_ESP32 #ifdef ARDUINO_ARCH_ESP32
#ifdef WLED_DEBUG #ifdef WLED_DEBUG
@ -547,10 +547,10 @@ void serializeNodes(JsonObject root)
{ {
JsonObject node = nodes.createNestedObject(); JsonObject node = nodes.createNestedObject();
node[F("name")] = it->second.nodeName; node[F("name")] = it->second.nodeName;
node[F("type")] = it->second.nodeType; node["type"] = it->second.nodeType;
node[F("ip")] = it->second.ip.toString(); node["ip"] = it->second.ip.toString();
node[F("age")] = it->second.age; node[F("age")] = it->second.age;
node[F("vid")] = it->second.build; node[F("vid")] = it->second.build;
} }
} }
} }

View File

@ -217,6 +217,10 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
notifyMacro = request->hasArg(F("SM")); notifyMacro = request->hasArg(F("SM"));
notifyTwice = request->hasArg(F("S2")); notifyTwice = request->hasArg(F("S2"));
nodeListEnabled = request->hasArg(F("NL"));
if (!nodeListEnabled) Nodes.clear();
nodeBroadcastEnabled = request->hasArg(F("NB"));
receiveDirect = request->hasArg(F("RD")); receiveDirect = request->hasArg(F("RD"));
e131SkipOutOfSequence = request->hasArg(F("ES")); e131SkipOutOfSequence = request->hasArg(F("ES"));
e131Multicast = request->hasArg(F("EM")); e131Multicast = request->hasArg(F("EM"));

View File

@ -169,7 +169,7 @@ void handleNotifications()
// WLED nodes info notifications // WLED nodes info notifications
if (isSupp && udpIn[0] == 255 && udpIn[1] == 1 && len >= 40) { if (isSupp && udpIn[0] == 255 && udpIn[1] == 1 && len >= 40) {
if (notifier2Udp.remoteIP() == Network.localIP()) return; if (!nodeListEnabled || notifier2Udp.remoteIP() == Network.localIP()) return;
uint8_t unit = udpIn[39]; uint8_t unit = udpIn[39];
NodesMap::iterator it = Nodes.find(unit); NodesMap::iterator it = Nodes.find(unit);

View File

@ -249,7 +249,7 @@ void WLED::loop()
if (lastMqttReconnectAttempt > millis()) rolloverMillis++; //millis() rolls over every 50 days if (lastMqttReconnectAttempt > millis()) rolloverMillis++; //millis() rolls over every 50 days
initMqtt(); initMqtt();
refreshNodeList(); refreshNodeList();
sendSysInfoUDP(); if (nodeBroadcastEnabled) sendSysInfoUDP();
} }
yield(); yield();
handleWs(); handleWs();
@ -300,10 +300,13 @@ void WLED::setup()
DEBUG_PRINTLN(ESP.getFreeHeap()); DEBUG_PRINTLN(ESP.getFreeHeap());
registerUsermods(); registerUsermods();
//DEBUG_PRINT(F("LEDs inited. heap usage ~")); //DEBUG_PRINT(F("LEDs inited. heap usage ~"));
//DEBUG_PRINTLN(heapPreAlloc - ESP.getFreeHeap()); //DEBUG_PRINTLN(heapPreAlloc - ESP.getFreeHeap());
#ifdef WLED_USE_DMX //reserve GPIO2 as hardcoded DMX pin
pinManager.allocatePin(2);
#endif
bool fsinit = false; bool fsinit = false;
DEBUGFS_PRINTLN(F("Mount FS")); DEBUGFS_PRINTLN(F("Mount FS"));
#ifdef ARDUINO_ARCH_ESP32 #ifdef ARDUINO_ARCH_ESP32
@ -338,7 +341,9 @@ void WLED::setup()
if (strcmp(clientSSID, DEFAULT_CLIENT_SSID) == 0) if (strcmp(clientSSID, DEFAULT_CLIENT_SSID) == 0)
showWelcomePage = true; showWelcomePage = true;
WiFi.persistent(false); WiFi.persistent(false);
#ifdef WLED_USE_ETHERNET
WiFi.onEvent(WiFiEvent); WiFi.onEvent(WiFiEvent);
#endif
Serial.println(F("Ada")); Serial.println(F("Ada"));

View File

@ -8,7 +8,7 @@
*/ */
// version code in format yymmddb (b = daily build) // version code in format yymmddb (b = daily build)
#define VERSION 2103090 #define VERSION 2103130
//uncomment this if you have a "my_config.h" file you'd like to use //uncomment this if you have a "my_config.h" file you'd like to use
//#define WLED_USE_MY_CONFIG //#define WLED_USE_MY_CONFIG
@ -259,6 +259,8 @@ WLED_GLOBAL bool syncToggleReceive _INIT(false); // UIs which only have a
// Sync CONFIG // Sync CONFIG
WLED_GLOBAL NodesMap Nodes; WLED_GLOBAL NodesMap Nodes;
WLED_GLOBAL bool nodeListEnabled _INIT(true);
WLED_GLOBAL bool nodeBroadcastEnabled _INIT(true);
WLED_GLOBAL bool buttonEnabled _INIT(true); WLED_GLOBAL bool buttonEnabled _INIT(true);
WLED_GLOBAL byte irEnabled _INIT(0); // Infrared receiver WLED_GLOBAL byte irEnabled _INIT(0); // Infrared receiver

View File

@ -364,6 +364,10 @@ void getSettingsJS(byte subPage, char* dest)
sappend('c',SET_F("SH"),notifyHue); sappend('c',SET_F("SH"),notifyHue);
sappend('c',SET_F("SM"),notifyMacro); sappend('c',SET_F("SM"),notifyMacro);
sappend('c',SET_F("S2"),notifyTwice); sappend('c',SET_F("S2"),notifyTwice);
sappend('c',SET_F("NL"),nodeListEnabled);
sappend('c',SET_F("NB"),nodeBroadcastEnabled);
sappend('c',SET_F("RD"),receiveDirect); sappend('c',SET_F("RD"),receiveDirect);
sappend('v',SET_F("EP"),e131Port); sappend('v',SET_F("EP"),e131Port);
sappend('c',SET_F("ES"),e131SkipOutOfSequence); sappend('c',SET_F("ES"),e131SkipOutOfSequence);