mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-27 06:32:19 +03:00
telegram
This commit is contained in:
@@ -10,7 +10,7 @@ bool getInfo(FSInfo& info) {
|
||||
void getFSInfo() {
|
||||
FSInfo buf;
|
||||
if (getInfo(buf)) {
|
||||
SerialPrint("I", F("FS"), F("Get FS info completed"));
|
||||
//SerialPrint("I", F("FS"), F("Get FS info completed"));
|
||||
|
||||
size_t totalBytes = buf.totalBytes; // всего
|
||||
size_t usedBytes = buf.usedBytes; // использовано
|
||||
|
||||
@@ -35,8 +35,10 @@ void handleTelegram() {
|
||||
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();
|
||||
if (jsonReadBool(configSetupJson, "autos")) {
|
||||
jsonWriteInt(configSetupJson, "chatId", msg.sender.id);
|
||||
saveConfig();
|
||||
}
|
||||
telegramMsgParse(String(msg.text));
|
||||
}
|
||||
}
|
||||
@@ -61,6 +63,7 @@ void telegramMsgParse(String msg) {
|
||||
myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), list);
|
||||
SerialPrint("<-", "Telegram", "chat ID: " + String(jsonReadInt(configSetupJson, "chatId")) + "\n" + list);
|
||||
} else {
|
||||
myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), "ID: " + chipId + ", Name: " + jsonReadStr(configSetupJson, F("name")));
|
||||
myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), F("Wrong order, use /all to get all values, /get_id to get value, or /set_id_value to set value"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -255,6 +255,12 @@ void web_init() {
|
||||
saveConfig();
|
||||
request->send(200);
|
||||
}
|
||||
if (request->hasArg("autos")) {
|
||||
bool value = request->getParam("autos")->value().toInt();
|
||||
jsonWriteBool(configSetupJson, "autos", value);
|
||||
saveConfig();
|
||||
request->send(200);
|
||||
}
|
||||
if (request->hasArg("chatId")) {
|
||||
jsonWriteStr(configSetupJson, "chatId", request->getParam("chatId")->value());
|
||||
saveConfig();
|
||||
|
||||
@@ -62,15 +62,15 @@ void LoggingClass::execute(String keyOrValue) {
|
||||
}
|
||||
|
||||
if (loggingValue != "") {
|
||||
if (cnt >= _maxPoints) { //удаляем старую строку и добавляем новую
|
||||
if (cnt >= _maxPoints) { //удаляем старую строку и добавляем новую
|
||||
String logData = readFile(filename, 20480); //10240
|
||||
SerialPrint("I", "Logging", "Free heap " + String(ESP.getFreeHeap()));
|
||||
if (logData == "large") {
|
||||
SerialPrint("E", "Logging", "File is very large");
|
||||
}
|
||||
//for (int i = 0; i < 5; i++) {
|
||||
|
||||
logData = deleteBeforeDelimiter(logData, "\r\n");
|
||||
//}
|
||||
|
||||
if (timeNow->hasTimeSynced()) {
|
||||
logData += timeNow->getTimeUnix() + " " + loggingValue + "\r\n";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user