mirror of
https://github.com/espressif/openthread.git
synced 2026-08-05 10:27:49 +00:00
[mle] add link margin to parent selection criteria (#2242)
This commit is contained in:
@@ -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:
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user