Skip to content

Commit

Permalink
Merge pull request #4 from Cascoda/elie-sleepy-resynch
Browse files Browse the repository at this point in the history
Adds API for resynchronizing sleepy child with its parent
  • Loading branch information
elie-elkhoury committed May 3, 2024
2 parents fb85d00 + 919e199 commit c0f30d6
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
2 changes: 1 addition & 1 deletion include/openthread/instance.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
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

0 comments on commit c0f30d6

Please sign in to comment.