Merge branch 'dev' into dev2

This commit is contained in:
MichaelDvP
2023-12-19 18:35:10 +01:00
29 changed files with 642 additions and 233 deletions

View File

@@ -8,6 +8,10 @@ the LICENSE file.
#pragma once
#ifndef TASMOTA_SDK
#define EMC_CLIENT_SECURE
#endif
#ifndef EMC_TX_TIMEOUT
#define EMC_TX_TIMEOUT 2000
#endif

View File

@@ -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 <WiFiClientSecure.h> // includes IPAddress
#else
#include <WiFiClient.h>
#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

View File

@@ -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;
}

View File

@@ -218,8 +218,10 @@ bool MqttSettingsService::configureMqtt() {
void MqttSettings::read(MqttSettings & settings, JsonObject & root) {
#if CONFIG_IDF_TARGET_ESP32S3
#ifndef TASMOTA_SDK
root["enableTLS"] = settings.enableTLS;
root["rootCA"] = settings.rootCA;
#endif
#endif
root["enabled"] = settings.enabled;
root["host"] = settings.host;
@@ -256,8 +258,10 @@ StateUpdateResult MqttSettings::update(JsonObject & root, MqttSettings & setting
bool changed = false;
#if CONFIG_IDF_TARGET_ESP32S3
#ifndef TASMOTA_SDK
newSettings.enableTLS = root["enableTLS"] | false;
newSettings.rootCA = root["rootCA"] | "";
#endif
#endif
newSettings.enabled = root["enabled"] | FACTORY_MQTT_ENABLED;
newSettings.host = root["host"] | FACTORY_MQTT_HOST;

View File

@@ -19,10 +19,15 @@ void SystemStatus::systemStatus(AsyncWebServerRequest * request) {
root["emsesp_version"] = EMSESP_APP_VERSION;
root["esp_platform"] = EMSESP_PLATFORM;
root["cpu_type"] = ESP.getChipModel();
root["cpu_rev"] = ESP.getChipRevision();
root["cpu_cores"] = ESP.getChipCores();
root["cpu_freq_mhz"] = ESP.getCpuFreqMHz();
root["max_alloc_heap"] = emsesp::EMSESP::system_.getMaxAllocMem();
root["free_heap"] = emsesp::EMSESP::system_.getHeapMem();
root["arduino_version"] = ARDUINO_VERSION;
root["sdk_version"] = ESP.getSdkVersion();
root["partition"] = esp_ota_get_running_partition()->label;
root["flash_chip_size"] = ESP.getFlashChipSize() / 1024;
root["flash_chip_speed"] = ESP.getFlashChipSpeed();
root["app_used"] = emsesp::EMSESP::system_.appUsed();
@@ -39,7 +44,7 @@ void SystemStatus::systemStatus(AsyncWebServerRequest * request) {
const esp_partition_t * partition = esp_partition_find_first(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_APP_FACTORY, NULL);
if (partition != NULL) { // factory partition found
root["has_loader"] = true;
} else { // check for not empty, smaller OTA partition
} else { // check for not empty, smaller OTA partition
partition = esp_ota_get_next_update_partition(NULL);
if (partition) {
uint64_t buffer;