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:
Jonathan Hui
2016-07-25 17:52:47 -07:00
committed by GitHub
parent c595b240fb
commit 8c39011d9c
12 changed files with 271 additions and 91 deletions
+26 -8
View File
@@ -15,6 +15,7 @@ OpenThread test scripts use the CLI to execute test cases.
* [eidcache](#eidcache)
* [extaddr](#extaddr)
* [extpanid](#extpanid)
* [ifconfig](#ifconfig)
* [ipaddr](#ipaddr)
* [keysequence](#keysequence)
* [leaderweight](#leaderweight)
@@ -32,9 +33,8 @@ OpenThread test scripts use the CLI to execute test cases.
* [router](#router)
* [routerupgradethreshold](#routerupgradethreshold)
* [scan](#scan)
* [start](#start)
* [state](#state)
* [stop](#stop)
* [thread](#thread)
* [version](#version)
* [whitelist](#whitelist)
@@ -208,6 +208,24 @@ Set the Thread Extended PAN ID value.
Done
```
### ifconfig up
Bring up the IPv6 interface.
```bash
> ifconfig up
Done
```
### ifconfig down
Bring down the IPv6 interface.
```bash
> ifconfig down
Done
```
### ipaddr
List all IPv6 addresses assigned to the Thread interface.
@@ -541,21 +559,21 @@ Perform an IEEE 802.15.4 Active Scan.
Done
```
### start
### thread start
Enable OpenThread.
Enable Thread protocol operation and attach to a Thread network.
```bash
> start
> thread start
Done
```
### stop
### thread stop
Disable OpenThread.
Disable Thread protocol operation and detach from a Thread network.
```bash
> stop
> thread stop
Done
```
+42 -15
View File
@@ -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);
+2 -2
View File
@@ -96,6 +96,7 @@ private:
static void ProcessEidCache(int argc, char *argv[]);
static void ProcessExtAddress(int argc, char *argv[]);
static void ProcessExtPanId(int argc, char *argv[]);
static void ProcessIfconfig(int argc, char *argv[]);
static void ProcessIpAddr(int argc, char *argv[]);
static ThreadError ProcessIpAddrAdd(int argc, char *argv[]);
static ThreadError ProcessIpAddrDel(int argc, char *argv[]);
@@ -120,9 +121,8 @@ private:
static void ProcessRouterUpgradeThreshold(int argc, char *argv[]);
static void ProcessRloc16(int argc, char *argv[]);
static void ProcessScan(int argc, char *argv[]);
static void ProcessStart(int argc, char *argv[]);
static void ProcessState(int argc, char *argv[]);
static void ProcessStop(int argc, char *argv[]);
static void ProcessThread(int argc, char *argv[]);
static void ProcessVersion(int argc, char *argv[]);
static void ProcessWhitelist(int argc, char *argv[]);