PersWiFiManager::PersWiFiManager
PersWiFiManager::attemptConnection
PersWiFiManager::setApCredentials
PersWiFiManager::setConnectNonBlock
PersWiFiManager::setupWiFiHandlers
Creates a new PersWiFiManager object
PersWiFiManager(ESP8266WebServer& s, DNSServer& d)
ESP8266WebServer& s An existing instance of the ESP8266WebServer class that will be used throughout the program
DNSServer& d An existing instance of the DNSServer class that will be used throughout the program
Declare the object globally, or at least in the same scope as your ESP8266WebServer and DNSServer
Attempts to auto-connect to last WiFi network used (or other if specified). Falls back to AP mode if unsuccessful.
bool attemptConnection()
bool attemptConnection(const String& ssid)
bool attemptConnection(const String& ssid, const String& pass)
const String& ssid (Optional) SSID to connect to. This overrides the default behavior of connecting to the last network used.
const String& pass (Optional) password for the specified SSID. Length must be >= 8 characters
true if successfully autoconnected, false if switched to AP mode
This function is already called inside begin, or when WiFi settings are changed, but this can be used for manual operation.
Begins automatic WiFi Configuration
bool begin()
bool begin(const String& ssid)
bool begin(const String& ssid, const String& pass)
const String& ssid (Optional) SSID to connect to. This overrides the default behavior of connecting to the last network used.
const String& pass (Optional) password for the specified SSID. Length must be >= 8 characters
true if successfully autoconnected
This sets up the server handlers for WiFi actions, then attempts to autoconnect. If no SSID is specified, it automatically attempts to connect to the last network used.
API Reference / PersWiFiManager::getApSsid Gets the AP mode SSID
String getApSsid()
String containing the AP mode SSID
The AP mode SSID is automatically set by the library, unless overridden by setApCredentials
Handles WiFi connecting/disconnecting in non-blocking mode
void handleWiFi()
This function does not need to be called in normal mode.
If the PersWiFiManager is set to non-blocking mode with setConnectNonBlock, this must be called in the main loop.
Attach a handler function that runs every time AP mode is started
void onAp(WiFiChangeHandlerFunction fn)
WiFiChangeHandlerFunction fn A generic function pointer to an AP mode handler function
This will run the handler function every time AP mode is started, when WiFi fails to connect or AP mode is manually triggered.
For successful connection handler, see onConnect
void setup(){
...
//uses a lambda function as the argument
persWM.onAp([]() {
//this code runs every time AP mode is started
DEBUG_PRINT("AP MODE");
DEBUG_PRINT(persWM.getApSsid());
});
Attach a handler function that runs every time WiFi connects
void onConnect(WiFiChangeHandlerFunction fn)
WiFiChangeHandlerFunction fn A generic function pointer to a wifi connection handler function
This will run the handler function every time the WiFi settings are changed and then a successful connection is made.
For unsuccessful / AP mode connection handler, see onAp
void setup(){
...
//uses a lambda function as the argument
persWM.onConnect([]() {
//this code runs every time wifi is connected
DEBUG_PRINT("wifi connected");
DEBUG_PRINT(WiFi.localIP());
EasySSDP::begin(server);
});
Sets the SSID (and password) to be used for AP mode
void setApCredentials(const String& apSsid)
void setApCredentials(const String& apSsid, const String& apPass)
const String& apSsid SSID to be used for AP mode.
const String& apPass (Optional) Password to be used for AP mode.
Passwords less than 8 characters long will be ignored.
Sets the PersWiFiManager connecting actions to non-blocking mode
void setConnectNonBlock(bool b)
bool b use true for non-blocking mode, false for regular mode
In non-blocking mode, handleWiFi must be called in the main loop
Attaches WiFi settings and captive DNS handlers to web server and DNS Server
void setupWiFiHandlers()
This function is already called inside begin() and doesn’t normally need to be used, but is available for manual operation.
Allows manual starting of AP mode
void startApMode()
WiFi settings are controlled by the user via the web-interface, but this allows a manual program-induced switch to AP mode.