Modules#

EmberCommandEntry

Command Interpreter#

Interpret serial port commands. See command-interpreter2.c for source code.

See the following application usage example followed by a brief explanation.

⁄⁄ Usage: network form 22 0xAB12 -3 { 00 01 02 A3 A4 A5 A6 A7 }
void formCommand(void)
{
  uint8_t channel = emberUnsignedCommandArgument(0);
  uint16_t panId  = emberUnsignedCommandArgument(1);
  int8_t power   = emberSignedCommandArgument(2);
  uint8_t length;
  uint8_t *eui64  = emberStringCommandArgument(3, &length);
  ...
  ... call emberFormNetwork() etc
  ...
}

⁄⁄ The main command table.
EmberCommandEntry emberCommandTable[] = {
  emberCommandEntrySubMenu("network",  networkCommands, "Network form/join commands"),
  emberCommandEntryAction("status",    statusCommand,   "Prints application status),
  ...
  emberCommandEntryTerminator()
};

⁄⁄ The table of network commands.
EmberCommandEntry networkCommands[] = {
  emberCommandEntryAction("form", formCommand, "uvsh", "Form a network"),
  emberCommandEntryAction("join", joinCommand, "uvsh", "Join a network"),
  ...
  emberCommandEntryTerminator()
};

void main(void)
{
   emberCommandReaderInit();
   while(0) {
     ...
     ⁄⁄ Process input and print prompt if it returns true.
     if (emberProcessCommandInput(serialPort)) {
        emberSerialPrintf(1, "%p>", PROMPT);
     }
     ...
   }
}
  1. Applications specify the commands that can be interpreted by defining the emberCommandTable array of type EmberCommandEntry. The table includes the following information for each command:

    1. The full command name.

    2. Your application's function name that implements the command.

    3. An EmberCommandEntry::argumentTypes string specifies the number and types of arguments the command accepts. See ::argumentTypes for details.

    4. A description string explains the command.

  1. A default error handler emberCommandErrorHandler() is provided to deal with incorrect command input. Applications may override it.

  2. The application calls emberCommandReaderInit() to initalize, and emberProcessCommandInput() in its main loop.

  3. Within the application's command functions, use emberXXXCommandArgument() functions to retrieve command arguments.

The command interpreter does extensive processing and validation of the command input before calling the function that implements the command. It checks that the number, type, syntax, and range of all arguments are correct. It performs any conversions necessary (for example, converting integers and strings input in hexadecimal notation into the corresponding bytes), so that no additional parsing is necessary within command functions. If there is an error in the command input, emberCommandErrorHandler() is called rather than a command function.

The command interpreter allows inexact matches of command names. The input command may be either shorter or longer than the actual command. However, if more than one inexact match is found and there is no exact match, an error of type EMBER_CMD_ERR_NO_SUCH_COMMAND will be generated. To disable this feature, define EMBER_REQUIRE_EXACT_COMMAND_NAME in the application configuration header.

Functions to Retrieve Arguments#

Use the following functions in your functions that process commands to retrieve arguments from the command interpreter. These functions pull out unsigned integers, signed integers, and strings, and hex strings. Index 0 is the first command argument.

uint32_t
int32_t
bool
emberStringToHostOrderIpv4Address(const uint8_t *string, uint32_t *hostOrderIpv4Address)
bool
emberStringArgumentToHostOrderIpv4Address(uint8_t argNum, uint32_t *hostOrderIpv4Address)
uint8_t *
emberStringCommandArgument(int8_t argNum, uint8_t *length)
const char *
uint8_t
emberCopyStringArgument(int8_t argNum, uint8_t *destination, uint8_t maxLength, bool leftPad)
uint8_t
emberCopyBigEndianEui64Argument(int8_t index, EmberEUI64 destination)
#define
emberCopyKeyArgument (index, keyDataPointer)
#define
emberCopyEui64Argument (index, eui64)
#define
emberGetEui64Argument (index, eui64)

Enumerations#

enum
EMBER_CMD_SUCCESS
EMBER_CMD_ERR_PORT_PROBLEM
EMBER_CMD_ERR_NO_SUCH_COMMAND
EMBER_CMD_ERR_WRONG_NUMBER_OF_ARGUMENTS
EMBER_CMD_ERR_ARGUMENT_OUT_OF_RANGE
EMBER_CMD_ERR_ARGUMENT_SYNTAX_ERROR
EMBER_CMD_ERR_STRING_TOO_LONG
EMBER_CMD_ERR_INVALID_ARGUMENT_TYPE
}

