4#include "include/types.hpp"
5#include "include/list.hpp"
6#include "include/util.hpp"
10 class commandLineInterface;
51 return static_cast<response>( -code );
70 char *storage{
nullptr };
74 volatile bool ready{
false };
76 void operator=( input
const& ) =
delete;
96 void *Command{
nullptr };
97 char *StrData{
nullptr };
98 void *Data{
nullptr };
100 size_t NumArgs{ 0U };
102 _Handler( _Handler
const& ) =
delete;
103 void operator=( _Handler
const& ) =
delete;
104 _Handler() =
default;
217 class commandHandler final {
220 command *Command{
nullptr };
221 char *StrData{
nullptr };
222 void *Data{
nullptr };
224 size_t NumArgs{ 0U };
226 commandHandler( commandHandler
const& ) =
delete;
227 void operator=( commandHandler
const& ) =
delete;
228 commandHandler() =
default;
234 inline char* getStringData(
void )
238 inline void* getData(
void )
242 inline size_t getStringLength(
void )
const
246 inline size_t getNumArgs(
void )
const
250 inline command& self(
void )
noexcept
254 inline command& thisCommand(
void )
noexcept
258 char* getArgPtr( index_t n )
const;
259 int getArgInt( index_t n )
const;
260 float32_t getArgFloat( index_t n )
const;
261 uint32_t getArgHex( index_t n )
const;
262 char* getArgString( index_t n,
char *pOut );
263 void writeOut(
const char c )
const;
264 void writeOut(
const char *s )
const;
265 char *output{
nullptr };
268 using handler_t = commandHandler&;
307 void *param{
nullptr };
308 char *Text{
nullptr };
310 void operator=(
command const& ) =
delete;
336 cli::commandHandler handler;
337 const char *ok_rsp{
"OK" };
338 const char *er_rsp{
"ERROR" };
339 const char *nf_rsp{
"UNKNOWN" };
340 const char *id_rsp{
"" };
341 const char *eol{
"\r\n" };
344 size_t sizeOutput{ 0U };
345 void *owner{
nullptr };
347 bool preProcessing(
cli::command *cmd,
char *inputBuffer );
348 size_t numOfArgs(
const char *str )
const;
371 template <
size_t inBufferSize,
size_t outBufferSize>
374 return setup( outFcn, pInput, inBufferSize, pOutput, outBufferSize );
463 handler.Data = pData;
465 friend class cli::commandHandler;
An AT-Command object.
Definition cli.hpp:302
void * getParam(void) noexcept
Definition cli.hpp:316
The command argument with all the regarding information of the incoming AT command.
Definition cli.hpp:93
int getArgInt(index_t n) const
Helper method to get the n argument parsed as integer from the incoming AT command.
float32_t getArgFloat(index_t n) const
Helper method to get the n argument parsed as float from the incoming AT command.
char * getArgString(index_t n, char *pOut)
Helper method to get the n argument parsed as string from the incoming AT command.
char * getArgPtr(index_t n) const
Helper method to get the pointer where the desired argument starts.
size_t getStringLength(void) const
The length of the stringStrData.
Definition cli.hpp:133
commandType getType(void) const
Retrieve the he incoming command type.*.
Definition cli.hpp:110
void writeOut(const char c) const
Helper method for printing a character to the CLI output. It displays only one character at a time.
void writeOut(const char *s) const
Writes a string to CLI output without the EOF string appended at the end.
char * getStringData(void)
The string data received after the detected command.
Definition cli.hpp:118
command & thisCommand(void) noexcept
return the instance of command being evaluated
uint32_t getArgHex(index_t n) const
Helper method to get the n HEX argument parsed uint32_t from the incoming AT command.
void * getData(void)
Retrieve a pointer to the user-defined data - Storage Pointer.
Definition cli.hpp:126
char * output
The CLI output buffer. Can be written by the user.
Definition cli.hpp:205
size_t getNumArgs(void) const
Retrieve the number of arguments of the incoming AT command. only available if Type = commandType::PA...
Definition cli.hpp:142
An AT Command Line Interface (CLI) object.
Definition cli.hpp:333
commandLineInterface()=default
bool raise(const char *cmd)
Sends a command to the Command Line Interface instance.
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.
Definition cli.hpp:453
void setData(void *pData)
Set the cli data or storage-pointer.
Definition cli.hpp:461
bool isrHandler(const char c)
Feed the CLI input with a single character. This call is mandatory from an interrupt context....
bool inputFlush(void)
Flush the CLI input buffer.
bool setup(util::putChar_t outFcn, char(&pInput)[inBufferSize], char(&pOutput)[outBufferSize])
Definition cli.hpp:372
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,...
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.
bool isrHandler(char *pData, const size_t n)
Feed the CLI input with a string. This call is mandatory from an interrupt context....
The class to interface the OS.
Definition kernel.hpp:83
A list object (Generic double-linked)
Definition list.hpp:119
A list-node object (Used internally)
Definition list.hpp:62
response(*)(handler_t) commandCallback_t
Pointer to function : An AT-Command callback.
Definition cli.hpp:292
uint16_t options_t
A typedef that holds the options for an AT-Command object.
Definition cli.hpp:297
response
an enumeration to define the possible values that can be returned from the callback of a command.
Definition cli.hpp:30
commandType
An enum to describe the available AT command types.
Definition cli.hpp:57
constexpr response ERROR_CODE(int16_t code)
Used to indicate an error code as return value inside a command-callback. This code is defined by the...
Definition cli.hpp:49
@ NOT_ALLOWED
Definition cli.hpp:32
@ DEVID
Definition cli.hpp:35
@ ERROR
Definition cli.hpp:31
@ OUTPUT_RESPONSE
Definition cli.hpp:37
@ NO_RESPONSE
Definition cli.hpp:33
@ OK
Definition cli.hpp:34
@ NOT_FOUND
Definition cli.hpp:36
@ TEST
Definition cli.hpp:60
@ READ
Definition cli.hpp:61
@ PARA
Definition cli.hpp:59
@ UNDEF
Definition cli.hpp:58
@ ACT
Definition cli.hpp:62
void(*)(void *, const char) putChar_t
Pointer to function that write-out a single character.
Definition util.hpp:33
STD_TYPE_SIZE_T index_t
A type to instantiate an OS index variable. Can store the maximum size of a theoretically possible ob...
Definition types.hpp:94
float float32_t
A type to instantiate a single-precision variable of 32-bits IEEE 754.
Definition types.hpp:82
OS/Kernel interfaces.
Definition bytebuffer.hpp:7