Merge branch 'development' of https://github.com/arendst/Tasmota into lvgl_m5stick

This commit is contained in:
Stephan Hadinger 2021-05-30 18:59:30 +02:00
commit 6a85cd8e67
3 changed files with 38 additions and 4 deletions

View File

@ -2198,6 +2198,7 @@ void SyslogAsync(bool refresh) {
AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION D_SYSLOG_HOST_NOT_FOUND ". " D_RETRY_IN " %d " D_UNIT_SECOND), SYSLOG_TIMER);
return;
}
/*
char log_data[len +72]; // Hostname + Id + log data
snprintf_P(log_data, sizeof(log_data), PSTR("%s ESP-"), NetworkHostname());
uint32_t preamble_len = strlen(log_data);
@ -2205,6 +2206,20 @@ void SyslogAsync(bool refresh) {
strlcpy(log_data +preamble_len, line +mxtime, len);
// wemos5 ESP-HTP: Web server active on wemos5 with IP address 192.168.2.172
PortUdp_write(log_data, preamble_len + len);
*/
String log_data = NetworkHostname();
log_data += F(" ESP-");
// log_data.concat(line +mxtime, len -mxtime -1); // Add terminating \'0'
len--;
char dummy = line[len];
line[len] = '\0'; // Add terminating \'0'
log_data.concat(line +mxtime);
line[len] = dummy;
// wemos5 ESP-HTP: Web server active on wemos5 with IP address 192.168.2.172
PortUdp.write(log_data.c_str());
PortUdp.endPacket();
delay(1); // Add time for UDP handling (#5512)
}

View File

@ -2848,9 +2848,16 @@ void HandleHttpCommand(void)
// [14:49:36.123 MQTT: stat/wemos5/RESULT = {"POWER":"OFF"}] > [{"POWER":"OFF"}]
char* JSON = (char*)memchr(line, '{', len);
if (JSON) { // Is it a JSON message (and not only [15:26:08 MQT: stat/wemos5/POWER = O])
size_t JSONlen = len - (JSON - line);
String stemp = (cflg) ? "," : ""; // Add a comma
stemp.concat(JSON +1, JSONlen -3); // Add a terminating '\0'
size_t JSONlen = len - (JSON - line);
// stemp.concat(JSON +1, JSONlen -3); // Add a terminating '\0'
len -= 2;
char dummy = line[len];
line[len] = '\0'; // Add terminating \'0'
stemp.concat(JSON +1);
line[len] = dummy;
Webserver->sendContent(stemp);
cflg = true;
}
@ -2931,7 +2938,12 @@ void HandleConsoleRefresh(void)
WSContentFlush();
while (GetLog(Settings.weblog_level, &index, &line, &len)) {
String stemp = (cflg) ? "\n" : ""; // Add a newline
stemp.concat(line, len -1); // Add a terminating '\0'
len--;
// stemp.concat(line, len); // Add a terminating '\0'
char dummy = line[len];
line[len] = '\0'; // Add terminating \'0'
stemp.concat(line);
line[len] = dummy;
Webserver->sendContent(stemp);
cflg = true;
}

View File

@ -300,7 +300,14 @@ String TelegramExecuteCommand(const char *svalue) {
if (JSON) { // Is it a JSON message (and not only [15:26:08 MQT: stat/wemos5/POWER = O])
size_t JSONlen = len - (JSON - line);
if (cflg) { response += F(","); }
response.concat(JSON +1, JSONlen -3);
// response.concat(JSON +1, JSONlen -3);
len -= 2;
char dummy = line[len];
line[len] = '\0'; // Add terminating \'0'
response.concat(JSON +1);
line[len] = dummy;
cflg = true;
}
}