diff --git a/include/openthread/instance.h b/include/openthread/instance.h index cc2fdeb928f..8b2457196e0 100644 --- a/include/openthread/instance.h +++ b/include/openthread/instance.h @@ -53,7 +53,7 @@ extern "C" { * @note This number versions both OpenThread platform and user APIs. * */ -#define OPENTHREAD_API_VERSION (200) +#define OPENTHREAD_API_VERSION (201) /** * @addtogroup api-instance diff --git a/include/openthread/thread.h b/include/openthread/thread.h index fe829003cb6..052f4a5ca12 100644 --- a/include/openthread/thread.h +++ b/include/openthread/thread.h @@ -285,6 +285,22 @@ otError otThreadSetJoinerAdvertisement(otInstance * aInstance, #define OT_JOINER_ADVDATA_MAX_LENGTH 64 ///< Maximum AdvData Length of Joiner Advertisement +/** + * Resynchronize a sleepy child with its parent, in case the Keep-alives + * are getting erroneously acknowledged. This function will send a child + * update request to the parent, if the device is a rx-off-when-idle (i.e. sleepy) + * child. + * + * @param aInstance A pointer to an OpenThread instance. + * + * @retval OT_ERROR_NONE Successfully attempted to resynchronize with the parent. + * @retval OT_ERROR_REJECTED The device is not a rx-off-when-idle child, so + * no attempt to resynchronize was made + * @retval OT_ERROR_NO_BUFS Insufficient buffers to generate the MLE Child Update Request. + * + */ +otError otThreadSleepyChildResynchronize(otInstance *aInstance); + /** * Get the Thread Child Timeout used when operating in the Child role. * diff --git a/src/core/api/thread_api.cpp b/src/core/api/thread_api.cpp index 8ec7a6bf735..0102fb9bcb0 100644 --- a/src/core/api/thread_api.cpp +++ b/src/core/api/thread_api.cpp @@ -43,7 +43,21 @@ using namespace ot; -uint32_t otThreadGetChildTimeout(otInstance *aInstance) +uint32_t otError otThreadSleepyChildResynchronize(otInstance *aInstance) +{ + Error error = kErrorNone; + Instance &instance = AsCoreType(aInstance); + + VerifyOrExit(instance.Get().IsChild(), error = kErrorRejected); + VerifyOrExit(instance.Get().GetRxOnWhenIdle() == false, error = kErrorRejected); + + error = AsCoreType(aInstance).Get().SendChildUpdateRequest(); + +exit: + return error; +} + +otThreadGetChildTimeout(otInstance *aInstance) { return AsCoreType(aInstance).Get().GetTimeout(); }