From 2ce8f1ee5dcd3b040eee05dcf2dd36157d104eb5 Mon Sep 17 00:00:00 2001 From: cschwinne Date: Sat, 11 Dec 2021 19:30:11 +0100 Subject: [PATCH] Skip first and apply preset fixes --- wled00/bus_manager.h | 4 ++-- wled00/presets.cpp | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/wled00/bus_manager.h b/wled00/bus_manager.h index b0838ae7..ab3156ff 100644 --- a/wled00/bus_manager.h +++ b/wled00/bus_manager.h @@ -91,7 +91,7 @@ class Bus { virtual void setBrightness(uint8_t b) {} virtual void cleanup() {} virtual uint8_t getPins(uint8_t* pinArray) { return 0; } - inline uint16_t getLength() { return _len; } + virtual uint16_t getLength() { return _len; } virtual void setColorOrder() {} virtual uint8_t getColorOrder() { return COL_ORDER_RGB; } virtual uint8_t skippedLeds() { return 0; } @@ -220,7 +220,7 @@ class BusDigital : public Bus { return _colorOrder; } - inline uint16_t getLength() { + uint16_t getLength() { return _len - _skip; } diff --git a/wled00/presets.cpp b/wled00/presets.cpp index 2d783f1c..de82c939 100644 --- a/wled00/presets.cpp +++ b/wled00/presets.cpp @@ -10,7 +10,15 @@ bool applyPreset(byte index, byte callMode) const char *filename = index < 255 ? "/presets.json" : "/tmp.json"; - if (fileDoc) { + uint8_t core = 1; + //crude way to determine if this was called by a network request + #ifdef ARDUINO_ARCH_ESP32 + core = xPortGetCoreID(); + #endif + + //only allow use of fileDoc from the core responsible for network requests + //do not use active network request doc from preset called by main loop (playlist, schedule, ...) + if (fileDoc && core) { errorFlag = readObjectFromFileUsingId(filename, index, fileDoc) ? ERR_NONE : ERR_FS_PLOAD; JsonObject fdo = fileDoc->as(); if (fdo["ps"] == index) fdo.remove("ps"); //remove load request for same presets to prevent recursive crash