Add option to set up for wifi or AP on compile #53
| @ -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: "); | ||||
|  | ||||
		Reference in New Issue
	
	Block a user