nRF Connect SDK API 3.3.99
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
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
80#define at_parser_num_get(parser, index, value) \
81 _Generic((value), \
82 int16_t * : at_parser_int16_get, \
83 uint16_t * : at_parser_uint16_get, \
84 int32_t * : at_parser_int32_get, \
85 uint32_t * : at_parser_uint32_get, \
86 int64_t * : at_parser_int64_get, \
87 uint64_t * : at_parser_uint64_get \
88 )(parser, index, value)
89
100int at_parser_init(struct at_parser *parser, const char *at);
101
120
134
147int at_parser_cmd_count_get(struct at_parser *parser, size_t *count);
148
171int at_parser_int16_get(struct at_parser *parser, size_t index, int16_t *value);
172
195int at_parser_uint16_get(struct at_parser *parser, size_t index, uint16_t *value);
196
219int at_parser_int32_get(struct at_parser *parser, size_t index, int32_t *value);
220
243int at_parser_uint32_get(struct at_parser *parser, size_t index, uint32_t *value);
244
267int at_parser_int64_get(struct at_parser *parser, size_t index, int64_t *value);
268
291int at_parser_uint64_get(struct at_parser *parser, size_t index, uint64_t *value);
292
321int at_parser_string_get(struct at_parser *parser, size_t index, char *str, size_t *len);
322
347int at_parser_string_ptr_get(struct at_parser *parser, size_t index, const char **str_ptr,
348 size_t *len);
349
352#ifdef __cplusplus
353}
354#endif
355
356#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