Skip to content

Commit 1631505

Browse files
author
brentru
committed
rem_len should be at the end of the fixed header
1 parent 1770e50 commit 1631505

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

adafruit_minimqtt/adafruit_minimqtt.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,6 @@ def publish(self, topic, msg, retain=False, qos=0):
449449
# fixed header
450450
pub_hdr_fixed = bytearray(b"\x30")
451451
pub_hdr_fixed[0] |= qos << 1 | retain
452-
pub_hdr_fixed.append(2 + len(msg) + len(topic))
453452

454453
# variable header
455454
pub_hdr_var = bytearray()
@@ -460,7 +459,7 @@ def publish(self, topic, msg, retain=False, qos=0):
460459
#pub_hdr_var.append(0x00) # pid msb
461460
#pub_hdr_var.append(0xa) #'PID LSB
462461

463-
remaining_length = 7 + len(msg)
462+
remaining_length = 2 + len(msg) + len(topic)
464463
if qos > 0:
465464
remaining_length += 2 + len(qos)
466465

@@ -479,11 +478,8 @@ def publish(self, topic, msg, retain=False, qos=0):
479478
if large_rel_length:
480479
pub_hdr_fixed.append(0x00)
481480
else:
482-
# append MSB/LSB to header
483-
#pub_hdr_fixed.append(len(topic) >> 8)
484-
#pub_hdr_fixed.append(len(topic) & 0xFF)
485-
print(remaining_length)
486-
print(pub_hdr_fixed)
481+
pub_hdr_fixed.append(remaining_length)
482+
#pub_hdr_fixed()
487483

488484

489485
self._sock.send(pub_hdr_fixed)

0 commit comments

Comments
 (0)