OS  v1.7.5
Documentation
Loading...
Searching...
No Matches
qOS::commandLineInterface Class Reference

An AT Command Line Interface (CLI) object. More...

#include <cli.hpp>

Inheritance diagram for qOS::commandLineInterface:
[legend]
Collaboration diagram for qOS::commandLineInterface:
[legend]

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.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ commandLineInterface()

qOS::commandLineInterface::commandLineInterface ( )
default

Member Function Documentation

◆ add()

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).

Parameters
[in]cmdThe AT command object.
[in]textCommandThe 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]cFcnThe 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]cmdOptThis 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]paramUser 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]cmdThe 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

◆ 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]pDataThe incoming string.
[in]nThe 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]cThe incoming byte/char to the input.
Returns
true when the CLI is ready to process the input, otherwise return false

◆ raise()

bool qOS::commandLineInterface::raise ( const char * cmd)

Sends a command to the Command Line Interface instance.

Parameters
[in]cmdThe 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]pDataA 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]outFcnThe basic output-char wrapper function. All the CLI responses will be printed-out through this function.
[in]pInputA memory location to store the cli input (Mandatory)
[in]sizeInThe size of the memory allocated in pInput
[in]pOutputA memory location to store the CLI output
[in]sizeOutThe 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