:mod:`expliot.core.protocols.internet.mqtt` =========================================== .. py:module:: expliot.core.protocols.internet.mqtt Package Contents ---------------- .. py:class:: SimpleMqttClient SimpleMqttClient A wrapper around simple publish and subscribe methods in paho mqtt. It also few implements helper methods .. staticmethod:: sub(topics, **kwargs) Wrapper around paho-mqtt subscribe.simple() method. For details on arguments. Please refer paho/mqtt/subscribe.py in paho-mqtt project (https://pypi.org/project/paho-mqtt/) :param topics: Either a string containing a single topic or a list containing multiple topics :param kwargs: subscribe.simple() keyword arguments :return: List of msg_count messages (from the topics subscribed to) received from the broker. msg_count subscribe.simple() argument is the count of messages to retrieve. .. staticmethod:: pub(topic, **kwargs) Wrapper around paho-mqtt publish.single() method. For details on arguments, please refer paho/mqtt/publish.py in paho-mqtt project (https://pypi.org/project/paho-mqtt/) :param topic: Topic to which the messahed will be published. :param kwargs: publish.single() keyword arguments :return: .. staticmethod:: pubmultiple(msgs, **kwargs) Wrapper around paho-mqtt publish.multiple() method. For details on arguments, please refer paho/mqtt/publish.py in paho-mqtt project (https://pypi.org/project/paho-mqtt/) :param msgs: List of messages to publish. Based on paho-mqtt doc, each message can either be 1. dict: msg = {'topic':"", 'payload':"", 'qos': 2. tuple: ("", "", qos, retain) :param kwargs: publish.multiple() keyword arguments :return: .. staticmethod:: connauth(host, clientid=None, user=None, passwd=None, **kw) connauth helps in checking if a client can connect to a broker with specific client id and/or credentials :param host: Host to connect to :param clientid: Client ID to use. If not specified paho-mqtt generates a random id. :param user: User name of the client. If None or empty, connection is attempted without user, pwd :param passwd: Password of the client. If None, only user name is sent :param kw: Client.connect() keyword arguments (excluding host) :return: Two comma separated values - The result code and it's string representation .. staticmethod:: _on_connauth(client, userdata, flags, rc) on_connect callback method for paho-mqtt Client. The arguments are passed by Client object. Details of the arguments are documented in paho/mqtt/client.py (https://pypi.org/project/paho-mqtt/ This method is internally used for connauth(). :param client: The client instance for this callback :param userdata: The private user data as set in Client() or userdata_set() :param flags: Response flags sent by the broker :param rc: The connection result :return: None .. py:class:: MqttClient Bases: :class:`paho.mqtt.client.Client`