mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-07-28 04:07:47 +00:00
Compare commits
158
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a151e60755 | ||
|
|
ce11c84e74 | ||
|
|
9808bf86c4 | ||
|
|
cfae636e55 | ||
|
|
ebaaf50df6 | ||
|
|
5c0be9e89f | ||
|
|
36468663f7 | ||
|
|
fba32608ee | ||
|
|
06848e50c3 | ||
|
|
879d0d4916 | ||
|
|
d083a58cd7 | ||
|
|
b1e9ff9fdc | ||
|
|
304280f415 | ||
|
|
2c8ca1421f | ||
|
|
3ce0fb9f75 | ||
|
|
8a71d2abd6 | ||
|
|
1b174f4eac | ||
|
|
f1d18c7b41 | ||
|
|
204d4607ba | ||
|
|
51f7ce0cb6 | ||
|
|
1d4147309c | ||
|
|
a68e4c1456 | ||
|
|
2ee51363dd | ||
|
|
172eb37b5b | ||
|
|
68e1d8ea69 | ||
|
|
ac8e8db0e7 | ||
|
|
d72bf9b76c | ||
|
|
6d3f535d16 | ||
|
|
0709763f3a | ||
|
|
538d843643 | ||
|
|
2339ee928c | ||
|
|
9550b951d5 | ||
|
|
0491af8a2f | ||
|
|
806a2757b2 | ||
|
|
3931b71d00 | ||
|
|
af0c3d5f62 | ||
|
|
c7a6ca4555 | ||
|
|
4a01e2eb49 | ||
|
|
d6ff20b35d | ||
|
|
0ada9aa105 | ||
|
|
6b04539571 | ||
|
|
9380ec13dc | ||
|
|
ae946c27c0 | ||
|
|
86cf00759f | ||
|
|
0eb5f55d63 | ||
|
|
f27d2aa7eb | ||
|
|
2d3285aaaf | ||
|
|
5bd2532853 | ||
|
|
765c56ccef | ||
|
|
4c755d83a6 | ||
|
|
1b9e1b92aa | ||
|
|
a4c73cc91e | ||
|
|
736fe2111a | ||
|
|
767b0af733 | ||
|
|
02255180e9 | ||
|
|
c3bde94f7a | ||
|
|
886958d479 | ||
|
|
84cbc19f38 | ||
|
|
178ec9dfa9 | ||
|
|
080be1ad0a | ||
|
|
232ca4f215 | ||
|
|
bfa6eac538 | ||
|
|
0ca06782b9 | ||
|
|
2079b0f28b | ||
|
|
32bf45e817 | ||
|
|
5d41bf9e73 | ||
|
|
dc5a2fd956 | ||
|
|
b20f05305b | ||
|
|
46586e5355 | ||
|
|
7e8a751657 | ||
|
|
7d61e55d34 | ||
|
|
2f663429a3 | ||
|
|
492791a4ac | ||
|
|
52e75ade78 | ||
|
|
525a0ba0a1 | ||
|
|
52c7e5012e | ||
|
|
4dd733eb63 | ||
|
|
02a065d623 | ||
|
|
e774ef5751 | ||
|
|
0afee4fafb | ||
|
|
eba1fb3388 | ||
|
|
b2c866edeb | ||
|
|
3583db3e22 | ||
|
|
5d3f8bf073 | ||
|
|
1a72444b0a | ||
|
|
dd88db1913 | ||
|
|
aab00567fc | ||
|
|
21cb6135dd | ||
|
|
f613bb4572 | ||
|
|
51059f0c18 | ||
|
|
dec6598f49 | ||
|
|
f8f6767bec | ||
|
|
07948c87aa | ||
|
|
5c475b98db | ||
|
|
58fb8dc42b | ||
|
|
cb2b11a41a | ||
|
|
ac4f3c4cd4 | ||
|
|
c651e29d2a | ||
|
|
d7e886a841 | ||
|
|
eec7647782 | ||
|
|
6f9d120ff0 | ||
|
|
28ddc2d9c0 | ||
|
|
cc54354ac3 | ||
|
|
3929390629 | ||
|
|
5f4685337e | ||
|
|
08c158aa9c | ||
|
|
e9d71a8f35 | ||
|
|
3e3173cbb0 | ||
|
|
3a26ebf7b1 | ||
|
|
1685bead52 | ||
|
|
3a2fe35e5c | ||
|
|
29ce7f774f | ||
|
|
cc85327356 | ||
|
|
0851bb655e | ||
|
|
d4bc10d8f1 | ||
|
|
0672f32f4b | ||
|
|
a17f7b679c | ||
|
|
425bd85c83 | ||
|
|
3be005e1ee | ||
|
|
174f9e6e03 | ||
|
|
51a14a174f | ||
|
|
7cb1f453d3 | ||
|
|
23a6caab89 | ||
|
|
6b4300bd46 | ||
|
|
04a9069db0 | ||
|
|
dd636903c8 | ||
|
|
4543a10739 | ||
|
|
940b65e86a | ||
|
|
6344de0649 | ||
|
|
8ccd7c3e8d | ||
|
|
22371649a4 | ||
|
|
2a48d5033e | ||
|
|
f064da797d | ||
|
|
b0b8edf935 | ||
|
|
8cbd9a0822 | ||
|
|
93f9d11738 | ||
|
|
cf3e0a3f0a | ||
|
|
ccfd14dbd3 | ||
|
|
3034738ad4 | ||
|
|
178d1c46a2 | ||
|
|
cdfd1d986e | ||
|
|
4b7aa53692 | ||
|
|
7959a5133f | ||
|
|
941fb5c29c | ||
|
|
c43c9ea2b3 | ||
|
|
967103bcad | ||
|
|
efe637ec70 | ||
|
|
00450eb260 | ||
|
|
cc02fa4481 | ||
|
|
fccc31a7c6 | ||
|
|
b84d905a0b | ||
|
|
94aa951cba | ||
|
|
2a23dcd011 | ||
|
|
ab3a406706 | ||
|
|
f135c63d84 | ||
|
|
daecf2017e | ||
|
|
37122bc619 | ||
|
|
4bca2c6361 |
@@ -1,18 +1,42 @@
|
||||
**NOTE: This is not a support forum! For questions and support go here: https://www.letscontrolit.com/forum/viewforum.php?f=1**
|
||||
<!--- NOTE: This is not a support forum! For questions and support go here: --->
|
||||
<!--- https://www.letscontrolit.com/forum/viewforum.php?f=1 --->
|
||||
<!--- Remove topics that are not applicable to your feature request of issue --->
|
||||
<!--- Remember to have a "to the point" TITLE --->
|
||||
|
||||
### Steps to reproduce
|
||||
How can we trigger this problem?
|
||||
|
||||
Does the problem persists after powering off and on? (just resetting isn't enough sometimes)
|
||||
### Summarize of the problem/feature request
|
||||
<!--- Describe the problem or feature request --->
|
||||
YOUR TEXT GOES HERE
|
||||
|
||||
### Expected behavior
|
||||
Tell us what should happen?
|
||||
<!--- Tell us what should happen? --->
|
||||
YOUR TEXT GOES HERE
|
||||
|
||||
### Actual behavior
|
||||
Tell us what happens instead?
|
||||
<!--- Tell us what happens instead? --->
|
||||
YOUR TEXT GOES HERE
|
||||
|
||||
### Steps to reproduce
|
||||
<!--- How can we trigger this problem? --->
|
||||
1.
|
||||
2.
|
||||
3.
|
||||
|
||||
<!--- Does the problem persists after powering off and on? (just resetting isn't enough sometimes) --->
|
||||
<!--- Please document if you have restarted the unit and if the problem is then gone etc. etc. --->
|
||||
### System configuration
|
||||
|
||||
<!--- Please add as much information and screenshots as possible --->
|
||||
Hardware:
|
||||
|
||||
Software or git version:
|
||||
<!--- You should also provide links to hardware pages etc where we can find more info --->
|
||||
ESP Easy version:
|
||||
|
||||
<!--- In order to have a better readablity of your issue then you should place screenshots here --->
|
||||
<!--- Simply drag and drop them onto this template, move the text string below the "ESP Easy settings/screenshots" topic --->
|
||||
ESP Easy settings/screenshots:
|
||||
|
||||
### Rules or log data
|
||||
<!--- place your code/rules between the two ``` rows --->
|
||||
<!--- remove if not applicable! --->
|
||||
```
|
||||
|
||||
```
|
||||
|
||||
Vendored
+314
@@ -1,3 +1,317 @@
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180414 (since mega-20180413)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Sat Apr 14 04:00:08 CEST 2018
|
||||
|
||||
GHolli (3):
|
||||
Update _P049_MHZ19.ino
|
||||
Change comma to semicolon
|
||||
Downstream updates (#1)
|
||||
|
||||
Gerald (1):
|
||||
Update _P049_MHZ19.ino
|
||||
|
||||
Grovkillen (4):
|
||||
Added RSSI, BSSID, Channel to WifiScan/Setup
|
||||
Removed the serial print "done."
|
||||
Added better(?) format for tables
|
||||
Fixed main page!
|
||||
|
||||
Holli (2):
|
||||
It seems the offsets [3]..[4] for the detection range setting (command byte 0x99) are wrong in the latest online data sheet: http://www.winsen-sensor.com/d/files/infrared-gas-sensor/mh-z19b-co2-ver1_0.pdf According to the MH-Z19B data sheet version 1.2, valid from: 2017.03.22 (received 2018-03-07), the offset should be [6]..[7] instead. Fixing the implementation accordingly.
|
||||
Disable detection range commands by default.
|
||||
|
||||
Plebs (5):
|
||||
Fixes for #1208 and partial #1196
|
||||
modified float() call
|
||||
new #formats
|
||||
added more formats
|
||||
Added #I
|
||||
|
||||
TD-er (1):
|
||||
[issue #1239] %bssid% and %wi_ch% added as variables
|
||||
|
||||
clumsy-stefan (1):
|
||||
_P015_TSL2561 added Broadband and IR Values
|
||||
|
||||
linuxnico (1):
|
||||
add ds1822 definition to ds_read_temp function
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180413 (since mega-20180412)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Fri Apr 13 04:00:09 CEST 2018
|
||||
|
||||
TD-er (1):
|
||||
[wifi] Event based wifi, fix set AP and crash on start
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180412 (since mega-20180410)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Thu Apr 12 04:00:14 CEST 2018
|
||||
|
||||
Gijs Noorlander (1):
|
||||
[MQTT] Process MQTT loop on publish
|
||||
|
||||
TD-er (7):
|
||||
[issue #1215] Cannot login to accesspoint on new install
|
||||
[issue #1215] Cannot login to accesspoint on new install
|
||||
[Wifi] Use statemachine to move between Wifi states
|
||||
[WiFi] Event based wifi, now AP mode works
|
||||
[wifi] Make it work for ESP32 again
|
||||
[wifi] Fix wifi AP setup mode for ESP32.
|
||||
[wifi] Event based wifi, improve scan information.
|
||||
|
||||
flexiti (1):
|
||||
ESP CPU speed and ID
|
||||
|
||||
mvdbro (1):
|
||||
Reboot/Reset pin, build 20101 patch
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180410 (since mega-20180409)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Tue Apr 10 04:00:21 CEST 2018
|
||||
|
||||
Grovkillen (5):
|
||||
Added comments that will not show up on issues
|
||||
Update issue_template.md
|
||||
Update issue_template.md
|
||||
Update issue_template.md
|
||||
Update issue_template.md
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180409 (since mega-20180407)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Mon Apr 9 04:00:13 CEST 2018
|
||||
|
||||
mvdbro (2):
|
||||
Factory Reset (not enabled yet)
|
||||
Both reset/factoryreset option
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180407 (since mega-20180405)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Sat Apr 7 04:00:12 CEST 2018
|
||||
|
||||
Grovkillen (1):
|
||||
Fixed clickable link www.letscontrolit.com (#1192)
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180405 (since mega-20180403)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Thu Apr 5 04:00:10 CEST 2018
|
||||
|
||||
Grovkillen (4):
|
||||
Updated JSON path for sensor values and names
|
||||
Delete WebServer.ino
|
||||
Moved to correct folder
|
||||
Added value number as discussed.
|
||||
|
||||
moi (3):
|
||||
Show CPU Load in JSON page
|
||||
Adds CPU Load LC in JSON page
|
||||
unwanted lib_ignore now properly commented
|
||||
|
||||
mvdbro (2):
|
||||
ESP32 RTOS config setting
|
||||
ESP32 RTOS 10 per second
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
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)
|
||||
-------------------------------------------------
|
||||
|
||||
@@ -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:
|
||||
|
||||
+489
-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,511 @@
|
||||
# -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_staged]
|
||||
platform = https://github.com/platformio/platform-espressif8266.git#feature/stage
|
||||
|
||||
[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_4_0.platform}
|
||||
|
||||
[normal]
|
||||
platform = ${common.platform}
|
||||
|
||||
# Testing and dev take too much memory for using 2.4.x core library.
|
||||
[testing]
|
||||
platform = ${core_2_3_0.platform}
|
||||
|
||||
[dev]
|
||||
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 = ${testing.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 = ${testing.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 = ${testing.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 = ${testing.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 = ${testing.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 = ${dev.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 = ${dev.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 = ${dev.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 = ${dev.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 = ${dev.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 = ${dev.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
|
||||
|
||||
+306
-128
@@ -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);
|
||||
setWifiState(WifiTryConnect);
|
||||
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);
|
||||
setWifiState(WifiEnableAP);
|
||||
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
|
||||
WifiDisconnect(); // 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();
|
||||
|
||||
+13
-11
@@ -92,11 +92,11 @@ void callback(char* c_topic, byte* b_payload, unsigned int length) {
|
||||
String log;
|
||||
log=F("MQTT : Topic: ");
|
||||
log+=c_topic;
|
||||
addLog(LOG_LEVEL_DEBUG, log);
|
||||
addLog(LOG_LEVEL_DEBUG_MORE, log);
|
||||
|
||||
log=F("MQTT : Payload: ");
|
||||
log+=c_payload;
|
||||
addLog(LOG_LEVEL_DEBUG, log);
|
||||
addLog(LOG_LEVEL_DEBUG_MORE, log);
|
||||
|
||||
// sprintf_P(log, PSTR("%s%s"), "MQTT : Topic: ", c_topic);
|
||||
// addLog(LOG_LEVEL_DEBUG, log);
|
||||
@@ -120,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 {
|
||||
@@ -166,11 +168,7 @@ bool MQTTConnect(int controller_idx)
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
|
||||
if (MQTTclient.publish(LWTTopic.c_str(), "Connected", 1)) {
|
||||
if (Settings.UseRules)
|
||||
{
|
||||
String event = F("MQTT#Connected");
|
||||
rulesProcessing(event);
|
||||
}
|
||||
updateMQTTclient_connected();
|
||||
statusLED(true);
|
||||
return true; // end loop if succesfull
|
||||
}
|
||||
@@ -183,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);
|
||||
@@ -227,8 +227,10 @@ void SendStatus(byte source, String status)
|
||||
|
||||
boolean MQTTpublish(int controller_idx, const char* topic, const char* payload, boolean retained)
|
||||
{
|
||||
if (MQTTclient.publish(topic, payload, retained))
|
||||
if (MQTTclient.publish(topic, payload, retained)) {
|
||||
timermqtt = millis(); // Make sure the MQTT is being processed as soon as possible.
|
||||
return true;
|
||||
}
|
||||
addLog(LOG_LEVEL_DEBUG, F("MQTT : publish failed"));
|
||||
return false;
|
||||
}
|
||||
|
||||
+35
-1
@@ -84,6 +84,14 @@ String minutesToDayHour(int minutes) {
|
||||
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;
|
||||
@@ -104,7 +112,33 @@ String secondsToDayHourMinuteSecond(int seconds) {
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************************************\
|
||||
|
||||
+175
-4
@@ -16,7 +16,8 @@
|
||||
#define DEFAULT_DELAY 60 // Sleep Delay in seconds
|
||||
|
||||
// --- Wifi AP Mode (when your Wifi Network is not reachable) ----------------------------------------
|
||||
#define DEFAULT_AP_IP 192,168,4,1 // Enter IP address (comma separated) for AP (config) mode
|
||||
#define DEFAULT_AP_IP 192,168,4,1 // Enter IP address (comma separated) for AP (config) mode
|
||||
#define DEFAULT_AP_SUBNET 255,255,255,0 // Enter IP address (comma separated) for AP (config) mode
|
||||
#define DEFAULT_AP_KEY "configesp" // Enter network WPA key for AP (config) mode
|
||||
|
||||
// --- Wifi Client Mode -----------------------------------------------------------------------------
|
||||
@@ -32,6 +33,8 @@
|
||||
#define DEFAULT_IPRANGE_HIGH "255.255.255.255" // Allowed IP range to access webserver
|
||||
#define DEFAULT_IP_BLOCK_LEVEL 1 // 0: ALL_ALLOWED 1: LOCAL_SUBNET_ALLOWED 2: ONLY_IP_RANGE_ALLOWED
|
||||
|
||||
#define DEFAULT_WIFI_CONNECTION_TIMEOUT 10000 // minimum timeout in ms for WiFi to be connected.
|
||||
|
||||
// --- Default Controller ------------------------------------------------------------------------------
|
||||
#define DEFAULT_CONTROLLER false // true or false enabled or disabled, set 1st controller defaults
|
||||
// using a default template, you also need to set a DEFAULT PROTOCOL to a suitable MQTT protocol !
|
||||
@@ -53,6 +56,10 @@
|
||||
|
||||
|
||||
// --- Advanced Settings ---------------------------------------------------------------------------------
|
||||
#if defined(ESP32)
|
||||
#define USE_RTOS_MULTITASKING
|
||||
#endif
|
||||
|
||||
#define DEFAULT_USE_RULES false // (true|false) Enable Rules?
|
||||
|
||||
#define DEFAULT_MQTT_RETAIN false // (true|false) Retain MQTT messages?
|
||||
@@ -147,7 +154,7 @@
|
||||
#define VERSION 3 // Change in config.dat mapping needs a full reset
|
||||
#endif
|
||||
|
||||
#define BUILD 20100 // git version 2.1.0
|
||||
#define BUILD 20101 // git version 2.1.01
|
||||
#if defined(ESP8266)
|
||||
#define BUILD_NOTES " - Mega"
|
||||
#endif
|
||||
@@ -432,11 +439,26 @@ using namespace fs;
|
||||
ADC_MODE(ADC_VCC);
|
||||
#endif
|
||||
|
||||
#define ESPEASY_WIFI_DISCONNECTED 0
|
||||
#define ESPEASY_WIFI_CONNECTED 1
|
||||
#define ESPEASY_WIFI_GOT_IP 2
|
||||
#define ESPEASY_WIFI_SERVICES_INITIALIZED 3
|
||||
|
||||
#if defined(ESP32)
|
||||
void WiFiEvent(system_event_id_t event, system_event_info_t info);
|
||||
#else
|
||||
WiFiEventHandler stationConnectedHandler;
|
||||
WiFiEventHandler stationDisconnectedHandler;
|
||||
WiFiEventHandler stationGotIpHandler;
|
||||
WiFiEventHandler APModeStationConnectedHandler;
|
||||
WiFiEventHandler APModeStationDisconnectedHandler;
|
||||
#endif
|
||||
|
||||
// Setup DNS, only used if the ESP has no valid WiFi config
|
||||
const byte DNS_PORT = 53;
|
||||
IPAddress apIP(DEFAULT_AP_IP);
|
||||
DNSServer dnsServer;
|
||||
bool dnsServerActive = false;
|
||||
#ifdef FEATURE_MDNS
|
||||
MDNSResponder mdns;
|
||||
#endif
|
||||
@@ -445,6 +467,7 @@ MDNSResponder mdns;
|
||||
WiFiClient mqtt;
|
||||
PubSubClient MQTTclient(mqtt);
|
||||
bool MQTTclient_should_reconnect = true;
|
||||
bool MQTTclient_connected = false;
|
||||
|
||||
// udp protocol stuff (syslog, global sync, node info list, ntp time)
|
||||
WiFiUDP portUDP;
|
||||
@@ -459,7 +482,68 @@ struct CRCStruct{
|
||||
uint32_t numberOfCRCBytes=0;
|
||||
}CRCValues;
|
||||
|
||||
enum Command {
|
||||
cmd_Unknown,
|
||||
cmd_accessinfo,
|
||||
cmd_background,
|
||||
cmd_BlynkGet,
|
||||
cmd_build,
|
||||
cmd_clearaccessblock,
|
||||
cmd_clearRTCRAM,
|
||||
cmd_config,
|
||||
cmd_Debug,
|
||||
cmd_Delay,
|
||||
cmd_deepSleep,
|
||||
cmd_Erase,
|
||||
cmd_Event,
|
||||
cmd_executeRules,
|
||||
cmd_i2cscanner,
|
||||
cmd_IP,
|
||||
cmd_Load,
|
||||
cmd_lowmem,
|
||||
cmd_malloc,
|
||||
cmd_meminfo,
|
||||
cmd_Name,
|
||||
cmd_notify,
|
||||
cmd_NoSleep,
|
||||
cmd_Password,
|
||||
cmd_Publish,
|
||||
cmd_Reboot,
|
||||
cmd_Reset,
|
||||
cmd_Restart,
|
||||
cmd_resetFlashWriteCounter,
|
||||
cmd_Rules,
|
||||
cmd_sdcard,
|
||||
cmd_sdremove,
|
||||
cmd_sysload,
|
||||
cmd_Save,
|
||||
cmd_SendTo,
|
||||
cmd_SendToHTTP,
|
||||
cmd_SendToUDP,
|
||||
cmd_SerialFloat,
|
||||
cmd_Settings,
|
||||
cmd_TaskClear,
|
||||
cmd_TaskClearAll,
|
||||
cmd_TaskRun,
|
||||
cmd_TaskValueSet,
|
||||
cmd_TimerSet,
|
||||
cmd_udptest,
|
||||
cmd_Unit,
|
||||
cmd_wdconfig,
|
||||
cmd_wdread,
|
||||
cmd_WifiAPMode,
|
||||
cmd_WifiConnect,
|
||||
cmd_WifiDisconnect,
|
||||
cmd_WifiKey2,
|
||||
cmd_WifiKey,
|
||||
cmd_WifiSSID2,
|
||||
cmd_WifiSSID,
|
||||
cmd_WifiScan
|
||||
};
|
||||
|
||||
|
||||
// Forward declarations.
|
||||
Command commandStringToEnum(const char * cmd);
|
||||
bool WiFiConnected(uint32_t timeout_ms);
|
||||
bool hostReachable(const IPAddress& ip);
|
||||
bool hostReachable(const String& hostname);
|
||||
@@ -491,6 +575,7 @@ struct SecurityStruct
|
||||
byte AllowedIPrangeLow[4]; // TD-er: Use these
|
||||
byte AllowedIPrangeHigh[4];
|
||||
byte IPblockLevel;
|
||||
|
||||
//its safe to extend this struct, up to 4096 bytes, default values in config are 0. Make sure crc is last
|
||||
uint8_t ProgmemMd5[16]; // crc of the binary that last saved the struct to file.
|
||||
uint8_t md5[16];
|
||||
@@ -612,6 +697,9 @@ struct SettingsStruct
|
||||
boolean ArduinoOTAEnable;
|
||||
uint16_t DST_Start;
|
||||
uint16_t DST_End;
|
||||
boolean UseRTOSMultitasking;
|
||||
int8_t Pin_Reset;
|
||||
|
||||
|
||||
//its safe to extend this struct, up to several bytes, default values in config are 0
|
||||
//look in misc.ino how config.dat is used because also other stuff is stored in it at different offsets.
|
||||
@@ -1043,15 +1131,91 @@ String dummyString = "";
|
||||
|
||||
byte lastBootCause = BOOT_CAUSE_MANUAL_REBOOT;
|
||||
|
||||
#if defined(ESP32)
|
||||
enum WiFiDisconnectReason
|
||||
{
|
||||
WIFI_DISCONNECT_REASON_UNSPECIFIED = 1,
|
||||
WIFI_DISCONNECT_REASON_AUTH_EXPIRE = 2,
|
||||
WIFI_DISCONNECT_REASON_AUTH_LEAVE = 3,
|
||||
WIFI_DISCONNECT_REASON_ASSOC_EXPIRE = 4,
|
||||
WIFI_DISCONNECT_REASON_ASSOC_TOOMANY = 5,
|
||||
WIFI_DISCONNECT_REASON_NOT_AUTHED = 6,
|
||||
WIFI_DISCONNECT_REASON_NOT_ASSOCED = 7,
|
||||
WIFI_DISCONNECT_REASON_ASSOC_LEAVE = 8,
|
||||
WIFI_DISCONNECT_REASON_ASSOC_NOT_AUTHED = 9,
|
||||
WIFI_DISCONNECT_REASON_DISASSOC_PWRCAP_BAD = 10, /* 11h */
|
||||
WIFI_DISCONNECT_REASON_DISASSOC_SUPCHAN_BAD = 11, /* 11h */
|
||||
WIFI_DISCONNECT_REASON_IE_INVALID = 13, /* 11i */
|
||||
WIFI_DISCONNECT_REASON_MIC_FAILURE = 14, /* 11i */
|
||||
WIFI_DISCONNECT_REASON_4WAY_HANDSHAKE_TIMEOUT = 15, /* 11i */
|
||||
WIFI_DISCONNECT_REASON_GROUP_KEY_UPDATE_TIMEOUT = 16, /* 11i */
|
||||
WIFI_DISCONNECT_REASON_IE_IN_4WAY_DIFFERS = 17, /* 11i */
|
||||
WIFI_DISCONNECT_REASON_GROUP_CIPHER_INVALID = 18, /* 11i */
|
||||
WIFI_DISCONNECT_REASON_PAIRWISE_CIPHER_INVALID = 19, /* 11i */
|
||||
WIFI_DISCONNECT_REASON_AKMP_INVALID = 20, /* 11i */
|
||||
WIFI_DISCONNECT_REASON_UNSUPP_RSN_IE_VERSION = 21, /* 11i */
|
||||
WIFI_DISCONNECT_REASON_INVALID_RSN_IE_CAP = 22, /* 11i */
|
||||
WIFI_DISCONNECT_REASON_802_1X_AUTH_FAILED = 23, /* 11i */
|
||||
WIFI_DISCONNECT_REASON_CIPHER_SUITE_REJECTED = 24, /* 11i */
|
||||
|
||||
WIFI_DISCONNECT_REASON_BEACON_TIMEOUT = 200,
|
||||
WIFI_DISCONNECT_REASON_NO_AP_FOUND = 201,
|
||||
WIFI_DISCONNECT_REASON_AUTH_FAIL = 202,
|
||||
WIFI_DISCONNECT_REASON_ASSOC_FAIL = 203,
|
||||
WIFI_DISCONNECT_REASON_HANDSHAKE_TIMEOUT = 204
|
||||
};
|
||||
#endif
|
||||
|
||||
enum WifiState {
|
||||
WifiOff,
|
||||
WifiStart,
|
||||
WifiTryConnect,
|
||||
WifiConnectionFailed,
|
||||
WifiClientConnectAP,
|
||||
WifiClientDisconnectAP,
|
||||
WifiCredentialsChanged,
|
||||
WifiConnectSuccess,
|
||||
WifiDisableAP,
|
||||
WifiEnableAP,
|
||||
WifiStartScan,
|
||||
};
|
||||
|
||||
WifiState currentWifiState = WifiStart;
|
||||
|
||||
void setWifiState(WifiState state);
|
||||
|
||||
// WiFi related data
|
||||
boolean wifiSetup = false;
|
||||
boolean wifiSetupConnect = false;
|
||||
uint8_t lastBSSID[6] = {0};
|
||||
boolean wifiConnected = false;
|
||||
unsigned long wifi_connect_timer = 0;
|
||||
uint8_t wifiStatus = ESPEASY_WIFI_DISCONNECTED;
|
||||
unsigned long last_wifi_connect_attempt_moment = 0;
|
||||
unsigned int wifi_connect_attempt = 0;
|
||||
uint8_t lastWiFiSettings = 0;
|
||||
String last_ssid;
|
||||
bool bssid_changed = false;
|
||||
uint8_t last_channel = 0;
|
||||
WiFiDisconnectReason lastDisconnectReason = WIFI_DISCONNECT_REASON_UNSPECIFIED;
|
||||
unsigned long lastConnectMoment = 0;
|
||||
unsigned long lastDisconnectMoment = 0;
|
||||
unsigned long lastGetIPmoment = 0;
|
||||
unsigned long lastGetScanMoment = 0;
|
||||
unsigned long lastConnectedDuration = 0;
|
||||
bool intent_to_reboot = false;
|
||||
uint8_t lastMacConnectedAPmode[6] = {0};
|
||||
uint8_t lastMacDisconnectedAPmode[6] = {0};
|
||||
|
||||
//uint32_t scan_done_status = 0;
|
||||
uint8_t scan_done_number = 0;
|
||||
//uint8_t scan_done_scan_id = 0;
|
||||
|
||||
// Semaphore like booleans for processing data gathered from WiFi events.
|
||||
bool processedConnect = true;
|
||||
bool processedDisconnect = true;
|
||||
bool processedGetIP = true;
|
||||
bool processedConnectAPmode = true;
|
||||
bool processedDisconnectAPmode = true;
|
||||
bool processedScanDone = true;
|
||||
|
||||
unsigned long start = 0;
|
||||
unsigned long elapsed = 0;
|
||||
@@ -1071,4 +1235,11 @@ bool firstLoop=true;
|
||||
|
||||
boolean activeRuleSets[RULESETS_MAX];
|
||||
|
||||
boolean UseRTOSMultitasking;
|
||||
|
||||
// These wifi event functions must be in a .h-file because otherwise the preprocessor
|
||||
// may not filter the ifdef checks properly.
|
||||
// Also the functions use a lot of global defined variables, so include at the end of this file.
|
||||
#include "ESPEasyWiFiEvent.h"
|
||||
|
||||
#endif /* ESPEASY_GLOBALS_H_ */
|
||||
|
||||
+159
-71
@@ -1,3 +1,4 @@
|
||||
|
||||
#ifdef CONTINUOUS_INTEGRATION
|
||||
#pragma GCC diagnostic error "-Wall"
|
||||
#else
|
||||
@@ -71,7 +72,9 @@
|
||||
// SHT1X temperature/humidity sensors
|
||||
// Ser2Net server
|
||||
|
||||
// Define globals before plugin sets to allow a personal override of the selected plugins
|
||||
#include "ESPEasy-Globals.h"
|
||||
#include "define_plugin_sets.h"
|
||||
|
||||
// Blynk_get prototype
|
||||
boolean Blynk_get(const String& command, byte controllerIndex,float *data = NULL );
|
||||
@@ -108,6 +111,16 @@ void setup()
|
||||
|
||||
initLog();
|
||||
|
||||
#if defined(ESP32)
|
||||
WiFi.onEvent((WiFiEventFullCb)WiFiEvent);
|
||||
#else
|
||||
// WiFi event handlers
|
||||
stationConnectedHandler = WiFi.onStationModeConnected(onConnected);
|
||||
stationDisconnectedHandler = WiFi.onStationModeDisconnected(onDisconnect);
|
||||
stationGotIpHandler = WiFi.onStationModeGotIP(onGotIP);
|
||||
APModeStationConnectedHandler = WiFi.onSoftAPModeStationConnected(onConnectedAPmode);
|
||||
APModeStationDisconnectedHandler = WiFi.onSoftAPModeStationDisconnected(onDisonnectedAPmode);
|
||||
#endif
|
||||
|
||||
if (SpiffsSectors() < 32)
|
||||
{
|
||||
@@ -155,13 +168,15 @@ void setup()
|
||||
saveToRTC();
|
||||
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
WiFi.setAutoReconnect(false);
|
||||
|
||||
fileSystemCheck();
|
||||
progMemMD5check();
|
||||
LoadSettings();
|
||||
checkRuleSets();
|
||||
if (strcasecmp(SecuritySettings.WifiSSID, "ssid") == 0)
|
||||
if (!selectValidWiFiSettings()) {
|
||||
wifiSetup = true;
|
||||
}
|
||||
|
||||
ExtraTaskSettings.TaskIndex = 255; // make sure this is an unused nr to prevent cache load on boot
|
||||
|
||||
@@ -184,6 +199,7 @@ void setup()
|
||||
//make sure previous serial buffers are flushed before resetting baudrate
|
||||
Serial.flush();
|
||||
Serial.begin(Settings.BaudRate);
|
||||
// Serial.setDebugOutput(true);
|
||||
}
|
||||
|
||||
if (Settings.Build != BUILD)
|
||||
@@ -210,7 +226,7 @@ void setup()
|
||||
timer100ms = 0; // timer for periodic actions 10 x per/sec
|
||||
timer1s = 0; // timer for periodic actions once per/sec
|
||||
timerwd = 0; // timer for watchdog once per 30 sec
|
||||
timermqtt = 0; // Timer for the MQTT keep alive loop.
|
||||
timermqtt = 10000; // Timer for the MQTT keep alive loop, initial value can be high, since it will be set as soon as IP is set.
|
||||
timermqtt_interval = 250; // Interval for checking MQTT
|
||||
timerAwakeFromDeepSleep = millis();
|
||||
|
||||
@@ -224,22 +240,15 @@ void setup()
|
||||
}
|
||||
|
||||
WiFi.persistent(false); // Do not use SDK storage of SSID/WPA parameters
|
||||
WifiAPconfig();
|
||||
|
||||
if (Settings.deepSleep)
|
||||
{
|
||||
//only one attempt in deepsleep, to conserve battery
|
||||
if (!WifiConnect(1))
|
||||
{
|
||||
if (Settings.deepSleepOnFail)
|
||||
{
|
||||
addLog(LOG_LEVEL_ERROR, F("SLEEP: Connection failed, going back to sleep."));
|
||||
deepSleep(Settings.Delay);
|
||||
}
|
||||
}
|
||||
/*
|
||||
// FIXME TD-er:
|
||||
// Async scanning for wifi doesn't work yet like it should.
|
||||
// So no selection of strongest network yet.
|
||||
if (selectValidWiFiSettings()) {
|
||||
WifiScanAsync();
|
||||
}
|
||||
else
|
||||
WiFiConnectRelaxed();
|
||||
*/
|
||||
setWifiState(WifiTryConnect);
|
||||
|
||||
#ifdef FEATURE_REPORTING
|
||||
ReportStatus();
|
||||
@@ -264,12 +273,6 @@ void setup()
|
||||
vcc = ESP.getVcc() / 1000.0;
|
||||
#endif
|
||||
|
||||
// Start DNS, only used if the ESP has no valid WiFi config
|
||||
// It will reply with it's own address on all DNS requests
|
||||
// (captive portal concept)
|
||||
if (wifiSetup)
|
||||
dnsServer.start(DNS_PORT, "*", apIP);
|
||||
|
||||
if (Settings.UseRules)
|
||||
{
|
||||
String event = F("System#Boot");
|
||||
@@ -278,8 +281,49 @@ void setup()
|
||||
|
||||
writeDefaultCSS();
|
||||
|
||||
UseRTOSMultitasking = Settings.UseRTOSMultitasking;
|
||||
#ifdef USE_RTOS_MULTITASKING
|
||||
if(UseRTOSMultitasking){
|
||||
log = F("RTOS : Launching tasks");
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
xTaskCreatePinnedToCore(RTOS_TaskServers, "RTOS_TaskServers", 8192, NULL, 1, NULL, 1);
|
||||
xTaskCreatePinnedToCore(RTOS_TaskSerial, "RTOS_TaskSerial", 8192, NULL, 1, NULL, 1);
|
||||
xTaskCreatePinnedToCore(RTOS_Task10ps, "RTOS_Task10ps", 8192, NULL, 1, NULL, 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#ifdef USE_RTOS_MULTITASKING
|
||||
void RTOS_TaskServers( void * parameter )
|
||||
{
|
||||
while (true){
|
||||
delay(100);
|
||||
WebServer.handleClient();
|
||||
checkUDP();
|
||||
}
|
||||
}
|
||||
|
||||
void RTOS_TaskSerial( void * parameter )
|
||||
{
|
||||
while (true){
|
||||
delay(100);
|
||||
if (Settings.UseSerial)
|
||||
if (Serial.available())
|
||||
if (!PluginCall(PLUGIN_SERIAL_IN, 0, dummyString))
|
||||
serial();
|
||||
}
|
||||
}
|
||||
|
||||
void RTOS_Task10ps( void * parameter )
|
||||
{
|
||||
while (true){
|
||||
delay(100);
|
||||
run10TimesPerSecond();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
int firstEnabledMQTTController() {
|
||||
for (byte i = 0; i < CONTROLLER_MAX; ++i) {
|
||||
byte ProtocolIndex = getProtocolIndex(Settings.Protocol[i]);
|
||||
@@ -307,20 +351,33 @@ void loop()
|
||||
if (wifiSetupConnect)
|
||||
{
|
||||
// try to connect for setup wizard
|
||||
WifiConnect(1);
|
||||
setWifiState(WifiCredentialsChanged);
|
||||
wifiSetupConnect = false;
|
||||
}
|
||||
if (wifiStatus != ESPEASY_WIFI_SERVICES_INITIALIZED) {
|
||||
if (wifiStatus >= ESPEASY_WIFI_CONNECTED) processConnect();
|
||||
if (wifiStatus >= ESPEASY_WIFI_GOT_IP) processGotIP();
|
||||
if (wifiStatus == ESPEASY_WIFI_DISCONNECTED) processDisconnect();
|
||||
} else if (WiFi.status() != WL_CONNECTED) {
|
||||
// Somehow the WiFi has entered a limbo state.
|
||||
// FIXME TD-er: This may happen on WiFi config with AP_STA mode active.
|
||||
// addLog(LOG_LEVEL_ERROR, F("Wifi status out sync"));
|
||||
// resetWiFi();
|
||||
}
|
||||
if (!processedConnectAPmode) processConnectAPmode();
|
||||
if (!processedDisconnectAPmode) processDisconnectAPmode();
|
||||
if (!processedScanDone) processScanDone();
|
||||
|
||||
// Deep sleep mode, just run all tasks one time and go back to sleep as fast as possible
|
||||
if (firstLoop && isDeepSleepEnabled())
|
||||
bool firstLoopWiFiConnected = wifiStatus == ESPEASY_WIFI_SERVICES_INITIALIZED && firstLoop;
|
||||
if (firstLoopWiFiConnected) {
|
||||
firstLoop = false;
|
||||
timerAwakeFromDeepSleep = millis(); // Allow to run for "awake" number of seconds, now we have wifi.
|
||||
}
|
||||
|
||||
// Deep sleep mode, just run all tasks one (more) time and go back to sleep as fast as possible
|
||||
if ((firstLoopWiFiConnected || readyForSleep()) && isDeepSleepEnabled())
|
||||
{
|
||||
// Setup MQTT Client
|
||||
// Controller index is forced to the first enabled MQTT controller.
|
||||
// This is normally done via frequent checks, but there's no time for in deepsleep.
|
||||
int enabledMqttController = firstEnabledMQTTController();
|
||||
if (enabledMqttController >= 0) {
|
||||
MQTTConnect(enabledMqttController);
|
||||
}
|
||||
runPeriodicalMQTT();
|
||||
// Now run all frequent tasks
|
||||
run50TimesPerSecond();
|
||||
run10TimesPerSecond();
|
||||
@@ -335,7 +392,8 @@ void loop()
|
||||
run50TimesPerSecond();
|
||||
|
||||
if (timeOutReached(timer100ms))
|
||||
run10TimesPerSecond();
|
||||
if(!UseRTOSMultitasking)
|
||||
run10TimesPerSecond();
|
||||
|
||||
if (timeOutReached(timerwd))
|
||||
runEach30Seconds();
|
||||
@@ -344,21 +402,7 @@ void loop()
|
||||
runOncePerSecond();
|
||||
|
||||
if (timeOutReached(timermqtt)) {
|
||||
// MQTT_KEEPALIVE = 15 seconds.
|
||||
timermqtt = millis() + timermqtt_interval;
|
||||
//dont do this in backgroundtasks(), otherwise causes crashes. (https://github.com/letscontrolit/ESPEasy/issues/683)
|
||||
int enabledMqttController = firstEnabledMQTTController();
|
||||
if (enabledMqttController >= 0) {
|
||||
if (!MQTTclient.loop()) {
|
||||
if (!MQTTCheck(enabledMqttController)) {
|
||||
// Check failed, no need to retry it immediately.
|
||||
if (timermqtt_interval < 2000)
|
||||
timermqtt_interval += 250;
|
||||
} else {
|
||||
timermqtt_interval = 250;
|
||||
}
|
||||
}
|
||||
}
|
||||
runPeriodicalMQTT();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -370,14 +414,58 @@ void loop()
|
||||
String event = F("System#Sleep");
|
||||
rulesProcessing(event);
|
||||
}
|
||||
// Flush outstanding MQTT messages
|
||||
runPeriodicalMQTT();
|
||||
|
||||
deepSleep(Settings.Delay);
|
||||
//deepsleep will never return, its a special kind of reboot
|
||||
}
|
||||
firstLoop = false;
|
||||
}
|
||||
|
||||
|
||||
void runPeriodicalMQTT() {
|
||||
// MQTT_KEEPALIVE = 15 seconds.
|
||||
if (!WiFiConnected(10)) {
|
||||
updateMQTTclient_connected();
|
||||
return;
|
||||
}
|
||||
//dont do this in backgroundtasks(), otherwise causes crashes. (https://github.com/letscontrolit/ESPEasy/issues/683)
|
||||
int enabledMqttController = firstEnabledMQTTController();
|
||||
if (enabledMqttController >= 0) {
|
||||
if (!MQTTclient.loop()) {
|
||||
updateMQTTclient_connected();
|
||||
if (MQTTCheck(enabledMqttController)) {
|
||||
updateMQTTclient_connected();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (MQTTclient.connected()) {
|
||||
MQTTclient.disconnect();
|
||||
updateMQTTclient_connected();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void updateMQTTclient_connected() {
|
||||
if (MQTTclient_connected != MQTTclient.connected()) {
|
||||
MQTTclient_connected = !MQTTclient_connected;
|
||||
if (!MQTTclient_connected)
|
||||
addLog(LOG_LEVEL_ERROR, F("MQTT : Connection lost"));
|
||||
if (Settings.UseRules) {
|
||||
String event = MQTTclient_connected ? F("MQTT#Connected") : F("MQTT#Disconnected");
|
||||
rulesProcessing(event);
|
||||
}
|
||||
}
|
||||
if (!MQTTclient_connected) {
|
||||
if (timermqtt_interval < 2000) {
|
||||
timermqtt_interval += 250;
|
||||
}
|
||||
} else {
|
||||
timermqtt_interval = 250;
|
||||
}
|
||||
timermqtt = millis() + timermqtt_interval;
|
||||
}
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Tasks that run 50 times per second
|
||||
\*********************************************************************************************/
|
||||
@@ -405,7 +493,9 @@ void run10TimesPerSecond()
|
||||
eventBuffer = "";
|
||||
}
|
||||
elapsed = micros() - start;
|
||||
WebServer.handleClient();
|
||||
#ifndef USE_RTOS_MULTITASKING
|
||||
WebServer.handleClient();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -493,12 +583,7 @@ void runOncePerSecond()
|
||||
Serial.print(F(" uS 1 ps:"));
|
||||
Serial.println(timer);
|
||||
}
|
||||
|
||||
if (timerAPoff != 0 && timeOutReached(timerAPoff))
|
||||
{
|
||||
timerAPoff = 0;
|
||||
WifiAPMode(false);
|
||||
}
|
||||
checkResetFactoryPin();
|
||||
}
|
||||
|
||||
/*********************************************************************************************\
|
||||
@@ -510,11 +595,14 @@ void runEach30Seconds()
|
||||
checkRAMtoLog();
|
||||
wdcounter++;
|
||||
timerwd = millis() + 30000;
|
||||
char str[60];
|
||||
str[0] = 0;
|
||||
sprintf_P(str, PSTR("Uptime %u ConnectFailures %u FreeMem %u"), wdcounter / 2, connectionFailures, FreeMem());
|
||||
String log = F("WD : ");
|
||||
log += str;
|
||||
String log;
|
||||
log.reserve(60);
|
||||
log = F("WD : Uptime ");
|
||||
log += wdcounter / 2;
|
||||
log += F(" ConnectFailures ");
|
||||
log += connectionFailures;
|
||||
log += F(" FreeMem ");
|
||||
log += FreeMem();
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
sendSysInfoUDP(1);
|
||||
refreshNodeList();
|
||||
@@ -741,19 +829,19 @@ void backgroundtasks()
|
||||
tcpCleanup();
|
||||
#endif
|
||||
|
||||
if (Settings.UseSerial)
|
||||
if (Serial.available())
|
||||
if (!PluginCall(PLUGIN_SERIAL_IN, 0, dummyString))
|
||||
serial();
|
||||
if(!UseRTOSMultitasking){
|
||||
if (Settings.UseSerial)
|
||||
if (Serial.available())
|
||||
if (!PluginCall(PLUGIN_SERIAL_IN, 0, dummyString))
|
||||
serial();
|
||||
WebServer.handleClient();
|
||||
checkUDP();
|
||||
}
|
||||
|
||||
// process DNS, only used if the ESP has no valid WiFi config
|
||||
if (wifiSetup)
|
||||
if (dnsServerActive)
|
||||
dnsServer.processNextRequest();
|
||||
|
||||
WebServer.handleClient();
|
||||
|
||||
checkUDP();
|
||||
|
||||
#ifdef FEATURE_ARDUINO_OTA
|
||||
if(Settings.ArduinoOTAEnable)
|
||||
ArduinoOTA.handle();
|
||||
|
||||
@@ -64,6 +64,7 @@ void setTimeZone(const TimeChangeRule& dstStart, const TimeChangeRule& stdStart,
|
||||
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,108 @@
|
||||
//********************************************************************************
|
||||
// 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;
|
||||
case SYSTEM_EVENT_AP_STACONNECTED:
|
||||
for (byte i = 0; i < 6; ++i) {
|
||||
lastMacConnectedAPmode[i] = info.sta_connected.mac[i];
|
||||
}
|
||||
processedConnectAPmode = false;
|
||||
break;
|
||||
case SYSTEM_EVENT_AP_STADISCONNECTED:
|
||||
for (byte i = 0; i < 6; ++i) {
|
||||
lastMacConnectedAPmode[i] = info.sta_disconnected.mac[i];
|
||||
}
|
||||
processedDisconnectAPmode = false;
|
||||
break;
|
||||
case SYSTEM_EVENT_SCAN_DONE:
|
||||
lastGetScanMoment = millis();
|
||||
// scan_done_status = info.scan_done.status;
|
||||
scan_done_number = info.scan_done.number;
|
||||
// scan_done_scan_id = info.scan_done.scan_id;
|
||||
processedScanDone = 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);
|
||||
lastDisconnectReason = event.reason;
|
||||
wifiStatus = ESPEASY_WIFI_DISCONNECTED;
|
||||
processedDisconnect = false;
|
||||
}
|
||||
|
||||
void onGotIP(const WiFiEventStationModeGotIP& event){
|
||||
lastGetIPmoment = millis();
|
||||
wifiStatus = ESPEASY_WIFI_GOT_IP;
|
||||
processedGetIP = false;
|
||||
}
|
||||
|
||||
void onConnectedAPmode(const WiFiEventSoftAPModeStationConnected& event) {
|
||||
for (byte i = 0; i < 6; ++i) {
|
||||
lastMacConnectedAPmode[i] = event.mac[i];
|
||||
}
|
||||
processedConnectAPmode = false;
|
||||
}
|
||||
|
||||
void onDisonnectedAPmode(const WiFiEventSoftAPModeStationDisconnected& event) {
|
||||
for (byte i = 0; i < 6; ++i) {
|
||||
lastMacDisconnectedAPmode[i] = event.mac[i];
|
||||
}
|
||||
processedDisconnectAPmode = false;
|
||||
}
|
||||
|
||||
void onScanFinished(int networksFound) {
|
||||
lastGetScanMoment = millis();
|
||||
scan_done_number = networksFound;
|
||||
processedScanDone = false;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,808 @@
|
||||
|
||||
#define WIFI_AP_OFF_TIMER_DURATION 60000 // in milliSeconds
|
||||
|
||||
//********************************************************************************
|
||||
// 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;
|
||||
processedConnect = true;
|
||||
if (wifiStatus < ESPEASY_WIFI_CONNECTED) return;
|
||||
const long connect_duration = timeDiff(last_wifi_connect_attempt_moment, lastConnectMoment);
|
||||
String log = F("WIFI : Connected! AP: ");
|
||||
log += WiFi.SSID();
|
||||
log += F(" (");
|
||||
log += WiFi.BSSIDstr();
|
||||
log += F(") Ch: ");
|
||||
log += last_channel;
|
||||
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 (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);
|
||||
}
|
||||
if (Settings.UseRules && bssid_changed) {
|
||||
String event = F("WiFi#ChangedAccesspoint");
|
||||
rulesProcessing(event);
|
||||
}
|
||||
setWifiState(WifiConnectSuccess);
|
||||
}
|
||||
|
||||
void processDisconnect() {
|
||||
if (processedDisconnect) return;
|
||||
processedDisconnect = true;
|
||||
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);
|
||||
if (wifi_connect_attempt > 5) {
|
||||
setWifiState(WifiConnectionFailed);
|
||||
} else {
|
||||
switch (lastDisconnectReason) {
|
||||
case WIFI_DISCONNECT_REASON_NO_AP_FOUND:
|
||||
case WIFI_DISCONNECT_REASON_AUTH_FAIL:
|
||||
case WIFI_DISCONNECT_REASON_ASSOC_FAIL:
|
||||
case WIFI_DISCONNECT_REASON_HANDSHAKE_TIMEOUT:
|
||||
// Disconnect without chance for success on next attempt
|
||||
if (selectNextWiFiSettings()) {
|
||||
if (!intent_to_reboot)
|
||||
setWifiState(WifiTryConnect);
|
||||
return;
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
setWifiState(WifiConnectionFailed);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
setWifiState(WifiStart);
|
||||
if (!intent_to_reboot)
|
||||
setWifiState(WifiTryConnect);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void processGotIP() {
|
||||
if (processedGetIP)
|
||||
return;
|
||||
processedGetIP = true;
|
||||
if (wifiStatus < ESPEASY_WIFI_GOT_IP)
|
||||
return;
|
||||
IPAddress ip = WiFi.localIP();
|
||||
if (ip[0] == 0 && ip[1] == 0 && ip[2] == 0 && ip[3] == 0)
|
||||
return;
|
||||
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);
|
||||
// WiFi.scanDelete();
|
||||
wifiStatus = ESPEASY_WIFI_SERVICES_INITIALIZED;
|
||||
if (wifiSetup) {
|
||||
// Wifi setup was active, Apparently these settings work.
|
||||
wifiSetup = false;
|
||||
SaveSettings();
|
||||
}
|
||||
}
|
||||
|
||||
void processConnectAPmode() {
|
||||
if (processedConnectAPmode) return;
|
||||
processedConnectAPmode = true;
|
||||
String log = F("AP Mode: Client connected: ");
|
||||
log += formatMAC(lastMacConnectedAPmode);
|
||||
log += F(" Connected devices: ");
|
||||
log += WiFi.softAPgetStationNum();
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
setWifiState(WifiClientConnectAP);
|
||||
}
|
||||
|
||||
void processDisconnectAPmode() {
|
||||
if (processedDisconnectAPmode) return;
|
||||
processedDisconnectAPmode = true;
|
||||
const int nrStationsConnected = WiFi.softAPgetStationNum();
|
||||
String log = F("AP Mode: Client disconnected: ");
|
||||
log += formatMAC(lastMacDisconnectedAPmode);
|
||||
log += F(" Connected devices: ");
|
||||
log += nrStationsConnected;
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
if (nrStationsConnected == 0) {
|
||||
setWifiState(WifiClientDisconnectAP);
|
||||
}
|
||||
}
|
||||
|
||||
void processScanDone() {
|
||||
if (processedScanDone) return;
|
||||
processedScanDone = true;
|
||||
String log = F("WIFI : Scan finished, found: ");
|
||||
log += scan_done_number;
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
|
||||
int bestScanID = -1;
|
||||
int32_t bestRssi = -1000;
|
||||
uint8_t bestWiFiSettings = lastWiFiSettings;
|
||||
if (selectValidWiFiSettings()) {
|
||||
bool done = false;
|
||||
String lastWiFiSettingsSSID = getLastWiFiSettingsSSID();
|
||||
for (int settingNr = 0; !done && settingNr < 2; ++settingNr) {
|
||||
for (int i = 0; i < scan_done_number; ++i) {
|
||||
if (WiFi.SSID(i) == lastWiFiSettingsSSID) {
|
||||
int32_t rssi = WiFi.RSSI(i);
|
||||
if (bestRssi < rssi) {
|
||||
bestRssi = rssi;
|
||||
bestScanID = i;
|
||||
bestWiFiSettings = lastWiFiSettings;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!selectNextWiFiSettings()) done = true;
|
||||
}
|
||||
if (bestScanID >= 0) {
|
||||
log = F("WIFI : Selected: ");
|
||||
log += formatScanResult(bestScanID, " ");
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
lastWiFiSettings = bestWiFiSettings;
|
||||
uint8_t * scanbssid = WiFi.BSSID(bestScanID);
|
||||
if (scanbssid) {
|
||||
for (int i = 0; i < 6 ; ++i) {
|
||||
lastBSSID[i] = *(scanbssid + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
setWifiState(WifiTryConnect);
|
||||
}
|
||||
}
|
||||
|
||||
void resetWiFi() {
|
||||
addLog(LOG_LEVEL_INFO, F("Reset WiFi."));
|
||||
setWifiState(WifiOff);
|
||||
setWifiState(WifiStart);
|
||||
lastDisconnectMoment = millis();
|
||||
processedDisconnect = false;
|
||||
wifiStatus = ESPEASY_WIFI_DISCONNECTED;
|
||||
}
|
||||
|
||||
void WifiScanAsync() {
|
||||
setWifiState(WifiStartScan);
|
||||
addLog(LOG_LEVEL_INFO, F("WIFI : Start network scan"));
|
||||
#ifdef ESP32
|
||||
bool async = true;
|
||||
bool show_hidden = false;
|
||||
bool passive = false;
|
||||
uint32_t max_ms_per_chan = 300;
|
||||
WiFi.scanNetworks(async, show_hidden, passive, max_ms_per_chan);
|
||||
#else
|
||||
// 2.4.x only and it doesn't work like expected.
|
||||
// WiFi.scanNetworksAsync(onScanFinished);
|
||||
#endif
|
||||
}
|
||||
|
||||
//********************************************************************************
|
||||
// WiFi state
|
||||
//********************************************************************************
|
||||
// 0 Wifi off
|
||||
// 1 Start => STA
|
||||
// 2 Try connect => STA => successful, goto 7
|
||||
// 3 Connection fails => AP => no client in N seconds, goto 1
|
||||
// 4 Client connects => AP
|
||||
// 5 Credentials changed => STA_AP => goto 2
|
||||
// 6 Connect successful (AP on) => STA_AP => disable AP after N seconds, goto 8
|
||||
// 7 Connect successful => STA
|
||||
// 8 Disable AP after N seconds => STA
|
||||
//********************************************************************************
|
||||
|
||||
bool WifiIsAP(WiFiMode_t wifimode)
|
||||
{
|
||||
#if defined(ESP32)
|
||||
return (wifimode == WIFI_MODE_AP) || (wifimode == WIFI_MODE_APSTA);
|
||||
#else
|
||||
return (wifimode == WIFI_AP) || (wifimode == WIFI_AP_STA);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool WifiIsSTA(WiFiMode_t wifimode)
|
||||
{
|
||||
#if defined(ESP32)
|
||||
return ((wifimode & WIFI_MODE_STA) != 0);
|
||||
#else
|
||||
return ((wifimode & WIFI_STA) != 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
void setWifiState(WifiState state) {
|
||||
currentWifiState = state;
|
||||
switch (state) {
|
||||
case WifiOff:
|
||||
WifiDisconnect();
|
||||
changeWifiMode(WIFI_OFF);
|
||||
break;
|
||||
case WifiStart:
|
||||
changeWifiMode(WIFI_STA);
|
||||
break;
|
||||
case WifiConnectionFailed:
|
||||
addLog(LOG_LEVEL_INFO, F("WIFI : Connection Failed"));
|
||||
if (WIFI_AP != WiFi.getMode()) {
|
||||
changeWifiMode(WIFI_AP);
|
||||
wifiSetup = true;
|
||||
timerAPoff = millis() + WIFI_AP_OFF_TIMER_DURATION;
|
||||
}
|
||||
break;
|
||||
case WifiClientConnectAP:
|
||||
timerAPoff = 0; // Disable timer to switch AP off.
|
||||
changeWifiMode(WIFI_AP);
|
||||
break;
|
||||
case WifiClientDisconnectAP:
|
||||
if (WifiIsAP(WiFi.getMode())) {
|
||||
timerAPoff = millis() + WIFI_AP_OFF_TIMER_DURATION;
|
||||
}
|
||||
break;
|
||||
case WifiCredentialsChanged:
|
||||
lastWiFiSettings = 0; // Force to load the first settings.
|
||||
wifi_connect_attempt = 0;
|
||||
// fall through
|
||||
case WifiTryConnect:
|
||||
if (WifiIsAP(WiFi.getMode())) {
|
||||
timerAPoff = 0; // Disable timer to switch AP off.
|
||||
changeWifiMode(WIFI_AP_STA);
|
||||
} else {
|
||||
changeWifiMode(WIFI_STA);
|
||||
}
|
||||
if (prepareWiFi()) {
|
||||
tryConnectWiFi();
|
||||
} else {
|
||||
setWifiState(WifiConnectionFailed);
|
||||
}
|
||||
break;
|
||||
case WifiConnectSuccess:
|
||||
if (WifiIsAP(WiFi.getMode())) {
|
||||
timerAPoff = millis() + WIFI_AP_OFF_TIMER_DURATION;
|
||||
} else {
|
||||
timerAPoff = 0; // Disable timer to switch AP off.
|
||||
changeWifiMode(WIFI_STA);
|
||||
}
|
||||
wifi_connect_attempt = 0;
|
||||
break;
|
||||
case WifiDisableAP:
|
||||
if (WifiIsAP(WiFi.getMode())) {
|
||||
timerAPoff = 0; // Disable timer to switch AP off.
|
||||
changeWifiMode(WIFI_STA);
|
||||
}
|
||||
break;
|
||||
case WifiEnableAP:
|
||||
if (wifiStatus == ESPEASY_WIFI_SERVICES_INITIALIZED) {
|
||||
changeWifiMode(WIFI_AP_STA);
|
||||
} else {
|
||||
changeWifiMode(WIFI_AP);
|
||||
}
|
||||
timerAPoff = millis() + WIFI_AP_OFF_TIMER_DURATION;
|
||||
break;
|
||||
case WifiStartScan:
|
||||
if (WifiIsAP(WiFi.getMode())) {
|
||||
changeWifiMode(WIFI_AP_STA);
|
||||
} else changeWifiMode(WIFI_STA);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//********************************************************************************
|
||||
// Set Wifi AP Mode
|
||||
//********************************************************************************
|
||||
void setWifiMode(WiFiMode_t wifimode) {
|
||||
switch (wifimode) {
|
||||
case WIFI_OFF:
|
||||
addLog(LOG_LEVEL_INFO, F("WIFI : Switch off WiFi"));
|
||||
break;
|
||||
case WIFI_STA:
|
||||
addLog(LOG_LEVEL_INFO, F("WIFI : Set WiFi to STA"));
|
||||
break;
|
||||
case WIFI_AP:
|
||||
addLog(LOG_LEVEL_INFO, F("WIFI : Set WiFi to AP"));
|
||||
break;
|
||||
case WIFI_AP_STA:
|
||||
addLog(LOG_LEVEL_INFO, F("WIFI : Set WiFi to AP+STA"));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
WiFi.mode(wifimode);
|
||||
}
|
||||
|
||||
void changeWifiMode(WiFiMode_t wifimode)
|
||||
{
|
||||
if (wifimode == WiFi.getMode()) return;
|
||||
if (WiFi.getMode() == WIFI_OFF) {
|
||||
// Any mode can be selected, starting from off mode.
|
||||
addLog(LOG_LEVEL_INFO, F("WIFI : Switch on WiFi"));
|
||||
setWifiMode(wifimode);
|
||||
return;
|
||||
}
|
||||
switch (wifimode) {
|
||||
case WIFI_OFF:
|
||||
WifiDisconnect();
|
||||
setWifiMode(WIFI_OFF);
|
||||
return;
|
||||
case WIFI_STA:
|
||||
if (WifiIsAP(WiFi.getMode())) {
|
||||
// Change from AP mode to STA mode, must disconnect clients.
|
||||
dnsServerActive = false;
|
||||
dnsServer.stop();
|
||||
if (WiFi.softAPdisconnect(true)) {
|
||||
String log("WIFI : AP Mode Disabled for SSID: ");
|
||||
log += WifiGetAPssid();
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
} else {
|
||||
String log("WIFI : Error while disabling AP Mode with SSID: ");
|
||||
log += WifiGetAPssid();
|
||||
addLog(LOG_LEVEL_ERROR, log);
|
||||
}
|
||||
}
|
||||
setWifiMode(wifimode);
|
||||
WiFi.reconnect();
|
||||
break;
|
||||
case WIFI_AP_STA:
|
||||
case WIFI_AP:
|
||||
{
|
||||
if (WifiIsSTA(WiFi.getMode())) {
|
||||
// Should disable WiFi first and then restart in AP mode.
|
||||
WifiDisconnect();
|
||||
if (wifimode == WIFI_AP_STA) {
|
||||
WiFi.reconnect();
|
||||
}
|
||||
// setWifiMode(WIFI_OFF);
|
||||
delay(100);
|
||||
}
|
||||
// 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
|
||||
setWifiMode(wifimode);
|
||||
WiFi.setAutoConnect(false);
|
||||
String softAPSSID=WifiGetAPssid();
|
||||
String pwd = SecuritySettings.WifiAPKey;
|
||||
IPAddress subnet(DEFAULT_AP_SUBNET);
|
||||
if (!WiFi.softAPConfig(apIP, apIP, subnet)) {
|
||||
addLog(LOG_LEVEL_ERROR, "WIFI : [AP] softAPConfig failed!");
|
||||
}
|
||||
if (WiFi.softAP(softAPSSID.c_str(),pwd.c_str())) {
|
||||
String log("WIFI : AP Mode ssid will be ");
|
||||
log += softAPSSID;
|
||||
log += F(" with address ");
|
||||
log += WiFi.softAPIP().toString();
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
} else {
|
||||
String log("WIFI : Error while starting AP Mode with SSID: ");
|
||||
log += softAPSSID;
|
||||
log += F(" IP: ");
|
||||
log += apIP.toString();
|
||||
addLog(LOG_LEVEL_ERROR, log);
|
||||
}
|
||||
#ifdef ESP32
|
||||
|
||||
#else
|
||||
if(wifi_softap_dhcps_status() != DHCP_STARTED) {
|
||||
if(!wifi_softap_dhcps_start()) {
|
||||
addLog(LOG_LEVEL_ERROR, "WIFI : [AP] wifi_softap_dhcps_start failed!");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// Start DNS, only used if the ESP has no valid WiFi config
|
||||
// It will reply with it's own address on all DNS requests
|
||||
// (captive portal concept)
|
||||
dnsServerActive = true;
|
||||
dnsServer.start(DNS_PORT, "*", apIP);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//********************************************************************************
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
||||
bool useStaticIP() {
|
||||
return (Settings.IP[0] != 0 && Settings.IP[0] != 255);
|
||||
}
|
||||
|
||||
//********************************************************************************
|
||||
// Set Wifi config
|
||||
//********************************************************************************
|
||||
bool prepareWiFi() {
|
||||
if (!selectValidWiFiSettings()) {
|
||||
addLog(LOG_LEVEL_ERROR, F("WIFI : No valid wifi settings"));
|
||||
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
|
||||
return 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; // Allow for empty pass
|
||||
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 (WifiIsAP(WiFi.getMode())) {
|
||||
// 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) {
|
||||
if (!WifiIsAP(WiFi.getMode())) {
|
||||
// Only when not in AP mode.
|
||||
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;
|
||||
}
|
||||
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()
|
||||
{
|
||||
#if defined(ESP32)
|
||||
WiFi.disconnect();
|
||||
#else
|
||||
ETS_UART_INTR_DISABLE();
|
||||
wifi_station_disconnect();
|
||||
ETS_UART_INTR_ENABLE();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
//********************************************************************************
|
||||
// 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.println(formatScanResult(i, " "));
|
||||
delay(10);
|
||||
}
|
||||
}
|
||||
Serial.println("");
|
||||
}
|
||||
|
||||
String formatScanResult(int i, const String& separator) {
|
||||
String result = WiFi.SSID(i);
|
||||
result += separator;
|
||||
result += WiFi.BSSIDstr(i);
|
||||
result += separator;
|
||||
result += F("Ch:");
|
||||
result += WiFi.channel(i);
|
||||
result += F(" (");
|
||||
result += WiFi.RSSI(i);
|
||||
result += F("dBm) ");
|
||||
switch (WiFi.encryptionType(i)) {
|
||||
#ifdef ESP32
|
||||
case WIFI_AUTH_OPEN: result += F("open"); break;
|
||||
case WIFI_AUTH_WEP: result += F("WEP"); break;
|
||||
case WIFI_AUTH_WPA_PSK: result += F("WPA/PSK"); break;
|
||||
case WIFI_AUTH_WPA2_PSK: result += F("WPA2/PSK"); break;
|
||||
case WIFI_AUTH_WPA_WPA2_PSK: result += F("WPA/WPA2/PSK"); break;
|
||||
case WIFI_AUTH_WPA2_ENTERPRISE: result += F("WPA2 Enterprise"); break;
|
||||
#else
|
||||
case ENC_TYPE_WEP: result += F("WEP"); break;
|
||||
case ENC_TYPE_TKIP: result += F("WPA/PSK"); break;
|
||||
case ENC_TYPE_CCMP: result += F("WPA2/PSK"); break;
|
||||
case ENC_TYPE_NONE: result += F("open"); break;
|
||||
case ENC_TYPE_AUTO: result += F("WPA/WPA2/PSK"); break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
//********************************************************************************
|
||||
// Check if we are still connected to a Wifi AP
|
||||
//********************************************************************************
|
||||
void WifiCheck()
|
||||
{
|
||||
if(wifiSetup)
|
||||
return;
|
||||
|
||||
if (WifiIsAP(WiFi.getMode())) {
|
||||
// disable AP after timeout.
|
||||
if (timerAPoff && timeOutReached(timerAPoff)) {
|
||||
setWifiState(WifiDisableAP);
|
||||
}
|
||||
}
|
||||
|
||||
if (wifiStatus == ESPEASY_WIFI_DISCONNECTED)
|
||||
{
|
||||
NC_Count++;
|
||||
if (!WifiIsAP(WiFi.getMode()))
|
||||
setWifiState(WifiTryConnect);
|
||||
}
|
||||
//connected
|
||||
else if (wifiStatus == ESPEASY_WIFI_SERVICES_INITIALIZED)
|
||||
{
|
||||
C_Count++;
|
||||
NC_Count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//********************************************************************************
|
||||
// Return subnet range of WiFi.
|
||||
//********************************************************************************
|
||||
bool getSubnetRange(IPAddress& low, IPAddress& high)
|
||||
{
|
||||
if (WifiIsAP(WiFi.getMode())) {
|
||||
// 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");
|
||||
}
|
||||
@@ -26,6 +26,9 @@ void hardwareInit()
|
||||
break;
|
||||
}
|
||||
|
||||
if (Settings.Pin_Reset != -1)
|
||||
pinMode(Settings.Pin_Reset,INPUT_PULLUP);
|
||||
|
||||
// configure hardware pins according to eeprom settings.
|
||||
if (Settings.Pin_i2c_sda != -1)
|
||||
{
|
||||
@@ -97,3 +100,27 @@ void hardwareInit()
|
||||
|
||||
}
|
||||
|
||||
void checkResetFactoryPin(){
|
||||
static byte factoryResetCounter=0;
|
||||
if (Settings.Pin_Reset == -1)
|
||||
return;
|
||||
|
||||
if (digitalRead(Settings.Pin_Reset) == 0){ // active low reset pin
|
||||
factoryResetCounter++; // just count every second
|
||||
}
|
||||
else
|
||||
{ // reset pin released
|
||||
if (factoryResetCounter > 9) // factory reset and reboot
|
||||
ResetFactory();
|
||||
if (factoryResetCounter > 3) // normal reboot
|
||||
#if defined(ESP8266)
|
||||
ESP.reset();
|
||||
#endif
|
||||
#if defined(ESP32)
|
||||
ESP.restart();
|
||||
#endif
|
||||
|
||||
factoryResetCounter = 0; // count was < 3, reset counter
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+147
-110
@@ -44,6 +44,10 @@ 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);
|
||||
}
|
||||
|
||||
@@ -317,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 )
|
||||
@@ -328,7 +332,7 @@ void statusLED(boolean traffic)
|
||||
}
|
||||
}
|
||||
//AP mode is active
|
||||
else if (WifiIsAP())
|
||||
else if (WifiIsAP(WiFi.getMode()))
|
||||
{
|
||||
nStatusValue = ((millis()>>1) & PWMRANGE) - (PWMRANGE>>2); //ramp up for 2 sec, 3/4 luminosity
|
||||
}
|
||||
@@ -478,6 +482,13 @@ String BuildFixes()
|
||||
f.close();
|
||||
}
|
||||
}
|
||||
|
||||
if (Settings.Build < 20101)
|
||||
{
|
||||
Serial.println(F("Fix reset Pin"));
|
||||
Settings.Pin_Reset = -1;
|
||||
}
|
||||
|
||||
Settings.Build = BUILD;
|
||||
return(SaveSettings());
|
||||
}
|
||||
@@ -690,25 +701,36 @@ String SaveSettings(void)
|
||||
{
|
||||
checkRAM(F("SaveSettings"));
|
||||
MD5Builder md5;
|
||||
uint8_t tmp_md5[16] = {0};
|
||||
memcpy( Settings.ProgmemMd5, CRCValues.runTimeMD5, 16);
|
||||
md5.begin();
|
||||
md5.add((uint8_t *)&Settings, sizeof(Settings)-16);
|
||||
md5.calculate();
|
||||
md5.getBytes(Settings.md5);
|
||||
|
||||
md5.getBytes(tmp_md5);
|
||||
String err;
|
||||
err=SaveToFile((char*)FILE_CONFIG, 0, (byte*)&Settings, sizeof(struct SettingsStruct));
|
||||
if (err.length())
|
||||
return(err);
|
||||
if (memcmp(tmp_md5, Settings.md5, 16) != 0) {
|
||||
// Settings have changed, save to file.
|
||||
memcpy(Settings.md5, tmp_md5, 16);
|
||||
err=SaveToFile((char*)FILE_CONFIG, 0, (byte*)&Settings, sizeof(struct SettingsStruct));
|
||||
if (err.length())
|
||||
return(err);
|
||||
}
|
||||
|
||||
memcpy( SecuritySettings.ProgmemMd5, CRCValues.runTimeMD5, 16);
|
||||
md5.begin();
|
||||
md5.add((uint8_t *)&SecuritySettings, sizeof(SecuritySettings)-16);
|
||||
md5.calculate();
|
||||
md5.getBytes(SecuritySettings.md5);
|
||||
err=SaveToFile((char*)FILE_SECURITY, 0, (byte*)&SecuritySettings, sizeof(struct SecurityStruct));
|
||||
|
||||
return (err);
|
||||
md5.getBytes(tmp_md5);
|
||||
if (memcmp(tmp_md5, SecuritySettings.md5, 16) != 0) {
|
||||
// Settings have changed, save to file.
|
||||
memcpy(SecuritySettings.md5, tmp_md5, 16);
|
||||
err=SaveToFile((char*)FILE_SECURITY, 0, (byte*)&SecuritySettings, sizeof(struct SecurityStruct));
|
||||
if (WifiIsAP(WiFi.getMode())) {
|
||||
// Security settings are saved, may be update of WiFi settings or hostname.
|
||||
wifiSetupConnect = true;
|
||||
}
|
||||
}
|
||||
return (err);
|
||||
}
|
||||
|
||||
/********************************************************************************************\
|
||||
@@ -1091,6 +1113,7 @@ void ResetFactory(void)
|
||||
Settings.Pin_status_led = -1;
|
||||
Settings.Pin_status_led_Inversed = true;
|
||||
Settings.Pin_sd_cs = -1;
|
||||
Settings.Pin_Reset = -1;
|
||||
Settings.Protocol[0] = DEFAULT_PROTOCOL;
|
||||
strcpy_P(Settings.Name, PSTR(DEFAULT_NAME));
|
||||
Settings.deepSleep = false;
|
||||
@@ -1163,7 +1186,8 @@ 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
|
||||
WiFi.disconnect(); // this will store empty ssid/wpa into sdk storage
|
||||
intent_to_reboot = true;
|
||||
WifiDisconnect(); // this will store empty ssid/wpa into sdk storage
|
||||
WiFi.persistent(false); // Do not use SDK storage of SSID/WPA parameters
|
||||
#if defined(ESP8266)
|
||||
ESP.reset();
|
||||
@@ -1308,6 +1332,8 @@ boolean loglevelActiveFor(byte destination, byte logLevel) {
|
||||
case LOG_TO_SERIAL: {
|
||||
if (!SerialAvailableForWrite()) return false;
|
||||
logLevelSettings = Settings.SerialLogLevel;
|
||||
if (wifiStatus != ESPEASY_WIFI_SERVICES_INITIALIZED)
|
||||
logLevelSettings = 2;
|
||||
break;
|
||||
}
|
||||
case LOG_TO_SYSLOG: {
|
||||
@@ -1336,6 +1362,8 @@ boolean loglevelActive(byte logLevel, byte logLevelSettings) {
|
||||
void addLog(byte logLevel, const char *line)
|
||||
{
|
||||
if (loglevelActiveFor(LOG_TO_SERIAL, logLevel)) {
|
||||
Serial.print(millis());
|
||||
Serial.print(F(" : "));
|
||||
Serial.println(line);
|
||||
}
|
||||
if (loglevelActiveFor(LOG_TO_SYSLOG, logLevel)) {
|
||||
@@ -1383,7 +1411,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"));
|
||||
@@ -1394,9 +1424,6 @@ boolean saveToRTC()
|
||||
return(true);
|
||||
}
|
||||
#endif
|
||||
#if defined(ESP32)
|
||||
boolean ret = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -1419,17 +1446,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
|
||||
}
|
||||
|
||||
@@ -1439,18 +1461,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;
|
||||
}
|
||||
|
||||
|
||||
@@ -1459,7 +1480,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);
|
||||
@@ -1472,11 +1495,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;
|
||||
}
|
||||
|
||||
|
||||
@@ -1513,87 +1533,104 @@ 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]);
|
||||
|
||||
if (valueFormat.length() > 0) //do the checks only if a Format is defined to optimize loop
|
||||
{
|
||||
const int val = value == "0" ? 0 : 1; //to be used for GPIO status (0 or 1)
|
||||
const float valFloat = value.toFloat();
|
||||
const int inverted = valueFormat.indexOf('!') >= 0 ? 1 : 0;
|
||||
|
||||
if (valueFormat.indexOf('O') >= 0)
|
||||
value = val == inverted ? "OFF" : " ON"; //(equivalent to XOR operator)
|
||||
else if (valueFormat.indexOf('C') >= 0)
|
||||
value = val == inverted ? "CLOSE" : " OPEN";
|
||||
else if (valueFormat.indexOf('U') >= 0)
|
||||
value = val == inverted ? "DOWN" : " UP";
|
||||
else if (valueFormat.indexOf('Y') >= 0)
|
||||
value = val == inverted ? " NO" : "YES";
|
||||
else if (valueFormat.indexOf('y') >= 0)
|
||||
value = val == inverted ? "N" : "Y";
|
||||
else if (valueFormat.indexOf('X') >= 0)
|
||||
value = val == inverted ? "O" : "X";
|
||||
else if (valueFormat.indexOf('I') >= 0)
|
||||
value = val == inverted ? "OUT" : " IN";
|
||||
else if (valueFormat.indexOf('Z') >= 0) // return "0" or "1"
|
||||
value = val == inverted ? "0" : "1";
|
||||
else if (valueFormat.indexOf('D') >= 0) // round to the nearest integer
|
||||
value = (int)roundf(valFloat);
|
||||
else if (valueFormat.indexOf('F') >= 0) // FLOOR (round down)
|
||||
value = (int)floorf(valFloat);
|
||||
else if (valueFormat.indexOf('E') >= 0) // CEILING (round up)
|
||||
value = (int)ceilf(valFloat);
|
||||
|
||||
if (valueFormat.indexOf('R') >= 0) {
|
||||
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++;
|
||||
@@ -1615,7 +1652,6 @@ String parseTemplate(String &tmpString, byte lineSize)
|
||||
return newString;
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************************************\
|
||||
Calculate function for simple expressions
|
||||
\*********************************************************************************************/
|
||||
@@ -1959,8 +1995,6 @@ String rulesProcessingFile(String fileName, String& event)
|
||||
Serial.println(fileName);
|
||||
Serial.println(F(" flags CMI parse output:"));
|
||||
}
|
||||
fs::File f = SPIFFS.open(fileName, "r+");
|
||||
SPIFFS_CHECK(f, fileName.c_str());
|
||||
|
||||
static byte nestingLevel = 0;
|
||||
int data = 0;
|
||||
@@ -1975,6 +2009,9 @@ String rulesProcessingFile(String fileName, String& event)
|
||||
return (log);
|
||||
}
|
||||
|
||||
fs::File f = SPIFFS.open(fileName, "r+");
|
||||
SPIFFS_CHECK(f, fileName.c_str());
|
||||
|
||||
String line = "";
|
||||
boolean match = false;
|
||||
boolean codeBlock = false;
|
||||
@@ -2013,7 +2050,7 @@ String rulesProcessingFile(String fileName, String& event)
|
||||
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
|
||||
|
||||
@@ -2060,9 +2097,9 @@ String rulesProcessingFile(String fileName, String& event)
|
||||
{
|
||||
isCommand = false;
|
||||
codeBlock = false;
|
||||
match = false;
|
||||
match = false;
|
||||
}
|
||||
|
||||
|
||||
if (Settings.SerialLogLevel == LOG_LEVEL_DEBUG_DEV){
|
||||
Serial.print(F("RuleDebug: "));
|
||||
Serial.print(codeBlock);
|
||||
@@ -2071,7 +2108,7 @@ String rulesProcessingFile(String fileName, String& event)
|
||||
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
|
||||
|
||||
+6
-8
@@ -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);
|
||||
@@ -596,12 +596,10 @@ bool WiFiConnected(uint32_t timeout_ms) {
|
||||
yield(); // Allow at least once time for backgroundtasks
|
||||
min_delay = 10;
|
||||
}
|
||||
if (!wifiConnected) {
|
||||
// Apparently something needs network, perform check to see if it is ready now.
|
||||
if (tryConnectWiFi())
|
||||
checkWifiJustConnected();
|
||||
}
|
||||
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;
|
||||
}
|
||||
@@ -624,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;
|
||||
}
|
||||
|
||||
+11
-2
@@ -54,6 +54,12 @@ void formatMAC(const uint8_t* mac, char (&strMAC)[20]) {
|
||||
sprintf_P(strMAC, PSTR("%02X:%02X:%02X:%02X:%02X:%02X"), mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
||||
}
|
||||
|
||||
String formatMAC(const uint8_t* mac) {
|
||||
char str[20];
|
||||
formatMAC(mac, str);
|
||||
return String(str);
|
||||
}
|
||||
|
||||
/*********************************************************************************************\
|
||||
Workaround for removing trailing white space when String() converts a float with 0 decimals
|
||||
\*********************************************************************************************/
|
||||
@@ -278,8 +284,10 @@ 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("%bssid%"), (wifiStatus == ESPEASY_WIFI_DISCONNECTED) ? F("00:00:00:00:00:00") : WiFi.BSSIDstr())
|
||||
SMART_REPL(F("%wi_ch%"), String((wifiStatus == ESPEASY_WIFI_DISCONNECTED) ? 0 : WiFi.channel()))
|
||||
SMART_REPL(F("%unit%"), String(Settings.Unit))
|
||||
SMART_REPL(F("%mac%"), String(WiFi.macAddress()))
|
||||
#if defined(ESP8266)
|
||||
@@ -311,6 +319,7 @@ void parseSystemVariables(String& s, boolean useURLencode)
|
||||
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) {
|
||||
|
||||
+26
-12
@@ -72,6 +72,7 @@ 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)
|
||||
@@ -83,6 +84,10 @@ void setTime(unsigned long t) {
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t getUnixTime() {
|
||||
return sysTime;
|
||||
}
|
||||
|
||||
unsigned long now() {
|
||||
// calculate number of seconds passed since last call to now()
|
||||
const long msec_passed = timePassedSince(prevMillis);
|
||||
@@ -94,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);
|
||||
@@ -197,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);
|
||||
@@ -217,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
|
||||
@@ -253,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);
|
||||
|
||||
+212
-131
@@ -348,6 +348,11 @@ boolean clientIPallowed()
|
||||
WiFiClient client(WebServer.client());
|
||||
if (ipInRange(client.remoteIP(), low, high))
|
||||
return true;
|
||||
|
||||
if (WifiIsAP(WiFi.getMode())) {
|
||||
// @TD-er Fixme: Should match subnet of SoftAP.
|
||||
return true;
|
||||
}
|
||||
String response = F("IP blocked: ");
|
||||
response += formatIP(client.remoteIP());
|
||||
WebServer.send(403, "text/html", response);
|
||||
@@ -390,10 +395,16 @@ static const char pgDefaultCSS[] PROGMEM = {
|
||||
".button.help {padding: 2px 4px; border: solid 1px #FFF; border-radius: 50%; }"
|
||||
".button:hover {background: #369; }"
|
||||
// tables
|
||||
"th {padding: 6px; background-color: #444; color: #FFF; border-color: #888; font-weight: bold; }"
|
||||
"td {padding: 4px; }"
|
||||
"tr {padding: 4px; }"
|
||||
"table {color: #000; width: 100%; min-width: 420px; }"
|
||||
"table.normal th {padding: 6px; background-color: #444; color: #FFF; border-color: #888; font-weight: bold; }"
|
||||
"table.normal td {padding: 4px; }"
|
||||
"table.normal tr {padding: 4px; }"
|
||||
"table.normal {color: #000; width: 100%; min-width: 420px; border-collapse: collapse; }"
|
||||
//every second row
|
||||
"table.multirow th {padding: 6px; background-color: #444; color: #FFF; border-color: #888; font-weight: bold; }"
|
||||
"table.multirow td {padding: 4px; text-align: center; }"
|
||||
"table.multirow tr {padding: 4px; }"
|
||||
"table.multirow tr:nth-child(even){background-color: #cfd6e4; }"
|
||||
"table.multirow {color: #000; width: 100%; min-width: 420px; border-collapse: collapse; }"
|
||||
// inside a form
|
||||
".note {color: #444; font-style: italic; }"
|
||||
//header with title and menu
|
||||
@@ -523,7 +534,8 @@ void getWebPageTemplateDefault(const String& tmplName, String& tmpl)
|
||||
"{{content}}"
|
||||
"</section>"
|
||||
"<footer>"
|
||||
"<h6>Powered by www.letscontrolit.com</h6>"
|
||||
"<br>"
|
||||
"<h6>Powered by <a href='http://www.letscontrolit.com' style='font-size: 15px; text-decoration: none'>www.letscontrolit.com</a></h6>"
|
||||
"</footer>"
|
||||
"</body>" );
|
||||
}
|
||||
@@ -548,7 +560,8 @@ void getWebPageTemplateDefault(const String& tmplName, String& tmpl)
|
||||
"{{content}}"
|
||||
"</section>"
|
||||
"<footer>"
|
||||
"<h6>Powered by www.letscontrolit.com</h6>"
|
||||
"<br>"
|
||||
"<h6>Powered by <a href='http://www.letscontrolit.com' style='font-size: 15px; text-decoration: none'>www.letscontrolit.com</a></h6>"
|
||||
"</footer>"
|
||||
"</body>"
|
||||
);
|
||||
@@ -577,7 +590,8 @@ void getWebPageTemplateDefault(const String& tmplName, String& tmpl)
|
||||
"{{content}}"
|
||||
"</section>"
|
||||
"<footer>"
|
||||
"<h6>Powered by www.letscontrolit.com</h6>"
|
||||
"<br>"
|
||||
"<h6>Powered by <a href='http://www.letscontrolit.com' style='font-size: 15px; text-decoration: none'>www.letscontrolit.com</a></h6>"
|
||||
"</footer>"
|
||||
"</body></html>"
|
||||
);
|
||||
@@ -809,12 +823,12 @@ void handle_root() {
|
||||
|
||||
TXBuffer += printWebString;
|
||||
TXBuffer += F("<form>");
|
||||
TXBuffer += F("<table><TR><TH>System Info<TH>Value<TH><TH>System Info<TH>Value<TH>");
|
||||
TXBuffer += F("<table class='normal'><TH style='width:150px;' align='left'>System Info<TH align='left'>Value");
|
||||
|
||||
TXBuffer += F("<TR><TD>Unit:<TD>");
|
||||
TXBuffer += String(Settings.Unit);
|
||||
|
||||
TXBuffer += F("<TD><TD>GIT version:<TD>");
|
||||
TXBuffer += F("<TR><TD>GIT version:<TD>");
|
||||
TXBuffer += BUILD_GIT;
|
||||
|
||||
TXBuffer += F("<TR><TD>Local Time:<TD>");
|
||||
@@ -823,9 +837,9 @@ void handle_root() {
|
||||
TXBuffer += getDateTimeString('-', ':', ' ');
|
||||
}
|
||||
else
|
||||
TXBuffer += F("NTP disabled");
|
||||
TXBuffer += F("<font color='red'>NTP disabled</font>");
|
||||
|
||||
TXBuffer += F("<TD><TD>Uptime:<TD>");
|
||||
TXBuffer += F("<TR><TD>Uptime:<TD>");
|
||||
char strUpTime[40];
|
||||
int minutes = wdcounter / 2;
|
||||
int days = minutes / 1440;
|
||||
@@ -844,7 +858,7 @@ void handle_root() {
|
||||
TXBuffer += F(")");
|
||||
}
|
||||
|
||||
TXBuffer += F("<TD><TD>Free Mem:<TD>");
|
||||
TXBuffer += F("<TR><TD>Free Mem:<TD>");
|
||||
TXBuffer += String(freeMem);
|
||||
TXBuffer += F(" (");
|
||||
TXBuffer += String(lowestRAM);
|
||||
@@ -855,8 +869,8 @@ void handle_root() {
|
||||
TXBuffer += F("<TR><TD>IP:<TD>");
|
||||
TXBuffer += formatIP(ip);
|
||||
|
||||
TXBuffer += F("<TD><TD>Wifi RSSI:<TD>");
|
||||
if (WiFi.status() == WL_CONNECTED)
|
||||
TXBuffer += F("<TR><TD>Wifi RSSI:<TD>");
|
||||
if (wifiStatus == ESPEASY_WIFI_SERVICES_INITIALIZED)
|
||||
{
|
||||
TXBuffer += String(WiFi.RSSI());
|
||||
TXBuffer += F(" dB");
|
||||
@@ -871,7 +885,7 @@ void handle_root() {
|
||||
#endif
|
||||
|
||||
|
||||
TXBuffer += F("<TR><TH>Node List:<TH>Name<TH>Build<TH>Type<TH>IP<TH>Age<TR><TD><TD>");
|
||||
TXBuffer += F("</table><BR><BR><table class='multirow'><TR><TH>Node List:<TH>Name<TH>Build<TH>Type<TH>IP<TH>Age");
|
||||
for (byte x = 0; x < UNIT_MAX; x++)
|
||||
{
|
||||
if (Nodes[x].ip[0] != 0)
|
||||
@@ -921,7 +935,6 @@ void handle_root() {
|
||||
printToWeb = false;
|
||||
sendHeadandTail(F("TmplStd"),_TAIL);
|
||||
TXBuffer.endStream();
|
||||
Serial.println("done.");
|
||||
|
||||
}
|
||||
else
|
||||
@@ -1049,7 +1062,7 @@ void handle_config() {
|
||||
addHtmlError( SaveSettings());
|
||||
}
|
||||
|
||||
TXBuffer += F("<form name='frmselect' method='post'><table>");
|
||||
TXBuffer += F("<form name='frmselect' method='post'><table class='normal'>");
|
||||
|
||||
addFormHeader(TXBuffer.buf, F("Main Settings"));
|
||||
|
||||
@@ -1100,14 +1113,14 @@ void handle_config() {
|
||||
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
|
||||
addFormNumericBox(TXBuffer.buf, F("Sleep time"), F("delay"), Settings.Delay, 0, 4294); //limited by hardware to ~1.2h
|
||||
addUnit(TXBuffer.buf, F("sec"));
|
||||
|
||||
addFormCheckBox( TXBuffer.buf, F("Sleep on connection failure"), F("deepsleeponfail"), Settings.deepSleepOnFail);
|
||||
|
||||
addFormSeparator( TXBuffer.buf);
|
||||
|
||||
TXBuffer += F("<TR><TD><TD>");
|
||||
TXBuffer += F("<TR><TD style='width:150px;' align='left'><TD>");
|
||||
addSubmitButton(TXBuffer.buf );
|
||||
TXBuffer += F("</table></form>");
|
||||
|
||||
@@ -1222,8 +1235,8 @@ void handle_controllers() {
|
||||
|
||||
if (controllerNotSet)
|
||||
{
|
||||
TXBuffer += F("<table border=1px frame='box' rules='all'><TR><TH>");
|
||||
TXBuffer += F("<TH>Nr<TH>Enabled<TH>Protocol<TH>Host<TH>Port");
|
||||
TXBuffer += F("<table class='multirow' border=1px frame='box' rules='all'><TR><TH style='width:70px;'>");
|
||||
TXBuffer += F("<TH style='width:50px;'>Nr<TH style='width:100px;'>Enabled<TH>Protocol<TH>Host<TH>Port");
|
||||
|
||||
ControllerSettingsStruct ControllerSettings;
|
||||
for (byte x = 0; x < CONTROLLER_MAX; x++)
|
||||
@@ -1258,7 +1271,7 @@ void handle_controllers() {
|
||||
}
|
||||
else
|
||||
{
|
||||
TXBuffer += F("<table><TR><TH>Controller Settings<TH>");
|
||||
TXBuffer += F("<table class='normal'><TR><TH style='width:150px;' align='left'>Controller Settings<TH>");
|
||||
TXBuffer += F("<TR><TD>Protocol:");
|
||||
byte choice = Settings.Protocol[controllerindex];
|
||||
TXBuffer += F("<TD>");
|
||||
@@ -1447,8 +1460,8 @@ void handle_notifications() {
|
||||
|
||||
if (notificationindexNotSet)
|
||||
{
|
||||
TXBuffer += F("<table border=1px frame='box' rules='all'><TR><TH>");
|
||||
TXBuffer += F("<TH>Nr<TH>Enabled<TH>Service<TH>Server<TH>Port");
|
||||
TXBuffer += F("<table class='multirow' border=1px frame='box' rules='all'><TR><TH style='width:70px;'>");
|
||||
TXBuffer += F("<TH style='width:50px;'>Nr<TH style='width:100px;'>Enabled<TH>Service<TH>Server<TH>Port");
|
||||
|
||||
NotificationSettingsStruct NotificationSettings;
|
||||
for (byte x = 0; x < NOTIFICATION_MAX; x++)
|
||||
@@ -1485,7 +1498,7 @@ void handle_notifications() {
|
||||
}
|
||||
else
|
||||
{
|
||||
TXBuffer += F("<table><TR><TH>Notification Settings<TH>");
|
||||
TXBuffer += F("<table class='normal'><TR><TH style='width:150px;' align='left'>Notification Settings<TH>");
|
||||
TXBuffer += F("<TR><TD>Notification:");
|
||||
byte choice = Settings.Notification[notificationindex];
|
||||
TXBuffer += F("<TD>");
|
||||
@@ -1592,11 +1605,11 @@ void handle_hardware() {
|
||||
navMenuIndex = 3;
|
||||
TXBuffer.startStream();
|
||||
sendHeadandTail(F("TmplStd"),_HEAD);
|
||||
|
||||
if (isFormItem(F("psda")))
|
||||
{
|
||||
Settings.Pin_status_led = getFormItemInt(F("pled"));
|
||||
Settings.Pin_status_led_Inversed = isFormItemChecked(F("pledi"));
|
||||
Settings.Pin_Reset = getFormItemInt(F("pres"));
|
||||
Settings.Pin_i2c_sda = getFormItemInt(F("psda"));
|
||||
Settings.Pin_i2c_scl = getFormItemInt(F("pscl"));
|
||||
Settings.InitSPI = isFormItemChecked(F("initspi")); // SPI Init
|
||||
@@ -1616,12 +1629,17 @@ void handle_hardware() {
|
||||
addHtmlError(TXBuffer.buf, SaveSettings());
|
||||
}
|
||||
|
||||
TXBuffer += F("<form method='post'><table><TR><TH>Hardware Settings<TH><TR><TD>");
|
||||
TXBuffer += F("<form method='post'><table class='normal'><TR><TH style='width:150px;' align='left'>Hardware Settings<TH><TR><TD>");
|
||||
|
||||
addFormSubHeader(TXBuffer.buf, F("Wifi Status LED"));
|
||||
addFormPinSelect( TXBuffer.buf,F("GPIO → LED"), "pled", Settings.Pin_status_led);
|
||||
addFormCheckBox(TXBuffer.buf, F("Inversed LED"), F("pledi"), Settings.Pin_status_led_Inversed);
|
||||
addFormNote(TXBuffer.buf, F("Use ’GPIO-2 (D4)’ with ’Inversed’ checked for onboard LED"));
|
||||
|
||||
addFormSubHeader(TXBuffer.buf, F("Reset Pin"));
|
||||
addFormPinSelect( TXBuffer.buf,F("GPIO ← Switch"), "pres", Settings.Pin_Reset);
|
||||
addFormNote(TXBuffer.buf, F("Press about 10s for factory reset"));
|
||||
|
||||
addFormSubHeader(TXBuffer.buf, F("I2C Interface"));
|
||||
addFormPinSelectI2C(TXBuffer.buf, F("GPIO ⇿ SDA"), F("psda"), Settings.Pin_i2c_sda);
|
||||
addFormPinSelectI2C(TXBuffer.buf, F("GPIO ⇾ SCL"), F("pscl"), Settings.Pin_i2c_scl);
|
||||
@@ -1906,7 +1924,7 @@ void handle_devices() {
|
||||
// show all tasks as table
|
||||
if (taskIndexNotSet)
|
||||
{
|
||||
TXBuffer += F("<table border=1px frame='box' rules='all'><TR><TH>");
|
||||
TXBuffer += F("<table class='multirow' border=1px frame='box' rules='all'><TR><TH style='width:70px;'>");
|
||||
|
||||
if (TASKS_MAX != TASKS_PER_PAGE)
|
||||
{
|
||||
@@ -1924,7 +1942,7 @@ void handle_devices() {
|
||||
TXBuffer += F("\">></a>");
|
||||
}
|
||||
|
||||
TXBuffer += F("<TH>Task<TH>Enabled<TH>Device<TH>Name<TH>Port<TH>Ctr (IDX)<TH>GPIO<TH>Values");
|
||||
TXBuffer += F("<TH style='width:50px;'>Task<TH style='width:100px;'>Enabled<TH>Device<TH>Name<TH>Port<TH style='width:50px;'>Ctr (IDX)<TH style='width:70px;'>GPIO<TH>Values");
|
||||
|
||||
String deviceName;
|
||||
|
||||
@@ -2062,11 +2080,11 @@ void handle_devices() {
|
||||
DeviceIndex = getDeviceIndex(Settings.TaskDeviceNumber[taskIndex]);
|
||||
TempEvent.TaskIndex = taskIndex;
|
||||
|
||||
TXBuffer += F("<form name='frmselect' method='post'><table>");
|
||||
TXBuffer += F("<form name='frmselect' method='post'><table class='normal'>");
|
||||
addFormHeader(TXBuffer.buf, F("Task Settings"));
|
||||
|
||||
|
||||
TXBuffer += F("<TR><TD>Device:<TD>");
|
||||
TXBuffer += F("<TR><TD style='width:150px;' align='left'>Device:<TD>");
|
||||
|
||||
//no device selected
|
||||
if (Settings.TaskDeviceNumber[taskIndex] == 0 )
|
||||
@@ -2166,7 +2184,7 @@ void handle_devices() {
|
||||
if (Device[DeviceIndex].TimerOption)
|
||||
{
|
||||
//FIXME: shoudn't the max be ULONG_MAX because Settings.TaskDeviceTimer is an unsigned long? addFormNumericBox only supports ints for min and max specification
|
||||
addFormNumericBox(TXBuffer.buf, F("Delay"), F("TDT"), Settings.TaskDeviceTimer[taskIndex], 0, 65535); //="taskdevicetimer"
|
||||
addFormNumericBox(TXBuffer.buf, F("Interval"), F("TDT"), Settings.TaskDeviceTimer[taskIndex], 0, 65535); //="taskdevicetimer"
|
||||
addUnit(TXBuffer.buf, F("sec"));
|
||||
if (Device[DeviceIndex].TimerOptional)
|
||||
TXBuffer += F(" (Optional for this Device)");
|
||||
@@ -2176,21 +2194,21 @@ void handle_devices() {
|
||||
if (!Device[DeviceIndex].Custom && Device[DeviceIndex].ValueCount > 0)
|
||||
{
|
||||
addFormSubHeader( TXBuffer.buf, F("Values"));
|
||||
TXBuffer += F("</table><table>");
|
||||
TXBuffer += F("</table><table class='normal'>");
|
||||
|
||||
//table header
|
||||
TXBuffer += F("<TR><TH>Value");
|
||||
TXBuffer += F("<TH>Name");
|
||||
TXBuffer += F("<TR><TH style='width:50px;' align='left'>Value");
|
||||
TXBuffer += F("<TH align='left'>Name");
|
||||
|
||||
if (Device[DeviceIndex].FormulaOption)
|
||||
{
|
||||
TXBuffer += F("<TH>Formula");
|
||||
TXBuffer += F("<TH align='left'>Formula");
|
||||
addHelpButton( TXBuffer.buf, F("EasyFormula"));
|
||||
}
|
||||
|
||||
if (Device[DeviceIndex].FormulaOption || Device[DeviceIndex].DecimalsOnly)
|
||||
{
|
||||
TXBuffer += F("<TH>Decimals");
|
||||
TXBuffer += F("<TH style='width:40px;' align='left'>Decimals");
|
||||
}
|
||||
|
||||
//table body
|
||||
@@ -2198,7 +2216,7 @@ void handle_devices() {
|
||||
{
|
||||
TXBuffer += F("<TR><TD>");
|
||||
TXBuffer += varNr + 1;
|
||||
TXBuffer += F("<TD>");
|
||||
TXBuffer += F("<TD style='width:100px;'>");
|
||||
String id = F("TDVN"); //="taskdevicevaluename"
|
||||
id += (varNr + 1);
|
||||
addTextBox( TXBuffer.buf, id, ExtraTaskSettings.TaskDeviceValueNames[varNr], 40);
|
||||
@@ -2213,7 +2231,7 @@ void handle_devices() {
|
||||
|
||||
if (Device[DeviceIndex].FormulaOption || Device[DeviceIndex].DecimalsOnly)
|
||||
{
|
||||
TXBuffer += F("<TD>");
|
||||
TXBuffer += F("<TD style='width:40px;'>");
|
||||
String id = F("TDVD"); //="taskdevicevaluedecimals"
|
||||
id += (varNr + 1);
|
||||
addNumericBox(TXBuffer.buf, id, ExtraTaskSettings.TaskDeviceValueDecimals[varNr], 0, 6);
|
||||
@@ -2224,7 +2242,7 @@ void handle_devices() {
|
||||
|
||||
addFormSeparator (TXBuffer.buf);
|
||||
|
||||
TXBuffer += F("<TR><TD><TD><a class='button link' href=\"devices?setpage=");
|
||||
TXBuffer += F("<TR><TD><TD colspan='3'><a class='button link' href=\"devices?setpage=");
|
||||
TXBuffer += page;
|
||||
TXBuffer += F("\">Close</a>");
|
||||
addSubmitButton (TXBuffer.buf);
|
||||
@@ -2973,7 +2991,7 @@ void handle_log() {
|
||||
sendHeadandTail(F("TmplStd"),_HEAD);
|
||||
|
||||
TXBuffer += F("<script>function RefreshMe(){window.location = window.location}setTimeout('RefreshMe()', 3000);</script>");
|
||||
TXBuffer += F("<table><TR><TH>Log<TR><TD>");
|
||||
TXBuffer += F("<table class='normal'><TR><TH style='width:150px;' align='left'>Log<TR><TD>");
|
||||
for (int i = 0; i< LOG_STRUCT_MESSAGE_LINES; i++){
|
||||
Logging.get(TXBuffer.buf, F("<BR>"),i);
|
||||
TXBuffer.checkFull();
|
||||
@@ -2998,18 +3016,18 @@ void handle_tools() {
|
||||
String webrequest = WebServer.arg(F("cmd"));
|
||||
|
||||
TXBuffer += F("<form>");
|
||||
TXBuffer += F("<table>");
|
||||
TXBuffer += F("<table class='normal'>");
|
||||
|
||||
addFormHeader(TXBuffer.buf, F("Tools"));
|
||||
|
||||
addFormSubHeader(TXBuffer.buf, F("Command"));
|
||||
TXBuffer += F("<TR><TD HEIGHT=\"30\">");
|
||||
TXBuffer += F("<TR><TD style='width: 180px'>");
|
||||
TXBuffer += F("<input type='text' name='cmd' value='");
|
||||
TXBuffer += webrequest;
|
||||
TXBuffer += F("'>");
|
||||
addHelpButton( TXBuffer.buf, F("ESPEasy_Command_Reference"));
|
||||
TXBuffer += F("<TD>");
|
||||
addSubmitButton(TXBuffer.buf );
|
||||
addHelpButton( TXBuffer.buf, F("ESPEasy_Command_Reference"));
|
||||
TXBuffer += F("<TR><TD>");
|
||||
|
||||
printToWeb = true;
|
||||
@@ -3100,11 +3118,6 @@ void handle_tools() {
|
||||
TXBuffer += F("<TD>");
|
||||
TXBuffer += F("Saves a settings file");
|
||||
|
||||
TXBuffer += F("<TR><TD HEIGHT=\"30\">");
|
||||
addButton(TXBuffer.buf, F("/?cmd=reset"), F("Factory Reset"));
|
||||
TXBuffer += F("<TD>");
|
||||
TXBuffer += F("Erase all settings files");
|
||||
|
||||
#if defined(ESP8266)
|
||||
if (ESP.getFlashChipRealSize() > 524288)
|
||||
{
|
||||
@@ -3124,6 +3137,11 @@ void handle_tools() {
|
||||
TXBuffer += F("<TD>");
|
||||
TXBuffer += F("Show files on internal flash");
|
||||
|
||||
TXBuffer += F("<TR><TD HEIGHT=\"30\">");
|
||||
addButton(TXBuffer.buf, F("/?cmd=reset"), F("Factory Reset"));
|
||||
TXBuffer += F("<TD>");
|
||||
TXBuffer += F("Erase all settings files");
|
||||
|
||||
#ifdef FEATURE_SD
|
||||
TXBuffer += F("<TR><TD HEIGHT=\"30\">");
|
||||
addButton(TXBuffer.buf, F("SDfilelist"), F("SD Card"));
|
||||
@@ -3155,7 +3173,7 @@ void handle_pinstates() {
|
||||
|
||||
//addFormSubHeader( F("Pin state table<TR>"));
|
||||
|
||||
TXBuffer += F("<table border=1px frame='box' rules='all'><TH>Plugin");
|
||||
TXBuffer += F("<table class='multirow' border=1px frame='box' rules='all'><TH>Plugin");
|
||||
addHelpButton(TXBuffer.buf, F("Official_plugin_list"));
|
||||
TXBuffer += F("<TH>GPIO<TH>Mode<TH>Value/State");
|
||||
for (byte x = 0; x < PINSTATE_TABLE_MAX; x++)
|
||||
@@ -3217,7 +3235,7 @@ void handle_i2cscanner() {
|
||||
|
||||
|
||||
|
||||
TXBuffer += F("<table border=1px frame='box' rules='all'><TH>I2C Addresses in use<TH>Supported devices");
|
||||
TXBuffer += F("<table class='multirow' border=1px frame='box' rules='all'><TH>I2C Addresses in use<TH>Supported devices");
|
||||
|
||||
byte error, address;
|
||||
int nDevices;
|
||||
@@ -3355,12 +3373,7 @@ void handle_wifiscanner() {
|
||||
navMenuIndex = 7;
|
||||
TXBuffer.startStream();
|
||||
sendHeadandTail(F("TmplStd"),_HEAD);
|
||||
|
||||
char *TempString = (char*)malloc(80);
|
||||
|
||||
|
||||
|
||||
TXBuffer += F("<table><TR><TH>Access Points:<TH>RSSI");
|
||||
TXBuffer += F("<table class='multirow'><TR><TH>SSID<TH>BSSID<TH>info");
|
||||
|
||||
int n = WiFi.scanNetworks();
|
||||
if (n == 0)
|
||||
@@ -3370,17 +3383,13 @@ void handle_wifiscanner() {
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
TXBuffer += F("<TR><TD>");
|
||||
TXBuffer += WiFi.SSID(i);
|
||||
TXBuffer += "<TD>";
|
||||
TXBuffer += WiFi.RSSI(i);
|
||||
TXBuffer += formatScanResult(i, "<TD>");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TXBuffer += F("</table>");
|
||||
sendHeadandTail(F("TmplStd"),_TAIL);
|
||||
TXBuffer.endStream();
|
||||
free(TempString);
|
||||
}
|
||||
|
||||
|
||||
@@ -3400,7 +3409,7 @@ void handle_login() {
|
||||
|
||||
|
||||
TXBuffer += F("<form method='post'>");
|
||||
TXBuffer += F("<table><TR><TD>Password<TD>");
|
||||
TXBuffer += F("<table class='normal'><TR><TD>Password<TD>");
|
||||
TXBuffer += F("<input type='password' name='password' value='");
|
||||
TXBuffer += webrequest;
|
||||
TXBuffer += F("'><TR><TD><TD>");
|
||||
@@ -3503,11 +3512,22 @@ void handle_json()
|
||||
reply += F(",\n");
|
||||
reply += to_json_object_value(F("Uptime"), String(wdcounter / 2));
|
||||
reply += F(",\n");
|
||||
|
||||
if (wdcounter > 0)
|
||||
{
|
||||
reply += to_json_object_value(F("Load"), String( 100 - (100 * loopCounterLast / loopCounterMax) ));
|
||||
reply += F(",\n");
|
||||
reply += to_json_object_value(F("Load LC"), String( int(loopCounterLast / 30) ));
|
||||
reply += F(",\n");
|
||||
}
|
||||
|
||||
reply += to_json_object_value(F("Free RAM"), String(ESP.getFreeHeap()));
|
||||
reply += F("\n},\n");
|
||||
|
||||
reply += F("\"WiFi\":{\n");
|
||||
reply += to_json_object_value(F("Hostname"), WiFi.hostname());
|
||||
#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");
|
||||
@@ -3525,6 +3545,14 @@ void handle_json()
|
||||
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");
|
||||
}
|
||||
@@ -3542,42 +3570,45 @@ void handle_json()
|
||||
if (Settings.TaskDeviceNumber[TaskIndex])
|
||||
lastActiveTaskIndex = TaskIndex;
|
||||
|
||||
if (taskNr == 0 )
|
||||
reply += F("\"Sensors\":[\n");
|
||||
for (byte TaskIndex = firstTaskIndex; TaskIndex <= lastTaskIndex; TaskIndex++)
|
||||
{
|
||||
if (Settings.TaskDeviceNumber[TaskIndex])
|
||||
{
|
||||
byte BaseVarIndex = TaskIndex * VARS_PER_TASK;
|
||||
byte DeviceIndex = getDeviceIndex(Settings.TaskDeviceNumber[TaskIndex]);
|
||||
LoadTaskSettings(TaskIndex);
|
||||
reply += F("{\n");
|
||||
|
||||
reply += to_json_object_value(F("tasknr"), String(TaskIndex + 1));
|
||||
reply += F(",\n");
|
||||
reply += to_json_object_value(F("TaskName"), String(ExtraTaskSettings.TaskDeviceName));
|
||||
reply += F(",\n");
|
||||
reply += to_json_object_value(F("Type"), getPluginNameFromDeviceIndex(DeviceIndex));
|
||||
if (Device[DeviceIndex].ValueCount != 0)
|
||||
reply += F(",");
|
||||
reply += F("\n");
|
||||
|
||||
for (byte x = 0; x < Device[DeviceIndex].ValueCount; x++)
|
||||
if (taskNr == 0 )
|
||||
reply += F("\"Sensors\":[\n");
|
||||
for (byte TaskIndex = firstTaskIndex; TaskIndex <= lastTaskIndex; TaskIndex++)
|
||||
{
|
||||
reply += to_json_object_value(ExtraTaskSettings.TaskDeviceValueNames[x],
|
||||
toString(UserVar[BaseVarIndex + x], ExtraTaskSettings.TaskDeviceValueDecimals[x]));
|
||||
if (x < (Device[DeviceIndex].ValueCount - 1))
|
||||
reply += F(",");
|
||||
reply += F("\n");
|
||||
if (Settings.TaskDeviceNumber[TaskIndex])
|
||||
{
|
||||
byte BaseVarIndex = TaskIndex * VARS_PER_TASK;
|
||||
byte DeviceIndex = getDeviceIndex(Settings.TaskDeviceNumber[TaskIndex]);
|
||||
LoadTaskSettings(TaskIndex);
|
||||
reply += F("{\n");
|
||||
|
||||
reply += to_json_object_value(F("TaskNumber"), String(TaskIndex + 1));
|
||||
reply += F(",\n");
|
||||
reply += to_json_object_value(F("Type"), getPluginNameFromDeviceIndex(DeviceIndex));
|
||||
reply += F(",\n");
|
||||
reply += to_json_object_value(F("TaskName"), String(ExtraTaskSettings.TaskDeviceName));
|
||||
if (Device[DeviceIndex].ValueCount != 0)
|
||||
reply += F(",\n");
|
||||
reply += F("\"TaskValues\": [\n");
|
||||
|
||||
for (byte x = 0; x < Device[DeviceIndex].ValueCount; x++)
|
||||
{
|
||||
reply += F("{");
|
||||
reply += to_json_object_value(F("ValueNumber"), String(x + 1));
|
||||
reply += F(",\n");
|
||||
reply += to_json_object_value(F("Name"), String(ExtraTaskSettings.TaskDeviceValueNames[x]));
|
||||
reply += F(",\n");
|
||||
reply += to_json_object_value(F("Value"), toString(UserVar[BaseVarIndex + x], ExtraTaskSettings.TaskDeviceValueDecimals[x]));
|
||||
if (x < (Device[DeviceIndex].ValueCount - 1))
|
||||
reply += F("},\n");
|
||||
}
|
||||
reply += F("}]\n}");
|
||||
if (TaskIndex != lastActiveTaskIndex)
|
||||
reply += F(",");
|
||||
reply += F("\n");
|
||||
}
|
||||
}
|
||||
reply += F("}");
|
||||
if (TaskIndex != lastActiveTaskIndex)
|
||||
reply += F(",");
|
||||
reply += F("\n");
|
||||
}
|
||||
}
|
||||
if (taskNr == 0 )
|
||||
reply += F("]}\n");
|
||||
if (taskNr == 0 )
|
||||
reply += F("]\n}");
|
||||
|
||||
WebServer.send(200, "application/json", reply);
|
||||
}
|
||||
@@ -3624,7 +3655,7 @@ void handle_advanced() {
|
||||
String cft = WebServer.arg(F("cft"));
|
||||
String MQTTRetainFlag = WebServer.arg(F("mqttretainflag"));
|
||||
String ArduinoOTAEnable = WebServer.arg(F("arduinootaenable"));
|
||||
|
||||
String UseRTOSMultitasking = WebServer.arg(F("usertosmultitasking"));
|
||||
|
||||
|
||||
if (edit.length() != 0)
|
||||
@@ -3656,6 +3687,7 @@ void handle_advanced() {
|
||||
Settings.ConnectionFailuresThreshold = cft.toInt();
|
||||
Settings.MQTTRetainFlag = (MQTTRetainFlag == "on");
|
||||
Settings.ArduinoOTAEnable = (ArduinoOTAEnable == "on");
|
||||
Settings.UseRTOSMultitasking = (UseRTOSMultitasking == "on");
|
||||
|
||||
addHtmlError( TXBuffer.buf, SaveSettings());
|
||||
if (Settings.UseNTP)
|
||||
@@ -3664,7 +3696,7 @@ void handle_advanced() {
|
||||
|
||||
// char str[20];
|
||||
|
||||
TXBuffer += F("<form method='post'><table>");
|
||||
TXBuffer += F("<form method='post'><table class='normal'>");
|
||||
|
||||
addFormHeader(TXBuffer.buf, F("Advanced Settings"));
|
||||
|
||||
@@ -3673,7 +3705,7 @@ void handle_advanced() {
|
||||
addFormSubHeader(TXBuffer.buf, F("Controller Settings"));
|
||||
|
||||
addFormCheckBox(TXBuffer.buf, F("MQTT Retain Msg"), F("mqttretainflag"), Settings.MQTTRetainFlag);
|
||||
addFormNumericBox(TXBuffer.buf, F("Message Delay"), F("messagedelay"), Settings.MessageDelay, 0, INT_MAX);
|
||||
addFormNumericBox(TXBuffer.buf, F("Message Interval"), F("messagedelay"), Settings.MessageDelay, 0, INT_MAX);
|
||||
addUnit(TXBuffer.buf, F("ms"));
|
||||
|
||||
addFormSubHeader(TXBuffer.buf, F("NTP Settings"));
|
||||
@@ -3729,9 +3761,13 @@ void handle_advanced() {
|
||||
|
||||
addFormCheckBox(TXBuffer.buf, F("Enable Arduino OTA"), F("arduinootaenable"), Settings.ArduinoOTAEnable);
|
||||
|
||||
#if defined(ESP32)
|
||||
addFormCheckBox(TXBuffer.buf, F("Enable RTOS Multitasking"), F("usertosmultitasking"), Settings.UseRTOSMultitasking);
|
||||
#endif
|
||||
|
||||
addFormSeparator (TXBuffer.buf);
|
||||
|
||||
TXBuffer += F("<TR><TD><TD>");
|
||||
TXBuffer += F("<TR><TD style='width:150px;' align='left'>");
|
||||
addSubmitButton (TXBuffer.buf);
|
||||
TXBuffer += F("<input type='hidden' name='edit' value='1'>");
|
||||
TXBuffer += F("</table></form>");
|
||||
@@ -4138,7 +4174,7 @@ boolean handle_custom(String path) {
|
||||
{
|
||||
// if the custom page does not exist, create a basic task value overview page in case of dashboard request...
|
||||
reply += F("<meta name=\"viewport\" content=\"width=width=device-width, initial-scale=1\"><STYLE>* {font-family:sans-serif; font-size:16pt;}.button {margin:4px; padding:4px 16px; background-color:#07D; color:#FFF; text-decoration:none; border-radius:4px}</STYLE>");
|
||||
reply += F("<table>");
|
||||
reply += F("<table class='normal'>");
|
||||
for (byte x = 0; x < TASKS_MAX; x++)
|
||||
{
|
||||
if (Settings.TaskDeviceNumber[x] != 0)
|
||||
@@ -4193,7 +4229,7 @@ void handle_filelist() {
|
||||
|
||||
|
||||
|
||||
TXBuffer += F("<table border=1px frame='box' rules='all'><TH><TH>Filename:<TH>Size");
|
||||
TXBuffer += F("<table class='multirow' border=1px frame='box' rules='all'><TH style='width:50px;'><TH>Filename:<TH style='width:80px;'>Size");
|
||||
|
||||
fs::Dir dir = SPIFFS.openDir("");
|
||||
while (dir.next())
|
||||
@@ -4231,7 +4267,7 @@ void handle_filelist() {
|
||||
|
||||
|
||||
|
||||
TXBuffer += F("<table border=1px frame='box' rules='all'><TH><TH>Filename:<TH>Size");
|
||||
TXBuffer += F("<table class='normal' border=1px frame='box' rules='all'><TH><TH>Filename:<TH>Size");
|
||||
|
||||
File root = SPIFFS.open("/");
|
||||
File file = root.openNextFile();
|
||||
@@ -4239,7 +4275,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();
|
||||
@@ -4257,7 +4293,7 @@ void handle_filelist() {
|
||||
}
|
||||
}
|
||||
TXBuffer += F("</table></form>");
|
||||
TXBuffer += F("<BR><a class='button link' href=\"/upload\">Upload</a>");
|
||||
TXBuffer += F("<BR><a class='button link' href=\"/upload\">Upload</a><BR><BR>");
|
||||
sendHeadandTail(F("TmplStd"),true);
|
||||
TXBuffer.endStream();
|
||||
#endif
|
||||
@@ -4338,7 +4374,7 @@ void handle_SDfilelist() {
|
||||
String subheader = "SD Card: " + current_dir;
|
||||
addFormSubHeader( subheader,TXBuffer.buf);
|
||||
TXBuffer += F("<BR>");
|
||||
TXBuffer += F("<table border=1px frame='box' rules='all'><TH>Action<TH>Name<TH>Size");
|
||||
TXBuffer += F("<table class='multirow' border=1px frame='box' rules='all'><TH style='width:50px;'>Action<TH>Name<TH>Size");
|
||||
TXBuffer += F("<TR><TD>");
|
||||
TXBuffer += F("<TD><a href=\"SDfilelist?chgto=");
|
||||
TXBuffer += parent_dir;
|
||||
@@ -4451,7 +4487,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();
|
||||
@@ -4467,8 +4503,7 @@ void handle_setup() {
|
||||
sendHeadandTail(F("TmplAP"),true);
|
||||
TXBuffer.endStream();
|
||||
|
||||
wifiSetup = false;
|
||||
//WifiAPMode(false); //this forces the iPhone to exit safari and this page was never displayed
|
||||
//setWifiMode(WIFI_STA); //this forces the iPhone to exit safari and this page was never displayed
|
||||
timerAPoff = millis() + 60000L; //switch the AP off in 1 minute
|
||||
return;
|
||||
}
|
||||
@@ -4486,11 +4521,15 @@ void handle_setup() {
|
||||
}
|
||||
|
||||
// if ssid config not set and params are both provided
|
||||
if (status == 0 && ssid.length() != 0 && strcasecmp(SecuritySettings.WifiSSID, "ssid") == 0)
|
||||
if (status == 0 && ssid.length() != 0 /*&& strcasecmp(SecuritySettings.WifiSSID, "ssid") == 0 */)
|
||||
{
|
||||
strncpy(SecuritySettings.WifiKey, password.c_str(), sizeof(SecuritySettings.WifiKey));
|
||||
strncpy(SecuritySettings.WifiSSID, ssid.c_str(), sizeof(SecuritySettings.WifiSSID));
|
||||
wifiSetupConnect = true;
|
||||
setWifiState(WifiCredentialsChanged);
|
||||
String reconnectlog = F("WIFI : Credentials Changed, retry connection. SSID: ");
|
||||
reconnectlog += ssid;
|
||||
addLog(LOG_LEVEL_INFO, reconnectlog);
|
||||
status = 1;
|
||||
refreshCount = 0;
|
||||
}
|
||||
@@ -4500,24 +4539,28 @@ void handle_setup() {
|
||||
|
||||
if (status == 0) // first step, scan and show access points within reach...
|
||||
{
|
||||
WiFiMode_t cur_wifimode = WiFi.getMode();
|
||||
if (n == 0)
|
||||
n = WiFi.scanNetworks();
|
||||
|
||||
setWifiMode(cur_wifimode);
|
||||
if (n == 0)
|
||||
TXBuffer += F("No Access Points found");
|
||||
else
|
||||
{
|
||||
TXBuffer += F("<table class='multirow'><TR><TH>SSID<TH>BSSID<TH>info");
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
TXBuffer += F("<TR><TD>");
|
||||
TXBuffer += F("<input type='radio' name='ssid' value='");
|
||||
TXBuffer += WiFi.SSID(i);
|
||||
TXBuffer += F("'");
|
||||
if (WiFi.SSID(i) == ssid)
|
||||
TXBuffer += F(" checked ");
|
||||
TXBuffer += F(">");
|
||||
TXBuffer += WiFi.SSID(i);
|
||||
TXBuffer += formatScanResult(i, "<TD>");
|
||||
TXBuffer += F("</input><br>");
|
||||
}
|
||||
TXBuffer += F("</table>");
|
||||
}
|
||||
|
||||
TXBuffer += F("<input type='radio' name='ssid' id='other_ssid' value='other' >other SSID:</input>");
|
||||
@@ -4536,8 +4579,8 @@ void handle_setup() {
|
||||
if (refreshCount > 0)
|
||||
{
|
||||
status = 0;
|
||||
strncpy(SecuritySettings.WifiSSID, "ssid", sizeof(SecuritySettings.WifiSSID));
|
||||
SecuritySettings.WifiKey[0] = 0;
|
||||
// strncpy(SecuritySettings.WifiSSID, "ssid", sizeof(SecuritySettings.WifiSSID));
|
||||
// SecuritySettings.WifiKey[0] = 0;
|
||||
TXBuffer += F("<a class=\"button\" href=\"setup\">Back to Setup</a>");
|
||||
}
|
||||
else
|
||||
@@ -4648,7 +4691,7 @@ void handle_rules() {
|
||||
if (rulesSet != currentSet)
|
||||
currentSet = rulesSet;
|
||||
|
||||
TXBuffer += F("<form name = 'frmselect' method = 'post'><table><TR><TH>Rules");
|
||||
TXBuffer += F("<form name = 'frmselect' method = 'post'><table class='normal'><TR><TH align='left'>Rules");
|
||||
|
||||
byte choice = rulesSet;
|
||||
String options[RULESETS_MAX];
|
||||
@@ -4720,7 +4763,7 @@ void handle_sysinfo() {
|
||||
addHeader(true, TXBuffer.buf);
|
||||
TXBuffer += printWebString;
|
||||
TXBuffer += F("<form>");
|
||||
TXBuffer += F("<table><TR><TH width=120>System Info<TH>");
|
||||
TXBuffer += F("<table class='normal'><TR><TH style='width:150px;' align='left'>System Info<TH>");
|
||||
|
||||
TXBuffer += F("<TR><TD>Unit<TD>");
|
||||
TXBuffer += Settings.Unit;
|
||||
@@ -4781,7 +4824,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)
|
||||
@@ -4816,14 +4859,18 @@ 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>DNS<TD>");
|
||||
TXBuffer += formatIP(WiFi.dnsIP(0));
|
||||
TXBuffer += F(" / ");
|
||||
TXBuffer += formatIP(WiFi.dnsIP(1));
|
||||
|
||||
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());
|
||||
@@ -4841,19 +4888,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();
|
||||
@@ -4909,6 +4971,25 @@ void handle_sysinfo() {
|
||||
TXBuffer += ESP.getCpuFreqMHz();
|
||||
TXBuffer += F(" MHz");
|
||||
#endif
|
||||
#if defined(ESP32)
|
||||
TXBuffer += F(" (0x");
|
||||
uint64_t chipid=ESP.getEfuseMac(); //The chip ID is essentially its MAC address(length: 6 bytes).
|
||||
uint32_t ChipId1 = (uint16_t)(chipid>>32);
|
||||
String espChipIdS(ChipId1, HEX);
|
||||
espChipIdS.toUpperCase();
|
||||
TXBuffer += espChipIdS;
|
||||
ChipId1 = (uint32_t)chipid;
|
||||
String espChipIdS1(ChipId1, HEX);
|
||||
espChipIdS1.toUpperCase();
|
||||
TXBuffer += espChipIdS1;
|
||||
TXBuffer += F(")");
|
||||
|
||||
TXBuffer += F("<TR><TD>ESP Chip Freq:<TD>");
|
||||
TXBuffer += ESP.getCpuFreqMHz();
|
||||
TXBuffer += F(" MHz");
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
TXBuffer += F("<TR><TD colspan=2><H3>Storage</H3></TD></TR>");
|
||||
|
||||
|
||||
-475
@@ -1,475 +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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//********************************************************************************
|
||||
// Set Wifi config
|
||||
//********************************************************************************
|
||||
void prepareWiFi() {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
//********************************************************************************
|
||||
// Configure network and connect to Wifi SSID and SSID2
|
||||
//********************************************************************************
|
||||
boolean WifiConnect(byte connectAttempts)
|
||||
{
|
||||
prepareWiFi();
|
||||
if (anyValidWifiSettings()) {
|
||||
//try to connect to one of the access points
|
||||
bool connected = WifiConnectAndWait(connectAttempts);
|
||||
if (!connected) {
|
||||
if (selectNextWiFiSettings()) {
|
||||
connected = WifiConnectAndWait(connectAttempts);
|
||||
}
|
||||
}
|
||||
if (connected) {
|
||||
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);
|
||||
}
|
||||
|
||||
//********************************************************************************
|
||||
// Start connect to WiFi and check later to see if connected.
|
||||
//********************************************************************************
|
||||
void WiFiConnectRelaxed() {
|
||||
prepareWiFi();
|
||||
wifiConnected = false;
|
||||
wifi_connect_attempt = 0;
|
||||
if (anyValidWifiSettings()) {
|
||||
tryConnectWiFi();
|
||||
return;
|
||||
}
|
||||
addLog(LOG_LEVEL_ERROR, F("WIFI : Could not connect to AP, no valid WiFi settings!"));
|
||||
//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 anyValidWifiSettings() {
|
||||
if (wifiSettingsValid(SecuritySettings.WifiSSID, SecuritySettings.WifiKey))
|
||||
return true;
|
||||
if (wifiSettingsValid(SecuritySettings.WifiSSID2, SecuritySettings.WifiKey2))
|
||||
return true;
|
||||
addLog(LOG_LEVEL_ERROR, F("WIFI : No valid WiFi settings!"));
|
||||
return false;
|
||||
}
|
||||
|
||||
bool selectNextWiFiSettings() {
|
||||
lastWiFiSettings = (lastWiFiSettings + 1) % 2;
|
||||
if (!wifiSettingsValid(getLastWiFiSettingsSSID(), getLastWiFiSettingsPassphrase())) {
|
||||
// other settings are not correct, switch back.
|
||||
lastWiFiSettings = (lastWiFiSettings + 1) % 2;
|
||||
return false; // Nothing changed.
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wifiSettingsValid(const char* ssid, const char* pass) {
|
||||
if (ssid[0] == 0 || (strcasecmp(ssid, "ssid") == 0)) {
|
||||
return false;
|
||||
}
|
||||
if (pass[0] == 0) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wifiConnectTimeoutReached() {
|
||||
if (wifi_connect_attempt == 0) return true;
|
||||
// wait until it connects + add some device specific random offset to prevent
|
||||
// all nodes overloading the accesspoint when turning on at the same time.
|
||||
const unsigned int randomOffset_in_sec = wifi_connect_attempt == 1 ? 0 : 1000 * ((ESP.getChipId() & 0xF));
|
||||
return timeOutReached(wifi_connect_timer + 7000 + randomOffset_in_sec);
|
||||
}
|
||||
|
||||
//********************************************************************************
|
||||
// Simply start the WiFi connection sequence
|
||||
//********************************************************************************
|
||||
bool tryConnectWiFi() {
|
||||
if (wifiSetup && !wifiSetupConnect)
|
||||
return false;
|
||||
if (WiFi.status() == WL_CONNECTED)
|
||||
return(true); //already connected, need to disconnect first
|
||||
if (!wifiConnectTimeoutReached())
|
||||
return true; // timeout not reached yet, thus no need to retry again.
|
||||
|
||||
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);
|
||||
|
||||
wifi_connect_timer = 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;
|
||||
}
|
||||
case WL_CONNECTED:
|
||||
checkWifiJustConnected();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return true; // Sent
|
||||
}
|
||||
|
||||
//********************************************************************************
|
||||
// Connect to Wifi specific SSID
|
||||
//********************************************************************************
|
||||
boolean WifiConnectAndWait(byte connectAttempts)
|
||||
{
|
||||
String log;
|
||||
|
||||
wifiConnected = false;
|
||||
wifi_connect_attempt = 0;
|
||||
for (byte tryConnect = 0; tryConnect < connectAttempts; tryConnect++)
|
||||
{
|
||||
if (tryConnectWiFi()) {
|
||||
do {
|
||||
if (checkWifiJustConnected())
|
||||
return true;
|
||||
delay(50);
|
||||
} while (!wifiConnectTimeoutReached());
|
||||
}
|
||||
// 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;
|
||||
}
|
||||
|
||||
bool checkWifiJustConnected() {
|
||||
if (wifiConnected) return true;
|
||||
if (WiFi.status() != WL_CONNECTED) {
|
||||
statusLED(false);
|
||||
delay(1);
|
||||
return false;
|
||||
}
|
||||
wifiConnected = true;
|
||||
String log = F("WIFI : WiFi connect attempt took: ");
|
||||
log += timePassedSince(wifi_connect_timer);
|
||||
log += F(" ms");
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
|
||||
// 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
|
||||
|
||||
// First try to get the time, since that may be used in logs
|
||||
if (Settings.UseNTP) {
|
||||
initTime();
|
||||
}
|
||||
uint8_t* curBSSID = WiFi.BSSID();
|
||||
bool changed = false;
|
||||
for (byte i=0; i < 6; ++i) {
|
||||
if (lastBSSID[i] != *(curBSSID + i)) {
|
||||
changed = true;
|
||||
lastBSSID[i] = *(curBSSID + i);
|
||||
}
|
||||
}
|
||||
if (Settings.UseRules)
|
||||
{
|
||||
if (changed) {
|
||||
String event = F("WiFi#ChangedAccesspoint");
|
||||
rulesProcessing(event);
|
||||
}
|
||||
String event = F("WiFi#Connected");
|
||||
rulesProcessing(event);
|
||||
}
|
||||
log = F("WIFI : Connected! IP: ");
|
||||
log += formatIP(WiFi.localIP());
|
||||
log += F(" (");
|
||||
log += WifiGetHostname();
|
||||
log += F(") AP: ");
|
||||
log += WiFi.SSID();
|
||||
log += F(" AP BSSID: ");
|
||||
log += WiFi.BSSIDstr();
|
||||
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
statusLED(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
//********************************************************************************
|
||||
// Disconnect from Wifi AP
|
||||
//********************************************************************************
|
||||
void WifiDisconnect()
|
||||
{
|
||||
WiFi.disconnect();
|
||||
wifiConnected = false;
|
||||
}
|
||||
|
||||
|
||||
//********************************************************************************
|
||||
// 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)
|
||||
{
|
||||
if (wifiConnected) {
|
||||
wifi_connect_attempt = 0;
|
||||
wifiConnected = false;
|
||||
WiFiConnectRelaxed();
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
if (!wifiConnected) {
|
||||
if (tryConnectWiFi())
|
||||
checkWifiJustConnected();
|
||||
}
|
||||
}
|
||||
|
||||
//********************************************************************************
|
||||
// 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;
|
||||
}
|
||||
+1
-1
@@ -87,7 +87,7 @@ 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((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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 ###########################
|
||||
// #######################################################################################################
|
||||
@@ -250,7 +251,7 @@ boolean Plugin_004_DS_readTemp(uint8_t ROM[8], float * value)
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((ROM[0] == 0x28 ) || (ROM[0] == 0x3b)) // DS18B20 or DS1825
|
||||
if ((ROM[0] == 0x28 ) || (ROM[0] == 0x3b) || (ROM[0] == 0x22)) // DS18B20 or DS1825 or DS1822
|
||||
{
|
||||
DSTemp = (ScratchPad[1] << 8) + ScratchPad[0];
|
||||
*value = (float(DSTemp) * 0.0625);
|
||||
@@ -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
|
||||
|
||||
+24
-5
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P015
|
||||
//#######################################################################################################
|
||||
//######################## Plugin 015 TSL2561 I2C Lux Sensor ############################################
|
||||
//#######################################################################################################
|
||||
@@ -11,6 +12,8 @@
|
||||
#define PLUGIN_ID_015 15
|
||||
#define PLUGIN_NAME_015 "Light/Lux - TSL2561"
|
||||
#define PLUGIN_VALUENAME1_015 "Lux"
|
||||
#define PLUGIN_VALUENAME2_015 "Infrared"
|
||||
#define PLUGIN_VALUENAME3_015 "Broadband"
|
||||
|
||||
boolean Plugin_015_init = false;
|
||||
|
||||
@@ -218,7 +221,7 @@ boolean plugin_015_getData(unsigned int &data0, unsigned int &data1)
|
||||
}
|
||||
|
||||
|
||||
boolean plugin_015_getLux(unsigned char gain, unsigned int ms, unsigned int CH0, unsigned int CH1, double &lux)
|
||||
boolean plugin_015_getLux(unsigned char gain, unsigned int ms, unsigned int CH0, unsigned int CH1, double &lux, double &infrared, double &broadband)
|
||||
// Convert raw data to lux
|
||||
// gain: 0 (1X) or 1 (16X), see setTiming()
|
||||
// ms: integration time in ms, from setTiming() or from manual integration
|
||||
@@ -245,6 +248,10 @@ boolean plugin_015_getLux(unsigned char gain, unsigned int ms, unsigned int CH0,
|
||||
// We will need the ratio for subsequent calculations
|
||||
ratio = d1 / d0;
|
||||
|
||||
// save original values
|
||||
infrared = d1;
|
||||
broadband = d0;
|
||||
|
||||
// Normalize for integration time
|
||||
d0 *= (402.0/ms);
|
||||
d1 *= (402.0/ms);
|
||||
@@ -289,7 +296,6 @@ boolean plugin_015_getLux(unsigned char gain, unsigned int ms, unsigned int CH0,
|
||||
}
|
||||
|
||||
|
||||
|
||||
boolean Plugin_015(byte function, struct EventStruct *event, String& string)
|
||||
{
|
||||
boolean success = false;
|
||||
@@ -300,12 +306,12 @@ boolean Plugin_015(byte function, struct EventStruct *event, String& string)
|
||||
{
|
||||
Device[++deviceCount].Number = PLUGIN_ID_015;
|
||||
Device[deviceCount].Type = DEVICE_TYPE_I2C;
|
||||
Device[deviceCount].VType = SENSOR_TYPE_SINGLE;
|
||||
Device[deviceCount].VType = SENSOR_TYPE_TRIPLE;
|
||||
Device[deviceCount].Ports = 0;
|
||||
Device[deviceCount].PullUpOption = false;
|
||||
Device[deviceCount].InverseLogicOption = false;
|
||||
Device[deviceCount].FormulaOption = true;
|
||||
Device[deviceCount].ValueCount = 1;
|
||||
Device[deviceCount].ValueCount = 3;
|
||||
Device[deviceCount].SendDataOption = true;
|
||||
Device[deviceCount].TimerOption = true;
|
||||
Device[deviceCount].GlobalSyncOption = true;
|
||||
@@ -321,6 +327,9 @@ boolean Plugin_015(byte function, struct EventStruct *event, String& string)
|
||||
case PLUGIN_GET_DEVICEVALUENAMES:
|
||||
{
|
||||
strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[0], PSTR(PLUGIN_VALUENAME1_015));
|
||||
strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[1], PSTR(PLUGIN_VALUENAME2_015));
|
||||
strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[2], PSTR(PLUGIN_VALUENAME3_015));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -402,12 +411,17 @@ boolean Plugin_015(byte function, struct EventStruct *event, String& string)
|
||||
{
|
||||
|
||||
double lux; // Resulting lux value
|
||||
double infrared; // Resulting infrared value
|
||||
double broadband; // Resulting broadband value
|
||||
boolean good; // True if neither sensor is saturated
|
||||
|
||||
// Perform lux calculation:
|
||||
|
||||
good = plugin_015_getLux(gain,ms,data0,data1,lux);
|
||||
good = plugin_015_getLux(gain,ms,data0,data1,lux, infrared, broadband);
|
||||
UserVar[event->BaseVarIndex] = lux;
|
||||
UserVar[event->BaseVarIndex + 1] = infrared;
|
||||
UserVar[event->BaseVarIndex + 2] = broadband;
|
||||
|
||||
if (!good)
|
||||
{
|
||||
addLog(LOG_LEVEL_INFO,F("TSL2561: Sensor saturated! > 65535 Lux"));
|
||||
@@ -422,6 +436,10 @@ boolean Plugin_015(byte function, struct EventStruct *event, String& string)
|
||||
log += String(gain,HEX);
|
||||
log += F(": Lux: ");
|
||||
log += UserVar[event->BaseVarIndex];
|
||||
log += F(": Infrared: ");
|
||||
log += UserVar[event->BaseVarIndex + 1];
|
||||
log += F(": Broadband: ");
|
||||
log += UserVar[event->BaseVarIndex + 2];
|
||||
addLog(LOG_LEVEL_INFO,log);
|
||||
}
|
||||
else
|
||||
@@ -441,3 +459,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
|
||||
|
||||
+57
-10
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P049
|
||||
/*
|
||||
|
||||
This plug in is written by Dmitry (rel22 ___ inbox.ru)
|
||||
@@ -5,10 +6,25 @@
|
||||
Additional features based on https://geektimes.ru/post/285572/ by Gerben (infernix__AT__gmail.com)
|
||||
|
||||
This plugin reads the CO2 value from MH-Z19 NDIR Sensor
|
||||
DevicePin1 - is RX for ESP
|
||||
DevicePin2 - is TX for ESP
|
||||
|
||||
Pin-out:
|
||||
Hd o
|
||||
SR o o PWM
|
||||
Tx o o AOT
|
||||
Rx o o GND
|
||||
Vo o o Vin
|
||||
(bottom view)
|
||||
Skipping pin numbers due to inconsistancies in individual data sheet revisions.
|
||||
MHZ19: Connection:
|
||||
VCC 5 V
|
||||
GND GND
|
||||
Tx ESP8266 1st GPIO specified in Device-settings
|
||||
Rx ESP8266 2nd GPIO specified in Device-settings
|
||||
*/
|
||||
|
||||
// Uncomment the following define to enable the detection range commands:
|
||||
//#define ENABLE_DETECTION_RANGE_COMMANDS
|
||||
|
||||
#define PLUGIN_049
|
||||
#define PLUGIN_ID_049 49
|
||||
#define PLUGIN_NAME_049 "Gases - CO2 MH-Z19"
|
||||
@@ -36,31 +52,56 @@ enum mhzCommands : byte { mhzCmdReadPPM,
|
||||
mhzCmdABCEnable,
|
||||
mhzCmdABCDisable,
|
||||
mhzCmdReset,
|
||||
#ifdef ENABLE_DETECTION_RANGE_COMMANDS
|
||||
mhzCmdMeasurementRange1000,
|
||||
mhzCmdMeasurementRange2000,
|
||||
mhzCmdMeasurementRange3000,
|
||||
mhzCmdMeasurementRange5000 };
|
||||
mhzCmdMeasurementRange5000
|
||||
#endif
|
||||
};
|
||||
// 9 byte commands:
|
||||
// mhzCmdReadPPM[] = {0xFF,0x01,0x86,0x00,0x00,0x00,0x00,0x00,0x79};
|
||||
// mhzCmdCalibrateZero[] = {0xFF,0x01,0x87,0x00,0x00,0x00,0x00,0x00,0x78};
|
||||
// mhzCmdABCEnable[] = {0xFF,0x01,0x79,0xA0,0x00,0x00,0x00,0x00,0xE6};
|
||||
// mhzCmdABCDisable[] = {0xFF,0x01,0x79,0x00,0x00,0x00,0x00,0x00,0x86};
|
||||
// mhzCmdReset[] = {0xFF,0x01,0x8d,0x00,0x00,0x00,0x00,0x00,0x72};
|
||||
// mhzCmdMeasurementRange1000[] = {0xFF,0x01,0x99,0x03,0xE8,0x00,0x00,0x00,0x7B};
|
||||
// mhzCmdMeasurementRange2000[] = {0xFF,0x01,0x99,0x07,0xD0,0x00,0x00,0x00,0x8F};
|
||||
// mhzCmdMeasurementRange3000[] = {0xFF,0x01,0x99,0x0B,0xB8,0x00,0x00,0x00,0xA3};
|
||||
// mhzCmdMeasurementRange5000[] = {0xFF,0x01,0x99,0x13,0x88,0x00,0x00,0x00,0xCB};
|
||||
// Removing redundant data, just keeping offsets [2]..[4]:
|
||||
/* It seems the offsets [3]..[4] for the detection range setting (command byte 0x99) are wrong in the latest
|
||||
* online data sheet: http://www.winsen-sensor.com/d/files/infrared-gas-sensor/mh-z19b-co2-ver1_0.pdf
|
||||
* According to the MH-Z19B datasheet version 1.2, valid from: 2017.03.22 (received 2018-03-07)
|
||||
* the offset should be [6]..[7] instead.
|
||||
* 0x99 - Detection range setting, send command:
|
||||
* /---------+---------+---------+---------+---------+---------+---------+---------+---------\
|
||||
* | Byte 0 | Byte 1 | Byte 2 | Byte 3 | Byte 4 | Byte 5 | Byte 6 | Byte 7 | Byte 8 |
|
||||
* |---------+---------+---------+---------+---------+---------+---------+---------+---------|
|
||||
* | Start | Reserved| Command | Reserved|Detection|Detection|Detection|Detection| Checksum|
|
||||
* | Byte | | | |range |range |range |range | |
|
||||
* | | | | |24~32 bit|16~23 bit|8~15 bit |0~7 bit | |
|
||||
* |---------+---------+---------+---------+---------+---------+---------+---------+---------|
|
||||
* | 0xFF | 0x01 | 0x99 | 0x00 | Data 1 | Data 2 | Data 3 | Data 4 | Checksum|
|
||||
* \---------+---------+---------+---------+---------+---------+---------+---------+---------/
|
||||
* Note: Detection range should be 0~2000, 0~5000, 0~10000 ppm.
|
||||
* For example: set 0~2000 ppm detection range, send command: FF 01 99 00 00 00 07 D0 8F
|
||||
* set 0~10000 ppm detection range, send command: FF 01 99 00 00 00 27 10 8F
|
||||
* The latter, updated version above is implemented here.
|
||||
*/
|
||||
// mhzCmdMeasurementRange1000[] = {0xFF,0x01,0x99,0x00,0x00,0x00,0x03,0xE8,0x7B};
|
||||
// mhzCmdMeasurementRange2000[] = {0xFF,0x01,0x99,0x00,0x00,0x00,0x07,0xD0,0x8F};
|
||||
// mhzCmdMeasurementRange3000[] = {0xFF,0x01,0x99,0x00,0x00,0x00,0x0B,0xB8,0xA3};
|
||||
// mhzCmdMeasurementRange5000[] = {0xFF,0x01,0x99,0x00,0x00,0x00,0x13,0x88,0xCB};
|
||||
// Removing redundant data, just keeping offsets [2], [6]..[7]:
|
||||
const PROGMEM byte mhzCmdData[][3] = {
|
||||
{0x86,0x00,0x00},
|
||||
{0x87,0x00,0x00},
|
||||
{0x79,0xA0,0x00},
|
||||
{0x79,0x00,0x00},
|
||||
{0x8d,0x00,0x00},
|
||||
#ifdef ENABLE_DETECTION_RANGE_COMMANDS
|
||||
{0x99,0x03,0xE8},
|
||||
{0x99,0x07,0xD0},
|
||||
{0x99,0x0B,0xB8},
|
||||
{0x99,0x13,0x88}};
|
||||
{0x99,0x13,0x88}
|
||||
#endif
|
||||
};
|
||||
|
||||
byte mhzResp[9]; // 9 byte response buffer
|
||||
|
||||
@@ -245,6 +286,7 @@ boolean Plugin_049(byte function, struct EventStruct *event, String& string)
|
||||
success = true;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_DETECTION_RANGE_COMMANDS
|
||||
if (command == F("mhzmeasurementrange1000"))
|
||||
{
|
||||
_P049_send_mhzCmd(mhzCmdMeasurementRange1000);
|
||||
@@ -272,6 +314,7 @@ boolean Plugin_049(byte function, struct EventStruct *event, String& string)
|
||||
addLog(LOG_LEVEL_INFO, F("MHZ19: Sent measurement range 0-5000PPM!"));
|
||||
success = true;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
}
|
||||
@@ -412,6 +455,7 @@ boolean Plugin_049(byte function, struct EventStruct *event, String& string)
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
break;
|
||||
|
||||
//#ifdef ENABLE_DETECTION_RANGE_COMMANDS
|
||||
// Sensor responds with 0x99 whenever we send it a measurement range adjustment
|
||||
} else if (mhzResp[0] == 0xFF && mhzResp[1] == 0x99 && mhzResp[8] == checksum) {
|
||||
|
||||
@@ -419,6 +463,7 @@ boolean Plugin_049(byte function, struct EventStruct *event, String& string)
|
||||
addLog(LOG_LEVEL_INFO, F("Expecting sensor reset..."));
|
||||
success = false;
|
||||
break;
|
||||
//#endif
|
||||
|
||||
// log verbosely anything else that the sensor reports
|
||||
} else {
|
||||
@@ -456,8 +501,10 @@ size_t _P049_send_mhzCmd(byte CommandId)
|
||||
mhzResp[0] = 0xFF; // Start byte, fixed
|
||||
mhzResp[1] = 0x01; // Sensor number, 0x01 by default
|
||||
memcpy_P(&mhzResp[2], mhzCmdData[CommandId], sizeof(mhzCmdData[0]));
|
||||
mhzResp[5] = mhzResp[6] = mhzResp[7] = 0x00;
|
||||
mhzResp[6] = mhzResp[3]; mhzResp[7] = mhzResp[4];
|
||||
mhzResp[3] = mhzResp[4] = mhzResp[5] = 0x00;
|
||||
mhzResp[8] = _P049_calculateChecksum(mhzResp);
|
||||
|
||||
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 ########################################
|
||||
//#######################################################################################################
|
||||
@@ -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 #######################################
|
||||
//#######################################################################################################
|
||||
@@ -179,6 +180,7 @@ boolean Plugin_059(byte function, struct EventStruct *event, String& string)
|
||||
log = String(F("QEI : ")) + string;
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
Plugin_059_QE->write(event->Par1);
|
||||
UserVar[event->BaseVarIndex] = (float) event->Par1;
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
@@ -189,3 +191,4 @@ boolean Plugin_059(byte function, struct EventStruct *event, String& string)
|
||||
}
|
||||
return success;
|
||||
}
|
||||
#endif // USES_P059
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P060
|
||||
//#######################################################################################################
|
||||
//#################################### Plugin 060: MCP3221 ##############################################
|
||||
//#######################################################################################################
|
||||
@@ -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
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P068
|
||||
//#######################################################################################################
|
||||
//################ Plugin 68: SHT30/SHT31/SHT35 Temperature and Humidity Sensor (I2C) ###################
|
||||
//#######################################################################################################
|
||||
@@ -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
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P073
|
||||
//#######################################################################################################
|
||||
//################### Plugin 073 - 7-segment display plugin TM1637/MAX7219 ######################
|
||||
//#######################################################################################################
|
||||
@@ -786,3 +787,4 @@ void max7219_ShowBuffer(uint8_t din_pin, uint8_t clk_pin, uint8_t cs_pin)
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // USES_P073
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef USES_P074
|
||||
//#######################################################################################################
|
||||
//######################## Plugin 074 TSL2591 I2C Lux/IR Sensor #########################################
|
||||
//#######################################################################################################
|
||||
@@ -263,3 +264,4 @@ boolean Plugin_074(byte function, struct EventStruct *event, String& string)
|
||||
return success;
|
||||
}
|
||||
#endif
|
||||
#endif // USES_P074
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
SRC=`pwd`
|
||||
DST=${SRC}/converted
|
||||
|
||||
mkdir -p ${DST}
|
||||
|
||||
for file in `ls _P*.ino`; do
|
||||
PREF=`echo $file|cut -d '_' -f-2`
|
||||
USES=`echo "USES${PREF}"`
|
||||
if ! grep -q $USES "$file"; then
|
||||
echo "#ifdef ${USES}" > ${DST}/${file}
|
||||
cat ${file} >> ${DST}/${file}
|
||||
echo "#endif // ${USES}" >> ${DST}/${file}
|
||||
fi
|
||||
done
|
||||
@@ -0,0 +1,518 @@
|
||||
/*
|
||||
#################################################
|
||||
This is the place where plugins are registered
|
||||
#################################################
|
||||
|
||||
To create/register a plugin, you have to :
|
||||
- find an available number, ie 777.
|
||||
- Create your own plugin, ie as "_P777_myfunction.ino"
|
||||
- be sure it starts with ""#ifdef USES_P777", and ends with "#endif"
|
||||
- then register it into the PLUGIN_SET_EXPERIMENTAL block (see below)
|
||||
#ifdef PLUGIN_SET_EXPERIMENTAL
|
||||
#define USES_P777 // MYsuperPlugin
|
||||
#endif
|
||||
- you can from now on test it by compiling using the PLUGIN_BUILD_DEV flag
|
||||
either by adding "-DPLUGIN_BUILD_DEV" when compiling, or by momentarly
|
||||
adding "#define PLUGIN_BUILD_DEV" at the top of the ESPEasy.ino file
|
||||
- You will then have to push a PR including your plugin + the corret line (#define USES_P777) added to this file
|
||||
|
||||
When found stable enought, the maintainer (and only him) will choose to move it to TESTING or STABLE
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
/******************************************************************************\
|
||||
* BUILD Configs *******************************************************************
|
||||
\******************************************************************************/
|
||||
|
||||
#ifdef PLUGIN_BUILD_DEV
|
||||
#define PLUGIN_SET_EXPERIMENTAL
|
||||
#define CONTROLLER_SET_EXPERIMENTAL
|
||||
#define NOTIFIER_SET_EXPERIMENTAL
|
||||
#define PLUGIN_BUILD_TESTING // add testing
|
||||
#endif
|
||||
|
||||
#ifdef PLUGIN_BUILD_TESTING
|
||||
#define PLUGIN_SET_TESTING
|
||||
#define CONTROLLER_SET_TESTING
|
||||
#define NOTIFIER_SET_TESTING
|
||||
#define PLUGIN_BUILD_NORMAL // add stable
|
||||
#endif
|
||||
|
||||
#ifndef PLUGIN_BUILD_CUSTOM
|
||||
#ifndef PLUGIN_BUILD_NORMAL
|
||||
#define PLUGIN_BUILD_NORMAL // defaults to stable, if not custom
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef PLUGIN_BUILD_NORMAL
|
||||
#define PLUGIN_SET_STABLE
|
||||
#define CONTROLLER_SET_STABLE
|
||||
#define NOTIFIER_SET_STABLE
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/******************************************************************************\
|
||||
* Devices ********************************************************************
|
||||
\******************************************************************************/
|
||||
|
||||
// Itead ----------------------------
|
||||
#ifdef PLUGIN_SET_SONOFF_BASIC
|
||||
#define PLUGIN_SET_ONLY_SWITCH
|
||||
#endif
|
||||
|
||||
#ifdef PLUGIN_SET_SONOFF_TH10
|
||||
#define PLUGIN_SET_ONLY_SWITCH
|
||||
#endif
|
||||
|
||||
#ifdef PLUGIN_SET_SONOFF_TH16
|
||||
#define PLUGIN_SET_ONLY_SWITCH
|
||||
#define PLUGIN_SET_ONLY_TEMP_HUM
|
||||
#endif
|
||||
|
||||
#ifdef PLUGIN_SET_SONOFF_POW
|
||||
#define PLUGIN_SET_ONLY_SWITCH
|
||||
#endif
|
||||
|
||||
#ifdef PLUGIN_SET_SONOFF_S20
|
||||
#define PLUGIN_SET_ONLY_SWITCH
|
||||
#endif
|
||||
|
||||
#ifdef PLUGIN_SET_SONOFF_4CH
|
||||
#define PLUGIN_SET_ONLY_SWITCH
|
||||
#endif
|
||||
|
||||
#ifdef PLUGIN_SET_SONOFF_TOUCH
|
||||
#define PLUGIN_SET_ONLY_SWITCH
|
||||
#endif
|
||||
|
||||
// Easy ----------------------------
|
||||
#ifdef PLUGIN_SET_EASY_TEMP
|
||||
#define PLUGIN_SET_ONLY_TEMP_HUM
|
||||
#endif
|
||||
|
||||
#ifdef PLUGIN_SET_EASY_CARBON
|
||||
#define PLUGIN_SET_NONE
|
||||
#define USES_P052 // SenseAir
|
||||
#endif
|
||||
|
||||
/*
|
||||
#ifdef PLUGIN_SET_EASY_NEXTION
|
||||
#define PLUGIN_SET_ONLY_SWITCH
|
||||
//#define USES_Pxxx // Nextion
|
||||
#endif
|
||||
*/
|
||||
|
||||
#ifdef PLUGIN_SET_EASY_OLED1
|
||||
#define PLUGIN_SET_ONLY_SWITCH
|
||||
#define USES_P036 // FrameOLED
|
||||
#endif
|
||||
|
||||
#ifdef PLUGIN_SET_EASY_OLED2
|
||||
#define PLUGIN_SET_ONLY_SWITCH
|
||||
#define USES_P023 // OLED
|
||||
#endif
|
||||
|
||||
#ifdef PLUGIN_SET_EASY_RELAY
|
||||
#define PLUGIN_SET_ONLY_SWITCH
|
||||
#endif
|
||||
|
||||
// LedStrips ----------------------------
|
||||
#ifdef PLUGIN_SET_H801
|
||||
#define PLUGIN_SET_ONLY_LEDSTRIP
|
||||
#endif
|
||||
|
||||
#ifdef PLUGIN_SET_MAGICHOME
|
||||
#define PLUGIN_SET_ONLY_LEDSTRIP
|
||||
#endif
|
||||
|
||||
#ifdef PLUGIN_SET_MAGICHOME_IR
|
||||
#define PLUGIN_SET_ONLY_LEDSTRIP
|
||||
#define USES_P016 // IR
|
||||
#endif
|
||||
|
||||
|
||||
// Generic ESP32 -----------------------------
|
||||
#ifdef PLUGIN_SET_GENERIC_ESP32
|
||||
#ifndef ESP32
|
||||
#define ESP32
|
||||
#endif
|
||||
#ifdef ESP8266
|
||||
#undef ESP8266
|
||||
#endif
|
||||
#define PLUGIN_SET_ONLY_SWITCH
|
||||
#define USES_P036 // FrameOLED
|
||||
// TODO : Add list of compatible plugins for ESP32 board.
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
// Generic ------------------------------------
|
||||
#ifdef PLUGIN_SET_GENERIC_1M
|
||||
#define PLUGIN_SET_NONE
|
||||
// TODO : small list of common plugins to fit in 1M
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/******************************************************************************\
|
||||
* "ONLY" shorcuts ************************************************************
|
||||
\******************************************************************************/
|
||||
#ifdef PLUGIN_SET_ONLY_SWITCH
|
||||
#ifndef PLUGIN_SET_NONE
|
||||
#define PLUGIN_SET_NONE
|
||||
#endif
|
||||
#ifndef USES_P001
|
||||
#define USES_P001 // switch
|
||||
#endif
|
||||
#ifndef USES_P003
|
||||
#define USES_P003 // pulse
|
||||
#endif
|
||||
#ifndef USES_P037
|
||||
#define USES_P037 // MQTTImport
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef PLUGIN_SET_ONLY_TEMP_HUM
|
||||
#ifndef PLUGIN_SET_NONE
|
||||
#define PLUGIN_SET_NONE
|
||||
#endif
|
||||
#ifndef USES_P004
|
||||
#define USES_P004 // Dallas
|
||||
#endif
|
||||
#ifndef USES_P005
|
||||
#define USES_P005 // DHT
|
||||
#endif
|
||||
#ifndef USES_P028
|
||||
#define USES_P028 // BME280
|
||||
#endif
|
||||
#ifndef USES_P030
|
||||
#define USES_P030 // BMP280
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef PLUGIN_SET_ONLY_LEDSTRIP
|
||||
#ifndef PLUGIN_SET_NONE
|
||||
#define PLUGIN_SET_NONE
|
||||
#endif
|
||||
#ifndef USES_P141
|
||||
#define USES_P141 // LedStrip
|
||||
#endif
|
||||
#ifndef USES_P037
|
||||
#define USES_P037 // MQTTImport
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/******************************************************************************\
|
||||
* Main Families **************************************************************
|
||||
\******************************************************************************/
|
||||
|
||||
// NONE #####################################
|
||||
#ifdef PLUGIN_SET_NONE
|
||||
#ifdef PLUGIN_SET_STABLE
|
||||
#undef PLUGIN_SET_STABLE
|
||||
#endif
|
||||
#ifdef PLUGIN_SET_TESTING
|
||||
#undef PLUGIN_SET_TESTING
|
||||
#endif
|
||||
#ifdef PLUGIN_SET_EXPERIMENTAL
|
||||
#undef PLUGIN_SET_EXPERIMENTAL
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef CONTROLLER_SET_NONE
|
||||
#ifdef CONTROLLER_SET_STABLE
|
||||
#undef CONTROLLER_SET_STABLE
|
||||
#endif
|
||||
#ifdef CONTROLLER_SET_TESTING
|
||||
#undef CONTROLLER_SET_TESTING
|
||||
#endif
|
||||
#ifdef CONTROLLER_SET_EXPERIMENTAL
|
||||
#undef CONTROLLER_SET_EXPERIMENTAL
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef NOTIFIER_SET_NONE
|
||||
#ifdef NOTIFIER_SET_STABLE
|
||||
#undef NOTIFIER_SET_STABLE
|
||||
#endif
|
||||
#ifdef NOTIFIER_SET_TESTING
|
||||
#undef NOTIFIER_SET_TESTING
|
||||
#endif
|
||||
#ifdef NOTIFIER_SET_EXPERIMENTAL
|
||||
#undef NOTIFIER_SET_EXPERIMENTAL
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// ALL ###########################################
|
||||
#ifdef PLUGIN_SET_ALL
|
||||
#ifndef PLUGIN_SET_STABLE
|
||||
#define PLUGIN_SET_STABLE
|
||||
#endif
|
||||
#ifndef PLUGIN_SET_TESTING
|
||||
#define PLUGIN_SET_TESTING
|
||||
#endif
|
||||
#ifndef PLUGIN_SET_EXPERIMENTAL
|
||||
#define PLUGIN_SET_EXPERIMENTAL
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef CONTROLLER_SET_ALL
|
||||
#ifndef CONTROLLER_SET_STABLE
|
||||
#define CONTROLLER_SET_STABLE
|
||||
#endif
|
||||
#ifndef CONTROLLER_SET_TESTING
|
||||
#define CONTROLLER_SET_TESTING
|
||||
#endif
|
||||
#ifndef CONTROLLER_SET_EXPERIMENTAL
|
||||
#define CONTROLLER_SET_EXPERIMENTAL
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef NOTIFIER_SET_ALL
|
||||
#ifndef NOTIFIER_SET_STABLE
|
||||
#define NOTIFIER_SET_STABLE
|
||||
#endif
|
||||
#ifndef NOTIFIER_SET_TESTING
|
||||
#define NOTIFIER_SET_TESTING
|
||||
#endif
|
||||
#ifndef NOTIFIER_SET_EXPERIMENTAL
|
||||
#define NOTIFIER_SET_EXPERIMENTAL
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
// STABLE #####################################
|
||||
#ifdef PLUGIN_SET_STABLE
|
||||
#define USES_P001 // Switch
|
||||
#define USES_P002 // ADC
|
||||
#define USES_P003 // Pulse
|
||||
#define USES_P004 // Dallas
|
||||
#define USES_P005 // DHT
|
||||
#define USES_P006 // BMP085
|
||||
#define USES_P007 // PCF8591
|
||||
#define USES_P008 // RFID
|
||||
#define USES_P009 // MCP
|
||||
|
||||
#define USES_P010 // BH1750
|
||||
#define USES_P011 // PME
|
||||
#define USES_P012 // LCD
|
||||
#define USES_P013 // HCSR04
|
||||
#define USES_P014 // SI7021
|
||||
#define USES_P015 // TSL2561
|
||||
#define USES_P016 // IR
|
||||
#define USES_P017 // PN532
|
||||
#define USES_P018 // Dust
|
||||
#define USES_P019 // PCF8574
|
||||
|
||||
#define USES_P020 // Ser2Net
|
||||
#define USES_P021 // Level
|
||||
#define USES_P022 // PCA9685
|
||||
#define USES_P023 // OLED
|
||||
#define USES_P024 // MLX90614
|
||||
#define USES_P025 // ADS1115
|
||||
#define USES_P026 // SysInfo
|
||||
#define USES_P027 // INA219
|
||||
#define USES_P028 // BME280
|
||||
#define USES_P029 // Output
|
||||
|
||||
#define USES_P030 // BMP280
|
||||
#define USES_P031 // SHT1X
|
||||
#define USES_P032 // MS5611
|
||||
#define USES_P033 // Dummy
|
||||
#define USES_P034 // DHT12
|
||||
#define USES_P035 // IRTX
|
||||
#define USES_P036 // FrameOLED
|
||||
#define USES_P037 // MQTTImport
|
||||
#define USES_P038 // NeoPixel
|
||||
#define USES_P039 // ID12
|
||||
|
||||
#define USES_P041 // NeoClock
|
||||
#define USES_P042 // Candle
|
||||
#define USES_P043 // ClkOutput
|
||||
#define USES_P044 // P1WifiGateway
|
||||
|
||||
#define USES_P049 // MHZ19
|
||||
|
||||
#define USES_P052 // SenseAir
|
||||
|
||||
#define USES_P059 // Encoder
|
||||
|
||||
#define USES_P063 // TTP229_KeyPad
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef CONTROLLER_SET_STABLE
|
||||
#define USES_C001 // Domoticz HTTP
|
||||
#define USES_C002 // Domoticz MQTT
|
||||
#define USES_C003 // Nodo telnet
|
||||
#define USES_C004 // ThingSpeak
|
||||
#define USES_C005 // OpenHAB MQTT
|
||||
#define USES_C006 // PiDome MQTT
|
||||
#define USES_C007 // Emoncms
|
||||
#define USES_C008 // Generic HTTP
|
||||
#define USES_C009 // FHEM HTTP
|
||||
#define USES_C010 // Generic UDP
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef NOTIFIER_SET_STABLE
|
||||
#define USES_N001 // Email
|
||||
#define USES_N002 // Buzzer
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
// TESTING #####################################
|
||||
#ifdef PLUGIN_SET_TESTING
|
||||
#define USES_P045 // MPU6050
|
||||
#define USES_P047 // I2C_soil_misture
|
||||
#define USES_P048 // Motoshield_v2
|
||||
|
||||
#define USES_P051 // AM2320
|
||||
|
||||
#define USES_P053 // PMSx003
|
||||
#define USES_P054 // DMX512
|
||||
#define USES_P055 // Chiming
|
||||
#define USES_P056 // SDS011-Dust
|
||||
#define USES_P057 // HT16K33_LED
|
||||
#define USES_P058 // HT16K33_KeyPad
|
||||
|
||||
#define USES_P060 // MCP3221
|
||||
#define USES_P061 // Keypad
|
||||
#define USES_P062 // MPR121_KeyPad
|
||||
|
||||
#define USES_P064 // APDS9960
|
||||
#define USES_P065 // DRF0299
|
||||
#define USES_P066 // VEML6040
|
||||
#define USES_P067 // HX711_Load_Cell
|
||||
#define USES_P068 // SHT3x
|
||||
#define USES_P069 // LM75A
|
||||
|
||||
#define USES_P070 // NeoPixel_Clock
|
||||
#define USES_P071 // Kamstrup401
|
||||
#define USES_P072 // HDC1080
|
||||
#define USES_P073 // 7DG
|
||||
#define USES_P074 // TSL2561
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef CONTROLLER_SET_TESTING
|
||||
#define USES_C011 // Generic HTTP Advanced
|
||||
#define USES_C012 // Blynk HTTP
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef NOTIFIER_SET_TESTING
|
||||
#endif
|
||||
|
||||
|
||||
// EXPERIMENTAL (playground) #######################
|
||||
#ifdef PLUGIN_SET_EXPERIMENTAL
|
||||
#define USES_P046 // VentusW266
|
||||
#define USES_P050 // TCS34725 RGB Color Sensor with IR filter and White LED
|
||||
#define USES_P064 // APDS9960 Gesture
|
||||
|
||||
// [copied from Playground as of 6 March 2018]
|
||||
// It needs some cleanup as some are ALSO in the main repo,
|
||||
// thus they should have been removed from the Playground repo
|
||||
#define USES_P100 // SRF01
|
||||
#define USES_P101 // NeoClock (MERGED?)
|
||||
#define USES_P102 // Nodo
|
||||
#define USES_P103 // Event
|
||||
#define USES_P104 // SRF02
|
||||
#define USES_P105 // RGBW
|
||||
#define USES_P106 // IRTX
|
||||
#define USES_P107 // Email_Demo
|
||||
#define USES_P108 // WOL
|
||||
#define USES_P109 // RESOL_DeltaSol_Pro
|
||||
#define USES_P110 // P1WifiGateway (MERGED?)
|
||||
#define USES_P111 // RF
|
||||
//#define USES_P111 // SenseAir (MERGED?)
|
||||
#define USES_P112 // Power
|
||||
//#define USES_P112 // RFTX
|
||||
#define USES_P113 // SI1145
|
||||
#define USES_P114 // DSM501
|
||||
#define USES_P115 // HeatpumpIR
|
||||
#define USES_P116 // ID12
|
||||
#define USES_P117 // LW12FC
|
||||
//#define USES_P117 // Neopixels
|
||||
//#define USES_P117 // Nextion
|
||||
#define USES_P118 // CCS811
|
||||
#define USES_P119 // BME680
|
||||
#define USES_P120 // Thermocouple
|
||||
#define USES_P121 // Candle
|
||||
#define USES_P122 // NeoPixel (MERGED?)
|
||||
#define USES_P123 // NeoPixel_Clock (MERGED?)
|
||||
#define USES_P124 // NeoPixelBusFX
|
||||
//#define USES_P124 // Ventus_W266_RFM69
|
||||
#define USES_P125 // ArduCAM
|
||||
#define USES_P127 // Teleinfo
|
||||
#define USES_P130 // VEML6075
|
||||
#define USES_P131 // SHT3X
|
||||
#define USES_P133 // VL53L0X
|
||||
#define USES_P141 // LedStrip
|
||||
#define USES_P142 // RGB-Strip
|
||||
#define USES_P143 // AnyonePresent
|
||||
#define USES_P144 // RC-Switch-TX
|
||||
#define USES_P145 // Itho
|
||||
#define USES_P149 // MHZ19
|
||||
#define USES_P150 // SDM120C
|
||||
#define USES_P151 // CISA
|
||||
#define USES_P153 // MAX44009
|
||||
#define USES_P162 // MPL3115A2
|
||||
#define USES_P163 // DS1631
|
||||
#define USES_P165 // SerSwitch
|
||||
#define USES_P166 // WiFiMan
|
||||
#define USES_P167 // ADS1015
|
||||
#define USES_P170 // HLW8012
|
||||
#define USES_P171 // PZEM-004T
|
||||
#define USES_P180 // Mux
|
||||
#define USES_P181 // TempHumidity_SHT2x
|
||||
#define USES_P182 // MT681
|
||||
#define USES_P199 // RF443_KaKu
|
||||
#define USES_P202 // ADC_ACcurrentSensor
|
||||
#define USES_P205 // FrameOLED (MERGED?)
|
||||
#define USES_P209 // IFTTTMaker
|
||||
#define USES_P210 // MQTTImport (MERGED?)
|
||||
#define USES_P211 // MPU6050
|
||||
#define USES_P212 // MY9291
|
||||
#define USES_P213 // VEML6070
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef CONTROLLER_SET_EXPERIMENTAL
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef NOTIFIER_SET_EXPERIMENTAL
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/******************************************************************************\
|
||||
* Libraries dependencies *****************************************************
|
||||
\******************************************************************************/
|
||||
|
||||
/*
|
||||
#if defined(USES_P00x) || defined(USES_P00y)
|
||||
#include <the_required_lib.h>
|
||||
#endif
|
||||
*/
|
||||
Reference in New Issue
Block a user