mirror of
https://github.com/espressif/openthread.git
synced 2026-08-04 01:47:47 +00:00
[cli] simplify simple commands using Process{Get/Set}() helpers (#11374)
This commit is contained in:
+3
-27
@@ -3297,8 +3297,6 @@ exit:
|
||||
|
||||
template <> otError Interpreter::Process<Cmd("instanceid")>(Arg aArgs[])
|
||||
{
|
||||
otError error = OT_ERROR_INVALID_ARGS;
|
||||
|
||||
/**
|
||||
* @cli instanceid
|
||||
* @code
|
||||
@@ -3309,13 +3307,7 @@ template <> otError Interpreter::Process<Cmd("instanceid")>(Arg aArgs[])
|
||||
* @par api_copy
|
||||
* #otInstanceGetId
|
||||
*/
|
||||
if (aArgs[0].IsEmpty())
|
||||
{
|
||||
OutputLine("%lu", ToUlong(otInstanceGetId(GetInstancePtr())));
|
||||
error = OT_ERROR_NONE;
|
||||
}
|
||||
|
||||
return error;
|
||||
return ProcessGet(aArgs, otInstanceGetId);
|
||||
}
|
||||
|
||||
template <> otError Interpreter::Process<Cmd("ipaddr")>(Arg aArgs[])
|
||||
@@ -4080,8 +4072,6 @@ template <> otError Interpreter::Process<Cmd("pskcref")>(Arg aArgs[])
|
||||
}
|
||||
else
|
||||
{
|
||||
otPskcRef pskcRef;
|
||||
|
||||
/**
|
||||
* @cli pskcref (set)
|
||||
* @code
|
||||
@@ -4092,19 +4082,9 @@ template <> otError Interpreter::Process<Cmd("pskcref")>(Arg aArgs[])
|
||||
* @par api_copy
|
||||
* #otThreadSetPskcRef
|
||||
*/
|
||||
if (aArgs[1].IsEmpty())
|
||||
{
|
||||
SuccessOrExit(error = aArgs[0].ParseAsUint32(pskcRef));
|
||||
}
|
||||
else
|
||||
{
|
||||
ExitNow(error = OT_ERROR_INVALID_ARGS);
|
||||
}
|
||||
|
||||
error = otThreadSetPskcRef(GetInstancePtr(), pskcRef);
|
||||
error = ProcessSet(aArgs, otThreadSetPskcRef);
|
||||
}
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
#endif
|
||||
@@ -4877,13 +4857,9 @@ template <> otError Interpreter::Process<Cmd("networkkeyref")>(Arg aArgs[])
|
||||
}
|
||||
else
|
||||
{
|
||||
otNetworkKeyRef keyRef;
|
||||
|
||||
SuccessOrExit(error = aArgs[0].ParseAsUint32(keyRef));
|
||||
SuccessOrExit(error = otThreadSetNetworkKeyRef(GetInstancePtr(), keyRef));
|
||||
error = ProcessSet(aArgs, otThreadSetNetworkKeyRef);
|
||||
}
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -528,19 +528,7 @@ template <> otError Commissioner::Process<Cmd("sessionid")>(Arg aArgs[])
|
||||
*/
|
||||
template <> otError Commissioner::Process<Cmd("id")>(Arg aArgs[])
|
||||
{
|
||||
otError error;
|
||||
|
||||
if (aArgs[0].IsEmpty())
|
||||
{
|
||||
OutputLine("%s", otCommissionerGetId(GetInstancePtr()));
|
||||
error = OT_ERROR_NONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
error = otCommissionerSetId(GetInstancePtr(), aArgs[0].GetCString());
|
||||
}
|
||||
|
||||
return error;
|
||||
return ProcessGetSet(aArgs, otCommissionerGetId, otCommissionerSetId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -152,18 +152,7 @@ template <> otError SrpServer::Process<Cmd("auto")>(Arg aArgs[])
|
||||
*/
|
||||
template <> otError SrpServer::Process<Cmd("domain")>(Arg aArgs[])
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
if (aArgs[0].IsEmpty())
|
||||
{
|
||||
OutputLine("%s", otSrpServerGetDomain(GetInstancePtr()));
|
||||
}
|
||||
else
|
||||
{
|
||||
error = otSrpServerSetDomain(GetInstancePtr(), aArgs[0].GetCString());
|
||||
}
|
||||
|
||||
return error;
|
||||
return ProcessGetSet(aArgs, otSrpServerGetDomain, otSrpServerSetDomain);
|
||||
}
|
||||
|
||||
#if OPENTHREAD_CONFIG_SRP_SERVER_FAST_START_MODE_ENABLE
|
||||
@@ -575,22 +564,7 @@ exit:
|
||||
*/
|
||||
template <> otError SrpServer::Process<Cmd("seqnum")>(Arg aArgs[])
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
if (aArgs[0].IsEmpty())
|
||||
{
|
||||
OutputLine("%u", otSrpServerGetAnycastModeSequenceNumber(GetInstancePtr()));
|
||||
}
|
||||
else
|
||||
{
|
||||
uint8_t sequenceNumber;
|
||||
|
||||
SuccessOrExit(error = aArgs[0].ParseAsUint8(sequenceNumber));
|
||||
error = otSrpServerSetAnycastModeSequenceNumber(GetInstancePtr(), sequenceNumber);
|
||||
}
|
||||
|
||||
exit:
|
||||
return error;
|
||||
return ProcessGetSet(aArgs, otSrpServerGetAnycastModeSequenceNumber, otSrpServerSetAnycastModeSequenceNumber);
|
||||
}
|
||||
|
||||
otError SrpServer::Process(Arg aArgs[])
|
||||
|
||||
Reference in New Issue
Block a user