9 Commits
264 ... 267

Author SHA1 Message Date
Dmitry Borisenko
50a5d51281 Merge pull request #63 from IoTManagerProject/beta
Beta
2020-11-07 01:40:13 +03:00
Dmitry Borisenko
709a1fe1f7 267 Scenario bug fully fixed Stable 2020-11-07 01:11:32 +03:00
Dmitry Borisenko
1f46226a46 fixed scenario bug 2020-11-06 20:17:49 +03:00
Dmitry Borisenko
8cd84a09e2 Merge pull request #62 from IoTManagerProject/beta
Beta
2020-11-06 00:18:48 +03:00
Dmitry Borisenko
e52437b828 266 (fix scenario bug) 2020-11-05 17:27:18 +03:00
Dmitry Borisenko
1f69019bb3 265 Telegram support added 2020-11-05 02:23:08 +03:00
Dmitry Borisenko
2cad740fc6 telegram bot added (working version) 2020-11-04 23:48:21 +03:00
Dmitry Borisenko
aec1d50732 264 2020-11-03 22:49:57 +03:00
Dmitry Borisenko
8817c532f4 esp32 compiling version 2020-11-03 22:45:43 +03:00
62 changed files with 703 additions and 496 deletions

View File

@@ -3,17 +3,18 @@
"chipID": "", "chipID": "",
"apssid": "IoTmanager", "apssid": "IoTmanager",
"appass": "", "appass": "",
"routerssid": "rise", "routerssid": "VOLODYA",
"routerpass": "hostel3333", "routerpass": "BELCHENKO",
"timezone": 2, "timezone": 1,
"ntp": "pool.ntp.org", "ntp": "pool.ntp.org",
"mqttServer": "91.204.228.124", "mqttServer": "m12.cloudmqtt.com",
"mqttPort": 1883, "mqttPort": 14053,
"mqttPrefix": "/iotTest", "mqttPrefix": "/iotTest",
"mqttUser": "rise", "mqttUser": "lbscvzuj",
"mqttPass": "23ri22se32", "mqttPass": "bLxlveOgaF8F",
"scen": "1", "scen": "1",
"pushingboxid": "v7C133E426B0C69E", "telegramApi": "1416711569:AAEI0j83GmXqwzb_gnK1B0Am0gDwZoJt5xo",
"telegonof": "0",
"weblogin": "admin", "weblogin": "admin",
"webpass": "admin", "webpass": "admin",
"udponoff": "1", "udponoff": "1",

View File

@@ -37,8 +37,8 @@
}, },
{ {
"type": "link", "type": "link",
"title": "Конфигурация push", "title": "Конфигурация telegram",
"action": "/?set.push", "action": "/?set.telegram",
"class": "btn btn-block btn-default" "class": "btn btn-block btn-default"
}, },
{ {

View File

@@ -1 +1 @@
0;input-time;id;inputTime;Ввод;Введите#время;order;st[10:00:00] 0;input-time;id;inputTime;Ввод;Введите#время;order;st[10:00]

View File

@@ -1,6 +1,8 @@
temp > inputU temp > inputU
button 0 button 0
telegram нагрев#выключен 1
end end
temp < inputL temp < inputL
button 1 button 1
telegram нагрев#включен 1
end end

View File

@@ -1,5 +1,5 @@
0;dht-hum;hum;anydataHum;Теплица;Влажность;1;pin[2];type[dht11];c[1] 0;dht-hum;hum;anydataHum;Теплица;Влажность;1;pin[2];type[dht11];c[1]
0;logging;log;chart;Теплица;Влажность;2;val[hum];int[60];cnt[100] 0;logging;log;chart;Теплица;История;2;val[hum];int[60];cnt[100]
0;input-digit;inputU;inputDigit;Теплица;Верхний#порог;3;st[45] 0;input-digit;inputU;inputDigit;Теплица;Верхний#порог;3;st[45]
0;input-digit;inputL;inputDigit;Теплица;Нижний#порог;4;st[35] 0;input-digit;inputL;inputDigit;Теплица;Нижний#порог;4;st[35]
0;button-out;button;toggle;Теплица;Полив;5;pin[12];st[0] 0;button-out;button;toggle;Теплица;Полив;5;pin[12];st[0]

View File

@@ -1,6 +1,8 @@
hum > inputU hum > inputU
button 0 button 0
telegram полив#выключен 1
end end
hum < inputL hum < inputL
button 1 button 1
telegram полив#включен 1
end end

4
data/presets/rel.c.txt Normal file
View File

@@ -0,0 +1,4 @@
0;button-out;button1;toggle;Реле;Освещение;1;pin[12];st[0]
0;button-out;button2;toggle;Реле;Освещение;2;pin[13];st[0]
0;input-time;T1;inputTime;Реле;Введите#время#включения;3;st[10:00]
0;input-time;T2;inputTime;Реле;Введите#время#выключения;4;st[11:00]

8
data/presets/rel.s.txt Normal file
View File

@@ -0,0 +1,8 @@
timenow = T1
button1 1
button2 0
end
timenow = T2
button1 0
button2 1
end

View File

@@ -43,7 +43,7 @@
}, },
{ {
"type": "h4", "type": "h4",
"title": "LittleFS version: 264" "title": "LittleFS version: 267"
}, },
{ {
"type": "hr" "type": "hr"
@@ -87,8 +87,9 @@
"style": "display:inline", "style": "display:inline",
"title": { "title": {
"#": "Выберите пресет из списка<span class=\"caret\"></span>", "#": "Выберите пресет из списка<span class=\"caret\"></span>",
"/set?addPreset=dal.c": "1.Термостат на основе ds18b20 (устройство держит заданный уровень температуры)", "/set?addPreset=dal.c": "1.Термостат на основе ds18b20 с оповещением в телеграм",
"/set?addPreset=dht.c": "2.Контроль влажности на основе DHT (устройство держит заданный уровень влажности)" "/set?addPreset=dht.c": "2.Контроль влажности на основе DHT с оповещением в телеграм",
"/set?addPreset=rel.c": "3.Включение выключение реле в заданное время"
} }
}, },
{ {
@@ -184,6 +185,15 @@
"action": "/check", "action": "/check",
"response": "[[my-block]]", "response": "[[my-block]]",
"class": "btn btn-block btn-default" "class": "btn btn-block btn-default"
},
{
"type": "hr"
},
{
"type": "link",
"title": "Перезагрузить устройство",
"action": "javascript:if(confirm(renameBlock(jsonResponse,'Перезагрузить?'))){send_request(this,'/set?device=ok');}",
"class": "btn btn-block btn-danger"
} }
] ]
} }

View File

@@ -1,51 +0,0 @@
{
"configs": [
"/config.setup.json",
"/lang/lang.ru.json"
],
"class": "col-sm-offset-1 col-sm-10 col-md-offset-2 col-md-8 col-lg-offset-3 col-lg-6",
"content": [
{
"type": "h5",
"title": "{{name}}",
"class": "alert-default"
},
{
"type": "link",
"title": "{{ButMainPage}}",
"action": "/",
"class": "btn btn-block btn-default"
},
{
"type": "hr"
},
{
"type": "h4",
"style": "width:60%;float:left;",
"title": "Device id:"
},
{
"type": "input",
"title": "",
"name": "push-arg",
"style": "width:40%;float:right",
"state": "{{pushingboxid}}"
},
{
"type": "button",
"title": "{{ButSave}}",
"action": "set?pushingboxid=[[push-arg]]",
"class": "btn btn-block btn-default",
"style": "width:100%;display:inline"
},
{
"type": "hr"
},
{
"type": "link",
"title": "Перезагрузить устройство",
"action": "javascript:if(confirm(renameBlock(jsonResponse,'Перезагрузить?'))){send_request(this,'/restart?device=ok');}",
"class": "btn btn-block btn-danger"
}
]
}

68
data/set.telegram.json Normal file
View File

@@ -0,0 +1,68 @@
{
"configs": [
"/config.setup.json",
"/lang/lang.ru.json"
],
"class": "col-sm-offset-1 col-sm-10 col-md-offset-2 col-md-8 col-lg-offset-3 col-lg-6",
"content": [
{
"type": "h5",
"title": "{{name}}",
"class": "alert-default"
},
{
"type": "link",
"title": "{{ButMainPage}}",
"action": "/",
"class": "btn btn-block btn-default"
},
{
"type": "hr"
},
{
"type": "checkbox",
"name": "tel",
"title": "Включить телеграм",
"action": "/set?telegonof=[[tel]]",
"state": "{{telegonof}}"
},
{
"type": "hr"
},
{
"type": "h4",
"style": "width:40%;float:left;",
"title": "Telegram API token:"
},
{
"type": "input",
"title": "",
"name": "telegramApi-arg",
"style": "width:60%;float:right",
"state": "{{telegramApi}}"
},
{
"type": "button",
"title": "{{ButSave}}",
"action": "set?telegramApi=[[telegramApi-arg]]",
"class": "btn btn-block btn-default",
"style": "width:100%;display:inline"
},
{
"type": "hr"
},
{
"type": "text",
"title": "<div style='margin-top:10px;margin-bottom:10px;'><font color='black'><p style='border: 1px solid #DCDCDC; border-radius: 3px; background-color: #F5F5F5; padding: 10px;'>После настройки telegram перезагрузите устройство что бы изменения вступили в силу</p></font></div>"
},
{
"type": "hr"
},
{
"type": "link",
"title": "Перезагрузить устройство",
"action": "javascript:if(confirm(renameBlock(jsonResponse,'Перезагрузить?'))){send_request(this,'/set?device=ok');}",
"class": "btn btn-block btn-danger"
}
]
}

View File

