mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-27 14:42:18 +03:00
telegram bot added (working version)
This commit is contained in:
37
src/Web.cpp
37
src/Web.cpp
@@ -193,14 +193,13 @@ void web_init() {
|
||||
request->send(200, "text/html", payload);
|
||||
}
|
||||
|
||||
// //==============================push settings=============================================
|
||||
//#ifdef PUSH_ENABLED
|
||||
// if (request->hasArg("pushingboxid")) {
|
||||
// jsonWriteStr(configSetupJson, "pushingboxid", request->getParam("pushingboxid")->value());
|
||||
// saveConfig();
|
||||
// request->send(200);
|
||||
// }
|
||||
//#endif
|
||||
//==============================push settings=============================================
|
||||
if (request->hasArg("telegramApi")) {
|
||||
jsonWriteStr(configSetupJson, "telegramApi", request->getParam("telegramApi")->value());
|
||||
|
||||
saveConfig();
|
||||
request->send(200);
|
||||
}
|
||||
|
||||
//==============================utilities settings=============================================
|
||||
if (request->hasArg("i2c")) {
|
||||
@@ -215,7 +214,7 @@ void web_init() {
|
||||
serverIP = jsonReadStr(configSetupJson, "serverip");
|
||||
request->send(200);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
//==============================list of items=====================================================
|
||||
//server.on("/del", HTTP_GET, [](AsyncWebServerRequest* request) {
|
||||
@@ -230,7 +229,7 @@ void web_init() {
|
||||
// request->redirect("/?setn.device");
|
||||
//});
|
||||
|
||||
/*
|
||||
/*
|
||||
* Check
|
||||
*/
|
||||
server.on("/check", HTTP_GET, [](AsyncWebServerRequest* request) {
|
||||
@@ -240,13 +239,17 @@ void web_init() {
|
||||
String msg = "";
|
||||
if (lastVersion == FIRMWARE_VERSION) {
|
||||
msg = F("Актуальная версия прошивки уже установлена.");
|
||||
} else if (lastVersion > FIRMWARE_VERSION) {
|
||||
}
|
||||
else if (lastVersion > FIRMWARE_VERSION) {
|
||||
msg = F("Новая версия прошивки<a href=\"#\" class=\"btn btn-block btn-danger\" onclick=\"send_request(this, '/upgrade');setTimeout(function(){ location.href='/?set.device'; }, 90000);html('my-block','<span class=loader></span>Идет обновление прошивки, после обновления страница перезагрузится автоматически...')\">Установить</a>");
|
||||
} else if (lastVersion == -1) {
|
||||
}
|
||||
else if (lastVersion == -1) {
|
||||
msg = F("Cервер не найден. Попробуйте повторить позже...");
|
||||
} else if (lastVersion == -2) {
|
||||
}
|
||||
else if (lastVersion == -2) {
|
||||
msg = F("Устройство не подключено к роутеру!");
|
||||
} else if (lastVersion < FIRMWARE_VERSION) {
|
||||
}
|
||||
else if (lastVersion < FIRMWARE_VERSION) {
|
||||
msg = F("Ошибка версии. Попробуйте повторить позже...");
|
||||
}
|
||||
|
||||
@@ -262,15 +265,15 @@ void web_init() {
|
||||
jsonWriteStr(tmp, "title", "<button class=\"close\" onclick=\"toggle('my-block')\">×</button>" + msg);
|
||||
jsonWriteStr(tmp, "class", "pop-up");
|
||||
request->send(200, "text/html", tmp);
|
||||
});
|
||||
});
|
||||
|
||||
/*
|
||||
/*
|
||||
* Upgrade
|
||||
*/
|
||||
server.on("/upgrade", HTTP_GET, [](AsyncWebServerRequest* request) {
|
||||
myNotAsyncActions->make(do_UPGRADE);
|
||||
request->send(200, "text/html");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
void setConfigParam(const char* param, const String& value) {
|
||||
|
||||
Reference in New Issue
Block a user