Add Gui Hostname display

Add command SetOption53 0/1 to toggle gui display of Hostname and IP address
This commit is contained in:
Theo Arends 2018-10-29 12:21:27 +01:00
parent ac00e6541a
commit cc56677ba3
3 changed files with 23 additions and 2 deletions

View File

@ -1,5 +1,6 @@
/* 6.2.1.20 20181028
* Add command SetOption35 0..255 (seconds) to delay mDNS initialization to control possible Wifi connect problems
* Add command SetOption53 0/1 to toggle gui display of Hostname and IP address
*
* 6.2.1.19 20181023
* Fix header file execution order by renaming user_config.h to my_user_config.h

View File

@ -66,7 +66,7 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu
uint32_t timers_enable : 1; // bit 0 (v6.1.1b)
uint32_t user_esp8285_enable : 1; // bit 1 (v6.1.1.14)
uint32_t time_append_timezone : 1; // bit 2 (v6.2.1.2)
uint32_t spare03 : 1;
uint32_t gui_hostname_ip : 1; // bit 3 (v6.2.1.20)
uint32_t spare04 : 1;
uint32_t spare05 : 1;
uint32_t spare06 : 1;

View File

@ -119,7 +119,7 @@ const char HTTP_HEAD_STYLE[] PROGMEM =
#else
"<h3>{ha " D_MODULE "</h3>"
#endif
"<h2>{h}</h2></div>";
"<h2>{h}</h2>{j}</div>";
const char HTTP_SCRIPT_CONSOL[] PROGMEM =
"var sn=0;" // Scroll position
"var id=0;" // Get most of weblog initially
@ -453,6 +453,25 @@ void ShowPage(String &page, bool auth)
page.replace(F("{a}"), String(Settings.web_refresh));
page.replace(F("{ha"), my_module.name);
page.replace(F("{h}"), Settings.friendlyname[0]);
String info = "";
if (Settings.flag3.gui_hostname_ip) {
uint8_t more_ips = 0;
info += F("<h3>"); info += my_hostname;
if (mdns_begun) { info += F(".local"); }
info += F(" (");
if (static_cast<uint32_t>(WiFi.localIP()) != 0) {
info += WiFi.localIP().toString();
more_ips++;
}
if (static_cast<uint32_t>(WiFi.softAPIP()) != 0) {
if (more_ips) { info += F(", "); }
info += WiFi.softAPIP().toString();
}
info += F(")</h3>");
}
page.replace(F("{j}"), info);
if (HTTP_MANAGER == webserver_state) {
if (WifiConfigCounter()) {
page.replace(F("<body>"), F("<body onload='u()'>"));
@ -1241,6 +1260,7 @@ void HandleInformation()
func += F("}1" D_AP); func += String(Settings.sta_active +1);
func += F(" " D_SSID " (" D_RSSI ")}2"); func += Settings.sta_ssid[Settings.sta_active]; func += F(" ("); func += WifiGetRssiAsQuality(WiFi.RSSI()); func += F("%)");
func += F("}1" D_HOSTNAME "}2"); func += my_hostname;
if (mdns_begun) { func += F(".local"); }
if (static_cast<uint32_t>(WiFi.localIP()) != 0) {
func += F("}1" D_IP_ADDRESS "}2"); func += WiFi.localIP().toString();
func += F("}1" D_GATEWAY "}2"); func += IPAddress(Settings.ip_address[1]).toString();