Skip to content

Commit

Permalink
Fix for disconnects on ESP8266 with static JSON buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
blazoncek committed Dec 10, 2021
1 parent 5dbc45e commit fed16fd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions wled00/const.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion wled00/wled.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,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;
Expand Down

0 comments on commit fed16fd

Please sign in to comment.