From a21f8cbc39b9926b04663b4bf6a3568db922c52c Mon Sep 17 00:00:00 2001 From: Shawn A Date: Wed, 31 Jan 2018 13:54:54 -0600 Subject: [PATCH] moved http strings to include, added token flags --- WiFiManager.cpp | 105 ++++++++++++++++++------------------------------ WiFiManager.h | 38 +----------------- strings_en.h | 56 ++++++++++++++++++++++++++ 3 files changed, 97 insertions(+), 102 deletions(-) create mode 100644 strings_en.h diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 9bb0eab..4af51ea 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -11,6 +11,7 @@ **************************************************************/ #include "WiFiManager.h" +#include "strings_en.h" // PARAMETERS @@ -585,7 +586,7 @@ void WiFiManager::handleWifi(boolean scan) { DEBUG_WM("<- HTTP Wifi"); String page = FPSTR(HTTP_HEAD); - page.replace("{v}", "Config ESP"); + page.replace("{v}", "Config ESP"); // @token titlewifi page += FPSTR(HTTP_SCRIPT); page += FPSTR(HTTP_STYLE); page += _customHeadElement; @@ -623,7 +624,7 @@ String WiFiManager::getScanItemOut(){ DEBUG_WM(F("Scan done")); if (n == 0) { DEBUG_WM(F("No networks found")); - page += F("No networks found. Refresh to scan again."); + page += F("No networks found. Refresh to scan again."); // @token scannotfound } else { //sort networks @@ -720,7 +721,7 @@ String WiFiManager::getStaticOut(){ item.replace("{i}", "ip"); item.replace("{n}", "ip"); item.replace("{p}", "{t}"); - item.replace("{t}", "Static IP"); + item.replace("{t}", "Static IP"); // @token staticip item.replace("{l}", "15"); item.replace("{v}", (_sta_static_ip ? _sta_static_ip.toString() : "")); item.replace("{c}", ""); @@ -735,7 +736,7 @@ String WiFiManager::getStaticOut(){ item.replace("{i}", "gw"); item.replace("{n}", "gw"); item.replace("{p}", "{t}"); - item.replace("{t}", "Static Gateway"); + item.replace("{t}", "Static Gateway"); // @token staticgateway item.replace("{l}", "15"); item.replace("{v}", (_sta_static_gw ? _sta_static_gw.toString() : "")); item.replace("{c}", ""); @@ -750,7 +751,7 @@ String WiFiManager::getStaticOut(){ item.replace("{i}", "sn"); item.replace("{n}", "sn"); item.replace("{p}", "{t}"); - item.replace("{t}", "Subnet"); + item.replace("{t}", "Subnet"); // @token subnet item.replace("{l}", "15"); item.replace("{v}", (_sta_static_sn ? _sta_static_sn.toString() : "")); item.replace("{c}", ""); @@ -880,7 +881,7 @@ void WiFiManager::handleWifiSave() { } String page = FPSTR(HTTP_HEAD); - page.replace("{v}", "Credentials Saved"); + page.replace("{v}", "Credentials Saved"); // @token titlewifisaved page += FPSTR(HTTP_SCRIPT); page += FPSTR(HTTP_STYLE); page += _customHeadElement; @@ -903,7 +904,7 @@ void WiFiManager::handleInfo() { DEBUG_WM(F("<- HTTP Info")); String page = FPSTR(HTTP_HEAD); - page.replace("{v}", "Info"); + page.replace("{v}", "Info"); // @token titleinfo page += FPSTR(HTTP_SCRIPT); page += FPSTR(HTTP_STYLE); page += _customHeadElement; @@ -916,39 +917,39 @@ void WiFiManager::handleInfo() { page += F("

esp8266


