mirror of
https://github.com/espressif/openthread.git
synced 2026-08-02 09:07:47 +00:00
[joiner] check Thread state on start (#5173)
This commit is contained in:
@@ -53,7 +53,7 @@ extern "C" {
|
||||
* @note This number versions both OpenThread platform and user APIs.
|
||||
*
|
||||
*/
|
||||
#define OPENTHREAD_API_VERSION (11)
|
||||
#define OPENTHREAD_API_VERSION (12)
|
||||
|
||||
/**
|
||||
* @addtogroup api-instance
|
||||
|
||||
@@ -106,8 +106,10 @@ typedef void (*otJoinerCallback)(otError aError, void *aContext);
|
||||
* @param[in] aCallback A pointer to a function that is called when the join operation completes.
|
||||
* @param[in] aContext A pointer to application-specific context.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully started the Commissioner role.
|
||||
* @retval OT_ERROR_NONE Successfully started the Joiner role.
|
||||
* @retval OT_ERROR_BUSY The previous attempt is still on-going.
|
||||
* @retval OT_ERROR_INVALID_ARGS @p aPskd or @p aProvisioningUrl is invalid.
|
||||
* @retval OT_ERROR_INVALID_STATE The IPv6 stack is not enabled or Thread stack is fully enabled.
|
||||
*
|
||||
*/
|
||||
otError otJoinerStart(otInstance * aInstance,
|
||||
|
||||
@@ -143,6 +143,8 @@ otError Joiner::Start(const char * aPskd,
|
||||
otLogInfoMeshCoP("Joiner starting");
|
||||
|
||||
VerifyOrExit(mState == OT_JOINER_STATE_IDLE, error = OT_ERROR_BUSY);
|
||||
VerifyOrExit(Get<ThreadNetif>().IsUp() && Get<Mle::Mle>().GetRole() == Mle::kRoleDisabled,
|
||||
error = OT_ERROR_INVALID_STATE);
|
||||
|
||||
SuccessOrExit(error = joinerPskd.SetFrom(aPskd));
|
||||
|
||||
|
||||
@@ -76,7 +76,9 @@ public:
|
||||
* @param[in] aCallback A pointer to a function that is called when the join operation completes.
|
||||
* @param[in] aContext A pointer to application-specific context.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully started the Joiner service.
|
||||
* @retval OT_ERROR_NONE Successfully started the Joiner service.
|
||||
* @retval OT_ERROR_BUSY The previous attempt is still on-going.
|
||||
* @retval OT_ERROR_INVALID_STATE The IPv6 stack is not enabled or Thread stack is fully enabled.
|
||||
*
|
||||
*/
|
||||
otError Start(const char * aPskd,
|
||||
|
||||
Reference in New Issue
Block a user