mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 22:22:16 +03:00
Merge pull request #383 from Mit4el/ver4dev
update telegram_v2 and Nextion upload
This commit is contained in:
@@ -428,7 +428,7 @@ bool ESPNexUpload::upload(Stream &myFile)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// create buffer for read
|
// create buffer for read
|
||||||
uint8_t buff[2048] = {0};
|
uint8_t buff[4096] = {0};
|
||||||
|
|
||||||
// read all data from server
|
// read all data from server
|
||||||
while (_undownloadByte > 0 || _undownloadByte == -1)
|
while (_undownloadByte > 0 || _undownloadByte == -1)
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ bool _autos;
|
|||||||
bool _initSD;
|
bool _initSD;
|
||||||
bool _resolveOTA;
|
bool _resolveOTA;
|
||||||
bool fl_rollback;
|
bool fl_rollback;
|
||||||
|
bool fl_reboot;
|
||||||
int8_t _OTAstate = -1;
|
int8_t _OTAstate = -1;
|
||||||
struct ButtonMenu
|
struct ButtonMenu
|
||||||
{
|
{
|
||||||
@@ -69,6 +70,7 @@ public:
|
|||||||
jsonRead(parameters, "chatID", _chatID);
|
jsonRead(parameters, "chatID", _chatID);
|
||||||
_textMode = jsonReadInt(parameters, "textMode");
|
_textMode = jsonReadInt(parameters, "textMode");
|
||||||
fl_rollback = false;
|
fl_rollback = false;
|
||||||
|
fl_reboot = false;
|
||||||
instanceBot();
|
instanceBot();
|
||||||
_myBot->setTextMode(_textMode);
|
_myBot->setTextMode(_textMode);
|
||||||
_myBot->attach(telegramMsgParse);
|
_myBot->attach(telegramMsgParse);
|
||||||
@@ -119,6 +121,11 @@ public:
|
|||||||
ESP.restart();
|
ESP.restart();
|
||||||
_OTAstate = -1;
|
_OTAstate = -1;
|
||||||
}
|
}
|
||||||
|
if (fl_reboot)
|
||||||
|
{
|
||||||
|
_myBot->tickManual();
|
||||||
|
ESP.restart();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Далее вызов doByInterval для обработки комманд
|
// Далее вызов doByInterval для обработки комманд
|
||||||
IoTItem::loop();
|
IoTItem::loop();
|
||||||
@@ -445,11 +452,12 @@ public:
|
|||||||
{
|
{
|
||||||
downloadFile(msg);
|
downloadFile(msg);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (msg.text.indexOf("Next_firmware") != -1)
|
else if (msg.text.indexOf("Next_firmware") != -1)
|
||||||
{
|
{
|
||||||
// удаляем последнее сообщение от бота
|
// удаляем последнее сообщение от бота
|
||||||
_myBot->deleteMessage(_myBot->lastBotMsg());
|
_myBot->deleteMessage(_myBot->lastBotMsg());
|
||||||
if (msg.data.indexOf("Firmware") != -1)
|
if (msg.data.indexOf("Firmware") != -1 && OTAfilepath != "")
|
||||||
{
|
{
|
||||||
for (std::list<IoTItem *>::iterator it = IoTItems.begin(); it != IoTItems.end(); ++it)
|
for (std::list<IoTItem *>::iterator it = IoTItems.begin(); it != IoTItems.end(); ++it)
|
||||||
{
|
{
|
||||||
@@ -462,7 +470,6 @@ public:
|
|||||||
OTAfilepath = "";
|
OTAfilepath = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// -------------- Обработка кнопок меню созданного в сценарии --------------
|
// -------------- Обработка кнопок меню созданного в сценарии --------------
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
else if (auto search = mapBtnMenu.find(msg.text); search != mapBtnMenu.end())
|
else if (auto search = mapBtnMenu.find(msg.text); search != mapBtnMenu.end())
|
||||||
@@ -668,7 +675,20 @@ public:
|
|||||||
{
|
{
|
||||||
_myBot->sendMessage("ID: " + chipId, _chatID);
|
_myBot->sendMessage("ID: " + chipId, _chatID);
|
||||||
_myBot->sendMessage("chatID: " + _chatID, _chatID);
|
_myBot->sendMessage("chatID: " + _chatID, _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);
|
_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 /reboot - reboot esp \n\n send file and write download - \"download\" file to esp \n\n send *.tft file - flash Nextion \n\n send firmware.bin or littltfs.bin - firmware ESP ", _chatID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (msg.text.indexOf("/reboot") != -1)
|
||||||
|
{
|
||||||
|
_myBot->inlineMenu("Перезагрузить esp " + jsonReadStr(settingsFlashJson, F("name")) + "\n esp_reboot", F("Reboot \t Cancel"));
|
||||||
|
}
|
||||||
|
else if (msg.text.indexOf("esp_reboot") != -1)
|
||||||
|
{
|
||||||
|
// удаляем последнее сообщение от бота
|
||||||
|
_myBot->deleteMessage(_myBot->lastBotMsg());
|
||||||
|
if (msg.data.indexOf("Reboot") != -1)
|
||||||
|
{
|
||||||
|
fl_reboot = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (msg.text.indexOf("/") != -1)
|
else if (msg.text.indexOf("/") != -1)
|
||||||
|
|||||||
Reference in New Issue
Block a user