diff --git a/lib/TasmotaMqtt-1.1.0/.gitignore b/lib/TasmotaMqtt-1.1.1/.gitignore similarity index 100% rename from lib/TasmotaMqtt-1.1.0/.gitignore rename to lib/TasmotaMqtt-1.1.1/.gitignore diff --git a/lib/TasmotaMqtt-1.1.0/README.md b/lib/TasmotaMqtt-1.1.1/README.md similarity index 100% rename from lib/TasmotaMqtt-1.1.0/README.md rename to lib/TasmotaMqtt-1.1.1/README.md diff --git a/lib/TasmotaMqtt-1.1.0/examples/mqtt_pub/mqtt_pub.ino b/lib/TasmotaMqtt-1.1.1/examples/mqtt_pub/mqtt_pub.ino similarity index 100% rename from lib/TasmotaMqtt-1.1.0/examples/mqtt_pub/mqtt_pub.ino rename to lib/TasmotaMqtt-1.1.1/examples/mqtt_pub/mqtt_pub.ino diff --git a/lib/TasmotaMqtt-1.1.0/examples/mqtt_sub/mqtt_sub.ino b/lib/TasmotaMqtt-1.1.1/examples/mqtt_sub/mqtt_sub.ino similarity index 100% rename from lib/TasmotaMqtt-1.1.0/examples/mqtt_sub/mqtt_sub.ino rename to lib/TasmotaMqtt-1.1.1/examples/mqtt_sub/mqtt_sub.ino diff --git a/lib/TasmotaMqtt-1.1.0/keywords.txt b/lib/TasmotaMqtt-1.1.1/keywords.txt similarity index 100% rename from lib/TasmotaMqtt-1.1.0/keywords.txt rename to lib/TasmotaMqtt-1.1.1/keywords.txt diff --git a/lib/TasmotaMqtt-1.1.0/library.properties b/lib/TasmotaMqtt-1.1.1/library.properties similarity index 100% rename from lib/TasmotaMqtt-1.1.0/library.properties rename to lib/TasmotaMqtt-1.1.1/library.properties diff --git a/lib/TasmotaMqtt-1.1.0/src/TasmotaMqtt.cpp b/lib/TasmotaMqtt-1.1.1/src/TasmotaMqtt.cpp similarity index 97% rename from lib/TasmotaMqtt-1.1.0/src/TasmotaMqtt.cpp rename to lib/TasmotaMqtt-1.1.1/src/TasmotaMqtt.cpp index 91a49e0f6..9beddd452 100644 --- a/lib/TasmotaMqtt-1.1.0/src/TasmotaMqtt.cpp +++ b/lib/TasmotaMqtt-1.1.1/src/TasmotaMqtt.cpp @@ -185,9 +185,10 @@ bool TasmotaMqtt::Connected() void TasmotaMqtt::_onMqttDataCb(const char* topic, uint32_t topic_len, const char* data, uint32_t data_len) { - char topic_copy[topic_len]; + char topic_copy[topic_len +1]; - memcpy(topic_copy, topic, topic_len); - topic_copy[topic_len] = 0; + memcpy(topic_copy, topic, topic_len); + topic_copy[topic_len] = 0; + if (0 == data_len) data = (const char*)&topic_copy + topic_len; onMqttDataCb((char*)topic_copy, (byte*)data, data_len); } diff --git a/lib/TasmotaMqtt-1.1.0/src/TasmotaMqtt.h b/lib/TasmotaMqtt-1.1.1/src/TasmotaMqtt.h similarity index 100% rename from lib/TasmotaMqtt-1.1.0/src/TasmotaMqtt.h rename to lib/TasmotaMqtt-1.1.1/src/TasmotaMqtt.h diff --git a/lib/TasmotaMqtt-1.1.0/src/mqtt/debug.h b/lib/TasmotaMqtt-1.1.1/src/mqtt/debug.h similarity index 100% rename from lib/TasmotaMqtt-1.1.0/src/mqtt/debug.h rename to lib/TasmotaMqtt-1.1.1/src/mqtt/debug.h diff --git a/lib/TasmotaMqtt-1.1.0/src/mqtt/mqtt.c b/lib/TasmotaMqtt-1.1.1/src/mqtt/mqtt.c similarity index 100% rename from lib/TasmotaMqtt-1.1.0/src/mqtt/mqtt.c rename to lib/TasmotaMqtt-1.1.1/src/mqtt/mqtt.c diff --git a/lib/TasmotaMqtt-1.1.0/src/mqtt/mqtt.h b/lib/TasmotaMqtt-1.1.1/src/mqtt/mqtt.h similarity index 100% rename from lib/TasmotaMqtt-1.1.0/src/mqtt/mqtt.h rename to lib/TasmotaMqtt-1.1.1/src/mqtt/mqtt.h diff --git a/lib/TasmotaMqtt-1.1.0/src/mqtt/mqtt_msg.c b/lib/TasmotaMqtt-1.1.1/src/mqtt/mqtt_msg.c similarity index 100% rename from lib/TasmotaMqtt-1.1.0/src/mqtt/mqtt_msg.c rename to lib/TasmotaMqtt-1.1.1/src/mqtt/mqtt_msg.c diff --git a/lib/TasmotaMqtt-1.1.0/src/mqtt/mqtt_msg.h b/lib/TasmotaMqtt-1.1.1/src/mqtt/mqtt_msg.h similarity index 100% rename from lib/TasmotaMqtt-1.1.0/src/mqtt/mqtt_msg.h rename to lib/TasmotaMqtt-1.1.1/src/mqtt/mqtt_msg.h diff --git a/lib/TasmotaMqtt-1.1.0/src/mqtt/proto.c b/lib/TasmotaMqtt-1.1.1/src/mqtt/proto.c similarity index 100% rename from lib/TasmotaMqtt-1.1.0/src/mqtt/proto.c rename to lib/TasmotaMqtt-1.1.1/src/mqtt/proto.c diff --git a/lib/TasmotaMqtt-1.1.0/src/mqtt/proto.h b/lib/TasmotaMqtt-1.1.1/src/mqtt/proto.h similarity index 100% rename from lib/TasmotaMqtt-1.1.0/src/mqtt/proto.h rename to lib/TasmotaMqtt-1.1.1/src/mqtt/proto.h diff --git a/lib/TasmotaMqtt-1.1.0/src/mqtt/queue.c b/lib/TasmotaMqtt-1.1.1/src/mqtt/queue.c similarity index 100% rename from lib/TasmotaMqtt-1.1.0/src/mqtt/queue.c rename to lib/TasmotaMqtt-1.1.1/src/mqtt/queue.c diff --git a/lib/TasmotaMqtt-1.1.0/src/mqtt/queue.h b/lib/TasmotaMqtt-1.1.1/src/mqtt/queue.h similarity index 100% rename from lib/TasmotaMqtt-1.1.0/src/mqtt/queue.h rename to lib/TasmotaMqtt-1.1.1/src/mqtt/queue.h diff --git a/lib/TasmotaMqtt-1.1.0/src/mqtt/ringbuf.c b/lib/TasmotaMqtt-1.1.1/src/mqtt/ringbuf.c similarity index 100% rename from lib/TasmotaMqtt-1.1.0/src/mqtt/ringbuf.c rename to lib/TasmotaMqtt-1.1.1/src/mqtt/ringbuf.c diff --git a/lib/TasmotaMqtt-1.1.0/src/mqtt/ringbuf.h b/lib/TasmotaMqtt-1.1.1/src/mqtt/ringbuf.h similarity index 100% rename from lib/TasmotaMqtt-1.1.0/src/mqtt/ringbuf.h rename to lib/TasmotaMqtt-1.1.1/src/mqtt/ringbuf.h diff --git a/lib/TasmotaMqtt-1.1.0/src/mqtt/typedef.h b/lib/TasmotaMqtt-1.1.1/src/mqtt/typedef.h similarity index 100% rename from lib/TasmotaMqtt-1.1.0/src/mqtt/typedef.h rename to lib/TasmotaMqtt-1.1.1/src/mqtt/typedef.h diff --git a/lib/TasmotaMqtt-1.1.0/src/mqtt/user_config.h b/lib/TasmotaMqtt-1.1.1/src/mqtt/user_config.h similarity index 100% rename from lib/TasmotaMqtt-1.1.0/src/mqtt/user_config.h rename to lib/TasmotaMqtt-1.1.1/src/mqtt/user_config.h diff --git a/lib/TasmotaMqtt-1.1.0/src/mqtt/utils.c b/lib/TasmotaMqtt-1.1.1/src/mqtt/utils.c similarity index 100% rename from lib/TasmotaMqtt-1.1.0/src/mqtt/utils.c rename to lib/TasmotaMqtt-1.1.1/src/mqtt/utils.c diff --git a/lib/TasmotaMqtt-1.1.0/src/mqtt/utils.h b/lib/TasmotaMqtt-1.1.1/src/mqtt/utils.h similarity index 100% rename from lib/TasmotaMqtt-1.1.0/src/mqtt/utils.h rename to lib/TasmotaMqtt-1.1.1/src/mqtt/utils.h diff --git a/sonoff/xdrv_00_mqtt.ino b/sonoff/xdrv_00_mqtt.ino index c4196817d..b8e76ca7e 100644 --- a/sonoff/xdrv_00_mqtt.ino +++ b/sonoff/xdrv_00_mqtt.ino @@ -154,12 +154,14 @@ void MqttDisconnectedCb() MqttDisconnected(MqttClient->getState()); // status codes are documented in file mqtt.h as tConnState } -void MqttMyDataCb(const char* topic, uint32_t topic_len, const char *data, uint32_t data_len) +void MqttMyDataCb(const char* topic, uint32_t topic_len, const char* data, uint32_t data_len) { - char topicCpy[topic_len]; - memcpy(topicCpy, topic, topic_len); - topicCpy[topic_len] = 0; - MqttDataHandler((char*)topicCpy, (byte*)data, data_len); + char topic_copy[topic_len +1]; + + memcpy(topic_copy, topic, topic_len); + topic_copy[topic_len] = 0; + if (0 == data_len) data = (const char*)&topic_copy + topic_len; + MqttDataHandler((char*)topic_copy, (byte*)data, data_len); } void MqttSubscribeLib(char *topic)