From 4d83f7631211b0d828c7d2ea1276e8e3049e901c Mon Sep 17 00:00:00 2001 From: gnawali Date: Wed, 31 Oct 2007 22:53:01 +0000 Subject: [PATCH] get etx now returns etx for the path to the root instead of etx from the current parent to the root --- tos/lib/net/ctp/CtpInfo.nc | 2 +- tos/lib/net/ctp/CtpRoutingEngineP.nc | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tos/lib/net/ctp/CtpInfo.nc b/tos/lib/net/ctp/CtpInfo.nc index 57c275ef..80745976 100644 --- a/tos/lib/net/ctp/CtpInfo.nc +++ b/tos/lib/net/ctp/CtpInfo.nc @@ -45,7 +45,7 @@ interface CtpInfo { * through the current parent. The pointer is allocated by the * caller. If the parent is invalid, return FAIL (no info). The * caller MUST NOT use the value in parent if the return is not - * SUCCESS. + * SUCCESS. Calling getEtx at the root will set the etx argument to 0. */ command error_t getEtx(uint16_t* etx); diff --git a/tos/lib/net/ctp/CtpRoutingEngineP.nc b/tos/lib/net/ctp/CtpRoutingEngineP.nc index a2d935f8..5a595341 100644 --- a/tos/lib/net/ctp/CtpRoutingEngineP.nc +++ b/tos/lib/net/ctp/CtpRoutingEngineP.nc @@ -548,7 +548,12 @@ implementation { return FAIL; if (routeInfo.parent == INVALID_ADDR) return FAIL; - *etx = routeInfo.etx; + if (state_is_root == 1) { + *etx = 0; + } else { + // path etx = etx(parent) + etx(link to the parent) + *etx = routeInfo.etx + evaluateEtx(call LinkEstimator.getLinkQuality(routeInfo.parent)); + } return SUCCESS; } -- 2.39.2