From 83e51e87fed24208cb1d5f2ead2d0e1103a2a8cf Mon Sep 17 00:00:00 2001 From: Stefan Ostermann Date: Sun, 2 Nov 2025 13:07:52 +0100 Subject: [PATCH] [ai] refactorings --- platformio.ini | 12 ++++++------ src/DirectoryNode.cpp | 14 ++++++++++---- src/main.cpp | 5 ++--- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/platformio.ini b/platformio.ini index 00732e7..61dabf4 100644 --- a/platformio.ini +++ b/platformio.ini @@ -21,16 +21,16 @@ lib_deps = monitor_speed = 115200 build_flags = -Os ; Optimize for size - -DCORE_DEBUG_LEVEL=0 ; Disable all debug output + ; -DCORE_DEBUG_LEVEL=0 ; Disable all debug output -DARDUINO_LOOP_STACK_SIZE=3072 ; Further reduce from 4096 -DWIFI_TASK_STACK_SIZE=3072 ; Reduce WiFi task stack -DARDUINO_EVENT_TASK_STACK_SIZE=2048 ; Reduce event task stack -DTCPIP_TASK_STACK_SIZE=2048 ; Reduce TCP/IP stack -DESP_TASK_WDT_TIMEOUT_S=10 ; Reduce watchdog timeout - -DCONFIG_ASYNC_TCP_MAX_ACK_TIME=3000 - -DCONFIG_ASYNC_TCP_PRIORITY=10 ; (keep default) - -DCONFIG_ASYNC_TCP_QUEUE_SIZE=64 ; (keep default) - -DCONFIG_ASYNC_TCP_RUNNING_CORE=1 ; force async_tcp task to be on same core as Arduino app (default is any core) - -DCONFIG_ASYNC_TCP_STACK_SIZE=4096 ; reduce the stack size (default is 16K) +; -DCONFIG_ASYNC_TCP_MAX_ACK_TIME=3000 +; -DCONFIG_ASYNC_TCP_PRIORITY=10 ; (keep default) +; -DCONFIG_ASYNC_TCP_QUEUE_SIZE=64 ; (keep default) + ; -DCONFIG_ASYNC_TCP_RUNNING_CORE=1 ; force async_tcp task to be on same core as Arduino app (default is any core) + -DCONFIG_ASYNC_TCP_STACK_SIZE=4096 ; reduce the stack size (default is 16K) monitor_filters = esp32_exception_decoder board_build.partitions = huge_app.csv diff --git a/src/DirectoryNode.cpp b/src/DirectoryNode.cpp index 369b461..e5b8111 100644 --- a/src/DirectoryNode.cpp +++ b/src/DirectoryNode.cpp @@ -540,6 +540,10 @@ DirectoryNode *DirectoryNode::advanceToNextMP3(const String *currentGlobal) void DirectoryNode::streamDirectoryHTML(Print &out) const { +#ifdef DEBUG + Serial.printf("StreamDirectoryHTML name=%s numOfFiles=%i\n", name, mp3Files.size()); +#endif + if (name == "/") { out.println(F("")); - delay(0); // Final yield before completing + yield(); // Final yield before completing } } diff --git a/src/main.cpp b/src/main.cpp index ba25faa..cd3dcd1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1205,8 +1205,7 @@ void init_webserver() { webreq_enter(); request->onDisconnect([](){ webreq_exit(); }); // Stream the response directly from the directory tree to avoid large temporary Strings - // Stream the response directly from the directory tree to avoid large temporary Strings - AsyncResponseStream* stream = request->beginResponseStream(txt_html_charset); + AsyncResponseStream* stream = request->beginResponseStream(txt_html_charset, 512); #ifdef DEBUG Serial.printf("Serving /directory heap=%u webreq_cnt=%u numOfFiles=%u\n", (unsigned)xPortGetFreeHeapSize(), (unsigned)webreq_cnt, rootNode.getNumOfFiles()); #endif @@ -1222,7 +1221,7 @@ void init_webserver() { webreq_enter(); request->onDisconnect([](){ webreq_exit();}); // Stream mapping to avoid Content-Length mismatches and reduce heap spikes - AsyncResponseStream* stream = request->beginResponseStream(txt_html_charset); + AsyncResponseStream* stream = request->beginResponseStream(txt_html_charset, 512); #ifdef DEBUG Serial.printf("Serving /mapping heap=%u webreq_cnt=%u\n", (unsigned)xPortGetFreeHeapSize(), (unsigned)webreq_cnt); #endif