Add API to retrieve router diag information. (#225)

This commit is contained in:
Jonathan Hui
2016-07-01 10:47:40 -07:00
committed by GitHub
parent 4779fb20eb
commit 50acd07a17
8 changed files with 179 additions and 0 deletions
+45
View File
@@ -27,6 +27,7 @@ OpenThread test scripts use the CLI to execute test cases.
* [releaserouterid](#releaserouterid)
* [rloc16](#rloc16)
* [route](#route)
* [router](#router)
* [routerupgradethreshold](#routerupgradethreshold)
* [scan](#scan)
* [start](#start)
@@ -421,6 +422,50 @@ Invalidate a prefix in the Network Data.
Done
```
### router list
List allocated Router IDs
```bash
> router list
8 24 50
Done
```
### router \<id\>
Print diagnostic information for a Thread Router. The `id` may be a Router ID or an RLOC16.
```bash
> router 50
Alloc: 1
Router ID: 50
Rloc: c800
Next Hop: c800
Link: 1
Ext Addr: e2b3540590b0fd87
Cost: 0
LQI In: 3
LQI Out: 3
Age: 3
Done
```
```bash
> router 0xc800
Alloc: 1
Router ID: 50
Rloc: c800
Next Hop: c800
Link: 1
Ext Addr: e2b3540590b0fd87
Cost: 0
LQI In: 3
LQI Out: 3
Age: 7
Done
```
### routerupgradethreshold
Get the ROUTER_UPGRADE_THRESHOLD value.
+59
View File
@@ -70,6 +70,7 @@ const struct Command Interpreter::sCommands[] =
{ "releaserouterid", &ProcessReleaseRouterId },
{ "rloc16", &ProcessRloc16 },
{ "route", &ProcessRoute },
{ "router", &ProcessRouter },
{ "routerupgradethreshold", &ProcessRouterUpgradeThreshold },
{ "scan", &ProcessScan },
{ "start", &ProcessStart },
@@ -923,6 +924,64 @@ exit:
AppendResult(error);
}
void Interpreter::ProcessRouter(int argc, char *argv[])
{
ThreadError error = kThreadError_None;
otRouterInfo routerInfo;
long value;
VerifyOrExit(argc > 0, error = kThreadError_Parse);
if (strcmp(argv[0], "list") == 0)
{
for (int i = 0; ; i++)
{
if (otGetRouterInfo(i, &routerInfo) != kThreadError_None)
{
sServer->OutputFormat("\r\n");
ExitNow();
}
if (routerInfo.mAllocated)
{
sServer->OutputFormat("%d ", i);
}
}
}
SuccessOrExit(error = ParseLong(argv[0], value));
SuccessOrExit(error = otGetRouterInfo(value, &routerInfo));
sServer->OutputFormat("Alloc: %d\r\n", routerInfo.mAllocated);
if (routerInfo.mAllocated)
{
sServer->OutputFormat("Router ID: %d\r\n", routerInfo.mRouterId);
sServer->OutputFormat("Rloc: %04x\r\n", routerInfo.mRloc16);
sServer->OutputFormat("Next Hop: %04x\r\n", static_cast<uint16_t>(routerInfo.mNextHop) << 10);
sServer->OutputFormat("Link: %d\r\n", routerInfo.mLinkEstablished);
if (routerInfo.mLinkEstablished)
{
sServer->OutputFormat("Ext Addr: ");
for (int j = 0; j < sizeof(routerInfo.mExtAddress); j++)
{
sServer->OutputFormat("%02x", routerInfo.mExtAddress.m8[j]);
}
sServer->OutputFormat("\r\n");
sServer->OutputFormat("Cost: %d\r\n", routerInfo.mPathCost);
sServer->OutputFormat("LQI In: %d\r\n", routerInfo.mLinkQualityIn);
sServer->OutputFormat("LQI Out: %d\r\n", routerInfo.mLinkQualityOut);
sServer->OutputFormat("Age: %d\r\n", routerInfo.mAge);
}
}
exit:
AppendResult(error);
}
void Interpreter::ProcessRouterUpgradeThreshold(int argc, char *argv[])
{
ThreadError error = kThreadError_None;
+1
View File
@@ -110,6 +110,7 @@ private:
static ThreadError ProcessPrefixRemove(int argc, char *argv[]);
static void ProcessReleaseRouterId(int argc, char *argv[]);
static void ProcessRoute(int argc, char *argv[]);
static void ProcessRouter(int argc, char *argv[]);
static ThreadError ProcessRouteAdd(int argc, char *argv[]);
static ThreadError ProcessRouteRemove(int argc, char *argv[]);
static void ProcessRouterUpgradeThreshold(int argc, char *argv[]);