comparison lib/mqtt_client/mqtt_client.py @ 560:3501410e4cc7

also pass topic as str at publish Ignore-this: ae4519416b4c4a29db44e9569b60edd
author drewp@bigasterisk.com
date Wed, 01 May 2019 00:09:23 -0700
parents 1df51216b712
children 603272ee3000
comparison
equal deleted inserted replaced
559:9294c00edbf7 560:3501410e4cc7
45 def publish(self, topic: bytes, msg: bytes): 45 def publish(self, topic: bytes, msg: bytes):
46 def _logFailure(failure): 46 def _logFailure(failure):
47 log.warn("publish failed: %s", failure.getErrorMessage()) 47 log.warn("publish failed: %s", failure.getErrorMessage())
48 return failure 48 return failure
49 49
50 return self.protocol.publish(topic=bytearray(topic), qos=0, 50 return self.protocol.publish(topic=topic.decode('utf-8'), qos=0,
51 message=bytearray(msg)).addErrback(_logFailure) 51 message=bytearray(msg)).addErrback(_logFailure)
52 52
53 53
54 class MqttClient(object): 54 class MqttClient(object):
55 def __init__(self, brokerHost='bang', brokerPort=1883): 55 def __init__(self, brokerHost='bang', brokerPort=1883):