Fixed problem with too large values for the DIO timer.
This commit is contained in:
parent
5f40a5d63e
commit
486f202d09
1 changed files with 10 additions and 4 deletions
|
@ -32,7 +32,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* This file is part of the Contiki operating system.
|
||||||
*
|
*
|
||||||
* $Id: rpl-timers.c,v 1.14 2010/12/13 16:52:02 dak664 Exp $
|
* $Id: rpl-timers.c,v 1.15 2010/12/15 12:12:27 nvt-se Exp $
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* \file
|
* \file
|
||||||
|
@ -82,19 +82,25 @@ handle_periodic_timer(void *ptr)
|
||||||
static void
|
static void
|
||||||
new_dio_interval(rpl_dag_t *dag)
|
new_dio_interval(rpl_dag_t *dag)
|
||||||
{
|
{
|
||||||
unsigned long time;
|
uint32_t time;
|
||||||
|
|
||||||
/* TODO: too small timer intervals for many cases */
|
/* TODO: too small timer intervals for many cases */
|
||||||
time = 1UL << dag->dio_intcurrent;
|
time = 1UL << dag->dio_intcurrent;
|
||||||
|
|
||||||
/* need to convert from milliseconds to CLOCK_TICKS */
|
/* Convert from milliseconds to CLOCK_TICKS. */
|
||||||
time = (time * CLOCK_SECOND) / 1000;
|
time = (time * CLOCK_SECOND) / 1000;
|
||||||
|
|
||||||
dag->dio_next_delay = time;
|
dag->dio_next_delay = time;
|
||||||
|
|
||||||
/* random number between I/2 and I */
|
/* random number between I/2 and I */
|
||||||
time = time >> 1;
|
time = time >> 1;
|
||||||
time += (time * random_rand()) / RANDOM_RAND_MAX;
|
time += (time * random_rand()) / RANDOM_RAND_MAX;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The intervals must be equally long among the nodes for Trickle to
|
||||||
|
* operate efficiently. Therefore we need to calculate the delay between
|
||||||
|
* the randomized time and the start time of the next interval.
|
||||||
|
*/
|
||||||
dag->dio_next_delay -= time;
|
dag->dio_next_delay -= time;
|
||||||
dag->dio_send = 1;
|
dag->dio_send = 1;
|
||||||
|
|
||||||
|
@ -116,7 +122,7 @@ new_dio_interval(rpl_dag_t *dag)
|
||||||
|
|
||||||
/* schedule the timer */
|
/* schedule the timer */
|
||||||
PRINTF("RPL: Scheduling DIO timer %lu ticks in future (Interval)\n", time);
|
PRINTF("RPL: Scheduling DIO timer %lu ticks in future (Interval)\n", time);
|
||||||
ctimer_set(&dag->dio_timer, time & 0xffff, &handle_dio_timer, dag);
|
ctimer_set(&dag->dio_timer, time, &handle_dio_timer, dag);
|
||||||
}
|
}
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in a new issue