"); // subject to rollover! - page += F("
Uptime
"); - page += (String)(system_get_time() / 1000000 / 60) + " mins "; - page += (String)((system_get_time() / 1000000)%60) + " secs"; + page += F("
Uptime
"); // @token uptime + page += (String)(system_get_time() / 1000000 / 60) + " mins "; // @token mins + page += (String)((system_get_time() / 1000000)%60) + " secs"; // @token secs - page += F("
Chip ID
"); + page += F("
Chip ID
"); // @token chipid page += WIFI_getChipId(); page += F("
"); - page += F("
Flash Chip ID
"); + page += F("
Flash Chip ID
"); // @token flashid page += ESP.getFlashChipId(); page += F("
"); - page += F("
IDE Flash Size
"); + page += F("
IDE Flash Size
"); // @token flashsize page += ESP.getFlashChipSize(); page += F(" bytes
"); - page += F("
Actual Flash Size
"); + page += F("
Actual Flash Size
"); // @token actualflashsize page += ESP.getFlashChipRealSize(); page += F(" bytes
"); - page += F("
SDK Version
"); + page += F("
SDK Version
"); // @token sdkver page += system_get_sdk_version(); page += F("
"); - page += F("
Core Version
"); + page += F("
Core Version
"); // @token corever page += ESP.getCoreVersion(); page += F("
"); - page += F("
Boot Version
"); + page += F("
Boot Version
"); // @token boot ver page += system_get_boot_version(); page += F("
"); - page += F("
CPU Frequency
"); + page += F("
CPU Frequency
"); // @token cpufreq page += ESP.getCpuFreqMHz(); page += F("MHz
"); @@ -962,12 +963,12 @@ void WiFiManager::handleInfo() { // page += "
"; // page += F(""); - page += F("
Memory - Free Heap
"); + page += F("
Memory - Free Heap
"); // @token freeheap page += ESP.getFreeHeap(); - page += F(" bytes available
"); + page += F(" bytes available"); // @token bytesavail - page += F("
Memory - Sketch Size
"); - page += F("Used/Total bytes
"); + page += F("
Memory - Sketch Size
"); // @token sketchsize + page += F("Used/Total bytes
"); // @token usedtotal page += (ESP.getSketchSize()+ESP.getFreeSketchSpace())-ESP.getFreeSketchSpace(); page += "/"; page += (ESP.getSketchSize()+ESP.getFreeSketchSpace()); @@ -977,15 +978,15 @@ void WiFiManager::handleInfo() { page += (String)(ESP.getSketchSize()+ESP.getFreeSketchSpace()); page += F("'>
"); - page += F("
Last reset reason
"); + page += F("
Last reset reason
"); // @token resetreason page += ESP.getResetReason(); page += F("
"); - page += F("

WiFi


Access Point IP
"); + page += F("

WiFi


Access Point IP
"); // @token apip page += WiFi.softAPIP().toString(); page += F("
"); - page += F("
Access Point MAC
"); + page += F("
Access Point MAC
"); // @token apmac page += WiFi.softAPmacAddress(); page += F("
"); @@ -997,71 +998,45 @@ void WiFiManager::handleInfo() { page += WiFi.BSSIDstr(); page += F(""); - page += F("
Station IP
"); + page += F("
Station IP
"); // @token staip page += WiFi.localIP().toString(); page += F("
"); - page += F("
Station Gateway
"); + page += F("
Station Gateway
"); // @token stagw page += WiFi.gatewayIP().toString(); page += F("
"); - page += F("
Station Subnet
"); + page += F("
Station Subnet
"); // @token stasub page += WiFi.subnetMask().toString(); page += F("
"); - page += F("
DNS Server
"); + page += F("
DNS Server
"); // @token dnss page += WiFi.dnsIP().toString(); page += F("
"); - page += F("
Hostname
"); + page += F("
Hostname
"); // @token hostname page += WiFi.hostname(); page += F("
"); - page += F("
Station MAC
"); + page += F("
Station MAC
"); // @stamac page += WiFi.macAddress(); page += F("
"); - page += F("
Connected
"); - page += WiFi.isConnected() ? "Yes" : "No"; + page += F("
Connected
"); // @token connected + page += WiFi.isConnected() ? "Yes" : "No"; //@token Y,N page += F("
"); page += F("
Autoconnect
"); - page += WiFi.getAutoConnect() ? "Enabled" : "Disabled"; + page += WiFi.getAutoConnect() ? "Enabled" : "Disabled"; // @token enabled,disabled page += F("
"); page += F("
"); - page += "
"; + page += "
"; + + page += FPSTR(HTTP_HELP); - page += F("

Available Pages


