Default to AP if wifi is inaccessible.

This commit is contained in:
mattbk 2023-09-27 20:43:01 -05:00
parent db7c0adfed
commit 9679248691

View File

@ -198,7 +198,8 @@ const char index_html[] PROGMEM = R"rawliteral(
Existing Wireless Network Password: <input type="password" name="inputPassword" value = "%inputPassword%"><br>
</p><p>
Access Point: Connect to wireless network "vulpes" and point your browser to URL <a href="http://192.168.0.1">http://192.168.0.1</a> (http, not http<b>s</b>)<br>
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).<br>
If an existing network can't be connected to, an access point will be set up.
</p>
<input type="submit" value="Submit and Reboot">
</form>
@ -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: ");