Bugfix to the Contiki LPP encounter timing code: encounters are now

properly timed.
This commit is contained in:
adamdunkels 2009-12-06 13:18:32 +00:00
parent 822149f943
commit 6897270289

View file

@ -28,7 +28,7 @@
* *
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
* $Id: lpp.c,v 1.27 2009/11/02 11:58:56 adamdunkels Exp $ * $Id: lpp.c,v 1.28 2009/12/06 13:18:32 adamdunkels Exp $
*/ */
/** /**
@ -90,7 +90,7 @@
#ifdef LPP_CONF_OFF_TIME #ifdef LPP_CONF_OFF_TIME
#define OFF_TIME LPP_CONF_OFF_TIME #define OFF_TIME LPP_CONF_OFF_TIME
#else #else
#define OFF_TIME (CLOCK_SECOND / 2) #define OFF_TIME (CLOCK_SECOND / 2 - LISTEN_TIME)
#endif /* LPP_CONF_OFF_TIME */ #endif /* LPP_CONF_OFF_TIME */
#define PACKET_LIFETIME (LISTEN_TIME + OFF_TIME) #define PACKET_LIFETIME (LISTEN_TIME + OFF_TIME)
@ -314,7 +314,7 @@ turn_radio_on_for_neighbor(rimeaddr_t *neighbor, struct queue_list_item *i)
time with modulo OFF_TIME. */ time with modulo OFF_TIME. */
now = clock_time(); now = clock_time();
wait = ((clock_time_t)(e->time - now)) % (OFF_TIME); wait = ((clock_time_t)(e->time - now)) % (OFF_TIME + LISTEN_TIME) - LISTEN_TIME;
/* printf("now %d e %d e-n %d w %d %d\n", now, e->time, e->time - now, (e->time - now) % (OFF_TIME), wait); /* printf("now %d e %d e-n %d w %d %d\n", now, e->time, e->time - now, (e->time - now) % (OFF_TIME), wait);