From d9b0df94e2a344b05bac88270a162b8e25f86ec5 Mon Sep 17 00:00:00 2001 From: Will Miles Date: Mon, 12 Feb 2024 08:59:50 -0500 Subject: [PATCH 1/5] LockedJsonResponse: Release early if possible Release the json buffer lock as soon as we've finished serializing. This should slightly reduce the number of lock collisions as the response class isn't destructed until after the last packet is ack'd. --- wled00/json.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/wled00/json.cpp b/wled00/json.cpp index e63a09ee9..af8ed89ef 100644 --- a/wled00/json.cpp +++ b/wled00/json.cpp @@ -1022,14 +1022,26 @@ void serializeModeNames(JsonArray arr) // Global buffer locking response helper class (to make sure lock is released when AsyncJsonResponse is destroyed) class LockedJsonResponse: public AsyncJsonResponse { + bool _holding_lock; public: // WARNING: constructor assumes requestJSONBufferLock() was successfully acquired externally/prior to constructing the instance // Not a good practice with C++. Unfortunately AsyncJsonResponse only has 2 constructors - for dynamic buffer or existing buffer, // with existing buffer it clears its content during construction // if the lock was not acquired (using JSONBufferGuard class) previous implementation still cleared existing buffer - inline LockedJsonResponse(JsonDocument *doc, bool isArray) : AsyncJsonResponse(doc, isArray) {}; + inline LockedJsonResponse(JsonDocument* doc, bool isArray) : AsyncJsonResponse(doc, isArray), _holding_lock(true) {}; + + virtual size_t _fillBuffer(uint8_t *buf, size_t maxLen) { + size_t result = AsyncJsonResponse::_fillBuffer(buf, maxLen); + // Release lock as soon as we're done filling content + if (((result + _sentLength) >= (_contentLength)) && _holding_lock) { + releaseJSONBufferLock(); + _holding_lock = false; + } + return result; + } + // destructor will remove JSON buffer lock when response is destroyed in AsyncWebServer - virtual ~LockedJsonResponse() { releaseJSONBufferLock(); }; + virtual ~LockedJsonResponse() { if (_holding_lock) releaseJSONBufferLock(); }; }; void serveJson(AsyncWebServerRequest* request) From 91c11a18e0fd9d447a62f5798e408bb649342edc Mon Sep 17 00:00:00 2001 From: Christian Schwinne Date: Sat, 9 Mar 2024 21:31:53 +0100 Subject: [PATCH 2/5] Update CONTRIBUTING.md --- CONTRIBUTING.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 560a70973..ddf61ec80 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,6 +2,10 @@ Here are a few suggestions to make it easier for you to contribute! +### Target branch for pull requests + +Please make all PRs against the `0_15` branch. + ### Code style When in doubt, it is easiest to replicate the code style you find in the files you want to edit :) @@ -73,6 +77,6 @@ Good: ``` -There is no set character limit for a comment within a line, -though as a rule of thumb you should wrap your comment if it exceeds the width of your editor window. +There is no hard character limit for a comment within a line, +though as a rule of thumb consider wrapping after 120 characters. Inline comments are OK if they describe that line only and are not exceedingly wide. \ No newline at end of file From 21d0f10dd7194675d28e7f4a9b588a3883e960d4 Mon Sep 17 00:00:00 2001 From: Christian Schwinne Date: Sat, 9 Mar 2024 21:59:45 +0100 Subject: [PATCH 3/5] Fix AR compilation --- platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index d7ed06eda..156d2782d 100644 --- a/platformio.ini +++ b/platformio.ini @@ -245,7 +245,7 @@ lib_deps = ${env.lib_deps} # additional build flags for audioreactive AR_build_flags = -D USERMOD_AUDIOREACTIVE -D UM_AUDIOREACTIVE_USE_NEW_FFT -AR_lib_deps = https://github.com/kosme/arduinoFFT#develop @ ^1.9.2 +AR_lib_deps = AR_lib_deps = https://github.com/kosme/arduinoFFT#419d7b0 [esp32_idf_V4] ;; experimental build environment for ESP32 using ESP-IDF 4.4.x / arduino-esp32 v2.0.5 From 6322ab9f07c4a171ad25526f1d55fdcbbafc1fb0 Mon Sep 17 00:00:00 2001 From: Christian Schwinne Date: Sat, 9 Mar 2024 22:00:18 +0100 Subject: [PATCH 4/5] . --- platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index 156d2782d..78ecc8fca 100644 --- a/platformio.ini +++ b/platformio.ini @@ -245,7 +245,7 @@ lib_deps = ${env.lib_deps} # additional build flags for audioreactive AR_build_flags = -D USERMOD_AUDIOREACTIVE -D UM_AUDIOREACTIVE_USE_NEW_FFT -AR_lib_deps = AR_lib_deps = https://github.com/kosme/arduinoFFT#419d7b0 +AR_lib_deps = https://github.com/kosme/arduinoFFT#419d7b0 [esp32_idf_V4] ;; experimental build environment for ESP32 using ESP-IDF 4.4.x / arduino-esp32 v2.0.5 From f55465f8b8ce1f2daecb8ee0bd489f957cda1ed2 Mon Sep 17 00:00:00 2001 From: Blaz Kristan Date: Mon, 11 Mar 2024 18:02:03 +0100 Subject: [PATCH 5/5] Fix AsyncWebServer library --- platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index 78ecc8fca..edcd321dd 100644 --- a/platformio.ini +++ b/platformio.ini @@ -181,7 +181,7 @@ lib_deps = fastled/FastLED @ 3.6.0 IRremoteESP8266 @ 2.8.2 makuna/NeoPixelBus @ 2.7.5 - https://github.com/Aircoookie/ESPAsyncWebServer.git @ ~2.0.7 + https://github.com/Aircoookie/ESPAsyncWebServer.git @ ^2.1.0 #For use of the TTGO T-Display ESP32 Module with integrated TFT display uncomment the following line #TFT_eSPI #For compatible OLED display uncomment following