[joiner] check Thread state on start (#5173)

This commit is contained in:
Yakun Xu
2020-07-03 09:24:52 -07:00
committed by GitHub
parent 2a05a4c5f2
commit 74fd255465
4 changed files with 9 additions and 3 deletions
+1 -1
View File
@@ -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
+3 -1
View File
@@ -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,
+2
View File
@@ -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));
+3 -1
View File
@@ -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,