[timer] fix elapsed overflow (#3789)

This commit fixes a bug in the commissioner when a joiner's expiration
time has alerady elapsed.

This commit also introduces convenience methods for computing time
elapsed and diffs.
This commit is contained in:
Yakun Xu
2019-05-02 23:44:37 +08:00
committed by Jonathan Hui
parent 267a3b3e29
commit ae4ef9eb3e
19 changed files with 126 additions and 64 deletions
+2 -2
View File
@@ -360,8 +360,8 @@ otError otThreadGetParentInfo(otInstance *aInstance, otRouterInfo *aParentInfo)
aParentInfo->mPathCost = parent->GetCost();
aParentInfo->mLinkQualityIn = parent->GetLinkInfo().GetLinkQuality();
aParentInfo->mLinkQualityOut = parent->GetLinkQualityOut();
aParentInfo->mAge = static_cast<uint8_t>(TimerMilli::MsecToSec(TimerMilli::GetNow() - parent->GetLastHeard()));
aParentInfo->mAllocated = true;
aParentInfo->mAge = static_cast<uint8_t>(TimerMilli::MsecToSec(TimerMilli::Elapsed(parent->GetLastHeard())));
aParentInfo->mAllocated = true;
aParentInfo->mLinkEstablished = parent->GetState() == Neighbor::kStateValid;
exit: