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
#### Build 2103130
- Added options for Auto Node discovery
- Optimized strings (no string both F() and raw)
#### Build 2103090
- Added Auto Node discovery (PR #1683)

View File

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

View File

@ -243,4 +243,12 @@
#define LEDPIN 2
#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

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) {
#buttonPcm {
display: none;

View File

@ -51,7 +51,7 @@ var cpick = new iro.ColorPicker("#picker", {
});
function handleVisibilityChange() {
if (!document.hidden && new Date () - lastUpdate > 3000) {
if (!d.hidden && new Date () - lastUpdate > 3000) {
requestJson(null);
}
}
@ -148,8 +148,8 @@ function cTheme(light) {
}
function loadBg(iUrl) {
let bg = document.getElementById('bg');
let img = document.createElement("img");
let bg = d.getElementById('bg');
let img = d.createElement("img");
img.src = iUrl;
if (iUrl == "") {
var today = new Date();
@ -305,12 +305,12 @@ function qlName(i) {
}
function cpBck() {
var copyText = document.getElementById("bck");
var copyText = d.getElementById("bck");
copyText.select();
copyText.setSelectionRange(0, 999999);
document.execCommand("copy");
d.execCommand("copy");
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">
${urows}
${inforow("Current instance:",i.name)}
@ -824,6 +825,7 @@ function requestJson(command, rinfo = true, verbose = true) {
pmt = info.fs.pmt;
if (!command && pmt != pmtLast) setTimeout(loadPresets,99);
pmtLast = pmt;
d.getElementById('buttonNodes').style.display = (info.ndc > 0 && window.innerWidth > 770) ? "block":"none";
lastinfo = info;
if (isInfo) populateInfo(info);
s = json.state;
@ -1376,7 +1378,7 @@ function unfocusSliders() {
}
//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;
@ -1427,6 +1429,7 @@ function move(e) {
function size() {
w = window.innerWidth;
d.getElementById('buttonNodes').style.display = (lastinfo.ndc > 0 && w > 770) ? "block":"none";
var h = d.getElementById('top').clientHeight;
sCol('--th', h + "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 notifications twice: <input type="checkbox" name="S2"><br>
<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>
Receive UDP realtime: <input type="checkbox" name="RD"><br><br>
<i>Network DMX input</i><br>

View File

@ -62,10 +62,6 @@ void initDMX() {
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
void handleDMX() {}
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 Macro notifications: <input type="checkbox" name="SM"><br>
Send notifications twice: <input type="checkbox" name="S2"><br><i>
Reboot required to apply changes.</i><h3>Realtime</h3>Receive UDP realtime:
<input type="checkbox" name="RD"><br><br><i>Network DMX input</i><br>Type:
<select name="DI" onchange="SP(),adj()"><option value="5568">E1.31 (sACN)
</option><option value="6454">Art-Net</option><option value="4048">DDP</option>
<option value="0" selected="selected">Custom port</option></select><br><div
id="xp">Port: <input name="EP" type="number" min="1" max="65535" value="5568"
class="d5" required><br></div>Multicast: <input type="checkbox" name="EM"><br>
Start universe: <input name="EU" type="number" min="0" max="63999" required><br>
<i>Reboot required.</i> Check out <a href="https://github.com/LedFx/LedFx"
target="_blank">LedFx</a>!<br>Skip out-of-sequence packets: <input
type="checkbox" name="ES"><br>DMX start address: <input name="DA" type="number"
min="0" max="510" required><br>DMX mode: <select name="DM"><option value="0">
Disabled</option><option 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
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>Receive UDP realtime: <input type="checkbox" name="RD"><br><br><i>
Network DMX input</i><br>Type: <select name="DI" onchange="SP(),adj()"><option
value="5568">E1.31 (sACN)</option><option value="6454">Art-Net</option><option
value="4048">DDP</option><option value="0" selected="selected">Custom port
</option></select><br><div id="xp">Port: <input name="EP" type="number" min="1"
max="65535" value="5568" class="d5" required><br></div>Multicast: <input
type="checkbox" name="EM"><br>Start universe: <input name="EU" type="number"
min="0" max="63999" required><br><i>Reboot required.</i> Check out <a
href="https://github.com/LedFx/LedFx" target="_blank">LedFx</a>!<br>
Skip out-of-sequence packets: <input type="checkbox" name="ES"><br>
DMX start address: <input name="DA" type="number" min="0" max="510" required>
<br>DMX mode: <select name="DM"><option value="0">Disabled</option><option
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">
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>

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -169,7 +169,7 @@ void handleNotifications()
// WLED nodes info notifications
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];
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
initMqtt();
refreshNodeList();
sendSysInfoUDP();
if (nodeBroadcastEnabled) sendSysInfoUDP();
}
yield();
handleWs();
@ -300,10 +300,13 @@ void WLED::setup()
DEBUG_PRINTLN(ESP.getFreeHeap());
registerUsermods();
//DEBUG_PRINT(F("LEDs inited. heap usage ~"));
//DEBUG_PRINTLN(heapPreAlloc - ESP.getFreeHeap());
#ifdef WLED_USE_DMX //reserve GPIO2 as hardcoded DMX pin
pinManager.allocatePin(2);
#endif
bool fsinit = false;
DEBUGFS_PRINTLN(F("Mount FS"));
#ifdef ARDUINO_ARCH_ESP32
@ -338,7 +341,9 @@ void WLED::setup()
if (strcmp(clientSSID, DEFAULT_CLIENT_SSID) == 0)
showWelcomePage = true;
WiFi.persistent(false);
#ifdef WLED_USE_ETHERNET
WiFi.onEvent(WiFiEvent);
#endif
Serial.println(F("Ada"));

View File

@ -8,7 +8,7 @@
*/
// 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
//#define WLED_USE_MY_CONFIG
@ -259,6 +259,8 @@ WLED_GLOBAL bool syncToggleReceive _INIT(false); // UIs which only have a
// Sync CONFIG
WLED_GLOBAL NodesMap Nodes;
WLED_GLOBAL bool nodeListEnabled _INIT(true);
WLED_GLOBAL bool nodeBroadcastEnabled _INIT(true);
WLED_GLOBAL bool buttonEnabled _INIT(true);
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("SM"),notifyMacro);
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('v',SET_F("EP"),e131Port);
sappend('c',SET_F("ES"),e131SkipOutOfSequence);