Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions adafruit_minimqtt/adafruit_minimqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ def ping(self):
def publish(self, topic, msg, retain=False, qos=0):
"""Publishes a message to a topic provided.
:param str topic: Unique topic identifier.
:param str,int,float msg: Data to send to the broker.
:param str,int,float,bytes msg: Data to send to the broker.
:param bool retain: Whether the message is saved by the broker.
:param int qos: Quality of Service level for the message, defaults to zero.

Expand All @@ -572,7 +572,7 @@ def publish(self, topic, msg, retain=False, qos=0):
msg = str(msg).encode("ascii")
elif isinstance(msg, str):
msg = str(msg).encode("utf-8")
else:
elif not isinstance(msg, bytes):
raise MMQTTException("Invalid message data type.")
if len(msg) > MQTT_MSG_MAX_SZ:
raise MMQTTException("Message size larger than %d bytes." % MQTT_MSG_MAX_SZ)
Expand Down