mirror of
https://github.com/Laxilef/OTGateway.git
synced 2025-12-12 19:24:27 +05:00
Compare commits
5 Commits
passive_bl
...
hyst
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
95d508553d | ||
|
|
d474be26dc | ||
|
|
d54a9cf2d7 | ||
|
|
00baf10b9f | ||
|
|
98e5fe42e8 |
22
.github/workflows/pio-dependabot.yaml
vendored
22
.github/workflows/pio-dependabot.yaml
vendored
@@ -1,22 +0,0 @@
|
|||||||
name: PlatformIO Dependabot
|
|
||||||
on:
|
|
||||||
workflow_dispatch: # option to manually trigger the workflow
|
|
||||||
schedule:
|
|
||||||
# Runs every day at 00:00
|
|
||||||
- cron: "0 0 * * *"
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
pull-requests: write
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
dependabot:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
name: run PlatformIO Dependabot
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v5
|
|
||||||
- name: run PlatformIO Dependabot
|
|
||||||
uses: peterus/platformio_dependabot@v1.2.0
|
|
||||||
with:
|
|
||||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
@@ -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 {
|
UpgradeHandler* setCanHandleCallback(CanHandleCallback callback = nullptr) {
|
||||||
if (!request->isHTTP()) {
|
this->canHandleCallback = callback;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return this->uri.matches(request);
|
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;
|
} else if (upload.status == UPLOAD_FILE_END) {
|
||||||
Log.sinfoln(
|
if (Update.end(true)) {
|
||||||
FPSTR(L_PORTAL_OTA), "File '%s', write %d bytes, %d of %d bytes",
|
result->status = UpgradeStatus::SUCCESS;
|
||||||
fileName.c_str(),
|
|
||||||
dataLength,
|
|
||||||
result->progress,
|
|
||||||
result->size
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result->size > 0) {
|
Log.sinfoln(FPSTR(L_PORTAL_OTA), F("File '%s': finish"), upload.filename.c_str());
|
||||||
if (result->progress > result->size || (isFinal && result->progress < result->size)) {
|
|
||||||
Update.end(false);
|
|
||||||
result->status = UpgradeStatus::SIZE_MISMATCH;
|
|
||||||
|
|
||||||
Log.serrorln(
|
} else {
|
||||||
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->status = UpgradeStatus::ERROR_ON_FINISH;
|
||||||
|
#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 finish: %s", fileName.c_str(), result->error);
|
Log.serrorln(FPSTR(L_PORTAL_OTA), F("File '%s', on finish: %s"), upload.filename.c_str(), result->error);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result->status = UpgradeStatus::SUCCESS;
|
} else if (upload.status == UPLOAD_FILE_ABORTED) {
|
||||||
Log.sinfoln(FPSTR(L_PORTAL_OTA), "File '%s': finish", fileName.c_str());
|
Update.end(false);
|
||||||
}
|
result->status = UpgradeStatus::ABORTED;
|
||||||
}
|
|
||||||
|
|
||||||
bool isRequestHandlerTrivial() const override final {
|
Log.serrorln(FPSTR(L_PORTAL_OTA), F("File '%s': aborted"), upload.filename.c_str());
|
||||||
return false;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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};
|
||||||
|
|||||||
586
platformio.ini
586
platformio.ini
@@ -1,275 +1,379 @@
|
|||||||
|
; 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.5.7-passiveble
|
version = 1.5.6
|
||||||
framework = arduino
|
framework = arduino
|
||||||
lib_deps = ESP32Async/AsyncTCP
|
lib_deps =
|
||||||
;ESP32Async/ESPAsyncWebServer
|
bblanchon/ArduinoJson@^7.4.2
|
||||||
https://github.com/ESP32Async/ESPAsyncWebServer
|
;ihormelnyk/OpenTherm Library@^1.1.5
|
||||||
bblanchon/ArduinoJson@^7.4.2
|
https://github.com/Laxilef/opentherm_library#esp32_timer
|
||||||
;ihormelnyk/OpenTherm Library@^1.1.5
|
arduino-libraries/ArduinoMqttClient@^0.1.8
|
||||||
https://github.com/Laxilef/opentherm_library#esp32_timer
|
lennarthennigs/ESP Telnet@^2.2.3
|
||||||
arduino-libraries/ArduinoMqttClient@^0.1.8
|
gyverlibs/FileData@^1.0.3
|
||||||
lennarthennigs/ESP Telnet@^2.2.3
|
gyverlibs/GyverPID@^3.3.2
|
||||||
gyverlibs/FileData@^1.0.3
|
gyverlibs/GyverBlinker@^1.1.1
|
||||||
gyverlibs/GyverPID@^3.3.2
|
https://github.com/pstolarz/Arduino-Temperature-Control-Library.git#OneWireNg
|
||||||
gyverlibs/GyverBlinker@^1.1.1
|
laxilef/TinyLogger@^1.1.1
|
||||||
https://github.com/pstolarz/Arduino-Temperature-Control-Library.git#OneWireNg
|
build_type = ${secrets.build_type}
|
||||||
laxilef/TinyLogger@^1.1.1
|
build_flags =
|
||||||
build_type = ${secrets.build_type}
|
-mtext-section-literals
|
||||||
build_flags = -mtext-section-literals
|
-D MQTT_CLIENT_STD_FUNCTION_CALLBACK=1
|
||||||
-Wno-deprecated-declarations
|
;-D DEBUG_ESP_CORE -D DEBUG_ESP_WIFI -D DEBUG_ESP_HTTP_SERVER -D DEBUG_ESP_PORT=Serial
|
||||||
-D MQTT_CLIENT_STD_FUNCTION_CALLBACK=1
|
-D BUILD_VERSION='"${this.version}"'
|
||||||
;-D DEBUG_ESP_CORE -D DEBUG_ESP_WIFI -D DEBUG_ESP_HTTP_SERVER -D DEBUG_ESP_PORT=Serial
|
-D BUILD_ENV='"$PIOENV"'
|
||||||
-D BUILD_VERSION='"${this.version}"'
|
-D DEFAULT_SERIAL_ENABLED=${secrets.serial_enabled}
|
||||||
-D BUILD_ENV='"$PIOENV"'
|
-D DEFAULT_SERIAL_BAUD=${secrets.serial_baud}
|
||||||
-D CONFIG_ASYNC_TCP_STACK_SIZE=4096
|
-D DEFAULT_TELNET_ENABLED=${secrets.telnet_enabled}
|
||||||
-D ARDUINOJSON_USE_DOUBLE=0
|
-D DEFAULT_TELNET_PORT=${secrets.telnet_port}
|
||||||
-D ARDUINOJSON_USE_LONG_LONG=0
|
-D DEFAULT_LOG_LEVEL=${secrets.log_level}
|
||||||
-D DEFAULT_SERIAL_ENABLED=${secrets.serial_enabled}
|
-D DEFAULT_HOSTNAME='"${secrets.hostname}"'
|
||||||
-D DEFAULT_SERIAL_BAUD=${secrets.serial_baud}
|
-D DEFAULT_AP_SSID='"${secrets.ap_ssid}"'
|
||||||
-D DEFAULT_TELNET_ENABLED=${secrets.telnet_enabled}
|
-D DEFAULT_AP_PASSWORD='"${secrets.ap_password}"'
|
||||||
-D DEFAULT_TELNET_PORT=${secrets.telnet_port}
|
-D DEFAULT_STA_SSID='"${secrets.sta_ssid}"'
|
||||||
-D DEFAULT_LOG_LEVEL=${secrets.log_level}
|
-D DEFAULT_STA_PASSWORD='"${secrets.sta_password}"'
|
||||||
-D DEFAULT_HOSTNAME='"${secrets.hostname}"'
|
-D DEFAULT_PORTAL_LOGIN='"${secrets.portal_login}"'
|
||||||
-D DEFAULT_AP_SSID='"${secrets.ap_ssid}"'
|
-D DEFAULT_PORTAL_PASSWORD='"${secrets.portal_password}"'
|
||||||
-D DEFAULT_AP_PASSWORD='"${secrets.ap_password}"'
|
-D DEFAULT_MQTT_ENABLED=${secrets.mqtt_enabled}
|
||||||
-D DEFAULT_STA_SSID='"${secrets.sta_ssid}"'
|
-D DEFAULT_MQTT_SERVER='"${secrets.mqtt_server}"'
|
||||||
-D DEFAULT_STA_PASSWORD='"${secrets.sta_password}"'
|
-D DEFAULT_MQTT_PORT=${secrets.mqtt_port}
|
||||||
-D DEFAULT_PORTAL_LOGIN='"${secrets.portal_login}"'
|
-D DEFAULT_MQTT_USER='"${secrets.mqtt_user}"'
|
||||||
-D DEFAULT_PORTAL_PASSWORD='"${secrets.portal_password}"'
|
-D DEFAULT_MQTT_PASSWORD='"${secrets.mqtt_password}"'
|
||||||
-D DEFAULT_MQTT_ENABLED=${secrets.mqtt_enabled}
|
-D DEFAULT_MQTT_PREFIX='"${secrets.mqtt_prefix}"'
|
||||||
-D DEFAULT_MQTT_SERVER='"${secrets.mqtt_server}"'
|
upload_speed = 921600
|
||||||
-D DEFAULT_MQTT_PORT=${secrets.mqtt_port}
|
monitor_speed = 115200
|
||||||
-D DEFAULT_MQTT_USER='"${secrets.mqtt_user}"'
|
;monitor_filters = direct
|
||||||
-D DEFAULT_MQTT_PASSWORD='"${secrets.mqtt_password}"'
|
monitor_filters =
|
||||||
-D DEFAULT_MQTT_PREFIX='"${secrets.mqtt_prefix}"'
|
esp32_exception_decoder
|
||||||
upload_speed = 921600
|
esp8266_exception_decoder
|
||||||
monitor_speed = 115200
|
board_build.flash_mode = dio
|
||||||
;monitor_filters = direct
|
board_build.filesystem = littlefs
|
||||||
monitor_filters = esp32_exception_decoder
|
check_tool = ; pvs-studio
|
||||||
esp8266_exception_decoder
|
check_flags =
|
||||||
board_build.flash_mode = dio
|
; pvs-studio:
|
||||||
board_build.filesystem = littlefs
|
; --analysis-mode=4
|
||||||
check_tool = ;pvs-studio
|
; --exclude-path=./.pio/libdeps
|
||||||
check_flags = ;pvs-studio: --analysis-mode=4 --exclude-path=./.pio/libdeps
|
|
||||||
|
|
||||||
; Defaults
|
; Defaults
|
||||||
[esp8266_defaults]
|
[esp8266_defaults]
|
||||||
platform = espressif8266@^4.2.1
|
platform = espressif8266@^4.2.1
|
||||||
platform_packages = ${env.platform_packages}
|
platform_packages = ${env.platform_packages}
|
||||||
lib_deps = ${env.lib_deps}
|
lib_deps =
|
||||||
nrwiersma/ESP8266Scheduler@^1.2
|
${env.lib_deps}
|
||||||
lib_ignore =
|
nrwiersma/ESP8266Scheduler@^1.2
|
||||||
extra_scripts = post:tools/build.py
|
lib_ignore =
|
||||||
build_type = ${env.build_type}
|
extra_scripts =
|
||||||
build_flags = ${env.build_flags}
|
post:tools/build.py
|
||||||
-D PIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY
|
build_type = ${env.build_type}
|
||||||
;-D PIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH_LOW_FLASH
|
build_flags =
|
||||||
-D PIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK305
|
${env.build_flags}
|
||||||
board_build.ldscript = eagle.flash.4m1m.ld
|
-D PIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY
|
||||||
check_tool = ${env.check_tool}
|
;-D PIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH_LOW_FLASH
|
||||||
check_flags = ${env.check_flags}
|
-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 = https://github.com/pioarduino/platform-espressif32/releases/download/55.03.34/platform-espressif32.zip
|
;platform = espressif32@^6.7
|
||||||
platform_packages = ${env.platform_packages}
|
;platform = https://github.com/platformio/platform-espressif32.git
|
||||||
board_build.partitions = esp32_partitions.csv
|
;platform_packages =
|
||||||
lib_deps = ${env.lib_deps}
|
; framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#3.0.5
|
||||||
laxilef/ESP32Scheduler@^1.0.1
|
; 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
|
||||||
nimble_lib = https://github.com/h2zero/NimBLE-Arduino
|
platform = https://github.com/pioarduino/platform-espressif32/releases/download/55.03.34/platform-espressif32.zip
|
||||||
lib_ignore = BluetoothSerial
|
platform_packages = ${env.platform_packages}
|
||||||
SimpleBLE
|
board_build.partitions = esp32_partitions.csv
|
||||||
ESP RainMaker
|
lib_deps =
|
||||||
RainMaker
|
${env.lib_deps}
|
||||||
ESP Insights
|
laxilef/ESP32Scheduler@^1.0.1
|
||||||
Insights
|
nimble_lib = h2zero/NimBLE-Arduino@2.3.3
|
||||||
Zigbee
|
lib_ignore =
|
||||||
Matter
|
extra_scripts =
|
||||||
OpenThread
|
post:tools/esp32.py
|
||||||
dsp
|
post:tools/build.py
|
||||||
custom_component_remove = espressif/esp_hosted
|
build_type = ${env.build_type}
|
||||||
espressif/esp_wifi_remote
|
build_flags =
|
||||||
espressif/esp-dsp
|
${env.build_flags}
|
||||||
espressif/esp_modem
|
-D CORE_DEBUG_LEVEL=0
|
||||||
espressif/esp_rainmaker
|
-Wl,--wrap=esp_panic_handler
|
||||||
espressif/rmaker_common
|
check_tool = ${env.check_tool}
|
||||||
espressif/esp_insights
|
check_flags = ${env.check_flags}
|
||||||
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
|
|
||||||
build_type = ${env.build_type}
|
|
||||||
build_flags = ${env.build_flags}
|
|
||||||
-D CORE_DEBUG_LEVEL=0
|
|
||||||
-Wl,--wrap=esp_panic_handler
|
|
||||||
check_tool = ${env.check_tool}
|
|
||||||
check_flags = ${env.check_flags}
|
|
||||||
|
|
||||||
|
|
||||||
; Boards
|
; Boards
|
||||||
[env:d1_mini]
|
[env:d1_mini]
|
||||||
extends = esp8266_defaults
|
platform = ${esp8266_defaults.platform}
|
||||||
board = d1_mini
|
platform_packages = ${esp8266_defaults.platform_packages}
|
||||||
build_flags = ${esp8266_defaults.build_flags}
|
board = d1_mini
|
||||||
-D DEFAULT_OT_IN_GPIO=4
|
lib_deps = ${esp8266_defaults.lib_deps}
|
||||||
-D DEFAULT_OT_OUT_GPIO=5
|
lib_ignore = ${esp8266_defaults.lib_ignore}
|
||||||
-D DEFAULT_SENSOR_OUTDOOR_GPIO=12
|
extra_scripts = ${esp8266_defaults.extra_scripts}
|
||||||
-D DEFAULT_SENSOR_INDOOR_GPIO=14
|
board_build.ldscript = ${esp8266_defaults.board_build.ldscript}
|
||||||
-D DEFAULT_STATUS_LED_GPIO=13
|
build_type = ${esp8266_defaults.build_type}
|
||||||
-D DEFAULT_OT_RX_LED_GPIO=15
|
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]
|
[env:d1_mini_lite]
|
||||||
extends = esp8266_defaults
|
platform = ${esp8266_defaults.platform}
|
||||||
board = d1_mini_lite
|
platform_packages = ${esp8266_defaults.platform_packages}
|
||||||
build_flags = ${esp8266_defaults.build_flags}
|
board = d1_mini_lite
|
||||||
-D DEFAULT_OT_IN_GPIO=4
|
lib_deps = ${esp8266_defaults.lib_deps}
|
||||||
-D DEFAULT_OT_OUT_GPIO=5
|
lib_ignore = ${esp8266_defaults.lib_ignore}
|
||||||
-D DEFAULT_SENSOR_OUTDOOR_GPIO=12
|
extra_scripts = ${esp8266_defaults.extra_scripts}
|
||||||
-D DEFAULT_SENSOR_INDOOR_GPIO=14
|
board_build.ldscript = ${esp8266_defaults.board_build.ldscript}
|
||||||
-D DEFAULT_STATUS_LED_GPIO=13
|
build_type = ${esp8266_defaults.build_type}
|
||||||
-D DEFAULT_OT_RX_LED_GPIO=15
|
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]
|
[env:d1_mini_pro]
|
||||||
extends = esp8266_defaults
|
platform = ${esp8266_defaults.platform}
|
||||||
board = d1_mini_pro
|
platform_packages = ${esp8266_defaults.platform_packages}
|
||||||
build_flags = ${esp8266_defaults.build_flags}
|
board = d1_mini_pro
|
||||||
-D DEFAULT_OT_IN_GPIO=4
|
lib_deps = ${esp8266_defaults.lib_deps}
|
||||||
-D DEFAULT_OT_OUT_GPIO=5
|
lib_ignore = ${esp8266_defaults.lib_ignore}
|
||||||
-D DEFAULT_SENSOR_OUTDOOR_GPIO=12
|
extra_scripts = ${esp8266_defaults.extra_scripts}
|
||||||
-D DEFAULT_SENSOR_INDOOR_GPIO=14
|
board_build.ldscript = ${esp8266_defaults.board_build.ldscript}
|
||||||
-D DEFAULT_STATUS_LED_GPIO=13
|
build_type = ${esp8266_defaults.build_type}
|
||||||
-D DEFAULT_OT_RX_LED_GPIO=15
|
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]
|
[env:nodemcu_8266]
|
||||||
extends = esp8266_defaults
|
platform = ${esp8266_defaults.platform}
|
||||||
board = nodemcuv2
|
platform_packages = ${esp8266_defaults.platform_packages}
|
||||||
build_flags = ${esp8266_defaults.build_flags}
|
board = nodemcuv2
|
||||||
-D DEFAULT_OT_IN_GPIO=13
|
lib_deps = ${esp8266_defaults.lib_deps}
|
||||||
-D DEFAULT_OT_OUT_GPIO=15
|
lib_ignore = ${esp8266_defaults.lib_ignore}
|
||||||
-D DEFAULT_SENSOR_OUTDOOR_GPIO=12
|
extra_scripts = ${esp8266_defaults.extra_scripts}
|
||||||
-D DEFAULT_SENSOR_INDOOR_GPIO=4
|
board_build.ldscript = ${esp8266_defaults.board_build.ldscript}
|
||||||
-D DEFAULT_STATUS_LED_GPIO=2
|
build_type = ${esp8266_defaults.build_type}
|
||||||
-D DEFAULT_OT_RX_LED_GPIO=16
|
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}
|
||||||
board = lolin_s2_mini
|
platform_packages = ${esp32_defaults.platform_packages}
|
||||||
build_unflags = -DARDUINO_USB_MODE=1
|
board = lolin_s2_mini
|
||||||
build_flags = ${esp32_defaults.build_flags}
|
board_build.partitions = ${esp32_defaults.board_build.partitions}
|
||||||
-D ARDUINO_USB_MODE=0
|
lib_deps = ${esp32_defaults.lib_deps}
|
||||||
-D ARDUINO_USB_CDC_ON_BOOT=1
|
lib_ignore = ${esp32_defaults.lib_ignore}
|
||||||
-D DEFAULT_OT_IN_GPIO=33
|
extra_scripts = ${esp32_defaults.extra_scripts}
|
||||||
-D DEFAULT_OT_OUT_GPIO=35
|
build_unflags =
|
||||||
-D DEFAULT_SENSOR_OUTDOOR_GPIO=9
|
-DARDUINO_USB_MODE=1
|
||||||
-D DEFAULT_SENSOR_INDOOR_GPIO=7
|
build_type = ${esp32_defaults.build_type}
|
||||||
-D DEFAULT_STATUS_LED_GPIO=11
|
build_flags =
|
||||||
-D DEFAULT_OT_RX_LED_GPIO=12
|
${esp32_defaults.build_flags}
|
||||||
|
-D ARDUINO_USB_MODE=0
|
||||||
|
-D ARDUINO_USB_CDC_ON_BOOT=1
|
||||||
|
-D DEFAULT_OT_IN_GPIO=33
|
||||||
|
-D DEFAULT_OT_OUT_GPIO=35
|
||||||
|
-D DEFAULT_SENSOR_OUTDOOR_GPIO=9
|
||||||
|
-D DEFAULT_SENSOR_INDOOR_GPIO=7
|
||||||
|
-D DEFAULT_STATUS_LED_GPIO=11
|
||||||
|
-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}
|
||||||
board = lolin_s3_mini
|
platform_packages = ${esp32_defaults.platform_packages}
|
||||||
lib_deps = ${esp32_defaults.lib_deps}
|
board = lolin_s3_mini
|
||||||
${esp32_defaults.nimble_lib}
|
board_build.partitions = ${esp32_defaults.board_build.partitions}
|
||||||
build_unflags = -DARDUINO_USB_MODE=1
|
lib_deps =
|
||||||
build_flags = ${esp32_defaults.build_flags}
|
${esp32_defaults.lib_deps}
|
||||||
-D ARDUINO_USB_MODE=0
|
${esp32_defaults.nimble_lib}
|
||||||
-D ARDUINO_USB_CDC_ON_BOOT=1
|
lib_ignore = ${esp32_defaults.lib_ignore}
|
||||||
-D USE_BLE=1
|
extra_scripts = ${esp32_defaults.extra_scripts}
|
||||||
-D MYNEWT_VAL_BLE_EXT_ADV=1
|
build_unflags =
|
||||||
-D DEFAULT_OT_IN_GPIO=35
|
-DARDUINO_USB_MODE=1
|
||||||
-D DEFAULT_OT_OUT_GPIO=36
|
build_type = ${esp32_defaults.build_type}
|
||||||
-D DEFAULT_SENSOR_OUTDOOR_GPIO=13
|
build_flags =
|
||||||
-D DEFAULT_SENSOR_INDOOR_GPIO=12
|
${esp32_defaults.build_flags}
|
||||||
-D DEFAULT_STATUS_LED_GPIO=11
|
-D ARDUINO_USB_MODE=0
|
||||||
-D DEFAULT_OT_RX_LED_GPIO=10
|
-D ARDUINO_USB_CDC_ON_BOOT=1
|
||||||
|
-D CONFIG_BT_NIMBLE_EXT_ADV=1
|
||||||
|
-D USE_BLE=1
|
||||||
|
-D DEFAULT_OT_IN_GPIO=35
|
||||||
|
-D DEFAULT_OT_OUT_GPIO=36
|
||||||
|
-D DEFAULT_SENSOR_OUTDOOR_GPIO=13
|
||||||
|
-D DEFAULT_SENSOR_INDOOR_GPIO=12
|
||||||
|
-D DEFAULT_STATUS_LED_GPIO=11
|
||||||
|
-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}
|
||||||
board = lolin_c3_mini
|
platform_packages = ${esp32_defaults.platform_packages}
|
||||||
lib_deps = ${esp32_defaults.lib_deps}
|
board = lolin_c3_mini
|
||||||
${esp32_defaults.nimble_lib}
|
board_build.partitions = ${esp32_defaults.board_build.partitions}
|
||||||
build_unflags = -mtext-section-literals
|
lib_deps =
|
||||||
build_flags = ${esp32_defaults.build_flags}
|
${esp32_defaults.lib_deps}
|
||||||
-D USE_BLE=1
|
${esp32_defaults.nimble_lib}
|
||||||
-D DEFAULT_OT_IN_GPIO=8
|
lib_ignore = ${esp32_defaults.lib_ignore}
|
||||||
-D DEFAULT_OT_OUT_GPIO=10
|
extra_scripts = ${esp32_defaults.extra_scripts}
|
||||||
-D DEFAULT_SENSOR_OUTDOOR_GPIO=0
|
build_unflags =
|
||||||
-D DEFAULT_SENSOR_INDOOR_GPIO=1
|
-mtext-section-literals
|
||||||
-D DEFAULT_STATUS_LED_GPIO=4
|
build_type = ${esp32_defaults.build_type}
|
||||||
-D DEFAULT_OT_RX_LED_GPIO=5
|
build_flags =
|
||||||
|
${esp32_defaults.build_flags}
|
||||||
|
-D CONFIG_BT_NIMBLE_EXT_ADV=1
|
||||||
|
-D USE_BLE=1
|
||||||
|
-D DEFAULT_OT_IN_GPIO=8
|
||||||
|
-D DEFAULT_OT_OUT_GPIO=10
|
||||||
|
-D DEFAULT_SENSOR_OUTDOOR_GPIO=0
|
||||||
|
-D DEFAULT_SENSOR_INDOOR_GPIO=1
|
||||||
|
-D DEFAULT_STATUS_LED_GPIO=4
|
||||||
|
-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}
|
||||||
board = nodemcu-32s
|
platform_packages = ${esp32_defaults.platform_packages}
|
||||||
lib_deps = ${esp32_defaults.lib_deps}
|
board = nodemcu-32s
|
||||||
${esp32_defaults.nimble_lib}
|
board_build.partitions = ${esp32_defaults.board_build.partitions}
|
||||||
build_flags = ${esp32_defaults.build_flags}
|
lib_deps =
|
||||||
-D USE_BLE=1
|
${esp32_defaults.lib_deps}
|
||||||
-D DEFAULT_OT_IN_GPIO=16
|
${esp32_defaults.nimble_lib}
|
||||||
-D DEFAULT_OT_OUT_GPIO=4
|
lib_ignore = ${esp32_defaults.lib_ignore}
|
||||||
-D DEFAULT_SENSOR_OUTDOOR_GPIO=15
|
extra_scripts = ${esp32_defaults.extra_scripts}
|
||||||
-D DEFAULT_SENSOR_INDOOR_GPIO=26
|
build_type = ${esp32_defaults.build_type}
|
||||||
-D DEFAULT_STATUS_LED_GPIO=2
|
build_flags =
|
||||||
-D DEFAULT_OT_RX_LED_GPIO=19
|
${esp32_defaults.build_flags}
|
||||||
|
-D USE_BLE=1
|
||||||
|
-D DEFAULT_OT_IN_GPIO=16
|
||||||
|
-D DEFAULT_OT_OUT_GPIO=4
|
||||||
|
-D DEFAULT_SENSOR_OUTDOOR_GPIO=15
|
||||||
|
-D DEFAULT_SENSOR_INDOOR_GPIO=26
|
||||||
|
-D DEFAULT_STATUS_LED_GPIO=2
|
||||||
|
-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}
|
||||||
board = wemos_d1_mini32
|
platform_packages = ${esp32_defaults.platform_packages}
|
||||||
lib_deps = ${esp32_defaults.lib_deps}
|
board = wemos_d1_mini32
|
||||||
${esp32_defaults.nimble_lib}
|
board_build.partitions = ${esp32_defaults.board_build.partitions}
|
||||||
build_flags = ${esp32_defaults.build_flags}
|
lib_deps =
|
||||||
-D USE_BLE=1
|
${esp32_defaults.lib_deps}
|
||||||
-D DEFAULT_OT_IN_GPIO=21
|
${esp32_defaults.nimble_lib}
|
||||||
-D DEFAULT_OT_OUT_GPIO=22
|
lib_ignore = ${esp32_defaults.lib_ignore}
|
||||||
-D DEFAULT_SENSOR_OUTDOOR_GPIO=12
|
extra_scripts = ${esp32_defaults.extra_scripts}
|
||||||
-D DEFAULT_SENSOR_INDOOR_GPIO=18
|
build_type = ${esp32_defaults.build_type}
|
||||||
-D DEFAULT_STATUS_LED_GPIO=2
|
build_flags =
|
||||||
-D DEFAULT_OT_RX_LED_GPIO=19
|
${esp32_defaults.build_flags}
|
||||||
|
-D USE_BLE=1
|
||||||
|
-D DEFAULT_OT_IN_GPIO=21
|
||||||
|
-D DEFAULT_OT_OUT_GPIO=22
|
||||||
|
-D DEFAULT_SENSOR_OUTDOOR_GPIO=12
|
||||||
|
-D DEFAULT_SENSOR_INDOOR_GPIO=18
|
||||||
|
-D DEFAULT_STATUS_LED_GPIO=2
|
||||||
|
-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
|
||||||
lib_deps = ${esp32_defaults.lib_deps}
|
platform_packages = ${esp32_defaults.platform_packages}
|
||||||
${esp32_defaults.nimble_lib}
|
board = esp32-c6-devkitm-1
|
||||||
build_unflags = -mtext-section-literals
|
board_build.partitions = ${esp32_defaults.board_build.partitions}
|
||||||
build_flags = ${esp32_defaults.build_flags}
|
board_build.embed_txtfiles =
|
||||||
-D USE_BLE=1
|
managed_components/espressif__esp_insights/server_certs/https_server.crt
|
||||||
-D DEFAULT_OT_IN_GPIO=15
|
managed_components/espressif__esp_rainmaker/server_certs/rmaker_mqtt_server.crt
|
||||||
-D DEFAULT_OT_OUT_GPIO=23
|
managed_components/espressif__esp_rainmaker/server_certs/rmaker_claim_service_server.crt
|
||||||
-D DEFAULT_SENSOR_OUTDOOR_GPIO=0
|
managed_components/espressif__esp_rainmaker/server_certs/rmaker_ota_server.crt
|
||||||
-D DEFAULT_SENSOR_INDOOR_GPIO=0
|
lib_deps = ${esp32_defaults.lib_deps}
|
||||||
-D DEFAULT_STATUS_LED_GPIO=11
|
lib_ignore =
|
||||||
-D DEFAULT_OT_RX_LED_GPIO=10
|
${esp32_defaults.lib_ignore}
|
||||||
|
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 DEFAULT_OT_IN_GPIO=15
|
||||||
|
-D DEFAULT_OT_OUT_GPIO=23
|
||||||
|
-D DEFAULT_SENSOR_OUTDOOR_GPIO=0
|
||||||
|
-D DEFAULT_SENSOR_INDOOR_GPIO=0
|
||||||
|
-D DEFAULT_STATUS_LED_GPIO=11
|
||||||
|
-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}
|
||||||
board = lolin_c3_mini
|
platform_packages = ${esp32_defaults.platform_packages}
|
||||||
lib_deps = ${esp32_defaults.lib_deps}
|
board = lolin_c3_mini
|
||||||
${esp32_defaults.nimble_lib}
|
board_build.partitions = ${esp32_defaults.board_build.partitions}
|
||||||
build_unflags = -mtext-section-literals
|
lib_deps =
|
||||||
build_flags = ${esp32_defaults.build_flags}
|
${esp32_defaults.lib_deps}
|
||||||
-D USE_BLE=1
|
${esp32_defaults.nimble_lib}
|
||||||
-D DEFAULT_OT_IN_GPIO=3
|
lib_ignore = ${esp32_defaults.lib_ignore}
|
||||||
-D DEFAULT_OT_OUT_GPIO=1
|
extra_scripts = ${esp32_defaults.extra_scripts}
|
||||||
;-D DEFAULT_SENSOR_OUTDOOR_GPIO=0
|
build_unflags =
|
||||||
;-D DEFAULT_SENSOR_INDOOR_GPIO=1
|
-mtext-section-literals
|
||||||
-D DEFAULT_STATUS_LED_GPIO=8
|
build_type = ${esp32_defaults.build_type}
|
||||||
-D DEFAULT_OT_RX_LED_GPIO=2
|
build_flags =
|
||||||
-D OT_BYPASS_RELAY_GPIO=20
|
${esp32_defaults.build_flags}
|
||||||
|
-D CONFIG_BT_NIMBLE_EXT_ADV=1
|
||||||
|
-D USE_BLE=1
|
||||||
|
-D DEFAULT_OT_IN_GPIO=3
|
||||||
|
-D DEFAULT_OT_OUT_GPIO=1
|
||||||
|
; -D DEFAULT_SENSOR_OUTDOOR_GPIO=0
|
||||||
|
; -D DEFAULT_SENSOR_INDOOR_GPIO=1
|
||||||
|
-D DEFAULT_STATUS_LED_GPIO=8
|
||||||
|
-D DEFAULT_OT_RX_LED_GPIO=2
|
||||||
|
-D OT_BYPASS_RELAY_GPIO=20
|
||||||
|
check_tool = ${esp32_defaults.check_tool}
|
||||||
|
check_flags = ${esp32_defaults.check_flags}
|
||||||
|
|||||||
@@ -443,6 +443,28 @@ public:
|
|||||||
return this->publish(this->makeConfigTopic(FPSTR(HA_ENTITY_SWITCH), F("heating_turbo")).c_str(), doc);
|
return this->publish(this->makeConfigTopic(FPSTR(HA_ENTITY_SWITCH), F("heating_turbo")).c_str(), doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool publishSwitchHeatingHysteresis(bool enabledByDefault = true) {
|
||||||
|
JsonDocument doc;
|
||||||
|
doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str();
|
||||||
|
doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault;
|
||||||
|
doc[FPSTR(HA_UNIQUE_ID)] = this->getUniqueIdWithPrefix(F("heating_hysteresis"));
|
||||||
|
doc[FPSTR(HA_DEFAULT_ENTITY_ID)] = this->getEntityIdWithPrefix(FPSTR(HA_ENTITY_SWITCH), F("heating_hysteresis"));
|
||||||
|
doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_CONFIG);
|
||||||
|
doc[FPSTR(HA_NAME)] = F("Use heating hysteresis");
|
||||||
|
doc[FPSTR(HA_ICON)] = F("mdi:altimeter");
|
||||||
|
doc[FPSTR(HA_STATE_TOPIC)] = this->settingsTopic.c_str();
|
||||||
|
doc[FPSTR(HA_STATE_ON)] = true;
|
||||||
|
doc[FPSTR(HA_STATE_OFF)] = false;
|
||||||
|
doc[FPSTR(HA_VALUE_TEMPLATE)] = F("{{ value_json.heating.hysteresis.enabled }}");
|
||||||
|
doc[FPSTR(HA_COMMAND_TOPIC)] = this->setSettingsTopic.c_str();
|
||||||
|
doc[FPSTR(HA_PAYLOAD_ON)] = F("{\"heating\": {\"hysteresis\" : {\"enabled\" : true}}}");
|
||||||
|
doc[FPSTR(HA_PAYLOAD_OFF)] = F("{\"heating\": {\"hysteresis\" : {\"enabled\" : false}}}");
|
||||||
|
doc[FPSTR(HA_EXPIRE_AFTER)] = this->expireAfter;
|
||||||
|
doc.shrinkToFit();
|
||||||
|
|
||||||
|
return this->publish(this->makeConfigTopic(FPSTR(HA_ENTITY_SWITCH), F("heating_hysteresis")).c_str(), doc);
|
||||||
|
}
|
||||||
|
|
||||||
bool publishInputHeatingHysteresis(UnitSystem unit = UnitSystem::METRIC, bool enabledByDefault = true) {
|
bool publishInputHeatingHysteresis(UnitSystem unit = UnitSystem::METRIC, bool enabledByDefault = true) {
|
||||||
JsonDocument doc;
|
JsonDocument doc;
|
||||||
doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str();
|
doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = this->statusTopic.c_str();
|
||||||
@@ -462,9 +484,9 @@ public:
|
|||||||
doc[FPSTR(HA_NAME)] = F("Heating hysteresis");
|
doc[FPSTR(HA_NAME)] = F("Heating hysteresis");
|
||||||
doc[FPSTR(HA_ICON)] = F("mdi:altimeter");
|
doc[FPSTR(HA_ICON)] = F("mdi:altimeter");
|
||||||
doc[FPSTR(HA_STATE_TOPIC)] = this->settingsTopic.c_str();
|
doc[FPSTR(HA_STATE_TOPIC)] = this->settingsTopic.c_str();
|
||||||
doc[FPSTR(HA_VALUE_TEMPLATE)] = F("{{ value_json.heating.hysteresis|float(0)|round(2) }}");
|
doc[FPSTR(HA_VALUE_TEMPLATE)] = F("{{ value_json.heating.hysteresis.value|float(0)|round(2) }}");
|
||||||
doc[FPSTR(HA_COMMAND_TOPIC)] = this->setSettingsTopic.c_str();
|
doc[FPSTR(HA_COMMAND_TOPIC)] = this->setSettingsTopic.c_str();
|
||||||
doc[FPSTR(HA_COMMAND_TEMPLATE)] = F("{\"heating\": {\"hysteresis\" : {{ value }}}}");
|
doc[FPSTR(HA_COMMAND_TEMPLATE)] = F("{\"heating\": {\"hysteresis\" : {\"value\" : {{ value }}}}}");
|
||||||
doc[FPSTR(HA_MIN)] = 0;
|
doc[FPSTR(HA_MIN)] = 0;
|
||||||
doc[FPSTR(HA_MAX)] = 15;
|
doc[FPSTR(HA_MAX)] = 15;
|
||||||
doc[FPSTR(HA_STEP)] = 0.01f;
|
doc[FPSTR(HA_STEP)] = 0.01f;
|
||||||
|
|||||||
@@ -51,10 +51,6 @@ protected:
|
|||||||
return "Main";
|
return "Main";
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t getTaskStackSize() override {
|
|
||||||
return 6000;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*BaseType_t getTaskCore() override {
|
/*BaseType_t getTaskCore() override {
|
||||||
return 1;
|
return 1;
|
||||||
}*/
|
}*/
|
||||||
|
|||||||
@@ -486,6 +486,7 @@ protected:
|
|||||||
void publishHaEntities() {
|
void publishHaEntities() {
|
||||||
// heating
|
// heating
|
||||||
this->haHelper->publishSwitchHeatingTurbo(false);
|
this->haHelper->publishSwitchHeatingTurbo(false);
|
||||||
|
this->haHelper->publishSwitchHeatingHysteresis();
|
||||||
this->haHelper->publishInputHeatingHysteresis(settings.system.unitSystem);
|
this->haHelper->publishInputHeatingHysteresis(settings.system.unitSystem);
|
||||||
this->haHelper->publishInputHeatingTurboFactor(false);
|
this->haHelper->publishInputHeatingTurboFactor(false);
|
||||||
this->haHelper->publishInputHeatingMinTemp(settings.system.unitSystem);
|
this->haHelper->publishInputHeatingMinTemp(settings.system.unitSystem);
|
||||||
|
|||||||
@@ -38,10 +38,6 @@ protected:
|
|||||||
return "OpenTherm";
|
return "OpenTherm";
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t getTaskStackSize() override {
|
|
||||||
return 7500;
|
|
||||||
}
|
|
||||||
|
|
||||||
BaseType_t getTaskCore() override {
|
BaseType_t getTaskCore() override {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -175,7 +171,7 @@ protected:
|
|||||||
vars.master.heating.enabled = this->isReady()
|
vars.master.heating.enabled = this->isReady()
|
||||||
&& settings.heating.enabled
|
&& settings.heating.enabled
|
||||||
&& vars.cascadeControl.input
|
&& vars.cascadeControl.input
|
||||||
&& !vars.master.heating.blocking
|
&& (!vars.master.heating.blocking || settings.heating.hysteresis.action != HysteresisAction::DISABLE_HEATING)
|
||||||
&& !vars.master.heating.overheat;
|
&& !vars.master.heating.overheat;
|
||||||
|
|
||||||
// DHW settings
|
// DHW settings
|
||||||
|
|||||||
841
src/PortalTask.h
841
src/PortalTask.h
File diff suppressed because it is too large
Load Diff
@@ -22,10 +22,6 @@ protected:
|
|||||||
return "Regulator";
|
return "Regulator";
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t getTaskStackSize() override {
|
|
||||||
return 5000;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*BaseType_t getTaskCore() override {
|
/*BaseType_t getTaskCore() override {
|
||||||
return 1;
|
return 1;
|
||||||
}*/
|
}*/
|
||||||
@@ -63,12 +59,23 @@ protected:
|
|||||||
this->turbo();
|
this->turbo();
|
||||||
this->hysteresis();
|
this->hysteresis();
|
||||||
|
|
||||||
vars.master.heating.targetTemp = settings.heating.target;
|
if (vars.master.heating.blocking && settings.heating.hysteresis.action == HysteresisAction::SET_ZERO_TARGET) {
|
||||||
vars.master.heating.setpointTemp = roundf(constrain(
|
vars.master.heating.targetTemp = 0.0f;
|
||||||
this->getHeatingSetpointTemp(),
|
vars.master.heating.setpointTemp = 0.0f;
|
||||||
this->getHeatingMinSetpointTemp(),
|
|
||||||
this->getHeatingMaxSetpointTemp()
|
// tick if PID enabled
|
||||||
), 0);
|
if (settings.pid.enabled) {
|
||||||
|
this->getHeatingSetpointTemp();
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
vars.master.heating.targetTemp = settings.heating.target;
|
||||||
|
vars.master.heating.setpointTemp = roundf(constrain(
|
||||||
|
this->getHeatingSetpointTemp(),
|
||||||
|
this->getHeatingMinSetpointTemp(),
|
||||||
|
this->getHeatingMaxSetpointTemp()
|
||||||
|
), 0);
|
||||||
|
}
|
||||||
|
|
||||||
Sensors::setValueByType(
|
Sensors::setValueByType(
|
||||||
Sensors::Type::HEATING_SETPOINT_TEMP, vars.master.heating.setpointTemp,
|
Sensors::Type::HEATING_SETPOINT_TEMP, vars.master.heating.setpointTemp,
|
||||||
@@ -96,15 +103,15 @@ protected:
|
|||||||
|
|
||||||
void hysteresis() {
|
void hysteresis() {
|
||||||
bool useHyst = false;
|
bool useHyst = false;
|
||||||
if (settings.heating.hysteresis > 0.01f && this->indoorSensorsConnected) {
|
if (settings.heating.hysteresis.enabled && this->indoorSensorsConnected) {
|
||||||
useHyst = settings.equitherm.enabled || settings.pid.enabled || settings.opentherm.options.nativeHeatingControl;
|
useHyst = settings.equitherm.enabled || settings.pid.enabled || settings.opentherm.options.nativeHeatingControl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (useHyst) {
|
if (useHyst) {
|
||||||
if (!vars.master.heating.blocking && vars.master.heating.indoorTemp - settings.heating.target + 0.0001f >= settings.heating.hysteresis) {
|
if (!vars.master.heating.blocking && vars.master.heating.indoorTemp - settings.heating.target + 0.0001f >= settings.heating.hysteresis.value) {
|
||||||
vars.master.heating.blocking = true;
|
vars.master.heating.blocking = true;
|
||||||
|
|
||||||
} else if (vars.master.heating.blocking && vars.master.heating.indoorTemp - settings.heating.target - 0.0001f <= -(settings.heating.hysteresis)) {
|
} else if (vars.master.heating.blocking && vars.master.heating.indoorTemp - settings.heating.target - 0.0001f <= -(settings.heating.hysteresis.value)) {
|
||||||
vars.master.heating.blocking = false;
|
vars.master.heating.blocking = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ public:
|
|||||||
|
|
||||||
static int16_t getIdByName(const char* name) {
|
static int16_t getIdByName(const char* name) {
|
||||||
if (settings == nullptr) {
|
if (settings == nullptr) {
|
||||||
return -1;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint8_t id = 0; id <= getMaxSensorId(); id++) {
|
for (uint8_t id = 0; id <= getMaxSensorId(); id++) {
|
||||||
@@ -163,7 +163,7 @@ public:
|
|||||||
|
|
||||||
static int16_t getIdByObjectId(const char* objectId) {
|
static int16_t getIdByObjectId(const char* objectId) {
|
||||||
if (settings == nullptr) {
|
if (settings == nullptr) {
|
||||||
return -1;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
String refObjectId;
|
String refObjectId;
|
||||||
|
|||||||
@@ -9,136 +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());
|
Log.sinfoln(
|
||||||
if (sensorAddress.isNull() || sensorAddress != deviceAddress) {
|
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': connected to %s"),
|
||||||
continue;
|
sensorId, sSensor.name, pClient->getPeerAddress().toString().c_str()
|
||||||
}
|
|
||||||
|
|
||||||
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.straceln(
|
|
||||||
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': discovered device %s, name: %s, RSSI: %hhd"),
|
|
||||||
sensorId, sSensor.name,
|
|
||||||
deviceAddress.toString().c_str(), deviceName.c_str(), deviceRssi
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!device->haveServiceData()) {
|
|
||||||
Log.straceln(
|
|
||||||
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
|
|
||||||
);
|
|
||||||
|
|
||||||
NimBLEUUID serviceUuid((uint16_t) 0x181A);
|
|
||||||
auto serviceData = device->getServiceData(serviceUuid);
|
|
||||||
if (!serviceData.size()) {
|
|
||||||
Log.straceln(
|
|
||||||
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': NOT found %s env service data"),
|
|
||||||
sensorId, sSensor.name, serviceUuid.toString().c_str()
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Log.straceln(
|
|
||||||
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': found %s env service data"),
|
|
||||||
sensorId, sSensor.name, serviceUuid.toString().c_str()
|
|
||||||
);
|
|
||||||
|
|
||||||
float temperature, humidity;
|
|
||||||
uint16_t batteryMv;
|
|
||||||
uint8_t batteryLevel;
|
|
||||||
|
|
||||||
if (serviceData.size() == 13) {
|
|
||||||
// atc1441 format
|
|
||||||
|
|
||||||
// Temperature (2 bytes, big-endian)
|
|
||||||
temperature = (
|
|
||||||
(static_cast<uint8_t>(serviceData[6]) << 8) | static_cast<uint8_t>(serviceData[7])
|
|
||||||
) * 0.1f;
|
|
||||||
|
|
||||||
// Humidity (1 byte)
|
|
||||||
humidity = static_cast<uint8_t>(serviceData[8]);
|
|
||||||
|
|
||||||
// Battery mV (2 bytes, big-endian)
|
|
||||||
batteryMv = (static_cast<uint8_t>(serviceData[10]) << 8) | static_cast<uint8_t>(serviceData[11]);
|
|
||||||
|
|
||||||
// Battery level (1 byte)
|
|
||||||
batteryLevel = static_cast<uint8_t>(serviceData[9]);
|
|
||||||
|
|
||||||
} else if (serviceData.size() == 15) {
|
|
||||||
// custom pvvx format
|
|
||||||
|
|
||||||
// Temperature (2 bytes, little-endian)
|
|
||||||
temperature = (
|
|
||||||
(static_cast<uint8_t>(serviceData[7]) << 8) | static_cast<uint8_t>(serviceData[6])
|
|
||||||
) * 0.01f;
|
|
||||||
|
|
||||||
// Humidity (2 bytes, little-endian)
|
|
||||||
humidity = (
|
|
||||||
(static_cast<uint8_t>(serviceData[9]) << 8) | static_cast<uint8_t>(serviceData[8])
|
|
||||||
) * 0.01f;
|
|
||||||
|
|
||||||
// Battery mV (2 bytes, little-endian)
|
|
||||||
batteryMv = (static_cast<uint8_t>(serviceData[11]) << 8) | static_cast<uint8_t>(serviceData[10]);
|
|
||||||
|
|
||||||
// Battery level (1 byte)
|
|
||||||
batteryLevel = static_cast<uint8_t>(serviceData[12]);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// unknown format
|
|
||||||
Log.straceln(
|
|
||||||
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': unknown data format (size: %i)"),
|
|
||||||
sensorId, sSensor.name, serviceData.size()
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Log.straceln(
|
|
||||||
FPSTR(L_SENSORS_BLE),
|
|
||||||
F("Sensor #%hhu '%s', received temp: %.2f; humidity: %.2f, battery voltage: %hu, battery level: %hhu"),
|
|
||||||
sensorId, sSensor.name,
|
|
||||||
temperature, humidity, batteryMv, batteryLevel
|
|
||||||
);
|
|
||||||
|
|
||||||
// update data
|
|
||||||
Sensors::setValueById(sensorId, temperature, Sensors::ValueType::TEMPERATURE, true, true);
|
|
||||||
Sensors::setValueById(sensorId, humidity, Sensors::ValueType::HUMIDITY, true, true);
|
|
||||||
Sensors::setValueById(sensorId, batteryLevel, Sensors::ValueType::BATTERY, true, true);
|
|
||||||
|
|
||||||
// update rssi
|
|
||||||
Sensors::setValueById(sensorId, deviceRssi, Sensors::ValueType::RSSI, false, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void onConnectFail(NimBLEClient* pClient, int reason) {
|
||||||
|
auto& sSensor = Sensors::settings[this->sensorId];
|
||||||
|
|
||||||
|
Log.sinfoln(
|
||||||
|
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': failed to connect, reason %i"),
|
||||||
|
sensorId, sSensor.name, reason
|
||||||
|
);
|
||||||
|
|
||||||
|
pClient->cancelConnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
uint8_t sensorId;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -150,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() {
|
||||||
@@ -162,17 +63,16 @@ 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 disconnectedTimeout = 180000u;
|
const unsigned int disconnectedTimeout = 120000;
|
||||||
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;
|
||||||
@@ -180,9 +80,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;
|
||||||
|
|
||||||
@@ -191,10 +91,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)
|
||||||
@@ -235,7 +131,8 @@ protected:
|
|||||||
this->yield();
|
this->yield();
|
||||||
|
|
||||||
#if USE_BLE
|
#if USE_BLE
|
||||||
scanBleSensors();
|
cleanBleInstances();
|
||||||
|
pollingBleSensors();
|
||||||
this->yield();
|
this->yield();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -547,71 +444,549 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if USE_BLE
|
#if USE_BLE
|
||||||
void scanBleSensors() {
|
void cleanBleInstances() {
|
||||||
if (!Sensors::getAmountByType(Sensors::Type::BLUETOOTH, true)) {
|
if (!NimBLEDevice::isInitialized()) {
|
||||||
if (NimBLEDevice::isInitialized()) {
|
return;
|
||||||
if (this->pBLEScan != nullptr) {
|
}
|
||||||
if (this->pBLEScan->isScanning()) {
|
|
||||||
this->pBLEScan->stop();
|
|
||||||
|
|
||||||
} else {
|
for (auto& [sensorId, pClient]: this->bleClients) {
|
||||||
this->pBLEScan = nullptr;
|
if (pClient == nullptr) {
|
||||||
}
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
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!"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)) {
|
||||||
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto address = NimBLEAddress(sSensor.address, 0);
|
||||||
|
if (address.isNull()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
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(
|
||||||
|
FPSTR(L_SENSORS_BLE), F("Sensor #%hhu '%s': trying connecting to %s..."),
|
||||||
|
sensorId, sSensor.name, pClient->getPeerAddress().toString().c_str()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
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 {
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this->pBLEScan->isScanning()) {
|
auto& sSensor = Sensors::settings[sensorId];
|
||||||
this->activeScanBle = !this->activeScanBle;
|
auto& rSensor = Sensors::results[sensorId];
|
||||||
this->pBLEScan->setActiveScan(this->activeScanBle);
|
|
||||||
|
|
||||||
if (this->pBLEScan->start(30000, false, false)) {
|
if (!sSensor.enabled || sSensor.type != Sensors::Type::BLUETOOTH || sSensor.purpose == Sensors::Purpose::NOT_CONFIGURED) {
|
||||||
Log.sinfoln(
|
return nullptr;
|
||||||
FPSTR(L_SENSORS_BLE),
|
}
|
||||||
F("%s scanning started"),
|
|
||||||
this->activeScanBle ? "Active" : "Passive"
|
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 {
|
} else {
|
||||||
Log.sinfoln(FPSTR(L_SENSORS_BLE), F("Unable to start scanning"));
|
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
|
||||||
|
|
||||||
|
|||||||
@@ -103,12 +103,17 @@ struct Settings {
|
|||||||
bool enabled = true;
|
bool enabled = true;
|
||||||
bool turbo = false;
|
bool turbo = false;
|
||||||
float target = DEFAULT_HEATING_TARGET_TEMP;
|
float target = DEFAULT_HEATING_TARGET_TEMP;
|
||||||
float hysteresis = 0.5f;
|
|
||||||
float turboFactor = 7.5f;
|
float turboFactor = 7.5f;
|
||||||
uint8_t minTemp = DEFAULT_HEATING_MIN_TEMP;
|
uint8_t minTemp = DEFAULT_HEATING_MIN_TEMP;
|
||||||
uint8_t maxTemp = DEFAULT_HEATING_MAX_TEMP;
|
uint8_t maxTemp = DEFAULT_HEATING_MAX_TEMP;
|
||||||
uint8_t maxModulation = 100;
|
uint8_t maxModulation = 100;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
bool enabled = true;
|
||||||
|
float value = 0.5f;
|
||||||
|
HysteresisAction action = HysteresisAction::DISABLE_HEATING;
|
||||||
|
} hysteresis;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
uint8_t highTemp = 95;
|
uint8_t highTemp = 95;
|
||||||
uint8_t lowTemp = 90;
|
uint8_t lowTemp = 90;
|
||||||
|
|||||||
@@ -163,4 +163,9 @@ enum class UnitSystem : uint8_t {
|
|||||||
IMPERIAL = 1
|
IMPERIAL = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class HysteresisAction : uint8_t {
|
||||||
|
DISABLE_HEATING = 0,
|
||||||
|
SET_ZERO_TARGET = 1
|
||||||
|
};
|
||||||
|
|
||||||
char buffer[255];
|
char buffer[255];
|
||||||
@@ -1,3 +1,6 @@
|
|||||||
|
#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>
|
||||||
@@ -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);
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ const char L_CASCADE_OUTPUT[] PROGMEM = "CASCADE.OUTPUT";
|
|||||||
const char L_EXTPUMP[] PROGMEM = "EXTPUMP";
|
const char L_EXTPUMP[] PROGMEM = "EXTPUMP";
|
||||||
|
|
||||||
|
|
||||||
|
const char S_ACTION[] PROGMEM = "action";
|
||||||
const char S_ACTIONS[] PROGMEM = "actions";
|
const char S_ACTIONS[] PROGMEM = "actions";
|
||||||
const char S_ACTIVE[] PROGMEM = "active";
|
const char S_ACTIVE[] PROGMEM = "active";
|
||||||
const char S_ADDRESS[] PROGMEM = "address";
|
const char S_ADDRESS[] PROGMEM = "address";
|
||||||
@@ -164,7 +165,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";
|
||||||
|
|||||||
38
src/utils.h
38
src/utils.h
@@ -490,7 +490,9 @@ void settingsToJson(const Settings& src, JsonVariant dst, bool safe = false) {
|
|||||||
heating[FPSTR(S_ENABLED)] = src.heating.enabled;
|
heating[FPSTR(S_ENABLED)] = src.heating.enabled;
|
||||||
heating[FPSTR(S_TURBO)] = src.heating.turbo;
|
heating[FPSTR(S_TURBO)] = src.heating.turbo;
|
||||||
heating[FPSTR(S_TARGET)] = roundf(src.heating.target, 2);
|
heating[FPSTR(S_TARGET)] = roundf(src.heating.target, 2);
|
||||||
heating[FPSTR(S_HYSTERESIS)] = roundf(src.heating.hysteresis, 3);
|
heating[FPSTR(S_HYSTERESIS)][FPSTR(S_ENABLED)] = src.heating.hysteresis.enabled;
|
||||||
|
heating[FPSTR(S_HYSTERESIS)][FPSTR(S_VALUE)] = roundf(src.heating.hysteresis.value, 3);
|
||||||
|
heating[FPSTR(S_HYSTERESIS)][FPSTR(S_ACTION)] = static_cast<uint8_t>(src.heating.hysteresis.action);
|
||||||
heating[FPSTR(S_TURBO_FACTOR)] = roundf(src.heating.turboFactor, 3);
|
heating[FPSTR(S_TURBO_FACTOR)] = roundf(src.heating.turboFactor, 3);
|
||||||
heating[FPSTR(S_MIN_TEMP)] = src.heating.minTemp;
|
heating[FPSTR(S_MIN_TEMP)] = src.heating.minTemp;
|
||||||
heating[FPSTR(S_MAX_TEMP)] = src.heating.maxTemp;
|
heating[FPSTR(S_MAX_TEMP)] = src.heating.maxTemp;
|
||||||
@@ -1304,15 +1306,41 @@ bool jsonToSettings(const JsonVariantConst src, Settings& dst, bool safe = false
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!src[FPSTR(S_HEATING)][FPSTR(S_HYSTERESIS)].isNull()) {
|
if (src[FPSTR(S_HEATING)][FPSTR(S_HYSTERESIS)][FPSTR(S_ENABLED)].is<bool>()) {
|
||||||
float value = src[FPSTR(S_HEATING)][FPSTR(S_HYSTERESIS)].as<float>();
|
bool value = src[FPSTR(S_HEATING)][FPSTR(S_HYSTERESIS)][FPSTR(S_ENABLED)].as<bool>();
|
||||||
|
|
||||||
if (value >= 0.0f && value <= 15.0f && fabsf(value - dst.heating.hysteresis) > 0.0001f) {
|
if (value != dst.heating.hysteresis.enabled) {
|
||||||
dst.heating.hysteresis = roundf(value, 2);
|
dst.heating.hysteresis.enabled = value;
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!src[FPSTR(S_HEATING)][FPSTR(S_HYSTERESIS)][FPSTR(S_VALUE)].isNull()) {
|
||||||
|
float value = src[FPSTR(S_HEATING)][FPSTR(S_HYSTERESIS)][FPSTR(S_VALUE)].as<float>();
|
||||||
|
|
||||||
|
if (value >= 0.0f && value <= 15.0f && fabsf(value - dst.heating.hysteresis.value) > 0.0001f) {
|
||||||
|
dst.heating.hysteresis.value = roundf(value, 2);
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!src[FPSTR(S_HEATING)][FPSTR(S_HYSTERESIS)][FPSTR(S_ACTION)].isNull()) {
|
||||||
|
uint8_t value = src[FPSTR(S_HEATING)][FPSTR(S_HYSTERESIS)][FPSTR(S_ACTION)].as<uint8_t>();
|
||||||
|
|
||||||
|
switch (value) {
|
||||||
|
case static_cast<uint8_t>(HysteresisAction::DISABLE_HEATING):
|
||||||
|
case static_cast<uint8_t>(HysteresisAction::SET_ZERO_TARGET):
|
||||||
|
if (static_cast<uint8_t>(dst.heating.hysteresis.action) != value) {
|
||||||
|
dst.heating.hysteresis.action = static_cast<HysteresisAction>(value);
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!src[FPSTR(S_HEATING)][FPSTR(S_TURBO_FACTOR)].isNull()) {
|
if (!src[FPSTR(S_HEATING)][FPSTR(S_TURBO_FACTOR)].isNull()) {
|
||||||
float value = src[FPSTR(S_HEATING)][FPSTR(S_TURBO_FACTOR)].as<float>();
|
float value = src[FPSTR(S_HEATING)][FPSTR(S_TURBO_FACTOR)].as<float>();
|
||||||
|
|
||||||
|
|||||||
@@ -356,7 +356,16 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
"heating": {
|
"heating": {
|
||||||
"hyst": "滞后值<small>(单位:度)</small>",
|
"hyst": {
|
||||||
|
"title": "滞回",
|
||||||
|
"desc": "滞回有助于维持设定的室内温度(在使用«Equitherm»和/或«PID»时)。强制禁用加热当<code>current indoor > target + value</code>,启用加热当<code>current indoor < (target - value)</code>。",
|
||||||
|
"value": "值 <small>(以度为单位)</small>",
|
||||||
|
"action": {
|
||||||
|
"title": "行动",
|
||||||
|
"disableHeating": "禁用加热",
|
||||||
|
"set0target": "设置空目标"
|
||||||
|
}
|
||||||
|
},
|
||||||
"turboFactor": "Turbo 模式系数"
|
"turboFactor": "Turbo 模式系数"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -356,7 +356,16 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
"heating": {
|
"heating": {
|
||||||
"hyst": "Hysteresis <small>(in degrees)</small>",
|
"hyst": {
|
||||||
|
"title": "Hysteresis",
|
||||||
|
"desc": "Hysteresis is useful for maintaining a set indoor temp (when using «Equitherm» and/or «PID»). Forces disable heating when <code>current indoor > target + value</code> and enable heating when <code>current indoor < (target - value)</code>.",
|
||||||
|
"value": "Value <small>(in degrees)</small>",
|
||||||
|
"action": {
|
||||||
|
"title": "Action",
|
||||||
|
"disableHeating": "Disable heating",
|
||||||
|
"set0target": "Set null target"
|
||||||
|
}
|
||||||
|
},
|
||||||
"turboFactor": "Turbo mode coeff."
|
"turboFactor": "Turbo mode coeff."
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -356,7 +356,16 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
"heating": {
|
"heating": {
|
||||||
"hyst": "Isteresi <small>(in gradi)</small>",
|
"hyst": {
|
||||||
|
"title": "Isteresi",
|
||||||
|
"desc": "L'isteresi è utile per mantenere una temperatura interna impostata (quando si utilizza «Equitherm» e/o «PID»). Forza la disabilitazione del riscaldamento quando <code>current indoor > target + value</code> e abilita il riscaldamento quando <code>current indoor < (target - value)</code>.",
|
||||||
|
"value": "Valore <small>(in gradi)</small>",
|
||||||
|
"action": {
|
||||||
|
"title": "Azione",
|
||||||
|
"disableHeating": "Disabilita riscaldamento",
|
||||||
|
"set0target": "Imposta target nullo"
|
||||||
|
}
|
||||||
|
},
|
||||||
"turboFactor": "Turbo mode coeff."
|
"turboFactor": "Turbo mode coeff."
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -327,7 +327,16 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"heating": {
|
"heating": {
|
||||||
"hyst": "Hysterese <small>(in graden)</small>",
|
"hyst": {
|
||||||
|
"title": "Hysterese",
|
||||||
|
"desc": "Hysterese is nuttig voor het handhaven van een ingestelde binnentemperatuur (bij gebruik van «Equitherm» en/of «PID»). Forceert uitschakelen van verwarming wanneer <code>current indoor > target + value</code> en inschakelen van verwarming wanneer <code>current indoor < (target - value)</code>.",
|
||||||
|
"value": "Waarde <small>(in graden)</small>",
|
||||||
|
"action": {
|
||||||
|
"title": "Actie",
|
||||||
|
"disableHeating": "Verwarming uitschakelen",
|
||||||
|
"set0target": "Stel null target in"
|
||||||
|
}
|
||||||
|
},
|
||||||
"turboFactor": "Turbomodus coëff."
|
"turboFactor": "Turbomodus coëff."
|
||||||
},
|
},
|
||||||
"emergency": {
|
"emergency": {
|
||||||
|
|||||||
@@ -356,7 +356,16 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
"heating": {
|
"heating": {
|
||||||
"hyst": "Гистерезис <small>(в градусах)</small>",
|
"hyst": {
|
||||||
|
"title": "Гистерезис",
|
||||||
|
"desc": "Гистерезис полезен для поддержания заданной внутр. темп. (при использовании «Equitherm» и/или «PID»). Принудительно откл. отопление, когда <code>current indoor > target + value</code>, и вкл. отопление, когда <code>current indoor < (target - value)</code>.",
|
||||||
|
"value": "Значение <small>(в градусах)</small>",
|
||||||
|
"action": {
|
||||||
|
"title": "Действие",
|
||||||
|
"disableHeating": "Отключить отопление",
|
||||||
|
"set0target": "Установить 0 в качестве целевой темп."
|
||||||
|
}
|
||||||
|
},
|
||||||
"turboFactor": "Коэфф. турбо режима"
|
"turboFactor": "Коэфф. турбо режима"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -193,21 +193,48 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="grid">
|
<div class="grid">
|
||||||
<label>
|
|
||||||
<span data-i18n>settings.heating.hyst</span>
|
|
||||||
<input type="number" inputmode="decimal" name="heating[hysteresis]" min="0" max="5" step="0.05" required>
|
|
||||||
</label>
|
|
||||||
|
|
||||||
<label>
|
<label>
|
||||||
<span data-i18n>settings.heating.turboFactor</span>
|
<span data-i18n>settings.heating.turboFactor</span>
|
||||||
<input type="number" inputmode="decimal" name="heating[turboFactor]" min="1.5" max="10" step="0.1" required>
|
<input type="number" inputmode="decimal" name="heating[turboFactor]" min="1.5" max="10" step="0.1" required>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
|
<label>
|
||||||
|
<span data-i18n>settings.maxModulation</span>
|
||||||
|
<input type="number" inputmode="numeric" name="heating[maxModulation]" min="1" max="100" step="1" required>
|
||||||
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<label>
|
<hr />
|
||||||
<span data-i18n>settings.maxModulation</span>
|
|
||||||
<input type="number" inputmode="numeric" name="heating[maxModulation]" min="1" max="100" step="1" required>
|
<details>
|
||||||
</label>
|
<summary><b data-i18n>settings.heating.hyst.title</b></summary>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<fieldset>
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" name="heating[hysteresis][enabled]" value="true">
|
||||||
|
<span data-i18n>settings.enable</span>
|
||||||
|
</label>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<div class="grid">
|
||||||
|
<label>
|
||||||
|
<span data-i18n>settings.heating.hyst.value</span>
|
||||||
|
<input type="number" inputmode="decimal" name="heating[hysteresis][value]" min="0" max="5" step="0.05" required>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<label>
|
||||||
|
<span data-i18n>settings.heating.hyst.action.title</span>
|
||||||
|
<select name="heating[hysteresis][action]">
|
||||||
|
<option value="0" data-i18n>settings.heating.hyst.action.disableHeating</option>
|
||||||
|
<option value="1" data-i18n>settings.heating.hyst.action.set0target</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<small data-i18n>settings.heating.hyst.desc</small>
|
||||||
|
</details>
|
||||||
|
|
||||||
<hr />
|
<hr />
|
||||||
|
|
||||||
@@ -963,7 +990,9 @@
|
|||||||
"min": data.system.unitSystem == 0 ? 1 : 33,
|
"min": data.system.unitSystem == 0 ? 1 : 33,
|
||||||
"max": data.system.unitSystem == 0 ? 100 : 212
|
"max": data.system.unitSystem == 0 ? 100 : 212
|
||||||
});
|
});
|
||||||
setInputValue("[name='heating[hysteresis]']", data.heating.hysteresis);
|
setCheckboxValue("[name='heating[hysteresis][enabled]']", data.heating.hysteresis.enabled);
|
||||||
|
setInputValue("[name='heating[hysteresis][value]']", data.heating.hysteresis.value);
|
||||||
|
setSelectValue("[name='heating[hysteresis][action]']", data.heating.hysteresis.action);
|
||||||
setInputValue("[name='heating[turboFactor]']", data.heating.turboFactor);
|
setInputValue("[name='heating[turboFactor]']", data.heating.turboFactor);
|
||||||
setInputValue("[name='heating[maxModulation]']", data.heating.maxModulation);
|
setInputValue("[name='heating[maxModulation]']", data.heating.maxModulation);
|
||||||
setInputValue("[name='heating[overheatProtection][highTemp]']", data.heating.overheatProtection.highTemp, {
|
setInputValue("[name='heating[overheatProtection][highTemp]']", data.heating.overheatProtection.highTemp, {
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
Reference in New Issue
Block a user