From b3e18adefe5456e097695801882bd9576e939be6 Mon Sep 17 00:00:00 2001 From: Nicolas Jouanin Date: Wed, 1 Jul 2015 21:38:22 +0200 Subject: [PATCH] HBMQTT-2 #comment fixed as published message with QOS=0 don't have packet ID --- hbmqtt/mqtt/publish.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hbmqtt/mqtt/publish.py b/hbmqtt/mqtt/publish.py index 1ebdc07..22b3a92 100644 --- a/hbmqtt/mqtt/publish.py +++ b/hbmqtt/mqtt/publish.py @@ -27,7 +27,11 @@ class PublishVariableHeader(MQTTVariableHeader): @classmethod def from_stream(cls, reader: asyncio.StreamReader, fixed_header: MQTTFixedHeader): topic_name = yield from decode_string(reader) - packet_id = yield from decode_packet_id(reader) + has_qos = (fixed_header.flags >> 1) & 0x03 + if has_qos: + packet_id = yield from decode_packet_id(reader) + else: + packet_id = None return cls(topic_name, packet_id)