From ded722ed7b1fd03d90c59ab063c9e220b8339fb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hubert=20Mi=C5=9B?= Date: Tue, 31 Jan 2017 18:33:02 +0100 Subject: [PATCH] Allow SED to reattach to it's parent if the link was lost before timeout. (#1234) * Note in API description that SED poll period is separated from child timeout. * Allow reattach of SED that detached from it's parent but did not timeout. --- include/openthread.h | 3 +++ src/core/thread/mle_router.cpp | 11 ++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/include/openthread.h b/include/openthread.h index 2283d450e..817e62aab 100644 --- a/include/openthread.h +++ b/include/openthread.h @@ -1028,6 +1028,9 @@ OTAPI ThreadError OTCALL otSendPendingSet(otInstance *aInstance, const otOperati /** * Get the data poll period of sleepy end device. * + * @note This function updates only poll period of sleepy end device. To update child timeout the function + * otGetChildTimeout() shall be called. + * * @param[in] aInstance A pointer to an OpenThread instance. * * @returns The data poll period of sleepy end device. diff --git a/src/core/thread/mle_router.cpp b/src/core/thread/mle_router.cpp index d37a55a02..b3369de41 100644 --- a/src/core/thread/mle_router.cpp +++ b/src/core/thread/mle_router.cpp @@ -1670,7 +1670,16 @@ ThreadError MleRouter::HandleParentRequest(const Message &aMessage, const Ip6::M SuccessOrExit(error = Tlv::GetTlv(aMessage, Tlv::kChallenge, sizeof(challenge), challenge)); VerifyOrExit(challenge.IsValid(), error = kThreadError_Parse); - if ((child = FindChild(macAddr)) == NULL) + child = FindChild(macAddr); + + if (child != NULL && !(child->mMode & ModeTlv::kModeFFD)) + { + // Parent Request from a MTD child means that the child had detached. It can be safely removed. + RemoveNeighbor(*child); + child = NULL; + } + + if (child == NULL) { VerifyOrExit((child = NewChild()) != NULL, ;);