diff --git a/src/cli/README.md b/src/cli/README.md index d58e009f9..7ef1ac4d7 100644 --- a/src/cli/README.md +++ b/src/cli/README.md @@ -75,6 +75,7 @@ Done - [prefix](#prefix-add-prefix-padcrosnD-prf) - [promiscuous](#promiscuous) - [pskc](#pskc--p-keypassphrase) +- [rcp](#rcp) - [releaserouterid](#releaserouterid-routerid) - [reset](#reset) - [rloc16](#rloc16) @@ -1282,6 +1283,20 @@ Disable radio promiscuous operation. Done ``` +### rcp + +RCP-related commands. + +### rcp version + +Print RCP version string. + +```bash +> rcp version +OPENTHREAD/20191113-00825-g82053cc9d-dirty; SIMULATION; Jun 4 2020 17:53:16 +Done +``` + ### releaserouterid \ Release a Router ID that has been allocated by the device in the Leader role. diff --git a/src/cli/cli.cpp b/src/cli/cli.cpp index e31c8be39..4c5803115 100644 --- a/src/cli/cli.cpp +++ b/src/cli/cli.cpp @@ -214,6 +214,9 @@ const struct Command Interpreter::sCommands[] = { #if OPENTHREAD_FTD {"preferrouterid", &Interpreter::ProcessPreferRouterId}, {"pskc", &Interpreter::ProcessPskc}, +#endif + {"rcp", &Interpreter::ProcessRcp}, +#if OPENTHREAD_FTD {"releaserouterid", &Interpreter::ProcessReleaseRouterId}, #endif {"reset", &Interpreter::ProcessReset}, @@ -2792,7 +2795,30 @@ void Interpreter::ProcessPreferRouterId(uint8_t aArgsLength, char *aArgs[]) exit: AppendResult(error); } +#endif +void Interpreter::ProcessRcp(uint8_t aArgsLength, char *aArgs[]) +{ + otError error = OT_ERROR_NONE; + const char *version = otPlatRadioGetVersionString(mInstance); + + VerifyOrExit(version != otGetVersionString(), error = OT_ERROR_NOT_IMPLEMENTED); + VerifyOrExit(aArgsLength > 0, error = OT_ERROR_INVALID_ARGS); + + if (strcmp(aArgs[0], "version") == 0) + { + mServer->OutputFormat("%s\r\n", version); + } + else + { + ExitNow(error = OT_ERROR_INVALID_ARGS); + } + +exit: + AppendResult(error); +} + +#if OPENTHREAD_FTD void Interpreter::ProcessReleaseRouterId(uint8_t aArgsLength, char *aArgs[]) { otError error = OT_ERROR_NONE; @@ -2806,7 +2832,7 @@ void Interpreter::ProcessReleaseRouterId(uint8_t aArgsLength, char *aArgs[]) exit: AppendResult(error); } -#endif // OPENTHREAD_FTD +#endif void Interpreter::ProcessReset(uint8_t aArgsLength, char *aArgs[]) { diff --git a/src/cli/cli.hpp b/src/cli/cli.hpp index 1fdf25ac1..02728565a 100644 --- a/src/cli/cli.hpp +++ b/src/cli/cli.hpp @@ -328,6 +328,9 @@ private: #if OPENTHREAD_FTD void ProcessPreferRouterId(uint8_t aArgsLength, char *aArgs[]); void ProcessPskc(uint8_t aArgsLength, char *aArgs[]); +#endif + void ProcessRcp(uint8_t aArgsLength, char *aArgs[]); +#if OPENTHREAD_FTD void ProcessReleaseRouterId(uint8_t aArgsLength, char *aArgs[]); #endif void ProcessReset(uint8_t aArgsLength, char *aArgs[]);