From 432c5837f0afa33dc0db1fa13e967d90946ef68c Mon Sep 17 00:00:00 2001 From: Blaz Kristan Date: Sun, 30 Apr 2023 17:30:36 +0200 Subject: [PATCH] Bugfix - WiFi power for Lolin S2 & C3 (use -DLOLIN_WIFI_FIX) - web response buffer size (corruption when websockets not used) --- platformio.ini | 3 +++ wled00/wled.cpp | 7 ++++++- wled00/wled_server.cpp | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/platformio.ini b/platformio.ini index bb12fa45..e46b9ec5 100644 --- a/platformio.ini +++ b/platformio.ini @@ -573,6 +573,9 @@ build_unflags = ${common.build_unflags} -DARDUINO_USB_CDC_ON_BOOT=1 build_flags = ${common.build_flags} ${esp32s2.build_flags} #-D WLED_RELEASE_NAME=LolinS2 -DBOARD_HAS_PSRAM -DARDUINO_USB_CDC_ON_BOOT=0 + -DARDUINO_USB_MSC_ON_BOOT=0 + -DARDUINO_USB_DFU_ON_BOOT=0 + -DLOLIN_WIFI_FIX ; seems to work much better with this -D WLED_USE_PSRAM -D WLED_WATCHDOG_TIMEOUT=0 -D CONFIG_ASYNC_TCP_USE_WDT=0 diff --git a/wled00/wled.cpp b/wled00/wled.cpp index 9e915218..22297503 100644 --- a/wled00/wled.cpp +++ b/wled00/wled.cpp @@ -505,6 +505,9 @@ void WLED::initAP(bool resetAP) DEBUG_PRINTLN(apSSID); WiFi.softAPConfig(IPAddress(4, 3, 2, 1), IPAddress(4, 3, 2, 1), IPAddress(255, 255, 255, 0)); WiFi.softAP(apSSID, apPass, apChannel, apHide); + #if defined(LOLIN_WIFI_FIX) && (defined(ARDUINO_ARCH_ESP32C3) || defined(ARDUINO_ARCH_ESP32S2)) + WiFi.setTxPower(WIFI_POWER_8_5dBm); + #endif if (!apActive) // start captive portal if AP active { @@ -662,8 +665,10 @@ void WLED::initConnection() #endif WiFi.begin(clientSSID, clientPass); - #ifdef ARDUINO_ARCH_ESP32 + #if defined(LOLIN_WIFI_FIX) && (defined(ARDUINO_ARCH_ESP32C3) || defined(ARDUINO_ARCH_ESP32S2)) + WiFi.setTxPower(WIFI_POWER_8_5dBm); + #endif WiFi.setSleep(!noWifiSleep); WiFi.setHostname(hostname); #else diff --git a/wled00/wled_server.cpp b/wled00/wled_server.cpp index 9fd64b55..8741255c 100644 --- a/wled00/wled_server.cpp +++ b/wled00/wled_server.cpp @@ -219,7 +219,7 @@ void initServer() } } request->send(200, "application/json", F("{\"success\":true}")); - }); + }, JSON_BUFFER_SIZE); server.addHandler(handler); server.on("/version", HTTP_GET, [](AsyncWebServerRequest *request){