Update platform version and enhance WiFi handling
- Set platform version to espressif32@^6.10.0 for all environments - Add applyWifiTxPower function to adjust TX power for ESP32-C3 - Implement handleNotFound function for improved HTTP 404 handling
This commit is contained in:
+6
-3
@@ -11,7 +11,7 @@
|
||||
[env]
|
||||
|
||||
[env:esp32-s3-devkitc-1]
|
||||
platform = espressif32
|
||||
platform = espressif32@^6.10.0
|
||||
board = esp32-s3-devkitc-1
|
||||
framework = arduino
|
||||
monitor_speed = 115200
|
||||
@@ -24,7 +24,7 @@ lib_deps =
|
||||
[env:esp32dev]
|
||||
board = esp32dev
|
||||
framework = arduino
|
||||
platform = espressif32
|
||||
platform = espressif32@^6.10.0
|
||||
monitor_speed = 115200
|
||||
board_build.filesystem = littlefs
|
||||
lib_deps =
|
||||
@@ -35,9 +35,12 @@ lib_deps =
|
||||
[env:esp32-C3-devkitm-1]
|
||||
board = esp32-c3-devkitm-1
|
||||
framework = arduino
|
||||
platform = espressif32
|
||||
platform = espressif32@^6.10.0
|
||||
monitor_speed = 115200
|
||||
board_build.filesystem = littlefs
|
||||
build_flags =
|
||||
-DARDUINO_USB_MODE=1
|
||||
-DARDUINO_USB_CDC_ON_BOOT=1
|
||||
lib_deps =
|
||||
tzapu/WiFiManager@^2.0.17
|
||||
bblanchon/ArduinoJson@^7.4.3
|
||||
|
||||
@@ -382,6 +382,15 @@ static void startMDNS() {
|
||||
}
|
||||
}
|
||||
|
||||
static void applyWifiTxPower() {
|
||||
#if defined(CONFIG_IDF_TARGET_ESP32C3)
|
||||
WiFi.setTxPower(WIFI_POWER_MINUS_1dBm);
|
||||
Serial.println("[WIFI] ESP32-C3 detected, lowering TX power for stability");
|
||||
#else
|
||||
Serial.println("[WIFI] using default TX power");
|
||||
#endif
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Web helpers
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -566,6 +575,20 @@ html += ".switch input:checked+.slid{background:#4361ee}.switch input:checked+.s
|
||||
Serial.printf("[HTTP] GET / -> 200 (%u bytes)\n", html.length());
|
||||
}
|
||||
|
||||
static void handleNotFound() {
|
||||
String uri = server.uri();
|
||||
if (uri == "/favicon.ico" || uri == "/favicon.png" || uri == "/robots.txt" ||
|
||||
uri == "/generate_204" || uri == "/hotspot-detect.html" ||
|
||||
uri == "/connecttest.txt" || uri == "/redirect") {
|
||||
server.sendHeader("Location", "/");
|
||||
server.send(302);
|
||||
return;
|
||||
}
|
||||
|
||||
Serial.printf("[HTTP] 404 %s\n", uri.c_str());
|
||||
server.send(404, "text/plain", "Not found");
|
||||
}
|
||||
|
||||
static void handleConfig() {
|
||||
if (!requireAuth()) { Serial.println("[HTTP] POST /config -> 401"); return; }
|
||||
Serial.println("[HTTP] POST /config");
|
||||
@@ -678,6 +701,7 @@ static void startServer() {
|
||||
server.on("/config", HTTP_POST, handleConfig);
|
||||
server.on("/reset", HTTP_POST, handleReset);
|
||||
server.on("/set", handleSet);
|
||||
server.onNotFound(handleNotFound);
|
||||
server.begin();
|
||||
Serial.println("HTTP server started");
|
||||
}
|
||||
@@ -820,6 +844,7 @@ void setup() {
|
||||
delay(3000);
|
||||
applyFactoryResetIfNeeded(resetCount);
|
||||
|
||||
applyWifiTxPower();
|
||||
Serial.println("[WIFI] starting WiFiManager");
|
||||
WiFiManager wm;
|
||||
wm.setTitle("M1730");
|
||||
|
||||
Reference in New Issue
Block a user