mirror of
https://github.com/espressif/openthread.git
synced 2026-07-17 01:24:08 +00:00
[cli] add 'childip' command to cli for getting ip addresses of MTD children (#3791)
This commit is contained in:
committed by
Jonathan Hui
parent
617f8958dd
commit
267a3b3e29
@@ -113,6 +113,7 @@ const struct Command Interpreter::sCommands[] = {
|
||||
{"channel", &Interpreter::ProcessChannel},
|
||||
#if OPENTHREAD_FTD
|
||||
{"child", &Interpreter::ProcessChild},
|
||||
{"childip", &Interpreter::ProcessChildIp},
|
||||
{"childmax", &Interpreter::ProcessChildMax},
|
||||
#endif
|
||||
{"childtimeout", &Interpreter::ProcessChildTimeout},
|
||||
@@ -783,6 +784,44 @@ exit:
|
||||
AppendResult(error);
|
||||
}
|
||||
|
||||
void Interpreter::ProcessChildIp(int argc, char *argv[])
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint8_t maxChildren;
|
||||
|
||||
VerifyOrExit(argc == 0, error = OT_ERROR_INVALID_ARGS);
|
||||
|
||||
maxChildren = otThreadGetMaxAllowedChildren(mInstance);
|
||||
|
||||
for (uint8_t childIndex = 0; childIndex < maxChildren; childIndex++)
|
||||
{
|
||||
otChildIp6AddressIterator iterator = OT_CHILD_IP6_ADDRESS_ITERATOR_INIT;
|
||||
otIp6Address ip6Address;
|
||||
otChildInfo childInfo;
|
||||
|
||||
if ((otThreadGetChildInfoByIndex(mInstance, childIndex, &childInfo) != OT_ERROR_NONE) ||
|
||||
childInfo.mIsStateRestoring)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
iterator = OT_CHILD_IP6_ADDRESS_ITERATOR_INIT;
|
||||
|
||||
while (otThreadGetChildNextIp6Address(mInstance, childIndex, &iterator, &ip6Address) == OT_ERROR_NONE)
|
||||
{
|
||||
mServer->OutputFormat("%04x: %x:%x:%x:%x:%x:%x:%x:%x\r\n", childInfo.mRloc16,
|
||||
HostSwap16(ip6Address.mFields.m16[0]), HostSwap16(ip6Address.mFields.m16[1]),
|
||||
HostSwap16(ip6Address.mFields.m16[2]), HostSwap16(ip6Address.mFields.m16[3]),
|
||||
HostSwap16(ip6Address.mFields.m16[4]), HostSwap16(ip6Address.mFields.m16[5]),
|
||||
HostSwap16(ip6Address.mFields.m16[6]), HostSwap16(ip6Address.mFields.m16[7]));
|
||||
}
|
||||
}
|
||||
|
||||
exit:
|
||||
OT_UNUSED_VARIABLE(argv);
|
||||
AppendResult(error);
|
||||
}
|
||||
|
||||
void Interpreter::ProcessChildMax(int argc, char *argv[])
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
Reference in New Issue
Block a user