"); - page += F(""); - page += F(""); - - page += F(""); - page += F(""); - - page += F(""); - page += F(""); - - page += F(""); - page += F(""); - - page += F(""); - page += F(""); - - page += F(""); - page += F(""); - - page += F(""); - page += F(""); - - page += F(""); - page += F(""); - - page += F(""); - page += F(""); - // @todo add callback here - page += F("
PageFunction
/Menu page.
/wifiShow WiFi scan results and enter WiFi configuration.
/wifisaveSave WiFi configuration information and configure device. Needs variables supplied.
/closeClose the configuration server and configuration WiFi network.
/iInformation page
/exitExit Config Portal, configportal will close
/rReboot the device
/eraseErase WiFi configuration and reboot Device. Device will not reconnect to a network until new WiFi configuration data is entered.
"); - page += F("

More information about WiFiManager at https://github.com/tzapu/WiFiManager."); page += FPSTR(HTTP_END); server->sendHeader("Content-Length", String(page.length())); diff --git a/WiFiManager.h b/WiFiManager.h index a3e415b..4c0065a 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -30,43 +30,7 @@ #define WIFI_getChipId() ESP.getChipId() #define WIFI_AUTH_OPEN ENC_TYPE_NONE -const char HTTP_HEAD[] PROGMEM = "{v}"; -// const char HTTP_STYLE[] PROGMEM = ""; -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_ITEM[] PROGMEM = "
{v}
"; -// const char HTTP_ITEM[] PROGMEM = "
{v} {R} {r}% {q} {e}
"; // test all tokens -//const char HTTP_ITEM_PADLOCK[] PROGMEM = ""; -const char HTTP_FORM_START[] PROGMEM = "


"; -const char HTTP_FORM_END[] PROGMEM = "
"; -const char HTTP_FORM_LABEL[] PROGMEM = ""; -const char HTTP_FORM_PARAM_START[] PROGMEM = "
"; -const char HTTP_FORM_PARAM[] PROGMEM = "
"; -const char HTTP_FORM_PARAM_END[] PROGMEM = "
"; -const char HTTP_SCAN_LINK[] PROGMEM = "
"; -const char HTTP_SAVED[] PROGMEM = "
Saving Credentials
Trying to connect ESP to network.
If it fails reconnect to AP to try again
"; -const char HTTP_END[] PROGMEM = "
"; - -#define WIFI_MANAGER_MAX_PARAMS 5 +#define WIFI_MANAGER_MAX_PARAMS 5 // params will autoincrement and realloc by this amount when max is reached #define WFM_LABEL_BEFORE 1 #define WFM_LABEL_AFTER 2 diff --git a/strings_en.h b/strings_en.h new file mode 100644 index 0000000..abda51c --- /dev/null +++ b/strings_en.h @@ -0,0 +1,56 @@ +const char HTTP_HEAD[] PROGMEM = "{v}"; +const char HTTP_SCRIPT[] PROGMEM = ""; +const char HTTP_HEAD_END[] PROGMEM = "
"; +const char HTTP_PORTAL_OPTIONS[] PROGMEM = "




"; +const char HTTP_ITEM[] PROGMEM = "
{v}
"; +// const char HTTP_ITEM[] PROGMEM = "
{v} {R} {r}% {q} {e}
"; // test all tokens +const char HTTP_FORM_START[] PROGMEM = "


"; +const char HTTP_FORM_END[] PROGMEM = "
"; +const char HTTP_FORM_LABEL[] PROGMEM = ""; +const char HTTP_FORM_PARAM_START[] PROGMEM = "
"; +const char HTTP_FORM_PARAM[] PROGMEM = "
"; +const char HTTP_FORM_PARAM_END[] PROGMEM = "
"; +const char HTTP_SCAN_LINK[] PROGMEM = "
"; +const char HTTP_SAVED[] PROGMEM = "
Saving Credentials
Trying to connect ESP to network.
If it fails reconnect to AP to try again
"; +const char HTTP_END[] PROGMEM = "
"; + +const char HTTP_STYLE[] PROGMEM = ""; + +const char HTTP_HELP[] PROGMEM = + "

Available Pages


" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "
PageFunction
/Menu page.
/wifiShow WiFi scan results and enter WiFi configuration.(/0wifi noscan)
/wifisaveSave WiFi configuration information and configure device. Needs variables supplied.
/closeClose the configuration server and configuration WiFi network.
/iInformation page
/exitExit Config Portal, configportal will close
/rReboot the device
/eraseErase WiFi configuration and reboot Device. Device will not reconnect to a network until new WiFi configuration data is entered.
" + "

More information about WiFiManager at https://github.com/tzapu/WiFiManager."; \ No newline at end of file