Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds API for resynchronizing sleepy child with its parent #4

Merged
merged 3 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions include/openthread/thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
16 changes: 15 additions & 1 deletion src/core/api/thread_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Mle::MleRouter>().IsChild(), error = kErrorRejected);
VerifyOrExit(instance.Get<MeshForwarder>().GetRxOnWhenIdle() == false, error = kErrorRejected);

error = AsCoreType(aInstance).Get<Mle::MleRouter>().SendChildUpdateRequest();

exit:
return error;
}

otThreadGetChildTimeout(otInstance *aInstance)
{
return AsCoreType(aInstance).Get<Mle::MleRouter>().GetTimeout();
}
Expand Down
Loading