mirror of
https://github.com/Laxilef/OTGateway.git
synced 2026-02-28 04:07:07 +05:00
Compare commits
3 Commits
67adb3b9cf
...
freeze_pro
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6539211b8f | ||
|
|
40fe40eb8a | ||
|
|
3a6bb03456 |
@@ -1,6 +1,6 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
class UpgradeHandler : public AsyncWebHandler {
|
class UpgradeHandler : public RequestHandler {
|
||||||
public:
|
public:
|
||||||
enum class UpgradeType {
|
enum class UpgradeType {
|
||||||
FIRMWARE = 0,
|
FIRMWARE = 0,
|
||||||
@@ -12,7 +12,7 @@ public:
|
|||||||
NO_FILE,
|
NO_FILE,
|
||||||
SUCCESS,
|
SUCCESS,
|
||||||
PROHIBITED,
|
PROHIBITED,
|
||||||
SIZE_MISMATCH,
|
ABORTED,
|
||||||
ERROR_ON_START,
|
ERROR_ON_START,
|
||||||
ERROR_ON_WRITE,
|
ERROR_ON_WRITE,
|
||||||
ERROR_ON_FINISH
|
ERROR_ON_FINISH
|
||||||
@@ -22,21 +22,27 @@ public:
|
|||||||
UpgradeType type;
|
UpgradeType type;
|
||||||
UpgradeStatus status;
|
UpgradeStatus status;
|
||||||
String error;
|
String error;
|
||||||
size_t progress = 0;
|
|
||||||
size_t size = 0;
|
|
||||||
} UpgradeResult;
|
} UpgradeResult;
|
||||||
|
|
||||||
typedef std::function<bool(AsyncWebServerRequest *request, UpgradeType)> BeforeUpgradeCallback;
|
typedef std::function<bool(HTTPMethod, const String&)> CanHandleCallback;
|
||||||
typedef std::function<void(AsyncWebServerRequest *request, const UpgradeResult&, const UpgradeResult&)> AfterUpgradeCallback;
|
typedef std::function<bool(const String&)> CanUploadCallback;
|
||||||
|
typedef std::function<bool(UpgradeType)> BeforeUpgradeCallback;
|
||||||
|
typedef std::function<void(const UpgradeResult&, const UpgradeResult&)> AfterUpgradeCallback;
|
||||||
|
|
||||||
UpgradeHandler(AsyncURIMatcher uri) : uri(uri) {}
|
UpgradeHandler(const char* uri) {
|
||||||
|
this->uri = uri;
|
||||||
bool canHandle(AsyncWebServerRequest *request) const override final {
|
|
||||||
if (!request->isHTTP()) {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return this->uri.matches(request);
|
UpgradeHandler* setCanHandleCallback(CanHandleCallback callback = nullptr) {
|
||||||
|
this->canHandleCallback = callback;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
UpgradeHandler* setCanUploadCallback(CanUploadCallback callback = nullptr) {
|
||||||
|
this->canUploadCallback = callback;
|
||||||
|
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
UpgradeHandler* setBeforeUpgradeCallback(BeforeUpgradeCallback callback = nullptr) {
|
UpgradeHandler* setBeforeUpgradeCallback(BeforeUpgradeCallback callback = nullptr) {
|
||||||
@@ -51,9 +57,29 @@ public:
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleRequest(AsyncWebServerRequest *request) override final {
|
#if defined(ARDUINO_ARCH_ESP32)
|
||||||
|
bool canHandle(WebServer &server, HTTPMethod method, const String &uri) override {
|
||||||
|
return this->canHandle(method, uri);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
bool canHandle(HTTPMethod method, const String& uri) override {
|
||||||
|
return method == HTTP_POST && uri.equals(this->uri) && (!this->canHandleCallback || this->canHandleCallback(method, uri));
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(ARDUINO_ARCH_ESP32)
|
||||||
|
bool canUpload(WebServer &server, const String &uri) override {
|
||||||
|
return this->canUpload(uri);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
bool canUpload(const String& uri) override {
|
||||||
|
return uri.equals(this->uri) && (!this->canUploadCallback || this->canUploadCallback(uri));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool handle(WebServer& server, HTTPMethod method, const String& uri) override {
|
||||||
if (this->afterUpgradeCallback) {
|
if (this->afterUpgradeCallback) {
|
||||||
this->afterUpgradeCallback(request, this->firmwareResult, this->filesystemResult);
|
this->afterUpgradeCallback(this->firmwareResult, this->filesystemResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->firmwareResult.status = UpgradeStatus::NONE;
|
this->firmwareResult.status = UpgradeStatus::NONE;
|
||||||
@@ -61,147 +87,129 @@ public:
|
|||||||
|
|
||||||
this->filesystemResult.status = UpgradeStatus::NONE;
|
this->filesystemResult.status = UpgradeStatus::NONE;
|
||||||
this->filesystemResult.error.clear();
|
this->filesystemResult.error.clear();
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleUpload(AsyncWebServerRequest *request, const String &fileName, size_t index, uint8_t *data, size_t dataLength, bool isFinal) override final {
|
void upload(WebServer& server, const String& uri, HTTPUpload& upload) override {
|
||||||
UpgradeResult* result = nullptr;
|
UpgradeResult* result;
|
||||||
|
if (upload.name.equals(F("firmware"))) {
|
||||||
if (!request->hasParam(asyncsrv::T_name, true, true)) {
|
|
||||||
// Missing content-disposition 'name' parameter
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto& pName = request->getParam(asyncsrv::T_name, true, true)->value();
|
|
||||||
if (pName.equals("fw")) {
|
|
||||||
result = &this->firmwareResult;
|
result = &this->firmwareResult;
|
||||||
|
|
||||||
if (!index) {
|
} else if (upload.name.equals(F("filesystem"))) {
|
||||||
result->progress = 0;
|
|
||||||
result->size = request->hasParam("fw_size", true)
|
|
||||||
? request->getParam("fw_size", true)->value().toInt()
|
|
||||||
: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (pName.equals("fs")) {
|
|
||||||
result = &this->filesystemResult;
|
result = &this->filesystemResult;
|
||||||
|
|
||||||
if (!index) {
|
|
||||||
result->progress = 0;
|
|
||||||
result->size = request->hasParam("fs_size", true)
|
|
||||||
? request->getParam("fs_size", true)->value().toInt()
|
|
||||||
: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Unknown parameter name
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check result status
|
|
||||||
if (result->status != UpgradeStatus::NONE) {
|
if (result->status != UpgradeStatus::NONE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->beforeUpgradeCallback && !this->beforeUpgradeCallback(request, result->type)) {
|
if (this->beforeUpgradeCallback && !this->beforeUpgradeCallback(result->type)) {
|
||||||
result->status = UpgradeStatus::PROHIBITED;
|
result->status = UpgradeStatus::PROHIBITED;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fileName.length()) {
|
if (!upload.filename.length()) {
|
||||||
result->status = UpgradeStatus::NO_FILE;
|
result->status = UpgradeStatus::NO_FILE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!index) {
|
if (upload.status == UPLOAD_FILE_START) {
|
||||||
// reset
|
// reset
|
||||||
if (Update.isRunning()) {
|
if (Update.isRunning()) {
|
||||||
Update.end(false);
|
Update.end(false);
|
||||||
Update.clearError();
|
Update.clearError();
|
||||||
}
|
}
|
||||||
|
|
||||||
// try begin
|
|
||||||
bool begin = false;
|
bool begin = false;
|
||||||
|
#ifdef ARDUINO_ARCH_ESP8266
|
||||||
|
Update.runAsync(true);
|
||||||
|
|
||||||
|
if (result->type == UpgradeType::FIRMWARE) {
|
||||||
|
begin = Update.begin((ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000, U_FLASH);
|
||||||
|
|
||||||
|
} else if (result->type == UpgradeType::FILESYSTEM) {
|
||||||
|
close_all_fs();
|
||||||
|
begin = Update.begin((size_t)FS_end - (size_t)FS_start, U_FS);
|
||||||
|
}
|
||||||
|
#elif defined(ARDUINO_ARCH_ESP32)
|
||||||
if (result->type == UpgradeType::FIRMWARE) {
|
if (result->type == UpgradeType::FIRMWARE) {
|
||||||
begin = Update.begin(UPDATE_SIZE_UNKNOWN, U_FLASH);
|
begin = Update.begin(UPDATE_SIZE_UNKNOWN, U_FLASH);
|
||||||
|
|
||||||
} else if (result->type == UpgradeType::FILESYSTEM) {
|
} else if (result->type == UpgradeType::FILESYSTEM) {
|
||||||
begin = Update.begin(UPDATE_SIZE_UNKNOWN, U_SPIFFS);
|
begin = Update.begin(UPDATE_SIZE_UNKNOWN, U_SPIFFS);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!begin || Update.hasError()) {
|
if (!begin || Update.hasError()) {
|
||||||
result->status = UpgradeStatus::ERROR_ON_START;
|
result->status = UpgradeStatus::ERROR_ON_START;
|
||||||
|
#ifdef ARDUINO_ARCH_ESP8266
|
||||||
|
result->error = Update.getErrorString();
|
||||||
|
#else
|
||||||
result->error = Update.errorString();
|
result->error = Update.errorString();
|
||||||
|
#endif
|
||||||
|
|
||||||
Log.serrorln(FPSTR(L_PORTAL_OTA), "File '%s', on start: %s", fileName.c_str(), result->error.c_str());
|
Log.serrorln(FPSTR(L_PORTAL_OTA), F("File '%s', on start: %s"), upload.filename.c_str(), result->error.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.sinfoln(FPSTR(L_PORTAL_OTA), "File '%s', started", fileName.c_str());
|
Log.sinfoln(FPSTR(L_PORTAL_OTA), F("File '%s', started"), upload.filename.c_str());
|
||||||
}
|
|
||||||
|
|
||||||
if (dataLength) {
|
} else if (upload.status == UPLOAD_FILE_WRITE) {
|
||||||
if (Update.write(data, dataLength) != dataLength) {
|
if (Update.write(upload.buf, upload.currentSize) != upload.currentSize) {
|
||||||
Update.end(false);
|
Update.end(false);
|
||||||
|
|
||||||
result->status = UpgradeStatus::ERROR_ON_WRITE;
|
result->status = UpgradeStatus::ERROR_ON_WRITE;
|
||||||
|
#ifdef ARDUINO_ARCH_ESP8266
|
||||||
|
result->error = Update.getErrorString();
|
||||||
|
#else
|
||||||
result->error = Update.errorString();
|
result->error = Update.errorString();
|
||||||
|
#endif
|
||||||
|
|
||||||
Log.serrorln(
|
Log.serrorln(
|
||||||
FPSTR(L_PORTAL_OTA), "File '%s', on write %d bytes, %d of %d bytes",
|
FPSTR(L_PORTAL_OTA),
|
||||||
fileName.c_str(),
|
F("File '%s', on writing %d bytes: %s"),
|
||||||
dataLength,
|
upload.filename.c_str(), upload.totalSize, result->error.c_str()
|
||||||
result->progress + dataLength,
|
|
||||||
result->size
|
|
||||||
);
|
);
|
||||||
return;
|
|
||||||
}
|
} else {
|
||||||
|
Log.sinfoln(FPSTR(L_PORTAL_OTA), F("File '%s', writed %d bytes"), upload.filename.c_str(), upload.totalSize);
|
||||||
result->progress += dataLength;
|
|
||||||
Log.sinfoln(
|
|
||||||
FPSTR(L_PORTAL_OTA), "File '%s', write %d bytes, %d of %d bytes",
|
|
||||||
fileName.c_str(),
|
|
||||||
dataLength,
|
|
||||||
result->progress,
|
|
||||||
result->size
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result->size > 0) {
|
|
||||||
if (result->progress > result->size || (isFinal && result->progress < result->size)) {
|
|
||||||
Update.end(false);
|
|
||||||
result->status = UpgradeStatus::SIZE_MISMATCH;
|
|
||||||
|
|
||||||
Log.serrorln(
|
|
||||||
FPSTR(L_PORTAL_OTA), "File '%s', size mismatch: %d of %d bytes",
|
|
||||||
fileName.c_str(),
|
|
||||||
result->progress,
|
|
||||||
result->size
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isFinal) {
|
|
||||||
if (!Update.end(true)) {
|
|
||||||
result->status = UpgradeStatus::ERROR_ON_FINISH;
|
|
||||||
result->error = Update.errorString();
|
|
||||||
|
|
||||||
Log.serrorln(FPSTR(L_PORTAL_OTA), "File '%s', on finish: %s", fileName.c_str(), result->error);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else if (upload.status == UPLOAD_FILE_END) {
|
||||||
|
if (Update.end(true)) {
|
||||||
result->status = UpgradeStatus::SUCCESS;
|
result->status = UpgradeStatus::SUCCESS;
|
||||||
Log.sinfoln(FPSTR(L_PORTAL_OTA), "File '%s': finish", fileName.c_str());
|
|
||||||
}
|
Log.sinfoln(FPSTR(L_PORTAL_OTA), F("File '%s': finish"), upload.filename.c_str());
|
||||||
|
|
||||||
|
} else {
|
||||||
|
result->status = UpgradeStatus::ERROR_ON_FINISH;
|
||||||
|
#ifdef ARDUINO_ARCH_ESP8266
|
||||||
|
result->error = Update.getErrorString();
|
||||||
|
#else
|
||||||
|
result->error = Update.errorString();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Log.serrorln(FPSTR(L_PORTAL_OTA), F("File '%s', on finish: %s"), upload.filename.c_str(), result->error);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isRequestHandlerTrivial() const override final {
|
} else if (upload.status == UPLOAD_FILE_ABORTED) {
|
||||||
return false;
|
Update.end(false);
|
||||||
|
result->status = UpgradeStatus::ABORTED;
|
||||||
|
|
||||||
|
Log.serrorln(FPSTR(L_PORTAL_OTA), F("File '%s': aborted"), upload.filename.c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
CanHandleCallback canHandleCallback;
|
||||||
|
CanUploadCallback canUploadCallback;
|
||||||
BeforeUpgradeCallback beforeUpgradeCallback;
|
BeforeUpgradeCallback beforeUpgradeCallback;
|
||||||
AfterUpgradeCallback afterUpgradeCallback;
|
AfterUpgradeCallback afterUpgradeCallback;
|
||||||
AsyncURIMatcher uri;
|
const char* uri = nullptr;
|
||||||
|
|
||||||
UpgradeResult firmwareResult{UpgradeType::FIRMWARE, UpgradeStatus::NONE};
|
UpgradeResult firmwareResult{UpgradeType::FIRMWARE, UpgradeStatus::NONE};
|
||||||
UpgradeResult filesystemResult{UpgradeType::FILESYSTEM, UpgradeStatus::NONE};
|
UpgradeResult filesystemResult{UpgradeType::FILESYSTEM, UpgradeStatus::NONE};
|
||||||
|
|||||||
310
platformio.ini
310
platformio.ini
@@ -1,41 +1,46 @@
|
|||||||
|
; PlatformIO Project Configuration File
|
||||||
|
;
|
||||||
|
; Build options: build flags, source filter
|
||||||
|
; Upload options: custom upload port, speed and extra flags
|
||||||
|
; Library options: dependencies, extra library storages
|
||||||
|
; Advanced options: extra scripting
|
||||||
|
;
|
||||||
|
; Please visit documentation for the other options and examples
|
||||||
|
; https://docs.platformio.org/page/projectconf.html
|
||||||
|
|
||||||
[platformio]
|
[platformio]
|
||||||
;extra_configs = secrets.ini
|
;extra_configs = secrets.ini
|
||||||
extra_configs = secrets.default.ini
|
extra_configs = secrets.default.ini
|
||||||
core_dir = .pio
|
core_dir = .pio
|
||||||
|
|
||||||
[env]
|
[env]
|
||||||
version = 1.6.0-passiveble
|
version = 1.6.0
|
||||||
framework = arduino
|
framework = arduino
|
||||||
lib_deps = ESP32Async/AsyncTCP@^3.4.10
|
lib_deps =
|
||||||
ESP32Async/ESPAsyncWebServer@^3.9.4
|
|
||||||
mathieucarbou/MycilaWebSerial@^8.2.0
|
|
||||||
bblanchon/ArduinoJson@^7.4.2
|
bblanchon/ArduinoJson@^7.4.2
|
||||||
;ihormelnyk/OpenTherm Library@^1.1.5
|
;ihormelnyk/OpenTherm Library@^1.1.5
|
||||||
https://github.com/Laxilef/opentherm_library#esp32_timer
|
https://github.com/Laxilef/opentherm_library#esp32_timer
|
||||||
arduino-libraries/ArduinoMqttClient@^0.1.8
|
arduino-libraries/ArduinoMqttClient@^0.1.8
|
||||||
|
lennarthennigs/ESP Telnet@^2.2.3
|
||||||
gyverlibs/FileData@^1.0.3
|
gyverlibs/FileData@^1.0.3
|
||||||
gyverlibs/GyverPID@^3.3.2
|
gyverlibs/GyverPID@^3.3.2
|
||||||
gyverlibs/GyverBlinker@^1.1.1
|
gyverlibs/GyverBlinker@^1.1.1
|
||||||
pstolarz/OneWireNg@^0.14.1
|
pstolarz/OneWireNg@^0.14.1
|
||||||
;milesburton/DallasTemperature@^4.0.5
|
;milesburton/DallasTemperature@^4.0.5
|
||||||
https://github.com/Laxilef/Arduino-Temperature-Control-Library#fix_85c
|
https://github.com/Laxilef/Arduino-Temperature-Control-Library#fix_85c
|
||||||
;laxilef/TinyLogger@^1.1.1
|
laxilef/TinyLogger@^1.1.1
|
||||||
https://github.com/Laxilef/TinyLogger#custom_handlers
|
lib_ignore = OneWire
|
||||||
lib_ignore = paulstoffregen/OneWire
|
|
||||||
build_type = ${secrets.build_type}
|
build_type = ${secrets.build_type}
|
||||||
build_flags = -mtext-section-literals
|
build_flags =
|
||||||
-Wno-deprecated-declarations
|
-mtext-section-literals
|
||||||
-D MQTT_CLIENT_STD_FUNCTION_CALLBACK=1
|
-D MQTT_CLIENT_STD_FUNCTION_CALLBACK=1
|
||||||
;-D DEBUG_ESP_CORE -D DEBUG_ESP_WIFI -D DEBUG_ESP_HTTP_SERVER -D DEBUG_ESP_PORT=Serial
|
;-D DEBUG_ESP_CORE -D DEBUG_ESP_WIFI -D DEBUG_ESP_HTTP_SERVER -D DEBUG_ESP_PORT=Serial
|
||||||
-D BUILD_VERSION='"${this.version}"'
|
-D BUILD_VERSION='"${this.version}"'
|
||||||
-D BUILD_ENV='"$PIOENV"'
|
-D BUILD_ENV='"$PIOENV"'
|
||||||
-D CONFIG_ASYNC_TCP_STACK_SIZE=4096
|
|
||||||
-D ARDUINOJSON_USE_DOUBLE=0
|
|
||||||
-D ARDUINOJSON_USE_LONG_LONG=0
|
|
||||||
-D TINYLOGGER_GLOBAL
|
|
||||||
-D DEFAULT_SERIAL_ENABLED=${secrets.serial_enabled}
|
-D DEFAULT_SERIAL_ENABLED=${secrets.serial_enabled}
|
||||||
-D DEFAULT_SERIAL_BAUD=${secrets.serial_baud}
|
-D DEFAULT_SERIAL_BAUD=${secrets.serial_baud}
|
||||||
-D DEFAULT_WEBSERIAL_ENABLED=${secrets.webserial_enabled}
|
-D DEFAULT_TELNET_ENABLED=${secrets.telnet_enabled}
|
||||||
|
-D DEFAULT_TELNET_PORT=${secrets.telnet_port}
|
||||||
-D DEFAULT_LOG_LEVEL=${secrets.log_level}
|
-D DEFAULT_LOG_LEVEL=${secrets.log_level}
|
||||||
-D DEFAULT_HOSTNAME='"${secrets.hostname}"'
|
-D DEFAULT_HOSTNAME='"${secrets.hostname}"'
|
||||||
-D DEFAULT_AP_SSID='"${secrets.ap_ssid}"'
|
-D DEFAULT_AP_SSID='"${secrets.ap_ssid}"'
|
||||||
@@ -53,53 +58,57 @@ build_flags = -mtext-section-literals
|
|||||||
upload_speed = 921600
|
upload_speed = 921600
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
;monitor_filters = direct
|
;monitor_filters = direct
|
||||||
monitor_filters = esp32_exception_decoder
|
monitor_filters =
|
||||||
|
esp32_exception_decoder
|
||||||
|
esp8266_exception_decoder
|
||||||
board_build.flash_mode = dio
|
board_build.flash_mode = dio
|
||||||
board_build.filesystem = littlefs
|
board_build.filesystem = littlefs
|
||||||
check_tool = ; pvs-studio
|
check_tool = ; pvs-studio
|
||||||
check_flags = ;pvs-studio: --analysis-mode=4 --exclude-path=./.pio/libdeps
|
check_flags =
|
||||||
|
; pvs-studio:
|
||||||
|
; --analysis-mode=4
|
||||||
|
; --exclude-path=./.pio/libdeps
|
||||||
|
|
||||||
; Defaults
|
; Defaults
|
||||||
|
[esp8266_defaults]
|
||||||
|
platform = espressif8266@^4.2.1
|
||||||
|
platform_packages = ${env.platform_packages}
|
||||||
|
lib_deps =
|
||||||
|
${env.lib_deps}
|
||||||
|
nrwiersma/ESP8266Scheduler@^1.2
|
||||||
|
lib_ignore = ${env.lib_ignore}
|
||||||
|
extra_scripts =
|
||||||
|
post:tools/build.py
|
||||||
|
build_type = ${env.build_type}
|
||||||
|
build_flags =
|
||||||
|
${env.build_flags}
|
||||||
|
-D PIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY
|
||||||
|
;-D PIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH_LOW_FLASH
|
||||||
|
-D PIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK305
|
||||||
|
board_build.ldscript = eagle.flash.4m1m.ld
|
||||||
|
check_tool = ${env.check_tool}
|
||||||
|
check_flags = ${env.check_flags}
|
||||||
|
|
||||||
[esp32_defaults]
|
[esp32_defaults]
|
||||||
|
;platform = espressif32@^6.7
|
||||||
|
;platform = https://github.com/platformio/platform-espressif32.git
|
||||||
|
;platform_packages =
|
||||||
|
; framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#3.0.5
|
||||||
|
; framework-arduinoespressif32-libs @ https://github.com/espressif/esp32-arduino-lib-builder/releases/download/idf-release_v5.1/esp32-arduino-libs-idf-release_v5.1-33fbade6.zip
|
||||||
platform = https://github.com/pioarduino/platform-espressif32/releases/download/55.03.36/platform-espressif32.zip
|
platform = https://github.com/pioarduino/platform-espressif32/releases/download/55.03.36/platform-espressif32.zip
|
||||||
platform_packages = ${env.platform_packages}
|
platform_packages = ${env.platform_packages}
|
||||||
board_build.partitions = esp32_partitions.csv
|
board_build.partitions = esp32_partitions.csv
|
||||||
lib_deps = ${env.lib_deps}
|
lib_deps =
|
||||||
|
${env.lib_deps}
|
||||||
laxilef/ESP32Scheduler@^1.0.1
|
laxilef/ESP32Scheduler@^1.0.1
|
||||||
nimble_lib = https://github.com/h2zero/NimBLE-Arduino
|
nimble_lib = h2zero/NimBLE-Arduino@2.3.7
|
||||||
lib_ignore = ${env.lib_ignore}
|
lib_ignore = ${env.lib_ignore}
|
||||||
BluetoothSerial
|
extra_scripts =
|
||||||
SimpleBLE
|
post:tools/esp32.py
|
||||||
ESP RainMaker
|
|
||||||
RainMaker
|
|
||||||
ESP Insights
|
|
||||||
Insights
|
|
||||||
Zigbee
|
|
||||||
Matter
|
|
||||||
OpenThread
|
|
||||||
dsp
|
|
||||||
custom_component_remove = espressif/esp_hosted
|
|
||||||
espressif/esp_wifi_remote
|
|
||||||
espressif/esp-dsp
|
|
||||||
espressif/esp_modem
|
|
||||||
espressif/esp_rainmaker
|
|
||||||
espressif/rmaker_common
|
|
||||||
espressif/esp_insights
|
|
||||||
espressif/esp_diag_data_store
|
|
||||||
espressif/esp_diagnostics
|
|
||||||
espressif/libsodium
|
|
||||||
espressif/esp-modbus
|
|
||||||
espressif/esp-cbor
|
|
||||||
espressif/esp-sr
|
|
||||||
espressif/esp32-camera
|
|
||||||
espressif/qrcode
|
|
||||||
espressif/esp-zboss-lib
|
|
||||||
espressif/esp-zigbee-lib
|
|
||||||
chmorgan/esp-libhelix-mp3
|
|
||||||
extra_scripts = post:tools/esp32.py
|
|
||||||
post:tools/build.py
|
post:tools/build.py
|
||||||
build_type = ${env.build_type}
|
build_type = ${env.build_type}
|
||||||
build_flags = ${env.build_flags}
|
build_flags =
|
||||||
|
${env.build_flags}
|
||||||
-D CORE_DEBUG_LEVEL=0
|
-D CORE_DEBUG_LEVEL=0
|
||||||
-Wl,--wrap=esp_panic_handler
|
-Wl,--wrap=esp_panic_handler
|
||||||
check_tool = ${env.check_tool}
|
check_tool = ${env.check_tool}
|
||||||
@@ -107,11 +116,99 @@ check_flags = ${env.check_flags}
|
|||||||
|
|
||||||
|
|
||||||
; Boards
|
; Boards
|
||||||
|
[env:d1_mini]
|
||||||
|
platform = ${esp8266_defaults.platform}
|
||||||
|
platform_packages = ${esp8266_defaults.platform_packages}
|
||||||
|
board = d1_mini
|
||||||
|
lib_deps = ${esp8266_defaults.lib_deps}
|
||||||
|
lib_ignore = ${esp8266_defaults.lib_ignore}
|
||||||
|
extra_scripts = ${esp8266_defaults.extra_scripts}
|
||||||
|
board_build.ldscript = ${esp8266_defaults.board_build.ldscript}
|
||||||
|
build_type = ${esp8266_defaults.build_type}
|
||||||
|
build_flags =
|
||||||
|
${esp8266_defaults.build_flags}
|
||||||
|
-D DEFAULT_OT_IN_GPIO=4
|
||||||
|
-D DEFAULT_OT_OUT_GPIO=5
|
||||||
|
-D DEFAULT_SENSOR_OUTDOOR_GPIO=12
|
||||||
|
-D DEFAULT_SENSOR_INDOOR_GPIO=14
|
||||||
|
-D DEFAULT_STATUS_LED_GPIO=13
|
||||||
|
-D DEFAULT_OT_RX_LED_GPIO=15
|
||||||
|
check_tool = ${esp8266_defaults.check_tool}
|
||||||
|
check_flags = ${esp8266_defaults.check_flags}
|
||||||
|
|
||||||
|
[env:d1_mini_lite]
|
||||||
|
platform = ${esp8266_defaults.platform}
|
||||||
|
platform_packages = ${esp8266_defaults.platform_packages}
|
||||||
|
board = d1_mini_lite
|
||||||
|
lib_deps = ${esp8266_defaults.lib_deps}
|
||||||
|
lib_ignore = ${esp8266_defaults.lib_ignore}
|
||||||
|
extra_scripts = ${esp8266_defaults.extra_scripts}
|
||||||
|
board_build.ldscript = ${esp8266_defaults.board_build.ldscript}
|
||||||
|
build_type = ${esp8266_defaults.build_type}
|
||||||
|
build_flags =
|
||||||
|
${esp8266_defaults.build_flags}
|
||||||
|
-D DEFAULT_OT_IN_GPIO=4
|
||||||
|
-D DEFAULT_OT_OUT_GPIO=5
|
||||||
|
-D DEFAULT_SENSOR_OUTDOOR_GPIO=12
|
||||||
|
-D DEFAULT_SENSOR_INDOOR_GPIO=14
|
||||||
|
-D DEFAULT_STATUS_LED_GPIO=13
|
||||||
|
-D DEFAULT_OT_RX_LED_GPIO=15
|
||||||
|
check_tool = ${esp8266_defaults.check_tool}
|
||||||
|
check_flags = ${esp8266_defaults.check_flags}
|
||||||
|
|
||||||
|
[env:d1_mini_pro]
|
||||||
|
platform = ${esp8266_defaults.platform}
|
||||||
|
platform_packages = ${esp8266_defaults.platform_packages}
|
||||||
|
board = d1_mini_pro
|
||||||
|
lib_deps = ${esp8266_defaults.lib_deps}
|
||||||
|
lib_ignore = ${esp8266_defaults.lib_ignore}
|
||||||
|
extra_scripts = ${esp8266_defaults.extra_scripts}
|
||||||
|
board_build.ldscript = ${esp8266_defaults.board_build.ldscript}
|
||||||
|
build_type = ${esp8266_defaults.build_type}
|
||||||
|
build_flags =
|
||||||
|
${esp8266_defaults.build_flags}
|
||||||
|
-D DEFAULT_OT_IN_GPIO=4
|
||||||
|
-D DEFAULT_OT_OUT_GPIO=5
|
||||||
|
-D DEFAULT_SENSOR_OUTDOOR_GPIO=12
|
||||||
|
-D DEFAULT_SENSOR_INDOOR_GPIO=14
|
||||||
|
-D DEFAULT_STATUS_LED_GPIO=13
|
||||||
|
-D DEFAULT_OT_RX_LED_GPIO=15
|
||||||
|
check_tool = ${esp8266_defaults.check_tool}
|
||||||
|
check_flags = ${esp8266_defaults.check_flags}
|
||||||
|
|
||||||
|
[env:nodemcu_8266]
|
||||||
|
platform = ${esp8266_defaults.platform}
|
||||||
|
platform_packages = ${esp8266_defaults.platform_packages}
|
||||||
|
board = nodemcuv2
|
||||||
|
lib_deps = ${esp8266_defaults.lib_deps}
|
||||||
|
lib_ignore = ${esp8266_defaults.lib_ignore}
|
||||||
|
extra_scripts = ${esp8266_defaults.extra_scripts}
|
||||||
|
board_build.ldscript = ${esp8266_defaults.board_build.ldscript}
|
||||||
|
build_type = ${esp8266_defaults.build_type}
|
||||||
|
build_flags =
|
||||||
|
${esp8266_defaults.build_flags}
|
||||||
|
-D DEFAULT_OT_IN_GPIO=13
|
||||||
|
-D DEFAULT_OT_OUT_GPIO=15
|
||||||
|
-D DEFAULT_SENSOR_OUTDOOR_GPIO=12
|
||||||
|
-D DEFAULT_SENSOR_INDOOR_GPIO=4
|
||||||
|
-D DEFAULT_STATUS_LED_GPIO=2
|
||||||
|
-D DEFAULT_OT_RX_LED_GPIO=16
|
||||||
|
check_tool = ${esp8266_defaults.check_tool}
|
||||||
|
check_flags = ${esp8266_defaults.check_flags}
|
||||||
|
|
||||||
[env:s2_mini]
|
[env:s2_mini]
|
||||||
extends = esp32_defaults
|
platform = ${esp32_defaults.platform}
|
||||||
|
platform_packages = ${esp32_defaults.platform_packages}
|
||||||
board = lolin_s2_mini
|
board = lolin_s2_mini
|
||||||
build_unflags = -DARDUINO_USB_MODE=1
|
board_build.partitions = ${esp32_defaults.board_build.partitions}
|
||||||
build_flags = ${esp32_defaults.build_flags}
|
lib_deps = ${esp32_defaults.lib_deps}
|
||||||
|
lib_ignore = ${esp32_defaults.lib_ignore}
|
||||||
|
extra_scripts = ${esp32_defaults.extra_scripts}
|
||||||
|
build_unflags =
|
||||||
|
-DARDUINO_USB_MODE=1
|
||||||
|
build_type = ${esp32_defaults.build_type}
|
||||||
|
build_flags =
|
||||||
|
${esp32_defaults.build_flags}
|
||||||
-D ARDUINO_USB_MODE=0
|
-D ARDUINO_USB_MODE=0
|
||||||
-D ARDUINO_USB_CDC_ON_BOOT=1
|
-D ARDUINO_USB_CDC_ON_BOOT=1
|
||||||
-D DEFAULT_OT_IN_GPIO=33
|
-D DEFAULT_OT_IN_GPIO=33
|
||||||
@@ -120,14 +217,24 @@ build_flags = ${esp32_defaults.build_flags}
|
|||||||
-D DEFAULT_SENSOR_INDOOR_GPIO=7
|
-D DEFAULT_SENSOR_INDOOR_GPIO=7
|
||||||
-D DEFAULT_STATUS_LED_GPIO=11
|
-D DEFAULT_STATUS_LED_GPIO=11
|
||||||
-D DEFAULT_OT_RX_LED_GPIO=12
|
-D DEFAULT_OT_RX_LED_GPIO=12
|
||||||
|
check_tool = ${esp32_defaults.check_tool}
|
||||||
|
check_flags = ${esp32_defaults.check_flags}
|
||||||
|
|
||||||
[env:s3_mini]
|
[env:s3_mini]
|
||||||
extends = esp32_defaults
|
platform = ${esp32_defaults.platform}
|
||||||
|
platform_packages = ${esp32_defaults.platform_packages}
|
||||||
board = lolin_s3_mini
|
board = lolin_s3_mini
|
||||||
lib_deps = ${esp32_defaults.lib_deps}
|
board_build.partitions = ${esp32_defaults.board_build.partitions}
|
||||||
|
lib_deps =
|
||||||
|
${esp32_defaults.lib_deps}
|
||||||
${esp32_defaults.nimble_lib}
|
${esp32_defaults.nimble_lib}
|
||||||
build_unflags = -DARDUINO_USB_MODE=1
|
lib_ignore = ${esp32_defaults.lib_ignore}
|
||||||
build_flags = ${esp32_defaults.build_flags}
|
extra_scripts = ${esp32_defaults.extra_scripts}
|
||||||
|
build_unflags =
|
||||||
|
-DARDUINO_USB_MODE=1
|
||||||
|
build_type = ${esp32_defaults.build_type}
|
||||||
|
build_flags =
|
||||||
|
${esp32_defaults.build_flags}
|
||||||
-D ARDUINO_USB_MODE=0
|
-D ARDUINO_USB_MODE=0
|
||||||
-D ARDUINO_USB_CDC_ON_BOOT=1
|
-D ARDUINO_USB_CDC_ON_BOOT=1
|
||||||
-D MYNEWT_VAL_BLE_EXT_ADV=1
|
-D MYNEWT_VAL_BLE_EXT_ADV=1
|
||||||
@@ -138,14 +245,24 @@ build_flags = ${esp32_defaults.build_flags}
|
|||||||
-D DEFAULT_SENSOR_INDOOR_GPIO=12
|
-D DEFAULT_SENSOR_INDOOR_GPIO=12
|
||||||
-D DEFAULT_STATUS_LED_GPIO=11
|
-D DEFAULT_STATUS_LED_GPIO=11
|
||||||
-D DEFAULT_OT_RX_LED_GPIO=10
|
-D DEFAULT_OT_RX_LED_GPIO=10
|
||||||
|
check_tool = ${esp32_defaults.check_tool}
|
||||||
|
check_flags = ${esp32_defaults.check_flags}
|
||||||
|
|
||||||
[env:c3_mini]
|
[env:c3_mini]
|
||||||
extends = esp32_defaults
|
platform = ${esp32_defaults.platform}
|
||||||
|
platform_packages = ${esp32_defaults.platform_packages}
|
||||||
board = lolin_c3_mini
|
board = lolin_c3_mini
|
||||||
lib_deps = ${esp32_defaults.lib_deps}
|
board_build.partitions = ${esp32_defaults.board_build.partitions}
|
||||||
|
lib_deps =
|
||||||
|
${esp32_defaults.lib_deps}
|
||||||
${esp32_defaults.nimble_lib}
|
${esp32_defaults.nimble_lib}
|
||||||
build_unflags = -mtext-section-literals
|
lib_ignore = ${esp32_defaults.lib_ignore}
|
||||||
build_flags = ${esp32_defaults.build_flags}
|
extra_scripts = ${esp32_defaults.extra_scripts}
|
||||||
|
build_unflags =
|
||||||
|
-mtext-section-literals
|
||||||
|
build_type = ${esp32_defaults.build_type}
|
||||||
|
build_flags =
|
||||||
|
${esp32_defaults.build_flags}
|
||||||
-D MYNEWT_VAL_BLE_EXT_ADV=1
|
-D MYNEWT_VAL_BLE_EXT_ADV=1
|
||||||
-D USE_BLE=1
|
-D USE_BLE=1
|
||||||
-D DEFAULT_OT_IN_GPIO=8
|
-D DEFAULT_OT_IN_GPIO=8
|
||||||
@@ -154,13 +271,22 @@ build_flags = ${esp32_defaults.build_flags}
|
|||||||
-D DEFAULT_SENSOR_INDOOR_GPIO=1
|
-D DEFAULT_SENSOR_INDOOR_GPIO=1
|
||||||
-D DEFAULT_STATUS_LED_GPIO=4
|
-D DEFAULT_STATUS_LED_GPIO=4
|
||||||
-D DEFAULT_OT_RX_LED_GPIO=5
|
-D DEFAULT_OT_RX_LED_GPIO=5
|
||||||
|
check_tool = ${esp32_defaults.check_tool}
|
||||||
|
check_flags = ${esp32_defaults.check_flags}
|
||||||
|
|
||||||
[env:nodemcu_32]
|
[env:nodemcu_32]
|
||||||
extends = esp32_defaults
|
platform = ${esp32_defaults.platform}
|
||||||
|
platform_packages = ${esp32_defaults.platform_packages}
|
||||||
board = nodemcu-32s
|
board = nodemcu-32s
|
||||||
lib_deps = ${esp32_defaults.lib_deps}
|
board_build.partitions = ${esp32_defaults.board_build.partitions}
|
||||||
|
lib_deps =
|
||||||
|
${esp32_defaults.lib_deps}
|
||||||
${esp32_defaults.nimble_lib}
|
${esp32_defaults.nimble_lib}
|
||||||
build_flags = ${esp32_defaults.build_flags}
|
lib_ignore = ${esp32_defaults.lib_ignore}
|
||||||
|
extra_scripts = ${esp32_defaults.extra_scripts}
|
||||||
|
build_type = ${esp32_defaults.build_type}
|
||||||
|
build_flags =
|
||||||
|
${esp32_defaults.build_flags}
|
||||||
-D USE_BLE=1
|
-D USE_BLE=1
|
||||||
-D DEFAULT_OT_IN_GPIO=16
|
-D DEFAULT_OT_IN_GPIO=16
|
||||||
-D DEFAULT_OT_OUT_GPIO=4
|
-D DEFAULT_OT_OUT_GPIO=4
|
||||||
@@ -168,17 +294,26 @@ build_flags = ${esp32_defaults.build_flags}
|
|||||||
-D DEFAULT_SENSOR_INDOOR_GPIO=26
|
-D DEFAULT_SENSOR_INDOOR_GPIO=26
|
||||||
-D DEFAULT_STATUS_LED_GPIO=2
|
-D DEFAULT_STATUS_LED_GPIO=2
|
||||||
-D DEFAULT_OT_RX_LED_GPIO=19
|
-D DEFAULT_OT_RX_LED_GPIO=19
|
||||||
|
check_tool = ${esp32_defaults.check_tool}
|
||||||
|
check_flags = ${esp32_defaults.check_flags}
|
||||||
|
|
||||||
[env:nodemcu_32_160mhz]
|
[env:nodemcu_32_160mhz]
|
||||||
extends = env:nodemcu_32
|
extends = env:nodemcu_32
|
||||||
board_build.f_cpu = 160000000L ; set frequency to 160MHz
|
board_build.f_cpu = 160000000L ; set frequency to 160MHz
|
||||||
|
|
||||||
[env:d1_mini32]
|
[env:d1_mini32]
|
||||||
extends = esp32_defaults
|
platform = ${esp32_defaults.platform}
|
||||||
|
platform_packages = ${esp32_defaults.platform_packages}
|
||||||
board = wemos_d1_mini32
|
board = wemos_d1_mini32
|
||||||
lib_deps = ${esp32_defaults.lib_deps}
|
board_build.partitions = ${esp32_defaults.board_build.partitions}
|
||||||
|
lib_deps =
|
||||||
|
${esp32_defaults.lib_deps}
|
||||||
${esp32_defaults.nimble_lib}
|
${esp32_defaults.nimble_lib}
|
||||||
build_flags = ${esp32_defaults.build_flags}
|
lib_ignore = ${esp32_defaults.lib_ignore}
|
||||||
|
extra_scripts = ${esp32_defaults.extra_scripts}
|
||||||
|
build_type = ${esp32_defaults.build_type}
|
||||||
|
build_flags =
|
||||||
|
${esp32_defaults.build_flags}
|
||||||
-D USE_BLE=1
|
-D USE_BLE=1
|
||||||
-D DEFAULT_OT_IN_GPIO=21
|
-D DEFAULT_OT_IN_GPIO=21
|
||||||
-D DEFAULT_OT_OUT_GPIO=22
|
-D DEFAULT_OT_OUT_GPIO=22
|
||||||
@@ -186,14 +321,29 @@ build_flags = ${esp32_defaults.build_flags}
|
|||||||
-D DEFAULT_SENSOR_INDOOR_GPIO=18
|
-D DEFAULT_SENSOR_INDOOR_GPIO=18
|
||||||
-D DEFAULT_STATUS_LED_GPIO=2
|
-D DEFAULT_STATUS_LED_GPIO=2
|
||||||
-D DEFAULT_OT_RX_LED_GPIO=19
|
-D DEFAULT_OT_RX_LED_GPIO=19
|
||||||
|
check_tool = ${esp32_defaults.check_tool}
|
||||||
|
check_flags = ${esp32_defaults.check_flags}
|
||||||
|
|
||||||
[env:esp32_c6]
|
[env:esp32_c6]
|
||||||
extends = esp32_defaults
|
platform = ${esp32_defaults.platform}
|
||||||
board = esp32-c6-devkitc-1
|
framework = arduino, espidf
|
||||||
|
platform_packages = ${esp32_defaults.platform_packages}
|
||||||
|
board = esp32-c6-devkitm-1
|
||||||
|
board_build.partitions = ${esp32_defaults.board_build.partitions}
|
||||||
|
board_build.embed_txtfiles =
|
||||||
|
managed_components/espressif__esp_insights/server_certs/https_server.crt
|
||||||
|
managed_components/espressif__esp_rainmaker/server_certs/rmaker_mqtt_server.crt
|
||||||
|
managed_components/espressif__esp_rainmaker/server_certs/rmaker_claim_service_server.crt
|
||||||
|
managed_components/espressif__esp_rainmaker/server_certs/rmaker_ota_server.crt
|
||||||
lib_deps = ${esp32_defaults.lib_deps}
|
lib_deps = ${esp32_defaults.lib_deps}
|
||||||
${esp32_defaults.nimble_lib}
|
lib_ignore =
|
||||||
build_unflags = -mtext-section-literals
|
${esp32_defaults.lib_ignore}
|
||||||
build_flags = ${esp32_defaults.build_flags}
|
extra_scripts = ${esp32_defaults.extra_scripts}
|
||||||
|
build_unflags =
|
||||||
|
-mtext-section-literals
|
||||||
|
build_type = ${esp32_defaults.build_type}
|
||||||
|
build_flags =
|
||||||
|
${esp32_defaults.build_flags}
|
||||||
-D USE_BLE=1
|
-D USE_BLE=1
|
||||||
-D DEFAULT_OT_IN_GPIO=15
|
-D DEFAULT_OT_IN_GPIO=15
|
||||||
-D DEFAULT_OT_OUT_GPIO=23
|
-D DEFAULT_OT_OUT_GPIO=23
|
||||||
@@ -201,14 +351,24 @@ build_flags = ${esp32_defaults.build_flags}
|
|||||||
-D DEFAULT_SENSOR_INDOOR_GPIO=0
|
-D DEFAULT_SENSOR_INDOOR_GPIO=0
|
||||||
-D DEFAULT_STATUS_LED_GPIO=11
|
-D DEFAULT_STATUS_LED_GPIO=11
|
||||||
-D DEFAULT_OT_RX_LED_GPIO=10
|
-D DEFAULT_OT_RX_LED_GPIO=10
|
||||||
|
check_tool = ${esp32_defaults.check_tool}
|
||||||
|
check_flags = ${esp32_defaults.check_flags}
|
||||||
|
|
||||||
[env:otthing]
|
[env:otthing]
|
||||||
extends = esp32_defaults
|
platform = ${esp32_defaults.platform}
|
||||||
|
platform_packages = ${esp32_defaults.platform_packages}
|
||||||
board = lolin_c3_mini
|
board = lolin_c3_mini
|
||||||
lib_deps = ${esp32_defaults.lib_deps}
|
board_build.partitions = ${esp32_defaults.board_build.partitions}
|
||||||
|
lib_deps =
|
||||||
|
${esp32_defaults.lib_deps}
|
||||||
${esp32_defaults.nimble_lib}
|
${esp32_defaults.nimble_lib}
|
||||||
build_unflags = -mtext-section-literals
|
lib_ignore = ${esp32_defaults.lib_ignore}
|
||||||
build_flags = ${esp32_defaults.build_flags}
|
extra_scripts = ${esp32_defaults.extra_scripts}
|
||||||
|
build_unflags =
|
||||||
|
-mtext-section-literals
|
||||||
|
build_type = ${esp32_defaults.build_type}
|
||||||
|
build_flags =
|
||||||
|
${esp32_defaults.build_flags}
|
||||||
-D MYNEWT_VAL_BLE_EXT_ADV=1
|
-D MYNEWT_VAL_BLE_EXT_ADV=1
|
||||||
-D USE_BLE=1
|
-D USE_BLE=1
|
||||||
-D DEFAULT_OT_IN_GPIO=3
|
-D DEFAULT_OT_IN_GPIO=3
|
||||||
@@ -218,3 +378,5 @@ build_flags = ${esp32_defaults.build_flags}
|
|||||||
-D DEFAULT_STATUS_LED_GPIO=8
|
-D DEFAULT_STATUS_LED_GPIO=8
|
||||||
-D DEFAULT_OT_RX_LED_GPIO=2
|
-D DEFAULT_OT_RX_LED_GPIO=2
|
||||||
-D OT_BYPASS_RELAY_GPIO=20
|
-D OT_BYPASS_RELAY_GPIO=20
|
||||||
|
check_tool = ${esp32_defaults.check_tool}
|
||||||
|
check_flags = ${esp32_defaults.check_flags}
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ build_type = release
|
|||||||
|
|
||||||
serial_enabled = true
|
serial_enabled = true
|
||||||
serial_baud = 115200
|
serial_baud = 115200
|
||||||
webserial_enabled = true
|
telnet_enabled = true
|
||||||
|
telnet_port = 23
|
||||||
log_level = 5
|
log_level = 5
|
||||||
hostname = opentherm
|
hostname = opentherm
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ extern NetworkMgr* network;
|
|||||||
extern MqttTask* tMqtt;
|
extern MqttTask* tMqtt;
|
||||||
extern OpenThermTask* tOt;
|
extern OpenThermTask* tOt;
|
||||||
extern FileData fsNetworkSettings, fsSettings, fsSensorsSettings;
|
extern FileData fsNetworkSettings, fsSettings, fsSensorsSettings;
|
||||||
|
extern ESPTelnetStream* telnetStream;
|
||||||
|
|
||||||
|
|
||||||
class MainTask : public Task {
|
class MainTask : public Task {
|
||||||
@@ -39,20 +40,15 @@ protected:
|
|||||||
PumpStartReason extPumpStartReason = PumpStartReason::NONE;
|
PumpStartReason extPumpStartReason = PumpStartReason::NONE;
|
||||||
unsigned long externalPumpStartTime = 0;
|
unsigned long externalPumpStartTime = 0;
|
||||||
bool ntpStarted = false;
|
bool ntpStarted = false;
|
||||||
|
bool telnetStarted = false;
|
||||||
bool emergencyDetected = false;
|
bool emergencyDetected = false;
|
||||||
unsigned long emergencyFlipTime = 0;
|
unsigned long emergencyFlipTime = 0;
|
||||||
bool freezeDetected = false;
|
|
||||||
unsigned long freezeDetectedTime = 0;
|
|
||||||
|
|
||||||
#if defined(ARDUINO_ARCH_ESP32)
|
#if defined(ARDUINO_ARCH_ESP32)
|
||||||
const char* getTaskName() override {
|
const char* getTaskName() override {
|
||||||
return "Main";
|
return "Main";
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t getTaskStackSize() override {
|
|
||||||
return 6000;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*BaseType_t getTaskCore() override {
|
/*BaseType_t getTaskCore() override {
|
||||||
return 1;
|
return 1;
|
||||||
}*/
|
}*/
|
||||||
@@ -108,9 +104,9 @@ protected:
|
|||||||
vars.network.connected = network->isConnected();
|
vars.network.connected = network->isConnected();
|
||||||
vars.network.rssi = network->isConnected() ? WiFi.RSSI() : 0;
|
vars.network.rssi = network->isConnected() ? WiFi.RSSI() : 0;
|
||||||
|
|
||||||
if (settings.system.logLevel >= TinyLoggerLevel::SILENT && settings.system.logLevel <= TinyLoggerLevel::VERBOSE) {
|
if (settings.system.logLevel >= TinyLogger::Level::SILENT && settings.system.logLevel <= TinyLogger::Level::VERBOSE) {
|
||||||
if (Log.getLevel() != settings.system.logLevel) {
|
if (Log.getLevel() != settings.system.logLevel) {
|
||||||
Log.setLevel(static_cast<TinyLoggerLevel>(settings.system.logLevel));
|
Log.setLevel(static_cast<TinyLogger::Level>(settings.system.logLevel));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,6 +121,11 @@ protected:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!this->telnetStarted && telnetStream != nullptr) {
|
||||||
|
telnetStream->begin(23, false);
|
||||||
|
this->telnetStarted = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (settings.mqtt.enabled && !tMqtt->isEnabled()) {
|
if (settings.mqtt.enabled && !tMqtt->isEnabled()) {
|
||||||
tMqtt->enable();
|
tMqtt->enable();
|
||||||
|
|
||||||
@@ -137,6 +138,11 @@ protected:
|
|||||||
this->ntpStarted = false;
|
this->ntpStarted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this->telnetStarted) {
|
||||||
|
telnetStream->stop();
|
||||||
|
this->telnetStarted = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (tMqtt->isEnabled()) {
|
if (tMqtt->isEnabled()) {
|
||||||
tMqtt->disable();
|
tMqtt->disable();
|
||||||
}
|
}
|
||||||
@@ -150,10 +156,23 @@ protected:
|
|||||||
}
|
}
|
||||||
this->ledStatus();
|
this->ledStatus();
|
||||||
|
|
||||||
|
// telnet
|
||||||
|
if (this->telnetStarted) {
|
||||||
|
this->yield();
|
||||||
|
telnetStream->loop();
|
||||||
|
this->yield();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// anti memory leak
|
// anti memory leak
|
||||||
while (Serial.available() > 0) {
|
for (Stream* stream : Log.getStreams()) {
|
||||||
Serial.read();
|
while (stream->available() > 0) {
|
||||||
|
stream->read();
|
||||||
|
|
||||||
|
#ifdef ARDUINO_ARCH_ESP8266
|
||||||
|
::optimistic_yield(1000);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// heap info
|
// heap info
|
||||||
@@ -192,7 +211,7 @@ protected:
|
|||||||
vars.states.restarting = true;
|
vars.states.restarting = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings.system.logLevel < TinyLoggerLevel::VERBOSE) {
|
if (settings.system.logLevel < TinyLogger::Level::VERBOSE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,7 +241,7 @@ protected:
|
|||||||
|
|
||||||
void heating() {
|
void heating() {
|
||||||
// freeze protection
|
// freeze protection
|
||||||
if (!settings.heating.enabled) {
|
{
|
||||||
float lowTemp = 255.0f;
|
float lowTemp = 255.0f;
|
||||||
uint8_t availableSensors = 0;
|
uint8_t availableSensors = 0;
|
||||||
|
|
||||||
@@ -253,29 +272,40 @@ protected:
|
|||||||
availableSensors++;
|
availableSensors++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (availableSensors && lowTemp <= settings.heating.freezeProtection.lowTemp) {
|
if (availableSensors) {
|
||||||
if (!this->freezeDetected) {
|
if (vars.master.heating.freezing) {
|
||||||
this->freezeDetected = true;
|
if (lowTemp - (float) settings.heating.freezeProtection.highTemp + 0.0001f >= 0.0f) {
|
||||||
this->freezeDetectedTime = millis();
|
vars.master.heating.freezing = false;
|
||||||
|
|
||||||
} else if (millis() - this->freezeDetectedTime > (settings.heating.freezeProtection.thresholdTime * 1000)) {
|
|
||||||
this->freezeDetected = false;
|
|
||||||
settings.heating.enabled = true;
|
|
||||||
fsSettings.update();
|
|
||||||
|
|
||||||
Log.sinfoln(
|
Log.sinfoln(
|
||||||
FPSTR(L_MAIN),
|
FPSTR(L_MAIN),
|
||||||
F("Heating turned on by freeze protection, current low temp: %.2f, threshold: %hhu"),
|
F("No freezing detected. Current low temp: %.2f, threshold (high): %hhu"),
|
||||||
lowTemp, settings.heating.freezeProtection.lowTemp
|
lowTemp, settings.heating.freezeProtection.highTemp
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (this->freezeDetected) {
|
} else {
|
||||||
this->freezeDetected = false;
|
if ((float) settings.heating.freezeProtection.lowTemp - lowTemp + 0.0001f >= 0.0f) {
|
||||||
|
vars.master.heating.freezing = true;
|
||||||
|
|
||||||
|
if (!settings.heating.enabled) {
|
||||||
|
settings.heating.enabled = true;
|
||||||
|
fsSettings.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (this->freezeDetected) {
|
Log.sinfoln(
|
||||||
this->freezeDetected = false;
|
FPSTR(L_MAIN),
|
||||||
|
F("Freezing detected! Current low temp: %.2f, threshold (low): %hhu"),
|
||||||
|
lowTemp, settings.heating.freezeProtection.lowTemp
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (vars.master.heating.freezing) {
|
||||||
|
vars.master.heating.freezing = false;
|
||||||
|
|
||||||
|
Log.sinfoln(FPSTR(L_MAIN), F("No sensors available, freeze protection unavailable!"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -416,7 +416,7 @@ protected:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings.system.logLevel >= TinyLoggerLevel::TRACE) {
|
if (settings.system.logLevel >= TinyLogger::Level::TRACE) {
|
||||||
Log.strace(FPSTR(L_MQTT_MSG), F("Topic: %s\r\n> "), topic.c_str());
|
Log.strace(FPSTR(L_MQTT_MSG), F("Topic: %s\r\n> "), topic.c_str());
|
||||||
if (Log.lock()) {
|
if (Log.lock()) {
|
||||||
for (size_t i = 0; i < length; i++) {
|
for (size_t i = 0; i < length; i++) {
|
||||||
|
|||||||
@@ -38,12 +38,8 @@ protected:
|
|||||||
return "OpenTherm";
|
return "OpenTherm";
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t getTaskStackSize() override {
|
|
||||||
return 7500;
|
|
||||||
}
|
|
||||||
|
|
||||||
BaseType_t getTaskCore() override {
|
BaseType_t getTaskCore() override {
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getTaskPriority() override {
|
int getTaskPriority() override {
|
||||||
@@ -174,8 +170,7 @@ protected:
|
|||||||
// Heating settings
|
// Heating settings
|
||||||
vars.master.heating.enabled = this->isReady()
|
vars.master.heating.enabled = this->isReady()
|
||||||
&& settings.heating.enabled
|
&& settings.heating.enabled
|
||||||
&& vars.cascadeControl.input
|
&& (vars.master.heating.freezing || (vars.cascadeControl.input && !vars.master.heating.blocking))
|
||||||
&& !vars.master.heating.blocking
|
|
||||||
&& !vars.master.heating.overheat;
|
&& !vars.master.heating.overheat;
|
||||||
|
|
||||||
// DHW settings
|
// DHW settings
|
||||||
|
|||||||
832
src/PortalTask.h
832
src/PortalTask.h
File diff suppressed because it is too large
Load Diff
@@ -20,10 +20,6 @@ protected:
|
|||||||
return "Regulator";
|
return "Regulator";
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t getTaskStackSize() override {
|
|
||||||
return 5000;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*BaseType_t getTaskCore() override {
|
/*BaseType_t getTaskCore() override {
|
||||||
return 1;
|
return 1;
|
||||||
}*/
|
}*/
|
||||||
@@ -244,6 +240,11 @@ protected:
|
|||||||
) * settings.heating.turboFactor;
|
) * settings.heating.turboFactor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If freezing, set temperature to no lower than low temp provided by freeze protection
|
||||||
|
if (vars.master.heating.freezing && fabsf(settings.heating.freezeProtection.lowTemp - newTemp) < 0.0001f) {
|
||||||
|
newTemp = settings.heating.freezeProtection.lowTemp;
|
||||||
|
}
|
||||||
|
|
||||||
return newTemp;
|
return newTemp;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -9,295 +9,41 @@
|
|||||||
extern FileData fsSensorsSettings;
|
extern FileData fsSensorsSettings;
|
||||||
|
|
||||||
#if USE_BLE
|
#if USE_BLE
|
||||||
class BluetoothScanCallbacks : public NimBLEScanCallbacks {
|
class BluetoothClientCallbacks : public NimBLEClientCallbacks {
|
||||||
public:
|
public:
|
||||||
void onDiscovered(const NimBLEAdvertisedDevice* device) override {
|
BluetoothClientCallbacks(uint8_t sensorId) : sensorId(sensorId) {}
|
||||||
auto& deviceAddress = device->getAddress();
|
|
||||||
|
|
||||||
bool found = false;
|
void onConnect(NimBLEClient* pClient) {
|
||||||
uint8_t sensorId;
|
auto& sSensor = Sensors::settings[this->sensorId];
|
||||||
for (sensorId = 0; sensorId <= Sensors::getMaxSensorId(); sensorId++) {
|
|
||||||
auto& sSensor = Sensors::settings[sensorId];
|
|
||||||
if (!sSensor.enabled || sSensor.type != Sensors::Type::BLUETOOTH || sSensor.purpose == Sensors::Purpose::NOT_CONFIGURED) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto sensorAddress = NimBLEAddress(sSensor.address, deviceAddress.getType());
|
|
||||||
if (sensorAddress.isNull() || sensorAddress != deviceAddress) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!found) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto& sSensor = Sensors::settings[sensorId];
|
|
||||||
auto& rSensor = Sensors::results[sensorId];
|
|
||||||
auto deviceName = device->getName();
|
|
||||||
auto deviceRssi = device->getRSSI();
|
|
||||||
|
|
||||||
Log.sinfoln(
|
Log.sinfoln(
|
||||||
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': discovered device %s, name: %s, RSSI: %hhd"),
|
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': connected to %s"),
|
||||||
sensorId, sSensor.name,
|
sensorId, sSensor.name, pClient->getPeerAddress().toString().c_str()
|
||||||
deviceAddress.toString().c_str(), deviceName.c_str(), deviceRssi
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!device->haveServiceData()) {
|
|
||||||
Log.swarningln(
|
|
||||||
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': not found service data!"),
|
|
||||||
sensorId, sSensor.name
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto serviceDataCount = device->getServiceDataCount();
|
|
||||||
Log.straceln(
|
|
||||||
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': found %hhu service data"),
|
|
||||||
sensorId, sSensor.name, serviceDataCount
|
|
||||||
);
|
|
||||||
|
|
||||||
if (parseAtcData(device, sensorId) || parsePvvxData(device, sensorId) || parseBTHomeData(device, sensorId)) {
|
|
||||||
// update rssi
|
|
||||||
Sensors::setValueById(sensorId, deviceRssi, Sensors::ValueType::RSSI, false, false);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
Log.swarningln(
|
|
||||||
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': unsupported data format!"),
|
|
||||||
sensorId, sSensor.name
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void onDisconnect(NimBLEClient* pClient, int reason) {
|
||||||
|
auto& sSensor = Sensors::settings[this->sensorId];
|
||||||
|
|
||||||
|
Log.sinfoln(
|
||||||
|
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': disconnected, reason %i"),
|
||||||
|
sensorId, sSensor.name, reason
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool parseAtcData(const NimBLEAdvertisedDevice* device, uint8_t sensorId) {
|
void onConnectFail(NimBLEClient* pClient, int reason) {
|
||||||
NimBLEUUID serviceUuid((uint16_t) 0x181A);
|
auto& sSensor = Sensors::settings[this->sensorId];
|
||||||
|
|
||||||
auto serviceData = device->getServiceData(serviceUuid);
|
Log.sinfoln(
|
||||||
if (!serviceData.size()) {
|
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': failed to connect, reason %i"),
|
||||||
Log.straceln(
|
sensorId, sSensor.name, reason
|
||||||
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu, service %s: not found ATC1441 data"),
|
|
||||||
sensorId, serviceUuid.toString().c_str()
|
|
||||||
);
|
|
||||||
return false;
|
|
||||||
|
|
||||||
} else if (serviceData.size() != 13) {
|
|
||||||
Log.straceln(
|
|
||||||
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu, service %s: not in ATC1441 format"),
|
|
||||||
sensorId, serviceUuid.toString().c_str()
|
|
||||||
);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Log.snoticeln(
|
|
||||||
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu, service %s: found ATC1441 format"),
|
|
||||||
sensorId, serviceUuid.toString().c_str()
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Temperature (2 bytes, big-endian)
|
pClient->cancelConnect();
|
||||||
float temperature = (
|
|
||||||
(static_cast<uint8_t>(serviceData[6]) << 8) | static_cast<uint8_t>(serviceData[7])
|
|
||||||
) * 0.1f;
|
|
||||||
Sensors::setValueById(sensorId, temperature, Sensors::ValueType::TEMPERATURE, true, true);
|
|
||||||
|
|
||||||
// Humidity (1 byte)
|
|
||||||
float humidity = static_cast<uint8_t>(serviceData[8]);
|
|
||||||
Sensors::setValueById(sensorId, humidity, Sensors::ValueType::HUMIDITY, true, true);
|
|
||||||
|
|
||||||
// Battery level (1 byte)
|
|
||||||
uint8_t batteryLevel = static_cast<uint8_t>(serviceData[9]);
|
|
||||||
Sensors::setValueById(sensorId, batteryLevel, Sensors::ValueType::BATTERY, true, true);
|
|
||||||
|
|
||||||
// Battery mV (2 bytes, big-endian)
|
|
||||||
uint16_t batteryMv = (static_cast<uint8_t>(serviceData[10]) << 8) | static_cast<uint8_t>(serviceData[11]);
|
|
||||||
|
|
||||||
// Log
|
|
||||||
Log.snoticeln(
|
|
||||||
FPSTR(L_SENSORS_BLE),
|
|
||||||
F("Sensor #%hhu, received temp: %.2f; humidity: %.2f, battery voltage: %hu, battery level: %hhu"),
|
|
||||||
sensorId, temperature, humidity, batteryMv, batteryLevel
|
|
||||||
);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool parsePvvxData(const NimBLEAdvertisedDevice* device, uint8_t sensorId) {
|
protected:
|
||||||
NimBLEUUID serviceUuid((uint16_t) 0x181A);
|
uint8_t sensorId;
|
||||||
|
|
||||||
auto serviceData = device->getServiceData(serviceUuid);
|
|
||||||
if (!serviceData.size()) {
|
|
||||||
Log.straceln(
|
|
||||||
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu, service %s: not found PVVX data"),
|
|
||||||
sensorId, serviceUuid.toString().c_str()
|
|
||||||
);
|
|
||||||
return false;
|
|
||||||
|
|
||||||
} else if (serviceData.size() != 15) {
|
|
||||||
Log.straceln(
|
|
||||||
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu, service %s: not in PVVX format"),
|
|
||||||
sensorId, serviceUuid.toString().c_str()
|
|
||||||
);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Log.snoticeln(
|
|
||||||
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu, service %s: found PVVX format"),
|
|
||||||
sensorId, serviceUuid.toString().c_str()
|
|
||||||
);
|
|
||||||
|
|
||||||
// Temperature (2 bytes, little-endian)
|
|
||||||
float temperature = (
|
|
||||||
(static_cast<uint8_t>(serviceData[7]) << 8) | static_cast<uint8_t>(serviceData[6])
|
|
||||||
) * 0.01f;
|
|
||||||
Sensors::setValueById(sensorId, temperature, Sensors::ValueType::TEMPERATURE, true, true);
|
|
||||||
|
|
||||||
// Humidity (2 bytes, little-endian)
|
|
||||||
float humidity = (
|
|
||||||
(static_cast<uint8_t>(serviceData[9]) << 8) | static_cast<uint8_t>(serviceData[8])
|
|
||||||
) * 0.01f;
|
|
||||||
Sensors::setValueById(sensorId, humidity, Sensors::ValueType::HUMIDITY, true, true);
|
|
||||||
|
|
||||||
// Battery level (1 byte)
|
|
||||||
uint8_t batteryLevel = static_cast<uint8_t>(serviceData[12]);
|
|
||||||
Sensors::setValueById(sensorId, batteryLevel, Sensors::ValueType::BATTERY, true, true);
|
|
||||||
|
|
||||||
// Battery mV (2 bytes, little-endian)
|
|
||||||
uint16_t batteryMv = (static_cast<uint8_t>(serviceData[11]) << 8) | static_cast<uint8_t>(serviceData[10]);
|
|
||||||
|
|
||||||
// Log
|
|
||||||
Log.snoticeln(
|
|
||||||
FPSTR(L_SENSORS_BLE),
|
|
||||||
F("Sensor #%hhu, received temp: %.2f; humidity: %.2f, battery voltage: %hu, battery level: %hhu"),
|
|
||||||
sensorId, temperature, humidity, batteryMv, batteryLevel
|
|
||||||
);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool parseBTHomeData(const NimBLEAdvertisedDevice* device, uint8_t sensorId) {
|
|
||||||
NimBLEUUID serviceUuid((uint16_t) 0xFCD2);
|
|
||||||
|
|
||||||
auto serviceData = device->getServiceData(serviceUuid);
|
|
||||||
if (!serviceData.size()) {
|
|
||||||
Log.straceln(
|
|
||||||
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu, service %s: not found BTHome data"),
|
|
||||||
sensorId, serviceUuid.toString().c_str()
|
|
||||||
);
|
|
||||||
return false;
|
|
||||||
|
|
||||||
} else if ((serviceData[0] & 0xE0) != 0x40) {
|
|
||||||
Log.straceln(
|
|
||||||
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu, service %s: unsupported BTHome version"),
|
|
||||||
sensorId, serviceUuid.toString().c_str()
|
|
||||||
);
|
|
||||||
return false;
|
|
||||||
|
|
||||||
} else if ((serviceData[0] & 0x01) != 0) {
|
|
||||||
Log.straceln(
|
|
||||||
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu, service %s: unsupported BTHome encrypted data"),
|
|
||||||
sensorId, serviceUuid.toString().c_str()
|
|
||||||
);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Log.snoticeln(
|
|
||||||
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu, service %s: found BTHome format"),
|
|
||||||
sensorId, serviceUuid.toString().c_str()
|
|
||||||
);
|
|
||||||
|
|
||||||
bool foundData = false;
|
|
||||||
size_t serviceDataPos = 0;
|
|
||||||
while (serviceDataPos < serviceData.size()) {
|
|
||||||
uint8_t objectId = serviceData[serviceDataPos++];
|
|
||||||
|
|
||||||
switch (objectId) {
|
|
||||||
// Packet ID (1 byte)
|
|
||||||
case 0x00:
|
|
||||||
serviceDataPos += 1;
|
|
||||||
break;
|
|
||||||
|
|
||||||
// Battery (1 byte)
|
|
||||||
case 0x01: {
|
|
||||||
if (serviceDataPos + 1 > serviceData.size()) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t batteryLevel = static_cast<uint8_t>(serviceData[serviceDataPos]);
|
|
||||||
Sensors::setValueById(sensorId, batteryLevel, Sensors::ValueType::BATTERY, true, true);
|
|
||||||
serviceDataPos += 1;
|
|
||||||
foundData = true;
|
|
||||||
|
|
||||||
Log.snoticeln(
|
|
||||||
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu, received battery level: %hhu"),
|
|
||||||
sensorId, batteryLevel
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Temperature (2 bytes, little-endian)
|
|
||||||
case 0x02: {
|
|
||||||
if (serviceDataPos + 2 > serviceData.size()) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
int16_t rawTemp = (static_cast<int16_t>(serviceData[serviceDataPos + 1]) << 8)
|
|
||||||
| static_cast<uint8_t>(serviceData[serviceDataPos]);
|
|
||||||
float temperature = static_cast<float>(rawTemp) * 0.01f;
|
|
||||||
Sensors::setValueById(sensorId, temperature, Sensors::ValueType::TEMPERATURE, true, true);
|
|
||||||
serviceDataPos += 2;
|
|
||||||
foundData = true;
|
|
||||||
|
|
||||||
Log.snoticeln(
|
|
||||||
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu, received temp: %.2f"),
|
|
||||||
sensorId, temperature
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Humidity (2 bytes, little-endian)
|
|
||||||
case 0x03: {
|
|
||||||
if (serviceDataPos + 2 > serviceData.size()) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t rawHumidity = (static_cast<uint16_t>(serviceData[serviceDataPos + 1]) << 8)
|
|
||||||
| static_cast<uint8_t>(serviceData[serviceDataPos]);
|
|
||||||
float humidity = static_cast<float>(rawHumidity) * 0.01f;
|
|
||||||
Sensors::setValueById(sensorId, humidity, Sensors::ValueType::HUMIDITY, true, true);
|
|
||||||
serviceDataPos += 2;
|
|
||||||
foundData = true;
|
|
||||||
|
|
||||||
Log.snoticeln(
|
|
||||||
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu, received humidity: %.2f"),
|
|
||||||
sensorId, humidity
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Voltage (2 bytes, little-endian)
|
|
||||||
case 0x0C: {
|
|
||||||
if (serviceDataPos + 2 > serviceData.size()) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t batteryMv = (static_cast<uint16_t>(serviceData[serviceDataPos + 1]) << 8)
|
|
||||||
| static_cast<uint8_t>(serviceData[serviceDataPos]);
|
|
||||||
serviceDataPos += 2;
|
|
||||||
foundData = true;
|
|
||||||
|
|
||||||
Log.snoticeln(
|
|
||||||
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu, received battery voltage: %hu"),
|
|
||||||
sensorId, batteryMv
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return foundData;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -309,10 +55,6 @@ public:
|
|||||||
this->dallasSearchTime.reserve(2);
|
this->dallasSearchTime.reserve(2);
|
||||||
this->dallasPolling.reserve(2);
|
this->dallasPolling.reserve(2);
|
||||||
this->dallasLastPollingTime.reserve(2);
|
this->dallasLastPollingTime.reserve(2);
|
||||||
|
|
||||||
#if USE_BLE
|
|
||||||
this->pBLEScanCallbacks = new BluetoothScanCallbacks();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
~SensorsTask() {
|
~SensorsTask() {
|
||||||
@@ -321,18 +63,17 @@ public:
|
|||||||
this->dallasSearchTime.clear();
|
this->dallasSearchTime.clear();
|
||||||
this->dallasPolling.clear();
|
this->dallasPolling.clear();
|
||||||
this->dallasLastPollingTime.clear();
|
this->dallasLastPollingTime.clear();
|
||||||
|
|
||||||
#if USE_BLE
|
|
||||||
delete this->pBLEScanCallbacks;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const unsigned int wiredDisconnectTimeout = 180000u;
|
const unsigned int wiredDisconnectTimeout = 180000u;
|
||||||
const unsigned int wirelessDisconnectTimeout = 600000u;
|
const unsigned int wirelessDisconnectTimeout = 600000u;
|
||||||
const unsigned short dallasSearchInterval = 60000u;
|
const unsigned short dallasSearchInterval = 60000;
|
||||||
const unsigned short dallasPollingInterval = 10000u;
|
const unsigned short dallasPollingInterval = 10000;
|
||||||
const unsigned short globalPollingInterval = 15000u;
|
const unsigned short globalPollingInterval = 15000;
|
||||||
|
#if USE_BLE
|
||||||
|
const unsigned int bleSetDtInterval = 7200000;
|
||||||
|
#endif
|
||||||
|
|
||||||
std::unordered_map<uint8_t, OneWire> owInstances;
|
std::unordered_map<uint8_t, OneWire> owInstances;
|
||||||
std::unordered_map<uint8_t, DallasTemperature> dallasInstances;
|
std::unordered_map<uint8_t, DallasTemperature> dallasInstances;
|
||||||
@@ -340,9 +81,9 @@ protected:
|
|||||||
std::unordered_map<uint8_t, bool> dallasPolling;
|
std::unordered_map<uint8_t, bool> dallasPolling;
|
||||||
std::unordered_map<uint8_t, unsigned long> dallasLastPollingTime;
|
std::unordered_map<uint8_t, unsigned long> dallasLastPollingTime;
|
||||||
#if USE_BLE
|
#if USE_BLE
|
||||||
NimBLEScan* pBLEScan = nullptr;
|
std::unordered_map<uint8_t, NimBLEClient*> bleClients;
|
||||||
BluetoothScanCallbacks* pBLEScanCallbacks = nullptr;
|
std::unordered_map<uint8_t, bool> bleSubscribed;
|
||||||
bool activeScanBle = false;
|
std::unordered_map<uint8_t, unsigned long> bleLastSetDtTime;
|
||||||
#endif
|
#endif
|
||||||
unsigned long globalLastPollingTime = 0;
|
unsigned long globalLastPollingTime = 0;
|
||||||
|
|
||||||
@@ -351,10 +92,6 @@ protected:
|
|||||||
return "Sensors";
|
return "Sensors";
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t getTaskStackSize() override {
|
|
||||||
return 7500;
|
|
||||||
}
|
|
||||||
|
|
||||||
BaseType_t getTaskCore() override {
|
BaseType_t getTaskCore() override {
|
||||||
// https://github.com/h2zero/NimBLE-Arduino/issues/676
|
// https://github.com/h2zero/NimBLE-Arduino/issues/676
|
||||||
#if USE_BLE && defined(CONFIG_BT_NIMBLE_PINNED_TO_CORE)
|
#if USE_BLE && defined(CONFIG_BT_NIMBLE_PINNED_TO_CORE)
|
||||||
@@ -395,7 +132,8 @@ protected:
|
|||||||
this->yield();
|
this->yield();
|
||||||
|
|
||||||
#if USE_BLE
|
#if USE_BLE
|
||||||
scanBleSensors();
|
cleanBleInstances();
|
||||||
|
pollingBleSensors();
|
||||||
this->yield();
|
this->yield();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -707,72 +445,550 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if USE_BLE
|
#if USE_BLE
|
||||||
void scanBleSensors() {
|
void cleanBleInstances() {
|
||||||
|
if (!NimBLEDevice::isInitialized()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto& [sensorId, pClient]: this->bleClients) {
|
||||||
|
if (pClient == nullptr) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto& sSensor = Sensors::settings[sensorId];
|
||||||
|
const auto sAddress = NimBLEAddress(sSensor.address, 0);
|
||||||
|
|
||||||
|
if (sAddress.isNull() || !sSensor.enabled || sSensor.type != Sensors::Type::BLUETOOTH || sSensor.purpose == Sensors::Purpose::NOT_CONFIGURED) {
|
||||||
|
Log.sinfoln(
|
||||||
|
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s', deleted unused client"),
|
||||||
|
sensorId, sSensor.name
|
||||||
|
);
|
||||||
|
|
||||||
|
NimBLEDevice::deleteClient(pClient);
|
||||||
|
pClient = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void pollingBleSensors() {
|
||||||
if (!Sensors::getAmountByType(Sensors::Type::BLUETOOTH, true)) {
|
if (!Sensors::getAmountByType(Sensors::Type::BLUETOOTH, true)) {
|
||||||
if (NimBLEDevice::isInitialized()) {
|
|
||||||
if (this->pBLEScan != nullptr) {
|
|
||||||
if (this->pBLEScan->isScanning()) {
|
|
||||||
this->pBLEScan->stop();
|
|
||||||
|
|
||||||
} else {
|
|
||||||
this->pBLEScan = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this->pBLEScan == nullptr) {
|
|
||||||
if (NimBLEDevice::deinit(true)) {
|
|
||||||
Log.sinfoln(FPSTR(L_SENSORS_BLE), F("Deinitialized"));
|
|
||||||
|
|
||||||
} else {
|
|
||||||
Log.swarningln(FPSTR(L_SENSORS_BLE), F("Unable to deinitialize!"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!NimBLEDevice::isInitialized() && millis() > 5000) {
|
if (!NimBLEDevice::isInitialized() && millis() > 5000) {
|
||||||
Log.sinfoln(FPSTR(L_SENSORS_BLE), F("Initialized"));
|
Log.sinfoln(FPSTR(L_SENSORS_BLE), F("Initialized"));
|
||||||
NimBLEDevice::init("");
|
BLEDevice::init("");
|
||||||
|
NimBLEDevice::setPower(9);
|
||||||
#ifdef ESP_PWR_LVL_P20
|
|
||||||
NimBLEDevice::setPower(ESP_PWR_LVL_P20);
|
|
||||||
#elifdef ESP_PWR_LVL_P9
|
|
||||||
NimBLEDevice::setPower(ESP_PWR_LVL_P9);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->pBLEScan == nullptr) {
|
for (uint8_t sensorId = 0; sensorId <= Sensors::getMaxSensorId(); sensorId++) {
|
||||||
this->pBLEScan = NimBLEDevice::getScan();
|
auto& sSensor = Sensors::settings[sensorId];
|
||||||
this->pBLEScan->setScanCallbacks(this->pBLEScanCallbacks);
|
auto& rSensor = Sensors::results[sensorId];
|
||||||
#if MYNEWT_VAL(BLE_EXT_ADV)
|
|
||||||
this->pBLEScan->setPhy(NimBLEScan::Phy::SCAN_ALL);
|
|
||||||
#endif
|
|
||||||
this->pBLEScan->setDuplicateFilter(false);
|
|
||||||
this->pBLEScan->setMaxResults(0);
|
|
||||||
this->pBLEScan->setInterval(10000);
|
|
||||||
this->pBLEScan->setWindow(10000);
|
|
||||||
|
|
||||||
Log.sinfoln(FPSTR(L_SENSORS_BLE), F("Scanning initialized"));
|
if (!sSensor.enabled || sSensor.type != Sensors::Type::BLUETOOTH || sSensor.purpose == Sensors::Purpose::NOT_CONFIGURED) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this->pBLEScan->isScanning()) {
|
const auto address = NimBLEAddress(sSensor.address, 0);
|
||||||
this->activeScanBle = !this->activeScanBle;
|
if (address.isNull()) {
|
||||||
this->pBLEScan->setActiveScan(this->activeScanBle);
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (this->pBLEScan->start(30000, false, false)) {
|
auto pClient = this->getBleClient(sensorId);
|
||||||
|
if (pClient == nullptr) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pClient->getPeerAddress() != address) {
|
||||||
|
if (pClient->isConnected()) {
|
||||||
|
if (!pClient->disconnect()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pClient->setPeerAddress(address);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!pClient->isConnected()) {
|
||||||
|
this->bleSubscribed[sensorId] = false;
|
||||||
|
this->bleLastSetDtTime[sensorId] = 0;
|
||||||
|
|
||||||
|
if (pClient->connect(false, true, true)) {
|
||||||
Log.sinfoln(
|
Log.sinfoln(
|
||||||
FPSTR(L_SENSORS_BLE),
|
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': trying connecting to %s..."),
|
||||||
F("%s scanning started"),
|
sensorId, sSensor.name, pClient->getPeerAddress().toString().c_str()
|
||||||
this->activeScanBle ? "Active" : "Passive"
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this->bleSubscribed[sensorId]) {
|
||||||
|
if (this->subscribeToBleDevice(sensorId, pClient)) {
|
||||||
|
this->bleSubscribed[sensorId] = true;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
this->bleSubscribed[sensorId] = false;
|
||||||
|
pClient->disconnect();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mark connected
|
||||||
|
Sensors::setConnectionStatusById(sensorId, true, true);
|
||||||
|
|
||||||
|
if (!this->bleLastSetDtTime[sensorId] || millis() - this->bleLastSetDtTime[sensorId] > this->bleSetDtInterval) {
|
||||||
|
struct tm ti;
|
||||||
|
|
||||||
|
if (getLocalTime(&ti)) {
|
||||||
|
if (this->setDateOnBleSensor(pClient, &ti)) {
|
||||||
|
Log.sinfoln(
|
||||||
|
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s', successfully set date: %02d.%02d.%04d %02d:%02d:%02d"),
|
||||||
|
sensorId, sSensor.name,
|
||||||
|
ti.tm_mday, ti.tm_mon + 1, ti.tm_year + 1900, ti.tm_hour, ti.tm_min, ti.tm_sec
|
||||||
);
|
);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Log.sinfoln(FPSTR(L_SENSORS_BLE), F("Unable to start scanning"));
|
Log.swarningln(
|
||||||
|
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s', failed set date: %02d.%02d.%04d %02d:%02d:%02d"),
|
||||||
|
sensorId, sSensor.name,
|
||||||
|
ti.tm_mday, ti.tm_mon + 1, ti.tm_year + 1900, ti.tm_hour, ti.tm_min, ti.tm_sec
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
this->bleLastSetDtTime[sensorId] = millis();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
NimBLEClient* getBleClient(const uint8_t sensorId) {
|
||||||
|
if (!NimBLEDevice::isInitialized()) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto& sSensor = Sensors::settings[sensorId];
|
||||||
|
auto& rSensor = Sensors::results[sensorId];
|
||||||
|
|
||||||
|
if (!sSensor.enabled || sSensor.type != Sensors::Type::BLUETOOTH || sSensor.purpose == Sensors::Purpose::NOT_CONFIGURED) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this->bleClients[sensorId] && this->bleClients[sensorId] != nullptr) {
|
||||||
|
return this->bleClients[sensorId];
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pClient = NimBLEDevice::createClient();
|
||||||
|
if (pClient == nullptr) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
//pClient->setConnectionParams(BLE_GAP_CONN_ITVL_MS(10), BLE_GAP_CONN_ITVL_MS(100), 10, 150);
|
||||||
|
pClient->setConnectTimeout(30000);
|
||||||
|
pClient->setSelfDelete(false, false);
|
||||||
|
pClient->setClientCallbacks(new BluetoothClientCallbacks(sensorId), true);
|
||||||
|
|
||||||
|
this->bleClients[sensorId] = pClient;
|
||||||
|
|
||||||
|
return pClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool subscribeToBleDevice(const uint8_t sensorId, NimBLEClient* pClient) {
|
||||||
|
auto& sSensor = Sensors::settings[sensorId];
|
||||||
|
auto pAddress = pClient->getPeerAddress().toString();
|
||||||
|
|
||||||
|
NimBLERemoteService* pService = nullptr;
|
||||||
|
NimBLERemoteCharacteristic* pChar = nullptr;
|
||||||
|
|
||||||
|
// ENV Service (0x181A)
|
||||||
|
NimBLEUUID serviceUuid((uint16_t) 0x181AU);
|
||||||
|
pService = pClient->getService(serviceUuid);
|
||||||
|
if (!pService) {
|
||||||
|
Log.straceln(
|
||||||
|
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': failed to find env service (%s) on device %s"),
|
||||||
|
sensorId, sSensor.name, serviceUuid.toString().c_str(), pAddress.c_str()
|
||||||
|
);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Log.straceln(
|
||||||
|
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': found env service (%s) on device %s"),
|
||||||
|
sensorId, sSensor.name, serviceUuid.toString().c_str(), pAddress.c_str()
|
||||||
|
);
|
||||||
|
|
||||||
|
// 0x2A6E - Notify temperature x0.01C (pvvx)
|
||||||
|
bool tempNotifyCreated = false;
|
||||||
|
if (!tempNotifyCreated) {
|
||||||
|
NimBLEUUID charUuid((uint16_t) 0x2A6E);
|
||||||
|
pChar = pService->getCharacteristic(charUuid);
|
||||||
|
|
||||||
|
if (pChar && (pChar->canNotify() || pChar->canIndicate())) {
|
||||||
|
Log.straceln(
|
||||||
|
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': found temp char (%s) in env service on device %s"),
|
||||||
|
sensorId, sSensor.name, charUuid.toString().c_str(), pAddress.c_str()
|
||||||
|
);
|
||||||
|
|
||||||
|
pChar->unsubscribe();
|
||||||
|
tempNotifyCreated = pChar->subscribe(
|
||||||
|
pChar->canNotify(),
|
||||||
|
[sensorId](NimBLERemoteCharacteristic* pChar, uint8_t* pData, size_t length, bool isNotify) {
|
||||||
|
if (pChar == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const NimBLERemoteService* pService = pChar->getRemoteService();
|
||||||
|
if (pService == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
NimBLEClient* pClient = pService->getClient();
|
||||||
|
if (pClient == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto& sSensor = Sensors::settings[sensorId];
|
||||||
|
|
||||||
|
if (length != 2) {
|
||||||
|
Log.swarningln(
|
||||||
|
FPSTR(L_SENSORS_BLE),
|
||||||
|
F("Sensor #%hhu '%s': invalid notification data at temp char (%s) on device %s"),
|
||||||
|
sensorId,
|
||||||
|
sSensor.name,
|
||||||
|
pChar->getUUID().toString().c_str(),
|
||||||
|
pClient->getPeerAddress().toString().c_str()
|
||||||
|
);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
float rawTemp = (pChar->getValue<int16_t>() * 0.01f);
|
||||||
|
Log.straceln(
|
||||||
|
FPSTR(L_SENSORS_BLE),
|
||||||
|
F("Sensor #%hhu '%s': received temp: %.2f"),
|
||||||
|
sensorId, sSensor.name, rawTemp
|
||||||
|
);
|
||||||
|
|
||||||
|
// set temp
|
||||||
|
Sensors::setValueById(sensorId, rawTemp, Sensors::ValueType::TEMPERATURE, true, true);
|
||||||
|
|
||||||
|
// update rssi
|
||||||
|
Sensors::setValueById(sensorId, pClient->getRssi(), Sensors::ValueType::RSSI, false, false);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
if (tempNotifyCreated) {
|
||||||
|
Log.straceln(
|
||||||
|
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': subscribed to temp char (%s) in env service on device %s"),
|
||||||
|
sensorId, sSensor.name,
|
||||||
|
charUuid.toString().c_str(), pAddress.c_str()
|
||||||
|
);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Log.swarningln(
|
||||||
|
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': failed to subscribe to temp char (%s) in env service on device %s"),
|
||||||
|
sensorId, sSensor.name,
|
||||||
|
charUuid.toString().c_str(), pAddress.c_str()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 0x2A1F - Notify temperature x0.1C (atc1441/pvvx)
|
||||||
|
if (!tempNotifyCreated) {
|
||||||
|
NimBLEUUID charUuid((uint16_t) 0x2A1F);
|
||||||
|
pChar = pService->getCharacteristic(charUuid);
|
||||||
|
|
||||||
|
if (pChar && (pChar->canNotify() || pChar->canIndicate())) {
|
||||||
|
Log.straceln(
|
||||||
|
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': found temp char (%s) in env service on device %s"),
|
||||||
|
sensorId, sSensor.name, charUuid.toString().c_str(), pAddress.c_str()
|
||||||
|
);
|
||||||
|
|
||||||
|
pChar->unsubscribe();
|
||||||
|
tempNotifyCreated = pChar->subscribe(
|
||||||
|
pChar->canNotify(),
|
||||||
|
[sensorId](NimBLERemoteCharacteristic* pChar, uint8_t* pData, size_t length, bool isNotify) {
|
||||||
|
if (pChar == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const NimBLERemoteService* pService = pChar->getRemoteService();
|
||||||
|
if (pService == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
NimBLEClient* pClient = pService->getClient();
|
||||||
|
if (pClient == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto& sSensor = Sensors::settings[sensorId];
|
||||||
|
|
||||||
|
if (length != 2) {
|
||||||
|
Log.swarningln(
|
||||||
|
FPSTR(L_SENSORS_BLE),
|
||||||
|
F("Sensor #%hhu '%s': invalid notification data at temp char (%s) on device %s"),
|
||||||
|
sensorId,
|
||||||
|
sSensor.name,
|
||||||
|
pChar->getUUID().toString().c_str(),
|
||||||
|
pClient->getPeerAddress().toString().c_str()
|
||||||
|
);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
float rawTemp = (pChar->getValue<int16_t>() * 0.1f);
|
||||||
|
Log.straceln(
|
||||||
|
FPSTR(L_SENSORS_BLE),
|
||||||
|
F("Sensor #%hhu '%s': received temp: %.2f"),
|
||||||
|
sensorId, sSensor.name, rawTemp
|
||||||
|
);
|
||||||
|
|
||||||
|
// set temp
|
||||||
|
Sensors::setValueById(sensorId, rawTemp, Sensors::ValueType::TEMPERATURE, true, true);
|
||||||
|
|
||||||
|
// update rssi
|
||||||
|
Sensors::setValueById(sensorId, pClient->getRssi(), Sensors::ValueType::RSSI, false, false);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
if (tempNotifyCreated) {
|
||||||
|
Log.straceln(
|
||||||
|
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': subscribed to temp char (%s) in env service on device %s"),
|
||||||
|
sensorId, sSensor.name,
|
||||||
|
charUuid.toString().c_str(), pAddress.c_str()
|
||||||
|
);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Log.swarningln(
|
||||||
|
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': failed to subscribe to temp char (%s) in env service on device %s"),
|
||||||
|
sensorId, sSensor.name,
|
||||||
|
charUuid.toString().c_str(), pAddress.c_str()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!tempNotifyCreated) {
|
||||||
|
Log.swarningln(
|
||||||
|
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': not found supported temp chars in env service on device %s"),
|
||||||
|
sensorId, sSensor.name, pAddress.c_str()
|
||||||
|
);
|
||||||
|
|
||||||
|
pClient->disconnect();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 0x2A6F - Notify about humidity x0.01% (pvvx)
|
||||||
|
{
|
||||||
|
bool humidityNotifyCreated = false;
|
||||||
|
if (!humidityNotifyCreated) {
|
||||||
|
NimBLEUUID charUuid((uint16_t) 0x2A6F);
|
||||||
|
pChar = pService->getCharacteristic(charUuid);
|
||||||
|
|
||||||
|
if (pChar && (pChar->canNotify() || pChar->canIndicate())) {
|
||||||
|
Log.straceln(
|
||||||
|
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': found humidity char (%s) in env service on device %s"),
|
||||||
|
sensorId, sSensor.name, charUuid.toString().c_str(), pAddress.c_str()
|
||||||
|
);
|
||||||
|
|
||||||
|
pChar->unsubscribe();
|
||||||
|
humidityNotifyCreated = pChar->subscribe(
|
||||||
|
pChar->canNotify(),
|
||||||
|
[sensorId](NimBLERemoteCharacteristic* pChar, uint8_t* pData, size_t length, bool isNotify) {
|
||||||
|
if (pChar == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const NimBLERemoteService* pService = pChar->getRemoteService();
|
||||||
|
if (pService == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
NimBLEClient* pClient = pService->getClient();
|
||||||
|
if (pClient == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto& sSensor = Sensors::settings[sensorId];
|
||||||
|
|
||||||
|
if (length != 2) {
|
||||||
|
Log.swarningln(
|
||||||
|
FPSTR(L_SENSORS_BLE),
|
||||||
|
F("Sensor #%hhu '%s': invalid notification data at humidity char (%s) on device %s"),
|
||||||
|
sensorId,
|
||||||
|
sSensor.name,
|
||||||
|
pChar->getUUID().toString().c_str(),
|
||||||
|
pClient->getPeerAddress().toString().c_str()
|
||||||
|
);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
float rawHumidity = (pChar->getValue<uint16_t>() * 0.01f);
|
||||||
|
Log.straceln(
|
||||||
|
FPSTR(L_SENSORS_BLE),
|
||||||
|
F("Sensor #%hhu '%s': received humidity: %.2f"),
|
||||||
|
sensorId, sSensor.name, rawHumidity
|
||||||
|
);
|
||||||
|
|
||||||
|
// set humidity
|
||||||
|
Sensors::setValueById(sensorId, rawHumidity, Sensors::ValueType::HUMIDITY, true, true);
|
||||||
|
|
||||||
|
// update rssi
|
||||||
|
Sensors::setValueById(sensorId, pClient->getRssi(), Sensors::ValueType::RSSI, false, false);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
if (humidityNotifyCreated) {
|
||||||
|
Log.straceln(
|
||||||
|
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': subscribed to humidity char (%s) in env service on device %s"),
|
||||||
|
sensorId, sSensor.name,
|
||||||
|
charUuid.toString().c_str(), pAddress.c_str()
|
||||||
|
);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Log.swarningln(
|
||||||
|
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': failed to subscribe to humidity char (%s) in env service on device %s"),
|
||||||
|
sensorId, sSensor.name,
|
||||||
|
charUuid.toString().c_str(), pAddress.c_str()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!humidityNotifyCreated) {
|
||||||
|
Log.swarningln(
|
||||||
|
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': not found supported humidity chars in env service on device %s"),
|
||||||
|
sensorId, sSensor.name, pAddress.c_str()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Battery Service (0x180F)
|
||||||
|
{
|
||||||
|
NimBLEUUID serviceUuid((uint16_t) 0x180F);
|
||||||
|
pService = pClient->getService(serviceUuid);
|
||||||
|
if (!pService) {
|
||||||
|
Log.straceln(
|
||||||
|
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': failed to find battery service (%s) on device %s"),
|
||||||
|
sensorId, sSensor.name, serviceUuid.toString().c_str(), pAddress.c_str()
|
||||||
|
);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Log.straceln(
|
||||||
|
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': found battery service (%s) on device %s"),
|
||||||
|
sensorId, sSensor.name, serviceUuid.toString().c_str(), pAddress.c_str()
|
||||||
|
);
|
||||||
|
|
||||||
|
// 0x2A19 - Notify the battery charge level 0..99% (pvvx)
|
||||||
|
bool batteryNotifyCreated = false;
|
||||||
|
if (!batteryNotifyCreated) {
|
||||||
|
NimBLEUUID charUuid((uint16_t) 0x2A19);
|
||||||
|
pChar = pService->getCharacteristic(charUuid);
|
||||||
|
|
||||||
|
if (pChar && (pChar->canNotify() || pChar->canIndicate())) {
|
||||||
|
Log.straceln(
|
||||||
|
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': found battery char (%s) in battery service on device %s"),
|
||||||
|
sensorId, sSensor.name, charUuid.toString().c_str(), pAddress.c_str()
|
||||||
|
);
|
||||||
|
|
||||||
|
pChar->unsubscribe();
|
||||||
|
batteryNotifyCreated = pChar->subscribe(
|
||||||
|
pChar->canNotify(),
|
||||||
|
[sensorId](NimBLERemoteCharacteristic* pChar, uint8_t* pData, size_t length, bool isNotify) {
|
||||||
|
if (pChar == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const NimBLERemoteService* pService = pChar->getRemoteService();
|
||||||
|
if (pService == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
NimBLEClient* pClient = pService->getClient();
|
||||||
|
if (pClient == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto& sSensor = Sensors::settings[sensorId];
|
||||||
|
|
||||||
|
if (length != 1) {
|
||||||
|
Log.swarningln(
|
||||||
|
FPSTR(L_SENSORS_BLE),
|
||||||
|
F("Sensor #%hhu '%s': invalid notification data at battery char (%s) on device %s"),
|
||||||
|
sensorId,
|
||||||
|
sSensor.name,
|
||||||
|
pChar->getUUID().toString().c_str(),
|
||||||
|
pClient->getPeerAddress().toString().c_str()
|
||||||
|
);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto rawBattery = pChar->getValue<uint8_t>();
|
||||||
|
Log.straceln(
|
||||||
|
FPSTR(L_SENSORS_BLE),
|
||||||
|
F("Sensor #%hhu '%s': received battery: %hhu"),
|
||||||
|
sensorId, sSensor.name, rawBattery
|
||||||
|
);
|
||||||
|
|
||||||
|
// set battery
|
||||||
|
Sensors::setValueById(sensorId, rawBattery, Sensors::ValueType::BATTERY, true, true);
|
||||||
|
|
||||||
|
// update rssi
|
||||||
|
Sensors::setValueById(sensorId, pClient->getRssi(), Sensors::ValueType::RSSI, false, false);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
if (batteryNotifyCreated) {
|
||||||
|
Log.straceln(
|
||||||
|
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': subscribed to battery char (%s) in battery service on device %s"),
|
||||||
|
sensorId, sSensor.name,
|
||||||
|
charUuid.toString().c_str(), pAddress.c_str()
|
||||||
|
);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Log.swarningln(
|
||||||
|
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': failed to subscribe to battery char (%s) in battery service on device %s"),
|
||||||
|
sensorId, sSensor.name,
|
||||||
|
charUuid.toString().c_str(), pAddress.c_str()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!batteryNotifyCreated) {
|
||||||
|
Log.swarningln(
|
||||||
|
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': not found supported battery chars in battery service on device %s"),
|
||||||
|
sensorId, sSensor.name, pAddress.c_str()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool setDateOnBleSensor(NimBLEClient* pClient, const struct tm *ptm) {
|
||||||
|
auto ts = mkgmtime(ptm);
|
||||||
|
|
||||||
|
uint8_t data[5] = {};
|
||||||
|
data[0] = 0x23;
|
||||||
|
data[1] = ts & 0xff;
|
||||||
|
data[2] = (ts >> 8) & 0xff;
|
||||||
|
data[3] = (ts >> 16) & 0xff;
|
||||||
|
data[4] = (ts >> 24) & 0xff;
|
||||||
|
|
||||||
|
return pClient->setValue(
|
||||||
|
NimBLEUUID((uint16_t) 0x1f10),
|
||||||
|
NimBLEUUID((uint16_t) 0x1f1f),
|
||||||
|
NimBLEAttValue(data, sizeof(data))
|
||||||
|
);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void updateConnectionStatus() {
|
void updateConnectionStatus() {
|
||||||
|
|||||||
@@ -32,8 +32,9 @@ struct Settings {
|
|||||||
} serial;
|
} serial;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
bool enabled = DEFAULT_WEBSERIAL_ENABLED;
|
bool enabled = DEFAULT_TELNET_ENABLED;
|
||||||
} webSerial;
|
unsigned short port = DEFAULT_TELNET_PORT;
|
||||||
|
} telnet;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
char server[49] = "pool.ntp.org";
|
char server[49] = "pool.ntp.org";
|
||||||
@@ -120,8 +121,8 @@ struct Settings {
|
|||||||
} overheatProtection;
|
} overheatProtection;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
uint8_t highTemp = 15;
|
||||||
uint8_t lowTemp = 10;
|
uint8_t lowTemp = 10;
|
||||||
unsigned short thresholdTime = 600;
|
|
||||||
} freezeProtection;
|
} freezeProtection;
|
||||||
} heating;
|
} heating;
|
||||||
|
|
||||||
@@ -303,6 +304,7 @@ struct Variables {
|
|||||||
bool enabled = false;
|
bool enabled = false;
|
||||||
bool indoorTempControl = false;
|
bool indoorTempControl = false;
|
||||||
bool overheat = false;
|
bool overheat = false;
|
||||||
|
bool freezing = false;
|
||||||
float setpointTemp = 0.0f;
|
float setpointTemp = 0.0f;
|
||||||
float targetTemp = 0.0f;
|
float targetTemp = 0.0f;
|
||||||
float currentTemp = 0.0f;
|
float currentTemp = 0.0f;
|
||||||
|
|||||||
@@ -42,8 +42,12 @@
|
|||||||
#define DEFAULT_SERIAL_BAUD 115200
|
#define DEFAULT_SERIAL_BAUD 115200
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef DEFAULT_WEBSERIAL_ENABLED
|
#ifndef DEFAULT_TELNET_ENABLED
|
||||||
#define DEFAULT_WEBSERIAL_ENABLED true
|
#define DEFAULT_TELNET_ENABLED true
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef DEFAULT_TELNET_PORT
|
||||||
|
#define DEFAULT_TELNET_PORT 23
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef USE_BLE
|
#ifndef USE_BLE
|
||||||
@@ -71,7 +75,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef DEFAULT_LOG_LEVEL
|
#ifndef DEFAULT_LOG_LEVEL
|
||||||
#define DEFAULT_LOG_LEVEL TinyLoggerLevel::VERBOSE
|
#define DEFAULT_LOG_LEVEL TinyLogger::Level::VERBOSE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef DEFAULT_STATUS_LED_GPIO
|
#ifndef DEFAULT_STATUS_LED_GPIO
|
||||||
|
|||||||
31
src/main.cpp
31
src/main.cpp
@@ -1,8 +1,11 @@
|
|||||||
|
#define ARDUINOJSON_USE_DOUBLE 0
|
||||||
|
#define ARDUINOJSON_USE_LONG_LONG 0
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
#include <FileData.h>
|
#include <FileData.h>
|
||||||
#include <LittleFS.h>
|
#include <LittleFS.h>
|
||||||
#include <MycilaWebSerial.h>
|
#include <ESPTelnetStream.h>
|
||||||
|
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
#include "strings.h"
|
#include "strings.h"
|
||||||
@@ -34,7 +37,7 @@
|
|||||||
using namespace NetworkUtils;
|
using namespace NetworkUtils;
|
||||||
|
|
||||||
// Vars
|
// Vars
|
||||||
WebSerial* webSerial = nullptr;
|
ESPTelnetStream* telnetStream = nullptr;
|
||||||
NetworkMgr* network = nullptr;
|
NetworkMgr* network = nullptr;
|
||||||
Sensors::Result sensorsResults[SENSORS_AMOUNT];
|
Sensors::Result sensorsResults[SENSORS_AMOUNT];
|
||||||
|
|
||||||
@@ -58,7 +61,7 @@ void setup() {
|
|||||||
Sensors::results = sensorsResults;
|
Sensors::results = sensorsResults;
|
||||||
LittleFS.begin();
|
LittleFS.begin();
|
||||||
|
|
||||||
Log.setLevel(TinyLoggerLevel::VERBOSE);
|
Log.setLevel(TinyLogger::Level::VERBOSE);
|
||||||
Log.setServiceTemplate("\033[1m[%s]\033[22m");
|
Log.setServiceTemplate("\033[1m[%s]\033[22m");
|
||||||
Log.setLevelTemplate("\033[1m[%s]\033[22m");
|
Log.setLevelTemplate("\033[1m[%s]\033[22m");
|
||||||
Log.setMsgPrefix("\033[m ");
|
Log.setMsgPrefix("\033[m ");
|
||||||
@@ -76,7 +79,7 @@ void setup() {
|
|||||||
#if ARDUINO_USB_MODE
|
#if ARDUINO_USB_MODE
|
||||||
Serial.setTxBufferSize(512);
|
Serial.setTxBufferSize(512);
|
||||||
#endif
|
#endif
|
||||||
Log.addHandler(&Serial);
|
Log.addStream(&Serial);
|
||||||
Log.print("\n\n\r");
|
Log.print("\n\n\r");
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -160,24 +163,24 @@ void setup() {
|
|||||||
// Logs settings
|
// Logs settings
|
||||||
if (!settings.system.serial.enabled) {
|
if (!settings.system.serial.enabled) {
|
||||||
Serial.end();
|
Serial.end();
|
||||||
Log.clearHandlers();
|
Log.clearStreams();
|
||||||
|
|
||||||
} else if (settings.system.serial.baudrate != 115200) {
|
} else if (settings.system.serial.baudrate != 115200) {
|
||||||
Serial.end();
|
Serial.end();
|
||||||
Log.clearHandlers();
|
Log.clearStreams();
|
||||||
|
|
||||||
Serial.begin(settings.system.serial.baudrate);
|
Serial.begin(settings.system.serial.baudrate);
|
||||||
Log.addHandler(&Serial);
|
Log.addStream(&Serial);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings.system.webSerial.enabled) {
|
if (settings.system.telnet.enabled) {
|
||||||
webSerial = new WebSerial();
|
telnetStream = new ESPTelnetStream;
|
||||||
webSerial->setBuffer(100);
|
telnetStream->setKeepAliveInterval(500);
|
||||||
Log.addHandler(webSerial);
|
Log.addStream(telnetStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings.system.logLevel >= TinyLoggerLevel::SILENT && settings.system.logLevel <= TinyLoggerLevel::VERBOSE) {
|
if (settings.system.logLevel >= TinyLogger::Level::SILENT && settings.system.logLevel <= TinyLogger::Level::VERBOSE) {
|
||||||
Log.setLevel(static_cast<TinyLoggerLevel>(settings.system.logLevel));
|
Log.setLevel(static_cast<TinyLogger::Level>(settings.system.logLevel));
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -213,7 +216,7 @@ void setup() {
|
|||||||
tRegulator = new RegulatorTask(true, 10000);
|
tRegulator = new RegulatorTask(true, 10000);
|
||||||
Scheduler.start(tRegulator);
|
Scheduler.start(tRegulator);
|
||||||
|
|
||||||
tPortal = new PortalTask(true, 10);
|
tPortal = new PortalTask(true, 0);
|
||||||
Scheduler.start(tPortal);
|
Scheduler.start(tPortal);
|
||||||
|
|
||||||
tMain = new MainTask(true, 100);
|
tMain = new MainTask(true, 100);
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ const char S_EXTERNAL_PUMP[] PROGMEM = "externalPump";
|
|||||||
const char S_FACTOR[] PROGMEM = "factor";
|
const char S_FACTOR[] PROGMEM = "factor";
|
||||||
const char S_FAULT[] PROGMEM = "fault";
|
const char S_FAULT[] PROGMEM = "fault";
|
||||||
const char S_FREEZE_PROTECTION[] PROGMEM = "freezeProtection";
|
const char S_FREEZE_PROTECTION[] PROGMEM = "freezeProtection";
|
||||||
|
const char S_FREEZING[] PROGMEM = "freezing";
|
||||||
const char S_FILTERING[] PROGMEM = "filtering";
|
const char S_FILTERING[] PROGMEM = "filtering";
|
||||||
const char S_FILTERING_FACTOR[] PROGMEM = "filteringFactor";
|
const char S_FILTERING_FACTOR[] PROGMEM = "filteringFactor";
|
||||||
const char S_FLAGS[] PROGMEM = "flags";
|
const char S_FLAGS[] PROGMEM = "flags";
|
||||||
@@ -165,7 +166,6 @@ const char S_POWER[] PROGMEM = "power";
|
|||||||
const char S_PREFIX[] PROGMEM = "prefix";
|
const char S_PREFIX[] PROGMEM = "prefix";
|
||||||
const char S_PROTOCOL_VERSION[] PROGMEM = "protocolVersion";
|
const char S_PROTOCOL_VERSION[] PROGMEM = "protocolVersion";
|
||||||
const char S_PURPOSE[] PROGMEM = "purpose";
|
const char S_PURPOSE[] PROGMEM = "purpose";
|
||||||
const char S_PSRAM[] PROGMEM = "psram";
|
|
||||||
const char S_P_FACTOR[] PROGMEM = "p_factor";
|
const char S_P_FACTOR[] PROGMEM = "p_factor";
|
||||||
const char S_P_MULTIPLIER[] PROGMEM = "p_multiplier";
|
const char S_P_MULTIPLIER[] PROGMEM = "p_multiplier";
|
||||||
const char S_REAL_SIZE[] PROGMEM = "realSize";
|
const char S_REAL_SIZE[] PROGMEM = "realSize";
|
||||||
@@ -202,6 +202,7 @@ const char S_SYSTEM[] PROGMEM = "system";
|
|||||||
const char S_TARGET[] PROGMEM = "target";
|
const char S_TARGET[] PROGMEM = "target";
|
||||||
const char S_TARGET_DIFF_FACTOR[] PROGMEM = "targetDiffFactor";
|
const char S_TARGET_DIFF_FACTOR[] PROGMEM = "targetDiffFactor";
|
||||||
const char S_TARGET_TEMP[] PROGMEM = "targetTemp";
|
const char S_TARGET_TEMP[] PROGMEM = "targetTemp";
|
||||||
|
const char S_TELNET[] PROGMEM = "telnet";
|
||||||
const char S_TEMPERATURE[] PROGMEM = "temperature";
|
const char S_TEMPERATURE[] PROGMEM = "temperature";
|
||||||
const char S_THRESHOLD_HIGH[] PROGMEM = "thresholdHigh";
|
const char S_THRESHOLD_HIGH[] PROGMEM = "thresholdHigh";
|
||||||
const char S_THRESHOLD_LOW[] PROGMEM = "thresholdLow";
|
const char S_THRESHOLD_LOW[] PROGMEM = "thresholdLow";
|
||||||
@@ -219,4 +220,3 @@ const char S_USE_DHCP[] PROGMEM = "useDhcp";
|
|||||||
const char S_USER[] PROGMEM = "user";
|
const char S_USER[] PROGMEM = "user";
|
||||||
const char S_VALUE[] PROGMEM = "value";
|
const char S_VALUE[] PROGMEM = "value";
|
||||||
const char S_VERSION[] PROGMEM = "version";
|
const char S_VERSION[] PROGMEM = "version";
|
||||||
const char S_WEBSERIAL[] PROGMEM = "webSerial";
|
|
||||||
46
src/utils.h
46
src/utils.h
@@ -425,8 +425,9 @@ void settingsToJson(const Settings& src, JsonVariant dst, bool safe = false) {
|
|||||||
serial[FPSTR(S_ENABLED)] = src.system.serial.enabled;
|
serial[FPSTR(S_ENABLED)] = src.system.serial.enabled;
|
||||||
serial[FPSTR(S_BAUDRATE)] = src.system.serial.baudrate;
|
serial[FPSTR(S_BAUDRATE)] = src.system.serial.baudrate;
|
||||||
|
|
||||||
auto webSerial = system[FPSTR(S_WEBSERIAL)].to<JsonObject>();
|
auto telnet = system[FPSTR(S_TELNET)].to<JsonObject>();
|
||||||
webSerial[FPSTR(S_ENABLED)] = src.system.webSerial.enabled;
|
telnet[FPSTR(S_ENABLED)] = src.system.telnet.enabled;
|
||||||
|
telnet[FPSTR(S_PORT)] = src.system.telnet.port;
|
||||||
|
|
||||||
auto ntp = system[FPSTR(S_NTP)].to<JsonObject>();
|
auto ntp = system[FPSTR(S_NTP)].to<JsonObject>();
|
||||||
ntp[FPSTR(S_SERVER)] = src.system.ntp.server;
|
ntp[FPSTR(S_SERVER)] = src.system.ntp.server;
|
||||||
@@ -504,8 +505,8 @@ void settingsToJson(const Settings& src, JsonVariant dst, bool safe = false) {
|
|||||||
heatingOverheatProtection[FPSTR(S_LOW_TEMP)] = src.heating.overheatProtection.lowTemp;
|
heatingOverheatProtection[FPSTR(S_LOW_TEMP)] = src.heating.overheatProtection.lowTemp;
|
||||||
|
|
||||||
auto freezeProtection = heating[FPSTR(S_FREEZE_PROTECTION)].to<JsonObject>();
|
auto freezeProtection = heating[FPSTR(S_FREEZE_PROTECTION)].to<JsonObject>();
|
||||||
|
freezeProtection[FPSTR(S_HIGH_TEMP)] = src.heating.freezeProtection.highTemp;
|
||||||
freezeProtection[FPSTR(S_LOW_TEMP)] = src.heating.freezeProtection.lowTemp;
|
freezeProtection[FPSTR(S_LOW_TEMP)] = src.heating.freezeProtection.lowTemp;
|
||||||
freezeProtection[FPSTR(S_THRESHOLD_TIME)] = src.heating.freezeProtection.thresholdTime;
|
|
||||||
|
|
||||||
auto dhw = dst[FPSTR(S_DHW)].to<JsonObject>();
|
auto dhw = dst[FPSTR(S_DHW)].to<JsonObject>();
|
||||||
dhw[FPSTR(S_ENABLED)] = src.dhw.enabled;
|
dhw[FPSTR(S_ENABLED)] = src.dhw.enabled;
|
||||||
@@ -580,7 +581,7 @@ bool jsonToSettings(const JsonVariantConst src, Settings& dst, bool safe = false
|
|||||||
if (!src[FPSTR(S_SYSTEM)][FPSTR(S_LOG_LEVEL)].isNull()) {
|
if (!src[FPSTR(S_SYSTEM)][FPSTR(S_LOG_LEVEL)].isNull()) {
|
||||||
uint8_t value = src[FPSTR(S_SYSTEM)][FPSTR(S_LOG_LEVEL)].as<uint8_t>();
|
uint8_t value = src[FPSTR(S_SYSTEM)][FPSTR(S_LOG_LEVEL)].as<uint8_t>();
|
||||||
|
|
||||||
if (value != dst.system.logLevel && value >= TinyLoggerLevel::SILENT && value <= TinyLoggerLevel::VERBOSE) {
|
if (value != dst.system.logLevel && value >= TinyLogger::Level::SILENT && value <= TinyLogger::Level::VERBOSE) {
|
||||||
dst.system.logLevel = value;
|
dst.system.logLevel = value;
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
@@ -606,11 +607,20 @@ bool jsonToSettings(const JsonVariantConst src, Settings& dst, bool safe = false
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (src[FPSTR(S_SYSTEM)][FPSTR(S_WEBSERIAL)][FPSTR(S_ENABLED)].is<bool>()) {
|
if (src[FPSTR(S_SYSTEM)][FPSTR(S_TELNET)][FPSTR(S_ENABLED)].is<bool>()) {
|
||||||
bool value = src[FPSTR(S_SYSTEM)][FPSTR(S_WEBSERIAL)][FPSTR(S_ENABLED)].as<bool>();
|
bool value = src[FPSTR(S_SYSTEM)][FPSTR(S_TELNET)][FPSTR(S_ENABLED)].as<bool>();
|
||||||
|
|
||||||
if (value != dst.system.webSerial.enabled) {
|
if (value != dst.system.telnet.enabled) {
|
||||||
dst.system.webSerial.enabled = value;
|
dst.system.telnet.enabled = value;
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!src[FPSTR(S_SYSTEM)][FPSTR(S_TELNET)][FPSTR(S_PORT)].isNull()) {
|
||||||
|
unsigned short value = src[FPSTR(S_SYSTEM)][FPSTR(S_TELNET)][FPSTR(S_PORT)].as<unsigned short>();
|
||||||
|
|
||||||
|
if (value > 0 && value <= 65535 && value != dst.system.telnet.port) {
|
||||||
|
dst.system.telnet.port = value;
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1416,6 +1426,15 @@ bool jsonToSettings(const JsonVariantConst src, Settings& dst, bool safe = false
|
|||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!src[FPSTR(S_HEATING)][FPSTR(S_FREEZE_PROTECTION)][FPSTR(S_HIGH_TEMP)].isNull()) {
|
||||||
|
unsigned short value = src[FPSTR(S_HEATING)][FPSTR(S_FREEZE_PROTECTION)][FPSTR(S_HIGH_TEMP)].as<uint8_t>();
|
||||||
|
|
||||||
|
if (isValidTemp(value, dst.system.unitSystem, 1, 50) && value != dst.heating.freezeProtection.highTemp) {
|
||||||
|
dst.heating.freezeProtection.highTemp = value;
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!src[FPSTR(S_HEATING)][FPSTR(S_FREEZE_PROTECTION)][FPSTR(S_LOW_TEMP)].isNull()) {
|
if (!src[FPSTR(S_HEATING)][FPSTR(S_FREEZE_PROTECTION)][FPSTR(S_LOW_TEMP)].isNull()) {
|
||||||
unsigned short value = src[FPSTR(S_HEATING)][FPSTR(S_FREEZE_PROTECTION)][FPSTR(S_LOW_TEMP)].as<uint8_t>();
|
unsigned short value = src[FPSTR(S_HEATING)][FPSTR(S_FREEZE_PROTECTION)][FPSTR(S_LOW_TEMP)].as<uint8_t>();
|
||||||
|
|
||||||
@@ -1425,16 +1444,10 @@ bool jsonToSettings(const JsonVariantConst src, Settings& dst, bool safe = false
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!src[FPSTR(S_HEATING)][FPSTR(S_FREEZE_PROTECTION)][FPSTR(S_THRESHOLD_TIME)].isNull()) {
|
if (dst.heating.freezeProtection.highTemp < dst.heating.freezeProtection.lowTemp) {
|
||||||
unsigned short value = src[FPSTR(S_HEATING)][FPSTR(S_FREEZE_PROTECTION)][FPSTR(S_THRESHOLD_TIME)].as<unsigned short>();
|
dst.heating.freezeProtection.highTemp = dst.heating.freezeProtection.lowTemp;
|
||||||
|
|
||||||
if (value >= 30 && value <= 1800) {
|
|
||||||
if (value != dst.heating.freezeProtection.thresholdTime) {
|
|
||||||
dst.heating.freezeProtection.thresholdTime = value;
|
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// dhw
|
// dhw
|
||||||
@@ -2160,6 +2173,7 @@ void varsToJson(const Variables& src, JsonVariant dst) {
|
|||||||
mHeating[FPSTR(S_BLOCKING)] = src.master.heating.blocking;
|
mHeating[FPSTR(S_BLOCKING)] = src.master.heating.blocking;
|
||||||
mHeating[FPSTR(S_INDOOR_TEMP_CONTROL)] = src.master.heating.indoorTempControl;
|
mHeating[FPSTR(S_INDOOR_TEMP_CONTROL)] = src.master.heating.indoorTempControl;
|
||||||
mHeating[FPSTR(S_OVERHEAT)] = src.master.heating.overheat;
|
mHeating[FPSTR(S_OVERHEAT)] = src.master.heating.overheat;
|
||||||
|
mHeating[FPSTR(S_FREEZING)] = src.master.heating.freezing;
|
||||||
mHeating[FPSTR(S_SETPOINT_TEMP)] = roundf(src.master.heating.setpointTemp, 2);
|
mHeating[FPSTR(S_SETPOINT_TEMP)] = roundf(src.master.heating.setpointTemp, 2);
|
||||||
mHeating[FPSTR(S_TARGET_TEMP)] = roundf(src.master.heating.targetTemp, 2);
|
mHeating[FPSTR(S_TARGET_TEMP)] = roundf(src.master.heating.targetTemp, 2);
|
||||||
mHeating[FPSTR(S_CURRENT_TEMP)] = roundf(src.master.heating.currentTemp, 2);
|
mHeating[FPSTR(S_CURRENT_TEMP)] = roundf(src.master.heating.currentTemp, 2);
|
||||||
|
|||||||
@@ -320,9 +320,15 @@
|
|||||||
},
|
},
|
||||||
"freezeProtection": {
|
"freezeProtection": {
|
||||||
"title": "防冻保护",
|
"title": "防冻保护",
|
||||||
"desc": "当热媒或室内温度在<b>等待时间</b> 内降至<b>低温阈值</b>以下时,系统将强制启动加热功能。",
|
"desc": "如果热载体或室内温度低于 <b>低温</b>,加热将被强制开启。",
|
||||||
"lowTemp": "低温阈值",
|
"highTemp": {
|
||||||
"thresholdTime": "等待时间<small>(秒)</small>"
|
"title": "高温阈值",
|
||||||
|
"note": "防冻保护激活后系统恢复正常模式的阈值"
|
||||||
|
},
|
||||||
|
"lowTemp": {
|
||||||
|
"title": "低温阈值",
|
||||||
|
"note": "强制开启加热的阈值"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
"portal": {
|
"portal": {
|
||||||
@@ -342,8 +348,12 @@
|
|||||||
"enable": "启用串口",
|
"enable": "启用串口",
|
||||||
"baud": "串口波特率"
|
"baud": "串口波特率"
|
||||||
},
|
},
|
||||||
"webSerial": {
|
"telnet": {
|
||||||
"enable": "启用 WebSerial"
|
"enable": "启用 Telnet",
|
||||||
|
"port": {
|
||||||
|
"title": "Telnet 端口",
|
||||||
|
"note": "默认值:23"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"ntp": {
|
"ntp": {
|
||||||
"server": "NTP服务器",
|
"server": "NTP服务器",
|
||||||
|
|||||||
@@ -119,6 +119,7 @@
|
|||||||
"mHeatEnabled": "Heating enabled",
|
"mHeatEnabled": "Heating enabled",
|
||||||
"mHeatBlocking": "Heating blocked",
|
"mHeatBlocking": "Heating blocked",
|
||||||
"mHeatOverheat": "Heating overheat",
|
"mHeatOverheat": "Heating overheat",
|
||||||
|
"mHeatFreezing": "Heating freezing",
|
||||||
"sHeatActive": "Heating active",
|
"sHeatActive": "Heating active",
|
||||||
"mHeatSetpointTemp": "Heating setpoint temp",
|
"mHeatSetpointTemp": "Heating setpoint temp",
|
||||||
"mHeatTargetTemp": "Heating target temp",
|
"mHeatTargetTemp": "Heating target temp",
|
||||||
@@ -320,9 +321,15 @@
|
|||||||
},
|
},
|
||||||
"freezeProtection": {
|
"freezeProtection": {
|
||||||
"title": "Freeze protection",
|
"title": "Freeze protection",
|
||||||
"desc": "Heating will be forced to turn on if the heat carrier or indoor temperature drops below <b>Low temperature</b> during <b>Waiting time</b>.",
|
"desc": "Heating will be forced to turn on if the heat carrier or indoor temperature drops below <b>Low temperature</b>.",
|
||||||
"lowTemp": "Low temperature threshold",
|
"highTemp": {
|
||||||
"thresholdTime": "Waiting time <small>(sec)</small>"
|
"title": "High temperature threshold",
|
||||||
|
"note": "Threshold when the system returns to normal mode after freeze protection activation"
|
||||||
|
},
|
||||||
|
"lowTemp": {
|
||||||
|
"title": "Low temperature threshold",
|
||||||
|
"note": "Threshold when heating is forced to turn on"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
"portal": {
|
"portal": {
|
||||||
@@ -342,8 +349,12 @@
|
|||||||
"enable": "Enabled Serial port",
|
"enable": "Enabled Serial port",
|
||||||
"baud": "Serial port baud rate"
|
"baud": "Serial port baud rate"
|
||||||
},
|
},
|
||||||
"webSerial": {
|
"telnet": {
|
||||||
"enable": "Enabled WebSerial"
|
"enable": "Enabled Telnet",
|
||||||
|
"port": {
|
||||||
|
"title": "Telnet port",
|
||||||
|
"note": "Default: 23"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"ntp": {
|
"ntp": {
|
||||||
"server": "NTP server",
|
"server": "NTP server",
|
||||||
|
|||||||
@@ -320,9 +320,15 @@
|
|||||||
},
|
},
|
||||||
"freezeProtection": {
|
"freezeProtection": {
|
||||||
"title": "Protezione antigelo",
|
"title": "Protezione antigelo",
|
||||||
"desc": "Il riscaldamento verrà attivato forzatamente se la temperatura del vettore di calore o interna scende al di sotto della <b>temperatura minima</b> durante il <b>tempo di attesa</b>.",
|
"desc": "Il riscaldamento verrà forzatamente attivato se la temperatura del vettore termico o la temperatura interna scende al di sotto della <b>Soglia di temperatura bassa</b>.",
|
||||||
"lowTemp": "Soglia di temperatura minima",
|
"highTemp": {
|
||||||
"thresholdTime": "Tempo di attesa <small>(sec)</small>"
|
"title": "Soglia di temperatura alta",
|
||||||
|
"note": "Soglia quando il sistema ritorna alla modalità normale dopo l'attivazione della protezione antigelo"
|
||||||
|
},
|
||||||
|
"lowTemp": {
|
||||||
|
"title": "Soglia di temperatura bassa",
|
||||||
|
"note": "Soglia quando il riscaldamento viene forzatamente attivato"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
"portal": {
|
"portal": {
|
||||||
@@ -342,8 +348,12 @@
|
|||||||
"enable": "Porta seriale attivata",
|
"enable": "Porta seriale attivata",
|
||||||
"baud": "Porta seriale baud rate"
|
"baud": "Porta seriale baud rate"
|
||||||
},
|
},
|
||||||
"webSerial": {
|
"telnet": {
|
||||||
"enable": "WebSerial attivato"
|
"enable": "Telnet attivato",
|
||||||
|
"port": {
|
||||||
|
"title": "Porta Telnet",
|
||||||
|
"note": "Default: 23"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"ntp": {
|
"ntp": {
|
||||||
"server": "NTP server",
|
"server": "NTP server",
|
||||||
|
|||||||
@@ -294,11 +294,18 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"freezeProtection": {
|
"freezeProtection": {
|
||||||
"title": "Vorstbeveiliging",
|
"title": "Vorbeveiliging",
|
||||||
"desc": "De verwarming wordt geforceerd ingeschakeld als de temperatuur van de warmtedrager of de binnentemperatuur onder de <b>Lage temperatuur</b> daalt gedurende de <b>Wachttijd</b>.",
|
"desc": "Verwarming zal geforceerd worden ingeschakeld als de temperatuur van de warmtedrager of de binnentemperatuur daalt onder de <b>Lage temperatuurdrempel</b>.",
|
||||||
"lowTemp": "Drempelwaarde lage temperatuur",
|
"highTemp": {
|
||||||
"thresholdTime": "Wachttijd <small>(sec)</small>"
|
"title": "Hoge temperatuurdrempel",
|
||||||
|
"note": "Drempel waarna het systeem terugkeert naar de normale modus na activering van de vorbeveiliging"
|
||||||
},
|
},
|
||||||
|
"lowTemp": {
|
||||||
|
"title": "Lage temperatuurdrempel",
|
||||||
|
"note": "Drempel wanneer de verwarming geforceerd wordt ingeschakeld"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
"portal": {
|
"portal": {
|
||||||
"login": "Gebruikersnaam",
|
"login": "Gebruikersnaam",
|
||||||
"password": "Wachtwoord",
|
"password": "Wachtwoord",
|
||||||
@@ -315,8 +322,12 @@
|
|||||||
"enable": "Seriële poort ingeschakeld",
|
"enable": "Seriële poort ingeschakeld",
|
||||||
"baud": "Baudrate seriële poort"
|
"baud": "Baudrate seriële poort"
|
||||||
},
|
},
|
||||||
"webSerial": {
|
"telnet": {
|
||||||
"enable": "WebSerial ingeschakeld"
|
"enable": "Telnet ingeschakeld",
|
||||||
|
"port": {
|
||||||
|
"title": "Telnet-poort",
|
||||||
|
"note": "Standaard: 23"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"ntp": {
|
"ntp": {
|
||||||
"server": "NTP-server",
|
"server": "NTP-server",
|
||||||
|
|||||||
@@ -320,9 +320,15 @@
|
|||||||
},
|
},
|
||||||
"freezeProtection": {
|
"freezeProtection": {
|
||||||
"title": "Защита от замерзания",
|
"title": "Защита от замерзания",
|
||||||
"desc": "Отопление будет принудительно включено, если темп. теплоносителя или внутренняя темп. опустится ниже <b>нижнего порога</b> в течение <b>времени ожидания</b>.",
|
"desc": "Отопление будет принудительно включено, если темп. теплоносителя или внутренняя темп. опустится ниже <b>нижнего порога</b>.",
|
||||||
"lowTemp": "Нижний порог температуры",
|
"highTemp": {
|
||||||
"thresholdTime": "Время ожидания <small>(сек)</small>"
|
"title": "Верхний порог температуры",
|
||||||
|
"note": "Порог, при котором система вернется в нормальное состояние после активации защиты от замерзания"
|
||||||
|
},
|
||||||
|
"lowTemp": {
|
||||||
|
"title": "Нижний порог температуры",
|
||||||
|
"note": "Порог, при котором отопление будет принудительно включено"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
"portal": {
|
"portal": {
|
||||||
@@ -342,8 +348,12 @@
|
|||||||
"enable": "Вкл. Serial порт",
|
"enable": "Вкл. Serial порт",
|
||||||
"baud": "Скорость Serial порта"
|
"baud": "Скорость Serial порта"
|
||||||
},
|
},
|
||||||
"webSerial": {
|
"telnet": {
|
||||||
"enable": "Вкл. WebSerial"
|
"enable": "Вкл. Telnet",
|
||||||
|
"port": {
|
||||||
|
"title": "Telnet порт",
|
||||||
|
"note": "По умолчанию: 23"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"ntp": {
|
"ntp": {
|
||||||
"server": "NTP сервер",
|
"server": "NTP сервер",
|
||||||
|
|||||||
@@ -195,6 +195,10 @@
|
|||||||
<th scope="row" data-i18n>dashboard.states.mHeatOverheat</th>
|
<th scope="row" data-i18n>dashboard.states.mHeatOverheat</th>
|
||||||
<td><i class="mHeatOverheat"></i></td>
|
<td><i class="mHeatOverheat"></i></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="row" data-i18n>dashboard.states.mHeatFreezing</th>
|
||||||
|
<td><i class="mHeatFreezing"></i></td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row" data-i18n>dashboard.states.sHeatActive</th>
|
<th scope="row" data-i18n>dashboard.states.sHeatActive</th>
|
||||||
<td><i class="sHeatActive"></i></td>
|
<td><i class="sHeatActive"></i></td>
|
||||||
@@ -491,9 +495,6 @@
|
|||||||
if (modified) {
|
if (modified) {
|
||||||
parameters.method = "POST";
|
parameters.method = "POST";
|
||||||
parameters.body = JSON.stringify(newSettings);
|
parameters.body = JSON.stringify(newSettings);
|
||||||
parameters.headers = {
|
|
||||||
"Content-Type": "application/json"
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await fetch("/api/settings", parameters);
|
const response = await fetch("/api/settings", parameters);
|
||||||
@@ -636,6 +637,11 @@
|
|||||||
result.master.heating.overheat ? "success" : "error",
|
result.master.heating.overheat ? "success" : "error",
|
||||||
result.master.heating.overheat ? "red" : "green"
|
result.master.heating.overheat ? "red" : "green"
|
||||||
);
|
);
|
||||||
|
setStatus(
|
||||||
|
'.mHeatFreezing',
|
||||||
|
result.master.heating.freezing ? "success" : "error",
|
||||||
|
result.master.heating.freezing ? "red" : "green"
|
||||||
|
);
|
||||||
setValue('.mHeatSetpointTemp', result.master.heating.setpointTemp);
|
setValue('.mHeatSetpointTemp', result.master.heating.setpointTemp);
|
||||||
setValue('.mHeatTargetTemp', result.master.heating.targetTemp);
|
setValue('.mHeatTargetTemp', result.master.heating.targetTemp);
|
||||||
setValue('.mHeatCurrTemp', result.master.heating.currentTemp);
|
setValue('.mHeatCurrTemp', result.master.heating.currentTemp);
|
||||||
|
|||||||
@@ -126,8 +126,8 @@
|
|||||||
</label>
|
</label>
|
||||||
|
|
||||||
<label>
|
<label>
|
||||||
<input type="checkbox" name="system[webSerial][enabled]" value="true">
|
<input type="checkbox" name="system[telnet][enabled]" value="true">
|
||||||
<span data-i18n>settings.system.webSerial.enable</span>
|
<span data-i18n>settings.system.telnet.enable</span>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<label>
|
<label>
|
||||||
@@ -156,6 +156,12 @@
|
|||||||
<option value="115200">115200</option>
|
<option value="115200">115200</option>
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
|
<label>
|
||||||
|
<span data-i18n>settings.system.telnet.port.title</span>
|
||||||
|
<input type="number" inputmode="numeric" name="system[telnet][port]" min="1" max="65535" step="1" required>
|
||||||
|
<small data-i18n>settings.system.telnet.port.note</small>
|
||||||
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<mark data-i18n>settings.note.restart</mark>
|
<mark data-i18n>settings.note.restart</mark>
|
||||||
@@ -259,13 +265,15 @@
|
|||||||
|
|
||||||
<div class="grid">
|
<div class="grid">
|
||||||
<label>
|
<label>
|
||||||
<span data-i18n>settings.freezeProtection.lowTemp</span>
|
<span data-i18n>settings.freezeProtection.highTemp.title</span>
|
||||||
<input type="number" inputmode="numeric" name="heating[freezeProtection][lowTemp]" min="0" max="0" step="1" required>
|
<input type="number" inputmode="numeric" name="heating[freezeProtection][highTemp]" min="0" max="0" step="1" required>
|
||||||
|
<small data-i18n>settings.freezeProtection.highTemp.note</small>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<label>
|
<label>
|
||||||
<span data-i18n>settings.freezeProtection.thresholdTime</span>
|
<span data-i18n>settings.freezeProtection.lowTemp.title</span>
|
||||||
<input type="number" inputmode="numeric" name="heating[freezeProtection][thresholdTime]" min="30" max="1800" step="1" required>
|
<input type="number" inputmode="numeric" name="heating[freezeProtection][lowTemp]" min="0" max="0" step="1" required>
|
||||||
|
<small data-i18n>settings.freezeProtection.lowTemp.note</small>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -1077,7 +1085,8 @@
|
|||||||
setSelectValue("[name='system[logLevel]']", data.system.logLevel);
|
setSelectValue("[name='system[logLevel]']", data.system.logLevel);
|
||||||
setCheckboxValue("[name='system[serial][enabled]']", data.system.serial.enabled);
|
setCheckboxValue("[name='system[serial][enabled]']", data.system.serial.enabled);
|
||||||
setSelectValue("[name='system[serial][baudrate]']", data.system.serial.baudrate);
|
setSelectValue("[name='system[serial][baudrate]']", data.system.serial.baudrate);
|
||||||
setCheckboxValue("[name='system[webSerial][enabled]']", data.system.webSerial.enabled);
|
setCheckboxValue("[name='system[telnet][enabled]']", data.system.telnet.enabled);
|
||||||
|
setInputValue("[name='system[telnet][port]']", data.system.telnet.port);
|
||||||
setInputValue("[name='system[ntp][server]']", data.system.ntp.server);
|
setInputValue("[name='system[ntp][server]']", data.system.ntp.server);
|
||||||
setInputValue("[name='system[ntp][timezone]']", data.system.ntp.timezone);
|
setInputValue("[name='system[ntp][timezone]']", data.system.ntp.timezone);
|
||||||
setRadioValue("[name='system[unitSystem]']", data.system.unitSystem);
|
setRadioValue("[name='system[unitSystem]']", data.system.unitSystem);
|
||||||
@@ -1177,11 +1186,14 @@
|
|||||||
"min": 0,
|
"min": 0,
|
||||||
"max": data.system.unitSystem == 0 ? 99 : 211
|
"max": data.system.unitSystem == 0 ? 99 : 211
|
||||||
});
|
});
|
||||||
|
setInputValue("[name='heating[freezeProtection][highTemp]']", data.heating.freezeProtection.highTemp, {
|
||||||
|
"min": data.system.unitSystem == 0 ? 1 : 34,
|
||||||
|
"max": data.system.unitSystem == 0 ? 50 : 122
|
||||||
|
});
|
||||||
setInputValue("[name='heating[freezeProtection][lowTemp]']", data.heating.freezeProtection.lowTemp, {
|
setInputValue("[name='heating[freezeProtection][lowTemp]']", data.heating.freezeProtection.lowTemp, {
|
||||||
"min": data.system.unitSystem == 0 ? 1 : 34,
|
"min": data.system.unitSystem == 0 ? 1 : 34,
|
||||||
"max": data.system.unitSystem == 0 ? 30 : 86
|
"max": data.system.unitSystem == 0 ? 30 : 86
|
||||||
});
|
});
|
||||||
setInputValue("[name='heating[freezeProtection][thresholdTime]']", data.heating.freezeProtection.thresholdTime);
|
|
||||||
setBusy('#heating-settings-busy', '#heating-settings', false);
|
setBusy('#heating-settings-busy', '#heating-settings', false);
|
||||||
|
|
||||||
// DHW
|
// DHW
|
||||||
|
|||||||
@@ -62,19 +62,19 @@
|
|||||||
|
|
||||||
<form action="/api/upgrade" id="upgrade">
|
<form action="/api/upgrade" id="upgrade">
|
||||||
<fieldset class="primary">
|
<fieldset class="primary">
|
||||||
<label>
|
<label for="firmware-file">
|
||||||
<span data-i18n>upgrade.fw</span>:
|
<span data-i18n>upgrade.fw</span>:
|
||||||
<div class="grid">
|
<div class="grid">
|
||||||
<input type="file" name="fw" accept=".bin">
|
<input type="file" name="firmware" id="firmware-file" accept=".bin">
|
||||||
<button type="button" class="fwResult hidden" disabled></button>
|
<button type="button" class="upgrade-firmware-result hidden" disabled></button>
|
||||||
</div>
|
</div>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<label>
|
<label for="filesystem-file">
|
||||||
<span data-i18n>upgrade.fs</span>:
|
<span data-i18n>upgrade.fs</span>:
|
||||||
<div class="grid">
|
<div class="grid">
|
||||||
<input type="file" name="fs" accept=".bin">
|
<input type="file" name="filesystem" id="filesystem-file" accept=".bin">
|
||||||
<button type="button" class="fsResult hidden" disabled></button>
|
<button type="button" class="upgrade-filesystem-result hidden" disabled></button>
|
||||||
</div>
|
</div>
|
||||||
</label>
|
</label>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
@@ -108,123 +108,7 @@
|
|||||||
lang.build();
|
lang.build();
|
||||||
|
|
||||||
setupRestoreBackupForm('#restore');
|
setupRestoreBackupForm('#restore');
|
||||||
|
setupUpgradeForm('#upgrade');
|
||||||
const upgradeForm = document.querySelector('#upgrade');
|
|
||||||
if (upgradeForm) {
|
|
||||||
upgradeForm.reset();
|
|
||||||
const statusToText = (status) => {
|
|
||||||
switch (status) {
|
|
||||||
case 0:
|
|
||||||
return "None";
|
|
||||||
case 1:
|
|
||||||
return "No file";
|
|
||||||
case 2:
|
|
||||||
return "Success";
|
|
||||||
case 3:
|
|
||||||
return "Prohibited";
|
|
||||||
case 4:
|
|
||||||
return "Size mismatch";
|
|
||||||
case 5:
|
|
||||||
return "Error on start";
|
|
||||||
case 6:
|
|
||||||
return "Error on write";
|
|
||||||
case 7:
|
|
||||||
return "Error on finish";
|
|
||||||
default:
|
|
||||||
return "Unknown";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
upgradeForm.addEventListener('submit', async (event) => {
|
|
||||||
event.preventDefault();
|
|
||||||
|
|
||||||
hide('.fwResult');
|
|
||||||
hide('.fsResult');
|
|
||||||
|
|
||||||
let button = upgradeForm.querySelector('button[type="submit"]');
|
|
||||||
button.textContent = i18n('button.uploading');
|
|
||||||
button.setAttribute('disabled', true);
|
|
||||||
button.setAttribute('aria-busy', true);
|
|
||||||
|
|
||||||
try {
|
|
||||||
let fd = new FormData();
|
|
||||||
|
|
||||||
const fw = upgradeForm.querySelector("[name='fw']").files;
|
|
||||||
if (fw.length > 0) {
|
|
||||||
fd.append("fw_size", fw[0].size);
|
|
||||||
fd.append("fw", fw[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
const fs = upgradeForm.querySelector("[name='fs']").files;
|
|
||||||
if (fs.length > 0) {
|
|
||||||
fd.append("fs_size", fs[0].size);
|
|
||||||
fd.append("fs", fs[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
let response = await fetch(upgradeForm.action, {
|
|
||||||
method: "POST",
|
|
||||||
cache: "no-cache",
|
|
||||||
credentials: "include",
|
|
||||||
body: fd
|
|
||||||
});
|
|
||||||
|
|
||||||
if (response.status != 202 && response.status != 406) {
|
|
||||||
throw new Error('Response not valid');
|
|
||||||
}
|
|
||||||
|
|
||||||
const result = await response.json();
|
|
||||||
let resItem = upgradeForm.querySelector('.fwResult');
|
|
||||||
if (resItem && result.firmware.status > 1) {
|
|
||||||
resItem.textContent = statusToText(result.firmware.status);
|
|
||||||
resItem.classList.remove('hidden');
|
|
||||||
|
|
||||||
if (result.firmware.status == 2) {
|
|
||||||
resItem.classList.remove('failed');
|
|
||||||
resItem.classList.add('success');
|
|
||||||
} else {
|
|
||||||
resItem.classList.remove('success');
|
|
||||||
resItem.classList.add('failed');
|
|
||||||
|
|
||||||
if (result.firmware.error != "") {
|
|
||||||
resItem.textContent += `: ${result.firmware.error}`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
resItem = upgradeForm.querySelector('.fsResult');
|
|
||||||
if (resItem && result.filesystem.status > 1) {
|
|
||||||
resItem.textContent = statusToText(result.filesystem.status);
|
|
||||||
resItem.classList.remove('hidden');
|
|
||||||
|
|
||||||
if (result.filesystem.status == 2) {
|
|
||||||
resItem.classList.remove('failed');
|
|
||||||
resItem.classList.add('success');
|
|
||||||
} else {
|
|
||||||
resItem.classList.remove('success');
|
|
||||||
resItem.classList.add('failed');
|
|
||||||
|
|
||||||
if (result.filesystem.error != "") {
|
|
||||||
resItem.textContent += `: ${result.filesystem.error}`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
console.log(err);
|
|
||||||
button.textContent = i18n('button.error');
|
|
||||||
button.classList.add('failed');
|
|
||||||
|
|
||||||
} finally {
|
|
||||||
setTimeout(() => {
|
|
||||||
button.removeAttribute('aria-busy');
|
|
||||||
button.removeAttribute('disabled');
|
|
||||||
button.classList.remove('success', 'failed');
|
|
||||||
button.textContent = i18n(button.dataset.i18n);
|
|
||||||
upgradeForm.reset();
|
|
||||||
}, 10000);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -318,7 +318,6 @@ const setupRestoreBackupForm = (formSelector) => {
|
|||||||
console.log("Backup: ", data);
|
console.log("Backup: ", data);
|
||||||
|
|
||||||
if (data.settings != undefined) {
|
if (data.settings != undefined) {
|
||||||
for (var key in data.settings) {
|
|
||||||
let response = await fetch(url, {
|
let response = await fetch(url, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
cache: "no-cache",
|
cache: "no-cache",
|
||||||
@@ -326,11 +325,7 @@ const setupRestoreBackupForm = (formSelector) => {
|
|||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json"
|
"Content-Type": "application/json"
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({"settings": data.settings})
|
||||||
"settings": {
|
|
||||||
[key]: data.settings[key]
|
|
||||||
}
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
@@ -338,7 +333,6 @@ const setupRestoreBackupForm = (formSelector) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (data.sensors != undefined) {
|
if (data.sensors != undefined) {
|
||||||
for (const sensorId in data.sensors) {
|
for (const sensorId in data.sensors) {
|
||||||
|
|||||||
Reference in New Issue
Block a user