From e1cd45c57ef47c815a2d6f1f36e70c05b18a5b47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Kristan?= Date: Fri, 10 Dec 2021 12:51:44 +0100 Subject: [PATCH] Bugfix for heap low disconnect. --- wled00/const.h | 6 ++++++ wled00/wled.cpp | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/wled00/const.h b/wled00/const.h index d338e930..51c3d496 100644 --- a/wled00/const.h +++ b/wled00/const.h @@ -301,6 +301,12 @@ #define JSON_BUFFER_SIZE 20480 #endif +#ifdef WLED_USE_DYNAMIC_JSON + #define MIN_HEAP_SIZE JSON_BUFFER_SIZE+512 +#else + #define MIN_HEAP_SIZE 4096 +#endif + // Maximum size of node map (list of other WLED instances) #ifdef ESP8266 #define WLED_MAX_NODES 24 diff --git a/wled00/wled.cpp b/wled00/wled.cpp index 1fb1565a..2a80ccce 100644 --- a/wled00/wled.cpp +++ b/wled00/wled.cpp @@ -626,7 +626,7 @@ void WLED::handleConnection() // reconnect WiFi to clear stale allocations if heap gets too low if (now - heapTime > 5000) { uint32_t heap = ESP.getFreeHeap(); - if (heap < JSON_BUFFER_SIZE+512 && lastHeap < JSON_BUFFER_SIZE+512) { + if (heap < MIN_HEAP_SIZE && lastHeap < MIN_HEAP_SIZE) { DEBUG_PRINT(F("Heap too low! ")); DEBUG_PRINTLN(heap); forceReconnect = true;