Skip to content

Commit 803452a

Browse files
felixdoerredpgeorge
authored andcommitted
umqtt.simple: Simplify check for user being unused.
There don't seem to be any MQTT implementations that expect an empty username (instead of the field missing), so the check for unused `user` can be simplified. Signed-off-by: Felix Dörre <[email protected]>
1 parent 7cdf708 commit 803452a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

micropython/umqtt.simple/umqtt/simple.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def connect(self, clean_session=True):
7575

7676
sz = 10 + 2 + len(self.client_id)
7777
msg[6] = clean_session << 1
78-
if self.user is not None:
78+
if self.user:
7979
sz += 2 + len(self.user) + 2 + len(self.pswd)
8080
msg[6] |= 0xC0
8181
if self.keepalive:
@@ -101,7 +101,7 @@ def connect(self, clean_session=True):
101101
if self.lw_topic:
102102
self._send_str(self.lw_topic)
103103
self._send_str(self.lw_msg)
104-
if self.user is not None:
104+
if self.user:
105105
self._send_str(self.user)
106106
self._send_str(self.pswd)
107107
resp = self.sock.read(4)

0 commit comments

Comments
 (0)