Add QoS -1 sample

This commit is contained in:
Ian Craggs
2014-03-21 15:32:55 +00:00
parent 36d005d96b
commit d6831bb7a7
4 changed files with 182 additions and 5 deletions

View File

@@ -57,7 +57,12 @@ int MQTTSNDeserialize_publish(int* dup, int* qos, int* retained, int* packetid,
*retained = flags.bits.retain;
topic->type = flags.bits.topicIdType;
if (topic->type == MQTTSN_TOPIC_TYPE_NORMAL || topic->type == MQTTSN_TOPIC_TYPE_PREDEFINED)
if (topic.type == MQTTSN_TOPIC_TYPE_NORMAL && qos == 3)
{
/* special arrangement for long topic names in QoS -1 publishes. The length of the topic is in the topicid field */
topic->data.qos3.longlen = readInt(&curdata);
}
else if (topic->type == MQTTSN_TOPIC_TYPE_NORMAL || topic->type == MQTTSN_TOPIC_TYPE_PREDEFINED)
topic->data.id = readInt(&curdata);
else
{
@@ -66,6 +71,12 @@ int MQTTSNDeserialize_publish(int* dup, int* qos, int* retained, int* packetid,
}
*packetid = readInt(&curdata);
if (topic.type == MQTTSN_TOPIC_TYPE_NORMAL && qos == 3)
{
topic->data.qos3.longname = curdata;
curdata += topic->data.qos3.longlen;
}
*payloadlen = enddata - curdata;
*payload = curdata;
rc = 1;