comparison spandsp-0.0.6pre17/src/spandsp/at_interpreter.h @ 4:26cd8f1ef0b1

import spandsp-0.0.6pre17
author Peter Meerwald <pmeerw@cosy.sbg.ac.at>
date Fri, 25 Jun 2010 15:50:58 +0200
parents
children
comparison
equal deleted inserted replaced
3:c6c5a16ce2f2 4:26cd8f1ef0b1
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 * $Id: at_interpreter.h,v 1.23 2009/02/10 13:06:47 steveu Exp $
26 */
27
28 /*! \file */
29
30 #if !defined(_SPANDSP_AT_INTERPRETER_H_)
31 #define _SPANDSP_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 /*! Start an outgoing call. */
71 AT_MODEM_CONTROL_CALL,
72 /*! Answer an incoming call. */
73 AT_MODEM_CONTROL_ANSWER,
74 /*! Hangup a call. */
75 AT_MODEM_CONTROL_HANGUP,
76 /*! Take the line off hook. */
77 AT_MODEM_CONTROL_OFFHOOK,
78 /*! Put the line on hook. */
79 AT_MODEM_CONTROL_ONHOOK,
80 /*! Control V.24 Circuit 108, "data terminal ready". */
81 AT_MODEM_CONTROL_DTR,
82 /*! Control V.24 Circuit 105, "request to send". */
83 AT_MODEM_CONTROL_RTS,
84 /*! Control V.24 Circuit 106, "clear to send". */
85 AT_MODEM_CONTROL_CTS,
86 /*! Control V.24 Circuit 109, "receive line signal detector" (i.e. carrier detect). */
87 AT_MODEM_CONTROL_CAR,
88 /*! Control V.24 Circuit 125, "ring indicator". */
89 AT_MODEM_CONTROL_RNG,
90 /*! Control V.24 Circuit 107, "data set ready". */
91 AT_MODEM_CONTROL_DSR,
92 /*! Set the caller ID for outgoing calls. */
93 AT_MODEM_CONTROL_SETID,
94 /* The remainder of the control functions should not get past the modem, to the
95 application. */
96 AT_MODEM_CONTROL_RESTART,
97 AT_MODEM_CONTROL_DTE_TIMEOUT
98 };
99
100 enum
101 {
102 AT_RESPONSE_CODE_OK = 0,
103 AT_RESPONSE_CODE_CONNECT,
104 AT_RESPONSE_CODE_RING,
105 AT_RESPONSE_CODE_NO_CARRIER,
106 AT_RESPONSE_CODE_ERROR,
107 AT_RESPONSE_CODE_XXX,
108 AT_RESPONSE_CODE_NO_DIALTONE,
109 AT_RESPONSE_CODE_BUSY,
110 AT_RESPONSE_CODE_NO_ANSWER,
111 AT_RESPONSE_CODE_FCERROR,
112 AT_RESPONSE_CODE_FRH3
113 };
114
115 /*!
116 AT profile.
117 */
118 typedef struct
119 {
120 /*! TRUE if character echo is enabled */
121 int echo;
122 /*! TRUE if verbose reporting is enabled */
123 int verbose;
124 /*! TRUE if result codes are verbose */
125 int result_code_format;
126 /*! TRUE if pulse dialling is the default */
127 int pulse_dial;
128 /*! ??? */
129 int double_escape;
130 /*! ??? */
131 int adaptive_receive;
132 /*! The state of all possible S registers */
133 uint8_t s_regs[100];
134 } at_profile_t;
135
136 #if defined(__cplusplus)
137 extern "C"
138 {
139 #endif
140
141 SPAN_DECLARE(void) at_set_at_rx_mode(at_state_t *s, int new_mode);
142
143 SPAN_DECLARE(void) at_put_response(at_state_t *s, const char *t);
144
145 SPAN_DECLARE(void) at_put_numeric_response(at_state_t *s, int val);
146
147 SPAN_DECLARE(void) at_put_response_code(at_state_t *s, int code);
148
149 SPAN_DECLARE(void) at_reset_call_info(at_state_t *s);
150
151 /*! Set the call information for an AT interpreter.
152 \brief Set the call information for an AT interpreter.
153 \param s The AT interpreter context.
154 \param id .
155 \param value . */
156 SPAN_DECLARE(void) at_set_call_info(at_state_t *s, char const *id, char const *value);
157
158 SPAN_DECLARE(void) at_display_call_info(at_state_t *s);
159
160 SPAN_DECLARE(int) at_modem_control(at_state_t *s, int op, const char *num);
161
162 SPAN_DECLARE(void) at_call_event(at_state_t *s, int event);
163
164 SPAN_DECLARE(void) at_interpreter(at_state_t *s, const char *cmd, int len);
165
166 SPAN_DECLARE(void) at_set_class1_handler(at_state_t *s, at_class1_handler_t handler, void *user_data);
167
168 /*! Initialise an AT interpreter context.
169 \brief Initialise an AT interpreter context.
170 \param s The AT context.
171 \param at_tx_handler x.
172 \param at_tx_user_data x.
173 \param modem_control_handler x.
174 \param modem_control_user_data x.
175 \return A pointer to the AT context, or NULL if there was a problem. */
176 SPAN_DECLARE(at_state_t *) at_init(at_state_t *s,
177 at_tx_handler_t *at_tx_handler,
178 void *at_tx_user_data,
179 at_modem_control_handler_t *modem_control_handler,
180 void *modem_control_user_data);
181
182 /*! Release an AT interpreter context.
183 \brief Release an AT interpreter context.
184 \param s The AT context.
185 \return 0 for OK */
186 SPAN_DECLARE(int) at_release(at_state_t *s);
187
188 /*! Free an AT interpreter context.
189 \brief Free an AT interpreter context.
190 \param s The AT context.
191 \return 0 for OK */
192 SPAN_DECLARE(int) at_free(at_state_t *s);
193
194 #if defined(__cplusplus)
195 }
196 #endif
197
198 #endif
199 /*- End of file ------------------------------------------------------------*/

Repositories maintained by Peter Meerwald, pmeerw@pmeerw.net.