[ai] refactorings
This commit is contained in:
parent
7f120ae62d
commit
83e51e87fe
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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("<ul>"));
|
||||
}
|
||||
|
|
@ -550,7 +554,7 @@ void DirectoryNode::streamDirectoryHTML(Print &out) const {
|
|||
out.print(F("\"><b>"));
|
||||
out.print(name);
|
||||
out.println(F("</b></li>"));
|
||||
delay(0); // Yield to allow network stack to send buffered data
|
||||
yield(); // Yield to allow network stack to send buffered data
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < mp3Files.size(); i++) {
|
||||
|
|
@ -559,10 +563,12 @@ void DirectoryNode::streamDirectoryHTML(Print &out) const {
|
|||
out.print(F("\">"));
|
||||
out.print(mp3Files[i]);
|
||||
out.println(F("</li>"));
|
||||
|
||||
#ifdef DEBUG
|
||||
Serial.printf("stream song: %s\n",mp3Files[i].c_str());
|
||||
#endif
|
||||
// Yield every few items to allow the async web server to send buffered data
|
||||
if (i % 5 == 4) {
|
||||
delay(1);
|
||||
yield();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -572,7 +578,7 @@ void DirectoryNode::streamDirectoryHTML(Print &out) const {
|
|||
|
||||
if (name == "/") {
|
||||
out.println(F("</ul>"));
|
||||
delay(0); // Final yield before completing
|
||||
yield(); // Final yield before completing
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue