From 40fe2e44bcadebb9833751c58e79c5565680b1e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Mon, 20 Nov 2017 07:29:30 +0100 Subject: [PATCH] Update uptime, heap in web UI every heartbeat --- code/espurna/utils.ino | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/code/espurna/utils.ino b/code/espurna/utils.ino index c0d8417a..6b96d5ed 100644 --- a/code/espurna/utils.ino +++ b/code/espurna/utils.ino @@ -120,6 +120,18 @@ void heartbeat() { mqttSend(MQTT_TOPIC_STATUS, MQTT_STATUS_ONLINE, true); #endif + // Send info to websocket clients + { + char buffer[200]; + snprintf_P( + buffer, + sizeof(buffer) - 1, + PSTR("{\"time\": \"%s\", \"uptime\": %lu, \"heap\": %lu}"), + ntpDateTime().c_str(), uptime_seconds, free_heap + ); + wsSend(buffer); + } + } // -----------------------------------------------------------------------------