154 self.__mqttClient.on_message = self.__onMessageV5 |
154 self.__mqttClient.on_message = self.__onMessageV5 |
155 |
155 |
156 self.__mqttClient.on_log = self.__onLog |
156 self.__mqttClient.on_log = self.__onLog |
157 self.__mqttClient.on_publish = self.__onPublish |
157 self.__mqttClient.on_publish = self.__onPublish |
158 |
158 |
159 def __onConnectV3(self, client, userdata, flags, rc, properties=None): # noqa: U100 |
159 def __onConnectV3( |
|
160 self, |
|
161 client, # noqa: U100 |
|
162 userdata, # noqa: U100 |
|
163 flags, |
|
164 rc, |
|
165 properties=None, # noqa: U100 |
|
166 ): |
160 """ |
167 """ |
161 Private method to handle the connect to the broker (MQTT v3.1 and v3.1.1). |
168 Private method to handle the connect to the broker (MQTT v3.1 and v3.1.1). |
162 |
169 |
163 @param client reference to the client object |
170 @param client reference to the client object |
164 @type paho.mqtt.Client |
171 @type paho.mqtt.Client |
171 @param properties optional properties (defaults to None) |
178 @param properties optional properties (defaults to None) |
172 @type dict (optional) |
179 @type dict (optional) |
173 """ |
180 """ |
174 self.onConnectV3.emit(flags, rc) |
181 self.onConnectV3.emit(flags, rc) |
175 |
182 |
176 def __onDisconnectedV3(self, client, userdata, rc): # noqa: U100 |
183 def __onDisconnectedV3( |
|
184 self, |
|
185 client, # noqa: U100 |
|
186 userdata, # noqa: U100 |
|
187 rc, |
|
188 ): |
177 """ |
189 """ |
178 Private method to handle the disconnect from the broker (MQTT v3.1 and v3.1.1). |
190 Private method to handle the disconnect from the broker (MQTT v3.1 and v3.1.1). |
179 |
191 |
180 @param client reference to the client object |
192 @param client reference to the client object |
181 @type paho.mqtt.Client |
193 @type paho.mqtt.Client |
184 @param rc result code |
196 @param rc result code |
185 @type int |
197 @type int |
186 """ |
198 """ |
187 self.onDisconnectedV3.emit(rc) |
199 self.onDisconnectedV3.emit(rc) |
188 |
200 |
189 def __onSubscribeV3(self, client, userdata, mid, grantedQos): # noqa: U100 |
201 def __onSubscribeV3( |
|
202 self, |
|
203 client, # noqa: U100 |
|
204 userdata, # noqa: U100 |
|
205 mid, |
|
206 grantedQos, |
|
207 ): |
190 """ |
208 """ |
191 Private method to handle a subscribe event (MQTT v3.1 and v3.1.1). |
209 Private method to handle a subscribe event (MQTT v3.1 and v3.1.1). |
192 |
210 |
193 @param client reference to the client object |
211 @param client reference to the client object |
194 @type paho.mqtt.Client |
212 @type paho.mqtt.Client |
199 @param grantedQos list of granted QoS for each subscription request |
217 @param grantedQos list of granted QoS for each subscription request |
200 @type list of int |
218 @type list of int |
201 """ |
219 """ |
202 self.onSubscribeV3.emit(mid, grantedQos) |
220 self.onSubscribeV3.emit(mid, grantedQos) |
203 |
221 |
204 def __onUnsubscribeV3(self, client, userdata, mid): # noqa: U100 |
222 def __onUnsubscribeV3( |
|
223 self, |
|
224 client, # noqa: U100 |
|
225 userdata, # noqa: U100 |
|
226 mid, |
|
227 ): |
205 """ |
228 """ |
206 Private method to handle an unsubscribe event (MQTT v3.1 and v3.1.1). |
229 Private method to handle an unsubscribe event (MQTT v3.1 and v3.1.1). |
207 |
230 |
208 @param client reference to the client object |
231 @param client reference to the client object |
209 @type paho.mqtt.Client |
232 @type paho.mqtt.Client |
212 @param mid message ID |
235 @param mid message ID |
213 @type int |
236 @type int |
214 """ |
237 """ |
215 self.onUnsubscribeV3.emit(mid) |
238 self.onUnsubscribeV3.emit(mid) |
216 |
239 |
217 def __onMessageV3(self, client, userdata, message): # noqa: U100 |
240 def __onMessageV3( |
|
241 self, |
|
242 client, # noqa: U100 |
|
243 userdata, # noqa: U100 |
|
244 message, |
|
245 ): |
218 """ |
246 """ |
219 Private method to handle a new message received from the broker (MQTT v3.1 |
247 Private method to handle a new message received from the broker (MQTT v3.1 |
220 and v3.1.1). |
248 and v3.1.1). |
221 |
249 |
222 @param client reference to the client object |
250 @param client reference to the client object |
228 """ |
256 """ |
229 self.onMessageV3.emit( |
257 self.onMessageV3.emit( |
230 message.topic, message.payload, message.qos, message.retain |
258 message.topic, message.payload, message.qos, message.retain |
231 ) |
259 ) |
232 |
260 |
233 def __onConnectV5(self, client, userdata, flags, rc, properties=None): # noqa: U100 |
261 def __onConnectV5( |
|
262 self, |
|
263 client, # noqa: U100 |
|
264 userdata, # noqa: U100 |
|
265 flags, |
|
266 rc, |
|
267 properties=None, |
|
268 ): |
234 """ |
269 """ |
235 Private method to handle the connect to the broker (MQTT v5.0). |
270 Private method to handle the connect to the broker (MQTT v5.0). |
236 |
271 |
237 @param client reference to the client object |
272 @param client reference to the client object |
238 @type paho.mqtt.Client |
273 @type paho.mqtt.Client |
250 rc.value, |
285 rc.value, |
251 rc.packetType, |
286 rc.packetType, |
252 properties.json() if properties is not None else {}, |
287 properties.json() if properties is not None else {}, |
253 ) |
288 ) |
254 |
289 |
255 def __onDisconnectedV5(self, client, userdata, rc, properties=None): # noqa: U100 |
290 def __onDisconnectedV5( |
|
291 self, |
|
292 client, # noqa: U100 |
|
293 userdata, # noqa: U100 |
|
294 rc, |
|
295 properties=None, # noqa: U100 |
|
296 ): |
256 """ |
297 """ |
257 Private method to handle the disconnect from the broker (MQTT v5.0). |
298 Private method to handle the disconnect from the broker (MQTT v5.0). |
258 |
299 |
259 @param client reference to the client object |
300 @param client reference to the client object |
260 @type paho.mqtt.Client |
301 @type paho.mqtt.Client |
271 else: |
312 else: |
272 packetType = rc.packetType |
313 packetType = rc.packetType |
273 resultCode = rc.value |
314 resultCode = rc.value |
274 self.onDisconnectedV5.emit(resultCode, packetType) |
315 self.onDisconnectedV5.emit(resultCode, packetType) |
275 |
316 |
276 def __onSubscribeV5(self, client, userdata, mid, reasonCodes, properties=None): |
317 def __onSubscribeV5( |
277 # noqa: U100 |
318 self, |
|
319 client, # noqa: U100 |
|
320 userdata, # noqa: U100 |
|
321 mid, |
|
322 reasonCodes, |
|
323 properties=None, |
|
324 ): |
278 """ |
325 """ |
279 Private method to handle a subscribe event (MQTT v5.0). |
326 Private method to handle a subscribe event (MQTT v5.0). |
280 |
327 |
281 @param client reference to the client object |
328 @param client reference to the client object |
282 @type paho.mqtt.Client |
329 @type paho.mqtt.Client |
293 mid, |
340 mid, |
294 reasonCodes, |
341 reasonCodes, |
295 properties.json() if properties is not None else {}, |
342 properties.json() if properties is not None else {}, |
296 ) |
343 ) |
297 |
344 |
298 def __onUnsubscribeV5(self, client, userdata, mid, properties, reasonCodes): |
345 def __onUnsubscribeV5( |
299 # noqa: U100 |
346 self, |
|
347 client, # noqa: U100 |
|
348 userdata, # noqa: U100 |
|
349 mid, |
|
350 properties, |
|
351 reasonCodes, |
|
352 ): |
300 """ |
353 """ |
301 Private method to handle an unsubscribe event (MQTT v5.0). |
354 Private method to handle an unsubscribe event (MQTT v5.0). |
302 |
355 |
303 @param client reference to the client object |
356 @param client reference to the client object |
304 @type paho.mqtt.Client |
357 @type paho.mqtt.Client |
316 reasonCodes.value, |
369 reasonCodes.value, |
317 reasonCodes.packetType, |
370 reasonCodes.packetType, |
318 properties.json() if properties is not None else {}, |
371 properties.json() if properties is not None else {}, |
319 ) |
372 ) |
320 |
373 |
321 def __onMessageV5(self, client, userdata, message): # noqa: U100 |
374 def __onMessageV5( |
|
375 self, |
|
376 client, # noqa: U100 |
|
377 userdata, # noqa: U100 |
|
378 message, |
|
379 ): |
322 """ |
380 """ |
323 Private method to handle a new message received from the broker (MQTT v5.0). |
381 Private method to handle a new message received from the broker (MQTT v5.0). |
324 |
382 |
325 @param client reference to the client object |
383 @param client reference to the client object |
326 @type paho.mqtt.Client |
384 @type paho.mqtt.Client |
335 message.qos, |
393 message.qos, |
336 message.retain, |
394 message.retain, |
337 message.properties.json(), |
395 message.properties.json(), |
338 ) |
396 ) |
339 |
397 |
340 def __onLog(self, client, userdata, level, buf): # noqa: U100 |
398 def __onLog( |
|
399 self, |
|
400 client, # noqa: U100 |
|
401 userdata, # noqa: U100 |
|
402 level, |
|
403 buf, |
|
404 ): |
341 """ |
405 """ |
342 Private method to handle a log event (MQTT v3.1, v3.1.1 and v5.0). |
406 Private method to handle a log event (MQTT v3.1, v3.1.1 and v5.0). |
343 |
407 |
344 @param client reference to the client object |
408 @param client reference to the client object |
345 @type paho.mqtt.Client |
409 @type paho.mqtt.Client |
350 @param buf log message |
414 @param buf log message |
351 @type str |
415 @type str |
352 """ |
416 """ |
353 self.onLog.emit(level, buf) |
417 self.onLog.emit(level, buf) |
354 |
418 |
355 def __onPublish(self, client, userdata, mid): # noqa: U100 |
419 def __onPublish( |
|
420 self, |
|
421 client, # noqa: U100 |
|
422 userdata, # noqa: U100 |
|
423 mid, |
|
424 ): |
356 """ |
425 """ |
357 Private method to handle the publishing of a message (MQTT v3.1, v3.1.1 |
426 Private method to handle the publishing of a message (MQTT v3.1, v3.1.1 |
358 and v5.0). |
427 and v5.0). |
359 |
428 |
360 @param client reference to the client object |
429 @param client reference to the client object |