Merge pull request #21 from malachib/master
Fixing reversal of topic/packet identifier (topic should come first)
This commit is contained in:
commit
d58783e3a1
@ -490,6 +490,7 @@ uint8_t Adafruit_MQTT::connectPacket(uint8_t *packet) {
|
||||
return len;
|
||||
}
|
||||
|
||||
// as per http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718040
|
||||
uint8_t Adafruit_MQTT::publishPacket(uint8_t *packet, const char *topic,
|
||||
const char *data, uint8_t qos) {
|
||||
uint8_t *p = packet;
|
||||
@ -499,6 +500,9 @@ uint8_t Adafruit_MQTT::publishPacket(uint8_t *packet, const char *topic,
|
||||
// fill in packet[1] last
|
||||
p+=2;
|
||||
|
||||
// topic comes before packet identifier
|
||||
p = stringprint_P(p, topic);
|
||||
|
||||
// add packet identifier. used for checking PUBACK in QOS > 0
|
||||
if(qos > 0) {
|
||||
p[0] = (packet_id_counter >> 8) & 0xFF;
|
||||
@ -509,8 +513,6 @@ uint8_t Adafruit_MQTT::publishPacket(uint8_t *packet, const char *topic,
|
||||
packet_id_counter++;
|
||||
}
|
||||
|
||||
p = stringprint_P(p, topic);
|
||||
|
||||
memcpy(p, data, strlen(data));
|
||||
p+=strlen(data);
|
||||
len = p - packet;
|
||||
|
Loading…
Reference in New Issue
Block a user