mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-07-28 12:17:05 +00:00
Compare commits
259
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1ff0141e38 | ||
|
|
125db8046b | ||
|
|
afa16e80b6 | ||
|
|
37f5c92aa7 | ||
|
|
684b89ae4c | ||
|
|
8c4612c300 | ||
|
|
0afab53659 | ||
|
|
e6e98345fe | ||
|
|
2394e4a75f | ||
|
|
e1c4691325 | ||
|
|
3f84c35014 | ||
|
|
bc0bafa96b | ||
|
|
4e7e66822d | ||
|
|
6f226e6d65 | ||
|
|
a50a035238 | ||
|
|
d560c635f5 | ||
|
|
f8db0c0a05 | ||
|
|
79616022df | ||
|
|
559d294607 | ||
|
|
d2588c5e01 | ||
|
|
ba45a51576 | ||
|
|
8321caaeed | ||
|
|
b35ed7d809 | ||
|
|
a4583d150e | ||
|
|
cadc0a885d | ||
|
|
061eb20ae5 | ||
|
|
9a9799eee7 | ||
|
|
f4615bb76b | ||
|
|
ecc498c359 | ||
|
|
e0e10fa6c8 | ||
|
|
228f09f394 | ||
|
|
19ac19778b | ||
|
|
5e2d517ba2 | ||
|
|
7a4b17983e | ||
|
|
6eba74ccc1 | ||
|
|
27a05b674c | ||
|
|
4a66bbf081 | ||
|
|
109bddb5c3 | ||
|
|
8158a919d8 | ||
|
|
706b91168b | ||
|
|
d047999c5e | ||
|
|
42f361aacd | ||
|
|
3dd076cf25 | ||
|
|
c0d155dd99 | ||
|
|
c433174d71 | ||
|
|
b805b59baf | ||
|
|
9fae0477d8 | ||
|
|
f7ac04dc96 | ||
|
|
d50e661efb | ||
|
|
57b5338af6 | ||
|
|
bd035c8f81 | ||
|
|
ac63d93e1a | ||
|
|
4cff0d0e02 | ||
|
|
ca83983fd2 | ||
|
|
d808f7e79b | ||
|
|
e469350ad9 | ||
|
|
60536b1a93 | ||
|
|
b9e45bd515 | ||
|
|
a0992b8383 | ||
|
|
9315581858 | ||
|
|
9a763303ca | ||
|
|
7df9379f47 | ||
|
|
c32fe50521 | ||
|
|
e4569b26f7 | ||
|
|
48998886fe | ||
|
|
36f97d7909 | ||
|
|
0e3b9c9e47 | ||
|
|
acecff4108 | ||
|
|
3322b954a7 | ||
|
|
4c4b844a4d | ||
|
|
cf4d28eb4f | ||
|
|
555b5386ae | ||
|
|
1903fdc7f2 | ||
|
|
918353461e | ||
|
|
e648a20fd0 | ||
|
|
1d7ea5e129 | ||
|
|
6ce5240dd7 | ||
|
|
692fb248ce | ||
|
|
5a87397ee0 | ||
|
|
99ba09b024 | ||
|
|
3dea091d21 | ||
|
|
ca13317cbd | ||
|
|
f68516d5bb | ||
|
|
8102a0096d | ||
|
|
73cec59bd5 | ||
|
|
96ecf9bf29 | ||
|
|
ef1e371514 | ||
|
|
45d67292a3 | ||
|
|
b5662baad4 | ||
|
|
12c3e5f81f | ||
|
|
dececf24ee | ||
|
|
3fb6dec382 | ||
|
|
cef962c5f1 | ||
|
|
cca2335070 | ||
|
|
ffd0d26ed3 | ||
|
|
9b457ed77b | ||
|
|
f787a9a9a6 | ||
|
|
a0ae104794 | ||
|
|
2b78810457 | ||
|
|
43081c3ac8 | ||
|
|
33281c08c2 | ||
|
|
461aee26ad | ||
|
|
2b0b14b2e8 | ||
|
|
b7404666b1 | ||
|
|
da25aa87dd | ||
|
|
10a1e634e2 | ||
|
|
83f86449b9 | ||
|
|
eee337d3e3 | ||
|
|
c549ecd329 | ||
|
|
d9e682668d | ||
|
|
e38072ac24 | ||
|
|
6aebeba5dc | ||
|
|
da01c8f469 | ||
|
|
d3c86b9824 | ||
|
|
9621a91d90 | ||
|
|
b3b68856f0 | ||
|
|
bec5cb5334 | ||
|
|
bda6011390 | ||
|
|
f3fdb93a52 | ||
|
|
200b060b15 | ||
|
|
ff41cb2f94 | ||
|
|
c134eb6d13 | ||
|
|
f9e2a211e1 | ||
|
|
bd3d3f66f4 | ||
|
|
3bad683211 | ||
|
|
68f6e913a2 | ||
|
|
0b9c550fd7 | ||
|
|
96420faa2f | ||
|
|
8eea77e4ed | ||
|
|
3d1f723787 | ||
|
|
5d459003e4 | ||
|
|
ad208c357c | ||
|
|
b1c777e6fd | ||
|
|
f5ab15c255 | ||
|
|
001ec6dcd2 | ||
|
|
15e5edccd8 | ||
|
|
651353cc99 | ||
|
|
85f97551c5 | ||
|
|
6a158f68f5 | ||
|
|
1933714de5 | ||
|
|
545117ddf7 | ||
|
|
8eb479c411 | ||
|
|
b39f51ca3c | ||
|
|
4511e08d3c | ||
|
|
086e836956 | ||
|
|
3e20f617ea | ||
|
|
8d9aacb6a4 | ||
|
|
0670fa98a6 | ||
|
|
2b3d1517c9 | ||
|
|
0be79759d1 | ||
|
|
d47bede215 | ||
|
|
2988a244b2 | ||
|
|
8d87dc0175 | ||
|
|
21c86e666a | ||
|
|
e6fdd3380a | ||
|
|
e04f71ab47 | ||
|
|
90ae0720cf | ||
|
|
c8ecd8d374 | ||
|
|
7a451dd672 | ||
|
|
b06f6aa360 | ||
|
|
6b67415c71 | ||
|
|
b095465d3a | ||
|
|
81a5d911ba | ||
|
|
48060d8d99 | ||
|
|
d303fa023f | ||
|
|
29b0cc1b32 | ||
|
|
584abd1e75 | ||
|
|
b4d8be0e59 | ||
|
|
30f5c5cb7d | ||
|
|
6e7286c6fb | ||
|
|
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 | ||
|
|
639685ea0d | ||
|
|
867209de6d | ||
|
|
1d8b6d346b | ||
|
|
2a5ac327d3 | ||
|
|
886101d4d4 | ||
|
|
8fc6486855 | ||
|
|
eeb1cc71b3 | ||
|
|
13837830e8 | ||
|
|
f86ff46a82 | ||
|
|
e901bc957a | ||
|
|
e7e10c5305 | ||
|
|
5511ee9f38 | ||
|
|
427a22d23b | ||
|
|
d271898968 | ||
|
|
4051f0bd2e |
@@ -1,3 +1,25 @@
|
||||
### Checklist
|
||||
- [ ] The title of this issue is "to the point" and descriptive.
|
||||
- [ ] This issue describes what is happening.
|
||||
- [ ] This issue describes what components are affected (e.g. name of plugin/controller)
|
||||
- [ ] This issue describes how to reproduce it.
|
||||
- [ ] This issue describes when it was introduced (when known) and what version is now showing the problem.
|
||||
|
||||
### I have...
|
||||
- [ ] searched the [issue tracker](https://github.com/letscontrolit/ESPEasy/issues) or the [forum](https://www.letscontrolit.com/forum/viewforum.php?f=1) for a similar issue. (include links when applicable)
|
||||
- [ ] entered a system description using "Copy info to clipboard" on the sysinfo page. (when possible)
|
||||
- [ ] entered the full filename of the used version (e.g. `ESP_Easy_mega-20181001_test_ESP8266_4096_VCC.bin` )
|
||||
- [ ] given a list of active plugins or controllers when applicable.
|
||||
- [ ] filled out all applicable fields below.
|
||||
|
||||
### Steps already tried...
|
||||
- [ ] Tried a clean install (empty `.bin` files are included in the ZIP)
|
||||
- [ ] Tested previous/other build (mention which one already tested)
|
||||
- [ ] Tested on other node to make sure hardware isn't defective.
|
||||
- [ ] Verified if the problem is limited to a single plugin/controller
|
||||
|
||||
|
||||
|
||||
### If you self compile, please state this and PLEASE try to ONLY REPORT ISSUES WITH OFFICIAL BUILDS! ###
|
||||
<!--- If you self compile, please state this and PLEASE try to ONLY REPORT ISSUES WITH OFFICIAL BUILDS! --->
|
||||
<!--- NOTE: This is not a support forum! For questions and support go here: --->
|
||||
@@ -5,6 +27,7 @@
|
||||
<!--- Remove topics that are not applicable to your feature request of issue --->
|
||||
<!--- Remember to have a "to the point" TITLE --->
|
||||
|
||||
|
||||
### Summarize of the problem/feature request
|
||||
<!--- Describe the problem or feature request --->
|
||||
YOUR TEXT GOES HERE
|
||||
|
||||
@@ -18,3 +18,9 @@ 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
|
||||
|
||||
docs/build/
|
||||
|
||||
+2
-1
@@ -22,9 +22,10 @@ addons:
|
||||
|
||||
|
||||
install:
|
||||
- pip install -U platformio
|
||||
- pip install -U platformio sphinx recommonmark sphinx_bootstrap_theme
|
||||
|
||||
script:
|
||||
# - bash ./preflight.sh # make sure input files are OK before wasting time with prereqs
|
||||
# - cppcheck --enable=warning src/*.ino -q --force -I src --include=src/ESPEasy.ino --error-exitcode=1
|
||||
# - ./memanalyzer.py ~/.platformio/packages/toolchain-xtensa/bin/xtensa-lx106-elf-objdump
|
||||
- PLATFORMIO_BUILD_FLAGS="-D CONTINUOUS_INTEGRATION" platformio run
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -41,4 +41,6 @@ ESPEasy_mega-20180102_dev_ESP8285_1024.bin | ESP8285 with 1Mb flash | Stabl
|
||||
|
||||
Details and discussion are on the Experimental forum: https://www.letscontrolit.com/forum/viewforum.php?f=18
|
||||
|
||||
Automated builds of the (new) documentation can be found at [ESPEasy.readthedocs.io](https://espeasy.readthedocs.io/en/latest/)
|
||||
|
||||
We're also on IRC: #ESPEasy @freenode
|
||||
|
||||
+8
-3
@@ -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"
|
||||
@@ -34,10 +35,14 @@ done
|
||||
|
||||
|
||||
#create a source structure that is the same as the original ESPEasy project (and works with the howto on the wiki)
|
||||
rm -rf dist/Source 2>/dev/null
|
||||
mkdir dist/Source
|
||||
#rm -rf dist/Source 2>/dev/null
|
||||
rm -rf dist/Docs 2>/dev/null
|
||||
|
||||
mkdir -p dist/Source
|
||||
#mkdir -p dist/Docs
|
||||
cp -r lib dist/Source/
|
||||
cp -r src dist/Source/
|
||||
#cp -r docs/build/ dist/Docs/
|
||||
cp platformio.ini dist/Source/
|
||||
|
||||
cd dist
|
||||
|
||||
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
+440
@@ -1,3 +1,443 @@
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20181021 (since mega-20181020)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Sun Oct 21 04:00:16 CEST 2018
|
||||
|
||||
Bartlomiej Zimon (2):
|
||||
fix for #1920 fix for out of sync, check both header bytes proper check for abnormal state
|
||||
Revert "fix for #1920"
|
||||
|
||||
TD-er (6):
|
||||
[stack usage] Allocate temp char array on heap for parsing arguments
|
||||
Proper look for connection.
|
||||
[Rules] Early exit on rules processing when rules not enabled
|
||||
[#1910] Notification settings extra strings on stack
|
||||
[#1891] Send all values for Generic UDP controller
|
||||
[#1870] Feature request build date as system info
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20181020 (since mega-20181017)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Sat Oct 20 04:00:16 CEST 2018
|
||||
|
||||
Plebs (22):
|
||||
Added [plugin#pcfgpio#pinstate#xx]
|
||||
added [plugin#mcpgpio#pinstate#xx]
|
||||
code optimization
|
||||
some code optimizations
|
||||
Update src/_P001_Switch.ino
|
||||
Update src/_P001_Switch.ino
|
||||
small fixes
|
||||
few changes
|
||||
Update src/_P001_Switch.ino
|
||||
Update src/_P001_Switch.ino
|
||||
some fixes
|
||||
added global variables for rules
|
||||
some fixes
|
||||
fixes
|
||||
fixed length check
|
||||
some optimizations
|
||||
modified command and variable name
|
||||
Update src/_P001_Switch.ino
|
||||
Update src/_P001_Switch.ino
|
||||
optimizations
|
||||
Update src/StringConverter.ino
|
||||
added 4 variables to verify the system status
|
||||
|
||||
kpalczewski (1):
|
||||
add support for 64bit IR codes.
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20181017 (since mega-20181016)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Wed Oct 17 04:00:18 CEST 2018
|
||||
|
||||
Gijs Noorlander (1):
|
||||
Added checklist to the Issue_template
|
||||
|
||||
TD-er (3):
|
||||
[#1906] Allocate NotificationSettings on the heap
|
||||
[#1906] Allocate ControllerSettings on the heap
|
||||
[Stack] Add Free Stack to System Info plugin
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20181016 (since mega-20181015)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Tue Oct 16 04:00:06 CEST 2018
|
||||
|
||||
Plebs (1):
|
||||
Fix for togglegpio without gpio initialization
|
||||
|
||||
TD-er (1):
|
||||
[Revert] Safe_strncpy cannot be used as generic strncpy replacement
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20181015 (since mega-20181014)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Mon Oct 15 04:00:10 CEST 2018
|
||||
|
||||
Plebs (2):
|
||||
fix for bug #1864
|
||||
Update src/_P023_OLED.ino
|
||||
|
||||
TD-er (1):
|
||||
[safe strncpy] Add warning when entered string is too large
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20181014 (since mega-20181011)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Sun Oct 14 04:00:13 CEST 2018
|
||||
|
||||
Gijs Noorlander (1):
|
||||
[#1799] Add SSID to main page
|
||||
|
||||
TD-er (5):
|
||||
[#1891] Generic UPD controller - send only first value from sensor
|
||||
[Controller] Fix send only first value
|
||||
Time#Initialized event in rules before %syshour% is set
|
||||
[UX] Warn user for incomplete network IP settings
|
||||
[#1895] Incorrect number bytes read I2C_read32_reg
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20181011 (since mega-20181010)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Thu Oct 11 04:00:24 CEST 2018
|
||||
|
||||
TD-er (5):
|
||||
[C009] Reduce memory usage of FHEM HTTP delay queue
|
||||
[Controller] Set default timeout to 300 msec (was 100 msec)
|
||||
Make sure to load ExtraTaskSettings when needed
|
||||
[Travis Doc] Remove building documentation by Travis
|
||||
[WebLog] Disable weblog when it is not being read
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20181010 (since mega-20181009)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Wed Oct 10 04:00:09 CEST 2018
|
||||
|
||||
Plebs (1):
|
||||
Update src/_P019_PCF8574.ino
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20181009 (since mega-20181008)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Tue Oct 9 04:00:18 CEST 2018
|
||||
|
||||
TD-er (7):
|
||||
[Docs] Add favicon to documentation
|
||||
[Docs] Add Travis check for documentation and stop build for docs only
|
||||
[Docs] Run Travic documentation check before compiling project
|
||||
[Docs] Disable travis_terminate for now
|
||||
[JSON] Replace \n and \r in text fields
|
||||
[LWIP1.4] Move back to LWIP1.4
|
||||
[StringConverter] Some optimisations to reduce memory allocation
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20181008 (since mega-20181007)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Mon Oct 8 04:00:09 CEST 2018
|
||||
|
||||
Gijs Noorlander (1):
|
||||
Added link to ReadTheDocs
|
||||
|
||||
Grovkillen (1):
|
||||
[Sphinx] added extension "sphinx.ext.imgconverter"
|
||||
|
||||
TD-er (3):
|
||||
[Sphinx] Initial setup for Sphinx documentation
|
||||
[Docs] First ESPEasy documentation (Controllers)
|
||||
[Docs] Added some directory structure and template
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20181007 (since mega-20181006)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Sun Oct 7 04:00:09 CEST 2018
|
||||
|
||||
Max (2):
|
||||
Force slash to be converted in htmlEscape
|
||||
Fix XSS-Vulnerabilites on wifi configuration pages
|
||||
|
||||
Plebs (3):
|
||||
Add three new TOGGLE commands
|
||||
fixed float to int conversion
|
||||
added "mcpgpiotoggle" command
|
||||
|
||||
TD-er (3):
|
||||
[ESP32] Allow Wrover dev kit to be used for PIO debug
|
||||
[Stack] Move Arduino 'cont' stack into user RAM
|
||||
[SPIFFS] Make sure to close open files on SPIFFS
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20181006 (since mega-20181004)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Sat Oct 6 04:00:13 CEST 2018
|
||||
|
||||
TD-er (3):
|
||||
[Stack] Increase stack to 5k and reduce stack allocations in rules
|
||||
[WiFi] Add delay to connection attempts in ControllerSettings
|
||||
[Build flags] Remove NO_EXTRA_4K_HEAP
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20181004 (since mega-20181003)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Thu Oct 4 04:00:08 CEST 2018
|
||||
|
||||
Bartlomiej Zimon (1):
|
||||
- partial fix for #1723
|
||||
|
||||
JojoS (1):
|
||||
added error checking and logging
|
||||
|
||||
JojoS62 (5):
|
||||
added float calculation for time to distance conversion
|
||||
added more settings: unit, filtertype and size
|
||||
max distance depends on measurement unit
|
||||
code clean up
|
||||
fixed 'unused variable' warning
|
||||
|
||||
TD-er (3):
|
||||
[sendHttp] #1830 Set timeout and early exit on timeout reached
|
||||
[WiFiClient] Set timeout and make it configurable for controllers
|
||||
[Core 2.4.1] Move back to core 2.4.1 from 2.4.2
|
||||
|
||||
Thomas (1):
|
||||
Update _P075_Nextion.ino (#1)
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20181003 (since mega-20181002)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Wed Oct 3 04:00:18 CEST 2018
|
||||
|
||||
David Conran (2):
|
||||
Acknowledge credit & origin of code used in IRTX
|
||||
Acknowledge credit & origin of code used in _P016IR.ino
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20181002 (since mega-20181001)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Tue Oct 2 04:00:29 CEST 2018
|
||||
|
||||
Plebs (1):
|
||||
split parseTemplate function
|
||||
|
||||
TD-er (4):
|
||||
[#1798] Bugfix Sonoff Si7021 stability
|
||||
[ESP32] Add default partition table for reference
|
||||
[ESP32] Update to PIO espressif32@1.4.0
|
||||
[Stack] Report stack usage on ESP32 and increase stack for ESP8266normal
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
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)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Mon Sep 10 04:00:22 CEST 2018
|
||||
|
||||
TD-er (2):
|
||||
[HTTP] Command SendToHttp cannot connect
|
||||
[Domoticz IDX] Allow for IDX of > 9999
|
||||
|
||||
sakinit (1):
|
||||
Reduced buffer size to prevent stack overflow
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180909 (since mega-20180908)
|
||||
-------------------------------------------------
|
||||
|
||||
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,19 @@
|
||||
# Minimal makefile for Sphinx documentation
|
||||
#
|
||||
|
||||
# You can set these variables from the command line.
|
||||
SPHINXOPTS =
|
||||
SPHINXBUILD = sphinx-build
|
||||
SOURCEDIR = source
|
||||
BUILDDIR = build
|
||||
|
||||
# Put it first so that "make" without argument is like "make help".
|
||||
help:
|
||||
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
||||
|
||||
.PHONY: help Makefile
|
||||
|
||||
# Catch-all target: route all unknown targets to Sphinx using the new
|
||||
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
||||
%: Makefile
|
||||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
||||
@@ -0,0 +1,35 @@
|
||||
@ECHO OFF
|
||||
|
||||
pushd %~dp0
|
||||
|
||||
REM Command file for Sphinx documentation
|
||||
|
||||
if "%SPHINXBUILD%" == "" (
|
||||
set SPHINXBUILD=sphinx-build
|
||||
)
|
||||
set SOURCEDIR=source
|
||||
set BUILDDIR=build
|
||||
|
||||
if "%1" == "" goto help
|
||||
|
||||
%SPHINXBUILD% >NUL 2>NUL
|
||||
if errorlevel 9009 (
|
||||
echo.
|
||||
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
|
||||
echo.installed, then set the SPHINXBUILD environment variable to point
|
||||
echo.to the full path of the 'sphinx-build' executable. Alternatively you
|
||||
echo.may add the Sphinx directory to PATH.
|
||||
echo.
|
||||
echo.If you don't have Sphinx installed, grab it from
|
||||
echo.http://sphinx-doc.org/
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
|
||||
goto end
|
||||
|
||||
:help
|
||||
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
|
||||
|
||||
:end
|
||||
popd
|
||||
@@ -0,0 +1,3 @@
|
||||
recommonmark
|
||||
Sphinx
|
||||
sphinx-bootstrap-theme
|
||||
@@ -0,0 +1,66 @@
|
||||
Controller
|
||||
**********
|
||||
|
||||
A controller is a component to enable a plugin to send data elsewhere.
|
||||
|
||||
- Up-to 3 controllers can be active in ESPEasy.
|
||||
- Per plugin up-to 3 active controllers can be selected.
|
||||
- For some controllers an additional parameter can be given.
|
||||
|
||||
For example, Domoticz needs an 'IDX' value to identify the configured entry in
|
||||
Domoticz for which new data is sent.
|
||||
|
||||
Controller Parameters
|
||||
=====================
|
||||
|
||||
Generic fields
|
||||
--------------
|
||||
|
||||
- **Protocol** - The type of controller (e.g. ThingSpeak/OpenHAB MQTT/etc.)
|
||||
- **Locate Controller** - Selection between hostname/IP
|
||||
- **Controller Hostname/IP** - The address to reach the selected service
|
||||
- **Controller Port** - TCP/UDP Port number (0...65536)
|
||||
- **Enabled** - Whether or not the controller is active.
|
||||
|
||||
Send queue parameters
|
||||
---------------------
|
||||
|
||||
Controllers have a queue to keep unsent messages.
|
||||
This queue is used to handle message bursts and also store messages which are recorded
|
||||
before WiFi connection is made or during lost connection.
|
||||
|
||||
- **Minimum Send Interval** - Minimum time between two messages in msec.
|
||||
- **Max Queue Depth** - Maximum length of the buffer queue to keep unsent messages.
|
||||
- **Max Retries** - Maximum number of retries to send a message.
|
||||
- **Full Queue Action** - How to handle when queue is full, ignore new or delete oldest message.
|
||||
- **Client Timeout** - Timeout in msec for an network connection used by the controller.
|
||||
- **Check Reply** - When set to false, a sent message is considered always successful.
|
||||
|
||||
|
||||
Sample ThingSpeak configuration
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Some controllers, like ThingSpeak, need a specific configuration.
|
||||
ThingSpeak only allows a message every 15 seconds for the free accounts.
|
||||
|
||||
- **Minimum Send Interval** - 15000 msec
|
||||
- **Max Queue Depth** - 1 (only report the last value)
|
||||
- **Max Retries** - 2
|
||||
- **Full Queue Action** - Delete Oldest
|
||||
- **Client Timeout** - 500 msec (server is online, so timeout must be a bit longer)
|
||||
|
||||
|
||||
Controller user credentials
|
||||
---------------------------
|
||||
|
||||
- **Controller User** - User name (optional)
|
||||
- **Controller Password** - Password (optional)
|
||||
|
||||
MQTT related settings
|
||||
---------------------
|
||||
|
||||
- **Controller Subscribe** - Subscribe to the given topic.
|
||||
- **Controller Publish** - Publish to the given topic.
|
||||
- **Controller lwl topic** - Topic to which LWT (Last Will Testament) messages should be sent.
|
||||
- **LWT Connect Message** - Connection established message.
|
||||
- **LWT Disconnect Message** - Connection lost message (sent to broker during connect and published by broker when connection is lost)
|
||||
@@ -0,0 +1,2 @@
|
||||
About Us
|
||||
********
|
||||
@@ -0,0 +1,2 @@
|
||||
ESPEasy Function Blocks
|
||||
***********************
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.1 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
@@ -0,0 +1,35 @@
|
||||
Documentation
|
||||
*************
|
||||
|
||||
For documentation we use Sphinx and this will be read by ReadTheDocs.
|
||||
We use the `Sphinx Bootstrap Theme <https://github.com/ryan-roemer/sphinx-bootstrap-theme>`_
|
||||
|
||||
This documentation is included in the GitHub repository.
|
||||
It allows us to create documentation per version of ESPEasy.
|
||||
|
||||
See also the `ESPEasy wiki <https://www.letscontrolit.com/wiki/index.php/ESPEasy>`_
|
||||
for more documentation which has not been moved here.
|
||||
|
||||
Needed Python packages::
|
||||
|
||||
pip install sphinx recommonmark sphinx_bootstrap_theme
|
||||
|
||||
PlatformIO with Atom
|
||||
====================
|
||||
|
||||
With the ESPEasy project open in Atom, open the PIO terminal in Atom.
|
||||
|
||||
Install dependencies::
|
||||
|
||||
cd docs
|
||||
pip install ... (see needed Python packages above)
|
||||
|
||||
Build on Windows::
|
||||
|
||||
cd docs
|
||||
.\make.bat html
|
||||
|
||||
Build on Linux/Mac::
|
||||
|
||||
cd docs
|
||||
./make html
|
||||
@@ -0,0 +1,2 @@
|
||||
Plugins
|
||||
*******
|
||||
@@ -0,0 +1,2 @@
|
||||
Command Reference
|
||||
*****************
|
||||
@@ -0,0 +1,2 @@
|
||||
System Variables
|
||||
****************
|
||||
@@ -0,0 +1,2 @@
|
||||
Rules
|
||||
*****
|
||||
@@ -0,0 +1,286 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Configuration file for the Sphinx documentation builder.
|
||||
#
|
||||
# This file does only contain a selection of the most common options. For a
|
||||
# full list see the documentation:
|
||||
# http://www.sphinx-doc.org/en/master/config
|
||||
|
||||
# -- Path setup --------------------------------------------------------------
|
||||
|
||||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
# add these directories to sys.path here. If the directory is relative to the
|
||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||
#
|
||||
# import os
|
||||
# import sys
|
||||
# sys.path.insert(0, os.path.abspath('.'))
|
||||
from recommonmark.parser import CommonMarkParser
|
||||
import sphinx_bootstrap_theme
|
||||
|
||||
|
||||
# -- Project information -----------------------------------------------------
|
||||
|
||||
project = u'ESPEasy'
|
||||
copyright = u'2018, ESPEasy'
|
||||
author = u'Many'
|
||||
|
||||
# The short X.Y version
|
||||
version = u''
|
||||
# The full version, including alpha/beta/rc tags
|
||||
release = u'2.1b1'
|
||||
|
||||
|
||||
# -- General configuration ---------------------------------------------------
|
||||
|
||||
# If your documentation needs a minimal Sphinx version, state it here.
|
||||
#
|
||||
# needs_sphinx = '1.0'
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be
|
||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
||||
# ones.
|
||||
extensions = [
|
||||
'sphinx.ext.autodoc',
|
||||
'sphinx.ext.intersphinx',
|
||||
'sphinx.ext.todo',
|
||||
'sphinx.ext.imgmath',
|
||||
'sphinx.ext.imgconverter',
|
||||
]
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
|
||||
source_parsers = {
|
||||
'.md': CommonMarkParser,
|
||||
}
|
||||
|
||||
# The suffix(es) of source filenames.
|
||||
# You can specify multiple suffix as a list of string:
|
||||
#
|
||||
source_suffix = ['.rst', '.md']
|
||||
#source_suffix = '.rst'
|
||||
|
||||
# The master toctree document.
|
||||
master_doc = 'index'
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
#
|
||||
# This is also used if you do content translation via gettext catalogs.
|
||||
# Usually you set "language" from the command line for these cases.
|
||||
language = None
|
||||
|
||||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
# This pattern also affects html_static_path and html_extra_path.
|
||||
exclude_patterns = []
|
||||
|
||||
# The name of the Pygments (syntax highlighting) style to use.
|
||||
pygments_style = None
|
||||
|
||||
|
||||
# -- Options for HTML output -------------------------------------------------
|
||||
html_logo = 'ESPEasy/espeasy_logo.png'
|
||||
html_favicon = 'ESPEasy/favicon.ico'
|
||||
|
||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||
# a list of builtin themes.
|
||||
#
|
||||
#html_theme = 'sphinx_rtd_theme'
|
||||
html_theme = 'bootstrap'
|
||||
html_theme_path = sphinx_bootstrap_theme.get_html_theme_path()
|
||||
|
||||
# Theme options are theme-specific and customize the look and feel of a theme
|
||||
# further. For a list of options available for each theme, see the
|
||||
# documentation.
|
||||
#
|
||||
# html_theme_options = {}
|
||||
#html_theme_options = {
|
||||
# 'canonical_url': '',
|
||||
# 'analytics_id': '',
|
||||
# 'logo_only': False,
|
||||
# 'display_version': True,
|
||||
# 'prev_next_buttons_location': 'bottom',
|
||||
# 'style_external_links': False,
|
||||
# # Toc options
|
||||
# 'collapse_navigation': True,
|
||||
# 'sticky_navigation': True,
|
||||
# 'navigation_depth': 4,
|
||||
# 'includehidden': True,
|
||||
# 'titles_only': False
|
||||
#}
|
||||
|
||||
html_theme_options = {
|
||||
# Navigation bar title. (Default: ``project`` value)
|
||||
'navbar_title': "ESPEasy",
|
||||
|
||||
# Tab name for entire site. (Default: "Site")
|
||||
'navbar_site_name': "Site",
|
||||
|
||||
# A list of tuples containing pages or urls to link to.
|
||||
# Valid tuples should be in the following forms:
|
||||
# (name, page) # a link to a page
|
||||
# (name, "/aa/bb", 1) # a link to an arbitrary relative url
|
||||
# (name, "http://example.com", True) # arbitrary absolute url
|
||||
# Note the "1" or "True" value above as the third argument to indicate
|
||||
# an arbitrary url.
|
||||
'navbar_links': [
|
||||
("Rules", "rules"),
|
||||
("Forum", "https://www.letscontrolit.com/forum/viewforum.php?f=1", True),
|
||||
],
|
||||
|
||||
# Render the next and previous page links in navbar. (Default: true)
|
||||
'navbar_sidebarrel': True,
|
||||
|
||||
# Render the current pages TOC in the navbar. (Default: true)
|
||||
'navbar_pagenav': True,
|
||||
|
||||
# Tab name for the current pages TOC. (Default: "Page")
|
||||
'navbar_pagenav_name': "Page",
|
||||
|
||||
# Global TOC depth for "site" navbar tab. (Default: 1)
|
||||
# Switching to -1 shows all levels.
|
||||
'globaltoc_depth': 2,
|
||||
|
||||
# Include hidden TOCs in Site navbar?
|
||||
#
|
||||
# Note: If this is "false", you cannot have mixed ``:hidden:`` and
|
||||
# non-hidden ``toctree`` directives in the same page, or else the build
|
||||
# will break.
|
||||
#
|
||||
# Values: "true" (default) or "false"
|
||||
'globaltoc_includehidden': "true",
|
||||
|
||||
# HTML navbar class (Default: "navbar") to attach to <div> element.
|
||||
# For black navbar, do "navbar navbar-inverse"
|
||||
'navbar_class': "navbar navbar-inverse",
|
||||
|
||||
# Fix navigation bar to top of page?
|
||||
# Values: "true" (default) or "false"
|
||||
'navbar_fixed_top': "true",
|
||||
|
||||
# Location of link to source.
|
||||
# Options are "nav" (default), "footer" or anything else to exclude.
|
||||
'source_link_position': "none",
|
||||
|
||||
# Bootswatch (http://bootswatch.com/) theme.
|
||||
#
|
||||
# Options are nothing (default) or the name of a valid theme
|
||||
# such as "cosmo" or "sandstone".
|
||||
#
|
||||
# The set of valid themes depend on the version of Bootstrap
|
||||
# that's used (the next config option).
|
||||
#
|
||||
# Currently, the supported themes are:
|
||||
# - Bootstrap 2: https://bootswatch.com/2
|
||||
# - Bootstrap 3: https://bootswatch.com/3
|
||||
'bootswatch_theme': "cerulean",
|
||||
|
||||
# Choose Bootstrap version.
|
||||
# Values: "3" (default) or "2" (in quotes)
|
||||
'bootstrap_version': "3",
|
||||
}
|
||||
|
||||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
html_static_path = ['_static']
|
||||
|
||||
# Custom sidebar templates, must be a dictionary that maps document names
|
||||
# to template names.
|
||||
#
|
||||
# The default sidebars (for documents that don't match any pattern) are
|
||||
# defined by theme itself. Builtin themes are using these templates by
|
||||
# default: ``['localtoc.html', 'relations.html', 'sourcelink.html',
|
||||
# 'searchbox.html']``.
|
||||
#
|
||||
# html_sidebars = {}
|
||||
|
||||
|
||||
# -- Options for HTMLHelp output ---------------------------------------------
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = 'ESPEasydoc'
|
||||
|
||||
|
||||
# -- Options for LaTeX output ------------------------------------------------
|
||||
|
||||
latex_elements = {
|
||||
# The paper size ('letterpaper' or 'a4paper').
|
||||
#
|
||||
# 'papersize': 'letterpaper',
|
||||
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
#
|
||||
# 'pointsize': '10pt',
|
||||
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
#
|
||||
# 'preamble': '',
|
||||
|
||||
# Latex figure (float) alignment
|
||||
#
|
||||
# 'figure_align': 'htbp',
|
||||
}
|
||||
|
||||
# Grouping the document tree into LaTeX files. List of tuples
|
||||
# (source start file, target name, title,
|
||||
# author, documentclass [howto, manual, or own class]).
|
||||
latex_documents = [
|
||||
(master_doc, 'ESPEasy.tex', u'ESPEasy Documentation',
|
||||
u'Many', 'manual'),
|
||||
]
|
||||
|
||||
|
||||
# -- Options for manual page output ------------------------------------------
|
||||
|
||||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
(master_doc, 'espeasy', u'ESPEasy Documentation',
|
||||
[author], 1)
|
||||
]
|
||||
|
||||
|
||||
# -- Options for Texinfo output ----------------------------------------------
|
||||
|
||||
# Grouping the document tree into Texinfo files. List of tuples
|
||||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
(master_doc, 'ESPEasy', u'ESPEasy Documentation',
|
||||
author, 'ESPEasy', 'ESP82xx/ESP32 firmware to connect people with any level of experience to system automation.',
|
||||
'Miscellaneous'),
|
||||
]
|
||||
|
||||
|
||||
# -- Options for Epub output -------------------------------------------------
|
||||
|
||||
# Bibliographic Dublin Core info.
|
||||
epub_title = project
|
||||
|
||||
# The unique identifier of the text. This can be a ISBN number
|
||||
# or the project homepage.
|
||||
#
|
||||
# epub_identifier = ''
|
||||
|
||||
# A unique identification for the text.
|
||||
#
|
||||
# epub_uid = ''
|
||||
|
||||
# A list of files that should not be packed into the epub file.
|
||||
epub_exclude_files = ['search.html']
|
||||
|
||||
|
||||
# -- Extension configuration -------------------------------------------------
|
||||
|
||||
# -- Options for intersphinx extension ---------------------------------------
|
||||
|
||||
# Example configuration for intersphinx: refer to the Python standard library.
|
||||
intersphinx_mapping = {'https://docs.python.org/': None}
|
||||
|
||||
# -- Options for todo extension ----------------------------------------------
|
||||
|
||||
# If true, `todo` and `todoList` produce output, else they produce nothing.
|
||||
todo_include_todos = True
|
||||
@@ -0,0 +1,38 @@
|
||||
.. ESPEasy documentation master file, created by
|
||||
sphinx-quickstart on Sat Oct 06 22:34:34 2018.
|
||||
You can adapt this file completely to your liking, but it should at least
|
||||
contain the root `toctree` directive.
|
||||
|
||||
Welcome to ESPEasy's documentation!
|
||||
===================================
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:caption: Table of Contents
|
||||
|
||||
ESPEasy/AboutUs.rst
|
||||
ESPEasy/FunctionBlocks.rst
|
||||
Controller/Controller.rst
|
||||
Plugin/Plugin.rst
|
||||
Rules/Rules.rst
|
||||
|
||||
.. raw:: latex
|
||||
|
||||
\appendix
|
||||
|
||||
|
||||
.. toctree::
|
||||
:caption: Appendix
|
||||
|
||||
Participate/Documentation.rst
|
||||
Reference/Command.rst
|
||||
Reference/SystemVariable.rst
|
||||
|
||||
|
||||
|
||||
Indices and tables
|
||||
==================
|
||||
|
||||
* :ref:`genindex`
|
||||
* :ref:`modindex`
|
||||
* :ref:`search`
|
||||
@@ -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, 0x140000,
|
||||
app1, app, ota_1, 0x150000,0x140000,
|
||||
eeprom, data, 0x99, 0x290000,0x1000,
|
||||
spiffs, data, spiffs, 0x291000,0x16F000,
|
||||
|
@@ -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,
|
||||
|
@@ -6,12 +6,13 @@
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#include "NewPingESP8266.h"
|
||||
|
||||
//#include "ESPEasy-Globals.h"
|
||||
// ---------------------------------------------------------------------------
|
||||
// NewPingESP8266 constructor
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
NewPingESP8266::NewPingESP8266(uint32_t trigger_pin, uint32_t echo_pin, unsigned int max_cm_distance) {
|
||||
_errorState = STATUS_SENSOR_READY;
|
||||
#if DO_BITWISE == true
|
||||
_triggerBit = digitalPinToBitMask(trigger_pin); // Get the port register bitmask for the trigger pin.
|
||||
_echoBit = digitalPinToBitMask(echo_pin); // Get the port register bitmask for the echo pin.
|
||||
@@ -58,7 +59,10 @@ unsigned int NewPingESP8266::ping(unsigned int max_cm_distance) {
|
||||
while (!digitalRead(_echoPin)) // Wait for the ping echo.
|
||||
#endif
|
||||
{
|
||||
if (micros() > _max_time) return NO_ECHO; // Stop the loop and return NO_ECHO (false) if we're beyond the set maximum distance.
|
||||
if ((_max_cm_distance > 0) && (micros() > _max_time)) {
|
||||
_errorState = STATUS_MAX_DISTANCE_EXCEEDED;
|
||||
return NO_ECHO; // Stop the loop and return NO_ECHO (false) if we're beyond the set maximum distance.
|
||||
}
|
||||
}
|
||||
#else
|
||||
#if DO_BITWISE == true
|
||||
@@ -67,10 +71,14 @@ unsigned int NewPingESP8266::ping(unsigned int max_cm_distance) {
|
||||
while (digitalRead(_echoPin)) // Wait for the ping echo.
|
||||
#endif
|
||||
{
|
||||
if (micros() > _max_time) return NO_ECHO; // Stop the loop and return NO_ECHO (false) if we're beyond the set maximum distance.
|
||||
if ((_max_cm_distance > 0) && (micros() > _max_time)) {
|
||||
_errorState = STATUS_MAX_DISTANCE_EXCEEDED;
|
||||
return NO_ECHO; // Stop the loop and return NO_ECHO (false) if we're beyond the set maximum distance.
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
_errorState = STATUS_MEASUREMENT_VALID;
|
||||
return (micros() - (_max_time - _maxEchoTime) - PING_OVERHEAD); // Calculate ping time, include overhead.
|
||||
}
|
||||
|
||||
@@ -144,15 +152,39 @@ boolean NewPingESP8266::ping_trigger() {
|
||||
#endif
|
||||
|
||||
#if URM37_ENABLED == true
|
||||
if (!(*_echoInput & _echoBit)) return false; // Previous ping hasn't finished, abort.
|
||||
if (!(*_echoInput & _echoBit)) { // Previous ping hasn't finished, abort.{
|
||||
_errorState = STATUS_ECHO_STATE_ERROR;
|
||||
return false;
|
||||
}
|
||||
_max_time = micros() + _maxEchoTime + MAX_SENSOR_DELAY; // Maximum time we'll wait for ping to start (most sensors are <450uS, the SRF06 can take up to 34,300uS!)
|
||||
while (*_echoInput & _echoBit) // Wait for ping to start.
|
||||
if (micros() > _max_time) return false; // Took too long to start, abort.
|
||||
{
|
||||
if (millis() > (start + 50)) {
|
||||
_errorState = STATUS_ECHO_START_TIMEOUT_50ms;
|
||||
return false;
|
||||
}
|
||||
if ((_max_cm_distance > 0) && (micros() > _max_time)) { // check max. distance if != 0 cm
|
||||
_errorState = STATUS_ECHO_START_TIMEOUT_DISTANCE;
|
||||
return false; // echo too late, max distance exceeded
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (*_echoInput & _echoBit) return false; // Previous ping hasn't finished, abort.
|
||||
if (*_echoInput & _echoBit) { // Previous ping hasn't finished, abort.
|
||||
_errorState = STATUS_ECHO_STATE_ERROR;
|
||||
return false;
|
||||
}
|
||||
_max_time = micros() + _maxEchoTime + MAX_SENSOR_DELAY; // Maximum time we'll wait for ping to start (most sensors are <450uS, the SRF06 can take up to 34,300uS!)
|
||||
while (!(*_echoInput & _echoBit)) // Wait for ping to start.
|
||||
if (micros() > _max_time) return false; // Took too long to start, abort.
|
||||
{
|
||||
if (millis() > (start + 50)) {
|
||||
_errorState = STATUS_ECHO_START_TIMEOUT_50ms;
|
||||
return false;
|
||||
}
|
||||
if ((_max_cm_distance > 0) && (micros() > _max_time)) { // check max. distance if != 0 cm
|
||||
_errorState = STATUS_ECHO_START_TIMEOUT_DISTANCE;
|
||||
return false; // echo too late, max distance exceeded
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
#if ONE_PIN_ENABLED == true
|
||||
@@ -170,30 +202,51 @@ boolean NewPingESP8266::ping_trigger() {
|
||||
#endif
|
||||
|
||||
#if URM37_ENABLED == true
|
||||
if (!digitalRead(_echoPin)) return false; // Previous ping hasn't finished, abort.
|
||||
if (!digitalRead(_echoPin)) {
|
||||
_errorState = STATUS_ECHO_STATE_ERROR;
|
||||
return false; // Previous ping hasn't finished, abort.
|
||||
}
|
||||
_max_time = micros() + _maxEchoTime + MAX_SENSOR_DELAY; // Maximum time we'll wait for ping to start (most sensors are <450uS, the SRF06 can take up to 34,300uS!)
|
||||
while (digitalRead(_echoPin)) // Wait for ping to start.
|
||||
{
|
||||
if (millis() > (start + 50)) return false;
|
||||
if (micros() > _max_time) return false; // Took too long to start, abort.
|
||||
if (millis() > (start + 50)) {
|
||||
_errorState = STATUS_ECHO_START_TIMEOUT_50ms;
|
||||
return false;
|
||||
}
|
||||
if ((_max_cm_distance > 0) && (micros() > _max_time)) { // check max. distance if != 0 cm
|
||||
_errorState = STATUS_ECHO_START_TIMEOUT_DISTANCE;
|
||||
return false; // echo too late, max distance exceeded
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (digitalRead(_echoPin)) return false; // Previous ping hasn't finished, abort.
|
||||
if (digitalRead(_echoPin)) {
|
||||
_errorState = STATUS_ECHO_STATE_ERROR;
|
||||
return false; // Previous ping hasn't finished, abort.
|
||||
}
|
||||
_max_time = micros() + _maxEchoTime + MAX_SENSOR_DELAY; // Maximum time we'll wait for ping to start (most sensors are <450uS, the SRF06 can take up to 34,300uS!)
|
||||
while (!digitalRead(_echoPin)) // Wait for ping to start.
|
||||
{
|
||||
if (millis() > (start + 50)) return false;
|
||||
if (micros() > _max_time) return false; // Took too long to start, abort.
|
||||
if (millis() > (start + 50)) {
|
||||
_errorState = STATUS_ECHO_START_TIMEOUT_50ms;
|
||||
return false;
|
||||
}
|
||||
if ((_max_cm_distance > 0) && (micros() > _max_time)) { // check max. distance if != 0 cm
|
||||
_errorState = STATUS_ECHO_START_TIMEOUT_DISTANCE;
|
||||
return false; // echo too late, max distance exceeded
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
_max_time = micros() + _maxEchoTime; // Ping started, set the time-out.
|
||||
_errorState = STATUS_ECHO_TRIGGERED;
|
||||
|
||||
return true; // Ping started successfully.
|
||||
}
|
||||
|
||||
|
||||
void NewPingESP8266::set_max_distance(unsigned int max_cm_distance) {
|
||||
_max_cm_distance = max_cm_distance;
|
||||
#if ROUNDING_ENABLED == false
|
||||
_maxEchoTime = min(max_cm_distance + 1, (unsigned int) MAX_SENSOR_DISTANCE + 1) * US_ROUNDTRIP_CM; // Calculate the maximum distance in uS (no rounding).
|
||||
#else
|
||||
@@ -222,3 +275,12 @@ unsigned int NewPingESP8266::convert_in(unsigned int echoTime) {
|
||||
return NewPingESP8266Convert(echoTime, US_ROUNDTRIP_IN); // Convert uS to inches.
|
||||
#endif
|
||||
}
|
||||
|
||||
float NewPingESP8266::convert_cm_F(unsigned int echoTime) {
|
||||
return ((float)echoTime / US_ROUNDTRIP_CM); // Convert uS to centimeters (no rounding).
|
||||
}
|
||||
|
||||
|
||||
float NewPingESP8266::convert_in_F(unsigned int echoTime) {
|
||||
return ((float)echoTime / US_ROUNDTRIP_IN); // Convert uS to inches (no rounding).
|
||||
}
|
||||
|
||||
@@ -194,15 +194,29 @@
|
||||
|
||||
class NewPingESP8266 {
|
||||
public:
|
||||
enum errorState {
|
||||
STATUS_SENSOR_READY, // no error, no measruement started
|
||||
STATUS_MEASUREMENT_VALID, // no errors
|
||||
STATUS_ECHO_TRIGGERED, // echo triggered, intermediate state
|
||||
STATUS_MAX_DISTANCE_EXCEEDED, // echo too late, maximum distance exceeded
|
||||
STATUS_ECHO_START_TIMEOUT_50ms, // no echo start signal after 50 ms
|
||||
STATUS_ECHO_START_TIMEOUT_DISTANCE, // no echo start signal after max. distance
|
||||
STATUS_ECHO_STATE_ERROR // echopin level not low after triggered
|
||||
};
|
||||
|
||||
NewPingESP8266(uint32_t trigger_pin, uint32_t echo_pin, unsigned int max_cm_distance = MAX_SENSOR_DISTANCE);
|
||||
~NewPingESP8266() { };
|
||||
unsigned int ping(unsigned int max_cm_distance = 0);
|
||||
unsigned long ping_cm(unsigned int max_cm_distance = 0);
|
||||
unsigned long ping_in(unsigned int max_cm_distance = 0);
|
||||
unsigned long ping_median(uint32_t it = 5, unsigned int max_cm_distance = 0);
|
||||
static unsigned int convert_cm(unsigned int echoTime);
|
||||
static unsigned int convert_in(unsigned int echoTime);
|
||||
static float convert_cm_F(unsigned int echoTime);
|
||||
static float convert_in_F(unsigned int echoTime);
|
||||
|
||||
unsigned int getMaxEchoTime() { return _maxEchoTime; }
|
||||
unsigned int getMaxEchoTime() { return _maxEchoTime; };
|
||||
errorState getErrorState() { return _errorState; };
|
||||
private:
|
||||
boolean ping_trigger();
|
||||
void set_max_distance(unsigned int max_cm_distance);
|
||||
@@ -218,6 +232,8 @@ class NewPingESP8266 {
|
||||
#endif
|
||||
unsigned int _maxEchoTime;
|
||||
unsigned long _max_time;
|
||||
errorState _errorState;
|
||||
unsigned int _max_cm_distance;
|
||||
};
|
||||
|
||||
|
||||
|
||||
+73
-28
@@ -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
|
||||
@@ -72,20 +73,23 @@ platform = espressif32@1.2.0
|
||||
[core_esp32_1_3_0]
|
||||
platform = espressif32@1.3.0
|
||||
|
||||
[core_esp32_1_4_0]
|
||||
platform = espressif32@1.4.0
|
||||
|
||||
[core_esp32_stage]
|
||||
platform = https://github.com/platformio/platform-espressif32.git#feature/stage
|
||||
|
||||
[core_esp32]
|
||||
platform = ${core_esp32_0_12_0.platform}
|
||||
platform = ${core_esp32_1_4_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,15 +104,20 @@ 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. (starting core_2.4.2)
|
||||
; ESP8266_DISABLE_EXTRA4K - Calls disable_extra4k_at_link_time() from setup
|
||||
; to force the linker keep user's stack in user ram.
|
||||
; CONT_STACKSIZE to set the 'cont' (Arduino) stack size. Default = 4096
|
||||
|
||||
[common]
|
||||
board_build.f_cpu = 80000000L
|
||||
build_unflags = ""
|
||||
build_unflags =
|
||||
build_flags = -D BUILD_GIT='"${sysenv.TRAVIS_TAG}"'
|
||||
-D NDEBUG
|
||||
-lstdc++ -lsupc++
|
||||
-DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY
|
||||
-DPIO_FRAMEWORK_ARDUINO_LWIP_HIGHER_BANDWIDTH
|
||||
-DVTABLES_IN_FLASH
|
||||
|
||||
|
||||
@@ -119,18 +128,20 @@ lib_archive = false
|
||||
upload_speed = 460800
|
||||
framework = arduino
|
||||
board = esp12e
|
||||
platform = ${core_2_4_2.platform}
|
||||
platform = ${core_2_4_1.platform}
|
||||
monitor_speed = 115200
|
||||
|
||||
|
||||
[normal]
|
||||
platform = ${common.platform}
|
||||
build_flags =
|
||||
|
||||
[testing]
|
||||
platform = ${core_2_4_2.platform}
|
||||
platform = ${core_2_4_1.platform}
|
||||
build_flags = -DPLUGIN_BUILD_TESTING
|
||||
|
||||
[dev]
|
||||
platform = ${core_2_4_2.platform}
|
||||
platform = ${core_2_4_1.platform}
|
||||
build_flags = -DPLUGIN_BUILD_DEV
|
||||
|
||||
[ir]
|
||||
lib_ignore = ESP32_ping, ESP32WebServer
|
||||
@@ -158,7 +169,7 @@ board_build.flash_mode = ${esp8266_1M.board_build.flash_mode}
|
||||
board_build.f_cpu = ${esp8266_1M.board_build.f_cpu}
|
||||
build_unflags = ${common.build_unflags}
|
||||
build_flags = ${common.build_flags} -Wl,-Tesp8266.flash.1m128.ld
|
||||
platform = ${core_2_4_2.platform}
|
||||
platform = ${core_2_4_1.platform}
|
||||
|
||||
[Sonoff_8285]
|
||||
board_upload.maximum_size = ${esp8285_1M.board_upload.maximum_size}
|
||||
@@ -167,7 +178,7 @@ board_build.f_cpu = ${esp8285_1M.board_build.f_cpu}
|
||||
board = ${esp8285_1M.board}
|
||||
build_unflags = ${esp8285_1M.build_unflags}
|
||||
build_flags = ${esp8285_1M.build_flags}
|
||||
platform = ${core_2_4_2.platform}
|
||||
platform = ${core_2_4_1.platform}
|
||||
|
||||
[espWroom2M]
|
||||
board_build.flash_mode = dout
|
||||
@@ -193,6 +204,25 @@ build_flags = ${common.build_flags} -Wl,-Tesp8266.flash.4m1m.ld
|
||||
; Will probably not work, not tested and guaranteed to take a few hours time of some ;
|
||||
; still trying to build the version without reading this warning. ;
|
||||
; *********************************************************************
|
||||
[env:esp-wrover-kit_test_1M8_partition]
|
||||
platform = ${core_esp32.platform}
|
||||
board = esp-wrover-kit
|
||||
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}
|
||||
upload_protocol = ftdi
|
||||
debug_tool = ftdi
|
||||
monitor_speed = ${common.monitor_speed}
|
||||
board_build.partitions = esp32_partition_app1810k_spiffs316k.csv
|
||||
board_upload.maximum_size = 1900544
|
||||
debug_extra_cmds = break Misc.ino:3011
|
||||
|
||||
|
||||
[env:esp32dev]
|
||||
platform = ${core_esp32.platform}
|
||||
board = esp32dev
|
||||
@@ -206,6 +236,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 +271,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 +288,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 +304,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 +320,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 +338,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 +360,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 +377,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 +393,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 +409,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 +425,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 +448,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 +465,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 +481,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 +497,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 +520,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 +537,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
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Check for documentation only changes.
|
||||
# Source: https://github.com/dev-id/Magic-Spoiler/blob/8111a06ab6682e020169991d5e2aa4fa503d787f/preflight.sh
|
||||
|
||||
set -e
|
||||
MAIN_BRANCH="mega"
|
||||
MD=".md$"
|
||||
DOCS="^docs/"
|
||||
|
||||
CHANGED_FILES=`git diff --name-only ${MAIN_BRANCH}...${TRAVIS_COMMIT}`
|
||||
ONLY_READMES=True
|
||||
DOCUMENTATION_CHANGED=False
|
||||
|
||||
for CHANGED_FILE in $CHANGED_FILES; do
|
||||
if ! [[ $CHANGED_FILE =~ $MD || $CHANGED_FILE =~ $DOCS ]]; then
|
||||
ONLY_READMES=False
|
||||
# break
|
||||
else
|
||||
DOCUMENTATION_CHANGED=True
|
||||
fi
|
||||
done
|
||||
|
||||
#if [[ $ONLY_READMES == True ]]; then
|
||||
# echo "Only documentation files found, exiting."
|
||||
# travis_terminate 0
|
||||
# exit 1
|
||||
#else
|
||||
# echo "Non-documentation files found, continuing with build."
|
||||
#fi
|
||||
|
||||
if [[ $DOCUMENTATION_CHANGED == True ]]; then
|
||||
echo "Generate documentation."
|
||||
cd docs
|
||||
make html
|
||||
fi
|
||||
+8
-6
@@ -79,6 +79,7 @@ String doExecuteCommand(const char * cmd, struct EventStruct *event, const char*
|
||||
break;
|
||||
}
|
||||
case 'l': {
|
||||
COMMAND_CASE("let" , Command_Rules_Let); // Rules.h
|
||||
COMMAND_CASE("load" , Command_Settings_Load); // Settings.h
|
||||
COMMAND_CASE("logentry" , Command_logentry); // Diagnostic.h
|
||||
COMMAND_CASE("lowmem" , Command_Lowmem); // Diagnostic.h
|
||||
@@ -131,7 +132,8 @@ String doExecuteCommand(const char * cmd, struct EventStruct *event, const char*
|
||||
COMMAND_CASE("taskclear" , Command_Task_Clear); // Tasks.h
|
||||
COMMAND_CASE("taskclearall" , Command_Task_ClearAll); // Tasks.h
|
||||
COMMAND_CASE("taskrun" , Command_Task_Run); // Tasks.h
|
||||
COMMAND_CASE("taskvalueset" , Command_Task_ValueSet); // Tasks.h
|
||||
COMMAND_CASE("taskvalueset" , Command_Task_ValueSet); // Tasks.h
|
||||
COMMAND_CASE("taskvaluetoggle" , Command_Task_ValueToggle); // Tasks.h
|
||||
COMMAND_CASE("taskvaluesetandrun" , Command_Task_ValueSetAndRun); // Tasks.h
|
||||
COMMAND_CASE("timerpause" , Command_Timer_Pause); // Timers.h
|
||||
COMMAND_CASE("timerresume" , Command_Timer_Resume); // Timers.h
|
||||
@@ -216,11 +218,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
|
||||
|
||||
+3
-2
@@ -24,7 +24,8 @@ String Command_HTTP_SendToHTTP(struct EventStruct *event, const char* Line)
|
||||
}
|
||||
WiFiClient client;
|
||||
const int port_int = port.toInt();
|
||||
if (client.connect(host.c_str(), port_int) != 1) {
|
||||
const bool connected = client.connect(host.c_str(), port_int) == 1;
|
||||
if (connected) {
|
||||
String hostportString = host;
|
||||
if (port_int != 0 && port_int != 80) {
|
||||
hostportString += ':';
|
||||
@@ -32,7 +33,7 @@ String Command_HTTP_SendToHTTP(struct EventStruct *event, const char* Line)
|
||||
}
|
||||
String request = do_create_http_request(hostportString, F("GET"), path);
|
||||
addLog(LOG_LEVEL_DEBUG, request);
|
||||
send_via_http(F("Command_HTTP_SendToHTTP"), client, request);
|
||||
send_via_http(F("Command_HTTP_SendToHTTP"), client, request, false);
|
||||
}
|
||||
}
|
||||
return return_command_success();
|
||||
|
||||
@@ -34,4 +34,15 @@ String Command_Rules_Events(struct EventStruct *event, const char* Line)
|
||||
return return_command_success();
|
||||
}
|
||||
|
||||
String Command_Rules_Let(struct EventStruct *event, const char* Line)
|
||||
{
|
||||
char TmpStr1[INPUT_COMMAND_SIZE];
|
||||
if (GetArgv(Line, TmpStr1, 3)) {
|
||||
float result = 0;
|
||||
Calculate(TmpStr1, &result);
|
||||
customFloatVar[event->Par1-1] = result;
|
||||
}
|
||||
return return_command_success();
|
||||
}
|
||||
|
||||
#endif // COMMAND_RULES_H
|
||||
|
||||
@@ -30,6 +30,15 @@ String Command_Task_ValueSet(struct EventStruct *event, const char* Line)
|
||||
return return_command_success();
|
||||
}
|
||||
|
||||
String Command_Task_ValueToggle(struct EventStruct *event, const char* Line)
|
||||
{
|
||||
const int result = round(UserVar[(VARS_PER_TASK * (event->Par1 - 1)) + event->Par2 - 1]);
|
||||
if (result == 0 || result == 1) {
|
||||
UserVar[(VARS_PER_TASK * (event->Par1 - 1)) + event->Par2 - 1] = !result;
|
||||
}
|
||||
return return_command_success();
|
||||
}
|
||||
|
||||
String Command_Task_ValueSetAndRun(struct EventStruct *event, const char* Line)
|
||||
{
|
||||
char TmpStr1[INPUT_COMMAND_SIZE];
|
||||
|
||||
+17
-7
@@ -132,8 +132,8 @@ void callback(char* c_topic, byte* b_payload, unsigned int length) {
|
||||
bool MQTTConnect(int controller_idx)
|
||||
{
|
||||
++mqtt_reconnect_count;
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(controller_idx, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
MakeControllerSettings(ControllerSettings);
|
||||
LoadControllerSettings(controller_idx, ControllerSettings);
|
||||
if (!ControllerSettings.checkHostReachable(true))
|
||||
return false;
|
||||
if (MQTTclient.connected()) {
|
||||
@@ -141,6 +141,7 @@ bool MQTTConnect(int controller_idx)
|
||||
updateMQTTclient_connected();
|
||||
}
|
||||
mqtt = WiFiClient(); // workaround see: https://github.com/esp8266/Arduino/issues/4497#issuecomment-373023864
|
||||
mqtt.setTimeout(ControllerSettings.ClientTimeout);
|
||||
if (ControllerSettings.UseDNS) {
|
||||
MQTTclient.setServer(ControllerSettings.getHost().c_str(), ControllerSettings.Port);
|
||||
} else {
|
||||
@@ -161,6 +162,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)
|
||||
@@ -283,9 +293,9 @@ void scheduleNextMQTTdelayQueue() {
|
||||
|
||||
void processMQTTdelayQueue() {
|
||||
START_TIMER;
|
||||
MQTT_queue_element element;
|
||||
if (!MQTTDelayHandler.getNext(element)) return;
|
||||
if (MQTTclient.publish(element._topic.c_str(), element._payload.c_str(), element._retained)) {
|
||||
MQTT_queue_element* element(MQTTDelayHandler.getNext());
|
||||
if (element == NULL) return;
|
||||
if (MQTTclient.publish(element->_topic.c_str(), element->_payload.c_str(), element->_retained)) {
|
||||
setIntervalTimerOverride(TIMER_MQTT, 10); // Make sure the MQTT is being processed as soon as possible.
|
||||
MQTTDelayHandler.markProcessed(true);
|
||||
} else {
|
||||
@@ -306,10 +316,10 @@ void processMQTTdelayQueue() {
|
||||
\*********************************************************************************************/
|
||||
void MQTTStatus(String& status)
|
||||
{
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
MakeControllerSettings(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);
|
||||
|
||||
+241
-104
@@ -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?
|
||||
|
||||
@@ -76,7 +79,7 @@
|
||||
#define DEFAULT_MQTT_LWT_TOPIC "" // Default lwt topic
|
||||
#define DEFAULT_MQTT_LWT_CONNECT_MESSAGE "Connected" // Default lwt message
|
||||
#define DEFAULT_MQTT_LWT_DISCONNECT_MESSAGE "Connection Lost" // Default lwt message
|
||||
#define DEFAULT_MQTT_USE_UNITNANE_AS_CLIENTID 0
|
||||
#define DEFAULT_MQTT_USE_UNITNAME_AS_CLIENTID 0
|
||||
|
||||
#define DEFAULT_USE_NTP false // (true|false) Use NTP Server
|
||||
#define DEFAULT_NTP_HOST "" // NTP Server Hostname
|
||||
@@ -188,6 +191,8 @@
|
||||
|
||||
#define MAX_FLASHWRITES_PER_DAY 100 // per 24 hour window
|
||||
#define INPUT_COMMAND_SIZE 240 // Affects maximum command length in rules and other commands
|
||||
// FIXME TD-er: INPUT_COMMAND_SIZE is also used in commands where simply a check for valid parameter is needed
|
||||
// and some may need less memory. (which is stack allocated)
|
||||
|
||||
#define NODE_TYPE_ID_ESP_EASY_STD 1
|
||||
#define NODE_TYPE_ID_ESP_EASYM_STD 17
|
||||
@@ -223,6 +228,9 @@
|
||||
// N.B. Retries without a connection to wifi do not count as retry.
|
||||
#define CONTROLLER_DELAY_QUEUE_RETRY_MAX 10
|
||||
#define CONTROLLER_DELAY_QUEUE_RETRY_DFLT 10
|
||||
// Timeout of the client in msec.
|
||||
#define CONTROLLER_CLIENTTIMEOUT_MAX 1000
|
||||
#define CONTROLLER_CLIENTTIMEOUT_DFLT 300
|
||||
|
||||
|
||||
#define PLUGIN_INIT_ALL 1
|
||||
@@ -284,6 +292,7 @@
|
||||
#define NPLUGIN_NOT_FOUND 255
|
||||
|
||||
|
||||
#define LOG_LEVEL_NONE 0
|
||||
#define LOG_LEVEL_ERROR 1
|
||||
#define LOG_LEVEL_INFO 2
|
||||
#define LOG_LEVEL_DEBUG 3
|
||||
@@ -297,7 +306,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 +338,9 @@
|
||||
#define RULESETS_MAX 4
|
||||
#define RULES_BUFFER_SIZE 64
|
||||
#define NAME_FORMULA_LENGTH_MAX 40
|
||||
#define RULES_IF_MAX_NESTING_LEVEL 4
|
||||
#define CUSTOM_VARS_MAX 16
|
||||
|
||||
#define UDP_PACKETSIZE_MAX 2048
|
||||
|
||||
#define PIN_MODE_UNDEFINED 0
|
||||
@@ -357,6 +373,9 @@
|
||||
#define SENSOR_TYPE_LONG 20
|
||||
#define SENSOR_TYPE_WIND 21
|
||||
|
||||
#define UNIT_NUMBER_MAX 9999 // Stored in Settings.Unit
|
||||
#define DOMOTICZ_MAX_IDX 999999999 // Looks like it is an unsigned int, so could be up to 4 bln.
|
||||
|
||||
#define VALUE_SOURCE_SYSTEM 1
|
||||
#define VALUE_SOURCE_SERIAL 2
|
||||
#define VALUE_SOURCE_HTTP 3
|
||||
@@ -393,14 +412,21 @@
|
||||
#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);
|
||||
void addToLog(byte logLevel, const __FlashStringHelper* flashString);
|
||||
void statusLED(boolean traffic);
|
||||
void backgroundtasks();
|
||||
uint32_t getCurrentFreeStack();
|
||||
uint32_t getFreeStackWatermark();
|
||||
bool canYield();
|
||||
|
||||
bool getBitFromUL(uint32_t number, byte bitnr);
|
||||
void setBitToUL(uint32_t& number, byte bitnr, bool value);
|
||||
|
||||
enum SettingsType {
|
||||
BasicSettings_Type = 0,
|
||||
@@ -512,10 +538,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
|
||||
@@ -575,14 +601,17 @@ bool MQTTclient_should_reconnect = true;
|
||||
bool MQTTclient_connected = false;
|
||||
int mqtt_reconnect_count = 0;
|
||||
|
||||
//NTP status
|
||||
bool statusNTPInitialized = false;
|
||||
|
||||
// mqtt import status
|
||||
bool P037_MQTTImport_connected = false;
|
||||
|
||||
// udp protocol stuff (syslog, global sync, node info list, ntp time)
|
||||
WiFiUDP portUDP;
|
||||
|
||||
class TimingStats;
|
||||
|
||||
#define LOADFILE_STATS 0
|
||||
#define LOOP_STATS 1
|
||||
|
||||
/*********************************************************************************************\
|
||||
* CRCStruct
|
||||
\*********************************************************************************************/
|
||||
@@ -650,6 +679,16 @@ struct SecurityStruct
|
||||
uint8_t md5[16];
|
||||
} SecuritySettings;
|
||||
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Custom Variables for usage in rules and http.
|
||||
* Syntax: %vX%
|
||||
* usage:
|
||||
* let,1,10
|
||||
* if %v1%=10 do ...
|
||||
\*********************************************************************************************/
|
||||
float customFloatVar[CUSTOM_VARS_MAX];
|
||||
|
||||
/*********************************************************************************************\
|
||||
* SettingsStruct
|
||||
\*********************************************************************************************/
|
||||
@@ -659,17 +698,46 @@ 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;
|
||||
}
|
||||
|
||||
bool networkSettingsEmpty() {
|
||||
return (IP[0] == 0 && Gateway[0] == 0 && Subnet[0] == 0 && DNS[0] == 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;
|
||||
@@ -694,13 +762,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;
|
||||
@@ -713,6 +785,7 @@ struct SettingsStruct
|
||||
for (byte task = 0; task < TASKS_MAX; ++task) {
|
||||
clearTask(task);
|
||||
}
|
||||
clearNetworkSettings();
|
||||
}
|
||||
|
||||
void clearTask(byte task) {
|
||||
@@ -827,6 +900,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
|
||||
@@ -834,15 +908,35 @@ 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
|
||||
* Analyze SettingsStruct and report inconsistencies
|
||||
* Not a member function to be able to use the F-macro
|
||||
\*********************************************************************************************/
|
||||
bool SettingsCheck(String& error) {
|
||||
error = "";
|
||||
if (!Settings.networkSettingsEmpty()) {
|
||||
if (Settings.IP[0] == 0 || Settings.Gateway[0] == 0 || Settings.Subnet[0] == 0 || Settings.DNS[0] == 0) {
|
||||
error += F("Error: Either fill all IP settings fields or leave all empty");
|
||||
}
|
||||
}
|
||||
|
||||
return error.length() == 0;
|
||||
}
|
||||
|
||||
/*********************************************************************************************\
|
||||
* ControllerSettingsStruct definition
|
||||
\*********************************************************************************************/
|
||||
struct ControllerSettingsStruct
|
||||
{
|
||||
ControllerSettingsStruct() : UseDNS(false), Port(0),
|
||||
MinimalTimeBetweenMessages(100), MaxQueueDepth(10), MaxRetry(10), DeleteOldest(false) {
|
||||
MinimalTimeBetweenMessages(100), MaxQueueDepth(10), MaxRetry(10),
|
||||
DeleteOldest(false), ClientTimeout(100), MustCheckReply(false) {
|
||||
for (byte i = 0; i < 4; ++i) {
|
||||
IP[i] = 0;
|
||||
}
|
||||
@@ -866,6 +960,19 @@ struct ControllerSettingsStruct
|
||||
unsigned int MaxQueueDepth;
|
||||
unsigned int MaxRetry;
|
||||
boolean DeleteOldest; // Action to perform when buffer full, delete oldest, or ignore newest.
|
||||
unsigned int ClientTimeout;
|
||||
boolean MustCheckReply; // When set to false, a sent message is considered always successful.
|
||||
|
||||
void validate() {
|
||||
if (Port > 65535) Port = 0;
|
||||
if (MinimalTimeBetweenMessages < 1 || MinimalTimeBetweenMessages > CONTROLLER_DELAY_QUEUE_DELAY_MAX)
|
||||
MinimalTimeBetweenMessages = CONTROLLER_DELAY_QUEUE_DELAY_DFLT;
|
||||
if (MaxQueueDepth > CONTROLLER_DELAY_QUEUE_DEPTH_MAX) MaxQueueDepth = CONTROLLER_DELAY_QUEUE_DEPTH_DFLT;
|
||||
if (MaxRetry > CONTROLLER_DELAY_QUEUE_RETRY_MAX) MaxRetry = CONTROLLER_DELAY_QUEUE_RETRY_MAX;
|
||||
if (ClientTimeout < 10 || ClientTimeout > CONTROLLER_CLIENTTIMEOUT_MAX) {
|
||||
ClientTimeout = CONTROLLER_CLIENTTIMEOUT_DFLT;
|
||||
}
|
||||
}
|
||||
|
||||
IPAddress getIP() const {
|
||||
IPAddress host(IP[0], IP[1], IP[2], IP[3]);
|
||||
@@ -888,6 +995,7 @@ struct ControllerSettingsStruct
|
||||
if (!WiFiConnected(10)) {
|
||||
return false; // Not connected, so no use in wasting time to connect to a host.
|
||||
}
|
||||
delay(1); // Make sure the Watchdog will not trigger a reset.
|
||||
if (quick && ipSet()) return true;
|
||||
if (UseDNS) {
|
||||
if (!updateIPcache()) {
|
||||
@@ -966,6 +1074,11 @@ private:
|
||||
|
||||
};
|
||||
|
||||
typedef std::shared_ptr<ControllerSettingsStruct> ControllerSettingsStruct_ptr_type;
|
||||
#define MakeControllerSettings(T) ControllerSettingsStruct_ptr_type ControllerSettingsStruct_ptr(new ControllerSettingsStruct());\
|
||||
ControllerSettingsStruct& T = *ControllerSettingsStruct_ptr;
|
||||
|
||||
|
||||
|
||||
/*********************************************************************************************\
|
||||
* NotificationSettingsStruct
|
||||
@@ -997,6 +1110,11 @@ struct NotificationSettingsStruct
|
||||
//its safe to extend this struct, up to 4096 bytes, default values in config are 0
|
||||
};
|
||||
|
||||
typedef std::shared_ptr<NotificationSettingsStruct> NotificationSettingsStruct_ptr_type;
|
||||
#define MakeNotificationSettings(T) NotificationSettingsStruct_ptr_type NotificationSettingsStruct_ptr(new NotificationSettingsStruct());\
|
||||
NotificationSettingsStruct& T = *NotificationSettingsStruct_ptr;
|
||||
|
||||
|
||||
/*********************************************************************************************\
|
||||
* ExtraTaskSettingsStruct
|
||||
\*********************************************************************************************/
|
||||
@@ -1080,22 +1198,36 @@ struct ExtraTaskSettingsStruct
|
||||
struct EventStruct
|
||||
{
|
||||
EventStruct() :
|
||||
Data(NULL), idx(0), Par1(0), Par2(0), Par3(0), Par4(0), Par5(0),
|
||||
Source(0), TaskIndex(TASKS_MAX), ControllerIndex(0), ProtocolIndex(0), NotificationIndex(0),
|
||||
BaseVarIndex(0), idx(0), sensorType(0), Par1(0), Par2(0), Par3(0), Par4(0), Par5(0),
|
||||
OriginTaskIndex(0), Data(NULL) {}
|
||||
BaseVarIndex(0), sensorType(0), OriginTaskIndex(0) {}
|
||||
EventStruct(const struct EventStruct& event):
|
||||
Source(event.Source), TaskIndex(event.TaskIndex), ControllerIndex(event.ControllerIndex)
|
||||
, ProtocolIndex(event.ProtocolIndex), NotificationIndex(event.NotificationIndex)
|
||||
, BaseVarIndex(event.BaseVarIndex), idx(event.idx), sensorType(event.sensorType)
|
||||
, Par1(event.Par1), Par2(event.Par2), Par3(event.Par3), Par4(event.Par4), Par5(event.Par5)
|
||||
, OriginTaskIndex(event.OriginTaskIndex)
|
||||
, String1(event.String1)
|
||||
String1(event.String1)
|
||||
, String2(event.String2)
|
||||
, String3(event.String3)
|
||||
, String4(event.String4)
|
||||
, String5(event.String5)
|
||||
, Data(event.Data) {}
|
||||
, Data(event.Data)
|
||||
, idx(event.idx)
|
||||
, Par1(event.Par1), Par2(event.Par2), Par3(event.Par3), Par4(event.Par4), Par5(event.Par5)
|
||||
, Source(event.Source), TaskIndex(event.TaskIndex), ControllerIndex(event.ControllerIndex)
|
||||
, ProtocolIndex(event.ProtocolIndex), NotificationIndex(event.NotificationIndex)
|
||||
, BaseVarIndex(event.BaseVarIndex), sensorType(event.sensorType)
|
||||
, OriginTaskIndex(event.OriginTaskIndex)
|
||||
{}
|
||||
|
||||
String String1;
|
||||
String String2;
|
||||
String String3;
|
||||
String String4;
|
||||
String String5;
|
||||
byte *Data;
|
||||
int idx;
|
||||
int Par1;
|
||||
int Par2;
|
||||
int Par3;
|
||||
int Par4;
|
||||
int Par5;
|
||||
byte Source;
|
||||
byte TaskIndex; // index position in TaskSettings array, 0-11
|
||||
byte ControllerIndex; // index position in Settings.Controller, 0-3
|
||||
@@ -1104,20 +1236,8 @@ struct EventStruct
|
||||
//Edwin: Not needed, and wasnt used. We can determine the protocol index with getNotificationProtocolIndex(NotificationIndex)
|
||||
// byte NotificationProtocolIndex; // index position in notification array, depending on which controller plugins are loaded.
|
||||
byte BaseVarIndex;
|
||||
int idx;
|
||||
byte sensorType;
|
||||
int Par1;
|
||||
int Par2;
|
||||
int Par3;
|
||||
int Par4;
|
||||
int Par5;
|
||||
byte OriginTaskIndex;
|
||||
String String1;
|
||||
String String2;
|
||||
String String3;
|
||||
String String4;
|
||||
String String5;
|
||||
byte *Data;
|
||||
};
|
||||
|
||||
|
||||
@@ -1127,18 +1247,19 @@ struct EventStruct
|
||||
#define LOG_STRUCT_MESSAGE_SIZE 128
|
||||
#ifdef ESP32
|
||||
#define LOG_STRUCT_MESSAGE_LINES 30
|
||||
#define LOG_BUFFER_EXPIRE 30000 // Time after which a buffered log item is considered expired.
|
||||
#else
|
||||
#if defined(PLUGIN_BUILD_TESTING) || defined(PLUGIN_BUILD_DEV)
|
||||
#define LOG_STRUCT_MESSAGE_LINES 10
|
||||
#else
|
||||
#define LOG_STRUCT_MESSAGE_LINES 15
|
||||
#endif
|
||||
#define LOG_BUFFER_EXPIRE 5000 // Time after which a buffered log item is considered expired.
|
||||
#endif
|
||||
|
||||
struct LogStruct {
|
||||
LogStruct() : write_idx(0), read_idx(0) {
|
||||
LogStruct() : write_idx(0), read_idx(0), lastReadTimeStamp(0) {
|
||||
for (int i = 0; i < LOG_STRUCT_MESSAGE_LINES; ++i) {
|
||||
Message[i].reserve(LOG_STRUCT_MESSAGE_SIZE);
|
||||
timeStamp[i] = 0;
|
||||
log_level[i] = 0;
|
||||
}
|
||||
@@ -1156,6 +1277,7 @@ struct LogStruct {
|
||||
if (linelength > LOG_STRUCT_MESSAGE_SIZE-1)
|
||||
linelength = LOG_STRUCT_MESSAGE_SIZE-1;
|
||||
Message[write_idx] = "";
|
||||
Message[write_idx].reserve(linelength);
|
||||
for (unsigned i = 0; i < linelength; ++i) {
|
||||
Message[write_idx] += *(line + i);
|
||||
}
|
||||
@@ -1164,6 +1286,7 @@ struct LogStruct {
|
||||
// Read the next item and append it to the given string.
|
||||
// Returns whether new lines are available.
|
||||
bool get(String& output, const String& lineEnd) {
|
||||
lastReadTimeStamp = millis();
|
||||
if (!isEmpty()) {
|
||||
read_idx = (read_idx + 1) % LOG_STRUCT_MESSAGE_LINES;
|
||||
output += formatLine(read_idx, lineEnd);
|
||||
@@ -1172,6 +1295,7 @@ struct LogStruct {
|
||||
}
|
||||
|
||||
String get_logjson_formatted(bool& logLinesAvailable, unsigned long& timestamp) {
|
||||
lastReadTimeStamp = millis();
|
||||
logLinesAvailable = false;
|
||||
if (isEmpty()) {
|
||||
return "";
|
||||
@@ -1185,31 +1309,15 @@ struct LogStruct {
|
||||
return output;
|
||||
}
|
||||
|
||||
bool get(String& output, const String& lineEnd, int line) {
|
||||
int tmpread((write_idx + 1+line) % LOG_STRUCT_MESSAGE_LINES);
|
||||
if (timeStamp[tmpread] != 0) {
|
||||
output += formatLine(tmpread, lineEnd);
|
||||
}
|
||||
return !isEmpty();
|
||||
}
|
||||
|
||||
bool getAll(String& output, const String& lineEnd) {
|
||||
int tmpread((write_idx + 1) % LOG_STRUCT_MESSAGE_LINES);
|
||||
bool someAdded = false;
|
||||
while (tmpread != write_idx) {
|
||||
if (timeStamp[tmpread] != 0) {
|
||||
output += formatLine(tmpread, lineEnd);
|
||||
someAdded = true;
|
||||
}
|
||||
tmpread = (tmpread + 1)% LOG_STRUCT_MESSAGE_LINES;
|
||||
}
|
||||
return someAdded;
|
||||
}
|
||||
|
||||
bool isEmpty() {
|
||||
return (write_idx == read_idx);
|
||||
}
|
||||
|
||||
bool logActiveRead() {
|
||||
clearExpiredEntries();
|
||||
return timePassedSince(lastReadTimeStamp) < LOG_BUFFER_EXPIRE;
|
||||
}
|
||||
|
||||
private:
|
||||
String formatLine(int index, const String& lineEnd) {
|
||||
String output;
|
||||
@@ -1233,20 +1341,38 @@ struct LogStruct {
|
||||
return output;
|
||||
}
|
||||
|
||||
void clearExpiredEntries() {
|
||||
if (isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (timePassedSince(lastReadTimeStamp) > LOG_BUFFER_EXPIRE) {
|
||||
// Clear the entire log.
|
||||
// If web log is the only log active, it will not be checked again until it is read.
|
||||
for (read_idx = 0; read_idx < LOG_STRUCT_MESSAGE_LINES; ++read_idx) {
|
||||
Message[read_idx] = String(); // Free also the reserved memory.
|
||||
timeStamp[read_idx] = 0;
|
||||
log_level[read_idx] = 0;
|
||||
}
|
||||
read_idx = 0;
|
||||
write_idx = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int write_idx;
|
||||
int read_idx;
|
||||
unsigned long timeStamp[LOG_STRUCT_MESSAGE_LINES];
|
||||
unsigned long lastReadTimeStamp;
|
||||
byte log_level[LOG_STRUCT_MESSAGE_LINES];
|
||||
String Message[LOG_STRUCT_MESSAGE_LINES];
|
||||
|
||||
} Logging;
|
||||
|
||||
std::deque<char> serialLogBuffer;
|
||||
unsigned long last_serial_log_emptied = 0;
|
||||
unsigned long last_serial_log_read = 0;
|
||||
|
||||
byte highest_active_log_level = 0;
|
||||
bool log_to_serial_disabled = false;
|
||||
bool log_to_serial_disabled_temporary = false;
|
||||
// Do this in a template to prevent casting to String when not needed.
|
||||
#define addLog(L,S) if (loglevelActiveFor(L)) { addToLog(L,S); }
|
||||
|
||||
@@ -1270,16 +1396,16 @@ struct DeviceStruct
|
||||
byte Type; // How the device is connected. e.g. DEVICE_TYPE_SINGLE => connected through 1 datapin
|
||||
byte VType; // Type of value the plugin will return, used only for Domoticz
|
||||
byte Ports; // Port to use when device has multiple I/O pins (N.B. not used much)
|
||||
byte ValueCount; // The number of output values of a plugin. The value should match the number of keys PLUGIN_VALUENAME1_xxx
|
||||
boolean PullUpOption; // Allow to set internal pull-up resistors.
|
||||
boolean InverseLogicOption; // Allow to invert the boolean state (e.g. a switch)
|
||||
boolean FormulaOption; // Allow to enter a formula to convert values during read. (not possible with Custom enabled)
|
||||
boolean Custom;
|
||||
boolean SendDataOption; // Allow to send data to a controller.
|
||||
boolean GlobalSyncOption; // No longer used. Was used for ESPeasy values sync between nodes
|
||||
boolean TimerOption; // Allow to set the "Interval" timer for the plugin.
|
||||
boolean TimerOptional; // When taskdevice timer is not set and not optional, use default "Interval" delay (Settings.Delay)
|
||||
boolean DecimalsOnly; // Allow to set the number of decimals (otherwise treated a 0 decimals)
|
||||
byte ValueCount; // The number of output values of a plugin. The value should match the number of keys PLUGIN_VALUENAME1_xxx
|
||||
bool PullUpOption : 1; // Allow to set internal pull-up resistors.
|
||||
bool InverseLogicOption : 1; // Allow to invert the boolean state (e.g. a switch)
|
||||
bool FormulaOption : 1; // Allow to enter a formula to convert values during read. (not possible with Custom enabled)
|
||||
bool Custom : 1;
|
||||
bool SendDataOption : 1; // Allow to send data to a controller.
|
||||
bool GlobalSyncOption : 1; // No longer used. Was used for ESPeasy values sync between nodes
|
||||
bool TimerOption : 1; // Allow to set the "Interval" timer for the plugin.
|
||||
bool TimerOptional : 1; // When taskdevice timer is not set and not optional, use default "Interval" delay (Settings.Delay)
|
||||
bool DecimalsOnly; // Allow to set the number of decimals (otherwise treated a 0 decimals)
|
||||
};
|
||||
typedef std::vector<DeviceStruct> DeviceVector;
|
||||
DeviceVector Device;
|
||||
@@ -1344,16 +1470,16 @@ NodesMap Nodes;
|
||||
struct systemTimerStruct
|
||||
{
|
||||
systemTimerStruct() :
|
||||
timer(0), plugin(0), TaskIndex(-1), Par1(0), Par2(0), Par3(0), Par4(0), Par5(0) {}
|
||||
timer(0), Par1(0), Par2(0), Par3(0), Par4(0), Par5(0), TaskIndex(-1), plugin(0) {}
|
||||
|
||||
unsigned long timer;
|
||||
byte plugin;
|
||||
int16_t TaskIndex;
|
||||
int Par1;
|
||||
int Par2;
|
||||
int Par3;
|
||||
int Par4;
|
||||
int Par5;
|
||||
int16_t TaskIndex;
|
||||
byte plugin;
|
||||
};
|
||||
std::map<unsigned long, systemTimerStruct> systemTimers;
|
||||
|
||||
@@ -1362,10 +1488,11 @@ std::map<unsigned long, systemTimerStruct> systemTimers;
|
||||
\*********************************************************************************************/
|
||||
struct pinStatesStruct
|
||||
{
|
||||
pinStatesStruct() : value(0), plugin(0), index(0), mode(0) {}
|
||||
uint16_t value;
|
||||
byte plugin;
|
||||
byte index;
|
||||
byte mode;
|
||||
uint16_t value;
|
||||
} pinStates[PINSTATE_TABLE_MAX];
|
||||
|
||||
|
||||
@@ -1379,18 +1506,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;
|
||||
@@ -1406,6 +1535,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;
|
||||
@@ -1413,14 +1544,15 @@ 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;
|
||||
unsigned long last_system_event_run = 0;
|
||||
|
||||
#if FEATURE_ADC_VCC
|
||||
float vcc = -1.0;
|
||||
@@ -1567,15 +1699,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
|
||||
@@ -1714,31 +1849,32 @@ unsigned long timediff_calls = 0;
|
||||
unsigned long timediff_cpu_cycles_total = 0;
|
||||
|
||||
#define LOADFILE_STATS 0
|
||||
#define LOOP_STATS 1
|
||||
#define PLUGIN_CALL_50PS 2
|
||||
#define PLUGIN_CALL_10PS 3
|
||||
#define PLUGIN_CALL_10PSU 4
|
||||
#define PLUGIN_CALL_1PS 5
|
||||
#define SENSOR_SEND_TASK 6
|
||||
#define SEND_DATA_STATS 7
|
||||
#define COMPUTE_FORMULA_STATS 8
|
||||
#define PROC_SYS_TIMER 9
|
||||
#define SET_NEW_TIMER 10
|
||||
#define TIME_DIFF_COMPUTE 11
|
||||
#define MQTT_DELAY_QUEUE 12
|
||||
#define C001_DELAY_QUEUE 13
|
||||
#define C002_DELAY_QUEUE 14
|
||||
#define C003_DELAY_QUEUE 15
|
||||
#define C004_DELAY_QUEUE 16
|
||||
#define C005_DELAY_QUEUE 17
|
||||
#define C006_DELAY_QUEUE 18
|
||||
#define C007_DELAY_QUEUE 19
|
||||
#define C008_DELAY_QUEUE 20
|
||||
#define C009_DELAY_QUEUE 21
|
||||
#define C010_DELAY_QUEUE 22
|
||||
#define C011_DELAY_QUEUE 23
|
||||
#define C012_DELAY_QUEUE 24
|
||||
#define C013_DELAY_QUEUE 25
|
||||
#define SAVEFILE_STATS 1
|
||||
#define LOOP_STATS 2
|
||||
#define PLUGIN_CALL_50PS 3
|
||||
#define PLUGIN_CALL_10PS 4
|
||||
#define PLUGIN_CALL_10PSU 5
|
||||
#define PLUGIN_CALL_1PS 6
|
||||
#define SENSOR_SEND_TASK 7
|
||||
#define SEND_DATA_STATS 8
|
||||
#define COMPUTE_FORMULA_STATS 9
|
||||
#define PROC_SYS_TIMER 10
|
||||
#define SET_NEW_TIMER 11
|
||||
#define TIME_DIFF_COMPUTE 12
|
||||
#define MQTT_DELAY_QUEUE 13
|
||||
#define C001_DELAY_QUEUE 14
|
||||
#define C002_DELAY_QUEUE 15
|
||||
#define C003_DELAY_QUEUE 16
|
||||
#define C004_DELAY_QUEUE 17
|
||||
#define C005_DELAY_QUEUE 18
|
||||
#define C006_DELAY_QUEUE 19
|
||||
#define C007_DELAY_QUEUE 20
|
||||
#define C008_DELAY_QUEUE 21
|
||||
#define C009_DELAY_QUEUE 22
|
||||
#define C010_DELAY_QUEUE 23
|
||||
#define C011_DELAY_QUEUE 24
|
||||
#define C012_DELAY_QUEUE 25
|
||||
#define C013_DELAY_QUEUE 26
|
||||
|
||||
|
||||
|
||||
@@ -1747,13 +1883,14 @@ unsigned long timediff_cpu_cycles_total = 0;
|
||||
|
||||
#define START_TIMER const unsigned statisticsTimerStart(micros());
|
||||
#define STOP_TIMER_TASK(T,F) if (mustLogFunction(F)) pluginStats[T*32 + F].add(usecPassedSince(statisticsTimerStart));
|
||||
#define STOP_TIMER_LOADFILE miscStats[LOADFILE_STATS].add(usecPassedSince(statisticsTimerStart));
|
||||
//#define STOP_TIMER_LOADFILE miscStats[LOADFILE_STATS].add(usecPassedSince(statisticsTimerStart));
|
||||
#define STOP_TIMER(L) miscStats[L].add(usecPassedSince(statisticsTimerStart));
|
||||
|
||||
|
||||
String getMiscStatsName(int stat) {
|
||||
switch (stat) {
|
||||
case LOADFILE_STATS: return F("Load File");
|
||||
case SAVEFILE_STATS: return F("Save File");
|
||||
case LOOP_STATS: return F("Loop");
|
||||
case PLUGIN_CALL_50PS: return F("Plugin call 50 p/s ");
|
||||
case PLUGIN_CALL_10PS: return F("Plugin call 10 p/s ");
|
||||
|
||||
+47
-11
@@ -106,9 +106,14 @@ int firstEnabledBlynkController() {
|
||||
\*********************************************************************************************/
|
||||
void setup()
|
||||
{
|
||||
#ifdef ESP8266_DISABLE_EXTRA4K
|
||||
disable_extra4k_at_link_time();
|
||||
#endif
|
||||
WiFi.persistent(false); // Do not use SDK storage of SSID/WPA parameters
|
||||
WiFi.setAutoReconnect(false);
|
||||
setWifiMode(WIFI_OFF);
|
||||
lowestFreeStack = getFreeStackWatermark();
|
||||
lowestRAM = FreeMem();
|
||||
|
||||
Plugin_id.resize(PLUGIN_MAX);
|
||||
Task_id_to_Plugin_id.resize(TASKS_MAX);
|
||||
@@ -119,8 +124,6 @@ void setup()
|
||||
ledChannelPin[x] = -1;
|
||||
#endif
|
||||
|
||||
lowestRAM = FreeMem();
|
||||
|
||||
Serial.begin(115200);
|
||||
// Serial.print("\n\n\nBOOOTTT\n\n\n");
|
||||
|
||||
@@ -158,6 +161,7 @@ void setup()
|
||||
//warm boot
|
||||
if (readFromRTC())
|
||||
{
|
||||
RTC.bootFailedCount++;
|
||||
RTC.bootCounter++;
|
||||
readUserVarFromRTC();
|
||||
|
||||
@@ -193,6 +197,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 +318,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 +375,14 @@ void RTOS_Task10ps( void * parameter )
|
||||
run10TimesPerSecond();
|
||||
}
|
||||
}
|
||||
|
||||
void RTOS_HandleSchedule( void * parameter )
|
||||
{
|
||||
while (true){
|
||||
handle_schedule();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
int firstEnabledMQTTController() {
|
||||
@@ -435,8 +465,11 @@ int getLoopCountPerSec() {
|
||||
\*********************************************************************************************/
|
||||
void loop()
|
||||
{
|
||||
/*
|
||||
//FIXME TD-er: No idea what this does.
|
||||
if(MainLoopCall_ptr)
|
||||
MainLoopCall_ptr();
|
||||
*/
|
||||
|
||||
updateLoopStats();
|
||||
|
||||
@@ -465,7 +498,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 +516,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();
|
||||
@@ -800,13 +839,10 @@ void SensorSendTask(byte TaskIndex)
|
||||
{
|
||||
if (ExtraTaskSettings.TaskDeviceFormula[varNr][0] != 0)
|
||||
{
|
||||
String spreValue = String(preValue[varNr]);
|
||||
String formula = ExtraTaskSettings.TaskDeviceFormula[varNr];
|
||||
float value = UserVar[varIndex + varNr];
|
||||
formula.replace(F("%pvalue%"), String(preValue[varNr]));
|
||||
formula.replace(F("%value%"), String(UserVar[varIndex + varNr]));
|
||||
float result = 0;
|
||||
String svalue = String(value);
|
||||
formula.replace(F("%pvalue%"), spreValue);
|
||||
formula.replace(F("%value%"), svalue);
|
||||
byte error = Calculate(formula.c_str(), &result);
|
||||
if (error == 0)
|
||||
UserVar[varIndex + varNr] = result;
|
||||
@@ -831,7 +867,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
|
||||
|
||||
+140
-34
@@ -77,7 +77,7 @@ String BuildFixes()
|
||||
Settings.UseRTOSMultitasking = false;
|
||||
Settings.Pin_Reset = -1;
|
||||
Settings.SyslogFacility = DEFAULT_SYSLOG_FACILITY;
|
||||
Settings.MQTTUseUnitNameAsClientId = DEFAULT_MQTT_USE_UNITNANE_AS_CLIENTID;
|
||||
Settings.MQTTUseUnitNameAsClientId = DEFAULT_MQTT_USE_UNITNAME_AS_CLIENTID;
|
||||
Settings.StructSize = sizeof(Settings);
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ void fileSystemCheck()
|
||||
{
|
||||
ResetFactory();
|
||||
}
|
||||
f.close();
|
||||
if (f) f.close();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -147,9 +147,14 @@ 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);
|
||||
return(err);
|
||||
// Must check this after saving, or else it is not possible to fix multiple
|
||||
// issues which can only corrected on different pages.
|
||||
if (!SettingsCheck(err)) return err;
|
||||
|
||||
// }
|
||||
|
||||
memcpy( SecuritySettings.ProgmemMd5, CRCValues.runTimeMD5, 16);
|
||||
@@ -182,6 +187,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 +225,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
|
||||
\*********************************************************************************************/
|
||||
@@ -366,6 +417,13 @@ String SaveCustomTaskSettings(int TaskIndex, byte* memAddress, int datasize)
|
||||
return(SaveToFile(CustomTaskSettings_Type, TaskIndex, (char*)FILE_CONFIG, memAddress, datasize));
|
||||
}
|
||||
|
||||
String getCustomTaskSettingsError(byte varNr) {
|
||||
String error = F("Error: Text too long for line ");
|
||||
error += varNr + 1;
|
||||
error += '\n';
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************************************\
|
||||
Clear custom task settings
|
||||
@@ -388,20 +446,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;
|
||||
}
|
||||
|
||||
|
||||
@@ -466,13 +529,15 @@ String InitFile(const char* fname, int datasize)
|
||||
FLASH_GUARD();
|
||||
|
||||
fs::File f = SPIFFS.open(fname, "w");
|
||||
SPIFFS_CHECK(f, fname);
|
||||
if (f) {
|
||||
SPIFFS_CHECK(f, fname);
|
||||
|
||||
for (int x = 0; x < datasize ; x++)
|
||||
{
|
||||
SPIFFS_CHECK(f.write(0), fname);
|
||||
for (int x = 0; x < datasize ; x++)
|
||||
{
|
||||
SPIFFS_CHECK(f.write(0), fname);
|
||||
}
|
||||
f.close();
|
||||
}
|
||||
f.close();
|
||||
|
||||
//OK
|
||||
return String();
|
||||
@@ -483,6 +548,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;
|
||||
@@ -490,24 +564,47 @@ String SaveToFile(char* fname, int index, byte* memAddress, int datasize)
|
||||
addLog(LOG_LEVEL_ERROR, log);
|
||||
return log;
|
||||
}
|
||||
|
||||
START_TIMER;
|
||||
checkRAM(F("SaveToFile"));
|
||||
FLASH_GUARD();
|
||||
|
||||
fs::File f = SPIFFS.open(fname, "r+");
|
||||
SPIFFS_CHECK(f, fname);
|
||||
|
||||
SPIFFS_CHECK(f.seek(index, fs::SeekSet), fname);
|
||||
byte *pointerToByteToSave = memAddress;
|
||||
for (int x = 0; x < datasize ; x++)
|
||||
{
|
||||
SPIFFS_CHECK(f.write(*pointerToByteToSave), fname);
|
||||
pointerToByteToSave++;
|
||||
String log = F("SaveToFile: free stack: ");
|
||||
log += getCurrentFreeStack();
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
}
|
||||
delay(1);
|
||||
unsigned long timer = millis() + 50;
|
||||
fs::File f = SPIFFS.open(fname, "r+");
|
||||
if (f) {
|
||||
SPIFFS_CHECK(f, fname);
|
||||
SPIFFS_CHECK(f.seek(index, fs::SeekSet), fname);
|
||||
byte *pointerToByteToSave = memAddress;
|
||||
for (int x = 0; x < datasize ; x++)
|
||||
{
|
||||
SPIFFS_CHECK(f.write(*pointerToByteToSave), fname);
|
||||
pointerToByteToSave++;
|
||||
if (timeOutReached(timer)) {
|
||||
timer += 50;
|
||||
delay(1);
|
||||
}
|
||||
}
|
||||
f.close();
|
||||
String log = F("FILE : Saved ");
|
||||
log=log+fname;
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
} else {
|
||||
String log = F("SaveToFile: ");
|
||||
log += fname;
|
||||
log += F(" ERROR, Cannot save to file");
|
||||
addLog(LOG_LEVEL_ERROR, log);
|
||||
return log;
|
||||
}
|
||||
STOP_TIMER(SAVEFILE_STATS);
|
||||
{
|
||||
String log = F("SaveToFile: free stack after: ");
|
||||
log += getCurrentFreeStack();
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
}
|
||||
f.close();
|
||||
String log = F("FILE : Saved ");
|
||||
log=log+fname;
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
|
||||
//OK
|
||||
return String();
|
||||
@@ -530,14 +627,22 @@ String ClearInFile(char* fname, int index, int datasize)
|
||||
FLASH_GUARD();
|
||||
|
||||
fs::File f = SPIFFS.open(fname, "r+");
|
||||
SPIFFS_CHECK(f, fname);
|
||||
if (f) {
|
||||
SPIFFS_CHECK(f, fname);
|
||||
|
||||
SPIFFS_CHECK(f.seek(index, fs::SeekSet), fname);
|
||||
for (int x = 0; x < datasize ; x++)
|
||||
{
|
||||
SPIFFS_CHECK(f.write(0), fname);
|
||||
SPIFFS_CHECK(f.seek(index, fs::SeekSet), fname);
|
||||
for (int x = 0; x < datasize ; x++)
|
||||
{
|
||||
SPIFFS_CHECK(f.write(0), fname);
|
||||
}
|
||||
f.close();
|
||||
} else {
|
||||
String log = F("ClearInFile: ");
|
||||
log += fname;
|
||||
log += F(" ERROR, Cannot save to file");
|
||||
addLog(LOG_LEVEL_ERROR, log);
|
||||
return log;
|
||||
}
|
||||
f.close();
|
||||
|
||||
//OK
|
||||
return String();
|
||||
@@ -556,10 +661,10 @@ String LoadFromFile(char* fname, int offset, byte* memAddress, int datasize)
|
||||
addLog(LOG_LEVEL_ERROR, log);
|
||||
return log;
|
||||
}
|
||||
delay(1);
|
||||
START_TIMER;
|
||||
|
||||
checkRAM(F("LoadFromFile"));
|
||||
|
||||
fs::File f = SPIFFS.open(fname, "r+");
|
||||
SPIFFS_CHECK(f, fname);
|
||||
SPIFFS_CHECK(f.seek(offset, fs::SeekSet), fname);
|
||||
@@ -567,6 +672,7 @@ String LoadFromFile(char* fname, int offset, byte* memAddress, int datasize)
|
||||
f.close();
|
||||
|
||||
STOP_TIMER(LOADFILE_STATS);
|
||||
delay(1);
|
||||
|
||||
return(String());
|
||||
}
|
||||
|
||||
+5
-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);
|
||||
}
|
||||
|
||||
@@ -676,6 +678,7 @@ void WifiScan()
|
||||
|
||||
String formatScanResult(int i, const String& separator) {
|
||||
String result = WiFi.SSID(i);
|
||||
htmlEscape(result);
|
||||
#ifndef ESP32
|
||||
if (WiFi.isHidden(i)) {
|
||||
result += F("#Hidden#");
|
||||
|
||||
+13
-5
@@ -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,8 +120,8 @@ int32_t I2C_read32_reg(uint8_t i2caddr, byte reg) {
|
||||
|
||||
Wire.beginTransmission(i2caddr);
|
||||
Wire.write((uint8_t)reg);
|
||||
Wire.endTransmission(false);
|
||||
Wire.requestFrom(i2caddr, (byte)3);
|
||||
Wire.endTransmission(END_TRANSMISSION_FLAG);
|
||||
Wire.requestFrom(i2caddr, (byte)4);
|
||||
value = (((int32_t)Wire.read()) <<24) | (((uint32_t)Wire.read()) << 16) | (Wire.read() << 8) | Wire.read();
|
||||
|
||||
return value;
|
||||
@@ -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
|
||||
|
||||
+697
-345
File diff suppressed because it is too large
Load Diff
+8
-1
@@ -41,19 +41,26 @@ unsigned long getMixedId(unsigned long timerType, unsigned long id) {
|
||||
\*********************************************************************************************/
|
||||
void handle_schedule() {
|
||||
unsigned long timer;
|
||||
const unsigned long mixed_id = msecTimerHandler.getNextId(timer);
|
||||
unsigned long mixed_id = 0;
|
||||
if (timePassedSince(last_system_event_run) < 500) {
|
||||
// Make sure system event queue will be looked at every now and then.
|
||||
mixed_id = msecTimerHandler.getNextId(timer);
|
||||
}
|
||||
if (mixed_id == 0) {
|
||||
// No id ready to run right now.
|
||||
// Events are not that important to run immediately.
|
||||
// Make sure normal scheduled jobs run at higher priority.
|
||||
backgroundtasks();
|
||||
process_system_event_queue();
|
||||
last_system_event_run = millis();
|
||||
return;
|
||||
}
|
||||
const unsigned long timerType = (mixed_id >> TIMER_ID_SHIFT);
|
||||
const unsigned long mask = (1 << TIMER_ID_SHIFT) -1;
|
||||
const unsigned long id = mixed_id & mask;
|
||||
|
||||
yield(); // See: https://github.com/letscontrolit/ESPEasy/issues/1818#issuecomment-425351328
|
||||
|
||||
switch (timerType) {
|
||||
case CONST_INTERVAL_TIMER:
|
||||
process_interval_timer(id, timer);
|
||||
|
||||
+99
-28
@@ -131,7 +131,7 @@ String toString(float value, byte decimals)
|
||||
|
||||
String toString(WiFiMode_t mode)
|
||||
{
|
||||
String result = F("Undefinited");
|
||||
String result = F("Undefined");
|
||||
switch (mode)
|
||||
{
|
||||
case WIFI_OFF:
|
||||
@@ -165,11 +165,13 @@ String doFormatUserVar(byte TaskIndex, byte rel_index, bool mustCheck, bool& isv
|
||||
const byte DeviceIndex = getDeviceIndex(Settings.TaskDeviceNumber[TaskIndex]);
|
||||
if (Device[DeviceIndex].ValueCount <= rel_index) {
|
||||
isvalid = false;
|
||||
String log = F("No sensor value for TaskIndex: ");
|
||||
log += TaskIndex;
|
||||
log += F(" varnumber: ");
|
||||
log += rel_index;
|
||||
addLog(LOG_LEVEL_ERROR, log);
|
||||
if (loglevelActiveFor(LOG_LEVEL_ERROR)) {
|
||||
String log = F("No sensor value for TaskIndex: ");
|
||||
log += TaskIndex;
|
||||
log += F(" varnumber: ");
|
||||
log += rel_index;
|
||||
addLog(LOG_LEVEL_ERROR, log);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
if (Device[DeviceIndex].VType == SENSOR_TYPE_LONG) {
|
||||
@@ -178,11 +180,13 @@ String doFormatUserVar(byte TaskIndex, byte rel_index, bool mustCheck, bool& isv
|
||||
float f(UserVar[BaseVarIndex + rel_index]);
|
||||
if (mustCheck && !isValidFloat(f)) {
|
||||
isvalid = false;
|
||||
String log = F("Invalid float value for TaskIndex: ");
|
||||
log += TaskIndex;
|
||||
log += F(" varnumber: ");
|
||||
log += rel_index;
|
||||
addLog(LOG_LEVEL_DEBUG, log);
|
||||
if (loglevelActiveFor(LOG_LEVEL_DEBUG)) {
|
||||
String log = F("Invalid float value for TaskIndex: ");
|
||||
log += TaskIndex;
|
||||
log += F(" varnumber: ");
|
||||
log += rel_index;
|
||||
addLog(LOG_LEVEL_DEBUG, log);
|
||||
}
|
||||
f = 0;
|
||||
}
|
||||
return toString(f, ExtraTaskSettings.TaskDeviceValueDecimals[rel_index]);
|
||||
@@ -210,13 +214,11 @@ String formatUserVar(struct EventStruct *event, byte rel_index, bool& isvalid)
|
||||
/*********************************************************************************************\
|
||||
Wrap a string with given pre- and postfix string.
|
||||
\*********************************************************************************************/
|
||||
String wrap_String(const String& string, const String& wrap) {
|
||||
String result;
|
||||
result.reserve(string.length() + 2* wrap.length());
|
||||
result = wrap;
|
||||
|
||||
void wrap_String(const String& string, const String& wrap, String& result) {
|
||||
result += wrap;
|
||||
result += string;
|
||||
result += wrap;
|
||||
return result;
|
||||
}
|
||||
|
||||
/*********************************************************************************************\
|
||||
@@ -225,19 +227,25 @@ String wrap_String(const String& string, const String& wrap) {
|
||||
String to_json_object_value(const String& object, const String& value) {
|
||||
String result;
|
||||
result.reserve(object.length() + value.length() + 6);
|
||||
result = wrap_String(object, F("\""));
|
||||
wrap_String(object, F("\""), result);
|
||||
result += F(":");
|
||||
if (value.length() == 0 || !isFloat(value)) {
|
||||
if (value.indexOf('\n') == -1 && value.indexOf('"') == -1 && value.indexOf(F("Pragma")) == -1) {
|
||||
result += wrap_String(value, F("\""));
|
||||
} else {
|
||||
if (value.length() == 0) {
|
||||
// Empty string
|
||||
result += F("\"\"");
|
||||
} else if (!isFloat(value)) {
|
||||
// Is not a numerical value, thus wrap with quotes
|
||||
if (value.indexOf('\n') != -1 || value.indexOf('\r') != -1 || value.indexOf('"') != -1) {
|
||||
// Must replace characters, so make a deepcopy
|
||||
String tmpValue(value);
|
||||
tmpValue.replace('\n', '^');
|
||||
tmpValue.replace('\r', '^');
|
||||
tmpValue.replace('"', '\'');
|
||||
tmpValue.replace(F("Pragma"), F("Bugje!"));
|
||||
result += wrap_String(tmpValue, F("\""));
|
||||
wrap_String(tmpValue, F("\""), result);
|
||||
} else {
|
||||
wrap_String(value, F("\""), result);
|
||||
}
|
||||
} else {
|
||||
// It is a numerical
|
||||
result += value;
|
||||
}
|
||||
return result;
|
||||
@@ -280,6 +288,26 @@ String stripQuotes(const String& text) {
|
||||
return text;
|
||||
}
|
||||
|
||||
bool safe_strncpy(char* dest, const String& source, size_t max_size) {
|
||||
return safe_strncpy(dest, source.c_str(), max_size);
|
||||
}
|
||||
|
||||
bool safe_strncpy(char* dest, const char* source, size_t max_size) {
|
||||
if (max_size < 1) return false;
|
||||
if (dest == NULL) return false;
|
||||
if (source == NULL) return false;
|
||||
bool result = true;
|
||||
memset(dest, 0, max_size);
|
||||
size_t str_length = strlen(source);
|
||||
if (str_length >= max_size) {
|
||||
str_length = max_size;
|
||||
result = false;
|
||||
}
|
||||
strncpy(dest, source, str_length);
|
||||
dest[max_size - 1] = 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
/*********************************************************************************************\
|
||||
Parse a string and get the xth command or parameter in lower case
|
||||
\*********************************************************************************************/
|
||||
@@ -373,8 +401,32 @@ void htmlEscape(String & html)
|
||||
html.replace("'", F("'"));
|
||||
html.replace("<", F("<"));
|
||||
html.replace(">", F(">"));
|
||||
html.replace("/", F("/"));
|
||||
}
|
||||
|
||||
void htmlStrongEscape(String & html)
|
||||
{
|
||||
String escaped;
|
||||
escaped.reserve(html.length());
|
||||
for (unsigned i = 0; i < html.length(); ++i)
|
||||
{
|
||||
if ((html[i] >= 'a' && html[i] <= 'z') || (html[i] >= 'A' && html[i] <= 'Z') || (html[i] >= '0' && html[i] <= '9'))
|
||||
{
|
||||
escaped += html[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
char s [4];
|
||||
sprintf(s, "%03d", static_cast<int>(html[i]));
|
||||
escaped += "&#";
|
||||
escaped += s;
|
||||
escaped += ";";
|
||||
}
|
||||
}
|
||||
html = escaped;
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************************************\
|
||||
replace other system variables like %sysname%, %systime%, %ip%
|
||||
\*********************************************************************************************/
|
||||
@@ -508,6 +560,8 @@ void parseSystemVariables(String& s, boolean useURLencode)
|
||||
SMART_REPL(F("%systm_hm_am%"), getTimeString_ampm(':', false))
|
||||
SMART_REPL(F("%systime%"), getTimeString(':'))
|
||||
SMART_REPL(F("%systime_am%"), getTimeString_ampm(':'))
|
||||
SMART_REPL(F("%sysbuild_date%"), String(CRCValues.compileDate))
|
||||
SMART_REPL(F("%sysbuild_time%"), String(CRCValues.compileTime))
|
||||
repl(F("%sysname%"), Settings.Name, s, useURLencode);
|
||||
|
||||
// valueString is being used by the macro.
|
||||
@@ -540,17 +594,34 @@ void parseSystemVariables(String& s, boolean useURLencode)
|
||||
SMART_REPL(F("%unixtime%"), String(getUnixTime()))
|
||||
SMART_REPL_T(F("%sunset"), replSunSetTimeString)
|
||||
SMART_REPL_T(F("%sunrise"), replSunRiseTimeString)
|
||||
|
||||
if (s.indexOf(F("%is")) != -1) {
|
||||
SMART_REPL(F("%ismqtt%"), String(MQTTclient_connected));
|
||||
SMART_REPL(F("%iswifi%"), String(wifiStatus)); //0=disconnected, 1=connected, 2=got ip, 3=services initialized
|
||||
SMART_REPL(F("%isntp%"), String(statusNTPInitialized));
|
||||
#ifdef USES_P037
|
||||
SMART_REPL(F("%ismqttimp%"), String(P037_MQTTImport_connected));
|
||||
#endif // USES_P037
|
||||
}
|
||||
const int v_index = s.indexOf("%v");
|
||||
if (v_index != -1 && isDigit(s[v_index+2])) {
|
||||
for (byte i = 0; i < CUSTOM_VARS_MAX; ++i) {
|
||||
SMART_REPL("%v"+toString(i+1,0)+'%', String(customFloatVar[i]))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String getReplacementString(const String& format, String& s) {
|
||||
int startpos = s.indexOf(format);
|
||||
int endpos = s.indexOf('%', startpos + 1);
|
||||
String R = s.substring(startpos, endpos + 1);
|
||||
String log = F("ReplacementString SunTime: ");
|
||||
log += R;
|
||||
log += F(" offset: ");
|
||||
log += getSecOffset(R);
|
||||
addLog(LOG_LEVEL_DEBUG, log);
|
||||
if (loglevelActiveFor(LOG_LEVEL_DEBUG)) {
|
||||
String log = F("ReplacementString SunTime: ");
|
||||
log += R;
|
||||
log += F(" offset: ");
|
||||
log += getSecOffset(R);
|
||||
addLog(LOG_LEVEL_DEBUG, log);
|
||||
}
|
||||
return R;
|
||||
}
|
||||
|
||||
|
||||
+16
-17
@@ -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);
|
||||
}
|
||||
@@ -143,20 +147,6 @@ void breakTime(unsigned long timeInput, struct timeStruct &tm) {
|
||||
tm.Day = time + 1; // day of month
|
||||
}
|
||||
|
||||
void setTime(unsigned long t) {
|
||||
sysTime = (uint32_t)t;
|
||||
applyTimeZone(t);
|
||||
nextSyncTime = (uint32_t)t + syncInterval;
|
||||
prevMillis = millis(); // restart counting from now (thanks to Korman for this fix)
|
||||
if (Settings.UseRules)
|
||||
{
|
||||
static bool firstUpdate = true;
|
||||
String event = firstUpdate ? F("Time#Initialized") : F("Time#Set");
|
||||
firstUpdate = false;
|
||||
rulesProcessing(event);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t getUnixTime() {
|
||||
return sysTime;
|
||||
}
|
||||
@@ -218,13 +208,22 @@ unsigned long now() {
|
||||
unsigned long t = getNtpTime();
|
||||
if (t != 0) {
|
||||
timeSynced = true;
|
||||
setTime(t);
|
||||
sysTime = (uint32_t)t;
|
||||
applyTimeZone(t);
|
||||
nextSyncTime = (uint32_t)t + syncInterval;
|
||||
prevMillis = millis(); // restart counting from now (thanks to Korman for this fix)
|
||||
}
|
||||
}
|
||||
uint32_t localSystime = toLocal(sysTime);
|
||||
breakTime(localSystime, tm);
|
||||
if (timeSynced) {
|
||||
calcSunRiseAndSet();
|
||||
if (Settings.UseRules)
|
||||
{
|
||||
String event = statusNTPInitialized ? F("Time#Set") : F("Time#Initialized");
|
||||
rulesProcessing(event);
|
||||
}
|
||||
statusNTPInitialized = true; //@giig1967g: setting system variable %isntp%
|
||||
}
|
||||
return (unsigned long)localSystime;
|
||||
}
|
||||
|
||||
+251
-147
@@ -396,6 +396,7 @@ bool getCheckWebserverArg_int(const String &key, int& value) {
|
||||
return true;
|
||||
}
|
||||
|
||||
#define strncpy_webserver_arg(D,N) safe_strncpy(D, WebServer.arg(N).c_str(), sizeof(D));
|
||||
#define update_whenset_FormItemInt(K,V) { int tmpVal; if (getCheckWebserverArg_int(K, tmpVal)) V=tmpVal;}
|
||||
|
||||
|
||||
@@ -875,6 +876,13 @@ void handle_root() {
|
||||
TXBuffer += F(" - ");
|
||||
TXBuffer += String(lowestRAMfunction);
|
||||
TXBuffer += F(")");
|
||||
html_TR_TD(); TXBuffer += F("Free Stack:<TD>");
|
||||
TXBuffer += String(getCurrentFreeStack());
|
||||
TXBuffer += F(" (");
|
||||
TXBuffer += String(lowestFreeStack);
|
||||
TXBuffer += F(" - ");
|
||||
TXBuffer += String(lowestFreeStackfunction);
|
||||
TXBuffer += F(")");
|
||||
|
||||
html_TR_TD(); TXBuffer += F("IP:<TD>");
|
||||
TXBuffer += formatIP(ip);
|
||||
@@ -883,7 +891,9 @@ void handle_root() {
|
||||
if (wifiStatus == ESPEASY_WIFI_SERVICES_INITIALIZED)
|
||||
{
|
||||
TXBuffer += String(WiFi.RSSI());
|
||||
TXBuffer += F(" dB");
|
||||
TXBuffer += F(" dB (");
|
||||
TXBuffer += WiFi.SSID();
|
||||
TXBuffer += ')';
|
||||
}
|
||||
|
||||
#ifdef FEATURE_MDNS
|
||||
@@ -1009,10 +1019,6 @@ void handle_config() {
|
||||
|
||||
String name = WebServer.arg(F("name"));
|
||||
//String password = WebServer.arg(F("password"));
|
||||
String ssid = WebServer.arg(F("ssid"));
|
||||
//String key = WebServer.arg(F("key"));
|
||||
String ssid2 = WebServer.arg(F("ssid2"));
|
||||
//String key2 = WebServer.arg(F("key2"));
|
||||
String iprangelow = WebServer.arg(F("iprangelow"));
|
||||
String iprangehigh = WebServer.arg(F("iprangehigh"));
|
||||
|
||||
@@ -1024,6 +1030,7 @@ void handle_config() {
|
||||
String espdns = WebServer.arg(F("espdns"));
|
||||
Settings.Unit = getFormItemInt(F("unit"), Settings.Unit);
|
||||
//String apkey = WebServer.arg(F("apkey"));
|
||||
String ssid = WebServer.arg(F("ssid"));
|
||||
|
||||
|
||||
if (ssid[0] != 0)
|
||||
@@ -1032,16 +1039,22 @@ void handle_config() {
|
||||
addLog(LOG_LEVEL_INFO, F("Unit Name changed."));
|
||||
MQTTclient_should_reconnect = true;
|
||||
}
|
||||
strncpy(Settings.Name, name.c_str(), sizeof(Settings.Name));
|
||||
//strncpy(SecuritySettings.Password, password.c_str(), sizeof(SecuritySettings.Password));
|
||||
// Unit name
|
||||
safe_strncpy(Settings.Name, name.c_str(), sizeof(Settings.Name));
|
||||
Settings.appendUnitToHostname(isFormItemChecked(F("appendunittohostname")));
|
||||
|
||||
// Password
|
||||
copyFormPassword(F("password"), SecuritySettings.Password, sizeof(SecuritySettings.Password));
|
||||
strncpy(SecuritySettings.WifiSSID, ssid.c_str(), sizeof(SecuritySettings.WifiSSID));
|
||||
//strncpy(SecuritySettings.WifiKey, key.c_str(), sizeof(SecuritySettings.WifiKey));
|
||||
|
||||
// SSID 1
|
||||
safe_strncpy(SecuritySettings.WifiSSID, ssid.c_str(), sizeof(SecuritySettings.WifiSSID));
|
||||
copyFormPassword(F("key"), SecuritySettings.WifiKey, sizeof(SecuritySettings.WifiKey));
|
||||
strncpy(SecuritySettings.WifiSSID2, ssid2.c_str(), sizeof(SecuritySettings.WifiSSID2));
|
||||
//strncpy(SecuritySettings.WifiKey2, key2.c_str(), sizeof(SecuritySettings.WifiKey2));
|
||||
|
||||
// SSID 2
|
||||
strncpy_webserver_arg(SecuritySettings.WifiSSID2, F("ssid2"));
|
||||
copyFormPassword(F("key2"), SecuritySettings.WifiKey2, sizeof(SecuritySettings.WifiKey2));
|
||||
//strncpy(SecuritySettings.WifiAPKey, apkey.c_str(), sizeof(SecuritySettings.WifiAPKey));
|
||||
|
||||
// Access point password.
|
||||
copyFormPassword(F("apkey"), SecuritySettings.WifiAPKey, sizeof(SecuritySettings.WifiAPKey));
|
||||
|
||||
|
||||
@@ -1082,7 +1095,8 @@ void handle_config() {
|
||||
Settings.Name[25] = 0;
|
||||
SecuritySettings.Password[25] = 0;
|
||||
addFormTextBox( F("Unit Name"), F("name"), Settings.Name, 25);
|
||||
addFormNumericBox( F("Unit Number"), F("unit"), Settings.Unit, 0, 9999);
|
||||
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"));
|
||||
@@ -1160,26 +1174,18 @@ void handle_controllers() {
|
||||
|
||||
String usedns = WebServer.arg(F("usedns"));
|
||||
String controllerip = WebServer.arg(F("controllerip"));
|
||||
String controllerhostname = WebServer.arg(F("controllerhostname"));
|
||||
const int controllerport = getFormItemInt(F("controllerport"), 0);
|
||||
const int protocol = getFormItemInt(F("protocol"), -1);
|
||||
String controlleruser = WebServer.arg(F("controlleruser"));
|
||||
String controllerpassword = WebServer.arg(F("controllerpassword"));
|
||||
String controllersubscribe = WebServer.arg(F("controllersubscribe"));
|
||||
String controllerpublish = WebServer.arg(F("controllerpublish"));
|
||||
String MQTTLwtTopic = WebServer.arg(F("mqttlwttopic"));
|
||||
String lwtmessageconnect = WebServer.arg(F("lwtmessageconnect"));
|
||||
String lwtmessagedisconnect = WebServer.arg(F("lwtmessagedisconnect"));
|
||||
const int minimumsendinterval = getFormItemInt(F("minimumsendinterval"), 100);
|
||||
const int maxqueuedepth = getFormItemInt(F("maxqueuedepth"), 10);
|
||||
const int maxretry = getFormItemInt(F("maxretry"), 10);
|
||||
String deleteoldest = WebServer.arg(F("deleteoldest"));
|
||||
const int clienttimeout = getFormItemInt(F("clienttimeout"), CONTROLLER_CLIENTTIMEOUT_DFLT);
|
||||
|
||||
|
||||
//submitted data
|
||||
if (protocol != -1 && !controllerNotSet)
|
||||
{
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
MakeControllerSettings(ControllerSettings);
|
||||
//submitted changed protocol
|
||||
if (Settings.Protocol[controllerindex] != protocol)
|
||||
{
|
||||
@@ -1192,15 +1198,16 @@ void handle_controllers() {
|
||||
//reset (some) default-settings
|
||||
byte ProtocolIndex = getProtocolIndex(Settings.Protocol[controllerindex]);
|
||||
ControllerSettings.Port = Protocol[ProtocolIndex].defaultPort;
|
||||
ControllerSettings.MinimalTimeBetweenMessages = 100;
|
||||
ControllerSettings.MinimalTimeBetweenMessages = CONTROLLER_DELAY_QUEUE_DELAY_DFLT;
|
||||
ControllerSettings.ClientTimeout = CONTROLLER_CLIENTTIMEOUT_DFLT;
|
||||
// ControllerSettings.MaxQueueDepth = 0;
|
||||
if (Protocol[ProtocolIndex].usesTemplate)
|
||||
CPlugin_ptr[ProtocolIndex](CPLUGIN_PROTOCOL_TEMPLATE, &TempEvent, dummyString);
|
||||
strncpy(ControllerSettings.Subscribe, TempEvent.String1.c_str(), sizeof(ControllerSettings.Subscribe));
|
||||
strncpy(ControllerSettings.Publish, TempEvent.String2.c_str(), sizeof(ControllerSettings.Publish));
|
||||
strncpy(ControllerSettings.MQTTLwtTopic, TempEvent.String3.c_str(), sizeof(ControllerSettings.MQTTLwtTopic));
|
||||
strncpy(ControllerSettings.LWTMessageConnect, TempEvent.String4.c_str(), sizeof(ControllerSettings.LWTMessageConnect));
|
||||
strncpy(ControllerSettings.LWTMessageDisconnect, TempEvent.String5.c_str(), sizeof(ControllerSettings.LWTMessageDisconnect));
|
||||
safe_strncpy(ControllerSettings.Subscribe, TempEvent.String1.c_str(), sizeof(ControllerSettings.Subscribe));
|
||||
safe_strncpy(ControllerSettings.Publish, TempEvent.String2.c_str(), sizeof(ControllerSettings.Publish));
|
||||
safe_strncpy(ControllerSettings.MQTTLwtTopic, TempEvent.String3.c_str(), sizeof(ControllerSettings.MQTTLwtTopic));
|
||||
safe_strncpy(ControllerSettings.LWTMessageConnect, TempEvent.String4.c_str(), sizeof(ControllerSettings.LWTMessageConnect));
|
||||
safe_strncpy(ControllerSettings.LWTMessageDisconnect, TempEvent.String5.c_str(), sizeof(ControllerSettings.LWTMessageDisconnect));
|
||||
TempEvent.String1 = "";
|
||||
TempEvent.String2 = "";
|
||||
TempEvent.String3 = "";
|
||||
@@ -1231,7 +1238,7 @@ void handle_controllers() {
|
||||
ControllerSettings.UseDNS = usedns.toInt();
|
||||
if (ControllerSettings.UseDNS)
|
||||
{
|
||||
strncpy(ControllerSettings.HostName, controllerhostname.c_str(), sizeof(ControllerSettings.HostName));
|
||||
strncpy_webserver_arg(ControllerSettings.HostName, F("controllerhostname"));
|
||||
IPAddress IP;
|
||||
WiFi.hostByName(ControllerSettings.HostName, IP);
|
||||
for (byte x = 0; x < 4; x++)
|
||||
@@ -1245,24 +1252,26 @@ void handle_controllers() {
|
||||
//copy settings to struct
|
||||
Settings.ControllerEnabled[controllerindex] = isFormItemChecked(F("controllerenabled"));
|
||||
ControllerSettings.Port = controllerport;
|
||||
strncpy(SecuritySettings.ControllerUser[controllerindex], controlleruser.c_str(), sizeof(SecuritySettings.ControllerUser[0]));
|
||||
//strncpy(SecuritySettings.ControllerPassword[controllerindex], controllerpassword.c_str(), sizeof(SecuritySettings.ControllerPassword[0]));
|
||||
strncpy_webserver_arg(SecuritySettings.ControllerUser[controllerindex], F("controlleruser"));
|
||||
//safe_strncpy(SecuritySettings.ControllerPassword[controllerindex], controllerpassword.c_str(), sizeof(SecuritySettings.ControllerPassword[0]));
|
||||
copyFormPassword(F("controllerpassword"), SecuritySettings.ControllerPassword[controllerindex], sizeof(SecuritySettings.ControllerPassword[0]));
|
||||
strncpy(ControllerSettings.Subscribe, controllersubscribe.c_str(), sizeof(ControllerSettings.Subscribe));
|
||||
strncpy(ControllerSettings.Publish, controllerpublish.c_str(), sizeof(ControllerSettings.Publish));
|
||||
strncpy(ControllerSettings.MQTTLwtTopic, MQTTLwtTopic.c_str(), sizeof(ControllerSettings.MQTTLwtTopic));
|
||||
strncpy(ControllerSettings.LWTMessageConnect, lwtmessageconnect.c_str(), sizeof(ControllerSettings.LWTMessageConnect));
|
||||
strncpy(ControllerSettings.LWTMessageDisconnect, lwtmessagedisconnect.c_str(), sizeof(ControllerSettings.LWTMessageDisconnect));
|
||||
strncpy_webserver_arg(ControllerSettings.Subscribe, F("controllersubscribe"));
|
||||
strncpy_webserver_arg(ControllerSettings.Publish, F("controllerpublish"));
|
||||
strncpy_webserver_arg(ControllerSettings.MQTTLwtTopic, F("mqttlwttopic"));
|
||||
strncpy_webserver_arg(ControllerSettings.LWTMessageConnect, F("lwtmessageconnect"));
|
||||
strncpy_webserver_arg(ControllerSettings.LWTMessageDisconnect, F("lwtmessagedisconnect"));
|
||||
ControllerSettings.MinimalTimeBetweenMessages = minimumsendinterval;
|
||||
ControllerSettings.MaxQueueDepth = maxqueuedepth;
|
||||
ControllerSettings.MaxRetry = maxretry;
|
||||
ControllerSettings.DeleteOldest = deleteoldest.toInt();
|
||||
ControllerSettings.DeleteOldest = getFormItemInt(F("deleteoldest"), ControllerSettings.DeleteOldest);
|
||||
ControllerSettings.MustCheckReply = getFormItemInt(F("mustcheckreply"), ControllerSettings.MustCheckReply);
|
||||
ControllerSettings.ClientTimeout = clienttimeout;
|
||||
|
||||
|
||||
CPlugin_ptr[ProtocolIndex](CPLUGIN_INIT, &TempEvent, dummyString);
|
||||
}
|
||||
}
|
||||
addHtmlError(SaveControllerSettings(controllerindex, (byte*)&ControllerSettings, sizeof(ControllerSettings)));
|
||||
addHtmlError(SaveControllerSettings(controllerindex, ControllerSettings));
|
||||
addHtmlError(SaveSettings());
|
||||
}
|
||||
|
||||
@@ -1273,10 +1282,10 @@ void handle_controllers() {
|
||||
TXBuffer += F("<table class='multirow' border=1px frame='box' rules='all'><TR><TH style='width:70px;'>");
|
||||
TXBuffer += F("<TH style='width:50px;'>Nr<TH style='width:100px;'>Enabled<TH>Protocol<TH>Host<TH>Port");
|
||||
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
MakeControllerSettings(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;
|
||||
@@ -1331,8 +1340,8 @@ void handle_controllers() {
|
||||
|
||||
if (Settings.Protocol[controllerindex])
|
||||
{
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(controllerindex, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
MakeControllerSettings(ControllerSettings);
|
||||
LoadControllerSettings(controllerindex, ControllerSettings);
|
||||
byte choice = ControllerSettings.UseDNS;
|
||||
String options[2];
|
||||
options[0] = F("Use IP address");
|
||||
@@ -1343,6 +1352,11 @@ void handle_controllers() {
|
||||
options_delete_oldest[0] = F("Ignore New");
|
||||
options_delete_oldest[1] = F("Delete Oldest");
|
||||
|
||||
byte choice_mustcheckreply = ControllerSettings.MustCheckReply;
|
||||
String options_mustcheckreply[2];
|
||||
options_mustcheckreply[0] = F("Ignore Acknowledgement");
|
||||
options_mustcheckreply[1] = F("Check Acknowledgement");
|
||||
|
||||
|
||||
byte ProtocolIndex = getProtocolIndex(Settings.Protocol[controllerindex]);
|
||||
if (!Protocol[ProtocolIndex].Custom)
|
||||
@@ -1365,6 +1379,9 @@ void handle_controllers() {
|
||||
addFormNumericBox( F("Max Retries"), F("maxretry"), ControllerSettings.MaxRetry, 1, CONTROLLER_DELAY_QUEUE_RETRY_MAX);
|
||||
addFormSelector(F("Full Queue Action"), F("deleteoldest"), 2, options_delete_oldest, NULL, NULL, choice_delete_oldest, true);
|
||||
|
||||
addFormSelector(F("Check Reply"), F("mustcheckreply"), 2, options_mustcheckreply, NULL, NULL, choice_mustcheckreply, true);
|
||||
addFormNumericBox( F("Client Timeout"), F("clienttimeout"), ControllerSettings.ClientTimeout, 10, CONTROLLER_CLIENTTIMEOUT_MAX);
|
||||
addUnit(F("ms"));
|
||||
|
||||
if (Protocol[ProtocolIndex].usesAccount)
|
||||
{
|
||||
@@ -1486,18 +1503,6 @@ void html_TD(int td_cnt) {
|
||||
}
|
||||
}
|
||||
|
||||
void html_input(const String& displayStr, const String& intString, int size, const String& value) {
|
||||
html_TR_TD();
|
||||
TXBuffer += displayStr;
|
||||
TXBuffer += F(":<TD><input class='wide' type='text' name='");
|
||||
TXBuffer += intString;
|
||||
TXBuffer += F("' size=");
|
||||
TXBuffer += size;
|
||||
TXBuffer += F(" value='");
|
||||
TXBuffer += value;
|
||||
TXBuffer += F("'>");
|
||||
}
|
||||
|
||||
|
||||
//********************************************************************************
|
||||
// Web Interface notifcations page
|
||||
@@ -1518,22 +1523,10 @@ void handle_notifications() {
|
||||
--notificationindex;
|
||||
|
||||
const int notification = getFormItemInt(F("notification"), -1);
|
||||
String domain = WebServer.arg(F("domain"));
|
||||
String server = WebServer.arg(F("server"));
|
||||
String sender = WebServer.arg(F("sender"));
|
||||
String receiver = WebServer.arg(F("receiver"));
|
||||
String subject = WebServer.arg(F("subject"));
|
||||
String user = WebServer.arg(F("user"));
|
||||
String pass = WebServer.arg(F("pass"));
|
||||
String body = WebServer.arg(F("body"));
|
||||
String notificationenabled = WebServer.arg(F("notificationenabled"));
|
||||
|
||||
|
||||
|
||||
|
||||
if (notification != -1 && !notificationindexNotSet)
|
||||
{
|
||||
NotificationSettingsStruct NotificationSettings;
|
||||
MakeNotificationSettings(NotificationSettings);
|
||||
if (Settings.Notification[notificationindex] != notification)
|
||||
{
|
||||
Settings.Notification[notificationindex] = notification;
|
||||
@@ -1549,18 +1542,19 @@ void handle_notifications() {
|
||||
NotificationSettings.Pin1 = getFormItemInt(F("pin1"), 0);
|
||||
NotificationSettings.Pin2 = getFormItemInt(F("pin2"), 0);
|
||||
Settings.NotificationEnabled[notificationindex] = isFormItemChecked(F("notificationenabled"));
|
||||
strncpy(NotificationSettings.Domain, domain.c_str(), sizeof(NotificationSettings.Domain));
|
||||
strncpy(NotificationSettings.Server, server.c_str(), sizeof(NotificationSettings.Server));
|
||||
strncpy(NotificationSettings.Sender, sender.c_str(), sizeof(NotificationSettings.Sender));
|
||||
strncpy(NotificationSettings.Receiver, receiver.c_str(), sizeof(NotificationSettings.Receiver));
|
||||
strncpy(NotificationSettings.Subject, subject.c_str(), sizeof(NotificationSettings.Subject));
|
||||
strncpy(NotificationSettings.User, user.c_str(), sizeof(NotificationSettings.User));
|
||||
strncpy(NotificationSettings.Pass, pass.c_str(), sizeof(NotificationSettings.Pass));
|
||||
strncpy(NotificationSettings.Body, body.c_str(), sizeof(NotificationSettings.Body));
|
||||
strncpy_webserver_arg(NotificationSettings.Domain, F("domain"));
|
||||
strncpy_webserver_arg(NotificationSettings.Server, F("server"));
|
||||
strncpy_webserver_arg(NotificationSettings.Sender, F("sender"));
|
||||
strncpy_webserver_arg(NotificationSettings.Receiver, F("receiver"));
|
||||
strncpy_webserver_arg(NotificationSettings.Subject, F("subject"));
|
||||
strncpy_webserver_arg(NotificationSettings.User, F("user"));
|
||||
strncpy_webserver_arg(NotificationSettings.Pass, F("pass"));
|
||||
strncpy_webserver_arg(NotificationSettings.Body, F("body"));
|
||||
|
||||
}
|
||||
}
|
||||
// Save the settings.
|
||||
addHtmlError(SaveNotificationSettings(notificationindex, (byte*)&NotificationSettings, sizeof(NotificationSettings)));
|
||||
addHtmlError(SaveNotificationSettings(notificationindex, (byte*)&NotificationSettings, sizeof(NotificationSettingsStruct)));
|
||||
addHtmlError(SaveSettings());
|
||||
if (WebServer.hasArg(F("test"))) {
|
||||
// Perform tests with the settings in the form.
|
||||
@@ -1581,10 +1575,10 @@ void handle_notifications() {
|
||||
TXBuffer += F("<table class='multirow' border=1px frame='box' rules='all'><TR><TH style='width:70px;'>");
|
||||
TXBuffer += F("<TH style='width:50px;'>Nr<TH style='width:100px;'>Enabled<TH>Service<TH>Server<TH>Port");
|
||||
|
||||
NotificationSettingsStruct NotificationSettings;
|
||||
MakeNotificationSettings(NotificationSettings);
|
||||
for (byte x = 0; x < NOTIFICATION_MAX; x++)
|
||||
{
|
||||
LoadNotificationSettings(x, (byte*)&NotificationSettings, sizeof(NotificationSettings));
|
||||
LoadNotificationSettings(x, (byte*)&NotificationSettings, sizeof(NotificationSettingsStruct));
|
||||
html_TR_TD();
|
||||
TXBuffer += F("<a class='button link' href=\"notifications?index=");
|
||||
TXBuffer += x + 1;
|
||||
@@ -1642,8 +1636,8 @@ void handle_notifications() {
|
||||
|
||||
if (Settings.Notification[notificationindex])
|
||||
{
|
||||
NotificationSettingsStruct NotificationSettings;
|
||||
LoadNotificationSettings(notificationindex, (byte*)&NotificationSettings, sizeof(NotificationSettings));
|
||||
MakeNotificationSettings(NotificationSettings);
|
||||
LoadNotificationSettings(notificationindex, (byte*)&NotificationSettings, sizeof(NotificationSettingsStruct));
|
||||
|
||||
byte NotificationProtocolIndex = getNotificationProtocolIndex(Settings.Notification[notificationindex]);
|
||||
if (NotificationProtocolIndex!=NPLUGIN_NOT_FOUND)
|
||||
@@ -1651,16 +1645,16 @@ void handle_notifications() {
|
||||
|
||||
if (Notification[NotificationProtocolIndex].usesMessaging)
|
||||
{
|
||||
html_input(F("Domain"), F("domain"), 64, NotificationSettings.Domain);
|
||||
html_input(F("Server"), F("server"), 64, NotificationSettings.Server);
|
||||
html_input(F("Port"), F("port"), 5, String(NotificationSettings.Port));
|
||||
addFormTextBox(F("Domain"), F("domain"), NotificationSettings.Domain, sizeof(NotificationSettings.Domain)-1);
|
||||
addFormTextBox(F("Server"), F("server"), NotificationSettings.Server, sizeof(NotificationSettings.Server)-1);
|
||||
addFormNumericBox(F("Port"), F("port"), NotificationSettings.Port, 1, 65535);
|
||||
|
||||
html_input(F("Sender"), F("sender"), 64, NotificationSettings.Sender);
|
||||
html_input(F("Receiver"), F("receiver"), 64, NotificationSettings.Receiver);
|
||||
html_input(F("Subject"), F("subject"), 64, NotificationSettings.Subject);
|
||||
addFormTextBox(F("Sender"), F("sender"), NotificationSettings.Sender, sizeof(NotificationSettings.Sender)-1);
|
||||
addFormTextBox(F("Receiver"), F("receiver"), NotificationSettings.Receiver, sizeof(NotificationSettings.Receiver)-1);
|
||||
addFormTextBox(F("Subject"), F("subject"), NotificationSettings.Subject, sizeof(NotificationSettings.Subject)-1);
|
||||
|
||||
html_input(F("User"), F("user"), 48, NotificationSettings.User);
|
||||
html_input(F("Pass"), F("pass"), 32, NotificationSettings.Pass);
|
||||
addFormTextBox(F("User"), F("user"), NotificationSettings.User, sizeof(NotificationSettings.User)-1);
|
||||
addFormTextBox(F("Pass"), F("pass"), NotificationSettings.Pass, sizeof(NotificationSettings.Pass)-1);
|
||||
|
||||
html_TR_TD(); TXBuffer += F("Body:<TD><textarea name='body' rows='20' size=512 wrap='off'>");
|
||||
TXBuffer += NotificationSettings.Body;
|
||||
@@ -1921,7 +1915,7 @@ void handle_devices() {
|
||||
if (taskdevicenumber != 0) // set default values if a new device has been selected
|
||||
{
|
||||
//NOTE: do not enable task by default. allow user to enter sensible valus first and let him enable it when ready.
|
||||
if (ExtraTaskSettings.TaskDeviceValueNames[0][0] == 0) // if field set empty, reload defaults
|
||||
if (ExtraTaskSettings.TaskIndex != taskIndex) // if field set empty, reload defaults
|
||||
PluginCall(PLUGIN_GET_DEVICEVALUENAMES, &TempEvent, dummyString); //the plugin should populate ExtraTaskSettings with its default values.
|
||||
} else {
|
||||
SaveTaskSettings(taskIndex);
|
||||
@@ -1944,7 +1938,7 @@ void handle_devices() {
|
||||
}
|
||||
|
||||
Settings.TaskDeviceEnabled[taskIndex] = isFormItemChecked(F("TDE"));
|
||||
strcpy(ExtraTaskSettings.TaskDeviceName, WebServer.arg(F("TDN")).c_str());
|
||||
strncpy_webserver_arg(ExtraTaskSettings.TaskDeviceName, F("TDN"));
|
||||
Settings.TaskDevicePort[taskIndex] = getFormItemInt(F("TDP"), 0);
|
||||
|
||||
for (byte controllerNr = 0; controllerNr < CONTROLLER_MAX; controllerNr++)
|
||||
@@ -1967,9 +1961,9 @@ void handle_devices() {
|
||||
for (byte varNr = 0; varNr < Device[DeviceIndex].ValueCount; varNr++)
|
||||
{
|
||||
|
||||
strcpy(ExtraTaskSettings.TaskDeviceFormula[varNr], WebServer.arg(String(F("TDF")) + (varNr + 1)).c_str());
|
||||
strncpy_webserver_arg(ExtraTaskSettings.TaskDeviceFormula[varNr], String(F("TDF")) + (varNr + 1));
|
||||
ExtraTaskSettings.TaskDeviceValueDecimals[varNr] = getFormItemInt(String(F("TDVD")) + (varNr + 1));
|
||||
strcpy(ExtraTaskSettings.TaskDeviceValueNames[varNr], WebServer.arg(String(F("TDVN")) + (varNr + 1)).c_str());
|
||||
strncpy_webserver_arg(ExtraTaskSettings.TaskDeviceValueNames[varNr], String(F("TDVN")) + (varNr + 1));
|
||||
|
||||
// taskdeviceformula[varNr].toCharArray(tmpString, 41);
|
||||
// strcpy(ExtraTaskSettings.TaskDeviceFormula[varNr], tmpString);
|
||||
@@ -1986,7 +1980,7 @@ void handle_devices() {
|
||||
// }
|
||||
|
||||
TempEvent.TaskIndex = taskIndex;
|
||||
if (ExtraTaskSettings.TaskDeviceValueNames[0][0] == 0) // if field set empty, reload defaults
|
||||
if (ExtraTaskSettings.TaskIndex != TempEvent.TaskIndex) // if field set empty, reload defaults
|
||||
PluginCall(PLUGIN_GET_DEVICEVALUENAMES, &TempEvent, dummyString);
|
||||
|
||||
//allow the plugin to save plugin-specific form settings.
|
||||
@@ -2283,7 +2277,7 @@ void handle_devices() {
|
||||
html_TR_TD(); TXBuffer += F("IDX:<TD>");
|
||||
id = F("TDID"); //="taskdeviceid"
|
||||
id += controllerNr + 1;
|
||||
addNumericBox(id, Settings.TaskDeviceID[controllerNr][taskIndex], 0, 999999999); // Looks like it is an unsigned int, so could be up to 4 bln.
|
||||
addNumericBox(id, Settings.TaskDeviceID[controllerNr][taskIndex], 0, DOMOTICZ_MAX_IDX);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2598,8 +2592,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 +2603,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
|
||||
|
||||
@@ -2986,7 +2982,7 @@ void copyFormPassword(const String& id, char* pPassword, int maxlength)
|
||||
String password = WebServer.arg(id);
|
||||
if (password == F("*****")) //no change?
|
||||
return;
|
||||
strncpy(pPassword, password.c_str(), maxlength);
|
||||
safe_strncpy(pPassword, password.c_str(), maxlength);
|
||||
}
|
||||
|
||||
void addFormIPBox(const String& label, const String& id, const byte ip[4])
|
||||
@@ -3130,7 +3126,7 @@ void handle_log_JSON() {
|
||||
TXBuffer += ',';
|
||||
TXBuffer += '{';
|
||||
int loglevel;
|
||||
stream_next_json_object_value(F("label"), getLogLevelDisplayString(i, loglevel));
|
||||
stream_next_json_object_value(F("label"), getLogLevelDisplayStringFromIndex(i, loglevel));
|
||||
stream_last_json_object_value(F("loglevel"), String(loglevel));
|
||||
}
|
||||
TXBuffer += F("],\n");
|
||||
@@ -3173,6 +3169,7 @@ void handle_log_JSON() {
|
||||
stream_last_json_object_value(F("logTimeSpan"), String(logTimeSpan));
|
||||
TXBuffer += F("}\n");
|
||||
TXBuffer.endStream();
|
||||
updateLogLevelCache();
|
||||
}
|
||||
|
||||
//********************************************************************************
|
||||
@@ -3649,6 +3646,8 @@ void handle_control() {
|
||||
}
|
||||
else if (command.equalsIgnoreCase(F("taskrun")) ||
|
||||
command.equalsIgnoreCase(F("taskvalueset")) ||
|
||||
command.equalsIgnoreCase(F("taskvaluetoggle")) ||
|
||||
command.equalsIgnoreCase(F("let")) ||
|
||||
command.equalsIgnoreCase(F("rules"))) {
|
||||
addLog(LOG_LEVEL_INFO,String(F("HTTP : ")) + webrequest);
|
||||
ExecuteCommand(VALUE_SOURCE_HTTP,webrequest.c_str());
|
||||
@@ -3925,11 +3924,6 @@ void handle_advanced() {
|
||||
TXBuffer.startStream();
|
||||
sendHeadandTail(F("TmplStd"));
|
||||
|
||||
char tmpString[81];
|
||||
|
||||
String ip = WebServer.arg(F("ip"));
|
||||
String syslogip = WebServer.arg(F("syslogip"));
|
||||
String ntphost = WebServer.arg(F("ntphost"));
|
||||
int timezone = getFormItemInt(F("timezone"));
|
||||
int dststartweek = getFormItemInt(F("dststartweek"));
|
||||
int dststartdow = getFormItemInt(F("dststartdow"));
|
||||
@@ -3945,15 +3939,14 @@ void handle_advanced() {
|
||||
if (edit.length() != 0)
|
||||
{
|
||||
Settings.MessageDelay = getFormItemInt(F("messagedelay"));
|
||||
Settings.IP_Octet = ip.toInt();
|
||||
ntphost.toCharArray(tmpString, 64);
|
||||
strcpy(Settings.NTPHost, tmpString);
|
||||
Settings.IP_Octet = WebServer.arg(F("ip")).toInt();
|
||||
strncpy_webserver_arg(Settings.NTPHost, F("ntphost"));
|
||||
Settings.TimeZone = timezone;
|
||||
TimeChangeRule dst_start(dststartweek, dststartdow, dststartmonth, dststarthour, timezone);
|
||||
if (dst_start.isValid()) { Settings.DST_Start = dst_start.toFlashStoredValue(); }
|
||||
TimeChangeRule dst_end(dstendweek, dstenddow, dstendmonth, dstendhour, timezone);
|
||||
if (dst_end.isValid()) { Settings.DST_End = dst_end.toFlashStoredValue(); }
|
||||
str2ip(syslogip.c_str(), Settings.Syslog_IP);
|
||||
str2ip(WebServer.arg(F("syslogip")).c_str(), Settings.Syslog_IP);
|
||||
Settings.UDPPort = getFormItemInt(F("udpport"));
|
||||
|
||||
Settings.SyslogFacility = getFormItemInt(F("syslogfacility"));
|
||||
@@ -4115,10 +4108,10 @@ void addLogLevelSelect(String name, int choice)
|
||||
{
|
||||
String options[LOG_LEVEL_NRELEMENTS + 1];
|
||||
int optionValues[LOG_LEVEL_NRELEMENTS + 1] = {0};
|
||||
options[0] = F("None");
|
||||
options[0] = getLogLevelDisplayString(0);
|
||||
optionValues[0] = 0;
|
||||
for (int i = 0; i < LOG_LEVEL_NRELEMENTS; ++i) {
|
||||
options[i + 1] = getLogLevelDisplayString(i, optionValues[i + 1]);
|
||||
options[i + 1] = getLogLevelDisplayStringFromIndex(i, optionValues[i + 1]);
|
||||
}
|
||||
addSelector(name, LOG_LEVEL_NRELEMENTS + 1, options, optionValues, NULL, choice, false);
|
||||
}
|
||||
@@ -4190,6 +4183,7 @@ void handle_download()
|
||||
|
||||
WebServer.sendHeader(F("Content-Disposition"), str);
|
||||
WebServer.streamFile(dataFile, F("application/octet-stream"));
|
||||
dataFile.close();
|
||||
}
|
||||
|
||||
|
||||
@@ -4569,18 +4563,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>");
|
||||
}
|
||||
|
||||
@@ -4591,12 +4607,32 @@ void handle_filelist() {
|
||||
TXBuffer += F("</a>");
|
||||
fs::File f = dir.openFile("r");
|
||||
html_TD();
|
||||
TXBuffer += f.size();
|
||||
if (f) {
|
||||
TXBuffer += f.size();
|
||||
f.close();
|
||||
}
|
||||
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 +4643,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
|
||||
@@ -4870,8 +4938,8 @@ void handle_setup() {
|
||||
// if ssid config not set and params are both provided
|
||||
if (status == 0 && ssid.length() != 0 /*&& strcasecmp(SecuritySettings.WifiSSID, "ssid") == 0 */)
|
||||
{
|
||||
strncpy(SecuritySettings.WifiKey, password.c_str(), sizeof(SecuritySettings.WifiKey));
|
||||
strncpy(SecuritySettings.WifiSSID, ssid.c_str(), sizeof(SecuritySettings.WifiSSID));
|
||||
safe_strncpy(SecuritySettings.WifiKey, password.c_str(), sizeof(SecuritySettings.WifiKey));
|
||||
safe_strncpy(SecuritySettings.WifiSSID, ssid.c_str(), sizeof(SecuritySettings.WifiSSID));
|
||||
wifiSetupConnect = true;
|
||||
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
|
||||
String reconnectlog = F("WIFI : Credentials Changed, retry connection. SSID: ");
|
||||
@@ -4900,7 +4968,11 @@ void handle_setup() {
|
||||
{
|
||||
html_TR_TD(); TXBuffer += F("<label class='container2'>");
|
||||
TXBuffer += F("<input type='radio' name='ssid' value='");
|
||||
TXBuffer += WiFi.SSID(i);
|
||||
{
|
||||
String escapeBuffer = WiFi.SSID(i);
|
||||
htmlStrongEscape(escapeBuffer);
|
||||
TXBuffer += escapeBuffer;
|
||||
}
|
||||
TXBuffer += F("'");
|
||||
if (WiFi.SSID(i) == ssid)
|
||||
TXBuffer += F(" checked ");
|
||||
@@ -4930,7 +5002,7 @@ void handle_setup() {
|
||||
if (refreshCount > 0)
|
||||
{
|
||||
status = 0;
|
||||
// strncpy(SecuritySettings.WifiSSID, "ssid", sizeof(SecuritySettings.WifiSSID));
|
||||
// safe_strncpy(SecuritySettings.WifiSSID, "ssid", sizeof(SecuritySettings.WifiSSID));
|
||||
// SecuritySettings.WifiKey[0] = 0;
|
||||
TXBuffer += F("<a class='button' href='setup'>Back to Setup</a><BR><BR>");
|
||||
}
|
||||
@@ -4973,7 +5045,7 @@ void handle_setup() {
|
||||
//********************************************************************************
|
||||
void handle_rules() {
|
||||
checkRAM(F("handle_rules"));
|
||||
if (!isLoggedIn()) return;
|
||||
if (!isLoggedIn() || !Settings.UseRules) return;
|
||||
navMenuIndex = 5;
|
||||
TXBuffer.startStream();
|
||||
sendHeadandTail(F("TmplStd"));
|
||||
@@ -5039,7 +5111,7 @@ void handle_rules() {
|
||||
log += F(" Create new file: ");
|
||||
log += fileName;
|
||||
fs::File f = SPIFFS.open(fileName, "w");
|
||||
f.close();
|
||||
if (f) f.close();
|
||||
}
|
||||
}
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
@@ -5175,6 +5247,13 @@ void handle_sysinfo() {
|
||||
TXBuffer += F(" - ");
|
||||
TXBuffer += lowestRAMfunction;
|
||||
TXBuffer += F(")");
|
||||
html_TR_TD(); TXBuffer += F("Free Stack<TD>");
|
||||
TXBuffer += getCurrentFreeStack();
|
||||
TXBuffer += F(" (");
|
||||
TXBuffer += lowestFreeStack;
|
||||
TXBuffer += F(" - ");
|
||||
TXBuffer += lowestFreeStackfunction;
|
||||
TXBuffer += F(")");
|
||||
|
||||
html_TR_TD(); TXBuffer += F("Boot<TD>");
|
||||
TXBuffer += getLastBootCauseString();
|
||||
@@ -5236,16 +5315,6 @@ void handle_sysinfo() {
|
||||
html_TR_TD(); TXBuffer += F("Allowed IP Range<TD>");
|
||||
TXBuffer += describeAllowedIPrange();
|
||||
|
||||
html_TR_TD(); TXBuffer += F("Serial Port available:<TD>");
|
||||
TXBuffer += String(SerialAvailableForWrite());
|
||||
TXBuffer += F(" (");
|
||||
#if defined(ESP8266)
|
||||
TXBuffer += Serial.availableForWrite();
|
||||
#endif
|
||||
TXBuffer += F(" , ");
|
||||
TXBuffer += Serial.available();
|
||||
TXBuffer += F(")");
|
||||
|
||||
html_TR_TD(); TXBuffer += F("STA MAC<TD>");
|
||||
|
||||
uint8_t mac[] = {0, 0, 0, 0, 0, 0};
|
||||
@@ -5310,6 +5379,23 @@ void handle_sysinfo() {
|
||||
TXBuffer += F("<TR><TD id='copyText_11'>Binary filename<TD id='copyText_12'>");
|
||||
TXBuffer += String(CRCValues.binaryFilename);
|
||||
|
||||
|
||||
addTableSeparator(F("System Status"), 2, 3);
|
||||
{
|
||||
// Actual Loglevel
|
||||
html_TR_TD(); TXBuffer += F("Syslog Log Level:<TD>");
|
||||
TXBuffer += getLogLevelDisplayString(Settings.SyslogLevel);
|
||||
html_TR_TD(); TXBuffer += F("Serial Log Level:<TD>");
|
||||
TXBuffer += getLogLevelDisplayString(getSerialLogLevel());
|
||||
html_TR_TD(); TXBuffer += F("Web Log Level:<TD>");
|
||||
TXBuffer += getLogLevelDisplayString(getWebLogLevel());
|
||||
#ifdef FEATURE_SD
|
||||
html_TR_TD(); TXBuffer += F("SD Log Level:<TD>");
|
||||
TXBuffer += getLogLevelDisplayString(Settings.SDLogLevel);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
addTableSeparator(F("ESP board"), 2, 3);
|
||||
|
||||
html_TR_TD(); TXBuffer += F("ESP Chip ID<TD>");
|
||||
@@ -5342,6 +5428,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);
|
||||
@@ -5519,6 +5607,15 @@ void handle_sysvars() {
|
||||
addSysVar_html(F("%vcc%"));
|
||||
#endif
|
||||
|
||||
addTableSeparator(F("System status"), 3, 3);
|
||||
|
||||
addSysVar_html(F("%iswifi%"));
|
||||
addSysVar_html(F("%isntp%"));
|
||||
addSysVar_html(F("%ismqtt%"));
|
||||
#ifdef USES_P037
|
||||
addSysVar_html(F("%ismqttimp%"));
|
||||
#endif // USES_P037
|
||||
|
||||
addTableSeparator(F("Time"), 3, 3);
|
||||
addSysVar_html(F("%lcltime%"));
|
||||
addSysVar_html(F("%lcltime_am%"));
|
||||
@@ -5526,6 +5623,8 @@ void handle_sysvars() {
|
||||
addSysVar_html(F("%systm_hm_am%"));
|
||||
addSysVar_html(F("%systime%"));
|
||||
addSysVar_html(F("%systime_am%"));
|
||||
addSysVar_html(F("%sysbuild_date%"));
|
||||
addSysVar_html(F("%sysbuild_time%"));
|
||||
addTableSeparator(F("System"), 3, 3);
|
||||
addSysVar_html(F("%sysyear% // %sysyear_0%"));
|
||||
addSysVar_html(F("%sysyears%"));
|
||||
@@ -5545,6 +5644,11 @@ void handle_sysvars() {
|
||||
addSysVar_html(F("%sunrise%"));
|
||||
addSysVar_html(F("%sunrise+10m%"));
|
||||
|
||||
addTableSeparator(F("Custom Variables"), 3, 3);
|
||||
for (byte i = 0; i < CUSTOM_VARS_MAX; ++i) {
|
||||
addSysVar_html("%v"+toString(i+1,0)+'%');
|
||||
}
|
||||
|
||||
addTableSeparator(F("Special Characters"), 3, 2);
|
||||
addTableSeparator(F("Degree"), 3, 3);
|
||||
addSysVar_html(F("{D}"));
|
||||
|
||||
+3
-3
@@ -33,8 +33,8 @@ boolean CPlugin_001(byte function, struct EventStruct *event, String& string)
|
||||
|
||||
case CPLUGIN_INIT:
|
||||
{
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(event->ControllerIndex, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
MakeControllerSettings(ControllerSettings);
|
||||
LoadControllerSettings(event->ControllerIndex, ControllerSettings);
|
||||
C001_DelayHandler.configureControllerSettings(ControllerSettings);
|
||||
break;
|
||||
}
|
||||
@@ -118,7 +118,7 @@ bool do_process_c001_delay_queue(int controller_number, const C001_queue_element
|
||||
String request = create_http_request_auth(controller_number, element.controller_idx, ControllerSettings, F("GET"), element.txt);
|
||||
|
||||
addLog(LOG_LEVEL_DEBUG, element.txt);
|
||||
return send_via_http(controller_number, client, request);
|
||||
return send_via_http(controller_number, client, request, ControllerSettings.MustCheckReply);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+4
-4
@@ -35,8 +35,8 @@ boolean CPlugin_002(byte function, struct EventStruct *event, String& string)
|
||||
|
||||
case CPLUGIN_INIT:
|
||||
{
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(event->ControllerIndex, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
MakeControllerSettings(ControllerSettings);
|
||||
LoadControllerSettings(event->ControllerIndex, ControllerSettings);
|
||||
MQTTDelayHandler.configureControllerSettings(ControllerSettings);
|
||||
break;
|
||||
}
|
||||
@@ -145,8 +145,8 @@ boolean CPlugin_002(byte function, struct EventStruct *event, String& string)
|
||||
{
|
||||
if (event->idx != 0)
|
||||
{
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(event->ControllerIndex, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
MakeControllerSettings(ControllerSettings);
|
||||
LoadControllerSettings(event->ControllerIndex, ControllerSettings);
|
||||
/*
|
||||
if (!ControllerSettings.checkHostReachable(true)) {
|
||||
success = false;
|
||||
|
||||
+4
-4
@@ -32,8 +32,8 @@ boolean CPlugin_003(byte function, struct EventStruct *event, String& string)
|
||||
|
||||
case CPLUGIN_INIT:
|
||||
{
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(event->ControllerIndex, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
MakeControllerSettings(ControllerSettings);
|
||||
LoadControllerSettings(event->ControllerIndex, ControllerSettings);
|
||||
C003_DelayHandler.configureControllerSettings(ControllerSettings);
|
||||
break;
|
||||
}
|
||||
@@ -78,7 +78,7 @@ bool do_process_c003_delay_queue(int controller_number, const C003_queue_element
|
||||
client.print(" \n");
|
||||
|
||||
unsigned long timer = millis() + 200;
|
||||
while (!client.available() && !timeOutReached(timer))
|
||||
while (!client_available(client) && !timeOutReached(timer))
|
||||
delay(1);
|
||||
|
||||
timer = millis() + 1000;
|
||||
@@ -102,7 +102,7 @@ bool do_process_c003_delay_queue(int controller_number, const C003_queue_element
|
||||
addLog(LOG_LEVEL_DEBUG, log);
|
||||
client.println(SecuritySettings.ControllerPassword[element.controller_idx]);
|
||||
delay(100);
|
||||
while (client.available())
|
||||
while (client_available(client))
|
||||
client.read();
|
||||
|
||||
strcpy_P(log, PSTR("TELNT: Sending cmd"));
|
||||
|
||||
+3
-3
@@ -32,8 +32,8 @@ boolean CPlugin_004(byte function, struct EventStruct *event, String& string)
|
||||
|
||||
case CPLUGIN_INIT:
|
||||
{
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(event->ControllerIndex, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
MakeControllerSettings(ControllerSettings);
|
||||
LoadControllerSettings(event->ControllerIndex, ControllerSettings);
|
||||
C004_DelayHandler.configureControllerSettings(ControllerSettings);
|
||||
break;
|
||||
}
|
||||
@@ -94,6 +94,6 @@ bool do_process_c004_delay_queue(int controller_number, const C004_queue_element
|
||||
postDataStr.length());
|
||||
postStr += postDataStr;
|
||||
|
||||
return send_via_http(controller_number, client, postStr);
|
||||
return send_via_http(controller_number, client, postStr, ControllerSettings.MustCheckReply);
|
||||
}
|
||||
#endif
|
||||
|
||||
+5
-5
@@ -33,8 +33,8 @@ boolean CPlugin_005(byte function, struct EventStruct *event, String& string)
|
||||
|
||||
case CPLUGIN_INIT:
|
||||
{
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(event->ControllerIndex, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
MakeControllerSettings(ControllerSettings);
|
||||
LoadControllerSettings(event->ControllerIndex, ControllerSettings);
|
||||
MQTTDelayHandler.configureControllerSettings(ControllerSettings);
|
||||
break;
|
||||
}
|
||||
@@ -92,15 +92,15 @@ boolean CPlugin_005(byte function, struct EventStruct *event, String& string)
|
||||
|
||||
case CPLUGIN_PROTOCOL_SEND:
|
||||
{
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(event->ControllerIndex, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
MakeControllerSettings(ControllerSettings);
|
||||
LoadControllerSettings(event->ControllerIndex, ControllerSettings);
|
||||
if (!ControllerSettings.checkHostReachable(true)) {
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
statusLED(true);
|
||||
|
||||
if (ExtraTaskSettings.TaskDeviceValueNames[0][0] == 0)
|
||||
if (ExtraTaskSettings.TaskIndex != event->TaskIndex)
|
||||
PluginCall(PLUGIN_GET_DEVICEVALUENAMES, event, dummyString);
|
||||
|
||||
String pubname = ControllerSettings.Publish;
|
||||
|
||||
+5
-5
@@ -33,8 +33,8 @@ boolean CPlugin_006(byte function, struct EventStruct *event, String& string)
|
||||
|
||||
case CPLUGIN_INIT:
|
||||
{
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(event->ControllerIndex, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
MakeControllerSettings(ControllerSettings);
|
||||
LoadControllerSettings(event->ControllerIndex, ControllerSettings);
|
||||
MQTTDelayHandler.configureControllerSettings(ControllerSettings);
|
||||
break;
|
||||
}
|
||||
@@ -90,12 +90,12 @@ boolean CPlugin_006(byte function, struct EventStruct *event, String& string)
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(event->ControllerIndex, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
MakeControllerSettings(ControllerSettings);
|
||||
LoadControllerSettings(event->ControllerIndex, ControllerSettings);
|
||||
|
||||
statusLED(true);
|
||||
|
||||
if (ExtraTaskSettings.TaskDeviceValueNames[0][0] == 0)
|
||||
if (ExtraTaskSettings.TaskIndex != event->TaskIndex)
|
||||
PluginCall(PLUGIN_GET_DEVICEVALUENAMES, event, dummyString);
|
||||
|
||||
String pubname = ControllerSettings.Publish;
|
||||
|
||||
+4
-3
@@ -32,8 +32,8 @@ boolean CPlugin_007(byte function, struct EventStruct *event, String& string)
|
||||
|
||||
case CPLUGIN_INIT:
|
||||
{
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(event->ControllerIndex, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
MakeControllerSettings(ControllerSettings);
|
||||
LoadControllerSettings(event->ControllerIndex, ControllerSettings);
|
||||
C007_DelayHandler.configureControllerSettings(ControllerSettings);
|
||||
break;
|
||||
}
|
||||
@@ -78,6 +78,7 @@ bool do_process_c007_delay_queue(int controller_number, const C007_queue_element
|
||||
Serial.println(url);
|
||||
|
||||
return send_via_http(controller_number, client,
|
||||
create_http_get_request(controller_number, ControllerSettings, url));
|
||||
create_http_get_request(controller_number, ControllerSettings, url),
|
||||
ControllerSettings.MustCheckReply);
|
||||
}
|
||||
#endif
|
||||
|
||||
+6
-6
@@ -34,8 +34,8 @@ boolean CPlugin_008(byte function, struct EventStruct *event, String& string)
|
||||
|
||||
case CPLUGIN_INIT:
|
||||
{
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(event->ControllerIndex, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
MakeControllerSettings(ControllerSettings);
|
||||
LoadControllerSettings(event->ControllerIndex, ControllerSettings);
|
||||
C008_DelayHandler.configureControllerSettings(ControllerSettings);
|
||||
break;
|
||||
}
|
||||
@@ -52,11 +52,11 @@ boolean CPlugin_008(byte function, struct EventStruct *event, String& string)
|
||||
// Collect the values at the same run, to make sure all are from the same sample
|
||||
byte valueCount = getValueCountFromSensorType(event->sensorType);
|
||||
C008_queue_element element(event, valueCount);
|
||||
if (ExtraTaskSettings.TaskDeviceValueNames[0][0] == 0)
|
||||
if (ExtraTaskSettings.TaskIndex != event->TaskIndex)
|
||||
PluginCall(PLUGIN_GET_DEVICEVALUENAMES, event, dummyString);
|
||||
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(event->ControllerIndex, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
MakeControllerSettings(ControllerSettings);
|
||||
LoadControllerSettings(event->ControllerIndex, ControllerSettings);
|
||||
|
||||
for (byte x = 0; x < valueCount; x++)
|
||||
{
|
||||
@@ -97,7 +97,7 @@ bool do_process_c008_delay_queue(int controller_number, const C008_queue_element
|
||||
return false;
|
||||
|
||||
String request = create_http_request_auth(controller_number, element.controller_idx, ControllerSettings, F("GET"), element.txt[element.valuesSent]);
|
||||
return element.checkDone(send_via_http(controller_number, client, request));
|
||||
return element.checkDone(send_via_http(controller_number, client, request, ControllerSettings.MustCheckReply));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+58
-52
@@ -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
|
||||
@@ -57,60 +57,20 @@ boolean CPlugin_009(byte function, struct EventStruct *event, String& string)
|
||||
|
||||
case CPLUGIN_PROTOCOL_SEND:
|
||||
{
|
||||
if (!WiFiConnected(100)) {
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
if (ExtraTaskSettings.TaskDeviceValueNames[0][0] == 0)
|
||||
byte valueCount = getValueCountFromSensorType(event->sensorType);
|
||||
C009_queue_element element(event);
|
||||
if (ExtraTaskSettings.TaskIndex != event->TaskIndex)
|
||||
PluginCall(PLUGIN_GET_DEVICEVALUENAMES, event, dummyString);
|
||||
|
||||
// We now create a URI for the request
|
||||
String url = F("/ESPEasy");
|
||||
MakeControllerSettings(ControllerSettings);
|
||||
LoadControllerSettings(event->ControllerIndex, ControllerSettings);
|
||||
|
||||
// Create json root object
|
||||
DynamicJsonBuffer jsonBuffer;
|
||||
JsonObject& root = jsonBuffer.createObject();
|
||||
root[F("module")] = String(F("ESPEasy"));
|
||||
root[F("version")] = String(F("1.04"));
|
||||
|
||||
// Create nested objects
|
||||
JsonObject& data = root.createNestedObject(String(F("data")));
|
||||
JsonObject& ESP = data.createNestedObject(String(F("ESP")));
|
||||
ESP[F("name")] = Settings.Name;
|
||||
ESP[F("unit")] = Settings.Unit;
|
||||
ESP[F("version")] = Settings.Version;
|
||||
ESP[F("build")] = Settings.Build;
|
||||
ESP[F("build_notes")] = String(F(BUILD_NOTES));
|
||||
ESP[F("build_git")] = String(F(BUILD_GIT));
|
||||
ESP[F("node_type_id")] = NODE_TYPE_ID;
|
||||
ESP[F("sleep")] = Settings.deepSleep;
|
||||
|
||||
// embed IP, important if there is NAT/PAT
|
||||
// char ipStr[20];
|
||||
// IPAddress ip = WiFi.localIP();
|
||||
// sprintf_P(ipStr, PSTR("%u.%u.%u.%u"), ip[0], ip[1], ip[2], ip[3]);
|
||||
ESP[F("ip")] = WiFi.localIP().toString();
|
||||
|
||||
// Create nested SENSOR json object
|
||||
JsonObject& SENSOR = data.createNestedObject(String(F("SENSOR")));
|
||||
byte valueCount = getValueCountFromSensorType(event->sensorType);
|
||||
// char itemNames[valueCount][2];
|
||||
for (byte x = 0; x < valueCount; x++)
|
||||
{
|
||||
// Each sensor value get an own object (0..n)
|
||||
// sprintf(itemNames[x],"%d",x);
|
||||
JsonObject& val = SENSOR.createNestedObject(String(x));
|
||||
val[F("deviceName")] = getTaskDeviceName(event->TaskIndex);
|
||||
val[F("valueName")] = ExtraTaskSettings.TaskDeviceValueNames[x];
|
||||
val[F("type")] = event->sensorType;
|
||||
val[F("value")] = formatUserVarNoCheck(event, x);
|
||||
element.txt[x] = formatUserVarNoCheck(event, x);
|
||||
element.valueNames[x] = ExtraTaskSettings.TaskDeviceValueNames[x];
|
||||
}
|
||||
|
||||
// Create json buffer
|
||||
String jsonString;
|
||||
root.printTo(jsonString);
|
||||
|
||||
success = C009_DelayHandler.addToQueue(C009_queue_element(event->ControllerIndex, url, jsonString));
|
||||
success = C009_DelayHandler.addToQueue(element);
|
||||
scheduleNextDelayQueue(TIMER_C009_DELAY_QUEUE, C009_DelayHandler.getNextScheduleTime());
|
||||
break;
|
||||
}
|
||||
@@ -126,11 +86,57 @@ bool do_process_c009_delay_queue(int controller_number, const C009_queue_element
|
||||
if (!try_connect_host(controller_number, client, ControllerSettings))
|
||||
return false;
|
||||
|
||||
// Create json root object
|
||||
DynamicJsonBuffer jsonBuffer;
|
||||
JsonObject& root = jsonBuffer.createObject();
|
||||
root[F("module")] = String(F("ESPEasy"));
|
||||
root[F("version")] = String(F("1.04"));
|
||||
|
||||
// Create nested objects
|
||||
JsonObject& data = root.createNestedObject(String(F("data")));
|
||||
JsonObject& ESP = data.createNestedObject(String(F("ESP")));
|
||||
ESP[F("name")] = Settings.Name;
|
||||
ESP[F("unit")] = Settings.Unit;
|
||||
ESP[F("version")] = Settings.Version;
|
||||
ESP[F("build")] = Settings.Build;
|
||||
ESP[F("build_notes")] = String(F(BUILD_NOTES));
|
||||
ESP[F("build_git")] = String(F(BUILD_GIT));
|
||||
ESP[F("node_type_id")] = NODE_TYPE_ID;
|
||||
ESP[F("sleep")] = Settings.deepSleep;
|
||||
|
||||
// embed IP, important if there is NAT/PAT
|
||||
// char ipStr[20];
|
||||
// IPAddress ip = WiFi.localIP();
|
||||
// sprintf_P(ipStr, PSTR("%u.%u.%u.%u"), ip[0], ip[1], ip[2], ip[3]);
|
||||
ESP[F("ip")] = WiFi.localIP().toString();
|
||||
|
||||
// Create nested SENSOR json object
|
||||
JsonObject& SENSOR = data.createNestedObject(String(F("SENSOR")));
|
||||
byte valueCount = getValueCountFromSensorType(element.sensorType);
|
||||
// char itemNames[valueCount][2];
|
||||
for (byte x = 0; x < valueCount; x++)
|
||||
{
|
||||
// Each sensor value get an own object (0..n)
|
||||
// sprintf(itemNames[x],"%d",x);
|
||||
JsonObject& val = SENSOR.createNestedObject(String(x));
|
||||
val[F("deviceName")] = getTaskDeviceName(element.TaskIndex);
|
||||
val[F("valueName")] = element.valueNames[x];
|
||||
val[F("type")] = element.sensorType;
|
||||
val[F("value")] = element.txt[x];
|
||||
}
|
||||
|
||||
// Create json buffer
|
||||
String jsonString;
|
||||
root.printTo(jsonString);
|
||||
|
||||
// We now create a URI for the request
|
||||
String url = F("/ESPEasy");
|
||||
|
||||
String request = create_http_request_auth(
|
||||
controller_number, element.controller_idx, ControllerSettings,
|
||||
F("POST"), element.url, element.json.length());
|
||||
request += element.json;
|
||||
F("POST"), url, jsonString.length());
|
||||
request += jsonString;
|
||||
|
||||
return send_via_http(controller_number, client, request);
|
||||
return send_via_http(controller_number, client, request, ControllerSettings.MustCheckReply);
|
||||
}
|
||||
#endif
|
||||
|
||||
+12
-7
@@ -42,11 +42,11 @@ boolean CPlugin_010(byte function, struct EventStruct *event, String& string)
|
||||
{
|
||||
byte valueCount = getValueCountFromSensorType(event->sensorType);
|
||||
C010_queue_element element(event, valueCount);
|
||||
if (ExtraTaskSettings.TaskDeviceValueNames[0][0] == 0)
|
||||
if (ExtraTaskSettings.TaskIndex != event->TaskIndex)
|
||||
PluginCall(PLUGIN_GET_DEVICEVALUENAMES, event, dummyString);
|
||||
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(event->ControllerIndex, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
MakeControllerSettings(ControllerSettings);
|
||||
LoadControllerSettings(event->ControllerIndex, ControllerSettings);
|
||||
|
||||
for (byte x = 0; x < valueCount; x++)
|
||||
{
|
||||
@@ -85,13 +85,18 @@ bool do_process_c010_delay_queue(int controller_number, const C010_queue_element
|
||||
if (element.checkDone(true))
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!try_connect_host(controller_number, portUDP, ControllerSettings))
|
||||
WiFiUDP C010_portUDP;
|
||||
if (!beginWiFiUDP_randomPort(C010_portUDP)) return false;
|
||||
if (!try_connect_host(controller_number, C010_portUDP, ControllerSettings))
|
||||
return false;
|
||||
|
||||
portUDP.write(
|
||||
C010_portUDP.write(
|
||||
(uint8_t*)element.txt[element.valuesSent].c_str(),
|
||||
element.txt[element.valuesSent].length());
|
||||
return element.checkDone(portUDP.endPacket() != 0);
|
||||
bool reply = C010_portUDP.endPacket();
|
||||
C010_portUDP.stop();
|
||||
if (ControllerSettings.MustCheckReply)
|
||||
return element.checkDone(reply);
|
||||
return element.checkDone(true);
|
||||
}
|
||||
#endif
|
||||
|
||||
+4
-4
@@ -133,7 +133,7 @@ bool do_process_c011_delay_queue(int controller_number, const C011_queue_element
|
||||
if (!try_connect_host(controller_number, client, ControllerSettings))
|
||||
return false;
|
||||
|
||||
return send_via_http(controller_number, client, element.txt);
|
||||
return send_via_http(controller_number, client, element.txt, ControllerSettings.MustCheckReply);
|
||||
}
|
||||
|
||||
|
||||
@@ -147,8 +147,8 @@ boolean Create_schedule_HTTP_C011(struct EventStruct *event)
|
||||
if (!WiFiConnected(100)) {
|
||||
return false;
|
||||
}
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(event->ControllerIndex, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
MakeControllerSettings(ControllerSettings);
|
||||
LoadControllerSettings(event->ControllerIndex, ControllerSettings);
|
||||
|
||||
C011_ConfigStruct customConfig;
|
||||
LoadCustomControllerSettings(event->ControllerIndex,(byte*)&customConfig, sizeof(customConfig));
|
||||
@@ -158,7 +158,7 @@ boolean Create_schedule_HTTP_C011(struct EventStruct *event)
|
||||
if (!try_connect_host(controller_number, client, ControllerSettings))
|
||||
return false;
|
||||
|
||||
if (ExtraTaskSettings.TaskDeviceValueNames[0][0] == 0)
|
||||
if (ExtraTaskSettings.TaskIndex != event->TaskIndex)
|
||||
PluginCall(PLUGIN_GET_DEVICEVALUENAMES, event, dummyString);
|
||||
|
||||
String payload = create_http_request_auth(
|
||||
|
||||
+50
-51
@@ -37,11 +37,11 @@ boolean CPlugin_012(byte function, struct EventStruct *event, String& string)
|
||||
// Collect the values at the same run, to make sure all are from the same sample
|
||||
byte valueCount = getValueCountFromSensorType(event->sensorType);
|
||||
C012_queue_element element(event, valueCount);
|
||||
if (ExtraTaskSettings.TaskDeviceValueNames[0][0] == 0)
|
||||
if (ExtraTaskSettings.TaskIndex != event->TaskIndex)
|
||||
PluginCall(PLUGIN_GET_DEVICEVALUENAMES, event, dummyString);
|
||||
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(event->ControllerIndex, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
MakeControllerSettings(ControllerSettings);
|
||||
LoadControllerSettings(event->ControllerIndex, ControllerSettings);
|
||||
|
||||
for (byte x = 0; x < valueCount; x++)
|
||||
{
|
||||
@@ -73,17 +73,16 @@ bool do_process_c012_delay_queue(int controller_number, const C012_queue_element
|
||||
if (element.checkDone(true))
|
||||
return true;
|
||||
}
|
||||
if (wifiStatus != ESPEASY_WIFI_SERVICES_INITIALIZED) {
|
||||
return false;
|
||||
}
|
||||
return element.checkDone(Blynk_get(element.txt[element.valuesSent], element.controller_idx));
|
||||
}
|
||||
|
||||
boolean Blynk_get(const String& command, byte controllerIndex, float *data )
|
||||
{
|
||||
if (wifiStatus != ESPEASY_WIFI_SERVICES_INITIALIZED) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(controllerIndex, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
MakeControllerSettings(ControllerSettings);
|
||||
LoadControllerSettings(controllerIndex, ControllerSettings);
|
||||
|
||||
if ((SecuritySettings.ControllerPassword[controllerIndex][0] == 0)) {
|
||||
addLog(LOG_LEVEL_ERROR, F("Blynk : No password set"));
|
||||
@@ -104,58 +103,58 @@ boolean Blynk_get(const String& command, byte controllerIndex, float *data )
|
||||
ControllerSettings.getHost().c_str());
|
||||
addLog(LOG_LEVEL_DEBUG, request);
|
||||
client.print(request);
|
||||
boolean success = !ControllerSettings.MustCheckReply;
|
||||
if (ControllerSettings.MustCheckReply || data) {
|
||||
unsigned long timer = millis() + 200;
|
||||
while (!client_available(client) && !timeOutReached(timer))
|
||||
delay(1);
|
||||
|
||||
unsigned long timer = millis() + 200;
|
||||
while (!client.available() && !timeOutReached(timer))
|
||||
yield();
|
||||
char log[80] = {0};
|
||||
|
||||
boolean success = false;
|
||||
char log[80] = {0};
|
||||
|
||||
// Read all the lines of the reply from server and log them
|
||||
while (client_available(client)) {
|
||||
String line;
|
||||
safeReadStringUntil(client, line, '\n');
|
||||
addLog(LOG_LEVEL_DEBUG_MORE, line);
|
||||
// success ?
|
||||
if (line.substring(0, 15) == F("HTTP/1.1 200 OK")) {
|
||||
strcpy_P(log, PSTR("HTTP : Success"));
|
||||
success = true;
|
||||
}
|
||||
else if (line.substring(0, 24) == F("HTTP/1.1 400 Bad Request")) {
|
||||
strcpy_P(log, PSTR("HTTP : Unauthorized"));
|
||||
}
|
||||
else if (line.substring(0, 25) == F("HTTP/1.1 401 Unauthorized")) {
|
||||
strcpy_P(log, PSTR("HTTP : Unauthorized"));
|
||||
}
|
||||
addLog(LOG_LEVEL_DEBUG, log);
|
||||
|
||||
// data only
|
||||
if (data && line.startsWith("["))
|
||||
{
|
||||
String strValue = line;
|
||||
byte pos = strValue.indexOf('"',2);
|
||||
strValue = strValue.substring(2, pos);
|
||||
strValue.trim();
|
||||
float value = strValue.toFloat();
|
||||
*data = value;
|
||||
success = true;
|
||||
|
||||
char value_char[5] = {0};
|
||||
strValue.toCharArray(value_char, 5);
|
||||
sprintf_P(log, PSTR("Blynk get - %s => %s"),command.c_str(), value_char );
|
||||
// Read all the lines of the reply from server and log them
|
||||
while (client_available(client)) {
|
||||
String line;
|
||||
safeReadStringUntil(client, line, '\n');
|
||||
addLog(LOG_LEVEL_DEBUG_MORE, line);
|
||||
// success ?
|
||||
if (line.substring(0, 15) == F("HTTP/1.1 200 OK")) {
|
||||
strcpy_P(log, PSTR("HTTP : Success"));
|
||||
success = true;
|
||||
}
|
||||
else if (line.substring(0, 24) == F("HTTP/1.1 400 Bad Request")) {
|
||||
strcpy_P(log, PSTR("HTTP : Unauthorized"));
|
||||
}
|
||||
else if (line.substring(0, 25) == F("HTTP/1.1 401 Unauthorized")) {
|
||||
strcpy_P(log, PSTR("HTTP : Unauthorized"));
|
||||
}
|
||||
addLog(LOG_LEVEL_DEBUG, log);
|
||||
|
||||
// data only
|
||||
if (data && line.startsWith("["))
|
||||
{
|
||||
String strValue = line;
|
||||
byte pos = strValue.indexOf('"',2);
|
||||
strValue = strValue.substring(2, pos);
|
||||
strValue.trim();
|
||||
float value = strValue.toFloat();
|
||||
*data = value;
|
||||
success = true;
|
||||
|
||||
char value_char[5] = {0};
|
||||
strValue.toCharArray(value_char, 5);
|
||||
sprintf_P(log, PSTR("Blynk get - %s => %s"),command.c_str(), value_char );
|
||||
addLog(LOG_LEVEL_DEBUG, log);
|
||||
}
|
||||
yield();
|
||||
}
|
||||
yield();
|
||||
}
|
||||
strcpy_P(log, PSTR("HTTP : closing connection (012)"));
|
||||
addLog(LOG_LEVEL_DEBUG, log);
|
||||
addLog(LOG_LEVEL_DEBUG, F("HTTP : closing connection (012)"));
|
||||
|
||||
client.flush();
|
||||
client.stop();
|
||||
|
||||
// important - backgroundtasks - free mem
|
||||
timer = millis() + Settings.MessageDelay;
|
||||
unsigned long timer = millis() + Settings.MessageDelay;
|
||||
while (!timeOutReached(timer))
|
||||
backgroundtasks();
|
||||
|
||||
|
||||
+106
-77
@@ -126,10 +126,10 @@ public:
|
||||
return total;
|
||||
}
|
||||
|
||||
String txt[VARS_PER_TASK];
|
||||
int controller_idx;
|
||||
byte TaskIndex;
|
||||
int idx;
|
||||
String txt[VARS_PER_TASK];
|
||||
mutable byte valuesSent; // Value must be set by const function checkDone()
|
||||
byte valueCount;
|
||||
};
|
||||
@@ -146,19 +146,31 @@ public:
|
||||
\*********************************************************************************************/
|
||||
class C009_queue_element {
|
||||
public:
|
||||
C009_queue_element() : controller_idx(0) {}
|
||||
C009_queue_element(int ctrl_idx, const String& URI, const String& JSON) :
|
||||
controller_idx(ctrl_idx), url(URI), json(JSON) {}
|
||||
C009_queue_element() : controller_idx(0), TaskIndex(0), idx(0), sensorType(0) {}
|
||||
C009_queue_element(const struct EventStruct* event) :
|
||||
controller_idx(event->ControllerIndex),
|
||||
TaskIndex(event->TaskIndex),
|
||||
idx(event->idx),
|
||||
sensorType(event->sensorType) {}
|
||||
|
||||
size_t getSize() const {
|
||||
return sizeof(this) + url.length() + json.length();
|
||||
size_t total = sizeof(this);
|
||||
for (int i = 0; i < VARS_PER_TASK; ++i) {
|
||||
total += txt[i].length();
|
||||
total += valueNames[i].length();
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
String txt[VARS_PER_TASK];
|
||||
String valueNames[VARS_PER_TASK];
|
||||
int controller_idx;
|
||||
String url;
|
||||
String json;
|
||||
byte TaskIndex;
|
||||
int idx;
|
||||
byte sensorType;
|
||||
};
|
||||
|
||||
|
||||
/*********************************************************************************************\
|
||||
* C010_queue_element for queueing requests for 010: Generic UDP
|
||||
* Using queue_element_single_value_base
|
||||
@@ -189,13 +201,15 @@ struct ControllerDelayHandlerStruct {
|
||||
max_queue_depth(CONTROLLER_DELAY_QUEUE_DEPTH_DFLT),
|
||||
attempt(0),
|
||||
max_retries(CONTROLLER_DELAY_QUEUE_RETRY_DFLT),
|
||||
delete_oldest(false) {}
|
||||
delete_oldest(false),
|
||||
must_check_reply(false) {}
|
||||
|
||||
void configureControllerSettings(const ControllerSettingsStruct& settings) {
|
||||
minTimeBetweenMessages = settings.MinimalTimeBetweenMessages;
|
||||
max_queue_depth = settings.MaxQueueDepth;
|
||||
max_retries = settings.MaxRetry;
|
||||
delete_oldest = settings.DeleteOldest;
|
||||
must_check_reply = settings.MustCheckReply;
|
||||
// Set some sound limits when not configured
|
||||
if (max_queue_depth == 0) max_queue_depth = CONTROLLER_DELAY_QUEUE_DEPTH_DFLT;
|
||||
if (max_retries == 0) max_retries = CONTROLLER_DELAY_QUEUE_RETRY_DFLT;
|
||||
@@ -251,15 +265,14 @@ struct ControllerDelayHandlerStruct {
|
||||
|
||||
// Get the next element.
|
||||
// Remove front element when max_retries is reached.
|
||||
bool getNext(T& element) {
|
||||
if (sendQueue.empty()) return false;
|
||||
T* getNext() {
|
||||
if (sendQueue.empty()) return NULL;
|
||||
if (attempt > max_retries) {
|
||||
sendQueue.pop_front();
|
||||
attempt = 0;
|
||||
if (sendQueue.empty()) return false;
|
||||
if (sendQueue.empty()) return NULL;
|
||||
}
|
||||
element = sendQueue.front();
|
||||
return true;
|
||||
return &sendQueue.front();
|
||||
}
|
||||
|
||||
// Mark as processed and return time to schedule for next process.
|
||||
@@ -302,6 +315,7 @@ struct ControllerDelayHandlerStruct {
|
||||
byte attempt;
|
||||
byte max_retries;
|
||||
bool delete_oldest;
|
||||
bool must_check_reply;
|
||||
};
|
||||
|
||||
ControllerDelayHandlerStruct<MQTT_queue_element> MQTTDelayHandler;
|
||||
@@ -321,17 +335,17 @@ ControllerDelayHandlerStruct<MQTT_queue_element> MQTTDelayHandler;
|
||||
ControllerDelayHandlerStruct<C##NNN##_queue_element> C##NNN##_DelayHandler; \
|
||||
bool do_process_c##NNN##_delay_queue(int controller_number, const C##NNN##_queue_element& element, ControllerSettingsStruct& ControllerSettings); \
|
||||
void process_c##NNN##_delay_queue() { \
|
||||
C##NNN##_queue_element element; \
|
||||
if (!C##NNN##_DelayHandler.getNext(element)) return; \
|
||||
ControllerSettingsStruct ControllerSettings; \
|
||||
LoadControllerSettings(element.controller_idx, (byte*)&ControllerSettings, sizeof(ControllerSettings)); \
|
||||
C##NNN##_queue_element* element(C##NNN##_DelayHandler.getNext()); \
|
||||
if (element == NULL) return; \
|
||||
MakeControllerSettings(ControllerSettings); \
|
||||
LoadControllerSettings(element->controller_idx, ControllerSettings); \
|
||||
C##NNN##_DelayHandler.configureControllerSettings(ControllerSettings); \
|
||||
if (!WiFiConnected(100)) { \
|
||||
scheduleNextDelayQueue(TIMER_C##NNN##_DELAY_QUEUE, C##NNN##_DelayHandler.getNextScheduleTime()); \
|
||||
return; \
|
||||
} \
|
||||
START_TIMER; \
|
||||
C##NNN##_DelayHandler.markProcessed(do_process_c##NNN##_delay_queue(M, element, ControllerSettings)); \
|
||||
C##NNN##_DelayHandler.markProcessed(do_process_c##NNN##_delay_queue(M, *element, ControllerSettings)); \
|
||||
STOP_TIMER(C##NNN##_DELAY_QUEUE); \
|
||||
scheduleNextDelayQueue(TIMER_C##NNN##_DELAY_QUEUE, C##NNN##_DelayHandler.getNextScheduleTime()); \
|
||||
}
|
||||
@@ -382,31 +396,35 @@ bool safeReadStringUntil(Stream &input, String &str, char terminator, unsigned i
|
||||
int c;
|
||||
const unsigned long start = millis();
|
||||
const unsigned long timer = start + timeout;
|
||||
unsigned long backgroundtasks_timer = start + 100;
|
||||
unsigned long backgroundtasks_timer = start + 10;
|
||||
str = "";
|
||||
|
||||
do {
|
||||
//read character
|
||||
c = input.read();
|
||||
if (c >= 0) {
|
||||
//found terminator, we're ok
|
||||
if (c == terminator) {
|
||||
return(true);
|
||||
}
|
||||
//found character, add to string
|
||||
else{
|
||||
str += char(c);
|
||||
//string at max size?
|
||||
if (str.length() >= maxSize) {
|
||||
addLog(LOG_LEVEL_ERROR, F("Not enough bufferspace to read all input data!"));
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
// We must run the backgroundtasks every now and then.
|
||||
if (timeOutReached(backgroundtasks_timer)) {
|
||||
backgroundtasks_timer += 100;
|
||||
backgroundtasks();
|
||||
if (input.available()) {
|
||||
c = input.read();
|
||||
if (c >= 0) {
|
||||
//found terminator, we're ok
|
||||
if (c == terminator) {
|
||||
return(true);
|
||||
}
|
||||
//found character, add to string
|
||||
else{
|
||||
str += char(c);
|
||||
//string at max size?
|
||||
if (str.length() >= maxSize) {
|
||||
addLog(LOG_LEVEL_ERROR, F("Not enough bufferspace to read all input data!"));
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
// We must run the backgroundtasks every now and then.
|
||||
if (timeOutReached(backgroundtasks_timer)) {
|
||||
backgroundtasks_timer += 10;
|
||||
backgroundtasks();
|
||||
} else {
|
||||
yield();
|
||||
}
|
||||
} else {
|
||||
yield();
|
||||
}
|
||||
@@ -584,6 +602,7 @@ bool count_connection_results(bool success, const String& prefix, int controller
|
||||
}
|
||||
|
||||
bool try_connect_host(int controller_number, WiFiUDP& client, ControllerSettingsStruct& ControllerSettings) {
|
||||
client.setTimeout(ControllerSettings.ClientTimeout);
|
||||
log_connecting_to(F("UDP : "), controller_number, ControllerSettings);
|
||||
bool success = ControllerSettings.beginPacket(client) != 0;
|
||||
return count_connection_results(
|
||||
@@ -593,6 +612,7 @@ bool try_connect_host(int controller_number, WiFiUDP& client, ControllerSettings
|
||||
|
||||
bool try_connect_host(int controller_number, WiFiClient& client, ControllerSettingsStruct& ControllerSettings) {
|
||||
// Use WiFiClient class to create TCP connections
|
||||
client.setTimeout(ControllerSettings.ClientTimeout);
|
||||
log_connecting_to(F("HTTP : "), controller_number, ControllerSettings);
|
||||
bool success = ControllerSettings.connectToHost(client);
|
||||
return count_connection_results(
|
||||
@@ -604,52 +624,61 @@ bool try_connect_host(int controller_number, WiFiClient& client, ControllerSetti
|
||||
// See: https://github.com/esp8266/Arduino/pull/5113
|
||||
// https://github.com/esp8266/Arduino/pull/1829
|
||||
bool client_available(WiFiClient& client) {
|
||||
#ifdef ESP32
|
||||
yield();
|
||||
#else
|
||||
esp_yield(); // Could be called from events
|
||||
#endif
|
||||
return client.available() || client.connected();
|
||||
}
|
||||
|
||||
bool send_via_http(const String& logIdentifier, WiFiClient& client, const String& postStr) {
|
||||
bool success = false;
|
||||
bool send_via_http(const String& logIdentifier, WiFiClient& client, const String& postStr, bool must_check_reply) {
|
||||
bool success = !must_check_reply;
|
||||
// This will send the request to the server
|
||||
client.print(postStr);
|
||||
|
||||
unsigned long timer = millis() + 200;
|
||||
while (!client.available() && !timeOutReached(timer))
|
||||
delay(1);
|
||||
|
||||
// Read all the lines of the reply from server and print them to Serial
|
||||
while (client_available(client) && !success) {
|
||||
// String line = client.readStringUntil('\n');
|
||||
String line;
|
||||
safeReadStringUntil(client, line, '\n');
|
||||
|
||||
if (loglevelActiveFor(LOG_LEVEL_DEBUG_MORE)) {
|
||||
if (line.length() > 80) {
|
||||
addLog(LOG_LEVEL_DEBUG_MORE, line.substring(0, 80));
|
||||
} else {
|
||||
addLog(LOG_LEVEL_DEBUG_MORE, line);
|
||||
}
|
||||
if (must_check_reply) {
|
||||
unsigned long timer = millis() + 200;
|
||||
while (!client_available(client)) {
|
||||
if (timeOutReached(timer)) return false;
|
||||
delay(1);
|
||||
}
|
||||
if (line.startsWith(F("HTTP/1.1 2")))
|
||||
{
|
||||
success = true;
|
||||
if (loglevelActiveFor(LOG_LEVEL_DEBUG)) {
|
||||
String log = F("HTTP : ");
|
||||
log += logIdentifier;
|
||||
log += F(" Success! ");
|
||||
log += line;
|
||||
addLog(LOG_LEVEL_DEBUG, log);
|
||||
|
||||
// Read all the lines of the reply from server and print them to Serial
|
||||
while (client_available(client) && !success) {
|
||||
// String line = client.readStringUntil('\n');
|
||||
String line;
|
||||
safeReadStringUntil(client, line, '\n');
|
||||
|
||||
if (loglevelActiveFor(LOG_LEVEL_DEBUG_MORE)) {
|
||||
if (line.length() > 80) {
|
||||
addLog(LOG_LEVEL_DEBUG_MORE, line.substring(0, 80));
|
||||
} else {
|
||||
addLog(LOG_LEVEL_DEBUG_MORE, line);
|
||||
}
|
||||
}
|
||||
} else if (line.startsWith(F("HTTP/1.1 4"))) {
|
||||
if (loglevelActiveFor(LOG_LEVEL_ERROR)) {
|
||||
String log = F("HTTP : ");
|
||||
log += logIdentifier;
|
||||
log += F(" Error: ");
|
||||
log += line;
|
||||
addLog(LOG_LEVEL_ERROR, log);
|
||||
if (line.startsWith(F("HTTP/1.1 2")))
|
||||
{
|
||||
success = true;
|
||||
if (loglevelActiveFor(LOG_LEVEL_DEBUG)) {
|
||||
String log = F("HTTP : ");
|
||||
log += logIdentifier;
|
||||
log += F(" Success! ");
|
||||
log += line;
|
||||
addLog(LOG_LEVEL_DEBUG, log);
|
||||
}
|
||||
} else if (line.startsWith(F("HTTP/1.1 4"))) {
|
||||
if (loglevelActiveFor(LOG_LEVEL_ERROR)) {
|
||||
String log = F("HTTP : ");
|
||||
log += logIdentifier;
|
||||
log += F(" Error: ");
|
||||
log += line;
|
||||
addLog(LOG_LEVEL_ERROR, log);
|
||||
}
|
||||
addLog(LOG_LEVEL_DEBUG_MORE, postStr);
|
||||
}
|
||||
addLog(LOG_LEVEL_DEBUG_MORE, postStr);
|
||||
yield();
|
||||
}
|
||||
yield();
|
||||
}
|
||||
if (loglevelActiveFor(LOG_LEVEL_DEBUG)) {
|
||||
String log = F("HTTP : ");
|
||||
@@ -663,8 +692,8 @@ bool send_via_http(const String& logIdentifier, WiFiClient& client, const String
|
||||
return success;
|
||||
}
|
||||
|
||||
bool send_via_http(int controller_number, WiFiClient& client, const String& postStr) {
|
||||
return send_via_http(get_formatted_Controller_number(controller_number), client, postStr);
|
||||
bool send_via_http(int controller_number, WiFiClient& client, const String& postStr, bool must_check_reply) {
|
||||
return send_via_http(get_formatted_Controller_number(controller_number), client, postStr, must_check_reply);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+5
-4
@@ -38,8 +38,8 @@ boolean NPlugin_001(byte function, struct EventStruct *event, String& string)
|
||||
//
|
||||
// if (command == F("email"))
|
||||
// {
|
||||
// NotificationSettingsStruct NotificationSettings;
|
||||
// LoadNotificationSettings(event->NotificationIndex, (byte*)&NotificationSettings, sizeof(NotificationSettings));
|
||||
// MakeNotificationSettings(NotificationSettings);
|
||||
// LoadNotificationSettings(event->NotificationIndex, (byte*)&NotificationSettings, sizeof(NotificationSettingsStruct));
|
||||
// NPlugin_001_send(NotificationSettings.Domain, NotificationSettings.Receiver, NotificationSettings.Sender, NotificationSettings.Subject, NotificationSettings.Body, NotificationSettings.Server, NotificationSettings.Port);
|
||||
// success = true;
|
||||
// }
|
||||
@@ -48,8 +48,8 @@ boolean NPlugin_001(byte function, struct EventStruct *event, String& string)
|
||||
|
||||
case NPLUGIN_NOTIFY:
|
||||
{
|
||||
NotificationSettingsStruct NotificationSettings;
|
||||
LoadNotificationSettings(event->NotificationIndex, (byte*)&NotificationSettings, sizeof(NotificationSettings));
|
||||
MakeNotificationSettings(NotificationSettings);
|
||||
LoadNotificationSettings(event->NotificationIndex, (byte*)&NotificationSettings, sizeof(NotificationSettingsStruct));
|
||||
String subject = NotificationSettings.Subject;
|
||||
String body = "";
|
||||
if (event->String1.length() > 0)
|
||||
@@ -73,6 +73,7 @@ boolean NPlugin_001_send(const NotificationSettingsStruct& notificationsettings,
|
||||
|
||||
// Use WiFiClient class to create TCP connections
|
||||
WiFiClient client;
|
||||
client.setTimeout(CONTROLLER_CLIENTTIMEOUT_DFLT);
|
||||
String aHost = notificationsettings.Server;
|
||||
addLog(LOG_LEVEL_DEBUG, String(F("EMAIL: Connecting to ")) + aHost + notificationsettings.Port);
|
||||
if (client.connect(aHost.c_str(), notificationsettings.Port) != 1) {
|
||||
|
||||
@@ -35,8 +35,8 @@ boolean NPlugin_002(byte function, struct EventStruct *event, String& string)
|
||||
//
|
||||
// if (command == F("buzzer"))
|
||||
// {
|
||||
// NotificationSettingsStruct NotificationSettings;
|
||||
// LoadNotificationSettings(event->NotificationIndex, (byte*)&NotificationSettings, sizeof(NotificationSettings));
|
||||
// MakeNotificationSettings(NotificationSettings);
|
||||
// LoadNotificationSettings(event->NotificationIndex, (byte*)&NotificationSettings, sizeof(NotificationSettingsStruct));
|
||||
// success = true;
|
||||
// }
|
||||
// break;
|
||||
@@ -44,8 +44,8 @@ boolean NPlugin_002(byte function, struct EventStruct *event, String& string)
|
||||
|
||||
case NPLUGIN_NOTIFY:
|
||||
{
|
||||
NotificationSettingsStruct NotificationSettings;
|
||||
LoadNotificationSettings(event->NotificationIndex, (byte*)&NotificationSettings, sizeof(NotificationSettings));
|
||||
MakeNotificationSettings(NotificationSettings);
|
||||
LoadNotificationSettings(event->NotificationIndex, (byte*)&NotificationSettings, sizeof(NotificationSettingsStruct));
|
||||
//this reserves IRAM and uninitialized RAM
|
||||
#ifndef ESP32
|
||||
// Buzzer not compatible with ESP32 due to lack of tone command.
|
||||
|
||||
+259
-44
@@ -3,6 +3,31 @@
|
||||
//#################################### Plugin 001: Input Switch #########################################
|
||||
//#######################################################################################################
|
||||
|
||||
/**************************************************\
|
||||
CONFIG
|
||||
TaskDevicePluginConfig settings:
|
||||
0: button type (switch or dimmer)
|
||||
1: dim value
|
||||
2: button option (normal, push high, push low)
|
||||
3: send boot state (true,false)
|
||||
4: use doubleclick (true,false)
|
||||
5: use longpress (true,false)
|
||||
6: LP fired (true,false)
|
||||
7: doubleclick counter (=0,1,2,3)
|
||||
|
||||
TaskDevicePluginConfigFloat settings:
|
||||
0: debounce interval ms
|
||||
1: doubleclick interval ms
|
||||
2: longpress interval ms
|
||||
3:
|
||||
|
||||
TaskDevicePluginConfigLong settings:
|
||||
0: clickTime debounce ms
|
||||
1: clickTime doubleclick ms
|
||||
2: clickTime longpress ms
|
||||
3:
|
||||
\**************************************************/
|
||||
|
||||
#define PLUGIN_001
|
||||
#define PLUGIN_ID_001 1
|
||||
#define PLUGIN_NAME_001 "Switch input - Switch"
|
||||
@@ -18,6 +43,10 @@
|
||||
#define PLUGIN_001_BUTTON_TYPE_NORMAL_SWITCH 0
|
||||
#define PLUGIN_001_BUTTON_TYPE_PUSH_ACTIVE_LOW 1
|
||||
#define PLUGIN_001_BUTTON_TYPE_PUSH_ACTIVE_HIGH 2
|
||||
#define PLUGIN_001_DOUBLECLICK_MIN_INTERVAL 1000
|
||||
#define PLUGIN_001_DOUBLECLICK_MAX_INTERVAL 3000
|
||||
#define PLUGIN_001_LONGPRESS_MIN_INTERVAL 1000
|
||||
#define PLUGIN_001_LONGPRESS_MAX_INTERVAL 5000
|
||||
|
||||
boolean Plugin_001_read_switch_state(struct EventStruct *event) {
|
||||
return digitalRead(Settings.TaskDevicePin1[event->TaskIndex]) == HIGH;
|
||||
@@ -89,6 +118,28 @@ boolean Plugin_001(byte function, struct EventStruct *event, String& string)
|
||||
addFormCheckBox(F("Send Boot state"),F("plugin_001_boot"),
|
||||
Settings.TaskDevicePluginConfig[event->TaskIndex][3]);
|
||||
|
||||
addFormSubHeader(F("Advanced event management"));
|
||||
|
||||
addFormNumericBox(F("De-bounce (ms)"), F("plugin_001_debounce"), round(Settings.TaskDevicePluginConfigFloat[event->TaskIndex][0]), 0, 250);
|
||||
|
||||
//set minimum value for doubleclick MIN max speed
|
||||
if (Settings.TaskDevicePluginConfigFloat[event->TaskIndex][1] < PLUGIN_001_DOUBLECLICK_MIN_INTERVAL)
|
||||
Settings.TaskDevicePluginConfigFloat[event->TaskIndex][1] = PLUGIN_001_DOUBLECLICK_MIN_INTERVAL;
|
||||
|
||||
addFormCheckBox(F("Doubleclick event (3)"), F("plugin_001_dc"), Settings.TaskDevicePluginConfig[event->TaskIndex][4]);
|
||||
addFormNumericBox(F("Doubleclick max. interval (ms)"), F("plugin_001_dcmaxinterval"), round(Settings.TaskDevicePluginConfigFloat[event->TaskIndex][1]), PLUGIN_001_DOUBLECLICK_MIN_INTERVAL, PLUGIN_001_DOUBLECLICK_MAX_INTERVAL);
|
||||
|
||||
//set minimum value for longpress MIN max speed
|
||||
if (Settings.TaskDevicePluginConfigFloat[event->TaskIndex][2] < PLUGIN_001_LONGPRESS_MIN_INTERVAL)
|
||||
Settings.TaskDevicePluginConfigFloat[event->TaskIndex][2] = PLUGIN_001_LONGPRESS_MIN_INTERVAL;
|
||||
|
||||
addFormCheckBox(F("Longpress event (10 & 11)"), F("plugin_001_lp"), Settings.TaskDevicePluginConfig[event->TaskIndex][5]);
|
||||
addFormNumericBox(F("Longpress min. interval (ms)"), F("plugin_001_lpmininterval"), round(Settings.TaskDevicePluginConfigFloat[event->TaskIndex][2]), PLUGIN_001_LONGPRESS_MIN_INTERVAL, PLUGIN_001_LONGPRESS_MAX_INTERVAL);
|
||||
|
||||
//TO-DO: add Extra-Long Press event
|
||||
//addFormCheckBox(F("Extra-Longpress event (20 & 21)"), F("plugin_001_elp"), Settings.TaskDevicePluginConfigLong[event->TaskIndex][1]);
|
||||
//addFormNumericBox(F("Extra-Longpress min. interval (ms)"), F("plugin_001_elpmininterval"), Settings.TaskDevicePluginConfigLong[event->TaskIndex][2], 500, 2000);
|
||||
|
||||
success = true;
|
||||
break;
|
||||
}
|
||||
@@ -105,6 +156,18 @@ boolean Plugin_001(byte function, struct EventStruct *event, String& string)
|
||||
|
||||
Settings.TaskDevicePluginConfig[event->TaskIndex][3] = isFormItemChecked(F("plugin_001_boot"));
|
||||
|
||||
Settings.TaskDevicePluginConfigFloat[event->TaskIndex][0] = getFormItemInt(F("plugin_001_debounce"));
|
||||
|
||||
Settings.TaskDevicePluginConfig[event->TaskIndex][4] = isFormItemChecked(F("plugin_001_dc"));
|
||||
Settings.TaskDevicePluginConfigFloat[event->TaskIndex][1] = getFormItemInt(F("plugin_001_dcmaxinterval"));
|
||||
|
||||
Settings.TaskDevicePluginConfig[event->TaskIndex][5] = isFormItemChecked(F("plugin_001_lp"));
|
||||
Settings.TaskDevicePluginConfigFloat[event->TaskIndex][2] = getFormItemInt(F("plugin_001_lpmininterval"));
|
||||
|
||||
//TO-DO: add Extra-Long Press event
|
||||
//Settings.TaskDevicePluginConfigLong[event->TaskIndex][1] = isFormItemChecked(F("plugin_001_elp"));
|
||||
//Settings.TaskDevicePluginConfigLong[event->TaskIndex][2] = getFormItemInt(F("plugin_001_elpmininterval"));
|
||||
|
||||
success = true;
|
||||
break;
|
||||
}
|
||||
@@ -132,19 +195,48 @@ boolean Plugin_001(byte function, struct EventStruct *event, String& string)
|
||||
switchstate[event->TaskIndex] = !switchstate[event->TaskIndex];
|
||||
outputstate[event->TaskIndex] = !outputstate[event->TaskIndex];
|
||||
}
|
||||
|
||||
// set initial UserVar of the switch
|
||||
if (Settings.TaskDevicePin1Inversed[event->TaskIndex]){
|
||||
UserVar[event->BaseVarIndex] = !switchstate[event->TaskIndex];
|
||||
} else {
|
||||
UserVar[event->BaseVarIndex] = switchstate[event->TaskIndex];
|
||||
}
|
||||
|
||||
// counter = 0
|
||||
Settings.TaskDevicePluginConfig[event->TaskIndex][7]=0;
|
||||
|
||||
//used to track if LP has fired
|
||||
Settings.TaskDevicePluginConfig[event->TaskIndex][6]=false;
|
||||
|
||||
//store millis for debounce, doubleclick and long press
|
||||
Settings.TaskDevicePluginConfigLong[event->TaskIndex][0]=millis(); //debounce timer
|
||||
Settings.TaskDevicePluginConfigLong[event->TaskIndex][1]=millis(); //doubleclick timer
|
||||
Settings.TaskDevicePluginConfigLong[event->TaskIndex][2]=millis(); //longpress timer
|
||||
|
||||
//set minimum value for doubleclick MIN max speed
|
||||
if (Settings.TaskDevicePluginConfigFloat[event->TaskIndex][1] < PLUGIN_001_DOUBLECLICK_MIN_INTERVAL)
|
||||
Settings.TaskDevicePluginConfigFloat[event->TaskIndex][1] = PLUGIN_001_DOUBLECLICK_MIN_INTERVAL;
|
||||
|
||||
//set minimum value for longpress MIN max speed
|
||||
if (Settings.TaskDevicePluginConfigFloat[event->TaskIndex][2] < PLUGIN_001_LONGPRESS_MIN_INTERVAL)
|
||||
Settings.TaskDevicePluginConfigFloat[event->TaskIndex][2] = PLUGIN_001_LONGPRESS_MIN_INTERVAL;
|
||||
|
||||
success = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case PLUGIN_REQUEST:
|
||||
{
|
||||
String device = parseString(string, 1);
|
||||
String command = parseString(string, 2);
|
||||
String strPar1 = parseString(string, 3);
|
||||
if (device == F("gpio") && command == F("pinstate"))
|
||||
//String device = parseString(string, 1);
|
||||
//String command = parseString(string, 2);
|
||||
//String strPar1 = parseString(string, 3);
|
||||
|
||||
// returns pin value using syntax: [plugin#gpio#pinstate#xx]
|
||||
if (string.length()>=13 && string.substring(0,13).equalsIgnoreCase(F("gpio,pinstate")))
|
||||
{
|
||||
int par1;
|
||||
if (validIntFromString(strPar1, par1)) {
|
||||
if (validIntFromString(parseString(string, 3), par1)) {
|
||||
string = digitalRead(par1);
|
||||
}
|
||||
success = true;
|
||||
@@ -161,7 +253,7 @@ boolean Plugin_001(byte function, struct EventStruct *event, String& string)
|
||||
if (PinMonitorState[x] != state){
|
||||
String eventString = F("GPIO#");
|
||||
eventString += x;
|
||||
eventString += F("=");
|
||||
eventString += '=';
|
||||
eventString += state;
|
||||
rulesProcessing(eventString);
|
||||
PinMonitorState[x] = state;
|
||||
@@ -173,51 +265,148 @@ boolean Plugin_001(byte function, struct EventStruct *event, String& string)
|
||||
case PLUGIN_TEN_PER_SECOND:
|
||||
{
|
||||
const boolean state = Plugin_001_read_switch_state(event);
|
||||
|
||||
/**************************************************************************\
|
||||
20181009 - @giig1967g: new doubleclick logic is:
|
||||
if there is a 'state' change, check debounce period.
|
||||
Then if doubleclick interval exceeded, reset Plugin_001_clickCounterDC to 0
|
||||
Plugin_001_clickCounterDC contains the current status for doubleclick:
|
||||
0: start counting
|
||||
1: 1st click
|
||||
2: 2nd click
|
||||
3: 3rd click = doubleclick event if inside interval (calculated as: '3rd click time' minus '1st click time')
|
||||
|
||||
Returned EVENT value is = 3 always for doubleclick
|
||||
In rules this can be checked:
|
||||
on Button#Switch=3 do //will fire if doubleclick
|
||||
\**************************************************************************/
|
||||
|
||||
if (state != switchstate[event->TaskIndex])
|
||||
{
|
||||
switchstate[event->TaskIndex] = state;
|
||||
const boolean currentOutputState = outputstate[event->TaskIndex];
|
||||
boolean new_outputState = currentOutputState;
|
||||
switch(Settings.TaskDevicePluginConfig[event->TaskIndex][2]) {
|
||||
case PLUGIN_001_BUTTON_TYPE_NORMAL_SWITCH:
|
||||
new_outputState = state;
|
||||
break;
|
||||
case PLUGIN_001_BUTTON_TYPE_PUSH_ACTIVE_LOW:
|
||||
if (!state)
|
||||
new_outputState = !currentOutputState;
|
||||
break;
|
||||
case PLUGIN_001_BUTTON_TYPE_PUSH_ACTIVE_HIGH:
|
||||
if (state)
|
||||
new_outputState = !currentOutputState;
|
||||
break;
|
||||
}
|
||||
//reset timer for long press
|
||||
Settings.TaskDevicePluginConfigLong[event->TaskIndex][2]=millis();
|
||||
Settings.TaskDevicePluginConfig[event->TaskIndex][6] = false;
|
||||
|
||||
// send if output needs to be changed
|
||||
if (currentOutputState != new_outputState)
|
||||
const unsigned long debounceTime = timePassedSince(Settings.TaskDevicePluginConfigLong[event->TaskIndex][0]);
|
||||
if (debounceTime >= (unsigned long)lround(Settings.TaskDevicePluginConfigFloat[event->TaskIndex][0])) //de-bounce check
|
||||
{
|
||||
outputstate[event->TaskIndex] = new_outputState;
|
||||
boolean sendState = new_outputState;
|
||||
if (Settings.TaskDevicePin1Inversed[event->TaskIndex])
|
||||
sendState = !sendState;
|
||||
|
||||
byte output_value = sendState ? 1 : 0;
|
||||
event->sensorType = SENSOR_TYPE_SWITCH;
|
||||
if (P001_getSwitchType(event) == PLUGIN_001_TYPE_DIMMER) {
|
||||
if (sendState) {
|
||||
output_value = Settings.TaskDevicePluginConfig[event->TaskIndex][1];
|
||||
// Only set type to being dimmer when setting a value else it is "switched off".
|
||||
event->sensorType = SENSOR_TYPE_DIMMER;
|
||||
}
|
||||
const unsigned long deltaDC = timePassedSince(Settings.TaskDevicePluginConfigLong[event->TaskIndex][1]);
|
||||
if (deltaDC >= (unsigned long)lround(Settings.TaskDevicePluginConfigFloat[event->TaskIndex][1]))
|
||||
{
|
||||
//reset timer for doubleclick
|
||||
Settings.TaskDevicePluginConfig[event->TaskIndex][7]=0;
|
||||
Settings.TaskDevicePluginConfigLong[event->TaskIndex][1]=millis();
|
||||
}
|
||||
UserVar[event->BaseVarIndex] = output_value;
|
||||
String log = F("SW : Switch state ");
|
||||
log += state ? F("1") : F("0");
|
||||
log += F(" Output value ");
|
||||
log += output_value;
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
sendData(event);
|
||||
Settings.TaskDevicePluginConfig[event->TaskIndex][7]++;
|
||||
|
||||
switchstate[event->TaskIndex] = state;
|
||||
const boolean currentOutputState = outputstate[event->TaskIndex];
|
||||
boolean new_outputState = currentOutputState;
|
||||
switch(Settings.TaskDevicePluginConfig[event->TaskIndex][2])
|
||||
{
|
||||
case PLUGIN_001_BUTTON_TYPE_NORMAL_SWITCH:
|
||||
new_outputState = state;
|
||||
break;
|
||||
case PLUGIN_001_BUTTON_TYPE_PUSH_ACTIVE_LOW:
|
||||
if (!state)
|
||||
new_outputState = !currentOutputState;
|
||||
break;
|
||||
case PLUGIN_001_BUTTON_TYPE_PUSH_ACTIVE_HIGH:
|
||||
if (state)
|
||||
new_outputState = !currentOutputState;
|
||||
break;
|
||||
}
|
||||
|
||||
// send if output needs to be changed
|
||||
if (currentOutputState != new_outputState)
|
||||
{
|
||||
byte output_value;
|
||||
outputstate[event->TaskIndex] = new_outputState;
|
||||
boolean sendState = new_outputState;
|
||||
if (Settings.TaskDevicePin1Inversed[event->TaskIndex])
|
||||
sendState = !sendState;
|
||||
|
||||
if (Settings.TaskDevicePluginConfig[event->TaskIndex][7]==3 && Settings.TaskDevicePluginConfig[event->TaskIndex][4])
|
||||
{
|
||||
output_value = 3; //double click
|
||||
} else {
|
||||
output_value = sendState ? 1 : 0; //single click
|
||||
}
|
||||
event->sensorType = SENSOR_TYPE_SWITCH;
|
||||
if (P001_getSwitchType(event) == PLUGIN_001_TYPE_DIMMER) {
|
||||
if (sendState) {
|
||||
output_value = Settings.TaskDevicePluginConfig[event->TaskIndex][1];
|
||||
// Only set type to being dimmer when setting a value else it is "switched off".
|
||||
event->sensorType = SENSOR_TYPE_DIMMER;
|
||||
}
|
||||
}
|
||||
UserVar[event->BaseVarIndex] = output_value;
|
||||
String log = F("SW : Switch state ");
|
||||
log += state ? '1' : '0';
|
||||
log += F(" Output value ");
|
||||
log += output_value;
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
sendData(event);
|
||||
}
|
||||
Settings.TaskDevicePluginConfigLong[event->TaskIndex][0] = millis();
|
||||
}
|
||||
}
|
||||
//check if LP is enabled and if LP has not fired yet
|
||||
else if (Settings.TaskDevicePluginConfig[event->TaskIndex][5] && !Settings.TaskDevicePluginConfig[event->TaskIndex][6]) {
|
||||
/**************************************************************************\
|
||||
20181009 - @giig1967g: new longpress logic is:
|
||||
if there is no 'state' change, check if longpress interval reached
|
||||
When reached send longpress event.
|
||||
Returned Event value = state + 10
|
||||
So if state = 0 => EVENT longpress = 10
|
||||
if state = 1 => EVENT longpress = 11
|
||||
So we can trigger longpress for high or low contact
|
||||
|
||||
In rules this can be checked:
|
||||
on Button#Switch=10 do //will fire if longpress when state = 0
|
||||
on Button#Switch=11 do //will fire if longpress when state = 1
|
||||
\**************************************************************************/
|
||||
const unsigned long deltaLP = timePassedSince(Settings.TaskDevicePluginConfigLong[event->TaskIndex][2]);
|
||||
if (deltaLP >= (unsigned long)lround(Settings.TaskDevicePluginConfigFloat[event->TaskIndex][2]))
|
||||
{
|
||||
byte output_value;
|
||||
byte needToSendEvent = false;
|
||||
|
||||
Settings.TaskDevicePluginConfig[event->TaskIndex][6] = true;
|
||||
|
||||
switch(Settings.TaskDevicePluginConfig[event->TaskIndex][2])
|
||||
{
|
||||
case PLUGIN_001_BUTTON_TYPE_NORMAL_SWITCH:
|
||||
needToSendEvent = true;
|
||||
break;
|
||||
case PLUGIN_001_BUTTON_TYPE_PUSH_ACTIVE_LOW:
|
||||
if (!state)
|
||||
needToSendEvent = true;
|
||||
break;
|
||||
case PLUGIN_001_BUTTON_TYPE_PUSH_ACTIVE_HIGH:
|
||||
if (state)
|
||||
needToSendEvent = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (needToSendEvent) {
|
||||
boolean sendState = state;
|
||||
if (Settings.TaskDevicePin1Inversed[event->TaskIndex])
|
||||
sendState = !sendState;
|
||||
output_value = sendState ? 1 : 0;
|
||||
output_value = output_value + 10;
|
||||
|
||||
UserVar[event->BaseVarIndex] = output_value;
|
||||
String log = F("SW : LongPress: Switch state ");
|
||||
log += state ? '1' : '0';
|
||||
log += F(" Output value ");
|
||||
log += output_value;
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
sendData(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
success = true;
|
||||
break;
|
||||
}
|
||||
@@ -257,6 +446,32 @@ boolean Plugin_001(byte function, struct EventStruct *event, String& string)
|
||||
}
|
||||
}
|
||||
|
||||
if (command == F("gpiotoggle"))
|
||||
{
|
||||
success = true;
|
||||
byte mode;
|
||||
uint16_t currentState;
|
||||
|
||||
if (event->Par1 >= 0 && event->Par1 <= PIN_D_MAX)
|
||||
{
|
||||
if (hasPinState(PLUGIN_ID_001,event->Par1)) {
|
||||
getPinState(PLUGIN_ID_001, event->Par1, &mode, ¤tState);
|
||||
} else {
|
||||
currentState = (digitalRead(event->Par1) == HIGH);
|
||||
mode = PIN_MODE_OUTPUT;
|
||||
}
|
||||
|
||||
if (mode != PIN_MODE_INPUT) { //toggle only output pins
|
||||
pinMode(event->Par1, OUTPUT);
|
||||
digitalWrite(event->Par1, !currentState);
|
||||
setPinState(PLUGIN_ID_001, event->Par1, PIN_MODE_OUTPUT, !currentState);
|
||||
log = String(F("SW : Toggle GPIO ")) + String(event->Par1) + String(F(" Set to ")) + String(!currentState);
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
SendStatus(event->Source, getPinStateJSON(SEARCH_PIN_STATE, PLUGIN_ID_001, event->Par1, log, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (command == F("pwm"))
|
||||
{
|
||||
success = true;
|
||||
|
||||
@@ -90,7 +90,7 @@ boolean Plugin_004(byte function, struct EventStruct * event, String& string)
|
||||
resolutionChoice = Plugin_004_DS_getResolution(savedAddress);
|
||||
else
|
||||
resolutionChoice = 9;
|
||||
String resultsOptions[4] = { "9", "10", "11", "12" };
|
||||
String resultsOptions[4] = { F("9"), F("10"), F("11"), F("12") };
|
||||
int resultsOptionValues[4] = { 9, 10, 11, 12 };
|
||||
addFormSelector(F("Device Resolution"), F("plugin_004_res"), 4, resultsOptions, resultsOptionValues, resolutionChoice);
|
||||
addHtml(F(" Bit"));
|
||||
@@ -105,7 +105,6 @@ boolean Plugin_004(byte function, struct EventStruct * event, String& string)
|
||||
|
||||
// save the address for selected device and store into extra tasksettings
|
||||
Plugin_004_DallasPin = Settings.TaskDevicePin1[event->TaskIndex];
|
||||
// byte devCount =
|
||||
if (Plugin_004_DallasPin != -1){
|
||||
Plugin_004_DS_scan(getFormItemInt(F("plugin_004_dev")), addr);
|
||||
for (byte x = 0; x < 8; x++)
|
||||
@@ -124,11 +123,12 @@ boolean Plugin_004(byte function, struct EventStruct * event, String& string)
|
||||
{
|
||||
if (x != 0)
|
||||
string += "-";
|
||||
// string += String(ExtraTaskSettings.TaskDevicePluginConfigLong[x], HEX);
|
||||
string += String(ExtraTaskSettings.TaskDevicePluginConfigLong[x], HEX);
|
||||
}
|
||||
success = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case PLUGIN_INIT:
|
||||
{
|
||||
Plugin_004_DallasPin = Settings.TaskDevicePin1[event->TaskIndex];
|
||||
@@ -169,7 +169,7 @@ boolean Plugin_004(byte function, struct EventStruct * event, String& string)
|
||||
for (byte x = 0; x < 8; x++)
|
||||
{
|
||||
if (x != 0)
|
||||
log += "-";
|
||||
log += '-';
|
||||
log += String(ExtraTaskSettings.TaskDevicePluginConfigLong[x], HEX);
|
||||
}
|
||||
|
||||
|
||||
+142
-116
@@ -9,6 +9,19 @@
|
||||
#define PLUGIN_VALUENAME1_005 "Temperature"
|
||||
#define PLUGIN_VALUENAME2_005 "Humidity"
|
||||
|
||||
#define P005_DHT11 11
|
||||
#define P005_DHT12 12
|
||||
#define P005_DHT22 22
|
||||
#define P005_AM2301 23
|
||||
#define P005_SI7021 70
|
||||
|
||||
#define P005_error_no_reading 1
|
||||
#define P005_error_protocol_timeout 2
|
||||
#define P005_error_checksum_error 3
|
||||
#define P005_error_invalid_NAN_reading 4
|
||||
#define P005_info_temperature 5
|
||||
#define P005_info_humidity 6
|
||||
|
||||
uint8_t Plugin_005_DHT_Pin;
|
||||
|
||||
boolean Plugin_005(byte function, struct EventStruct *event, String& string)
|
||||
@@ -49,7 +62,7 @@ boolean Plugin_005(byte function, struct EventStruct *event, String& string)
|
||||
case PLUGIN_WEBFORM_LOAD:
|
||||
{
|
||||
const String options[] = { F("DHT 11"), F("DHT 22"), F("DHT 12"), F("Sonoff am2301"), F("Sonoff si7021") };
|
||||
int indices[] = { 11, 22, 12, 23, 70 };
|
||||
int indices[] = { P005_DHT11, P005_DHT22, P005_DHT12, P005_AM2301, P005_SI7021 };
|
||||
|
||||
addFormSelector(F("DHT Type"), F("plugin_005_dhttype"), 5, options, indices, Settings.TaskDevicePluginConfig[event->TaskIndex][0] );
|
||||
|
||||
@@ -67,92 +80,7 @@ boolean Plugin_005(byte function, struct EventStruct *event, String& string)
|
||||
|
||||
case PLUGIN_READ:
|
||||
{
|
||||
byte dht_dat[5];
|
||||
byte i;
|
||||
boolean error = false;
|
||||
|
||||
byte Par3 = Settings.TaskDevicePluginConfig[event->TaskIndex][0];
|
||||
Plugin_005_DHT_Pin = Settings.TaskDevicePin1[event->TaskIndex];
|
||||
|
||||
pinMode(Plugin_005_DHT_Pin, OUTPUT);
|
||||
digitalWrite(Plugin_005_DHT_Pin, LOW); // Pull low
|
||||
if(Par3 == 11 || Par3 == 22 || Par3 == 12) delay(18);
|
||||
else if (Par3 == 23 ) delayMicroseconds(900);
|
||||
else if (Par3 == 70 ) delayMicroseconds(500);
|
||||
pinMode(Plugin_005_DHT_Pin, INPUT); // change pin to input
|
||||
delayMicroseconds(50);
|
||||
|
||||
error = waitState(0);
|
||||
if(error)
|
||||
{ logError(event, F("DHT : no Reading !"));
|
||||
break;
|
||||
}
|
||||
error = waitState(1);
|
||||
if(error)
|
||||
{ logError(event, F("DHT : no Reading !"));
|
||||
break;
|
||||
}
|
||||
noInterrupts();
|
||||
error = waitState(0);
|
||||
if(error)
|
||||
{ logError(event, F("DHT : no Reading !"));
|
||||
break;
|
||||
}
|
||||
for (i = 0; i < 5; i++)
|
||||
{
|
||||
byte data = Plugin_005_read_dht_dat();
|
||||
if(data == -1)
|
||||
{ logError(event, F("DHT : protocol timeout!"));
|
||||
break;
|
||||
}
|
||||
dht_dat[i] = data;
|
||||
}
|
||||
interrupts();
|
||||
|
||||
// Checksum calculation is a Rollover Checksum by design!
|
||||
byte dht_check_sum = (dht_dat[0] + dht_dat[1] + dht_dat[2] + dht_dat[3]) & 0xFF; // check check_sum
|
||||
if (dht_dat[4] != dht_check_sum)
|
||||
{
|
||||
logError(event, F("DHT : checksum error!"));
|
||||
break;
|
||||
}
|
||||
|
||||
float temperature = NAN;
|
||||
float humidity = NAN;
|
||||
if (Par3 == 11)
|
||||
{
|
||||
temperature = float(dht_dat[2]); // Temperature
|
||||
humidity = float(dht_dat[0]); // Humidity
|
||||
}
|
||||
else if (Par3 == 12)
|
||||
{
|
||||
temperature = float(dht_dat[2]*10 + (dht_dat[3] & 0x7f)) / 10.0; // Temperature
|
||||
if (dht_dat[3] & 0x80) { temperature = -temperature; } // Negative temperature
|
||||
humidity = float(dht_dat[0]*10+dht_dat[1]) / 10.0; // Humidity
|
||||
}
|
||||
else if (Par3 == 22 || Par3 == 23 || Par3 == 70)
|
||||
{
|
||||
if (dht_dat[2] & 0x80) // negative temperature
|
||||
temperature = -0.1 * word(dht_dat[2] & 0x7F, dht_dat[3]);
|
||||
else
|
||||
temperature = 0.1 * word(dht_dat[2], dht_dat[3]);
|
||||
humidity = 0.1 * word(dht_dat[0], dht_dat[1]); // Humidity
|
||||
}
|
||||
|
||||
if (temperature == NAN || humidity == NAN)
|
||||
{ logError(event, F("DHT : invalid NAN reading !"));
|
||||
break;
|
||||
}
|
||||
|
||||
UserVar[event->BaseVarIndex] = temperature;
|
||||
UserVar[event->BaseVarIndex + 1] = humidity;
|
||||
String log = F("DHT : Temperature: ");
|
||||
log += UserVar[event->BaseVarIndex];
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
log = F("DHT : Humidity: ");
|
||||
log += UserVar[event->BaseVarIndex + 1];
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
success = true;
|
||||
success = P005_do_plugin_read(event);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -163,28 +91,144 @@ boolean Plugin_005(byte function, struct EventStruct *event, String& string)
|
||||
/*********************************************************************************************\
|
||||
* DHT sub to log an error
|
||||
\*********************************************************************************************/
|
||||
void logError(struct EventStruct *event, String text)
|
||||
void P005_log(struct EventStruct *event, int logNr)
|
||||
{
|
||||
bool isError = true;
|
||||
String text = F("DHT : ");
|
||||
switch (logNr) {
|
||||
case P005_error_no_reading: text += F("No Reading"); break;
|
||||
case P005_error_protocol_timeout: text += F("Protocol Timeout"); break;
|
||||
case P005_error_checksum_error: text += F("Checksum Error"); break;
|
||||
case P005_error_invalid_NAN_reading: text += F("Invalid NAN reading"); break;
|
||||
case P005_info_temperature:
|
||||
text += F("Temperature: ");
|
||||
text += UserVar[event->BaseVarIndex];
|
||||
isError = false;
|
||||
break;
|
||||
case P005_info_humidity:
|
||||
text += F("Humidity: ");
|
||||
text += UserVar[event->BaseVarIndex + 1];
|
||||
isError = false;
|
||||
break;
|
||||
}
|
||||
addLog(LOG_LEVEL_INFO, text);
|
||||
UserVar[event->BaseVarIndex] = NAN;
|
||||
UserVar[event->BaseVarIndex + 1] = NAN;
|
||||
if (isError) {
|
||||
UserVar[event->BaseVarIndex] = NAN;
|
||||
UserVar[event->BaseVarIndex + 1] = NAN;
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************************************\
|
||||
* DHT sub to wait until a pin is in a certiin state
|
||||
* DHT sub to wait until a pin is in a certain state
|
||||
\*********************************************************************************************/
|
||||
boolean waitState(int state)
|
||||
boolean P005_waitState(int state)
|
||||
{
|
||||
byte counter = 0;
|
||||
while (( digitalRead(Plugin_005_DHT_Pin) != state) && (counter < 100))
|
||||
unsigned long timeout = micros() + 100;
|
||||
while (digitalRead(Plugin_005_DHT_Pin) != state)
|
||||
{
|
||||
if (usecTimeOutReached(timeout)) return false;
|
||||
delayMicroseconds(1);
|
||||
counter++;
|
||||
}
|
||||
if( counter < 100) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Perform the actual reading + interpreting of data.
|
||||
\*********************************************************************************************/
|
||||
bool P005_do_plugin_read(struct EventStruct *event) {
|
||||
byte i;
|
||||
|
||||
byte Par3 = Settings.TaskDevicePluginConfig[event->TaskIndex][0];
|
||||
Plugin_005_DHT_Pin = Settings.TaskDevicePin1[event->TaskIndex];
|
||||
|
||||
pinMode(Plugin_005_DHT_Pin, OUTPUT);
|
||||
digitalWrite(Plugin_005_DHT_Pin, LOW); // Pull low
|
||||
switch (Par3) {
|
||||
case P005_DHT11:
|
||||
case P005_DHT22:
|
||||
case P005_DHT12: delay(18); break; // FIXME TD-er: Must this be so long?
|
||||
case P005_AM2301: delayMicroseconds(900); break;
|
||||
case P005_SI7021: delayMicroseconds(500); break;
|
||||
}
|
||||
switch (Par3) {
|
||||
case P005_DHT11:
|
||||
case P005_DHT22:
|
||||
case P005_DHT12:
|
||||
case P005_AM2301:
|
||||
pinMode(Plugin_005_DHT_Pin, INPUT);
|
||||
delayMicroseconds(50);
|
||||
break;
|
||||
case P005_SI7021:
|
||||
// See: https://github.com/letscontrolit/ESPEasy/issues/1798
|
||||
digitalWrite(Plugin_005_DHT_Pin, HIGH);
|
||||
delayMicroseconds(20);
|
||||
pinMode(Plugin_005_DHT_Pin, INPUT);
|
||||
break;
|
||||
}
|
||||
if(!P005_waitState(0)) {P005_log(event, P005_error_no_reading); return false; }
|
||||
if(!P005_waitState(1)) {P005_log(event, P005_error_no_reading); return false; }
|
||||
noInterrupts();
|
||||
if(!P005_waitState(0)) {P005_log(event, P005_error_no_reading); return false; }
|
||||
bool readingAborted = false;
|
||||
byte dht_dat[5];
|
||||
for (i = 0; i < 5 && !readingAborted; i++)
|
||||
{
|
||||
byte data = Plugin_005_read_dht_dat();
|
||||
if(data == -1)
|
||||
{ P005_log(event, P005_error_protocol_timeout);
|
||||
readingAborted = true;
|
||||
}
|
||||
dht_dat[i] = data;
|
||||
}
|
||||
interrupts();
|
||||
if (readingAborted)
|
||||
return false;
|
||||
|
||||
// Checksum calculation is a Rollover Checksum by design!
|
||||
byte dht_check_sum = (dht_dat[0] + dht_dat[1] + dht_dat[2] + dht_dat[3]) & 0xFF; // check check_sum
|
||||
if (dht_dat[4] != dht_check_sum)
|
||||
{
|
||||
P005_log(event, P005_error_checksum_error);
|
||||
return false;
|
||||
}
|
||||
|
||||
float temperature = NAN;
|
||||
float humidity = NAN;
|
||||
switch (Par3) {
|
||||
case P005_DHT11:
|
||||
temperature = float(dht_dat[2]); // Temperature
|
||||
humidity = float(dht_dat[0]); // Humidity
|
||||
break;
|
||||
case P005_DHT12:
|
||||
temperature = float(dht_dat[2]*10 + (dht_dat[3] & 0x7f)) / 10.0; // Temperature
|
||||
if (dht_dat[3] & 0x80) { temperature = -temperature; } // Negative temperature
|
||||
humidity = float(dht_dat[0]*10+dht_dat[1]) / 10.0; // Humidity
|
||||
break;
|
||||
case P005_DHT22:
|
||||
case P005_AM2301:
|
||||
case P005_SI7021:
|
||||
if (dht_dat[2] & 0x80) // negative temperature
|
||||
temperature = -0.1 * word(dht_dat[2] & 0x7F, dht_dat[3]);
|
||||
else
|
||||
temperature = 0.1 * word(dht_dat[2], dht_dat[3]);
|
||||
humidity = 0.1 * word(dht_dat[0], dht_dat[1]); // Humidity
|
||||
break;
|
||||
}
|
||||
|
||||
if (temperature == NAN || humidity == NAN)
|
||||
{ P005_log(event, P005_error_invalid_NAN_reading);
|
||||
return false;
|
||||
}
|
||||
|
||||
UserVar[event->BaseVarIndex] = temperature;
|
||||
UserVar[event->BaseVarIndex + 1] = humidity;
|
||||
P005_log(event, P005_info_temperature);
|
||||
P005_log(event, P005_info_humidity);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*********************************************************************************************\
|
||||
* DHT sub to get an 8 bit value from the receiving bitstream
|
||||
\*********************************************************************************************/
|
||||
@@ -192,31 +236,13 @@ int Plugin_005_read_dht_dat(void)
|
||||
{
|
||||
byte i = 0;
|
||||
byte result = 0;
|
||||
byte counter = 0;
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
while ((!digitalRead(Plugin_005_DHT_Pin)) && (counter < 100))
|
||||
{
|
||||
delayMicroseconds(1);
|
||||
counter++;
|
||||
}
|
||||
if (counter >= 100)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if (!P005_waitState(1)) return -1;
|
||||
delayMicroseconds(35); // was 30
|
||||
if (digitalRead(Plugin_005_DHT_Pin))
|
||||
result |= (1 << (7 - i));
|
||||
counter = 0;
|
||||
while ((digitalRead(Plugin_005_DHT_Pin)) && (counter < 100))
|
||||
{
|
||||
delayMicroseconds(1);
|
||||
counter++;
|
||||
}
|
||||
if (counter >= 100)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if (!P005_waitState(0)) return -1;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
+41
-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;
|
||||
@@ -109,6 +109,24 @@ boolean Plugin_009(byte function, struct EventStruct *event, String& string)
|
||||
break;
|
||||
}
|
||||
|
||||
case PLUGIN_REQUEST:
|
||||
{
|
||||
//parseString(string, 1) = device
|
||||
//parseString(string, 2) = command
|
||||
//parseString(string, 3) = gpio number
|
||||
|
||||
// returns pin value using syntax: [plugin#mcpgpio#pinstate#xx]
|
||||
if (string.length()>=16 && string.substring(0,16).equalsIgnoreCase(F("mcpgpio,pinstate")))
|
||||
{
|
||||
int par1;
|
||||
if (validIntFromString(parseString(string, 3), par1)) {
|
||||
string = Plugin_009_Read(par1);
|
||||
}
|
||||
success = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case PLUGIN_WRITE:
|
||||
{
|
||||
String log = "";
|
||||
@@ -124,6 +142,28 @@ boolean Plugin_009(byte function, struct EventStruct *event, String& string)
|
||||
SendStatus(event->Source, getPinStateJSON(SEARCH_PIN_STATE, PLUGIN_ID_009, event->Par1, log, 0));
|
||||
}
|
||||
|
||||
if (command == F("mcpgpiotoggle"))
|
||||
{
|
||||
success = true;
|
||||
byte mode;
|
||||
uint16_t currentState;
|
||||
|
||||
if (hasPinState(PLUGIN_ID_009,event->Par1)) {
|
||||
getPinState(PLUGIN_ID_009, event->Par1, &mode, ¤tState);
|
||||
} else {
|
||||
currentState = Plugin_009_Read(event->Par1);
|
||||
mode = PIN_MODE_OUTPUT;
|
||||
}
|
||||
|
||||
if (mode != PIN_MODE_INPUT) {
|
||||
setPinState(PLUGIN_ID_009, event->Par1, PIN_MODE_OUTPUT, !currentState);
|
||||
Plugin_009_Write(event->Par1, !currentState);
|
||||
log = String(F("MCP : Toggle GPIO ")) + String(event->Par1) + String(F(" Set to ")) + String(!currentState);
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
SendStatus(event->Source, getPinStateJSON(SEARCH_PIN_STATE, PLUGIN_ID_009, event->Par1, log, 0));
|
||||
}
|
||||
}
|
||||
|
||||
if (command == F("mcppulse"))
|
||||
{
|
||||
success = true;
|
||||
|
||||
+17
-12
@@ -21,6 +21,9 @@ int Plugin_012_mode = 1;
|
||||
#define PLUGIN_NAME_012 "Display - LCD2004"
|
||||
#define PLUGIN_VALUENAME1_012 "LCD"
|
||||
|
||||
#define P12_Nlines 4 // The number of different lines which can be displayed
|
||||
#define P12_Nchars 80
|
||||
|
||||
boolean Plugin_012(byte function, struct EventStruct *event, String& string)
|
||||
{
|
||||
boolean success = false;
|
||||
@@ -81,9 +84,9 @@ boolean Plugin_012(byte function, struct EventStruct *event, String& string)
|
||||
addFormSelector(F("Display Size"), F("plugin_012_size"), 2, options2, optionValues2, choice2);
|
||||
|
||||
|
||||
char deviceTemplate[4][80];
|
||||
char deviceTemplate[P12_Nlines][P12_Nchars];
|
||||
LoadCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate));
|
||||
for (byte varNr = 0; varNr < 4; varNr++)
|
||||
for (byte varNr = 0; varNr < P12_Nlines; varNr++)
|
||||
{
|
||||
addHtml(F("<TR><TD>Line "));
|
||||
addHtml(String(varNr + 1));
|
||||
@@ -122,17 +125,19 @@ boolean Plugin_012(byte function, struct EventStruct *event, String& string)
|
||||
Settings.TaskDevicePluginConfig[event->TaskIndex][2] = getFormItemInt(F("plugin_12_timer"));
|
||||
Settings.TaskDevicePluginConfig[event->TaskIndex][3] = getFormItemInt(F("plugin_012_mode"));
|
||||
|
||||
char deviceTemplate[4][80];
|
||||
for (byte varNr = 0; varNr < 4; varNr++)
|
||||
char deviceTemplate[P12_Nlines][P12_Nchars];
|
||||
String error;
|
||||
for (byte varNr = 0; varNr < P12_Nlines; varNr++)
|
||||
{
|
||||
char argc[25];
|
||||
String arg = F("Plugin_012_template");
|
||||
arg += varNr + 1;
|
||||
arg.toCharArray(argc, 25);
|
||||
String tmpString = WebServer.arg(argc);
|
||||
strncpy(deviceTemplate[varNr], tmpString.c_str(), sizeof(deviceTemplate[varNr]));
|
||||
String argName = F("Plugin_012_template");
|
||||
argName += varNr + 1;
|
||||
if (!safe_strncpy(deviceTemplate[varNr], WebServer.arg(argName), P12_Nchars)) {
|
||||
error += getCustomTaskSettingsError(varNr);
|
||||
}
|
||||
}
|
||||
if (error.length() > 0) {
|
||||
addHtmlError(error);
|
||||
}
|
||||
|
||||
SaveCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate));
|
||||
success = true;
|
||||
break;
|
||||
@@ -194,7 +199,7 @@ boolean Plugin_012(byte function, struct EventStruct *event, String& string)
|
||||
|
||||
case PLUGIN_READ:
|
||||
{
|
||||
char deviceTemplate[4][80];
|
||||
char deviceTemplate[P12_Nlines][P12_Nchars];
|
||||
LoadCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate));
|
||||
|
||||
for (byte x = 0; x < Plugin_012_rows; x++)
|
||||
|
||||
+199
-58
@@ -12,27 +12,21 @@
|
||||
#include <map>
|
||||
#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;
|
||||
// PlugIn specific defines
|
||||
// operatingMode
|
||||
#define OPMODE_VALUE (0)
|
||||
#define OPMODE_STATE (1)
|
||||
|
||||
// measuringUnit
|
||||
#define UNIT_CM (0)
|
||||
#define UNIT_INCH (1)
|
||||
|
||||
// filterType
|
||||
#define FILTER_NONE (0)
|
||||
#define FILTER_MEDIAN (1)
|
||||
|
||||
// map of sensors
|
||||
std::map<unsigned int, std::shared_ptr<NewPingESP8266> > P_013_sensordefs;
|
||||
|
||||
boolean Plugin_013(byte function, struct EventStruct *event, String& string)
|
||||
{
|
||||
@@ -54,6 +48,7 @@ boolean Plugin_013(byte function, struct EventStruct *event, String& string)
|
||||
Device[deviceCount].SendDataOption = true;
|
||||
Device[deviceCount].TimerOption = true;
|
||||
Device[deviceCount].GlobalSyncOption = true;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -72,19 +67,51 @@ boolean Plugin_013(byte function, struct EventStruct *event, String& string)
|
||||
|
||||
case PLUGIN_WEBFORM_LOAD:
|
||||
{
|
||||
byte choice = Settings.TaskDevicePluginConfig[event->TaskIndex][0];
|
||||
String options[2];
|
||||
options[0] = F("Value");
|
||||
options[1] = F("State");
|
||||
int optionValues[2] = { 1, 2 };
|
||||
addFormSelector(F("Mode"), F("plugin_013_mode"), 2, options, optionValues, choice);
|
||||
int16_t operatingMode = Settings.TaskDevicePluginConfig[event->TaskIndex][0];
|
||||
int16_t threshold = Settings.TaskDevicePluginConfig[event->TaskIndex][1];
|
||||
int16_t max_distance = Settings.TaskDevicePluginConfig[event->TaskIndex][2];
|
||||
int16_t measuringUnit = Settings.TaskDevicePluginConfig[event->TaskIndex][3];
|
||||
int16_t filterType = Settings.TaskDevicePluginConfig[event->TaskIndex][4];
|
||||
int16_t filterSize = Settings.TaskDevicePluginConfig[event->TaskIndex][5];
|
||||
|
||||
if (Settings.TaskDevicePluginConfig[event->TaskIndex][0] == 2)
|
||||
{
|
||||
addFormNumericBox(F("Threshold"), F("plugin_013_threshold"), Settings.TaskDevicePluginConfig[event->TaskIndex][1]);
|
||||
// default filtersize = 5
|
||||
if (filterSize == 0) {
|
||||
filterSize = 5;
|
||||
Settings.TaskDevicePluginConfig[event->TaskIndex][5] = filterSize;
|
||||
}
|
||||
addFormNumericBox(F("Max Distance"), F("plugin_013_max_distance"), Settings.TaskDevicePluginConfig[event->TaskIndex][2], 0, 500);
|
||||
addUnit(F("cm"));
|
||||
|
||||
|
||||
String strUnit = (measuringUnit == UNIT_CM) ? F("cm") : F("inch");
|
||||
|
||||
String optionsOpMode[2];
|
||||
int optionValuesOpMode[2] = { 0, 1 };
|
||||
optionsOpMode[0] = F("Value");
|
||||
optionsOpMode[1] = F("State");
|
||||
addFormSelector(F("Mode"), F("plugin_013_mode"), 2, optionsOpMode, optionValuesOpMode, operatingMode);
|
||||
|
||||
if (operatingMode == OPMODE_STATE)
|
||||
{
|
||||
addFormNumericBox(F("Threshold"), F("plugin_013_threshold"), threshold);
|
||||
addUnit(strUnit);
|
||||
}
|
||||
addFormNumericBox(F("Max Distance"), F("plugin_013_max_distance"), max_distance, 0, 500);
|
||||
addUnit(strUnit);
|
||||
|
||||
String optionsUnit[2];
|
||||
int optionValuesUnit[2] = { 0, 1 };
|
||||
optionsUnit[0] = F("Metric");
|
||||
optionsUnit[1] = F("Imperial");
|
||||
addFormSelector(F("Unit"), F("plugin_013_Unit"), 2, optionsUnit, optionValuesUnit, measuringUnit);
|
||||
|
||||
String optionsFilter[2];
|
||||
int optionValuesFilter[2] = { 0, 1 };
|
||||
optionsFilter[0] = F("None");
|
||||
optionsFilter[1] = F("Median");
|
||||
addFormSelector(F("Filter"), F("plugin_013_FilterType"), 2, optionsFilter, optionValuesFilter, filterType);
|
||||
|
||||
// enable filtersize option if filter is used,
|
||||
if (filterType != FILTER_NONE)
|
||||
addFormNumericBox(F("Filter size"), F("plugin_013_FilterSize"), filterSize, 2, 20);
|
||||
|
||||
success = true;
|
||||
break;
|
||||
@@ -92,33 +119,60 @@ boolean Plugin_013(byte function, struct EventStruct *event, String& string)
|
||||
|
||||
case PLUGIN_WEBFORM_SAVE:
|
||||
{
|
||||
int16_t operatingMode = Settings.TaskDevicePluginConfig[event->TaskIndex][0];
|
||||
int16_t filterType = Settings.TaskDevicePluginConfig[event->TaskIndex][4];
|
||||
|
||||
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = getFormItemInt(F("plugin_013_mode"));
|
||||
if (Settings.TaskDevicePluginConfig[event->TaskIndex][0] == 2)
|
||||
{
|
||||
if (operatingMode == OPMODE_STATE)
|
||||
Settings.TaskDevicePluginConfig[event->TaskIndex][1] = getFormItemInt(F("plugin_013_threshold"));
|
||||
}
|
||||
Settings.TaskDevicePluginConfig[event->TaskIndex][2] = getFormItemInt(F("plugin_013_max_distance"));
|
||||
|
||||
Settings.TaskDevicePluginConfig[event->TaskIndex][3] = getFormItemInt(F("plugin_013_Unit"));
|
||||
Settings.TaskDevicePluginConfig[event->TaskIndex][4] = getFormItemInt(F("plugin_013_FilterType"));
|
||||
if (filterType != FILTER_NONE)
|
||||
Settings.TaskDevicePluginConfig[event->TaskIndex][5] = getFormItemInt(F("plugin_013_FilterSize"));
|
||||
|
||||
success = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case PLUGIN_INIT:
|
||||
{
|
||||
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];
|
||||
int16_t max_distance = Settings.TaskDevicePluginConfig[event->TaskIndex][2];
|
||||
int16_t measuringUnit = Settings.TaskDevicePluginConfig[event->TaskIndex][3];
|
||||
int16_t filterType = Settings.TaskDevicePluginConfig[event->TaskIndex][4];
|
||||
int16_t filterSize = Settings.TaskDevicePluginConfig[event->TaskIndex][5];
|
||||
|
||||
int8_t Plugin_013_TRIG_Pin = Settings.TaskDevicePin1[event->TaskIndex];
|
||||
int8_t Plugin_013_IRQ_Pin = Settings.TaskDevicePin2[event->TaskIndex];
|
||||
int16_t max_distance_cm = (measuringUnit == UNIT_CM) ? max_distance : (float)max_distance * 2.54f;
|
||||
|
||||
// create sensor instance and add to std::map
|
||||
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_distance_cm));
|
||||
|
||||
String log = F("ULTRASONIC : TaskNr: ");
|
||||
log += event->TaskIndex +1;
|
||||
log += F(" TrigPin: ");
|
||||
log += Plugin_013_TRIG_Pin;
|
||||
log += F(" IRQ_Pin: ");
|
||||
log += Plugin_013_IRQ_Pin;
|
||||
log += F(" max dist cm: ");
|
||||
log += max_cm_distance;
|
||||
log += F(" max dist ");
|
||||
log += (measuringUnit == UNIT_CM) ? F("[cm]: ") : F("[inch]: ");
|
||||
log += max_distance;
|
||||
log += F(" max echo: ");
|
||||
log += P_013_sensordefs[event->TaskIndex].sonar->getMaxEchoTime();
|
||||
log += P_013_sensordefs[event->TaskIndex]->getMaxEchoTime();
|
||||
log += F(" Filter: ");
|
||||
if (filterType == FILTER_NONE)
|
||||
log += F("none");
|
||||
else
|
||||
if (filterType == FILTER_MEDIAN) {
|
||||
log += F("Median size: ");
|
||||
log += filterSize;
|
||||
}
|
||||
else
|
||||
log += F("invalid!");
|
||||
log += F(" nr_tasks: ");
|
||||
log += P_013_sensordefs.size();
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
@@ -136,7 +190,6 @@ boolean Plugin_013(byte function, struct EventStruct *event, String& string)
|
||||
log += F(" usec, ");
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
|
||||
|
||||
success = true;
|
||||
break;
|
||||
}
|
||||
@@ -149,39 +202,48 @@ boolean Plugin_013(byte function, struct EventStruct *event, String& string)
|
||||
|
||||
case PLUGIN_READ: // If we select value mode, read and send the value based on global timer
|
||||
{
|
||||
if (Settings.TaskDevicePluginConfig[event->TaskIndex][0] == 1)
|
||||
int16_t operatingMode = Settings.TaskDevicePluginConfig[event->TaskIndex][0];
|
||||
int16_t measuringUnit = Settings.TaskDevicePluginConfig[event->TaskIndex][3];
|
||||
|
||||
if (operatingMode == OPMODE_VALUE)
|
||||
{
|
||||
float value = Plugin_013_read(event->TaskIndex);
|
||||
String log = F("ULTRASONIC : TaskNr: ");
|
||||
log += event->TaskIndex +1;
|
||||
log += F(" Distance: ");
|
||||
if (value > 0)
|
||||
UserVar[event->BaseVarIndex] = value;
|
||||
log += UserVar[event->BaseVarIndex];
|
||||
log += (measuringUnit == UNIT_CM) ? F(" cm ") : F(" inch ");
|
||||
if (value == NO_ECHO)
|
||||
{
|
||||
UserVar[event->BaseVarIndex] = value;
|
||||
log += UserVar[event->BaseVarIndex];
|
||||
success = true;
|
||||
log += F(" Error: ");
|
||||
log += Plugin_013_getErrorStatusString(event->TaskIndex);
|
||||
}
|
||||
else
|
||||
log += F("No reading!");
|
||||
|
||||
addLog(LOG_LEVEL_INFO,log);
|
||||
addLog(LOG_LEVEL_INFO,log);
|
||||
}
|
||||
success = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case PLUGIN_TEN_PER_SECOND: // If we select state mode, do more frequent checks and send only state changes
|
||||
{
|
||||
if (Settings.TaskDevicePluginConfig[event->TaskIndex][0] == 2)
|
||||
int16_t operatingMode = Settings.TaskDevicePluginConfig[event->TaskIndex][0];
|
||||
int16_t threshold = Settings.TaskDevicePluginConfig[event->TaskIndex][1];
|
||||
|
||||
if (operatingMode == OPMODE_STATE)
|
||||
{
|
||||
byte state = 0;
|
||||
float value = Plugin_013_read(event->TaskIndex);
|
||||
if (value > 0)
|
||||
if (value != NO_ECHO)
|
||||
{
|
||||
if (value < Settings.TaskDevicePluginConfig[event->TaskIndex][1])
|
||||
if (value < threshold)
|
||||
state = 1;
|
||||
if (state != switchstate[event->TaskIndex])
|
||||
{
|
||||
String log = F("ULTRASONIC : State ");
|
||||
String log = F("ULTRASONIC : TaskNr: ");
|
||||
log += event->TaskIndex +1;
|
||||
log += F(" state: ");
|
||||
log += state;
|
||||
addLog(LOG_LEVEL_INFO,log);
|
||||
switchstate[event->TaskIndex] = state;
|
||||
@@ -190,6 +252,14 @@ boolean Plugin_013(byte function, struct EventStruct *event, String& string)
|
||||
sendData(event);
|
||||
}
|
||||
}
|
||||
else {
|
||||
String log = F("ULTRASONIC : TaskNr: ");
|
||||
log += event->TaskIndex +1;
|
||||
log += F(" Error: ");
|
||||
log += Plugin_013_getErrorStatusString(event->TaskIndex);
|
||||
addLog(LOG_LEVEL_INFO,log);
|
||||
}
|
||||
|
||||
}
|
||||
success = true;
|
||||
break;
|
||||
@@ -202,11 +272,82 @@ boolean Plugin_013(byte function, struct EventStruct *event, String& string)
|
||||
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();
|
||||
delay(1);
|
||||
return distance;
|
||||
if (P_013_sensordefs.count(taskIndex) == 0)
|
||||
return 0;
|
||||
|
||||
int16_t max_distance = Settings.TaskDevicePluginConfig[taskIndex][2];
|
||||
int16_t measuringUnit = Settings.TaskDevicePluginConfig[taskIndex][3];
|
||||
int16_t filterType = Settings.TaskDevicePluginConfig[taskIndex][4];
|
||||
int16_t filterSize = Settings.TaskDevicePluginConfig[taskIndex][5];
|
||||
int16_t max_distance_cm = (measuringUnit == UNIT_CM) ? max_distance : (float)max_distance * 2.54f;
|
||||
|
||||
unsigned int echoTime = 0;
|
||||
|
||||
switch (filterType) {
|
||||
case FILTER_NONE:
|
||||
echoTime = (P_013_sensordefs[taskIndex])->ping();
|
||||
break;
|
||||
case FILTER_MEDIAN:
|
||||
echoTime = (P_013_sensordefs[taskIndex])->ping_median(filterSize, max_distance_cm);
|
||||
break;
|
||||
default:
|
||||
addLog(LOG_LEVEL_INFO, F("invalid Filter Type setting!"));
|
||||
}
|
||||
|
||||
if (measuringUnit == UNIT_CM)
|
||||
return NewPingESP8266::convert_cm_F(echoTime);
|
||||
else
|
||||
return NewPingESP8266::convert_in_F(echoTime);
|
||||
}
|
||||
|
||||
/*********************************************************************/
|
||||
String Plugin_013_getErrorStatusString(unsigned int taskIndex)
|
||||
/*********************************************************************/
|
||||
{
|
||||
if (P_013_sensordefs.count(taskIndex) == 0)
|
||||
return String(F("invalid taskindex"));
|
||||
|
||||
switch ((P_013_sensordefs[taskIndex])->getErrorState()) {
|
||||
case NewPingESP8266::STATUS_SENSOR_READY: {
|
||||
return String(F("Sensor ready"));
|
||||
break;
|
||||
}
|
||||
|
||||
case NewPingESP8266::STATUS_MEASUREMENT_VALID: {
|
||||
return String(F("no error, measurement valid"));
|
||||
break;
|
||||
}
|
||||
|
||||
case NewPingESP8266::STATUS_ECHO_TRIGGERED: {
|
||||
return String(F("Echo triggered, waiting for Echo end"));
|
||||
break;
|
||||
}
|
||||
|
||||
case NewPingESP8266::STATUS_ECHO_STATE_ERROR: {
|
||||
return String(F("Echo pulse error, Echopin not low on trigger"));
|
||||
break;
|
||||
}
|
||||
|
||||
case NewPingESP8266::STATUS_ECHO_START_TIMEOUT_50ms: {
|
||||
return String(F("Echo timeout error, no echo start whithin 50 ms"));
|
||||
break;
|
||||
}
|
||||
|
||||
case NewPingESP8266::STATUS_ECHO_START_TIMEOUT_DISTANCE: {
|
||||
return String(F("Echo timeout error, no echo start whithin time for max. distance"));
|
||||
break;
|
||||
}
|
||||
|
||||
case NewPingESP8266::STATUS_MAX_DISTANCE_EXCEEDED: {
|
||||
return String(F("Echo too late, maximum distance exceeded"));
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
return String(F("unknown error"));
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
#endif // USES_P013
|
||||
|
||||
@@ -41,6 +41,9 @@ decode_results results;
|
||||
#define PLUGIN_NAME_016 "Communication - TSOP4838"
|
||||
#define PLUGIN_VALUENAME1_016 "IR"
|
||||
|
||||
// A lot of the following code has been taken directly (with permission) from the IRrecvDumpV2.ino example code
|
||||
// of the IRremoteESP8266 library. (https://github.com/markszabo/IRremoteESP8266)
|
||||
|
||||
// ==================== start of TUNEABLE PARAMETERS ====================
|
||||
// As this program is a special purpose capture/decoder, let us use a larger
|
||||
// than normal buffer so we can handle Air Conditioner remote codes.
|
||||
@@ -155,7 +158,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");
|
||||
|
||||
+60
-7
@@ -11,7 +11,7 @@
|
||||
boolean Plugin_019(byte function, struct EventStruct *event, String& string)
|
||||
{
|
||||
boolean success = false;
|
||||
static byte switchstate[TASKS_MAX];
|
||||
static boolean switchstate[TASKS_MAX];
|
||||
|
||||
switch (function)
|
||||
{
|
||||
@@ -20,10 +20,10 @@ 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;
|
||||
Device[deviceCount].InverseLogicOption = true;
|
||||
Device[deviceCount].FormulaOption = false;
|
||||
Device[deviceCount].ValueCount = 1;
|
||||
Device[deviceCount].SendDataOption = true;
|
||||
@@ -66,10 +66,17 @@ boolean Plugin_019(byte function, struct EventStruct *event, String& string)
|
||||
// read and store current state to prevent switching at boot time
|
||||
switchstate[event->TaskIndex] = Plugin_019_Read(Settings.TaskDevicePort[event->TaskIndex]);
|
||||
|
||||
// if boot state must be send, inverse default state
|
||||
if (Settings.TaskDevicePluginConfig[event->TaskIndex][0])
|
||||
switchstate[event->TaskIndex] = !switchstate[event->TaskIndex];
|
||||
if (Settings.TaskDevicePin1Inversed[event->TaskIndex]){
|
||||
UserVar[event->BaseVarIndex] = !switchstate[event->TaskIndex];
|
||||
} else {
|
||||
UserVar[event->BaseVarIndex] = switchstate[event->TaskIndex];
|
||||
}
|
||||
|
||||
// if boot state must be send, inverse default state
|
||||
// this is done to force the trigger in PLUGIN_TEN_PER_SECOND
|
||||
if (Settings.TaskDevicePluginConfig[event->TaskIndex][0]) {
|
||||
switchstate[event->TaskIndex] = !switchstate[event->TaskIndex];
|
||||
}
|
||||
success = true;
|
||||
break;
|
||||
}
|
||||
@@ -85,7 +92,13 @@ boolean Plugin_019(byte function, struct EventStruct *event, String& string)
|
||||
log += state;
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
switchstate[event->TaskIndex] = state;
|
||||
UserVar[event->BaseVarIndex] = state;
|
||||
|
||||
if (Settings.TaskDevicePin1Inversed[event->TaskIndex]){
|
||||
UserVar[event->BaseVarIndex] = !switchstate[event->TaskIndex];
|
||||
} else {
|
||||
UserVar[event->BaseVarIndex] = switchstate[event->TaskIndex];
|
||||
}
|
||||
|
||||
event->sensorType = SENSOR_TYPE_SWITCH;
|
||||
sendData(event);
|
||||
}
|
||||
@@ -105,6 +118,24 @@ boolean Plugin_019(byte function, struct EventStruct *event, String& string)
|
||||
break;
|
||||
}
|
||||
|
||||
case PLUGIN_REQUEST:
|
||||
{
|
||||
//parseString(string, 1) = device
|
||||
//parseString(string, 2) = command
|
||||
//parseString(string, 3) = gpio number
|
||||
|
||||
// returns pin value using syntax: [plugin#pcfgpio#pinstate#xx]
|
||||
if (string.length()>=16 && string.substring(0,16).equalsIgnoreCase(F("pcfgpio,pinstate")))
|
||||
{
|
||||
int par1;
|
||||
if (validIntFromString(parseString(string, 3), par1)) {
|
||||
string = Plugin_019_Read(par1);
|
||||
}
|
||||
success = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case PLUGIN_WRITE:
|
||||
{
|
||||
String log = "";
|
||||
@@ -128,6 +159,28 @@ boolean Plugin_019(byte function, struct EventStruct *event, String& string)
|
||||
SendStatus(event->Source, getPinStateJSON(SEARCH_PIN_STATE, PLUGIN_ID_019, event->Par1, log, 0));
|
||||
}
|
||||
|
||||
if (command == F("pcfgpiotoggle"))
|
||||
{
|
||||
success = true;
|
||||
byte mode;
|
||||
uint16_t currentState;
|
||||
|
||||
if (hasPinState(PLUGIN_ID_019,event->Par1)) {
|
||||
getPinState(PLUGIN_ID_019, event->Par1, &mode, ¤tState);
|
||||
} else {
|
||||
currentState = Plugin_019_Read(event->Par1);
|
||||
mode = PIN_MODE_OUTPUT;
|
||||
}
|
||||
|
||||
if (mode != PIN_MODE_INPUT) {
|
||||
setPinState(PLUGIN_ID_019, event->Par1, PIN_MODE_OUTPUT, !currentState);
|
||||
Plugin_019_Write(event->Par1, !currentState);
|
||||
log = String(F("PCF : Toggle GPIO ")) + String(event->Par1) + String(F(" Set to ")) + String(!currentState);
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
SendStatus(event->Source, getPinStateJSON(SEARCH_PIN_STATE, PLUGIN_ID_019, event->Par1, log, 0));
|
||||
}
|
||||
}
|
||||
|
||||
if (command == F("pcfpulse"))
|
||||
{
|
||||
success = true;
|
||||
|
||||
+20
-11
@@ -15,6 +15,9 @@
|
||||
#define PLUGIN_VALUENAME1_023 "OLED"
|
||||
#define PLUGIN_023_MAX_DYSPALY 2
|
||||
|
||||
#define P23_Nlines 8 // The number of different lines which can be displayed
|
||||
#define P23_Nchars 64
|
||||
|
||||
struct Plugin_023_OLED_SettingStruct
|
||||
{
|
||||
Plugin_023_OLED_SettingStruct(): address(0)
|
||||
@@ -94,7 +97,7 @@ boolean Plugin_023(byte function, struct EventStruct *event, String& string)
|
||||
int optionValues4[2] = { 1, 2 };
|
||||
addFormSelector(F("Font Width"), F("plugin_023_font_width"), 2, options4, optionValues4, choice4);
|
||||
|
||||
char deviceTemplate[8][64];
|
||||
char deviceTemplate[P23_Nlines][P23_Nchars];
|
||||
LoadCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate));
|
||||
for (byte varNr = 0; varNr < 8; varNr++)
|
||||
{
|
||||
@@ -117,16 +120,19 @@ boolean Plugin_023(byte function, struct EventStruct *event, String& string)
|
||||
Settings.TaskDevicePluginConfig[event->TaskIndex][3] = getFormItemInt(F("plugin_023_size"));
|
||||
Settings.TaskDevicePluginConfig[event->TaskIndex][4] = getFormItemInt(F("plugin_023_font_width"));
|
||||
|
||||
char deviceTemplate[8][64];
|
||||
for (byte varNr = 0; varNr < 8; varNr++)
|
||||
char deviceTemplate[P23_Nlines][P23_Nchars];
|
||||
String error;
|
||||
for (byte varNr = 0; varNr < P23_Nlines; varNr++)
|
||||
{
|
||||
String arg = F("Plugin_023_template");
|
||||
arg += varNr + 1;
|
||||
String tmpString = WebServer.arg(arg);
|
||||
strncpy(deviceTemplate[varNr], tmpString.c_str(), sizeof(deviceTemplate[varNr])-1);
|
||||
deviceTemplate[varNr][63]=0;
|
||||
String argName = F("Plugin_023_template");
|
||||
argName += varNr + 1;
|
||||
if (!safe_strncpy(deviceTemplate[varNr], WebServer.arg(argName), P23_Nchars)) {
|
||||
error += getCustomTaskSettingsError(varNr);
|
||||
}
|
||||
}
|
||||
if (error.length() > 0) {
|
||||
addHtmlError(error);
|
||||
}
|
||||
|
||||
SaveCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate));
|
||||
success = true;
|
||||
break;
|
||||
@@ -203,7 +209,7 @@ boolean Plugin_023(byte function, struct EventStruct *event, String& string)
|
||||
|
||||
case PLUGIN_READ:
|
||||
{
|
||||
char deviceTemplate[8][64];
|
||||
char deviceTemplate[P23_Nlines][P23_Nchars];
|
||||
LoadCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate));
|
||||
int index = Settings.TaskDevicePluginConfig[event->TaskIndex][0] == 0x3C
|
||||
? 0
|
||||
@@ -228,8 +234,10 @@ boolean Plugin_023(byte function, struct EventStruct *event, String& string)
|
||||
? 0
|
||||
: 1;
|
||||
String arguments = String(string);
|
||||
|
||||
//Fixed bug #1864
|
||||
int dotPos = arguments.indexOf('.');
|
||||
if(dotPos > -1)
|
||||
if(dotPos > -1 && arguments.substring(dotPos,dotPos+4).equalsIgnoreCase(F("oled")))
|
||||
{
|
||||
LoadTaskSettings(event->TaskIndex);
|
||||
String name = arguments.substring(0,dotPos);
|
||||
@@ -245,6 +253,7 @@ boolean Plugin_023(byte function, struct EventStruct *event, String& string)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int argIndex = arguments.indexOf(',');
|
||||
if (argIndex)
|
||||
arguments = arguments.substring(0, argIndex);
|
||||
|
||||
@@ -41,7 +41,7 @@ boolean Plugin_026(byte function, struct EventStruct *event, String& string)
|
||||
case PLUGIN_WEBFORM_LOAD:
|
||||
{
|
||||
byte choice = Settings.TaskDevicePluginConfig[event->TaskIndex][0];
|
||||
String options[10];
|
||||
String options[11];
|
||||
options[0] = F("Uptime");
|
||||
options[1] = F("Free RAM");
|
||||
options[2] = F("Wifi RSSI");
|
||||
@@ -52,7 +52,8 @@ boolean Plugin_026(byte function, struct EventStruct *event, String& string)
|
||||
options[7] = F("IP 3.Octet");
|
||||
options[8] = F("IP 4.Octet");
|
||||
options[9] = F("Web activity");
|
||||
addFormSelector(F("Indicator"), F("plugin_026"), 10, options, NULL, choice);
|
||||
options[10] = F("Free Stack");
|
||||
addFormSelector(F("Indicator"), F("plugin_026"), 11, options, NULL, choice);
|
||||
|
||||
success = true;
|
||||
break;
|
||||
@@ -124,6 +125,11 @@ boolean Plugin_026(byte function, struct EventStruct *event, String& string)
|
||||
value = (millis()-lastWeb)/1000; // respond in seconds
|
||||
break;
|
||||
}
|
||||
case 10:
|
||||
{
|
||||
value = getCurrentFreeStack();
|
||||
break;
|
||||
}
|
||||
}
|
||||
UserVar[event->BaseVarIndex] = value;
|
||||
String log = F("SYS : ");
|
||||
|
||||
+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;
|
||||
|
||||
@@ -53,7 +53,7 @@ boolean Plugin_029(byte function, struct EventStruct *event, String& string)
|
||||
addHtml(F("<TR><TD>IDX:<TD>"));
|
||||
String id = F("TDID"); //="taskdeviceid"
|
||||
id += controllerNr + 1;
|
||||
addNumericBox(id, Settings.TaskDeviceID[controllerNr][event->TaskIndex], 0, 9999);
|
||||
addNumericBox(id, Settings.TaskDeviceID[controllerNr][event->TaskIndex], 0, DOMOTICZ_MAX_IDX);
|
||||
success = true;
|
||||
break;
|
||||
}
|
||||
|
||||
+4
-2
@@ -205,7 +205,7 @@ boolean Plugin_035(byte function, struct EventStruct *event, String& string)
|
||||
// unsigned long IrSecondCode=0UL;
|
||||
char ircodestr[100];
|
||||
if (GetArgv(command, TmpStr1,100, 2)) IrType = TmpStr1;
|
||||
if (GetArgv(command, TmpStr1, 100, 3)){ IrCode = strtoul(TmpStr1, NULL, 16);
|
||||
if (GetArgv(command, TmpStr1, 100, 3)){ IrCode = strtoull(TmpStr1, NULL, 16);
|
||||
memcpy(ircodestr, TmpStr1, sizeof(TmpStr1[0])*100);
|
||||
}
|
||||
//if (GetArgv(command, TmpStr1, 100, 4)) IrBits = str2int(TmpStr1); //not needed any more... leave it for reverce compatibility or remove it and break existing instalations?
|
||||
@@ -274,6 +274,8 @@ boolean Plugin_035(byte function, struct EventStruct *event, String& string)
|
||||
return success;
|
||||
}
|
||||
|
||||
// A lot of the following code has been taken directly (with permission) from the IRMQTTServer.ino example code
|
||||
// of the IRremoteESP8266 library. (https://github.com/markszabo/IRremoteESP8266)
|
||||
|
||||
// Parse an Air Conditioner A/C Hex String/code and send it.
|
||||
// Args:
|
||||
@@ -615,4 +617,4 @@ uint16_t countValuesInStr(const String str, char sep) {
|
||||
// }
|
||||
// return result;
|
||||
//}
|
||||
#endif // USES_P035
|
||||
#endif // USES_P035
|
||||
|
||||
@@ -180,15 +180,18 @@ boolean Plugin_036(byte function, struct EventStruct *event, String& string)
|
||||
Settings.TaskDevicePluginConfig[event->TaskIndex][5] = getFormItemInt(F("plugin_036_controler"));
|
||||
Settings.TaskDevicePluginConfig[event->TaskIndex][6] = getFormItemInt(F("plugin_036_contrast"));
|
||||
|
||||
String argName;
|
||||
|
||||
String error;
|
||||
for (byte varNr = 0; varNr < P36_Nlines; varNr++)
|
||||
{
|
||||
argName = F("Plugin_036_template");
|
||||
String argName = F("Plugin_036_template");
|
||||
argName += varNr + 1;
|
||||
strncpy(P036_deviceTemplate[varNr], WebServer.arg(argName).c_str(), sizeof(P036_deviceTemplate[varNr]));
|
||||
if (!safe_strncpy(P036_deviceTemplate[varNr], WebServer.arg(argName), P36_Nchars)) {
|
||||
error += getCustomTaskSettingsError(varNr);
|
||||
}
|
||||
}
|
||||
if (error.length() > 0) {
|
||||
addHtmlError(error);
|
||||
}
|
||||
|
||||
SaveCustomTaskSettings(event->TaskIndex, (byte*)&P036_deviceTemplate, sizeof(P036_deviceTemplate));
|
||||
|
||||
success = true;
|
||||
|
||||
+69
-42
@@ -24,6 +24,37 @@
|
||||
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();
|
||||
espclient_037.setTimeout(CONTROLLER_CLIENTTIMEOUT_DFLT);
|
||||
|
||||
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;
|
||||
@@ -32,6 +63,8 @@ void Plugin_037_update_connect_status() {
|
||||
}
|
||||
if (MQTTclient_037_connected != connected) {
|
||||
MQTTclient_037_connected = !MQTTclient_037_connected;
|
||||
P037_MQTTImport_connected = MQTTclient_037_connected;
|
||||
|
||||
if (Settings.UseRules) {
|
||||
String event = connected ? F("MQTTimport#Connected") : F("MQTTimport#Disconnected");
|
||||
rulesProcessing(event);
|
||||
@@ -39,6 +72,8 @@ void Plugin_037_update_connect_status() {
|
||||
if (!connected) {
|
||||
// workaround see: https://github.com/esp8266/Arduino/issues/4497#issuecomment-373023864
|
||||
espclient_037 = WiFiClient();
|
||||
espclient_037.setTimeout(CONTROLLER_CLIENTTIMEOUT_DFLT);
|
||||
++reconnectCount;
|
||||
addLog(LOG_LEVEL_ERROR, F("IMPT : MQTT 037 Connection lost"));
|
||||
}
|
||||
}
|
||||
@@ -49,11 +84,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 +151,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 +177,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 +284,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 +308,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 +375,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) {
|
||||
@@ -367,8 +394,8 @@ boolean MQTTConnect_037(String clientid)
|
||||
Plugin_037_update_connect_status();
|
||||
return false; // Not connected, so no use in wasting time to connect to a host.
|
||||
}
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(enabledMqttController, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
MakeControllerSettings(ControllerSettings);
|
||||
LoadControllerSettings(enabledMqttController, ControllerSettings);
|
||||
if (ControllerSettings.UseDNS) {
|
||||
MQTTclient_037->setServer(ControllerSettings.getHost().c_str(), ControllerSettings.Port);
|
||||
} else {
|
||||
|
||||
+16
-12
@@ -16,7 +16,7 @@
|
||||
|
||||
#define P044_STATUS_LED 12
|
||||
#define P044_BUFFER_SIZE 1024
|
||||
#define P044_NETBUF_SIZE 600
|
||||
#define P044_NETBUF_SIZE 128
|
||||
#define P044_DISABLED 0
|
||||
#define P044_WAITING 1
|
||||
#define P044_READING 2
|
||||
@@ -31,7 +31,7 @@ boolean CRCcheck = false;
|
||||
unsigned int currCRC = 0;
|
||||
int checkI = 0;
|
||||
|
||||
WiFiServer *P1GatewayServer;
|
||||
WiFiServer *P1GatewayServer = nullptr;
|
||||
WiFiClient P1GatewayClient;
|
||||
|
||||
boolean Plugin_044(byte function, struct EventStruct *event, String& string)
|
||||
@@ -125,7 +125,11 @@ boolean Plugin_044(byte function, struct EventStruct *event, String& string)
|
||||
#if defined(ESP32)
|
||||
Serial.begin(ExtraTaskSettings.TaskDevicePluginConfigLong[1], serialconfig);
|
||||
#endif
|
||||
if (P1GatewayServer) P1GatewayServer->close();
|
||||
if (P1GatewayServer)
|
||||
{
|
||||
P1GatewayServer->close();
|
||||
delete P1GatewayServer;
|
||||
}
|
||||
P1GatewayServer = new WiFiServer(ExtraTaskSettings.TaskDevicePluginConfigLong[0]);
|
||||
P1GatewayServer->begin();
|
||||
|
||||
@@ -164,7 +168,7 @@ boolean Plugin_044(byte function, struct EventStruct *event, String& string)
|
||||
{
|
||||
if (P1GatewayServer) {
|
||||
P1GatewayServer->close();
|
||||
//FIXME: shouldnt P1P1GatewayServer be deleted?
|
||||
delete P1GatewayServer;
|
||||
P1GatewayServer = NULL;
|
||||
}
|
||||
success = true;
|
||||
@@ -175,7 +179,6 @@ boolean Plugin_044(byte function, struct EventStruct *event, String& string)
|
||||
{
|
||||
if (Plugin_044_init)
|
||||
{
|
||||
size_t bytes_read;
|
||||
if (P1GatewayServer->hasClient())
|
||||
{
|
||||
if (P1GatewayClient) P1GatewayClient.stop();
|
||||
@@ -186,24 +189,25 @@ boolean Plugin_044(byte function, struct EventStruct *event, String& string)
|
||||
if (P1GatewayClient.connected())
|
||||
{
|
||||
connectionState = 1;
|
||||
uint8_t net_buf[P044_BUFFER_SIZE];
|
||||
uint8_t net_buf[P044_NETBUF_SIZE];
|
||||
int count = P1GatewayClient.available();
|
||||
if (count > 0)
|
||||
{
|
||||
if (count > P044_BUFFER_SIZE)
|
||||
count = P044_BUFFER_SIZE;
|
||||
bytes_read = P1GatewayClient.read(net_buf, count);
|
||||
Serial.write(net_buf, bytes_read);
|
||||
size_t net_bytes_read;
|
||||
if (count > P044_NETBUF_SIZE)
|
||||
count = P044_NETBUF_SIZE;
|
||||
net_bytes_read = P1GatewayClient.read(net_buf, count);
|
||||
Serial.write(net_buf, net_bytes_read);
|
||||
Serial.flush(); // Waits for the transmission of outgoing serial data to complete
|
||||
|
||||
if (count == P044_BUFFER_SIZE) // if we have a full buffer, drop the last position to stuff with string end marker
|
||||
if (count == P044_NETBUF_SIZE) // if we have a full buffer, drop the last position to stuff with string end marker
|
||||
{
|
||||
count--;
|
||||
// and log buffer full situation
|
||||
addLog(LOG_LEVEL_ERROR, F("P1 : Error: network buffer full!"));
|
||||
}
|
||||
net_buf[count] = 0; // before logging as a char array, zero terminate the last position to be safe.
|
||||
char log[P044_BUFFER_SIZE + 40];
|
||||
char log[P044_NETBUF_SIZE + 40];
|
||||
sprintf_P(log, PSTR("P1 : Error: N>: %s"), (char*)net_buf);
|
||||
addLog(LOG_LEVEL_DEBUG, log);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
+135
-92
@@ -2,11 +2,16 @@
|
||||
//#######################################################################################################
|
||||
//################################### Plugin 075: Nextion <info@sensorio.cz> ###########################
|
||||
//################################### Created on the work of majklovec ###########################
|
||||
//################################### Revisions by BertB and ThomasB ###########################
|
||||
//################################### Last Revision: Aug-03-2018 (TB) ###########################
|
||||
//################################### Revisions by BertB and ThomasB ###########################
|
||||
//################################### Last Revision: Oct-03-2018 (TB) ###########################
|
||||
//#######################################################################################################
|
||||
//
|
||||
// Updated: Aug-03-2018, ThomasB.
|
||||
// Updated: Oct-03-2018, ThomasB.
|
||||
// Added DEBUG_LOG define to reduce info log messages and prevent serial log flooding.
|
||||
// Added SendStatus() to post log message on browser to acknowledge HTTP write.
|
||||
// Added reserve() to minimize string memory allocations.
|
||||
//
|
||||
// Aug-03-2018 change log summary:
|
||||
// This updated Nextion Plugin introduces hardware (UART) serial as an alternative to SoftSerial.
|
||||
// Hardware serial offers more reliable communication with the Nextion display.
|
||||
// Created on the experimental Serial.swap() work of BertB.
|
||||
@@ -19,6 +24,9 @@
|
||||
// Defines start here
|
||||
// *****************************************************************************************************
|
||||
|
||||
//#define DEBUG_LOG // Enable this to include additional info messages in log output.
|
||||
|
||||
|
||||
// Plug-In defines
|
||||
#define PLUGIN_075
|
||||
#define PLUGIN_ID_075 75
|
||||
@@ -28,18 +36,18 @@
|
||||
#define PLUGIN_VALUENAME2_075 "value"
|
||||
|
||||
// Configuration Settings. Custom Configuration Memory must be less than 1024 Bytes (per TD'er findings).
|
||||
//#define Nlines 12 // Custom Config, Number of user entered Command Statment Lines. DO NOT USE!
|
||||
//#define Lenlines 64 // Custom Config, Length of user entered Command Statment Lines. DO NOT USE!
|
||||
#define Nlines 10 // Custom Config, Number of user entered Command Statments.
|
||||
#define Lenlines 51 // Custom Config, Length of user entered Command Statments.
|
||||
//#define P75_Nlines 12 // Custom Config, Number of user entered Command Statment Lines. DO NOT USE!
|
||||
//#define P75_Nchars 64 // Custom Config, Length of user entered Command Statment Lines. DO NOT USE!
|
||||
#define P75_Nlines 10 // Custom Config, Number of user entered Command Statments.
|
||||
#define P75_Nchars 51 // Custom Config, Length of user entered Command Statments.
|
||||
|
||||
// Nextion defines
|
||||
#define RXBUFFSZ 64 // Serial RxD buffer (Local staging buffer and ESPeasySoftwareSerial).
|
||||
#define RXBUFFSZ 64 // Serial RxD buffer (Local staging buffer and ESPeasySoftwareSerial).
|
||||
#define RXBUFFWARN RXBUFFSZ-16 // Warning, Rx buffer close to being full.
|
||||
#define TOUCH_BASE 500 // Base offset for 0X65 Touch Event Send Component ID.
|
||||
|
||||
// Serial defines
|
||||
#define B9600 0
|
||||
#define B9600 0
|
||||
#define B38400 1
|
||||
#define B57600 2
|
||||
#define B115200 3
|
||||
@@ -50,7 +58,7 @@
|
||||
|
||||
// Global vars
|
||||
ESPeasySoftwareSerial *SoftSerial = NULL;
|
||||
char deviceTemplate[Nlines][Lenlines];
|
||||
char deviceTemplate[P75_Nlines][P75_Nchars];
|
||||
int rxPin = -1;
|
||||
int txPin = -1;
|
||||
|
||||
@@ -59,10 +67,10 @@ int txPin = -1;
|
||||
// PlugIn starts here
|
||||
// *****************************************************************************************************
|
||||
|
||||
boolean Plugin_075(byte function, struct EventStruct *event, String& string)
|
||||
boolean Plugin_075(byte function, struct EventStruct *event, String& string)
|
||||
{
|
||||
boolean success = false;
|
||||
static uint8_t BaudCode = 0; // Web GUI baud rate drop down. 9600 if 0, See array for other rates.
|
||||
static uint8_t BaudCode = 0; // Web GUI baud rate drop down. 9600 if 0, See array for other rates.
|
||||
static boolean HwSerial = SOFTSERIAL; // Serial mode, hardware uart or softserial.
|
||||
static boolean AdvHwSerial = false; // Web GUI checkbox flag; false = softserial mode, true = hardware UART serial.
|
||||
static boolean IncludeValues = false; // Web GUI checkbox flag; false = don't send idx & value data at interval.
|
||||
@@ -126,7 +134,7 @@ boolean Plugin_075(byte function, struct EventStruct *event, String& string)
|
||||
if (!((rxPin == 3 && txPin == 1) || (rxPin == 13 && txPin == 15))) { // Hardware Serial Compatible?
|
||||
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = false; // Not HW serial compatible, Reset Check Box.
|
||||
}
|
||||
|
||||
|
||||
if (rxPin == 3 && txPin == 1) { // UART USB Port?
|
||||
if(Settings.TaskDevicePluginConfig[event->TaskIndex][0]==false && // Hardware serial currently disabled.
|
||||
Settings.TaskDeviceEnabled[event->TaskIndex] == true) { // Plugin is enabled.
|
||||
@@ -134,10 +142,10 @@ boolean Plugin_075(byte function, struct EventStruct *event, String& string)
|
||||
}
|
||||
}
|
||||
|
||||
if (Settings.TaskDevicePluginConfig[event->TaskIndex][0] == false) { // SoftSerial mode.
|
||||
if (Settings.TaskDevicePluginConfig[event->TaskIndex][0] == false) { // SoftSerial mode.
|
||||
Settings.TaskDevicePluginConfig[event->TaskIndex][1] = B9600; // Reset to 9600 baud.
|
||||
}
|
||||
|
||||
|
||||
if(rxPin <0 || txPin <0) { // Missing serial I/O pins!
|
||||
addFormNote(F("Please configure the RX and TX sensor pins before enabling this plugin."));
|
||||
addFormSubHeader(F("")); // Blank line, vertical space.
|
||||
@@ -153,13 +161,13 @@ boolean Plugin_075(byte function, struct EventStruct *event, String& string)
|
||||
options[1] = F("38400");
|
||||
options[2] = F("57600");
|
||||
options[3] = F("115200");
|
||||
|
||||
addFormSelector(F("Baud Rate"), F("plugin_075_baud"), 4, options, NULL, choice);
|
||||
|
||||
addFormSelector(F("Baud Rate"), F("plugin_075_baud"), 4, options, NULL, choice);
|
||||
addFormNote(F("Un-check box for Soft Serial communication (low performance mode, 9600 Baud)."));
|
||||
addFormNote(F("Hardware Serial is available when the GPIO pins are RX=D7 and TX=D8."));
|
||||
addFormNote(F("D8 (GPIO-15) requires a Buffer Circuit (PNP transistor) or ESP boot may fail."));
|
||||
addFormNote(F("Do <b>NOT</b> enable the Serial Log file on Tools->Advanced->Serial Port."));
|
||||
|
||||
|
||||
// ** DEVELOPER DEBUG MESSAGE AREA **
|
||||
// int datax = (int)(Settings.TaskDeviceEnabled[event->TaskIndex]); // Debug value.
|
||||
// String Data = "Debug. Plugin Enable State: ";
|
||||
@@ -168,12 +176,12 @@ boolean Plugin_075(byte function, struct EventStruct *event, String& string)
|
||||
|
||||
addFormSubHeader(F("")); // Blank line, vertical space.
|
||||
addFormHeader(F("Nextion Command Statements (Optional)"));
|
||||
|
||||
char deviceTemplate[Nlines][Lenlines];
|
||||
|
||||
char deviceTemplate[P75_Nlines][P75_Nchars];
|
||||
LoadCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate));
|
||||
for (byte varNr = 0; varNr < Nlines; varNr++) {
|
||||
addFormTextBox(String(F("Line ")) + (varNr + 1), String(F("Plugin_075_template")) + (varNr + 1), deviceTemplate[varNr], Lenlines-1);
|
||||
|
||||
for (byte varNr = 0; varNr < P75_Nlines; varNr++) {
|
||||
addFormTextBox(String(F("Line ")) + (varNr + 1), String(F("Plugin_075_template")) + (varNr + 1), deviceTemplate[varNr], P75_Nchars-1);
|
||||
|
||||
}
|
||||
if( Settings.TaskDeviceTimer[event->TaskIndex]==0) { // Is interval timer disabled?
|
||||
if(IncludeValues) {
|
||||
@@ -194,17 +202,18 @@ boolean Plugin_075(byte function, struct EventStruct *event, String& string)
|
||||
|
||||
|
||||
case PLUGIN_WEBFORM_SAVE: {
|
||||
|
||||
String argName;
|
||||
|
||||
char deviceTemplate[Nlines][Lenlines];
|
||||
for (byte varNr = 0; varNr < Nlines; varNr++)
|
||||
char deviceTemplate[P75_Nlines][P75_Nchars];
|
||||
String error;
|
||||
for (byte varNr = 0; varNr < P75_Nlines; varNr++)
|
||||
{
|
||||
String arg = F("Plugin_075_template");
|
||||
arg += varNr + 1;
|
||||
String tmpString = WebServer.arg(arg);
|
||||
strncpy(deviceTemplate[varNr], tmpString.c_str(), sizeof(deviceTemplate[varNr])-1);
|
||||
deviceTemplate[varNr][Lenlines-1]=0;
|
||||
String argName = F("Plugin_075_template");
|
||||
argName += varNr + 1;
|
||||
if (!safe_strncpy(deviceTemplate[varNr], WebServer.arg(argName), P75_Nchars)) {
|
||||
error += getCustomTaskSettingsError(varNr);
|
||||
}
|
||||
}
|
||||
if (error.length() > 0) {
|
||||
addHtmlError(error);
|
||||
}
|
||||
if(getTaskDeviceName(event->TaskIndex) == "") { // Check to see if user entered device name.
|
||||
strcpy(ExtraTaskSettings.TaskDeviceName,PLUGIN_DEFAULT_NAME); // Name missing, populate default name.
|
||||
@@ -236,12 +245,14 @@ boolean Plugin_075(byte function, struct EventStruct *event, String& string)
|
||||
txPin = Settings.TaskDevicePin2[event->TaskIndex];
|
||||
}
|
||||
|
||||
if (SoftSerial != NULL) {
|
||||
if (SoftSerial != NULL) {
|
||||
delete SoftSerial;
|
||||
SoftSerial = NULL;
|
||||
}
|
||||
|
||||
String log = F("NEXTION075 : serial pin config RX:");
|
||||
String log;
|
||||
log.reserve(80); // Prevent re-allocation
|
||||
log = F("NEXTION075 : serial pin config RX:");
|
||||
log += rxPin;
|
||||
log += F(", TX:");
|
||||
log += txPin;
|
||||
@@ -283,7 +294,7 @@ boolean Plugin_075(byte function, struct EventStruct *event, String& string)
|
||||
HwSerial = SOFTSERIAL;
|
||||
if (SoftSerial == NULL) {
|
||||
SoftSerial = new ESPeasySoftwareSerial(rxPin, txPin, false, RXBUFFSZ);
|
||||
}
|
||||
}
|
||||
SoftSerial->begin(9600);
|
||||
SoftSerial->flush();
|
||||
}
|
||||
@@ -295,8 +306,8 @@ boolean Plugin_075(byte function, struct EventStruct *event, String& string)
|
||||
}
|
||||
|
||||
|
||||
case PLUGIN_READ: {
|
||||
char deviceTemplate[Nlines][Lenlines];
|
||||
case PLUGIN_READ: {
|
||||
char deviceTemplate[P75_Nlines][P75_Nchars];
|
||||
int RssiIndex;
|
||||
String newString;
|
||||
String tmpString;
|
||||
@@ -305,7 +316,7 @@ boolean Plugin_075(byte function, struct EventStruct *event, String& string)
|
||||
LoadCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate));
|
||||
|
||||
// Get optional LINE command statements. Special RSSIBAR bargraph keyword is supported.
|
||||
for (byte x = 0; x < Nlines; x++) {
|
||||
for (byte x = 0; x < P75_Nlines; x++) {
|
||||
tmpString = deviceTemplate[x];
|
||||
if (tmpString.length()) {
|
||||
UcTmpString = deviceTemplate[x];
|
||||
@@ -313,6 +324,7 @@ boolean Plugin_075(byte function, struct EventStruct *event, String& string)
|
||||
RssiIndex = UcTmpString.indexOf(F("RSSIBAR")); // RSSI bargraph Keyword found, wifi value in dBm.
|
||||
if(RssiIndex >= 0) {
|
||||
int barVal;
|
||||
newString.reserve(P75_Nchars+10); // Prevent re-allocation
|
||||
newString = tmpString.substring(0, RssiIndex);
|
||||
int nbars = WiFi.RSSI();
|
||||
if (nbars < -100 || nbars >= 0)
|
||||
@@ -345,55 +357,64 @@ boolean Plugin_075(byte function, struct EventStruct *event, String& string)
|
||||
}
|
||||
|
||||
sendCommand(newString.c_str(), HwSerial);
|
||||
|
||||
String log = F("NEXTION075 : Cmd Statement Line-");
|
||||
log += String(x+1);
|
||||
log += F(" Sent: ");
|
||||
log += newString;
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
#ifdef DEBUG_LOG
|
||||
String log;
|
||||
log.reserve(P75_Nchars+50); // Prevent re-allocation
|
||||
log = F("NEXTION075 : Cmd Statement Line-");
|
||||
log += String(x+1);
|
||||
log += F(" Sent: ");
|
||||
log += newString;
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// At Interval timer, send idx & value data only if user enabled "values" interval mode.
|
||||
if(IncludeValues) {
|
||||
/*
|
||||
String log = F("NEXTION075: Interval values data enabled, resending idx=");
|
||||
log += String(UserVar[event->BaseVarIndex]);
|
||||
log += F(", value=");
|
||||
log += String(UserVar[event->BaseVarIndex+1]);
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
*/
|
||||
#ifdef DEBUG_LOG
|
||||
String log;
|
||||
log.reserve(120); // Prevent re-allocation
|
||||
log = F("NEXTION075: Interval values data enabled, resending idx=");
|
||||
log += String(UserVar[event->BaseVarIndex]);
|
||||
log += F(", value=");
|
||||
log += String(UserVar[event->BaseVarIndex+1]);
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
#endif
|
||||
|
||||
success = true;
|
||||
}
|
||||
else {
|
||||
/*
|
||||
String log = F("NEXTION075: Interval values data disabled, idx & value not resent");
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
*/
|
||||
#ifdef DEBUG_LOG
|
||||
String log = F("NEXTION075: Interval values data disabled, idx & value not resent");
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
#endif
|
||||
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Nextion commands received from events (including http) get processed here. PLUGIN_WRITE
|
||||
// Nextion commands received from events (including http) get processed here. PLUGIN_WRITE
|
||||
// does NOT process publish commands that are sent.
|
||||
case PLUGIN_WRITE: {
|
||||
|
||||
|
||||
String tmpString = string;
|
||||
int argIndex = tmpString.indexOf(',');
|
||||
if (argIndex) tmpString = tmpString.substring(0, argIndex);
|
||||
|
||||
|
||||
// Enable addLog() code below to help debug plugin write problems.
|
||||
/*
|
||||
String log;
|
||||
log.reserve(140); // Prevent re-allocation
|
||||
String log = F("Nextion arg0: ");
|
||||
log += tmpString;
|
||||
log += tmpString;
|
||||
log += F(", TaskDeviceName: ");
|
||||
log += getTaskDeviceName(event->TaskIndex);
|
||||
log += F(", event->TaskIndex: ");
|
||||
log += String(event->TaskIndex);
|
||||
log += String(event->TaskIndex);
|
||||
log += F(", cmd str: ");
|
||||
log += string;
|
||||
log += string;
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
*/
|
||||
if (tmpString.equalsIgnoreCase(getTaskDeviceName(event->TaskIndex)) == true) { // If device names match we have a command to write.
|
||||
@@ -401,11 +422,14 @@ boolean Plugin_075(byte function, struct EventStruct *event, String& string)
|
||||
tmpString = string.substring(argIndex + 1);
|
||||
sendCommand(tmpString.c_str(), HwSerial);
|
||||
|
||||
String log = F("NEXTION075 : WRITE, ");
|
||||
log += F("Command is ");
|
||||
log += (tmpString.c_str());
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
|
||||
String log;
|
||||
log.reserve(110); // Prevent re-allocation
|
||||
log = F("NEXTION075 : WRITE = ");
|
||||
log += tmpString;
|
||||
#ifdef DEBUG_LOG
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
#endif
|
||||
SendStatus(event->Source, log); // Reply (echo) to sender. This will print message on browser.
|
||||
success = true; // Set true only if plugin found a command to execute.
|
||||
}
|
||||
break;
|
||||
@@ -434,20 +458,19 @@ boolean Plugin_075(byte function, struct EventStruct *event, String& string)
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
case PLUGIN_TEN_PER_SECOND: {
|
||||
uint16_t i;
|
||||
uint8_t c;
|
||||
uint8_t charCount;
|
||||
String log;
|
||||
String Vidx;
|
||||
String Nvalue;
|
||||
String Svalue;
|
||||
String Nswitch;
|
||||
char __buffer[RXBUFFSZ+1]; // Staging buffer.
|
||||
|
||||
|
||||
if(rxPin < 0) {
|
||||
String log = F("NEXTION075 : Missing RxD Pin Number, aborted serial receive");
|
||||
String log = F("NEXTION075 : Missing RxD Pin, aborted serial receive");
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
break;
|
||||
}
|
||||
@@ -455,6 +478,8 @@ boolean Plugin_075(byte function, struct EventStruct *event, String& string)
|
||||
if(HwSerial == UARTSERIAL) {
|
||||
charCount = Serial.available(); // Prime the Hardware Serial engine.
|
||||
if(charCount >= RXBUFFWARN) { // ESP8266 has 128 byte circular Rx buffer.
|
||||
String log;
|
||||
log.reserve(70); // Prevent re-allocation
|
||||
log = F("NEXTION075 : RxD UART Buffer capacity warning,");
|
||||
log += String(charCount);
|
||||
log += F(" bytes");
|
||||
@@ -465,6 +490,8 @@ boolean Plugin_075(byte function, struct EventStruct *event, String& string)
|
||||
if(SoftSerial == NULL) break; // SoftSerial missing, exit.
|
||||
charCount = SoftSerial->available(); // Prime the Soft Serial engine.
|
||||
if(charCount >= RXBUFFWARN) {
|
||||
String log;
|
||||
log.reserve(70); // Prevent re-allocation
|
||||
log = F("NEXTION075 : RxD SoftSerial Buffer capacity warning, ");
|
||||
log += String(charCount);
|
||||
log += F(" bytes");
|
||||
@@ -495,16 +522,20 @@ boolean Plugin_075(byte function, struct EventStruct *event, String& string)
|
||||
UserVar[event->BaseVarIndex + 1] = __buffer[3];
|
||||
sendData(event);
|
||||
|
||||
log = F("NEXTION075 : code: ");
|
||||
log += __buffer[1];
|
||||
log += ",";
|
||||
log += __buffer[2];
|
||||
log += ",";
|
||||
log += __buffer[3];
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
#ifdef DEBUG_LOG
|
||||
String log;
|
||||
log.reserve(70); // Prevent re-allocation
|
||||
log = F("NEXTION075 : code: ");
|
||||
log += __buffer[1];
|
||||
log += ",";
|
||||
log += __buffer[2];
|
||||
log += ",";
|
||||
log += __buffer[3];
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (c == '|') {
|
||||
__buffer[0] = c; // Store in staging buffer.
|
||||
@@ -515,7 +546,7 @@ boolean Plugin_075(byte function, struct EventStruct *event, String& string)
|
||||
else charCount = SoftSerial->available();
|
||||
|
||||
if(HwSerial == UARTSERIAL) {
|
||||
i = 1;
|
||||
i = 1;
|
||||
while (Serial.available() > 0 && i<RXBUFFSZ) { // Copy global serial buffer to local buffer.
|
||||
__buffer[i] = Serial.read();
|
||||
if (__buffer[i]==0x0a || __buffer[i]==0x0d) break;
|
||||
@@ -523,7 +554,7 @@ boolean Plugin_075(byte function, struct EventStruct *event, String& string)
|
||||
}
|
||||
}
|
||||
else {
|
||||
i = 1;
|
||||
i = 1;
|
||||
while (SoftSerial->available() > 0 && i<RXBUFFSZ) { // Copy global serial buffer to local buffer.
|
||||
__buffer[i] = SoftSerial->read();
|
||||
if (__buffer[i]==0x0a || __buffer[i]==0x0d) break;
|
||||
@@ -532,11 +563,16 @@ boolean Plugin_075(byte function, struct EventStruct *event, String& string)
|
||||
}
|
||||
|
||||
__buffer[i] = 0x00;
|
||||
|
||||
|
||||
String tmpString = __buffer;
|
||||
log = F("NEXTION075 : code: ");
|
||||
log += tmpString;
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
|
||||
#ifdef DEBUG_LOG
|
||||
String log;
|
||||
log.reserve(50); // Prevent re-allocation
|
||||
log = F("NEXTION075 : Code = ");
|
||||
log += tmpString;
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
#endif
|
||||
|
||||
int argIndex = tmpString.indexOf(F(",i"));
|
||||
int argEnd = tmpString.indexOf(',', argIndex + 1);
|
||||
@@ -568,14 +604,21 @@ boolean Plugin_075(byte function, struct EventStruct *event, String& string)
|
||||
UserVar[event->BaseVarIndex+1] = Svalue.toFloat();
|
||||
sendData(event);
|
||||
|
||||
log = F("NEXTION075 : Pipe Command Sent: ");
|
||||
log += __buffer;
|
||||
log += UserVar[event->BaseVarIndex];
|
||||
#ifdef DEBUG_LOG
|
||||
String log;
|
||||
log.reserve(80); // Prevent re-allocation
|
||||
log = F("NEXTION075 : Pipe Command Sent: ");
|
||||
log += __buffer;
|
||||
log += UserVar[event->BaseVarIndex];
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
log = F("NEXTION075 : Unknown Pipe Command, skipped");
|
||||
#ifdef DEBUG_LOG
|
||||
String log = F("NEXTION075 : Unknown Pipe Command, skipped");
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
#endif
|
||||
}
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
}
|
||||
}
|
||||
if(HwSerial == UARTSERIAL) charCount = Serial.available();
|
||||
@@ -590,7 +633,7 @@ boolean Plugin_075(byte function, struct EventStruct *event, String& string)
|
||||
}
|
||||
|
||||
|
||||
void sendCommand(const char *cmd, boolean SerialMode)
|
||||
void sendCommand(const char *cmd, boolean SerialMode)
|
||||
{
|
||||
if(txPin < 0) {
|
||||
String log = F("NEXTION075 : Missing TxD Pin Number, aborted sendCommand");
|
||||
|
||||
+1
-2
@@ -1252,11 +1252,10 @@ byte PluginCall(byte Function, struct EventStruct *event, String& str)
|
||||
// Schedule the plugin to be read.
|
||||
schedule_task_device_timer_at_init(event->TaskIndex);
|
||||
}
|
||||
if (Function != PLUGIN_GET_DEVICEVALUENAMES) {
|
||||
if (ExtraTaskSettings.TaskIndex != event->TaskIndex) {
|
||||
// LoadTaskSettings may call PLUGIN_GET_DEVICEVALUENAMES.
|
||||
LoadTaskSettings(event->TaskIndex);
|
||||
}
|
||||
|
||||
event->BaseVarIndex = event->TaskIndex * VARS_PER_TASK;
|
||||
checkRAM(F("PluginCall_init"),x);
|
||||
START_TIMER;
|
||||
|
||||
@@ -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