Repository navigation
Full blazoncek fork merge - #2610
Aircoookie wants to merge 33 commits into
Conversation
blazoncek
left a comment
There was a problem hiding this comment.
Most of the uncommented changes are cosmetic or bugfixes (including all usermods).
applyPreset()/handlePresets() may need special treatment as may refreshLightCapabilities().
| else temp.add(F("°F")); | ||
| temp.add(degC ? F("°C") : F("°F")); | ||
|
|
||
| JsonObject sensor = root[F("sensor")]; |
There was a problem hiding this comment.
We talked about adding sensor data to info object a while. This is it.
| PSTR("~ %02d-%02d %02d:%02d:%02d ~"), | ||
| month(localTime), day(localTime), | ||
| hour(localTime), minute(localTime), second(localTime)); | ||
| cacheInvalidate++; // force reload of presets |
There was a problem hiding this comment.
This tries to circumvent occasional browser caching issues.
| inline bool isOffRefreshRequired(void) {return _isOffRefreshRequired;} | ||
| }; | ||
|
|
||
| extern const char JSON_mode_names[]; |
There was a problem hiding this comment.
Moved to cpp. Saved a few bytes on my tests.
| } | ||
| if (correctWB && type != TYPE_ANALOG_1CH) capabilities |= 0x04; //white balance correction (uses CCT slider) | ||
| uint8_t aWM = Bus::getAutoWhiteMode()<255 ? Bus::getAutoWhiteMode() : bus->getAWMode(); | ||
| bool whiteSlider = (awm == RGBW_MODE_DUAL || awm == RGBW_MODE_MANUAL_ONLY) || (aWM == RGBW_MODE_DUAL || aWM == RGBW_MODE_MANUAL_ONLY); // white slider allowed |
There was a problem hiding this comment.
This may need fine-tuning.
There was a problem hiding this comment.
No longer sure awm (instance->autoWhiteMode) is needed here since Bus::getAutoWhiteMode() returns the same value. Global override.
| //if none selected, apply to the main segment | ||
| if (!didSet) deserializeSegment(segVar, strip.getMainSegmentId(), presetId); | ||
| //TODO: not sure if it is good idea to change first active but unselected segment | ||
| //if (!didSet) deserializeSegment(segVar, strip.getMainSegmentId(), presetId); |
There was a problem hiding this comment.
You may uncomment this but IMO if no segments are selected it should not apply.
| root[F("fxcount")] = strip.getModeCount(); | ||
| root[F("palcount")] = strip.getPaletteCount(); | ||
|
|
||
| JsonArray ledmaps = root.createNestedArray(F("maps")); |
There was a problem hiding this comment.
Allows selection of ledmap within preset.
| return true; | ||
| } | ||
|
|
||
| void handlePresets() |
There was a problem hiding this comment.
This one was originally applyPreset().
blazoncek
left a comment
There was a problem hiding this comment.
As you can see there are no major or breaking changes except async preset loading.
Changes in UI loading have been thoroughly tested with plenty of ESP8266 units with various network signal strengths.
| infoArr.add(F("disabled")); | ||
| } | ||
|
|
||
| JsonObject sensor = root[F("sensor")]; |
There was a problem hiding this comment.
Sensor info object we talked about (exposing sensor info to integrations).
| uint16_t count = defCounts[(i < defNumCounts) ? i : defNumCounts -1]; | ||
| prevLen += count; | ||
| BusConfig defCfg = BusConfig(DEFAULT_LED_TYPE, defPin, start, count, DEFAULT_LED_COLOR_ORDER); | ||
| BusConfig defCfg = BusConfig(DEFAULT_LED_TYPE, defPin, start, count, DEFAULT_LED_COLOR_ORDER, false, 0, RGBW_MODE_MANUAL_ONLY); |
There was a problem hiding this comment.
You are free to change to DUAL if you wish.
| uint8_t autoWhite; | ||
| uint8_t pins[5] = {LEDPIN, 255, 255, 255, 255}; | ||
| BusConfig(uint8_t busType, uint8_t* ppins, uint16_t pstart, uint16_t len = 1, uint8_t pcolorOrder = COL_ORDER_GRB, bool rev = false, uint8_t skip = 0) { | ||
| BusConfig(uint8_t busType, uint8_t* ppins, uint16_t pstart, uint16_t len = 1, uint8_t pcolorOrder = COL_ORDER_GRB, bool rev = false, uint8_t skip = 0, byte aw=RGBW_MODE_MANUAL_ONLY) { |
| //#define B_HS_WS1_3 NeoPixelBrightnessBus<NeoRbgFeature, NeoWs2801Spi20MhzMethod> | ||
| //#define B_HS_WS1_3 NeoPixelBrightnessBus<NeoRbgFeature, NeoWs2801SpiMethod> // 10MHz | ||
| #define B_HS_WS1_3 NeoPixelBrightnessBus<NeoRbgFeature, NeoWs2801Spi2MhzMethod> //slower, more compatible | ||
| #if defined(WLED_WS2801_SPEED_KHZ) && WLED_WS2801_SPEED_KHZ==40000 |
There was a problem hiding this comment.
Perhaps adding runtime selection in the future.
| // initialize LED pins and lengths prior to other HW (except for ethernet) | ||
| JsonObject hw_led = hw["led"]; | ||
|
|
||
| uint8_t autoWhiteMode = RGBW_MODE_MANUAL_ONLY; |
There was a problem hiding this comment.
I would prefer this to stay MANUAL.
|
|
||
| root[F("mainseg")] = strip.getMainSegmentId(); | ||
|
|
||
| bool selectedSegmentsOnly = root[F("sc")] | false; |
There was a problem hiding this comment.
New feature to allow saving only selected segments to preset.
| } | ||
| } | ||
|
|
||
| void serializeModeData(JsonArray fxdata) |
There was a problem hiding this comment.
Handlers for SR extensions to mode/effect data.
| static volatile byte callModeToApply = 0; | ||
| static volatile bool checkPlaylist = false; | ||
|
|
||
| bool applyPreset(byte index, byte callMode, bool fromJson) |
There was a problem hiding this comment.
The biggest change: async preset loading.
| yield(); | ||
| #endif | ||
|
|
||
| handlePresets(); |
There was a problem hiding this comment.
Async preset loading entry point.
| } | ||
|
|
||
| // 15min PIN time-out | ||
| if (strlen(settingsPIN)>0 && millis() - lastEditTime > 900000) { |
There was a problem hiding this comment.
This could be made customizable at some point.
Modal Close button moved to top-right.
Added numpad to funtion and pattern for numerals
Cleanup.
|
@Aircoookie any progress on this? A few main points to test:
Also, it may be good to add Play and Pause glyphs to Wicons font. |
Implemented custom effect parameters.
|
Thank you for the latest additions! :) |
|
Reason I can't just copy UI files myself is that I would get attribution for all your changes which is not fair imo. And I did not find an easy option to merge only some files (without creating a huge change set by reverting changes to all other files) |
Bugfix for HTTP API preset. WS multiple broadcast fix. Turning segment on/off will not reset currentPreset/cause stateChanged.
- Changed boot load order (info must be present before presets are loaded because pmt is required), this fixes new presets not appearing after page reload - Fixed repeat segments turning off regression - Added Update button to info section
Yellow connection indicator on pending request (turn red on actual failure/timeout)
- keep .staytop/.staybot sticky - .fnd inheritance
Cleanup. Added new holidays.
Do not redirect back to main page but immediately to intended page Make PIN work on /update page
Fix OTA lock Fix OTA lock not locking edit page Remove reboot requirement for changing OTA lock Slight Flash string optimization
Fix for speed/intensity sliders in Firefox.
| }); | ||
|
|
||
| createEditHandler(correctPIN); | ||
| createEditHandler(correctPIN && !otaLock); |
There was a problem hiding this comment.
OTA lock should have no influence on ability to visit /edit page.
Security setting cannot be changed using /edit.
There was a problem hiding this comment.
/edit page is able to set (not retrieve sec) arbitrary settings, but more critically, able to alter the pages displayed to the browser, which is a security risk. It can even be seen as a form of OTA update :)
PIN is an adequate protection, but if the user has OTA lock active before and after the update, they would still expect /edit to be locked. I will change the label of OTA to make clear that it also locks edit though.
There was a problem hiding this comment.
Sorry but I fail to understand how a user can update if OTA is locked? If you mean serially then all measures are irrelevant since with physical access anything is possible.
If OTA is locked it will prevent any kind of updates (not true ATM due to bug) to firmware even if PIN is entered and that should be the main purpose of it IMO (which also holds for WiFi settings).
There was a problem hiding this comment.
They can't update the firmware, but they can arbitrarily change the index.htm served to clients.
Regarding ArduinoOTA: I think it should stay separate from OTA lock - most common use case for OTA lock is allowing access to port 80 only. This allows local updates via ArduinoOTA without having to unlock OTA each time. If ArduinoOTA is disabled via the checkbox and OTA locked, it can't be re-enabled without the correct OTA password. Should add a note though that ArduinoOTA will remain active unless disabled manually.
There was a problem hiding this comment.
I still think that locking OTA should be consistent for both options: web update and Arduino OTA. Otherwise an adversary can update firmware even if a user thinks he/she locked OTA updates and considers WLED secure.
/editpage is able to set (not retrieve sec) arbitrary settings, but more critically, able to alter the pages displayed to the browser
Locking settings (and /edit) using PIN code should be sufficient for most cases where WLED can be put to public use (with the warning about non encrypted transfer). Removing fake index.htm can be done without too much effort in case when adversary intercepted PIN and uploaded fake index.htm. Combined with OTA lock it can prevent most malicious attacks (except carefully planned ones) even with plain HTTP. I would not expect /edit to be locked when OTA is disabled/locked. It has become a feature that was suggested as a help in case of many problem solving options. It will also prevent uploading ledmaps and such which should not be a condition of OTA lock.
PIN in itself will also prevent updating OTA and will lend a grace period of 15 minutes (when entered) in which time you can do OTA (Arduino or web) if you need to update.
|
I have an update on async preset loading. WLED UI knows content of a preset so instead of sending If an external source (i.e. not WLED UI) wants to change a preset by using preset ID I cannot see a reason why would it require a returned state to reflect exact preset content immediately since it can subscribe to websockets or periodically request a state to get the correct state at any given time (since WLED state may change from another source and in such case it would maintain incorrect state internally after another source changed WLED state). So I would propose to change WLED UI to send complete preset API to WLED and pass a preset ID alongside API ("pt" from above). This may simplify preset loading and issues tied to it. |
|
This has been superseded by #2737 |
Introduces all features and fixes of @blazoncek dev branch.
PR for feedback and adjustments.