Merge pull request #15661 from haukepetersen/fix_emcute_msgidqos0

net/emcute: fix MsgId for PUBLISH with QOS0
This commit is contained in:
Hauke Petersen 2020-12-18 13:45:10 +01:00 committed by GitHub
commit 1e7b95cd70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View File

@ -66,6 +66,7 @@
* how to put / how to encode the IPv(4/6) address AND the port of
* a gateway in the GwAdd field of the GWINFO message
* @todo QOS level 2
* @todo QOS level -1
* @todo put the node to sleep (send DISCONNECT with duration field set)
* @todo handle DISCONNECT messages initiated by the broker/gateway
* @todo support for pre-defined and short topic IDs

View File

@ -351,8 +351,15 @@ int emcute_pub(emcute_topic_t *topic, const void *data, size_t len,
tbuf[pos++] = flags;
byteorder_htobebufs(&tbuf[pos], topic->id);
pos += 2;
byteorder_htobebufs(&tbuf[pos], id_next);
waitonid = id_next++;
/* set generated MessageId for QOS 1 and 2, else set it to 0 */
if (((flags & MQTTSN_QOS_MASK) == MQTTSN_QOS_1) ||
((flags & MQTTSN_QOS_MASK) == MQTTSN_QOS_2)) {
byteorder_htobebufs(&tbuf[pos], id_next);
waitonid = id_next++;
}
else {
memset(&tbuf[pos], 0, 2);
}
pos += 2;
memcpy(&tbuf[pos], data, len);