mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-07-28 12:17:05 +00:00
Compare commits
100
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2b3d1517c9 | ||
|
|
0be79759d1 | ||
|
|
d47bede215 | ||
|
|
2988a244b2 | ||
|
|
8d87dc0175 | ||
|
|
21c86e666a | ||
|
|
e04f71ab47 | ||
|
|
90ae0720cf | ||
|
|
7a451dd672 | ||
|
|
b06f6aa360 | ||
|
|
6b67415c71 | ||
|
|
b095465d3a | ||
|
|
81a5d911ba | ||
|
|
48060d8d99 | ||
|
|
d303fa023f | ||
|
|
29b0cc1b32 | ||
|
|
584abd1e75 | ||
|
|
b4d8be0e59 | ||
|
|
30f5c5cb7d | ||
|
|
ae1db543ce | ||
|
|
947e1e0343 | ||
|
|
0578d720f4 | ||
|
|
211d79bbd5 | ||
|
|
91c5d60af9 | ||
|
|
0d9bc8027d | ||
|
|
bd2bdab95c | ||
|
|
c4f98fbc8e | ||
|
|
b332a513b5 | ||
|
|
e36bb714f1 | ||
|
|
6e1cde343f | ||
|
|
cce9ddd2dc | ||
|
|
51be17a436 | ||
|
|
66d27a6697 | ||
|
|
a033e458fb | ||
|
|
494436bbff | ||
|
|
23bacd0762 | ||
|
|
f131254853 | ||
|
|
657d15d962 | ||
|
|
60910da48d | ||
|
|
6cee2d0f32 | ||
|
|
533cb88a64 | ||
|
|
ffa32fe851 | ||
|
|
b900cc9389 | ||
|
|
8e11c19af6 | ||
|
|
f33ca6df78 | ||
|
|
194a230d20 | ||
|
|
7a5a432016 | ||
|
|
07511fe144 | ||
|
|
9a390136f9 | ||
|
|
27a03f166a | ||
|
|
0a63aeb8f0 | ||
|
|
22c10ac615 | ||
|
|
ac83cfa249 | ||
|
|
6ef0c08bc4 | ||
|
|
1ee965067d | ||
|
|
e46a873fce | ||
|
|
784e956c96 | ||
|
|
b6eebb330a | ||
|
|
a4fe8d42d2 | ||
|
|
fa42cadfa1 | ||
|
|
17dc6fa859 | ||
|
|
1432726dec | ||
|
|
7ba6ffa407 | ||
|
|
ab555e4d6b | ||
|
|
d4259f4e23 | ||
|
|
aef45c06f6 | ||
|
|
828f9e6a30 | ||
|
|
e79d778cf4 | ||
|
|
965eb2d994 | ||
|
|
657fccf49f | ||
|
|
228b41a1ac | ||
|
|
3bba294eb7 | ||
|
|
0254181b3e | ||
|
|
3b67282abb | ||
|
|
38af765935 | ||
|
|
ff180b085c | ||
|
|
e0785eb796 | ||
|
|
75a83787a4 | ||
|
|
65bea6343c | ||
|
|
6fe61411a0 | ||
|
|
4552e91022 | ||
|
|
cc94d70e6c | ||
|
|
2435078f76 | ||
|
|
dd2cd50d4b | ||
|
|
fe38eb629d | ||
|
|
e961507456 | ||
|
|
e5ee5644bf | ||
|
|
ac6d85e214 | ||
|
|
39c2d54aee | ||
|
|
68efd5ff9e | ||
|
|
627f516f85 | ||
|
|
a45fadf42e | ||
|
|
2ae52b849c | ||
|
|
1d8b6d346b | ||
|
|
2a5ac327d3 | ||
|
|
886101d4d4 | ||
|
|
5511ee9f38 | ||
|
|
427a22d23b | ||
|
|
d271898968 | ||
|
|
4051f0bd2e |
@@ -18,3 +18,7 @@ lib/readme.txt
|
||||
src/Custom.h
|
||||
/ESPEasy
|
||||
test/output_export.cpp
|
||||
.vscode
|
||||
.vscode/.browse.c_cpp.db*
|
||||
.vscode/c_cpp_properties.json
|
||||
.vscode/launch.json
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
|Latest Nightly | Build Status | Patreon | Ko-Fi |
|
||||
|-------|-------|-------|-------|
|
||||
| [](https://github.com/letscontrolit/ESPEasy/releases/latest) | [](https://travis-ci.org/letscontrolit/ESPEasy) | [](https://www.patreon.com/GrovkillenTDer) | [](https://ko-fi.com/grovkillentder) |
|
||||
|Latest Nightly | Build Status | Patreon | Ko-Fi | PayPal |
|
||||
|-------|-------|-------|-------|-------|
|
||||
| [](https://github.com/letscontrolit/ESPEasy/releases/latest) | [](https://travis-ci.org/letscontrolit/ESPEasy) | [](https://www.patreon.com/GrovkillenTDer) | [](https://ko-fi.com/grovkillentder) | [](https://www.paypal.me/espeasy) |
|
||||
|
||||
For ways to *support* us, see [this announcement on the forum](https://www.letscontrolit.com/forum/viewtopic.php?f=14&t=5787), or have a look at the [Patreon](https://www.patreon.com/GrovkillenTDer) or [Ko-Fi](https://ko-fi.com/grovkillentder) links above.
|
||||
For ways to *support* us, see [this announcement on the forum](https://www.letscontrolit.com/forum/viewtopic.php?f=14&t=5787), or have a look at the [Patreon](https://www.patreon.com/GrovkillenTDer), [Ko-Fi](https://ko-fi.com/grovkillentder) or [PayPal](https://www.paypal.me/espeasy) links above.
|
||||
|
||||
# ESPEasy (development branch)
|
||||
|
||||
|
||||
+2
-1
@@ -22,7 +22,8 @@ for ENV in \
|
||||
dev_ESP8266PUYA_1024_VCC\
|
||||
hard_SONOFF_POW\
|
||||
hard_Shelly_1\
|
||||
esp32dev;\
|
||||
esp32dev\
|
||||
esp32test_1M8_partition;\
|
||||
do
|
||||
echo
|
||||
echo "### Deploying environment $ENV for version $VERSION"
|
||||
|
||||
Vendored
+61
@@ -0,0 +1,61 @@
|
||||
_____ ____ ____
|
||||
| ____/ ___|| _ \ ___ __ _ ___ _ _
|
||||
| _| \___ \| |_) / _ \/ _` / __| | | |
|
||||
| |___ ___) | __/ __/ (_| \__ \ |_| |
|
||||
|_____|____/|_| \___|\__,_|___/\__, |
|
||||
|___/
|
||||
|
||||
|
||||
This is the distribution folder for ESPeasy.
|
||||
In here you will find a flash tool to program the ESP module.
|
||||
|
||||
Also a number of binary images is included.
|
||||
|
||||
The filename is quite descriptive:
|
||||
ESP_Easy_mega-<date>_<buildType>_<chip>_<memorySize>.bin
|
||||
|
||||
Build type can be: (differ in included plugins)
|
||||
- normal => Only Stable plugins and controllers
|
||||
- test => Stable + Testing
|
||||
- dev => Stable + Testing + Development
|
||||
|
||||
There is also a number of special builds:
|
||||
- normal_IR => "Normal" + IR receiver/transmitter plugins and library
|
||||
- hard_xxxxx => Special builds for some off-the-shelf hardware.
|
||||
|
||||
Chip can be:
|
||||
- ESP8266 => Most likely option
|
||||
- ESP8285 => Used in some Sonoff modules
|
||||
- ESP32 => Experimental support at this moment
|
||||
- ESP8266PUYA => For ESP modules with a flash chip labeled "PUYA" (often 1 MB)
|
||||
|
||||
The "PUYA" version deserves a bit more attention.
|
||||
If you cannot save settings, better try to see if the flash chip has "PUYA" written on it.
|
||||
If so, try the "PUYA" build.
|
||||
|
||||
MemorySize can be:
|
||||
- 1024 => 1 MB flash modules (e.g. almost all Sonoff modules)
|
||||
- 2048 => 2 MB flash modules (e.g. Shelly1/WROOM02)
|
||||
- 4096 => 4 MB flash modules (e.g. NodeMCU/ESP32)
|
||||
|
||||
ESP32 now has 2 builds:
|
||||
- esp32dev Using the default partition layout (1.4 MB for the sketch)
|
||||
- esp32test_1M8_partition Larger sketch partition (1.8MB) smaller SPIFFS (316 kB)
|
||||
|
||||
Please note that changing between those versions will destroy the settings!
|
||||
The SPIFFS partition will be lost and that contains all settings.
|
||||
|
||||
|
||||
To help recover from a bad flash, there are also blank images included.
|
||||
- blank_1MB.bin
|
||||
- blank_2MB.bin
|
||||
- blank_4MB.bin
|
||||
|
||||
When the wrong image is flashed, or the module behaves unstable, or is in a reboot loop,
|
||||
flash these images first and then the right image for the module.
|
||||
|
||||
Another great flash tool can be found here: (Windows only)
|
||||
https://github.com/Grovkillen/ESP_Easy_Flasher
|
||||
|
||||
For more information, see: https://github.com/letscontrolit/ESPEasy
|
||||
Or our forum: https://www.letscontrolit.com/forum/
|
||||
Vendored
+168
@@ -1,3 +1,171 @@
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20181001 (since mega-20180930)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Mon Oct 1 13:13:13 CEST 2018
|
||||
|
||||
TD-er (4):
|
||||
[#1824] Show stack size on main page
|
||||
[Heap] Use NO_EXTRA_4K_HEAP to get old stack address space
|
||||
[Stack] Check if a block sent to save on SPIFFS is stack allocated
|
||||
[Stack] Revert move Settings from stack to heap
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180930 (since mega-20180927)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Sun Sep 30 04:00:24 CEST 2018
|
||||
|
||||
JojoS (5):
|
||||
fixed distance reading
|
||||
on INIT, delete sensordef before adding new
|
||||
removed sensordefs helper structure
|
||||
changed implementation to use shared_ptr instead of helper structure
|
||||
minor change: unit was missing for threshold in 'state' mode
|
||||
|
||||
TD-er (2):
|
||||
[Default Settings] Properly clear settings when reset to default
|
||||
[Defaults] Other default initializations
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180927 (since mega-20180924)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Thu Sep 27 04:00:17 CEST 2018
|
||||
|
||||
TD-er (7):
|
||||
[ESP32] Change partition size (will clear all settings) and add plugins
|
||||
[Travis] Uninitialized variable in P073_7DGT
|
||||
[Stack] Move Settings from stack to heap
|
||||
[ESP32] RTOS move handle_schedule() to core1 and increase stack
|
||||
[Info] Add board name to the sysinfo page.
|
||||
[ESP32] Split new partition layout to separate build
|
||||
[Build] Add esp32test_1M8_partition build and warning on ESP32 partition
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180924 (since mega-20180923)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Mon Sep 24 04:00:20 CEST 2018
|
||||
|
||||
Benno Eigenmann (1):
|
||||
Fix platformio
|
||||
|
||||
TD-er (2):
|
||||
[MQTT] Work around for lost MQTT connection
|
||||
[ESP32] Fix I2C handling to allow I2C devices to work
|
||||
|
||||
sakinit (1):
|
||||
change to platform version core_esp32_1_3_0
|
||||
|
||||
stefan (1):
|
||||
Change type of sensor for MCP and PCF devices
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180923 (since mega-20180922)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Sun Sep 23 04:00:12 CEST 2018
|
||||
|
||||
TD-er (2):
|
||||
[MQTT import] Fix crash at boot when plugin is enabled
|
||||
[BME280] Fix slow reading of BME280 causing watchdog resets
|
||||
|
||||
sakinit (5):
|
||||
ESP32 build issues fixed
|
||||
Fix ESP32 stack overflow in addPinSelect when called from P1WifiGateway
|
||||
ESP32: Split webserver spiffs filelist into pages
|
||||
Reverted Webserver change
|
||||
ESP32 platform updated to 1.2.0; Webserver replaced by platform one
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180922 (since mega-20180916)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Sat Sep 22 04:00:22 CEST 2018
|
||||
|
||||
Gijs Noorlander (1):
|
||||
Revert "Revert "Added 2 new operators in Calculate() function""
|
||||
|
||||
TD-er (2):
|
||||
Revert "[Scheduler] Disable command scheduler"
|
||||
Revert "Revert "Fix elseif & Add if-elseif-else nesting levels""
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180916 (since mega-20180915)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Sun Sep 16 04:00:11 CEST 2018
|
||||
|
||||
Gijs Noorlander (3):
|
||||
Revert "Added 2 new operators in Calculate() function"
|
||||
Revert "Fix elseif & Add if-elseif-else nesting levels"
|
||||
Added warning to release notes 20180915
|
||||
|
||||
TD-er (1):
|
||||
[HW Watchdog] Backgroundtasks instead of yield during rules handling
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180915 (since mega-20180914)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Sat Sep 15 04:00:15 CEST 2018
|
||||
Known issue:
|
||||
Causes reboots. (see [#1748](https://github.com/letscontrolit/ESPEasy/issues/1748) )
|
||||
|
||||
|
||||
Plebs (1):
|
||||
Added 2 new operators in Calculate
|
||||
|
||||
TD-er (4):
|
||||
[Scheduler] Disable command scheduler
|
||||
[Controller settings] Validate settings on load/save
|
||||
[#1713] Make hostname-unitnumber optional & validate settings
|
||||
[#1698] Incorrect sunrise value southern hemisphere
|
||||
|
||||
svmac (4):
|
||||
Fix elseif & Add if-elseif-else nesting levels
|
||||
reenabled code about !
|
||||
some code optimization
|
||||
fix mistake
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180914 (since mega-20180910)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Fri Sep 14 04:00:17 CEST 2018
|
||||
|
||||
Gijs Noorlander (1):
|
||||
Added PayPal link
|
||||
|
||||
giddyhup (1):
|
||||
Fix IR plugin passing received code
|
||||
|
||||
Plebs (7):
|
||||
Use parameters inside rules when calling commands
|
||||
few changes
|
||||
fixed ESP32 compatibility issue
|
||||
fixed calls to F-macro
|
||||
adding more parameters to EVENT
|
||||
final version with '=' sign as a prefix to identify the formula in rules
|
||||
added %eventvalue4%
|
||||
|
||||
TD-er (2):
|
||||
[Flash tools] Add blank files and README.txt
|
||||
[CrashRecover] Disable failing step based on failed boot count
|
||||
|
||||
sakinit (1):
|
||||
Feature: Split webserver spiffs filelist into pages
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180910 (since mega-20180909)
|
||||
-------------------------------------------------
|
||||
|
||||
Vendored
+1
File diff suppressed because one or more lines are too long
Vendored
+1
File diff suppressed because one or more lines are too long
Vendored
+1
File diff suppressed because one or more lines are too long
@@ -0,0 +1,7 @@
|
||||
# Name, Type, SubType, Offset, Size, Flags
|
||||
nvs, data, nvs, 0x9000, 0x5000,
|
||||
otadata, data, ota, 0xe000, 0x2000,
|
||||
app0, app, ota_0, 0x10000, 0x1D0000,
|
||||
app1, app, ota_1, 0x1E0000,0x1D0000,
|
||||
eeprom, data, 0x99, 0x3B0000,0x1000,
|
||||
spiffs, data, spiffs, 0x3B1000,0x4F000,
|
||||
|
+42
-21
@@ -65,6 +65,7 @@ platform = https://github.com/platformio/platform-espressif8266
|
||||
|
||||
[core_esp32_0_12_0]
|
||||
platform = espressif32@0.12.0
|
||||
lib_deps = "ESP32WebServer"
|
||||
|
||||
[core_esp32_1_2_0]
|
||||
platform = espressif32@1.2.0
|
||||
@@ -76,16 +77,16 @@ platform = espressif32@1.3.0
|
||||
platform = https://github.com/platformio/platform-espressif32.git#feature/stage
|
||||
|
||||
[core_esp32]
|
||||
platform = ${core_esp32_0_12_0.platform}
|
||||
platform = ${core_esp32_1_3_0.platform}
|
||||
build_unflags = -Wall
|
||||
build_flags = -D BUILD_GIT='"${sysenv.TRAVIS_TAG}"'
|
||||
-lstdc++ -lsupc++
|
||||
lib_ignore = AS_BH1750, ESP8266WiFi, ESP8266Ping, ESP8266WebServer, ESP8266HTTPUpdateServer, ESP8266mDNS, IRremoteESP8266, ESPEasy_ESP8266Ping, SerialSensors, SDM
|
||||
lib_deps = ESP32WebServer
|
||||
lib_deps = ""
|
||||
monitor_speed = 115200
|
||||
|
||||
|
||||
|
||||
|
||||
; Build Flags:
|
||||
; -DUSE_CONFIG_OVERRIDE
|
||||
; lwIP 1.4 (Default)
|
||||
@@ -100,11 +101,13 @@ monitor_speed = 115200
|
||||
; -DVTABLES_IN_DRAM
|
||||
; VTABLES in IRAM
|
||||
; -DVTABLES_IN_IRAM
|
||||
|
||||
; NO_EXTRA_4K_HEAP - this forces the default NONOS-SDK user's heap location
|
||||
; Default currently overlaps cont stack (Arduino) with sys stack (System)
|
||||
; to save up-to 4 kB of heap.
|
||||
|
||||
[common]
|
||||
board_build.f_cpu = 80000000L
|
||||
build_unflags = ""
|
||||
build_unflags =
|
||||
build_flags = -D BUILD_GIT='"${sysenv.TRAVIS_TAG}"'
|
||||
-D NDEBUG
|
||||
-lstdc++ -lsupc++
|
||||
@@ -125,12 +128,15 @@ monitor_speed = 115200
|
||||
|
||||
[normal]
|
||||
platform = ${common.platform}
|
||||
build_flags = -DNO_EXTRA_4K_HEAP
|
||||
|
||||
[testing]
|
||||
platform = ${core_2_4_2.platform}
|
||||
build_flags = -DNO_EXTRA_4K_HEAP -DPLUGIN_BUILD_TESTING
|
||||
|
||||
[dev]
|
||||
platform = ${core_2_4_2.platform}
|
||||
build_flags = -DNO_EXTRA_4K_HEAP -DPLUGIN_BUILD_DEV
|
||||
|
||||
[ir]
|
||||
lib_ignore = ESP32_ping, ESP32WebServer
|
||||
@@ -206,6 +212,21 @@ framework = ${common.framework}
|
||||
upload_speed = ${common.upload_speed}
|
||||
monitor_speed = ${common.monitor_speed}
|
||||
|
||||
[env:esp32test_1M8_partition]
|
||||
platform = ${core_esp32.platform}
|
||||
board = esp32dev
|
||||
build_unflags = ${core_esp32.build_unflags}
|
||||
build_flags = ${core_esp32.build_flags} -DPLUGIN_SET_TEST_ESP32
|
||||
lib_deps = ${core_esp32.lib_deps}
|
||||
lib_ignore = ${core_esp32.lib_ignore}
|
||||
lib_ldf_mode = ${common.lib_ldf_mode}
|
||||
lib_archive = ${common.lib_archive}
|
||||
framework = ${common.framework}
|
||||
upload_speed = ${common.upload_speed}
|
||||
monitor_speed = ${common.monitor_speed}
|
||||
board_build.partitions = esp32_partition_app1810k_spiffs316k.csv
|
||||
board_upload.maximum_size = 1900544
|
||||
|
||||
|
||||
;;; NORMAL (STABLE) ; ****; ****; ****; ****; ****; ****; ****; ****; ****; ****; ****;;;;
|
||||
; normal version with stable plugins ;
|
||||
@@ -226,7 +247,7 @@ board_upload.maximum_size = ${esp8266_1M.board_upload.maximum_size}
|
||||
board_build.f_cpu = ${esp8266_1M.board_build.f_cpu}
|
||||
board_build.flash_mode = ${esp8266_1M.board_build.flash_mode}
|
||||
build_unflags = ${esp8266_1M.build_unflags}
|
||||
build_flags = ${esp8266_1M.build_flags}
|
||||
build_flags = ${esp8266_1M.build_flags} ${normal.build_flags}
|
||||
|
||||
; NORMAL: 1024k for esp8285 ----------------------
|
||||
[env:normal_ESP8285_1024]
|
||||
@@ -243,7 +264,7 @@ board_upload.maximum_size = ${esp8285_1M.board_upload.maximum_size}
|
||||
board_build.f_cpu = ${esp8285_1M.board_build.f_cpu}
|
||||
board_build.flash_mode = ${esp8285_1M.board_build.flash_mode}
|
||||
build_unflags = ${esp8285_1M.build_unflags}
|
||||
build_flags = ${esp8285_1M.build_flags}
|
||||
build_flags = ${esp8285_1M.build_flags} ${normal.build_flags}
|
||||
|
||||
; NORMAL: 2048k version --------------------------
|
||||
[env:normal_WROOM02_2048]
|
||||
@@ -259,7 +280,7 @@ board = ${espWroom2M.board}
|
||||
board_build.f_cpu = ${espWroom2M.board_build.f_cpu}
|
||||
board_build.flash_mode = ${espWroom2M.board_build.flash_mode}
|
||||
build_unflags = ${espWroom2M.build_unflags}
|
||||
build_flags = ${espWroom2M.build_flags}
|
||||
build_flags = ${espWroom2M.build_flags} ${normal.build_flags}
|
||||
|
||||
; NORMAL: 4096k version --------------------------
|
||||
[env:normal_ESP8266_4096]
|
||||
@@ -275,7 +296,7 @@ board = ${common.board}
|
||||
board_build.f_cpu = ${esp8266_4M.board_build.f_cpu}
|
||||
board_build.flash_mode = ${esp8266_4M.board_build.flash_mode}
|
||||
build_unflags = ${esp8266_4M.build_unflags}
|
||||
build_flags = ${esp8266_4M.build_flags}
|
||||
build_flags = ${esp8266_4M.build_flags} ${normal.build_flags}
|
||||
|
||||
|
||||
; NORMAL IR: 4096k version --------------------------
|
||||
@@ -293,7 +314,7 @@ board = ${common.board}
|
||||
board_build.f_cpu = ${esp8266_4M.board_build.f_cpu}
|
||||
board_build.flash_mode = ${esp8266_4M.board_build.flash_mode}
|
||||
build_unflags = ${esp8266_4M.build_unflags}
|
||||
build_flags = ${esp8266_4M.build_flags} -DPLUGIN_BUILD_NORMAL_IR
|
||||
build_flags = ${esp8266_4M.build_flags} ${normal.build_flags} -DPLUGIN_BUILD_NORMAL_IR
|
||||
|
||||
|
||||
;;; TESTING ; ****; ****; ****; ****; ****; ****; ****; ****; ****; ****; ****; ****; ****
|
||||
@@ -315,7 +336,7 @@ board_upload.maximum_size = ${esp8266_1M.board_upload.maximum_size}
|
||||
board_build.flash_mode = ${esp8266_1M.board_build.flash_mode}
|
||||
board_build.f_cpu = ${esp8266_1M.board_build.f_cpu}
|
||||
build_unflags = ${esp8266_1M.build_unflags}
|
||||
build_flags = ${esp8266_1M.build_flags} -D PLUGIN_BUILD_TESTING
|
||||
build_flags = ${esp8266_1M.build_flags} ${testing.build_flags}
|
||||
|
||||
; TEST: 1024k for esp8285 ------------------------
|
||||
[env:test_ESP8285_1024]
|
||||
@@ -332,7 +353,7 @@ board_build.f_cpu = ${esp8285_1M.board_build.f_cpu}
|
||||
board_build.flash_mode = ${esp8285_1M.board_build.flash_mode}
|
||||
board = ${esp8285_1M.board}
|
||||
build_unflags = ${esp8285_1M.build_unflags}
|
||||
build_flags = ${esp8285_1M.build_flags} -D PLUGIN_BUILD_TESTING
|
||||
build_flags = ${esp8285_1M.build_flags} ${testing.build_flags}
|
||||
|
||||
; TEST: 2048k version ----------------------------
|
||||
[env:test_WROOM02_2048]
|
||||
@@ -348,7 +369,7 @@ board_build.f_cpu = ${espWroom2M.board_build.f_cpu}
|
||||
board_build.flash_mode = ${espWroom2M.board_build.flash_mode}
|
||||
board = ${espWroom2M.board}
|
||||
build_unflags = ${espWroom2M.build_unflags}
|
||||
build_flags = ${espWroom2M.build_flags} -D PLUGIN_BUILD_TESTING
|
||||
build_flags = ${espWroom2M.build_flags} ${testing.build_flags}
|
||||
|
||||
; TEST: 4096k version ----------------------------
|
||||
[env:test_ESP8266_4096]
|
||||
@@ -364,7 +385,7 @@ monitor_speed = ${common.monitor_speed}
|
||||
board_build.f_cpu = ${esp8266_4M.board_build.f_cpu}
|
||||
board_build.flash_mode = ${esp8266_4M.board_build.flash_mode}
|
||||
build_unflags = ${esp8266_4M.build_unflags}
|
||||
build_flags = ${esp8266_4M.build_flags} -D PLUGIN_BUILD_TESTING
|
||||
build_flags = ${esp8266_4M.build_flags} ${testing.build_flags}
|
||||
|
||||
; TEST: 4096k version + FEATURE_ADC_VCC ----------
|
||||
[env:test_ESP8266_4096_VCC]
|
||||
@@ -380,7 +401,7 @@ monitor_speed = ${common.monitor_speed}
|
||||
board_build.f_cpu = ${esp8266_4M.board_build.f_cpu}
|
||||
board_build.flash_mode = ${esp8266_4M.board_build.flash_mode}
|
||||
build_unflags = ${esp8266_4M.build_unflags}
|
||||
build_flags = ${esp8266_4M.build_flags} -D PLUGIN_BUILD_TESTING -D FEATURE_ADC_VCC=true
|
||||
build_flags = ${esp8266_4M.build_flags} ${testing.build_flags} -D FEATURE_ADC_VCC=true
|
||||
|
||||
|
||||
|
||||
@@ -403,7 +424,7 @@ board_build.f_cpu = ${esp8266_1M.board_build.f_cpu}
|
||||
board_build.flash_mode = ${esp8266_1M.board_build.flash_mode}
|
||||
board = ${common.board}
|
||||
build_unflags = ${esp8266_1M.build_unflags}
|
||||
build_flags = ${esp8266_1M.build_flags} -D PLUGIN_BUILD_DEV
|
||||
build_flags = ${esp8266_1M.build_flags} ${dev.build_flags}
|
||||
|
||||
; DEV: 1024k for esp8285 -------------------------
|
||||
[env:dev_ESP8285_1024]
|
||||
@@ -420,7 +441,7 @@ board_build.f_cpu = ${esp8285_1M.board_build.f_cpu}
|
||||
board_build.flash_mode = ${esp8285_1M.board_build.flash_mode}
|
||||
board = ${esp8285_1M.board}
|
||||
build_unflags = ${esp8285_1M.build_unflags}
|
||||
build_flags = ${esp8285_1M.build_flags} -D PLUGIN_BUILD_DEV
|
||||
build_flags = ${esp8285_1M.build_flags} ${dev.build_flags}
|
||||
|
||||
; DEV: 2048k version -----------------------------
|
||||
[env:dev_WROOM02_2048]
|
||||
@@ -436,7 +457,7 @@ board_build.f_cpu = ${espWroom2M.board_build.f_cpu}
|
||||
board_build.flash_mode = ${espWroom2M.board_build.flash_mode}
|
||||
board = ${espWroom2M.board}
|
||||
build_unflags = ${espWroom2M.build_unflags}
|
||||
build_flags = ${espWroom2M.build_flags} -D PLUGIN_BUILD_DEV
|
||||
build_flags = ${espWroom2M.build_flags} ${dev.build_flags}
|
||||
|
||||
; DEV : 4096k version ----------------------------
|
||||
[env:dev_ESP8266_4096]
|
||||
@@ -452,7 +473,7 @@ monitor_speed = ${common.monitor_speed}
|
||||
board_build.f_cpu = ${esp8266_4M.board_build.f_cpu}
|
||||
board_build.flash_mode = ${esp8266_4M.board_build.flash_mode}
|
||||
build_unflags = ${esp8266_4M.build_unflags}
|
||||
build_flags = ${esp8266_4M.build_flags} -D PLUGIN_BUILD_DEV
|
||||
build_flags = ${esp8266_4M.build_flags} ${dev.build_flags}
|
||||
|
||||
|
||||
|
||||
@@ -475,7 +496,7 @@ board_upload.maximum_size = ${esp8266_1M.board_upload.maximum_size}
|
||||
board_build.f_cpu = ${esp8266_1M.board_build.f_cpu}
|
||||
board_build.flash_mode = ${esp8266_1M.board_build.flash_mode}
|
||||
build_unflags = ${esp8266_1M.build_unflags}
|
||||
build_flags = ${esp8266_1M.build_flags} -D PLUGIN_BUILD_DEV -D FLASH_QUIRK_WRITE_0_TO_1
|
||||
build_flags = ${esp8266_1M.build_flags} ${dev.build_flags} -D FLASH_QUIRK_WRITE_0_TO_1
|
||||
|
||||
; DEV+PUYA : 1024k version + FEATURE_ADC_VCC -----
|
||||
[env:dev_ESP8266PUYA_1024_VCC]
|
||||
@@ -492,7 +513,7 @@ board_upload.maximum_size = ${esp8266_1M.board_upload.maximum_size}
|
||||
board_build.f_cpu = ${esp8266_1M.board_build.f_cpu}
|
||||
board_build.flash_mode = ${esp8266_1M.board_build.flash_mode}
|
||||
build_unflags = ${esp8266_1M.build_unflags}
|
||||
build_flags = ${esp8266_1M.build_flags} -D PLUGIN_BUILD_DEV -D FLASH_QUIRK_WRITE_0_TO_1 -D FEATURE_ADC_VCC=true
|
||||
build_flags = ${esp8266_1M.build_flags} ${dev.build_flags} -D FLASH_QUIRK_WRITE_0_TO_1 -D FEATURE_ADC_VCC=true
|
||||
|
||||
|
||||
|
||||
|
||||
+5
-5
@@ -216,11 +216,11 @@ void ExecuteCommand(byte source, const char *Line)
|
||||
// since commands can originate from anywhere.
|
||||
TempEvent.Source = source;
|
||||
GetArgv(Line, cmd, 1);
|
||||
if (GetArgv(Line, TmpStr1, 2)) TempEvent.Par1 = str2int(TmpStr1);
|
||||
if (GetArgv(Line, TmpStr1, 3)) TempEvent.Par2 = str2int(TmpStr1);
|
||||
if (GetArgv(Line, TmpStr1, 4)) TempEvent.Par3 = str2int(TmpStr1);
|
||||
if (GetArgv(Line, TmpStr1, 5)) TempEvent.Par4 = str2int(TmpStr1);
|
||||
if (GetArgv(Line, TmpStr1, 6)) TempEvent.Par5 = str2int(TmpStr1);
|
||||
if (GetArgv(Line, TmpStr1, 2)) TempEvent.Par1 = CalculateParam(TmpStr1);
|
||||
if (GetArgv(Line, TmpStr1, 3)) TempEvent.Par2 = CalculateParam(TmpStr1);
|
||||
if (GetArgv(Line, TmpStr1, 4)) TempEvent.Par3 = CalculateParam(TmpStr1);
|
||||
if (GetArgv(Line, TmpStr1, 5)) TempEvent.Par4 = CalculateParam(TmpStr1);
|
||||
if (GetArgv(Line, TmpStr1, 6)) TempEvent.Par5 = CalculateParam(TmpStr1);
|
||||
|
||||
if (source == VALUE_SOURCE_WEB_FRONTEND) {
|
||||
// Must run immediately, to see result in web frontend
|
||||
|
||||
+11
-2
@@ -133,7 +133,7 @@ bool MQTTConnect(int controller_idx)
|
||||
{
|
||||
++mqtt_reconnect_count;
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(controller_idx, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
LoadControllerSettings(controller_idx, ControllerSettings);
|
||||
if (!ControllerSettings.checkHostReachable(true))
|
||||
return false;
|
||||
if (MQTTclient.connected()) {
|
||||
@@ -161,6 +161,15 @@ bool MQTTConnect(int controller_idx)
|
||||
clientid = F("ESPClient_");
|
||||
clientid += WiFi.macAddress();
|
||||
}
|
||||
// Work-around for 'lost connections' to the MQTT broker.
|
||||
// If the broker thinks the connection is still alive, a reconnect from the
|
||||
// client will be refused.
|
||||
// To overcome this issue, append the number of reconnects to the client ID to
|
||||
// make it different from the previous one.
|
||||
if (wifi_reconnects >= 1) {
|
||||
clientid += F("_");
|
||||
clientid += wifi_reconnects;
|
||||
}
|
||||
|
||||
String LWTTopic = ControllerSettings.MQTTLwtTopic;
|
||||
if(LWTTopic.length() == 0)
|
||||
@@ -309,7 +318,7 @@ void MQTTStatus(String& status)
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
int enabledMqttController = firstEnabledMQTTController();
|
||||
if (enabledMqttController >= 0) {
|
||||
LoadControllerSettings(enabledMqttController, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
LoadControllerSettings(enabledMqttController, ControllerSettings);
|
||||
String pubname = ControllerSettings.Subscribe;
|
||||
pubname.replace(F("/#"), F("/status"));
|
||||
parseSystemVariables(pubname, false);
|
||||
|
||||
+77
-14
@@ -68,6 +68,9 @@
|
||||
#if defined(ESP32)
|
||||
#define USE_RTOS_MULTITASKING
|
||||
#endif
|
||||
#ifdef M5STACK_ESP
|
||||
// #include <M5Stack.h>
|
||||
#endif
|
||||
|
||||
#define DEFAULT_USE_RULES false // (true|false) Enable Rules?
|
||||
|
||||
@@ -297,7 +300,11 @@
|
||||
#if defined(PLUGIN_BUILD_TESTING) || defined(PLUGIN_BUILD_DEV)
|
||||
#define DEVICES_MAX 75
|
||||
#else
|
||||
#define DEVICES_MAX 50
|
||||
#ifdef ESP32
|
||||
#define DEVICES_MAX 75
|
||||
#else
|
||||
#define DEVICES_MAX 50
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(ESP8266)
|
||||
@@ -325,6 +332,8 @@
|
||||
#define RULESETS_MAX 4
|
||||
#define RULES_BUFFER_SIZE 64
|
||||
#define NAME_FORMULA_LENGTH_MAX 40
|
||||
#define RULES_IF_MAX_NESTING_LEVEL 4
|
||||
|
||||
#define UDP_PACKETSIZE_MAX 2048
|
||||
|
||||
#define PIN_MODE_UNDEFINED 0
|
||||
@@ -396,8 +405,9 @@
|
||||
#endif
|
||||
|
||||
// Forward declaration
|
||||
struct ControllerSettingsStruct;
|
||||
void scheduleNextDelayQueue(unsigned long id, unsigned long nextTime);
|
||||
String LoadControllerSettings(int ControllerIndex, byte* memAddress, int datasize);
|
||||
String LoadControllerSettings(int ControllerIndex, ControllerSettingsStruct& controller_settings);
|
||||
String get_formatted_Controller_number(int controller_index);
|
||||
bool loglevelActiveFor(byte logLevel);
|
||||
void addToLog(byte loglevel, const String& string);
|
||||
@@ -405,6 +415,9 @@ void addToLog(byte logLevel, const __FlashStringHelper* flashString);
|
||||
void statusLED(boolean traffic);
|
||||
void backgroundtasks();
|
||||
|
||||
bool getBitFromUL(uint32_t number, byte bitnr);
|
||||
void setBitToUL(uint32_t& number, byte bitnr, bool value);
|
||||
|
||||
enum SettingsType {
|
||||
BasicSettings_Type = 0,
|
||||
TaskSettings_Type,
|
||||
@@ -515,10 +528,10 @@ bool showSettingsFileLayout = false;
|
||||
#define FILE_RULES "/rules1.txt"
|
||||
#include <WiFi.h>
|
||||
#include "esp32_ping.h"
|
||||
#include <ESP32WebServer.h>
|
||||
#include <WebServer.h>
|
||||
#include "SPIFFS.h"
|
||||
#include <rom/rtc.h>
|
||||
ESP32WebServer WebServer(80);
|
||||
WebServer WebServer(80);
|
||||
#ifdef FEATURE_MDNS
|
||||
#include <ESPmDNS.h>
|
||||
#endif
|
||||
@@ -662,17 +675,42 @@ struct SettingsStruct
|
||||
clearAll();
|
||||
}
|
||||
|
||||
// VariousBits1 defaults to 0, keep in mind when adding bit lookups.
|
||||
bool appendUnitToHostname() { return !getBitFromUL(VariousBits1, 1); }
|
||||
void appendUnitToHostname(bool value) { setBitToUL(VariousBits1, 1, !value); }
|
||||
|
||||
void validate() {
|
||||
if (UDPPort > 65535) UDPPort = 0;
|
||||
|
||||
if (Latitude < -90.0 || Latitude > 90.0) Latitude = 0.0;
|
||||
if (Longitude < -180.0 || Longitude > 180.0) Longitude = 0.0;
|
||||
if (VariousBits1 > (1 << 30)) VariousBits1 = 0;
|
||||
}
|
||||
|
||||
void clearNetworkSettings() {
|
||||
for (byte i = 0; i < 4; ++i) {
|
||||
IP[i] = 0;
|
||||
Gateway[i] = 0;
|
||||
Subnet[i] = 0;
|
||||
DNS[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void clearAll() {
|
||||
PID = 0;
|
||||
Version = 0;
|
||||
Build = 0;
|
||||
IP_Octet = 0;
|
||||
Unit = 0;
|
||||
Name[0] = 0;
|
||||
NTPHost[0] = 0;
|
||||
Delay = 0;
|
||||
Pin_i2c_sda = -1;
|
||||
Pin_i2c_scl = -1;
|
||||
Pin_status_led = -1;
|
||||
Pin_sd_cs = -1;
|
||||
for (byte i = 0; i < 17; ++i) { PinBootStates[i] = 0; }
|
||||
for (byte i = 0; i < 4; ++i) { Syslog_IP[i] = 0; }
|
||||
UDPPort = 0;
|
||||
SyslogLevel = 0;
|
||||
SerialLogLevel = 0;
|
||||
@@ -697,13 +735,17 @@ struct SettingsStruct
|
||||
Pin_status_led_Inversed = false;
|
||||
deepSleepOnFail = false;
|
||||
UseValueLogger = false;
|
||||
ArduinoOTAEnable = false;
|
||||
DST_Start = 0;
|
||||
DST_End = 0;
|
||||
UseRTOSMultitasking = false;
|
||||
Pin_Reset = -1;
|
||||
SyslogFacility = DEFAULT_SYSLOG_FACILITY;
|
||||
StructSize = 0;
|
||||
StructSize = sizeof(SettingsStruct);
|
||||
MQTTUseUnitNameAsClientId = 0;
|
||||
Latitude = 0.0;
|
||||
Longitude = 0.0;
|
||||
VariousBits1 = 0;
|
||||
|
||||
for (byte i = 0; i < CONTROLLER_MAX; ++i) {
|
||||
Protocol[i] = 0;
|
||||
@@ -716,6 +758,7 @@ struct SettingsStruct
|
||||
for (byte task = 0; task < TASKS_MAX; ++task) {
|
||||
clearTask(task);
|
||||
}
|
||||
clearNetworkSettings();
|
||||
}
|
||||
|
||||
void clearTask(byte task) {
|
||||
@@ -830,6 +873,7 @@ struct SettingsStruct
|
||||
//TODO: document config.dat somewhere here
|
||||
float Latitude;
|
||||
float Longitude;
|
||||
uint32_t VariousBits1;
|
||||
|
||||
// FIXME @TD-er: As discussed in #1292, the CRC for the settings is now disabled.
|
||||
// make sure crc is the last value in the struct
|
||||
@@ -837,7 +881,10 @@ struct SettingsStruct
|
||||
// uint8_t ProgmemMd5[16]; // crc of the binary that last saved the struct to file.
|
||||
// uint8_t md5[16];
|
||||
} Settings;
|
||||
|
||||
/*
|
||||
SettingsStruct* SettingsStruct_ptr = new SettingsStruct;
|
||||
SettingsStruct& Settings = *SettingsStruct_ptr;
|
||||
*/
|
||||
|
||||
/*********************************************************************************************\
|
||||
* ControllerSettingsStruct
|
||||
@@ -870,6 +917,14 @@ struct ControllerSettingsStruct
|
||||
unsigned int MaxRetry;
|
||||
boolean DeleteOldest; // Action to perform when buffer full, delete oldest, or ignore newest.
|
||||
|
||||
void validate() {
|
||||
if (Port > 65535) Port = 0;
|
||||
if (MinimalTimeBetweenMessages < 1) MinimalTimeBetweenMessages = 100;
|
||||
if (MinimalTimeBetweenMessages > 3600000) MinimalTimeBetweenMessages = 100;
|
||||
if (MaxQueueDepth > 25) MaxQueueDepth = 10;
|
||||
if (MaxRetry > 10) MaxRetry = 10;
|
||||
}
|
||||
|
||||
IPAddress getIP() const {
|
||||
IPAddress host(IP[0], IP[1], IP[2], IP[3]);
|
||||
return host;
|
||||
@@ -1365,6 +1420,7 @@ std::map<unsigned long, systemTimerStruct> systemTimers;
|
||||
\*********************************************************************************************/
|
||||
struct pinStatesStruct
|
||||
{
|
||||
pinStatesStruct() : plugin(0), index(0), mode(0), value(0) {}
|
||||
byte plugin;
|
||||
byte index;
|
||||
byte mode;
|
||||
@@ -1382,18 +1438,20 @@ struct pinStatesStruct
|
||||
//max 40 bytes: ( 74 - 64 ) * 4
|
||||
struct RTCStruct
|
||||
{
|
||||
RTCStruct() : ID1(0), ID2(0), unused1(false), factoryResetCounter(0),
|
||||
deepSleepState(0), bootFailedCount(0), flashDayCounter(0),
|
||||
flashCounter(0), bootCounter(0) {}
|
||||
byte ID1;
|
||||
byte ID2;
|
||||
boolean unused1;
|
||||
byte factoryResetCounter;
|
||||
byte deepSleepState;
|
||||
byte unused2;
|
||||
byte bootFailedCount;
|
||||
byte flashDayCounter;
|
||||
unsigned long flashCounter;
|
||||
unsigned long bootCounter;
|
||||
} RTC;
|
||||
|
||||
|
||||
int deviceCount = -1;
|
||||
int protocolCount = -1;
|
||||
int notificationCount = -1;
|
||||
@@ -1409,6 +1467,8 @@ float UserVar[VARS_PER_TASK * TASKS_MAX];
|
||||
\*********************************************************************************************/
|
||||
struct rulesTimerStatus
|
||||
{
|
||||
rulesTimerStatus() : timestamp(0), interval(0), paused(false) {}
|
||||
|
||||
unsigned long timestamp;
|
||||
unsigned int interval; //interval in milliseconds
|
||||
boolean paused;
|
||||
@@ -1416,11 +1476,11 @@ struct rulesTimerStatus
|
||||
|
||||
msecTimerHandlerStruct msecTimerHandler;
|
||||
|
||||
unsigned long timermqtt_interval;
|
||||
unsigned long lastSend;
|
||||
unsigned long lastWeb;
|
||||
unsigned long timermqtt_interval = 250;
|
||||
unsigned long lastSend = 0;
|
||||
unsigned long lastWeb = 0;
|
||||
byte cmd_within_mainloop = 0;
|
||||
unsigned long connectionFailures;
|
||||
unsigned long connectionFailures = 0;
|
||||
unsigned long wdcounter = 0;
|
||||
unsigned long timerAPoff = 0;
|
||||
unsigned long timerAwakeFromDeepSleep = 0;
|
||||
@@ -1570,15 +1630,18 @@ String eventBuffer = "";
|
||||
|
||||
uint32_t lowestRAM = 0;
|
||||
String lowestRAMfunction = "";
|
||||
uint32_t lowestFreeStack = 0;
|
||||
String lowestFreeStackfunction = "";
|
||||
|
||||
|
||||
bool shouldReboot=false;
|
||||
bool firstLoop=true;
|
||||
|
||||
boolean activeRuleSets[RULESETS_MAX];
|
||||
|
||||
boolean UseRTOSMultitasking;
|
||||
boolean UseRTOSMultitasking = false;
|
||||
|
||||
void (*MainLoopCall_ptr)(void);
|
||||
// void (*MainLoopCall_ptr)(void); //FIXME TD-er: No idea what this does.
|
||||
|
||||
/*********************************************************************************************\
|
||||
* TimingStats
|
||||
|
||||
+44
-6
@@ -109,6 +109,10 @@ void setup()
|
||||
WiFi.persistent(false); // Do not use SDK storage of SSID/WPA parameters
|
||||
WiFi.setAutoReconnect(false);
|
||||
setWifiMode(WIFI_OFF);
|
||||
#ifndef ESP32
|
||||
lowestFreeStack = getFreeStackWatermark();
|
||||
#endif
|
||||
lowestRAM = FreeMem();
|
||||
|
||||
Plugin_id.resize(PLUGIN_MAX);
|
||||
Task_id_to_Plugin_id.resize(TASKS_MAX);
|
||||
@@ -119,8 +123,6 @@ void setup()
|
||||
ledChannelPin[x] = -1;
|
||||
#endif
|
||||
|
||||
lowestRAM = FreeMem();
|
||||
|
||||
Serial.begin(115200);
|
||||
// Serial.print("\n\n\nBOOOTTT\n\n\n");
|
||||
|
||||
@@ -158,6 +160,7 @@ void setup()
|
||||
//warm boot
|
||||
if (readFromRTC())
|
||||
{
|
||||
RTC.bootFailedCount++;
|
||||
RTC.bootCounter++;
|
||||
readUserVarFromRTC();
|
||||
|
||||
@@ -193,6 +196,16 @@ void setup()
|
||||
fileSystemCheck();
|
||||
progMemMD5check();
|
||||
LoadSettings();
|
||||
if (RTC.bootFailedCount > 10 && RTC.bootCounter > 10) {
|
||||
byte toDisable = RTC.bootFailedCount - 10;
|
||||
toDisable = disablePlugin(toDisable);
|
||||
if (toDisable != 0) {
|
||||
toDisable = disableController(toDisable);
|
||||
}
|
||||
if (toDisable != 0) {
|
||||
toDisable = disableNotification(toDisable);
|
||||
}
|
||||
}
|
||||
|
||||
// setWifiMode(WIFI_STA);
|
||||
checkRuleSets();
|
||||
@@ -304,9 +317,17 @@ void setup()
|
||||
if(UseRTOSMultitasking){
|
||||
log = F("RTOS : Launching tasks");
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
xTaskCreatePinnedToCore(RTOS_TaskServers, "RTOS_TaskServers", 8192, NULL, 1, NULL, 1);
|
||||
xTaskCreatePinnedToCore(RTOS_TaskServers, "RTOS_TaskServers", 16384, NULL, 1, NULL, 1);
|
||||
xTaskCreatePinnedToCore(RTOS_TaskSerial, "RTOS_TaskSerial", 8192, NULL, 1, NULL, 1);
|
||||
xTaskCreatePinnedToCore(RTOS_Task10ps, "RTOS_Task10ps", 8192, NULL, 1, NULL, 1);
|
||||
xTaskCreatePinnedToCore(
|
||||
RTOS_HandleSchedule, /* Function to implement the task */
|
||||
"RTOS_HandleSchedule", /* Name of the task */
|
||||
16384, /* Stack size in words */
|
||||
NULL, /* Task input parameter */
|
||||
1, /* Priority of the task */
|
||||
NULL, /* Task handle. */
|
||||
1); /* Core where the task should run */
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -353,6 +374,14 @@ void RTOS_Task10ps( void * parameter )
|
||||
run10TimesPerSecond();
|
||||
}
|
||||
}
|
||||
|
||||
void RTOS_HandleSchedule( void * parameter )
|
||||
{
|
||||
while (true){
|
||||
handle_schedule();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
int firstEnabledMQTTController() {
|
||||
@@ -435,8 +464,11 @@ int getLoopCountPerSec() {
|
||||
\*********************************************************************************************/
|
||||
void loop()
|
||||
{
|
||||
/*
|
||||
//FIXME TD-er: No idea what this does.
|
||||
if(MainLoopCall_ptr)
|
||||
MainLoopCall_ptr();
|
||||
*/
|
||||
|
||||
updateLoopStats();
|
||||
|
||||
@@ -465,7 +497,10 @@ void loop()
|
||||
firstLoop = false;
|
||||
timerAwakeFromDeepSleep = millis(); // Allow to run for "awake" number of seconds, now we have wifi.
|
||||
// schedule_all_task_device_timers(); Disabled for now, since we are now using queues for controllers.
|
||||
}
|
||||
|
||||
RTC.bootFailedCount = 0;
|
||||
saveToRTC();
|
||||
}
|
||||
|
||||
// Deep sleep mode, just run all tasks one (more) time and go back to sleep as fast as possible
|
||||
if ((firstLoopConnectionsEstablished || readyForSleep()) && isDeepSleepEnabled())
|
||||
@@ -480,7 +515,10 @@ void loop()
|
||||
//normal mode, run each task when its time
|
||||
else
|
||||
{
|
||||
handle_schedule();
|
||||
if (!UseRTOSMultitasking) {
|
||||
// On ESP32 the schedule is executed on the 2nd core.
|
||||
handle_schedule();
|
||||
}
|
||||
}
|
||||
|
||||
backgroundtasks();
|
||||
@@ -831,7 +869,7 @@ void backgroundtasks()
|
||||
/*
|
||||
// Remove this watchdog feed for now.
|
||||
// See https://github.com/letscontrolit/ESPEasy/issues/1722#issuecomment-419659193
|
||||
|
||||
|
||||
#ifdef ESP32
|
||||
// Have to find a similar function to call ESP32's esp_task_wdt_feed();
|
||||
#else
|
||||
|
||||
+66
-5
@@ -147,6 +147,7 @@ String SaveSettings(void)
|
||||
// Settings have changed, save to file.
|
||||
memcpy(Settings.md5, tmp_md5, 16);
|
||||
*/
|
||||
Settings.validate();
|
||||
err=SaveToFile((char*)FILE_CONFIG, 0, (byte*)&Settings, sizeof(Settings));
|
||||
if (err.length())
|
||||
return(err);
|
||||
@@ -182,6 +183,7 @@ String LoadSettings()
|
||||
err=LoadFromFile((char*)FILE_CONFIG, 0, (byte*)&Settings, sizeof( SettingsStruct));
|
||||
if (err.length())
|
||||
return(err);
|
||||
Settings.validate();
|
||||
|
||||
// FIXME @TD-er: As discussed in #1292, the CRC for the settings is now disabled.
|
||||
/*
|
||||
@@ -219,6 +221,51 @@ String LoadSettings()
|
||||
return(err);
|
||||
}
|
||||
|
||||
/********************************************************************************************\
|
||||
Disable Plugin, based on bootFailedCount
|
||||
\*********************************************************************************************/
|
||||
byte disablePlugin(byte bootFailedCount) {
|
||||
for (byte i = 0; i < TASKS_MAX && bootFailedCount > 0; ++i) {
|
||||
if (Settings.TaskDeviceEnabled[i]) {
|
||||
--bootFailedCount;
|
||||
if (bootFailedCount == 0) {
|
||||
Settings.TaskDeviceEnabled[i] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return bootFailedCount;
|
||||
}
|
||||
|
||||
/********************************************************************************************\
|
||||
Disable Controller, based on bootFailedCount
|
||||
\*********************************************************************************************/
|
||||
byte disableController(byte bootFailedCount) {
|
||||
for (byte i = 0; i < CONTROLLER_MAX && bootFailedCount > 0; ++i) {
|
||||
if (Settings.ControllerEnabled[i]) {
|
||||
--bootFailedCount;
|
||||
if (bootFailedCount == 0) {
|
||||
Settings.ControllerEnabled[i] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return bootFailedCount;
|
||||
}
|
||||
|
||||
/********************************************************************************************\
|
||||
Disable Notification, based on bootFailedCount
|
||||
\*********************************************************************************************/
|
||||
byte disableNotification(byte bootFailedCount) {
|
||||
for (byte i = 0; i < NOTIFICATION_MAX && bootFailedCount > 0; ++i) {
|
||||
if (Settings.NotificationEnabled[i]) {
|
||||
--bootFailedCount;
|
||||
if (bootFailedCount == 0) {
|
||||
Settings.NotificationEnabled[i] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return bootFailedCount;
|
||||
}
|
||||
|
||||
/********************************************************************************************\
|
||||
Offsets in settings files
|
||||
\*********************************************************************************************/
|
||||
@@ -388,20 +435,25 @@ String LoadCustomTaskSettings(int TaskIndex, byte* memAddress, int datasize)
|
||||
/********************************************************************************************\
|
||||
Save Controller settings to SPIFFS
|
||||
\*********************************************************************************************/
|
||||
String SaveControllerSettings(int ControllerIndex, byte* memAddress, int datasize)
|
||||
String SaveControllerSettings(int ControllerIndex, ControllerSettingsStruct& controller_settings)
|
||||
{
|
||||
checkRAM(F("SaveControllerSettings"));
|
||||
return SaveToFile(ControllerSettings_Type, ControllerIndex, (char*)FILE_CONFIG, memAddress, datasize);
|
||||
controller_settings.validate(); // Make sure the saved controller settings have proper values.
|
||||
return SaveToFile(ControllerSettings_Type, ControllerIndex,
|
||||
(char*)FILE_CONFIG, (byte*)&controller_settings, sizeof(controller_settings));
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************************************\
|
||||
Load Controller settings to SPIFFS
|
||||
\*********************************************************************************************/
|
||||
String LoadControllerSettings(int ControllerIndex, byte* memAddress, int datasize)
|
||||
{
|
||||
String LoadControllerSettings(int ControllerIndex, ControllerSettingsStruct& controller_settings) {
|
||||
checkRAM(F("LoadControllerSettings"));
|
||||
return(LoadFromFile(ControllerSettings_Type, ControllerIndex, (char*)FILE_CONFIG, memAddress, datasize));
|
||||
String result =
|
||||
LoadFromFile(ControllerSettings_Type, ControllerIndex,
|
||||
(char*)FILE_CONFIG, (byte*)&controller_settings, sizeof(controller_settings));
|
||||
controller_settings.validate(); // Make sure the loaded controller settings have proper values.
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -483,6 +535,15 @@ String InitFile(const char* fname, int datasize)
|
||||
\*********************************************************************************************/
|
||||
String SaveToFile(char* fname, int index, byte* memAddress, int datasize)
|
||||
{
|
||||
#ifndef ESP32
|
||||
if (allocatedOnStack(memAddress)) {
|
||||
String log = F("SaveToFile: ");
|
||||
log += fname;
|
||||
log += F(" ERROR, Data allocated on stack");
|
||||
addLog(LOG_LEVEL_ERROR, log);
|
||||
// return log; // FIXME TD-er: Should this be considered a breaking error?
|
||||
}
|
||||
#endif
|
||||
if (index < 0) {
|
||||
String log = F("SaveToFile: ");
|
||||
log += fname;
|
||||
|
||||
+4
-2
@@ -418,8 +418,10 @@ void setWifiMode(WiFiMode_t wifimode) {
|
||||
String WifiGetAPssid()
|
||||
{
|
||||
String ssid(Settings.Name);
|
||||
ssid+=F("_");
|
||||
ssid+=Settings.Unit;
|
||||
if (Settings.appendUnitToHostname()) {
|
||||
ssid+=F("_");
|
||||
ssid+=Settings.Unit;
|
||||
}
|
||||
return (ssid);
|
||||
}
|
||||
|
||||
|
||||
+12
-4
@@ -11,6 +11,12 @@ bool I2C_read_words(uint8_t i2caddr, I2Cdata_words& data) {
|
||||
return size == i2cdev.readWords(i2caddr, data.getRegister(), size, data.get());
|
||||
}
|
||||
|
||||
// See https://github.com/platformio/platform-espressif32/issues/126
|
||||
#ifdef ESP32
|
||||
#define END_TRANSMISSION_FLAG true
|
||||
#else
|
||||
#define END_TRANSMISSION_FLAG false
|
||||
#endif
|
||||
|
||||
//**************************************************************************/
|
||||
// Wake up I2C device
|
||||
@@ -66,7 +72,7 @@ uint8_t I2C_read8_reg(uint8_t i2caddr, byte reg, bool * is_ok) {
|
||||
|
||||
Wire.beginTransmission(i2caddr);
|
||||
Wire.write((uint8_t)reg);
|
||||
Wire.endTransmission(false);
|
||||
Wire.endTransmission(END_TRANSMISSION_FLAG);
|
||||
byte count = Wire.requestFrom(i2caddr, (byte)1);
|
||||
if (is_ok != NULL) {
|
||||
*is_ok = (count == 1);
|
||||
@@ -84,7 +90,7 @@ uint16_t I2C_read16_reg(uint8_t i2caddr, byte reg) {
|
||||
|
||||
Wire.beginTransmission(i2caddr);
|
||||
Wire.write((uint8_t)reg);
|
||||
Wire.endTransmission(false);
|
||||
Wire.endTransmission(END_TRANSMISSION_FLAG);
|
||||
Wire.requestFrom(i2caddr, (byte)2);
|
||||
value = (Wire.read() << 8) | Wire.read();
|
||||
|
||||
@@ -99,7 +105,7 @@ int32_t I2C_read24_reg(uint8_t i2caddr, byte reg) {
|
||||
|
||||
Wire.beginTransmission(i2caddr);
|
||||
Wire.write((uint8_t)reg);
|
||||
Wire.endTransmission(false);
|
||||
Wire.endTransmission(END_TRANSMISSION_FLAG);
|
||||
Wire.requestFrom(i2caddr, (byte)3);
|
||||
value = (((int32_t)Wire.read()) << 16) | (Wire.read() << 8) | Wire.read();
|
||||
|
||||
@@ -114,7 +120,7 @@ int32_t I2C_read32_reg(uint8_t i2caddr, byte reg) {
|
||||
|
||||
Wire.beginTransmission(i2caddr);
|
||||
Wire.write((uint8_t)reg);
|
||||
Wire.endTransmission(false);
|
||||
Wire.endTransmission(END_TRANSMISSION_FLAG);
|
||||
Wire.requestFrom(i2caddr, (byte)3);
|
||||
value = (((int32_t)Wire.read()) <<24) | (((uint32_t)Wire.read()) << 16) | (Wire.read() << 8) | Wire.read();
|
||||
|
||||
@@ -139,3 +145,5 @@ int16_t I2C_readS16_reg(uint8_t i2caddr, byte reg) {
|
||||
int16_t I2C_readS16_LE_reg(uint8_t i2caddr, byte reg) {
|
||||
return (int16_t)I2C_read16_LE_reg(i2caddr, reg);
|
||||
}
|
||||
|
||||
#undef END_TRANSMISSION_FLAG
|
||||
|
||||
+304
-78
@@ -12,6 +12,62 @@ struct tcp_pcb;
|
||||
extern struct tcp_pcb* tcp_tw_pcbs;
|
||||
extern "C" void tcp_abort (struct tcp_pcb* pcb);
|
||||
|
||||
// For keeping track of 'cont' stack
|
||||
// See: https://github.com/esp8266/Arduino/issues/2557
|
||||
// https://github.com/esp8266/Arduino/issues/5148#issuecomment-424329183
|
||||
// https://github.com/letscontrolit/ESPEasy/issues/1824
|
||||
#ifndef ESP32
|
||||
#if defined(ARDUINO_ESP8266_RELEASE_2_3_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_1)
|
||||
// All version before core 2.4.2
|
||||
extern "C" {
|
||||
#include <cont.h>
|
||||
extern cont_t g_cont;
|
||||
}
|
||||
|
||||
uint32_t getCurrentFreeStack() {
|
||||
register uint32_t *sp asm("a1");
|
||||
return 4 * (sp - g_cont.stack);
|
||||
}
|
||||
|
||||
uint32_t getFreeStackWatermark() {
|
||||
return cont_get_free_stack(&g_cont);
|
||||
}
|
||||
|
||||
bool allocatedOnStack(const void* address) {
|
||||
register uint32_t *sp asm("a1");
|
||||
if (sp < address) return false;
|
||||
return g_cont.stack < address;
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
// All version from core 2.4.2
|
||||
// See: https://github.com/esp8266/Arduino/pull/5018
|
||||
// https://github.com/esp8266/Arduino/pull/4553
|
||||
extern "C" {
|
||||
#include <cont.h>
|
||||
extern cont_t* g_pcont;
|
||||
}
|
||||
|
||||
uint32_t getCurrentFreeStack() {
|
||||
// https://github.com/esp8266/Arduino/issues/2557
|
||||
register uint32_t *sp asm("a1");
|
||||
return 4 * (sp - g_pcont->stack);
|
||||
}
|
||||
|
||||
uint32_t getFreeStackWatermark() {
|
||||
return cont_get_free_stack(g_pcont);
|
||||
}
|
||||
|
||||
bool allocatedOnStack(const void* address) {
|
||||
register uint32_t *sp asm("a1");
|
||||
if (sp < address) return false;
|
||||
return g_pcont->stack < address;
|
||||
}
|
||||
|
||||
#endif // ARDUINO_ESP8266_RELEASE_2_x_x
|
||||
#endif // ESP32
|
||||
|
||||
void tcpCleanup()
|
||||
{
|
||||
|
||||
@@ -206,6 +262,19 @@ boolean hasPinState(byte plugin, byte index)
|
||||
}
|
||||
|
||||
|
||||
/*********************************************************************************************\
|
||||
Bitwise operators
|
||||
\*********************************************************************************************/
|
||||
bool getBitFromUL(uint32_t number, byte bitnr) {
|
||||
return (number >> bitnr) & 1UL;
|
||||
}
|
||||
|
||||
void setBitToUL(uint32_t& number, byte bitnr, bool value) {
|
||||
uint32_t newbit = value ? 1UL : 0UL;
|
||||
number ^= (-newbit ^ number) & (1UL << bitnr);
|
||||
}
|
||||
|
||||
|
||||
/*********************************************************************************************\
|
||||
report pin mode & state (info table) using json
|
||||
\*********************************************************************************************/
|
||||
@@ -365,11 +434,11 @@ void parseCommandString(struct EventStruct *event, const String& string)
|
||||
event->Par4 = 0;
|
||||
event->Par5 = 0;
|
||||
|
||||
if (GetArgv(command, TmpStr1, 2)) event->Par1 = str2int(TmpStr1);
|
||||
if (GetArgv(command, TmpStr1, 3)) event->Par2 = str2int(TmpStr1);
|
||||
if (GetArgv(command, TmpStr1, 4)) event->Par3 = str2int(TmpStr1);
|
||||
if (GetArgv(command, TmpStr1, 5)) event->Par4 = str2int(TmpStr1);
|
||||
if (GetArgv(command, TmpStr1, 6)) event->Par5 = str2int(TmpStr1);
|
||||
if (GetArgv(command, TmpStr1, 2)) event->Par1 = CalculateParam(TmpStr1);
|
||||
if (GetArgv(command, TmpStr1, 3)) event->Par2 = CalculateParam(TmpStr1);
|
||||
if (GetArgv(command, TmpStr1, 4)) event->Par3 = CalculateParam(TmpStr1);
|
||||
if (GetArgv(command, TmpStr1, 5)) event->Par4 = CalculateParam(TmpStr1);
|
||||
if (GetArgv(command, TmpStr1, 6)) event->Par5 = CalculateParam(TmpStr1);
|
||||
}
|
||||
|
||||
/********************************************************************************************\
|
||||
@@ -768,7 +837,7 @@ void ResetFactory(void)
|
||||
str2ip((char*)DEFAULT_SERVER, ControllerSettings.IP);
|
||||
ControllerSettings.HostName[0]=0;
|
||||
ControllerSettings.Port = DEFAULT_PORT;
|
||||
SaveControllerSettings(0, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
SaveControllerSettings(0, ControllerSettings);
|
||||
#endif
|
||||
checkRAM(F("ResetFactory2"));
|
||||
Serial.println(F("RESET: Succesful, rebooting. (you might need to press the reset button if you've justed flashed the firmware)"));
|
||||
@@ -1687,7 +1756,8 @@ float globalstack[STACK_SIZE];
|
||||
float *sp = globalstack - 1;
|
||||
float *sp_max = &globalstack[STACK_SIZE - 1];
|
||||
|
||||
#define is_operator(c) (c == '+' || c == '-' || c == '*' || c == '/' || c == '^')
|
||||
#define is_operator(c) (c == '+' || c == '-' || c == '*' || c == '/' || c == '^' || c == '%')
|
||||
#define is_unary_operator(c) (c == '!')
|
||||
|
||||
int push(float value)
|
||||
{
|
||||
@@ -1720,6 +1790,8 @@ float apply_operator(char op, float first, float second)
|
||||
return first * second;
|
||||
case '/':
|
||||
return first / second;
|
||||
case '%':
|
||||
return round(first) % round(second);
|
||||
case '^':
|
||||
return pow(first, second);
|
||||
default:
|
||||
@@ -1727,6 +1799,17 @@ float apply_operator(char op, float first, float second)
|
||||
}
|
||||
}
|
||||
|
||||
float apply_unary_operator(char op, float first)
|
||||
{
|
||||
switch (op)
|
||||
{
|
||||
case '!':
|
||||
return (round(first) == 0) ? 1 : 0;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
char *next_token(char *linep)
|
||||
{
|
||||
while (isspace(*(linep++)));
|
||||
@@ -1746,8 +1829,14 @@ int RPNCalculate(char* token)
|
||||
|
||||
if (push(apply_operator(token[0], first, second)))
|
||||
return CALCULATE_ERROR_STACK_OVERFLOW;
|
||||
}
|
||||
else // Als er nog een is, dan deze ophalen
|
||||
} else if (is_unary_operator(token[0]) && token[1] == 0)
|
||||
{
|
||||
float first = pop();
|
||||
|
||||
if (push(apply_unary_operator(token[0], first)))
|
||||
return CALCULATE_ERROR_STACK_OVERFLOW;
|
||||
|
||||
} else // Als er nog een is, dan deze ophalen
|
||||
if (push(atof(token))) // is het een waarde, dan op de stack plaatsen
|
||||
return CALCULATE_ERROR_STACK_OVERFLOW;
|
||||
|
||||
@@ -1763,10 +1852,13 @@ int op_preced(const char c)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case '!':
|
||||
return 4;
|
||||
case '^':
|
||||
return 3;
|
||||
case '*':
|
||||
case '/':
|
||||
case '%':
|
||||
return 2;
|
||||
case '+':
|
||||
case '-':
|
||||
@@ -1784,8 +1876,10 @@ bool op_left_assoc(const char c)
|
||||
case '/':
|
||||
case '+':
|
||||
case '-':
|
||||
case '%':
|
||||
return true; // left to right
|
||||
//case '!': return false; // right to left
|
||||
case '!':
|
||||
return false; // right to left
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -1799,8 +1893,10 @@ unsigned int op_arg_count(const char c)
|
||||
case '/':
|
||||
case '+':
|
||||
case '-':
|
||||
case '%':
|
||||
return 2;
|
||||
//case '!': return 1;
|
||||
case '!':
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -1820,6 +1916,12 @@ int Calculate(const char *input, float* result)
|
||||
//*sp=0; // bug, it stops calculating after 50 times
|
||||
sp = globalstack - 1;
|
||||
oc=c=0;
|
||||
|
||||
if (input[0] == '=') {
|
||||
++strpos;
|
||||
c = *strpos;
|
||||
}
|
||||
|
||||
while (strpos < strend)
|
||||
{
|
||||
// read one token from the input stream
|
||||
@@ -1835,7 +1937,7 @@ int Calculate(const char *input, float* result)
|
||||
}
|
||||
|
||||
// If the token is an operator, op1, then:
|
||||
else if (is_operator(c))
|
||||
else if (is_operator(c) || is_unary_operator(c))
|
||||
{
|
||||
*(TokenPos) = 0;
|
||||
error = RPNCalculate(token);
|
||||
@@ -1945,6 +2047,56 @@ int Calculate(const char *input, float* result)
|
||||
return CALCULATE_OK;
|
||||
}
|
||||
|
||||
int CalculateParam(char *TmpStr) {
|
||||
int returnValue;
|
||||
|
||||
// Minimize calls to the Calulate function.
|
||||
// Only if TmpStr starts with '=' then call Calculate(). Otherwise do not call it
|
||||
if (TmpStr[0] != '=') {
|
||||
returnValue=str2int(TmpStr);
|
||||
} else {
|
||||
float param=0;
|
||||
TmpStr[0] = ' '; //replace '=' with space
|
||||
int returnCode=Calculate(TmpStr, ¶m);
|
||||
if (returnCode!=CALCULATE_OK) {
|
||||
String errorDesc;
|
||||
switch (returnCode) {
|
||||
case CALCULATE_ERROR_STACK_OVERFLOW:
|
||||
errorDesc = F("Stack Overflow");
|
||||
break;
|
||||
case CALCULATE_ERROR_BAD_OPERATOR:
|
||||
errorDesc = F("Bad Operator");
|
||||
break;
|
||||
case CALCULATE_ERROR_PARENTHESES_MISMATCHED:
|
||||
errorDesc = F("Parenthesis mismatch");
|
||||
break;
|
||||
case CALCULATE_ERROR_UNKNOWN_TOKEN:
|
||||
errorDesc = F("Unknown token");
|
||||
break;
|
||||
default:
|
||||
errorDesc = F("Unknown error");
|
||||
break;
|
||||
}
|
||||
String log = String(F("CALCULATE PARAM ERROR: ")) + errorDesc;
|
||||
addLog(LOG_LEVEL_ERROR, log);
|
||||
log = F("CALCULATE PARAM ERROR details: ");
|
||||
log += TmpStr;
|
||||
log += F(" = ");
|
||||
log += round(param);
|
||||
addLog(LOG_LEVEL_ERROR, log);
|
||||
} else {
|
||||
if (loglevelActiveFor(LOG_LEVEL_DEBUG)) {
|
||||
String log = F("CALCULATE PARAM: ");
|
||||
log += TmpStr;
|
||||
log += F(" = ");
|
||||
log += round(param);
|
||||
addLog(LOG_LEVEL_DEBUG, log);
|
||||
}
|
||||
}
|
||||
returnValue=round(param); //return integer only as it's valid only for device and task id
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
void checkRuleSets(){
|
||||
for (byte x=0; x < RULESETS_MAX; x++){
|
||||
@@ -2040,10 +2192,10 @@ String rulesProcessingFile(String fileName, String& event)
|
||||
bool match = false;
|
||||
bool codeBlock = false;
|
||||
bool isCommand = false;
|
||||
bool conditional = false;
|
||||
bool condition = false;
|
||||
bool ifBranche = false;
|
||||
bool ifBrancheJustMatch = false;
|
||||
bool condition[RULES_IF_MAX_NESTING_LEVEL];
|
||||
bool ifBranche[RULES_IF_MAX_NESTING_LEVEL];
|
||||
byte ifBlock = 0;
|
||||
byte fakeIfBlock = 0;
|
||||
|
||||
byte buf[RULES_BUFFER_SIZE];
|
||||
int len = 0;
|
||||
@@ -2066,9 +2218,9 @@ String rulesProcessingFile(String fileName, String& event)
|
||||
parseCompleteNonCommentLine(
|
||||
line, event, log,
|
||||
match, codeBlock, isCommand,
|
||||
conditional, condition,
|
||||
ifBranche, ifBrancheJustMatch);
|
||||
yield();
|
||||
condition, ifBranche,
|
||||
ifBlock, fakeIfBlock);
|
||||
backgroundtasks();
|
||||
}
|
||||
|
||||
line = "";
|
||||
@@ -2088,10 +2240,11 @@ void parseCompleteNonCommentLine(
|
||||
bool& match,
|
||||
bool& codeBlock,
|
||||
bool& isCommand,
|
||||
bool& conditional,
|
||||
bool& condition,
|
||||
bool& ifBranche,
|
||||
bool& ifBrancheJustMatch) {
|
||||
bool condition[],
|
||||
bool ifBranche[],
|
||||
byte& ifBlock,
|
||||
byte& fakeIfBlock)
|
||||
{
|
||||
isCommand = true;
|
||||
|
||||
// Strip comments
|
||||
@@ -2103,6 +2256,23 @@ void parseCompleteNonCommentLine(
|
||||
// only parse [xxx#yyy] if we have a matching ruleblock or need to eval the "on" (no codeBlock)
|
||||
// This to avoid waisting CPU time...
|
||||
line = parseTemplate(line, line.length());
|
||||
|
||||
if (match && !fakeIfBlock) {
|
||||
// substitution of %eventvalue% is made here so it can be used on if statement too
|
||||
if (event.charAt(0) == '!')
|
||||
{
|
||||
line.replace(F("%eventvalue%"), event); // substitute %eventvalue% with literal event string if starting with '!'
|
||||
}
|
||||
else
|
||||
{
|
||||
int equalsPos = event.indexOf("=");
|
||||
if (equalsPos > 0)
|
||||
{
|
||||
String tmpString = event.substring(equalsPos + 1);
|
||||
line.replace(F("%eventvalue%"), tmpString); // substitute %eventvalue% with the actual value from the event
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
line.trim();
|
||||
|
||||
@@ -2117,6 +2287,8 @@ void parseCompleteNonCommentLine(
|
||||
{
|
||||
if (line.startsWith(F("on ")))
|
||||
{
|
||||
ifBlock = 0;
|
||||
fakeIfBlock = 0;
|
||||
line = line.substring(3);
|
||||
int split = line.indexOf(F(" do"));
|
||||
if (split != -1)
|
||||
@@ -2153,6 +2325,8 @@ void parseCompleteNonCommentLine(
|
||||
isCommand = false;
|
||||
codeBlock = false;
|
||||
match = false;
|
||||
ifBlock = 0;
|
||||
fakeIfBlock = 0;
|
||||
}
|
||||
|
||||
if (Settings.SerialLogLevel == LOG_LEVEL_DEBUG_DEV){
|
||||
@@ -2169,8 +2343,8 @@ void parseCompleteNonCommentLine(
|
||||
processMatchedRule(
|
||||
lcAction, action, event, log,
|
||||
match, codeBlock, isCommand,
|
||||
conditional, condition,
|
||||
ifBranche, ifBrancheJustMatch);
|
||||
condition, ifBranche,
|
||||
ifBlock, fakeIfBlock);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2179,70 +2353,101 @@ void processMatchedRule(
|
||||
bool& match,
|
||||
bool& codeBlock,
|
||||
bool& isCommand,
|
||||
bool& conditional,
|
||||
bool& condition,
|
||||
bool& ifBranche,
|
||||
bool& ifBrancheJustMatch)
|
||||
bool condition[],
|
||||
bool ifBranche[],
|
||||
byte& ifBlock,
|
||||
byte& fakeIfBlock)
|
||||
{
|
||||
int split = lcAction.indexOf(F("if ")); // check for optional "if" condition
|
||||
if (!lcAction.startsWith(F("elseif "))) {
|
||||
if (split != -1)
|
||||
{ // There is some 'if ' in the string.
|
||||
conditional = true;
|
||||
String check = lcAction.substring(split + 3);
|
||||
|
||||
log = F("[if ");
|
||||
log += check;
|
||||
log += F("]=");
|
||||
condition = ifBrancheJustMatch == false && conditionMatchExtended(check);
|
||||
if(condition == true)
|
||||
{
|
||||
ifBrancheJustMatch = true;
|
||||
}
|
||||
ifBranche = true;
|
||||
if (fakeIfBlock)
|
||||
isCommand = false;
|
||||
else if (ifBlock)
|
||||
if (condition[ifBlock-1] != ifBranche[ifBlock-1])
|
||||
isCommand = false;
|
||||
log += toString(condition);
|
||||
addLog(LOG_LEVEL_DEBUG, log);
|
||||
int split = lcAction.indexOf(F("elseif ")); // check for optional "elseif" condition
|
||||
if (split != -1)
|
||||
{
|
||||
isCommand = false;
|
||||
if (ifBlock && !fakeIfBlock)
|
||||
{
|
||||
if (ifBranche[ifBlock-1])
|
||||
{
|
||||
if (condition[ifBlock-1])
|
||||
ifBranche[ifBlock-1] = false;
|
||||
else
|
||||
{
|
||||
String check = lcAction.substring(split + 7);
|
||||
log = F("Lev.");
|
||||
log += String(ifBlock);
|
||||
log += F(": [elseif ");
|
||||
log += check;
|
||||
log += "]=";
|
||||
condition[ifBlock-1] = conditionMatchExtended(check);
|
||||
log += toString(condition[ifBlock-1]);
|
||||
addLog(LOG_LEVEL_DEBUG, log);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // Starts with 'elseif '
|
||||
String check = lcAction.substring(7);
|
||||
log = F("[elseif ");
|
||||
log += check;
|
||||
log += "]=";
|
||||
condition = ifBrancheJustMatch == false && conditionMatchExtended(check);
|
||||
if(condition == true)
|
||||
{
|
||||
split = lcAction.indexOf(F("if ")); // check for optional "if" condition
|
||||
if (split != -1)
|
||||
{
|
||||
ifBrancheJustMatch = true;
|
||||
if (ifBlock < RULES_IF_MAX_NESTING_LEVEL)
|
||||
{
|
||||
if (isCommand)
|
||||
{
|
||||
ifBlock++;
|
||||
String check = lcAction.substring(split + 3);
|
||||
log = F("Lev.");
|
||||
log += String(ifBlock);
|
||||
log += F(": [if ");
|
||||
log += check;
|
||||
log += F("]=");
|
||||
condition[ifBlock-1] = conditionMatchExtended(check);
|
||||
ifBranche[ifBlock-1] = true;
|
||||
log += toString(condition[ifBlock-1]);
|
||||
addLog(LOG_LEVEL_DEBUG, log);
|
||||
}
|
||||
else
|
||||
fakeIfBlock++;
|
||||
}
|
||||
else
|
||||
{
|
||||
fakeIfBlock++;
|
||||
log = F("Lev.");
|
||||
log += String(ifBlock);
|
||||
log = F(": Error: IF Nesting level exceeded!");
|
||||
addLog(LOG_LEVEL_ERROR, log);
|
||||
}
|
||||
isCommand = false;
|
||||
}
|
||||
ifBranche = true;
|
||||
isCommand = false;
|
||||
log += toString(condition);
|
||||
addLog(LOG_LEVEL_DEBUG, log);
|
||||
}
|
||||
|
||||
if (lcAction == "else") // in case of an "else" block of actions, set ifBranche to false
|
||||
if ((lcAction == F("else")) && !fakeIfBlock) // in case of an "else" block of actions, set ifBranche to false
|
||||
{
|
||||
ifBranche = false;
|
||||
ifBranche[ifBlock-1] = false;
|
||||
isCommand = false;
|
||||
if (loglevelActiveFor(LOG_LEVEL_DEBUG)) {
|
||||
String log = F("else = ");
|
||||
log += toString(conditional && (condition == ifBranche));
|
||||
log = F("Lev.");
|
||||
log += String(ifBlock);
|
||||
log += F(": [else]=");
|
||||
log += toString(condition[ifBlock-1] == ifBranche[ifBlock-1]);
|
||||
addLog(LOG_LEVEL_DEBUG, log);
|
||||
}
|
||||
}
|
||||
|
||||
if (lcAction == "endif") // conditional block ends here
|
||||
if (lcAction == F("endif")) // conditional block ends here
|
||||
{
|
||||
conditional = false;
|
||||
if (fakeIfBlock)
|
||||
fakeIfBlock--;
|
||||
else if (ifBlock)
|
||||
ifBlock--;
|
||||
isCommand = false;
|
||||
ifBranche = false;
|
||||
ifBrancheJustMatch = false;
|
||||
}
|
||||
|
||||
// process the action if it's a command and unconditional, or conditional and the condition matches the if or else block.
|
||||
if (isCommand && ((!conditional) || (conditional && (condition == ifBranche))))
|
||||
if (isCommand)
|
||||
{
|
||||
if (event.charAt(0) == '!')
|
||||
{
|
||||
@@ -2254,7 +2459,20 @@ void processMatchedRule(
|
||||
if (equalsPos > 0)
|
||||
{
|
||||
String tmpString = event.substring(equalsPos + 1);
|
||||
action.replace(F("%eventvalue%"), tmpString); // substitute %eventvalue% in actions with the actual value from the event
|
||||
|
||||
char command[INPUT_COMMAND_SIZE];
|
||||
command[0] = 0;
|
||||
char tmpParam[INPUT_COMMAND_SIZE];
|
||||
tmpParam[0] = 0;
|
||||
tmpString.toCharArray(command, INPUT_COMMAND_SIZE);
|
||||
|
||||
if (GetArgv(command,tmpParam,1)) {
|
||||
action.replace(F("%eventvalue%"), tmpParam); // for compatibility issues
|
||||
action.replace(F("%eventvalue1%"), tmpParam); // substitute %eventvalue1% in actions with the actual value from the event
|
||||
}
|
||||
if (GetArgv(command,tmpParam,2)) action.replace(F("%eventvalue2%"), tmpParam); // substitute %eventvalue2% in actions with the actual value from the event
|
||||
if (GetArgv(command,tmpParam,3)) action.replace(F("%eventvalue3%"), tmpParam); // substitute %eventvalue3% in actions with the actual value from the event
|
||||
if (GetArgv(command,tmpParam,4)) action.replace(F("%eventvalue4%"), tmpParam); // substitute %eventvalue4% in actions with the actual value from the event
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2306,19 +2524,21 @@ boolean ruleMatch(String& event, String& rule)
|
||||
// Special handling of literal string events, they should start with '!'
|
||||
if (event.charAt(0) == '!')
|
||||
{
|
||||
int pos = rule.indexOf('#');
|
||||
if (pos == -1) // no # sign in rule, use 'wildcard' match on event 'source'
|
||||
{
|
||||
tmpEvent = event.substring(0,rule.length());
|
||||
tmpRule = rule;
|
||||
}
|
||||
|
||||
pos = rule.indexOf('*');
|
||||
int pos = rule.indexOf('*');
|
||||
if (pos != -1) // a * sign in rule, so use a'wildcard' match on message
|
||||
{
|
||||
tmpEvent = event.substring(0,pos-1);
|
||||
tmpRule = rule.substring(0,pos-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
pos = rule.indexOf('#');
|
||||
if (pos == -1) // no # sign in rule, use 'wildcard' match on event 'source'
|
||||
{
|
||||
tmpEvent = event.substring(0,rule.length());
|
||||
tmpRule = rule;
|
||||
}
|
||||
}
|
||||
|
||||
if (tmpEvent.equalsIgnoreCase(tmpRule))
|
||||
return true;
|
||||
@@ -2741,12 +2961,18 @@ void checkRAM( const __FlashStringHelper* flashString)
|
||||
myRamTracker.registerRamState(s);
|
||||
|
||||
uint32_t freeRAM = FreeMem();
|
||||
|
||||
if (freeRAM < lowestRAM)
|
||||
{
|
||||
lowestRAM = freeRAM;
|
||||
lowestRAMfunction = flashString;
|
||||
}
|
||||
#ifndef ESP32
|
||||
uint32_t freeStack = getFreeStackWatermark();
|
||||
if (freeStack < lowestFreeStack) {
|
||||
lowestFreeStack = freeStack;
|
||||
lowestFreeStackfunction = flashString;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void checkRAM( String &a ) {
|
||||
|
||||
+6
-2
@@ -61,8 +61,8 @@ void calcSunRiseAndSet() {
|
||||
float eqt = equationOfTime(doy);
|
||||
float dec = sunDeclination(doy);
|
||||
float da = diurnalArc(dec, Settings.Latitude);
|
||||
float rise = 12 - da - eqt - Settings.Longitude / 15.0;
|
||||
float set = 12 + da - eqt - Settings.Longitude / 15.0;
|
||||
float rise = 12 - da - eqt;
|
||||
float set = 12 + da - eqt;
|
||||
tsRise.Hour = (int)rise;
|
||||
tsRise.Minute = (rise - (int)rise) * 60.0;
|
||||
tsSet.Hour = (int)set;
|
||||
@@ -70,6 +70,10 @@ void calcSunRiseAndSet() {
|
||||
tsRise.Day = tsSet.Day = tm.Day;
|
||||
tsRise.Month = tsSet.Month = tm.Month;
|
||||
tsRise.Year = tsSet.Year = tm.Year;
|
||||
// Now apply the longitude
|
||||
int secOffset_longitude = -1.0 * (Settings.Longitude / 15.0) * 3600;
|
||||
tsSet = addSeconds(tsSet, secOffset_longitude, false);
|
||||
tsRise = addSeconds(tsRise, secOffset_longitude, false);
|
||||
breakTime(toLocal(makeTime(tsRise)), sunRise);
|
||||
breakTime(toLocal(makeTime(tsSet)), sunSet);
|
||||
}
|
||||
|
||||
+120
-25
@@ -875,6 +875,15 @@ void handle_root() {
|
||||
TXBuffer += F(" - ");
|
||||
TXBuffer += String(lowestRAMfunction);
|
||||
TXBuffer += F(")");
|
||||
html_TR_TD(); TXBuffer += F("Free Stack:<TD>");
|
||||
#ifndef ESP32
|
||||
TXBuffer += String(getCurrentFreeStack());
|
||||
TXBuffer += F(" (");
|
||||
TXBuffer += String(lowestFreeStack);
|
||||
TXBuffer += F(" - ");
|
||||
TXBuffer += String(lowestFreeStackfunction);
|
||||
TXBuffer += F(")");
|
||||
#endif
|
||||
|
||||
html_TR_TD(); TXBuffer += F("IP:<TD>");
|
||||
TXBuffer += formatIP(ip);
|
||||
@@ -1033,6 +1042,7 @@ void handle_config() {
|
||||
MQTTclient_should_reconnect = true;
|
||||
}
|
||||
strncpy(Settings.Name, name.c_str(), sizeof(Settings.Name));
|
||||
Settings.appendUnitToHostname(isFormItemChecked(F("appendunittohostname")));
|
||||
//strncpy(SecuritySettings.Password, password.c_str(), sizeof(SecuritySettings.Password));
|
||||
copyFormPassword(F("password"), SecuritySettings.Password, sizeof(SecuritySettings.Password));
|
||||
strncpy(SecuritySettings.WifiSSID, ssid.c_str(), sizeof(SecuritySettings.WifiSSID));
|
||||
@@ -1083,6 +1093,7 @@ void handle_config() {
|
||||
SecuritySettings.Password[25] = 0;
|
||||
addFormTextBox( F("Unit Name"), F("name"), Settings.Name, 25);
|
||||
addFormNumericBox( F("Unit Number"), F("unit"), Settings.Unit, 0, UNIT_NUMBER_MAX);
|
||||
addFormCheckBox(F("Append Unit Number to hostname"), F("appendunittohostname"), Settings.appendUnitToHostname());
|
||||
addFormPasswordBox(F("Admin Password"), F("password"), SecuritySettings.Password, 25);
|
||||
|
||||
addFormSubHeader(F("Wifi Settings"));
|
||||
@@ -1262,7 +1273,7 @@ void handle_controllers() {
|
||||
CPlugin_ptr[ProtocolIndex](CPLUGIN_INIT, &TempEvent, dummyString);
|
||||
}
|
||||
}
|
||||
addHtmlError(SaveControllerSettings(controllerindex, (byte*)&ControllerSettings, sizeof(ControllerSettings)));
|
||||
addHtmlError(SaveControllerSettings(controllerindex, ControllerSettings));
|
||||
addHtmlError(SaveSettings());
|
||||
}
|
||||
|
||||
@@ -1276,7 +1287,7 @@ void handle_controllers() {
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
for (byte x = 0; x < CONTROLLER_MAX; x++)
|
||||
{
|
||||
LoadControllerSettings(x, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
LoadControllerSettings(x, ControllerSettings);
|
||||
html_TR_TD();
|
||||
TXBuffer += F("<a class='button link' href=\"controllers?index=");
|
||||
TXBuffer += x + 1;
|
||||
@@ -1332,7 +1343,7 @@ void handle_controllers() {
|
||||
if (Settings.Protocol[controllerindex])
|
||||
{
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(controllerindex, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
LoadControllerSettings(controllerindex, ControllerSettings);
|
||||
byte choice = ControllerSettings.UseDNS;
|
||||
String options[2];
|
||||
options[0] = F("Use IP address");
|
||||
@@ -2598,8 +2609,8 @@ void addPinSelect(boolean forI2C, String name, int choice)
|
||||
//********************************************************************************
|
||||
void addPinSelect(boolean forI2C, String name, int choice)
|
||||
{
|
||||
String options[PIN_D_MAX+1];
|
||||
int optionValues[PIN_D_MAX+1];
|
||||
String * options = new String[PIN_D_MAX+1];
|
||||
int * optionValues = new int[PIN_D_MAX+1];
|
||||
options[0] = F("- None -");
|
||||
optionValues[0] = -1;
|
||||
for(byte x=1; x < PIN_D_MAX+1; x++)
|
||||
@@ -2609,6 +2620,8 @@ void addPinSelect(boolean forI2C, String name, int choice)
|
||||
optionValues[x] = x;
|
||||
}
|
||||
renderHTMLForPinSelect(options, optionValues, forI2C, name, choice, PIN_D_MAX+1);
|
||||
delete[] optionValues;
|
||||
delete[] options;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -4569,18 +4582,40 @@ void handle_filelist() {
|
||||
checkRuleSets();
|
||||
}
|
||||
|
||||
const int pageSize = 25;
|
||||
int startIdx = 0;
|
||||
|
||||
String fstart = WebServer.arg(F("start"));
|
||||
if (fstart.length() > 0)
|
||||
{
|
||||
startIdx = atoi(fstart.c_str());
|
||||
}
|
||||
int endIdx = startIdx + pageSize - 1;
|
||||
|
||||
TXBuffer += F("<table class='multirow' border=1px frame='box' rules='all'><TH style='width:50px;'><TH>Filename<TH style='width:80px;'>Size");
|
||||
|
||||
fs::Dir dir = SPIFFS.openDir("");
|
||||
|
||||
int count = -1;
|
||||
while (dir.next())
|
||||
{
|
||||
++count;
|
||||
|
||||
if (count < startIdx)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
html_TR_TD();
|
||||
if (dir.fileName() != F(FILE_CONFIG) && dir.fileName() != F(FILE_SECURITY) && dir.fileName() != F(FILE_NOTIFICATION))
|
||||
{
|
||||
TXBuffer += F("<a class='button link' href=\"filelist?delete=");
|
||||
TXBuffer += dir.fileName();
|
||||
if (startIdx > 0)
|
||||
{
|
||||
TXBuffer += F("&start=");
|
||||
TXBuffer += startIdx;
|
||||
}
|
||||
TXBuffer += F("\">Del</a>");
|
||||
}
|
||||
|
||||
@@ -4592,11 +4627,28 @@ void handle_filelist() {
|
||||
fs::File f = dir.openFile("r");
|
||||
html_TD();
|
||||
TXBuffer += f.size();
|
||||
if (count >= endIdx)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
TXBuffer += F("</table></form>");
|
||||
TXBuffer += F("<BR><a class='button link' href=\"/upload\">Upload</a><BR><BR>");
|
||||
sendHeadandTail(F("TmplStd"),true);
|
||||
TXBuffer.endStream();
|
||||
TXBuffer += F("<BR><a class='button link' href=\"/upload\">Upload</a>");
|
||||
if (startIdx > 0)
|
||||
{
|
||||
TXBuffer += F("<a class='button link' href=\"/filelist?start=");
|
||||
TXBuffer += max(0, startIdx - pageSize);
|
||||
TXBuffer += F("\">Previous</a>");
|
||||
}
|
||||
if (count >= endIdx and dir.next())
|
||||
{
|
||||
TXBuffer += F("<a class='button link' href=\"/filelist?start=");
|
||||
TXBuffer += endIdx + 1;
|
||||
TXBuffer += F("\">Next</a>");
|
||||
}
|
||||
TXBuffer += F("<BR><BR>");
|
||||
sendHeadandTail(F("TmplStd"),true);
|
||||
TXBuffer.endStream();
|
||||
#endif
|
||||
#if defined(ESP32)
|
||||
String fdelete = WebServer.arg(F("delete"));
|
||||
@@ -4607,35 +4659,67 @@ void handle_filelist() {
|
||||
// flashCount();
|
||||
}
|
||||
|
||||
const int pageSize = 25;
|
||||
int startIdx = 0;
|
||||
|
||||
String fstart = WebServer.arg(F("start"));
|
||||
if (fstart.length() > 0)
|
||||
{
|
||||
startIdx = atoi(fstart.c_str());
|
||||
}
|
||||
int endIdx = startIdx + pageSize - 1;
|
||||
|
||||
TXBuffer += F("<table class='multirow' border=1px frame='box' rules='all'><TH><TH>Filename<TH>Size");
|
||||
|
||||
File root = SPIFFS.open("/");
|
||||
File file = root.openNextFile();
|
||||
while (file)
|
||||
int count = -1;
|
||||
while (file and count < endIdx)
|
||||
{
|
||||
if(!file.isDirectory()){
|
||||
html_TR_TD();
|
||||
if (strcmp(file.name(), FILE_CONFIG) != 0 && strcmp(file.name(), FILE_SECURITY) != 0 && strcmp(file.name(), FILE_NOTIFICATION) != 0)
|
||||
{
|
||||
TXBuffer += F("<a class='button link' href=\"filelist?delete=");
|
||||
TXBuffer += file.name();
|
||||
TXBuffer += F("\">Del</a>");
|
||||
}
|
||||
++count;
|
||||
|
||||
TXBuffer += F("<TD><a href=\"");
|
||||
TXBuffer += file.name();
|
||||
TXBuffer += F("\">");
|
||||
TXBuffer += file.name();
|
||||
TXBuffer += F("</a>");
|
||||
html_TD();
|
||||
TXBuffer += file.size();
|
||||
file = root.openNextFile();
|
||||
if (count >= startIdx)
|
||||
{
|
||||
html_TR_TD();
|
||||
if (strcmp(file.name(), FILE_CONFIG) != 0 && strcmp(file.name(), FILE_SECURITY) != 0 && strcmp(file.name(), FILE_NOTIFICATION) != 0)
|
||||
{
|
||||
TXBuffer += F("<a class='button link' href=\"filelist?delete=");
|
||||
TXBuffer += file.name();
|
||||
if (startIdx > 0)
|
||||
{
|
||||
TXBuffer += F("&start=");
|
||||
TXBuffer += startIdx;
|
||||
}
|
||||
TXBuffer += F("\">Del</a>");
|
||||
}
|
||||
|
||||
TXBuffer += F("<TD><a href=\"");
|
||||
TXBuffer += file.name();
|
||||
TXBuffer += F("\">");
|
||||
TXBuffer += file.name();
|
||||
TXBuffer += F("</a>");
|
||||
html_TD();
|
||||
TXBuffer += file.size();
|
||||
}
|
||||
}
|
||||
file = root.openNextFile();
|
||||
}
|
||||
TXBuffer += F("</table></form>");
|
||||
TXBuffer += F("<BR><a class='button link' href=\"/upload\">Upload</a><BR><BR>");
|
||||
TXBuffer += F("<BR><a class='button link' href=\"/upload\">Upload</a>");
|
||||
if (startIdx > 0)
|
||||
{
|
||||
TXBuffer += F("<a class='button link' href=\"/filelist?start=");
|
||||
TXBuffer += startIdx < pageSize ? 0 : startIdx - pageSize;
|
||||
TXBuffer += F("\">Previous</a>");
|
||||
}
|
||||
if (count >= endIdx and file)
|
||||
{
|
||||
TXBuffer += F("<a class='button link' href=\"/filelist?start=");
|
||||
TXBuffer += endIdx + 1;
|
||||
TXBuffer += F("\">Next</a>");
|
||||
}
|
||||
TXBuffer += F("<BR><BR>");
|
||||
sendHeadandTail(F("TmplStd"),true);
|
||||
TXBuffer.endStream();
|
||||
#endif
|
||||
@@ -5175,6 +5259,15 @@ void handle_sysinfo() {
|
||||
TXBuffer += F(" - ");
|
||||
TXBuffer += lowestRAMfunction;
|
||||
TXBuffer += F(")");
|
||||
#ifndef ESP32
|
||||
html_TR_TD(); TXBuffer += F("Free Stack<TD>");
|
||||
TXBuffer += getCurrentFreeStack();
|
||||
TXBuffer += F(" (");
|
||||
TXBuffer += lowestFreeStack;
|
||||
TXBuffer += F(" - ");
|
||||
TXBuffer += lowestFreeStackfunction;
|
||||
TXBuffer += F(")");
|
||||
#endif
|
||||
|
||||
html_TR_TD(); TXBuffer += F("Boot<TD>");
|
||||
TXBuffer += getLastBootCauseString();
|
||||
@@ -5342,6 +5435,8 @@ void handle_sysinfo() {
|
||||
TXBuffer += ESP.getCpuFreqMHz();
|
||||
TXBuffer += F(" MHz");
|
||||
#endif
|
||||
html_TR_TD(); TXBuffer += F("ESP Board Name:<TD>");
|
||||
TXBuffer += ARDUINO_BOARD;
|
||||
|
||||
|
||||
addTableSeparator(F("Storage"), 2, 3);
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ boolean CPlugin_001(byte function, struct EventStruct *event, String& string)
|
||||
case CPLUGIN_INIT:
|
||||
{
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(event->ControllerIndex, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
LoadControllerSettings(event->ControllerIndex, ControllerSettings);
|
||||
C001_DelayHandler.configureControllerSettings(ControllerSettings);
|
||||
break;
|
||||
}
|
||||
|
||||
+2
-2
@@ -36,7 +36,7 @@ boolean CPlugin_002(byte function, struct EventStruct *event, String& string)
|
||||
case CPLUGIN_INIT:
|
||||
{
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(event->ControllerIndex, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
LoadControllerSettings(event->ControllerIndex, ControllerSettings);
|
||||
MQTTDelayHandler.configureControllerSettings(ControllerSettings);
|
||||
break;
|
||||
}
|
||||
@@ -146,7 +146,7 @@ boolean CPlugin_002(byte function, struct EventStruct *event, String& string)
|
||||
if (event->idx != 0)
|
||||
{
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(event->ControllerIndex, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
LoadControllerSettings(event->ControllerIndex, ControllerSettings);
|
||||
/*
|
||||
if (!ControllerSettings.checkHostReachable(true)) {
|
||||
success = false;
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ boolean CPlugin_003(byte function, struct EventStruct *event, String& string)
|
||||
case CPLUGIN_INIT:
|
||||
{
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(event->ControllerIndex, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
LoadControllerSettings(event->ControllerIndex, ControllerSettings);
|
||||
C003_DelayHandler.configureControllerSettings(ControllerSettings);
|
||||
break;
|
||||
}
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ boolean CPlugin_004(byte function, struct EventStruct *event, String& string)
|
||||
case CPLUGIN_INIT:
|
||||
{
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(event->ControllerIndex, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
LoadControllerSettings(event->ControllerIndex, ControllerSettings);
|
||||
C004_DelayHandler.configureControllerSettings(ControllerSettings);
|
||||
break;
|
||||
}
|
||||
|
||||
+2
-2
@@ -34,7 +34,7 @@ boolean CPlugin_005(byte function, struct EventStruct *event, String& string)
|
||||
case CPLUGIN_INIT:
|
||||
{
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(event->ControllerIndex, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
LoadControllerSettings(event->ControllerIndex, ControllerSettings);
|
||||
MQTTDelayHandler.configureControllerSettings(ControllerSettings);
|
||||
break;
|
||||
}
|
||||
@@ -93,7 +93,7 @@ boolean CPlugin_005(byte function, struct EventStruct *event, String& string)
|
||||
case CPLUGIN_PROTOCOL_SEND:
|
||||
{
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(event->ControllerIndex, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
LoadControllerSettings(event->ControllerIndex, ControllerSettings);
|
||||
if (!ControllerSettings.checkHostReachable(true)) {
|
||||
success = false;
|
||||
break;
|
||||
|
||||
+2
-2
@@ -34,7 +34,7 @@ boolean CPlugin_006(byte function, struct EventStruct *event, String& string)
|
||||
case CPLUGIN_INIT:
|
||||
{
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(event->ControllerIndex, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
LoadControllerSettings(event->ControllerIndex, ControllerSettings);
|
||||
MQTTDelayHandler.configureControllerSettings(ControllerSettings);
|
||||
break;
|
||||
}
|
||||
@@ -91,7 +91,7 @@ boolean CPlugin_006(byte function, struct EventStruct *event, String& string)
|
||||
break;
|
||||
}
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(event->ControllerIndex, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
LoadControllerSettings(event->ControllerIndex, ControllerSettings);
|
||||
|
||||
statusLED(true);
|
||||
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ boolean CPlugin_007(byte function, struct EventStruct *event, String& string)
|
||||
case CPLUGIN_INIT:
|
||||
{
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(event->ControllerIndex, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
LoadControllerSettings(event->ControllerIndex, ControllerSettings);
|
||||
C007_DelayHandler.configureControllerSettings(ControllerSettings);
|
||||
break;
|
||||
}
|
||||
|
||||
+2
-2
@@ -35,7 +35,7 @@ boolean CPlugin_008(byte function, struct EventStruct *event, String& string)
|
||||
case CPLUGIN_INIT:
|
||||
{
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(event->ControllerIndex, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
LoadControllerSettings(event->ControllerIndex, ControllerSettings);
|
||||
C008_DelayHandler.configureControllerSettings(ControllerSettings);
|
||||
break;
|
||||
}
|
||||
@@ -56,7 +56,7 @@ boolean CPlugin_008(byte function, struct EventStruct *event, String& string)
|
||||
PluginCall(PLUGIN_GET_DEVICEVALUENAMES, event, dummyString);
|
||||
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(event->ControllerIndex, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
LoadControllerSettings(event->ControllerIndex, ControllerSettings);
|
||||
|
||||
for (byte x = 0; x < valueCount; x++)
|
||||
{
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@
|
||||
- removed obsolete http get url code
|
||||
- v1.04
|
||||
- added build options and node_type_id to JSON/device
|
||||
/******************************************************************************/
|
||||
******************************************************************************/
|
||||
|
||||
#define CPLUGIN_009
|
||||
#define CPLUGIN_ID_009 9
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ boolean CPlugin_010(byte function, struct EventStruct *event, String& string)
|
||||
PluginCall(PLUGIN_GET_DEVICEVALUENAMES, event, dummyString);
|
||||
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(event->ControllerIndex, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
LoadControllerSettings(event->ControllerIndex, ControllerSettings);
|
||||
|
||||
for (byte x = 0; x < valueCount; x++)
|
||||
{
|
||||
|
||||
+1
-1
@@ -148,7 +148,7 @@ boolean Create_schedule_HTTP_C011(struct EventStruct *event)
|
||||
return false;
|
||||
}
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(event->ControllerIndex, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
LoadControllerSettings(event->ControllerIndex, ControllerSettings);
|
||||
|
||||
C011_ConfigStruct customConfig;
|
||||
LoadCustomControllerSettings(event->ControllerIndex,(byte*)&customConfig, sizeof(customConfig));
|
||||
|
||||
+2
-2
@@ -41,7 +41,7 @@ boolean CPlugin_012(byte function, struct EventStruct *event, String& string)
|
||||
PluginCall(PLUGIN_GET_DEVICEVALUENAMES, event, dummyString);
|
||||
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(event->ControllerIndex, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
LoadControllerSettings(event->ControllerIndex, ControllerSettings);
|
||||
|
||||
for (byte x = 0; x < valueCount; x++)
|
||||
{
|
||||
@@ -83,7 +83,7 @@ boolean Blynk_get(const String& command, byte controllerIndex, float *data )
|
||||
}
|
||||
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(controllerIndex, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
LoadControllerSettings(controllerIndex, ControllerSettings);
|
||||
|
||||
if ((SecuritySettings.ControllerPassword[controllerIndex][0] == 0)) {
|
||||
addLog(LOG_LEVEL_ERROR, F("Blynk : No password set"));
|
||||
|
||||
@@ -324,7 +324,7 @@ ControllerDelayHandlerStruct<MQTT_queue_element> MQTTDelayHandler;
|
||||
C##NNN##_queue_element element; \
|
||||
if (!C##NNN##_DelayHandler.getNext(element)) return; \
|
||||
ControllerSettingsStruct ControllerSettings; \
|
||||
LoadControllerSettings(element.controller_idx, (byte*)&ControllerSettings, sizeof(ControllerSettings)); \
|
||||
LoadControllerSettings(element.controller_idx, ControllerSettings); \
|
||||
C##NNN##_DelayHandler.configureControllerSettings(ControllerSettings); \
|
||||
if (!WiFiConnected(100)) { \
|
||||
scheduleNextDelayQueue(TIMER_C##NNN##_DELAY_QUEUE, C##NNN##_DelayHandler.getNextScheduleTime()); \
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ boolean Plugin_009(byte function, struct EventStruct *event, String& string)
|
||||
{
|
||||
Device[++deviceCount].Number = PLUGIN_ID_009;
|
||||
Device[deviceCount].Type = DEVICE_TYPE_I2C;
|
||||
Device[deviceCount].VType = SENSOR_TYPE_SINGLE;
|
||||
Device[deviceCount].VType = SENSOR_TYPE_SWITCH;
|
||||
Device[deviceCount].Ports = 16;
|
||||
Device[deviceCount].PullUpOption = false;
|
||||
Device[deviceCount].InverseLogicOption = false;
|
||||
|
||||
+8
-25
@@ -10,29 +10,11 @@
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <map>
|
||||
//#include <shared_ptr>
|
||||
#include <NewPingESP8266.h>
|
||||
|
||||
struct P_013_sensordef {
|
||||
P_013_sensordef() : sonar(NULL) {}
|
||||
|
||||
P_013_sensordef(byte TRIG_Pin, byte IRQ_Pin, int16_t max_cm_distance) : sonar(NULL) {
|
||||
sonar = new NewPingESP8266(TRIG_Pin, IRQ_Pin, max_cm_distance);
|
||||
}
|
||||
|
||||
~P_013_sensordef() {
|
||||
if (sonar != NULL) {
|
||||
delete sonar;
|
||||
sonar = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
NewPingESP8266 *sonar;
|
||||
};
|
||||
|
||||
std::map<unsigned int, P_013_sensordef> P_013_sensordefs;
|
||||
|
||||
|
||||
|
||||
// map of sensors
|
||||
std::map<unsigned int, std::shared_ptr<NewPingESP8266> > P_013_sensordefs;
|
||||
|
||||
boolean Plugin_013(byte function, struct EventStruct *event, String& string)
|
||||
{
|
||||
@@ -82,6 +64,7 @@ boolean Plugin_013(byte function, struct EventStruct *event, String& string)
|
||||
if (Settings.TaskDevicePluginConfig[event->TaskIndex][0] == 2)
|
||||
{
|
||||
addFormNumericBox(F("Threshold"), F("plugin_013_threshold"), Settings.TaskDevicePluginConfig[event->TaskIndex][1]);
|
||||
addUnit(F("cm"));
|
||||
}
|
||||
addFormNumericBox(F("Max Distance"), F("plugin_013_max_distance"), Settings.TaskDevicePluginConfig[event->TaskIndex][2], 0, 500);
|
||||
addUnit(F("cm"));
|
||||
@@ -107,8 +90,9 @@ boolean Plugin_013(byte function, struct EventStruct *event, String& string)
|
||||
byte Plugin_013_TRIG_Pin = Settings.TaskDevicePin1[event->TaskIndex];
|
||||
byte Plugin_013_IRQ_Pin = Settings.TaskDevicePin2[event->TaskIndex];
|
||||
int16_t max_cm_distance = Settings.TaskDevicePluginConfig[event->TaskIndex][2];
|
||||
P_013_sensordefs.erase(event->TaskIndex);
|
||||
P_013_sensordefs[event->TaskIndex] =
|
||||
P_013_sensordef(Plugin_013_TRIG_Pin, Plugin_013_IRQ_Pin, max_cm_distance);
|
||||
std::shared_ptr<NewPingESP8266> (new NewPingESP8266(Plugin_013_TRIG_Pin, Plugin_013_IRQ_Pin, max_cm_distance));
|
||||
String log = F("ULTRASONIC : TaskNr: ");
|
||||
log += event->TaskIndex +1;
|
||||
log += F(" TrigPin: ");
|
||||
@@ -118,7 +102,7 @@ boolean Plugin_013(byte function, struct EventStruct *event, String& string)
|
||||
log += F(" max dist cm: ");
|
||||
log += max_cm_distance;
|
||||
log += F(" max echo: ");
|
||||
log += P_013_sensordefs[event->TaskIndex].sonar->getMaxEchoTime();
|
||||
log += P_013_sensordefs[event->TaskIndex]->getMaxEchoTime();
|
||||
log += F(" nr_tasks: ");
|
||||
log += P_013_sensordefs.size();
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
@@ -203,9 +187,8 @@ float Plugin_013_read(unsigned int taskIndex)
|
||||
/*********************************************************************/
|
||||
{
|
||||
if (P_013_sensordefs.count(taskIndex) == 0) return 0;
|
||||
if (P_013_sensordefs[taskIndex].sonar == NULL) return 0;
|
||||
delay(1);
|
||||
float distance = P_013_sensordefs[taskIndex].sonar->ping_cm();
|
||||
float distance = (P_013_sensordefs[taskIndex])->ping_cm();
|
||||
delay(1);
|
||||
return distance;
|
||||
}
|
||||
|
||||
@@ -155,7 +155,10 @@ boolean Plugin_016(byte function, struct EventStruct *event, String& string)
|
||||
{
|
||||
if (irReceiver->decode(&results))
|
||||
{
|
||||
unsigned long IRcode = results.value;
|
||||
irReceiver->resume();
|
||||
UserVar[event->BaseVarIndex] = (IRcode & 0xFFFF);
|
||||
UserVar[event->BaseVarIndex + 1] = ((IRcode >> 16) & 0xFFFF);
|
||||
String log = "IR: ";
|
||||
if (results.overflow)
|
||||
log += F("WARNING: IR code is too big for buffer. This result shouldn't be trusted until this is resolved. Edit & increase CAPTURE_BUFFER_SIZE.\n");
|
||||
|
||||
@@ -20,7 +20,7 @@ boolean Plugin_019(byte function, struct EventStruct *event, String& string)
|
||||
{
|
||||
Device[++deviceCount].Number = PLUGIN_ID_019;
|
||||
Device[deviceCount].Type = DEVICE_TYPE_I2C;
|
||||
Device[deviceCount].VType = SENSOR_TYPE_SINGLE;
|
||||
Device[deviceCount].VType = SENSOR_TYPE_SWITCH;
|
||||
Device[deviceCount].Ports = 8;
|
||||
Device[deviceCount].PullUpOption = false;
|
||||
Device[deviceCount].InverseLogicOption = false;
|
||||
|
||||
+7
-12
@@ -382,8 +382,10 @@ bool Plugin_028_update_measurements(const uint8_t i2cAddress, float tempOffset,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!timeOutReached(sensor.last_measurement + 1000)) {
|
||||
// Must wait one second to make sure the filtered values stabilize.
|
||||
// It takes at least 1.587 sec for valit measurements to complete.
|
||||
// The datasheet names this the "T63" moment.
|
||||
// 1 second = 63% of the time needed to perform a measurement.
|
||||
if (!timeOutReached(sensor.last_measurement + 1587)) {
|
||||
return false;
|
||||
}
|
||||
if (!Plugin_028_readUncompensatedData(i2cAddress)) {
|
||||
@@ -510,7 +512,7 @@ bool Plugin_028_begin(uint8_t i2cAddress) {
|
||||
I2C_write8_reg(i2cAddress, BMx280_REGISTER_SOFTRESET, 0xB6);
|
||||
delay(2); // Startup time is 2 ms (datasheet)
|
||||
Plugin_028_readCoefficients(i2cAddress);
|
||||
delay(65); //May be needed here as well to fix first wrong measurement?
|
||||
// delay(65); //May be needed here as well to fix first wrong measurement?
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -548,8 +550,8 @@ void Plugin_028_readCoefficients(uint8_t i2cAddress)
|
||||
bool Plugin_028_readUncompensatedData(uint8_t i2cAddress) {
|
||||
// wait until measurement has been completed, otherwise we would read
|
||||
// the values from the last measurement
|
||||
while (I2C_read8_reg(i2cAddress, BMx280_REGISTER_STATUS) & 0x08)
|
||||
delay(1);
|
||||
if (I2C_read8_reg(i2cAddress, BMx280_REGISTER_STATUS) & 0x08)
|
||||
return false;
|
||||
|
||||
I2Cdata_bytes BME280_data(BME280_P_T_H_DATA_LEN, BME280_DATA_ADDR);
|
||||
bool allDataRead = I2C_read_bytes(i2cAddress, BME280_data);
|
||||
@@ -642,13 +644,6 @@ float Plugin_028_readHumidity(uint8_t i2cAddress)
|
||||
// No support for humidity
|
||||
return 0.0;
|
||||
}
|
||||
// It takes at least 1.587 sec for valit measurements to complete.
|
||||
// The datasheet names this the "T63" moment.
|
||||
// 1 second = 63% of the time needed to perform a measurement.
|
||||
unsigned long difTime = millis() - sensor.last_measurement;
|
||||
if (difTime < 1587) {
|
||||
delay(1587 - difTime);
|
||||
}
|
||||
int32_t adc_H = sensor.uncompensated.humidity;
|
||||
|
||||
int32_t v_x1_u32r;
|
||||
|
||||
+64
-41
@@ -24,6 +24,36 @@
|
||||
WiFiClient espclient_037;
|
||||
PubSubClient *MQTTclient_037 = NULL;
|
||||
bool MQTTclient_037_connected = false;
|
||||
int reconnectCount = 0;
|
||||
|
||||
String getClientName() {
|
||||
//
|
||||
// Generate the MQTT import client name from the system name and a suffix
|
||||
//
|
||||
String tmpClientName = F("%sysname%-Import");
|
||||
String ClientName = parseTemplate(tmpClientName, 20);
|
||||
if (reconnectCount != 0) ClientName += reconnectCount;
|
||||
return ClientName;
|
||||
}
|
||||
|
||||
void Plugin_037_try_connect() {
|
||||
Plugin_037_update_connect_status();
|
||||
if (MQTTclient_037_connected) return;
|
||||
// workaround see: https://github.com/esp8266/Arduino/issues/4497#issuecomment-373023864
|
||||
espclient_037 = WiFiClient();
|
||||
|
||||
if (MQTTclient_037 == NULL) {
|
||||
MQTTclient_037 = new PubSubClient(espclient_037);
|
||||
}
|
||||
if (MQTTConnect_037())
|
||||
{
|
||||
// Subscribe to ALL the topics from ALL instance of this import module
|
||||
MQTTSubscribe_037();
|
||||
} else {
|
||||
MQTTclient_037->disconnect();
|
||||
}
|
||||
Plugin_037_update_connect_status();
|
||||
}
|
||||
|
||||
void Plugin_037_update_connect_status() {
|
||||
bool connected = false;
|
||||
@@ -39,6 +69,7 @@ void Plugin_037_update_connect_status() {
|
||||
if (!connected) {
|
||||
// workaround see: https://github.com/esp8266/Arduino/issues/4497#issuecomment-373023864
|
||||
espclient_037 = WiFiClient();
|
||||
++reconnectCount;
|
||||
addLog(LOG_LEVEL_ERROR, F("IMPT : MQTT 037 Connection lost"));
|
||||
}
|
||||
}
|
||||
@@ -49,11 +80,6 @@ boolean Plugin_037(byte function, struct EventStruct *event, String& string)
|
||||
boolean success = false;
|
||||
|
||||
char deviceTemplate[4][41]; // variable for saving the subscription topics
|
||||
//
|
||||
// Generate the MQTT import client name from the system name and a suffix
|
||||
//
|
||||
String tmpClientName = F("%sysname%-Import");
|
||||
String ClientName = parseTemplate(tmpClientName, 20);
|
||||
|
||||
switch (function)
|
||||
{
|
||||
@@ -121,30 +147,23 @@ boolean Plugin_037(byte function, struct EventStruct *event, String& string)
|
||||
|
||||
case PLUGIN_INIT:
|
||||
{
|
||||
if (!MQTTclient_037) {
|
||||
MQTTclient_037 = new PubSubClient(espclient_037);
|
||||
}
|
||||
|
||||
success = false;
|
||||
// When we edit the subscription data from the webserver, the plugin is called again with init.
|
||||
// In order to resubscribe we have to disconnect and reconnect in order to get rid of any obsolete subscriptions
|
||||
|
||||
MQTTclient_037->disconnect();
|
||||
|
||||
if (MQTTConnect_037(ClientName))
|
||||
{
|
||||
// Subscribe to ALL the topics from ALL instance of this import module
|
||||
MQTTSubscribe_037();
|
||||
success = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
success = false;
|
||||
if (MQTTclient_037 != NULL) {
|
||||
MQTTclient_037->disconnect();
|
||||
if (MQTTConnect_037())
|
||||
{
|
||||
// Subscribe to ALL the topics from ALL instance of this import module
|
||||
MQTTSubscribe_037();
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
case PLUGIN_TEN_PER_SECOND:
|
||||
{
|
||||
if (!MQTTclient_037->loop()) { // Listen out for callbacks
|
||||
if (MQTTclient_037 != NULL && !MQTTclient_037->loop()) { // Listen out for callbacks
|
||||
Plugin_037_update_connect_status();
|
||||
}
|
||||
success = true;
|
||||
@@ -154,25 +173,26 @@ boolean Plugin_037(byte function, struct EventStruct *event, String& string)
|
||||
case PLUGIN_ONCE_A_SECOND:
|
||||
{
|
||||
// Here we check that the MQTT client is alive.
|
||||
Plugin_037_try_connect();
|
||||
if (MQTTclient_037 != NULL) {
|
||||
if (!MQTTclient_037->connected() || MQTTclient_should_reconnect) {
|
||||
if (MQTTclient_should_reconnect) {
|
||||
addLog(LOG_LEVEL_ERROR, F("IMPT : MQTT 037 Intentional reconnect"));
|
||||
}
|
||||
|
||||
if (!MQTTclient_037->connected() || MQTTclient_should_reconnect) {
|
||||
if (MQTTclient_should_reconnect) {
|
||||
addLog(LOG_LEVEL_ERROR, F("IMPT : MQTT 037 Intentional reconnect"));
|
||||
MQTTclient_037->disconnect();
|
||||
Plugin_037_update_connect_status();
|
||||
delay(250);
|
||||
|
||||
if (! MQTTConnect_037()) {
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
|
||||
MQTTSubscribe_037();
|
||||
}
|
||||
|
||||
MQTTclient_037->disconnect();
|
||||
Plugin_037_update_connect_status();
|
||||
delay(250);
|
||||
|
||||
if (! MQTTConnect_037(ClientName)) {
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
|
||||
MQTTSubscribe_037();
|
||||
success = true;
|
||||
}
|
||||
|
||||
success = true;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -260,6 +280,7 @@ boolean Plugin_037(byte function, struct EventStruct *event, String& string)
|
||||
}
|
||||
boolean MQTTSubscribe_037()
|
||||
{
|
||||
if (!MQTTclient_037_connected) return false;
|
||||
|
||||
// Subscribe to the topics requested by ALL calls to this plugin.
|
||||
// We do this because if the connection to the broker is lost, we want to resubscribe for all instances.
|
||||
@@ -283,7 +304,7 @@ boolean MQTTSubscribe_037()
|
||||
if (subscribeTo.length() > 0)
|
||||
{
|
||||
parseSystemVariables(subscribeTo, false);
|
||||
if (MQTTclient_037->subscribe(subscribeTo.c_str()))
|
||||
if (MQTTclient_037 != NULL && MQTTclient_037->subscribe(subscribeTo.c_str()))
|
||||
{
|
||||
String log = F("IMPT : [");
|
||||
LoadTaskSettings(y);
|
||||
@@ -350,9 +371,11 @@ void mqttcallback_037(char* c_topic, byte* b_payload, unsigned int length)
|
||||
// For some reason this seems to failduring the call in INIT- however it succeeds later during recovery
|
||||
// It would be nice to understand this....
|
||||
|
||||
boolean MQTTConnect_037(String clientid)
|
||||
boolean MQTTConnect_037()
|
||||
{
|
||||
boolean result = false;
|
||||
if (MQTTclient_037 == NULL) return false;
|
||||
String clientid = getClientName();
|
||||
// @ToDo TD-er: Plugin allows for more than one MQTT controller, but we're now using only the first enabled one.
|
||||
int enabledMqttController = firstEnabledMQTTController();
|
||||
if (enabledMqttController < 0) {
|
||||
@@ -368,7 +391,7 @@ boolean MQTTConnect_037(String clientid)
|
||||
return false; // Not connected, so no use in wasting time to connect to a host.
|
||||
}
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(enabledMqttController, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
LoadControllerSettings(enabledMqttController, ControllerSettings);
|
||||
if (ControllerSettings.UseDNS) {
|
||||
MQTTclient_037->setServer(ControllerSettings.getHost().c_str(), ControllerSettings.Port);
|
||||
} else {
|
||||
|
||||
@@ -458,6 +458,7 @@ void p073_FillBufferWithTemp(long temperature)
|
||||
int p073_numlenght = strlen(p073_digit);
|
||||
byte p073_dispdigit;
|
||||
for (int i=0;i<p073_numlenght;i++) {
|
||||
p073_dispdigit = 10; // default is space
|
||||
if (p073_digit[i] > 47 && p073_digit[i] < 58)
|
||||
p073_dispdigit = p073_digit[i]-48;
|
||||
else if (p073_digit[i] == 32) // space
|
||||
|
||||
@@ -206,10 +206,25 @@ To create/register a plugin, you have to :
|
||||
#define USES_P036 // FrameOLED
|
||||
#define USES_P027 // INA219
|
||||
#define USES_P028 // BME280
|
||||
|
||||
// TODO : Add list of compatible plugins for ESP32 board.
|
||||
#endif
|
||||
|
||||
#ifdef PLUGIN_SET_TEST_ESP32
|
||||
#ifndef ESP32
|
||||
#define ESP32
|
||||
#endif
|
||||
#ifdef ESP8266
|
||||
#undef ESP8266
|
||||
#endif
|
||||
// #define PLUGIN_SET_ONLY_SWITCH
|
||||
|
||||
#define PLUGIN_SET_TESTING
|
||||
#define CONTROLLER_SET_STABLE
|
||||
#define NOTIFIER_SET_STABLE
|
||||
#define PLUGIN_SET_STABLE // add stable
|
||||
// See also PLUGIN_SET_TEST_ESP32 section at end,
|
||||
// where incompatible plugins will be disabled.
|
||||
// TODO : Check compatibility of plugins for ESP32 board.
|
||||
#endif
|
||||
|
||||
|
||||
// Generic ------------------------------------
|
||||
@@ -585,8 +600,22 @@ To create/register a plugin, you have to :
|
||||
#ifdef NOTIFIER_SET_EXPERIMENTAL
|
||||
#endif
|
||||
|
||||
/******************************************************************************\
|
||||
* Remove incompatible plugins ************************************************
|
||||
\******************************************************************************/
|
||||
#ifdef PLUGIN_SET_TEST_ESP32
|
||||
#undef USES_P010 // BH1750 (doesn't work yet on ESP32)
|
||||
#undef USES_P049 // MHZ19 (doesn't work yet on ESP32)
|
||||
|
||||
#undef USES_P052 // SenseAir (doesn't work yet on ESP32)
|
||||
#undef USES_P053 // PMSx003
|
||||
|
||||
#undef USES_P056 // SDS011-Dust (doesn't work yet on ESP32)
|
||||
#undef USES_P065 // DRF0299
|
||||
#undef USES_P071 // Kamstrup401
|
||||
#undef USES_P075 // Nextion
|
||||
#undef USES_P078 // Eastron Modbus Energy meters (doesn't work yet on ESP32)
|
||||
#endif
|
||||
|
||||
|
||||
/******************************************************************************\
|
||||
|
||||
Reference in New Issue
Block a user