Skip to content

Commit 7aacbfe

Browse files
committed
deduplicate remaining length encoding for PUBLISH packet
1 parent 973df68 commit 7aacbfe

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

adafruit_minimqtt/adafruit_minimqtt.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -765,16 +765,7 @@ def publish(
765765
pub_hdr_var.append(self._pid >> 8)
766766
pub_hdr_var.append(self._pid & 0xFF)
767767

768-
# Calculate remaining length [2.2.3]
769-
if remaining_length > 0x7F:
770-
while remaining_length > 0:
771-
encoded_byte = remaining_length % 0x80
772-
remaining_length = remaining_length // 0x80
773-
if remaining_length > 0:
774-
encoded_byte |= 0x80
775-
pub_hdr_fixed.append(encoded_byte)
776-
else:
777-
pub_hdr_fixed.append(remaining_length)
768+
self.encode_remaining_length(pub_hdr_fixed, remaining_length)
778769

779770
self.logger.debug(
780771
"Sending PUBLISH\nTopic: %s\nMsg: %s\

0 commit comments

Comments
 (0)