From 1b623014c1dbd1171a309124f16a9708ebef4ec8 Mon Sep 17 00:00:00 2001 From: Proddy Date: Fri, 14 Jul 2023 12:11:22 +0200 Subject: [PATCH] added log message --- lib/framework/MqttSettingsService.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/framework/MqttSettingsService.cpp b/lib/framework/MqttSettingsService.cpp index 1135525b7..707c1e865 100644 --- a/lib/framework/MqttSettingsService.cpp +++ b/lib/framework/MqttSettingsService.cpp @@ -172,14 +172,14 @@ void MqttSettingsService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) { } bool MqttSettingsService::configureMqtt() { - // disconnect if connected + // disconnect if already connected if (_mqttClient->connected()) { - emsesp::EMSESP::logger().info("Disconneting to configure"); + emsesp::EMSESP::logger().info("Disconnecting to configure"); _mqttClient->disconnect(true); } + // only connect if WiFi is connected and MQTT is enabled if (_state.enabled && emsesp::EMSESP::system_.network_connected() && !_state.host.isEmpty()) { - // if (_state.enabled && !_state.host.isEmpty()) { _reconfigureMqtt = false; #if CONFIG_IDF_TARGET_ESP32S3 if (_state.rootCA.length() > 0) { @@ -212,6 +212,8 @@ bool MqttSettingsService::configureMqtt() { static_cast(_mqttClient)->setCleanSession(_state.cleanSession); return _mqttClient->connect(); } + emsesp::EMSESP::logger().info("Connecting to MQTT broker..."); + return false; }