From f94ed5c5f58df5fb35bb73a0d24fe131df473cad Mon Sep 17 00:00:00 2001 From: Adrien-P Date: Mon, 18 Aug 2025 19:33:30 +0200 Subject: [PATCH] fix: ensure connected flag set for both authenticated connections. --- src/MqttClient.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/MqttClient.cpp b/src/MqttClient.cpp index 66c71e6..e1a0947 100644 --- a/src/MqttClient.cpp +++ b/src/MqttClient.cpp @@ -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; - } - return connected; + connected = CLIENT()->connect(id.c_str()); + } else { + logInfo("Connect with auth"); + connected = CLIENT()->connect(id.c_str(), user.c_str(), password.c_str()); } - return CLIENT()->connect(id.c_str(), user.c_str(), password.c_str()); + return connected; } + void MqttClient::handle(void) { if (isBegin == false) { return;