@@ -7,4 +7,58 @@ extern void csvCmdExecute(String& cmdStr);
extern void spaceCmdExecute(String& cmdStr); extern void spaceCmdExecute(String& cmdStr);
extern void loopCmdExecute(); extern void loopCmdExecute();
extern void addKey(String& key, String& keyNumberTable, int number); extern void addKey(String& key, String& keyNumberTable, int number);
extern int getKeyNum(String& key, String& keyNumberTable); extern int getKeyNum(String& key, String& keyNumberTable);
extern void buttonOut();
extern void buttonOutSet();
extern void pwmOut();
extern void pwmOutSet();
extern void buttonIn();
extern void buttonInSet();
extern void inputDigit();
extern void inputDigitSet();
extern void inputTime();
extern void inputTimeSet();
extern void textOut();
extern void textOutSet();
extern void analogAdc();
extern void analogReading();
extern void ultrasonicCm();
extern void ultrasonicReading();
extern void dallasTemp();
extern void dallasReading();
extern void dhtTemp();
extern void dhtReadingTemp();
extern void dhtHum();
extern void dhtReadingHum();
extern void bme280Temp();
extern void bme280ReadingTemp();
extern void bme280Hum();
extern void bme280ReadingHum();
extern void bme280Press();
extern void bme280ReadingPress();
extern void bmp280Temp();
extern void bmp280ReadingTemp();
extern void bmp280Press();
extern void bmp280ReadingPress();
//extern void modbus();
//extern void modbusReading();
extern void sysUptime();
extern void uptimeReading();
extern void logging();
extern void impuls();

View File

@@ -1,128 +0,0 @@
#pragma once
#include <Arduino.h>
#include "Cmd.h"
#include "Global.h"
class Scenario {
protected:
String _scenarioTmp;
String _condition;
String _conditionParam;
String _conditionSign;
String _conditionValue;
String _scenBlok;
String _event;
String _eventParam;
String _eventValue;
public:
Scenario() : _scenarioTmp{ "" },
_condition{ "" },
_conditionParam{ "" },
_conditionSign{ "" },
_conditionValue{ "" },
_scenBlok{ "" },
_event{ "" },
_eventParam{ "" },
_eventValue{ "" } {};
void load() {
_scenarioTmp = scenario;
}
void calculate1() {
_scenBlok = selectToMarker(_scenarioTmp, "end\n");
_condition = selectToMarker(_scenBlok, "\n");
_eventParam = selectToMarker(eventBuf, ",");
}
bool isIncommingEventInScenario() {
bool ret = false;
if (_condition.indexOf(_eventParam) != -1) {
ret = true;
}
return ret;
}
void calculate2() {
_scenarioTmp += "\n";
_scenarioTmp.replace("\r\n", "\n");
_scenarioTmp.replace("\r", "\n");
_conditionParam = selectFromMarkerToMarker(_condition, " ", 0);
_conditionSign = selectFromMarkerToMarker(_condition, " ", 1);
_conditionValue = selectFromMarkerToMarker(_condition, " ", 2);
if (!isDigitStr(_conditionValue)) _conditionValue = jsonReadStr(configLiveJson, _conditionValue);
_eventValue = jsonReadStr(configLiveJson, _conditionParam);
}
void delOneScenBlock() {
_scenarioTmp = deleteBeforeDelimiter(_scenarioTmp, "end\n");
}
void delOneEvent() {
eventBuf = deleteBeforeDelimiter(eventBuf, ",");
}
bool isConditionSatisfied() {
boolean flag = false;
if (_conditionSign == "=") {
flag = _eventValue == _conditionValue;
}
else if (_conditionSign == "!=") {
flag = _eventValue != _conditionValue;
}
else if (_conditionSign == "<") {
flag = _eventValue.toFloat() < _conditionValue.toFloat();
}
else if (_conditionSign == ">") {
flag = _eventValue.toFloat() > _conditionValue.toFloat();
}
else if (_conditionSign == ">=") {
flag = _eventValue.toFloat() >= _conditionValue.toFloat();
}
else if (_conditionSign == "<=") {
flag = _eventValue.toFloat() <= _conditionValue.toFloat();
}
if (flag) {
//SerialPrint("I", "Scenario", "event value: " + _eventValue);
//SerialPrint("I", "Scenario", "condition value: " + _conditionValue);
SerialPrint("I", "Scenario", "event: " + _condition);
}
return flag;
}
void loop() {
if (!this->isScenarioEnabled()) {
return;
}
this->load(); //после этого мы получили все сценарии
while (_scenarioTmp.length() > 1) {
this->calculate1(); //расчет необходимый для ответа на следующий вопрос
if (this->isIncommingEventInScenario()) { //если вошедшее событие есть в сценарии
this->calculate2();
if (this->isConditionSatisfied()) { //если вошедшее событие выполняет условие сценария
_scenBlok = deleteBeforeDelimiter(_scenBlok, "\n");
String forPrint = _scenBlok;
forPrint.replace("end", "");
forPrint.replace("\r\n", "");
forPrint.replace("\r", "");
forPrint.replace("\n", "");
SerialPrint("I", "Scenario", "making: " + forPrint);
spaceCmdExecute(_scenBlok);
}
}
this->delOneScenBlock(); //удалим использованный блок
}
this->delOneEvent();
}
bool isScenarioEnabled() {
return jsonReadBool(configSetupJson, "scen") && eventBuf != "";
}
};
extern Scenario* myScenario;

View File

@@ -0,0 +1,69 @@
#pragma once
#include <Arduino.h>
#include "Cmd.h"
#include "Global.h"
class Scenario {
public:
void loop() {
String allBlocks = scenario;
allBlocks.replace("\r\n", "\n");
allBlocks.replace("\r", "\n");
allBlocks += "\n";
String incommingEvent = selectToMarker(eventBuf, ",");
while (allBlocks.length() > 1) {
String oneBlock = selectToMarker(allBlocks, "end\n");
String condition = selectToMarker(oneBlock, "\n");
String setEvent = selectFromMarkerToMarker(condition, " ", 0);
String setEventSign = selectFromMarkerToMarker(condition, " ", 1);
String setEventValue = selectFromMarkerToMarker(condition, " ", 2);
if (!isDigitStr(setEventValue)) setEventValue = jsonReadStr(configLiveJson, setEventValue);
String incommingEventValue = jsonReadStr(configLiveJson, incommingEvent);
if (incommingEvent == setEvent) {
boolean flag = false;
if (setEventSign == "=") {
flag = incommingEventValue == setEventValue;
}
else if (setEventSign == "!=") {
flag = incommingEventValue != setEventValue;
}
else if (setEventSign == "<") {
flag = incommingEventValue.toFloat() < setEventValue.toFloat();
}
else if (setEventSign == ">") {
flag = incommingEventValue.toFloat() > setEventValue.toFloat();
}
else if (setEventSign == ">=") {
flag = incommingEventValue.toFloat() >= setEventValue.toFloat();
}
else if (setEventSign == "<=") {
flag = incommingEventValue.toFloat() <= setEventValue.toFloat();
}
if (flag) {
//SerialPrint("I", "Scenario", "incomming Event Value: " + incommingEventValue);
//SerialPrint("I", "Scenario", "set Event Value: " + setEventValue);
oneBlock = deleteBeforeDelimiter(oneBlock, "\n");
oneBlock.replace("end", "");
SerialPrint("I", "Scenario", condition + " set:\n" + oneBlock);
spaceCmdExecute(oneBlock);
}
}
allBlocks = deleteBeforeDelimiter(allBlocks, "end\n");
}
eventBuf = deleteBeforeDelimiter(eventBuf, ",");
}
};
extern Scenario* myScenario;

View File

@@ -0,0 +1,70 @@
#pragma once
#include <Arduino.h>
#include "Cmd.h"
#include "Global.h"
class Scenario {
public:
void loop() {
String allBlocks = scenario;
allBlocks.replace("\r\n", "\n");
allBlocks.replace("\r", "\n");
allBlocks += "\n";
String incommingEvent = selectToMarker(eventBuf, ",");
String incommingEventKey = selectToMarker(incommingEvent, " ");
String incommingEventValue = selectToMarkerLast(incommingEvent, " ");
while (allBlocks.length() > 1) {
String oneBlock = selectToMarker(allBlocks, "end\n");
String condition = selectToMarker(oneBlock, "\n");
String setEventKey = selectFromMarkerToMarker(condition, " ", 0);
if (incommingEventKey == setEventKey) {
String setEventSign = selectFromMarkerToMarker(condition, " ", 1);
String setEventValue = selectFromMarkerToMarker(condition, " ", 2);
if (!isDigitStr(setEventValue)) setEventValue = jsonReadStr(configLiveJson, setEventValue);
boolean flag = false;
if (setEventSign == "=") {
flag = incommingEventValue == setEventValue;
}
else if (setEventSign == "!=") {
flag = incommingEventValue != setEventValue;
}
else if (setEventSign == "<") {
flag = incommingEventValue.toFloat() < setEventValue.toFloat();
}
else if (setEventSign == ">") {
flag = incommingEventValue.toFloat() > setEventValue.toFloat();
}
else if (setEventSign == ">=") {
flag = incommingEventValue.toFloat() >= setEventValue.toFloat();
}
else if (setEventSign == "<=") {
flag = incommingEventValue.toFloat() <= setEventValue.toFloat();
}
if (flag) {
//SerialPrint("I", "Scenario", "incomming Event Value: " + incommingEventValue);
//SerialPrint("I", "Scenario", "set Event Value: " + setEventValue);
oneBlock = deleteBeforeDelimiter(oneBlock, "\n");
oneBlock.replace("end", "");
SerialPrint("I", "Scenario", condition + " \n" + oneBlock);
spaceCmdExecute(oneBlock);
}
}
allBlocks = deleteBeforeDelimiter(allBlocks, "end\n");
}
eventBuf = deleteBeforeDelimiter(eventBuf, ",");
}
};
extern Scenario* myScenario;

View File

