diff --git a/WiFiManager.cpp b/WiFiManager.cpp
index 0819fb4..8762b74 100644
--- a/WiFiManager.cpp
+++ b/WiFiManager.cpp
@@ -91,6 +91,8 @@ void WiFiManager::setupConfigPortal() {
server->on("/wifi", std::bind(&WiFiManager::handleWifi, this, true));
server->on("/0wifi", std::bind(&WiFiManager::handleWifi, this, false));
server->on("/wifisave", std::bind(&WiFiManager::handleWifiSave, this));
+ server->on("/i", std::bind(&WiFiManager::handleInfo, this));
+ server->on("/r", std::bind(&WiFiManager::handleReset, this));
server->on("/generate_204", std::bind(&WiFiManager::handle204, this)); //Android/Chrome OS captive portal check.
server->on("/fwlink", std::bind(&WiFiManager::handleRoot, this)); //Microsoft captive portal. Maybe not needed. Might be handled by notFound handler.
server->onNotFound (std::bind(&WiFiManager::handleNotFound, this));
@@ -311,31 +313,20 @@ void WiFiManager::handleRoot() {
return;
}
- server->sendHeader("Cache-Control", "no-cache, no-store, must-revalidate");
- server->sendHeader("Pragma", "no-cache");
- server->sendHeader("Expires", "-1");
- server->setContentLength(CONTENT_LENGTH_UNKNOWN);
- server->send(200, "text/html", ""); // Empty content inhibits Content-length header so we have to close the socket ourselves.
+ String page = FPSTR(HTTP_HEAD);
+ page.replace("{v}", "Options");
+ page += FPSTR(HTTP_SCRIPT);
+ page += FPSTR(HTTP_STYLE);
+ page += FPSTR(HTTP_HEAD_END);
+ page += "
";
+ page += _apName;
+ page += "
";
+ page += F("WiFiManager
");
+ page += FPSTR(HTTP_PORTAL_OPTIONS);
+ page += FPSTR(HTTP_END);
+
+ server->send(200, "text/html", page);
- String head = HTTP_HEAD;
- head.replace("{v}", "Options");
- server->sendContent(head);
- server->sendContent_P(HTTP_SCRIPT);
- server->sendContent_P(HTTP_STYLE);
- server->sendContent_P(HTTP_HEAD_END);
-
- //server->sendContent(F(""));
- String title = "";
- title += _apName;
- title += "
";
- server->sendContent(title);
- server->sendContent(F("WiFiManager
"));
-
-
- server->sendContent_P(HTTP_PORTAL_OPTIONS);
- server->sendContent_P(HTTP_END);
-
- server->client().stop(); // Stop is needed because we sent no content length
}
/** Wifi config page handler */
@@ -347,7 +338,7 @@ void WiFiManager::handleWifi(boolean scan) {
server->send(200, "text/html", ""); // Empty content inhibits Content-length header so we have to close the socket ourselves.
server->setContentLength(CONTENT_LENGTH_UNKNOWN);
- String head = HTTP_HEAD;
+ String head = FPSTR(HTTP_HEAD);
head.replace("{v}", "Config ESP");
server->sendContent(head);
server->sendContent_P(HTTP_SCRIPT);
@@ -446,6 +437,7 @@ void WiFiManager::handleWifi(boolean scan) {
}
server->sendContent_P(HTTP_FORM_END);
+ server->sendContent_P(HTTP_SCAN_LINK);
server->sendContent_P(HTTP_END);
server->client().stop();
@@ -496,7 +488,7 @@ void WiFiManager::handleWifiSave() {
server->setContentLength(CONTENT_LENGTH_UNKNOWN);
server->send(200, "text/html", ""); // Empty content inhibits Content-length header so we have to close the socket ourselves.
- String head = HTTP_HEAD;
+ String head = FPSTR(HTTP_HEAD);
head.replace("{v}", "Credentials Saved");
server->sendContent(head);
server->sendContent_P(HTTP_SCRIPT);
@@ -513,6 +505,64 @@ void WiFiManager::handleWifiSave() {
connect = true; //signal ready to connect/reset
}
+/** Handle the info page */
+void WiFiManager::handleInfo() {
+ DEBUG_WM(F("Info"));
+
+String page = FPSTR(HTTP_HEAD);
+ page.replace("{v}", "Info");
+ page += FPSTR(HTTP_SCRIPT);
+ page += FPSTR(HTTP_STYLE);
+ page += FPSTR(HTTP_HEAD_END);
+ page += F("");
+ page += F("- Chip ID
- ");
+ page += ESP.getChipId();
+ page += F("
");
+ page += F("- Flash Chip ID
- ");
+ page += ESP.getFlashChipId();
+ page += F("
");
+ page += F("- Flash Size
- ");
+ page += ESP.getFlashChipSize();
+ page += F(" bytes
");
+ page += F("- Soft AP IP
- ");
+ page += WiFi.softAPIP().toString();
+ page += F("
");
+ page += F("- Soft AP MAC
- ");
+ page += WiFi.softAPmacAddress();
+ page += F("
");
+ page += F("- Station MAC
- ");
+ page += WiFi.macAddress();
+ page += F("
");
+ page += F("
");
+ page += FPSTR(HTTP_END);
+
+ server->send(200, "text/html", page);
+
+ DEBUG_WM(F("Sent info page"));
+}
+
+/** Handle the reset page */
+void WiFiManager::handleReset() {
+ DEBUG_WM(F("Reset"));
+
+ String page = FPSTR(HTTP_HEAD);
+ page.replace("{v}", "Info");
+ page += FPSTR(HTTP_SCRIPT);
+ page += FPSTR(HTTP_STYLE);
+ page += FPSTR(HTTP_HEAD_END);
+ page += F("Module will reset in a few seconds.");
+ page += FPSTR(HTTP_END);
+ server->send(200, "text/html", page);
+
+ DEBUG_WM(F("Sent reset page"));
+ delay(5000);
+ ESP.reset();
+ delay(2000);
+}
+
+
+
+
void WiFiManager::handle204() {
DEBUG_WM(F("204 No Response"));
server->sendHeader("Cache-Control", "no-cache, no-store, must-revalidate");
diff --git a/WiFiManager.h b/WiFiManager.h
index 301ae36..f849bf3 100644
--- a/WiFiManager.h
+++ b/WiFiManager.h
@@ -20,16 +20,17 @@
const char HTTP_200[] PROGMEM = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n";
-//const char HTTP_HEAD[] PROGMEM = "{v}";
+const char HTTP_HEAD[] PROGMEM = "{v}";
const char HTTP_STYLE[] PROGMEM = "";
const char HTTP_SCRIPT[] PROGMEM = "";
const char HTTP_HEAD_END[] PROGMEM = "";
-const char HTTP_PORTAL_OPTIONS[] PROGMEM = "
";
+const char HTTP_PORTAL_OPTIONS[] PROGMEM = "
";
const char HTTP_ITEM[] PROGMEM = "
";
const char HTTP_ITEM_PADLOCK[] PROGMEM = "

";
const char HTTP_FORM_START[] PROGMEM = "
";
+const char HTTP_SCAN_LINK[] PROGMEM = "
";
const char HTTP_SAVED[] PROGMEM = "
Credentials Saved
Trying to connect ESP to network.
If it fails reconnect to AP to try again
";
const char HTTP_END[] PROGMEM = "
";
@@ -102,7 +103,7 @@ class WiFiManager
const int WM_DONE = 0;
const int WM_WAIT = 10;
- const String HTTP_HEAD = "{v}";
+ //const String HTTP_HEAD = "{v}";
void setupConfigPortal();
@@ -132,6 +133,8 @@ class WiFiManager
void handleRoot();
void handleWifi(boolean scan);
void handleWifiSave();
+ void handleInfo();
+ void handleReset();
void handleNotFound();
void handle204();
boolean captivePortal();
diff --git a/extras/WiFiManager.template.html b/extras/WiFiManager.template.html
index 5ef5924..4b1aeba 100644
--- a/extras/WiFiManager.template.html
+++ b/extras/WiFiManager.template.html
@@ -10,8 +10,11 @@
+
+
+ Scan
\ No newline at end of file