From 5d60a439391240ad2f87bc1337bf35a67e8a7619 Mon Sep 17 00:00:00 2001 From: Leif Jakob Date: Fri, 4 Oct 2019 12:46:31 +0000 Subject: [PATCH 1/2] process Backlog commands without minimum delay --- sonoff/sonoff.h | 2 +- sonoff/sonoff.ino | 33 ++++++++++++++++++--------------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/sonoff/sonoff.h b/sonoff/sonoff.h index c1c19f3fe..72d1608e0 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 = 0; // Minimal backlog delay in 0.1 seconds const uint32_t SOFT_BAUDRATE = 9600; // Default software serial baudrate const uint32_t APP_BAUDRATE = 115200; // Default serial baudrate diff --git a/sonoff/sonoff.ino b/sonoff/sonoff.ino index 8f0627b1b..c1f338acb 100755 --- a/sonoff/sonoff.ino +++ b/sonoff/sonoff.ino @@ -869,21 +869,6 @@ void Every100mSeconds(void) } } } - - // Backlog - if (TimeReached(backlog_delay)) { - if (!BACKLOG_EMPTY && !backlog_mutex) { - backlog_mutex = true; -#ifdef SUPPORT_IF_STATEMENT - ExecuteCommand((char*)backlog.shift().c_str(), SRC_BACKLOG); -#else - ExecuteCommand((char*)backlog[backlog_pointer].c_str(), SRC_BACKLOG); - backlog_pointer++; - if (backlog_pointer >= MAX_BACKLOG) { backlog_pointer = 0; } -#endif - backlog_mutex = false; - } - } } /*-------------------------------------------------------------------------------------------*\ @@ -1674,6 +1659,23 @@ void setup(void) XsnsCall(FUNC_INIT); } +static void BacklogLoop() +{ + if (TimeReached(backlog_delay)) { + if (!BACKLOG_EMPTY && !backlog_mutex) { + backlog_mutex = true; +#ifdef SUPPORT_IF_STATEMENT + ExecuteCommand((char*)backlog.shift().c_str(), SRC_BACKLOG); +#else + ExecuteCommand((char*)backlog[backlog_pointer].c_str(), SRC_BACKLOG); + backlog_pointer++; + if (backlog_pointer >= MAX_BACKLOG) { backlog_pointer = 0; } +#endif + backlog_mutex = false; + } + } +} + void loop(void) { uint32_t my_sleep = millis(); @@ -1685,6 +1687,7 @@ void loop(void) ButtonLoop(); SwitchLoop(); + BacklogLoop(); #ifdef ROTARY_V1 RotaryLoop(); #endif From 10babaf061e2f17f5fb7b92c2339263a7d2981b5 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Wed, 9 Oct 2019 17:16:52 +0200 Subject: [PATCH 2/2] Update sonoff.h --- sonoff/sonoff.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonoff/sonoff.h b/sonoff/sonoff.h index 72d1608e0..c1c19f3fe 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 = 0; // Minimal backlog delay in 0.1 seconds +const uint32_t MIN_BACKLOG_DELAY = 2; // Minimal backlog delay in 0.1 seconds const uint32_t SOFT_BAUDRATE = 9600; // Default software serial baudrate const uint32_t APP_BAUDRATE = 115200; // Default serial baudrate