adds handleClose

This commit is contained in:
tablatronix
2018-03-17 10:10:46 -05:00
parent c9e82ae920
commit 8ddc86f470
3 changed files with 20 additions and 4 deletions
+14 -2
View File
@@ -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){
+1
View File
@@ -336,6 +336,7 @@ class WiFiManager
void handleReset();
void handleNotFound();
void handleExit();
void handleClose();
void handleErase();
void handleParam();
void handleWiFiStatus();
+5 -2
View File
@@ -97,13 +97,13 @@ const char HTTP_HELP[] PROGMEM =
"<td>Save WiFi configuration information and configure device. Needs variables supplied.</td></tr>"
"<tr><td><a href='/param'>/param</a></td>"
"<td>Parameter page</td></tr>"
"<tr><td><a href='/info'>/i</a></td>"
"<tr><td><a href='/info'>/info</a></td>"
"<td>Information page</td></tr>"
"<tr><td><a href='/close'>/close</a></td>"
"<td>Close the captiveportal popup,configportal will remain active</td></tr>"
"<tr><td><a href='/exit'>/exit</a></td>"
"<td>Exit Config Portal, configportal will close</td></tr>"
"<tr><td><a href='/restart'>/r</a></td>"
"<tr><td><a href='/restart'>/restart</a></td>"
"<td>Reboot the device</td></tr>"
"<tr><td><a href='/erase'>/erase</a></td>"
"<td>Erase WiFi configuration and reboot Device. Device will not reconnect to a network until new WiFi configuration data is entered.</td></tr>"
@@ -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: ";