@@ -70,20 +70,20 @@ assert(connack.retcode == 0)
7070
7171
7272= MQTTSubscribe, packet instantiation
73- sb = MQTT()/MQTTSubscribe(msgid=1,topic='newtopic',QOS=0, length=0)
73+ sb = MQTT()/MQTTSubscribe(msgid=1, topics=[MQTTTopicQOS( topic='newtopic', QOS=1, length=0)] )
7474assert(sb.type == 8)
7575assert(sb.msgid == 1)
76- assert(sb.topic == b'newtopic')
77- assert(sb.length == 0)
78- assert(sb[MQTTSubscribe].QOS == 0 )
76+ assert(sb.topics[0]. topic == b'newtopic')
77+ assert(sb.topics[0]. length == 0)
78+ assert(sb[MQTTSubscribe][MQTTTopicQOS] .QOS == 1 )
7979
8080= MQTTSubscribe, packet dissection
81- s = b'\x82\t\x00\x01\x00\x04test\x00 '
81+ s = b'\x82\t\x00\x01\x00\x04test\x01 '
8282subscribe = MQTT(s)
8383assert(subscribe.msgid == 1)
84- assert(subscribe.length == 4)
85- assert(subscribe.topic == b'test')
86- assert(subscribe.QOS == 1)
84+ assert(subscribe.topics[0]. length == 4)
85+ assert(subscribe.topics[0]. topic == b'test')
86+ assert(subscribe.topics[0]. QOS == 1)
8787
8888
8989= MQTTSuback, packet instantiation
@@ -98,6 +98,30 @@ suback = MQTT(s)
9898assert(suback.msgid == 1)
9999assert(suback.retcode == 0)
100100
101+ = MQTTUnsubscribe, packet instantiation
102+ unsb = MQTT()/MQTTUnsubscribe(msgid=1, topics=[MQTTTopic(topic='newtopic',length=0)])
103+ assert(unsb.type == 10)
104+ assert(unsb.msgid == 1)
105+ assert(unsb.topics[0].topic == b'newtopic')
106+ assert(unsb.topics[0].length == 0)
107+
108+ = MQTTUnsubscribe, packet dissection
109+ u = b'\xA2\x09\x00\x01\x00\x03\x61\x2F\x62'
110+ unsubscribe = MQTT(u)
111+ assert(unsubscribe.msgid == 1)
112+ assert(unsubscribe.topics[0].length == 3)
113+ assert(unsubscribe.topics[0].topic == b'a/b')
114+
115+ = MQTTUnsuback, packet instantiation
116+ unsk = MQTT()/MQTTUnsuback(msgid=1)
117+ assert(unsk.type == 11)
118+ assert(unsk.msgid == 1)
119+
120+ = MQTTUnsuback, packet dissection
121+ u = b'\xb0\x02\x00\x01'
122+ unsuback = MQTT(u)
123+ assert(unsuback.type == 11)
124+ assert(unsuback.msgid == 1)
101125
102126= MQTTPubrec, packet instantiation
103127pc = MQTT()/MQTTPubrec(msgid=1)
@@ -129,3 +153,7 @@ assert(type(MQTT().fieldtype['len'].randval() + 0) == int)
129153= MQTTUnsubscribe
130154u = MQTT(b'\xA2\x0C\x00\x01\x00\x03\x61\x2F\x62\x00\x03\x63\x2F\x64')
131155assert MQTTUnsubscribe in u and len(u.topics) == 2 and u.topics[1].topic == b"c/d"
156+
157+ = MQTTSubscribe
158+ u = MQTT(b'\x82\x10\x00\x01\x00\x03\x61\x2F\x62\x02\x00\x03\x63\x2F\x64\x00')
159+ assert MQTTSubscribe in u and len(u.topics) == 2 and u.topics[1].topic == b"c/d"
0 commit comments