@@ -3,11 +3,11 @@
//===========Firmware============================================================================================================================================= //===========Firmware=============================================================================================================================================
#ifdef ESP8266 #ifdef ESP8266
#define FIRMWARE_NAME "esp8266-iotm" #define FIRMWARE_NAME "esp8266-iotm"
#define FIRMWARE_VERSION 264 #define FIRMWARE_VERSION 267
#endif #endif
#ifdef ESP32 #ifdef ESP32
#define FIRMWARE_NAME "esp32-iotm" #define FIRMWARE_NAME "esp32-iotm"
#define FIRMWARE_VERSION 259 #define FIRMWARE_VERSION 267
#endif #endif
#define FLASH_4MB true #define FLASH_4MB true
@@ -105,4 +105,8 @@ enum LedStatus_t {
enum ConfigType_t { enum ConfigType_t {
CT_CONFIG, CT_CONFIG,
CT_SCENARIO CT_SCENARIO
}; };
//07.11.2020
//RAM: [===== ] 46.8% (used 38376 bytes from 81920 bytes)
//Flash: [===== ] 54.2% (used 566004 bytes from 1044464 bytes)

View File

@@ -3,6 +3,7 @@
#include <Adafruit_BME280.h> #include <Adafruit_BME280.h>
#include <Adafruit_BMP280.h> #include <Adafruit_BMP280.h>
#include <Arduino.h> #include <Arduino.h>
#include "CTBot.h"
#include <ArduinoJson.h> #include <ArduinoJson.h>
#include <ArduinoOTA.h> #include <ArduinoOTA.h>
#include <Bounce2.h> #include <Bounce2.h>
@@ -46,6 +47,7 @@ extern Bounce* buttons;
//Global vars //Global vars
extern boolean just_load; extern boolean just_load;
extern boolean telegramInitBeen;
// Json // Json
extern String configSetupJson; //все настройки extern String configSetupJson; //все настройки
@@ -91,7 +93,7 @@ extern void servo_();
extern void setLedStatus(LedStatus_t); extern void setLedStatus(LedStatus_t);
//Scenario //Scenario
extern void eventGen(String event_name, String number); extern void eventGen2(String eventName, String eventValue);
extern String add_set(String param_name); extern String add_set(String param_name);
//Timers //Timers

View File

@@ -1,55 +0,0 @@
#pragma once
extern void buttonOut();
extern void buttonOutSet();
extern void pwmOut();
extern void pwmOutSet();
extern void buttonIn();
extern void buttonInSet();
extern void inputDigit();
extern void inputDigitSet();
extern void inputTime();
extern void inputTimeSet();
extern void textOut();
extern void textOutSet();
extern void analogAdc();
extern void analogReading();
extern void ultrasonicCm();
extern void ultrasonicReading();
extern void dallasTemp();
extern void dallasReading();
extern void dhtTemp();
extern void dhtReadingTemp();
extern void dhtHum();
extern void dhtReadingHum();
extern void bme280Temp();
extern void bme280ReadingTemp();
extern void bme280Hum();
extern void bme280ReadingHum();
extern void bme280Press();
extern void bme280ReadingPress();
extern void bmp280Temp();
extern void bmp280ReadingTemp();
extern void bmp280Press();
extern void bmp280ReadingPress();
//extern void modbus();
//extern void modbusReading();
extern void sysUptime();
extern void uptimeReading();
extern void logging();
extern void impuls();

View File

@@ -1,7 +1,9 @@
#pragma once #pragma once
#ifdef ESP8266
#include "ESPAsyncUDP.h" #include "ESPAsyncUDP.h"
extern AsyncUDP asyncUdp; extern AsyncUDP asyncUdp;
extern void asyncUdpInit(); extern void asyncUdpInit();
extern String uint8tToString(uint8_t* data, size_t len); extern String uint8tToString(uint8_t* data, size_t len);
extern bool udpPacketValidation(String& data); extern bool udpPacketValidation(String& data);
extern void udpPacketParse(String& data); extern void udpPacketParse(String& data);
#endif

9
include/Telegram.h Normal file
View File

@@ -0,0 +1,9 @@
#pragma once
#include "Global.h"
extern void sendTelegramMsg();
extern void telegramInit();
extern void handleTelegram();
extern bool isTelegramEnabled();
extern void telegramMsgParse(String msg);
extern String returnListOfParams();

View File

@@ -4,6 +4,8 @@
#include "Class/LineParsing.h" #include "Class/LineParsing.h"
#include "Global.h" #include "Global.h"
class ButtonInClass : public LineParsing { class ButtonInClass : public LineParsing {
protected: protected:
int numberEntering = 0; int numberEntering = 0;
@@ -50,7 +52,7 @@ class ButtonInClass : public LineParsing {
} }
void switchChangeVirtual(String key, String state) { void switchChangeVirtual(String key, String state) {
eventGen(key, ""); eventGen2(key, state);
jsonWriteInt(configLiveJson, key, state.toInt()); jsonWriteInt(configLiveJson, key, state.toInt());
publishStatus(key, state); publishStatus(key, state);
} }

View File

@@ -32,7 +32,7 @@ public:
else { else {
digitalWrite(pinInt, !state.toInt()); digitalWrite(pinInt, !state.toInt());
} }
eventGen(key, ""); eventGen2(key, state);
jsonWriteInt(configLiveJson, key, state.toInt()); jsonWriteInt(configLiveJson, key, state.toInt());
publishStatus(key, state); publishStatus(key, state);
} }

View File

@@ -16,13 +16,13 @@ class InputClass : public LineParsing {
} }
void inputSetFloat(String key, String state) { void inputSetFloat(String key, String state) {
eventGen(key, ""); eventGen2(key, state);
jsonWriteFloat(configLiveJson, key, state.toFloat()); jsonWriteFloat(configLiveJson, key, state.toFloat());
publishStatus(key, state); publishStatus(key, state);
} }
void inputSetStr(String key, String state) { void inputSetStr(String key, String state) {
eventGen(key, ""); eventGen2(key, state);
jsonWriteStr(configLiveJson, key, state); jsonWriteStr(configLiveJson, key, state);
publishStatus(key, state); publishStatus(key, state);
} }

View File

@@ -15,7 +15,7 @@ class OutputTextClass : public LineParsing {
void OutputModuleChange(String key, String state) { void OutputModuleChange(String key, String state) {
state.replace("#", " "); state.replace("#", " ");
eventGen(key, ""); eventGen2(key, state);
jsonWriteStr(configLiveJson, key, state); jsonWriteStr(configLiveJson, key, state);
publishStatus(key, state); publishStatus(key, state);
} }

View File

@@ -22,7 +22,7 @@ class PwmOutClass : public LineParsing {
void pwmChange(String key, String pin, String state) { void pwmChange(String key, String pin, String state) {
int pinInt = pin.toInt(); int pinInt = pin.toInt();
analogWrite(pinInt, state.toInt()); analogWrite(pinInt, state.toInt());
eventGen(key, ""); eventGen2(key, state);
jsonWriteInt(configLiveJson, key, state.toInt()); jsonWriteInt(configLiveJson, key, state.toInt());
publishStatus(key, state); publishStatus(key, state);
} }

View File

@@ -26,7 +26,7 @@ class SensorAnalogClass : public SensorConvertingClass {
#endif #endif
value = this->mapping(key, value); value = this->mapping(key, value);
float valueFl = this->correction(key, value); float valueFl = this->correction(key, value);
eventGen(key, ""); eventGen2(key, String(valueFl));
jsonWriteStr(configLiveJson, key, String(valueFl)); jsonWriteStr(configLiveJson, key, String(valueFl));
publishStatus(key, String(valueFl)); publishStatus(key, String(valueFl));
SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl)); SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl));

View File

@@ -25,7 +25,7 @@ class SensorBme280Class : public SensorConvertingClass {
float value; float value;
value = bme.readTemperature(); value = bme.readTemperature();
float valueFl = this->correction(key, value); float valueFl = this->correction(key, value);
eventGen(key, ""); eventGen2(key, String(valueFl));
jsonWriteStr(configLiveJson, key, String(valueFl)); jsonWriteStr(configLiveJson, key, String(valueFl));
publishStatus(key, String(valueFl)); publishStatus(key, String(valueFl));
SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl)); SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl));
@@ -35,7 +35,7 @@ class SensorBme280Class : public SensorConvertingClass {
float value; float value;
value = bme.readHumidity(); value = bme.readHumidity();
float valueFl = this->correction(key, value); float valueFl = this->correction(key, value);
eventGen(key, ""); eventGen2(key, String(valueFl));
jsonWriteStr(configLiveJson, key, String(valueFl)); jsonWriteStr(configLiveJson, key, String(valueFl));
publishStatus(key, String(valueFl)); publishStatus(key, String(valueFl));
SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl)); SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl));
@@ -46,7 +46,7 @@ class SensorBme280Class : public SensorConvertingClass {
value = bme.readPressure(); value = bme.readPressure();
value = value / 1.333224 / 100; value = value / 1.333224 / 100;
float valueFl = this->correction(key, value); float valueFl = this->correction(key, value);
eventGen(key, ""); eventGen2(key, String(valueFl));
jsonWriteStr(configLiveJson, key, String(valueFl)); jsonWriteStr(configLiveJson, key, String(valueFl));
publishStatus(key, String(valueFl)); publishStatus(key, String(valueFl));
SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl)); SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl));

View File

@@ -26,7 +26,7 @@ class SensorBmp280Class : public SensorConvertingClass {
bmp_temp->getEvent(&temp_event); bmp_temp->getEvent(&temp_event);
value = temp_event.temperature; value = temp_event.temperature;
float valueFl = this->correction(key, value); float valueFl = this->correction(key, value);
eventGen(key, ""); eventGen2(key, String(valueFl));
jsonWriteStr(configLiveJson, key, String(valueFl)); jsonWriteStr(configLiveJson, key, String(valueFl));
publishStatus(key, String(valueFl)); publishStatus(key, String(valueFl));
SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl)); SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl));
@@ -39,7 +39,7 @@ class SensorBmp280Class : public SensorConvertingClass {
value = pressure_event.pressure; value = pressure_event.pressure;
value = value / 1.333224; value = value / 1.333224;
float valueFl = this->correction(key, value); float valueFl = this->correction(key, value);
eventGen(key, ""); eventGen2(key, String(valueFl));
jsonWriteStr(configLiveJson, key, String(valueFl)); jsonWriteStr(configLiveJson, key, String(valueFl));
publishStatus(key, String(valueFl)); publishStatus(key, String(valueFl));
SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl)); SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl));

View File

@@ -41,7 +41,7 @@ class SensorDhtClass : public SensorConvertingClass {
if (String(value) != "nan") { if (String(value) != "nan") {
//value = this->mapping(key, value); //value = this->mapping(key, value);
float valueFl = this->correction(key, value); float valueFl = this->correction(key, value);
eventGen(key, ""); eventGen2(key, String(valueFl));
jsonWriteStr(configLiveJson, key, String(valueFl)); jsonWriteStr(configLiveJson, key, String(valueFl));
publishStatus(key, String(valueFl)); publishStatus(key, String(valueFl));
SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl)); SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl));
@@ -65,7 +65,7 @@ class SensorDhtClass : public SensorConvertingClass {
if (String(value) != "nan") { if (String(value) != "nan") {
//value = this->mapping(key, value); //value = this->mapping(key, value);
float valueFl = this->correction(key, value); float valueFl = this->correction(key, value);
eventGen(key, ""); eventGen2(key, String(valueFl));
jsonWriteStr(configLiveJson, key, String(valueFl)); jsonWriteStr(configLiveJson, key, String(valueFl));
publishStatus(key, String(valueFl)); publishStatus(key, String(valueFl));
SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl)); SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl));

