mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-23 18:56:38 +00:00
Prep removal of global log_data
Prep removal of global log_data providing re-entry
This commit is contained in:
parent
436e62c86a
commit
b1b20c53b4
@ -1987,7 +1987,7 @@ bool GetLog(uint32_t req_loglevel, uint32_t* index_p, char** entry_pp, size_t* l
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddLog(uint32_t loglevel) {
|
void AddLogData(uint32_t loglevel, const char* log_data) {
|
||||||
// char mxtime[10]; // "13:45:21 "
|
// 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);
|
// 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 "
|
char mxtime[14]; // "13:45:21.999 "
|
||||||
@ -1995,7 +1995,7 @@ void AddLog(uint32_t loglevel) {
|
|||||||
|
|
||||||
if ((loglevel <= TasmotaGlobal.seriallog_level) &&
|
if ((loglevel <= TasmotaGlobal.seriallog_level) &&
|
||||||
(TasmotaGlobal.masterlog_level <= 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;
|
uint32_t highest_loglevel = Settings.weblog_level;
|
||||||
@ -2012,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
|
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
|
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;
|
char* it = TasmotaGlobal.log_buffer;
|
||||||
it++; // Skip log_buffer_pointer
|
it++; // Skip log_buffer_pointer
|
||||||
@ -2021,64 +2021,44 @@ 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
|
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"),
|
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;
|
TasmotaGlobal.log_buffer_pointer &= 0xFF;
|
||||||
if (!TasmotaGlobal.log_buffer_pointer) {
|
if (!TasmotaGlobal.log_buffer_pointer) {
|
||||||
TasmotaGlobal.log_buffer_pointer++; // Index 0 is not allowed as it is the end of char string
|
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(uint32_t loglevel) {
|
||||||
|
AddLogData(loglevel, TasmotaGlobal.log_data);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
void AddLog_P(uint32_t loglevel, PGM_P formatP, ...)
|
void AddLog_P(uint32_t loglevel, PGM_P formatP, ...)
|
||||||
{
|
{
|
||||||
/*
|
char log_data[LOGSZ];
|
||||||
if (TasmotaGlobal.prepped_loglevel) {
|
|
||||||
AddLog(TasmotaGlobal.prepped_loglevel);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
va_list arg;
|
va_list arg;
|
||||||
va_start(arg, formatP);
|
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);
|
va_end(arg);
|
||||||
|
|
||||||
AddLog(loglevel);
|
AddLogData(loglevel, log_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddLog_Debug(PGM_P formatP, ...)
|
void AddLog_Debug(PGM_P formatP, ...)
|
||||||
{
|
{
|
||||||
|
char log_data[LOGSZ];
|
||||||
|
|
||||||
va_list arg;
|
va_list arg;
|
||||||
va_start(arg, formatP);
|
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);
|
va_end(arg);
|
||||||
|
|
||||||
AddLog(LOG_LEVEL_DEBUG);
|
AddLogData(LOG_LEVEL_DEBUG, log_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddLogBuffer(uint32_t loglevel, uint8_t *buffer, uint32_t count)
|
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];
|
char hex_char[(count * 3) + 2];
|
||||||
AddLog_P(loglevel, PSTR("DMP: %s"), ToHex_P(buffer, count, hex_char, sizeof(hex_char), ' '));
|
AddLog_P(loglevel, PSTR("DMP: %s"), ToHex_P(buffer, count, hex_char, sizeof(hex_char), ' '));
|
||||||
}
|
}
|
||||||
@ -2094,16 +2074,18 @@ void AddLogMissed(const char *sensor, uint32_t misses)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AddLogBufferSize(uint32_t loglevel, uint8_t *buffer, uint32_t count, uint32_t size) {
|
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++) {
|
for (uint32_t i = 0; i < count; i++) {
|
||||||
if (1 == size) { // uint8_t
|
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
|
} 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;
|
buffer += size;
|
||||||
}
|
}
|
||||||
AddLog(loglevel);
|
AddLogData(loglevel, log_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************************************\
|
/*********************************************************************************************\
|
||||||
|
@ -897,11 +897,6 @@ void Every100mSeconds(void)
|
|||||||
// As the max amount of sleep = 250 mSec this loop will shift in time...
|
// As the max amount of sleep = 250 mSec this loop will shift in time...
|
||||||
power_t power_now;
|
power_t power_now;
|
||||||
|
|
||||||
/*
|
|
||||||
if (TasmotaGlobal.prepped_loglevel) {
|
|
||||||
AddLog(TasmotaGlobal.prepped_loglevel);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
if (TasmotaGlobal.latching_relay_pulse) {
|
if (TasmotaGlobal.latching_relay_pulse) {
|
||||||
TasmotaGlobal.latching_relay_pulse--;
|
TasmotaGlobal.latching_relay_pulse--;
|
||||||
if (!TasmotaGlobal.latching_relay_pulse) SetLatchingRelay(0, 0);
|
if (!TasmotaGlobal.latching_relay_pulse) SetLatchingRelay(0, 0);
|
||||||
@ -1019,7 +1014,8 @@ void Every250mSeconds(void)
|
|||||||
ota_result = 0;
|
ota_result = 0;
|
||||||
ota_retry_counter--;
|
ota_retry_counter--;
|
||||||
if (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
|
#ifndef FIRMWARE_MINIMAL
|
||||||
if (RtcSettings.ota_loader) {
|
if (RtcSettings.ota_loader) {
|
||||||
// OTA File too large so try OTA minimal version
|
// OTA File too large so try OTA minimal version
|
||||||
|
@ -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
|
char log_data[LOGSZ];
|
||||||
if (strlen(TasmotaGlobal.log_data) >= (sizeof(TasmotaGlobal.log_data) - strlen(sretained) -1)) {
|
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
|
||||||
TasmotaGlobal.log_data[sizeof(TasmotaGlobal.log_data) - strlen(sretained) -5] = '\0';
|
if (strlen(log_data) >= (sizeof(log_data) - strlen(sretained) -1)) {
|
||||||
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("%s ..."), TasmotaGlobal.log_data);
|
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);
|
snprintf_P(log_data, sizeof(log_data), PSTR("%s%s"), log_data, sretained);
|
||||||
AddLog(LOG_LEVEL_INFO);
|
AddLogData(LOG_LEVEL_INFO, log_data);
|
||||||
|
|
||||||
if (Settings.ledstate &0x04) {
|
if (Settings.ledstate &0x04) {
|
||||||
TasmotaGlobal.blinks++;
|
TasmotaGlobal.blinks++;
|
||||||
|
@ -3622,7 +3622,8 @@ void toLogN(const char *cp, uint8_t len) {
|
|||||||
void toLogEOL(const char *s1,const char *str) {
|
void toLogEOL(const char *s1,const char *str) {
|
||||||
if (!str) return;
|
if (!str) return;
|
||||||
uint8_t index = 0;
|
uint8_t index = 0;
|
||||||
char *cp = TasmotaGlobal.log_data;
|
char log_data[LOGSZ];
|
||||||
|
char *cp = log_data;
|
||||||
strcpy(cp, s1);
|
strcpy(cp, s1);
|
||||||
cp += strlen(s1);
|
cp += strlen(s1);
|
||||||
while (*str) {
|
while (*str) {
|
||||||
@ -3630,7 +3631,7 @@ void toLogEOL(const char *s1,const char *str) {
|
|||||||
*cp++ = *str++;
|
*cp++ = *str++;
|
||||||
}
|
}
|
||||||
*cp = 0;
|
*cp = 0;
|
||||||
AddLog(LOG_LEVEL_INFO);
|
AddLogData(LOG_LEVEL_INFO, log_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -370,8 +370,9 @@ void TryResponseAppend_P(const char *format, ...)
|
|||||||
{
|
{
|
||||||
AddLog_P(LOG_LEVEL_ERROR, PSTR("%s (%u/%u):"), kHAssError1, dlen, slen);
|
AddLog_P(LOG_LEVEL_ERROR, PSTR("%s (%u/%u):"), kHAssError1, dlen, slen);
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
vsnprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), format, args);
|
char log_data[LOGSZ];
|
||||||
AddLog(LOG_LEVEL_ERROR);
|
vsnprintf_P(log_data, sizeof(log_data), format, args);
|
||||||
|
AddLogData(LOG_LEVEL_ERROR, log_data);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -404,16 +404,17 @@ void TuyaSendCmd(uint8_t cmd, uint8_t payload[] = nullptr, uint16_t payload_len
|
|||||||
TuyaSerial->write(cmd); // Tuya command
|
TuyaSerial->write(cmd); // Tuya command
|
||||||
TuyaSerial->write(payload_len >> 8); // following data length (Hi)
|
TuyaSerial->write(payload_len >> 8); // following data length (Hi)
|
||||||
TuyaSerial->write(payload_len & 0xFF); // following data length (Lo)
|
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) {
|
for (uint32_t i = 0; i < payload_len; ++i) {
|
||||||
TuyaSerial->write(payload[i]);
|
TuyaSerial->write(payload[i]);
|
||||||
checksum += 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->write(checksum);
|
||||||
TuyaSerial->flush();
|
TuyaSerial->flush();
|
||||||
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("%s%02x\""), TasmotaGlobal.log_data, checksum);
|
snprintf_P(log_data, sizeof(log_data), PSTR("%s%02x\""), log_data, checksum);
|
||||||
AddLog(LOG_LEVEL_DEBUG);
|
AddLogData(LOG_LEVEL_DEBUG, log_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TuyaSendState(uint8_t id, uint8_t type, uint8_t* value)
|
void TuyaSendState(uint8_t id, uint8_t type, uint8_t* value)
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
* https://ex-store.de/2-Kanal-RS232-WiFi-WLan-Dimmer-Modul-V4-fuer-Unterputzmontage-230V-3A
|
* https://ex-store.de/2-Kanal-RS232-WiFi-WLan-Dimmer-Modul-V4-fuer-Unterputzmontage-230V-3A
|
||||||
* https://ex-store.de/2-Kanal-RS232-WiFi-WLan-Dimmer-Modul-V4-fuer-Unterputzmontage-230V-3A-ESP8266-V12-Stift-und-Buchsenleisten
|
* https://ex-store.de/2-Kanal-RS232-WiFi-WLan-Dimmer-Modul-V4-fuer-Unterputzmontage-230V-3A-ESP8266-V12-Stift-und-Buchsenleisten
|
||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
//#define EXS_DEBUG
|
#define EXS_DEBUG
|
||||||
|
|
||||||
#define XDRV_30 30
|
#define XDRV_30 30
|
||||||
|
|
||||||
@ -124,13 +124,8 @@ void ExsSerialSend(const uint8_t data[] = nullptr, uint16_t len = 0)
|
|||||||
char rc;
|
char rc;
|
||||||
|
|
||||||
#ifdef EXS_DEBUG
|
#ifdef EXS_DEBUG
|
||||||
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("EXS: Tx Packet: \""));
|
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("EXS: Tx Packet:"));
|
||||||
for (uint32_t i = 0; i < len; i++)
|
AddLogBuffer(LOG_LEVEL_DEBUG_MORE, (uint8_t *)data, len);
|
||||||
{
|
|
||||||
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);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
while (retries)
|
while (retries)
|
||||||
@ -368,13 +363,8 @@ bool ExsModuleSelected(void)
|
|||||||
bool ExsSetChannels(void)
|
bool ExsSetChannels(void)
|
||||||
{
|
{
|
||||||
#ifdef EXS_DEBUG
|
#ifdef EXS_DEBUG
|
||||||
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("EXS: SetChannels: \""));
|
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("EXS: SetChannels:"));
|
||||||
for (int i = 0; i < XdrvMailbox.data_len; i++)
|
AddLogBuffer(LOG_LEVEL_DEBUG_MORE, (uint8_t *)XdrvMailbox.data, XdrvMailbox.data_len);
|
||||||
{
|
|
||||||
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);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Exs.dimm[0] = ((uint8_t *)XdrvMailbox.data)[0];
|
Exs.dimm[0] = ((uint8_t *)XdrvMailbox.data)[0];
|
||||||
@ -466,13 +456,8 @@ void ExsSerialInput(void)
|
|||||||
Exs.cmd_status = 0;
|
Exs.cmd_status = 0;
|
||||||
|
|
||||||
#ifdef EXS_DEBUG
|
#ifdef EXS_DEBUG
|
||||||
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("EXS: RX Packet: \""));
|
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("EXS: CRC: 0x%02x, RX Packet:"), crc);
|
||||||
for (uint32_t i = 0; i < Exs.byte_counter; i++)
|
AddLogBuffer(LOG_LEVEL_DEBUG_MORE, (uint8_t *)Exs.buffer, Exs.byte_counter);
|
||||||
{
|
|
||||||
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);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (Exs.buffer[0] == crc)
|
if (Exs.buffer[0] == crc)
|
||||||
|
@ -267,10 +267,8 @@ bool ShdSerialSend(const uint8_t data[] = nullptr, uint16_t len = 0)
|
|||||||
int retries = 3;
|
int retries = 3;
|
||||||
|
|
||||||
#ifdef SHELLY_DIMMER_DEBUG
|
#ifdef SHELLY_DIMMER_DEBUG
|
||||||
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR(SHD_LOGNAME "Tx Packet:"));
|
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(SHD_LOGNAME "Tx Packet:"));
|
||||||
for (uint32_t i = 0; i < len; i++)
|
AddLogBuffer(LOG_LEVEL_DEBUG_MORE, (uint8_t*)data, len);
|
||||||
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("%s %02x"), TasmotaGlobal.log_data, data[i]);
|
|
||||||
AddLog(LOG_LEVEL_DEBUG_MORE);
|
|
||||||
#endif // SHELLY_DIMMER_DEBUG
|
#endif // SHELLY_DIMMER_DEBUG
|
||||||
|
|
||||||
while (retries--)
|
while (retries--)
|
||||||
@ -696,10 +694,8 @@ bool ShdSerialInput(void)
|
|||||||
// finished
|
// finished
|
||||||
#ifdef SHELLY_DIMMER_DEBUG
|
#ifdef SHELLY_DIMMER_DEBUG
|
||||||
Shd.byte_counter++;
|
Shd.byte_counter++;
|
||||||
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR(SHD_LOGNAME "RX Packet:"));
|
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(SHD_LOGNAME "Rx Packet:"));
|
||||||
for (uint32_t i = 0; i < Shd.byte_counter; i++)
|
AddLogBuffer(LOG_LEVEL_DEBUG_MORE, Shd.buffer, Shd.byte_counter);
|
||||||
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR("%s %02x"), TasmotaGlobal.log_data, Shd.buffer[i]);
|
|
||||||
AddLog(LOG_LEVEL_DEBUG_MORE);
|
|
||||||
#endif // SHELLY_DIMMER_DEBUG
|
#endif // SHELLY_DIMMER_DEBUG
|
||||||
Shd.byte_counter = 0;
|
Shd.byte_counter = 0;
|
||||||
|
|
||||||
@ -711,12 +707,9 @@ bool ShdSerialInput(void)
|
|||||||
{
|
{
|
||||||
// wrong data
|
// wrong data
|
||||||
#ifdef SHELLY_DIMMER_DEBUG
|
#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++;
|
Shd.byte_counter++;
|
||||||
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR(SHD_LOGNAME "RX Packet:"));
|
AddLogBuffer(LOG_LEVEL_DEBUG_MORE, Shd.buffer, Shd.byte_counter);
|
||||||
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);
|
|
||||||
#endif // SHELLY_DIMMER_DEBUG
|
#endif // SHELLY_DIMMER_DEBUG
|
||||||
Shd.byte_counter = 0;
|
Shd.byte_counter = 0;
|
||||||
}
|
}
|
||||||
@ -746,11 +739,8 @@ bool ShdModuleSelected(void) {
|
|||||||
bool ShdSetChannels(void)
|
bool ShdSetChannels(void)
|
||||||
{
|
{
|
||||||
#ifdef SHELLY_DIMMER_DEBUG
|
#ifdef SHELLY_DIMMER_DEBUG
|
||||||
snprintf_P(TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data), PSTR(SHD_LOGNAME "SetChannels: \""));
|
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(SHD_LOGNAME "SetChannels:"));
|
||||||
for (int i = 0; i < XdrvMailbox.data_len; i++)
|
AddLogBuffer(LOG_LEVEL_DEBUG_MORE, (uint8_t *)XdrvMailbox.data, XdrvMailbox.data_len);
|
||||||
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);
|
|
||||||
#endif // SHELLY_DIMMER_DEBUG
|
#endif // SHELLY_DIMMER_DEBUG
|
||||||
|
|
||||||
uint16_t brightness = ((uint32_t *)XdrvMailbox.data)[0];
|
uint16_t brightness = ((uint32_t *)XdrvMailbox.data)[0];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user