Command Processor and Console¶
SDK provide in-built command processor and console with many features like User authentication and command autocomplete etc.
By default SDK provide system commands and linux like core utility commands.
Available commands¶
Command |
Description |
|---|---|
devinfo |
Get device information |
sysinfo |
Get system information |
loglevel |
Set or get current debug loglevel |
reboot |
Reboot system |
ntpdate |
Get date time information from NTP server |
df |
Show information about filesystem |
ls |
List file(s) or directory |
echo |
Display line of text |
cat |
Display file on standard output |
mkdir |
Make directory |
rm |
Remove file or directory |
mv |
Move file or directory |
logout |
Logout current user |
help |
Get command help |
Optional Commands¶
Some commands are available only when a module is used or enabled by the application.
Following is the list of Commands with modules.
TODO: optional command list to be added
Custom commands¶
Command processor APIs can be used to add new commands to the system.
Command Processor API Reference¶
Header File¶
Functions¶
-
int
command_process(const char *cmd, int len, struct cmdinfo_t *info, commandproc_cb callback, void *arg)¶ Execute command buffer
Multiple commands can be separated by ; and will be executed by the built-in parser.
- Return
0 on success, or != 0 on error. command_ret_e
- Parameters
cmd: [in] String containing list of commandslen: [in] length of cmd stringinfo: [in] Command information structurecallback: [in] process callback function of type commandproc_cb, called after execution of each command in the listarg: [in] Argument passed to callback function
Structures¶
-
struct
cmdinfo_t¶ Command information structure, passed to command handler function
-
struct
cmddesc_t¶ Command descriptor structure
Macros¶
-
CMD_MAX_ARGS¶ Maximum number of allowed arguments including commmand
-
CMD_ADD(_name, _minarg, _maxarg, _cmd, _help, _usage, _type)¶ Add new command
- Parameters
_name: Name of command_minarg: Minimum number of arguments including command (must be >= 1)_maxarg: Maximum number of arguments including command (must be >= 1 & <= CMD_MAX_ARGS)_cmd: Command handler function_help: Short help message_usage: Long help message and usage detail_type: Command type flag see command_type_e
Type Definitions¶
Enumerations¶
-
enum
command_ret_e¶ Command executing return code
Values:
-
enumerator
CMD_RET_SUCCESS¶ Command executed successfully
-
enumerator
CMD_RET_FAILURE¶ Command executing failure
-
enumerator
CMD_RET_PERM¶ Command Permission denied
-
enumerator
CMD_RET_LOGOUT¶ Execute session logout
-
enumerator
CMD_RET_USAGE= -1¶ Failure, please report ‘usage’ error
-
enumerator
-
enum
command_src_e¶ Source of command used in cmdinfo_t structure
Values:
-
enumerator
CMD_SRC_CONSOLE¶ Command source console
-
enumerator
CMD_SRC_BTCONSOLE¶ Command source Bluetooth Console
-
enumerator
CMD_SRC_DBG¶ Command source Remote debug console
-
enumerator
CMD_SRC_SMS¶ Command source SMS
-
enumerator
CMD_SRC_TCP¶ Command source TCP
-
enumerator
CMD_SRC_SYS¶ Command source system() API
-
enumerator
-
enum
command_type_e¶ Command type flags. These flags can be ORed together.
Values:
-
enumerator
CMD_TYPE_DEFAULT= 0¶ Default command, executing allowed everywhere and can be executed by user and admin.
-
enumerator
CMD_TYPE_HIDDEN= 1¶ Hidden command, Only executed by admin user; Unless allowed by allow flags
-
enumerator
CMD_ALLOW_SMS= 2¶ Command allowed over SMS
-
enumerator
CMD_ALLOW_TCP= 4¶ Command allowed over TCP
-
enumerator
CMD_ALLOW_DBG= 8¶ Command allowed over remote debug
-
enumerator
CMD_ALLOW_CONSOLE= 0x10¶ Command allowed over console
-
enumerator
CMD_ALLOW_BT_CONSOLE= 0x20¶ Command allowed over Bluetooth console
-
enumerator
CMD_ALLOW_SYS= 0x40¶ Command allowed to execute via system() API
-
enumerator
CMD_ALLOW_ALL= 0x7F¶ Command allowed from all sources
-
enumerator
CMD_ALLOW_TCP_SMS= 0x6¶ Command allowed over TCP and SMS
-
enumerator
CMD_ALLOW_CONSOLE_ONLY= 0x38¶ Command allowed over Console only
-
enumerator
CMD_ALLOW_TCP_SMS_DBG= 0xE¶ Command allowed over TCP, SMS and remote console
-
enumerator
Console API Reference¶
Header File¶
Functions¶
Type Definitions¶
-
typedef int (*
cliauth_f)(const char *user, const char *pass)¶ CLI Authentication function
- Return
Authentication return code, see cli_auth_rc
- Parameters
user: Username entered on console.For Remote debug console this value is “rdbg”.
For Bluetooth console this value is “btcli”.
pass: Password
