diff --git a/tasmota/sendemail_ESP32.ino b/tasmota/sendemail_ESP32.ino index b518d537f..d7f8a2b4a 100644 --- a/tasmota/sendemail_ESP32.ino +++ b/tasmota/sendemail_ESP32.ino @@ -151,7 +151,7 @@ uint16_t SendMail(char *buffer) { #endif #ifdef DEBUG_EMAIL_PORT - AddLog_P(LOG_LEVEL_INFO, PSTR("%s - %d - %s - %s"), mserv, port, user, passwd); + AddLog(LOG_LEVEL_INFO, PSTR("%s - %d - %s - %s"), mserv, port, user, passwd); #endif #ifdef EMAIL_FROM @@ -161,7 +161,7 @@ uint16_t SendMail(char *buffer) { #endif #ifdef DEBUG_EMAIL_PORT - AddLog_P(LOG_LEVEL_INFO, PSTR("%s - %s - %s - %s"), from, to, subject, cmd); + AddLog(LOG_LEVEL_INFO, PSTR("%s - %s - %s - %s"), from, to, subject, cmd); #endif diff --git a/tasmota/sendemail_ESP8266.ino b/tasmota/sendemail_ESP8266.ino index f8fb023fd..1b1088776 100644 --- a/tasmota/sendemail_ESP8266.ino +++ b/tasmota/sendemail_ESP8266.ino @@ -162,7 +162,7 @@ uint16_t SendMail(char *buffer) { #endif #ifdef DEBUG_EMAIL_PORT - AddLog_P(LOG_LEVEL_INFO, PSTR("%s - %s - %s - %s"),from,to,subject,cmd); + AddLog(LOG_LEVEL_INFO, PSTR("%s - %s - %s - %s"),from,to,subject,cmd); #endif if (mail) { @@ -217,7 +217,7 @@ String buffer; buffer = readClient(); #ifdef DEBUG_EMAIL_PORT - AddLog_P(LOG_LEVEL_INFO, PSTR("%s"),buffer.c_str()); + AddLog(LOG_LEVEL_INFO, PSTR("%s"),buffer.c_str()); #endif if (!buffer.startsWith(F("220"))) { goto exit; @@ -228,11 +228,11 @@ String buffer; client->println(buffer); #ifdef DEBUG_EMAIL_PORT - AddLog_P(LOG_LEVEL_INFO, PSTR("%s"),buffer.c_str()); + AddLog(LOG_LEVEL_INFO, PSTR("%s"),buffer.c_str()); #endif buffer = readClient(); #ifdef DEBUG_EMAIL_PORT - AddLog_P(LOG_LEVEL_INFO, PSTR("%s"),buffer.c_str()); + AddLog(LOG_LEVEL_INFO, PSTR("%s"),buffer.c_str()); #endif if (!buffer.startsWith(F("250"))) { goto exit; @@ -242,11 +242,11 @@ String buffer; buffer = F("AUTH LOGIN"); client->println(buffer); #ifdef DEBUG_EMAIL_PORT - AddLog_P(LOG_LEVEL_INFO, PSTR("%s"),buffer.c_str()); + AddLog(LOG_LEVEL_INFO, PSTR("%s"),buffer.c_str()); #endif buffer = readClient(); #ifdef DEBUG_EMAIL_PORT - AddLog_P(LOG_LEVEL_INFO, PSTR("%s"),buffer.c_str()); + AddLog(LOG_LEVEL_INFO, PSTR("%s"),buffer.c_str()); #endif if (!buffer.startsWith(F("334"))) { @@ -257,11 +257,11 @@ String buffer; client->println(buffer); #ifdef DEBUG_EMAIL_PORT - AddLog_P(LOG_LEVEL_INFO, PSTR("%s"),buffer.c_str()); + AddLog(LOG_LEVEL_INFO, PSTR("%s"),buffer.c_str()); #endif buffer = readClient(); #ifdef DEBUG_EMAIL_PORT - AddLog_P(LOG_LEVEL_INFO, PSTR("%s"),buffer.c_str()); + AddLog(LOG_LEVEL_INFO, PSTR("%s"),buffer.c_str()); #endif if (!buffer.startsWith(F("334"))) { goto exit; @@ -269,11 +269,11 @@ String buffer; buffer = b.encode(passwd); client->println(buffer); #ifdef DEBUG_EMAIL_PORT - AddLog_P(LOG_LEVEL_INFO, PSTR("%s"),buffer.c_str()); + AddLog(LOG_LEVEL_INFO, PSTR("%s"),buffer.c_str()); #endif buffer = readClient(); #ifdef DEBUG_EMAIL_PORT - AddLog_P(LOG_LEVEL_INFO, PSTR("%s"),buffer.c_str()); + AddLog(LOG_LEVEL_INFO, PSTR("%s"),buffer.c_str()); #endif if (!buffer.startsWith(F("235"))) { goto exit; @@ -285,11 +285,11 @@ String buffer; buffer += from; client->println(buffer); #ifdef DEBUG_EMAIL_PORT - AddLog_P(LOG_LEVEL_INFO, PSTR("%s"),buffer.c_str()); + AddLog(LOG_LEVEL_INFO, PSTR("%s"),buffer.c_str()); #endif buffer = readClient(); #ifdef DEBUG_EMAIL_PORT - AddLog_P(LOG_LEVEL_INFO, PSTR("%s"),buffer.c_str()); + AddLog(LOG_LEVEL_INFO, PSTR("%s"),buffer.c_str()); #endif if (!buffer.startsWith(F("250"))) { goto exit; @@ -298,11 +298,11 @@ String buffer; buffer += to; client->println(buffer); #ifdef DEBUG_EMAIL_PORT - AddLog_P(LOG_LEVEL_INFO, PSTR("%s"),buffer.c_str()); + AddLog(LOG_LEVEL_INFO, PSTR("%s"),buffer.c_str()); #endif buffer = readClient(); #ifdef DEBUG_EMAIL_PORT - AddLog_P(LOG_LEVEL_INFO, PSTR("%s"),buffer.c_str()); + AddLog(LOG_LEVEL_INFO, PSTR("%s"),buffer.c_str()); #endif if (!buffer.startsWith(F("250"))) { goto exit; @@ -311,11 +311,11 @@ String buffer; buffer = F("DATA"); client->println(buffer); #ifdef DEBUG_EMAIL_PORT - AddLog_P(LOG_LEVEL_INFO, PSTR("%s"),buffer.c_str()); + AddLog(LOG_LEVEL_INFO, PSTR("%s"),buffer.c_str()); #endif buffer = readClient(); #ifdef DEBUG_EMAIL_PORT - AddLog_P(LOG_LEVEL_INFO, PSTR("%s"),buffer.c_str()); + AddLog(LOG_LEVEL_INFO, PSTR("%s"),buffer.c_str()); #endif if (!buffer.startsWith(F("354"))) { goto exit; @@ -325,19 +325,19 @@ String buffer; buffer += from; client->println(buffer); #ifdef DEBUG_EMAIL_PORT - AddLog_P(LOG_LEVEL_INFO, PSTR("%s"),buffer.c_str()); + AddLog(LOG_LEVEL_INFO, PSTR("%s"),buffer.c_str()); #endif buffer = F("To: "); buffer += to; client->println(buffer); #ifdef DEBUG_EMAIL_PORT - AddLog_P(LOG_LEVEL_INFO, PSTR("%s"),buffer.c_str()); + AddLog(LOG_LEVEL_INFO, PSTR("%s"),buffer.c_str()); #endif buffer = F("Subject: "); buffer += subject; client->println(buffer); #ifdef DEBUG_EMAIL_PORT - AddLog_P(LOG_LEVEL_INFO, PSTR("%s"),buffer.c_str()); + AddLog(LOG_LEVEL_INFO, PSTR("%s"),buffer.c_str()); #endif #ifdef USE_SCRIPT @@ -359,13 +359,13 @@ String buffer; #endif client->println('.'); #ifdef DEBUG_EMAIL_PORT - AddLog_P(LOG_LEVEL_INFO, PSTR("%s"),buffer.c_str()); + AddLog(LOG_LEVEL_INFO, PSTR("%s"),buffer.c_str()); #endif buffer = F("QUIT"); client->println(buffer); #ifdef DEBUG_EMAIL_PORT - AddLog_P(LOG_LEVEL_INFO, PSTR("%s"),buffer.c_str()); + AddLog(LOG_LEVEL_INFO, PSTR("%s"),buffer.c_str()); #endif status=true; @@ -378,7 +378,7 @@ exit: void xsend_message_txt(char *msg) { #ifdef DEBUG_EMAIL_PORT - AddLog_P(LOG_LEVEL_INFO, PSTR("%s"),msg); + AddLog(LOG_LEVEL_INFO, PSTR("%s"),msg); #endif #ifdef USE_UFILESYS diff --git a/tasmota/support.ino b/tasmota/support.ino index 8abb5d644..ccf3bdf8d 100644 --- a/tasmota/support.ino +++ b/tasmota/support.ino @@ -1608,7 +1608,7 @@ bool JsonTemplate(char* dataBuf) // Old: {"NAME":"Shelly 2.5","GPIO":[56,0,17,0,21,83,0,0,6,82,5,22,156],"FLAG":2,"BASE":18} // New: {"NAME":"Shelly 2.5","GPIO":[320,0,32,0,224,193,0,0,640,192,608,225,3456,4736],"FLAG":0,"BASE":18} -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("TPL: |%s|"), dataBuf); +// AddLog(LOG_LEVEL_DEBUG, PSTR("TPL: |%s|"), dataBuf); if (strlen(dataBuf) < 9) { return false; } // Workaround exception if empty JSON like {} - Needs checks @@ -2343,55 +2343,20 @@ void AddLogData(uint32_t loglevel, const char* log_data) { } void AddLog(uint32_t loglevel, PGM_P formatP, ...) { - // To save stack space support logging for max text length of 128 characters - char log_data[LOGSZ +4]; - va_list arg; va_start(arg, formatP); - uint32_t len = ext_vsnprintf_P(log_data, LOGSZ +1, formatP, arg); + char* log_data = ext_vsnprintf_malloc_P(formatP, arg); va_end(arg); - if (len > LOGSZ) { strcat(log_data, "..."); } // Actual data is more - -#ifdef DEBUG_TASMOTA_CORE - // Profile max_len - static uint32_t max_len = 0; - if (len > max_len) { - max_len = len; - Serial.printf("PRF: AddLog %d\n", max_len); - } -#endif + if (log_data == nullptr) { return; } AddLogData(loglevel, log_data); -} - -void AddLog_P(uint32_t loglevel, PGM_P formatP, ...) { - // Use more stack space to support logging for max text length of 700 characters - char log_data[MAX_LOGSZ]; - - va_list arg; - va_start(arg, formatP); - uint32_t len = ext_vsnprintf_P(log_data, sizeof(log_data), formatP, arg); - va_end(arg); - - AddLogData(loglevel, log_data); -} - -void AddLog_Debug(PGM_P formatP, ...) -{ - char log_data[MAX_LOGSZ]; - - va_list arg; - va_start(arg, formatP); - uint32_t len = ext_vsnprintf_P(log_data, sizeof(log_data), formatP, arg); - va_end(arg); - - AddLogData(LOG_LEVEL_DEBUG, log_data); + free(log_data); } void AddLogBuffer(uint32_t loglevel, uint8_t *buffer, uint32_t count) { char hex_char[(count * 3) + 2]; - AddLog_P(loglevel, PSTR("DMP: %s"), ToHex_P(buffer, count, hex_char, sizeof(hex_char), ' ')); + AddLog(loglevel, PSTR("DMP: %s"), ToHex_P(buffer, count, hex_char, sizeof(hex_char), ' ')); } void AddLogSerial(uint32_t loglevel) diff --git a/tasmota/support_command.ino b/tasmota/support_command.ino index e8bca9f73..d36d44c6d 100644 --- a/tasmota/support_command.ino +++ b/tasmota/support_command.ino @@ -240,7 +240,7 @@ void CommandHandler(char* topicBuf, char* dataBuf, uint32_t data_len) } } - AddLog_P(LOG_LEVEL_DEBUG, PSTR("CMD: Grp %d, Cmnd '%s', Idx %d, Len %d, Data '%s'"), + AddLog(LOG_LEVEL_DEBUG, PSTR("CMD: Grp %d, Cmnd '%s', Idx %d, Len %d, Data '%s'"), grpflg, type, index, data_len, (binary_data) ? HexToString((uint8_t*)dataBuf, data_len).c_str() : dataBuf); if (type != nullptr) { diff --git a/tasmota/support_tasmota.ino b/tasmota/support_tasmota.ino index d439fe0a2..b01d87ff4 100644 --- a/tasmota/support_tasmota.ino +++ b/tasmota/support_tasmota.ino @@ -1554,7 +1554,7 @@ void SerialInput(void) if (serial_buffer_overrun) { AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_COMMAND "Serial buffer overrun")); } else { - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_COMMAND "%s"), TasmotaGlobal.serial_in_buffer); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_COMMAND "%s"), TasmotaGlobal.serial_in_buffer); ExecuteCommand(TasmotaGlobal.serial_in_buffer, SRC_SERIAL); } TasmotaGlobal.serial_in_byte_counter = 0; diff --git a/tasmota/support_udp.ino b/tasmota/support_udp.ino index 544bbe5a1..a3cb53a1a 100644 --- a/tasmota/support_udp.ino +++ b/tasmota/support_udp.ino @@ -132,7 +132,7 @@ void PollUdp(void) AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("UDP: Packet (%d/%d)"), len, pack_len); #endif // ESP32 - // AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("\n%s"), packet_buffer); + // AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("\n%s"), packet_buffer); // Simple Service Discovery Protocol (SSDP) if (Settings.flag2.emulation) { @@ -151,7 +151,7 @@ void PollUdp(void) udp_remote_port = PortUdp.remotePort(); #endif - // AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("UDP: M-SEARCH Packet from %_I:%d\n%s"), + // AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("UDP: M-SEARCH Packet from %_I:%d\n%s"), // (uint32_t)udp_remote_ip, udp_remote_port, packet_buffer); LowerCase(packet_buffer, packet_buffer); diff --git a/tasmota/tasmota_globals.h b/tasmota/tasmota_globals.h index e451563c8..60e4b3f80 100644 --- a/tasmota/tasmota_globals.h +++ b/tasmota/tasmota_globals.h @@ -483,22 +483,22 @@ bool first_device_group_is_local = true; #endif // USE_DEVICE_GROUPS #ifdef DEBUG_TASMOTA_CORE -#define DEBUG_CORE_LOG(...) AddLog_Debug(__VA_ARGS__) +#define DEBUG_CORE_LOG(...) AddLog(LOG_LEVEL_DEBUG, __VA_ARGS__) #else #define DEBUG_CORE_LOG(...) #endif #ifdef DEBUG_TASMOTA_DRIVER -#define DEBUG_DRIVER_LOG(...) AddLog_Debug(__VA_ARGS__) +#define DEBUG_DRIVER_LOG(...) AddLog(LOG_LEVEL_DEBUG, __VA_ARGS__) #else #define DEBUG_DRIVER_LOG(...) #endif #ifdef DEBUG_TASMOTA_SENSOR -#define DEBUG_SENSOR_LOG(...) AddLog_Debug(__VA_ARGS__) +#define DEBUG_SENSOR_LOG(...) AddLog(LOG_LEVEL_DEBUG, __VA_ARGS__) #else #define DEBUG_SENSOR_LOG(...) #endif #ifdef DEBUG_TASMOTA_TRACE -#define DEBUG_TRACE_LOG(...) AddLog_Debug(__VA_ARGS__) +#define DEBUG_TRACE_LOG(...) AddLog(LOG_LEVEL_DEBUG, __VA_ARGS__) #else #define DEBUG_TRACE_LOG(...) #endif diff --git a/tasmota/xdrv_01_webserver.ino b/tasmota/xdrv_01_webserver.ino index 5be1ad5da..64ebf2378 100644 --- a/tasmota/xdrv_01_webserver.ino +++ b/tasmota/xdrv_01_webserver.ino @@ -2881,7 +2881,7 @@ void HandleConsoleRefresh(void) { String svalue = Webserver->arg(F("c1")); if (svalue.length() && (svalue.length() < MQTT_MAX_PACKET_SIZE)) { - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_COMMAND "%s"), svalue.c_str()); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_COMMAND "%s"), svalue.c_str()); ExecuteWebCommand((char*)svalue.c_str(), SRC_WEBCONSOLE); } @@ -3246,11 +3246,11 @@ bool Xdrv01(uint8_t function) } if (Web.wifi_test_counter) { Web.wifi_test_counter--; - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_WIFI D_TRYING_TO_CONNECT " %s"), SettingsText(SET_STASSID1)); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_WIFI D_TRYING_TO_CONNECT " %s"), SettingsText(SET_STASSID1)); if ( WifiCheck_hasIP(WiFi.localIP()) ) { // Got IP - Connection Established Web.wifi_test_counter = 0; Web.wifiTest = WIFI_TEST_FINISHED_SUCCESSFUL; - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_CMND_SSID "1 %s: " D_CONNECTED " - " D_IP_ADDRESS " %_I"), SettingsText(SET_STASSID1), (uint32_t)WiFi.localIP()); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_CMND_SSID "1 %s: " D_CONNECTED " - " D_IP_ADDRESS " %_I"), SettingsText(SET_STASSID1), (uint32_t)WiFi.localIP()); // TasmotaGlobal.blinks = 255; // Signal wifi connection with blinks if (MAX_WIFI_OPTION != Web.old_wificonfig) { TasmotaGlobal.wifi_state_flag = Settings.sta_config = Web.old_wificonfig; diff --git a/tasmota/xdrv_04_light.ino b/tasmota/xdrv_04_light.ino index 27051e00e..3b98e5969 100644 --- a/tasmota/xdrv_04_light.ino +++ b/tasmota/xdrv_04_light.ino @@ -1138,7 +1138,7 @@ void LightInit(void) } LightCalcPWMRange(); #ifdef DEBUG_LIGHT - AddLog_P(LOG_LEVEL_DEBUG_MORE, "LightInit Light.pwm_multi_channels=%d Light.subtype=%d Light.device=%d TasmotaGlobal.devices_present=%d", + AddLog(LOG_LEVEL_DEBUG_MORE, "LightInit Light.pwm_multi_channels=%d Light.subtype=%d Light.device=%d TasmotaGlobal.devices_present=%d", Light.pwm_multi_channels, Light.subtype, Light.device, TasmotaGlobal.devices_present); #endif @@ -1637,7 +1637,7 @@ void LightSetPower(void) Light.wakeup_active--; } #ifdef DEBUG_LIGHT - AddLog_P(LOG_LEVEL_DEBUG_MORE, "LightSetPower XdrvMailbox.index=%d Light.old_power=%d Light.power=%d mask=%d shift=%d", + AddLog(LOG_LEVEL_DEBUG_MORE, "LightSetPower XdrvMailbox.index=%d Light.old_power=%d Light.power=%d mask=%d shift=%d", XdrvMailbox.index, Light.old_power, Light.power, mask, shift); #endif if (Light.power != Light.old_power) { diff --git a/tasmota/xdrv_05_irremote_full.ino b/tasmota/xdrv_05_irremote_full.ino index 293170b66..2bb38abcb 100644 --- a/tasmota/xdrv_05_irremote_full.ino +++ b/tasmota/xdrv_05_irremote_full.ino @@ -381,7 +381,7 @@ uint32_t IrRemoteCmndIrHvacJson(void) { stdAc::state_t state; - //AddLog_P(LOG_LEVEL_DEBUG, PSTR("IRHVAC: Received %s"), XdrvMailbox.data); + //AddLog(LOG_LEVEL_DEBUG, PSTR("IRHVAC: Received %s"), XdrvMailbox.data); JsonParser parser(XdrvMailbox.data); JsonParserObject root = parser.getRootObject(); if (!root) { return IE_INVALID_JSON; } diff --git a/tasmota/xdrv_07_domoticz.ino b/tasmota/xdrv_07_domoticz.ino index 473dab297..157391e66 100644 --- a/tasmota/xdrv_07_domoticz.ino +++ b/tasmota/xdrv_07_domoticz.ino @@ -315,7 +315,7 @@ bool DomoticzMqttData(void) { } if (!found) { return true; } // No command received - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_DOMOTICZ D_RECEIVED_TOPIC " %s, " D_DATA " %s"), XdrvMailbox.topic, XdrvMailbox.data); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_DOMOTICZ D_RECEIVED_TOPIC " %s, " D_DATA " %s"), XdrvMailbox.topic, XdrvMailbox.data); domoticz_update_flag = false; return false; // Process new data diff --git a/tasmota/xdrv_10_rules.ino b/tasmota/xdrv_10_rules.ino index 8f12f9cbb..a0b114f1b 100644 --- a/tasmota/xdrv_10_rules.ino +++ b/tasmota/xdrv_10_rules.ino @@ -434,7 +434,7 @@ bool RulesRuleMatch(uint8_t rule_set, String &event, String &rule, bool stop_all // rule_param = "0.100" or "%VAR1%" #ifdef DEBUG_RULES - AddLog_P(LOG_LEVEL_DEBUG, PSTR("RUL-RM1: Teleperiod %d, Expr %s, Name %s, Param %s"), Rules.teleperiod, rule_expr.c_str(), rule_name.c_str(), rule_param.c_str()); + AddLog(LOG_LEVEL_DEBUG, PSTR("RUL-RM1: Teleperiod %d, Expr %s, Name %s, Param %s"), Rules.teleperiod, rule_expr.c_str(), rule_name.c_str(), rule_param.c_str()); #endif char rule_svalue[80] = { 0 }; @@ -510,13 +510,13 @@ bool RulesRuleMatch(uint8_t rule_set, String &event, String &rule, bool stop_all String buf = event; // Copy the string into a new buffer that will be modified -//AddLog_P(LOG_LEVEL_DEBUG, PSTR("RUL-RM2: RulesRuleMatch |%s|"), buf.c_str()); +//AddLog(LOG_LEVEL_DEBUG, PSTR("RUL-RM2: RulesRuleMatch |%s|"), buf.c_str()); buf.replace("\\"," "); // "Disable" any escaped control character JsonParser parser((char*)buf.c_str()); JsonParserObject obj = parser.getRootObject(); if (!obj) { -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("RUL: Event too long (%d)"), event.length()); +// AddLog(LOG_LEVEL_DEBUG, PSTR("RUL: Event too long (%d)"), event.length()); AddLog(LOG_LEVEL_DEBUG, PSTR("RUL: No valid JSON (%s)"), buf.c_str()); return false; // No valid JSON data } @@ -547,7 +547,7 @@ bool RulesRuleMatch(uint8_t rule_set, String &event, String &rule, bool stop_all } #ifdef DEBUG_RULES - AddLog_P(LOG_LEVEL_DEBUG, PSTR("RUL-RM3: Name %s, Value |%s|, TrigCnt %d, TrigSt %d, Source %s, Json |%s|"), + AddLog(LOG_LEVEL_DEBUG, PSTR("RUL-RM3: Name %s, Value |%s|, TrigCnt %d, TrigSt %d, Source %s, Json |%s|"), rule_name.c_str(), rule_svalue, Rules.trigger_count[rule_set], bitRead(Rules.triggers[rule_set], Rules.trigger_count[rule_set]), event.c_str(), (str_value[0] != '\0') ? str_value : "none"); #endif @@ -608,7 +608,7 @@ bool RulesRuleMatch(uint8_t rule_set, String &event, String &rule, bool stop_all if (stop_all_rules) { match = false; } -//AddLog_P(LOG_LEVEL_DEBUG, PSTR("RUL-RM4: Match 1 %d, Triggers %08X, TriggerCount %d"), match, Rules.triggers[rule_set], Rules.trigger_count[rule_set]); +//AddLog(LOG_LEVEL_DEBUG, PSTR("RUL-RM4: Match 1 %d, Triggers %08X, TriggerCount %d"), match, Rules.triggers[rule_set], Rules.trigger_count[rule_set]); if (bitRead(Settings.rule_once, rule_set)) { if (match) { // Only allow match state changes @@ -622,7 +622,7 @@ bool RulesRuleMatch(uint8_t rule_set, String &event, String &rule, bool stop_all } } -//AddLog_P(LOG_LEVEL_DEBUG, PSTR("RUL-RM5: Match 2 %d, Triggers %08X, TriggerCount %d"), match, Rules.triggers[rule_set], Rules.trigger_count[rule_set]); +//AddLog(LOG_LEVEL_DEBUG, PSTR("RUL-RM5: Match 2 %d, Triggers %08X, TriggerCount %d"), match, Rules.triggers[rule_set], Rules.trigger_count[rule_set]); return match; } @@ -694,7 +694,7 @@ bool RuleSetProcess(uint8_t rule_set, String &event_saved) delay(0); // Prohibit possible loop software watchdog -//AddLog_P(LOG_LEVEL_DEBUG, PSTR("RUL-RP1: Event = %s, Rule = %s"), event_saved.c_str(), Settings.rules[rule_set]); +//AddLog(LOG_LEVEL_DEBUG, PSTR("RUL-RP1: Event = %s, Rule = %s"), event_saved.c_str(), Settings.rules[rule_set]); String rules = GetRule(rule_set); @@ -728,7 +728,7 @@ bool RuleSetProcess(uint8_t rule_set, String &event_saved) String event = event_saved; #ifdef DEBUG_RULES -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("RUL-RP2: Event |%s|, Rule |%s|, Command(s) |%s|"), event.c_str(), event_trigger.c_str(), commands.c_str()); +// AddLog(LOG_LEVEL_DEBUG, PSTR("RUL-RP2: Event |%s|, Rule |%s|, Command(s) |%s|"), event.c_str(), event_trigger.c_str(), commands.c_str()); #endif if (RulesRuleMatch(rule_set, event, event_trigger, stop_all_rules)) { @@ -808,7 +808,7 @@ bool RulesProcessEvent(char *json_event) ShowFreeMem(PSTR("RulesProcessEvent")); #endif -//AddLog_P(LOG_LEVEL_DEBUG, PSTR("RUL: ProcessEvent |%s|"), json_event); +//AddLog(LOG_LEVEL_DEBUG, PSTR("RUL: ProcessEvent |%s|"), json_event); String event_saved = json_event; // json_event = {"INA219":{"Voltage":4.494,"Current":0.020,"Power":0.089}} @@ -822,7 +822,7 @@ bool RulesProcessEvent(char *json_event) } event_saved.toUpperCase(); -//AddLog_P(LOG_LEVEL_DEBUG, PSTR("RUL: Event |%s|"), event_saved.c_str()); +//AddLog(LOG_LEVEL_DEBUG, PSTR("RUL: Event |%s|"), event_saved.c_str()); for (uint32_t i = 0; i < MAX_RULE_SETS; i++) { if (GetRuleLen(i) && bitRead(Settings.rule_enabled, i)) { @@ -1050,13 +1050,13 @@ bool RulesMqttData(void) bool serviced = false; String sTopic = XdrvMailbox.topic; String sData = XdrvMailbox.data; - //AddLog_P(LOG_LEVEL_DEBUG, PSTR("RUL: MQTT Topic %s, Event %s"), XdrvMailbox.topic, XdrvMailbox.data); + //AddLog(LOG_LEVEL_DEBUG, PSTR("RUL: MQTT Topic %s, Event %s"), XdrvMailbox.topic, XdrvMailbox.data); MQTT_Subscription event_item; //Looking for matched topic for (uint32_t index = 0; index < subscriptions.size(); index++) { event_item = subscriptions.get(index); - //AddLog_P(LOG_LEVEL_DEBUG, PSTR("RUL: Match MQTT message Topic %s with subscription topic %s"), sTopic.c_str(), event_item.Topic.c_str()); + //AddLog(LOG_LEVEL_DEBUG, PSTR("RUL: Match MQTT message Topic %s with subscription topic %s"), sTopic.c_str(), event_item.Topic.c_str()); if (sTopic.startsWith(event_item.Topic)) { //This topic is subscribed by us, so serve it serviced = true; @@ -1133,7 +1133,7 @@ void CmndSubscribe(void) } } } - //AddLog_P(LOG_LEVEL_DEBUG, PSTR("RUL: Subscribe command with parameters: %s, %s, %s."), event_name.c_str(), topic.c_str(), key.c_str()); + //AddLog(LOG_LEVEL_DEBUG, PSTR("RUL: Subscribe command with parameters: %s, %s, %s."), event_name.c_str(), topic.c_str(), key.c_str()); event_name.toUpperCase(); if (event_name.length() > 0 && topic.length() > 0) { //Search all subscriptions @@ -1154,7 +1154,7 @@ void CmndSubscribe(void) topic.concat("/#"); } } - //AddLog_P(LOG_LEVEL_DEBUG, PSTR("RUL: New topic: %s."), topic.c_str()); + //AddLog(LOG_LEVEL_DEBUG, PSTR("RUL: New topic: %s."), topic.c_str()); //MQTT Subscribe subscription_item.Event = event_name; subscription_item.Topic = topic.substring(0, topic.length() - 2); //Remove "/#" so easy to match @@ -1753,7 +1753,7 @@ bool evaluateLogicalExpression(const char * expression, int len) memcpy(expbuff, expression, len); expbuff[len] = '\0'; - //AddLog_P(LOG_LEVEL_DEBUG, PSTR("EvalLogic: |%s|"), expbuff); + //AddLog(LOG_LEVEL_DEBUG, PSTR("EvalLogic: |%s|"), expbuff); char * pointer = expbuff; LinkedList values; LinkedList logicOperators; @@ -1879,7 +1879,7 @@ void ExecuteCommandBlock(const char * commands, int len) memcpy(cmdbuff, commands, len); cmdbuff[len] = '\0'; - //AddLog_P(LOG_LEVEL_DEBUG, PSTR("ExecCmd: |%s|"), cmdbuff); + //AddLog(LOG_LEVEL_DEBUG, PSTR("ExecCmd: |%s|"), cmdbuff); char oneCommand[len + 1]; //To put one command int insertPosition = 0; //When insert into backlog, we should do it by 0, 1, 2 ... char * pos = cmdbuff; diff --git a/tasmota/xdrv_10_scripter.ino b/tasmota/xdrv_10_scripter.ino index 7d5f1c074..1fb0341fe 100755 --- a/tasmota/xdrv_10_scripter.ino +++ b/tasmota/xdrv_10_scripter.ino @@ -7788,7 +7788,7 @@ String request; request = String("POST ") + "/api/login/Basic" + " HTTP/1.1\r\n" + "Host: " + host + "\r\n" + cert + "\r\n" + "Content-Type: application/json" + "\r\n"; httpsClient->print(request); - AddLog_P(LOG_LEVEL_INFO,PSTR(">>> post request %s"),(char*)request.c_str()); + AddLog(LOG_LEVEL_INFO,PSTR(">>> post request %s"),(char*)request.c_str()); String line = httpsClient->readStringUntil('\n'); AddLog(LOG_LEVEL_INFO,PSTR(">>> post response 1a %s"),(char*)line.c_str()); @@ -7801,7 +7801,7 @@ String request; "Host: " + host + "\r\n" + "Connection: close\r\n\r\n"; httpsClient->print(request); -// AddLog_P(LOG_LEVEL_INFO,PSTR(">>> get request %s"),(char*)request.c_str()); +// AddLog(LOG_LEVEL_INFO,PSTR(">>> get request %s"),(char*)request.c_str()); while (httpsClient->connected()) { String line = httpsClient->readStringUntil('\n'); diff --git a/tasmota/xdrv_12_home_assistant.ino b/tasmota/xdrv_12_home_assistant.ino index 46bfcf9c1..08db2aaac 100644 --- a/tasmota/xdrv_12_home_assistant.ino +++ b/tasmota/xdrv_12_home_assistant.ino @@ -366,7 +366,7 @@ void TryResponseAppend_P(const char *format, ...) int slen = ResponseSize() - 1 - mlen; if (dlen >= slen) { - AddLog_P(LOG_LEVEL_ERROR, PSTR("%s (%u/%u):"), kHAssError1, dlen, slen); + AddLog(LOG_LEVEL_ERROR, PSTR("%s (%u/%u):"), kHAssError1, dlen, slen); va_start(args, format); char log_data[MAX_LOGSZ]; vsnprintf_P(log_data, sizeof(log_data), format, args); @@ -469,7 +469,7 @@ void HAssAnnounceRelayLight(void) // suppress shutter relays } else if ((i < Light.device) && !RelayX) { err_flag = true; - AddLog_P(LOG_LEVEL_ERROR, PSTR("%s"), kHAssError2); + AddLog(LOG_LEVEL_ERROR, PSTR("%s"), kHAssError2); } else { if (Settings.flag.hass_discovery && (RelayX || (Light.device > 0) && (max_lights > 0)) && !err_flag ) { // SetOption19 - Control Home Assistant automatic discovery (See SetOption59) @@ -898,7 +898,7 @@ void HAssAnnounceSensors(void) JsonParserObject root = parser.getRootObject(); if (!root) { - AddLog_P(LOG_LEVEL_ERROR, PSTR("%s '%s' (ERR1)"), kHAssError3, sensordata); + AddLog(LOG_LEVEL_ERROR, PSTR("%s '%s' (ERR1)"), kHAssError3, sensordata); continue; } for (auto sensor_key : root) @@ -909,7 +909,7 @@ void HAssAnnounceSensors(void) if (!sensors) { - AddLog_P(LOG_LEVEL_ERROR, PSTR("%s '%s' (ERR2)"), kHAssError3, sensorname); + AddLog(LOG_LEVEL_ERROR, PSTR("%s '%s' (ERR2)"), kHAssError3, sensorname); continue; } diff --git a/tasmota/xdrv_13_display.ino b/tasmota/xdrv_13_display.ino index ef076f3a7..99869ecae 100755 --- a/tasmota/xdrv_13_display.ino +++ b/tasmota/xdrv_13_display.ino @@ -1621,7 +1621,7 @@ void DisplayJsonValue(const char* topic, const char* device, const char* mkey, c } snprintf_P(buffer, sizeof(buffer), PSTR("%s %s"), source, svalue); -// AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "mkey [%s], source [%s], value [%s], quantity_code %d, log_buffer [%s]"), mkey, source, value, quantity_code, buffer); +// AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "mkey [%s], source [%s], value [%s], quantity_code %d, log_buffer [%s]"), mkey, source, value, quantity_code, buffer); DisplayLogBufferAdd(buffer); } diff --git a/tasmota/xdrv_16_tuyamcu.ino b/tasmota/xdrv_16_tuyamcu.ino index ccd830e0d..92c8178e8 100644 --- a/tasmota/xdrv_16_tuyamcu.ino +++ b/tasmota/xdrv_16_tuyamcu.ino @@ -1227,7 +1227,7 @@ void TuyaSerialInput(void) if (Settings.flag3.tuya_serial_mqtt_publish) { // SetOption66 - Enable TuyaMcuReceived messages over Mqtt MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_TUYA_MCU_RECEIVED)); } else { - AddLog_P(LOG_LEVEL_DEBUG, TasmotaGlobal.mqtt_data); + AddLog(LOG_LEVEL_DEBUG, TasmotaGlobal.mqtt_data); } XdrvRulesProcess(0); diff --git a/tasmota/xdrv_17_rcswitch.ino b/tasmota/xdrv_17_rcswitch.ino index 4e33bcc97..f70918cfc 100644 --- a/tasmota/xdrv_17_rcswitch.ino +++ b/tasmota/xdrv_17_rcswitch.ino @@ -100,7 +100,7 @@ void RfInit(void) { void CmndRfProtocol(void) { if (!PinUsed(GPIO_RFRECV)) { return; } -// AddLog_P(LOG_LEVEL_INFO, PSTR("RFR:CmndRfRxProtocol:: index:%d usridx:%d data_len:%d data:\"%s\""),XdrvMailbox.index, XdrvMailbox.usridx, XdrvMailbox.data_len,XdrvMailbox.data); +// AddLog(LOG_LEVEL_INFO, PSTR("RFR:CmndRfRxProtocol:: index:%d usridx:%d data_len:%d data:\"%s\""),XdrvMailbox.index, XdrvMailbox.usridx, XdrvMailbox.data_len,XdrvMailbox.data); uint64_t thisdat; if (1 == XdrvMailbox.usridx) { diff --git a/tasmota/xdrv_20_hue.ino b/tasmota/xdrv_20_hue.ino index 9044d02b9..45727e2d1 100644 --- a/tasmota/xdrv_20_hue.ino +++ b/tasmota/xdrv_20_hue.ino @@ -207,17 +207,17 @@ void HueRespondToMSearch(void) snprintf_P(response + len, sizeof(response) - len, msg[HUE_RESP_ST1], uuid.c_str()); PortUdp.write(response); PortUdp.endPacket(); - // AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_UPNP "UDP resp=%s"), response); + // AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_UPNP "UDP resp=%s"), response); snprintf_P(response + len, sizeof(response) - len, msg[HUE_RESP_ST2], uuid.c_str(), uuid.c_str()); PortUdp.write(response); PortUdp.endPacket(); - // AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_UPNP "UDP resp=%s"), response); + // AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_UPNP "UDP resp=%s"), response); snprintf_P(response + len, sizeof(response) - len, msg[HUE_RESP_ST3], uuid.c_str()); PortUdp.write(response); PortUdp.endPacket(); - // AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_UPNP "UDP resp=%s"), response); + // AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_UPNP "UDP resp=%s"), response); snprintf_P(message, sizeof(message), PSTR(D_3_RESPONSE_PACKETS_SENT)); } else { @@ -1000,7 +1000,7 @@ void HueLights(String *path) code = 406; } exit: - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_HTTP D_HUE " Result (%s)"), response.c_str()); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_HTTP D_HUE " Result (%s)"), response.c_str()); WSSend(code, CT_APP_JSON, response); } diff --git a/tasmota/xdrv_21_wemo_multi.ino b/tasmota/xdrv_21_wemo_multi.ino index d6edfe5c0..7c78d966f 100644 --- a/tasmota/xdrv_21_wemo_multi.ino +++ b/tasmota/xdrv_21_wemo_multi.ino @@ -300,9 +300,8 @@ public: } else { snprintf_P(message, sizeof(message), PSTR(D_FAILED_TO_SEND_RESPONSE)); } - // Do not use AddLog_P here (interrupt routine) if syslog or mqttlog is enabled. UDP/TCP will force exception 9 AddLog(LOG_LEVEL_DEBUG, PSTR("WMO: WeMo Type %d, %s to %s:%d"), - echo_type, message, udp_remote_ip.toString().c_str(), udp_remote_port); + echo_type, message, udp_remote_ip.toString().c_str(), udp_remote_port); } void HandleServerLoop() { diff --git a/tasmota/xdrv_23_zigbee_2a_devices_impl.ino b/tasmota/xdrv_23_zigbee_2a_devices_impl.ino index f11ab47df..6aecfaa82 100644 --- a/tasmota/xdrv_23_zigbee_2a_devices_impl.ino +++ b/tasmota/xdrv_23_zigbee_2a_devices_impl.ino @@ -880,7 +880,7 @@ int32_t Z_Devices::deviceRestore(JsonParserObject json) { data.setConfig(config); } } else { - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Ignoring config '%s'"), conf_str); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Ignoring config '%s'"), conf_str); } } } diff --git a/tasmota/xdrv_23_zigbee_3_hue.ino b/tasmota/xdrv_23_zigbee_3_hue.ino index d6347b9b4..f8bf00e68 100644 --- a/tasmota/xdrv_23_zigbee_3_hue.ino +++ b/tasmota/xdrv_23_zigbee_3_hue.ino @@ -367,7 +367,7 @@ void ZigbeeHandleHue(uint16_t shortaddr, uint32_t device_id, String &response) { else { response = msg[HUE_ERROR_JSON]; } - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_HTTP D_HUE " Result (%s)"), response.c_str()); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_HTTP D_HUE " Result (%s)"), response.c_str()); WSSend(code, CT_APP_JSON, response); free(buf); diff --git a/tasmota/xdrv_23_zigbee_4a_nano_fs.ino b/tasmota/xdrv_23_zigbee_4a_nano_fs.ino index 8ed8b82eb..6d2a64fc8 100644 --- a/tasmota/xdrv_23_zigbee_4a_nano_fs.ino +++ b/tasmota/xdrv_23_zigbee_4a_nano_fs.ino @@ -308,7 +308,7 @@ bool ZFS::findFileEntry(uint32_t name, ZFS_File_Entry & entry, uint8_t * _entry_ #ifdef Z_EEPROM_DEBUG // { // char hex_char[(sizeof(ZFS_File_Entry) * 2) + 2]; - // AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Read entry %d at address 0x%04X contains %*_H"), entry_idx, entry_addr, sizeof(entry), &entry); + // AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Read entry %d at address 0x%04X contains %*_H"), entry_idx, entry_addr, sizeof(entry), &entry); // } #endif if (entry.name == name) { @@ -341,7 +341,7 @@ void ZFS::erase(void) { int32_t ZFS::readBytes(uint32_t name, void* buffer, size_t buffer_len, uint16_t read_start, uint16_t read_len) { if (!zigbee.eeprom_ready) { return -1; } #ifdef Z_EEPROM_DEBUG - // AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "readBytes name=%08X, buffer_len=%d, read_start=0x%04X, read_len=%d"), name, buffer_len, read_start, read_len); + // AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "readBytes name=%08X, buffer_len=%d, read_start=0x%04X, read_len=%d"), name, buffer_len, read_start, read_len); #endif if (name == 0x00000000) { return -1; } if (buffer_len == 0) { return 0; } @@ -375,20 +375,20 @@ void ZFS::initOrFormat(void) { if (!zigbee.eeprom_present) { return; } #ifdef Z_EEPROM_DEBUG - // AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "sizeof(ZFS_Bitmap)=%d sizeof(ZFS_File_Entry)=%d sizeof(ZFS_Root_Entry)=%d sizeof(ZFS_Dir_Block)=%d"), sizeof(ZFS_Bitmap), sizeof(ZFS_File_Entry), sizeof(ZFS_Root_Entry), sizeof(ZFS_Dir_Block)); + // AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "sizeof(ZFS_Bitmap)=%d sizeof(ZFS_File_Entry)=%d sizeof(ZFS_Root_Entry)=%d sizeof(ZFS_Dir_Block)=%d"), sizeof(ZFS_Bitmap), sizeof(ZFS_File_Entry), sizeof(ZFS_Root_Entry), sizeof(ZFS_Dir_Block)); { byte map[256]; char hex_char[(256 * 2) + 2]; zigbee.eeprom.readBytes(0x0000, 256, map); - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "BLK 00 %s"), ToHex_P(map, sizeof(map), hex_char, sizeof(hex_char))); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "BLK 00 %s"), ToHex_P(map, sizeof(map), hex_char, sizeof(hex_char))); // zigbee.eeprom.readBytes(0x0100, 256, map); - // AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "BLK 01 %s"), ToHex_P(map, sizeof(map), hex_char, sizeof(hex_char))); + // AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "BLK 01 %s"), ToHex_P(map, sizeof(map), hex_char, sizeof(hex_char))); zigbee.eeprom.readBytes(0x0200, 256, map); - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "BLK 02 %s"), ToHex_P(map, sizeof(map), hex_char, sizeof(hex_char))); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "BLK 02 %s"), ToHex_P(map, sizeof(map), hex_char, sizeof(hex_char))); zigbee.eeprom.readBytes(0x2100, 256, map); - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "BLK 21 %s"), ToHex_P(map, sizeof(map), hex_char, sizeof(hex_char))); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "BLK 21 %s"), ToHex_P(map, sizeof(map), hex_char, sizeof(hex_char))); // zigbee.eeprom.readBytes(0xFF00, 256, map); - // AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "BLK FF %s"), ToHex_P(map, sizeof(map), hex_char, sizeof(hex_char))); + // AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "BLK FF %s"), ToHex_P(map, sizeof(map), hex_char, sizeof(hex_char))); } #endif @@ -397,9 +397,9 @@ void ZFS::initOrFormat(void) { if (dir->b0.signature == ZFS_SIGNATURE) { // Good - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "EEPROM signature 0x%08X is correct"), dir->b0.signature); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "EEPROM signature 0x%08X is correct"), dir->b0.signature); } else { - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "EEPROM signature 0x%08X is incorrect, formatting"), dir->b0.signature); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "EEPROM signature 0x%08X is incorrect, formatting"), dir->b0.signature); format(); } delete dir; @@ -411,7 +411,7 @@ void ZFS::initOrFormat(void) { // Format EEPROM // void ZFS::format(void) { - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Formatting EEPROM")); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Formatting EEPROM")); // First write the bitmap ZFS_Bitmap * bitmap = new ZFS_Bitmap(); @@ -455,7 +455,7 @@ int32_t ZFS_Write_File::addBytes(void* buffer, size_t buffer_len) { if (length + buffer_len > ZFS_FILE_BLOCKS * 256) { return -1; } // exceeded max size // #ifdef Z_EEPROM_DEBUG -// AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "eeprom.writeBytes address=0x%04X, len=%d"), (blk_start << 8) + length, buffer_len); +// AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "eeprom.writeBytes address=0x%04X, len=%d"), (blk_start << 8) + length, buffer_len); // #endif zigbee.eeprom.writeBytes((blk_start << 8) + length, buffer_len, (byte*)buffer); length += buffer_len; diff --git a/tasmota/xdrv_23_zigbee_4b_data.ino b/tasmota/xdrv_23_zigbee_4b_data.ino index 1c4b9b525..95eb7096d 100644 --- a/tasmota/xdrv_23_zigbee_4b_data.ino +++ b/tasmota/xdrv_23_zigbee_4b_data.ino @@ -62,7 +62,7 @@ bool hydrateDeviceData(class Z_Device & device, const SBuffer & buf, size_t star // #ifdef Z_EEPROM_DEBUG // { // char hex_char[((data_len+1) * 2) + 2]; -// AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "hydrateDeviceData data_len=%d contains %s"), data_len, ToHex_P(buf.buf(start+offset+1), data_len, hex_char, sizeof(hex_char))); +// AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "hydrateDeviceData data_len=%d contains %s"), data_len, ToHex_P(buf.buf(start+offset+1), data_len, hex_char, sizeof(hex_char))); // } // #endif Z_Data & data_elt = device.data.createFromBuffer(buf, start + offset + 1, data_len); @@ -89,7 +89,7 @@ int32_t hydrateSingleDeviceData(const SBuffer & buf) { #ifdef Z_EEPROM_DEBUG { if (segment_len > 3) { - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "ZbData 0x%04X,%*_H"), shortaddr, buf.buf(2), buf.len() - 2); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "ZbData 0x%04X,%*_H"), shortaddr, buf.buf(2), buf.len() - 2); } } #endif diff --git a/tasmota/xdrv_23_zigbee_5_converters.ino b/tasmota/xdrv_23_zigbee_5_converters.ino index 528e3eb6b..583c13307 100644 --- a/tasmota/xdrv_23_zigbee_5_converters.ino +++ b/tasmota/xdrv_23_zigbee_5_converters.ino @@ -751,7 +751,7 @@ public: if (Settings.flag3.tuya_serial_mqtt_publish) { MqttPublishPrefixTopicRulesProcess_P(TELE, PSTR(D_RSLT_SENSOR)); } else { - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "%s"), TasmotaGlobal.mqtt_data); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "%s"), TasmotaGlobal.mqtt_data); } } @@ -2042,7 +2042,7 @@ void Z_postProcessAttributes(uint16_t shortaddr, uint16_t src_ep, class Z_attrib uint8_t *attr_address = ((uint8_t*)&data) + sizeof(Z_Data) + map_offset; uint32_t uval32 = attr.getUInt(); // call converter to uint only once int32_t ival32 = attr.getInt(); // call converter to int only once - // AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_ZIGBEE "Mapping type=%d offset=%d zigbee_type=%02X value=%d\n"), (uint8_t) map_type, map_offset, zigbee_type, ival32); + // AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_ZIGBEE "Mapping type=%d offset=%d zigbee_type=%02X value=%d\n"), (uint8_t) map_type, map_offset, zigbee_type, ival32); switch (ccccaaaa) { case 0xEF000202: case 0xEF000203: // need to convert Tuya temperatures from 1/10 to 1/00 °C @@ -2108,7 +2108,7 @@ void Z_parseAttributeKey_inner(class Z_attribute & attr, uint16_t preferred_clus uint16_t local_cluster_id = CxToCluster(pgm_read_byte(&converter->cluster_short)); uint8_t local_type_id = pgm_read_byte(&converter->type); int8_t local_multiplier = CmToMultiplier(pgm_read_byte(&converter->multiplier_idx)); - // AddLog_P(LOG_LEVEL_DEBUG, PSTR("Try cluster = 0x%04X, attr = 0x%04X, type_id = 0x%02X"), local_cluster_id, local_attr_id, local_type_id); + // AddLog(LOG_LEVEL_DEBUG, PSTR("Try cluster = 0x%04X, attr = 0x%04X, type_id = 0x%02X"), local_cluster_id, local_attr_id, local_type_id); if (!attr.key_is_str) { if ((attr.key.id.cluster == local_cluster_id) && (attr.key.id.attr_id == local_attr_id)) { @@ -2117,7 +2117,7 @@ void Z_parseAttributeKey_inner(class Z_attribute & attr, uint16_t preferred_clus } } else if (pgm_read_word(&converter->name_offset)) { const char * key = attr.key.key; - // AddLog_P(LOG_LEVEL_DEBUG, PSTR("Comparing '%s' with '%s'"), attr_name, converter->name); + // AddLog(LOG_LEVEL_DEBUG, PSTR("Comparing '%s' with '%s'"), attr_name, converter->name); if (0 == strcasecmp_P(key, Z_strings + pgm_read_word(&converter->name_offset))) { if ((preferred_cluster == 0xFFFF) || // any cluster (local_cluster_id == preferred_cluster)) { @@ -2171,7 +2171,7 @@ bool Z_parseAttributeKey(class Z_attribute & attr, uint16_t preferred_cluster) { attr.attr_type = type_id; } } - // AddLog_P(LOG_LEVEL_DEBUG, PSTR("cluster_id = 0x%04X, attr_id = 0x%04X"), cluster_id, attr_id); + // AddLog(LOG_LEVEL_DEBUG, PSTR("cluster_id = 0x%04X, attr_id = 0x%04X"), cluster_id, attr_id); // do we already know the type, i.e. attribute and cluster are also known if ((Zunk == attr.attr_type) && (preferred_cluster != 0xFFFF)) { diff --git a/tasmota/xdrv_23_zigbee_6_commands.ino b/tasmota/xdrv_23_zigbee_6_commands.ino index 760fdcdcf..3b0d16b02 100644 --- a/tasmota/xdrv_23_zigbee_6_commands.ino +++ b/tasmota/xdrv_23_zigbee_6_commands.ino @@ -283,7 +283,7 @@ void convertClusterSpecific(class Z_attribute_list &attr_list, uint16_t cluster, uint8_t conv_direction; Z_XYZ_Var xyz; - //AddLog_P(LOG_LEVEL_INFO, PSTR(">>> len = %d - %02X%02X%02X"), payload.len(), payload.get8(0), payload.get8(1), payload.get8(2)); + //AddLog(LOG_LEVEL_INFO, PSTR(">>> len = %d - %02X%02X%02X"), payload.len(), payload.get8(0), payload.get8(1), payload.get8(2)); for (uint32_t i = 0; i < sizeof(Z_Commands) / sizeof(Z_Commands[0]); i++) { const Z_CommandConverter *conv = &Z_Commands[i]; uint16_t conv_cluster = pgm_read_word(&conv->cluster); @@ -299,18 +299,18 @@ void convertClusterSpecific(class Z_attribute_list &attr_list, uint16_t cluster, // - payload exactly matches conv->param (conv->param may be longer) // - payload matches conv->param until 'x', 'y' or 'z' const char * p = Z_strings + pgm_read_word(&conv->param_offset); - //AddLog_P(LOG_LEVEL_INFO, PSTR(">>>++1 param = %s"), p); + //AddLog(LOG_LEVEL_INFO, PSTR(">>>++1 param = %s"), p); bool match = true; for (uint8_t i = 0; i < payload.len(); i++) { const char c1 = pgm_read_byte(p); // const char c2 = pgm_read_byte(p+1); - //AddLog_P(LOG_LEVEL_INFO, PSTR(">>>++2 c1 = %c, c2 = %c"), c1, c2); + //AddLog(LOG_LEVEL_INFO, PSTR(">>>++2 c1 = %c, c2 = %c"), c1, c2); if ((0x00 == c1) || isXYZ(c1)) { break; } const char * p2 = p; uint32_t nextbyte = parseHex_P(&p2, 2); - //AddLog_P(LOG_LEVEL_INFO, PSTR(">>>++3 parseHex_P = %02X"), nextbyte); + //AddLog(LOG_LEVEL_INFO, PSTR(">>>++3 parseHex_P = %02X"), nextbyte); if (nextbyte != payload.get8(i)) { match = false; break; diff --git a/tasmota/xdrv_23_zigbee_7_0_statemachine.ino b/tasmota/xdrv_23_zigbee_7_0_statemachine.ino index 5def5a618..3fd21ad51 100644 --- a/tasmota/xdrv_23_zigbee_7_0_statemachine.ino +++ b/tasmota/xdrv_23_zigbee_7_0_statemachine.ino @@ -963,10 +963,10 @@ void ZigbeeGotoLabel(uint8_t label) { const Zigbee_Instruction *cur_instr_line = &zb_prog[i]; cur_instr = pgm_read_byte(&cur_instr_line->i.i); cur_d8 = pgm_read_byte(&cur_instr_line->i.d8); - //AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("ZGB GOTO: pc %d instr %d"), i, cur_instr); + //AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("ZGB GOTO: pc %d instr %d"), i, cur_instr); if (ZGB_INSTR_LABEL == cur_instr) { - //AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_ZIGBEE "found label %d at pc %d"), cur_d8, i); + //AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_ZIGBEE "found label %d at pc %d"), cur_d8, i); if (label == cur_d8) { // label found, goto to this pc zigbee.pc = i; @@ -1090,7 +1090,7 @@ void ZigbeeStateMachine_Run(void) { } break; case ZGB_INSTR_LOG: - AddLog_P(cur_d8, (char*) cur_ptr1); + AddLog(cur_d8, (char*) cur_ptr1); break; case ZGB_INSTR_MQTT_STATE: { diff --git a/tasmota/xdrv_23_zigbee_8_parsers.ino b/tasmota/xdrv_23_zigbee_8_parsers.ino index a738d5dc4..2d13b1e62 100644 --- a/tasmota/xdrv_23_zigbee_8_parsers.ino +++ b/tasmota/xdrv_23_zigbee_8_parsers.ino @@ -1219,7 +1219,7 @@ int32_t Z_Mgmt_Lqi_Bind_Rsp(int32_t res, const SBuffer &buf, boolean lqi) { dstep = buf.get8(idx + 20); idx += 21; } else { - //AddLog_P(LOG_LEVEL_INFO, PSTR("ZNP_MgmtBindRsp unknwon address mode %d"), addrmode); + //AddLog(LOG_LEVEL_INFO, PSTR("ZNP_MgmtBindRsp unknwon address mode %d"), addrmode); break; // abort for any other value since we don't know the length of the field } @@ -1451,7 +1451,7 @@ void Z_SendCIEZoneEnrollResponse(uint16_t shortaddr, uint16_t groupaddr, uint16_ void Z_AutoBind(uint16_t shortaddr, uint16_t groupaddr, uint16_t cluster, uint8_t endpoint, uint32_t value) { uint64_t srcLongAddr = zigbee_devices.getDeviceLongAddr(shortaddr); - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "auto-bind `ZbBind {\"Device\":\"0x%04X\",\"Endpoint\":%d,\"Cluster\":\"0x%04X\"}`"), + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "auto-bind `ZbBind {\"Device\":\"0x%04X\",\"Endpoint\":%d,\"Cluster\":\"0x%04X\"}`"), shortaddr, endpoint, cluster); #ifdef USE_ZIGBEE_ZNP SBuffer buf(34); @@ -1577,7 +1577,7 @@ void Z_AutoConfigReportingForCluster(uint16_t shortaddr, uint16_t groupaddr, uin ResponseAppend_P(PSTR("}}")); if (buf.len() > 0) { - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "auto-bind `%s`"), TasmotaGlobal.mqtt_data); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "auto-bind `%s`"), TasmotaGlobal.mqtt_data); ZCLMessage zcl(buf.len()); // message is 4 bytes zcl.shortaddr = shortaddr; zcl.cluster = cluster; @@ -1680,7 +1680,7 @@ void Z_IncomingMessage(class ZCLFrame &zcl_received) { zcl_received.parseClusterSpecificCommand(attr_list); } - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE D_JSON_ZIGBEEZCL_RAW_RECEIVED ": {\"0x%04X\":{%s}}"), srcaddr, attr_list.toString().c_str()); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE D_JSON_ZIGBEEZCL_RAW_RECEIVED ": {\"0x%04X\":{%s}}"), srcaddr, attr_list.toString().c_str()); // discard the message if it was sent by us (broadcast or group loopback) if (srcaddr == localShortAddr) { @@ -2164,7 +2164,7 @@ void ZCLFrame::autoResponder(const uint16_t *attr_list_ids, size_t attr_len) { // we have a non-empty output // log first - AddLog_P(LOG_LEVEL_INFO, PSTR("ZIG: Auto-responder: ZbSend {\"Device\":\"0x%04X\"" + AddLog(LOG_LEVEL_INFO, PSTR("ZIG: Auto-responder: ZbSend {\"Device\":\"0x%04X\"" ",\"Cluster\":\"0x%04X\"" ",\"Endpoint\":%d" ",\"Response\":%s}" diff --git a/tasmota/xdrv_23_zigbee_9_serial.ino b/tasmota/xdrv_23_zigbee_9_serial.ino index 14d2b1436..814f137a1 100644 --- a/tasmota/xdrv_23_zigbee_9_serial.ino +++ b/tasmota/xdrv_23_zigbee_9_serial.ino @@ -92,7 +92,7 @@ void ZigbeeInputLoop(void) { while (ZigbeeSerial->available()) { yield(); uint8_t zigbee_in_byte = ZigbeeSerial->read(); - //AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("ZbInput byte=%d len=%d"), zigbee_in_byte, zigbee_buffer->len()); + //AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("ZbInput byte=%d len=%d"), zigbee_in_byte, zigbee_buffer->len()); if (0 == zigbee_buffer->len()) { // make sure all variables are correctly initialized zigbee_frame_len = 5; @@ -134,17 +134,17 @@ void ZigbeeInputLoop(void) { } if (zigbee_buffer->len() && (millis() > (zigbee_polling_window + ZIGBEE_POLLING))) { - // AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_ZIGBEE "Bytes follow_read_metric = %0d"), ZigbeeSerial->getLoopReadMetric()); + // AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_ZIGBEE "Bytes follow_read_metric = %0d"), ZigbeeSerial->getLoopReadMetric()); // buffer received, now check integrity if (zigbee_buffer->len() != zigbee_frame_len) { // Len is not correct, log and reject frame - AddLog_P(LOG_LEVEL_INFO, PSTR(D_JSON_ZIGBEEZNPRECEIVED ": received frame of wrong size %_B, len %d, expected %d"), zigbee_buffer, zigbee_buffer->len(), zigbee_frame_len); + AddLog(LOG_LEVEL_INFO, PSTR(D_JSON_ZIGBEEZNPRECEIVED ": received frame of wrong size %_B, len %d, expected %d"), zigbee_buffer, zigbee_buffer->len(), zigbee_frame_len); } else if (0x00 != fcs) { // FCS is wrong, packet is corrupt, log and reject frame - AddLog_P(LOG_LEVEL_INFO, PSTR(D_JSON_ZIGBEEZNPRECEIVED ": received bad FCS frame %_B, %d"), zigbee_buffer, fcs); + AddLog(LOG_LEVEL_INFO, PSTR(D_JSON_ZIGBEEZNPRECEIVED ": received bad FCS frame %_B, %d"), zigbee_buffer, fcs); } else { // frame is correct - //AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(D_JSON_ZIGBEEZNPRECEIVED ": received correct frame %s"), hex_char); + //AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_JSON_ZIGBEEZNPRECEIVED ": received correct frame %s"), hex_char); SBuffer znp_buffer = zigbee_buffer->subBuffer(2, zigbee_frame_len - 3); // remove SOF, LEN and FCS @@ -152,7 +152,7 @@ void ZigbeeInputLoop(void) { if (Settings.flag3.tuya_serial_mqtt_publish) { MqttPublishPrefixTopicRulesProcess_P(TELE, PSTR(D_RSLT_SENSOR)); } else { - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "%s"), TasmotaGlobal.mqtt_data); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "%s"), TasmotaGlobal.mqtt_data); } // now process the message ZigbeeProcessInput(znp_buffer); @@ -177,7 +177,7 @@ void ZigbeeInputLoop(void) { yield(); uint8_t zigbee_in_byte = ZigbeeSerial->read(); - // AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("ZIG: ZbInput byte=0x%02X len=%d"), zigbee_in_byte, zigbee_buffer->len()); + // AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("ZIG: ZbInput byte=0x%02X len=%d"), zigbee_in_byte, zigbee_buffer->len()); // if (0 == zigbee_buffer->len()) { // make sure all variables are correctly initialized // escape = false; @@ -189,13 +189,13 @@ void ZigbeeInputLoop(void) { } if (ZIGBEE_EZSP_ESCAPE == zigbee_in_byte) { - // AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("ZIG: Escape byte received")); + // AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("ZIG: Escape byte received")); escape = true; continue; } if (ZIGBEE_EZSP_CANCEL == zigbee_in_byte) { - // AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("ZIG: ZbInput byte=0x1A, cancel byte received, discarding %d bytes"), zigbee_buffer->len()); + // AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("ZIG: ZbInput byte=0x1A, cancel byte received, discarding %d bytes"), zigbee_buffer->len()); zigbee_buffer->setLen(0); // empty buffer escape = false; frame_complete = false; @@ -222,10 +222,10 @@ void ZigbeeInputLoop(void) { uint32_t frame_len = zigbee_buffer->len(); if (frame_complete || (frame_len && (millis() > (zigbee_polling_window + ZIGBEE_POLLING)))) { - // AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_ZIGBEE "Bytes follow_read_metric = %0d"), ZigbeeSerial->getLoopReadMetric()); + // AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_ZIGBEE "Bytes follow_read_metric = %0d"), ZigbeeSerial->getLoopReadMetric()); if ((frame_complete) && (frame_len >= 3)) { // frame received and has at least 3 bytes (without EOF), checking CRC - // AddLog_P(LOG_LEVEL_INFO, PSTR(D_JSON_ZIGBEE_EZSP_RECEIVED ": received raw frame %s"), hex_char); + // AddLog(LOG_LEVEL_INFO, PSTR(D_JSON_ZIGBEE_EZSP_RECEIVED ": received raw frame %s"), hex_char); uint16_t crc = 0xFFFF; // frame CRC // compute CRC for (uint32_t i=0; isubBuffer(0, frame_len - 2); // CRC @@ -259,13 +259,13 @@ void ZigbeeInputLoop(void) { } } - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_ZIGBEE "{\"" D_JSON_ZIGBEE_EZSP_RECEIVED "2\":\"%_B\"}"), &ezsp_buffer); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_ZIGBEE "{\"" D_JSON_ZIGBEE_EZSP_RECEIVED "2\":\"%_B\"}"), &ezsp_buffer); // now process the message ZigbeeProcessInputRaw(ezsp_buffer); } } else { // the buffer timed-out, print error and discard - AddLog_P(LOG_LEVEL_INFO, PSTR(D_JSON_ZIGBEE_EZSP_RECEIVED ": time-out, discarding %_B"), zigbee_buffer); + AddLog(LOG_LEVEL_INFO, PSTR(D_JSON_ZIGBEE_EZSP_RECEIVED ": time-out, discarding %_B"), zigbee_buffer); } zigbee_buffer->setLen(0); // empty buffer escape = false; @@ -281,10 +281,10 @@ void ZigbeeInputLoop(void) { // Initialize internal structures void ZigbeeInitSerial(void) { -// AddLog_P(LOG_LEVEL_INFO, PSTR("ZigbeeInit Mem1 = %d"), ESP_getFreeHeap()); +// AddLog(LOG_LEVEL_INFO, PSTR("ZigbeeInit Mem1 = %d"), ESP_getFreeHeap()); zigbee.active = false; if (PinUsed(GPIO_ZIGBEE_RX) && PinUsed(GPIO_ZIGBEE_TX)) { - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_ZIGBEE "GPIOs Rx:%d Tx:%d"), Pin(GPIO_ZIGBEE_RX), Pin(GPIO_ZIGBEE_TX)); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_ZIGBEE "GPIOs Rx:%d Tx:%d"), Pin(GPIO_ZIGBEE_RX), Pin(GPIO_ZIGBEE_TX)); // if TasmotaGlobal.seriallog_level is 0, we allow GPIO 13/15 to switch to Hardware Serial ZigbeeSerial = new TasmotaSerial(Pin(GPIO_ZIGBEE_RX), Pin(GPIO_ZIGBEE_TX), TasmotaGlobal.seriallog_level ? 1 : 2, 0, 256); // set a receive buffer of 256 bytes ZigbeeSerial->begin(115200); @@ -293,9 +293,9 @@ void ZigbeeInitSerial(void) uint32_t aligned_buffer = ((uint32_t)TasmotaGlobal.serial_in_buffer + 3) & ~3; zigbee_buffer = new PreAllocatedSBuffer(sizeof(TasmotaGlobal.serial_in_buffer) - 3, (char*) aligned_buffer); } else { -// AddLog_P(LOG_LEVEL_INFO, PSTR("ZigbeeInit Mem2 = %d"), ESP_getFreeHeap()); +// AddLog(LOG_LEVEL_INFO, PSTR("ZigbeeInit Mem2 = %d"), ESP_getFreeHeap()); zigbee_buffer = new SBuffer(ZIGBEE_BUFFER_SIZE); -// AddLog_P(LOG_LEVEL_INFO, PSTR("ZigbeeInit Mem3 = %d"), ESP_getFreeHeap()); +// AddLog(LOG_LEVEL_INFO, PSTR("ZigbeeInit Mem3 = %d"), ESP_getFreeHeap()); } if (PinUsed(GPIO_ZIGBEE_RST)) { @@ -312,7 +312,7 @@ void ZigbeeInitSerial(void) zigbee.state_machine = true; // start the state machine ZigbeeSerial->flush(); } -// AddLog_P(LOG_LEVEL_INFO, PSTR("ZigbeeInit Mem9 = %d"), ESP_getFreeHeap()); +// AddLog(LOG_LEVEL_INFO, PSTR("ZigbeeInit Mem9 = %d"), ESP_getFreeHeap()); } #ifdef USE_ZIGBEE_ZNP @@ -323,14 +323,14 @@ void ZigbeeZNPFlush(void) { for (uint32_t i = 0; i < 256; i++) { ZigbeeSerial->write(0xFF); } - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE D_JSON_ZIGBEEZNPSENT " 0xFF x 255")); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE D_JSON_ZIGBEEZNPSENT " 0xFF x 255")); } } void ZigbeeZNPSend(const uint8_t *msg, size_t len) { if ((len < 2) || (len > 252)) { // abort, message cannot be less than 2 bytes for CMD1 and CMD2 - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_JSON_ZIGBEEZNPSENT ": bad message len %d"), len); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_JSON_ZIGBEEZNPSENT ": bad message len %d"), len); return; } uint8_t data_len = len - 2; // removing CMD1 and CMD2 @@ -339,20 +339,20 @@ void ZigbeeZNPSend(const uint8_t *msg, size_t len) { uint8_t fcs = data_len; ZigbeeSerial->write(ZIGBEE_SOF); // 0xFE - //AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("ZNPSend SOF %02X"), ZIGBEE_SOF); + //AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("ZNPSend SOF %02X"), ZIGBEE_SOF); ZigbeeSerial->write(data_len); - //AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("ZNPSend LEN %02X"), data_len); + //AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("ZNPSend LEN %02X"), data_len); for (uint32_t i = 0; i < len; i++) { uint8_t b = pgm_read_byte(msg + i); ZigbeeSerial->write(b); fcs ^= b; - //AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("ZNPSend byt %02X"), b); + //AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("ZNPSend byt %02X"), b); } ZigbeeSerial->write(fcs); // finally send fcs checksum byte - //AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("ZNPSend FCS %02X"), fcs); + //AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("ZNPSend FCS %02X"), fcs); } // Now send a MQTT message to report the sent message - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE D_JSON_ZIGBEEZNPSENT " %*_H"), len, msg); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE D_JSON_ZIGBEEZNPSENT " %*_H"), len, msg); } // @@ -437,7 +437,7 @@ void ZigbeeEZSPSend_Out(uint8_t out_byte) { void ZigbeeEZSPSendRaw(const uint8_t *msg, size_t len, bool send_cancel) { if ((len < 1) || (len > 252)) { // abort, message cannot be less than 2 bytes for CMD1 and CMD2 - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_JSON_ZIGBEE_EZSP_SENT ": bad message len %d"), len); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_JSON_ZIGBEE_EZSP_SENT ": bad message len %d"), len); return; } // turn send led on @@ -484,13 +484,13 @@ void ZigbeeEZSPSendRaw(const uint8_t *msg, size_t len, bool send_cancel) { } // Now send a MQTT message to report the sent message - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_ZIGBEE D_JSON_ZIGBEE_EZSP_SENT_RAW " %*_H"), len, msg); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_ZIGBEE D_JSON_ZIGBEE_EZSP_SENT_RAW " %*_H"), len, msg); } // Send an EZSP command and data // Ex: Version with min v8 = 000008 void ZigbeeEZSPSendCmd(const uint8_t *msg, size_t len) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "ZbEZSPSend %*_H"), len, msg); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "ZbEZSPSend %*_H"), len, msg); SBuffer cmd(len+3); // prefix with seq number (1 byte) and frame control bytes (2 bytes) @@ -507,7 +507,7 @@ void ZigbeeEZSPSendCmd(const uint8_t *msg, size_t len) { void ZigbeeEZSPSendDATA_frm(bool send_cancel, uint8_t to_frm, uint8_t from_ack) { SBuffer *buf = EZSP_Serial.to_packets[to_frm]; if (!buf) { - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("ZIG: Buffer for packet %d is not allocated"), EZSP_Serial.to_send); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("ZIG: Buffer for packet %d is not allocated"), EZSP_Serial.to_send); return; } @@ -524,7 +524,7 @@ void ZigbeeEZSPSendDATA(const uint8_t *msg, size_t len) { buf->add8(0x00); // placeholder for control_byte buf->addBuffer(msg, len); // - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("ZIG: adding packet to_send, to_ack:%d, to_send:%d, to_end:%d"), + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("ZIG: adding packet to_send, to_ack:%d, to_send:%d, to_end:%d"), EZSP_Serial.to_ack, EZSP_Serial.to_send, EZSP_Serial.to_end); uint8_t to_frm = EZSP_Serial.to_end; if (EZSP_Serial.to_packets[to_frm]) { @@ -552,7 +552,7 @@ void ZigbeeProcessInputEZSP(SBuffer &buf) { // bool callbackPending = frame_control & 0x04; bool security_enabled = frame_control & 0x8000; if (truncated || overflow || security_enabled) { - AddLog_P(LOG_LEVEL_INFO, PSTR("ZIG: specific frame_control 0x%04X"), frame_control); + AddLog(LOG_LEVEL_INFO, PSTR("ZIG: specific frame_control 0x%04X"), frame_control); } // remove first 2 bytes, be @@ -597,7 +597,7 @@ void ZigbeeProcessInputEZSP(SBuffer &buf) { log_level = LOG_LEVEL_DEBUG; break; } - AddLog_P(log_level, PSTR(D_LOG_ZIGBEE "%s"), TasmotaGlobal.mqtt_data); // TODO move to LOG_LEVEL_DEBUG when stable + AddLog(log_level, PSTR(D_LOG_ZIGBEE "%s"), TasmotaGlobal.mqtt_data); // TODO move to LOG_LEVEL_DEBUG when stable } // Pass message to state machine @@ -607,14 +607,14 @@ void ZigbeeProcessInputEZSP(SBuffer &buf) { // Check if we advanced in the ACKed frames, and free from memory packets acknowledged void EZSP_HandleAck(uint8_t new_ack) { if (EZSP_Serial.to_ack != new_ack) { // new ack receveid - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("ZIG: new ack/data received, was %d now %d"), EZSP_Serial.to_ack, new_ack); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("ZIG: new ack/data received, was %d now %d"), EZSP_Serial.to_ack, new_ack); uint32_t i = EZSP_Serial.to_ack; do { if (EZSP_Serial.to_packets[i]) { delete EZSP_Serial.to_packets[i]; EZSP_Serial.to_packets[i] = nullptr; } - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("ZIG: freeing packet %d from memory"), i); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("ZIG: freeing packet %d from memory"), i); i = (i + 1) & 0x07; } while (i != new_ack); EZSP_Serial.to_ack = new_ack; @@ -635,10 +635,10 @@ void ZigbeeProcessInputRaw(SBuffer &buf) { } else if (frame_type == 0xA0) { // NAK - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("ZIG: Received NAK %d, to_ack:%d, to_send:%d, to_end:%d"), + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("ZIG: Received NAK %d, to_ack:%d, to_send:%d, to_end:%d"), ack_num, EZSP_Serial.to_ack, EZSP_Serial.to_send, EZSP_Serial.to_end); EZSP_Serial.to_send = ack_num; - AddLog_P(LOG_LEVEL_DEBUG, PSTR("ZIG: NAK, resending packet %d"), ack_num); + AddLog(LOG_LEVEL_DEBUG, PSTR("ZIG: NAK, resending packet %d"), ack_num); } else if (control_byte == 0xC1) { // RSTACK @@ -664,7 +664,7 @@ void ZigbeeProcessInputRaw(SBuffer &buf) { } else { // Unknown - AddLog_P(LOG_LEVEL_DEBUG, PSTR("ZIG: Received unknown control byte 0x%02X"), control_byte); + AddLog(LOG_LEVEL_DEBUG, PSTR("ZIG: Received unknown control byte 0x%02X"), control_byte); } } else { // DATA Frame @@ -864,7 +864,7 @@ void ZigbeeOutputLoop(void) { #ifdef USE_ZIGBEE_EZSP // while (EZSP_Serial.to_send != EZSP_Serial.to_end) { if (EZSP_Serial.to_send != EZSP_Serial.to_end) { // we send only one packet per tick to lower the chance of NAK - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("ZIG: Something to_send, to_ack:%d, to_send:%d, to_end:%d"), + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("ZIG: Something to_send, to_ack:%d, to_send:%d, to_end:%d"), EZSP_Serial.to_ack, EZSP_Serial.to_send, EZSP_Serial.to_end); // we have a frame waiting to be sent ZigbeeEZSPSendDATA_frm(true, EZSP_Serial.to_send, EZSP_Serial.from_ack); diff --git a/tasmota/xdrv_23_zigbee_9a_upload.ino b/tasmota/xdrv_23_zigbee_9a_upload.ino index 0aac5eb1c..04582dea3 100644 --- a/tasmota/xdrv_23_zigbee_9a_upload.ino +++ b/tasmota/xdrv_23_zigbee_9a_upload.ino @@ -77,7 +77,7 @@ char ZigbeeUploadFlashRead(void) { if (sector != ZbUpload.sector_counter) { ZbUpload.sector_counter = sector; ESP.flashRead(ZbUpload.sector_counter * SPI_FLASH_SEC_SIZE, (uint32_t*)ZbUpload.buffer, SPI_FLASH_SEC_SIZE); - // AddLog_P(LOG_LEVEL_DEBUG, "= sector %d %*_H", ZbUpload.sector_counter, 256, ZbUpload.buffer); + // AddLog(LOG_LEVEL_DEBUG, "= sector %d %*_H", ZbUpload.sector_counter, 256, ZbUpload.buffer); } char data = ZbUpload.buffer[index]; diff --git a/tasmota/xdrv_23_zigbee_A_impl.ino b/tasmota/xdrv_23_zigbee_A_impl.ino index 973a5a902..e751c4949 100644 --- a/tasmota/xdrv_23_zigbee_A_impl.ino +++ b/tasmota/xdrv_23_zigbee_A_impl.ino @@ -184,14 +184,14 @@ void zigbeeZCLSendCmd(class ZCLMessage &zcl) { // endpoint is not specified, let's try to find it from shortAddr, unless it's a group address zcl.endpoint = zigbee_devices.findFirstEndpoint(zcl.shortaddr); if (0x00 == zcl.endpoint) { zcl.endpoint = 0x01; } // if we don't know the endpoint, try 0x01 - //AddLog_P(LOG_LEVEL_DEBUG, PSTR("ZbSend: guessing endpoint 0x%02X"), endpoint); + //AddLog(LOG_LEVEL_DEBUG, PSTR("ZbSend: guessing endpoint 0x%02X"), endpoint); } - // AddLog_P(LOG_LEVEL_DEBUG, PSTR("ZbSend: shortaddr 0x%04X, groupaddr 0x%04X, cluster 0x%04X, endpoint 0x%02X, cmd 0x%02X, data %_B"), + // AddLog(LOG_LEVEL_DEBUG, PSTR("ZbSend: shortaddr 0x%04X, groupaddr 0x%04X, cluster 0x%04X, endpoint 0x%02X, cmd 0x%02X, data %_B"), // zcl.shortaddr, zcl.groupaddr, zcl.cluster, zcl.endpoint, zcl.cmd, &zcl.buf); if ((0 == zcl.endpoint) && (zcl.validShortaddr())) { // endpoint null is ok for group address - AddLog_P(LOG_LEVEL_INFO, PSTR("ZbSend: unspecified endpoint")); + AddLog(LOG_LEVEL_INFO, PSTR("ZbSend: unspecified endpoint")); return; } @@ -202,7 +202,7 @@ void zigbeeZCLSendCmd(class ZCLMessage &zcl) { zcl.transacSet = true; } - AddLog_P(LOG_LEVEL_DEBUG, PSTR("ZigbeeZCLSend device: 0x%04X, group: 0x%04X, endpoint:%d, cluster:0x%04X, cmd:0x%02X, send:\"%_B\""), + AddLog(LOG_LEVEL_DEBUG, PSTR("ZigbeeZCLSend device: 0x%04X, group: 0x%04X, endpoint:%d, cluster:0x%04X, cmd:0x%02X, send:\"%_B\""), zcl.shortaddr, zcl.groupaddr, zcl.endpoint, zcl.cluster, zcl.cmd, &zcl.buf); ZigbeeZCLSend_Raw(zcl); @@ -312,7 +312,7 @@ bool ZbAppendWriteBuf(SBuffer & buf, const Z_attribute & attr, bool prepend_stat if (res < 0) { // remove the attribute type we just added // buf.setLen(buf.len() - (operation == ZCL_READ_ATTRIBUTES_RESPONSE ? 4 : 3)); - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE D_ZIGBEE_UNSUPPORTED_ATTRIBUTE_TYPE " %04X/%04X '0x%02X'"), attr.key.id.cluster, attr.key.id.attr_id, attr.attr_type); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE D_ZIGBEE_UNSUPPORTED_ATTRIBUTE_TYPE " %04X/%04X '0x%02X'"), attr.key.id.cluster, attr.key.id.attr_id, attr.attr_type); return false; } return true; @@ -518,7 +518,7 @@ void ZbSendSend(class JsonParserToken val_cmd, ZCLMessage & zcl) { } } - //AddLog_P(LOG_LEVEL_DEBUG, PSTR("ZbSend: command_template = %s"), cmd_str.c_str()); + //AddLog(LOG_LEVEL_DEBUG, PSTR("ZbSend: command_template = %s"), cmd_str.c_str()); if (0xFF == cmd_var) { // if command number is a variable, replace it with x zcl.cmd = x; x = y; // and shift other variables @@ -653,7 +653,7 @@ void ZbSendRead(JsonParserToken val_attr, ZCLMessage & zcl) { } } if (!found) { - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE D_ZIGBEE_UNKNWON_ATTRIBUTE), key.getStr()); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE D_ZIGBEE_UNKNWON_ATTRIBUTE), key.getStr()); } } @@ -742,7 +742,7 @@ void CmndZbSend(void) { zcl.endpoint = 0xFF; // endpoint not used for group addresses, so use a dummy broadcast endpoint } else if (!zcl.validEndpoint()) { // if it was not already specified, try to guess it zcl.endpoint = zigbee_devices.findFirstEndpoint(zcl.shortaddr); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("ZIG: guessing endpoint %d"), zcl.endpoint); + AddLog(LOG_LEVEL_DEBUG, PSTR("ZIG: guessing endpoint %d"), zcl.endpoint); } if (!zcl.validEndpoint()) { // after this, if it is still zero, then it's an error ResponseCmndChar_P(PSTR("Missing endpoint")); @@ -1621,7 +1621,7 @@ void CmndZbConfig(void) { if (zb_channel > 26) { zb_channel = 26; } // if network key is zero, we generate a truly random key with a hardware generator from ESP if ((0 == zb_precfgkey_l) && (0 == zb_precfgkey_h)) { - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE D_ZIGBEE_GENERATE_KEY)); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE D_ZIGBEE_GENERATE_KEY)); zb_precfgkey_l = (uint64_t)HwRandom() << 32 | HwRandom(); zb_precfgkey_h = (uint64_t)HwRandom() << 32 | HwRandom(); } @@ -2092,7 +2092,7 @@ void ZigbeeMapRefresh(void) { // Display a graphical representation of the Zigbee map using vis.js network void ZigbeeShowMap(void) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP "Zigbee Mapper")); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP "Zigbee Mapper")); // if no map, then launch a new mapping if ((!zigbee.init_phase) && (!zigbee.mapping_ready) && (!zigbee.mapping_in_progress)) { diff --git a/tasmota/xdrv_27_shutter.ino b/tasmota/xdrv_27_shutter.ino index a97e35452..e36065dfc 100644 --- a/tasmota/xdrv_27_shutter.ino +++ b/tasmota/xdrv_27_shutter.ino @@ -265,7 +265,7 @@ void ShutterInit(void) for (uint32_t j = 0; j < MAX_INTERLOCKS * Settings.flag.interlock; j++) { // CMND_INTERLOCK - Enable/disable interlock //AddLog(LOG_LEVEL_DEBUG, PSTR("SHT: Interlock state i=%d %d, flag %d, Shuttermask %d, MaskedIL %d"),i, Settings.interlock[i], Settings.flag.interlock,ShutterGlobal.RelayShutterMask, Settings.interlock[i]&ShutterGlobal.RelayShutterMask); if (Settings.interlock[j] && (Settings.interlock[j] & ShutterGlobal.RelayShutterMask)) { - //AddLog_P(LOG_LEVEL_DEBUG, PSTR("SHT: Relay in Interlock group")); + //AddLog(LOG_LEVEL_DEBUG, PSTR("SHT: Relay in Interlock group")); relay_in_interlock = true; } } @@ -554,7 +554,7 @@ void ShutterAllowPreStartProcedure(uint8_t i) void ShutterStartInit(uint32_t i, int32_t direction, int32_t target_pos) { - //AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: dir %d, delta1 %d, delta2 %d, grant %d"),direction, (Shutter[i].open_max - Shutter[i].real_position) / Shutter[i].close_velocity, Shutter[i].real_position / Shutter[i].close_velocity, 2+Shutter[i].motordelay); + //AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: dir %d, delta1 %d, delta2 %d, grant %d"),direction, (Shutter[i].open_max - Shutter[i].real_position) / Shutter[i].close_velocity, Shutter[i].real_position / Shutter[i].close_velocity, 2+Shutter[i].motordelay); if ( ( (1 == direction) && ((Shutter[i].open_max - Shutter[i].real_position) / 100 <= 2) ) || ( (-1 == direction) && (Shutter[i].real_position / Shutter[i].close_velocity <= 2)) ) { ShutterGlobal.skip_relay_change = 1; @@ -624,7 +624,7 @@ void ShutterRelayChanged(void) // SRC_IGNORE added because INTERLOCK function bite causes this as last source for changing the relay. //uint8 manual_relays_changed = ((ShutterGlobal.RelayCurrentMask >> (Settings.shutter_startrelay[i] -1)) & 3) && SRC_IGNORE != TasmotaGlobal.last_source && SRC_SHUTTER != TasmotaGlobal.last_source && SRC_PULSETIMER != TasmotaGlobal.last_source ; uint8 manual_relays_changed = ((ShutterGlobal.RelayCurrentMask >> (Settings.shutter_startrelay[i] -1)) & 3) && SRC_SHUTTER != TasmotaGlobal.last_source && SRC_PULSETIMER != TasmotaGlobal.last_source ; - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Shtr%d, Source %s, Powerstate %ld, RelayMask %d, ManualChange %d"), + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Shtr%d, Source %s, Powerstate %ld, RelayMask %d, ManualChange %d"), i+1, GetTextIndexed(stemp1, sizeof(stemp1), TasmotaGlobal.last_source, kCommandSource), powerstate_local,ShutterGlobal.RelayCurrentMask,manual_relays_changed); if (manual_relays_changed) { //ShutterGlobal.skip_relay_change = true; @@ -833,7 +833,7 @@ void ShutterButtonHandler(void) if (Settings.shutter_startrelay[shutter_index] && Settings.shutter_startrelay[shutter_index] <9) { uint8_t pos_press_index = (buttonState == SHT_PRESSED_HOLD) ? 3 : (press_index-1); if (pos_press_index>3) pos_press_index=3; - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Shtr%d, Button %d = %d (single=1, double=2, tripple=3, hold=4)"), shutter_index+1, button_index+1, pos_press_index+1); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Shtr%d, Button %d = %d (single=1, double=2, tripple=3, hold=4)"), shutter_index+1, button_index+1, pos_press_index+1); XdrvMailbox.index = shutter_index +1; TasmotaGlobal.last_source = SRC_BUTTON; XdrvMailbox.data_len = 0; @@ -1020,7 +1020,7 @@ void CmndShutterStop(void) void CmndShutterIncDec(void) { - //AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Change in: payload %s (%d), payload %d, idx %d, src %d"), XdrvMailbox.data , XdrvMailbox.data_len, XdrvMailbox.payload , XdrvMailbox.index, TasmotaGlobal.last_source ); + //AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Change in: payload %s (%d), payload %d, idx %d, src %d"), XdrvMailbox.data , XdrvMailbox.data_len, XdrvMailbox.payload , XdrvMailbox.index, TasmotaGlobal.last_source ); if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= TasmotaGlobal.shutters_present)) { if (XdrvMailbox.data_len > 0) { XdrvMailbox.payload = ShutterRealToPercentPosition(Shutter[XdrvMailbox.index-1].target_position, XdrvMailbox.index-1)+XdrvMailbox.payload; diff --git a/tasmota/xdrv_30_exs_dimmer.ino b/tasmota/xdrv_30_exs_dimmer.ino index ffab61d5d..3b37a146a 100644 --- a/tasmota/xdrv_30_exs_dimmer.ino +++ b/tasmota/xdrv_30_exs_dimmer.ino @@ -250,7 +250,7 @@ bool ExsSyncState() void ExsDebugState() { #ifdef EXS_DEBUG - AddLog_P(LOG_LEVEL_DEBUG, PSTR("EXS: MCU v%d.%d, c0: On:%d,Dim:%d,Tbl:%d(%d%%), c1: On:%d,Dim:%d,Tbl:%d(%d%%), ChLock: %d"), + AddLog(LOG_LEVEL_DEBUG, PSTR("EXS: MCU v%d.%d, c0: On:%d,Dim:%d,Tbl:%d(%d%%), c1: On:%d,Dim:%d,Tbl:%d(%d%%), ChLock: %d"), Exs.dimmer.version_major, Exs.dimmer.version_minor, Exs.dimmer.channel[0].on, Exs.dimmer.channel[0].dimm, Exs.dimmer.channel[0].bright_tbl, diff --git a/tasmota/xdrv_31_tasmota_client.ino b/tasmota/xdrv_31_tasmota_client.ino index 54082d827..6301393d7 100644 --- a/tasmota/xdrv_31_tasmota_client.ino +++ b/tasmota/xdrv_31_tasmota_client.ino @@ -95,7 +95,7 @@ uint32_t SimpleHexParseLine(char *hexline) { uint8_t addr_l = SimpleHexParseGetByte(hexline, 3); uint8_t rectype = SimpleHexParseGetByte(hexline, 4); -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("DBG: Hexline |%s|, Len %d, Address 0x%02X%02X, RecType %d"), hexline, len, addr_h, addr_l, rectype); +// AddLog(LOG_LEVEL_DEBUG, PSTR("DBG: Hexline |%s|, Len %d, Address 0x%02X%02X, RecType %d"), hexline, len, addr_h, addr_l, rectype); if (len > 16) { return 5; } // Error: Line too long if (rectype > 1) { return 6; } // Error: Invalid record type diff --git a/tasmota/xdrv_40_telegram.ino b/tasmota/xdrv_40_telegram.ino index fd4d75ee9..fb0344c43 100644 --- a/tasmota/xdrv_40_telegram.ino +++ b/tasmota/xdrv_40_telegram.ino @@ -104,7 +104,7 @@ bool TelegramInit(void) { } String TelegramConnectToTelegram(String command) { -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("TGM: Cmnd %s"), command.c_str()); +// AddLog(LOG_LEVEL_DEBUG, PSTR("TGM: Cmnd %s"), command.c_str()); if (!TelegramInit()) { return ""; } @@ -201,13 +201,13 @@ void TelegramGetUpdates(uint32_t offset) { // } // ]} - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("TGM: Response %s"), response.c_str()); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("TGM: Response %s"), response.c_str()); JsonParser parser((char*)response.c_str()); JsonParserObject root = parser.getRootObject(); if (root) { -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("TGM: Sent Update request messages up to %s"), offset.c_str()); +// AddLog(LOG_LEVEL_DEBUG, PSTR("TGM: Sent Update request messages up to %s"), offset.c_str()); JsonParserArray arr = root[PSTR("result")]; uint32_t max_updates = arr.size(); @@ -235,7 +235,7 @@ void TelegramGetUpdates(uint32_t offset) { } Telegram.next_update_id = Telegram.message[i].update_id +1; // Write id of last read message - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("TGM: Parsed update_id %d, chat_id %s, text \"%s\""), Telegram.message[i].update_id, Telegram.message[i].chat_id.c_str(), Telegram.message[i].text.c_str()); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("TGM: Parsed update_id %d, chat_id %s, text \"%s\""), Telegram.message[i].update_id, Telegram.message[i].chat_id.c_str(), Telegram.message[i].text.c_str()); } } else { // AddLog(LOG_LEVEL_DEBUG, PSTR("TGM: No new messages")); @@ -256,7 +256,7 @@ bool TelegramSendMessage(String chat_id, String text) { String command = "bot" + _token + "/sendMessage?chat_id=" + chat_id + "&text=" + UrlEncode(text); String response = TelegramConnectToTelegram(command); -// AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("TGM: Response %s"), response.c_str()); +// AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("TGM: Response %s"), response.c_str()); if (response.startsWith("{\"ok\":true")) { // AddLog(LOG_LEVEL_DEBUG, PSTR("TGM: Message sent")); @@ -279,7 +279,7 @@ void TelegramSendGetMe(void) { // {"ok":true,"result":{"id":1179906608,"is_bot":true,"first_name":"Tasmota","username":"tasmota_bot","can_join_groups":true,"can_read_all_group_messages":false,"supports_inline_queries":false}} -// AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("TGM: Response %s"), response.c_str()); +// AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("TGM: Response %s"), response.c_str()); } */ diff --git a/tasmota/xdrv_41_tcp_bridge.ino b/tasmota/xdrv_41_tcp_bridge.ino index 44a686e77..a66c6fab6 100644 --- a/tasmota/xdrv_41_tcp_bridge.ino +++ b/tasmota/xdrv_41_tcp_bridge.ino @@ -90,7 +90,7 @@ void TCPLoop(void) } } if (buf_len > 0) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_TCP "from MCU: %*_H"), buf_len, tcp_buf); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_TCP "from MCU: %*_H"), buf_len, tcp_buf); for (uint32_t i=0; i 0) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_TCP "to MCU/%d: %*_H"), i+1, buf_len, tcp_buf); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_TCP "to MCU/%d: %*_H"), i+1, buf_len, tcp_buf); TCPSerial->write(tcp_buf, buf_len); } } diff --git a/tasmota/xdrv_44_miel_hvac.ino b/tasmota/xdrv_44_miel_hvac.ino index 026f9eac9..f33dcecc8 100644 --- a/tasmota/xdrv_44_miel_hvac.ino +++ b/tasmota/xdrv_44_miel_hvac.ino @@ -495,7 +495,7 @@ miel_hvac_send(struct miel_hvac_softc *sc, uint8_t type, char hex_h[(sizeof(h) + 1) * 2]; char hex_d[(len + 1) * 2]; - AddLog_P(LOG_LEVEL_DEBUG, + AddLog(LOG_LEVEL_DEBUG, PSTR(MIEL_HVAC_LOGNAME ": sending %s %s %02x"), ToHex_P((uint8_t *)&h, sizeof(h), hex_h, sizeof(hex_h)), ToHex_P((uint8_t *)data, len, hex_d, sizeof(hex_d)), @@ -837,7 +837,7 @@ miel_hvac_log_bytes(struct miel_hvac_softc *sc, const char *name, char hex[(MIEL_HVAC_DATABUFLEN + 1) * 2]; const unsigned char *b = (const unsigned char *)buf; - AddLog_P(LOG_LEVEL_DEBUG, PSTR(MIEL_HVAC_LOGNAME + AddLog(LOG_LEVEL_DEBUG, PSTR(MIEL_HVAC_LOGNAME ": response %s %s"), name, ToHex_P(b, len, hex, sizeof(hex))); } diff --git a/tasmota/xdrv_48_timeprop.ino b/tasmota/xdrv_48_timeprop.ino index 0defa6d33..68b1696e0 100644 --- a/tasmota/xdrv_48_timeprop.ino +++ b/tasmota/xdrv_48_timeprop.ino @@ -184,7 +184,7 @@ bool TimepropCommand() bool serviced = true; uint8_t ua_prefix_len = strlen(D_CMND_TIMEPROP); // to detect prefix of command /* - AddLog_P(LOG_LEVEL_INFO, PSTR("Command called: " + AddLog(LOG_LEVEL_INFO, PSTR("Command called: " "index: %d data_len: %d payload: %d topic: %s data: %s"), XdrvMailbox.index, XdrvMailbox.data_len, @@ -197,7 +197,7 @@ bool TimepropCommand() int command_code = GetCommandCode(command, sizeof(command), XdrvMailbox.topic + ua_prefix_len, kTimepropCommands); if (CMND_TIMEPROP_SETPOWER == command_code) { /* - AddLog_P(LOG_LEVEL_INFO, PSTR("Timeprop command timeprop_setpower: " + AddLog(LOG_LEVEL_INFO, PSTR("Timeprop command timeprop_setpower: " "index: %d data_len: %d payload: %d topic: %s data: %s"), XdrvMailbox.index, XdrvMailbox.data_len, diff --git a/tasmota/xdrv_52_3_berry_tasmota.ino b/tasmota/xdrv_52_3_berry_tasmota.ino index c6a248643..75d5d359e 100644 --- a/tasmota/xdrv_52_3_berry_tasmota.ino +++ b/tasmota/xdrv_52_3_berry_tasmota.ino @@ -382,7 +382,7 @@ extern "C" { log_level = be_toint(vm, 3); if (log_level > LOG_LEVEL_DEBUG_MORE) { log_level = LOG_LEVEL_DEBUG_MORE; } } - AddLog_P(log_level, PSTR("%s"), msg); + AddLog(log_level, PSTR("%s"), msg); be_return(vm); // Return } be_return_nil(vm); // Return nil when something goes wrong @@ -425,7 +425,7 @@ void berry_log(const char * berry_buf) { } // AddLog(LOG_LEVEL_INFO, PSTR("[Add to log] %s"), berry_buf); berry.log.addString(berry_buf, pre_delimiter, "\n"); - AddLog_P(LOG_LEVEL_INFO, PSTR("%s"), berry_buf); + AddLog(LOG_LEVEL_INFO, PSTR("%s"), berry_buf); } extern "C" { diff --git a/tasmota/xdrv_52_9_berry.ino b/tasmota/xdrv_52_9_berry.ino index e78884efd..649ad0220 100644 --- a/tasmota/xdrv_52_9_berry.ino +++ b/tasmota/xdrv_52_9_berry.ino @@ -408,7 +408,7 @@ void BrREPLRun(char * cmd) { if (!be_isnil(berry.vm, 1)) { const char * ret_val = be_tostring(berry.vm, 1); berry.log.addString(ret_val, nullptr, "\n"); - // AddLog_P(LOG_LEVEL_INFO, PSTR(">>> %s"), ret_val); + // AddLog(LOG_LEVEL_INFO, PSTR(">>> %s"), ret_val); } be_pop(berry.vm, 1); } @@ -418,7 +418,7 @@ void BrREPLRun(char * cmd) { char exception_s[120]; ext_snprintf_P(exception_s, sizeof(exception_s), PSTR("%s: %s"), be_tostring(berry.vm, -2), be_tostring(berry.vm, -1)); berry.log.addString(exception_s, nullptr, "\n"); - // AddLog_P(LOG_LEVEL_INFO, PSTR(">>> %s"), exception_s); + // AddLog(LOG_LEVEL_INFO, PSTR(">>> %s"), exception_s); be_pop(berry.vm, 2); } } while(0); @@ -602,7 +602,7 @@ void HandleBerryConsoleRefresh(void) if (svalue.length()) { berry.log.reset(); // clear all previous logs berry.repl_active = true; // start recording - // AddLog_P(LOG_LEVEL_INFO, PSTR("BRY: received command %s"), svalue.c_str()); + // AddLog(LOG_LEVEL_INFO, PSTR("BRY: received command %s"), svalue.c_str()); berry.log.addString(svalue.c_str(), nullptr, BERRY_CONSOLE_CMD_DELIMITER); // Call berry @@ -655,7 +655,7 @@ void HandleBerryConsole(void) // String svalue = Webserver->arg(F("c1")); // if (svalue.length() && (svalue.length() < MQTT_MAX_PACKET_SIZE)) { // // TODO run command and store result -// // AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_COMMAND "%s"), svalue.c_str()); +// // AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_COMMAND "%s"), svalue.c_str()); // // ExecuteWebCommand((char*)svalue.c_str(), SRC_WEBCONSOLE); // } diff --git a/tasmota/xdrv_53_projector_ctrl.ino b/tasmota/xdrv_53_projector_ctrl.ino index 40c8d4a9f..6e559b71e 100644 --- a/tasmota/xdrv_53_projector_ctrl.ino +++ b/tasmota/xdrv_53_projector_ctrl.ino @@ -103,7 +103,7 @@ projector_ctrl_pre_init(void) sc = (struct projector_ctrl_softc_s *)malloc(sizeof(*sc)); if (sc == NULL) { - AddLog_P(LOG_LEVEL_ERROR, PSTR(PROJECTOR_CTRL_LOGNAME ": unable to allocate state")); + AddLog(LOG_LEVEL_ERROR, PSTR(PROJECTOR_CTRL_LOGNAME ": unable to allocate state")); return; } @@ -113,7 +113,7 @@ projector_ctrl_pre_init(void) Pin(GPIO_PROJECTOR_CTRL_TX), 2); if (!sc->sc_serial->begin(baudrate, 2)) { - AddLog_P(LOG_LEVEL_ERROR, PSTR(PROJECTOR_CTRL_LOGNAME ": unable to begin serial " + AddLog(LOG_LEVEL_ERROR, PSTR(PROJECTOR_CTRL_LOGNAME ": unable to begin serial " "(baudrate %d)"), baudrate); goto del; } @@ -125,7 +125,7 @@ projector_ctrl_pre_init(void) sc->sc_device = ++(TasmotaGlobal.devices_present); /* claim a POWER device slot */ - AddLog_P(LOG_LEVEL_INFO, PSTR(PROJECTOR_CTRL_LOGNAME ": new RELAY%d, polling serial for Projector status"), sc->sc_device); + AddLog(LOG_LEVEL_INFO, PSTR(PROJECTOR_CTRL_LOGNAME ": new RELAY%d, polling serial for Projector status"), sc->sc_device); projector_ctrl_sc = sc; return; @@ -156,13 +156,13 @@ projector_ctrl_write(struct projector_ctrl_softc_s *sc, const uint8_t *bytes, co serial->write(cksum); #ifdef DEBUG_PROJECTOR_CTRL char hex_b[(len + 1) * 2]; - AddLog_P(LOG_LEVEL_DEBUG,PSTR(PROJECTOR_CTRL_LOGNAME ": RAW bytes %s %02x"), + AddLog(LOG_LEVEL_DEBUG,PSTR(PROJECTOR_CTRL_LOGNAME ": RAW bytes %s %02x"), ToHex_P((uint8_t *)bytes, len, hex_b, sizeof(hex_b)), cksum); #endif //DEBUG_PROJECTOR_CTRL #else //!USE_PROJECTOR_CTRL_NEC #ifdef DEBUG_PROJECTOR_CTRL char hex_b[(len + 1) * 2]; - AddLog_P(LOG_LEVEL_DEBUG,PSTR(PROJECTOR_CTRL_LOGNAME ": RAW bytes %s"), + AddLog(LOG_LEVEL_DEBUG,PSTR(PROJECTOR_CTRL_LOGNAME ": RAW bytes %s"), ToHex_P((uint8_t *)bytes, len, hex_b, sizeof(hex_b))); #endif //DEBUG_PROJECTOR_CTRL #endif //!USE_PROJECTOR_CTRL_NEC @@ -182,7 +182,7 @@ projector_ctrl_request(struct projector_ctrl_softc_s *sc, const uint8_t command) if ((sc->sc_dev_state!=PROJECTOR_CTRL_DEV_UNKNOWN)&&(sc->sc_ser_state!=PROJECTOR_CTRL_S_IDLE)) { if ((command!=PROJECTOR_CTRL_S_QRY_PWR)&&(command!=PROJECTOR_CTRL_S_QRY_TYPE)) { sc->sc_ser_next_cmd=(projector_ctrl_serial_state_e)command; - AddLog_P(LOG_LEVEL_INFO, PSTR(PROJECTOR_CTRL_LOGNAME + AddLog(LOG_LEVEL_INFO, PSTR(PROJECTOR_CTRL_LOGNAME ": Serial CMD %02x already running, enqueueing next (%02x)"), sc->sc_ser_state, command); }; return; @@ -199,7 +199,7 @@ projector_ctrl_request(struct projector_ctrl_softc_s *sc, const uint8_t command) sc->sc_ser_next_cmd=PROJECTOR_CTRL_S_UNCONNECTED; sc->sc_ticks=0; #ifdef DEBUG_PROJECTOR_CTRL - AddLog_P(LOG_LEVEL_DEBUG, PSTR(PROJECTOR_CTRL_LOGNAME + AddLog(LOG_LEVEL_DEBUG, PSTR(PROJECTOR_CTRL_LOGNAME ": Sending CMD %02x"), command); #endif //DEBUG_PROJECTOR_CTRL projector_ctrl_write(sc,e->send_codes,e->send_len); @@ -207,7 +207,7 @@ projector_ctrl_request(struct projector_ctrl_softc_s *sc, const uint8_t command) } }; #ifdef DEBUG_PROJECTOR_CTRL - AddLog_P(LOG_LEVEL_DEBUG, PSTR(PROJECTOR_CTRL_LOGNAME + AddLog(LOG_LEVEL_DEBUG, PSTR(PROJECTOR_CTRL_LOGNAME ": Undefined serial command %02x"), command); #endif //DEBUG_PROJECTOR_CTRL return; @@ -227,7 +227,7 @@ projector_ctrl_parse(struct projector_ctrl_softc_s *sc, const uint8_t byte) case PROJECTOR_CTRL_S_IDLE: case PROJECTOR_CTRL_S_UNCONNECTED: #ifdef DEBUG_PROJECTOR_CTRL - AddLog_P(LOG_LEVEL_DEBUG, PSTR(PROJECTOR_CTRL_LOGNAME + AddLog(LOG_LEVEL_DEBUG, PSTR(PROJECTOR_CTRL_LOGNAME ": Spurious input in state %02x, got %02x, going UNCONNECTED"), nstate, byte); #endif //DEBUG_PROJECTOR_CTRL return(PROJECTOR_CTRL_S_UNCONNECTED); @@ -239,18 +239,18 @@ projector_ctrl_parse(struct projector_ctrl_softc_s *sc, const uint8_t byte) if (byte==cmd->pass_first_byte){ sc->sc_ser_result=PROJECTOR_CTRL_R_PASS; #ifdef DEBUG_PROJECTOR_CTRL - AddLog_P(LOG_LEVEL_DEBUG, PSTR(PROJECTOR_CTRL_LOGNAME + AddLog(LOG_LEVEL_DEBUG, PSTR(PROJECTOR_CTRL_LOGNAME ": CMD %02x PASS, 1st byte %02x"), nstate, byte); #endif //DEBUG_PROJECTOR_CTRL }else if (byte==cmd->fail_first_byte){ sc->sc_ser_result=PROJECTOR_CTRL_R_FAIL; #ifdef DEBUG_PROJECTOR_CTRL - AddLog_P(LOG_LEVEL_DEBUG, PSTR(PROJECTOR_CTRL_LOGNAME + AddLog(LOG_LEVEL_DEBUG, PSTR(PROJECTOR_CTRL_LOGNAME ": CMD %02x FAIL, 1st byte %02x"), nstate, byte); #endif //DEBUG_PROJECTOR_CTRL }else{ #ifdef DEBUG_PROJECTOR_CTRL - AddLog_P(LOG_LEVEL_DEBUG, PSTR(PROJECTOR_CTRL_LOGNAME + AddLog(LOG_LEVEL_DEBUG, PSTR(PROJECTOR_CTRL_LOGNAME ": CMD %02x UNKNOWN, 1st byte %02x, going UNCONNECTED"), nstate, byte); #endif //DEBUG_PROJECTOR_CTRL return(PROJECTOR_CTRL_S_UNCONNECTED); @@ -265,7 +265,7 @@ projector_ctrl_parse(struct projector_ctrl_softc_s *sc, const uint8_t byte) #ifdef USE_PROJECTOR_CTRL_NEC if(sc->sc_ser_sum!=byte){ #ifdef DEBUG_PROJECTOR_CTRL - AddLog_P(LOG_LEVEL_DEBUG, PSTR(PROJECTOR_CTRL_LOGNAME + AddLog(LOG_LEVEL_DEBUG, PSTR(PROJECTOR_CTRL_LOGNAME ": Failed cksum for CMD %02x. Got %02x bytes, computed cksum: %02x, recevied cksum: %02x, going UNCONNECTED"), nstate, sc->sc_ser_len, sc->sc_ser_sum, byte); #endif //DEBUG_PROJECTOR_CTRL @@ -274,7 +274,7 @@ projector_ctrl_parse(struct projector_ctrl_softc_s *sc, const uint8_t byte) #endif //USE_PROJECTOR_CTRL_NEC { #ifdef DEBUG_PROJECTOR_CTRL - AddLog_P(LOG_LEVEL_DEBUG, PSTR(PROJECTOR_CTRL_LOGNAME + AddLog(LOG_LEVEL_DEBUG, PSTR(PROJECTOR_CTRL_LOGNAME ": CMD %02x PASS, got %02x bytes, retval %02x, going IDLE"), nstate, sc->sc_ser_len, sc->sc_ser_value); #endif //DEBUG_PROJECTOR_CTRL nstate=PROJECTOR_CTRL_S_IDLE; @@ -291,7 +291,7 @@ projector_ctrl_parse(struct projector_ctrl_softc_s *sc, const uint8_t byte) #ifdef USE_PROJECTOR_CTRL_NEC if(sc->sc_ser_sum!=byte){ #ifdef DEBUG_PROJECTOR_CTRL - AddLog_P(LOG_LEVEL_DEBUG, PSTR(PROJECTOR_CTRL_LOGNAME + AddLog(LOG_LEVEL_DEBUG, PSTR(PROJECTOR_CTRL_LOGNAME ": Failed cksum for CMD %02x. Got %02x bytes, computed cksum: %02x, receied cksum: %02x, going UNCONNECTED"), nstate, sc->sc_ser_len, sc->sc_ser_sum, byte); #endif //DEBUG_PROJECTOR_CTRL @@ -300,7 +300,7 @@ projector_ctrl_parse(struct projector_ctrl_softc_s *sc, const uint8_t byte) #endif //USE_PROJECTOR_CTRL_NEC { #ifdef DEBUG_PROJECTOR_CTRL - AddLog_P(LOG_LEVEL_DEBUG, PSTR(PROJECTOR_CTRL_LOGNAME + AddLog(LOG_LEVEL_DEBUG, PSTR(PROJECTOR_CTRL_LOGNAME ": CMD %02x FAIL, got %02x bytes, retval %02x, going idle"), nstate, sc->sc_ser_len, sc->sc_ser_value); #endif //DEBUG_PROJECTOR_CTRL nstate=PROJECTOR_CTRL_S_IDLE; @@ -333,13 +333,13 @@ projector_ctrl_loop(struct projector_ctrl_softc_s *sc) case PROJECTOR_CTRL_S_UNCONNECTED: if (sc->sc_dev_state!=PROJECTOR_CTRL_DEV_UNKNOWN){ sc->sc_dev_state=PROJECTOR_CTRL_DEV_UNKNOWN; - AddLog_P(LOG_LEVEL_INFO,PSTR(PROJECTOR_CTRL_LOGNAME ": DISCONNECTED(unexpected input)")); + AddLog(LOG_LEVEL_INFO,PSTR(PROJECTOR_CTRL_LOGNAME ": DISCONNECTED(unexpected input)")); } break; case PROJECTOR_CTRL_S_IDLE: if ((oldstate==PROJECTOR_CTRL_S_QRY_PWR)&&(sc->sc_ser_result==PROJECTOR_CTRL_R_PASS)){ if(sc->sc_dev_state==PROJECTOR_CTRL_DEV_UNKNOWN){ - AddLog_P(LOG_LEVEL_INFO,PSTR(PROJECTOR_CTRL_LOGNAME ": CONNECTED")); + AddLog(LOG_LEVEL_INFO,PSTR(PROJECTOR_CTRL_LOGNAME ": CONNECTED")); }; if(( (sc->sc_ser_value==PROJECTOR_CTRL_QRYPWR_ON) ||(sc->sc_ser_value==PROJECTOR_CTRL_QRYPWR_COOLING) @@ -396,7 +396,7 @@ projector_ctrl_tick(struct projector_ctrl_softc_s *sc) }; }else if(sc->sc_ticks > sc->sc_cmd_info->timeout_ticks){ //current CMD has ran out of time, drop connection - AddLog_P(LOG_LEVEL_INFO,PSTR(PROJECTOR_CTRL_LOGNAME ": DISCONNECTED(timeout)")); + AddLog(LOG_LEVEL_INFO,PSTR(PROJECTOR_CTRL_LOGNAME ": DISCONNECTED(timeout)")); sc->sc_dev_state=PROJECTOR_CTRL_DEV_UNKNOWN; sc->sc_ser_state=PROJECTOR_CTRL_S_UNCONNECTED; }; @@ -410,7 +410,7 @@ projector_ctrl_set_power(struct projector_ctrl_softc_s *sc) if (TasmotaGlobal.active_device==PROJECTOR_CTRL_PWR_BY_RELAY){ if ((sc->sc_dev_state == PROJECTOR_CTRL_DEV_PWR_ON) && (0==bitRead(XdrvMailbox.index, PROJECTOR_CTRL_PWR_BY_RELAY -1))) { TasmotaGlobal.power = bitSet(TasmotaGlobal.power,PROJECTOR_CTRL_PWR_BY_RELAY -1); - AddLog_P(LOG_LEVEL_INFO,PSTR(PROJECTOR_CTRL_LOGNAME ": Keep RELAY" xxstr(PROJECTOR_CTRL_PWR_BY_RELAY) " ON")); + AddLog(LOG_LEVEL_INFO,PSTR(PROJECTOR_CTRL_LOGNAME ": Keep RELAY" xxstr(PROJECTOR_CTRL_PWR_BY_RELAY) " ON")); } else { return(false); }; diff --git a/tasmota/xdrv_79_esp32_ble.ino b/tasmota/xdrv_79_esp32_ble.ino index 9b816c63f..2aba0896c 100644 --- a/tasmota/xdrv_79_esp32_ble.ino +++ b/tasmota/xdrv_79_esp32_ble.ino @@ -974,14 +974,14 @@ int SafeAddLog_P(uint32_t loglevel, PGM_P formatP, ...) { vsnprintf_P(BLE_temp_log_data, maxlen, formatP, arg); va_end(arg); #ifdef USE_NATIVE_LOGGING - AddLog_P(loglevel, PSTR("%s"), BLE_temp_log_data); + AddLog(loglevel, PSTR("%s"), BLE_temp_log_data); return 1; #else if (thistask == TasmotaMainTask){ loglevel = LOG_LEVEL_ERROR; snprintf(BLE_temp_log_data + strlen(BLE_temp_log_data), 13, "-!MAINTHREAD!"); xSemaphoreGive(SafeLogMutex); // release mutex - AddLog_P(loglevel, PSTR("%s"), BLE_temp_log_data); + AddLog(loglevel, PSTR("%s"), BLE_temp_log_data); return 0; } @@ -3395,7 +3395,7 @@ static void BLEDiag() uint32_t totalCount = BLEAdvertisment.totalCount; uint32_t deviceCount = seenDevices.size(); #ifdef BLE_ESP32_DEBUG - if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: scans:%u,advertisements:%u,devices:%u,resets:%u,BLEStop:%d,BLERunning:%d,BLERunningScan:%d,BLELoopCount:%u,BLEOpCount:%u"), BLEScanCount, totalCount, deviceCount, BLEResets, BLEStop, BLERunning, BLERunningScan, BLELoopCount, BLEOpCount); + if (BLEDebugMode > 0) AddLog(LOG_LEVEL_INFO,PSTR("BLE: scans:%u,advertisements:%u,devices:%u,resets:%u,BLEStop:%d,BLERunning:%d,BLERunningScan:%d,BLELoopCount:%u,BLEOpCount:%u"), BLEScanCount, totalCount, deviceCount, BLEResets, BLEStop, BLERunning, BLERunningScan, BLELoopCount, BLEOpCount); #endif } diff --git a/tasmota/xdrv_98_product_test.ino b/tasmota/xdrv_98_product_test.ino new file mode 100644 index 000000000..39bdec35e --- /dev/null +++ b/tasmota/xdrv_98_product_test.ino @@ -0,0 +1,407 @@ +/* + xdrv_98_product_test.ino - Product test for Sonoff-Tasmota + + Copyright (C) 2021 Theo Arends and Adrian Scillato + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +//#define PRODUCT_TEST // Enable this to include Tuya product test protocol +#define PRODUCT_TEST_DEBUG // Enable to compile status messages as shown below + +#define PRODUCT_TEST_SSID "FACILITY_SSID" // <-- CHANGE THIS TO YOURS + +#define PRODUCT_VOLTAGE "220.0" // Volt +#define PRODUCT_CURRENT "392.0" // milliAmpere +#define PRODUCT_POWER "87.0" // Watt +#define PRODUCT_CALIBRATE_CYCLE 20 // Seconds - Need at least 8 seconds + +#define PRODUCT_SCAN_INTERVAL 8 // Seconds +#define PRODUCT_SCAN_RETRY 4 // Scan retry count + +#define PRODUCT_TEST_VERSION "3.2" + +/*********************************************************************************************\ +This code is supported starting with Tasmota version 9.2.0. +The product test will run at power on when both SSids are empty. +The test can be restarted by power cycling off then on. + +*** Flash firmware +Write binary firmware.bin + esptool.py --port COM4 write_flash -fs 1MB -fm dout 0x0 firmware.bin + +*** Typical succesful product test with succesful wifi scan +Initial Power ON + 00:00:00 CFG: Use defaults + 00:00:00 TST: Product test v3.0 + 00:00:00 TST: 1/6 Product test started using ssid tuya_mdev_test1 + 00:00:00 SRC: Restart + 00:00:00 Project sonoff Sonoff Version 6.4.1.19(basic)-2_4_2 + 00:00:00 CFG: Saved to flash at FA, Count 2, Bytes 3584 + 00:00:00 WIF: WifiManager active for 3 minutes + 00:00:00 WIF: Wifimanager set AccessPoint + 00:00:00 HTP: Web server active on sonoff-2927 with IP address 192.168.4.1 + 00:00:01 CFG: Saved to flash at F9, Count 3, Bytes 3584 + 00:00:04 TST: Scanned SSId1 indebuurt1 + 00:00:04 TST: Scanned SSId2 indebuurt2 + 00:00:04 TST: Scanned SSId3 indebuurt3 + 00:00:04 TST: Scanned SSId4 tuya_mdev_test1 + 00:00:04 TST: 2/6 Wifi found + 00:00:13 APP: Boot Count 1 +Button pressed + 00:00:15 TST: 3/6 Button pressed first time - Toggle relay and led once + 00:00:15 APP: Button1 immediate + 00:00:15 SRC: Button + 00:00:15 RSL: stat/sonoff/RESULT = {"POWER":"ON"} + 00:00:15 RSL: stat/sonoff/POWER = ON +Button pressed again + 00:00:20 TST: 4/6 Button pressed second time - Toggle relay and led three times + 00:00:21 RSL: stat/sonoff/RESULT = {"POWER":"OFF"} + 00:00:21 RSL: stat/sonoff/POWER = OFF + 00:00:22 RSL: stat/sonoff/RESULT = {"POWER":"ON"} + 00:00:22 RSL: stat/sonoff/POWER = ON + 00:00:23 RSL: stat/sonoff/RESULT = {"POWER":"OFF"} + 00:00:23 RSL: stat/sonoff/POWER = OFF + 00:00:24 TST: 5/6 Button test finished - Start calibration + 00:00:27 CFG: Saved to flash at FB, Count 4, Bytes 3584 + 00:00:27 TST: 6/6 Product test finished - Save to power off +Device can and should be powered off now as it is in an unknown state + +*** Restore Product test prerequisite + Power off device +\*********************************************************************************************/ + +#ifdef PRODUCT_TEST +/*********************************************************************************************\ + * Product test procedure support + * + * - Initiate test if power on and no user SSIDs configured + * - Init test environment (Led OFF, flash save off) + * - Wait for wifi scan to find PRODUCT_TEST_SSID then start flashing led every 250 mSec + * - Wait for user press button then turn relay and led ON + * - Wait for user press button again then toggle relay and led 3 times and increment bootcount + * - If energy monitoring is detected calibrate Voltage, Current and Power + * - Wait for power down +\*********************************************************************************************/ + +/*********************************************************************************************\ + * Examples to test a particular device: + * + * Set in user_config_override.h the following: + * + * #undef MODULE + * #define MODULE SONOFF_BASIC // [Module] Select default model (the list is kModuleNiceList() in file tasmota_template.h) + * #undef FALLBACK_MODULE + * #define FALLBACK_MODULE SONOFF_BASIC // to Select the default model as FALLBACK when the user does a RESET 1 + * + * or + * + * #define USER_TEMPLATE "{\"NAME\":\"Shelly 2.5\",\"GPIO\":[320,0,32,0,224,193,0,0,640,192,608,225,3456,4736],\"FLAG\":0,\"BASE\":18}" // [Template] Set JSON template + * + * For ESP32 examples check user_config.h + * +\*********************************************************************************************/ + + +#define XDRV_98 98 + +enum ProductTestStates { PROD_TEST_IDLE, PROD_TEST_START, PROD_TEST_WIFI, PROD_TEST_BUTTON, PROD_TEST_CALIBRATE, PROD_TEST_DONE }; + +struct PRODUCTTEST { + uint8_t state = PROD_TEST_IDLE; // No product test + uint8_t blink = 3; // Toggle relay three times + uint8_t button_step = 0; // Either initial power toggle or end of test + uint8_t last_button = 0; // Store initial power toggle last button state + uint8_t scan_interval = 2; // Seconds after power on + uint8_t scan_retry = PRODUCT_SCAN_RETRY +1; + uint8_t calibrate_state = PRODUCT_CALIBRATE_CYCLE; // Calibrate cycle max seconds + uint8_t calibrate_timer = 0; // 100mS timer + + uint16_t save_data_counter; + uint8_t ledstate; + uint8_t button_single; + uint8_t global_state; +} prodtest; + +bool ProductTestTrigger(void) +{ +// AddLog(LOG_LEVEL_INFO, PSTR("TST: resetInfo %d, sta_ssid1 (%s), sta_ssid2 (%s), save_flag %d"), resetInfo.reason, SettingsText(SET_STASSID1), SettingsText(SET_STASSID2), Settings.save_flag); + + if (((resetInfo.reason == REASON_DEFAULT_RST) || (resetInfo.reason == REASON_EXT_SYS_RST)) && // Power on + !strlen(SettingsText(SET_STASSID1)) && // No configured SSID1 + !strlen(SettingsText(SET_STASSID2)) // No configured SSID2 + ) { + return true; + } + + return false; +} + +bool ProductTestSsidFound(void) +{ + bool result = false; + + if (prodtest.scan_interval) { + prodtest.scan_interval--; + if (!prodtest.scan_interval) { + prodtest.scan_retry--; + if (prodtest.scan_retry) { + prodtest.scan_interval = PRODUCT_SCAN_INTERVAL; + int n = WiFi.scanNetworks(); + if (n > 0) { + for (int i = 0; i < n; i++) { +#ifdef PRODUCT_TEST_DEBUG + AddLog(LOG_LEVEL_DEBUG, PSTR("TST: Scanned SSId%d %s"), i +1, WiFi.SSID(i).c_str()); +#endif + if (!strcasecmp_P(WiFi.SSID(i).c_str(), PSTR(PRODUCT_TEST_SSID))) { result = true; } + } + } + } else { + if (Wifi.config_type) { + TasmotaGlobal.blinks = 255; // Re-enable wifi config blinks + } + Settings.ledstate = prodtest.ledstate; + Settings.flag.global_state = prodtest.global_state; + TasmotaGlobal.save_data_counter = prodtest.save_data_counter; +#ifdef PRODUCT_TEST_DEBUG + AddLog(LOG_LEVEL_INFO, PSTR("TST: 6/6 Product test failed")); +#endif + prodtest.state = PROD_TEST_IDLE; + } + } + } + return result; +} + +void ProductTestLedOff(void) +{ + TasmotaGlobal.blinks = 0; // No blinks + SetLedLink(0); + SetLedPower(0); +} + +void ProductTestInit(void) +{ + if (ProductTestTrigger()) { +#ifdef PRODUCT_TEST_DEBUG + TasmotaGlobal.seriallog_level = 3; // Enable more serial logging + AddLog(LOG_LEVEL_INFO, PSTR("TST: Product test v" PRODUCT_TEST_VERSION)); +#endif + // Prepare for product test procedure + prodtest.save_data_counter = TasmotaGlobal.save_data_counter; + TasmotaGlobal.save_data_counter = 32000; // Stop auto saving data - Updating Settings + prodtest.global_state = Settings.flag.global_state; + Settings.flag.global_state = 1; // Disable global state (wifi and mqtt) led blinks as it interferes with the test protocol + prodtest.ledstate = Settings.ledstate; + Settings.ledstate = 0; // Disable led power state as it interferes with the test protocol + + ProductTestLedOff(); // Signal start of test +#ifdef PRODUCT_TEST_DEBUG + AddLog(LOG_LEVEL_INFO, PSTR("TST: 1/6 Product test started using ssid " PRODUCT_TEST_SSID)); +#endif // PRODUCT_TEST_DEBUG + prodtest.state = PROD_TEST_START; + } else { + prodtest.state = PROD_TEST_IDLE; + } +} + +bool ProductTestButton(void) +{ + bool result = false; // Ignore + + if (prodtest.state > PROD_TEST_IDLE) { + result = true; // Disable button processing + + if (PROD_TEST_WIFI == prodtest.state) { + if ((PRESSED == XdrvMailbox.payload) && (NOT_PRESSED == prodtest.last_button)) { // Button pressed + if (0 == prodtest.button_step) { +#ifdef PRODUCT_TEST_DEBUG + AddLog(LOG_LEVEL_INFO, PSTR("TST: 3/6 Button pressed first time - Toggle relay and led once")); +#endif + ProductTestLedOff(); // Signal button pressed and activate relay + Settings.ledstate = 1; // Enable led power state + prodtest.button_step++; + result = false; // Process normal button press which will turn relay and led on + } else { +#ifdef PRODUCT_TEST_DEBUG + AddLog(LOG_LEVEL_INFO, PSTR("TST: 4/6 Button pressed second time - Toggle relay and led three times")); +#endif + prodtest.state = PROD_TEST_BUTTON; + result = true; // Disable further button processing + } + } + prodtest.last_button = XdrvMailbox.payload; + } + } + + return result; +} + +void ProductTestEverySecond(void) +{ + if (PROD_TEST_IDLE == prodtest.state) { + return; + } + else if (PROD_TEST_START == prodtest.state) { + TasmotaGlobal.blinks = 0; // Disable blinks initiated by WifiManager + if (ProductTestSsidFound()) { +#ifdef PRODUCT_TEST_DEBUG + AddLog(LOG_LEVEL_INFO, PSTR("TST: 2/6 Wifi found")); +#endif + TasmotaGlobal.sleep = 0; // Disable sleep + TasmotaGlobal.restart_flag = 0; // No restart and enable blinks + TasmotaGlobal.ota_state_flag = 0; // No OTA and enable blinks + + prodtest.button_single = Settings.flag.button_single; + Settings.flag.button_single = 1; // Allow only single press + + TasmotaGlobal.blinks = 255; // Signal wifi connection with blinks + prodtest.state = PROD_TEST_WIFI; + } + } + else if (PROD_TEST_BUTTON == prodtest.state) { + if (prodtest.blink) { + prodtest.blink--; + ExecuteCommandPower(1, POWER_TOGGLE, SRC_IGNORE); // Toggle relay and led + } else { + if (TasmotaGlobal.energy_driver != ENERGY_NONE) { + prodtest.state = PROD_TEST_CALIBRATE; + } else { +#ifdef PRODUCT_TEST_DEBUG + AddLog(LOG_LEVEL_INFO, PSTR("TST: 5/6 Button test finished")); +#endif + prodtest.state = PROD_TEST_DONE; + } + } + } + else if (PROD_TEST_CALIBRATE == prodtest.state) { + if (prodtest.calibrate_state) { + prodtest.calibrate_state--; + if (PRODUCT_CALIBRATE_CYCLE -1 == prodtest.calibrate_state) { +#ifdef PRODUCT_TEST_DEBUG + AddLog(LOG_LEVEL_INFO, PSTR("TST: 5/6 Start calibration")); +#endif + ExecuteCommandPower(1, POWER_ON, SRC_IGNORE); // On relay and led - start energy measurment + } + else if ((prodtest.calibrate_state < PRODUCT_CALIBRATE_CYCLE -4) && (prodtest.calibrate_state > 1)) { + // Allow a few seconds before starting calibration + uint8_t all_done = 0; + if (HLW_PREF_PULSE == Settings.energy_power_calibration) { + char set_value[] = PRODUCT_POWER; + XdrvMailbox.data = set_value; + XdrvMailbox.data_len = sizeof(set_value); + Energy.command_code = CMND_POWERSET; + HlwCommand(); // Get calibrated setting + } else { + all_done++; + } + if (HLW_UREF_PULSE == Settings.energy_voltage_calibration) { + char set_value[] = PRODUCT_VOLTAGE; + XdrvMailbox.data = set_value; + XdrvMailbox.data_len = sizeof(set_value); + Energy.command_code = CMND_VOLTAGESET; + HlwCommand(); // Get calibrated setting + } else { + all_done++; + } + if (HLW_IREF_PULSE == Settings.energy_current_calibration) { + char set_value[] = PRODUCT_CURRENT; + XdrvMailbox.data = set_value; + XdrvMailbox.data_len = sizeof(set_value); + Energy.command_code = CMND_CURRENTSET; + HlwCommand(); // Get calibrated setting + } else { + all_done++; + } + if (3 == all_done) { + prodtest.calibrate_state = 2; + } + } + else if (1 == prodtest.calibrate_state) { + ExecuteCommandPower(1, POWER_OFF, SRC_IGNORE); // Off relay and led - stop energy measurment + } + else if (0 == prodtest.calibrate_state) { + // Save calibration data + uint32_t power_calibration = Settings.energy_power_calibration; + uint32_t voltage_calibration = Settings.energy_voltage_calibration; + uint32_t current_calibration = Settings.energy_current_calibration; + SettingsDefaultSet1(); // Reset any Settings change + SettingsDefaultSet2(); // Init default settings + // Store calibration data + Settings.energy_power_calibration = power_calibration; + Settings.energy_voltage_calibration = voltage_calibration; + Settings.energy_current_calibration = current_calibration; + SettingsSave(2); + TasmotaGlobal.save_data_counter = 32000; // Stop auto saving data - Updating Settings + } + } else { + prodtest.state = PROD_TEST_DONE; + SetLedLink(1); // Wifi led on - Succesful calibration + } + } + else if (PROD_TEST_DONE == prodtest.state) { +#ifdef PRODUCT_TEST_DEBUG + AddLog(LOG_LEVEL_INFO, PSTR("TST: 6/6 Product test finished - Save to power off")); +#endif + + while (1) { + OsWatchLoop(); // Feed OsWatch timer to prevent restart + delay(50); // Satisfy SDK + } + } +} + +void ProductTestEvery100mSecond(void) +{ + if (PROD_TEST_CALIBRATE == prodtest.state) { + // Blink wifi led 2 flashes every 3 seconds - Calibrating + prodtest.calibrate_timer++; + if (1 == prodtest.calibrate_timer) { + SetLedLink(0); // Wifi led off + } + else if (12 == prodtest.calibrate_timer) { + SetLedLink(1); // Wifi led on + } + else if (16 == prodtest.calibrate_timer) { + prodtest.calibrate_timer = 0; + } + } +} + +/*********************************************************************************************\ + * Interface +\*********************************************************************************************/ + +bool Xdrv98(uint8_t function) +{ + bool result = false; + + switch (function) { + case FUNC_EVERY_100_MSECOND: + ProductTestEvery100mSecond(); + break; + case FUNC_EVERY_SECOND: + ProductTestEverySecond(); + break; + case FUNC_BUTTON_PRESSED: + result = ProductTestButton(); + break; + case FUNC_PRE_INIT: + ProductTestInit(); + break; + } + return result; +} + +#endif // PRODUCT_TEST diff --git a/tasmota/xdrv_99_debug.ino b/tasmota/xdrv_99_debug.ino index 6c4c57ce3..27b4f163d 100644 --- a/tasmota/xdrv_99_debug.ino +++ b/tasmota/xdrv_99_debug.ino @@ -480,7 +480,7 @@ void SetFlashMode(uint8_t mode) void CmndHelp(void) { - AddLog_P(LOG_LEVEL_INFO, PSTR("HLP: %s"), kDebugCommands); + AddLog(LOG_LEVEL_INFO, PSTR("HLP: %s"), kDebugCommands); ResponseCmndDone(); } diff --git a/tasmota/xlgt_05_sonoff_l1.ino b/tasmota/xlgt_05_sonoff_l1.ino index 23ed21e8d..8b30f1c9a 100644 --- a/tasmota/xlgt_05_sonoff_l1.ino +++ b/tasmota/xlgt_05_sonoff_l1.ino @@ -78,7 +78,7 @@ void SnfL1SendDelayed(void) { void SnfL1Send(void) { #ifdef SONOFF_L1_DEBUG1 - AddLog_P(LOG_LEVEL_DEBUG, PSTR("SL1: Send %s"), Snfl1.buffer); + AddLog(LOG_LEVEL_DEBUG, PSTR("SL1: Send %s"), Snfl1.buffer); #endif Serial.print(Snfl1.buffer); Serial.write(0x1B); @@ -106,7 +106,7 @@ bool SnfL1SerialInput(void) { // AT+UPDATE="sequence":"34906","switch":"on","light_type":1,"colorR":0,"colorG":16,"colorB":0,"bright":6,"mode":1 // AT+UPDATE="switch":"on","light_type":1,"colorR":255,"colorG":0,"colorB":0,"bright":6,"mode":1,"speed":100,"sensitive":10 #ifdef SONOFF_L1_DEBUG1 - AddLog_P(LOG_LEVEL_DEBUG, PSTR("SL1: Rcvd %s"), TasmotaGlobal.serial_in_buffer); + AddLog(LOG_LEVEL_DEBUG, PSTR("SL1: Rcvd %s"), TasmotaGlobal.serial_in_buffer); #endif if (!strncmp(TasmotaGlobal.serial_in_buffer +3, "RESULT", 6)) { #ifdef SONOFF_L1_ALLOW_REMOTE_INTERRUPT diff --git a/tasmota/xnrg_15_teleinfo.ino b/tasmota/xnrg_15_teleinfo.ino index cc2b0f584..c989f60c2 100755 --- a/tasmota/xnrg_15_teleinfo.ino +++ b/tasmota/xnrg_15_teleinfo.ino @@ -686,7 +686,7 @@ bool TInfoCmd(void) { // At least "EnergyConfig" if (CMND_ENERGYCONFIG == Energy.command_code) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("TIC: len %d, data '%s'"), XdrvMailbox.data_len, XdrvMailbox.data ? XdrvMailbox.data : "null" ); + AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: len %d, data '%s'"), XdrvMailbox.data_len, XdrvMailbox.data ? XdrvMailbox.data : "null" ); // Just "EnergyConfig" no more parameter // Show Teleinfo configuration @@ -703,7 +703,7 @@ bool TInfoCmd(void) { GetTextIndexed(mode_name, MAX_TINFO_COMMAND_NAME, index_mode, kTInfo_Commands); GetTextIndexed(raw_name, MAX_TINFO_COMMAND_NAME, index_raw, kTInfo_Commands); - AddLog_P(LOG_LEVEL_INFO, TELEINFO_COMMAND_SETTINGS, mode_name, raw_name, Settings.teleinfo.raw_skip, Settings.teleinfo.raw_limit); + AddLog(LOG_LEVEL_INFO, TELEINFO_COMMAND_SETTINGS, mode_name, raw_name, Settings.teleinfo.raw_skip, Settings.teleinfo.raw_limit); serviced = true; @@ -730,7 +730,7 @@ bool TInfoCmd(void) { int command_code = GetCommandCode(command, sizeof(command), pParam, kTInfo_Commands); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("TIC: param '%s' cmnd %d"), pParam, command_code); + AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: param '%s' cmnd %d"), pParam, command_code); switch (command_code) { case CMND_TELEINFO_STANDARD: @@ -755,7 +755,7 @@ bool TInfoCmd(void) { // Change mode Settings.teleinfo.mode_standard = command_code == CMND_TELEINFO_STANDARD ? 1 : 0; - AddLog_P(LOG_LEVEL_INFO, PSTR("TIC: '%s' mode"), mode_name); + AddLog(LOG_LEVEL_INFO, PSTR("TIC: '%s' mode"), mode_name); // Re init teleinfo (LibTeleinfo always free linked list on init) TInfoInit(); @@ -763,7 +763,7 @@ bool TInfoCmd(void) { serviced = true; } else { - AddLog_P(LOG_LEVEL_INFO, PSTR("TIC: No change to '%s' mode"), mode_name); + AddLog(LOG_LEVEL_INFO, PSTR("TIC: No change to '%s' mode"), mode_name); } } break; @@ -787,7 +787,7 @@ bool TInfoCmd(void) { Settings.teleinfo.raw_report_changed = command_code == CMND_TELEINFO_RAW_CHANGE ? 1 : 0; } - AddLog_P(LOG_LEVEL_INFO, PSTR("TIC: Raw to '%s'"), raw_name); + AddLog(LOG_LEVEL_INFO, PSTR("TIC: Raw to '%s'"), raw_name); serviced = true; } break; @@ -808,22 +808,22 @@ bool TInfoCmd(void) { Settings.teleinfo.raw_skip = raw_skip; if (raw_skip ==0) { - AddLog_P(LOG_LEVEL_INFO, PSTR("TIC: Raw no skip")); + AddLog(LOG_LEVEL_INFO, PSTR("TIC: Raw no skip")); } else { - AddLog_P(LOG_LEVEL_INFO, PSTR("TIC: Raw each %d frame(s)"), raw_skip+1); + AddLog(LOG_LEVEL_INFO, PSTR("TIC: Raw each %d frame(s)"), raw_skip+1); } serviced = true; } else { - AddLog_P(LOG_LEVEL_INFO, PSTR("TIC: skip can be 0 to 255")); + AddLog(LOG_LEVEL_INFO, PSTR("TIC: skip can be 0 to 255")); } } else { - AddLog_P(LOG_LEVEL_INFO, PSTR("TIC: no skip value")); + AddLog(LOG_LEVEL_INFO, PSTR("TIC: no skip value")); } } break; default: - AddLog_P(LOG_LEVEL_INFO, PSTR("TIC: bad cmd param '%s'"), pParam); + AddLog(LOG_LEVEL_INFO, PSTR("TIC: bad cmd param '%s'"), pParam); break; } diff --git a/tasmota/xnrg_19_cse7761.ino b/tasmota/xnrg_19_cse7761.ino index 478d5db62..e2fc9257b 100644 --- a/tasmota/xnrg_19_cse7761.ino +++ b/tasmota/xnrg_19_cse7761.ino @@ -516,13 +516,13 @@ void Cse7761DumpRegs(void) { for (uint32_t i = 0; i < 23; i++) { snprintf_P(reg_data, sizeof(reg_data), PSTR("%s%s%8X"), reg_data, (i) ? "," : "", reg_num[i]); } - AddLog_P(LOG_LEVEL_DEBUG, PSTR("C61: RegDump %s"), reg_data); + AddLog(LOG_LEVEL_DEBUG, PSTR("C61: RegDump %s"), reg_data); reg_data[0] = '\0'; for (uint32_t i = 0; i < 23; i++) { snprintf_P(reg_data, sizeof(reg_data), PSTR("%s%s%08X"), reg_data, (i) ? "," : "", registers[i]); } - AddLog_P(LOG_LEVEL_DEBUG, PSTR("C61: RegDump %s"), reg_data); + AddLog(LOG_LEVEL_DEBUG, PSTR("C61: RegDump %s"), reg_data); } */ diff --git a/tasmota/xnrg_20_dummy.ino b/tasmota/xnrg_20_dummy.ino index f1bac903b..550add11e 100644 --- a/tasmota/xnrg_20_dummy.ino +++ b/tasmota/xnrg_20_dummy.ino @@ -101,7 +101,7 @@ bool NrgDummyCommand(void) { } } else if (CMND_ENERGYCONFIG == Energy.command_code) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("NRG: Config index %d, payload %d, data '%s'"), + AddLog(LOG_LEVEL_DEBUG, PSTR("NRG: Config index %d, payload %d, data '%s'"), XdrvMailbox.index, XdrvMailbox.payload, XdrvMailbox.data ? XdrvMailbox.data : "null" ); } else serviced = false; // Unknown command diff --git a/tasmota/xsns_15_mhz19.ino b/tasmota/xsns_15_mhz19.ino index 1536fbd25..15d269cbd 100644 --- a/tasmota/xsns_15_mhz19.ino +++ b/tasmota/xsns_15_mhz19.ino @@ -123,7 +123,7 @@ size_t MhzSendCmd(uint8_t command_id) memcpy_P(&mhz_send[6], kMhzCommands[command_id] + sizeof(uint16_t), sizeof(uint16_t)); mhz_send[8] = MhzCalculateChecksum(mhz_send); -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("Final MhzCommand: %x %x %x %x %x %x %x %x %x"),mhz_send[0],mhz_send[1],mhz_send[2],mhz_send[3],mhz_send[4],mhz_send[5],mhz_send[6],mhz_send[7],mhz_send[8]); +// AddLog(LOG_LEVEL_DEBUG, PSTR("Final MhzCommand: %x %x %x %x %x %x %x %x %x"),mhz_send[0],mhz_send[1],mhz_send[2],mhz_send[3],mhz_send[4],mhz_send[5],mhz_send[6],mhz_send[7],mhz_send[8]); return MhzSerial->write(mhz_send, sizeof(mhz_send)); } diff --git a/tasmota/xsns_31_ccs811_v2.ino b/tasmota/xsns_31_ccs811_v2.ino index a6e54dabb..5a3d65e19 100644 --- a/tasmota/xsns_31_ccs811_v2.ino +++ b/tasmota/xsns_31_ccs811_v2.ino @@ -150,7 +150,7 @@ void CCS811ReadMailboxValue( uint8_t address, uint8_t mailbox, byte * pbuf, uint for (uint8_t i = 0; i < buflen; i++) { *(pbuf + i) = Wire.read(); #ifdef CCS811_DEBUG - AddLog_P(LOG_LEVEL_DEBUG, PSTR( D_LOG_DEBUG D_PRFX_CCS811 " reading byte %u: 0%02x / %u"), i, *(pbuf + i), *(pbuf + i)); + AddLog(LOG_LEVEL_DEBUG, PSTR( D_LOG_DEBUG D_PRFX_CCS811 " reading byte %u: 0%02x / %u"), i, *(pbuf + i), *(pbuf + i)); #endif } } @@ -159,7 +159,7 @@ void CCS811WriteMailboxValue(uint8_t address, uint8_t mailbox, byte * pbuf, uint { #ifdef CCS811_DEBUG for (uint8_t i = 0; i < buflen; i++) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR( D_LOG_DEBUG D_PRFX_CCS811 " writing byte %u: 0%02x / %u"), i, *(pbuf + i), *(pbuf + i)); + AddLog(LOG_LEVEL_DEBUG, PSTR( D_LOG_DEBUG D_PRFX_CCS811 " writing byte %u: 0%02x / %u"), i, *(pbuf + i), *(pbuf + i)); } #endif Wire.beginTransmission(address); @@ -180,7 +180,7 @@ CCS811DATA * CmndCCS811SelectDeviceFromIndex(void) { if (pccsd->device_index == XdrvMailbox.index) { pccsd_command = pccsd; #ifdef CCS811_DEBUG - AddLog_P(LOG_LEVEL_DEBUG, PSTR( D_LOG_DEBUG D_PRFX_CCS811 " I2C Address: 0%02x"), pccsd_command->address); + AddLog(LOG_LEVEL_DEBUG, PSTR( D_LOG_DEBUG D_PRFX_CCS811 " I2C Address: 0%02x"), pccsd_command->address); #endif break; } diff --git a/tasmota/xsns_31_ccs811_v2_test.ino b/tasmota/xsns_31_ccs811_v2_test.ino new file mode 100644 index 000000000..8fec2aaba --- /dev/null +++ b/tasmota/xsns_31_ccs811_v2_test.ino @@ -0,0 +1,357 @@ +/* + xsns_31_ccs811_v2.ino - CCS811 gas and air quality sensor support for Tasmota + + Copyright (C) 2021 Gerhard Mutz and Theo Arends + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifdef USE_I2C +#ifdef USE_CCS811_V2_TEST +/*********************************************************************************************\ + * CCS811 - Gas (TVOC - Total Volatile Organic Compounds) and Air Quality (CO2) + * + * Source: Adafruit + * + * This driver supports one to two devices at a time at + * addressses 0x5A or/and 0x5B + * - for I2C address 0x5A, connect ADDR to GND + * - for I2C address 0x5B, connect ADDR to VCC + * NOTE: + * - Wake must be connected to GND (no sleep mode supported!) + * - depending on the breakout bouard, SDA & SCL may require + * pull-ups to VCC, e.g. 4k7R + * +\*********************************************************************************************/ + +#define XSNS_31 31 +#define XI2C_24 24 // See I2CDEVICES.md + +#define EVERYNSECONDS 5 +#define RESETCOUNT 6 + +#include "Adafruit_CCS811.h" + +uint8_t CCS811_addresses[] = { CCS811_ADDRESS, (CCS811_ADDRESS + 1) }; +#define MAXDEVICECOUNT (sizeof( CCS811_addresses) / sizeof(uint8_t)) + +typedef struct { + uint8_t address; + uint8_t device_found; + uint8_t device_index; + uint8_t device_ready; + Adafruit_CCS811 ccsinstance; + uint16_t eCO2; + uint16_t TVOC; + uint8_t refresh_count; + uint8_t reset_count; +} CCS811DATA; + +uint8_t CCS811_devices_found = 0; +CCS811DATA ccsd[ MAXDEVICECOUNT]; +CCS811DATA * pccsd; +uint32_t i; + + +#define D_CMND_CCS811 "CCS811" + +const char S_JSON_CCS811_COMMAND_XVALUE[] PROGMEM = "{\"" D_CMND_CCS811 "%s\":0x%02x}"; +const char S_JSON_CCS811_COMMAND_NVALUE[] PROGMEM = "{\"" D_CMND_CCS811 "%s\":%u}"; +const char S_JSON_CCS811_COMMAND_HWVERSION[] PROGMEM = "{\"" D_CMND_CCS811 "%s\":\"%x\"}"; +const char S_JSON_CCS811_COMMAND_FWAPPVERSION[] PROGMEM = "{\"" D_CMND_CCS811 "%s\":\"%x.%x.%x\"}"; + +const char S_JSON_CCS811_COMMAND[] PROGMEM = "{\"" D_CMND_CCS811 "%s\"}"; +const char kCCS811_Commands[] PROGMEM = "HW|FWApp|Baseline"; + +enum CCS811_Commands { // commands useable in console or rules + CMND_CCS811_HW, + CMND_CCS811_FWAPP, + CMND_CCS811_BASELINE +}; + +/********************************************************************************************/ + +void CCS811Detect(void) +{ + if (!CCS811_devices_found) { + memset( ccsd, 0, sizeof( ccsd)); + } + int active_index = 1; + for (i = 0, pccsd = ccsd; i < MAXDEVICECOUNT; i++, pccsd++) { + pccsd->address = CCS811_addresses[ i]; + if (I2cActive( pccsd->address)) { continue; } + if (!pccsd->ccsinstance.begin(pccsd->address)) { + pccsd->device_found = 1; + CCS811_devices_found += 1; + I2cSetActiveFound( pccsd->address, "CCS811"); + pccsd->device_index = active_index; + active_index++; + } + } +} + +void CCS811Update(void) // Perform every n second +{ + for (i = 0, pccsd = ccsd; i < MAXDEVICECOUNT; i++, pccsd++) { + + if (!pccsd->device_found) + continue; + + pccsd->refresh_count++; + if (pccsd->refresh_count >= EVERYNSECONDS) { + pccsd->refresh_count = 0; + pccsd->device_ready = 0; + if (pccsd->ccsinstance.available()) { + if (!pccsd->ccsinstance.readData()){ + pccsd->TVOC = pccsd->ccsinstance.getTVOC(); + pccsd->eCO2 = pccsd->ccsinstance.geteCO2(); + pccsd->device_ready = 1; + if ((TasmotaGlobal.global_update) && + (TasmotaGlobal.humidity > 0) && + (!isnan(TasmotaGlobal.temperature_celsius))) { + pccsd->ccsinstance.setEnvironmentalData((uint8_t)TasmotaGlobal.humidity, + TasmotaGlobal.temperature_celsius); + } + pccsd->reset_count = 0; + } + } else { + // failed, count up + pccsd->reset_count++; + if (pccsd->reset_count > RESETCOUNT) { + // after 30 seconds, restart + pccsd->ccsinstance.begin( pccsd->address); + pccsd->reset_count = 0; + } + } + } + } +} + + +// no methods available in Adafruit library to read version data or +// read/set the baseline value, so we need to emulate the private methods + +void CCS811ReadMailboxValue( uint8_t address, uint8_t mailbox, byte * pbuf, uint8_t buflen) +{ + Wire.beginTransmission(address); + Wire.write(mailbox); + Wire.endTransmission(); + Wire.requestFrom(address, buflen); + for (uint8_t i = 0; i < buflen; i++) { + *(pbuf + i) = Wire.read(); +#ifdef CCS811_DEBUG + AddLog(LOG_LEVEL_DEBUG, PSTR( D_LOG_DEBUG D_CMND_CCS811 " reading byte %u: 0%02x / %u"), i, *(pbuf + i), *(pbuf + i)); +#endif + } +} + +void CCS811WriteMailboxValue(uint8_t address, uint8_t mailbox, byte * pbuf, uint8_t buflen) +{ +#ifdef CCS811_DEBUG + for (uint8_t i = 0; i < buflen; i++) { + AddLog(LOG_LEVEL_DEBUG, PSTR( D_LOG_DEBUG D_CMND_CCS811 " writing byte %u: 0%02x / %u"), i, *(pbuf + i), *(pbuf + i)); + } +#endif + Wire.beginTransmission(address); + Wire.write((uint8_t)mailbox); + Wire.write(pbuf, buflen); + Wire.endTransmission(); +} + +/*********************************************************************************************\ + * Command Sensor31 +\*********************************************************************************************/ + +bool CCS811CommandSensor() +{ + + char command[CMDSZ]; + bool serviced = true; + uint8_t prefix_len = strlen(D_CMND_CCS811); + + if ((!strncasecmp_P(XdrvMailbox.topic, PSTR(D_CMND_CCS811), prefix_len)) && + (XdrvMailbox.index <= CCS811_devices_found)) { // check prefix and device index + + int command_code = GetCommandCode(command, sizeof(command), XdrvMailbox.topic + prefix_len, kCCS811_Commands); + + // select device data matching the index + CCS811DATA * pccsd_command; + for (i = 0, pccsd = ccsd; i < MAXDEVICECOUNT; i++, pccsd++) { + if (pccsd->device_index == XdrvMailbox.index) { + pccsd_command = pccsd; +#ifdef CCS811_DEBUG + AddLog(LOG_LEVEL_DEBUG, PSTR( D_LOG_DEBUG D_CMND_CCS811 " I2C Address: 0%02x"), pccsd_command->address); +#endif + break; + } + } + if (!pccsd_command) { + return false; + } + + switch (command_code) { + + case CMND_CCS811_HW: + { + byte CCS811_hw_version; + CCS811ReadMailboxValue( pccsd_command->address, + CCS811_HW_VERSION, + &CCS811_hw_version, + sizeof(CCS811_hw_version)); + Response_P(S_JSON_CCS811_COMMAND_HWVERSION, command, CCS811_hw_version); + } + break; + + case CMND_CCS811_FWAPP: + { + byte CCS811_fw_app_version[2]; + CCS811ReadMailboxValue( pccsd_command->address, + CCS811_FW_APP_VERSION, + CCS811_fw_app_version, + (sizeof(CCS811_fw_app_version) / sizeof(byte))); + Response_P(S_JSON_CCS811_COMMAND_FWAPPVERSION, + command, + (CCS811_fw_app_version[0] >> 4), // major + (CCS811_fw_app_version[0] & 0xF), // minor + CCS811_fw_app_version[1]); // build + } + break; + + case CMND_CCS811_BASELINE: + { + byte CCS811_baseline[2]; + if (XdrvMailbox.data_len > 0) { + CCS811_baseline[0] = (XdrvMailbox.payload & 0xFF00) >> 8; + CCS811_baseline[1] = XdrvMailbox.payload & 0xFF; + CCS811WriteMailboxValue( pccsd_command->address, + CCS811_BASELINE, + CCS811_baseline, + (sizeof(CCS811_baseline) / sizeof(byte))); + } else { + CCS811ReadMailboxValue( pccsd_command->address, + CCS811_BASELINE, + CCS811_baseline, + (sizeof(CCS811_baseline) / sizeof(byte))); + } + Response_P(S_JSON_CCS811_COMMAND_NVALUE, + command, + ((CCS811_baseline[0] << 8) + CCS811_baseline[1])); + } + break; + + default: + // else for Unknown command + serviced = false; + break; + } + } + + return serviced; +} + + +const char HTTP_SNS_CCS811[] PROGMEM = + "{s}%s " D_ECO2 "{m}%d " D_UNIT_PARTS_PER_MILLION "{e}" // {s} = , {m} = , {e} = + "{s}%s " D_TVOC "{m}%d " D_UNIT_PARTS_PER_BILLION "{e}"; + +const char * devicenamelist[] PROGMEM = { "CCS811", "CCS811_1", "CCS811_2" }; + +void CCS811Show(bool json) +{ + uint8_t ready_count = 0; + for (i = 0, pccsd = ccsd; i < MAXDEVICECOUNT; i++, pccsd++) { + if ((pccsd->device_found) && (pccsd->device_ready)) { + ready_count += 1; + } + } + if (!ready_count) { + return; + } + + // in upcoming loops use either one device name + // with no index or or two names with index + const char ** pdevicename; + const char ** pdevicename_first = devicenamelist; + if (ready_count > 1) { + pdevicename_first++; + } + + if (json) { + for (i = 0, pccsd = ccsd, pdevicename = pdevicename_first; i < MAXDEVICECOUNT; i++, pccsd++) { + if (pccsd->device_ready) { + ResponseAppend_P( PSTR(",\"%s\":{\"" D_JSON_ECO2 "\":%d,\"" D_JSON_TVOC "\":%d}"), + *pdevicename, + pccsd->eCO2, + pccsd->TVOC); + pdevicename++; + } + } +#ifdef USE_DOMOTICZ + if (0 == TasmotaGlobal.tele_period) { + if (pccsd->device_ready) { + pccsd = ccsd; + DomoticzSensor(DZ_AIRQUALITY, pccsd->eCO2); + } + } +#endif // USE_DOMOTICZ +#ifdef USE_WEBSERVER + } else { + for (i = 0, pccsd = ccsd, pdevicename = pdevicename_first; i < MAXDEVICECOUNT; i++, pccsd++) { + if (pccsd->device_ready) { + WSContentSend_PD( HTTP_SNS_CCS811, + *pdevicename, pccsd->eCO2, + *pdevicename, pccsd->TVOC); + pdevicename++; + } + } +#endif + } +} + +/*********************************************************************************************\ + * Interface +\*********************************************************************************************/ + +bool Xsns31(uint8_t function) +{ + if (!I2cEnabled(XI2C_24)) { return false; } + + bool result = false; + + if (FUNC_INIT == function) { + CCS811Detect(); + } + else if (CCS811_devices_found) { + switch (function) { + case FUNC_EVERY_SECOND: + CCS811Update(); + break; + case FUNC_COMMAND: + result = CCS811CommandSensor(); + break; + case FUNC_JSON_APPEND: + CCS811Show(1); + break; +#ifdef USE_WEBSERVER + case FUNC_WEB_SENSOR: + CCS811Show(0); + break; +#endif // USE_WEBSERVER + } + } + return result; +} + +#endif // USE_CCS811_V2 +#endif // USE_I2C \ No newline at end of file diff --git a/tasmota/xsns_37_rfsensor.ino b/tasmota/xsns_37_rfsensor.ino index 3b469b2b5..451f47798 100644 --- a/tasmota/xsns_37_rfsensor.ino +++ b/tasmota/xsns_37_rfsensor.ino @@ -251,7 +251,7 @@ void RfSnsAnalyzeTheov2(void) break; } - AddLog_P(LOG_LEVEL_DEBUG, PSTR("RFS: TheoV2, ChkCalc %d, Chksum %d, id %d, Type %d, Ch %d, Volt %d, BattLo %d, Pld1 %d, Pld2 %d"), + AddLog(LOG_LEVEL_DEBUG, PSTR("RFS: TheoV2, ChkCalc %d, Chksum %d, id %d, Type %d, Ch %d, Volt %d, BattLo %d, Pld1 %d, Pld2 %d"), chksum, Checksum, id, Type, Channel +1, Payload3, (Voltage & 0x80) >> 7, Payload1, Payload2); } @@ -502,7 +502,7 @@ void RfSnsAnalyzeAlectov2() rfsns_alecto_v2->wdir = data[8] & 0xf; } - AddLog_P(LOG_LEVEL_DEBUG, PSTR("RFS: " D_ALECTOV2 ", ChkCalc %d, Chksum %d, rc %d, Temp %d, Hum %d, Rain %d, Wind %d, Gust %d, Dir %d, Factor %s"), + AddLog(LOG_LEVEL_DEBUG, PSTR("RFS: " D_ALECTOV2 ", ChkCalc %d, Chksum %d, rc %d, Temp %d, Hum %d, Rain %d, Wind %d, Gust %d, Dir %d, Factor %s"), checksumcalc, checksum, rc, ((data[1] & 0x3) * 256 + data[2]) - 400, data[3], (data[6] * 256) + data[7], data[4], data[5], data[8] & 0xf, dtostrfd(factor, 3, buf1)); } diff --git a/tasmota/xsns_42_scd30.ino b/tasmota/xsns_42_scd30.ino index 671b29903..081503ad1 100644 --- a/tasmota/xsns_42_scd30.ino +++ b/tasmota/xsns_42_scd30.ino @@ -120,7 +120,7 @@ void Scd30Update(void) scd30ErrorState = SCD30_STATE_ERROR_DATA_CRC; scd30CrcError_count++; #ifdef SCD30_DEBUG - AddLog_P(LOG_LEVEL_ERROR, PSTR("SCD30: CRC error, CRC error: %ld, CO2 zero: %ld, good: %ld, no data: %ld, sc30_reset: %ld, i2c_reset: %ld"), + AddLog(LOG_LEVEL_ERROR, PSTR("SCD30: CRC error, CRC error: %ld, CO2 zero: %ld, good: %ld, no data: %ld, sc30_reset: %ld, i2c_reset: %ld"), scd30CrcError_count, scd30Co2Zero_count, scd30GoodMeas_count, scd30DataNotAvailable_count, scd30Reset_count, i2cReset_count); #endif break; @@ -128,7 +128,7 @@ void Scd30Update(void) case ERROR_SCD30_CO2_ZERO: scd30Co2Zero_count++; #ifdef SCD30_DEBUG - AddLog_P(LOG_LEVEL_ERROR, PSTR("SCD30: CO2 zero, CRC error: %ld, CO2 zero: %ld, good: %ld, no data: %ld, sc30_reset: %ld, i2c_reset: %ld"), + AddLog(LOG_LEVEL_ERROR, PSTR("SCD30: CO2 zero, CRC error: %ld, CO2 zero: %ld, good: %ld, no data: %ld, sc30_reset: %ld, i2c_reset: %ld"), scd30CrcError_count, scd30Co2Zero_count, scd30GoodMeas_count, scd30DataNotAvailable_count, scd30Reset_count, i2cReset_count); #endif break; @@ -136,7 +136,7 @@ void Scd30Update(void) default: { scd30ErrorState = SCD30_STATE_ERROR_READ_MEAS; #ifdef SCD30_DEBUG - AddLog_P(LOG_LEVEL_ERROR, PSTR("SCD30: Update: ReadMeasurement error: 0x%lX, counter: %ld"), error, scd30Loop_count); + AddLog(LOG_LEVEL_ERROR, PSTR("SCD30: Update: ReadMeasurement error: 0x%lX, counter: %ld"), error, scd30Loop_count); #endif return; } @@ -148,9 +148,9 @@ void Scd30Update(void) case SCD30_STATE_ERROR_DATA_CRC: { //scd30IsDataValid = false; #ifdef SCD30_DEBUG - AddLog_P(LOG_LEVEL_ERROR, PSTR("SCD30: in error state: %d, good: %ld, no data: %ld, sc30 reset: %ld, i2c reset: %ld"), + AddLog(LOG_LEVEL_ERROR, PSTR("SCD30: in error state: %d, good: %ld, no data: %ld, sc30 reset: %ld, i2c reset: %ld"), scd30ErrorState, scd30GoodMeas_count, scd30DataNotAvailable_count, scd30Reset_count, i2cReset_count); - AddLog_P(LOG_LEVEL_ERROR, PSTR("SCD30: got CRC error, try again, counter: %ld"), scd30Loop_count); + AddLog(LOG_LEVEL_ERROR, PSTR("SCD30: got CRC error, try again, counter: %ld"), scd30Loop_count); #endif scd30ErrorState = ERROR_SCD30_NO_ERROR; } @@ -159,15 +159,15 @@ void Scd30Update(void) case SCD30_STATE_ERROR_READ_MEAS: { //scd30IsDataValid = false; #ifdef SCD30_DEBUG - AddLog_P(LOG_LEVEL_ERROR, PSTR("SCD30: in error state: %d, good: %ld, no data: %ld, sc30 reset: %ld, i2c reset: %ld"), + AddLog(LOG_LEVEL_ERROR, PSTR("SCD30: in error state: %d, good: %ld, no data: %ld, sc30 reset: %ld, i2c reset: %ld"), scd30ErrorState, scd30GoodMeas_count, scd30DataNotAvailable_count, scd30Reset_count, i2cReset_count); - AddLog_P(LOG_LEVEL_ERROR, PSTR("SCD30: not answering, sending soft reset, counter: %ld"), scd30Loop_count); + AddLog(LOG_LEVEL_ERROR, PSTR("SCD30: not answering, sending soft reset, counter: %ld"), scd30Loop_count); #endif scd30Reset_count++; error = scd30.softReset(); if (error) { #ifdef SCD30_DEBUG - AddLog_P(LOG_LEVEL_ERROR, PSTR("SCD30: resetting got error: 0x%lX"), error); + AddLog(LOG_LEVEL_ERROR, PSTR("SCD30: resetting got error: 0x%lX"), error); #endif error >>= 8; if (error == 4) { @@ -184,16 +184,16 @@ void Scd30Update(void) case SCD30_STATE_ERROR_SOFT_RESET: { //scd30IsDataValid = false; #ifdef SCD30_DEBUG - AddLog_P(LOG_LEVEL_ERROR, PSTR("SCD30: in error state: %d, good: %ld, no data: %ld, sc30 reset: %ld, i2c reset: %ld"), + AddLog(LOG_LEVEL_ERROR, PSTR("SCD30: in error state: %d, good: %ld, no data: %ld, sc30 reset: %ld, i2c reset: %ld"), scd30ErrorState, scd30GoodMeas_count, scd30DataNotAvailable_count, scd30Reset_count, i2cReset_count); - AddLog_P(LOG_LEVEL_ERROR, PSTR("SCD30: clearing i2c bus")); + AddLog(LOG_LEVEL_ERROR, PSTR("SCD30: clearing i2c bus")); #endif i2cReset_count++; error = scd30.clearI2CBus(); if (error) { scd30ErrorState = SCD30_STATE_ERROR_I2C_RESET; #ifdef SCD30_DEBUG - AddLog_P(LOG_LEVEL_ERROR, PSTR("SCD30: error clearing i2c bus: 0x%lX"), error); + AddLog(LOG_LEVEL_ERROR, PSTR("SCD30: error clearing i2c bus: 0x%lX"), error); #endif } else { scd30ErrorState = ERROR_SCD30_NO_ERROR; @@ -204,7 +204,7 @@ void Scd30Update(void) default: { //scd30IsDataValid = false; #ifdef SCD30_DEBUG - AddLog_P(LOG_LEVEL_ERROR, PSTR("SCD30: unknown error state: 0x%lX"), scd30ErrorState); + AddLog(LOG_LEVEL_ERROR, PSTR("SCD30: unknown error state: 0x%lX"), scd30ErrorState); #endif scd30ErrorState = SCD30_STATE_ERROR_SOFT_RESET; // try again } @@ -340,7 +340,7 @@ bool Scd30CommandSensor() if (error) { #ifdef SCD30_DEBUG - AddLog_P(LOG_LEVEL_ERROR, PSTR("SCD30: error getting FW version: 0x%lX"), error); + AddLog(LOG_LEVEL_ERROR, PSTR("SCD30: error getting FW version: 0x%lX"), error); #endif serviced = false; } diff --git a/tasmota/xsns_53_sml.ino b/tasmota/xsns_53_sml.ino index 925997c0b..96f02ee5f 100755 --- a/tasmota/xsns_53_sml.ino +++ b/tasmota/xsns_53_sml.ino @@ -1856,7 +1856,7 @@ void SML_Decode(uint8_t index) { if (lowByte(crc)!=smltbuf[mindex][pos]) goto nextsect; if (highByte(crc)!=smltbuf[mindex][pos+1]) goto nextsect; dval=mbus_dval; - //AddLog_P(LOG_LEVEL_INFO, PSTR(">> %s"),mp); + //AddLog(LOG_LEVEL_INFO, PSTR(">> %s"),mp); mp++; } else { if (meter_desc_p[mindex].type=='p') { @@ -1879,7 +1879,7 @@ void SML_Decode(uint8_t index) { meter_vars[vindex]=dval; #endif - //AddLog_P(LOG_LEVEL_INFO, PSTR(">> %s"),mp); + //AddLog(LOG_LEVEL_INFO, PSTR(">> %s"),mp); // get scaling factor double fac = CharToDouble((char*)mp); meter_vars[vindex] /= fac; @@ -2203,13 +2203,13 @@ char dstbuf[SML_SRCBSIZE*2]; Replace_Cmd_Vars(lp,1,dstbuf,sizeof(dstbuf)); lp+=SML_getlinelen(lp)+1; uint32_t slen=strlen(dstbuf); - //AddLog_P(LOG_LEVEL_INFO, PSTR("%d - %s"),slen,dstbuf); + //AddLog(LOG_LEVEL_INFO, PSTR("%d - %s"),slen,dstbuf); mlen+=slen+1; if (*lp=='#') break; if (*lp=='>') break; if (*lp==0) break; } - //AddLog_P(LOG_LEVEL_INFO, PSTR("len=%d"),mlen); + //AddLog(LOG_LEVEL_INFO, PSTR("len=%d"),mlen); return mlen+32; } #else @@ -2221,7 +2221,7 @@ uint32_t SML_getscriptsize(char *lp) { break; } } - //AddLog_P(LOG_LEVEL_INFO, PSTR("len=%d"),mlen); + //AddLog(LOG_LEVEL_INFO, PSTR("len=%d"),mlen); return mlen; } #endif @@ -2406,7 +2406,7 @@ dddef_exit: char dstbuf[SML_SRCBSIZE*2]; Replace_Cmd_Vars(lp, 1, dstbuf,sizeof(dstbuf)); lp += SML_getlinelen(lp); - //AddLog_P(LOG_LEVEL_INFO, PSTR("%s"),dstbuf); + //AddLog(LOG_LEVEL_INFO, PSTR("%s"),dstbuf); char *lp1 = dstbuf; if (*lp1 == '-' || isdigit(*lp1)) { //toLogEOL(">>",lp); @@ -2783,10 +2783,10 @@ void SML_Check_Send(void) { char *cp; for (uint32_t cnt=sml_desc_cnt; cnt=0 && script_meter_desc[cnt].txmem) { - //AddLog_P(LOG_LEVEL_INFO, PSTR("100 ms>> %d - %s - %d"),sml_desc_cnt,script_meter_desc[cnt].txmem,script_meter_desc[cnt].tsecs); + //AddLog(LOG_LEVEL_INFO, PSTR("100 ms>> %d - %s - %d"),sml_desc_cnt,script_meter_desc[cnt].txmem,script_meter_desc[cnt].tsecs); if ((sml_100ms_cnt>=script_meter_desc[cnt].tsecs)) { sml_100ms_cnt=0; - //AddLog_P(LOG_LEVEL_INFO, PSTR("100 ms>> 2"),cp); + //AddLog(LOG_LEVEL_INFO, PSTR("100 ms>> 2"),cp); if (script_meter_desc[cnt].max_index>1) { script_meter_desc[cnt].index++; if (script_meter_desc[cnt].index>=script_meter_desc[cnt].max_index) { @@ -2800,7 +2800,7 @@ void SML_Check_Send(void) { //SML_Send_Seq(cnt,cp); sml_desc_cnt++; } - //AddLog_P(LOG_LEVEL_INFO, PSTR(">> %s"),cp); + //AddLog(LOG_LEVEL_INFO, PSTR(">> %s"),cp); SML_Send_Seq(cnt,cp); if (sml_desc_cnt>=meters_used) { sml_desc_cnt=0; diff --git a/tasmota/xsns_62_esp32_mi_ble.ino b/tasmota/xsns_62_esp32_mi_ble.ino index 1c12aa245..912b9c798 100644 --- a/tasmota/xsns_62_esp32_mi_ble.ino +++ b/tasmota/xsns_62_esp32_mi_ble.ino @@ -2755,7 +2755,7 @@ void MI32ShowOneMISensor(){ id); MqttPublish(SensorTopic); - //AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: %s: show some %d %s"),D_CMND_MI32, MI32.mqttCurrentSlot, TasmotaGlobal.mqtt_data); + //AddLog(LOG_LEVEL_DEBUG,PSTR("M32: %s: show some %d %s"),D_CMND_MI32, MI32.mqttCurrentSlot, TasmotaGlobal.mqtt_data); } MI32.mqttCurrentSingleSlot++; } @@ -3011,7 +3011,7 @@ void MI32DiscoveryOneMISensor(){ //vTaskDelay(100/ portTICK_PERIOD_MS); } } // end if hass discovery - //AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: %s: show some %d %s"),D_CMND_MI32, MI32.mqttCurrentSlot, TasmotaGlobal.mqtt_data); + //AddLog(LOG_LEVEL_DEBUG,PSTR("M32: %s: show some %d %s"),D_CMND_MI32, MI32.mqttCurrentSlot, TasmotaGlobal.mqtt_data); #endif //USE_HOME_ASSISTANT }