Merge pull request #5 from arendst/development

update repo
This commit is contained in:
Vic 2020-12-23 17:38:53 +00:00 committed by GitHub
commit cfd8239608
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 3284 additions and 1777 deletions

File diff suppressed because it is too large Load Diff

1550
.github/workflows/Tasmota_build_master.yml vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -797,8 +797,4 @@ const char HTTP_SNS_COLOR_BLUE[] PROGMEM = "{s}%s " D_COLOR_BLUE "{
const char HTTP_SNS_MILLILITERS[] PROGMEM = "{s}%s " D_VOLUME "{m}%s " D_UNIT_MILLILITERS "{e}";
#endif // USE_WEBSERVER
const uint32_t MARKER_START = 0x5AA55AA5;
const uint32_t MARKER_END = 0xA55AA55A;
const uint32_t VERSION_MARKER[] PROGMEM = { MARKER_START, VERSION, MARKER_END };
#endif // _I18N_H_

View File

@ -1896,48 +1896,41 @@ void SetSyslog(uint32_t loglevel)
TasmotaGlobal.syslog_timer = 0;
}
void Syslog(void)
{
void SyslogAsync(bool refresh) {
static IPAddress syslog_host_addr; // Syslog host IP address
static uint32_t syslog_host_hash = 0; // Syslog host name hash
// Destroys TasmotaGlobal.log_data
uint32_t current_hash = GetHash(SettingsText(SET_SYSLOG_HOST), strlen(SettingsText(SET_SYSLOG_HOST)));
if (syslog_host_hash != current_hash) {
syslog_host_hash = current_hash;
WiFi.hostByName(SettingsText(SET_SYSLOG_HOST), syslog_host_addr); // If sleep enabled this might result in exception so try to do it once using hash
}
if (PortUdp.beginPacket(syslog_host_addr, Settings.syslog_port)) {
char syslog_preamble[64]; // Hostname + Id
snprintf_P(syslog_preamble, sizeof(syslog_preamble), PSTR("%s ESP-"), NetworkHostname());
memmove(TasmotaGlobal.log_data + strlen(syslog_preamble), TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data) - strlen(syslog_preamble));
TasmotaGlobal.log_data[sizeof(TasmotaGlobal.log_data) -1] = '\0';
memcpy(TasmotaGlobal.log_data, syslog_preamble, strlen(syslog_preamble));
PortUdp_write(TasmotaGlobal.log_data, strlen(TasmotaGlobal.log_data));
PortUdp.endPacket();
delay(1); // Add time for UDP handling (#5512)
} else {
TasmotaGlobal.syslog_level = 0;
TasmotaGlobal.syslog_timer = SYSLOG_TIMER;
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION D_SYSLOG_HOST_NOT_FOUND ". " D_RETRY_IN " %d " D_UNIT_SECOND), SYSLOG_TIMER);
}
}
void SyslogAsync(bool refresh) {
static uint32_t index = 1;
if (!TasmotaGlobal.syslog_level) { return; }
if (refresh && !NeedLogRefresh(TasmotaGlobal.syslog_level, index)) { return; }
char* line;
size_t len;
while (GetLog(TasmotaGlobal.syslog_level, &index, &line, &len)) {
// 00:00:00.110 Project tasmota Wemos5 Version 9.2.0.1(theo)-2_7_4_9(2020-12-20T17:09:26)
// Project tasmota Wemos5 Version 9.2.0.1(theo)-2_7_4_9(2020-12-20T17:09:26)
// 00:00:02.096 HTP: Web server active on wemos5 with IP address 192.168.2.172
// HTP: Web server active on wemos5 with IP address 192.168.2.172
uint32_t mxtime = strchr(line, ' ') - line +1; // Remove mxtime
if (mxtime > 0) {
strlcpy(TasmotaGlobal.log_data, line +mxtime, len -mxtime);
Syslog();
uint32_t current_hash = GetHash(SettingsText(SET_SYSLOG_HOST), strlen(SettingsText(SET_SYSLOG_HOST)));
if (syslog_host_hash != current_hash) {
syslog_host_hash = current_hash;
WiFi.hostByName(SettingsText(SET_SYSLOG_HOST), syslog_host_addr); // If sleep enabled this might result in exception so try to do it once using hash
}
if (PortUdp.beginPacket(syslog_host_addr, Settings.syslog_port)) {
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);
len -= mxtime;
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);
PortUdp.endPacket();
delay(1); // Add time for UDP handling (#5512)
} else {
TasmotaGlobal.syslog_level = 0;
TasmotaGlobal.syslog_timer = SYSLOG_TIMER;
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION D_SYSLOG_HOST_NOT_FOUND ". " D_RETRY_IN " %d " D_UNIT_SECOND), SYSLOG_TIMER);
}
}
}
}
@ -1994,7 +1987,7 @@ bool GetLog(uint32_t req_loglevel, uint32_t* index_p, char** entry_pp, size_t* l
return false;
}
void AddLog(uint32_t loglevel) {
void AddLogData(uint32_t loglevel, const char* log_data) {
// char mxtime[10]; // "13:45:21 "
// snprintf_P(mxtime, sizeof(mxtime), PSTR("%02d" D_HOUR_MINUTE_SEPARATOR "%02d" D_MINUTE_SECOND_SEPARATOR "%02d "), RtcTime.hour, RtcTime.minute, RtcTime.second);
char mxtime[14]; // "13:45:21.999 "
@ -2002,7 +1995,7 @@ void AddLog(uint32_t loglevel) {
if ((loglevel <= TasmotaGlobal.seriallog_level) &&
(TasmotaGlobal.masterlog_level <= TasmotaGlobal.seriallog_level)) {
Serial.printf("%s%s\r\n", mxtime, TasmotaGlobal.log_data);
Serial.printf("%s%s\r\n", mxtime, log_data);
}
uint32_t highest_loglevel = Settings.weblog_level;
@ -2019,7 +2012,7 @@ void AddLog(uint32_t loglevel) {
TasmotaGlobal.log_buffer_pointer++; // Index 0 is not allowed as it is the end of char string
}
while (TasmotaGlobal.log_buffer_pointer == TasmotaGlobal.log_buffer[0] || // If log already holds the next index, remove it
strlen(TasmotaGlobal.log_buffer) + strlen(TasmotaGlobal.log_data) + strlen(mxtime) + 4 > LOG_BUFFER_SIZE) // 4 = log_buffer_pointer + '\1' + '\0'
strlen(TasmotaGlobal.log_buffer) + strlen(log_data) + strlen(mxtime) + 4 > LOG_BUFFER_SIZE) // 4 = log_buffer_pointer + '\1' + '\0'
{
char* it = TasmotaGlobal.log_buffer;
it++; // Skip log_buffer_pointer
@ -2028,64 +2021,40 @@ void AddLog(uint32_t loglevel) {
memmove(TasmotaGlobal.log_buffer, it, LOG_BUFFER_SIZE -(it-TasmotaGlobal.log_buffer)); // Move buffer forward to remove oldest log line
}
snprintf_P(TasmotaGlobal.log_buffer, sizeof(TasmotaGlobal.log_buffer), PSTR("%s%c%c%s%s\1"),
TasmotaGlobal.log_buffer, TasmotaGlobal.log_buffer_pointer++, '0'+loglevel, mxtime, TasmotaGlobal.log_data);
TasmotaGlobal.log_buffer, TasmotaGlobal.log_buffer_pointer++, '0'+loglevel, mxtime, log_data);
TasmotaGlobal.log_buffer_pointer &= 0xFF;
if (!TasmotaGlobal.log_buffer_pointer) {
TasmotaGlobal.log_buffer_pointer++; // Index 0 is not allowed as it is the end of char string
}
}
// TasmotaGlobal.prepped_loglevel = 0;
}
/*
void PrepLog_P(uint32_t loglevel, PGM_P formatP, ...)
{
va_list arg;
va_start(arg, formatP);
vsnprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), formatP, arg);
va_end(arg);
TasmotaGlobal.prepped_loglevel = loglevel;
}
*/
void AddLog_P(uint32_t loglevel, PGM_P formatP, ...)
{
/*
if (TasmotaGlobal.prepped_loglevel) {
AddLog(TasmotaGlobal.prepped_loglevel);
}
*/
char log_data[LOGSZ];
va_list arg;
va_start(arg, formatP);
vsnprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), formatP, arg);
vsnprintf_P(log_data, sizeof(log_data), formatP, arg);
va_end(arg);
AddLog(loglevel);
AddLogData(loglevel, log_data);
}
void AddLog_Debug(PGM_P formatP, ...)
{
char log_data[LOGSZ];
va_list arg;
va_start(arg, formatP);
vsnprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), formatP, arg);
vsnprintf_P(log_data, sizeof(log_data), formatP, arg);
va_end(arg);
AddLog(LOG_LEVEL_DEBUG);
AddLogData(LOG_LEVEL_DEBUG, log_data);
}
void AddLogBuffer(uint32_t loglevel, uint8_t *buffer, uint32_t count)
{
/*
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("DMP:"));
for (uint32_t i = 0; i < count; i++) {
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("%s %02X"), TasmotaGlobal.log_data, *(buffer++));
}
AddLog(loglevel);
*/
/*
strcpy_P(TasmotaGlobal.log_data, PSTR("DMP: "));
ToHex_P(buffer, count, TasmotaGlobal.log_data + strlen(TasmotaGlobal.log_data), sizeof(TasmotaGlobal.log_data) - strlen(TasmotaGlobal.log_data), ' ');
AddLog(loglevel);
*/
char hex_char[(count * 3) + 2];
AddLog_P(loglevel, PSTR("DMP: %s"), ToHex_P(buffer, count, hex_char, sizeof(hex_char), ' '));
}
@ -2101,16 +2070,18 @@ void AddLogMissed(const char *sensor, uint32_t misses)
}
void AddLogBufferSize(uint32_t loglevel, uint8_t *buffer, uint32_t count, uint32_t size) {
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("DMP:"));
char log_data[LOGSZ];
snprintf_P(log_data, sizeof(log_data), PSTR("DMP:"));
for (uint32_t i = 0; i < count; i++) {
if (1 == size) { // uint8_t
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("%s %02X"), TasmotaGlobal.log_data, *(buffer));
snprintf_P(log_data, sizeof(log_data), PSTR("%s %02X"), log_data, *(buffer));
} else { // uint16_t
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("%s %02X%02X"), TasmotaGlobal.log_data, *(buffer +1), *(buffer));
snprintf_P(log_data, sizeof(log_data), PSTR("%s %02X%02X"), log_data, *(buffer +1), *(buffer));
}
buffer += size;
}
AddLog(loglevel);
AddLogData(loglevel, log_data);
}
/*********************************************************************************************\

View File

@ -245,7 +245,7 @@ void CommandHandler(char* topicBuf, char* dataBuf, uint32_t data_len)
DEBUG_CORE_LOG(PSTR("CMD: Payload %d"), payload);
// TasmotaGlobal.backlog_timer = millis() + (100 * MIN_BACKLOG_DELAY);
TasmotaGlobal.backlog_timer = millis() + Settings.param[P_BACKLOG_DELAY];
TasmotaGlobal.backlog_timer = millis() + Settings.param[P_BACKLOG_DELAY]; // SetOption34
char command[CMDSZ] = { 0 };
XdrvMailbox.command = command;
@ -1188,7 +1188,7 @@ void CmndGpio(void)
}
char stemp1[TOPSZ];
if ((ResponseAppend_P(PSTR("\"" D_CMND_GPIO "%d\":{\"%d\":\"%s%s\"}"), i, sensor_type, GetTextIndexed(stemp1, sizeof(stemp1), sensor_name_idx, sensor_names), sindex) > (LOGSZ - TOPSZ)) || (i == ARRAY_SIZE(Settings.my_gp.io) -1)) {
ResponseJsonEndEnd();
ResponseJsonEnd();
MqttPublishPrefixTopic_P(RESULT_OR_STAT, XdrvMailbox.command);
jsflg2 = true;
jsflg = false;

View File

@ -897,11 +897,6 @@ void Every100mSeconds(void)
// As the max amount of sleep = 250 mSec this loop will shift in time...
power_t power_now;
/*
if (TasmotaGlobal.prepped_loglevel) {
AddLog(TasmotaGlobal.prepped_loglevel);
}
*/
if (TasmotaGlobal.latching_relay_pulse) {
TasmotaGlobal.latching_relay_pulse--;
if (!TasmotaGlobal.latching_relay_pulse) SetLatchingRelay(0, 0);
@ -1019,7 +1014,8 @@ void Every250mSeconds(void)
ota_result = 0;
ota_retry_counter--;
if (ota_retry_counter) {
strlcpy(TasmotaGlobal.mqtt_data, GetOtaUrl(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data)), sizeof(TasmotaGlobal.mqtt_data));
char ota_url[TOPSZ];
strlcpy(TasmotaGlobal.mqtt_data, GetOtaUrl(ota_url, sizeof(ota_url)), sizeof(TasmotaGlobal.mqtt_data));
#ifndef FIRMWARE_MINIMAL
if (RtcSettings.ota_loader) {
// OTA File too large so try OTA minimal version

View File

@ -170,7 +170,6 @@ struct {
char mqtt_client[99]; // Composed MQTT Clientname
char mqtt_topic[TOPSZ]; // Composed MQTT topic
char mqtt_data[MESSZ]; // MQTT publish buffer and web page ajax buffer
char log_data[LOGSZ]; // Logging
char log_buffer[LOG_BUFFER_SIZE]; // Web log buffer
} TasmotaGlobal;
@ -320,8 +319,6 @@ void setup(void) {
AddLog_P(LOG_LEVEL_INFO, PSTR(D_WARNING_MINIMAL_VERSION));
#endif // FIRMWARE_MINIMAL
memcpy_P(TasmotaGlobal.log_data, VERSION_MARKER, 1); // Dummy for compiler saving VERSION_MARKER
RtcInit();
#ifdef USE_ARDUINO_OTA

View File

@ -294,7 +294,7 @@ void MqttUnsubscribe(const char *topic)
void MqttPublishLoggingAsync(bool refresh) {
static uint32_t index = 1;
if (!Settings.flag.mqtt_enabled) { return; } // SetOption3 - Enable MQTT
if (!Settings.mqttlog_level || !Settings.flag.mqtt_enabled) { return; } // SetOption3 - Enable MQTT
if (refresh && !NeedLogRefresh(Settings.mqttlog_level, index)) { return; }
char* line;
@ -331,13 +331,14 @@ void MqttPublish(const char* topic, bool retained)
}
}
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("%s%s = %s"), slog_type, (Settings.flag.mqtt_enabled) ? topic : strrchr(topic,'/')+1, TasmotaGlobal.mqtt_data); // SetOption3 - Enable MQTT
if (strlen(TasmotaGlobal.log_data) >= (sizeof(TasmotaGlobal.log_data) - strlen(sretained) -1)) {
TasmotaGlobal.log_data[sizeof(TasmotaGlobal.log_data) - strlen(sretained) -5] = '\0';
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("%s ..."), TasmotaGlobal.log_data);
char log_data[LOGSZ];
snprintf_P(log_data, sizeof(log_data), PSTR("%s%s = %s"), slog_type, (Settings.flag.mqtt_enabled) ? topic : strrchr(topic,'/')+1, TasmotaGlobal.mqtt_data); // SetOption3 - Enable MQTT
if (strlen(log_data) >= (sizeof(log_data) - strlen(sretained) -1)) {
log_data[sizeof(log_data) - strlen(sretained) -5] = '\0';
snprintf_P(log_data, sizeof(log_data), PSTR("%s ..."), log_data);
}
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("%s%s"), TasmotaGlobal.log_data, sretained);
AddLog(LOG_LEVEL_INFO);
snprintf_P(log_data, sizeof(log_data), PSTR("%s%s"), log_data, sretained);
AddLogData(LOG_LEVEL_INFO, log_data);
if (Settings.ledstate &0x04) {
TasmotaGlobal.blinks++;

View File

@ -3622,7 +3622,8 @@ void toLogN(const char *cp, uint8_t len) {
void toLogEOL(const char *s1,const char *str) {
if (!str) return;
uint8_t index = 0;
char *cp = TasmotaGlobal.log_data;
char log_data[LOGSZ];
char *cp = log_data;
strcpy(cp, s1);
cp += strlen(s1);
while (*str) {
@ -3630,7 +3631,7 @@ void toLogEOL(const char *s1,const char *str) {
*cp++ = *str++;
}
*cp = 0;
AddLog(LOG_LEVEL_INFO);
AddLogData(LOG_LEVEL_INFO, log_data);
}

View File

@ -370,8 +370,9 @@ void TryResponseAppend_P(const char *format, ...)
{
AddLog_P(LOG_LEVEL_ERROR, PSTR("%s (%u/%u):"), kHAssError1, dlen, slen);
va_start(args, format);
vsnprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), format, args);
AddLog(LOG_LEVEL_ERROR);
char log_data[LOGSZ];
vsnprintf_P(log_data, sizeof(log_data), format, args);
AddLogData(LOG_LEVEL_ERROR, log_data);
}
else
{

View File

@ -404,16 +404,17 @@ void TuyaSendCmd(uint8_t cmd, uint8_t payload[] = nullptr, uint16_t payload_len
TuyaSerial->write(cmd); // Tuya command
TuyaSerial->write(payload_len >> 8); // following data length (Hi)
TuyaSerial->write(payload_len & 0xFF); // following data length (Lo)
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("TYA: Send \"55aa00%02x%02x%02x"), cmd, payload_len >> 8, payload_len & 0xFF);
char log_data[LOGSZ];
snprintf_P(log_data, sizeof(log_data), PSTR("TYA: Send \"55aa00%02x%02x%02x"), cmd, payload_len >> 8, payload_len & 0xFF);
for (uint32_t i = 0; i < payload_len; ++i) {
TuyaSerial->write(payload[i]);
checksum += payload[i];
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("%s%02x"), TasmotaGlobal.log_data, payload[i]);
snprintf_P(log_data, sizeof(log_data), PSTR("%s%02x"), log_data, payload[i]);
}
TuyaSerial->write(checksum);
TuyaSerial->flush();
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("%s%02x\""), TasmotaGlobal.log_data, checksum);
AddLog(LOG_LEVEL_DEBUG);
snprintf_P(log_data, sizeof(log_data), PSTR("%s%02x\""), log_data, checksum);
AddLogData(LOG_LEVEL_DEBUG, log_data);
}
void TuyaSendState(uint8_t id, uint8_t type, uint8_t* value)

