This module includes functions that control the Thread stack's execution.

Summary

Typedefs

otCliOutputCallback)(void *aContext, const char *aFormat, va_list aArguments) typedef

int(*

Pointer is called to notify about Console output.

Functions

otCliAppendResult(otError aError)

void

Write error code to the CLI console.

otCliInit(otInstance *aInstance, otCliOutputCallback aCallback, void *aContext)

void

Initialize the CLI module.

otCliInputLine(char *aBuf)

void

Is called to feed in a console input line.

otCliOutputBytes(const uint8_t *aBytes, uint8_t aLength)

void

Write a number of bytes to the CLI console as a hex string.

otCliOutputFormat(const char *aFmt, ...)

void

Write formatted string to the CLI console.

otCliPlatLogv(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, va_list aArgs)

void

Callback to write the OpenThread Log to the CLI console.

otCliSetUserCommands(const otCliCommand *aUserCommands, uint8_t aLength, void *aContext)

Set a user command table.

otCliVendorSetUserCommands(void)

void

Callback to allow vendor specific commands to be added to the user command table.

Typedefs

otCliOutputCallback

int(* otCliOutputCallback)(void *aContext, const char *aFormat, va_list aArguments)

Pointer is called to notify about Console output.

Details
Parameters
[out] aContext

A user context pointer.

[in] aFormat

The format string.

[in] aArguments

The format string arguments.

Returns

Number of bytes written by the callback.

Functions

otCliAppendResult

void otCliAppendResult(
  otError aError
)

Write error code to the CLI console.

If the aError is OT_ERROR_PENDING nothing will be outputted.

Details
Parameters
[in] aError

Error code value.

otCliInit

void otCliInit(
  otInstance *aInstance,
  otCliOutputCallback aCallback,
  void *aContext
)

Initialize the CLI module.

Details
Parameters
[in] aInstance

The OpenThread instance structure.

[in] aCallback

A callback method called to process CLI output.

[in] aContext

A user context pointer.

otCliInputLine

void otCliInputLine(
  char *aBuf
)

Is called to feed in a console input line.

Details
Parameters
[in] aBuf

A pointer to a null-terminated string.

otCliOutputBytes

void otCliOutputBytes(
  const uint8_t *aBytes,
  uint8_t aLength
)

Write a number of bytes to the CLI console as a hex string.

Details
Parameters
[in] aBytes

A pointer to data which should be printed.

[in] aLength

aBytes length.

otCliOutputFormat

void otCliOutputFormat(
  const char *aFmt,
  ...
)

Write formatted string to the CLI console.

Details
Parameters
[in] aFmt

A pointer to the format string.

[in] ...

A matching list of arguments.

otCliPlatLogv

void otCliPlatLogv(
  otLogLevel aLogLevel,
  otLogRegion aLogRegion,
  const char *aFormat,
  va_list aArgs
)

Callback to write the OpenThread Log to the CLI console.

Details
Parameters
[in] aLogLevel

The log level.

[in] aLogRegion

The log region.

[in] aFormat

A pointer to the format string.

[in] aArgs

va_list matching aFormat.

otCliSetUserCommands

otError otCliSetUserCommands(
  const otCliCommand *aUserCommands,
  uint8_t aLength,
  void *aContext
)

Set a user command table.

Details
Parameters
[in] aUserCommands

A pointer to an array with user commands.

[in] aLength

aUserCommands length.

[in] aContext

The context passed to the handler.

Return Values
OT_ERROR_NONE

Successfully updated command table with commands from aUserCommands.

OT_ERROR_FAILED

Maximum number of command entries have already been set.

otCliVendorSetUserCommands

void otCliVendorSetUserCommands(
  void
)

Callback to allow vendor specific commands to be added to the user command table.

Available when OPENTHREAD_CONFIG_CLI_VENDOR_COMMANDS_ENABLE is enabled and OPENTHREAD_CONFIG_CLI_MAX_USER_CMD_ENTRIES is greater than 1.

Resources

OpenThread API Reference topics originate from the source code, available on GitHub. For more information, or to contribute to our documentation, refer to Resources.

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. The OPENTHREAD and related marks are trademarks of the Thread Group and are used under license.

Last updated 2024-01-02 UTC.