diff --git a/include/openthread/cli.h b/include/openthread/cli.h index 5a8f54c43..c13657796 100644 --- a/include/openthread/cli.h +++ b/include/openthread/cli.h @@ -92,11 +92,10 @@ void otCliConsoleInit(otInstance *aInstance, otCliConsoleOutputCallback aCallbac /** * This method is called to feed in a console input line. * - * @param[in] aBuf A pointer to a buffer with an input. - * @param[in] aBufLength A length of the input data stored in the buffer. + * @param[in] aBuf A pointer to a null-terminated string. * */ -void otCliConsoleInputLine(char *aBuf, uint16_t aBufLength); +void otCliConsoleInputLine(char *aBuf); /** * Initialize the CLI UART module. diff --git a/include/openthread/instance.h b/include/openthread/instance.h index b0297f6d9..8f92ab4bd 100644 --- a/include/openthread/instance.h +++ b/include/openthread/instance.h @@ -53,7 +53,7 @@ extern "C" { * @note This number versions both OpenThread platform and user APIs. * */ -#define OPENTHREAD_API_VERSION (82) +#define OPENTHREAD_API_VERSION (83) /** * @addtogroup api-instance diff --git a/src/cli/cli.cpp b/src/cli/cli.cpp index 16eecdcc7..6e2bafd0c 100644 --- a/src/cli/cli.cpp +++ b/src/cli/cli.cpp @@ -4783,17 +4783,17 @@ otError Interpreter::ProcessDiag(uint8_t aArgsLength, char *aArgs[]) } #endif -void Interpreter::ProcessLine(char *aBuf, uint16_t aBufLength) +void Interpreter::ProcessLine(char *aBuf) { char * args[kMaxArgs] = {nullptr}; uint8_t argsLength; const Command *command; - VerifyOrExit(aBuf != nullptr && StringLength(aBuf, aBufLength + 1) <= aBufLength); + VerifyOrExit(aBuf != nullptr && StringLength(aBuf, kMaxLineLength) <= kMaxLineLength - 1); VerifyOrExit(Utils::CmdLineParser::ParseCmd(aBuf, argsLength, args, kMaxArgs) == OT_ERROR_NONE, OutputLine("Error: too many args (max %d)", kMaxArgs)); - VerifyOrExit(argsLength >= 1, OutputLine("Error: no given command.")); + VerifyOrExit(argsLength >= 1); #if OPENTHREAD_CONFIG_DIAG_ENABLE VerifyOrExit((!otDiagIsEnabled(mInstance) || (strcmp(args[0], "diag") == 0)), diff --git a/src/cli/cli.hpp b/src/cli/cli.hpp index ae1cb4f48..9a8a8ae75 100644 --- a/src/cli/cli.hpp +++ b/src/cli/cli.hpp @@ -125,10 +125,9 @@ public: * This method interprets a CLI command. * * @param[in] aBuf A pointer to a string. - * @param[in] aBufLength The length of the string in bytes. * */ - void ProcessLine(char *aBuf, uint16_t aBufLength); + void ProcessLine(char *aBuf); /** * This method delivers raw characters to the client. diff --git a/src/cli/cli_config.h b/src/cli/cli_config.h index 265ed16d2..16976bb4f 100644 --- a/src/cli/cli_config.h +++ b/src/cli/cli_config.h @@ -44,7 +44,7 @@ * */ #ifndef OPENTHREAD_CONFIG_CLI_MAX_LINE_LENGTH -#define OPENTHREAD_CONFIG_CLI_MAX_LINE_LENGTH 128 +#define OPENTHREAD_CONFIG_CLI_MAX_LINE_LENGTH 384 #endif /** diff --git a/src/cli/cli_console.cpp b/src/cli/cli_console.cpp index 55ef6bfeb..ab7f7499d 100644 --- a/src/cli/cli_console.cpp +++ b/src/cli/cli_console.cpp @@ -53,9 +53,9 @@ extern "C" void otCliConsoleInit(otInstance *aInstance, otCliConsoleOutputCallba Console::Initialize(aInstance, aCallback, aContext); } -extern "C" void otCliConsoleInputLine(char *aBuf, uint16_t aBufLength) +extern "C" void otCliConsoleInputLine(char *aBuf) { - Interpreter::GetInterpreter().ProcessLine(aBuf, aBufLength); + Interpreter::GetInterpreter().ProcessLine(aBuf); } // Add stubs for simulation diff --git a/src/cli/cli_uart.cpp b/src/cli/cli_uart.cpp index da408b015..4b573a020 100644 --- a/src/cli/cli_uart.cpp +++ b/src/cli/cli_uart.cpp @@ -227,7 +227,7 @@ otError Uart::ProcessCommand(void) #endif if (mRxLength > 0) { - ProcessLine(mRxBuffer, mRxLength); + ProcessLine(mRxBuffer); } mRxLength = 0; diff --git a/src/posix/console_cli.cpp b/src/posix/console_cli.cpp index 18fa1909f..b98ea8851 100644 --- a/src/posix/console_cli.cpp +++ b/src/posix/console_cli.cpp @@ -70,12 +70,10 @@ static void InputCallback(char *aLine) { if (aLine != nullptr) { - size_t len; - - if ((len = strlen(aLine)) > 0) + if (aLine[0] != '\0') { add_history(aLine); - otCliConsoleInputLine(aLine, (uint16_t)len); + otCliConsoleInputLine(aLine); } free(aLine); }