diff --git a/sonoff/_changelog.ino b/sonoff/_changelog.ino index 2600039cf..64525de6d 100644 --- a/sonoff/_changelog.ino +++ b/sonoff/_changelog.ino @@ -1,4 +1,7 @@ /*********************************************************************************************\ + * 6.6.0.20 20191018 + * Add command SetOption65 0/1 to disable (1) fast power cycle detection fixing unwanted brownout trigger + * * 6.6.0.19 20191018 * Replace obsolete xsns_23_sdm120 with xnrg_08_sdm120 and consolidate define USE_SDM120 * Replace obsolete xsns_25_sdm630 with xnrg_10_sdm630 and consolidate define USE_SDM630 @@ -78,7 +81,7 @@ * Add support for Hiking DDS238-2 Modbus energy meter by Matteo Campanella (#6384) * * 6.6.0.10 20190905 - * Redesign Tuya support by Shantur Rathore (#6353) + * Redesign Tuya support by Shantur Rathore removing commands SetOption34, 41, 44, 45, 46 and 65 (#6353) * Add command Reset 99 to reset bootcount to zero (#684, #6351) * Change command Time 1/2/3 to select JSON time format ISO, ISO + Epoch or Epoch for legacy reason * diff --git a/sonoff/settings.h b/sonoff/settings.h index 0edf3c73b..0709395f1 100644 --- a/sonoff/settings.h +++ b/sonoff/settings.h @@ -78,7 +78,7 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu uint32_t no_hold_retain : 1; // bit 12 (v6.4.1.19) - SetOption62 - Don't use retain flag on HOLD messages uint32_t no_power_feedback : 1; // bit 13 (v6.5.0.9) - SetOption63 - Don't scan relay power state at restart uint32_t use_underscore : 1; // bit 14 (v6.5.0.12) - SetOption64 - Enable "_" instead of "-" as sensor index separator - uint32_t ex_tuya_disable_dimmer : 1; // bit 15 (v6.5.0.15) - SetOption65 - (Enable or Disable Tuya Serial Dimmer control) - free since 6.6.0.10 + uint32_t fast_power_cycle_disable : 1; // bit 15 (v6.6.0.20) - SetOption65 - Disable fast power cycle detection for device reset uint32_t ex_tuya_dimmer_range_255 : 1; // bit 16 (v6.6.0.1) - SetOption66 - Enable or Disable Dimmer range 255 slider control uint32_t buzzer_enable : 1; // bit 17 (v6.6.0.1) - SetOption67 - Enable buzzer when available uint32_t pwm_multi_channels : 1; // bit 18 (v6.6.0.3) - SetOption68 - Enable multi-channels PWM instead of Color PWM diff --git a/sonoff/settings.ino b/sonoff/settings.ino index 8cd67a610..ae0f0577f 100644 --- a/sonoff/settings.ino +++ b/sonoff/settings.ino @@ -366,6 +366,8 @@ void SettingsSaveAll(void) void UpdateQuickPowerCycle(bool update) { + if (Settings.flag3.fast_power_cycle_disable) { return; } + uint32_t pc_register; uint32_t pc_location = SETTINGS_LOCATION - CFG_ROTATES; @@ -378,7 +380,7 @@ void UpdateQuickPowerCycle(bool update) } else { pc_register = 0xFFA55AB0 | counter; ESP.flashWrite(pc_location * SPI_FLASH_SEC_SIZE, (uint32*)&pc_register, sizeof(pc_register)); -// AddLog_P2(LOG_LEVEL_DEBUG, PSTR("QPC: Flag %02X"), counter); // Won't show as too early in power on sequence + AddLog_P2(LOG_LEVEL_DEBUG, PSTR("QPC: Flag %02X"), counter); } } else if (pc_register != 0xFFA55ABF) { @@ -386,7 +388,7 @@ void UpdateQuickPowerCycle(bool update) // Assume flash is default all ones and setting a bit to zero does not need an erase ESP.flashEraseSector(pc_location); ESP.flashWrite(pc_location * SPI_FLASH_SEC_SIZE, (uint32*)&pc_register, sizeof(pc_register)); -// AddLog_P2(LOG_LEVEL_DEBUG, PSTR("QPC: Reset")); // Won't show as too early in power on sequence + AddLog_P2(LOG_LEVEL_DEBUG, PSTR("QPC: Reset")); } } @@ -1137,11 +1139,11 @@ void SettingsDelta(void) if (Settings.version < 0x0606000A) { uint8_t tuyaindex = 0; - if (Settings.param[P_BACKLOG_DELAY] > 0) { // ex SetOption34 + if (Settings.param[P_BACKLOG_DELAY] > 0) { // ex SetOption34 Settings.tuya_fnid_map[tuyaindex].fnid = 21; // TUYA_MCU_FUNC_DIMMER - Move Tuya Dimmer Id to Map Settings.tuya_fnid_map[tuyaindex].dpid = Settings.param[P_BACKLOG_DELAY]; tuyaindex++; - } else if (Settings.flag3.ex_tuya_disable_dimmer == 1) { // ex SetOption65 + } else if (Settings.flag3.fast_power_cycle_disable == 1) { // ex SetOption65 Settings.tuya_fnid_map[tuyaindex].fnid = 11; // TUYA_MCU_FUNC_REL1 - Create FnID for Switches Settings.tuya_fnid_map[tuyaindex].dpid = 1; tuyaindex++; @@ -1195,6 +1197,20 @@ void SettingsDelta(void) Settings.dimmer_hw_max = Settings.param[P_ex_DIMMER_MAX]; } } + if (Settings.version < 0x06060014) { + // Clear unused parameters for future use + Settings.flag3.ex_tuya_dimmer_range_255 = 0; + Settings.flag3.ex_tuya_dimmer_min_limit = 0; + Settings.param[P_ex_TUYA_RELAYS] = 0; + Settings.param[P_ex_DIMMER_MAX] = 0; + Settings.param[P_ex_TUYA_VOLTAGE_ID] = 0; + Settings.param[P_ex_TUYA_CURRENT_ID] = 0; + Settings.param[P_ex_TUYA_POWER_ID] = 0; + Settings.ex_baudrate = 0; + Settings.ex_sbaudrate = 0; + + Settings.flag3.fast_power_cycle_disable = 0; + } Settings.version = VERSION; SettingsSave(1); diff --git a/sonoff/sonoff.ino b/sonoff/sonoff.ino index 1c6d95b4b..0fbc690cc 100755 --- a/sonoff/sonoff.ino +++ b/sonoff/sonoff.ino @@ -1472,7 +1472,6 @@ void setup(void) RtcRebootLoad(); if (!RtcRebootValid()) { RtcReboot.fast_reboot_count = 0; - UpdateQuickPowerCycle(true); // As RTC is invalid it must be a power cycle } RtcReboot.fast_reboot_count++; RtcRebootSave(); @@ -1497,6 +1496,7 @@ void setup(void) GetFeatures(); if (1 == RtcReboot.fast_reboot_count) { // Allow setting override only when all is well + UpdateQuickPowerCycle(true); XdrvCall(FUNC_SETTINGS_OVERRIDE); } @@ -1547,8 +1547,6 @@ void setup(void) } } -// UpdateQuickPowerCycle(true); // Test location - Format(mqtt_client, Settings.mqtt_client, sizeof(mqtt_client)); Format(mqtt_topic, Settings.mqtt_topic, sizeof(mqtt_topic)); if (strstr(Settings.hostname, "%") != nullptr) { diff --git a/sonoff/sonoff_version.h b/sonoff/sonoff_version.h index 828c71aa6..062d4dedf 100644 --- a/sonoff/sonoff_version.h +++ b/sonoff/sonoff_version.h @@ -20,6 +20,6 @@ #ifndef _SONOFF_VERSION_H_ #define _SONOFF_VERSION_H_ -const uint32_t VERSION = 0x06060013; +const uint32_t VERSION = 0x06060014; #endif // _SONOFF_VERSION_H_ diff --git a/sonoff/xdrv_04_light.ino b/sonoff/xdrv_04_light.ino index c4a4a2504..558b843da 100644 --- a/sonoff/xdrv_04_light.ino +++ b/sonoff/xdrv_04_light.ino @@ -1685,8 +1685,8 @@ void LightAnimate(void) for (uint32_t i = 0; i < 3; i++) { scale_col[i] = (0 == max) ? 255 : (255 > max) ? changeUIntScale(cur_col[i], 0, max, 0, 255) : cur_col[i]; } - AddLog_P2(LOG_LEVEL_DEBUG, PSTR("LGT: R%d(%d) G%d(%d) B%d(%d), C%d W%d, D%d"), - cur_col[0], scale_col[0], cur_col[1], scale_col[1], cur_col[2], scale_col[2], cur_col[3], cur_col[4], light_state.getDimmer()); +// AddLog_P2(LOG_LEVEL_DEBUG, PSTR("LGT: R%d(%d) G%d(%d) B%d(%d), C%d W%d, D%d"), +// cur_col[0], scale_col[0], cur_col[1], scale_col[1], cur_col[2], scale_col[2], cur_col[3], cur_col[4], light_state.getDimmer()); char *tmp_data = XdrvMailbox.data; char *tmp_topic = XdrvMailbox.topic; diff --git a/tools/decode-status.py b/tools/decode-status.py index 1abbc7b32..ce20da571 100755 --- a/tools/decode-status.py +++ b/tools/decode-status.py @@ -95,7 +95,7 @@ a_setoption = [[ "Ignore hold time (s)", "(not used) Number of Tuya MCU relays", "Over temperature threshold (celsius)", - "Tuya MCU max dimmer value", + "(not used) Tuya MCU max dimmer value", "(not used) Tuya MCU voltage Id", "(not used) Tuya MCU current Id", "(not used) Tuya MCU power Id", @@ -118,11 +118,11 @@ a_setoption = [[ "Do not use retain flag on HOLD messages", "Do not scan relay power state at restart", "Use _ instead of - as sensor index separator", - "(not used) Disable Dimmer slider control", - "Disable Dimmer range 255 slider control", + "Disable fast power cycle detection for device reset", + "(not used) Disable Dimmer range 255 slider control", "Enable buzzer when available", "Enable multi-channels PWM instead of Color PWM", - "Limits Tuya MCU dimmers to minimum of 10% (25) when enabled", + "(not used) Limits Tuya MCU dimmers to minimum of 10% (25) when enabled", "Enable Weekend Energy Tariff", "Select different Modbus registers for Active Energy", "","",