spandsp 3.0.0
at_interpreter.h
Go to the documentation of this file.
1/*
2 * SpanDSP - a series of DSP components for telephony
3 *
4 * at_interpreter.h - AT command interpreter to V.251, V.252, V.253, T.31 and the 3GPP specs.
5 *
6 * Written by Steve Underwood <steveu@coppice.org>
7 *
8 * Copyright (C) 2004, 2005, 2006 Steve Underwood
9 *
10 * All rights reserved.
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 2.1,
14 * as published by the Free Software Foundation.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License for more details.
20 *
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 */
25
26/*! \file */
27
28#if !defined(_SPANDSP_AT_INTERPRETER_H_)
29#define _SPANDSP_AT_INTERPRETER_H_
30
31/*! \page at_page AT command interpreter
32\section at_page_sec_1 What does it do?
33The AT interpreter module implements V.251, V.252, V.253, T.31 and various 3GPP
34modem control commands.
35
36\section at_page_sec_2 How does it work?
37*/
38
39typedef struct at_state_s at_state_t;
40
41typedef int (*at_modem_control_handler_t)(void *user_data, int op, const char *num);
42typedef int (*at_tx_handler_t)(void *user_data, const uint8_t *buf, size_t len);
43typedef int (*at_class1_handler_t)(void *user_data, int direction, int operation, int val);
44
45enum at_rx_mode_e
46{
47 AT_MODE_ONHOOK_COMMAND,
48 AT_MODE_OFFHOOK_COMMAND,
49 AT_MODE_CONNECTED,
50 AT_MODE_DELIVERY,
51 AT_MODE_HDLC,
52 AT_MODE_STUFFED
53};
54
55enum at_call_event_e
56{
57 AT_CALL_EVENT_ALERTING = 1,
58 AT_CALL_EVENT_CONNECTED,
59 AT_CALL_EVENT_ANSWERED,
60 AT_CALL_EVENT_BUSY,
61 AT_CALL_EVENT_NO_DIALTONE,
62 AT_CALL_EVENT_NO_ANSWER,
63 AT_CALL_EVENT_HANGUP
64};
65
67{
68 /*! Start an outgoing call. */
70 /*! Answer an incoming call. */
72 /*! Hangup a call. */
74 /*! Take the line off hook. */
76 /*! Put the line on hook. */
78 /*! Control V.24 Circuit 108, "data terminal ready". */
80 /*! Control V.24 Circuit 105, "request to send". */
82 /*! Control V.24 Circuit 106, "clear to send". */
84 /*! Control V.24 Circuit 109, "receive line signal detector" (i.e. carrier detect). */
86 /*! Control V.24 Circuit 125, "ring indicator". */
88 /*! Control V.24 Circuit 107, "data set ready". */
90 /*! Set the caller ID for outgoing calls. */
92 /* The remainder of the control functions should not get past the modem, to the
93 application. */
94 AT_MODEM_CONTROL_RESTART,
95 AT_MODEM_CONTROL_DTE_TIMEOUT
96};
97
98enum
99{
100 AT_RESPONSE_CODE_OK = 0,
101 AT_RESPONSE_CODE_CONNECT,
102 AT_RESPONSE_CODE_RING,
103 AT_RESPONSE_CODE_NO_CARRIER,
104 AT_RESPONSE_CODE_ERROR,
105 AT_RESPONSE_CODE_XXX,
106 AT_RESPONSE_CODE_NO_DIALTONE,
107 AT_RESPONSE_CODE_BUSY,
108 AT_RESPONSE_CODE_NO_ANSWER,
109 AT_RESPONSE_CODE_FCERROR,
110 AT_RESPONSE_CODE_FRH3
111};
112
113/*!
114 AT profile.
115*/
116typedef struct
117{
118 /*! True if character echo is enabled */
119 bool echo;
120 /*! True if verbose reporting is enabled */
122 /*! Result code format code - numeic or verbose */
124 /*! True if pulse dialling is the default */
126 /*! ??? */
128 /*! ??? */
130 /*! The state of all possible S registers */
131 uint8_t s_regs[100];
133
134#if defined(__cplusplus)
135extern "C"
136{
137#endif
138
139SPAN_DECLARE(const char *) at_call_state_to_str(int state);
140
141SPAN_DECLARE(const char *) at_modem_control_to_str(int state);
142
143SPAN_DECLARE(void) at_set_at_rx_mode(at_state_t *s, int new_mode);
144
145SPAN_DECLARE(void) at_put_response(at_state_t *s, const char *t);
146
147SPAN_DECLARE(void) at_put_numeric_response(at_state_t *s, int val);
148
149SPAN_DECLARE(void) at_put_response_code(at_state_t *s, int code);
150
151SPAN_DECLARE(void) at_reset_call_info(at_state_t *s);
152
153/*! Set the call information for an AT interpreter.
154 \brief Set the call information for an AT interpreter.
155 \param s The AT interpreter context.
156 \param id .
157 \param value . */
158SPAN_DECLARE(void) at_set_call_info(at_state_t *s, char const *id, char const *value);
159
160SPAN_DECLARE(void) at_display_call_info(at_state_t *s);
161
162SPAN_DECLARE(int) at_modem_control(at_state_t *s, int op, const char *num);
163
164SPAN_DECLARE(void) at_call_event(at_state_t *s, int event);
165
166SPAN_DECLARE(void) at_interpreter(at_state_t *s, const char *cmd, int len);
167
168SPAN_DECLARE(void) at_set_class1_handler(at_state_t *s, at_class1_handler_t handler, void *user_data);
169
170/*! Get the logging context associated with an AT interpreter context.
171 \brief Get the logging context associated with an AT interpreter context.
172 \param s The AT context.
173 \return A pointer to the logging context */
174SPAN_DECLARE(logging_state_t *) at_get_logging_state(at_state_t *s);
175
176SPAN_DECLARE(void) at_set_modem_control_handler(at_state_t *s,
177 at_modem_control_handler_t modem_control_handler,
178 void *modem_control_user_data);
179
180SPAN_DECLARE(void) at_set_at_tx_handler(at_state_t *s,
181 at_tx_handler_t at_tx_handler,
182 void *at_tx_user_data);
183
184/*! Initialise an AT interpreter context.
185 \brief Initialise an AT interpreter context.
186 \param s The AT context.
187 \param at_tx_handler x.
188 \param at_tx_user_data x.
189 \param modem_control_handler x.
190 \param modem_control_user_data x.
191 \return A pointer to the AT context, or NULL if there was a problem. */
192SPAN_DECLARE(at_state_t *) at_init(at_state_t *s,
193 at_tx_handler_t at_tx_handler,
194 void *at_tx_user_data,
195 at_modem_control_handler_t modem_control_handler,
196 void *modem_control_user_data);
197
198/*! Release an AT interpreter context.
199 \brief Release an AT interpreter context.
200 \param s The AT context.
201 \return 0 for OK */
202SPAN_DECLARE(int) at_release(at_state_t *s);
203
204/*! Free an AT interpreter context.
205 \brief Free an AT interpreter context.
206 \param s The AT context.
207 \return 0 for OK */
208SPAN_DECLARE(int) at_free(at_state_t *s);
209
210#if defined(__cplusplus)
211}
212#endif
213
214#endif
215/*- End of file ------------------------------------------------------------*/
at_modem_control_operation_e
Definition at_interpreter.h:67
@ AT_MODEM_CONTROL_RTS
Definition at_interpreter.h:81
@ AT_MODEM_CONTROL_ONHOOK
Definition at_interpreter.h:77
@ AT_MODEM_CONTROL_CTS
Definition at_interpreter.h:83
@ AT_MODEM_CONTROL_DTR
Definition at_interpreter.h:79
@ AT_MODEM_CONTROL_DSR
Definition at_interpreter.h:89
@ AT_MODEM_CONTROL_OFFHOOK
Definition at_interpreter.h:75
@ AT_MODEM_CONTROL_RNG
Definition at_interpreter.h:87
@ AT_MODEM_CONTROL_CALL
Definition at_interpreter.h:69
@ AT_MODEM_CONTROL_ANSWER
Definition at_interpreter.h:71
@ AT_MODEM_CONTROL_CAR
Definition at_interpreter.h:85
@ AT_MODEM_CONTROL_HANGUP
Definition at_interpreter.h:73
@ AT_MODEM_CONTROL_SETID
Definition at_interpreter.h:91
int at_free(at_state_t *s)
Free an AT interpreter context.
Definition at_interpreter.c:5660
void at_set_call_info(at_state_t *s, char const *id, char const *value)
Set the call information for an AT interpreter.
Definition at_interpreter.c:398
int at_release(at_state_t *s)
Release an AT interpreter context.
Definition at_interpreter.c:5651
logging_state_t * at_get_logging_state(at_state_t *s)
Get the logging context associated with an AT interpreter context.
Definition at_interpreter.c:5616
at_state_t * at_init(at_state_t *s, at_tx_handler_t at_tx_handler, void *at_tx_user_data, at_modem_control_handler_t modem_control_handler, void *modem_control_user_data)
Initialise an AT interpreter context.
Definition at_interpreter.c:5622
struct logging_state_s logging_state_t
Definition logging.h:72
Definition at_interpreter.h:117
bool verbose
Definition at_interpreter.h:121
bool pulse_dial
Definition at_interpreter.h:125
int adaptive_receive
Definition at_interpreter.h:129
bool echo
Definition at_interpreter.h:119
int result_code_format
Definition at_interpreter.h:123
uint8_t s_regs[100]
Definition at_interpreter.h:131
int double_escape
Definition at_interpreter.h:127
Definition private/at_interpreter.h:45