From b4e266f128074aba151469f27584263a7578c313 Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Sat, 14 Oct 2023 18:31:06 +0200 Subject: [PATCH] mqtt secure only for S3 (avoid conflict with tasmota platform esp32) --- lib/espMqttClient/src/Config.h | 4 ++++ lib/espMqttClient/src/Transport/ClientSecureSync.h | 9 +++++++++ lib/espMqttClient/src/espMqttClient.cpp | 10 ++++++++++ 3 files changed, 23 insertions(+) diff --git a/lib/espMqttClient/src/Config.h b/lib/espMqttClient/src/Config.h index 940c2dea8..d32b5f4ed 100644 --- a/lib/espMqttClient/src/Config.h +++ b/lib/espMqttClient/src/Config.h @@ -8,6 +8,10 @@ the LICENSE file. #pragma once +#if CONFIG_IDF_TARGET_ESP32S3 +#define EMC_CLIENT_SECURE +#endif + #ifndef EMC_TX_TIMEOUT #define EMC_TX_TIMEOUT 2000 #endif diff --git a/lib/espMqttClient/src/Transport/ClientSecureSync.h b/lib/espMqttClient/src/Transport/ClientSecureSync.h index b81681e36..c29b03d2f 100644 --- a/lib/espMqttClient/src/Transport/ClientSecureSync.h +++ b/lib/espMqttClient/src/Transport/ClientSecureSync.h @@ -10,7 +10,12 @@ the LICENSE file. #if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32) +#include "../Config.h" +#if defined(EMC_CLIENT_SECURE) #include // includes IPAddress +#else +#include +#endif #include "Transport.h" @@ -26,7 +31,11 @@ class ClientSecureSync : public Transport { void stop() override; bool connected() override; bool disconnected() override; +#if defined(EMC_CLIENT_SECURE) WiFiClientSecure client; +#else + WiFiClient client; +#endif }; } // namespace espMqttClientInternals diff --git a/lib/espMqttClient/src/espMqttClient.cpp b/lib/espMqttClient/src/espMqttClient.cpp index 833ece10b..bd9b6935a 100644 --- a/lib/espMqttClient/src/espMqttClient.cpp +++ b/lib/espMqttClient/src/espMqttClient.cpp @@ -78,27 +78,37 @@ espMqttClientSecure::espMqttClientSecure(uint8_t priority, uint8_t core) } espMqttClientSecure& espMqttClientSecure::setInsecure() { +#if defined(EMC_CLIENT_SECURE) _client.client.setInsecure(); +#endif return *this; } espMqttClientSecure& espMqttClientSecure::setCACert(const char* rootCA) { +#if defined(EMC_CLIENT_SECURE) _client.client.setCACert(rootCA); +#endif return *this; } espMqttClientSecure& espMqttClientSecure::setCertificate(const char* clientCa) { +#if defined(EMC_CLIENT_SECURE) _client.client.setCertificate(clientCa); +#endif return *this; } espMqttClientSecure& espMqttClientSecure::setPrivateKey(const char* privateKey) { +#if defined(EMC_CLIENT_SECURE) _client.client.setPrivateKey(privateKey); +#endif return *this; } espMqttClientSecure& espMqttClientSecure::setPreSharedKey(const char* pskIdent, const char* psKey) { +#if defined(EMC_CLIENT_SECURE) _client.client.setPreSharedKey(pskIdent, psKey); +#endif return *this; }