From 77d7a48d5f27fc0c7d4b545a7ab24615c6c0cca6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Tue, 28 Feb 2017 22:48:24 +0100 Subject: [PATCH] Discard empty MQTT topics when subscribing --- code/espurna/mqtt.ino | 3 +-- code/html/index.html | 8 ++++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/code/espurna/mqtt.ino b/code/espurna/mqtt.ino index 51c6f229..2db6259f 100644 --- a/code/espurna/mqtt.ino +++ b/code/espurna/mqtt.ino @@ -65,7 +65,7 @@ void mqttSend(const char * topic, const char * message) { } void mqttSubscribeRaw(const char * topic) { - if (mqtt.connected()) { + if (mqtt.connected() && (strlen(topic) > 0)) { DEBUG_MSG("[MQTT] Subscribing to %s\n", topic); mqtt.subscribe(topic, MQTT_QOS); } @@ -144,7 +144,6 @@ void _mqttOnMessage(char* topic, char* payload, unsigned int len) { } // Send message event to subscribers - // Topic is set to the specific part each one might be checking for (unsigned char i = 0; i < _mqtt_callbacks.size(); i++) { (*_mqtt_callbacks[i])(MQTT_MESSAGE_EVENT, topic, message); } diff --git a/code/html/index.html b/code/html/index.html index 46541513..a4be8021 100644 --- a/code/html/index.html +++ b/code/html/index.html @@ -417,12 +417,12 @@
- +
- +
@@ -470,12 +470,12 @@
- +
- +