Improve HTML presentation

This commit is contained in:
Mathieu Maret 2016-03-26 01:26:36 +01:00
parent dfb5746180
commit 7682a85982

View File

@ -1,17 +1,26 @@
void WebHandleRoot() {
server.send(200, "text/html",
"<head><meta http-equiv=\"refresh\" content=\"" + String(SAMPLING_PERIODE_MS / 1000) + "\" ></head>"
"<h1>You are connected on " + String(hostName) +"</h1><br/>"
"Current temperature " + String(temp, 2) + "C<br/>"
"Current pressure " + String(pressure, 2) + "mB<br/>"
"<h1>You are connected to " + String(hostName) + "</h1>"
"<fieldset>"
"<legend>Sensors</legend>"
"Temperature " + String(temp, 2) + "C<br/>"
"Pressure " + String(pressure, 2) + "mB<br/>"
"</fieldset>"
"<fieldset>"
"<legend>Pump</legend>"
"<a href=\"/gpio?gpio=13&amp;value=1\">Power PUMP ON</a><br/>"
"<a href=\"/gpio?gpio=13&value=0\">Power PUMP OFF</a><br/>"
"</fieldset>"
"<fieldset>"
"<legend>Settings</legend>"
"<a href=\"/setup\">Enter Setup</a><br/>"
"<a href=\"/otamode\">Put device in OTA mode</a><br/>"
"MQTT Status: " + (MqttIsConnected() ? "Connected" : "Disconnected") + "<br/>"
"BMP 180 (Temp+Pression) Status: " + (BMP180IsConnected() ? "Connected" : "Disconnected") + "<br/>"
"Free space: "+ ESP.getFreeSketchSpace() +"<br/>"
"Free heap: "+ ESP.getFreeHeap() +"<br/>"
"<a href=\"/setup\">Setup</a><br/>"
"<a href=\"/otamode\">OTA mode</a><br/>"
"<a href=\"/gpio?gpio=2&amp;value=1\">ON</a><br/>"
"<a href=\"/gpio?gpio=2&value=0\">OFF</a><br/>"
"Free space: " + ESP.getFreeSketchSpace() + "<br/>"
"Free heap: " + ESP.getFreeHeap() + "<br/>"
"</fieldset>"
);
}
@ -30,16 +39,16 @@ void WebHandleSetup() {
server.send(200, "text/html", "<form action=\"/save\" method=\"get\">"
"<fieldset>"
"<legend>Wifi configuration:</legend>"
"<div><label for=\"ssid\">Wifi SSID :</label> <input type=\"text\" name=\"ssid\" value=\"" + String(confSsid) + "\" /></div>"
"<div><label for=\"password\">Wifi Password :</label><input type=\"password\" name=\"password\" /> </div>"
"<div><label for=\"host\">Hostname :</label><input type=\"text\" name=\"host\" value=\"" + String(confHost) + "\" /> </div>"
"<div><label for=\"ssid\">Wifi SSID :</label> <br/><input type=\"text\" name=\"ssid\" value=\"" + String(confSsid) + "\" /></div>"
"<div><label for=\"password\">Wifi Password :</label><br/><input type=\"password\" name=\"password\" /> </div>"
"<div><label for=\"host\">Hostname :</label><br/><input type=\"text\" name=\"host\" value=\"" + String(confHost) + "\" /> </div>"
"</fieldset>"
"<fieldset>"
"<legend>MQTT:</legend>"
"<div><label for=\"mqttServer\">MQTTServer :</label><input type=\"text\" name=\"mqttServer\" value=\"" + String(mqttServer) + "\" /> </div>"
"<div><label for=\"mqttUser\">MQTTUsername :</label><input type=\"text\" name=\"mqttUser\" value=\"" + String(mqttUser) + "\" /> </div>"
"<div><label for=\"mqttPasswd\">MQTTPassword :</label><input type=\"password\" name=\"mqttPasswd\" /> </div>"
"<div><label for=\"mqttPort\">MQTTPort :</label><input type=\"text\" name=\"mqttPort\" value=\"" + String(mqttPort) + "\" /> </div>"
"<div><label for=\"mqttServer\">Server :</label><br/><input type=\"text\" name=\"mqttServer\" value=\"" + String(mqttServer) + "\" /> </div>"
"<div><label for=\"mqttUser\">Username :</label><br/><input type=\"text\" name=\"mqttUser\" value=\"" + String(mqttUser) + "\" /> </div>"
"<div><label for=\"mqttPasswd\">Password :</label><br/><input type=\"password\" name=\"mqttPasswd\" /> </div>"
"<div><label for=\"mqttPort\">Port :</label><br/><input type=\"text\" name=\"mqttPort\" value=\"" + String(mqttPort) + "\" /> </div>"
"</fieldset>"
"<div class=\"button\"> <button type=\"submit\">Save</button></div>"
"</form>");
@ -81,7 +90,8 @@ void WebHandleOTA() {
Serial.println("Boot mode Set to OTA");
EepromSaveBootMode(BOOTMODE_OTA);
server.send(200, "text/html", "<h1>OTA Mode set</h1><br/>"
"You can reboot now");
"You can reboot now"
"<a href=\"/reboot\">Reboot</a><br/>");
}
void WebHandleNotFound() {