View File

@ -534,20 +534,19 @@ void Z_Device::jsonPublishAttrList(const char * json_prefix, const Z_attribute_l
}
if (Settings.flag4.zigbee_distinct_topics) {
if (Settings.flag4.zb_topic_fname && friendlyName) {
//Clean special characters and check size of friendly name
char subtopic[TOPSZ];
if (Settings.flag4.zb_topic_fname && friendlyName && strlen(friendlyName)) {
// Clean special characters
char stemp[TOPSZ];
strlcpy(stemp, (!strlen(friendlyName)) ? MQTT_TOPIC : friendlyName, sizeof(stemp));
strlcpy(stemp, friendlyName, sizeof(stemp));
MakeValidMqtt(0, stemp);
//Create topic with Prefix3 and cleaned up friendly name
char frtopic[TOPSZ];
snprintf_P(frtopic, sizeof(frtopic), PSTR("%s/%s/" D_RSLT_SENSOR), SettingsText(SET_MQTTPREFIX3), stemp);
MqttPublish(frtopic, Settings.flag.mqtt_sensor_retain);
snprintf_P(subtopic, sizeof(subtopic), PSTR("%s/%s"), TasmotaGlobal.mqtt_topic, stemp);
} else {
char subtopic[16];
snprintf_P(subtopic, sizeof(subtopic), PSTR("%04X/" D_RSLT_SENSOR), shortaddr);
MqttPublishPrefixTopic_P(TELE, subtopic, Settings.flag.mqtt_sensor_retain);
snprintf_P(subtopic, sizeof(subtopic), PSTR("%s/%04X"), TasmotaGlobal.mqtt_topic, shortaddr);
}
char stopic[TOPSZ];
GetTopic_P(stopic, TELE, subtopic, D_RSLT_SENSOR);
MqttPublish(stopic, Settings.flag.mqtt_sensor_retain);
} else {
MqttPublishPrefixTopic_P(TELE, PSTR(D_RSLT_SENSOR), Settings.flag.mqtt_sensor_retain);
}
@ -624,10 +623,10 @@ Z_Device & Z_Devices::parseDeviceFromName(const char * param, uint16_t * parsed_
}
/*********************************************************************************************\
*
*
* Methods below build a JSON representation of device data
* Used by: ZbLight, ZbStatus, ZbInfo
*
*
\*********************************************************************************************/
// Add "Device":"0x1234","Name":"FrienflyName"

View File

@ -725,15 +725,19 @@ public:
char hex_char[_payload.len()*2+2];
ToHex_P((unsigned char*)_payload.getBuffer(), _payload.len(), hex_char, sizeof(hex_char));
Response_P(PSTR("{\"" D_JSON_ZIGBEEZCL_RECEIVED "\":{"
"\"groupid\":%d," "\"clusterid\":%d," "\"srcaddr\":\"0x%04X\","
"\"groupid\":%d," "\"clusterid\":\"0x%04X\"," "\"srcaddr\":\"0x%04X\","
"\"srcendpoint\":%d," "\"dstendpoint\":%d," "\"wasbroadcast\":%d,"
"\"" D_CMND_ZIGBEE_LINKQUALITY "\":%d," "\"securityuse\":%d," "\"seqnumber\":%d,"
"\"fc\":\"0x%02X\",\"manuf\":\"0x%04X\",\"transact\":%d,"
"\"fc\":\"0x%02X\","
"\"frametype\":%d,\"direction\":%d,\"disableresp\":%d,"
"\"manuf\":\"0x%04X\",\"transact\":%d,"
"\"cmdid\":\"0x%02X\",\"payload\":\"%s\"}}"),
_groupaddr, _cluster_id, _srcaddr,
_srcendpoint, _dstendpoint, _wasbroadcast,
_linkquality, _securityuse, _seqnumber,
_frame_control, _manuf_code, _transact_seq, _cmd_id,
_frame_control,
_frame_control.b.frame_type, _frame_control.b.direction, _frame_control.b.disable_def_resp,
_manuf_code, _transact_seq, _cmd_id,
hex_char);
if (Settings.flag3.tuya_serial_mqtt_publish) {
MqttPublishPrefixTopicRulesProcess_P(TELE, PSTR(D_RSLT_SENSOR));

View File

@ -124,13 +124,8 @@ void ExsSerialSend(const uint8_t data[] = nullptr, uint16_t len = 0)
char rc;
#ifdef EXS_DEBUG
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("EXS: Tx Packet: \""));
for (uint32_t i = 0; i < len; i++)
{
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("%s%02x"), TasmotaGlobal.log_data, data[i]);
}
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("%s\""), TasmotaGlobal.log_data);
AddLog(LOG_LEVEL_DEBUG_MORE);
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("EXS: Tx Packet:"));
AddLogBuffer(LOG_LEVEL_DEBUG_MORE, (uint8_t *)data, len);
#endif
while (retries)
@ -368,13 +363,8 @@ bool ExsModuleSelected(void)
bool ExsSetChannels(void)
{
#ifdef EXS_DEBUG
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("EXS: SetChannels: \""));
for (int i = 0; i < XdrvMailbox.data_len; i++)
{
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("%s%02x"), TasmotaGlobal.log_data, ((uint8_t *)XdrvMailbox.data)[i]);
}
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("%s\""), TasmotaGlobal.log_data);
AddLog(LOG_LEVEL_DEBUG_MORE);
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("EXS: SetChannels:"));
AddLogBuffer(LOG_LEVEL_DEBUG_MORE, (uint8_t *)XdrvMailbox.data, XdrvMailbox.data_len);
#endif
Exs.dimm[0] = ((uint8_t *)XdrvMailbox.data)[0];
@ -466,13 +456,8 @@ void ExsSerialInput(void)
Exs.cmd_status = 0;
#ifdef EXS_DEBUG
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("EXS: RX Packet: \""));
for (uint32_t i = 0; i < Exs.byte_counter; i++)
{
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("%s%02x"), TasmotaGlobal.log_data, Exs.buffer[i]);
}
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("%s\", CRC: 0x%02x"), TasmotaGlobal.log_data, crc);
AddLog(LOG_LEVEL_DEBUG_MORE);
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("EXS: CRC: 0x%02x, RX Packet:"), crc);
AddLogBuffer(LOG_LEVEL_DEBUG_MORE, (uint8_t *)Exs.buffer, Exs.byte_counter);
#endif
if (Exs.buffer[0] == crc)

