mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
trickle: use random_uint32_range
This commit is contained in:
parent
1e6b2bcd5d
commit
4303847333
@ -46,7 +46,7 @@ void trickle_interval(trickle_t *trickle)
|
|||||||
DEBUG("trickle: I == %" PRIu32 "\n", trickle->I);
|
DEBUG("trickle: I == %" PRIu32 "\n", trickle->I);
|
||||||
|
|
||||||
trickle->c = 0;
|
trickle->c = 0;
|
||||||
trickle->t = (trickle->I / 2) + (random_uint32() % ((trickle->I / 2) + 1));
|
trickle->t = (trickle->I / 2) + random_uint32_range(0, (trickle->I / 2) + 1);
|
||||||
|
|
||||||
trickle->msg_callback_time = trickle->t * SEC_IN_MS;
|
trickle->msg_callback_time = trickle->t * SEC_IN_MS;
|
||||||
xtimer_set_msg64(&trickle->msg_callback_timer, trickle->msg_callback_time,
|
xtimer_set_msg64(&trickle->msg_callback_timer, trickle->msg_callback_time,
|
||||||
@ -73,7 +73,7 @@ void trickle_start(kernel_pid_t pid, trickle_t *trickle, uint16_t interval_msg_t
|
|||||||
trickle->k = k;
|
trickle->k = k;
|
||||||
trickle->Imin = Imin;
|
trickle->Imin = Imin;
|
||||||
trickle->Imax = Imax;
|
trickle->Imax = Imax;
|
||||||
trickle->I = trickle->Imin + (random_uint32() % (4 * trickle->Imin));
|
trickle->I = trickle->Imin + random_uint32_range(0, 4 * trickle->Imin);
|
||||||
trickle->pid = pid;
|
trickle->pid = pid;
|
||||||
trickle->msg_interval.content.ptr = (char *)trickle;
|
trickle->msg_interval.content.ptr = (char *)trickle;
|
||||||
trickle->msg_interval.type = interval_msg_type;
|
trickle->msg_interval.type = interval_msg_type;
|
||||||
|
Loading…
Reference in New Issue
Block a user