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:
2026-07-05 23:17:29 +02:00
parent c55eea0e14
commit d4745997dc
2 changed files with 31 additions and 3 deletions
+25
View File
@@ -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");