mirror of
https://github.com/espressif/openthread.git
synced 2026-08-06 18:57:47 +00:00
Trickle Timer: Allow other modules to set Imin equal to Imax (#802)
Currently, when TrickleTimer:Start method is called with same aIntervalMin and aIntervalMax, the remainder used to calculate I is 0, which cause an Arithmetic Error and crash of the program.
This commit is contained in:
committed by
Jonathan Hui
parent
c28042ce97
commit
04f13fef8b
@@ -71,7 +71,14 @@ void TrickleTimer::Start(uint32_t aIntervalMin, uint32_t aIntervalMax, Mode aMod
|
||||
mMode = aMode;
|
||||
|
||||
// Initialize I to [Imin, Imax]
|
||||
I = Imin + otPlatRandomGet() % (Imax - Imin);
|
||||
if (Imin == Imax)
|
||||
{
|
||||
I = Imin;
|
||||
}
|
||||
else
|
||||
{
|
||||
I = Imin + otPlatRandomGet() % (Imax - Imin);
|
||||
}
|
||||
|
||||
// Start a new interval
|
||||
StartNewInterval();
|
||||
|
||||
Reference in New Issue
Block a user