Skip to content

Commit 29e60e9

Browse files
committed
use const for the packet type mask
1 parent 94589a8 commit 29e60e9

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

adafruit_minimqtt/adafruit_minimqtt.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252
MQTT_UNSUB = b"\xA2"
5353
MQTT_DISCONNECT = b"\xe0\0"
5454

55+
MQTT_PKT_TYPE_MASK = const(0xF0)
56+
5557
# Variable CONNECT header [MQTT 3.1.2]
5658
MQTT_HDR_CONNECT = bytearray(b"\x04MQTT\x04\x02\0\0")
5759

@@ -902,7 +904,7 @@ def _wait_for_msg(self, timeout=0.1):
902904
if res in [None, b"", b"\x00"]:
903905
# If we get here, it means that there is nothing to be received
904906
return None
905-
if res[0] & 0xF0 == MQTT_PINGRESP:
907+
if res[0] & MQTT_PKT_TYPE_MASK == MQTT_PINGRESP:
906908
if self.logger is not None:
907909
self.logger.debug("Got PINGRESP")
908910
sz = self._sock_exact_recv(1)[0]
@@ -912,7 +914,7 @@ def _wait_for_msg(self, timeout=0.1):
912914
)
913915
return MQTT_PINGRESP
914916

915-
if res[0] & 0xF0 != MQTT_PUBLISH:
917+
if res[0] & MQTT_PKT_TYPE_MASK != MQTT_PUBLISH:
916918
return res[0]
917919

918920
# Handle only the PUBLISH packet type from now on.

0 commit comments

Comments
 (0)