mirror of
https://github.com/alexhopeoconnor/WiFiManager.git
synced 2026-10-04 02:48:13 +10:00
Merge branch 'master' of https://github.com/tzapu/WiFiManager
This commit is contained in:
+28
-13
@@ -705,15 +705,16 @@ boolean WiFiManager::startConfigPortal(char const *apName, char const *apPasswo
|
||||
DEBUG_WM(DEBUG_VERBOSE,F("Config Portal Running, non blocking/processing"));
|
||||
if(_configPortalTimeout > 0) DEBUG_WM(DEBUG_VERBOSE,F("Portal Timeout In"),(String)(_configPortalTimeout/1000) + (String)F(" seconds"));
|
||||
#endif
|
||||
return result;
|
||||
return result; // skip blocking loop
|
||||
}
|
||||
|
||||
// enter blocking loop, waiting for config
|
||||
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(DEBUG_VERBOSE,F("Config Portal Running, blocking, waiting for clients..."));
|
||||
if(_configPortalTimeout > 0) DEBUG_WM(DEBUG_VERBOSE,F("Portal Timeout In"),(String)(_configPortalTimeout/1000) + (String)F(" seconds"));
|
||||
#endif
|
||||
|
||||
// blocking loop waiting for config
|
||||
while(1){
|
||||
|
||||
// if timed out or abort, break
|
||||
@@ -729,6 +730,7 @@ boolean WiFiManager::startConfigPortal(char const *apName, char const *apPasswo
|
||||
state = processConfigPortal();
|
||||
|
||||
// status change, break
|
||||
// @todo what is this for, should be moved inside the processor
|
||||
if(state != WL_IDLE_STATUS){
|
||||
result = (state == WL_CONNECTED); // true if connected
|
||||
DEBUG_WM(DEBUG_DEV,F("configportal loop break"));
|
||||
@@ -756,6 +758,10 @@ boolean WiFiManager::process(){
|
||||
#if defined(WM_MDNS) && defined(ESP8266)
|
||||
MDNS.update();
|
||||
#endif
|
||||
|
||||
if(configPortalActive && !_configPortalIsBlocking){
|
||||
if(configPortalHasTimeout()) shutdownConfigPortal();
|
||||
}
|
||||
|
||||
if(webPortalActive || (configPortalActive && !_configPortalIsBlocking)){
|
||||
uint8_t state = processConfigPortal();
|
||||
@@ -805,8 +811,8 @@ uint8_t WiFiManager::processConfigPortal(){
|
||||
if ( _savewificallback != NULL) {
|
||||
_savewificallback();
|
||||
}
|
||||
shutdownConfigPortal();
|
||||
if(!_connectonsave) return WL_IDLE_STATUS;
|
||||
shutdownConfigPortal();
|
||||
return WL_CONNECTED; // CONNECT SUCCESS
|
||||
}
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
@@ -828,7 +834,7 @@ uint8_t WiFiManager::processConfigPortal(){
|
||||
shutdownConfigPortal();
|
||||
return WL_CONNECT_FAILED; // CONNECT FAIL
|
||||
}
|
||||
else{
|
||||
else if(_configPortalIsBlocking){
|
||||
// clear save strings
|
||||
_ssid = "";
|
||||
_pass = "";
|
||||
@@ -836,9 +842,14 @@ uint8_t WiFiManager::processConfigPortal(){
|
||||
WiFi_Disconnect();
|
||||
WiFi_enableSTA(false);
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(DEBUG_VERBOSE,F("Disabling STA"));
|
||||
DEBUG_WM(DEBUG_VERBOSE,F("Processing - Disabling STA"));
|
||||
#endif
|
||||
}
|
||||
else{
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(DEBUG_VERBOSE,F("Portal is non blocking - remaining open"));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
return WL_IDLE_STATUS;
|
||||
@@ -933,12 +944,16 @@ uint8_t WiFiManager::connectWifi(String ssid, String pass, bool connect) {
|
||||
// if ssid argument provided connect to that
|
||||
if (ssid != "") {
|
||||
wifiConnectNew(ssid,pass,connect);
|
||||
if(_saveTimeout > 0){
|
||||
connRes = waitForConnectResult(_saveTimeout); // use default save timeout for saves to prevent bugs in esp->waitforconnectresult loop
|
||||
}
|
||||
else {
|
||||
connRes = waitForConnectResult(0);
|
||||
}
|
||||
// @todo connect=false seems to disconnect sta in begin() so not sure if _connectonsave is useful at all
|
||||
// skip wait if not connecting
|
||||
// if(connect){
|
||||
if(_saveTimeout > 0){
|
||||
connRes = waitForConnectResult(_saveTimeout); // use default save timeout for saves to prevent bugs in esp->waitforconnectresult loop
|
||||
}
|
||||
else {
|
||||
connRes = waitForConnectResult(0);
|
||||
}
|
||||
// }
|
||||
}
|
||||
else {
|
||||
// connect using saved ssid if there is one
|
||||
@@ -2042,13 +2057,13 @@ String WiFiManager::getInfoData(String id){
|
||||
p.replace(FPSTR(T_1),WiFi.softAPgetHostname());
|
||||
}
|
||||
#endif
|
||||
#ifdef ESP8266
|
||||
// #ifdef ESP8266
|
||||
#ifndef WM_NOSOFTAPSSID
|
||||
else if(id==F("apssid")){
|
||||
p = FPSTR(HTTP_INFO_apssid);
|
||||
p.replace(FPSTR(T_1),htmlEntities(WiFi.softAPSSID()));
|
||||
}
|
||||
#endif
|
||||
// #endif
|
||||
#endif
|
||||
else if(id==F("apbssid")){
|
||||
p = FPSTR(HTTP_INFO_apbssid);
|
||||
|
||||
@@ -10,7 +10,7 @@ void setup() {
|
||||
//wm.resetSettings();
|
||||
|
||||
wm.setConfigPortalBlocking(false);
|
||||
|
||||
wm.setConfigPortalTimeout(60);
|
||||
//automatically connect using saved credentials if they exist
|
||||
//If connection fails it starts an access point with the specified name
|
||||
if(wm.autoConnect("AutoConnectAP")){
|
||||
@@ -19,6 +19,9 @@ void setup() {
|
||||
else {
|
||||
Serial.println("Configportal running");
|
||||
}
|
||||
|
||||
wm.startConfigPortal();
|
||||
// wm.startWebPortal();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
Reference in New Issue
Block a user