Skip to content

Commit df63c8f

Browse files
committed
Update adafruit_minimqtt.py
1 parent 3980b5a commit df63c8f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

adafruit_minimqtt/adafruit_minimqtt.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ def publish(self, topic, msg, retain=False, qos=0):
576576
pass
577577
else:
578578
raise MMQTTException("Invalid message data type.")
579-
if len(msg.encode("utf-8")) > MQTT_MSG_MAX_SZ:
579+
if len(msg) > MQTT_MSG_MAX_SZ:
580580
raise MMQTTException("Message size larger than %d bytes." % MQTT_MSG_MAX_SZ)
581581
assert (
582582
0 <= qos <= 1
@@ -589,7 +589,7 @@ def publish(self, topic, msg, retain=False, qos=0):
589589
pub_hdr_var = bytearray(struct.pack(">H", len(topic.encode("utf-8"))))
590590
pub_hdr_var.extend(topic.encode("utf-8")) # Topic name
591591

592-
remaining_length = 2 + len(msg.encode("utf-8")) + len(topic.encode("utf-8"))
592+
remaining_length = 2 + len(msg) + len(topic.encode("utf-8"))
593593
if qos > 0:
594594
# packet identifier where QoS level is 1 or 2. [3.3.2.2]
595595
remaining_length += 2

0 commit comments

Comments
 (0)