mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 22:22:16 +03:00
fixed scenario bug
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
#include "Class/ScenarioClass.h"
|
||||
#include "Class/ScenarioClass2.h"
|
||||
Scenario* myScenario;
|
||||
|
||||
void eventGen(String event_name, String number) {
|
||||
if (!jsonReadBool(configSetupJson, "scen")) {
|
||||
return;
|
||||
}
|
||||
SerialPrint("", "", event_name);
|
||||
eventBuf += event_name + number + ",";
|
||||
}
|
||||
@@ -43,28 +43,70 @@ void handleTelegram() {
|
||||
}
|
||||
|
||||
void telegramMsgParse(String msg) {
|
||||
SerialPrint("<-", "Telegram", "chat ID: " + String(jsonReadInt(configSetupJson, "chatId")) + ", msg: " + String(msg));
|
||||
if (msg.indexOf("order") != -1) {
|
||||
msg = deleteBeforeDelimiter(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, " ");
|
||||
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 'get id' to get value, or 'order id value' to send order");
|
||||
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("#", " ");
|
||||
myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), msg);
|
||||
SerialPrint("<-", "Telegram", "chat ID: " + String(jsonReadInt(configSetupJson, "chatId")) + ", msg: " + msg);
|
||||
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;
|
||||
}
|
||||
@@ -68,7 +68,7 @@ String addNewDevice() {
|
||||
//==============================================
|
||||
jsonWriteStr(json, "uniqueId", mac);
|
||||
jsonWriteStr(json, "name", FIRMWARE_NAME);
|
||||
jsonWriteInt(json, "model", FIRMWARE_VERSION);
|
||||
jsonWriteStr(json, "model", getChipId());
|
||||
//==============================================
|
||||
http.begin(client, serverIP + F(":8082/api/devices/"));
|
||||
http.setAuthorization("admin", "admin");
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "Bus.h"
|
||||
#include "Class/CallBackTest.h"
|
||||
#include "Class/NotAsync.h"
|
||||
#include "Class/ScenarioClass.h"
|
||||
#include "Class/ScenarioClass2.h"
|
||||
#include "Cmd.h"
|
||||
#include "Global.h"
|
||||
#include "Init.h"
|
||||
|
||||
Reference in New Issue
Block a user