From 8ddc86f470b7f9ef47682f25168407e2b57675ca Mon Sep 17 00:00:00 2001 From: tablatronix Date: Sat, 17 Mar 2018 10:10:46 -0500 Subject: [PATCH 1/3] adds handleClose --- WiFiManager.cpp | 16 ++++++++++++++-- WiFiManager.h | 1 + strings_en.h | 7 +++++-- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 7980c9a..639446f 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -283,7 +283,8 @@ bool WiFiManager::startAP(){ if(_debugLevel > DEBUG_DEV) debugSoftAPConfig(); if(!ret) DEBUG_WM(DEBUG_ERROR,"[ERROR] There was a problem starting the AP"); - + // @tood add softAP retry here + delay(500); // slight delay to make sure we get an AP IP DEBUG_WM(F("AP IP address:"),WiFi.softAPIP()); @@ -382,7 +383,7 @@ void WiFiManager::setupConfigPortal() { server->on((String)FPSTR(R_paramsave), std::bind(&WiFiManager::handleParamSave, this)); server->on((String)FPSTR(R_restart), std::bind(&WiFiManager::handleReset, this)); server->on((String)FPSTR(R_exit), std::bind(&WiFiManager::handleExit, this)); - server->on((String)FPSTR(R_close), std::bind(&WiFiManager::stopCaptivePortal, this)); + server->on((String)FPSTR(R_close), std::bind(&WiFiManager::handleClose, this)); server->on((String)FPSTR(R_erase), std::bind(&WiFiManager::handleErase, this)); server->on((String)FPSTR(R_status), std::bind(&WiFiManager::handleWiFiStatus, this)); //server->on("/fwlink", std::bind(&WiFiManager::handleRoot, this)); //Microsoft captive portal. Maybe not needed. Might be handled by notFound handler. @@ -1508,6 +1509,17 @@ boolean WiFiManager::captivePortal() { void WiFiManager::stopCaptivePortal(){ _enableCaptivePortal= false; + // @todo maybe disable configportaltimeout(optional), or just provide callback for user +} + +void WiFiManager::handleClose(){ + stopCaptivePortal(); + DEBUG_WM(DEBUG_VERBOSE,F("<- HTTP close")); + handleRequest(); + String page = getHTTPHead(FPSTR(S_titleclose)); // @token titleclose + page += FPSTR(S_closing); // @token closing + server->sendHeader(FPSTR(HTTP_HEAD_CL), String(page.length())); + server->send(200, FPSTR(HTTP_HEAD_CT), page); } void WiFiManager::reportStatus(String &page){ diff --git a/WiFiManager.h b/WiFiManager.h index e90c9e5..b9636d6 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -336,6 +336,7 @@ class WiFiManager void handleReset(); void handleNotFound(); void handleExit(); + void handleClose(); void handleErase(); void handleParam(); void handleWiFiStatus(); diff --git a/strings_en.h b/strings_en.h index 439c99f..63ebddf 100644 --- a/strings_en.h +++ b/strings_en.h @@ -97,13 +97,13 @@ const char HTTP_HELP[] PROGMEM = "Save WiFi configuration information and configure device. Needs variables supplied." "/param" "Parameter page" - "/i" + "/info" "Information page" "/close" "Close the captiveportal popup,configportal will remain active" "/exit" "Exit Config Portal, configportal will close" - "/r" + "/restart" "Reboot the device" "/erase" "Erase WiFi configuration and reboot Device. Device will not reconnect to a network until new WiFi configuration data is entered." @@ -184,6 +184,7 @@ const char S_titleparamsaved[] PROGMEM = "Setup Saved"; const char S_titleexit[] PROGMEM = "Exit"; const char S_titlereset[] PROGMEM = "Reset"; const char S_titleerase[] PROGMEM = "Erase"; +const char S_titleclose[] PROGMEM = "Close"; const char S_options[] PROGMEM = "options"; const char S_nonetworks[] PROGMEM = "No networks found. Refresh to scan again."; const char S_staticip[] PROGMEM = "Static IP"; @@ -192,6 +193,8 @@ const char S_staticdns[] PROGMEM = "Static DNS"; const char S_subnet[] PROGMEM = "Subnet"; const char S_exiting[] PROGMEM = "Exiting"; const char S_resetting[] PROGMEM = "Module will reset in a few seconds."; +const char S_resetting[] PROGMEM = "Module will reset in a few seconds."; +const char S_closing[] PROGMEM = "You can close the page, portal will continue to run"; const char S_error[] PROGMEM = "An Error Occured"; const char S_notfound[] PROGMEM = "File Not Found\n\n"; const char S_uri[] PROGMEM = "URI: "; From de85162267bf16d1cf3643beb245d2beafb63d78 Mon Sep 17 00:00:00 2001 From: tablatronix Date: Sat, 17 Mar 2018 10:11:03 -0500 Subject: [PATCH 2/3] add bug workaround for esp8266 softap --- WiFiManager.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 639446f..ff1d0dc 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -272,6 +272,15 @@ bool WiFiManager::startAP(){ WiFi.softAPConfig(_ap_static_ip, _ap_static_gw, _ap_static_sn); } + #ifdef ESP8266 + // @bug workaround for bug #4372 https://github.com/esp8266/Arduino/issues/4372 + if(!WiFi.enableAP(true)) { + DEBUG_WM("enableAP failed!"); + return false; + } + delay(500); + #endif + // start soft AP with password or anonymous if (_apPassword != "") { ret = WiFi.softAP(_apName.c_str(), _apPassword.c_str());//password option From 7ad6470adf52a615ab6870c9453644a812669079 Mon Sep 17 00:00:00 2001 From: tablatronix Date: Sat, 17 Mar 2018 10:45:48 -0500 Subject: [PATCH 3/3] oops --- strings_en.h | 1 - 1 file changed, 1 deletion(-) diff --git a/strings_en.h b/strings_en.h index 63ebddf..66dec3d 100644 --- a/strings_en.h +++ b/strings_en.h @@ -193,7 +193,6 @@ const char S_staticdns[] PROGMEM = "Static DNS"; const char S_subnet[] PROGMEM = "Subnet"; const char S_exiting[] PROGMEM = "Exiting"; const char S_resetting[] PROGMEM = "Module will reset in a few seconds."; -const char S_resetting[] PROGMEM = "Module will reset in a few seconds."; const char S_closing[] PROGMEM = "You can close the page, portal will continue to run"; const char S_error[] PROGMEM = "An Error Occured"; const char S_notfound[] PROGMEM = "File Not Found\n\n";