mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 08:19:52 +03:00
mqtt secure only for S3 (avoid conflict with tasmota platform esp32)
This commit is contained in:
@@ -8,6 +8,10 @@ the LICENSE file.
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#if CONFIG_IDF_TARGET_ESP32S3
|
||||||
|
#define EMC_CLIENT_SECURE
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef EMC_TX_TIMEOUT
|
#ifndef EMC_TX_TIMEOUT
|
||||||
#define EMC_TX_TIMEOUT 2000
|
#define EMC_TX_TIMEOUT 2000
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -10,7 +10,12 @@ the LICENSE file.
|
|||||||
|
|
||||||
#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
|
#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
|
||||||
|
|
||||||
|
#include "../Config.h"
|
||||||
|
#if defined(EMC_CLIENT_SECURE)
|
||||||
#include <WiFiClientSecure.h> // includes IPAddress
|
#include <WiFiClientSecure.h> // includes IPAddress
|
||||||
|
#else
|
||||||
|
#include <WiFiClient.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "Transport.h"
|
#include "Transport.h"
|
||||||
|
|
||||||
@@ -26,7 +31,11 @@ class ClientSecureSync : public Transport {
|
|||||||
void stop() override;
|
void stop() override;
|
||||||
bool connected() override;
|
bool connected() override;
|
||||||
bool disconnected() override;
|
bool disconnected() override;
|
||||||
|
#if defined(EMC_CLIENT_SECURE)
|
||||||
WiFiClientSecure client;
|
WiFiClientSecure client;
|
||||||
|
#else
|
||||||
|
WiFiClient client;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace espMqttClientInternals
|
} // namespace espMqttClientInternals
|
||||||
|
|||||||
@@ -78,27 +78,37 @@ espMqttClientSecure::espMqttClientSecure(uint8_t priority, uint8_t core)
|
|||||||
}
|
}
|
||||||
|
|
||||||
espMqttClientSecure& espMqttClientSecure::setInsecure() {
|
espMqttClientSecure& espMqttClientSecure::setInsecure() {
|
||||||
|
#if defined(EMC_CLIENT_SECURE)
|
||||||
_client.client.setInsecure();
|
_client.client.setInsecure();
|
||||||
|
#endif
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
espMqttClientSecure& espMqttClientSecure::setCACert(const char* rootCA) {
|
espMqttClientSecure& espMqttClientSecure::setCACert(const char* rootCA) {
|
||||||
|
#if defined(EMC_CLIENT_SECURE)
|
||||||
_client.client.setCACert(rootCA);
|
_client.client.setCACert(rootCA);
|
||||||
|
#endif
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
espMqttClientSecure& espMqttClientSecure::setCertificate(const char* clientCa) {
|
espMqttClientSecure& espMqttClientSecure::setCertificate(const char* clientCa) {
|
||||||
|
#if defined(EMC_CLIENT_SECURE)
|
||||||
_client.client.setCertificate(clientCa);
|
_client.client.setCertificate(clientCa);
|
||||||
|
#endif
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
espMqttClientSecure& espMqttClientSecure::setPrivateKey(const char* privateKey) {
|
espMqttClientSecure& espMqttClientSecure::setPrivateKey(const char* privateKey) {
|
||||||
|
#if defined(EMC_CLIENT_SECURE)
|
||||||
_client.client.setPrivateKey(privateKey);
|
_client.client.setPrivateKey(privateKey);
|
||||||
|
#endif
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
espMqttClientSecure& espMqttClientSecure::setPreSharedKey(const char* pskIdent, const char* psKey) {
|
espMqttClientSecure& espMqttClientSecure::setPreSharedKey(const char* pskIdent, const char* psKey) {
|
||||||
|
#if defined(EMC_CLIENT_SECURE)
|
||||||
_client.client.setPreSharedKey(pskIdent, psKey);
|
_client.client.setPreSharedKey(pskIdent, psKey);
|
||||||
|
#endif
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user