From 63ea56256885b376d6fdfa3845bb81dbb8486924 Mon Sep 17 00:00:00 2001 From: simonduq Date: Mon, 26 Mar 2012 22:49:28 +0200 Subject: [PATCH] base encounter_time on the time before last strobe, remove unused previous_txtime --- core/net/mac/contikimac.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/core/net/mac/contikimac.c b/core/net/mac/contikimac.c index 93bf4f5ea..ded95cada 100644 --- a/core/net/mac/contikimac.c +++ b/core/net/mac/contikimac.c @@ -522,7 +522,7 @@ static int send_packet(mac_callback_t mac_callback, void *mac_callback_ptr, struct rdc_buf_list *buf_list) { rtimer_clock_t t0; - rtimer_clock_t encounter_time = 0, previous_txtime = 0; + rtimer_clock_t encounter_time = 0; int strobes; uint8_t got_strobe_ack = 0; int hdrlen, len; @@ -723,7 +723,6 @@ send_packet(mac_callback_t mac_callback, void *mac_callback_ptr, struct rdc_buf_ watchdog_periodic(); t0 = RTIMER_NOW(); seqno = packetbuf_attr(PACKETBUF_ATTR_MAC_SEQNO); - previous_txtime = RTIMER_NOW(); for(strobes = 0, collisions = 0; got_strobe_ack == 0 && collisions == 0 && RTIMER_CLOCK_LT(RTIMER_NOW(), t0 + STROBE_TIME); strobes++) { @@ -751,7 +750,7 @@ send_packet(mac_callback_t mac_callback, void *mac_callback_ptr, struct rdc_buf_ if(ret == RADIO_TX_OK) { if(!is_broadcast) { got_strobe_ack = 1; - encounter_time = previous_txtime; + encounter_time = txtime; break; } } else if (ret == RADIO_TX_NOACK) { @@ -776,7 +775,7 @@ send_packet(mac_callback_t mac_callback, void *mac_callback_ptr, struct rdc_buf_ len = NETSTACK_RADIO.read(ackbuf, ACK_LEN); if(len == ACK_LEN && seqno == ackbuf[ACK_LEN-1]) { got_strobe_ack = 1; - encounter_time = previous_txtime; + encounter_time = txtime; break; } else { PRINTF("contikimac: collisions while sending\n"); @@ -784,8 +783,6 @@ send_packet(mac_callback_t mac_callback, void *mac_callback_ptr, struct rdc_buf_ } } #endif /* RDC_CONF_HARDWARE_ACK */ - - previous_txtime = txtime; } }