Command error states.

Typedefs#

typedef void(*

Functions#

void
emberCommandActionHandler(const CommandAction action)
void
emberCommandErrorHandler(EmberCommandStatus status)
void
emberPrintCommandUsage(EmberCommandEntry *entry)
void

Initialize the command interpreter.

bool
emberProcessCommandString(uint8_t *input, uint8_t sizeOrPort)

Process the given string as a command.

bool

Returns true interpreter is reading a command.

Macros#

#define
MAX_TOKEN_COUNT (EMBER_MAX_COMMAND_ARGUMENTS + 1)
#define
emberCommandEntryAction (name, action, argumentTypes, description)
#define
emberCommandEntryActionWithDetails (name, action, argumentTypes, description, argumentDescriptionArray)
#define
emberCommandEntrySubMenu (name, subMenu, description)
#define

Process input coming in on the given serial port.

#define

Turn echo of command line on.

#define

Turn echo of command line off.

#define

Returns true if echo is on, false otherwise.

Command Table Settings Documentation#

EMBER_MAX_COMMAND_ARGUMENTS#

#define EMBER_MAX_COMMAND_ARGUMENTS
Value:
16

The maximum number of arguments a command can have. A nested command counts as an argument.


Definition at line 113 of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h

EMBER_COMMAND_BUFFER_LENGTH#

#define EMBER_COMMAND_BUFFER_LENGTH
Value:
100

The maximum number of arguments a command can have. A nested command counts as an argument.


Definition at line 117 of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h

EMBER_COMMAND_INTEPRETER_HAS_DESCRIPTION_FIELD#

#define EMBER_COMMAND_INTEPRETER_HAS_DESCRIPTION_FIELD

Whether or not the command entry structure will include descriptions for the commands. This consumes additional CONST space. By default descriptions are not included.


Definition at line 125 of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h

Functions to Retrieve Arguments Documentation#

emberCommandArgumentCount#

uint8_t emberCommandArgumentCount (void )
Parameters
N/A

Returns the number of arguments for the current command.


Definition at line 302 of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h

emberUnsignedCommandArgument#

uint32_t emberUnsignedCommandArgument (uint8_t argNum)
Parameters
N/AargNum

Retrieves unsigned integer arguments.


Definition at line 305 of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h

emberSignedCommandArgument#

int32_t emberSignedCommandArgument (uint8_t argNum)
Parameters
N/AargNum

Retrieves signed integer arguments.


Definition at line 308 of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h

emberStringToHostOrderIpv4Address#

bool emberStringToHostOrderIpv4Address (const uint8_t * string, uint32_t * hostOrderIpv4Address)
Parameters
N/Astring
N/AhostOrderIpv4Address

Parses an IPv4 address string and returns a host order uint32_t. Returns true if address is valid dotted quad notation (A.B.C.D), false otherwise.


Definition at line 313 of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h

emberStringArgumentToHostOrderIpv4Address#

bool emberStringArgumentToHostOrderIpv4Address (uint8_t argNum, uint32_t * hostOrderIpv4Address)
Parameters
N/AargNum
N/AhostOrderIpv4Address

Parses an IPv4 address string from a command argument and returns host order uint32_t. Returns true if address is valid dotted quad notation (A.B.C.D), false otherwise.


Definition at line 318 of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h

emberStringCommandArgument#

uint8_t* emberStringCommandArgument (int8_t argNum, uint8_t * length)
Parameters
N/AargNum
N/Alength

Retrieve quoted string or hex string arguments. Hex strings have already been converted into binary. To retrieve the name of the command itself, use an argNum of -1. For example, to retrieve the first character of the command, do: uint8_t firstChar = emberStringCommandArgument(-1, NULL)[0]. If the command is nested, an index of -2, -3, etc will work to retrieve the higher level command names. Note that [-1] only returns the text entered. If an abbreviated command name is entered only the text entered will be returned with [-1].


Definition at line 330 of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h

emberCommandName#

const char* emberCommandName (void )
Parameters
N/A

A convenience macro for copying security key arguments to an EmberKeyData pointer.


Definition at line 332 of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h

emberCopyStringArgument#

uint8_t emberCopyStringArgument (int8_t argNum, uint8_t * destination, uint8_t maxLength, bool leftPad)
Parameters
N/AargNum
N/Adestination
N/AmaxLength
N/AleftPad

Copies the string argument to the given destination up to maxLength. If the argument length is nonzero but less than maxLength and leftPad is true, leading zeroes are prepended to bring the total length of the target up to maxLength. If the argument is longer than the maxLength, it is truncated to maxLength. Returns the minimum of the argument length and maxLength.

This function is commonly used for reading in hex strings such as EUI64 or key data and left padding them with zeroes. See emberCopyKeyArgument and emberCopyEui64Argument for convenience macros for this purpose.


Definition at line 346 of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h

emberCopyBigEndianEui64Argument#

uint8_t emberCopyBigEndianEui64Argument (int8_t index, EmberEUI64 destination)
Parameters
N/Aindex
N/Adestination

Copies eui64 arguments in big-endian format to an EmberEUI64. This is useful because eui64s are often presented to users in big-endian format even though they are used in software in little-endian format.


Definition at line 370 of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h

emberCopyKeyArgument#

#define emberCopyKeyArgument
Value:
(emberCopyStringArgument((index), \
emberKeyContents((keyDataPointer)), \
EMBER_ENCRYPTION_KEY_SIZE, \
true))

A convenience macro for copying security key arguments to an EmberKeyData pointer.


Definition at line 354 of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h

emberCopyEui64Argument#

#define emberCopyEui64Argument
Value:
(index, eui64)

A convenience macro for copying eui64 arguments to an EmberEUI64.


Definition at line 361 of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h

emberGetEui64Argument#

#define emberGetEui64Argument
Value:
(index, eui64)

A convenience macro for copying security key arguments to an EmberKeyData pointer.


Definition at line 363 of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h

Enumeration Documentation#

EmberCommandStatus#

EmberCommandStatus

Command error states.

If you change this list, ensure you also change the strings that describe these errors in the array emberCommandErrorNames[] in command-interpreter.c.

Enumerator
EMBER_CMD_SUCCESS
EMBER_CMD_ERR_PORT_PROBLEM
EMBER_CMD_ERR_NO_SUCH_COMMAND
EMBER_CMD_ERR_WRONG_NUMBER_OF_ARGUMENTS
EMBER_CMD_ERR_ARGUMENT_OUT_OF_RANGE
EMBER_CMD_ERR_ARGUMENT_SYNTAX_ERROR
EMBER_CMD_ERR_STRING_TOO_LONG
EMBER_CMD_ERR_INVALID_ARGUMENT_TYPE

Definition at line 277 of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h

Typedef Documentation#

CommandAction#

typedef void(* CommandAction) (void) )(void)

