mirror of
https://github.com/espressif/openthread.git
synced 2026-09-14 13:10:08 +00:00
[mle] maintain best parent candidate during router-only search (#3803)
* maintain best parent candidate during router-only search * add margin for duplicate parent request check
This commit is contained in:
committed by
Jonathan Hui
parent
55da08861e
commit
5a7faa539f
@@ -1606,8 +1606,13 @@ void Mle::HandleAttachTimer(void)
|
|||||||
// to which the device is attached. This ensures that the
|
// to which the device is attached. This ensures that the
|
||||||
// new parent candidate is compared with the current parent
|
// new parent candidate is compared with the current parent
|
||||||
// and that it is indeed preferred over the current one.
|
// and that it is indeed preferred over the current one.
|
||||||
|
// If we are in kAttachStateParentRequestRouter and cannot
|
||||||
|
// find a parent with best link quality(3), we will keep
|
||||||
|
// the candidate and forward to REED stage to find a better
|
||||||
|
// parent.
|
||||||
|
|
||||||
if (mParentCandidate.GetState() == Neighbor::kStateParentResponse &&
|
if ((mParentCandidate.GetLinkInfo().GetLinkQuality() == 3 || mAttachState != kAttachStateParentRequestRouter) &&
|
||||||
|
mParentCandidate.GetState() == Neighbor::kStateParentResponse &&
|
||||||
(mRole != OT_DEVICE_ROLE_CHILD || mReceivedResponseFromParent || mParentRequestMode == kAttachBetter) &&
|
(mRole != OT_DEVICE_ROLE_CHILD || mReceivedResponseFromParent || mParentRequestMode == kAttachBetter) &&
|
||||||
SendChildIdRequest() == OT_ERROR_NONE)
|
SendChildIdRequest() == OT_ERROR_NONE)
|
||||||
{
|
{
|
||||||
@@ -3133,8 +3138,6 @@ otError Mle::HandleParentResponse(const Message &aMessage, const Ip6::MessageInf
|
|||||||
|
|
||||||
linkQuality = LinkQualityInfo::ConvertLinkMarginToLinkQuality(linkMargin);
|
linkQuality = LinkQualityInfo::ConvertLinkMarginToLinkQuality(linkMargin);
|
||||||
|
|
||||||
VerifyOrExit(mAttachState != kAttachStateParentRequestRouter || linkQuality == 3);
|
|
||||||
|
|
||||||
// Connectivity
|
// Connectivity
|
||||||
SuccessOrExit(error = Tlv::GetTlv(aMessage, Tlv::kConnectivity, sizeof(connectivity), connectivity));
|
SuccessOrExit(error = Tlv::GetTlv(aMessage, Tlv::kConnectivity, sizeof(connectivity), connectivity));
|
||||||
VerifyOrExit(connectivity.IsValid(), error = OT_ERROR_PARSE);
|
VerifyOrExit(connectivity.IsValid(), error = OT_ERROR_PARSE);
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ enum
|
|||||||
kThreadVersion = 2, ///< Thread Version
|
kThreadVersion = 2, ///< Thread Version
|
||||||
kUdpPort = 19788, ///< MLE UDP Port
|
kUdpPort = 19788, ///< MLE UDP Port
|
||||||
kParentRequestRouterTimeout = 750, ///< Router Parent Request timeout
|
kParentRequestRouterTimeout = 750, ///< Router Parent Request timeout
|
||||||
|
kParentRequestDuplicateMargin = 50, ///< Margin for duplicate parent request
|
||||||
kParentRequestReedTimeout = 1250, ///< Router and REEDs Parent Request timeout
|
kParentRequestReedTimeout = 1250, ///< Router and REEDs Parent Request timeout
|
||||||
kAttachStartJitter = 50, ///< Maximum jitter time added to start of attach.
|
kAttachStartJitter = 50, ///< Maximum jitter time added to start of attach.
|
||||||
kAnnounceProcessTimeout = 250, ///< Timeout after receiving Announcement before channel/pan-id change
|
kAnnounceProcessTimeout = 250, ///< Timeout after receiving Announcement before channel/pan-id change
|
||||||
|
|||||||
@@ -1649,7 +1649,7 @@ otError MleRouter::HandleParentRequest(const Message &aMessage, const Ip6::Messa
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else if (TimerMilli::Elapsed(child->GetLastHeard()) < kParentRequestRouterTimeout)
|
else if (TimerMilli::Elapsed(child->GetLastHeard()) < kParentRequestRouterTimeout - kParentRequestDuplicateMargin)
|
||||||
{
|
{
|
||||||
ExitNow(error = OT_ERROR_DUPLICATED);
|
ExitNow(error = OT_ERROR_DUPLICATED);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user