Skip to content

Commit 99cd90f

Browse files
authored
Merge pull request adafruit#84 from PhearZero/patch-1
Allow publishing of bytes messages
2 parents d589d62 + 752e632 commit 99cd90f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

adafruit_minimqtt/adafruit_minimqtt.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ def ping(self):
556556
def publish(self, topic, msg, retain=False, qos=0):
557557
"""Publishes a message to a topic provided.
558558
:param str topic: Unique topic identifier.
559-
:param str,int,float msg: Data to send to the broker.
559+
:param str,int,float,bytes msg: Data to send to the broker.
560560
:param bool retain: Whether the message is saved by the broker.
561561
:param int qos: Quality of Service level for the message, defaults to zero.
562562
@@ -572,6 +572,8 @@ def publish(self, topic, msg, retain=False, qos=0):
572572
msg = str(msg).encode("ascii")
573573
elif isinstance(msg, str):
574574
msg = str(msg).encode("utf-8")
575+
elif isinstance(msg, bytes):
576+
pass
575577
else:
576578
raise MMQTTException("Invalid message data type.")
577579
if len(msg) > MQTT_MSG_MAX_SZ:

0 commit comments

Comments
 (0)