mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-29 05:36:39 +00:00
commit
cfd8239608
4
.github/workflows/Tasmota_build.yml
vendored
4
.github/workflows/Tasmota_build.yml
vendored
@ -13,7 +13,7 @@ jobs:
|
|||||||
- name: Use latest Tasmota development
|
- name: Use latest Tasmota development
|
||||||
run: |
|
run: |
|
||||||
git config --local user.name "Platformio BUILD"
|
git config --local user.name "Platformio BUILD"
|
||||||
git switch -c master
|
git switch -c work
|
||||||
git remote add -f Tasmota "https://github.com/arendst/Tasmota.git"
|
git remote add -f Tasmota "https://github.com/arendst/Tasmota.git"
|
||||||
git merge Tasmota/development --allow-unrelated-histories
|
git merge Tasmota/development --allow-unrelated-histories
|
||||||
- name: Push Tasmota # Push updates of latest Tasmota development to repo
|
- name: Push Tasmota # Push updates of latest Tasmota development to repo
|
||||||
@ -1531,6 +1531,8 @@ jobs:
|
|||||||
[ ! -f ./mv_firmware/tasmota32-knx.* ] || mv ./mv_firmware/tasmota32-knx.* ./firmware/tasmota32/
|
[ ! -f ./mv_firmware/tasmota32-knx.* ] || mv ./mv_firmware/tasmota32-knx.* ./firmware/tasmota32/
|
||||||
[ ! -f ./mv_firmware/tasmota32* ] || mv ./mv_firmware/tasmota32* ./firmware/tasmota32/languages/
|
[ ! -f ./mv_firmware/tasmota32* ] || mv ./mv_firmware/tasmota32* ./firmware/tasmota32/languages/
|
||||||
[ ! -f ./mv_firmware/* ] || mv ./mv_firmware/* ./firmware/tasmota/languages/
|
[ ! -f ./mv_firmware/* ] || mv ./mv_firmware/* ./firmware/tasmota/languages/
|
||||||
|
rm ./firmware/tasmota32/*.gz
|
||||||
|
rm ./firmware/tasmota32/languages/*.gz
|
||||||
[ ! -f ./tools/Esptool/ESP32/*.* ] || mv ./tools/Esptool/ESP32/*.* ./firmware/tasmota32/ESP32_needed_files/
|
[ ! -f ./tools/Esptool/ESP32/*.* ] || mv ./tools/Esptool/ESP32/*.* ./firmware/tasmota32/ESP32_needed_files/
|
||||||
[ ! -f ./FIRMWARE.md ] || mv -f ./FIRMWARE.md ./README.md
|
[ ! -f ./FIRMWARE.md ] || mv -f ./FIRMWARE.md ./README.md
|
||||||
- name: Commit files # transfer the new binaries back into the repository
|
- name: Commit files # transfer the new binaries back into the repository
|
||||||
|
1550
.github/workflows/Tasmota_build_master.yml
vendored
Normal file
1550
.github/workflows/Tasmota_build_master.yml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
@ -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}";
|
const char HTTP_SNS_MILLILITERS[] PROGMEM = "{s}%s " D_VOLUME "{m}%s " D_UNIT_MILLILITERS "{e}";
|
||||||
#endif // USE_WEBSERVER
|
#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_
|
#endif // _I18N_H_
|
||||||
|
@ -1896,25 +1896,34 @@ void SetSyslog(uint32_t loglevel)
|
|||||||
TasmotaGlobal.syslog_timer = 0;
|
TasmotaGlobal.syslog_timer = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Syslog(void)
|
void SyslogAsync(bool refresh) {
|
||||||
{
|
|
||||||
static IPAddress syslog_host_addr; // Syslog host IP address
|
static IPAddress syslog_host_addr; // Syslog host IP address
|
||||||
static uint32_t syslog_host_hash = 0; // Syslog host name hash
|
static uint32_t syslog_host_hash = 0; // Syslog host name hash
|
||||||
|
static uint32_t index = 1;
|
||||||
|
|
||||||
// Destroys TasmotaGlobal.log_data
|
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: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) {
|
||||||
uint32_t current_hash = GetHash(SettingsText(SET_SYSLOG_HOST), strlen(SettingsText(SET_SYSLOG_HOST)));
|
uint32_t current_hash = GetHash(SettingsText(SET_SYSLOG_HOST), strlen(SettingsText(SET_SYSLOG_HOST)));
|
||||||
if (syslog_host_hash != current_hash) {
|
if (syslog_host_hash != current_hash) {
|
||||||
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
|
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)) {
|
if (PortUdp.beginPacket(syslog_host_addr, Settings.syslog_port)) {
|
||||||
char syslog_preamble[64]; // Hostname + Id
|
char log_data[len +72]; // Hostname + Id + log data
|
||||||
snprintf_P(syslog_preamble, sizeof(syslog_preamble), PSTR("%s ESP-"), NetworkHostname());
|
snprintf_P(log_data, sizeof(log_data), PSTR("%s ESP-"), NetworkHostname());
|
||||||
memmove(TasmotaGlobal.log_data + strlen(syslog_preamble), TasmotaGlobal.log_data, sizeof(TasmotaGlobal.log_data) - strlen(syslog_preamble));
|
uint32_t preamble_len = strlen(log_data);
|
||||||
TasmotaGlobal.log_data[sizeof(TasmotaGlobal.log_data) -1] = '\0';
|
len -= mxtime;
|
||||||
memcpy(TasmotaGlobal.log_data, syslog_preamble, strlen(syslog_preamble));
|
strlcpy(log_data +preamble_len, line +mxtime, len);
|
||||||
PortUdp_write(TasmotaGlobal.log_data, strlen(TasmotaGlobal.log_data));
|
// wemos5 ESP-HTP: Web server active on wemos5 with IP address 192.168.2.172
|
||||||
|
PortUdp_write(log_data, preamble_len + len);
|
||||||
PortUdp.endPacket();
|
PortUdp.endPacket();
|
||||||
delay(1); // Add time for UDP handling (#5512)
|
delay(1); // Add time for UDP handling (#5512)
|
||||||
} else {
|
} else {
|
||||||
@ -1923,22 +1932,6 @@ void Syslog(void)
|
|||||||
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION D_SYSLOG_HOST_NOT_FOUND ". " D_RETRY_IN " %d " D_UNIT_SECOND), 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 (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)
|
|
||||||
uint32_t mxtime = strchr(line, ' ') - line +1; // Remove mxtime
|
|
||||||
if (mxtime > 0) {
|
|
||||||
strlcpy(TasmotaGlobal.log_data, line +mxtime, len -mxtime);
|
|
||||||
Syslog();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1994,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 "
|
||||||
@ -2002,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;
|
||||||
@ -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
|
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
|
||||||
@ -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
|
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_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), ' '));
|
||||||
}
|
}
|
||||||
@ -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) {
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************************************\
|
/*********************************************************************************************\
|
||||||
|
@ -245,7 +245,7 @@ void CommandHandler(char* topicBuf, char* dataBuf, uint32_t data_len)
|
|||||||
DEBUG_CORE_LOG(PSTR("CMD: Payload %d"), payload);
|
DEBUG_CORE_LOG(PSTR("CMD: Payload %d"), payload);
|
||||||
|
|
||||||
// TasmotaGlobal.backlog_timer = millis() + (100 * MIN_BACKLOG_DELAY);
|
// 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 };
|
char command[CMDSZ] = { 0 };
|
||||||
XdrvMailbox.command = command;
|
XdrvMailbox.command = command;
|
||||||
@ -1188,7 +1188,7 @@ void CmndGpio(void)
|
|||||||
}
|
}
|
||||||
char stemp1[TOPSZ];
|
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)) {
|
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);
|
MqttPublishPrefixTopic_P(RESULT_OR_STAT, XdrvMailbox.command);
|
||||||
jsflg2 = true;
|
jsflg2 = true;
|
||||||
jsflg = false;
|
jsflg = false;
|
||||||
|
@ -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
|
||||||
|
@ -170,7 +170,6 @@ struct {
|
|||||||
char mqtt_client[99]; // Composed MQTT Clientname
|
char mqtt_client[99]; // Composed MQTT Clientname
|
||||||
char mqtt_topic[TOPSZ]; // Composed MQTT topic
|
char mqtt_topic[TOPSZ]; // Composed MQTT topic
|
||||||
char mqtt_data[MESSZ]; // MQTT publish buffer and web page ajax buffer
|
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
|
char log_buffer[LOG_BUFFER_SIZE]; // Web log buffer
|
||||||
} TasmotaGlobal;
|
} TasmotaGlobal;
|
||||||
|
|
||||||
@ -320,8 +319,6 @@ void setup(void) {
|
|||||||
AddLog_P(LOG_LEVEL_INFO, PSTR(D_WARNING_MINIMAL_VERSION));
|
AddLog_P(LOG_LEVEL_INFO, PSTR(D_WARNING_MINIMAL_VERSION));
|
||||||
#endif // FIRMWARE_MINIMAL
|
#endif // FIRMWARE_MINIMAL
|
||||||
|
|
||||||
memcpy_P(TasmotaGlobal.log_data, VERSION_MARKER, 1); // Dummy for compiler saving VERSION_MARKER
|
|
||||||
|
|
||||||
RtcInit();
|
RtcInit();
|
||||||
|
|
||||||
#ifdef USE_ARDUINO_OTA
|
#ifdef USE_ARDUINO_OTA
|
||||||
|
@ -294,7 +294,7 @@ void MqttUnsubscribe(const char *topic)
|
|||||||
void MqttPublishLoggingAsync(bool refresh) {
|
void MqttPublishLoggingAsync(bool refresh) {
|
||||||
static uint32_t index = 1;
|
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; }
|
if (refresh && !NeedLogRefresh(Settings.mqttlog_level, index)) { return; }
|
||||||
|
|
||||||
char* line;
|
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
|
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)
|
||||||
|
@ -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.zigbee_distinct_topics) {
|
||||||
if (Settings.flag4.zb_topic_fname && friendlyName) {
|
char subtopic[TOPSZ];
|
||||||
//Clean special characters and check size of friendly name
|
if (Settings.flag4.zb_topic_fname && friendlyName && strlen(friendlyName)) {
|
||||||
|
// Clean special characters
|
||||||
char stemp[TOPSZ];
|
char stemp[TOPSZ];
|
||||||
strlcpy(stemp, (!strlen(friendlyName)) ? MQTT_TOPIC : friendlyName, sizeof(stemp));
|
strlcpy(stemp, friendlyName, sizeof(stemp));
|
||||||
MakeValidMqtt(0, stemp);
|
MakeValidMqtt(0, stemp);
|
||||||
//Create topic with Prefix3 and cleaned up friendly name
|
snprintf_P(subtopic, sizeof(subtopic), PSTR("%s/%s"), TasmotaGlobal.mqtt_topic, stemp);
|
||||||
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);
|
|
||||||
} else {
|
} else {
|
||||||
char subtopic[16];
|
snprintf_P(subtopic, sizeof(subtopic), PSTR("%s/%04X"), TasmotaGlobal.mqtt_topic, shortaddr);
|
||||||
snprintf_P(subtopic, sizeof(subtopic), PSTR("%04X/" D_RSLT_SENSOR), shortaddr);
|
|
||||||
MqttPublishPrefixTopic_P(TELE, subtopic, Settings.flag.mqtt_sensor_retain);
|
|
||||||
}
|
}
|
||||||
|
char stopic[TOPSZ];
|
||||||
|
GetTopic_P(stopic, TELE, subtopic, D_RSLT_SENSOR);
|
||||||
|
MqttPublish(stopic, Settings.flag.mqtt_sensor_retain);
|
||||||
} else {
|
} else {
|
||||||
MqttPublishPrefixTopic_P(TELE, PSTR(D_RSLT_SENSOR), Settings.flag.mqtt_sensor_retain);
|
MqttPublishPrefixTopic_P(TELE, PSTR(D_RSLT_SENSOR), Settings.flag.mqtt_sensor_retain);
|
||||||
}
|
}
|
||||||
|
@ -725,15 +725,19 @@ public:
|
|||||||
char hex_char[_payload.len()*2+2];
|
char hex_char[_payload.len()*2+2];
|
||||||
ToHex_P((unsigned char*)_payload.getBuffer(), _payload.len(), hex_char, sizeof(hex_char));
|
ToHex_P((unsigned char*)_payload.getBuffer(), _payload.len(), hex_char, sizeof(hex_char));
|
||||||
Response_P(PSTR("{\"" D_JSON_ZIGBEEZCL_RECEIVED "\":{"
|
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,"
|
"\"srcendpoint\":%d," "\"dstendpoint\":%d," "\"wasbroadcast\":%d,"
|
||||||
"\"" D_CMND_ZIGBEE_LINKQUALITY "\":%d," "\"securityuse\":%d," "\"seqnumber\":%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\"}}"),
|
"\"cmdid\":\"0x%02X\",\"payload\":\"%s\"}}"),
|
||||||
_groupaddr, _cluster_id, _srcaddr,
|
_groupaddr, _cluster_id, _srcaddr,
|
||||||
_srcendpoint, _dstendpoint, _wasbroadcast,
|
_srcendpoint, _dstendpoint, _wasbroadcast,
|
||||||
_linkquality, _securityuse, _seqnumber,
|
_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);
|
hex_char);
|
||||||
if (Settings.flag3.tuya_serial_mqtt_publish) {
|
if (Settings.flag3.tuya_serial_mqtt_publish) {
|
||||||
MqttPublishPrefixTopicRulesProcess_P(TELE, PSTR(D_RSLT_SENSOR));
|
MqttPublishPrefixTopicRulesProcess_P(TELE, PSTR(D_RSLT_SENSOR));
|
||||||
|
@ -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];
|
||||||
|
@ -55,8 +55,8 @@
|
|||||||
|
|
||||||
#define FTC532_KEYS_MAX 8
|
#define FTC532_KEYS_MAX 8
|
||||||
|
|
||||||
#define FTC532_STATE_WAITING 0x01
|
#define FTC532_STATE_WAITING false
|
||||||
#define FTC532_STATE_READING 0x02
|
#define FTC532_STATE_READING true
|
||||||
|
|
||||||
// Rising edge timing in microseconds
|
// Rising edge timing in microseconds
|
||||||
#define FTC532_BIT 377
|
#define FTC532_BIT 377
|
||||||
@ -67,14 +67,16 @@
|
|||||||
|
|
||||||
struct FTC532 {
|
struct FTC532 {
|
||||||
volatile uint32_t rxtime; // ISR timer memory
|
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 sample = 0xF0F0; // buffer for bit-coded time samples
|
||||||
volatile uint16_t rxbit; // ISR bit counter
|
volatile uint16_t rxbit; // ISR bit counter
|
||||||
uint16_t keys = 0; // bitmap of active keys
|
uint8_t keys = 0; // bitmap of active keys
|
||||||
uint16_t old_keys = 0; // previously active keys
|
uint8_t old_keys = 0; // previously active keys
|
||||||
volatile uint8_t state; // ISR state
|
volatile bool state; // ISR state
|
||||||
volatile uint8_t valid; // did we ever receive valid data?
|
|
||||||
bool present = false;
|
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;
|
} Ftc532;
|
||||||
|
|
||||||
const char ftc532_json[] PROGMEM = "\"FTC532\":{\"KEYS\":\"";
|
const char ftc532_json[] PROGMEM = "\"FTC532\":{\"KEYS\":\"";
|
||||||
@ -92,7 +94,9 @@ void ICACHE_RAM_ATTR ftc532_ISR(void) { // Hardware interrupt routine, trigger
|
|||||||
return;
|
return;
|
||||||
} // FTC532_STATE_READING starts here
|
} // FTC532_STATE_READING starts here
|
||||||
if (time_diff > FTC532_LONG + FTC532_BIT) {
|
if (time_diff > FTC532_LONG + FTC532_BIT) {
|
||||||
|
#ifdef DEBUG_TASMOTA_DRIVER
|
||||||
++Ftc532.errors; // frame error
|
++Ftc532.errors; // frame error
|
||||||
|
#endif // DEBUG_TASMOTA_DRIVER
|
||||||
Ftc532.state = FTC532_STATE_WAITING;
|
Ftc532.state = FTC532_STATE_WAITING;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -104,16 +108,19 @@ void ICACHE_RAM_ATTR ftc532_ISR(void) { // Hardware interrupt routine, trigger
|
|||||||
++Ftc532.rxbit;
|
++Ftc532.rxbit;
|
||||||
if (Ftc532.rxbit == FTC532_KEYS_MAX * 2) { // frame complete
|
if (Ftc532.rxbit == FTC532_KEYS_MAX * 2) { // frame complete
|
||||||
Ftc532.rxbit = 0;
|
Ftc532.rxbit = 0;
|
||||||
Ftc532.valid = 1;
|
#ifdef DEBUG_TASMOTA_DRIVER
|
||||||
|
Ftc532.valid = true;
|
||||||
|
#endif // DEBUG_TASMOTA_DRIVER
|
||||||
Ftc532.state = FTC532_STATE_WAITING;
|
Ftc532.state = FTC532_STATE_WAITING;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ftc532_init(void) { // Initialize
|
void ftc532_init(void) { // Initialize
|
||||||
if (!PinUsed(GPIO_FTC532)) { return; }
|
if (!PinUsed(GPIO_FTC532)) { return; }
|
||||||
|
#ifdef DEBUG_TASMOTA_DRIVER
|
||||||
Ftc532.errors = 0;
|
Ftc532.errors = 0;
|
||||||
Ftc532.valid = 0;
|
Ftc532.valid = false;
|
||||||
|
#endif // DEBUG_TASMOTA_DRIVER
|
||||||
Ftc532.state = FTC532_STATE_WAITING;
|
Ftc532.state = FTC532_STATE_WAITING;
|
||||||
Ftc532.rxtime = micros();
|
Ftc532.rxtime = micros();
|
||||||
pinMode(Pin(GPIO_FTC532), INPUT_PULLUP);
|
pinMode(Pin(GPIO_FTC532), INPUT_PULLUP);
|
||||||
@ -122,15 +129,19 @@ void ftc532_init(void) { // Initialize
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ftc532_update(void) { // Usually called every 50 ms
|
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)) {
|
// 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);
|
// 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);
|
Ftc532.keys = (Ftc532.sample & 0xF) | ((Ftc532.sample >> 4) & 0xF0);
|
||||||
if (Ftc532.keys != Ftc532.old_keys) {
|
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"),
|
#ifdef DEBUG_TASMOTA_DRIVER
|
||||||
// Ftc532.sample, Ftc532.keys, Ftc532.old_keys, Ftc532.errors, Ftc532.valid, Ftc532.rxtime, Pin(GPIO_FTC532));
|
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_publish();
|
||||||
Ftc532.old_keys = Ftc532.keys;
|
Ftc532.old_keys = Ftc532.keys;
|
||||||
}
|
}
|
||||||
|
@ -222,7 +222,7 @@ void DebugFreeMem(void)
|
|||||||
void DebugRtcDump(char* parms)
|
void DebugRtcDump(char* parms)
|
||||||
{
|
{
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
#define CFG_COLS 16
|
uint32_t CFG_COLS = 16;
|
||||||
|
|
||||||
uint16_t idx;
|
uint16_t idx;
|
||||||
uint16_t maxrow;
|
uint16_t maxrow;
|
||||||
@ -258,24 +258,25 @@ void DebugRtcDump(char* parms)
|
|||||||
maxrow = srow + mrow;
|
maxrow = srow + mrow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char log_data[LOGSZ];
|
||||||
for (row = srow; row < maxrow; row++) {
|
for (row = srow; row < maxrow; row++) {
|
||||||
idx = row * CFG_COLS;
|
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++) {
|
for (col = 0; col < CFG_COLS; col++) {
|
||||||
if (!(col%4)) {
|
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++) {
|
for (col = 0; col < CFG_COLS; col++) {
|
||||||
// if (!(col%4)) {
|
// 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);
|
snprintf_P(log_data, sizeof(log_data), PSTR("%s|"), log_data);
|
||||||
AddLog(LOG_LEVEL_INFO);
|
AddLogData(LOG_LEVEL_INFO, log_data);
|
||||||
}
|
}
|
||||||
#endif // ESP8266
|
#endif // ESP8266
|
||||||
}
|
}
|
||||||
@ -309,34 +310,32 @@ void DebugDump(uint32_t start, uint32_t size) {
|
|||||||
maxrow = srow + mrow;
|
maxrow = srow + mrow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char log_data[LOGSZ];
|
||||||
for (row = srow; row < maxrow; row++) {
|
for (row = srow; row < maxrow; row++) {
|
||||||
idx = row * CFG_COLS;
|
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++) {
|
for (col = 0; col < CFG_COLS; col++) {
|
||||||
if (!(col%4)) {
|
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++) {
|
for (col = 0; col < CFG_COLS; col++) {
|
||||||
// if (!(col%4)) {
|
// 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);
|
snprintf_P(log_data, sizeof(log_data), PSTR("%s|"), log_data);
|
||||||
AddLog(LOG_LEVEL_INFO);
|
AddLogData(LOG_LEVEL_INFO, log_data);
|
||||||
delay(1);
|
delay(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void DebugCfgDump(char* parms)
|
void DebugCfgDump(char* parms)
|
||||||
{
|
{
|
||||||
#define CFG_COLS 16
|
uint32_t CFG_COLS = 16;
|
||||||
|
|
||||||
uint16_t idx;
|
uint16_t idx;
|
||||||
uint16_t maxrow;
|
uint16_t maxrow;
|
||||||
@ -362,24 +361,25 @@ void DebugCfgDump(char* parms)
|
|||||||
maxrow = srow + mrow;
|
maxrow = srow + mrow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char log_data[LOGSZ];
|
||||||
for (row = srow; row < maxrow; row++) {
|
for (row = srow; row < maxrow; row++) {
|
||||||
idx = row * CFG_COLS;
|
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++) {
|
for (col = 0; col < CFG_COLS; col++) {
|
||||||
if (!(col%4)) {
|
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++) {
|
for (col = 0; col < CFG_COLS; col++) {
|
||||||
// if (!(col%4)) {
|
// 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);
|
snprintf_P(log_data, sizeof(log_data), PSTR("%s|"), log_data);
|
||||||
AddLog(LOG_LEVEL_INFO);
|
AddLogData(LOG_LEVEL_INFO, log_data);
|
||||||
delay(1);
|
delay(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -397,16 +397,17 @@ void DebugCfgPeek(char* parms)
|
|||||||
uint16_t data16 = (buffer[address +1] << 8) + buffer[address];
|
uint16_t data16 = (buffer[address +1] << 8) + buffer[address];
|
||||||
uint32_t data32 = (buffer[address +3] << 24) + (buffer[address +2] << 16) + data16;
|
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++) {
|
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++) {
|
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);
|
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);
|
||||||
AddLog(LOG_LEVEL_INFO);
|
AddLogData(LOG_LEVEL_INFO, log_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebugCfgPoke(char* parms)
|
void DebugCfgPoke(char* parms)
|
||||||
|
@ -824,37 +824,38 @@ void Dump2log(void) {
|
|||||||
int16_t index=0,hcnt=0;
|
int16_t index=0,hcnt=0;
|
||||||
uint32_t d_lastms;
|
uint32_t d_lastms;
|
||||||
uint8_t dchars[16];
|
uint8_t dchars[16];
|
||||||
|
char log_data[LOGSZ]; // May be a lot smaller...
|
||||||
|
|
||||||
//if (!SML_SAVAILABLE) return;
|
//if (!SML_SAVAILABLE) return;
|
||||||
|
|
||||||
if (dump2log&8) {
|
if (dump2log&8) {
|
||||||
// combo mode
|
// combo mode
|
||||||
while (SML_SAVAILABLE) {
|
while (SML_SAVAILABLE) {
|
||||||
TasmotaGlobal.log_data[index]=':';
|
log_data[index]=':';
|
||||||
index++;
|
index++;
|
||||||
TasmotaGlobal.log_data[index]=' ';
|
log_data[index]=' ';
|
||||||
index++;
|
index++;
|
||||||
d_lastms=millis();
|
d_lastms=millis();
|
||||||
while ((millis()-d_lastms)<40) {
|
while ((millis()-d_lastms)<40) {
|
||||||
if (SML_SAVAILABLE) {
|
if (SML_SAVAILABLE) {
|
||||||
uint8_t c=SML_SREAD;
|
uint8_t c=SML_SREAD;
|
||||||
sprintf(&TasmotaGlobal.log_data[index],"%02x ",c);
|
sprintf(&log_data[index],"%02x ",c);
|
||||||
dchars[hcnt]=c;
|
dchars[hcnt]=c;
|
||||||
index+=3;
|
index+=3;
|
||||||
hcnt++;
|
hcnt++;
|
||||||
if (hcnt>15) {
|
if (hcnt>15) {
|
||||||
// line complete, build asci chars
|
// line complete, build asci chars
|
||||||
TasmotaGlobal.log_data[index]='=';
|
log_data[index]='=';
|
||||||
index++;
|
index++;
|
||||||
TasmotaGlobal.log_data[index]='>';
|
log_data[index]='>';
|
||||||
index++;
|
index++;
|
||||||
TasmotaGlobal.log_data[index]=' ';
|
log_data[index]=' ';
|
||||||
index++;
|
index++;
|
||||||
for (uint8_t ccnt=0; ccnt<16; ccnt++) {
|
for (uint8_t ccnt=0; ccnt<16; ccnt++) {
|
||||||
if (isprint(dchars[ccnt])) {
|
if (isprint(dchars[ccnt])) {
|
||||||
TasmotaGlobal.log_data[index]=dchars[ccnt];
|
log_data[index]=dchars[ccnt];
|
||||||
} else {
|
} else {
|
||||||
TasmotaGlobal.log_data[index]=' ';
|
log_data[index]=' ';
|
||||||
}
|
}
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
@ -863,8 +864,8 @@ uint8_t dchars[16];
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (index>0) {
|
if (index>0) {
|
||||||
TasmotaGlobal.log_data[index]=0;
|
log_data[index]=0;
|
||||||
AddLog(LOG_LEVEL_INFO);
|
AddLogData(LOG_LEVEL_INFO, log_data);
|
||||||
index=0;
|
index=0;
|
||||||
hcnt=0;
|
hcnt=0;
|
||||||
}
|
}
|
||||||
@ -875,24 +876,24 @@ uint8_t dchars[16];
|
|||||||
while (SML_SAVAILABLE) {
|
while (SML_SAVAILABLE) {
|
||||||
char c=SML_SREAD&0x7f;
|
char c=SML_SREAD&0x7f;
|
||||||
if (c=='\n' || c=='\r') {
|
if (c=='\n' || c=='\r') {
|
||||||
TasmotaGlobal.log_data[sml_logindex]=0;
|
log_data[sml_logindex]=0;
|
||||||
AddLog(LOG_LEVEL_INFO);
|
AddLog(LOG_LEVEL_INFO);
|
||||||
sml_logindex=2;
|
sml_logindex=2;
|
||||||
TasmotaGlobal.log_data[0]=':';
|
log_data[0]=':';
|
||||||
TasmotaGlobal.log_data[1]=' ';
|
log_data[1]=' ';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
TasmotaGlobal.log_data[sml_logindex]=c;
|
log_data[sml_logindex]=c;
|
||||||
if (sml_logindex<sizeof(TasmotaGlobal.log_data)-2) {
|
if (sml_logindex<sizeof(log_data)-2) {
|
||||||
sml_logindex++;
|
sml_logindex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//while (SML_SAVAILABLE) {
|
//while (SML_SAVAILABLE) {
|
||||||
index=0;
|
index=0;
|
||||||
TasmotaGlobal.log_data[index]=':';
|
log_data[index]=':';
|
||||||
index++;
|
index++;
|
||||||
TasmotaGlobal.log_data[index]=' ';
|
log_data[index]=' ';
|
||||||
index++;
|
index++;
|
||||||
d_lastms=millis();
|
d_lastms=millis();
|
||||||
while ((millis()-d_lastms)<40) {
|
while ((millis()-d_lastms)<40) {
|
||||||
@ -901,7 +902,7 @@ uint8_t dchars[16];
|
|||||||
if (meter_desc_p[(dump2log&7)-1].type=='e') {
|
if (meter_desc_p[(dump2log&7)-1].type=='e') {
|
||||||
// ebus
|
// ebus
|
||||||
c=SML_SREAD;
|
c=SML_SREAD;
|
||||||
sprintf(&TasmotaGlobal.log_data[index],"%02x ",c);
|
sprintf(&log_data[index],"%02x ",c);
|
||||||
index+=3;
|
index+=3;
|
||||||
if (c==EBUS_SYNC) break;
|
if (c==EBUS_SYNC) break;
|
||||||
} else {
|
} else {
|
||||||
@ -916,14 +917,14 @@ uint8_t dchars[16];
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
c=SML_SREAD;
|
c=SML_SREAD;
|
||||||
sprintf(&TasmotaGlobal.log_data[index],"%02x ",c);
|
sprintf(&log_data[index],"%02x ",c);
|
||||||
index+=3;
|
index+=3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (index>2) {
|
if (index>2) {
|
||||||
TasmotaGlobal.log_data[index]=0;
|
log_data[index]=0;
|
||||||
AddLog(LOG_LEVEL_INFO);
|
AddLogData(LOG_LEVEL_INFO, log_data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user