Default to AP if wifi is inaccessible.
This commit is contained in:
parent
db7c0adfed
commit
9679248691
|
@ -198,7 +198,8 @@ const char index_html[] PROGMEM = R"rawliteral(
|
||||||
Existing Wireless Network Password: <input type="password" name="inputPassword" value = "%inputPassword%"><br>
|
Existing Wireless Network Password: <input type="password" name="inputPassword" value = "%inputPassword%"><br>
|
||||||
</p><p>
|
</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>
|
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>
|
</p>
|
||||||
<input type="submit" value="Submit and Reboot">
|
<input type="submit" value="Submit and Reboot">
|
||||||
</form>
|
</form>
|
||||||
|
@ -406,10 +407,13 @@ void setup() {
|
||||||
const char* password_char = yourInputPassword.c_str();
|
const char* password_char = yourInputPassword.c_str();
|
||||||
WiFi.begin(ssid_char, password_char);
|
WiFi.begin(ssid_char, password_char);
|
||||||
if (WiFi.waitForConnectResult() != WL_CONNECTED) {
|
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
|
// If you fail to connect, act as new access point
|
||||||
|
WiFi.disconnect(true);
|
||||||
WiFi.softAPConfig(local_ip, gateway, subnet);
|
WiFi.softAPConfig(local_ip, gateway, subnet);
|
||||||
WiFi.softAP(ssid_ap, password_ap);
|
WiFi.softAP(ssid_ap, password_ap);
|
||||||
|
// update the file so the webform is right
|
||||||
|
writeFile(SPIFFS, "/inputNetwork.txt", "0");
|
||||||
//return;
|
//return;
|
||||||
}
|
}
|
||||||
Serial.print("IP Address: ");
|
Serial.print("IP Address: ");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user