From 9679248691f3a5668686bdb81ec4a976d58fc269 Mon Sep 17 00:00:00 2001 From: mattbk Date: Wed, 27 Sep 2023 20:43:01 -0500 Subject: [PATCH] Default to AP if wifi is inaccessible. --- src/main.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index bbeb011..c15d0c0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -198,7 +198,8 @@ const char index_html[] PROGMEM = R"rawliteral( Existing Wireless Network Password:

Access Point: Connect to wireless network "vulpes" and point your browser to URL http://192.168.0.1 (http, not https)
- Existing Network (advanced): Connect to the same existing network and use the proper IP address (useful if you have access to the router or a serial connection). + Existing Network (advanced): Connect to the same existing network and use the proper IP address (useful if you have access to the router or a serial connection).
+ If an existing network can't be connected to, an access point will be set up.

@@ -406,10 +407,13 @@ void setup() { const char* password_char = yourInputPassword.c_str(); WiFi.begin(ssid_char, password_char); if (WiFi.waitForConnectResult() != WL_CONNECTED) { - Serial.println("WiFi Failed!"); + Serial.println("WiFi Failed! Setting up access point 'vulpes'..."); // If you fail to connect, act as new access point + WiFi.disconnect(true); WiFi.softAPConfig(local_ip, gateway, subnet); WiFi.softAP(ssid_ap, password_ap); + // update the file so the webform is right + writeFile(SPIFFS, "/inputNetwork.txt", "0"); //return; } Serial.print("IP Address: ");