expliot.core.protocols.internet.mqtt¶
Package Contents¶
-
class
expliot.core.protocols.internet.mqtt.SimpleMqttClient¶ SimpleMqttClient
A wrapper around simple publish and subscribe methods in paho mqtt. It also few implements helper methods
-
static
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/)
Parameters: - topics – Either a string containing a single topic or a list containing multiple topics
- kwargs – subscribe.simple() keyword arguments
Returns: 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.
-
static
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/)
Parameters: - topic – Topic to which the messahed will be published.
- kwargs – publish.single() keyword arguments
Returns:
-
static
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/)
Parameters: - msgs – List of messages to publish. Based on paho-mqtt doc, each message can either be 1. dict: msg = {‘topic’:”<topic>”, ‘payload’:”<payload>”, ‘qos’:<qos> 2. tuple: (“<topic>”, “<payload>”, qos, retain)
- kwargs – publish.multiple() keyword arguments
Returns:
-
static
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
Parameters: - host – Host to connect to
- clientid – Client ID to use. If not specified paho-mqtt generates a random id.
- user – User name of the client. If None or empty, connection is attempted without user, pwd
- passwd – Password of the client. If None, only user name is sent
- kw – Client.connect() keyword arguments (excluding host)
Returns: Two comma separated values - The result code and it’s string representation
-
static
_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().
Parameters: - client – The client instance for this callback
- userdata – The private user data as set in Client() or userdata_set()
- flags – Response flags sent by the broker
- rc – The connection result
Returns: None
-
static
-
class
expliot.core.protocols.internet.mqtt.MqttClient¶ Bases:
paho.mqtt.client.Client