Support network diagnostic feature. (#652)

* support network diagnostic

* add network diagnostic THCI implementation
This commit is contained in:
Buke Po
2016-09-24 12:06:08 +08:00
committed by Jonathan Hui
parent 61dcf6cf58
commit d283c29f23
22 changed files with 2311 additions and 17 deletions
+34
View File
@@ -103,6 +103,7 @@ const struct Command Interpreter::sCommands[] =
{ "masterkey", &Interpreter::ProcessMasterKey },
{ "mode", &Interpreter::ProcessMode },
{ "netdataregister", &Interpreter::ProcessNetworkDataRegister },
{ "networkdiagnostic", &Interpreter::ProcessNetworkDiagnostic },
{ "networkidtimeout", &Interpreter::ProcessNetworkIdTimeout },
{ "networkname", &Interpreter::ProcessNetworkName },
{ "panid", &Interpreter::ProcessPanId },
@@ -2449,5 +2450,38 @@ exit:
return;
}
void Interpreter::ProcessNetworkDiagnostic(int argc, char *argv[])
{
ThreadError error = kThreadError_None;
struct otIp6Address address;
uint8_t index = 2;
uint8_t tlvTypes[OT_NUM_NETDIAG_TLV_TYPES];
uint8_t count = 0;
VerifyOrExit(argc > 1 + 1, error = kThreadError_Parse);
SuccessOrExit(error = otIp6AddressFromString(argv[1], &address));
while (index < argc && count < sizeof(tlvTypes))
{
long value;
SuccessOrExit(error = ParseLong(argv[index], value));
tlvTypes[count++] = static_cast<uint8_t>(value);
index++;
}
if (strcmp(argv[0], "get") == 0)
{
otSendDiagnosticGet(mInstance, &address, tlvTypes, count);
}
else if (strcmp(argv[0], "reset") == 0)
{
otSendDiagnosticReset(mInstance, &address, tlvTypes, count);
}
exit:
AppendResult(error);
}
} // namespace Cli
} // namespace Thread