move mqtt loop into network task

This commit is contained in:
technyon
2023-02-26 10:26:55 +01:00
parent c5bd325ed5
commit 8b647e8b8e
12 changed files with 129 additions and 17 deletions

View File

@@ -25,7 +25,7 @@ WifiDevice::WifiDevice(const String& hostname, Preferences* _preferences)
{
Log->println(F("MQTT over TLS."));
Log->println(_ca);
_mqttClientSecure = new espMqttClientSecure();
_mqttClientSecure = new espMqttClientSecureAsync();
_mqttClientSecure->setCACert(_ca);
if(crtLength > 1 && keyLength > 1) // length is 1 when empty
{
@@ -38,7 +38,7 @@ WifiDevice::WifiDevice(const String& hostname, Preferences* _preferences)
} else
{
Log->println(F("MQTT without TLS."));
_mqttClient = new espMqttClient();
_mqttClient = new espMqttClientAsync();
}
if(_preferences->getBool(preference_mqtt_log_enabled))
@@ -142,7 +142,14 @@ ReconnectStatus WifiDevice::reconnect()
void WifiDevice::update()
{
if(_useEncryption)
{
_mqttClientSecure->loop();
}
else
{
_mqttClient->loop();
}
}
void WifiDevice::onDisconnected()