spandsp  0.0.6
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?
33 The AT interpreter module implements V.251, V.252, V.253, T.31 and various 3GPP
34 modem control commands.
35 
36 \section at_page_sec_2 How does it work?
37 */
38 
39 typedef struct at_state_s at_state_t;
40 
41 typedef int (at_modem_control_handler_t)(at_state_t *s, void *user_data, int op, const char *num);
42 typedef int (at_tx_handler_t)(at_state_t *s, void *user_data, const uint8_t *buf, size_t len);
43 typedef int (at_class1_handler_t)(at_state_t *s, void *user_data, int direction, int operation, int val);
44 
45 enum 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 
55 enum 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 
98 enum
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 */
116 typedef struct
117 {
118  /*! TRUE if character echo is enabled */
119  int echo;
120  /*! TRUE if verbose reporting is enabled */
121  int verbose;
122  /*! TRUE if result codes are 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];
132 } at_profile_t;
133 
134 #if defined(__cplusplus)
135 extern "C"
136 {
137 #endif
138 
139 SPAN_DECLARE(void) at_set_at_rx_mode(at_state_t *s, int new_mode);
140 
141 SPAN_DECLARE(void) at_put_response(at_state_t *s, const char *t);
142 
143 SPAN_DECLARE(void) at_put_numeric_response(at_state_t *s, int val);
144 
145 SPAN_DECLARE(void) at_put_response_code(at_state_t *s, int code);
146 
147 SPAN_DECLARE(void) at_reset_call_info(at_state_t *s);
148 
149 /*! Set the call information for an AT interpreter.
150  \brief Set the call information for an AT interpreter.
151  \param s The AT interpreter context.
152  \param id .
153  \param value . */
154 SPAN_DECLARE(void) at_set_call_info(at_state_t *s, char const *id, char const *value);
155 
156 SPAN_DECLARE(void) at_display_call_info(at_state_t *s);
157 
158 SPAN_DECLARE(int) at_modem_control(at_state_t *s, int op, const char *num);
159 
160 SPAN_DECLARE(void) at_call_event(at_state_t *s, int event);
161 
162 SPAN_DECLARE(void) at_interpreter(at_state_t *s, const char *cmd, int len);
163 
164 SPAN_DECLARE(void) at_set_class1_handler(at_state_t *s, at_class1_handler_t handler, void *user_data);
165 
166 /*! Initialise an AT interpreter context.
167  \brief Initialise an AT interpreter context.
168  \param s The AT context.
169  \param at_tx_handler x.
170  \param at_tx_user_data x.
171  \param modem_control_handler x.
172  \param modem_control_user_data x.
173  \return A pointer to the AT context, or NULL if there was a problem. */
174 SPAN_DECLARE(at_state_t *) at_init(at_state_t *s,
175  at_tx_handler_t *at_tx_handler,
176  void *at_tx_user_data,
177  at_modem_control_handler_t *modem_control_handler,
178  void *modem_control_user_data);
179 
180 /*! Release an AT interpreter context.
181  \brief Release an AT interpreter context.
182  \param s The AT context.
183  \return 0 for OK */
184 SPAN_DECLARE(int) at_release(at_state_t *s);
185 
186 /*! Free an AT interpreter context.
187  \brief Free an AT interpreter context.
188  \param s The AT context.
189  \return 0 for OK */
190 SPAN_DECLARE(int) at_free(at_state_t *s);
191 
192 #if defined(__cplusplus)
193 }
194 #endif
195 
196 #endif
197 /*- End of file ------------------------------------------------------------*/
int result_code_format
Definition: at_interpreter.h:123
Definition: at_interpreter.h:89
int adaptive_receive
Definition: at_interpreter.h:129
int at_release(at_state_t *s)
Release an AT interpreter context.
Definition: at_interpreter.c:5523
int verbose
Definition: at_interpreter.h:121
Definition: at_interpreter.h:73
Definition: at_interpreter.h:85
int echo
Definition: at_interpreter.h:119
Definition: at_interpreter.h:79
Definition: at_interpreter.h:75
Definition: at_interpreter.h:83
Definition: at_interpreter.h:81
Definition: at_interpreter.h:69
Definition: at_interpreter.h:87
int pulse_dial
Definition: at_interpreter.h:125
Definition: at_interpreter.h:71
Definition: at_interpreter.h:77
Definition: at_interpreter.h:91
int double_escape
Definition: at_interpreter.h:127
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:5496
int at_free(at_state_t *s)
Free an AT interpreter context.
Definition: at_interpreter.c:5532
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:328
at_modem_control_operation_e
Definition: at_interpreter.h:66
Definition: private/at_interpreter.h:44
Definition: at_interpreter.h:116