From 0c5850e7ba825835fe2fd44495e656d64e9bd903 Mon Sep 17 00:00:00 2001 From: Ciaran Woodward Date: Wed, 19 Apr 2017 17:02:51 +0100 Subject: [PATCH] Fix CLI implementation of the child command (#1626) * CLI fix for printing child list In the previous implementation, if a child was not available at a certain index, all children at greater indexes would not be printed for a child list or child table command, despite still being connected to the node. This change modifies the logic so that if a child does not exist at a given index, only that index is disgarded, and future indexes are checked correctly. * Made pretty * Add ExitNow statement at end of table printing. This prevents printing an error at the end of the table. --- src/cli/cli.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/cli/cli.cpp b/src/cli/cli.cpp index 64ec2feb3..eb5525463 100644 --- a/src/cli/cli.cpp +++ b/src/cli/cli.cpp @@ -486,8 +486,16 @@ void Interpreter::ProcessChild(int argc, char *argv[]) for (uint8_t i = 0; i < maxChildren ; i++) { - if (otThreadGetChildInfoByIndex(mInstance, i, &childInfo) != kThreadError_None) + + switch (otThreadGetChildInfoByIndex(mInstance, i, &childInfo)) { + case kThreadError_None: + break; + + case kThreadError_NotFound: + continue; + + default: sServer->OutputFormat("\r\n"); ExitNow(); } @@ -521,6 +529,8 @@ void Interpreter::ProcessChild(int argc, char *argv[]) } } } + + ExitNow(); } SuccessOrExit(error = ParseLong(argv[0], value));