Skip to content

Commit eb8378a

Browse files
authored
Merge pull request #338 from Adrien-P/fix/mqtt-with-auth-connected-flag
fix: ensure connected flag set for both authenticated connections.
2 parents 9471f3e + f94ed5c commit eb8378a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/MqttClient.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -260,13 +260,14 @@ bool MqttClient::connect(String id) {
260260
connected = false;
261261
if (user.isEmpty()) {
262262
logInfo("Connect without auth");
263-
if(CLIENT()->connect(id.c_str())) {
264-
connected = true;
265-
}
266-
return connected;
263+
connected = CLIENT()->connect(id.c_str());
264+
} else {
265+
logInfo("Connect with auth");
266+
connected = CLIENT()->connect(id.c_str(), user.c_str(), password.c_str());
267267
}
268-
return CLIENT()->connect(id.c_str(), user.c_str(), password.c_str());
268+
return connected;
269269
}
270+
270271
void MqttClient::handle(void) {
271272
if (isBegin == false) {
272273
return;

0 commit comments

Comments
 (0)