From 4c58026fdcd055e648b98ca173ab65ff310eba3a Mon Sep 17 00:00:00 2001 From: Vladimir Kotal Date: Sat, 18 Nov 2023 11:21:23 +0100 Subject: [PATCH] do not share CONNECT variable header fixes #185 --- adafruit_minimqtt/adafruit_minimqtt.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/adafruit_minimqtt/adafruit_minimqtt.py b/adafruit_minimqtt/adafruit_minimqtt.py index cbeb8f6..d51b2bc 100644 --- a/adafruit_minimqtt/adafruit_minimqtt.py +++ b/adafruit_minimqtt/adafruit_minimqtt.py @@ -66,9 +66,6 @@ MQTT_PKT_TYPE_MASK = const(0xF0) -# Variable CONNECT header [MQTT 3.1.2] -MQTT_HDR_CONNECT = bytearray(b"\x04MQTT\x04\x02\0\0") - CONNACK_ERRORS = { const(0x01): "Connection Refused - Incorrect Protocol Version", @@ -567,10 +564,9 @@ def _connect( # Fixed Header fixed_header = bytearray([0x10]) - # NOTE: Variable header is - # MQTT_HDR_CONNECT = bytearray(b"\x04MQTT\x04\x02\0\0") - # because final 4 bytes are 4, 2, 0, 0 - var_header = MQTT_HDR_CONNECT + # Variable CONNECT header [MQTT 3.1.2] + # The byte array is used as a template. + var_header = bytearray(b"\x04MQTT\x04\x02\0\0") var_header[6] = clean_session << 1 # Set up variable header and remaining_length