An AT Command Line Interface (CLI) object.
More...
#include <cli.hpp>
|
| | 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.
|
| |
| bool | isInitialized (void) const |
| | Check if the CLI instance has been initialized.
|
| |
| | operator bool () const noexcept |
| | Check if the CLI instance has been initialized.
|
| |
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.
◆ commandLineInterface()
| qOS::commandLineInterface::commandLineInterface |
( |
| ) |
|
|
default |
◆ add()
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).
- Parameters
-
| [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:
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.
- Parameters
-
| [in] | param | User storage pointer. |
- Returns
true on success, otherwise return false.
◆ exec()
| cli::response qOS::commandLineInterface::exec |
( |
const char * | cmd | ) |
|
Try to execute the requested command.
- Parameters
-
| [in] | cmd | The command string, including arguments if required. |
- Returns
- The response output for the requested command.
◆ getOwner()
| void * qOS::commandLineInterface::getOwner |
( |
void | | ) |
|
|
inline |
Retrieves a pointer of the owner of this object.
- Returns
A pointer to the owner.
◆ inputFlush()
| bool qOS::commandLineInterface::inputFlush |
( |
void | | ) |
|
Flush the CLI input buffer.
- Returns
true on success, otherwise return false
◆ isInitialized()
| bool qOS::commandLineInterface::isInitialized |
( |
void | | ) |
const |
|
inline |
Check if the CLI instance has been initialized.
- Returns
true if instance has been initialized
◆ isrHandler() [1/2]
| 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.
- Parameters
-
| [in] | pData | The incoming string. |
| [in] | n | The length of the string. |
- Returns
true when the CLI is ready to process the input, otherwise return false
◆ isrHandler() [2/2]
| 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.
- Parameters
-
| [in] | c | The incoming byte/char to the input. |
- Returns
true when the CLI is ready to process the input, otherwise return false
◆ operator bool()
| qOS::commandLineInterface::operator bool |
( |
| ) |
const |
|
inlineexplicitnoexcept |
Check if the CLI instance has been initialized.
- Returns
true if instance has been initialized
◆ raise()
| bool qOS::commandLineInterface::raise |
( |
const char * | cmd | ) |
|
Sends a command to the Command Line Interface instance.
- Parameters
-
| [in] | cmd | The command string, including arguments if required. |
- Returns
true when the CLI accepts the input. If busy, return false
◆ run()
| bool qOS::commandLineInterface::run |
( |
void | | ) |
|
Run the AT Command Line Interface when the input is ready.
- See also
- core::add()
- Returns
true on success, otherwise return false
◆ setData()
| void qOS::commandLineInterface::setData |
( |
void * | pData | ) |
|
|
inline |
Set the cli data or storage-pointer.
- Parameters
-
| [in] | pData | A pointer to data or storage-pointer. |
◆ setup() [1/2]
| 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.
- See also
- core::add()
- Note
- CLI Built-in strings will be written to their default values.
- Parameters
-
| [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 |
- Returns
true on success, otherwise return false.
◆ setup() [2/2]
template<size_t inBufferSize, size_t outBufferSize>
| bool qOS::commandLineInterface::setup |
( |
util::putChar_t | outFcn, |
|
|
char(&) | pInput[inBufferSize], |
|
|
char(&) | pOutput[outBufferSize] ) |
|
inline |