Skip to content

Commit

Permalink
Merge pull request #130 from flavio-fernandes/username_fix
Browse files Browse the repository at this point in the history
MQTT connect with an empty username should have the proper header
  • Loading branch information
tekktrik authored Dec 5, 2022
2 parents 4c0c770 + 9f4c8fd commit 35cab6f
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions adafruit_minimqtt/adafruit_minimqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ def connect(self, clean_session=True, host=None, port=None, keep_alive=None):

# Set up variable header and remaining_length
remaining_length = 12 + len(self.client_id.encode("utf-8"))
if self._username:
if self._username is not None:
remaining_length += (
2
+ len(self._username.encode("utf-8"))
Expand Down Expand Up @@ -533,9 +533,7 @@ def connect(self, clean_session=True, host=None, port=None, keep_alive=None):
# [MQTT-3.1.3-11]
self._send_str(self._lw_topic)
self._send_str(self._lw_msg)
if self._username is None:
self._username = None
else:
if self._username is not None:
self._send_str(self._username)
self._send_str(self._password)
if self.logger is not None:
Expand Down

0 comments on commit 35cab6f

Please sign in to comment.