File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -99,11 +99,11 @@ void otCliInputLine(char *aBuf);
9999 * Set a user command table.
100100 *
101101 * @param[in] aUserCommands A pointer to an array with user commands.
102- * @param[in] aLength @p aUserCommands length.
103- * @param[in] aContext @p The context passed to the handler.
102+ * @param[in] aLength The @p aUserCommands length.
103+ * @param[in] aContext The context passed to the handler.
104104 *
105- * @retval OT_ERROR_NONE Successfully updated command table with commands from @p aUserCommands.
106- * @retval OT_ERROR_FAILED Maximum number of command entries have already been set.
105+ * @retval OT_ERROR_NONE Successfully updated command table with commands from @p aUserCommands.
106+ * @retval OT_ERROR_NO_BUFS Maximum number of command entries have already been set.
107107 */
108108otError otCliSetUserCommands (const otCliCommand * aUserCommands , uint8_t aLength , void * aContext );
109109
Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ extern "C" {
5252 *
5353 * @note This number versions both OpenThread platform and user APIs.
5454 */
55- #define OPENTHREAD_API_VERSION (593 )
55+ #define OPENTHREAD_API_VERSION (594 )
5656
5757/**
5858 * @addtogroup api-instance
Original file line number Diff line number Diff line change @@ -400,21 +400,28 @@ otError Interpreter::ProcessUserCommands(Arg aArgs[])
400400
401401otError Interpreter::SetUserCommands (const otCliCommand *aCommands, uint8_t aLength, void *aContext)
402402{
403- otError error = OT_ERROR_FAILED ;
403+ otError error = OT_ERROR_NONE ;
404404
405405 for (UserCommandsEntry &entry : mUserCommands )
406406 {
407+ if (entry.mCommands == aCommands)
408+ {
409+ // Ignore if already registered.
410+ ExitNow ();
411+ }
412+
407413 if (entry.mCommands == nullptr )
408414 {
409415 entry.mCommands = aCommands;
410416 entry.mLength = aLength;
411417 entry.mContext = aContext;
412-
413- error = OT_ERROR_NONE;
414- break ;
418+ ExitNow ();
415419 }
416420 }
417421
422+ error = OT_ERROR_NO_BUFS;
423+
424+ exit:
418425 return error;
419426}
420427
Original file line number Diff line number Diff line change @@ -176,10 +176,10 @@ class Interpreter : public OutputImplementer, public Utils
176176 *
177177 * @param[in] aCommands A pointer to an array with user commands.
178178 * @param[in] aLength @p aUserCommands length.
179- * @param[in] aContext @p aUserCommands length .
179+ * @param[in] aContext Context to use when invoking the command handler .
180180 *
181- * @retval OT_ERROR_NONE Successfully updated command table with commands from @p aCommands.
182- * @retval OT_ERROR_FAILED No available UserCommandsEntry to register requested user commands.
181+ * @retval OT_ERROR_NONE Successfully updated command table with commands from @p aCommands.
182+ * @retval OT_ERROR_NO_BUFS No available ` UserCommandsEntry` to register the requested user commands.
183183 */
184184 otError SetUserCommands (const otCliCommand *aCommands, uint8_t aLength, void *aContext);
185185
You can’t perform that action at this time.
0 commit comments