mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-04-05 16:49:25 +03:00
Compare commits
100 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
069ba9ae9f | ||
|
|
810f3ca061 | ||
| dd8d173a94 | |||
| 43a8614d8c | |||
| bfabd3965f | |||
|
|
adbe794edd | ||
|
|
c7b649db07 | ||
| 51b137b3cc | |||
| 8f33afec8c | |||
| cc115c701b | |||
|
|
bc765cf3a6 | ||
|
|
4f36adb407 | ||
| f135840ec4 | |||
| f928766de5 | |||
| c87854b2ce | |||
| 0a2c86ccbf | |||
| 2d8de37ee7 | |||
| 2b1cac904b | |||
|
|
e2b0f0e71e | ||
| 56c0ec14fa | |||
| a4e3b9d868 | |||
| 5a029fb159 | |||
| e979711372 | |||
| 46a87ebe26 | |||
|
|
68c9741226 | ||
| 3787959f52 | |||
| bcd6f06e5e | |||
|
|
bf9acf4c63 | ||
|
|
3fab2241aa | ||
| 3f1fbf647a | |||
| ea53d5ccf1 | |||
| 1abe6b20bc | |||
| c2010c4979 | |||
| 044867ca00 | |||
| 9f733a1535 | |||
| d78907d854 | |||
|
|
b2b70a0d9d | ||
| 3dcbd3dafb | |||
|
|
c6d45f5d9a | ||
|
|
f477d5838b | ||
|
|
9b535f04aa | ||
|
|
eb22c713c0 | ||
| 4d36db0755 | |||
| 7e92d57d4d | |||
| 203ceafb19 | |||
| 8509de3efa | |||
|
|
66f21a5001 | ||
|
|
e9032365b4 | ||
|
|
f39b16f787 | ||
|
|
fd09ec9d6b | ||
| cfa8fc4212 | |||
|
|
9ce2cea94a | ||
|
|
b0e06707bd | ||
|
|
cf7599e367 | ||
| da7393e32a | |||
| 87191fa81b | |||
|
|
5b87cedd78 | ||
|
|
5e24d7aec0 | ||
|
|
a4fe4f6c1a | ||
|
|
3d93141e2c | ||
|
|
e9d3750e1b | ||
|
|
03b347b630 | ||
|
|
3fc86fb173 | ||
|
|
9dde5942f0 | ||
|
|
3bb13de0a9 | ||
|
|
f5b5bd78ec | ||
|
|
b68fa1b0f6 | ||
|
|
1529da443b | ||
|
|
8984a8d143 | ||
|
|
93a6a24254 | ||
|
|
d2a375dc9e | ||
|
|
acf9e2bd5d | ||
| 4a946ff3eb | |||
|
|
9c1604e9cc | ||
|
|
bc8f683c79 | ||
|
|
65c1449cde | ||
|
|
1a88298fd4 | ||
|
|
fbb5ba7e64 | ||
|
|
ca9444bbd9 | ||
|
|
e9f36e7d20 | ||
|
|
32350ddaf1 | ||
|
|
d083fbf9cf | ||
|
|
e46a6247f9 | ||
|
|
b125986fb3 | ||
|
|
a020c09928 | ||
|
|
7c423ddea6 | ||
|
|
f28bafa277 | ||
|
|
35923eca7d | ||
|
|
495488a52f | ||
| 96b80dfd28 | |||
|
|
b8f2cb2716 | ||
|
|
bb5eed987e | ||
| 2b1ab1df50 | |||
| f668b5783e | |||
| 70d2926f55 | |||
| f1c573b882 | |||
| de2075664b | |||
| 55ee70849f | |||
| 725cf26d41 | |||
| 7e5b611c23 |
5
.vscode/settings.json
vendored
Normal file
5
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"array": "cpp"
|
||||
}
|
||||
}
|
||||
@@ -1,37 +1,37 @@
|
||||
{
|
||||
"name": "IoTmanager",
|
||||
"chipID": "",
|
||||
"apssid": "IoTmanager",
|
||||
"appass": "",
|
||||
"routerssid": "XChangeWIFI",
|
||||
"routerpass": "XCh@WIFI",
|
||||
"timezone": 1,
|
||||
"ntp": "pool.ntp.org",
|
||||
"mqttServer": "91.204.228.124",
|
||||
"mqttPort": 1883,
|
||||
"mqttPrefix": "/iotTest3",
|
||||
"mqttUser": "rise",
|
||||
"mqttPass": "23ri22se32",
|
||||
"mqttServer2": "M2.WQTT.RU",
|
||||
"mqttPort2": 8021,
|
||||
"mqttPrefix2": "/iotTest3",
|
||||
"mqttUser2": "rise",
|
||||
"mqttPass2": "hostel3333",
|
||||
"scen": "1",
|
||||
"telegramApi": "1416711569:AAEI0j83GmXqwzb_gnK1B0Am0gDwZoJt5xo",
|
||||
"telegonof": "0",
|
||||
"teleginput": "0",
|
||||
"autos": "1",
|
||||
"weblogin": "admin",
|
||||
"webpass": "admin",
|
||||
"MqttIn": "0",
|
||||
"MqttOut": "0",
|
||||
"blink": "0",
|
||||
"oneWirePin": "2",
|
||||
"serverip": "http://206.189.49.244",
|
||||
"uart": "0",
|
||||
"uartS": "9600",
|
||||
"uartTX": "12",
|
||||
"uartRX": "13",
|
||||
"grafmax": "0"
|
||||
"name": "IoTmanager",
|
||||
"chipID": "",
|
||||
"apssid": "IoTmanager",
|
||||
"appass": "",
|
||||
"routerssid": "rise",
|
||||
"routerpass": "hostel3333",
|
||||
"timezone": 3,
|
||||
"ntp": "pool.ntp.org",
|
||||
"mqttServer": "live-control.ru",
|
||||
"mqttPort": 1883,
|
||||
"mqttPrefix": "/IotManager",
|
||||
"mqttUser": "IotManager:guest",
|
||||
"mqttPass": "guest",
|
||||
"mqttServer2": "",
|
||||
"mqttPort2": 0,
|
||||
"mqttPrefix2": "",
|
||||
"mqttUser2": "",
|
||||
"mqttPass2": "",
|
||||
"scen": "1",
|
||||
"telegramApi": "",
|
||||
"telegonof": "0",
|
||||
"teleginput": "0",
|
||||
"autos": "1",
|
||||
"weblogin": "admin",
|
||||
"webpass": "admin",
|
||||
"MqttIn": "0",
|
||||
"MqttOut": "0",
|
||||
"blink": "0",
|
||||
"oneWirePin": "2",
|
||||
"serverip": "http://206.189.49.244",
|
||||
"uart": "0",
|
||||
"uartS": "9600",
|
||||
"uartTX": "12",
|
||||
"uartRX": "13",
|
||||
"grafmax": "0"
|
||||
}
|
||||
1
data_esp/dashboard/build/bundle.css
Normal file
1
data_esp/dashboard/build/bundle.css
Normal file
File diff suppressed because one or more lines are too long
BIN
data_esp/dashboard/build/bundle.js.gz
Normal file
BIN
data_esp/dashboard/build/bundle.js.gz
Normal file
Binary file not shown.
63
data_esp/dashboard/global.css
Normal file
63
data_esp/dashboard/global.css
Normal file
@@ -0,0 +1,63 @@
|
||||
html, body {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
color: #333;
|
||||
margin: 0;
|
||||
padding: 8px;
|
||||
box-sizing: border-box;
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
|
||||
}
|
||||
|
||||
a {
|
||||
color: rgb(0,100,200);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
a:visited {
|
||||
color: rgb(0,80,160);
|
||||
}
|
||||
|
||||
label {
|
||||
display: block;
|
||||
}
|
||||
|
||||
input, button, select, textarea {
|
||||
font-family: inherit;
|
||||
font-size: inherit;
|
||||
-webkit-padding: 0.4em 0;
|
||||
padding: 0.4em;
|
||||
margin: 0 0 0.5em 0;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
input:disabled {
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
button {
|
||||
color: #333;
|
||||
background-color: #f4f4f4;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
button:disabled {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
button:not(:disabled):active {
|
||||
background-color: #ddd;
|
||||
}
|
||||
|
||||
button:focus {
|
||||
border-color: #666;
|
||||
}
|
||||
104
data_esp/dashboard/index.html
Normal file
104
data_esp/dashboard/index.html
Normal file
@@ -0,0 +1,104 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
||||
|
||||
<title>LiveControl v 0.3.2</title>
|
||||
|
||||
<link rel="icon" type="image/png" href="/favicon.ico" />
|
||||
<link rel="stylesheet" href="/dashboard/global.css" />
|
||||
<link rel="stylesheet" href="/dashboard/build/bundle.css" />
|
||||
|
||||
<script defer src="/dashboard/build/bundle.js" onload="loadPage()"></script>
|
||||
<script>
|
||||
function get_cookie ( cookie_name ){
|
||||
var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );
|
||||
if ( results )
|
||||
return ( unescape ( results[2] ) );
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
if (get_cookie("darktheme") == "true"){
|
||||
var myColor = "#1d3040";
|
||||
document.write('\
|
||||
<style>\
|
||||
body{\
|
||||
background-color: '+myColor+';\
|
||||
}\
|
||||
</style>\
|
||||
');
|
||||
}
|
||||
|
||||
function loadPage() {
|
||||
document.getElementById("status").style.display = "none";
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<style>
|
||||
|
||||
.rotate-shadows {
|
||||
width: 220px;
|
||||
height: 220px;
|
||||
margin:0 auto;
|
||||
position: relative;
|
||||
}
|
||||
.rotate-shadows:after,
|
||||
.rotate-shadows:before {
|
||||
content: "";
|
||||
border-radius: 150%;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
transform-origin: center center;
|
||||
}
|
||||
.rotate-shadows:before {
|
||||
box-shadow: inset 0 20px 0 rgba(0, 250, 250, 0.2),
|
||||
inset 20px 0 0 rgba(0, 200, 200, 0.2),
|
||||
inset 0 -20px 0 rgba(0, 150, 200, 0.2),
|
||||
inset -20px 0 0 rgba(0, 200, 250, 0.2);
|
||||
animation: rotate-before 9s -0.5s linear infinite;
|
||||
}
|
||||
.rotate-shadows:after {
|
||||
box-shadow: inset 0 20px 0 rgba(250, 250, 0, 0.2),
|
||||
inset 20px 0 0 rgba(250, 200, 0, 0.2),
|
||||
inset 0 -20px 0 rgba(250, 150, 0, 0.2),
|
||||
inset -20px 0 0 rgba(250, 100, 0, 0.2);
|
||||
animation: rotate-after 9s -0.5s linear infinite;
|
||||
}
|
||||
@keyframes rotate-after {
|
||||
0% {
|
||||
transform: rotateZ(0deg) scaleX(1) scaleY(1);
|
||||
}
|
||||
50% {
|
||||
transform: rotateZ(180deg) scaleX(0.82) scaleY(0.95);
|
||||
}
|
||||
100% {
|
||||
transform: rotateZ(360deg) scaleX(1) scaleY(1);
|
||||
}
|
||||
}
|
||||
@keyframes rotate-before {
|
||||
0% {
|
||||
transform: rotateZ(0deg) scaleX(1) scaleY(1);
|
||||
}
|
||||
50% {
|
||||
transform: rotateZ(-180deg) scaleX(0.95) scaleY(0.85);
|
||||
}
|
||||
100% {
|
||||
transform: rotateZ(-360deg) scaleX(1) scaleY(1);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<p><div id="status" class="rotate-shadows"></div></p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Binary file not shown.
Binary file not shown.
@@ -31,4 +31,13 @@
|
||||
0;output-value;txtid;anydata;Вывод;Температура;order*
|
||||
0;logging;crtid;chart;Графики;История;order;val[any];int[60];cnt[100]*
|
||||
0;logging;crtid;chart3;Графики;История;order;val[any];int[23:30];cnt[100];st[0]*
|
||||
0;uptime;uptid;anydataTime;Системные;%name%#uptime;order;int[60]*
|
||||
0;uptime;uptid;anydataTime;Системные;%name%#uptime;order;int[60]*
|
||||
0;sht20;tmpid;anydataTemp;Сенсоры;Температура;1;c[1]
|
||||
0;sht20;humid;anydataHum;Сенсоры;Влажность;2;c[1];int[50]*
|
||||
0;sensor;anyid;anydata;Сенсоры;Параметр;1;c[1];int[10];type[HDC1080_temp];addr[0x76]
|
||||
0;sensor;anyid;anydata;Сенсоры;Параметр;1;c[1];int[10];type[HDC1080_hum];addr[0x76]*
|
||||
0;sensor;anyid;anydata;Сенсоры;Параметр;1;c[1];int[10];type[AHTX0_temp];addr[0x76]
|
||||
0;sensor;anyid;anydata;Сенсоры;Параметр;1;c[1];int[10];type[AHTX0_hum];addr[0x76]*
|
||||
0;LCD2004;lcdid;na;na;IP;1;addr[0x27];k[16,2];int[10];c[0,0];val[ip]*
|
||||
0;TM1637;dispid;na;na;f;1;pin[12,13];int[10];c[4];k[0];val[1234]*
|
||||
0;sensor;anyid;anydata;Сенсоры;Параметр;1;c[1];int[10];type[type1];addr[0x76]*
|
||||
@@ -83,7 +83,7 @@ start = 0
|
||||
cnt71 0
|
||||
cnt72 0
|
||||
end*
|
||||
sens8 = 1 && on8b = 1
|
||||
sens8 = 1 && on8 = 1
|
||||
txt81 обнаружено
|
||||
txt82 %date%
|
||||
telegram often Обнаружено#движение
|
||||
|
||||
@@ -1 +1,5 @@
|
||||
Удалить;Тип элемента;Id;Виджет;Имя вкладки;Имя виджета;Позиция виджета
|
||||
Удалить;Тип элемента;Id;Виджет;Имя вкладки;Имя виджета;Позиция виджета
|
||||
0;uptime;upt;anydataTime;IoTManager;%name%#uptime;8;int[60]
|
||||
0;output-value;ip;anydata;IoTManager;IP;9
|
||||
0;output-value;time;anydata;IoTManager;Время#на#устройстве;10
|
||||
0;output-value;weekday;anydata;IoTManager;День#недели#на#устройстве ;11
|
||||
|
@@ -1 +1,5 @@
|
||||
//
|
||||
timenow > 0
|
||||
weekday %weekday%
|
||||
ip %IP%
|
||||
time %date%
|
||||
end
|
||||
Binary file not shown.
1
data_esp/setup/build/bundle.css
Normal file
1
data_esp/setup/build/bundle.css
Normal file
@@ -0,0 +1 @@
|
||||
.letter.svelte-1ls9om6{color:grey;font-size:60%;padding-left:0px;opacity:0.5}table.svelte-1ls9om6{margin:0px;background-color:#fafafa;line-height:1}td.svelte-1ls9om6{text-align:left;padding-left:1px}input[type="text"].svelte-1ls9om6{width:100%;padding:10px;border:1;box-shadow:0 0 15px 10px rgba(0, 0, 0, 0.06);border-radius:1px}.letter1.svelte-1ls9om6{color:grey;font-size:80%;padding-left:20px}.letter2.svelte-1ls9om6{text-align:left;padding-left:0px}select.svelte-1ls9om6{padding:10px;border-radius:10px;padding-left:20px;height:40px;font-size:13px}input[type="password"].svelte-1ls9om6{width:100%;padding:10px;border:1;box-shadow:0 0 15px 10px rgba(0, 0, 0, 0.06);border-radius:1px}input.svelte-1ls9om6:required:invalid:not(:placeholder-shown){border-color:crimson}.red.svelte-1ls9om6{border-color:crimson}progress.svelte-1ls9om6{height:4px}textarea.svelte-1ls9om6{width:100%}button.svelte-1ls9om6{height:30px;border-radius:4px;line-height:0}body.light-mode{background-color:white}body.dark-mode{background-color:#1d3040;color:#bfc2c7}body.dark-mode textarea.svelte-1ls9om6{background-color:#1d3040;color:#bfc2c7}body.dark-mode input.svelte-1ls9om6{background-color:#1d3040;color:#bfc2c7}body.dark-mode select.svelte-1ls9om6{background-color:#1d3040;color:#bfc2c7}body.dark-mode button.svelte-1ls9om6{background-color:#1d3040;color:#bfc2c7}body.dark-mode div.svelte-1ls9om6{background-color:#1d3040;color:#bfc2c7}body.dark-mode span.svelte-1ls9om6{background-color:#1d3040;color:#bfc2c7}.Shutter.svelte-1ls9om6{background-color:hsl(200, 16%, 96%);color:blak;padding:10px;border-radius:5px}body.dark-mode .Shutter.svelte-1ls9om6{background-color:#1d3040;color:#bfc2c7;padding:10px;border-radius:5px}body.dark-mode table.svelte-1ls9om6{background-color:#1d3040;color:#bfc2c7}body.dark-mode .letter1.svelte-1ls9om6{color:#bfc2c7}body.dark-mode .letter2.svelte-1ls9om6{color:#bfc2c7}body.dark-mode b.svelte-1ls9om6{color:#bfc2c7}body.dark-mode button.svelte-1ls9om6{background-color:#1d3040;color:#bfc2c7}h5.svelte-1ls9om6{display:inline}.box.svelte-hp9es9{width:93%;border:1px solid #aaa;border-radius:10px;box-shadow:10px 10px 8px rgba(0, 0, 0, 0.1);padding:1em;margin:0 0 1em 0}.tooltip.svelte-1vepdvs{border:1px solid #ddd;box-shadow:1px 1px 1px #ddd;background:rgb(185, 238, 241);border-radius:4px;padding:4px;position:absolute;color:black}.modal-background.svelte-10j5cq5{position:fixed;top:0;left:0;width:100%;height:100%;background:gray;opacity:0.8}.modal.svelte-10j5cq5{position:absolute;left:50%;top:50%;width:calc(100vw - 4em);max-width:32em;max-height:calc(100vh - 4em);overflow:auto;transform:translate(-50%, -50%);padding:1em;border-radius:0.2em;background:white}button.svelte-10j5cq5{display:block}.rotate-shadows.svelte-tks6xu{width:220px;height:220px;position:relative}.rotate-shadows.svelte-tks6xu:after,.rotate-shadows.svelte-tks6xu:before{content:"";border-radius:150%;position:absolute;top:0;left:0;width:100%;height:100%;transform-origin:center center}.rotate-shadows.svelte-tks6xu:before{box-shadow:inset 0 20px 0 rgba(0, 250, 250, 0.2), inset 20px 0 0 rgba(0, 200, 200, 0.2), inset 0 -20px 0 rgba(0, 150, 200, 0.2), inset -20px 0 0 rgba(0, 200, 250, 0.2);animation:svelte-tks6xu-rotate-before 9s -0.5s linear infinite}.rotate-shadows.svelte-tks6xu:after{box-shadow:inset 0 20px 0 rgba(250, 250, 0, 0.2), inset 20px 0 0 rgba(250, 200, 0, 0.2), inset 0 -20px 0 rgba(250, 150, 0, 0.2), inset -20px 0 0 rgba(250, 100, 0, 0.2);animation:svelte-tks6xu-rotate-after 9s -0.5s linear infinite}@keyframes svelte-tks6xu-rotate-after{0%{transform:rotateZ(0deg) scaleX(1) scaleY(1)}50%{transform:rotateZ(180deg) scaleX(0.82) scaleY(0.95)}100%{transform:rotateZ(360deg) scaleX(1) scaleY(1)}}@keyframes svelte-tks6xu-rotate-before{0%{transform:rotateZ(0deg) scaleX(1) scaleY(1)}50%{transform:rotateZ(-180deg) scaleX(0.95) scaleY(0.85)}100%{transform:rotateZ(-360deg) scaleX(1) scaleY(1)}}
|
||||
BIN
data_esp/setup/build/bundle.js.gz
Normal file
BIN
data_esp/setup/build/bundle.js.gz
Normal file
Binary file not shown.
63
data_esp/setup/global.css
Normal file
63
data_esp/setup/global.css
Normal file
@@ -0,0 +1,63 @@
|
||||
html, body {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
color: #333;
|
||||
margin: 0;
|
||||
padding: 8px;
|
||||
box-sizing: border-box;
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
|
||||
}
|
||||
|
||||
a {
|
||||
color: rgb(0,100,200);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
a:visited {
|
||||
color: rgb(0,80,160);
|
||||
}
|
||||
|
||||
label {
|
||||
display: block;
|
||||
}
|
||||
|
||||
input, button, select, textarea {
|
||||
font-family: inherit;
|
||||
font-size: inherit;
|
||||
-webkit-padding: 0.4em 0;
|
||||
padding: 0.4em;
|
||||
margin: 0 0 0.5em 0;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
input:disabled {
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
button {
|
||||
color: #333;
|
||||
background-color: #f4f4f4;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
button:disabled {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
button:not(:disabled):active {
|
||||
background-color: #ddd;
|
||||
}
|
||||
|
||||
button:focus {
|
||||
border-color: #666;
|
||||
}
|
||||
103
data_esp/setup/index.html
Normal file
103
data_esp/setup/index.html
Normal file
@@ -0,0 +1,103 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
||||
|
||||
<title>IotManager v 0.3.2</title>
|
||||
|
||||
<link rel="icon" type="image/png" href="/favicon.ico" />
|
||||
<link rel="stylesheet" href="/setup/global.css" />
|
||||
<link rel="stylesheet" href="/setup/build/bundle.css?0.3" />
|
||||
|
||||
<script defer src="/setup/build/bundle.js?0.3" onload="loadPage()"></script>
|
||||
<script>
|
||||
function get_cookie ( cookie_name ){
|
||||
var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );
|
||||
if ( results )
|
||||
return ( unescape ( results[2] ) );
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
if (get_cookie("darktheme") == "true"){
|
||||
var myColor = "#1d3040";
|
||||
document.write('\
|
||||
<style>\
|
||||
body{\
|
||||
background-color: '+myColor+';\
|
||||
}\
|
||||
</style>\
|
||||
');
|
||||
}
|
||||
|
||||
function loadPage() {
|
||||
document.getElementById("status").style.display = "none";
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
.rotate-shadows {
|
||||
width: 220px;
|
||||
height: 220px;
|
||||
margin:0 auto;
|
||||
position: relative;
|
||||
}
|
||||
.rotate-shadows:after,
|
||||
.rotate-shadows:before {
|
||||
content: "";
|
||||
border-radius: 150%;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
transform-origin: center center;
|
||||
}
|
||||
.rotate-shadows:before {
|
||||
box-shadow: inset 0 20px 0 rgba(0, 250, 250, 0.2),
|
||||
inset 20px 0 0 rgba(0, 200, 200, 0.2),
|
||||
inset 0 -20px 0 rgba(0, 150, 200, 0.2),
|
||||
inset -20px 0 0 rgba(0, 200, 250, 0.2);
|
||||
animation: rotate-before 9s -0.5s linear infinite;
|
||||
}
|
||||
.rotate-shadows:after {
|
||||
box-shadow: inset 0 20px 0 rgba(250, 250, 0, 0.2),
|
||||
inset 20px 0 0 rgba(250, 200, 0, 0.2),
|
||||
inset 0 -20px 0 rgba(250, 150, 0, 0.2),
|
||||
inset -20px 0 0 rgba(250, 100, 0, 0.2);
|
||||
animation: rotate-after 9s -0.5s linear infinite;
|
||||
}
|
||||
@keyframes rotate-after {
|
||||
0% {
|
||||
transform: rotateZ(0deg) scaleX(1) scaleY(1);
|
||||
}
|
||||
50% {
|
||||
transform: rotateZ(180deg) scaleX(0.82) scaleY(0.95);
|
||||
}
|
||||
100% {
|
||||
transform: rotateZ(360deg) scaleX(1) scaleY(1);
|
||||
}
|
||||
}
|
||||
@keyframes rotate-before {
|
||||
0% {
|
||||
transform: rotateZ(0deg) scaleX(1) scaleY(1);
|
||||
}
|
||||
50% {
|
||||
transform: rotateZ(-180deg) scaleX(0.95) scaleY(0.85);
|
||||
}
|
||||
100% {
|
||||
transform: rotateZ(-360deg) scaleX(1) scaleY(1);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<p><div id="status" class="rotate-shadows"></div></p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
BIN
data_esp/setup/progress.gif
Normal file
BIN
data_esp/setup/progress.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.0 KiB |
@@ -1,34 +1,35 @@
|
||||
{
|
||||
"undef": "Ошибка",
|
||||
"toggleBtn": "Кнопка переключатель",
|
||||
"range": "Ползунок",
|
||||
"inputDate": "Окно ввода даты",
|
||||
"inputTime": "Окно ввода времени 1",
|
||||
"inputTimeClock": "Окно ввода времени 2",
|
||||
"inputDigit": "Окно ввода цифры",
|
||||
"inputDigitTemp": "Окно ввода температуры",
|
||||
"inputText": "Окно ввода текста",
|
||||
"select": "Выпадающий список",
|
||||
"chart": "График без точек",
|
||||
"chart2": "График с точками",
|
||||
"chart3": "График дневного расхода (столбики)",
|
||||
"chart4": "График дневного расхода (плавный)",
|
||||
"fillgauge": "Бочка",
|
||||
"progress-line": "Линия",
|
||||
"progress-round": "Круг",
|
||||
"anydata": "Текст",
|
||||
"anydataHum": "Влажность (%)",
|
||||
"anydataPress": "Давление (mm)",
|
||||
"anydataTemp": "Температура (°С)",
|
||||
"anydataPpb": "Части на миллиард (ppb)",
|
||||
"anydataPpm": "Части на миллион (ppm)",
|
||||
"anydataVlt": "Напряжение (Vlt)",
|
||||
"anydataAmp": "Сила тока (Amp)",
|
||||
"anydataWtt": "Мощность (Wtt)",
|
||||
"anydataWhr": "Энергия (Whr)",
|
||||
"anydataHtz": "Частота (Htz)",
|
||||
"anydataTime": "Манометр",
|
||||
"alarm": "Тревожное сообщение 1",
|
||||
"anydataAlarm": "Тревожное сообщение 2",
|
||||
"na": "Без виджета"
|
||||
}
|
||||
{
|
||||
"undef": "Ошибка",
|
||||
"toggleBtn": "Переключатель",
|
||||
"btn": "Кнопка",
|
||||
"select": "Кнопка переключатель",
|
||||
"range": "Ползунок",
|
||||
"inputDate": "Окно ввода даты",
|
||||
"inputTime": "Окно ввода времени 1",
|
||||
"inputTimeClock": "Окно ввода времени 2",
|
||||
"inputDigit": "Окно ввода цифры",
|
||||
"inputDigitTemp": "Окно ввода температуры",
|
||||
"inputText": "Окно ввода текста",
|
||||
"chart": "График без точек",
|
||||
"chart2": "График с точками",
|
||||
"chart3": "График дневного расхода (столбики)",
|
||||
"chart4": "График дневного расхода (плавный)",
|
||||
"fillgauge": "Бочка",
|
||||
"progress-line": "Линия",
|
||||
"progress-round": "Круг",
|
||||
"anydata": "Текст",
|
||||
"anydataHum": "Влажность (%)",
|
||||
"anydataPress": "Давление (mm)",
|
||||
"anydataTemp": "Температура (°С)",
|
||||
"anydataPpb": "Части на миллиард (ppb)",
|
||||
"anydataPpm": "Части на миллион (ppm)",
|
||||
"anydataVlt": "Напряжение (Vlt)",
|
||||
"anydataAmp": "Сила тока (Amp)",
|
||||
"anydataWtt": "Мощность (Wtt)",
|
||||
"anydataWhr": "Энергия (Whr)",
|
||||
"anydataHtz": "Частота (Htz)",
|
||||
"anydataTime": "Манометр",
|
||||
"alarm": "Тревожное сообщение 1",
|
||||
"anydataAlarm": "Тревожное сообщение 2",
|
||||
"na": "Без виджета"
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"widget": "anydata",
|
||||
"after": "%",
|
||||
"icon": "water"
|
||||
}
|
||||
"icon": "water",
|
||||
"color": "#88AADF"
|
||||
}
|
||||
|
||||
@@ -1,5 +1,16 @@
|
||||
{
|
||||
"widget": "anydata",
|
||||
"after": "°С",
|
||||
"icon": "thermometer"
|
||||
}
|
||||
"icon": "thermometer",
|
||||
"font": "OCR A Std",
|
||||
"color": [
|
||||
{ "level": -20, "value": "#0000CC" },
|
||||
{ "level": -10, "value": "#0000CC" },
|
||||
{ "level": 0, "value": "#0000CC" },
|
||||
{ "level": 12, "value": "#3366FF" },
|
||||
{ "level": 16, "value": "#33CCFF" },
|
||||
{ "level": 18, "value": "#009933" },
|
||||
{ "level": 30, "value": "#FF9900" },
|
||||
{ "level": 40, "value": "red" }
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,38 +1,37 @@
|
||||
{
|
||||
"name": "IoTmanager",
|
||||
"chipID": "",
|
||||
"apssid": "IoTmanager",
|
||||
"appass": "",
|
||||
"routerssid": "rise2",
|
||||
"routerpass": "hostel3333",
|
||||
"timezone": 1,
|
||||
"ntp": "pool.ntp.org",
|
||||
"mqttServer": "91.204.228.124",
|
||||
"mqttPort": 1883,
|
||||
"mqttPrefix": "/iotTest4",
|
||||
"mqttUser": "rise",
|
||||
"mqttPass": "23ri22se32",
|
||||
"mqttServer2": "",
|
||||
"mqttPort2": 0,
|
||||
"mqttPrefix2": "",
|
||||
"mqttUser2": "",
|
||||
"mqttPass2": "",
|
||||
"scen": "1",
|
||||
"telegramApi": "1416711569:AAEI0j83GmXqwzb_gnK1B0Am0gDwZoJt5xo",
|
||||
"telegonof": "0",
|
||||
"teleginput": "0",
|
||||
"autos": "1",
|
||||
"weblogin": "admin",
|
||||
"webpass": "admin",
|
||||
"MqttIn": "0",
|
||||
"MqttOut": "0",
|
||||
"blink": "0",
|
||||
"oneWirePin": "2",
|
||||
"serverip": "http://206.189.49.244",
|
||||
"uart": "0",
|
||||
"uartS": "9600",
|
||||
"uartTX": "12",
|
||||
"uartRX": "13",
|
||||
"grafmax": "0",
|
||||
"gateAuto": "0"
|
||||
}
|
||||
"name": "IoTmanager",
|
||||
"chipID": "",
|
||||
"apssid": "IoTmanager",
|
||||
"appass": "",
|
||||
"routerssid": "Mikro",
|
||||
"routerpass": "4455667788",
|
||||
"timezone": 3,
|
||||
"ntp": "pool.ntp.org",
|
||||
"mqttServer": "live-control.ru",
|
||||
"mqttPort": 1883,
|
||||
"mqttPrefix": "/IotManager",
|
||||
"mqttUser": "IotManager:guest",
|
||||
"mqttPass": "guest",
|
||||
"mqttServer2": "",
|
||||
"mqttPort2": 0,
|
||||
"mqttPrefix2": "",
|
||||
"mqttUser2": "",
|
||||
"mqttPass2": "",
|
||||
"scen": "1",
|
||||
"telegramApi": "",
|
||||
"telegonof": "0",
|
||||
"teleginput": "0",
|
||||
"autos": "1",
|
||||
"weblogin": "admin",
|
||||
"webpass": "admin",
|
||||
"MqttIn": "0",
|
||||
"MqttOut": "0",
|
||||
"blink": "0",
|
||||
"oneWirePin": "2",
|
||||
"serverip": "http://206.189.49.244",
|
||||
"uart": "0",
|
||||
"uartS": "9600",
|
||||
"uartTX": "12",
|
||||
"uartRX": "13",
|
||||
"grafmax": "0"
|
||||
}
|
||||
|
||||
1
data_ms/dashboard/build/bundle.css
Normal file
1
data_ms/dashboard/build/bundle.css
Normal file
File diff suppressed because one or more lines are too long
BIN
data_ms/dashboard/build/bundle.js.gz
Normal file
BIN
data_ms/dashboard/build/bundle.js.gz
Normal file
Binary file not shown.
63
data_ms/dashboard/global.css
Normal file
63
data_ms/dashboard/global.css
Normal file
@@ -0,0 +1,63 @@
|
||||
html, body {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
color: #333;
|
||||
margin: 0;
|
||||
padding: 8px;
|
||||
box-sizing: border-box;
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
|
||||
}
|
||||
|
||||
a {
|
||||
color: rgb(0,100,200);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
a:visited {
|
||||
color: rgb(0,80,160);
|
||||
}
|
||||
|
||||
label {
|
||||
display: block;
|
||||
}
|
||||
|
||||
input, button, select, textarea {
|
||||
font-family: inherit;
|
||||
font-size: inherit;
|
||||
-webkit-padding: 0.4em 0;
|
||||
padding: 0.4em;
|
||||
margin: 0 0 0.5em 0;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
input:disabled {
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
button {
|
||||
color: #333;
|
||||
background-color: #f4f4f4;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
button:disabled {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
button:not(:disabled):active {
|
||||
background-color: #ddd;
|
||||
}
|
||||
|
||||
button:focus {
|
||||
border-color: #666;
|
||||
}
|
||||
104
data_ms/dashboard/index.html
Normal file
104
data_ms/dashboard/index.html
Normal file
@@ -0,0 +1,104 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
||||
|
||||
<title>LiveControl v 0.3.2</title>
|
||||
|
||||
<link rel="icon" type="image/png" href="/favicon.ico" />
|
||||
<link rel="stylesheet" href="/dashboard/global.css" />
|
||||
<link rel="stylesheet" href="/dashboard/build/bundle.css" />
|
||||
|
||||
<script defer src="/dashboard/build/bundle.js" onload="loadPage()"></script>
|
||||
<script>
|
||||
function get_cookie ( cookie_name ){
|
||||
var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );
|
||||
if ( results )
|
||||
return ( unescape ( results[2] ) );
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
if (get_cookie("darktheme") == "true"){
|
||||
var myColor = "#1d3040";
|
||||
document.write('\
|
||||
<style>\
|
||||
body{\
|
||||
background-color: '+myColor+';\
|
||||
}\
|
||||
</style>\
|
||||
');
|
||||
}
|
||||
|
||||
function loadPage() {
|
||||
document.getElementById("status").style.display = "none";
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<style>
|
||||
|
||||
.rotate-shadows {
|
||||
width: 220px;
|
||||
height: 220px;
|
||||
margin:0 auto;
|
||||
position: relative;
|
||||
}
|
||||
.rotate-shadows:after,
|
||||
.rotate-shadows:before {
|
||||
content: "";
|
||||
border-radius: 150%;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
transform-origin: center center;
|
||||
}
|
||||
.rotate-shadows:before {
|
||||
box-shadow: inset 0 20px 0 rgba(0, 250, 250, 0.2),
|
||||
inset 20px 0 0 rgba(0, 200, 200, 0.2),
|
||||
inset 0 -20px 0 rgba(0, 150, 200, 0.2),
|
||||
inset -20px 0 0 rgba(0, 200, 250, 0.2);
|
||||
animation: rotate-before 9s -0.5s linear infinite;
|
||||
}
|
||||
.rotate-shadows:after {
|
||||
box-shadow: inset 0 20px 0 rgba(250, 250, 0, 0.2),
|
||||
inset 20px 0 0 rgba(250, 200, 0, 0.2),
|
||||
inset 0 -20px 0 rgba(250, 150, 0, 0.2),
|
||||
inset -20px 0 0 rgba(250, 100, 0, 0.2);
|
||||
animation: rotate-after 9s -0.5s linear infinite;
|
||||
}
|
||||
@keyframes rotate-after {
|
||||
0% {
|
||||
transform: rotateZ(0deg) scaleX(1) scaleY(1);
|
||||
}
|
||||
50% {
|
||||
transform: rotateZ(180deg) scaleX(0.82) scaleY(0.95);
|
||||
}
|
||||
100% {
|
||||
transform: rotateZ(360deg) scaleX(1) scaleY(1);
|
||||
}
|
||||
}
|
||||
@keyframes rotate-before {
|
||||
0% {
|
||||
transform: rotateZ(0deg) scaleX(1) scaleY(1);
|
||||
}
|
||||
50% {
|
||||
transform: rotateZ(-180deg) scaleX(0.95) scaleY(0.85);
|
||||
}
|
||||
100% {
|
||||
transform: rotateZ(-360deg) scaleX(1) scaleY(1);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<p><div id="status" class="rotate-shadows"></div></p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Binary file not shown.
@@ -1,10 +1,11 @@
|
||||
0;button-out;btnid;toggleBtn;Кнопки;Освещение;order*
|
||||
0;button-out;100-0;toggleBtn;Кнопки;Освещение;order;type[ms]*
|
||||
0;input;dgtid;inputDigit;Ввод;Введите#цифру;order*
|
||||
0;input-value;dgtid;inputDigit;Ввод;Введите#цифру;order*
|
||||
0;input;tmid;inputTime;Ввод;Введите#время;order*
|
||||
0;output;txtid;anydata;Вывод;Сигнализация;order*
|
||||
0;count-down;cntid;anydata;Таймер;Обратный#отчет;order*
|
||||
0;sensor-node;100-0;anydataTemp;MySensors;Температура;order;tm1[30];tm2[60];c[1];k[0]*
|
||||
0;logging;crtid;chart;Графики;История;order;val[any];int[60];cnt[100]*
|
||||
0;logging;crtid;chart3;Графики;История;order;val[any];int[23:30];cnt[100];st[0]*
|
||||
0;uptime;uptid;anydataTime;Системные;%name%#uptime;order;int[60]*
|
||||
0;uptime;uptid;anydataTime;Системные;%name%#uptime;order;int[60]*
|
||||
0;LCD2004;lcdid;anydata;Вывод;IP;1;addr[0x27];k[20,4];int[10];c[0,0];val[ip]*
|
||||
@@ -1 +1,5 @@
|
||||
Удалить;Тип элемента;Id;Виджет;Имя вкладки;Имя виджета;Позиция виджета
|
||||
Удалить;Тип элемента;Id;Виджет;Имя вкладки;Имя виджета;Позиция виджета
|
||||
0;uptime;upt;anydataTime;IoTManager;%name%#uptime;8;int[60]
|
||||
0;output-value;ip;anydata;IoTManager;IP;9
|
||||
0;output-value;time;anydata;IoTManager;Время#на#устройстве;10
|
||||
0;output-value;weekday;anydata;IoTManager;День#недели#на#устройстве ;11
|
||||
|
@@ -1 +1,5 @@
|
||||
//
|
||||
timenow > 0
|
||||
weekday %weekday%
|
||||
ip %IP%
|
||||
time %date%
|
||||
end
|
||||
Binary file not shown.
1
data_ms/setup/build/bundle.css
Normal file
1
data_ms/setup/build/bundle.css
Normal file
@@ -0,0 +1 @@
|
||||
.letter.svelte-1ls9om6{color:grey;font-size:60%;padding-left:0px;opacity:0.5}table.svelte-1ls9om6{margin:0px;background-color:#fafafa;line-height:1}td.svelte-1ls9om6{text-align:left;padding-left:1px}input[type="text"].svelte-1ls9om6{width:100%;padding:10px;border:1;box-shadow:0 0 15px 10px rgba(0, 0, 0, 0.06);border-radius:1px}.letter1.svelte-1ls9om6{color:grey;font-size:80%;padding-left:20px}.letter2.svelte-1ls9om6{text-align:left;padding-left:0px}select.svelte-1ls9om6{padding:10px;border-radius:10px;padding-left:20px;height:40px;font-size:13px}input[type="password"].svelte-1ls9om6{width:100%;padding:10px;border:1;box-shadow:0 0 15px 10px rgba(0, 0, 0, 0.06);border-radius:1px}input.svelte-1ls9om6:required:invalid:not(:placeholder-shown){border-color:crimson}.red.svelte-1ls9om6{border-color:crimson}progress.svelte-1ls9om6{height:4px}textarea.svelte-1ls9om6{width:100%}button.svelte-1ls9om6{height:30px;border-radius:4px;line-height:0}body.light-mode{background-color:white}body.dark-mode{background-color:#1d3040;color:#bfc2c7}body.dark-mode textarea.svelte-1ls9om6{background-color:#1d3040;color:#bfc2c7}body.dark-mode input.svelte-1ls9om6{background-color:#1d3040;color:#bfc2c7}body.dark-mode select.svelte-1ls9om6{background-color:#1d3040;color:#bfc2c7}body.dark-mode button.svelte-1ls9om6{background-color:#1d3040;color:#bfc2c7}body.dark-mode div.svelte-1ls9om6{background-color:#1d3040;color:#bfc2c7}body.dark-mode span.svelte-1ls9om6{background-color:#1d3040;color:#bfc2c7}.Shutter.svelte-1ls9om6{background-color:hsl(200, 16%, 96%);color:blak;padding:10px;border-radius:5px}body.dark-mode .Shutter.svelte-1ls9om6{background-color:#1d3040;color:#bfc2c7;padding:10px;border-radius:5px}body.dark-mode table.svelte-1ls9om6{background-color:#1d3040;color:#bfc2c7}body.dark-mode .letter1.svelte-1ls9om6{color:#bfc2c7}body.dark-mode .letter2.svelte-1ls9om6{color:#bfc2c7}body.dark-mode b.svelte-1ls9om6{color:#bfc2c7}body.dark-mode button.svelte-1ls9om6{background-color:#1d3040;color:#bfc2c7}h5.svelte-1ls9om6{display:inline}.box.svelte-hp9es9{width:93%;border:1px solid #aaa;border-radius:10px;box-shadow:10px 10px 8px rgba(0, 0, 0, 0.1);padding:1em;margin:0 0 1em 0}.tooltip.svelte-1vepdvs{border:1px solid #ddd;box-shadow:1px 1px 1px #ddd;background:rgb(185, 238, 241);border-radius:4px;padding:4px;position:absolute;color:black}.modal-background.svelte-10j5cq5{position:fixed;top:0;left:0;width:100%;height:100%;background:gray;opacity:0.8}.modal.svelte-10j5cq5{position:absolute;left:50%;top:50%;width:calc(100vw - 4em);max-width:32em;max-height:calc(100vh - 4em);overflow:auto;transform:translate(-50%, -50%);padding:1em;border-radius:0.2em;background:white}button.svelte-10j5cq5{display:block}.rotate-shadows.svelte-tks6xu{width:220px;height:220px;position:relative}.rotate-shadows.svelte-tks6xu:after,.rotate-shadows.svelte-tks6xu:before{content:"";border-radius:150%;position:absolute;top:0;left:0;width:100%;height:100%;transform-origin:center center}.rotate-shadows.svelte-tks6xu:before{box-shadow:inset 0 20px 0 rgba(0, 250, 250, 0.2), inset 20px 0 0 rgba(0, 200, 200, 0.2), inset 0 -20px 0 rgba(0, 150, 200, 0.2), inset -20px 0 0 rgba(0, 200, 250, 0.2);animation:svelte-tks6xu-rotate-before 9s -0.5s linear infinite}.rotate-shadows.svelte-tks6xu:after{box-shadow:inset 0 20px 0 rgba(250, 250, 0, 0.2), inset 20px 0 0 rgba(250, 200, 0, 0.2), inset 0 -20px 0 rgba(250, 150, 0, 0.2), inset -20px 0 0 rgba(250, 100, 0, 0.2);animation:svelte-tks6xu-rotate-after 9s -0.5s linear infinite}@keyframes svelte-tks6xu-rotate-after{0%{transform:rotateZ(0deg) scaleX(1) scaleY(1)}50%{transform:rotateZ(180deg) scaleX(0.82) scaleY(0.95)}100%{transform:rotateZ(360deg) scaleX(1) scaleY(1)}}@keyframes svelte-tks6xu-rotate-before{0%{transform:rotateZ(0deg) scaleX(1) scaleY(1)}50%{transform:rotateZ(-180deg) scaleX(0.95) scaleY(0.85)}100%{transform:rotateZ(-360deg) scaleX(1) scaleY(1)}}
|
||||
BIN
data_ms/setup/build/bundle.js.gz
Normal file
BIN
data_ms/setup/build/bundle.js.gz
Normal file
Binary file not shown.
63
data_ms/setup/global.css
Normal file
63
data_ms/setup/global.css
Normal file
@@ -0,0 +1,63 @@
|
||||
html, body {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
color: #333;
|
||||
margin: 0;
|
||||
padding: 8px;
|
||||
box-sizing: border-box;
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
|
||||
}
|
||||
|
||||
a {
|
||||
color: rgb(0,100,200);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
a:visited {
|
||||
color: rgb(0,80,160);
|
||||
}
|
||||
|
||||
label {
|
||||
display: block;
|
||||
}
|
||||
|
||||
input, button, select, textarea {
|
||||
font-family: inherit;
|
||||
font-size: inherit;
|
||||
-webkit-padding: 0.4em 0;
|
||||
padding: 0.4em;
|
||||
margin: 0 0 0.5em 0;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
input:disabled {
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
button {
|
||||
color: #333;
|
||||
background-color: #f4f4f4;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
button:disabled {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
button:not(:disabled):active {
|
||||
background-color: #ddd;
|
||||
}
|
||||
|
||||
button:focus {
|
||||
border-color: #666;
|
||||
}
|
||||
103
data_ms/setup/index.html
Normal file
103
data_ms/setup/index.html
Normal file
@@ -0,0 +1,103 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
||||
|
||||
<title>IotManager v 0.3.2</title>
|
||||
|
||||
<link rel="icon" type="image/png" href="/favicon.ico" />
|
||||
<link rel="stylesheet" href="/setup/global.css" />
|
||||
<link rel="stylesheet" href="/setup/build/bundle.css?0.3" />
|
||||
|
||||
<script defer src="/setup/build/bundle.js?0.3" onload="loadPage()"></script>
|
||||
<script>
|
||||
function get_cookie ( cookie_name ){
|
||||
var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );
|
||||
if ( results )
|
||||
return ( unescape ( results[2] ) );
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
if (get_cookie("darktheme") == "true"){
|
||||
var myColor = "#1d3040";
|
||||
document.write('\
|
||||
<style>\
|
||||
body{\
|
||||
background-color: '+myColor+';\
|
||||
}\
|
||||
</style>\
|
||||
');
|
||||
}
|
||||
|
||||
function loadPage() {
|
||||
document.getElementById("status").style.display = "none";
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
.rotate-shadows {
|
||||
width: 220px;
|
||||
height: 220px;
|
||||
margin:0 auto;
|
||||
position: relative;
|
||||
}
|
||||
.rotate-shadows:after,
|
||||
.rotate-shadows:before {
|
||||
content: "";
|
||||
border-radius: 150%;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
transform-origin: center center;
|
||||
}
|
||||
.rotate-shadows:before {
|
||||
box-shadow: inset 0 20px 0 rgba(0, 250, 250, 0.2),
|
||||
inset 20px 0 0 rgba(0, 200, 200, 0.2),
|
||||
inset 0 -20px 0 rgba(0, 150, 200, 0.2),
|
||||
inset -20px 0 0 rgba(0, 200, 250, 0.2);
|
||||
animation: rotate-before 9s -0.5s linear infinite;
|
||||
}
|
||||
.rotate-shadows:after {
|
||||
box-shadow: inset 0 20px 0 rgba(250, 250, 0, 0.2),
|
||||
inset 20px 0 0 rgba(250, 200, 0, 0.2),
|
||||
inset 0 -20px 0 rgba(250, 150, 0, 0.2),
|
||||
inset -20px 0 0 rgba(250, 100, 0, 0.2);
|
||||
animation: rotate-after 9s -0.5s linear infinite;
|
||||
}
|
||||
@keyframes rotate-after {
|
||||
0% {
|
||||
transform: rotateZ(0deg) scaleX(1) scaleY(1);
|
||||
}
|
||||
50% {
|
||||
transform: rotateZ(180deg) scaleX(0.82) scaleY(0.95);
|
||||
}
|
||||
100% {
|
||||
transform: rotateZ(360deg) scaleX(1) scaleY(1);
|
||||
}
|
||||
}
|
||||
@keyframes rotate-before {
|
||||
0% {
|
||||
transform: rotateZ(0deg) scaleX(1) scaleY(1);
|
||||
}
|
||||
50% {
|
||||
transform: rotateZ(-180deg) scaleX(0.95) scaleY(0.85);
|
||||
}
|
||||
100% {
|
||||
transform: rotateZ(-360deg) scaleX(1) scaleY(1);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<p><div id="status" class="rotate-shadows"></div></p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
BIN
data_ms/setup/progress.gif
Normal file
BIN
data_ms/setup/progress.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.0 KiB |
@@ -1,33 +1,35 @@
|
||||
{
|
||||
"toggleBtn": "Кнопка переключатель",
|
||||
"range": "Ползунок",
|
||||
"inputDate": "Окно ввода даты",
|
||||
"inputTime": "Окно ввода времени 1",
|
||||
"inputTimeClock": "Окно ввода времени 2",
|
||||
"inputDigit": "Окно ввода цифры",
|
||||
"inputDigitTemp": "Окно ввода температуры",
|
||||
"inputText": "Окно ввода текста",
|
||||
"select": "Выпадающий список",
|
||||
"chart": "График без точек",
|
||||
"chart2": "График с точками",
|
||||
"chart3": "График дневного расхода (столбики)",
|
||||
"chart4": "График дневного расхода (плавный)",
|
||||
"fillgauge": "Бочка",
|
||||
"progress-line": "Линия",
|
||||
"progress-round": "Круг",
|
||||
"anydata": "Текст",
|
||||
"anydataHum": "Влажность (%)",
|
||||
"anydataPress": "Давление (mm)",
|
||||
"anydataTemp": "Температура (°С)",
|
||||
"anydataPpb": "Части на миллиард (ppb)",
|
||||
"anydataPpm": "Части на миллион (ppm)",
|
||||
"anydataVlt": "Напряжение (Vlt)",
|
||||
"anydataAmp": "Сила тока (Amp)",
|
||||
"anydataWtt": "Мощность (Wtt)",
|
||||
"anydataWhr": "Энергия (Whr)",
|
||||
"anydataHtz": "Частота (Htz)",
|
||||
"anydataTime": "Манометр",
|
||||
"alarm": "Тревожное сообщение 1",
|
||||
"anydataAlarm": "Тревожное сообщение 2",
|
||||
"na": "Без виджета"
|
||||
}
|
||||
"undef": "Ошибка",
|
||||
"toggleBtn": "Переключатель",
|
||||
"btn": "Кнопка",
|
||||
"select": "Кнопка переключатель",
|
||||
"range": "Ползунок",
|
||||
"inputDate": "Окно ввода даты",
|
||||
"inputTime": "Окно ввода времени 1",
|
||||
"inputTimeClock": "Окно ввода времени 2",
|
||||
"inputDigit": "Окно ввода цифры",
|
||||
"inputDigitTemp": "Окно ввода температуры",
|
||||
"inputText": "Окно ввода текста",
|
||||
"chart": "График без точек",
|
||||
"chart2": "График с точками",
|
||||
"chart3": "График дневного расхода (столбики)",
|
||||
"chart4": "График дневного расхода (плавный)",
|
||||
"fillgauge": "Бочка",
|
||||
"progress-line": "Линия",
|
||||
"progress-round": "Круг",
|
||||
"anydata": "Текст",
|
||||
"anydataHum": "Влажность (%)",
|
||||
"anydataPress": "Давление (mm)",
|
||||
"anydataTemp": "Температура (°С)",
|
||||
"anydataPpb": "Части на миллиард (ppb)",
|
||||
"anydataPpm": "Части на миллион (ppm)",
|
||||
"anydataVlt": "Напряжение (Vlt)",
|
||||
"anydataAmp": "Сила тока (Amp)",
|
||||
"anydataWtt": "Мощность (Wtt)",
|
||||
"anydataWhr": "Энергия (Whr)",
|
||||
"anydataHtz": "Частота (Htz)",
|
||||
"anydataTime": "Манометр",
|
||||
"alarm": "Тревожное сообщение 1",
|
||||
"anydataAlarm": "Тревожное сообщение 2",
|
||||
"na": "Без виджета"
|
||||
}
|
||||
|
||||
@@ -1,5 +1,16 @@
|
||||
{
|
||||
"widget": "anydata",
|
||||
"after": "°С",
|
||||
"icon": "thermometer"
|
||||
}
|
||||
"icon": "thermometer",
|
||||
"font": "OCR A Std",
|
||||
"color": [
|
||||
{ "level": -20, "value": "#0000CC" },
|
||||
{ "level": -10, "value": "#0000CC" },
|
||||
{ "level": 0, "value": "#0000CC" },
|
||||
{ "level": 12, "value": "#3366FF" },
|
||||
{ "level": 16, "value": "#33CCFF" },
|
||||
{ "level": 18, "value": "#009933" },
|
||||
{ "level": 30, "value": "#FF9900" },
|
||||
{ "level": 40, "value": "red" }
|
||||
]
|
||||
}
|
||||
|
||||
@@ -3,20 +3,20 @@
|
||||
"chipID": "",
|
||||
"apssid": "IoTmanager",
|
||||
"appass": "",
|
||||
"routerssid": "rise2",
|
||||
"routerssid": "rise",
|
||||
"routerpass": "hostel3333",
|
||||
"timezone": 1,
|
||||
"ntp": "pool.ntp.org",
|
||||
"mqttServer": "91.204.228.124",
|
||||
"mqttPort": 1883,
|
||||
"mqttServer": "M2.WQTT.RU",
|
||||
"mqttPort": 8021,
|
||||
"mqttPrefix": "/iotTest3",
|
||||
"mqttUser": "rise",
|
||||
"mqttPass": "23ri22se32",
|
||||
"mqttServer2": "M2.WQTT.RU",
|
||||
"mqttPort2": 8021,
|
||||
"mqttPrefix2": "/iotTest3",
|
||||
"mqttUser2": "rise",
|
||||
"mqttPass2": "hostel3333",
|
||||
"mqttPass": "hostel3333",
|
||||
"mqttServer2": "",
|
||||
"mqttPort2": 0,
|
||||
"mqttPrefix2": "",
|
||||
"mqttUser2": "",
|
||||
"mqttPass2": "",
|
||||
"scen": "1",
|
||||
"telegramApi": "1416711569:AAEI0j83GmXqwzb_gnK1B0Am0gDwZoJt5xo",
|
||||
"telegonof": "0",
|
||||
@@ -26,7 +26,7 @@
|
||||
"webpass": "admin",
|
||||
"MqttIn": "0",
|
||||
"MqttOut": "0",
|
||||
"blink": "0",
|
||||
"blink": "1",
|
||||
"oneWirePin": "2",
|
||||
"serverip": "http://206.189.49.244",
|
||||
"uart": "0",
|
||||
|
||||
6
esp32_partitions_castom.csv
Normal file
6
esp32_partitions_castom.csv
Normal file
@@ -0,0 +1,6 @@
|
||||
# Name, Type, SubType, Offset, Size, Flags
|
||||
nvs, data, nvs, 0x9000, 0x5000,
|
||||
otadata, data, ota, 0xe000, 0x2000,
|
||||
app0, app, ota_0, 0x10000, 0x150000,
|
||||
app1, app, ota_1, 0x160000,0x150000,
|
||||
spiffs, data, spiffs, 0x2B0000,0x150000,
|
||||
|
6
esp32_partitions_default.csv
Normal file
6
esp32_partitions_default.csv
Normal file
@@ -0,0 +1,6 @@
|
||||
# Name, Type, SubType, Offset, Size, Flags
|
||||
nvs, data, nvs, 0x9000, 0x5000,
|
||||
otadata, data, ota, 0xe000, 0x2000,
|
||||
app0, app, ota_0, 0x10000, 0x140000,
|
||||
app1, app, ota_1, 0x150000,0x140000,
|
||||
spiffs, data, spiffs, 0x290000,0x170000,
|
||||
|
@@ -127,6 +127,7 @@ class LineParsing {
|
||||
}
|
||||
|
||||
if (_pin != "") {
|
||||
/*
|
||||
if (_pin.indexOf(",") == -1) {
|
||||
if (!isPinExist(_pin.toInt()) || !isDigitStr(_pin)) {
|
||||
pinErrors++;
|
||||
@@ -139,6 +140,17 @@ class LineParsing {
|
||||
pinErrors++;
|
||||
_pin = "";
|
||||
}
|
||||
}*/
|
||||
|
||||
String tmpstr;
|
||||
for (int i=0; i<15; i++) {
|
||||
tmpstr = selectFromMarkerToMarker(_pin, ",", i);
|
||||
if(tmpstr == "not found") break;
|
||||
if(!isDigitStr(tmpstr) || !isPinExist(tmpstr.toInt())){
|
||||
pinErrors++;
|
||||
_pin = "";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,10 +10,14 @@ class Scenario {
|
||||
if (!jsonReadBool(configSetupJson, "scen")) {
|
||||
return;
|
||||
}
|
||||
|
||||
String allBlocks = scenario;
|
||||
allBlocks += "\n";
|
||||
|
||||
|
||||
String incommingEvent = selectToMarker(eventBuf, ",");
|
||||
if (incommingEvent == "") {
|
||||
return;
|
||||
}
|
||||
|
||||
String incommingEventKey = selectToMarker(incommingEvent, " ");
|
||||
String incommingEventValue = selectToMarkerLast(incommingEvent, " ");
|
||||
@@ -159,18 +163,20 @@ class Scenario {
|
||||
|
||||
private:
|
||||
bool isScenarioNeedToDo(String &condition, String &incommingEventKey, String &incommingEventValue, int type) {
|
||||
bool res = false;
|
||||
if (condition == "") return false;
|
||||
String setEventKey = selectFromMarkerToMarker(condition, " ", 0);
|
||||
if (isEventExist(incommingEventKey, setEventKey)) {
|
||||
String setEventSign;
|
||||
String setEventValue;
|
||||
if (type == 1) preCalculation(condition, setEventSign, setEventValue);
|
||||
String cloneOfIncommingEventValue = incommingEventValue; //клонируем для изменения в preCalculation и передачи для проверки по условиям
|
||||
if (type == 1) preCalculation(condition, setEventSign, cloneOfIncommingEventValue, setEventValue);
|
||||
if (type == 2) preCalculationGisteresis(condition, setEventSign, setEventValue);
|
||||
if (isConditionMatch(setEventSign, incommingEventValue, setEventValue)) {
|
||||
res = true;
|
||||
if (isConditionMatch(setEventSign, cloneOfIncommingEventValue, setEventValue)) {
|
||||
return true;
|
||||
}
|
||||
//SerialPrint("I", "incommingEventKey", incommingEventKey);
|
||||
}
|
||||
return res;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isScenarioNeedToDoJson(String &condition) {
|
||||
@@ -178,8 +184,9 @@ class Scenario {
|
||||
String setEventKey = selectFromMarkerToMarker(condition, " ", 0);
|
||||
String setEventSign;
|
||||
String setEventValue;
|
||||
preCalculation(condition, setEventSign, setEventValue);
|
||||
|
||||
String jsonValue = getValue(setEventKey);
|
||||
preCalculation(condition, setEventSign, jsonValue, setEventValue);
|
||||
if (isConditionMatch(setEventSign, jsonValue, setEventValue)) {
|
||||
res = true;
|
||||
}
|
||||
@@ -200,11 +207,24 @@ class Scenario {
|
||||
// return res;
|
||||
//}
|
||||
|
||||
void preCalculation(String &condition, String &setEventSign, String &setEventValue) {
|
||||
void preCalculation(String &condition, String &setEventSign, String &incommingEventValue, String &setEventValue) {
|
||||
setEventSign = selectFromMarkerToMarker(condition, " ", 1);
|
||||
setEventValue = selectFromMarkerToMarker(condition, " ", 2);
|
||||
|
||||
String tmpStr;
|
||||
tmpStr = getValue(setEventValue);
|
||||
if (tmpStr != "no value") setEventValue = tmpStr;
|
||||
|
||||
if (!isDigitDotCommaStr(setEventValue)) {
|
||||
setEventValue = getValue(setEventValue);
|
||||
if (isTimeStr(incommingEventValue)) {
|
||||
int hhLStr = selectToMarker(incommingEventValue, ":").toInt();
|
||||
int mmLStr = selectToMarkerLast(incommingEventValue, ":").toInt();
|
||||
int hhRStr = selectToMarker(setEventValue, ":").toInt();
|
||||
int mmRStr = selectToMarkerLast(setEventValue, ":").toInt();
|
||||
|
||||
incommingEventValue = hhLStr*60 + mmLStr;
|
||||
setEventValue = hhRStr*60 + mmRStr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,14 +248,20 @@ class Scenario {
|
||||
|
||||
bool isEventExist(String &incommingEventKey, String &setEventKey) {
|
||||
bool res = false;
|
||||
if (incommingEventKey == setEventKey) {
|
||||
if (incommingEventKey != "not found" && incommingEventKey == setEventKey) {
|
||||
res = true;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
bool isConditionMatch(String &setEventSign, String &incommingEventValue, String &setEventValue) {
|
||||
if (setEventValue == "no value") return false;
|
||||
|
||||
boolean flag = false;
|
||||
//SerialPrint("I", "setEventSign", setEventSign);
|
||||
//SerialPrint("I", "incommingEventValue", incommingEventValue);
|
||||
//SerialPrint("I", "setEventValue", setEventValue);
|
||||
//SerialPrint("I", "==========", "===============");
|
||||
if (setEventSign == "=") {
|
||||
flag = incommingEventValue == setEventValue;
|
||||
} else if (setEventSign == "!=") {
|
||||
@@ -249,6 +275,7 @@ class Scenario {
|
||||
} else if (setEventSign == "<=") {
|
||||
flag = incommingEventValue.toFloat() <= setEventValue.toFloat();
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "Clock.h"
|
||||
#include "Global.h"
|
||||
#include "Utils/TimeUtils.h"
|
||||
#include "Utils\SerialPrint.h"
|
||||
#include "Utils/SerialPrint.h"
|
||||
|
||||
extern void clockInit();
|
||||
|
||||
@@ -143,8 +143,16 @@ class Clock {
|
||||
return String(buf);
|
||||
}
|
||||
|
||||
/*
|
||||
* Локальное дата время "день недели"
|
||||
*/
|
||||
const String getWeekday() {
|
||||
char buf[32];
|
||||
sprintf(buf, "%d", _time_local.day_of_week);
|
||||
return String(buf);
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Локальное время "чч:мм:cc"
|
||||
*/
|
||||
const String getTime() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#define FIRMWARE_VERSION 302
|
||||
#define FIRMWARE_VERSION 306
|
||||
|
||||
//#define svelte
|
||||
|
||||
@@ -46,15 +46,21 @@
|
||||
#define MYSENSORS
|
||||
#endif
|
||||
|
||||
#ifndef esp32_4mb
|
||||
#define NUM_BUTTONS 6
|
||||
#define MQTT_RECONNECT_INTERVAL 20000
|
||||
#endif
|
||||
#ifdef esp32_4mb
|
||||
#define NUM_BUTTONS 8
|
||||
#endif
|
||||
|
||||
#define MQTT_RECONNECT_INTERVAL 60000
|
||||
#define CHANGE_BROKER_AFTER 5
|
||||
#define TELEMETRY_UPDATE_INTERVAL_MIN 60
|
||||
#define DEVICE_CONFIG_FILE "s.conf.csv"
|
||||
#define DEVICE_SCENARIO_FILE "s.scen.txt"
|
||||
//#define OTA_UPDATES_ENABLED
|
||||
//#define MDNS_ENABLED
|
||||
//#define WEBSOCKET_ENABLED
|
||||
#define WEBSOCKET_ENABLED
|
||||
//#define LAYOUT_IN_RAM
|
||||
//#define UDP_ENABLED
|
||||
//#define SSDP_ENABLED
|
||||
@@ -70,6 +76,7 @@
|
||||
#define EnablePwmOut
|
||||
#define EnableSensorAnalog
|
||||
#define EnableSensorBme280
|
||||
#define EnableSensorSht20
|
||||
#define EnableSensorBmp280
|
||||
#define EnableSensorCcs811
|
||||
#define EnableSensorDallas
|
||||
@@ -77,8 +84,11 @@
|
||||
#define EnableSensorPzem
|
||||
#define EnableSensorUltrasonic
|
||||
#define EnableSensorUptime
|
||||
#define EnableSensorAny
|
||||
#define EnableTelegram
|
||||
#define EnableUart
|
||||
#define EnableSensorLCD2004
|
||||
#define EnableSensorTM1637
|
||||
#endif
|
||||
|
||||
#ifdef GATE_MODE
|
||||
@@ -91,6 +101,7 @@
|
||||
#define EnableSensorUptime
|
||||
#define EnableTelegram
|
||||
#define EnableUart
|
||||
#define EnableSensorLCD2004
|
||||
#endif
|
||||
|
||||
//================================================================================================================================================================
|
||||
@@ -132,27 +143,27 @@ enum ConfigType_t {
|
||||
CT_SCENARIO
|
||||
};
|
||||
|
||||
//history
|
||||
//07.11.2020 (SSDP OFF, UDP OFF)
|
||||
//RAM: [===== ] 46.8% (used 38376 bytes from 81920 bytes)
|
||||
//Flash: [===== ] 54.2% (used 566004 bytes from 1044464 bytes)
|
||||
// history
|
||||
// 07.11.2020 (SSDP OFF, UDP OFF)
|
||||
// RAM: [===== ] 46.8% (used 38376 bytes from 81920 bytes)
|
||||
// Flash: [===== ] 54.2% (used 566004 bytes from 1044464 bytes)
|
||||
|
||||
//13.11.2020 (SSDP OFF, UDP OFF)
|
||||
//RAM: [===== ] 46.6% (used 38208 bytes from 81920 bytes)
|
||||
//Flash: [===== ] 54.2% (used 566388 bytes from 1044464 bytes)
|
||||
// 13.11.2020 (SSDP OFF, UDP OFF)
|
||||
// RAM: [===== ] 46.6% (used 38208 bytes from 81920 bytes)
|
||||
// Flash: [===== ] 54.2% (used 566388 bytes from 1044464 bytes)
|
||||
|
||||
//15.11.2020 (SSDP OFF, UDP OFF)
|
||||
//RAM: [===== ] 46.1% (used 37780 bytes from 81920 bytes)
|
||||
//Flash: [===== ] 54.3% (used 566656 bytes from 1044464 bytes)
|
||||
// 15.11.2020 (SSDP OFF, UDP OFF)
|
||||
// RAM: [===== ] 46.1% (used 37780 bytes from 81920 bytes)
|
||||
// Flash: [===== ] 54.3% (used 566656 bytes from 1044464 bytes)
|
||||
|
||||
//17.11.2020 (SSDP OFF, UDP OFF)
|
||||
//RAM: [===== ] 45.7% (used 37476 bytes from 81920 bytes)
|
||||
//Flash: [===== ] 54.5% (used 569296 bytes from 1044464 bytes)
|
||||
// 17.11.2020 (SSDP OFF, UDP OFF)
|
||||
// RAM: [===== ] 45.7% (used 37476 bytes from 81920 bytes)
|
||||
// Flash: [===== ] 54.5% (used 569296 bytes from 1044464 bytes)
|
||||
|
||||
//RAM: [===== ] 45.6% (used 37336 bytes from 81920 bytes)
|
||||
//Flash: [====== ] 55.3% (used 577396 bytes from 1044464 bytes)
|
||||
// RAM: [===== ] 45.6% (used 37336 bytes from 81920 bytes)
|
||||
// Flash: [====== ] 55.3% (used 577396 bytes from 1044464 bytes)
|
||||
|
||||
//eventBuf - буфер событий которые проверяются в сценариях,
|
||||
// eventBuf - буфер событий которые проверяются в сценариях,
|
||||
//и если событие удовлетворяет какому нибудь условию то выполняются указанные команды
|
||||
|
||||
//orderBuf - буфер команд которые выполняются сейчас же
|
||||
// orderBuf - буфер команд которые выполняются сейчас же
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
|
||||
|
||||
void mqttInit();
|
||||
void selectBroker();
|
||||
void getMqttData1();
|
||||
@@ -29,3 +27,5 @@ void publishState();
|
||||
|
||||
void mqttCallback(char* topic, uint8_t* payload, size_t length);
|
||||
const String getStateStr();
|
||||
|
||||
String getAllJson();
|
||||
|
||||
@@ -8,6 +8,8 @@ int jsonReadInt(String& json, String name);
|
||||
|
||||
boolean jsonReadBool(String& json, String name);
|
||||
|
||||
float jsonReadFloat(String& json, String name);
|
||||
|
||||
String jsonWriteStr(String& json, String name, String value);
|
||||
|
||||
String jsonWriteInt(String& json, String name, int value);
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
void hex2string(byte array[], unsigned int len, char buffer[]);
|
||||
|
||||
int string2hex(const char* str, unsigned char* bytes );
|
||||
|
||||
uint8_t hexStringToUint8(String hex);
|
||||
|
||||
uint16_t hexStringToUint16(String hex);
|
||||
@@ -30,6 +34,8 @@ size_t itemsCount(String& str, const char* delim);
|
||||
|
||||
boolean isDigitStr(const String& str);
|
||||
|
||||
boolean isTimeStr(const String& str);
|
||||
|
||||
boolean isDigitDotCommaStr(const String& str);
|
||||
|
||||
String prettyBytes(size_t size);
|
||||
|
||||
12
include/YourSensor.h
Normal file
12
include/YourSensor.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
extern float yourSensorReading(String type, String addr);
|
||||
|
||||
extern void HDC1080_init(String addr);
|
||||
extern void AHTX0_init();
|
||||
extern void LCD_init();
|
||||
extern void BH1750_init();
|
||||
|
||||
extern unsigned long getValue(byte packet[]);
|
||||
extern void sendRequest(byte packet[]);
|
||||
@@ -20,7 +20,7 @@ class ButtonInClass : public LineParsing {
|
||||
void init() {
|
||||
if (_pin != "") {
|
||||
int number = numberEntering++;
|
||||
buttons[number].attach(_pin.toInt());
|
||||
buttons[number].attach(_pin.toInt(), INPUT);
|
||||
buttons[number].interval(_db.toInt());
|
||||
but[number] = true;
|
||||
jsonWriteStr(configOptionJson, "switch_num_" + String(number), _key);
|
||||
|
||||
@@ -23,7 +23,6 @@ class ImpulsOutClass {
|
||||
unsigned int _impulsCount = 0;
|
||||
unsigned int _impulsCountBuf = 0;
|
||||
unsigned int _impulsPin = 0;
|
||||
|
||||
};
|
||||
|
||||
extern MyImpulsOutVector* myImpulsOut;
|
||||
|
||||
@@ -11,15 +11,11 @@ typedef std::vector<LoggingClass> MyLoggingVector;
|
||||
|
||||
class LoggingClass {
|
||||
public:
|
||||
|
||||
LoggingClass(String interval, unsigned int maxPoints, String loggingValueKey, String key, String startState, bool savedFromWeb);
|
||||
~LoggingClass();
|
||||
|
||||
void loop();
|
||||
void execute(String keyOrValue);
|
||||
|
||||
private:
|
||||
|
||||
unsigned long currentMillis;
|
||||
unsigned long prevMillis;
|
||||
unsigned long difference;
|
||||
@@ -29,16 +25,14 @@ class LoggingClass {
|
||||
unsigned int _maxPoints;
|
||||
String _loggingValueKey;
|
||||
String _key;
|
||||
|
||||
|
||||
};
|
||||
|
||||
extern MyLoggingVector* myLogging;
|
||||
|
||||
extern void logging();
|
||||
extern void loggingExecute();
|
||||
extern void choose_log_date_and_send();
|
||||
extern void choose_log_date_and_sendWS();
|
||||
extern void sendLogData(String file, String topic);
|
||||
extern void sendLogDataWS(String file, String topic);
|
||||
extern void sendLogData2(String file, String topic);
|
||||
extern void cleanLogAndData();
|
||||
#endif
|
||||
|
||||
@@ -1,29 +1,19 @@
|
||||
#ifdef EnableOutput
|
||||
#pragma once
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "Global.h"
|
||||
|
||||
class Output;
|
||||
|
||||
typedef std::vector<Output> MyOutputVector;
|
||||
|
||||
class Output {
|
||||
public:
|
||||
|
||||
Output(String key);
|
||||
~Output();
|
||||
|
||||
void execute(String value);
|
||||
|
||||
private:
|
||||
|
||||
String _key;
|
||||
|
||||
};
|
||||
|
||||
extern MyOutputVector* myOutput;
|
||||
|
||||
extern void outputValue();
|
||||
extern void outputExecute();
|
||||
#endif
|
||||
|
||||
37
include/items/vSensorAny.h
Normal file
37
include/items/vSensorAny.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#ifdef EnableSensorAny
|
||||
#pragma once
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "Global.h"
|
||||
|
||||
class SensorAny;
|
||||
|
||||
typedef std::vector<SensorAny> MySensorAnyVector;
|
||||
|
||||
class SensorAny {
|
||||
public:
|
||||
SensorAny(const String& paramsAny);
|
||||
~SensorAny();
|
||||
|
||||
void loop();
|
||||
void read();
|
||||
|
||||
private:
|
||||
String _paramsAny;
|
||||
int _interval;
|
||||
float _c;
|
||||
float _k;
|
||||
String _key;
|
||||
String _addr;
|
||||
String _type;
|
||||
String _val;
|
||||
String _descr;
|
||||
|
||||
unsigned long prevMillis;
|
||||
unsigned long difference;
|
||||
};
|
||||
|
||||
extern MySensorAnyVector* mySensorAny;
|
||||
|
||||
extern void AnySensor();
|
||||
#endif
|
||||
@@ -5,17 +5,19 @@
|
||||
#include <DallasTemperature.h>
|
||||
#include "Global.h"
|
||||
|
||||
|
||||
//ИНТЕГРИРУЮ: Объявляем глагольные переменные необходимые интегрируемой библиотеке
|
||||
extern DallasTemperature sensors;
|
||||
extern OneWire* oneWire;
|
||||
|
||||
//ИНТЕГРИРУЮ: следим за наименованиями далее
|
||||
class SensorDallas;
|
||||
|
||||
typedef std::vector<SensorDallas> MySensorDallasVector;
|
||||
|
||||
class SensorDallas {
|
||||
public:
|
||||
SensorDallas(unsigned long interval, unsigned int pin, unsigned int index, String key);
|
||||
//ИНТЕГРИРУЮ: обращаем внимание на параметры, берутся из таблицы настроек
|
||||
SensorDallas(unsigned long interval, unsigned int pin, unsigned int index, String addr, String key);
|
||||
~SensorDallas();
|
||||
|
||||
void loop();
|
||||
@@ -27,8 +29,13 @@ class SensorDallas {
|
||||
unsigned long difference;
|
||||
unsigned long _interval;
|
||||
String _key;
|
||||
String _addr;
|
||||
unsigned int _pin;
|
||||
unsigned int _index;
|
||||
|
||||
//для работы библиотеки с несколькими линиями необходимо обеспечить каждый экземпляр класса ссылками на объекты настроенные на эти линии
|
||||
OneWire* oneWire;
|
||||
DallasTemperature* sensors;
|
||||
};
|
||||
|
||||
extern MySensorDallasVector* mySensorDallas2;
|
||||
|
||||
40
include/items/vSensorLCD2004.h
Normal file
40
include/items/vSensorLCD2004.h
Normal file
@@ -0,0 +1,40 @@
|
||||
#ifdef EnableSensorLCD2004
|
||||
#pragma once
|
||||
#include <Arduino.h>
|
||||
#include <OneWire.h>
|
||||
#include "Global.h"
|
||||
#include "LiquidCrystal_I2C.h"
|
||||
|
||||
|
||||
class SensorLCD2004;
|
||||
|
||||
typedef std::vector<SensorLCD2004> MySensorLCD2004Vector;
|
||||
|
||||
class SensorLCD2004 {
|
||||
public:
|
||||
SensorLCD2004(String key, unsigned long interval, unsigned int x, unsigned int y, String val, String descr);
|
||||
~SensorLCD2004();
|
||||
|
||||
void loop();
|
||||
void writeLCD2004();
|
||||
void execute(String command);
|
||||
String _key;
|
||||
void printBlankStr(int strSize);
|
||||
|
||||
private:
|
||||
unsigned long currentMillis;
|
||||
unsigned long prevMillis;
|
||||
unsigned long difference;
|
||||
|
||||
unsigned long _interval;
|
||||
unsigned int _x;
|
||||
unsigned int _y;
|
||||
String _val;
|
||||
String _descr;
|
||||
int _prevStrSize;
|
||||
};
|
||||
|
||||
extern MySensorLCD2004Vector* mySensorLCD20042;
|
||||
|
||||
extern void lcd2004();
|
||||
#endif
|
||||
40
include/items/vSensorSHT20.h
Normal file
40
include/items/vSensorSHT20.h
Normal file
@@ -0,0 +1,40 @@
|
||||
#ifdef EnableSensorSht20
|
||||
#pragma once
|
||||
#include <Arduino.h>
|
||||
#include "Wire.h"
|
||||
#include "SHT2x.h"
|
||||
|
||||
#include "Global.h"
|
||||
|
||||
extern SHT2x* sht;
|
||||
|
||||
class SensorSht20;
|
||||
|
||||
typedef std::vector<SensorSht20> MySensorSht20Vector;
|
||||
|
||||
struct paramsSht {
|
||||
String key;
|
||||
unsigned long interval;
|
||||
float c;
|
||||
};
|
||||
|
||||
class SensorSht20 {
|
||||
public:
|
||||
SensorSht20(const paramsSht& paramsTmp, const paramsSht& paramsHum);
|
||||
~SensorSht20();
|
||||
|
||||
void loop();
|
||||
void read();
|
||||
|
||||
private:
|
||||
paramsSht _paramsTmp;
|
||||
paramsSht _paramsHum;
|
||||
|
||||
unsigned long prevMillis;
|
||||
unsigned long difference;
|
||||
};
|
||||
|
||||
extern MySensorSht20Vector* mySensorSht20;
|
||||
|
||||
extern void sht20Sensor();
|
||||
#endif
|
||||
44
include/items/vSensorTM1637.h
Normal file
44
include/items/vSensorTM1637.h
Normal file
@@ -0,0 +1,44 @@
|
||||
#ifdef EnableSensorTM1637
|
||||
#pragma once
|
||||
#include <Arduino.h>
|
||||
#include <OneWire.h>
|
||||
#include "Global.h"
|
||||
#include <TM1637Display.h>
|
||||
|
||||
struct DisplayObj {
|
||||
TM1637Display* disp;
|
||||
int curIndex;
|
||||
};
|
||||
|
||||
class SensorTM1637;
|
||||
|
||||
typedef std::vector<SensorTM1637> MySensorTM1637Vector;
|
||||
|
||||
class SensorTM1637 {
|
||||
public:
|
||||
SensorTM1637(String key, int pin1, int pin2, unsigned long interval, unsigned int c, unsigned int k, String val, String descr);
|
||||
~SensorTM1637();
|
||||
|
||||
void loop();
|
||||
void writeTM1637();
|
||||
void execute(String command);
|
||||
String _key;
|
||||
|
||||
private:
|
||||
unsigned long currentMillis;
|
||||
unsigned long prevMillis;
|
||||
unsigned long difference;
|
||||
|
||||
String _descr;
|
||||
unsigned long _interval;
|
||||
unsigned int _c;
|
||||
unsigned int _k;
|
||||
String _val;
|
||||
|
||||
TM1637Display* _disp;
|
||||
};
|
||||
|
||||
extern MySensorTM1637Vector* mySensorTM1637;
|
||||
|
||||
extern void TM1637();
|
||||
#endif
|
||||
BIN
partitions.xlsx
Normal file
BIN
partitions.xlsx
Normal file
Binary file not shown.
@@ -1,6 +0,0 @@
|
||||
# Name, Type, SubType, Offset, Size, Flags
|
||||
ota_0, app, ota_0, 0x10000, 0x1A0000
|
||||
ota_1, app, ota_1, , 0x1A0000
|
||||
otadata, data, ota, 0x350000, 0x2000
|
||||
nvs, data, nvs, , 0x6000
|
||||
data, data, spiffs, , 0xA8000
|
||||
|
@@ -8,34 +8,20 @@
|
||||
; Please visit documentation for the other options and examples
|
||||
; https://docs.platformio.org/page/projectconf.html
|
||||
|
||||
|
||||
;==============================================================================================
|
||||
;To choose firmware please use one of definition:
|
||||
;esp8266_1mb , esp8266_4mb , esp32_4mb , esp8266_mysensors_4mb , esp32_mysensors_4mb
|
||||
[platformio]
|
||||
default_envs = esp32_4mb
|
||||
|
||||
|
||||
;data_esp => esp8266_1mb , esp8266_4mb , esp32_4mb
|
||||
;data_ms => esp8266_mysensors_4mb , esp32_mysensors_4mb
|
||||
;data_svelte => new web interface (in progress...)
|
||||
default_envs = esp8266_4mb
|
||||
data_dir = data_esp
|
||||
;==============================================================================================
|
||||
|
||||
|
||||
[common_env_data]
|
||||
lib_deps_external =
|
||||
bblanchon/ArduinoJson @5.*
|
||||
knolleary/PubSubClient
|
||||
|
||||
|
||||
lib_deps_internal =
|
||||
ESP Async WebServer
|
||||
GyverFilters
|
||||
OneWire
|
||||
EspSoftwareSerial
|
||||
|
||||
|
||||
[env:esp8266_4mb]
|
||||
build_flags = -Desp8266_4mb="esp8266_4mb"
|
||||
framework = arduino
|
||||
@@ -54,12 +40,17 @@ lib_deps =
|
||||
adafruit/Adafruit BME280 Library
|
||||
adafruit/Adafruit CCS811 Library
|
||||
milesburton/DallasTemperature
|
||||
robtillaart/SHT2x@^0.1.1
|
||||
ClosedCube HDC1080
|
||||
Adafruit AHTX0
|
||||
BH1750
|
||||
marcoschwartz/LiquidCrystal_I2C@^1.1.4
|
||||
smougenot/TM1637@0.0.0-alpha+sha.9486982048
|
||||
monitor_filters = esp8266_exception_decoder
|
||||
upload_speed = 921600
|
||||
monitor_speed = 115200
|
||||
board_build.filesystem = littlefs
|
||||
|
||||
|
||||
[env:esp8266_1mb]
|
||||
build_flags = -Desp8266_1mb="esp8266_1mb"
|
||||
framework = arduino
|
||||
@@ -78,11 +69,16 @@ lib_deps =
|
||||
adafruit/Adafruit BME280 Library
|
||||
adafruit/Adafruit CCS811 Library
|
||||
milesburton/DallasTemperature
|
||||
robtillaart/SHT2x@^0.1.1
|
||||
ClosedCube HDC1080
|
||||
Adafruit AHTX0
|
||||
BH1750
|
||||
marcoschwartz/LiquidCrystal_I2C@^1.1.4
|
||||
smougenot/TM1637@0.0.0-alpha+sha.9486982048
|
||||
monitor_filters = esp8266_exception_decoder
|
||||
upload_speed = 921600
|
||||
monitor_speed = 115200
|
||||
|
||||
|
||||
[env:esp8266_mysensors_4mb]
|
||||
build_flags = -Desp8266_mysensors_4mb="esp8266_mysensors_4mb"
|
||||
framework = arduino
|
||||
@@ -96,17 +92,21 @@ lib_deps =
|
||||
ESPAsyncUDP
|
||||
CTBot @2.1.6
|
||||
MySensors @2.3.2
|
||||
marcoschwartz/LiquidCrystal_I2C@^1.1.4
|
||||
smougenot/TM1637@0.0.0-alpha+sha.9486982048
|
||||
Adafruit AHTX0
|
||||
BH1750
|
||||
ClosedCube HDC1080
|
||||
monitor_filters = esp8266_exception_decoder
|
||||
upload_speed = 921600
|
||||
monitor_speed = 115200
|
||||
board_build.filesystem = littlefs
|
||||
|
||||
|
||||
[env:esp32_4mb]
|
||||
build_flags = -Desp32_4mb="esp32_4mb"
|
||||
framework = arduino
|
||||
board = esp32dev
|
||||
platform = espressif32 @3.3.0
|
||||
platform = espressif32 @3.4.0
|
||||
lib_deps =
|
||||
${common_env_data.lib_deps_external}
|
||||
${common_env_data.lib_deps_internal}
|
||||
@@ -121,16 +121,22 @@ lib_deps =
|
||||
adafruit/Adafruit BME280 Library
|
||||
adafruit/Adafruit CCS811 Library
|
||||
milesburton/DallasTemperature
|
||||
robtillaart/SHT2x@^0.1.1
|
||||
ClosedCube HDC1080
|
||||
Adafruit AHTX0
|
||||
BH1750
|
||||
marcoschwartz/LiquidCrystal_I2C@^1.1.4
|
||||
smougenot/TM1637@0.0.0-alpha+sha.9486982048
|
||||
monitor_filters = esp32_exception_decoder
|
||||
upload_speed = 921600
|
||||
monitor_speed = 115200
|
||||
|
||||
board_build.partitions = esp32_partitions_castom.csv
|
||||
|
||||
[env:esp32_mysensors_4mb]
|
||||
build_flags = -Desp32_mysensors_4mb="esp32_mysensors_4mb"
|
||||
framework = arduino
|
||||
board = esp32dev
|
||||
platform = espressif32 @3.3.0
|
||||
platform = espressif32 @3.3.0
|
||||
lib_deps =
|
||||
${common_env_data.lib_deps_external}
|
||||
${common_env_data.lib_deps_internal}
|
||||
@@ -140,6 +146,10 @@ lib_deps =
|
||||
ESP32 AnalogWrite
|
||||
ESP32Servo
|
||||
MySensors @2.3.2
|
||||
monitor_filters = esp32_exception_decoder
|
||||
marcoschwartz/LiquidCrystal_I2C@^1.1.4
|
||||
smougenot/TM1637@0.0.0-alpha+sha.9486982048
|
||||
Adafruit AHTX0
|
||||
BH1750
|
||||
ClosedCube HDC1080
|
||||
upload_speed = 921600
|
||||
monitor_speed = 115200
|
||||
monitor_speed = 115200
|
||||
|
||||
@@ -11,15 +11,20 @@
|
||||
#include "items/vOutput.h"
|
||||
#include "items/vPwmOut.h"
|
||||
#include "items/vSensorAnalog.h"
|
||||
#include "items/vSensorAny.h"
|
||||
#include "items/vSensorBme280.h"
|
||||
#include "items/vSensorBmp280.h"
|
||||
#include "items/vSensorCcs811.h"
|
||||
#include "items/vSensorDallas.h"
|
||||
#include "items/vSensorLCD2004.h"
|
||||
#include "items/vSensorTM1637.h"
|
||||
#include "items/vSensorDht.h"
|
||||
#include "items/vSensorNode.h"
|
||||
#include "items/vSensorPzem.h"
|
||||
#include "items/vSensorSHT20.h"
|
||||
#include "items/vSensorUltrasonic.h"
|
||||
#include "items/vSensorUptime.h"
|
||||
#include "MqttClient.h"
|
||||
|
||||
void loopCmdAdd(const String& cmdStr) {
|
||||
if (cmdStr.endsWith(",")) {
|
||||
@@ -43,7 +48,7 @@ void loopCmdExecute() {
|
||||
String tmp = selectToMarker(orderBuf, ","); //выделяем первую команду rel 5 1,
|
||||
sCmd.readStr(tmp); //выполняем
|
||||
if (tmp != "") {
|
||||
sCmd.readStr(tmp);
|
||||
sCmd.readStr(tmp);
|
||||
SerialPrint("I", F("Order done L"), tmp);
|
||||
}
|
||||
orderBuf = deleteBeforeDelimiter(orderBuf, ","); //осекаем
|
||||
@@ -69,7 +74,7 @@ void csvCmdExecute(String& cmdStr) {
|
||||
count++;
|
||||
|
||||
if (count > 1) {
|
||||
//SerialPrint("I", "Items", buf);
|
||||
// SerialPrint("I", "Items", buf);
|
||||
String order = selectToMarker(buf, " "); //отсечка самой команды
|
||||
if (order == F("button-out")) {
|
||||
#ifdef EnableButtonOut
|
||||
@@ -99,9 +104,18 @@ void csvCmdExecute(String& cmdStr) {
|
||||
#ifdef EnableSensorUltrasonic
|
||||
sCmd.addCommand(order.c_str(), ultrasonic);
|
||||
#endif
|
||||
//ИНТЕГРИРУЮ: Первая интеграция в ядро. Следим за наименованием
|
||||
} else if (order == F("dallas-temp")) {
|
||||
#ifdef EnableSensorDallas
|
||||
sCmd.addCommand(order.c_str(), dallas);
|
||||
#endif
|
||||
} else if (order == F("LCD2004")) {
|
||||
#ifdef EnableSensorLCD2004
|
||||
sCmd.addCommand(order.c_str(), lcd2004);
|
||||
#endif
|
||||
} else if (order == F("TM1637")) {
|
||||
#ifdef EnableSensorTM1637
|
||||
sCmd.addCommand(order.c_str(), TM1637);
|
||||
#endif
|
||||
} else if (order == F("dht")) {
|
||||
#ifdef EnableSensorDht
|
||||
@@ -110,6 +124,14 @@ void csvCmdExecute(String& cmdStr) {
|
||||
} else if (order == F("bme280")) {
|
||||
#ifdef EnableSensorBme280
|
||||
sCmd.addCommand(order.c_str(), bme280Sensor);
|
||||
#endif
|
||||
} else if (order == F("sht20")) {
|
||||
#ifdef EnableSensorSht20
|
||||
sCmd.addCommand(order.c_str(), sht20Sensor);
|
||||
#endif
|
||||
} else if (order == F("sensor")) {
|
||||
#ifdef EnableSensorAny
|
||||
sCmd.addCommand(order.c_str(), AnySensor);
|
||||
#endif
|
||||
} else if (order == F("bmp280")) {
|
||||
#ifdef EnableSensorBmp280
|
||||
@@ -141,7 +163,7 @@ void csvCmdExecute(String& cmdStr) {
|
||||
#endif
|
||||
} else if (order == F("impuls-in")) {
|
||||
#ifdef EnableImpulsIn
|
||||
//sCmd.addCommand(order.c_str(), impulsInSensor);
|
||||
// sCmd.addCommand(order.c_str(), impulsInSensor);
|
||||
#endif
|
||||
} else if (order == F("sensor-node")) {
|
||||
#ifdef EnableSensorNode
|
||||
@@ -161,6 +183,16 @@ void spaceCmdExecute(String& cmdStr) {
|
||||
cmdStr.replace("\r", "\n");
|
||||
while (cmdStr.length()) {
|
||||
String buf = selectToMarker(cmdStr, "\n");
|
||||
if (buf.indexOf("*") != -1) {
|
||||
buf.replace("*", "");
|
||||
String order = selectToMarker(buf, " ");
|
||||
String newValue = selectToMarkerLast(buf, " ");
|
||||
String allJson = getAllJson();
|
||||
String currentValue = jsonReadStr(allJson, order);
|
||||
if (newValue == currentValue) {
|
||||
buf = "";
|
||||
}
|
||||
}
|
||||
if (buf != "") {
|
||||
sCmd.readStr(buf);
|
||||
SerialPrint("I", F("Order done W"), buf);
|
||||
|
||||
@@ -184,21 +184,22 @@ void FSEditor::getDirList(const String &path, String &output) {
|
||||
}
|
||||
#else
|
||||
void FSEditor::getDirList(const String &path, String &output) {
|
||||
auto dir = _fs.open(path, FILE_READ);
|
||||
File dir = _fs.open(path.c_str(), FILE_READ);
|
||||
dir.rewindDirectory();
|
||||
while (dir.openNextFile()) {
|
||||
String fname = dir.name();
|
||||
if (!path.endsWith("/") && !fname.startsWith("/")) {
|
||||
fname = "/" + fname;
|
||||
}
|
||||
fname = path + fname;
|
||||
if (isExcluded(_fs, fname.c_str())) {
|
||||
continue;
|
||||
}
|
||||
if (dir.isDirectory()) {
|
||||
getDirList(fname, output);
|
||||
continue;
|
||||
}
|
||||
File file;
|
||||
while (file = dir.openNextFile()) {
|
||||
String fname = file.name();
|
||||
//if (!path.endsWith("/") && !fname.startsWith("/")) {
|
||||
// fname = "/" + fname;
|
||||
//}
|
||||
//fname = path + fname;
|
||||
//if (isExcluded(_fs, fname.c_str())) {
|
||||
// continue;
|
||||
//}
|
||||
//if (dir.isDirectory()) {
|
||||
// getDirList(fname, output);
|
||||
// continue;
|
||||
//}
|
||||
if (output != "[") output += ',';
|
||||
char buf[128];
|
||||
sprintf(buf, "{\"type\":\"file\",\"name\":\"%s\",\"size\":%d}", fname.c_str(), dir.size());
|
||||
|
||||
30
src/Init.cpp
30
src/Init.cpp
@@ -16,12 +16,19 @@
|
||||
#include "items/vSensorBmp280.h"
|
||||
#include "items/vSensorCcs811.h"
|
||||
#include "items/vSensorDallas.h"
|
||||
#include "items/vSensorLCD2004.h"
|
||||
#include "items/vSensorTM1637.h"
|
||||
#include "items/vSensorDht.h"
|
||||
#include "items/vSensorNode.h"
|
||||
#include "items/vSensorPzem.h"
|
||||
#include "items/vSensorSHT20.h"
|
||||
#include "items/vSensorUltrasonic.h"
|
||||
#include "items/vSensorUptime.h"
|
||||
|
||||
#ifdef EnableSensorLCD2004
|
||||
extern LiquidCrystal_I2C *LCDI2C;
|
||||
#endif
|
||||
|
||||
void loadConfig() {
|
||||
configSetupJson = readFile("config.json", 4096);
|
||||
configSetupJson.replace("\r\n", "");
|
||||
@@ -69,14 +76,14 @@ void deviceInit() {
|
||||
int errors = myLineParsing.getPinErrors();
|
||||
|
||||
if (errors > 0) {
|
||||
jsonWriteStr(configSetupJson, F("warning3"), F("<div style='margin-top:10px;margin-bottom:10px;'><font color='black'><p style='border: 1px solid #DCDCDC; border-radius: 3px; background-color: #ffc7c7; padding: 10px;'>Обнаружен неверный номер пина</p></font></div>"));
|
||||
jsonWriteStr(configSetupJson, F("warning3"), F("Обнаружен неверный номер пина"));
|
||||
} else {
|
||||
jsonWriteStr(configSetupJson, F("warning3"), "");
|
||||
}
|
||||
|
||||
savedFromWeb = false;
|
||||
//publishWidgets();
|
||||
//publishState();
|
||||
// publishWidgets();
|
||||
// publishState();
|
||||
}
|
||||
|
||||
void loadScenario() {
|
||||
@@ -162,11 +169,23 @@ void clearVectors() {
|
||||
pwmOut_EnterCounter = -1;
|
||||
#endif
|
||||
//==================================
|
||||
//ИНТЕГРИРУЮ: Вторая интеграция в ядро. Следим за наименованием
|
||||
#ifdef EnableSensorDallas
|
||||
if (mySensorDallas2 != nullptr) {
|
||||
mySensorDallas2->clear();
|
||||
}
|
||||
#endif
|
||||
#ifdef EnableSensorLCD2004
|
||||
if (mySensorLCD20042 != nullptr) {
|
||||
if(LCDI2C != nullptr) LCDI2C->clear();
|
||||
mySensorLCD20042->clear();
|
||||
}
|
||||
#endif
|
||||
#ifdef EnableSensorTM1637
|
||||
if (mySensorTM1637 != nullptr) {
|
||||
mySensorTM1637->clear();
|
||||
}
|
||||
#endif
|
||||
#ifdef EnableSensorUltrasonic
|
||||
if (mySensorUltrasonic != nullptr) {
|
||||
mySensorUltrasonic->clear();
|
||||
@@ -187,6 +206,11 @@ void clearVectors() {
|
||||
mySensorBme280->clear();
|
||||
}
|
||||
#endif
|
||||
#ifdef EnableSensorSht20
|
||||
if (mySensorSht20 != nullptr) {
|
||||
mySensorSht20->clear();
|
||||
}
|
||||
#endif
|
||||
#ifdef EnableSensorBmp280
|
||||
if (mySensorBmp280 != nullptr) {
|
||||
mySensorBmp280->clear();
|
||||
|
||||
@@ -154,8 +154,8 @@ boolean mqttConnect() {
|
||||
|
||||
if (connected) {
|
||||
SerialPrint("I", F("MQTT"), F("✔ connected"));
|
||||
if (currentBroker == 1) jsonWriteStr(configSetupJson, F("warning4"), F("<div style='margin-top:10px;margin-bottom:10px;'><font color='black'><p style='border: 1px solid #DCDCDC; border-radius: 3px; background-color: #8ef584; padding: 10px;'>Подключено к основному брокеру</p></font></div>"));
|
||||
if (currentBroker == 2) jsonWriteStr(configSetupJson, F("warning4"), F("<div style='margin-top:10px;margin-bottom:10px;'><font color='black'><p style='border: 1px solid #DCDCDC; border-radius: 3px; background-color: #8ef584; padding: 10px;'>Подключено к резервному брокеру</p></font></div>"));
|
||||
if (currentBroker == 1) jsonWriteStr(configSetupJson, F("warning4"), F("Подключено к основному брокеру"));
|
||||
if (currentBroker == 2) jsonWriteStr(configSetupJson, F("warning4"), F("Подключено к резервному брокеру"));
|
||||
setLedStatus(LED_OFF);
|
||||
mqttSubscribe();
|
||||
res = true;
|
||||
@@ -163,7 +163,7 @@ boolean mqttConnect() {
|
||||
mqttConnectAttempts++;
|
||||
SerialPrint("E", F("MQTT"), "🡆 Attempt No: " + String(mqttConnectAttempts) + " could't connect, retry in " + String(MQTT_RECONNECT_INTERVAL / 1000) + "s");
|
||||
setLedStatus(LED_FAST);
|
||||
jsonWriteStr(configSetupJson, F("warning4"), F("<div style='margin-top:10px;margin-bottom:10px;'><font color='black'><p style='border: 1px solid #DCDCDC; border-radius: 3px; background-color: #fa987a; padding: 10px;'>Не подключено брокеру</p></font></div>"));
|
||||
jsonWriteStr(configSetupJson, F("warning4"), F("Не подключено брокеру"));
|
||||
if (mqttConnectAttempts >= CHANGE_BROKER_AFTER) {
|
||||
mqttConnectAttempts = 0;
|
||||
if (isSecondBrokerSet()) {
|
||||
@@ -180,14 +180,14 @@ boolean mqttConnect() {
|
||||
|
||||
void mqttCallback(char* topic, uint8_t* payload, size_t length) {
|
||||
String topicStr = String(topic);
|
||||
//SerialPrint("I", "=>MQTT", topicStr);
|
||||
// SerialPrint("I", "=>MQTT", topicStr);
|
||||
String payloadStr;
|
||||
payloadStr.reserve(length + 1);
|
||||
for (size_t i = 0; i < length; i++) {
|
||||
payloadStr += (char)payload[i];
|
||||
}
|
||||
|
||||
//SerialPrint("I", "=>MQTT", payloadStr);
|
||||
// SerialPrint("I", "=>MQTT", payloadStr);
|
||||
|
||||
if (payloadStr.startsWith("HELLO")) {
|
||||
SerialPrint("I", F("MQTT"), F("Full update"));
|
||||
@@ -224,6 +224,7 @@ void mqttCallback(char* topic, uint8_t* payload, size_t length) {
|
||||
String key = selectFromMarkerToMarker(topicStr, "/", 3);
|
||||
SerialPrint("I", F("=>MQTT"), "Received event from other device: '" + devId + "' " + key + " " + payloadStr);
|
||||
String event = key + " " + payloadStr + ",";
|
||||
jsonWriteStr(configLiveJson, key, payloadStr);
|
||||
eventBuf += event;
|
||||
}
|
||||
}
|
||||
@@ -321,8 +322,8 @@ void publishWidgets() {
|
||||
line = all_widgets.substring(psn_1, psn_2);
|
||||
line.replace("\n", "");
|
||||
line.replace("\r\n", "");
|
||||
//jsonWriteStr(line, "id", String(counter));
|
||||
//jsonWriteStr(line, "pageId", String(counter));
|
||||
// jsonWriteStr(line, "id", String(counter));
|
||||
// jsonWriteStr(line, "pageId", String(counter));
|
||||
counter++;
|
||||
sendMQTT("config", line);
|
||||
Serial.println("[V] " + line);
|
||||
@@ -415,3 +416,14 @@ const String getStateStr() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
String getAllJson() {
|
||||
String str;
|
||||
if (configLiveJson != "{}") {
|
||||
str += configLiveJson;
|
||||
}
|
||||
if (configStoreJson != "{}") {
|
||||
str += "," + configStoreJson;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,15 @@
|
||||
|
||||
//для того что бы выключить оригинальный лог нужно перейти в файл библиотеки MyGatewayTransportSerial.cpp
|
||||
//и заккоментировать строку 36 MY_SERIALDEVICE.print(protocolMyMessage2Serial(message));
|
||||
|
||||
boolean publishAnyJsonKeyWS(const String& topic, const String& key, const String& data) {
|
||||
String path = mqttRootDevice + "/" + topic + "/status";
|
||||
String json = "{}";
|
||||
jsonWriteStr(json, key, data);
|
||||
//добавляем топик, выводим в ws
|
||||
String MyJson = json;
|
||||
jsonWriteStr(MyJson, "topic", path);
|
||||
ws.textAll(MyJson);
|
||||
}
|
||||
void loopMySensorsExecute() {
|
||||
if (mysensorBuf.length()) {
|
||||
String tmp = selectToMarker(mysensorBuf, ";");
|
||||
@@ -27,9 +35,15 @@ void loopMySensorsExecute() {
|
||||
if (command == "3") { //это особое внутреннее сообщение
|
||||
if (type == "11") { //название ноды
|
||||
SerialPrint("I", "MySensor", "Node name: " + value);
|
||||
}
|
||||
//*
|
||||
publishAnyJsonKey("MySensors", "Node name:", value);
|
||||
publishAnyJsonKeyWS("MySensors", "Node name:", value);
|
||||
}
|
||||
if (type == "12") { //версия ноды
|
||||
SerialPrint("I", "MySensor", "Node version: " + value);
|
||||
//*
|
||||
publishAnyJsonKey("MySensors", "Node version: ", value);
|
||||
publishAnyJsonKeyWS("MySensors", "Node version: ", value);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -44,13 +58,26 @@ void loopMySensorsExecute() {
|
||||
addItemAuto(num, key, widget, descr);
|
||||
descr.replace("#", " ");
|
||||
SerialPrint("I", "MySensor", "Add new item: " + key + ": " + descr);
|
||||
//*
|
||||
publishAnyJsonKey("MySensors", key, descr);
|
||||
publishAnyJsonKeyWS("MySensors", key, descr);
|
||||
|
||||
|
||||
} else {
|
||||
descr.replace("#", " ");
|
||||
SerialPrint("I", "MySensor", "Item already exist: " + key + ": " + descr);
|
||||
|
||||
//*
|
||||
publishAnyJsonKey("MySensors", key, descr);
|
||||
publishAnyJsonKeyWS("MySensors", key, descr);
|
||||
}
|
||||
} else {
|
||||
descr.replace("#", " ");
|
||||
SerialPrint("I", "MySensor", "Presentation: " + key + ": " + descr);
|
||||
|
||||
//*
|
||||
publishAnyJsonKey("MySensors", key, descr);
|
||||
publishAnyJsonKeyWS("MySensors", key, descr);
|
||||
}
|
||||
}
|
||||
if (command == "1") { //это данные
|
||||
@@ -63,6 +90,9 @@ void loopMySensorsExecute() {
|
||||
if (mySensorNode != nullptr) {
|
||||
for (unsigned int i = 0; i < mySensorNode->size(); i++) {
|
||||
mySensorNode->at(i).onChange(value, key); //вызываем поочередно все экземпляры, там где подойдет там и выполнится
|
||||
//*
|
||||
publishAnyJsonKey("MySensors", key, value);
|
||||
publishAnyJsonKeyWS("MySensors", key, value);
|
||||
}
|
||||
}
|
||||
SerialPrint("I", "MySensor", "node: " + nodeId + ", sensor: " + childSensorId + ", command: " + command + ", type: " + type + ", val: " + value);
|
||||
|
||||
@@ -59,7 +59,7 @@ void telegramMsgParse(String msg) {
|
||||
SerialPrint("<-", F("Telegram"), "chat ID: " + String(jsonReadInt(configSetupJson, "chatId")) + ", msg: " + String(msg));
|
||||
} else if (msg.indexOf("get") != -1) {
|
||||
msg = deleteBeforeDelimiter(msg, "_");
|
||||
myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), getValue(msg)); //jsonReadStr(configLiveJson , msg));
|
||||
myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), getValue(msg)); // jsonReadStr(configLiveJson , msg));
|
||||
SerialPrint("<-", F("Telegram"), "chat ID: " + String(jsonReadInt(configSetupJson, "chatId")) + ", msg: " + String(msg));
|
||||
} else if (msg.indexOf("all") != -1) {
|
||||
String list = returnListOfParams();
|
||||
@@ -74,8 +74,21 @@ void telegramMsgParse(String msg) {
|
||||
void sendTelegramMsg() {
|
||||
String sabject = sCmd.next();
|
||||
String msg = sCmd.next();
|
||||
String ID_name = "";
|
||||
String ID_value = "";
|
||||
if (sabject == "often") {
|
||||
msg.replace("#", " ");
|
||||
msg.replace("%date%", timeNow->getDateTimeDotFormated());
|
||||
msg.replace("%weekday%", timeNow->getWeekday());
|
||||
msg.replace("%IP%", jsonReadStr(configSetupJson, F("ip")));
|
||||
msg.replace("%name%", jsonReadStr(configSetupJson, F("name")));
|
||||
if (msg.indexOf("_") != -1) {
|
||||
ID_name = deleteBeforeDelimiter(msg, "_");
|
||||
ID_name = deleteAfterDelimiter(ID_name, "_");
|
||||
ID_value = getValue(ID_name);
|
||||
msg.replace(ID_name, ID_value);
|
||||
}
|
||||
msg.replace("_", " ");
|
||||
myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), msg);
|
||||
SerialPrint("<-", F("Telegram"), "chat ID: " + String(jsonReadInt(configSetupJson, "chatId")) + ", msg: " + msg);
|
||||
} else {
|
||||
@@ -84,6 +97,18 @@ void sendTelegramMsg() {
|
||||
jsonWriteStr(telegramMsgJson, sabject, msg);
|
||||
msg.replace("#", " ");
|
||||
sabject.replace("#", " ");
|
||||
msg.replace("%date%", timeNow->getDateTimeDotFormated());
|
||||
msg.replace("%weekday%", timeNow->getWeekday());
|
||||
msg.replace("%IP%", jsonReadStr(configSetupJson, F("ip")));
|
||||
msg.replace("%name%", jsonReadStr(configSetupJson, F("name")));
|
||||
if (msg.indexOf("_") != -1) {
|
||||
ID_name = deleteBeforeDelimiter(msg, "_");
|
||||
ID_name = deleteAfterDelimiter(ID_name, "_");
|
||||
ID_value = getValue(ID_name);
|
||||
msg.replace(ID_name, ID_value);
|
||||
}
|
||||
msg.replace("_", " ");
|
||||
|
||||
myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), msg);
|
||||
SerialPrint("<-", F("Telegram"), "chat ID: " + String(jsonReadInt(configSetupJson, "chatId")) + ", msg: " + msg);
|
||||
}
|
||||
@@ -110,7 +135,7 @@ String returnListOfParams() {
|
||||
count++;
|
||||
if (count > 1) {
|
||||
String id = selectFromMarkerToMarker(buf, ";", 2);
|
||||
String value = getValue(id); //jsonReadStr(configLiveJson , id);
|
||||
String value = getValue(id); // jsonReadStr(configLiveJson , id);
|
||||
String page = selectFromMarkerToMarker(buf, ";", 4);
|
||||
page.replace("#", " ");
|
||||
String name = selectFromMarkerToMarker(buf, ";", 5);
|
||||
|
||||
@@ -8,11 +8,14 @@
|
||||
#endif
|
||||
|
||||
#include "Global.h"
|
||||
|
||||
String msg = "";
|
||||
void upgradeInit() {
|
||||
|
||||
|
||||
myNotAsyncActions->add(
|
||||
do_UPGRADE, [&](void*) {
|
||||
upgrade_firmware(3);
|
||||
|
||||
},
|
||||
nullptr);
|
||||
|
||||
@@ -61,6 +64,8 @@ void getLastVersion() {
|
||||
}
|
||||
|
||||
void upgrade_firmware(int type) {
|
||||
|
||||
|
||||
String scenario_ForUpdate;
|
||||
String devconfig_ForUpdate;
|
||||
String configSetup_ForUpdate;
|
||||
@@ -84,6 +89,8 @@ void upgrade_firmware(int type) {
|
||||
|
||||
else if (type == 3) { //spiffs and build
|
||||
if (upgradeFS()) {
|
||||
String temp = jsonWriteInt(msg, "upgrade", 3 );
|
||||
ws.textAll(temp);
|
||||
writeFile(String(DEVICE_SCENARIO_FILE), scenario_ForUpdate);
|
||||
writeFile(String(DEVICE_CONFIG_FILE), devconfig_ForUpdate);
|
||||
writeFile("config.json", configSetup_ForUpdate);
|
||||
@@ -95,11 +102,18 @@ void upgrade_firmware(int type) {
|
||||
}
|
||||
}
|
||||
|
||||
bool upgradeFS() {
|
||||
bool ret = false;
|
||||
bool upgradeFS() {
|
||||
|
||||
|
||||
|
||||
bool ret = false;
|
||||
#ifndef esp8266_1mb
|
||||
WiFiClient wifiClient;
|
||||
|
||||
|
||||
|
||||
Serial.printf("Start upgrade %s, please wait...", FS_NAME);
|
||||
|
||||
#ifdef esp8266_4mb
|
||||
ESPhttpUpdate.rebootOnUpdate(false);
|
||||
t_httpUpdate_return retFS = ESPhttpUpdate.updateFS(wifiClient, serverIP + F("/projects/iotmanager/esp8266/littlefs/littlefs.bin"));
|
||||
@@ -117,6 +131,8 @@ bool upgradeFS() {
|
||||
HTTPUpdateResult retFS = httpUpdate.updateSpiffs(wifiClient, serverIP + F("/projects/iotmanager/esp32ms/littlefs/spiffs.bin"));
|
||||
#endif
|
||||
if (retFS == HTTP_UPDATE_OK) { //если FS обновилась успешно
|
||||
String temp = jsonWriteInt(msg, "upgrade", 2);
|
||||
ws.textAll(temp);
|
||||
SerialPrint("I", F("Update"), F("FS upgrade done!"));
|
||||
ret = true;
|
||||
}
|
||||
@@ -125,6 +141,8 @@ bool upgradeFS() {
|
||||
}
|
||||
|
||||
bool upgradeBuild() {
|
||||
String temp = jsonWriteInt(msg, "upgrade", 4 );
|
||||
ws.textAll(temp);
|
||||
bool ret = false;
|
||||
#ifndef esp8266_1mb
|
||||
WiFiClient wifiClient;
|
||||
@@ -149,12 +167,16 @@ bool upgradeBuild() {
|
||||
if (retBuild == HTTP_UPDATE_OK) { //если BUILD обновился успешно
|
||||
SerialPrint("I", F("Update"), F("BUILD upgrade done!"));
|
||||
ret = true;
|
||||
String temp = jsonWriteInt(msg, "upgrade", 5 );
|
||||
ws.textAll(temp);
|
||||
}
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
void restartEsp() {
|
||||
String temp = jsonWriteInt(msg, "upgrade", 6 );
|
||||
ws.textAll(temp);
|
||||
Serial.println(F("Restart ESP...."));
|
||||
delay(1000);
|
||||
ESP.restart();
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include "FileSystem.h"
|
||||
#include "Utils/StringUtils.h"
|
||||
#include "Utils\SerialPrint.h"
|
||||
#include "Utils/SerialPrint.h"
|
||||
|
||||
const String filepath(const String& filename) {
|
||||
return filename.startsWith("/") ? filename : "/" + filename;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "Utils/JsonUtils.h"
|
||||
#include "Utils/FileUtils.h"
|
||||
|
||||
#include "Global.h"
|
||||
#include "Utils/FileUtils.h"
|
||||
|
||||
String jsonReadStr(String& json, String name) {
|
||||
DynamicJsonBuffer jsonBuffer;
|
||||
@@ -20,6 +21,12 @@ int jsonReadInt(String& json, String name) {
|
||||
return root[name];
|
||||
}
|
||||
|
||||
float jsonReadFloat(String& json, String name) {
|
||||
DynamicJsonBuffer jsonBuffer;
|
||||
JsonObject& root = jsonBuffer.parseObject(json);
|
||||
return root[name];
|
||||
}
|
||||
|
||||
String jsonWriteStr(String& json, String name, String value) {
|
||||
DynamicJsonBuffer jsonBuffer;
|
||||
JsonObject& root = jsonBuffer.parseObject(json);
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
#include "Utils\SerialPrint.h"
|
||||
|
||||
#include "Utils/SerialPrint.h"
|
||||
#include "Global.h"
|
||||
|
||||
void SerialPrint(String errorLevel, String module, String msg) {
|
||||
//if (module == "MySensor") {
|
||||
Serial.println(prettyMillis(millis()) + " [" + errorLevel + "] [" + module + "] " + msg);
|
||||
String logtoWS = jsonReadStr(configSetupJson, "logtoWS");
|
||||
if (logtoWS == "true"){
|
||||
ws.textAll(" [" + errorLevel + "] [" + module + "] " + msg);
|
||||
}
|
||||
String logtoMQTT = jsonReadStr(configSetupJson, "logtoMQTT");
|
||||
if (logtoMQTT == "true"){
|
||||
publishAnyJsonKey("log", "log", errorLevel + " " + module + " " + msg);
|
||||
}
|
||||
//}
|
||||
}
|
||||
@@ -62,6 +62,41 @@ String selectFromMarkerToMarker(String str, String tofind, int number) {
|
||||
return "not found";
|
||||
}
|
||||
|
||||
//преобразовываем байтовый массив в человеческий вид HEX в строке
|
||||
void hex2string(byte array[], unsigned int len, char buffer[])
|
||||
{
|
||||
for (unsigned int i = 0; i < len; i++)
|
||||
{
|
||||
byte nib1 = (array[i] >> 4) & 0x0F;
|
||||
byte nib2 = (array[i] >> 0) & 0x0F;
|
||||
buffer[i*2+0] = nib1 < 0xA ? '0' + nib1 : 'A' + nib1 - 0xA;
|
||||
buffer[i*2+1] = nib2 < 0xA ? '0' + nib2 : 'A' + nib2 - 0xA;
|
||||
}
|
||||
buffer[len*2] = '\0';
|
||||
}
|
||||
|
||||
inline unsigned char ChartoHex( char ch )
|
||||
{
|
||||
return ( ( ch >= 'A' ) ? ( ch - 'A' + 0xA ) : ( ch - '0' ) ) & 0x0F;
|
||||
}
|
||||
|
||||
// str - указатель на массив символов
|
||||
// bytes - выходной буфер
|
||||
// функция возвращает колл-во байт
|
||||
//
|
||||
int string2hex(const char* str, unsigned char* bytes )
|
||||
{
|
||||
unsigned char Hi, Lo;
|
||||
|
||||
int i = 0;
|
||||
while( ( Hi = *str++ ) && ( Lo = *str++ ) )
|
||||
{
|
||||
bytes[i++] = ( ChartoHex( Hi ) << 4 ) | ChartoHex( Lo );
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
uint8_t hexStringToUint8(String hex) {
|
||||
uint8_t tmp = strtol(hex.c_str(), NULL, 0);
|
||||
if (tmp >= 0x00 && tmp <= 0xFF) {
|
||||
@@ -120,6 +155,18 @@ boolean isDigitStr(const String& str) {
|
||||
return str.length();
|
||||
}
|
||||
|
||||
boolean isTimeStr(const String& str) {
|
||||
|
||||
for (size_t i = 0; i < str.length(); i++) {
|
||||
char latter = str.charAt(i);
|
||||
if (!isDigit(latter) && latter != ':') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (str.charAt(2) != ':') return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean isDigitDotCommaStr(const String& str) {
|
||||
for (size_t i = 0; i < str.length(); i++) {
|
||||
char latter = str.charAt(i);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "Utils/WiFiUtils.h"
|
||||
|
||||
#include "FileSystem.h"
|
||||
|
||||
void routerConnect() {
|
||||
@@ -63,7 +64,7 @@ bool startAPMode() {
|
||||
SerialPrint("I", "WIFI", "AP IP: " + myIP.toString());
|
||||
jsonWriteStr(configSetupJson, "ip", myIP.toString());
|
||||
|
||||
//if (jsonReadInt(configOptionJson, "pass_status") != 1) {
|
||||
// if (jsonReadInt(configOptionJson, "pass_status") != 1) {
|
||||
ts.add(
|
||||
WIFI_SCAN, 10 * 1000, [&](void*) {
|
||||
String sta_ssid = jsonReadStr(configSetupJson, "routerssid");
|
||||
@@ -88,7 +89,7 @@ boolean RouterFind(String ssid) {
|
||||
|
||||
if (n == -2) { //Сканирование не было запущено, запускаем
|
||||
SerialPrint("I", "WIFI", "start scanning");
|
||||
WiFi.scanNetworks(true, false); //async, show_hidden
|
||||
WiFi.scanNetworks(true, false); // async, show_hidden
|
||||
}
|
||||
|
||||
else if (n == -1) { //Сканирование все еще выполняется
|
||||
@@ -146,25 +147,25 @@ void wifiSignalInit() {
|
||||
|
||||
switch (RSSIquality()) {
|
||||
case 0:
|
||||
jsonWriteStr(configSetupJson, F("signal"), F("Уровень WiFi сигнала: <font color='red'>не подключено к роутеру</font>"));
|
||||
jsonWriteStr(configSetupJson, F("signal"), F("не подключено к роутеру"));
|
||||
break;
|
||||
case 1:
|
||||
jsonWriteStr(configSetupJson, F("signal"), F("Уровень WiFi сигнала: <font color='red'>нет сигнала</font>"));
|
||||
jsonWriteStr(configSetupJson, F("signal"), F("нет сигнала"));
|
||||
break;
|
||||
case 2:
|
||||
jsonWriteStr(configSetupJson, F("signal"), F("Уровень WiFi сигнала: <font color='red'>очень низкий</font>"));
|
||||
jsonWriteStr(configSetupJson, F("signal"), F("очень низкий"));
|
||||
break;
|
||||
case 3:
|
||||
jsonWriteStr(configSetupJson, F("signal"), F("Уровень WiFi сигнала: <font color='orange'>низкий</font>"));
|
||||
jsonWriteStr(configSetupJson, F("signal"), F("низкий"));
|
||||
break;
|
||||
case 4:
|
||||
jsonWriteStr(configSetupJson, F("signal"), F("Уровень WiFi сигнала: <font color='green'>хороший</font>"));
|
||||
jsonWriteStr(configSetupJson, F("signal"), F("хороший"));
|
||||
break;
|
||||
case 5:
|
||||
jsonWriteStr(configSetupJson, F("signal"), F("Уровень WiFi сигнала: <font color='green'>очень хороший</font>"));
|
||||
jsonWriteStr(configSetupJson, F("signal"), F("очень хороший"));
|
||||
break;
|
||||
case 6:
|
||||
jsonWriteStr(configSetupJson, F("signal"), F("Уровень WiFi сигнала: <font color='green'>отличный</font>"));
|
||||
jsonWriteStr(configSetupJson, F("signal"), F("отличный"));
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "Utils/StatUtils.h"
|
||||
#include "Utils/statUtils.h"
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <EEPROM.h>
|
||||
|
||||
42
src/Web.cpp
42
src/Web.cpp
@@ -1,4 +1,5 @@
|
||||
#include "Web.h"
|
||||
|
||||
#include "BufferExecute.h"
|
||||
#include "Class/NotAsync.h"
|
||||
#include "Global.h"
|
||||
@@ -28,13 +29,13 @@ void web_init() {
|
||||
if (request->hasArg(F("addPreset"))) {
|
||||
addPreset2(request->getParam(F("addPreset"))->value().toInt());
|
||||
|
||||
jsonWriteStr(configSetupJson, F("warning1"), F("<div style='margin-top:10px;margin-bottom:10px;'><font color='black'><p style='border: 1px solid #DCDCDC; border-radius: 3px; background-color: #ffc7c7; padding: 10px;'>Требуется перезагрузка</p></font></div>"));
|
||||
jsonWriteStr(configSetupJson, F("warning1"), F("Требуется перезагрузка"));
|
||||
|
||||
request->redirect(F("/?set.device"));
|
||||
}
|
||||
|
||||
if (request->hasArg(F("delChoosingItems"))) {
|
||||
jsonWriteStr(configSetupJson, F("warning1"), F("<div style='margin-top:10px;margin-bottom:10px;'><font color='black'><p style='border: 1px solid #DCDCDC; border-radius: 3px; background-color: #ffc7c7; padding: 10px;'>Требуется перезагрузка</p></font></div>"));
|
||||
jsonWriteStr(configSetupJson, F("warning1"), F("Требуется перезагрузка"));
|
||||
myNotAsyncActions->make(do_delChoosingItems);
|
||||
request->send(200);
|
||||
}
|
||||
@@ -44,7 +45,7 @@ void web_init() {
|
||||
#ifdef EnableLogging
|
||||
cleanLogAndData();
|
||||
#endif
|
||||
jsonWriteStr(configSetupJson, F("warning1"), F("<div style='margin-top:10px;margin-bottom:10px;'><font color='black'><p style='border: 1px solid #DCDCDC; border-radius: 3px; background-color: #ffc7c7; padding: 10px;'>Требуется перезагрузка</p></font></div>"));
|
||||
jsonWriteStr(configSetupJson, F("warning1"), F("Требуется перезагрузка"));
|
||||
request->redirect(F("/?set.device"));
|
||||
}
|
||||
|
||||
@@ -174,7 +175,7 @@ void web_init() {
|
||||
}
|
||||
|
||||
//==============================mqtt settings=============================================
|
||||
//primary
|
||||
// primary
|
||||
if (request->hasArg(F("mqttServer"))) {
|
||||
jsonWriteStr(configSetupJson, F("mqttServer"), request->getParam(F("mqttServer"))->value());
|
||||
saveConfig();
|
||||
@@ -206,7 +207,7 @@ void web_init() {
|
||||
myNotAsyncActions->make(do_MQTTPARAMSCHANGED);
|
||||
request->send(200);
|
||||
}
|
||||
//secondary
|
||||
// secondary
|
||||
if (request->hasArg(F("mqttServer2"))) {
|
||||
jsonWriteStr(configSetupJson, F("mqttServer2"), request->getParam(F("mqttServer2"))->value());
|
||||
saveConfig();
|
||||
@@ -240,7 +241,7 @@ void web_init() {
|
||||
}
|
||||
|
||||
if (request->hasArg("mqttsend")) {
|
||||
//myNotAsyncActions->make(do_MQTTUDP);
|
||||
// myNotAsyncActions->make(do_MQTTUDP);
|
||||
request->send(200);
|
||||
}
|
||||
|
||||
@@ -336,7 +337,7 @@ void web_init() {
|
||||
serverIP = jsonReadStr(configSetupJson, "serverip");
|
||||
request->send(200);
|
||||
}
|
||||
//set?order=button_1
|
||||
// set?order=button_1
|
||||
if (request->hasArg("order")) {
|
||||
String order = request->getParam("order")->value();
|
||||
order.replace("_", " ");
|
||||
@@ -351,7 +352,7 @@ void web_init() {
|
||||
request->send(200);
|
||||
}
|
||||
|
||||
//gate mode
|
||||
// gate mode
|
||||
|
||||
if (request->hasArg("gateAuto")) {
|
||||
bool value = request->getParam("gateAuto")->value().toInt();
|
||||
@@ -359,19 +360,18 @@ void web_init() {
|
||||
saveConfig();
|
||||
request->send(200);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
//server.on("/del", HTTP_GET, [](AsyncWebServerRequest* request) {
|
||||
// if (request->hasArg("file") && request->hasArg("line")) {
|
||||
// String fileName = request->getParam("file")->value();
|
||||
// Serial.println(fileName);
|
||||
// int line = request->getParam("line")->value().toInt();
|
||||
// Serial.println(line);
|
||||
// myNotAsyncActions->make(do_delChoosingItems);
|
||||
// request->redirect(F("/?set.device"));
|
||||
// }
|
||||
//});
|
||||
// server.on("/del", HTTP_GET, [](AsyncWebServerRequest* request) {
|
||||
// if (request->hasArg("file") && request->hasArg("line")) {
|
||||
// String fileName = request->getParam("file")->value();
|
||||
// Serial.println(fileName);
|
||||
// int line = request->getParam("line")->value().toInt();
|
||||
// Serial.println(line);
|
||||
// myNotAsyncActions->make(do_delChoosingItems);
|
||||
// request->redirect(F("/?set.device"));
|
||||
// }
|
||||
// });
|
||||
|
||||
server.on("/check", HTTP_GET, [](AsyncWebServerRequest* request) {
|
||||
myNotAsyncActions->make(do_GETLASTVERSION);
|
||||
@@ -402,8 +402,8 @@ void web_init() {
|
||||
});
|
||||
|
||||
/*
|
||||
* Upgrade
|
||||
*/
|
||||
* Upgrade
|
||||
*/
|
||||
server.on("/upgrade", HTTP_GET, [](AsyncWebServerRequest* request) {
|
||||
myNotAsyncActions->make(do_UPGRADE);
|
||||
request->send(200, "text/html");
|
||||
|
||||
@@ -3,7 +3,13 @@
|
||||
#include "Utils/FileUtils.h"
|
||||
#include "Utils/WebUtils.h"
|
||||
#include "FSEditor.h"
|
||||
#include "Upgrade.h"
|
||||
#include "Class/NotAsync.h"
|
||||
#include "items/vLogging.h"
|
||||
|
||||
int flagq ;
|
||||
AsyncWebSocket ws ("/ws");
|
||||
AsyncEventSource events("/events");
|
||||
namespace HttpServer {
|
||||
|
||||
|
||||
@@ -84,12 +90,100 @@ void init() {
|
||||
|
||||
SerialPrint("I", F("HTTP"), F("HttpServer Init"));
|
||||
}
|
||||
///////////
|
||||
|
||||
#ifndef LAYOUT_IN_RAM
|
||||
void publishWidgetsWS() {
|
||||
String str="";
|
||||
auto file = seekFile("layout.txt");
|
||||
if (!file) {
|
||||
SerialPrint("E", F("WS"), F("no file layout.txt"));
|
||||
return;
|
||||
}
|
||||
while (file.available()) {
|
||||
|
||||
String payload = file.readStringUntil('\n');
|
||||
if (str==""){
|
||||
str += payload;
|
||||
}else {str += "," + payload;}
|
||||
|
||||
}
|
||||
file.close();
|
||||
SerialPrint("I", "WS", "widgets: " + str);
|
||||
ws.textAll(str);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void publishStateWS() {
|
||||
String mystr="";
|
||||
String str;
|
||||
if (configLiveJson != "{}") {
|
||||
str += configLiveJson;
|
||||
}
|
||||
if (configStoreJson != "{}") {
|
||||
str += "," + configStoreJson;
|
||||
}
|
||||
|
||||
|
||||
|
||||
str.replace("{", "");
|
||||
str.replace("}", "");
|
||||
str.replace("\"", "");
|
||||
str += ",";
|
||||
|
||||
while (str.length() != 0) {
|
||||
String tmp = selectToMarker(str, ",");
|
||||
String topic = selectToMarker(tmp, ":");
|
||||
String state = deleteBeforeDelimiter(tmp, ":");
|
||||
|
||||
|
||||
if (topic != "" && state != "") {
|
||||
|
||||
String json = "{}";
|
||||
jsonWriteStr(json, "status", state);
|
||||
jsonWriteStr(json, "topic", mqttRootDevice + "/" + topic + "/status");
|
||||
SerialPrint("I", "ws", json.c_str());
|
||||
if (mystr==""){
|
||||
mystr += json;
|
||||
}else {mystr += "," + json;}
|
||||
|
||||
|
||||
}
|
||||
str = deleteBeforeDelimiter(str, ",");
|
||||
}
|
||||
ws.textAll(mystr);
|
||||
|
||||
}
|
||||
/*
|
||||
boolean publishStatusWS(const String& topic, const String& data) {
|
||||
String path = mqttRootDevice + "/" + topic + "/status";
|
||||
String json = "{}";
|
||||
jsonWriteStr(json, "status", data);
|
||||
String MyJson = json;
|
||||
jsonWriteStr(MyJson, "topic", path);
|
||||
ws.textAll(MyJson);
|
||||
|
||||
}
|
||||
*/
|
||||
boolean publishAnyJsonKeyWS(const String& topic, const String& key, const String& data) {
|
||||
String path = mqttRootDevice + "/" + topic + "/status";
|
||||
String json = "{}";
|
||||
jsonWriteStr(json, key, data);
|
||||
//добавляем топик, выводим в ws
|
||||
String MyJson = json;
|
||||
jsonWriteStr(MyJson, "topic", path);
|
||||
ws.textAll(MyJson);
|
||||
}
|
||||
#endif
|
||||
|
||||
/////////
|
||||
void onWsEvent(AsyncWebSocket *server, AsyncWebSocketClient *client, AwsEventType type, void *arg, uint8_t *data, size_t len) {
|
||||
#ifdef WS_enable
|
||||
#ifdef WEBSOCKET_ENABLED
|
||||
if (type == WS_EVT_CONNECT) {
|
||||
Serial.printf("ws[%s][%u] connect\n", server->url(), client->id());
|
||||
client->printf(json.c_str(), 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());
|
||||
@@ -116,6 +210,121 @@ void onWsEvent(AsyncWebSocket *server, AsyncWebSocketClient *client, AwsEventTyp
|
||||
}
|
||||
}
|
||||
Serial.printf("%s\n", msg.c_str());
|
||||
//->
|
||||
//если пришло HELLO публикуем виджеты и статусы
|
||||
if (msg.startsWith("HELLO")) {
|
||||
SerialPrint("I", F("WS"), F("Full update"));
|
||||
publishWidgetsWS();
|
||||
publishStateWS();
|
||||
flagq = 1;
|
||||
}
|
||||
//если пришло UPGRADE
|
||||
if (msg.startsWith("upgrade")) {
|
||||
// SerialPrint("I", F("WS"), F("do_UPGRADEstart"));
|
||||
myNotAsyncActions->make(do_UPGRADE);
|
||||
String temp = jsonWriteInt(msg, "upgrade", 1 );
|
||||
ws.textAll(temp);
|
||||
}
|
||||
|
||||
String upgrade = jsonReadStr(msg, "upgrade");
|
||||
|
||||
if (upgrade != ""){
|
||||
// SerialPrint("I", F("WS"), F("do_UPGRADE"));
|
||||
myNotAsyncActions->make(do_UPGRADE);
|
||||
String temp = jsonWriteInt(msg, "upgrade", 1 );
|
||||
ws.textAll(temp);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//отправляем конфигурацию на ESP
|
||||
if (msg.startsWith("getconfigsetupjson")) {
|
||||
ws.textAll(configSetupJson);
|
||||
// Serial.printf("%s\n", configSetupJson.c_str());
|
||||
}
|
||||
//отправляем NetworkMap в ESP
|
||||
if (msg.startsWith("getNetworkMap")) {
|
||||
String NetworkMap= readFile("NetworkMap.json", 409600);
|
||||
// NetworkMap = NetworkMap.replace("\r\n", "");
|
||||
ws.textAll(NetworkMap);
|
||||
|
||||
}
|
||||
|
||||
//отправляем файл в ESP
|
||||
String getFileName = jsonReadStr(msg, "getFileName");
|
||||
if (getFileName !=""){
|
||||
String getFile= readFile(getFileName, 409600);
|
||||
// getFile.replace("\n", " ");
|
||||
getFile="{getFileText:'"+getFile+"', getFileName: '"+getFileName+"'}";
|
||||
jsonWriteStr(getFile, "getFileName", getFileName);
|
||||
ws.textAll(getFile);
|
||||
Serial.printf("%s\n getFileName: ", getFileName.c_str());
|
||||
Serial.printf("%s\n getFile: ", getFile.c_str());
|
||||
}
|
||||
//получаем файл от ESP
|
||||
|
||||
String setFileName = jsonReadStr(msg, "setFileName");
|
||||
if (setFileName !=""){
|
||||
|
||||
|
||||
DynamicJsonBuffer jsonBuffer;
|
||||
JsonObject& root = jsonBuffer.parseObject(msg);
|
||||
|
||||
root.remove("setFileName");
|
||||
String newmsg;
|
||||
root.printTo(newmsg);
|
||||
|
||||
|
||||
writeFile(setFileName,newmsg);
|
||||
//Serial.printf("%s\n setFileName: ", setFileName.c_str());
|
||||
Serial.printf("%s\n text: ", newmsg.c_str());
|
||||
}
|
||||
|
||||
//получаем NetworkMap от ESP
|
||||
String NetworkMap = jsonReadStr(msg, "NetworkMap");
|
||||
if (NetworkMap !=""){
|
||||
writeFile("NetworkMap.json", NetworkMap.c_str());
|
||||
// ws.textAll(NetworkMap);
|
||||
}
|
||||
//перезагрузка
|
||||
String command = jsonReadStr(msg, "command");
|
||||
if (command !="" && jsonReadStr(msg, "command")=="reboot"){
|
||||
ESP.restart();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//получаем конфигурацию от ESP
|
||||
|
||||
String changeConf = jsonReadStr(msg, "setconfigsetupjson");
|
||||
if (changeConf = "1"){
|
||||
|
||||
jsonWriteStr(configSetupJson, jsonReadStr(msg, "name"), jsonReadStr(msg, "val"));
|
||||
saveConfig();
|
||||
Serial.printf("%s\n", jsonReadStr(msg, "name").c_str(), jsonReadStr(msg, "val").c_str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
// если пришло в control управляем
|
||||
String path = jsonReadStr(msg, "path");
|
||||
String status = jsonReadStr(msg, "status");
|
||||
|
||||
if (path.indexOf("control") != -1) {
|
||||
String key = selectFromMarkerToMarker(path, "/", 3);
|
||||
|
||||
String order;
|
||||
order += key;
|
||||
order += " ";
|
||||
order += status;
|
||||
order += ",";
|
||||
|
||||
loopCmdAdd(order);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (info->opcode == WS_TEXT)
|
||||
client->text("{}");
|
||||
@@ -200,7 +409,7 @@ void initOta() {
|
||||
}
|
||||
|
||||
void initWS() {
|
||||
#ifdef WS_enable
|
||||
#ifdef WEBSOCKET_ENABLED
|
||||
ws.onEvent(onWsEvent);
|
||||
server.addHandler(&ws);
|
||||
events.onConnect([](AsyncEventSourceClient *client) {
|
||||
|
||||
138
src/YourSensor.cpp
Normal file
138
src/YourSensor.cpp
Normal file
@@ -0,0 +1,138 @@
|
||||
#include "YourSensor.h"
|
||||
|
||||
#include "Global.h"
|
||||
#include "Utils/JsonUtils.h"
|
||||
#include "Utils/StringUtils.h"
|
||||
|
||||
//подключаем необходимые файлы библиотеки
|
||||
//#include "Adafruit_ADS1X15.h"
|
||||
#include "Adafruit_AHTX0.h"
|
||||
#include "BH1750.h"
|
||||
#include "ClosedCube_HDC1080.h"
|
||||
//#include "LiquidCrystal_I2C.h"
|
||||
|
||||
//создаем объект HDC1080
|
||||
ClosedCube_HDC1080 hdc1080;
|
||||
|
||||
//создаем объект AHTX0
|
||||
Adafruit_AHTX0 aht;
|
||||
Adafruit_Sensor *aht_humidity, *aht_temp;
|
||||
sensors_event_t tmpEvent_t;
|
||||
|
||||
//создаем объект LCD
|
||||
//LiquidCrystal_I2C LCD(0x27, 16, 2);
|
||||
|
||||
//создаем объект BH1750
|
||||
BH1750 lightMeter;
|
||||
|
||||
//создаем объект ADS1015
|
||||
// Adafruit_ADS1015 ads;
|
||||
|
||||
// co2 sensor
|
||||
//SoftwareSerial K_30_Serial(13, 15); //Программный порт
|
||||
byte readCO2[] = {0xFE, 0X44, 0X00, 0X08, 0X02, 0X9F, 0X25}; //Команды для запроса показаний с датчика
|
||||
byte response[] = {0, 0, 0, 0, 0, 0, 0}; //массив для ответа от датчика
|
||||
unsigned long getValue(byte packet[]) {
|
||||
int high = packet[3]; //верхний байт показания СО2
|
||||
int low = packet[4]; //нижний байт показания СО2
|
||||
unsigned long val_1 = high * 256 + low; //соединяем байты
|
||||
return val_1;
|
||||
}
|
||||
void sendRequest(byte packet[]) {
|
||||
//while (!K_30_Serial.available()) {
|
||||
// K_30_Serial.write(readCO2, 7);
|
||||
// delay(50);
|
||||
//}
|
||||
}
|
||||
|
||||
float yourSensorReading(String type, String paramsAny) {
|
||||
float value;
|
||||
//========================================================HDC1080================================================================
|
||||
if (type == "HDC1080_temp") {
|
||||
HDC1080_init(jsonReadStr(paramsAny, "addr"));
|
||||
value = hdc1080.readTemperature();
|
||||
}
|
||||
if (type == "HDC1080_hum") {
|
||||
HDC1080_init(jsonReadStr(paramsAny, "addr"));
|
||||
value = hdc1080.readHumidity();
|
||||
}
|
||||
//==========================================================AHTX0=================================================================
|
||||
if (type == "AHTX0_temp") {
|
||||
AHTX0_init();
|
||||
aht_temp->getEvent(&tmpEvent_t);
|
||||
value = tmpEvent_t.temperature;
|
||||
}
|
||||
if (type == "AHTX0_hum") {
|
||||
AHTX0_init();
|
||||
aht_humidity->getEvent(&tmpEvent_t);
|
||||
value = tmpEvent_t.relative_humidity;
|
||||
}
|
||||
//==========================================================LCD=================================================================
|
||||
//if (type == "LCD") {
|
||||
//LCD_init();
|
||||
// LCD.setCursor(jsonReadInt(paramsAny, "c"), jsonReadInt(paramsAny, "k"));
|
||||
// String toPrint = jsonReadStr(paramsAny, "descr") + " " + jsonReadStr(configLiveJson, jsonReadStr(paramsAny, "val"));
|
||||
// LCD.print(toPrint);
|
||||
//}
|
||||
//==========================================================BH1750=================================================================
|
||||
if (type == "BH1750_lux") {
|
||||
BH1750_init();
|
||||
value = lightMeter.readLightLevel();
|
||||
}
|
||||
//==========================================================co2=================================================================
|
||||
if (type == "valCO2") {
|
||||
//K_30_Serial.begin(9600);
|
||||
//sendRequest(readCO2);
|
||||
//int valCO2 = getValue(response);
|
||||
//value = valCO2;
|
||||
// Serial.println(valCO2);
|
||||
}
|
||||
//==========================================================timer=================================================================
|
||||
if (type == "timer") {
|
||||
value = jsonReadFloat(configLiveJson, jsonReadStr(paramsAny, "val"));
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
void HDC1080_init(String addr) {
|
||||
static bool HDC1080_flag = true;
|
||||
if (HDC1080_flag) {
|
||||
hdc1080.begin(hexStringToUint8(addr));
|
||||
HDC1080_flag = false;
|
||||
}
|
||||
}
|
||||
|
||||
void AHTX0_init() {
|
||||
static bool AHTX0_flag = true;
|
||||
if (AHTX0_flag) {
|
||||
if (!aht.begin()) {
|
||||
Serial.println("Failed to find AHT10/AHT20 chip");
|
||||
// return -127;
|
||||
}
|
||||
aht_temp = aht.getTemperatureSensor();
|
||||
aht_temp->printSensorDetails();
|
||||
|
||||
aht_humidity = aht.getHumiditySensor();
|
||||
aht_humidity->printSensorDetails();
|
||||
AHTX0_flag = false;
|
||||
}
|
||||
}
|
||||
|
||||
//void LCD_init() {
|
||||
//static bool LCD_flag = true;
|
||||
//if (LCD_flag) {
|
||||
//LCD.init(); //инициализация дисплея
|
||||
//LCD.backlight(); //включаем подсветку
|
||||
//}
|
||||
//LCD_flag = false;
|
||||
//}
|
||||
|
||||
void BH1750_init() {
|
||||
static bool BH1750_flag = true;
|
||||
if (BH1750_flag) {
|
||||
lightMeter.begin();
|
||||
|
||||
BH1750_flag = false;
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "Global.h"
|
||||
#include "SoftUART.h"
|
||||
#include "items/vButtonOut.h"
|
||||
//#include "WebServer.h"
|
||||
//this class save data to flash
|
||||
ButtonOut::ButtonOut(String pin, boolean inv, String key, String type) {
|
||||
_pin = pin;
|
||||
@@ -21,6 +22,12 @@ ButtonOut::ButtonOut(String pin, boolean inv, String key, String type) {
|
||||
this->execute(String(state)); //установили это состояние
|
||||
#endif
|
||||
#ifdef GATE_MODE
|
||||
if (_pin != "") {
|
||||
pinMode(_pin.toInt(), OUTPUT);
|
||||
}
|
||||
int state = jsonReadInt(configStoreJson, key); //прочитали из памяти
|
||||
this->execute(String(state)); //установили это состояние
|
||||
|
||||
//TO DO запросили ноду о состоянии реле
|
||||
//установили в это состояние кнопку в приложении
|
||||
//если нода не ответила - кнопку сделать красным цветом
|
||||
@@ -44,6 +51,20 @@ void ButtonOut::execute(String state) {
|
||||
}
|
||||
#endif
|
||||
#ifdef GATE_MODE
|
||||
// включаем кнопки на ESP гейта
|
||||
if (state != "" && _pin != "") {
|
||||
if (state == "change") {
|
||||
state = String(!digitalRead(_pin.toInt()));
|
||||
digitalWrite(_pin.toInt(), state.toInt());
|
||||
} else {
|
||||
if (_inv) {
|
||||
digitalWrite(_pin.toInt(), !state.toInt());
|
||||
} else {
|
||||
digitalWrite(_pin.toInt(), state.toInt());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//отправили ноде команду на вкл выкл
|
||||
//получили обратную связь - переставили кнопку в приложении
|
||||
//не получили обратную связь - сделали кнопку красной
|
||||
@@ -52,6 +73,12 @@ void ButtonOut::execute(String state) {
|
||||
jsonWriteInt(configStoreJson, _key, state.toInt());
|
||||
saveStore();
|
||||
publishStatus(_key, state);
|
||||
String path = mqttRootDevice + "/" + _key + "/status";
|
||||
String json = "{}";
|
||||
jsonWriteStr(json, "status", state);
|
||||
String MyJson = json;
|
||||
jsonWriteStr(MyJson, "topic", path);
|
||||
ws.textAll(MyJson);
|
||||
}
|
||||
|
||||
MyButtonOutVector* myButtonOut = nullptr;
|
||||
|
||||
@@ -32,6 +32,12 @@ void CountDownClass::loop() {
|
||||
String time = String(prettyMillis(sec * 1000));
|
||||
jsonWriteStr(configLiveJson, _key, time);
|
||||
publishStatus(_key, time);
|
||||
String path = mqttRootDevice + "/" + _key + "/status";
|
||||
String json = "{}";
|
||||
jsonWriteStr(json, "status", time);
|
||||
String MyJson = json;
|
||||
jsonWriteStr(MyJson, "topic", path);
|
||||
ws.textAll(MyJson);
|
||||
sec--;
|
||||
if (sec < 0) {
|
||||
_countDownPeriod = 0;
|
||||
@@ -48,10 +54,8 @@ void countDown() {
|
||||
|
||||
countDown_EnterCounter++;
|
||||
addKey(key, countDown_KeyList, countDown_EnterCounter);
|
||||
|
||||
//Serial.println(countDown_EnterCounter);
|
||||
//Serial.println(countDown_KeyList);
|
||||
|
||||
static bool firstTime = true;
|
||||
if (firstTime) myCountDown = new MyCountDownVector();
|
||||
firstTime = false;
|
||||
|
||||
@@ -24,7 +24,7 @@ void ImpulsOutClass::loop() {
|
||||
currentMillis = millis();
|
||||
difference = currentMillis - prevMillis;
|
||||
if (_impulsCountBuf > 0) {
|
||||
if (difference > _impulsPeriod) {
|
||||
if (difference >= _impulsPeriod) {
|
||||
_impulsCountBuf--;
|
||||
prevMillis = millis();
|
||||
yield();
|
||||
|
||||
@@ -31,6 +31,12 @@ void Input::execute(String value) {
|
||||
jsonWriteStr(configStoreJson, _key, value);
|
||||
saveStore();
|
||||
publishStatus(_key, value);
|
||||
String path = mqttRootDevice + "/" + _key + "/status";
|
||||
String json = "{}";
|
||||
jsonWriteStr(json, "status", value);
|
||||
String MyJson = json;
|
||||
jsonWriteStr(MyJson, "topic", path);
|
||||
ws.textAll(MyJson);
|
||||
}
|
||||
|
||||
MyInputVector* myInput = nullptr;
|
||||
|
||||
@@ -166,7 +166,78 @@ void loggingExecute() {
|
||||
}
|
||||
}
|
||||
|
||||
void choose_log_date_and_sendWS() {
|
||||
|
||||
String all_line = logging_KeyList;
|
||||
while (all_line.length() != 0) {
|
||||
String tmp = selectToMarker(all_line, ",");
|
||||
sendLogDataWS("/logs/" + tmp + ".txt", tmp);
|
||||
all_line = deleteBeforeDelimiter(all_line, ",");
|
||||
}
|
||||
}
|
||||
|
||||
void sendLogDataWS(String file, String topic) {
|
||||
File configFile = FileFS.open(file, "r");
|
||||
if (!configFile) {
|
||||
return;
|
||||
}
|
||||
configFile.seek(0, SeekSet);
|
||||
int i = 0;
|
||||
String buf = "{}";
|
||||
String json_array;
|
||||
String unix_time;
|
||||
String value;
|
||||
unsigned int psn;
|
||||
unsigned int sz = configFile.size();
|
||||
do {
|
||||
i++;
|
||||
psn = configFile.position();
|
||||
String line = configFile.readStringUntil('\n');
|
||||
unix_time = selectToMarker(line, " ");
|
||||
jsonWriteInt(buf, "x", unix_time.toInt());
|
||||
value = deleteBeforeDelimiter(line, " ");
|
||||
jsonWriteFloat(buf, "y1", value.toFloat());
|
||||
if (unix_time != "" || value != "") {
|
||||
json_array += buf + ",";
|
||||
}
|
||||
int grafmax = jsonReadInt(configSetupJson, "grafmax");
|
||||
if (grafmax != 0) {
|
||||
if (i >= grafmax) {
|
||||
json_array = "{\"status\":[" + json_array + "]}";
|
||||
json_array.replace("},]}", "}]}");
|
||||
// publishChart(topic, json_array);
|
||||
|
||||
// добавляем топик, выводим в ws
|
||||
String path = mqttRootDevice + "/" + topic;
|
||||
String json = "{}";
|
||||
json=json_array;
|
||||
jsonWriteStr(json, "topic", path);
|
||||
ws.textAll(json);
|
||||
|
||||
|
||||
json_array = "";
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
} while (psn < sz);
|
||||
|
||||
configFile.close();
|
||||
|
||||
json_array = "{\"status\":[" + json_array + "]}";
|
||||
json_array.replace("},]}", "}]}");
|
||||
//publishChart(topic, json_array);
|
||||
|
||||
// добавляем топик, выводим в ws
|
||||
String path = mqttRootDevice + "/" + topic;
|
||||
String json = "{}";
|
||||
json=json_array;
|
||||
jsonWriteStr(json, "topic", path);
|
||||
ws.textAll(json);
|
||||
|
||||
}
|
||||
|
||||
void choose_log_date_and_send() {
|
||||
|
||||
String all_line = logging_KeyList;
|
||||
while (all_line.length() != 0) {
|
||||
String tmp = selectToMarker(all_line, ",");
|
||||
@@ -205,7 +276,8 @@ void sendLogData(String file, String topic) {
|
||||
json_array = "{\"status\":[" + json_array + "]}";
|
||||
json_array.replace("},]}", "}]}");
|
||||
publishChart(topic, json_array);
|
||||
json_array = "";
|
||||
|
||||
json_array = "";
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
@@ -216,6 +288,7 @@ void sendLogData(String file, String topic) {
|
||||
json_array = "{\"status\":[" + json_array + "]}";
|
||||
json_array.replace("},]}", "}]}");
|
||||
publishChart(topic, json_array);
|
||||
|
||||
}
|
||||
|
||||
void cleanLogAndData() {
|
||||
|
||||
@@ -19,6 +19,12 @@ void Output::execute(String value) {
|
||||
eventGen2(_key, value);
|
||||
jsonWriteStr(configLiveJson, _key, value);
|
||||
publishStatus(_key, value);
|
||||
String path = mqttRootDevice + "/" + _key + "/status";
|
||||
String json = "{}";
|
||||
jsonWriteStr(json, "status", value);
|
||||
String MyJson = json;
|
||||
jsonWriteStr(MyJson, "topic", path);
|
||||
ws.textAll(MyJson);
|
||||
//publishLastUpdateTime(_key, timeNow->getTime());
|
||||
}
|
||||
|
||||
@@ -46,6 +52,9 @@ void outputExecute() {
|
||||
|
||||
value.replace("#", " ");
|
||||
value.replace("%date%", timeNow->getDateTimeDotFormated());
|
||||
value.replace("%weekday%", timeNow->getWeekday());
|
||||
value.replace("%IP%", jsonReadStr(configSetupJson, F("ip")));
|
||||
value.replace("%name%", jsonReadStr(configSetupJson, F("name")));
|
||||
|
||||
int number = getKeyNum(key, output_KeyList);
|
||||
|
||||
|
||||
@@ -25,6 +25,12 @@ void PwmOut::execute(String state) {
|
||||
jsonWriteInt(configStoreJson, _key, state.toInt());
|
||||
saveStore();
|
||||
publishStatus(_key, state);
|
||||
String path = mqttRootDevice + "/" + _key + "/status";
|
||||
String json = "{}";
|
||||
jsonWriteStr(json, "status", state);
|
||||
String MyJson = json;
|
||||
jsonWriteStr(MyJson, "topic", path);
|
||||
ws.textAll(MyJson);
|
||||
}
|
||||
|
||||
MyPwmOutVector* myPwmOut = nullptr;
|
||||
|
||||
@@ -45,6 +45,12 @@ void SensorAnalog::readAnalog() {
|
||||
eventGen2(_key, String(valueFloat));
|
||||
jsonWriteStr(configLiveJson, _key, String(valueFloat));
|
||||
publishStatus(_key, String(valueFloat));
|
||||
String path = mqttRootDevice + "/" + _key + "/status";
|
||||
String json = "{}";
|
||||
jsonWriteStr(json, "status", String(valueFloat));
|
||||
String MyJson = json;
|
||||
jsonWriteStr(MyJson, "topic", path);
|
||||
ws.textAll(MyJson);
|
||||
SerialPrint("I", "Sensor", "'" + _key + "' data: " + String(valueFloat));
|
||||
}
|
||||
|
||||
|
||||
92
src/items/vSensorAny.cpp
Normal file
92
src/items/vSensorAny.cpp
Normal file
@@ -0,0 +1,92 @@
|
||||
#include "Consts.h"
|
||||
#ifdef EnableSensorAny
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "BufferExecute.h"
|
||||
#include "Class/LineParsing.h"
|
||||
#include "Global.h"
|
||||
#include "YourSensor.h"
|
||||
#include "items/vSensorAny.h"
|
||||
|
||||
SensorAny::SensorAny(const String& paramsAny) {
|
||||
_paramsAny = paramsAny;
|
||||
|
||||
_interval = jsonReadInt(_paramsAny, "int");
|
||||
_c = jsonReadFloat(_paramsAny, "c");
|
||||
_k = jsonReadFloat(_paramsAny, "k");
|
||||
_key = jsonReadStr(_paramsAny, "key");
|
||||
_addr = jsonReadStr(_paramsAny, "addr");
|
||||
_type = jsonReadStr(_paramsAny, "type");
|
||||
_val = jsonReadStr(_paramsAny, "val");
|
||||
_descr = jsonReadStr(_paramsAny, "descr");
|
||||
}
|
||||
|
||||
SensorAny::~SensorAny() {}
|
||||
|
||||
void SensorAny::loop() {
|
||||
difference = millis() - prevMillis;
|
||||
if (difference >= _interval * 1000) {
|
||||
prevMillis = millis();
|
||||
read();
|
||||
}
|
||||
}
|
||||
|
||||
void SensorAny::read() {
|
||||
float value = yourSensorReading(_type, _paramsAny);
|
||||
|
||||
value = value * _c;
|
||||
|
||||
eventGen2(_key, String(value));
|
||||
jsonWriteStr(configLiveJson, _key, String(value));
|
||||
publishStatus(_key, String(value));
|
||||
String path = mqttRootDevice + "/" + _key + "/status";
|
||||
String json = "{}";
|
||||
jsonWriteStr(json, "status", String(value));
|
||||
String MyJson = json;
|
||||
jsonWriteStr(MyJson, "topic", path);
|
||||
ws.textAll(MyJson);
|
||||
SerialPrint("I", "Sensor", "'" + _key + "' data: " + String(value));
|
||||
}
|
||||
|
||||
MySensorAnyVector* mySensorAny = nullptr;
|
||||
|
||||
void AnySensorExecute() {
|
||||
String key = sCmd.order();
|
||||
String command = sCmd.next();
|
||||
|
||||
if (command == "cmd1") {
|
||||
SerialPrint("I", "Sensor", key + " выполняет cmd1 без параметра");
|
||||
}
|
||||
else if (command == "cmd2") {
|
||||
String par = sCmd.next();
|
||||
SerialPrint("I", "Sensor", key + " выполняет cmd2 c параметром " + par);
|
||||
}
|
||||
else if (command == "cmd3") {
|
||||
String par = sCmd.next();
|
||||
SerialPrint("I", "Sensor", key + " выполняет cmd3 c параметром " + par);
|
||||
}
|
||||
}
|
||||
|
||||
void AnySensor() {
|
||||
String params = "{}";
|
||||
myLineParsing.update();
|
||||
String key = myLineParsing.gkey();
|
||||
jsonWriteStr(params, "key", key);
|
||||
jsonWriteStr(params, "addr", myLineParsing.gaddr());
|
||||
jsonWriteStr(params, "int", myLineParsing.gint());
|
||||
jsonWriteStr(params, "c", myLineParsing.gc());
|
||||
jsonWriteStr(params, "k", myLineParsing.gk());
|
||||
jsonWriteStr(params, "val", myLineParsing.gval());
|
||||
jsonWriteStr(params, "type", myLineParsing.gtype());
|
||||
jsonWriteStr(params, "descr", myLineParsing.gdescr());
|
||||
myLineParsing.clear();
|
||||
|
||||
static bool firstTime = true;
|
||||
if (firstTime) {
|
||||
mySensorAny = new MySensorAnyVector();
|
||||
sCmd.addCommand(key.c_str(), AnySensorExecute);
|
||||
}
|
||||
firstTime = false;
|
||||
mySensorAny->push_back(SensorAny(params));
|
||||
}
|
||||
#endif
|
||||
@@ -48,16 +48,34 @@ void SensorBme280::read() {
|
||||
eventGen2(_paramsTmp.key, String(tmp));
|
||||
jsonWriteStr(configLiveJson, _paramsTmp.key, String(tmp));
|
||||
publishStatus(_paramsTmp.key, String(tmp));
|
||||
String path = mqttRootDevice + "/" +_paramsTmp.key + "/status";
|
||||
String json = "{}";
|
||||
jsonWriteStr(json, "status", String(tmp));
|
||||
String MyJson = json;
|
||||
jsonWriteStr(MyJson, "topic", path);
|
||||
ws.textAll(MyJson);
|
||||
SerialPrint("I", "Sensor", "'" + _paramsTmp.key + "' data: " + String(tmp));
|
||||
|
||||
eventGen2(_paramsHum.key, String(hum));
|
||||
jsonWriteStr(configLiveJson, _paramsHum.key, String(hum));
|
||||
publishStatus(_paramsHum.key, String(hum));
|
||||
path = mqttRootDevice + "/" +_paramsHum.key + "/status";
|
||||
json = "{}";
|
||||
jsonWriteStr(json, "status", String(hum));
|
||||
MyJson = json;
|
||||
jsonWriteStr(MyJson, "topic", path);
|
||||
ws.textAll(MyJson);
|
||||
SerialPrint("I", "Sensor", "'" + _paramsHum.key + "' data: " + String(hum));
|
||||
|
||||
eventGen2(_paramsPrs.key, String(prs));
|
||||
jsonWriteStr(configLiveJson, _paramsPrs.key, String(prs));
|
||||
publishStatus(_paramsPrs.key, String(prs));
|
||||
path = mqttRootDevice + "/" +_paramsPrs.key + "/status";
|
||||
json = "{}";
|
||||
jsonWriteStr(json, "status", String(prs));
|
||||
MyJson = json;
|
||||
jsonWriteStr(MyJson, "topic", path);
|
||||
ws.textAll(MyJson);
|
||||
SerialPrint("I", "Sensor", "'" + _paramsPrs.key + "' data: " + String(prs));
|
||||
}
|
||||
|
||||
|
||||
@@ -44,11 +44,23 @@ void SensorBmp280::read() {
|
||||
eventGen2(_paramsTmp.key, String(tmp));
|
||||
jsonWriteStr(configLiveJson, _paramsTmp.key, String(tmp));
|
||||
publishStatus(_paramsTmp.key, String(tmp));
|
||||
String path = mqttRootDevice + "/" +_paramsTmp.key + "/status";
|
||||
String json = "{}";
|
||||
jsonWriteStr(json, "status", String(tmp));
|
||||
String MyJson = json;
|
||||
jsonWriteStr(MyJson, "topic", path);
|
||||
ws.textAll(MyJson);
|
||||
SerialPrint("I", "Sensor", "'" + _paramsTmp.key + "' data: " + String(tmp));
|
||||
|
||||
eventGen2(_paramsPrs.key, String(prs));
|
||||
jsonWriteStr(configLiveJson, _paramsPrs.key, String(prs));
|
||||
publishStatus(_paramsPrs.key, String(prs));
|
||||
path = mqttRootDevice + "/" +_paramsPrs.key + "/status";
|
||||
json = "{}";
|
||||
jsonWriteStr(json, "status", String(prs));
|
||||
MyJson = json;
|
||||
jsonWriteStr(MyJson, "topic", path);
|
||||
ws.textAll(MyJson);
|
||||
SerialPrint("I", "Sensor", "'" + _paramsPrs.key + "' data: " + String(prs));
|
||||
}
|
||||
|
||||
|
||||
@@ -41,11 +41,23 @@ void SensorCcs811::read() {
|
||||
eventGen2(_paramsPpm.key, String(co2));
|
||||
jsonWriteStr(configLiveJson, _paramsPpm.key, String(co2));
|
||||
publishStatus(_paramsPpm.key, String(co2));
|
||||
String path = mqttRootDevice + "/" +_paramsPpm.key + "/status";
|
||||
String json = "{}";
|
||||
jsonWriteStr(json, "status", String(co2));
|
||||
String MyJson = json;
|
||||
jsonWriteStr(MyJson, "topic", path);
|
||||
ws.textAll(MyJson);
|
||||
SerialPrint("I", "Sensor", "'" + _paramsPpm.key + "' data: " + String(co2));
|
||||
|
||||
eventGen2(_paramsPpb.key, String(ppm));
|
||||
jsonWriteStr(configLiveJson, _paramsPpb.key, String(ppm));
|
||||
publishStatus(_paramsPpb.key, String(ppm));
|
||||
path = mqttRootDevice + "/" +_paramsPpb.key + "/status";
|
||||
json = "{}";
|
||||
jsonWriteStr(json, "status", String(ppm));
|
||||
MyJson = json;
|
||||
jsonWriteStr(MyJson, "topic", path);
|
||||
ws.textAll(MyJson);
|
||||
SerialPrint("I", "Sensor", "'" + _paramsPpb.key + "' data: " + String(ppm));
|
||||
} else {
|
||||
SerialPrint("E", "Sensor CCS", "Error");
|
||||
|
||||
@@ -4,26 +4,49 @@
|
||||
#include "BufferExecute.h"
|
||||
#include "Class/LineParsing.h"
|
||||
#include "Global.h"
|
||||
#include "DallasTemperature.h"
|
||||
#include "Utils/StringUtils.h"
|
||||
#include <map>
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
OneWire* oneWire;
|
||||
DallasTemperature sensors;
|
||||
//ИНТЕГРИРУЮ: переменные необходимые для работы интегрируемой библиотеки. Аналог Arduino
|
||||
std::map<int, OneWire*> oneWireTemperatureArray;
|
||||
std::map<int, DallasTemperature*> sensorsTemperatureArray;
|
||||
|
||||
SensorDallas::SensorDallas(unsigned long interval, unsigned int pin, unsigned int index, String key) {
|
||||
//ИНТЕГРИРУЮ:
|
||||
//Для каждого датчика указанного в конфигурации вызывается конструктор для настройки перед запуском. Аналог функции setup() в Arduino.
|
||||
//В параметрах передаются дополнительные настройки, указанные все в той же таблице настройки устройства.
|
||||
SensorDallas::SensorDallas(unsigned long interval, unsigned int pin, unsigned int index, String addr, String key) {
|
||||
//все особые параметры сливаем в локальные переменные экземпляра для будущего доступа
|
||||
_interval = interval * 1000;
|
||||
_key = key;
|
||||
_pin = pin;
|
||||
_index = index;
|
||||
_addr = addr;
|
||||
|
||||
oneWire = new OneWire((uint8_t)_pin);
|
||||
sensors.setOneWire(oneWire);
|
||||
sensors.begin();
|
||||
sensors.setResolution(12);
|
||||
//ИНТЕГРИРУЮ:
|
||||
//вызываем необходимые инициирующие функции интегрируемой библиотеки
|
||||
//учитываем, что библиотека может работать с несколькими линиями на разных пинах, поэтому инициируем библиотеку, если линия ранее не использовалась
|
||||
if (oneWireTemperatureArray.find(_pin) == oneWireTemperatureArray.end()) {
|
||||
oneWire = new OneWire((uint8_t)_pin);
|
||||
sensors = new DallasTemperature();
|
||||
sensors->setOneWire(oneWire);
|
||||
sensors->begin();
|
||||
sensors->setResolution(12);
|
||||
|
||||
oneWireTemperatureArray[_pin] = oneWire;
|
||||
sensorsTemperatureArray[_pin] = sensors;
|
||||
} else {
|
||||
oneWire = oneWireTemperatureArray[_pin];
|
||||
sensors = sensorsTemperatureArray[_pin];
|
||||
}
|
||||
}
|
||||
|
||||
//ИНТЕГРИРУЮ: оставляем как есть или развиваем, если нужно правильно завершить работу с интегрируемой библиотекой после отключения датчика
|
||||
SensorDallas::~SensorDallas() {}
|
||||
|
||||
//ИНТЕГРИРУЮ: аналог loop() в Arduino. Требуется изменить, если интегрируемая библиотека нуждается в другом алгоритме квотирования времени.
|
||||
void SensorDallas::loop() {
|
||||
currentMillis = millis();
|
||||
difference = currentMillis - prevMillis;
|
||||
@@ -33,28 +56,52 @@ void SensorDallas::loop() {
|
||||
}
|
||||
}
|
||||
|
||||
//ИНТЕГРИРУЮ: вызывается из цикла loop каждый установленный временно интервал в параметрах датчика. Необходимо изменить для чтения данных из датчика.
|
||||
void SensorDallas::readDallas() {
|
||||
sensors.requestTemperaturesByIndex(_index);
|
||||
float value = sensors.getTempCByIndex(_index);
|
||||
//запускаем опрос измерений у всех датчиков на линии
|
||||
sensors->requestTemperatures();
|
||||
|
||||
//Определяем адрес. Если парамтер addr не установлен, то узнаем адрес по индексу
|
||||
DeviceAddress deviceAddress;
|
||||
if (_addr == "") {
|
||||
sensors->getAddress(deviceAddress, _index);
|
||||
} else {
|
||||
string2hex(_addr.c_str(), deviceAddress);
|
||||
}
|
||||
|
||||
//получаем температуру по адресу
|
||||
float value = sensors->getTempC(deviceAddress);
|
||||
|
||||
//ИНТЕГРИРУЮ: блок генерации уведомлений в ядре системы. Стоит обратить внимание только на формат выводимого сообщения в консоли.
|
||||
eventGen2(_key, String(value));
|
||||
jsonWriteStr(configLiveJson, _key, String(value));
|
||||
publishStatus(_key, String(value));
|
||||
SerialPrint("I", "Sensor", "'" + _key + "' data: " + String(value));
|
||||
char addrStr[20] = "";
|
||||
hex2string(deviceAddress, 8, addrStr);
|
||||
SerialPrint("I", "Sensor", "'" + _key + "' data: " + String(value) + "' addr: " + String(addrStr));
|
||||
}
|
||||
|
||||
//ИНТЕГРИРУЮ: глобальная переменная необходима для интеграции в ядро. Следим за наименованием.
|
||||
MySensorDallasVector* mySensorDallas2 = nullptr;
|
||||
|
||||
//ИНТЕГРИРУЮ: функция вызывается ядром для каждой записи в таблице настроки для создания экземпляров датчиков
|
||||
//некоторые датчики записаны в таблице в виде нескольких строк, поэтому необходимо контролировать итерации обращения к данной функции
|
||||
void dallas() {
|
||||
//ИНТЕГРИРУЮ: не меняем
|
||||
myLineParsing.update();
|
||||
//ИНТЕГРИРУЮ: устанавливаем в соответствии с параметрами таблицы
|
||||
String interval = myLineParsing.gint();
|
||||
String pin = myLineParsing.gpin();
|
||||
String index = myLineParsing.gindex();
|
||||
String key = myLineParsing.gkey();
|
||||
String addr = myLineParsing.gaddr();
|
||||
//ИНТЕГРИРУЮ: не меняем
|
||||
myLineParsing.clear();
|
||||
|
||||
//ИНТЕГРИРУЮ: блок создания экземпляров датчиков. Обратить внимание на наименования и передаваемые параметры в конструктор
|
||||
static bool firstTime = true;
|
||||
if (firstTime) mySensorDallas2 = new MySensorDallasVector();
|
||||
firstTime = false;
|
||||
mySensorDallas2->push_back(SensorDallas(interval.toInt(), pin.toInt(), index.toInt(), key));
|
||||
mySensorDallas2->push_back(SensorDallas(interval.toInt(), pin.toInt(), index.toInt(), addr, key));
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -44,11 +44,23 @@ void SensorDht::readTmpHum() {
|
||||
eventGen2(_paramsTmp.key, String(tmp));
|
||||
jsonWriteStr(configLiveJson, _paramsTmp.key, String(tmp));
|
||||
publishStatus(_paramsTmp.key, String(tmp));
|
||||
String path = mqttRootDevice + "/" +_paramsTmp.key + "/status";
|
||||
String json = "{}";
|
||||
jsonWriteStr(json, "status", String(tmp));
|
||||
String MyJson = json;
|
||||
jsonWriteStr(MyJson, "topic", path);
|
||||
ws.textAll(MyJson);
|
||||
SerialPrint("I", "Sensor", "'" + _paramsTmp.key + "' data: " + String(tmp));
|
||||
|
||||
eventGen2(_paramsHum.key, String(hum));
|
||||
jsonWriteStr(configLiveJson, _paramsHum.key, String(hum));
|
||||
publishStatus(_paramsHum.key, String(hum));
|
||||
path = mqttRootDevice + "/" +_paramsHum.key + "/status";
|
||||
json = "{}";
|
||||
jsonWriteStr(json, "status", String(hum));
|
||||
MyJson = json;
|
||||
jsonWriteStr(MyJson, "topic", path);
|
||||
ws.textAll(MyJson);
|
||||
SerialPrint("I", "Sensor", "'" + _paramsHum.key + "' data: " + String(hum));
|
||||
|
||||
} else {
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
//#include "items/vSensorImpulsIn.h"
|
||||
//
|
||||
//#include "BufferExecute.h"
|
||||
//#include "Class/LineParsing.h"
|
||||
//#include "Global.h"
|
||||
//#include "SoftUART.h"
|
||||
//
|
||||
//SensorImpulsIn::SensorImpulsIn(const paramsImpulsIn& paramsImpuls) {
|
||||
// _paramsImpuls = paramsImpulsIn(paramsImpuls);
|
||||
// pinMode(14, INPUT);
|
||||
// //pinMode(_paramsImpuls.pin, INPUT_PULLUP);
|
||||
// //attachInterrupt(digitalPinToInterrupt(14), MYinterrupt, CHANGE);
|
||||
//}
|
||||
//
|
||||
//SensorImpulsIn::~SensorImpulsIn() {}
|
||||
//
|
||||
////void SensorImpulsIn::read() {
|
||||
// float voltage; //= (impulsIn->values()->voltage * _paramsV.c) + _paramsV.k;
|
||||
//
|
||||
// eventGen2(_paramsImpuls.key, String(voltage));
|
||||
// jsonWriteStr(configLiveJson, _paramsImpuls.key, String(voltage));
|
||||
// publishStatus(_paramsImpuls.key, String(voltage));
|
||||
// SerialPrint("I", "Sensor", "'" + _paramsImpuls.key + "' data: " + String(voltage));
|
||||
//}
|
||||
//
|
||||
//MySensorImpulsInVector* mySensorImpulsIn = nullptr;
|
||||
//
|
||||
//void impulsInSensor() {
|
||||
// myLineParsing.update();
|
||||
// String key = myLineParsing.gkey();
|
||||
// String pin = myLineParsing.gpin();
|
||||
// String c = myLineParsing.gc();
|
||||
// String k = myLineParsing.gk();
|
||||
// myLineParsing.clear();
|
||||
//
|
||||
// static paramsImpulsIn paramsImpuls;
|
||||
//
|
||||
// paramsImpuls.key = key;
|
||||
// paramsImpuls.pin = pin.toInt();
|
||||
// paramsImpuls.c = c.toFloat();
|
||||
// paramsImpuls.k = k.toFloat();
|
||||
//
|
||||
// static bool firstTime = true;
|
||||
// if (firstTime) mySensorImpulsIn = new MySensorImpulsInVector();
|
||||
// firstTime = false;
|
||||
// mySensorImpulsIn->push_back(SensorImpulsIn(paramsImpuls));
|
||||
//}
|
||||
//
|
||||
//void MYinterrupt() {
|
||||
// Serial.println("interrupt!");
|
||||
//}
|
||||
128
src/items/vSensorLCD2004.cpp
Normal file
128
src/items/vSensorLCD2004.cpp
Normal file
@@ -0,0 +1,128 @@
|
||||
#include "Consts.h"
|
||||
#ifdef EnableSensorLCD2004
|
||||
#include "items/vSensorLCD2004.h"
|
||||
#include "BufferExecute.h"
|
||||
#include "Class/LineParsing.h"
|
||||
#include "Global.h"
|
||||
#include "Utils/StringUtils.h"
|
||||
#include <map>
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
LiquidCrystal_I2C *LCDI2C;
|
||||
|
||||
SensorLCD2004::SensorLCD2004(String key, unsigned long interval, unsigned int x, unsigned int y, String val, String descr) {
|
||||
_key = key;
|
||||
_interval = interval * 1000;
|
||||
_x = x;
|
||||
_y = y;
|
||||
_val = val;
|
||||
_descr = descr;
|
||||
_prevStrSize = 0;
|
||||
}
|
||||
|
||||
SensorLCD2004::~SensorLCD2004() {}
|
||||
|
||||
//печать пустой строки нужной длинны для затирания предыдущего значения на экране
|
||||
void SensorLCD2004::printBlankStr(int strSize){
|
||||
String tmpStr = "";
|
||||
for(int i=0; i<strSize; i++) tmpStr += " ";
|
||||
LCDI2C->setCursor(_x, _y);
|
||||
LCDI2C->print(tmpStr);
|
||||
}
|
||||
|
||||
void SensorLCD2004::execute(String command) {
|
||||
if (command == "noBacklight") LCDI2C->noBacklight();
|
||||
else if (command == "backlight") LCDI2C->backlight();
|
||||
else if (command == "noDisplay") LCDI2C->noDisplay();
|
||||
else if (command == "display") LCDI2C->display();
|
||||
else if (command == "x") {
|
||||
printBlankStr(_prevStrSize);
|
||||
String par = sCmd.next();
|
||||
_x = par.toInt();
|
||||
}
|
||||
else if (command == "y") {
|
||||
printBlankStr(_prevStrSize);
|
||||
String par = sCmd.next();
|
||||
_y = par.toInt();
|
||||
}
|
||||
else if (command == "descr") {
|
||||
printBlankStr(_prevStrSize);
|
||||
String par = sCmd.next();
|
||||
_descr = par;
|
||||
}
|
||||
else { //не команда, значит данные
|
||||
_val = command;
|
||||
}
|
||||
|
||||
writeLCD2004();
|
||||
}
|
||||
|
||||
void SensorLCD2004::loop() {
|
||||
currentMillis = millis();
|
||||
difference = currentMillis - prevMillis;
|
||||
if (difference >= _interval) {
|
||||
prevMillis = millis();
|
||||
writeLCD2004();
|
||||
}
|
||||
}
|
||||
|
||||
void SensorLCD2004::writeLCD2004() {
|
||||
if (LCDI2C != nullptr) {
|
||||
printBlankStr(_prevStrSize);
|
||||
|
||||
String tmpStr = getValue(_val);
|
||||
if (tmpStr == "no value") tmpStr = _val;
|
||||
if (_descr != "none") tmpStr = _descr + " " + tmpStr;
|
||||
LCDI2C->setCursor(_x, _y);
|
||||
LCDI2C->print(tmpStr);
|
||||
|
||||
_prevStrSize = tmpStr.length();
|
||||
}
|
||||
}
|
||||
|
||||
MySensorLCD2004Vector* mySensorLCD20042 = nullptr;
|
||||
|
||||
void lcd2004Execute() {
|
||||
String key = sCmd.order();
|
||||
String command = sCmd.next();
|
||||
|
||||
for (unsigned int i = 0; i < mySensorLCD20042->size(); i++) {
|
||||
if (mySensorLCD20042->at(i)._key == key) mySensorLCD20042->at(i).execute(command);
|
||||
}
|
||||
}
|
||||
|
||||
void lcd2004() {
|
||||
myLineParsing.update();
|
||||
String key = myLineParsing.gkey();
|
||||
String addr = myLineParsing.gaddr();
|
||||
String interval = myLineParsing.gint();
|
||||
String c = myLineParsing.gc();
|
||||
String k = myLineParsing.gk();
|
||||
String val = myLineParsing.gval();
|
||||
String descr = myLineParsing.gdescr();
|
||||
myLineParsing.clear();
|
||||
|
||||
int x = selectFromMarkerToMarker(c, ",", 0).toInt();
|
||||
int y = selectFromMarkerToMarker(c, ",", 1).toInt();
|
||||
int w = selectFromMarkerToMarker(k, ",", 0).toInt(); //количество столбцов
|
||||
int h = selectFromMarkerToMarker(k, ",", 1).toInt(); //количество строк
|
||||
|
||||
if (LCDI2C == nullptr) { //инициализации экрана еще не было
|
||||
LCDI2C = new LiquidCrystal_I2C(hexStringToUint8(addr), w, h);//hexStringToUint8(addr), w, h);
|
||||
if(LCDI2C != nullptr) {
|
||||
LCDI2C->init();
|
||||
LCDI2C->backlight();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static bool firstTime = true;
|
||||
if (firstTime) mySensorLCD20042 = new MySensorLCD2004Vector();
|
||||
firstTime = false;
|
||||
mySensorLCD20042->push_back(SensorLCD2004(key, interval.toInt(), x, y, val, descr));
|
||||
|
||||
sCmd.addCommand(key.c_str(), lcd2004Execute);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -37,6 +37,12 @@ void SensorNode::onChange(String newValue, String incommingKey) {
|
||||
eventGen2(_params.key, newValue);
|
||||
jsonWriteStr(configLiveJson, _params.key, newValue);
|
||||
publishStatus(_params.key, newValue);
|
||||
String path = mqttRootDevice + "/" +_params.key + "/status";
|
||||
String json = "{}";
|
||||
jsonWriteStr(json, "status", newValue);
|
||||
String MyJson = json;
|
||||
jsonWriteStr(MyJson, "topic", path);
|
||||
ws.textAll(MyJson);
|
||||
|
||||
_updateTime = timeNow->getDateTimeDotFormated();
|
||||
|
||||
@@ -48,17 +54,72 @@ void SensorNode::onChange(String newValue, String incommingKey) {
|
||||
void SensorNode::publish() {
|
||||
if (_minutesPassed < _params.tm1.toInt()) {
|
||||
publishAnyJsonKey(_params.key, "info", String(_minutesPassed) + " min");
|
||||
|
||||
String path = mqttRootDevice + "/" + _params.key + "/status";
|
||||
String json = "{}";
|
||||
jsonWriteStr(json, "info", String(_minutesPassed) + " min");
|
||||
String MyJson = json;
|
||||
jsonWriteStr(MyJson, "topic", path);
|
||||
ws.textAll(MyJson);
|
||||
|
||||
|
||||
publishAnyJsonKey(_params.key, "color", "");
|
||||
|
||||
|
||||
path = mqttRootDevice + "/" + _params.key + "/status";
|
||||
json = "{}";
|
||||
jsonWriteStr(json, "color", "");
|
||||
MyJson = json;
|
||||
jsonWriteStr(MyJson, "topic", path);
|
||||
ws.textAll(MyJson);
|
||||
|
||||
} else if (_minutesPassed >= _params.tm1.toInt() && _minutesPassed < _params.tm2.toInt()) {
|
||||
publishAnyJsonKey(_params.key, "info", String(_minutesPassed) + " min");
|
||||
|
||||
String path = mqttRootDevice + "/" + _params.key + "/status";
|
||||
String json = "{}";
|
||||
jsonWriteStr(json, "info", String(_minutesPassed) + " min");
|
||||
String MyJson = json;
|
||||
jsonWriteStr(MyJson, "topic", path);
|
||||
ws.textAll(MyJson);
|
||||
|
||||
publishAnyJsonKey(_params.key, "color", "orange");
|
||||
path = mqttRootDevice + "/" + _params.key + "/status";
|
||||
json = "{}";
|
||||
jsonWriteStr(json, "color", "orange");
|
||||
MyJson = json;
|
||||
jsonWriteStr(MyJson, "topic", path);
|
||||
ws.textAll(MyJson);
|
||||
|
||||
} else if (_minutesPassed >= _params.tm2.toInt()) {
|
||||
if (_updateTime == "") {
|
||||
publishAnyJsonKey(_params.key, "info", "offline");
|
||||
|
||||
|
||||
String path = mqttRootDevice + "/" + _params.key + "/status";
|
||||
String json = "{}";
|
||||
jsonWriteStr(json, "info", "offline");
|
||||
String MyJson = json;
|
||||
jsonWriteStr(MyJson, "topic", path);
|
||||
ws.textAll(MyJson);
|
||||
} else {
|
||||
publishAnyJsonKey(_params.key, "info", _updateTime);
|
||||
String path = mqttRootDevice + "/" + _params.key + "/status";
|
||||
String json = "{}";
|
||||
jsonWriteStr(json, "info", _updateTime);
|
||||
String MyJson = json;
|
||||
jsonWriteStr(MyJson, "topic", path);
|
||||
ws.textAll(MyJson);
|
||||
|
||||
|
||||
}
|
||||
publishAnyJsonKey(_params.key, "color", "red");
|
||||
String path = mqttRootDevice + "/" + _params.key + "/status";
|
||||
String json = "{}";
|
||||
jsonWriteStr(json, "color", "red");
|
||||
String MyJson = json;
|
||||
jsonWriteStr(MyJson, "topic", path);
|
||||
ws.textAll(MyJson);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,26 +38,56 @@ void SensorPzem::read() {
|
||||
eventGen2(_paramsV.key, String(voltage));
|
||||
jsonWriteStr(configLiveJson, _paramsV.key, String(voltage));
|
||||
publishStatus(_paramsV.key, String(voltage));
|
||||
String path = mqttRootDevice + "/" +_paramsV.key + "/status";
|
||||
String json = "{}";
|
||||
jsonWriteStr(json, "status", String(voltage));
|
||||
String MyJson = json;
|
||||
jsonWriteStr(MyJson, "topic", path);
|
||||
ws.textAll(MyJson);
|
||||
SerialPrint("I", "Sensor", "'" + _paramsV.key + "' data: " + String(voltage));
|
||||
|
||||
eventGen2(_paramsA.key, String(current));
|
||||
jsonWriteStr(configLiveJson, _paramsA.key, String(current));
|
||||
publishStatus(_paramsA.key, String(current));
|
||||
path = mqttRootDevice + "/" +_paramsA.key + "/status";
|
||||
json = "{}";
|
||||
jsonWriteStr(json, "status", String(current));
|
||||
MyJson = json;
|
||||
jsonWriteStr(MyJson, "topic", path);
|
||||
ws.textAll(MyJson);
|
||||
SerialPrint("I", "Sensor", "'" + _paramsA.key + "' data: " + String(current));
|
||||
|
||||
eventGen2(_paramsWatt.key, String(power));
|
||||
jsonWriteStr(configLiveJson, _paramsWatt.key, String(power));
|
||||
publishStatus(_paramsWatt.key, String(power));
|
||||
path = mqttRootDevice + "/" +_paramsWatt.key + "/status";
|
||||
json = "{}";
|
||||
jsonWriteStr(json, "status", String(power));
|
||||
MyJson = json;
|
||||
jsonWriteStr(MyJson, "topic", path);
|
||||
ws.textAll(MyJson);
|
||||
SerialPrint("I", "Sensor", "'" + _paramsWatt.key + "' data: " + String(power));
|
||||
|
||||
eventGen2(_paramsWattHrs.key, String(energy));
|
||||
jsonWriteStr(configLiveJson, _paramsWattHrs.key, String(energy));
|
||||
publishStatus(_paramsWattHrs.key, String(energy));
|
||||
path = mqttRootDevice + "/" +_paramsWattHrs.key + "/status";
|
||||
json = "{}";
|
||||
jsonWriteStr(json, "status", String(energy));
|
||||
MyJson = json;
|
||||
jsonWriteStr(MyJson, "topic", path);
|
||||
ws.textAll(MyJson);
|
||||
SerialPrint("I", "Sensor", "'" + _paramsWattHrs.key + "' data: " + String(energy));
|
||||
|
||||
eventGen2(_paramsHz.key, String(freq));
|
||||
jsonWriteStr(configLiveJson, _paramsHz.key, String(freq));
|
||||
publishStatus(_paramsHz.key, String(freq));
|
||||
path = mqttRootDevice + "/" +_paramsHz.key + "/status";
|
||||
json = "{}";
|
||||
jsonWriteStr(json, "status", String(freq));
|
||||
MyJson = json;
|
||||
jsonWriteStr(MyJson, "topic", path);
|
||||
ws.textAll(MyJson);
|
||||
SerialPrint("I", "Sensor", "'" + _paramsHz.key + "' data: " + String(freq));
|
||||
} else {
|
||||
SerialPrint("E", "Sensor PZEM", "Error, UART switched off");
|
||||
|
||||
104
src/items/vSensorSHT20.cpp
Normal file
104
src/items/vSensorSHT20.cpp
Normal file
@@ -0,0 +1,104 @@
|
||||
#include "Consts.h"
|
||||
#ifdef EnableSensorSht20
|
||||
#include "items/vSensorSHT20.h"
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "BufferExecute.h"
|
||||
#include "Class/LineParsing.h"
|
||||
#include "Global.h"
|
||||
|
||||
#include "Wire.h"
|
||||
#include "SHT2x.h"
|
||||
SHT2x* sht = nullptr;
|
||||
|
||||
SensorSht20::SensorSht20(const paramsSht& paramsTmp, const paramsSht& paramsHum) {
|
||||
_paramsTmp = paramsSht(paramsTmp);
|
||||
_paramsHum = paramsSht(paramsHum);
|
||||
|
||||
if (!sht) {
|
||||
sht = new SHT2x;
|
||||
}
|
||||
|
||||
sht->begin();
|
||||
|
||||
uint8_t stat = sht->getStatus();
|
||||
Serial.print(stat, HEX);
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
SensorSht20::~SensorSht20() {}
|
||||
|
||||
void SensorSht20::loop() {
|
||||
difference = millis() - prevMillis;
|
||||
if (difference >= _paramsHum.interval) {
|
||||
prevMillis = millis();
|
||||
read();
|
||||
}
|
||||
}
|
||||
|
||||
void SensorSht20::read() {
|
||||
sht->read();
|
||||
|
||||
float tmp = sht->getTemperature();
|
||||
float hum = sht->getHumidity();
|
||||
|
||||
tmp = tmp * _paramsTmp.c;
|
||||
hum = hum * _paramsHum.c;
|
||||
|
||||
eventGen2(_paramsTmp.key, String(tmp));
|
||||
jsonWriteStr(configLiveJson, _paramsTmp.key, String(tmp));
|
||||
publishStatus(_paramsTmp.key, String(tmp));
|
||||
String path = mqttRootDevice + "/" +_paramsTmp.key + "/status";
|
||||
String json = "{}";
|
||||
jsonWriteStr(json, "status", String(tmp));
|
||||
String MyJson = json;
|
||||
jsonWriteStr(MyJson, "topic", path);
|
||||
ws.textAll(MyJson);
|
||||
|
||||
SerialPrint("I", "Sensor", "'" + _paramsTmp.key + "' data: " + String(tmp));
|
||||
|
||||
eventGen2(_paramsHum.key, String(hum));
|
||||
jsonWriteStr(configLiveJson, _paramsHum.key, String(hum));
|
||||
publishStatus(_paramsHum.key, String(hum));
|
||||
path = mqttRootDevice + "/" +_paramsHum.key + "/status";
|
||||
json = "{}";
|
||||
jsonWriteStr(json, "status", String(hum));
|
||||
MyJson = json;
|
||||
jsonWriteStr(MyJson, "topic", path);
|
||||
ws.textAll(MyJson);
|
||||
SerialPrint("I", "Sensor", "'" + _paramsHum.key + "' data: " + String(hum));
|
||||
}
|
||||
|
||||
MySensorSht20Vector* mySensorSht20 = nullptr;
|
||||
|
||||
void sht20Sensor() {
|
||||
myLineParsing.update();
|
||||
String key = myLineParsing.gkey();
|
||||
String interval = myLineParsing.gint();
|
||||
String c = myLineParsing.gc();
|
||||
myLineParsing.clear();
|
||||
|
||||
static int enterCnt = -1;
|
||||
enterCnt++;
|
||||
|
||||
static paramsSht paramsTmp;
|
||||
static paramsSht paramsHum;
|
||||
|
||||
if (enterCnt == 0) {
|
||||
paramsTmp.key = key;
|
||||
paramsTmp.c = c.toFloat();
|
||||
}
|
||||
|
||||
if (enterCnt == 1) {
|
||||
paramsHum.key = key;
|
||||
paramsHum.c = c.toFloat();
|
||||
paramsHum.interval = interval.toInt() * 1000;
|
||||
|
||||
static bool firstTime = true;
|
||||
if (firstTime) mySensorSht20 = new MySensorSht20Vector();
|
||||
firstTime = false;
|
||||
mySensorSht20->push_back(SensorSht20(paramsTmp, paramsHum));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
124
src/items/vSensorTM1637.cpp
Normal file
124
src/items/vSensorTM1637.cpp
Normal file
@@ -0,0 +1,124 @@
|
||||
#include "Consts.h"
|
||||
#ifdef EnableSensorTM1637
|
||||
#include "items/vSensorTM1637.h"
|
||||
#include "BufferExecute.h"
|
||||
#include "Class/LineParsing.h"
|
||||
#include "Global.h"
|
||||
#include "Utils/StringUtils.h"
|
||||
#include <map>
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
const uint8_t segmentsVal[] = {0x77, 0x7f, 0x39, 0x3f, 0x79, 0x71, 0x3d, 0x76, 0x1e, 0x38, 0x37, 0x3f, 0x73, 0x6d, 0x3e, 0x6e, 0x5f, 0x7c, 0x58, 0x5e, 0x7b, 0x71, 0x74, 0x10, 0x0e, 0x06, 0x54, 0x5c, 0x67, 0x50, 0x78, 0x1c, 0x6e, 0x40, 0x08, 0x48, 0x00, 0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f};
|
||||
char segmentsIndex[] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'L', 'N', 'O', 'P', 'S', 'U', 'Y', 'a', 'b', 'c', 'd', 'e', 'f', 'h', 'i', 'j', 'l', 'n', 'o', 'q', 'r', 't', 'u', 'y', '-', '_', '=', ' ', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
|
||||
|
||||
|
||||
std::map<int, DisplayObj> displayObjects;
|
||||
|
||||
uint8_t char2Segment(char ch) {
|
||||
for (int i=0; i<sizeof(segmentsIndex); i++) {
|
||||
if (ch == segmentsIndex[i]) return segmentsVal[i];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SensorTM1637::SensorTM1637(String key, int pin1, int pin2, unsigned long interval, unsigned int c, unsigned int k, String val, String descr) {
|
||||
_key = key;
|
||||
_interval = interval * 1000;
|
||||
_c = c;
|
||||
_k = k;
|
||||
_val = val;
|
||||
_descr = descr;
|
||||
|
||||
if (displayObjects.find(pin1) == displayObjects.end()) {
|
||||
_disp = new TM1637Display(pin1, pin2);
|
||||
DisplayObj dispObj;
|
||||
dispObj.curIndex = 0;
|
||||
dispObj.disp = _disp;
|
||||
displayObjects[pin1] = dispObj;
|
||||
|
||||
_disp->setBrightness(0x0f);
|
||||
_disp->clear();
|
||||
} else {
|
||||
_disp = displayObjects[pin1].disp;
|
||||
}
|
||||
}
|
||||
|
||||
SensorTM1637::~SensorTM1637() {}
|
||||
|
||||
void SensorTM1637::execute(String command) {
|
||||
if (command == "noDisplay") _disp->setBrightness(0x00, false);
|
||||
else if (command == "display") _disp->setBrightness(0x0f, true);
|
||||
else if (command == "setBrightness") {
|
||||
String par = sCmd.next();
|
||||
_disp->setBrightness(par.toInt());
|
||||
}
|
||||
else if (command == "descr") {
|
||||
String par = sCmd.next();
|
||||
_descr = par;
|
||||
}
|
||||
else { //не команда, значит данные
|
||||
_val = command;
|
||||
}
|
||||
|
||||
writeTM1637();
|
||||
}
|
||||
|
||||
void SensorTM1637::loop() {
|
||||
currentMillis = millis();
|
||||
difference = currentMillis - prevMillis;
|
||||
if (difference >= _interval) {
|
||||
prevMillis = millis();
|
||||
writeTM1637();
|
||||
}
|
||||
}
|
||||
|
||||
void SensorTM1637::writeTM1637() {
|
||||
if (_disp != nullptr) {
|
||||
if (_descr != "none") {
|
||||
uint8_t segments[] = {0};
|
||||
segments[0] = char2Segment(_descr.c_str()[0]);
|
||||
_disp->setSegments(segments, 1, 0); //выводим поле описания в самом первой секции экрана, один символ
|
||||
}
|
||||
String tmpStr = getValue(_val);
|
||||
if (tmpStr == "no value") tmpStr = _val;
|
||||
|
||||
_disp->showNumberDec(tmpStr.toInt(), false, _c, _k);
|
||||
}
|
||||
}
|
||||
|
||||
MySensorTM1637Vector* mySensorTM1637 = nullptr;
|
||||
|
||||
void TM1637Execute() {
|
||||
String key = sCmd.order();
|
||||
String command = sCmd.next();
|
||||
|
||||
for (unsigned int i = 0; i < mySensorTM1637->size(); i++) {
|
||||
if (mySensorTM1637->at(i)._key == key) mySensorTM1637->at(i).execute(command);
|
||||
}
|
||||
}
|
||||
|
||||
void TM1637() {
|
||||
myLineParsing.update();
|
||||
String key = myLineParsing.gkey();
|
||||
String pins = myLineParsing.gpin();
|
||||
String interval = myLineParsing.gint();
|
||||
String c = myLineParsing.gc();
|
||||
String k = myLineParsing.gk();
|
||||
String val = myLineParsing.gval();
|
||||
String descr = myLineParsing.gdescr();
|
||||
myLineParsing.clear();
|
||||
|
||||
int pin1 = selectFromMarkerToMarker(pins, ",", 0).toInt();
|
||||
int pin2 = selectFromMarkerToMarker(pins, ",", 1).toInt();
|
||||
|
||||
static bool firstTime = true;
|
||||
if (firstTime) mySensorTM1637 = new MySensorTM1637Vector();
|
||||
firstTime = false;
|
||||
mySensorTM1637->push_back(SensorTM1637(key, pin1, pin2, interval.toInt(), c.toInt(), k.toInt(), val, descr));
|
||||
|
||||
sCmd.addCommand(key.c_str(), TM1637Execute);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -53,20 +53,22 @@ void SensorUltrasonic::readUltrasonic() {
|
||||
value = duration_ / 29 / 2;
|
||||
|
||||
value = testFilter.filtered(value);
|
||||
|
||||
value = map(value, _map1, _map2, _map3, _map4);
|
||||
float valueFloat = value * _c;
|
||||
|
||||
if (counter > 10) {
|
||||
eventGen2(_key, String(valueFloat));
|
||||
jsonWriteStr(configLiveJson, _key, String(valueFloat));
|
||||
publishStatus(_key, String(valueFloat));
|
||||
String path = mqttRootDevice + "/" +_key + "/status";
|
||||
String json = "{}";
|
||||
jsonWriteStr(json, "status", String(valueFloat));
|
||||
String MyJson = json;
|
||||
jsonWriteStr(MyJson, "topic", path);
|
||||
ws.textAll(MyJson);
|
||||
SerialPrint("I", "Sensor", "'" + _key + "' data: " + String(valueFloat));
|
||||
}
|
||||
}
|
||||
|
||||
MySensorUltrasonicVector* mySensorUltrasonic = nullptr;
|
||||
|
||||
void ultrasonic() {
|
||||
myLineParsing.update();
|
||||
String interval = myLineParsing.gint();
|
||||
@@ -75,15 +77,12 @@ void ultrasonic() {
|
||||
String map = myLineParsing.gmap();
|
||||
String c = myLineParsing.gc();
|
||||
myLineParsing.clear();
|
||||
|
||||
unsigned int trig = selectFromMarkerToMarker(pin, ",", 0).toInt();
|
||||
unsigned int echo = selectFromMarkerToMarker(pin, ",", 1).toInt();
|
||||
|
||||
int map1 = selectFromMarkerToMarker(map, ",", 0).toInt();
|
||||
int map2 = selectFromMarkerToMarker(map, ",", 1).toInt();
|
||||
int map3 = selectFromMarkerToMarker(map, ",", 2).toInt();
|
||||
int map4 = selectFromMarkerToMarker(map, ",", 3).toInt();
|
||||
|
||||
static bool firstTime = true;
|
||||
if (firstTime) mySensorUltrasonic = new MySensorUltrasonicVector();
|
||||
firstTime = false;
|
||||
|
||||
@@ -28,6 +28,12 @@ void SensorUptime::read() {
|
||||
eventGen2(_paramsUpt.key, upt);
|
||||
jsonWriteStr(configLiveJson, _paramsUpt.key, upt);
|
||||
publishStatus(_paramsUpt.key, upt);
|
||||
String path = mqttRootDevice + "/" +_paramsUpt.key + "/status";
|
||||
String json = "{}";
|
||||
jsonWriteStr(json, "status", upt);
|
||||
String MyJson = json;
|
||||
jsonWriteStr(MyJson, "topic", path);
|
||||
ws.textAll(MyJson);
|
||||
SerialPrint("I", "Sensor", "'" + _paramsUpt.key + "' data: " + upt);
|
||||
}
|
||||
|
||||
@@ -38,12 +44,9 @@ void uptimeSensor() {
|
||||
String key = myLineParsing.gkey();
|
||||
String interval = myLineParsing.gint();
|
||||
myLineParsing.clear();
|
||||
|
||||
static paramsUptime paramsUpt;
|
||||
|
||||
paramsUpt.key = key;
|
||||
paramsUpt.interval = interval.toInt() * 1000;
|
||||
|
||||
static bool firstTime = true;
|
||||
if (firstTime) mySensorUptime = new MySensorUptimeVector();
|
||||
firstTime = false;
|
||||
|
||||
54
src/main.cpp
54
src/main.cpp
@@ -1,4 +1,3 @@
|
||||
|
||||
#include <SSDP.h>
|
||||
|
||||
#include "BufferExecute.h"
|
||||
@@ -11,34 +10,38 @@
|
||||
#include "Global.h"
|
||||
#include "Init.h"
|
||||
#include "ItemsList.h"
|
||||
#include "MySensorsDataParse.h"
|
||||
#include "RemoteOrdersUdp.h"
|
||||
#include "SoftUART.h"
|
||||
#include "Telegram.h"
|
||||
#include "Tests.h"
|
||||
#include "Utils/StatUtils.h"
|
||||
#include "Utils/statUtils.h"
|
||||
#include "Utils/Timings.h"
|
||||
#include "Utils/WebUtils.h"
|
||||
#include "MySensorsDataParse.h"
|
||||
#include "items/ButtonInClass.h"
|
||||
#include "items/vCountDown.h"
|
||||
#include "items/vImpulsOut.h"
|
||||
#include "items/vLogging.h"
|
||||
#include "items/vSensorAnalog.h"
|
||||
#include "items/vSensorAny.h"
|
||||
#include "items/vSensorBme280.h"
|
||||
#include "items/vSensorBmp280.h"
|
||||
#include "items/vSensorCcs811.h"
|
||||
#include "items/vSensorDallas.h"
|
||||
#include "items/vSensorLCD2004.h"
|
||||
#include "items/vSensorTM1637.h"
|
||||
#include "items/vSensorDht.h"
|
||||
#include "items/vSensorNode.h"
|
||||
#include "items/vSensorPzem.h"
|
||||
#include "items/vSensorSHT20.h"
|
||||
#include "items/vSensorUltrasonic.h"
|
||||
#include "items/vSensorUptime.h"
|
||||
#include "items/vSensorNode.h"
|
||||
|
||||
//#include "WebServer.h"
|
||||
void not_async_actions();
|
||||
|
||||
Timings metric;
|
||||
boolean initialized = false;
|
||||
|
||||
extern int flagq;
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
Serial.flush();
|
||||
@@ -79,7 +82,7 @@ void setup() {
|
||||
|
||||
getFSInfo();
|
||||
|
||||
//testsPerform();
|
||||
// testsPerform();
|
||||
|
||||
just_load = false;
|
||||
initialized = true;
|
||||
@@ -93,8 +96,14 @@ void loop() {
|
||||
#ifdef OTA_UPDATES_ENABLED
|
||||
ArduinoOTA.handle();
|
||||
#endif
|
||||
#ifdef WS_enable
|
||||
#ifdef WEBSOCKET_ENABLED
|
||||
|
||||
ws.cleanupClients();
|
||||
if (flagq == 1) {
|
||||
SerialPrint("I", "WS ", "choose_log_date_and_send()");
|
||||
choose_log_date_and_sendWS();
|
||||
flagq = 0;
|
||||
}
|
||||
#endif
|
||||
timeNow->loop();
|
||||
mqttLoop();
|
||||
@@ -130,6 +139,7 @@ void loop() {
|
||||
}
|
||||
}
|
||||
#endif
|
||||
//ИНТЕГРИРУЮ: Третья интеграция в ядро. Следим за наименованием
|
||||
#ifdef EnableLogging
|
||||
if (myLogging != nullptr) {
|
||||
for (unsigned int i = 0; i < myLogging->size(); i++) {
|
||||
@@ -144,6 +154,20 @@ void loop() {
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef EnableSensorLCD2004
|
||||
if (mySensorLCD20042 != nullptr) {
|
||||
for (unsigned int i = 0; i < mySensorLCD20042->size(); i++) {
|
||||
mySensorLCD20042->at(i).loop();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef EnableSensorTM1637
|
||||
if (mySensorTM1637 != nullptr) {
|
||||
for (unsigned int i = 0; i < mySensorTM1637->size(); i++) {
|
||||
mySensorTM1637->at(i).loop();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef EnableSensorUltrasonic
|
||||
if (mySensorUltrasonic != nullptr) {
|
||||
for (unsigned int i = 0; i < mySensorUltrasonic->size(); i++) {
|
||||
@@ -173,6 +197,20 @@ void loop() {
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef EnableSensorSht20
|
||||
if (mySensorSht20 != nullptr) {
|
||||
for (unsigned int i = 0; i < mySensorSht20->size(); i++) {
|
||||
mySensorSht20->at(i).loop();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef EnableSensorAny
|
||||
if (mySensorAny != nullptr) {
|
||||
for (unsigned int i = 0; i < mySensorAny->size(); i++) {
|
||||
mySensorAny->at(i).loop();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef EnableSensorBmp280
|
||||
if (mySensorBmp280 != nullptr) {
|
||||
for (unsigned int i = 0; i < mySensorBmp280->size(); i++) {
|
||||
|
||||
Reference in New Issue
Block a user