OS
v1.7.5
Documentation
|
An AT Command Line Interface (CLI) object. More...
#include <cli.hpp>
Public Member Functions | |
commandLineInterface ()=default | |
bool | setup (util::putChar_t outFcn, char *pInput, const size_t sizeIn, char *pOutput, const size_t sizeOut) |
Setup an instance of the AT Command Line Interface. | |
template<size_t inBufferSize, size_t outBufferSize> | |
bool | setup (util::putChar_t outFcn, char(&pInput)[inBufferSize], char(&pOutput)[outBufferSize]) |
bool | add (cli::command &cmd, char *textCommand, const cli::commandCallback_t &cFcn, cli::options_t cmdOpt, void *param=nullptr) |
This function subscribes the CLI instance to a specific command with an associated Callback function, so that next time the required command is sent to the CLI input, the callback function will be executed. The CLI parser only analyze commands that follows the extended AT-Commands syntax (the + char can be ignored). | |
bool | isrHandler (const char c) |
Feed the CLI input with a single character. This call is mandatory from an interrupt context. Put it inside the desired peripheral's ISR. | |
bool | isrHandler (char *pData, const size_t n) |
Feed the CLI input with a string. This call is mandatory from an interrupt context. Put it inside the desired peripheral's ISR. | |
bool | raise (const char *cmd) |
Sends a command to the Command Line Interface instance. | |
bool | inputFlush (void) |
Flush the CLI input buffer. | |
cli::response | exec (const char *cmd) |
Try to execute the requested command. | |
bool | run (void) |
Run the AT Command Line Interface when the input is ready. | |
void * | getOwner (void) |
Retrieves a pointer of the owner of this object. | |
void | setData (void *pData) |
Set the cli data or storage-pointer. | |
An AT Command Line Interface (CLI) object.
Before starting the CLI development, the corresponding instance must be defined.
The instance should be initialized using the commandLineInterface::setup() method.
|
default |
bool qOS::commandLineInterface::add | ( | cli::command & | cmd, |
char * | textCommand, | ||
const cli::commandCallback_t & | cFcn, | ||
cli::options_t | cmdOpt, | ||
void * | param = nullptr ) |
This function subscribes the CLI instance to a specific command with an associated Callback function, so that next time the required command is sent to the CLI input, the callback function will be executed. The CLI parser only analyze commands that follows the extended AT-Commands syntax (the + char can be ignored).
[in] | cmd | The AT command object. |
[in] | textCommand | The string (name) of the command we want to subscribe to. Since this service only handles AT commands, this string has to begin by the "at" characters and should be in lower case. |
[in] | cFcn | The handler of the callback function associated to the command. Prototype: cli::response xCallback( cli::handler_t h )
The command argument with all the regarding information of the incoming AT command. Definition cli.hpp:93 response an enumeration to define the possible values that can be returned from the callback of a command. Definition cli.hpp:30 |
[in] | cmdOpt | This flag combines with a bitwise OR the following information: |
cli::commandType::PARA : AT+cmd=x
,y is allowed. The execution of the callback function also depends on whether the number of argument is valid or not. Information about number of arguments is combined with a bitwise 'OR' : cli::commandType::PARA | 0xXY , where X which defines maximum argument number for incoming command and Y which defines minimum argument number for incoming command
cli::commandType::TEST : "AT+cmd=?"
is allowed.
cli::commandType::READ : "AT+cmd?"
is allowed.
cli::commandType::ACT : AT+cmd
is allowed.
[in] | param | User storage pointer. |
true
on success, otherwise return false
. cli::response qOS::commandLineInterface::exec | ( | const char * | cmd | ) |
Try to execute the requested command.
[in] | cmd | The command string, including arguments if required. |
|
inline |
Retrieves a pointer of the owner of this object.
A
pointer to the owner. bool qOS::commandLineInterface::inputFlush | ( | void | ) |
Flush the CLI input buffer.
true
on success, otherwise return false
bool qOS::commandLineInterface::isrHandler | ( | char * | pData, |
const size_t | n ) |
Feed the CLI input with a string. This call is mandatory from an interrupt context. Put it inside the desired peripheral's ISR.
[in] | pData | The incoming string. |
[in] | n | The length of the string. |
true
when the CLI is ready to process the input, otherwise return false
bool qOS::commandLineInterface::isrHandler | ( | const char | c | ) |
Feed the CLI input with a single character. This call is mandatory from an interrupt context. Put it inside the desired peripheral's ISR.
[in] | c | The incoming byte/char to the input. |
true
when the CLI is ready to process the input, otherwise return false
bool qOS::commandLineInterface::raise | ( | const char * | cmd | ) |
Sends a command to the Command Line Interface instance.
[in] | cmd | The command string, including arguments if required. |
true
when the CLI accepts the input. If busy, return false
bool qOS::commandLineInterface::run | ( | void | ) |
Run the AT Command Line Interface when the input is ready.
true
on success, otherwise return false
|
inline |
Set the cli data or storage-pointer.
[in] | pData | A pointer to data or storage-pointer. |
bool qOS::commandLineInterface::setup | ( | util::putChar_t | outFcn, |
char * | pInput, | ||
const size_t | sizeIn, | ||
char * | pOutput, | ||
const size_t | sizeOut ) |
Setup an instance of the AT Command Line Interface.
[in] | outFcn | The basic output-char wrapper function. All the CLI responses will be printed-out through this function. |
[in] | pInput | A memory location to store the cli input (Mandatory) |
[in] | sizeIn | The size of the memory allocated in pInput |
[in] | pOutput | A memory location to store the CLI output |
[in] | sizeOut | The size of the memory allocated in pOutput |
true
on success, otherwise return false
.
|
inline |