mirror of https://github.com/arendst/Tasmota.git
Provide weblog without heap use
This commit is contained in:
parent
36c816dce1
commit
aaa9e3d0e6
|
@ -2843,22 +2843,14 @@ void HandleHttpCommand(void)
|
||||||
uint32_t index = curridx;
|
uint32_t index = curridx;
|
||||||
char* line;
|
char* line;
|
||||||
size_t len;
|
size_t len;
|
||||||
WSContentFlush();
|
|
||||||
while (GetLog(TasmotaGlobal.templog_level, &index, &line, &len)) {
|
while (GetLog(TasmotaGlobal.templog_level, &index, &line, &len)) {
|
||||||
// [14:49:36.123 MQTT: stat/wemos5/RESULT = {"POWER":"OFF"}] > [{"POWER":"OFF"}]
|
// [14:49:36.123 MQTT: stat/wemos5/RESULT = {"POWER":"OFF"}] > [{"POWER":"OFF"}]
|
||||||
char* JSON = (char*)memchr(line, '{', len);
|
char* JSON = (char*)memchr(line, '{', len);
|
||||||
if (JSON) { // Is it a JSON message (and not only [15:26:08 MQT: stat/wemos5/POWER = O])
|
if (JSON) { // Is it a JSON message (and not only [15:26:08 MQT: stat/wemos5/POWER = O])
|
||||||
String stemp = (cflg) ? "," : ""; // Add comma
|
if (cflg) { WSContentSend_P(PSTR(",")); }
|
||||||
|
WSContentFlush();
|
||||||
// size_t JSONlen = len - (JSON - line);
|
uint32_t JSONlen = len - (JSON - line) -3;
|
||||||
// stemp.concat(JSON +1, JSONlen -3); // Add terminating '\0' - Not supported on ESP32
|
Webserver->sendContent(JSON +1, JSONlen);
|
||||||
len -= 2; // Skip last '}'
|
|
||||||
char save_log_char = line[len];
|
|
||||||
line[len] = '\0'; // Add terminating \'0'
|
|
||||||
stemp.concat(JSON +1); // Skip first '{'
|
|
||||||
line[len] = save_log_char;
|
|
||||||
|
|
||||||
Webserver->sendContent(stemp);
|
|
||||||
cflg = true;
|
cflg = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2935,18 +2927,10 @@ void HandleConsoleRefresh(void)
|
||||||
bool cflg = (index);
|
bool cflg = (index);
|
||||||
char* line;
|
char* line;
|
||||||
size_t len;
|
size_t len;
|
||||||
WSContentFlush();
|
|
||||||
while (GetLog(Settings.weblog_level, &index, &line, &len)) {
|
while (GetLog(Settings.weblog_level, &index, &line, &len)) {
|
||||||
String stemp = (cflg) ? "\n" : ""; // Add newline
|
if (cflg) { WSContentSend_P(PSTR("\n")); }
|
||||||
|
WSContentFlush();
|
||||||
// stemp.concat(line, len -1); // Add terminating '\0' - Not supported on ESP32
|
Webserver->sendContent(line, len -1);
|
||||||
len--;
|
|
||||||
char save_log_char = line[len];
|
|
||||||
line[len] = '\0'; // Add terminating \'0'
|
|
||||||
stemp.concat(line);
|
|
||||||
line[len] = save_log_char;
|
|
||||||
|
|
||||||
Webserver->sendContent(stemp);
|
|
||||||
cflg = true;
|
cflg = true;
|
||||||
}
|
}
|
||||||
WSContentSend_P(PSTR("}1"));
|
WSContentSend_P(PSTR("}1"));
|
||||||
|
|
|
@ -673,15 +673,10 @@ void HandleBerryConsole(void)
|
||||||
// bool cflg = (index);
|
// bool cflg = (index);
|
||||||
// char* line;
|
// char* line;
|
||||||
// size_t len;
|
// size_t len;
|
||||||
// WSContentFlush();
|
|
||||||
// while (GetLog(Settings.weblog_level, &index, &line, &len)) {
|
// while (GetLog(Settings.weblog_level, &index, &line, &len)) {
|
||||||
// String stemp = (cflg) ? "\n" : ""; // Add newline
|
// if (cflg) { WSContentSend_P(PSTR("\n")); }
|
||||||
// len--;
|
// WSContentFlush();
|
||||||
// char save_log_char = line[len];
|
// Webserver->sendContent(line, len -1);
|
||||||
// line[len] = '\0'; // Add terminating \'0'
|
|
||||||
// stemp.concat(line);
|
|
||||||
// line[len] = save_log_char;
|
|
||||||
// Webserver->sendContent(stemp);
|
|
||||||
// cflg = true;
|
// cflg = true;
|
||||||
// }
|
// }
|
||||||
// WSContentSend_P(PSTR("}1"));
|
// WSContentSend_P(PSTR("}1"));
|
||||||
|
|
Loading…
Reference in New Issue