Skip to content

Commit dbd7f1b

Browse files
committed
support passwords with empty usernames
1 parent b72a94d commit dbd7f1b

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ bool connect(const char clientID[], const char username[], bool skip = false);
189189
bool connect(const char clientID[], const char username[], const char password[], bool skip = false);
190190
```
191191

192+
- If `password` is present but `username` is absent, the client will fall back to an empty username.
192193
- If the `skip` option is set to true, the client will skip the network level connection and jump to the MQTT level connection. This option can be used in order to establish and verify TLS connections manually before giving control to the MQTT client.
193194
- The functions return a boolean that indicates if the connection has been established successfully (true).
194195

src/MQTTClient.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,10 +352,9 @@ bool MQTTClient::connect(const char clientID[], const char username[], const cha
352352
// set username and password if available
353353
if (username != nullptr) {
354354
options.username = lwmqtt_string(username);
355-
356-
if (password != nullptr) {
357-
options.password = lwmqtt_string(password);
358-
}
355+
}
356+
if (password != nullptr) {
357+
options.password = lwmqtt_string(password);
359358
}
360359

361360
// connect to broker

0 commit comments

Comments
 (0)