mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-07-28 04:07:47 +00:00
Compare commits
270
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c3bde94f7a | ||
|
|
080be1ad0a | ||
|
|
232ca4f215 | ||
|
|
bfa6eac538 | ||
|
|
5d41bf9e73 | ||
|
|
dc5a2fd956 | ||
|
|
b20f05305b | ||
|
|
46586e5355 | ||
|
|
7e8a751657 | ||
|
|
7d61e55d34 | ||
|
|
2f663429a3 | ||
|
|
492791a4ac | ||
|
|
52e75ade78 | ||
|
|
525a0ba0a1 | ||
|
|
52c7e5012e | ||
|
|
4dd733eb63 | ||
|
|
02a065d623 | ||
|
|
0afee4fafb | ||
|
|
eba1fb3388 | ||
|
|
b2c866edeb | ||
|
|
3583db3e22 | ||
|
|
1a72444b0a | ||
|
|
f613bb4572 | ||
|
|
51059f0c18 | ||
|
|
dec6598f49 | ||
|
|
f8f6767bec | ||
|
|
5c475b98db | ||
|
|
58fb8dc42b | ||
|
|
cb2b11a41a | ||
|
|
ac4f3c4cd4 | ||
|
|
c651e29d2a | ||
|
|
d7e886a841 | ||
|
|
eec7647782 | ||
|
|
6f9d120ff0 | ||
|
|
28ddc2d9c0 | ||
|
|
cc54354ac3 | ||
|
|
3929390629 | ||
|
|
3a26ebf7b1 | ||
|
|
1685bead52 | ||
|
|
3a2fe35e5c | ||
|
|
29ce7f774f | ||
|
|
cc85327356 | ||
|
|
0851bb655e | ||
|
|
d4bc10d8f1 | ||
|
|
0672f32f4b | ||
|
|
a17f7b679c | ||
|
|
425bd85c83 | ||
|
|
3be005e1ee | ||
|
|
174f9e6e03 | ||
|
|
51a14a174f | ||
|
|
7cb1f453d3 | ||
|
|
23a6caab89 | ||
|
|
6b4300bd46 | ||
|
|
04a9069db0 | ||
|
|
dd636903c8 | ||
|
|
940b65e86a | ||
|
|
6344de0649 | ||
|
|
8ccd7c3e8d | ||
|
|
22371649a4 | ||
|
|
2a48d5033e | ||
|
|
f064da797d | ||
|
|
b0b8edf935 | ||
|
|
8cbd9a0822 | ||
|
|
93f9d11738 | ||
|
|
cf3e0a3f0a | ||
|
|
ccfd14dbd3 | ||
|
|
3034738ad4 | ||
|
|
178d1c46a2 | ||
|
|
cdfd1d986e | ||
|
|
4b7aa53692 | ||
|
|
7959a5133f | ||
|
|
941fb5c29c | ||
|
|
c43c9ea2b3 | ||
|
|
967103bcad | ||
|
|
efe637ec70 | ||
|
|
00450eb260 | ||
|
|
cc02fa4481 | ||
|
|
1c5f8af083 | ||
|
|
fccc31a7c6 | ||
|
|
b84d905a0b | ||
|
|
94aa951cba | ||
|
|
2a23dcd011 | ||
|
|
ab3a406706 | ||
|
|
e7a9ee7eee | ||
|
|
3edfdbf5f7 | ||
|
|
27bac2ca00 | ||
|
|
373f74e9f8 | ||
|
|
1220c565c8 | ||
|
|
1931fe9e53 | ||
|
|
0eab6293dc | ||
|
|
f0987dab41 | ||
|
|
51bd52603f | ||
|
|
47f1fa145a | ||
|
|
605055d95a | ||
|
|
af3e353181 | ||
|
|
c711d6ea51 | ||
|
|
20c23a2935 | ||
|
|
bbfe254232 | ||
|
|
882c888f6d | ||
|
|
0a754f072c | ||
|
|
1f084c51cc | ||
|
|
89df0932c5 | ||
|
|
429fd3e4d0 | ||
|
|
85e8d98da8 | ||
|
|
6d52a7e03a | ||
|
|
fa513b52f9 | ||
|
|
f98401524f | ||
|
|
4090b4f23c | ||
|
|
b89c00008d | ||
|
|
d57a617138 | ||
|
|
cefe6b4b7c | ||
|
|
2432740b41 | ||
|
|
44a934651c | ||
|
|
95fb0d6e6c | ||
|
|
8ccbdcadf0 | ||
|
|
433aa6910a | ||
|
|
f135c63d84 | ||
|
|
2ebc733b63 | ||
|
|
21bc1a7814 | ||
|
|
53b8009df6 | ||
|
|
68a8e5982e | ||
|
|
08acfeac97 | ||
|
|
999a561515 | ||
|
|
3ee1a4ed2e | ||
|
|
05801db47c | ||
|
|
7bec632f15 | ||
|
|
3f8fe11b47 | ||
|
|
4b8f1e4c1b | ||
|
|
573fd0f320 | ||
|
|
4fa5203c5b | ||
|
|
9c9617f6ed | ||
|
|
bbbf6c483f | ||
|
|
668909e7b3 | ||
|
|
c642848ef2 | ||
|
|
6eea35aa81 | ||
|
|
738a48213c | ||
|
|
d1c093d109 | ||
|
|
00166a1aad | ||
|
|
589238324b | ||
|
|
6787bc8c0e | ||
|
|
6845a03741 | ||
|
|
6a4284f189 | ||
|
|
cf644b45b1 | ||
|
|
e6fe1c63a9 | ||
|
|
df978036f0 | ||
|
|
7cb375833d | ||
|
|
41c57f1ef9 | ||
|
|
808b40bdba | ||
|
|
58b20615da | ||
|
|
13026b1cc4 | ||
|
|
7f3460e492 | ||
|
|
a222391f81 | ||
|
|
a8165531d5 | ||
|
|
3218ea9839 | ||
|
|
eca8901fca | ||
|
|
6635eafe91 | ||
|
|
fe4d1f952f | ||
|
|
1abd31b421 | ||
|
|
72fe49d905 | ||
|
|
9dd9f3befa | ||
|
|
471d76dbe6 | ||
|
|
4475a225cc | ||
|
|
8b047490c4 | ||
|
|
455f77d0ed | ||
|
|
836fc4a875 | ||
|
|
2aece1c143 | ||
|
|
70df225e7e | ||
|
|
19af52a3ef | ||
|
|
3d396575ff | ||
|
|
873f8474b5 | ||
|
|
826deaac89 | ||
|
|
cce621cff8 | ||
|
|
57eb38dbd0 | ||
|
|
fd2451bb07 | ||
|
|
c94e5cb903 | ||
|
|
27699f7192 | ||
|
|
2eff001b14 | ||
|
|
bd499c7a94 | ||
|
|
4da1e4fbdd | ||
|
|
1d14770ea7 | ||
|
|
8b7574d298 | ||
|
|
14d87d95f6 | ||
|
|
5a15288d80 | ||
|
|
869dff12ce | ||
|
|
cc0b3dac26 | ||
|
|
4208048fc1 | ||
|
|
06a2f47812 | ||
|
|
d3434eb4d2 | ||
|
|
bd2665041f | ||
|
|
1fd429a029 | ||
|
|
7b3a71bcc9 | ||
|
|
18e612dea2 | ||
|
|
f99593ed62 | ||
|
|
2f7e96fa5b | ||
|
|
25b4392dd5 | ||
|
|
ad4130a547 | ||
|
|
e4d4463eab | ||
|
|
991384822f | ||
|
|
b29f56c6f4 | ||
|
|
779514481d | ||
|
|
82ed319e59 | ||
|
|
0a752dd26f | ||
|
|
2e4af86a99 | ||
|
|
8112e0e67a | ||
|
|
89a9f842fd | ||
|
|
b4791d3421 | ||
|
|
885c5394a3 | ||
|
|
e35304e4e7 | ||
|
|
6561d577d4 | ||
|
|
92932fddb2 | ||
|
|
02d8834763 | ||
|
|
e82080dc52 | ||
|
|
89581fd0fb | ||
|
|
cfbf972c1b | ||
|
|
e25ea52edc | ||
|
|
3f84a961ad | ||
|
|
7d8e5e5175 | ||
|
|
3d39dec686 | ||
|
|
ff656593ec | ||
|
|
96bfaa27f5 | ||
|
|
bcca0514dd | ||
|
|
90b4e3438d | ||
|
|
139f8905d0 | ||
|
|
6c1806fae6 | ||
|
|
e6b581e7ff | ||
|
|
bb9f8fc809 | ||
|
|
4d9504bce0 | ||
|
|
ff3a769033 | ||
|
|
e3de56a7a8 | ||
|
|
873d639461 | ||
|
|
edb2a6d3f6 | ||
|
|
2682b0bd2f | ||
|
|
5097157a09 | ||
|
|
02ea957894 | ||
|
|
c2b0d76595 | ||
|
|
91b7cbe075 | ||
|
|
bff60a2e27 | ||
|
|
61831e5962 | ||
|
|
d105b47d44 | ||
|
|
449568bcc4 | ||
|
|
3144077103 | ||
|
|
8f056be0a8 | ||
|
|
e9cdc5693d | ||
|
|
64b38df187 | ||
|
|
377c50ec36 | ||
|
|
76f6dfdc59 | ||
|
|
3a6f7acd15 | ||
|
|
d65b126f84 | ||
|
|
90a2a799da | ||
|
|
feb419b6ae | ||
|
|
e83d8468b0 | ||
|
|
6eabaaa62d | ||
|
|
8299e38b24 | ||
|
|
b0169b4aa7 | ||
|
|
786ec4714a | ||
|
|
67a28a7f97 | ||
|
|
18b8e61d32 | ||
|
|
5821b0709c | ||
|
|
ec783fe03b | ||
|
|
4d749b19fd | ||
|
|
6a66440a5f | ||
|
|
9122565431 | ||
|
|
64a0f79e02 | ||
|
|
92e4a8da9b | ||
|
|
4bca2c6361 | ||
|
|
40e2d7ec8e | ||
|
|
7318e87965 | ||
|
|
9c3a28439f | ||
|
|
eee55a92d9 | ||
|
|
21398fbf8a |
Vendored
+441
@@ -1,3 +1,444 @@
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180403 (since mega-20180402)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Tue Apr 3 04:00:14 CEST 2018
|
||||
|
||||
Grovkillen (2):
|
||||
Update _P038_NeoPixel.ino
|
||||
Update _P029_Output.ino
|
||||
|
||||
mvdbro (1):
|
||||
ESP32 prep for RTOS multitasking
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180402 (since mega-20180401)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Mon Apr 2 04:00:10 CEST 2018
|
||||
|
||||
Gijs Noorlander (1):
|
||||
Revert "Merge pull request #1205 from s0170071/SerialSwap"
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180401 (since mega-20180331)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Sun Apr 1 04:00:08 CEST 2018
|
||||
|
||||
Grovkillen (1):
|
||||
P0059 (rotary encoder) and P0063 (ttp229, keypad)
|
||||
|
||||
TD-er (3):
|
||||
[issue #1201] MQTT#Disconnected event and MQTT stability improvements
|
||||
[issue #1201] MQTT#Disconnected event and MQTT stability improvements
|
||||
[deepsleep] Allow for some minimum wifi connect time
|
||||
|
||||
s0170071 (1):
|
||||
Serial Swap function
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180331 (since mega-20180330)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Sat Mar 31 04:00:09 CEST 2018
|
||||
|
||||
TD-er (2):
|
||||
[Build ESP32] Fix for build issues between ESP32 and ESP8266
|
||||
[ESP32] Build errors/warnings
|
||||
|
||||
mvdbro (1):
|
||||
ESP32: Fix Wifi Disconnect reason
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180330 (since mega-20180329)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Fri Mar 30 04:00:10 CEST 2018
|
||||
|
||||
Gijs Noorlander (1):
|
||||
Build issue with Arduino IDE
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180329 (since mega-20180328)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Thu Mar 29 04:00:11 CEST 2018
|
||||
|
||||
TD-er (2):
|
||||
[ESP32] Event driven WiFi for ESP32
|
||||
[Arduino IDE] Revert changes in include paths
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180328 (since mega-20180327)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Wed Mar 28 04:00:09 CEST 2018
|
||||
|
||||
TD-er (2):
|
||||
[Build] Cleanup/split builds using defines
|
||||
[build] Disabled a few PlatformIO profiles for now.
|
||||
|
||||
mvdbro (1):
|
||||
Fix nesting level check
|
||||
|
||||
soif (1):
|
||||
Initial re-organisation of plugin sets (#1019)
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180327 (since mega-20180326)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Tue Mar 27 04:00:09 CEST 2018
|
||||
|
||||
TD-er (1):
|
||||
[issue #1174] Show degree sign via external writes to LCD
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180326 (since mega-20180324)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Mon Mar 26 04:00:14 CEST 2018
|
||||
|
||||
Bartlomiej Zimon (1):
|
||||
- fix for #1170 - uservar not setted on encwrite
|
||||
|
||||
Brian Setz (1):
|
||||
[P1] Support for latest standard
|
||||
|
||||
TD-er (3):
|
||||
[Command] Parsing improvement for commands
|
||||
[wifi] Event based connect/reconnect
|
||||
[NTP] Speedup NTP again with async WiFi
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180324 (since mega-20180323)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Sat Mar 24 04:00:10 CET 2018
|
||||
|
||||
TD-er (3):
|
||||
[WiFi] Reverted those temp String uses for ssid/pass
|
||||
[issue #1131] Add %unixtime%
|
||||
[issue #1097] Call MQTTclient.loop() during deepsleep
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180323 (since mega-20180322)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Fri Mar 23 04:00:06 CET 2018
|
||||
|
||||
mvdbro (1):
|
||||
ESP32 fix
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180322 (since mega-20180321)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Thu Mar 22 04:00:11 CET 2018
|
||||
|
||||
Bartlomiej Zimon (7):
|
||||
- P012 fix command interpretation
|
||||
- P023 fix command interpretation
|
||||
- P035 move strings to flash
|
||||
- P048 fetch params only when needed
|
||||
- P012 fix command interpretation
|
||||
- P023 fix command interpretation
|
||||
- P048 fetch params only when needed
|
||||
|
||||
ESPEasy release bot (1):
|
||||
automaticly updated release notes for v2.0-20180321
|
||||
|
||||
Gijs Noorlander (1):
|
||||
[merge issue] Forgotten #endif in merge
|
||||
|
||||
TD-er (6):
|
||||
[wifi] Make more robust checks and increase timeout
|
||||
- P035 move strings to flash
|
||||
[wifi] Make more robust checks and increase timeout
|
||||
[Memory] parseTemplate did not check if markers were found
|
||||
[WiFi] Take much more time for initial WiFi connect during setup
|
||||
[WiFi] Take much more time for initial WiFi connect during setup
|
||||
|
||||
Unknown (1):
|
||||
[Memory] parseTemplate did not check if markers were found
|
||||
|
||||
s0170071 (2):
|
||||
Serial WD crash
|
||||
Serial WD crash
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180321 (since mega-20180320)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Wed Mar 21 04:00:08 CET 2018
|
||||
|
||||
ESPEasy release bot (1):
|
||||
automaticly updated release notes for v2.0-20180320
|
||||
|
||||
Unknown (2):
|
||||
[wifi] Setup with factory settings could not complete
|
||||
[wifi] Setup with factory settings could not complete
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180320 (since mega-20180319)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Tue Mar 20 04:00:10 CET 2018
|
||||
|
||||
ESPEasy release bot (1):
|
||||
automaticly updated release notes for v2.0-20180319
|
||||
|
||||
Gijs Noorlander (1):
|
||||
Revert "Merge pull request #1116 from TD-er/feature/allow_own_defaults"
|
||||
|
||||
Unknown (3):
|
||||
Revert "Merge pull request #1116 from TD-er/feature/allow_own_defaults"
|
||||
[issue #1097] WiFi connect with deepsleep enabled trigger watchdog reset
|
||||
[issue #1097] WiFi connect with deepsleep enabled trigger watchdog reset
|
||||
|
||||
es-ka (2):
|
||||
Fix wiring description for SN75176 transceiver
|
||||
Fix wiring description for SN75176 transceiver
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180319 (since mega-20180316)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Mon Mar 19 04:00:11 CET 2018
|
||||
|
||||
Bartlomiej Zimon (5):
|
||||
Add download button for current rule set
|
||||
- add encoder write #1086
|
||||
- fix success setting
|
||||
- fix P073 success setting in PLUGIN_WRITE callback
|
||||
- initialize pointer in P073
|
||||
|
||||
ESPEasy release bot (1):
|
||||
automaticly updated release notes for v2.0-20180316
|
||||
|
||||
Gijs Noorlander (6):
|
||||
Add download button for current rule set (#1102)
|
||||
- add encoder write command #1086 (#1103)
|
||||
Changed so that running all tasks immediately with deep sleep enabled… (#1110)
|
||||
Merge pull request #1112 from uzi18/fix-p073
|
||||
Merge pull request #1114 from TD-er/feature/wifi_details_json
|
||||
Merge pull request #1118 from TD-er/bugfix/mqtt_publish_after_deep_sleep
|
||||
|
||||
Panayotis Kouvarakis (1):
|
||||
Changed so that running all tasks immediately with deep sleep enabled only happens on first iteration after wake up
|
||||
|
||||
Unknown (11):
|
||||
[WiFi] Try to minimize effect of WiFi interruptions
|
||||
[Relaxed WiFi] Perform WiFi initialization in steps
|
||||
[Travis error] Some #include test that wasn't meant to be included
|
||||
[JSON] Add uint name (#1099) and WiFi information (PR #1113)
|
||||
[issue #1007] Allow user specific data in separate file
|
||||
#ifndef instead of #ifdef
|
||||
[issue #1007] Add other defines as suggested by @uzi18
|
||||
[issue #1097] MQTT publish after deep sleep
|
||||
Merge pull request #1113 from TD-er/feature/reduce_impact_wifi_disconnect
|
||||
Merge pull request #1116 from TD-er/feature/allow_own_defaults
|
||||
[merge] MIssing #endif due to merging.
|
||||
|
||||
s0170071 (2):
|
||||
changed memory tracker to uint64_t for the ESP32
|
||||
Keep uint. Just change the init value.
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180316 (since mega-20180315)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Fri Mar 16 04:00:11 CET 2018
|
||||
|
||||
Bartlomiej Zimon (3):
|
||||
- move all structs from ESPEasy.ino into header file - add some fix for headers - add const to rtttl notes array
|
||||
Merge branch 'mega' of github.com:letscontrolit/ESPEasy into mega
|
||||
Merge branch 'mega' of github.com:letscontrolit/ESPEasy into mega
|
||||
|
||||
ESPEasy release bot (1):
|
||||
automaticly updated release notes for v2.0-20180313
|
||||
|
||||
Gijs Noorlander (3):
|
||||
MCP3221 allow values for calibration (#1073)
|
||||
[issue #1066] Fix Webserver handle_control (#1079)
|
||||
Fixed multi instance problem on SHT3x #433 (#1081)
|
||||
|
||||
JK (1):
|
||||
Fixed #433
|
||||
|
||||
Unknown (9):
|
||||
[issue #1066] Fix Webserver handle_control
|
||||
- move all structs from ESPEasy.ino into header file
|
||||
[v2.0 split globals] Base split on v2.0 version of ESPEasy.ino
|
||||
[issue #1057] AM PM display issue
|
||||
[issue #993] variable in MQTT subscribe topic
|
||||
[issue #951] Changed System#Initialized => System#Wake
|
||||
[issue #1057] AM PM display issue
|
||||
[issue #993] variable in MQTT subscribe topic
|
||||
[issue #951] Changed System#Initialized => System#Wake
|
||||
|
||||
mvdbro (4):
|
||||
#893 part1, send messages
|
||||
Custom controller GUI option
|
||||
#893, part 2 receiving
|
||||
Rules fix
|
||||
|
||||
sassod (1):
|
||||
12bit ADC values acceted up to 4095
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180315 (since mega-20180314)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Thu Mar 15 04:00:08 CET 2018
|
||||
|
||||
mvdbro (3):
|
||||
Custom controller GUI option
|
||||
#893, part 2 receiving
|
||||
Rules fix
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180314 (since mega-20180313)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Wed Mar 14 04:00:11 CET 2018
|
||||
|
||||
mvdbro (1):
|
||||
#893 part1, send messages
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180313 (since mega-20180312)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Tue Mar 13 04:00:11 CET 2018
|
||||
|
||||
Bartlomiej Zimon (4):
|
||||
- fix for #1065
|
||||
- remove double trimm()
|
||||
- fix for #1065
|
||||
- remove double trimm()
|
||||
|
||||
ESPEasy release bot (1):
|
||||
automaticly updated release notes for v2.0-20180312
|
||||
|
||||
Unknown (1):
|
||||
Rule Engine minor fix and added dev debugging
|
||||
|
||||
mvdbro (1):
|
||||
ESP32 C010 fix
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180312 (since mega-20180311)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Mon Mar 12 04:00:07 CET 2018
|
||||
|
||||
ESPEasy release bot (1):
|
||||
automaticly updated release notes for v2.0-20180311
|
||||
|
||||
Unknown (4):
|
||||
[issue #1039 ] Change CSS to show topmost SSID on large screens
|
||||
[webserver] Improve chunked transfer
|
||||
[issue #1039 ] Change CSS to show topmost SSID on large screens
|
||||
[webserver] Improve chunked transfer
|
||||
|
||||
mvdbro (1):
|
||||
Rule Engine minor fix and added dev debugging
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180311 (since mega-20180310)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Sun Mar 11 04:00:06 CET 2018
|
||||
|
||||
ESPEasy release bot (2):
|
||||
automaticly updated release notes for v2.0-20180309
|
||||
automaticly updated release notes for v2.0-20180310
|
||||
|
||||
Unknown (19):
|
||||
Move plugin init before WiFi init
|
||||
[Conversions] Use more decimals in conversions and add AM/PM for time.
|
||||
Update P07 Plugin
|
||||
[AM/PM] Am/Pm notation doesn't have '0' hours
|
||||
[P073] Remove tm1637_bitDelay()
|
||||
Improve flash read performance
|
||||
Add read buffer to rule processing to speedup parsing
|
||||
Final ruleset speed-up
|
||||
[AM/PM] Am/Pm notation doesn't have '0' hours
|
||||
Update P07 Plugin
|
||||
[P073] Remove tm1637_bitDelay()
|
||||
[deepsleep] Make sure the 'shortcut' of running all services when sleep enabled
|
||||
[OLED] fix drawProgressBar
|
||||
[deepsleep] Make sure the 'shortcut' of running all services when sleep enabled
|
||||
[OLED] fix drawProgressBar
|
||||
[DNS lookup] Controllers sometimes try to connect to 0.0.0.0
|
||||
[DNS lookup] Controllers sometimes try to connect to 0.0.0.0
|
||||
[issue #1039] Topmost SSID are covered on mobile Browser
|
||||
[issue #1039] Topmost SSID are covered on mobile Browser
|
||||
|
||||
mvdbro (5):
|
||||
Improve flash read performance
|
||||
Rule Engine, stop waisting time on non matching rules
|
||||
Add read buffer to rule processing to speedup parsing
|
||||
Final ruleset speed-up
|
||||
Rule Engine, stop waisting time on non matching rules
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180310 (since mega-20180309)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Sat Mar 10 04:00:07 CET 2018
|
||||
|
||||
Unknown (2):
|
||||
Move plugin init before WiFi init
|
||||
[Conversions] Use more decimals in conversions and add AM/PM for time.
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180309 (since mega-20180308)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Fri Mar 9 04:00:11 CET 2018
|
||||
|
||||
ESPEasy release bot (3):
|
||||
automaticly updated release notes for v2.0-20180305
|
||||
automaticly updated release notes for v2.0-20180306
|
||||
automaticly updated release notes for v2.0-20180307
|
||||
|
||||
Gijs Noorlander (2):
|
||||
Fixes P073 plugin for latest TM1637 based 7 segments displays modules (#996) (#1022)
|
||||
[CSS] Quick fix for smaller displays (#1026)
|
||||
|
||||
Unknown (5):
|
||||
[issue #1012] Removed Content-Length header + improved webserver speed
|
||||
[Rule Events] Add a number of events to handle in rules and awake timer
|
||||
[Rule Events] Add a number of events to handle in rules and awake timer
|
||||
[issue #1015] Add other simple conversions like Celsius to Fahrenheit, etc.
|
||||
[issue #1015] Add other simple conversions like Celsius to Fahrenheit, etc.
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180308 (since mega-20180307)
|
||||
-------------------------------------------------
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# EspESPeasySoftwareSerial
|
||||
# ESPeasySoftwareSerial
|
||||
|
||||
Implementation of the Arduino software serial library for the ESP8266
|
||||
|
||||
@@ -7,5 +7,3 @@ Speed up to 115200 baud is supported. The constructor also has an optional input
|
||||
|
||||
Please note that due to the fact that the ESP always have other activities ongoing, there will be some inexactness in interrupt
|
||||
timings. This may lead to bit errors when having heavy data traffic in high baud rates.
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "EspESPeasySoftwareSerial",
|
||||
"name": "ESPeasySoftwareSerial",
|
||||
"version": "3.3.1",
|
||||
"keywords": [
|
||||
"serial", "io", "softwareserial"
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "SensorSerialBuffer.h"
|
||||
#include "ESPeasySoftwareSerial.h"
|
||||
|
||||
|
||||
class CjkSDS011
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -22,6 +22,10 @@ SOFTWARE.
|
||||
|
||||
See more at http://blog.squix.ch
|
||||
*/
|
||||
|
||||
#ifndef DIALOG_PLAIN_FONT_H
|
||||
#define DIALOG_PLAIN_FONT_H
|
||||
|
||||
// OLED library version >= 3.0.0
|
||||
// Created by http://oleddisplay.squix.ch/ Consider a donation
|
||||
// In case of problems make sure that you are using the font file with the correct version!
|
||||
@@ -481,3 +485,6 @@ const char Dialog_plain_12[] PROGMEM = {
|
||||
0x00,0x00,0xFC,0x7F,0x40,0x04,0x20,0x08,0x20,0x08,0x60,0x0C,0xC0,0x07, // 254
|
||||
0x00,0x00,0xE0,0x40,0x04,0x47,0x00,0x38,0x84,0x07,0xE0 // 255
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -349,7 +349,7 @@ void OLEDDisplay::drawProgressBar(uint16_t x, uint16_t y, uint16_t width, uint16
|
||||
drawHorizontalLine(xRadius, y + height, width - doubleRadius + 1);
|
||||
drawCircleQuads(x + width - radius, yRadius, radius, 0b00001001);
|
||||
|
||||
uint16_t maxProgressWidth = (width - doubleRadius - 1) * progress / 100;
|
||||
uint16_t maxProgressWidth = (width - doubleRadius + 1) * progress / 100;
|
||||
|
||||
fillCircle(xRadius, yRadius, innerRadius);
|
||||
fillRect(xRadius + 1, y + 2, maxProgressWidth, height - 3);
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
#ifndef OLED_SSD1306_SH1106_IMAGES_H
|
||||
#define OLED_SSD1306_SH1106_IMAGES_H
|
||||
|
||||
#define espeasy_logo_width 36
|
||||
#define espeasy_logo_height 36
|
||||
const char espeasy_logo_bits[] PROGMEM= {
|
||||
@@ -38,3 +41,5 @@ const char inactiveSymbole[] PROGMEM = {
|
||||
B00000000,
|
||||
B00000000
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
+476
-128
@@ -7,11 +7,11 @@
|
||||
|
||||
#minimal version for esps with 512K or less flash (only has minimal plugin set)
|
||||
; [env:mini_512]
|
||||
; platform = espressif8266@1.5.0
|
||||
; framework = arduino
|
||||
; platform = ${common.platform}
|
||||
; framework = ${common.framework}
|
||||
; board = esp01
|
||||
; upload_speed=460800
|
||||
; build_flags = !echo -Wl,-Tesp8266.flash.512k64.ld -D BUILD_GIT=\'\"$(git describe)\"\'
|
||||
; upload_speed = ${common.upload_speed}
|
||||
; build_flags = !echo -Wl,-Tesp8266.flash.512k64.ld -D BUILD_GIT=\'\"$(git describe)\"\'
|
||||
; # upload_port = /dev/ttyUSB0
|
||||
|
||||
# add these:
|
||||
@@ -19,150 +19,498 @@
|
||||
# -Wmissing-include-dirs -Wnoexcept -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-promo -Wstrict-null-sentinel
|
||||
# -Wstrict-overflow=5 -Wundef -Wno-unused -Wno-variadic-macros -Wno-parentheses -fdiagnostics-show-option
|
||||
# thanks @chouffe103
|
||||
[compiler_warnings]
|
||||
build_flags =
|
||||
-Wall -Wno-parentheses -fdiagnostics-show-option
|
||||
|
||||
##########################################################################################
|
||||
|
||||
###### Definition cheat sheet:
|
||||
# board_flash_mode in terms of performance: QIO > QOUT > DIO > DOUT
|
||||
# for lib_ldf_mode, see http://docs.platformio.org/en/latest/librarymanager/ldf.html#ldf
|
||||
|
||||
###### Frequently used build flags:
|
||||
# Use custom.h file to override default settings for ESPeasy: -D USE_CUSTOM_H
|
||||
# Set VCC mode to measure Vcc of ESP chip : -D FEATURE_ADC_VCC=true
|
||||
|
||||
[core_2_3_0]
|
||||
platform = espressif8266@1.5.0
|
||||
|
||||
[core_2_4_0]
|
||||
platform = espressif8266@1.6.0
|
||||
|
||||
[core_esp32]
|
||||
#platform = espressif32@0.12.0
|
||||
platform = https://github.com/platformio/platform-espressif32.git#feature/stage
|
||||
build_flags = -D BUILD_GIT='"${env.TRAVIS_TAG}"'
|
||||
lib_ignore = ESPeasySoftwareSerial, EspESPeasySoftwareSerial, AS_BH1750, ESP8266WiFi, ESP8266Ping, ESP8266WebServer, ESP8266HTTPUpdateServer, ESP8266mDNS, IRremoteESP8266, ESPEasy_ESP8266Ping, SerialSensors
|
||||
lib_deps = ESP32WebServer
|
||||
|
||||
|
||||
[common]
|
||||
build_flags = -D BUILD_GIT='"${env.TRAVIS_TAG}"'
|
||||
lib_deps = ""
|
||||
build_flags = -D BUILD_GIT='"${env.TRAVIS_TAG}"' ; ${compiler_warnings.build_flags}
|
||||
lib_deps = ""
|
||||
lib_ignore = ESP32_ping, ESP32WebServer
|
||||
lib_ldf_mode = chain
|
||||
upload_speed = 460800
|
||||
framework = arduino
|
||||
board = esp12e
|
||||
platform = ${core_2_3_0.platform}
|
||||
|
||||
|
||||
#normal version with stable plugins, 1024k version
|
||||
[esp8266_1M]
|
||||
board_flash_mode = dout
|
||||
build_flags = ${common.build_flags} -Wl,-Tesp8266.flash.1m128.ld
|
||||
|
||||
[esp8285_1M]
|
||||
board = esp8285
|
||||
board_flash_mode = ${esp8266_1M.board_flash_mode}
|
||||
build_flags = ${esp8266_1M.build_flags} -DESP8285
|
||||
|
||||
[Sonoff]
|
||||
board = esp01_1m
|
||||
board_flash_mode = ${esp8266_1M.board_flash_mode}
|
||||
build_flags = ${common.build_flags} -Wl,-Tesp8266.flash.1m128.ld
|
||||
|
||||
[espWroom2M]
|
||||
board_flash_mode = dout
|
||||
board = esp_wroom_02
|
||||
build_flags = ${common.build_flags} -Wl,-Tesp8266.flash.2m.ld
|
||||
|
||||
[esp8266_4M]
|
||||
board_flash_mode = dio
|
||||
build_flags = ${common.build_flags} -Wl,-Tesp8266.flash.4m1m.ld
|
||||
|
||||
### ESP32 pre-alpha test build ###########################################################
|
||||
# Very limited build for ESP32, to start testing regular building for ESP32. #
|
||||
# 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:esp32dev]
|
||||
platform = ${core_esp32.platform}
|
||||
board = esp32dev
|
||||
build_flags = ${core_esp32.build_flags} -DPLUGIN_SET_GENERIC_ESP32
|
||||
lib_deps = ${core_esp32.lib_deps}
|
||||
lib_ignore = ${core_esp32.lib_ignore}
|
||||
lib_ldf_mode = ${common.lib_ldf_mode}
|
||||
framework = ${common.framework}
|
||||
upload_speed = ${common.upload_speed}
|
||||
|
||||
### NORMAL (STABLE) ######################################################################
|
||||
# normal version with stable plugins #
|
||||
##########################################################################################
|
||||
|
||||
# NORMAL: 1024k version --------------------------
|
||||
[env:normal_ESP8266_1024]
|
||||
platform = espressif8266@1.5.0
|
||||
lib_deps = ${common.lib_deps}
|
||||
board_flash_mode = dout
|
||||
framework = arduino
|
||||
board = esp12e
|
||||
upload_speed=460800
|
||||
build_flags = ${common.build_flags} -Wl,-Tesp8266.flash.1m128.ld
|
||||
# upload_port = /dev/ttyUSB0
|
||||
platform = ${common.platform}
|
||||
lib_deps = ${common.lib_deps}
|
||||
lib_ignore = ${common.lib_ignore}
|
||||
lib_ldf_mode = ${common.lib_ldf_mode}
|
||||
framework = ${common.framework}
|
||||
upload_speed = ${common.upload_speed}
|
||||
board = ${common.board}
|
||||
board_flash_mode = ${esp8266_1M.board_flash_mode}
|
||||
build_flags = ${esp8266_1M.build_flags}
|
||||
|
||||
[env:normal_ESP8266_1024_DOUT]
|
||||
platform = espressif8266@1.5.0
|
||||
lib_deps = ${common.lib_deps}
|
||||
board_flash_mode = dout
|
||||
framework = arduino
|
||||
board = esp12e
|
||||
upload_speed=460800
|
||||
build_flags = ${common.build_flags} -Wl,-Tesp8266.flash.1m128.ld
|
||||
# upload_port = /dev/ttyUSB0
|
||||
|
||||
#normal version with stable plugins, 4096k version
|
||||
[env:normal_ESP8266_4096]
|
||||
platform = espressif8266@1.5.0
|
||||
lib_deps = ${common.lib_deps}
|
||||
framework = arduino
|
||||
board = esp12e
|
||||
upload_speed=460800
|
||||
build_flags = ${common.build_flags} -Wl,-Tesp8266.flash.4m1m.ld
|
||||
# upload_port = /dev/ttyUSB0
|
||||
|
||||
#normal version with stable plugins, 4096k version for esp8285
|
||||
# NORMAL: 1024k for esp8285 ----------------------
|
||||
[env:normal_ESP8285_1024]
|
||||
platform = espressif8266@1.5.0
|
||||
lib_deps = ${common.lib_deps}
|
||||
board_flash_mode = dout
|
||||
framework = arduino
|
||||
board = esp8285
|
||||
upload_speed=460800
|
||||
build_flags = ${common.build_flags} -Wl,-Tesp8266.flash.1m128.ld -DESP8285
|
||||
# upload_port = /dev/ttyUSB0
|
||||
platform = ${common.platform}
|
||||
lib_deps = ${common.lib_deps}
|
||||
lib_ignore = ${common.lib_ignore}
|
||||
lib_ldf_mode = ${common.lib_ldf_mode}
|
||||
framework = ${common.framework}
|
||||
upload_speed = ${common.upload_speed}
|
||||
board = ${esp8285_1M.board}
|
||||
board_flash_mode = ${esp8285_1M.board_flash_mode}
|
||||
build_flags = ${esp8285_1M.build_flags}
|
||||
|
||||
# NORMAL: 2048k version --------------------------
|
||||
[env:normal_WROOM02_2048]
|
||||
platform = ${common.platform}
|
||||
lib_deps = ${common.lib_deps}
|
||||
lib_ignore = ${common.lib_ignore}
|
||||
lib_ldf_mode = ${common.lib_ldf_mode}
|
||||
framework = ${common.framework}
|
||||
upload_speed = ${common.upload_speed}
|
||||
board = ${espWroom2M.board}
|
||||
board_flash_mode = ${espWroom2M.board_flash_mode}
|
||||
build_flags = ${espWroom2M.build_flags}
|
||||
|
||||
# NORMAL: 4096k version --------------------------
|
||||
[env:normal_ESP8266_4096]
|
||||
platform = ${common.platform}
|
||||
lib_deps = ${common.lib_deps}
|
||||
lib_ignore = ${common.lib_ignore}
|
||||
lib_ldf_mode = ${common.lib_ldf_mode}
|
||||
framework = ${common.framework}
|
||||
upload_speed = ${common.upload_speed}
|
||||
board = ${common.board}
|
||||
board_flash_mode = ${esp8266_4M.board_flash_mode}
|
||||
build_flags = ${esp8266_4M.build_flags}
|
||||
|
||||
|
||||
#version with additional plugins (and dependend code) that are in test-stadium 1024k
|
||||
|
||||
### TESTING ##############################################################################
|
||||
# additional plugins (and dependend code) that are in test-stadium #
|
||||
##########################################################################################
|
||||
|
||||
# TEST: 1024k version ----------------------------
|
||||
[env:test_ESP8266_1024]
|
||||
platform = espressif8266@1.5.0
|
||||
lib_deps = ${common.lib_deps}
|
||||
board_flash_mode = dout
|
||||
framework = arduino
|
||||
board = esp12e
|
||||
upload_speed=460800
|
||||
build_flags = ${common.build_flags} -Wl,-Tesp8266.flash.1m128.ld -D PLUGIN_BUILD_TESTING
|
||||
platform = ${common.platform}
|
||||
lib_deps = ${common.lib_deps}
|
||||
lib_ignore = ${common.lib_ignore}
|
||||
lib_ldf_mode = ${common.lib_ldf_mode}
|
||||
framework = ${common.framework}
|
||||
upload_speed = ${common.upload_speed}
|
||||
board = ${common.board}
|
||||
board_flash_mode = ${esp8266_1M.board_flash_mode}
|
||||
build_flags = ${esp8266_1M.build_flags} -D PLUGIN_BUILD_TESTING
|
||||
|
||||
#version with additional plugins (and dependend code) that are in test-stadium 4096k
|
||||
[env:test_ESP8266_4096]
|
||||
platform = espressif8266@1.5.0
|
||||
lib_deps = ${common.lib_deps}
|
||||
framework = arduino
|
||||
board = esp12e
|
||||
upload_speed=460800
|
||||
build_flags = ${common.build_flags} -Wl,-Tesp8266.flash.4m1m.ld -D PLUGIN_BUILD_TESTING
|
||||
|
||||
[env:test_ESP8266_4096_VCC]
|
||||
platform = espressif8266@1.5.0
|
||||
lib_deps = ${common.lib_deps}
|
||||
framework = arduino
|
||||
board = esp12e
|
||||
upload_speed=460800
|
||||
build_flags = ${common.build_flags} -Wl,-Tesp8266.flash.4m1m.ld -D PLUGIN_BUILD_TESTING -D FEATURE_ADC_VCC=true
|
||||
|
||||
#version with additional plugins (and dependend code) that are in test-stadium 4096k for esp8285
|
||||
# TEST: 1024k for esp8285 ------------------------
|
||||
[env:test_ESP8285_1024]
|
||||
platform = espressif8266@1.5.0
|
||||
lib_deps = ${common.lib_deps}
|
||||
board_flash_mode = dout
|
||||
framework = arduino
|
||||
board = esp8285
|
||||
upload_speed=460800
|
||||
build_flags = ${common.build_flags} -Wl,-Tesp8266.flash.1m128.ld -D PLUGIN_BUILD_TESTING -DESP8285
|
||||
platform = ${common.platform}
|
||||
lib_deps = ${common.lib_deps}
|
||||
lib_ignore = ${common.lib_ignore}
|
||||
lib_ldf_mode = ${common.lib_ldf_mode}
|
||||
framework = ${common.framework}
|
||||
upload_speed = ${common.upload_speed}
|
||||
board_flash_mode = ${esp8285_1M.board_flash_mode}
|
||||
board = ${esp8285_1M.board}
|
||||
build_flags = ${esp8285_1M.build_flags} -D PLUGIN_BUILD_TESTING
|
||||
|
||||
# TEST: 2048k version ----------------------------
|
||||
[env:test_WROOM02_2048]
|
||||
platform = ${common.platform}
|
||||
lib_deps = ${common.lib_deps}
|
||||
lib_ignore = ${common.lib_ignore}
|
||||
lib_ldf_mode = ${common.lib_ldf_mode}
|
||||
framework = ${common.framework}
|
||||
upload_speed = ${common.upload_speed}
|
||||
board_flash_mode = ${espWroom2M.board_flash_mode}
|
||||
board = ${espWroom2M.board}
|
||||
build_flags = ${espWroom2M.build_flags} -D PLUGIN_BUILD_TESTING
|
||||
|
||||
# TEST: 4096k version ----------------------------
|
||||
[env:test_ESP8266_4096]
|
||||
platform = ${common.platform}
|
||||
lib_deps = ${common.lib_deps}
|
||||
lib_ignore = ${common.lib_ignore}
|
||||
lib_ldf_mode = ${common.lib_ldf_mode}
|
||||
framework = ${common.framework}
|
||||
board = ${common.board}
|
||||
upload_speed = ${common.upload_speed}
|
||||
board_flash_mode = ${esp8266_4M.board_flash_mode}
|
||||
build_flags = ${esp8266_4M.build_flags} -D PLUGIN_BUILD_TESTING
|
||||
|
||||
# TEST: 4096k version + FEATURE_ADC_VCC ----------
|
||||
[env:test_ESP8266_4096_VCC]
|
||||
platform = ${common.platform}
|
||||
lib_deps = ${common.lib_deps}
|
||||
lib_ignore = ${common.lib_ignore}
|
||||
lib_ldf_mode = ${common.lib_ldf_mode}
|
||||
framework = ${common.framework}
|
||||
board = ${common.board}
|
||||
upload_speed = ${common.upload_speed}
|
||||
board_flash_mode = ${esp8266_4M.board_flash_mode}
|
||||
build_flags = ${esp8266_4M.build_flags} -D PLUGIN_BUILD_TESTING -D FEATURE_ADC_VCC=true
|
||||
|
||||
|
||||
#version with additional plugins (and dependend code) that is in development (probably broken or incomplete) 1024k
|
||||
|
||||
### DEV ##################################################################################
|
||||
# additional plugins (and dependend code) that is in development (probably broken or incomplete)
|
||||
##########################################################################################
|
||||
|
||||
# DEV : 1024k version ----------------------------
|
||||
[env:dev_ESP8266_1024]
|
||||
platform = espressif8266@1.5.0
|
||||
lib_deps = ${common.lib_deps}
|
||||
board_flash_mode = dout
|
||||
framework = arduino
|
||||
board = esp12e
|
||||
upload_speed=460800
|
||||
build_flags = ${common.build_flags} -Wl,-Tesp8266.flash.1m128.ld -D PLUGIN_BUILD_TESTING -D PLUGIN_BUILD_DEV
|
||||
platform = ${common.platform}
|
||||
lib_deps = ${common.lib_deps}
|
||||
lib_ignore = ${common.lib_ignore}
|
||||
lib_ldf_mode = ${common.lib_ldf_mode}
|
||||
framework = ${common.framework}
|
||||
upload_speed = ${common.upload_speed}
|
||||
board_flash_mode = ${esp8266_1M.board_flash_mode}
|
||||
board = ${common.board}
|
||||
build_flags = ${esp8266_1M.build_flags} -D PLUGIN_BUILD_DEV
|
||||
|
||||
#version with additional plugins (and dependend code) that is in development (probably broken or incomplete) 4096k
|
||||
[env:dev_ESP8266_4096]
|
||||
platform = espressif8266@1.5.0
|
||||
lib_deps = ${common.lib_deps}
|
||||
framework = arduino
|
||||
board = esp12e
|
||||
upload_speed=460800
|
||||
build_flags = ${common.build_flags} -Wl,-Tesp8266.flash.4m1m.ld -D PLUGIN_BUILD_TESTING -D PLUGIN_BUILD_DEV
|
||||
|
||||
#version with additional plugins (and dependend code) that is in development (probably broken or incomplete) 4096k
|
||||
# Use latest ESP8266 core 2.4.0
|
||||
[env:dev_ESP8266_4096_core2_4_0]
|
||||
platform = espressif8266
|
||||
framework = arduino
|
||||
board = esp12e
|
||||
upload_speed=460800
|
||||
build_flags = ${common.build_flags} -Wl,-Tesp8266.flash.4m1m.ld -D PLUGIN_BUILD_TESTING -D PLUGIN_BUILD_DEV
|
||||
|
||||
|
||||
#version with additional plugins (and dependend code) that is in development (probably broken or incomplete) 4096k for esp8285
|
||||
# DEV: 1024k for esp8285 -------------------------
|
||||
[env:dev_ESP8285_1024]
|
||||
platform = espressif8266@1.5.0
|
||||
lib_deps = ${common.lib_deps}
|
||||
board_flash_mode = dout
|
||||
framework = arduino
|
||||
board = esp8285
|
||||
upload_speed=460800
|
||||
build_flags = ${common.build_flags} -Wl,-Tesp8266.flash.1m128.ld -D PLUGIN_BUILD_TESTING -D PLUGIN_BUILD_DEV -DESP8285
|
||||
platform = ${common.platform}
|
||||
lib_deps = ${common.lib_deps}
|
||||
lib_ignore = ${common.lib_ignore}
|
||||
lib_ldf_mode = ${common.lib_ldf_mode}
|
||||
framework = ${common.framework}
|
||||
upload_speed = ${common.upload_speed}
|
||||
board_flash_mode = ${esp8285_1M.board_flash_mode}
|
||||
board = ${esp8285_1M.board}
|
||||
build_flags = ${esp8285_1M.build_flags} -D PLUGIN_BUILD_DEV
|
||||
|
||||
# DEV: 2048k version -----------------------------
|
||||
[env:dev_WROOM02_2048]
|
||||
platform = ${common.platform}
|
||||
lib_deps = ${common.lib_deps}
|
||||
lib_ignore = ${common.lib_ignore}
|
||||
lib_ldf_mode = ${common.lib_ldf_mode}
|
||||
framework = ${common.framework}
|
||||
upload_speed = ${common.upload_speed}
|
||||
board_flash_mode = ${espWroom2M.board_flash_mode}
|
||||
board = ${espWroom2M.board}
|
||||
build_flags = ${espWroom2M.build_flags} -D PLUGIN_BUILD_DEV
|
||||
|
||||
# DEV : 4096k version ----------------------------
|
||||
[env:dev_ESP8266_4096]
|
||||
platform = ${common.platform}
|
||||
lib_deps = ${common.lib_deps}
|
||||
lib_ignore = ${common.lib_ignore}
|
||||
lib_ldf_mode = ${common.lib_ldf_mode}
|
||||
framework = ${common.framework}
|
||||
board = ${common.board}
|
||||
upload_speed = ${common.upload_speed}
|
||||
board_flash_mode = ${esp8266_4M.board_flash_mode}
|
||||
build_flags = ${esp8266_4M.build_flags} -D PLUGIN_BUILD_DEV
|
||||
|
||||
|
||||
|
||||
#special patched version for PUYA flash chips, see https://github.com/letscontrolit/ESPEasy/issues/650
|
||||
### DEV + PUYA ###########################################################################
|
||||
# special patched version for PUYA flash chips, see issue #650 at Github #
|
||||
##########################################################################################
|
||||
|
||||
# DEV+PUYA : 1024k version -----------------------
|
||||
[env:dev_ESP8266PUYA_1024]
|
||||
platform = espressif8266@1.5.0
|
||||
lib_deps = ${common.lib_deps}
|
||||
board_flash_mode = dout
|
||||
framework = arduino
|
||||
board = esp12e
|
||||
upload_speed=460800
|
||||
build_flags = ${common.build_flags} -Wl,-Tesp8266.flash.1m128.ld -D PLUGIN_BUILD_TESTING -D PLUGIN_BUILD_DEV -D FLASH_QUIRK_WRITE_0_TO_1
|
||||
platform = ${common.platform}
|
||||
lib_deps = ${common.lib_deps}
|
||||
lib_ignore = ${common.lib_ignore}
|
||||
lib_ldf_mode = ${common.lib_ldf_mode}
|
||||
framework = ${common.framework}
|
||||
board = ${common.board}
|
||||
upload_speed = ${common.upload_speed}
|
||||
board_flash_mode = ${esp8266_1M.board_flash_mode}
|
||||
build_flags = ${esp8266_1M.build_flags} -D PLUGIN_BUILD_DEV -D FLASH_QUIRK_WRITE_0_TO_1
|
||||
|
||||
#special patched version for PUYA flash chips, see https://github.com/letscontrolit/ESPEasy/issues/650
|
||||
# DEV+PUYA : 1024k version + FEATURE_ADC_VCC -----
|
||||
[env:dev_ESP8266PUYA_1024_VCC]
|
||||
platform = espressif8266@1.5.0
|
||||
lib_deps = ${common.lib_deps}
|
||||
board_flash_mode = dout
|
||||
framework = arduino
|
||||
board = esp12e
|
||||
upload_speed=460800
|
||||
build_flags = ${common.build_flags} -Wl,-Tesp8266.flash.1m128.ld -D PLUGIN_BUILD_TESTING -D PLUGIN_BUILD_DEV -D FLASH_QUIRK_WRITE_0_TO_1 -D FEATURE_ADC_VCC=true
|
||||
platform = ${common.platform}
|
||||
lib_deps = ${common.lib_deps}
|
||||
lib_ignore = ${common.lib_ignore}
|
||||
lib_ldf_mode = ${common.lib_ldf_mode}
|
||||
framework = ${common.framework}
|
||||
board = ${common.board}
|
||||
upload_speed = ${common.upload_speed}
|
||||
board_flash_mode = ${esp8266_1M.board_flash_mode}
|
||||
build_flags = ${esp8266_1M.build_flags} -D PLUGIN_BUILD_DEV -D FLASH_QUIRK_WRITE_0_TO_1 -D FEATURE_ADC_VCC=true
|
||||
|
||||
|
||||
|
||||
|
||||
### HARDWARE SPECIFIC VERSIONS ###########################################################
|
||||
# versions specially designed to fit, and contents only needed plugins for each hardware #
|
||||
##########################################################################################
|
||||
|
||||
# ITEAD Products ################################
|
||||
|
||||
# ITEAD / SONOFF BASIC version ------------------
|
||||
#[env:hard_SONOFF_BASIC]
|
||||
#upload_speed = ${common.upload_speed}
|
||||
#framework = ${common.framework}
|
||||
#platform = ${common.platform}
|
||||
#lib_deps = ${common.lib_deps}
|
||||
lib_ignore = ${common.lib_ignore}
|
||||
#lib_ldf_mode = ${common.lib_ldf_mode}
|
||||
#board_flash_mode = ${Sonoff.board_flash_mode}
|
||||
#board = ${Sonoff.board}
|
||||
#build_flags = ${Sonoff.build_flags} -D PLUGIN_SET_SONOFF_BASIC
|
||||
|
||||
# ITEAD / SONOFF TH10 version -------------------
|
||||
#[env:hard_SONOFF_TH10]
|
||||
#upload_speed = ${common.upload_speed}
|
||||
#framework = ${common.framework}
|
||||
#platform = ${common.platform}
|
||||
#lib_deps = ${common.lib_deps}
|
||||
lib_ignore = ${common.lib_ignore}
|
||||
#lib_ldf_mode = ${common.lib_ldf_mode}
|
||||
#board_flash_mode = ${Sonoff.board_flash_mode}
|
||||
#board = ${Sonoff.board}
|
||||
#build_flags = ${Sonoff.build_flags} -D PLUGIN_SET_SONOFF_TH10
|
||||
|
||||
# ITEAD / SONOFF TH16 version -------------------
|
||||
#[env:hard_SONOFF_TH16]
|
||||
#upload_speed = ${common.upload_speed}
|
||||
#framework = ${common.framework}
|
||||
#platform = ${common.platform}
|
||||
#lib_deps = ${common.lib_deps}
|
||||
lib_ignore = ${common.lib_ignore}
|
||||
#lib_ldf_mode = ${common.lib_ldf_mode}
|
||||
#board_flash_mode = ${Sonoff.board_flash_mode}
|
||||
#board = ${Sonoff.board}
|
||||
#build_flags = ${Sonoff.build_flags} -D PLUGIN_SET_SONOFF_TH16
|
||||
|
||||
# ITEAD / SONOFF POW version --------------------
|
||||
#[env:hard_SONOFF_POW]
|
||||
#upload_speed = ${common.upload_speed}
|
||||
#framework = ${common.framework}
|
||||
#platform = ${common.platform}
|
||||
#lib_deps = ${common.lib_deps}
|
||||
lib_ignore = ${common.lib_ignore}
|
||||
#lib_ldf_mode = ${common.lib_ldf_mode}
|
||||
#board_flash_mode = ${Sonoff.board_flash_mode}
|
||||
#board = ${Sonoff.board}
|
||||
#build_flags = ${Sonoff.build_flags} -D PLUGIN_SET_SONOFF_POW
|
||||
|
||||
# ITEAD / SONOFF S20 version --------------------
|
||||
#[env:hard_SONOFF_S20]
|
||||
#upload_speed = ${common.upload_speed}
|
||||
#framework = ${common.framework}
|
||||
#platform = ${common.platform}
|
||||
#lib_deps = ${common.lib_deps}
|
||||
lib_ignore = ${common.lib_ignore}
|
||||
#lib_ldf_mode = ${common.lib_ldf_mode}
|
||||
#board_flash_mode = ${Sonoff.board_flash_mode}
|
||||
#board = ${Sonoff.board}
|
||||
#build_flags = ${Sonoff.build_flags} -D PLUGIN_SET_SONOFF_S20
|
||||
|
||||
# ITEAD / SONOFF 4CH version --------------------
|
||||
#[env:hard_SONOFF_4CH]
|
||||
#upload_speed = ${common.upload_speed}
|
||||
#framework = ${common.framework}
|
||||
#platform = ${common.platform}
|
||||
#lib_deps = ${common.lib_deps}
|
||||
lib_ignore = ${common.lib_ignore}
|
||||
#lib_ldf_mode = ${common.lib_ldf_mode}
|
||||
#board_flash_mode = ${Sonoff.board_flash_mode}
|
||||
#board = ${Sonoff.board}
|
||||
#build_flags = ${Sonoff.build_flags} -D PLUGIN_SET_SONOFF_4CH
|
||||
|
||||
# ITEAD / SONOFF TOUCH version ------------------
|
||||
#[env:hard_SONOFF_TOUCH]
|
||||
#upload_speed = ${common.upload_speed}
|
||||
#framework = ${common.framework}
|
||||
#platform = ${common.platform}
|
||||
#lib_deps = ${common.lib_deps}
|
||||
lib_ignore = ${common.lib_ignore}
|
||||
#lib_ldf_mode = ${common.lib_ldf_mode}
|
||||
#board_flash_mode = ${Sonoff.board_flash_mode}
|
||||
#board = ${Sonoff.board}
|
||||
#build_flags = ${Sonoff.build_flags} -D PLUGIN_SET_SONOFF_TOUCH
|
||||
|
||||
|
||||
|
||||
# LED Strips #####################################
|
||||
|
||||
# Huacanxing / H801 ------------------------------
|
||||
#[env:hard_HUACANXING_H801]
|
||||
#upload_speed = ${common.upload_speed}
|
||||
#framework = ${common.framework}
|
||||
#platform = ${common.platform}
|
||||
#lib_deps = ${common.lib_deps}
|
||||
lib_ignore = ${common.lib_ignore}
|
||||
#lib_ldf_mode = ${common.lib_ldf_mode}
|
||||
#board_flash_mode = ${esp8266_1M.board_flash_mode}
|
||||
#board = esp01_1m
|
||||
#build_flags = ${esp8266_1M.build_flags} -D PLUGIN_SET_H801
|
||||
|
||||
# MagicHome / Led Controller ---------------------
|
||||
#[env:hard_MAGICHOME]
|
||||
#upload_speed = ${common.upload_speed}
|
||||
#upload_speed = ${common.upload_speed}
|
||||
#framework = ${common.framework}
|
||||
#platform = ${common.platform}
|
||||
#lib_deps = ${common.lib_deps}
|
||||
lib_ignore = ${common.lib_ignore}
|
||||
#lib_ldf_mode = ${common.lib_ldf_mode}
|
||||
#board_flash_mode = ${esp8266_1M.board_flash_mode}
|
||||
#board = esp01_1m
|
||||
#build_flags = ${esp8266_1M.build_flags} -D PLUGIN_SET_MAGICHOME
|
||||
|
||||
# MagicHome / Led Controller with IR -------------
|
||||
#[env:hard_MAGICHOME_IR]
|
||||
#upload_speed = ${common.upload_speed}
|
||||
#framework = ${common.framework}
|
||||
#platform = ${common.platform}
|
||||
#lib_deps = ${common.lib_deps}
|
||||
lib_ignore = ${common.lib_ignore}
|
||||
#lib_ldf_mode = ${common.lib_ldf_mode}
|
||||
#board_flash_mode = ${esp8266_1M.board_flash_mode}
|
||||
#board = esp01_1m
|
||||
#build_flags = ${esp8266_1M.build_flags} -D PLUGIN_SET_MAGICHOME_IR
|
||||
|
||||
|
||||
|
||||
|
||||
### EASY VERSIONS ########################################################################
|
||||
# versions specially designed to be small and cover a specific usage #
|
||||
##########################################################################################
|
||||
|
||||
# Easy Temperature Sensor ------------------------
|
||||
#[env:easy_TEMP]
|
||||
#upload_speed = ${common.upload_speed}
|
||||
#framework = ${common.framework}
|
||||
#platform = ${common.platform}
|
||||
#lib_deps = ${common.lib_deps}
|
||||
lib_ignore = ${common.lib_ignore}
|
||||
#lib_ldf_mode = ${common.lib_ldf_mode}
|
||||
#board_flash_mode = ${esp8266_1M.board_flash_mode}
|
||||
#board = esp01_1m
|
||||
#build_flags = ${esp8266_1M.build_flags} -D PLUGIN_SET_EASY_TEMP
|
||||
|
||||
|
||||
# Easy Carbon Sensor -----------------------------
|
||||
#[env:easy_CARBON]
|
||||
#upload_speed = ${common.upload_speed}
|
||||
#framework = ${common.framework}
|
||||
#platform = ${common.platform}
|
||||
#lib_deps = ${common.lib_deps}
|
||||
lib_ignore = ${common.lib_ignore}
|
||||
#lib_ldf_mode = ${common.lib_ldf_mode}
|
||||
#board_flash_mode = ${esp8266_1M.board_flash_mode}
|
||||
#board = esp01_1m
|
||||
#build_flags = ${esp8266_1M.build_flags} -D PLUGIN_SET_EASY_CARBON
|
||||
|
||||
## Easy Nextion ----------------------------------
|
||||
##PLUGIN_SET_EASY_NEXTION
|
||||
|
||||
# Easy OLED Display v1 ---------------------------
|
||||
#[env:easy_OLED_V1]
|
||||
#upload_speed = ${common.upload_speed}
|
||||
#framework = ${common.framework}
|
||||
#platform = ${common.platform}
|
||||
#lib_deps = ${common.lib_deps}
|
||||
lib_ignore = ${common.lib_ignore}
|
||||
#lib_ldf_mode = ${common.lib_ldf_mode}
|
||||
#board_flash_mode = ${esp8266_1M.board_flash_mode}
|
||||
#board = esp01_1m
|
||||
#build_flags = ${esp8266_1M.build_flags} -D PLUGIN_SET_EASY_OLED1
|
||||
|
||||
# Easy OLED Display v2 ---------------------------
|
||||
#[env:easy_OLED_V2]
|
||||
#upload_speed = ${common.upload_speed}
|
||||
#framework = ${common.framework}
|
||||
#platform = ${common.platform}
|
||||
#lib_deps = ${common.lib_deps}
|
||||
lib_ignore = ${common.lib_ignore}
|
||||
#lib_ldf_mode = ${common.lib_ldf_mode}
|
||||
#board_flash_mode = ${esp8266_1M.board_flash_mode}
|
||||
#board = esp01_1m
|
||||
#build_flags = ${esp8266_1M.build_flags} -D PLUGIN_SET_EASY_OLED2
|
||||
|
||||
# Easy Relay Switch ------------------------------
|
||||
#[env:easy_OLED_V2]
|
||||
#upload_speed = ${common.upload_speed}
|
||||
#framework = ${common.framework}
|
||||
#platform = ${common.platform}
|
||||
#lib_deps = ${common.lib_deps}
|
||||
lib_ignore = ${common.lib_ignore}
|
||||
#lib_ldf_mode = ${common.lib_ldf_mode}
|
||||
#board_flash_mode = ${esp8266_1M.board_flash_mode}
|
||||
#board = esp01_1m
|
||||
#build_flags = ${esp8266_1M.build_flags} -D PLUGIN_SET_EASY_RELAY
|
||||
|
||||
# Easy Generic (1M) device ----------------------
|
||||
#[env:easy_GENERIC_1M]
|
||||
#upload_speed = ${common.upload_speed}
|
||||
#framework = ${common.framework}
|
||||
#platform = ${common.platform}
|
||||
#lib_deps = ${common.lib_deps}
|
||||
lib_ignore = ${common.lib_ignore}
|
||||
#lib_ldf_mode = ${common.lib_ldf_mode}
|
||||
#board_flash_mode = ${esp8266_1M.board_flash_mode}
|
||||
#board = esp01_1m
|
||||
#build_flags = ${esp8266_1M.build_flags} -D PLUGIN_SET_GENERIC_1M
|
||||
|
||||
+304
-126
@@ -38,31 +38,146 @@ bool safeReadStringUntil(Stream &input, String &str, char terminator, unsigned i
|
||||
|
||||
}
|
||||
|
||||
|
||||
#define INPUT_COMMAND_SIZE 80
|
||||
Command commandStringToEnum(const char * cmd) {
|
||||
String tmpcmd;
|
||||
tmpcmd = cmd;
|
||||
tmpcmd.toLowerCase();
|
||||
char cmd_lc[INPUT_COMMAND_SIZE];
|
||||
tmpcmd.toCharArray(cmd_lc, tmpcmd.length() + 1);
|
||||
switch (cmd_lc[0]) {
|
||||
case 'a': {
|
||||
if (strcmp_P(cmd_lc, PSTR("accessinfo") ) == 0) return cmd_accessinfo;
|
||||
break;
|
||||
}
|
||||
case 'b': {
|
||||
if (strcmp_P(cmd_lc, PSTR("background") ) == 0) return cmd_background;
|
||||
else if (strcmp_P(cmd_lc, PSTR("blynkget") ) == 0) return cmd_BlynkGet;
|
||||
else if (strcmp_P(cmd_lc, PSTR("build") ) == 0) return cmd_build;
|
||||
break;
|
||||
}
|
||||
case 'c': {
|
||||
if (strcmp_P(cmd_lc, PSTR("clearaccessblock") ) == 0) return cmd_clearaccessblock;
|
||||
else if (strcmp_P(cmd_lc, PSTR("clearrtcram") ) == 0) return cmd_clearRTCRAM;
|
||||
else if (strcmp_P(cmd_lc, PSTR("config") ) == 0) return cmd_config;
|
||||
break;
|
||||
}
|
||||
case 'd': {
|
||||
if (strcmp_P(cmd_lc, PSTR("debug") ) == 0) return cmd_Debug;
|
||||
else if (strcmp_P(cmd_lc, PSTR("delay") ) == 0) return cmd_Delay;
|
||||
else if (strcmp_P(cmd_lc, PSTR("deepsleep") ) == 0) return cmd_deepSleep;
|
||||
break;
|
||||
}
|
||||
case 'e': {
|
||||
if (strcmp_P(cmd_lc, PSTR("erase") ) == 0) return cmd_Erase;
|
||||
else if (strcmp_P(cmd_lc, PSTR("event") ) == 0) return cmd_Event;
|
||||
else if (strcmp_P(cmd_lc, PSTR("executerules") ) == 0) return cmd_executeRules;
|
||||
break;
|
||||
}
|
||||
case 'i': {
|
||||
if (strcmp_P(cmd_lc, PSTR("i2cscanner") ) == 0) return cmd_i2cscanner;
|
||||
else if (strcmp_P(cmd_lc, PSTR("ip") ) == 0) return cmd_IP;
|
||||
break;
|
||||
}
|
||||
case 'l': {
|
||||
if (strcmp_P(cmd_lc, PSTR("load") ) == 0) return cmd_Load;
|
||||
else if (strcmp_P(cmd_lc, PSTR("lowmem") ) == 0) return cmd_lowmem;
|
||||
break;
|
||||
}
|
||||
case 'm': {
|
||||
if (strcmp_P(cmd_lc, PSTR("malloc") ) == 0) return cmd_malloc;
|
||||
else if (strcmp_P(cmd_lc, PSTR("meminfo") ) == 0) return cmd_meminfo;
|
||||
break;
|
||||
}
|
||||
case 'n': {
|
||||
if (strcmp_P(cmd_lc, PSTR("name") ) == 0) return cmd_Name;
|
||||
else if (strcmp_P(cmd_lc, PSTR("notify") ) == 0) return cmd_notify;
|
||||
else if (strcmp_P(cmd_lc, PSTR("nosleep") ) == 0) return cmd_NoSleep;
|
||||
break;
|
||||
}
|
||||
case 'p': {
|
||||
if (strcmp_P(cmd_lc, PSTR("password") ) == 0) return cmd_Password;
|
||||
else if (strcmp_P(cmd_lc, PSTR("publish") ) == 0) return cmd_Publish;
|
||||
break;
|
||||
}
|
||||
case 'r': {
|
||||
if (strcmp_P(cmd_lc, PSTR("reboot") ) == 0) return cmd_Reboot;
|
||||
else if (strcmp_P(cmd_lc, PSTR("reset") ) == 0) return cmd_Reset;
|
||||
else if (strcmp_P(cmd_lc, PSTR("restart") ) == 0) return cmd_Restart;
|
||||
else if (strcmp_P(cmd_lc, PSTR("resetflashwritecounter")) == 0) return cmd_resetFlashWriteCounter;
|
||||
else if (strcmp_P(cmd_lc, PSTR("rules") ) == 0) return cmd_Rules;
|
||||
break;
|
||||
}
|
||||
case 's': {
|
||||
if (strcmp_P(cmd_lc, PSTR("sdcard") ) == 0) return cmd_sdcard;
|
||||
else if (strcmp_P(cmd_lc, PSTR("sdremove") ) == 0) return cmd_sdremove;
|
||||
else if (strcmp_P(cmd_lc, PSTR("sysload") ) == 0) return cmd_sysload;
|
||||
else if (strcmp_P(cmd_lc, PSTR("save") ) == 0) return cmd_Save;
|
||||
else if (strcmp_P(cmd_lc, PSTR("sendto") ) == 0) return cmd_SendTo;
|
||||
else if (strcmp_P(cmd_lc, PSTR("sendtohttp") ) == 0) return cmd_SendToHTTP;
|
||||
else if (strcmp_P(cmd_lc, PSTR("sendtoudp") ) == 0) return cmd_SendToUDP;
|
||||
else if (strcmp_P(cmd_lc, PSTR("serialfloat") ) == 0) return cmd_SerialFloat;
|
||||
else if (strcmp_P(cmd_lc, PSTR("settings") ) == 0) return cmd_Settings;
|
||||
break;
|
||||
}
|
||||
case 't': {
|
||||
if (strcmp_P(cmd_lc, PSTR("taskclear") ) == 0) return cmd_TaskClear;
|
||||
else if (strcmp_P(cmd_lc, PSTR("taskclearall") ) == 0) return cmd_TaskClearAll;
|
||||
else if (strcmp_P(cmd_lc, PSTR("taskrun") ) == 0) return cmd_TaskRun;
|
||||
else if (strcmp_P(cmd_lc, PSTR("taskvalueset") ) == 0) return cmd_TaskValueSet;
|
||||
else if (strcmp_P(cmd_lc, PSTR("timerset") ) == 0) return cmd_TimerSet;
|
||||
break;
|
||||
}
|
||||
case 'u': {
|
||||
if (strcmp_P(cmd_lc, PSTR("udptest") ) == 0) return cmd_udptest;
|
||||
else if (strcmp_P(cmd_lc, PSTR("unit") ) == 0) return cmd_Unit;
|
||||
break;
|
||||
}
|
||||
case 'w': {
|
||||
if (strcmp_P(cmd_lc, PSTR("wdconfig") ) == 0) return cmd_wdconfig;
|
||||
else if (strcmp_P(cmd_lc, PSTR("wdread") ) == 0) return cmd_wdread;
|
||||
else if (strcmp_P(cmd_lc, PSTR("wifiapmode") ) == 0) return cmd_WifiAPMode;
|
||||
else if (strcmp_P(cmd_lc, PSTR("wificonnect") ) == 0) return cmd_WifiConnect;
|
||||
else if (strcmp_P(cmd_lc, PSTR("wifidisconnect") ) == 0) return cmd_WifiDisconnect;
|
||||
else if (strcmp_P(cmd_lc, PSTR("wifikey2") ) == 0) return cmd_WifiKey2;
|
||||
else if (strcmp_P(cmd_lc, PSTR("wifikey") ) == 0) return cmd_WifiKey;
|
||||
else if (strcmp_P(cmd_lc, PSTR("wifissid2") ) == 0) return cmd_WifiSSID2;
|
||||
else if (strcmp_P(cmd_lc, PSTR("wifissid") ) == 0) return cmd_WifiSSID;
|
||||
else if (strcmp_P(cmd_lc, PSTR("wifiscan") ) == 0) return cmd_WifiScan;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return cmd_Unknown;
|
||||
}
|
||||
return cmd_Unknown;
|
||||
}
|
||||
|
||||
void ExecuteCommand(byte source, const char *Line)
|
||||
{
|
||||
checkRAM(F("ExecuteCommand"));
|
||||
String status = "";
|
||||
boolean success = false;
|
||||
char TmpStr1[80];
|
||||
char TmpStr1[INPUT_COMMAND_SIZE];
|
||||
TmpStr1[0] = 0;
|
||||
char Command[80];
|
||||
Command[0] = 0;
|
||||
char cmd[INPUT_COMMAND_SIZE];
|
||||
cmd[0] = 0;
|
||||
int Par1 = 0;
|
||||
int Par2 = 0;
|
||||
int Par3 = 0;
|
||||
|
||||
GetArgv(Line, Command, 1);
|
||||
GetArgv(Line, cmd, 1);
|
||||
if (GetArgv(Line, TmpStr1, 2)) Par1 = str2int(TmpStr1);
|
||||
if (GetArgv(Line, TmpStr1, 3)) Par2 = str2int(TmpStr1);
|
||||
if (GetArgv(Line, TmpStr1, 4)) Par3 = str2int(TmpStr1);
|
||||
|
||||
const Command cmd_enum = commandStringToEnum(cmd);
|
||||
switch (cmd_enum) {
|
||||
|
||||
// ****************************************
|
||||
// commands for debugging
|
||||
// ****************************************
|
||||
|
||||
if (strcasecmp_P(Command, PSTR("background")) == 0)
|
||||
case cmd_background:
|
||||
{
|
||||
success = true;
|
||||
unsigned long timer = millis() + Par1;
|
||||
@@ -70,9 +185,10 @@ void ExecuteCommand(byte source, const char *Line)
|
||||
while (!timeOutReached(timer))
|
||||
backgroundtasks();
|
||||
Serial.println("end");
|
||||
break;
|
||||
}
|
||||
|
||||
if (strcasecmp_P(Command, PSTR("executeRules")) == 0)
|
||||
case cmd_executeRules:
|
||||
{
|
||||
success = true;
|
||||
if (GetArgv(Line, TmpStr1, 2))
|
||||
@@ -81,15 +197,17 @@ void ExecuteCommand(byte source, const char *Line)
|
||||
String event = "";
|
||||
rulesProcessingFile(fileName, event);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (strcasecmp_P(Command, PSTR("clearRTCRAM")) == 0)
|
||||
case cmd_clearRTCRAM:
|
||||
{
|
||||
success = true;
|
||||
initRTC();
|
||||
break;
|
||||
}
|
||||
|
||||
if (strcasecmp_P(Command, PSTR("notify")) == 0)
|
||||
case cmd_notify:
|
||||
{
|
||||
success = true;
|
||||
String message = "";
|
||||
@@ -110,15 +228,17 @@ void ExecuteCommand(byte source, const char *Line)
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (strcasecmp_P(Command, PSTR("resetFlashWriteCounter")) == 0)
|
||||
case cmd_resetFlashWriteCounter:
|
||||
{
|
||||
success = true;
|
||||
RTC.flashDayCounter = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (strcasecmp_P(Command, PSTR("udptest")) == 0)
|
||||
case cmd_udptest:
|
||||
{
|
||||
success = true;
|
||||
for (byte x = 0; x < Par2; x++)
|
||||
@@ -127,18 +247,20 @@ void ExecuteCommand(byte source, const char *Line)
|
||||
event += x;
|
||||
SendUDPCommand(Par1, (char*)event.c_str(), event.length());
|
||||
}
|
||||
break;
|
||||
}
|
||||
#ifdef FEATURE_SD
|
||||
if (strcasecmp_P(Command, PSTR("sdcard")) == 0)
|
||||
case cmd_sdcard:
|
||||
{
|
||||
success = true;
|
||||
File root = SD.open("/");
|
||||
root.rewindDirectory();
|
||||
printDirectory(root, 0);
|
||||
root.close();
|
||||
break;
|
||||
}
|
||||
|
||||
if (strcasecmp_P(Command, PSTR("sdremove")) == 0)
|
||||
case cmd_sdremove:
|
||||
{
|
||||
success = true;
|
||||
String fname = Line;
|
||||
@@ -146,56 +268,63 @@ void ExecuteCommand(byte source, const char *Line)
|
||||
Serial.print(F("Removing:"));
|
||||
Serial.println(fname.c_str());
|
||||
SD.remove((char*)fname.c_str());
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (strcasecmp_P(Command, PSTR("lowmem")) == 0)
|
||||
case cmd_lowmem:
|
||||
{
|
||||
Serial.print(lowestRAM);
|
||||
Serial.print(F(" : "));
|
||||
Serial.println(lowestRAMfunction);
|
||||
success = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (strcasecmp_P(Command, PSTR("malloc")) == 0)
|
||||
case cmd_malloc:
|
||||
{
|
||||
ramtest = (char *)malloc(Par1);
|
||||
success = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (strcasecmp_P(Command, PSTR("sysload")) == 0)
|
||||
case cmd_sysload:
|
||||
{
|
||||
success = true;
|
||||
Serial.print(100 - (100 * loopCounterLast / loopCounterMax));
|
||||
Serial.print(F("% (LC="));
|
||||
Serial.print(int(loopCounterLast / 30));
|
||||
Serial.println(F(")"));
|
||||
break;
|
||||
}
|
||||
|
||||
if (strcasecmp_P(Command, PSTR("SerialFloat")) == 0)
|
||||
case cmd_SerialFloat:
|
||||
{
|
||||
success = true;
|
||||
pinMode(1, INPUT);
|
||||
pinMode(3, INPUT);
|
||||
delay(60000);
|
||||
break;
|
||||
}
|
||||
|
||||
if (strcasecmp_P(Command, PSTR("accessinfo")) == 0)
|
||||
case cmd_accessinfo:
|
||||
{
|
||||
success = true;
|
||||
Serial.print(F("Allowed IP range : "));
|
||||
Serial.println(describeAllowedIPrange());
|
||||
break;
|
||||
}
|
||||
|
||||
if (strcasecmp_P(Command, PSTR("clearaccessblock")) == 0)
|
||||
case cmd_clearaccessblock:
|
||||
{
|
||||
success = true;
|
||||
clearAccessBlock();
|
||||
Serial.print(F("Allowed IP range : "));
|
||||
Serial.println(describeAllowedIPrange());
|
||||
break;
|
||||
}
|
||||
|
||||
if (strcasecmp_P(Command, PSTR("meminfo")) == 0)
|
||||
case cmd_meminfo:
|
||||
{
|
||||
success = true;
|
||||
Serial.print(F("SecurityStruct : "));
|
||||
@@ -206,32 +335,36 @@ void ExecuteCommand(byte source, const char *Line)
|
||||
Serial.println(sizeof(ExtraTaskSettings));
|
||||
Serial.print(F("DeviceStruct: "));
|
||||
Serial.println(sizeof(Device));
|
||||
break;
|
||||
}
|
||||
|
||||
if (strcasecmp_P(Command, PSTR("TaskClear")) == 0)
|
||||
case cmd_TaskClear:
|
||||
{
|
||||
success = true;
|
||||
taskClear(Par1 - 1, true);
|
||||
break;
|
||||
}
|
||||
|
||||
//quickly clear all tasks, without saving (used by test suite)
|
||||
if (strcasecmp_P(Command, PSTR("TaskClearAll")) == 0)
|
||||
case cmd_TaskClearAll:
|
||||
{
|
||||
success = true;
|
||||
for (byte t=0; t<TASKS_MAX; t++)
|
||||
taskClear(t, false);
|
||||
break;
|
||||
}
|
||||
|
||||
if (strcasecmp_P(Command, PSTR("wdconfig")) == 0)
|
||||
case cmd_wdconfig:
|
||||
{
|
||||
success = true;
|
||||
Wire.beginTransmission(Par1); // address
|
||||
Wire.write(Par2); // command
|
||||
Wire.write(Par3); // data
|
||||
Wire.endTransmission();
|
||||
break;
|
||||
}
|
||||
|
||||
if (strcasecmp_P(Command, PSTR("wdread")) == 0)
|
||||
case cmd_wdread:
|
||||
{
|
||||
success = true;
|
||||
Wire.beginTransmission(Par1); // address
|
||||
@@ -245,22 +378,25 @@ void ExecuteCommand(byte source, const char *Line)
|
||||
status = F("Reg value: ");
|
||||
status += value;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (strcasecmp_P(Command, PSTR("build")) == 0)
|
||||
case cmd_build:
|
||||
{
|
||||
success = true;
|
||||
Settings.Build = Par1;
|
||||
SaveSettings();
|
||||
break;
|
||||
}
|
||||
|
||||
if (strcasecmp_P(Command, PSTR("NoSleep")) == 0)
|
||||
case cmd_NoSleep:
|
||||
{
|
||||
success = true;
|
||||
Settings.deepSleep = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (strcasecmp_P(Command, PSTR("i2cscanner")) == 0)
|
||||
case cmd_i2cscanner:
|
||||
{
|
||||
success = true;
|
||||
|
||||
@@ -280,28 +416,31 @@ void ExecuteCommand(byte source, const char *Line)
|
||||
Serial.println(String(address, HEX));
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// ****************************************
|
||||
// commands for rules
|
||||
// ****************************************
|
||||
|
||||
if (strcasecmp_P(Command, PSTR("config")) == 0)
|
||||
case cmd_config:
|
||||
{
|
||||
success = true;
|
||||
struct EventStruct TempEvent;
|
||||
String request = Line;
|
||||
remoteConfig(&TempEvent, request);
|
||||
break;
|
||||
}
|
||||
|
||||
if (strcasecmp_P(Command, PSTR("deepSleep")) == 0)
|
||||
case cmd_deepSleep:
|
||||
{
|
||||
success = true;
|
||||
if (Par1 > 0)
|
||||
deepSleepStart(Par1); // call the second part of the function to avoid check and enable one-shot operation
|
||||
break;
|
||||
}
|
||||
|
||||
if (strcasecmp_P(Command, PSTR("TaskValueSet")) == 0)
|
||||
case cmd_TaskValueSet:
|
||||
{
|
||||
success = true;
|
||||
if (GetArgv(Line, TmpStr1, 4))
|
||||
@@ -310,15 +449,17 @@ void ExecuteCommand(byte source, const char *Line)
|
||||
Calculate(TmpStr1, &result);
|
||||
UserVar[(VARS_PER_TASK * (Par1 - 1)) + Par2 - 1] = result;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (strcasecmp_P(Command, PSTR("TaskRun")) == 0)
|
||||
case cmd_TaskRun:
|
||||
{
|
||||
success = true;
|
||||
SensorSendTask(Par1 - 1);
|
||||
break;
|
||||
}
|
||||
|
||||
if (strcasecmp_P(Command, PSTR("TimerSet")) == 0)
|
||||
case cmd_TimerSet:
|
||||
{
|
||||
if (Par1>=1 && Par1<=RULES_TIMER_MAX)
|
||||
{
|
||||
@@ -334,24 +475,27 @@ void ExecuteCommand(byte source, const char *Line)
|
||||
{
|
||||
addLog(LOG_LEVEL_ERROR, F("TIMER: invalid timer number"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (strcasecmp_P(Command, PSTR("Delay")) == 0)
|
||||
case cmd_Delay:
|
||||
{
|
||||
success = true;
|
||||
delayBackground(Par1);
|
||||
break;
|
||||
}
|
||||
|
||||
if (strcasecmp_P(Command, PSTR("Rules")) == 0)
|
||||
case cmd_Rules:
|
||||
{
|
||||
success = true;
|
||||
if (Par1 == 1)
|
||||
Settings.UseRules = true;
|
||||
else
|
||||
Settings.UseRules = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (strcasecmp_P(Command, PSTR("Event")) == 0)
|
||||
case cmd_Event:
|
||||
{
|
||||
success = true;
|
||||
String event = Line;
|
||||
@@ -359,9 +503,10 @@ void ExecuteCommand(byte source, const char *Line)
|
||||
event.replace("$", "#");
|
||||
if (Settings.UseRules)
|
||||
rulesProcessing(event);
|
||||
break;
|
||||
}
|
||||
|
||||
if (strcasecmp_P(Command, PSTR("SendTo")) == 0)
|
||||
case cmd_SendTo:
|
||||
{
|
||||
success = true;
|
||||
String event = Line;
|
||||
@@ -372,78 +517,88 @@ void ExecuteCommand(byte source, const char *Line)
|
||||
event = event.substring(index + 1);
|
||||
SendUDPCommand(Par1, (char*)event.c_str(), event.length());
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (strcasecmp_P(Command, PSTR("Publish")) == 0 && WiFi.status() == WL_CONNECTED)
|
||||
case cmd_Publish:
|
||||
{
|
||||
// ToDo TD-er: Not sure about this function, but at least it sends to an existing MQTTclient
|
||||
int enabledMqttController = firstEnabledMQTTController();
|
||||
if (enabledMqttController >= 0) {
|
||||
if (wifiStatus == ESPEASY_WIFI_SERVICES_INITIALIZED) {
|
||||
// ToDo TD-er: Not sure about this function, but at least it sends to an existing MQTTclient
|
||||
int enabledMqttController = firstEnabledMQTTController();
|
||||
if (enabledMqttController >= 0) {
|
||||
success = true;
|
||||
String event = Line;
|
||||
event = event.substring(8);
|
||||
int index = event.indexOf(',');
|
||||
if (index > 0)
|
||||
{
|
||||
String topic = event.substring(0, index);
|
||||
String value = event.substring(index + 1);
|
||||
MQTTpublish(enabledMqttController, topic.c_str(), value.c_str(), Settings.MQTTRetainFlag);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case cmd_SendToUDP:
|
||||
{
|
||||
if (wifiStatus == ESPEASY_WIFI_SERVICES_INITIALIZED) {
|
||||
success = true;
|
||||
String event = Line;
|
||||
event = event.substring(8);
|
||||
int index = event.indexOf(',');
|
||||
if (index > 0)
|
||||
String strLine = Line;
|
||||
String ip = parseString(strLine, 2);
|
||||
String port = parseString(strLine, 3);
|
||||
int msgpos = getParamStartPos(strLine, 4);
|
||||
String message = strLine.substring(msgpos);
|
||||
IPAddress UDP_IP;
|
||||
if(UDP_IP.fromString(ip)) {
|
||||
portUDP.beginPacket(UDP_IP, port.toInt());
|
||||
#if defined(ESP8266)
|
||||
portUDP.write(message.c_str(), message.length());
|
||||
#endif
|
||||
#if defined(ESP32)
|
||||
portUDP.write((uint8_t*)message.c_str(), message.length());
|
||||
#endif
|
||||
portUDP.endPacket();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case cmd_SendToHTTP:
|
||||
{
|
||||
if (wifiStatus == ESPEASY_WIFI_SERVICES_INITIALIZED) {
|
||||
success = true;
|
||||
String strLine = Line;
|
||||
String host = parseString(strLine, 2);
|
||||
String port = parseString(strLine, 3);
|
||||
int pathpos = getParamStartPos(strLine, 4);
|
||||
String path = strLine.substring(pathpos);
|
||||
WiFiClient client;
|
||||
if (client.connect(host.c_str(), port.toInt()))
|
||||
{
|
||||
String topic = event.substring(0, index);
|
||||
String value = event.substring(index + 1);
|
||||
MQTTpublish(enabledMqttController, topic.c_str(), value.c_str(), Settings.MQTTRetainFlag);
|
||||
client.print(String("GET ") + path + " HTTP/1.1\r\n" +
|
||||
"Host: " + host + "\r\n" +
|
||||
"Connection: close\r\n\r\n");
|
||||
|
||||
unsigned long timer = millis() + 200;
|
||||
while (!client.available() && !timeOutReached(timer))
|
||||
delay(1);
|
||||
|
||||
while (client.available()) {
|
||||
// String line = client.readStringUntil('\n');
|
||||
String line;
|
||||
safeReadStringUntil(client, line, '\n');
|
||||
|
||||
|
||||
if (line.substring(0, 15) == F("HTTP/1.1 200 OK"))
|
||||
addLog(LOG_LEVEL_DEBUG, line);
|
||||
delay(1);
|
||||
}
|
||||
client.flush();
|
||||
client.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (strcasecmp_P(Command, PSTR("SendToUDP")) == 0 && WiFi.status() == WL_CONNECTED)
|
||||
{
|
||||
success = true;
|
||||
String strLine = Line;
|
||||
String ip = parseString(strLine, 2);
|
||||
String port = parseString(strLine, 3);
|
||||
int msgpos = getParamStartPos(strLine, 4);
|
||||
String message = strLine.substring(msgpos);
|
||||
IPAddress UDP_IP;
|
||||
if(UDP_IP.fromString(ip)) {
|
||||
portUDP.beginPacket(UDP_IP, port.toInt());
|
||||
#if defined(ESP8266)
|
||||
portUDP.write(message.c_str(), message.length());
|
||||
#endif
|
||||
#if defined(ESP32)
|
||||
portUDP.write((uint8_t*)message.c_str(), message.length());
|
||||
#endif
|
||||
portUDP.endPacket();
|
||||
}
|
||||
}
|
||||
|
||||
if (strcasecmp_P(Command, PSTR("SendToHTTP")) == 0 && WiFi.status() == WL_CONNECTED)
|
||||
{
|
||||
success = true;
|
||||
String strLine = Line;
|
||||
String host = parseString(strLine, 2);
|
||||
String port = parseString(strLine, 3);
|
||||
int pathpos = getParamStartPos(strLine, 4);
|
||||
String path = strLine.substring(pathpos);
|
||||
WiFiClient client;
|
||||
if (client.connect(host.c_str(), port.toInt()))
|
||||
{
|
||||
client.print(String("GET ") + path + " HTTP/1.1\r\n" +
|
||||
"Host: " + host + "\r\n" +
|
||||
"Connection: close\r\n\r\n");
|
||||
|
||||
unsigned long timer = millis() + 200;
|
||||
while (!client.available() && !timeOutReached(timer))
|
||||
delay(1);
|
||||
|
||||
while (client.available()) {
|
||||
// String line = client.readStringUntil('\n');
|
||||
String line;
|
||||
safeReadStringUntil(client, line, '\n');
|
||||
|
||||
|
||||
if (line.substring(0, 15) == F("HTTP/1.1 200 OK"))
|
||||
addLog(LOG_LEVEL_DEBUG, line);
|
||||
delay(1);
|
||||
}
|
||||
client.flush();
|
||||
client.stop();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// ****************************************
|
||||
@@ -452,7 +607,7 @@ void ExecuteCommand(byte source, const char *Line)
|
||||
|
||||
#ifdef CPLUGIN_012
|
||||
//FIXME: this should go to PLUGIN_WRITE in _C012.ino
|
||||
if (strcasecmp_P(Command, PSTR("BlynkGet")) == 0)
|
||||
case cmd_BlynkGet:
|
||||
{
|
||||
byte first_enabled_blynk_controller = firstEnabledBlynkController();
|
||||
if (first_enabled_blynk_controller == -1) {
|
||||
@@ -481,80 +636,91 @@ void ExecuteCommand(byte source, const char *Line)
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
// ****************************************
|
||||
// configure settings commands
|
||||
// ****************************************
|
||||
if (strcasecmp_P(Command, PSTR("WifiSSID")) == 0)
|
||||
case cmd_WifiSSID:
|
||||
{
|
||||
success = true;
|
||||
strcpy(SecuritySettings.WifiSSID, Line + 9);
|
||||
break;
|
||||
}
|
||||
|
||||
if (strcasecmp_P(Command, PSTR("WifiKey")) == 0)
|
||||
case cmd_WifiKey:
|
||||
{
|
||||
success = true;
|
||||
strcpy(SecuritySettings.WifiKey, Line + 8);
|
||||
break;
|
||||
}
|
||||
|
||||
if (strcasecmp_P(Command, PSTR("WifiSSID2")) == 0)
|
||||
case cmd_WifiSSID2:
|
||||
{
|
||||
success = true;
|
||||
strcpy(SecuritySettings.WifiSSID2, Line + 10);
|
||||
break;
|
||||
}
|
||||
|
||||
if (strcasecmp_P(Command, PSTR("WifiKey2")) == 0)
|
||||
case cmd_WifiKey2:
|
||||
{
|
||||
success = true;
|
||||
strcpy(SecuritySettings.WifiKey2, Line + 9);
|
||||
break;
|
||||
}
|
||||
|
||||
if (strcasecmp_P(Command, PSTR("WifiScan")) == 0)
|
||||
case cmd_WifiScan:
|
||||
{
|
||||
success = true;
|
||||
WifiScan();
|
||||
break;
|
||||
}
|
||||
|
||||
if (strcasecmp_P(Command, PSTR("WifiConnect")) == 0)
|
||||
case cmd_WifiConnect:
|
||||
{
|
||||
success = true;
|
||||
WifiConnect(1);
|
||||
WiFiConnectRelaxed();
|
||||
break;
|
||||
}
|
||||
|
||||
if (strcasecmp_P(Command, PSTR("WifiDisconnect")) == 0)
|
||||
case cmd_WifiDisconnect:
|
||||
{
|
||||
success = true;
|
||||
WifiDisconnect();
|
||||
break;
|
||||
}
|
||||
|
||||
if (strcasecmp_P(Command, PSTR("WifiAPMode")) == 0)
|
||||
case cmd_WifiAPMode:
|
||||
{
|
||||
WifiAPMode(true);
|
||||
success = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (strcasecmp_P(Command, PSTR("Unit")) == 0)
|
||||
case cmd_Unit:
|
||||
{
|
||||
success = true;
|
||||
Settings.Unit=Par1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (strcasecmp_P(Command, PSTR("Name")) == 0)
|
||||
case cmd_Name:
|
||||
{
|
||||
success = true;
|
||||
strcpy(Settings.Name, Line + 5);
|
||||
break;
|
||||
}
|
||||
|
||||
if (strcasecmp_P(Command, PSTR("Password")) == 0)
|
||||
case cmd_Password:
|
||||
{
|
||||
success = true;
|
||||
strcpy(SecuritySettings.Password, Line + 9);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (strcasecmp_P(Command, PSTR("Reboot")) == 0)
|
||||
case cmd_Reboot:
|
||||
{
|
||||
success = true;
|
||||
pinMode(0, INPUT);
|
||||
@@ -566,22 +732,26 @@ void ExecuteCommand(byte source, const char *Line)
|
||||
#if defined(ESP32)
|
||||
ESP.restart();
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
if (strcasecmp_P(Command, PSTR("Restart")) == 0)
|
||||
case cmd_Restart:
|
||||
{
|
||||
success = true;
|
||||
ESP.restart();
|
||||
break;
|
||||
}
|
||||
if (strcasecmp_P(Command, PSTR("Erase")) == 0)
|
||||
|
||||
case cmd_Erase:
|
||||
{
|
||||
success = true;
|
||||
WiFi.persistent(true); // use SDK storage of SSID/WPA parameters
|
||||
WiFi.disconnect(); // this will store empty ssid/wpa into sdk storage
|
||||
WiFi.persistent(false); // Do not use SDK storage of SSID/WPA parameters
|
||||
break;
|
||||
}
|
||||
|
||||
if (strcasecmp_P(Command, PSTR("Reset")) == 0)
|
||||
case cmd_Reset:
|
||||
{
|
||||
success = true;
|
||||
ResetFactory();
|
||||
@@ -591,37 +761,41 @@ void ExecuteCommand(byte source, const char *Line)
|
||||
#if defined(ESP32)
|
||||
ESP.restart();
|
||||
#endif
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (strcasecmp_P(Command, PSTR("Save")) == 0)
|
||||
case cmd_Save:
|
||||
{
|
||||
success = true;
|
||||
SaveSettings();
|
||||
break;
|
||||
}
|
||||
|
||||
if (strcasecmp_P(Command, PSTR("Load")) == 0)
|
||||
case cmd_Load:
|
||||
{
|
||||
success = true;
|
||||
LoadSettings();
|
||||
break;
|
||||
}
|
||||
|
||||
if (strcasecmp_P(Command, PSTR("Debug")) == 0)
|
||||
case cmd_Debug:
|
||||
{
|
||||
success = true;
|
||||
Settings.SerialLogLevel = Par1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (strcasecmp_P(Command, PSTR("IP")) == 0)
|
||||
case cmd_IP:
|
||||
{
|
||||
success = true;
|
||||
if (GetArgv(Line, TmpStr1, 2)) {
|
||||
if (!str2ip(TmpStr1, Settings.IP))
|
||||
Serial.println("?");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (strcasecmp_P(Command, PSTR("Settings")) == 0)
|
||||
case cmd_Settings:
|
||||
{
|
||||
success = true;
|
||||
char str[20];
|
||||
@@ -639,6 +813,10 @@ void ExecuteCommand(byte source, const char *Line)
|
||||
Serial.print(F(" WifiSSID2 : ")); Serial.println(SecuritySettings.WifiSSID2);
|
||||
Serial.print(F(" WifiKey2 : ")); Serial.println(SecuritySettings.WifiKey2);
|
||||
Serial.print(F(" Free mem : ")); Serial.println(FreeMem());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
success = false;
|
||||
}
|
||||
|
||||
yield();
|
||||
|
||||
+10
-8
@@ -8,9 +8,6 @@ void sendData(struct EventStruct *event)
|
||||
if (Settings.UseRules)
|
||||
createRuleEvents(event->TaskIndex);
|
||||
|
||||
if (Settings.GlobalSync && Settings.TaskDeviceGlobalSync[event->TaskIndex])
|
||||
SendUDPTaskData(0, event->TaskIndex, event->TaskIndex);
|
||||
|
||||
if (Settings.UseValueLogger && Settings.InitSPI && Settings.Pin_sd_cs >= 0)
|
||||
SendValueLogger(event->TaskIndex);
|
||||
|
||||
@@ -123,8 +120,10 @@ bool MQTTConnect(int controller_idx)
|
||||
LoadControllerSettings(controller_idx, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
if (!ControllerSettings.checkHostReachable(true))
|
||||
return false;
|
||||
if (MQTTclient.connected())
|
||||
if (MQTTclient.connected()) {
|
||||
MQTTclient.disconnect();
|
||||
updateMQTTclient_connected();
|
||||
}
|
||||
if (ControllerSettings.UseDNS) {
|
||||
MQTTclient.setServer(ControllerSettings.getHost().c_str(), ControllerSettings.Port);
|
||||
} else {
|
||||
@@ -138,7 +137,7 @@ bool MQTTConnect(int controller_idx)
|
||||
|
||||
String LWTTopic = ControllerSettings.Subscribe;
|
||||
LWTTopic.replace(F("/#"), F("/status"));
|
||||
LWTTopic.replace(F("%sysname%"), Settings.Name);
|
||||
parseSystemVariables(LWTTopic, false);
|
||||
LWTTopic += F("/LWT"); // Extend the topic for status updates of connected/disconnected status.
|
||||
|
||||
boolean MQTTresult = false;
|
||||
@@ -169,6 +168,7 @@ bool MQTTConnect(int controller_idx)
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
|
||||
if (MQTTclient.publish(LWTTopic.c_str(), "Connected", 1)) {
|
||||
updateMQTTclient_connected();
|
||||
statusLED(true);
|
||||
return true; // end loop if succesfull
|
||||
}
|
||||
@@ -181,15 +181,17 @@ bool MQTTConnect(int controller_idx)
|
||||
\*********************************************************************************************/
|
||||
bool MQTTCheck(int controller_idx)
|
||||
{
|
||||
if (!WiFiConnected(10)) {
|
||||
return false;
|
||||
}
|
||||
byte ProtocolIndex = getProtocolIndex(Settings.Protocol[controller_idx]);
|
||||
if (Protocol[ProtocolIndex].usesMQTT)
|
||||
{
|
||||
if (MQTTclient_should_reconnect || !WiFiConnected(10) || !MQTTclient.connected())
|
||||
if (MQTTclient_should_reconnect || !MQTTclient.connected())
|
||||
{
|
||||
if (MQTTclient_should_reconnect) {
|
||||
addLog(LOG_LEVEL_ERROR, F("MQTT : Intentional reconnect"));
|
||||
} else {
|
||||
addLog(LOG_LEVEL_ERROR, F("MQTT : Connection lost"));
|
||||
connectionFailures += 2;
|
||||
}
|
||||
return MQTTConnect(controller_idx);
|
||||
@@ -242,7 +244,7 @@ void MQTTStatus(String& status)
|
||||
LoadControllerSettings(enabledMqttController, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
String pubname = ControllerSettings.Subscribe;
|
||||
pubname.replace(F("/#"), F("/status"));
|
||||
pubname.replace(F("%sysname%"), Settings.Name);
|
||||
parseSystemVariables(pubname, false);
|
||||
MQTTpublish(enabledMqttController, pubname.c_str(), status.c_str(),Settings.MQTTRetainFlag);
|
||||
}
|
||||
}
|
||||
|
||||
+163
@@ -0,0 +1,163 @@
|
||||
|
||||
/*********************************************************************************************\
|
||||
Convert bearing in degree to bearing string
|
||||
\*********************************************************************************************/
|
||||
|
||||
String getBearing(int degrees)
|
||||
{
|
||||
const __FlashStringHelper* bearing[] = {
|
||||
F("N"),
|
||||
F("NNE"),
|
||||
F("NE"),
|
||||
F("ENE"),
|
||||
F("E"),
|
||||
F("ESE"),
|
||||
F("SE"),
|
||||
F("SSE"),
|
||||
F("S"),
|
||||
F("SSW"),
|
||||
F("SW"),
|
||||
F("WSW"),
|
||||
F("W"),
|
||||
F("WNW"),
|
||||
F("NW"),
|
||||
F("NNW")
|
||||
};
|
||||
int nr_directions = (int) (sizeof(bearing)/sizeof(bearing[0]));
|
||||
float stepsize = (360.0 / nr_directions);
|
||||
if (degrees < 0) { degrees += 360; } // Allow for bearing -360 .. 359
|
||||
int bearing_idx=int((degrees + (stepsize / 2.0)) / stepsize) % nr_directions;
|
||||
if (bearing_idx < 0)
|
||||
return("");
|
||||
else
|
||||
return(bearing[bearing_idx]);
|
||||
}
|
||||
|
||||
float CelsiusToFahrenheit(float celsius) {
|
||||
return celsius * (9.0 / 5.0) + 32;
|
||||
}
|
||||
|
||||
int m_secToBeaufort(float m_per_sec) {
|
||||
if (m_per_sec < 0.3) return 0;
|
||||
if (m_per_sec < 1.6) return 1;
|
||||
if (m_per_sec < 3.4) return 2;
|
||||
if (m_per_sec < 5.5) return 3;
|
||||
if (m_per_sec < 8.0) return 4;
|
||||
if (m_per_sec < 10.8) return 5;
|
||||
if (m_per_sec < 13.9) return 6;
|
||||
if (m_per_sec < 17.2) return 7;
|
||||
if (m_per_sec < 20.8) return 8;
|
||||
if (m_per_sec < 24.5) return 9;
|
||||
if (m_per_sec < 28.5) return 10;
|
||||
if (m_per_sec < 32.6) return 11;
|
||||
return 12;
|
||||
}
|
||||
|
||||
String centimeterToImperialLength(float cm) {
|
||||
return millimeterToImperialLength(cm * 10.0);
|
||||
}
|
||||
|
||||
String millimeterToImperialLength(float mm) {
|
||||
float inches = mm / 25.4;
|
||||
int feet = inches /12;
|
||||
inches = inches - (feet * 12);
|
||||
String result;
|
||||
result.reserve(10);
|
||||
if (feet != 0) {
|
||||
result += feet;
|
||||
result += '\'';
|
||||
}
|
||||
result += toString(inches,1);
|
||||
result += '"';
|
||||
return result;
|
||||
}
|
||||
|
||||
float minutesToDay(int minutes) {
|
||||
return minutes / 1440.0;
|
||||
}
|
||||
|
||||
String minutesToDayHour(int minutes) {
|
||||
int days = minutes / 1440;
|
||||
int hours = (minutes % 1440) / 60;
|
||||
char TimeString[6]; //5 digits plus the null char
|
||||
sprintf_P(TimeString, PSTR("%d%c%02d%c"), days, 'd', hours, 'h');
|
||||
return TimeString;
|
||||
}
|
||||
|
||||
String minutesToHourMinute(int minutes) {
|
||||
int hours = (minutes % 1440) / 60;
|
||||
int mins = (minutes % 1440) % 60;
|
||||
char TimeString[20];
|
||||
sprintf_P(TimeString, PSTR("%d%c%02d%c"), hours, 'h', mins, 'm');
|
||||
return TimeString;
|
||||
}
|
||||
|
||||
String minutesToDayHourMinute(int minutes) {
|
||||
int days = minutes / 1440;
|
||||
int hours = (minutes % 1440) / 60;
|
||||
int mins = (minutes % 1440) % 60;
|
||||
char TimeString[20];
|
||||
sprintf_P(TimeString, PSTR("%d%c%02d%c%02d%c"), days, 'd', hours, 'h', mins, 'm');
|
||||
return TimeString;
|
||||
}
|
||||
|
||||
String secondsToDayHourMinuteSecond(int seconds) {
|
||||
int sec = seconds % 60;
|
||||
int minutes = seconds / 60;
|
||||
int days = minutes / 1440;
|
||||
int hours = (minutes % 1440) / 60;
|
||||
int mins = (minutes % 1440) % 60;
|
||||
char TimeString[20];
|
||||
sprintf_P(TimeString, PSTR("%d%c%02d%c%02d%c%02d"), days, 'd', hours, ':', mins, ':', sec);
|
||||
return TimeString;
|
||||
}
|
||||
|
||||
String format_msec_duration(long duration) {
|
||||
String result;
|
||||
if (duration < 0) {
|
||||
result = "-";
|
||||
duration = -1 * duration;
|
||||
}
|
||||
if (duration < 10000) {
|
||||
result += duration;
|
||||
result += F(" ms");
|
||||
return result;
|
||||
}
|
||||
duration /= 1000;
|
||||
if (duration < 3600) {
|
||||
int sec = duration % 60;
|
||||
int minutes = duration / 60;
|
||||
if (minutes > 0) {
|
||||
result += minutes;
|
||||
result += F(" m ");
|
||||
}
|
||||
result += sec;
|
||||
result += F(" s");
|
||||
return result;
|
||||
}
|
||||
duration /= 60;
|
||||
if (duration < 1440) return minutesToHourMinute(duration);
|
||||
return minutesToDayHourMinute(duration);
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************************************\
|
||||
In memory convert float to long
|
||||
\*********************************************************************************************/
|
||||
unsigned long float2ul(float f)
|
||||
{
|
||||
unsigned long ul;
|
||||
memcpy(&ul, &f, 4);
|
||||
return ul;
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************************************\
|
||||
In memory convert long to float
|
||||
\*********************************************************************************************/
|
||||
float ul2float(unsigned long ul)
|
||||
{
|
||||
float f;
|
||||
memcpy(&f, &ul, 4);
|
||||
return f;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
+147
-1115
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,6 @@
|
||||
#ifndef ESPEASY_TIMETYPES_H_
|
||||
#define ESPEASY_TIMETYPES_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
struct timeStruct {
|
||||
@@ -59,3 +62,9 @@ struct TimeChangeRule {
|
||||
void applyTimeZone(uint32_t curTime = 0);
|
||||
void setTimeZone(const TimeChangeRule& dstStart, const TimeChangeRule& stdStart, uint32_t curTime = 0);
|
||||
uint32_t calcTimeChangeForRule(const TimeChangeRule& r, int yr);
|
||||
String getTimeString(char delimiter, bool show_seconds=true);
|
||||
String getTimeString_ampm(char delimiter, bool show_seconds=true);
|
||||
long timeDiff(unsigned long prev, unsigned long next);
|
||||
|
||||
|
||||
#endif /* ESPEASY_TIMETYPES_H_ */
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
//********************************************************************************
|
||||
// Functions called on events.
|
||||
// Make sure not to call anything in these functions that result in delay() or yield()
|
||||
//********************************************************************************
|
||||
#ifdef ESP32
|
||||
void WiFiEvent(system_event_id_t event, system_event_info_t info) {
|
||||
switch(event) {
|
||||
case SYSTEM_EVENT_STA_CONNECTED:
|
||||
lastConnectMoment = millis();
|
||||
processedConnect = false;
|
||||
wifiStatus = ESPEASY_WIFI_CONNECTED;
|
||||
break;
|
||||
case SYSTEM_EVENT_STA_DISCONNECTED:
|
||||
lastDisconnectMoment = millis();
|
||||
if (timeDiff(lastConnectMoment, last_wifi_connect_attempt_moment) > 0) {
|
||||
// There was an unsuccessful connection attempt
|
||||
lastConnectedDuration = timeDiff(last_wifi_connect_attempt_moment, lastDisconnectMoment);
|
||||
} else {
|
||||
lastConnectedDuration = timeDiff(lastConnectMoment, lastDisconnectMoment);
|
||||
}
|
||||
processedDisconnect = false;
|
||||
lastDisconnectReason = static_cast<WiFiDisconnectReason>(info.disconnected.reason);
|
||||
wifiStatus = ESPEASY_WIFI_DISCONNECTED;
|
||||
break;
|
||||
case SYSTEM_EVENT_STA_GOT_IP:
|
||||
lastGetIPmoment = millis();
|
||||
wifiStatus = ESPEASY_WIFI_GOT_IP;
|
||||
processedGetIP = false;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
||||
void onConnected(const WiFiEventStationModeConnected& event){
|
||||
lastConnectMoment = millis();
|
||||
processedConnect = false;
|
||||
wifiStatus = ESPEASY_WIFI_CONNECTED;
|
||||
last_channel = event.channel;
|
||||
last_ssid = event.ssid;
|
||||
bssid_changed = false;
|
||||
for (byte i=0; i < 6; ++i) {
|
||||
if (lastBSSID[i] != event.bssid[i]) {
|
||||
bssid_changed = true;
|
||||
lastBSSID[i] = event.bssid[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void onDisconnect(const WiFiEventStationModeDisconnected& event){
|
||||
lastDisconnectMoment = millis();
|
||||
if (timeDiff(lastConnectMoment, last_wifi_connect_attempt_moment) > 0) {
|
||||
// There was an unsuccessful connection attempt
|
||||
lastConnectedDuration = timeDiff(last_wifi_connect_attempt_moment, lastDisconnectMoment);
|
||||
} else
|
||||
lastConnectedDuration = timeDiff(lastConnectMoment, lastDisconnectMoment);
|
||||
processedDisconnect = false;
|
||||
lastDisconnectReason = event.reason;
|
||||
wifiStatus = ESPEASY_WIFI_DISCONNECTED;
|
||||
}
|
||||
|
||||
void onGotIP(const WiFiEventStationModeGotIP& event){
|
||||
lastGetIPmoment = millis();
|
||||
wifiStatus = ESPEASY_WIFI_GOT_IP;
|
||||
processedGetIP = false;
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,522 @@
|
||||
|
||||
|
||||
//********************************************************************************
|
||||
// Functions to process the data gathered from the events.
|
||||
// These functions are called from Setup() or Loop() and thus may call delay() or yield()
|
||||
//********************************************************************************
|
||||
void processConnect() {
|
||||
if (processedConnect) return;
|
||||
if (wifiStatus < ESPEASY_WIFI_CONNECTED) return;
|
||||
|
||||
String log = F("WIFI : Connected! AP: ");
|
||||
log += WiFi.SSID();
|
||||
log += F(" (");
|
||||
log += WiFi.BSSIDstr();
|
||||
log += F(") Ch: ");
|
||||
log += last_channel;
|
||||
const long connect_duration = timeDiff(last_wifi_connect_attempt_moment, lastConnectMoment);
|
||||
if (connect_duration > 0 && connect_duration < 30000) {
|
||||
// Just log times when they make sense.
|
||||
log += F(" Duration: ");
|
||||
log += connect_duration;
|
||||
log += F(" ms");
|
||||
}
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
|
||||
if (Settings.UseRules && bssid_changed) {
|
||||
String event = F("WiFi#ChangedAccesspoint");
|
||||
rulesProcessing(event);
|
||||
}
|
||||
wifi_connect_attempt = 0;
|
||||
processedConnect = true;
|
||||
}
|
||||
|
||||
void processDisconnect() {
|
||||
if (processedDisconnect) return;
|
||||
if (Settings.UseRules) {
|
||||
String event = F("WiFi#Disconnected");
|
||||
rulesProcessing(event);
|
||||
}
|
||||
String log = F("WIFI : Disconnected! Reason: '");
|
||||
log += getLastDisconnectReason();
|
||||
log += F("'");
|
||||
if (lastConnectedDuration > 0) {
|
||||
log += F(" Connected for ");
|
||||
log += format_msec_duration(lastConnectedDuration);
|
||||
}
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
processedDisconnect = true;
|
||||
|
||||
if (Settings.deepSleep && Settings.deepSleepOnFail) {
|
||||
//only one attempt in deepsleep, to conserve battery
|
||||
addLog(LOG_LEVEL_ERROR, F("SLEEP: Connection failed, going back to sleep."));
|
||||
deepSleep(Settings.Delay);
|
||||
}
|
||||
|
||||
if (!intent_to_reboot)
|
||||
WiFiConnectRelaxed();
|
||||
}
|
||||
|
||||
|
||||
void processGotIP() {
|
||||
if (processedGetIP)
|
||||
return;
|
||||
if (wifiStatus < ESPEASY_WIFI_GOT_IP)
|
||||
return;
|
||||
IPAddress ip = WiFi.localIP();
|
||||
const IPAddress gw = WiFi.gatewayIP();
|
||||
const IPAddress subnet = WiFi.subnetMask();
|
||||
String log = F("WIFI : ");
|
||||
if (useStaticIP()) {
|
||||
log += F("Static IP: ");
|
||||
} else {
|
||||
log += F("DHCP IP: ");
|
||||
}
|
||||
log += formatIP(ip);
|
||||
log += F(" (");
|
||||
log += WifiGetHostname();
|
||||
log += F(") GW: ");
|
||||
log += formatIP(gw);
|
||||
log += F(" SN: ");
|
||||
log += formatIP(subnet);
|
||||
|
||||
const long dhcp_duration = timeDiff(lastConnectMoment, lastGetIPmoment);
|
||||
if (dhcp_duration > 0 && dhcp_duration < 30000) {
|
||||
// Just log times when they make sense.
|
||||
log += F(" duration: ");
|
||||
log += dhcp_duration;
|
||||
log += F(" ms");
|
||||
}
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
|
||||
// fix octet?
|
||||
if (Settings.IP_Octet != 0 && Settings.IP_Octet != 255)
|
||||
{
|
||||
ip[3] = Settings.IP_Octet;
|
||||
log = F("IP : Fixed IP octet:");
|
||||
log += formatIP(ip);
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
WiFi.config(ip, gw, subnet);
|
||||
}
|
||||
|
||||
#ifdef FEATURE_MDNS
|
||||
|
||||
log = F("WIFI : ");
|
||||
if (MDNS.begin(WifiGetHostname().c_str(), WiFi.localIP())) {
|
||||
|
||||
log += F("mDNS started, with name: ");
|
||||
log += WifiGetHostname();
|
||||
log += F(".local");
|
||||
}
|
||||
else{
|
||||
log += F("mDNS failed");
|
||||
}
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
#endif
|
||||
|
||||
// First try to get the time, since that may be used in logs
|
||||
if (Settings.UseNTP) {
|
||||
initTime();
|
||||
}
|
||||
timermqtt_interval = 100;
|
||||
timermqtt = millis() + timermqtt_interval;
|
||||
if (Settings.UseRules)
|
||||
{
|
||||
String event = F("WiFi#Connected");
|
||||
rulesProcessing(event);
|
||||
}
|
||||
statusLED(true);
|
||||
wifiStatus = ESPEASY_WIFI_SERVICES_INITIALIZED;
|
||||
processedGetIP = true;
|
||||
}
|
||||
|
||||
void resetWiFi() {
|
||||
WiFiMode_t currentMode = WiFi.getMode();
|
||||
WiFi.mode(WIFI_OFF);
|
||||
WiFi.mode(currentMode);
|
||||
lastDisconnectMoment = millis();
|
||||
processedDisconnect = false;
|
||||
wifiStatus = ESPEASY_WIFI_DISCONNECTED;
|
||||
}
|
||||
|
||||
|
||||
//********************************************************************************
|
||||
// Determine Wifi AP name to set. (also used for mDNS)
|
||||
//********************************************************************************
|
||||
String WifiGetAPssid()
|
||||
{
|
||||
String ssid(Settings.Name);
|
||||
ssid+=F("-");
|
||||
ssid+=Settings.Unit;
|
||||
return (ssid);
|
||||
}
|
||||
|
||||
//********************************************************************************
|
||||
// Determine hostname: basically WifiGetAPssid with spaces changed to -
|
||||
//********************************************************************************
|
||||
String WifiGetHostname()
|
||||
{
|
||||
String hostname(WifiGetAPssid());
|
||||
hostname.replace(F(" "), F("-"));
|
||||
hostname.replace(F("_"), F("-")); // See RFC952
|
||||
return (hostname);
|
||||
}
|
||||
|
||||
|
||||
//********************************************************************************
|
||||
// Set Wifi AP Mode config
|
||||
//********************************************************************************
|
||||
void WifiAPconfig()
|
||||
{
|
||||
// create and store unique AP SSID/PW to prevent ESP from starting AP mode with default SSID and No password!
|
||||
// setup ssid for AP Mode when needed
|
||||
|
||||
String softAPSSID=WifiGetAPssid();
|
||||
String pwd = SecuritySettings.WifiAPKey;
|
||||
WiFi.softAP(softAPSSID.c_str(),pwd.c_str());
|
||||
// We start in STA mode
|
||||
WifiAPMode(false);
|
||||
|
||||
String log("WIFI : AP Mode ssid will be ");
|
||||
log=log+WifiGetAPssid();
|
||||
|
||||
log=log+F(" with address ");
|
||||
log=log+apIP.toString();
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
}
|
||||
|
||||
|
||||
bool WifiIsAP()
|
||||
{
|
||||
#if defined(ESP8266)
|
||||
byte wifimode = wifi_get_opmode();
|
||||
#endif
|
||||
#if defined(ESP32)
|
||||
byte wifimode = WiFi.getMode();
|
||||
#endif
|
||||
return(wifimode == 2 || wifimode == 3); //apmode is enabled
|
||||
}
|
||||
|
||||
//********************************************************************************
|
||||
// Set Wifi AP Mode
|
||||
//********************************************************************************
|
||||
void WifiAPMode(boolean state)
|
||||
{
|
||||
if (WifiIsAP())
|
||||
{
|
||||
//want to disable?
|
||||
if (!state)
|
||||
{
|
||||
WiFi.mode(WIFI_STA);
|
||||
addLog(LOG_LEVEL_INFO, F("WIFI : AP Mode disabled"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//want to enable?
|
||||
if (state)
|
||||
{
|
||||
WiFi.mode(WIFI_AP_STA);
|
||||
addLog(LOG_LEVEL_INFO, F("WIFI : AP Mode enabled"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool useStaticIP() {
|
||||
return (Settings.IP[0] != 0 && Settings.IP[0] != 255);
|
||||
}
|
||||
|
||||
//********************************************************************************
|
||||
// Set Wifi config
|
||||
//********************************************************************************
|
||||
bool prepareWiFi() {
|
||||
if (!selectValidWiFiSettings())
|
||||
return false;
|
||||
|
||||
String log = "";
|
||||
char hostname[40];
|
||||
strncpy(hostname, WifiGetHostname().c_str(), sizeof(hostname));
|
||||
#if defined(ESP8266)
|
||||
wifi_station_set_hostname(hostname);
|
||||
#endif
|
||||
#if defined(ESP32)
|
||||
WiFi.setHostname(hostname);
|
||||
#endif
|
||||
|
||||
//use static ip?
|
||||
if (useStaticIP())
|
||||
{
|
||||
const IPAddress ip = Settings.IP;
|
||||
log = F("IP : Static IP :");
|
||||
log += ip;
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
const IPAddress gw = Settings.Gateway;
|
||||
const IPAddress subnet = Settings.Subnet;
|
||||
const IPAddress dns = Settings.DNS;
|
||||
WiFi.config(ip, gw, subnet, dns);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//********************************************************************************
|
||||
// Start connect to WiFi and check later to see if connected.
|
||||
//********************************************************************************
|
||||
void WiFiConnectRelaxed() {
|
||||
if (prepareWiFi()) {
|
||||
tryConnectWiFi();
|
||||
return;
|
||||
}
|
||||
addLog(LOG_LEVEL_ERROR, F("WIFI : Could not connect to AP! (relaxed connect mode)"));
|
||||
//everything failed, activate AP mode (will deactivate automatically after a while if its connected again)
|
||||
WifiAPMode(true);
|
||||
}
|
||||
|
||||
|
||||
//********************************************************************************
|
||||
// Manage WiFi credentials
|
||||
//********************************************************************************
|
||||
const char* getLastWiFiSettingsSSID() {
|
||||
return lastWiFiSettings == 0 ? SecuritySettings.WifiSSID : SecuritySettings.WifiSSID2;
|
||||
}
|
||||
|
||||
const char* getLastWiFiSettingsPassphrase() {
|
||||
return lastWiFiSettings == 0 ? SecuritySettings.WifiKey : SecuritySettings.WifiKey2;
|
||||
}
|
||||
|
||||
bool selectNextWiFiSettings() {
|
||||
uint8_t tmp = lastWiFiSettings;
|
||||
lastWiFiSettings = (lastWiFiSettings + 1) % 2;
|
||||
if (!wifiSettingsValid(getLastWiFiSettingsSSID(), getLastWiFiSettingsPassphrase())) {
|
||||
// other settings are not correct, switch back.
|
||||
lastWiFiSettings = tmp;
|
||||
return false; // Nothing changed.
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool selectValidWiFiSettings() {
|
||||
if (wifiSettingsValid(getLastWiFiSettingsSSID(), getLastWiFiSettingsPassphrase()))
|
||||
return true;
|
||||
return selectNextWiFiSettings();
|
||||
}
|
||||
|
||||
bool wifiSettingsValid(const char* ssid, const char* pass) {
|
||||
if (ssid[0] == 0 || (strcasecmp(ssid, "ssid") == 0)) {
|
||||
return false;
|
||||
}
|
||||
if (pass[0] == 0) return false;
|
||||
if (strlen(ssid) > 32) return false;
|
||||
if (strlen(pass) > 64) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wifiConnectTimeoutReached() {
|
||||
if (wifi_connect_attempt == 0) return true;
|
||||
if (timeDiff(last_wifi_connect_attempt_moment, lastDisconnectMoment) >0 ) {
|
||||
// Connection attempt was already ended.
|
||||
return true;
|
||||
}
|
||||
if (wifiSetupConnect) {
|
||||
// Initial setup of WiFi, may take much longer since accesspoint is still active.
|
||||
return timeOutReached(last_wifi_connect_attempt_moment + 20000);
|
||||
}
|
||||
// wait until it connects + add some device specific random offset to prevent
|
||||
// all nodes overloading the accesspoint when turning on at the same time.
|
||||
#if defined(ESP8266)
|
||||
const unsigned int randomOffset_in_sec = wifi_connect_attempt == 1 ? 0 : 1000 * ((ESP.getChipId() & 0xF));
|
||||
#endif
|
||||
#if defined(ESP32)
|
||||
const unsigned int randomOffset_in_sec = wifi_connect_attempt == 1 ? 0 : 1000 * ((ESP.getEfuseMac() & 0xF));
|
||||
#endif
|
||||
return timeOutReached(last_wifi_connect_attempt_moment + DEFAULT_WIFI_CONNECTION_TIMEOUT + randomOffset_in_sec);
|
||||
}
|
||||
|
||||
//********************************************************************************
|
||||
// Simply start the WiFi connection sequence
|
||||
//********************************************************************************
|
||||
bool tryConnectWiFi() {
|
||||
if (wifiSetup && !wifiSetupConnect)
|
||||
return false;
|
||||
if (wifiStatus != ESPEASY_WIFI_DISCONNECTED)
|
||||
return(true); //already connected, need to disconnect first
|
||||
if (!wifiConnectTimeoutReached())
|
||||
return true; // timeout not reached yet, thus no need to retry again.
|
||||
if (!selectValidWiFiSettings()) {
|
||||
addLog(LOG_LEVEL_ERROR, F("WIFI : No valid WiFi settings!"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (wifi_connect_attempt != 0 && ((wifi_connect_attempt % 3) == 0)) {
|
||||
// Change to other wifi settings.
|
||||
if (selectNextWiFiSettings())
|
||||
WiFi.disconnect();
|
||||
}
|
||||
if (wifi_connect_attempt > 6) {
|
||||
//everything failed, activate AP mode (will deactivate automatically after a while if its connected again)
|
||||
WifiAPMode(true);
|
||||
}
|
||||
const char* ssid = getLastWiFiSettingsSSID();
|
||||
const char* passphrase = getLastWiFiSettingsPassphrase();
|
||||
String log = F("WIFI : Connecting ");
|
||||
log += ssid;
|
||||
log += F(" attempt #");
|
||||
log += wifi_connect_attempt;
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
|
||||
last_wifi_connect_attempt_moment = millis();
|
||||
switch (wifi_connect_attempt) {
|
||||
case 0:
|
||||
if (lastBSSID[0] == 0)
|
||||
WiFi.begin(ssid, passphrase);
|
||||
else
|
||||
WiFi.begin(ssid, passphrase, 0, &lastBSSID[0]);
|
||||
break;
|
||||
default:
|
||||
WiFi.begin(ssid, passphrase);
|
||||
}
|
||||
++wifi_connect_attempt;
|
||||
switch (WiFi.status()) {
|
||||
case WL_NO_SSID_AVAIL: {
|
||||
log = F("WIFI : No SSID found matching: ");
|
||||
log += ssid;
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
return false;
|
||||
}
|
||||
case WL_CONNECT_FAILED: {
|
||||
log = F("WIFI : Connection failed to: ");
|
||||
log += ssid;
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
return false;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return true; // Sent
|
||||
}
|
||||
|
||||
//********************************************************************************
|
||||
// Disconnect from Wifi AP
|
||||
//********************************************************************************
|
||||
void WifiDisconnect()
|
||||
{
|
||||
WiFi.disconnect();
|
||||
}
|
||||
|
||||
|
||||
//********************************************************************************
|
||||
// Scan all Wifi Access Points
|
||||
//********************************************************************************
|
||||
void WifiScan()
|
||||
{
|
||||
// Direct Serial is allowed here, since this function will only be called from serial input.
|
||||
Serial.println(F("WIFI : SSID Scan start"));
|
||||
int n = WiFi.scanNetworks();
|
||||
if (n == 0)
|
||||
Serial.println(F("WIFI : No networks found"));
|
||||
else
|
||||
{
|
||||
Serial.print(F("WIFI : "));
|
||||
Serial.print(n);
|
||||
Serial.println(F(" networks found"));
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
// Print SSID and RSSI for each network found
|
||||
Serial.print(F("WIFI : "));
|
||||
Serial.print(i + 1);
|
||||
Serial.print(": ");
|
||||
Serial.print(WiFi.SSID(i));
|
||||
Serial.print(" (");
|
||||
Serial.print(WiFi.RSSI(i));
|
||||
Serial.print(")");
|
||||
Serial.println("");
|
||||
delay(10);
|
||||
}
|
||||
}
|
||||
Serial.println("");
|
||||
}
|
||||
|
||||
|
||||
//********************************************************************************
|
||||
// Check if we are still connected to a Wifi AP
|
||||
//********************************************************************************
|
||||
void WifiCheck()
|
||||
{
|
||||
if(wifiSetup)
|
||||
return;
|
||||
|
||||
if (wifiStatus == ESPEASY_WIFI_DISCONNECTED)
|
||||
{
|
||||
NC_Count++;
|
||||
WiFiConnectRelaxed();
|
||||
}
|
||||
//connected
|
||||
else
|
||||
{
|
||||
C_Count++;
|
||||
NC_Count = 0;
|
||||
if (C_Count > 2) // disable AP after timeout if a Wifi connection is established...
|
||||
{
|
||||
WifiAPMode(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//********************************************************************************
|
||||
// Return subnet range of WiFi.
|
||||
//********************************************************************************
|
||||
bool getSubnetRange(IPAddress& low, IPAddress& high)
|
||||
{
|
||||
if (WifiIsAP()) {
|
||||
// WiFi is active as accesspoint, do not check.
|
||||
return false;
|
||||
}
|
||||
if (wifiStatus < ESPEASY_WIFI_GOT_IP) {
|
||||
return false;
|
||||
}
|
||||
const IPAddress ip = WiFi.localIP();
|
||||
const IPAddress subnet = WiFi.subnetMask();
|
||||
low = ip;
|
||||
high = ip;
|
||||
// Compute subnet range.
|
||||
for (byte i=0; i < 4; ++i) {
|
||||
if (subnet[i] != 255) {
|
||||
low[i] = low[i] & subnet[i];
|
||||
high[i] = high[i] | ~subnet[i];
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
String getLastDisconnectReason() {
|
||||
switch (lastDisconnectReason) {
|
||||
case WIFI_DISCONNECT_REASON_UNSPECIFIED: return F("Unspecified");
|
||||
case WIFI_DISCONNECT_REASON_AUTH_EXPIRE: return F("Auth expire");
|
||||
case WIFI_DISCONNECT_REASON_AUTH_LEAVE: return F("Auth leave");
|
||||
case WIFI_DISCONNECT_REASON_ASSOC_EXPIRE: return F("Assoc expire");
|
||||
case WIFI_DISCONNECT_REASON_ASSOC_TOOMANY: return F("Assoc toomany");
|
||||
case WIFI_DISCONNECT_REASON_NOT_AUTHED: return F("Not authed");
|
||||
case WIFI_DISCONNECT_REASON_NOT_ASSOCED: return F("Not assoced");
|
||||
case WIFI_DISCONNECT_REASON_ASSOC_LEAVE: return F("Assoc leave");
|
||||
case WIFI_DISCONNECT_REASON_ASSOC_NOT_AUTHED: return F("Assoc not authed");
|
||||
case WIFI_DISCONNECT_REASON_DISASSOC_PWRCAP_BAD: return F("Disassoc pwrcap bad");
|
||||
case WIFI_DISCONNECT_REASON_DISASSOC_SUPCHAN_BAD: return F("Disassoc supchan bad");
|
||||
case WIFI_DISCONNECT_REASON_IE_INVALID: return F("IE invalid");
|
||||
case WIFI_DISCONNECT_REASON_MIC_FAILURE: return F("Mic failure");
|
||||
case WIFI_DISCONNECT_REASON_4WAY_HANDSHAKE_TIMEOUT: return F("4way handshake timeout");
|
||||
case WIFI_DISCONNECT_REASON_GROUP_KEY_UPDATE_TIMEOUT: return F("Group key update timeout");
|
||||
case WIFI_DISCONNECT_REASON_IE_IN_4WAY_DIFFERS: return F("IE in 4way differs");
|
||||
case WIFI_DISCONNECT_REASON_GROUP_CIPHER_INVALID: return F("Group cipher invalid");
|
||||
case WIFI_DISCONNECT_REASON_PAIRWISE_CIPHER_INVALID: return F("Pairwise cipher invalid");
|
||||
case WIFI_DISCONNECT_REASON_AKMP_INVALID: return F("AKMP invalid");
|
||||
case WIFI_DISCONNECT_REASON_UNSUPP_RSN_IE_VERSION: return F("Unsupp RSN IE version");
|
||||
case WIFI_DISCONNECT_REASON_INVALID_RSN_IE_CAP: return F("Invalid RSN IE cap");
|
||||
case WIFI_DISCONNECT_REASON_802_1X_AUTH_FAILED: return F("802 1X auth failed");
|
||||
case WIFI_DISCONNECT_REASON_CIPHER_SUITE_REJECTED: return F("Cipher suite rejected");
|
||||
case WIFI_DISCONNECT_REASON_BEACON_TIMEOUT: return F("Beacon timeout");
|
||||
case WIFI_DISCONNECT_REASON_NO_AP_FOUND: return F("No AP found");
|
||||
case WIFI_DISCONNECT_REASON_AUTH_FAIL: return F("Auth fail");
|
||||
case WIFI_DISCONNECT_REASON_ASSOC_FAIL: return F("Assoc fail");
|
||||
case WIFI_DISCONNECT_REASON_HANDSHAKE_TIMEOUT: return F("Handshake timeout");
|
||||
}
|
||||
return F("Unknown");
|
||||
}
|
||||
+267
-249
@@ -40,6 +40,17 @@ bool isDeepSleepEnabled()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool readyForSleep()
|
||||
{
|
||||
if (!isDeepSleepEnabled())
|
||||
return false;
|
||||
if (wifiStatus != ESPEASY_WIFI_SERVICES_INITIALIZED) {
|
||||
// Allow 6 seconds to connect to WiFi
|
||||
return timeOutReached(timerAwakeFromDeepSleep + 6000);
|
||||
}
|
||||
return timeOutReached(timerAwakeFromDeepSleep + 1000 * Settings.deepSleep);
|
||||
}
|
||||
|
||||
void deepSleep(int delay)
|
||||
{
|
||||
|
||||
@@ -310,7 +321,7 @@ void statusLED(boolean traffic)
|
||||
else
|
||||
{
|
||||
|
||||
if (WiFi.status() == WL_CONNECTED)
|
||||
if (wifiStatus == ESPEASY_WIFI_SERVICES_INITIALIZED)
|
||||
{
|
||||
long int delta = timePassedSince(gnLastUpdate);
|
||||
if (delta>0 || delta<0 )
|
||||
@@ -971,22 +982,11 @@ String ClearInFile(char* fname, int index, int datasize)
|
||||
String LoadFromFile(char* fname, int index, byte* memAddress, int datasize)
|
||||
{
|
||||
checkRAM(F("LoadFromFile"));
|
||||
// addLog(LOG_LEVEL_INFO, String(F("FILE : Load size "))+datasize);
|
||||
|
||||
fs::File f = SPIFFS.open(fname, "r+");
|
||||
SPIFFS_CHECK(f, fname);
|
||||
|
||||
// addLog(LOG_LEVEL_INFO, String(F("FILE : File size "))+f.size());
|
||||
|
||||
SPIFFS_CHECK(f.seek(index, fs::SeekSet), fname);
|
||||
byte *pointerToByteToRead = memAddress;
|
||||
for (int x = 0; x < datasize; x++)
|
||||
{
|
||||
int readres=f.read();
|
||||
SPIFFS_CHECK(readres >=0, fname);
|
||||
*pointerToByteToRead = readres;
|
||||
pointerToByteToRead++;// next byte
|
||||
}
|
||||
SPIFFS_CHECK(f.read(memAddress,datasize), fname);
|
||||
f.close();
|
||||
|
||||
return(String());
|
||||
@@ -1167,6 +1167,7 @@ void ResetFactory(void)
|
||||
//NOTE: this is a known ESP8266 bug, not our fault. :)
|
||||
delay(1000);
|
||||
WiFi.persistent(true); // use SDK storage of SSID/WPA parameters
|
||||
intent_to_reboot = true;
|
||||
WiFi.disconnect(); // this will store empty ssid/wpa into sdk storage
|
||||
WiFi.persistent(false); // Do not use SDK storage of SSID/WPA parameters
|
||||
#if defined(ESP8266)
|
||||
@@ -1213,28 +1214,6 @@ unsigned long FreeMem(void)
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************************************\
|
||||
In memory convert float to long
|
||||
\*********************************************************************************************/
|
||||
unsigned long float2ul(float f)
|
||||
{
|
||||
unsigned long ul;
|
||||
memcpy(&ul, &f, 4);
|
||||
return ul;
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************************************\
|
||||
In memory convert long to float
|
||||
\*********************************************************************************************/
|
||||
float ul2float(unsigned long ul)
|
||||
{
|
||||
float f;
|
||||
memcpy(&f, &ul, 4);
|
||||
return f;
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************************************\
|
||||
Check if string is valid float
|
||||
\*********************************************************************************************/
|
||||
@@ -1409,7 +1388,9 @@ void delayedReboot(int rebootDelay)
|
||||
\*********************************************************************************************/
|
||||
boolean saveToRTC()
|
||||
{
|
||||
#if defined(ESP8266)
|
||||
#if defined(ESP32)
|
||||
return false;
|
||||
#else
|
||||
if (!system_rtc_mem_write(RTC_BASE_STRUCT, (byte*)&RTC, sizeof(RTC)) || !readFromRTC())
|
||||
{
|
||||
addLog(LOG_LEVEL_ERROR, F("RTC : Error while writing to RTC"));
|
||||
@@ -1420,9 +1401,6 @@ boolean saveToRTC()
|
||||
return(true);
|
||||
}
|
||||
#endif
|
||||
#if defined(ESP32)
|
||||
boolean ret = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -1445,17 +1423,12 @@ void initRTC()
|
||||
\*********************************************************************************************/
|
||||
boolean readFromRTC()
|
||||
{
|
||||
#if defined(ESP8266)
|
||||
#if defined(ESP32)
|
||||
return false;
|
||||
#else
|
||||
if (!system_rtc_mem_read(RTC_BASE_STRUCT, (byte*)&RTC, sizeof(RTC)))
|
||||
return(false);
|
||||
|
||||
if (RTC.ID1 == 0xAA && RTC.ID2 == 0x55)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
#endif
|
||||
#if defined(ESP32)
|
||||
boolean ret = false;
|
||||
return (RTC.ID1 == 0xAA && RTC.ID2 == 0x55);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1465,18 +1438,17 @@ boolean readFromRTC()
|
||||
\*********************************************************************************************/
|
||||
boolean saveUserVarToRTC()
|
||||
{
|
||||
#if defined(ESP8266)
|
||||
#if defined(ESP32)
|
||||
return false;
|
||||
#else
|
||||
//addLog(LOG_LEVEL_DEBUG, F("RTCMEM: saveUserVarToRTC"));
|
||||
byte* buffer = (byte*)&UserVar;
|
||||
size_t size = sizeof(UserVar);
|
||||
uint32_t sum = getChecksum(buffer, size);
|
||||
boolean ret = system_rtc_mem_write(RTC_BASE_USERVAR, buffer, size);
|
||||
ret &= system_rtc_mem_write(RTC_BASE_USERVAR+(size>>2), (byte*)&sum, 4);
|
||||
return ret;
|
||||
#endif
|
||||
#if defined(ESP32)
|
||||
boolean ret = false;
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -1485,7 +1457,9 @@ boolean saveUserVarToRTC()
|
||||
\*********************************************************************************************/
|
||||
boolean readUserVarFromRTC()
|
||||
{
|
||||
#if defined(ESP8266)
|
||||
#if defined(ESP32)
|
||||
return false;
|
||||
#else
|
||||
//addLog(LOG_LEVEL_DEBUG, F("RTCMEM: readUserVarFromRTC"));
|
||||
byte* buffer = (byte*)&UserVar;
|
||||
size_t size = sizeof(UserVar);
|
||||
@@ -1498,11 +1472,8 @@ boolean readUserVarFromRTC()
|
||||
addLog(LOG_LEVEL_ERROR, F("RTC : Checksum error on reading RTC user var"));
|
||||
memset(buffer, 0, size);
|
||||
}
|
||||
return ret;
|
||||
#endif
|
||||
#if defined(ESP32)
|
||||
boolean ret = false;
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -1539,87 +1510,89 @@ String parseTemplate(String &tmpString, byte lineSize)
|
||||
newString += tmpString.substring(0, leftBracketIndex);
|
||||
tmpString = tmpString.substring(leftBracketIndex + 1);
|
||||
int rightBracketIndex = tmpString.indexOf(']');
|
||||
if (rightBracketIndex)
|
||||
if (rightBracketIndex >= 0)
|
||||
{
|
||||
tmpStringMid = tmpString.substring(0, rightBracketIndex);
|
||||
tmpString = tmpString.substring(rightBracketIndex + 1);
|
||||
int hashtagIndex = tmpStringMid.indexOf('#');
|
||||
String deviceName = tmpStringMid.substring(0, hashtagIndex);
|
||||
String valueName = tmpStringMid.substring(hashtagIndex + 1);
|
||||
String valueFormat = "";
|
||||
hashtagIndex = valueName.indexOf('#');
|
||||
if (hashtagIndex >= 0)
|
||||
{
|
||||
valueFormat = valueName.substring(hashtagIndex + 1);
|
||||
valueName = valueName.substring(0, hashtagIndex);
|
||||
}
|
||||
|
||||
if (deviceName.equalsIgnoreCase("Plugin"))
|
||||
{
|
||||
String tmpString = tmpStringMid.substring(7);
|
||||
tmpString.replace("#", ",");
|
||||
if (PluginCall(PLUGIN_REQUEST, 0, tmpString))
|
||||
newString += tmpString;
|
||||
}
|
||||
else
|
||||
for (byte y = 0; y < TASKS_MAX; y++)
|
||||
if (hashtagIndex >= 0) {
|
||||
String deviceName = tmpStringMid.substring(0, hashtagIndex);
|
||||
String valueName = tmpStringMid.substring(hashtagIndex + 1);
|
||||
String valueFormat = "";
|
||||
hashtagIndex = valueName.indexOf('#');
|
||||
if (hashtagIndex >= 0)
|
||||
{
|
||||
if (Settings.TaskDeviceEnabled[y])
|
||||
valueFormat = valueName.substring(hashtagIndex + 1);
|
||||
valueName = valueName.substring(0, hashtagIndex);
|
||||
}
|
||||
|
||||
if (deviceName.equalsIgnoreCase("Plugin"))
|
||||
{
|
||||
String tmpString = tmpStringMid.substring(7);
|
||||
tmpString.replace("#", ",");
|
||||
if (PluginCall(PLUGIN_REQUEST, 0, tmpString))
|
||||
newString += tmpString;
|
||||
}
|
||||
else
|
||||
for (byte y = 0; y < TASKS_MAX; y++)
|
||||
{
|
||||
LoadTaskSettings(y);
|
||||
if (ExtraTaskSettings.TaskDeviceName[0] != 0)
|
||||
if (Settings.TaskDeviceEnabled[y])
|
||||
{
|
||||
if (deviceName.equalsIgnoreCase(ExtraTaskSettings.TaskDeviceName))
|
||||
LoadTaskSettings(y);
|
||||
if (ExtraTaskSettings.TaskDeviceName[0] != 0)
|
||||
{
|
||||
boolean match = false;
|
||||
for (byte z = 0; z < VARS_PER_TASK; z++)
|
||||
if (valueName.equalsIgnoreCase(ExtraTaskSettings.TaskDeviceValueNames[z]))
|
||||
{
|
||||
// here we know the task and value, so find the uservar
|
||||
match = true;
|
||||
String value = "";
|
||||
byte DeviceIndex = getDeviceIndex(Settings.TaskDeviceNumber[y]);
|
||||
if (Device[DeviceIndex].VType == SENSOR_TYPE_LONG)
|
||||
value = (unsigned long)UserVar[y * VARS_PER_TASK + z] + ((unsigned long)UserVar[y * VARS_PER_TASK + z + 1] << 16);
|
||||
else
|
||||
value = toString(UserVar[y * VARS_PER_TASK + z], ExtraTaskSettings.TaskDeviceValueDecimals[z]);
|
||||
|
||||
int oidx;
|
||||
if ((oidx = valueFormat.indexOf('O')) >= 0) // Output
|
||||
{
|
||||
valueFormat.remove(oidx);
|
||||
oidx = valueFormat.indexOf('!'); // inverted or active low
|
||||
float val = value.toFloat();
|
||||
if (oidx >= 0) {
|
||||
valueFormat.remove(oidx);
|
||||
value = val == 0 ? " ON" : "OFF";
|
||||
} else {
|
||||
value = val == 0 ? "OFF" : " ON";
|
||||
}
|
||||
}
|
||||
|
||||
if (valueFormat == "R")
|
||||
{
|
||||
int filler = lineSize - newString.length() - value.length() - tmpString.length() ;
|
||||
for (byte f = 0; f < filler; f++)
|
||||
newString += " ";
|
||||
}
|
||||
newString += String(value);
|
||||
break;
|
||||
}
|
||||
if (!match) // try if this is a get config request
|
||||
if (deviceName.equalsIgnoreCase(ExtraTaskSettings.TaskDeviceName))
|
||||
{
|
||||
struct EventStruct TempEvent;
|
||||
TempEvent.TaskIndex = y;
|
||||
String tmpName = valueName;
|
||||
if (PluginCall(PLUGIN_GET_CONFIG, &TempEvent, tmpName))
|
||||
newString += tmpName;
|
||||
boolean match = false;
|
||||
for (byte z = 0; z < VARS_PER_TASK; z++)
|
||||
if (valueName.equalsIgnoreCase(ExtraTaskSettings.TaskDeviceValueNames[z]))
|
||||
{
|
||||
// here we know the task and value, so find the uservar
|
||||
match = true;
|
||||
String value = "";
|
||||
byte DeviceIndex = getDeviceIndex(Settings.TaskDeviceNumber[y]);
|
||||
if (Device[DeviceIndex].VType == SENSOR_TYPE_LONG)
|
||||
value = (unsigned long)UserVar[y * VARS_PER_TASK + z] + ((unsigned long)UserVar[y * VARS_PER_TASK + z + 1] << 16);
|
||||
else
|
||||
value = toString(UserVar[y * VARS_PER_TASK + z], ExtraTaskSettings.TaskDeviceValueDecimals[z]);
|
||||
|
||||
int oidx;
|
||||
if ((oidx = valueFormat.indexOf('O')) >= 0) // Output
|
||||
{
|
||||
valueFormat.remove(oidx);
|
||||
oidx = valueFormat.indexOf('!'); // inverted or active low
|
||||
float val = value.toFloat();
|
||||
if (oidx >= 0) {
|
||||
valueFormat.remove(oidx);
|
||||
value = val == 0 ? " ON" : "OFF";
|
||||
} else {
|
||||
value = val == 0 ? "OFF" : " ON";
|
||||
}
|
||||
}
|
||||
|
||||
if (valueFormat == "R")
|
||||
{
|
||||
int filler = lineSize - newString.length() - value.length() - tmpString.length() ;
|
||||
for (byte f = 0; f < filler; f++)
|
||||
newString += " ";
|
||||
}
|
||||
newString += String(value);
|
||||
break;
|
||||
}
|
||||
if (!match) // try if this is a get config request
|
||||
{
|
||||
struct EventStruct TempEvent;
|
||||
TempEvent.TaskIndex = y;
|
||||
String tmpName = valueName;
|
||||
if (PluginCall(PLUGIN_GET_CONFIG, &TempEvent, tmpName))
|
||||
newString += tmpName;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
leftBracketIndex = tmpString.indexOf('[');
|
||||
count++;
|
||||
@@ -1641,7 +1614,6 @@ String parseTemplate(String &tmpString, byte lineSize)
|
||||
return newString;
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************************************\
|
||||
Calculate function for simple expressions
|
||||
\*********************************************************************************************/
|
||||
@@ -1916,6 +1888,29 @@ int Calculate(const char *input, float* result)
|
||||
}
|
||||
|
||||
|
||||
void checkRuleSets(){
|
||||
for (byte x=0; x < RULESETS_MAX; x++){
|
||||
#if defined(ESP8266)
|
||||
String fileName = F("rules");
|
||||
#endif
|
||||
#if defined(ESP32)
|
||||
String fileName = F("/rules");
|
||||
#endif
|
||||
fileName += x+1;
|
||||
fileName += F(".txt");
|
||||
if (SPIFFS.exists(fileName))
|
||||
activeRuleSets[x] = true;
|
||||
else
|
||||
activeRuleSets[x] = false;
|
||||
|
||||
if (Settings.SerialLogLevel == LOG_LEVEL_DEBUG_DEV){
|
||||
Serial.print(fileName);
|
||||
Serial.print(" ");
|
||||
Serial.println(activeRuleSets[x]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************************************\
|
||||
Rules processing
|
||||
@@ -1930,7 +1925,7 @@ void rulesProcessing(String& event)
|
||||
log += event;
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
|
||||
for (byte x = 1; x < RULESETS_MAX + 1; x++)
|
||||
for (byte x = 0; x < RULESETS_MAX; x++)
|
||||
{
|
||||
#if defined(ESP8266)
|
||||
String fileName = F("rules");
|
||||
@@ -1938,9 +1933,9 @@ void rulesProcessing(String& event)
|
||||
#if defined(ESP32)
|
||||
String fileName = F("/rules");
|
||||
#endif
|
||||
fileName += x;
|
||||
fileName += x+1;
|
||||
fileName += F(".txt");
|
||||
if (SPIFFS.exists(fileName))
|
||||
if(activeRuleSets[x])
|
||||
rulesProcessingFile(fileName, event);
|
||||
}
|
||||
|
||||
@@ -1957,8 +1952,11 @@ void rulesProcessing(String& event)
|
||||
String rulesProcessingFile(String fileName, String& event)
|
||||
{
|
||||
checkRAM(F("rulesProcessingFile"));
|
||||
fs::File f = SPIFFS.open(fileName, "r+");
|
||||
SPIFFS_CHECK(f, fileName.c_str());
|
||||
if (Settings.SerialLogLevel == LOG_LEVEL_DEBUG_DEV){
|
||||
Serial.print(F("RuleDebug Processing:"));
|
||||
Serial.println(fileName);
|
||||
Serial.println(F(" flags CMI parse output:"));
|
||||
}
|
||||
|
||||
static byte nestingLevel = 0;
|
||||
int data = 0;
|
||||
@@ -1970,11 +1968,12 @@ String rulesProcessingFile(String fileName, String& event)
|
||||
log = F("EVENT: Error: Nesting level exceeded!");
|
||||
addLog(LOG_LEVEL_ERROR, log);
|
||||
nestingLevel--;
|
||||
return(log);
|
||||
return (log);
|
||||
}
|
||||
|
||||
fs::File f = SPIFFS.open(fileName, "r+");
|
||||
SPIFFS_CHECK(f, fileName.c_str());
|
||||
|
||||
// int pos = 0;
|
||||
String line = "";
|
||||
boolean match = false;
|
||||
boolean codeBlock = false;
|
||||
@@ -1983,148 +1982,167 @@ String rulesProcessingFile(String fileName, String& event)
|
||||
boolean condition = false;
|
||||
boolean ifBranche = false;
|
||||
|
||||
byte buf[RULES_BUFFER_SIZE];
|
||||
int len = 0;
|
||||
while (f.available())
|
||||
{
|
||||
data = f.read();
|
||||
len = f.read((byte*)buf, RULES_BUFFER_SIZE);
|
||||
for (int x = 0; x < len; x++) {
|
||||
data = buf[x];
|
||||
|
||||
SPIFFS_CHECK(data >= 0, fileName.c_str());
|
||||
SPIFFS_CHECK(data >= 0, fileName.c_str());
|
||||
|
||||
if (data != 10)
|
||||
line += char(data);
|
||||
if (data != 10)
|
||||
line += char(data);
|
||||
|
||||
if (data == 10) // if line complete, parse this rule
|
||||
{
|
||||
line.replace("\r", "");
|
||||
if (line.substring(0, 2) != "//" && line.length() > 0)
|
||||
if (data == 10) // if line complete, parse this rule
|
||||
{
|
||||
isCommand = true;
|
||||
|
||||
int comment = line.indexOf("//");
|
||||
if (comment > 0)
|
||||
line = line.substring(0, comment);
|
||||
|
||||
line = parseTemplate(line, line.length());
|
||||
line.trim();
|
||||
|
||||
String lineOrg = line; // store original line for future use
|
||||
line.toLowerCase(); // convert all to lower case to make checks easier
|
||||
|
||||
String eventTrigger = "";
|
||||
String action = "";
|
||||
|
||||
if (!codeBlock) // do not check "on" rules if a block of actions is to be processed
|
||||
line.replace("\r", "");
|
||||
if (line.substring(0, 2) != "//" && line.length() > 0)
|
||||
{
|
||||
if (line.startsWith("on "))
|
||||
isCommand = true;
|
||||
|
||||
int comment = line.indexOf("//");
|
||||
if (comment > 0)
|
||||
line = line.substring(0, comment);
|
||||
|
||||
if (match || !codeBlock) {
|
||||
// only parse [xxx#yyy] if we have a matching ruleblock or need to eval the "on" (no codeBlock)
|
||||
// This to avoid waisting CPU time...
|
||||
line = parseTemplate(line, line.length());
|
||||
}
|
||||
line.trim();
|
||||
|
||||
String lineOrg = line; // store original line for future use
|
||||
line.toLowerCase(); // convert all to lower case to make checks easier
|
||||
|
||||
|
||||
String eventTrigger = "";
|
||||
String action = "";
|
||||
|
||||
if (!codeBlock) // do not check "on" rules if a block of actions is to be processed
|
||||
{
|
||||
line = line.substring(3);
|
||||
int split = line.indexOf(" do");
|
||||
if (line.startsWith("on "))
|
||||
{
|
||||
line = line.substring(3);
|
||||
int split = line.indexOf(" do");
|
||||
if (split != -1)
|
||||
{
|
||||
eventTrigger = line.substring(0, split);
|
||||
action = lineOrg.substring(split + 7);
|
||||
action.trim();
|
||||
}
|
||||
if (eventTrigger == "*") // wildcard, always process
|
||||
match = true;
|
||||
else
|
||||
match = ruleMatch(event, eventTrigger);
|
||||
if (action.length() > 0) // single on/do/action line, no block
|
||||
{
|
||||
isCommand = true;
|
||||
codeBlock = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
isCommand = false;
|
||||
codeBlock = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
action = lineOrg;
|
||||
}
|
||||
|
||||
String lcAction = action;
|
||||
lcAction.toLowerCase();
|
||||
if (lcAction == "endon") // Check if action block has ended, then we will wait for a new "on" rule
|
||||
{
|
||||
isCommand = false;
|
||||
codeBlock = false;
|
||||
match = false;
|
||||
}
|
||||
|
||||
if (Settings.SerialLogLevel == LOG_LEVEL_DEBUG_DEV){
|
||||
Serial.print(F("RuleDebug: "));
|
||||
Serial.print(codeBlock);
|
||||
Serial.print(match);
|
||||
Serial.print(isCommand);
|
||||
Serial.print(": ");
|
||||
Serial.println(line);
|
||||
}
|
||||
|
||||
if (match) // rule matched for one action or a block of actions
|
||||
{
|
||||
int split = lcAction.indexOf("if "); // check for optional "if" condition
|
||||
if (split != -1)
|
||||
{
|
||||
eventTrigger = line.substring(0, split);
|
||||
action = lineOrg.substring(split + 7);
|
||||
action.trim();
|
||||
}
|
||||
if (eventTrigger == "*") // wildcard, always process
|
||||
match = true;
|
||||
else
|
||||
match = ruleMatch(event, eventTrigger);
|
||||
if (action.length() > 0) // single on/do/action line, no block
|
||||
{
|
||||
isCommand = true;
|
||||
codeBlock = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
conditional = true;
|
||||
String check = lcAction.substring(split + 3);
|
||||
condition = conditionMatchExtended(check);
|
||||
ifBranche = true;
|
||||
isCommand = false;
|
||||
codeBlock = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
action = lineOrg;
|
||||
}
|
||||
|
||||
String lcAction = action;
|
||||
lcAction.toLowerCase();
|
||||
if (lcAction == "endon") // Check if action block has ended, then we will wait for a new "on" rule
|
||||
{
|
||||
isCommand = false;
|
||||
codeBlock = false;
|
||||
}
|
||||
|
||||
if (match) // rule matched for one action or a block of actions
|
||||
{
|
||||
int split = lcAction.indexOf("if "); // check for optional "if" condition
|
||||
if (split != -1)
|
||||
{
|
||||
conditional = true;
|
||||
String check = lcAction.substring(split + 3);
|
||||
condition = conditionMatchExtended(check);
|
||||
ifBranche = true;
|
||||
isCommand = false;
|
||||
}
|
||||
|
||||
if (lcAction == "else") // in case of an "else" block of actions, set ifBranche to false
|
||||
{
|
||||
ifBranche = false;
|
||||
isCommand = false;
|
||||
}
|
||||
|
||||
if (lcAction == "endif") // conditional block ends here
|
||||
{
|
||||
conditional = false;
|
||||
isCommand = false;
|
||||
}
|
||||
|
||||
// process the action if it's a command and unconditional, or conditional and the condition matches the if or else block.
|
||||
if (isCommand && ((!conditional) || (conditional && (condition == ifBranche))))
|
||||
{
|
||||
if (event.charAt(0) == '!')
|
||||
if (lcAction == "else") // in case of an "else" block of actions, set ifBranche to false
|
||||
{
|
||||
action.replace(F("%eventvalue%"), event); // substitute %eventvalue% with literal event string if starting with '!'
|
||||
ifBranche = false;
|
||||
isCommand = false;
|
||||
}
|
||||
else
|
||||
|
||||
if (lcAction == "endif") // conditional block ends here
|
||||
{
|
||||
int equalsPos = event.indexOf("=");
|
||||
if (equalsPos > 0)
|
||||
conditional = false;
|
||||
isCommand = false;
|
||||
}
|
||||
|
||||
// process the action if it's a command and unconditional, or conditional and the condition matches the if or else block.
|
||||
if (isCommand && ((!conditional) || (conditional && (condition == ifBranche))))
|
||||
{
|
||||
if (event.charAt(0) == '!')
|
||||
{
|
||||
String tmpString = event.substring(equalsPos + 1);
|
||||
action.replace(F("%eventvalue%"), tmpString); // substitute %eventvalue% in actions with the actual value from the event
|
||||
action.replace(F("%eventvalue%"), event); // substitute %eventvalue% with literal event string if starting with '!'
|
||||
}
|
||||
}
|
||||
log = F("ACT : ");
|
||||
log += action;
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
else
|
||||
{
|
||||
int equalsPos = event.indexOf("=");
|
||||
if (equalsPos > 0)
|
||||
{
|
||||
String tmpString = event.substring(equalsPos + 1);
|
||||
action.replace(F("%eventvalue%"), tmpString); // substitute %eventvalue% in actions with the actual value from the event
|
||||
}
|
||||
}
|
||||
log = F("ACT : ");
|
||||
log += action;
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
|
||||
struct EventStruct TempEvent;
|
||||
parseCommandString(&TempEvent, action);
|
||||
yield();
|
||||
// Use a tmp string to call PLUGIN_WRITE, since PluginCall may inadvertenly alter the string.
|
||||
String tmpAction(action);
|
||||
if (!PluginCall(PLUGIN_WRITE, &TempEvent, tmpAction)) {
|
||||
if (!tmpAction.equals(action)) {
|
||||
String log = F("PLUGIN_WRITE altered the string: ");
|
||||
log += action;
|
||||
log += F(" to: ");
|
||||
log += tmpAction;
|
||||
addLog(LOG_LEVEL_ERROR, log);
|
||||
struct EventStruct TempEvent;
|
||||
parseCommandString(&TempEvent, action);
|
||||
yield();
|
||||
// Use a tmp string to call PLUGIN_WRITE, since PluginCall may inadvertenly alter the string.
|
||||
String tmpAction(action);
|
||||
if (!PluginCall(PLUGIN_WRITE, &TempEvent, tmpAction)) {
|
||||
if (!tmpAction.equals(action)) {
|
||||
String log = F("PLUGIN_WRITE altered the string: ");
|
||||
log += action;
|
||||
log += F(" to: ");
|
||||
log += tmpAction;
|
||||
addLog(LOG_LEVEL_ERROR, log);
|
||||
}
|
||||
ExecuteCommand(VALUE_SOURCE_SYSTEM, action.c_str());
|
||||
}
|
||||
ExecuteCommand(VALUE_SOURCE_SYSTEM, action.c_str());
|
||||
yield();
|
||||
}
|
||||
yield();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
line = "";
|
||||
line = "";
|
||||
}
|
||||
}
|
||||
//pos++;
|
||||
}
|
||||
|
||||
nestingLevel--;
|
||||
checkRAM(F("rulesProcessingFile2"));
|
||||
return(String());
|
||||
return (String());
|
||||
}
|
||||
|
||||
|
||||
@@ -2502,7 +2520,7 @@ class RamTracker{
|
||||
writePtr=0;
|
||||
for (int i = 0; i< TRACES; i++) {
|
||||
traces[i]="";
|
||||
tracesMemory[i]=0xffff; // init with best case memory values, so they get replaced if memory goes lower
|
||||
tracesMemory[i]=0xffffffff; // init with best case memory values, so they get replaced if memory goes lower
|
||||
}
|
||||
for (int i = 0; i< TRACEENTRIES; i++) {
|
||||
nextAction[i]="startup";
|
||||
@@ -2611,7 +2629,7 @@ void play_rtttl(uint8_t _pin, const char *p )
|
||||
#define OCTAVE_OFFSET 0
|
||||
// FIXME: Absolutely no error checking in here
|
||||
|
||||
int notes[] = { 0,
|
||||
const int notes[] = { 0,
|
||||
262, 277, 294, 311, 330, 349, 370, 392, 415, 440, 466, 494,
|
||||
523, 554, 587, 622, 659, 698, 740, 784, 831, 880, 932, 988,
|
||||
1047, 1109, 1175, 1245, 1319, 1397, 1480, 1568, 1661, 1760, 1865, 1976,
|
||||
|
||||
+7
-170
@@ -12,7 +12,7 @@
|
||||
\*********************************************************************************************/
|
||||
void syslog(const char *message)
|
||||
{
|
||||
if (Settings.Syslog_IP[0] != 0 && WiFi.status() == WL_CONNECTED)
|
||||
if (Settings.Syslog_IP[0] != 0 && wifiStatus == ESPEASY_WIFI_SERVICES_INITIALIZED)
|
||||
{
|
||||
IPAddress broadcastIP(Settings.Syslog_IP[0], Settings.Syslog_IP[1], Settings.Syslog_IP[2], Settings.Syslog_IP[3]);
|
||||
portUDP.beginPacket(broadcastIP, 514);
|
||||
@@ -36,35 +36,6 @@ void syslog(const char *message)
|
||||
}
|
||||
|
||||
|
||||
/*********************************************************************************************\
|
||||
Structs for UDP messaging
|
||||
\*********************************************************************************************/
|
||||
struct infoStruct
|
||||
{
|
||||
byte header = 255;
|
||||
byte ID = 3;
|
||||
byte sourcelUnit;
|
||||
byte destUnit;
|
||||
byte sourceTaskIndex;
|
||||
byte destTaskIndex;
|
||||
byte deviceNumber;
|
||||
char taskName[26];
|
||||
char ValueNames[VARS_PER_TASK][26];
|
||||
};
|
||||
|
||||
struct dataStruct
|
||||
{
|
||||
byte header = 255;
|
||||
byte ID = 5;
|
||||
byte sourcelUnit;
|
||||
byte destUnit;
|
||||
byte sourceTaskIndex;
|
||||
byte destTaskIndex;
|
||||
float Values[VARS_PER_TASK];
|
||||
};
|
||||
|
||||
//TODO: add sysinfoStruct
|
||||
|
||||
/*********************************************************************************************\
|
||||
Check UDP messages (ESPEasy propiertary protocol)
|
||||
\*********************************************************************************************/
|
||||
@@ -108,22 +79,10 @@ void checkUDP()
|
||||
}
|
||||
else
|
||||
{
|
||||
if (packetBuffer[1] > 1 && packetBuffer[1] < 6)
|
||||
{
|
||||
String log = (F("UDP : Sensor msg "));
|
||||
for (byte x = 1; x < 6; x++)
|
||||
{
|
||||
log += " ";
|
||||
log += (int)packetBuffer[x];
|
||||
}
|
||||
addLog(LOG_LEVEL_DEBUG_MORE, log);
|
||||
}
|
||||
|
||||
// binary data!
|
||||
switch (packetBuffer[1])
|
||||
{
|
||||
|
||||
//TODO: use a nice struct for it
|
||||
case 1: // sysinfo message
|
||||
{
|
||||
byte mac[6];
|
||||
@@ -160,70 +119,13 @@ void checkUDP()
|
||||
break;
|
||||
}
|
||||
|
||||
case 2: // sensor info pull request
|
||||
{
|
||||
SendUDPTaskInfo(packetBuffer[2], packetBuffer[5], packetBuffer[4]);
|
||||
break;
|
||||
}
|
||||
|
||||
case 3: // sensor info
|
||||
{
|
||||
if (Settings.GlobalSync)
|
||||
{
|
||||
struct infoStruct infoReply;
|
||||
memcpy((byte*)&infoReply, (byte*)&packetBuffer, sizeof(infoStruct));
|
||||
|
||||
// to prevent flash wear out (bugs in communication?) we can only write to an empty task
|
||||
// so it will write only once and has to be cleared manually through webgui
|
||||
if (Settings.TaskDeviceNumber[infoReply.destTaskIndex] == 0)
|
||||
{
|
||||
Settings.TaskDeviceNumber[infoReply.destTaskIndex] = infoReply.deviceNumber;
|
||||
Settings.TaskDeviceDataFeed[infoReply.destTaskIndex] = 1; // remote feed
|
||||
for (byte x=0; x < CONTROLLER_MAX; x++)
|
||||
Settings.TaskDeviceSendData[x][infoReply.destTaskIndex] = false;
|
||||
strcpy(ExtraTaskSettings.TaskDeviceName, infoReply.taskName);
|
||||
for (byte x = 0; x < VARS_PER_TASK; x++)
|
||||
strcpy( ExtraTaskSettings.TaskDeviceValueNames[x], infoReply.ValueNames[x]);
|
||||
SaveTaskSettings(infoReply.destTaskIndex);
|
||||
SaveSettings();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 4: // sensor data pull request
|
||||
{
|
||||
SendUDPTaskData(packetBuffer[2], packetBuffer[5], packetBuffer[4]);
|
||||
break;
|
||||
}
|
||||
|
||||
case 5: // sensor data
|
||||
{
|
||||
if (Settings.GlobalSync)
|
||||
{
|
||||
struct dataStruct dataReply;
|
||||
memcpy((byte*)&dataReply, (byte*)&packetBuffer, sizeof(dataStruct));
|
||||
|
||||
// only if this task has a remote feed, update values
|
||||
if (Settings.TaskDeviceDataFeed[dataReply.destTaskIndex] != 0)
|
||||
{
|
||||
for (byte x = 0; x < VARS_PER_TASK; x++)
|
||||
{
|
||||
UserVar[dataReply.destTaskIndex * VARS_PER_TASK + x] = dataReply.Values[x];
|
||||
}
|
||||
if (Settings.UseRules)
|
||||
createRuleEvents(dataReply.destTaskIndex);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
struct EventStruct TempEvent;
|
||||
TempEvent.Data = (byte*)packetBuffer;
|
||||
TempEvent.Par1 = remoteIP[3];
|
||||
PluginCall(PLUGIN_UDP_IN, &TempEvent, dummyString);
|
||||
CPluginCall(CPLUGIN_UDP_IN, &TempEvent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -236,73 +138,6 @@ void checkUDP()
|
||||
}
|
||||
|
||||
|
||||
/*********************************************************************************************\
|
||||
Send task info using UDP message
|
||||
\*********************************************************************************************/
|
||||
void SendUDPTaskInfo(byte destUnit, byte sourceTaskIndex, byte destTaskIndex)
|
||||
{
|
||||
if (!WiFiConnected(100)) {
|
||||
return;
|
||||
}
|
||||
struct infoStruct infoReply;
|
||||
infoReply.sourcelUnit = Settings.Unit;
|
||||
infoReply.sourceTaskIndex = sourceTaskIndex;
|
||||
infoReply.destTaskIndex = destTaskIndex;
|
||||
LoadTaskSettings(infoReply.sourceTaskIndex);
|
||||
infoReply.deviceNumber = Settings.TaskDeviceNumber[infoReply.sourceTaskIndex];
|
||||
strcpy(infoReply.taskName, ExtraTaskSettings.TaskDeviceName);
|
||||
for (byte x = 0; x < VARS_PER_TASK; x++)
|
||||
strcpy(infoReply.ValueNames[x], ExtraTaskSettings.TaskDeviceValueNames[x]);
|
||||
|
||||
byte firstUnit = 1;
|
||||
byte lastUnit = UNIT_MAX - 1;
|
||||
if (destUnit != 0)
|
||||
{
|
||||
firstUnit = destUnit;
|
||||
lastUnit = destUnit;
|
||||
}
|
||||
for (byte x = firstUnit; x <= lastUnit; x++)
|
||||
{
|
||||
infoReply.destUnit = x;
|
||||
sendUDP(x, (byte*)&infoReply, sizeof(infoStruct));
|
||||
delay(10);
|
||||
}
|
||||
delay(50);
|
||||
}
|
||||
|
||||
|
||||
/*********************************************************************************************\
|
||||
Send task data using UDP message
|
||||
\*********************************************************************************************/
|
||||
void SendUDPTaskData(byte destUnit, byte sourceTaskIndex, byte destTaskIndex)
|
||||
{
|
||||
if (!WiFiConnected(100)) {
|
||||
return;
|
||||
}
|
||||
struct dataStruct dataReply;
|
||||
dataReply.sourcelUnit = Settings.Unit;
|
||||
dataReply.sourceTaskIndex = sourceTaskIndex;
|
||||
dataReply.destTaskIndex = destTaskIndex;
|
||||
for (byte x = 0; x < VARS_PER_TASK; x++)
|
||||
dataReply.Values[x] = UserVar[dataReply.sourceTaskIndex * VARS_PER_TASK + x];
|
||||
|
||||
byte firstUnit = 1;
|
||||
byte lastUnit = UNIT_MAX - 1;
|
||||
if (destUnit != 0)
|
||||
{
|
||||
firstUnit = destUnit;
|
||||
lastUnit = destUnit;
|
||||
}
|
||||
for (byte x = firstUnit; x <= lastUnit; x++)
|
||||
{
|
||||
dataReply.destUnit = x;
|
||||
sendUDP(x, (byte*) &dataReply, sizeof(dataStruct));
|
||||
delay(10);
|
||||
}
|
||||
delay(50);
|
||||
}
|
||||
|
||||
|
||||
/*********************************************************************************************\
|
||||
Send event using UDP message
|
||||
\*********************************************************************************************/
|
||||
@@ -761,7 +596,10 @@ bool WiFiConnected(uint32_t timeout_ms) {
|
||||
yield(); // Allow at least once time for backgroundtasks
|
||||
min_delay = 10;
|
||||
}
|
||||
while (WiFi.status() != WL_CONNECTED) {
|
||||
// Apparently something needs network, perform check to see if it is ready now.
|
||||
// if (!tryConnectWiFi())
|
||||
// return false;
|
||||
while (wifiStatus != ESPEASY_WIFI_SERVICES_INITIALIZED) {
|
||||
if (timeOutReached(timer)) {
|
||||
return false;
|
||||
}
|
||||
@@ -784,7 +622,7 @@ bool hostReachable(const IPAddress& ip) {
|
||||
--retry;
|
||||
}
|
||||
String log = F("Host unreachable: ");
|
||||
log += ip;
|
||||
log += formatIP(ip);
|
||||
addLog(LOG_LEVEL_ERROR, log);
|
||||
return false;
|
||||
}
|
||||
@@ -798,4 +636,3 @@ bool hostReachable(const String& hostname) {
|
||||
addLog(LOG_LEVEL_ERROR, log);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+21
-8
@@ -278,17 +278,20 @@ void parseSystemVariables(String& s, boolean useURLencode)
|
||||
repl(F("%CR%"), F("\r"), s, useURLencode);
|
||||
repl(F("%LF%"), F("\n"), s, useURLencode);
|
||||
SMART_REPL(F("%ip%"),WiFi.localIP().toString())
|
||||
SMART_REPL(F("%rssi%"), String((WiFi.status() == WL_CONNECTED) ? WiFi.RSSI() : 0))
|
||||
SMART_REPL(F("%ssid%"), (WiFi.status() == WL_CONNECTED) ? WiFi.SSID() : F("--"))
|
||||
SMART_REPL(F("%rssi%"), String((wifiStatus == ESPEASY_WIFI_DISCONNECTED) ? 0 : WiFi.RSSI()))
|
||||
SMART_REPL(F("%ssid%"), (wifiStatus == ESPEASY_WIFI_DISCONNECTED) ? F("--") : WiFi.SSID())
|
||||
SMART_REPL(F("%unit%"), String(Settings.Unit))
|
||||
SMART_REPL(F("%mac%"), String(WiFi.macAddress()))
|
||||
#if defined(ESP8266)
|
||||
SMART_REPL(F("%mac_int%"), String(ESP.getChipId())) // Last 24 bit of MAC address as integer, to be used in rules.
|
||||
#endif
|
||||
|
||||
|
||||
if (s.indexOf(F("%sys")) != -1) {
|
||||
SMART_REPL(F("%sysload%"), String(100 - (100 * loopCounterLast / loopCounterMax)))
|
||||
SMART_REPL(F("%systm_hm%"), getTimeString(':', false))
|
||||
SMART_REPL(F("%systm_hm_am%"), getTimeString_ampm(':', false))
|
||||
SMART_REPL(F("%systime%"), getTimeString(':'))
|
||||
SMART_REPL(F("%systime_am%"), getTimeString_ampm(':'))
|
||||
repl(F("%sysname%"), Settings.Name, s, useURLencode);
|
||||
|
||||
// valueString is being used by the macro.
|
||||
@@ -306,7 +309,9 @@ void parseSystemVariables(String& s, boolean useURLencode)
|
||||
#undef SMART_REPL_TIME
|
||||
}
|
||||
SMART_REPL(F("%lcltime%"), getDateTimeString('-',':',' '))
|
||||
SMART_REPL(F("%lcltime_am%"), getDateTimeString_ampm('-',':',' '))
|
||||
SMART_REPL(F("%uptime%"), String(wdcounter / 2))
|
||||
SMART_REPL(F("%unixtime%"), String(getUnixTime()))
|
||||
|
||||
repl(F("%tskname%"), ExtraTaskSettings.TaskDeviceName, s, useURLencode);
|
||||
if (s.indexOf("%vname") != -1) {
|
||||
@@ -356,16 +361,24 @@ bool getConvertArgument(const String& marker, const String& s, float& argument,
|
||||
// Parse conversions marked with "%conv_marker%(float)"
|
||||
// Must be called last, since all sensor values must be converted, processed, etc.
|
||||
void parseStandardConversions(String& s, boolean useURLencode) {
|
||||
if (s.indexOf(F("%conv")) == -1)
|
||||
if (s.indexOf(F("%c_")) == -1)
|
||||
return; // Nothing to replace
|
||||
|
||||
float argument = 0.0;
|
||||
float arg = 0.0;
|
||||
int startIndex = 0;
|
||||
int endIndex = 0;
|
||||
// These replacements should be done in a while loop per marker,
|
||||
// since they also replace the numerical parameter.
|
||||
// The marker may occur more than once per string, but with different parameters.
|
||||
while (getConvertArgument(F("%conv_wind_dir%"), s, argument, startIndex, endIndex)) {
|
||||
repl(s.substring(startIndex, endIndex), getBearing(argument), s, useURLencode);
|
||||
}
|
||||
#define SMART_CONV(T,FUN) while (getConvertArgument((T), s, arg, startIndex, endIndex)) { repl(s.substring(startIndex, endIndex), (FUN), s, useURLencode); }
|
||||
SMART_CONV(F("%c_w_dir%"), getBearing(arg))
|
||||
SMART_CONV(F("%c_c2f%"), toString(CelsiusToFahrenheit(arg), 1))
|
||||
SMART_CONV(F("%c_ms2Bft%"), String(m_secToBeaufort(arg)))
|
||||
SMART_CONV(F("%c_cm2imp%"), centimeterToImperialLength(arg))
|
||||
SMART_CONV(F("%c_mm2imp%"), millimeterToImperialLength(arg))
|
||||
SMART_CONV(F("%c_m2day%"), toString(minutesToDay(arg), 2))
|
||||
SMART_CONV(F("%c_m2dh%"), minutesToDayHour(arg))
|
||||
SMART_CONV(F("%c_m2dhm%"), minutesToDayHourMinute(arg))
|
||||
SMART_CONV(F("%c_s2dhms%"), secondsToDayHourMinuteSecond(arg))
|
||||
#undef SMART_CONV
|
||||
}
|
||||
|
||||
+74
-20
@@ -72,8 +72,20 @@ void breakTime(unsigned long timeInput, struct timeStruct &tm) {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
unsigned long now() {
|
||||
@@ -87,10 +99,6 @@ unsigned long now() {
|
||||
unsigned long t = getNtpTime();
|
||||
if (t != 0) {
|
||||
setTime(t);
|
||||
applyTimeZone(t);
|
||||
} else {
|
||||
// Unable to sync, retry again in a minute
|
||||
nextSyncTime = sysTime + 60;
|
||||
}
|
||||
}
|
||||
uint32_t localSystime = toLocal(sysTime);
|
||||
@@ -190,19 +198,30 @@ void checkTime()
|
||||
|
||||
unsigned long getNtpTime()
|
||||
{
|
||||
if (!Settings.UseNTP || !WiFiConnected(100)) {
|
||||
if (!Settings.UseNTP || !WiFiConnected(10)) {
|
||||
return 0;
|
||||
}
|
||||
IPAddress timeServerIP;
|
||||
const char* ntpServerName = "pool.ntp.org";
|
||||
// Have to do a lookup eacht time, since the NTP pool always returns another IP
|
||||
if (Settings.NTPHost[0] != 0)
|
||||
String log = F("NTP : NTP send to ");
|
||||
if (Settings.NTPHost[0] != 0) {
|
||||
WiFi.hostByName(Settings.NTPHost, timeServerIP);
|
||||
else
|
||||
WiFi.hostByName(ntpServerName, timeServerIP);
|
||||
log += Settings.NTPHost;
|
||||
// When single set host fails, retry again in a minute
|
||||
nextSyncTime = sysTime + 20;
|
||||
}
|
||||
else {
|
||||
// Have to do a lookup eacht time, since the NTP pool always returns another IP
|
||||
String ntpServerName = String(random(0, 3));
|
||||
ntpServerName += F(".pool.ntp.org");
|
||||
WiFi.hostByName(ntpServerName.c_str(), timeServerIP);
|
||||
log += ntpServerName;
|
||||
// When pool host fails, retry can be much sooner
|
||||
nextSyncTime = sysTime + 5;
|
||||
}
|
||||
|
||||
if (!hostReachable(timeServerIP))
|
||||
if (!hostReachable(timeServerIP)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
WiFiUDP udp;
|
||||
udp.begin(123);
|
||||
@@ -210,8 +229,9 @@ unsigned long getNtpTime()
|
||||
const int NTP_PACKET_SIZE = 48; // NTP time is in the first 48 bytes of message
|
||||
byte packetBuffer[NTP_PACKET_SIZE]; //buffer to hold incoming & outgoing packets
|
||||
|
||||
String log = F("NTP : NTP send to ");
|
||||
log += F(" (");
|
||||
log += timeServerIP.toString();
|
||||
log += F(")");
|
||||
addLog(LOG_LEVEL_DEBUG_MORE, log);
|
||||
|
||||
while (udp.parsePacket() > 0) ; // discard any previously received packets
|
||||
@@ -246,6 +266,7 @@ unsigned long getNtpTime()
|
||||
addLog(LOG_LEVEL_DEBUG_MORE, log);
|
||||
return secsSince1900 - 2208988800UL;
|
||||
}
|
||||
delay(10);
|
||||
}
|
||||
log = F("NTP : No reply");
|
||||
addLog(LOG_LEVEL_DEBUG_MORE, log);
|
||||
@@ -383,16 +404,40 @@ String getDateString()
|
||||
|
||||
// returns the current Time separated by the given delimiter
|
||||
// time format example with ':' delimiter: 23:59:59 (HH:MM:SS)
|
||||
String getTimeString(const timeStruct& ts, char delimiter)
|
||||
String getTimeString(const timeStruct& ts, char delimiter, bool am_pm, bool show_seconds)
|
||||
{
|
||||
char TimeString[20]; //19 digits plus the null char
|
||||
sprintf_P(TimeString, PSTR("%02d%c%02d%c%02d"), ts.Hour, delimiter, ts.Minute, delimiter, ts.Second);
|
||||
if (am_pm) {
|
||||
uint8_t hour(ts.Hour % 12);
|
||||
if (hour == 0) { hour = 12; }
|
||||
const char a_or_p = ts.Hour < 12 ? 'A' : 'P';
|
||||
if (show_seconds) {
|
||||
sprintf_P(TimeString, PSTR("%d%c%02d%c%02d %cM"),
|
||||
hour, delimiter, ts.Minute, delimiter, ts.Second, a_or_p);
|
||||
} else {
|
||||
sprintf_P(TimeString, PSTR("%d%c%02d %cM"),
|
||||
hour, delimiter, ts.Minute, a_or_p);
|
||||
}
|
||||
} else {
|
||||
if (show_seconds) {
|
||||
sprintf_P(TimeString, PSTR("%02d%c%02d%c%02d"),
|
||||
ts.Hour, delimiter, ts.Minute, delimiter, ts.Second);
|
||||
} else {
|
||||
sprintf_P(TimeString, PSTR("%d%c%02d"),
|
||||
ts.Hour, delimiter, ts.Minute);
|
||||
}
|
||||
}
|
||||
return TimeString;
|
||||
}
|
||||
|
||||
String getTimeString(char delimiter)
|
||||
String getTimeString(char delimiter, bool show_seconds /*=true*/)
|
||||
{
|
||||
return getTimeString(tm, delimiter);
|
||||
return getTimeString(tm, delimiter, false, show_seconds);
|
||||
}
|
||||
|
||||
String getTimeString_ampm(char delimiter, bool show_seconds /*=true*/)
|
||||
{
|
||||
return getTimeString(tm, delimiter, true, show_seconds);
|
||||
}
|
||||
|
||||
// returns the current Time without delimiter
|
||||
@@ -402,20 +447,29 @@ String getTimeString()
|
||||
return getTimeString('\0');
|
||||
}
|
||||
|
||||
String getTimeString_ampm()
|
||||
{
|
||||
return getTimeString_ampm('\0');
|
||||
}
|
||||
|
||||
// returns the current Date and Time separated by the given delimiter
|
||||
// if called like this: getDateTimeString('\0', '\0', '\0');
|
||||
// it will give back this: 20161231235959 (YYYYMMDDHHMMSS)
|
||||
String getDateTimeString(const timeStruct& ts, char dateDelimiter, char timeDelimiter, char dateTimeDelimiter)
|
||||
String getDateTimeString(const timeStruct& ts, char dateDelimiter, char timeDelimiter, char dateTimeDelimiter, bool am_pm)
|
||||
{
|
||||
String ret = getDateString(ts, dateDelimiter);
|
||||
if (dateTimeDelimiter != '\0')
|
||||
ret += dateTimeDelimiter;
|
||||
ret += getTimeString(ts, timeDelimiter);
|
||||
ret += getTimeString(ts, timeDelimiter, am_pm, true);
|
||||
return ret;
|
||||
}
|
||||
|
||||
String getDateTimeString(char dateDelimiter, char timeDelimiter, char dateTimeDelimiter) {
|
||||
return getDateTimeString(tm, dateDelimiter, timeDelimiter, dateTimeDelimiter);
|
||||
return getDateTimeString(tm, dateDelimiter, timeDelimiter, dateTimeDelimiter, false);
|
||||
}
|
||||
|
||||
String getDateTimeString_ampm(char dateDelimiter, char timeDelimiter, char dateTimeDelimiter) {
|
||||
return getDateTimeString(tm, dateDelimiter, timeDelimiter, dateTimeDelimiter, true);
|
||||
}
|
||||
|
||||
/********************************************************************************************\
|
||||
@@ -434,7 +488,7 @@ unsigned long string2TimeLong(const String &str)
|
||||
// Within a scope so the tmpString is only used for copy.
|
||||
String tmpString(str);
|
||||
tmpString.toLowerCase();
|
||||
tmpString.toCharArray(command, 20);
|
||||
tmpString.toCharArray(command, 20);
|
||||
}
|
||||
unsigned long lngTime = 0;
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ void logTimeZoneInfo() {
|
||||
if (m_dstLoc != 0) {
|
||||
timeStruct tmp;
|
||||
breakTime(m_dstLoc, tmp);
|
||||
log += getDateTimeString(tmp, '-', ':', ' ');
|
||||
log += getDateTimeString(tmp, '-', ':', ' ', false);
|
||||
}
|
||||
log += F(" offset: ");
|
||||
log += m_dst.offset;
|
||||
@@ -108,7 +108,7 @@ void logTimeZoneInfo() {
|
||||
if (m_stdLoc != 0) {
|
||||
timeStruct tmp;
|
||||
breakTime(m_stdLoc, tmp);
|
||||
log += getDateTimeString(tmp, '-', ':', ' ');
|
||||
log += getDateTimeString(tmp, '-', ':', ' ', false);
|
||||
}
|
||||
log += F(" offset: ");
|
||||
log += m_std.offset;
|
||||
|
||||
+213
-135
@@ -6,6 +6,7 @@
|
||||
#define ONLY_IP_RANGE_ALLOWED 2
|
||||
#define _HEAD false
|
||||
#define _TAIL true
|
||||
#define CHUNKED_BUFFER_SIZE 400
|
||||
|
||||
void sendContentBlocking(String& data);
|
||||
void sendHeaderBlocking(bool json);
|
||||
@@ -21,58 +22,72 @@ public:
|
||||
uint32_t finalRam;
|
||||
uint32_t maxCoreUsage;
|
||||
uint32_t maxServerUsage;
|
||||
unsigned int BufferSize;
|
||||
unsigned int sentBytes;
|
||||
String buf;
|
||||
|
||||
StreamingBuffer(void) : lowMemorySkip(false),
|
||||
initialRam(0), beforeTXRam(0), duringTXRam(0), finalRam(0), maxCoreUsage(0),
|
||||
maxServerUsage(0), BufferSize(400), sentBytes(0)
|
||||
maxServerUsage(0), sentBytes(0)
|
||||
{
|
||||
buf.reserve(BufferSize + 100);
|
||||
buf.reserve(CHUNKED_BUFFER_SIZE + 50);
|
||||
buf = "";
|
||||
}
|
||||
StreamingBuffer operator= (String& a) { this->buf=a; checkFull(); return *this; }
|
||||
StreamingBuffer operator= (const String& a) { this->buf=a; checkFull(); return *this; }
|
||||
StreamingBuffer operator+= (long unsigned int a) { this->buf+=String(a); checkFull(); return *this; }
|
||||
StreamingBuffer operator+= (float a) { this->buf+=String(a); checkFull(); return *this; }
|
||||
StreamingBuffer operator+= (int a) { this->buf+=String(a); checkFull(); return *this; }
|
||||
StreamingBuffer operator+= (uint32_t a) { this->buf+=String(a); checkFull(); return *this; }
|
||||
StreamingBuffer operator+=(const String& a) {
|
||||
StreamingBuffer operator= (String& a) { flush(); return addString(a); }
|
||||
StreamingBuffer operator= (const String& a) { flush(); return addString(a); }
|
||||
StreamingBuffer operator+= (long unsigned int a) { return addString(String(a)); }
|
||||
StreamingBuffer operator+= (float a) { return addString(String(a)); }
|
||||
StreamingBuffer operator+= (int a) { return addString(String(a)); }
|
||||
StreamingBuffer operator+= (uint32_t a) { return addString(String(a)); }
|
||||
StreamingBuffer operator+=(const String& a) { return addString(a); }
|
||||
|
||||
StreamingBuffer addString(const String& a) {
|
||||
if (lowMemorySkip) return *this;
|
||||
const int length = a.length();
|
||||
if (((this->buf.length() + length) > BufferSize) &&
|
||||
(this->buf.length() > 100))
|
||||
sendContentBlocking(this->buf);
|
||||
int flush_step = CHUNKED_BUFFER_SIZE - this->buf.length();
|
||||
if (flush_step < 1) flush_step = 0;
|
||||
int pos = 0;
|
||||
int flush_step = BufferSize - this->buf.length();
|
||||
if (flush_step < 1) flush_step = 1;
|
||||
const int length = a.length();
|
||||
while (pos < length) {
|
||||
const char c = a[pos];
|
||||
this->buf += c;
|
||||
++pos;
|
||||
--flush_step;
|
||||
if (flush_step == 0) {
|
||||
sendContentBlocking(this->buf);
|
||||
flush_step = BufferSize;
|
||||
flush_step = CHUNKED_BUFFER_SIZE;
|
||||
}
|
||||
this->buf += a[pos];
|
||||
++pos;
|
||||
--flush_step;
|
||||
}
|
||||
checkFull();
|
||||
return *this;
|
||||
}
|
||||
|
||||
void flush() {
|
||||
if (lowMemorySkip) {
|
||||
this->buf = "";
|
||||
} else {
|
||||
sendContentBlocking(this->buf);
|
||||
}
|
||||
}
|
||||
|
||||
void checkFull(void) {
|
||||
if (lowMemorySkip) this->buf = "";
|
||||
if (this->buf.length() > BufferSize) {
|
||||
if (this->buf.length() > CHUNKED_BUFFER_SIZE) {
|
||||
trackTotalMem();
|
||||
sendContentBlocking(this->buf);
|
||||
}
|
||||
}
|
||||
|
||||
void startStream() {
|
||||
startStream(false);
|
||||
}
|
||||
|
||||
void startJsonStream() {
|
||||
startStream(true);
|
||||
}
|
||||
|
||||
private:
|
||||
void startStream(bool json) {
|
||||
maxCoreUsage = maxServerUsage = 0;
|
||||
beforeTXRam = ESP.getFreeHeap();
|
||||
initialRam = ESP.getFreeHeap();
|
||||
beforeTXRam = initialRam;
|
||||
sentBytes = 0;
|
||||
buf = "";
|
||||
if (beforeTXRam < 3000) {
|
||||
@@ -83,7 +98,7 @@ public:
|
||||
#endif
|
||||
return;
|
||||
} else
|
||||
sendHeaderBlocking();
|
||||
sendHeaderBlocking(json);
|
||||
}
|
||||
|
||||
void trackTotalMem() {
|
||||
@@ -92,6 +107,8 @@ public:
|
||||
maxServerUsage = initialRam - beforeTXRam;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
void trackCoreMem() {
|
||||
duringTXRam = ESP.getFreeHeap();
|
||||
if ((initialRam - duringTXRam) > maxCoreUsage)
|
||||
@@ -118,17 +135,18 @@ public:
|
||||
void sendContentBlocking(String& data) {
|
||||
checkRAM(F("sendContentBlocking"));
|
||||
uint32_t freeBeforeSend = ESP.getFreeHeap();
|
||||
String log = String("sendcontent free: ") + freeBeforeSend + " chunk size:" + data.length();
|
||||
const uint32_t length = data.length();
|
||||
String log = String("sendcontent free: ") + freeBeforeSend + " chunk size:" + length;
|
||||
addLog(LOG_LEVEL_DEBUG_DEV, log);
|
||||
freeBeforeSend = ESP.getFreeHeap();
|
||||
if (TXBuffer.beforeTXRam > freeBeforeSend)
|
||||
TXBuffer.beforeTXRam = freeBeforeSend;
|
||||
TXBuffer.duringTXRam = freeBeforeSend;
|
||||
#if defined(ESP8266) && defined(ARDUINO_ESP8266_RELEASE_2_3_0)
|
||||
String size = String(data.length(), HEX) + "\r\n";
|
||||
String size = String(length, HEX) + "\r\n";
|
||||
// do chunked transfer encoding ourselves (WebServer doesn't support it)
|
||||
WebServer.sendContent(size);
|
||||
if (data.length()) WebServer.sendContent(data);
|
||||
if (length > 0) WebServer.sendContent(data);
|
||||
WebServer.sendContent("\r\n");
|
||||
#else // ESP8266 2.4.0rc2 and higher and the ESP32 webserver supports chunked http transfer
|
||||
unsigned int timeout = 0;
|
||||
@@ -147,18 +165,18 @@ void sendContentBlocking(String& data) {
|
||||
}
|
||||
#endif
|
||||
|
||||
TXBuffer.sentBytes += data.length();
|
||||
TXBuffer.sentBytes += length;
|
||||
data = "";
|
||||
}
|
||||
|
||||
void sendHeaderBlocking() {
|
||||
void sendHeaderBlocking(bool json) {
|
||||
checkRAM(F("sendHeaderBlocking"));
|
||||
#if defined(ESP8266) && defined(ARDUINO_ESP8266_RELEASE_2_3_0)
|
||||
WebServer.setContentLength(CONTENT_LENGTH_UNKNOWN);
|
||||
WebServer.sendHeader("Content-Type", "text/html", true);
|
||||
WebServer.sendHeader("Accept-Ranges", "none");
|
||||
WebServer.sendHeader("Cache-Control", "no-cache");
|
||||
WebServer.sendHeader("Transfer-Encoding", "chunked");
|
||||
WebServer.sendHeader(F("Content-Type"), json ? F("application/json") : F("text/html"), true);
|
||||
WebServer.sendHeader(F("Accept-Ranges"), F("none"));
|
||||
WebServer.sendHeader(F("Cache-Control"), F("no-cache"));
|
||||
WebServer.sendHeader(F("Transfer-Encoding"), F("chunked"));
|
||||
WebServer.send(200);
|
||||
#else
|
||||
unsigned int timeout = 0;
|
||||
@@ -167,8 +185,8 @@ void sendHeaderBlocking() {
|
||||
if (freeBeforeSend < 4000) timeout = 1000;
|
||||
const uint32_t beginWait = millis();
|
||||
WebServer.setContentLength(CONTENT_LENGTH_UNKNOWN);
|
||||
WebServer.sendHeader("Content-Type", "text/html", true);
|
||||
WebServer.sendHeader("Cache-Control", "no-cache");
|
||||
WebServer.sendHeader(F("Content-Type"), json ? F("application/json") : F("text/html"), true);
|
||||
WebServer.sendHeader(F("Cache-Control"), F("no-cache"));
|
||||
WebServer.send(200);
|
||||
// dont wait on 2.3.0. Memory returns just too slow.
|
||||
while ((ESP.getFreeHeap() < freeBeforeSend) &&
|
||||
@@ -349,7 +367,7 @@ void clearAccessBlock()
|
||||
//********************************************************************************
|
||||
// Web Interface init
|
||||
//********************************************************************************
|
||||
#include "core_version.h"
|
||||
//#include "core_version.h"
|
||||
#define HTML_SYMBOL_WARNING "⚠"
|
||||
|
||||
#if defined(ESP8266)
|
||||
@@ -380,6 +398,7 @@ static const char pgDefaultCSS[] PROGMEM = {
|
||||
".note {color: #444; font-style: italic; }"
|
||||
//header with title and menu
|
||||
".headermenu {position: fixed; top: 0; left: 0; right: 0; height: 90px; padding: 8px 12px; background-color: #F8F8F8; border-bottom: 1px solid #DDD; }"
|
||||
".apheader {padding: 8px 12px; background-color: #F8F8F8;}"
|
||||
".bodymenu {margin-top: 96px; }"
|
||||
// menu
|
||||
".menubar {position: inherit; top: 55px; }"
|
||||
@@ -494,11 +513,13 @@ void getWebPageTemplateDefault(const String& tmplName, String& tmpl)
|
||||
"{{css}}"
|
||||
"</head>"
|
||||
"<body>"
|
||||
"<header class='headermenu'>"
|
||||
"<header class='apheader'>"
|
||||
"<h1>Welcome to ESP Easy Mega AP</h1>"
|
||||
"</header>"
|
||||
"<section>"
|
||||
"<span class='message error'>"
|
||||
"{{error}}"
|
||||
"</span>"
|
||||
"{{content}}"
|
||||
"</section>"
|
||||
"<footer>"
|
||||
@@ -521,7 +542,9 @@ void getWebPageTemplateDefault(const String& tmplName, String& tmpl)
|
||||
"<h1>ESP Easy Mega: {{name}}</h1>"
|
||||
"</header>"
|
||||
"<section>"
|
||||
"<span class='message error'>"
|
||||
"{{error}}"
|
||||
"</span>"
|
||||
"{{content}}"
|
||||
"</section>"
|
||||
"<footer>"
|
||||
@@ -658,13 +681,15 @@ void getWebPageTemplateVar(const String& varName )
|
||||
// Send CSS per chunk to avoid sending either too short or too large strings.
|
||||
String tmpString;
|
||||
tmpString.reserve(64);
|
||||
uint16_t tmpStringPos = 0;
|
||||
for (unsigned int i = 0; i < strlen(pgDefaultCSS); i++)
|
||||
{
|
||||
const char c = (char)pgm_read_byte(&pgDefaultCSS[i]);
|
||||
tmpString += c;
|
||||
if (c == ';' || c == '{') {
|
||||
tmpString += (char)pgm_read_byte(&pgDefaultCSS[i]);
|
||||
++tmpStringPos;
|
||||
if (tmpStringPos == 64) {
|
||||
TXBuffer += tmpString;
|
||||
tmpString = "";
|
||||
tmpStringPos = 0;
|
||||
}
|
||||
} // saves 1k of ram
|
||||
if (tmpString.length() > 0) {
|
||||
@@ -831,7 +856,7 @@ void handle_root() {
|
||||
TXBuffer += formatIP(ip);
|
||||
|
||||
TXBuffer += F("<TD><TD>Wifi RSSI:<TD>");
|
||||
if (WiFi.status() == WL_CONNECTED)
|
||||
if (wifiStatus == ESPEASY_WIFI_SERVICES_INITIALIZED)
|
||||
{
|
||||
TXBuffer += String(WiFi.RSSI());
|
||||
TXBuffer += F(" dB");
|
||||
@@ -1014,7 +1039,7 @@ void handle_config() {
|
||||
}
|
||||
|
||||
Settings.Delay = sensordelay.toInt();
|
||||
Settings.deepSleep = (deepsleep == "on");
|
||||
Settings.deepSleep = deepsleep.toInt();
|
||||
Settings.deepSleepOnFail = (deepsleeponfail == "on");
|
||||
str2ip(espip, Settings.IP);
|
||||
str2ip(espgateway, Settings.Gateway);
|
||||
@@ -1070,7 +1095,9 @@ void handle_config() {
|
||||
|
||||
addFormSubHeader(TXBuffer.buf, F("Sleep Mode"));
|
||||
|
||||
addFormCheckBox(TXBuffer.buf, F("Sleep enabled"), F("deepsleep"), Settings.deepSleep);
|
||||
addFormNumericBox(TXBuffer.buf, F("Sleep awake time"), F("deepsleep"), Settings.deepSleep, 0, 255);
|
||||
addUnit(TXBuffer.buf, F("sec"));
|
||||
addFormNote(TXBuffer.buf, F("0 = Sleep Disabled, else time awake from sleep"));
|
||||
|
||||
addHelpButton(TXBuffer.buf, F("SleepMode"));
|
||||
addFormNumericBox(TXBuffer.buf, F("Sleep Delay"), F("delay"), Settings.Delay, 0, 4294); //limited by hardware to ~1.2h
|
||||
@@ -1184,6 +1211,7 @@ void handle_controllers() {
|
||||
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));
|
||||
CPlugin_ptr[ProtocolIndex](CPLUGIN_INIT, &TempEvent, dummyString);
|
||||
}
|
||||
}
|
||||
addHtmlError( TXBuffer.buf, SaveControllerSettings(controllerindex, (byte*)&ControllerSettings, sizeof(ControllerSettings)));
|
||||
@@ -1262,57 +1290,61 @@ void handle_controllers() {
|
||||
options[0] = F("Use IP address");
|
||||
options[1] = F("Use Hostname");
|
||||
|
||||
addFormSelector(TXBuffer.buf, F("Locate Controller"), F("usedns"), 2, options, NULL, NULL, choice, true);
|
||||
|
||||
if (ControllerSettings.UseDNS)
|
||||
{
|
||||
addFormTextBox(TXBuffer.buf, F("Controller Hostname"), F("controllerhostname"), ControllerSettings.HostName, sizeof(ControllerSettings.HostName)-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
addFormIPBox(TXBuffer.buf, F("Controller IP"), F("controllerip"), ControllerSettings.IP);
|
||||
}
|
||||
|
||||
addFormNumericBox(TXBuffer.buf, F("Controller Port"), F("controllerport"), ControllerSettings.Port, 1, 65535);
|
||||
|
||||
byte ProtocolIndex = getProtocolIndex(Settings.Protocol[controllerindex]);
|
||||
if (Protocol[ProtocolIndex].usesAccount)
|
||||
{
|
||||
String protoDisplayName;
|
||||
if (!getControllerProtocolDisplayName(ProtocolIndex, CONTROLLER_USER, protoDisplayName)) {
|
||||
protoDisplayName = F("Controller User");
|
||||
if (!Protocol[ProtocolIndex].Custom){
|
||||
|
||||
addFormSelector(TXBuffer.buf, F("Locate Controller"), F("usedns"), 2, options, NULL, NULL, choice, true);
|
||||
|
||||
if (ControllerSettings.UseDNS)
|
||||
{
|
||||
addFormTextBox(TXBuffer.buf, F("Controller Hostname"), F("controllerhostname"), ControllerSettings.HostName, sizeof(ControllerSettings.HostName)-1);
|
||||
}
|
||||
addFormTextBox(TXBuffer.buf, protoDisplayName, F("controlleruser"), SecuritySettings.ControllerUser[controllerindex], sizeof(SecuritySettings.ControllerUser[0])-1);
|
||||
}
|
||||
if (Protocol[ProtocolIndex].usesPassword)
|
||||
{
|
||||
String protoDisplayName;
|
||||
if (getControllerProtocolDisplayName(ProtocolIndex, CONTROLLER_PASS, protoDisplayName)) {
|
||||
// It is not a regular password, thus use normal text field.
|
||||
addFormTextBox(TXBuffer.buf, protoDisplayName, F("controllerpassword"), SecuritySettings.ControllerPassword[controllerindex], sizeof(SecuritySettings.ControllerPassword[0])-1);
|
||||
} else {
|
||||
addFormPasswordBox(TXBuffer.buf, F("Controller Password"), F("controllerpassword"), SecuritySettings.ControllerPassword[controllerindex], sizeof(SecuritySettings.ControllerPassword[0])-1);
|
||||
else
|
||||
{
|
||||
addFormIPBox(TXBuffer.buf, F("Controller IP"), F("controllerip"), ControllerSettings.IP);
|
||||
}
|
||||
|
||||
addFormNumericBox(TXBuffer.buf, F("Controller Port"), F("controllerport"), ControllerSettings.Port, 1, 65535);
|
||||
|
||||
if (Protocol[ProtocolIndex].usesAccount)
|
||||
{
|
||||
String protoDisplayName;
|
||||
if (!getControllerProtocolDisplayName(ProtocolIndex, CONTROLLER_USER, protoDisplayName)) {
|
||||
protoDisplayName = F("Controller User");
|
||||
}
|
||||
addFormTextBox(TXBuffer.buf, protoDisplayName, F("controlleruser"), SecuritySettings.ControllerUser[controllerindex], sizeof(SecuritySettings.ControllerUser[0])-1);
|
||||
}
|
||||
if (Protocol[ProtocolIndex].usesPassword)
|
||||
{
|
||||
String protoDisplayName;
|
||||
if (getControllerProtocolDisplayName(ProtocolIndex, CONTROLLER_PASS, protoDisplayName)) {
|
||||
// It is not a regular password, thus use normal text field.
|
||||
addFormTextBox(TXBuffer.buf, protoDisplayName, F("controllerpassword"), SecuritySettings.ControllerPassword[controllerindex], sizeof(SecuritySettings.ControllerPassword[0])-1);
|
||||
} else {
|
||||
addFormPasswordBox(TXBuffer.buf, F("Controller Password"), F("controllerpassword"), SecuritySettings.ControllerPassword[controllerindex], sizeof(SecuritySettings.ControllerPassword[0])-1);
|
||||
}
|
||||
}
|
||||
|
||||
if (Protocol[ProtocolIndex].usesTemplate || Protocol[ProtocolIndex].usesMQTT)
|
||||
{
|
||||
String protoDisplayName;
|
||||
if (!getControllerProtocolDisplayName(ProtocolIndex, CONTROLLER_SUBSCRIBE, protoDisplayName)) {
|
||||
protoDisplayName = F("Controller Subscribe");
|
||||
}
|
||||
addFormTextBox(TXBuffer.buf, protoDisplayName, F("controllersubscribe"), ControllerSettings.Subscribe, sizeof(ControllerSettings.Subscribe)-1);
|
||||
}
|
||||
|
||||
if (Protocol[ProtocolIndex].usesTemplate || Protocol[ProtocolIndex].usesMQTT)
|
||||
{
|
||||
String protoDisplayName;
|
||||
if (!getControllerProtocolDisplayName(ProtocolIndex, CONTROLLER_PUBLISH, protoDisplayName)) {
|
||||
protoDisplayName = F("Controller Publish");
|
||||
}
|
||||
addFormTextBox(TXBuffer.buf, protoDisplayName, F("controllerpublish"), ControllerSettings.Publish, sizeof(ControllerSettings.Publish)-1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (Protocol[ProtocolIndex].usesTemplate || Protocol[ProtocolIndex].usesMQTT)
|
||||
{
|
||||
String protoDisplayName;
|
||||
if (!getControllerProtocolDisplayName(ProtocolIndex, CONTROLLER_SUBSCRIBE, protoDisplayName)) {
|
||||
protoDisplayName = F("Controller Subscribe");
|
||||
}
|
||||
addFormTextBox(TXBuffer.buf, protoDisplayName, F("controllersubscribe"), ControllerSettings.Subscribe, sizeof(ControllerSettings.Subscribe)-1);
|
||||
}
|
||||
|
||||
if (Protocol[ProtocolIndex].usesTemplate || Protocol[ProtocolIndex].usesMQTT)
|
||||
{
|
||||
String protoDisplayName;
|
||||
if (!getControllerProtocolDisplayName(ProtocolIndex, CONTROLLER_PUBLISH, protoDisplayName)) {
|
||||
protoDisplayName = F("Controller Publish");
|
||||
}
|
||||
addFormTextBox(TXBuffer.buf, protoDisplayName, F("controllerpublish"), ControllerSettings.Publish, sizeof(ControllerSettings.Publish)-1);
|
||||
}
|
||||
|
||||
addFormCheckBox(TXBuffer.buf, F("Enabled"), F("controllerenabled"), Settings.ControllerEnabled[controllerindex]);
|
||||
|
||||
TempEvent.ControllerIndex = controllerindex;
|
||||
@@ -1823,18 +1855,6 @@ void handle_devices() {
|
||||
if (Device[DeviceIndex].InverseLogicOption)
|
||||
Settings.TaskDevicePin1Inversed[taskIndex] = (WebServer.arg(F("TDPI")) == F("on"));
|
||||
|
||||
if (Settings.GlobalSync)
|
||||
{
|
||||
if (Device[DeviceIndex].GlobalSyncOption)
|
||||
Settings.TaskDeviceGlobalSync[taskIndex] = (WebServer.arg(F("TDGS")) == F("on"));
|
||||
|
||||
// Send task info if set global
|
||||
if (Settings.TaskDeviceGlobalSync[taskIndex])
|
||||
{
|
||||
SendUDPTaskInfo(0, taskIndex, taskIndex);
|
||||
}
|
||||
}
|
||||
|
||||
for (byte varNr = 0; varNr < Device[DeviceIndex].ValueCount; varNr++)
|
||||
{
|
||||
|
||||
@@ -1862,6 +1882,18 @@ void handle_devices() {
|
||||
|
||||
//allow the plugin to save plugin-specific form settings.
|
||||
PluginCall(PLUGIN_WEBFORM_SAVE, &TempEvent, dummyString);
|
||||
|
||||
// notify controllers: CPLUGIN_TASK_CHANGE_NOTIFICATION
|
||||
for (byte x=0; x < CONTROLLER_MAX; x++)
|
||||
{
|
||||
TempEvent.ControllerIndex = x;
|
||||
if (Settings.TaskDeviceSendData[TempEvent.ControllerIndex][TempEvent.TaskIndex] &&
|
||||
Settings.ControllerEnabled[TempEvent.ControllerIndex] && Settings.Protocol[TempEvent.ControllerIndex])
|
||||
{
|
||||
TempEvent.ProtocolIndex = getProtocolIndex(Settings.Protocol[TempEvent.ControllerIndex]);
|
||||
CPlugin_ptr[TempEvent.ProtocolIndex](CPLUGIN_TASK_CHANGE_NOTIFICATION, &TempEvent, dummyString);
|
||||
}
|
||||
}
|
||||
}
|
||||
addHtmlError( SaveTaskSettings(taskIndex));
|
||||
|
||||
@@ -2060,11 +2092,6 @@ void handle_devices() {
|
||||
|
||||
addFormCheckBox(TXBuffer.buf, F("Enabled"), F("TDE"), Settings.TaskDeviceEnabled[taskIndex]); //="taskdeviceenabled"
|
||||
|
||||
if (Settings.GlobalSync && Device[DeviceIndex].GlobalSyncOption && Settings.TaskDeviceDataFeed[taskIndex] == 0 && Settings.UDPPort != 0)
|
||||
{
|
||||
addFormCheckBox(TXBuffer.buf, F("Global Sync"), F("TDGS"), Settings.TaskDeviceGlobalSync[taskIndex]); //="taskdeviceglobalsync"
|
||||
}
|
||||
|
||||
// section: Sensor / Actuator
|
||||
if (!Device[DeviceIndex].Custom && Settings.TaskDeviceDataFeed[taskIndex] == 0 &&
|
||||
((Device[DeviceIndex].Ports != 0) || (Device[DeviceIndex].PullUpOption) || (Device[DeviceIndex].InverseLogicOption) || (Device[DeviceIndex].Type >= DEVICE_TYPE_SINGLE && Device[DeviceIndex].Type <= DEVICE_TYPE_TRIPLE)) )
|
||||
@@ -3393,6 +3420,11 @@ void handle_login() {
|
||||
else
|
||||
{
|
||||
TXBuffer += F("Invalid password!");
|
||||
if (Settings.UseRules)
|
||||
{
|
||||
String event = F("Login#Failed");
|
||||
rulesProcessing(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3410,8 +3442,7 @@ void handle_control() {
|
||||
checkRAM(F("handle_control"));
|
||||
if (!clientIPallowed()) return;
|
||||
//TXBuffer.startStream(true); // true= json
|
||||
// sendHeadandTail(F("TmplStd"),_HEAD);
|
||||
|
||||
// sendHeadandTail(F("TmplStd"),_HEAD);
|
||||
String webrequest = WebServer.arg(F("cmd"));
|
||||
|
||||
// in case of event, store to buffer and return...
|
||||
@@ -3430,18 +3461,18 @@ void handle_control() {
|
||||
printToWeb = true;
|
||||
printWebString = "";
|
||||
|
||||
if (printToWebJSON)
|
||||
TXBuffer.startJsonStream();
|
||||
else
|
||||
TXBuffer.startStream();
|
||||
|
||||
if (PluginCall(PLUGIN_WRITE, &TempEvent, webrequest));
|
||||
else if (remoteConfig(&TempEvent, webrequest));
|
||||
else
|
||||
TXBuffer += F("Unknown or restricted command!");
|
||||
|
||||
TXBuffer += printWebString;
|
||||
|
||||
if (printToWebJSON)
|
||||
WebServer.send(200, "application/json");
|
||||
else
|
||||
WebServer.send(200, "text/html");
|
||||
TXBuffer += printWebString;
|
||||
TXBuffer.endStream();
|
||||
|
||||
printWebString = "";
|
||||
printToWeb = false;
|
||||
@@ -3468,10 +3499,44 @@ void handle_json()
|
||||
reply += F(",\n");
|
||||
reply += to_json_object_value(F("Unit"), String(Settings.Unit));
|
||||
reply += F(",\n");
|
||||
reply += to_json_object_value(F("Name"), String(Settings.Name));
|
||||
reply += F(",\n");
|
||||
reply += to_json_object_value(F("Uptime"), String(wdcounter / 2));
|
||||
reply += F(",\n");
|
||||
reply += to_json_object_value(F("Free RAM"), String(ESP.getFreeHeap()));
|
||||
reply += F("\n},\n");
|
||||
|
||||
reply += F("\"WiFi\":{\n");
|
||||
#if defined(ESP8266)
|
||||
reply += to_json_object_value(F("Hostname"), WiFi.hostname());
|
||||
#endif
|
||||
reply += F(",\n");
|
||||
reply += to_json_object_value(F("IP"), WiFi.localIP().toString());
|
||||
reply += F(",\n");
|
||||
reply += to_json_object_value(F("Subnet Mask"), WiFi.subnetMask().toString());
|
||||
reply += F(",\n");
|
||||
reply += to_json_object_value(F("Gateway IP"), WiFi.gatewayIP().toString());
|
||||
reply += F(",\n");
|
||||
reply += to_json_object_value(F("MAC address"), WiFi.macAddress());
|
||||
reply += F(",\n");
|
||||
reply += to_json_object_value(F("DNS 1"), WiFi.dnsIP(0).toString());
|
||||
reply += F(",\n");
|
||||
reply += to_json_object_value(F("DNS 2"), WiFi.dnsIP(1).toString());
|
||||
reply += F(",\n");
|
||||
reply += to_json_object_value(F("SSID"), WiFi.SSID());
|
||||
reply += F(",\n");
|
||||
reply += to_json_object_value(F("BSSID"), WiFi.BSSIDstr());
|
||||
reply += F(",\n");
|
||||
reply += to_json_object_value(F("Channel"), String(WiFi.channel()));
|
||||
reply += F(",\n");
|
||||
reply += to_json_object_value(F("Connected msec"), String(timeDiff(lastConnectMoment, millis())));
|
||||
reply += F(",\n");
|
||||
reply += to_json_object_value(F("Last Disconnect Reason"), String(lastDisconnectReason));
|
||||
reply += F(",\n");
|
||||
reply += to_json_object_value(F("Last Disconnect Reason str"), getLastDisconnectReason());
|
||||
reply += F(",\n");
|
||||
reply += to_json_object_value(F("RSSI"), String(WiFi.RSSI()));
|
||||
reply += F("\n},\n");
|
||||
}
|
||||
|
||||
byte taskNr = tasknr.toInt();
|
||||
@@ -3565,7 +3630,6 @@ void handle_advanced() {
|
||||
String usessdp = WebServer.arg(F("usessdp"));
|
||||
String edit = WebServer.arg(F("edit"));
|
||||
String wireclockstretchlimit = WebServer.arg(F("wireclockstretchlimit"));
|
||||
String globalsync = WebServer.arg(F("globalsync"));
|
||||
String userules = WebServer.arg(F("userules"));
|
||||
String cft = WebServer.arg(F("cft"));
|
||||
String MQTTRetainFlag = WebServer.arg(F("mqttretainflag"));
|
||||
@@ -3599,7 +3663,6 @@ void handle_advanced() {
|
||||
Settings.UseSSDP = (usessdp == "on");
|
||||
Settings.WireClockStretchLimit = wireclockstretchlimit.toInt();
|
||||
Settings.UseRules = (userules == "on");
|
||||
Settings.GlobalSync = (globalsync == "on");
|
||||
Settings.ConnectionFailuresThreshold = cft.toInt();
|
||||
Settings.MQTTRetainFlag = (MQTTRetainFlag == "on");
|
||||
Settings.ArduinoOTAEnable = (ArduinoOTAEnable == "on");
|
||||
@@ -3655,9 +3718,8 @@ void handle_advanced() {
|
||||
addFormNumericBox(TXBuffer.buf, F("Baud Rate"), F("baudrate"), Settings.BaudRate, 0, 1000000);
|
||||
|
||||
|
||||
addFormSubHeader(TXBuffer.buf, F("Inter-ESPEasy Network (experimental)"));
|
||||
addFormSubHeader(TXBuffer.buf, F("Inter-ESPEasy Network"));
|
||||
|
||||
addFormCheckBox( TXBuffer.buf, F("Global Sync"), F("globalsync"), Settings.GlobalSync);
|
||||
addFormNumericBox(TXBuffer.buf, F("UDP port"), F("udpport"), Settings.UDPPort, 0, 65535);
|
||||
|
||||
|
||||
@@ -4136,7 +4198,7 @@ void handle_filelist() {
|
||||
if (fdelete.length() > 0)
|
||||
{
|
||||
SPIFFS.remove(fdelete);
|
||||
// flashCount();
|
||||
checkRuleSets();
|
||||
}
|
||||
|
||||
|
||||
@@ -4187,7 +4249,7 @@ void handle_filelist() {
|
||||
{
|
||||
if(!file.isDirectory()){
|
||||
TXBuffer += F("<TR><TD>");
|
||||
if (file.name() != "/config.dat" && file.name() != "/security.dat" && file.name() != "/notification.dat")
|
||||
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();
|
||||
@@ -4399,7 +4461,7 @@ void handle_setup() {
|
||||
|
||||
addHeader(false,TXBuffer.buf);
|
||||
|
||||
if (WiFi.status() == WL_CONNECTED)
|
||||
if (wifiStatus == ESPEASY_WIFI_SERVICES_INITIALIZED)
|
||||
{
|
||||
addHtmlError( SaveSettings());
|
||||
const IPAddress ip = WiFi.localIP();
|
||||
@@ -4610,6 +4672,7 @@ void handle_rules() {
|
||||
|
||||
TXBuffer += F("<TR><TD>Edit: ");
|
||||
addSelector(TXBuffer.buf, F("set"), RULESETS_MAX, options, optionValues, NULL, choice, true);
|
||||
addButton(TXBuffer.buf, fileName, F("Download to file"));
|
||||
addHelpButton(TXBuffer.buf, F("Tutorial_Rules"));
|
||||
|
||||
// load form data from flash
|
||||
@@ -4649,6 +4712,7 @@ void handle_rules() {
|
||||
sendHeadandTail(F("TmplStd"),true);
|
||||
TXBuffer.endStream();
|
||||
|
||||
checkRuleSets();
|
||||
}
|
||||
|
||||
|
||||
@@ -4727,7 +4791,7 @@ void handle_sysinfo() {
|
||||
|
||||
TXBuffer += F("<TR><TD colspan=2><H3>Network</H3></TD></TR>");
|
||||
|
||||
if (WiFi.status() == WL_CONNECTED)
|
||||
if (wifiStatus == ESPEASY_WIFI_SERVICES_INITIALIZED)
|
||||
{
|
||||
TXBuffer += F("<TR><TD>Wifi<TD>");
|
||||
#if defined(ESP8266)
|
||||
@@ -4762,14 +4826,13 @@ void handle_sysinfo() {
|
||||
TXBuffer += formatIP(WiFi.gatewayIP());
|
||||
|
||||
{
|
||||
TXBuffer += F("<TR><TD>Client IP<TD>");
|
||||
TXBuffer += F("<TR><TD>Client IP<TD>");
|
||||
WiFiClient client(WebServer.client());
|
||||
TXBuffer += formatIP(client.remoteIP());
|
||||
TXBuffer += formatIP(client.remoteIP());
|
||||
}
|
||||
|
||||
|
||||
TXBuffer += F("<TR><TD>Allowed IP Range<TD>");
|
||||
TXBuffer += describeAllowedIPrange();
|
||||
TXBuffer += F("<TR><TD>Allowed IP Range<TD>");
|
||||
TXBuffer += describeAllowedIPrange();
|
||||
|
||||
TXBuffer += F("<TR><TD>Serial Port available:<TD>");
|
||||
TXBuffer += String(SerialAvailableForWrite());
|
||||
@@ -4787,19 +4850,34 @@ void handle_sysinfo() {
|
||||
uint8_t* macread = WiFi.macAddress(mac);
|
||||
char macaddress[20];
|
||||
formatMAC(macread, macaddress);
|
||||
TXBuffer += macaddress;
|
||||
TXBuffer += macaddress;
|
||||
|
||||
TXBuffer += F("<TR><TD>AP MAC<TD>");
|
||||
TXBuffer += F("<TR><TD>AP MAC<TD>");
|
||||
macread = WiFi.softAPmacAddress(mac);
|
||||
formatMAC(macread, macaddress);
|
||||
TXBuffer += macaddress;
|
||||
TXBuffer += macaddress;
|
||||
|
||||
TXBuffer += F("<TR><TD colspan=2><H3>Firmware</H3></TD></TR>");
|
||||
TXBuffer += F("<TR><TD>SSID<TD>");
|
||||
TXBuffer += WiFi.SSID();
|
||||
TXBuffer += F(" (");
|
||||
TXBuffer += WiFi.BSSIDstr();
|
||||
TXBuffer += F(")");
|
||||
|
||||
TXBuffer += F("<TR><TD>Build<TD>");
|
||||
TXBuffer += BUILD;
|
||||
TXBuffer += F(" ");
|
||||
TXBuffer += F(BUILD_NOTES);
|
||||
TXBuffer += F("<TR><TD>Channel<TD>");
|
||||
TXBuffer += WiFi.channel();
|
||||
|
||||
TXBuffer += F("<TR><TD>Connected<TD>");
|
||||
TXBuffer += format_msec_duration(timeDiff(lastConnectMoment, millis()));
|
||||
|
||||
TXBuffer += F("<TR><TD>Last Disconnect Reason<TD>");
|
||||
TXBuffer += getLastDisconnectReason();
|
||||
|
||||
TXBuffer += F("<TR><TD colspan=2><H3>Firmware</H3></TD></TR>");
|
||||
|
||||
TXBuffer += F("<TR><TD>Build<TD>");
|
||||
TXBuffer += BUILD;
|
||||
TXBuffer += F(" ");
|
||||
TXBuffer += F(BUILD_NOTES);
|
||||
#if defined(ESP8266)
|
||||
TXBuffer += F(" (core ");
|
||||
TXBuffer += ESP.getCoreVersion();
|
||||
|
||||
-330
@@ -1,330 +0,0 @@
|
||||
//********************************************************************************
|
||||
// Determine Wifi AP name to set. (also used for mDNS)
|
||||
//********************************************************************************
|
||||
String WifiGetAPssid()
|
||||
{
|
||||
String ssid(Settings.Name);
|
||||
ssid+=F("_");
|
||||
ssid+=Settings.Unit;
|
||||
return (ssid);
|
||||
}
|
||||
|
||||
//********************************************************************************
|
||||
// Determine hostname: basically WifiGetAPssid with spaces changed to -
|
||||
//********************************************************************************
|
||||
String WifiGetHostname()
|
||||
{
|
||||
String hostname(WifiGetAPssid());
|
||||
hostname.replace(F(" "), F("-"));
|
||||
return (hostname);
|
||||
}
|
||||
|
||||
|
||||
//********************************************************************************
|
||||
// Set Wifi AP Mode config
|
||||
//********************************************************************************
|
||||
void WifiAPconfig()
|
||||
{
|
||||
// create and store unique AP SSID/PW to prevent ESP from starting AP mode with default SSID and No password!
|
||||
// setup ssid for AP Mode when needed
|
||||
WiFi.softAP(WifiGetAPssid().c_str(), SecuritySettings.WifiAPKey);
|
||||
// We start in STA mode
|
||||
WifiAPMode(false);
|
||||
|
||||
String log("WIFI : AP Mode ssid will be ");
|
||||
log=log+WifiGetAPssid();
|
||||
|
||||
log=log+F(" with address ");
|
||||
log=log+apIP.toString();
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool WifiIsAP()
|
||||
{
|
||||
#if defined(ESP8266)
|
||||
byte wifimode = wifi_get_opmode();
|
||||
#endif
|
||||
#if defined(ESP32)
|
||||
byte wifimode = WiFi.getMode();
|
||||
#endif
|
||||
return(wifimode == 2 || wifimode == 3); //apmode is enabled
|
||||
}
|
||||
|
||||
//********************************************************************************
|
||||
// Set Wifi AP Mode
|
||||
//********************************************************************************
|
||||
void WifiAPMode(boolean state)
|
||||
{
|
||||
if (WifiIsAP())
|
||||
{
|
||||
//want to disable?
|
||||
if (!state)
|
||||
{
|
||||
WiFi.mode(WIFI_STA);
|
||||
addLog(LOG_LEVEL_INFO, F("WIFI : AP Mode disabled"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//want to enable?
|
||||
if (state)
|
||||
{
|
||||
WiFi.mode(WIFI_AP_STA);
|
||||
addLog(LOG_LEVEL_INFO, F("WIFI : AP Mode enabled"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//********************************************************************************
|
||||
// Configure network and connect to Wifi SSID and SSID2
|
||||
//********************************************************************************
|
||||
boolean WifiConnect(byte connectAttempts)
|
||||
{
|
||||
String log = "";
|
||||
char hostname[40];
|
||||
strncpy(hostname, WifiGetHostname().c_str(), sizeof(hostname));
|
||||
#if defined(ESP8266)
|
||||
wifi_station_set_hostname(hostname);
|
||||
#endif
|
||||
#if defined(ESP32)
|
||||
WiFi.setHostname(hostname);
|
||||
#endif
|
||||
|
||||
//use static ip?
|
||||
if (Settings.IP[0] != 0 && Settings.IP[0] != 255)
|
||||
{
|
||||
const IPAddress ip = Settings.IP;
|
||||
log = F("IP : Static IP :");
|
||||
log += ip;
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
const IPAddress gw = Settings.Gateway;
|
||||
const IPAddress subnet = Settings.Subnet;
|
||||
const IPAddress dns = Settings.DNS;
|
||||
WiFi.config(ip, gw, subnet, dns);
|
||||
}
|
||||
|
||||
//try to connect to one of the access points
|
||||
if (WifiConnectSSID(SecuritySettings.WifiSSID, SecuritySettings.WifiKey, connectAttempts) ||
|
||||
WifiConnectSSID(SecuritySettings.WifiSSID2, SecuritySettings.WifiKey2, connectAttempts))
|
||||
{
|
||||
// fix octet?
|
||||
if (Settings.IP_Octet != 0 && Settings.IP_Octet != 255)
|
||||
{
|
||||
IPAddress ip = WiFi.localIP();
|
||||
IPAddress gw = WiFi.gatewayIP();
|
||||
IPAddress subnet = WiFi.subnetMask();
|
||||
ip[3] = Settings.IP_Octet;
|
||||
log = F("IP : Fixed IP octet:");
|
||||
log += ip;
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
WiFi.config(ip, gw, subnet);
|
||||
}
|
||||
|
||||
#ifdef FEATURE_MDNS
|
||||
|
||||
String log = F("WIFI : ");
|
||||
if (MDNS.begin(WifiGetHostname().c_str(), WiFi.localIP())) {
|
||||
|
||||
log += F("mDNS started, with name: ");
|
||||
log += WifiGetHostname();
|
||||
log += F(".local");
|
||||
}
|
||||
else{
|
||||
log += F("mDNS failed");
|
||||
}
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
#endif
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
addLog(LOG_LEVEL_ERROR, F("WIFI : Could not connect to AP!"));
|
||||
|
||||
//everything failed, activate AP mode (will deactivate automatically after a while if its connected again)
|
||||
WifiAPMode(true);
|
||||
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
//********************************************************************************
|
||||
// Connect to Wifi specific SSID
|
||||
//********************************************************************************
|
||||
boolean WifiConnectSSID(char WifiSSID[], char WifiKey[], byte connectAttempts)
|
||||
{
|
||||
String log;
|
||||
|
||||
//already connected, need to disconnect first
|
||||
if (WiFi.status() == WL_CONNECTED)
|
||||
return(true);
|
||||
|
||||
//no ssid specified
|
||||
if ((WifiSSID[0] == 0) || (strcasecmp(WifiSSID, "ssid") == 0))
|
||||
return(false);
|
||||
|
||||
for (byte tryConnect = 1; tryConnect <= connectAttempts; tryConnect++)
|
||||
{
|
||||
log = F("WIFI : Connecting ");
|
||||
log += WifiSSID;
|
||||
log += F(" attempt #");
|
||||
log += tryConnect;
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
|
||||
if (tryConnect == 1)
|
||||
WiFi.begin(WifiSSID, WifiKey);
|
||||
else
|
||||
WiFi.begin();
|
||||
|
||||
//wait until it connects
|
||||
for (byte x = 0; x < 200; x++)
|
||||
{
|
||||
if (!WiFiConnected(50))
|
||||
{
|
||||
statusLED(false);
|
||||
// No delay needed, since the WiFi check has a delay
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
if (WiFi.status() == WL_CONNECTED)
|
||||
{
|
||||
if (Settings.UseNTP) {
|
||||
initTime();
|
||||
}
|
||||
log = F("WIFI : Connected! IP: ");
|
||||
log += formatIP(WiFi.localIP());
|
||||
log += F(" (");
|
||||
log += WifiGetHostname();
|
||||
log += F(")");
|
||||
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
statusLED(true);
|
||||
return(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// log = F("WIFI : Disconnecting!");
|
||||
// addLog(LOG_LEVEL_INFO, log);
|
||||
#if defined(ESP8266)
|
||||
ETS_UART_INTR_DISABLE();
|
||||
wifi_station_disconnect();
|
||||
ETS_UART_INTR_ENABLE();
|
||||
#endif
|
||||
for (byte x = 0; x < 20; x++)
|
||||
{
|
||||
statusLED(true);
|
||||
delay(50);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//********************************************************************************
|
||||
// Disconnect from Wifi AP
|
||||
//********************************************************************************
|
||||
void WifiDisconnect()
|
||||
{
|
||||
WiFi.disconnect();
|
||||
}
|
||||
|
||||
|
||||
//********************************************************************************
|
||||
// Scan all Wifi Access Points
|
||||
//********************************************************************************
|
||||
void WifiScan()
|
||||
{
|
||||
// Direct Serial is allowed here, since this function will only be called from serial input.
|
||||
Serial.println(F("WIFI : SSID Scan start"));
|
||||
int n = WiFi.scanNetworks();
|
||||
if (n == 0)
|
||||
Serial.println(F("WIFI : No networks found"));
|
||||
else
|
||||
{
|
||||
Serial.print(F("WIFI : "));
|
||||
Serial.print(n);
|
||||
Serial.println(F(" networks found"));
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
// Print SSID and RSSI for each network found
|
||||
Serial.print(F("WIFI : "));
|
||||
Serial.print(i + 1);
|
||||
Serial.print(": ");
|
||||
Serial.print(WiFi.SSID(i));
|
||||
Serial.print(" (");
|
||||
Serial.print(WiFi.RSSI(i));
|
||||
Serial.print(")");
|
||||
Serial.println("");
|
||||
delay(10);
|
||||
}
|
||||
}
|
||||
Serial.println("");
|
||||
}
|
||||
|
||||
|
||||
//********************************************************************************
|
||||
// Check if we are still connected to a Wifi AP
|
||||
//********************************************************************************
|
||||
void WifiCheck()
|
||||
{
|
||||
|
||||
if(wifiSetup)
|
||||
return;
|
||||
|
||||
if (WiFi.status() != WL_CONNECTED)
|
||||
{
|
||||
NC_Count++;
|
||||
//give it time to automatically reconnect
|
||||
if (NC_Count > 2)
|
||||
{
|
||||
WifiConnect(2);
|
||||
|
||||
C_Count=0;
|
||||
NC_Count = 0;
|
||||
}
|
||||
}
|
||||
//connected
|
||||
else
|
||||
{
|
||||
C_Count++;
|
||||
NC_Count = 0;
|
||||
if (C_Count > 2) // disable AP after timeout if a Wifi connection is established...
|
||||
{
|
||||
WifiAPMode(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//********************************************************************************
|
||||
// Return subnet range of WiFi.
|
||||
//********************************************************************************
|
||||
bool getSubnetRange(IPAddress& low, IPAddress& high)
|
||||
{
|
||||
if (WifiIsAP()) {
|
||||
// WiFi is active as accesspoint, do not check.
|
||||
return false;
|
||||
}
|
||||
if (WiFi.status() != WL_CONNECTED) {
|
||||
return false;
|
||||
}
|
||||
const IPAddress ip = WiFi.localIP();
|
||||
const IPAddress subnet = WiFi.subnetMask();
|
||||
low = ip;
|
||||
high = ip;
|
||||
// Compute subnet range.
|
||||
for (byte i=0; i < 4; ++i) {
|
||||
if (subnet[i] != 255) {
|
||||
low[i] = low[i] & subnet[i];
|
||||
high[i] = high[i] | ~subnet[i];
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
+2
-2
@@ -87,9 +87,9 @@ void C010_Send(struct EventStruct *event, byte varIndex, float value, unsigned l
|
||||
else
|
||||
msg.replace(F("%value%"), toString(value, ExtraTaskSettings.TaskDeviceValueDecimals[varIndex]));
|
||||
|
||||
if (WiFi.status() == WL_CONNECTED) {
|
||||
if (wifiStatus == ESPEASY_WIFI_SERVICES_INITIALIZED) {
|
||||
ControllerSettings.beginPacket(portUDP);
|
||||
portUDP.write(msg.c_str());
|
||||
portUDP.write((uint8_t*)msg.c_str(),msg.length());
|
||||
portUDP.endPacket();
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -33,7 +33,7 @@ boolean CPlugin_012(byte function, struct EventStruct *event, String& string)
|
||||
|
||||
case CPLUGIN_PROTOCOL_SEND:
|
||||
{
|
||||
if (WiFi.status() != WL_CONNECTED) {
|
||||
if (wifiStatus != ESPEASY_WIFI_SERVICES_INITIALIZED) {
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
@@ -63,7 +63,7 @@ boolean CPlugin_012_send(struct EventStruct *event, int nrValues) {
|
||||
|
||||
boolean Blynk_get(const String& command, byte controllerIndex, float *data )
|
||||
{
|
||||
if (WiFi.status() != WL_CONNECTED) {
|
||||
if (wifiStatus != ESPEASY_WIFI_SERVICES_INITIALIZED) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+265
@@ -0,0 +1,265 @@
|
||||
//#######################################################################################################
|
||||
//########################### Controller Plugin 013: ESPEasy P2P network ################################
|
||||
//#######################################################################################################
|
||||
|
||||
#define CPLUGIN_013
|
||||
#define CPLUGIN_ID_013 13
|
||||
#define CPLUGIN_NAME_013 "ESPEasy P2P Networking"
|
||||
|
||||
WiFiUDP C013_portUDP;
|
||||
|
||||
struct infoStruct
|
||||
{
|
||||
byte header = 255;
|
||||
byte ID = 3;
|
||||
byte sourcelUnit;
|
||||
byte destUnit;
|
||||
byte sourceTaskIndex;
|
||||
byte destTaskIndex;
|
||||
byte deviceNumber;
|
||||
char taskName[26];
|
||||
char ValueNames[VARS_PER_TASK][26];
|
||||
};
|
||||
|
||||
struct dataStruct
|
||||
{
|
||||
byte header = 255;
|
||||
byte ID = 5;
|
||||
byte sourcelUnit;
|
||||
byte destUnit;
|
||||
byte sourceTaskIndex;
|
||||
byte destTaskIndex;
|
||||
float Values[VARS_PER_TASK];
|
||||
};
|
||||
|
||||
|
||||
boolean CPlugin_013(byte function, struct EventStruct *event, String& string)
|
||||
{
|
||||
boolean success = false;
|
||||
|
||||
switch (function)
|
||||
{
|
||||
case CPLUGIN_PROTOCOL_ADD:
|
||||
{
|
||||
Protocol[++protocolCount].Number = CPLUGIN_ID_013;
|
||||
Protocol[protocolCount].usesMQTT = false;
|
||||
Protocol[protocolCount].usesTemplate = false;
|
||||
Protocol[protocolCount].usesAccount = false;
|
||||
Protocol[protocolCount].usesPassword = false;
|
||||
Protocol[protocolCount].defaultPort = 65501;
|
||||
Protocol[protocolCount].usesID = false;
|
||||
Protocol[protocolCount].Custom = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case CPLUGIN_GET_DEVICENAME:
|
||||
{
|
||||
string = F(CPLUGIN_NAME_013);
|
||||
break;
|
||||
}
|
||||
|
||||
case CPLUGIN_PROTOCOL_TEMPLATE:
|
||||
{
|
||||
event->String1 = "";
|
||||
event->String2 = "";
|
||||
break;
|
||||
}
|
||||
|
||||
case CPLUGIN_INIT:
|
||||
{
|
||||
//C013_portUDP.begin(Settings.UDPPort);
|
||||
break;
|
||||
}
|
||||
|
||||
case CPLUGIN_TASK_CHANGE_NOTIFICATION:
|
||||
{
|
||||
C013_SendUDPTaskInfo(0, event->TaskIndex, event->TaskIndex);
|
||||
break;
|
||||
}
|
||||
|
||||
case CPLUGIN_PROTOCOL_SEND:
|
||||
{
|
||||
C013_Send(event, 0, UserVar[event->BaseVarIndex], 0);
|
||||
break;
|
||||
}
|
||||
|
||||
case CPLUGIN_UDP_IN:
|
||||
{
|
||||
C013_Receive(event);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
//********************************************************************************
|
||||
// Generic UDP message
|
||||
//********************************************************************************
|
||||
void C013_Send(struct EventStruct *event, byte varIndex, float value, unsigned long longValue)
|
||||
{
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
LoadControllerSettings(event->ControllerIndex, (byte*)&ControllerSettings, sizeof(ControllerSettings));
|
||||
statusLED(true);
|
||||
C013_SendUDPTaskData(0, event->TaskIndex, event->TaskIndex);
|
||||
}
|
||||
|
||||
void C013_SendUDPTaskInfo(byte destUnit, byte sourceTaskIndex, byte destTaskIndex)
|
||||
{
|
||||
if (!WiFiConnected(100)) {
|
||||
return;
|
||||
}
|
||||
struct infoStruct infoReply;
|
||||
infoReply.sourcelUnit = Settings.Unit;
|
||||
infoReply.sourceTaskIndex = sourceTaskIndex;
|
||||
infoReply.destTaskIndex = destTaskIndex;
|
||||
LoadTaskSettings(infoReply.sourceTaskIndex);
|
||||
infoReply.deviceNumber = Settings.TaskDeviceNumber[infoReply.sourceTaskIndex];
|
||||
strcpy(infoReply.taskName, ExtraTaskSettings.TaskDeviceName);
|
||||
for (byte x = 0; x < VARS_PER_TASK; x++)
|
||||
strcpy(infoReply.ValueNames[x], ExtraTaskSettings.TaskDeviceValueNames[x]);
|
||||
|
||||
byte firstUnit = 1;
|
||||
byte lastUnit = UNIT_MAX - 1;
|
||||
if (destUnit != 0)
|
||||
{
|
||||
firstUnit = destUnit;
|
||||
lastUnit = destUnit;
|
||||
}
|
||||
for (byte x = firstUnit; x <= lastUnit; x++)
|
||||
{
|
||||
if (x != Settings.Unit){
|
||||
infoReply.destUnit = x;
|
||||
C013_sendUDP(x, (byte*)&infoReply, sizeof(infoStruct));
|
||||
delay(10);
|
||||
}
|
||||
}
|
||||
delay(50);
|
||||
}
|
||||
|
||||
void C013_SendUDPTaskData(byte destUnit, byte sourceTaskIndex, byte destTaskIndex)
|
||||
{
|
||||
if (!WiFiConnected(100)) {
|
||||
return;
|
||||
}
|
||||
struct dataStruct dataReply;
|
||||
dataReply.sourcelUnit = Settings.Unit;
|
||||
dataReply.sourceTaskIndex = sourceTaskIndex;
|
||||
dataReply.destTaskIndex = destTaskIndex;
|
||||
for (byte x = 0; x < VARS_PER_TASK; x++)
|
||||
dataReply.Values[x] = UserVar[dataReply.sourceTaskIndex * VARS_PER_TASK + x];
|
||||
|
||||
byte firstUnit = 1;
|
||||
byte lastUnit = UNIT_MAX - 1;
|
||||
if (destUnit != 0)
|
||||
{
|
||||
firstUnit = destUnit;
|
||||
lastUnit = destUnit;
|
||||
}
|
||||
for (byte x = firstUnit; x <= lastUnit; x++)
|
||||
{
|
||||
if (x != Settings.Unit){
|
||||
dataReply.destUnit = x;
|
||||
C013_sendUDP(x, (byte*) &dataReply, sizeof(dataStruct));
|
||||
delay(10);
|
||||
}
|
||||
}
|
||||
delay(50);
|
||||
}
|
||||
|
||||
/*********************************************************************************************\
|
||||
Send UDP message (unit 255=broadcast)
|
||||
\*********************************************************************************************/
|
||||
void C013_sendUDP(byte unit, byte* data, byte size)
|
||||
{
|
||||
if (!WiFiConnected(100)) {
|
||||
return;
|
||||
}
|
||||
if (unit != 255)
|
||||
if (Nodes[unit].ip[0] == 0)
|
||||
return;
|
||||
String log = "C013 : Send UDP message to ";
|
||||
log += unit;
|
||||
addLog(LOG_LEVEL_DEBUG_MORE, log);
|
||||
|
||||
statusLED(true);
|
||||
|
||||
IPAddress remoteNodeIP;
|
||||
if (unit == 255)
|
||||
remoteNodeIP = {255, 255, 255, 255};
|
||||
else
|
||||
remoteNodeIP = Nodes[unit].ip;
|
||||
C013_portUDP.beginPacket(remoteNodeIP, Settings.UDPPort);
|
||||
C013_portUDP.write(data, size);
|
||||
C013_portUDP.endPacket();
|
||||
}
|
||||
|
||||
void C013_Receive(struct EventStruct *event) {
|
||||
|
||||
if (event->Data[1] > 1 && event->Data[1] < 6)
|
||||
{
|
||||
String log = (F("C013 : msg "));
|
||||
for (byte x = 1; x < 6; x++)
|
||||
{
|
||||
log += " ";
|
||||
log += (int)event->Data[x];
|
||||
}
|
||||
addLog(LOG_LEVEL_DEBUG_MORE, log);
|
||||
}
|
||||
|
||||
switch (event->Data[1]) {
|
||||
case 2: // sensor info pull request
|
||||
{
|
||||
//SendUDPTaskInfo(packetBuffer[2], packetBuffer[5], packetBuffer[4]);
|
||||
break;
|
||||
}
|
||||
|
||||
case 3: // sensor info
|
||||
{
|
||||
struct infoStruct infoReply;
|
||||
memcpy((byte*)&infoReply, (byte*)event->Data, sizeof(infoStruct));
|
||||
|
||||
// to prevent flash wear out (bugs in communication?) we can only write to an empty task
|
||||
// so it will write only once and has to be cleared manually through webgui
|
||||
if (Settings.TaskDeviceNumber[infoReply.destTaskIndex] == 0)
|
||||
{
|
||||
Settings.TaskDeviceNumber[infoReply.destTaskIndex] = infoReply.deviceNumber;
|
||||
Settings.TaskDeviceDataFeed[infoReply.destTaskIndex] = 1; // remote feed
|
||||
for (byte x = 0; x < CONTROLLER_MAX; x++)
|
||||
Settings.TaskDeviceSendData[x][infoReply.destTaskIndex] = false;
|
||||
strcpy(ExtraTaskSettings.TaskDeviceName, infoReply.taskName);
|
||||
for (byte x = 0; x < VARS_PER_TASK; x++)
|
||||
strcpy( ExtraTaskSettings.TaskDeviceValueNames[x], infoReply.ValueNames[x]);
|
||||
SaveTaskSettings(infoReply.destTaskIndex);
|
||||
SaveSettings();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 4: // sensor data pull request
|
||||
{
|
||||
//SendUDPTaskData(packetBuffer[2], packetBuffer[5], packetBuffer[4]);
|
||||
break;
|
||||
}
|
||||
|
||||
case 5: // sensor data
|
||||
{
|
||||
struct dataStruct dataReply;
|
||||
memcpy((byte*)&dataReply, (byte*)event->Data, sizeof(dataStruct));
|
||||
|
||||
// only if this task has a remote feed, update values
|
||||
if (Settings.TaskDeviceDataFeed[dataReply.destTaskIndex] != 0)
|
||||
{
|
||||
for (byte x = 0; x < VARS_PER_TASK; x++)
|
||||
{
|
||||
UserVar[dataReply.destTaskIndex * VARS_PER_TASK + x] = dataReply.Values[x];
|
||||
}
|
||||
if (Settings.UseRules)
|
||||
createRuleEvents(dataReply.destTaskIndex);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,37 +26,3 @@ byte getValueCountFromSensorType(byte sensorType)
|
||||
addLog(LOG_LEVEL_ERROR, F("getValueCountFromSensorType: Unknown sensortype"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*********************************************************************************************\
|
||||
Convert bearing in degree to bearing string
|
||||
\*********************************************************************************************/
|
||||
|
||||
String getBearing(int degrees)
|
||||
{
|
||||
const __FlashStringHelper* bearing[] = {
|
||||
F("N"),
|
||||
F("NNE"),
|
||||
F("NE"),
|
||||
F("ENE"),
|
||||
F("E"),
|
||||
F("ESE"),
|
||||
F("SE"),
|
||||
F("SSE"),
|
||||
F("S"),
|
||||
F("SSW"),
|
||||
F("SW"),
|
||||
F("WSW"),
|
||||
F("W"),
|
||||
F("WNW"),
|
||||
F("NW"),
|
||||
F("NNW")
|
||||
};
|
||||
int nr_directions = (int) (sizeof(bearing)/sizeof(bearing[0]));
|
||||
float stepsize = (360.0 / nr_directions);
|
||||
if (degrees < 0) { degrees += 360; } // Allow for bearing -360 .. 359
|
||||
int bearing_idx=int((degrees + (stepsize / 2.0)) / stepsize) % nr_directions;
|
||||
if (bearing_idx < 0)
|
||||
return("");
|
||||
else
|
||||
return(bearing[bearing_idx]);
|
||||
}
|
||||
|
||||
@@ -46,7 +46,10 @@ boolean NPlugin_002(byte function, struct EventStruct *event, String& string)
|
||||
NotificationSettingsStruct NotificationSettings;
|
||||
LoadNotificationSettings(event->NotificationIndex, (byte*)&NotificationSettings, sizeof(NotificationSettings));
|
||||
//this reserves IRAM and uninitialized RAM
|
||||
#ifndef ESP32
|
||||
// Buzzer not compatible with ESP32 due to lack of tone command.
|
||||
tone(NotificationSettings.Pin1, 500, 500);
|
||||
#endif
|
||||
success = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P001
|
||||
//#######################################################################################################
|
||||
//#################################### Plugin 001: Input Switch #########################################
|
||||
//#######################################################################################################
|
||||
@@ -480,3 +481,4 @@ byte P001_getSwitchType(struct EventStruct *event) {
|
||||
}
|
||||
return choice;
|
||||
}
|
||||
#endif // USES_P001
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P002
|
||||
//#######################################################################################################
|
||||
//#################################### Plugin 002: Analog ###############################################
|
||||
//#######################################################################################################
|
||||
@@ -150,3 +151,4 @@ boolean Plugin_002(byte function, struct EventStruct *event, String& string)
|
||||
}
|
||||
return success;
|
||||
}
|
||||
#endif // USES_P002
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P003
|
||||
//#######################################################################################################
|
||||
//#################################### Plugin 003: Pulse ###############################################
|
||||
//#######################################################################################################
|
||||
@@ -267,3 +268,4 @@ bool Plugin_003_pulseinit(byte Par1, byte Index, byte Mode)
|
||||
|
||||
return(true);
|
||||
}
|
||||
#endif // USES_P003
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P004
|
||||
// #######################################################################################################
|
||||
// #################################### Plugin 004: TempSensor Dallas DS18B20 ###########################
|
||||
// #######################################################################################################
|
||||
@@ -653,3 +654,4 @@ boolean Plugin_004_DS_crc8(uint8_t * addr)
|
||||
}
|
||||
return crc == *addr; // addr 8
|
||||
}
|
||||
#endif // USES_P004
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P005
|
||||
//#######################################################################################################
|
||||
//######################## Plugin 005: Temperature and Humidity sensor DHT 11/22 ########################
|
||||
//#######################################################################################################
|
||||
@@ -219,3 +220,4 @@ int Plugin_005_read_dht_dat(void)
|
||||
}
|
||||
return result;
|
||||
}
|
||||
#endif // USES_P005
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P006
|
||||
//#######################################################################################################
|
||||
//######################## Plugin 006 BMP0685 I2C Barometric Pressure Sensor ###########################
|
||||
//#######################################################################################################
|
||||
@@ -287,3 +288,4 @@ float Plugin_006_pressureElevation(float atmospheric, int altitude) {
|
||||
/*********************************************************************/
|
||||
return atmospheric / pow(1.0 - (altitude/44330.0), 5.255);
|
||||
}
|
||||
#endif // USES_P006
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P007
|
||||
//#######################################################################################################
|
||||
//#################################### Plugin 007: ExtWiredAnalog #######################################
|
||||
//#######################################################################################################
|
||||
@@ -69,3 +70,4 @@ boolean Plugin_007(byte function, struct EventStruct *event, String& string)
|
||||
}
|
||||
return success;
|
||||
}
|
||||
#endif // USES_P007
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P008
|
||||
//#######################################################################################################
|
||||
//################################# Plugin 008: Wiegand RFID Tag Reader #################################
|
||||
//#######################################################################################################
|
||||
@@ -176,3 +177,4 @@ void Plugin_008_interrupt2()
|
||||
Plugin_008_keyBuffer = Plugin_008_keyBuffer << 1; // Left shift the number (effectively multiplying by 2)
|
||||
Plugin_008_bitCount++; // Increment the bit count
|
||||
}
|
||||
#endif // USES_P008
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P009
|
||||
//#######################################################################################################
|
||||
//#################################### Plugin 009: MCP23017 input #######################################
|
||||
//#######################################################################################################
|
||||
@@ -306,3 +307,4 @@ void Plugin_009_Config(byte Par1, byte Par2)
|
||||
Wire.endTransmission();
|
||||
}
|
||||
}
|
||||
#endif // USES_P009
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P010
|
||||
//#######################################################################################################
|
||||
//#################################### Plugin-010: LuxRead ############################################
|
||||
//#######################################################################################################
|
||||
@@ -124,3 +125,4 @@ boolean Plugin_010(byte function, struct EventStruct *event, String& string)
|
||||
}
|
||||
return success;
|
||||
}
|
||||
#endif // USES_P010
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P011
|
||||
//#######################################################################################################
|
||||
//#################################### Plugin 011: Pro Mini Extender ####################################
|
||||
//#######################################################################################################
|
||||
@@ -211,3 +212,4 @@ void Plugin_011_Write(byte Par1, byte Par2)
|
||||
Wire.write((Par2 >> 8));
|
||||
Wire.endTransmission();
|
||||
}
|
||||
#endif // USES_P011
|
||||
|
||||
+19
-18
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P012
|
||||
//#######################################################################################################
|
||||
//#################################### Plugin 012: LCD ##################################################
|
||||
//#######################################################################################################
|
||||
@@ -8,7 +9,6 @@
|
||||
// Lux:[Lux#Lux#R]
|
||||
// Baro:[Baro#Pressure#R]
|
||||
// Pump:[Pump#on#O] -> ON/OFF
|
||||
|
||||
#include <LiquidCrystal_I2C.h>
|
||||
|
||||
LiquidCrystal_I2C *lcd=NULL;
|
||||
@@ -226,11 +226,27 @@ boolean Plugin_012(byte function, struct EventStruct *event, String& string)
|
||||
if (argIndex)
|
||||
tmpString = tmpString.substring(0, argIndex);
|
||||
|
||||
if (lcd && tmpString.equalsIgnoreCase(F("LCD")))
|
||||
if (lcd && tmpString.equalsIgnoreCase(F("LCDCMD")))
|
||||
{
|
||||
success = true;
|
||||
argIndex = string.lastIndexOf(',');
|
||||
tmpString = string.substring(argIndex + 1);
|
||||
if (tmpString.equalsIgnoreCase(F("Off"))){
|
||||
lcd->noBacklight();
|
||||
}
|
||||
else if (tmpString.equalsIgnoreCase(F("On"))){
|
||||
lcd->backlight();
|
||||
}
|
||||
else if (tmpString.equalsIgnoreCase(F("Clear"))){
|
||||
lcd->clear();
|
||||
}
|
||||
}
|
||||
else if (lcd && tmpString.equalsIgnoreCase(F("LCD")))
|
||||
{
|
||||
success = true;
|
||||
tmpString = P012_parseTemplate(string, cols);
|
||||
argIndex = tmpString.lastIndexOf(',');
|
||||
tmpString = tmpString.substring(argIndex + 1);
|
||||
|
||||
int colPos = event->Par2 - 1;
|
||||
int rowPos = event->Par1 - 1;
|
||||
@@ -281,22 +297,6 @@ boolean Plugin_012(byte function, struct EventStruct *event, String& string)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (lcd && tmpString.equalsIgnoreCase(F("LCDCMD")))
|
||||
{
|
||||
success = true;
|
||||
argIndex = string.lastIndexOf(',');
|
||||
tmpString = string.substring(argIndex + 1);
|
||||
if (tmpString.equalsIgnoreCase(F("Off"))){
|
||||
lcd->noBacklight();
|
||||
}
|
||||
else if (tmpString.equalsIgnoreCase(F("On"))){
|
||||
lcd->backlight();
|
||||
}
|
||||
else if (tmpString.equalsIgnoreCase(F("Clear"))){
|
||||
lcd->clear();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -313,3 +313,4 @@ String P012_parseTemplate(String &tmpString, byte lineSize) {
|
||||
result.replace(degree, degree_lcd);
|
||||
return result;
|
||||
}
|
||||
#endif // USES_P012
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P013
|
||||
//#######################################################################################################
|
||||
//#################################### Plugin 013: HC-SR04 ##############################################
|
||||
//#######################################################################################################
|
||||
@@ -180,3 +181,4 @@ void Plugin_013_interrupt()
|
||||
Plugin_013_timer = micros() - Plugin_013_timer;
|
||||
}
|
||||
}
|
||||
#endif // USES_P013
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P014
|
||||
//#######################################################################################################
|
||||
//######################## Plugin 014 SI7021 I2C Temperature Humidity Sensor ###########################
|
||||
//#######################################################################################################
|
||||
@@ -393,3 +394,4 @@ int8_t Plugin_014_si7021_setResolution(uint8_t res)
|
||||
|
||||
return error;
|
||||
}
|
||||
#endif // USES_P014
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P015
|
||||
//#######################################################################################################
|
||||
//######################## Plugin 015 TSL2561 I2C Lux Sensor ############################################
|
||||
//#######################################################################################################
|
||||
@@ -441,3 +442,4 @@ boolean Plugin_015(byte function, struct EventStruct *event, String& string)
|
||||
}
|
||||
return success;
|
||||
}
|
||||
#endif // USES_P015
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P016
|
||||
//#######################################################################################################
|
||||
//#################################### Plugin 016: Input IR #############################################
|
||||
//#######################################################################################################
|
||||
@@ -93,3 +94,4 @@ boolean Plugin_016(byte function, struct EventStruct *event, String& string)
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // USES_P016
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P017
|
||||
//#######################################################################################################
|
||||
//#################################### Plugin-017: PN532 RFID reader ####################################
|
||||
//#######################################################################################################
|
||||
@@ -401,3 +402,4 @@ int8_t Plugin_017_readAckFrame()
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif // USES_P017
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P018
|
||||
//#######################################################################################################
|
||||
//#################################### Plugin 018: GP2Y10 ###############################################
|
||||
//#######################################################################################################
|
||||
@@ -82,3 +83,4 @@ boolean Plugin_018(byte function, struct EventStruct *event, String& string)
|
||||
}
|
||||
return success;
|
||||
}
|
||||
#endif // USES_P018
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P019
|
||||
//#######################################################################################################
|
||||
//#################################### Plugin 019: PCF8574 ##############################################
|
||||
//#######################################################################################################
|
||||
@@ -238,3 +239,4 @@ boolean Plugin_019_Write(byte Par1, byte Par2)
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif // USES_P019
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P020
|
||||
//#######################################################################################################
|
||||
//#################################### Plugin 020: Ser2Net ##############################################
|
||||
//#######################################################################################################
|
||||
@@ -292,3 +293,4 @@ boolean Plugin_020(byte function, struct EventStruct *event, String& string)
|
||||
}
|
||||
return success;
|
||||
}
|
||||
#endif // USES_P020
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P021
|
||||
//#######################################################################################################
|
||||
//#################################### Plugin 021: Level Control ########################################
|
||||
//#######################################################################################################
|
||||
@@ -137,3 +138,4 @@ boolean Plugin_021(byte function, struct EventStruct *event, String& string)
|
||||
}
|
||||
return success;
|
||||
}
|
||||
#endif // USES_P021
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P022
|
||||
//#######################################################################################################
|
||||
//#################################### Plugin 022: PCA9685 ##############################################
|
||||
//#######################################################################################################
|
||||
@@ -152,3 +153,4 @@ void Plugin_022_initialize()
|
||||
Plugin_022_writeRegister(PCA9685_MODE2, (byte)0x10); // set to output
|
||||
Plugin_022_init = true;
|
||||
}
|
||||
#endif // USES_P022
|
||||
|
||||
+19
-18
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P023
|
||||
//#######################################################################################################
|
||||
//#################################### Plugin 023: OLED SSD1306 display #################################
|
||||
//#######################################################################################################
|
||||
@@ -208,14 +209,6 @@ boolean Plugin_023(byte function, struct EventStruct *event, String& string)
|
||||
int argIndex = tmpString.indexOf(',');
|
||||
if (argIndex)
|
||||
tmpString = tmpString.substring(0, argIndex);
|
||||
if (tmpString.equalsIgnoreCase(F("OLED")))
|
||||
{
|
||||
success = true;
|
||||
argIndex = string.lastIndexOf(',');
|
||||
tmpString = string.substring(argIndex + 1);
|
||||
String newString = P023_parseTemplate(tmpString, 16);
|
||||
Plugin_023_sendStrXY(newString.c_str(), event->Par1 - 1, event->Par2 - 1);
|
||||
}
|
||||
if (tmpString.equalsIgnoreCase(F("OLEDCMD")))
|
||||
{
|
||||
success = true;
|
||||
@@ -228,9 +221,16 @@ boolean Plugin_023(byte function, struct EventStruct *event, String& string)
|
||||
else if (tmpString.equalsIgnoreCase(F("Clear")))
|
||||
Plugin_023_clear_display();
|
||||
}
|
||||
else if (tmpString.equalsIgnoreCase(F("OLED")))
|
||||
{
|
||||
success = true;
|
||||
argIndex = string.lastIndexOf(',');
|
||||
tmpString = string.substring(argIndex + 1);
|
||||
String newString = P023_parseTemplate(tmpString, 16);
|
||||
Plugin_023_sendStrXY(newString.c_str(), event->Par1 - 1, event->Par2 - 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
return success;
|
||||
}
|
||||
@@ -444,7 +444,7 @@ const char Plugin_023_myFont[][8] PROGMEM = {
|
||||
{0x00, 0x02, 0x05, 0x05, 0x02, 0x00, 0x00, 0x00} // DEL
|
||||
};
|
||||
|
||||
static void Plugin_023_reset_display(void)
|
||||
void Plugin_023_reset_display(void)
|
||||
{
|
||||
Plugin_023_displayOff();
|
||||
Plugin_023_clear_display();
|
||||
@@ -475,7 +475,7 @@ void Plugin_023_displayOff(void)
|
||||
}
|
||||
|
||||
|
||||
static void Plugin_023_clear_display(void)
|
||||
void Plugin_023_clear_display(void)
|
||||
{
|
||||
unsigned char i, k;
|
||||
for (k = 0; k < 8; k++)
|
||||
@@ -492,7 +492,7 @@ static void Plugin_023_clear_display(void)
|
||||
|
||||
|
||||
// Actually this sends a byte, not a char to draw in the display.
|
||||
static void Plugin_023_SendChar(unsigned char data)
|
||||
void Plugin_023_SendChar(unsigned char data)
|
||||
{
|
||||
Wire.beginTransmission(Plugin_023_OLED_address); // begin transmitting
|
||||
Wire.write(0x40); //data mode
|
||||
@@ -503,7 +503,7 @@ static void Plugin_023_SendChar(unsigned char data)
|
||||
|
||||
// Prints a display char (not just a byte) in coordinates X Y,
|
||||
//currently unused:
|
||||
// static void Plugin_023_sendCharXY(unsigned char data, int X, int Y)
|
||||
// void Plugin_023_sendCharXY(unsigned char data, int X, int Y)
|
||||
// {
|
||||
// //if (interrupt && !doing_menu) return; // Stop printing only if interrupt is call but not in button functions
|
||||
// Plugin_023_setXY(X, Y);
|
||||
@@ -517,7 +517,7 @@ static void Plugin_023_SendChar(unsigned char data)
|
||||
// }
|
||||
|
||||
|
||||
static void Plugin_023_sendcommand(unsigned char com)
|
||||
void Plugin_023_sendcommand(unsigned char com)
|
||||
{
|
||||
Wire.beginTransmission(Plugin_023_OLED_address); //begin transmitting
|
||||
Wire.write(0x80); //command mode
|
||||
@@ -528,7 +528,7 @@ static void Plugin_023_sendcommand(unsigned char com)
|
||||
|
||||
// Set the cursor position in a 16 COL * 8 ROW map (128x64 pixels)
|
||||
// or 8 COL * 5 ROW map (64x48 pixels)
|
||||
static void Plugin_023_setXY(unsigned char row, unsigned char col)
|
||||
void Plugin_023_setXY(unsigned char row, unsigned char col)
|
||||
{
|
||||
switch (Plugin_023_OLED_type)
|
||||
{
|
||||
@@ -548,7 +548,7 @@ static void Plugin_023_setXY(unsigned char row, unsigned char col)
|
||||
|
||||
// Prints a string regardless the cursor position.
|
||||
// unused:
|
||||
// static void Plugin_023_sendStr(unsigned char *string)
|
||||
// void Plugin_023_sendStr(unsigned char *string)
|
||||
// {
|
||||
// unsigned char i = 0;
|
||||
// while (*string)
|
||||
@@ -564,7 +564,7 @@ static void Plugin_023_setXY(unsigned char row, unsigned char col)
|
||||
|
||||
// Prints a string in coordinates X Y, being multiples of 8.
|
||||
// This means we have 16 COLS (0-15) and 8 ROWS (0-7).
|
||||
static void Plugin_023_sendStrXY(const char *string, int X, int Y)
|
||||
void Plugin_023_sendStrXY(const char *string, int X, int Y)
|
||||
{
|
||||
Plugin_023_setXY(X, Y);
|
||||
unsigned char i = 0;
|
||||
@@ -590,7 +590,7 @@ static void Plugin_023_sendStrXY(const char *string, int X, int Y)
|
||||
}
|
||||
|
||||
|
||||
static void Plugin_023_init_OLED(void)
|
||||
void Plugin_023_init_OLED(void)
|
||||
{
|
||||
unsigned char multiplex;
|
||||
unsigned char compins;
|
||||
@@ -636,3 +636,4 @@ static void Plugin_023_init_OLED(void)
|
||||
Plugin_023_sendcommand(0x00); //Set Memory Addressing Mode ab Horizontal addressing mode
|
||||
|
||||
}
|
||||
#endif // USES_P023
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P024
|
||||
//#######################################################################################################
|
||||
//#################################### Plugin 024: MLX90614 IR temperature I2C 0x5A) ###############################################
|
||||
//#######################################################################################################
|
||||
@@ -122,3 +123,4 @@ boolean Plugin_024(byte function, struct EventStruct *event, String& string)
|
||||
}
|
||||
return success;
|
||||
}
|
||||
#endif // USES_P024
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P025
|
||||
//#######################################################################################################
|
||||
//#################################### Plugin 025: ADS1115 I2C 0x48) ###############################################
|
||||
//#######################################################################################################
|
||||
@@ -9,7 +10,7 @@
|
||||
|
||||
boolean Plugin_025_init = false;
|
||||
|
||||
static uint16_t readRegister025(uint8_t i2cAddress, uint8_t reg) {
|
||||
uint16_t readRegister025(uint8_t i2cAddress, uint8_t reg) {
|
||||
Wire.beginTransmission(i2cAddress);
|
||||
Wire.write((0x00));
|
||||
Wire.endTransmission();
|
||||
@@ -202,3 +203,4 @@ boolean Plugin_025(byte function, struct EventStruct *event, String& string)
|
||||
}
|
||||
return success;
|
||||
}
|
||||
#endif // USES_P025
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P026
|
||||
//#######################################################################################################
|
||||
//#################################### Plugin 026: System Info ##########################################
|
||||
//#######################################################################################################
|
||||
@@ -134,3 +135,4 @@ boolean Plugin_026(byte function, struct EventStruct *event, String& string)
|
||||
}
|
||||
return success;
|
||||
}
|
||||
#endif // USES_P026
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P027
|
||||
//#######################################################################################################
|
||||
//######################### Plugin 027: INA219 DC Voltage/Current sensor ################################
|
||||
//#######################################################################################################
|
||||
@@ -426,3 +427,4 @@ float Plugin_027_getCurrent_mA(uint8_t i2caddr) {
|
||||
valueDec /= _ina219_data[idx].currentDivider_mA;
|
||||
return valueDec;
|
||||
}
|
||||
#endif // USES_P027
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P028
|
||||
//#######################################################################################################
|
||||
//#################### Plugin 028 BME280 I2C Temp/Hum/Barometric Pressure Sensor #######################
|
||||
//#######################################################################################################
|
||||
@@ -667,3 +668,4 @@ float Plugin_028_readAltitude(float seaLevel)
|
||||
float Plugin_028_pressureElevation(float atmospheric, int altitude) {
|
||||
return atmospheric / pow(1.0 - (altitude/44330.0), 5.255);
|
||||
}
|
||||
#endif // USES_P028
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
#ifdef USES_P029
|
||||
//#######################################################################################################
|
||||
//#################################### Plugin 029: Output ###############################################
|
||||
//#######################################################################################################
|
||||
|
||||
#define PLUGIN_029
|
||||
#define PLUGIN_ID_029 29
|
||||
#define PLUGIN_NAME_029 "Output - (Domoticz MQTT helper)"
|
||||
#define PLUGIN_NAME_029 "Output - Domoticz MQTT Helper"
|
||||
#define PLUGIN_VALUENAME1_029 "Output"
|
||||
boolean Plugin_029(byte function, struct EventStruct *event, String& string)
|
||||
{
|
||||
@@ -65,3 +66,4 @@ boolean Plugin_029(byte function, struct EventStruct *event, String& string)
|
||||
}
|
||||
return success;
|
||||
}
|
||||
#endif // USES_P029
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P030
|
||||
//#######################################################################################################
|
||||
//#################### Plugin 030 BMP280 I2C Temp/Barometric Pressure Sensor #######################
|
||||
//#######################################################################################################
|
||||
@@ -394,3 +395,4 @@ float Plugin_030_readAltitude(float seaLevel)
|
||||
float Plugin_030_pressureElevation(float atmospheric, int altitude) {
|
||||
return atmospheric / pow(1.0 - (altitude/44330.0), 5.255);
|
||||
}
|
||||
#endif // USES_P030
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P031
|
||||
//#######################################################################################################
|
||||
//#################### Plugin 031: SHT10/SHT11/SHT15 Temp/Humidity Sensor ###############################
|
||||
//#######################################################################################################
|
||||
@@ -242,3 +243,4 @@ int Plugin_031_readData(const int bits)
|
||||
|
||||
return val;
|
||||
}
|
||||
#endif // USES_P031
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P032
|
||||
//#######################################################################################################
|
||||
//################ Plugin 032 MS5611 (GY-63) I2C Temp/Barometric Pressure Sensor #######################
|
||||
//#######################################################################################################
|
||||
@@ -252,3 +253,4 @@ void Plugin_032_readout() {
|
||||
double Plugin_032_pressureElevation(double atmospheric, int altitude) {
|
||||
return atmospheric / pow(1.0 - (altitude/44330.0), 5.255);
|
||||
}
|
||||
#endif // USES_P032
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P033
|
||||
//#######################################################################################################
|
||||
//#################################### Plugin 033: Dummy ################################################
|
||||
//#######################################################################################################
|
||||
@@ -100,3 +101,4 @@ boolean Plugin_033(byte function, struct EventStruct *event, String& string)
|
||||
}
|
||||
return success;
|
||||
}
|
||||
#endif // USES_P033
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P034
|
||||
//#######################################################################################################
|
||||
//######################## Plugin 034: Temperature and Humidity sensor DHT 12 (I2C) #####################
|
||||
//#######################################################################################################
|
||||
@@ -110,3 +111,4 @@ boolean Plugin_034(byte function, struct EventStruct *event, String& string)
|
||||
}
|
||||
return success;
|
||||
}
|
||||
#endif // USES_P034
|
||||
|
||||
+10
-8
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P035
|
||||
//#######################################################################################################
|
||||
//#################################### Plugin 035: Output IR ############################################
|
||||
//#######################################################################################################
|
||||
@@ -204,14 +205,14 @@ boolean Plugin_035(byte function, struct EventStruct *event, String& string)
|
||||
if (GetArgv(command, TmpStr1, 5)) IrRepeat = str2int(TmpStr1);
|
||||
if (GetArgv(command, TmpStr1, 6)) IrSecondCode = strtoul(TmpStr1, NULL, 16);
|
||||
|
||||
if (IrType.equalsIgnoreCase("NEC")) Plugin_035_irSender->sendNEC(IrCode, IrBits);
|
||||
if (IrType.equalsIgnoreCase("JVC")) Plugin_035_irSender->sendJVC(IrCode, IrBits, 2);
|
||||
if (IrType.equalsIgnoreCase("RC5")) Plugin_035_irSender->sendRC5(IrCode, IrBits);
|
||||
if (IrType.equalsIgnoreCase("RC6")) Plugin_035_irSender->sendRC6(IrCode, IrBits);
|
||||
if (IrType.equalsIgnoreCase("SAMSUNG")) Plugin_035_irSender->sendSAMSUNG(IrCode, IrBits);
|
||||
if (IrType.equalsIgnoreCase("SONY")) Plugin_035_irSender->sendSony(IrCode, IrBits);
|
||||
if (IrType.equalsIgnoreCase("PANASONIC")) Plugin_035_irSender->sendPanasonic(IrBits, IrCode);
|
||||
if (IrType.equalsIgnoreCase("PIONEER")) Plugin_035_irSender->sendPioneer(IrCode, IrBits, IrRepeat, IrSecondCode);
|
||||
if (IrType.equalsIgnoreCase(F("NEC"))) Plugin_035_irSender->sendNEC(IrCode, IrBits);
|
||||
if (IrType.equalsIgnoreCase(F("JVC"))) Plugin_035_irSender->sendJVC(IrCode, IrBits, 2);
|
||||
if (IrType.equalsIgnoreCase(F("RC5"))) Plugin_035_irSender->sendRC5(IrCode, IrBits);
|
||||
if (IrType.equalsIgnoreCase(F("RC6"))) Plugin_035_irSender->sendRC6(IrCode, IrBits);
|
||||
if (IrType.equalsIgnoreCase(F("SAMSUNG"))) Plugin_035_irSender->sendSAMSUNG(IrCode, IrBits);
|
||||
if (IrType.equalsIgnoreCase(F("SONY"))) Plugin_035_irSender->sendSony(IrCode, IrBits);
|
||||
if (IrType.equalsIgnoreCase(F("PANASONIC"))) Plugin_035_irSender->sendPanasonic(IrBits, IrCode);
|
||||
if (IrType.equalsIgnoreCase(F("PIONEER"))) Plugin_035_irSender->sendPioneer(IrCode, IrBits, IrRepeat, IrSecondCode);
|
||||
}
|
||||
|
||||
addLog(LOG_LEVEL_INFO, F("IRTX :IR Code Sent"));
|
||||
@@ -233,3 +234,4 @@ boolean Plugin_035(byte function, struct EventStruct *event, String& string)
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // USES_P035
|
||||
|
||||
+10
-7
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P036
|
||||
//#######################################################################################################
|
||||
//#################################### Plugin 036: OLED SSD1306 display #################################
|
||||
//
|
||||
@@ -24,10 +25,11 @@
|
||||
#define P36_CONTRAST_MED 0xCF
|
||||
#define P36_CONTRAST_HIGH 0xFF
|
||||
|
||||
#include "SSD1306.h"
|
||||
#include "SH1106Wire.h"
|
||||
#include "OLED_SSD1306_SH1106_images.h"
|
||||
#include "Dialog_Plain_12_font.h"
|
||||
|
||||
#include "SSD1306.h"
|
||||
#include "SH1106Wire.h"
|
||||
#include "OLED_SSD1306_SH1106_images.h"
|
||||
#include "Dialog_Plain_12_font.h"
|
||||
|
||||
#define P36_WIFI_STATE_UNSET -2
|
||||
#define P36_WIFI_STATE_NOT_CONNECTED -1
|
||||
@@ -466,7 +468,7 @@ String P36_parseTemplate(String &tmpString, byte lineSize) {
|
||||
|
||||
void display_header() {
|
||||
static boolean showWiFiName = true;
|
||||
if (showWiFiName && (WiFi.status() == WL_CONNECTED) ) {
|
||||
if (showWiFiName && (wifiStatus == ESPEASY_WIFI_SERVICES_INITIALIZED) ) {
|
||||
String newString = WiFi.SSID();
|
||||
newString.trim();
|
||||
display_title(newString);
|
||||
@@ -629,7 +631,7 @@ void display_scroll(String outString[], String inString[], int nlines, int scrol
|
||||
|
||||
//Draw Signal Strength Bars, return true when there was an update.
|
||||
bool display_wifibars() {
|
||||
const bool connected = WiFi.status() == WL_CONNECTED;
|
||||
const bool connected = wifiStatus == ESPEASY_WIFI_SERVICES_INITIALIZED;
|
||||
const int nbars_filled = (WiFi.RSSI() + 100) / 8;
|
||||
const int newState = connected ? nbars_filled : P36_WIFI_STATE_UNSET;
|
||||
if (newState == lastWiFiState)
|
||||
@@ -651,7 +653,7 @@ bool display_wifibars() {
|
||||
display->setColor(BLACK);
|
||||
display->fillRect(x , y, size_x, size_y);
|
||||
display->setColor(WHITE);
|
||||
if (WiFi.status() == WL_CONNECTED) {
|
||||
if (wifiStatus == ESPEASY_WIFI_SERVICES_INITIALIZED) {
|
||||
for (byte ibar = 0; ibar < nbars; ibar++) {
|
||||
int16_t height = size_y * (ibar + 1) / nbars;
|
||||
int16_t xpos = x + ibar * width;
|
||||
@@ -670,3 +672,4 @@ bool display_wifibars() {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endif // USES_P036
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P037
|
||||
//#######################################################################################################
|
||||
//#################################### Plugin 037: MQTT Import ##########################################
|
||||
//#######################################################################################################
|
||||
@@ -19,8 +20,26 @@
|
||||
|
||||
// Declare a Wifi client for this plugin only
|
||||
|
||||
// TODO TD-er: These must be kept in some vector to allow multiple instances of MQTT import.
|
||||
WiFiClient espclient_037;
|
||||
PubSubClient *MQTTclient_037;
|
||||
PubSubClient *MQTTclient_037 = NULL;
|
||||
bool MQTTclient_037_connected = false;
|
||||
|
||||
void Plugin_037_update_connect_status() {
|
||||
bool connected = false;
|
||||
if (MQTTclient_037 != NULL) {
|
||||
connected = MQTTclient_037->connected();
|
||||
}
|
||||
if (MQTTclient_037_connected != connected) {
|
||||
MQTTclient_037_connected = !MQTTclient_037_connected;
|
||||
if (Settings.UseRules) {
|
||||
String event = connected ? F("MQTTimport#Connected") : F("MQTTimport#Disconnected");
|
||||
rulesProcessing(event);
|
||||
}
|
||||
if (!connected)
|
||||
addLog(LOG_LEVEL_ERROR, F("IMPT : MQTT 037 Connection lost"));
|
||||
}
|
||||
}
|
||||
|
||||
boolean Plugin_037(byte function, struct EventStruct *event, String& string)
|
||||
{
|
||||
@@ -121,7 +140,9 @@ boolean Plugin_037(byte function, struct EventStruct *event, String& string)
|
||||
|
||||
case PLUGIN_TEN_PER_SECOND:
|
||||
{
|
||||
MQTTclient_037->loop(); // Listen out for callbacks
|
||||
if (!MQTTclient_037->loop()) { // Listen out for callbacks
|
||||
Plugin_037_update_connect_status();
|
||||
}
|
||||
success = true;
|
||||
break;
|
||||
}
|
||||
@@ -133,13 +154,11 @@ boolean Plugin_037(byte function, struct EventStruct *event, String& string)
|
||||
if (!MQTTclient_037->connected() || MQTTclient_should_reconnect) {
|
||||
if (MQTTclient_should_reconnect) {
|
||||
addLog(LOG_LEVEL_ERROR, F("IMPT : MQTT 037 Intentional reconnect"));
|
||||
} else {
|
||||
addLog(LOG_LEVEL_ERROR, F("IMPT : MQTT 037 Connection lost"));
|
||||
}
|
||||
|
||||
|
||||
MQTTclient_037->disconnect();
|
||||
delay(1000);
|
||||
Plugin_037_update_connect_status();
|
||||
delay(250);
|
||||
|
||||
if (! MQTTConnect_037(ClientName)) {
|
||||
success = false;
|
||||
@@ -338,7 +357,8 @@ boolean MQTTConnect_037(String clientid)
|
||||
if (MQTTclient_037->connected()) return true;
|
||||
|
||||
// define stuff for the client - this could also be done in the intial declaration of MQTTclient_037
|
||||
if (!WiFiConnected(1000)) {
|
||||
if (!WiFiConnected(100)) {
|
||||
Plugin_037_update_connect_status();
|
||||
return false; // Not connected, so no use in wasting time to connect to a host.
|
||||
}
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
@@ -379,7 +399,7 @@ boolean MQTTConnect_037(String clientid)
|
||||
|
||||
delay(500);
|
||||
}
|
||||
|
||||
Plugin_037_update_connect_status();
|
||||
return MQTTclient_037->connected();
|
||||
}
|
||||
|
||||
@@ -448,3 +468,4 @@ boolean MQTTCheckSubscription_037(String Topic, String Subscription) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif // USES_P037
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P038
|
||||
//#######################################################################################################
|
||||
//#################################### Plugin 038: NeoPixel Basic #######################################
|
||||
//#######################################################################################################
|
||||
@@ -21,11 +22,12 @@
|
||||
// The NeoPixelLine command does not work for RGBW, cause espeasy currently only allows max. 5 parameters
|
||||
|
||||
#include <Adafruit_NeoPixel.h>
|
||||
|
||||
Adafruit_NeoPixel *Plugin_038_pixels;
|
||||
|
||||
#define PLUGIN_038
|
||||
#define PLUGIN_ID_038 38
|
||||
#define PLUGIN_NAME_038 "Output - NeoPixel (basic)"
|
||||
#define PLUGIN_NAME_038 "Output - NeoPixel (Basic)"
|
||||
#define PLUGIN_VALUENAME1_038 ""
|
||||
|
||||
int MaxPixels = 0;
|
||||
@@ -159,3 +161,4 @@ boolean Plugin_038(byte function, struct EventStruct *event, String& string)
|
||||
}
|
||||
return success;
|
||||
}
|
||||
#endif // USES_P038
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P039
|
||||
//#######################################################################################################
|
||||
//######################## Plugin 039: Thermocouple (MAX6675 / MAX31855) ################################
|
||||
//#######################################################################################################
|
||||
@@ -289,3 +290,4 @@ int Plugin_039_convert_two_complement(uint32_t value, int nr_bits) {
|
||||
}
|
||||
return nativeInt;
|
||||
}
|
||||
#endif // USES_P039
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P040
|
||||
//#######################################################################################################
|
||||
//#################################### Plugin 040: Serial RFID ID-12 ####################################
|
||||
//#######################################################################################################
|
||||
@@ -133,3 +134,4 @@ boolean Plugin_040(byte function, struct EventStruct *event, String& string)
|
||||
}
|
||||
return success;
|
||||
}
|
||||
#endif // USES_P040
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P041
|
||||
//#######################################################################################################
|
||||
//#################################### Plugin 041: NeoPixel clock #######################################
|
||||
//#######################################################################################################
|
||||
@@ -429,3 +430,4 @@ void pushHOURE() {
|
||||
pushToStrip(103);
|
||||
pushToStrip(104);
|
||||
}
|
||||
#endif // USES_P041
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P042
|
||||
//#######################################################################################################
|
||||
//######################################## Plugin 042: NeoPixel Candle ##################################
|
||||
//#######################################################################################################
|
||||
@@ -718,3 +719,4 @@ void RGBtoHSV(byte r, byte g, byte b, double hsv[3]) {
|
||||
hsv[1] = s * 255;
|
||||
hsv[2] = v * 255;
|
||||
}
|
||||
#endif // USES_P042
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P043
|
||||
//#######################################################################################################
|
||||
//#################################### Plugin 043: Clock Output #########################################
|
||||
//#######################################################################################################
|
||||
@@ -119,3 +120,4 @@ boolean Plugin_043(byte function, struct EventStruct *event, String& string)
|
||||
}
|
||||
return success;
|
||||
}
|
||||
#endif // USES_P043
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P044
|
||||
//#################################### Plugin 044: P1WifiGateway ########################################
|
||||
//
|
||||
// based on P020 Ser2Net, extended by Ronald Leenes romix/-at-/macuser.nl
|
||||
@@ -123,7 +124,7 @@ boolean Plugin_044(byte function, struct EventStruct *event, String& string)
|
||||
#endif
|
||||
#if defined(ESP32)
|
||||
Serial.begin(ExtraTaskSettings.TaskDevicePluginConfigLong[1], serialconfig);
|
||||
#endif
|
||||
#endif
|
||||
if (P1GatewayServer) P1GatewayServer->close();
|
||||
P1GatewayServer = new WiFiServer(ExtraTaskSettings.TaskDevicePluginConfigLong[0]);
|
||||
P1GatewayServer->begin();
|
||||
@@ -347,7 +348,7 @@ void blinkLED() {
|
||||
checks whether the incoming character is a valid one for a P1 datagram. Returns false if not, which signals corrupt datagram
|
||||
*/
|
||||
bool validP1char(char ch) {
|
||||
if ((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch == '.') || (ch == '!') || (ch == 92) || (ch == 13) || (ch == '\n') || (ch == '(') || (ch == ')') || (ch == '-') || (ch == '*') || (ch == ':') )
|
||||
if ((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch == '.') || (ch == '!') || (ch == ' ') || (ch == 92) || (ch == 13) || (ch == '\n') || (ch == '(') || (ch == ')') || (ch == '-') || (ch == '*') || (ch == ':') )
|
||||
{
|
||||
return true;
|
||||
} else {
|
||||
@@ -436,3 +437,4 @@ bool checkDatagram(int len) {
|
||||
}
|
||||
return validCRCFound;
|
||||
}
|
||||
#endif // USES_P044
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P045
|
||||
//#######################################################################################################
|
||||
//#################################### Plugin 045: MPU6050 [Testing] ####################################
|
||||
//#######################################################################################################
|
||||
@@ -401,3 +402,4 @@ void _P045_writeBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif // USES_P045
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P046
|
||||
//#######################################################################################################
|
||||
//#################################### Plugin 046: Ventus W266 [Testing] ################################
|
||||
//#######################################################################################################
|
||||
@@ -499,3 +500,4 @@ void Plugin_046_ISR_SCLK() // Interrupt on
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif // USES_P046
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P047
|
||||
//#######################################################################################################
|
||||
//#################### Plugin 047 Moisture & Temperature & Light I2C Soil moisture sensor ##############
|
||||
//#######################################################################################################
|
||||
@@ -302,3 +303,4 @@ bool Plugin_047_setAddress(int addr) {
|
||||
|
||||
|
||||
#endif
|
||||
#endif // USES_P047
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P048
|
||||
//#######################################################################################################
|
||||
//#################################### Plugin 048: Adafruit Motorshield v2 ##############################
|
||||
//#######################################################################################################
|
||||
@@ -102,18 +103,17 @@ boolean Plugin_048(byte function, struct EventStruct *event, String& string) {
|
||||
String tmpString = string;
|
||||
|
||||
String cmd = parseString(tmpString, 1);
|
||||
String param1 = parseString(tmpString, 2);
|
||||
String param2 = parseString(tmpString, 3);
|
||||
String param3 = parseString(tmpString, 4);
|
||||
String param4 = parseString(tmpString, 5);
|
||||
String param5 = parseString(tmpString, 6);
|
||||
|
||||
|
||||
// Commands:
|
||||
// MotorShieldCMD,<DCMotor>,<Motornumber>,<Forward/Backward/Release>,<Speed>
|
||||
|
||||
if (cmd.equalsIgnoreCase(F("MotorShieldCMD")))
|
||||
{
|
||||
String param1 = parseString(tmpString, 2);
|
||||
String param2 = parseString(tmpString, 3);
|
||||
String param3 = parseString(tmpString, 4);
|
||||
String param4 = parseString(tmpString, 5);
|
||||
String param5 = parseString(tmpString, 6);
|
||||
|
||||
// Create the motor shield object with the default I2C address
|
||||
AFMS = Adafruit_MotorShield(Plugin_048_MotorShield_address);
|
||||
@@ -277,3 +277,4 @@ boolean Plugin_048(byte function, struct EventStruct *event, String& string) {
|
||||
|
||||
|
||||
#endif
|
||||
#endif // USES_P048
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P049
|
||||
/*
|
||||
|
||||
This plug in is written by Dmitry (rel22 ___ inbox.ru)
|
||||
@@ -461,3 +462,4 @@ size_t _P049_send_mhzCmd(byte CommandId)
|
||||
|
||||
return Plugin_049_SoftSerial->write(mhzResp, sizeof(mhzResp));
|
||||
}
|
||||
#endif // USES_P049
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P050
|
||||
//#######################################################################################################
|
||||
//#################### Plugin 050 I2C TCS34725 RGB Color Sensor with IR filter and White LED ############
|
||||
//#######################################################################################################
|
||||
@@ -176,3 +177,4 @@ boolean Plugin_050(byte function, struct EventStruct *event, String& string)
|
||||
|
||||
|
||||
#endif
|
||||
#endif // USES_P050
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P051
|
||||
//#######################################################################################################
|
||||
//#################### Plugin 051 Temperature and Humidity Sensor AM2320 ##############
|
||||
//#######################################################################################################
|
||||
@@ -102,3 +103,4 @@ boolean Plugin_051(byte function, struct EventStruct *event, String& string)
|
||||
|
||||
|
||||
#endif
|
||||
#endif // USES_P051
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P052
|
||||
//#######################################################################################################
|
||||
//############################# Plugin 052: Senseair CO2 Sensors ########################################
|
||||
//#######################################################################################################
|
||||
@@ -416,3 +417,4 @@ int getBitOfInt(int reg, int pos)
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif // USES_P052
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P053
|
||||
//#######################################################################################################
|
||||
//#################################### Plugin 053: Plantower PMSx003 ####################################
|
||||
//#######################################################################################################
|
||||
@@ -301,3 +302,4 @@ boolean Plugin_053(byte function, struct EventStruct *event, String& string)
|
||||
return success;
|
||||
}
|
||||
#endif // PLUGIN_BUILD_TESTING
|
||||
#endif // USES_P053
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P054
|
||||
//#######################################################################################################
|
||||
//######################################## Plugin 054: DMX512 TX ########################################
|
||||
//#######################################################################################################
|
||||
@@ -34,7 +35,7 @@
|
||||
// Transceiver:
|
||||
// SN75176 or MAX485 or LT1785 or ...
|
||||
// Pin 5: GND
|
||||
// Pin 2, 3, 5: +5V
|
||||
// Pin 2, 3, 8: +5V
|
||||
// Pin 4: to ESP D4
|
||||
// Pin 6: DMX+ (hot)
|
||||
// Pin 7: DMX- (cold)
|
||||
@@ -256,3 +257,4 @@ boolean Plugin_054(byte function, struct EventStruct *event, String& string)
|
||||
}
|
||||
|
||||
#endif //PLUGIN_BUILD_TESTING
|
||||
#endif // USES_P054
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P055
|
||||
//#######################################################################################################
|
||||
//#################################### Plugin 055: Chiming Mechanism ####################################
|
||||
//#######################################################################################################
|
||||
@@ -501,3 +502,4 @@ byte Plugin_055_ReadChime(const String& name, String& tokens)
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // USES_P055
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P056
|
||||
//#######################################################################################################
|
||||
//#################################### Plugin 056: Dust Sensor SDS011 / SDS018 ##########################
|
||||
//#######################################################################################################
|
||||
@@ -204,3 +205,4 @@ void Plugin_056_setWorkingPeriod(int minutes) {
|
||||
}
|
||||
|
||||
#endif //PLUGIN_BUILD_TESTING
|
||||
#endif // USES_P056
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P057
|
||||
//#######################################################################################################
|
||||
//#################################### Plugin 057: HT16K33 LED ##########################################
|
||||
//#######################################################################################################
|
||||
@@ -324,3 +325,4 @@ boolean Plugin_057(byte function, struct EventStruct *event, String& string)
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // USES_P057
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P058
|
||||
//#######################################################################################################
|
||||
//#################################### Plugin 058: HT16K33 KeyPad #######################################
|
||||
//#######################################################################################################
|
||||
@@ -149,3 +150,4 @@ boolean Plugin_058(byte function, struct EventStruct *event, String& string)
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // USES_P058
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P059
|
||||
//#######################################################################################################
|
||||
//#################################### Plugin 059: Rotary Encoder #######################################
|
||||
//#######################################################################################################
|
||||
@@ -166,6 +167,28 @@ boolean Plugin_059(byte function, struct EventStruct *event, String& string)
|
||||
break;
|
||||
}
|
||||
|
||||
case PLUGIN_WRITE:
|
||||
{
|
||||
if (Plugin_059_QE)
|
||||
{
|
||||
String log = "";
|
||||
String command = parseString(string, 1);
|
||||
if (command == F("encwrite"))
|
||||
{
|
||||
if (event->Par1 >= 0)
|
||||
{
|
||||
log = String(F("QEI : ")) + string;
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
Plugin_059_QE->write(event->Par1);
|
||||
UserVar[event->BaseVarIndex] = (float) event->Par1;
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
return success;
|
||||
}
|
||||
#endif // USES_P059
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P060
|
||||
//#######################################################################################################
|
||||
//#################################### Plugin 060: MCP3221 ##############################################
|
||||
//#######################################################################################################
|
||||
@@ -81,11 +82,11 @@ boolean Plugin_060(byte function, struct EventStruct *event, String& string)
|
||||
|
||||
addFormCheckBox(string, F("Calibration Enabled"), F("plugin_060_cal"), CONFIG(3));
|
||||
|
||||
addFormNumericBox(string, F("Point 1"), F("plugin_060_adc1"), Settings.TaskDevicePluginConfigLong[event->TaskIndex][0], 0, 1023);
|
||||
addFormNumericBox(string, F("Point 1"), F("plugin_060_adc1"), Settings.TaskDevicePluginConfigLong[event->TaskIndex][0], 0, 4095);
|
||||
string += F(" ≙ ");
|
||||
addTextBox(string, F("plugin_060_out1"), String(Settings.TaskDevicePluginConfigFloat[event->TaskIndex][0], 3), 10);
|
||||
|
||||
addFormNumericBox(string, F("Point 2"), F("plugin_060_adc2"), Settings.TaskDevicePluginConfigLong[event->TaskIndex][1], 0, 1023);
|
||||
addFormNumericBox(string, F("Point 2"), F("plugin_060_adc2"), Settings.TaskDevicePluginConfigLong[event->TaskIndex][1], 0, 4095);
|
||||
string += F(" ≙ ");
|
||||
addTextBox(string, F("plugin_060_out2"), String(Settings.TaskDevicePluginConfigFloat[event->TaskIndex][1], 3), 10);
|
||||
|
||||
@@ -167,3 +168,4 @@ boolean Plugin_060(byte function, struct EventStruct *event, String& string)
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // USES_P060
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P061
|
||||
//#######################################################################################################
|
||||
//#################################### Plugin 061: PCF8574/MCP23017 KeyPad ##############################
|
||||
//#######################################################################################################
|
||||
@@ -373,3 +374,4 @@ byte PCF8574_KeyPadDirectScan(byte addr)
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // USES_P061
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P062
|
||||
//#######################################################################################################
|
||||
//#################################### Plugin 062: MPR121 KeyPad ########################################
|
||||
//#######################################################################################################
|
||||
@@ -159,3 +160,4 @@ boolean Plugin_062(byte function, struct EventStruct *event, String& string)
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // USES_P062
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P063
|
||||
//#######################################################################################################
|
||||
//#################################### Plugin 063: TTP229 KeyPad ########################################
|
||||
//#######################################################################################################
|
||||
@@ -204,3 +205,4 @@ boolean Plugin_063(byte function, struct EventStruct *event, String& string)
|
||||
}
|
||||
return success;
|
||||
}
|
||||
#endif // USES_P063
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P064
|
||||
//#######################################################################################################
|
||||
//#################################### Plugin 064: APDS9960 Gesture ##############################
|
||||
//#######################################################################################################
|
||||
@@ -215,3 +216,4 @@ boolean Plugin_064(byte function, struct EventStruct *event, String& string)
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // USES_P064
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P065
|
||||
//#######################################################################################################
|
||||
//############################# Plugin 065: P065_DFR0299_MP3 ############################################
|
||||
//#######################################################################################################
|
||||
@@ -227,3 +228,4 @@ void Plugin_065_SendCmd(byte cmd, int16_t data)
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // USES_P065
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P066
|
||||
//#######################################################################################################
|
||||
//#################################### Plugin 066: VEML6040 RGBW ##############################
|
||||
//#######################################################################################################
|
||||
@@ -234,3 +235,4 @@ float Plugin_066_CalcRelW(float X, float W)
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // USES_P066
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P067
|
||||
//#######################################################################################################
|
||||
//#################################### Plugin 063: _P067_HX711_Load_Cell ################################
|
||||
//#######################################################################################################
|
||||
@@ -289,3 +290,4 @@ boolean Plugin_067(byte function, struct EventStruct *event, String& string)
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // USES_P067
|
||||
|
||||
+10
-8
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P068
|
||||
//#######################################################################################################
|
||||
//################ Plugin 68: SHT30/SHT31/SHT35 Temperature and Humidity Sensor (I2C) ###################
|
||||
//#######################################################################################################
|
||||
@@ -87,7 +88,7 @@ void SHT3X::get()
|
||||
#define CONFIG(n) (Settings.TaskDevicePluginConfig[event->TaskIndex][n])
|
||||
#endif
|
||||
|
||||
SHT3X* Plugin_068_SHT3x = NULL;
|
||||
SHT3X* Plugin_068_SHT3x[TASKS_MAX] = { NULL, };
|
||||
|
||||
|
||||
//==============================================
|
||||
@@ -148,9 +149,9 @@ boolean Plugin_068(byte function, struct EventStruct *event, String& string)
|
||||
|
||||
case PLUGIN_INIT:
|
||||
{
|
||||
if (Plugin_068_SHT3x)
|
||||
delete Plugin_068_SHT3x;
|
||||
Plugin_068_SHT3x = new SHT3X(CONFIG(0));
|
||||
if (Plugin_068_SHT3x[event->TaskIndex])
|
||||
delete Plugin_068_SHT3x[event->TaskIndex];
|
||||
Plugin_068_SHT3x[event->TaskIndex] = new SHT3X(CONFIG(0));
|
||||
|
||||
success = true;
|
||||
break;
|
||||
@@ -158,12 +159,12 @@ boolean Plugin_068(byte function, struct EventStruct *event, String& string)
|
||||
|
||||
case PLUGIN_READ:
|
||||
{
|
||||
if (!Plugin_068_SHT3x)
|
||||
if (!Plugin_068_SHT3x[event->TaskIndex])
|
||||
return success;
|
||||
|
||||
Plugin_068_SHT3x->get();
|
||||
UserVar[event->BaseVarIndex + 0] = Plugin_068_SHT3x->tmp;
|
||||
UserVar[event->BaseVarIndex + 1] = Plugin_068_SHT3x->hum;
|
||||
Plugin_068_SHT3x[event->TaskIndex]->get();
|
||||
UserVar[event->BaseVarIndex + 0] = Plugin_068_SHT3x[event->TaskIndex]->tmp;
|
||||
UserVar[event->BaseVarIndex + 1] = Plugin_068_SHT3x[event->TaskIndex]->hum;
|
||||
String log = F("SHT3x: Temperature: ");
|
||||
log += UserVar[event->BaseVarIndex + 0];
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
@@ -178,3 +179,4 @@ boolean Plugin_068(byte function, struct EventStruct *event, String& string)
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // USES_P068
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P069
|
||||
//#######################################################################################################
|
||||
//########################### Plugin 69: LM75A Temperature Sensor (I2C) #################################
|
||||
//#######################################################################################################
|
||||
@@ -202,3 +203,4 @@ boolean Plugin_069(byte function, struct EventStruct *event, String& string)
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // USES_P069
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P070
|
||||
//#######################################################################################################
|
||||
//#################################### Plugin 070: NeoPixel ring clock #######################################
|
||||
//#######################################################################################################
|
||||
@@ -281,3 +282,4 @@ void timeToStrip(int hours, int minutes, int seconds) {
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // USES_P070
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P071
|
||||
//#######################################################################################################
|
||||
//############################# Plugin 071: Kamstrup Multical 401 #######################################
|
||||
//#######################################################################################################
|
||||
@@ -270,3 +271,4 @@ bool parity_check(unsigned input) {
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // USES_P071
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P072
|
||||
//######################################################################################################
|
||||
//####################### Plugin 072: Temperature and Humidity sensor HDC1080 (I2C) ####################
|
||||
//######################################################################################################
|
||||
@@ -99,3 +100,4 @@ boolean Plugin_072(byte function, struct EventStruct *event, String& string)
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // USES_P072
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user