View File

@ -267,10 +267,8 @@ bool ShdSerialSend(const uint8_t data[] = nullptr, uint16_t len = 0)
int retries = 3;
#ifdef SHELLY_DIMMER_DEBUG
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR(SHD_LOGNAME "Tx Packet:"));
for (uint32_t i = 0; i < len; i++)
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("%s %02x"), TasmotaGlobal.log_data, data[i]);
AddLog(LOG_LEVEL_DEBUG_MORE);
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(SHD_LOGNAME "Tx Packet:"));
AddLogBuffer(LOG_LEVEL_DEBUG_MORE, (uint8_t*)data, len);
#endif // SHELLY_DIMMER_DEBUG
while (retries--)
@ -696,10 +694,8 @@ bool ShdSerialInput(void)
// finished
#ifdef SHELLY_DIMMER_DEBUG
Shd.byte_counter++;
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR(SHD_LOGNAME "RX Packet:"));
for (uint32_t i = 0; i < Shd.byte_counter; i++)
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("%s %02x"), TasmotaGlobal.log_data, Shd.buffer[i]);
AddLog(LOG_LEVEL_DEBUG_MORE);
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(SHD_LOGNAME "Rx Packet:"));
AddLogBuffer(LOG_LEVEL_DEBUG_MORE, Shd.buffer, Shd.byte_counter);
#endif // SHELLY_DIMMER_DEBUG
Shd.byte_counter = 0;
@ -711,12 +707,9 @@ bool ShdSerialInput(void)
{
// wrong data
#ifdef SHELLY_DIMMER_DEBUG
AddLog_P(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Byte %i of received data frame is invalid"), Shd.byte_counter);
AddLog_P(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Byte %i of received data frame is invalid. Rx Packet:"), Shd.byte_counter);
Shd.byte_counter++;
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR(SHD_LOGNAME "RX Packet:"));
for (uint32_t i = 0; i < Shd.byte_counter; i++)
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("%s %02x"), TasmotaGlobal.log_data, Shd.buffer[i]);
AddLog(LOG_LEVEL_DEBUG_MORE);
AddLogBuffer(LOG_LEVEL_DEBUG_MORE, Shd.buffer, Shd.byte_counter);
#endif // SHELLY_DIMMER_DEBUG
Shd.byte_counter = 0;
}
@ -746,11 +739,8 @@ bool ShdModuleSelected(void) {
bool ShdSetChannels(void)
{
#ifdef SHELLY_DIMMER_DEBUG
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR(SHD_LOGNAME "SetChannels: \""));
for (int i = 0; i < XdrvMailbox.data_len; i++)
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("%s%02x"), TasmotaGlobal.log_data, ((uint8_t *)XdrvMailbox.data)[i]);
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("%s\""), TasmotaGlobal.log_data);
AddLog(LOG_LEVEL_DEBUG_MORE);
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(SHD_LOGNAME "SetChannels:"));
AddLogBuffer(LOG_LEVEL_DEBUG_MORE, (uint8_t *)XdrvMailbox.data, XdrvMailbox.data_len);
#endif // SHELLY_DIMMER_DEBUG
uint16_t brightness = ((uint32_t *)XdrvMailbox.data)[0];

