Add callback to indicate when joiner operation completes. (#1094)

This commit is contained in:
Jonathan Hui
2016-12-27 08:06:18 -08:00
committed by GitHub
parent 28c049f2ce
commit 64d49153bd
18 changed files with 247 additions and 48 deletions
+20 -1
View File
@@ -2438,7 +2438,7 @@ void Interpreter::ProcessJoiner(int argc, char *argv[])
const char *provisioningUrl;
VerifyOrExit(argc > 1, error = kThreadError_Parse);
provisioningUrl = (argc > 2) ? argv[2] : NULL;
otJoinerStart(mInstance, argv[1], provisioningUrl);
otJoinerStart(mInstance, argv[1], provisioningUrl, &Interpreter::s_HandleJoinerCallback, this);
}
else if (strcmp(argv[0], "stop") == 0)
{
@@ -2451,6 +2451,25 @@ exit:
#endif // OPENTHREAD_ENABLE_JOINER
void Interpreter::s_HandleJoinerCallback(ThreadError aError, void *aContext)
{
static_cast<Interpreter *>(aContext)->HandleJoinerCallback(aError);
}
void Interpreter::HandleJoinerCallback(ThreadError aError)
{
switch (aError)
{
case kThreadError_None:
sServer->OutputFormat("Join success\r\n");
break;
default:
sServer->OutputFormat("Join failed [%s]\r\n", otThreadErrorToString(aError));
break;
}
}
void Interpreter::ProcessJoinerPort(int argc, char *argv[])
{
ThreadError error = kThreadError_None;