From 76f699bf0255f4c0d8dc797a89e84a9dd0ecc95f Mon Sep 17 00:00:00 2001 From: Theo Arends Date: Thu, 19 Apr 2018 22:29:09 +0200 Subject: [PATCH] Remove debug code and do some clean-up Remove debug code and set H801 GPIO0 to GPIO_USER (#1503) --- sonoff/i18n.h | 1 - sonoff/settings.ino | 86 ---------------------------------------- sonoff/sonoff.ino | 18 +-------- sonoff/sonoff_post.h | 5 ++- sonoff/sonoff_template.h | 2 +- 5 files changed, 6 insertions(+), 106 deletions(-) diff --git a/sonoff/i18n.h b/sonoff/i18n.h index 595f8c30f..2820ae0de 100644 --- a/sonoff/i18n.h +++ b/sonoff/i18n.h @@ -222,7 +222,6 @@ #define D_CMND_ALTITUDE "Altitude" #define D_CMND_LEDPOWER "LedPower" #define D_CMND_LEDSTATE "LedState" -#define D_CMND_CFGDUMP "CfgDump" #define D_CMND_I2CSCAN "I2CScan" #define D_CMND_SERIALSEND "SerialSend" #define D_CMND_SERIALDELIMITER "SerialDelimiter" diff --git a/sonoff/settings.ino b/sonoff/settings.ino index 9419548c8..579862457 100644 --- a/sonoff/settings.ino +++ b/sonoff/settings.ino @@ -119,41 +119,6 @@ boolean RtcSettingsValid() return (RTC_MEM_VALID == RtcSettings.valid); } -#ifdef DEBUG_THEO -void RtcSettingsDump() -{ - #define CFG_COLS 16 - - uint16_t idx; - uint16_t maxrow; - uint16_t row; - uint16_t col; - - uint8_t *buffer = (uint8_t *) &RtcSettings; - maxrow = ((sizeof(RTCMEM)+CFG_COLS)/CFG_COLS); - - for (row = 0; row < maxrow; row++) { - idx = row * CFG_COLS; - snprintf_P(log_data, sizeof(log_data), PSTR("%03X:"), idx); - for (col = 0; col < CFG_COLS; col++) { - if (!(col%4)) { - snprintf_P(log_data, sizeof(log_data), PSTR("%s "), log_data); - } - snprintf_P(log_data, sizeof(log_data), PSTR("%s %02X"), log_data, buffer[idx + col]); - } - snprintf_P(log_data, sizeof(log_data), PSTR("%s |"), log_data); - for (col = 0; col < CFG_COLS; col++) { -// if (!(col%4)) { -// snprintf_P(log_data, sizeof(log_data), PSTR("%s "), log_data); -// } - snprintf_P(log_data, sizeof(log_data), PSTR("%s%c"), log_data, ((buffer[idx + col] > 0x20) && (buffer[idx + col] < 0x7F)) ? (char)buffer[idx + col] : ' '); - } - snprintf_P(log_data, sizeof(log_data), PSTR("%s|"), log_data); - AddLog(LOG_LEVEL_INFO); - } -} -#endif // DEBUG_THEO - /*********************************************************************************************\ * Config - Flash \*********************************************************************************************/ @@ -374,57 +339,6 @@ void SettingsSdkErase() delay(1000); } -void SettingsDump(char* parms) -{ - #define CFG_COLS 16 - - uint16_t idx; - uint16_t maxrow; - uint16_t row; - uint16_t col; - char *p; - - uint8_t *buffer = (uint8_t *) &Settings; - maxrow = ((sizeof(SYSCFG)+CFG_COLS)/CFG_COLS); - - uint16_t srow = strtol(parms, &p, 16) / CFG_COLS; - uint16_t mrow = strtol(p, &p, 10); - -// snprintf_P(log_data, sizeof(log_data), PSTR("Cnfg: Parms %s, Start row %d, rows %d"), parms, srow, mrow); -// AddLog(LOG_LEVEL_DEBUG); - - if (0 == mrow) { // Default only 8 lines - mrow = 8; - } - if (srow > maxrow) { - srow = maxrow - mrow; - } - if (mrow < (maxrow - srow)) { - maxrow = srow + mrow; - } - - for (row = srow; row < maxrow; row++) { - idx = row * CFG_COLS; - snprintf_P(log_data, sizeof(log_data), PSTR("%03X:"), idx); - for (col = 0; col < CFG_COLS; col++) { - if (!(col%4)) { - snprintf_P(log_data, sizeof(log_data), PSTR("%s "), log_data); - } - snprintf_P(log_data, sizeof(log_data), PSTR("%s %02X"), log_data, buffer[idx + col]); - } - snprintf_P(log_data, sizeof(log_data), PSTR("%s |"), log_data); - for (col = 0; col < CFG_COLS; col++) { -// if (!(col%4)) { -// snprintf_P(log_data, sizeof(log_data), PSTR("%s "), log_data); -// } - snprintf_P(log_data, sizeof(log_data), PSTR("%s%c"), log_data, ((buffer[idx + col] > 0x20) && (buffer[idx + col] < 0x7F)) ? (char)buffer[idx + col] : ' '); - } - snprintf_P(log_data, sizeof(log_data), PSTR("%s|"), log_data); - AddLog(LOG_LEVEL_INFO); - delay(1); - } -} - /********************************************************************************************/ void SettingsDefault() diff --git a/sonoff/sonoff.ino b/sonoff/sonoff.ino index f937cc517..df9997cfd 100644 --- a/sonoff/sonoff.ino +++ b/sonoff/sonoff.ino @@ -84,7 +84,7 @@ enum TasmotaCommands { CMND_LOGHOST, CMND_LOGPORT, CMND_IPADDRESS, CMND_NTPSERVER, CMND_AP, CMND_SSID, CMND_PASSWORD, CMND_HOSTNAME, CMND_WIFICONFIG, CMND_FRIENDLYNAME, CMND_SWITCHMODE, CMND_WEBSERVER, CMND_WEBPASSWORD, CMND_WEBLOG, CMND_EMULATION, CMND_TELEPERIOD, CMND_RESTART, CMND_RESET, CMND_TIMEZONE, CMND_ALTITUDE, CMND_LEDPOWER, CMND_LEDSTATE, - CMND_CFGDUMP, CMND_I2CSCAN, CMND_SERIALSEND, CMND_BAUDRATE, CMND_SERIALDELIMITER, CMND_EXCEPTION }; + CMND_I2CSCAN, CMND_SERIALSEND, CMND_BAUDRATE, CMND_SERIALDELIMITER }; const char kTasmotaCommands[] PROGMEM = D_CMND_BACKLOG "|" D_CMND_DELAY "|" D_CMND_POWER "|" D_CMND_STATUS "|" D_CMND_STATE "|" D_CMND_POWERONSTATE "|" D_CMND_PULSETIME "|" D_CMND_BLINKTIME "|" D_CMND_BLINKCOUNT "|" D_CMND_SENSOR "|" D_CMND_SAVEDATA "|" D_CMND_SETOPTION "|" D_CMND_TEMPERATURE_RESOLUTION "|" D_CMND_HUMIDITY_RESOLUTION "|" @@ -94,11 +94,7 @@ const char kTasmotaCommands[] PROGMEM = D_CMND_LOGHOST "|" D_CMND_LOGPORT "|" D_CMND_IPADDRESS "|" D_CMND_NTPSERVER "|" D_CMND_AP "|" D_CMND_SSID "|" D_CMND_PASSWORD "|" D_CMND_HOSTNAME "|" D_CMND_WIFICONFIG "|" D_CMND_FRIENDLYNAME "|" D_CMND_SWITCHMODE "|" D_CMND_WEBSERVER "|" D_CMND_WEBPASSWORD "|" D_CMND_WEBLOG "|" D_CMND_EMULATION "|" D_CMND_TELEPERIOD "|" D_CMND_RESTART "|" D_CMND_RESET "|" D_CMND_TIMEZONE "|" D_CMND_ALTITUDE "|" D_CMND_LEDPOWER "|" D_CMND_LEDSTATE "|" - D_CMND_CFGDUMP "|" D_CMND_I2CSCAN "|" D_CMND_SERIALSEND "|" D_CMND_BAUDRATE "|" D_CMND_SERIALDELIMITER -#ifdef DEBUG_THEO - "|" D_CMND_EXCEPTION -#endif - ; + D_CMND_I2CSCAN "|" D_CMND_SERIALSEND "|" D_CMND_BAUDRATE "|" D_CMND_SERIALDELIMITER; const char kOptionOff[] PROGMEM = "OFF|" D_OFF "|" D_FALSE "|" D_STOP "|" D_CELSIUS ; const char kOptionOn[] PROGMEM = "ON|" D_ON "|" D_TRUE "|" D_START "|" D_FAHRENHEIT "|" D_USER ; @@ -1068,10 +1064,6 @@ void MqttDataHandler(char* topic, byte* data, unsigned int data_len) } snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_NVALUE, command, Settings.ledstate); } - else if (CMND_CFGDUMP == command_code) { - SettingsDump(dataBuf); - snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_SVALUE, command, D_JSON_DONE); - } #ifdef USE_I2C else if ((CMND_I2CSCAN == command_code) && i2c_flg) { I2cScan(mqtt_data, sizeof(mqtt_data)); @@ -1080,12 +1072,6 @@ void MqttDataHandler(char* topic, byte* data, unsigned int data_len) else if (XdrvCommand(grpflg, type, index, dataBuf, data_len, payload, payload16)) { // Serviced } -#ifdef DEBUG_THEO - else if (CMND_EXCEPTION == command_code) { - if (data_len > 0) ExceptionTest(payload); - snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_SVALUE, command, D_JSON_DONE); - } -#endif // DEBUG_THEO else { type = NULL; } diff --git a/sonoff/sonoff_post.h b/sonoff/sonoff_post.h index d488f4ea4..47a752c72 100644 --- a/sonoff/sonoff_post.h +++ b/sonoff/sonoff_post.h @@ -86,8 +86,6 @@ void KNX_CB_Action(message_t const &msg, void *arg); #define USE_DS18B20 // Default DS18B20 sensor needs no external library #endif -//#define DEBUG_THEO // Add debug code - #ifdef BE_MINIMAL // ========================== Configure sonoff-minimal.bin ===================== #ifdef USE_MQTT_TLS #undef USE_MQTT_TLS // Disable TLS support won't work as the MQTTHost is not set @@ -113,6 +111,9 @@ void KNX_CB_Action(message_t const &msg, void *arg); #ifdef USE_SUNRISE #undef USE_SUNRISE // Disable support for Sunrise and sunset tools #endif +#ifdef USE_KNX +#undef USE_KNX // Disable KNX IP Protocol Support +#endif #ifdef USE_PZEM004T #undef USE_PZEM004T // Disable PZEM004T energy sensor #endif diff --git a/sonoff/sonoff_template.h b/sonoff/sonoff_template.h index cbb197abb..b7ceb6c24 100644 --- a/sonoff/sonoff_template.h +++ b/sonoff/sonoff_template.h @@ -494,7 +494,7 @@ const mytmplt kModules[MAXMODULE] PROGMEM = { GPIO_ADC0 // ADC0 A0 Analog input }, { "H801", // Lixada H801 Wifi (ESP8266) - GPIO_KEY1, // GPIO00 E-FW Button + GPIO_USER, // GPIO00 E-FW Button GPIO_LED1, // GPIO01 Green LED GPIO_TXD, // GPIO02 RX - Pin next to TX on the PCB GPIO_RXD, // GPIO03 TX - Pin next to GND on the PCB