Setmqtt setting optional (#1021)
* Define MQTTsetMQTT for configuring MQTT over MQTT * Enable MQTTsetMQTT per default on all ESP except RFBridge Co-authored-by: Dave <d.kneisz@gmail.com>
This commit is contained in:
1 parent
c44ab5aeb9
commit
ebe17c8899
3 files changed
+25
-10
No files matched your search
+12
-10
@@ -1897,6 +1897,7 @@ void MQTTtoSYS(char* topicOri, JsonObject& SYSdata) { // json object decoding
|
||||
# endif
|
||||
}
|
||||
|
||||
# ifdef MQTTsetMQTT
|
||||
if (SYSdata.containsKey("mqtt_user") && SYSdata.containsKey("mqtt_pass")) {
|
||||
bool update_server = false;
|
||||
bool secure_connect = SYSdata.get<bool>("mqtt_secure");
|
||||
@@ -1909,7 +1910,7 @@ void MQTTtoSYS(char* topicOri, JsonObject& SYSdata) { // json object decoding
|
||||
Log.error(F("mqtt_server provided without mqtt_secure defined - ignoring command" CR));
|
||||
return;
|
||||
}
|
||||
# if MQTT_SECURE_SELF_SIGNED
|
||||
# if MQTT_SECURE_SELF_SIGNED
|
||||
if (use_ss_cert) {
|
||||
cert_index = SYSdata.get<uint8_t>("mqtt_cert_index");
|
||||
if (cert_index >= sizeof(certs_array) / sizeof(ss_certs)) {
|
||||
@@ -1917,11 +1918,11 @@ void MQTTtoSYS(char* topicOri, JsonObject& SYSdata) { // json object decoding
|
||||
return;
|
||||
}
|
||||
}
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# if defined(ZgatewayBT) && defined(ESP32)
|
||||
# if defined(ZgatewayBT) && defined(ESP32)
|
||||
stopProcessing();
|
||||
# endif
|
||||
# endif
|
||||
client.disconnect();
|
||||
update_server = true;
|
||||
if (secure_connect != mqtt_secure) {
|
||||
@@ -1942,9 +1943,9 @@ void MQTTtoSYS(char* topicOri, JsonObject& SYSdata) { // json object decoding
|
||||
|
||||
client.setServer(SYSdata.get<const char*>("mqtt_server"), SYSdata.get<unsigned int>("mqtt_port"));
|
||||
} else {
|
||||
# if defined(ZgatewayBT) && defined(ESP32)
|
||||
# if defined(ZgatewayBT) && defined(ESP32)
|
||||
stopProcessing();
|
||||
# endif
|
||||
# endif
|
||||
client.disconnect();
|
||||
}
|
||||
|
||||
@@ -1965,9 +1966,9 @@ void MQTTtoSYS(char* topicOri, JsonObject& SYSdata) { // json object decoding
|
||||
delete prev_client;
|
||||
}
|
||||
}
|
||||
# ifndef ESPWifiManualSetup
|
||||
# ifndef ESPWifiManualSetup
|
||||
saveMqttConfig();
|
||||
# endif
|
||||
# endif
|
||||
} else {
|
||||
if (update_server) {
|
||||
if (prev_client != nullptr) {
|
||||
@@ -1985,10 +1986,11 @@ void MQTTtoSYS(char* topicOri, JsonObject& SYSdata) { // json object decoding
|
||||
}
|
||||
connectMQTT();
|
||||
}
|
||||
# if defined(ZgatewayBT) && defined(ESP32)
|
||||
# if defined(ZgatewayBT) && defined(ESP32)
|
||||
startProcessing();
|
||||
# endif
|
||||
# endif
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef ZmqttDiscovery
|
||||
|
||||
Reference in new issue
Block a user