ESPectro32 Library
Library for using ESPectro32 board
 All Classes Functions Variables Enumerations Enumerator Pages
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
WiFiManager Class Reference

WiFiManager class. More...

#include <WiFiManager.h>

Inheritance diagram for WiFiManager:
Task

Public Types

enum  Status_t { WIFI_STATUS_STA_DISCONNECTED, WIFI_STATUS_STA_CONNECTING, WIFI_STATUS_STA_CONNECTED, WIFI_STATUS_STA_SMARTCONFIG }
 
typedef std::function< void(system_event_t
*event)> 
WifiEventCallback
 
typedef std::function< void(bool)> WifiConnectedCallback
 
typedef std::function< void()> WifiDisconnectedCallback
 
typedef std::function< void(uint64_t
elapsedTime, Status_t status)> 
WifiConnectingCallback
 

Public Member Functions

esp_err_t begin (wifi_mode_t mode=WIFI_MODE_STA, bool autoConnect=true)
 
esp_err_t connectToAP (const char *ssid, const char *pwd, uint32_t ticks_to_wait=WIFIMANAGER_DEFAULT_TIMEOUT)
 
esp_err_t startSmartConfig (smartconfig_type_t sc_type=SC_TYPE_ESPTOUCH, uint32_t ticks_to_wait=WIFIMANAGER_DEFAULT_TIMEOUT)
 
void disconnect ()
 
void run ()
 
void runAsync (void *taskData)
 Body of the task to execute. More...
 
tcpip_adapter_ip_info_t getStationIpInfo ()
 
std::string getStationIpAddress ()
 
void onWiFiEvent (WifiEventCallback cb)
 
void onWiFiConnected (WifiConnectedCallback cb)
 
void onWiFiDisconnected (WifiDisconnectedCallback cb)
 
void onWiFiConnecting (WifiConnectingCallback cb)
 
void notifyEvent (system_event_t *event)
 
bool waitForConnection ()
 
- Public Member Functions inherited from Task
 Task (std::string taskName="Task", uint16_t stackSize=2048, UBaseType_t priority=5)
 
 Task (BaseType_t coreId, std::string taskName="Task", uint16_t stackSize=2048, UBaseType_t priority=5)
 
void setStackSize (uint16_t stackSize)
 
void setPriority (UBaseType_t priority)
 
void setTaskName (std::string &taskN)
 
void start (void *taskData=nullptr)
 Start an instance of the task. More...
 
void stop ()
 
void delay (int ms)
 Suspend the task for the specified milliseconds. More...
 

Private Member Functions

esp_err_t loadSavedStaConfig (wifi_sta_config_t *saved_sta_config)
 
esp_err_t saveStaConfig (wifi_sta_config_t *sta_config)
 

Private Attributes

wifi_mode_t currentMode_ = WIFI_MODE_NULL
 
WifiEventCallback wifiEventCallback_ = nullptr
 
WifiConnectedCallback wifiConnectedCallback_ = nullptr
 
WifiDisconnectedCallback wifiDisconnectedCallback_ = nullptr
 
WifiConnectingCallback wifiConnectingCallback_ = nullptr
 
Status_t currentStatus_ = WIFI_STATUS_STA_DISCONNECTED
 
uint32_t connectTimeout_ = 0
 
uint64_t lastConnectingCheckMicros_ = 0
 
bool newConnection_ = false
 
wifi_sta_config_t * savedStaConfig = NULL
 

Detailed Description

WiFiManager class.

It wraps WiFi station functionalities to connect to Access Point. It supports connecting to an Access Point using stored WiFi credentials. When no credentials stored, it will activate Smart Config so you can "transfer" the credentials to it via Smart Config app (available for iOS and Android). Upon successful connection, the credentials will be stored to be used later.

Currently only supports as "station". Possibly later will make it possible as "access point".

Examples:
examples-idf/ex_wifi_conn_anim.hpp.

Member Enumeration Documentation

Enumerator
WIFI_STATUS_STA_DISCONNECTED 

ESP32 station disconnected

WIFI_STATUS_STA_CONNECTING 

ESP32 station connecting

WIFI_STATUS_STA_CONNECTED 

ESP32 station connected

Member Function Documentation

esp_err_t WiFiManager::begin ( wifi_mode_t  mode = WIFI_MODE_STA,
bool  autoConnect = true 
)

Call this method first before anything else.

Parameters
[in]modeThe WiFi mode, default as station
[in]autoConnectSetting this to true will make it automatically connect to stored SSID and stored password, or if no SSD stored, it will automatically activate Smart Config.
Examples:
examples-idf/ex_wifi_conn_anim.hpp.
void WiFiManager::runAsync ( void *  data)
virtual

Body of the task to execute.

This function must be implemented in the subclass that represents the actual task to run. When a task is started by calling start(), this is the code that is executed in the newly created task.

Parameters
[in]dataThe data passed in to the newly started task.

Implements Task.

esp_err_t WiFiManager::startSmartConfig ( smartconfig_type_t  sc_type = SC_TYPE_ESPTOUCH,
uint32_t  ticks_to_wait = WIFIMANAGER_DEFAULT_TIMEOUT 
)

Explicitly start Smart Config. Most of the time, you don't have to call it manually, unless you want to change the SSID it connects to, possibly via hardware action (button push?).

bool WiFiManager::waitForConnection ( )

Call this method to "block" current process until WiFi is connected.

Examples:
examples-idf/ex_wifi_conn_anim.hpp.

The documentation for this class was generated from the following files: