Skip to content

Commit 3eb666d

Browse files
authored
Merge pull request #186 from vladak/var_header_vs_bytearray
do not share CONNECT variable header
2 parents 4698382 + 4c58026 commit 3eb666d

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

adafruit_minimqtt/adafruit_minimqtt.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,6 @@
6666

6767
MQTT_PKT_TYPE_MASK = const(0xF0)
6868

69-
# Variable CONNECT header [MQTT 3.1.2]
70-
MQTT_HDR_CONNECT = bytearray(b"\x04MQTT\x04\x02\0\0")
71-
7269

7370
CONNACK_ERRORS = {
7471
const(0x01): "Connection Refused - Incorrect Protocol Version",
@@ -603,10 +600,9 @@ def _connect(
603600
# Fixed Header
604601
fixed_header = bytearray([0x10])
605602

606-
# NOTE: Variable header is
607-
# MQTT_HDR_CONNECT = bytearray(b"\x04MQTT\x04\x02\0\0")
608-
# because final 4 bytes are 4, 2, 0, 0
609-
var_header = MQTT_HDR_CONNECT
603+
# Variable CONNECT header [MQTT 3.1.2]
604+
# The byte array is used as a template.
605+
var_header = bytearray(b"\x04MQTT\x04\x02\0\0")
610606
var_header[6] = clean_session << 1
611607

612608
# Set up variable header and remaining_length

0 commit comments

Comments
 (0)