diff --git a/sonoff/_changelog.ino b/sonoff/_changelog.ino index 7607b1a48..d82502b4d 100644 --- a/sonoff/_changelog.ino +++ b/sonoff/_changelog.ino @@ -1,4 +1,7 @@ /*********************************************************************************************\ + * 6.6.0.17 20191009 + * Add command SetOption34 0..255 to set backlog delay. Default value is 200 (mSeconds) (#6562) + * * 6.6.0.16 20191008 * Change PZEM004T default address mask from 0.0.0.x to 192.168.1.x for legacy reason (#6585) * Fix PZEM004T, PZEMAC and PZEMDC autodetection (#6585) diff --git a/sonoff/settings.ino b/sonoff/settings.ino index 908ab8337..12647de97 100644 --- a/sonoff/settings.ino +++ b/sonoff/settings.ino @@ -566,6 +566,7 @@ void SettingsDefaultSet2(void) // Settings.flag.value_units = 0; // Settings.flag.stop_flash_rotate = 0; Settings.save_data = SAVE_DATA; + Settings.param[P_BACKLOG_DELAY] = MIN_BACKLOG_DELAY; Settings.param[P_BOOT_LOOP_OFFSET] = BOOT_LOOP_OFFSET; Settings.param[P_RGB_REMAP] = RGB_REMAP_RGBW; Settings.sleep = APP_SLEEP; @@ -1097,9 +1098,9 @@ void SettingsDelta(void) if (Settings.version < 0x0606000A) { uint8_t tuyaindex = 0; - if (Settings.param[P_ex_TUYA_DIMMER_ID] > 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_ex_TUYA_DIMMER_ID]; + Settings.tuya_fnid_map[tuyaindex].dpid = Settings.param[P_BACKLOG_DELAY]; tuyaindex++; } else if (Settings.flag3.ex_tuya_disable_dimmer == 1) { // ex SetOption65 Settings.tuya_fnid_map[tuyaindex].fnid = 11; // TUYA_MCU_FUNC_REL1 - Create FnID for Switches @@ -1136,6 +1137,9 @@ void SettingsDelta(void) Settings.shutter_accuracy = 0; Settings.mqttlog_level = MQTT_LOG_LEVEL; } + if (Settings.version < 0x06060011) { + Settings.param[P_BACKLOG_DELAY] = MIN_BACKLOG_DELAY; + } Settings.version = VERSION; SettingsSave(1); diff --git a/sonoff/sonoff.h b/sonoff/sonoff.h index dbdeadc0c..500933374 100644 --- a/sonoff/sonoff.h +++ b/sonoff/sonoff.h @@ -124,7 +124,7 @@ const uint16_t MIN_MESSZ = 893; // Min number of characters in MQTT const uint8_t SENSOR_MAX_MISS = 5; // Max number of missed sensor reads before deciding it's offline const uint8_t MAX_BACKLOG = 30; // Max number of commands in backlog -const uint32_t MIN_BACKLOG_DELAY = 2; // Minimal backlog delay in 0.1 seconds +const uint32_t MIN_BACKLOG_DELAY = 200; // Minimal backlog delay in mSeconds const uint32_t SOFT_BAUDRATE = 9600; // Default software serial baudrate const uint32_t APP_BAUDRATE = 115200; // Default serial baudrate @@ -245,7 +245,7 @@ enum ButtonStates { PRESSED, NOT_PRESSED }; enum Shortcuts { SC_CLEAR, SC_DEFAULT, SC_USER }; -enum SettingsParamIndex { P_HOLD_TIME, P_MAX_POWER_RETRY, P_ex_TUYA_DIMMER_ID, P_MDNS_DELAYED_START, P_BOOT_LOOP_OFFSET, P_RGB_REMAP, P_IR_UNKNOW_THRESHOLD, // SetOption32 .. SetOption38 +enum SettingsParamIndex { P_HOLD_TIME, P_MAX_POWER_RETRY, P_BACKLOG_DELAY, P_MDNS_DELAYED_START, P_BOOT_LOOP_OFFSET, P_RGB_REMAP, P_IR_UNKNOW_THRESHOLD, // SetOption32 .. SetOption38 P_CSE7766_INVALID_POWER, P_HOLD_IGNORE, P_ex_TUYA_RELAYS, P_OVER_TEMP, // SetOption39 .. SetOption42 P_DIMMER_MAX, P_ex_TUYA_VOLTAGE_ID, P_ex_TUYA_CURRENT_ID, P_ex_TUYA_POWER_ID, // SetOption43 .. SetOption46 diff --git a/sonoff/sonoff.ino b/sonoff/sonoff.ino index 16fa50868..b07b4c721 100755 --- a/sonoff/sonoff.ino +++ b/sonoff/sonoff.ino @@ -1642,10 +1642,10 @@ void loop(void) ButtonLoop(); SwitchLoop(); - BacklogLoop(); #ifdef ROTARY_V1 RotaryLoop(); #endif + BacklogLoop(); if (TimeReached(state_50msecond)) { SetNextTimeInterval(state_50msecond, 50); diff --git a/sonoff/support_command.ino b/sonoff/support_command.ino index fbc6316c5..b36abf714 100644 --- a/sonoff/support_command.ino +++ b/sonoff/support_command.ino @@ -180,7 +180,8 @@ void CommandHandler(char* topicBuf, char* dataBuf, uint32_t data_len) DEBUG_CORE_LOG(PSTR("CMD: Payload %d"), payload); - backlog_delay = millis() + (100 * MIN_BACKLOG_DELAY); +// backlog_delay = millis() + (100 * MIN_BACKLOG_DELAY); + backlog_delay = millis() + Settings.param[P_BACKLOG_DELAY]; char command[CMDSZ]; XdrvMailbox.command = command; @@ -283,7 +284,7 @@ void CmndBacklog(void) void CmndDelay(void) { - if ((XdrvMailbox.payload >= MIN_BACKLOG_DELAY) && (XdrvMailbox.payload <= 3600)) { + if ((XdrvMailbox.payload >= (MIN_BACKLOG_DELAY / 100)) && (XdrvMailbox.payload <= 3600)) { backlog_delay = millis() + (100 * XdrvMailbox.payload); } uint32_t bl_delay = 0;