mqtt_client_shell.py 文件源码

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

项目:python-mqtt-client-shell 作者: bapowell 项目源码 文件源码
def subscribe(self, sub):
        """Subscribe to a topic, using the Subscription (namedtuple)."""
        if not sub.topic:
            print("Topic must be specified")
        else:
            (result, msg_id) = self._mqttclient.subscribe(topic=sub.topic, qos=(sub.qos or 0))
            print("...msg_id={!r}, result={} ({})".format(msg_id, result, mqtt.error_string(result)))
            if result == mqtt.MQTT_ERR_SUCCESS:
                self._discard_sub(sub.topic)   # do not want two Subscriptions with same topic, but different qos
                self._subscriptions.add(sub)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号