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:
Łukasz Duda
2016-10-13 06:23:00 -07:00
committed by Jonathan Hui
parent c28042ce97
commit 04f13fef8b
+8 -1
View File
@@ -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();