Skip to content

Commit

Permalink
support passwords with empty usernames
Browse files Browse the repository at this point in the history
  • Loading branch information
256dpi committed Feb 5, 2023
1 parent b72a94d commit dbd7f1b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ bool connect(const char clientID[], const char username[], bool skip = false);
bool connect(const char clientID[], const char username[], const char password[], bool skip = false);
```

- If `password` is present but `username` is absent, the client will fall back to an empty username.
- 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.
- The functions return a boolean that indicates if the connection has been established successfully (true).

Expand Down
7 changes: 3 additions & 4 deletions src/MQTTClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,10 +352,9 @@ bool MQTTClient::connect(const char clientID[], const char username[], const cha
// set username and password if available
if (username != nullptr) {
options.username = lwmqtt_string(username);

if (password != nullptr) {
options.password = lwmqtt_string(password);
}
}
if (password != nullptr) {
options.password = lwmqtt_string(password);
}

// connect to broker
Expand Down

0 comments on commit dbd7f1b

Please sign in to comment.