mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2026-05-09 07:25:49 +00:00
Compare commits
154 Commits
main
...
60b7d6d795
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
60b7d6d795 | ||
|
|
947f29cca0 | ||
|
|
d2a13ec0da | ||
|
|
cc39ba409e | ||
|
|
ac9db6256e | ||
|
|
096f628d97 | ||
|
|
bbc2de08a5 | ||
|
|
22312812bb | ||
|
|
df808a2bcf | ||
|
|
d04e7c36f3 | ||
|
|
205d826adb | ||
|
|
3584975acb | ||
|
|
30b9ca4e6c | ||
|
|
7c6ff01ebe | ||
|
|
a54edcaf5b | ||
|
|
e446954844 | ||
|
|
4a2d0d6787 | ||
|
|
9725314135 | ||
|
|
4db8e43648 | ||
|
|
e610f0d57f | ||
|
|
8244af2940 | ||
|
|
cc60062678 | ||
|
|
40f371d23b | ||
|
|
817b791e59 | ||
|
|
25a7aac360 | ||
|
|
37115a174d | ||
|
|
1397f81fd0 | ||
|
|
56365cb403 | ||
|
|
dfd245ee7b | ||
|
|
9c81e4b34d | ||
|
|
67676df131 | ||
|
|
a73b129596 | ||
|
|
4600d886b5 | ||
|
|
e3305ab9db | ||
|
|
0fe45a2405 | ||
|
|
db87213242 | ||
|
|
b0157f288e | ||
|
|
5c3c010d5a | ||
|
|
c804cedd7a | ||
|
|
a9f50d9371 | ||
|
|
65a3226404 | ||
|
|
45690f5418 | ||
|
|
aa30ca99bf | ||
|
|
6836b6197f | ||
|
|
c0ca9d1069 | ||
|
|
5e79e1d57f | ||
|
|
8c732f9f1e | ||
|
|
5e94c2f636 | ||
|
|
69d4163b9d | ||
|
|
b1e974a82c | ||
|
|
34a2b20be8 | ||
|
|
f1fc8d9aae | ||
|
|
b04355e3e1 | ||
|
|
cd3ae5cdf2 | ||
|
|
a261ca23af | ||
|
|
cb96904a5c | ||
|
|
4a2d78f8e1 | ||
|
|
f5af4fb52f | ||
|
|
2037bc3a10 | ||
|
|
64d17d7c65 | ||
|
|
92e2633342 | ||
|
|
96a7ea8a02 | ||
|
|
5c4aaa4510 | ||
|
|
c05e1cb77b | ||
|
|
5879ce4090 | ||
|
|
ac3e5c793c | ||
|
|
64e5d29996 | ||
|
|
b320d8ded2 | ||
|
|
4326fb931b | ||
|
|
ced7051ce7 | ||
|
|
0be1b20996 | ||
|
|
6c55460622 | ||
|
|
421da246ed | ||
|
|
d627404dc2 | ||
|
|
148a721e17 | ||
|
|
f317123c26 | ||
|
|
e4df1887b0 | ||
|
|
34142c3e85 | ||
|
|
6e7f8bdf02 | ||
|
|
3dd9fcfb58 | ||
|
|
35e2954b8b | ||
|
|
59aa63db0f | ||
|
|
7a41a190f8 | ||
|
|
6741232450 | ||
|
|
a811670c5a | ||
|
|
72f08a86cf | ||
|
|
27c471f45f | ||
|
|
e303972d26 | ||
|
|
97bb03d703 | ||
|
|
e9f77c1bde | ||
|
|
81cba6c0a8 | ||
|
|
89029df25e | ||
|
|
3463b6818d | ||
|
|
349843e666 | ||
|
|
96ae3bbbba | ||
|
|
b153364b60 | ||
|
|
ccc40937fb | ||
|
|
909edf394d | ||
|
|
ac8ef646e9 | ||
|
|
3ef279ea10 | ||
|
|
769beeda37 | ||
|
|
f83404c216 | ||
|
|
c239658131 | ||
|
|
be82afd778 | ||
|
|
2156c96368 | ||
|
|
f7f078d82a | ||
|
|
95168cf514 | ||
|
|
6dc601c4a2 | ||
|
|
6b87bbb882 | ||
|
|
abdf2c5037 | ||
|
|
7beec1b80f | ||
|
|
3a0e46f064 | ||
|
|
85cc85a923 | ||
|
|
ca0079c0df | ||
|
|
28b662ad43 | ||
|
|
6bac6bbfeb | ||
|
|
958ec1002b | ||
|
|
438852ecaf | ||
|
|
92d82c0a00 | ||
|
|
7d37267f57 | ||
|
|
5641d53cc3 | ||
|
|
8fc6752290 | ||
|
|
cca6f87500 | ||
|
|
758d76051f | ||
|
|
95f7e66cff | ||
|
|
4e194287c9 | ||
|
|
3545830552 | ||
|
|
074f4c32ed | ||
|
|
b3fec5ed7d | ||
|
|
ffb90b8f9a | ||
|
|
584618043d | ||
|
|
d702c485b7 | ||
|
|
d3561da331 | ||
|
|
0e0aaf37df | ||
|
|
5ec068409f | ||
|
|
8796b6d340 | ||
|
|
bfbb18655d | ||
|
|
9088651e53 | ||
|
|
3e8f379502 | ||
|
|
265c2c4231 | ||
|
|
f671d79280 | ||
|
|
97c89d1d13 | ||
|
|
e0a26a38fa | ||
|
|
038f06e59f | ||
|
|
f4d2bae04f | ||
|
|
d443e275ea | ||
|
|
30d2057e01 | ||
|
|
d952b9aaae | ||
|
|
3402215e8d | ||
|
|
f01031dc26 | ||
|
|
01d4d116b9 | ||
|
|
bc7f82eef1 | ||
|
|
efdb355033 | ||
|
|
87c9fd010f |
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -22,7 +22,7 @@ _Make sure your have performed every step and checked the applicable boxes befor
|
||||
- [ ] Searched the issue in [issues](https://github.com/emsesp/EMS-ESP32/issues)
|
||||
- [ ] Searched the issue in [discussions](https://github.com/emsesp/EMS-ESP32/discussions)
|
||||
- [ ] Searched the issue in the [docs](https://emsesp.org/Troubleshooting/)
|
||||
- [ ] Searched the issue in the [chat](https://discord.gg/3J3GgnzpyT)
|
||||
- [ ] Searched the issue in the [chat](https://discord.gg/GP9DPSgeJq)
|
||||
- [ ] Provide the System information in the area below, taken from `http://<IP>/api/system`
|
||||
|
||||
```json
|
||||
|
||||
2
.github/ISSUE_TEMPLATE/config.yml
vendored
2
.github/ISSUE_TEMPLATE/config.yml
vendored
@@ -7,5 +7,5 @@ contact_links:
|
||||
url: https://github.com/emsesp/EMS-ESP32/discussions
|
||||
about: EMS-ESP usage Questions, Feature Requests and Projects.
|
||||
- name: EMS-ESP Users Chat
|
||||
url: https://discord.gg/3J3GgnzpyT
|
||||
url: https://discord.gg/GP9DPSgeJq
|
||||
about: Chat for feedback, questions and troubleshooting.
|
||||
|
||||
29
CHANGELOG.md
29
CHANGELOG.md
@@ -5,6 +5,35 @@ All notable changes to this project will be documented in this file.
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [3.8.1] 11 January 2026
|
||||
|
||||
## Added
|
||||
|
||||
- update time saved in nvs
|
||||
- heatpump entities [#2883](https://github.com/emsesp/EMS-ESP32/issues/2883)
|
||||
- HA input number format (mode) selectable box/slider (slider for max range 100) [#2900](https://github.com/emsesp/EMS-ESP32/discussions/2900)
|
||||
|
||||
## Fixed
|
||||
|
||||
- fix EMS bus disconnected errors on some systems [#2881](https://github.com/emsesp/EMS-ESP32/issues/2881)
|
||||
- selflowtemp fix [#2876](https://github.com/emsesp/EMS-ESP32/issues/2876)
|
||||
- updated valid GPIOs for ESP32S2, ESP32S3 and ESP32 that caused custom systems to block gpios [#2887](https://github.com/emsesp/EMS-ESP32/issues/2887)
|
||||
- Junkers wwcharge offset [#2860](https://github.com/emsesp/EMS-ESP32/issues/2860)
|
||||
- fixed minflowtemp [#2890](https://github.com/emsesp/EMS-ESP32/issues/2890)
|
||||
- don't add HA uom/classes for bool values [#2885](https://github.com/emsesp/EMS-ESP32/issues/2885)
|
||||
- fixed missing progress bar on web firmware uploads
|
||||
|
||||
## Changed
|
||||
|
||||
- snapshot gpios stored in temporary ram
|
||||
- GPIOs stored along with the name and reported in log if conflicting
|
||||
- free GPIOs depend on board profile [#2901](https://github.com/emsesp/EMS-ESP32/issues/2901)
|
||||
- prefer PSram for mqtt queue [#2889](https://github.com/emsesp/EMS-ESP32/issues/2889)
|
||||
- day schedule defult to all days, no day selected is not allowed
|
||||
- board profile `CUSTOM` can only be selected in developer mode
|
||||
- mqtt sends round values without decimals (`28` instead of `28.0`)
|
||||
|
||||
|
||||
## [3.8.0] 31 December 2025
|
||||
|
||||
## Added
|
||||
|
||||
@@ -2,30 +2,32 @@
|
||||
|
||||
For more details go to [emsesp.org](https://emsesp.org/).
|
||||
|
||||
## [3.8.1]
|
||||
## [3.8.2]
|
||||
|
||||
## Added
|
||||
|
||||
- update time saved in nvs
|
||||
- heatpump entities [#2883](https://github.com/emsesp/EMS-ESP32/issues/2883)
|
||||
- HA input number format (mode) selectable box/slider (slider for max range 100) [#2900](https://github.com/emsesp/EMS-ESP32/discussions/2900)
|
||||
- comfortpoint for BC400 [#2935](https://github.com/emsesp/EMS-ESP32/issues/2935)
|
||||
- customize device brand [#2784](https://github.com/emsesp/EMS-ESP32/issues/2784)
|
||||
- set model for ems-esp devices temperature, analog, etc. [#2958](https://github.com/emsesp/EMS-ESP32/discussions/2958)
|
||||
- prometheus metrics for temperature/analog/scheduler/custom [#2962](https://github.com/emsesp/EMS-ESP32/issues/2962)
|
||||
- boiler pumpkick [#2965](https://github.com/emsesp/EMS-ESP32/discussions/2965)
|
||||
- heatpump reset [#2933](https://github.com/emsesp/EMS-ESP32/issues/2933)
|
||||
- e-mail notification using ReadyMail Client
|
||||
- 2.nd freshwater module (dhw4) [#2991](https://github.com/emsesp/EMS-ESP32/issues/2991)
|
||||
|
||||
## Fixed
|
||||
|
||||
- fix EMS bus disconnected errors on some systems [#2881](https://github.com/emsesp/EMS-ESP32/issues/2881)
|
||||
- selflowtemp fix [#2876](https://github.com/emsesp/EMS-ESP32/issues/2876)
|
||||
- updated valid GPIOs for ESP32S2, ESP32S3 and ESP32 that caused custom systems to block gpios [#2887](https://github.com/emsesp/EMS-ESP32/issues/2887)
|
||||
- Junkers wwcharge offset [#2860](https://github.com/emsesp/EMS-ESP32/issues/2860)
|
||||
- fixed minflowtemp [#2890](https://github.com/emsesp/EMS-ESP32/issues/2890)
|
||||
- don't add HA uom/classes for bool values [#2885](https://github.com/emsesp/EMS-ESP32/issues/2885)
|
||||
- fixed missing progress bar on web firmware uploads
|
||||
- SRC climate creation [#2936](https://github.com/emsesp/EMS-ESP32/issues/2936) and [#2960](https://github.com/emsesp/EMS-ESP32/issues/2960)
|
||||
|
||||
## Changed
|
||||
|
||||
- snapshot gpios stored in temporary ram
|
||||
- GPIOs stored along with the name and reported in log if conflicting
|
||||
- free GPIOs depend on board profile [#2901](https://github.com/emsesp/EMS-ESP32/issues/2901)
|
||||
- prefer PSram for mqtt queue [#2889](https://github.com/emsesp/EMS-ESP32/issues/2889)
|
||||
- day schedule defult to all days, no day selected is not allowed
|
||||
- board profile `CUSTOM` can only be selected in developer mode
|
||||
- mqtt sends round values without decimals (`28` instead of `28.0`)
|
||||
- weblogbuffer up to 1000 messages with PSRAM, mentioned in [#2933](https://github.com/emsesp/EMS-ESP32/issues/2933)
|
||||
- validate custom entity writes, [#2931](https://github.com/emsesp/EMS-ESP32/issues/2931)
|
||||
- remove wrong burnMinPower [#2918](https://github.com/emsesp/EMS-ESP32/issues/2918)
|
||||
- store scheduler active state to nvs [#2946](https://github.com/emsesp/EMS-ESP32/discussions/2946)
|
||||
- translated modes `heat` and `eco` for HA-climate mode-str-tpl
|
||||
- support `minflowtemp` and `baseflowtemp` [#2969](https://github.com/emsesp/EMS-ESP32/discussions/2969)
|
||||
- update version if it is 00.00 in first read [#2981](https://github.com/emsesp/EMS-ESP32/issues/2981)
|
||||
- device class for % values [#2980](https://github.com/emsesp/EMS-ESP32/issues/2980)
|
||||
- use tasmota core 2026.03.30
|
||||
- secure mqtt uses ESP_SSLClient
|
||||
|
||||
7
Makefile
7
Makefile
@@ -63,8 +63,9 @@ CXX_STANDARD := -std=gnu++17
|
||||
#----------------------------------------------------------------------
|
||||
# Defined Symbols
|
||||
#----------------------------------------------------------------------
|
||||
DEFINES += -DARDUINOJSON_ENABLE -DARDUINOJSON_ENABLE_ARDUINO_STRING -DARDUINOJSON_USE_DOUBLE=0
|
||||
DEFINES += -DARDUINOJSON_ENABLE -DARDUINOJSON_ENABLE_ARDUINO_STRING -DARDUINOJSON_USE_DOUBLE=0
|
||||
DEFINES += -DEMSESP_STANDALONE -DEMSESP_TEST -DEMSESP_DEBUG -DEMC_RX_BUFFER_SIZE=1500
|
||||
DEFINES += -DNO_TLS_SUPPORT
|
||||
DEFINES += $(ARGS)
|
||||
|
||||
DEFAULTS = -DEMSESP_DEFAULT_LOCALE=\"en\" -DEMSESP_DEFAULT_BOARD_PROFILE=\"S32S3\"
|
||||
@@ -79,6 +80,10 @@ SYMBOLS := $(CURDIR)/$(BUILD)/$(TARGET).out
|
||||
CSOURCES := $(shell find $(SOURCES) -name "*.c" 2>/dev/null)
|
||||
CXXSOURCES := $(shell find $(SOURCES) -name "*.cpp" 2>/dev/null)
|
||||
|
||||
# Exclude files not needed for standalone build, if they exist
|
||||
CSOURCES := $(filter-out src/core/ModuleLibrary.c,$(CSOURCES))
|
||||
CXXSOURCES := $(filter-out src/core/ModuleLibrary.cpp,$(CXXSOURCES))
|
||||
|
||||
OBJS := $(patsubst %,$(BUILD)/%.o,$(basename $(CSOURCES)) $(basename $(CXXSOURCES)))
|
||||
DEPS := $(patsubst %,$(BUILD)/%.d,$(basename $(CSOURCES)) $(basename $(CXXSOURCES)))
|
||||
|
||||
|
||||
18
README.md
18
README.md
@@ -18,7 +18,7 @@
|
||||
<a href="https://emsesp.org">
|
||||
<img src="https://img.shields.io/badge/Documentation-0077b5?style=for-the-badge&logo=googledocs&logoColor=white" alt="Guides" />
|
||||
</a>
|
||||
<a href="https://discord.gg/3J3GgnzpyT">
|
||||
<a href="https://discord.gg/GP9DPSgeJq">
|
||||
<img src="https://img.shields.io/badge/Discord-7289da?style=for-the-badge&logo=discord&logoColor=white" alt="Discord" />
|
||||
</a>
|
||||
<a href="https://github.com/emsesp/EMS-ESP32/blob/main/CHANGELOG.md">
|
||||
@@ -32,7 +32,8 @@
|
||||
[](https://sonarcloud.io/summary/new_code?id=emsesp_EMS-ESP32)
|
||||
[](https://app.codacy.com/gh/emsesp/EMS-ESP32/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
|
||||
[](https://github.com/emsesp/EMS-ESP32/releases)
|
||||
[](https://discord.gg/3J3GgnzpyT)
|
||||
[](https://discord.gg/GP9DPSgeJq)
|
||||
[](https://deepwiki.com/emsesp/EMS-ESP32)
|
||||
|
||||
[](https://github.com/emsesp/EMS-ESP32/stargazers)
|
||||
[](https://github.com/emsesp/EMS-ESP32/network)
|
||||
@@ -40,7 +41,8 @@
|
||||
|
||||
**EMS-ESP** is an open-source firmware for the Espressif ESP32 microcontroller to communicate with **EMS** (Energy Management System) compatible equipment from manufacturers such as Bosch, Buderus, Nefit, Junkers, Worcester, Sieger, elm.leblanc and iVT.
|
||||
|
||||
It requires a small circuit to interface with the EMS bus which can be purchased from <https://bbqkees-electronics.nl> or custom built.
|
||||
It requires a small circuit to interface with the EMS bus which can be purchased from <https://bbqkees-electronics.nl>. These gateways are tested thoroughly and certified to work with EMS-ESP.
|
||||
|
||||
|
||||
## 📦 **Key Features**
|
||||
|
||||
@@ -64,17 +66,17 @@ Head over to the [Installation Guide](https://emsesp.org/Installing) section of
|
||||
|
||||
## 📋 **Documentation**
|
||||
|
||||
Visit [emsesp.org](https://emsesp.org) for more details on how to install and configure EMS-ESP. There is also a collection of Frequently Asked Questions and Troubleshooting tips with example customizations from the community.
|
||||
Visit [emsesp.org](https://emsesp.org) for more details on how to setup and configure EMS-ESP. You'll also find more a collection of example configuarations, Frequently Asked Questions and Troubleshooting tips.
|
||||
|
||||
## 💬 **Getting Support**
|
||||
|
||||
To chat with the community reach out on our [Discord Server](https://discord.gg/3J3GgnzpyT).
|
||||
To chat with the community reach out on our [Discord Server](https://discord.gg/GP9DPSgeJq).
|
||||
|
||||
If you find an issue or have a request, see [how to request support](https://emsesp.org/Support/) on how to submit a bug report or feature request.
|
||||
If you find an issue or have a request, see the [Getting Support](https://emsesp.org/Support/) section of the documentation. Note if you are using a non-BBQKees EMS gateway, you may need to contact the manufacturer for support.
|
||||
|
||||
## 🎥 **Live Demo**
|
||||
|
||||
For a live demo go to [demo.emsesp.org](https://demo.emsesp.org). Pick a language from the sign on page and log in with any username or password. Note not all features are operational as it's based on static data.
|
||||
To see a live demo go to [demo.emsesp.org](https://demo.emsesp.org). Pick a language and use any username and password to log in. Note whast you're seeing is static example data so not all features are operational.
|
||||
|
||||
## 💖 **Contributors**
|
||||
|
||||
@@ -84,7 +86,7 @@ If you like **EMS-ESP**, please give it a ✨ on GitHub, or even better fork it
|
||||
|
||||
## 📦 **Building**
|
||||
|
||||
See the [Building Guide](https://emsesp.org/Building) section of the documentation for instructions on how to build EMS-ESP.
|
||||
See the [Building the firmware](https://emsesp.org/Building) guide in the documentation for instructions on how to build EMS-ESP from this source code.
|
||||
|
||||
## 📢 **Libraries used**
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
},
|
||||
"core": "esp32",
|
||||
"extra_flags": [
|
||||
"-DTASMOTA_SDK",
|
||||
"-DNO_TLS_SUPPORT",
|
||||
"-DARDUINO_LOLIN_C3_MINI",
|
||||
"-DARDUINO_USB_MODE=1",
|
||||
"-DARDUINO_USB_CDC_ON_BOOT=1"
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"core": "esp32",
|
||||
"extra_flags": [
|
||||
"-DBOARD_HAS_PSRAM",
|
||||
"-DTASMOTA_SDK",
|
||||
"-DNO_TLS_SUPPORT",
|
||||
"-DARDUINO_USB_CDC_ON_BOOT=1",
|
||||
"-DARDUINO_USB_MODE=0"
|
||||
],
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
"arduino",
|
||||
"espidf"
|
||||
],
|
||||
"name": "Espressif ESP32-S3 32M Flash OPI PSRAM, 4608KB Code/OTA, 2MB FS",
|
||||
"name": "Tasmota ESP32-S3 32M Flash OPI PSRAM, 4608KB Code/OTA, 2MB FS",
|
||||
"upload": {
|
||||
"flash_size": "32MB",
|
||||
"maximum_ram_size": 327680,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"build": {
|
||||
"core": "esp32",
|
||||
"extra_flags": "-DTASMOTA_SDK",
|
||||
"extra_flags": "-DNO_TLS_SUPPORT",
|
||||
"f_cpu": "240000000L",
|
||||
"f_flash": "40000000L",
|
||||
"flash_mode": "dio",
|
||||
@@ -19,7 +19,7 @@
|
||||
"arduino",
|
||||
"espidf"
|
||||
],
|
||||
"name": "Espressif ESP32 16M Flash, 4608KB Code/OTA, 2MB FS",
|
||||
"name": "Tasmota ESP32 16M Flash, 4608KB Code/OTA, 2MB FS",
|
||||
"upload": {
|
||||
"flash_size": "16MB",
|
||||
"maximum_ram_size": 327680,
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
"arduino",
|
||||
"espidf"
|
||||
],
|
||||
"name": "Espressif ESP32 16M Flash DIO PSRAM, 4608KB Code/OTA, 2MB FS",
|
||||
"name": "Tasmota ESP32 16M Flash DIO PSRAM, 4608KB Code/OTA, 2MB FS",
|
||||
"upload": {
|
||||
"flash_size": "16MB",
|
||||
"maximum_ram_size": 327680,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"build": {
|
||||
"core": "esp32",
|
||||
"extra_flags": "-DTASMOTA_SDK",
|
||||
"extra_flags": "-DNO_TLS_SUPPORT",
|
||||
"f_cpu": "240000000L",
|
||||
"f_flash": "40000000L",
|
||||
"flash_mode": "dio",
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"build": {
|
||||
"core": "esp32",
|
||||
"extra_flags": [
|
||||
"-DNO_TLS_SUPPORT",
|
||||
"-DARDUINO_XIAO_ESP32C6",
|
||||
"-DARDUINO_USB_MODE=1",
|
||||
"-DARDUINO_USB_CDC_ON_BOOT=1"
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
}
|
||||
],
|
||||
"dictionaries": ["project-words"],
|
||||
"caseSensitive": false,
|
||||
"ignorePaths": [
|
||||
"node_modules",
|
||||
"compile_commands.json",
|
||||
@@ -36,6 +37,8 @@
|
||||
"pnpm-*.yaml",
|
||||
"vite.config.ts",
|
||||
"lib/esp32-psram/**",
|
||||
"test/test_api/test_api.h"
|
||||
"test/test_api/test_api.h",
|
||||
"lib_standalone/**",
|
||||
"lib/mbedtls_ssl/**"
|
||||
]
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -13,7 +13,7 @@ telegram_type_id,name,is_fetched
|
||||
0x19,UBAMonitorSlow,
|
||||
0x1A,UBASetPoints,
|
||||
0x1C,UBAMaintenanceStatus,
|
||||
0x1E,WM10TempMessage,
|
||||
0x1E,HydrTemp,
|
||||
0x23,JunkersSetMixer,fetched
|
||||
0x27,UBASettingsWW,fetched
|
||||
0x28,WeatherComp,fetched
|
||||
@@ -72,11 +72,12 @@ telegram_type_id,name,is_fetched
|
||||
0xE6,UBAParametersPlus,fetched
|
||||
0xE9,UBAMonitorWWPlus,
|
||||
0xEA,UBAParameterWWPlus,fetched
|
||||
0xEB,PumpKick,fetched
|
||||
0x0101,ISM1Set,fetched
|
||||
0x0103,ISM1StatusMessage,fetched
|
||||
0x0104,ISM2StatusMessage,
|
||||
0x010C,IPMStatusMessage,
|
||||
0x011E,JunkersDisp,fetched
|
||||
0x011E,IPMTempMessage,
|
||||
0x012E,HPEnergy1,
|
||||
0x013B,HPEnergy2,
|
||||
0x0165,JunkersSet,
|
||||
@@ -111,8 +112,8 @@ telegram_type_id,name,is_fetched
|
||||
0x02A0,RC300Curves,
|
||||
0x02A1,RC300Curves,
|
||||
0x02A2,RC300Curves,
|
||||
0x02A5,RC300Monitor,
|
||||
0x02A6,RC300Monitor,
|
||||
0x02A5,RC300Monitor,fetched
|
||||
0x02A6,CRFMonitor,
|
||||
0x02A7,RC300Monitor,
|
||||
0x02A8,CRFMonitor,
|
||||
0x02A9,RC300Monitor,
|
||||
@@ -197,7 +198,7 @@ telegram_type_id,name,is_fetched
|
||||
0x04A2,HpInput,fetched
|
||||
0x04A5,HPFan,fetched
|
||||
0x04A7,HPPowerLimit,fetched
|
||||
0x04AA,HPPower2,fetched
|
||||
0x04AA,HPPower,
|
||||
0x04AE,HPEnergy,fetched
|
||||
0x04AF,HPMeters,fetched
|
||||
0x055C,VentilationSet,fetched
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"adapter": "react",
|
||||
"baseLocale": "pl",
|
||||
"$schema": "https://unpkg.com/typesafe-i18n@5.26.2/schema/typesafe-i18n.json"
|
||||
"$schema": "https://unpkg.com/typesafe-i18n@5.27.1/schema/typesafe-i18n.json"
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
// @ts-check
|
||||
import eslint from '@eslint/js';
|
||||
import prettierConfig from 'eslint-config-prettier';
|
||||
import { defineConfig } from 'eslint/config';
|
||||
import tseslint from 'typescript-eslint';
|
||||
|
||||
export default tseslint.config(
|
||||
export default defineConfig(
|
||||
eslint.configs.recommended,
|
||||
...tseslint.configs.recommendedTypeChecked,
|
||||
prettierConfig,
|
||||
|
||||
@@ -26,46 +26,45 @@
|
||||
"@alova/adapter-xhr": "2.3.1",
|
||||
"@emotion/react": "^11.14.0",
|
||||
"@emotion/styled": "^11.14.1",
|
||||
"@mui/icons-material": "^7.3.7",
|
||||
"@mui/material": "^7.3.7",
|
||||
"@preact/compat": "^18.3.1",
|
||||
"@mui/icons-material": "^7.3.9",
|
||||
"@mui/material": "^7.3.9",
|
||||
"@preact/compat": "^18.3.2",
|
||||
"@table-library/react-table-library": "4.1.15",
|
||||
"alova": "3.4.1",
|
||||
"alova": "^3.5.1",
|
||||
"async-validator": "^4.2.5",
|
||||
"etag": "^1.8.1",
|
||||
"formidable": "^3.5.4",
|
||||
"jwt-decode": "^4.0.0",
|
||||
"magic-string": "^0.30.21",
|
||||
"mime-types": "^3.0.2",
|
||||
"preact": "^10.28.2",
|
||||
"react": "^19.2.3",
|
||||
"react-dom": "^19.2.3",
|
||||
"react-icons": "^5.5.0",
|
||||
"react-router": "^7.12.0",
|
||||
"preact": "^10.29.0",
|
||||
"react": "^19.2.4",
|
||||
"react-dom": "^19.2.4",
|
||||
"react-icons": "^5.6.0",
|
||||
"react-router": "^7.13.1",
|
||||
"react-toastify": "^11.0.5",
|
||||
"typesafe-i18n": "^5.26.2",
|
||||
"typesafe-i18n": "^5.27.1",
|
||||
"typescript": "^5.9.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.28.5",
|
||||
"@eslint/js": "^9.39.2",
|
||||
"@preact/compat": "^18.3.1",
|
||||
"@preact/preset-vite": "^2.10.2",
|
||||
"@babel/core": "^7.29.0",
|
||||
"@eslint/js": "^10.0.1",
|
||||
"@preact/compat": "^18.3.2",
|
||||
"@preact/preset-vite": "^2.10.5",
|
||||
"@trivago/prettier-plugin-sort-imports": "^6.0.2",
|
||||
"@types/node": "^25.0.6",
|
||||
"@types/react": "^19.2.8",
|
||||
"@types/node": "^25.5.0",
|
||||
"@types/react": "^19.2.14",
|
||||
"@types/react-dom": "^19.2.3",
|
||||
"axe-core": "^4.11.1",
|
||||
"concurrently": "^9.2.1",
|
||||
"eslint": "^9.39.2",
|
||||
"eslint": "^10.1.0",
|
||||
"eslint-config-prettier": "^10.1.8",
|
||||
"prettier": "^3.7.4",
|
||||
"rollup-plugin-visualizer": "^6.0.5",
|
||||
"terser": "^5.44.1",
|
||||
"typescript-eslint": "^8.52.0",
|
||||
"vite": "^7.3.1",
|
||||
"vite-plugin-imagemin": "^0.6.1",
|
||||
"vite-tsconfig-paths": "^6.0.4"
|
||||
"prettier": "^3.8.1",
|
||||
"rollup-plugin-visualizer": "^7.0.1",
|
||||
"terser": "^5.46.1",
|
||||
"typescript-eslint": "^8.57.1",
|
||||
"vite": "^8.0.1",
|
||||
"vite-plugin-imagemin": "^0.6.1"
|
||||
},
|
||||
"packageManager": "pnpm@10.28.0+sha512.05df71d1421f21399e053fde567cea34d446fa02c76571441bfc1c7956e98e363088982d940465fd34480d4d90a0668bc12362f8aa88000a64e83d0b0e47be48"
|
||||
"packageManager": "pnpm@10.32.1+sha512.a706938f0e89ac1456b6563eab4edf1d1faf3368d1191fc5c59790e96dc918e4456ab2e67d613de1043d2e8c81f87303e6b40d4ffeca9df15ef1ad567348f2be"
|
||||
}
|
||||
|
||||
2316
interface/pnpm-lock.yaml
generated
2316
interface/pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -310,13 +310,15 @@ const CustomEntities = () => {
|
||||
/>
|
||||
)}
|
||||
</Cell>
|
||||
<Cell>{ei.ram > 0 ? '' : showHex(ei.device_id as number, 2)}</Cell>
|
||||
<Cell>{ei.ram > 0 ? '' : showHex(ei.type_id as number, 3)}</Cell>
|
||||
<Cell>{ei.ram > 0 ? '' : ei.offset}</Cell>
|
||||
<Cell>
|
||||
{ei.ram === 1 ? '' : showHex(ei.device_id as number, 2)}
|
||||
</Cell>
|
||||
<Cell>{ei.ram === 1 ? '' : showHex(ei.type_id as number, 3)}</Cell>
|
||||
<Cell>{ei.ram === 1 ? '' : ei.offset}</Cell>
|
||||
<Cell>
|
||||
{ei.ram === 1 ? 'RAM' : DeviceValueTypeNames[ei.value_type]}
|
||||
{ei.ram === 1
|
||||
? 'RAM'
|
||||
: ei.ram === 2
|
||||
? 'NVS'
|
||||
: DeviceValueTypeNames[ei.value_type]}
|
||||
</Cell>
|
||||
<Cell>{formatValue(ei.value, ei.uom)}</Cell>
|
||||
</Row>
|
||||
|
||||
@@ -205,9 +205,10 @@ const CustomEntitiesDialog = ({
|
||||
>
|
||||
<MenuItem value={0}>EMS-{LL.VALUE(1)}</MenuItem>
|
||||
<MenuItem value={1}>RAM-{LL.VALUE(1)}</MenuItem>
|
||||
<MenuItem value={2}>NVS-{LL.VALUE(1)}</MenuItem>
|
||||
</TextField>
|
||||
</Grid>
|
||||
{editItem.ram === 1 && (
|
||||
{editItem.ram > 0 && (
|
||||
<>
|
||||
<Grid>
|
||||
<TextField
|
||||
|
||||
@@ -111,13 +111,14 @@ const Customizations = () => {
|
||||
const [selectedDeviceTypeNameURL, setSelectedDeviceTypeNameURL] =
|
||||
useState<string>(''); // needed for API URL
|
||||
const [selectedDeviceName, setSelectedDeviceName] = useState<string>('');
|
||||
const [selectedDeviceBrand, setSelectedDeviceBrand] = useState<string>('');
|
||||
|
||||
const { send: sendResetCustomizations } = useRequest(resetCustomizations(), {
|
||||
immediate: false
|
||||
});
|
||||
|
||||
const { send: sendDeviceName } = useRequest(
|
||||
(data: { id: number; name: string }) => writeDeviceName(data),
|
||||
(data: { id: number; name: string; brand: string }) => writeDeviceName(data),
|
||||
{
|
||||
immediate: false
|
||||
}
|
||||
@@ -267,6 +268,7 @@ const Customizations = () => {
|
||||
if (device) {
|
||||
setSelectedDeviceTypeNameURL(device.url || '');
|
||||
setSelectedDeviceName(device.n);
|
||||
setSelectedDeviceBrand(device.b);
|
||||
}
|
||||
setNumChanges(0);
|
||||
setRestartNeeded(false);
|
||||
@@ -442,7 +444,11 @@ const Customizations = () => {
|
||||
}, [devices, deviceEntities, selectedDevice, sendCustomizationEntities, LL]);
|
||||
|
||||
const renameDevice = useCallback(async () => {
|
||||
await sendDeviceName({ id: selectedDevice, name: selectedDeviceName })
|
||||
await sendDeviceName({
|
||||
id: selectedDevice,
|
||||
name: selectedDeviceName,
|
||||
brand: selectedDeviceBrand
|
||||
})
|
||||
.then(() => {
|
||||
toast.success(LL.UPDATED_OF(LL.NAME(1)));
|
||||
})
|
||||
@@ -453,7 +459,14 @@ const Customizations = () => {
|
||||
setRename(false);
|
||||
await fetchCoreData();
|
||||
});
|
||||
}, [selectedDevice, selectedDeviceName, sendDeviceName, LL, fetchCoreData]);
|
||||
}, [
|
||||
selectedDevice,
|
||||
selectedDeviceName,
|
||||
selectedDeviceBrand,
|
||||
sendDeviceName,
|
||||
LL,
|
||||
fetchCoreData
|
||||
]);
|
||||
|
||||
const renderDeviceList = () => (
|
||||
<>
|
||||
@@ -462,15 +475,26 @@ const Customizations = () => {
|
||||
</Box>
|
||||
<Box display="flex" flexWrap="wrap" alignItems="center" gap={2}>
|
||||
{rename ? (
|
||||
<TextField
|
||||
name="device"
|
||||
label={LL.EMS_DEVICE()}
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
value={selectedDeviceName}
|
||||
onChange={(e) => setSelectedDeviceName(e.target.value)}
|
||||
margin="normal"
|
||||
/>
|
||||
<>
|
||||
<TextField
|
||||
name="device"
|
||||
label={LL.EMS_DEVICE()}
|
||||
style={{ minWidth: '48%' }}
|
||||
variant="outlined"
|
||||
value={selectedDeviceName}
|
||||
onChange={(e) => setSelectedDeviceName(e.target.value)}
|
||||
margin="normal"
|
||||
/>
|
||||
<TextField
|
||||
name="brand"
|
||||
label={LL.BRAND()}
|
||||
style={{ minWidth: '48%' }}
|
||||
variant="outlined"
|
||||
value={selectedDeviceBrand}
|
||||
onChange={(e) => setSelectedDeviceBrand(e.target.value)}
|
||||
margin="normal"
|
||||
/>
|
||||
</>
|
||||
) : (
|
||||
<TextField
|
||||
name="device"
|
||||
|
||||
@@ -263,7 +263,17 @@ const Dashboard = memo(() => {
|
||||
return (
|
||||
<>
|
||||
{!data.connected && (
|
||||
<MessageBox level="error" message={LL.EMS_BUS_WARNING()} />
|
||||
<MessageBox level="error" message={LL.EMS_BUS_WARNING() + '.'}>
|
||||
(
|
||||
<Link
|
||||
target="_blank"
|
||||
to="https://docs.emsesp.org/Troubleshooting#ems-bus-is-not-connecting"
|
||||
style={{ color: 'white' }}
|
||||
>
|
||||
{LL.ONLINE_HELP()}
|
||||
</Link>
|
||||
)
|
||||
</MessageBox>
|
||||
)}
|
||||
|
||||
{data.connected && data.nodes.length > 0 && !hasFavEntities && (
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
useState
|
||||
} from 'react';
|
||||
import { IconContext } from 'react-icons';
|
||||
import { useNavigate } from 'react-router';
|
||||
import { Link, useNavigate } from 'react-router';
|
||||
import { toast } from 'react-toastify';
|
||||
|
||||
import CommentsDisabledOutlinedIcon from '@mui/icons-material/CommentsDisabledOutlined';
|
||||
@@ -534,7 +534,17 @@ const Devices = memo(() => {
|
||||
const renderCoreData = () => (
|
||||
<>
|
||||
{!coreData.connected ? (
|
||||
<MessageBox level="error" message={LL.EMS_BUS_WARNING()} />
|
||||
<MessageBox level="error" message={LL.EMS_BUS_WARNING() + '.'}>
|
||||
(
|
||||
<Link
|
||||
target="_blank"
|
||||
to="https://docs.emsesp.org/Troubleshooting#ems-bus-is-not-connecting"
|
||||
style={{ color: 'white' }}
|
||||
>
|
||||
{LL.ONLINE_HELP()}
|
||||
</Link>
|
||||
)
|
||||
</MessageBox>
|
||||
) : (
|
||||
<Box justifyContent="center" flexDirection="column">
|
||||
<IconContext.Provider
|
||||
|
||||
@@ -120,7 +120,7 @@ const HelpComponent = () => {
|
||||
label: () => LL.HELP_INFORMATION_1()
|
||||
},
|
||||
{
|
||||
href: 'https://discord.gg/3J3GgnzpyT',
|
||||
href: 'https://discord.gg/GP9DPSgeJq',
|
||||
icon: <CommentIcon />,
|
||||
label: () => LL.HELP_INFORMATION_2()
|
||||
},
|
||||
|
||||
@@ -43,6 +43,16 @@ export interface Settings {
|
||||
modbus_port: number;
|
||||
modbus_max_clients: number;
|
||||
modbus_timeout: number;
|
||||
email_enabled: boolean;
|
||||
email_ssl?: boolean;
|
||||
email_starttls?: boolean;
|
||||
email_server: string;
|
||||
email_port: number;
|
||||
email_login: string;
|
||||
email_pass: string;
|
||||
email_sender: string;
|
||||
email_recp: string;
|
||||
email_subject: string;
|
||||
developer_mode: boolean;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ import {
|
||||
FormLoader,
|
||||
MessageBox,
|
||||
SectionContent,
|
||||
ValidatedPasswordField,
|
||||
ValidatedTextField,
|
||||
useLayoutTitle
|
||||
} from 'components';
|
||||
@@ -351,6 +352,156 @@ const ApplicationSettings = () => {
|
||||
</Grid>
|
||||
</Grid>
|
||||
)}
|
||||
<Typography color="secondary">eMail</Typography>
|
||||
<BlockFormControlLabel
|
||||
control={
|
||||
<Checkbox
|
||||
checked={data.email_enabled}
|
||||
onChange={updateFormValue}
|
||||
name="email_enabled"
|
||||
disabled={!hardwareData.psram}
|
||||
/>
|
||||
}
|
||||
label={
|
||||
<Typography color={!hardwareData.psram ? 'grey' : 'default'}>
|
||||
Enable eMail notification
|
||||
{!hardwareData.psram && (
|
||||
<Typography variant="caption">
|
||||
({LL.IS_REQUIRED('PSRAM')})
|
||||
</Typography>
|
||||
)}
|
||||
</Typography>
|
||||
}
|
||||
/>
|
||||
{data.email_enabled && (
|
||||
<>
|
||||
<Grid
|
||||
container
|
||||
spacing={2}
|
||||
direction="row"
|
||||
justifyContent="flex-start"
|
||||
alignItems="flex-start"
|
||||
>
|
||||
<Grid>
|
||||
<ValidatedTextField
|
||||
fieldErrors={fieldErrors || {}}
|
||||
name="email_server"
|
||||
label="SMTP Server"
|
||||
variant="outlined"
|
||||
value={data.email_server}
|
||||
onChange={updateFormValue}
|
||||
margin="normal"
|
||||
/>
|
||||
</Grid>
|
||||
<Grid>
|
||||
<ValidatedTextField
|
||||
fieldErrors={fieldErrors || {}}
|
||||
sx={{ width: '12ch' }}
|
||||
name="email_port"
|
||||
variant="outlined"
|
||||
label="Port"
|
||||
value={numberValue(data.email_port)}
|
||||
type="number"
|
||||
onChange={updateFormValue}
|
||||
margin="normal"
|
||||
/>
|
||||
</Grid>
|
||||
<Grid size={4} mt={!data.email_ssl && !data.email_starttls ? 0 : 3}>
|
||||
{!data.email_starttls && (
|
||||
<BlockFormControlLabel
|
||||
sx={{ width: '12ch' }}
|
||||
control={
|
||||
<Checkbox
|
||||
checked={data.email_ssl}
|
||||
onChange={updateFormValue}
|
||||
name="email_ssl"
|
||||
disabled={
|
||||
data.email_starttls || data.email_ssl === undefined
|
||||
}
|
||||
/>
|
||||
}
|
||||
label="SSL/TLS"
|
||||
/>
|
||||
)}
|
||||
{!data.email_ssl && (
|
||||
<BlockFormControlLabel
|
||||
sx={{ width: '12ch' }}
|
||||
control={
|
||||
<Checkbox
|
||||
checked={data.email_starttls}
|
||||
onChange={updateFormValue}
|
||||
name="email_starttls"
|
||||
disabled={
|
||||
data.email_ssl || data.email_starttls === undefined
|
||||
}
|
||||
/>
|
||||
}
|
||||
label="STARTTLS"
|
||||
/>
|
||||
)}
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid container spacing={2} rowSpacing={0}>
|
||||
<Grid>
|
||||
<ValidatedTextField
|
||||
fieldErrors={fieldErrors || {}}
|
||||
name="email_login"
|
||||
label="Login"
|
||||
variant="outlined"
|
||||
value={data.email_login}
|
||||
onChange={updateFormValue}
|
||||
margin="normal"
|
||||
/>
|
||||
</Grid>
|
||||
<Grid>
|
||||
<ValidatedPasswordField
|
||||
fieldErrors={fieldErrors || {}}
|
||||
name="email_pass"
|
||||
label="Password"
|
||||
variant="outlined"
|
||||
value={data.email_pass}
|
||||
onChange={updateFormValue}
|
||||
margin="normal"
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid container spacing={2} rowSpacing={0}>
|
||||
<Grid>
|
||||
<ValidatedTextField
|
||||
fieldErrors={fieldErrors || {}}
|
||||
name="email_sender"
|
||||
label="From"
|
||||
variant="outlined"
|
||||
value={data.email_sender}
|
||||
onChange={updateFormValue}
|
||||
margin="normal"
|
||||
/>
|
||||
</Grid>
|
||||
<Grid>
|
||||
<ValidatedTextField
|
||||
fieldErrors={fieldErrors || {}}
|
||||
name="email_recp"
|
||||
label="To"
|
||||
variant="outlined"
|
||||
value={data.email_recp}
|
||||
onChange={updateFormValue}
|
||||
margin="normal"
|
||||
/>
|
||||
</Grid>
|
||||
<Grid>
|
||||
<ValidatedTextField
|
||||
fieldErrors={fieldErrors || {}}
|
||||
name="email_subject"
|
||||
label="Subject"
|
||||
variant="outlined"
|
||||
value={data.email_subject}
|
||||
onChange={updateFormValue}
|
||||
margin="normal"
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</>
|
||||
)}
|
||||
<Typography sx={{ pb: 1, pt: 2 }} variant="h6" color="primary">
|
||||
{LL.SENSORS()}
|
||||
</Typography>
|
||||
|
||||
@@ -20,7 +20,6 @@ import { useI18nContext } from 'i18n/i18n-react';
|
||||
import { saveFile } from 'utils';
|
||||
|
||||
interface DownloadButton {
|
||||
key: string;
|
||||
type: string;
|
||||
label: string | number;
|
||||
isGridButton: boolean;
|
||||
@@ -66,31 +65,31 @@ const DownloadUpload = () => {
|
||||
const downloadButtons: DownloadButton[] = useMemo(
|
||||
() => [
|
||||
{
|
||||
key: 'settings',
|
||||
type: 'settings',
|
||||
label: LL.SETTINGS_OF(LL.APPLICATION()),
|
||||
isGridButton: true
|
||||
},
|
||||
{
|
||||
key: 'customizations',
|
||||
type: 'customizations',
|
||||
label: LL.CUSTOMIZATIONS(),
|
||||
isGridButton: true
|
||||
},
|
||||
{
|
||||
key: 'entities',
|
||||
type: 'entities',
|
||||
label: LL.CUSTOM_ENTITIES(0),
|
||||
isGridButton: true
|
||||
},
|
||||
{
|
||||
key: 'schedule',
|
||||
type: 'schedule',
|
||||
label: LL.SCHEDULE(0),
|
||||
isGridButton: true
|
||||
},
|
||||
{
|
||||
key: 'allvalues',
|
||||
type: 'systembackup',
|
||||
label: LL.DOWNLOAD_SYSTEM_BACKUP(),
|
||||
isGridButton: true
|
||||
},
|
||||
{
|
||||
type: 'allvalues',
|
||||
label: LL.ALLVALUES(),
|
||||
isGridButton: false
|
||||
@@ -133,7 +132,7 @@ const DownloadUpload = () => {
|
||||
|
||||
<Grid container spacing={2}>
|
||||
{gridButtons.map((button) => (
|
||||
<Grid key={button.key}>
|
||||
<Grid key={button.type}>
|
||||
<Button
|
||||
startIcon={<DownloadIcon />}
|
||||
variant="outlined"
|
||||
|
||||
@@ -38,8 +38,6 @@ import type { LogEntry, LogSettings } from 'types';
|
||||
import { LogLevel } from 'types';
|
||||
import { updateValueDirty, useRest } from 'utils';
|
||||
|
||||
const MAX_LOG_ENTRIES = 1000; // Limit log entries to prevent memory issues
|
||||
|
||||
const TextColors: Record<LogLevel, string> = {
|
||||
[LogLevel.ERROR]: '#ff0000', // red
|
||||
[LogLevel.WARNING]: '#ff0000', // red
|
||||
@@ -200,10 +198,6 @@ const SystemLog = () => {
|
||||
}
|
||||
}
|
||||
const newLog = [...log, logentry];
|
||||
// Limit log entries to prevent memory issues - only slice when necessary
|
||||
if (newLog.length > MAX_LOG_ENTRIES) {
|
||||
return newLog.slice(-MAX_LOG_ENTRIES);
|
||||
}
|
||||
return newLog;
|
||||
});
|
||||
}, []);
|
||||
@@ -308,6 +302,8 @@ const SystemLog = () => {
|
||||
<MenuItem value={50}>50</MenuItem>
|
||||
<MenuItem value={75}>75</MenuItem>
|
||||
<MenuItem value={100}>100</MenuItem>
|
||||
<MenuItem value={500}>500</MenuItem>
|
||||
<MenuItem value={1000}>1000</MenuItem>
|
||||
</TextField>
|
||||
</Grid>
|
||||
)}
|
||||
|
||||
@@ -60,18 +60,16 @@ const SystemMonitor = () => {
|
||||
const { statusMessage, isUploading, progressValue } = useMemo(() => {
|
||||
const status = data?.status;
|
||||
|
||||
let message = '';
|
||||
if (status && status >= SystemStatusCodes.SYSTEM_STATUS_UPLOADING) {
|
||||
message = LL.WAIT_FIRMWARE();
|
||||
} else if (status === SystemStatusCodes.SYSTEM_STATUS_PENDING_RESTART) {
|
||||
message = LL.APPLICATION_RESTARTING();
|
||||
} else if (status === SystemStatusCodes.SYSTEM_STATUS_NORMAL) {
|
||||
message = LL.RESTARTING_PRE();
|
||||
} else if (status === SystemStatusCodes.SYSTEM_STATUS_ERROR_UPLOAD) {
|
||||
message = 'Upload Failed';
|
||||
} else {
|
||||
message = LL.RESTARTING_POST();
|
||||
}
|
||||
const message =
|
||||
status && status >= SystemStatusCodes.SYSTEM_STATUS_UPLOADING
|
||||
? LL.WAIT_FIRMWARE()
|
||||
: status === SystemStatusCodes.SYSTEM_STATUS_PENDING_RESTART
|
||||
? LL.APPLICATION_RESTARTING()
|
||||
: status === SystemStatusCodes.SYSTEM_STATUS_NORMAL
|
||||
? LL.RESTARTING_PRE()
|
||||
: status === SystemStatusCodes.SYSTEM_STATUS_ERROR_UPLOAD
|
||||
? 'Upload Failed'
|
||||
: LL.RESTARTING_POST();
|
||||
|
||||
const uploading =
|
||||
status !== undefined && status >= SystemStatusCodes.SYSTEM_STATUS_UPLOADING;
|
||||
|
||||
@@ -274,7 +274,6 @@ const InstallDialog = memo(
|
||||
fetchDevVersion,
|
||||
latestVersion,
|
||||
latestDevVersion,
|
||||
downloadOnly,
|
||||
platform,
|
||||
LL,
|
||||
onClose,
|
||||
@@ -284,7 +283,6 @@ const InstallDialog = memo(
|
||||
fetchDevVersion: boolean;
|
||||
latestVersion?: VersionInfo;
|
||||
latestDevVersion?: VersionInfo;
|
||||
downloadOnly: boolean;
|
||||
platform: string;
|
||||
LL: TranslationFunctions;
|
||||
onClose: () => void;
|
||||
@@ -309,7 +307,7 @@ const InstallDialog = memo(
|
||||
<DialogContent dividers>
|
||||
<Typography mb={2}>
|
||||
{LL.INSTALL_VERSION(
|
||||
downloadOnly ? LL.DOWNLOAD(1) : LL.INSTALL(),
|
||||
LL.INSTALL(),
|
||||
fetchDevVersion ? latestDevVersion?.name : latestVersion?.name
|
||||
)}
|
||||
</Typography>
|
||||
@@ -333,16 +331,14 @@ const InstallDialog = memo(
|
||||
{LL.DOWNLOAD(0)}
|
||||
</Link>
|
||||
</Button>
|
||||
{!downloadOnly && (
|
||||
<Button
|
||||
startIcon={<WarningIcon color="warning" />}
|
||||
variant="outlined"
|
||||
onClick={() => onInstall(binURL)}
|
||||
color="primary"
|
||||
>
|
||||
{LL.INSTALL()}
|
||||
</Button>
|
||||
)}
|
||||
<Button
|
||||
startIcon={<WarningIcon color="warning" />}
|
||||
variant="outlined"
|
||||
onClick={() => onInstall(binURL)}
|
||||
color="primary"
|
||||
>
|
||||
{LL.INSTALL()}
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
);
|
||||
@@ -423,7 +419,6 @@ const Version = () => {
|
||||
const [stableUpgradeAvailable, setStableUpgradeAvailable] =
|
||||
useState<boolean>(false);
|
||||
const [internetLive, setInternetLive] = useState<boolean>(false);
|
||||
const [downloadOnly, setDownloadOnly] = useState<boolean>(false);
|
||||
const [showVersionInfo, setShowVersionInfo] = useState<number>(0); // 1 = stable, 2 = dev, 3 = partition
|
||||
const [firmwareSize, setFirmwareSize] = useState<number>(0);
|
||||
|
||||
@@ -449,9 +444,6 @@ const Version = () => {
|
||||
error
|
||||
} = useRequest(SystemApi.readSystemStatus).onSuccess((event) => {
|
||||
const systemData = event.data as VersionData;
|
||||
if (systemData.arduino_version.startsWith('Tasmota')) {
|
||||
setDownloadOnly(true);
|
||||
}
|
||||
setUsingDevVersion(systemData.emsesp_version.includes('dev'));
|
||||
});
|
||||
|
||||
@@ -815,7 +807,6 @@ const Version = () => {
|
||||
fetchDevVersion={fetchDevVersion}
|
||||
latestVersion={latestVersion}
|
||||
latestDevVersion={latestDevVersion}
|
||||
downloadOnly={downloadOnly}
|
||||
platform={platform}
|
||||
LL={LL}
|
||||
onClose={closeInstallDialog}
|
||||
@@ -851,7 +842,6 @@ const Version = () => {
|
||||
locale,
|
||||
openInstallDialog,
|
||||
fetchDevVersion,
|
||||
downloadOnly,
|
||||
me.admin,
|
||||
showButtons,
|
||||
handleVersionInfoClose,
|
||||
|
||||
@@ -186,7 +186,8 @@ const cz: Translation = {
|
||||
BUFFER_SIZE: 'Maximální velikost vyrovnávací paměti',
|
||||
COMPACT: 'Kompaktní',
|
||||
DOWNLOAD_SETTINGS_TEXT: 'Vytvořte zálohu svého nastavení a konfigurace',
|
||||
DOWNLOAD_SETTINGS_TEXT2: 'Exportovat všechna data',
|
||||
DOWNLOAD_SETTINGS_TEXT2: 'Exportovat všechny hodnoty',
|
||||
DOWNLOAD_SYSTEM_BACKUP: 'Systémová záloha',
|
||||
UPLOAD_TEXT: 'Nahrajte nový soubor firmwaru (.bin) nebo záložní soubor (.json)',
|
||||
UPLOAD_DROP_TEXT: 'Přetáhněte soubor sem nebo klikněte pro výběr',
|
||||
ERROR: 'Neočekávaná chyba, zkuste to prosím znovu',
|
||||
@@ -357,7 +358,8 @@ const cz: Translation = {
|
||||
FIRMWARE_VERSION_INFO: 'Informace o verzi firmwaru',
|
||||
NO_DATA: 'Žádná data',
|
||||
USER_PROFILE: 'Uživatelský profil',
|
||||
STORED_VERSIONS: 'Uložené verze'
|
||||
STORED_VERSIONS: 'Uložené verze',
|
||||
ONLINE_HELP: 'online nápověda'
|
||||
};
|
||||
|
||||
export default cz;
|
||||
|
||||
@@ -186,7 +186,8 @@ const de: Translation = {
|
||||
BUFFER_SIZE: 'Max. Puffergröße',
|
||||
COMPACT: 'Kompakte Darstellung',
|
||||
DOWNLOAD_SETTINGS_TEXT: 'Erstellen Sie eine Sicherung Ihrer Konfigurationen und Einstellungen',
|
||||
DOWNLOAD_SETTINGS_TEXT2: 'Exportiere alle Daten',
|
||||
DOWNLOAD_SETTINGS_TEXT2: 'Exportiere alle Werte',
|
||||
DOWNLOAD_SYSTEM_BACKUP: 'System Sicherung',
|
||||
UPLOAD_TEXT: 'Laden Sie eine neue Firmware-Datei (.bin) oder eine Sicherungsdatei (.json) hoch',
|
||||
UPLOAD_DROP_TEXT: 'Legen Sie eine Firmware-Datei (.bin) ab oder klicken Sie hier',
|
||||
ERROR: 'Unerwarteter Fehler, bitte versuchen Sie es erneut.',
|
||||
@@ -357,7 +358,8 @@ const de: Translation = {
|
||||
FIRMWARE_VERSION_INFO: 'Firmware-Versionsinformation',
|
||||
NO_DATA: 'Keine Daten',
|
||||
USER_PROFILE: 'Benutzerprofil',
|
||||
STORED_VERSIONS: 'Gespeicherte Versionen'
|
||||
STORED_VERSIONS: 'Gespeicherte Versionen',
|
||||
ONLINE_HELP: 'Online-Hilfe'
|
||||
};
|
||||
|
||||
export default de;
|
||||
|
||||
@@ -186,7 +186,8 @@ const en: Translation = {
|
||||
BUFFER_SIZE: 'Max Buffer Size',
|
||||
COMPACT: 'Compact',
|
||||
DOWNLOAD_SETTINGS_TEXT: 'Create a backup of your configuration and settings',
|
||||
DOWNLOAD_SETTINGS_TEXT2: 'Export all data',
|
||||
DOWNLOAD_SETTINGS_TEXT2: 'Export all values',
|
||||
DOWNLOAD_SYSTEM_BACKUP: 'System Backup',
|
||||
UPLOAD_TEXT: 'Upload a new firmware file (.bin) or a backup file (.json)',
|
||||
UPLOAD_DROP_TEXT: 'Drop a firmware .bin file or click here',
|
||||
ERROR: 'Unexpected Error, please try again',
|
||||
@@ -357,7 +358,8 @@ const en: Translation = {
|
||||
FIRMWARE_VERSION_INFO: 'Firmware Version Information',
|
||||
NO_DATA: 'No data',
|
||||
USER_PROFILE: 'User Profile',
|
||||
STORED_VERSIONS: 'Stored Versions'
|
||||
STORED_VERSIONS: 'Stored Versions',
|
||||
ONLINE_HELP: 'online help'
|
||||
};
|
||||
|
||||
export default en;
|
||||
|
||||
@@ -186,7 +186,8 @@ const fr: Translation = {
|
||||
BUFFER_SIZE: 'Max taille du buffer',
|
||||
COMPACT: 'Compact',
|
||||
DOWNLOAD_SETTINGS_TEXT: 'Créer une sauvegarde de vos paramètres et configurations',
|
||||
DOWNLOAD_SETTINGS_TEXT2: 'Exporter toutes les données',
|
||||
DOWNLOAD_SETTINGS_TEXT2: 'Exporter toutes les valeurs',
|
||||
DOWNLOAD_SYSTEM_BACKUP: 'Sauvegarde système',
|
||||
UPLOAD_TEXT: 'Télécharger un nouveau fichier firmware (.bin) ou une sauvegarde (.json)',
|
||||
UPLOAD_DROP_TEXT: 'Drop a firmware .bin file or click here',
|
||||
ERROR: 'Erreur inattendue, veuillez réessayer',
|
||||
@@ -357,7 +358,8 @@ const fr: Translation = {
|
||||
FIRMWARE_VERSION_INFO: 'Informations sur la version du firmware',
|
||||
NO_DATA: 'Aucune donnée',
|
||||
USER_PROFILE: 'Profil utilisateur',
|
||||
STORED_VERSIONS: 'Versions stockées'
|
||||
STORED_VERSIONS: 'Versions stockées',
|
||||
ONLINE_HELP: 'aide en ligne'
|
||||
};
|
||||
|
||||
export default fr;
|
||||
|
||||
@@ -186,7 +186,8 @@ const it: Translation = {
|
||||
BUFFER_SIZE: 'Max Buffer Size',
|
||||
COMPACT: 'Compatto',
|
||||
DOWNLOAD_SETTINGS_TEXT: 'Create a backup of your configuration and settings',
|
||||
DOWNLOAD_SETTINGS_TEXT2: 'Esporta tutti i dati',
|
||||
DOWNLOAD_SETTINGS_TEXT2: 'Esporta tutti i valori',
|
||||
DOWNLOAD_SYSTEM_BACKUP: 'Backup sistema',
|
||||
UPLOAD_TEXT: 'Upload a new firmware file (.bin) or a backup file (.json)',
|
||||
UPLOAD_DROP_TEXT: 'Drop a firmware .bin file or click here',
|
||||
ERROR: 'Errore Inaspettato, prego tenta ancora',
|
||||
@@ -357,7 +358,8 @@ const it: Translation = {
|
||||
FIRMWARE_VERSION_INFO: 'Informazioni sulla versione del firmware',
|
||||
NO_DATA: 'Nessun dato',
|
||||
USER_PROFILE: 'Profilo utente',
|
||||
STORED_VERSIONS: 'Versioni memorizzate'
|
||||
STORED_VERSIONS: 'Versioni memorizzate',
|
||||
ONLINE_HELP: 'aiuto online'
|
||||
};
|
||||
|
||||
export default it;
|
||||
|
||||
@@ -27,7 +27,7 @@ const nl: Translation = {
|
||||
REFRESH: 'Ververs',
|
||||
EXPORT: 'Export',
|
||||
FAVORITES: "Favorieten",
|
||||
DEVICE_DETAILS: 'Device Gegevens',
|
||||
DEVICE_DETAILS: 'Apparaat Gegevens',
|
||||
ID_OF: '{0} ID',
|
||||
DEVICE: 'Apparaat',
|
||||
PRODUCT: 'Product',
|
||||
@@ -65,7 +65,7 @@ const nl: Translation = {
|
||||
TEMP_SENSOR: 'Temperatuur sensor',
|
||||
TEMP_SENSORS: 'Temperatuur Sensoren',
|
||||
WRITE_CMD_SENT: 'Schrijf commando gestuurd',
|
||||
EMS_BUS_WARNING: 'EMS bus niet gevonden. Als deze waarschuwing blijft staan na een paar seconden dan loop de instellingen na en in het bijzonder het apparaat type profiel na.',
|
||||
EMS_BUS_WARNING: 'EMS bus niet gevonden. Als deze waarschuwing blijft staan na een paar seconden loop dan de instellingen na en in het bijzonder het apparaat type profiel.',
|
||||
EMS_BUS_SCANNING: 'Scannen naar EMS apparaten...',
|
||||
CONNECTED: 'Verbonden',
|
||||
TX_ISSUES: 'Tx bus probleem. Probeer een andere Tx verzendmodus',
|
||||
@@ -75,7 +75,7 @@ const nl: Translation = {
|
||||
EMS_DEVICE: 'EMS Apparaat',
|
||||
SUCCESS: 'SUCCESS',
|
||||
FAIL: 'MISLUKT',
|
||||
QUALITY: 'QUALITEIT',
|
||||
QUALITY: 'KWALITEIT',
|
||||
SCAN: 'Scan',
|
||||
STATUS_NAMES: [
|
||||
'EMS Telegrammen ontvangen (Rx)',
|
||||
@@ -120,7 +120,7 @@ const nl: Translation = {
|
||||
ENABLE_SHOWER_TIMER: 'Activeer Douche Timer (tijdmeting)',
|
||||
ENABLE_SHOWER_ALERT: 'Activeer Douchemelding',
|
||||
TRIGGER_TIME: 'Trigger tijd',
|
||||
COLD_SHOT_DURATION: 'Tijd Shot koud water',
|
||||
COLD_SHOT_DURATION: 'Lengte koud water puls',
|
||||
FORMATTING_OPTIONS: 'Formatteringsopties',
|
||||
BOOLEAN_FORMAT_DASHBOARD: 'Boolean formaat web',
|
||||
BOOLEAN_FORMAT_API: 'Boolean formaat API/MQTT',
|
||||
@@ -143,7 +143,7 @@ const nl: Translation = {
|
||||
CUSTOMIZATIONS_FULL: 'Te veel entiteiten geselecteerd. Sla op in delen aub',
|
||||
CUSTOMIZATIONS_SAVED: 'Custom aanpassingen opgeslagen',
|
||||
CUSTOMIZATIONS_HELP_1: 'Selecteer een apparaat en pas de entiteiten aan door middel van de opties',
|
||||
CUSTOMIZATIONS_HELP_2: 'Markeer as favoriet',
|
||||
CUSTOMIZATIONS_HELP_2: 'Markeer als favoriet',
|
||||
CUSTOMIZATIONS_HELP_3: 'Zet schrijfacties uit',
|
||||
CUSTOMIZATIONS_HELP_4: 'Uitsluiten van MQTT en API',
|
||||
CUSTOMIZATIONS_HELP_5: 'verbergen voor apparaten',
|
||||
@@ -186,12 +186,13 @@ const nl: Translation = {
|
||||
BUFFER_SIZE: 'Max buffer grootte',
|
||||
COMPACT: 'Compact',
|
||||
DOWNLOAD_SETTINGS_TEXT: 'Maak een back-up van uw configuratie en instellingen',
|
||||
DOWNLOAD_SETTINGS_TEXT2: 'Exporteer alle data',
|
||||
DOWNLOAD_SETTINGS_TEXT2: 'Exporteer alle waarden',
|
||||
DOWNLOAD_SYSTEM_BACKUP: 'Systeem Backup',
|
||||
UPLOAD_TEXT: 'Upload een nieuw firmwarebestand (.bin) of een back-upbestand (.json)',
|
||||
UPLOAD_DROP_TEXT: 'Sleep en firmware .bin bestand hierheen of klik hier',
|
||||
ERROR: 'Onverwachte fout, probeer opnieuw',
|
||||
TIME_SET: 'Tijd ingesteld',
|
||||
MANAGE_USERS: 'Beheer Gebruikers',
|
||||
MANAGE_USERS: 'Gebruikersbeheer',
|
||||
IS_ADMIN: 'is Admin',
|
||||
USER_WARNING: 'U dient tenminste 1 admin gebruiker te configureren',
|
||||
ADD: 'Toevoegen',
|
||||
@@ -200,7 +201,7 @@ const nl: Translation = {
|
||||
GENERATING_TOKEN: 'Token aan het genereren',
|
||||
USER: 'Gebruiker',
|
||||
MODIFY: 'Aanpassen',
|
||||
SU_TEXT: 'Het su (super user) wachtwoord wordt gebruikt om authorisatie tokens te signeren en ook om admin privileges te activeren in de console.',
|
||||
SU_TEXT: 'Het su (super user) wachtwoord wordt gebruikt om authorisatie tokens te ondertekenen en ook om admin privileges te activeren in de console.',
|
||||
NOT_ENABLED: 'Niet geactiveerd',
|
||||
ERRORS_OF: '{0} Foutmeldingen',
|
||||
DISCONNECT_REASON: 'Verbinding verbroken vanwege',
|
||||
@@ -357,7 +358,8 @@ const nl: Translation = {
|
||||
FIRMWARE_VERSION_INFO: 'Informatie over firmwareversie',
|
||||
NO_DATA: 'Geen data',
|
||||
USER_PROFILE: 'Gebruikersprofiel',
|
||||
STORED_VERSIONS: 'Opgeslagen versies'
|
||||
STORED_VERSIONS: 'Opgeslagen versies',
|
||||
ONLINE_HELP: 'online help'
|
||||
};
|
||||
|
||||
export default nl;
|
||||
export default nl;
|
||||
|
||||
@@ -186,7 +186,8 @@ const no: Translation = {
|
||||
BUFFER_SIZE: 'Max Buffer Størrelse',
|
||||
COMPACT: 'Komprimere',
|
||||
DOWNLOAD_SETTINGS_TEXT: 'Lag en sikkerhetskopi av dine konfigurasjon og innstillinger',
|
||||
DOWNLOAD_SETTINGS_TEXT2: 'Eksporter alle data',
|
||||
DOWNLOAD_SETTINGS_TEXT2: 'Eksporter alle verdier',
|
||||
DOWNLOAD_SYSTEM_BACKUP: 'System Sikkerhetskopi',
|
||||
UPLOAD_TEXT: 'Last opp en ny firmware fil (.bin) eller en sikkerhetskopi fil (.json)',
|
||||
UPLOAD_DROP_TEXT: 'Dropp en firmware fil (.bin) eller klikk her',
|
||||
ERROR: 'Ukjent feil, prøv igjen',
|
||||
@@ -357,7 +358,8 @@ const no: Translation = {
|
||||
FIRMWARE_VERSION_INFO: 'Informasjon om firmwareversjon',
|
||||
NO_DATA: 'Ingen data',
|
||||
USER_PROFILE: 'Brukerprofil',
|
||||
STORED_VERSIONS: 'Lagret versjoner'
|
||||
STORED_VERSIONS: 'Lagret versjoner',
|
||||
ONLINE_HELP: 'online hjelp'
|
||||
};
|
||||
|
||||
export default no;
|
||||
|
||||
@@ -186,7 +186,8 @@ const pl: BaseTranslation = {
|
||||
BUFFER_SIZE: 'Maksymalna pojemność bufora (ilość wpisów)',
|
||||
COMPACT: 'Kompaktowy',
|
||||
DOWNLOAD_SETTINGS_TEXT: 'Utwórz kopię swoich ustawień i konfiguracji',
|
||||
DOWNLOAD_SETTINGS_TEXT2: 'Eksportuj wszystkie dane',
|
||||
DOWNLOAD_SETTINGS_TEXT2: 'Eksportuj wszystkie wartości',
|
||||
DOWNLOAD_SYSTEM_BACKUP: 'Kopia zapasowa systemu',
|
||||
UPLOAD_TEXT: 'Wgraj nowy plik firmware (.bin) lub kopię ustawień (.json)',
|
||||
UPLOAD_DROP_TEXT: 'Upuść plik firmware .bin lub kliknij tutaj',
|
||||
ERROR: 'Nieoczekiwany błąd, spróbuj ponownie!',
|
||||
@@ -357,7 +358,8 @@ const pl: BaseTranslation = {
|
||||
FIRMWARE_VERSION_INFO: 'Informacje o wersji firmware',
|
||||
NO_DATA: 'Brak danych',
|
||||
USER_PROFILE: 'Profil użytkownika',
|
||||
STORED_VERSIONS: 'Zapisane wersje'
|
||||
STORED_VERSIONS: 'Zapisane wersje',
|
||||
ONLINE_HELP: 'pomoc online'
|
||||
};
|
||||
|
||||
export default pl;
|
||||
|
||||
@@ -186,7 +186,8 @@ const sk: Translation = {
|
||||
BUFFER_SIZE: 'Buffer-max. veľkosť',
|
||||
COMPACT: 'Kompaktné',
|
||||
DOWNLOAD_SETTINGS_TEXT: 'Vytvorte zálohu svojej konfigurácie a nastavení',
|
||||
DOWNLOAD_SETTINGS_TEXT2: 'Exportovať všetky dáta',
|
||||
DOWNLOAD_SETTINGS_TEXT2: 'Exportovať všetky hodnoty',
|
||||
DOWNLOAD_SYSTEM_BACKUP: 'Systémová záloha',
|
||||
UPLOAD_TEXT: 'Nahrajte nový súbor firmvéru (.bin) alebo súbor zálohy (.json)',
|
||||
UPLOAD_DROP_TEXT: 'Presuňte súbor .bin firmvéru alebo kliknite sem',
|
||||
ERROR: 'Neočakávaná chyba, prosím skúste to znova',
|
||||
@@ -357,7 +358,8 @@ const sk: Translation = {
|
||||
FIRMWARE_VERSION_INFO: 'Informácie o verzii firmware',
|
||||
NO_DATA: 'Žiadne dáta',
|
||||
USER_PROFILE: 'Profil používateľa',
|
||||
STORED_VERSIONS: 'Uložené verzie'
|
||||
STORED_VERSIONS: 'Uložené verzie',
|
||||
ONLINE_HELP: 'online pomoc'
|
||||
};
|
||||
|
||||
export default sk;
|
||||
|
||||
@@ -186,7 +186,8 @@ const sv: Translation = {
|
||||
BUFFER_SIZE: 'Max bufferstorlek',
|
||||
COMPACT: 'Komprimerad',
|
||||
DOWNLOAD_SETTINGS_TEXT: 'Skapa en säkerhetskopia av din konfiguration och inställningar',
|
||||
DOWNLOAD_SETTINGS_TEXT2: 'Exportera alla data',
|
||||
DOWNLOAD_SETTINGS_TEXT2: 'Exportera alla värden',
|
||||
DOWNLOAD_SYSTEM_BACKUP: 'System säkerhetskopia',
|
||||
UPLOAD_TEXT: 'Ladda upp en ny firmwarefil (.bin) eller en säkerhetskopiafil (.json)',
|
||||
UPLOAD_DROP_TEXT: 'Droppa en firmware .bin fil eller klicka här',
|
||||
ERROR: 'Okänt fel, var god försök igen',
|
||||
@@ -357,7 +358,8 @@ const sv: Translation = {
|
||||
FIRMWARE_VERSION_INFO: 'Information om firmwareversion',
|
||||
NO_DATA: 'Ingen data',
|
||||
USER_PROFILE: 'Användarprofil',
|
||||
STORED_VERSIONS: 'Lagrad versioner'
|
||||
STORED_VERSIONS: 'Lagrad versioner',
|
||||
ONLINE_HELP: 'online hjälp'
|
||||
};
|
||||
|
||||
export default sv;
|
||||
|
||||
@@ -186,7 +186,8 @@ const tr: Translation = {
|
||||
BUFFER_SIZE: 'En fazla bellek boyutu',
|
||||
COMPACT: 'Sıkışık',
|
||||
DOWNLOAD_SETTINGS_TEXT: 'Yapılandırma ve ayarlarınızın yedekleme yapın',
|
||||
DOWNLOAD_SETTINGS_TEXT2: 'Tüm verileri dışarı al',
|
||||
DOWNLOAD_SETTINGS_TEXT2: 'Tüm değerleri dışarı al',
|
||||
DOWNLOAD_SYSTEM_BACKUP: 'Sistem yedekleme',
|
||||
UPLOAD_TEXT: 'Yeni bir firmware dosyası (.bin) veya yedek dosyası (.json) yükle',
|
||||
UPLOAD_DROP_TEXT: 'Bir firmware .bin dosyası veya buraya tıklayın',
|
||||
ERROR: 'Beklenemedik hata, lütfen tekrar deneyin.',
|
||||
@@ -357,7 +358,8 @@ const tr: Translation = {
|
||||
FIRMWARE_VERSION_INFO: 'Firmware Sürüm Bilgisi',
|
||||
NO_DATA: 'Hiçbir veri yok',
|
||||
USER_PROFILE: 'Kullanıcı Profili',
|
||||
STORED_VERSIONS: 'Kaydedilmiş Sürümler'
|
||||
STORED_VERSIONS: 'Kaydedilmiş Sürümler',
|
||||
ONLINE_HELP: 'online yardım'
|
||||
};
|
||||
|
||||
export default tr;
|
||||
|
||||
@@ -23,6 +23,8 @@ export const saveFile = (
|
||||
}, 100);
|
||||
} catch (error) {
|
||||
console.error('Failed to save file:', error);
|
||||
throw new Error(`Unable to save file: ${filename}${extension}`);
|
||||
throw new Error(`Unable to save file: ${filename}${extension}`, {
|
||||
cause: error
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2,9 +2,8 @@ import preact from '@preact/preset-vite';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { visualizer } from 'rollup-plugin-visualizer';
|
||||
import { Plugin, defineConfig } from 'vite';
|
||||
import { Plugin, PluginOption, defineConfig } from 'vite';
|
||||
import viteImagemin from 'vite-plugin-imagemin';
|
||||
import viteTsconfigPaths from 'vite-tsconfig-paths';
|
||||
import zlib from 'zlib';
|
||||
|
||||
// @ts-expect-error - mock server doesn't have type declarations
|
||||
@@ -99,16 +98,31 @@ const createPreactPlugin = (devToolsEnabled: boolean) =>
|
||||
prefreshEnabled: false
|
||||
});
|
||||
|
||||
// Patch preact/compat to export stub React 19 APIs (use, useOptimistic) so that
|
||||
// react-router v7 doesn't trigger IMPORT_IS_UNDEFINED warnings from Rolldown.
|
||||
const preactCompatPatchPlugin = (): Plugin => ({
|
||||
name: 'preact-compat-react19-patch',
|
||||
transform(code, id) {
|
||||
if (id.includes('preact') && id.includes('compat.module.js')) {
|
||||
return {
|
||||
code:
|
||||
code +
|
||||
'\nexport var use = undefined;\nexport var useOptimistic = undefined;\n',
|
||||
map: null
|
||||
};
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
});
|
||||
|
||||
// Common base plugins
|
||||
const createBasePlugins = (
|
||||
devToolsEnabled: boolean,
|
||||
includeBundleReporter = true
|
||||
) => {
|
||||
const plugins = [
|
||||
): PluginOption[] => {
|
||||
const plugins: PluginOption[] = [
|
||||
createPreactPlugin(devToolsEnabled),
|
||||
viteTsconfigPaths({
|
||||
projects: ['./tsconfig.json']
|
||||
})
|
||||
preactCompatPatchPlugin()
|
||||
];
|
||||
if (includeBundleReporter) {
|
||||
plugins.push(bundleSizeReporter());
|
||||
@@ -234,7 +248,8 @@ export default defineConfig(
|
||||
plugins: [...createBasePlugins(true, true), mockServer()],
|
||||
resolve: {
|
||||
alias: RESOLVE_ALIASES,
|
||||
extensions: RESOLVE_EXTENSIONS
|
||||
extensions: RESOLVE_EXTENSIONS,
|
||||
tsconfigPaths: true
|
||||
},
|
||||
server: {
|
||||
open: true,
|
||||
@@ -263,7 +278,8 @@ export default defineConfig(
|
||||
plugins: createBasePlugins(false, true),
|
||||
resolve: {
|
||||
alias: RESOLVE_ALIASES,
|
||||
extensions: RESOLVE_EXTENSIONS
|
||||
extensions: RESOLVE_EXTENSIONS,
|
||||
tsconfigPaths: true
|
||||
},
|
||||
build: {
|
||||
...createBaseBuildConfig(),
|
||||
@@ -297,7 +313,8 @@ export default defineConfig(
|
||||
],
|
||||
resolve: {
|
||||
alias: RESOLVE_ALIASES,
|
||||
extensions: RESOLVE_EXTENSIONS
|
||||
extensions: RESOLVE_EXTENSIONS,
|
||||
tsconfigPaths: true
|
||||
},
|
||||
build: {
|
||||
...createBaseBuildConfig(),
|
||||
@@ -306,8 +323,7 @@ export default defineConfig(
|
||||
rollupOptions: {
|
||||
treeshake: {
|
||||
moduleSideEffects: false,
|
||||
propertyReadSideEffects: false,
|
||||
tryCatchDeoptimization: false,
|
||||
propertyReadSideEffects: false as const,
|
||||
unknownGlobalSideEffects: false
|
||||
},
|
||||
output: {
|
||||
|
||||
@@ -148,9 +148,7 @@
|
||||
#elif defined(ARDUINO_ARCH_ESP32)
|
||||
#include <driver/rtc_io.h>
|
||||
#include <soc/gpio_struct.h>
|
||||
#if ESP_IDF_VERSION_MAJOR >= 5
|
||||
#include "soc/gpio_periph.h"
|
||||
#endif // ESP_IDF_VERSION_MAJOR >= 5
|
||||
#define PIN_TO_BASEREG(pin) (0)
|
||||
#define PIN_TO_BITMASK(pin) (pin)
|
||||
#define IO_REG_TYPE uint32_t
|
||||
|
||||
@@ -12,7 +12,9 @@
|
||||
// Include all library components
|
||||
#include "esp32-psram/AllocatorPSRAM.h" // PSRAM-backed vector
|
||||
#include "esp32-psram/VectorPSRAM.h" // PSRAM-backed vector
|
||||
#include "esp32-psram/VectorHIMEM.h" // HIMEM-backed vector
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
#include "esp32-psram/VectorHIMEM.h" // HIMEM-backed vector (ESP32 only)
|
||||
#endif
|
||||
// #include "esp32-psram/InMemoryFile.h" // File interface using vectors
|
||||
// #include "esp32-psram/PSRAM.h" // PSRAM file system
|
||||
// #include "esp32-psram/HIMEM.h" // HIMEM file system
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
// HIMEM is only available on original ESP32
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
@@ -360,3 +363,5 @@ class HimemBlock {
|
||||
};
|
||||
|
||||
} // namespace esp32_psram
|
||||
|
||||
#endif // CONFIG_IDF_TARGET_ESP32
|
||||
|
||||
@@ -238,7 +238,9 @@ using RingBufferStreamPSRAM = RingBufferStream<VectorPSRAM<uint8_t>>;
|
||||
/**
|
||||
* @brief Type alias for a RingBufferStream that uses HIMEM-backed vector storage
|
||||
*/
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
using RingBufferStreamHIMEM = RingBufferStream<VectorHIMEM<uint8_t>>;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Type alias for a RingBufferStream that uses std::vector storage
|
||||
|
||||
@@ -209,8 +209,10 @@ using TypedRingBufferRAM = TypedRingBuffer<T, std::vector<T>>;
|
||||
/**
|
||||
* @brief Type alias for a typed ring buffer that uses HIMEM-backed vector storage
|
||||
*/
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
template<typename T>
|
||||
using TypedRingBufferHIMEM = TypedRingBuffer<T, VectorHIMEM<T>>;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Type alias for a typed ring buffer that uses PSRAM-backed vector storage
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
// HIMEM is only available on original ESP32
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
|
||||
#include "HimemBlock.h"
|
||||
|
||||
namespace esp32_psram {
|
||||
@@ -526,4 +529,6 @@ void swap(VectorHIMEM<T>& lhs, VectorHIMEM<T>& rhs) noexcept {
|
||||
lhs.swap(rhs);
|
||||
}
|
||||
|
||||
} // namespace esp32_psram
|
||||
} // namespace esp32_psram
|
||||
|
||||
#endif // CONFIG_IDF_TARGET_ESP32
|
||||
@@ -49,6 +49,10 @@ the LICENSE file.
|
||||
#define EMC_CLIENTID_LENGTH 23 + 1
|
||||
#endif
|
||||
|
||||
#ifdef EMSESP_MQTT_STACKSIZE
|
||||
#define EMC_TASK_STACK_SIZE EMSESP_MQTT_STACKSIZE
|
||||
#endif
|
||||
|
||||
#ifndef EMC_TASK_STACK_SIZE
|
||||
#define EMC_TASK_STACK_SIZE 5120
|
||||
#endif
|
||||
@@ -66,14 +70,10 @@ the LICENSE file.
|
||||
#endif
|
||||
|
||||
#if EMC_USE_MEMPOOL
|
||||
#ifndef EMC_NUM_POOL_ELEMENTS
|
||||
#define EMC_NUM_POOL_ELEMENTS 32
|
||||
#endif
|
||||
#ifndef EMC_SIZE_POOL_ELEMENTS
|
||||
#define EMC_SIZE_POOL_ELEMENTS 128
|
||||
#endif
|
||||
#ifndef EMC_NUM_POOL_ELEMENTS
|
||||
#define EMC_NUM_POOL_ELEMENTS 32
|
||||
#endif
|
||||
#ifndef EMC_SIZE_POOL_ELEMENTS
|
||||
#define EMC_SIZE_POOL_ELEMENTS 128
|
||||
#endif
|
||||
|
||||
#ifndef TASMOTA_SDK
|
||||
#define EMC_CLIENT_SECURE
|
||||
#endif
|
||||
|
||||
@@ -62,7 +62,11 @@ MqttClient::MqttClient(espMqttClientTypes::UseInternalTask useInternalTask, uint
|
||||
_xSemaphore = xSemaphoreCreateMutex();
|
||||
EMC_SEMAPHORE_GIVE(); // release before first use
|
||||
if (_useInternalTask == espMqttClientTypes::UseInternalTask::YES) {
|
||||
xTaskCreatePinnedToCore((TaskFunction_t)_loop, "mqttclient", EMC_TASK_STACK_SIZE, this, priority, &_taskHandle, core);
|
||||
if (core > 1) {
|
||||
xTaskCreate((TaskFunction_t)_loop, "mqttclient", EMC_TASK_STACK_SIZE, this, priority, &_taskHandle);
|
||||
} else {
|
||||
xTaskCreatePinnedToCore((TaskFunction_t)_loop, "mqttclient", EMC_TASK_STACK_SIZE, this, priority, &_taskHandle, core);
|
||||
}
|
||||
}
|
||||
#else
|
||||
(void) useInternalTask;
|
||||
@@ -70,6 +74,7 @@ MqttClient::MqttClient(espMqttClientTypes::UseInternalTask useInternalTask, uint
|
||||
(void) core;
|
||||
#endif
|
||||
_clientId = _generatedClientId;
|
||||
_core = core;
|
||||
}
|
||||
|
||||
MqttClient::~MqttClient() {
|
||||
|
||||
@@ -69,7 +69,17 @@ class MqttClient {
|
||||
const char* getClientId() const;
|
||||
size_t queueSize(); // No const because of mutex
|
||||
void loop();
|
||||
|
||||
uint32_t stack() {
|
||||
#ifndef EMSESP_STANDALONE
|
||||
return uxTaskGetStackHighWaterMark(_taskHandle);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
uint8_t core() {
|
||||
return _core;
|
||||
}
|
||||
|
||||
protected:
|
||||
explicit MqttClient(espMqttClientTypes::UseInternalTask useInternalTask, uint8_t priority = 1, uint8_t core = 1);
|
||||
espMqttClientTypes::UseInternalTask _useInternalTask;
|
||||
@@ -98,6 +108,7 @@ class MqttClient {
|
||||
uint8_t _willQos;
|
||||
bool _willRetain;
|
||||
uint32_t _timeout;
|
||||
uint8_t _core;
|
||||
|
||||
// state is protected to allow state changes by the transport system, defined in child classes
|
||||
// eg. to allow AsyncTCP
|
||||
|
||||
@@ -6,66 +6,65 @@ For a copy, see <https://opensource.org/licenses/MIT> or
|
||||
the LICENSE file.
|
||||
*/
|
||||
|
||||
#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
|
||||
#ifndef NO_TLS_SUPPORT
|
||||
|
||||
#include "ClientSecureSync.h"
|
||||
#include <lwip/sockets.h> // socket options
|
||||
#include <lwip/sockets.h>
|
||||
#include "../Config.h"
|
||||
|
||||
namespace espMqttClientInternals {
|
||||
|
||||
ClientSecureSync::ClientSecureSync()
|
||||
: client() {
|
||||
// empty
|
||||
: client() {
|
||||
client.setClient(&basic_client, true);
|
||||
client.setBufferSizes(EMC_RX_BUFFER_SIZE, EMC_TX_BUFFER_SIZE);
|
||||
client.setSessionTimeout(120); // Set the timeout in seconds (>=120 seconds)
|
||||
}
|
||||
|
||||
ClientSecureSync::~ClientSecureSync() {
|
||||
stop();
|
||||
}
|
||||
|
||||
bool ClientSecureSync::connect(IPAddress ip, uint16_t port) {
|
||||
bool ret = client.connect(ip, port); // implicit conversion of return code int --> bool
|
||||
if (ret) {
|
||||
#if defined(ARDUINO_ARCH_ESP8266)
|
||||
client.setNoDelay(true);
|
||||
#elif defined(ARDUINO_ARCH_ESP32)
|
||||
// Set TCP option directly to bypass lack of working setNoDelay for WiFiClientSecure
|
||||
int val = true;
|
||||
client.setSocketOption(IPPROTO_TCP, TCP_NODELAY, &val, sizeof(int));
|
||||
#endif
|
||||
}
|
||||
return ret;
|
||||
bool ret = client.connect(ip, port); // implicit conversion of return code int --> bool
|
||||
if (ret) {
|
||||
// Set TCP option directly to bypass lack of working setNoDelay for WiFiClientSecure
|
||||
int val = true;
|
||||
basic_client.setSocketOption(IPPROTO_TCP, TCP_NODELAY, &val, sizeof(int));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool ClientSecureSync::connect(const char* host, uint16_t port) {
|
||||
bool ret = client.connect(host, port); // implicit conversion of return code int --> bool
|
||||
if (ret) {
|
||||
#if defined(ARDUINO_ARCH_ESP8266)
|
||||
client.setNoDelay(true);
|
||||
#elif defined(ARDUINO_ARCH_ESP32)
|
||||
// Set TCP option directly to bypass lack of working setNoDelay for WiFiClientSecure
|
||||
int val = true;
|
||||
client.setSocketOption(IPPROTO_TCP, TCP_NODELAY, &val, sizeof(int));
|
||||
#endif
|
||||
}
|
||||
return ret;
|
||||
bool ClientSecureSync::connect(const char * host, uint16_t port) {
|
||||
bool ret = client.connect(host, port); // implicit conversion of return code int --> bool
|
||||
if (ret) {
|
||||
// Set TCP option directly to bypass lack of working setNoDelay for WiFiClientSecure
|
||||
int val = true;
|
||||
basic_client.setSocketOption(IPPROTO_TCP, TCP_NODELAY, &val, sizeof(int));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
size_t ClientSecureSync::write(const uint8_t* buf, size_t size) {
|
||||
return client.write(buf, size);
|
||||
size_t ClientSecureSync::write(const uint8_t * buf, size_t size) {
|
||||
return client.write(buf, size);
|
||||
}
|
||||
|
||||
int ClientSecureSync::read(uint8_t* buf, size_t size) {
|
||||
return client.read(buf, size);
|
||||
int ClientSecureSync::read(uint8_t * buf, size_t size) {
|
||||
return client.read(buf, size);
|
||||
}
|
||||
|
||||
void ClientSecureSync::stop() {
|
||||
client.stop();
|
||||
client.stop();
|
||||
}
|
||||
|
||||
bool ClientSecureSync::connected() {
|
||||
return client.connected();
|
||||
return client.connected();
|
||||
}
|
||||
|
||||
bool ClientSecureSync::disconnected() {
|
||||
return !client.connected();
|
||||
return !client.connected();
|
||||
}
|
||||
|
||||
} // namespace espMqttClientInternals
|
||||
} // namespace espMqttClientInternals
|
||||
|
||||
#endif
|
||||
#endif
|
||||
@@ -8,15 +8,11 @@ the LICENSE file.
|
||||
|
||||
#pragma once
|
||||
|
||||
#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
|
||||
#ifndef NO_TLS_SUPPORT
|
||||
|
||||
// Added for EMS-ESP
|
||||
#include "../Config.h"
|
||||
#if defined(EMC_CLIENT_SECURE)
|
||||
#include <WiFiClientSecure.h> // includes IPAddress
|
||||
#else
|
||||
// #include "esp_tls.h"
|
||||
#include <WiFiClient.h>
|
||||
#endif
|
||||
#include <ESP_SSLClient.h>
|
||||
#include "Transport.h"
|
||||
|
||||
namespace espMqttClientInternals {
|
||||
@@ -24,6 +20,7 @@ namespace espMqttClientInternals {
|
||||
class ClientSecureSync : public Transport {
|
||||
public:
|
||||
ClientSecureSync();
|
||||
~ClientSecureSync();
|
||||
bool connect(IPAddress ip, uint16_t port) override;
|
||||
bool connect(const char * host, uint16_t port) override;
|
||||
size_t write(const uint8_t * buf, size_t size) override;
|
||||
@@ -31,14 +28,11 @@ class ClientSecureSync : public Transport {
|
||||
void stop() override;
|
||||
bool connected() override;
|
||||
bool disconnected() override;
|
||||
// added for EMS-ESP
|
||||
#if defined(EMC_CLIENT_SECURE)
|
||||
WiFiClientSecure client;
|
||||
#else
|
||||
WiFiClient client;
|
||||
#endif
|
||||
|
||||
WiFiClient basic_client;
|
||||
ESP_SSLClient client;
|
||||
};
|
||||
|
||||
} // namespace espMqttClientInternals
|
||||
|
||||
#endif
|
||||
#endif
|
||||
@@ -8,50 +8,6 @@ the LICENSE file.
|
||||
|
||||
#include "espMqttClient.h"
|
||||
|
||||
#if defined(ARDUINO_ARCH_ESP8266)
|
||||
espMqttClient::espMqttClient()
|
||||
: MqttClientSetup(espMqttClientTypes::UseInternalTask::NO)
|
||||
, _client() {
|
||||
_transport = &_client;
|
||||
}
|
||||
|
||||
espMqttClientSecure::espMqttClientSecure()
|
||||
: MqttClientSetup(espMqttClientTypes::UseInternalTask::NO)
|
||||
, _client() {
|
||||
_transport = &_client;
|
||||
}
|
||||
|
||||
espMqttClientSecure & espMqttClientSecure::setInsecure() {
|
||||
_client.client.setInsecure();
|
||||
return *this;
|
||||
}
|
||||
|
||||
espMqttClientSecure & espMqttClientSecure::setFingerprint(const uint8_t fingerprint[20]) {
|
||||
_client.client.setFingerprint(fingerprint);
|
||||
return *this;
|
||||
}
|
||||
|
||||
espMqttClientSecure & espMqttClientSecure::setTrustAnchors(const X509List * ta) {
|
||||
_client.client.setTrustAnchors(ta);
|
||||
return *this;
|
||||
}
|
||||
|
||||
espMqttClientSecure & espMqttClientSecure::setClientRSACert(const X509List * cert, const PrivateKey * sk) {
|
||||
_client.client.setClientRSACert(cert, sk);
|
||||
return *this;
|
||||
}
|
||||
|
||||
espMqttClientSecure & espMqttClientSecure::setClientECCert(const X509List * cert, const PrivateKey * sk, unsigned allowed_usages, unsigned cert_issuer_key_type) {
|
||||
_client.client.setClientECCert(cert, sk, allowed_usages, cert_issuer_key_type);
|
||||
return *this;
|
||||
}
|
||||
|
||||
espMqttClientSecure & espMqttClientSecure::setCertStore(CertStoreBase * certStore) {
|
||||
_client.client.setCertStore(certStore);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(ARDUINO_ARCH_ESP32)
|
||||
espMqttClient::espMqttClient(espMqttClientTypes::UseInternalTask useInternalTask)
|
||||
: MqttClientSetup(useInternalTask)
|
||||
@@ -78,36 +34,35 @@ espMqttClientSecure::espMqttClientSecure(uint8_t priority, uint8_t core)
|
||||
}
|
||||
|
||||
espMqttClientSecure & espMqttClientSecure::setInsecure() {
|
||||
#if defined(EMC_CLIENT_SECURE)
|
||||
#ifndef NO_TLS_SUPPORT
|
||||
_client.client.setInsecure();
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
espMqttClientSecure & espMqttClientSecure::setCACert(const char * rootCA) {
|
||||
#if defined(EMC_CLIENT_SECURE)
|
||||
#ifndef NO_TLS_SUPPORT
|
||||
_client.client.setCACert(rootCA);
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
espMqttClientSecure & espMqttClientSecure::setCertificate(const char * clientCa) {
|
||||
#if defined(EMC_CLIENT_SECURE)
|
||||
#ifndef NO_TLS_SUPPORT
|
||||
_client.client.setCertificate(clientCa);
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
espMqttClientSecure & espMqttClientSecure::setPrivateKey(const char * privateKey) {
|
||||
#if defined(EMC_CLIENT_SECURE)
|
||||
#ifndef NO_TLS_SUPPORT
|
||||
_client.client.setPrivateKey(privateKey);
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
espMqttClientSecure & espMqttClientSecure::setPreSharedKey(const char * pskIdent, const char * psKey) {
|
||||
#if defined(EMC_CLIENT_SECURE)
|
||||
_client.client.setPreSharedKey(pskIdent, psKey);
|
||||
#ifndef NO_TLS_SUPPORT
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
@@ -120,9 +75,4 @@ espMqttClient::espMqttClient()
|
||||
, _client() {
|
||||
_transport = &_client;
|
||||
}
|
||||
#elif defined(_WIN32) || defined(__APPLE__)
|
||||
// Windows
|
||||
espMqttClient::espMqttClient()
|
||||
: MqttClientSetup(espMqttClientTypes::UseInternalTask::NO) {
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -65,10 +65,16 @@ class espMqttClientSecure : public MqttClientSetup<espMqttClientSecure> {
|
||||
espMqttClientSecure & setPreSharedKey(const char * pskIdent, const char * psKey);
|
||||
|
||||
protected:
|
||||
#ifndef NO_TLS_SUPPORT
|
||||
espMqttClientInternals::ClientSecureSync _client;
|
||||
#else
|
||||
espMqttClientInternals::ClientSync _client;
|
||||
#endif
|
||||
};
|
||||
|
||||
#elif defined(__linux__)
|
||||
#endif
|
||||
|
||||
#if defined(__linux__)
|
||||
class espMqttClient : public MqttClientSetup<espMqttClient> {
|
||||
public:
|
||||
espMqttClient();
|
||||
@@ -76,10 +82,4 @@ class espMqttClient : public MqttClientSetup<espMqttClient> {
|
||||
protected:
|
||||
espMqttClientInternals::ClientPosix _client;
|
||||
};
|
||||
#elif defined(_WIN32) || defined(__APPLE__)
|
||||
class espMqttClient : public MqttClientSetup<espMqttClient> {
|
||||
public:
|
||||
espMqttClient();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <esp32-psram.h>
|
||||
#include <uuid/common.h>
|
||||
#include <uuid/log.h>
|
||||
|
||||
@@ -1645,22 +1646,22 @@ class Shell : public std::enable_shared_from_this<Shell>, public uuid::log::Hand
|
||||
uint8_t cursor_ = 0; /*!< cursor position from end of line */
|
||||
uint8_t esc_ = 0; /*!< esc sequence running */
|
||||
|
||||
Stream & stream_; /*!< Stream used for the input/output of this shell. @since 3.0.0 */
|
||||
std::shared_ptr<Commands> commands_; /*!< Commands available for execution in this shell. @since 0.1.0 */
|
||||
std::deque<unsigned int> context_; /*!< Context stack for this shell. Affects which commands are available. Should never be empty. @since 0.1.0 */
|
||||
unsigned int flags_ = 0; /*!< Current flags for this shell. Affects which commands are available. @since 0.1.0 */
|
||||
Stream & stream_; /*!< Stream used for the input/output of this shell. @since 3.0.0 */
|
||||
std::shared_ptr<Commands> commands_; /*!< Commands available for execution in this shell. @since 0.1.0 */
|
||||
std::deque<unsigned int, AllocatorPSRAM<unsigned int>> context_; /*!< Context stack for this shell. Affects which commands are available. Should never be empty. @since 0.1.0 */
|
||||
unsigned int flags_ = 0; /*!< Current flags for this shell. Affects which commands are available. @since 0.1.0 */
|
||||
#if UUID_CONSOLE_THREAD_SAFE
|
||||
mutable std::mutex mutex_; /*!< Mutex for queued log messages. @since 1.0.0 */
|
||||
#endif
|
||||
unsigned long log_message_id_ = 0; /*!< The next identifier to use for queued log messages. @since 0.1.0 */
|
||||
std::list<QueuedLogMessage> log_messages_; /*!< Queued log messages, in the order they were received. @since 0.1.0 */
|
||||
size_t maximum_log_messages_ = MAX_LOG_MESSAGES; /*!< Maximum command line length in bytes. @since 0.6.0 */
|
||||
std::string line_buffer_; /*!< Command line buffer. Limited to maximum_command_line_length() bytes. @since 0.1.0 */
|
||||
size_t maximum_command_line_length_ = MAX_COMMAND_LINE_LENGTH; /*!< Maximum command line length in bytes. @since 0.6.0 */
|
||||
unsigned char previous_ = 0; /*!< Previous character that was entered on the command line. Used to detect CRLF line endings. @since 0.1.0 */
|
||||
Mode mode_ = Mode::NORMAL; /*!< Current execution mode. @since 0.1.0 */
|
||||
std::unique_ptr<ModeData> mode_data_ = nullptr; /*!< Data associated with the current execution mode. @since 0.1.0 */
|
||||
bool stopped_ = false; /*!< Indicates that the shell has been stopped. @since 0.1.0 */
|
||||
unsigned long log_message_id_ = 0; /*!< The next identifier to use for queued log messages. @since 0.1.0 */
|
||||
std::list<QueuedLogMessage, AllocatorPSRAM<QueuedLogMessage>> log_messages_; /*!< Queued log messages, in the order they were received. @since 0.1.0 */
|
||||
size_t maximum_log_messages_ = MAX_LOG_MESSAGES; /*!< Maximum command line length in bytes. @since 0.6.0 */
|
||||
std::string line_buffer_; /*!< Command line buffer. Limited to maximum_command_line_length() bytes. @since 0.1.0 */
|
||||
size_t maximum_command_line_length_ = MAX_COMMAND_LINE_LENGTH; /*!< Maximum command line length in bytes. @since 0.6.0 */
|
||||
unsigned char previous_ = 0; /*!< Previous character that was entered on the command line. Used to detect CRLF line endings. @since 0.1.0 */
|
||||
Mode mode_ = Mode::NORMAL; /*!< Current execution mode. @since 0.1.0 */
|
||||
std::unique_ptr<ModeData> mode_data_ = nullptr; /*!< Data associated with the current execution mode. @since 0.1.0 */
|
||||
bool stopped_ = false; /*!< Indicates that the shell has been stopped. @since 0.1.0 */
|
||||
bool prompt_displayed_ = false; /*!< Indicates that a command prompt has been displayed, so that the output of invoke_command() is correct. @since 0.1.0 */
|
||||
uint64_t idle_time_ = 0; /*!< Time the shell became idle. @since 0.7.0 */
|
||||
uint64_t idle_timeout_ = 0; /*!< Idle timeout (in milliseconds). @since 0.7.0 */
|
||||
@@ -1786,7 +1787,7 @@ class CommandLine {
|
||||
* @return A reference to the parameters.
|
||||
* @since 0.6.0
|
||||
*/
|
||||
inline std::vector<std::string> & operator*() {
|
||||
inline std::vector<std::string, AllocatorPSRAM<std::string>> & operator*() {
|
||||
return parameters_;
|
||||
}
|
||||
/**
|
||||
@@ -1795,7 +1796,7 @@ class CommandLine {
|
||||
* @return A reference to the parameters.
|
||||
* @since 0.6.0
|
||||
*/
|
||||
inline const std::vector<std::string> & operator*() const {
|
||||
inline const std::vector<std::string, AllocatorPSRAM<std::string>> & operator*() const {
|
||||
return parameters_;
|
||||
}
|
||||
/**
|
||||
@@ -1804,7 +1805,7 @@ class CommandLine {
|
||||
* @return A pointer to the parameters.
|
||||
* @since 0.4.0
|
||||
*/
|
||||
inline std::vector<std::string> * operator->() {
|
||||
inline std::vector<std::string, AllocatorPSRAM<std::string>> * operator->() {
|
||||
return ¶meters_;
|
||||
}
|
||||
/**
|
||||
@@ -1813,7 +1814,7 @@ class CommandLine {
|
||||
* @return A pointer to the parameters.
|
||||
* @since 0.4.0
|
||||
*/
|
||||
inline const std::vector<std::string> * operator->() const {
|
||||
inline const std::vector<std::string, AllocatorPSRAM<std::string>> * operator->() const {
|
||||
return ¶meters_;
|
||||
}
|
||||
|
||||
@@ -1843,8 +1844,8 @@ class CommandLine {
|
||||
bool trailing_space = false; /*!< Command line has a trailing space. @since 0.4.0 */
|
||||
|
||||
private:
|
||||
std::vector<std::string> parameters_; /*!< Separate command line parameters. @since 0.4.0 */
|
||||
size_t escape_parameters_ = std::numeric_limits<size_t>::max(); /*!< Number of initial arguments to escape in output. @since 0.5.0 */
|
||||
std::vector<std::string, AllocatorPSRAM<std::string>> parameters_; /*!< Separate command line parameters. @since 0.4.0 */
|
||||
size_t escape_parameters_ = std::numeric_limits<size_t>::max(); /*!< Number of initial arguments to escape in output. @since 0.5.0 */
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -232,7 +232,7 @@ void Logger::vlog(Level level, const char * format, va_list ap) const {
|
||||
}
|
||||
|
||||
void Logger::vlog(Level level, Facility facility, const char * format, va_list ap) const {
|
||||
std::vector<char> text(MAX_LOG_LENGTH + 1);
|
||||
std::vector<char, AllocatorPSRAM<char>> text(MAX_LOG_LENGTH + 1);
|
||||
|
||||
if (vsnprintf(text.data(), text.size(), format, ap) <= 0) {
|
||||
return;
|
||||
@@ -241,7 +241,7 @@ void Logger::vlog(Level level, Facility facility, const char * format, va_list a
|
||||
dispatch(level, facility, text);
|
||||
}
|
||||
|
||||
void Logger::dispatch(Level level, Facility facility, std::vector<char> & text) const {
|
||||
void Logger::dispatch(Level level, Facility facility, std::vector<char, AllocatorPSRAM<char>> & text) const {
|
||||
std::shared_ptr<Message> message = std::make_shared<Message>(get_uptime_ms(), level, facility, name_, text.data());
|
||||
text.resize(0);
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <esp32-psram.h>
|
||||
#include <uuid/common.h>
|
||||
|
||||
#ifndef UUID_COMMON_THREAD_SAFE
|
||||
@@ -645,7 +646,7 @@ class Logger {
|
||||
* @param[in] text Log message text.
|
||||
* @since 1.0.0
|
||||
*/
|
||||
void dispatch(Level level, Facility facility, std::vector<char> & text) const;
|
||||
void dispatch(Level level, Facility facility, std::vector<char, AllocatorPSRAM<char>> & text) const;
|
||||
|
||||
static std::atomic<Level> global_level_; /*!< Minimum global log level across all handlers. @since 3.0.0 */
|
||||
#if UUID_LOG_THREAD_SAFE
|
||||
@@ -723,7 +724,7 @@ class PrintHandler : public uuid::log::Handler {
|
||||
mutable std::mutex mutex_; /*!< Mutex for configuration, state and queued log messages. @since 2.3.0 */
|
||||
#endif
|
||||
size_t maximum_log_messages_ = MAX_LOG_MESSAGES; /*!< Maximum number of log messages to buffer before they are output. @since 2.2.0 */
|
||||
std::list<std::shared_ptr<Message>> log_messages_; /*!< Queued log messages, in the order they were received. @since 2.2.0 */
|
||||
std::list<std::shared_ptr<Message>, AllocatorPSRAM<std::shared_ptr<Message>>> log_messages_; /*!< Queued log messages, in the order they were received. @since 2.2.0 */
|
||||
};
|
||||
|
||||
} // namespace log
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include "../../src/core/emsesp.h"
|
||||
|
||||
#ifndef UUID_SYSLOG_HAVE_GETTIMEOFDAY
|
||||
#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
|
||||
#if defined(ARDUINO_ARCH_ESP8266)
|
||||
// time() does not return UTC on the ESP8266: https://github.com/esp8266/Arduino/issues/4637
|
||||
#define UUID_SYSLOG_HAVE_GETTIMEOFDAY 1
|
||||
#endif
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include <esp32-psram.h>
|
||||
#include <uuid/log.h>
|
||||
|
||||
#ifndef UUID_LOG_THREAD_SAFE
|
||||
@@ -321,7 +322,7 @@ class SyslogService : public uuid::log::Handler {
|
||||
#endif
|
||||
size_t maximum_log_messages_ = MAX_LOG_MESSAGES; /*!< Maximum number of log messages to buffer before they are output. @since 1.0.0 */
|
||||
unsigned long log_message_id_ = 0; /*!< The next identifier to use for queued log messages. @since 1.0.0 */
|
||||
std::list<QueuedLogMessage> log_messages_; /*!< Queued log messages, in the order they were received. @since 1.0.0 */
|
||||
std::list<QueuedLogMessage, AllocatorPSRAM<QueuedLogMessage>> log_messages_; /*!< Queued log messages, in the order they were received. @since 1.0.0 */
|
||||
uint64_t mark_interval_ = 0; /*!< Mark interval in milliseconds. @since 2.0.0 */
|
||||
uint64_t last_message_ = 0; /*!< Last message/mark time. @since 2.0.0 */
|
||||
|
||||
|
||||
@@ -249,7 +249,7 @@ size_t TelnetStream::write(uint8_t data) {
|
||||
}
|
||||
|
||||
size_t TelnetStream::write(const uint8_t * buffer, size_t size) {
|
||||
std::vector<unsigned char> data;
|
||||
std::vector<unsigned char, AllocatorPSRAM<unsigned char>> data;
|
||||
data.reserve(size);
|
||||
|
||||
while (size-- > 0) {
|
||||
@@ -310,7 +310,7 @@ size_t TelnetStream::raw_write(unsigned char data) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
size_t TelnetStream::raw_write(const std::vector<unsigned char> & data) {
|
||||
size_t TelnetStream::raw_write(const std::vector<unsigned char, AllocatorPSRAM<unsigned char>> & data) {
|
||||
return raw_write(reinterpret_cast<const unsigned char *>(data.data()), data.size());
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <esp32-psram.h>
|
||||
#include <uuid/console.h>
|
||||
|
||||
namespace uuid {
|
||||
@@ -203,7 +204,7 @@ class TelnetStream : public ::Stream {
|
||||
* @return The number of bytes that were output.
|
||||
* @since 0.1.0
|
||||
*/
|
||||
size_t raw_write(const std::vector<unsigned char> & data);
|
||||
size_t raw_write(const std::vector<unsigned char, AllocatorPSRAM<unsigned char>> & data);
|
||||
/**
|
||||
* Write an array of bytes directly to the output stream.
|
||||
*
|
||||
@@ -222,7 +223,7 @@ class TelnetStream : public ::Stream {
|
||||
unsigned char previous_in_ = 0; /*!< Previous character that was received. Used to detect CR NUL. @since 0.1.0 */
|
||||
unsigned char previous_out_ = 0; /*!< Previous character that was sent. Used to insert NUL after CR without LF. @since 0.1.0 */
|
||||
int peek_ = -1; /*!< Previously read data cached by peek(). @since 0.1.0 */
|
||||
std::vector<char> output_buffer_; /*!< Buffer data to be output until a read function is called. @since 0.1.0 */
|
||||
std::vector<char, AllocatorPSRAM<char>> output_buffer_; /*!< Buffer data to be output until a read function is called. @since 0.1.0 */
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -425,7 +426,7 @@ class TelnetService {
|
||||
|
||||
WiFiServer server_; /*!< TCP server. @since 0.1.0 */
|
||||
size_t maximum_connections_ = MAX_CONNECTIONS; /*!< Maximum number of concurrent open connections. @since 0.1.0 */
|
||||
std::list<Connection> connections_; /*!< Open connections. @since 0.1.0 */
|
||||
std::list<Connection, AllocatorPSRAM<Connection>> connections_; /*!< Open connections. @since 0.1.0 */
|
||||
shell_factory_function shell_factory_; /*!< Function to create a shell. @since 0.1.0 */
|
||||
unsigned long initial_idle_timeout_ = DEFAULT_IDLE_TIMEOUT; /*!< Initial idle timeout (in seconds). @since 0.1.0 */
|
||||
unsigned long write_timeout_ = DEFAULT_WRITE_TIMEOUT; /*!< Write timeout (in milliseconds). @since 0.1.0 */
|
||||
|
||||
@@ -145,6 +145,7 @@ double ledcSetup(uint8_t chan, double freq, uint8_t bit_num) {
|
||||
return 0;
|
||||
};
|
||||
void ledcAttachPin(uint8_t pin, uint8_t chan) {};
|
||||
void ledcAttach(uint8_t pin, uint8_t chan, uint8_t bit_num) {};
|
||||
void ledcWrite(uint8_t chan, uint32_t duty) {};
|
||||
void neopixelWrite(uint8_t pin, uint8_t red_val, uint8_t green_val, uint8_t blue_val) {};
|
||||
void rgbLedWrite(uint8_t pin, uint8_t red_val, uint8_t green_val, uint8_t blue_val) {};
|
||||
|
||||
@@ -72,6 +72,7 @@ void analogSetAttenuation(adc_attenuation_t attenuation);
|
||||
void dacWrite(uint8_t pin, uint8_t value);
|
||||
double ledcSetup(uint8_t chan, double freq, uint8_t bit_num);
|
||||
void ledcAttachPin(uint8_t pin, uint8_t chan);
|
||||
void ledcAttach(uint8_t pin, uint8_t chan, uint8_t bit_num);
|
||||
void ledcWrite(uint8_t chan, uint32_t duty);
|
||||
void neopixelWrite(uint8_t pin, uint8_t red_val, uint8_t green_val, uint8_t blue_val);
|
||||
void rgbLedWrite(uint8_t pin, uint8_t red_val, uint8_t green_val, uint8_t blue_val);
|
||||
|
||||
@@ -19,12 +19,164 @@ class AsyncClient {
|
||||
class AsyncServer {
|
||||
public:
|
||||
AsyncServer(uint16_t port)
|
||||
: _port(port){};
|
||||
~AsyncServer(){};
|
||||
: _port(port) {};
|
||||
~AsyncServer() {};
|
||||
|
||||
protected:
|
||||
uint16_t _port;
|
||||
};
|
||||
|
||||
namespace asyncsrv {
|
||||
|
||||
static constexpr const char empty[] = "";
|
||||
|
||||
static constexpr const char T__opaque[] = "\", opaque=\"";
|
||||
static constexpr const char T_100_CONTINUE[] = "100-continue";
|
||||
static constexpr const char T_13[] = "13";
|
||||
static constexpr const char T_ACCEPT[] = "Accept";
|
||||
static constexpr const char T_Accept_Ranges[] = "Accept-Ranges";
|
||||
static constexpr const char T_attachment[] = "attachment; filename=\"";
|
||||
static constexpr const char T_AUTH[] = "Authorization";
|
||||
static constexpr const char T_auth_nonce[] = "\", qop=\"auth\", nonce=\"";
|
||||
static constexpr const char T_BASIC[] = "Basic";
|
||||
static constexpr const char T_BASIC_REALM[] = "Basic realm=\"";
|
||||
static constexpr const char T_BEARER[] = "Bearer";
|
||||
static constexpr const char T_BODY[] = "body";
|
||||
static constexpr const char T_Cache_Control[] = "Cache-Control";
|
||||
static constexpr const char T_chunked[] = "chunked";
|
||||
static constexpr const char T_close[] = "close";
|
||||
static constexpr const char T_cnonce[] = "cnonce";
|
||||
static constexpr const char T_Connection[] = "Connection";
|
||||
static constexpr const char T_Content_Disposition[] = "Content-Disposition";
|
||||
static constexpr const char T_Content_Encoding[] = "Content-Encoding";
|
||||
static constexpr const char T_Content_Length[] = "Content-Length";
|
||||
static constexpr const char T_Content_Type[] = "Content-Type";
|
||||
static constexpr const char T_Content_Location[] = "Content-Location";
|
||||
static constexpr const char T_Cookie[] = "Cookie";
|
||||
static constexpr const char T_CORS_ACAC[] = "Access-Control-Allow-Credentials";
|
||||
static constexpr const char T_CORS_ACAH[] = "Access-Control-Allow-Headers";
|
||||
static constexpr const char T_CORS_ACAM[] = "Access-Control-Allow-Methods";
|
||||
static constexpr const char T_CORS_ACAO[] = "Access-Control-Allow-Origin";
|
||||
static constexpr const char T_CORS_ACMA[] = "Access-Control-Max-Age";
|
||||
static constexpr const char T_CORS_O[] = "Origin";
|
||||
static constexpr const char T_data_[] = "data: ";
|
||||
static constexpr const char T_Date[] = "Date";
|
||||
static constexpr const char T_DIGEST[] = "Digest";
|
||||
static constexpr const char T_DIGEST_[] = "Digest ";
|
||||
static constexpr const char T_ETag[] = "ETag";
|
||||
static constexpr const char T_event_[] = "event: ";
|
||||
static constexpr const char T_EXPECT[] = "Expect";
|
||||
static constexpr const char T_FALSE[] = "false";
|
||||
static constexpr const char T_filename[] = "filename";
|
||||
static constexpr const char T_gzip[] = "gzip";
|
||||
static constexpr const char T_Host[] = "host";
|
||||
static constexpr const char T_HTTP_1_0[] = "HTTP/1.0";
|
||||
static constexpr const char T_HTTP_100_CONT[] = "HTTP/1.1 100 Continue\r\n\r\n";
|
||||
static constexpr const char T_id__[] = "id: ";
|
||||
static constexpr const char T_IMS[] = "If-Modified-Since";
|
||||
static constexpr const char T_INM[] = "If-None-Match";
|
||||
static constexpr const char T_inline[] = "inline";
|
||||
static constexpr const char T_keep_alive[] = "keep-alive";
|
||||
static constexpr const char T_Last_Event_ID[] = "Last-Event-ID";
|
||||
static constexpr const char T_Last_Modified[] = "Last-Modified";
|
||||
static constexpr const char T_LOCATION[] = "Location";
|
||||
static constexpr const char T_LOGIN_REQ[] = "Login Required";
|
||||
static constexpr const char T_MULTIPART_[] = "multipart/";
|
||||
static constexpr const char T_name[] = "name";
|
||||
static constexpr const char T_nc[] = "nc";
|
||||
static constexpr const char T_no_cache[] = "no-cache";
|
||||
static constexpr const char T_nonce[] = "nonce";
|
||||
static constexpr const char T_none[] = "none";
|
||||
static constexpr const char T_opaque[] = "opaque";
|
||||
static constexpr const char T_qop[] = "qop";
|
||||
static constexpr const char T_realm[] = "realm";
|
||||
static constexpr const char T_realm__[] = "realm=\"";
|
||||
static constexpr const char T_response[] = "response";
|
||||
static constexpr const char T_retry_[] = "retry: ";
|
||||
static constexpr const char T_retry_after[] = "Retry-After";
|
||||
static constexpr const char T_nn[] = "\n\n";
|
||||
static constexpr const char T_rn[] = "\r\n";
|
||||
static constexpr const char T_rnrn[] = "\r\n\r\n";
|
||||
static constexpr const char T_Server[] = "Server";
|
||||
static constexpr const char T_Transfer_Encoding[] = "Transfer-Encoding";
|
||||
static constexpr const char T_TRUE[] = "true";
|
||||
static constexpr const char T_UPGRADE[] = "Upgrade";
|
||||
static constexpr const char T_uri[] = "uri";
|
||||
static constexpr const char T_username[] = "username";
|
||||
static constexpr const char T_WS[] = "websocket";
|
||||
static constexpr const char T_WWW_AUTH[] = "WWW-Authenticate";
|
||||
|
||||
// HTTP Methods
|
||||
static constexpr const char T_ANY[] = "ANY";
|
||||
static constexpr const char T_GET[] = "GET";
|
||||
static constexpr const char T_POST[] = "POST";
|
||||
static constexpr const char T_PUT[] = "PUT";
|
||||
static constexpr const char T_DELETE[] = "DELETE";
|
||||
static constexpr const char T_PATCH[] = "PATCH";
|
||||
static constexpr const char T_HEAD[] = "HEAD";
|
||||
static constexpr const char T_OPTIONS[] = "OPTIONS";
|
||||
static constexpr const char T_UNKNOWN[] = "UNKNOWN";
|
||||
|
||||
// Req content types
|
||||
static constexpr const char T_RCT_NOT_USED[] = "RCT_NOT_USED";
|
||||
static constexpr const char T_RCT_DEFAULT[] = "RCT_DEFAULT";
|
||||
static constexpr const char T_RCT_HTTP[] = "RCT_HTTP";
|
||||
static constexpr const char T_RCT_WS[] = "RCT_WS";
|
||||
static constexpr const char T_RCT_EVENT[] = "RCT_EVENT";
|
||||
static constexpr const char T_ERROR[] = "ERROR";
|
||||
|
||||
// extensions & MIME-Types
|
||||
static constexpr const char T__avif[] = ".avif"; // AVIF: Highly compressed images. Compatible with all modern browsers.
|
||||
static constexpr const char T__csv[] = ".csv"; // CSV: Data logging and configuration
|
||||
static constexpr const char T__css[] = ".css"; // CSS: Styling for web interfaces
|
||||
static constexpr const char T__gif[] = ".gif"; // GIF: Simple animations. Legacy support
|
||||
static constexpr const char T__gz[] = ".gz"; // GZ: compressed files
|
||||
static constexpr const char T__htm[] = ".htm"; // HTM: Web interface files
|
||||
static constexpr const char T__html[] = ".html"; // HTML: Web interface files
|
||||
static constexpr const char T__ico[] = ".ico"; // ICO: Favicons, system icons. Legacy support
|
||||
static constexpr const char T__jpg[] = ".jpg"; // JPEG/JPG: Photos. Legacy support
|
||||
static constexpr const char T__js[] = ".js"; // JavaScript: Interactive functionality
|
||||
static constexpr const char T__json[] = ".json"; // JSON: Data exchange format
|
||||
static constexpr const char T__mp4[] = ".mp4"; // MP4: Proprietary format. Worse compression than WEBM.
|
||||
static constexpr const char T__mjs[] = ".mjs"; // MJS: JavaScript module format
|
||||
static constexpr const char T__opus[] = ".opus"; // OPUS: High compression audio format
|
||||
static constexpr const char T__pdf[] = ".pdf"; // PDF: Universal document format
|
||||
static constexpr const char T__png[] = ".png"; // PNG: Icons, logos, transparency. Legacy support
|
||||
static constexpr const char T__svg[] = ".svg"; // SVG: Vector graphics, icons (scalable, tiny file sizes)
|
||||
static constexpr const char T__ttf[] = ".ttf"; // TTF: Font file. Legacy support
|
||||
static constexpr const char T__txt[] = ".txt"; // TXT: Plain text files
|
||||
static constexpr const char T__webm[] = ".webm"; // WebM: Video. Open source, optimized for web. Compatible with all modern browsers.
|
||||
static constexpr const char T__webp[] = ".webp"; // WebP: Highly compressed images. Compatible with all modern browsers.
|
||||
static constexpr const char T__woff[] = ".woff"; // WOFF: Font file. Legacy support
|
||||
static constexpr const char T__woff2[] = ".woff2"; // WOFF2: Better compression. Compatible with all modern browsers.
|
||||
static constexpr const char T__xml[] = ".xml"; // XML: Configuration and data files
|
||||
static constexpr const char T_application_javascript[] = "application/javascript"; // Obsolete type for JavaScript
|
||||
static constexpr const char T_application_json[] = "application/json";
|
||||
static constexpr const char T_application_msgpack[] = "application/msgpack";
|
||||
static constexpr const char T_application_octet_stream[] = "application/octet-stream";
|
||||
static constexpr const char T_application_pdf[] = "application/pdf";
|
||||
static constexpr const char T_app_xform_urlencoded[] = "application/x-www-form-urlencoded";
|
||||
static constexpr const char T_audio_opus[] = "audio/opus";
|
||||
static constexpr const char T_font_ttf[] = "font/ttf";
|
||||
static constexpr const char T_font_woff[] = "font/woff";
|
||||
static constexpr const char T_font_woff2[] = "font/woff2";
|
||||
static constexpr const char T_image_avif[] = "image/avif";
|
||||
static constexpr const char T_image_gif[] = "image/gif";
|
||||
static constexpr const char T_image_jpeg[] = "image/jpeg";
|
||||
static constexpr const char T_image_png[] = "image/png";
|
||||
static constexpr const char T_image_svg_xml[] = "image/svg+xml";
|
||||
static constexpr const char T_image_webp[] = "image/webp";
|
||||
static constexpr const char T_image_x_icon[] = "image/x-icon";
|
||||
static constexpr const char T_text_css[] = "text/css";
|
||||
static constexpr const char T_text_csv[] = "text/csv";
|
||||
static constexpr const char T_text_event_stream[] = "text/event-stream";
|
||||
static constexpr const char T_text_html[] = "text/html";
|
||||
static constexpr const char T_text_javascript[] = "text/javascript";
|
||||
static constexpr const char T_text_plain[] = "text/plain";
|
||||
static constexpr const char T_text_xml[] = "text/xml";
|
||||
static constexpr const char T_video_mp4[] = "video/mp4";
|
||||
static constexpr const char T_video_webm[] = "video/webm";
|
||||
} // namespace asyncsrv
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -67,6 +67,9 @@ class Preferences {
|
||||
size_t putString(const char * key, String value) {
|
||||
return 0;
|
||||
}
|
||||
bool isKey(const char * key) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// unused....
|
||||
|
||||
@@ -84,7 +87,6 @@ class Preferences {
|
||||
// size_t putBool(const char * key, bool value);
|
||||
|
||||
// size_t putBytes(const char * key, const void * value, size_t len);
|
||||
// bool isKey(const char * key);
|
||||
// PreferenceType getType(const char * key);
|
||||
// int8_t getChar(const char * key, int8_t defaultValue = 0);
|
||||
// int16_t getShort(const char * key, int16_t defaultValue = 0);
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
"@msgpack/msgpack": "^3.1.3",
|
||||
"@trivago/prettier-plugin-sort-imports": "^6.0.2",
|
||||
"formidable": "^3.5.4",
|
||||
"itty-router": "^5.0.22",
|
||||
"prettier": "^3.7.4"
|
||||
"itty-router": "^5.0.23",
|
||||
"prettier": "^3.8.1"
|
||||
},
|
||||
"packageManager": "pnpm@10.28.0+sha512.05df71d1421f21399e053fde567cea34d446fa02c76571441bfc1c7956e98e363088982d940465fd34480d4d90a0668bc12362f8aa88000a64e83d0b0e47be48"
|
||||
"packageManager": "pnpm@10.32.1+sha512.a706938f0e89ac1456b6563eab4edf1d1faf3368d1191fc5c59790e96dc918e4456ab2e67d613de1043d2e8c81f87303e6b40d4ffeca9df15ef1ad567348f2be"
|
||||
}
|
||||
|
||||
108
mock-api/pnpm-lock.yaml
generated
108
mock-api/pnpm-lock.yaml
generated
@@ -13,25 +13,25 @@ importers:
|
||||
version: 3.1.3
|
||||
'@trivago/prettier-plugin-sort-imports':
|
||||
specifier: ^6.0.2
|
||||
version: 6.0.2(prettier@3.7.4)
|
||||
version: 6.0.2(prettier@3.8.1)
|
||||
formidable:
|
||||
specifier: ^3.5.4
|
||||
version: 3.5.4
|
||||
itty-router:
|
||||
specifier: ^5.0.22
|
||||
version: 5.0.22
|
||||
specifier: ^5.0.23
|
||||
version: 5.0.23
|
||||
prettier:
|
||||
specifier: ^3.7.4
|
||||
version: 3.7.4
|
||||
specifier: ^3.8.1
|
||||
version: 3.8.1
|
||||
|
||||
packages:
|
||||
|
||||
'@babel/code-frame@7.27.1':
|
||||
resolution: {integrity: sha512-cjQ7ZlQ0Mv3b47hABuTevyTuYN4i+loJKGeV9flcCgIK37cCXRh+L1bd3iBHlynerhQ7BhCkn2BPbQUL+rGqFg==}
|
||||
'@babel/code-frame@7.29.0':
|
||||
resolution: {integrity: sha512-9NhCeYjq9+3uxgdtp20LSiJXJvN0FeCtNGpJxuMFZ1Kv3cWUNb6DOhJwUvcVCzKGR66cw4njwM6hrJLqgOwbcw==}
|
||||
engines: {node: '>=6.9.0'}
|
||||
|
||||
'@babel/generator@7.28.5':
|
||||
resolution: {integrity: sha512-3EwLFhZ38J4VyIP6WNtt2kUdW9dokXA9Cr4IVIFHuCpZ3H8/YFOl5JjZHisrn1fATPBmKKqXzDFvh9fUwHz6CQ==}
|
||||
'@babel/generator@7.29.1':
|
||||
resolution: {integrity: sha512-qsaF+9Qcm2Qv8SRIMMscAvG4O3lJ0F1GuMo5HR/Bp02LopNgnZBC/EkbevHFeGs4ls/oPz9v+Bsmzbkbe+0dUw==}
|
||||
engines: {node: '>=6.9.0'}
|
||||
|
||||
'@babel/helper-globals@7.28.0':
|
||||
@@ -46,21 +46,21 @@ packages:
|
||||
resolution: {integrity: sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q==}
|
||||
engines: {node: '>=6.9.0'}
|
||||
|
||||
'@babel/parser@7.28.5':
|
||||
resolution: {integrity: sha512-KKBU1VGYR7ORr3At5HAtUQ+TV3SzRCXmA/8OdDZiLDBIZxVyzXuztPjfLd3BV1PRAQGCMWWSHYhL0F8d5uHBDQ==}
|
||||
'@babel/parser@7.29.2':
|
||||
resolution: {integrity: sha512-4GgRzy/+fsBa72/RZVJmGKPmZu9Byn8o4MoLpmNe1m8ZfYnz5emHLQz3U4gLud6Zwl0RZIcgiLD7Uq7ySFuDLA==}
|
||||
engines: {node: '>=6.0.0'}
|
||||
hasBin: true
|
||||
|
||||
'@babel/template@7.27.2':
|
||||
resolution: {integrity: sha512-LPDZ85aEJyYSd18/DkjNh4/y1ntkE5KwUHWTiqgRxruuZL2F1yuHligVHLvcHY2vMHXttKFpJn6LwfI7cw7ODw==}
|
||||
'@babel/template@7.28.6':
|
||||
resolution: {integrity: sha512-YA6Ma2KsCdGb+WC6UpBVFJGXL58MDA6oyONbjyF/+5sBgxY/dwkhLogbMT2GXXyU84/IhRw/2D1Os1B/giz+BQ==}
|
||||
engines: {node: '>=6.9.0'}
|
||||
|
||||
'@babel/traverse@7.28.5':
|
||||
resolution: {integrity: sha512-TCCj4t55U90khlYkVV/0TfkJkAkUg3jZFA3Neb7unZT8CPok7iiRfaX0F+WnqWqt7OxhOn0uBKXCw4lbL8W0aQ==}
|
||||
'@babel/traverse@7.29.0':
|
||||
resolution: {integrity: sha512-4HPiQr0X7+waHfyXPZpWPfWL/J7dcN1mx9gL6WdQVMbPnF3+ZhSMs8tCxN7oHddJE9fhNE7+lxdnlyemKfJRuA==}
|
||||
engines: {node: '>=6.9.0'}
|
||||
|
||||
'@babel/types@7.28.5':
|
||||
resolution: {integrity: sha512-qQ5m48eI/MFLQ5PxQj4PFaprjyCTLI37ElWMmNs0K8Lk3dVeOdNpB3ks8jc7yM5CDmVC73eMVk/trk3fgmrUpA==}
|
||||
'@babel/types@7.29.0':
|
||||
resolution: {integrity: sha512-LwdZHpScM4Qz8Xw2iKSzS+cfglZzJGvofQICy7W7v4caru4EaAmyUuO6BGrbyQ2mYV11W0U8j5mBhd14dd3B0A==}
|
||||
engines: {node: '>=6.9.0'}
|
||||
|
||||
'@jridgewell/gen-mapping@0.3.13':
|
||||
@@ -131,8 +131,8 @@ packages:
|
||||
resolution: {integrity: sha512-YikH+7CUTOtP44ZTnUhR7Ic2UASBPOqmaRkRKxRbywPTe5VxF7RRCck4af9wutiZ/QKM5nME9Bie2fFaPz5Gug==}
|
||||
engines: {node: '>=14.0.0'}
|
||||
|
||||
itty-router@5.0.22:
|
||||
resolution: {integrity: sha512-9hmdGErWdYDOurGYxSbqLhy4EFReIwk71hMZTJ5b+zfa2zjMNV1ftFno2b8VjAQvX615gNB8Qxbl9JMRqHnIVA==}
|
||||
itty-router@5.0.23:
|
||||
resolution: {integrity: sha512-i49WU+SNPrwOZA4Z61En1RYd5h2Lcqa+5IvCpMrNi4dxymzJK15ozUUnRrWIUAv95Zamd4eJPAot2UvHRrQg7w==}
|
||||
|
||||
javascript-natural-sort@0.7.1:
|
||||
resolution: {integrity: sha512-nO6jcEfZWQXDhOiBtG2KvKyEptz7RVbpGP4vTD2hLBdmNQSsCiicO2Ioinv6UI4y9ukqnBpy+XZ9H6uLNgJTlw==}
|
||||
@@ -145,11 +145,11 @@ packages:
|
||||
engines: {node: '>=6'}
|
||||
hasBin: true
|
||||
|
||||
lodash-es@4.17.22:
|
||||
resolution: {integrity: sha512-XEawp1t0gxSi9x01glktRZ5HDy0HXqrM0x5pXQM98EaI0NxO6jVM7omDOxsuEo5UIASAnm2bRp1Jt/e0a2XU8Q==}
|
||||
lodash-es@4.17.23:
|
||||
resolution: {integrity: sha512-kVI48u3PZr38HdYz98UmfPnXl2DXrpdctLrFLCd3kOx1xUkOmpFPx7gCWWM5MPkL/fD8zb+Ph0QzjGFs4+hHWg==}
|
||||
|
||||
minimatch@9.0.5:
|
||||
resolution: {integrity: sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==}
|
||||
minimatch@9.0.9:
|
||||
resolution: {integrity: sha512-OBwBN9AL4dqmETlpS2zasx+vTeWclWzkblfZk7KTA5j3jeOONz/tRCnZomUyvNg83wL5Zv9Ss6HMJXAgL8R2Yg==}
|
||||
engines: {node: '>=16 || 14 >=14.17'}
|
||||
|
||||
ms@2.1.3:
|
||||
@@ -167,8 +167,8 @@ packages:
|
||||
picocolors@1.1.1:
|
||||
resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==}
|
||||
|
||||
prettier@3.7.4:
|
||||
resolution: {integrity: sha512-v6UNi1+3hSlVvv8fSaoUbggEM5VErKmmpGA7Pl3HF8V6uKY7rvClBOJlH6yNwQtfTueNkGVpOv/mtWL9L4bgRA==}
|
||||
prettier@3.8.1:
|
||||
resolution: {integrity: sha512-UOnG6LftzbdaHZcKoPFtOcCKztrQ57WkHDeRD9t/PTQtmT0NHSeWWepj6pS0z/N7+08BHFDQVUrfmfMRcZwbMg==}
|
||||
engines: {node: '>=14'}
|
||||
hasBin: true
|
||||
|
||||
@@ -177,16 +177,16 @@ packages:
|
||||
|
||||
snapshots:
|
||||
|
||||
'@babel/code-frame@7.27.1':
|
||||
'@babel/code-frame@7.29.0':
|
||||
dependencies:
|
||||
'@babel/helper-validator-identifier': 7.28.5
|
||||
js-tokens: 4.0.0
|
||||
picocolors: 1.1.1
|
||||
|
||||
'@babel/generator@7.28.5':
|
||||
'@babel/generator@7.29.1':
|
||||
dependencies:
|
||||
'@babel/parser': 7.28.5
|
||||
'@babel/types': 7.28.5
|
||||
'@babel/parser': 7.29.2
|
||||
'@babel/types': 7.29.0
|
||||
'@jridgewell/gen-mapping': 0.3.13
|
||||
'@jridgewell/trace-mapping': 0.3.31
|
||||
jsesc: 3.1.0
|
||||
@@ -197,29 +197,29 @@ snapshots:
|
||||
|
||||
'@babel/helper-validator-identifier@7.28.5': {}
|
||||
|
||||
'@babel/parser@7.28.5':
|
||||
'@babel/parser@7.29.2':
|
||||
dependencies:
|
||||
'@babel/types': 7.28.5
|
||||
'@babel/types': 7.29.0
|
||||
|
||||
'@babel/template@7.27.2':
|
||||
'@babel/template@7.28.6':
|
||||
dependencies:
|
||||
'@babel/code-frame': 7.27.1
|
||||
'@babel/parser': 7.28.5
|
||||
'@babel/types': 7.28.5
|
||||
'@babel/code-frame': 7.29.0
|
||||
'@babel/parser': 7.29.2
|
||||
'@babel/types': 7.29.0
|
||||
|
||||
'@babel/traverse@7.28.5':
|
||||
'@babel/traverse@7.29.0':
|
||||
dependencies:
|
||||
'@babel/code-frame': 7.27.1
|
||||
'@babel/generator': 7.28.5
|
||||
'@babel/code-frame': 7.29.0
|
||||
'@babel/generator': 7.29.1
|
||||
'@babel/helper-globals': 7.28.0
|
||||
'@babel/parser': 7.28.5
|
||||
'@babel/template': 7.27.2
|
||||
'@babel/types': 7.28.5
|
||||
'@babel/parser': 7.29.2
|
||||
'@babel/template': 7.28.6
|
||||
'@babel/types': 7.29.0
|
||||
debug: 4.4.3
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
'@babel/types@7.28.5':
|
||||
'@babel/types@7.29.0':
|
||||
dependencies:
|
||||
'@babel/helper-string-parser': 7.27.1
|
||||
'@babel/helper-validator-identifier': 7.28.5
|
||||
@@ -246,17 +246,17 @@ snapshots:
|
||||
dependencies:
|
||||
'@noble/hashes': 1.8.0
|
||||
|
||||
'@trivago/prettier-plugin-sort-imports@6.0.2(prettier@3.7.4)':
|
||||
'@trivago/prettier-plugin-sort-imports@6.0.2(prettier@3.8.1)':
|
||||
dependencies:
|
||||
'@babel/generator': 7.28.5
|
||||
'@babel/parser': 7.28.5
|
||||
'@babel/traverse': 7.28.5
|
||||
'@babel/types': 7.28.5
|
||||
'@babel/generator': 7.29.1
|
||||
'@babel/parser': 7.29.2
|
||||
'@babel/traverse': 7.29.0
|
||||
'@babel/types': 7.29.0
|
||||
javascript-natural-sort: 0.7.1
|
||||
lodash-es: 4.17.22
|
||||
minimatch: 9.0.5
|
||||
lodash-es: 4.17.23
|
||||
minimatch: 9.0.9
|
||||
parse-imports-exports: 0.2.4
|
||||
prettier: 3.7.4
|
||||
prettier: 3.8.1
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
@@ -283,7 +283,7 @@ snapshots:
|
||||
dezalgo: 1.0.4
|
||||
once: 1.4.0
|
||||
|
||||
itty-router@5.0.22: {}
|
||||
itty-router@5.0.23: {}
|
||||
|
||||
javascript-natural-sort@0.7.1: {}
|
||||
|
||||
@@ -291,9 +291,9 @@ snapshots:
|
||||
|
||||
jsesc@3.1.0: {}
|
||||
|
||||
lodash-es@4.17.22: {}
|
||||
lodash-es@4.17.23: {}
|
||||
|
||||
minimatch@9.0.5:
|
||||
minimatch@9.0.9:
|
||||
dependencies:
|
||||
brace-expansion: 2.0.2
|
||||
|
||||
@@ -311,6 +311,6 @@ snapshots:
|
||||
|
||||
picocolors@1.1.1: {}
|
||||
|
||||
prettier@3.7.4: {}
|
||||
prettier@3.8.1: {}
|
||||
|
||||
wrappy@1.0.2: {}
|
||||
|
||||
@@ -363,6 +363,8 @@ function export_data(type: string) {
|
||||
return emsesp_modules;
|
||||
case 'allvalues':
|
||||
return emsesp_allvalues;
|
||||
case 'systembackup':
|
||||
return emsesp_systembackup;
|
||||
default:
|
||||
return status(404);
|
||||
}
|
||||
@@ -732,6 +734,8 @@ const emsesp_info = {
|
||||
]
|
||||
};
|
||||
|
||||
const emsesp_systembackup = {};
|
||||
|
||||
const emsesp_allvalues = {
|
||||
'Boiler Nefit Trendline HRC30 (DeviceID:0x08, ProductID:123, Version:06.01)': {
|
||||
'force heating off': 'off',
|
||||
@@ -4564,7 +4568,7 @@ router
|
||||
let sorted_devices = [...emsesp_coredata.devices].sort((a, b) => a.t - b.t);
|
||||
// append emsesp_coredata to sorted_devices so Custom is always at the end of the list
|
||||
sorted_devices.push(emsesp_coredata_custom);
|
||||
// sorted_devices = []; // uncomment if simulating no devices...
|
||||
// return { connected: false, devices: [] }; // uncomment if simulating no devices...
|
||||
return { connected: true, devices: sorted_devices };
|
||||
})
|
||||
.get(EMSESP_SENSOR_DATA_ENDPOINT, () => {
|
||||
|
||||
@@ -15,15 +15,14 @@ description = EMS-ESP Firmware for the ESP32
|
||||
src_dir = src
|
||||
lib_dir = lib
|
||||
boards_dir = boards
|
||||
; build_cache_dir = .pio/build_cache
|
||||
|
||||
extra_configs =
|
||||
factory_settings.ini
|
||||
pio_local.ini
|
||||
|
||||
[common]
|
||||
core_build_flags = -std=c++17 -std=gnu++17 -O3 -flto=auto -Wno-type-limits -Wall -Wextra -Wno-unused-parameter -Wno-unused-variable -Wno-format
|
||||
core_unbuild_flags = -std=gnu++11 -fno-lto
|
||||
core_build_flags = -std=c++17 -std=gnu++17 -O3 -Wno-type-limits -Wall -Wextra -Wno-unused-parameter -Wno-unused-variable -Wno-format -Wno-missing-field-initializers
|
||||
core_unbuild_flags = -std=gnu++11
|
||||
|
||||
my_build_flags =
|
||||
|
||||
@@ -54,13 +53,21 @@ build_flags =
|
||||
unbuild_flags =
|
||||
${common.core_unbuild_flags}
|
||||
|
||||
; 4MB Flash variants
|
||||
[espressif32_base_4M]
|
||||
framework = arduino
|
||||
board_build.partitions = partitions/esp32_partition_4M.csv
|
||||
board_upload.flash_size = 4MB
|
||||
board_build.app_partition_name = app0
|
||||
platform = https://github.com/tasmota/platform-espressif32/releases/download/2026.03.50/platform-espressif32.zip ; Tasmota Arduino Core 3.3.7 based on IDF 5.5.3.260313
|
||||
|
||||
; 16MB Flash variants
|
||||
[espressif32_base_16M]
|
||||
framework = arduino
|
||||
board_build.partitions = partitions/esp32_partition_16M.csv
|
||||
board_upload.flash_size = 16MB
|
||||
board_build.app_partition_name = app0
|
||||
platform = espressif32@6.12.0 ; Arduino Core 2.0.17 / IDF 4.4.7
|
||||
platform = https://github.com/tasmota/platform-espressif32/releases/download/2026.03.50/platform-espressif32.zip ; Tasmota Arduino Core 3.3.7 based on IDF 5.5.3.260313
|
||||
|
||||
; 32MB Flash variants
|
||||
[espressif32_base_32M]
|
||||
@@ -68,29 +75,7 @@ framework = arduino
|
||||
board_build.partitions = partitions/esp32_partition_32M.csv
|
||||
board_upload.flash_size = 32MB
|
||||
board_build.app_partition_name = app0
|
||||
platform = espressif32@6.12.0 ; Arduino Core 2.0.17 / IDF 4.4.7
|
||||
|
||||
; use Tasmota's library for 4MB Flash variants.
|
||||
; Removes libs (like mbedtsl, so no WiFi_secure.h) to increase available heap
|
||||
[espressif32_base_T_4M]
|
||||
framework = arduino
|
||||
board_build.partitions = partitions/esp32_partition_4M.csv
|
||||
board_upload.flash_size = 4MB
|
||||
board_build.app_partition_name = app0
|
||||
platform = https://github.com/tasmota/platform-espressif32/releases/download/2024.06.00/platform-espressif32.zip ; Arduino Core 2.0.18 with IPv6 support, based on IDF 4.4.8
|
||||
; Tasmota Arduino Core 3.1.3.250302 based on IDF 5.3.2.250228
|
||||
; platform = https://github.com/tasmota/platform-espressif32/releases/download/2025.03.30/platform-espressif32.zip
|
||||
|
||||
; use Tasmota's library for 16MB Flash variants.
|
||||
; Removes libs (like mbedtsl, so no WiFi_secure.h) to increase available heap
|
||||
[espressif32_base_T_16M]
|
||||
framework = arduino
|
||||
board_build.partitions = partitions/esp32_partition_16M.csv
|
||||
board_upload.flash_size = 16MB
|
||||
board_build.app_partition_name = app0
|
||||
platform = https://github.com/tasmota/platform-espressif32/releases/download/2024.06.00/platform-espressif32.zip ; Arduino Core 2.0.18 with IPv6 support, based on IDF 4.4.8
|
||||
; Tasmota Arduino Core 3.1.3.250302 based on IDF 5.3.2.250228
|
||||
; platform = https://github.com/tasmota/platform-espressif32/releases/download/2025.03.30/platform-espressif32.zip
|
||||
platform = https://github.com/tasmota/platform-espressif32/releases/download/2026.03.50/platform-espressif32.zip ; Tasmota Arduino Core 3.3.7 based on IDF 5.5.3.260313
|
||||
|
||||
[env]
|
||||
build_flags =
|
||||
@@ -106,9 +91,10 @@ board_build.filesystem = littlefs
|
||||
lib_deps =
|
||||
bblanchon/ArduinoJson @ 7.4.2
|
||||
ESP32Async/AsyncTCP @ 3.4.10
|
||||
ESP32Async/ESPAsyncWebServer @ 3.9.4
|
||||
https://github.com/emsesp/EMS-ESP-Modules.git @ 1.0.8
|
||||
|
||||
ESP32Async/ESPAsyncWebServer @ 3.10.3
|
||||
https://github.com/mobizt/ReadyMail.git @ 0.3.8
|
||||
https://github.com/mobizt/ESP_SSLClient.git @ 3.1.3
|
||||
; https://github.com/emsesp/EMS-ESP-Modules.git @ 1.0.8
|
||||
|
||||
; builds the web interface only, not the firmware
|
||||
[env:build_webUI]
|
||||
@@ -120,18 +106,17 @@ build_src_filter = -<*>
|
||||
|
||||
;
|
||||
; Builds for different board types
|
||||
; We use Tasmota for boards without PSRAM as this framework has mbedtls removed to save memory.
|
||||
; If you're building for a single target environment, we recommend creating a pio_local.ini (see example file)
|
||||
;
|
||||
|
||||
[env:s_4M]
|
||||
; 4MB ESP32 - no SSL, no PSRAM - like a BBQKees older S32 and E32 models - uses Tasmota
|
||||
extends = espressif32_base_T_4M
|
||||
; 4MB ESP32 - no SSL, no PSRAM - like a BBQKees older S32 and E32 models
|
||||
extends = espressif32_base_4M
|
||||
board = s_4M
|
||||
|
||||
[env:s_16M]
|
||||
; 16MB ESP32 - no PSRAM - like a BBQKees later S32 V2 models - uses Tasmota
|
||||
extends = espressif32_base_T_16M
|
||||
; 16MB ESP32 - no PSRAM - like a BBQKees later S32 V2 models
|
||||
extends = espressif32_base_16M
|
||||
board = s_16M
|
||||
|
||||
[env:s_16M_P]
|
||||
@@ -150,36 +135,29 @@ extends = espressif32_base_32M
|
||||
board = s3_32M_P
|
||||
|
||||
[env:s2_4M_P]
|
||||
; based on lolin_s2_mini 4MB with 2MB PSRAM - uses Tasmota
|
||||
extends = espressif32_base_T_4M
|
||||
; based on lolin_s2_mini 4MB with 2MB PSRAM
|
||||
extends = espressif32_base_4M
|
||||
board = s2_4M_P
|
||||
|
||||
[env:c3_mini_4M]
|
||||
; based on lolin_c3_mini 4MB, no PSRAM - uses Tasmota
|
||||
extends = espressif32_base_T_4M
|
||||
; based on lolin_c3_mini 4MB, no PSRAM
|
||||
extends = espressif32_base_4M
|
||||
board = c3_mini_4M
|
||||
|
||||
; lolin C3 mini v1 needs special wifi initialization
|
||||
; https://www.wemos.cc/en/latest/c3/c3_mini_1_0_0.html#about-wifi
|
||||
[env:c3_miniv1_4M]
|
||||
extends = espressif32_base_T_4M
|
||||
extends = espressif32_base_4M
|
||||
board = c3_mini_4M
|
||||
build_flags =
|
||||
${common.build_flags}
|
||||
-DBOARD_C3_MINI_V1
|
||||
|
||||
; XIAO ESP32C - 512KB SRAM & 4MB Flash - https://wiki.seeedstudio.com/xiao_esp32c6_getting_started/
|
||||
[env:c6]
|
||||
framework = arduino
|
||||
board_build.partitions = partitions/esp32_partition_4M.csv
|
||||
board_upload.flash_size = 4MB
|
||||
[env:c6_xiao_4M]
|
||||
extends = espressif32_base_4M
|
||||
board_build.app_partition_name = app0
|
||||
platform = https://github.com/pioarduino/platform-espressif32/releases/download/54.03.21-2/platform-espressif32.zip ; Arduino Release v3.2.1 based on ESP-IDF v5.4.2
|
||||
; platform = https://github.com/pioarduino/platform-espressif32/releases/download/55.03.30-2/platform-espressif32.zip ; Arduino Release v3.3.0 based on ESP-IDF v5.5.0
|
||||
board = seeed_xiao_esp32c6
|
||||
build_flags =
|
||||
${common.build_flags}
|
||||
-DBOARD_C6
|
||||
|
||||
; foundation for building and testing natively, standalone without an ESP32
|
||||
; use the `standalone` environment instead of `native` for testing
|
||||
@@ -190,6 +168,7 @@ build_flags =
|
||||
build_src_flags =
|
||||
-DEMSESP_STANDALONE -DEMSESP_TEST
|
||||
-DARDUINOJSON_ENABLE_ARDUINO_STRING=1
|
||||
-DNO_TLS_SUPPORT
|
||||
-std=gnu++17 -Og -ggdb
|
||||
-Wall -Wextra
|
||||
-Wno-unused-parameter -Wno-sign-compare -Wno-missing-braces
|
||||
@@ -212,6 +191,8 @@ build_src_filter =
|
||||
-<../lib/uuid-syslog>
|
||||
-<../lib/eModbus>
|
||||
-<../lib/OneWire>
|
||||
-<../lib/mbedtls_ssl/src>
|
||||
-<../src/core/ModuleLibrary.cpp>
|
||||
lib_ldf_mode = off
|
||||
lib_deps =
|
||||
|
||||
@@ -228,6 +209,7 @@ build_src_flags =
|
||||
-DEMSESP_STANDALONE -DEMSESP_TEST
|
||||
-DEMSESP_UNITY
|
||||
-DARDUINOJSON_ENABLE_ARDUINO_STRING=1
|
||||
-DNO_TLS_SUPPORT
|
||||
-DEMSESP_DEFAULT_LOCALE=\"en\" -DEMSESP_DEFAULT_BOARD_PROFILE=\"S32\"
|
||||
-std=gnu++17 -Og -ggdb
|
||||
-Wall -Wextra
|
||||
@@ -254,6 +236,8 @@ build_src_filter =
|
||||
-<../lib/uuid-syslog>
|
||||
-<../lib/eModbus>
|
||||
-<../lib/OneWire>
|
||||
-<../lib/mbedtls_ssl/src>
|
||||
-<../src/core/ModuleLibrary.cpp>
|
||||
lib_ldf_mode = off
|
||||
lib_deps = Unity
|
||||
test_testing_command =
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -10,7 +10,6 @@ APSettingsService::APSettingsService(AsyncWebServer * server, FS * fs, SecurityM
|
||||
, _reconfigureAp(false)
|
||||
, _connected(0) {
|
||||
addUpdateHandler([this] { reconfigureAP(); }, false);
|
||||
WiFi.onEvent([this](WiFiEvent_t event, WiFiEventInfo_t info) { WiFiEvent(event); });
|
||||
}
|
||||
|
||||
void APSettingsService::begin() {
|
||||
@@ -19,51 +18,40 @@ void APSettingsService::begin() {
|
||||
// reconfigureAP();
|
||||
}
|
||||
|
||||
// wait 10 sec on STA disconnect before starting AP
|
||||
void APSettingsService::WiFiEvent(WiFiEvent_t event) {
|
||||
uint8_t was_connected = _connected;
|
||||
switch (event) {
|
||||
case ARDUINO_EVENT_WIFI_STA_DISCONNECTED:
|
||||
_connected &= ~1;
|
||||
break;
|
||||
case ARDUINO_EVENT_ETH_DISCONNECTED:
|
||||
_connected &= ~2;
|
||||
break;
|
||||
case ARDUINO_EVENT_WIFI_STA_GOT_IP:
|
||||
case ARDUINO_EVENT_WIFI_STA_GOT_IP6:
|
||||
_connected |= 1;
|
||||
break;
|
||||
case ARDUINO_EVENT_ETH_GOT_IP:
|
||||
case ARDUINO_EVENT_ETH_GOT_IP6:
|
||||
_connected |= 2;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// wait 10 sec before starting AP
|
||||
if (was_connected && !_connected) {
|
||||
_lastManaged = uuid::get_uptime();
|
||||
}
|
||||
}
|
||||
|
||||
void APSettingsService::reconfigureAP() {
|
||||
_lastManaged = uuid::get_uptime() - MANAGE_NETWORK_DELAY;
|
||||
_reconfigureAp = true;
|
||||
}
|
||||
|
||||
void APSettingsService::loop() {
|
||||
unsigned long currentMillis = uuid::get_uptime();
|
||||
unsigned long manageElapsed = static_cast<uint32_t>(currentMillis - _lastManaged);
|
||||
if (manageElapsed >= MANAGE_NETWORK_DELAY) {
|
||||
const uint8_t was_connected = _connected;
|
||||
if (WiFi.isConnected()) {
|
||||
_connected |= 1U;
|
||||
} else {
|
||||
_connected &= ~1U;
|
||||
}
|
||||
if (ETH.connected()) {
|
||||
_connected |= 2U;
|
||||
} else {
|
||||
_connected &= ~2U;
|
||||
}
|
||||
// wait 10 sec before starting AP
|
||||
if (was_connected && !_connected) {
|
||||
_lastManaged = uuid::get_uptime();
|
||||
}
|
||||
const unsigned long currentMillis = uuid::get_uptime();
|
||||
if ((currentMillis - _lastManaged) >= MANAGE_NETWORK_DELAY) {
|
||||
_lastManaged = currentMillis;
|
||||
manageAP();
|
||||
}
|
||||
|
||||
handleDNS();
|
||||
if (_dnsServer) {
|
||||
handleDNS();
|
||||
}
|
||||
}
|
||||
|
||||
void APSettingsService::manageAP() {
|
||||
WiFiMode_t currentWiFiMode = WiFi.getMode();
|
||||
const WiFiMode_t currentWiFiMode = WiFi.getMode();
|
||||
if (_state.provisionMode == AP_MODE_ALWAYS || (_state.provisionMode == AP_MODE_DISCONNECTED && !_connected)) {
|
||||
if (_reconfigureAp || currentWiFiMode == WIFI_OFF || currentWiFiMode == WIFI_STA) {
|
||||
startAP();
|
||||
@@ -75,11 +63,7 @@ void APSettingsService::manageAP() {
|
||||
}
|
||||
|
||||
void APSettingsService::startAP() {
|
||||
#if ESP_IDF_VERSION_MAJOR < 5
|
||||
WiFi.softAPenableIpV6(); // force IPV6, same as for WiFi - fixes https://github.com/emsesp/EMS-ESP32/issues/1922
|
||||
#else
|
||||
WiFi.softAPenableIPv6(); // force IPV6, same as for WiFi - fixes https://github.com/emsesp/EMS-ESP32/issues/1922
|
||||
#endif
|
||||
WiFi.softAPConfig(_state.localIP, _state.gatewayIP, _state.subnetMask);
|
||||
esp_wifi_set_bandwidth(static_cast<wifi_interface_t>(ESP_IF_WIFI_AP), WIFI_BW_HT20);
|
||||
WiFi.softAP(_state.ssid.c_str(), _state.password.c_str(), _state.channel, _state.ssidHidden, _state.maxClients);
|
||||
@@ -87,8 +71,10 @@ void APSettingsService::startAP() {
|
||||
WiFi.setTxPower(WIFI_POWER_8_5dBm); // https://www.wemos.cc/en/latest/c3/c3_mini_1_0_0.html#about-wifi
|
||||
#endif
|
||||
if (!_dnsServer) {
|
||||
IPAddress apIp = WiFi.softAPIP();
|
||||
emsesp::EMSESP::logger().info("Starting Access Point with captive portal on %s", apIp.toString().c_str());
|
||||
const IPAddress apIp = WiFi.softAPIP();
|
||||
char ipStr[16];
|
||||
snprintf(ipStr, sizeof(ipStr), "%u.%u.%u.%u", apIp[0], apIp[1], apIp[2], apIp[3]);
|
||||
emsesp::EMSESP::logger().info("Starting Access Point with captive portal on %s", ipStr);
|
||||
_dnsServer = new DNSServer;
|
||||
_dnsServer->start(DNS_PORT, "*", apIp);
|
||||
}
|
||||
@@ -111,8 +97,8 @@ void APSettingsService::handleDNS() {
|
||||
}
|
||||
|
||||
APNetworkStatus APSettingsService::getAPNetworkStatus() {
|
||||
WiFiMode_t currentWiFiMode = WiFi.getMode();
|
||||
bool apActive = currentWiFiMode == WIFI_AP || currentWiFiMode == WIFI_AP_STA;
|
||||
const WiFiMode_t currentWiFiMode = WiFi.getMode();
|
||||
const bool apActive = (currentWiFiMode == WIFI_AP || currentWiFiMode == WIFI_AP_STA);
|
||||
|
||||
if (apActive && _state.provisionMode != AP_MODE_ALWAYS && WiFi.status() == WL_CONNECTED) {
|
||||
return APNetworkStatus::LINGERING;
|
||||
@@ -135,7 +121,7 @@ void APSettings::read(const APSettings & settings, JsonObject root) {
|
||||
}
|
||||
|
||||
StateUpdateResult APSettings::update(JsonObject root, APSettings & settings) {
|
||||
APSettings newSettings = {};
|
||||
APSettings newSettings{};
|
||||
newSettings.provisionMode = static_cast<uint8_t>(root["provision_mode"] | FACTORY_AP_PROVISION_MODE);
|
||||
|
||||
switch (settings.provisionMode) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef APSettingsConfig_h
|
||||
#define APSettingsConfig_h
|
||||
#ifndef APSettingsService_h
|
||||
#define APSettingsService_h
|
||||
|
||||
#include "HttpEndpoint.h"
|
||||
#include "FSPersistence.h"
|
||||
@@ -70,9 +70,9 @@ class APSettings {
|
||||
IPAddress subnetMask;
|
||||
|
||||
bool operator==(const APSettings & settings) const {
|
||||
return provisionMode == settings.provisionMode && ssid == settings.ssid && password == settings.password && channel == settings.channel
|
||||
&& ssidHidden == settings.ssidHidden && maxClients == settings.maxClients && localIP == settings.localIP && gatewayIP == settings.gatewayIP
|
||||
&& subnetMask == settings.subnetMask;
|
||||
return provisionMode == settings.provisionMode && channel == settings.channel && ssidHidden == settings.ssidHidden && maxClients == settings.maxClients
|
||||
&& localIP == settings.localIP && gatewayIP == settings.gatewayIP && subnetMask == settings.subnetMask && ssid == settings.ssid
|
||||
&& password == settings.password;
|
||||
}
|
||||
|
||||
static void read(const APSettings & settings, JsonObject root);
|
||||
@@ -96,15 +96,14 @@ class APSettingsService : public StatefulService<APSettings> {
|
||||
|
||||
// for the management delay loop
|
||||
volatile unsigned long _lastManaged;
|
||||
volatile boolean _reconfigureAp;
|
||||
uint8_t _connected;
|
||||
volatile bool _reconfigureAp;
|
||||
volatile uint8_t _connected;
|
||||
|
||||
void reconfigureAP();
|
||||
void manageAP();
|
||||
void startAP();
|
||||
void stopAP();
|
||||
void handleDNS();
|
||||
void WiFiEvent(WiFiEvent_t event);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -66,21 +66,16 @@ void ArduinoJsonJWT::parseJWT(String jwt, JsonDocument & jsonDocument) {
|
||||
}
|
||||
|
||||
/*
|
||||
* ESP32 uses mbedtls, with decent HMAC implementations supporting sha256, as well as others.
|
||||
* No need to pull in additional crypto libraries - lets use what we already have.
|
||||
* HMAC-SHA256 using mbedtls
|
||||
*/
|
||||
String ArduinoJsonJWT::sign(String & payload) {
|
||||
std::array<unsigned char, 32> hmacResult{};
|
||||
{
|
||||
mbedtls_md_context_t ctx;
|
||||
mbedtls_md_type_t md_type = MBEDTLS_MD_SHA256;
|
||||
mbedtls_md_init(&ctx);
|
||||
mbedtls_md_setup(&ctx, mbedtls_md_info_from_type(md_type), 1);
|
||||
mbedtls_md_hmac_starts(&ctx, reinterpret_cast<const unsigned char *>(_secret.c_str()), _secret.length());
|
||||
mbedtls_md_hmac_update(&ctx, reinterpret_cast<const unsigned char *>(payload.c_str()), payload.length());
|
||||
mbedtls_md_hmac_finish(&ctx, hmacResult.data());
|
||||
mbedtls_md_free(&ctx);
|
||||
}
|
||||
mbedtls_md_hmac(mbedtls_md_info_from_type(MBEDTLS_MD_SHA256),
|
||||
reinterpret_cast<const unsigned char *>(_secret.c_str()),
|
||||
_secret.length(),
|
||||
reinterpret_cast<const unsigned char *>(payload.c_str()),
|
||||
payload.length(),
|
||||
hmacResult.data());
|
||||
return encode(reinterpret_cast<const char *>(hmacResult.data()), hmacResult.size());
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
#include "WWWData.h" // include auto-generated static web resources
|
||||
|
||||
static constexpr const char CACHE_CONTROL[] = "public,max-age=60";
|
||||
|
||||
ESP32React::ESP32React(AsyncWebServer * server, FS * fs)
|
||||
: _securitySettingsService(server, fs)
|
||||
, _networkSettingsService(server, fs, &_securitySettingsService)
|
||||
@@ -22,21 +24,18 @@ ESP32React::ESP32React(AsyncWebServer * server, FS * fs)
|
||||
ArRequestHandlerFunction indexHtmlHandler = nullptr;
|
||||
|
||||
WWWData::registerRoutes([server, &indexHtmlHandler](const char * uri, const String & contentType, const uint8_t * content, size_t len, const String & hash) {
|
||||
ArRequestHandlerFunction requestHandler = [contentType, content, len, hash](AsyncWebServerRequest * request) {
|
||||
AsyncWebServerResponse * response;
|
||||
String etag = "\"" + hash + "\""; // RFC9110: ETag must be enclosed in double quotes
|
||||
|
||||
// Check if the client already has the same version and respond with a 304 (Not modified)
|
||||
if (request->header("If-None-Match").equals(hash)) {
|
||||
response = request->beginResponse(304);
|
||||
} else {
|
||||
response = request->beginResponse(200, contentType, content, len);
|
||||
response->addHeader("Content-Encoding", "gzip"); // not br for brotlin only works over HTTPS
|
||||
ArRequestHandlerFunction requestHandler = [contentType, content, len, etag](AsyncWebServerRequest * request) {
|
||||
if (request->header(asyncsrv::T_INM) == etag) {
|
||||
request->send(304);
|
||||
return;
|
||||
}
|
||||
|
||||
// always send these headers - see https://datatracker.ietf.org/doc/html/rfc7232#section-4.1
|
||||
response->addHeader("ETag", hash);
|
||||
response->addHeader("Cache-Control", "no-cache"); // Requires revalidation before using cached content (ETags enable 304 responses)
|
||||
|
||||
AsyncWebServerResponse * response = request->beginResponse(200, contentType, content, len);
|
||||
response->addHeader(asyncsrv::T_Content_Encoding, asyncsrv::T_gzip, false);
|
||||
response->addHeader(asyncsrv::T_ETag, etag, false);
|
||||
response->addHeader(asyncsrv::T_Cache_Control, CACHE_CONTROL, false);
|
||||
request->send(response);
|
||||
};
|
||||
|
||||
@@ -69,11 +68,11 @@ void ESP32React::begin() {
|
||||
_networkSettingsService.read([&](NetworkSettings & networkSettings) {
|
||||
DefaultHeaders & defaultHeaders = DefaultHeaders::Instance();
|
||||
if (networkSettings.enableCORS) {
|
||||
defaultHeaders.addHeader("Access-Control-Allow-Origin", networkSettings.CORSOrigin);
|
||||
defaultHeaders.addHeader("Access-Control-Allow-Headers", "Accept, Content-Type, Authorization");
|
||||
defaultHeaders.addHeader("Access-Control-Allow-Credentials", "true");
|
||||
defaultHeaders.addHeader(asyncsrv::T_CORS_ACAO, networkSettings.CORSOrigin);
|
||||
defaultHeaders.addHeader(asyncsrv::T_CORS_ACAH, "Accept, Content-Type, Authorization");
|
||||
defaultHeaders.addHeader(asyncsrv::T_CORS_ACAC, "true");
|
||||
}
|
||||
defaultHeaders.addHeader("Server", networkSettings.hostname);
|
||||
defaultHeaders.addHeader(asyncsrv::T_Server, networkSettings.hostname);
|
||||
});
|
||||
_apSettingsService.begin();
|
||||
_ntpSettingsService.begin();
|
||||
@@ -85,4 +84,5 @@ void ESP32React::loop() {
|
||||
_networkSettingsService.loop();
|
||||
_apSettingsService.loop();
|
||||
_mqttSettingsService.loop();
|
||||
_ntpSettingsService.loop();
|
||||
}
|
||||
@@ -10,20 +10,23 @@
|
||||
class JsonUtils {
|
||||
public:
|
||||
static void readIP(JsonObject root, const String & key, IPAddress & ip, const String & def) {
|
||||
IPAddress defaultIp = {};
|
||||
IPAddress defaultIp{};
|
||||
if (!defaultIp.fromString(def)) {
|
||||
defaultIp = INADDR_NONE;
|
||||
}
|
||||
readIP(root, key, ip, defaultIp);
|
||||
}
|
||||
static void readIP(JsonObject root, const String & key, IPAddress & ip, const IPAddress & defaultIp = INADDR_NONE) {
|
||||
if (!root[key].is<String>() || !ip.fromString(root[key].as<String>())) {
|
||||
const JsonVariant value = root[key];
|
||||
if (!value.is<String>() || !ip.fromString(value.as<const char *>())) {
|
||||
ip = defaultIp;
|
||||
}
|
||||
}
|
||||
static void writeIP(JsonObject root, const String & key, const IPAddress & ip) {
|
||||
if (IPUtils::isSet(ip)) {
|
||||
root[key] = ip.toString();
|
||||
char ipStr[16];
|
||||
snprintf(ipStr, sizeof(ipStr), "%u.%u.%u.%u", ip[0], ip[1], ip[2], ip[3]);
|
||||
root[key] = ipStr;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -9,7 +9,6 @@ MqttSettingsService::MqttSettingsService(AsyncWebServer * server, FS * fs, Secur
|
||||
, _disconnectedAt(0)
|
||||
, _disconnectReason(espMqttClientTypes::DisconnectReason::TCP_DISCONNECTED)
|
||||
, _mqttClient(nullptr) {
|
||||
WiFi.onEvent([this](WiFiEvent_t event, WiFiEventInfo_t info) { WiFiEvent(event); });
|
||||
addUpdateHandler([this] { onConfigUpdated(); }, false);
|
||||
}
|
||||
|
||||
@@ -29,6 +28,7 @@ MqttSettingsService::~MqttSettingsService() {
|
||||
void MqttSettingsService::begin() {
|
||||
_fsPersistence.readFromFS();
|
||||
startClient();
|
||||
_reconfigureMqtt = true;
|
||||
}
|
||||
|
||||
void MqttSettingsService::startClient() {
|
||||
@@ -41,7 +41,7 @@ void MqttSettingsService::startClient() {
|
||||
delete _mqttClient;
|
||||
_mqttClient = nullptr;
|
||||
}
|
||||
#ifndef TASMOTA_SDK
|
||||
#ifndef NO_TLS_SUPPORT
|
||||
if (_state.enableTLS) {
|
||||
isSecure = true;
|
||||
if (emsesp::EMSESP::system_.PSram() == 0) {
|
||||
@@ -79,6 +79,10 @@ void MqttSettingsService::startClient() {
|
||||
}
|
||||
|
||||
void MqttSettingsService::loop() {
|
||||
if (_state.enabled && _mqttClient && _mqttClient->connected() && !emsesp::EMSESP::system_.network_connected()) {
|
||||
// emsesp::EMSESP::logger().info("Network connection dropped, stopping MQTT client");
|
||||
_mqttClient->disconnect(true);
|
||||
}
|
||||
if (_reconfigureMqtt || (_disconnectedAt && static_cast<uint32_t>(uuid::get_uptime() - _disconnectedAt) >= MQTT_RECONNECTION_DELAY)) {
|
||||
// reconfigure MQTT client
|
||||
_disconnectedAt = configureMqtt() ? 0 : uuid::get_uptime();
|
||||
@@ -142,28 +146,6 @@ void MqttSettingsService::onConfigUpdated() {
|
||||
emsesp::EMSESP::mqtt_.start(); // reload EMS-ESP MQTT settings
|
||||
}
|
||||
|
||||
void MqttSettingsService::WiFiEvent(WiFiEvent_t event) {
|
||||
switch (event) {
|
||||
case ARDUINO_EVENT_WIFI_STA_GOT_IP:
|
||||
case ARDUINO_EVENT_ETH_GOT_IP:
|
||||
case ARDUINO_EVENT_ETH_GOT_IP6:
|
||||
case ARDUINO_EVENT_WIFI_STA_GOT_IP6:
|
||||
if (_state.enabled && !_mqttClient->connected()) {
|
||||
onConfigUpdated();
|
||||
}
|
||||
break;
|
||||
case ARDUINO_EVENT_WIFI_STA_DISCONNECTED:
|
||||
case ARDUINO_EVENT_ETH_DISCONNECTED:
|
||||
if (_state.enabled) {
|
||||
_mqttClient->disconnect(true);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool MqttSettingsService::configureMqtt() {
|
||||
// disconnect if already connected
|
||||
if (_mqttClient->connected()) {
|
||||
@@ -182,7 +164,7 @@ bool MqttSettingsService::configureMqtt() {
|
||||
}
|
||||
|
||||
_reconfigureMqtt = false;
|
||||
#ifndef TASMOTA_SDK
|
||||
#ifndef NO_TLS_SUPPORT
|
||||
if (_state.enableTLS) {
|
||||
if (_state.rootCA == "insecure") {
|
||||
emsesp::EMSESP::logger().debug("Start insecure MQTT");
|
||||
@@ -219,7 +201,7 @@ bool MqttSettingsService::configureMqtt() {
|
||||
}
|
||||
|
||||
void MqttSettings::read(MqttSettings & settings, JsonObject root) {
|
||||
#ifndef TASMOTA_SDK
|
||||
#ifndef NO_TLS_SUPPORT
|
||||
root["enableTLS"] = settings.enableTLS;
|
||||
root["rootCA"] = settings.rootCA;
|
||||
#endif
|
||||
@@ -255,10 +237,10 @@ void MqttSettings::read(MqttSettings & settings, JsonObject root) {
|
||||
}
|
||||
|
||||
StateUpdateResult MqttSettings::update(JsonObject root, MqttSettings & settings) {
|
||||
MqttSettings newSettings = {};
|
||||
bool changed = false;
|
||||
MqttSettings newSettings;
|
||||
bool changed = false;
|
||||
|
||||
#ifndef TASMOTA_SDK
|
||||
#ifndef NO_TLS_SUPPORT
|
||||
newSettings.enableTLS = root["enableTLS"];
|
||||
newSettings.rootCA = root["rootCA"] | "";
|
||||
#else
|
||||
@@ -316,6 +298,10 @@ StateUpdateResult MqttSettings::update(JsonObject root, MqttSettings & settings)
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (newSettings.ha_number_mode != settings.ha_number_mode) {
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (newSettings.entity_format != settings.entity_format) {
|
||||
changed = true;
|
||||
}
|
||||
@@ -385,7 +371,7 @@ StateUpdateResult MqttSettings::update(JsonObject root, MqttSettings & settings)
|
||||
emsesp::EMSESP::mqtt_.set_publish_time_heartbeat(newSettings.publish_time_heartbeat);
|
||||
}
|
||||
|
||||
#ifndef TASMOTA_SDK
|
||||
#ifndef NO_TLS_SUPPORT
|
||||
// strip down to certificate only
|
||||
newSettings.rootCA.replace("\r", "");
|
||||
newSettings.rootCA.replace("\n", "");
|
||||
|
||||
@@ -125,16 +125,15 @@ class MqttSettingsService : public StatefulService<MqttSettings> {
|
||||
FSPersistence<MqttSettings> _fsPersistence;
|
||||
|
||||
// variable to help manage connection
|
||||
bool _reconfigureMqtt;
|
||||
unsigned long _disconnectedAt;
|
||||
volatile bool _reconfigureMqtt;
|
||||
volatile unsigned long _disconnectedAt;
|
||||
|
||||
// connection status
|
||||
espMqttClientTypes::DisconnectReason _disconnectReason;
|
||||
volatile espMqttClientTypes::DisconnectReason _disconnectReason;
|
||||
|
||||
// the MQTT client instance
|
||||
MqttClient * _mqttClient;
|
||||
|
||||
void WiFiEvent(WiFiEvent_t event);
|
||||
void onMqttConnect(bool sessionPresent);
|
||||
void onMqttDisconnect(espMqttClientTypes::DisconnectReason reason);
|
||||
void
|
||||
|
||||
@@ -11,7 +11,6 @@ NTPSettingsService::NTPSettingsService(AsyncWebServer * server, FS * fs, Securit
|
||||
configureTime(request, json);
|
||||
});
|
||||
|
||||
WiFi.onEvent([this](WiFiEvent_t event, WiFiEventInfo_t info) { WiFiEvent(event); });
|
||||
addUpdateHandler([this] { configureNTP(); }, false);
|
||||
}
|
||||
|
||||
@@ -20,27 +19,10 @@ void NTPSettingsService::begin() {
|
||||
configureNTP();
|
||||
}
|
||||
|
||||
// handles both WiFI and Ethernet
|
||||
void NTPSettingsService::WiFiEvent(WiFiEvent_t event) {
|
||||
switch (event) {
|
||||
case ARDUINO_EVENT_WIFI_STA_DISCONNECTED:
|
||||
case ARDUINO_EVENT_ETH_DISCONNECTED:
|
||||
if (_connected && emsesp::EMSESP::system_.ntp_connected()) {
|
||||
emsesp::EMSESP::logger().info("WiFi connection dropped, stopping NTP");
|
||||
_connected = false;
|
||||
configureNTP();
|
||||
}
|
||||
break;
|
||||
|
||||
case ARDUINO_EVENT_WIFI_STA_GOT_IP:
|
||||
case ARDUINO_EVENT_ETH_GOT_IP:
|
||||
// emsesp::EMSESP::logger().info("Got IP address, starting NTP synchronization");
|
||||
_connected = true;
|
||||
void NTPSettingsService::loop() {
|
||||
if (_connected != emsesp::EMSESP::system_.network_connected()) {
|
||||
_connected = emsesp::EMSESP::system_.network_connected();
|
||||
configureNTP();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +37,9 @@ void NTPSettingsService::configureNTP() {
|
||||
} else {
|
||||
setenv("TZ", _state.tzFormat.c_str(), 1);
|
||||
tzset();
|
||||
esp_sntp_stop();
|
||||
if (esp_sntp_enabled()) {
|
||||
esp_sntp_stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +52,12 @@ void NTPSettingsService::configureTime(AsyncWebServerRequest * request, JsonVari
|
||||
tm.tm_isdst = -1; // not set by strptime, tells mktime to determine daylightsaving
|
||||
time_t time = mktime(&tm);
|
||||
struct timeval now = {.tv_sec = time, .tv_usec = {}};
|
||||
#if CONFIG_IDF_TARGET_ESP32C3
|
||||
// settimeofday and adjtime() does not work, unknown how to set time
|
||||
emsesp::EMSESP::logger().warning("manual clock setting not possible");
|
||||
#else
|
||||
settimeofday(&now, nullptr);
|
||||
#endif
|
||||
AsyncWebServerResponse * response = request->beginResponse(200);
|
||||
request->send(response);
|
||||
return;
|
||||
|
||||
@@ -44,14 +44,14 @@ class NTPSettingsService : public StatefulService<NTPSettings> {
|
||||
NTPSettingsService(AsyncWebServer * server, FS * fs, SecurityManager * securityManager);
|
||||
|
||||
void begin();
|
||||
void loop();
|
||||
static void ntp_received(struct timeval * tv);
|
||||
|
||||
private:
|
||||
HttpEndpoint<NTPSettings> _httpEndpoint;
|
||||
FSPersistence<NTPSettings> _fsPersistence;
|
||||
bool _connected;
|
||||
volatile bool _connected;
|
||||
|
||||
void WiFiEvent(WiFiEvent_t event);
|
||||
void configureNTP();
|
||||
void configureTime(AsyncWebServerRequest * request, JsonVariant json);
|
||||
};
|
||||
|
||||
@@ -9,7 +9,7 @@ NetworkSettingsService::NetworkSettingsService(AsyncWebServer * server, FS * fs,
|
||||
, _stopping(false) {
|
||||
addUpdateHandler([this] { reconfigureWiFiConnection(); }, false);
|
||||
// Eth is also bound to the WifiGeneric event handler
|
||||
WiFi.onEvent([this](WiFiEvent_t event, WiFiEventInfo_t info) { WiFiEvent(event, info); });
|
||||
// Network.onEvent([this](arduino_event_id_t event, arduino_event_info_t info) { WiFiEvent(event, info); });
|
||||
}
|
||||
|
||||
static bool formatBssid(const String & bssid, uint8_t (&mac)[6]) {
|
||||
@@ -62,24 +62,118 @@ void NetworkSettingsService::loop() {
|
||||
_lastConnectionAttempt = currentMillis;
|
||||
manageSTA();
|
||||
}
|
||||
static uint8_t connect = 0;
|
||||
enum uint8_t {
|
||||
CONNECT_IDLE = 0,
|
||||
CONNECT_WAIT_ETH,
|
||||
CONNECT_WAIT_IP4,
|
||||
CONNECT_WAIT_ETH_IP4,
|
||||
CONNECT_WAIT_IP6,
|
||||
CONNECT_WAIT_ETH_IP6,
|
||||
CONNECT_ETH_ACTIVE,
|
||||
CONNECT_WIFI_ACTIVE
|
||||
};
|
||||
switch (connect) {
|
||||
default:
|
||||
connect = CONNECT_IDLE;
|
||||
break;
|
||||
case CONNECT_IDLE:
|
||||
if (ETH.started() && _state.ssid.length() == 0) {
|
||||
emsesp::EMSESP::logger().info("ETH started");
|
||||
ETH.enableIPv6(true);
|
||||
if (_state.staticIPConfig) {
|
||||
ETH.config(_state.localIP, _state.gatewayIP, _state.subnetMask, _state.dnsIP1, _state.dnsIP2);
|
||||
}
|
||||
ETH.setHostname(emsesp::EMSESP::system_.hostname().c_str());
|
||||
connect = CONNECT_WAIT_ETH;
|
||||
}
|
||||
if (WiFi.isConnected()) {
|
||||
emsesp::EMSESP::logger().info("Wifi connected");
|
||||
if (_state.tx_power == 0) {
|
||||
setWiFiPowerOnRSSI();
|
||||
}
|
||||
mDNS_start();
|
||||
emsesp::EMSESP::system_.has_ipv6(true);
|
||||
connect = CONNECT_WAIT_IP4;
|
||||
}
|
||||
break;
|
||||
case CONNECT_WAIT_ETH:
|
||||
if (ETH.connected()) {
|
||||
emsesp::EMSESP::logger().info("ETH connected");
|
||||
emsesp::EMSESP::system_.ethernet_connected(true);
|
||||
mDNS_start();
|
||||
emsesp::EMSESP::system_.has_ipv6(true);
|
||||
connect = CONNECT_WAIT_ETH_IP4;
|
||||
}
|
||||
break;
|
||||
case CONNECT_WAIT_ETH_IP4:
|
||||
if (ETH.hasIP()) {
|
||||
emsesp::EMSESP::logger().info("Eth IPv4: %s", ETH.localIP().toString().c_str());
|
||||
connect = CONNECT_WAIT_ETH_IP6;
|
||||
}
|
||||
if (!ETH.connected()) {
|
||||
connect = CONNECT_ETH_ACTIVE;
|
||||
}
|
||||
break;
|
||||
case CONNECT_WAIT_ETH_IP6:
|
||||
if (ETH.hasLinkLocalIPv6() && ETH.hasGlobalIPv6()) {
|
||||
emsesp::EMSESP::system_.has_ipv6(true);
|
||||
connect = CONNECT_ETH_ACTIVE;
|
||||
}
|
||||
if (!ETH.connected()) {
|
||||
connect = CONNECT_ETH_ACTIVE;
|
||||
}
|
||||
break;
|
||||
case CONNECT_ETH_ACTIVE:
|
||||
if (!ETH.connected()) {
|
||||
emsesp::EMSESP::logger().info("ETH disconnected");
|
||||
emsesp::EMSESP::system_.ethernet_connected(false);
|
||||
emsesp::EMSESP::system_.has_ipv6(false);
|
||||
connect = CONNECT_IDLE;
|
||||
}
|
||||
break;
|
||||
case CONNECT_WAIT_IP4:
|
||||
if (!WiFi.localIP().toString().isEmpty()) {
|
||||
emsesp::EMSESP::logger().info("Wifi IPv4: %s", WiFi.localIP().toString().c_str());
|
||||
connect = CONNECT_WAIT_IP6;
|
||||
}
|
||||
if (!WiFi.isConnected()) {
|
||||
connect = CONNECT_ETH_ACTIVE;
|
||||
}
|
||||
break;
|
||||
case CONNECT_WAIT_IP6:
|
||||
if (WiFi.linkLocalIPv6().toString() != "::" && WiFi.globalIPv6().toString() != "::") {
|
||||
emsesp::EMSESP::logger().info("Wifi IPv6: %s, %s", WiFi.linkLocalIPv6().toString().c_str(), WiFi.globalIPv6().toString().c_str());
|
||||
emsesp::EMSESP::system_.has_ipv6(true);
|
||||
connect = CONNECT_WIFI_ACTIVE;
|
||||
}
|
||||
if (!WiFi.isConnected()) {
|
||||
connect = CONNECT_WIFI_ACTIVE;
|
||||
}
|
||||
break;
|
||||
case CONNECT_WIFI_ACTIVE:
|
||||
if (!WiFi.isConnected()) {
|
||||
emsesp::EMSESP::logger().info("WiFi disconnected");
|
||||
if (_stopping) {
|
||||
_lastConnectionAttempt = 0;
|
||||
_stopping = false;
|
||||
}
|
||||
emsesp::EMSESP::system_.has_ipv6(false);
|
||||
connect = CONNECT_IDLE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkSettingsService::manageSTA() {
|
||||
// Abort if already connected, or if we have no SSID
|
||||
if (WiFi.isConnected() || _state.ssid.length() == 0) {
|
||||
#if ESP_IDF_VERSION_MAJOR >= 5
|
||||
if (_state.ssid.length() == 0) {
|
||||
ETH.enableIPv6(true);
|
||||
}
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
// Connect or reconnect as required
|
||||
if ((WiFi.getMode() & WIFI_STA) == 0) {
|
||||
#if ESP_IDF_VERSION_MAJOR >= 5
|
||||
WiFi.enableIPv6(true);
|
||||
#endif
|
||||
if (_state.staticIPConfig) {
|
||||
WiFi.config(_state.localIP, _state.gatewayIP, _state.subnetMask, _state.dnsIP1, _state.dnsIP2); // configure for static IP
|
||||
}
|
||||
@@ -293,7 +387,7 @@ const char * NetworkSettingsService::disconnectReason(uint8_t code) {
|
||||
}
|
||||
|
||||
// handles both WiFI and Ethernet
|
||||
void NetworkSettingsService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) {
|
||||
void NetworkSettingsService::WiFiEvent(arduino_event_id_t event, arduino_event_info_t info) {
|
||||
#ifndef EMSESP_STANDALONE
|
||||
|
||||
switch (event) {
|
||||
@@ -305,7 +399,7 @@ void NetworkSettingsService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info)
|
||||
break;
|
||||
|
||||
case ARDUINO_EVENT_WIFI_STA_DISCONNECTED:
|
||||
connectcount_++; // count the number of WiFi reconnects
|
||||
connectcount_ = connectcount_ + 1; // count the number of WiFi reconnects
|
||||
emsesp::EMSESP::logger().warning("WiFi disconnected (#%d). Reason: %s (%d)",
|
||||
connectcount_,
|
||||
disconnectReason(info.wifi_sta_disconnected.reason),
|
||||
@@ -360,25 +454,15 @@ void NetworkSettingsService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info)
|
||||
if (_state.tx_power == 0) {
|
||||
setWiFiPowerOnRSSI();
|
||||
}
|
||||
#if ESP_IDF_VERSION_MAJOR < 5
|
||||
WiFi.enableIpV6(); // force ipv6
|
||||
#endif
|
||||
break;
|
||||
|
||||
case ARDUINO_EVENT_ETH_CONNECTED:
|
||||
#if ESP_IDF_VERSION_MAJOR < 5
|
||||
ETH.enableIpV6(); // force ipv6
|
||||
#endif
|
||||
break;
|
||||
|
||||
// IPv6 specific - WiFi/Eth
|
||||
case ARDUINO_EVENT_WIFI_STA_GOT_IP6:
|
||||
case ARDUINO_EVENT_ETH_GOT_IP6: {
|
||||
#if !TASMOTA_SDK && ESP_IDF_VERSION_MAJOR < 5
|
||||
auto ip6 = IPv6Address((uint8_t *)info.got_ip6.ip6_info.ip.addr).toString();
|
||||
#else
|
||||
auto ip6 = IPAddress(IPv6, (uint8_t *)info.got_ip6.ip6_info.ip.addr, 0).toString();
|
||||
#endif
|
||||
auto ip6 = IPAddress(IPv6, (uint8_t *)info.got_ip6.ip6_info.ip.addr, 0).toString();
|
||||
const char * link = event == ARDUINO_EVENT_ETH_GOT_IP6 ? "Eth" : "WiFi";
|
||||
if (ip6.startsWith("fe80")) {
|
||||
emsesp::EMSESP::logger().info("IPv6 (%s) local: %s", link, ip6.c_str());
|
||||
|
||||
@@ -102,12 +102,12 @@ class NetworkSettingsService : public StatefulService<NetworkSettings> {
|
||||
HttpEndpoint<NetworkSettings> _httpEndpoint;
|
||||
FSPersistence<NetworkSettings> _fsPersistence;
|
||||
|
||||
unsigned long _lastConnectionAttempt;
|
||||
bool _stopping;
|
||||
volatile unsigned long _lastConnectionAttempt;
|
||||
volatile bool _stopping;
|
||||
|
||||
uint16_t connectcount_ = 0; // number of wifi reconnects
|
||||
volatile uint16_t connectcount_ = 0; // number of wifi reconnects
|
||||
|
||||
void WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info);
|
||||
void WiFiEvent(arduino_event_id_t event, arduino_event_info_t info);
|
||||
void mDNS_start() const;
|
||||
const char * disconnectReason(uint8_t code);
|
||||
void reconfigureWiFiConnection();
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <emsesp.h>
|
||||
|
||||
#ifdef TASMOTA_SDK
|
||||
#ifdef NO_TLS_SUPPORT
|
||||
#include "lwip/dns.h"
|
||||
#endif
|
||||
|
||||
@@ -31,22 +31,13 @@ void NetworkStatus::networkStatus(AsyncWebServerRequest * request) {
|
||||
// for both connections show ethernet
|
||||
if (ethernet_connected) {
|
||||
// Ethernet
|
||||
root["local_ip"] = ETH.localIP().toString();
|
||||
#if ESP_IDF_VERSION_MAJOR < 5
|
||||
root["local_ipv6"] = ETH.localIPv6().toString();
|
||||
#else
|
||||
root["local_ipv6"] = ETH.linkLocalIPv6().toString();
|
||||
#endif
|
||||
root["local_ip"] = ETH.localIP().toString();
|
||||
root["local_ipv6"] = ETH.linkLocalIPv6().toString();
|
||||
root["mac_address"] = ETH.macAddress();
|
||||
root["subnet_mask"] = ETH.subnetMask().toString();
|
||||
root["gateway_ip"] = ETH.gatewayIP().toString();
|
||||
#ifdef TASMOTA_SDK
|
||||
IPAddress dnsIP1 = IPAddress(dns_getserver(0));
|
||||
IPAddress dnsIP2 = IPAddress(dns_getserver(1));
|
||||
#else
|
||||
IPAddress dnsIP1 = ETH.dnsIP(0);
|
||||
IPAddress dnsIP2 = ETH.dnsIP(1);
|
||||
#endif
|
||||
IPAddress dnsIP1 = ETH.dnsIP(0);
|
||||
IPAddress dnsIP2 = ETH.dnsIP(1);
|
||||
if (IPUtils::isSet(dnsIP1)) {
|
||||
root["dns_ip_1"] = dnsIP1.toString();
|
||||
}
|
||||
@@ -54,12 +45,8 @@ void NetworkStatus::networkStatus(AsyncWebServerRequest * request) {
|
||||
root["dns_ip_2"] = dnsIP2.toString();
|
||||
}
|
||||
} else if (wifi_status == WL_CONNECTED) {
|
||||
root["local_ip"] = WiFi.localIP().toString();
|
||||
#if ESP_IDF_VERSION_MAJOR < 5
|
||||
root["local_ipv6"] = WiFi.localIPv6().toString();
|
||||
#else
|
||||
root["local_ipv6"] = WiFi.linkLocalIPv6().toString();
|
||||
#endif
|
||||
root["local_ip"] = WiFi.localIP().toString();
|
||||
root["local_ipv6"] = WiFi.linkLocalIPv6().toString();
|
||||
root["mac_address"] = WiFi.macAddress();
|
||||
root["rssi"] = WiFi.RSSI();
|
||||
root["ssid"] = WiFi.SSID();
|
||||
@@ -71,14 +58,8 @@ void NetworkStatus::networkStatus(AsyncWebServerRequest * request) {
|
||||
if (WiFi.gatewayIP() != INADDR_NONE) {
|
||||
root["gateway_ip"] = WiFi.gatewayIP().toString();
|
||||
}
|
||||
|
||||
#ifdef TASMOTA_SDK
|
||||
IPAddress dnsIP1 = IPAddress(dns_getserver(0));
|
||||
IPAddress dnsIP2 = IPAddress(dns_getserver(1));
|
||||
#else
|
||||
IPAddress dnsIP1 = WiFi.dnsIP(0);
|
||||
IPAddress dnsIP2 = WiFi.dnsIP(1);
|
||||
#endif
|
||||
if (dnsIP1 != INADDR_NONE) {
|
||||
root["dns_ip_1"] = dnsIP1.toString();
|
||||
}
|
||||
|
||||
@@ -61,22 +61,27 @@ void UploadFileService::handleUpload(AsyncWebServerRequest * request, const Stri
|
||||
if (_is_firmware) {
|
||||
// Check firmware header, 0xE9 magic offset 0 indicates esp bin, chip offset 12: esp32:0, S2:2, C3:5
|
||||
#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4
|
||||
if (len > 12 && (data[0] != 0xE9 || data[12] != 0)) {
|
||||
if (len > 12 && (data[0] != ESP_IMAGE_HEADER_MAGIC || data[12] != ESP_CHIP_ID_ESP32)) {
|
||||
handleError(request, 503); // service unavailable
|
||||
return;
|
||||
}
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||
if (len > 12 && (data[0] != 0xE9 || data[12] != 2)) {
|
||||
if (len > 12 && (data[0] != ESP_IMAGE_HEADER_MAGIC || data[12] != ESP_CHIP_ID_ESP32S2)) {
|
||||
handleError(request, 503); // service unavailable
|
||||
return;
|
||||
}
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
if (len > 12 && (data[0] != 0xE9 || data[12] != 5)) {
|
||||
if (len > 12 && (data[0] != ESP_IMAGE_HEADER_MAGIC || data[12] != ESP_CHIP_ID_ESP32C3)) {
|
||||
handleError(request, 503); // service unavailable
|
||||
return;
|
||||
}
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
if (len > 12 && (data[0] != 0xE9 || data[12] != 9)) {
|
||||
if (len > 12 && (data[0] != ESP_IMAGE_HEADER_MAGIC || data[12] != ESP_CHIP_ID_ESP32S3)) {
|
||||
handleError(request, 503); // service unavailable
|
||||
return;
|
||||
}
|
||||
#elif CONFIG_IDF_TARGET_ESP32C6
|
||||
if (len > 12 && (data[0] != ESP_IMAGE_HEADER_MAGIC || data[12] != ESP_CHIP_ID_ESP32C6)) {
|
||||
handleError(request, 503); // service unavailable
|
||||
return;
|
||||
}
|
||||
|
||||
31
src/core/ModuleLibrary.cpp
Normal file
31
src/core/ModuleLibrary.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* EMS-ESP - https://github.com/emsesp/EMS-ESP
|
||||
* Copyright 2020-2025 emsesp.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#include <emsesp.h>
|
||||
|
||||
void ModuleLibrary::list(JsonObject output) {};
|
||||
|
||||
void ModuleLibrary::loop() {};
|
||||
|
||||
void ModuleLibrary::start(emsesp::EMSESP * emsesp_main, bool test_mode) {};
|
||||
|
||||
bool ModuleLibrary::enable(const char * key, const char * license, bool enable) {
|
||||
return true;
|
||||
};
|
||||
52
src/core/ModuleLibrary.h
Normal file
52
src/core/ModuleLibrary.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* EMS-ESP - https://github.com/emsesp/EMS-ESP
|
||||
* Copyright 2020-2025 emsesp.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef MODULELIBRARY_H
|
||||
#define MODULELIBRARY_H
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include <emsesp.h>
|
||||
|
||||
class ModuleLibrary {
|
||||
public:
|
||||
class Modules {
|
||||
public:
|
||||
Modules(const char * key, std::unique_ptr<Module> module)
|
||||
: key(key)
|
||||
, module(std::move(module)) {
|
||||
}
|
||||
const char * key;
|
||||
std::unique_ptr<Module> module;
|
||||
};
|
||||
|
||||
void start(emsesp::EMSESP * emsesp_main, bool test_mode = false);
|
||||
void loop();
|
||||
void list(JsonObject output);
|
||||
bool enable(const char * key, const char * license, bool enable);
|
||||
|
||||
static uuid::log::Logger logger_;
|
||||
|
||||
private:
|
||||
std::vector<Modules> modules_;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -346,23 +346,13 @@ void AnalogSensor::reload(bool get_nvs) {
|
||||
sensor.polltime_ = sensor.value() != 0 ? uuid::get_uptime() + (sensor.factor() * 1000) : 0;
|
||||
} else if (sensor.type() >= AnalogType::PWM_0 && sensor.type() <= AnalogType::PWM_2) {
|
||||
LOG_DEBUG("PWM output on GPIO %02d", sensor.gpio());
|
||||
#if ESP_IDF_VERSION_MAJOR >= 5
|
||||
ledcAttach(sensor.gpio(), sensor.factor(), 13);
|
||||
#else
|
||||
uint8_t channel = sensor.type() - AnalogType::PWM_0;
|
||||
ledcSetup(channel, sensor.factor(), 13);
|
||||
ledcAttachPin(sensor.gpio(), channel);
|
||||
#endif
|
||||
if (sensor.offset() > 100) {
|
||||
sensor.set_offset(100);
|
||||
} else if (sensor.offset() < 0) {
|
||||
sensor.set_offset(0);
|
||||
}
|
||||
#if ESP_IDF_VERSION_MAJOR >= 5
|
||||
ledcWrite(sensor.gpio(), (uint32_t)(sensor.offset() * 8191 / 100));
|
||||
#else
|
||||
ledcWrite(channel, (uint32_t)(sensor.offset() * 8191 / 100));
|
||||
#endif
|
||||
sensor.set_value(sensor.offset());
|
||||
sensor.set_uom(DeviceValueUOM::PERCENT);
|
||||
publish_sensor(sensor);
|
||||
@@ -852,6 +842,15 @@ bool AnalogSensor::get_value_info(JsonObject output, const char * cmd, const int
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!strcmp(cmd, F_(metrics))) {
|
||||
std::string metrics = get_metrics_prometheus();
|
||||
if (!metrics.empty()) {
|
||||
output["api_data"] = metrics;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// this is for a specific sensor, return the value
|
||||
const char * attribute_s = Command::get_attribute(cmd);
|
||||
|
||||
@@ -866,6 +865,35 @@ bool AnalogSensor::get_value_info(JsonObject output, const char * cmd, const int
|
||||
return false; // not found
|
||||
}
|
||||
|
||||
// generate Prometheus metrics format from analog values
|
||||
std::string AnalogSensor::get_metrics_prometheus() {
|
||||
std::string result;
|
||||
result.reserve(sensors_.size() * 140);
|
||||
char val[10];
|
||||
for (auto & sensor : sensors_) {
|
||||
result += (std::string) "# HELP emsesp_" + sensor.name() + " " + sensor.name();
|
||||
if (sensor.type() != AnalogType::DIGITAL_OUT && sensor.type() != AnalogType::DIGITAL_IN) {
|
||||
result += (std::string) ", " + EMSdevice::uom_to_string(sensor.uom());
|
||||
} else {
|
||||
result += (std::string) ", boolean";
|
||||
}
|
||||
result += (std::string) ", readable, visible";
|
||||
if (sensor.type() == AnalogType::COUNTER || sensor.type() == AnalogType::RGB || sensor.type() == AnalogType::PULSE
|
||||
|| (sensor.type() >= AnalogType::DIGITAL_OUT && sensor.type() <= AnalogType::PWM_2)
|
||||
|| (sensor.type() >= AnalogType::CNT_0 && sensor.type() <= AnalogType::CNT_2)) {
|
||||
result += (std::string) ", writable";
|
||||
}
|
||||
result += (std::string) "\n# TYPE emsesp_" + sensor.name() + " gauge\n";
|
||||
result += (std::string) "emsesp_" + sensor.name() + " ";
|
||||
if (sensor.type() != AnalogType::DIGITAL_OUT && sensor.type() != AnalogType::DIGITAL_IN) {
|
||||
result += (std::string)Helpers::render_value(val, sensor.value(), 2) + "\n";
|
||||
} else {
|
||||
result += (std::string)(sensor.value() == 0 ? "0\n" : "1\n");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// note we don't add the device and state classes here, as we do in the custom entity service
|
||||
void AnalogSensor::get_value_json(JsonObject output, const Sensor & sensor) {
|
||||
output["name"] = (const char *)sensor.name();
|
||||
@@ -1002,12 +1030,7 @@ bool AnalogSensor::command_setvalue(const char * value, const int8_t gpio) {
|
||||
}
|
||||
sensor.set_offset(val);
|
||||
sensor.set_value(val);
|
||||
#if ESP_IDF_VERSION_MAJOR >= 5
|
||||
ledcWrite(sensor.gpio(), (uint32_t)(sensor.offset() * 8191 / 100));
|
||||
#else
|
||||
uint8_t channel = sensor.type() - AnalogType::PWM_0;
|
||||
ledcWrite(channel, (uint32_t)(val * 8191 / 100));
|
||||
#endif
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -177,6 +177,7 @@ class AnalogSensor {
|
||||
bool update(uint8_t gpio, const char * name, double offset, double factor, uint8_t uom, int8_t type, bool deleted, bool is_system);
|
||||
bool get_value_info(JsonObject output, const char * cmd, const int8_t id = -1);
|
||||
void store_counters();
|
||||
std::string get_metrics_prometheus();
|
||||
static std::vector<uint8_t> exclude_types() {
|
||||
return exclude_types_;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#ifndef EMSESP_COMMAND_H_
|
||||
#define EMSESP_COMMAND_H_
|
||||
|
||||
#include <unordered_map>
|
||||
#include <map>
|
||||
|
||||
#include "console.h"
|
||||
#include <esp32-psram.h>
|
||||
@@ -153,8 +153,8 @@ class Command {
|
||||
|
||||
class SUrlParser {
|
||||
private:
|
||||
std::unordered_map<std::string, std::string> m_keysvalues;
|
||||
std::vector<std::string> m_folders;
|
||||
std::map<std::string, std::string> m_keysvalues;
|
||||
std::vector<std::string> m_folders;
|
||||
|
||||
public:
|
||||
SUrlParser() = default;
|
||||
@@ -166,7 +166,7 @@ class SUrlParser {
|
||||
return m_folders;
|
||||
};
|
||||
|
||||
std::unordered_map<std::string, std::string> & params() {
|
||||
std::map<std::string, std::string> & params() {
|
||||
return m_keysvalues;
|
||||
};
|
||||
|
||||
|
||||
@@ -285,6 +285,8 @@ enum {
|
||||
#define EMSESP_PLATFORM "ESP32S3"
|
||||
#elif CONFIG_IDF_TARGET_ESP32 || EMSESP_STANDALONE
|
||||
#define EMSESP_PLATFORM "ESP32"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C6
|
||||
#define EMSESP_PLATFORM "ESP32C6"
|
||||
#else
|
||||
#error Target CONFIG_IDF_TARGET is not supported
|
||||
#endif
|
||||
@@ -293,12 +295,9 @@ enum {
|
||||
#ifndef STRINGIZE
|
||||
#define STRINGIZE(s) #s
|
||||
#endif
|
||||
#ifdef TASMOTA_SDK
|
||||
|
||||
#define ARDUINO_VERSION_STR(major, minor, patch) "Tasmota Arduino v" STRINGIZE(major) "." STRINGIZE(minor) "." STRINGIZE(patch)
|
||||
#else
|
||||
#define ARDUINO_VERSION_STR(major, minor, patch) "ESP32 Arduino v" STRINGIZE(major) "." STRINGIZE(minor) "." STRINGIZE(patch)
|
||||
#endif
|
||||
#define ARDUINO_VERSION ARDUINO_VERSION_STR(ESP_ARDUINO_VERSION_MAJOR, ESP_ARDUINO_VERSION_MINOR, ESP_ARDUINO_VERSION_PATCH)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -72,6 +72,21 @@ const char * EMSdevice::tag_to_mqtt(int8_t tag) {
|
||||
return (DeviceValue::DeviceValueTAG_mqtt[tag > DeviceValue::NUM_TAGS ? 0 : tag]);
|
||||
}
|
||||
|
||||
uint8_t EMSdevice::tag_to_flag(const uint8_t tag) {
|
||||
if (tag >= DeviceValueTAG::TAG_HC1 && tag <= DeviceValueTAG::TAG_HC8) {
|
||||
return CommandFlag::CMD_FLAG_HC;
|
||||
} else if (tag >= DeviceValueTAG::TAG_DHW1 && tag <= DeviceValueTAG::TAG_DHW10) {
|
||||
return CommandFlag::CMD_FLAG_DHW;
|
||||
} else if (tag >= DeviceValueTAG::TAG_HS1 && tag <= DeviceValueTAG::TAG_HS16) {
|
||||
return CommandFlag::CMD_FLAG_HS;
|
||||
} else if (tag >= DeviceValueTAG::TAG_AHS1 && tag <= DeviceValueTAG::TAG_AHS1) {
|
||||
return CommandFlag::CMD_FLAG_AHS;
|
||||
} else if (tag >= DeviceValueTAG::TAG_SRC1 && tag <= DeviceValueTAG::TAG_SRC16) {
|
||||
return CommandFlag::CMD_FLAG_SRC;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// convert UOM to a char string - translating only for hours/minutes/seconds
|
||||
const char * EMSdevice::uom_to_string(uint8_t uom) {
|
||||
switch (uom) {
|
||||
@@ -89,7 +104,10 @@ const char * EMSdevice::uom_to_string(uint8_t uom) {
|
||||
}
|
||||
}
|
||||
|
||||
const char * EMSdevice::brand_to_char() {
|
||||
std::string EMSdevice::brand_to_char() {
|
||||
if (!custom_brand().empty()) {
|
||||
return custom_brand();
|
||||
}
|
||||
switch (brand_) {
|
||||
case EMSdevice::Brand::BOSCH:
|
||||
return F_(bosch);
|
||||
@@ -313,15 +331,15 @@ uint8_t EMSdevice::decode_brand(uint8_t value) {
|
||||
std::string EMSdevice::to_string() {
|
||||
// for devices that haven't been lookup yet, don't show all details
|
||||
if (product_id_ == 0) {
|
||||
return std::string(name()) + " (DeviceID:" + Helpers::hextoa(device_id_) + ")";
|
||||
return name() + " (DeviceID:" + Helpers::hextoa(device_id_) + ")";
|
||||
}
|
||||
|
||||
if (brand_ == Brand::NO_BRAND) {
|
||||
return std::string(name()) + " (DeviceID:" + Helpers::hextoa(device_id_) + ", ProductID:" + Helpers::itoa(product_id_) + ", Version:" + version_ + ")";
|
||||
if (brand_ == Brand::NO_BRAND && custom_brand().empty()) {
|
||||
return name() + " (DeviceID:" + Helpers::hextoa(device_id_) + ", ProductID:" + Helpers::itoa(product_id_) + ", Version:" + version_ + ")";
|
||||
}
|
||||
|
||||
return std::string(brand_to_char()) + " " + name() + " (DeviceID:" + Helpers::hextoa(device_id_) + ", ProductID:" + Helpers::itoa(product_id_)
|
||||
+ ", Version:" + version_ + ")";
|
||||
return brand_to_char() + " " + name() + " (DeviceID:" + Helpers::hextoa(device_id_) + ", ProductID:" + Helpers::itoa(product_id_) + ", Version:" + version_
|
||||
+ ")";
|
||||
}
|
||||
|
||||
// returns string of EMS device version and productID
|
||||
@@ -332,7 +350,7 @@ std::string EMSdevice::to_string_version() {
|
||||
// returns out brand + device name
|
||||
// translated
|
||||
std::string EMSdevice::to_string_short() {
|
||||
if (brand_ == Brand::NO_BRAND) {
|
||||
if (brand_ == Brand::NO_BRAND && custom_brand().empty()) {
|
||||
return std::string(device_type_2_device_name_translated()) + ": " + name();
|
||||
}
|
||||
|
||||
@@ -650,25 +668,21 @@ void EMSdevice::add_device_value(int8_t tag, // to b
|
||||
|
||||
// add a new command if it has a function attached
|
||||
if (has_cmd) {
|
||||
uint8_t flags = CommandFlag::ADMIN_ONLY; // executing commands require admin privileges
|
||||
|
||||
if (tag >= DeviceValueTAG::TAG_HC1 && tag <= DeviceValueTAG::TAG_HC8) {
|
||||
flags |= CommandFlag::CMD_FLAG_HC;
|
||||
} else if (tag >= DeviceValueTAG::TAG_DHW1 && tag <= DeviceValueTAG::TAG_DHW10) {
|
||||
flags |= CommandFlag::CMD_FLAG_DHW;
|
||||
} else if (tag >= DeviceValueTAG::TAG_HS1 && tag <= DeviceValueTAG::TAG_HS16) {
|
||||
flags |= CommandFlag::CMD_FLAG_HS;
|
||||
} else if (tag >= DeviceValueTAG::TAG_AHS1 && tag <= DeviceValueTAG::TAG_AHS1) {
|
||||
flags |= CommandFlag::CMD_FLAG_AHS;
|
||||
} else if (tag >= DeviceValueTAG::TAG_SRC1 && tag <= DeviceValueTAG::TAG_SRC16) {
|
||||
flags |= CommandFlag::CMD_FLAG_SRC;
|
||||
}
|
||||
|
||||
uint8_t flags = CommandFlag::ADMIN_ONLY | tag_to_flag(tag); // executing commands require admin privileges
|
||||
// add the command to our library
|
||||
Command::add(device_type_, device_id_, short_name, f, fullname, flags);
|
||||
}
|
||||
}
|
||||
|
||||
void EMSdevice::erase_device_values() {
|
||||
for (auto & dv : devicevalues_) {
|
||||
if (dv.has_cmd) {
|
||||
Command::erase_command(device_type_, dv.short_name, tag_to_flag(dv.tag));
|
||||
}
|
||||
}
|
||||
devicevalues_.clear();
|
||||
}
|
||||
|
||||
// single list of options
|
||||
void EMSdevice::register_device_value(int8_t tag,
|
||||
void * value_p,
|
||||
@@ -898,7 +912,7 @@ void EMSdevice::publish_value(void * value_p) const {
|
||||
// looks up the UOM for a given key from the device value table
|
||||
std::string EMSdevice::get_value_uom(const std::string & shortname) const {
|
||||
for (const auto & dv : devicevalues_) {
|
||||
if ((!dv.has_state(DeviceValueState::DV_WEB_EXCLUDE)) && (dv.short_name == shortname)) {
|
||||
if ((!dv.has_state(DeviceValueState::DV_WEB_EXCLUDE)) && !strcmp(dv.short_name, shortname.c_str())) {
|
||||
// ignore TIME since "minutes" is already added to the string value
|
||||
if ((dv.uom == DeviceValueUOM::NONE) || (dv.uom == DeviceValueUOM::MINUTES)) {
|
||||
break;
|
||||
@@ -1268,7 +1282,7 @@ void EMSdevice::setCustomizationEntity(const std::string & entity_id) {
|
||||
// set the min / max
|
||||
dv.set_custom_minmax();
|
||||
|
||||
if (Mqtt::ha_enabled() && dv.short_name == FL_(seltemp)[0] && (min != dv.min || max != dv.max)) {
|
||||
if (Mqtt::ha_enabled() && dv.tag <= DeviceValueTAG::TAG_HC8 && !strcmp(dv.short_name, FL_(selRoomTemp)[0]) && (min != dv.min || max != dv.max)) {
|
||||
set_climate_minmax(dv.tag, dv.min, dv.max);
|
||||
}
|
||||
|
||||
@@ -1720,8 +1734,8 @@ void EMSdevice::get_value_json(JsonObject json, DeviceValue & dv) {
|
||||
|
||||
// generate Prometheus metrics format from device values
|
||||
std::string EMSdevice::get_metrics_prometheus(const int8_t tag) {
|
||||
std::string result;
|
||||
std::unordered_map<std::string, bool> seen_metrics;
|
||||
std::string result;
|
||||
std::map<std::string, bool> seen_metrics;
|
||||
|
||||
// Helper function to check if a device value type is supported for Prometheus metrics
|
||||
auto is_supported_type = [](uint8_t type) -> bool {
|
||||
@@ -2106,9 +2120,8 @@ bool EMSdevice::generate_values(JsonObject output, const int8_t tag_filter, cons
|
||||
// create the Home Assistant configs for each device value / entity
|
||||
// this is called when an MQTT publish is done via an EMS Device in emsesp.cpp::publish_device_values()
|
||||
void EMSdevice::mqtt_ha_entity_config_create() {
|
||||
bool create_device_config = !ha_config_done(); // do we need to create the main Discovery device config with this entity?
|
||||
uint16_t count = 0;
|
||||
const char * const ** mode_options = nullptr;
|
||||
bool create_device_config = !ha_config_done(); // do we need to create the main Discovery device config with this entity?
|
||||
uint16_t count = 0;
|
||||
|
||||
// check the state of each of the device values
|
||||
// create the discovery topic if if hasn't already been created, not a command (like reset) and is active and visible
|
||||
@@ -2121,15 +2134,13 @@ void EMSdevice::mqtt_ha_entity_config_create() {
|
||||
bool needs_update = !has_config_created || (haclimate_value == 1 ? has_climate_no_rt : !has_climate_no_rt);
|
||||
|
||||
if (needs_update) {
|
||||
// if it's a thermostat go fetch the list of modes
|
||||
if (device_type() == EMSdevice::DeviceType::THERMOSTAT) {
|
||||
for (auto & dv : devicevalues_) {
|
||||
// make sure it's a type DeviceValueType::ENUM
|
||||
if ((dv.type == DeviceValueType::ENUM) && !strcmp(dv.short_name, FL_(mode)[0])) {
|
||||
// get options
|
||||
mode_options = dv.options;
|
||||
break;
|
||||
}
|
||||
const char * const ** mode_options = nullptr;
|
||||
for (const auto & d : devicevalues_) {
|
||||
// make sure mode in same circuit is DeviceValueType::ENUM
|
||||
if ((d.tag == dv.tag) && (d.type == DeviceValueType::ENUM) && !strcmp(d.short_name, FL_(mode)[0]) && (d.options_size > 0)) {
|
||||
// get options
|
||||
mode_options = d.options;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2149,24 +2160,33 @@ void EMSdevice::mqtt_ha_entity_config_create() {
|
||||
if (!dv.has_state(DeviceValueState::DV_HA_CONFIG_CREATED) && dv.has_state(DeviceValueState::DV_ACTIVE)
|
||||
&& !dv.has_state(DeviceValueState::DV_API_MQTT_EXCLUDE)) {
|
||||
// create_device_config is only done once for the EMS device. It can added to any entity, so we take the first
|
||||
if (Mqtt::publish_ha_sensor_config_dv(dv, name().c_str(), brand_to_char(), to_string_version().c_str(), false, create_device_config)) {
|
||||
if (Mqtt::publish_ha_sensor_config_dv(dv, name().c_str(), brand_to_char().c_str(), to_string_version().c_str(), false, create_device_config)) {
|
||||
dv.add_state(DeviceValueState::DV_HA_CONFIG_CREATED);
|
||||
create_device_config = false; // only create the main config once
|
||||
count++;
|
||||
}
|
||||
|
||||
// SRC thermostats mapped to connect/src1/...
|
||||
// SRC thermostats mapped to connect/src1/... always contains mode, selRoomTemp, currtemp
|
||||
if (dv.tag >= DeviceValueTAG::TAG_SRC1 && dv.tag <= DeviceValueTAG::TAG_SRC16 && !strcmp(dv.short_name, FL_(selRoomTemp)[0])) {
|
||||
const char * icon = nullptr;
|
||||
for (auto & d : devicevalues_) {
|
||||
if (d.tag == dv.tag && !strcmp(d.short_name, FL_(icon)[0]) && *(uint8_t *)(d.value_p != 0)) {
|
||||
icon = d.options[*(uint8_t *)(d.value_p)][0];
|
||||
break;
|
||||
// add modes and icon if we have one
|
||||
const char * icon = nullptr;
|
||||
const char * const ** mode_options = nullptr;
|
||||
for (const auto & d : devicevalues_) {
|
||||
if ((d.tag != dv.tag) || (d.type != DeviceValueType::ENUM)) {
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(d.short_name, FL_(mode)[0]) && (d.options_size > 0)) {
|
||||
mode_options = d.options;
|
||||
}
|
||||
if (!strcmp(d.short_name, FL_(icon)[0])) {
|
||||
uint8_t val = *(uint8_t *)(d.value_p);
|
||||
if (val != 0 && val < d.options_size) {
|
||||
icon = d.options[val][0];
|
||||
}
|
||||
}
|
||||
}
|
||||
// add all modes - auto, heat, off, cool
|
||||
// https://github.com/emsesp/EMS-ESP32/issues/2636
|
||||
Mqtt::publish_ha_climate_config(dv, true, nullptr, false, icon);
|
||||
Mqtt::publish_ha_climate_config(dv, true, mode_options, false, icon);
|
||||
count++;
|
||||
}
|
||||
|
||||
#ifndef EMSESP_STANDALONE
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include "emsdevicevalue.h"
|
||||
|
||||
#include <esp32-psram.h>
|
||||
#include <unordered_map>
|
||||
#include <map>
|
||||
|
||||
namespace emsesp {
|
||||
|
||||
@@ -55,6 +55,7 @@ class EMSdevice {
|
||||
static const char * tag_to_mqtt(int8_t tag);
|
||||
static uint8_t decode_brand(uint8_t value);
|
||||
static bool export_values(uint8_t device_type, JsonObject output, const int8_t id, const uint8_t output_target);
|
||||
static uint8_t tag_to_flag(const uint8_t tag);
|
||||
|
||||
// non static functions
|
||||
|
||||
@@ -62,7 +63,7 @@ class EMSdevice {
|
||||
const char * device_type_2_device_name_translated(); // returns translated device type name
|
||||
bool has_tags(const int8_t tag) const;
|
||||
bool has_cmd(const char * cmd, const int8_t id) const;
|
||||
const char * brand_to_char();
|
||||
std::string brand_to_char();
|
||||
std::string to_string();
|
||||
std::string to_string_short();
|
||||
std::string to_string_version();
|
||||
@@ -89,6 +90,10 @@ class EMSdevice {
|
||||
return version_;
|
||||
}
|
||||
|
||||
void version(const char * version) {
|
||||
strlcpy(version_, version, sizeof(version_));
|
||||
}
|
||||
|
||||
uint8_t brand() const {
|
||||
return brand_;
|
||||
}
|
||||
@@ -124,6 +129,14 @@ class EMSdevice {
|
||||
return custom_name_;
|
||||
}
|
||||
|
||||
// set custom brand
|
||||
void custom_brand(std::string const & custom_brand) {
|
||||
custom_brand_ = custom_brand;
|
||||
}
|
||||
|
||||
std::string custom_brand() const {
|
||||
return custom_brand_;
|
||||
}
|
||||
// set device model
|
||||
void model(std::string const & model) {
|
||||
model_ = model;
|
||||
@@ -282,6 +295,8 @@ class EMSdevice {
|
||||
int16_t min,
|
||||
uint32_t max);
|
||||
|
||||
void erase_device_values();
|
||||
|
||||
void
|
||||
register_device_value(int8_t tag, void * value_p, uint8_t type, const char * const ** options, const char * const * name, uint8_t uom, const cmd_function_p f);
|
||||
|
||||
@@ -524,12 +539,13 @@ class EMSdevice {
|
||||
uint8_t device_id_ = 0;
|
||||
uint8_t product_id_ = 0;
|
||||
char version_[6];
|
||||
const char * default_name_; // the fixed name the EMS model taken from the device library
|
||||
std::string custom_name_ = ""; // custom name
|
||||
std::string model_ = ""; // model, taken from the 0x01 telegram. see process_deviceName()
|
||||
uint8_t flags_ = 0;
|
||||
uint8_t brand_ = Brand::NO_BRAND;
|
||||
bool active_ = true;
|
||||
const char * default_name_; // the fixed name the EMS model taken from the device library
|
||||
std::string custom_name_ = ""; // custom name
|
||||
std::string custom_brand_ = ""; // custom brand
|
||||
std::string model_ = ""; // model, taken from the 0x01 telegram. see process_deviceName()
|
||||
uint8_t flags_ = 0;
|
||||
uint8_t brand_ = Brand::NO_BRAND;
|
||||
bool active_ = true;
|
||||
|
||||
bool ha_config_done_ = false;
|
||||
bool has_update_ = false;
|
||||
|
||||
@@ -84,7 +84,7 @@ uuid::log::Logger EMSESP::logger() {
|
||||
RxService EMSESP::rxservice_; // incoming Telegram Rx handler
|
||||
TxService EMSESP::txservice_; // outgoing Telegram Tx handler
|
||||
Mqtt EMSESP::mqtt_; // mqtt handler
|
||||
Modbus * EMSESP::modbus_; // modbus handler
|
||||
Modbus * EMSESP::modbus_ = nullptr; // modbus handler
|
||||
System EMSESP::system_; // core system services
|
||||
TemperatureSensor EMSESP::temperaturesensor_; // Temperature sensors
|
||||
AnalogSensor EMSESP::analogsensor_; // Analog sensors
|
||||
@@ -1307,9 +1307,17 @@ bool EMSESP::add_device(const uint8_t device_id, const uint8_t product_id, const
|
||||
// first check to see if we already have it, if so update the record
|
||||
for (auto it = emsdevices.begin(); it != emsdevices.end(); ++it) {
|
||||
if ((*it) && (*it)->is_device_id(device_id)) {
|
||||
if (product_id == 0 || (*it)->product_id() != 0) { // update only with valid product_id
|
||||
if (product_id == 0) { // no product-id, ignore
|
||||
return false;
|
||||
}
|
||||
if ((*it)->product_id() == product_id) { // update version if we have valid product_id
|
||||
if (!strcmp((*it)->version(), "00.00")) {
|
||||
(*it)->version(version);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
// product-id has changed for this device-id, delete and re-add
|
||||
(*it)->erase_device_values();
|
||||
emsdevices.erase(it); // erase the old device without product_id and re detect
|
||||
break;
|
||||
}
|
||||
@@ -1450,6 +1458,7 @@ bool EMSESP::add_device(const uint8_t device_id, const uint8_t product_id, const
|
||||
if ((e.device_id == device_id) && (e.product_id == product_id)) {
|
||||
LOG_DEBUG("Have customizations for %s with deviceID 0x%02X productID %d", e.custom_name.c_str(), device_id, product_id);
|
||||
emsdevices.back()->custom_name(e.custom_name);
|
||||
emsdevices.back()->custom_brand(e.custom_brand);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1760,7 +1769,7 @@ void EMSESP::start() {
|
||||
nvs_.begin("ems-esp", false, "nvs"); // fallback to small nvs
|
||||
}
|
||||
|
||||
LOG_DEBUG("NVS device information: %s", system_.getBBQKeesGatewayDetails().isEmpty() ? "not set" : system_.getBBQKeesGatewayDetails().c_str());
|
||||
LOG_DEBUG("Fuse device information: %s", system_.getBBQKeesGatewayDetails().isEmpty() ? "not set" : system_.getBBQKeesGatewayDetails().c_str());
|
||||
|
||||
webSettingsService.begin(); // load EMS-ESP Application settings
|
||||
|
||||
@@ -1793,12 +1802,6 @@ void EMSESP::start() {
|
||||
#endif
|
||||
}
|
||||
|
||||
// start services
|
||||
if (system_.modbus_enabled()) {
|
||||
modbus_ = new Modbus;
|
||||
modbus_->start(1, system_.modbus_port(), system_.modbus_max_clients(), system_.modbus_timeout() * 1000);
|
||||
}
|
||||
|
||||
mqtt_.start(); // mqtt init
|
||||
system_.start(); // starts commands, led, adc, button, network (sets hostname), syslog & uart
|
||||
shower_.start(); // initialize shower timer and shower alert
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include <string>
|
||||
#include <functional>
|
||||
#include <deque>
|
||||
#include <unordered_map>
|
||||
#include <map>
|
||||
#include <list>
|
||||
|
||||
#include <ArduinoJson.h>
|
||||
|
||||
@@ -86,6 +86,6 @@ using string_vector = std::vector<const char *>;
|
||||
|
||||
// Translation count - dynamically calculated at compile-time
|
||||
enum { EMSESP_TRANSLATION_COUNT_END = __COUNTER__ };
|
||||
static constexpr uint16_t EMSESP_TRANSLATION_COUNT = EMSESP_TRANSLATION_COUNT_END - EMSESP_TRANSLATION_COUNT_START - 1;
|
||||
static constexpr uint16_t EMSESP_TRANSLATION_COUNT = static_cast<int>(EMSESP_TRANSLATION_COUNT_END) - static_cast<int>(EMSESP_TRANSLATION_COUNT_START) - 1;
|
||||
|
||||
#endif
|
||||
@@ -19,14 +19,15 @@
|
||||
#ifndef EMSESP_EMSFACTORY_H_
|
||||
#define EMSESP_EMSFACTORY_H_
|
||||
|
||||
#include <map>
|
||||
#include <memory> // for unique_ptr
|
||||
#include <map>
|
||||
|
||||
#include "emsdevice.h"
|
||||
// Forward declaration
|
||||
namespace emsesp {
|
||||
class EMSdevice;
|
||||
}
|
||||
|
||||
// Macro for class registration
|
||||
// Anonymous namespace is used to make the definitions here private to the current
|
||||
// compilation unit (current file). It is equivalent to the old C static keyword.
|
||||
#define REGISTER_FACTORY(derivedClass, device_type) \
|
||||
namespace { \
|
||||
auto registry_##derivedClass = ConcreteEMSFactory<derivedClass>(device_type); \
|
||||
@@ -34,30 +35,29 @@
|
||||
|
||||
namespace emsesp {
|
||||
|
||||
class EMSdevice; // forward declaration, for gcc linking
|
||||
|
||||
class EMSFactory {
|
||||
public:
|
||||
virtual ~EMSFactory() = default;
|
||||
|
||||
// Register factory object of derived class
|
||||
// using the device_type as the unique identifier
|
||||
static auto registerFactory(const uint8_t device_type, EMSFactory * factory) -> void {
|
||||
auto & reg = EMSFactory::getRegister();
|
||||
reg[device_type] = factory;
|
||||
}
|
||||
|
||||
using FactoryMap = std::map<uint8_t, EMSFactory *>;
|
||||
|
||||
// Register factory object of derived class using the device_type as the unique identifier
|
||||
static inline auto registerFactory(const uint8_t device_type, EMSFactory * factory) -> void {
|
||||
getRegister()[device_type] = factory;
|
||||
}
|
||||
|
||||
// returns all registered classes (really only for debugging)
|
||||
static auto device_handlers() -> FactoryMap {
|
||||
return EMSFactory::getRegister();
|
||||
static inline auto device_handlers() -> const FactoryMap & {
|
||||
return getRegister();
|
||||
}
|
||||
|
||||
// Construct derived class returning an unique ptr
|
||||
static auto add(const uint8_t device_type, uint8_t device_id, uint8_t product_id, const char * version, const char * default_name, uint8_t flags, uint8_t brand)
|
||||
-> std::unique_ptr<EMSdevice> {
|
||||
return std::unique_ptr<EMSdevice>(EMSFactory::makeRaw(device_type, device_id, product_id, version, default_name, flags, brand));
|
||||
if (auto * ptr = makeRaw(device_type, device_id, product_id, version, default_name, flags, brand)) {
|
||||
return std::unique_ptr<EMSdevice>(ptr);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
virtual auto construct(uint8_t device_type, uint8_t device_id, uint8_t product_id, const char * version, const char * name, uint8_t flags, uint8_t brand) const
|
||||
@@ -65,7 +65,7 @@ class EMSFactory {
|
||||
|
||||
private:
|
||||
// Force global variable to be initialized, thus it avoids the "initialization order fiasco"
|
||||
static auto getRegister() -> FactoryMap & {
|
||||
static inline auto getRegister() -> FactoryMap & {
|
||||
static FactoryMap classRegister{};
|
||||
return classRegister;
|
||||
}
|
||||
@@ -74,11 +74,9 @@ class EMSFactory {
|
||||
// find which EMS device it is and use that class
|
||||
static auto makeRaw(const uint8_t device_type, uint8_t device_id, uint8_t product_id, const char * version, const char * name, uint8_t flags, uint8_t brand)
|
||||
-> EMSdevice * {
|
||||
auto it = EMSFactory::getRegister().find(device_type);
|
||||
if (it != EMSFactory::getRegister().end()) {
|
||||
return it->second->construct(device_type, device_id, product_id, version, name, flags, brand);
|
||||
}
|
||||
return nullptr;
|
||||
const auto & reg = getRegister();
|
||||
const auto it = reg.find(device_type);
|
||||
return (it != reg.end()) ? it->second->construct(device_type, device_id, product_id, version, name, flags, brand) : nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -86,7 +84,7 @@ template <typename DerivedClass>
|
||||
class ConcreteEMSFactory : EMSFactory {
|
||||
public:
|
||||
// Register this global object on the EMSFactory register
|
||||
ConcreteEMSFactory(const uint8_t device_type) {
|
||||
explicit ConcreteEMSFactory(const uint8_t device_type) {
|
||||
EMSFactory::registerFactory(device_type, this);
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user