mirror of https://github.com/arendst/Tasmota.git
Merge pull request #9995 from emontnemery/fix_backlog_wrap_around
Fix wraparound bug in backlog
This commit is contained in:
commit
c57e79d51f
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue