at_interpreter.h

Go to the documentation of this file.
00001 /*
00002  * SpanDSP - a series of DSP components for telephony
00003  *
00004  * at_interpreter.h - AT command interpreter to V.251, V.252, V.253, T.31 and the 3GPP specs.
00005  *
00006  * Written by Steve Underwood <steveu@coppice.org>
00007  *
00008  * Copyright (C) 2004, 2005, 2006 Steve Underwood
00009  *
00010  * All rights reserved.
00011  *
00012  * This program is free software; you can redistribute it and/or modify
00013  * it under the terms of the GNU General Public License version 2, as
00014  * published by the Free Software Foundation.
00015  *
00016  * This program is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License
00022  * along with this program; if not, write to the Free Software
00023  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00024  *
00025  * $Id: at_interpreter.h,v 1.14 2007/05/15 13:22:43 steveu Exp $
00026  */
00027 
00028 /*! \file */
00029 
00030 #if !defined(_SPANDSP_AT_INTERPRETER_H_)
00031 #define _SPANDSP_AT_INTERPRETER_H_
00032 
00033 /*! \page at_page AT command interpreter
00034 \section at_page_sec_1 What does it do?
00035 The AT interpreter module implements V.251, V.252, V.253, T.31 and various 3GPP
00036 modem control commands.
00037 
00038 \section at_page_sec_2 How does it work?
00039 */
00040 
00041 typedef struct at_state_s at_state_t;
00042 
00043 typedef int (at_modem_control_handler_t)(at_state_t *s, void *user_data, int op, const char *num);
00044 typedef int (at_tx_handler_t)(at_state_t *s, void *user_data, const uint8_t *buf, size_t len);
00045 typedef int (at_class1_handler_t)(at_state_t *s, void *user_data, int direction, int operation, int val);
00046 
00047 enum at_rx_mode_e
00048 {
00049     AT_MODE_ONHOOK_COMMAND,
00050     AT_MODE_OFFHOOK_COMMAND,
00051     AT_MODE_CONNECTED,
00052     AT_MODE_DELIVERY,
00053     AT_MODE_HDLC,
00054     AT_MODE_STUFFED
00055 };
00056 
00057 enum at_call_event_e
00058 {
00059     AT_CALL_EVENT_ALERTING = 1,
00060     AT_CALL_EVENT_CONNECTED,
00061     AT_CALL_EVENT_ANSWERED,
00062     AT_CALL_EVENT_BUSY,
00063     AT_CALL_EVENT_NO_DIALTONE,
00064     AT_CALL_EVENT_NO_ANSWER,
00065     AT_CALL_EVENT_HANGUP
00066 };
00067 
00068 enum at_modem_control_operation_e
00069 {
00070     AT_MODEM_CONTROL_CALL,
00071     AT_MODEM_CONTROL_ANSWER,
00072     AT_MODEM_CONTROL_HANGUP,
00073     AT_MODEM_CONTROL_OFFHOOK,
00074     AT_MODEM_CONTROL_ONHOOK,
00075     AT_MODEM_CONTROL_DTR,
00076     AT_MODEM_CONTROL_RTS,
00077     AT_MODEM_CONTROL_CTS,
00078     AT_MODEM_CONTROL_CAR,
00079     AT_MODEM_CONTROL_RNG,
00080     AT_MODEM_CONTROL_DSR,
00081     AT_MODEM_CONTROL_SETID,
00082     /* The remainder of the control functions should not get past the modem, to the
00083        application. */
00084     AT_MODEM_CONTROL_RESTART,
00085     AT_MODEM_CONTROL_DTE_TIMEOUT
00086 };
00087 
00088 enum
00089 {
00090     AT_RESPONSE_CODE_OK = 0,
00091     AT_RESPONSE_CODE_CONNECT,
00092     AT_RESPONSE_CODE_RING,
00093     AT_RESPONSE_CODE_NO_CARRIER,
00094     AT_RESPONSE_CODE_ERROR,
00095     AT_RESPONSE_CODE_XXX,
00096     AT_RESPONSE_CODE_NO_DIALTONE,
00097     AT_RESPONSE_CODE_BUSY,
00098     AT_RESPONSE_CODE_NO_ANSWER,
00099     AT_RESPONSE_CODE_FCERROR,
00100     AT_RESPONSE_CODE_FRH3
00101 };
00102 
00103 struct at_call_id
00104 {
00105     char *id;
00106     char *value;
00107     struct at_call_id *next;
00108 };
00109 
00110 /*!
00111     AT profile.
00112 */
00113 typedef struct
00114 {
00115     /*! TRUE if character echo is enabled */
00116     int echo;
00117     /*! TRUE if verbose reporting is enabled */
00118     int verbose;
00119     /*! TRUE if result codes are verbose */
00120     int result_code_format;
00121     /*! TRUE if pulse dialling is the default */
00122     int pulse_dial;
00123     /*! ??? */
00124     int double_escape;
00125     /*! ??? */
00126     int adaptive_receive;
00127     /*! The state of all possible S registers */
00128     uint8_t s_regs[100];
00129 } at_profile_t;
00130 
00131 /*!
00132     AT descriptor. This defines the working state for a single instance of
00133     the AT interpreter.
00134 */
00135 struct at_state_s
00136 {
00137     at_profile_t p;
00138     /*! Value set by +GCI */
00139     int country_of_installation;
00140     /*! Value set by +FIT */
00141     int dte_inactivity_timeout;
00142     /*! Value set by +FIT */
00143     int dte_inactivity_action;
00144     /*! Value set by L */
00145     int speaker_volume;
00146     /*! Value set by M */
00147     int speaker_mode;
00148     /*! This is no real DTE rate. This variable is for compatibility this serially
00149         connected modems. */
00150     /*! Value set by +IPR/+FPR */
00151     int dte_rate;
00152     /*! Value set by +ICF */
00153     int dte_char_format;
00154     /*! Value set by +ICF */
00155     int dte_parity;
00156     /*! Value set by &C */
00157     int rlsd_behaviour;
00158     /*! Value set by &D */
00159     int dtr_behaviour;
00160     /*! Value set by +FCL */
00161     int carrier_loss_timeout;
00162     /*! Value set by X */
00163     int result_code_mode;
00164     /*! Value set by +IDSR */
00165     int dsr_option;
00166     /*! Value set by +ILSD */
00167     int long_space_disconnect_option;
00168     /*! Value set by +ICLOK */
00169     int sync_tx_clock_source;
00170     /*! Value set by +EWIND */
00171     int rx_window;
00172     /*! Value set by +EWIND */
00173     int tx_window;
00174     
00175     int v8bis_signal;
00176     int v8bis_1st_message;
00177     int v8bis_2nd_message;
00178     int v8bis_sig_en;
00179     int v8bis_msg_en;
00180     int v8bis_supp_delay;
00181 
00182     uint8_t rx_data[256];
00183     int rx_data_bytes;
00184 
00185     int display_call_info;
00186     int call_info_displayed;
00187     struct at_call_id *call_id;
00188     char *local_id;
00189     /*! The currently select FAX modem class. 0 = data modem mode. */
00190     int fclass_mode;
00191     int at_rx_mode;
00192     int rings_indicated;
00193     int do_hangup;
00194     int silent_dial;
00195     int ok_is_pending;
00196     int dte_is_waiting;
00197     /*! \brief TRUE if a carrier is presnt. Otherwise FALSE. */
00198     int rx_signal_present;
00199     /*! \brief TRUE if a modem has trained, Otherwise FALSE. */
00200     int rx_trained;
00201     int transmit;
00202 
00203     char line[256];
00204     int line_ptr;
00205 
00206     at_modem_control_handler_t *modem_control_handler;
00207     void *modem_control_user_data;
00208     at_tx_handler_t *at_tx_handler;
00209     void *at_tx_user_data;
00210     at_class1_handler_t *class1_handler;
00211     void *class1_user_data;
00212 
00213     /*! \brief Error and flow logging control */
00214     logging_state_t logging;
00215 };
00216 
00217 #if defined(__cplusplus)
00218 extern "C"
00219 {
00220 #endif
00221 
00222 void at_set_at_rx_mode(at_state_t *s, int new_mode);
00223 
00224 void at_put_response(at_state_t *s, const char *t);
00225 
00226 void at_put_numeric_response(at_state_t *s, int val);
00227 
00228 void at_put_response_code(at_state_t *s, int code);
00229 
00230 void at_reset_call_info(at_state_t *s);
00231 
00232 /*! Set the call information for an AT interpreter.
00233     \brief Set the call information for an AT interpreter.
00234     \param s The AT interpreter context.
00235     \param id .
00236     \param value . */
00237 void at_set_call_info(at_state_t *s, char const *id, char const *value);
00238 
00239 void at_display_call_info(at_state_t *s);
00240 
00241 int at_modem_control(at_state_t *s, int op, const char *num);
00242 
00243 void at_call_event(at_state_t *s, int event);
00244 
00245 void at_interpreter(at_state_t *s, const char *cmd, int len);
00246 
00247 void at_set_class1_handler(at_state_t *s, at_class1_handler_t handler, void *user_data);
00248 
00249 at_state_t *at_init(at_state_t *s,
00250                     at_tx_handler_t *at_tx_handler,
00251                     void *at_tx_user_data,
00252                     at_modem_control_handler_t *modem_control_handler,
00253                     void *modem_control_user_data);
00254 
00255 #if defined(__cplusplus)
00256 }
00257 #endif
00258 
00259 #endif
00260 /*- End of file ------------------------------------------------------------*/

Generated on Tue Jul 24 11:29:28 2007 for libspandsp by  doxygen 1.5.2