spandsp: at_interpreter.h Source File

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?
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
39enum 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
49enum 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
60 enum at_modem_control_operation_e
61{
62 /*! Start an outgoing call. */
63 AT_MODEM_CONTROL_CALL,
64 /*! Answer an incoming call. */
65 AT_MODEM_CONTROL_ANSWER,
66 /*! Hangup a call. */
67 AT_MODEM_CONTROL_HANGUP,
68 /*! Take the line off hook. */
69 AT_MODEM_CONTROL_OFFHOOK,
70 /*! Put the line on hook. */
71 AT_MODEM_CONTROL_ONHOOK,
72 /*! Control V.24 Circuit 108, "data terminal ready". */
73 AT_MODEM_CONTROL_DTR,
74 /*! Control V.24 Circuit 105, "request to send". */
75 AT_MODEM_CONTROL_RTS,
76 /*! Control V.24 Circuit 106, "clear to send". */
77 AT_MODEM_CONTROL_CTS,
78 /*! Control V.24 Circuit 109, "receive line signal detector" (i.e. carrier detect). */
79 AT_MODEM_CONTROL_CAR,
80 /*! Control V.24 Circuit 125, "ring indicator". */
81 AT_MODEM_CONTROL_RNG,
82 /*! Control V.24 Circuit 107, "data set ready". */
83 AT_MODEM_CONTROL_DSR,
84 /*! Set the caller ID for outgoing calls. */
85 AT_MODEM_CONTROL_SETID,
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
92enum
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
107typedef struct at_state_s at_state_t;
108
109typedef int (at_modem_control_handler_t)(at_state_t *s, void *user_data, int op, const char *num);
110typedef int (at_tx_handler_t)(at_state_t *s, void *user_data, const uint8_t *buf, size_t len);
111typedef 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 */
123 int result_code_format;
124 /*! TRUE if pulse dialling is the default */
125 int pulse_dial;
126 /*! ??? */
127 int double_escape;
128 /*! ??? */
129 int adaptive_receive;
130 /*! The state of all possible S registers */
131 uint8_t s_regs[100];
132} at_profile_t;
133
134#if defined(__cplusplus)
135extern "C"
136{
137#endif
138
139SPAN_DECLARE(void) at_set_at_rx_mode(at_state_t *s, int new_mode);
140
141SPAN_DECLARE(void) at_put_response(at_state_t *s, const char *t);
142
143SPAN_DECLARE(void) at_put_numeric_response(at_state_t *s, int val);
144
145SPAN_DECLARE(void) at_put_response_code(at_state_t *s, int code);
146
147SPAN_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 . */
154SPAN_DECLARE(void) at_set_call_info(at_state_t *s, char const *id, char const *value);
155
156SPAN_DECLARE(void) at_display_call_info(at_state_t *s);
157
158SPAN_DECLARE(int) at_modem_control(at_state_t *s, int op, const char *num);
159
160SPAN_DECLARE(void) at_call_event(at_state_t *s, int event);
161
162SPAN_DECLARE(void) at_interpreter(at_state_t *s, const char *cmd, int len);
163
164SPAN_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. */
174SPAN_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 */
184SPAN_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 */
190SPAN_DECLARE(int) at_free(at_state_t *s);
191
192#if defined(__cplusplus)
193}
194#endif
195
196#endif
197/*- End of file ------------------------------------------------------------*/
at_modem_control_operation_e
at_modem_control_operation_e
Definition at_interpreter.h:61
AT_MODEM_CONTROL_RTS
@ AT_MODEM_CONTROL_RTS
Definition at_interpreter.h:75
AT_MODEM_CONTROL_ONHOOK
@ AT_MODEM_CONTROL_ONHOOK
Definition at_interpreter.h:71
AT_MODEM_CONTROL_CTS
@ AT_MODEM_CONTROL_CTS
Definition at_interpreter.h:77
AT_MODEM_CONTROL_DTR
@ AT_MODEM_CONTROL_DTR
Definition at_interpreter.h:73
AT_MODEM_CONTROL_DSR
@ AT_MODEM_CONTROL_DSR
Definition at_interpreter.h:83
AT_MODEM_CONTROL_OFFHOOK
@ AT_MODEM_CONTROL_OFFHOOK
Definition at_interpreter.h:69
AT_MODEM_CONTROL_RNG
@ AT_MODEM_CONTROL_RNG
Definition at_interpreter.h:81
AT_MODEM_CONTROL_CALL
@ AT_MODEM_CONTROL_CALL
Definition at_interpreter.h:63
AT_MODEM_CONTROL_ANSWER
@ AT_MODEM_CONTROL_ANSWER
Definition at_interpreter.h:65
AT_MODEM_CONTROL_CAR
@ AT_MODEM_CONTROL_CAR
Definition at_interpreter.h:79
AT_MODEM_CONTROL_HANGUP
@ AT_MODEM_CONTROL_HANGUP
Definition at_interpreter.h:67
AT_MODEM_CONTROL_SETID
@ AT_MODEM_CONTROL_SETID
Definition at_interpreter.h:85
at_init
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
at_free
int at_free(at_state_t *s)
Free an AT interpreter context.
Definition at_interpreter.c:5539
at_set_call_info
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_release
int at_release(at_state_t *s)
Release an AT interpreter context.
Definition at_interpreter.c:5530
at_profile_t
Definition at_interpreter.h:117
at_profile_t::pulse_dial
int pulse_dial
Definition at_interpreter.h:125
at_profile_t::adaptive_receive
int adaptive_receive
Definition at_interpreter.h:129
at_profile_t::verbose
int verbose
Definition at_interpreter.h:121
at_profile_t::echo
int echo
Definition at_interpreter.h:119
at_profile_t::result_code_format
int result_code_format
Definition at_interpreter.h:123
at_profile_t::double_escape
int double_escape
Definition at_interpreter.h:127
at_state_s
Definition private/at_interpreter.h:45