Skip to content

Commit

Permalink
MQTT adjs
Browse files Browse the repository at this point in the history
  • Loading branch information
steadramon committed Jul 30, 2023
1 parent 86e1490 commit 8bd2d46
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion ESPGeiger/src/Mqtt/MQTT_Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,19 @@
MQTT_Client::MQTT_Client()
: PubSubClient(espClient)
{
#ifdef ESP8266
// setTimeout in msecs
espClient.setTimeout(200 * 100);
#else
// setTimeout in secs
uint32_t timeout = (20);
espClient.setTimeout(timeout);
#endif
}
void MQTT_Client::disconnect()
{
PubSubClient::disconnect();
espClient.stop();
mqttEnabled = true;
}
void MQTT_Client::loop()
Expand Down Expand Up @@ -298,6 +307,7 @@ void MQTT_Client::removeHassTopic(const String& mqttDeviceType, const String& ma
path.concat("/config");

publish(path.c_str(), "", true);
yield();
}

void MQTT_Client::begin()
Expand All @@ -313,7 +323,8 @@ void MQTT_Client::begin()
}
setServer(configManager.getParamValueFromID("mqttServer"), atoi(configManager.getParamValueFromID("mqttPort")));
setBufferSize(MQTT_MAX_PACKET_SIZE);

setKeepAlive(30);
setSocketTimeout(4);
mqttEnabled = true;

}

0 comments on commit 8bd2d46

Please sign in to comment.