mirror of
https://github.com/alexhopeoconnor/WiFiManager.git
synced 2026-10-17 16:41:31 +10:00
cleanup and get said name as per https://github.com/tzapu/WiFiManager/pull/52
added example of above
This commit is contained in:
@@ -3,11 +3,17 @@
|
||||
//needed for library
|
||||
#include <DNSServer.h>
|
||||
#include <ESP8266WebServer.h>
|
||||
#include <WiFiManager.h> //https://github.com/tzapu/WiFiManager
|
||||
#include "WiFiManager.h" //https://github.com/tzapu/WiFiManager
|
||||
|
||||
//WiFiManger
|
||||
//global intialization: this wastes memory, only used here to have access to wifiManager.getConfigPortalSSID()
|
||||
WiFiManager wifiManager;
|
||||
|
||||
void configModeCallback () {
|
||||
Serial.println("Entered config mode");
|
||||
Serial.println(WiFi.softAPIP());
|
||||
//if you used auto generated SSID, print it
|
||||
Serial.println(wifiManager.getConfigPortalSSID());
|
||||
}
|
||||
|
||||
void setup() {
|
||||
@@ -16,17 +22,18 @@ void setup() {
|
||||
|
||||
//WiFiManager
|
||||
//Local intialization. Once its business is done, there is no need to keep it around
|
||||
WiFiManager wifiManager;
|
||||
//WiFiManager wifiManager;
|
||||
//reset settings - for testing
|
||||
//wifiManager.resetSettings();
|
||||
|
||||
//set callback that gets called when connecting to previous WiFi fails, and enters Access Point mode
|
||||
wifiManager.setAPCallback(configModeCallback);
|
||||
|
||||
//fetches ssid and pass and tries to connect
|
||||
//if it does not connect it starts an access point with the specified name
|
||||
//here "AutoConnectAP"
|
||||
//and goes into a blocking loop awaiting configuration
|
||||
if(!wifiManager.autoConnect("AutoConnectAP")) {
|
||||
if(!wifiManager.autoConnect()) {
|
||||
Serial.println("failed to connect and hit timeout");
|
||||
//reset and try again, or maybe put it to deep sleep
|
||||
ESP.reset();
|
||||
|
||||
Reference in New Issue
Block a user