Skip to content

Commit f0f9a05

Browse files
committed
TimedAttempt: fix overflow bug
1 parent f3c6faa commit f0f9a05

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/time/TimedAttempt.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ namespace arduino { namespace time {
4949
unsigned long TimedAttempt::reload() {
5050
unsigned long shift = _retryCount > 31 ? 31 : _retryCount;
5151
unsigned long delay = (1UL << shift) * _minDelay;
52-
_retryDelay = min(delay, _maxDelay);
52+
/* delay should always increase */
53+
_retryDelay = (delay > _retryDelay) ? min(delay, _maxDelay): _maxDelay;
5354
_retryTick = millis();
5455
return _retryDelay;
5556
}

0 commit comments

Comments
 (0)