Mercurial > hg > audiostuff
comparison spandsp-0.0.3/spandsp-0.0.3/src/spandsp/at_interpreter.h @ 5:f762bf195c4b
import spandsp-0.0.3
author | Peter Meerwald <pmeerw@cosy.sbg.ac.at> |
---|---|
date | Fri, 25 Jun 2010 16:00:21 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
4:26cd8f1ef0b1 | 5:f762bf195c4b |
---|---|
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 General Public License version 2, as | |
14 * 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 General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
24 * | |
25 * $Id: at_interpreter.h,v 1.10 2006/10/24 13:45:27 steveu Exp $ | |
26 */ | |
27 | |
28 /*! \file */ | |
29 | |
30 #if !defined(_AT_INTERPRETER_H_) | |
31 #define _AT_INTERPRETER_H_ | |
32 | |
33 /*! \page at_page AT command interpreter | |
34 \section at_page_sec_1 What does it do? | |
35 The AT interpreter module implements V.251, V.252, V.253, T.31 and various 3GPP | |
36 modem control commands. | |
37 | |
38 \section at_page_sec_2 How does it work? | |
39 */ | |
40 | |
41 typedef struct at_state_s at_state_t; | |
42 | |
43 typedef int (at_modem_control_handler_t)(at_state_t *s, void *user_data, int op, const char *num); | |
44 typedef int (at_tx_handler_t)(at_state_t *s, void *user_data, const uint8_t *buf, size_t len); | |
45 typedef int (at_class1_handler_t)(at_state_t *s, void *user_data, int direction, int operation, int val); | |
46 | |
47 enum at_rx_mode_e | |
48 { | |
49 AT_MODE_ONHOOK_COMMAND, | |
50 AT_MODE_OFFHOOK_COMMAND, | |
51 AT_MODE_CONNECTED, | |
52 AT_MODE_DELIVERY, | |
53 AT_MODE_HDLC, | |
54 AT_MODE_STUFFED | |
55 }; | |
56 | |
57 enum at_call_event_e | |
58 { | |
59 AT_CALL_EVENT_ALERTING = 1, | |
60 AT_CALL_EVENT_CONNECTED, | |
61 AT_CALL_EVENT_ANSWERED, | |
62 AT_CALL_EVENT_BUSY, | |
63 AT_CALL_EVENT_NO_DIALTONE, | |
64 AT_CALL_EVENT_NO_ANSWER, | |
65 AT_CALL_EVENT_HANGUP | |
66 }; | |
67 | |
68 enum at_modem_control_operation_e | |
69 { | |
70 AT_MODEM_CONTROL_CALL, | |
71 AT_MODEM_CONTROL_ANSWER, | |
72 AT_MODEM_CONTROL_HANGUP, | |
73 AT_MODEM_CONTROL_OFFHOOK, | |
74 AT_MODEM_CONTROL_ONHOOK, | |
75 AT_MODEM_CONTROL_DTR, | |
76 AT_MODEM_CONTROL_RTS, | |
77 AT_MODEM_CONTROL_CTS, | |
78 AT_MODEM_CONTROL_CAR, | |
79 AT_MODEM_CONTROL_RNG, | |
80 AT_MODEM_CONTROL_DSR, | |
81 AT_MODEM_CONTROL_SETID, | |
82 /* The remainder of the control functions should not get past the modem, to the | |
83 application. */ | |
84 AT_MODEM_CONTROL_RESTART, | |
85 AT_MODEM_CONTROL_DTE_TIMEOUT | |
86 }; | |
87 | |
88 enum | |
89 { | |
90 AT_RESPONSE_CODE_OK = 0, | |
91 AT_RESPONSE_CODE_CONNECT, | |
92 AT_RESPONSE_CODE_RING, | |
93 AT_RESPONSE_CODE_NO_CARRIER, | |
94 AT_RESPONSE_CODE_ERROR, | |
95 AT_RESPONSE_CODE_XXX, | |
96 AT_RESPONSE_CODE_NO_DIALTONE, | |
97 AT_RESPONSE_CODE_BUSY, | |
98 AT_RESPONSE_CODE_NO_ANSWER, | |
99 AT_RESPONSE_CODE_FCERROR, | |
100 AT_RESPONSE_CODE_FRH3 | |
101 }; | |
102 | |
103 /*! | |
104 AT profile. | |
105 */ | |
106 typedef struct | |
107 { | |
108 /*! TRUE if character echo is enabled */ | |
109 int echo; | |
110 /*! TRUE if verbose reporting is enabled */ | |
111 int verbose; | |
112 /*! TRUE if result codes are verbose */ | |
113 int result_code_format; | |
114 /*! TRUE if pulse dialling is the default */ | |
115 int pulse_dial; | |
116 /*! ??? */ | |
117 int double_escape; | |
118 /*! ??? */ | |
119 int adaptive_receive; | |
120 /*! The state of all possible S registers */ | |
121 uint8_t s_regs[100]; | |
122 } at_profile_t; | |
123 | |
124 /*! | |
125 AT descriptor. This defines the working state for a single instance of | |
126 the AT interpreter. | |
127 */ | |
128 struct at_state_s | |
129 { | |
130 at_profile_t p; | |
131 /*! Value set by +GCI */ | |
132 int country_of_installation; | |
133 /*! Value set by +FIT */ | |
134 int dte_inactivity_timeout; | |
135 /*! Value set by +FIT */ | |
136 int dte_inactivity_action; | |
137 /*! Value set by L */ | |
138 int speaker_volume; | |
139 /*! Value set by M */ | |
140 int speaker_mode; | |
141 /*! This is no real DTE rate. This variable is for compatibility this serially | |
142 connected modems. */ | |
143 /*! Value set by +IPR/+FPR */ | |
144 int dte_rate; | |
145 /*! Value set by +ICF */ | |
146 int dte_char_format; | |
147 /*! Value set by +ICF */ | |
148 int dte_parity; | |
149 /*! Value set by &C */ | |
150 int rlsd_behaviour; | |
151 /*! Value set by &D */ | |
152 int dtr_behaviour; | |
153 /*! Value set by +FCL */ | |
154 int carrier_loss_timeout; | |
155 /*! Value set by X */ | |
156 int result_code_mode; | |
157 /*! Value set by +IDSR */ | |
158 int dsr_option; | |
159 /*! Value set by +ILSD */ | |
160 int long_space_disconnect_option; | |
161 /*! Value set by +ICLOK */ | |
162 int sync_tx_clock_source; | |
163 /*! Value set by +EWIND */ | |
164 int rx_window; | |
165 /*! Value set by +EWIND */ | |
166 int tx_window; | |
167 | |
168 int v8bis_signal; | |
169 int v8bis_1st_message; | |
170 int v8bis_2nd_message; | |
171 int v8bis_sig_en; | |
172 int v8bis_msg_en; | |
173 int v8bis_supp_delay; | |
174 | |
175 uint8_t rx_data[256]; | |
176 int rx_data_bytes; | |
177 | |
178 int display_call_info; | |
179 int call_info_displayed; | |
180 char *call_date; | |
181 char *call_time; | |
182 char *originating_name; | |
183 char *originating_number; | |
184 char *originating_ani; | |
185 char *destination_number; | |
186 char *local_id; | |
187 /*! The currently select FAX modem class. 0 = data modem mode. */ | |
188 int fclass_mode; | |
189 int at_rx_mode; | |
190 int rings_indicated; | |
191 int do_hangup; | |
192 int silent_dial; | |
193 int ok_is_pending; | |
194 int dte_is_waiting; | |
195 /*! \brief TRUE if a carrier is presnt. Otherwise FALSE. */ | |
196 int rx_signal_present; | |
197 /*! \brief TRUE if a modem has trained, Otherwise FALSE. */ | |
198 int rx_trained; | |
199 int transmit; | |
200 | |
201 char line[256]; | |
202 int line_ptr; | |
203 | |
204 at_modem_control_handler_t *modem_control_handler; | |
205 void *modem_control_user_data; | |
206 at_tx_handler_t *at_tx_handler; | |
207 void *at_tx_user_data; | |
208 at_class1_handler_t *class1_handler; | |
209 void *class1_user_data; | |
210 | |
211 /*! \brief Error and flow logging control */ | |
212 logging_state_t logging; | |
213 }; | |
214 | |
215 #ifdef __cplusplus | |
216 extern "C" { | |
217 #endif | |
218 | |
219 void at_set_at_rx_mode(at_state_t *s, int new_mode); | |
220 | |
221 void at_put_response(at_state_t *s, const char *t); | |
222 | |
223 void at_put_numeric_response(at_state_t *s, int val); | |
224 | |
225 void at_put_response_code(at_state_t *s, int code); | |
226 | |
227 void at_reset_call_info(at_state_t *s); | |
228 | |
229 /*! Set the call information for an AT interpreter. | |
230 \brief Set the call information for an AT interpreter. | |
231 \param s The AT interpreter context. | |
232 \param call_date . | |
233 \param call_time . | |
234 \param originating_name . | |
235 \param originating_number . | |
236 \param originating_ani . | |
237 \param destination_number . */ | |
238 void at_set_call_info(at_state_t *s, | |
239 char const *call_date, | |
240 char const *call_time, | |
241 char const *originating_name, | |
242 char const *originating_number, | |
243 char const *originating_ani, | |
244 char const *destination_number); | |
245 | |
246 void at_display_call_info(at_state_t *s); | |
247 | |
248 int at_modem_control(at_state_t *s, int op, const char *num); | |
249 | |
250 void at_call_event(at_state_t *s, int event); | |
251 | |
252 void at_interpreter(at_state_t *s, const char *cmd, int len); | |
253 | |
254 void at_set_class1_handler(at_state_t *s, at_class1_handler_t handler, void *user_data); | |
255 | |
256 at_state_t *at_init(at_state_t *s, | |
257 at_tx_handler_t *at_tx_handler, | |
258 void *at_tx_user_data, | |
259 at_modem_control_handler_t *modem_control_handler, | |
260 void *modem_control_user_data); | |
261 | |
262 #ifdef __cplusplus | |
263 } | |
264 #endif | |
265 | |
266 #endif | |
267 /*- End of file ------------------------------------------------------------*/ |