WolkMQTT.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:WolkConnect-Python- 作者: Wolkabout 项目源码 文件源码
def __init__(self, wolkMQTTClientConfig):
        self.clientConfig = wolkMQTTClientConfig
        # Setup MQTT client
        self.client = mqtt.Client(self.clientConfig.wolkClientId, True)
        self.client.on_connect = self._on_mqtt_connect
        self.client.on_disconnect = self._on_mqtt_disconnect
        self.client.on_message = self._on_mqtt_message

        if self.clientConfig.ca_cert:
            self.client.tls_set(self.clientConfig.ca_cert)

        if self.clientConfig.set_insecure:
            self.client.tls_insecure_set(self.clientConfig.set_insecure)

        self.client.username_pw_set(self.clientConfig.username, self.clientConfig.password)
        self.host = self.clientConfig.host
        self.port = self.clientConfig.port
        lastWillTopic = "lastwill/" + self.clientConfig.username
        lastWillPayloyad = "Last will of serial:" + self.clientConfig.username
        self.client.will_set(lastWillTopic, lastWillPayloyad, self.clientConfig.qos, False)
        self.client.on_log = self._on_log
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号