mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 22:22:16 +03:00
Партии выгрузки в логгировании
This commit is contained in:
@@ -11,7 +11,7 @@ void testsPerform() {
|
||||
//Serial.println(isDigitDotCommaStr("-12552.5555"));
|
||||
|
||||
//String str = "Geeks for Geeks ";
|
||||
//
|
||||
|
||||
//Serial.println(itemsCount2(str, " "));
|
||||
|
||||
Serial.println("==========end============");
|
||||
|
||||
15
src/Web.cpp
15
src/Web.cpp
@@ -325,13 +325,20 @@ void web_init() {
|
||||
serverIP = jsonReadStr(configSetupJson, "serverip");
|
||||
request->send(200);
|
||||
}
|
||||
//set?order=button_1
|
||||
//set?order=button_1
|
||||
if (request->hasArg("order")) {
|
||||
String order = request->getParam("order")->value();
|
||||
order.replace("_"," ");
|
||||
order.replace("_", " ");
|
||||
orderBuf += order + ",";
|
||||
request->send(200);
|
||||
}
|
||||
|
||||
if (request->hasArg("grafmax")) {
|
||||
int value = request->getParam("grafmax")->value().toInt();
|
||||
jsonWriteInt(configSetupJson, "grafmax", value);
|
||||
saveConfig();
|
||||
request->send(200);
|
||||
}
|
||||
});
|
||||
|
||||
server.on("/order", HTTP_GET, [](AsyncWebServerRequest* request) {
|
||||
@@ -345,8 +352,6 @@ void web_init() {
|
||||
String msg = "";
|
||||
|
||||
if (USE_OTA) {
|
||||
msg = F("Обновление невозможно, память устройства 1 мб");
|
||||
} else {
|
||||
if (lastVersion == FIRMWARE_VERSION) {
|
||||
msg = F("Актуальная версия прошивки уже установлена.");
|
||||
} else if (lastVersion > FIRMWARE_VERSION) {
|
||||
@@ -358,6 +363,8 @@ void web_init() {
|
||||
} else if (lastVersion < FIRMWARE_VERSION) {
|
||||
msg = F("Ошибка версии. Попробуйте повторить позже...");
|
||||
}
|
||||
} else {
|
||||
msg = F("Обновление невозможно, память устройства 1 мб");
|
||||
}
|
||||
|
||||
String tmp = "{}";
|
||||
|
||||
@@ -36,8 +36,8 @@ void LoggingClass::execute(String keyOrValue) {
|
||||
} else {
|
||||
SerialPrint("E", "Logging", "This value not found on this device");
|
||||
}
|
||||
} else { //прилетело из события
|
||||
if (isDigitStr(keyOrValue) || keyOrValue.indexOf(".") != -1) { //если это число или дробное число
|
||||
} else { //прилетело из события
|
||||
if (isDigitDotCommaStr(keyOrValue)) { //если это число или дробное число
|
||||
loggingValue = keyOrValue;
|
||||
} else { //если это ключ
|
||||
if (getValue(_loggingValueKey) != "no value") {
|
||||
@@ -49,21 +49,22 @@ void LoggingClass::execute(String keyOrValue) {
|
||||
}
|
||||
|
||||
String filename = "logs/" + _key + ".txt";
|
||||
|
||||
|
||||
size_t cnt = countLines(filename);
|
||||
size_t sz = getFileSize(filename);
|
||||
|
||||
SerialPrint("I", "Logging", "http://" + WiFi.localIP().toString() + "/" + filename + " lines " + String(cnt, DEC) + ", size " + String(sz) + ", heap " + ESP.getFreeHeap());
|
||||
SerialPrint("I", "Logging", "http://" + WiFi.localIP().toString() + "/" + filename + " lines " + String(cnt, DEC) + ", size " + String(sz));
|
||||
|
||||
if ((cnt > _maxPoints + 1) || cnt == -1) {
|
||||
removeFile(filename);
|
||||
removeFile(filename);
|
||||
SerialPrint("E", "Logging", "file been remooved: " + filename + " " + String(cnt) + ">" + String(_maxPoints));
|
||||
cnt = 0;
|
||||
}
|
||||
|
||||
if (loggingValue != "") {
|
||||
if (cnt > _maxPoints) { //удаляем старую строку и добавляем новую
|
||||
String logData = readFile(filename, 10240);
|
||||
if (cnt > _maxPoints) { //удаляем старую строку и добавляем новую
|
||||
String logData = readFile(filename, 20480); //10240
|
||||
SerialPrint("I", "Logging", "Free heap " + ESP.getFreeHeap());
|
||||
if (logData == "large") {
|
||||
SerialPrint("E", "Logging", "File is very large");
|
||||
}
|
||||
@@ -132,39 +133,6 @@ void choose_log_date_and_send() {
|
||||
}
|
||||
}
|
||||
|
||||
void sendLogData2(String file, String topic) {
|
||||
String log_date = readFile(file, 5120);
|
||||
if (log_date != "failed") {
|
||||
log_date.replace("\r\n", "\n");
|
||||
log_date.replace("\r", "\n");
|
||||
String buf = "{}";
|
||||
String json_array;
|
||||
String unix_time;
|
||||
String value;
|
||||
while (log_date.length()) {
|
||||
String tmp = selectToMarker(log_date, "\n");
|
||||
log_date = deleteBeforeDelimiter(log_date, "\n");
|
||||
unix_time = selectToMarker(tmp, " ");
|
||||
jsonWriteInt(buf, "x", unix_time.toInt());
|
||||
value = deleteBeforeDelimiter(tmp, " ");
|
||||
jsonWriteFloat(buf, "y1", value.toFloat());
|
||||
if (log_date.length() < 3) {
|
||||
json_array += buf;
|
||||
} else {
|
||||
json_array += buf + ",";
|
||||
}
|
||||
buf = "{}";
|
||||
}
|
||||
unix_time = "";
|
||||
value = "";
|
||||
log_date = "";
|
||||
json_array = "{\"status\":[" + json_array + "]}";
|
||||
//SerialPrint("I", "module", json_array);
|
||||
|
||||
publishChart(topic, json_array);
|
||||
}
|
||||
}
|
||||
|
||||
void sendLogData(String file, String topic) {
|
||||
File configFile = FileFS.open(file, "r");
|
||||
if (!configFile) {
|
||||
@@ -189,12 +157,15 @@ void sendLogData(String file, String topic) {
|
||||
if (unix_time != "" || value != "") {
|
||||
json_array += buf + ",";
|
||||
}
|
||||
if (i >= 100) {
|
||||
json_array = "{\"status\":[" + json_array + "]}";
|
||||
json_array.replace("},]}", "}]}");
|
||||
publishChart(topic, json_array);
|
||||
json_array = "";
|
||||
i = 0;
|
||||
int grafmax = jsonReadInt(configSetupJson, "grafmax");
|
||||
if (grafmax != 0) {
|
||||
if (i >= grafmax) {
|
||||
json_array = "{\"status\":[" + json_array + "]}";
|
||||
json_array.replace("},]}", "}]}");
|
||||
publishChart(topic, json_array);
|
||||
json_array = "";
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
} while (psn < sz);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user