View File

@@ -35,7 +35,7 @@
// } // }
// //
// int valueFl = this->correction(key, value); // int valueFl = this->correction(key, value);
// eventGen(key, ""); // eventGen2(key, String(valueFl));
// jsonWriteStr(configLiveJson, key, String(valueFl)); // jsonWriteStr(configLiveJson, key, String(valueFl));
// publishStatus(key, String(valueFl)); // publishStatus(key, String(valueFl));
// SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl) + ", Slave dev addr: " + String(slaveAddress) + ", Register: " + String(regAddress)); // SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl) + ", Slave dev addr: " + String(slaveAddress) + ", Register: " + String(regAddress));

View File

@@ -40,7 +40,7 @@ class SensorUltrasonic : public SensorConvertingClass {
value = this->mapping(key, value); value = this->mapping(key, value);
float valueFl = this->correction(key, value); float valueFl = this->correction(key, value);
eventGen(key, ""); eventGen2(key, String(valueFl));
jsonWriteStr(configLiveJson, key, String(valueFl)); jsonWriteStr(configLiveJson, key, String(valueFl));
publishStatus(key, String(valueFl)); publishStatus(key, String(valueFl));
SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl)); SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl));

View File

@@ -26,6 +26,7 @@ lib_deps =
AsyncTCP AsyncTCP
madhephaestus/ESP32Servo madhephaestus/ESP32Servo
luc-github/ESP32SSDP luc-github/ESP32SSDP
CTBot
monitor_filters = esp32_exception_decoder monitor_filters = esp32_exception_decoder
upload_speed = 921600 upload_speed = 921600
monitor_speed = 115200 monitor_speed = 115200
@@ -43,6 +44,7 @@ lib_deps =
ESPAsyncTCP ESPAsyncTCP
ESPAsyncUDP ESPAsyncUDP
EspSoftwareSerial EspSoftwareSerial
CTBot
monitor_filters = esp8266_exception_decoder monitor_filters = esp8266_exception_decoder
upload_speed = 921600 upload_speed = 921600
monitor_speed = 115200 monitor_speed = 115200
@@ -58,6 +60,7 @@ lib_deps =
ESPAsyncTCP ESPAsyncTCP
ESPAsyncUDP ESPAsyncUDP
EspSoftwareSerial EspSoftwareSerial
CTBot
monitor_filters = esp8266_exception_decoder monitor_filters = esp8266_exception_decoder
upload_speed = 921600 upload_speed = 921600
monitor_speed = 115200 monitor_speed = 115200

View File

