mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 14:12:16 +03:00
запись лога в файл
This commit is contained in:
@@ -14,7 +14,7 @@
|
|||||||
"mqttPrefix": "/rise",
|
"mqttPrefix": "/rise",
|
||||||
"mqttUser": "rise",
|
"mqttUser": "rise",
|
||||||
"mqttPass": "3hostel3",
|
"mqttPass": "3hostel3",
|
||||||
"serverip": "http://206.189.49.244:8081",
|
"serverip": "http://157.245.22.57:8081",
|
||||||
"log": 0,
|
"log": 0,
|
||||||
"mqttin": 0
|
"mqttin": 0
|
||||||
}
|
}
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
"mqttPrefix": "/rise",
|
"mqttPrefix": "/rise",
|
||||||
"mqttUser": "rise",
|
"mqttUser": "rise",
|
||||||
"mqttPass": "3hostel3",
|
"mqttPass": "3hostel3",
|
||||||
"serverip": "http://206.189.49.244:8081",
|
"serverip": "http://157.245.22.57:8081",
|
||||||
"log": 0,
|
"log": 0,
|
||||||
"mqttin": 0
|
"mqttin": 0
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -43,12 +43,16 @@ void standWebServerInit() {
|
|||||||
HTTP.send(200, "text/plain", "ok");
|
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) и выше
|
// Добавляем функцию Update для перезаписи прошивки по WiFi при 1М(256K FileFS) и выше
|
||||||
// httpUpdater.setup(&HTTP);
|
// httpUpdater.setup(&HTTP);
|
||||||
// Запускаем HTTP сервер
|
// Запускаем HTTP сервер
|
||||||
HTTP.begin();
|
HTTP.begin();
|
||||||
|
|
||||||
//#ifdef REST_FILE_OPERATIONS
|
//#ifdef REST_FILE_OPERATIONS
|
||||||
// SPIFFS.begin();
|
// SPIFFS.begin();
|
||||||
// {
|
// {
|
||||||
// Dir dir = SPIFFS.openDir("/");
|
// Dir dir = SPIFFS.openDir("/");
|
||||||
@@ -58,10 +62,10 @@ void standWebServerInit() {
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// HTTP страницы для работы с FFS
|
// HTTP страницы для работы с FFS
|
||||||
|
|
||||||
// list directory
|
// list directory
|
||||||
HTTP.on("/list", HTTP_GET, handleFileList);
|
HTTP.on("/list", HTTP_GET, handleFileList);
|
||||||
|
|
||||||
//загрузка редактора editor
|
//загрузка редактора editor
|
||||||
HTTP.on("/edit", HTTP_GET, []() {
|
HTTP.on("/edit", HTTP_GET, []() {
|
||||||
if (!HTTP.args()) {
|
if (!HTTP.args()) {
|
||||||
@@ -69,31 +73,32 @@ void standWebServerInit() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (HTTP.hasArg("list")) {
|
if (HTTP.hasArg("list")) {
|
||||||
handleFileList();
|
handleFileList();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HTTP.hasArg("edit")) {
|
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 (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_PUT, handleFileCreate);
|
||||||
|
|
||||||
//Удаление файла
|
//Удаление файла
|
||||||
HTTP.on("/edit", HTTP_DELETE, handleFileDelete);
|
HTTP.on("/edit", HTTP_DELETE, handleFileDelete);
|
||||||
|
|
||||||
//Изменение файла
|
//Изменение файла
|
||||||
HTTP.on("/edit", HTTP_POST, []() {
|
HTTP.on(
|
||||||
|
"/edit", HTTP_POST, []() {
|
||||||
HTTP.send(200, "text/plain", "");
|
HTTP.send(200, "text/plain", "");
|
||||||
},
|
},
|
||||||
handleFileUpload);
|
handleFileUpload);
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
// called when the url is not defined here
|
// called when the url is not defined here
|
||||||
HTTP.onNotFound([]() {
|
HTTP.onNotFound([]() {
|
||||||
if (!handleFileRead(HTTP.uri()))
|
if (!handleFileRead(HTTP.uri()))
|
||||||
@@ -109,7 +114,7 @@ bool handleFileRead(String path) {
|
|||||||
if (FileFS.exists(pathWithGz))
|
if (FileFS.exists(pathWithGz))
|
||||||
path += ".gz";
|
path += ".gz";
|
||||||
File file = FileFS.open(path, "r");
|
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.sendHeader("Content-Disposition", "attachment;filename=" + (String)file.name());
|
||||||
HTTP.streamFile(file, contentType);
|
HTTP.streamFile(file, contentType);
|
||||||
file.close();
|
file.close();
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ class Loging : public IoTItem {
|
|||||||
SerialPrint("E", F("Logging"), F("no value set"));
|
SerialPrint("E", F("Logging"), F("no value set"));
|
||||||
} else {
|
} else {
|
||||||
regEvent(value, "Logging");
|
regEvent(value, "Logging");
|
||||||
|
String logData = String(_time_local.second) + " " + value + "\r\n";
|
||||||
|
writeFile("log.txt", logData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user