RBE1001Lib
|
#include <WifiManager.h>
Public Member Functions | |
WifiManager () | |
virtual | ~WifiManager () |
void | loop () |
void | setup () |
void | setupAP () |
void | setupScan () |
void | printState () |
enum connectionState | getState () |
void | WiFiEvent (WiFiEvent_t event) |
bool | isApMode () |
void | erase () |
void | disconnect () |
int | updateApList () |
Static Public Attributes | |
static WifiManager * | staticRef = NULL |
Private Member Functions | |
void | connectToWiFi (const char *ssid, const char *pwd) |
void | startAP () |
void | rescan () |
void | runSerialLoop () |
void | setPassword (String ssid, String pass) |
String | getPassword (String ssid, String defaultPass="none") |
String | getPasswordKey (String ssid) |
Private Attributes | |
bool | APMode =false |
long | timeOfLastDisconnect = 0 |
long | timeOfLastConnect = 0 |
String | networkNameServer |
String | networkPswdServer |
String | apNameServer |
String | apPswdServer |
int | connectionAttempts =0 |
Preferences | preferences |
long | timeSinceAPPrint =0 |
long | timeSinceAPStart =0 |
enum connectionState | state =firstStart |
enum connectionState | whatToDoAfterScanning =reconnect |
bool | setupDone = false |
Definition at line 30 of file WifiManager.h.
WifiManager::WifiManager | ( | ) |
WifiManager is a class to manage the WIFI connections and reconnections THis manager will also take over the Serial object and use it to set connection To connect to an AP, type the AP into the arduino serial moniter and hit enter When the password prompt comes up, type the password and and hit enter. if the password is correct, the AP will be stored for a fast connect next time.
To change the AP name, use ap:MyNewAPName instead of the ap to which you want to connect the password will be stored as the AP name
Definition at line 17 of file WifiManager.cpp.
|
virtual |
Definition at line 20 of file WifiManager.cpp.
|
private |
Definition at line 124 of file WifiManager.cpp.
References Disconnected, rescanIncrement, state, timeOfLastConnect, and timeOfLastDisconnect.
Referenced by loop().
void WifiManager::disconnect | ( | ) |
disconnect Force a disconnection and rescan of the system
Definition at line 394 of file WifiManager.cpp.
References APMode, connectionAttempts, Disconnected, networkNameServer, printState(), rescanIncrement, state, timeOfLastConnect, timeOfLastDisconnect, and timeoutTime.
Referenced by loop(), runSerialLoop(), setupScan(), and WiFiEvent().
void WifiManager::erase | ( | ) |
erase() Erase all stored passwords and AP mode settings
Definition at line 531 of file WifiManager.cpp.
References preferences.
Referenced by runSerialLoop().
|
private |
Definition at line 286 of file WifiManager.cpp.
References getPasswordKey(), and preferences.
Referenced by loop(), rescan(), setup(), and startAP().
|
private |
Definition at line 277 of file WifiManager.cpp.
References PASS_LEN_KEY.
Referenced by getPassword(), and setPassword().
enum connectionState WifiManager::getState | ( | ) |
bool WifiManager::isApMode | ( | ) |
Check to see if the device is already in AP mode.
Definition at line 523 of file WifiManager.cpp.
References APMode.
void WifiManager::loop | ( | ) |
call the loop function to update the state
Definition at line 290 of file WifiManager.cpp.
References apconnected, APMode, apPswdServer, APWaitingForSTA, Connected, connectionAttempts, connectToWiFi(), disconnect(), Disconnected, firstStart, getPassword(), HaveSSIDSerial, InitialConnect, networkNameServer, networkPswdServer, preferences, printState(), reconnect, rescan(), rescanIncrement, runSerialLoop(), scanDone, scanRunning, setPassword(), startAP(), state, timeOfLastConnect, timeOfLastDisconnect, timeoutTime, timeSinceAPPrint, timeSinceAPStart, updateApList(), and whatToDoAfterScanning.
Referenced by loop(), and setup().
void WifiManager::printState | ( | ) |
A formated print statement of the current state
Definition at line 26 of file WifiManager.cpp.
References APWaitingForSTA, Connected, Disconnected, firstStart, HaveSSIDSerial, InitialConnect, reconnect, and state.
Referenced by disconnect(), loop(), and WiFiEvent().
|
private |
Definition at line 164 of file WifiManager.cpp.
References APMode, getPassword(), networkNameServer, networkPswdServer, preferences, reconnect, and state.
Referenced by loop().
|
private |
Definition at line 234 of file WifiManager.cpp.
References APMode, apNameServer, disconnect(), erase(), HaveSSIDSerial, networkNameServer, reconnect, and state.
Referenced by loop().
|
private |
Definition at line 283 of file WifiManager.cpp.
References getPasswordKey(), and preferences.
Referenced by loop(), and startAP().
void WifiManager::setup | ( | ) |
Perfoem a normal setup This will attempt to connect to a stored network. If the stored network is not found, it will re-scan and connect to a remembered network, if no remembered network is found, it will start AP mode
Definition at line 68 of file WifiManager.cpp.
References apNameServer, apPswdServer, connectionAttempts, getPassword(), networkNameServer, networkPswdServer, preferences, reconnect, setupDone, state, staticRef, and WiFiEventWifiManager().
Referenced by setup(), setupAP(), and setupScan().
void WifiManager::setupAP | ( | ) |
void WifiManager::setupScan | ( | ) |
Start the manager but re-scan the environment first
Definition at line 64 of file WifiManager.cpp.
References disconnect(), and setup().
Referenced by setup().
|
private |
Definition at line 95 of file WifiManager.cpp.
References apNameServer, apPswdServer, getPassword(), preferences, rescanIncrement, setPassword(), timeOfLastConnect, timeOfLastDisconnect, and timeSinceAPStart.
Referenced by loop().
int WifiManager::updateApList | ( | ) |
Update AP list
This function will update the AP list, then reconnect
Definition at line 151 of file WifiManager.cpp.
References reconnect, scanRunning, state, and whatToDoAfterScanning.
Referenced by loop().
void WifiManager::WiFiEvent | ( | WiFiEvent_t | event | ) |
Internal function to process wifi events This is only public to allow the static wifi event to call it
< ESP32 station got IP from connected AP
< ESP32 station disconnected from AP
< ESP32 WiFi ready
< ESP32 finish scanning AP
< ESP32 station start
< ESP32 station stop
< ESP32 station connected to AP
< the auth mode of AP connected by ESP32 station changed
< ESP32 station lost IP and the IP is reset to 0
< ESP32 station wps succeeds in enrollee mode
< ESP32 station wps fails in enrollee mode
< ESP32 station wps timeout in enrollee mode
< ESP32 station wps pin code in enrollee mode
< ESP32 soft-AP start
< ESP32 soft-AP stop
< a station connected to ESP32 soft-AP
< a station disconnected from ESP32 soft-AP
< Receive probe request packet in soft-AP interface
< ESP32 station or ap interface v6IP addr is preferred
< ESP32 ethernet start
< ESP32 ethernet stop
< ESP32 ethernet phy link up
< ESP32 ethernet phy link down
< ESP32 ethernet got IP from connected AP
Definition at line 406 of file WifiManager.cpp.
References apconnected, APMode, APWaitingForSTA, Connected, connectionAttempts, disconnect(), Disconnected, HaveSSIDSerial, InitialConnect, printState(), rescanIncrement, state, timeOfLastConnect, and timeOfLastDisconnect.
Referenced by WiFiEventWifiManager().
|
private |
Definition at line 34 of file WifiManager.h.
Referenced by disconnect(), isApMode(), loop(), rescan(), runSerialLoop(), setupAP(), and WiFiEvent().
|
private |
Definition at line 40 of file WifiManager.h.
Referenced by runSerialLoop(), setup(), and startAP().
|
private |
Definition at line 41 of file WifiManager.h.
|
private |
Definition at line 42 of file WifiManager.h.
Referenced by disconnect(), loop(), setup(), and WiFiEvent().
|
private |
Definition at line 38 of file WifiManager.h.
Referenced by disconnect(), loop(), rescan(), runSerialLoop(), and setup().
|
private |
Definition at line 39 of file WifiManager.h.
|
private |
Definition at line 43 of file WifiManager.h.
Referenced by erase(), getPassword(), loop(), rescan(), setPassword(), setup(), and startAP().
|
private |
Definition at line 49 of file WifiManager.h.
Referenced by setup().
|
private |
Definition at line 47 of file WifiManager.h.
Referenced by connectToWiFi(), disconnect(), getState(), loop(), printState(), rescan(), runSerialLoop(), setup(), setupAP(), updateApList(), and WiFiEvent().
|
static |
Static reference used by the wifi event to pass the event from the static context to the object context.
Definition at line 58 of file WifiManager.h.
Referenced by setup().
|
private |
Definition at line 37 of file WifiManager.h.
Referenced by connectToWiFi(), disconnect(), loop(), startAP(), and WiFiEvent().
|
private |
Definition at line 36 of file WifiManager.h.
Referenced by connectToWiFi(), disconnect(), loop(), startAP(), and WiFiEvent().
|
private |
Definition at line 45 of file WifiManager.h.
Referenced by loop().
|
private |
Definition at line 46 of file WifiManager.h.
|
private |
Definition at line 48 of file WifiManager.h.
Referenced by loop(), and updateApList().