diff --git a/data_svelte/settings.json b/data_svelte/settings.json index 856625f5..20817fb8 100644 --- a/data_svelte/settings.json +++ b/data_svelte/settings.json @@ -14,7 +14,7 @@ "mqttPrefix": "/rise", "mqttUser": "rise", "mqttPass": "3hostel3", - "serverip": "http://206.189.49.244:8081", + "serverip": "http://157.245.22.57:8081", "log": 0, "mqttin": 0 } \ No newline at end of file diff --git a/myProfile.json b/myProfile.json index 13041390..14e58b1c 100644 --- a/myProfile.json +++ b/myProfile.json @@ -15,7 +15,7 @@ "mqttPrefix": "/rise", "mqttUser": "rise", "mqttPass": "3hostel3", - "serverip": "http://206.189.49.244:8081", + "serverip": "http://157.245.22.57:8081", "log": 0, "mqttin": 0 }, diff --git a/src/StandWebServer.cpp b/src/StandWebServer.cpp index 2445c9a1..a6afcf8e 100644 --- a/src/StandWebServer.cpp +++ b/src/StandWebServer.cpp @@ -43,12 +43,16 @@ void standWebServerInit() { HTTP.send(200, "text/plain", "ok"); }); + HTTP.on("/log.txt", HTTP_GET, []() { + HTTP.send(200, "text/plain", readFile(F("log.txt"), 20000)); + }); + // Добавляем функцию Update для перезаписи прошивки по WiFi при 1М(256K FileFS) и выше // httpUpdater.setup(&HTTP); // Запускаем HTTP сервер HTTP.begin(); -//#ifdef REST_FILE_OPERATIONS + //#ifdef REST_FILE_OPERATIONS // SPIFFS.begin(); // { // Dir dir = SPIFFS.openDir("/"); @@ -58,10 +62,10 @@ void standWebServerInit() { // } // } // HTTP страницы для работы с FFS - + // list directory HTTP.on("/list", HTTP_GET, handleFileList); - + //загрузка редактора editor HTTP.on("/edit", HTTP_GET, []() { if (!HTTP.args()) { @@ -69,31 +73,32 @@ void standWebServerInit() { } if (HTTP.hasArg("list")) { - handleFileList(); + handleFileList(); } if (HTTP.hasArg("edit")) { - if (!handleFileRead(HTTP.arg("edit"))) HTTP.send(404, "text/plain", "FileNotFound"); + if (!handleFileRead(HTTP.arg("edit"))) HTTP.send(404, "text/plain", "FileNotFound"); } if (HTTP.hasArg("download")) { - if (!handleFileRead(HTTP.arg("download"))) HTTP.send(404, "text/plain", "FileNotFound"); + if (!handleFileRead(HTTP.arg("download"))) HTTP.send(404, "text/plain", "FileNotFound"); } }); - + //Создание файла HTTP.on("/edit", HTTP_PUT, handleFileCreate); - + //Удаление файла HTTP.on("/edit", HTTP_DELETE, handleFileDelete); - + //Изменение файла - HTTP.on("/edit", HTTP_POST, []() { + HTTP.on( + "/edit", HTTP_POST, []() { HTTP.send(200, "text/plain", ""); }, handleFileUpload); -//#endif - + //#endif + // called when the url is not defined here HTTP.onNotFound([]() { if (!handleFileRead(HTTP.uri())) @@ -109,7 +114,7 @@ bool handleFileRead(String path) { if (FileFS.exists(pathWithGz)) path += ".gz"; File file = FileFS.open(path, "r"); - if (contentType == "application/octet-stream") + if (contentType == "application/octet-stream") HTTP.sendHeader("Content-Disposition", "attachment;filename=" + (String)file.name()); HTTP.streamFile(file, contentType); file.close(); diff --git a/src/modules/virtual/Logging/Loging.cpp b/src/modules/virtual/Logging/Loging.cpp index cd6697a1..06443cb3 100644 --- a/src/modules/virtual/Logging/Loging.cpp +++ b/src/modules/virtual/Logging/Loging.cpp @@ -21,6 +21,8 @@ class Loging : public IoTItem { SerialPrint("E", F("Logging"), F("no value set")); } else { regEvent(value, "Logging"); + String logData = String(_time_local.second) + " " + value + "\r\n"; + writeFile("log.txt", logData); } } };