fix: ensure connected flag set for both authenticated connections.

This commit is contained in:
Adrien-P
2025-08-18 19:33:30 +02:00
parent d8eb6b3c1a
commit f94ed5c5f5

View File

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