mirror of https://github.com/arendst/Tasmota.git
Fix exception if no MQTT data
This commit is contained in:
parent
a16e2316b3
commit
15886c1df3
|
@ -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);
|
||||
}
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue