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

changeset 37
8bc357057af3
parent 12
e0175cb7c5d5
child 58
6c84ba9a9fcd
equal deleted inserted replaced
36:f8ff464db1f9 37:8bc357057af3
36 </table> 36 </table>
37 <h3>Functions</h3> 37 <h3>Functions</h3>
38 <table> 38 <table>
39 <tr> 39 <tr>
40 <td><a href="#mqttConnackMessage">mqttConnackMessage</a></td> 40 <td><a href="#mqttConnackMessage">mqttConnackMessage</a></td>
41 <td>Public method to get the string associated with a CONNACK result.</td> 41 <td>Module function to get the string associated with a CONNACK result.</td>
42 </tr><tr> 42 </tr><tr>
43 <td><a href="#mqttErrorMessage">mqttErrorMessage</a></td> 43 <td><a href="#mqttErrorMessage">mqttErrorMessage</a></td>
44 <td>Public method to get the error string associated with an MQTT error number.</td> 44 <td>Module function to get the error string associated with an MQTT error number.</td>
45 </tr><tr>
46 <td><a href="#mqttLogLevelString">mqttLogLevelString</a></td>
47 <td>Module function to get the log level string associated with a log level.</td>
45 </tr> 48 </tr>
46 </table> 49 </table>
47 <hr /><hr /> 50 <hr /><hr />
48 <a NAME="MqttClient" ID="MqttClient"></a> 51 <a NAME="MqttClient" ID="MqttClient"></a>
49 <h2>MqttClient</h2> 52 <h2>MqttClient</h2>
57 broker 60 broker
58 </dd><dt>onDisconnected(rc)</dt> 61 </dd><dt>onDisconnected(rc)</dt>
59 <dd> 62 <dd>
60 emitted after the client has disconnected from 63 emitted after the client has disconnected from
61 the broker 64 the broker
65 </dd><dt>onLog(level, message)</dt>
66 <dd>
67 emitted to send client log data
62 </dd><dt>onMessage(topic, payload, qos, retain)</dt> 68 </dd><dt>onMessage(topic, payload, qos, retain)</dt>
63 <dd> 69 <dd>
64 emitted after a message has 70 emitted after a message has
65 been received by the client 71 been received by the client
66 </dd><dt>onPublish(mid)</dt> 72 </dd><dt>onPublish(mid)</dt>
78 </dl> 84 </dl>
79 <h3>Derived from</h3> 85 <h3>Derived from</h3>
80 QObject 86 QObject
81 <h3>Class Attributes</h3> 87 <h3>Class Attributes</h3>
82 <table> 88 <table>
83 <tr><td>None</td></tr> 89 <tr><td>DefaultConnectTimeout</td></tr><tr><td>LogDebug</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>
84 </table> 90 </table>
85 <h3>Class Methods</h3> 91 <h3>Class Methods</h3>
86 <table> 92 <table>
87 <tr><td>None</td></tr> 93 <tr><td>None</td></tr>
88 </table> 94 </table>
90 <table> 96 <table>
91 <tr> 97 <tr>
92 <td><a href="#MqttClient.__init__">MqttClient</a></td> 98 <td><a href="#MqttClient.__init__">MqttClient</a></td>
93 <td>Constructor</td> 99 <td>Constructor</td>
94 </tr><tr> 100 </tr><tr>
101 <td><a href="#MqttClient.__connectTimeout">__connectTimeout</a></td>
102 <td>Privat slot handling a failed connection attempt.</td>
103 </tr><tr>
95 <td><a href="#MqttClient.__initCallbacks">__initCallbacks</a></td> 104 <td><a href="#MqttClient.__initCallbacks">__initCallbacks</a></td>
96 <td>Private method to initialize the MQTT callback methods.</td> 105 <td>Private method to initialize the MQTT callback methods.</td>
97 </tr><tr> 106 </tr><tr>
107 <td><a href="#MqttClient.clearLastWill">clearLastWill</a></td>
108 <td>Public method to remove a will that was previously configured with setLastWill().</td>
109 </tr><tr>
98 <td><a href="#MqttClient.connectToServer">connectToServer</a></td> 110 <td><a href="#MqttClient.connectToServer">connectToServer</a></td>
99 <td>Public method to connect to a remote MQTT broker.</td> 111 <td>Public method to connect to a remote MQTT broker.</td>
100 </tr><tr> 112 </tr><tr>
101 <td><a href="#MqttClient.connectToServerWithOptions">connectToServerWithOptions</a></td> 113 <td><a href="#MqttClient.connectToServerWithOptions">connectToServerWithOptions</a></td>
102 <td>Public method to connect to a remote MQTT broker.</td> 114 <td>Public method to connect to a remote MQTT broker.</td>
114 <td>Public method to reconnect the client with the same parameters.</td> 126 <td>Public method to reconnect the client with the same parameters.</td>
115 </tr><tr> 127 </tr><tr>
116 <td><a href="#MqttClient.reinitialise">reinitialise</a></td> 128 <td><a href="#MqttClient.reinitialise">reinitialise</a></td>
117 <td>Public method to reinitialize the client with given data.</td> 129 <td>Public method to reinitialize the client with given data.</td>
118 </tr><tr> 130 </tr><tr>
131 <td><a href="#MqttClient.setConnectionTimeout">setConnectionTimeout</a></td>
132 <td>Public method to set the connection timeout value.</td>
133 </tr><tr>
119 <td><a href="#MqttClient.setLastWill">setLastWill</a></td> 134 <td><a href="#MqttClient.setLastWill">setLastWill</a></td>
120 <td>Public method to set the last will of the client.</td> 135 <td>Public method to set the last will of the client.</td>
121 </tr><tr> 136 </tr><tr>
122 <td><a href="#MqttClient.setMaxInflightMessages">setMaxInflightMessages</a></td> 137 <td><a href="#MqttClient.setMaxInflightMessages">setMaxInflightMessages</a></td>
123 <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> 138 <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>
124 </tr><tr> 139 </tr><tr>
125 <td><a href="#MqttClient.setMaxQueuedMessages">setMaxQueuedMessages</a></td> 140 <td><a href="#MqttClient.setMaxQueuedMessages">setMaxQueuedMessages</a></td>
126 <td>Public method to set the maximum number of messages with QoS > 0 that can be pending in the outgoing message queue.</td> 141 <td>Public method to set the maximum number of messages with QoS > 0 that can be pending in the outgoing message queue.</td>
142 </tr><tr>
143 <td><a href="#MqttClient.setTLS">setTLS</a></td>
144 <td>Public method to enable secure connections and set the TLS parameters.</td>
127 </tr><tr> 145 </tr><tr>
128 <td><a href="#MqttClient.setUserCredentials">setUserCredentials</a></td> 146 <td><a href="#MqttClient.setUserCredentials">setUserCredentials</a></td>
129 <td>Public method to set the user name and optionally the password.</td> 147 <td>Public method to set the user name and optionally the password.</td>
130 </tr><tr> 148 </tr><tr>
131 <td><a href="#MqttClient.setUserData">setUserData</a></td> 149 <td><a href="#MqttClient.setUserData">setUserData</a></td>
171 transport to be used 189 transport to be used
172 </dd><dt><i>parent</i> (QObject)</dt> 190 </dd><dt><i>parent</i> (QObject)</dt>
173 <dd> 191 <dd>
174 reference to the parent object 192 reference to the parent object
175 </dd> 193 </dd>
176 </dl><a NAME="MqttClient.__initCallbacks" ID="MqttClient.__initCallbacks"></a> 194 </dl><a NAME="MqttClient.__connectTimeout" ID="MqttClient.__connectTimeout"></a>
195 <h4>MqttClient.__connectTimeout</h4>
196 <b>__connectTimeout</b>(<i></i>)
197 <p>
198 Privat slot handling a failed connection attempt.
199 </p><a NAME="MqttClient.__initCallbacks" ID="MqttClient.__initCallbacks"></a>
177 <h4>MqttClient.__initCallbacks</h4> 200 <h4>MqttClient.__initCallbacks</h4>
178 <b>__initCallbacks</b>(<i></i>) 201 <b>__initCallbacks</b>(<i></i>)
179 <p> 202 <p>
180 Private method to initialize the MQTT callback methods. 203 Private method to initialize the MQTT callback methods.
204 </p><a NAME="MqttClient.clearLastWill" ID="MqttClient.clearLastWill"></a>
205 <h4>MqttClient.clearLastWill</h4>
206 <b>clearLastWill</b>(<i></i>)
207 <p>
208 Public method to remove a will that was previously configured with
209 setLastWill().
181 </p><a NAME="MqttClient.connectToServer" ID="MqttClient.connectToServer"></a> 210 </p><a NAME="MqttClient.connectToServer" ID="MqttClient.connectToServer"></a>
182 <h4>MqttClient.connectToServer</h4> 211 <h4>MqttClient.connectToServer</h4>
183 <b>connectToServer</b>(<i>host, port=1883, keepalive=60, bindAddress=""</i>) 212 <b>connectToServer</b>(<i>host, port=1883, keepalive=60, bindAddress="", reinit=True</i>)
184 <p> 213 <p>
185 Public method to connect to a remote MQTT broker. 214 Public method to connect to a remote MQTT broker.
186 </p><dl> 215 </p><dl>
187 <dt><i>host</i> (str)</dt> 216 <dt><i>host</i> (str)</dt>
188 <dd> 217 <dd>
220 </dd><dt><i>options</i> (dict)</dt> 249 </dd><dt><i>options</i> (dict)</dt>
221 <dd> 250 <dd>
222 dictionary containing the connection options. This 251 dictionary containing the connection options. This
223 dictionary should contain the keys "ClientId", "Keepalive", 252 dictionary should contain the keys "ClientId", "Keepalive",
224 "CleanSession", "Username", "Password", "WillTopic", "WillMessage", 253 "CleanSession", "Username", "Password", "WillTopic", "WillMessage",
225 "WillQos", "WillRetain" 254 "WillQos", "WillRetain", "TlsEnable", "TlsCaCert", "TlsClientCert",
255 "TlsClientKey", "ConnectionTimeout"
226 </dd> 256 </dd>
227 </dl><a NAME="MqttClient.defaultConnectionOptions" ID="MqttClient.defaultConnectionOptions"></a> 257 </dl><a NAME="MqttClient.defaultConnectionOptions" ID="MqttClient.defaultConnectionOptions"></a>
228 <h4>MqttClient.defaultConnectionOptions</h4> 258 <h4>MqttClient.defaultConnectionOptions</h4>
229 <b>defaultConnectionOptions</b>(<i></i>) 259 <b>defaultConnectionOptions</b>(<i></i>)
230 <p> 260 <p>
233 </p><dl> 263 </p><dl>
234 <dt>Returns:</dt> 264 <dt>Returns:</dt>
235 <dd> 265 <dd>
236 dictionary containing the default connection options. It has 266 dictionary containing the default connection options. It has
237 the keys "ClientId", "Keepalive", "CleanSession", "Username", 267 the keys "ClientId", "Keepalive", "CleanSession", "Username",
238 "Password", "WillTopic", "WillMessage", "WillQos", "WillRetain" 268 "Password", "WillTopic", "WillMessage", "WillQos", "WillRetain",
269 "TlsEnable", "TlsCaCert", "TlsClientCert", "TlsClientKey",
270 "ConnectionTimeout".
239 </dd> 271 </dd>
240 </dl><dl> 272 </dl><dl>
241 <dt>Return Type:</dt> 273 <dt>Return Type:</dt>
242 <dd> 274 <dd>
243 dict 275 dict
296 flag indicating to start a clean session 328 flag indicating to start a clean session
297 </dd><dt><i>userdata</i> (any)</dt> 329 </dd><dt><i>userdata</i> (any)</dt>
298 <dd> 330 <dd>
299 user data 331 user data
300 </dd> 332 </dd>
333 </dl><a NAME="MqttClient.setConnectionTimeout" ID="MqttClient.setConnectionTimeout"></a>
334 <h4>MqttClient.setConnectionTimeout</h4>
335 <b>setConnectionTimeout</b>(<i>timeout</i>)
336 <p>
337 Public method to set the connection timeout value.
338 </p><dl>
339 <dt><i>timeout</i> (int)</dt>
340 <dd>
341 timeout value to be set in seconds
342 </dd>
301 </dl><a NAME="MqttClient.setLastWill" ID="MqttClient.setLastWill"></a> 343 </dl><a NAME="MqttClient.setLastWill" ID="MqttClient.setLastWill"></a>
302 <h4>MqttClient.setLastWill</h4> 344 <h4>MqttClient.setLastWill</h4>
303 <b>setLastWill</b>(<i>topic, payload=None, qos=0, retain=False</i>) 345 <b>setLastWill</b>(<i>topic, payload=None, qos=0, retain=False</i>)
304 <p> 346 <p>
305 Public method to set the last will of the client. 347 Public method to set the last will of the client.
337 can be pending in the outgoing message queue. 379 can be pending in the outgoing message queue.
338 </p><dl> 380 </p><dl>
339 <dt><i>queueSize</i> (int)</dt> 381 <dt><i>queueSize</i> (int)</dt>
340 <dd> 382 <dd>
341 maximum number of queued messages (0 = unlimited) 383 maximum number of queued messages (0 = unlimited)
384 </dd>
385 </dl><a NAME="MqttClient.setTLS" ID="MqttClient.setTLS"></a>
386 <h4>MqttClient.setTLS</h4>
387 <b>setTLS</b>(<i>caCerts=None, certFile=None, keyFile=None</i>)
388 <p>
389 Public method to enable secure connections and set the TLS parameters.
390 </p><dl>
391 <dt><i>caCerts</i> (str)</dt>
392 <dd>
393 path to the Certificate Authority certificates file
394 </dd><dt><i>certFile</i> (str)</dt>
395 <dd>
396 PEM encoded client certificate file
397 </dd><dt><i>keyFile</i> (str)</dt>
398 <dd>
399 PEM encoded private key file
400 </dd>
401 </dl><dl>
402 <dt>Returns:</dt>
403 <dd>
404 tuple containing a success flag and the error string of the
405 paho-mqtt library
406 </dd>
407 </dl><dl>
408 <dt>Return Type:</dt>
409 <dd>
410 tuple of (bool, str)
342 </dd> 411 </dd>
343 </dl><a NAME="MqttClient.setUserCredentials" ID="MqttClient.setUserCredentials"></a> 412 </dl><a NAME="MqttClient.setUserCredentials" ID="MqttClient.setUserCredentials"></a>
344 <h4>MqttClient.setUserCredentials</h4> 413 <h4>MqttClient.setUserCredentials</h4>
345 <b>setUserCredentials</b>(<i>username, password=None</i>) 414 <b>setUserCredentials</b>(<i>username, password=None</i>)
346 <p> 415 <p>
422 <hr /><hr /> 491 <hr /><hr />
423 <a NAME="mqttConnackMessage" ID="mqttConnackMessage"></a> 492 <a NAME="mqttConnackMessage" ID="mqttConnackMessage"></a>
424 <h2>mqttConnackMessage</h2> 493 <h2>mqttConnackMessage</h2>
425 <b>mqttConnackMessage</b>(<i>connackCode</i>) 494 <b>mqttConnackMessage</b>(<i>connackCode</i>)
426 <p> 495 <p>
427 Public method to get the string associated with a CONNACK result. 496 Module function to get the string associated with a CONNACK result.
428 </p><dl> 497 </p><dl>
429 <dt><i>connackCode</i> (int)</dt> 498 <dt><i>connackCode</i> (int)</dt>
430 <dd> 499 <dd>
431 result code of the connection request 500 result code of the connection request
432 </dd> 501 </dd>
445 <hr /><hr /> 514 <hr /><hr />
446 <a NAME="mqttErrorMessage" ID="mqttErrorMessage"></a> 515 <a NAME="mqttErrorMessage" ID="mqttErrorMessage"></a>
447 <h2>mqttErrorMessage</h2> 516 <h2>mqttErrorMessage</h2>
448 <b>mqttErrorMessage</b>(<i>mqttErrno</i>) 517 <b>mqttErrorMessage</b>(<i>mqttErrno</i>)
449 <p> 518 <p>
450 Public method to get the error string associated with an MQTT error 519 Module function to get the error string associated with an MQTT error
451 number. 520 number.
452 </p><dl> 521 </p><dl>
453 <dt><i>mqttErrno</i> (int)</dt> 522 <dt><i>mqttErrno</i> (int)</dt>
454 <dd> 523 <dd>
455 result code of a MQTT request 524 result code of a MQTT request
456 </dd> 525 </dd>
457 </dl><dl> 526 </dl><dl>
458 <dt>Returns:</dt> 527 <dt>Returns:</dt>
459 <dd> 528 <dd>
460 textual representation of the result code 529 textual representation of the result code
530 </dd>
531 </dl><dl>
532 <dt>Return Type:</dt>
533 <dd>
534 str
535 </dd>
536 </dl>
537 <div align="right"><a href="#top">Up</a></div>
538 <hr /><hr />
539 <a NAME="mqttLogLevelString" ID="mqttLogLevelString"></a>
540 <h2>mqttLogLevelString</h2>
541 <b>mqttLogLevelString</b>(<i>mqttLogLevel, isMqttLogLevel=True</i>)
542 <p>
543 Module function to get the log level string associated with a log level.
544 </p><dl>
545 <dt><i>mqttLogLevel</i> (int)</dt>
546 <dd>
547 log level of the paho-mqtt client
548 </dd><dt><i>isMqttLogLevel</i> (bool)</dt>
549 <dd>
550 flag indicating a MQTT log level is given (if
551 False it is the MqttClient variant, i.e. Debug being lowest)
552 </dd>
553 </dl><dl>
554 <dt>Returns:</dt>
555 <dd>
556 textual representation of the log level
461 </dd> 557 </dd>
462 </dl><dl> 558 </dl><dl>
463 <dt>Return Type:</dt> 559 <dt>Return Type:</dt>
464 <dd> 560 <dd>
465 str 561 str

eric ide

mercurial