Add Thread Auto Start Support (#1268)

* Add Thread Auto Start Support

* Add compile-time option

* Return error in Windows API
This commit is contained in:
Nick Banks
2017-02-20 17:29:20 -08:00
committed by Jonathan Hui
parent 500dada64c
commit 64f5ab43fc
11 changed files with 230 additions and 13 deletions
+32
View File
@@ -67,6 +67,7 @@ namespace Cli {
const struct Command Interpreter::sCommands[] =
{
{ "help", &Interpreter::ProcessHelp },
{ "autostart", &Interpreter::ProcessAutoStart },
{ "blacklist", &Interpreter::ProcessBlacklist },
{ "bufferinfo", &Interpreter::ProcessBufferInfo },
{ "channel", &Interpreter::ProcessChannel },
@@ -247,6 +248,37 @@ void Interpreter::ProcessHelp(int argc, char *argv[])
(void)argv;
}
void Interpreter::ProcessAutoStart(int argc, char *argv[])
{
ThreadError error = kThreadError_None;
if (argc == 0)
{
if (otThreadGetAutoStart(mInstance))
{
sServer->OutputFormat("true\r\n");
}
else
{
sServer->OutputFormat("false\r\n");
}
}
else if (strcmp(argv[0], "true") == 0)
{
error = otThreadSetAutoStart(mInstance, true);
}
else if (strcmp(argv[0], "false") == 0)
{
error = otThreadSetAutoStart(mInstance, false);
}
else
{
error = kThreadError_InvalidArgs;
}
AppendResult(error);
}
void Interpreter::ProcessBlacklist(int argc, char *argv[])
{
ThreadError error = kThreadError_None;