Show hostname of web page

This commit is contained in:
Mathieu Maret 2016-03-25 00:03:25 +01:00
parent a89a8a0727
commit ff6ab5755d
2 changed files with 4 additions and 1 deletions

View File

@ -1,7 +1,7 @@
void WebHandleRoot() { void WebHandleRoot() {
server.send(200, "text/html", server.send(200, "text/html",
"<head><meta http-equiv=\"refresh\" content=\"" + String(SAMPLING_PERIODE_MS / 1000) + "\" ></head>" "<head><meta http-equiv=\"refresh\" content=\"" + String(SAMPLING_PERIODE_MS / 1000) + "\" ></head>"
"<h1>You are connected</h1><br/>" "<h1>You are connected on " + String(hostName) +"</h1><br/>"
"Current temperature " + String(temp, 2) + "C<br/>" "Current temperature " + String(temp, 2) + "C<br/>"
"Current pressure " + String(pressure, 2) + "mB<br/>" "Current pressure " + String(pressure, 2) + "mB<br/>"
"MQTT Status: " + (MqttIsConnected() ? "Connected" : "Disconnected") + "<br/>" "MQTT Status: " + (MqttIsConnected() ? "Connected" : "Disconnected") + "<br/>"

View File

@ -44,6 +44,7 @@ char eeprom[EEPROM_SIZE];
double temp, pressure; double temp, pressure;
uint8_t mode; uint8_t mode;
char *hostName = "";
/* Set these to your desired credentials. */ /* Set these to your desired credentials. */
const char *ssid = "ESPConfigurator"; const char *ssid = "ESPConfigurator";
@ -174,6 +175,8 @@ void setup() {
EEPROM.begin(EEPROM_SIZE); EEPROM.begin(EEPROM_SIZE);
EepromReadConfig(mode, &confSsid, &confPassword, &confHost, &mqttServer, &mqttUser, &mqttPasswd, mqttPort); EepromReadConfig(mode, &confSsid, &confPassword, &confHost, &mqttServer, &mqttUser, &mqttPasswd, mqttPort);
hostName = confHost;
if (mode == BOOTMODE_NORMAL || mode == BOOTMODE_OTA) { if (mode == BOOTMODE_NORMAL || mode == BOOTMODE_OTA) {
Serial.println("Configuration Found !:"); Serial.println("Configuration Found !:");
Serial.println(mode); Serial.println(mode);