Firmware SDK
twr_atci

AT command interface. More...

Data Structures

struct  twr_atci_param_t
 
struct  twr_atci_command_t
 AT command struct. More...
 

Macros

#define TWR_ATCI_UART   TWR_UART_UART2
 
#define TWR_ATCI_COMMANDS_LENGTH(COMMANDS)   (sizeof(COMMANDS) / sizeof(COMMANDS[0]))
 
#define TWR_ATCI_COMMAND_CLAC   {"+CLAC", twr_atci_clac_action, NULL, NULL, NULL, "List all available AT commands"}
 
#define TWR_ATCI_COMMAND_HELP   {"$HELP", twr_atci_help_action, NULL, NULL, NULL, "This help"}
 

Functions

void twr_atci_init (const twr_atci_command_t *commands, int length)
 Initialize. More...
 
void twr_atci_write_ok (void)
 Write OK.
 
void twr_atci_write_error (void)
 Write ERROR.
 
size_t twr_atci_print (const char *message)
 Print message. More...
 
size_t twr_atci_println (const char *message)
 Print message and add CR LF. More...
 
size_t twr_atci_printf (const char *format,...)
 Prinf message. More...
 
size_t twr_atci_printfln (const char *format,...)
 Prinf message and add CR LF. More...
 
size_t twr_atci_print_buffer_as_hex (const void *buffer, size_t length)
 Print buffer as HEX string. More...
 
bool twr_atci_skip_response (void)
 Skip response, use in callback in twr_atci_command_t.
 
bool twr_atci_clac_action (void)
 Helper for clac action.
 
bool twr_atci_help_action (void)
 Helper for help action.
 
bool twr_atci_get_uint (twr_atci_param_t *param, uint32_t *value)
 Parse string to uint and move parsing cursor forward. More...
 
bool twr_atci_get_string (twr_atci_param_t *param, char *str, size_t length)
 Copy string and move parsing cursor forward. More...
 
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. More...
 
bool twr_atci_is_comma (twr_atci_param_t *param)
 Check if the character at cursor is comma. More...
 
bool twr_atci_is_quotation_mark (twr_atci_param_t *param)
 Check if the character at cursor is quotation mark (") More...
 
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 (default callback: twr_system_get_vbus_sense, scan_interval: 200) More...
 

Detailed Description

AT command interface.

Function Documentation

◆ twr_atci_get_buffer_from_hex_string()

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.

Parameters
[in]paramATCI instance
[out]destinationPointer to destination buffer
[in,out]lengthNumber of bytes to be read, Number of bytes read
Returns
true On success
false On failure

Definition at line 390 of file twr_atci.c.

◆ twr_atci_get_string()

bool twr_atci_get_string ( twr_atci_param_t param,
char *  str,
size_t  length 
)

Copy string and move parsing cursor forward.

Parameters
[in]paramATCI instance
[in]valuepointer to str destination
[in]lengthmaximum str length
Returns
true On success
false On failure

Definition at line 353 of file twr_atci.c.

◆ twr_atci_get_uint()

bool twr_atci_get_uint ( twr_atci_param_t param,
uint32_t *  value 
)

Parse string to uint and move parsing cursor forward.

Parameters
[in]paramATCI instance
[in]valuepointer to number
Returns
true On success
false On failure

Definition at line 323 of file twr_atci.c.

◆ twr_atci_init()

void twr_atci_init ( const twr_atci_command_t commands,
int  length 
)

Initialize.

Parameters
[in]commands
[in]lengthNumber of commands

Definition at line 27 of file twr_atci.c.

Here is the call graph for this function:

◆ twr_atci_is_comma()

bool twr_atci_is_comma ( twr_atci_param_t param)

Check if the character at cursor is comma.

Parameters
[in]paramATCI instance
Returns
true On success
false On failure

Definition at line 454 of file twr_atci.c.

◆ twr_atci_is_quotation_mark()

bool twr_atci_is_quotation_mark ( twr_atci_param_t param)

Check if the character at cursor is quotation mark (")

Parameters
[in]paramATCI instance
Returns
true On success
false On failure

Definition at line 459 of file twr_atci.c.

◆ twr_atci_print()

size_t twr_atci_print ( const char *  message)

Print message.

Parameters
[in]messageMessage
Returns
Number of bytes written

Definition at line 46 of file twr_atci.c.

Here is the call graph for this function:

◆ twr_atci_print_buffer_as_hex()

size_t twr_atci_print_buffer_as_hex ( const void *  buffer,
size_t  length 
)

Print buffer as HEX string.

Parameters
[in]bufferPointer to source buffer
[in]lengthNumber of bytes to be written
Returns
Number of bytes written

Definition at line 103 of file twr_atci.c.

Here is the call graph for this function:

◆ twr_atci_printf()

size_t twr_atci_printf ( const char *  format,
  ... 
)

Prinf message.

Parameters
[in]formatFormat string (printf style)
[in]...Optional format arguments
Returns
Number of bytes written

Definition at line 68 of file twr_atci.c.

Here is the call graph for this function:

◆ twr_atci_printfln()

size_t twr_atci_printfln ( const char *  format,
  ... 
)

Prinf message and add CR LF.

Parameters
[in]formatFormat string (printf style)
[in]...Optional format arguments
Returns
Number of bytes written

Definition at line 84 of file twr_atci.c.

Referenced by twr_atci_clac_action(), and twr_atci_help_action().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ twr_atci_println()

size_t twr_atci_println ( const char *  message)

Print message and add CR LF.

Parameters
[in]messageMessage
Returns
Number of bytes written

Definition at line 51 of file twr_atci.c.

Here is the call graph for this function:

◆ twr_atci_set_uart_active_callback()

void twr_atci_set_uart_active_callback ( bool(*)(void)  callback,
twr_tick_t  scan_interval 
)

Set callback function for scan if uart is active. Used for low-power when USB is disconnected (default callback: twr_system_get_vbus_sense, scan_interval: 200)

Parameters
[in]callbackCallback function address
[in]scan_intervalDesired scan interval in ticks

Definition at line 464 of file twr_atci.c.

Referenced by twr_atci_init().

Here is the call graph for this function:
Here is the caller graph for this function: