MqttMonitor/Documentation/source/Plugin_Mqtt_Monitor.MqttMonitor.MqttClient.html

changeset 78
a22328182bc2
parent 58
6c84ba9a9fcd
child 87
fe391e485681
equal deleted inserted replaced
77:a580238d85de 78:a22328182bc2
16 16
17 a { color: #BA6D36; } 17 a { color: #BA6D36; }
18 18
19 </style> 19 </style>
20 </head> 20 </head>
21 <body><a NAME="top" ID="top"></a> 21 <body>
22 <a NAME="top" ID="top"></a>
22 <h1>Plugin_Mqtt_Monitor.MqttMonitor.MqttClient</h1> 23 <h1>Plugin_Mqtt_Monitor.MqttMonitor.MqttClient</h1>
24
23 <p> 25 <p>
24 Module implementing a PyQt wrapper around the paho MQTT client. 26 Module implementing a PyQt wrapper around the paho MQTT client.
25 </p> 27 </p>
26 <h3>Global Attributes</h3> 28 <h3>Global Attributes</h3>
29
27 <table> 30 <table>
28 <tr><td>None</td></tr> 31 <tr><td>None</td></tr>
29 </table> 32 </table>
30 <h3>Classes</h3> 33 <h3>Classes</h3>
34
31 <table> 35 <table>
36
32 <tr> 37 <tr>
33 <td><a href="#MqttClient">MqttClient</a></td> 38 <td><a href="#MqttClient">MqttClient</a></td>
34 <td>Class implementing a PyQt wrapper around the paho MQTT client.</td> 39 <td>Class implementing a PyQt wrapper around the paho MQTT client.</td>
35 </tr> 40 </tr>
36 </table> 41 </table>
37 <h3>Functions</h3> 42 <h3>Functions</h3>
43
38 <table> 44 <table>
45
39 <tr> 46 <tr>
40 <td><a href="#mqttConnackMessage">mqttConnackMessage</a></td> 47 <td><a href="#mqttConnackMessage">mqttConnackMessage</a></td>
41 <td>Module function to get the string associated with a CONNACK result.</td> 48 <td>Module function to get the string associated with a CONNACK result.</td>
42 </tr><tr> 49 </tr>
50 <tr>
43 <td><a href="#mqttErrorMessage">mqttErrorMessage</a></td> 51 <td><a href="#mqttErrorMessage">mqttErrorMessage</a></td>
44 <td>Module function to get the error string associated with an MQTT error number.</td> 52 <td>Module function to get the error string associated with an MQTT error number.</td>
45 </tr><tr> 53 </tr>
54 <tr>
46 <td><a href="#mqttLogLevelString">mqttLogLevelString</a></td> 55 <td><a href="#mqttLogLevelString">mqttLogLevelString</a></td>
47 <td>Module function to get the log level string associated with a log level.</td> 56 <td>Module function to get the log level string associated with a log level.</td>
48 </tr> 57 </tr>
49 </table> 58 </table>
50 <hr /><hr /> 59 <hr />
60 <hr />
51 <a NAME="MqttClient" ID="MqttClient"></a> 61 <a NAME="MqttClient" ID="MqttClient"></a>
52 <h2>MqttClient</h2> 62 <h2>MqttClient</h2>
63
53 <p> 64 <p>
54 Class implementing a PyQt wrapper around the paho MQTT client. 65 Class implementing a PyQt wrapper around the paho MQTT client.
55 </p><h3>Signals</h3> 66 </p>
56 <dl> 67 <h3>Signals</h3>
68 <dl>
69
57 <dt>connectTimeout()</dt> 70 <dt>connectTimeout()</dt>
58 <dd> 71 <dd>
59 emitted to indicate, that a connection attempt 72 emitted to indicate, that a connection attempt
60 timed out 73 timed out
61 </dd><dt>onConnect(flags, rc)</dt> 74 </dd>
75 <dt>onConnect(flags, rc)</dt>
62 <dd> 76 <dd>
63 emitted after the client has connected to the 77 emitted after the client has connected to the
64 broker 78 broker
65 </dd><dt>onDisconnected(rc)</dt> 79 </dd>
80 <dt>onDisconnected(rc)</dt>
66 <dd> 81 <dd>
67 emitted after the client has disconnected from 82 emitted after the client has disconnected from
68 the broker 83 the broker
69 </dd><dt>onLog(level, message)</dt> 84 </dd>
85 <dt>onLog(level, message)</dt>
70 <dd> 86 <dd>
71 emitted to send client log data 87 emitted to send client log data
72 </dd><dt>onMessage(topic, payload, qos, retain)</dt> 88 </dd>
89 <dt>onMessage(topic, payload, qos, retain)</dt>
73 <dd> 90 <dd>
74 emitted after a message has 91 emitted after a message has
75 been received by the client 92 been received by the client
76 </dd><dt>onPublish(mid)</dt> 93 </dd>
94 <dt>onPublish(mid)</dt>
77 <dd> 95 <dd>
78 emitted after a message has been published 96 emitted after a message has been published
79 </dd><dt>onSubscribe(mid, grantedQos)</dt> 97 </dd>
98 <dt>onSubscribe(mid, grantedQos)</dt>
80 <dd> 99 <dd>
81 emitted after the client has 100 emitted after the client has
82 subscribed to some topics 101 subscribed to some topics
83 </dd><dt>onUnsubscribe(mid)</dt> 102 </dd>
103 <dt>onUnsubscribe(mid)</dt>
84 <dd> 104 <dd>
85 emitted after the client has unsubscribed from 105 emitted after the client has unsubscribed from
86 some topics 106 some topics
87 </dd> 107 </dd>
88 </dl> 108 </dl>
89 <h3>Derived from</h3> 109 <h3>Derived from</h3>
90 QObject 110 QObject
91 <h3>Class Attributes</h3> 111 <h3>Class Attributes</h3>
112
92 <table> 113 <table>
93 <tr><td>DefaultConnectTimeout</td></tr><tr><td>LogDebug</td></tr><tr><td>LogDisabled</td></tr><tr><td>LogError</td></tr><tr><td>LogInfo</td></tr><tr><td>LogLevelMap</td></tr><tr><td>LogNotice</td></tr><tr><td>LogWarning</td></tr> 114 <tr><td>DefaultConnectTimeout</td></tr><tr><td>LogDebug</td></tr><tr><td>LogDisabled</td></tr><tr><td>LogError</td></tr><tr><td>LogInfo</td></tr><tr><td>LogLevelMap</td></tr><tr><td>LogNotice</td></tr><tr><td>LogWarning</td></tr>
94 </table> 115 </table>
95 <h3>Class Methods</h3> 116 <h3>Class Methods</h3>
117
96 <table> 118 <table>
97 <tr><td>None</td></tr> 119 <tr><td>None</td></tr>
98 </table> 120 </table>
99 <h3>Methods</h3> 121 <h3>Methods</h3>
122
100 <table> 123 <table>
124
101 <tr> 125 <tr>
102 <td><a href="#MqttClient.__init__">MqttClient</a></td> 126 <td><a href="#MqttClient.__init__">MqttClient</a></td>
103 <td>Constructor</td> 127 <td>Constructor</td>
104 </tr><tr> 128 </tr>
129 <tr>
105 <td><a href="#MqttClient.__connectTimeout">__connectTimeout</a></td> 130 <td><a href="#MqttClient.__connectTimeout">__connectTimeout</a></td>
106 <td>Private slot handling a failed connection attempt.</td> 131 <td>Private slot handling a failed connection attempt.</td>
107 </tr><tr> 132 </tr>
133 <tr>
108 <td><a href="#MqttClient.__initCallbacks">__initCallbacks</a></td> 134 <td><a href="#MqttClient.__initCallbacks">__initCallbacks</a></td>
109 <td>Private method to initialize the MQTT callback methods.</td> 135 <td>Private method to initialize the MQTT callback methods.</td>
110 </tr><tr> 136 </tr>
137 <tr>
111 <td><a href="#MqttClient.clearLastWill">clearLastWill</a></td> 138 <td><a href="#MqttClient.clearLastWill">clearLastWill</a></td>
112 <td>Public method to remove a will that was previously configured with setLastWill().</td> 139 <td>Public method to remove a will that was previously configured with setLastWill().</td>
113 </tr><tr> 140 </tr>
141 <tr>
114 <td><a href="#MqttClient.connectToServer">connectToServer</a></td> 142 <td><a href="#MqttClient.connectToServer">connectToServer</a></td>
115 <td>Public method to connect to a remote MQTT broker.</td> 143 <td>Public method to connect to a remote MQTT broker.</td>
116 </tr><tr> 144 </tr>
145 <tr>
117 <td><a href="#MqttClient.connectToServerWithOptions">connectToServerWithOptions</a></td> 146 <td><a href="#MqttClient.connectToServerWithOptions">connectToServerWithOptions</a></td>
118 <td>Public method to connect to a remote MQTT broker.</td> 147 <td>Public method to connect to a remote MQTT broker.</td>
119 </tr><tr> 148 </tr>
149 <tr>
120 <td><a href="#MqttClient.defaultConnectionOptions">defaultConnectionOptions</a></td> 150 <td><a href="#MqttClient.defaultConnectionOptions">defaultConnectionOptions</a></td>
121 <td>Public method to get a connection options dictionary with default values.</td> 151 <td>Public method to get a connection options dictionary with default values.</td>
122 </tr><tr> 152 </tr>
153 <tr>
123 <td><a href="#MqttClient.disconnectFromServer">disconnectFromServer</a></td> 154 <td><a href="#MqttClient.disconnectFromServer">disconnectFromServer</a></td>
124 <td>Public method to disconnect the client from the remote broker.</td> 155 <td>Public method to disconnect the client from the remote broker.</td>
125 </tr><tr> 156 </tr>
157 <tr>
126 <td><a href="#MqttClient.publish">publish</a></td> 158 <td><a href="#MqttClient.publish">publish</a></td>
127 <td>Public method to publish to a topic.</td> 159 <td>Public method to publish to a topic.</td>
128 </tr><tr> 160 </tr>
161 <tr>
129 <td><a href="#MqttClient.reconnectToServer">reconnectToServer</a></td> 162 <td><a href="#MqttClient.reconnectToServer">reconnectToServer</a></td>
130 <td>Public method to reconnect the client with the same parameters.</td> 163 <td>Public method to reconnect the client with the same parameters.</td>
131 </tr><tr> 164 </tr>
165 <tr>
132 <td><a href="#MqttClient.reinitialise">reinitialise</a></td> 166 <td><a href="#MqttClient.reinitialise">reinitialise</a></td>
133 <td>Public method to reinitialize the client with given data.</td> 167 <td>Public method to reinitialize the client with given data.</td>
134 </tr><tr> 168 </tr>
169 <tr>
135 <td><a href="#MqttClient.setConnectionTimeout">setConnectionTimeout</a></td> 170 <td><a href="#MqttClient.setConnectionTimeout">setConnectionTimeout</a></td>
136 <td>Public method to set the connection timeout value.</td> 171 <td>Public method to set the connection timeout value.</td>
137 </tr><tr> 172 </tr>
173 <tr>
138 <td><a href="#MqttClient.setLastWill">setLastWill</a></td> 174 <td><a href="#MqttClient.setLastWill">setLastWill</a></td>
139 <td>Public method to set the last will of the client.</td> 175 <td>Public method to set the last will of the client.</td>
140 </tr><tr> 176 </tr>
177 <tr>
141 <td><a href="#MqttClient.setMaxInflightMessages">setMaxInflightMessages</a></td> 178 <td><a href="#MqttClient.setMaxInflightMessages">setMaxInflightMessages</a></td>
142 <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> 179 <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>
143 </tr><tr> 180 </tr>
181 <tr>
144 <td><a href="#MqttClient.setMaxQueuedMessages">setMaxQueuedMessages</a></td> 182 <td><a href="#MqttClient.setMaxQueuedMessages">setMaxQueuedMessages</a></td>
145 <td>Public method to set the maximum number of messages with QoS > 0 that can be pending in the outgoing message queue.</td> 183 <td>Public method to set the maximum number of messages with QoS > 0 that can be pending in the outgoing message queue.</td>
146 </tr><tr> 184 </tr>
185 <tr>
147 <td><a href="#MqttClient.setTLS">setTLS</a></td> 186 <td><a href="#MqttClient.setTLS">setTLS</a></td>
148 <td>Public method to enable secure connections and set the TLS parameters.</td> 187 <td>Public method to enable secure connections and set the TLS parameters.</td>
149 </tr><tr> 188 </tr>
189 <tr>
150 <td><a href="#MqttClient.setUserCredentials">setUserCredentials</a></td> 190 <td><a href="#MqttClient.setUserCredentials">setUserCredentials</a></td>
151 <td>Public method to set the user name and optionally the password.</td> 191 <td>Public method to set the user name and optionally the password.</td>
152 </tr><tr> 192 </tr>
193 <tr>
153 <td><a href="#MqttClient.setUserData">setUserData</a></td> 194 <td><a href="#MqttClient.setUserData">setUserData</a></td>
154 <td>Public method to set the user data.</td> 195 <td>Public method to set the user data.</td>
155 </tr><tr> 196 </tr>
197 <tr>
156 <td><a href="#MqttClient.startLoop">startLoop</a></td> 198 <td><a href="#MqttClient.startLoop">startLoop</a></td>
157 <td>Public method to start the MQTT client loop.</td> 199 <td>Public method to start the MQTT client loop.</td>
158 </tr><tr> 200 </tr>
201 <tr>
159 <td><a href="#MqttClient.stopLoop">stopLoop</a></td> 202 <td><a href="#MqttClient.stopLoop">stopLoop</a></td>
160 <td>Public method to stop the MQTT client loop.</td> 203 <td>Public method to stop the MQTT client loop.</td>
161 </tr><tr> 204 </tr>
205 <tr>
162 <td><a href="#MqttClient.subscribe">subscribe</a></td> 206 <td><a href="#MqttClient.subscribe">subscribe</a></td>
163 <td>Public method to subscribe to topics with quality of service.</td> 207 <td>Public method to subscribe to topics with quality of service.</td>
164 </tr><tr> 208 </tr>
209 <tr>
165 <td><a href="#MqttClient.unsubscribe">unsubscribe</a></td> 210 <td><a href="#MqttClient.unsubscribe">unsubscribe</a></td>
166 <td>Public method to unsubscribe topics.</td> 211 <td>Public method to unsubscribe topics.</td>
167 </tr> 212 </tr>
168 </table> 213 </table>
169 <h3>Static Methods</h3> 214 <h3>Static Methods</h3>
215
170 <table> 216 <table>
171 <tr><td>None</td></tr> 217 <tr><td>None</td></tr>
172 </table> 218 </table>
219
173 <a NAME="MqttClient.__init__" ID="MqttClient.__init__"></a> 220 <a NAME="MqttClient.__init__" ID="MqttClient.__init__"></a>
174 <h4>MqttClient (Constructor)</h4> 221 <h4>MqttClient (Constructor)</h4>
175 <b>MqttClient</b>(<i>clientId="", cleanSession=True, userdata=None, protocol=mqtt.MQTTv311, transport="tcp", parent=None</i>) 222 <b>MqttClient</b>(<i>clientId="", cleanSession=True, userdata=None, protocol=mqtt.MQTTv311, transport="tcp", parent=None</i>)
223
176 <p> 224 <p>
177 Constructor 225 Constructor
178 </p><dl> 226 </p>
227 <dl>
228
179 <dt><i>clientId</i> (str)</dt> 229 <dt><i>clientId</i> (str)</dt>
180 <dd> 230 <dd>
181 ID to be used for the client 231 ID to be used for the client
182 </dd><dt><i>cleanSession</i> (bool)</dt> 232 </dd>
233 <dt><i>cleanSession</i> (bool)</dt>
183 <dd> 234 <dd>
184 flag indicating to start a clean session 235 flag indicating to start a clean session
185 </dd><dt><i>userdata</i> (any)</dt> 236 </dd>
237 <dt><i>userdata</i> (any)</dt>
186 <dd> 238 <dd>
187 user data 239 user data
188 </dd><dt><i>protocol</i> (int, one of mqtt.MQTTv31 or mqtt.MQTTv311)</dt> 240 </dd>
241 <dt><i>protocol</i> (int, one of mqtt.MQTTv31 or mqtt.MQTTv311)</dt>
189 <dd> 242 <dd>
190 version of the MQTT protocol to use 243 version of the MQTT protocol to use
191 </dd><dt><i>transport</i> (str, one of "tcp" or "websockets")</dt> 244 </dd>
245 <dt><i>transport</i> (str, one of "tcp" or "websockets")</dt>
192 <dd> 246 <dd>
193 transport to be used 247 transport to be used
194 </dd><dt><i>parent</i> (QObject)</dt> 248 </dd>
249 <dt><i>parent</i> (QObject)</dt>
195 <dd> 250 <dd>
196 reference to the parent object 251 reference to the parent object
197 </dd> 252 </dd>
198 </dl><a NAME="MqttClient.__connectTimeout" ID="MqttClient.__connectTimeout"></a> 253 </dl>
254 <a NAME="MqttClient.__connectTimeout" ID="MqttClient.__connectTimeout"></a>
199 <h4>MqttClient.__connectTimeout</h4> 255 <h4>MqttClient.__connectTimeout</h4>
200 <b>__connectTimeout</b>(<i></i>) 256 <b>__connectTimeout</b>(<i></i>)
257
201 <p> 258 <p>
202 Private slot handling a failed connection attempt. 259 Private slot handling a failed connection attempt.
203 </p><a NAME="MqttClient.__initCallbacks" ID="MqttClient.__initCallbacks"></a> 260 </p>
261 <a NAME="MqttClient.__initCallbacks" ID="MqttClient.__initCallbacks"></a>
204 <h4>MqttClient.__initCallbacks</h4> 262 <h4>MqttClient.__initCallbacks</h4>
205 <b>__initCallbacks</b>(<i></i>) 263 <b>__initCallbacks</b>(<i></i>)
264
206 <p> 265 <p>
207 Private method to initialize the MQTT callback methods. 266 Private method to initialize the MQTT callback methods.
208 </p><a NAME="MqttClient.clearLastWill" ID="MqttClient.clearLastWill"></a> 267 </p>
268 <a NAME="MqttClient.clearLastWill" ID="MqttClient.clearLastWill"></a>
209 <h4>MqttClient.clearLastWill</h4> 269 <h4>MqttClient.clearLastWill</h4>
210 <b>clearLastWill</b>(<i></i>) 270 <b>clearLastWill</b>(<i></i>)
271
211 <p> 272 <p>
212 Public method to remove a will that was previously configured with 273 Public method to remove a will that was previously configured with
213 setLastWill(). 274 setLastWill().
214 </p><a NAME="MqttClient.connectToServer" ID="MqttClient.connectToServer"></a> 275 </p>
276 <a NAME="MqttClient.connectToServer" ID="MqttClient.connectToServer"></a>
215 <h4>MqttClient.connectToServer</h4> 277 <h4>MqttClient.connectToServer</h4>
216 <b>connectToServer</b>(<i>host, port=1883, keepalive=60, bindAddress="", reinit=True</i>) 278 <b>connectToServer</b>(<i>host, port=1883, keepalive=60, bindAddress="", reinit=True</i>)
279
217 <p> 280 <p>
218 Public method to connect to a remote MQTT broker. 281 Public method to connect to a remote MQTT broker.
219 </p><dl> 282 </p>
283 <dl>
284
220 <dt><i>host</i> (str)</dt> 285 <dt><i>host</i> (str)</dt>
221 <dd> 286 <dd>
222 host name or IP address of the remote broker 287 host name or IP address of the remote broker
223 </dd><dt><i>port</i> (int)</dt> 288 </dd>
289 <dt><i>port</i> (int)</dt>
224 <dd> 290 <dd>
225 network port of the server host to connect to (default: 291 network port of the server host to connect to (default:
226 1883, using TLS: 8883) 292 1883, using TLS: 8883)
227 </dd><dt><i>keepalive</i> (int)</dt> 293 </dd>
294 <dt><i>keepalive</i> (int)</dt>
228 <dd> 295 <dd>
229 maximum period in seconds allowed between 296 maximum period in seconds allowed between
230 communications with the broker 297 communications with the broker
231 </dd><dt><i>bindAddress</i> (str)</dt> 298 </dd>
299 <dt><i>bindAddress</i> (str)</dt>
232 <dd> 300 <dd>
233 IP address of a local network interface to bind 301 IP address of a local network interface to bind
234 this client to 302 this client to
235 </dd><dt><i>reinit</i> (bool)</dt> 303 </dd>
304 <dt><i>reinit</i> (bool)</dt>
236 <dd> 305 <dd>
237 flag indicating to reinitialize the MQTT client before 306 flag indicating to reinitialize the MQTT client before
238 trying to connect with the given parameters 307 trying to connect with the given parameters
239 </dd> 308 </dd>
240 </dl><a NAME="MqttClient.connectToServerWithOptions" ID="MqttClient.connectToServerWithOptions"></a> 309 </dl>
310 <a NAME="MqttClient.connectToServerWithOptions" ID="MqttClient.connectToServerWithOptions"></a>
241 <h4>MqttClient.connectToServerWithOptions</h4> 311 <h4>MqttClient.connectToServerWithOptions</h4>
242 <b>connectToServerWithOptions</b>(<i>host, port=1883, bindAddress="", options=None</i>) 312 <b>connectToServerWithOptions</b>(<i>host, port=1883, bindAddress="", options=None</i>)
313
243 <p> 314 <p>
244 Public method to connect to a remote MQTT broker. 315 Public method to connect to a remote MQTT broker.
245 </p><dl> 316 </p>
317 <dl>
318
246 <dt><i>host</i> (str)</dt> 319 <dt><i>host</i> (str)</dt>
247 <dd> 320 <dd>
248 host name or IP address of the remote broker 321 host name or IP address of the remote broker
249 </dd><dt><i>port</i> (int)</dt> 322 </dd>
323 <dt><i>port</i> (int)</dt>
250 <dd> 324 <dd>
251 network port of the server host to connect to (default: 325 network port of the server host to connect to (default:
252 1883, using TLS: 8883) 326 1883, using TLS: 8883)
253 </dd><dt><i>bindAddress</i> (str)</dt> 327 </dd>
328 <dt><i>bindAddress</i> (str)</dt>
254 <dd> 329 <dd>
255 IP address of a local network interface to bind 330 IP address of a local network interface to bind
256 this client to 331 this client to
257 </dd><dt><i>options</i> (dict)</dt> 332 </dd>
333 <dt><i>options</i> (dict)</dt>
258 <dd> 334 <dd>
259 dictionary containing the connection options. This 335 dictionary containing the connection options. This
260 dictionary should contain the keys "ClientId", "Keepalive", 336 dictionary should contain the keys "ClientId", "Keepalive",
261 "CleanSession", "Username", "Password", "WillTopic", "WillMessage", 337 "CleanSession", "Username", "Password", "WillTopic", "WillMessage",
262 "WillQos", "WillRetain", "TlsEnable", "TlsCaCert", "TlsClientCert", 338 "WillQos", "WillRetain", "TlsEnable", "TlsCaCert", "TlsClientCert",
263 "TlsClientKey", "ConnectionTimeout" 339 "TlsClientKey", "ConnectionTimeout"
264 </dd> 340 </dd>
265 </dl><a NAME="MqttClient.defaultConnectionOptions" ID="MqttClient.defaultConnectionOptions"></a> 341 </dl>
342 <a NAME="MqttClient.defaultConnectionOptions" ID="MqttClient.defaultConnectionOptions"></a>
266 <h4>MqttClient.defaultConnectionOptions</h4> 343 <h4>MqttClient.defaultConnectionOptions</h4>
267 <b>defaultConnectionOptions</b>(<i></i>) 344 <b>defaultConnectionOptions</b>(<i></i>)
345
268 <p> 346 <p>
269 Public method to get a connection options dictionary with default 347 Public method to get a connection options dictionary with default
270 values. 348 values.
271 </p><dl> 349 </p>
350 <dl>
272 <dt>Returns:</dt> 351 <dt>Returns:</dt>
273 <dd> 352 <dd>
274 dictionary containing the default connection options. It has 353 dictionary containing the default connection options. It has
275 the keys "ClientId", "Keepalive", "CleanSession", "Username", 354 the keys "ClientId", "Keepalive", "CleanSession", "Username",
276 "Password", "WillTopic", "WillMessage", "WillQos", "WillRetain", 355 "Password", "WillTopic", "WillMessage", "WillQos", "WillRetain",
277 "TlsEnable", "TlsCaCert", "TlsClientCert", "TlsClientKey", 356 "TlsEnable", "TlsCaCert", "TlsClientCert", "TlsClientKey",
278 "ConnectionTimeout". 357 "ConnectionTimeout".
279 </dd> 358 </dd>
280 </dl><dl> 359 </dl>
360 <dl>
281 <dt>Return Type:</dt> 361 <dt>Return Type:</dt>
282 <dd> 362 <dd>
283 dict 363 dict
284 </dd> 364 </dd>
285 </dl><a NAME="MqttClient.disconnectFromServer" ID="MqttClient.disconnectFromServer"></a> 365 </dl>
366 <a NAME="MqttClient.disconnectFromServer" ID="MqttClient.disconnectFromServer"></a>
286 <h4>MqttClient.disconnectFromServer</h4> 367 <h4>MqttClient.disconnectFromServer</h4>
287 <b>disconnectFromServer</b>(<i></i>) 368 <b>disconnectFromServer</b>(<i></i>)
369
288 <p> 370 <p>
289 Public method to disconnect the client from the remote broker. 371 Public method to disconnect the client from the remote broker.
290 </p><a NAME="MqttClient.publish" ID="MqttClient.publish"></a> 372 </p>
373 <a NAME="MqttClient.publish" ID="MqttClient.publish"></a>
291 <h4>MqttClient.publish</h4> 374 <h4>MqttClient.publish</h4>
292 <b>publish</b>(<i>topic, payload=None, qos=0, retain=False</i>) 375 <b>publish</b>(<i>topic, payload=None, qos=0, retain=False</i>)
376
293 <p> 377 <p>
294 Public method to publish to a topic. 378 Public method to publish to a topic.
295 </p><dl> 379 </p>
380 <dl>
381
296 <dt><i>topic</i> (str)</dt> 382 <dt><i>topic</i> (str)</dt>
297 <dd> 383 <dd>
298 topic to publish to 384 topic to publish to
299 </dd><dt><i>payload</i> (str, bytes, int or float)</dt> 385 </dd>
386 <dt><i>payload</i> (str, bytes, int or float)</dt>
300 <dd> 387 <dd>
301 data to be published 388 data to be published
302 </dd><dt><i>qos</i> (int, one of 0, 1 or 2)</dt> 389 </dd>
390 <dt><i>qos</i> (int, one of 0, 1 or 2)</dt>
303 <dd> 391 <dd>
304 quality of service 392 quality of service
305 </dd><dt><i>retain</i> (bool)</dt> 393 </dd>
394 <dt><i>retain</i> (bool)</dt>
306 <dd> 395 <dd>
307 flag indicating to set as the "last known good"/retained 396 flag indicating to set as the "last known good"/retained
308 message for the topic 397 message for the topic
309 </dd> 398 </dd>
310 </dl><dl> 399 </dl>
400 <dl>
311 <dt>Returns:</dt> 401 <dt>Returns:</dt>
312 <dd> 402 <dd>
313 message info object 403 message info object
314 </dd> 404 </dd>
315 </dl><dl> 405 </dl>
406 <dl>
316 <dt>Return Type:</dt> 407 <dt>Return Type:</dt>
317 <dd> 408 <dd>
318 mqtt.MQTTMessageInfo 409 mqtt.MQTTMessageInfo
319 </dd> 410 </dd>
320 </dl><a NAME="MqttClient.reconnectToServer" ID="MqttClient.reconnectToServer"></a> 411 </dl>
412 <a NAME="MqttClient.reconnectToServer" ID="MqttClient.reconnectToServer"></a>
321 <h4>MqttClient.reconnectToServer</h4> 413 <h4>MqttClient.reconnectToServer</h4>
322 <b>reconnectToServer</b>(<i></i>) 414 <b>reconnectToServer</b>(<i></i>)
415
323 <p> 416 <p>
324 Public method to reconnect the client with the same parameters. 417 Public method to reconnect the client with the same parameters.
325 </p><a NAME="MqttClient.reinitialise" ID="MqttClient.reinitialise"></a> 418 </p>
419 <a NAME="MqttClient.reinitialise" ID="MqttClient.reinitialise"></a>
326 <h4>MqttClient.reinitialise</h4> 420 <h4>MqttClient.reinitialise</h4>
327 <b>reinitialise</b>(<i>clientId="", cleanSession=True, userdata=None</i>) 421 <b>reinitialise</b>(<i>clientId="", cleanSession=True, userdata=None</i>)
422
328 <p> 423 <p>
329 Public method to reinitialize the client with given data. 424 Public method to reinitialize the client with given data.
330 </p><dl> 425 </p>
426 <dl>
427
331 <dt><i>clientId</i> (str)</dt> 428 <dt><i>clientId</i> (str)</dt>
332 <dd> 429 <dd>
333 ID to be used for the client 430 ID to be used for the client
334 </dd><dt><i>cleanSession</i> (bool)</dt> 431 </dd>
432 <dt><i>cleanSession</i> (bool)</dt>
335 <dd> 433 <dd>
336 flag indicating to start a clean session 434 flag indicating to start a clean session
337 </dd><dt><i>userdata</i> (any)</dt> 435 </dd>
436 <dt><i>userdata</i> (any)</dt>
338 <dd> 437 <dd>
339 user data 438 user data
340 </dd> 439 </dd>
341 </dl><a NAME="MqttClient.setConnectionTimeout" ID="MqttClient.setConnectionTimeout"></a> 440 </dl>
441 <a NAME="MqttClient.setConnectionTimeout" ID="MqttClient.setConnectionTimeout"></a>
342 <h4>MqttClient.setConnectionTimeout</h4> 442 <h4>MqttClient.setConnectionTimeout</h4>
343 <b>setConnectionTimeout</b>(<i>timeout</i>) 443 <b>setConnectionTimeout</b>(<i>timeout</i>)
444
344 <p> 445 <p>
345 Public method to set the connection timeout value. 446 Public method to set the connection timeout value.
346 </p><dl> 447 </p>
448 <dl>
449
347 <dt><i>timeout</i> (int)</dt> 450 <dt><i>timeout</i> (int)</dt>
348 <dd> 451 <dd>
349 timeout value to be set in seconds 452 timeout value to be set in seconds
350 </dd> 453 </dd>
351 </dl><a NAME="MqttClient.setLastWill" ID="MqttClient.setLastWill"></a> 454 </dl>
455 <a NAME="MqttClient.setLastWill" ID="MqttClient.setLastWill"></a>
352 <h4>MqttClient.setLastWill</h4> 456 <h4>MqttClient.setLastWill</h4>
353 <b>setLastWill</b>(<i>topic, payload=None, qos=0, retain=False</i>) 457 <b>setLastWill</b>(<i>topic, payload=None, qos=0, retain=False</i>)
458
354 <p> 459 <p>
355 Public method to set the last will of the client. 460 Public method to set the last will of the client.
356 </p><dl> 461 </p>
462 <dl>
463
357 <dt><i>topic</i> (str)</dt> 464 <dt><i>topic</i> (str)</dt>
358 <dd> 465 <dd>
359 topic the will message should be published on 466 topic the will message should be published on
360 </dd><dt><i>payload</i> (str, bytes, int or float)</dt> 467 </dd>
468 <dt><i>payload</i> (str, bytes, int or float)</dt>
361 <dd> 469 <dd>
362 message to send as a will 470 message to send as a will
363 </dd><dt><i>qos</i> (int, one of 0, 1 or 2)</dt> 471 </dd>
472 <dt><i>qos</i> (int, one of 0, 1 or 2)</dt>
364 <dd> 473 <dd>
365 quality of service level to use for the will 474 quality of service level to use for the will
366 </dd><dt><i>retain</i> (bool)</dt> 475 </dd>
476 <dt><i>retain</i> (bool)</dt>
367 <dd> 477 <dd>
368 flag indicating to set as the "last known good"/retained 478 flag indicating to set as the "last known good"/retained
369 message for the will topic 479 message for the will topic
370 </dd> 480 </dd>
371 </dl><a NAME="MqttClient.setMaxInflightMessages" ID="MqttClient.setMaxInflightMessages"></a> 481 </dl>
482 <a NAME="MqttClient.setMaxInflightMessages" ID="MqttClient.setMaxInflightMessages"></a>
372 <h4>MqttClient.setMaxInflightMessages</h4> 483 <h4>MqttClient.setMaxInflightMessages</h4>
373 <b>setMaxInflightMessages</b>(<i>inflight=20</i>) 484 <b>setMaxInflightMessages</b>(<i>inflight=20</i>)
485
374 <p> 486 <p>
375 Public method to set the maximum number of messages with QoS > 0 that 487 Public method to set the maximum number of messages with QoS > 0 that
376 can be part way through their network flow at once. 488 can be part way through their network flow at once.
377 </p><dl> 489 </p>
490 <dl>
491
378 <dt><i>inflight</i> (int)</dt> 492 <dt><i>inflight</i> (int)</dt>
379 <dd> 493 <dd>
380 maximum number of messages in flight 494 maximum number of messages in flight
381 </dd> 495 </dd>
382 </dl><a NAME="MqttClient.setMaxQueuedMessages" ID="MqttClient.setMaxQueuedMessages"></a> 496 </dl>
497 <a NAME="MqttClient.setMaxQueuedMessages" ID="MqttClient.setMaxQueuedMessages"></a>
383 <h4>MqttClient.setMaxQueuedMessages</h4> 498 <h4>MqttClient.setMaxQueuedMessages</h4>
384 <b>setMaxQueuedMessages</b>(<i>queueSize=0</i>) 499 <b>setMaxQueuedMessages</b>(<i>queueSize=0</i>)
500
385 <p> 501 <p>
386 Public method to set the maximum number of messages with QoS > 0 that 502 Public method to set the maximum number of messages with QoS > 0 that
387 can be pending in the outgoing message queue. 503 can be pending in the outgoing message queue.
388 </p><dl> 504 </p>
505 <dl>
506
389 <dt><i>queueSize</i> (int)</dt> 507 <dt><i>queueSize</i> (int)</dt>
390 <dd> 508 <dd>
391 maximum number of queued messages (0 = unlimited) 509 maximum number of queued messages (0 = unlimited)
392 </dd> 510 </dd>
393 </dl><a NAME="MqttClient.setTLS" ID="MqttClient.setTLS"></a> 511 </dl>
512 <a NAME="MqttClient.setTLS" ID="MqttClient.setTLS"></a>
394 <h4>MqttClient.setTLS</h4> 513 <h4>MqttClient.setTLS</h4>
395 <b>setTLS</b>(<i>caCerts=None, certFile=None, keyFile=None</i>) 514 <b>setTLS</b>(<i>caCerts=None, certFile=None, keyFile=None</i>)
515
396 <p> 516 <p>
397 Public method to enable secure connections and set the TLS parameters. 517 Public method to enable secure connections and set the TLS parameters.
398 </p><dl> 518 </p>
519 <dl>
520
399 <dt><i>caCerts</i> (str)</dt> 521 <dt><i>caCerts</i> (str)</dt>
400 <dd> 522 <dd>
401 path to the Certificate Authority certificates file 523 path to the Certificate Authority certificates file
402 </dd><dt><i>certFile</i> (str)</dt> 524 </dd>
525 <dt><i>certFile</i> (str)</dt>
403 <dd> 526 <dd>
404 PEM encoded client certificate file 527 PEM encoded client certificate file
405 </dd><dt><i>keyFile</i> (str)</dt> 528 </dd>
529 <dt><i>keyFile</i> (str)</dt>
406 <dd> 530 <dd>
407 PEM encoded private key file 531 PEM encoded private key file
408 </dd> 532 </dd>
409 </dl><dl> 533 </dl>
534 <dl>
410 <dt>Returns:</dt> 535 <dt>Returns:</dt>
411 <dd> 536 <dd>
412 tuple containing a success flag and the error string of the 537 tuple containing a success flag and the error string of the
413 paho-mqtt library 538 paho-mqtt library
414 </dd> 539 </dd>
415 </dl><dl> 540 </dl>
541 <dl>
416 <dt>Return Type:</dt> 542 <dt>Return Type:</dt>
417 <dd> 543 <dd>
418 tuple of (bool, str) 544 tuple of (bool, str)
419 </dd> 545 </dd>
420 </dl><a NAME="MqttClient.setUserCredentials" ID="MqttClient.setUserCredentials"></a> 546 </dl>
547 <a NAME="MqttClient.setUserCredentials" ID="MqttClient.setUserCredentials"></a>
421 <h4>MqttClient.setUserCredentials</h4> 548 <h4>MqttClient.setUserCredentials</h4>
422 <b>setUserCredentials</b>(<i>username, password=None</i>) 549 <b>setUserCredentials</b>(<i>username, password=None</i>)
550
423 <p> 551 <p>
424 Public method to set the user name and optionally the password. 552 Public method to set the user name and optionally the password.
425 </p><dl> 553 </p>
554 <dl>
555
426 <dt><i>username</i> (str)</dt> 556 <dt><i>username</i> (str)</dt>
427 <dd> 557 <dd>
428 user name to be set 558 user name to be set
429 </dd><dt><i>password</i> (str)</dt> 559 </dd>
560 <dt><i>password</i> (str)</dt>
430 <dd> 561 <dd>
431 optional password 562 optional password
432 </dd> 563 </dd>
433 </dl><a NAME="MqttClient.setUserData" ID="MqttClient.setUserData"></a> 564 </dl>
565 <a NAME="MqttClient.setUserData" ID="MqttClient.setUserData"></a>
434 <h4>MqttClient.setUserData</h4> 566 <h4>MqttClient.setUserData</h4>
435 <b>setUserData</b>(<i>userdata</i>) 567 <b>setUserData</b>(<i>userdata</i>)
568
436 <p> 569 <p>
437 Public method to set the user data. 570 Public method to set the user data.
438 </p><dl> 571 </p>
572 <dl>
573
439 <dt><i>userdata</i> (any)</dt> 574 <dt><i>userdata</i> (any)</dt>
440 <dd> 575 <dd>
441 user data 576 user data
442 </dd> 577 </dd>
443 </dl><a NAME="MqttClient.startLoop" ID="MqttClient.startLoop"></a> 578 </dl>
579 <a NAME="MqttClient.startLoop" ID="MqttClient.startLoop"></a>
444 <h4>MqttClient.startLoop</h4> 580 <h4>MqttClient.startLoop</h4>
445 <b>startLoop</b>(<i></i>) 581 <b>startLoop</b>(<i></i>)
582
446 <p> 583 <p>
447 Public method to start the MQTT client loop. 584 Public method to start the MQTT client loop.
448 </p><a NAME="MqttClient.stopLoop" ID="MqttClient.stopLoop"></a> 585 </p>
586 <a NAME="MqttClient.stopLoop" ID="MqttClient.stopLoop"></a>
449 <h4>MqttClient.stopLoop</h4> 587 <h4>MqttClient.stopLoop</h4>
450 <b>stopLoop</b>(<i></i>) 588 <b>stopLoop</b>(<i></i>)
589
451 <p> 590 <p>
452 Public method to stop the MQTT client loop. 591 Public method to stop the MQTT client loop.
453 </p><a NAME="MqttClient.subscribe" ID="MqttClient.subscribe"></a> 592 </p>
593 <a NAME="MqttClient.subscribe" ID="MqttClient.subscribe"></a>
454 <h4>MqttClient.subscribe</h4> 594 <h4>MqttClient.subscribe</h4>
455 <b>subscribe</b>(<i>topic, qos=0</i>) 595 <b>subscribe</b>(<i>topic, qos=0</i>)
596
456 <p> 597 <p>
457 Public method to subscribe to topics with quality of service. 598 Public method to subscribe to topics with quality of service.
458 </p><dl> 599 </p>
600 <dl>
601
459 <dt><i>topic</i> (str or tuple of (str, int) or list of tuple of (str, int))</dt> 602 <dt><i>topic</i> (str or tuple of (str, int) or list of tuple of (str, int))</dt>
460 <dd> 603 <dd>
461 single topic to subscribe to or a tuple with a topic 604 single topic to subscribe to or a tuple with a topic
462 and a QoS or a list of tuples with a topic and a QoS each 605 and a QoS or a list of tuples with a topic and a QoS each
463 </dd><dt><i>qos</i> (int, one of 0, 1 or 2)</dt> 606 </dd>
607 <dt><i>qos</i> (int, one of 0, 1 or 2)</dt>
464 <dd> 608 <dd>
465 quality of service 609 quality of service
466 </dd> 610 </dd>
467 </dl><dl> 611 </dl>
612 <dl>
468 <dt>Returns:</dt> 613 <dt>Returns:</dt>
469 <dd> 614 <dd>
470 tuple containing the result code and the message ID 615 tuple containing the result code and the message ID
471 </dd> 616 </dd>
472 </dl><dl> 617 </dl>
618 <dl>
473 <dt>Return Type:</dt> 619 <dt>Return Type:</dt>
474 <dd> 620 <dd>
475 tuple of (int, int) 621 tuple of (int, int)
476 </dd> 622 </dd>
477 </dl><a NAME="MqttClient.unsubscribe" ID="MqttClient.unsubscribe"></a> 623 </dl>
624 <a NAME="MqttClient.unsubscribe" ID="MqttClient.unsubscribe"></a>
478 <h4>MqttClient.unsubscribe</h4> 625 <h4>MqttClient.unsubscribe</h4>
479 <b>unsubscribe</b>(<i>topic</i>) 626 <b>unsubscribe</b>(<i>topic</i>)
627
480 <p> 628 <p>
481 Public method to unsubscribe topics. 629 Public method to unsubscribe topics.
482 </p><dl> 630 </p>
631 <dl>
632
483 <dt><i>topic</i> (str or list of str)</dt> 633 <dt><i>topic</i> (str or list of str)</dt>
484 <dd> 634 <dd>
485 topic or list of topics to unsubscribe 635 topic or list of topics to unsubscribe
486 </dd> 636 </dd>
487 </dl><dl> 637 </dl>
638 <dl>
488 <dt>Returns:</dt> 639 <dt>Returns:</dt>
489 <dd> 640 <dd>
490 tuple containing the result code and the message ID 641 tuple containing the result code and the message ID
491 </dd> 642 </dd>
492 </dl><dl> 643 </dl>
644 <dl>
493 <dt>Return Type:</dt> 645 <dt>Return Type:</dt>
494 <dd> 646 <dd>
495 tuple of (int, int) 647 tuple of (int, int)
496 </dd> 648 </dd>
497 </dl> 649 </dl>
498 <div align="right"><a href="#top">Up</a></div> 650 <div align="right"><a href="#top">Up</a></div>
499 <hr /><hr /> 651 <hr />
652 <hr />
500 <a NAME="mqttConnackMessage" ID="mqttConnackMessage"></a> 653 <a NAME="mqttConnackMessage" ID="mqttConnackMessage"></a>
501 <h2>mqttConnackMessage</h2> 654 <h2>mqttConnackMessage</h2>
502 <b>mqttConnackMessage</b>(<i>connackCode</i>) 655 <b>mqttConnackMessage</b>(<i>connackCode</i>)
656
503 <p> 657 <p>
504 Module function to get the string associated with a CONNACK result. 658 Module function to get the string associated with a CONNACK result.
505 </p><dl> 659 </p>
660 <dl>
661
506 <dt><i>connackCode</i> (int)</dt> 662 <dt><i>connackCode</i> (int)</dt>
507 <dd> 663 <dd>
508 result code of the connection request 664 result code of the connection request
509 </dd> 665 </dd>
510 </dl><dl> 666 </dl>
667 <dl>
511 <dt>Returns:</dt> 668 <dt>Returns:</dt>
512 <dd> 669 <dd>
513 textual representation for the result code 670 textual representation for the result code
514 </dd> 671 </dd>
515 </dl><dl> 672 </dl>
673 <dl>
516 <dt>Return Type:</dt> 674 <dt>Return Type:</dt>
517 <dd> 675 <dd>
518 str 676 str
519 </dd> 677 </dd>
520 </dl> 678 </dl>
521 <div align="right"><a href="#top">Up</a></div> 679 <div align="right"><a href="#top">Up</a></div>
522 <hr /><hr /> 680 <hr />
681 <hr />
523 <a NAME="mqttErrorMessage" ID="mqttErrorMessage"></a> 682 <a NAME="mqttErrorMessage" ID="mqttErrorMessage"></a>
524 <h2>mqttErrorMessage</h2> 683 <h2>mqttErrorMessage</h2>
525 <b>mqttErrorMessage</b>(<i>mqttErrno</i>) 684 <b>mqttErrorMessage</b>(<i>mqttErrno</i>)
685
526 <p> 686 <p>
527 Module function to get the error string associated with an MQTT error 687 Module function to get the error string associated with an MQTT error
528 number. 688 number.
529 </p><dl> 689 </p>
690 <dl>
691
530 <dt><i>mqttErrno</i> (int)</dt> 692 <dt><i>mqttErrno</i> (int)</dt>
531 <dd> 693 <dd>
532 result code of a MQTT request 694 result code of a MQTT request
533 </dd> 695 </dd>
534 </dl><dl> 696 </dl>
697 <dl>
535 <dt>Returns:</dt> 698 <dt>Returns:</dt>
536 <dd> 699 <dd>
537 textual representation of the result code 700 textual representation of the result code
538 </dd> 701 </dd>
539 </dl><dl> 702 </dl>
703 <dl>
540 <dt>Return Type:</dt> 704 <dt>Return Type:</dt>
541 <dd> 705 <dd>
542 str 706 str
543 </dd> 707 </dd>
544 </dl> 708 </dl>
545 <div align="right"><a href="#top">Up</a></div> 709 <div align="right"><a href="#top">Up</a></div>
546 <hr /><hr /> 710 <hr />
711 <hr />
547 <a NAME="mqttLogLevelString" ID="mqttLogLevelString"></a> 712 <a NAME="mqttLogLevelString" ID="mqttLogLevelString"></a>
548 <h2>mqttLogLevelString</h2> 713 <h2>mqttLogLevelString</h2>
549 <b>mqttLogLevelString</b>(<i>mqttLogLevel, isMqttLogLevel=True</i>) 714 <b>mqttLogLevelString</b>(<i>mqttLogLevel, isMqttLogLevel=True</i>)
715
550 <p> 716 <p>
551 Module function to get the log level string associated with a log level. 717 Module function to get the log level string associated with a log level.
552 </p><dl> 718 </p>
719 <dl>
720
553 <dt><i>mqttLogLevel</i> (int)</dt> 721 <dt><i>mqttLogLevel</i> (int)</dt>
554 <dd> 722 <dd>
555 log level of the paho-mqtt client 723 log level of the paho-mqtt client
556 </dd><dt><i>isMqttLogLevel</i> (bool)</dt> 724 </dd>
725 <dt><i>isMqttLogLevel</i> (bool)</dt>
557 <dd> 726 <dd>
558 flag indicating a MQTT log level is given (if 727 flag indicating a MQTT log level is given (if
559 False it is the MqttClient variant, i.e. Debug being lowest) 728 False it is the MqttClient variant, i.e. Debug being lowest)
560 </dd> 729 </dd>
561 </dl><dl> 730 </dl>
731 <dl>
562 <dt>Returns:</dt> 732 <dt>Returns:</dt>
563 <dd> 733 <dd>
564 textual representation of the log level 734 textual representation of the log level
565 </dd> 735 </dd>
566 </dl><dl> 736 </dl>
737 <dl>
567 <dt>Return Type:</dt> 738 <dt>Return Type:</dt>
568 <dd> 739 <dd>
569 str 740 str
570 </dd> 741 </dd>
571 </dl> 742 </dl>

eric ide

mercurial