* 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);
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;
}