--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MqttMonitor/Documentation/source/Plugin_Mqtt_Monitor.MqttMonitor.MqttClient.html Sun Sep 02 18:36:22 2018 +0200 @@ -0,0 +1,470 @@ +<!DOCTYPE html> +<html><head> +<title>Plugin_Mqtt_Monitor.MqttMonitor.MqttClient</title> +<meta charset="UTF-8"> +<style> +body { + background: #EDECE6; + margin: 0em 1em 10em 1em; + color: black; +} + +h1 { color: white; background: #85774A; } +h2 { color: white; background: #85774A; } +h3 { color: white; background: #9D936E; } +h4 { color: white; background: #9D936E; } + +a { color: #BA6D36; } + +</style> +</head> +<body><a NAME="top" ID="top"></a> +<h1>Plugin_Mqtt_Monitor.MqttMonitor.MqttClient</h1> +<p> +Module implementing a PyQt wrapper around the paho MQTT client. +</p> +<h3>Global Attributes</h3> +<table> +<tr><td>None</td></tr> +</table> +<h3>Classes</h3> +<table> +<tr> +<td><a href="#MqttClient">MqttClient</a></td> +<td>Class implementing a PyQt wrapper around the paho MQTT client.</td> +</tr> +</table> +<h3>Functions</h3> +<table> +<tr> +<td><a href="#mqttConnackMessage">mqttConnackMessage</a></td> +<td>Public method to get the string associated with a CONNACK result.</td> +</tr><tr> +<td><a href="#mqttErrorMessage">mqttErrorMessage</a></td> +<td>Public method to get the error string associated with an MQTT error number.</td> +</tr> +</table> +<hr /><hr /> +<a NAME="MqttClient" ID="MqttClient"></a> +<h2>MqttClient</h2> +<p> + Class implementing a PyQt wrapper around the paho MQTT client. +</p><h3>Signals</h3> +<dl> +<dt>onConnect(flags, rc)</dt> +<dd> +emitted after the client has connected to the + broker +</dd><dt>onDisconnected(rc)</dt> +<dd> +emitted after the client has disconnected from + the broker +</dd><dt>onMessage(topic, payload, qos, retain)</dt> +<dd> +emitted after a message has + been received by the client +</dd><dt>onPublish(mid)</dt> +<dd> +emitted after a message has been published +</dd><dt>onSubscribe(mid, grantedQos)</dt> +<dd> +emitted after the client has + subscribed to some topics +</dd><dt>onUnsubscribe(mid)</dt> +<dd> +emitted after the client has unsubscribed from + some topics +</dd> +</dl> +<h3>Derived from</h3> +QObject +<h3>Class Attributes</h3> +<table> +<tr><td>None</td></tr> +</table> +<h3>Class Methods</h3> +<table> +<tr><td>None</td></tr> +</table> +<h3>Methods</h3> +<table> +<tr> +<td><a href="#MqttClient.__init__">MqttClient</a></td> +<td>Constructor</td> +</tr><tr> +<td><a href="#MqttClient.__initCallbacks">__initCallbacks</a></td> +<td>Private method to initialize the MQTT callback methods.</td> +</tr><tr> +<td><a href="#MqttClient.connectToServer">connectToServer</a></td> +<td>Public method to connect to a remote MQTT broker.</td> +</tr><tr> +<td><a href="#MqttClient.connectToServerWithOptions">connectToServerWithOptions</a></td> +<td>Public method to connect to a remote MQTT broker.</td> +</tr><tr> +<td><a href="#MqttClient.defaultConnectionOptions">defaultConnectionOptions</a></td> +<td>Public method to get a connection options dictionary with default values.</td> +</tr><tr> +<td><a href="#MqttClient.disconnectFromServer">disconnectFromServer</a></td> +<td>Public method to disconnect the client from the remote broker.</td> +</tr><tr> +<td><a href="#MqttClient.publish">publish</a></td> +<td>Public method to publish to a topic.</td> +</tr><tr> +<td><a href="#MqttClient.reconnectToServer">reconnectToServer</a></td> +<td>Public method to reconnect the client with the same parameters.</td> +</tr><tr> +<td><a href="#MqttClient.reinitialise">reinitialise</a></td> +<td>Public method to reinitialize the client with given data.</td> +</tr><tr> +<td><a href="#MqttClient.setLastWill">setLastWill</a></td> +<td>Public method to set the last will of the client.</td> +</tr><tr> +<td><a href="#MqttClient.setMaxInflightMessages">setMaxInflightMessages</a></td> +<td>Public method to set the maximum number of messages with QoS > 0 that can be part way through their network flow at once.</td> +</tr><tr> +<td><a href="#MqttClient.setMaxQueuedMessages">setMaxQueuedMessages</a></td> +<td>Public method to set the maximum number of messages with QoS > 0 that can be pending in the outgoing message queue.</td> +</tr><tr> +<td><a href="#MqttClient.setUserCredentials">setUserCredentials</a></td> +<td>Public method to set the user name and optionally the password.</td> +</tr><tr> +<td><a href="#MqttClient.setUserData">setUserData</a></td> +<td>Public method to set the user data.</td> +</tr><tr> +<td><a href="#MqttClient.startLoop">startLoop</a></td> +<td>Public method to start the MQTT client loop.</td> +</tr><tr> +<td><a href="#MqttClient.stopLoop">stopLoop</a></td> +<td>Public method to stop the MQTT client loop.</td> +</tr><tr> +<td><a href="#MqttClient.subscribe">subscribe</a></td> +<td>Public method to subscribe to topics with quality of service.</td> +</tr><tr> +<td><a href="#MqttClient.unsubscribe">unsubscribe</a></td> +<td>Public method to unsubscribe topics.</td> +</tr> +</table> +<h3>Static Methods</h3> +<table> +<tr><td>None</td></tr> +</table> +<a NAME="MqttClient.__init__" ID="MqttClient.__init__"></a> +<h4>MqttClient (Constructor)</h4> +<b>MqttClient</b>(<i>clientId="", cleanSession=True, userdata=None, protocol=mqtt.MQTTv311, transport="tcp", parent=None</i>) +<p> + Constructor +</p><dl> +<dt><i>clientId</i> (str)</dt> +<dd> +ID to be used for the client +</dd><dt><i>cleanSession</i> (bool)</dt> +<dd> +flag indicating to start a clean session +</dd><dt><i>userdata</i> (any)</dt> +<dd> +user data +</dd><dt><i>protocol</i> (int, one of mqtt.MQTTv31 or mqtt.MQTTv311)</dt> +<dd> +version of the MQTT protocol to use +</dd><dt><i>transport</i> (str, one of "tcp" or "websockets")</dt> +<dd> +transport to be used +</dd><dt><i>parent</i> (QObject)</dt> +<dd> +reference to the parent object +</dd> +</dl><a NAME="MqttClient.__initCallbacks" ID="MqttClient.__initCallbacks"></a> +<h4>MqttClient.__initCallbacks</h4> +<b>__initCallbacks</b>(<i></i>) +<p> + Private method to initialize the MQTT callback methods. +</p><a NAME="MqttClient.connectToServer" ID="MqttClient.connectToServer"></a> +<h4>MqttClient.connectToServer</h4> +<b>connectToServer</b>(<i>host, port=1883, keepalive=60, bindAddress=""</i>) +<p> + Public method to connect to a remote MQTT broker. +</p><dl> +<dt><i>host</i> (str)</dt> +<dd> +host name or IP address of the remote broker +</dd><dt><i>port</i> (int)</dt> +<dd> +network port of the server host to connect to (default: + 1883, using TLS: 8883) +</dd><dt><i>keepalive</i> (int)</dt> +<dd> +maximum period in seconds allowed between + communications with the broker +</dd><dt><i>bindAddress</i> (str)</dt> +<dd> +IP address of a local network interface to bind + this client to +</dd> +</dl><a NAME="MqttClient.connectToServerWithOptions" ID="MqttClient.connectToServerWithOptions"></a> +<h4>MqttClient.connectToServerWithOptions</h4> +<b>connectToServerWithOptions</b>(<i>host, port=1883, bindAddress="", options=None</i>) +<p> + Public method to connect to a remote MQTT broker. +</p><dl> +<dt><i>host</i> (str)</dt> +<dd> +host name or IP address of the remote broker +</dd><dt><i>port</i> (int)</dt> +<dd> +network port of the server host to connect to (default: + 1883, using TLS: 8883) +</dd><dt><i>bindAddress</i> (str)</dt> +<dd> +IP address of a local network interface to bind + this client to +</dd><dt><i>options</i> (dict)</dt> +<dd> +dictionary containing the connection options. This + dictionary should contain the keys "ClientId", "Keepalive", + "CleanSession", "Username", "Password", "WillTopic", "WillMessage", + "WillQos", "WillRetain" +</dd> +</dl><a NAME="MqttClient.defaultConnectionOptions" ID="MqttClient.defaultConnectionOptions"></a> +<h4>MqttClient.defaultConnectionOptions</h4> +<b>defaultConnectionOptions</b>(<i></i>) +<p> + Public method to get a connection options dictionary with default + values. +</p><dl> +<dt>Returns:</dt> +<dd> +dictionary containing the default connection options. It has + the keys "ClientId", "Keepalive", "CleanSession", "Username", + "Password", "WillTopic", "WillMessage", "WillQos", "WillRetain" +</dd> +</dl><dl> +<dt>Return Type:</dt> +<dd> +dict +</dd> +</dl><a NAME="MqttClient.disconnectFromServer" ID="MqttClient.disconnectFromServer"></a> +<h4>MqttClient.disconnectFromServer</h4> +<b>disconnectFromServer</b>(<i></i>) +<p> + Public method to disconnect the client from the remote broker. +</p><a NAME="MqttClient.publish" ID="MqttClient.publish"></a> +<h4>MqttClient.publish</h4> +<b>publish</b>(<i>topic, payload=None, qos=0, retain=False</i>) +<p> + Public method to publish to a topic. +</p><dl> +<dt><i>topic</i> (str)</dt> +<dd> +topic to publish to +</dd><dt><i>payload</i> (str, bytes, int or float)</dt> +<dd> +data to be published +</dd><dt><i>qos</i> (int, one of 0, 1 or 2)</dt> +<dd> +quality of service +</dd><dt><i>retain</i> (bool)</dt> +<dd> +flag indicating to set as the "last known good"/retained + message for the topic +</dd> +</dl><dl> +<dt>Returns:</dt> +<dd> +message info object +</dd> +</dl><dl> +<dt>Return Type:</dt> +<dd> +mqtt.MQTTMessageInfo +</dd> +</dl><a NAME="MqttClient.reconnectToServer" ID="MqttClient.reconnectToServer"></a> +<h4>MqttClient.reconnectToServer</h4> +<b>reconnectToServer</b>(<i></i>) +<p> + Public method to reconnect the client with the same parameters. +</p><a NAME="MqttClient.reinitialise" ID="MqttClient.reinitialise"></a> +<h4>MqttClient.reinitialise</h4> +<b>reinitialise</b>(<i>clientId="", cleanSession=True, userdata=None</i>) +<p> + Public method to reinitialize the client with given data. +</p><dl> +<dt><i>clientId</i> (str)</dt> +<dd> +ID to be used for the client +</dd><dt><i>cleanSession</i> (bool)</dt> +<dd> +flag indicating to start a clean session +</dd><dt><i>userdata</i> (any)</dt> +<dd> +user data +</dd> +</dl><a NAME="MqttClient.setLastWill" ID="MqttClient.setLastWill"></a> +<h4>MqttClient.setLastWill</h4> +<b>setLastWill</b>(<i>topic, payload=None, qos=0, retain=False</i>) +<p> + Public method to set the last will of the client. +</p><dl> +<dt><i>topic</i> (str)</dt> +<dd> +topic the will message should be published on +</dd><dt><i>payload</i> (str, bytes, int or float)</dt> +<dd> +message to send as a will +</dd><dt><i>qos</i> (int, one of 0, 1 or 2)</dt> +<dd> +quality of service level to use for the will +</dd><dt><i>retain</i> (bool)</dt> +<dd> +flag indicating to set as the "last known good"/retained + message for the will topic +</dd> +</dl><a NAME="MqttClient.setMaxInflightMessages" ID="MqttClient.setMaxInflightMessages"></a> +<h4>MqttClient.setMaxInflightMessages</h4> +<b>setMaxInflightMessages</b>(<i>inflight=20</i>) +<p> + Public method to set the maximum number of messages with QoS > 0 that + can be part way through their network flow at once. +</p><dl> +<dt><i>inflight</i> (int)</dt> +<dd> +maximum number of messages in flight +</dd> +</dl><a NAME="MqttClient.setMaxQueuedMessages" ID="MqttClient.setMaxQueuedMessages"></a> +<h4>MqttClient.setMaxQueuedMessages</h4> +<b>setMaxQueuedMessages</b>(<i>queueSize=0</i>) +<p> + Public method to set the maximum number of messages with QoS > 0 that + can be pending in the outgoing message queue. +</p><dl> +<dt><i>queueSize</i> (int)</dt> +<dd> +maximum number of queued messages (0 = unlimited) +</dd> +</dl><a NAME="MqttClient.setUserCredentials" ID="MqttClient.setUserCredentials"></a> +<h4>MqttClient.setUserCredentials</h4> +<b>setUserCredentials</b>(<i>username, password=None</i>) +<p> + Public method to set the user name and optionally the password. +</p><dl> +<dt><i>username</i> (str)</dt> +<dd> +user name to be set +</dd><dt><i>password</i> (str)</dt> +<dd> +optional password +</dd> +</dl><a NAME="MqttClient.setUserData" ID="MqttClient.setUserData"></a> +<h4>MqttClient.setUserData</h4> +<b>setUserData</b>(<i>userdata</i>) +<p> + Public method to set the user data. +</p><dl> +<dt><i>userdata</i> (any)</dt> +<dd> +user data +</dd> +</dl><a NAME="MqttClient.startLoop" ID="MqttClient.startLoop"></a> +<h4>MqttClient.startLoop</h4> +<b>startLoop</b>(<i></i>) +<p> + Public method to start the MQTT client loop. +</p><a NAME="MqttClient.stopLoop" ID="MqttClient.stopLoop"></a> +<h4>MqttClient.stopLoop</h4> +<b>stopLoop</b>(<i></i>) +<p> + Public method to stop the MQTT client loop. +</p><a NAME="MqttClient.subscribe" ID="MqttClient.subscribe"></a> +<h4>MqttClient.subscribe</h4> +<b>subscribe</b>(<i>topic, qos=0</i>) +<p> + Public method to subscribe to topics with quality of service. +</p><dl> +<dt><i>topic</i> (str or tuple of (str, int) or list of tuple of (str, int))</dt> +<dd> +single topic to subscribe to or a tuple with a topic + and a QoS or a list of tuples with a topic and a QoS each +</dd><dt><i>qos</i> (int, one of 0, 1 or 2)</dt> +<dd> +quality of service +</dd> +</dl><dl> +<dt>Returns:</dt> +<dd> +tuple containing the result code and the message ID +</dd> +</dl><dl> +<dt>Return Type:</dt> +<dd> +tuple of (int, int) +</dd> +</dl><a NAME="MqttClient.unsubscribe" ID="MqttClient.unsubscribe"></a> +<h4>MqttClient.unsubscribe</h4> +<b>unsubscribe</b>(<i>topic</i>) +<p> + Public method to unsubscribe topics. +</p><dl> +<dt><i>topic</i> (str or list of str)</dt> +<dd> +topic or list of topics to unsubscribe +</dd> +</dl><dl> +<dt>Returns:</dt> +<dd> +tuple containing the result code and the message ID +</dd> +</dl><dl> +<dt>Return Type:</dt> +<dd> +tuple of (int, int) +</dd> +</dl> +<div align="right"><a href="#top">Up</a></div> +<hr /><hr /> +<a NAME="mqttConnackMessage" ID="mqttConnackMessage"></a> +<h2>mqttConnackMessage</h2> +<b>mqttConnackMessage</b>(<i>connackCode</i>) +<p> + Public method to get the string associated with a CONNACK result. +</p><dl> +<dt><i>connackCode</i> (int)</dt> +<dd> +result code of the connection request +</dd> +</dl><dl> +<dt>Returns:</dt> +<dd> +textual representation for the result code +</dd> +</dl><dl> +<dt>Return Type:</dt> +<dd> +str +</dd> +</dl> +<div align="right"><a href="#top">Up</a></div> +<hr /><hr /> +<a NAME="mqttErrorMessage" ID="mqttErrorMessage"></a> +<h2>mqttErrorMessage</h2> +<b>mqttErrorMessage</b>(<i>mqttErrno</i>) +<p> + Public method to get the error string associated with an MQTT error + number. +</p><dl> +<dt><i>mqttErrno</i> (int)</dt> +<dd> +result code of a MQTT request +</dd> +</dl><dl> +<dt>Returns:</dt> +<dd> +textual representation of the result code +</dd> +</dl><dl> +<dt>Return Type:</dt> +<dd> +str +</dd> +</dl> +<div align="right"><a href="#top">Up</a></div> +<hr /> +</body></html> \ No newline at end of file