mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 22:22:16 +03:00
266 (fix scenario bug)
This commit is contained in:
@@ -3,8 +3,8 @@
|
||||
"chipID": "",
|
||||
"apssid": "IoTmanager",
|
||||
"appass": "",
|
||||
"routerssid": "rise",
|
||||
"routerpass": "hostel3333",
|
||||
"routerssid": "VOLODYA",
|
||||
"routerpass": "BELCHENKO",
|
||||
"timezone": 2,
|
||||
"ntp": "pool.ntp.org",
|
||||
"mqttServer": "91.204.228.124",
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
},
|
||||
{
|
||||
"type": "h4",
|
||||
"title": "LittleFS version: 265"
|
||||
"title": "LittleFS version: 266"
|
||||
},
|
||||
{
|
||||
"type": "hr"
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
//===========Firmware=============================================================================================================================================
|
||||
#ifdef ESP8266
|
||||
#define FIRMWARE_NAME "esp8266-iotm"
|
||||
#define FIRMWARE_VERSION 265
|
||||
#define FIRMWARE_VERSION 266
|
||||
#endif
|
||||
#ifdef ESP32
|
||||
#define FIRMWARE_NAME "esp32-iotm"
|
||||
#define FIRMWARE_VERSION 265
|
||||
#define FIRMWARE_VERSION 266
|
||||
#endif
|
||||
#define FLASH_4MB true
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#pragma once
|
||||
#include "Global.h"
|
||||
|
||||
extern void sendTelegramMsg();
|
||||
extern void telegramInit();
|
||||
extern void handleTelegram();
|
||||
extern bool isTelegramEnabled();
|
||||
extern bool isTelegramEnabled();
|
||||
extern void telegramMsgParse(String msg);
|
||||
@@ -1,2 +1,9 @@
|
||||
#include "Class/ScenarioClass.h"
|
||||
Scenario* myScenario;
|
||||
Scenario* myScenario;
|
||||
|
||||
void eventGen(String event_name, String number) {
|
||||
if (!jsonReadBool(configSetupJson, "scen")) {
|
||||
return;
|
||||
}
|
||||
eventBuf += event_name + number + ",";
|
||||
}
|
||||
@@ -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
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "Telegram.h"
|
||||
#include "Global.h"
|
||||
|
||||
|
||||
CTBot* myBot{ nullptr };
|
||||
|
||||
@@ -29,24 +29,38 @@ void handleTelegram() {
|
||||
static unsigned long prevMillis;
|
||||
unsigned long currentMillis = millis();
|
||||
unsigned long difference = currentMillis - prevMillis;
|
||||
if (difference >= 1000) {
|
||||
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();
|
||||
orderBuf += String(msg.text) + ",";
|
||||
myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), msg.text);
|
||||
SerialPrint("<-", "Telegram", "chat ID: " + String(jsonReadInt(configSetupJson, "chatId")) + ", msg: " + String(msg.text));
|
||||
telegramMsgParse(String(msg.text));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void telegramMsgParse(String msg) {
|
||||
SerialPrint("<-", "Telegram", "chat ID: " + String(jsonReadInt(configSetupJson, "chatId")) + ", msg: " + String(msg));
|
||||
if (msg.indexOf("order") != -1) {
|
||||
msg = deleteBeforeDelimiter(msg, " ");
|
||||
orderBuf += String(msg) + ",";
|
||||
myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), "order done");
|
||||
}
|
||||
else if (msg.indexOf("get") != -1) {
|
||||
msg = deleteBeforeDelimiter(msg, " ");
|
||||
myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), jsonReadStr(configLiveJson, msg));
|
||||
}
|
||||
else {
|
||||
myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), "wrong order, use 'get id' to get value, or 'order id value' to send order");
|
||||
}
|
||||
}
|
||||
|
||||
void sendTelegramMsg() {
|
||||
String msg = sCmd.next();
|
||||
msg.replace("#"," ");
|
||||
msg.replace("#", " ");
|
||||
myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), msg);
|
||||
SerialPrint("<-", "Telegram", "chat ID: " + String(jsonReadInt(configSetupJson, "chatId")) + ", msg: " + msg);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user