From 27efc08d2c63647249a11794a7b71be54a1e5b2e Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Thu, 8 Aug 2019 16:24:11 +0200 Subject: [PATCH] Add define DEBUG_TASMOTA_CORE Add define DEBUG_TASMOTA_CORE --- platformio.ini | 1 + sonoff/my_user_config.h | 1 + sonoff/sonoff.ino | 2 +- sonoff/sonoff_post.h | 6 ++++++ sonoff/support_button.ino | 2 +- sonoff/xdrv_01_webserver.ino | 4 ++-- sonoff/xdrv_03_energy.ino | 2 +- 7 files changed, 13 insertions(+), 5 deletions(-) diff --git a/platformio.ini b/platformio.ini index eb6f3077f..ae7da7e1a 100755 --- a/platformio.ini +++ b/platformio.ini @@ -189,6 +189,7 @@ platform = ${core_active.platform} build_flags = ${core_active.build_flags} ; *** Optional Debug messages +; -DDEBUG_TASMOTA_CORE ; -DDEBUG_TASMOTA_DRIVER ; -DDEBUG_TASMOTA_SENSOR diff --git a/sonoff/my_user_config.h b/sonoff/my_user_config.h index 9a1fadb44..3169d3b59 100644 --- a/sonoff/my_user_config.h +++ b/sonoff/my_user_config.h @@ -496,6 +496,7 @@ * Debug features \*********************************************************************************************/ +//#define DEBUG_TASMOTA_CORE // Enable core debug messages //#define DEBUG_TASMOTA_DRIVER // Enable driver debug messages //#define DEBUG_TASMOTA_SENSOR // Enable sensor debug messages //#define USE_DEBUG_DRIVER // Use xdrv_99_debug.ino providing commands CpuChk, CfgXor, CfgDump, CfgPeek and CfgPoke diff --git a/sonoff/sonoff.ino b/sonoff/sonoff.ino index 8df877520..cee34df17 100755 --- a/sonoff/sonoff.ino +++ b/sonoff/sonoff.ino @@ -929,7 +929,7 @@ void Every250mSeconds(void) if (!ota_result) { #ifndef FIRMWARE_MINIMAL int ota_error = ESPhttpUpdate.getLastError(); -// AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPLOAD "Ota error %d"), ota_error); + DEBUG_CORE_LOG(PSTR("OTA: Error %d"), ota_error); if ((HTTP_UE_TOO_LESS_SPACE == ota_error) || (HTTP_UE_BIN_FOR_WRONG_FLASH == ota_error)) { RtcSettings.ota_loader = 1; // Try minimal image next } diff --git a/sonoff/sonoff_post.h b/sonoff/sonoff_post.h index 4eca7aafd..d2f0c7ea4 100644 --- a/sonoff/sonoff_post.h +++ b/sonoff/sonoff_post.h @@ -517,6 +517,12 @@ void KNX_CB_Action(message_t const &msg, void *arg); #undef USE_MQTT_TLS_CA_CERT #endif +#ifdef DEBUG_TASMOTA_CORE +#define DEBUG_CORE_LOG(...) AddLog_Debug(__VA_ARGS__) +#else +#define DEBUG_CORE_LOG(...) +#endif + #ifdef DEBUG_TASMOTA_DRIVER #define DEBUG_DRIVER_LOG(...) AddLog_Debug(__VA_ARGS__) #else diff --git a/sonoff/support_button.ino b/sonoff/support_button.ino index 9311cd838..4292ff460 100644 --- a/sonoff/support_button.ino +++ b/sonoff/support_button.ino @@ -199,7 +199,7 @@ void ButtonHandler(void) if (holdbutton[button_index] > loops_per_second * Settings.param[P_HOLD_IGNORE] / 10) { holdbutton[button_index] = 0; // Reset button hold counter to stay below hold trigger multipress[button_index] = 0; // Discard button press to disable functionality -// AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_BUTTON "%d cancel by " D_CMND_SETOPTION "40 %d"), button_index +1, Settings.param[P_HOLD_IGNORE]); + DEBUG_CORE_LOG(PSTR("BTN: " D_BUTTON "%d cancel by " D_CMND_SETOPTION "40 %d"), button_index +1, Settings.param[P_HOLD_IGNORE]); } } if (holdbutton[button_index] == loops_per_second * Settings.param[P_HOLD_TIME] / 10) { // SetOption32 (40) - Button hold diff --git a/sonoff/xdrv_01_webserver.ino b/sonoff/xdrv_01_webserver.ino index c80dd7318..10a008f6d 100644 --- a/sonoff/xdrv_01_webserver.ino +++ b/sonoff/xdrv_01_webserver.ino @@ -678,7 +678,7 @@ void _WSContentSend(const String& content) // Low level sendContent for a #ifdef USE_DEBUG_DRIVER ShowFreeMem(PSTR("WSContentSend")); #endif -// AddLog_P2(LOG_LEVEL_DEBUG, PSTR("HTP: Chunk size %d"), len); + DEBUG_DRIVER_LOG(PSTR("WEB: Chunk size %d"), len); } void WSContentFlush() @@ -2392,7 +2392,7 @@ int WebSend(char *buffer) } url += command; // url = |http://192.168.178.86/cm?cmnd=POWER1 ON| -//AddLog_P2(LOG_LEVEL_DEBUG, PSTR("DBG: Uri |%s|"), url.c_str()); + DEBUG_DRIVER_LOG(PSTR("WEB: Uri |%s|"), url.c_str()); #if defined(ARDUINO_ESP8266_RELEASE_2_3_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_1) || defined(ARDUINO_ESP8266_RELEASE_2_4_2) HTTPClient http; diff --git a/sonoff/xdrv_03_energy.ino b/sonoff/xdrv_03_energy.ino index cba5f7173..9809eb81c 100644 --- a/sonoff/xdrv_03_energy.ino +++ b/sonoff/xdrv_03_energy.ino @@ -221,7 +221,7 @@ void EnergyMarginCheck(void) energy_voltage_u = (uint16_t)(energy_voltage); energy_current_u = (uint16_t)(energy_current * 1000); -// AddLog_P2(LOG_LEVEL_DEBUG, PSTR("NRG: W %d, U %d, I %d"), energy_power_u, energy_voltage_u, energy_current_u); + DEBUG_DRIVER_LOG(PSTR("NRG: W %d, U %d, I %d"), energy_power_u, energy_voltage_u, energy_current_u); Response_P(PSTR("{")); jsonflg = false;