mirror of
https://github.com/espressif/openthread.git
synced 2026-10-28 18:24:37 +00:00
Parent Info (#1370)
* Expanded otGetParentInfo to populate the entire aParentInfo structure * Added otGetParentAverageRssi function * Use GetRouterId from rloc function instead of doing it manualy, and corrected documentation
This commit is contained in:
+10
-1
@@ -1933,7 +1933,7 @@ OTAPI uint8_t OTCALL otGetRouterIdSequence(otInstance *aInstance);
|
||||
OTAPI ThreadError OTCALL otGetRouterInfo(otInstance *aInstance, uint16_t aRouterId, otRouterInfo *aRouterInfo);
|
||||
|
||||
/**
|
||||
* The function retains diagnostic information for a Thread Router as parent.
|
||||
* The function retrieves diagnostic information for a Thread Router as parent.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[out] aParentInfo A pointer to where the parent router information is placed.
|
||||
@@ -1941,6 +1941,15 @@ OTAPI ThreadError OTCALL otGetRouterInfo(otInstance *aInstance, uint16_t aRouter
|
||||
*/
|
||||
OTAPI ThreadError OTCALL otGetParentInfo(otInstance *aInstance, otRouterInfo *aParentInfo);
|
||||
|
||||
/**
|
||||
* The function retrieves the average RSSI for the Thread Parent.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[out] aParentInfo A pointer to where the parent rssi should be placed.
|
||||
*
|
||||
*/
|
||||
OTAPI ThreadError OTCALL otGetParentAverageRssi(otInstance *aInstance, int8_t *aParentRssi);
|
||||
|
||||
/**
|
||||
* Get the Stable Network Data Version.
|
||||
*
|
||||
|
||||
+26
-1
@@ -906,7 +906,32 @@ ThreadError otGetParentInfo(otInstance *aInstance, otRouterInfo *aParentInfo)
|
||||
|
||||
parent = aInstance->mThreadNetif.GetMle().GetParent();
|
||||
memcpy(aParentInfo->mExtAddress.m8, parent->mMacAddr.m8, OT_EXT_ADDRESS_SIZE);
|
||||
aParentInfo->mRloc16 = parent->mValid.mRloc16;
|
||||
|
||||
aParentInfo->mRloc16 = parent->mValid.mRloc16;
|
||||
aParentInfo->mRouterId = Mle::Mle::GetRouterId(parent->mValid.mRloc16);
|
||||
aParentInfo->mNextHop = parent->mNextHop;
|
||||
aParentInfo->mPathCost = parent->mCost;
|
||||
aParentInfo->mLinkQualityIn = parent->mLinkInfo.GetLinkQuality(aInstance->mThreadNetif.GetMac().GetNoiseFloor());
|
||||
aParentInfo->mLinkQualityOut = parent->mLinkQualityOut;
|
||||
aParentInfo->mAge = static_cast<uint8_t>(Timer::MsecToSec(Timer::GetNow() - parent->mLastHeard));
|
||||
aParentInfo->mAllocated = parent->mAllocated;
|
||||
aParentInfo->mLinkEstablished = parent->mState == Neighbor::kStateValid;
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
ThreadError otGetParentAverageRssi(otInstance *aInstance, int8_t *aParentRssi)
|
||||
{
|
||||
ThreadError error = kThreadError_None;
|
||||
Router *parent;
|
||||
|
||||
VerifyOrExit(aParentRssi != NULL, error = kThreadError_InvalidArgs);
|
||||
|
||||
parent = aInstance->mThreadNetif.GetMle().GetParent();
|
||||
*aParentRssi = parent->mLinkInfo.GetAverageRss();
|
||||
|
||||
VerifyOrExit(*aParentRssi != LinkQualityInfo::kUnknownRss, error = kThreadError_Failed);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
|
||||
Reference in New Issue
Block a user