diff --git a/WiFiManager.cpp b/WiFiManager.cpp index acf5f107..a85587b3 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -1334,7 +1334,8 @@ void WiFiManager::handleRoot() { String page = getHTTPHead(_title); // @token options @todo replace options with title String str = FPSTR(HTTP_ROOT_MAIN); // @todo custom title str.replace(FPSTR(T_t),_title); - str.replace(FPSTR(T_v),configPortalActive ? _apName : (getWiFiHostname() + " - " + WiFi.localIP().toString())); // use ip if ap is not active for heading @todo use hostname? + str.replace(FPSTR(T_v), _subtitle.length() ? _subtitle : ( // Use subtitle, AP name or ip + configPortalActive ? _apName : (getWiFiHostname() + " - " + WiFi.localIP().toString()))); page += str; page += FPSTR(HTTP_PORTAL_OPTIONS); page += getMenuOut(); @@ -3140,6 +3141,14 @@ void WiFiManager::setTitle(String title){ _title = title; } +/** + * [setSubtitle description] + * @param String subtitle, set app subtitle + */ +void WiFiManager::setSubtitle(String subtitle) { + _subtitle = subtitle; +} + /** * set menu items and order * if param is present in menu , params will be removed from wifi page automatically @@ -3869,8 +3878,9 @@ void WiFiManager::handleUpdate() { if (captivePortal()) return; // If captive portal redirect instead of displaying the page String page = getHTTPHead(_title); // @token options String str = FPSTR(HTTP_ROOT_MAIN); - str.replace(FPSTR(T_t), _title); - str.replace(FPSTR(T_v), configPortalActive ? _apName : (getWiFiHostname() + " - " + WiFi.localIP().toString())); // use ip if ap is not active for heading + str.replace(FPSTR(T_t), _title); + str.replace(FPSTR(T_v), _subtitle.length() ? _subtitle : ( // Use subtitle, AP name or ip + configPortalActive ? _apName : (getWiFiHostname() + " - " + WiFi.localIP().toString()))); page += str; page += FPSTR(HTTP_UPDATE); @@ -3979,8 +3989,9 @@ void WiFiManager::handleUpdateDone() { String page = getHTTPHead(FPSTR(S_options)); // @token options String str = FPSTR(HTTP_ROOT_MAIN); - str.replace(FPSTR(T_t),_title); - str.replace(FPSTR(T_v), configPortalActive ? _apName : WiFi.localIP().toString()); // use ip if ap is not active for heading + str.replace(FPSTR(T_t),_title); + str.replace(FPSTR(T_v), _subtitle.length() ? _subtitle : ( // Use subtitle, AP name or ip + configPortalActive ? _apName : (getWiFiHostname() + " - " + WiFi.localIP().toString()))); page += str; if (Update.hasError()) { diff --git a/WiFiManager.h b/WiFiManager.h index 78394c5d..33ce683f 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -440,6 +440,9 @@ class WiFiManager // set the webapp title, default WiFiManager void setTitle(String title); + // set the webapp subtitle, default AP name + void setSubtitle(String subtitle); + // add params to its own menu page and remove from wifi, NOT TO BE COMBINED WITH setMenu! void setParamsPage(bool enable); @@ -599,7 +602,8 @@ class WiFiManager const char* _customHeadElement = ""; // store custom head element html from user isnide const char* _customMenuHTML = ""; // store custom head element html from user inside <> String _bodyClass = ""; // class to add to body - String _title = FPSTR(S_brand); // app title - default WiFiManager + String _title = FPSTR(S_brand); // app title - default WiFiManager + String _subtitle = ""; // app subtitle - default AP name // internal options