Skip to content
This repository has been archived by the owner on Nov 29, 2023. It is now read-only.

Commit

Permalink
Fixed error in publish code
Browse files Browse the repository at this point in the history
Was adding an incorrect '\0' to the topic that was seen to cause
problems
  • Loading branch information
nscooling committed Feb 3, 2013
1 parent 9df17d1 commit 9b5e8c0
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/mqtt.c
Expand Up @@ -277,14 +277,13 @@ int mqtt_publish(mqtt_broker_handle_t *broker, const char *topic, const char *ms
}

// utf topic
uint8_t utf_topic[2+strlen(topic)+1]; // 2 for message size + 1 for '\0'
uint8_t utf_topic[2+strlen(topic)]; // 2 for message size QoS-0 does not have msg ID

// set up topic payload
utf_topic[0] = 0; // MSB(strlen(topic));
utf_topic[1] = LSB(strlen(topic));
strcpy((char *)&utf_topic[2], topic);
utf_topic[sizeof(utf_topic)-1] = '\0'; // terminate topic str correctly


uint8_t fixed_header[] = { SET_MESSAGE(PUBLISH), sizeof(utf_topic)+strlen(msg)};
// fixed_header_t fixed_header = { .QoS = 0, .connect_msg_t = PUBLISH, .remaining_length = sizeof(utf_topic)+strlen(msg) };

Expand Down

0 comments on commit 9b5e8c0

Please sign in to comment.