diff --git a/src/MqttClient.cpp b/src/MqttClient.cpp index c6edb6e7..727473ad 100644 --- a/src/MqttClient.cpp +++ b/src/MqttClient.cpp @@ -104,6 +104,8 @@ void getMqttData() { mqttPort = jsonReadInt(settingsFlashJson, F("mqttPort")); mqttUser = jsonReadStr(settingsFlashJson, F("mqttUser")); mqttPass = jsonReadStr(settingsFlashJson, F("mqttPass")); + mqttPrefix = jsonReadStr(settingsFlashJson, F("mqttPrefix")); + mqttRootDevice = mqttPrefix + "/" + chipId; } void mqttSubscribe() { diff --git a/src/modules/exec/ButtonOut/ButtonOut.cpp b/src/modules/exec/ButtonOut/ButtonOut.cpp index 65b8e42f..ab4a6116 100644 --- a/src/modules/exec/ButtonOut/ButtonOut.cpp +++ b/src/modules/exec/ButtonOut/ButtonOut.cpp @@ -53,8 +53,8 @@ class ButtonOut : public IoTItem { void setValue(const IoTValue& Value, bool genEvent = true) { value = Value; - if ((value.valD == !_inv?1:0) && (_interval != 0)) { - value.valD = !_inv?1:0; + if ((value.valD == 1) && (_interval != 0)) { + // value.valD = !_inv?1:0; enableDoByInt = true; // SerialPrint("I", "ButtonOut","single pulse start"); suspendNextDoByInt(_interval); diff --git a/src/modules/exec/Telegram_v2/Telegram_v2.cpp b/src/modules/exec/Telegram_v2/Telegram_v2.cpp index ecaaaa4e..b7b5e170 100644 --- a/src/modules/exec/Telegram_v2/Telegram_v2.cpp +++ b/src/modules/exec/Telegram_v2/Telegram_v2.cpp @@ -9,7 +9,7 @@ // #include "esp_camera.h" #include -#include +#include // FastBot _myBot; FastBot *_myBot = nullptr; @@ -28,6 +28,17 @@ String _chatID; bool _autos; bool _initSD; +struct ButtonMenu +{ + String message = ""; + String getId = ""; + String setId = ""; + String value = ""; +}; + +std::map mapBtnMenu; // +std::map mapBtnInline; // + class Telegram_v2 : public IoTItem { private: @@ -43,6 +54,7 @@ public: jsonRead(parameters, "receiveMsg", _receiveMsg); jsonRead(parameters, "chatID", _chatID); instanceBot(); + // _myBot->setTextMode(FB_MARKDOWN); _myBot->attach(telegramMsgParse); #ifdef ESP32 @@ -69,9 +81,13 @@ public: { } + //============================================================================= + //=============++====== Обработка команд сценария ============================= + //============================================================================= IoTValue execute(String command, std::vector ¶m) { - if (!isNetworkActive()) return {}; + if (!isNetworkActive()) + return {}; if (command == "sendMsg") { if (param.size()) @@ -108,9 +124,14 @@ public: _myBot->sendMessage(strTmp, _chatID); _myBot->pinMessage(_myBot->lastBotMsg()); - SerialPrint("<-", F("Telegram"), "chat ID: " + _chatID + ",pin msg: " + strTmp); + SerialPrint("i", F("Telegram"), "chat ID: " + _chatID + ", pin msg: " + strTmp); } } + else if (command == "unpinAllMsg") + { + _myBot->unpinAll(_chatID); + SerialPrint("i", F("Telegram"), "chat ID: " + _chatID + ", unpin all message"); + } else if (command == "editMsg") { if (param.size()) @@ -121,7 +142,7 @@ public: else strTmp = param[0].valS; _myBot->editMessage(_myBot->lastBotMsg(), strTmp); - SerialPrint("<-", F("Telegram"), "chat ID: " + _chatID + ",edit msg: " + strTmp); + SerialPrint("i", F("Telegram"), "chat ID: " + _chatID + ", edit msg: " + strTmp); } } else if (command == "sendFile") @@ -139,10 +160,9 @@ public: // selectToMarkerLast(msg.text, "_") uint8_t res = _myBot->sendFile(file, (FB_FileType)param[1].valD, selectToMarkerLast(param[0].valS, "/"), _chatID); file.close(); - SerialPrint("<-", F("Telegram"), "chat ID: " + _chatID + ", sendFile: " + param[0].valS + " res: " + String(res)); + SerialPrint("i", F("Telegram"), "chat ID: " + _chatID + ", sendFile: " + param[0].valS + " res: " + String(res)); } } - else if (command == "editFile") { if (param.size() && !param[0].isDecimal) @@ -158,28 +178,297 @@ public: // selectToMarkerLast(msg.text, "_") uint8_t res = _myBot->editFile(file, (FB_FileType)param[1].valD, selectToMarkerLast(param[0].valS, "/"), _myBot->lastBotMsg(), _chatID); file.close(); - SerialPrint("<-", F("Telegram"), "chat ID: " + _chatID + ", editFile: " + param[0].valS + " res: " + String(res)); + SerialPrint("i", F("Telegram"), "chat ID: " + _chatID + ", editFile: " + param[0].valS + " res: " + String(res)); } } + else if (command == "btnMenu") + { + mapBtnMenu[param[0].valS] = new ButtonMenu; + if (param.size() == 3) // btnMenu("Name", message, getId); + { + // if (IoTItems.find(param[2].valS) != IoTItems.end()) + // { + mapBtnMenu[param[0].valS]->message = param[1].valS; + mapBtnMenu[param[0].valS]->getId = param[2].valS; + // mapBtnMenu[param[0].valS] = btn; + SerialPrint("i", F("Telegram"), "add button menu: " + param[0].valS + ", get id: " + param[2].valS); + // } + } + else if (param.size() == 5) // btnMenu("Name", message, getId, setId, value); + { + // if (IoTItems.find(param[2].valS) != IoTItems.end()) + // { + mapBtnMenu[param[0].valS]->message = param[1].valS; + mapBtnMenu[param[0].valS]->getId = param[2].valS; + mapBtnMenu[param[0].valS]->setId = param[3].valS; + mapBtnMenu[param[0].valS]->value = param[4].valS; + // mapBtnMenu[param[0].valS] = btn; + SerialPrint("i", F("Telegram"), "add button menu: " + param[0].valS + ",get id: " + param[2].valS + ",set id: " + param[3].valS + "=" + param[4].valS); + // } + } + } + else if (command == "showMenu") + { + String out; + // перебирвем весь мап и строим меню + uint8_t cnt = 0; + for (auto it = mapBtnMenu.begin(); it != mapBtnMenu.end(); it++) + { + cnt++; + if (cnt % 2 == 0) + { + out += " \t " + it->first; + } + else + { + if (it == mapBtnMenu.begin()) + out = it->first; + else + out += " \n " + it->first; + } + } + _myBot->showMenuText("Menu", out, true); + SerialPrint("i", F("Telegram"), "chat ID: " + _chatID + ", show menu: \n" + out); + } + else if (command == "btnInline") + { + mapBtnInline[param[0].valS] = new ButtonMenu; + if (param.size() == 3) // btnMenu("Name", message, getId); + { + // if (IoTItems.find(param[2].valS) != IoTItems.end()) + // { + mapBtnInline[param[0].valS]->message = param[1].valS; + mapBtnInline[param[0].valS]->getId = param[2].valS; + // mapBtnMenu[param[0].valS] = btn; + SerialPrint("i", "Telegram", "add button inline: " + param[0].valS + ", get id: " + param[2].valS); + // } + } + else if (param.size() == 5) // btnMenu("Name", message, getId, setId, value); + { + // if (IoTItems.find(param[2].valS) != IoTItems.end()) + // { + mapBtnInline[param[0].valS]->message = param[1].valS; + mapBtnInline[param[0].valS]->getId = param[2].valS; + mapBtnInline[param[0].valS]->setId = param[3].valS; + mapBtnInline[param[0].valS]->value = param[4].valS; + // mapBtnMenu[param[0].valS] = btn; + SerialPrint("i", "Telegram", "add button inline: " + param[0].valS + ",get id: " + param[2].valS + ",set id: " + param[3].valS + "=" + param[4].valS); + // } + } + } + else if (command == "showInline") + { + String out; + // перебирвем весь мап и строим меню + uint8_t cnt = 0; + for (auto it = mapBtnInline.begin(); it != mapBtnInline.end(); it++) + { + cnt++; + if (cnt % 2 == 0) + { + out += " \t " + it->first; + } + else + { + if (it == mapBtnInline.begin()) + out = it->first; + else + out += " \n " + it->first; + } + } + _myBot->inlineMenu("inline_menu", out); + SerialPrint("i", F("Telegram"), "chat ID: " + _chatID + ", show inline: \n" + out); + } + else if (command == "clearInline") + { + clearMapMenuInline(); + SerialPrint("i", F("Telegram"), "chat ID: " + _chatID + ", clear inline menu "); + } + else if (command == "clearMenu") + { + clearMapMenu(); + SerialPrint("i", F("Telegram"), "chat ID: " + _chatID + ", clear menu "); + } + else if (command == "closeMenu") + { + _myBot->closeMenu(); + SerialPrint("i", F("Telegram"), "chat ID: " + _chatID + ", closeMenu "); + } return {}; } + //============================================================================= + //=================== Обработка сообщений из чата ============================= + //============================================================================= void static telegramMsgParse(FB_msg &msg) { // FB_msg msg; - SerialPrint("->", F("Telegram"), "chat ID: " + msg.chatID + ", msg: " + msg.text); + SerialPrint("i", F("Telegram"), "chat ID: " + msg.chatID + ", msg: " + msg.text); // _myBot->setChatID(_chatID); if (_autos) { _chatID = msg.chatID; } - if (msg.text.indexOf("set") != -1) + // -------------- Обработка кнопок меню созданного в сценарии -------------- + // ------------------------------------------------------------------------- + if (auto search = mapBtnMenu.find(msg.text); search != mapBtnMenu.end()) + { + String outMsg; + outMsg = mapBtnMenu[msg.text]->message; + if (mapBtnMenu[msg.text]->getId != "") + { + IoTItem *item = findIoTItem(mapBtnMenu[msg.text]->getId); + if (item) + { + outMsg += ": " + item->getValue(); + } + } + if (mapBtnMenu[msg.text]->setId != "") + { + //outMsg += ", " + mapBtnMenu[msg.text]->setId + "=" + mapBtnMenu[msg.text]->value; + generateOrder(mapBtnMenu[msg.text]->setId, mapBtnMenu[msg.text]->value); + } + SerialPrint("i", F("Telegram"), "chat ID: " + _chatID + ", msg: " + String(outMsg)); + _myBot->sendMessage(outMsg, _chatID); + } + + // -------------- Обработка нажатия на пользовательском инлайн меню -------------- + // ------------------------------------------------------------------------- + else if (msg.text.indexOf("inline_menu") != -1) + { + SerialPrint("i", F("Telegram"), "chat ID: " + _chatID + ", data: " + String(msg.data)); + if (auto search = mapBtnInline.find(msg.data); search != mapBtnInline.end()) + { + + String outMsg; + outMsg = mapBtnInline[msg.data]->message; + if (mapBtnInline[msg.data]->getId != "") + { + IoTItem *item = findIoTItem(mapBtnInline[msg.data]->getId); + if (item) + { + outMsg += ": " + item->getValue(); + //SerialPrint("i", F("Telegram"), "chat ID: " + _chatID + ", msg: " + String(msg.data)); + } + } + if (mapBtnInline[msg.data]->setId != "") + { + //outMsg += ", " + mapBtnInline[msg.data]->setId + "=" + mapBtnInline[msg.data]->value; + generateOrder(mapBtnInline[msg.data]->setId, mapBtnInline[msg.data]->value); + } + SerialPrint("i", F("Telegram"), "chat ID: " + _chatID + ", msg: " + String(outMsg)); + _myBot->sendMessage(outMsg, _chatID); + } + } + // -------------- Вызов (повторный вызов) меню созданного в сценарии -------------- + // ------------------------------------------------------------------------- + else if (msg.text.indexOf("menu") != -1) + { + String out; + // перебирвем весь мап и строим меню + uint8_t cnt = 0; + for (auto it = mapBtnMenu.begin(); it != mapBtnMenu.end(); it++) + { + cnt++; + if (cnt % 2 == 0) + { + out += " \t " + it->first; + } + else + { + if (it == mapBtnMenu.begin()) + out = it->first; + else + out += " \n " + it->first; + } + } + _myBot->showMenuText("Menu", out, true); + SerialPrint("i", F("Telegram"), "chat ID: " + _chatID + ", show menu: \n" + out); + } + // -------------- вывод нижнего меню всех юнитов -------------- + // ------------------------------------------------------------------------- + else if (msg.text.indexOf("allMenu") != -1) + { + // String list = returnListOfParams(); + String out; + // std::vector vctr; + uint8_t cnt = 0; + for (std::list::iterator it = IoTItems.begin(); it != IoTItems.end(); ++it) + { + if ((*it)->iAmLocal) + { + cnt++; + if (cnt % 2 == 0) + { + out += " \t get_" + (*it)->getID(); + } + else + { + if (it == IoTItems.begin()) + out = "get_" + (*it)->getID(); + else + out += " \n get_" + (*it)->getID(); + } + } + } + _myBot->showMenuText("select Id", out, true); + SerialPrint("i", F("Telegram"), "chat ID: " + _chatID + "\n" + out); + // _myBot->sendMessage(CharPlot(&vctr[0], vctr.size(), 5), _chatID); + // SerialPrint("<-", F("Telegram"), CharPlot(&vctr[0], vctr.size(), 10)); + } + + // -------------- Обработка нажатия в инлайн меню all (всех юнитов) -------------- + // ------------------------------------------------------------------------- + else if (msg.text.indexOf("all_inline") != -1 && msg.data.indexOf("get") != -1) + { + String out = deleteBeforeDelimiter(msg.data, "_"); + IoTItem *item = findIoTItem(out); + if (item) + { + _myBot->sendMessage(item->getID() + ": " + item->getValue(), _chatID); + SerialPrint("i", F("Telegram"), "chat ID: " + _chatID + ", msg: " + out); + } + } + // -------------- вывод инлайн меню всех юнитов -------------- + // ------------------------------------------------------------------------- + else if (msg.text.indexOf("all") != -1) + { + // String list = returnListOfParams(); + String out; + // std::vector vctr; + uint8_t cnt = 0; + for (std::list::iterator it = IoTItems.begin(); it != IoTItems.end(); ++it) + { + if ((*it)->iAmLocal) + { + cnt++; + if (cnt % 2 == 0) + { + out += " \t get_" + (*it)->getID(); + } + else + { + if (it == IoTItems.begin()) + out = "get_" + (*it)->getID(); + else + out += " \n get_" + (*it)->getID(); + } + } + } + _myBot->inlineMenu("all_inline", out); + SerialPrint("i", F("Telegram"), "chat ID: " + _chatID + "\n" + out); + } + // -------------- обработка команды /set_ID_VALUE -------------- + // ------------------------------------------------------------------------- + else if (msg.text.indexOf("set") != -1) { msg.text = deleteBeforeDelimiter(msg.text, "_"); generateOrder(selectToMarker(msg.text, "_"), selectToMarkerLast(msg.text, "_")); _myBot->replyMessage("order done", msg.messageID, _chatID); - SerialPrint("<-", F("Telegram"), "chat ID: " + _chatID + ", msg: " + String(msg.text)); + SerialPrint("i", F("Telegram"), "chat ID: " + _chatID + ", msg: " + String(msg.text)); } + // -------------- обработка команды /get_ID -------------- + // ------------------------------------------------------------------------- else if (msg.text.indexOf("get") != -1) { msg.text = deleteBeforeDelimiter(msg.text, "_"); @@ -187,41 +476,15 @@ public: if (item) { _myBot->replyMessage(item->getValue(), msg.messageID, _chatID); - SerialPrint("<-", F("Telegram"), "chat ID: " + _chatID + ", msg: " + String(msg.text)); + SerialPrint("i", F("Telegram"), "chat ID: " + _chatID + ", msg: " + String(msg.text)); } } - - else if (msg.text.indexOf("all") != -1) - { - // String list = returnListOfParams(); - String out; - std::vector vctr; - for (std::list::iterator it = IoTItems.begin(); it != IoTItems.end(); ++it) - { - if ((*it)->iAmLocal) - { - if (it == IoTItems.begin()) - { - out = "get_" + (*it)->getID(); - } - else - { - out = out + " \n " + "get_" + (*it)->getID(); - } - vctr.push_back(atoff((*it)->getValue().c_str())); - // _myBot->sendMessage((*it)->getID() + ": " + (*it)->getValue(), _chatID); - } - } - _myBot->showMenuText("select Id", out, true); - SerialPrint("<-", F("Telegram"), "chat ID: " + _chatID + "\n" + out); - // _myBot->sendMessage(CharPlot(&vctr[0], vctr.size(), 5), _chatID); - // SerialPrint("<-", F("Telegram"), CharPlot(&vctr[0], vctr.size(), 10)); - } - + // -------------- обработка запроса пользователя на скачивание файла -------------- + // ------------------------------------------------------------------------- else if (msg.text.indexOf("file") != -1 && msg.chatID == _chatID) { msg.text = deleteBeforeDelimiter(msg.text, "_"); - SerialPrint("<-", F("Telegram"), "chat ID: " + _chatID + ", get file: " + String(msg.text)); + SerialPrint("i", F("Telegram"), "chat ID: " + _chatID + ", get file: " + String(msg.text)); auto file = FileFS.open(selectToMarker(msg.text, "_"), FILE_READ); // /test.png if (!file) { @@ -232,6 +495,8 @@ public: _myBot->sendFile(file, (FB_FileType)type, selectToMarker(msg.text, "_"), _chatID); file.close(); } + // -------------- обработка файлов загруженных пользователем -------------- + // ------------------------------------------------------------------------- else if (msg.isFile) { if (msg.text.indexOf("download") != -1 && msg.chatID == _chatID) @@ -240,32 +505,41 @@ public: } else if (msg.text.indexOf("nextion") != -1 && msg.chatID == _chatID) { - for (std::list::iterator it = IoTItems.begin(); it != IoTItems.end(); ++it) { - if ((*it)->getSubtype() == "NextionUpload") { - (*it)->uploadNextionTlgrm(msg.fileUrl); + for (std::list::iterator it = IoTItems.begin(); it != IoTItems.end(); ++it) + { + if ((*it)->getSubtype() == "NextionUpload" || (*it)->getSubtype() == "Nextion") + { + (*it)->uploadNextionTlgrm(msg.fileUrl); + } } } - } } + // -------------- обработка остальных команд -------------- + // ------------------------------------------------------------------------- else if (msg.text.indexOf("help") != -1) { _myBot->sendMessage("ID: " + chipId, _chatID); _myBot->sendMessage("chatID: " + _chatID, _chatID); - _myBot->sendMessage(F("Wrong order, use /all to get all values, /get_id to get value, /set_id_value to set value, or /file_name_type or send file msg=download"), _chatID); + _myBot->sendMessage("Command: /help - this text \n /all - inline menu get all values \n /allMenu - bottom menu get all values \n /menu - bottom USER menu from scenario \n /get_id - get value by ID \n /set_id_value - set value in ID \n /file_name_type - take file from esp \n /file_type - support file type \n send file and write download - \"download\" file to esp \n send tft file and write \"nextion\" - flash file.tft to Nextion", _chatID); + } + else if (msg.text.indexOf("file_type") != -1) + { + _myBot->sendMessage("Support file type download: \n 0-foto \n 1-audio \n 2-doc \n 3-video \n 4-gif \n 5-voice", _chatID); } else { - // setValue(msg.text); + _myBot->sendMessage("Wrong order, use /help", _chatID); } } void sendTelegramMsg(bool often, String msg) { - if (!isNetworkActive()) return; + if (!isNetworkActive()) + return; if (often) { _myBot->sendMessage(msg, _chatID); - SerialPrint("<-", F("Telegram"), "chat ID: " + _chatID + ", msg: " + msg); + SerialPrint("i", F("Telegram"), "chat ID: " + _chatID + ", msg: " + msg); } else { @@ -273,23 +547,25 @@ public: { _prevMsg = msg; _myBot->sendMessage(msg, _chatID); - SerialPrint("<-", F("Telegram"), "chat ID: " + _chatID + ", msg: " + msg); + SerialPrint("i", F("Telegram"), "chat ID: " + _chatID + ", msg: " + msg); } } } void sendFoto(uint8_t *buf, uint32_t length, const String &name) { - if (!isNetworkActive()) return; + if (!isNetworkActive()) + return; _myBot->sendFile(buf, length, FB_PHOTO, name, _chatID); - SerialPrint("<-", F("Telegram"), "chat ID: " + _chatID + ", send foto from esp-cam"); + SerialPrint("i", F("Telegram"), "chat ID: " + _chatID + ", send foto from esp-cam"); } void editFoto(uint8_t *buf, uint32_t length, const String &name) { - if (!isNetworkActive()) return; + if (!isNetworkActive()) + return; _myBot->editFile(buf, length, FB_PHOTO, name, _myBot->lastBotMsg(), _chatID); - SerialPrint("<-", F("Telegram"), "chat ID: " + _chatID + ", edit foto from esp-cam"); + SerialPrint("i", F("Telegram"), "chat ID: " + _chatID + ", edit foto from esp-cam"); } int static downloadFile(FB_msg &msg) @@ -325,7 +601,7 @@ public: } else { - SerialPrint("<-", F("Telegram"), "download from: " + _chatID + ", file: " + msg.fileName + " size = " + String(_size) + " byte"); + SerialPrint("i", F("Telegram"), "download from: " + _chatID + ", file: " + msg.fileName + " size = " + String(_size) + " byte"); _myBot->sendMessage("Download Ok, size = " + String(_size) + " byte", _chatID); } } @@ -341,9 +617,31 @@ public: { return this; } - + void clearMapMenu() + { + for (auto it = mapBtnMenu.begin(); it != mapBtnMenu.end(); it++) + { + delete it->second; + } + mapBtnMenu.clear(); + for (auto it = mapBtnInline.begin(); it != mapBtnInline.end(); it++) + { + delete it->second; + } + mapBtnInline.clear(); + } + void clearMapMenuInline() + { + for (auto it = mapBtnInline.begin(); it != mapBtnInline.end(); it++) + { + delete it->second; + } + mapBtnInline.clear(); + } ~Telegram_v2() { + clearMapMenu(); + clearMapMenuInline(); tlgrmItem = nullptr; }; }; diff --git a/src/modules/exec/Telegram_v2/modinfo.json b/src/modules/exec/Telegram_v2/modinfo.json index a87f130b..c5633329 100644 --- a/src/modules/exec/Telegram_v2/modinfo.json +++ b/src/modules/exec/Telegram_v2/modinfo.json @@ -14,7 +14,7 @@ "token": "", "autos": 1, - "receiveMsg": 0, + "receiveMsg": 1, "chatID": "" }], @@ -24,7 +24,7 @@ "authorGit": "https://github.com/Mit4el", "specialThanks": "", "moduleName": "Telegram_v2", - "moduleVersion": "1.0", + "moduleVersion": "3.0", "usedRam": { "esp32_4mb": 37, "esp8266_4mb": 37 @@ -45,14 +45,19 @@ }, { "name": "sendOftenMsg", - "descr": "Отправить сообщение в любом случае, даж если отправляли такое ранее.", + "descr": "Отправить сообщение в любом случае, даже если отправляли такое ранее.", "params": ["Сообщение, может быть строкой, числом или ИД другого элемента для получения значения"] }, { "name": "sendPinMsg", - "descr": "Отправить закрепленное сообщение в любом случае, даж если отправляли такое ранее.", + "descr": "Отправить закрепленное сообщение в любом случае, даже если отправляли такое ранее.", "params": ["Сообщение, может быть строкой, числом или ИД другого элемента для получения значения"] }, + { + "name": "unpinAllMsg", + "descr": "Открепить все сообщения в чате.", + "params": [] + }, { "name": "editMsg", "descr": "Отредактировать последнее отправленное ботом сообщение.", @@ -67,7 +72,52 @@ "name": "editFile", "descr": "Отредактировать последний отправленный файл, с указанием типа файла: 0-фото, 1-аудио, 2-документ, 3-видео, 4-анимация, 5-голос", "params": ["Путь к файлу (/test.png)", "Тип файла/информации (число)"] - } + }, + { + "name": "btnMenu", + "descr": "Описание кнопки меню выводит запросит значение ID и выведит сообщение => Произвольное сообщение(message): значение. Пример: btnMenu(Темп.Дома, Текущая температура, IDbme280)", + "params": ["Name - название кнопки отображается ботом", "message - Произвольное сообщения присылается в ответ на кнопку", "Id - Вернет значение элемента"] + }, + { + "name": "btnMenu", + "descr": "Описание кнопки меню выводит запросит значение getID,установит значение value в setID и выведит сообщение => Произвольное сообщение(message): значение, IDrele=1. ВСЁ УКАЗЫВАТЬ В КАВЫЧКАХ, значение не обязательно! Пример: btnMenu(\"Обогрев\", \"Текущая температура\", \"IDbme280\", \"IDrele\", 1), btnMenu(Свет, Вклбчил свет, \"\", IDrele, 1)", + "params": ["Name - название кнопки отображается ботом", "message - Произвольное сообщения присылается в ответ на кнопку", "getId - Вернет значение элемента", "setId - Установит значение элементу", "value - Устанавливаемое значение"] + }, + { + "name": "showMenu", + "descr": "Отобразить меню, созданное в сценарии", + "params": [] + }, + { + "name": "closeMenu", + "descr": "Закрыть мменю", + "params": [] + }, + { + "name": "btnInline", + "descr": "Описание кнопки встроенного (inline) меню выводит запросит значение ID и выведит сообщение => Произвольное сообщение(message): значение. Пример: btnMenu(Темп.Дома, Текущая температура, IDbme280)", + "params": ["Name - название кнопки отображается ботом", "message - Произвольное сообщения присылается в ответ на кнопку", "Id - Вернет значение элемента"] + }, + { + "name": "btnInline", + "descr": "Описание кнопки встроенного (inline) меню выводит запросит значение getID,установит значение value в setID и выведит сообщение => Произвольное сообщение(message): значение, IDrele=1. ВСЁ УКАЗЫВАТЬ В КАВЫЧКАХ, значение не обязательно! Пример: btnMenu(\"Обогрев\", \"Текущая температура\", \"IDbme280\", \"IDrele\", 1), btnMenu(Свет, Вклбчил свет, \"\", IDrele, 1)", + "params": ["Name - название кнопки отображается ботом", "message - Произвольное сообщения присылается в ответ на кнопку", "getId - Вернет значение элемента", "setId - Установит значение элементу", "value - Устанавливаемое значение"] + }, + { + "name": "showInline", + "descr": "Отобразить встроенное (inline) меню, созданное в сценарии", + "params": [] + }, + { + "name": "clearInline", + "descr": "Очистить встроенное (inline) меню, вызвать перед для язменения, перед созданием новых кнопок", + "params": [] + }, + { + "name": "clearMenu", + "descr": "Очистить меню, вызвать перед для язменения, перед созданием новых кнопок", + "params": [] + } ] }, diff --git a/src/modules/sensors/ld2410/ld2410.cpp b/src/modules/sensors/ld2410/ld2410.cpp index c17c5751..bd0e7c30 100644 --- a/src/modules/sensors/ld2410/ld2410.cpp +++ b/src/modules/sensors/ld2410/ld2410.cpp @@ -237,7 +237,7 @@ public: } ~ld2410m() { - delete ld2410; + delete radar; radar = nullptr; }; }; @@ -297,7 +297,7 @@ public: ~ld2410t() { - delete ld2410; + delete radar; radar = nullptr; }; }; @@ -356,7 +356,7 @@ public: } ~ld2410d() { - delete ld2410; + delete radar; radar = nullptr; }; }; @@ -418,7 +418,7 @@ public: } ~ld2410e() { - delete ld2410; + delete radar; radar = nullptr; }; };