Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cziter15 committed Jun 10, 2024
1 parent fdde7ba commit 8090a88
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/ksf/comp/ksMqttConnector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand All @@ -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<WiFiClientSecure*>(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
Expand Down

0 comments on commit 8090a88

Please sign in to comment.