Sat, 01 Sep 2018 20:18:11 +0200
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
2
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
3 | # Copyright (c) 2018 Detlev Offenbach <detlev@die-offenbachs.de> |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | Module implementing a PyQt wrapper around the paho MQTT client. |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | """ |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
10 | from __future__ import unicode_literals |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
11 | |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
12 | from PyQt5.QtCore import pyqtSignal, QObject, QCoreApplication |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
13 | |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
14 | import paho.mqtt.client as mqtt |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
15 | |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
16 | |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
17 | class MqttClient(QObject): |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
18 | """ |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
19 | Class implementing a PyQt wrapper around the paho MQTT client. |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
20 | |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
21 | @signal onConnect(flags, rc) emitted after the client has connected to the |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
22 | broker |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
23 | @signal onDisconnected(rc) emitted after the client has disconnected from |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
24 | the broker |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
25 | @signal onMessage(topic, payload, qos, retain) emitted after a message has |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
26 | been received by the client |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
27 | @signal onPublish(mid) emitted after a message has been published |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
28 | @signal onSubscribe(mid, grantedQos) emitted after the client has |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
29 | subscribed to some topics |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
30 | @signal onUnsubscribe(mid) emitted after the client has unsubscribed from |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
31 | some topics |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
32 | """ |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
33 | onConnect = pyqtSignal(dict, int) |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
34 | onDisconnected = pyqtSignal(int) |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
35 | onMessage = pyqtSignal(str, bytes, int, bool) |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
36 | onPublish = pyqtSignal(int) |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
37 | onSubscribe = pyqtSignal(int, tuple) |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
38 | onUnsubscribe = pyqtSignal(int) |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
39 | |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
40 | def __init__(self, clientId="", cleanSession=True, userdata=None, |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
41 | protocol=mqtt.MQTTv311, transport="tcp", parent=None): |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
42 | """ |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
43 | Constructor |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
44 | |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
45 | @param clientId ID to be used for the client |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
46 | @type str |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
47 | @param cleanSession flag indicating to start a clean session |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
48 | @type bool |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
49 | @param userdata user data |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
50 | @type any |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
51 | @param protocol version of the MQTT protocol to use |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
52 | @type int, one of mqtt.MQTTv31 or mqtt.MQTTv311 |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
53 | @param transport transport to be used |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
54 | @type str, one of "tcp" or "websockets" |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
55 | @param parent reference to the parent object |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
56 | @type QObject |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
57 | """ |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
58 | QObject.__init__(self, parent=parent) |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
59 | |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
60 | self.__loopStarted = False |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
61 | |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
62 | self.__mqttClient = mqtt.Client( |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
63 | client_id=clientId, clean_session=cleanSession, userdata=None, |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
64 | protocol=mqtt.MQTTv311, transport="tcp") |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
65 | |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
66 | self.__mqttClient.on_connect = \ |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
67 | lambda client, userdata, flags, rc: self.onConnect.emit( |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
68 | flags, rc) |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
69 | self.__mqttClient.on_disconnect = \ |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
70 | lambda client, userdata, rc: self.onDisconnected.emit(rc) |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
71 | self.__mqttClient.on_message = \ |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
72 | lambda client, userdata, message: self.onMessage.emit( |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
73 | message.topic, message.payload, message.qos, message.retain) |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
74 | self.__mqttClient.on_publish = \ |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
75 | lambda client, userdata, mid: self.onPublish.emit(mid) |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
76 | self.__mqttClient.on_subscribe = \ |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
77 | lambda client, userdata, mid, grantedQos: self.onSubscribe.emit( |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
78 | mid, grantedQos) |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
79 | self.__mqttClient.on_unsubscribe = \ |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
80 | lambda client, userdata, mid: self.onUnsubscribe.emit(mid) |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
81 | |
10
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
82 | def reinitialise(self, clientId="", cleanSession=True, userdata=None): |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
83 | """ |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
84 | Public method to reinitialize the client with given data. |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
85 | |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
86 | @param clientId ID to be used for the client |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
87 | @type str |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
88 | @param cleanSession flag indicating to start a clean session |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
89 | @type bool |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
90 | @param userdata user data |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
91 | @type any |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
92 | """ |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
93 | self.__mqttClient.reinitialise( |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
94 | client_id=clientId, clean_session=cleanSession, userdata=userdata) |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
95 | |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
96 | def setMaxInflightMessages(self, inflight=20): |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
97 | """ |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
98 | Public method to set the maximum number of messages with QoS > 0 that |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
99 | can be part way through their network flow at once. |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
100 | |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
101 | @param inflight maximum number of messages in flight |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
102 | @type int |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
103 | """ |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
104 | self.__mqttClient.max_inflight_messages_set(inflight) |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
105 | |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
106 | def setMaxQueuedMessages(self, queueSize=0): |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
107 | """ |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
108 | Public method to set the maximum number of messages with QoS > 0 that |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
109 | can be pending in the outgoing message queue. |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
110 | |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
111 | @param queueSize maximum number of queued messages (0 = unlimited) |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
112 | @type int |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
113 | """ |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
114 | self.__mqttClient.max_queued_messages_set(queueSize) |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
115 | |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
116 | def setUserCredentials(self, username, password=None): |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
117 | """ |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
118 | Public method to set the user name and optionally the password. |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
119 | |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
120 | @param username user name to be set |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
121 | @type str |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
122 | @param password optional password |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
123 | @type str |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
124 | """ |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
125 | self.__mqttClient.username_pw_set(username, password=password) |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
126 | |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
127 | def setUserData(self, userdata): |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
128 | """ |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
129 | Public method to set the user data. |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
130 | |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
131 | @param userdata user data |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
132 | @type any |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
133 | """ |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
134 | self.__mqttClient.user_data_set(userdata) |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
135 | |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
136 | def setLastWill(self, topic, payload=None, qos=0, retain=False): |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
137 | """ |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
138 | Public method to set the last will of the client. |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
139 | |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
140 | @param topic topic the will message should be published on |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
141 | @type str |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
142 | @param payload message to send as a will |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
143 | @type str, bytes, int or float |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
144 | @param qos quality of service level to use for the will |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
145 | @type int, one of 0, 1 or 2 |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
146 | @param retain flag indicating to set as the "last known good"/retained |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
147 | message for the will topic |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
148 | @type bool |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
149 | """ |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
150 | self.__mqttClient.will_set(topic, payload=payload, qos=qos, |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
151 | retain=retain) |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
152 | |
2
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
153 | def startLoop(self): |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
154 | """ |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
155 | Public method to start the MQTT client loop. |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
156 | """ |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
157 | self.__mqttClient.loop_start() |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
158 | self.__loopStarted = True |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
159 | |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
160 | def stopLoop(self): |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
161 | """ |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
162 | Public method to stop the MQTT client loop. |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
163 | """ |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
164 | self.__mqttClient.loop_stop() |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
165 | self.__loopStarted = False |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
166 | |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
167 | def connectToServer(self, host, port=1883, keepalive=60, bindAddress=""): |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
168 | """ |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
169 | Public method to connect to a remote MQTT broker. |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
170 | |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
171 | @param host host name or IP address of the remote broker |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
172 | @type str |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
173 | @param port network port of the server host to connect to (default: |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
174 | 1883, using TLS: 8883) |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
175 | @type int |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
176 | @param keepalive maximum period in seconds allowed between |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
177 | communications with the broker |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
178 | @type int |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
179 | @param bindAddress IP address of a local network interface to bind |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
180 | this client to |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
181 | @type str |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
182 | """ |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
183 | self.__mqttClient.connect_async( |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
184 | host, port=port, keepalive=keepalive, bind_address=bindAddress) |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
185 | |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
186 | if not self.__loopStarted: |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
187 | self.startLoop() |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
188 | |
10
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
189 | def connectToServerWithOptions(self, host, port=1883, bindAddress="", |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
190 | options=None): |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
191 | """ |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
192 | Public method to connect to a remote MQTT broker. |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
193 | |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
194 | @param host host name or IP address of the remote broker |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
195 | @type str |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
196 | @param port network port of the server host to connect to (default: |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
197 | 1883, using TLS: 8883) |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
198 | @type int |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
199 | @param bindAddress IP address of a local network interface to bind |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
200 | this client to |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
201 | @type str |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
202 | @param options dictionary containing the connection options. This |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
203 | dictionary should contain the keys "ClientId", "Keepalive", |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
204 | "CleanSession", "Username", "Password", "WillTopic", "WillMessage", |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
205 | "WillQos", "WillRetain" |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
206 | @type dict |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
207 | """ |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
208 | if options: |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
209 | parametersDict = self.defaultConnectionOptions() |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
210 | parametersDict.update(options) |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
211 | |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
212 | # step 1: reinitialize to set the client ID and clean session flag |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
213 | self.reinitialise( |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
214 | clientId=parametersDict["ClientId"], |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
215 | cleanSession=parametersDict["CleanSession"] |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
216 | ) |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
217 | |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
218 | # step 2: set username and password |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
219 | if parametersDict["Username"]: |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
220 | if parametersDict["Password"]: |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
221 | self.setUserCredentials(parametersDict["Username"], |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
222 | parametersDict["Password"]) |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
223 | else: |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
224 | self.setUserCredentials(parametersDict["Username"]) |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
225 | |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
226 | # step 3: set last will data |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
227 | if parametersDict["WillTopic"]: |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
228 | if parametersDict["WillMessage"]: |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
229 | willMessage = parametersDict["WillMessage"] |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
230 | else: |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
231 | # empty message to clear the will |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
232 | willMessage = None |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
233 | self.setLastWill(parametersDict["WillTopic"], |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
234 | willMessage, |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
235 | parametersDict["WillQos"], |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
236 | parametersDict["WillRetain"]) |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
237 | |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
238 | # step 4: connect to server |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
239 | self.connectToServer(host, port=port, |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
240 | keepalive=parametersDict["Keepalive"]) |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
241 | else: |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
242 | keepalive = self.defaultConnectionOptions["Keepalive"] |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
243 | self.connectToServer(host, port=port, keepalive=keepalive, |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
244 | bindAddress=bindAddress) |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
245 | |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
246 | def defaultConnectionOptions(self): |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
247 | """ |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
248 | Public method to get a connection options dictionary with default |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
249 | values. |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
250 | |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
251 | @return dictionary containing the default connection options. It has |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
252 | the keys "ClientId", "Keepalive", "CleanSession", "Username", |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
253 | "Password", "WillTopic", "WillMessage", "WillQos", "WillRetain" |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
254 | @rtype dict |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
255 | """ |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
256 | return { |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
257 | "ClientId": "ERIC6_MQTT_MONITOR_CLIENT", |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
258 | "Keepalive": 60, |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
259 | "CleanSession": True, |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
260 | "Username": "", |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
261 | "Password": "", |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
262 | "WillTopic": "", |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
263 | "WillMessage": "", |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
264 | "WillQos": 0, |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
265 | "WillRetain": False, |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
266 | } |
7e0e921dc7ea
Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9
diff
changeset
|
267 | |
2
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
268 | def reconnectToServer(self): |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
269 | """ |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
270 | Public method to reconnect the client with the same parameters. |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
271 | """ |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
272 | self.__mqttClient.reconnect() |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
273 | |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
274 | if not self.__loopStarted: |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
275 | self.startLoop() |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
276 | |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
277 | def disconnectFromServer(self): |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
278 | """ |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
279 | Public method to disconnect the client from the remote broker. |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
280 | """ |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
281 | self.__mqttClient.disconnect() |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
282 | |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
283 | def subscribe(self, topic, qos=0): |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
284 | """ |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
285 | Public method to subscribe to topics with quality of service. |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
286 | |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
287 | @param topic single topic to subscribe to or a tuple with a topic |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
288 | and a QoS or a list of tuples with a topic and a QoS each |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
289 | @type str or tuple of (str, int) or list of tuple of (str, int) |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
290 | @param qos quality of service |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
291 | @type int, one of 0, 1 or 2 |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
292 | @return tuple containing the result code and the message ID |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
293 | @rtype tuple of (int, int) |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
294 | """ |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
295 | return self.__mqttClient.subscribe(topic, qos=qos) |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
296 | |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
297 | def unsubscribe(self, topic): |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
298 | """ |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
299 | Public method to unsubscribe topics. |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
300 | |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
301 | @param topic topic or list of topics to unsubscribe |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
302 | @type str or list of str |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
303 | @return tuple containing the result code and the message ID |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
304 | @rtype tuple of (int, int) |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
305 | """ |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
306 | return self.__mqttClient.unsubscribe(topic) |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
307 | |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
308 | def publish(self, topic, payload=None, qos=0, retain=False): |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
309 | """ |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
310 | Public method to publish to a topic. |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
311 | |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
312 | @param topic topic to publish to |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
313 | @type str |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
314 | @param payload data to be published |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
315 | @type str, bytes, int or float |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
316 | @param qos quality of service |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
317 | @type int, one of 0, 1 or 2 |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
318 | @param retain flag indicating to set as the "last known good"/retained |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
319 | message for the topic |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
320 | @type bool |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
321 | @return message info object |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
322 | @rtype mqtt.MQTTMessageInfo |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
323 | """ |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
324 | return self.__mqttClient.publish(topic, payload=payload, qos=qos, |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
325 | retain=retain) |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
326 | |
3
82845c0fd550
Fixed some code style issues and implemented the broker connect/disconnect group of the MqttMonitorWidget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2
diff
changeset
|
327 | |
2
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
328 | def mqttConnackMessage(connackCode): |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
329 | """ |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
330 | Public method to get the string associated with a CONNACK result. |
3
82845c0fd550
Fixed some code style issues and implemented the broker connect/disconnect group of the MqttMonitorWidget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2
diff
changeset
|
331 | |
82845c0fd550
Fixed some code style issues and implemented the broker connect/disconnect group of the MqttMonitorWidget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2
diff
changeset
|
332 | @param connackCode result code of the connection request |
82845c0fd550
Fixed some code style issues and implemented the broker connect/disconnect group of the MqttMonitorWidget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2
diff
changeset
|
333 | @type int |
82845c0fd550
Fixed some code style issues and implemented the broker connect/disconnect group of the MqttMonitorWidget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2
diff
changeset
|
334 | @return textual representation for the result code |
82845c0fd550
Fixed some code style issues and implemented the broker connect/disconnect group of the MqttMonitorWidget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2
diff
changeset
|
335 | @rtype str |
2
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
336 | """ |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
337 | if connackCode == mqtt.CONNACK_ACCEPTED: |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
338 | return QCoreApplication.translate( |
3
82845c0fd550
Fixed some code style issues and implemented the broker connect/disconnect group of the MqttMonitorWidget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2
diff
changeset
|
339 | "MqttConnackMessage", |
2
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
340 | "Connection Accepted.") |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
341 | elif connackCode == mqtt.CONNACK_REFUSED_PROTOCOL_VERSION: |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
342 | return QCoreApplication.translate( |
3
82845c0fd550
Fixed some code style issues and implemented the broker connect/disconnect group of the MqttMonitorWidget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2
diff
changeset
|
343 | "MqttConnackMessage", |
2
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
344 | "Connection Refused: unacceptable protocol version.") |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
345 | elif connackCode == mqtt.CONNACK_REFUSED_IDENTIFIER_REJECTED: |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
346 | return QCoreApplication.translate( |
3
82845c0fd550
Fixed some code style issues and implemented the broker connect/disconnect group of the MqttMonitorWidget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2
diff
changeset
|
347 | "MqttConnackMessage", |
2
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
348 | "Connection Refused: identifier rejected.") |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
349 | elif connackCode == mqtt.CONNACK_REFUSED_SERVER_UNAVAILABLE: |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
350 | return QCoreApplication.translate( |
3
82845c0fd550
Fixed some code style issues and implemented the broker connect/disconnect group of the MqttMonitorWidget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2
diff
changeset
|
351 | "MqttConnackMessage", |
2
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
352 | "Connection Refused: broker unavailable.") |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
353 | elif connackCode == mqtt.CONNACK_REFUSED_BAD_USERNAME_PASSWORD: |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
354 | return QCoreApplication.translate( |
3
82845c0fd550
Fixed some code style issues and implemented the broker connect/disconnect group of the MqttMonitorWidget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2
diff
changeset
|
355 | "MqttConnackMessage", |
2
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
356 | "Connection Refused: bad user name or password.") |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
357 | elif connackCode == mqtt.CONNACK_REFUSED_NOT_AUTHORIZED: |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
358 | return QCoreApplication.translate( |
3
82845c0fd550
Fixed some code style issues and implemented the broker connect/disconnect group of the MqttMonitorWidget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2
diff
changeset
|
359 | "MqttConnackMessage", |
2
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
360 | "Connection Refused: not authorised.") |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
361 | else: |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
362 | return QCoreApplication.translate( |
3
82845c0fd550
Fixed some code style issues and implemented the broker connect/disconnect group of the MqttMonitorWidget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2
diff
changeset
|
363 | "MqttConnackMessage", |
2
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
364 | "Connection Refused: unknown reason.") |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
365 | |
3
82845c0fd550
Fixed some code style issues and implemented the broker connect/disconnect group of the MqttMonitorWidget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2
diff
changeset
|
366 | |
9
f75a385e9127
MqttClient: fixed an issue in mqttErrorMessage() definition.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3
diff
changeset
|
367 | def mqttErrorMessage(mqttErrno): |
2
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
368 | """ |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
369 | Public method to get the error string associated with an MQTT error |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
370 | number. |
3
82845c0fd550
Fixed some code style issues and implemented the broker connect/disconnect group of the MqttMonitorWidget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2
diff
changeset
|
371 | |
82845c0fd550
Fixed some code style issues and implemented the broker connect/disconnect group of the MqttMonitorWidget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2
diff
changeset
|
372 | @param mqttErrno result code of a MQTT request |
82845c0fd550
Fixed some code style issues and implemented the broker connect/disconnect group of the MqttMonitorWidget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2
diff
changeset
|
373 | @type int |
82845c0fd550
Fixed some code style issues and implemented the broker connect/disconnect group of the MqttMonitorWidget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2
diff
changeset
|
374 | @return textual representation of the result code |
82845c0fd550
Fixed some code style issues and implemented the broker connect/disconnect group of the MqttMonitorWidget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2
diff
changeset
|
375 | @rtype str |
2
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
376 | """ |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
377 | if mqttErrno == mqtt.MQTT_ERR_SUCCESS: |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
378 | return QCoreApplication.translate( |
3
82845c0fd550
Fixed some code style issues and implemented the broker connect/disconnect group of the MqttMonitorWidget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2
diff
changeset
|
379 | "MqttErrorMessage", |
2
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
380 | "No error.") |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
381 | elif mqttErrno == mqtt.MQTT_ERR_NOMEM: |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
382 | return QCoreApplication.translate( |
3
82845c0fd550
Fixed some code style issues and implemented the broker connect/disconnect group of the MqttMonitorWidget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2
diff
changeset
|
383 | "MqttErrorMessage", |
2
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
384 | "Out of memory.") |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
385 | elif mqttErrno == mqtt.MQTT_ERR_PROTOCOL: |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
386 | return QCoreApplication.translate( |
3
82845c0fd550
Fixed some code style issues and implemented the broker connect/disconnect group of the MqttMonitorWidget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2
diff
changeset
|
387 | "MqttErrorMessage", |
2
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
388 | "A network protocol error occurred when communicating with" |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
389 | " the broker.") |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
390 | elif mqttErrno == mqtt.MQTT_ERR_INVAL: |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
391 | return QCoreApplication.translate( |
3
82845c0fd550
Fixed some code style issues and implemented the broker connect/disconnect group of the MqttMonitorWidget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2
diff
changeset
|
392 | "MqttErrorMessage", |
2
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
393 | "Invalid function arguments provided.") |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
394 | elif mqttErrno == mqtt.MQTT_ERR_NO_CONN: |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
395 | return QCoreApplication.translate( |
3
82845c0fd550
Fixed some code style issues and implemented the broker connect/disconnect group of the MqttMonitorWidget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2
diff
changeset
|
396 | "MqttErrorMessage", |
2
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
397 | "The client is not currently connected.") |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
398 | elif mqttErrno == mqtt.MQTT_ERR_CONN_REFUSED: |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
399 | return QCoreApplication.translate( |
3
82845c0fd550
Fixed some code style issues and implemented the broker connect/disconnect group of the MqttMonitorWidget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2
diff
changeset
|
400 | "MqttErrorMessage", |
2
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
401 | "The connection was refused.") |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
402 | elif mqttErrno == mqtt.MQTT_ERR_NOT_FOUND: |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
403 | return QCoreApplication.translate( |
3
82845c0fd550
Fixed some code style issues and implemented the broker connect/disconnect group of the MqttMonitorWidget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2
diff
changeset
|
404 | "MqttErrorMessage", |
2
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
405 | "Message not found (internal error).") |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
406 | elif mqttErrno == mqtt.MQTT_ERR_CONN_LOST: |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
407 | return QCoreApplication.translate( |
3
82845c0fd550
Fixed some code style issues and implemented the broker connect/disconnect group of the MqttMonitorWidget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2
diff
changeset
|
408 | "MqttErrorMessage", |
2
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
409 | "The connection was lost.") |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
410 | elif mqttErrno == mqtt.MQTT_ERR_TLS: |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
411 | return QCoreApplication.translate( |
3
82845c0fd550
Fixed some code style issues and implemented the broker connect/disconnect group of the MqttMonitorWidget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2
diff
changeset
|
412 | "MqttErrorMessage", |
2
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
413 | "A TLS error occurred.") |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
414 | elif mqttErrno == mqtt.MQTT_ERR_PAYLOAD_SIZE: |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
415 | return QCoreApplication.translate( |
3
82845c0fd550
Fixed some code style issues and implemented the broker connect/disconnect group of the MqttMonitorWidget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2
diff
changeset
|
416 | "MqttErrorMessage", |
2
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
417 | "Payload too large.") |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
418 | elif mqttErrno == mqtt.MQTT_ERR_NOT_SUPPORTED: |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
419 | return QCoreApplication.translate( |
3
82845c0fd550
Fixed some code style issues and implemented the broker connect/disconnect group of the MqttMonitorWidget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2
diff
changeset
|
420 | "MqttErrorMessage", |
2
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
421 | "This feature is not supported.") |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
422 | elif mqttErrno == mqtt.MQTT_ERR_AUTH: |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
423 | return QCoreApplication.translate( |
3
82845c0fd550
Fixed some code style issues and implemented the broker connect/disconnect group of the MqttMonitorWidget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2
diff
changeset
|
424 | "MqttErrorMessage", |
2
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
425 | "Authorisation failed.") |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
426 | elif mqttErrno == mqtt.MQTT_ERR_ACL_DENIED: |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
427 | return QCoreApplication.translate( |
3
82845c0fd550
Fixed some code style issues and implemented the broker connect/disconnect group of the MqttMonitorWidget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2
diff
changeset
|
428 | "MqttErrorMessage", |
2
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
429 | "Access denied by ACL.") |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
430 | elif mqttErrno == mqtt.MQTT_ERR_UNKNOWN: |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
431 | return QCoreApplication.translate( |
3
82845c0fd550
Fixed some code style issues and implemented the broker connect/disconnect group of the MqttMonitorWidget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2
diff
changeset
|
432 | "MqttErrorMessage", |
2
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
433 | "Unknown error.") |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
434 | elif mqttErrno == mqtt.MQTT_ERR_ERRNO: |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
435 | return QCoreApplication.translate( |
3
82845c0fd550
Fixed some code style issues and implemented the broker connect/disconnect group of the MqttMonitorWidget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2
diff
changeset
|
436 | "MqttErrorMessage", |
2
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
437 | "Error defined by errno.") |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
438 | else: |
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
439 | return QCoreApplication.translate( |
3
82845c0fd550
Fixed some code style issues and implemented the broker connect/disconnect group of the MqttMonitorWidget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2
diff
changeset
|
440 | "MqttErrorMessage", |
2
d439c5109829
MqttClient: added the MqttClient wrapper around paho.mqtt.client.Client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
441 | "Unknown error.") |