Definition at line 134 of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h

Variable Documentation#

emberCurrentCommand#

EmberCommandEntry* emberCurrentCommand

A pointer to the currently matching command entry. Only valid from within a command function. If the original command was nested, points to the final (non-nested) command entry.


Definition at line 260 of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h

emberCommandTable#

EmberCommandEntry emberCommandTable[]

Definition at line 262 of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h

emberCommandInterpreter2Configuration#

uint8_t emberCommandInterpreter2Configuration

Configuration byte.


Definition at line 267 of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h

Function Documentation#

emberCommandReaderSetDefaultBase#

void emberCommandReaderSetDefaultBase (uint8_t base)
Parameters
N/Abase

Definition at line 375 of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h

emberCommandActionHandler#

void emberCommandActionHandler (const CommandAction action)
Parameters
N/Aaction

The application may implement this handler. To override the default handler, define EMBER_APPLICATION_HAS_COMMAND_ACTION_HANDLER in the CONFIGURATION_HEADER.


Definition at line 381 of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h

emberCommandErrorHandler#

void emberCommandErrorHandler (EmberCommandStatus status)
Parameters
N/Astatus

The application may implement this handler. To override the default handler, define EMBER_APPLICATION_HAS_COMMAND_ERROR_HANDLER in the CONFIGURATION_HEADER. Defining this will also remove the help functions emberPrintCommandUsage(), emberPrintCommandUsageNotes(), and emberPrintCommandTable().


