mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-31 12:29:14 +03:00
Compare commits
478 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
57c12e43f1 | ||
|
|
c72af8650b | ||
|
|
a68dfb37fc | ||
|
|
3cdd8fc2b9 | ||
|
|
a4ae02736c | ||
|
|
e822414187 | ||
|
|
4e630fd0b0 | ||
|
|
988fb94c52 | ||
|
|
9906fade9a | ||
|
|
4cf68f417f | ||
|
|
05f726e378 | ||
|
|
75a7d4e16a | ||
|
|
691126a2d0 | ||
|
|
5eb3c6d3a3 | ||
|
|
bf9855aa60 | ||
|
|
50c616c61b | ||
|
|
2d2148d2c4 | ||
|
|
6ae001232d | ||
|
|
965b09cc78 | ||
|
|
a8534c4a73 | ||
|
|
401564a778 | ||
|
|
673bfe6b6b | ||
|
|
f8d574d15a | ||
|
|
e39806e0ac | ||
|
|
0fa7876b80 | ||
|
|
7eac8dde3b | ||
|
|
746ecc9c7a | ||
|
|
dad08c1686 | ||
|
|
e0bb6d58e8 | ||
|
|
a30dc04055 | ||
|
|
454922b8b4 | ||
|
|
02c363f1d6 | ||
|
|
d20f30d5e9 | ||
|
|
ddc3a92c15 | ||
|
|
e33ec57a1e | ||
|
|
7e4f852bf1 | ||
|
|
1a097ff2b7 | ||
|
|
99134cb6fd | ||
|
|
5955743426 | ||
|
|
5c664594af | ||
|
|
0df63ba642 | ||
|
|
d9672d17b0 | ||
|
|
c5772f8451 | ||
|
|
1df87f8986 | ||
|
|
3417d0c915 | ||
|
|
f4e917afba | ||
|
|
2aa3b56e85 | ||
|
|
e60d5eb62f | ||
|
|
6573b2c145 | ||
|
|
017c6f6234 | ||
|
|
305b3f32d6 | ||
|
|
5280a8914f | ||
|
|
cab8aff562 | ||
|
|
4711af6589 | ||
|
|
fe029a624c | ||
|
|
17162a2d85 | ||
|
|
433d28a785 | ||
|
|
19f728e209 | ||
|
|
07b75afb94 | ||
|
|
916116bbc4 | ||
|
|
9ac72f14e0 | ||
|
|
eddb2eb289 | ||
|
|
5f9d9ec48e | ||
|
|
0d6d1a7f6c | ||
|
|
a467117df9 | ||
|
|
0bb028229a | ||
|
|
ce383fe7fe | ||
|
|
2e240def88 | ||
|
|
245475ae99 | ||
|
|
c4df80e904 | ||
|
|
d5826b7038 | ||
|
|
8f08459a5a | ||
|
|
2fc82c3311 | ||
|
|
078c4389b5 | ||
|
|
9934690d0a | ||
|
|
b8a9f9b6b3 | ||
|
|
9fd88ffae1 | ||
|
|
9a7f6c5b05 | ||
|
|
ef01d08053 | ||
|
|
9a8061a84d | ||
|
|
e9820efff9 | ||
|
|
b2385bbc4c | ||
|
|
3e5d9770a1 | ||
|
|
71468599fe | ||
|
|
71c8fec27b | ||
|
|
f487a691fb | ||
|
|
d17112b3ff | ||
|
|
81866043bc | ||
|
|
253a9a5ae5 | ||
|
|
5c774c29bd | ||
|
|
6205f6959c | ||
|
|
6e44f76385 | ||
|
|
8dd4d8491c | ||
|
|
4436991205 | ||
|
|
d15cf619f1 | ||
|
|
9a2bdb54d1 | ||
|
|
7043855e3d | ||
|
|
49f11841be | ||
|
|
e88718ada0 | ||
|
|
0fc7cccda7 | ||
|
|
38924e4ed3 | ||
|
|
70c34d3d8d | ||
|
|
4f9763334b | ||
|
|
b2e9d90686 | ||
|
|
ceb516ddbe | ||
|
|
06df1f17b6 | ||
|
|
a20c2b8564 | ||
|
|
3c3a4a33ca | ||
|
|
28c24562bc | ||
|
|
d0ef8ec82e | ||
|
|
452110225d | ||
|
|
bdc9cd9b31 | ||
|
|
6cd60c9eef | ||
|
|
3e9da81b8c | ||
|
|
2e73eac2f1 | ||
|
|
6f45148d75 | ||
|
|
3766a744f4 | ||
|
|
94d93d3be6 | ||
|
|
d6aab0cf94 | ||
|
|
6135f3322e | ||
|
|
b53e7d15a4 | ||
|
|
7daa49083b | ||
|
|
68dc9c7bb3 | ||
|
|
b5cf1fd347 | ||
|
|
22f44afa1e | ||
|
|
964abc9f0c | ||
|
|
dfae6ebf09 | ||
|
|
50ad50efb2 | ||
|
|
96f160fc88 | ||
|
|
8bfba7ab4a | ||
|
|
6d52a181f0 | ||
|
|
044dd6294e | ||
|
|
c2baece068 | ||
|
|
9d6ec18bb2 | ||
|
|
50a5d51281 | ||
|
|
709a1fe1f7 | ||
|
|
1f46226a46 | ||
|
|
8cd84a09e2 | ||
|
|
e52437b828 | ||
|
|
1f69019bb3 | ||
|
|
2cad740fc6 | ||
|
|
aec1d50732 | ||
|
|
8817c532f4 | ||
|
|
3d42b96676 | ||
|
|
9845f010fd | ||
|
|
c02abefb43 | ||
|
|
aba00d9a70 | ||
|
|
0efae6949d | ||
|
|
777a04b901 | ||
|
|
50590bc90e | ||
|
|
0bfc876c65 | ||
|
|
518a0e0404 | ||
|
|
245db32e0b | ||
|
|
24de398a32 | ||
|
|
b2163c7626 | ||
|
|
d96aea8eef | ||
|
|
1126575822 | ||
|
|
8445dd3b0c | ||
|
|
b7a98e19d2 | ||
|
|
ff12345b12 | ||
|
|
0385beccdd | ||
|
|
f3a6add753 | ||
|
|
e984768a8d | ||
|
|
fb218fea76 | ||
|
|
600e66c345 | ||
|
|
29e5a55ad3 | ||
|
|
a5171f1178 | ||
|
|
a18f95d4e5 | ||
|
|
6064b9eac9 | ||
|
|
c389792081 | ||
|
|
7f0993f33b | ||
|
|
56e98e27f6 | ||
|
|
bea7afd057 | ||
|
|
cfd9d5baa0 | ||
|
|
b43fd9e389 | ||
|
|
92371f01da | ||
|
|
5b72a9b37f | ||
|
|
d2855270cf | ||
|
|
8778de1ffd | ||
|
|
281f338f97 | ||
|
|
d3ad04eae6 | ||
|
|
74b526e2f1 | ||
|
|
6426959060 | ||
|
|
cd9a6c98fa | ||
|
|
3bafbb88df | ||
|
|
eaef10aee2 | ||
|
|
d9556f5b31 | ||
|
|
a1eb94c4b3 | ||
|
|
5b6128ca21 | ||
|
|
65456398ac | ||
|
|
23fc8ec469 | ||
|
|
3607c26ae0 | ||
|
|
54841d59cf | ||
|
|
8bf136373c | ||
|
|
716aa697dc | ||
|
|
12cdefd531 | ||
|
|
19bc027083 | ||
|
|
1e4206f31d | ||
|
|
d6cb8b8d9a | ||
|
|
7472863b05 | ||
|
|
8a80d509c7 | ||
|
|
a77784abc7 | ||
|
|
52b8d971d8 | ||
|
|
65175e3663 | ||
|
|
9619a17abf | ||
|
|
3d1f1ec524 | ||
|
|
734f3e1b36 | ||
|
|
b66b4ab947 | ||
|
|
0598a20beb | ||
|
|
16b2498d6a | ||
|
|
716dfd095d | ||
|
|
e23481eef2 | ||
|
|
d6f5506812 | ||
|
|
8568e945a4 | ||
|
|
0a212e0933 | ||
|
|
fc91a60bab | ||
|
|
e0a83189d9 | ||
|
|
fe35633d23 | ||
|
|
251f7ee83f | ||
|
|
c960e5c5e5 | ||
|
|
807a6855e4 | ||
|
|
bac9396e9a | ||
|
|
dcbc928896 | ||
|
|
d8dfe7f60c | ||
|
|
e505eb9b6e | ||
|
|
799118d763 | ||
|
|
a258c8c1b6 | ||
|
|
26b5c173a2 | ||
|
|
551b35ff4f | ||
|
|
eea82a7edb | ||
|
|
26b211dc07 | ||
|
|
ab65cda820 | ||
|
|
89fed305c8 | ||
|
|
93c6b05238 | ||
|
|
8a07b7cbd7 | ||
|
|
4a57cf69d1 | ||
|
|
2e8ea582d2 | ||
|
|
70096c71c8 | ||
|
|
26383c0a19 | ||
|
|
a8e7799011 | ||
|
|
a9fc6f73f5 | ||
|
|
e66b49ddc3 | ||
|
|
3816711f04 | ||
|
|
0005760774 | ||
|
|
86ee523182 | ||
|
|
01248f41da | ||
|
|
786468e0b9 | ||
|
|
490a2f1f5b | ||
|
|
61f1ad64a1 | ||
|
|
25d58d3471 | ||
|
|
b1ca2ad511 | ||
|
|
8219cf3271 | ||
|
|
21e7297035 | ||
|
|
3ab75bcea6 | ||
|
|
eb6c06c8e9 | ||
|
|
0c1a1940d2 | ||
|
|
c473f616b6 | ||
|
|
74a7c8f528 | ||
|
|
f16d336575 | ||
|
|
ffc5e6c894 | ||
|
|
90e6822d3b | ||
|
|
e3f3ae7664 | ||
|
|
abbfcec92c | ||
|
|
7f7bad305c | ||
|
|
532925756f | ||
|
|
b1318de1dc | ||
|
|
c11983003b | ||
|
|
ce7c550410 | ||
|
|
e44d2dc793 | ||
|
|
82b1fb6846 | ||
|
|
0485feeabe | ||
|
|
e0d0e30e93 | ||
|
|
0ebe372848 | ||
|
|
e32097f563 | ||
|
|
10975cc8df | ||
|
|
1fa2add718 | ||
|
|
6c8be73d3a | ||
|
|
b2c8437c05 | ||
|
|
ef6930350e | ||
|
|
7ec3c05e6c | ||
|
|
b95a56d3a5 | ||
|
|
b512c0258d | ||
|
|
33ebb36aec | ||
|
|
8d31bcb5dd | ||
|
|
78fb96d50d | ||
|
|
6c969a2455 | ||
|
|
8df3ab8946 | ||
|
|
b2496bbc9f | ||
|
|
614b456b24 | ||
|
|
feab9e9afd | ||
|
|
924b6a1e84 | ||
|
|
f4a5bc0218 | ||
|
|
217cdfc080 | ||
|
|
b0fe94ddd4 | ||
|
|
6831c49a13 | ||
|
|
715ae0584a | ||
|
|
3dab9e484f | ||
|
|
1eac8a2f0e | ||
|
|
2434602d78 | ||
|
|
854d5f42e5 | ||
|
|
7806aa1ae8 | ||
|
|
98d59615a3 | ||
|
|
7134c07f60 | ||
|
|
9fa3ec05c2 | ||
|
|
832e6a36f1 | ||
|
|
5aa6f9482f | ||
|
|
bcbec5a9d8 | ||
|
|
2e66c93814 | ||
|
|
e04bb7bb78 | ||
|
|
110fc167a1 | ||
|
|
be60311f35 | ||
|
|
bdd9f1d3bd | ||
|
|
291373fe6f | ||
|
|
b653ce1e87 | ||
|
|
4aa0dc39b9 | ||
|
|
f7f4e176b2 | ||
|
|
62d0355a1e | ||
|
|
9b94aef8ca | ||
|
|
3dc49f66a8 | ||
|
|
d96ba8cb2c | ||
|
|
2dfca14478 | ||
|
|
b6eedca37e | ||
|
|
d7e6e0e9b8 | ||
|
|
9e291bfc9c | ||
|
|
7ac0691347 | ||
|
|
eb2881ee0a | ||
|
|
39a3cb04ed | ||
|
|
e561f82b02 | ||
|
|
00fd9f9bb9 | ||
|
|
b51ec4d0e2 | ||
|
|
e60269ed1e | ||
|
|
0f0d2ea209 | ||
|
|
5faa708c83 | ||
|
|
3ece57fc18 | ||
|
|
f75f0b5a50 | ||
|
|
9add7c9e8e | ||
|
|
5de838beb8 | ||
|
|
b7899aa059 | ||
|
|
c0b7cdddf8 | ||
|
|
d802758b6f | ||
|
|
a13dda46ca | ||
|
|
a73747c3dc | ||
|
|
e9a8e44a7a | ||
|
|
cd6008435e | ||
|
|
6277d2a9db | ||
|
|
d0c6d34f4a | ||
|
|
428efff8d5 | ||
|
|
7330849262 | ||
|
|
3dfee0eabe | ||
|
|
b6d346f779 | ||
|
|
a1bd008867 | ||
|
|
1264f12314 | ||
|
|
7c61ff2810 | ||
|
|
5ed1c23c62 | ||
|
|
b50e1c9791 | ||
|
|
baba0b77b2 | ||
|
|
3daa517c7e | ||
|
|
6618e6fa7e | ||
|
|
688a769798 | ||
|
|
a25288ef79 | ||
|
|
5643804d77 | ||
|
|
90a342bc27 | ||
|
|
c4dfdee7e5 | ||
|
|
a422c72565 | ||
|
|
2c3efd6309 | ||
|
|
e400de1e1c | ||
|
|
cc3c17dfb2 | ||
|
|
f9933ea55e | ||
|
|
59f65abda8 | ||
|
|
7dd13b7fcf | ||
|
|
f54cac95bb | ||
|
|
cb9c0efac6 | ||
|
|
06bbecd0bb | ||
|
|
dfeb25a8fa | ||
|
|
ecd124dacc | ||
|
|
6e97ec5845 | ||
|
|
e375cca3dc | ||
|
|
8f76cbac74 | ||
|
|
b50911ddcf | ||
|
|
8f395ccc8a | ||
|
|
fea662aed2 | ||
|
|
f7e3515c82 | ||
|
|
1bfe58766d | ||
|
|
274678f17a | ||
|
|
059b08fb8b | ||
|
|
f638de4139 | ||
|
|
8cdc271c48 | ||
|
|
092bec7dde | ||
|
|
4967f66238 | ||
|
|
3a3d27492b | ||
|
|
4013a21262 | ||
|
|
eba3b80076 | ||
|
|
c9c8fc0a31 | ||
|
|
cba45d7893 | ||
|
|
2769a8883f | ||
|
|
e2e6256aa0 | ||
|
|
b9f0564f28 | ||
|
|
b53660d4bf | ||
|
|
2333006b76 | ||
|
|
f2aabd0349 | ||
|
|
63e34bf2e2 | ||
|
|
9a5172e4a6 | ||
|
|
c670d0cb58 | ||
|
|
4e478c9d2a | ||
|
|
40688130fd | ||
|
|
62e11ff7fc | ||
|
|
179ab2c3bf | ||
|
|
91359fa9c4 | ||
|
|
de0696b81a | ||
|
|
aeedbdef92 | ||
|
|
bba7487374 | ||
|
|
f7d4b9abc9 | ||
|
|
45e96da169 | ||
|
|
ac6f51af7b | ||
|
|
72989f3dfb | ||
|
|
c7b87508a1 | ||
|
|
704afcdcd2 | ||
|
|
6fbd555474 | ||
|
|
91fffe83d1 | ||
|
|
cffd80d125 | ||
|
|
93fd7f6e16 | ||
|
|
fb62ae7a4b | ||
|
|
c4feb99e8d | ||
|
|
db5b8d7258 | ||
|
|
52599fe02c | ||
|
|
de5a9c01d0 | ||
|
|
df9d70ce77 | ||
|
|
652eaa99d0 | ||
|
|
93d128b9b4 | ||
|
|
98db017502 | ||
|
|
6f310e5e07 | ||
|
|
ece010976e | ||
|
|
cbb821167b | ||
|
|
465c393db4 | ||
|
|
7f2981d4e9 | ||
|
|
66d3754cc4 | ||
|
|
734edf522d | ||
|
|
8ec105d0b2 | ||
|
|
b044497c8e | ||
|
|
817a3e5898 | ||
|
|
446809355b | ||
|
|
48ba3c99dd | ||
|
|
e6637dcd69 | ||
|
|
2a45769caf | ||
|
|
2edba7baba | ||
|
|
02855b5ab9 | ||
|
|
15aa8c8539 | ||
|
|
aa1ad777c9 | ||
|
|
5494f61267 | ||
|
|
5bec53e6c2 | ||
|
|
86e18f1e99 | ||
|
|
c16b61c82b | ||
|
|
509ee7da0b | ||
|
|
3e5eed24c6 | ||
|
|
03f0d563ee | ||
|
|
2bc3c44b64 | ||
|
|
44dec6aece | ||
|
|
61b0c4b6b8 | ||
|
|
a154f3cd15 | ||
|
|
cf182b2fe7 | ||
|
|
996af08d6e | ||
|
|
130a7fef0b | ||
|
|
99a17e4a0c | ||
|
|
0e074e68ca | ||
|
|
df5525bc7a | ||
|
|
70cb7164ce | ||
|
|
fc567c2f4a | ||
|
|
ec76321206 | ||
|
|
bf75e9f4b7 | ||
|
|
3ea2509b6d | ||
|
|
07f439b900 | ||
|
|
ae64d8f8ff | ||
|
|
58bbfec87f | ||
|
|
4442b46603 | ||
|
|
a31c303c23 | ||
|
|
ac5b7e5775 | ||
|
|
696c51b113 | ||
|
|
990bd6fb47 |
2
.gitattributes
vendored
2
.gitattributes
vendored
@@ -1,2 +0,0 @@
|
||||
# Auto detect text files and perform LF normalization
|
||||
* text=auto
|
||||
7
.gitignore
vendored
Normal file
7
.gitignore
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
.pio
|
||||
.vscode/.browse.c_cpp.db*
|
||||
.vscode/c_cpp_properties.json
|
||||
.vscode/launch.json
|
||||
.vscode/ipch
|
||||
lib/libraies-master
|
||||
|
||||
7
.vscode/extensions.json
vendored
Normal file
7
.vscode/extensions.json
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
||||
// for the documentation about the extensions.json format
|
||||
"recommendations": [
|
||||
"platformio.platformio-ide"
|
||||
]
|
||||
}
|
||||
497
Cmd.ino
497
Cmd.ino
@@ -1,497 +0,0 @@
|
||||
void CMD_init() {
|
||||
|
||||
sCmd.addCommand("button", button);
|
||||
sCmd.addCommand("buttonSet", buttonSet);
|
||||
sCmd.addCommand("buttonChange", buttonChange);
|
||||
|
||||
sCmd.addCommand("pinSet", pinSet);
|
||||
sCmd.addCommand("pinChange", pinChange);
|
||||
|
||||
sCmd.addCommand("pwm", pwm);
|
||||
sCmd.addCommand("pwmSet", pwmSet);
|
||||
|
||||
sCmd.addCommand("switch", switch_);
|
||||
|
||||
sCmd.addCommand("analog", analog);
|
||||
sCmd.addCommand("level", level);
|
||||
sCmd.addCommand("dallas", dallas);
|
||||
|
||||
sCmd.addCommand("dhtT", dhtT);
|
||||
sCmd.addCommand("dhtH", dhtH);
|
||||
sCmd.addCommand("dhtPerception", dhtPerception);
|
||||
sCmd.addCommand("dhtComfort", dhtComfort);
|
||||
sCmd.addCommand("dhtDewpoint", dhtDewpoint);
|
||||
|
||||
sCmd.addCommand("stepper", stepper);
|
||||
sCmd.addCommand("stepperSet", stepperSet);
|
||||
|
||||
sCmd.addCommand("logging", logging);
|
||||
|
||||
sCmd.addCommand("inputDigit", inputDigit);
|
||||
sCmd.addCommand("digitSet", digitSet);
|
||||
|
||||
sCmd.addCommand("inputTime", inputTime);
|
||||
sCmd.addCommand("timeSet", timeSet);
|
||||
|
||||
sCmd.addCommand("timerStart", timerStart);
|
||||
sCmd.addCommand("timerStop", timerStop);
|
||||
|
||||
sCmd.addCommand("text", text);
|
||||
sCmd.addCommand("textSet", textSet);
|
||||
|
||||
|
||||
sCmd.addCommand("mqtt", mqttOrderSend);
|
||||
sCmd.addCommand("http", httpOrderSend);
|
||||
sCmd.addCommand("push", pushControl);
|
||||
|
||||
|
||||
handle_time_init();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//==========================================================================================================
|
||||
//==========================================Модуль кнопок===================================================
|
||||
void button() {
|
||||
|
||||
String button_number = sCmd.next();
|
||||
String button_param = sCmd.next();
|
||||
String widget_name = sCmd.next();
|
||||
String page_name = sCmd.next();
|
||||
String start_state = sCmd.next();
|
||||
String page_number = sCmd.next();
|
||||
|
||||
jsonWriteStr(optionJson, "button_param" + button_number, button_param);
|
||||
jsonWriteStr(configJson, "buttonSet" + button_number, start_state);
|
||||
|
||||
if (isDigitStr (button_param)) {
|
||||
pinMode(button_param.toInt(), OUTPUT);
|
||||
digitalWrite(button_param.toInt(), start_state.toInt());
|
||||
}
|
||||
|
||||
if (button_param == "scenario") {
|
||||
jsonWriteStr(configSetup, "scenario", start_state);
|
||||
Scenario_init();
|
||||
saveConfig();
|
||||
}
|
||||
|
||||
if (button_param.indexOf("line") != -1) {
|
||||
String str = button_param;
|
||||
while (str.length() != 0) {
|
||||
if (str == "") return;
|
||||
String tmp = selectToMarker (str, ","); //line1,
|
||||
String number = deleteBeforeDelimiter(tmp, "e"); //1,
|
||||
number.replace(",", "");
|
||||
Serial.println(number);
|
||||
int number_int = number.toInt();
|
||||
scenario_line_status[number_int] = start_state.toInt();
|
||||
str = deleteBeforeDelimiter(str, ",");
|
||||
}
|
||||
}
|
||||
createWidget (widget_name, page_name, page_number, "widgets/widget.toggle.json", "buttonSet" + button_number);
|
||||
}
|
||||
|
||||
void buttonSet() {
|
||||
|
||||
String button_number = sCmd.next();
|
||||
String button_state = sCmd.next();
|
||||
String button_param = jsonRead(optionJson, "button_param" + button_number);
|
||||
|
||||
if (button_param != "na" || button_param != "scenario" || button_param.indexOf("line") != -1) {
|
||||
digitalWrite(button_param.toInt(), button_state.toInt());
|
||||
}
|
||||
|
||||
if (button_param == "scenario") {
|
||||
jsonWriteStr(configSetup, "scenario", button_state);
|
||||
Scenario_init();
|
||||
saveConfig();
|
||||
}
|
||||
|
||||
if (button_param.indexOf("line") != -1) {
|
||||
String str = button_param;
|
||||
while (str.length() != 0) {
|
||||
if (str == "") return;
|
||||
String tmp = selectToMarker (str, ","); //line1,
|
||||
String number = deleteBeforeDelimiter(tmp, "e"); //1,
|
||||
number.replace(",", "");
|
||||
Serial.println(number);
|
||||
int number_int = number.toInt();
|
||||
scenario_line_status[number_int] = button_state.toInt();
|
||||
str = deleteBeforeDelimiter(str, ",");
|
||||
}
|
||||
}
|
||||
|
||||
eventGen ("buttonSet", button_number);
|
||||
|
||||
jsonWriteStr(configJson, "buttonSet" + button_number, button_state);
|
||||
sendSTATUS("buttonSet" + button_number, button_state);
|
||||
}
|
||||
|
||||
void buttonChange() {
|
||||
String button_number = sCmd.next();
|
||||
String current_state = jsonRead(configJson, "buttonSet" + button_number);
|
||||
if (current_state == "1") {
|
||||
current_state = "0";
|
||||
} else if (current_state == "0") {
|
||||
current_state = "1";
|
||||
}
|
||||
order_loop += "buttonSet " + button_number + " " + current_state + ",";
|
||||
jsonWriteStr(configJson, "buttonSet" + button_number, current_state);
|
||||
sendSTATUS("buttonSet" + button_number, current_state);
|
||||
}
|
||||
|
||||
void pinSet() {
|
||||
String pin_number = sCmd.next();
|
||||
String pin_state = sCmd.next();
|
||||
pinMode(pin_number.toInt(), OUTPUT);
|
||||
digitalWrite(pin_number.toInt(), pin_state.toInt());
|
||||
}
|
||||
|
||||
void pinChange() {
|
||||
String pin_number = sCmd.next();
|
||||
pinMode(pin_number.toInt(), OUTPUT);
|
||||
digitalWrite(pin_number.toInt(), !digitalRead(pin_number.toInt()));
|
||||
}
|
||||
//==================================================================================================================
|
||||
//==========================================Модуль управления ШИМ===================================================
|
||||
void pwm() {
|
||||
|
||||
static boolean flag = true;
|
||||
String pwm_number = sCmd.next();
|
||||
String pwm_pin = sCmd.next();
|
||||
String widget_name = sCmd.next();
|
||||
widget_name.replace("#", " ");
|
||||
String page_name = sCmd.next();
|
||||
String start_state = sCmd.next();
|
||||
String page_number = sCmd.next();
|
||||
|
||||
|
||||
uint8_t pwm_pin_int = pwm_pin.toInt();
|
||||
jsonWriteStr(optionJson, "pwm_pin" + pwm_number, pwm_pin);
|
||||
pinMode(pwm_pin_int, INPUT);
|
||||
analogWrite(pwm_pin_int, start_state.toInt());
|
||||
//analogWriteFreq(32000);
|
||||
jsonWriteStr(configJson, "pwmSet" + pwm_number, start_state);
|
||||
|
||||
createWidget (widget_name, page_name, page_number, "widgets/widget.range.json", "pwmSet" + pwm_number);
|
||||
}
|
||||
|
||||
void pwmSet() {
|
||||
|
||||
String pwm_number = sCmd.next();
|
||||
String pwm_state = sCmd.next();
|
||||
int pwm_state_int = pwm_state.toInt();
|
||||
|
||||
int pin = jsonReadtoInt(optionJson, "pwm_pin" + pwm_number);
|
||||
analogWrite(pin, pwm_state_int);
|
||||
|
||||
eventGen ("pwmSet", pwm_number);
|
||||
|
||||
jsonWriteStr(configJson, "pwmSet" + pwm_number, pwm_state);
|
||||
sendSTATUS("pwmSet" + pwm_number, pwm_state);
|
||||
}
|
||||
//==================================================================================================================
|
||||
//==========================================Модуль физической кнопки================================================
|
||||
void switch_ () {
|
||||
|
||||
String switch_number = sCmd.next();
|
||||
String switch_pin = sCmd.next();
|
||||
String switch_delay = sCmd.next();
|
||||
|
||||
buttons[switch_number.toInt()].attach(switch_pin.toInt());
|
||||
buttons[switch_number.toInt()].interval(switch_delay.toInt());
|
||||
but[switch_number.toInt()] = true;
|
||||
}
|
||||
|
||||
void handleButton() {
|
||||
|
||||
static uint8_t switch_number = 1;
|
||||
|
||||
if (but[switch_number]) {
|
||||
buttons[switch_number].update();
|
||||
if (buttons[switch_number].fell()) {
|
||||
|
||||
eventGen ("switchSet", String(switch_number));
|
||||
|
||||
jsonWriteStr(configJson, "switchSet" + String(switch_number), "1");
|
||||
}
|
||||
if (buttons[switch_number].rose()) {
|
||||
|
||||
eventGen ("switchSet", String(switch_number));
|
||||
|
||||
jsonWriteStr(configJson, "switchSet" + String(switch_number), "0");
|
||||
}
|
||||
}
|
||||
switch_number++;
|
||||
if (switch_number == NUM_BUTTONS) switch_number = 0;
|
||||
}
|
||||
|
||||
//=====================================================================================================================================
|
||||
//=========================================Добавление окна ввода цифры=================================================================
|
||||
void inputDigit() {
|
||||
String value_name = sCmd.next();
|
||||
String number = value_name.substring(5);
|
||||
String widget_name = sCmd.next();
|
||||
widget_name.replace("#", " ");
|
||||
String page_name = sCmd.next();
|
||||
page_name.replace("#", " ");
|
||||
String start_state = sCmd.next();
|
||||
String page_number = sCmd.next();
|
||||
jsonWriteStr(configJson, "digitSet" + number, start_state);
|
||||
createWidget (widget_name, page_name, page_number, "widgets/widget.inputNum.json", "digitSet" + number);
|
||||
}
|
||||
void digitSet() {
|
||||
String number = sCmd.next();
|
||||
String value = sCmd.next();
|
||||
jsonWriteStr(configJson, "digitSet" + number, value);
|
||||
sendSTATUS("digitSet" + number, value);
|
||||
}
|
||||
//=====================================================================================================================================
|
||||
//=========================================Добавление окна ввода времени===============================================================
|
||||
void inputTime() {
|
||||
String value_name = sCmd.next();
|
||||
String number = value_name.substring(4);
|
||||
String widget_name = sCmd.next();
|
||||
widget_name.replace("#", " ");
|
||||
String page_name = sCmd.next();
|
||||
page_name.replace("#", " ");
|
||||
String start_state = sCmd.next();
|
||||
String page_number = sCmd.next();
|
||||
jsonWriteStr(configJson, "timeSet" + number, start_state);
|
||||
createWidget (widget_name, page_name, page_number, "widgets/widget.inputTime.json", "timeSet" + number);
|
||||
}
|
||||
void timeSet() {
|
||||
String number = sCmd.next();
|
||||
String value = sCmd.next();
|
||||
jsonWriteStr(configJson, "timeSet" + number, value);
|
||||
sendSTATUS("timeSet" + number, value);
|
||||
}
|
||||
|
||||
void handle_time_init() {
|
||||
ts.add(TIME, 1000, [&](void*) {
|
||||
|
||||
String tmp = GetTime();
|
||||
tmp.replace(":", "-");
|
||||
jsonWriteStr(configJson, "timenowSet", tmp);
|
||||
eventGen ("timenowSet", "");
|
||||
|
||||
}, nullptr, true);
|
||||
}
|
||||
|
||||
//=====================================================================================================================================
|
||||
//=========================================Добавление текстового виджета============================================================
|
||||
void text() {
|
||||
|
||||
String number = sCmd.next();
|
||||
String widget_name = sCmd.next();
|
||||
String page_name = sCmd.next();
|
||||
String page_number = sCmd.next();
|
||||
|
||||
createWidget (widget_name, page_name, page_number, "widgets/widget.anyData.json", "textSet" + number);
|
||||
}
|
||||
|
||||
|
||||
void textSet() {
|
||||
|
||||
String number = sCmd.next();
|
||||
String text = sCmd.next();
|
||||
text.replace("_", " ");
|
||||
|
||||
if (text.indexOf("-time") >= 0) {
|
||||
text.replace("-time", "");
|
||||
text.replace("#", " ");
|
||||
String time = GetTime();
|
||||
time.replace(":", ".");
|
||||
text = text + " " + GetDataDigital() + " " + time;
|
||||
}
|
||||
|
||||
jsonWriteStr(configJson, "textSet" + number, text);
|
||||
sendSTATUS("textSet" + number, text);
|
||||
}
|
||||
|
||||
//=====================================================================================================================================
|
||||
//=========================================Модуль шагового мотора======================================================================
|
||||
|
||||
//stepper 1 12 13
|
||||
void stepper() {
|
||||
String stepper_number = sCmd.next();
|
||||
String pin_step = sCmd.next();
|
||||
String pin_dir = sCmd.next();
|
||||
|
||||
jsonWriteStr(optionJson, "stepper" + stepper_number, pin_step + " " + pin_dir);
|
||||
pinMode(pin_step.toInt(), OUTPUT);
|
||||
pinMode(pin_dir.toInt(), OUTPUT);
|
||||
}
|
||||
|
||||
//stepperSet 1 100 5
|
||||
void stepperSet() {
|
||||
String stepper_number = sCmd.next();
|
||||
String steps = sCmd.next();
|
||||
jsonWriteStr(optionJson, "steps" + stepper_number, steps);
|
||||
String stepper_speed = sCmd.next();
|
||||
String pin_step = selectToMarker (jsonRead(optionJson, "stepper" + stepper_number), " ");
|
||||
String pin_dir = deleteBeforeDelimiter (jsonRead(optionJson, "stepper" + stepper_number), " ");
|
||||
Serial.println(pin_step);
|
||||
Serial.println(pin_dir);
|
||||
if (steps.toInt() > 0) digitalWrite(pin_dir.toInt(), HIGH);
|
||||
if (steps.toInt() < 0) digitalWrite(pin_dir.toInt(), LOW);
|
||||
if (stepper_number == "1") {
|
||||
ts.add(STEPPER1, stepper_speed.toInt(), [&](void*) {
|
||||
int steps_int = abs(jsonReadtoInt(optionJson, "steps1") * 2);
|
||||
static int count;
|
||||
count++;
|
||||
String pin_step = selectToMarker (jsonRead(optionJson, "stepper1"), " ");
|
||||
digitalWrite(pin_step.toInt(), !digitalRead(pin_step.toInt()));
|
||||
if (count > steps_int) {
|
||||
digitalWrite(pin_step.toInt(), LOW);
|
||||
ts.remove(STEPPER1);
|
||||
count = 0;
|
||||
}
|
||||
}, nullptr, true);
|
||||
}
|
||||
if (stepper_number == "2") {
|
||||
ts.add(STEPPER2, stepper_speed.toInt(), [&](void*) {
|
||||
int steps_int = abs(jsonReadtoInt(optionJson, "steps2") * 2);
|
||||
static int count;
|
||||
count++;
|
||||
String pin_step = selectToMarker (jsonRead(optionJson, "stepper2"), " ");
|
||||
digitalWrite(pin_step.toInt(), !digitalRead(pin_step.toInt()));
|
||||
if (count > steps_int) {
|
||||
digitalWrite(pin_step.toInt(), LOW);
|
||||
ts.remove(STEPPER2);
|
||||
count = 0;
|
||||
}
|
||||
}, nullptr, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//====================================================================================================================================================
|
||||
/*
|
||||
void inputText() {
|
||||
String number = sCmd.next();
|
||||
String widget_name = sCmd.next();
|
||||
widget_name.replace("#", " ");
|
||||
String page_name = sCmd.next();
|
||||
page_name.replace("#", " ");
|
||||
String start_state = sCmd.next();
|
||||
String page_number = sCmd.next();
|
||||
jsonWriteStr(configJson, "inputTextSet" + number, start_state);
|
||||
createWidget (widget_name, page_name, page_number, "widgets/widget.inputText.json", "inputTextSet" + number);
|
||||
}
|
||||
void inputTextSet() {
|
||||
String number = sCmd.next();
|
||||
String value = sCmd.next();
|
||||
jsonWriteStr(configJson, "inputTextSet" + number, value);
|
||||
sendSTATUS("inputTextSet" + number, value);
|
||||
}
|
||||
|
||||
void inputTime() {
|
||||
String number = sCmd.next();
|
||||
String widget_name = sCmd.next();
|
||||
widget_name.replace("#", " ");
|
||||
String page_name = sCmd.next();
|
||||
page_name.replace("#", " ");
|
||||
String start_state = sCmd.next();
|
||||
String page_number = sCmd.next();
|
||||
jsonWriteStr(configJson, "inputTimeSet" + number, start_state);
|
||||
createWidget (widget_name, page_name, page_number, "widgets/widget.inputTime.json", "inputTimeSet" + number);
|
||||
}
|
||||
void inputTimeSet() {
|
||||
String number = sCmd.next();
|
||||
String value = sCmd.next();
|
||||
value.replace(":", ".");
|
||||
jsonWriteStr(configJson, "inputTimeSet" + number, value);
|
||||
value.replace(".", ":");
|
||||
sendSTATUS("inputTimeSet" + number, value);
|
||||
}
|
||||
|
||||
|
||||
void inputDate() {
|
||||
String number = sCmd.next();
|
||||
String widget_name = sCmd.next();
|
||||
widget_name.replace("#", " ");
|
||||
String page_name = sCmd.next();
|
||||
page_name.replace("#", " ");
|
||||
String start_state = sCmd.next();
|
||||
String page_number = sCmd.next();
|
||||
jsonWriteStr(configJson, "inputDateSet" + number, start_state);
|
||||
createWidget (widget_name, page_name, page_number, "widgets/widget.inputDate.json", "inputDateSet" + number);
|
||||
}
|
||||
void inputDateSet() {
|
||||
String number = sCmd.next();
|
||||
String value = sCmd.next();
|
||||
jsonWriteStr(configJson, "inputDateSet" + number, value);
|
||||
sendSTATUS("inputDateSet" + number, value);
|
||||
}
|
||||
*/
|
||||
//=================================================Глобальные команды удаленного управления===========================================================
|
||||
|
||||
void mqttOrderSend() {
|
||||
|
||||
String id = sCmd.next();
|
||||
String order = sCmd.next();
|
||||
|
||||
String all_line = jsonRead(configSetup, "mqttPrefix") + "/" + id + "/order";
|
||||
//Serial.print(all_line);
|
||||
//Serial.print("->");
|
||||
//Serial.println(order);
|
||||
int send_status = client.publish (all_line.c_str(), order.c_str(), false);
|
||||
}
|
||||
|
||||
void httpOrderSend() {
|
||||
|
||||
String ip = sCmd.next();
|
||||
String order = sCmd.next();
|
||||
order.replace("_", "%20");
|
||||
String url = "http://" + ip + "/cmd?command=" + order;
|
||||
getURL(url);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//==============================================================================================================================
|
||||
//============================выполнение команд (в лупе) по очереди из строки order=============================================
|
||||
void handleCMD_loop() {
|
||||
|
||||
if (order_loop != "") {
|
||||
|
||||
String tmp = selectToMarker(order_loop, ","); //выделяем из страки order первую команду rel 5 1,
|
||||
sCmd.readStr(tmp); //выполняем первую команду
|
||||
Serial.println("[ORDER] => " + order_loop);
|
||||
order_loop = deleteBeforeDelimiter(order_loop, ","); //осекаем выполненную команду
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================================================================================
|
||||
//=======================================================================================================================================
|
||||
void txtExecution(String file) {
|
||||
|
||||
String command_all = readFile(file, 2048) + "\r\n";
|
||||
|
||||
command_all.replace("\r\n", "\n");
|
||||
command_all.replace("\r", "\n");
|
||||
|
||||
while (command_all.length() != 0) {
|
||||
|
||||
String tmp = selectToMarker (command_all, "\n");
|
||||
sCmd.readStr(tmp);
|
||||
command_all = deleteBeforeDelimiter(command_all, "\n");
|
||||
}
|
||||
command_all = "";
|
||||
}
|
||||
|
||||
void stringExecution(String str) {
|
||||
|
||||
str = str + "\r\n";
|
||||
|
||||
str.replace("\r\n", "\n");
|
||||
str.replace("\r", "\n");
|
||||
|
||||
while (str.length() != 0) {
|
||||
|
||||
String tmp = selectToMarker (str, "\n");
|
||||
sCmd.readStr(tmp);
|
||||
str = deleteBeforeDelimiter(str, "\n");
|
||||
}
|
||||
}
|
||||
BIN
ESP32FS.rar
BIN
ESP32FS.rar
Binary file not shown.
Binary file not shown.
38
FS.ino
38
FS.ino
@@ -1,38 +0,0 @@
|
||||
void File_system_init() {
|
||||
|
||||
Serial.begin(115200);
|
||||
//Serial.setDebugOutput(true);
|
||||
Serial.println("--------------started----------------");
|
||||
//--------------------------------------------------------------
|
||||
SPIFFS.begin();
|
||||
configSetup = readFile("config.json", 4096);
|
||||
configSetup.replace(" ", "");
|
||||
configSetup.replace("\r\n", "");
|
||||
Serial.println(configSetup);
|
||||
jsonWriteStr(configJson, "name", jsonRead(configSetup, "name"));
|
||||
jsonWriteStr(configJson, "lang", jsonRead(configSetup, "lang"));
|
||||
|
||||
|
||||
#ifdef ESP32
|
||||
uint32_t chipID_u = ESP.getEfuseMac();
|
||||
chipID = String(chipID_u);
|
||||
jsonWriteStr(configSetup, "chipID", chipID);
|
||||
#endif
|
||||
|
||||
#ifdef ESP8266
|
||||
chipID = String( ESP.getChipId() ) + "-" + String(ESP.getFlashChipId());
|
||||
jsonWriteStr(configSetup, "chipID", chipID);
|
||||
Serial.setDebugOutput(0);
|
||||
#endif
|
||||
|
||||
jsonWriteStr(configSetup, "firmware_version", firmware_version);
|
||||
|
||||
prex = jsonRead(configSetup, "mqttPrefix") + "/" + chipID;
|
||||
Serial.println(chipID);
|
||||
|
||||
}
|
||||
|
||||
void get_esp_info() {
|
||||
|
||||
|
||||
}
|
||||
213
Init.ino
213
Init.ino
@@ -1,213 +0,0 @@
|
||||
void All_init() {
|
||||
|
||||
server.on("/init", HTTP_GET, [](AsyncWebServerRequest * request) {
|
||||
String value;
|
||||
if (request->hasArg("arg")) {
|
||||
value = request->getParam("arg")->value();
|
||||
}
|
||||
if (value == "0") {
|
||||
jsonWriteStr(configSetup, "scenario", value);
|
||||
saveConfig();
|
||||
Scenario_init();
|
||||
}
|
||||
if (value == "1") {
|
||||
jsonWriteStr(configSetup, "scenario", value);
|
||||
saveConfig();
|
||||
Scenario_init();
|
||||
}
|
||||
if (value == "2") {
|
||||
Device_init();
|
||||
}
|
||||
if (value == "3") {
|
||||
clean_log_date();
|
||||
}
|
||||
if (value == "4") {
|
||||
Scenario_init();
|
||||
}
|
||||
request->send(200, "text/text", "OK"); // отправляем ответ о выполнении
|
||||
});
|
||||
|
||||
prsets_init();
|
||||
Device_init();
|
||||
Scenario_init();
|
||||
Timer_countdown_init();
|
||||
}
|
||||
|
||||
void Device_init() {
|
||||
|
||||
ts.remove(ANALOG_);
|
||||
ts.remove(LEVEL);
|
||||
ts.remove(DALLAS);
|
||||
ts.remove(DHTT);
|
||||
ts.remove(DHTH);
|
||||
ts.remove(DHTC);
|
||||
ts.remove(DHTP);
|
||||
ts.remove(DHTD);
|
||||
ts.remove(STEPPER1);
|
||||
ts.remove(STEPPER2);
|
||||
|
||||
#ifdef layout_in_ram
|
||||
all_widgets = "";
|
||||
#else
|
||||
SPIFFS.remove("/layout.txt");
|
||||
#endif
|
||||
|
||||
txtExecution("firmware.c.txt");
|
||||
//outcoming_date();
|
||||
}
|
||||
//-------------------------------сценарии-----------------------------------------------------
|
||||
|
||||
void Scenario_init() {
|
||||
if (jsonRead(configSetup, "scenario") == "1") {
|
||||
scenario = readFile("firmware.s.txt", 2048);
|
||||
}
|
||||
}
|
||||
|
||||
void prsets_init() {
|
||||
server.on("/preset", HTTP_GET, [](AsyncWebServerRequest * request) {
|
||||
String value;
|
||||
if (request->hasArg("arg")) {
|
||||
value = request->getParam("arg")->value();
|
||||
}
|
||||
if (value == "1") {
|
||||
writeFile("firmware.c.txt", readFile("configs/relay.c.txt", 2048));
|
||||
writeFile("firmware.s.txt", readFile("configs/relay.s.txt", 2048));
|
||||
}
|
||||
if (value == "2") {
|
||||
writeFile("firmware.c.txt", readFile("configs/relay_t.c.txt", 2048));
|
||||
writeFile("firmware.s.txt", readFile("configs/relay_t.s.txt", 2048));
|
||||
}
|
||||
if (value == "3") {
|
||||
writeFile("firmware.c.txt", readFile("configs/relay_c.c.txt", 2048));
|
||||
writeFile("firmware.s.txt", readFile("configs/relay_c.s.txt", 2048));
|
||||
}
|
||||
if (value == "4") {
|
||||
writeFile("firmware.c.txt", readFile("configs/relay_s.c.txt", 2048));
|
||||
writeFile("firmware.s.txt", readFile("configs/relay_s.s.txt", 2048));
|
||||
}
|
||||
if (value == "5") {
|
||||
writeFile("firmware.c.txt", readFile("configs/relay_sw.c.txt", 2048));
|
||||
writeFile("firmware.s.txt", readFile("configs/relay_sw.s.txt", 2048));
|
||||
}
|
||||
if (value == "6") {
|
||||
writeFile("firmware.c.txt", readFile("configs/relay_br.c.txt", 2048));
|
||||
writeFile("firmware.s.txt", readFile("configs/relay_br.s.txt", 2048));
|
||||
}
|
||||
if (value == "7") {
|
||||
writeFile("firmware.c.txt", readFile("configs/relay_sr.c.txt", 2048));
|
||||
writeFile("firmware.s.txt", readFile("configs/relay_sr.s.txt", 2048));
|
||||
}
|
||||
if (value == "8") {
|
||||
writeFile("firmware.c.txt", readFile("configs/pwm.c.txt", 2048));
|
||||
writeFile("firmware.s.txt", readFile("configs/pwm.s.txt", 2048));
|
||||
}
|
||||
if (value == "9") {
|
||||
writeFile("firmware.c.txt", readFile("configs/dht11.c.txt", 2048));
|
||||
writeFile("firmware.s.txt", readFile("configs/dht11.s.txt", 2048));
|
||||
}
|
||||
if (value == "10") {
|
||||
writeFile("firmware.c.txt", readFile("configs/dht22.c.txt", 2048));
|
||||
writeFile("firmware.s.txt", readFile("configs/dht22.s.txt", 2048));
|
||||
}
|
||||
if (value == "11") {
|
||||
writeFile("firmware.c.txt", readFile("configs/analog.c.txt", 2048));
|
||||
writeFile("firmware.s.txt", readFile("configs/analog.s.txt", 2048));
|
||||
}
|
||||
if (value == "12") {
|
||||
writeFile("firmware.c.txt", readFile("configs/dallas.c.txt", 2048));
|
||||
writeFile("firmware.s.txt", readFile("configs/dallas.s.txt", 2048));
|
||||
}
|
||||
if (value == "13") {
|
||||
writeFile("firmware.c.txt", readFile("configs/termostat.c.txt", 2048));
|
||||
writeFile("firmware.s.txt", readFile("configs/termostat.s.txt", 2048));
|
||||
}
|
||||
if (value == "14") {
|
||||
writeFile("firmware.c.txt", readFile("configs/level.c.txt", 2048));
|
||||
writeFile("firmware.s.txt", readFile("configs/level.s.txt", 2048));
|
||||
}
|
||||
if (value == "15") {
|
||||
writeFile("firmware.c.txt", readFile("configs/moution_r.c.txt", 2048));
|
||||
writeFile("firmware.s.txt", readFile("configs/moution_r.s.txt", 2048));
|
||||
}
|
||||
if (value == "16") {
|
||||
writeFile("firmware.c.txt", readFile("configs/moution_s.c.txt", 2048));
|
||||
writeFile("firmware.s.txt", readFile("configs/moution_s.s.txt", 2048));
|
||||
}
|
||||
if (value == "17") {
|
||||
writeFile("firmware.c.txt", readFile("configs/stepper.c.txt", 2048));
|
||||
writeFile("firmware.s.txt", readFile("configs/stepper.s.txt", 2048));
|
||||
}
|
||||
if (value == "18") {
|
||||
writeFile("firmware.c.txt", readFile("configs/firmware.c.txt", 2048));
|
||||
writeFile("firmware.s.txt", readFile("configs/firmware.s.txt", 2048));
|
||||
}
|
||||
Device_init();
|
||||
Scenario_init();
|
||||
request->redirect("/?configuration");
|
||||
});
|
||||
}
|
||||
|
||||
void up_time() {
|
||||
uint32_t ss = millis() / 1000;
|
||||
uint32_t mm = ss / 60;
|
||||
uint32_t hh = mm / 60;
|
||||
uint32_t dd = hh / 24;
|
||||
|
||||
String out = "";
|
||||
|
||||
if (ss != 0) {
|
||||
out = "[i] uptime = " + String(ss) + " sec";
|
||||
jsonWriteStr(configJson, "uptime", String(ss) + " sec");
|
||||
}
|
||||
if (mm != 0) {
|
||||
out = "[i] uptime = " + String(mm) + " min";
|
||||
jsonWriteStr(configJson, "uptime", String(mm) + " min");
|
||||
}
|
||||
if (hh != 0) {
|
||||
out = "[i] uptime = " + String(hh) + " hours";
|
||||
jsonWriteStr(configJson, "uptime", String(hh) + " hours");
|
||||
}
|
||||
if (dd != 0) {
|
||||
out = "[i] uptime = " + String(dd) + " days";
|
||||
jsonWriteStr(configJson, "uptime", String(dd) + " days");
|
||||
}
|
||||
Serial.println(out + ", mqtt_lost_error: " + String(mqtt_lost_error) + ", wifi_lost_error: " + String(wifi_lost_error));
|
||||
}
|
||||
|
||||
void statistics_init() {
|
||||
ts.add(STATISTICS, statistics_update, [&](void*) {
|
||||
|
||||
statistics();
|
||||
|
||||
}, nullptr, true);
|
||||
}
|
||||
|
||||
void statistics() {
|
||||
if (WiFi.status() == WL_CONNECTED) {
|
||||
String urls = "http://backup.privet.lv/visitors/?";
|
||||
//-----------------------------------------------------------------
|
||||
urls += WiFi.macAddress().c_str();
|
||||
urls += "&";
|
||||
//-----------------------------------------------------------------
|
||||
#ifdef ESP8266
|
||||
urls += "iot-manager_esp8266";
|
||||
#endif
|
||||
#ifdef ESP32
|
||||
urls += "iot-manager_esp32";
|
||||
#endif
|
||||
urls += "&";
|
||||
//-----------------------------------------------------------------
|
||||
#ifdef ESP8266
|
||||
urls += ESP.getResetReason();
|
||||
#endif
|
||||
#ifdef ESP32
|
||||
urls += "Unknown";
|
||||
#endif
|
||||
urls += "&";
|
||||
//-----------------------------------------------------------------
|
||||
urls += "firm version: " + firmware_version + " " + DATE_COMPILING + " " + TIME_COMPILING;
|
||||
//-----------------------------------------------------------------
|
||||
String stat = getURL(urls);
|
||||
//Serial.println(stat);
|
||||
}
|
||||
}
|
||||
171
Logging.ino
171
Logging.ino
@@ -1,171 +0,0 @@
|
||||
//===============================================Логирование============================================================
|
||||
void logging() {
|
||||
|
||||
static boolean flag = true;
|
||||
|
||||
String sensor_name = sCmd.next();
|
||||
String period_min = sCmd.next();
|
||||
String maxCount = sCmd.next();
|
||||
|
||||
String optimozation = sCmd.next();
|
||||
|
||||
String widget_name = sCmd.next();
|
||||
widget_name.replace("#", " ");
|
||||
String page_name = sCmd.next();
|
||||
String page_number = sCmd.next();
|
||||
|
||||
if (optimozation == "fast") chart_data_in_solid_array = true;
|
||||
if (optimozation == "slow") chart_data_in_solid_array = false;
|
||||
|
||||
if (sensor_name == "analog") jsonWriteStr(optionJson, "analog_logging_count", maxCount);
|
||||
if (sensor_name == "level") jsonWriteStr(optionJson, "level_logging_count", maxCount);
|
||||
if (sensor_name == "dallas") jsonWriteStr(optionJson, "dallas_logging_count", maxCount);
|
||||
if (sensor_name == "dhtT") jsonWriteStr(optionJson, "dhtT_logging_count", maxCount);
|
||||
if (sensor_name == "dhtH") jsonWriteStr(optionJson, "dhtH_logging_count", maxCount);
|
||||
|
||||
if (sensor_name == "analog") createChart (widget_name, page_name, page_number, "widgets/widget.chart.json", "loganalog", maxCount);
|
||||
if (sensor_name == "level") createChart (widget_name, page_name, page_number, "widgets/widget.chart.json", "loglevel", maxCount);
|
||||
if (sensor_name == "dallas") createChart (widget_name, page_name, page_number, "widgets/widget.chart.json", "logdallas", maxCount);
|
||||
if (sensor_name == "dhtT") createChart (widget_name, page_name, page_number, "widgets/widget.chart.json", "logdhtT", maxCount);
|
||||
if (sensor_name == "dhtH") createChart (widget_name, page_name, page_number, "widgets/widget.chart.json", "logdhtH", maxCount);
|
||||
|
||||
if (sensor_name == "analog") {
|
||||
flagLoggingAnalog = true;
|
||||
ts.remove(ANALOG_LOG);
|
||||
ts.add(ANALOG_LOG, period_min.toInt() * 1000 * 60, [&](void*) {
|
||||
deleteOldDate("log.analog.txt", jsonReadtoInt(optionJson, "analog_logging_count"), jsonRead(configJson, "analog"));
|
||||
}, nullptr, true);
|
||||
}
|
||||
|
||||
if (sensor_name == "level") {
|
||||
flagLoggingLevel = true;
|
||||
ts.remove(LEVEL_LOG);
|
||||
ts.add(LEVEL_LOG, period_min.toInt() * 1000 * 60, [&](void*) {
|
||||
deleteOldDate("log.level.txt", jsonReadtoInt(optionJson, "level_logging_count"), jsonRead(configJson, "level"));
|
||||
}, nullptr, true);
|
||||
}
|
||||
|
||||
if (sensor_name == "dallas") {
|
||||
flagLoggingDallas = true;
|
||||
ts.remove(DALLAS_LOG);
|
||||
ts.add(DALLAS_LOG, period_min.toInt() * 1000 * 60, [&](void*) {
|
||||
deleteOldDate("log.dallas.txt", jsonReadtoInt(optionJson, "dallas_logging_count"), jsonRead(configJson, "dallas"));
|
||||
}, nullptr, true);
|
||||
}
|
||||
|
||||
if (sensor_name == "dhtT") {
|
||||
flagLoggingdhtT = true;
|
||||
ts.remove(dhtT_LOG);
|
||||
ts.add(dhtT_LOG, period_min.toInt() * 1000 * 60, [&](void*) {
|
||||
deleteOldDate("log.dhtT.txt", jsonReadtoInt(optionJson, "dhtT_logging_count"), jsonRead(configJson, "dhtT"));
|
||||
}, nullptr, true);
|
||||
}
|
||||
|
||||
if (sensor_name == "dhtH") {
|
||||
flagLoggingdhtH = true;
|
||||
ts.remove(dhtH_LOG);
|
||||
ts.add(dhtH_LOG, period_min.toInt() * 1000 * 60, [&](void*) {
|
||||
deleteOldDate("log.dhtH.txt", jsonReadtoInt(optionJson, "dhtH_logging_count"), jsonRead(configJson, "dhtH"));
|
||||
}, nullptr, true);
|
||||
}
|
||||
}
|
||||
|
||||
//=========================================Удаление стрых данных и запись новых==================================================================
|
||||
void deleteOldDate(String file, int seted_number_of_lines, String date_to_add) {
|
||||
String log_date = readFile(file, 5000);
|
||||
int current_number_of_lines = count(log_date, "\r\n");
|
||||
Serial.println("=====> [i] in log file " + file + " " + current_number_of_lines + " lines");
|
||||
|
||||
if (current_number_of_lines > seted_number_of_lines + 1) {
|
||||
SPIFFS.remove("/" + file);
|
||||
current_number_of_lines = 0;
|
||||
}
|
||||
if (current_number_of_lines == 0) {
|
||||
SPIFFS.remove("/" + file);
|
||||
current_number_of_lines = 0;
|
||||
}
|
||||
if (current_number_of_lines > seted_number_of_lines) {
|
||||
log_date = deleteBeforeDelimiter(log_date, "\r\n");
|
||||
if (GetTimeUnix() != "failed") {
|
||||
log_date += GetTimeUnix() + " " + date_to_add + "\r\n";
|
||||
writeFile(file, log_date);
|
||||
}
|
||||
} else {
|
||||
if (GetTimeUnix() != "failed") {
|
||||
addFile(file, GetTimeUnix() + " " + date_to_add);
|
||||
}
|
||||
}
|
||||
log_date = "";
|
||||
}
|
||||
|
||||
//=========================================Выбор какие данные отправлять==================================================================
|
||||
void choose_log_date_and_send() {
|
||||
|
||||
if (flagLoggingAnalog) sendLogData("log.analog.txt", "loganalog", chart_data_in_solid_array);
|
||||
if (flagLoggingLevel) sendLogData("log.level.txt", "loglevel", chart_data_in_solid_array);
|
||||
if (flagLoggingDallas) sendLogData("log.dallas.txt", "logdallas", chart_data_in_solid_array);
|
||||
if (flagLoggingdhtT) sendLogData("log.dhtT.txt", "logdhtT", chart_data_in_solid_array);
|
||||
if (flagLoggingdhtH) sendLogData("log.dhtH.txt", "logdhtH", chart_data_in_solid_array);
|
||||
}
|
||||
|
||||
//=========================================Отправка данных===================================================================================
|
||||
void sendLogData(String file, String topic, boolean type) {
|
||||
if (type) {
|
||||
//----------------------------------------------
|
||||
String log_date = readFile(file, 5000);
|
||||
log_date.replace("\r\n", "\n");
|
||||
log_date.replace("\r", "\n");
|
||||
String buf = "{}";
|
||||
String json_array;
|
||||
String unix_time;
|
||||
String value;
|
||||
while (log_date.length() != 0) {
|
||||
String tmp = selectToMarker (log_date, "\n");
|
||||
log_date = deleteBeforeDelimiter(log_date, "\n");
|
||||
unix_time = selectToMarker (tmp, " ");
|
||||
jsonWriteInt(buf, "x", unix_time.toInt());
|
||||
value = deleteBeforeDelimiter(tmp, " ");
|
||||
jsonWriteFloat(buf, "y1", value.toFloat());
|
||||
if (log_date.length() < 3) {
|
||||
json_array += buf;
|
||||
} else {
|
||||
json_array += buf + ",";
|
||||
}
|
||||
buf = "{}";
|
||||
}
|
||||
unix_time = "";
|
||||
value = "";
|
||||
log_date = "";
|
||||
json_array = "{\"status\":[" + json_array + "]}";
|
||||
Serial.println(json_array);
|
||||
sendCHART(topic, json_array);
|
||||
json_array = "";
|
||||
getMemoryLoad("[i] after send log date");
|
||||
//----------------------------------------------
|
||||
} else {
|
||||
//----------------------------------------------
|
||||
File configFile = SPIFFS.open("/" + file, "r");
|
||||
if (!configFile) {
|
||||
return;
|
||||
}
|
||||
configFile.seek(0, SeekSet); //поставим курсор в начало файла
|
||||
while (configFile.position() != configFile.size()) {
|
||||
String tmp = configFile.readStringUntil('\r\n');
|
||||
String unix_time = selectToMarker (tmp, " ");
|
||||
String value = deleteBeforeDelimiter(tmp, " ");
|
||||
String final_line = "{\"status\":{\"x\":" + unix_time + ",\"y1\":" + value + "}}";
|
||||
//Serial.println(final_line);
|
||||
sendCHART(topic, final_line);
|
||||
}
|
||||
getMemoryLoad("[i] after send log date");
|
||||
}
|
||||
//----------------------------------------------
|
||||
}
|
||||
//=========================================Очистка данных===================================================================================
|
||||
void clean_log_date() {
|
||||
SPIFFS.remove("/log.analog.txt");
|
||||
SPIFFS.remove("/log.level.txt");
|
||||
SPIFFS.remove("/log.dallas.txt");
|
||||
SPIFFS.remove("/log.dhtT.txt");
|
||||
SPIFFS.remove("/log.dhtH.txt");
|
||||
}
|
||||
6
README.md
Normal file
6
README.md
Normal file
@@ -0,0 +1,6 @@
|
||||
# IoTManager
|
||||
Это модульная система беспроводной автоматизации на базе ESP32/ESP8266 микроконтроллеров и приложения IoT Manager.
|
||||
Телеграм канал обсуждения приложения и системы автоматизации https://t.me/IoTmanager
|
||||
# [Инструкция](https://github.com/IoTManagerProject/IoTManager/wiki)
|
||||
|
||||

|
||||
98
Scenario.ino
98
Scenario.ino
@@ -1,98 +0,0 @@
|
||||
void handleScenario() {
|
||||
|
||||
if (jsonRead(configSetup, "scenario") == "1") {
|
||||
if ((jsonRead(optionJson, "scenario_status") != "")) {
|
||||
int i = 0;
|
||||
String str = scenario; //читаем переменную с сценариями (то что из файла на странице)
|
||||
str += "\n";
|
||||
str.replace("\r\n", "\n");
|
||||
str.replace("\r", "\n");
|
||||
while (str.length() != 0) {
|
||||
//-----------------------------------------------------------------------------------------------------------------------
|
||||
String tmp = selectToMarker (str, "end"); //выделяем первый сценарий из файла вместе с командами
|
||||
if (tmp == "") return;
|
||||
i++;
|
||||
|
||||
if (scenario_line_status[i] == 1) {
|
||||
//Serial.println(i);
|
||||
String condition = selectToMarker (tmp, "\n"); //выделяем первую строку самого сценария button1 = 1 (условие)
|
||||
String param_name = selectFromMarkerToMarker(condition, " " , 0);
|
||||
param_name = add_set(param_name); //из первой страки берем имя параметра button1 и вставляем в него Set и получаем buttonSet1
|
||||
if (param_name.indexOf("timenow") != -1){
|
||||
param_name = param_name + "Set";
|
||||
}
|
||||
String order = jsonRead(optionJson, "scenario_status"); //читаем весь файл событий
|
||||
String param = selectToMarker (order, ","); //читаем первое событие из файла событий
|
||||
if (param_name == param) { //если поступившее событие равно событию заданному buttonSet1 в файле начинаем его обработку
|
||||
|
||||
String sign = selectFromMarkerToMarker(condition, " " , 1); //читаем знак (=)
|
||||
String value = selectFromMarkerToMarker(condition, " " , 2); //читаем значение (1)
|
||||
if (value.indexOf("digit") != -1) {
|
||||
value = add_set(value);
|
||||
value = jsonRead(configJson, value);
|
||||
}
|
||||
if (value.indexOf("time") != -1) {
|
||||
value = add_set(value);
|
||||
value = jsonRead(configJson, value);
|
||||
}
|
||||
boolean flag = false; //если одно из значений совпало то только тогда начинаем выполнять комнады
|
||||
if (sign == "=") {
|
||||
if (jsonRead(configJson, param_name) == value) flag = true;
|
||||
}
|
||||
if (sign == "!=") {
|
||||
if (jsonRead(configJson, param_name) != value) flag = true;
|
||||
}
|
||||
if (sign == "<") {
|
||||
if (jsonRead(configJson, param_name).toInt() < value.toInt()) flag = true;
|
||||
}
|
||||
if (sign == ">") {
|
||||
if (jsonRead(configJson, param_name).toInt() > value.toInt()) flag = true;
|
||||
}
|
||||
if (sign == ">=") {
|
||||
if (jsonRead(configJson, param_name).toInt() >= value.toInt()) flag = true;
|
||||
}
|
||||
if (sign == "<=") {
|
||||
if (jsonRead(configJson, param_name).toInt() <= value.toInt()) flag = true;
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
tmp = deleteBeforeDelimiter(tmp, "\n"); //удаляем строку самого сценария оставляя только команды
|
||||
stringExecution(tmp); //выполняем все команды
|
||||
|
||||
Serial.println("[SCENARIO] '" + condition + "'");
|
||||
//Serial.println(" " + tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
str = deleteBeforeDelimiter(str, "end\n"); //удаляем первый сценарий
|
||||
//-----------------------------------------------------------------------------------------------------------------------
|
||||
}
|
||||
String tmp2 = jsonRead(optionJson, "scenario_status"); //читаем файл событий
|
||||
tmp2 = deleteBeforeDelimiter(tmp2, ","); //удаляем выполненное событие
|
||||
jsonWriteStr(optionJson, "scenario_status", tmp2); //записываем обновленный файл событий
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void eventGen (String event_name, String number) { //событие выглядит как имя плюс set плюс номер: button+Set+1
|
||||
|
||||
if (jsonRead(configSetup, "scenario") == "1") {
|
||||
String tmp = jsonRead(optionJson, "scenario_status") ; //генерирование события
|
||||
//Serial.println(event_name);
|
||||
jsonWriteStr(optionJson, "scenario_status", tmp + event_name + number + ",");
|
||||
}
|
||||
}
|
||||
|
||||
String add_set(String param_name) {
|
||||
String num1 = param_name.substring(param_name.length() - 1);
|
||||
String num2 = param_name.substring(param_name.length() - 2, param_name.length() - 1);
|
||||
if (isDigitStr(num1) && isDigitStr(num2)) {
|
||||
param_name = param_name.substring(0, param_name.length() - 2) + "Set" + num2 + num1;
|
||||
} else {
|
||||
if (isDigitStr(num1)) {
|
||||
param_name = param_name.substring(0, param_name.length() - 1) + "Set" + num1;
|
||||
}
|
||||
}
|
||||
return param_name;
|
||||
}
|
||||
323
Sensors.ino
323
Sensors.ino
@@ -1,323 +0,0 @@
|
||||
//===============================================================================================================================
|
||||
//=========================================Модуль аналогового сенсора============================================================
|
||||
void analog() {
|
||||
String pin = sCmd.next();
|
||||
String widget_name = sCmd.next();
|
||||
String page_name = sCmd.next();
|
||||
String type = sCmd.next();
|
||||
String analog_start = sCmd.next();
|
||||
String analog_end = sCmd.next();
|
||||
String analog_start_out = sCmd.next();
|
||||
String analog_end_out = sCmd.next();
|
||||
String page_number = sCmd.next();
|
||||
jsonWriteStr(optionJson, "analog_start", analog_start);
|
||||
jsonWriteStr(optionJson, "analog_end", analog_end);
|
||||
jsonWriteStr(optionJson, "analog_start_out", analog_start_out);
|
||||
jsonWriteStr(optionJson, "analog_end_out", analog_end_out);
|
||||
choose_widget_and_create(widget_name, page_name, page_number, type, "analog");
|
||||
ts.add(ANALOG_, analog_update_int, [&](void*) {
|
||||
static int analog_old;
|
||||
#ifdef ESP32
|
||||
//int pin_int = pin.toInt();
|
||||
int analog_in = analogRead(34);
|
||||
#endif
|
||||
#ifdef ESP8266
|
||||
int analog_in = analogRead(A0);
|
||||
#endif
|
||||
jsonWriteInt(configJson, "analog_in", analog_in);
|
||||
int analog = map(analog_in,
|
||||
jsonReadtoInt(optionJson, "analog_start") ,
|
||||
jsonReadtoInt(optionJson, "analog_end"),
|
||||
jsonReadtoInt(optionJson, "analog_start_out"),
|
||||
jsonReadtoInt(optionJson, "analog_end_out"));
|
||||
jsonWriteInt(configJson, "analog", analog);
|
||||
// if (analog_old != analog) {
|
||||
eventGen ("analog", "");
|
||||
sendSTATUS("analog", String(analog));
|
||||
if (client.connected()) {
|
||||
Serial.println("[i] sensor 'analog' send date " + String(analog));
|
||||
}
|
||||
// }
|
||||
analog_old = analog;
|
||||
}, nullptr, true);
|
||||
}
|
||||
|
||||
//===================================================================================================================================
|
||||
//=========================================Модуль измерения уровня в баке============================================================
|
||||
void level() {
|
||||
String widget_name = sCmd.next();
|
||||
String page_name = sCmd.next();
|
||||
String type = sCmd.next();
|
||||
String empty_level = sCmd.next();
|
||||
String full_level = sCmd.next();
|
||||
String page_number = sCmd.next();
|
||||
jsonWriteStr(optionJson, "empty_level", empty_level);
|
||||
jsonWriteStr(optionJson, "full_level", full_level);
|
||||
pinMode(14, OUTPUT);
|
||||
pinMode(12, INPUT);
|
||||
choose_widget_and_create(widget_name, page_name, page_number, type, "level");
|
||||
ts.add(LEVEL, tank_level_shooting_interval, [&](void*) {
|
||||
long duration_;
|
||||
int distance_cm;
|
||||
int level;
|
||||
static int level_old; //переменная static сохраняет свое значение между вызовами функции
|
||||
static int counter;
|
||||
digitalWrite(14, LOW);
|
||||
delayMicroseconds(2);
|
||||
digitalWrite(14, HIGH);
|
||||
delayMicroseconds(10);
|
||||
digitalWrite(14, LOW);
|
||||
duration_ = pulseIn(12, HIGH, 30000); // 3000 µs = 50cm // 30000 µs = 5 m
|
||||
distance_cm = duration_ / 29 / 2;
|
||||
distance_cm = medianFilter.filtered(distance_cm);//отсечение промахов медианным фильтром
|
||||
counter++;
|
||||
if (counter > tank_level_times_to_send) {
|
||||
counter = 0;
|
||||
jsonWriteInt(configJson, "level_in", distance_cm);
|
||||
level = map(distance_cm,
|
||||
jsonReadtoInt(optionJson, "empty_level"),
|
||||
jsonReadtoInt(optionJson, "full_level"), 0, 100);
|
||||
jsonWriteInt(configJson, "level", level);
|
||||
//if (level_old != level) {
|
||||
eventGen ("level", "");
|
||||
sendSTATUS("level", String(level));
|
||||
if (client.connected()) {
|
||||
Serial.println("[i] sensor tank 'level' send date " + String(level));
|
||||
}
|
||||
//}
|
||||
level_old = level;
|
||||
}
|
||||
}, nullptr, true);
|
||||
}
|
||||
|
||||
//==========================================================================================================================================
|
||||
//=========================================Модуль температурного сенсора ds18b20============================================================
|
||||
void dallas() {
|
||||
String pin = sCmd.next();
|
||||
String widget_name = sCmd.next();
|
||||
String page_name = sCmd.next();
|
||||
String type = sCmd.next();
|
||||
String page_number = sCmd.next();
|
||||
oneWire = new OneWire((uint8_t) pin.toInt());
|
||||
sensors.setOneWire(oneWire);
|
||||
sensors.begin();
|
||||
sensors.setResolution(12);
|
||||
choose_widget_and_create(widget_name, page_name, page_number, type, "dallas");
|
||||
ts.add(DALLAS, temp_update_int, [&](void*) {
|
||||
float temp = 0;
|
||||
static float temp_old;
|
||||
sensors.requestTemperatures();
|
||||
temp = sensors.getTempCByIndex(0);
|
||||
jsonWriteStr(configJson, "dallas", String(temp));
|
||||
//if (temp_old != temp) {
|
||||
eventGen ("dallas", "");
|
||||
sendSTATUS("dallas", String(temp));
|
||||
if (client.connected()) {
|
||||
Serial.println("[i] sensor 'dallas' send date " + String(temp));
|
||||
}
|
||||
//}
|
||||
temp_old = temp;
|
||||
}, nullptr, true);
|
||||
}
|
||||
|
||||
|
||||
//======================================================================================================================
|
||||
//=========================================Модуль сенсоров DHT==========================================================
|
||||
void dhtT() {
|
||||
String sensor_type = sCmd.next();
|
||||
String pin = sCmd.next();
|
||||
String widget_name = sCmd.next();
|
||||
String page_name = sCmd.next();
|
||||
String type = sCmd.next();
|
||||
String page_number = sCmd.next();
|
||||
if (sensor_type == "DHT11") {
|
||||
dht.setup(pin.toInt(), DHTesp::DHT11);
|
||||
}
|
||||
if (sensor_type == "DHT22") {
|
||||
dht.setup(pin.toInt(), DHTesp::DHT22);
|
||||
}
|
||||
choose_widget_and_create(widget_name, page_name, page_number, type, "dhtT");
|
||||
ts.add(DHTT, dhtT_update_int, [&](void*) { //dht.getMinimumSamplingPeriod()
|
||||
float value = 0;
|
||||
static float value_old;
|
||||
static int counter;
|
||||
if (dht.getStatus() != 0 && counter < 5) {
|
||||
sendSTATUS("dhtT", String(dht.getStatusString()));
|
||||
counter++;
|
||||
} else {
|
||||
counter = 0;
|
||||
value = dht.getTemperature();
|
||||
//if (value_old != value) {
|
||||
if (String(value) != "nan") {
|
||||
eventGen ("dhtT", "");
|
||||
jsonWriteStr(configJson, "dhtT", String(value));
|
||||
sendSTATUS("dhtT", String(value));
|
||||
if (client.connected()) {
|
||||
Serial.println("[i] sensor 'dhtT' send date " + String(value));
|
||||
}
|
||||
//}
|
||||
}
|
||||
value_old = value;
|
||||
}
|
||||
}, nullptr, true);
|
||||
}
|
||||
|
||||
|
||||
void dhtH() {
|
||||
String sensor_type = sCmd.next();
|
||||
String pin = sCmd.next();
|
||||
String widget_name = sCmd.next();
|
||||
String page_name = sCmd.next();
|
||||
String type = sCmd.next();
|
||||
String page_number = sCmd.next();
|
||||
if (sensor_type == "DHT11") {
|
||||
dht.setup(pin.toInt(), DHTesp::DHT11);
|
||||
}
|
||||
if (sensor_type == "DHT22") {
|
||||
dht.setup(pin.toInt(), DHTesp::DHT22);
|
||||
}
|
||||
choose_widget_and_create(widget_name, page_name, page_number, type, "dhtH");
|
||||
ts.add(DHTH, dhtH_update_int , [&](void*) { //dht.getMinimumSamplingPeriod()
|
||||
int value = 0;
|
||||
static int value_old;
|
||||
static int counter;
|
||||
if (dht.getStatus() != 0 && counter < 5) {
|
||||
sendSTATUS("dhtH", String(dht.getStatusString()));
|
||||
counter++;
|
||||
} else {
|
||||
counter = 0;
|
||||
value = dht.getHumidity();
|
||||
if (String(value) != "nan" || value <= 100 || value >= 0) {
|
||||
//if (value_old != value) {
|
||||
eventGen ("dhtH", "");
|
||||
jsonWriteStr(configJson, "dhtH", String(value));
|
||||
sendSTATUS("dhtH", String(value));
|
||||
if (client.connected()) {
|
||||
Serial.println("[i] sensor 'dhtH' send date " + String(value));
|
||||
}
|
||||
//}
|
||||
}
|
||||
value_old = value;
|
||||
}
|
||||
}, nullptr, true);
|
||||
}
|
||||
|
||||
void dhtPerception() {
|
||||
String widget_name = sCmd.next();
|
||||
String page_name = sCmd.next();
|
||||
String page_number = sCmd.next();
|
||||
choose_widget_and_create(widget_name, page_name, page_number, "any-data", "dhtPerception");
|
||||
ts.add(DHTP, dht_calculation_update_int, [&](void*) {
|
||||
byte value;
|
||||
if (dht.getStatus() != 0) {
|
||||
sendSTATUS("dhtPerception", String(dht.getStatusString()));
|
||||
} else {
|
||||
value = dht.computePerception(jsonRead(configJson, "dhtT").toFloat(), jsonRead(configJson, "dhtH").toFloat(), false);
|
||||
String final_line = perception(value);
|
||||
jsonWriteStr(configJson, "dhtPerception", final_line);
|
||||
eventGen ("dhtPerception", "");
|
||||
sendSTATUS("dhtPerception", final_line);
|
||||
if (client.connected()) {
|
||||
Serial.println("[i] sensor 'dhtPerception' send date " + final_line);
|
||||
}
|
||||
}
|
||||
}, nullptr, true);
|
||||
}
|
||||
|
||||
String perception(byte value) {
|
||||
if (value == 0) return "Сухой воздух";
|
||||
if (value == 1) return "Комфортно";
|
||||
if (value == 2) return "Уютно";
|
||||
if (value == 3) return "Хорошо";
|
||||
if (value == 4) return "Неудобно";
|
||||
if (value == 5) return "Довольно неудобно";
|
||||
if (value == 6) return "Очень неудобно";
|
||||
if (value == 7) return "Сильно неудобно, полный звиздец";
|
||||
}
|
||||
|
||||
void dhtComfort() {
|
||||
String widget_name = sCmd.next();
|
||||
String page_name = sCmd.next();
|
||||
String page_number = sCmd.next();
|
||||
choose_widget_and_create(widget_name, page_name, page_number, "any-data", "dhtComfort");
|
||||
ts.add(DHTC, dht_calculation_update_int, [&](void*) {
|
||||
float value;
|
||||
ComfortState cf;
|
||||
if (dht.getStatus() != 0) {
|
||||
sendSTATUS("dhtComfort", String(dht.getStatusString()));
|
||||
} else {
|
||||
value = dht.getComfortRatio(cf, jsonRead(configJson, "dhtT").toFloat(), jsonRead(configJson, "dhtH").toFloat(), false);
|
||||
String comfortStatus;
|
||||
switch (cf) {
|
||||
case Comfort_OK:
|
||||
comfortStatus = "Отлично";
|
||||
break;
|
||||
case Comfort_TooHot:
|
||||
comfortStatus = "Очень жарко";
|
||||
break;
|
||||
case Comfort_TooCold:
|
||||
comfortStatus = "Очень холодно";
|
||||
break;
|
||||
case Comfort_TooDry:
|
||||
comfortStatus = "Очень сухо";
|
||||
break;
|
||||
case Comfort_TooHumid:
|
||||
comfortStatus = "Очень влажно";
|
||||
break;
|
||||
case Comfort_HotAndHumid:
|
||||
comfortStatus = "Жарко и влажно";
|
||||
break;
|
||||
case Comfort_HotAndDry:
|
||||
comfortStatus = "Жарко и сухо";
|
||||
break;
|
||||
case Comfort_ColdAndHumid:
|
||||
comfortStatus = "Холодно и влажно";
|
||||
break;
|
||||
case Comfort_ColdAndDry:
|
||||
comfortStatus = "Холодно и сухо";
|
||||
break;
|
||||
default:
|
||||
comfortStatus = "Неизвестно";
|
||||
break;
|
||||
};
|
||||
String final_line = comfortStatus;
|
||||
jsonWriteStr(configJson, "dhtComfort", final_line);
|
||||
eventGen ("dhtComfort", "");
|
||||
sendSTATUS("dhtComfort", final_line);
|
||||
if (client.connected()) {
|
||||
Serial.println("[i] sensor 'dhtComfort' send date " + final_line);
|
||||
}
|
||||
}
|
||||
}, nullptr, true);
|
||||
}
|
||||
|
||||
void dhtDewpoint() {
|
||||
String widget_name = sCmd.next();
|
||||
String page_name = sCmd.next();
|
||||
String page_number = sCmd.next();
|
||||
choose_widget_and_create(widget_name, page_name, page_number, "any-data", "dhtDewpoint");
|
||||
ts.add(DHTD, dht_calculation_update_int, [&](void*) {
|
||||
float value;
|
||||
if (dht.getStatus() != 0) {
|
||||
sendSTATUS("dhtDewpoint", String(dht.getStatusString()));
|
||||
} else {
|
||||
value = dht.computeDewPoint(jsonRead(configJson, "dhtT").toFloat(), jsonRead(configJson, "dhtH").toFloat(), false);
|
||||
jsonWriteInt(configJson, "dhtDewpoint", value);
|
||||
eventGen ("dhtDewpoint", "");
|
||||
sendSTATUS("dhtDewpoint", String(value));
|
||||
if (client.connected()) {
|
||||
Serial.println("[i] sensor 'dhtDewpoint' send date " + String(value));
|
||||
}
|
||||
}
|
||||
}, nullptr, true);
|
||||
}
|
||||
|
||||
|
||||
void choose_widget_and_create(String widget_name, String page_name, String page_number, String type, String topik) {
|
||||
|
||||
if (type == "any-data") createWidget (widget_name, page_name, page_number, "widgets/widget.anyData.json", topik);
|
||||
if (type == "progress-line") createWidget (widget_name, page_name, page_number, "widgets/widget.progLine.json", topik);
|
||||
if (type == "progress-round") createWidget (widget_name, page_name, page_number, "widgets/widget.progRound.json", topik);
|
||||
if (type == "fill-gauge") createWidget (widget_name, page_name, page_number, "widgets/widget.fillGauge.json", topik);
|
||||
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
/*
|
||||
Ticker.cpp - esp8266 library that calls functions periodically
|
||||
|
||||
Copyright (c) 2014 Ivan Grokhotkov. All rights reserved.
|
||||
This file is part of the esp8266 core for Arduino environment.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "c_types.h"
|
||||
#include "eagle_soc.h"
|
||||
#include "ets_sys.h"
|
||||
#include "osapi.h"
|
||||
|
||||
static const int ONCE = 0;
|
||||
static const int REPEAT = 1;
|
||||
|
||||
#include "Ticker.h"
|
||||
|
||||
Ticker::Ticker()
|
||||
: _timer(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
Ticker::~Ticker()
|
||||
{
|
||||
detach();
|
||||
}
|
||||
|
||||
void Ticker::_attach_ms(uint32_t milliseconds, bool repeat, callback_with_arg_t callback, uint32_t arg)
|
||||
{
|
||||
if (_timer)
|
||||
{
|
||||
os_timer_disarm(_timer);
|
||||
}
|
||||
else
|
||||
{
|
||||
_timer = new ETSTimer;
|
||||
}
|
||||
|
||||
os_timer_setfn(_timer, reinterpret_cast<ETSTimerFunc*>(callback), reinterpret_cast<void*>(arg));
|
||||
os_timer_arm(_timer, milliseconds, (repeat)?REPEAT:ONCE);
|
||||
}
|
||||
|
||||
void Ticker::detach()
|
||||
{
|
||||
if (!_timer)
|
||||
return;
|
||||
|
||||
os_timer_disarm(_timer);
|
||||
delete _timer;
|
||||
_timer = nullptr;
|
||||
_callback_function = nullptr;
|
||||
}
|
||||
|
||||
bool Ticker::active() const
|
||||
{
|
||||
return (bool)_timer;
|
||||
}
|
||||
|
||||
void Ticker::_static_callback(void* arg)
|
||||
{
|
||||
Ticker* _this = (Ticker*)arg;
|
||||
if (_this == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (_this->_callback_function)
|
||||
{
|
||||
_this->_callback_function();
|
||||
}
|
||||
}
|
||||
@@ -1,136 +0,0 @@
|
||||
/*
|
||||
Ticker.h - esp8266 library that calls functions periodically
|
||||
|
||||
Copyright (c) 2014 Ivan Grokhotkov. All rights reserved.
|
||||
This file is part of the esp8266 core for Arduino environment.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef TICKER_H
|
||||
#define TICKER_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <functional>
|
||||
#include <Schedule.h>
|
||||
|
||||
extern "C" {
|
||||
typedef struct _ETSTIMER_ ETSTimer;
|
||||
}
|
||||
|
||||
class Ticker
|
||||
{
|
||||
public:
|
||||
Ticker();
|
||||
~Ticker();
|
||||
typedef void (*callback_t)(void);
|
||||
typedef void (*callback_with_arg_t)(void*);
|
||||
typedef std::function<void(void)> callback_function_t;
|
||||
|
||||
void attach_scheduled(float seconds, callback_function_t callback)
|
||||
{
|
||||
attach(seconds,std::bind(schedule_function, callback));
|
||||
}
|
||||
|
||||
void attach(float seconds, callback_function_t callback)
|
||||
{
|
||||
_callback_function = callback;
|
||||
attach(seconds, _static_callback, (void*)this);
|
||||
}
|
||||
|
||||
void attach_ms_scheduled(uint32_t milliseconds, callback_function_t callback)
|
||||
{
|
||||
attach_ms(milliseconds, std::bind(schedule_function, callback));
|
||||
}
|
||||
|
||||
void attach_ms(uint32_t milliseconds, callback_function_t callback)
|
||||
{
|
||||
_callback_function = callback;
|
||||
attach_ms(milliseconds, _static_callback, (void*)this);
|
||||
}
|
||||
|
||||
template<typename TArg>
|
||||
void attach(float seconds, void (*callback)(TArg), TArg arg)
|
||||
{
|
||||
static_assert(sizeof(TArg) <= sizeof(uint32_t), "attach() callback argument size must be <= 4 bytes");
|
||||
// C-cast serves two purposes:
|
||||
// static_cast for smaller integer types,
|
||||
// reinterpret_cast + const_cast for pointer types
|
||||
uint32_t arg32 = (uint32_t)arg;
|
||||
_attach_ms(seconds * 1000, true, reinterpret_cast<callback_with_arg_t>(callback), arg32);
|
||||
}
|
||||
|
||||
template<typename TArg>
|
||||
void attach_ms(uint32_t milliseconds, void (*callback)(TArg), TArg arg)
|
||||
{
|
||||
static_assert(sizeof(TArg) <= sizeof(uint32_t), "attach_ms() callback argument size must be <= 4 bytes");
|
||||
uint32_t arg32 = (uint32_t)arg;
|
||||
_attach_ms(milliseconds, true, reinterpret_cast<callback_with_arg_t>(callback), arg32);
|
||||
}
|
||||
|
||||
void once_scheduled(float seconds, callback_function_t callback)
|
||||
{
|
||||
once(seconds, std::bind(schedule_function, callback));
|
||||
}
|
||||
|
||||
void once(float seconds, callback_function_t callback)
|
||||
{
|
||||
_callback_function = callback;
|
||||
once(seconds, _static_callback, (void*)this);
|
||||
}
|
||||
|
||||
void once_ms_scheduled(uint32_t milliseconds, callback_function_t callback)
|
||||
{
|
||||
once_ms(milliseconds, std::bind(schedule_function, callback));
|
||||
}
|
||||
|
||||
void once_ms(uint32_t milliseconds, callback_function_t callback)
|
||||
{
|
||||
_callback_function = callback;
|
||||
once_ms(milliseconds, _static_callback, (void*)this);
|
||||
}
|
||||
|
||||
template<typename TArg>
|
||||
void once(float seconds, void (*callback)(TArg), TArg arg)
|
||||
{
|
||||
static_assert(sizeof(TArg) <= sizeof(uint32_t), "attach() callback argument size must be <= 4 bytes");
|
||||
uint32_t arg32 = (uint32_t)(arg);
|
||||
_attach_ms(seconds * 1000, false, reinterpret_cast<callback_with_arg_t>(callback), arg32);
|
||||
}
|
||||
|
||||
template<typename TArg>
|
||||
void once_ms(uint32_t milliseconds, void (*callback)(TArg), TArg arg)
|
||||
{
|
||||
static_assert(sizeof(TArg) <= sizeof(uint32_t), "attach_ms() callback argument size must be <= 4 bytes");
|
||||
uint32_t arg32 = (uint32_t)(arg);
|
||||
_attach_ms(milliseconds, false, reinterpret_cast<callback_with_arg_t>(callback), arg32);
|
||||
}
|
||||
|
||||
void detach();
|
||||
bool active() const;
|
||||
|
||||
protected:
|
||||
void _attach_ms(uint32_t milliseconds, bool repeat, callback_with_arg_t callback, uint32_t arg);
|
||||
static void _static_callback (void* arg);
|
||||
|
||||
protected:
|
||||
ETSTimer* _timer;
|
||||
callback_function_t _callback_function = nullptr;
|
||||
};
|
||||
|
||||
|
||||
#endif//TICKER_H
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
Basic Ticker usage
|
||||
|
||||
Ticker is an object that will call a given function with a certain period.
|
||||
Each Ticker calls one function. You can have as many Tickers as you like,
|
||||
memory being the only limitation.
|
||||
|
||||
A function may be attached to a ticker and detached from the ticker.
|
||||
There are two variants of the attach function: attach and attach_ms.
|
||||
The first one takes period in seconds, the second one in milliseconds.
|
||||
|
||||
The built-in LED will be blinking.
|
||||
*/
|
||||
|
||||
#include <Ticker.h>
|
||||
|
||||
Ticker flipper;
|
||||
|
||||
int count = 0;
|
||||
|
||||
void flip() {
|
||||
int state = digitalRead(LED_BUILTIN); // get the current state of GPIO1 pin
|
||||
digitalWrite(LED_BUILTIN, !state); // set pin to the opposite state
|
||||
|
||||
++count;
|
||||
// when the counter reaches a certain value, start blinking like crazy
|
||||
if (count == 20) {
|
||||
flipper.attach(0.1, flip);
|
||||
}
|
||||
// when the counter reaches yet another value, stop blinking
|
||||
else if (count == 120) {
|
||||
flipper.detach();
|
||||
}
|
||||
}
|
||||
|
||||
void setup() {
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
// flip the pin every 0.3s
|
||||
flipper.attach(0.3, flip);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
#include "Arduino.h"
|
||||
#include "Ticker.h"
|
||||
|
||||
#define LED1 2
|
||||
#define LED2 4
|
||||
#define LED3 12
|
||||
#define LED4 14
|
||||
#define LED5 15
|
||||
|
||||
|
||||
class ExampleClass {
|
||||
public:
|
||||
ExampleClass(int pin, int duration) : _pin(pin), _duration(duration) {
|
||||
pinMode(_pin, OUTPUT);
|
||||
_myTicker.attach_ms(_duration, std::bind(&ExampleClass::classBlink, this));
|
||||
}
|
||||
~ExampleClass() {};
|
||||
|
||||
int _pin, _duration;
|
||||
Ticker _myTicker;
|
||||
|
||||
void classBlink() {
|
||||
digitalWrite(_pin, !digitalRead(_pin));
|
||||
}
|
||||
};
|
||||
|
||||
void staticBlink() {
|
||||
digitalWrite(LED2, !digitalRead(LED2));
|
||||
}
|
||||
|
||||
void scheduledBlink() {
|
||||
digitalWrite(LED3, !digitalRead(LED2));
|
||||
}
|
||||
|
||||
void parameterBlink(int p) {
|
||||
digitalWrite(p, !digitalRead(p));
|
||||
}
|
||||
|
||||
Ticker staticTicker;
|
||||
Ticker scheduledTicker;
|
||||
Ticker parameterTicker;
|
||||
Ticker lambdaTicker;
|
||||
|
||||
ExampleClass example(LED1, 100);
|
||||
|
||||
|
||||
void setup() {
|
||||
pinMode(LED2, OUTPUT);
|
||||
staticTicker.attach_ms(100, staticBlink);
|
||||
|
||||
pinMode(LED3, OUTPUT);
|
||||
scheduledTicker.attach_ms_scheduled(100, scheduledBlink);
|
||||
|
||||
pinMode(LED4, OUTPUT);
|
||||
parameterTicker.attach_ms(100, std::bind(parameterBlink, LED4));
|
||||
|
||||
pinMode(LED5, OUTPUT);
|
||||
lambdaTicker.attach_ms(100, []() {
|
||||
digitalWrite(LED5, !digitalRead(LED5));
|
||||
});
|
||||
}
|
||||
|
||||
void loop() {
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
Passing paramters to Ticker callbacks
|
||||
|
||||
Apart from void(void) functions, the Ticker library supports
|
||||
functions taking one argument. This argument's size has to be less or
|
||||
equal to 4 bytes (so char, short, int, float, void*, char* types will do).
|
||||
|
||||
This sample runs two tickers that both call one callback function,
|
||||
but with different arguments.
|
||||
|
||||
The built-in LED will be pulsing.
|
||||
*/
|
||||
|
||||
#include <Ticker.h>
|
||||
|
||||
Ticker tickerSetHigh;
|
||||
Ticker tickerSetLow;
|
||||
|
||||
void setPin(int state) {
|
||||
digitalWrite(LED_BUILTIN, state);
|
||||
}
|
||||
|
||||
void setup() {
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(1, LOW);
|
||||
|
||||
// every 25 ms, call setPin(0)
|
||||
tickerSetLow.attach_ms(25, setPin, 0);
|
||||
|
||||
// every 26 ms, call setPin(1)
|
||||
tickerSetHigh.attach_ms(26, setPin, 1);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
name=Ticker
|
||||
version=1.0
|
||||
author=Ivan Grokhtokov <ivan@esp8266.com>
|
||||
maintainer=Ivan Grokhtokov <ivan@esp8266.com>
|
||||
sentence=Allows to call functions with a given interval.
|
||||
paragraph=
|
||||
category=Timing
|
||||
url=
|
||||
architectures=esp8266
|
||||
dot_a_linkage=true
|
||||
135
Time.ino
135
Time.ino
@@ -1,135 +0,0 @@
|
||||
void Time_Init() {
|
||||
server.on("/timeZone", HTTP_GET, [](AsyncWebServerRequest * request) {
|
||||
if (request->hasArg("timezone")) {
|
||||
jsonWriteStr(configSetup, "timezone", request->getParam("timezone")->value());
|
||||
}
|
||||
saveConfig();
|
||||
reconfigTime();
|
||||
request->send(200, "text/text", "OK"); // отправляем ответ о выполнении
|
||||
});
|
||||
|
||||
ts.add(TIME_SYNC, 30000, [&](void*) {
|
||||
if (GetTimeUnix() == "failed") {
|
||||
Serial.println("[i] Time is not synchronized, start synchronization");
|
||||
reconfigTime();
|
||||
}
|
||||
}, nullptr, true);
|
||||
}
|
||||
|
||||
void reconfigTime() {
|
||||
if (WiFi.status() == WL_CONNECTED) {
|
||||
configTime(0, 0, ntpServer);
|
||||
int i = 0;
|
||||
Serial.println("[i] Awaiting for time ");
|
||||
#ifdef ESP32
|
||||
struct tm timeinfo;
|
||||
while (!getLocalTime(&timeinfo) && i <= 4) {
|
||||
Serial.print(".");
|
||||
i++;
|
||||
delay(1000);
|
||||
}
|
||||
#endif
|
||||
#ifdef ESP8266
|
||||
// while (!time(nullptr) && i < 4) {
|
||||
// Serial.print(".");
|
||||
// i++;
|
||||
delay(2000);
|
||||
// }
|
||||
#endif
|
||||
if (GetTimeUnix() != "failed") {
|
||||
Serial.print("[V] Time synchronized = ");
|
||||
Serial.print(GetDataDigital());
|
||||
Serial.print(" ");
|
||||
Serial.println(GetTime());
|
||||
} else {
|
||||
Serial.println("[E] Time server or internet connection error, will try again in 30 sec");
|
||||
}
|
||||
} else {
|
||||
Serial.println("[E] Get time impossible, no wifi connection");
|
||||
}
|
||||
}
|
||||
|
||||
//Получаем время в формате linux gmt
|
||||
String GetTimeUnix() {
|
||||
time_t now = time(nullptr);
|
||||
if (now < 30000) {
|
||||
return "failed";
|
||||
} else {
|
||||
return String(now);
|
||||
}
|
||||
}
|
||||
// Получение текущего времени
|
||||
String GetTime() {
|
||||
time_t now = time(nullptr); // получаем время с помощью библиотеки time.h
|
||||
int zone = 3600 * jsonRead(configSetup, "timezone").toInt();
|
||||
now = now + zone;
|
||||
String Time = ""; // Строка для результатов времени
|
||||
Time += ctime(&now); // Преобразуем время в строку формата Thu Jan 19 00:55:35 2017
|
||||
int i = Time.indexOf(":"); //Ишем позицию первого символа :
|
||||
Time = Time.substring(i - 2, i + 6); // Выделяем из строки 2 символа перед символом : и 6 символов после
|
||||
return Time; // Возврашаем полученное время
|
||||
}
|
||||
|
||||
String GetTimeWOsec() {
|
||||
time_t now = time(nullptr); // получаем время с помощью библиотеки time.h
|
||||
int zone = 3600 * jsonRead(configSetup, "timezone").toInt();
|
||||
now = now + zone;
|
||||
String Time = ""; // Строка для результатов времени
|
||||
Time += ctime(&now); // Преобразуем время в строку формата Thu Jan 19 00:55:35 2017
|
||||
int i = Time.indexOf(":"); //Ишем позицию первого символа :
|
||||
Time = Time.substring(i - 2, i + 3); // Выделяем из строки 2 символа перед символом : и 6 символов после
|
||||
return Time; // Возврашаем полученное время
|
||||
}
|
||||
|
||||
// Получение даты
|
||||
String GetDate() {
|
||||
time_t now = time(nullptr); // получаем время с помощью библиотеки time.h
|
||||
int zone = 3600 * jsonRead(configSetup, "timezone").toInt();
|
||||
now = now + zone;
|
||||
String Data = ""; // Строка для результатов времени
|
||||
Data += ctime(&now); // Преобразуем время в строку формата Thu Jan 19 00:55:35 2017
|
||||
Data.replace("\n", "");
|
||||
uint8_t i = Data.lastIndexOf(" "); //Ишем позицию последнего символа пробел
|
||||
String Time = Data.substring(i - 8, i + 1); // Выделяем время и пробел
|
||||
Data.replace(Time, ""); // Удаляем из строки 8 символов времени и пробел
|
||||
return Data; // Возврашаем полученную дату
|
||||
}
|
||||
|
||||
String GetDataDigital() {
|
||||
String date = GetDate();
|
||||
|
||||
date = deleteBeforeDelimiter(date, " ");
|
||||
|
||||
date.replace("Jan", "01");
|
||||
date.replace("Feb", "02");
|
||||
date.replace("Mar", "03");
|
||||
date.replace("Apr", "04");
|
||||
date.replace("May", "05");
|
||||
date.replace("Jun", "06");
|
||||
date.replace("Jul", "07");
|
||||
date.replace("Aug", "08");
|
||||
date.replace("Sep", "09");
|
||||
date.replace("Oct", "10");
|
||||
date.replace("Nov", "11");
|
||||
date.replace("Dec", "12");
|
||||
|
||||
String month = date.substring(0, 2);
|
||||
String day = date.substring(3, 5);
|
||||
String year = date.substring(8, 10);
|
||||
|
||||
String out = day;
|
||||
out += ".";
|
||||
out += month;
|
||||
out += ".";
|
||||
out += year;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
int timeToMin(String Time) {
|
||||
//"00:00:00" время в секунды
|
||||
long min = selectToMarker(Time, ":").toInt() * 60; //общее количество секунд в полных часах
|
||||
Time = deleteBeforeDelimiter (Time, ":"); // Теперь здесь минуты секунды
|
||||
min += selectToMarker(Time, ":").toInt(); // Добавим секунды из полных минут
|
||||
return min;
|
||||
}
|
||||
188
Timers.ino
188
Timers.ino
@@ -1,188 +0,0 @@
|
||||
//================================================================================================================
|
||||
//=========================================Таймера=================================================================
|
||||
void Timer_countdown_init() {
|
||||
|
||||
ts.add(TIMER_COUNTDOWN, 1000, [&](void*) {
|
||||
|
||||
String old_line = jsonRead(optionJson, "timers");
|
||||
|
||||
|
||||
if (old_line != "") {
|
||||
|
||||
//Serial.println(old_line);
|
||||
|
||||
int i = 0;
|
||||
|
||||
do {
|
||||
|
||||
String timer = selectFromMarkerToMarker(old_line, "," , i);
|
||||
// Serial.print("timer no " + String (i) + ": ");
|
||||
// Serial.println(timer);
|
||||
if (timer == "not found" || timer == "") return;
|
||||
int number = selectToMarker (timer, ":").toInt();
|
||||
int time = readTimer(number);
|
||||
if (time == 0) {
|
||||
|
||||
delTimer (String (number));
|
||||
|
||||
jsonWriteStr(configJson, "timerSet" + String(number), "0");
|
||||
|
||||
eventGen ("timerSet", String(number));
|
||||
|
||||
} else {
|
||||
time--;
|
||||
addTimer(String (number), String (time));
|
||||
}
|
||||
i++;
|
||||
} while (i <= 9);
|
||||
|
||||
}
|
||||
}, nullptr, true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void timerStart() {
|
||||
|
||||
String number = sCmd.next();
|
||||
String period_of_time = sCmd.next();
|
||||
String type = sCmd.next();
|
||||
|
||||
if (period_of_time.indexOf("digit") != -1) {
|
||||
period_of_time = add_set(period_of_time);
|
||||
period_of_time = jsonRead(configJson, period_of_time);
|
||||
}
|
||||
|
||||
if (type == "sec") period_of_time = period_of_time;
|
||||
if (type == "min") period_of_time = String(period_of_time.toInt() * 60);
|
||||
if (type == "hours") period_of_time = String(period_of_time.toInt() * 60 * 60);
|
||||
|
||||
addTimer(number, period_of_time);
|
||||
jsonWriteStr(configJson, "timerSet" + number, "1");
|
||||
}
|
||||
void addTimer(String number, String time) {
|
||||
|
||||
String tmp = jsonRead(optionJson, "timers"); //1:60,2:120,
|
||||
String new_timer = number + ":" + time;
|
||||
int psn1 = tmp.indexOf(number + ":"); //0 ищем позицию таймера который надо заменить
|
||||
|
||||
if (psn1 != -1) { //если он есть
|
||||
|
||||
int psn2 = tmp.indexOf(",", psn1); //4 от этой позиции находим позицию запятой
|
||||
|
||||
String timer = tmp.substring(psn1, psn2); //1:60 выделяем таймер который надо заменить
|
||||
///tmp.replace(timer, new_timer); //заменяем таймер на новый (во всей стороке)
|
||||
tmp.replace(timer + ",", "");
|
||||
tmp += new_timer + ",";
|
||||
|
||||
} else { //если его нет
|
||||
tmp += new_timer + ",";
|
||||
}
|
||||
jsonWriteStr(optionJson, "timers", tmp);
|
||||
//Serial.println("ura");
|
||||
}
|
||||
|
||||
|
||||
void timerStop() {
|
||||
|
||||
String number = sCmd.next();
|
||||
delTimer(number);
|
||||
|
||||
}
|
||||
void delTimer (String number) {
|
||||
|
||||
String tmp = jsonRead(optionJson, "timers"); //1:60,2:120,
|
||||
int psn1 = tmp.indexOf(number + ":"); //0 ищем позицию таймера который надо удалить
|
||||
|
||||
if (psn1 != -1) { //если он есть
|
||||
int psn2 = tmp.indexOf(",", psn1); //4 от этой позиции находим позицию запятой
|
||||
String timer = tmp.substring(psn1, psn2) + ","; //1:60, выделяем таймер который надо удалить
|
||||
tmp.replace(timer, ""); //удаляем таймер
|
||||
jsonWriteStr(optionJson, "timers", tmp);
|
||||
}
|
||||
}
|
||||
|
||||
int readTimer(int number) {
|
||||
|
||||
String tmp = jsonRead(optionJson, "timers"); //1:60,2:120,
|
||||
|
||||
int psn1 = tmp.indexOf(String(number) + ":"); //0 ищем позицию таймера который надо прочитать
|
||||
|
||||
String timer;
|
||||
|
||||
if (psn1 != -1) { //если он есть
|
||||
int psn2 = tmp.indexOf(",", psn1); //4 от этой позиции находим позицию запятой
|
||||
timer = tmp.substring(psn1, psn2); //1:60 выделяем таймер который надо прочитать
|
||||
timer = deleteBeforeDelimiter(timer, ":");
|
||||
}
|
||||
return timer.toInt();
|
||||
}
|
||||
|
||||
/*void timer() {
|
||||
|
||||
String seted_time = sCmd.next();
|
||||
String order = sCmd.next();
|
||||
order.replace("_", " ");
|
||||
if (seted_time == current_time) {
|
||||
|
||||
order_loop += order + ",";
|
||||
|
||||
}
|
||||
}*/
|
||||
|
||||
//------------------------------таймеры------------------------------------------------------
|
||||
|
||||
/*
|
||||
void time() {
|
||||
|
||||
String time_number = sCmd.next();
|
||||
String time = sCmd.next();
|
||||
|
||||
String time_to_add = time_number + "-" + time;
|
||||
|
||||
String replace_line = jsonRead(optionJson, "times") ;
|
||||
int psn1 = replace_line.indexOf(time_number + "-") ; //ищем позицию времени которое надо заменить
|
||||
|
||||
if (psn1 != -1) { //если оно есть
|
||||
|
||||
int psn2 = replace_line.indexOf(",", psn1); //от этой позиции находим позицию запятой
|
||||
|
||||
String timer = replace_line.substring(psn1, psn2); //выделяем таймер который надо заменить
|
||||
///tmp.replace(timer, new_timer); //заменяем таймер на новый (во всей стороке)
|
||||
replace_line.replace(timer + ",", "");
|
||||
replace_line += time_to_add + ",";
|
||||
|
||||
} else { //если его нет
|
||||
replace_line += time_to_add + ",";
|
||||
}
|
||||
|
||||
|
||||
jsonWriteStr(optionJson, "times", replace_line);
|
||||
|
||||
jsonWriteStr(configJson, "timeSet" + time_number, "1");
|
||||
|
||||
ts.add(TIMERS, 1000, [&](void*) {
|
||||
|
||||
current_time = GetTime();
|
||||
Serial.println(current_time);
|
||||
|
||||
String seted_times = jsonRead(optionJson, "times");
|
||||
|
||||
while (seted_times.length() != 0) {
|
||||
String tmp = selectToMarker (seted_times, ",");
|
||||
|
||||
String time_number = selectToMarker(tmp, "-");
|
||||
String seted_time = deleteBeforeDelimiter(tmp, "-");
|
||||
|
||||
Serial.println(seted_time);
|
||||
|
||||
if (current_time == seted_time) {
|
||||
jsonWriteStr(configJson, "timeSet" + time_number, "0");
|
||||
eventGen ("timeSet", time_number);
|
||||
}
|
||||
|
||||
seted_times = deleteBeforeDelimiter(seted_times, ",");
|
||||
}
|
||||
}, nullptr, true);
|
||||
}
|
||||
*/
|
||||
273
Upgrade.ino
273
Upgrade.ino
@@ -1,273 +0,0 @@
|
||||
void initUpgrade() {
|
||||
|
||||
#ifdef ESP8266
|
||||
if (WiFi.status() == WL_CONNECTED) last_version = getURL("http://91.204.228.124:1100/update/esp8266/version.txt");
|
||||
#endif
|
||||
#ifdef ESP32
|
||||
if (WiFi.status() == WL_CONNECTED) last_version = getURL("http://91.204.228.124:1100/update/esp32/version.txt");
|
||||
#endif
|
||||
jsonWriteStr(configSetup, "last_version", last_version);
|
||||
Serial.print("[i] Last firmware version: ");
|
||||
Serial.println(last_version);
|
||||
|
||||
server.on("/check", HTTP_GET, [](AsyncWebServerRequest * request) {
|
||||
upgrade_url = true;
|
||||
Serial.print("[i] Last firmware version: ");
|
||||
Serial.println(last_version);
|
||||
String tmp = "{}";
|
||||
if (WiFi.status() == WL_CONNECTED) {
|
||||
if (mb_4_of_memory) {
|
||||
if (last_version != "") {
|
||||
if (last_version != "error") {
|
||||
if (last_version == firmware_version) {
|
||||
jsonWriteStr(tmp, "title", "<button class=\"close\" onclick=\"toggle('my-block')\">×</button>Последняя версия прошивки уже установлена.");
|
||||
jsonWriteStr(tmp, "class", "pop-up");
|
||||
} else {
|
||||
jsonWriteStr(tmp, "title", "<button class=\"close\" onclick=\"toggle('my-block')\">×</button>Имеется новая версия прошивки<a href=\"#\" class=\"btn btn-block btn-danger\" onclick=\"send_request(this, '/upgrade');setTimeout(function(){ location.href='/'; }, 30000);html('my-block','<span class=loader></span>Идет обновление прошивки, после обновления страница перезагрузится автоматически...')\">Установить</a>");
|
||||
jsonWriteStr(tmp, "class", "pop-up");
|
||||
}
|
||||
} else {
|
||||
jsonWriteStr(tmp, "title", "<button class=\"close\" onclick=\"toggle('my-block')\">×</button>Ошибка... Cервер не найден. Попробуйте позже...");
|
||||
jsonWriteStr(tmp, "class", "pop-up");
|
||||
}
|
||||
} else {
|
||||
jsonWriteStr(tmp, "title", "<button class=\"close\" onclick=\"toggle('my-block')\">×</button>Нажмите на кнопку \"обновить прошивку\" повторно...");
|
||||
jsonWriteStr(tmp, "class", "pop-up");
|
||||
}
|
||||
} else {
|
||||
jsonWriteStr(tmp, "title", "<button class=\"close\" onclick=\"toggle('my-block')\">×</button>Обновление по воздуху не поддерживается, модуль имеет меньше 4 мб памяти...");
|
||||
jsonWriteStr(tmp, "class", "pop-up");
|
||||
}
|
||||
} else {
|
||||
jsonWriteStr(tmp, "title", "<button class=\"close\" onclick=\"toggle('my-block')\">×</button>Устройство не подключен к роутеру...");
|
||||
jsonWriteStr(tmp, "class", "pop-up");
|
||||
}
|
||||
request->send(200, "text/text", tmp);
|
||||
});
|
||||
|
||||
server.on("/upgrade", HTTP_GET, [](AsyncWebServerRequest * request) {
|
||||
upgrade = true;
|
||||
String tmp = "{}";
|
||||
//jsonWriteStr(tmp, "title", "<button class=\"close\" onclick=\"toggle('my-block')\">×</button>Есть новая версия <a href=\"#\" onclick=\"setTimeout(function(){ location.href='/'; }, 5000);}\">Установить?</a>");
|
||||
request->send(200, "text/text", "ok");
|
||||
});
|
||||
}
|
||||
|
||||
void do_upgrade_url() {
|
||||
if (upgrade_url) {
|
||||
upgrade_url = false;
|
||||
#ifdef ESP32
|
||||
last_version = getURL("http://91.204.228.124:1100/update/esp32/version.txt");
|
||||
jsonWriteStr(configSetup, "last_version", last_version);
|
||||
#endif
|
||||
#ifdef ESP8266
|
||||
last_version = getURL("http://91.204.228.124:1100/update/esp8266/version.txt");
|
||||
jsonWriteStr(configSetup, "last_version", last_version);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void upgrade_firmware() {
|
||||
|
||||
String scenario_for_update;
|
||||
String config_for_update;
|
||||
String configSetup_for_update;
|
||||
scenario_for_update = readFile("firmware.s.txt", 3072);
|
||||
config_for_update = readFile("firmware.c.txt", 3072);
|
||||
configSetup_for_update = configSetup;
|
||||
|
||||
Serial.println("Start upgrade SPIFFS, please wait...");
|
||||
|
||||
WiFiClient client_for_upgrade;
|
||||
|
||||
#ifdef ESP32
|
||||
httpUpdate.rebootOnUpdate(false);
|
||||
t_httpUpdate_return ret = httpUpdate.updateSpiffs(client_for_upgrade, "http://91.204.228.124:1100/update/esp32/esp32-esp8266_iot-manager_modules_firmware.spiffs.bin");
|
||||
#endif
|
||||
#ifdef ESP8266
|
||||
ESPhttpUpdate.rebootOnUpdate(false);
|
||||
t_httpUpdate_return ret = ESPhttpUpdate.updateSpiffs(client_for_upgrade, "http://91.204.228.124:1100/update/esp8266/esp32-esp8266_iot-manager_modules_firmware.spiffs.bin");
|
||||
#endif
|
||||
|
||||
if (ret == HTTP_UPDATE_OK) {
|
||||
|
||||
writeFile("firmware.s.txt", scenario_for_update);
|
||||
writeFile("firmware.c.txt", config_for_update);
|
||||
writeFile("config.json", configSetup_for_update);
|
||||
saveConfig();
|
||||
|
||||
Serial.println("SPIFFS upgrade done!");
|
||||
Serial.println("Start upgrade BUILD, please wait...");
|
||||
|
||||
#ifdef ESP32
|
||||
//httpUpdate.rebootOnUpdate(true);
|
||||
t_httpUpdate_return ret = httpUpdate.update(client_for_upgrade, "http://91.204.228.124:1100/update/esp32/esp32-esp8266_iot-manager_modules_firmware.ino.bin");
|
||||
#endif
|
||||
#ifdef ESP8266
|
||||
//ESPhttpUpdate.rebootOnUpdate(true);
|
||||
t_httpUpdate_return ret = ESPhttpUpdate.update(client_for_upgrade, "http://91.204.228.124:1100/update/esp8266/esp32-esp8266_iot-manager_modules_firmware.ino.bin");
|
||||
#endif
|
||||
|
||||
if (ret == HTTP_UPDATE_OK) {
|
||||
Serial.println("BUILD upgrade done!");
|
||||
Serial.println("Restart ESP....");
|
||||
ESP.restart();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void do_upgrade() {
|
||||
if (upgrade) {
|
||||
upgrade = false;
|
||||
upgrade_firmware();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
void upgrade_status(t_httpUpdate_return set) {
|
||||
switch (set) {
|
||||
case HTTP_UPDATE_FAILED:
|
||||
Serial.printf("UPDATE_FAILED Error (%d): %s", httpUpdate.getLastError(), httpUpdate.getLastErrorString().c_str());
|
||||
break;
|
||||
|
||||
case HTTP_UPDATE_NO_UPDATES:
|
||||
Serial.println("NO_UPDATES");
|
||||
break;
|
||||
|
||||
case HTTP_UPDATE_OK:
|
||||
Serial.println("HTTP_UPDATE_OK");
|
||||
break;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
// ----------------------- Обновление с сайта
|
||||
void webUpgrade() {
|
||||
|
||||
#ifdef ESP8266
|
||||
String spiffsData = "http://91.204.228.124:1100/update/esp8266/esp32-esp8266_iot-manager_modules_firmware.spiffs.bin";
|
||||
String buildData = "http://91.204.228.124:1100/update/esp8266/esp32-esp8266_iot-manager_modules_firmware.ino.bin";
|
||||
#endif
|
||||
|
||||
#ifdef ESP32
|
||||
String spiffsData = "http://91.204.228.124:1100/update/esp32/esp32-esp8266_iot-manager_modules_firmware.spiffs.bin";
|
||||
String buildData = "http://91.204.228.124:1100/update/esp32/esp32-esp8266_iot-manager_modules_firmware.ino.bin";
|
||||
#endif
|
||||
|
||||
if (spiffsData != "") { // Если нужно прошить FS
|
||||
String scenario_for_update;
|
||||
String config_for_update;
|
||||
String configSetup_for_update;
|
||||
Serial.println(spiffsData);
|
||||
scenario_for_update = readFile("firmware.s.txt", 2048);
|
||||
config_for_update = readFile("config.all.txt", 2048);
|
||||
configSetup_for_update = configSetup;
|
||||
ESPhttpUpdate.rebootOnUpdate(false); // Отключим перезагрузку после обновления
|
||||
updateHTTP(spiffsData, true);
|
||||
writeFile("firmware.s.txt", scenario_for_update);
|
||||
writeFile("config.all.txt", config_for_update);
|
||||
writeFile("config.json", configSetup_for_update);
|
||||
saveConfig();
|
||||
}
|
||||
|
||||
if (buildData != "") { // Если нужно прошить build
|
||||
Serial.println(buildData);
|
||||
ESPhttpUpdate.rebootOnUpdate(true); // Включим перезагрузку после обновления
|
||||
updateHTTP(buildData, false);
|
||||
}
|
||||
}
|
||||
// ------------------ Обновление по url
|
||||
void updateHTTP(String url, boolean mode) {
|
||||
if (url == "") return;
|
||||
ESPhttpUpdate.setLedPin(LED_BUILTIN, LOW);
|
||||
if (mode) {
|
||||
Serial.println("Update Spiffs...");
|
||||
t_httpUpdate_return ret = ESPhttpUpdate.updateSpiffs(url);
|
||||
UpdateStatus(ret , "Spiffs");
|
||||
} else {
|
||||
Serial.println("Update Build...");
|
||||
t_httpUpdate_return ret = ESPhttpUpdate.update(url);
|
||||
UpdateStatus(ret , "build");
|
||||
}
|
||||
}
|
||||
void UpdateStatus(t_httpUpdate_return set, String mode) {
|
||||
|
||||
switch (set) {
|
||||
|
||||
case HTTP_UPDATE_FAILED:
|
||||
Serial.println(mode + "_FAILED");
|
||||
var = "{}";
|
||||
jsonWriteStr(var, "title", "<button class=\"close\" onclick=\"toggle('my-block')\">×</button>_FAILED");
|
||||
jsonWriteStr(var, "class", "pop-up");
|
||||
//request->send(200, "text/text", var);
|
||||
break;
|
||||
|
||||
case HTTP_UPDATE_NO_UPDATES:
|
||||
Serial.println(mode + "_NO_UPDATES");
|
||||
var = "{}";
|
||||
jsonWriteStr(var, "title", "<button class=\"close\" onclick=\"toggle('my-block')\">×</button>_NO_UPDATES");
|
||||
jsonWriteStr(var, "class", "pop-up");
|
||||
//request->send(200, "text/text", var);
|
||||
break;
|
||||
|
||||
case HTTP_UPDATE_OK:
|
||||
Serial.println(mode + "_UPDATE_OK");
|
||||
var = "{}";
|
||||
jsonWriteStr(var, "title", "<button class=\"close\" onclick=\"toggle('my-block')\">×</button>_UPDATE_OK");
|
||||
jsonWriteStr(var, "class", "pop-up");
|
||||
//request->send(200, "text/text", var);
|
||||
break;
|
||||
}
|
||||
}
|
||||
*/
|
||||
231
Web_server.ino
231
Web_server.ino
@@ -1,231 +0,0 @@
|
||||
void Web_server_init() {
|
||||
|
||||
//========================================OTA============================================
|
||||
#ifdef OTA_enable
|
||||
//Send OTA events to the browser
|
||||
ArduinoOTA.onStart([]() {
|
||||
events.send("Update Start", "ota");
|
||||
});
|
||||
|
||||
ArduinoOTA.onEnd([]() {
|
||||
events.send("Update End", "ota");
|
||||
});
|
||||
|
||||
ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
|
||||
char p[32];
|
||||
sprintf(p, "Progress: %u%%\n", (progress / (total / 100)));
|
||||
events.send(p, "ota");
|
||||
});
|
||||
|
||||
ArduinoOTA.onError([](ota_error_t error) {
|
||||
if (error == OTA_AUTH_ERROR) events.send("Auth Failed", "ota");
|
||||
else if (error == OTA_BEGIN_ERROR) events.send("Begin Failed", "ota");
|
||||
else if (error == OTA_CONNECT_ERROR) events.send("Connect Failed", "ota");
|
||||
else if (error == OTA_RECEIVE_ERROR) events.send("Recieve Failed", "ota");
|
||||
else if (error == OTA_END_ERROR) events.send("End Failed", "ota");
|
||||
});
|
||||
ArduinoOTA.setHostname(hostName);
|
||||
|
||||
ArduinoOTA.begin();
|
||||
#endif
|
||||
//========================================MDNS============================================
|
||||
#ifdef MDNS_enable
|
||||
MDNS.addService("http", "tcp", 80);
|
||||
#endif
|
||||
|
||||
//SPIFFS.begin();
|
||||
|
||||
//========================================WS============================================
|
||||
#ifdef WS_enable
|
||||
ws.onEvent(onWsEvent);
|
||||
server.addHandler(&ws);
|
||||
|
||||
events.onConnect([](AsyncEventSourceClient * client) {
|
||||
//!!!client->send("hello!", NULL, millis(), 1000);
|
||||
});
|
||||
|
||||
server.addHandler(&events);
|
||||
#endif
|
||||
//======================================================================================
|
||||
|
||||
#ifdef ESP32
|
||||
server.addHandler(new SPIFFSEditor(SPIFFS, jsonRead(configSetup, "web_login").c_str(), jsonRead(configSetup, "web_pass").c_str()));
|
||||
#elif defined(ESP8266)
|
||||
server.addHandler(new SPIFFSEditor(jsonRead(configSetup, "web_login").c_str(), jsonRead(configSetup, "web_pass").c_str()));
|
||||
#endif
|
||||
|
||||
server.on("/heap", HTTP_GET, [](AsyncWebServerRequest * request) {
|
||||
request->send(200, "text/plain", String(ESP.getFreeHeap()));
|
||||
});
|
||||
|
||||
|
||||
server.serveStatic("/css/", SPIFFS, "/css/").setCacheControl("max-age=31536000");
|
||||
server.serveStatic("/js/", SPIFFS, "/js/").setCacheControl("max-age=31536000");
|
||||
server.serveStatic("/", SPIFFS, "/favicon.ico").setCacheControl("max-age=31536000");
|
||||
|
||||
server.serveStatic("/", SPIFFS, "/").setDefaultFile("index.htm")
|
||||
.setAuthentication(jsonRead(configSetup, "web_login").c_str(), jsonRead(configSetup, "web_pass").c_str());
|
||||
|
||||
|
||||
server.onNotFound([](AsyncWebServerRequest * request) {
|
||||
Serial.printf("NOT_FOUND: ");
|
||||
if (request->method() == HTTP_GET)
|
||||
Serial.printf("GET");
|
||||
else if (request->method() == HTTP_POST)
|
||||
Serial.printf("POST");
|
||||
else if (request->method() == HTTP_DELETE)
|
||||
Serial.printf("DELETE");
|
||||
else if (request->method() == HTTP_PUT)
|
||||
Serial.printf("PUT");
|
||||
else if (request->method() == HTTP_PATCH)
|
||||
Serial.printf("PATCH");
|
||||
else if (request->method() == HTTP_HEAD)
|
||||
Serial.printf("HEAD");
|
||||
else if (request->method() == HTTP_OPTIONS)
|
||||
Serial.printf("OPTIONS");
|
||||
else
|
||||
Serial.printf("UNKNOWN");
|
||||
Serial.printf(" http://%s%s\n", request->host().c_str(), request->url().c_str());
|
||||
|
||||
if (request->contentLength()) {
|
||||
Serial.printf("_CONTENT_TYPE: %s\n", request->contentType().c_str());
|
||||
Serial.printf("_CONTENT_LENGTH: %u\n", request->contentLength());
|
||||
}
|
||||
|
||||
int headers = request->headers();
|
||||
int i;
|
||||
for (i = 0; i < headers; i++) {
|
||||
AsyncWebHeader* h = request->getHeader(i);
|
||||
Serial.printf("_HEADER[%s]: %s\n", h->name().c_str(), h->value().c_str());
|
||||
}
|
||||
|
||||
int params = request->params();
|
||||
for (i = 0; i < params; i++) {
|
||||
AsyncWebParameter* p = request->getParam(i);
|
||||
if (p->isFile()) {
|
||||
Serial.printf("_FILE[%s]: %s, size: %u\n", p->name().c_str(), p->value().c_str(), p->size());
|
||||
} else if (p->isPost()) {
|
||||
Serial.printf("_POST[%s]: %s\n", p->name().c_str(), p->value().c_str());
|
||||
} else {
|
||||
Serial.printf("_GET[%s]: %s\n", p->name().c_str(), p->value().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
request->send(404);
|
||||
});
|
||||
|
||||
server.onFileUpload([](AsyncWebServerRequest * request, const String & filename, size_t index, uint8_t *data, size_t len, bool final) {
|
||||
if (!index)
|
||||
Serial.printf("UploadStart: %s\n", filename.c_str());
|
||||
Serial.printf("%s", (const char*)data);
|
||||
if (final)
|
||||
Serial.printf("UploadEnd: %s (%u)\n", filename.c_str(), index + len);
|
||||
});
|
||||
|
||||
server.onRequestBody([](AsyncWebServerRequest * request, uint8_t *data, size_t len, size_t index, size_t total) {
|
||||
if (!index)
|
||||
Serial.printf("BodyStart: %u\n", total);
|
||||
Serial.printf("%s", (const char*)data);
|
||||
if (index + len == total)
|
||||
Serial.printf("BodyEnd: %u\n", total);
|
||||
});
|
||||
|
||||
server.begin();
|
||||
|
||||
//=============================Устанавливаем реакции на запросы к серверу============================
|
||||
|
||||
// --------------------Выдаем данные configJson //config.live.json - динамические данные
|
||||
server.on("/config.live.json", HTTP_GET, [](AsyncWebServerRequest * request) {
|
||||
request->send(200, "application/json", configJson);
|
||||
});
|
||||
// --------------------Выдаем данные optionJson //config.option.json - данные не являющиеся событиями
|
||||
server.on("/config.option.json", HTTP_GET, [](AsyncWebServerRequest * request) {
|
||||
request->send(200, "application/json", optionJson);
|
||||
});
|
||||
// -------------------Выдаем данные configSetup //config.setup.json - для хранения постоянных данных
|
||||
server.on("/config.setup.json", HTTP_GET, [](AsyncWebServerRequest * request) {
|
||||
request->send(200, "application/json", configSetup);
|
||||
});
|
||||
|
||||
// ------------------Выполнение команды из запроса
|
||||
server.on("/cmd", HTTP_GET, [](AsyncWebServerRequest * request) { //http://192.168.88.45/cmd?command=rel%201%201
|
||||
String com = request->getParam("command")->value();
|
||||
Serial.println(com);
|
||||
order_loop += com + ",";
|
||||
request->send(200, "text/text", "OK"); // отправляем ответ о выполнении
|
||||
});
|
||||
}
|
||||
//========================================WS=========================================================================================
|
||||
#ifdef WS_enable
|
||||
void onWsEvent(AsyncWebSocket * server, AsyncWebSocketClient * client, AwsEventType type, void * arg, uint8_t *data, size_t len) {
|
||||
if (type == WS_EVT_CONNECT) {
|
||||
Serial.printf("ws[%s][%u] connect\n", server->url(), client->id());
|
||||
client->printf(json.c_str(), client->id());
|
||||
//client->ping();
|
||||
} else if (type == WS_EVT_DISCONNECT) {
|
||||
Serial.printf("ws[%s][%u] disconnect\n", server->url(), client->id());
|
||||
} else if (type == WS_EVT_ERROR) {
|
||||
Serial.printf("ws[%s][%u] error(%u): %s\n", server->url(), client->id(), *((uint16_t*)arg), (char*)data);
|
||||
} else if (type == WS_EVT_PONG) {
|
||||
Serial.printf("ws[%s][%u] pong[%u]: %s\n", server->url(), client->id(), len, (len) ? (char*)data : "");
|
||||
} else if (type == WS_EVT_DATA) {
|
||||
AwsFrameInfo * info = (AwsFrameInfo*)arg;
|
||||
String msg = "";
|
||||
if (info->final && info->index == 0 && info->len == len) {
|
||||
//the whole message is in a single frame and we got all of it's data
|
||||
Serial.printf("ws[%s][%u] %s-message[%llu]: ", server->url(), client->id(), (info->opcode == WS_TEXT) ? "text" : "binary", info->len);
|
||||
|
||||
if (info->opcode == WS_TEXT) {
|
||||
for (size_t i = 0; i < info->len; i++) {
|
||||
msg += (char) data[i];
|
||||
}
|
||||
} else {
|
||||
char buff[3];
|
||||
for (size_t i = 0; i < info->len; i++) {
|
||||
sprintf(buff, "%02x ", (uint8_t) data[i]);
|
||||
msg += buff ;
|
||||
}
|
||||
}
|
||||
Serial.printf("%s\n", msg.c_str());
|
||||
|
||||
if (info->opcode == WS_TEXT)
|
||||
client->text("{}");
|
||||
else
|
||||
client->binary("{}");
|
||||
} else {
|
||||
//message is comprised of multiple frames or the frame is split into multiple packets
|
||||
if (info->index == 0) {
|
||||
if (info->num == 0)
|
||||
Serial.printf("ws[%s][%u] %s-message start\n", server->url(), client->id(), (info->message_opcode == WS_TEXT) ? "text" : "binary");
|
||||
Serial.printf("ws[%s][%u] frame[%u] start[%llu]\n", server->url(), client->id(), info->num, info->len);
|
||||
}
|
||||
|
||||
Serial.printf("ws[%s][%u] frame[%u] %s[%llu - %llu]: ", server->url(), client->id(), info->num, (info->message_opcode == WS_TEXT) ? "text" : "binary", info->index, info->index + len);
|
||||
|
||||
if (info->opcode == WS_TEXT) {
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
msg += (char) data[i];
|
||||
}
|
||||
} else {
|
||||
char buff[3];
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
sprintf(buff, "%02x ", (uint8_t) data[i]);
|
||||
msg += buff ;
|
||||
}
|
||||
}
|
||||
Serial.printf("%s\n", msg.c_str());
|
||||
|
||||
if ((info->index + len) == info->len) {
|
||||
Serial.printf("ws[%s][%u] frame[%u] end[%llu]\n", server->url(), client->id(), info->num, info->len);
|
||||
if (info->final) {
|
||||
Serial.printf("ws[%s][%u] %s-message end\n", server->url(), client->id(), (info->message_opcode == WS_TEXT) ? "text" : "binary");
|
||||
if (info->message_opcode == WS_TEXT)
|
||||
client->text("I got your text message");
|
||||
else
|
||||
client->binary("I got your binary message");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
207
WiFi.ino
207
WiFi.ino
@@ -1,207 +0,0 @@
|
||||
void WIFI_init() {
|
||||
|
||||
// --------------------Получаем ssid password со страницы
|
||||
server.on("/ssid", HTTP_GET, [](AsyncWebServerRequest * request) {
|
||||
if (request->hasArg("ssid")) {
|
||||
jsonWriteStr(configSetup, "ssid", request->getParam("ssid")->value());
|
||||
}
|
||||
if (request->hasArg("password")) {
|
||||
jsonWriteStr(configSetup, "password", request->getParam("password")->value());
|
||||
}
|
||||
saveConfig(); // Функция сохранения данных во Flash
|
||||
request->send(200, "text/text", "OK"); // отправляем ответ о выполнении
|
||||
});
|
||||
// --------------------Получаем ssidAP passwordAP со страницы
|
||||
server.on("/ssidap", HTTP_GET, [](AsyncWebServerRequest * request) {
|
||||
if (request->hasArg("ssidAP")) {
|
||||
jsonWriteStr(configSetup, "ssidAP", request->getParam("ssidAP")->value());
|
||||
}
|
||||
if (request->hasArg("passwordAP")) {
|
||||
jsonWriteStr(configSetup, "passwordAP", request->getParam("passwordAP")->value());
|
||||
}
|
||||
saveConfig(); // Функция сохранения данных во Flash
|
||||
request->send(200, "text/text", "OK"); // отправляем ответ о выполнении
|
||||
});
|
||||
|
||||
// --------------------Получаем логин и пароль для web со страницы
|
||||
server.on("/web", HTTP_GET, [](AsyncWebServerRequest * request) {
|
||||
if (request->hasArg("web_login")) {
|
||||
jsonWriteStr(configSetup, "web_login", request->getParam("web_login")->value());
|
||||
}
|
||||
if (request->hasArg("web_pass")) {
|
||||
jsonWriteStr(configSetup, "web_pass", request->getParam("web_pass")->value());
|
||||
}
|
||||
saveConfig(); // Функция сохранения данных во Flash
|
||||
//Web_server_init();
|
||||
request->send(200, "text/text", "OK"); // отправляем ответ о выполнении
|
||||
});
|
||||
|
||||
server.on("/restart", HTTP_GET, [](AsyncWebServerRequest * request) {
|
||||
if (request->hasArg("device")) {
|
||||
if (request->getParam("device")->value() == "ok") ESP.restart();
|
||||
}
|
||||
request->send(200, "text/text", "OK"); // отправляем ответ о выполнении
|
||||
});
|
||||
ROUTER_Connecting();
|
||||
}
|
||||
|
||||
void ROUTER_Connecting() {
|
||||
|
||||
WiFi.mode(WIFI_STA);
|
||||
|
||||
byte tries = 20;
|
||||
String _ssid = jsonRead(configSetup, "ssid");
|
||||
String _password = jsonRead(configSetup, "password");
|
||||
//WiFi.persistent(false);
|
||||
|
||||
if (_ssid == "" && _password == "") {
|
||||
WiFi.begin();
|
||||
}
|
||||
else {
|
||||
WiFi.begin(_ssid.c_str(), _password.c_str());
|
||||
Serial.print("ssid: ");
|
||||
Serial.println(_ssid);
|
||||
}
|
||||
// Делаем проверку подключения до тех пор пока счетчик tries
|
||||
// не станет равен нулю или не получим подключение
|
||||
while (--tries && WiFi.status() != WL_CONNECTED)
|
||||
{
|
||||
if (WiFi.status() == WL_CONNECT_FAILED) {
|
||||
Serial.println("[E] password is not correct");
|
||||
tries = 1;
|
||||
jsonWriteInt(optionJson, "pass_status", 1);
|
||||
}
|
||||
Serial.print(".");
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
if (WiFi.status() != WL_CONNECTED)
|
||||
{
|
||||
// Если не удалось подключиться запускаем в режиме AP
|
||||
Serial.println("");
|
||||
// WiFi.disconnect(true);
|
||||
StartAPMode();
|
||||
|
||||
}
|
||||
else {
|
||||
// Иначе удалось подключиться отправляем сообщение
|
||||
// о подключении и выводим адрес IP
|
||||
Serial.println("");
|
||||
Serial.println("[V] WiFi connected");
|
||||
Serial.print("[V] IP address: http://");
|
||||
Serial.print(WiFi.localIP());
|
||||
Serial.println("");
|
||||
jsonWriteStr(configJson, "ip", WiFi.localIP().toString());
|
||||
|
||||
//add_dev_in_list("dev.txt", chipID, WiFi.localIP().toString());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
bool StartAPMode() {
|
||||
Serial.println("WiFi up AP");
|
||||
WiFi.disconnect();
|
||||
|
||||
WiFi.mode(WIFI_AP);
|
||||
|
||||
String _ssidAP = jsonRead(configSetup, "ssidAP");
|
||||
String _passwordAP = jsonRead(configSetup, "passwordAP");
|
||||
WiFi.softAP(_ssidAP.c_str(), _passwordAP.c_str());
|
||||
IPAddress myIP = WiFi.softAPIP();
|
||||
Serial.print("AP IP address: ");
|
||||
Serial.println(myIP);
|
||||
jsonWriteStr(configJson, "ip", myIP.toString());
|
||||
|
||||
if (jsonReadtoInt(optionJson, "pass_status") != 1) {
|
||||
ts.add(ROUTER_SEARCHING, 10 * 1000, [&](void*) {
|
||||
Serial.println("->try find router");
|
||||
if (RouterFind(jsonRead(configSetup, "ssid"))) {
|
||||
ts.remove(ROUTER_SEARCHING);
|
||||
ROUTER_Connecting();
|
||||
MQTT_Connecting();
|
||||
}
|
||||
}, nullptr, true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
boolean RouterFind(String ssid) {
|
||||
int n = WiFi.scanComplete ();
|
||||
Serial.println("n = " + String(n));
|
||||
if (n == -2) { //Сканирование не было запущено, запускаем
|
||||
Serial.println("[WIFI][i] scanning has not been triggered, starting scanning");
|
||||
WiFi.scanNetworks (true, false); //async, show_hidden
|
||||
return false;
|
||||
}
|
||||
if (n == -1) { //Сканирование все еще выполняется
|
||||
Serial.println("[WIFI][i] scanning still in progress");
|
||||
return false;
|
||||
}
|
||||
if (n == 0) { //Сканирование все еще выполняется
|
||||
Serial.println("[WIFI][i] no any wifi sations, starting scanning");
|
||||
WiFi.scanNetworks (true, false);
|
||||
return false;
|
||||
}
|
||||
if (n > 0) {
|
||||
for (int i = 0; i <= n; i++) {
|
||||
if (WiFi.SSID (i) == ssid) {
|
||||
WiFi.scanDelete();
|
||||
return true;
|
||||
} else {
|
||||
Serial.print(i);
|
||||
Serial.print(")");
|
||||
//Serial.print(ssid);
|
||||
//Serial.print("<=>");
|
||||
if (i == n) {
|
||||
Serial.print(WiFi.SSID(i));
|
||||
Serial.println("; ");
|
||||
} else {
|
||||
Serial.print(WiFi.SSID(i));
|
||||
Serial.println("; ");
|
||||
}
|
||||
}
|
||||
}
|
||||
WiFi.scanDelete();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
String scanWIFI() {
|
||||
uint8_t n = WiFi.scanNetworks();
|
||||
DynamicJsonBuffer jsonBuffer;
|
||||
JsonObject& json = jsonBuffer.createObject();
|
||||
JsonArray& networks = json.createNestedArray("networks");
|
||||
for (uint8_t i = 0; i < n; i++) {
|
||||
JsonObject& data = networks.createNestedObject();
|
||||
String ssidMy = WiFi.SSID(i);
|
||||
data["ssid"] = ssidMy;
|
||||
data["pass"] = (WiFi.encryptionType(i) == ENC_TYPE_NONE) ? "" : "*";
|
||||
int8_t dbm = WiFi.RSSI(i);
|
||||
data["dbm"] = dbm;
|
||||
if (ssidMy == jsonRead(configSetup, "ssid")) {
|
||||
jsonWriteStr(configJson, "dbm", dbm);
|
||||
}
|
||||
}
|
||||
String root;
|
||||
json.printTo(root);
|
||||
return root;
|
||||
}
|
||||
*/
|
||||
/*
|
||||
{
|
||||
"type":"wifi",
|
||||
"title":"{{LangWiFi1}}",
|
||||
"name":"ssid",
|
||||
"state":"{{ssid}}",
|
||||
"pattern":".{1,}"
|
||||
},
|
||||
{
|
||||
"type":"password",
|
||||
"title":"{{LangPass}}",
|
||||
"name":"ssidPass",
|
||||
"state":"{{ssidPass}}",
|
||||
"pattern":".{8,}"
|
||||
},
|
||||
*/
|
||||
49
Widgets.ino
49
Widgets.ino
@@ -1,49 +0,0 @@
|
||||
//======================================================================================================================
|
||||
//===============================================Создание виджетов=======================================================
|
||||
void createWidget (String widget_name, String page_name, String page_number, String file, String topic) {
|
||||
|
||||
String widget;
|
||||
widget = readFile(file, 1024);
|
||||
|
||||
if (widget == "Failed") return;
|
||||
if (widget == "Large") return;
|
||||
|
||||
widget_name.replace("#", " ");
|
||||
page_name.replace("#", " ");
|
||||
|
||||
jsonWriteStr(widget, "page", page_name);
|
||||
jsonWriteStr(widget, "order", page_number);
|
||||
jsonWriteStr(widget, "descr", widget_name);
|
||||
jsonWriteStr(widget, "topic", prex + "/" + topic);
|
||||
#ifdef layout_in_ram
|
||||
all_widgets += widget + "\r\n";
|
||||
#else
|
||||
addFile("layout.txt", widget);
|
||||
#endif
|
||||
widget = "";
|
||||
}
|
||||
|
||||
void createChart (String widget_name, String page_name, String page_number, String file, String topic, String maxCount) {
|
||||
|
||||
String widget;
|
||||
widget = readFile(file, 1024);
|
||||
|
||||
if (widget == "Failed") return;
|
||||
if (widget == "Large") return;
|
||||
|
||||
widget_name.replace("#", " ");
|
||||
page_name.replace("#", " ");
|
||||
|
||||
jsonWriteStr(widget, "page", page_name);
|
||||
jsonWriteStr(widget, "order", page_number);
|
||||
//jsonWriteStr(widget, "descr", widget_name);
|
||||
jsonWriteStr(widget, "series", widget_name);
|
||||
jsonWriteStr(widget, "maxCount", maxCount);
|
||||
jsonWriteStr(widget, "topic", prex + "/" + topic);
|
||||
#ifdef layout_in_ram
|
||||
all_widgets += widget + "\r\n";
|
||||
#else
|
||||
addFile("layout.txt", widget);
|
||||
#endif
|
||||
widget = "";
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
const char* local_root_ca1 = \
|
||||
"-----BEGIN CERTIFICATE-----\n" \
|
||||
"MIIFdDCCBFygAwIBAgIQJ2buVutJ846r13Ci/ITeIjANBgkqhkiG9w0BAQwFADBv\n" \
|
||||
"MQswCQYDVQQGEwJTRTEUMBIGA1UEChMLQWRkVHJ1c3QgQUIxJjAkBgNVBAsTHUFk\n" \
|
||||
"ZFRydXN0IEV4dGVybmFsIFRUUCBOZXR3b3JrMSIwIAYDVQQDExlBZGRUcnVzdCBF\n" \
|
||||
"eHRlcm5hbCBDQSBSb290MB4XDTAwMDUzMDEwNDgzOFoXDTIwMDUzMDEwNDgzOFow\n" \
|
||||
"gYUxCzAJBgNVBAYTAkdCMRswGQYDVQQIExJHcmVhdGVyIE1hbmNoZXN0ZXIxEDAO\n" \
|
||||
"BgNVBAcTB1NhbGZvcmQxGjAYBgNVBAoTEUNPTU9ETyBDQSBMaW1pdGVkMSswKQYD\n" \
|
||||
"VQQDEyJDT01PRE8gUlNBIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIICIjANBgkq\n" \
|
||||
"hkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAkehUktIKVrGsDSTdxc9EZ3SZKzejfSNw\n" \
|
||||
"AHG8U9/E+ioSj0t/EFa9n3Byt2F/yUsPF6c947AEYe7/EZfH9IY+Cvo+XPmT5jR6\n" \
|
||||
"2RRr55yzhaCCenavcZDX7P0N+pxs+t+wgvQUfvm+xKYvT3+Zf7X8Z0NyvQwA1onr\n" \
|
||||
"ayzT7Y+YHBSrfuXjbvzYqOSSJNpDa2K4Vf3qwbxstovzDo2a5JtsaZn4eEgwRdWt\n" \
|
||||
"4Q08RWD8MpZRJ7xnw8outmvqRsfHIKCxH2XeSAi6pE6p8oNGN4Tr6MyBSENnTnIq\n" \
|
||||
"m1y9TBsoilwie7SrmNnu4FGDwwlGTm0+mfqVF9p8M1dBPI1R7Qu2XK8sYxrfV8g/\n" \
|
||||
"vOldxJuvRZnio1oktLqpVj3Pb6r/SVi+8Kj/9Lit6Tf7urj0Czr56ENCHonYhMsT\n" \
|
||||
"8dm74YlguIwoVqwUHZwK53Hrzw7dPamWoUi9PPevtQ0iTMARgexWO/bTouJbt7IE\n" \
|
||||
"IlKVgJNp6I5MZfGRAy1wdALqi2cVKWlSArvX31BqVUa/oKMoYX9w0MOiqiwhqkfO\n" \
|
||||
"KJwGRXa/ghgntNWutMtQ5mv0TIZxMOmm3xaG4Nj/QN370EKIf6MzOi5cHkERgWPO\n" \
|
||||
"GHFrK+ymircxXDpqR+DDeVnWIBqv8mqYqnK8V0rSS527EPywTEHl7R09XiidnMy/\n" \
|
||||
"s1Hap0flhFMCAwEAAaOB9DCB8TAfBgNVHSMEGDAWgBStvZh6NLQm9/rEJlTvA73g\n" \
|
||||
"JMtUGjAdBgNVHQ4EFgQUu69+Aj36pvE8hI6t7jiY7NkyMtQwDgYDVR0PAQH/BAQD\n" \
|
||||
"AgGGMA8GA1UdEwEB/wQFMAMBAf8wEQYDVR0gBAowCDAGBgRVHSAAMEQGA1UdHwQ9\n" \
|
||||
"MDswOaA3oDWGM2h0dHA6Ly9jcmwudXNlcnRydXN0LmNvbS9BZGRUcnVzdEV4dGVy\n" \
|
||||
"bmFsQ0FSb290LmNybDA1BggrBgEFBQcBAQQpMCcwJQYIKwYBBQUHMAGGGWh0dHA6\n" \
|
||||
"Ly9vY3NwLnVzZXJ0cnVzdC5jb20wDQYJKoZIhvcNAQEMBQADggEBAGS/g/FfmoXQ\n" \
|
||||
"zbihKVcN6Fr30ek+8nYEbvFScLsePP9NDXRqzIGCJdPDoCpdTPW6i6FtxFQJdcfj\n" \
|
||||
"Jw5dhHk3QBN39bSsHNA7qxcS1u80GH4r6XnTq1dFDK8o+tDb5VCViLvfhVdpfZLY\n" \
|
||||
"Uspzgb8c8+a4bmYRBbMelC1/kZWSWfFMzqORcUx8Rww7Cxn2obFshj5cqsQugsv5\n" \
|
||||
"B5a6SE2Q8pTIqXOi6wZ7I53eovNNVZ96YUWYGGjHXkBrI/V5eu+MtWuLt29G9Hvx\n" \
|
||||
"PUsE2JOAWVrgQSQdso8VYFhH2+9uRv0V9dlfmrPb2LjkQLPNlzmuhbsdjrzch5vR\n" \
|
||||
"pu/xO28QOG8=\n" \
|
||||
"-----END CERTIFICATE-----\n";
|
||||
|
||||
const char* local_root_ca2 = \
|
||||
"-----BEGIN CERTIFICATE-----\n" \
|
||||
"MIIGCDCCA/CgAwIBAgIQKy5u6tl1NmwUim7bo3yMBzANBgkqhkiG9w0BAQwFADCB\n" \
|
||||
"hTELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4G\n" \
|
||||
"A1UEBxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNV\n" \
|
||||
"BAMTIkNPTU9ETyBSU0EgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTQwMjEy\n" \
|
||||
"MDAwMDAwWhcNMjkwMjExMjM1OTU5WjCBkDELMAkGA1UEBhMCR0IxGzAZBgNVBAgT\n" \
|
||||
"EkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UEChMR\n" \
|
||||
"Q09NT0RPIENBIExpbWl0ZWQxNjA0BgNVBAMTLUNPTU9ETyBSU0EgRG9tYWluIFZh\n" \
|
||||
"bGlkYXRpb24gU2VjdXJlIFNlcnZlciBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEP\n" \
|
||||
"ADCCAQoCggEBAI7CAhnhoFmk6zg1jSz9AdDTScBkxwtiBUUWOqigwAwCfx3M28Sh\n" \
|
||||
"bXcDow+G+eMGnD4LgYqbSRutA776S9uMIO3Vzl5ljj4Nr0zCsLdFXlIvNN5IJGS0\n" \
|
||||
"Qa4Al/e+Z96e0HqnU4A7fK31llVvl0cKfIWLIpeNs4TgllfQcBhglo/uLQeTnaG6\n" \
|
||||
"ytHNe+nEKpooIZFNb5JPJaXyejXdJtxGpdCsWTWM/06RQ1A/WZMebFEh7lgUq/51\n" \
|
||||
"UHg+TLAchhP6a5i84DuUHoVS3AOTJBhuyydRReZw3iVDpA3hSqXttn7IzW3uLh0n\n" \
|
||||
"c13cRTCAquOyQQuvvUSH2rnlG51/ruWFgqUCAwEAAaOCAWUwggFhMB8GA1UdIwQY\n" \
|
||||
"MBaAFLuvfgI9+qbxPISOre44mOzZMjLUMB0GA1UdDgQWBBSQr2o6lFoL2JDqElZz\n" \
|
||||
"30O0Oija5zAOBgNVHQ8BAf8EBAMCAYYwEgYDVR0TAQH/BAgwBgEB/wIBADAdBgNV\n" \
|
||||
"HSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwGwYDVR0gBBQwEjAGBgRVHSAAMAgG\n" \
|
||||
"BmeBDAECATBMBgNVHR8ERTBDMEGgP6A9hjtodHRwOi8vY3JsLmNvbW9kb2NhLmNv\n" \
|
||||
"bS9DT01PRE9SU0FDZXJ0aWZpY2F0aW9uQXV0aG9yaXR5LmNybDBxBggrBgEFBQcB\n" \
|
||||
"AQRlMGMwOwYIKwYBBQUHMAKGL2h0dHA6Ly9jcnQuY29tb2RvY2EuY29tL0NPTU9E\n" \
|
||||
"T1JTQUFkZFRydXN0Q0EuY3J0MCQGCCsGAQUFBzABhhhodHRwOi8vb2NzcC5jb21v\n" \
|
||||
"ZG9jYS5jb20wDQYJKoZIhvcNAQEMBQADggIBAE4rdk+SHGI2ibp3wScF9BzWRJ2p\n" \
|
||||
"mj6q1WZmAT7qSeaiNbz69t2Vjpk1mA42GHWx3d1Qcnyu3HeIzg/3kCDKo2cuH1Z/\n" \
|
||||
"e+FE6kKVxF0NAVBGFfKBiVlsit2M8RKhjTpCipj4SzR7JzsItG8kO3KdY3RYPBps\n" \
|
||||
"P0/HEZrIqPW1N+8QRcZs2eBelSaz662jue5/DJpmNXMyYE7l3YphLG5SEXdoltMY\n" \
|
||||
"dVEVABt0iN3hxzgEQyjpFv3ZBdRdRydg1vs4O2xyopT4Qhrf7W8GjEXCBgCq5Ojc\n" \
|
||||
"2bXhc3js9iPc0d1sjhqPpepUfJa3w/5Vjo1JXvxku88+vZbrac2/4EjxYoIQ5QxG\n" \
|
||||
"V/Iz2tDIY+3GH5QFlkoakdH368+PUq4NCNk+qKBR6cGHdNXJ93SrLlP7u3r7l+L4\n" \
|
||||
"HyaPs9Kg4DdbKDsx5Q5XLVq4rXmsXiBmGqW5prU5wfWYQ//u+aen/e7KJD2AFsQX\n" \
|
||||
"j4rBYKEMrltDR5FL1ZoXX/nUh8HCjLfn4g8wGTeGrODcQgPmlKidrv0PJFGUzpII\n" \
|
||||
"0fxQ8ANAe4hZ7Q7drNJ3gjTcBpUC2JD5Leo31Rpg0Gcg19hCC0Wvgmje3WYkN5Ap\n" \
|
||||
"lBlGGSW4gNfL1IYoakRwJiNiqZ+Gb7+6kHDSVneFeO/qJakXzlByjAA6quPbYzSf\n" \
|
||||
"+AZxAeKCINT+b72x\n" \
|
||||
"-----END CERTIFICATE-----\n";
|
||||
*/
|
||||
@@ -1,18 +0,0 @@
|
||||
{
|
||||
"name": "IoTmanager",
|
||||
"chipID": "",
|
||||
"ssidAP": "WiFi",
|
||||
"passwordAP": "",
|
||||
"ssid": "your_ssid",
|
||||
"password": "your_password",
|
||||
"timezone": 3,
|
||||
"mqttServer": "",
|
||||
"mqttPort": 0,
|
||||
"mqttPrefix": "/IoTmanager",
|
||||
"mqttUser": "",
|
||||
"mqttPass": "",
|
||||
"scenario": "1",
|
||||
"pushingbox_id": "",
|
||||
"web_login": "admin",
|
||||
"web_pass": "admin"
|
||||
}
|
||||
@@ -1,18 +1,37 @@
|
||||
{
|
||||
"name": "IoTmanager",
|
||||
"chipID": "",
|
||||
"ssidAP": "WiFi",
|
||||
"passwordAP": "",
|
||||
"ssid": "rise",
|
||||
"password": "hostel3333",
|
||||
"timezone": 2,
|
||||
"mqttServer": "mqtt.ioty.ru",
|
||||
"apssid": "IoTmanager",
|
||||
"appass": "",
|
||||
"routerssid": "rise",
|
||||
"routerpass": "hostel3333",
|
||||
"timezone": 1,
|
||||
"ntp": "pool.ntp.org",
|
||||
"mqttServer": "91.204.228.124",
|
||||
"mqttPort": 1883,
|
||||
"mqttPrefix": "/rise",
|
||||
"mqttUser": "test",
|
||||
"mqttPass": "test",
|
||||
"scenario": "1",
|
||||
"pushingbox_id": "",
|
||||
"web_login": "admin",
|
||||
"web_pass": "admin"
|
||||
"mqttPrefix": "/iotTest",
|
||||
"mqttUser": "rise",
|
||||
"mqttPass": "23ri22se32",
|
||||
"mqttServer2": "",
|
||||
"mqttPort2": 1883,
|
||||
"mqttPrefix2": "/iotTest",
|
||||
"mqttUser2": "",
|
||||
"mqttPass2": "",
|
||||
"scen": "1",
|
||||
"telegramApi": "1416711569:AAEI0j83GmXqwzb_gnK1B0Am0gDwZoJt5xo",
|
||||
"telegonof": "0",
|
||||
"teleginput": "0",
|
||||
"autos": "1",
|
||||
"weblogin": "admin",
|
||||
"webpass": "admin",
|
||||
"MqttIn": "0",
|
||||
"MqttOut": "0",
|
||||
"blink": "0",
|
||||
"oneWirePin": "2",
|
||||
"serverip": "http://206.189.49.244",
|
||||
"uart": "0",
|
||||
"uartS": "9600",
|
||||
"uartTX": "12",
|
||||
"uartRX": "13",
|
||||
"grafmax": "0"
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
analog 0 Аналоговый#вход,#% Датчики progress-round 310 620 1 100 1
|
||||
logging analog 5 100 slow Аналоговый#вход Датчики 2
|
||||
|
||||
//если датчик углекислого газа выдает напряжение от 1 вольта до 2 вольт, то значит
|
||||
//значение чтения аналогового входа будут примерно равным
|
||||
//при 1 вольте - 310, а при 2 вольтах - 620 (считаем по пропорции)
|
||||
//данная строка переведет диапазон 310-620 в диапазон 1-100 и отобразит в приложении
|
||||
//варианты отображения: any-data, progress-round, progress-line, fill-gauge
|
||||
@@ -1 +0,0 @@
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
dallas 2 Водонагреватель,#t°C Датчики any-data 1
|
||||
logging dallas 1 100 slow Температура Датчики 2
|
||||
|
||||
//2 - номер пина датчика
|
||||
//варианты отображения: any-data, progress-round, progress-line, fill-gauge
|
||||
@@ -1 +0,0 @@
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
dhtT DHT11 2 Температура#DHT,#t°C Датчики any-data 1
|
||||
dhtH DHT11 2 Влажность#DHT,#% Датчики any-data 2
|
||||
dhtComfort Степень#комфорта: Датчики 3
|
||||
dhtPerception Восприятие: Датчики 4
|
||||
dhtDewpoint Точка#росы: Датчики 5
|
||||
logging dhtT 5 50 slow Температура Датчики 6
|
||||
logging dhtH 5 50 slow Влажность Датчики 7
|
||||
|
||||
//2 - номер пина датчика
|
||||
//варианты отображения: any-data, progress-round, progress-line, fill-gauge
|
||||
@@ -1 +0,0 @@
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
dhtT DHT22 2 Температура#DHT,#t°C Датчики any-data 1
|
||||
dhtH DHT22 2 Влажность#DHT,#% Датчики any-data 2
|
||||
dhtComfort Степень#комфорта: Датчики 3
|
||||
dhtPerception Восприятие: Датчики 4
|
||||
dhtDewpoint Точка#росы: Датчики 5
|
||||
logging dhtT 5 50 slow Температура Датчики 6
|
||||
logging dhtH 5 50 slow Влажность Датчики 7
|
||||
|
||||
//2 - номер пина датчика
|
||||
//варианты отображения: any-data, progress-round, progress-line, fill-gauge
|
||||
@@ -1 +0,0 @@
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
button 1 na Включить#все Реле 0 1
|
||||
button 2 13 Прихожая Реле 0 2
|
||||
button 3 14 Кухня Реле 0 3
|
||||
pwm 1 3 Яркость#коредор: Реле 1023 4
|
||||
pwm 2 4 Яркость#ванная: Реле 510 5
|
||||
analog 0 Аналоговый#вход Датчики fill-gauge 1 1023 1 1023 6
|
||||
logging analog 1 100 slow Аналоговый#вход Датчики 7
|
||||
|
||||
//Это демо конфигурация. В ней показано как связать кнопки c мощью сценариев
|
||||
//Кнопка номер 1 связана с кнопкой 2, 3 и с pwm 2
|
||||
//Так же продемонстрированна система логгирования данных строкой logging
|
||||
//1 - это интервал между точками в минутах, 100 это количество точек
|
||||
//slow или fast это два варианта выгрузки графика, slow более экономичный режим
|
||||
//больше подходит для esp8266
|
||||
@@ -1,10 +0,0 @@
|
||||
button1 = 1
|
||||
buttonSet 2 1
|
||||
buttonSet 3 1
|
||||
pwmSet 2 1024
|
||||
end
|
||||
button1 = 0
|
||||
buttonSet 2 0
|
||||
buttonSet 3 0
|
||||
pwmSet 2 0
|
||||
end
|
||||
@@ -1,11 +0,0 @@
|
||||
level Вода#в#баке,#% Датчики fill-gauge 125 20 1
|
||||
inputDigit digit1 При#скольки#выключить? Датчики 95 2
|
||||
inputDigit digit2 При#скольки#включить? Датчики 10 3
|
||||
button 1 5 Насос Датчики 0 4
|
||||
button 2 line1,line2, Автоматический#режим Датчики 1 5
|
||||
logging level 1 100 slow Вода#в#баке Датчики 6
|
||||
|
||||
//125 - это расстояние от датчика до дна бака в сантиметрах
|
||||
//20 - это расстояние от датчика до поверхности воды когда бак полный в сантиметрах
|
||||
//вывод данных будет в процентах заполнения бака
|
||||
//варианты отображения: any-data, progress-round, progress-line, fill-gauge
|
||||
@@ -1,6 +0,0 @@
|
||||
level > digit1
|
||||
buttonSet 1 0
|
||||
end
|
||||
level < digit2
|
||||
buttonSet 1 1
|
||||
end
|
||||
@@ -1,11 +0,0 @@
|
||||
button 1 5 Прихожая Освещение 0 1
|
||||
inputDigit digit1 Задержка#выключения Освещение 30 2
|
||||
switch 1 0 10
|
||||
|
||||
//0 - номер пина датчика движения
|
||||
//5 - номер пина реле
|
||||
//при срабатывании датчика движения включится реле и обратный таймер на 30 сек
|
||||
//если движение не будет обнаружено повтороно в течении 30 секунд - свет выключится
|
||||
//если движение повторится в течении 30 секунд то таймер продлится опять на 30 сек
|
||||
//свет выключится только в том случае если в комнате все замрет на 30 сек
|
||||
//задержку выключения можно будет настраивать в приложении
|
||||
@@ -1,7 +0,0 @@
|
||||
switch1 = 1
|
||||
timerStart 1 digit1 sec
|
||||
buttonSet 1 1
|
||||
end
|
||||
timer1 = 0
|
||||
buttonSet 1 0
|
||||
end
|
||||
@@ -1,12 +0,0 @@
|
||||
switch 1 0 20
|
||||
text 1 Вход: Охрана 1
|
||||
textSet 1 не#обнаружено-time
|
||||
button 1 na Сбросить Охрана 0 2
|
||||
button 2 line3, Включить#push Охрана 1 3
|
||||
|
||||
//0 - номер пина датчика
|
||||
//при срабатывании датчика движения устройство пошлет пуш и в приложении будет
|
||||
//написано в текстовом поле, что движение было обнаружено
|
||||
//так же будет зафиксирован момент времени срабатывания датчика
|
||||
//в приложении можно отключать отправку пуш сообщений на тот случай если дома хозяин
|
||||
//перевести датчик снова в режим ожидания движения можно нажав кнопку сброса в приложении
|
||||
@@ -1,10 +0,0 @@
|
||||
switch1 = 1
|
||||
textSet 1 обнаружено#движение-time
|
||||
end
|
||||
button1 = 1
|
||||
textSet 1 не#обнаружено-time
|
||||
buttonSet 1 0
|
||||
end
|
||||
switch1 = 1
|
||||
push Внимание обнаружено#движение!
|
||||
end
|
||||
@@ -1,6 +0,0 @@
|
||||
pwm 1 3 Яркость#коредор: Реле 1023 1
|
||||
pwm 2 4 Яркость#ванная: Реле 510 2
|
||||
|
||||
//в приложении появятся ползунки, соответствующее значение pwm
|
||||
//будет установленно на пинах 3 и 4
|
||||
//1023 и 510 это начальные значения после загрузки модуля
|
||||
@@ -1 +0,0 @@
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
button 1 5 Включить#реле Реле 0 1
|
||||
|
||||
//это простая кнопка номер 1 управляющая пином 5 имеющая начальное состояние 0
|
||||
@@ -1 +0,0 @@
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
button 1 5 Включить#все Реле 0 1
|
||||
|
||||
|
||||
//что бы использовать эту конфигурацию на другой esp необходимо активировать пресет
|
||||
//"Вкл. выкл. локального реле", затем в сценарии данного модуля подставить Device ID
|
||||
//того esp, кнопка на этом девайсе будет выключать другие устройства по воздуху
|
||||
@@ -1,8 +0,0 @@
|
||||
button1 = 1
|
||||
mqtt 3233662-1589485 buttonSet_1_1
|
||||
mqtt 2233662-1589486 buttonSet_1_1
|
||||
end
|
||||
button1 = 0
|
||||
mqtt 3233662-1589485 buttonSet_1_0
|
||||
mqtt 2233662-1589486 buttonSet_1_0
|
||||
end
|
||||
@@ -1,4 +0,0 @@
|
||||
button 1 5 Вкл#на#время Таймеры 0 1
|
||||
inputDigit digit1 Через#сколько#секунд#выключить? Таймеры 5 2
|
||||
|
||||
//в сценариях можно поменять на sec, min или hours если нужны другие размерности времени
|
||||
@@ -1,6 +0,0 @@
|
||||
button1 = 1
|
||||
timerStart 1 digit1 sec
|
||||
end
|
||||
timer1 = 0
|
||||
buttonSet 1 0
|
||||
end
|
||||
@@ -1,3 +0,0 @@
|
||||
switch 1 0 10
|
||||
|
||||
//физическая кнопка номер 1 подключенная к пину 0, задержка от дребезга 10 мс
|
||||
@@ -1,3 +0,0 @@
|
||||
switch1 = 1
|
||||
mqtt 3233662-1589489 buttonChange_1
|
||||
end
|
||||
@@ -1,3 +0,0 @@
|
||||
button 1 na Включить#все Освещение 0 1
|
||||
|
||||
//при нажатии на эту кнопку пины номер 5 и 13 поведут себя как установленно в сценариях
|
||||
@@ -1,8 +0,0 @@
|
||||
button1 = 1
|
||||
pinSet 5 1
|
||||
pinSet 13 0
|
||||
end
|
||||
button1 = 0
|
||||
pinSet 5 0
|
||||
pinSet 13 1
|
||||
end
|
||||
@@ -1,6 +0,0 @@
|
||||
switch 1 0 10
|
||||
|
||||
//что бы использовать эту конфигурацию на другой esp необходимо активировать пресет
|
||||
//"Вкл. выкл. локального реле", затем в сценарии данного модуля подставить Device ID
|
||||
//того esp, к данному модулю нужно подключить кнопку к пину 0 и тогда
|
||||
//один девайс будет управлять другим по воздуху
|
||||
@@ -1,4 +0,0 @@
|
||||
switch1 = 1
|
||||
mqtt 3233662-1589485 buttonChange_1
|
||||
mqtt 2233662-1589486 buttonChange_1
|
||||
end
|
||||
@@ -1,4 +0,0 @@
|
||||
button 1 13 Включить#реле Реле 0 1
|
||||
switch 1 0 10
|
||||
|
||||
//можно управлять реле на пине 13 кнопкой на пине 0 или кнопкой в приложении
|
||||
@@ -1,3 +0,0 @@
|
||||
switch1 = 1
|
||||
buttonChange 1
|
||||
end
|
||||
@@ -1,6 +0,0 @@
|
||||
inputTime time1 Во#сколько#включить? Таймеры 20-30-00 1
|
||||
inputTime time2 Во#сколько#выключить? Таймеры 20-35-00 2
|
||||
button 1 5 Кнопка#(по#таймеру) Таймеры 0 3
|
||||
|
||||
//время в приложение необходимо вводить в строгом формате: ЧЧ-ММ-СС
|
||||
//можно создавать любое количество таймеров, копируя строку inputTime...
|
||||
@@ -1,6 +0,0 @@
|
||||
timenow = time1
|
||||
buttonSet 1 1
|
||||
end
|
||||
timenow = time2
|
||||
buttonSet 1 0
|
||||
end
|
||||
@@ -1,17 +0,0 @@
|
||||
stepper 1 12 4
|
||||
stepper 2 13 5
|
||||
button 1 na Открыть#штору#1 Шторы 0 1
|
||||
button 2 na Открыть#штору#2 Шторы 0 2
|
||||
|
||||
//для подключения необходим драйвер шагового двигателя A4988
|
||||
|
||||
//stepper 1 12 4 шаговый двигатель с параметрами: 1 - номер шагового двигателя,
|
||||
//12 - номер пина количества шагов, 4 - номер пина направления
|
||||
|
||||
//stepper 2 13 5 шаговый двигатель с параметрами: 2 - номер шагового двигателя,
|
||||
//13 - номер пина количества шагов, 5 - номер пина направления
|
||||
|
||||
//stepperSet 1 200 5 - прокрутить шаговик номер 1 на 200 шагов по часовой стрелке
|
||||
//с задержкой между шагами 5 милисекунд (чем меньше задержка тем больше скорость)
|
||||
//если поставить -200 то будет вращаться против часовой стрелки
|
||||
//можно подключить не более двух шаговиков
|
||||
@@ -1,12 +0,0 @@
|
||||
button1 = 1
|
||||
stepperSet 1 200 1
|
||||
end
|
||||
button1 = 0
|
||||
stepperSet 1 -200 1
|
||||
end
|
||||
button2 = 1
|
||||
stepperSet 2 200 1
|
||||
end
|
||||
button2 = 0
|
||||
stepperSet 2 -200 1
|
||||
end
|
||||
@@ -1,12 +0,0 @@
|
||||
dallas 2 Водонагреватель,#t°C Термостат any-data 1
|
||||
logging dallas 5 100 slow Температура Термостат 2
|
||||
inputDigit digit1 При#скольки#выключить? Термостат 40 3
|
||||
inputDigit digit2 При#скольки#включить? Термостат 20 4
|
||||
button 1 5 Нагреватель Термостат 0 5
|
||||
button 2 line1,line2, Автоматический#режим Термостат 1 6
|
||||
|
||||
//2 - номер пина датчика
|
||||
//5 - номер пина реле
|
||||
//это термостат который будет держать температуру между двумя
|
||||
//установленными в приложении значениями, так же можно выключить
|
||||
//автоматический режим, и тогда нагреватель будет управляться в ручную
|
||||
@@ -1,6 +0,0 @@
|
||||
dallas > digit1
|
||||
buttonSet 1 0
|
||||
end
|
||||
dallas < digit2
|
||||
buttonSet 1 1
|
||||
end
|
||||
@@ -1,113 +0,0 @@
|
||||
{
|
||||
"configs": [
|
||||
"/config.live.json",
|
||||
"/config.setup.json",
|
||||
"/config.option.json"
|
||||
],
|
||||
"class": "col-sm-offset-1 col-sm-10",
|
||||
"content": [
|
||||
{
|
||||
"type": "h5",
|
||||
"title": "{{name}}",
|
||||
"class": "alert-warning"
|
||||
},
|
||||
{
|
||||
"type": "h4",
|
||||
"title": "Device ID: {{chipID}}"
|
||||
},
|
||||
{
|
||||
"type": "h4",
|
||||
"title": "IP address: {{ip}}"
|
||||
},
|
||||
{
|
||||
"type": "h4",
|
||||
"title": "Uptime: {{uptime}}"
|
||||
},
|
||||
{
|
||||
"type": "hr"
|
||||
},
|
||||
{
|
||||
"type": "dropdown",
|
||||
"name": "help-url",
|
||||
"class": "btn btn-warning btn-lg",
|
||||
"style": "display:inline",
|
||||
"title": {
|
||||
"#": "Выбирите то, во что Вы хотите превратить ESP <span class=\"caret\"></span>",
|
||||
"/preset?arg=1": "1.Вкл. выкл. локального реле",
|
||||
"/preset?arg=2": "2.Вкл. выкл. локального реле в определенное время",
|
||||
"/preset?arg=3": "3.Вкл. выкл. локального реле на определенный период времени",
|
||||
"/preset?arg=4": "4.Вкл. выкл. нескольких локальных реле кнопкой в приложении",
|
||||
"/preset?arg=5": "5.Вкл. выкл. локального реле физической кнопкой и кнопкой в приложении параллельно (для выключателя света)",
|
||||
"/preset?arg=6": "6.Вкл. выкл. нескольких удаленных реле кнопкой в приложении (нужно указать Device ID)",
|
||||
"/preset?arg=7": "7.Вкл. выкл. нескольких удаленных реле физической кнопкой (нужно указать Device ID)",
|
||||
"/preset?arg=8": "8.Широтно импульсная модуляция",
|
||||
"/preset?arg=9": "9.Сенсор DHT11 и логгирование",
|
||||
"/preset?arg=10": "10.Сенсор DHT22, DHT33, DHT44, AM2302, RHT03 и логгирование",
|
||||
"/preset?arg=11": "11.Аналоговый сенсор и логгирование",
|
||||
"/preset?arg=12": "12.Сенсор DS18B20 и логгирование",
|
||||
"/preset?arg=13": "13.Термостат на DS18B20 с переключением в ручной режим и логгированием",
|
||||
"/preset?arg=14": "14.Контроль уровня в баке на сенсорах: JSN-SR04T, HC-SR04, HY-SRF05 и логгирование (управление насосом)",
|
||||
"/preset?arg=15": "15.Датчик движения включающий свет",
|
||||
"/preset?arg=16": "16.Охранный датчик движения",
|
||||
"/preset?arg=17": "17.Система управления шаговыми двигателями на основе драйвера A4988 (открытие закрытие штор)",
|
||||
"/preset?arg=18": "Настройки по умолчанию"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "h2",
|
||||
"title": "Конфигурация устройства"
|
||||
},
|
||||
{
|
||||
"type": "file",
|
||||
"state": "firmware.c.txt",
|
||||
"style": "width:100%;height:400px",
|
||||
"title": "Сохранить",
|
||||
"action": "/init?arg=2",
|
||||
"class": "btn btn-block btn-success"
|
||||
},
|
||||
{
|
||||
"type": "link",
|
||||
"title": "Подробная инструкция",
|
||||
"action": "https://github.com/DmitryBorisenko33/esp32-esp8266_iot-manager_modules_firmware/wiki/Instruction",
|
||||
"class": "btn btn-block btn-primary"
|
||||
},
|
||||
{
|
||||
"type": "h2",
|
||||
"title": "Сценарии"
|
||||
},
|
||||
{
|
||||
"type": "checkbox",
|
||||
"name": "scenario",
|
||||
"title": "Включить сценарии",
|
||||
"action": "/init?arg=[[scenario]]",
|
||||
"state": "{{scenario}}"
|
||||
},
|
||||
{
|
||||
"type": "h6",
|
||||
"title": ""
|
||||
},
|
||||
{
|
||||
"type": "file",
|
||||
"state": "firmware.s.txt",
|
||||
"style": "width:100%;height:400px",
|
||||
"title": "Сохранить",
|
||||
"action": "/init?arg=4",
|
||||
"class": "btn btn-block btn-success"
|
||||
},
|
||||
{
|
||||
"type": "hr"
|
||||
},
|
||||
{
|
||||
"type": "link",
|
||||
"title": "Очистить логи сенсоров",
|
||||
"action": "/init?arg=3",
|
||||
"class": "btn btn-block btn-success"
|
||||
},
|
||||
{
|
||||
"type": "link",
|
||||
"title": "Главная",
|
||||
"action": "/",
|
||||
"class": "btn btn-block btn-danger btn-sm"
|
||||
}
|
||||
]
|
||||
}
|
||||
Binary file not shown.
@@ -1,65 +0,0 @@
|
||||
{
|
||||
"configs": [
|
||||
"/config.live.json",
|
||||
"/config.setup.json"
|
||||
],
|
||||
"title": "Главная",
|
||||
"class": "col-sm-offset-1 col-sm-10 col-md-offset-2 col-md-8 col-lg-offset-3 col-lg-6",
|
||||
"content": [
|
||||
{
|
||||
"type": "h5",
|
||||
"title": "{{name}}",
|
||||
"class": "alert-warning"
|
||||
},
|
||||
{
|
||||
"type": "h3",
|
||||
"title": "Список других устройств в сети:"
|
||||
},
|
||||
{
|
||||
"type": "hr"
|
||||
},
|
||||
{
|
||||
"type": "csv",
|
||||
"title": [
|
||||
"html",
|
||||
"html",
|
||||
"html"
|
||||
],
|
||||
"state": "dev.csv",
|
||||
"style": "width:100%;",
|
||||
"class": "nan"
|
||||
},
|
||||
{
|
||||
"type": "hr"
|
||||
},
|
||||
{
|
||||
"type": "link",
|
||||
"title": "Переформировать список устройств",
|
||||
"action": "udp?arg=2",
|
||||
"class": "btn btn-block btn-success"
|
||||
},
|
||||
{
|
||||
"type": "link",
|
||||
"title": "Обновить страницу",
|
||||
"action": "udp?arg=3",
|
||||
"class": "btn btn-block btn-success"
|
||||
},
|
||||
{
|
||||
"type": "hr"
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"class": "alert alert-warning",
|
||||
"title": "После нажатия на кнопку 'Переформировать список устройств' ждите примерно минуту, а затем обновите страницу и список появится вновь"
|
||||
},
|
||||
{
|
||||
"type": "hr"
|
||||
},
|
||||
{
|
||||
"type": "link",
|
||||
"title": "Главная",
|
||||
"action": "/",
|
||||
"class": "btn btn-block btn-danger"
|
||||
}
|
||||
]
|
||||
}
|
||||
0
data/dev_conf.txt
Normal file
0
data/dev_conf.txt
Normal file
BIN
data/edit.htm.gz
Normal file
BIN
data/edit.htm.gz
Normal file
Binary file not shown.
@@ -1,14 +0,0 @@
|
||||
button 1 na Включить#все Реле 0 1
|
||||
button 2 13 Прихожая Реле 0 2
|
||||
button 3 14 Кухня Реле 0 3
|
||||
pwm 1 3 Яркость#коредор: Реле 1023 4
|
||||
pwm 2 4 Яркость#ванная: Реле 510 5
|
||||
analog 0 Аналоговый#вход Датчики fill-gauge 1 1023 1 1023 6
|
||||
logging analog 1 100 slow Аналоговый#вход Датчики 7
|
||||
|
||||
//Это демо конфигурация. В ней показано как связать кнопки c мощью сценариев
|
||||
//Кнопка номер 1 связана с кнопкой 2, 3 и с pwm 2
|
||||
//Так же продемонстрированна система логгирования данных строкой logging
|
||||
//1 - это интервал между точками в минутах, 100 это количество точек
|
||||
//slow или fast это два варианта выгрузки графика, slow более экономичный режим
|
||||
//больше подходит для esp8266
|
||||
@@ -1,10 +0,0 @@
|
||||
button1 = 1
|
||||
buttonSet 2 1
|
||||
buttonSet 3 1
|
||||
pwmSet 2 1024
|
||||
end
|
||||
button1 = 0
|
||||
buttonSet 2 0
|
||||
buttonSet 3 0
|
||||
pwmSet 2 0
|
||||
end
|
||||
Binary file not shown.
102
data/index.json
102
data/index.json
@@ -1,102 +0,0 @@
|
||||
{
|
||||
"configs": [
|
||||
"/config.live.json",
|
||||
"/config.setup.json"
|
||||
],
|
||||
"title": "Главная",
|
||||
"class": "col-sm-offset-1 col-sm-10 col-md-offset-2 col-md-8 col-lg-offset-3 col-lg-6",
|
||||
"content": [
|
||||
{
|
||||
"type": "h5",
|
||||
"title": "{{name}}",
|
||||
"class": "alert-warning"
|
||||
},
|
||||
{
|
||||
"type": "h4",
|
||||
"title": "Device ID: {{chipID}}"
|
||||
},
|
||||
{
|
||||
"type": "h4",
|
||||
"title": "IP address: {{ip}}"
|
||||
},
|
||||
{
|
||||
"type": "h4",
|
||||
"title": "Uptime: {{uptime}}"
|
||||
},
|
||||
{
|
||||
"type": "h4",
|
||||
"title": "Build version: {{firmware_version}}"
|
||||
},
|
||||
{
|
||||
"type": "h4",
|
||||
"title": "SPIFFS version: 2.3.2"
|
||||
},
|
||||
{
|
||||
"type": "hr"
|
||||
},
|
||||
{
|
||||
"type": "link",
|
||||
"title": "Конфигурация устройства",
|
||||
"action": "/?configuration",
|
||||
"class": "btn btn-block btn-primary"
|
||||
},
|
||||
{
|
||||
"type": "hr"
|
||||
},
|
||||
{
|
||||
"type": "link",
|
||||
"title": "Список других устройств в сети",
|
||||
"action": "/?dev",
|
||||
"class": "btn btn-block btn-success"
|
||||
},
|
||||
{
|
||||
"type": "link",
|
||||
"title": "Конфигурация WIFI",
|
||||
"action": "/?setup",
|
||||
"class": "btn btn-block btn-success"
|
||||
},
|
||||
{
|
||||
"type": "link",
|
||||
"title": "Конфигурация MQTT",
|
||||
"action": "/?mqtt",
|
||||
"class": "btn btn-block btn-success"
|
||||
},
|
||||
{
|
||||
"type": "link",
|
||||
"title": "Конфигурация push",
|
||||
"action": "/?pushingbox",
|
||||
"class": "btn btn-block btn-success"
|
||||
},
|
||||
{
|
||||
"type": "h3",
|
||||
"name": "my-block",
|
||||
"style": "position:fixed;top:50%;left:50%;width:400px;margin-left:-200px;text-align:center;",
|
||||
"class": "hidden"
|
||||
},
|
||||
{
|
||||
"type": "hr"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"title": "Обновить прошивку",
|
||||
"action": "/check",
|
||||
"response": "[[my-block]]",
|
||||
"class": "btn btn-block btn-danger"
|
||||
},
|
||||
{
|
||||
"type": "hr"
|
||||
},
|
||||
{
|
||||
"type": "link",
|
||||
"title": "Скачать приложение IoT Manager для android",
|
||||
"action": "https://play.google.com/store/apps/details?id=ru.esp8266.iotmanager",
|
||||
"class": "btn btn-block btn-warning"
|
||||
},
|
||||
{
|
||||
"type": "link",
|
||||
"title": "Скачать приложение IoT Manager для iphone",
|
||||
"action": "https://apps.apple.com/ru/app/iot-manager/id1155934877",
|
||||
"class": "btn btn-block btn-warning"
|
||||
}
|
||||
]
|
||||
}
|
||||
BIN
data/index.json.gz
Normal file
BIN
data/index.json.gz
Normal file
Binary file not shown.
27
data/items/items.txt
Normal file
27
data/items/items.txt
Normal file
@@ -0,0 +1,27 @@
|
||||
0;button-out;btnid;toggle;Кнопки;Освещение;order;gpio*
|
||||
0;button-out;btnid;toggle;Кнопки;Освещение;order;gpio;inv[1]*
|
||||
0;button-out;btnid;toggle;Кнопки;Освещение;order*
|
||||
0;button-in;btnid;toggle;Кнопки;Освещение;order;gpio;db[20]*
|
||||
0;pwm-out;pwmid;range;Ползунки;Яркость;order;gpio*
|
||||
0;inoutput;dgtid;inputDigit;Ввод;Введите#цифру;order*
|
||||
0;inoutput;tmid;inputTime;Ввод;Введите#время;order*
|
||||
0;inoutput;txtid;anydata;Вывод;Сигнализация;order*
|
||||
0;analog-adc;adcid;fillgauge;Сенсоры;Аналоговый;order;pin[0];map[0,1024,0,100];c[1];int[10]*
|
||||
0;dallas-temp;tmpid;anydataTemp;Сенсоры;Температура;order;pin[2];index[0];int[10]*
|
||||
0;ultrasonic-cm;cmid;anydata;Сенсоры;Расстояние;order;pin[12,13];map[0,500,0,100];c[1];int[10]*
|
||||
0;dht;tmpid;anydataTemp;Сенсоры;Температура;1;c[1]
|
||||
0;dht;humid;anydataHum;Сенсоры;Влажность;2;c[1];pin[2];type[dht11];int[10]*
|
||||
0;dht;tmpid;anydataTemp;Сенсоры;Температура;1;c[1]
|
||||
0;dht;humid;anydataHum;Сенсоры;Влажность;2;c[1];pin[2];type[dht22];int[10]*
|
||||
0;bme280;tmpid;anydataTemp;Сенсоры;Температура;1;c[1]
|
||||
0;bme280;humid;anydataHum;Сенсоры;Влажность;2;c[1]
|
||||
0;bme280;prsid;anydataPress;Сенсоры;Давление;3;c[1];addr[0x76];int[10]*
|
||||
0;bmp280;tmpid;anydataTemp;Сенсоры;Температура;1;c[1]
|
||||
0;bmp280;prsid;anydataPress;Сенсоры;Давление;3;c[1];addr[0x76];int[10]*
|
||||
0;ccs811;ppmid;anydataPpm;Сенсоры;Содержание#CO2;1;c[1]
|
||||
0;ccs811;ppbid;anydataPpb;Сенсоры;Содержание#орг#соед;2;c[1];int[10]*
|
||||
0;impuls-out;impid;na;na;na;order;gpio*
|
||||
0;count-down;cntid;anydata;Таймер;Обратный#отчет;order*
|
||||
0;inoutput;txtid;anydata;Вывод;Вывод#uart;order*
|
||||
0;logging;crtid;chart;Графики;История;order;val[any];int[60];cnt[100]*
|
||||
0;uptime;uptid;anydataTime;Системные;%name%#uptime;order;int[60]*
|
||||
Binary file not shown.
Binary file not shown.
39
data/lang/lang.ru.json
Normal file
39
data/lang/lang.ru.json
Normal file
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"SetDevConf": "Конфигурация устройства",
|
||||
"SetDevPreset": "Выберите из списка подходящий пресет кофигурации",
|
||||
|
||||
"ButSave":"Сохранить",
|
||||
"ButMainPage":"Главная",
|
||||
|
||||
|
||||
"SetUDPList": "Список других устройств в сети:",
|
||||
"SetUDPWarn1": "После нажатия на кнопку <b>переформировать список устройств</b> ждите примерно минуту, а затем обновите страницу и список появится вновь",
|
||||
|
||||
"SetUDPUpdateList":"Переформировать список устройств",
|
||||
"SetUDPUpdatePage":"Обновить страницу",
|
||||
"SetUDPNameOfDev":"Имя этого устройства:",
|
||||
"SetUDPDateExchange":"Включить обмен данными между устройствами",
|
||||
"SetUDPWarn2":"Если обмен данными включен, то устройства будут обмениваться широковещательными пакетами udp для формирования списка устройств и для осуществления посылки настроек mqtt. Данный обмен создает дополнительную нагрузку на wifi сеть.",
|
||||
|
||||
"SetWiFiNameOfDev":"Имя устройства:",
|
||||
"SetWiFiRouterConnect":"Подключение к WiFi роутеру:",
|
||||
"SetWiFiAccessPoint":"Точка доступа:",
|
||||
"SetWiFiWeb":"Логин и пароль web interface:",
|
||||
"SetWiFiTimeZone":"Временная зона:",
|
||||
"SetWiFiNTP":"Сервер NTP:",
|
||||
"SetWiFiWarn1":"Имя устройства должно состоять из английских букв и иметь длинну от 6 до 12 символов",
|
||||
"SetWiFiWarn2":"После того как вы введете логин пароль от вашего wifi роутера необходимо нажать кнопку сохранить, а затем обязательно нажать кнопку <b>перезагрузить устройство</b> внизу этой страницы",
|
||||
"SetWiFiWarn3":"Устройство постоянно сканирует сеть на наличие wifi. Если роутер отключен, то устройство автоматически перейдет в режим точки доступа. Когда wifi появится устройство автоматически подключится к роутеру снова, и выключит точку доступа",
|
||||
"SetWiFiWarn4":"После изменения поля <b>NTP сервер</b> необходимо перезагрузить устройство",
|
||||
"SetWiFiWarn5":"Светодиод статуса подключения показывает четыре состояния подключения: <br><b>1. мигает редко</b> - идет подключение к wifi <br><b>2. мигает часто</b> - идет подключение к серверу mqtt <br><b>3. горит постоянно</b> - модуль в режиме точки доступа, <br><b>4. не горит</b> - модуль подключен к wifi и к mqtt. <br>Светодиод подключен к gpio2. Если галочка стоит - то использовать этот пин нельзя",
|
||||
|
||||
"SetMQTTServerName":"Имя сервера:",
|
||||
"SetMQTTPort":"Номер порта:",
|
||||
"SetMQTTPrefix":"Префикс:",
|
||||
"SetMQTTUserName":"Имя пользователя:",
|
||||
"SetMQTTPassword":"Пароль:",
|
||||
|
||||
"SetMQTTSendSettings":"Отправить настройки MQTT с этого устройства на все остальные",
|
||||
"SetMQTTWarn1":"Обратите внимание что поле префикс может состоять только из одного слова и одного разделителя: <b>/prefix</b>, вариант вида: <b>/prefix1/prefix2</b> работать не будет. После изменения поля prefix необходимо перезагрузить устройство",
|
||||
"SetMQTTWarn2":"Прежде чем нажимать на кнопку <b>Отправить настройки MQTT</b> сохрание их, если Вы их меняли. Настройки получат и перезапишут все устройства в локальной сети"
|
||||
}
|
||||
106
data/mqtt.json
106
data/mqtt.json
@@ -1,106 +0,0 @@
|
||||
{
|
||||
"configs": [
|
||||
"/config.setup.json"
|
||||
],
|
||||
"class": "col-sm-offset-1 col-sm-10 col-md-offset-2 col-md-8 col-lg-offset-3 col-lg-6",
|
||||
"content": [
|
||||
{
|
||||
"type": "h5",
|
||||
"title": "{{name}}",
|
||||
"class": "alert-warning"
|
||||
},
|
||||
{
|
||||
"type": "h4",
|
||||
"title": "Server name:"
|
||||
},
|
||||
{
|
||||
"type": "input",
|
||||
"title": "",
|
||||
"name": "1",
|
||||
"state": "{{mqttServer}}"
|
||||
},
|
||||
{
|
||||
"type": "h4",
|
||||
"title": "Port:"
|
||||
},
|
||||
{
|
||||
"type": "input",
|
||||
"title": "",
|
||||
"name": "2",
|
||||
"state": "{{mqttPort}}"
|
||||
},
|
||||
{
|
||||
"type": "h4",
|
||||
"title": "Prefix:"
|
||||
},
|
||||
{
|
||||
"type": "input",
|
||||
"title": "",
|
||||
"name": "3",
|
||||
"state": "{{mqttPrefix}}"
|
||||
},
|
||||
{
|
||||
"type": "h4",
|
||||
"title": "User name:"
|
||||
},
|
||||
{
|
||||
"type": "input",
|
||||
"title": "",
|
||||
"name": "4",
|
||||
"state": "{{mqttUser}}"
|
||||
},
|
||||
{
|
||||
"type": "h4",
|
||||
"title": "Password:"
|
||||
},
|
||||
{
|
||||
"type": "input",
|
||||
"title": "",
|
||||
"name": "5",
|
||||
"state": "{{mqttPass}}"
|
||||
},
|
||||
{
|
||||
"type": "h3",
|
||||
"name": "my-block",
|
||||
"style": "position:fixed;top:30%;left:50%;width:400px;margin-left:-200px;text-align:center;",
|
||||
"class": "hidden"
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"class": "alert alert-warning",
|
||||
"title": "Прежде чем нажимать на кнопку 'Отправить настройки MQTT' сохрание их, если Вы их меняли. Настройки получат и перезапишут все устройства в локальной сети"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"title": "Сохранить",
|
||||
"action": "mqttSave?mqttServer=[[1]]&mqttPort=[[2]]&mqttPrefix=[[3]]&mqttUser=[[4]]&mqttPass=[[5]]",
|
||||
"class": "btn btn-block btn-success"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"title": "Отправить настройки MQTT с этого устройства на все остальные",
|
||||
"action": "udp?arg=1",
|
||||
"class": "btn btn-block btn-success"
|
||||
},
|
||||
|
||||
{
|
||||
"type": "button",
|
||||
"title": "Проверить соединение с MQTT",
|
||||
"action": "mqttCheck",
|
||||
"response": "[[my-block]]",
|
||||
"class": "btn btn-block btn-success"
|
||||
},
|
||||
{
|
||||
"type": "link",
|
||||
"title": "Перезагрузить устройство",
|
||||
"action": "javascript:if(confirm(renameBlock(jsonResponse,'Перезагрузить?'))){send_request(this,'/restart?device=ok');}",
|
||||
"class": "btn btn-block btn-success"
|
||||
},
|
||||
{
|
||||
"type": "link",
|
||||
"title": "Главная",
|
||||
"action": "/",
|
||||
"class": "btn btn-block btn-danger btn-sm"
|
||||
}
|
||||
]
|
||||
}
|
||||
47
data/presets/presets.c.txt
Normal file
47
data/presets/presets.c.txt
Normal file
@@ -0,0 +1,47 @@
|
||||
0;dallas-temp;t1;anydataTemp;Термостат1;Температура;1;pin[2];index[0];int[10]
|
||||
0;logging;log1;chart;Термостат1;История;2;val[t1];int[60];cnt[100]
|
||||
0;inoutput;tUp1;inputDigit;Термостат1;Верхний#порог;3
|
||||
0;inoutput;tLow1;inputDigit;Термостат1;Нижний#порог;4
|
||||
0;button-out;btn1;toggle;Термостат1;Нагрев;5;pin[12]*
|
||||
0;dallas-temp;t2;anydataTemp;Термостат2;Температура;1;pin[2];index[0];int[10]
|
||||
0;logging;log2;chart;Термостат2;История;2;val[t2];int[10];cnt[100]
|
||||
0;inoutput;threshold;inputDigitTemp;Термостат2;Заданная#температура;3
|
||||
0;button-out;heater2;toggle;Термостат2;Нагреватель;7;pin[5]
|
||||
0;inoutput;time21;inputTimeClock;Расписание2;Утренний#период;8
|
||||
0;inoutput;threshold1;inputDigitTemp;Расписание2;Температура;9
|
||||
0;inoutput;time22;inputTimeClock;Расписание2;Дневной#период;10
|
||||
0;inoutput;threshold2;inputDigitTemp;Расписание2;Температура;11
|
||||
0;inoutput;time23;inputTimeClock;Расписание2;Вечерний#период;12
|
||||
0;inoutput;threshold3;inputDigitTemp;Расписание2;Температура;13
|
||||
0;inoutput;time24;inputTimeClock;Расписание2;Ночной#период;14
|
||||
0;inoutput;threshold4;inputDigitTemp;Расписание2;Температура;15*
|
||||
0;dht;t3;anydataTemp;Теплица3;Температура;1;c[1]
|
||||
0;dht;h3;anydataHum;Теплица3;Влажность;2;c[1];pin[2];type[dht11];int[10]
|
||||
0;logging;log3;chart;Теплица3;История;3;val[h3];int[60];cnt[100]
|
||||
0;inoutput;hUp3;inputDigit;Теплица3;Верхний#порог;4
|
||||
0;inoutput;hLow3;inputDigit;Теплица3;Нижний#порог;5
|
||||
0;button-out;hUp3;toggle;Теплица3;Полив;6;pin[12]*
|
||||
0;button-out;btn41;toggle;Реле4;Освещение;1;pin[12]
|
||||
0;button-out;btn42;toggle;Реле4;Освещение;2;pin[13]
|
||||
0;inoutput;time41;inputTime;Реле4;Введите#время#включения;3
|
||||
0;inoutput;time42;inputTime;Реле4;Введите#время#выключения;4*
|
||||
0;button-out;btn51;toggle;Свет5;Выключить#все;1
|
||||
0;button-out;btn52;toggle;Свет5;Гостинная;2;pin[12]
|
||||
0;button-out;btn53;toggle;Свет5;Спальня;3;pin[13]
|
||||
0;button-out;btn54;toggle;Свет5;Прихожая;4;pin[14]
|
||||
0;pwm-out;pwm51;range;Свет5;Яркость;5;pin[15]
|
||||
0;pwm-out;pwm52;range;Свет5;Яркость;6;pin[16]
|
||||
0;inoutput;txt5;anydata;Свет5;Статус;7*
|
||||
0;button-out;button;toggle;Таймер;Освещение;1;pin[12]
|
||||
0;count-down;count;anydata;Таймер;Обратный#отчет;2
|
||||
0;inoutput;input;inputDigit;Таймер;Введите#цифру;3*
|
||||
0;inoutput;text;anydataAlarm;Сигнализация;Движение:;1
|
||||
0;inoutput;time;anydataTime;Сигнализация;Время:;2
|
||||
0;button-in;sensor;na;na;na;3;pin[0];db[20]
|
||||
0;button-out;reset;toggle;Сигнализация;Сбросить;4*
|
||||
0;button-in;sensor;na;na;na;1;pin[0];db[20]
|
||||
0;button-out;light;toggle;Освещение;Освещение;2;pin[13]
|
||||
0;count-down;count;anydata;Освещение;Обратный#отчет;3
|
||||
0;inoutput;period;inputDigit;Освещение;Период#включения;4*
|
||||
0;button-out;light;toggle;Кнопки;Освещение;1;pin[13]
|
||||
0;button-in;switch;na;na;na;2;pin[0];db[20]*
|
||||
84
data/presets/presets.s.txt
Normal file
84
data/presets/presets.s.txt
Normal file
@@ -0,0 +1,84 @@
|
||||
t1 > tUp1
|
||||
btn1 0
|
||||
telegram Гостинная нагрев#выключен
|
||||
end
|
||||
t1 < tLow1
|
||||
btn1 1
|
||||
telegram Гостинная нагрев#включен
|
||||
end*
|
||||
t2 > threshold+-2
|
||||
heater2 0
|
||||
end
|
||||
t2 < threshold+-2
|
||||
heater2 1
|
||||
end
|
||||
timenow = time21
|
||||
threshold threshold1
|
||||
end
|
||||
timenow = time22
|
||||
threshold threshold2
|
||||
end
|
||||
timenow = time23
|
||||
threshold threshold3
|
||||
end
|
||||
timenow = time24
|
||||
threshold threshold4
|
||||
end*
|
||||
h3 > hUp3
|
||||
hUp3 0
|
||||
telegram Теплица полив#выключен
|
||||
end
|
||||
h3 < hLow3
|
||||
hUp3 1
|
||||
telegram Теплица полив#включен
|
||||
end*
|
||||
timenow = time41
|
||||
btn41 1
|
||||
btn42 0
|
||||
end
|
||||
timenow = time42
|
||||
btn41 0
|
||||
btn42 1
|
||||
end*
|
||||
btn51 = 1
|
||||
btn52 1
|
||||
btn53 1
|
||||
btn54 1
|
||||
pwm51 200
|
||||
pwm52 800
|
||||
txt5 включено
|
||||
end
|
||||
btn51 = 0
|
||||
btn52 0
|
||||
btn53 0
|
||||
btn54 0
|
||||
pwm51 800
|
||||
pwm52 200
|
||||
txt5 выключено
|
||||
end*
|
||||
button = 1
|
||||
count input
|
||||
end
|
||||
count = 0
|
||||
button 0
|
||||
end*
|
||||
sensor = 1
|
||||
text обнаружено
|
||||
time %date%
|
||||
telegram often Обнаружено#движение
|
||||
end
|
||||
reset = 1
|
||||
text не#обнаружено
|
||||
time %date%
|
||||
reset 0
|
||||
end*
|
||||
sensor = 1
|
||||
light 1
|
||||
count period
|
||||
end
|
||||
count = 0
|
||||
light 0
|
||||
end*
|
||||
switch = 1
|
||||
light change
|
||||
end*
|
||||
@@ -1,46 +0,0 @@
|
||||
{
|
||||
"configs": [
|
||||
"/config.setup.json"
|
||||
],
|
||||
"class":"col-sm-offset-1 col-sm-10 col-md-offset-2 col-md-8 col-lg-offset-3 col-lg-6",
|
||||
"content": [
|
||||
{
|
||||
"type": "h5",
|
||||
"title": "{{name}}",
|
||||
"class":"alert-warning"
|
||||
},
|
||||
{
|
||||
"type": "h4",
|
||||
"title": "Device id:"
|
||||
},
|
||||
{
|
||||
"type": "input",
|
||||
"title": "",
|
||||
"name":"1",
|
||||
"state": "{{pushingbox_id}}"
|
||||
},
|
||||
|
||||
{
|
||||
"type": "button",
|
||||
"title":"Сохранить",
|
||||
"action": "pushingboxDate?pushingbox_id=[[1]]",
|
||||
"class": "btn btn-block btn-success",
|
||||
"style": "width:100%;display:inline"
|
||||
},
|
||||
{
|
||||
"type": "hr"
|
||||
},
|
||||
{
|
||||
"type": "link",
|
||||
"title": "Перезагрузить устройство",
|
||||
"action": "javascript:if(confirm(renameBlock(jsonResponse,'Перезагрузить?'))){send_request(this,'/restart?device=ok');}",
|
||||
"class": "btn btn-block btn-warning"
|
||||
},
|
||||
{
|
||||
"type": "link",
|
||||
"title": "Главная",
|
||||
"action": "/",
|
||||
"class": "btn btn-block btn-danger btn-sm"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
User-agent: *
|
||||
Disallow: *
|
||||
1
data/s.conf.csv
Normal file
1
data/s.conf.csv
Normal file
@@ -0,0 +1 @@
|
||||
Удалить;Тип элемента;Id;Виджет;Имя вкладки;Имя виджета;Позиция виджета
|
||||
|
1
data/s.scen.txt
Normal file
1
data/s.scen.txt
Normal file
@@ -0,0 +1 @@
|
||||
//
|
||||
BIN
data/set.dev.json.gz
Normal file
BIN
data/set.dev.json.gz
Normal file
Binary file not shown.
BIN
data/set.device.json.gz
Normal file
BIN
data/set.device.json.gz
Normal file
Binary file not shown.
BIN
data/set.manual.json.gz
Normal file
BIN
data/set.manual.json.gz
Normal file
Binary file not shown.
BIN
data/set.mqtt.json.gz
Normal file
BIN
data/set.mqtt.json.gz
Normal file
Binary file not shown.
BIN
data/set.telegram.json.gz
Normal file
BIN
data/set.telegram.json.gz
Normal file
Binary file not shown.
BIN
data/set.udp.json.gz
Normal file
BIN
data/set.udp.json.gz
Normal file
Binary file not shown.
BIN
data/set.utilities.json.gz
Normal file
BIN
data/set.utilities.json.gz
Normal file
Binary file not shown.
BIN
data/set.wifi.json.gz
Normal file
BIN
data/set.wifi.json.gz
Normal file
Binary file not shown.
148
data/setup.json
148
data/setup.json
@@ -1,148 +0,0 @@
|
||||
{
|
||||
"configs": [
|
||||
"/config.setup.json"
|
||||
],
|
||||
"title": "Конфигурация",
|
||||
"class":"col-sm-offset-1 col-sm-10 col-md-offset-2 col-md-8 col-lg-offset-3 col-lg-6",
|
||||
"content": [
|
||||
{
|
||||
"type": "h5",
|
||||
"title": "{{name}}",
|
||||
"class":"alert-warning"
|
||||
},
|
||||
{
|
||||
"type": "link",
|
||||
"title": "Главная",
|
||||
"action": "/",
|
||||
"class": "btn btn-block btn-danger"
|
||||
},
|
||||
{
|
||||
"type": "hr"
|
||||
},
|
||||
{
|
||||
"type": "h2",
|
||||
"title": "Имя устройства"
|
||||
},
|
||||
{
|
||||
"type": "input",
|
||||
"title": "Имя устройства",
|
||||
"name":"dev_name",
|
||||
"state": "{{name}}",
|
||||
"pattern": "[0-9a-zA-Zа-яА-Я.\\- ]{1,20}"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"title": "Сохранить",
|
||||
"action": "name?arg=[[dev_name]]",
|
||||
"class": "btn btn-block btn-success"
|
||||
},
|
||||
{
|
||||
"type": "hr"
|
||||
},
|
||||
{
|
||||
"type": "h2",
|
||||
"title": "Подключение к Wi-Fi роутеру"
|
||||
},
|
||||
{
|
||||
"type": "input",
|
||||
"title":"Сеть",
|
||||
"name":"ssid",
|
||||
"state": "{{ssid}}"
|
||||
},
|
||||
{
|
||||
"type": "password",
|
||||
"title": "Введите пароль",
|
||||
"name":"ssidPass",
|
||||
"state": "{{password}}"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"title": "Сохранить",
|
||||
"class": "btn btn-block btn-success",
|
||||
"action": "ssid?ssid=[[ssid]]&password=[[ssidPass]]"
|
||||
},
|
||||
{
|
||||
"type": "hr"
|
||||
},
|
||||
{
|
||||
"type": "h2",
|
||||
"title": "Точка доступа"
|
||||
},
|
||||
{
|
||||
"type": "input",
|
||||
"title": "Имя WI-FI сети",
|
||||
"name":"ssidap",
|
||||
"state": "{{ssidAP}}",
|
||||
"pattern": ".{1,20}"
|
||||
},
|
||||
{
|
||||
"type": "password",
|
||||
"title": "Пароль",
|
||||
"name":"ssidApPass",
|
||||
"state": "{{passwordAP}}",
|
||||
"pattern": ".{8,20}"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"title": "Сохранить",
|
||||
"action": "ssidap?ssidAP=[[ssidap]]&passwordAP=[[ssidApPass]]",
|
||||
"class": "btn btn-block btn-success"
|
||||
},
|
||||
{
|
||||
"type": "hr"
|
||||
},
|
||||
{
|
||||
"type": "h2",
|
||||
"title": "Логин и пароль web interface"
|
||||
},
|
||||
{
|
||||
"type": "input",
|
||||
"title": "Логин",
|
||||
"name":"web-login",
|
||||
"state": "{{web_login}}",
|
||||
"pattern": ".{1,20}"
|
||||
},
|
||||
{
|
||||
"type": "password",
|
||||
"title": "Пароль",
|
||||
"name":"web-pass",
|
||||
"state": "{{web_pass}}",
|
||||
"pattern": ".{1,20}"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"title": "Сохранить",
|
||||
"action": "web?web_login=[[web-login]]&web_pass=[[web-pass]]",
|
||||
"class": "btn btn-block btn-success"
|
||||
},
|
||||
{
|
||||
"type": "hr"
|
||||
},
|
||||
{
|
||||
"type": "h2",
|
||||
"title": "Временная зона"
|
||||
},
|
||||
{
|
||||
"type": "input",
|
||||
"title": "Логин",
|
||||
"name":"time-zone",
|
||||
"state": "{{timezone}}",
|
||||
"pattern": ".{1,20}"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"title": "Сохранить",
|
||||
"action": "timeZone?timezone=[[time-zone]]",
|
||||
"class": "btn btn-block btn-success"
|
||||
},
|
||||
{
|
||||
"type": "hr"
|
||||
},
|
||||
{
|
||||
"type": "link",
|
||||
"title": "Перезагрузить устройство",
|
||||
"action": "javascript:if(confirm(renameBlock(jsonResponse,'Перезагрузить?'))){send_request(this,'/restart?device=ok');}",
|
||||
"class": "btn btn-block btn-warning"
|
||||
}
|
||||
]
|
||||
}
|
||||
BIN
data/sync.ffs_db
BIN
data/sync.ffs_db
Binary file not shown.
6
data/widgets/alarm.json
Normal file
6
data/widgets/alarm.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"widget": "anydata",
|
||||
"icon": "body",
|
||||
"color": "red",
|
||||
"descrColor": "red"
|
||||
}
|
||||
5
data/widgets/anydata.json
Normal file
5
data/widgets/anydata.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"widget": "anydata",
|
||||
"after": "",
|
||||
"icon": ""
|
||||
}
|
||||
6
data/widgets/anydataAlarm.json
Normal file
6
data/widgets/anydataAlarm.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"widget": "anydata",
|
||||
"after": "",
|
||||
"color":"red",
|
||||
"icon": "walk"
|
||||
}
|
||||
5
data/widgets/anydataHum.json
Normal file
5
data/widgets/anydataHum.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"widget": "anydata",
|
||||
"after": "%",
|
||||
"icon": "water"
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user