Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cziter15 committed Jun 19, 2024
1 parent 8b1b488 commit b4d07d9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
12 changes: 10 additions & 2 deletions src/ksf/comp/ksMqttConnector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,22 @@ namespace ksf::comps

if (certFingerprint->setup(secureClient.get(), fingerprint))
netClientUq = std::move(secureClient);

#if ESP32
constexpr auto handshakeTimeoutSec{KSF_MQTT_TIMEOUT_MS/KSF_ONE_SEC_MS};
secureClient->setHandshakeTimeout(handshakeTimeoutSec);
#endif
}
else
{
netClientUq = std::make_unique<ksMqttConnectorNetClient_t>();
}

/* Set MQTT timeout. */
netClientUq->setTimeout(KSF_MQTT_TIMEOUT_MS);
#if ESP32
netClientUq->setConnectionTimeout(KSF_MQTT_TIMEOUT_MS);
#endif
/* Whoops, it looks like fingerprint validation failed. */
if (!netClientUq)
return;
Expand All @@ -89,8 +99,6 @@ namespace ksf::comps
this->prefix = std::move(prefix);
this->broker = std::move(broker);

netClientUq->setTimeout(KSF_SEC_TO_MS(KSF_MQTT_TIMEOUT_SEC));

/* Load MQTT port. */
ksf::from_chars(port, portNumber);
}
Expand Down
6 changes: 3 additions & 3 deletions src/ksf/ksConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
#define KSF_MQTT_RECONNECT_DELAY_MS 5000UL
#endif

#ifndef KSF_MQTT_TIMEOUT_SEC
/*! MQTT socket timeout in seconds. On ESP32 is also used as connect (blocking) timeout. */
#define KSF_MQTT_TIMEOUT_SEC 4UL
#ifndef KSF_MQTT_TIMEOUT_MS
/*! MQTT socket timeout in milliseconds. On ESP32 is also used as connect (blocking) timeout. */
#define KSF_MQTT_TIMEOUT_MS 4000UL
#endif

#ifndef KSF_WIFI_TIMEOUT_MS
Expand Down

0 comments on commit b4d07d9

Please sign in to comment.