Firmware SDK
twr_atci.h
1 #ifndef _TWR_ATCI_H
2 #define _TWR_ATCI_H
3 
4 #include <twr_uart.h>
5 
9 
10 #ifndef TWR_ATCI_UART
11 #define TWR_ATCI_UART TWR_UART_UART2
12 #endif
13 
14 #define TWR_ATCI_COMMANDS_LENGTH(COMMANDS) (sizeof(COMMANDS) / sizeof(COMMANDS[0]))
15 
16 #define TWR_ATCI_COMMAND_CLAC {"+CLAC", twr_atci_clac_action, NULL, NULL, NULL, "List all available AT commands"}
17 #define TWR_ATCI_COMMAND_HELP {"$HELP", twr_atci_help_action, NULL, NULL, NULL, "This help"}
18 
19 typedef struct
20 {
21  char *txt;
22  size_t length;
23  size_t offset;
24 
26 
28 
29 typedef struct
30 {
31  const char *command;
32  bool (*action)(void);
33  bool (*set)(twr_atci_param_t *param);
34  bool (*read)(void);
35  bool (*help)(void);
36  const char *hint;
37 
39 
43 
44 void twr_atci_init(const twr_atci_command_t *commands, int length);
45 
47 
48 void twr_atci_write_ok(void);
49 
51 
52 void twr_atci_write_error(void);
53 
57 
58 size_t twr_atci_print(const char *message);
59 
63 
64 size_t twr_atci_println(const char *message);
65 
70 
71 size_t twr_atci_printf(const char *format, ...);
72 
77 
78 size_t twr_atci_printfln(const char *format, ...);
79 
84 
85 size_t twr_atci_print_buffer_as_hex(const void *buffer, size_t length);
86 
88 
89 bool twr_atci_skip_response(void);
90 
92 
93 bool twr_atci_clac_action(void);
94 
96 
97 bool twr_atci_help_action(void);
98 
104 
105 bool twr_atci_get_uint(twr_atci_param_t *param, uint32_t *value);
106 
113 
114 bool twr_atci_get_string(twr_atci_param_t *param, char *str, size_t length);
115 
122 
123 bool twr_atci_get_buffer_from_hex_string(twr_atci_param_t *param, void *buffer, size_t *length);
124 
129 
131 
136 
138 
142 
143 void twr_atci_set_uart_active_callback(bool(*callback)(void), twr_tick_t scan_interval);
144 
146 
147 #endif //_TWR_ATCI_H
bool twr_atci_get_buffer_from_hex_string(twr_atci_param_t *param, void *buffer, size_t *length)
Decode HEX string to buffer and move parsing cursor forward.
Definition: twr_atci.c:390
bool twr_atci_skip_response(void)
Skip response, use in callback in twr_atci_command_t.
Definition: twr_atci.c:127
bool twr_atci_is_comma(twr_atci_param_t *param)
Check if the character at cursor is comma.
Definition: twr_atci.c:454
size_t twr_atci_printf(const char *format,...)
Prinf message.
Definition: twr_atci.c:68
bool twr_atci_clac_action(void)
Helper for clac action.
Definition: twr_atci.c:144
bool twr_atci_help_action(void)
Helper for help action.
Definition: twr_atci.c:153
bool twr_atci_is_quotation_mark(twr_atci_param_t *param)
Check if the character at cursor is quotation mark (")
Definition: twr_atci.c:459
size_t twr_atci_print(const char *message)
Print message.
Definition: twr_atci.c:46
void twr_atci_write_error(void)
Write ERROR.
Definition: twr_atci.c:139
bool twr_atci_get_uint(twr_atci_param_t *param, uint32_t *value)
Parse string to uint and move parsing cursor forward.
Definition: twr_atci.c:323
void twr_atci_init(const twr_atci_command_t *commands, int length)
Initialize.
Definition: twr_atci.c:27
bool twr_atci_get_string(twr_atci_param_t *param, char *str, size_t length)
Copy string and move parsing cursor forward.
Definition: twr_atci.c:353
void twr_atci_write_ok(void)
Write OK.
Definition: twr_atci.c:134
size_t twr_atci_print_buffer_as_hex(const void *buffer, size_t length)
Print buffer as HEX string.
Definition: twr_atci.c:103
size_t twr_atci_println(const char *message)
Print message and add CR LF.
Definition: twr_atci.c:51
void twr_atci_set_uart_active_callback(bool(*callback)(void), twr_tick_t scan_interval)
Set callback function for scan if uart is active. Used for low-power when USB is disconnected (defaul...
Definition: twr_atci.c:464
size_t twr_atci_printfln(const char *format,...)
Prinf message and add CR LF.
Definition: twr_atci.c:84
uint64_t twr_tick_t
Timestamp data type.
Definition: twr_tick.h:16
AT command struct.
Definition: twr_atci.h:30