Asynchronous WiFi connection with automatic fallback to Access Point (AP) mode if a connection times out.
Supports ESP8266 and ESP32
Use this library when your WiFi credentials are stored externally or are not known in advance.
If the SSID is passed as an empty string, the device will launch in AP mode.
If a connection fails, AP mode will be launched automatically for web-based configuration or user interaction.
// AP name, AP password, timeout in seconds, disable AP after STA connection
WiFiConnectorClass(const String& APname = "ESP AP",
const String& APpass = "",
uint16_t timeout = 60 * 3,
bool closeAP = true);
void setName(const String& name); // Set AP name
void setPass(const String& pass); // Set AP password
void setTimeout(uint16_t timeout); // Set connection timeout
void setAPIdleTimeout(60000); // 60 second AP-Idle-Timeout
void closeAP(bool close); // Enable/disable AP shutdown after STA connect
void onConnect(ConnectorCallback cb); // Set successful connect callback
void onError(ConnectorCallback cb); // Set error callback after AP starts
bool connect(const String& ssid, const String& pass = ""); // Start connection
bool tick(); // Call in loop()
bool connected(); // Returns true if STA connected
bool connecting(); // Returns true if still connecting