[mle] add link margin to parent selection criteria (#2242)

This commit is contained in:
Jonathan Hui
2017-10-04 08:43:20 -07:00
committed by GitHub
parent 6933a1c680
commit 6dda5c8408
2 changed files with 10 additions and 3 deletions
+7 -2
View File
@@ -79,6 +79,7 @@ Mle::Mle(ThreadNetif &aThreadNetif) :
mParentLinkQuality2(0),
mParentLinkQuality1(0),
mChildUpdateAttempts(0),
mParentLinkMargin(0),
mParentIsSingleton(false),
mSocket(aThreadNetif.GetIp6().mUdp),
mTimeout(kMleEndDeviceTimeout),
@@ -2523,7 +2524,8 @@ exit:
return error;
}
bool Mle::IsBetterParent(uint16_t aRloc16, uint8_t aLinkQuality, ConnectivityTlv &aConnectivityTlv)
bool Mle::IsBetterParent(uint16_t aRloc16, uint8_t aLinkQuality, uint8_t aLinkMargin,
ConnectivityTlv &aConnectivityTlv)
{
bool rval = false;
@@ -2561,6 +2563,8 @@ bool Mle::IsBetterParent(uint16_t aRloc16, uint8_t aLinkQuality, ConnectivityTlv
ExitNow(rval = (aConnectivityTlv.GetLinkQuality1() > mParentLinkQuality1));
}
rval = (aLinkMargin > mParentLinkMargin);
exit:
return rval;
}
@@ -2664,7 +2668,7 @@ otError Mle::HandleParentResponse(const Message &aMessage, const Ip6::MessageInf
VerifyOrExit(compare >= 0);
// only consider better parents if the partitions are the same
VerifyOrExit(compare != 0 || IsBetterParent(sourceAddress.GetRloc16(), linkQuality, connectivity));
VerifyOrExit(compare != 0 || IsBetterParent(sourceAddress.GetRloc16(), linkQuality, linkMargin, connectivity));
}
// Link Frame Counter
@@ -2707,6 +2711,7 @@ otError Mle::HandleParentResponse(const Message &aMessage, const Ip6::MessageInf
mParentLeaderCost = connectivity.GetLeaderCost();
mParentLeaderData = leaderData;
mParentIsSingleton = connectivity.GetActiveRouters() <= 1;
mParentLinkMargin = linkMargin;
exit:
+3 -1
View File
@@ -1386,7 +1386,8 @@ private:
otError SendChildIdRequest(void);
void SendOrphanAnnounce(void);
bool IsBetterParent(uint16_t aRloc16, uint8_t aLinkQuality, ConnectivityTlv &aConnectivityTlv);
bool IsBetterParent(uint16_t aRloc16, uint8_t aLinkQuality, uint8_t aLinkMargin,
ConnectivityTlv &aConnectivityTlv);
void ResetParentCandidate(void);
#if OPENTHREAD_CONFIG_INFORM_PREVIOUS_PARENT_ON_REATTACH
@@ -1415,6 +1416,7 @@ private:
uint8_t mParentLinkQuality1;
uint8_t mChildUpdateAttempts;
LeaderDataTlv mParentLeaderData;
uint8_t mParentLinkMargin;
bool mParentIsSingleton;
Router mParentCandidate;