View File

@ -55,8 +55,8 @@
#define FTC532_KEYS_MAX 8
#define FTC532_STATE_WAITING 0x01
#define FTC532_STATE_READING 0x02
#define FTC532_STATE_WAITING false
#define FTC532_STATE_READING true
// Rising edge timing in microseconds
#define FTC532_BIT 377
@ -67,14 +67,16 @@
struct FTC532 {
volatile uint32_t rxtime; // ISR timer memory
volatile uint16_t errors; // error counter
volatile uint16_t sample = 0xF0F0; // buffer for bit-coded time samples
volatile uint16_t rxbit; // ISR bit counter
uint16_t keys = 0; // bitmap of active keys
uint16_t old_keys = 0; // previously active keys
volatile uint8_t state; // ISR state
volatile uint8_t valid; // did we ever receive valid data?
uint8_t keys = 0; // bitmap of active keys
uint8_t old_keys = 0; // previously active keys
volatile bool state; // ISR state
bool present = false;
#ifdef DEBUG_TASMOTA_DRIVER
volatile uint16_t errors; // error counter
volatile bool valid; // did we ever receive valid data?
#endif // DEBUG_TASMOTA_DRIVER
} Ftc532;
const char ftc532_json[] PROGMEM = "\"FTC532\":{\"KEYS\":\"";
@ -92,7 +94,9 @@ void ICACHE_RAM_ATTR ftc532_ISR(void) { // Hardware interrupt routine, trigger
return;
} // FTC532_STATE_READING starts here
if (time_diff > FTC532_LONG + FTC532_BIT) {
#ifdef DEBUG_TASMOTA_DRIVER
++Ftc532.errors; // frame error
#endif // DEBUG_TASMOTA_DRIVER
Ftc532.state = FTC532_STATE_WAITING;
return;
}
@ -104,16 +108,19 @@ void ICACHE_RAM_ATTR ftc532_ISR(void) { // Hardware interrupt routine, trigger
++Ftc532.rxbit;
if (Ftc532.rxbit == FTC532_KEYS_MAX * 2) { // frame complete
Ftc532.rxbit = 0;
Ftc532.valid = 1;
#ifdef DEBUG_TASMOTA_DRIVER
Ftc532.valid = true;
#endif // DEBUG_TASMOTA_DRIVER
Ftc532.state = FTC532_STATE_WAITING;
}
}
void ftc532_init(void) { // Initialize
if (!PinUsed(GPIO_FTC532)) { return; }
#ifdef DEBUG_TASMOTA_DRIVER
Ftc532.errors = 0;
Ftc532.valid = 0;
Ftc532.valid = false;
#endif // DEBUG_TASMOTA_DRIVER
Ftc532.state = FTC532_STATE_WAITING;
Ftc532.rxtime = micros();
pinMode(Pin(GPIO_FTC532), INPUT_PULLUP);
@ -122,15 +129,19 @@ void ftc532_init(void) { // Initialize
}
void ftc532_update(void) { // Usually called every 50 ms
// // WARNING: Reduce callback frequency if this code is enabled
#ifdef DEBUG_TASMOTA_DRIVER
// WARNING: Reduce callback frequency if this code is enabled
// if ((Ftc532.sample & 0xF) != ((~Ftc532.sample >> 4) & 0xF) || ((Ftc532.sample >> 8) & 0xF) != ((~Ftc532.sample >> 12) & 0xF)) {
// AddLog_P(LOG_LEVEL_ERROR, PSTR("FTC: inverted sample does not match %x %x %x %x"),
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("FTC: inverted sample does not match %x %x %x %x"),
// Ftc532.sample & 0xF, (~Ftc532.sample >> 4) & 0xF, (Ftc532.sample >> 8) & 0xF, (~Ftc532.sample >> 12) & 0xF);
// }
#endif // DEBUG_TASMOTA_DRIVER
Ftc532.keys = (Ftc532.sample & 0xF) | ((Ftc532.sample >> 4) & 0xF0);
if (Ftc532.keys != Ftc532.old_keys) {
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("FTC: SAM=%04X KEY=%02X OLD=%02X ERR=%u OK=%u TIME=%lu Pin=%u"),
// Ftc532.sample, Ftc532.keys, Ftc532.old_keys, Ftc532.errors, Ftc532.valid, Ftc532.rxtime, Pin(GPIO_FTC532));
#ifdef DEBUG_TASMOTA_DRIVER
AddLog_P(LOG_LEVEL_DEBUG, PSTR("FTC: SAM=%04X KEY=%02X OLD=%02X ERR=%u OK=%u TIME=%lu Pin=%u"),
Ftc532.sample, Ftc532.keys, Ftc532.old_keys, Ftc532.errors, Ftc532.valid, Ftc532.rxtime, Pin(GPIO_FTC532));
#endif // DEBUG_TASMOTA_DRIVER
ftc532_publish();
Ftc532.old_keys = Ftc532.keys;
}
@ -171,4 +182,4 @@ bool Xdrv47(uint8_t function) {
return result;
}
#endif // USE_FTC532
#endif // USE_FTC532

View File

@ -222,7 +222,7 @@ void DebugFreeMem(void)
void DebugRtcDump(char* parms)
{
#ifdef ESP8266
#define CFG_COLS 16
uint32_t CFG_COLS = 16;
uint16_t idx;
uint16_t maxrow;
@ -258,24 +258,25 @@ void DebugRtcDump(char* parms)
maxrow = srow + mrow;
}
char log_data[LOGSZ];
for (row = srow; row < maxrow; row++) {
idx = row * CFG_COLS;
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("%03X:"), idx);
snprintf_P(log_data, sizeof(log_data), PSTR("%03X:"), idx);
for (col = 0; col < CFG_COLS; col++) {
if (!(col%4)) {
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("%s "), TasmotaGlobal.log_data);
snprintf_P(log_data, sizeof(log_data), PSTR("%s "), log_data);
}
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("%s %02X"), TasmotaGlobal.log_data, buffer[idx + col]);
snprintf_P(log_data, sizeof(log_data), PSTR("%s %02X"), log_data, buffer[idx + col]);
}
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("%s |"), TasmotaGlobal.log_data);
snprintf_P(log_data, sizeof(log_data), PSTR("%s |"), log_data);
for (col = 0; col < CFG_COLS; col++) {
// if (!(col%4)) {
// snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("%s "), TasmotaGlobal.log_data);
// snprintf_P(log_data, sizeof(log_data), PSTR("%s "), log_data);
// }
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("%s%c"), TasmotaGlobal.log_data, ((buffer[idx + col] > 0x20) && (buffer[idx + col] < 0x7F)) ? (char)buffer[idx + col] : ' ');
snprintf_P(log_data, sizeof(log_data), PSTR("%s%c"), log_data, ((buffer[idx + col] > 0x20) && (buffer[idx + col] < 0x7F)) ? (char)buffer[idx + col] : ' ');
}
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("%s|"), TasmotaGlobal.log_data);
AddLog(LOG_LEVEL_INFO);
snprintf_P(log_data, sizeof(log_data), PSTR("%s|"), log_data);
AddLogData(LOG_LEVEL_INFO, log_data);
}
#endif // ESP8266
}
@ -309,34 +310,32 @@ void DebugDump(uint32_t start, uint32_t size) {
maxrow = srow + mrow;
}
char log_data[LOGSZ];
for (row = srow; row < maxrow; row++) {
idx = row * CFG_COLS;
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("%03X:"), idx);
snprintf_P(log_data, sizeof(log_data), PSTR("%03X:"), idx);
for (col = 0; col < CFG_COLS; col++) {
if (!(col%4)) {
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("%s "), TasmotaGlobal.log_data);
snprintf_P(log_data, sizeof(log_data), PSTR("%s "), log_data);
}
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("%s %02X"), TasmotaGlobal.log_data, buffer[idx + col]);
snprintf_P(log_data, sizeof(log_data), PSTR("%s %02X"), log_data, buffer[idx + col]);
}
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("%s |"), TasmotaGlobal.log_data);
snprintf_P(log_data, sizeof(log_data), PSTR("%s |"), log_data);
for (col = 0; col < CFG_COLS; col++) {
// if (!(col%4)) {
// snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("%s "), TasmotaGlobal.log_data);
// snprintf_P(log_data, sizeof(log_data), PSTR("%s "), log_data);
// }
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("%s%c"), TasmotaGlobal.log_data, ((buffer[idx + col] > 0x20) && (buffer[idx + col] < 0x7F)) ? (char)buffer[idx + col] : ' ');
snprintf_P(log_data, sizeof(log_data), PSTR("%s%c"), log_data, ((buffer[idx + col] > 0x20) && (buffer[idx + col] < 0x7F)) ? (char)buffer[idx + col] : ' ');
}
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("%s|"), TasmotaGlobal.log_data);
AddLog(LOG_LEVEL_INFO);
snprintf_P(log_data, sizeof(log_data), PSTR("%s|"), log_data);
AddLogData(LOG_LEVEL_INFO, log_data);
delay(1);
}
}
void DebugCfgDump(char* parms)
{
#define CFG_COLS 16
uint32_t CFG_COLS = 16;
uint16_t idx;
uint16_t maxrow;
@ -362,24 +361,25 @@ void DebugCfgDump(char* parms)
maxrow = srow + mrow;
}
char log_data[LOGSZ];
for (row = srow; row < maxrow; row++) {
idx = row * CFG_COLS;
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("%03X:"), idx);
snprintf_P(log_data, sizeof(log_data), PSTR("%03X:"), idx);
for (col = 0; col < CFG_COLS; col++) {
if (!(col%4)) {
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("%s "), TasmotaGlobal.log_data);
snprintf_P(log_data, sizeof(log_data), PSTR("%s "), log_data);
}
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("%s %02X"), TasmotaGlobal.log_data, buffer[idx + col]);
snprintf_P(log_data, sizeof(log_data), PSTR("%s %02X"), log_data, buffer[idx + col]);
}
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("%s |"), TasmotaGlobal.log_data);
snprintf_P(log_data, sizeof(log_data), PSTR("%s |"), log_data);
for (col = 0; col < CFG_COLS; col++) {
// if (!(col%4)) {
// snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("%s "), TasmotaGlobal.log_data);
// snprintf_P(log_data, sizeof(log_data), PSTR("%s "), log_data);
// }
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("%s%c"), TasmotaGlobal.log_data, ((buffer[idx + col] > 0x20) && (buffer[idx + col] < 0x7F)) ? (char)buffer[idx + col] : ' ');
snprintf_P(log_data, sizeof(log_data), PSTR("%s%c"), log_data, ((buffer[idx + col] > 0x20) && (buffer[idx + col] < 0x7F)) ? (char)buffer[idx + col] : ' ');
}
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("%s|"), TasmotaGlobal.log_data);
AddLog(LOG_LEVEL_INFO);
snprintf_P(log_data, sizeof(log_data), PSTR("%s|"), log_data);
AddLogData(LOG_LEVEL_INFO, log_data);
delay(1);
}
}
@ -397,16 +397,17 @@ void DebugCfgPeek(char* parms)
uint16_t data16 = (buffer[address +1] << 8) + buffer[address];
uint32_t data32 = (buffer[address +3] << 24) + (buffer[address +2] << 16) + data16;
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("%03X:"), address);
char log_data[LOGSZ];
snprintf_P(log_data, sizeof(log_data), PSTR("%03X:"), address);
for (uint32_t i = 0; i < 4; i++) {
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("%s %02X"), TasmotaGlobal.log_data, buffer[address +i]);
snprintf_P(log_data, sizeof(log_data), PSTR("%s %02X"), log_data, buffer[address +i]);
}
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("%s |"), TasmotaGlobal.log_data);
snprintf_P(log_data, sizeof(log_data), PSTR("%s |"), log_data);
for (uint32_t i = 0; i < 4; i++) {
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("%s%c"), TasmotaGlobal.log_data, ((buffer[address +i] > 0x20) && (buffer[address +i] < 0x7F)) ? (char)buffer[address +i] : ' ');
snprintf_P(log_data, sizeof(log_data), PSTR("%s%c"), log_data, ((buffer[address +i] > 0x20) && (buffer[address +i] < 0x7F)) ? (char)buffer[address +i] : ' ');
}
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("%s| 0x%02X (%d), 0x%04X (%d), 0x%0LX (%lu)"), TasmotaGlobal.log_data, data8, data8, data16, data16, data32, data32);
AddLog(LOG_LEVEL_INFO);
snprintf_P(log_data, sizeof(log_data), PSTR("%s| 0x%02X (%d), 0x%04X (%d), 0x%0LX (%lu)"), log_data, data8, data8, data16, data16, data32, data32);
AddLogData(LOG_LEVEL_INFO, log_data);
}
void DebugCfgPoke(char* parms)

