Modules#
Command Interpreter Plugin#
Process commands coming from the serial port.
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"),
{ "join", joinCommand, "uvsh" },
...
emberCommandEntryTerminator()
};
void main(void)
{
emberCommandReaderInit();
while(0) {
...
// Process input and print prompt if it returns true.
if (emberProcessCommandInput(serialPort)) {
emberSerialPrintf(1, "%p>", PROMPT);
}
...
}
}
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:
The full command name.
The application's function name that implements the command.
An EmberCommandEntry::argumentTypes string specifies the number and types of arguments the command accepts.
A description string explains the command.
A default error handler emberCommandErrorHandler() is provided to deal with the incorrect command input. Applications may override it.
The application calls emberCommandReaderInit() to initialize and emberProcessCommandInput() in its main loop.
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 is 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 an error occurs in the command input, emberCommandErrorHandler() is called instead of 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 is generated. To disable this feature, define EMBER_REQUIRE_EXACT_COMMAND_NAME in the application configuration header.
Retrieve Arguments#
Use the following functions that process commands to retrieve arguments from the command interpreter. These functions pull out unsigned integers, signed integers, strings, and hexadecimal strings. Index 0 is the first command argument.
Callbacks#
Command Table Settings#
Enumerations#
Command error states.
Typedefs#
Type of error handlers; the command argument is currently always NULL.
Variables#
Functions#
Initialize the command interpreter.
Process the given string as a command.
Return the value of a hexadecimal digit ch (0 - 15). Returns a value > 15 if ch is not a hexadecimal digit.
Parse textual representations of IPv6 addresses as described in http://www.ietf.org/rfc/rfc4291.txt.
Parse textual representations of IPv6 prefixes as described in http://www.ietf.org/rfc/rfc4291.txt.
Must be called to initialize a command state before passing it to emberRunCommandInterpreter().
For use when additional different command streams are used.
Macros#
Process the input coming in on the given serial port.
Retrieve Arguments Documentation#
emberCommandArgumentCount#
uint8_t emberCommandArgumentCount (void )
N/A |
Returns the number of arguments for the current command.
262
of file /mnt/raid/workspaces/ws.SZ9MaSA5u/overlay/gsdk/protocol/flex/command-interpreter/command-interpreter2.h
emberUnsignedCommandArgument#
uint32_t emberUnsignedCommandArgument (uint8_t argNum)
N/A | argNum |
Retrieves unsigned integer arguments.
265
of file /mnt/raid/workspaces/ws.SZ9MaSA5u/overlay/gsdk/protocol/flex/command-interpreter/command-interpreter2.h
emberSignedCommandArgument#
int32_t emberSignedCommandArgument (uint8_t argNum)
N/A | argNum |
Retrieve signed integer arguments.
268
of file /mnt/raid/workspaces/ws.SZ9MaSA5u/overlay/gsdk/protocol/flex/command-interpreter/command-interpreter2.h
emberStringCommandArgument#
uint8_t * emberStringCommandArgument (int8_t argNum, uint8_t * length)
N/A | argNum | |
N/A | length |
Retrieve quoted string or hexadecimal string arguments. Hexadecimal strings are already converted into binary. ASCII strings are null terminated. The null terminator is not included in the returned length argument. To retrieve the name of the command itself, use an argNum of -1. For example, to retrieve the first character of the command, uint8_t firstChar = emberStringCommandArgument(-1, NULL)[0]. If the command is nested, an index of -2, -3, and so on retrieves 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].
282
of file /mnt/raid/workspaces/ws.SZ9MaSA5u/overlay/gsdk/protocol/flex/command-interpreter/command-interpreter2.h
emberCommandName#
const char * emberCommandName (void )
N/A |
A convenience macro for copying security key arguments to an EmberKeyData pointer.
290
of file /mnt/raid/workspaces/ws.SZ9MaSA5u/overlay/gsdk/protocol/flex/command-interpreter/command-interpreter2.h
emberGetStringArgument#
uint8_t emberGetStringArgument (int8_t argNum, uint8_t * destination, uint8_t maxLength, bool leftPad)
N/A | argNum | |
N/A | destination | |
N/A | maxLength | |
N/A | leftPad |
Copy the string argument to the given destination up to maxLength. If the argument length is not zero 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. ASCII strings are null terminated but the null terminator is not included in the returned length.
This function is commonly used for reading in hexadecimal strings, such as EUI64 or key data and left padding them with zeros. See emberGetKeyArgument and emberGetEui64Argument for convenience macros for this purpose.
319
of file /mnt/raid/workspaces/ws.SZ9MaSA5u/overlay/gsdk/protocol/flex/command-interpreter/command-interpreter2.h
emberGetIpArgument#
bool emberGetIpArgument (uint8_t index, uint8_t * target)
N/A | index | |
N/A | target |
Parse and return, via target, an IP address at the provided index. Returns true if an IP address was successfully parsed Returns false otherwise.
328
of file /mnt/raid/workspaces/ws.SZ9MaSA5u/overlay/gsdk/protocol/flex/command-interpreter/command-interpreter2.h
emberGetIpPrefixArgument#
bool emberGetIpPrefixArgument (uint8_t index, uint8_t * target)
N/A | index | |
N/A | target |
Parse and return, via target, an IP prefix at the provided index. Returns true if an IP prefix was successfully parsed. Returns false otherwise.
334
of file /mnt/raid/workspaces/ws.SZ9MaSA5u/overlay/gsdk/protocol/flex/command-interpreter/command-interpreter2.h
emberGetExtendedPanIdArgument#
void emberGetExtendedPanIdArgument (int8_t index, uint8_t * extendedPanId)
N/A | index | |
N/A | extendedPanId |
Copy the extended PAN ID argument to the given destination, reversing the bytes. Extended PAN IDs are stored little endian so reversing the bytes means they are big endian in the input command string.
356
of file /mnt/raid/workspaces/ws.SZ9MaSA5u/overlay/gsdk/protocol/flex/command-interpreter/command-interpreter2.h
emberCopyKeyArgument#
#define emberCopyKeyArgumentValue:
A convenience macro for copying security key arguments to an EmberKeyData pointer.
295
of file /mnt/raid/workspaces/ws.SZ9MaSA5u/overlay/gsdk/protocol/flex/command-interpreter/command-interpreter2.h
emberCopyEui64Argument#
#define emberCopyEui64ArgumentValue:
(index, eui64)
A convenience macro for copying eui64 arguments to an EmberEUI64.
302
of file /mnt/raid/workspaces/ws.SZ9MaSA5u/overlay/gsdk/protocol/flex/command-interpreter/command-interpreter2.h
emberGetKeyArgument#
#define emberGetKeyArgumentValue:
A convenience macro for copying security key arguments to an EmberKeyData pointer.
339
of file /mnt/raid/workspaces/ws.SZ9MaSA5u/overlay/gsdk/protocol/flex/command-interpreter/command-interpreter2.h
emberGetEui64Argument#
#define emberGetEui64ArgumentValue:
(index, eui64)
Copy the EUI64 argument to the given EmberEui64 destination reversing the bytes. EUI64's are stored little endian so reversing the bytes means they are big endian in the input command string.
349
of file /mnt/raid/workspaces/ws.SZ9MaSA5u/overlay/gsdk/protocol/flex/command-interpreter/command-interpreter2.h
Callbacks Documentation#
emberCommandErrorHandler#
void emberCommandErrorHandler (EmberCommandStatus status, EmberCommandEntry * command)
N/A | status | |
N/A | command |
365
of file /mnt/raid/workspaces/ws.SZ9MaSA5u/overlay/gsdk/protocol/flex/command-interpreter/command-interpreter2.h
Command Table Settings Documentation#
EMBER_MAX_COMMAND_ARGUMENTS#
#define EMBER_MAX_COMMAND_ARGUMENTSValue:
20
The maximum number of arguments a command can have. A nested command counts as an argument.
113
of file /mnt/raid/workspaces/ws.SZ9MaSA5u/overlay/gsdk/protocol/flex/command-interpreter/command-interpreter2.h
EMBER_COMMAND_BUFFER_LENGTH#
#define EMBER_COMMAND_BUFFER_LENGTHValue:
200
The maximum number of arguments a command can have. A nested command counts as an argument.
117
of file /mnt/raid/workspaces/ws.SZ9MaSA5u/overlay/gsdk/protocol/flex/command-interpreter/command-interpreter2.h
EMBER_CUSTOM_COMMAND_BUFFER_LENGTH#
#define EMBER_CUSTOM_COMMAND_BUFFER_LENGTHValue:
(EMBER_COMMAND_BUFFER_LENGTH - 3)
The maximum message size for custom commands reserves three bytes for the length (1 bytes) and the custom command identifier (2 bytes).
123
of file /mnt/raid/workspaces/ws.SZ9MaSA5u/overlay/gsdk/protocol/flex/command-interpreter/command-interpreter2.h
EMBER_COMMAND_INTEPRETER_HAS_DESCRIPTION_FIELD#
#define EMBER_COMMAND_INTEPRETER_HAS_DESCRIPTION_FIELD
Indicate whether or not the command entry structure includes descriptions for the commands. This consumes additional CONST space, which is expensive on the XAP. By default, descriptions are not included.
130
of file /mnt/raid/workspaces/ws.SZ9MaSA5u/overlay/gsdk/protocol/flex/command-interpreter/command-interpreter2.h
Enumeration Documentation#
EmberCommandStatus#
EmberCommandStatus
Command error states.
If you change this list, also change the strings that describe these errors in the array emberCommandErrorNames[] in command-interpreter2-error.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 |
237
of file /mnt/raid/workspaces/ws.SZ9MaSA5u/overlay/gsdk/protocol/flex/command-interpreter/command-interpreter2.h
Typedef Documentation#
CommandAction#
typedef void(* CommandAction) (void) )(void)
139
of file /mnt/raid/workspaces/ws.SZ9MaSA5u/overlay/gsdk/protocol/flex/command-interpreter/command-interpreter2.h
EmberCommandErrorHandler#
typedef void EmberCommandErrorHandler(EmberCommandStatus status, EmberCommandEntry *command) (EmberCommandStatus status, EmberCommandEntry *command)
Type of error handlers; the command argument is currently always NULL.
465
of file /mnt/raid/workspaces/ws.SZ9MaSA5u/overlay/gsdk/protocol/flex/command-interpreter/command-interpreter2.h
Variable Documentation#
emberCommandTable#
EmberCommandEntry emberCommandTable[]
228
of file /mnt/raid/workspaces/ws.SZ9MaSA5u/overlay/gsdk/protocol/flex/command-interpreter/command-interpreter2.h
Function Documentation#
emberPrintCommandUsage#
void emberPrintCommandUsage (EmberCommandEntry * entry)
N/A | entry |
371
of file /mnt/raid/workspaces/ws.SZ9MaSA5u/overlay/gsdk/protocol/flex/command-interpreter/command-interpreter2.h
emberPrintCommandUsageNotes#
void emberPrintCommandUsageNotes (void )
N/A |
372
of file /mnt/raid/workspaces/ws.SZ9MaSA5u/overlay/gsdk/protocol/flex/command-interpreter/command-interpreter2.h
emberPrintCommandTable#
void emberPrintCommandTable (void )
N/A |
373
of file /mnt/raid/workspaces/ws.SZ9MaSA5u/overlay/gsdk/protocol/flex/command-interpreter/command-interpreter2.h
emberCommandClearBuffer#
void emberCommandClearBuffer (void )
N/A |
374
of file /mnt/raid/workspaces/ws.SZ9MaSA5u/overlay/gsdk/protocol/flex/command-interpreter/command-interpreter2.h
emberCommandReaderInit#
void emberCommandReaderInit (void )
Initialize the command interpreter.
N/A |
378
of file /mnt/raid/workspaces/ws.SZ9MaSA5u/overlay/gsdk/protocol/flex/command-interpreter/command-interpreter2.h
emberProcessCommandString#
bool emberProcessCommandString (const uint8_t * input, uint16_t sizeOrPort)
Process the given string as a command.
N/A | input | |
N/A | sizeOrPort |
382
of file /mnt/raid/workspaces/ws.SZ9MaSA5u/overlay/gsdk/protocol/flex/command-interpreter/command-interpreter2.h
emberHexToInt#
uint8_t emberHexToInt (uint8_t ch)
Return the value of a hexadecimal digit ch (0 - 15). Returns a value > 15 if ch is not a hexadecimal digit.
N/A | ch |
398
of file /mnt/raid/workspaces/ws.SZ9MaSA5u/overlay/gsdk/protocol/flex/command-interpreter/command-interpreter2.h
emberStringToIpAddress#
bool emberStringToIpAddress (const uint8_t * string, uint8_t stringLength, uint8_t * target)
Parse textual representations of IPv6 addresses as described in http://www.ietf.org/rfc/rfc4291.txt.
N/A | string | |
N/A | stringLength | |
N/A | target |
403
of file /mnt/raid/workspaces/ws.SZ9MaSA5u/overlay/gsdk/protocol/flex/command-interpreter/command-interpreter2.h
emberStringToIpPrefix#
bool emberStringToIpPrefix (const uint8_t * string, uint8_t stringLength, uint8_t * target)
Parse textual representations of IPv6 prefixes as described in http://www.ietf.org/rfc/rfc4291.txt.
N/A | string | |
N/A | stringLength | |
N/A | target |
410
of file /mnt/raid/workspaces/ws.SZ9MaSA5u/overlay/gsdk/protocol/flex/command-interpreter/command-interpreter2.h
emberInitializeCommandState#
void emberInitializeCommandState (EmberCommandState * state)
Must be called to initialize a command state before passing it to emberRunCommandInterpreter().
N/A | state |
459
of file /mnt/raid/workspaces/ws.SZ9MaSA5u/overlay/gsdk/protocol/flex/command-interpreter/command-interpreter2.h
emberRunCommandInterpreter#
bool emberRunCommandInterpreter (bool commandIsBinary, EmberCommandState * state, EmberCommandEntry * commands, EmberCommandErrorHandler * errorHandler, const uint8_t * input, uint16_t sizeOrPort)
For use when additional different command streams are used.
N/A | commandIsBinary | |
N/A | state | |
N/A | commands | |
N/A | errorHandler | |
N/A | input | |
N/A | sizeOrPort |
470
of file /mnt/raid/workspaces/ws.SZ9MaSA5u/overlay/gsdk/protocol/flex/command-interpreter/command-interpreter2.h
emberCommandReaderSetDefaultBase#
void emberCommandReaderSetDefaultBase (uint8_t base)
N/A | base |
480
of file /mnt/raid/workspaces/ws.SZ9MaSA5u/overlay/gsdk/protocol/flex/command-interpreter/command-interpreter2.h
Macro Definition Documentation#
MAX_TOKEN_COUNT#
#define MAX_TOKEN_COUNTValue:
(EMBER_MAX_COMMAND_ARGUMENTS + 1)
137
of file /mnt/raid/workspaces/ws.SZ9MaSA5u/overlay/gsdk/protocol/flex/command-interpreter/command-interpreter2.h
emberCommandEntryAction#
#define emberCommandEntryActionValue:
(name, command, arguments, description)
216
of file /mnt/raid/workspaces/ws.SZ9MaSA5u/overlay/gsdk/protocol/flex/command-interpreter/command-interpreter2.h
emberCommandEntrySubMenu
#define emberCommandEntrySubMenuValue:
(name, nestedCommands, description)
218
of file /mnt/raid/workspaces/ws.SZ9MaSA5u/overlay/gsdk/protocol/flex/command-interpreter/command-interpreter2.h
emberCommandEntryTerminator#
#define emberCommandEntryTerminatorValue:
()
220
of file /mnt/raid/workspaces/ws.SZ9MaSA5u/overlay/gsdk/protocol/flex/command-interpreter/command-interpreter2.h
emberCommand#
#define emberCommandValue:
emberCommandEntryAction
225
of file /mnt/raid/workspaces/ws.SZ9MaSA5u/overlay/gsdk/protocol/flex/command-interpreter/command-interpreter2.h
emberNestedCommand#
#define emberNestedCommandValue:
emberCommandEntrySubMenu
226
of file /mnt/raid/workspaces/ws.SZ9MaSA5u/overlay/gsdk/protocol/flex/command-interpreter/command-interpreter2.h
emberProcessCommandInput#
#define emberProcessCommandInputValue:
(port)
Process the 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);
392
of file /mnt/raid/workspaces/ws.SZ9MaSA5u/overlay/gsdk/protocol/flex/command-interpreter/command-interpreter2.h