Skip to content

Commit

Permalink
Merge pull request #9995 from emontnemery/fix_backlog_wrap_around
Browse files Browse the repository at this point in the history
Fix wraparound bug in backlog
  • Loading branch information
arendst authored Nov 27, 2020
2 parents 22fe64e + aa12879 commit c57e79d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions tasmota/support_command.ino
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ void CommandHandler(char* topicBuf, char* dataBuf, uint32_t data_len)

DEBUG_CORE_LOG(PSTR("CMD: Payload %d"), payload);

// TasmotaGlobal.backlog_delay = millis() + (100 * MIN_BACKLOG_DELAY);
TasmotaGlobal.backlog_delay = millis() + Settings.param[P_BACKLOG_DELAY];
// TasmotaGlobal.backlog_timer = millis() + (100 * MIN_BACKLOG_DELAY);
TasmotaGlobal.backlog_timer = millis() + Settings.param[P_BACKLOG_DELAY];

char command[CMDSZ] = { 0 };
XdrvMailbox.command = command;
Expand Down Expand Up @@ -344,7 +344,7 @@ void CmndBacklog(void)
}
// ResponseCmndChar(D_JSON_APPENDED);
ResponseClear();
TasmotaGlobal.backlog_delay = 0;
TasmotaGlobal.backlog_timer = millis();
} else {
bool blflag = BACKLOG_EMPTY;
#ifdef SUPPORT_IF_STATEMENT
Expand All @@ -359,10 +359,10 @@ void CmndBacklog(void)
void CmndDelay(void)
{
if ((XdrvMailbox.payload >= (MIN_BACKLOG_DELAY / 100)) && (XdrvMailbox.payload <= 3600)) {
TasmotaGlobal.backlog_delay = millis() + (100 * XdrvMailbox.payload);
TasmotaGlobal.backlog_timer = millis() + (100 * XdrvMailbox.payload);
}
uint32_t bl_delay = 0;
long bl_delta = TimePassedSince(TasmotaGlobal.backlog_delay);
long bl_delta = TimePassedSince(TasmotaGlobal.backlog_timer);
if (bl_delta < 0) { bl_delay = (bl_delta *-1) / 100; }
ResponseCmndNumber(bl_delay);
}
Expand Down
2 changes: 1 addition & 1 deletion tasmota/support_wifi.ino
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ void stationKeepAliveNow(void) {
}

void wifiKeepAlive(void) {
static uint32_t wifi_timer = 0; // Wifi keepalive timer
static uint32_t wifi_timer = millis(); // Wifi keepalive timer

uint32_t wifiTimerSec = Settings.param[P_ARP_GRATUITOUS]; // 8-bits number of seconds, or minutes if > 100

Expand Down
6 changes: 3 additions & 3 deletions tasmota/tasmota.ino
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ struct {
uint32_t baudrate; // Current Serial baudrate
uint32_t pulse_timer[MAX_PULSETIMERS]; // Power off timer
uint32_t blink_timer; // Power cycle timer
uint32_t backlog_delay; // Command backlog delay
uint32_t backlog_timer; // Timer for next command in backlog
uint32_t loop_load_avg; // Indicative loop load average
uint32_t web_log_index; // Index in Web log buffer
uint32_t uptime; // Counting every second until 4294967295 = 130 year
Expand Down Expand Up @@ -319,7 +319,7 @@ void setup(void) {
}

void BacklogLoop(void) {
if (TimeReached(TasmotaGlobal.backlog_delay)) {
if (TimeReached(TasmotaGlobal.backlog_timer)) {
if (!BACKLOG_EMPTY && !TasmotaGlobal.backlog_mutex) {
TasmotaGlobal.backlog_mutex = true;
bool nodelay = false;
Expand All @@ -341,7 +341,7 @@ void BacklogLoop(void) {
ExecuteCommand((char*)cmd.c_str(), SRC_BACKLOG);
}
if (nodelay) {
TasmotaGlobal.backlog_delay = 0; // Reset backlog_delay which has been set by ExecuteCommand (CommandHandler)
TasmotaGlobal.backlog_timer = millis(); // Reset backlog_timer which has been set by ExecuteCommand (CommandHandler)
}
TasmotaGlobal.backlog_mutex = false;
}
Expand Down

0 comments on commit c57e79d

Please sign in to comment.