Merge branch 'dev2' of https://github.com/emsesp/EMS-ESP32 into dev2

This commit is contained in:
MichaelDvP
2023-07-14 19:15:28 +02:00
29 changed files with 1140 additions and 413 deletions

View File

@@ -172,14 +172,14 @@ void MqttSettingsService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) {
}
bool MqttSettingsService::configureMqtt() {
// disconnect if connected
// disconnect if already connected
if (_mqttClient->connected()) {
emsesp::EMSESP::logger().info("Disconneting to configure");
emsesp::EMSESP::logger().info("Disconnecting to configure");
_mqttClient->disconnect(true);
}
// only connect if WiFi is connected and MQTT is enabled
if (_state.enabled && emsesp::EMSESP::system_.network_connected() && !_state.host.isEmpty()) {
// if (_state.enabled && !_state.host.isEmpty()) {
_reconfigureMqtt = false;
#if CONFIG_IDF_TARGET_ESP32S3
if (_state.rootCA.length() > 0) {
@@ -212,6 +212,7 @@ bool MqttSettingsService::configureMqtt() {
static_cast<espMqttClient *>(_mqttClient)->setCleanSession(_state.cleanSession);
return _mqttClient->connect();
}
return false;
}