From 1640b11972b66f0f5cf40d79254459c32e58d2b9 Mon Sep 17 00:00:00 2001 From: adamdunkels Date: Tue, 8 Jan 2008 07:54:16 +0000 Subject: [PATCH] The radio driver now takes care of adjusting for the transmission time --- core/sys/timesynch.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/core/sys/timesynch.c b/core/sys/timesynch.c index ecf8c33db..adb808bd7 100644 --- a/core/sys/timesynch.c +++ b/core/sys/timesynch.c @@ -34,7 +34,7 @@ * * This file is part of the Contiki operating system. * - * $Id: timesynch.c,v 1.4 2007/12/23 14:57:11 oliverschmidt Exp $ + * $Id: timesynch.c,v 1.5 2008/01/08 07:54:16 adamdunkels Exp $ */ /** @@ -107,25 +107,36 @@ read_packet(void) len = mac->read(); + if(len == 0) { + return 0; + } + /* We check the authority level of the sender of the incoming packet. If the sending node has a lower authority level than we have, we synchronize to the time of the sending node and set our own authority level to be one more than the sending node. */ if(simple_cc2420_authority_level_of_sender < authority_level) { - adjust_offset(simple_cc2420_time_of_departure + - simple_cc2420_time_for_transmission, + + adjust_offset(simple_cc2420_time_of_departure, simple_cc2420_time_of_arrival); if(simple_cc2420_authority_level_of_sender + 1 != authority_level) { authority_level = simple_cc2420_authority_level_of_sender + 1; } - /* XXX the authority level should be increased over time except - for the sink node. */ } return len; } /*---------------------------------------------------------------------------*/ +#if 0 +static void +periodic_authority_increase(void *ptr) +{ + /* XXX the authority level should be increased over time except + for the sink node (which has authority 0). */ +} +#endif +/*---------------------------------------------------------------------------*/ static void set_receive_function(void (* recv)(const struct mac_driver *)) {