diff --git a/src/ksf/comp/ksMqttConnector.cpp b/src/ksf/comp/ksMqttConnector.cpp index 5789f57..da17f36 100644 --- a/src/ksf/comp/ksMqttConnector.cpp +++ b/src/ksf/comp/ksMqttConnector.cpp @@ -184,10 +184,9 @@ namespace ksf::comps { if (sendConnectionStatus) { - std::string willTopic{prefix + PSTR("connected")}; #ifdef APP_LOG_ENABLED app->log([&](std::string& out) { - out += PSTR("[MQTT] Trying to connect to MQTT broker..."); + out += PSTR("[MQTT] Connecting to MQTT broker..."); }); #endif /* Handle connection manually. */ @@ -198,27 +197,21 @@ namespace ksf::comps /* If not connected, return. */ if (!wifiClientSp->connected()) - { -#ifdef APP_LOG_ENABLED - app->log([&](std::string& out) { - out += PSTR("[MQTT] Failed to connect..."); - }); -#endif return false; - } /* Verify certificate fingerprint. */ if (certFingerprint && !certFingerprint->verify(reinterpret_cast(wifiClientSp.get()))) { #ifdef APP_LOG_ENABLED app->log([&](std::string& out) { - out += PSTR("[MQTT] Certificate verification failed..."); + out += PSTR("[MQTT] Invalid certificate fingerprint! Disconnecting."); }); #endif wifiClientSp->stop(); return false; } + std::string willTopic{prefix + PSTR("connected")}; if (mqttClientSp->connect(WiFi.macAddress().c_str(), login.c_str(), password.c_str(), willTopic.c_str(), 0, true, "0", !usePersistentSession)) { #ifdef APP_LOG_ENABLED