def initialize(self):
try:
if DEBUG_ON:
print('connect again')
self._mqttc = mqtt.Client(None)
self._mqttc.on_message = self.mqtt_on_message
self._mqttc.on_connect = self.mqtt_on_connect
self._mqttc.on_subscribe = self.mqtt_on_subscribe
self._mqttc.on_publish = self.mqtt_on_publish
self._mqttc.on_disconnect = self.on_disconnect
# Enable this line if you are doing the snip code, off stress
# self._mqttc.loop_start()
except TypeError:
print('Connect to mqtter error')
return
评论列表
文章目录