]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - tos/lib/net/ctp/CtpRoutingEngineP.nc
bug fix: make evaluateEtx arg a 16 bit arg
[tinyos-2.x.git] / tos / lib / net / ctp / CtpRoutingEngineP.nc
index a2d935f8cfbbb8455511fc78a0b162e86508befb..ef3857ad8dfb4fbe3135b41c30d3ec17d1f5f5bd 100644 (file)
@@ -259,7 +259,7 @@ implementation {
 
     /* Converts the output of the link estimator to path metric
      * units, that can be *added* to form path metric measures */
-    uint16_t evaluateEtx(uint8_t quality) {
+    uint16_t evaluateEtx(uint16_t quality) {
         //dbg("TreeRouting","%s %d -> %d\n",__FUNCTION__,quality, quality+10);
         return (quality + 10);
     }
@@ -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;
     }