mirror of
https://github.com/alexhopeoconnor/WiFiManager.git
synced 2026-10-04 02:48:13 +10:00
adds preloadWiFi default ssid pass
This commit is contained in:
+8
-1
@@ -316,7 +316,7 @@ boolean WiFiManager::autoConnect(char const *apName, char const *apPassword) {
|
||||
// and we have no idea WHAT we are connected to
|
||||
}
|
||||
|
||||
if(connected || connectWifi("", "") == WL_CONNECTED){
|
||||
if(connected || connectWifi(_defaultssid, _defaultpass) == WL_CONNECTED){
|
||||
//connected
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(F("AutoConnect: SUCCESS"));
|
||||
@@ -2921,6 +2921,13 @@ void WiFiManager::setHttpPort(uint16_t port){
|
||||
_httpPort = port;
|
||||
}
|
||||
|
||||
|
||||
bool WiFiManager::preloadWiFi(String ssid, String pass){
|
||||
_defaultssid = ssid;
|
||||
_defaultpass = pass;
|
||||
return true;
|
||||
}
|
||||
|
||||
// HELPERS
|
||||
|
||||
/**
|
||||
|
||||
+9
-3
@@ -367,6 +367,9 @@ class WiFiManager
|
||||
// check if web portal is active (true)
|
||||
bool getWebPortalActive();
|
||||
|
||||
// to preload autoconnect for test fixtures or other uses that skip esp sta config
|
||||
bool preloadWiFi(String ssid, String pass);
|
||||
|
||||
std::unique_ptr<DNSServer> dnsServer;
|
||||
|
||||
#if defined(ESP32) && defined(WM_WEBSERVERSHIM)
|
||||
@@ -397,9 +400,11 @@ class WiFiManager
|
||||
const byte HTTP_PORT = 80;
|
||||
String _apName = "no-net";
|
||||
String _apPassword = "";
|
||||
String _ssid = "";
|
||||
String _pass = "";
|
||||
|
||||
String _ssid = ""; // var temp ssid
|
||||
String _pass = ""; // var temp psk
|
||||
String _defaultssid = ""; // preload ssid
|
||||
String _defaultpass = ""; // preload pass
|
||||
|
||||
// options flags
|
||||
unsigned long _configPortalTimeout = 0; // ms close config portal loop if set (depending on _cp/webClientCheck options)
|
||||
unsigned long _connectTimeout = 0; // ms stop trying to connect to ap if set
|
||||
@@ -467,6 +472,7 @@ class WiFiManager
|
||||
// cache time helps throttle this
|
||||
// async enables asyncronous scans, so they do not block anything
|
||||
// the refresh button bypasses cache
|
||||
// no aps found is problematic as scans are always going to want to run, leading to page load delays
|
||||
boolean _preloadwifiscan = false; // preload wifiscan if true
|
||||
boolean _asyncScan = false; // perform wifi network scan async
|
||||
unsigned int _scancachetime = 30000; // ms cache time for background scans
|
||||
|
||||
Reference in New Issue
Block a user