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 = "