AT command parser

The AT command parser is a library for parsing the string that is returned after issuing an AT command. It parses the response parameters from the string and saves them in a list.

To store the parameters in a list, the parser uses the AT parameters storage module. The resulting list can be used by any external module to obtain the value of the parameters. Based on the type of the parameter, you can obtain its value by calling either at_params_int_get(), at_params_short_get(), or at_params_string_get().

Before using the AT command parser, you must initialize a list of AT command/response parameters by calling at_params_list_init(). Then, to parse a string, simply pass the returned AT command string to the library function at_parser_params_from_str().

API documentation

group at_cmd_parser

Functions

int at_parser_max_params_from_str(char *at_params_str, struct at_param_list *list, size_t max_params_count)

Parse a maximum number of AT command or response parameters from a string.

This function parses the parameters from at_params_str and saves them in list. If there are more parameters than max_params_count, they are ignored.

list must be initialized. It can be reused to parse multiple commands. When calling this function, the list is cleared. The maximum number of AT parameters that can be parsed and stored is limited by the size of list.

If an error is returned by the parser, the content of list should be ignored.

Parameters
  • at_params_str: AT parameters as a null-terminated string. Can be numeric or string parameters.
  • list: Pointer to an initialized list where parameters are stored. Must not be NULL.
  • max_params_count: Maximum number of parameters expected in at_params_str. Can be set to a smaller value to parse only some parameters.
Return Value
  • 0: If the operation was successful. Otherwise, a (negative) error code is returned.

int at_parser_params_from_str(char *at_params_str, struct at_param_list *list)

Parse AT command or response parameters from a string.

This function parses the parameters from at_params_str and saves them in list.

list must be initialized. It can be reused to parse multiple commands. When calling this function, the list is cleared. The maximum number of AT parameters that can be parsed and stored is limited by the size of list.

If an error is returned by the parser, the content of list should be ignored.

Parameters
  • at_params_str: AT parameters as a null-terminated string. Can be numeric or string parameters.
  • list: Pointer to an initialized list where parameters are stored. Must not be NULL.
Return Value
  • 0: If the operation was successful. Otherwise, a (negative) error code is returned.