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 00026 /*! \file */ 00027 00028 #if !defined(_SPANDSP_AT_INTERPRETER_H_) 00029 #define _SPANDSP_AT_INTERPRETER_H_ 00030 00031 /*! \page at_page AT command interpreter 00032 \section at_page_sec_1 What does it do? 00033 The AT interpreter module implements V.251, V.252, V.253, T.31 and various 3GPP 00034 modem control commands. 00035 00036 \section at_page_sec_2 How does it work? 00037 */ 00038 00039 typedef struct at_state_s at_state_t; 00040 00041 typedef int (at_modem_control_handler_t)(at_state_t *s, void *user_data, int op, const char *num); 00042 typedef int (at_tx_handler_t)(at_state_t *s, void *user_data, const uint8_t *buf, size_t len); 00043 typedef int (at_class1_handler_t)(at_state_t *s, void *user_data, int direction, int operation, int val); 00044 00045 enum at_rx_mode_e 00046 { 00047 AT_MODE_ONHOOK_COMMAND, 00048 AT_MODE_OFFHOOK_COMMAND, 00049 AT_MODE_CONNECTED, 00050 AT_MODE_DELIVERY, 00051 AT_MODE_HDLC, 00052 AT_MODE_STUFFED 00053 }; 00054 00055 enum at_call_event_e 00056 { 00057 AT_CALL_EVENT_ALERTING = 1, 00058 AT_CALL_EVENT_CONNECTED, 00059 AT_CALL_EVENT_ANSWERED, 00060 AT_CALL_EVENT_BUSY, 00061 AT_CALL_EVENT_NO_DIALTONE, 00062 AT_CALL_EVENT_NO_ANSWER, 00063 AT_CALL_EVENT_HANGUP 00064 }; 00065 00066 enum at_modem_control_operation_e 00067 { 00068 /*! Start an outgoing call. */ 00069 AT_MODEM_CONTROL_CALL, 00070 /*! Answer an incoming call. */ 00071 AT_MODEM_CONTROL_ANSWER, 00072 /*! Hangup a call. */ 00073 AT_MODEM_CONTROL_HANGUP, 00074 /*! Take the line off hook. */ 00075 AT_MODEM_CONTROL_OFFHOOK, 00076 /*! Put the line on hook. */ 00077 AT_MODEM_CONTROL_ONHOOK, 00078 /*! Control V.24 Circuit 108, "data terminal ready". */ 00079 AT_MODEM_CONTROL_DTR, 00080 /*! Control V.24 Circuit 105, "request to send". */ 00081 AT_MODEM_CONTROL_RTS, 00082 /*! Control V.24 Circuit 106, "clear to send". */ 00083 AT_MODEM_CONTROL_CTS, 00084 /*! Control V.24 Circuit 109, "receive line signal detector" (i.e. carrier detect). */ 00085 AT_MODEM_CONTROL_CAR, 00086 /*! Control V.24 Circuit 125, "ring indicator". */ 00087 AT_MODEM_CONTROL_RNG, 00088 /*! Control V.24 Circuit 107, "data set ready". */ 00089 AT_MODEM_CONTROL_DSR, 00090 /*! Set the caller ID for outgoing calls. */ 00091 AT_MODEM_CONTROL_SETID, 00092 /* The remainder of the control functions should not get past the modem, to the 00093 application. */ 00094 AT_MODEM_CONTROL_RESTART, 00095 AT_MODEM_CONTROL_DTE_TIMEOUT 00096 }; 00097 00098 enum 00099 { 00100 AT_RESPONSE_CODE_OK = 0, 00101 AT_RESPONSE_CODE_CONNECT, 00102 AT_RESPONSE_CODE_RING, 00103 AT_RESPONSE_CODE_NO_CARRIER, 00104 AT_RESPONSE_CODE_ERROR, 00105 AT_RESPONSE_CODE_XXX, 00106 AT_RESPONSE_CODE_NO_DIALTONE, 00107 AT_RESPONSE_CODE_BUSY, 00108 AT_RESPONSE_CODE_NO_ANSWER, 00109 AT_RESPONSE_CODE_FCERROR, 00110 AT_RESPONSE_CODE_FRH3 00111 }; 00112 00113 /*! 00114 AT profile. 00115 */ 00116 typedef struct 00117 { 00118 /*! TRUE if character echo is enabled */ 00119 int echo; 00120 /*! TRUE if verbose reporting is enabled */ 00121 int verbose; 00122 /*! TRUE if result codes are verbose */ 00123 int result_code_format; 00124 /*! TRUE if pulse dialling is the default */ 00125 int pulse_dial; 00126 /*! ??? */ 00127 int double_escape; 00128 /*! ??? */ 00129 int adaptive_receive; 00130 /*! The state of all possible S registers */ 00131 uint8_t s_regs[100]; 00132 } at_profile_t; 00133 00134 #if defined(__cplusplus) 00135 extern "C" 00136 { 00137 #endif 00138 00139 SPAN_DECLARE(void) at_set_at_rx_mode(at_state_t *s, int new_mode); 00140 00141 SPAN_DECLARE(void) at_put_response(at_state_t *s, const char *t); 00142 00143 SPAN_DECLARE(void) at_put_numeric_response(at_state_t *s, int val); 00144 00145 SPAN_DECLARE(void) at_put_response_code(at_state_t *s, int code); 00146 00147 SPAN_DECLARE(void) at_reset_call_info(at_state_t *s); 00148 00149 /*! Set the call information for an AT interpreter. 00150 \brief Set the call information for an AT interpreter. 00151 \param s The AT interpreter context. 00152 \param id . 00153 \param value . */ 00154 SPAN_DECLARE(void) at_set_call_info(at_state_t *s, char const *id, char const *value); 00155 00156 SPAN_DECLARE(void) at_display_call_info(at_state_t *s); 00157 00158 SPAN_DECLARE(int) at_modem_control(at_state_t *s, int op, const char *num); 00159 00160 SPAN_DECLARE(void) at_call_event(at_state_t *s, int event); 00161 00162 SPAN_DECLARE(void) at_interpreter(at_state_t *s, const char *cmd, int len); 00163 00164 SPAN_DECLARE(void) at_set_class1_handler(at_state_t *s, at_class1_handler_t handler, void *user_data); 00165 00166 /*! Initialise an AT interpreter context. 00167 \brief Initialise an AT interpreter context. 00168 \param s The AT context. 00169 \param at_tx_handler x. 00170 \param at_tx_user_data x. 00171 \param modem_control_handler x. 00172 \param modem_control_user_data x. 00173 \return A pointer to the AT context, or NULL if there was a problem. */ 00174 SPAN_DECLARE(at_state_t *) at_init(at_state_t *s, 00175 at_tx_handler_t *at_tx_handler, 00176 void *at_tx_user_data, 00177 at_modem_control_handler_t *modem_control_handler, 00178 void *modem_control_user_data); 00179 00180 /*! Release an AT interpreter context. 00181 \brief Release an AT interpreter context. 00182 \param s The AT context. 00183 \return 0 for OK */ 00184 SPAN_DECLARE(int) at_release(at_state_t *s); 00185 00186 /*! Free an AT interpreter context. 00187 \brief Free an AT interpreter context. 00188 \param s The AT context. 00189 \return 0 for OK */ 00190 SPAN_DECLARE(int) at_free(at_state_t *s); 00191 00192 #if defined(__cplusplus) 00193 } 00194 #endif 00195 00196 #endif 00197 /*- End of file ------------------------------------------------------------*/