mqtt: update compatibility with latest client

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Eric Callahan 2022-11-16 08:05:56 -05:00
parent bd1fd63b14
commit bfe20433f9
No known key found for this signature in database
GPG Key ID: 5A1EB336DFB4C71B
1 changed files with 27 additions and 13 deletions

View File

@ -54,6 +54,8 @@ class ExtPahoClient(paho_mqtt.Client):
if self._port <= 0: if self._port <= 0:
raise ValueError('Invalid port number.') raise ValueError('Invalid port number.')
if hasattr(self, "_out_packet_mutex"):
# Paho Mqtt Version < 1.6.x
self._in_packet = { self._in_packet = {
"command": 0, "command": 0,
"have_remaining": 0, "have_remaining": 0,
@ -62,13 +64,25 @@ class ExtPahoClient(paho_mqtt.Client):
"remaining_length": 0, "remaining_length": 0,
"packet": b"", "packet": b"",
"to_process": 0, "to_process": 0,
"pos": 0} "pos": 0
}
with self._out_packet_mutex: with self._out_packet_mutex:
self._out_packet = deque() # type: ignore self._out_packet = deque() # type: ignore
with self._current_out_packet_mutex: with self._current_out_packet_mutex:
self._current_out_packet = None self._current_out_packet = None
else:
self._in_packet = {
"command": 0,
"have_remaining": 0,
"remaining_count": [],
"remaining_mult": 1,
"remaining_length": 0,
"packet": bytearray(b""),
"to_process": 0,
"pos": 0
}
self._out_packet = deque() # type: ignore
with self._msgtime_mutex: with self._msgtime_mutex:
self._last_msg_in = paho_mqtt.time_func() self._last_msg_in = paho_mqtt.time_func()