Definition at line 388 of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h

emberPrintCommandUsage#

void emberPrintCommandUsage (EmberCommandEntry * entry)
Parameters
N/Aentry

Definition at line 389 of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h

emberPrintCommandUsageNotes#

void emberPrintCommandUsageNotes (void )
Parameters
N/A

Definition at line 390 of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h

emberPrintCommandTable#

void emberPrintCommandTable (void )
Parameters
N/A

Definition at line 391 of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h

emberCommandClearBuffer#

void emberCommandClearBuffer (void )
Parameters
N/A

Definition at line 392 of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h

emberCommandReaderInit#

void emberCommandReaderInit (void )

Initialize the command interpreter.

Parameters
N/A

Definition at line 396 of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h

emberProcessCommandString#

bool emberProcessCommandString (uint8_t * input, uint8_t sizeOrPort)

Process the given string as a command.

Parameters
N/Ainput
N/AsizeOrPort

Definition at line 400 of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h

emberCommandInterpreterBusy#

bool emberCommandInterpreterBusy (void )

Returns true interpreter is reading a command.

Parameters
N/A

Definition at line 433 of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h

Macro Definition Documentation#

MAX_TOKEN_COUNT#

#define MAX_TOKEN_COUNT
Value:
(EMBER_MAX_COMMAND_ARGUMENTS + 1)

Definition at line 132 of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h

emberCommandEntryAction#

#define emberCommandEntryAction
Value:
(name, action, argumentTypes, description)

Definition at line 213 of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h

emberCommandEntryActionWithDetails#

#define emberCommandEntryActionWithDetails
Value:
(name, action, argumentTypes, description, argumentDescriptionArray)

Definition at line 220 of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h

emberCommandEntrySubMenu#

#define emberCommandEntrySubMenu
Value:
(name, subMenu, description)

Definition at line 224 of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h

emberCommandEntryTerminator#

#define emberCommandEntryTerminator
Value:
()

Definition at line 228 of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h

EMBER_COMMAND_INTERPRETER_CONFIGURATION_ECHO#

#define EMBER_COMMAND_INTERPRETER_CONFIGURATION_ECHO
Value:
(0x01)

Definition at line 269 of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h

emberProcessCommandInput#

#define emberProcessCommandInput
Value:
(port)

Process input coming in on the given serial port.

Returns

  • true if an end of line character was read. If the application uses a command line prompt, this indicates it is time to print the prompt.

    void emberProcessCommandInput(uint8_t port);
    

Definition at line 410 of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h

emberCommandInterpreterEchoOn#

#define emberCommandInterpreterEchoOn
Value:
(emberCommandInterpreter2Configuration \
|= EMBER_COMMAND_INTERPRETER_CONFIGURATION_ECHO)

Turn echo of command line on.


Definition at line 415 of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h

emberCommandInterpreterEchoOff#

#define emberCommandInterpreterEchoOff
Value:
(emberCommandInterpreter2Configuration \
&= (~EMBER_COMMAND_INTERPRETER_CONFIGURATION_ECHO))

Turn echo of command line off.


Definition at line 421 of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h

emberCommandInterpreterIsEchoOn#

#define emberCommandInterpreterIsEchoOn
Value:
(emberCommandInterpreter2Configuration \
& EMBER_COMMAND_INTERPRETER_CONFIGURATION_ECHO)

Returns true if echo is on, false otherwise.


Definition at line 427 of file /Users/vihuszar/Git/EmbeddedSoftware/super/protocol/zigbee/app/util/serial/command-interpreter2.h