mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-27 14:42:18 +03:00
стабильное логгирование
This commit is contained in:
@@ -133,9 +133,9 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t* payload, size_t length)
|
||||
if (headerStr == "/reboot|") {
|
||||
ESP.restart();
|
||||
}
|
||||
//команда обновления esp//
|
||||
if (headerStr == "/update|") {
|
||||
upgrade_firmware(3);
|
||||
//команда очистки всех логов esp//
|
||||
if (headerStr == "/clean|") {
|
||||
cleanDirectory("logs");
|
||||
}
|
||||
|
||||
//Прием сообщений cotrol ==============================================================================
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "NTP.h"
|
||||
|
||||
//раскомментировать если нужна цельная выгрузка графиков
|
||||
//#define SOLID_UPLOADING
|
||||
#define SOLID_UPLOADING
|
||||
|
||||
class Loging : public IoTItem {
|
||||
private:
|
||||
@@ -177,16 +177,6 @@ class Loging : public IoTItem {
|
||||
publishChart(id, oneSingleJson);
|
||||
}
|
||||
|
||||
void cleanLog() {
|
||||
String directory = "logs/" + id;
|
||||
auto dir = FileFS.openDir(directory);
|
||||
while (dir.next()) {
|
||||
String fname = dir.fileName();
|
||||
removeFile(directory + "/" + fname);
|
||||
SerialPrint("I", "Loging " + id, fname + " deleted");
|
||||
}
|
||||
}
|
||||
|
||||
int calculateMaxCount() {
|
||||
return 86400 / interval;
|
||||
}
|
||||
|
||||
@@ -190,6 +190,17 @@ void removeFile(const String& filename) {
|
||||
}
|
||||
}
|
||||
|
||||
//очищаем директорию с файлами
|
||||
void cleanDirectory(String path) {
|
||||
auto dir = FileFS.openDir(path);
|
||||
while (dir.next()) {
|
||||
String fname = dir.fileName();
|
||||
removeFile(path + "/" + fname);
|
||||
SerialPrint("I", "Files", fname + " deleted");
|
||||
}
|
||||
onFlashWrite();
|
||||
}
|
||||
|
||||
//счетчик количества записей на флешь за сеанс
|
||||
void onFlashWrite() {
|
||||
flashWriteNumber++;
|
||||
|
||||
Reference in New Issue
Block a user