Don't return parent info if the device is not a child (#1868)

* Fix the issue that the previous parent information could be retrieved
  even after the device is not a child

* Print more parent information in CLI
This commit is contained in:
Shu Chen
2017-06-03 00:03:48 +08:00
committed by Jonathan Hui
parent 0cbb0898e1
commit 4460fb1815
2 changed files with 6 additions and 0 deletions
+3
View File
@@ -304,6 +304,9 @@ otError otThreadGetParentInfo(otInstance *aInstance, otRouterInfo *aParentInfo)
otError error = OT_ERROR_NONE;
Router *parent;
VerifyOrExit(aInstance->mThreadNetif.GetMle().GetRole() == OT_DEVICE_ROLE_CHILD,
error = OT_ERROR_INVALID_STATE);
VerifyOrExit(aParentInfo != NULL, error = OT_ERROR_INVALID_ARGS);
parent = aInstance->mThreadNetif.GetMle().GetParent();