@@ -1,5 +1,5 @@
#include "BufferExecute.h" #include "BufferExecute.h"
#include "items/SensorDallas.h"
#include "Global.h" #include "Global.h"
#include "Module/Terminal.h" #include "Module/Terminal.h"
@@ -23,9 +23,81 @@ void csvCmdExecute(String& cmdStr) {
int count = 0; int count = 0;
while (cmdStr.length()) { while (cmdStr.length()) {
String buf = selectToMarker(cmdStr, "\n"); String buf = selectToMarker(cmdStr, "\n");
buf = deleteBeforeDelimiter(buf, " "); //отсечка чекбокса buf = deleteBeforeDelimiter(buf, " "); //отсечка чекбокса
count++; count++;
if (count > 1) sCmd.readStr(buf); if (count > 1) {
SerialPrint("I", "Items", buf);
String order = selectToMarker(buf, " "); //отсечка самой команды
if (order == F("button-out")) {
sCmd.addCommand(order.c_str(), buttonOut);
}
else if (order == F("pwm-out")) {
sCmd.addCommand(order.c_str(), pwmOut);
}
else if (order == F("button-in")) {
sCmd.addCommand(order.c_str(), buttonIn);
}
else if (order == F("input-digit")) {
sCmd.addCommand(order.c_str(), inputDigit);
}
else if (order == F("input-time")) {
sCmd.addCommand(order.c_str(), inputTime);
}
else if (order == F("output-text")) {
sCmd.addCommand(order.c_str(), textOut);
}
else if (order == F("analog-adc")) {
sCmd.addCommand(order.c_str(), analogAdc);
}
else if (order == F("ultrasonic-cm")) {
sCmd.addCommand(order.c_str(), ultrasonicCm);
}
else if (order == F("dallas-temp")) {
sCmd.addCommand(order.c_str(), dallas);
}
else if (order == F("dht-temp")) {
sCmd.addCommand(order.c_str(), dhtTemp);
}
else if (order == F("dht-hum")) {
sCmd.addCommand(order.c_str(), dhtHum);
}
else if (order == F("bme280-temp")) {
sCmd.addCommand(order.c_str(), bme280Temp);
}
else if (order == F("bme280-hum")) {
sCmd.addCommand(order.c_str(), bme280Hum);
}
else if (order == F("bme280-press")) {
sCmd.addCommand(order.c_str(), bme280Press);
}
else if (order == F("bmp280-temp")) {
sCmd.addCommand(order.c_str(), bmp280Temp);
}
else if (order == F("bmp280-press")) {
sCmd.addCommand(order.c_str(), bmp280Press);
}
else if (order == F("modbus")) {
//sCmd.addCommand(order.c_str(), modbus);
}
else if (order == F("uptime")) {
sCmd.addCommand(order.c_str(), sysUptime);
}
else if (order == F("logging")) {
sCmd.addCommand(order.c_str(), logging);
}
else if (order == F("impuls-out")) {
sCmd.addCommand(order.c_str(), impuls);
}
sCmd.readStr(buf);
}
cmdStr = deleteBeforeDelimiter(cmdStr, "\n"); cmdStr = deleteBeforeDelimiter(cmdStr, "\n");
} }
} }
@@ -80,7 +152,7 @@ void addKey(String& key, String& keyNumberTable, int number) {
int getKeyNum(String& key, String& keyNumberTable) { int getKeyNum(String& key, String& keyNumberTable) {
String keyNumberTableBuf = keyNumberTable; String keyNumberTableBuf = keyNumberTable;
//SerialPrint("","",keyNumberTable);
int number = -1; int number = -1;
while (keyNumberTableBuf.length()) { while (keyNumberTableBuf.length()) {
String tmp = selectToMarker(keyNumberTableBuf, ","); String tmp = selectToMarker(keyNumberTableBuf, ",");

View File

@@ -1,2 +0,0 @@
#include "Class/ScenarioClass.h"
Scenario* myScenario;

View File

@@ -0,0 +1,18 @@
#include "Class/ScenarioClass3.h"
Scenario* myScenario;
//void eventGen(String event_name, String number) {
// if (!jsonReadBool(configSetupJson, "scen")) {
// return;
// }
// SerialPrint("", "", event_name);
// eventBuf += event_name + number + ",";
//}
void eventGen2(String eventName, String eventValue) {
if (!jsonReadBool(configSetupJson, "scen")) {
return;
}
//Serial.println(eventName + " " + eventValue);
eventBuf += eventName + " " + eventValue + ",";
}

View File

@@ -18,6 +18,7 @@ DallasTemperature sensors;
*/ */
boolean just_load = true; boolean just_load = true;
boolean telegramInitBeen = false;
// Json // Json
String configSetupJson = "{}"; String configSetupJson = "{}";

View File

@@ -35,19 +35,18 @@ void Device_init() {
if (mySensorDallas2 != nullptr) { if (mySensorDallas2 != nullptr) {
mySensorDallas2->clear(); mySensorDallas2->clear();
} }
//======clear logging params====== //======clear logging params======
if (myLogging != nullptr) { if (myLogging != nullptr) {
myLogging->clear(); myLogging->clear();
} }
loggingKeyList = ""; loggingKeyList = "";
//======clear impuls params======= //======clear impuls params=======
if (myImpulsOut != nullptr) { if (myImpulsOut != nullptr) {
myImpulsOut->clear(); myImpulsOut->clear();
} }
impulsKeyList = ""; impulsKeyList = "";
impulsEnterCounter = -1; impulsEnterCounter = -1;
//================================
#ifdef LAYOUT_IN_RAM #ifdef LAYOUT_IN_RAM

View File

@@ -1,60 +1,60 @@
#include "ItemsCmd.h" //#include "BufferExecute.h"
//
//#include "BufferExecute.h"
//#include "Class/NotAsync.h"
//#include "Cmd.h"
//#include "Global.h"
//#include "Module/Terminal.h"
//#include "Servo/Servos.h"
//
//#include "items/SensorDallas.h"
//
//Terminal *term = nullptr;
//
//boolean but[NUM_BUTTONS];
//Bounce *buttons = new Bounce[NUM_BUTTONS];
//
//#ifdef ESP8266
//SoftwareSerial *mySerial = nullptr;
//#else
//HardwareSerial *mySerial = nullptr;
//#endif
//
//void getData();
//
//void cmd_init() {
//sCmd.addCommand("button-out", buttonOut);
//sCmd.addCommand("pwm-out", pwmOut);
//sCmd.addCommand("button-in", buttonIn);
#include "BufferExecute.h" //sCmd.addCommand("input-digit", inputDigit);
#include "Class/NotAsync.h" //sCmd.addCommand("input-time", inputTime);
#include "Cmd.h" //sCmd.addCommand("output-text", textOut);
#include "Global.h"
#include "Module/Terminal.h"
#include "Servo/Servos.h"
#include "items/SensorDallas.h" //sCmd.addCommand("analog-adc", analogAdc);
//sCmd.addCommand("ultrasonic-cm", ultrasonicCm);
//sCmd.addCommand("dallas-temp", dallas);
Terminal *term = nullptr; //sCmd.addCommand("dht-temp", dhtTemp);
//sCmd.addCommand("dht-hum", dhtHum);
boolean but[NUM_BUTTONS]; //sCmd.addCommand("bme280-temp", bme280Temp);
Bounce *buttons = new Bounce[NUM_BUTTONS]; //sCmd.addCommand("bme280-hum", bme280Hum);
//sCmd.addCommand("bme280-press", bme280Press);
#ifdef ESP8266 //sCmd.addCommand("bmp280-temp", bmp280Temp);
SoftwareSerial *mySerial = nullptr; //sCmd.addCommand("bmp280-press", bmp280Press);
#else
HardwareSerial *mySerial = nullptr;
#endif
void getData();
void cmd_init() {
sCmd.addCommand("button-out", buttonOut);
sCmd.addCommand("pwm-out", pwmOut);
sCmd.addCommand("button-in", buttonIn);
sCmd.addCommand("input-digit", inputDigit);
sCmd.addCommand("input-time", inputTime);
sCmd.addCommand("output-text", textOut);
sCmd.addCommand("analog-adc", analogAdc);
sCmd.addCommand("ultrasonic-cm", ultrasonicCm);
sCmd.addCommand("dallas-temp", dallas);
sCmd.addCommand("dht-temp", dhtTemp);
sCmd.addCommand("dht-hum", dhtHum);
sCmd.addCommand("bme280-temp", bme280Temp);
sCmd.addCommand("bme280-hum", bme280Hum);
sCmd.addCommand("bme280-press", bme280Press);
sCmd.addCommand("bmp280-temp", bmp280Temp);
sCmd.addCommand("bmp280-press", bmp280Press);
//sCmd.addCommand("modbus", modbus); //sCmd.addCommand("modbus", modbus);
sCmd.addCommand("uptime", sysUptime); //sCmd.addCommand("uptime", sysUptime);
sCmd.addCommand("logging", logging); //sCmd.addCommand("logging", logging);
sCmd.addCommand("impuls-out", impuls); //sCmd.addCommand("impuls-out", impuls);
handle_time_init();
} //}
// sCmd.addCommand("timerStart", timerStart_); // sCmd.addCommand("timerStart", timerStart_);
// sCmd.addCommand("timerStop", timerStop_); // sCmd.addCommand("timerStop", timerStop_);
@@ -249,7 +249,7 @@ void cmd_init() {
// servo->write(value); // servo->write(value);
// } // }
// //
// eventGen("servo", number); // eventGen2("servo", number);
// jsonWriteInt(configLiveJson, "servo" + number, value); // jsonWriteInt(configLiveJson, "servo" + number, value);
// publishStatus("servo" + number, String(value, DEC)); // publishStatus("servo" + number, String(value, DEC));
//} //}

View File

@@ -1,97 +0,0 @@
#include "Cmd.h"
#include "Global.h"
#include "Class/ScenarioClass.h"
boolean isScenarioEnabled() {
return jsonReadBool(configSetupJson, "scen") && eventBuf != "";
}
//void loopScenario() {
// if (!isScenarioEnabled()) {
// return;
// }
// String scenarioTmp = scenario;
// scenarioTmp += "\n";
// scenarioTmp.replace("\r\n", "\n");
// scenarioTmp.replace("\r", "\n");
//
// while (scenarioTmp.length()) {
// String scenBlok = selectToMarker(scenarioTmp, "end"); //выделяем первый сценарий
// if (!scenBlok.length()) {
// return;
// }
//
// size_t i = 0;
// i++;
// if (scenario_line_status[i] == 1) {
// String condition = selectToMarker(scenBlok, "\n"); //выделяем условие
//
// String conditionParam = selectFromMarkerToMarker(condition, " ", 0); //выделяем параметр условия
// String order = eventBuf;
// String eventParam = selectToMarker(order, ","); //выделяем параметр события
//
// if (conditionParam == eventParam) { //если поступившее событие равно событию заданному buttonSet1 в файле начинаем его обработку
//
// String conditionSign = selectFromMarkerToMarker(condition, " ", 1); //выделяем знак (=)
//
// String conditionValue = selectFromMarkerToMarker(condition, " ", 2); //выделяем значение (1)
//
// boolean flag = false;
//
// String eventParam = jsonReadStr(configLiveJson, conditionParam); //получаем значение этого параметра события из json
//
// if (conditionSign == "=") {
// flag = eventParam == conditionValue;
// } else if (conditionSign == "!=") {
// flag = eventParam != conditionValue;
// } else if (conditionSign == "<") {
// flag = eventParam.toInt() < conditionValue.toInt();
// } else if (conditionSign == ">") {
// flag = eventParam.toInt() > conditionValue.toInt();
// } else if (conditionSign == ">=") {
// flag = eventParam.toInt() >= conditionValue.toInt();
// } else if (conditionSign == "<=") {
// flag = eventParam.toInt() <= conditionValue.toInt();
// }
//
// if (flag) {
// scenBlok = deleteBeforeDelimiter(scenBlok, "\n"); // удаляем строку самого сценария оставляя только команды
// SerialPrint("I","module","do: " + scenBlok);
// spaceCmdExecute(scenBlok); // выполняем все команды
// }
// }
// }
// scenarioTmp = deleteBeforeDelimiter(scenarioTmp, "end\n"); //удаляем первый сценарий
// }
//
// String eventBufTmp = eventBuf; //читаем файл событий
// eventBufTmp = deleteBeforeDelimiter(eventBufTmp, ","); //удаляем выполненное событие
// eventBuf = eventBufTmp; //записываем обновленный файл событий
//}
void eventGen(String event_name, String number) {
if (!jsonReadBool(configSetupJson, "scen")) {
return;
}
eventBuf = event_name + number + ",";
}
//String add_set(String str) {
// String num1 = str.substring(str.length() - 1);
// String num2 = str.substring(str.length() - 2, str.length() - 1);
// if (isDigitStr(num1) && isDigitStr(num2)) {
// str = str.substring(0, str.length() - 2) + "Set" + num2 + num1;
// } else {
// if (isDigitStr(num1)) {
// str = str.substring(0, str.length() - 1) + "Set" + num1;
// }
// }
// return str;
//}
//button-out1 = 1
//button-out2 1
//button-out3 1
//end

View File

@@ -54,7 +54,7 @@
// counter = 0; // counter = 0;
// value = dht.getTemperature(); // value = dht.getTemperature();
// if (String(value) != "nan") { // if (String(value) != "nan") {
// //eventGen(dhtT_value_name, ""); // //eventGen2(dhtT_value_name, "");
// //jsonWriteStr(configLiveJson, dhtT_value_name, String(value)); // //jsonWriteStr(configLiveJson, dhtT_value_name, String(value));
// // publishStatus(dhtT_value_name, String(value)); // // publishStatus(dhtT_value_name, String(value));
// //SerialPrint("I", "Sensor", "'" + dhtT_value_name + "' data: " + String(value)); // //SerialPrint("I", "Sensor", "'" + dhtT_value_name + "' data: " + String(value));
@@ -92,7 +92,7 @@
// counter = 0; // counter = 0;
// value = dht.getHumidity(); // value = dht.getHumidity();
// if (String(value) != "nan") { // if (String(value) != "nan") {
// //eventGen(dhtH_value_name, ""); // //eventGen2(dhtH_value_name, "");
// //jsonWriteStr(configLiveJson, dhtH_value_name, String(value)); // //jsonWriteStr(configLiveJson, dhtH_value_name, String(value));
// // publishStatus(dhtH_value_name, String(value)); // // publishStatus(dhtH_value_name, String(value));
// //SerialPrint("I", "Sensor", "'" + dhtH_value_name + "' data: " + String(value)); // //SerialPrint("I", "Sensor", "'" + dhtH_value_name + "' data: " + String(value));
@@ -117,7 +117,7 @@
// //value = dht.computePerception(jsonReadStr(configLiveJson, dhtT_value_name).toFloat(), jsonReadStr(configLiveJson, dhtH_value_name).toFloat(), false); // //value = dht.computePerception(jsonReadStr(configLiveJson, dhtT_value_name).toFloat(), jsonReadStr(configLiveJson, dhtH_value_name).toFloat(), false);
// String final_line = perceptionStr(value); // String final_line = perceptionStr(value);
// jsonWriteStr(configLiveJson, "dhtPerception", final_line); // jsonWriteStr(configLiveJson, "dhtPerception", final_line);
// eventGen("dhtPerception", ""); // eventGen2("dhtPerception", "");
// publishStatus("dhtPerception", final_line); // publishStatus("dhtPerception", final_line);
// if (mqtt.connected()) { // if (mqtt.connected()) {
// SerialPrint("I", "Sensor", "'dhtPerception' data: " + final_line); // SerialPrint("I", "Sensor", "'dhtPerception' data: " + final_line);
@@ -142,7 +142,7 @@
// //dht.getComfortRatio(cf, jsonReadStr(configLiveJson, dhtT_value_name).toFloat(), jsonReadStr(configLiveJson, dhtH_value_name).toFloat(), false); // //dht.getComfortRatio(cf, jsonReadStr(configLiveJson, dhtT_value_name).toFloat(), jsonReadStr(configLiveJson, dhtH_value_name).toFloat(), false);
// String final_line = comfortStr(cf); // String final_line = comfortStr(cf);
// jsonWriteStr(configLiveJson, "dhtComfort", final_line); // jsonWriteStr(configLiveJson, "dhtComfort", final_line);
// eventGen("dhtComfort", ""); // eventGen2("dhtComfort", "");
// publishStatus("dhtComfort", final_line); // publishStatus("dhtComfort", final_line);
// SerialPrint("I", "Sensor", "'dhtComfort' send date " + final_line); // SerialPrint("I", "Sensor", "'dhtComfort' send date " + final_line);
// } // }
@@ -234,7 +234,7 @@
// } else { // } else {
// //value = dht.computeDewPoint(jsonReadStr(configLiveJson, dhtT_value_name).toFloat(), jsonReadStr(configLiveJson, dhtH_value_name).toFloat(), false); // //value = dht.computeDewPoint(jsonReadStr(configLiveJson, dhtT_value_name).toFloat(), jsonReadStr(configLiveJson, dhtH_value_name).toFloat(), false);
// jsonWriteInt(configLiveJson, "dhtDewpoint", value); // jsonWriteInt(configLiveJson, "dhtDewpoint", value);
// eventGen("dhtDewpoint", ""); // eventGen2("dhtDewpoint", "");
// publishStatus("dhtDewpoint", String(value)); // publishStatus("dhtDewpoint", String(value));
// SerialPrint("I", "Sensor", "'dhtDewpoint' data: " + String(value)); // SerialPrint("I", "Sensor", "'dhtDewpoint' data: " + String(value));
// } // }
@@ -270,7 +270,7 @@
// bmp_temp->getEvent(&temp_event); // bmp_temp->getEvent(&temp_event);
// value = temp_event.temperature; // value = temp_event.temperature;
// //jsonWriteStr(configLiveJson, bmp280T_value_name, String(value)); // //jsonWriteStr(configLiveJson, bmp280T_value_name, String(value));
// //eventGen(bmp280T_value_name, ""); // //eventGen2(bmp280T_value_name, "");
// // publishStatus(bmp280T_value_name, String(value)); // // publishStatus(bmp280T_value_name, String(value));
// //SerialPrint("I", "Sensor", "'" + bmp280T_value_name + "' data: " + String(value)); // //SerialPrint("I", "Sensor", "'" + bmp280T_value_name + "' data: " + String(value));
//} //}
@@ -302,7 +302,7 @@
// value = pressure_event.pressure; // value = pressure_event.pressure;
// value = value / 1.333224; // value = value / 1.333224;
// //jsonWriteStr(configLiveJson, bmp280P_value_name, String(value)); // //jsonWriteStr(configLiveJson, bmp280P_value_name, String(value));
// //eventGen(bmp280P_value_name, ""); // //eventGen2(bmp280P_value_name, "");
// // publishStatus(bmp280P_value_name, String(value)); // // publishStatus(bmp280P_value_name, String(value));
// //SerialPrint("I", "Sensor", "'" + bmp280P_value_name + "' data: " + String(value)); // //SerialPrint("I", "Sensor", "'" + bmp280P_value_name + "' data: " + String(value));
//} //}
@@ -327,7 +327,7 @@
// float value = 0; // float value = 0;
// value = bme.readTemperature(); // value = bme.readTemperature();
// //jsonWriteStr(configLiveJson, bme280T_value_name, String(value)); // //jsonWriteStr(configLiveJson, bme280T_value_name, String(value));
// //eventGen(bme280T_value_name, ""); // //eventGen2(bme280T_value_name, "");
// // publishStatus(bme280T_value_name, String(value)); // // publishStatus(bme280T_value_name, String(value));
// //SerialPrint("I", "Sensor", "'" + bme280T_value_name + "' data: " + String(value)); // //SerialPrint("I", "Sensor", "'" + bme280T_value_name + "' data: " + String(value));
//} //}
@@ -351,7 +351,7 @@
// value = bme.readPressure(); // value = bme.readPressure();
// value = value / 1.333224 / 100; // value = value / 1.333224 / 100;
// //jsonWriteStr(configLiveJson, bme280P_value_name, String(value)); // //jsonWriteStr(configLiveJson, bme280P_value_name, String(value));
// //eventGen(bme280P_value_name, ""); // //eventGen2(bme280P_value_name, "");
// // publishStatus(bme280P_value_name, String(value)); // // publishStatus(bme280P_value_name, String(value));
// //SerialPrint("I", "Sensor", "'" + bme280P_value_name + "' data: " + String(value)); // //SerialPrint("I", "Sensor", "'" + bme280P_value_name + "' data: " + String(value));
//} //}
@@ -374,7 +374,7 @@
// float value = 0; // float value = 0;
// value = bme.readHumidity(); // value = bme.readHumidity();
// //jsonWriteStr(configLiveJson, bme280H_value_name, String(value)); // //jsonWriteStr(configLiveJson, bme280H_value_name, String(value));
// //eventGen(bme280H_value_name, ""); // //eventGen2(bme280H_value_name, "");
// // publishStatus(bme280H_value_name, String(value)); // // publishStatus(bme280H_value_name, String(value));
// //SerialPrint("I", "Sensor", "'" + bme280H_value_name + "' data: " + String(value)); // //SerialPrint("I", "Sensor", "'" + bme280H_value_name + "' data: " + String(value));
//} //}
@@ -397,7 +397,7 @@
// float value = bme.readAltitude(1013.25); // float value = bme.readAltitude(1013.25);
// //jsonWriteStr(configLiveJson, bme280A_value_name, String(value, 2)); // //jsonWriteStr(configLiveJson, bme280A_value_name, String(value, 2));
// //
// //eventGen(bme280A_value_name, ""); // //eventGen2(bme280A_value_name, "");
// //
// // publishStatus(bme280A_value_name, String(value)); // // publishStatus(bme280A_value_name, String(value));
// //

112
src/Telegram.cpp Normal file
View File

@@ -0,0 +1,112 @@
#include "Telegram.h"
CTBot* myBot{ nullptr };
void telegramInit() {
if (isTelegramEnabled()) {
telegramInitBeen = true;
sCmd.addCommand("telegram", sendTelegramMsg);
String token = jsonReadStr(configSetupJson, "telegramApi");
if (!myBot) {
myBot = new CTBot();
}
myBot->setTelegramToken(token);
myBot->enableUTF8Encoding(true);
if (myBot->testConnection()) {
SerialPrint("I", "Telegram", "Connected");
}
else {
SerialPrint("E", "Telegram", "Not connected");
}
}
}
void handleTelegram() {
if (telegramInitBeen) {
if (isTelegramEnabled()) {
TBMessage msg;
static unsigned long prevMillis;
unsigned long currentMillis = millis();
unsigned long difference = currentMillis - prevMillis;
if (difference >= 5000) {
prevMillis = millis();
if (myBot->getNewMessage(msg)) {
SerialPrint("->", "Telegram", "chat ID: " + String(msg.sender.id) + ", msg: " + String(msg.text));
jsonWriteInt(configSetupJson, "chatId", msg.sender.id);
saveConfig();
telegramMsgParse(String(msg.text));
}
}
}
}
}
void telegramMsgParse(String msg) {
if (msg.indexOf("set") != -1) {
msg = deleteBeforeDelimiter(msg, "_");
msg.replace("_", " ");
orderBuf += String(msg) + ",";
myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), "order done");
SerialPrint("<-", "Telegram", "chat ID: " + String(jsonReadInt(configSetupJson, "chatId")) + ", msg: " + String(msg));
}
else if (msg.indexOf("get") != -1) {
msg = deleteBeforeDelimiter(msg, "_");
myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), jsonReadStr(configLiveJson, msg));
SerialPrint("<-", "Telegram", "chat ID: " + String(jsonReadInt(configSetupJson, "chatId")) + ", msg: " + String(msg));
}
else if (msg.indexOf("all") != -1) {
String list = returnListOfParams();
myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), list);
SerialPrint("<-", "Telegram", "chat ID: " + String(jsonReadInt(configSetupJson, "chatId")) + "\n" + list);
}
else {
myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), "Wrong order, use /all to get all values, /get_id to get value, or /set_id_value to set value");
}
}
void sendTelegramMsg() {
String msg = sCmd.next();
String type = sCmd.next();
msg.replace("#", " ");
if (type == "1") {
static String prevMsg;
if (prevMsg != msg) {
prevMsg = msg;
myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), msg);
SerialPrint("<-", "Telegram", "chat ID: " + String(jsonReadInt(configSetupJson, "chatId")) + ", msg: " + msg);
}
} else if (type == "2") {
myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), msg);
SerialPrint("<-", "Telegram", "chat ID: " + String(jsonReadInt(configSetupJson, "chatId")) + ", msg: " + msg);
}
}
bool isTelegramEnabled() {
return jsonReadBool(configSetupJson, "telegonof");
}
String returnListOfParams() {
String cmdStr = readFile(DEVICE_CONFIG_FILE, 4096);
cmdStr += "\r\n";
cmdStr.replace("\r\n", "\n");
cmdStr.replace("\r", "\n");
int count = 0;
String out;
while (cmdStr.length()) {
String buf = selectToMarker(cmdStr, "\n");
count++;
if (count > 1) {
String id = selectFromMarkerToMarker(buf, ";", 2);
String value = jsonReadStr(configLiveJson, id);
String page = selectFromMarkerToMarker(buf, ";", 4);
page.replace("#", " ");
String name = selectFromMarkerToMarker(buf, ";", 5);
name.replace("#", " ");
out += page + " " + " " + name + " " + value + "\n";
}
cmdStr = deleteBeforeDelimiter(cmdStr, "\n");
}
return out;
}

