spandsp 0.0.6
|
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 Lesser General Public License version 2.1, 00014 * as 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 Lesser General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU Lesser General Public 00022 * License 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.23 2009/02/10 13:06:47 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 /*! Start an outgoing call. */ 00071 AT_MODEM_CONTROL_CALL, 00072 /*! Answer an incoming call. */ 00073 AT_MODEM_CONTROL_ANSWER, 00074 /*! Hangup a call. */ 00075 AT_MODEM_CONTROL_HANGUP, 00076 /*! Take the line off hook. */ 00077 AT_MODEM_CONTROL_OFFHOOK, 00078 /*! Put the line on hook. */ 00079 AT_MODEM_CONTROL_ONHOOK, 00080 /*! Control V.24 Circuit 108, "data terminal ready". */ 00081 AT_MODEM_CONTROL_DTR, 00082 /*! Control V.24 Circuit 105, "request to send". */ 00083 AT_MODEM_CONTROL_RTS, 00084 /*! Control V.24 Circuit 106, "clear to send". */ 00085 AT_MODEM_CONTROL_CTS, 00086 /*! Control V.24 Circuit 109, "receive line signal detector" (i.e. carrier detect). */ 00087 AT_MODEM_CONTROL_CAR, 00088 /*! Control V.24 Circuit 125, "ring indicator". */ 00089 AT_MODEM_CONTROL_RNG, 00090 /*! Control V.24 Circuit 107, "data set ready". */ 00091 AT_MODEM_CONTROL_DSR, 00092 /*! Set the caller ID for outgoing calls. */ 00093 AT_MODEM_CONTROL_SETID, 00094 /* The remainder of the control functions should not get past the modem, to the 00095 application. */ 00096 AT_MODEM_CONTROL_RESTART, 00097 AT_MODEM_CONTROL_DTE_TIMEOUT 00098 }; 00099 00100 enum 00101 { 00102 AT_RESPONSE_CODE_OK = 0, 00103 AT_RESPONSE_CODE_CONNECT, 00104 AT_RESPONSE_CODE_RING, 00105 AT_RESPONSE_CODE_NO_CARRIER, 00106 AT_RESPONSE_CODE_ERROR, 00107 AT_RESPONSE_CODE_XXX, 00108 AT_RESPONSE_CODE_NO_DIALTONE, 00109 AT_RESPONSE_CODE_BUSY, 00110 AT_RESPONSE_CODE_NO_ANSWER, 00111 AT_RESPONSE_CODE_FCERROR, 00112 AT_RESPONSE_CODE_FRH3 00113 }; 00114 00115 /*! 00116 AT profile. 00117 */ 00118 typedef struct 00119 { 00120 /*! TRUE if character echo is enabled */ 00121 int echo; 00122 /*! TRUE if verbose reporting is enabled */ 00123 int verbose; 00124 /*! TRUE if result codes are verbose */ 00125 int result_code_format; 00126 /*! TRUE if pulse dialling is the default */ 00127 int pulse_dial; 00128 /*! ??? */ 00129 int double_escape; 00130 /*! ??? */ 00131 int adaptive_receive; 00132 /*! The state of all possible S registers */ 00133 uint8_t s_regs[100]; 00134 } at_profile_t; 00135 00136 #if defined(__cplusplus) 00137 extern "C" 00138 { 00139 #endif 00140 00141 SPAN_DECLARE(void) at_set_at_rx_mode(at_state_t *s, int new_mode); 00142 00143 SPAN_DECLARE(void) at_put_response(at_state_t *s, const char *t); 00144 00145 SPAN_DECLARE(void) at_put_numeric_response(at_state_t *s, int val); 00146 00147 SPAN_DECLARE(void) at_put_response_code(at_state_t *s, int code); 00148 00149 SPAN_DECLARE(void) at_reset_call_info(at_state_t *s); 00150 00151 /*! Set the call information for an AT interpreter. 00152 \brief Set the call information for an AT interpreter. 00153 \param s The AT interpreter context. 00154 \param id . 00155 \param value . */ 00156 SPAN_DECLARE(void) at_set_call_info(at_state_t *s, char const *id, char const *value); 00157 00158 SPAN_DECLARE(void) at_display_call_info(at_state_t *s); 00159 00160 SPAN_DECLARE(int) at_modem_control(at_state_t *s, int op, const char *num); 00161 00162 SPAN_DECLARE(void) at_call_event(at_state_t *s, int event); 00163 00164 SPAN_DECLARE(void) at_interpreter(at_state_t *s, const char *cmd, int len); 00165 00166 SPAN_DECLARE(void) at_set_class1_handler(at_state_t *s, at_class1_handler_t handler, void *user_data); 00167 00168 /*! Initialise an AT interpreter context. 00169 \brief Initialise an AT interpreter context. 00170 \param s The AT context. 00171 \param at_tx_handler x. 00172 \param at_tx_user_data x. 00173 \param modem_control_handler x. 00174 \param modem_control_user_data x. 00175 \return A pointer to the AT context, or NULL if there was a problem. */ 00176 SPAN_DECLARE(at_state_t *) at_init(at_state_t *s, 00177 at_tx_handler_t *at_tx_handler, 00178 void *at_tx_user_data, 00179 at_modem_control_handler_t *modem_control_handler, 00180 void *modem_control_user_data); 00181 00182 /*! Release an AT interpreter context. 00183 \brief Release an AT interpreter context. 00184 \param s The AT context. 00185 \return 0 for OK */ 00186 SPAN_DECLARE(int) at_release(at_state_t *s); 00187 00188 /*! Free an AT interpreter context. 00189 \brief Free an AT interpreter context. 00190 \param s The AT context. 00191 \return 0 for OK */ 00192 SPAN_DECLARE(int) at_free(at_state_t *s); 00193 00194 #if defined(__cplusplus) 00195 } 00196 #endif 00197 00198 #endif 00199 /*- End of file ------------------------------------------------------------*/