mirror of
https://github.com/espressif/openthread.git
synced 2026-08-06 02:37:47 +00:00
[time] adding Time class (#4195)
This commit adds `Time` class which represents an instance of time (it is a simple wrapper over a `uint32_t` corresponding to a numerical time value). The `Time` class provides helpful operator overloads: - Operators `+` and `-` with a `Time` instance and a `Duration` to get a `Time` instance after or before. - Operator `-` with two `Time` instances to calculate the `Duration` duration between two time instances. - Operators `<`, `<=`, `>`,'>=', '==' and `!=` to compare two `Time` instances. They correctly handle the wrapping of numeric time value. The core modules are updated to use the new `Time` and `Duration` types which help make the code simpler. This commit also updates the unit test `test_timer` to add test cases for newly added types.
This commit is contained in:
committed by
Jonathan Hui
parent
43be2b821f
commit
4feadec950
@@ -320,8 +320,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::Elapsed(parent->GetLastHeard())));
|
||||
aParentInfo->mAllocated = true;
|
||||
aParentInfo->mAge = static_cast<uint8_t>(Time::MsecToSec(TimerMilli::GetNow() - parent->GetLastHeard()));
|
||||
aParentInfo->mAllocated = true;
|
||||
aParentInfo->mLinkEstablished = parent->GetState() == Neighbor::kStateValid;
|
||||
|
||||
#if !OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
|
||||
|
||||
Reference in New Issue
Block a user