View File

@@ -19,7 +19,7 @@ void Timer_countdown_init() {
if (time == 0) { if (time == 0) {
delTimer(String(number)); delTimer(String(number));
jsonWriteStr(configLiveJson, "timer" + String(number), "0"); jsonWriteStr(configLiveJson, "timer" + String(number), "0");
eventGen("timer", String(number)); eventGen2("timer", String(number));
} else { } else {
time--; time--;
addTimer(String(number), String(time)); addTimer(String(number), String(time));

View File

@@ -2,8 +2,6 @@
#include "Utils/FileUtils.h" #include "Utils/FileUtils.h"
#include "Global.h" #include "Global.h"
#include <ArduinoJson.h>
String jsonReadStr(String& json, String name) { String jsonReadStr(String& json, String name) {
DynamicJsonBuffer jsonBuffer; DynamicJsonBuffer jsonBuffer;
JsonObject& root = jsonBuffer.parseObject(json); JsonObject& root = jsonBuffer.parseObject(json);

View File

@@ -68,7 +68,7 @@ String addNewDevice() {
//============================================== //==============================================
jsonWriteStr(json, "uniqueId", mac); jsonWriteStr(json, "uniqueId", mac);
jsonWriteStr(json, "name", FIRMWARE_NAME); jsonWriteStr(json, "name", FIRMWARE_NAME);
jsonWriteInt(json, "model", FIRMWARE_VERSION); jsonWriteStr(json, "model", getChipId());
//============================================== //==============================================
http.begin(client, serverIP + F(":8082/api/devices/")); http.begin(client, serverIP + F(":8082/api/devices/"));
http.setAuthorization("admin", "admin"); http.setAuthorization("admin", "admin");
@@ -141,7 +141,8 @@ String updateDeviceStatus() {
"&uptime=" + timeNow->getUptime() + "&uptime=" + timeNow->getUptime() +
"&uptimeTotal=" + getUptimeTotal() + "&uptimeTotal=" + getUptimeTotal() +
"&version=" + FIRMWARE_VERSION + "&version=" + FIRMWARE_VERSION +
"&resetsTotal=" + String(getCurrentNumber("stat.txt")) + ""); "&resetsTotal=" + String(getCurrentNumber("stat.txt")) +
"&heap=" + String(ESP.getFreeHeap()) + "");
if (httpCode > 0) { if (httpCode > 0) {
ret = httpCode; ret = httpCode;
if (httpCode == HTTP_CODE_OK) { if (httpCode == HTTP_CODE_OK) {

View File

@@ -1,10 +1,10 @@
#include "Web.h" #include "Web.h"
#include "Class/NotAsync.h" #include "Class/NotAsync.h"
#include "Global.h" #include "Global.h"
#include "Init.h" #include "Init.h"
#include "ItemsList.h" #include "ItemsList.h"
#include "items/LoggingClass.h" #include "items/LoggingClass.h"
#include "Telegram.h"
bool parseRequestForPreset(AsyncWebServerRequest* request, uint8_t& preset) { bool parseRequestForPreset(AsyncWebServerRequest* request, uint8_t& preset) {
if (request->hasArg("preset")) { if (request->hasArg("preset")) {
@@ -193,14 +193,20 @@ void web_init() {
request->send(200, "text/html", payload); request->send(200, "text/html", payload);
} }
// //==============================push settings============================================= //==============================push settings=============================================
//#ifdef PUSH_ENABLED if (request->hasArg("telegramApi")) {
// if (request->hasArg("pushingboxid")) { jsonWriteStr(configSetupJson, "telegramApi", request->getParam("telegramApi")->value());
// jsonWriteStr(configSetupJson, "pushingboxid", request->getParam("pushingboxid")->value()); //telegramInit();
// saveConfig(); saveConfig();
// request->send(200); request->send(200);
// } }
//#endif if (request->hasArg("telegonof")) {
bool value = request->getParam("telegonof")->value().toInt();
jsonWriteBool(configSetupJson, "telegonof", value);
//telegramInit();
saveConfig();
request->send(200);
}
//==============================utilities settings============================================= //==============================utilities settings=============================================
if (request->hasArg("i2c")) { if (request->hasArg("i2c")) {
@@ -215,7 +221,7 @@ void web_init() {
serverIP = jsonReadStr(configSetupJson, "serverip"); serverIP = jsonReadStr(configSetupJson, "serverip");
request->send(200); request->send(200);
} }
}); });
//==============================list of items===================================================== //==============================list of items=====================================================
//server.on("/del", HTTP_GET, [](AsyncWebServerRequest* request) { //server.on("/del", HTTP_GET, [](AsyncWebServerRequest* request) {
@@ -230,7 +236,7 @@ void web_init() {
// request->redirect("/?setn.device"); // request->redirect("/?setn.device");
//}); //});
/* /*
* Check * Check
*/ */
server.on("/check", HTTP_GET, [](AsyncWebServerRequest* request) { server.on("/check", HTTP_GET, [](AsyncWebServerRequest* request) {
@@ -240,13 +246,17 @@ void web_init() {
String msg = ""; String msg = "";
if (lastVersion == FIRMWARE_VERSION) { if (lastVersion == FIRMWARE_VERSION) {
msg = F("Актуальная версия прошивки уже установлена."); msg = F("Актуальная версия прошивки уже установлена.");
} else if (lastVersion > FIRMWARE_VERSION) { }
else if (lastVersion > FIRMWARE_VERSION) {
msg = F("Новая версия прошивки<a href=\"#\" class=\"btn btn-block btn-danger\" onclick=\"send_request(this, '/upgrade');setTimeout(function(){ location.href='/?set.device'; }, 90000);html('my-block','<span class=loader></span>Идет обновление прошивки, после обновления страница перезагрузится автоматически...')\">Установить</a>"); msg = F("Новая версия прошивки<a href=\"#\" class=\"btn btn-block btn-danger\" onclick=\"send_request(this, '/upgrade');setTimeout(function(){ location.href='/?set.device'; }, 90000);html('my-block','<span class=loader></span>Идет обновление прошивки, после обновления страница перезагрузится автоматически...')\">Установить</a>");
} else if (lastVersion == -1) { }
else if (lastVersion == -1) {
msg = F("Cервер не найден. Попробуйте повторить позже..."); msg = F("Cервер не найден. Попробуйте повторить позже...");
} else if (lastVersion == -2) { }
else if (lastVersion == -2) {
msg = F("Устройство не подключено к роутеру!"); msg = F("Устройство не подключено к роутеру!");
} else if (lastVersion < FIRMWARE_VERSION) { }
else if (lastVersion < FIRMWARE_VERSION) {
msg = F("Ошибка версии. Попробуйте повторить позже..."); msg = F("Ошибка версии. Попробуйте повторить позже...");
} }
@@ -262,15 +272,15 @@ void web_init() {
jsonWriteStr(tmp, "title", "<button class=\"close\" onclick=\"toggle('my-block')\">×</button>" + msg); jsonWriteStr(tmp, "title", "<button class=\"close\" onclick=\"toggle('my-block')\">×</button>" + msg);
jsonWriteStr(tmp, "class", "pop-up"); jsonWriteStr(tmp, "class", "pop-up");
request->send(200, "text/html", tmp); request->send(200, "text/html", tmp);
}); });
/* /*
* Upgrade * Upgrade
*/ */
server.on("/upgrade", HTTP_GET, [](AsyncWebServerRequest* request) { server.on("/upgrade", HTTP_GET, [](AsyncWebServerRequest* request) {
myNotAsyncActions->make(do_UPGRADE); myNotAsyncActions->make(do_UPGRADE);
request->send(200, "text/html"); request->send(200, "text/html");
}); });
} }
void setConfigParam(const char* param, const String& value) { void setConfigParam(const char* param, const String& value) {

View File

@@ -1,8 +1,12 @@
#include "ItemsCmd.h" #include "BufferExecute.h"
#include "items/ButtonInClass.h" #include "items/ButtonInClass.h"
//==========================================Модуль физических кнопок======================================== //==========================================Модуль физических кнопок========================================
//button-in switch1 toggle Кнопки Свет 1 pin[2] db[20] //button-in switch1 toggle Кнопки Свет 1 pin[2] db[20]
//========================================================================================================== //==========================================================================================================
boolean but[NUM_BUTTONS];
Bounce *buttons = new Bounce[NUM_BUTTONS];
ButtonInClass myButtonIn; ButtonInClass myButtonIn;
void buttonIn() { void buttonIn() {
myButtonIn.update(); myButtonIn.update();

View File

@@ -1,6 +1,6 @@
#include "items/ButtonOutClass.h" #include "items/ButtonOutClass.h"
#include "ItemsCmd.h" #include "BufferExecute.h"
//==========================================Модуль кнопок=================================================== //==========================================Модуль кнопок===================================================
//button-out light toggle Кнопки Свет 1 pin[12] inv[1] st[1] //button-out light toggle Кнопки Свет 1 pin[12] inv[1] st[1]
//========================================================================================================== //==========================================================================================================

View File

@@ -4,7 +4,7 @@
#include "BufferExecute.h" #include "BufferExecute.h"
#include "Class/LineParsing.h" #include "Class/LineParsing.h"
#include "Global.h" #include "Global.h"
#include "ItemsCmd.h" #include "BufferExecute.h"
ImpulsOutClass::ImpulsOutClass(unsigned int impulsPin) { ImpulsOutClass::ImpulsOutClass(unsigned int impulsPin) {
_impulsPin = impulsPin; _impulsPin = impulsPin;

View File

@@ -1,4 +1,4 @@
#include "ItemsCmd.h" #include "BufferExecute.h"
#include "items/InputClass.h" #include "items/InputClass.h"
//==========================================Модуль ввода цифровых значений================================== //==========================================Модуль ввода цифровых значений==================================
//input-digit digit1 inputDigit Ввод Введите.цифру 4 st[60] //input-digit digit1 inputDigit Ввод Введите.цифру 4 st[60]

View File

@@ -1,4 +1,4 @@
#include "ItemsCmd.h" #include "BufferExecute.h"
#include "items/InputClass.h" #include "items/InputClass.h"
//==========================================Модуль ввода времени============================================ //==========================================Модуль ввода времени============================================
//========================================================================================================== //==========================================================================================================
@@ -19,9 +19,14 @@ void inputTimeSet() {
void handle_time_init() { void handle_time_init() {
ts.add( ts.add(
TIME, 1000, [&](void *) { TIME, 1000, [&](void*) {
jsonWriteStr(configLiveJson, "timenow", timeNow->getTime()); String timenow = timeNow->getTimeWOsec();
eventGen("timenow", ""); static String prevTime;
if (prevTime != timenow) {
prevTime = timenow;
jsonWriteStr(configLiveJson, "timenow", timenow);
eventGen2("timenow", timenow);
}
}, },
nullptr, true); nullptr, true);
} }

View File

@@ -4,7 +4,7 @@
#include "Class/LineParsing.h" #include "Class/LineParsing.h"
#include "Global.h" #include "Global.h"
#include "ItemsCmd.h" #include "BufferExecute.h"
LoggingClass::LoggingClass(unsigned long period, unsigned int maxPoints, String loggingValueKey, String key) { LoggingClass::LoggingClass(unsigned long period, unsigned int maxPoints, String loggingValueKey, String key) {
_period = period * 1000; _period = period * 1000;
@@ -42,7 +42,8 @@ void LoggingClass::addNewDelOldData(const String filename, size_t maxPoints, Str
logData += timeNow->getTimeUnix() + " " + payload + "\r\n"; logData += timeNow->getTimeUnix() + " " + payload + "\r\n";
writeFile(filename, logData); writeFile(filename, logData);
} }
} else { }
else {
if (timeNow->hasTimeSynced()) { if (timeNow->hasTimeSynced()) {
addFileLn(filename, timeNow->getTimeUnix() + " " + payload); addFileLn(filename, timeNow->getTimeUnix() + " " + payload);
} }
@@ -95,7 +96,8 @@ void sendLogData(String file, String topic) {
jsonWriteFloat(buf, "y1", value.toFloat()); jsonWriteFloat(buf, "y1", value.toFloat());
if (log_date.length() < 3) { if (log_date.length() < 3) {
json_array += buf; json_array += buf;
} else { }
else {
json_array += buf + ","; json_array += buf + ",";
} }
buf = "{}"; buf = "{}";
@@ -111,10 +113,12 @@ void sendLogData(String file, String topic) {
} }
void clean_log_date() { void clean_log_date() {
#ifdef ESP8266
auto dir = LittleFS.openDir("logs"); auto dir = LittleFS.openDir("logs");
while (dir.next()) { while (dir.next()) {
String fname = dir.fileName(); String fname = dir.fileName();
SerialPrint("I", "System", fname); SerialPrint("I", "System", fname);
removeFile("logs/" + fname); removeFile("logs/" + fname);
} }
#endif
} }

View File

@@ -1,4 +1,4 @@
#include "ItemsCmd.h" #include "BufferExecute.h"
#include "items/OutputTextClass.h" #include "items/OutputTextClass.h"
//===============================================Модуль вывода текста============================================ //===============================================Модуль вывода текста============================================
//output-text;id;anydata;Вывод;Сигнализация;order;st[Обнаружено.движение] //output-text;id;anydata;Вывод;Сигнализация;order;st[Обнаружено.движение]

View File

@@ -1,4 +1,4 @@
#include "ItemsCmd.h" #include "BufferExecute.h"
#include "items/PwmOutClass.h" #include "items/PwmOutClass.h"
//==========================================Модуль управления ШИМ=================================================== //==========================================Модуль управления ШИМ===================================================
//pwm-out volume range Кнопки Свет 1 pin[12] st[500] //pwm-out volume range Кнопки Свет 1 pin[12] st[500]

View File

@@ -1,4 +1,4 @@
#include "ItemsCmd.h" #include "BufferExecute.h"
#include "items/SensorAnalogClass.h" #include "items/SensorAnalogClass.h"
#ifdef ANALOG_ENABLED #ifdef ANALOG_ENABLED
//==============================================Модуль аналогового сенсора=========================================================================================== //==============================================Модуль аналогового сенсора===========================================================================================

View File

@@ -1,6 +1,6 @@
#include "items/SensorBme280Class.h" #include "items/SensorBme280Class.h"
#include "ItemsCmd.h" #include "BufferExecute.h"
//#ifdef SensorBme280Enabled //#ifdef SensorBme280Enabled
//=========================================Модуль ультрозвукового дальномера================================================================== //=========================================Модуль ультрозвукового дальномера==================================================================
//bme280-temp;id;anydata;Сенсоры;Температура;order;c[1] //bme280-temp;id;anydata;Сенсоры;Температура;order;c[1]

View File

@@ -1,6 +1,6 @@
#include "items/SensorBmp280Class.h" #include "items/SensorBmp280Class.h"
#include "ItemsCmd.h" #include "BufferExecute.h"
//#ifdef SensorBmp280Enabled //#ifdef SensorBmp280Enabled
//=========================================Модуль ультрозвукового дальномера================================================================== //=========================================Модуль ультрозвукового дальномера==================================================================
//bmp280-temp;id;anydata;Сенсоры;Температура;order;c[1] //bmp280-temp;id;anydata;Сенсоры;Температура;order;c[1]

View File

@@ -1,7 +1,7 @@
#include "items/SensorDallas.h" #include "items/SensorDallas.h"
#include "Class/LineParsing.h" #include "Class/LineParsing.h"
#include "Global.h" #include "Global.h"
#include "ItemsCmd.h" #include "BufferExecute.h"
#include <Arduino.h> #include <Arduino.h>
SensorDallas::SensorDallas(unsigned long interval, unsigned int pin, unsigned int index, String key) { SensorDallas::SensorDallas(unsigned long interval, unsigned int pin, unsigned int index, String key) {
@@ -30,7 +30,7 @@ void SensorDallas::loop() {
void SensorDallas::readDallas() { void SensorDallas::readDallas() {
sensors.requestTemperaturesByIndex(_index); sensors.requestTemperaturesByIndex(_index);
float value = sensors.getTempCByIndex(_index); float value = sensors.getTempCByIndex(_index);
eventGen(_key, ""); eventGen2(_key, String(value));
jsonWriteStr(configLiveJson, _key, String(value)); jsonWriteStr(configLiveJson, _key, String(value));
publishStatus(_key, String(value)); publishStatus(_key, String(value));
SerialPrint("I", "Sensor", "'" + _key + "' data: " + String(value)); SerialPrint("I", "Sensor", "'" + _key + "' data: " + String(value));

View File

@@ -1,6 +1,6 @@
#include "items/SensorDhtClass.h" #include "items/SensorDhtClass.h"
#include "ItemsCmd.h" #include "BufferExecute.h"
//#ifdef SensorDhtEnabled //#ifdef SensorDhtEnabled
//=========================================DHT Sensor================================================================== //=========================================DHT Sensor==================================================================
//dht-temp;id;anydata;Сенсоры;Температура;order;pin;type[dht11];c[1] //dht-temp;id;anydata;Сенсоры;Температура;order;pin;type[dht11];c[1]

View File

@@ -1,6 +1,6 @@
//#include "items/SensorModbusClass.h" //#include "items/SensorModbusClass.h"
// //
//#include "ItemsCmd.h" //#include "BufferExecute.h"
////#ifdef SensorModbusEnabled ////#ifdef SensorModbusEnabled
////=========================================Модуль modbus=================================================================================== ////=========================================Модуль modbus===================================================================================
////modbus;id;anydata;Сенсоры;Температура;order;addr[1];regaddr[0];c[1] ////modbus;id;anydata;Сенсоры;Температура;order;addr[1];regaddr[0];c[1]

View File

@@ -1,4 +1,4 @@
#include "ItemsCmd.h" #include "BufferExecute.h"
#include "items/SensorUltrasonicClass.h" #include "items/SensorUltrasonicClass.h"
//#ifdef SensorUltrasonicEnabled //#ifdef SensorUltrasonicEnabled
//=========================================Модуль ультрозвукового дальномера================================================================== //=========================================Модуль ультрозвукового дальномера==================================================================

View File

@@ -1,5 +1,5 @@
#include "Class/LineParsing.h" #include "Class/LineParsing.h"
#include "ItemsCmd.h" #include "BufferExecute.h"
#include "Global.h" #include "Global.h"
#include <Arduino.h> #include <Arduino.h>

View File

@@ -5,7 +5,7 @@
#include "Bus.h" #include "Bus.h"
#include "Class/CallBackTest.h" #include "Class/CallBackTest.h"
#include "Class/NotAsync.h" #include "Class/NotAsync.h"
#include "Class/ScenarioClass.h" #include "Class/ScenarioClass3.h"
#include "Cmd.h" #include "Cmd.h"
#include "Global.h" #include "Global.h"
#include "Init.h" #include "Init.h"
@@ -18,6 +18,7 @@
#include "items/LoggingClass.h" #include "items/LoggingClass.h"
#include "items/ImpulsOutClass.h" #include "items/ImpulsOutClass.h"
#include "items/SensorDallas.h" #include "items/SensorDallas.h"
#include "Telegram.h"
void not_async_actions(); void not_async_actions();
@@ -38,44 +39,47 @@ void setup() {
myNotAsyncActions = new NotAsync(do_LAST); myNotAsyncActions = new NotAsync(do_LAST);
myScenario = new Scenario(); myScenario = new Scenario();
SerialPrint("I", "FS", "FS Init");
fileSystemInit(); fileSystemInit();
SerialPrint("I", "FS", "FS Init");
SerialPrint("I", "Conf", "Config Init");
loadConfig(); loadConfig();
SerialPrint("I", "Conf", "Config Init");
SerialPrint("I", "Time", "Clock Init");
clock_init(); clock_init();
SerialPrint("I", "Time", "Clock Init");
SerialPrint("I", "CMD", "Commands Init"); handle_time_init();
cmd_init(); SerialPrint("I", "Time", "Handle time init(");
SerialPrint("I", "Sensors", "Sensors Init");
sensorsInit(); sensorsInit();
SerialPrint("I", "Sensors", "Sensors Init");
SerialPrint("I", "Items", "Items Init");
itemsListInit(); itemsListInit();
SerialPrint("I", "Items", "Items Init");
SerialPrint("I", "Init", "Init Init");
all_init(); all_init();
SerialPrint("I", "Init", "Init Init");
SerialPrint("I", "WIFI", "Network Init");
routerConnect(); routerConnect();
SerialPrint("I", "WIFI", "Network Init");
telegramInit();
SerialPrint("I", "Telegram", "Telegram Init");
SerialPrint("I", "Uptime", "Uptime Init");
uptime_init(); uptime_init();
SerialPrint("I", "Uptime", "Uptime Init");
SerialPrint("I", "Update", "Updater Init");
upgradeInit(); upgradeInit();
SerialPrint("I", "Update", "Updater Init");
SerialPrint("I", "HTTP", "HttpServer Init");
HttpServer::init(); HttpServer::init();
SerialPrint("I", "HTTP", "HttpServer Init");
SerialPrint("I", "Web", "WebAdmin Init");
web_init(); web_init();
SerialPrint("I", "Web", "WebAdmin Init");
SerialPrint("I", "Stat", "Stat Init");
initSt(); initSt();
SerialPrint("I", "Stat", "Stat Init");
#ifdef UDP_ENABLED #ifdef UDP_ENABLED
SerialPrint("I", "UDP", "Udp Init"); SerialPrint("I", "UDP", "Udp Init");
@@ -90,6 +94,8 @@ void setup() {
SsdpInit(); SsdpInit();
#endif #endif
//esp_log_level_set("esp_littlefs", ESP_LOG_NONE); //esp_log_level_set("esp_littlefs", ESP_LOG_NONE);
ts.add( ts.add(
@@ -99,9 +105,7 @@ void setup() {
nullptr, true); nullptr, true);
just_load = false; just_load = false;
initialized = true; //this second POST makes the data to be processed (you don't need to connect as "keep-alive" for that to work) initialized = true;
} }
void loop() { void loop() {
@@ -124,6 +128,8 @@ void loop() {
myNotAsyncActions->loop(); myNotAsyncActions->loop();
ts.update(); ts.update();
handleTelegram();
if (myLogging != nullptr) { if (myLogging != nullptr) {
for (unsigned int i = 0; i < myLogging->size(); i++) { for (unsigned int i = 0; i < myLogging->size(); i++) {
myLogging->at(i).loop(); myLogging->at(i).loop();