mirror of
https://github.com/espressif/openthread.git
synced 2026-07-08 13:20:25 +00:00
[cli] fix router table command (#2747)
This commit is contained in:
+26
-23
@@ -2333,6 +2333,8 @@ void Interpreter::ProcessRouter(int argc, char *argv[])
|
||||
|
||||
if (isTable || strcmp(argv[0], "list") == 0)
|
||||
{
|
||||
uint8_t maxRouterId;
|
||||
|
||||
if (isTable)
|
||||
{
|
||||
mServer->OutputFormat(
|
||||
@@ -2341,40 +2343,41 @@ void Interpreter::ProcessRouter(int argc, char *argv[])
|
||||
"+----+--------+----------+-----------+-------+--------+-----+------------------+\r\n");
|
||||
}
|
||||
|
||||
for (uint8_t i = 0;; i++)
|
||||
maxRouterId = otThreadGetMaxRouterId(mInstance);
|
||||
|
||||
for (uint8_t i = 0; i <= maxRouterId; i++)
|
||||
{
|
||||
if (otThreadGetRouterInfo(mInstance, i, &routerInfo) != OT_ERROR_NONE)
|
||||
{
|
||||
mServer->OutputFormat("\r\n");
|
||||
ExitNow();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (routerInfo.mAllocated)
|
||||
if (isTable)
|
||||
{
|
||||
if (isTable)
|
||||
{
|
||||
mServer->OutputFormat("| %2d ", routerInfo.mRouterId);
|
||||
mServer->OutputFormat("| 0x%04x ", routerInfo.mRloc16);
|
||||
mServer->OutputFormat("| %8d ", routerInfo.mNextHop);
|
||||
mServer->OutputFormat("| %9d ", routerInfo.mPathCost);
|
||||
mServer->OutputFormat("| %5d ", routerInfo.mLinkQualityIn);
|
||||
mServer->OutputFormat("| %6d ", routerInfo.mLinkQualityOut);
|
||||
mServer->OutputFormat("| %3d ", routerInfo.mAge);
|
||||
mServer->OutputFormat("| ");
|
||||
mServer->OutputFormat("| %2d ", routerInfo.mRouterId);
|
||||
mServer->OutputFormat("| 0x%04x ", routerInfo.mRloc16);
|
||||
mServer->OutputFormat("| %8d ", routerInfo.mNextHop);
|
||||
mServer->OutputFormat("| %9d ", routerInfo.mPathCost);
|
||||
mServer->OutputFormat("| %5d ", routerInfo.mLinkQualityIn);
|
||||
mServer->OutputFormat("| %6d ", routerInfo.mLinkQualityOut);
|
||||
mServer->OutputFormat("| %3d ", routerInfo.mAge);
|
||||
mServer->OutputFormat("| ");
|
||||
|
||||
for (size_t j = 0; j < sizeof(routerInfo.mExtAddress); j++)
|
||||
{
|
||||
mServer->OutputFormat("%02x", routerInfo.mExtAddress.m8[j]);
|
||||
}
|
||||
|
||||
mServer->OutputFormat(" |\r\n");
|
||||
}
|
||||
else
|
||||
for (size_t j = 0; j < sizeof(routerInfo.mExtAddress); j++)
|
||||
{
|
||||
mServer->OutputFormat("%d ", i);
|
||||
mServer->OutputFormat("%02x", routerInfo.mExtAddress.m8[j]);
|
||||
}
|
||||
|
||||
mServer->OutputFormat(" |\r\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
mServer->OutputFormat("%d ", i);
|
||||
}
|
||||
}
|
||||
|
||||
mServer->OutputFormat("\r\n");
|
||||
ExitNow();
|
||||
}
|
||||
|
||||
SuccessOrExit(error = ParseLong(argv[0], value));
|
||||
|
||||
Reference in New Issue
Block a user