From b01309c3bfc2008b157b7585ab37d9966b8177ce Mon Sep 17 00:00:00 2001 From: PLCHome Date: Mon, 7 Mar 2022 18:26:53 +0100 Subject: [PATCH 1/3] Mixed content exception in web browser in websocket communication on peek behind an https backproxy. (#2571) "ws://" must be the change to the "wss://" for encryption --- wled00/data/index.js | 2 +- wled00/data/liveviewws.htm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/wled00/data/index.js b/wled00/data/index.js index f8359d0e2..c3ef0c5da 100644 --- a/wled00/data/index.js +++ b/wled00/data/index.js @@ -1000,7 +1000,7 @@ function reconnectWS() { function makeWS() { if (ws) return; - ws = new WebSocket('ws://'+(loc?locip:window.location.hostname)+'/ws'); + ws = new WebSocket((window.location.protocol == 'https:'?'wss':'ws')+'://'+(loc?locip:window.location.hostname)+'/ws'); ws.binaryType = "arraybuffer"; ws.onmessage = function(event) { if (event.data instanceof ArrayBuffer) return; //liveview packet diff --git a/wled00/data/liveviewws.htm b/wled00/data/liveviewws.htm index 9ad2a667d..9234d317c 100644 --- a/wled00/data/liveviewws.htm +++ b/wled00/data/liveviewws.htm @@ -51,7 +51,7 @@ ws.send("{'lv':true}"); } else { console.info("Peek WS opening"); - ws = new WebSocket("ws://"+document.location.host+"/ws"); + ws = new WebSocket((window.location.protocol == "https:"?"wss":"ws")+"://"+document.location.host+"/ws"); ws.onopen = function () { console.info("Peek WS open"); ws.send("{'lv':true}"); From 5d90d8930e75d4a8d8e50a0c19de5c2b52f25add Mon Sep 17 00:00:00 2001 From: cschwinne Date: Mon, 7 Mar 2022 20:37:48 +0100 Subject: [PATCH 2/3] Fix non-0 terminated hostname str --- wled00/wled.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/wled00/wled.cpp b/wled00/wled.cpp index 9da278120..a98116954 100644 --- a/wled00/wled.cpp +++ b/wled00/wled.cpp @@ -62,18 +62,19 @@ void prepareHostname(char* hostname) hostname[pos] = '-'; pos++; } - // else do nothing - no leading hyphens and do not include hyphens for all other characters. - pC++; - } - // if the hostname is left blank, use the mac address/default mdns name - if (pos < 6) { - sprintf(hostname + 5, "%*s", 6, escapedMac.c_str() + 6); - } else { //last character must not be hyphen - while (pos > 0 && hostname[pos -1] == '-') { - hostname[pos -1] = 0; - pos--; - } + // else do nothing - no leading hyphens and do not include hyphens for all other characters. + pC++; + } + // if the hostname is left blank, use the mac address/default mdns name + if (pos < 6) { + sprintf(hostname + 5, "%*s", 6, escapedMac.c_str() + 6); + } else { //last character must not be hyphen + hostname[pos] = '\0'; // terminate string + while (pos > 0 && hostname[pos -1] == '-') { + hostname[pos -1] = '\0'; + pos--; } + } } //handle Ethernet connection event From b626c7620eef8b8f66ede2a3d7a53738d8319c67 Mon Sep 17 00:00:00 2001 From: cschwinne Date: Tue, 8 Mar 2022 02:16:33 +0100 Subject: [PATCH 3/3] Disabled auto white mode in segments with no RGB bus --- CHANGELOG.md | 6 ++++++ wled00/FX.h | 3 ++- wled00/FX_fcn.cpp | 24 +++++++++++++++--------- wled00/cfg.cpp | 15 ++++++++------- wled00/ir.cpp | 4 ++-- wled00/json.cpp | 13 ++++--------- wled00/set.cpp | 9 +++++---- wled00/wled.h | 2 +- wled00/xml.cpp | 6 +++--- 9 files changed, 46 insertions(+), 36 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4564e5786..3d2fc81da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ ### Builds after release 0.12.0 +#### Build 2203080 + +- Disabled auto white mode in segments with no RGB bus +- Fixed hostname string not 0-terminated +- Fixed Popcorn mode not lighting first LED on pop + #### Build 2203060 - Dynamic hiding of unused color controls in UI (PR #2567) diff --git a/wled00/FX.h b/wled00/FX.h index 8de43566d..d9f826b89 100644 --- a/wled00/FX.h +++ b/wled00/FX.h @@ -657,7 +657,8 @@ class WS2812FX { paletteFade = 0, paletteBlend = 0, milliampsPerLed = 55, - cctBlending = 0, + autoWhiteMode = RGBW_MODE_DUAL, + cctBlending = 0, getBrightness(void), getModeCount(void), getPaletteCount(void), diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index 7136c512e..4c98480dd 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -152,17 +152,18 @@ void WS2812FX::service() { _colors_t[slot] = transitions[t].currentColor(SEGMENT.colors[slot]); } if (!cctFromRgb || correctWB) busses.setSegmentCCT(_cct_t, correctWB); - _no_rgb = !(SEGMENT.getLightCapabilities() & 0x01); for (uint8_t c = 0; c < NUM_COLORS; c++) { - // if segment is not RGB capable, treat RGB channels of main segment colors as if 0 - // this prevents Dual mode with white value 0 from setting White channel from inaccessible RGB values - // If not RGB capable, also treat palette as if default (0), as palettes set white channel to 0 - if (_no_rgb) _colors_t[c] = _colors_t[c] & 0xFF000000; _colors_t[c] = gamma32(_colors_t[c]); } handle_palette(); + + // if segment is not RGB capable, force None auto white mode + // If not RGB capable, also treat palette as if default (0), as palettes set white channel to 0 + _no_rgb = !(SEGMENT.getLightCapabilities() & 0x01); + if (_no_rgb) Bus::setAutoWhiteMode(RGBW_MODE_MANUAL_ONLY); delay = (this->*_mode[SEGMENT.mode])(); //effect function if (SEGMENT.mode != FX_MODE_HALLOWEEN_EYES) SEGENV.call++; + Bus::setAutoWhiteMode(strip.autoWhiteMode); } SEGENV.next_time = nowUp + delay; @@ -573,8 +574,9 @@ void WS2812FX::Segment::refreshLightCapabilities() { _capabilities = 0; return; } uint8_t capabilities = 0; - uint8_t awm = Bus::getAutoWhiteMode(); + uint8_t awm = instance->autoWhiteMode; bool whiteSlider = (awm == RGBW_MODE_DUAL || awm == RGBW_MODE_MANUAL_ONLY); + bool segHasValidBus = false; for (uint8_t b = 0; b < busses.getNumBusses(); b++) { Bus *bus = busses.getBus(b); @@ -582,12 +584,13 @@ void WS2812FX::Segment::refreshLightCapabilities() { if (bus->getStart() >= stop) continue; if (bus->getStart() + bus->getLength() <= start) continue; + segHasValidBus = true; uint8_t type = bus->getType(); - if (!whiteSlider || (type != TYPE_ANALOG_1CH && (cctFromRgb || type != TYPE_ANALOG_2CH))) + if (type != TYPE_ANALOG_1CH && (cctFromRgb || type != TYPE_ANALOG_2CH)) { - capabilities |= 0x01; //segment supports RGB (full color) + capabilities |= 0x01; // segment supports RGB (full color) } - if (bus->isRgbw() && whiteSlider) capabilities |= 0x02; //segment supports white channel + if (bus->isRgbw() && whiteSlider) capabilities |= 0x02; // segment supports white channel if (!cctFromRgb) { switch (type) { case TYPE_ANALOG_5CH: @@ -597,6 +600,9 @@ void WS2812FX::Segment::refreshLightCapabilities() { } if (correctWB && type != TYPE_ANALOG_1CH) capabilities |= 0x04; //white balance correction (uses CCT slider) } + // if seg has any bus, but no bus has RGB, it by definition supports white (at least for now) + // In case of no RGB, disregard auto white mode and always show a white slider + if (segHasValidBus && !(capabilities & 0x01)) capabilities |= 0x02; // segment supports white channel _capabilities = capabilities; } diff --git a/wled00/cfg.cpp b/wled00/cfg.cpp index ed90512e7..4fb07fbc8 100644 --- a/wled00/cfg.cpp +++ b/wled00/cfg.cpp @@ -80,13 +80,14 @@ bool deserializeConfig(JsonObject doc, bool fromFS) { CJSON(strip.ablMilliampsMax, hw_led[F("maxpwr")]); CJSON(strip.milliampsPerLed, hw_led[F("ledma")]); - Bus::setAutoWhiteMode(hw_led[F("rgbwm")] | Bus::getAutoWhiteMode()); + CJSON(strip.autoWhiteMode, hw_led[F("rgbwm")]); + Bus::setAutoWhiteMode(strip.autoWhiteMode); strip.fixInvalidSegments(); // refreshes segment light capabilities (in case auto white mode changed) CJSON(correctWB, hw_led["cct"]); CJSON(cctFromRgb, hw_led[F("cr")]); - CJSON(strip.cctBlending, hw_led[F("cb")]); - Bus::setCCTBlend(strip.cctBlending); - strip.setTargetFps(hw_led["fps"]); //NOP if 0, default 42 FPS + CJSON(strip.cctBlending, hw_led[F("cb")]); + Bus::setCCTBlend(strip.cctBlending); + strip.setTargetFps(hw_led["fps"]); //NOP if 0, default 42 FPS JsonArray ins = hw_led["ins"]; @@ -577,9 +578,9 @@ void serializeConfig() { hw_led[F("ledma")] = strip.milliampsPerLed; hw_led["cct"] = correctWB; hw_led[F("cr")] = cctFromRgb; - hw_led[F("cb")] = strip.cctBlending; - hw_led["fps"] = strip.getTargetFps(); - hw_led[F("rgbwm")] = Bus::getAutoWhiteMode(); + hw_led[F("cb")] = strip.cctBlending; + hw_led["fps"] = strip.getTargetFps(); + hw_led[F("rgbwm")] = strip.autoWhiteMode; JsonArray hw_led_ins = hw_led.createNestedArray("ins"); diff --git a/wled00/ir.cpp b/wled00/ir.cpp index b740a8d12..5e1577445 100644 --- a/wled00/ir.cpp +++ b/wled00/ir.cpp @@ -226,7 +226,7 @@ void changeColor(uint32_t c, int16_t cct=-1) bool isCCT = GET_BIT(capabilities, 2); if (isRGB) mask |= 0x00FFFFFF; // RGB if (hasW) mask |= 0xFF000000; // white - if (hasW && (Bus::getAutoWhiteMode() == RGBW_MODE_AUTO_ACCURATE) && (c & 0xFF000000)) { // white channel & white specified + if (hasW && (strip.autoWhiteMode == RGBW_MODE_AUTO_ACCURATE) && (c & 0xFF000000)) { // white channel & white specified seg.setColor(0, c | 0xFFFFFF, i); // for accurate mode we fake white } else if (c & mask) seg.setColor(0, c & mask, i); // only apply if not black if (isCCT && cct >= 0) seg.setCCT(cct, i); @@ -242,7 +242,7 @@ void changeColor(uint32_t c, int16_t cct=-1) bool isCCT = GET_BIT(capabilities, 2); if (isRGB) mask |= 0x00FFFFFF; // RGB if (hasW) mask |= 0xFF000000; // white - if (hasW && (Bus::getAutoWhiteMode() == RGBW_MODE_AUTO_ACCURATE) && (c & 0xFF000000)) { // white channel & white specified + if (hasW && (strip.autoWhiteMode == RGBW_MODE_AUTO_ACCURATE) && (c & 0xFF000000)) { // white channel & white specified seg.setColor(0, c | 0xFFFFFF, i); // for accurate mode we fake white } else if (c & mask) seg.setColor(0, c & mask, i); // only apply if not black if (isCCT && cct >= 0) seg.setCCT(cct, i); diff --git a/wled00/json.cpp b/wled00/json.cpp index c39da1bf0..007ab3431 100644 --- a/wled00/json.cpp +++ b/wled00/json.cpp @@ -497,15 +497,6 @@ void serializeInfo(JsonObject root) JsonObject leds = root.createNestedObject("leds"); leds[F("count")] = strip.getLengthTotal(); - leds[F("rgbw")] = strip.hasRGBWBus(); //deprecated, use info.leds.lc - leds[F("wv")] = false; //deprecated, use info.leds.lc - leds["cct"] = correctWB || strip.hasCCTBus(); //deprecated, use info.leds.lc - switch (Bus::getAutoWhiteMode()) { - case RGBW_MODE_MANUAL_ONLY: - case RGBW_MODE_DUAL: - if (strip.hasWhiteChannel()) leds[F("wv")] = true; - break; - } leds[F("pwr")] = strip.currentMilliamps; leds["fps"] = strip.getFps(); @@ -524,6 +515,10 @@ void serializeInfo(JsonObject root) leds["lc"] = totalLC; + leds[F("rgbw")] = strip.hasRGBWBus(); // deprecated, use info.leds.lc + leds[F("wv")] = totalLC & 0x02; // deprecated, true if white slider should be displayed for any segment + leds["cct"] = totalLC & 0x04; // deprecated, use info.leds.lc + root[F("str")] = syncToggleReceive; root[F("name")] = serverDescription; diff --git a/wled00/set.cpp b/wled00/set.cpp index e51bb9173..0facbaef4 100644 --- a/wled00/set.cpp +++ b/wled00/set.cpp @@ -84,10 +84,11 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage) autoSegments = request->hasArg(F("MS")); correctWB = request->hasArg(F("CCT")); cctFromRgb = request->hasArg(F("CR")); - strip.cctBlending = request->arg(F("CB")).toInt(); - Bus::setCCTBlend(strip.cctBlending); - Bus::setAutoWhiteMode(request->arg(F("AW")).toInt()); - strip.setTargetFps(request->arg(F("FR")).toInt()); + strip.cctBlending = request->arg(F("CB")).toInt(); + Bus::setCCTBlend(strip.cctBlending); + strip.autoWhiteMode = (request->arg(F("AW")).toInt()); + Bus::setAutoWhiteMode(strip.autoWhiteMode); + strip.setTargetFps(request->arg(F("FR")).toInt()); for (uint8_t s = 0; s < WLED_MAX_BUSSES; s++) { char lp[4] = "L0"; lp[2] = 48+s; lp[3] = 0; //ascii 0-9 //strip data pin diff --git a/wled00/wled.h b/wled00/wled.h index 8b7d92371..02fe8fa67 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -8,7 +8,7 @@ */ // version code in format yymmddb (b = daily build) -#define VERSION 2203061 +#define VERSION 2203080 //uncomment this if you have a "my_config.h" file you'd like to use //#define WLED_USE_MY_CONFIG diff --git a/wled00/xml.cpp b/wled00/xml.cpp index c1ea5fd71..7021c3ce1 100644 --- a/wled00/xml.cpp +++ b/wled00/xml.cpp @@ -382,9 +382,9 @@ void getSettingsJS(byte subPage, char* dest) sappend('c',SET_F("MS"),autoSegments); sappend('c',SET_F("CCT"),correctWB); sappend('c',SET_F("CR"),cctFromRgb); - sappend('v',SET_F("CB"),strip.cctBlending); - sappend('v',SET_F("FR"),strip.getTargetFps()); - sappend('v',SET_F("AW"),Bus::getAutoWhiteMode()); + sappend('v',SET_F("CB"),strip.cctBlending); + sappend('v',SET_F("FR"),strip.getTargetFps()); + sappend('v',SET_F("AW"),strip.autoWhiteMode); for (uint8_t s=0; s < busses.getNumBusses(); s++) { Bus* bus = busses.getBus(s);