Merge pull request #338 from Adrien-P/fix/mqtt-with-auth-connected-flag

fix: ensure connected flag set for both authenticated connections.
This commit is contained in:
Samuel Siburian
2025-08-19 10:03:47 +07:00
committed by GitHub

View File

@@ -260,13 +260,14 @@ bool MqttClient::connect(String id) {
connected = false;
if (user.isEmpty()) {
logInfo("Connect without auth");
if(CLIENT()->connect(id.c_str())) {
connected = true;
connected = CLIENT()->connect(id.c_str());
} else {
logInfo("Connect with auth");
connected = CLIENT()->connect(id.c_str(), user.c_str(), password.c_str());
}
return connected;
}
return CLIENT()->connect(id.c_str(), user.c_str(), password.c_str());
}
void MqttClient::handle(void) {
if (isBegin == false) {
return;