otError otThreadGetParentLastRssi(otInstance *aInstance, int8_t *aLastRssi) { otError error = OT_ERROR_NONE; Instance &instance = *static_cast<Instance *>(aInstance); Router * parent; VerifyOrExit(aLastRssi != NULL, error = OT_ERROR_INVALID_ARGS); parent = instance.GetThreadNetif().GetMle().GetParent(); *aLastRssi = parent->GetLinkInfo().GetLastRss(); VerifyOrExit(*aLastRssi != OT_RADIO_RSSI_INVALID, error = OT_ERROR_FAILED); exit: return error; }
otError otThreadGetParentInfo(otInstance *aInstance, otRouterInfo *aParentInfo) { otError error = OT_ERROR_NONE; Instance &instance = *static_cast<Instance *>(aInstance); Router * parent; VerifyOrExit(aParentInfo != NULL, error = OT_ERROR_INVALID_ARGS); parent = instance.GetThreadNetif().GetMle().GetParent(); aParentInfo->mExtAddress = parent->GetExtAddress(); aParentInfo->mRloc16 = parent->GetRloc16(); aParentInfo->mRouterId = Mle::Mle::GetRouterId(parent->GetRloc16()); aParentInfo->mNextHop = parent->GetNextHop(); 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 = parent->IsAllocated(); aParentInfo->mLinkEstablished = parent->GetState() == Neighbor::kStateValid; exit: return error; }