mirror of
https://github.com/espressif/openthread.git
synced 2026-07-11 14:50:18 +00:00
Separate out interface up/down from Thread start/stop. (#278)
* Redefine otEnable/otDisable to just initialize/uninitialize the OpenThread stack. * Remove otInit API since it is replaced by otEnable. * Add otInterfaceUp/otInterfaceDown APIs to bring up/down IPv6 interface. * Add otThreadStart/otThreadStop APIs to start/stop Thread protocol operation. * Updated NCP implementation to utilize new APIs.
This commit is contained in:
+42
-15
@@ -59,6 +59,7 @@ const struct Command Interpreter::sCommands[] =
|
||||
{ "eidcache", &ProcessEidCache },
|
||||
{ "extaddr", &ProcessExtAddress },
|
||||
{ "extpanid", &ProcessExtPanId },
|
||||
{ "ifconfig", &ProcessIfconfig },
|
||||
{ "ipaddr", &ProcessIpAddr },
|
||||
{ "keysequence", &ProcessKeySequence },
|
||||
{ "leaderdata", &ProcessLeaderData },
|
||||
@@ -77,9 +78,8 @@ const struct Command Interpreter::sCommands[] =
|
||||
{ "router", &ProcessRouter },
|
||||
{ "routerupgradethreshold", &ProcessRouterUpgradeThreshold },
|
||||
{ "scan", &ProcessScan },
|
||||
{ "start", &ProcessStart },
|
||||
{ "state", &ProcessState },
|
||||
{ "stop", &ProcessStop },
|
||||
{ "thread", &ProcessThread },
|
||||
{ "version", &ProcessVersion },
|
||||
{ "whitelist", &ProcessWhitelist },
|
||||
};
|
||||
@@ -408,6 +408,34 @@ exit:
|
||||
AppendResult(error);
|
||||
}
|
||||
|
||||
void Interpreter::ProcessIfconfig(int argc, char *argv[])
|
||||
{
|
||||
ThreadError error = kThreadError_Parse;
|
||||
|
||||
if (argc == 0)
|
||||
{
|
||||
if (otIsInterfaceUp())
|
||||
{
|
||||
sServer->OutputFormat("up\r\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
sServer->OutputFormat("down\r\n");
|
||||
}
|
||||
}
|
||||
else if (strcmp(argv[0], "up") == 0)
|
||||
{
|
||||
SuccessOrExit(error = otInterfaceUp());
|
||||
}
|
||||
else if (strcmp(argv[0], "down") == 0)
|
||||
{
|
||||
SuccessOrExit(error = otInterfaceDown());
|
||||
}
|
||||
|
||||
exit:
|
||||
AppendResult(error);
|
||||
}
|
||||
|
||||
ThreadError Interpreter::ProcessIpAddrAdd(int argc, char *argv[])
|
||||
{
|
||||
ThreadError error;
|
||||
@@ -1192,16 +1220,6 @@ exit:
|
||||
return;
|
||||
}
|
||||
|
||||
void Interpreter::ProcessStart(int argc, char *argv[])
|
||||
{
|
||||
ThreadError error = kThreadError_None;
|
||||
|
||||
SuccessOrExit(error = otEnable());
|
||||
|
||||
exit:
|
||||
AppendResult(error);
|
||||
}
|
||||
|
||||
void Interpreter::ProcessState(int argc, char *argv[])
|
||||
{
|
||||
ThreadError error = kThreadError_None;
|
||||
@@ -1259,11 +1277,20 @@ exit:
|
||||
AppendResult(error);
|
||||
}
|
||||
|
||||
void Interpreter::ProcessStop(int argc, char *argv[])
|
||||
void Interpreter::ProcessThread(int argc, char *argv[])
|
||||
{
|
||||
ThreadError error = kThreadError_None;
|
||||
ThreadError error = kThreadError_Parse;
|
||||
|
||||
SuccessOrExit(error = otDisable());
|
||||
VerifyOrExit(argc > 0, error = kThreadError_Parse);
|
||||
|
||||
if (strcmp(argv[0], "start") == 0)
|
||||
{
|
||||
SuccessOrExit(error = otThreadStart());
|
||||
}
|
||||
else if (strcmp(argv[0], "stop") == 0)
|
||||
{
|
||||
SuccessOrExit(error = otThreadStop());
|
||||
}
|
||||
|
||||
exit:
|
||||
AppendResult(error);
|
||||
|
||||
Reference in New Issue
Block a user