View File

@ -821,40 +821,41 @@ uint8_t sml_logindex;
void Dump2log(void) {
int16_t index=0,hcnt=0;
uint32_t d_lastms;
uint8_t dchars[16];
int16_t index=0,hcnt=0;
uint32_t d_lastms;
uint8_t dchars[16];
char log_data[LOGSZ]; // May be a lot smaller...
//if (!SML_SAVAILABLE) return;
if (dump2log&8) {
// combo mode
while (SML_SAVAILABLE) {
TasmotaGlobal.log_data[index]=':';
log_data[index]=':';
index++;
TasmotaGlobal.log_data[index]=' ';
log_data[index]=' ';
index++;
d_lastms=millis();
while ((millis()-d_lastms)<40) {
if (SML_SAVAILABLE) {
uint8_t c=SML_SREAD;
sprintf(&TasmotaGlobal.log_data[index],"%02x ",c);
sprintf(&log_data[index],"%02x ",c);
dchars[hcnt]=c;
index+=3;
hcnt++;
if (hcnt>15) {
// line complete, build asci chars
TasmotaGlobal.log_data[index]='=';
log_data[index]='=';
index++;
TasmotaGlobal.log_data[index]='>';
log_data[index]='>';
index++;
TasmotaGlobal.log_data[index]=' ';
log_data[index]=' ';
index++;
for (uint8_t ccnt=0; ccnt<16; ccnt++) {
if (isprint(dchars[ccnt])) {
TasmotaGlobal.log_data[index]=dchars[ccnt];
log_data[index]=dchars[ccnt];
} else {
TasmotaGlobal.log_data[index]=' ';
log_data[index]=' ';
}
index++;
}
@ -863,8 +864,8 @@ uint8_t dchars[16];
}
}
if (index>0) {
TasmotaGlobal.log_data[index]=0;
AddLog(LOG_LEVEL_INFO);
log_data[index]=0;
AddLogData(LOG_LEVEL_INFO, log_data);
index=0;
hcnt=0;
}
@ -875,24 +876,24 @@ uint8_t dchars[16];
while (SML_SAVAILABLE) {
char c=SML_SREAD&0x7f;
if (c=='\n' || c=='\r') {
TasmotaGlobal.log_data[sml_logindex]=0;
log_data[sml_logindex]=0;
AddLog(LOG_LEVEL_INFO);
sml_logindex=2;
TasmotaGlobal.log_data[0]=':';
TasmotaGlobal.log_data[1]=' ';
log_data[0]=':';
log_data[1]=' ';
break;
}
TasmotaGlobal.log_data[sml_logindex]=c;
if (sml_logindex<sizeof(TasmotaGlobal.log_data)-2) {
log_data[sml_logindex]=c;
if (sml_logindex<sizeof(log_data)-2) {
sml_logindex++;
}
}
} else {
//while (SML_SAVAILABLE) {
index=0;
TasmotaGlobal.log_data[index]=':';
log_data[index]=':';
index++;
TasmotaGlobal.log_data[index]=' ';
log_data[index]=' ';
index++;
d_lastms=millis();
while ((millis()-d_lastms)<40) {
@ -901,7 +902,7 @@ uint8_t dchars[16];
if (meter_desc_p[(dump2log&7)-1].type=='e') {
// ebus
c=SML_SREAD;
sprintf(&TasmotaGlobal.log_data[index],"%02x ",c);
sprintf(&log_data[index],"%02x ",c);
index+=3;
if (c==EBUS_SYNC) break;
} else {
@ -916,14 +917,14 @@ uint8_t dchars[16];
}
}
c=SML_SREAD;
sprintf(&TasmotaGlobal.log_data[index],"%02x ",c);
sprintf(&log_data[index],"%02x ",c);
index+=3;
}
}
}
if (index>2) {
TasmotaGlobal.log_data[index]=0;
AddLog(LOG_LEVEL_INFO);
log_data[index]=0;
AddLogData(LOG_LEVEL_INFO, log_data);
}
}
}