From 46b2451969303cf5e74e22f6abd1403cbef1b2d4 Mon Sep 17 00:00:00 2001 From: adamdunkels Date: Wed, 22 Sep 2010 22:03:21 +0000 Subject: [PATCH] Made the initial link estimate explicit --- core/net/rime/collect-link-estimate.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/core/net/rime/collect-link-estimate.c b/core/net/rime/collect-link-estimate.c index 3c364b53c..82c779294 100644 --- a/core/net/rime/collect-link-estimate.c +++ b/core/net/rime/collect-link-estimate.c @@ -32,7 +32,7 @@ * * This file is part of the Contiki operating system. * - * $Id: collect-link-estimate.c,v 1.2 2010/09/13 13:28:14 adamdunkels Exp $ + * $Id: collect-link-estimate.c,v 1.3 2010/09/22 22:03:21 adamdunkels Exp $ */ /** @@ -51,6 +51,16 @@ collect-link-estimate.h. */ #define ETX_HISTORY_WINDOW 16 +#define INITIAL_LINK_ESTIMATE 4 + +#define DEBUG 0 +#if DEBUG +#include +#define PRINTF(...) printf(__VA_ARGS__) +#else +#define PRINTF(...) +#endif + /*---------------------------------------------------------------------------*/ void collect_link_estimate_new(struct collect_link_estimate *le) @@ -60,7 +70,7 @@ collect_link_estimate_new(struct collect_link_estimate *le) /* Start with a conservative / pessimistic estimate of link quality for new links. */ for(i = 0; i < ETX_HISTORY_WINDOW; i++) { - le->history[i] = 4; + le->history[i] = INITIAL_LINK_ESTIMATE; } le->historyptr = 0; } @@ -94,13 +104,13 @@ collect_link_estimate(struct collect_link_estimate *le) { int i, etx; - /* printf("collect_link_estimate: ");*/ + PRINTF("collect_link_estimate: "); etx = 0; for(i = 0; i < ETX_HISTORY_WINDOW; ++i) { - /* printf("%d ", le->history[i]);*/ + PRINTF("%d ", le->history[i]); etx += le->history[i]; } - /* printf(", %d\n", (COLLECT_LINK_ESTIMATE_UNIT * etx) / ETX_HISTORY_WINDOW);*/ + PRINTF(", %d\n", (COLLECT_LINK_ESTIMATE_UNIT * etx) / ETX_HISTORY_WINDOW); return (COLLECT_LINK_ESTIMATE_UNIT * etx) / ETX_HISTORY_WINDOW; } /*---------------------------------------------------------------------------*/