File syn_at_parser.c¶
FileList > proto > syn_at_parser.c
Go to the source code of this file
Implementation of stream-oriented AT command parser.
#include "syn_at_parser.h"#include <ctype.h>#include <stdlib.h>#include <string.h>
Public Functions¶
| Type | Name |
|---|---|
| SYN_AtRespType | syn_at_parser_feed_char (SYN_AtParser * parser, char c) Feed a single byte into the AT parser. |
| SYN_AtRespType | syn_at_parser_feed_stream (SYN_AtParser * parser, SYN_Stream * stream) Feed available bytes from a SYN_Stream into the AT parser. |
| int | syn_at_parser_get_cme_error (const SYN_AtParser * parser) Get the parsed error code for SYN_AT_RESP_CME_ERROR. |
| const char * | syn_at_parser_get_line (const SYN_AtParser * parser) Get the current accumulated response line string. |
| bool | syn_at_parser_get_param_int (const char * line, size_t param_idx, int * out_val) Helper: Extract an integer parameter from a comma-delimited AT response line. |
| bool | syn_at_parser_get_param_str (const char * line, size_t param_idx, char * out_buf, size_t max_len) Helper: Extract a string parameter from a comma-delimited AT response line. |
| SYN_Status | syn_at_parser_init (SYN_AtParser * parser, char * buf, size_t buf_size) Initialize an AT command parser. |
| void | syn_at_parser_reset (SYN_AtParser * parser) Reset internal parser state. |
Public Static Functions¶
| Type | Name |
|---|---|
| const char * | find_param_start (const char * line, size_t param_idx) |
| bool | starts_with (const char * str, const char * prefix) |
Public Functions Documentation¶
function syn_at_parser_feed_char¶
Feed a single byte into the AT parser.
Processes a single character. Returns response type if a complete line (\r ) or prompt ('>') has been parsed.
Parameters:
parserParser instance.cByte to process.
Returns:
Decoded response type, or SYN_AT_RESP_NONE if line incomplete.
function syn_at_parser_feed_stream¶
Feed available bytes from a SYN_Stream into the AT parser.
Reads bytes non-blockingly from the stream until a complete response line/prompt is parsed or the stream is empty.
Parameters:
parserParser instance.streamPointer to input stream.
Returns:
Decoded response type, or SYN_AT_RESP_NONE if line incomplete.
function syn_at_parser_get_cme_error¶
Get the parsed error code for SYN_AT_RESP_CME_ERROR.
Parameters:
parserParser instance.
Returns:
Numerical CME/CMS error code, or -1 if unavailable.
function syn_at_parser_get_line¶
Get the current accumulated response line string.
Parameters:
parserParser instance.
Returns:
Null-terminated line string.
function syn_at_parser_get_param_int¶
Helper: Extract an integer parameter from a comma-delimited AT response line.
Example line: "+CSQ: 20,0" -> param 0 is 20, param 1 is 0.
Parameters:
lineResponse text line.param_idx0-based parameter index.out_val[out] Extracted integer value.
Returns:
true if parameter was found and successfully parsed.
function syn_at_parser_get_param_str¶
Helper: Extract a string parameter from a comma-delimited AT response line.
bool syn_at_parser_get_param_str (
const char * line,
size_t param_idx,
char * out_buf,
size_t max_len
)
Handles quoted strings (e.g. "+CPIN: \"READY\"") and strips quotes.
Parameters:
lineResponse text line.param_idx0-based parameter index.out_bufDestination buffer.max_lenDestination capacity.
Returns:
true if parameter was found and extracted.
function syn_at_parser_init¶
Initialize an AT command parser.
Parameters:
parserParser instance.bufCaller-owned buffer for line accumulation.buf_sizeCapacity of buffer in bytes.
Returns:
SYN_OK on success, or SYN_ERR_INVALID_PARAM.
function syn_at_parser_reset¶
Reset internal parser state.
Clears accumulated line buffer and last decoded response.
Parameters:
parserParser instance.
Public Static Functions Documentation¶
function find_param_start¶
function starts_with¶
The documentation for this class was generated from the following file src/syntropic/proto/syn_at_parser.c