OS  v7.3.3
Documentation
Loading...
Searching...
No Matches
qatcli.h
1
8#ifndef QATCLI_H
9 #define QATCLI_H
10
11 #include "qtypes.h"
12 #include "qioutils.h"
13
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17
18 #ifndef Q_ATCLI
19 #define Q_ATCLI ( 1 )
20 #endif
21
31 typedef enum {
32 qATCLI_ERROR = -32767,
36 qATCLI_DEVID = 32765,
38 qATCLI_OUTPUT = 32767
39 }
41
51 #define qATCLI_ERROR_CODE(ecode) (-(ecode) )
52
53
55 typedef volatile struct _qATCLI_Input_s { // skipcq: CXX-E2000
56 char *storage; /*< Points to the user-defined storage area for the input. */
57 volatile qIndex_t index; /*< Used to hold the index of the current input-buffer. */
58 qIndex_t maxIndex; /*< Max index = (Size - 1) */
59 size_t size; /*< The size of the input buffer. */
60 volatile qBool_t ready; /*< A flag that indicates when the input is ready to parse. */
61 }
62 qATCLI_Input_t;
63
64 #define QATCLI_CMDTYPE_UNDEF ( 0x0000 )
65 #define QATCLI_CMDTYPE_PARA ( 0x0100 )
66 #define QATCLI_CMDTYPE_TEST ( 0x0200 )
67 #define QATCLI_CMDTYPE_READ ( 0x0400 )
68 #define QATCLI_CMDTYPE_ACT ( 0x0800 )
69
70 #define QATCLI_CMDTYPE_SET ( QATCLI_CMDTYPE_PARA )
71 #define QATCLI_CMDTYPE_CHECK ( QATCLI_CMDTYPE_ACT )
72
78 typedef enum {
79 qATCLI_CMDTYPE_UNDEF = QATCLI_CMDTYPE_UNDEF,
80 qATCLI_CMDTYPE_PARA = QATCLI_CMDTYPE_PARA,
81 qATCLI_CMDTYPE_TEST = QATCLI_CMDTYPE_TEST,
82 qATCLI_CMDTYPE_READ = QATCLI_CMDTYPE_READ,
83 qATCLI_CMDTYPE_ACT = QATCLI_CMDTYPE_ACT
84 }
86
99 typedef struct _qATCLI_PublicData_s { // skipcq: CXX-E2000
103 void *Command;
107 char *StrData;
115 char* (*GetArgPtr)( qIndex_t n );
124 int (*GetArgInt)( qIndex_t n );
133 qFloat32_t (*GetArgFlt)( qIndex_t n );
142 qUINT32_t (*GetArgHex)( qIndex_t n );
151 char* (*GetArgString)( qIndex_t n, char* pOut );
158 void (*putch)( const char c );
165 void (*puts)( const char *s );
169 char *Output;
173 void *Data;
177 size_t StrLen;
181 size_t NumArgs;
186 }
187 #ifdef DOXYGEN
189 #else
190 _qATCLI_PublicData_t; // skipcq: CXX-E2000
191 typedef _qATCLI_PublicData_t* qATCLI_Handler_t;
192 #endif
193
202 typedef struct _qATCLI_ControlBlock_s { // skipcq: CXX-E2000
204 struct _qATCLI_Private_s { // skipcq: CXX-E2000
205 void *first; /*< Points to the first command*/
206 const char *ok_rsp; /*< The response printed when OK is needed. */
207 const char *er_rsp; /*< The response printed when ERROR is needed. */
208 const char *nf_rsp; /*< The response printed when NOTFOUND is needed. */
209 const char *id_rsp; /*< The response printed when the "ATID" command has been entered. */
210 const char *eol; /*< The End Of Line string after a command response */
211 qPutChar_t outputFcn; /*< Points to the user-supplied function to write a single byte to the output. */
212 void (*xNotifyFcn)(struct _qATCLI_ControlBlock_s * const arg); /*< Used to notify the attached task if available*/
213 size_t sizeOutput; /*< The size of Output. */
214 qATCLI_Input_t xInput; /*< The input of the CLI. */
215 _qATCLI_PublicData_t xPublic; /*< External accessible through the qATCLI_Handler_t*/
216 void *owner;
217 }
218 qPrivate;
220 }
221 qATCLI_t;
222
246
251
255 typedef struct _qATCLI_Command_s { // skipcq: CXX-E2000
257 struct _qATCLI_Command_Private_s { /*< Linked-list pointers. */ // skipcq: CXX-E2000
258 qATCLI_CommandCallback_t cmdCallback; /*< The command callback. */
259 struct _qATCLI_Command_s *next; /*< Points to the next command in the list. */
260 qATCLI_Options_t cmdOpt; /*< The command options. */
261 size_t cmdLen; /*< The command length. */
262 }
263 qPrivate;
265 void *param;
266 char *Text;
267 }
269
281
292 const char *str );
293
307 qBool_t qATCLI_Setup( qATCLI_t * const cli,
308 const qPutChar_t outFcn,
309 char *pInput,
310 const size_t sizeInput,
311 char *pOutput,
312 const size_t sizeOutput );
313
348 qATCLI_Command_t * const cmd,
349 char *textCommand,
350 const qATCLI_CommandCallback_t cFcn,
351 qATCLI_Options_t cmdOpt,
352 void *param );
353
362 qATCLI_Command_t* qATCLI_CmdIterate( const qATCLI_t * const cli,
363 const qBool_t reload );
364
375 const char c );
376
388 char *pData,
389 const size_t n );
390
397 qBool_t qATCLI_Raise( qATCLI_t * const cli,
398 const char *cmd );
399
407 char *cmd );
408
414 qBool_t qATCLI_Input_Flush( qATCLI_t * const cli );
415
422 qBool_t qATCLI_Run( qATCLI_t * const cli );
423
426 #ifdef __cplusplus
427 }
428 #endif
429
430#endif
qATCLI_Response_t qATCLI_Exec(qATCLI_t *const cli, char *cmd)
Try to execute the requested command.
Definition qatcli.c:345
qBool_t qATCLI_Input_Flush(qATCLI_t *const cli)
Flush the CLI input buffer.
Definition qatcli.c:448
qBool_t qATCLI_Raise(qATCLI_t *const cli, const char *cmd)
Sends a command to the specified AT Command Line Interface instance.
Definition qatcli.c:322
qBool_t qATCLI_SetBuiltInString(qATCLI_t *const cli, qATCLI_BuiltInString_t which, const char *str)
Set a CLI built-in string to a custom one.
Definition qatcli.c:72
qATCLI_Response_t(* qATCLI_CommandCallback_t)(qATCLI_Handler_t arg1)
Pointer to function : An AT-Command callback.
Definition qatcli.h:245
qBool_t qATCLI_Setup(qATCLI_t *const cli, const qPutChar_t outFcn, char *pInput, const size_t sizeInput, char *pOutput, const size_t sizeOutput)
Setup an instance of the AT Command Line Interface.
Definition qatcli.c:112
qATCLI_Command_t * qATCLI_CmdIterate(const qATCLI_t *const cli, const qBool_t reload)
Iterate between the commands available inside the AT-CLI instance.
Definition qatcli.c:198
qBool_t qATCLI_ISRHandlerBlock(qATCLI_t *const cli, char *pData, const size_t n)
Feed the CLI input with a string. This call is mandatory from an interrupt context....
Definition qatcli.c:257
qATCLI_BuiltInString_t
Possible values for built-in string identifiers.
Definition qatcli.h:273
qATCLI_CommandType_t
An enum to describe the available AT command types.
Definition qatcli.h:78
qBool_t qATCLI_ISRHandler(qATCLI_t *const cli, const char c)
Feed the CLI input with a single character. This call is mandatory from an interrupt context....
Definition qatcli.c:224
qBool_t qATCLI_Run(qATCLI_t *const cli)
Run the AT Command Line Interface when the input is ready.
Definition qatcli.c:465
qATCLI_Response_t
an enumeration to define the possible values that can be returned from the callback of a command.
Definition qatcli.h:31
qUINT16_t qATCLI_Options_t
A typedef that holds the options for an AT-Command object.
Definition qatcli.h:250
qBool_t qATCLI_CmdSubscribe(qATCLI_t *const cli, qATCLI_Command_t *const cmd, char *textCommand, const qATCLI_CommandCallback_t cFcn, qATCLI_Options_t cmdOpt, void *param)
This function subscribes the CLI instance to a specific command with an associated Callback function,...
Definition qatcli.c:154
@ QATCLI_BUILTIN_STR_ERROR_RESPONSE
Definition qatcli.h:276
@ QATCLI_BUILTIN_STR_IDENTIFIER
Definition qatcli.h:274
@ QATCLI_BUILTIN_STR_TERM_EOL
Definition qatcli.h:278
@ QATCLI_BUILTIN_STR_NOTFOUND_RESPONSE
Definition qatcli.h:277
@ QATCLI_BUILTIN_STR_OK_RESPONSE
Definition qatcli.h:275
@ qATCLI_CMDTYPE_TEST
Definition qatcli.h:81
@ qATCLI_CMDTYPE_ACT
Definition qatcli.h:83
@ qATCLI_CMDTYPE_PARA
Definition qatcli.h:80
@ qATCLI_CMDTYPE_UNDEF
Definition qatcli.h:79
@ qATCLI_CMDTYPE_READ
Definition qatcli.h:82
@ qATCLI_NOTALLOWED
Definition qatcli.h:33
@ qATCLI_OK
Definition qatcli.h:35
@ qATCLI_NOTFOUND
Definition qatcli.h:37
@ qATCLI_DEVID
Definition qatcli.h:36
@ qATCLI_ERROR
Definition qatcli.h:32
@ qATCLI_NORESPONSE
Definition qatcli.h:34
@ qATCLI_OUTPUT
Definition qatcli.h:38
void(* qPutChar_t)(void *arg1, const char arg2)
Pointer to function that write-out a single character.
Definition qioutils.h:52
qUINT8_t qBool_t
A type to instantiate an OS boolean variable.
Definition qtypes.h:139
size_t qIndex_t
A type to instantiate an OS index variable. Can store the maximum size of a theoretically possible ob...
Definition qtypes.h:146
uint32_t qUINT32_t
Unsigned integer type with width of exactly 32 bits respectively.
Definition qtypes.h:48
uint16_t qUINT16_t
Unsigned integer type with width of exactly 16 bits respectively.
Definition qtypes.h:46
float qFloat32_t
A type to instantiate a single-precision variable of 32-bits IEEE 754.
Definition qtypes.h:111
An AT-Command object.
Definition qatcli.h:255
void * param
Definition qatcli.h:265
char * Text
Definition qatcli.h:266
The command argument with all the regarding information of the incoming AT command.
Definition qatcli.h:99
char * Output
The CLI output buffer. Can be written by the user.
Definition qatcli.h:169
size_t NumArgs
Number of arguments, only available if Type = qATCLI_CMDTYPE_PARA.
Definition qatcli.h:181
void * Data
Points to the user-defined data - Storage Pointer.
Definition qatcli.h:173
size_t StrLen
The length of StrData.
Definition qatcli.h:177
void * Command
A pointer to the calling AT Command object.
Definition qatcli.h:103
qATCLI_CommandType_t Type
The incoming command type. *.
Definition qatcli.h:185
char * StrData
The string data received after the detected command.
Definition qatcli.h:107
An AT Command Line Interface (CLI) object.
Definition qatcli.h:202