mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-31 04:19:15 +03:00
Compare commits
311 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 |
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"
|
||||
]
|
||||
}
|
||||
49
.vscode/settings.json
vendored
Normal file
49
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"*.tcc": "cpp",
|
||||
"string": "cpp",
|
||||
"functional": "cpp",
|
||||
"array": "cpp",
|
||||
"atomic": "cpp",
|
||||
"bitset": "cpp",
|
||||
"cctype": "cpp",
|
||||
"chrono": "cpp",
|
||||
"clocale": "cpp",
|
||||
"cmath": "cpp",
|
||||
"cstdarg": "cpp",
|
||||
"cstdint": "cpp",
|
||||
"cstdio": "cpp",
|
||||
"cstdlib": "cpp",
|
||||
"cstring": "cpp",
|
||||
"ctime": "cpp",
|
||||
"cwchar": "cpp",
|
||||
"cwctype": "cpp",
|
||||
"deque": "cpp",
|
||||
"list": "cpp",
|
||||
"unordered_map": "cpp",
|
||||
"vector": "cpp",
|
||||
"exception": "cpp",
|
||||
"fstream": "cpp",
|
||||
"initializer_list": "cpp",
|
||||
"iosfwd": "cpp",
|
||||
"iostream": "cpp",
|
||||
"istream": "cpp",
|
||||
"limits": "cpp",
|
||||
"mutex": "cpp",
|
||||
"new": "cpp",
|
||||
"ostream": "cpp",
|
||||
"numeric": "cpp",
|
||||
"ratio": "cpp",
|
||||
"sstream": "cpp",
|
||||
"stdexcept": "cpp",
|
||||
"streambuf": "cpp",
|
||||
"system_error": "cpp",
|
||||
"cinttypes": "cpp",
|
||||
"regex": "cpp",
|
||||
"tuple": "cpp",
|
||||
"type_traits": "cpp",
|
||||
"utility": "cpp",
|
||||
"typeinfo": "cpp"
|
||||
},
|
||||
"cmake.configureOnOpen": true
|
||||
}
|
||||
Binary file not shown.
599
Cmd.ino
599
Cmd.ino
@@ -1,599 +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_);
|
||||
|
||||
#ifdef analog_enable
|
||||
sCmd.addCommand("analog", analog);
|
||||
#endif
|
||||
#ifdef level_enable
|
||||
sCmd.addCommand("level", level);
|
||||
#endif
|
||||
#ifdef dallas_enable
|
||||
sCmd.addCommand("dallas", dallas);
|
||||
#endif
|
||||
#ifdef dht_enable
|
||||
sCmd.addCommand("dhtT", dhtT);
|
||||
sCmd.addCommand("dhtH", dhtH);
|
||||
sCmd.addCommand("dhtPerception", dhtP);
|
||||
sCmd.addCommand("dhtComfort", dhtC);
|
||||
sCmd.addCommand("dhtDewpoint", dhtD);
|
||||
#endif
|
||||
|
||||
#ifdef bmp_enable
|
||||
sCmd.addCommand("bmp280T", bmp280T);
|
||||
sCmd.addCommand("bmp280P", bmp280P);
|
||||
#endif
|
||||
|
||||
#ifdef bme_enable
|
||||
sCmd.addCommand("bme280T", bme280T);
|
||||
sCmd.addCommand("bme280P", bme280P);
|
||||
sCmd.addCommand("bme280H", bme280H);
|
||||
sCmd.addCommand("bme280A", bme280A);
|
||||
#endif
|
||||
|
||||
#ifdef stepper_enable
|
||||
sCmd.addCommand("stepper", stepper);
|
||||
sCmd.addCommand("stepperSet", stepperSet);
|
||||
#endif
|
||||
|
||||
#ifdef servo_enable
|
||||
sCmd.addCommand("servo", servo_);
|
||||
sCmd.addCommand("servoSet", servoSet);
|
||||
#endif
|
||||
|
||||
#ifdef serial_enable
|
||||
sCmd.addCommand("serialBegin", serialBegin);
|
||||
sCmd.addCommand("serialWrite", serialWrite);
|
||||
#endif
|
||||
|
||||
#ifdef logging_enable
|
||||
sCmd.addCommand("logging", logging);
|
||||
#endif
|
||||
|
||||
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);
|
||||
|
||||
#ifdef push_enable
|
||||
sCmd.addCommand("push", pushControl);
|
||||
#endif
|
||||
|
||||
sCmd.addCommand("update", update_firmware);
|
||||
sCmd.addCommand("firmware", firmware);
|
||||
|
||||
|
||||
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(configOptionJson, "button_param" + button_number, button_param);
|
||||
jsonWriteStr(configLiveJson, "button" + button_number, start_state);
|
||||
|
||||
if (isDigitStr (button_param)) {
|
||||
pinMode(button_param.toInt(), OUTPUT);
|
||||
digitalWrite(button_param.toInt(), start_state.toInt());
|
||||
}
|
||||
|
||||
if (button_param == "scen") {
|
||||
jsonWriteStr(configSetupJson, "scen", 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", "button" + button_number);
|
||||
}
|
||||
|
||||
void buttonSet() {
|
||||
|
||||
String button_number = sCmd.next();
|
||||
String button_state = sCmd.next();
|
||||
String button_param = jsonReadStr(configOptionJson, "button_param" + button_number);
|
||||
|
||||
if (button_param != "na" || button_param != "scen" || button_param.indexOf("line") != -1) {
|
||||
digitalWrite(button_param.toInt(), button_state.toInt());
|
||||
}
|
||||
|
||||
if (button_param == "scen") {
|
||||
jsonWriteStr(configSetupJson, "scen", 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 ("button", button_number);
|
||||
|
||||
jsonWriteStr(configLiveJson, "button" + button_number, button_state);
|
||||
sendSTATUS("button" + button_number, button_state);
|
||||
}
|
||||
|
||||
void buttonChange() {
|
||||
String button_number = sCmd.next();
|
||||
String current_state = jsonReadStr(configLiveJson, "button" + 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(configLiveJson, "button" + button_number, current_state);
|
||||
sendSTATUS("button" + 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(configOptionJson, "pwm_pin" + pwm_number, pwm_pin);
|
||||
pinMode(pwm_pin_int, INPUT);
|
||||
analogWrite(pwm_pin_int, start_state.toInt());
|
||||
//analogWriteFreq(32000);
|
||||
jsonWriteStr(configLiveJson, "pwm" + pwm_number, start_state);
|
||||
|
||||
createWidget (widget_name, page_name, page_number, "widgets/widget.range.json", "pwm" + pwm_number);
|
||||
}
|
||||
|
||||
void pwmSet() {
|
||||
|
||||
String pwm_number = sCmd.next();
|
||||
String pwm_state = sCmd.next();
|
||||
int pwm_state_int = pwm_state.toInt();
|
||||
|
||||
int pin = jsonReadInt(configOptionJson, "pwm_pin" + pwm_number);
|
||||
analogWrite(pin, pwm_state_int);
|
||||
|
||||
eventGen ("pwm", pwm_number);
|
||||
|
||||
jsonWriteStr(configLiveJson, "pwm" + pwm_number, pwm_state);
|
||||
sendSTATUS("pwm" + 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 ("switch", String(switch_number));
|
||||
|
||||
jsonWriteStr(configLiveJson, "switch" + String(switch_number), "1");
|
||||
}
|
||||
if (buttons[switch_number].rose()) {
|
||||
|
||||
eventGen ("switch", String(switch_number));
|
||||
|
||||
jsonWriteStr(configLiveJson, "switch" + 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(configLiveJson, "digit" + number, start_state);
|
||||
createWidget (widget_name, page_name, page_number, "widgets/widget.inputNum.json", "digit" + number);
|
||||
}
|
||||
void digitSet() {
|
||||
String number = sCmd.next();
|
||||
String value = sCmd.next();
|
||||
jsonWriteStr(configLiveJson, "digit" + number, value);
|
||||
sendSTATUS("digit" + 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(configLiveJson, "time" + number, start_state);
|
||||
createWidget (widget_name, page_name, page_number, "widgets/widget.inputTime.json", "time" + number);
|
||||
}
|
||||
void timeSet() {
|
||||
String number = sCmd.next();
|
||||
String value = sCmd.next();
|
||||
jsonWriteStr(configLiveJson, "time" + number, value);
|
||||
sendSTATUS("time" + number, value);
|
||||
}
|
||||
|
||||
void handle_time_init() {
|
||||
ts.add(TIME, 1000, [&](void*) {
|
||||
|
||||
String tmp = GetTime();
|
||||
jsonWriteStr(configLiveJson, "time", tmp);
|
||||
tmp.replace(":", "-");
|
||||
jsonWriteStr(configLiveJson, "timenow", tmp);
|
||||
eventGen ("timenow", "");
|
||||
|
||||
}, 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", "text" + 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(configLiveJson, "text" + number, text);
|
||||
sendSTATUS("text" + number, text);
|
||||
}
|
||||
//=====================================================================================================================================
|
||||
//=========================================Модуль шагового мотора======================================================================
|
||||
#ifdef stepper_enable
|
||||
//stepper 1 12 13
|
||||
void stepper() {
|
||||
String stepper_number = sCmd.next();
|
||||
String pin_step = sCmd.next();
|
||||
String pin_dir = sCmd.next();
|
||||
|
||||
jsonWriteStr(configOptionJson, "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(configOptionJson, "steps" + stepper_number, steps);
|
||||
String stepper_speed = sCmd.next();
|
||||
String pin_step = selectToMarker (jsonReadStr(configOptionJson, "stepper" + stepper_number), " ");
|
||||
String pin_dir = deleteBeforeDelimiter (jsonReadStr(configOptionJson, "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(jsonReadInt(configOptionJson, "steps1") * 2);
|
||||
static int count;
|
||||
count++;
|
||||
String pin_step = selectToMarker (jsonReadStr(configOptionJson, "stepper1"), " ");
|
||||
digitalWrite(pin_step.toInt(), !digitalRead(pin_step.toInt()));
|
||||
yield();
|
||||
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(jsonReadInt(configOptionJson, "steps2") * 2);
|
||||
static int count;
|
||||
count++;
|
||||
String pin_step = selectToMarker (jsonReadStr(configOptionJson, "stepper2"), " ");
|
||||
digitalWrite(pin_step.toInt(), !digitalRead(pin_step.toInt()));
|
||||
yield();
|
||||
if (count > steps_int) {
|
||||
digitalWrite(pin_step.toInt(), LOW);
|
||||
ts.remove(STEPPER2);
|
||||
count = 0;
|
||||
}
|
||||
}, nullptr, true);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
//====================================================================================================================================================
|
||||
//=================================================================Сервоприводы=======================================================================
|
||||
#ifdef servo_enable
|
||||
//servo 1 13 50 Мой#сервопривод Сервоприводы 0 100 0 180 2
|
||||
void servo_() {
|
||||
String servo_number = sCmd.next();
|
||||
String servo_pin = sCmd.next();
|
||||
String start_state = sCmd.next();
|
||||
int start_state_int = start_state.toInt();
|
||||
String widget_name = sCmd.next();
|
||||
String page_name = sCmd.next();
|
||||
|
||||
String min_value = sCmd.next();
|
||||
String max_value = sCmd.next();
|
||||
|
||||
String min_deg = sCmd.next();
|
||||
String max_deg = sCmd.next();
|
||||
|
||||
String page_number = sCmd.next();
|
||||
|
||||
jsonWriteStr(configOptionJson, "servo_pin" + servo_number, servo_pin);
|
||||
start_state_int = map(start_state_int, min_value.toInt(), max_value.toInt(), min_deg.toInt(), max_deg.toInt());
|
||||
|
||||
if (servo_number == "1") {
|
||||
#ifdef ESP8266
|
||||
myServo1.attach(servo_pin.toInt());
|
||||
myServo1.write(start_state_int);
|
||||
#endif
|
||||
#ifdef ESP32
|
||||
myServo1.attach(servo_pin.toInt(), 500, 2400);
|
||||
myServo1.write(start_state_int);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (servo_number == "2") {
|
||||
#ifdef ESP8266
|
||||
myServo2.attach(servo_pin.toInt());
|
||||
myServo2.write(start_state_int);
|
||||
#endif
|
||||
#ifdef ESP32
|
||||
myServo2.attach(servo_pin.toInt(), 500, 2400);
|
||||
myServo2.write(start_state_int);
|
||||
#endif
|
||||
}
|
||||
|
||||
jsonWriteStr(configOptionJson, "s_min_val" + servo_number, min_value);
|
||||
jsonWriteStr(configOptionJson, "s_max_val" + servo_number, max_value);
|
||||
jsonWriteStr(configOptionJson, "s_min_deg" + servo_number, min_deg);
|
||||
jsonWriteStr(configOptionJson, "s_max_deg" + servo_number, max_deg);
|
||||
|
||||
jsonWriteStr(configLiveJson, "servo" + servo_number, start_state);
|
||||
|
||||
createWidgetParam (widget_name, page_name, page_number, "widgets/widget.range.json", "servo" + servo_number, "min", min_value, "max", max_value, "k", "1");
|
||||
}
|
||||
|
||||
void servoSet() {
|
||||
String servo_number = sCmd.next();
|
||||
String servo_state = sCmd.next();
|
||||
int servo_state_int = servo_state.toInt();
|
||||
|
||||
int pin = jsonReadInt(configOptionJson, "servo_pin" + servo_number);
|
||||
|
||||
servo_state_int = map(servo_state_int,
|
||||
jsonReadInt(configOptionJson, "s_min_val" + servo_number),
|
||||
jsonReadInt(configOptionJson, "s_max_val" + servo_number),
|
||||
jsonReadInt(configOptionJson, "s_min_deg" + servo_number),
|
||||
jsonReadInt(configOptionJson, "s_max_deg" + servo_number));
|
||||
|
||||
if (servo_number == "1") {
|
||||
#ifdef ESP8266
|
||||
myServo1.write(servo_state_int);
|
||||
#endif
|
||||
#ifdef ESP32
|
||||
myServo1.write(servo_state_int);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (servo_number == "2") {
|
||||
#ifdef ESP8266
|
||||
myServo2.write(servo_state_int);
|
||||
#endif
|
||||
#ifdef ESP32
|
||||
myServo2.write(servo_state_int);
|
||||
#endif
|
||||
}
|
||||
|
||||
//Serial.println(servo_state_int);
|
||||
|
||||
eventGen ("servo", servo_number);
|
||||
|
||||
jsonWriteStr(configLiveJson, "servo" + servo_number, servo_state);
|
||||
sendSTATUS("servo" + servo_number, servo_state);
|
||||
}
|
||||
#endif
|
||||
//====================================================================================================================================================
|
||||
//===================================================================================serial===========================================================
|
||||
#ifdef serial_enable
|
||||
void serialBegin() {
|
||||
//String s_speed = sCmd.next();
|
||||
//String rxPin = sCmd.next();
|
||||
//String txPin = sCmd.next();
|
||||
//SoftwareSerial mySerial(rxPin.toInt(), txPin.toInt());
|
||||
//mySerial.begin(s_speed.toInt());
|
||||
}
|
||||
|
||||
void serialWrite() {
|
||||
//String text = sCmd.next();
|
||||
//mySerial.println(text);
|
||||
}
|
||||
#endif
|
||||
//====================================================================================================================================================
|
||||
//=================================================Глобальные команды удаленного управления===========================================================
|
||||
|
||||
void mqttOrderSend() {
|
||||
|
||||
String id = sCmd.next();
|
||||
String order = sCmd.next();
|
||||
|
||||
String all_line = jsonReadStr(configSetupJson, "mqttPrefix") + "/" + id + "/order";
|
||||
//Serial.print(all_line);
|
||||
//Serial.print("->");
|
||||
//Serial.println(order);
|
||||
int send_status = client_mqtt.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);
|
||||
}
|
||||
|
||||
void update_firmware() {
|
||||
upgrade = true;
|
||||
}
|
||||
|
||||
void firmware() {
|
||||
String widget_name = sCmd.next();
|
||||
String page_name = sCmd.next();
|
||||
String page_number = sCmd.next();
|
||||
jsonWriteStr(configLiveJson, "firm1", firmware_version);
|
||||
choose_widget_and_create(widget_name, page_name, page_number, "any-data", "firm1");
|
||||
}
|
||||
|
||||
//==============================================================================================================================
|
||||
//============================выполнение команд (в лупе) по очереди из строки 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.7z
BIN
ESP32FS.7z
Binary file not shown.
BIN
ESP8266FS.7z
BIN
ESP8266FS.7z
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();
|
||||
configSetupJson = readFile("config.json", 4096);
|
||||
configSetupJson.replace(" ", "");
|
||||
configSetupJson.replace("\r\n", "");
|
||||
Serial.println(configSetupJson);
|
||||
//jsonWriteStr(configLiveJson, "name", jsonReadStr(configSetupJson, "name"));
|
||||
//jsonWriteStr(configLiveJson, "lang", jsonReadStr(configSetupJson, "lang"));
|
||||
|
||||
|
||||
#ifdef ESP32
|
||||
uint32_t chipID_u = ESP.getEfuseMac();
|
||||
chipID = String(chipID_u);
|
||||
jsonWriteStr(configSetupJson, "chipID", chipID);
|
||||
#endif
|
||||
|
||||
#ifdef ESP8266
|
||||
chipID = String( ESP.getChipId() ) + "-" + String(ESP.getFlashChipId());
|
||||
jsonWriteStr(configSetupJson, "chipID", chipID);
|
||||
Serial.setDebugOutput(0);
|
||||
#endif
|
||||
|
||||
jsonWriteStr(configSetupJson, "firmware_version", firmware_version);
|
||||
|
||||
prex = jsonReadStr(configSetupJson, "mqttPrefix") + "/" + chipID;
|
||||
Serial.println(chipID);
|
||||
|
||||
}
|
||||
|
||||
void get_esp_info() {
|
||||
|
||||
|
||||
}
|
||||
99
Init.ino
99
Init.ino
@@ -1,99 +0,0 @@
|
||||
void All_init() {
|
||||
Device_init();
|
||||
Scenario_init();
|
||||
Timer_countdown_init();
|
||||
}
|
||||
|
||||
void Device_init() {
|
||||
|
||||
logging_value_names_list = "";
|
||||
enter_to_logging_counter = LOG1 - 1;
|
||||
|
||||
analog_value_names_list = "";
|
||||
enter_to_analog_counter = 0;
|
||||
|
||||
level_value_name = "";
|
||||
|
||||
dhtT_value_name = "";
|
||||
dhtH_value_name = "";
|
||||
|
||||
bmp280T_value_name = "";
|
||||
bmp280P_value_name = "";
|
||||
|
||||
bme280T_value_name = "";
|
||||
bme280P_value_name = "";
|
||||
bme280H_value_name = "";
|
||||
bme280A_value_name = "";
|
||||
|
||||
int array_sz = sizeof(sensors_reading_map) / sizeof(sensors_reading_map[0]);
|
||||
|
||||
for (int i = 0; i <= array_sz; i++) {
|
||||
sensors_reading_map[i] = 0;
|
||||
}
|
||||
|
||||
for (int i = LOG1; i <= LOG5; i++) {
|
||||
ts.remove(i);
|
||||
}
|
||||
|
||||
#ifdef layout_in_ram
|
||||
all_widgets = "";
|
||||
#else
|
||||
SPIFFS.remove("/layout.txt");
|
||||
#endif
|
||||
|
||||
txtExecution("firmware.c.txt");
|
||||
//outcoming_date();
|
||||
}
|
||||
//-------------------------------сценарии-----------------------------------------------------
|
||||
|
||||
void Scenario_init() {
|
||||
if (jsonReadStr(configSetupJson, "scen") == "1") {
|
||||
scenario = readFile("firmware.s.txt", 2048);
|
||||
}
|
||||
}
|
||||
|
||||
void uptime_init() {
|
||||
ts.add(UPTIME, 5000, [&](void*) {
|
||||
handle_uptime();
|
||||
}, nullptr, true);
|
||||
ts.add(STATISTICS, statistics_update, [&](void*) {
|
||||
handle_statistics();
|
||||
}, nullptr, true);
|
||||
}
|
||||
|
||||
void handle_uptime() {
|
||||
if (myUpTime.check()) {
|
||||
jsonWriteStr(configSetupJson, "uptime", uptime_as_string());
|
||||
}
|
||||
}
|
||||
|
||||
void handle_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();
|
||||
//Serial.println(ESP.getResetReason());
|
||||
#endif
|
||||
#ifdef ESP32
|
||||
urls += "Power on";
|
||||
#endif
|
||||
urls += "&";
|
||||
//-----------------------------------------------------------------
|
||||
urls += "ver: " + firmware_version;
|
||||
//-----------------------------------------------------------------
|
||||
String stat = getURL(urls);
|
||||
//Serial.println(stat);
|
||||
}
|
||||
}
|
||||
153
Logging.ino
153
Logging.ino
@@ -1,153 +0,0 @@
|
||||
#ifdef logging_enable
|
||||
//===============================================Логирование============================================================
|
||||
//logging temp1 1 10 Температура Датчики 2
|
||||
void logging() {
|
||||
String value_name = sCmd.next();
|
||||
String period_min = sCmd.next();
|
||||
String maxCount = sCmd.next();
|
||||
String widget_name = sCmd.next();
|
||||
widget_name.replace("#", " ");
|
||||
String page_name = sCmd.next();
|
||||
String page_number = sCmd.next();
|
||||
logging_value_names_list += value_name + ",";
|
||||
enter_to_logging_counter++; //считаем количество входов в эту функцию
|
||||
jsonWriteStr(configOptionJson, value_name + "_c", maxCount); //создаем в файловой системе переменную количества точек на графике с отметкой _c что значит count
|
||||
createChart (widget_name, page_name, page_number, "widgets/widget.chart.json", value_name + "_ch", maxCount); //создаем график в приложении с топиком _ch /prefix/3234045-1589487/value_name_ch
|
||||
if (enter_to_logging_counter == LOG1) {
|
||||
ts.add(LOG1, period_min.toInt() * 1000 * 60, [&](void*) {
|
||||
String tmp_buf_1 = selectFromMarkerToMarker(logging_value_names_list, ",", 0);
|
||||
deleteOldDate("log." + tmp_buf_1 + ".txt", jsonReadInt(configOptionJson, tmp_buf_1 + "_c"), jsonReadStr(configLiveJson, tmp_buf_1));
|
||||
Serial.println("[i] LOGGING for sensor '" + tmp_buf_1 + "' done");
|
||||
}, nullptr, false);
|
||||
}
|
||||
if (enter_to_logging_counter == LOG2) {
|
||||
ts.add(LOG2, period_min.toInt() * 1000 * 60, [&](void*) {
|
||||
String tmp_buf_2 = selectFromMarkerToMarker(logging_value_names_list, ",", 1);
|
||||
deleteOldDate("log." + tmp_buf_2 + ".txt", jsonReadInt(configOptionJson, tmp_buf_2 + "_c"), jsonReadStr(configLiveJson, tmp_buf_2));
|
||||
Serial.println("[i] LOGGING for sensor '" + tmp_buf_2 + "' done");
|
||||
}, nullptr, false);
|
||||
}
|
||||
if (enter_to_logging_counter == LOG3) {
|
||||
ts.add(LOG3, period_min.toInt() * 1000 * 60, [&](void*) {
|
||||
String tmp_buf_3 = selectFromMarkerToMarker(logging_value_names_list, ",", 2);
|
||||
deleteOldDate("log." + tmp_buf_3 + ".txt", jsonReadInt(configOptionJson, tmp_buf_3 + "_c"), jsonReadStr(configLiveJson, tmp_buf_3));
|
||||
Serial.println("[i] LOGGING for sensor '" + tmp_buf_3 + "' done");
|
||||
}, nullptr, false);
|
||||
}
|
||||
if (enter_to_logging_counter == LOG4) {
|
||||
ts.add(LOG4, period_min.toInt() * 1000 * 60, [&](void*) {
|
||||
String tmp_buf_4 = selectFromMarkerToMarker(logging_value_names_list, ",", 3);
|
||||
deleteOldDate("log." + tmp_buf_4 + ".txt", jsonReadInt(configOptionJson, tmp_buf_4 + "_c"), jsonReadStr(configLiveJson, tmp_buf_4));
|
||||
Serial.println("[i] LOGGING for sensor '" + tmp_buf_4 + "' done");
|
||||
}, nullptr, false);
|
||||
}
|
||||
if (enter_to_logging_counter == LOG5) {
|
||||
ts.add(LOG5, period_min.toInt() * 1000 * 60, [&](void*) {
|
||||
String tmp_buf_5 = selectFromMarkerToMarker(logging_value_names_list, ",", 4);
|
||||
deleteOldDate("log." + tmp_buf_5 + ".txt", jsonReadInt(configOptionJson, tmp_buf_5 + "_c"), jsonReadStr(configLiveJson, tmp_buf_5));
|
||||
Serial.println("[i] LOGGING for sensor '" + tmp_buf_5 + "' done");
|
||||
}, nullptr, false);
|
||||
}
|
||||
}
|
||||
|
||||
//=========================================Удаление стрых данных и запись новых==================================================================
|
||||
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() {
|
||||
String all_line = logging_value_names_list;
|
||||
while (all_line.length() != 0) {
|
||||
String tmp = selectToMarker (all_line, ",");
|
||||
sendLogData("log." + tmp + ".txt", tmp + "_ch");
|
||||
all_line = deleteBeforeDelimiter(all_line, ",");
|
||||
}
|
||||
all_line = "";
|
||||
}
|
||||
//=========================================Отправка данных===================================================================================
|
||||
void sendLogData(String file, String topic) {
|
||||
String log_date = readFile(file, 5000);
|
||||
if (log_date != "Failed") {
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
//----------------------------------------------
|
||||
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() {
|
||||
String all_line = logging_value_names_list;
|
||||
while (all_line.length() != 0) {
|
||||
String tmp = selectToMarker (all_line, ",");
|
||||
SPIFFS.remove("/log." + tmp + ".txt");
|
||||
all_line = deleteBeforeDelimiter(all_line, ",");
|
||||
}
|
||||
all_line = "";
|
||||
}
|
||||
#endif
|
||||
40
README.md
40
README.md
@@ -1,37 +1,5 @@
|
||||
# esp32-esp8266_iot-manager_modules_firmware
|
||||
|
||||
It is based on esp8266 and esp32 automation system. Each module has a web interface for its initial configuration. The modules are managed using the "iot manager" application. This application is released for both android and ios platform. The application connects to a MQTT broker, you can add several brokers and switch between them. All modules also connect to same broker. All esp8266 esp32 are combined and appear in the application as widgets.
|
||||
|
||||
There are two configuration options in the web interface of the modules:
|
||||
|
||||
1. Select a ready-made preset.
|
||||
|
||||
The following presets are available:
|
||||
|
||||
- On off relay
|
||||
- On off relay according to the schedule specified in the application
|
||||
- On off the relay after a period of time specified in the application
|
||||
- On off relay groups on different devices with one button in the application
|
||||
- Light switch module
|
||||
- PWM controlled by the slider in the application
|
||||
- Reading and logging analog input into graph with scaling function
|
||||
- Reading and logging in the graph of the following sensors:
|
||||
|
||||
DHT22, DHT33, DHT44, AM2302, RHT03
|
||||
DS18B20
|
||||
JSN-SR04T, HC-SR04, HY-SRF05
|
||||
BME280 BMP280 and other i2c sensors
|
||||
|
||||
-ds18b20 termostat controlled from application with graph (you can use any sensor for termostat any other supported).
|
||||
|
||||
2. Configure with special scripts. A simple programming language was invented which can very flexibly configure the module.
|
||||
|
||||
People who do not know how to program can use ready-made presets (option 1), and people who want to play with the system can use scripts (option 2).
|
||||
|
||||
Scenarios:
|
||||
|
||||
The web interface has the ability to configure Scenarios. An event occurs on one esp, and a reaction to this event can setup to occurs on another.
|
||||
|
||||
Logging of sensors data in this project made with out any server. All data for graf storring in esp flash. You can look any time your sensor history for 2 - 3 days or week in mobile app in graf. And for this option needed only esp.
|
||||
|
||||
# IoTManager
|
||||
Это модульная система беспроводной автоматизации на базе ESP32/ESP8266 микроконтроллеров и приложения IoT Manager.
|
||||
# [Инструкция](https://github.com/IoTManagerProject/IoTManager/wiki)
|
||||
|
||||

|
||||
|
||||
94
Scenario.ino
94
Scenario.ino
@@ -1,94 +0,0 @@
|
||||
void handleScenario() {
|
||||
|
||||
if (jsonReadStr(configSetupJson, "scen") == "1") {
|
||||
if ((jsonReadStr(configOptionJson, "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);
|
||||
String order = jsonReadStr(configOptionJson, "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 = jsonReadStr(configLiveJson, value);
|
||||
}
|
||||
if (value.indexOf("time") != -1) {
|
||||
// value = add_set(value);
|
||||
value = jsonReadStr(configLiveJson, value);
|
||||
}
|
||||
boolean flag = false; //если одно из значений совпало то только тогда начинаем выполнять комнады
|
||||
if (sign == "=") {
|
||||
if (jsonReadStr(configLiveJson, param_name) == value) flag = true;
|
||||
}
|
||||
if (sign == "!=") {
|
||||
if (jsonReadStr(configLiveJson, param_name) != value) flag = true;
|
||||
}
|
||||
if (sign == "<") {
|
||||
if (jsonReadStr(configLiveJson, param_name).toInt() < value.toInt()) flag = true;
|
||||
}
|
||||
if (sign == ">") {
|
||||
if (jsonReadStr(configLiveJson, param_name).toInt() > value.toInt()) flag = true;
|
||||
}
|
||||
if (sign == ">=") {
|
||||
if (jsonReadStr(configLiveJson, param_name).toInt() >= value.toInt()) flag = true;
|
||||
}
|
||||
if (sign == "<=") {
|
||||
if (jsonReadStr(configLiveJson, 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 = jsonReadStr(configOptionJson, "scenario_status"); //читаем файл событий
|
||||
tmp2 = deleteBeforeDelimiter(tmp2, ","); //удаляем выполненное событие
|
||||
jsonWriteStr(configOptionJson, "scenario_status", tmp2); //записываем обновленный файл событий
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void eventGen (String event_name, String number) { //событие выглядит как имя плюс set плюс номер: button+Set+1
|
||||
|
||||
if (jsonReadStr(configSetupJson, "scen") == "1") {
|
||||
String tmp = jsonReadStr(configOptionJson, "scenario_status") ; //генерирование события
|
||||
//Serial.println(event_name);
|
||||
jsonWriteStr(configOptionJson, "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;
|
||||
}
|
||||
556
Sensors.ino
556
Sensors.ino
@@ -1,556 +0,0 @@
|
||||
void sensors_init() {
|
||||
ts.add(SENSORS, 1000, [&](void*) {
|
||||
static int counter;
|
||||
counter++;
|
||||
|
||||
#ifdef level_enable
|
||||
if (sensors_reading_map[0] == 1) level_reading();
|
||||
#endif
|
||||
|
||||
if (counter > 10) {
|
||||
counter = 0;
|
||||
|
||||
#ifdef analog_enable
|
||||
if (sensors_reading_map[1] == 1) analog_reading1();
|
||||
if (sensors_reading_map[2] == 1) analog_reading2();
|
||||
#endif
|
||||
|
||||
#ifdef dallas_enable
|
||||
if (sensors_reading_map[3] == 1) dallas_reading();
|
||||
#endif
|
||||
|
||||
#ifdef dht_enable
|
||||
if (sensors_reading_map[4] == 1) dhtT_reading();
|
||||
if (sensors_reading_map[5] == 1) dhtH_reading();
|
||||
if (sensors_reading_map[6] == 1) dhtP_reading();
|
||||
if (sensors_reading_map[7] == 1) dhtC_reading();
|
||||
if (sensors_reading_map[8] == 1) dhtD_reading();
|
||||
#endif
|
||||
|
||||
#ifdef bmp_enable
|
||||
if (sensors_reading_map[9] == 1) bmp280T_rading();
|
||||
if (sensors_reading_map[10] == 1) bmp280P_reading();
|
||||
#endif
|
||||
|
||||
#ifdef bme_enable
|
||||
if (sensors_reading_map[11] == 1) bme280T_reading();
|
||||
if (sensors_reading_map[12] == 1) bme280P_reading();
|
||||
if (sensors_reading_map[13] == 1) bme280H_reading();
|
||||
if (sensors_reading_map[14] == 1) bme280A_reading();
|
||||
#endif
|
||||
}
|
||||
}, nullptr, true);
|
||||
}
|
||||
|
||||
//=========================================================================================================================================
|
||||
//=========================================Модуль измерения уровня в баке==================================================================
|
||||
#ifdef level_enable
|
||||
//level L 14 12 Вода#в#баке,#% Датчики fill-gauge 125 20 1
|
||||
void level() {
|
||||
String value_name = sCmd.next();
|
||||
String trig = sCmd.next();
|
||||
String echo = sCmd.next();
|
||||
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();
|
||||
level_value_name = value_name;
|
||||
jsonWriteStr(configOptionJson, "e_lev", empty_level);
|
||||
jsonWriteStr(configOptionJson, "f_lev", full_level);
|
||||
jsonWriteStr(configOptionJson, "trig", trig);
|
||||
jsonWriteStr(configOptionJson, "echo", echo);
|
||||
pinMode(trig.toInt(), OUTPUT);
|
||||
pinMode(echo.toInt(), INPUT);
|
||||
choose_widget_and_create(widget_name, page_name, page_number, type, value_name);
|
||||
sensors_reading_map[0] = 1;
|
||||
}
|
||||
|
||||
void level_reading() {
|
||||
long duration_;
|
||||
int distance_cm;
|
||||
int level;
|
||||
static int counter;
|
||||
int trig = jsonReadInt(configOptionJson, "trig");
|
||||
int echo = jsonReadInt(configOptionJson, "echo");
|
||||
digitalWrite(trig, LOW);
|
||||
delayMicroseconds(2);
|
||||
digitalWrite(trig, HIGH);
|
||||
delayMicroseconds(10);
|
||||
digitalWrite(trig, LOW);
|
||||
duration_ = pulseIn(echo, 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;
|
||||
level = map(distance_cm,
|
||||
jsonReadInt(configOptionJson, "e_lev"),
|
||||
jsonReadInt(configOptionJson, "f_lev"), 0, 100);
|
||||
jsonWriteInt(configLiveJson, level_value_name, level);
|
||||
eventGen (level_value_name, "");
|
||||
sendSTATUS(level_value_name, String(level));
|
||||
Serial.println("[i] sensor '" + level_value_name + "' data: " + String(level));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
//=========================================================================================================================================
|
||||
//=========================================Модуль аналогового сенсора======================================================================
|
||||
#ifdef analog_enable
|
||||
//analog adc 0 Аналоговый#вход,#% Датчики any-data 1 1023 1 100 1
|
||||
void analog() {
|
||||
String value_name = sCmd.next();
|
||||
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();
|
||||
analog_value_names_list += value_name + ",";
|
||||
enter_to_analog_counter++;
|
||||
jsonWriteStr(configOptionJson, value_name + "_st", analog_start);
|
||||
jsonWriteStr(configOptionJson, value_name + "_end", analog_end);
|
||||
jsonWriteStr(configOptionJson, value_name + "_st_out", analog_start_out);
|
||||
jsonWriteStr(configOptionJson, value_name + "_end_out", analog_end_out);
|
||||
choose_widget_and_create(widget_name, page_name, page_number, type, value_name);
|
||||
if (enter_to_analog_counter == 1) {
|
||||
sensors_reading_map[1] = 1;
|
||||
}
|
||||
if (enter_to_analog_counter == 2) {
|
||||
sensors_reading_map[2] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void analog_reading1() {
|
||||
String value_name = selectFromMarkerToMarker(analog_value_names_list, ",", 0);
|
||||
#ifdef ESP32
|
||||
int analog_in = analogRead(34);
|
||||
#endif
|
||||
#ifdef ESP8266
|
||||
int analog_in = analogRead(A0);
|
||||
#endif
|
||||
int analog = map(analog_in,
|
||||
jsonReadInt(configOptionJson, value_name + "_st") ,
|
||||
jsonReadInt(configOptionJson, value_name + "_end"),
|
||||
jsonReadInt(configOptionJson, value_name + "_st_out"),
|
||||
jsonReadInt(configOptionJson, value_name + "_end_out"));
|
||||
jsonWriteInt(configLiveJson, value_name, analog);
|
||||
eventGen (value_name, "");
|
||||
sendSTATUS(value_name, String(analog));
|
||||
Serial.println("[i] sensor '" + value_name + "' data: " + String(analog));
|
||||
}
|
||||
|
||||
void analog_reading2() {
|
||||
String value_name = selectFromMarkerToMarker(analog_value_names_list, ",", 1);
|
||||
#ifdef ESP32
|
||||
int analog_in = analogRead(35);
|
||||
#endif
|
||||
#ifdef ESP8266
|
||||
int analog_in = analogRead(A0);
|
||||
#endif
|
||||
int analog = map(analog_in,
|
||||
jsonReadInt(configOptionJson, value_name + "_st") ,
|
||||
jsonReadInt(configOptionJson, value_name + "_end"),
|
||||
jsonReadInt(configOptionJson, value_name + "_st_out"),
|
||||
jsonReadInt(configOptionJson, value_name + "_end_out"));
|
||||
jsonWriteInt(configLiveJson, value_name, analog);
|
||||
eventGen (value_name, "");
|
||||
sendSTATUS(value_name, String(analog));
|
||||
Serial.println("[i] sensor '" + value_name + "' data: " + String(analog));
|
||||
}
|
||||
#endif
|
||||
//=========================================================================================================================================
|
||||
//=========================================Модуль температурного сенсора ds18b20===========================================================
|
||||
#ifdef dallas_enable
|
||||
void dallas() {
|
||||
String value_name = sCmd.next();
|
||||
String pin = sCmd.next();
|
||||
String address = 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");
|
||||
sensors_reading_map[3] = 1;
|
||||
}
|
||||
|
||||
void dallas_reading() {
|
||||
float temp = 0;
|
||||
sensors.requestTemperatures();
|
||||
temp = sensors.getTempCByIndex(0);
|
||||
jsonWriteStr(configLiveJson, "dallas", String(temp));
|
||||
eventGen ("dallas", "");
|
||||
sendSTATUS("dallas", String(temp));
|
||||
Serial.println("[i] sensor 'dallas' send date " + String(temp));
|
||||
}
|
||||
#endif
|
||||
//=========================================================================================================================================
|
||||
//=========================================Модуль сенсоров DHT=============================================================================
|
||||
#ifdef dht_enable
|
||||
//dhtT t 2 dht11 Температура#DHT,#t°C Датчики any-data 1
|
||||
void dhtT() {
|
||||
String value_name = sCmd.next();
|
||||
String pin = sCmd.next();
|
||||
String sensor_type = sCmd.next();
|
||||
String widget_name = sCmd.next();
|
||||
String page_name = sCmd.next();
|
||||
String type = sCmd.next();
|
||||
String page_number = sCmd.next();
|
||||
dhtT_value_name = value_name;
|
||||
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, value_name);
|
||||
sensors_reading_map[4] = 1;
|
||||
}
|
||||
|
||||
void dhtT_reading() {
|
||||
float value = 0;
|
||||
static int counter;
|
||||
if (dht.getStatus() != 0 && counter < 5) {
|
||||
sendSTATUS(dhtT_value_name, String(dht.getStatusString()));
|
||||
counter++;
|
||||
} else {
|
||||
counter = 0;
|
||||
value = dht.getTemperature();
|
||||
if (String(value) != "nan") {
|
||||
eventGen (dhtT_value_name, "");
|
||||
jsonWriteStr(configLiveJson, dhtT_value_name, String(value));
|
||||
sendSTATUS(dhtT_value_name, String(value));
|
||||
Serial.println("[i] sensor '" + dhtT_value_name + "' data: " + String(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//dhtH h 2 dht11 Влажность#DHT,#t°C Датчики any-data 1
|
||||
void dhtH() {
|
||||
String value_name = sCmd.next();
|
||||
String pin = sCmd.next();
|
||||
String sensor_type = sCmd.next();
|
||||
String widget_name = sCmd.next();
|
||||
String page_name = sCmd.next();
|
||||
String type = sCmd.next();
|
||||
String page_number = sCmd.next();
|
||||
dhtH_value_name = value_name;
|
||||
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, value_name);
|
||||
sensors_reading_map[5] = 1;
|
||||
}
|
||||
|
||||
void dhtH_reading() {
|
||||
float value = 0;
|
||||
static int counter;
|
||||
if (dht.getStatus() != 0 && counter < 5) {
|
||||
sendSTATUS(dhtH_value_name, String(dht.getStatusString()));
|
||||
counter++;
|
||||
} else {
|
||||
counter = 0;
|
||||
value = dht.getHumidity();
|
||||
if (String(value) != "nan") {
|
||||
eventGen (dhtH_value_name, "");
|
||||
jsonWriteStr(configLiveJson, dhtH_value_name, String(value));
|
||||
sendSTATUS(dhtH_value_name, String(value));
|
||||
Serial.println("[i] sensor '" + dhtH_value_name + "' data: " + String(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//dhtPerception Восприятие: Датчики 4
|
||||
void dhtP() {
|
||||
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");
|
||||
sensors_reading_map[6] = 1;
|
||||
}
|
||||
|
||||
void dhtP_reading() {
|
||||
byte value;
|
||||
if (dht.getStatus() != 0) {
|
||||
sendSTATUS("dhtPerception", String(dht.getStatusString()));
|
||||
} else {
|
||||
value = dht.computePerception(jsonReadStr(configLiveJson, dhtT_value_name).toFloat(), jsonReadStr(configLiveJson, dhtH_value_name).toFloat(), false);
|
||||
String final_line = perception(value);
|
||||
jsonWriteStr(configLiveJson, "dhtPerception", final_line);
|
||||
eventGen ("dhtPerception", "");
|
||||
sendSTATUS("dhtPerception", final_line);
|
||||
if (client_mqtt.connected()) {
|
||||
Serial.println("[i] sensor 'dhtPerception' data: " + final_line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 "Сильно неудобно, полный звиздец";
|
||||
}
|
||||
|
||||
//dhtComfort Степень#комфорта: Датчики 3
|
||||
void dhtC() {
|
||||
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");
|
||||
sensors_reading_map[7] = 1;
|
||||
}
|
||||
|
||||
void dhtC_reading() {
|
||||
float value;
|
||||
ComfortState cf;
|
||||
if (dht.getStatus() != 0) {
|
||||
sendSTATUS("dhtComfort", String(dht.getStatusString()));
|
||||
} else {
|
||||
value = dht.getComfortRatio(cf, jsonReadStr(configLiveJson, dhtT_value_name).toFloat(), jsonReadStr(configLiveJson, dhtH_value_name).toFloat(), false);
|
||||
String final_line = get_comfort_status(cf);
|
||||
jsonWriteStr(configLiveJson, "dhtComfort", final_line);
|
||||
eventGen ("dhtComfort", "");
|
||||
sendSTATUS("dhtComfort", final_line);
|
||||
Serial.println("[i] sensor 'dhtComfort' send date " + final_line);
|
||||
}
|
||||
}
|
||||
|
||||
String get_comfort_status(ComfortState cf) {
|
||||
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;
|
||||
};
|
||||
return comfortStatus;
|
||||
}
|
||||
|
||||
|
||||
//dhtDewpoint Точка#росы: Датчики 5
|
||||
void dhtD() {
|
||||
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");
|
||||
sensors_reading_map[8] = 1;
|
||||
}
|
||||
|
||||
void dhtD_reading() {
|
||||
float value;
|
||||
if (dht.getStatus() != 0) {
|
||||
sendSTATUS("dhtDewpoint", String(dht.getStatusString()));
|
||||
} else {
|
||||
value = dht.computeDewPoint(jsonReadStr(configLiveJson, dhtT_value_name).toFloat(), jsonReadStr(configLiveJson, dhtH_value_name).toFloat(), false);
|
||||
jsonWriteInt(configLiveJson, "dhtDewpoint", value);
|
||||
eventGen ("dhtDewpoint", "");
|
||||
sendSTATUS("dhtDewpoint", String(value));
|
||||
Serial.println("[i] sensor 'dhtDewpoint' data: " + String(value));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
//=========================================i2c bus esp8266 scl-4 sda-5 ====================================================================
|
||||
//=========================================================================================================================================
|
||||
//=========================================Модуль сенсоров bmp280==========================================================================
|
||||
#ifdef bmp_enable
|
||||
//bmp280T temp1 0x76 Температура#bmp280 Датчики any-data 1
|
||||
void bmp280T() {
|
||||
String value_name = sCmd.next();
|
||||
String address = sCmd.next();
|
||||
String widget_name = sCmd.next();
|
||||
String page_name = sCmd.next();
|
||||
String type = sCmd.next();
|
||||
String page_number = sCmd.next();
|
||||
bmp280T_value_name = value_name;
|
||||
choose_widget_and_create(widget_name, page_name, page_number, type, value_name);
|
||||
bmp.begin(hexStringToUint8(address));
|
||||
bmp.setSampling(Adafruit_BMP280::MODE_NORMAL, /* Operating Mode. */
|
||||
Adafruit_BMP280::SAMPLING_X2, /* Temp. oversampling */
|
||||
Adafruit_BMP280::SAMPLING_X16, /* Pressure oversampling */
|
||||
Adafruit_BMP280::FILTER_X16, /* Filtering. */
|
||||
Adafruit_BMP280::STANDBY_MS_500); /* Standby time. */
|
||||
//bmp_temp->printSensorDetails();
|
||||
sensors_reading_map[9] = 1;
|
||||
}
|
||||
|
||||
void bmp280T_rading() {
|
||||
float value = 0;
|
||||
sensors_event_t temp_event, pressure_event;
|
||||
bmp_temp->getEvent(&temp_event);
|
||||
value = temp_event.temperature;
|
||||
jsonWriteStr(configLiveJson, bmp280T_value_name, String(value));
|
||||
eventGen(bmp280T_value_name, "");
|
||||
sendSTATUS(bmp280T_value_name, String(value));
|
||||
Serial.println("[i] sensor '" + bmp280T_value_name + "' data: " + String(value));
|
||||
}
|
||||
|
||||
//bmp280P press1 0x76 Давление#bmp280 Датчики any-data 2
|
||||
void bmp280P() {
|
||||
String value_name = sCmd.next();
|
||||
String address = sCmd.next();
|
||||
String widget_name = sCmd.next();
|
||||
String page_name = sCmd.next();
|
||||
String type = sCmd.next();
|
||||
String page_number = sCmd.next();
|
||||
bmp280P_value_name = value_name;
|
||||
choose_widget_and_create(widget_name, page_name, page_number, type, value_name);
|
||||
bmp.begin(hexStringToUint8(address));
|
||||
bmp.setSampling(Adafruit_BMP280::MODE_NORMAL, /* Operating Mode. */
|
||||
Adafruit_BMP280::SAMPLING_X2, /* Temp. oversampling */
|
||||
Adafruit_BMP280::SAMPLING_X16, /* Pressure oversampling */
|
||||
Adafruit_BMP280::FILTER_X16, /* Filtering. */
|
||||
Adafruit_BMP280::STANDBY_MS_500); /* Standby time. */
|
||||
//bmp_temp->printSensorDetails();
|
||||
sensors_reading_map[10] = 1;
|
||||
}
|
||||
|
||||
void bmp280P_reading() {
|
||||
float value = 0;
|
||||
sensors_event_t temp_event, pressure_event;
|
||||
bmp_pressure->getEvent(&pressure_event);
|
||||
value = pressure_event.pressure;
|
||||
value = value / 1.333224;
|
||||
jsonWriteStr(configLiveJson, bmp280P_value_name, String(value));
|
||||
eventGen(bmp280P_value_name, "");
|
||||
sendSTATUS(bmp280P_value_name, String(value));
|
||||
Serial.println("[i] sensor '" + bmp280P_value_name + "' data: " + String(value));
|
||||
}
|
||||
#endif
|
||||
//=========================================================================================================================================
|
||||
//=============================================Модуль сенсоров bme280======================================================================
|
||||
#ifdef bme_enable
|
||||
//bme280T temp1 0x76 Температура#bmp280 Датчики any-data 1
|
||||
void bme280T() {
|
||||
String value_name = sCmd.next();
|
||||
String address = sCmd.next();
|
||||
String widget_name = sCmd.next();
|
||||
String page_name = sCmd.next();
|
||||
String type = sCmd.next();
|
||||
String page_number = sCmd.next();
|
||||
bme280T_value_name = value_name;
|
||||
choose_widget_and_create(widget_name, page_name, page_number, type, value_name);
|
||||
bme.begin(hexStringToUint8(address));
|
||||
sensors_reading_map[11] = 1;
|
||||
}
|
||||
|
||||
void bme280T_reading() {
|
||||
float value = 0;
|
||||
value = bme.readTemperature();
|
||||
jsonWriteStr(configLiveJson, bme280T_value_name, String(value));
|
||||
eventGen(bme280T_value_name, "");
|
||||
sendSTATUS(bme280T_value_name, String(value));
|
||||
Serial.println("[i] sensor '" + bme280T_value_name + "' data: " + String(value));
|
||||
}
|
||||
|
||||
//bme280P pres1 0x76 Давление#bmp280 Датчики any-data 1
|
||||
void bme280P() {
|
||||
String value_name = sCmd.next();
|
||||
String address = sCmd.next();
|
||||
String widget_name = sCmd.next();
|
||||
String page_name = sCmd.next();
|
||||
String type = sCmd.next();
|
||||
String page_number = sCmd.next();
|
||||
bme280P_value_name = value_name;
|
||||
choose_widget_and_create(widget_name, page_name, page_number, type, value_name);
|
||||
bme.begin(hexStringToUint8(address));
|
||||
sensors_reading_map[12] = 1;
|
||||
}
|
||||
|
||||
void bme280P_reading() {
|
||||
float value = 0;
|
||||
value = bme.readPressure();
|
||||
value = value / 1.333224;
|
||||
jsonWriteStr(configLiveJson, bme280P_value_name, String(value));
|
||||
eventGen(bme280P_value_name, "");
|
||||
sendSTATUS(bme280P_value_name, String(value));
|
||||
Serial.println("[i] sensor '" + bme280P_value_name + "' data: " + String(value));
|
||||
}
|
||||
|
||||
//bme280H hum1 0x76 Влажность#bmp280 Датчики any-data 1
|
||||
void bme280H() {
|
||||
String value_name = sCmd.next();
|
||||
String address = sCmd.next();
|
||||
String widget_name = sCmd.next();
|
||||
String page_name = sCmd.next();
|
||||
String type = sCmd.next();
|
||||
String page_number = sCmd.next();
|
||||
bme280H_value_name = value_name;
|
||||
choose_widget_and_create(widget_name, page_name, page_number, type, value_name);
|
||||
bme.begin(hexStringToUint8(address));
|
||||
sensors_reading_map[13] = 1;
|
||||
}
|
||||
|
||||
void bme280H_reading() {
|
||||
float value = 0;
|
||||
value = bme.readHumidity();
|
||||
jsonWriteStr(configLiveJson, bme280H_value_name, String(value));
|
||||
eventGen(bme280H_value_name, "");
|
||||
sendSTATUS(bme280H_value_name, String(value));
|
||||
Serial.println("[i] sensor '" + bme280H_value_name + "' data: " + String(value));
|
||||
}
|
||||
|
||||
//bme280A altit1 0x76 Высота#bmp280 Датчики any-data 1
|
||||
void bme280A() {
|
||||
String value_name = sCmd.next();
|
||||
String address = sCmd.next();
|
||||
String widget_name = sCmd.next();
|
||||
String page_name = sCmd.next();
|
||||
String type = sCmd.next();
|
||||
String page_number = sCmd.next();
|
||||
bme280A_value_name = value_name;
|
||||
choose_widget_and_create(widget_name, page_name, page_number, type, value_name);
|
||||
bme.begin(hexStringToUint8(address));
|
||||
sensors_reading_map[14] = 1;
|
||||
}
|
||||
|
||||
void bme280A_reading() {
|
||||
float value = 0;
|
||||
value = bme.readAltitude(1013.25);
|
||||
jsonWriteStr(configLiveJson, bme280A_value_name, String(value));
|
||||
eventGen(bme280A_value_name, "");
|
||||
sendSTATUS(bme280A_value_name, String(value));
|
||||
Serial.println("[i] sensor '" + bme280A_value_name + "' data: " + String(value));
|
||||
}
|
||||
#endif
|
||||
@@ -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
|
||||
131
Time.ino
131
Time.ino
@@ -1,131 +0,0 @@
|
||||
void Time_Init() {
|
||||
ts.add(TIME_SYNC, 30000, [&](void*) {
|
||||
time_check();
|
||||
}, nullptr, true);
|
||||
}
|
||||
|
||||
void time_check() {
|
||||
if (GetTimeUnix() == "failed") {
|
||||
Serial.println("[i] Time is not synchronized, start synchronization");
|
||||
reconfigTime();
|
||||
}
|
||||
}
|
||||
|
||||
void reconfigTime() {
|
||||
if (WiFi.status() == WL_CONNECTED) {
|
||||
String ntp = jsonReadStr(configSetupJson, "ntp");
|
||||
configTime(0, 0, ntp.c_str());
|
||||
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 * jsonReadStr(configSetupJson, "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 * jsonReadStr(configSetupJson, "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 * jsonReadStr(configSetupJson, "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;
|
||||
}
|
||||
89
Timers.ino
89
Timers.ino
@@ -1,89 +0,0 @@
|
||||
//================================================================================================================
|
||||
//=========================================Таймеры=================================================================
|
||||
void Timer_countdown_init() {
|
||||
|
||||
ts.add(TIMER_COUNTDOWN, 1000, [&](void*) {
|
||||
|
||||
String old_line = jsonReadStr(configOptionJson, "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(configLiveJson, "timer" + String(number), "0");
|
||||
eventGen ("timer", 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 = jsonReadStr(configLiveJson, 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(configLiveJson, "timer" + number, "1");
|
||||
}
|
||||
void addTimer(String number, String time) {
|
||||
String tmp = jsonReadStr(configOptionJson, "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(configOptionJson, "timers", tmp);
|
||||
//Serial.println("ura");
|
||||
}
|
||||
|
||||
void timerStop() {
|
||||
String number = sCmd.next();
|
||||
delTimer(number);
|
||||
}
|
||||
|
||||
void delTimer (String number) {
|
||||
String tmp = jsonReadStr(configOptionJson, "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(configOptionJson, "timers", tmp);
|
||||
}
|
||||
}
|
||||
|
||||
int readTimer(int number) {
|
||||
String tmp = jsonReadStr(configOptionJson, "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();
|
||||
}
|
||||
234
Upgrade.ino
234
Upgrade.ino
@@ -1,234 +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(configSetupJson, "last_version", last_version);
|
||||
Serial.print("[i] Last firmware version: ");
|
||||
Serial.println(last_version);
|
||||
}
|
||||
|
||||
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");
|
||||
#endif
|
||||
#ifdef ESP8266
|
||||
last_version = getURL("http://91.204.228.124:1100/update/esp8266/version.txt");
|
||||
#endif
|
||||
jsonWriteStr(configSetupJson, "last_version", last_version);
|
||||
}
|
||||
}
|
||||
|
||||
void upgrade_firmware() {
|
||||
|
||||
String scenario_for_update;
|
||||
String config_for_update;
|
||||
String configSetup_for_update;
|
||||
scenario_for_update = readFile("firmware.s.txt", 4000);
|
||||
config_for_update = readFile("firmware.c.txt", 4000);
|
||||
configSetup_for_update = configSetupJson;
|
||||
|
||||
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();
|
||||
} else {
|
||||
Serial.println("!!!!BUILD upgrade ERROR");
|
||||
}
|
||||
} else {
|
||||
Serial.println("!!!!SPIFFS upgrade ERROR");
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
*/
|
||||
352
Web.ino
352
Web.ino
@@ -1,352 +0,0 @@
|
||||
void web_init() {
|
||||
server.on("/set", HTTP_GET, [](AsyncWebServerRequest * request) {
|
||||
String value;
|
||||
//============================device settings=====================================
|
||||
if (request->hasArg("preset")) {
|
||||
//--------------------------------------------------------------------------------
|
||||
String value;
|
||||
value = request->getParam("preset")->value();
|
||||
if (value == "1") {
|
||||
writeFile("firmware.c.txt", readFile("configs/1-relay.c.txt", 2048));
|
||||
writeFile("firmware.s.txt", readFile("configs/1-relay.s.txt", 2048));
|
||||
}
|
||||
if (value == "2") {
|
||||
writeFile("firmware.c.txt", readFile("configs/2-relay.c.txt", 2048));
|
||||
writeFile("firmware.s.txt", readFile("configs/2-relay.s.txt", 2048));
|
||||
}
|
||||
if (value == "3") {
|
||||
writeFile("firmware.c.txt", readFile("configs/3-relay.c.txt", 2048));
|
||||
writeFile("firmware.s.txt", readFile("configs/3-relay.s.txt", 2048));
|
||||
}
|
||||
if (value == "4") {
|
||||
writeFile("firmware.c.txt", readFile("configs/4-relay.c.txt", 2048));
|
||||
writeFile("firmware.s.txt", readFile("configs/4-relay.s.txt", 2048));
|
||||
}
|
||||
if (value == "5") {
|
||||
writeFile("firmware.c.txt", readFile("configs/5-relay.c.txt", 2048));
|
||||
writeFile("firmware.s.txt", readFile("configs/5-relay.s.txt", 2048));
|
||||
}
|
||||
if (value == "6") {
|
||||
writeFile("firmware.c.txt", readFile("configs/6-relay.c.txt", 2048));
|
||||
writeFile("firmware.s.txt", readFile("configs/6-relay.s.txt", 2048));
|
||||
}
|
||||
if (value == "7") {
|
||||
writeFile("firmware.c.txt", readFile("configs/7-relay.c.txt", 2048));
|
||||
writeFile("firmware.s.txt", readFile("configs/7-relay.s.txt", 2048));
|
||||
}
|
||||
if (value == "8") {
|
||||
writeFile("firmware.c.txt", readFile("configs/8-pwm.c.txt", 2048));
|
||||
writeFile("firmware.s.txt", readFile("configs/8-pwm.s.txt", 2048));
|
||||
}
|
||||
if (value == "9") {
|
||||
writeFile("firmware.c.txt", readFile("configs/9-dht11.c.txt", 2048));
|
||||
writeFile("firmware.s.txt", readFile("configs/9-dht11.s.txt", 2048));
|
||||
}
|
||||
if (value == "10") {
|
||||
writeFile("firmware.c.txt", readFile("configs/10-dht22.c.txt", 2048));
|
||||
writeFile("firmware.s.txt", readFile("configs/10-dht22.s.txt", 2048));
|
||||
}
|
||||
if (value == "11") {
|
||||
writeFile("firmware.c.txt", readFile("configs/11-analog.c.txt", 2048));
|
||||
writeFile("firmware.s.txt", readFile("configs/11-analog.s.txt", 2048));
|
||||
}
|
||||
if (value == "12") {
|
||||
writeFile("firmware.c.txt", readFile("configs/12-bmp280.c.txt", 2048));
|
||||
writeFile("firmware.s.txt", readFile("configs/12-bmp280.s.txt", 2048));
|
||||
}
|
||||
if (value == "13") {
|
||||
writeFile("firmware.c.txt", readFile("configs/13-bme280.c.txt", 2048));
|
||||
writeFile("firmware.s.txt", readFile("configs/13-bme280.s.txt", 2048));
|
||||
}
|
||||
if (value == "14") {
|
||||
writeFile("firmware.c.txt", readFile("configs/14-dallas.c.txt", 2048));
|
||||
writeFile("firmware.s.txt", readFile("configs/14-dallas.s.txt", 2048));
|
||||
}
|
||||
if (value == "15") {
|
||||
writeFile("firmware.c.txt", readFile("configs/15-termostat.c.txt", 2048));
|
||||
writeFile("firmware.s.txt", readFile("configs/15-termostat.s.txt", 2048));
|
||||
}
|
||||
if (value == "16") {
|
||||
writeFile("firmware.c.txt", readFile("configs/16-level.c.txt", 2048));
|
||||
writeFile("firmware.s.txt", readFile("configs/16-level.s.txt", 2048));
|
||||
}
|
||||
if (value == "17") {
|
||||
writeFile("firmware.c.txt", readFile("configs/17-moution.c.txt", 2048));
|
||||
writeFile("firmware.s.txt", readFile("configs/17-moution.s.txt", 2048));
|
||||
}
|
||||
if (value == "18") {
|
||||
writeFile("firmware.c.txt", readFile("configs/18-moution.c.txt", 2048));
|
||||
writeFile("firmware.s.txt", readFile("configs/18-moution.s.txt", 2048));
|
||||
}
|
||||
if (value == "19") {
|
||||
writeFile("firmware.c.txt", readFile("configs/19-stepper.c.txt", 2048));
|
||||
writeFile("firmware.s.txt", readFile("configs/19-stepper.s.txt", 2048));
|
||||
}
|
||||
if (value == "20") {
|
||||
writeFile("firmware.c.txt", readFile("configs/20-servo.c.txt", 2048));
|
||||
writeFile("firmware.s.txt", readFile("configs/20-servo.s.txt", 2048));
|
||||
}
|
||||
if (value == "21") {
|
||||
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("/?set.device");
|
||||
}
|
||||
//--------------------------------------------------------------------------------
|
||||
if (request->hasArg("devinit")) {
|
||||
Device_init();
|
||||
request->send(200, "text/text", "OK");
|
||||
}
|
||||
//--------------------------------------------------------------------------------
|
||||
if (request->hasArg("scen")) {
|
||||
value = request->getParam("scen")->value();
|
||||
if (value == "0") {
|
||||
jsonWriteStr(configSetupJson, "scen", value);
|
||||
saveConfig();
|
||||
Scenario_init();
|
||||
}
|
||||
if (value == "1") {
|
||||
jsonWriteStr(configSetupJson, "scen", value);
|
||||
saveConfig();
|
||||
Scenario_init();
|
||||
}
|
||||
request->send(200, "text/text", "OK");
|
||||
}
|
||||
//--------------------------------------------------------------------------------
|
||||
if (request->hasArg("sceninit")) {
|
||||
Scenario_init();
|
||||
request->send(200, "text/text", "OK");
|
||||
}
|
||||
//--------------------------------------------------------------------------------
|
||||
#ifdef logging_enable
|
||||
if (request->hasArg("cleanlog")) {
|
||||
clean_log_date();
|
||||
request->send(200, "text/text", "OK");
|
||||
}
|
||||
#endif
|
||||
//==============================udp settings=============================================
|
||||
if (request->hasArg("udponoff")) {
|
||||
value = request->getParam("udponoff")->value();
|
||||
if (value == "0") {
|
||||
jsonWriteStr(configSetupJson, "udponoff", value);
|
||||
saveConfig();
|
||||
Scenario_init();
|
||||
}
|
||||
if (value == "1") {
|
||||
jsonWriteStr(configSetupJson, "udponoff", value);
|
||||
saveConfig();
|
||||
Scenario_init();
|
||||
}
|
||||
request->send(200, "text/text", "OK");
|
||||
}
|
||||
//--------------------------------------------------------------------------------
|
||||
if (request->hasArg("updatelist")) {
|
||||
SPIFFS.remove("/dev.csv");
|
||||
addFile("dev.csv", "device id;device name;ip address");
|
||||
request->redirect("/?set.udp");
|
||||
}
|
||||
//--------------------------------------------------------------------------------
|
||||
if (request->hasArg("updatepage")) {
|
||||
request->redirect("/?set.udp");
|
||||
}
|
||||
//--------------------------------------------------------------------------------
|
||||
if (request->hasArg("devname")) {
|
||||
jsonWriteStr(configSetupJson, "name", request->getParam("devname")->value());
|
||||
saveConfig();
|
||||
request->send(200, "text/text", "OK");
|
||||
}
|
||||
//==============================wifi settings=============================================
|
||||
if (request->hasArg("routerssid")) {
|
||||
jsonWriteStr(configSetupJson, "routerssid", request->getParam("routerssid")->value());
|
||||
saveConfig();
|
||||
request->send(200, "text/text", "OK");
|
||||
}
|
||||
if (request->hasArg("routerpass")) {
|
||||
jsonWriteStr(configSetupJson, "routerpass", request->getParam("routerpass")->value());
|
||||
saveConfig();
|
||||
request->send(200, "text/text", "OK");
|
||||
}
|
||||
//--------------------------------------------------------------------------------
|
||||
if (request->hasArg("apssid")) {
|
||||
jsonWriteStr(configSetupJson, "apssid", request->getParam("apssid")->value());
|
||||
saveConfig();
|
||||
request->send(200, "text/text", "OK");
|
||||
}
|
||||
if (request->hasArg("appass")) {
|
||||
jsonWriteStr(configSetupJson, "appass", request->getParam("appass")->value());
|
||||
saveConfig();
|
||||
request->send(200, "text/text", "OK");
|
||||
}
|
||||
//--------------------------------------------------------------------------------
|
||||
if (request->hasArg("weblogin")) {
|
||||
jsonWriteStr(configSetupJson, "weblogin", request->getParam("weblogin")->value());
|
||||
saveConfig();
|
||||
request->send(200, "text/text", "OK");
|
||||
}
|
||||
if (request->hasArg("webpass")) {
|
||||
jsonWriteStr(configSetupJson, "webpass", request->getParam("webpass")->value());
|
||||
saveConfig();
|
||||
request->send(200, "text/text", "OK");
|
||||
}
|
||||
//--------------------------------------------------------------------------------
|
||||
if (request->hasArg("timezone")) {
|
||||
jsonWriteStr(configSetupJson, "timezone", request->getParam("timezone")->value());
|
||||
saveConfig();
|
||||
reconfigTime();
|
||||
request->send(200, "text/text", "OK");
|
||||
}
|
||||
if (request->hasArg("ntp")) {
|
||||
jsonWriteStr(configSetupJson, "ntp", request->getParam("ntp")->value());
|
||||
saveConfig();
|
||||
reconfigTime();
|
||||
request->send(200, "text/text", "OK");
|
||||
}
|
||||
//--------------------------------------------------------------------------------
|
||||
if (request->hasArg("device")) {
|
||||
if (request->getParam("device")->value() == "ok") ESP.restart();
|
||||
request->send(200, "text/text", "OK");
|
||||
}
|
||||
//--------------------------------------------------------------------------------
|
||||
if (request->hasArg("blink")) {
|
||||
value = request->getParam("blink")->value();
|
||||
if (value == "0") {
|
||||
jsonWriteStr(configSetupJson, "blink", value);
|
||||
saveConfig();
|
||||
}
|
||||
if (value == "1") {
|
||||
jsonWriteStr(configSetupJson, "blink", value);
|
||||
saveConfig();
|
||||
}
|
||||
request->send(200, "text/text", "OK");
|
||||
}
|
||||
//==============================mqtt settings=============================================
|
||||
if (request->hasArg("mqttServer")) {
|
||||
jsonWriteStr(configSetupJson, "mqttServer", request->getParam("mqttServer")->value());
|
||||
saveConfig();
|
||||
mqtt_connection = true;
|
||||
request->send(200, "text/text", "ok");
|
||||
}
|
||||
if (request->hasArg("mqttPort")) {
|
||||
int port = (request->getParam("mqttPort")->value()).toInt();
|
||||
jsonWriteInt(configSetupJson, "mqttPort", port);
|
||||
saveConfig();
|
||||
mqtt_connection = true;
|
||||
request->send(200, "text/text", "ok");
|
||||
}
|
||||
if (request->hasArg("mqttPrefix")) {
|
||||
jsonWriteStr(configSetupJson, "mqttPrefix", request->getParam("mqttPrefix")->value());
|
||||
saveConfig();
|
||||
mqtt_connection = true;
|
||||
request->send(200, "text/text", "ok");
|
||||
}
|
||||
if (request->hasArg("mqttUser")) {
|
||||
jsonWriteStr(configSetupJson, "mqttUser", request->getParam("mqttUser")->value());
|
||||
saveConfig();
|
||||
mqtt_connection = true;
|
||||
request->send(200, "text/text", "ok");
|
||||
}
|
||||
if (request->hasArg("mqttPass")) {
|
||||
jsonWriteStr(configSetupJson, "mqttPass", request->getParam("mqttPass")->value());
|
||||
saveConfig();
|
||||
mqtt_connection = true;
|
||||
request->send(200, "text/text", "ok");
|
||||
}
|
||||
//--------------------------------------------------------------------------------
|
||||
if (request->hasArg("mqttsend")) {
|
||||
mqtt_send_settings_to_udp = true;
|
||||
request->send(200, "text/text", "ok");
|
||||
}
|
||||
//--------------------------------------------------------------------------------
|
||||
if (request->hasArg("mqttcheck")) {
|
||||
String tmp = "{}";
|
||||
jsonWriteStr(tmp, "title", "<button class=\"close\" onclick=\"toggle('my-block')\">×</button>" + stateMQTT());
|
||||
jsonWriteStr(tmp, "class", "pop-up");
|
||||
request->send(200, "text/text", tmp);
|
||||
}
|
||||
//==============================push settings=============================================
|
||||
#ifdef push_enable
|
||||
if (request->hasArg("pushingboxid")) {
|
||||
jsonWriteStr(configSetupJson, "pushingboxid", request->getParam("pushingboxid")->value());
|
||||
saveConfig();
|
||||
request->send(200, "text/text", "ok");
|
||||
}
|
||||
#endif
|
||||
//==============================utilities settings=============================================
|
||||
if (request->hasArg("itoc")) {
|
||||
i2c_scanning = true;
|
||||
request->redirect("/?set.utilities");
|
||||
}
|
||||
});
|
||||
//==============================upgrade settings=============================================
|
||||
server.on("/check", HTTP_GET, [](AsyncWebServerRequest * request) {
|
||||
upgrade_url = true;
|
||||
Serial.print("[i] Last firmware version: ");
|
||||
Serial.println(last_version);
|
||||
String tmp = "{}";
|
||||
int case_of_update;
|
||||
|
||||
if (WiFi.status() != WL_CONNECTED) last_version = "nowifi";
|
||||
if (!mb_4_of_memory) last_version = "less";
|
||||
|
||||
if (last_version == firmware_version) case_of_update = 1;
|
||||
if (last_version != firmware_version) case_of_update = 2;
|
||||
if (last_version == "error") case_of_update = 3;
|
||||
if (last_version == "") case_of_update = 4;
|
||||
if (last_version == "less") case_of_update = 5;
|
||||
if (last_version == "nowifi") case_of_update = 6;
|
||||
if (last_version == "notsupported") case_of_update = 7;
|
||||
|
||||
switch (case_of_update) {
|
||||
case 1: {
|
||||
jsonWriteStr(tmp, "title", "<button class=\"close\" onclick=\"toggle('my-block')\">×</button>Последняя версия прошивки уже установлена.");
|
||||
jsonWriteStr(tmp, "class", "pop-up");
|
||||
}
|
||||
break;
|
||||
|
||||
case 2: {
|
||||
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='/'; }, 120000);html('my-block','<span class=loader></span>Идет обновление прошивки, после обновления страница перезагрузится автоматически...')\">Установить</a>");
|
||||
jsonWriteStr(tmp, "class", "pop-up");
|
||||
}
|
||||
break;
|
||||
|
||||
case 3: {
|
||||
jsonWriteStr(tmp, "title", "<button class=\"close\" onclick=\"toggle('my-block')\">×</button>Ошибка... Cервер не найден. Попробуйте позже...");
|
||||
jsonWriteStr(tmp, "class", "pop-up");
|
||||
}
|
||||
break;
|
||||
|
||||
case 4: {
|
||||
jsonWriteStr(tmp, "title", "<button class=\"close\" onclick=\"toggle('my-block')\">×</button>Нажмите на кнопку \"обновить прошивку\" повторно...");
|
||||
jsonWriteStr(tmp, "class", "pop-up");
|
||||
break;
|
||||
}
|
||||
|
||||
case 5: {
|
||||
jsonWriteStr(tmp, "title", "<button class=\"close\" onclick=\"toggle('my-block')\">×</button>Обновление по воздуху не поддерживается, модуль имеет меньше 4 мб памяти...");
|
||||
jsonWriteStr(tmp, "class", "pop-up");
|
||||
break;
|
||||
}
|
||||
|
||||
case 6: {
|
||||
jsonWriteStr(tmp, "title", "<button class=\"close\" onclick=\"toggle('my-block')\">×</button>Устройство не подключено к роутеру...");
|
||||
jsonWriteStr(tmp, "class", "pop-up");
|
||||
break;
|
||||
}
|
||||
|
||||
case 7: {
|
||||
jsonWriteStr(tmp, "title", "<button class=\"close\" onclick=\"toggle('my-block')\">×</button>Обновление на новую версию возможно только через usb...");
|
||||
jsonWriteStr(tmp, "class", "pop-up");
|
||||
break;
|
||||
}
|
||||
}
|
||||
request->send(200, "text/text", tmp);
|
||||
});
|
||||
|
||||
server.on("/upgrade", HTTP_GET, [](AsyncWebServerRequest * request) {
|
||||
upgrade = true;
|
||||
String tmp = "{}";
|
||||
request->send(200, "text/text", "ok");
|
||||
});
|
||||
}
|
||||
232
Web_server.ino
232
Web_server.ino
@@ -1,232 +0,0 @@
|
||||
void Web_server_init() {
|
||||
/*********************************************************************************
|
||||
***************************************OTA****************************************
|
||||
*********************************************************************************/
|
||||
#ifdef OTA_enable
|
||||
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
|
||||
/*********************************************************************************
|
||||
**************************************WEB****************************************
|
||||
*********************************************************************************/
|
||||
#ifdef ESP32
|
||||
server.addHandler(new SPIFFSEditor(SPIFFS, jsonReadStr(configSetupJson, "web_login").c_str(), jsonReadStr(configSetupJson, "web_pass").c_str()));
|
||||
#elif defined(ESP8266)
|
||||
server.addHandler(new SPIFFSEditor(jsonReadStr(configSetupJson, "web_login").c_str(), jsonReadStr(configSetupJson, "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("/favicon.ico", SPIFFS, "/favicon.ico").setCacheControl("max-age=31536000");
|
||||
server.serveStatic("/icon.jpeg", SPIFFS, "/icon.jpeg").setCacheControl("max-age=31536000");
|
||||
|
||||
server.serveStatic("/", SPIFFS, "/").setDefaultFile("index.htm")
|
||||
.setAuthentication(jsonReadStr(configSetupJson, "web_login").c_str(), jsonReadStr(configSetupJson, "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", configLiveJson);
|
||||
});
|
||||
// --------------------Выдаем данные optionJson //config.option.json - данные не являющиеся событиями
|
||||
server.on("/config.option.json", HTTP_GET, [](AsyncWebServerRequest * request) {
|
||||
request->send(200, "application/json", configOptionJson);
|
||||
});
|
||||
// -------------------Выдаем данные configSetup //config.setup.json - для хранения постоянных данных
|
||||
server.on("/config.setup.json", HTTP_GET, [](AsyncWebServerRequest * request) {
|
||||
request->send(200, "application/json", configSetupJson);
|
||||
});
|
||||
|
||||
// ------------------Выполнение команды из запроса
|
||||
//http://192.168.88.45/cmd?command=rel%201%201
|
||||
server.on("/cmd", HTTP_GET, [](AsyncWebServerRequest * request) {
|
||||
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
|
||||
162
WiFi.ino
162
WiFi.ino
@@ -1,162 +0,0 @@
|
||||
void ROUTER_Connecting() {
|
||||
|
||||
led_blink("slow");
|
||||
|
||||
WiFi.mode(WIFI_STA);
|
||||
|
||||
byte tries = 20;
|
||||
String _ssid = jsonReadStr(configSetupJson, "routerssid");
|
||||
String _password = jsonReadStr(configSetupJson, "routerpass");
|
||||
//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(configOptionJson, "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(configSetupJson, "ip", WiFi.localIP().toString());
|
||||
led_blink("off");
|
||||
//add_dev_in_list("dev.txt", chipID, WiFi.localIP().toString());
|
||||
MQTT_init();
|
||||
}
|
||||
}
|
||||
|
||||
bool StartAPMode() {
|
||||
Serial.println("WiFi up AP");
|
||||
WiFi.disconnect();
|
||||
|
||||
WiFi.mode(WIFI_AP);
|
||||
|
||||
String _ssidAP = jsonReadStr(configSetupJson, "apssid");
|
||||
String _passwordAP = jsonReadStr(configSetupJson, "appass");
|
||||
WiFi.softAP(_ssidAP.c_str(), _passwordAP.c_str());
|
||||
IPAddress myIP = WiFi.softAPIP();
|
||||
led_blink("on");
|
||||
Serial.print("AP IP address: ");
|
||||
Serial.println(myIP);
|
||||
jsonWriteStr(configSetupJson, "ip", myIP.toString());
|
||||
|
||||
//if (jsonReadInt(configOptionJson, "pass_status") != 1) {
|
||||
ts.add(ROUTER_SEARCHING, 10 * 1000, [&](void*) {
|
||||
Serial.println("->try find router");
|
||||
if (RouterFind(jsonReadStr(configSetupJson, "routerssid"))) {
|
||||
ts.remove(ROUTER_SEARCHING);
|
||||
WiFi.scanDelete();
|
||||
ROUTER_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["routerssid"] = ssidMy;
|
||||
data["pass"] = (WiFi.encryptionType(i) == ENC_TYPE_NONE) ? "" : "*";
|
||||
int8_t dbm = WiFi.RSSI(i);
|
||||
data["dbm"] = dbm;
|
||||
if (ssidMy == jsonReadStr(configSetupJson, "routerssid")) {
|
||||
jsonWriteStr(configLiveJson, "dbm", dbm);
|
||||
}
|
||||
}
|
||||
String root;
|
||||
json.printTo(root);
|
||||
return root;
|
||||
}
|
||||
*/
|
||||
/*
|
||||
{
|
||||
"type":"wifi",
|
||||
"title":"{{LangWiFi1}}",
|
||||
"name":"routerssid",
|
||||
"state":"{{ssid}}",
|
||||
"pattern":".{1,}"
|
||||
},
|
||||
{
|
||||
"type":"routerpass",
|
||||
"title":"{{LangPass}}",
|
||||
"name":"routerpass",
|
||||
"state":"{{ssidPass}}",
|
||||
"pattern":".{8,}"
|
||||
},
|
||||
*/
|
||||
88
Widgets.ino
88
Widgets.ino
@@ -1,88 +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 createWidgetParam (String widget_name, String page_name, String page_number, String file, String topic, String name1, String param1, String name2, String param2, String name3, String param3) {
|
||||
|
||||
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);
|
||||
|
||||
if (name1 != "") jsonWriteStr(widget, name1, param1);
|
||||
if (name2 != "") jsonWriteStr(widget, name2, param2);
|
||||
if (name3 != "") jsonWriteStr(widget, name3, param3);
|
||||
|
||||
#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 = "";
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
33
bus.ino
33
bus.ino
@@ -1,33 +0,0 @@
|
||||
void do_i2c_scanning() {
|
||||
if (i2c_scanning) {
|
||||
i2c_scanning = false;
|
||||
String tmp = i2c_scan();
|
||||
if (tmp == "error") {
|
||||
tmp = i2c_scan();
|
||||
Serial.println(tmp);
|
||||
jsonWriteStr(configLiveJson, "i2c", tmp);
|
||||
} else {
|
||||
Serial.println(tmp);
|
||||
jsonWriteStr(configLiveJson, "i2c", tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String i2c_scan() {
|
||||
String out;
|
||||
byte count = 0;
|
||||
Wire.begin();
|
||||
for (byte i = 8; i < 120; i++) {
|
||||
Wire.beginTransmission(i);
|
||||
if (Wire.endTransmission() == 0) {
|
||||
count++;
|
||||
out += String(count) + ". 0x" + String(i, HEX) + "; ";
|
||||
delay(1);
|
||||
}
|
||||
}
|
||||
if (count == 0) {
|
||||
return "error";
|
||||
} else {
|
||||
return out;
|
||||
}
|
||||
}
|
||||
@@ -9,13 +9,15 @@
|
||||
"ntp": "pool.ntp.org",
|
||||
"mqttServer": "91.204.228.124",
|
||||
"mqttPort": 1883,
|
||||
"mqttPrefix": "/rise",
|
||||
"mqttUser": "test",
|
||||
"mqttPass": "test",
|
||||
"mqttPrefix": "/iotTest",
|
||||
"mqttUser": "rise",
|
||||
"mqttPass": "23ri22se32",
|
||||
"scen": "1",
|
||||
"pushingboxid": "v7C133E426B0C69E",
|
||||
"weblogin": "admin",
|
||||
"webpass": "admin",
|
||||
"udponoff": "1",
|
||||
"blink":"1"
|
||||
"blink": "1",
|
||||
"oneWirePin": "2",
|
||||
"serverip": "http://206.189.49.244"
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
dallas 2 Водонагреватель,#t°C Датчики any-data 1
|
||||
logging dallas 1 100 Температура Датчики 2
|
||||
|
||||
//2 - номер пина датчика
|
||||
//варианты отображения: any-data, progress-round, progress-line, fill-gauge
|
||||
@@ -1,11 +0,0 @@
|
||||
level lev 14 12 Вода#в#баке,#% Датчики 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 lev 1 100 Вода#в#баке Датчики 6
|
||||
|
||||
//125 - это расстояние от датчика до дна бака в сантиметрах
|
||||
//20 - это расстояние от датчика до поверхности воды когда бак полный в сантиметрах
|
||||
//вывод данных будет в процентах заполнения бака
|
||||
//варианты отображения: any-data, progress-round, progress-line, fill-gauge
|
||||
@@ -1,12 +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 adc 0 Аналоговый#вход Датчики fill-gauge 1 1023 1 1023 6
|
||||
logging adc 1 100 Аналоговый#вход Датчики 7
|
||||
|
||||
//Это демо конфигурация. В ней показано как связать кнопки c помощью сценариев
|
||||
//Кнопка номер 1 связана с кнопкой 2, 3 и с pwm 2
|
||||
//Так же продемонстрированна система логгирования данных строкой logging
|
||||
//1 - это интервал между точками в минутах, 100 это количество точек
|
||||
Binary file not shown.
658
data/edit.htm
Normal file
658
data/edit.htm
Normal file
@@ -0,0 +1,658 @@
|
||||
<!--This is the plain html source of the hex encoded Editor-Page embedded in SPIFFSEditor.cpp -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<title>FS Editor</title>
|
||||
<style type="text/css" media="screen">
|
||||
.cm {
|
||||
z-index: 300;
|
||||
position: absolute;
|
||||
left: 5px;
|
||||
border: 1px solid #444;
|
||||
background-color: #F5F5F5;
|
||||
display: none;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, .4);
|
||||
font-size: 12px;
|
||||
font-family: sans-serif;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.cm ul {
|
||||
list-style: none;
|
||||
top: 0;
|
||||
left: 0;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.cm li {
|
||||
position: relative;
|
||||
min-width: 60px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.cm span {
|
||||
color: #444;
|
||||
display: inline-block;
|
||||
padding: 6px;
|
||||
}
|
||||
|
||||
.cm li:hover {
|
||||
background: #444;
|
||||
}
|
||||
|
||||
.cm li:hover span {
|
||||
color: #EEE;
|
||||
}
|
||||
|
||||
.tvu ul,
|
||||
.tvu li {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.tvu input {
|
||||
position: absolute;
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.tvu {
|
||||
font: normal 12px Verdana, Arial, Sans-serif;
|
||||
-moz-user-select: none;
|
||||
-webkit-user-select: none;
|
||||
user-select: none;
|
||||
color: #444;
|
||||
line-height: 16px;
|
||||
}
|
||||
|
||||
.tvu span {
|
||||
margin-bottom: 5px;
|
||||
padding: 0 0 0 18px;
|
||||
cursor: pointer;
|
||||
display: inline-block;
|
||||
height: 16px;
|
||||
vertical-align: middle;
|
||||
background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAQAAAC1+jfqAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAADoSURBVBgZBcExblNBGAbA2ceegTRBuIKOgiihSZNTcC5LUHAihNJR0kGKCDcYJY6D3/77MdOinTvzAgCw8ysThIvn/VojIyMjIyPP+bS1sUQIV2s95pBDDvmbP/mdkft83tpYguZq5Jh/OeaYh+yzy8hTHvNlaxNNczm+la9OTlar1UdA/+C2A4trRCnD3jS8BB1obq2Gk6GU6QbQAS4BUaYSQAf4bhhKKTFdAzrAOwAxEUAH+KEM01SY3gM6wBsEAQB0gJ+maZoC3gI6iPYaAIBJsiRmHU0AALOeFC3aK2cWAACUXe7+AwO0lc9eTHYTAAAAAElFTkSuQmCC') no-repeat;
|
||||
background-position: 0px 0px;
|
||||
}
|
||||
|
||||
.tvu span:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
@media screen and (-webkit-min-device-pixel-ratio:0) {
|
||||
.tvu {
|
||||
-webkit-animation: webkit-adjacent-element-selector-bugfix infinite 1s;
|
||||
}
|
||||
|
||||
@-webkit-keyframes webkit-adjacent-element-selector-bugfix {
|
||||
from {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
to {
|
||||
padding: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#uploader {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
left: 0;
|
||||
height: 28px;
|
||||
line-height: 24px;
|
||||
padding-left: 10px;
|
||||
background-color: #444;
|
||||
color: #EEE;
|
||||
}
|
||||
|
||||
#tree {
|
||||
position: absolute;
|
||||
top: 28px;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 160px;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
#editor,
|
||||
#preview {
|
||||
position: absolute;
|
||||
top: 28px;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 160px;
|
||||
border-left: 1px solid #EEE;
|
||||
}
|
||||
|
||||
#preview {
|
||||
background-color: #EEE;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
#loader {
|
||||
position: absolute;
|
||||
top: 36%;
|
||||
right: 40%;
|
||||
}
|
||||
|
||||
.loader {
|
||||
z-index: 10000;
|
||||
border: 8px solid #b5b5b5;
|
||||
/* Grey */
|
||||
border-top: 8px solid #3498db;
|
||||
/* Blue */
|
||||
border-bottom: 8px solid #3498db;
|
||||
/* Blue */
|
||||
border-radius: 50%;
|
||||
width: 240px;
|
||||
height: 240px;
|
||||
animation: spin 2s linear infinite;
|
||||
display: none;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
0% {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
|
||||
100% {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
if (typeof XMLHttpRequest === "undefined") {
|
||||
XMLHttpRequest = function () {
|
||||
try { return new ActiveXObject("Msxml2.XMLHTTP.6.0"); } catch (e) { }
|
||||
try { return new ActiveXObject("Msxml2.XMLHTTP.3.0"); } catch (e) { }
|
||||
try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { }
|
||||
throw new Error("This browser does not support XMLHttpRequest.");
|
||||
};
|
||||
}
|
||||
|
||||
function ge(a) {
|
||||
return document.getElementById(a);
|
||||
}
|
||||
function ce(a) {
|
||||
return document.createElement(a);
|
||||
}
|
||||
|
||||
function sortByKey(array, key) {
|
||||
return array.sort(function (a, b) {
|
||||
var x = a[key]; var y = b[key];
|
||||
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
var QueuedRequester = function () {
|
||||
this.queue = [];
|
||||
this.running = false;
|
||||
this.xmlhttp = null;
|
||||
}
|
||||
QueuedRequester.prototype = {
|
||||
_request: function (req) {
|
||||
this.running = true;
|
||||
if (!req instanceof Object) return;
|
||||
var that = this;
|
||||
|
||||
function ajaxCb(x, d) {
|
||||
return function () {
|
||||
if (x.readyState == 4) {
|
||||
ge("loader").style.display = "none";
|
||||
d.callback(x.status, x.responseText);
|
||||
if (that.queue.length === 0) that.running = false;
|
||||
if (that.running) that._request(that.queue.shift());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ge("loader").style.display = "block";
|
||||
|
||||
var p = "";
|
||||
if (req.params instanceof FormData) {
|
||||
p = req.params;
|
||||
} else if (req.params instanceof Object) {
|
||||
for (var key in req.params) {
|
||||
if (p === "")
|
||||
p += (req.method === "GET") ? "?" : "";
|
||||
else
|
||||
p += "&";
|
||||
p += encodeURIComponent(key) + "=" + encodeURIComponent(req.params[key]);
|
||||
};
|
||||
}
|
||||
|
||||
this.xmlhttp = new XMLHttpRequest();
|
||||
this.xmlhttp.onreadystatechange = ajaxCb(this.xmlhttp, req);
|
||||
if (req.method === "GET") {
|
||||
this.xmlhttp.open(req.method, req.url + p, true);
|
||||
this.xmlhttp.send();
|
||||
} else {
|
||||
this.xmlhttp.open(req.method, req.url, true);
|
||||
if (p instanceof String)
|
||||
this.xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
||||
this.xmlhttp.send(p);
|
||||
}
|
||||
},
|
||||
stop: function () {
|
||||
if (this.running) this.running = false;
|
||||
if (this.xmlhttp && this.xmlhttp.readyState < 4) {
|
||||
this.xmlhttp.abort();
|
||||
}
|
||||
},
|
||||
add: function (method, url, params, callback) {
|
||||
this.queue.push({ url: url, method: method, params: params, callback: callback });
|
||||
if (!this.running) {
|
||||
this._request(this.queue.shift());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var requests = new QueuedRequester();
|
||||
|
||||
function createFileUploader(element, tree, editor) {
|
||||
var xmlHttp;
|
||||
|
||||
var refresh = ce("button");
|
||||
refresh.innerHTML = 'Refresh List';
|
||||
ge(element).appendChild(refresh);
|
||||
|
||||
var input = ce("input");
|
||||
input.type = "file";
|
||||
input.multiple = false;
|
||||
input.name = "data";
|
||||
input.id = "upload-select";
|
||||
ge(element).appendChild(input);
|
||||
|
||||
var path = ce("input");
|
||||
path.id = "upload-path";
|
||||
path.type = "text";
|
||||
path.name = "path";
|
||||
path.defaultValue = "/";
|
||||
ge(element).appendChild(path);
|
||||
|
||||
var button = ce("button");
|
||||
button.innerHTML = 'Upload';
|
||||
ge(element).appendChild(button);
|
||||
|
||||
var mkfile = ce("button");
|
||||
mkfile.innerHTML = 'Create';
|
||||
ge(element).appendChild(mkfile);
|
||||
|
||||
var filename = ce("input");
|
||||
filename.id = "editor-filename";
|
||||
filename.type = "text";
|
||||
filename.disabled = true;
|
||||
filename.size = 20;
|
||||
ge(element).appendChild(filename);
|
||||
|
||||
var savefile = ce("button");
|
||||
savefile.innerHTML = ' Save ';
|
||||
ge(element).appendChild(savefile);
|
||||
|
||||
function httpPostProcessRequest(status, responseText) {
|
||||
if (status != 200)
|
||||
alert("ERROR[" + status + "]: " + responseText);
|
||||
else
|
||||
tree.refreshPath(path.value);
|
||||
}
|
||||
function createPath(p) {
|
||||
var formData = new FormData();
|
||||
formData.append("path", p);
|
||||
requests.add("PUT", "/edit", formData, httpPostProcessRequest);
|
||||
}
|
||||
|
||||
mkfile.onclick = function (e) {
|
||||
createPath(path.value);
|
||||
editor.loadUrl(path.value);
|
||||
path.value = "/";
|
||||
};
|
||||
|
||||
savefile.onclick = function (e) {
|
||||
editor.execCommand('saveCommand');
|
||||
};
|
||||
|
||||
refresh.onclick = function (e) {
|
||||
tree.refreshPath(path.value);
|
||||
};
|
||||
|
||||
button.onclick = function (e) {
|
||||
if (input.files.length === 0) {
|
||||
return;
|
||||
}
|
||||
var formData = new FormData();
|
||||
formData.append("data", input.files[0], path.value);
|
||||
requests.add("POST", "/edit", formData, httpPostProcessRequest);
|
||||
var uploadPath = ge("upload-path");
|
||||
uploadPath.value = "/";
|
||||
var uploadSelect = ge("upload-select");
|
||||
uploadSelect.value = "";
|
||||
};
|
||||
input.onchange = function (e) {
|
||||
if (input.files.length === 0) return;
|
||||
var filename = input.files[0].name;
|
||||
var ext = /(?:\.([^.]+))?$/.exec(filename)[1];
|
||||
var name = /(.*)\.[^.]+$/.exec(filename)[1];
|
||||
if (typeof name !== undefined) {
|
||||
filename = name;
|
||||
}
|
||||
path.value = "/" + filename + "." + ext;
|
||||
};
|
||||
}
|
||||
|
||||
function createTree(element, editor) {
|
||||
var preview = ge("preview");
|
||||
var treeRoot = ce("div");
|
||||
treeRoot.className = "tvu";
|
||||
ge(element).appendChild(treeRoot);
|
||||
|
||||
function loadDownload(path) {
|
||||
ge('download-frame').src = "/edit?download=" + path;
|
||||
}
|
||||
|
||||
function loadPreview(path) {
|
||||
var edfname = ge("editor-filename");
|
||||
edfname.value = path;
|
||||
ge("editor").style.display = "none";
|
||||
preview.style.display = "block";
|
||||
preview.innerHTML = '<img src="/edit?edit=' + path + '&_cb=' + Date.now() + '" style="max-width:100%; max-height:100%; margin:auto; display:block;" />';
|
||||
}
|
||||
|
||||
function fillFileMenu(el, path) {
|
||||
var list = ce("ul");
|
||||
el.appendChild(list);
|
||||
var action = ce("li");
|
||||
list.appendChild(action);
|
||||
if (isImageFile(path)) {
|
||||
action.innerHTML = "<span>Preview</span>";
|
||||
action.onclick = function (e) {
|
||||
loadPreview(path);
|
||||
if (document.body.getElementsByClassName('cm').length > 0) document.body.removeChild(el);
|
||||
};
|
||||
} else if (isTextFile(path)) {
|
||||
action.innerHTML = "<span>Edit</span>";
|
||||
action.onclick = function (e) {
|
||||
editor.loadUrl(path);
|
||||
if (document.body.getElementsByClassName('cm').length > 0) document.body.removeChild(el);
|
||||
};
|
||||
}
|
||||
var download = ce("li");
|
||||
list.appendChild(download);
|
||||
download.innerHTML = "<span>Download</span>";
|
||||
download.onclick = function (e) {
|
||||
loadDownload(path);
|
||||
if (document.body.getElementsByClassName('cm').length > 0) document.body.removeChild(el);
|
||||
};
|
||||
var delFile = ce("li");
|
||||
list.appendChild(delFile);
|
||||
delFile.innerHTML = "<span>Delete</span>";
|
||||
delFile.onclick = function (e) {
|
||||
httpDelete(path);
|
||||
if (document.body.getElementsByClassName('cm').length > 0) document.body.removeChild(el);
|
||||
};
|
||||
}
|
||||
|
||||
function showContextMenu(event, path, isfile) {
|
||||
var divContext = ce("div");
|
||||
var scrollTop = document.body.scrollTop ? document.body.scrollTop : document.documentElement.scrollTop;
|
||||
var scrollLeft = document.body.scrollLeft ? document.body.scrollLeft : document.documentElement.scrollLeft;
|
||||
var left = event.clientX + scrollLeft;
|
||||
var top = event.clientY + scrollTop;
|
||||
divContext.className = 'cm';
|
||||
divContext.style.display = 'block';
|
||||
divContext.style.left = left + 'px';
|
||||
divContext.style.top = top + 'px';
|
||||
fillFileMenu(divContext, path);
|
||||
document.body.appendChild(divContext);
|
||||
var width = divContext.offsetWidth;
|
||||
var height = divContext.offsetHeight;
|
||||
divContext.onmouseout = function (e) {
|
||||
if (e.clientX < left || e.clientX > (left + width) || e.clientY < top || e.clientY > (top + height)) {
|
||||
if (document.body.getElementsByClassName('cm').length > 0) document.body.removeChild(divContext);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function createTreeLeaf(path, name, size) {
|
||||
var leaf = ce("li");
|
||||
leaf.id = name;
|
||||
var label = ce("span");
|
||||
label.innerHTML = name;
|
||||
leaf.appendChild(label);
|
||||
leaf.onclick = function (e) {
|
||||
if (isTextFile(leaf.id.toLowerCase())) {
|
||||
editor.loadUrl(leaf.id);
|
||||
} else if (isImageFile(leaf.id.toLowerCase())) {
|
||||
loadPreview(leaf.id);
|
||||
}
|
||||
};
|
||||
leaf.oncontextmenu = function (e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
showContextMenu(e, leaf.id, true);
|
||||
};
|
||||
return leaf;
|
||||
}
|
||||
|
||||
function addList(parent, path, items) {
|
||||
sortByKey(items, 'name');
|
||||
var list = ce("ul");
|
||||
parent.appendChild(list);
|
||||
var ll = items.length;
|
||||
for (var i = 0; i < ll; i++) {
|
||||
if (items[i].type === "file")
|
||||
list.appendChild(createTreeLeaf(path, items[i].name, items[i].size));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function isTextFile(path) {
|
||||
var ext = /(?:\.([^.]+))?$/.exec(path)[1];
|
||||
if (typeof ext !== undefined) {
|
||||
switch (ext) {
|
||||
case "cnv":
|
||||
case "txt":
|
||||
case "htm":
|
||||
case "html":
|
||||
case "js":
|
||||
case "css":
|
||||
case "xml":
|
||||
case "json":
|
||||
case "conf":
|
||||
case "ini":
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function isImageFile(path) {
|
||||
var ext = /(?:\.([^.]+))?$/.exec(path)[1];
|
||||
if (typeof ext !== undefined) {
|
||||
switch (ext) {
|
||||
case "png":
|
||||
case "jpg":
|
||||
case "jpeg":
|
||||
case "gif":
|
||||
case "bmp":
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
this.refreshPath = function (path) {
|
||||
treeRoot.removeChild(treeRoot.childNodes[0]);
|
||||
httpGet(treeRoot, "/");
|
||||
};
|
||||
|
||||
function delCb(path) {
|
||||
return function (status, responseText) {
|
||||
if (status != 200) {
|
||||
alert("ERROR[" + status + "]: " + responseText);
|
||||
} else {
|
||||
treeRoot.removeChild(treeRoot.childNodes[0]);
|
||||
httpGet(treeRoot, "/");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function httpDelete(filename) {
|
||||
var formData = new FormData();
|
||||
formData.append("path", filename);
|
||||
requests.add("DELETE", "/edit", formData, delCb(filename));
|
||||
}
|
||||
|
||||
function getCb(parent, path) {
|
||||
return function (status, responseText) {
|
||||
if (status == 200)
|
||||
addList(parent, path, JSON.parse(responseText));
|
||||
}
|
||||
}
|
||||
|
||||
function httpGet(parent, path) {
|
||||
requests.add("GET", "/edit", { list: path }, getCb(parent, path));
|
||||
}
|
||||
|
||||
httpGet(treeRoot, "/");
|
||||
return this;
|
||||
}
|
||||
|
||||
function createEditor(element, file, lang, theme, type) {
|
||||
function getLangFromFilename(filename) {
|
||||
var lang = "plain";
|
||||
var ext = /(?:\.([^.]+))?$/.exec(filename)[1];
|
||||
if (typeof ext !== undefined) {
|
||||
switch (ext) {
|
||||
case "cnv": lang = "plain"; break;
|
||||
case "txt": lang = "plain"; break;
|
||||
case "hex": lang = "plain"; break;
|
||||
case "conf": lang = "plain"; break;
|
||||
case "htm": lang = "html"; break;
|
||||
case "js": lang = "javascript"; break;
|
||||
case "css":
|
||||
case "scss":
|
||||
case "php":
|
||||
case "html":
|
||||
case "json":
|
||||
case "xml":
|
||||
case "ini": lang = ext;
|
||||
}
|
||||
}
|
||||
return lang;
|
||||
}
|
||||
|
||||
if (typeof file === "undefined") file = "/index.html";
|
||||
|
||||
if (typeof lang === "undefined") {
|
||||
lang = getLangFromFilename(file);
|
||||
}
|
||||
|
||||
if (typeof theme === "undefined") theme = "textmate";
|
||||
|
||||
if (typeof type === "undefined") {
|
||||
type = "text/" + lang;
|
||||
if (lang === "c_cpp") type = "text/plain";
|
||||
}
|
||||
|
||||
var editor = ace.edit(element);
|
||||
function httpPostProcessRequest(status, responseText) {
|
||||
if (status != 200) alert("ERROR[" + status + "]: " + responseText);
|
||||
}
|
||||
function httpPost(filename, data, type) {
|
||||
var formData = new FormData();
|
||||
formData.append("data", new Blob([data], { type: type }), filename);
|
||||
requests.add("POST", "/edit", formData, httpPostProcessRequest);
|
||||
}
|
||||
function httpGetProcessRequest(status, responseText) {
|
||||
ge("preview").style.display = "none";
|
||||
ge("editor").style.display = "block";
|
||||
if (status == 200)
|
||||
editor.setValue(responseText);
|
||||
else
|
||||
editor.setValue("");
|
||||
editor.clearSelection();
|
||||
}
|
||||
function httpGet(theUrl) {
|
||||
requests.add("GET", "/edit", { edit: theUrl }, httpGetProcessRequest);
|
||||
}
|
||||
|
||||
if (lang !== "plain") editor.getSession().setMode("ace/mode/" + lang);
|
||||
editor.setTheme("ace/theme/" + theme);
|
||||
editor.$blockScrolling = Infinity;
|
||||
editor.getSession().setUseSoftTabs(true);
|
||||
editor.getSession().setTabSize(2);
|
||||
editor.setHighlightActiveLine(true);
|
||||
editor.setShowPrintMargin(false);
|
||||
editor.commands.addCommand({
|
||||
name: 'saveCommand',
|
||||
bindKey: { win: 'Ctrl-S', mac: 'Command-S' },
|
||||
exec: function (editor) {
|
||||
httpPost(file, editor.getValue() + "", type);
|
||||
},
|
||||
readOnly: false
|
||||
});
|
||||
editor.commands.addCommand({
|
||||
name: 'undoCommand',
|
||||
bindKey: { win: 'Ctrl-Z', mac: 'Command-Z' },
|
||||
exec: function (editor) {
|
||||
editor.getSession().getUndoManager().undo(false);
|
||||
},
|
||||
readOnly: false
|
||||
});
|
||||
editor.commands.addCommand({
|
||||
name: 'redoCommand',
|
||||
bindKey: { win: 'Ctrl-Shift-Z', mac: 'Command-Shift-Z' },
|
||||
exec: function (editor) {
|
||||
editor.getSession().getUndoManager().redo(false);
|
||||
},
|
||||
readOnly: false
|
||||
});
|
||||
editor.loadUrl = function (filename) {
|
||||
var edfname = ge("editor-filename");
|
||||
edfname.value = filename;
|
||||
file = filename;
|
||||
lang = getLangFromFilename(file);
|
||||
type = "text/" + lang;
|
||||
if (lang !== "plain") editor.getSession().setMode("ace/mode/" + lang);
|
||||
httpGet(file);
|
||||
};
|
||||
return editor;
|
||||
}
|
||||
function onBodyLoad() {
|
||||
var vars = {};
|
||||
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function (m, key, value) { vars[key] = value; });
|
||||
var editor = createEditor("editor", vars.file, vars.lang, vars.theme);
|
||||
var tree = createTree("tree", editor);
|
||||
createFileUploader("uploader", tree, editor);
|
||||
if (typeof vars.file === "undefined") vars.file = "/dev_conf.txt";
|
||||
editor.loadUrl(vars.file);
|
||||
};
|
||||
</script>
|
||||
<script id='ace' src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.6/ace.js" type="text/javascript"
|
||||
charset="utf-8"></script>
|
||||
<script>
|
||||
if (typeof ace.edit == "undefined") {
|
||||
var script = document.createElement('script');
|
||||
script.src = "/ace.js";
|
||||
script.async = false;
|
||||
document.head.appendChild(script);
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body onload="onBodyLoad();">
|
||||
<div id="loader" class="loader"></div>
|
||||
<div id="uploader"></div>
|
||||
<div id="tree"></div>
|
||||
<div id="editor"></div>
|
||||
<div id="preview" style="display:none;"></div>
|
||||
<iframe id=download-frame style='display:none;'></iframe>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,13 +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
|
||||
adc > 50
|
||||
buttonSet 2 1
|
||||
end
|
||||
Binary file not shown.
@@ -23,12 +23,6 @@
|
||||
"action": "/?set.device",
|
||||
"class": "btn btn-block btn-default"
|
||||
},
|
||||
{
|
||||
"type": "link",
|
||||
"title": "Список других устройств в сети",
|
||||
"action": "/?set.udp",
|
||||
"class": "btn btn-block btn-default"
|
||||
},
|
||||
{
|
||||
"type": "link",
|
||||
"title": "Конфигурация WIFI",
|
||||
|
||||
1
data/items/analog-adc.txt
Normal file
1
data/items/analog-adc.txt
Normal file
@@ -0,0 +1 @@
|
||||
0;analog-adc;id;fillgauge;Сенсоры;Аналоговый;order;gol;map[0,1024,0,100];c[1]
|
||||
1
data/items/bme280-hum.txt
Normal file
1
data/items/bme280-hum.txt
Normal file
@@ -0,0 +1 @@
|
||||
0;bme280-hum;id;anydataHum;Сенсоры;Влажность;order;addr[0x76];c[1]
|
||||
1
data/items/bme280-press.txt
Normal file
1
data/items/bme280-press.txt
Normal file
@@ -0,0 +1 @@
|
||||
0;bme280-press;id;anydataPress;Сенсоры;Давление;order;addr[0x76];c[1]
|
||||
1
data/items/bme280-temp.txt
Normal file
1
data/items/bme280-temp.txt
Normal file
@@ -0,0 +1 @@
|
||||
0;bme280-temp;id;anydataTemp;Сенсоры;Температура;order;addr[0x76];c[1]
|
||||
1
data/items/bmp280-press.txt
Normal file
1
data/items/bmp280-press.txt
Normal file
@@ -0,0 +1 @@
|
||||
0;bmp280-press;id;anydataPress;Сенсоры;Давление;order;addr[0x76];c[1]
|
||||
1
data/items/bmp280-temp.txt
Normal file
1
data/items/bmp280-temp.txt
Normal file
@@ -0,0 +1 @@
|
||||
0;bmp280-temp;id;anydataTemp;Сенсоры;Температура;order;addr[0x76];c[1]
|
||||
1
data/items/button-in.txt
Normal file
1
data/items/button-in.txt
Normal file
@@ -0,0 +1 @@
|
||||
0;button-in;id;toggle;Кнопки;Освещение;order;pin;db[20]
|
||||
1
data/items/button-out.inv.txt
Normal file
1
data/items/button-out.inv.txt
Normal file
@@ -0,0 +1 @@
|
||||
0;button-out;id;toggle;Кнопки;Освещение;order;pin;inv[1];st[1]
|
||||
1
data/items/button-out.npin.txt
Normal file
1
data/items/button-out.npin.txt
Normal file
@@ -0,0 +1 @@
|
||||
0;button-out;id;toggle;Кнопки;Освещение;order;st[0]
|
||||
1
data/items/button-out.pin.txt
Normal file
1
data/items/button-out.pin.txt
Normal file
@@ -0,0 +1 @@
|
||||
0;button-out;id;toggle;Кнопки;Освещение;order;pin;st[0]
|
||||
1
data/items/dallas-temp.txt
Normal file
1
data/items/dallas-temp.txt
Normal file
@@ -0,0 +1 @@
|
||||
0;dallas-temp;id;anydataTemp;Сенсоры;Температура;order;sal;index[0];int[10]
|
||||
1
data/items/dht11-hum.txt
Normal file
1
data/items/dht11-hum.txt
Normal file
@@ -0,0 +1 @@
|
||||
0;dht-hum;id;anydataHum;Сенсоры;Влажность;order;thd;type[dht11];c[1]
|
||||
1
data/items/dht11-temp.txt
Normal file
1
data/items/dht11-temp.txt
Normal file
@@ -0,0 +1 @@
|
||||
0;dht-temp;id;anydataTemp;Сенсоры;Температура;order;thd;type[dht11];c[1]
|
||||
1
data/items/dht22-hum.txt
Normal file
1
data/items/dht22-hum.txt
Normal file
@@ -0,0 +1 @@
|
||||
0;dht-hum;id;anydataHum;Сенсоры;Влажность;order;thd;type[dht22];c[1]
|
||||
1
data/items/dht22-temp.txt
Normal file
1
data/items/dht22-temp.txt
Normal file
@@ -0,0 +1 @@
|
||||
0;dht-temp;id;anydataTemp;Сенсоры;Температура;order;thd;type[dht22];c[1]
|
||||
1
data/items/impuls-out.txt
Normal file
1
data/items/impuls-out.txt
Normal file
@@ -0,0 +1 @@
|
||||
0;impuls-out;id;na;na;na;order;pin
|
||||
1
data/items/input-digit.txt
Normal file
1
data/items/input-digit.txt
Normal file
@@ -0,0 +1 @@
|
||||
0;input-digit;id;inputDigit;Ввод;Введите#цифру;order;st[60]
|
||||
1
data/items/input-time.txt
Normal file
1
data/items/input-time.txt
Normal file
@@ -0,0 +1 @@
|
||||
0;input-time;id;inputTime;Ввод;Введите#время;order;st[10:00:00]
|
||||
1
data/items/logging.txt
Normal file
1
data/items/logging.txt
Normal file
@@ -0,0 +1 @@
|
||||
0;logging;id;chart;Графики;История;order;val[any];int[60];cnt[100]
|
||||
1
data/items/modbus.txt
Normal file
1
data/items/modbus.txt
Normal file
@@ -0,0 +1 @@
|
||||
0;modbus;id;anydata;Modbus;Регистр;order;addr[1];reg[0];c[1]
|
||||
1
data/items/output-text.txt
Normal file
1
data/items/output-text.txt
Normal file
@@ -0,0 +1 @@
|
||||
0;output-text;id;anydata;Вывод;Сигнализация;order;st[Обнаружено#движение]
|
||||
1
data/items/pwm-out.txt
Normal file
1
data/items/pwm-out.txt
Normal file
@@ -0,0 +1 @@
|
||||
0;pwm-out;id;range;Ползунки;Яркость;order;pin;st[500]
|
||||
1
data/items/ultrasonic-cm.txt
Normal file
1
data/items/ultrasonic-cm.txt
Normal file
@@ -0,0 +1 @@
|
||||
0;ultrasonic-cm;id;anydata;Сенсоры;Расстояние;order;cin;map[0,500,0,100];c[1]
|
||||
1
data/items/uptime.txt
Normal file
1
data/items/uptime.txt
Normal file
@@ -0,0 +1 @@
|
||||
0;uptime;id;anydataTime;Системные;%name%#uptime;order
|
||||
Binary file not shown.
Binary file not shown.
5
data/presets/dal.c.txt
Normal file
5
data/presets/dal.c.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
0;dallas-temp;temp;anydataTemp;Термостат;Температура;1;pin[2];index[0];int[10]
|
||||
0;logging;log;chart;Термостат;История;2;val[temp];int[60];cnt[100]
|
||||
0;input-digit;inputU;inputDigit;Термостат;Верхний#порог;3;st[30]
|
||||
0;input-digit;inputL;inputDigit;Термостат;Нижний#порог;4;st[20]
|
||||
0;button-out;button;toggle;Термостат;Нагрев;5;pin[12];st[0]
|
||||
6
data/presets/dal.s.txt
Normal file
6
data/presets/dal.s.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
temp > inputU
|
||||
button 0
|
||||
end
|
||||
temp < inputL
|
||||
button 1
|
||||
end
|
||||
5
data/presets/dht.c.txt
Normal file
5
data/presets/dht.c.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
0;dht-hum;hum;anydataHum;Теплица;Влажность;1;pin[2];type[dht11];c[1]
|
||||
0;logging;log;chart;Теплица;Влажность;2;val[hum];int[60];cnt[100]
|
||||
0;input-digit;inputU;inputDigit;Теплица;Верхний#порог;3;st[45]
|
||||
0;input-digit;inputL;inputDigit;Теплица;Нижний#порог;4;st[35]
|
||||
0;button-out;button;toggle;Теплица;Полив;5;pin[12];st[0]
|
||||
6
data/presets/dht.s.txt
Normal file
6
data/presets/dht.s.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
hum > inputU
|
||||
button 0
|
||||
end
|
||||
hum < inputL
|
||||
button 1
|
||||
end
|
||||
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 @@
|
||||
//
|
||||
46
data/set.dev.json
Normal file
46
data/set.dev.json
Normal file
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"configs": [
|
||||
"/config.setup.json",
|
||||
"/lang/lang.ru.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-default"
|
||||
},
|
||||
{
|
||||
"type": "link",
|
||||
"title": "{{ButMainPage}}",
|
||||
"action": "/",
|
||||
"class": "btn btn-block btn-default"
|
||||
},
|
||||
{
|
||||
"type": "hr"
|
||||
},
|
||||
{
|
||||
"type": "h3",
|
||||
"title": "Адрес сервера обновлений"
|
||||
},
|
||||
{
|
||||
"type": "input",
|
||||
"title": "ip address",
|
||||
"name": "serverip-arg",
|
||||
"state": "{{serverip}}"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"title": "{{ButSave}}",
|
||||
"action": "set?serverip=[[serverip-arg]]",
|
||||
"class": "btn btn-block btn-default"
|
||||
},
|
||||
{
|
||||
"type": "link",
|
||||
"title": "Перезагрузить устройство",
|
||||
"action": "javascript:if(confirm(renameBlock(jsonResponse,'Перезагрузить?'))){send_request(this,'/set?device=ok');}",
|
||||
"class": "btn btn-block btn-danger"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,143 +1,189 @@
|
||||
{
|
||||
"configs": [
|
||||
"/config.setup.json",
|
||||
"/config.option.json",
|
||||
"/config.live.json",
|
||||
"/lang/lang.ru.json"
|
||||
],
|
||||
"class": "col-sm-offset-1 col-sm-10",
|
||||
"content": [
|
||||
{
|
||||
"type": "h5",
|
||||
"title": "{{name}}",
|
||||
"class": "alert-default"
|
||||
},
|
||||
{
|
||||
"type": "link",
|
||||
"title": "{{ButMainPage}}",
|
||||
"action": "/",
|
||||
"class": "btn btn-block btn-default"
|
||||
},
|
||||
{
|
||||
"type": "hr"
|
||||
},
|
||||
{
|
||||
"type": "h4",
|
||||
"title": "Device ID: {{chipID}}"
|
||||
},
|
||||
{
|
||||
"type": "h4",
|
||||
"title": "IP address: {{ip}}"
|
||||
},
|
||||
{
|
||||
"type": "h4",
|
||||
"title": "Time: {{time}}"
|
||||
},
|
||||
{
|
||||
"type": "h4",
|
||||
"title": "Uptime: {{uptime}}"
|
||||
},
|
||||
{
|
||||
"type": "h4",
|
||||
"title": "Build version: {{firmware_version}}"
|
||||
},
|
||||
{
|
||||
"type": "h4",
|
||||
"title": "SPIFFS version: 2.3.3"
|
||||
},
|
||||
{
|
||||
"type": "hr"
|
||||
},
|
||||
{
|
||||
"type": "dropdown",
|
||||
"name": "help-url",
|
||||
"class": "btn btn-default",
|
||||
"style": "display:inline",
|
||||
"title": {
|
||||
"#": "{{SetDevPreset}}<span class=\"caret\"></span>",
|
||||
"/set?preset=1": "1.Вкл. выкл. локального реле",
|
||||
"/set?preset=2": "2.Вкл. выкл. локального реле в определенное время",
|
||||
"/set?preset=3": "3.Вкл. выкл. локального реле на определенный период времени",
|
||||
"/set?preset=4": "4.Вкл. выкл. нескольких локальных реле кнопкой в приложении",
|
||||
"/set?preset=5": "5.Вкл. выкл. локального реле физической кнопкой и кнопкой в приложении параллельно (для выключателя света)",
|
||||
"/set?preset=6": "6.Вкл. выкл. нескольких удаленных реле кнопкой в приложении (нужно указать Device ID)",
|
||||
"/set?preset=7": "7.Вкл. выкл. нескольких удаленных реле физической кнопкой (нужно указать Device ID)",
|
||||
"/set?preset=8": "8.Широтно импульсная модуляция",
|
||||
"/set?preset=9": "9.Сенсор DHT11 (темп, влажность) и логгирование",
|
||||
"/set?preset=10": "10.Сенсор DHT22, DHT33, DHT44, AM2302, RHT03 (темп, влажность) и логгирование",
|
||||
"/set?preset=11": "11.Аналоговый сенсор и логгирование",
|
||||
"/set?preset=12": "12.Cенсор bmp280 (темп, давление) и логгирование",
|
||||
"/set?preset=13": "13.Cенсор bme280 (темп, давление, влажность, высота) и логгирование",
|
||||
"/set?preset=14": "12.Сенсор DS18B20 (темп) и логгирование",
|
||||
"/set?preset=15": "13.Термостат на DS18B20 с переключением в ручной режим и логгированием",
|
||||
"/set?preset=16": "14.Котроль уровня в баке (датчик расстояния) на сенсорах: JSN-SR04T, HC-SR04, HY-SRF05 и логгирование",
|
||||
"/set?preset=17": "15.Датчик движения включающий свет",
|
||||
"/set?preset=18": "16.Охранный датчик движения",
|
||||
"/set?preset=19": "17.Система управления шаговыми двигателями на основе драйвера A4988 (открытие закрытие штор)",
|
||||
"/set?preset=20": "18.Система управления сервоприводами",
|
||||
"/set?preset=21": "Настройки по умолчанию"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "h2",
|
||||
"title": "{{SetDevConf}}"
|
||||
},
|
||||
{
|
||||
"type": "file",
|
||||
"state": "firmware.c.txt",
|
||||
"style": "width:100%;height:350px",
|
||||
"title": "Сохранить",
|
||||
"action": "/set?devinit",
|
||||
"class": "btn btn-block btn-default"
|
||||
},
|
||||
{
|
||||
"type": "h2",
|
||||
"title": "Сценарии"
|
||||
},
|
||||
{
|
||||
"type": "checkbox",
|
||||
"name": "scen",
|
||||
"title": "Включить сценарии",
|
||||
"action": "/set?scen=[[scen]]",
|
||||
"state": "{{scen}}"
|
||||
},
|
||||
{
|
||||
"type": "file",
|
||||
"state": "firmware.s.txt",
|
||||
"style": "width:100%;height:350px",
|
||||
"title": "Сохранить",
|
||||
"action": "/set?sceninit",
|
||||
"class": "btn btn-block btn-default"
|
||||
},
|
||||
|
||||
{
|
||||
"type": "link",
|
||||
"title": "Инструкция к системе автоматизации",
|
||||
"action": "https://github.com/DmitryBorisenko33/esp32-esp8266_iot-manager_modules_firmware/wiki/Instruction",
|
||||
"class": "btn btn-block btn-default"
|
||||
},
|
||||
{
|
||||
"type": "link",
|
||||
"title": "Очистить логи сенсоров",
|
||||
"action": "/set?cleanlog",
|
||||
"class": "btn btn-block btn-default"
|
||||
},
|
||||
{
|
||||
"type": "hr"
|
||||
},
|
||||
{
|
||||
"type": "h3",
|
||||
"name": "my-block",
|
||||
"style": "position:fixed;top:50%;left:50%;width:400px;margin-left:-200px;text-align:center;",
|
||||
"class": "hidden"
|
||||
},
|
||||
|
||||
{
|
||||
"type": "button",
|
||||
"title": "Обновить прошивку устройства",
|
||||
"action": "/check",
|
||||
"response": "[[my-block]]",
|
||||
"class": "btn btn-block btn-default"
|
||||
}
|
||||
]
|
||||
"configs": [
|
||||
"/config.setup.json",
|
||||
"/config.option.json",
|
||||
"/config.live.json",
|
||||
"/lang/lang.ru.json"
|
||||
],
|
||||
"class": "col-sm-offset-1 col-sm-10",
|
||||
"content": [
|
||||
{
|
||||
"type": "h5",
|
||||
"title": "{{name}}",
|
||||
"class": "alert-default"
|
||||
},
|
||||
{
|
||||
"type": "link",
|
||||
"title": "{{ButMainPage}}",
|
||||
"action": "/",
|
||||
"class": "btn btn-block btn-default"
|
||||
},
|
||||
{
|
||||
"type": "hr"
|
||||
},
|
||||
{
|
||||
"type": "h4",
|
||||
"title": "Device ID: {{chipID}}"
|
||||
},
|
||||
{
|
||||
"type": "h4",
|
||||
"title": "IP address: {{ip}}"
|
||||
},
|
||||
{
|
||||
"type": "h4",
|
||||
"title": "Time: {{timenow}}"
|
||||
},
|
||||
{
|
||||
"type": "h4",
|
||||
"title": "Uptime: {{uptime}}"
|
||||
},
|
||||
{
|
||||
"type": "h4",
|
||||
"title": "Build version: {{firmware_version}}"
|
||||
},
|
||||
{
|
||||
"type": "h4",
|
||||
"title": "LittleFS version: 264"
|
||||
},
|
||||
{
|
||||
"type": "hr"
|
||||
},
|
||||
{
|
||||
"type": "dropdown",
|
||||
"name": "help-url1",
|
||||
"class": "btn btn-default",
|
||||
"style": "display:inline",
|
||||
"title": {
|
||||
"#": "Выберите элемент из списка<span class=\"caret\"></span>",
|
||||
"/set?addItem=button-out.pin": "1.Кнопка управляющая пином",
|
||||
"/set?addItem=button-out.npin": "2.Кнопка виртуальная",
|
||||
"/set?addItem=button-in": "4.Кнопка физическая",
|
||||
"/set?addItem=pwm-out": "3.Широтно импульсная модуляция pwm",
|
||||
"/set?addItem=input-digit": "5.Окно ввода цифровых значений",
|
||||
"/set?addItem=input-time": "6.Окно ввода времени",
|
||||
"/set?addItem=output-text": "7.Окно вывода любого текста, предупреждения, цифры",
|
||||
"/set?addItem=analog-adc": "8.Датчик аналоговый, чтение аналогового входа",
|
||||
"/set?addItem=dallas-temp": "9.Датчик температуры ds18b20",
|
||||
"/set?addItem=ultrasonic-cm": "10.Датчик расстояния ультрозвуковой JSN-SR04T, HC-SR04, HY-SRF05",
|
||||
"/set?addItem=dht11-temp": "11.Датчик температуры DHT11",
|
||||
"/set?addItem=dht11-hum": "12.Датчик влажности DHT11",
|
||||
"/set?addItem=dht22-temp": "13.Датчик температуры DHT22, DHT33, DHT44, AM2302, RHT03",
|
||||
"/set?addItem=dht22-hum": "14.Датчик влажности DHT22, DHT33, DHT44, AM2302, RHT03",
|
||||
"/set?addItem=bme280-temp": "15.Датчик температуры bme280",
|
||||
"/set?addItem=bme280-hum": "16.Датчик влажности bme280",
|
||||
"/set?addItem=bme280-press": "17.Датчик давления bme280",
|
||||
"/set?addItem=bmp280-temp": "18.Датчик температуры bmp280",
|
||||
"/set?addItem=bmp280-press": "19.Датчик давления bmp280",
|
||||
"/set?addItem=impuls-out": "20.Создать импульсы через заданный промежуток времени (управление шд)",
|
||||
"/set?addItem=modbus": "21.Прочитать регистр modbus устройства",
|
||||
"/set?addItem=logging": "a.Логгирование и вывод в график любой величины",
|
||||
"/set?addItem=uptime": "b.Отобразить время работы устройства"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "dropdown",
|
||||
"name": "help-url2",
|
||||
"class": "btn btn-default",
|
||||
"style": "display:inline",
|
||||
"title": {
|
||||
"#": "Выберите пресет из списка<span class=\"caret\"></span>",
|
||||
"/set?addPreset=dal.c": "1.Термостат на основе ds18b20 (устройство держит заданный уровень температуры)",
|
||||
"/set?addPreset=dht.c": "2.Контроль влажности на основе DHT (устройство держит заданный уровень влажности)"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "hr"
|
||||
},
|
||||
{
|
||||
"type": "csv",
|
||||
"title": [
|
||||
"checkbox",
|
||||
"html",
|
||||
"text",
|
||||
"text",
|
||||
"text",
|
||||
"text",
|
||||
"text"
|
||||
],
|
||||
"state": "s.conf.csv",
|
||||
"style": "width:100%;",
|
||||
"action": "/set?saveItems",
|
||||
"class": "btn btn-block btn-default"
|
||||
},
|
||||
{
|
||||
"type": "hr"
|
||||
},
|
||||
{
|
||||
"type": "link",
|
||||
"title": "Удалить выбранные элементы",
|
||||
"action": "javascript:{send_request(this,'/set?delChoosingItems');setTimeout(function(){location.href='/?set.device' ; }, 1000);}",
|
||||
"class": "btn btn-block btn-default"
|
||||
},
|
||||
{
|
||||
"type": "link",
|
||||
"title": "Удалить все",
|
||||
"action": "/set?delAllItems",
|
||||
"class": "btn btn-block btn-default"
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"title": "<div style='margin-top:10px;margin-bottom:10px;'><font color='black'><p style='border: 1px solid #DCDCDC; border-radius: 3px; background-color: #F5F5F5; padding: 10px;'>После любого изменения таблицы элементов, включая удаление/добавление строк, необходимо нажать кнопку <b>СОХРАНИТЬ ТАБЛИЦУ</b>. Иногда, для корректной работы необходимо перезагрузить устройство после финального завершения его настройки</p></font></div>"
|
||||
},
|
||||
{
|
||||
"type": "h2",
|
||||
"title": "Сценарии"
|
||||
},
|
||||
{
|
||||
"type": "checkbox",
|
||||
"name": "scen",
|
||||
"title": "Включить сценарии",
|
||||
"action": "/set?scen=[[scen]]",
|
||||
"state": "{{scen}}"
|
||||
},
|
||||
{
|
||||
"type": "file",
|
||||
"state": "s.scen.txt",
|
||||
"style": "width:100%;height:350px",
|
||||
"title": "Сохранить",
|
||||
"action": "/set?sceninit",
|
||||
"class": "btn btn-block btn-default"
|
||||
},
|
||||
{
|
||||
"type": "hr"
|
||||
},
|
||||
{
|
||||
"type": "link",
|
||||
"title": "Ручная настройка",
|
||||
"action": "/?set.manual",
|
||||
"class": "btn btn-block btn-default"
|
||||
},
|
||||
{
|
||||
"type": "link",
|
||||
"title": "Инструкция к системе автоматизации",
|
||||
"action": "https://github.com/IoTManagerProject/IoTManager/wiki",
|
||||
"class": "btn btn-block btn-default"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"title": "Очистить логи сенсоров",
|
||||
"action": "/set?cleanlog",
|
||||
"class": "btn btn-block btn-default"
|
||||
},
|
||||
{
|
||||
"type": "hr"
|
||||
},
|
||||
{
|
||||
"type": "h3",
|
||||
"name": "my-block",
|
||||
"style": "position:fixed;top:50%;left:50%;width:400px;margin-left:-200px;text-align:center;",
|
||||
"class": "hidden"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"title": "Обновить прошивку устройства",
|
||||
"action": "/check",
|
||||
"response": "[[my-block]]",
|
||||
"class": "btn btn-block btn-default"
|
||||
}
|
||||
]
|
||||
}
|
||||
38
data/set.manual.json
Normal file
38
data/set.manual.json
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"configs": [
|
||||
"/config.setup.json",
|
||||
"/config.option.json",
|
||||
"/config.live.json",
|
||||
"/lang/lang.ru.json"
|
||||
],
|
||||
"class": "col-sm-offset-1 col-sm-10",
|
||||
"content": [
|
||||
{
|
||||
"type": "h5",
|
||||
"title": "{{name}}",
|
||||
"class": "alert-default"
|
||||
},
|
||||
{
|
||||
"type": "link",
|
||||
"title": "{{ButMainPage}}",
|
||||
"action": "/",
|
||||
"class": "btn btn-block btn-default"
|
||||
},
|
||||
{
|
||||
"type": "file",
|
||||
"state": "s.conf.csv",
|
||||
"style": "width:100%;height:350px",
|
||||
"title": "Сохранить",
|
||||
"action": "/set?saveItems",
|
||||
"class": "btn btn-block btn-default"
|
||||
},
|
||||
{
|
||||
"type": "file",
|
||||
"state": "s.scen.txt",
|
||||
"style": "width:100%;height:350px",
|
||||
"title": "Сохранить",
|
||||
"action": "/set?sceninit",
|
||||
"class": "btn btn-block btn-default"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -23,7 +23,7 @@
|
||||
},
|
||||
{
|
||||
"type": "h3",
|
||||
"title": "Сканирование адресов шины i2c"
|
||||
"title": "Сканирование шины i2c"
|
||||
},
|
||||
{
|
||||
"type": "h4",
|
||||
@@ -32,7 +32,7 @@
|
||||
{
|
||||
"type": "link",
|
||||
"title": "Сканировать",
|
||||
"action": "/set?itoc",
|
||||
"action": "/set?i2c",
|
||||
"class": "btn btn-block btn-default"
|
||||
}
|
||||
]
|
||||
|
||||
@@ -28,8 +28,7 @@
|
||||
"type": "input",
|
||||
"title": "{{SetWiFiNameOfDev}}",
|
||||
"name": "devname-arg",
|
||||
"state": "{{name}}",
|
||||
"pattern": "[A-Za-z0-9]{6,12}"
|
||||
"state": "{{name}}"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
|
||||
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": ""
|
||||
}
|
||||
5
data/widgets/anydataHum.json
Normal file
5
data/widgets/anydataHum.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"widget": "anydata",
|
||||
"after": "%",
|
||||
"icon": "water"
|
||||
}
|
||||
5
data/widgets/anydataPress.json
Normal file
5
data/widgets/anydataPress.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"widget": "anydata",
|
||||
"after": "mm",
|
||||
"icon": "speedometer"
|
||||
}
|
||||
5
data/widgets/anydataTemp.json
Normal file
5
data/widgets/anydataTemp.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"widget": "anydata",
|
||||
"after": "°С",
|
||||
"icon": "thermometer"
|
||||
}
|
||||
5
data/widgets/anydataTime.json
Normal file
5
data/widgets/anydataTime.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"widget": "anydata",
|
||||
"after": "",
|
||||
"icon": "speedometer"
|
||||
}
|
||||
6
data/widgets/btn.json
Normal file
6
data/widgets/btn.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"widget": "btn",
|
||||
"size": "large",
|
||||
"color": "green",
|
||||
"send": "test"
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
{
|
||||
"widget": "chart",
|
||||
"series": "Temperature, °C",
|
||||
"dateFormat": "HH:mm"
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"widget" : "select",
|
||||
"size" : "small",
|
||||
"fill" : "outline",
|
||||
"options" : "["Zero item", "First item", "Second item"]",
|
||||
"status" : 2
|
||||
}
|
||||
12
data/widgets/progress-line.json
Normal file
12
data/widgets/progress-line.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"widget": "progress-line",
|
||||
"icon": "sunny",
|
||||
"descrColor": "",
|
||||
"color": "",
|
||||
"max": "100",
|
||||
"background": "",
|
||||
"stroke": "10",
|
||||
"disabled": "",
|
||||
"before": "",
|
||||
"after": ""
|
||||
}
|
||||
11
data/widgets/progress-round.json
Normal file
11
data/widgets/progress-round.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"widget": "progress-round",
|
||||
"descrColor": "",
|
||||
"max": "100",
|
||||
"stroke": "20",
|
||||
"color": "#45ccce",
|
||||
"background": "#777",
|
||||
"before": "",
|
||||
"semicircle": "1",
|
||||
"after": ""
|
||||
}
|
||||
8
data/widgets/select.json
Normal file
8
data/widgets/select.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"widget": "select",
|
||||
"options": [
|
||||
"Выключен",
|
||||
"Включен"
|
||||
],
|
||||
"status": 0
|
||||
}
|
||||
5
data/widgets/toggle.json
Normal file
5
data/widgets/toggle.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"widget": "toggle",
|
||||
"icon": "",
|
||||
"iconOff": ""
|
||||
}
|
||||
5
data/widgets/toggleSunMoon.json
Normal file
5
data/widgets/toggleSunMoon.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"widget": "toggle",
|
||||
"icon": "sunny",
|
||||
"iconOff": "moon"
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"widget" : "anydata",
|
||||
"after" : "",
|
||||
"icon" : ""
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"widget" : "progress-line",
|
||||
"icon" : "sunny",
|
||||
"descrColor" : "",
|
||||
"color" : "",
|
||||
"max" : "100",
|
||||
"background" : "",
|
||||
"stroke" : "10",
|
||||
"disabled" : "",
|
||||
"before" : "",
|
||||
"after" : ""
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
{
|
||||
"widget" : "progress-round",
|
||||
"descrColor" : "",
|
||||
"max" : "100",
|
||||
"stroke" : "20",
|
||||
"color" : "#45ccce",
|
||||
"background": "#777",
|
||||
"before" : "",
|
||||
"semicircle" : "1",
|
||||
"after" : ""
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"widget" : "toggle",
|
||||
"icon" : "",
|
||||
"iconOff" : ""
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"name": "IoTmanager",
|
||||
"chipID": "",
|
||||
"ssidAP": "WiFi",
|
||||
"passwordAP": "",
|
||||
"ssid": "your_ssid",
|
||||
"password": "your_password",
|
||||
"timezone": 3,
|
||||
"ntp": "pool.ntp.org",
|
||||
"mqttServer": "",
|
||||
"mqttPort": 0,
|
||||
"mqttPrefix": "/IoTmanager",
|
||||
"mqttUser": "",
|
||||
"mqttPass": "",
|
||||
"scenario": "1",
|
||||
"pushingbox_id": "",
|
||||
"web_login": "admin",
|
||||
"web_pass": "admin",
|
||||
"udponoff": "1"
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user