nRF Connect SDK API 0.1.0
Loading...
Searching...
No Matches
at_parser.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6
7#ifndef AT_PARSER_H__
8#define AT_PARSER_H__
9
10#include <stdbool.h>
11#include <zephyr/types.h>
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
37};
38
45struct at_parser {
46 /* Pointer to the current AT command line. */
47 const char *at;
48 /* Pointer to the current AT command line value. */
49 const char *cursor;
50 /* Number of values parsed so far for the current AT command line. */
51 size_t count;
52 /* Indicates that the next subparameter is empty. */
54 /* Sentinel value for determining initialization state. */
55 uint32_t init_sentinel;
56};
57
79#define at_parser_num_get(parser, index, value) \
80 _Generic((value), \
81 int16_t * : at_parser_int16_get, \
82 uint16_t * : at_parser_uint16_get, \
83 int32_t * : at_parser_int32_get, \
84 uint32_t * : at_parser_uint32_get, \
85 int64_t * : at_parser_int64_get, \
86 uint64_t * : at_parser_uint64_get \
87 )(parser, index, value)
88
99int at_parser_init(struct at_parser *parser, const char *at);
100
119
133
146int at_parser_cmd_count_get(struct at_parser *parser, size_t *count);
147
169int at_parser_int16_get(struct at_parser *parser, size_t index, int16_t *value);
170
192int at_parser_uint16_get(struct at_parser *parser, size_t index, uint16_t *value);
193
215int at_parser_int32_get(struct at_parser *parser, size_t index, int32_t *value);
216
238int at_parser_uint32_get(struct at_parser *parser, size_t index, uint32_t *value);
239
261int at_parser_int64_get(struct at_parser *parser, size_t index, int64_t *value);
262
284int at_parser_uint64_get(struct at_parser *parser, size_t index, uint64_t *value);
285
313int at_parser_string_get(struct at_parser *parser, size_t index, char *str, size_t *len);
314
339int at_parser_string_ptr_get(struct at_parser *parser, size_t index, const char **str_ptr,
340 size_t *len);
341
344#ifdef __cplusplus
345}
346#endif
347
348#endif /* AT_PARSER_H__ */
int at_parser_cmd_count_get(struct at_parser *parser, size_t *count)
Get the number of values that exist in the current AT command line.
int at_parser_uint16_get(struct at_parser *parser, size_t index, uint16_t *value)
Get an unsigned 16-bit integer value.
int at_parser_uint32_get(struct at_parser *parser, size_t index, uint32_t *value)
Get an unsigned 32-bit integer value.
int at_parser_init(struct at_parser *parser, const char *at)
Initialize an AT parser for a given AT command string.
int at_parser_string_ptr_get(struct at_parser *parser, size_t index, const char **str_ptr, size_t *len)
Get a pointer to a string value.
int at_parser_int16_get(struct at_parser *parser, size_t index, int16_t *value)
Get a signed 16-bit integer value.
int at_parser_int64_get(struct at_parser *parser, size_t index, int64_t *value)
Get a signed 64-bit integer value.
int at_parser_string_get(struct at_parser *parser, size_t index, char *str, size_t *len)
Get a string value.
int at_parser_int32_get(struct at_parser *parser, size_t index, int32_t *value)
Get a signed 32-bit integer value.
at_parser_cmd_type
Identifies the type of a given AT command prefix.
Definition: at_parser.h:26
@ AT_PARSER_CMD_TYPE_SET
Definition: at_parser.h:32
@ AT_PARSER_CMD_TYPE_UNKNOWN
Definition: at_parser.h:30
@ AT_PARSER_CMD_TYPE_READ
Definition: at_parser.h:34
@ AT_PARSER_CMD_TYPE_TEST
Definition: at_parser.h:36
int at_parser_cmd_type_get(struct at_parser *parser, enum at_parser_cmd_type *type)
Get the type of the command prefix in the current AT command line.
int at_parser_cmd_next(struct at_parser *parser)
Move the cursor of an AT parser to the next command line of its configured AT command string.
int at_parser_uint64_get(struct at_parser *parser, size_t index, uint64_t *value)
Get an unsigned 64-bit integer value.
uint32_t init_sentinel
Definition: at_parser.h:55
size_t count
Definition: at_parser.h:51
const char * cursor
Definition: at_parser.h:49
bool is_next_empty
Definition: at_parser.h:53
const char * at
Definition: at_parser.h:47
AT parser.
Definition: at_parser.h:45
Set of parser variables needed for parser framework to operate.
Definition: parser.h:55