Browse Source

Discard empty MQTT topics when subscribing

fastled
Xose Pérez 7 years ago
parent
commit
77d7a48d5f
2 changed files with 5 additions and 6 deletions
  1. +1
    -2
      code/espurna/mqtt.ino
  2. +4
    -4
      code/html/index.html

+ 1
- 2
code/espurna/mqtt.ino View File

@ -65,7 +65,7 @@ void mqttSend(const char * topic, const char * message) {
} }
void mqttSubscribeRaw(const char * topic) { void mqttSubscribeRaw(const char * topic) {
if (mqtt.connected()) {
if (mqtt.connected() && (strlen(topic) > 0)) {
DEBUG_MSG("[MQTT] Subscribing to %s\n", topic); DEBUG_MSG("[MQTT] Subscribing to %s\n", topic);
mqtt.subscribe(topic, MQTT_QOS); mqtt.subscribe(topic, MQTT_QOS);
} }
@ -144,7 +144,6 @@ void _mqttOnMessage(char* topic, char* payload, unsigned int len) {
} }
// Send message event to subscribers // 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++) { for (unsigned char i = 0; i < _mqtt_callbacks.size(); i++) {
(*_mqtt_callbacks[i])(MQTT_MESSAGE_EVENT, topic, message); (*_mqtt_callbacks[i])(MQTT_MESSAGE_EVENT, topic, message);
} }


+ 4
- 4
code/html/index.html View File

@ -417,12 +417,12 @@
<div class="pure-g"> <div class="pure-g">
<label class="pure-u-1 pure-u-md-1-4" for="mqttServer">MQTT Server</label> <label class="pure-u-1 pure-u-md-1-4" for="mqttServer">MQTT Server</label>
<input class="pure-u-1 pure-u-md-3-4" name="mqttServer" type="text" size="20" tabindex="21" placeholder="MQTT Server" />
<input class="pure-u-1 pure-u-md-3-4" name="mqttServer" type="text" size="20" tabindex="21" placeholder="IP or address of your broker" />
</div> </div>
<div class="pure-g"> <div class="pure-g">
<label class="pure-u-1 pure-u-md-1-4" for="mqttPort">MQTT Port</label> <label class="pure-u-1 pure-u-md-1-4" for="mqttPort">MQTT Port</label>
<input class="pure-u-1 pure-u-md-3-4" name="mqttPort" type="text" size="6" tabindex="22" placeholder="1883" />
<input class="pure-u-1 pure-u-md-3-4" name="mqttPort" type="text" size="6" tabindex="22" value="1883" />
</div> </div>
<div class="pure-g"> <div class="pure-g">
@ -470,12 +470,12 @@
<div class="pure-g"> <div class="pure-g">
<label class="pure-u-1 pure-u-md-1-4" for="dczTopicIn">Domoticz IN Topic</label> <label class="pure-u-1 pure-u-md-1-4" for="dczTopicIn">Domoticz IN Topic</label>
<input class="pure-u-1 pure-u-md-3-4" name="dczTopicIn" type="text" tabindex="31" placeholder="domoticz/in" />
<input class="pure-u-1 pure-u-md-3-4" name="dczTopicIn" type="text" tabindex="31" />
</div> </div>
<div class="pure-g"> <div class="pure-g">
<label class="pure-u-1 pure-u-md-1-4" for="dczTopicOut">Domoticz OUT Topic</label> <label class="pure-u-1 pure-u-md-1-4" for="dczTopicOut">Domoticz OUT Topic</label>
<input class="pure-u-1 pure-u-md-3-4" name="dczTopicOut" type="text" tabindex="32" placeholder="domoticz/out" />
<input class="pure-u-1 pure-u-md-3-4" name="dczTopicOut" type="text" tabindex="32" />
</div> </div>
<div class="pure-g module module-dht module-ds"> <div class="pure-g module module-dht module-ds">


Loading…
Cancel
Save