Home page show mqtt status

This commit is contained in:
Mathieu Maret 2016-03-14 18:05:14 +01:00
parent cbbf4b2b3d
commit a145dc9a9c
3 changed files with 6 additions and 0 deletions

View File

@ -26,6 +26,10 @@ int setupMQTT(char *server, char *user, char *passwd, int port) {
return 0; return 0;
} }
int MQTT_isConnected(){
return mqtt->connected();
}
// Function to connect and reconnect as necessary to the MQTT server. // Function to connect and reconnect as necessary to the MQTT server.
// Should be called in the loop function and it will take care if connecting. // Should be called in the loop function and it will take care if connecting.
int MQTT_connect() { int MQTT_connect() {

View File

@ -1,6 +1,7 @@
void handleRoot() { void handleRoot() {
server.send(200, "text/html", "<h1>You are connected</h1><br/>" server.send(200, "text/html", "<h1>You are connected</h1><br/>"
"Current temperature " + String(temp, 2) + "C<br/>" "Current temperature " + String(temp, 2) + "C<br/>"
"MQTT Status :" + (MQTT_isConnected()? "Connected":"Disconnected") +"<br/>"
"<a href=\"/setup\">Setup</a><br/>" "<a href=\"/setup\">Setup</a><br/>"
"<a href=\"/otamode\">OTA mode</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&amp;value=1\">ON</a><br/>"

View File

@ -70,6 +70,7 @@ int getTemperature(double &t);
/* MQTT decl */ /* MQTT decl */
int MQTT_connect(); int MQTT_connect();
int MQTT_isConnected();
int setupMQTT(char *server, char *user, char *passwd, int port); int setupMQTT(char *server, char *user, char *passwd, int port);
int publishMQTT(int temp); int publishMQTT(int temp);