From 2321c67ffa5903e6e473121fed32e239ac2beddc Mon Sep 17 00:00:00 2001 From: frizzy Date: Fri, 4 Nov 2016 19:42:34 +0000 Subject: [PATCH] MQTT: Removed need for new topic buffer --- core/MyProtocolMySensors.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/core/MyProtocolMySensors.cpp b/core/MyProtocolMySensors.cpp index f3c9ac4..d046e57 100755 --- a/core/MyProtocolMySensors.cpp +++ b/core/MyProtocolMySensors.cpp @@ -120,18 +120,11 @@ bool protocolMQTTParse(MyMessage &message, char* topic, uint8_t* payload, unsign uint8_t bvalue[MAX_PAYLOAD]; uint8_t blen = 0; uint8_t command = 0; - uint8_t topiclen = strlen(topic) - strlen(MY_MQTT_SUBSCRIBE_TOPIC_PREFIX); - char topicTrimmed[topiclen]; - if (topic != strstr(topic, MY_MQTT_SUBSCRIBE_TOPIC_PREFIX)) { // Prefix doesn't match incoming topic return false; } - // Extract the topic sans prefix - strncpy(topicTrimmed, &topic[strlen(MY_MQTT_SUBSCRIBE_TOPIC_PREFIX) + 1], topiclen); - topicTrimmed[topiclen] = (char)0; - - for (str = strtok_r(topicTrimmed, "/", &p); str && i <= 5; + for (str = strtok_r(topic + strlen(MY_MQTT_SUBSCRIBE_TOPIC_PREFIX) + 1, "/", &p); str && i <= 5; str = strtok_r(NULL, "/", &p)) { switch (i) { case 0: {