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 enum at_rx_mode_e
40 {
41  AT_MODE_ONHOOK_COMMAND,
42  AT_MODE_OFFHOOK_COMMAND,
43  AT_MODE_CONNECTED,
44  AT_MODE_DELIVERY,
45  AT_MODE_HDLC,
46  AT_MODE_STUFFED
47 };
48 
49 enum at_call_event_e
50 {
51  AT_CALL_EVENT_ALERTING = 1,
52  AT_CALL_EVENT_CONNECTED,
53  AT_CALL_EVENT_ANSWERED,
54  AT_CALL_EVENT_BUSY,
55  AT_CALL_EVENT_NO_DIALTONE,
56  AT_CALL_EVENT_NO_ANSWER,
57  AT_CALL_EVENT_HANGUP
58 };
59 
61 {
62  /*! Start an outgoing call. */
64  /*! Answer an incoming call. */
66  /*! Hangup a call. */
68  /*! Take the line off hook. */
70  /*! Put the line on hook. */
72  /*! Control V.24 Circuit 108, "data terminal ready". */
74  /*! Control V.24 Circuit 105, "request to send". */
76  /*! Control V.24 Circuit 106, "clear to send". */
78  /*! Control V.24 Circuit 109, "receive line signal detector" (i.e. carrier detect). */
80  /*! Control V.24 Circuit 125, "ring indicator". */
82  /*! Control V.24 Circuit 107, "data set ready". */
84  /*! Set the caller ID for outgoing calls. */
86  /* The remainder of the control functions should not get past the modem, to the
87  application. */
88  AT_MODEM_CONTROL_RESTART,
89  AT_MODEM_CONTROL_DTE_TIMEOUT
90 };
91 
92 enum
93 {
94  AT_RESPONSE_CODE_OK = 0,
95  AT_RESPONSE_CODE_CONNECT,
96  AT_RESPONSE_CODE_RING,
97  AT_RESPONSE_CODE_NO_CARRIER,
98  AT_RESPONSE_CODE_ERROR,
99  AT_RESPONSE_CODE_XXX,
100  AT_RESPONSE_CODE_NO_DIALTONE,
101  AT_RESPONSE_CODE_BUSY,
102  AT_RESPONSE_CODE_NO_ANSWER,
103  AT_RESPONSE_CODE_FCERROR,
104  AT_RESPONSE_CODE_FRH3
105 };
106 
107 typedef struct at_state_s at_state_t;
108 
109 typedef int (at_modem_control_handler_t)(at_state_t *s, void *user_data, int op, const char *num);
110 typedef int (at_tx_handler_t)(at_state_t *s, void *user_data, const uint8_t *buf, size_t len);
111 typedef int (at_class1_handler_t)(at_state_t *s, void *user_data, int direction, int operation, int val);
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:83
int adaptive_receive
Definition: at_interpreter.h:129
int at_free(at_state_t *s)
Free an AT interpreter context.
Definition: at_interpreter.c:5539
int verbose
Definition: at_interpreter.h:121
Definition: at_interpreter.h:67
int at_release(at_state_t *s)
Release an AT interpreter context.
Definition: at_interpreter.c:5530
Definition: at_interpreter.h:79
int echo
Definition: at_interpreter.h:119
Definition: at_interpreter.h:73
Definition: at_interpreter.h:69
Definition: at_interpreter.h:77
Definition: at_interpreter.h:75
Definition: at_interpreter.h:63
Definition: at_interpreter.h:81
int pulse_dial
Definition: at_interpreter.h:125
Definition: at_interpreter.h:65
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
Definition: at_interpreter.h:71
Definition: at_interpreter.h:85
int double_escape
Definition: at_interpreter.h:127
at_modem_control_operation_e
Definition: at_interpreter.h:60
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:5503
Definition: private/at_interpreter.h:44
Definition: at_interpreter.h:116