From 9d6ce13b92f889c803cf9fe6b5d9ea90dce269cc Mon Sep 17 00:00:00 2001 From: tablatronix Date: Fri, 29 Nov 2019 19:29:56 -0600 Subject: [PATCH] fix for #740 confusion --- WiFiManager.cpp | 12 +++++++++--- .../OnDemandConfigPortal/OnDemandConfigPortal.ino | 2 ++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 6844b27..a34a28a 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -624,7 +624,7 @@ uint8_t WiFiManager::processConfigPortal(){ // skip wifi if no ssid if(_ssid == ""){ - DEBUG_WM(DEBUG_VERBOSE,F("No ssid, skipping wifi")); + DEBUG_WM(DEBUG_VERBOSE,F("No ssid, skipping wifi save")); } else{ // attempt sta connection to submitted _ssid, _pass @@ -1335,8 +1335,6 @@ void WiFiManager::handleWifiSave() { _ssid = server->arg(F("s")).c_str(); _pass = server->arg(F("p")).c_str(); - if(_paramsInWifi) doParamSave(); - if (server->arg(FPSTR(S_ip)) != "") { //_sta_static_ip.fromString(server->arg(FPSTR(S_ip)); String ip = server->arg(FPSTR(S_ip)); @@ -1359,6 +1357,14 @@ void WiFiManager::handleWifiSave() { DEBUG_WM(DEBUG_DEV,F("static DNS:"),dns); } + if(_paramsInWifi){ + if(_ssid == ""){ + handleParamSave(); // send param save result and not wifi connect if no wifi creds + return; + } + else doParamSave(); + } + String page = getHTTPHead(FPSTR(S_titlewifisaved)); // @token titlewifisaved page += FPSTR(HTTP_SAVED); page += FPSTR(HTTP_END); diff --git a/examples/DEV/OnDemandConfigPortal/OnDemandConfigPortal.ino b/examples/DEV/OnDemandConfigPortal/OnDemandConfigPortal.ino index 1e37d80..d9582d4 100644 --- a/examples/DEV/OnDemandConfigPortal/OnDemandConfigPortal.ino +++ b/examples/DEV/OnDemandConfigPortal/OnDemandConfigPortal.ino @@ -199,6 +199,8 @@ void setup() { wm.setConfigPortalTimeout(120); // wm.startConfigPortal("AutoConnectAP", "password"); + // wm.setBreakAfterConfig(true); + //fetches ssid and pass and tries to connect //if it does not connect it starts an access point with the specified name //here "AutoConnectAP"