Add PSKc API (#1635)

* add pskc api

* add pskc cli

* add NCP api of PSKc

* apply PSKc from network

* implement PSKC api for windows

* add name for pskc property

* clear active and pending dataset when settings pskc
This commit is contained in:
Buke Po
2017-04-28 07:32:35 +08:00
committed by Jonathan Hui
parent 0759f874e0
commit 024c44de5c
18 changed files with 396 additions and 4 deletions
+32
View File
@@ -156,6 +156,9 @@ const struct Command Interpreter::sCommands[] =
{ "promiscuous", &Interpreter::ProcessPromiscuous },
#endif
{ "prefix", &Interpreter::ProcessPrefix },
#if OPENTHREAD_FTD
{ "pskc", &Interpreter::ProcessPSKc },
#endif
{ "releaserouterid", &Interpreter::ProcessReleaseRouterId },
{ "reset", &Interpreter::ProcessReset },
{ "rloc16", &Interpreter::ProcessRloc16 },
@@ -1292,6 +1295,35 @@ exit:
AppendResult(error);
}
#if OPENTHREAD_FTD
void Interpreter::ProcessPSKc(int argc, char *argv[])
{
ThreadError error = kThreadError_None;
if (argc == 0)
{
const uint8_t *currentPSKc = otThreadGetPSKc(mInstance);
for (int i = 0; i < OT_PSKC_MAX_SIZE; i++)
{
sServer->OutputFormat("%02x", currentPSKc[i]);
}
sServer->OutputFormat("\r\n");
}
else
{
uint8_t newPSKc[OT_PSKC_MAX_SIZE];
VerifyOrExit(Hex2Bin(argv[0], newPSKc, sizeof(newPSKc)) == OT_PSKC_MAX_SIZE, error = kThreadError_Parse);
SuccessOrExit(error = otThreadSetPSKc(mInstance, newPSKc));
}
exit:
AppendResult(error);
}
#endif
void Interpreter::ProcessMasterKey(int argc, char *argv[])
{
ThreadError error = kThreadError_None;