1 /*
2  * SpanDSP - a series of DSP components for telephony
3  *
4  * at_interpreter_tests.c - Tests for the AT interpreter.
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 General Public License version 2, as
14  * 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 General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * 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 /*! \page at_interpreter_tests_page AT interpreter tests
29 \section at_interpreter_tests_page_sec_1 What does it do?
30 These tests exercise all the commands which should be understood by the AT interpreter.
31 */
32 
33 #if defined(HAVE_CONFIG_H)
34 #include "config.h"
35 #endif
36 
37 #include <stdlib.h>
38 #include <stdio.h>
39 #include <fcntl.h>
40 #include <unistd.h>
41 #include <string.h>
42 #include <assert.h>
43 #include <sndfile.h>
44 
45 #include "spandsp.h"
46 
47 #define DLE 0x10
48 #define ETX 0x03
49 #define SUB 0x1A
50 
51 #define MANUFACTURER            "www.soft-switch.org"
52 
53 struct command_response_s
54 {
55     const char *command;
56     const char *response;
57 };
58 
59 static const struct command_response_s general_test_seq[] =
60 {
61     /* Try the various cases for "AT" */
62     {"atE1\r", "atE1\r\r\nOK\r\n"},
63     {"AtE1\r", "AtE1\r\r\nOK\r\n"},
64     {"aTE1\r", "aTE1\r\r\nOK\r\n"},
65     {"ATE1\r", "ATE1\r\r\nOK\r\n"},
66     {"ATE0\r", "ATE0\r\r\nOK\r\n"},
67 
68     /* Try the various command formats */
69     {"ATS8?\r", "\r\n005\r\n\r\nOK\r\n"},
70     {"ATS8=1\r", "\r\nOK\r\n"},
71     {"ATS8.5?\r", "\r\n0\r\n\r\nOK\r\n"},
72     {"ATS8.5=1\r", "\r\nOK\r\n"},
73     {"ATS8.5?\r", "\r\n1\r\n\r\nOK\r\n"},
74     {"ATS8?\r", "\r\n033\r\n\r\nOK\r\n"},
75     {"AT+FCLASS=1\r", "\r\nOK\r\n"},
76     {"AT+FCLASS?\r", "\r\n1\r\n\r\nOK\r\n"},
77     {"AT+FCLASS=?\r", "\r\n0,1,1.0\r\n\r\nOK\r\n"},
78 
79     /* Try all the commands */
80     {"AT&C\r", "\r\nOK\r\n"},                                       /* V.250 6.2.8 - Circuit 109 (received line signal detector), behaviour */
81     {"AT&D\r", "\r\nOK\r\n"},                                       /* V.250 6.2.9 - Circuit 108 (data terminal ready) behaviour */
82     {"AT&F\r", "\r\nOK\r\n"},                                       /* V.250 6.1.2 - Set to factory-defined configuration */
83     {"ATE0\r", "ATE0\r\r\nOK\r\n"},                                 /* Counteract the effects of the above */
84     {"AT+A8E=?\r", "\r\n+A8E:(0-6),(0-5),(00-FF)\r\n\r\nOK\r\n"},   /* V.251 5.1 - V.8 and V.8bis operation controls */
85     {"AT+A8M\r", "\r\nOK\r\n"},                                     /* V.251 5.2 - Send V.8 menu signals */
86     {"AT+A8T=?\r", "\r\n+A8T:(0-10)\r\n\r\nOK\r\n"},                /* V.251 5.3 - Send V.8bis signal and/or message(s) */
87     {"AT+ASTO=?\r", "\r\n+ASTO:\r\n\r\nOK\r\n"},                    /* V.250 6.3.15 - Store telephone number */
88     {"AT+CAAP=?\r", "\r\n+CAAP:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 7.25 - Automatic answer for eMLPP Service */
89     {"AT+CACM=?\r", "\r\n+CACM:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 8.25 - Accumulated call meter */
90     {"AT+CACSP=?\r", "\r\n+CACSP:\r\n\r\nOK\r\n"},                  /* 3GPP TS 27.007 11.1.7 - Voice Group or Voice Broadcast Call State Attribute Presentation */
91     {"AT+CAEMLPP=?\r", "\r\n+CAEMLPP:\r\n\r\nOK\r\n"},              /* 3GPP TS 27.007 7.22 - eMLPP Priority Registration and Interrogation */
92     {"AT+CAHLD=?\r", "\r\n+CAHLD:\r\n\r\nOK\r\n"},                  /* 3GPP TS 27.007 11.1.3 - Leave an ongoing Voice Group or Voice Broadcast Call */
93     {"AT+CAJOIN=?\r", "\r\n+CAJOIN:\r\n\r\nOK\r\n"},                /* 3GPP TS 27.007 11.1.1 - Accept an incoming Voice Group or Voice Broadcast Call */
94     {"AT+CALA=?\r", "\r\n+CALA:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 8.16 - Alarm */
95     {"AT+CALCC=?\r", "\r\n+CALCC:\r\n\r\nOK\r\n"},                  /* 3GPP TS 27.007 11.1.6 - List current Voice Group and Voice Broadcast Calls */
96     {"AT+CALD=?\r", "\r\n+CALD:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 8.38 - Delete alar m */
97     {"AT+CALM=?\r", "\r\n+CALM:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 8.20 - Alert sound mode */
98     {"AT+CAMM=?\r", "\r\n+CAMM:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 8.26 - Accumulated call meter maximum */
99     {"AT+CANCHEV=?\r", "\r\n+CANCHEV:\r\n\r\nOK\r\n"},              /* 3GPP TS 27.007 11.1.8 - NCH Support Indication */
100     {"AT+CAOC=?\r", "\r\n+CAOC:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 7.16 - Advice of Charge */
101     {"AT+CAPD=?\r", "\r\n+CAPD:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 8.39 - Postpone or dismiss an alarm */
102     {"AT+CAPTT=?\r", "\r\n+CAPTT:\r\n\r\nOK\r\n"},                  /* 3GPP TS 27.007 11.1.4 - Talker Access for Voice Group Call */
103     {"AT+CAREJ=?\r", "\r\n+CAREJ:\r\n\r\nOK\r\n"},                  /* 3GPP TS 27.007 11.1.2 - Reject an incoming Voice Group or Voice Broadcast Call */
104     {"AT+CAULEV=?\r", "\r\n+CAULEV:\r\n\r\nOK\r\n"},                /* 3GPP TS 27.007 11.1.5 - Voice Group Call Uplink Status Presentation */
105     {"AT+CBC=?\r", "\r\n+CBC:\r\n\r\nOK\r\n"},                      /* 3GPP TS 27.007 8.4 - Battery charge */
106     {"AT+CBCS=?\r", "\r\n+CBCS:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 11.3.2 - VBS subscriptions and GId status */
107     {"AT+CBST=?\r", "\r\n+CBST:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 6.7 - Select bearer service type */
108     {"AT+CCFC=?\r", "\r\n+CCFC:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 7.11 - Call forwarding number and conditions */
109     {"AT+CCLK=?\r", "\r\n+CCLK:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 8.15 - Clock */
110     {"AT+CCUG=?\r", "\r\n+CCUG:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 7.10 - Closed user group */
111     {"AT+CCWA=?\r", "\r\n+CCWA:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 7.12 - Call waiting */
112     {"AT+CCWE=?\r", "\r\n+CCWE:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 8.28 - Call Meter maximum event */
113     {"AT+CDIP=?\r", "\r\n+CDIP:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 7.9 - Called line identification presentation */
114     {"AT+CDIS=?\r", "\r\n+CDIS:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 8.8 - Display control */
115     {"AT+CEER=?\r", "\r\n+CEER:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 6.10 - Extended error report */
116     {"AT+CFCS=?\r", "\r\n+CFCS:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 7.24 - Fast call setup conditions */
117     {"AT+CFUN=?\r", "\r\n+CFUN:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 8.2 - Set phone functionality */
118     {"AT+CGACT=?\r", "\r\n+CGACT:\r\n\r\nOK\r\n"},                  /* 3GPP TS 27.007 10.1.10 - PDP context activate or deactivate */
119     {"AT+CGANS=?\r", "\r\n+CGANS:\r\n\r\nOK\r\n"},                  /* 3GPP TS 27.007 10.1.16 - Manual response to a network request for PDP context activation */
120     {"AT+CGATT=?\r", "\r\n+CGATT:\r\n\r\nOK\r\n"},                  /* 3GPP TS 27.007 10.1.9 - PS attach or detach */
121     {"AT+CGAUTO=?\r", "\r\n+CGAUTO:\r\n\r\nOK\r\n"},                /* 3GPP TS 27.007 10.1.15 - Automatic response to a network request for PDP context activation */
122     {"AT+CGCLASS=?\r", "\r\n+CGCLASS:\r\n\r\nOK\r\n"},              /* 3GPP TS 27.007 10.1.17 - GPRS mobile station class (GPRS only) */
123     {"AT+CGCLOSP=?\r", "\r\n+CGCLOSP:\r\n\r\nOK\r\n"},              /* 3GPP TS 27.007 10.1.13 - Configure local octet stream PAD parameters (Obsolete) */
124     {"AT+CGCLPAD=?\r", "\r\n+CGCLPAD:\r\n\r\nOK\r\n"},              /* 3GPP TS 27.007 10.1.12 - Configure local triple-X PAD parameters (GPRS only) (Obsolete) */
125     {"AT+CGCMOD=?\r", "\r\n+CGCMOD:\r\n\r\nOK\r\n"},                /* 3GPP TS 27.007 10.1.11 - PDP Context Modify */
126     {"AT+CGCS=?\r", "\r\n+CGCS:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 11.3.1 - VGCS subscriptions and GId status */
127     {"AT+CGDATA=?\r", "\r\n+CGDATA:\r\n\r\nOK\r\n"},                /* 3GPP TS 27.007 10.1.12 - Enter data state */
128     {"AT+CGDCONT=?\r", "\r\n+CGDCONT:\r\n\r\nOK\r\n"},              /* 3GPP TS 27.007 10.1.1 - Define PDP Context */
129     {"AT+CGDSCONT=?\r", "\r\n+CGDSCONT:\r\n\r\nOK\r\n"},            /* 3GPP TS 27.007 10.1.2 - Define Secondary PDP Context */
130     {"AT+CGEQMIN=?\r", "\r\n+CGEQMIN:\r\n\r\nOK\r\n"},              /* 3GPP TS 27.007 10.1.7 - 3G Quality of Service Profile (Minimum acceptable) */
131     {"AT+CGEQNEG=?\r", "\r\n+CGEQNEG:\r\n\r\nOK\r\n"},              /* 3GPP TS 27.007 10.1.8 - 3G Quality of Service Profile (Negotiated) */
132     {"AT+CGEQREQ=?\r", "\r\n+CGEQREQ:\r\n\r\nOK\r\n"},              /* 3GPP TS 27.007 10.1.6 - 3G Quality of Service Profile (Requested) */
133     {"AT+CGEREP=?\r", "\r\n+CGEREP:\r\n\r\nOK\r\n"},                /* 3GPP TS 27.007 10.1.18 - Packet Domain event reporting */
134     {"AT+CGMI=?\r", "\r\n+CGMI:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 5.1 - Request manufacturer identification */
135     {"AT+CGMM=?\r", "\r\n+CGMM:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 5.2 - Request model identification */
136     {"AT+CGMR=?\r", "\r\n+CGMR:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 5.3 - Request revision identification */
137     {"AT+CGPADDR=?\r", "\r\n+CGPADDR:\r\n\r\nOK\r\n"},              /* 3GPP TS 27.007 10.1.14 - Show PDP address */
138     {"AT+CGQMIN=?\r", "\r\n+CGQMIN:\r\n\r\nOK\r\n"},                /* 3GPP TS 27.007 10.1.5 - Quality of Service Profile (Minimum acceptable) */
139     {"AT+CGQREQ=?\r", "\r\n+CGQREQ:\r\n\r\nOK\r\n"},                /* 3GPP TS 27.007 10.1.4 - Quality of Service Profile (Requested) */
140     {"AT+CGREG=?\r", "\r\n+CGREG:\r\n\r\nOK\r\n"},                  /* 3GPP TS 27.007 10.1.19 - GPRS network registration status */
141     {"AT+CGSMS=?\r", "\r\n+CGSMS:\r\n\r\nOK\r\n"},                  /* 3GPP TS 27.007 10.1.20 - Select service for MO SMS messages */
142     {"AT+CGSN=?\r", "\r\n+CGSN:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 5.4 - Request product serial number identification */
143     {"AT+CGTFT=?\r", "\r\n+CGTFT:\r\n\r\nOK\r\n"},                  /* 3GPP TS 27.007 10.1.3 - Traffic Flow Template */
144     {"AT+CHLD=?\r", "\r\n+CHLD:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 7.13 - Call related supplementary services */
145     {"AT+CHSA=?\r", "\r\n+CHSA:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 6.18 - HSCSD non-transparent asymmetry configuration */
146     {"AT+CHSC=?\r", "\r\n+CHSC:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 6.15 - HSCSD current call parameters */
147     {"AT+CHSD=?\r", "\r\n+CHSD:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 6.12 - HSCSD device parameters */
148     {"AT+CHSN=?\r", "\r\n+CHSN:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 6.14 - HSCSD non-transparent call configuration */
149     {"AT+CHSR=?\r", "\r\n+CHSR:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 6.16 - HSCSD parameters report */
150     {"AT+CHST=?\r", "\r\n+CHST:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 6.13 - HSCSD transparent call configuration */
151     {"AT+CHSU=?\r", "\r\n+CHSU:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 6.17 - HSCSD automatic user initiated upgrading */
152     {"AT+CHUP=?\r", "\r\n+CHUP:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 6.5 - Hangup call */
153     {"AT+CIMI=?\r", "\r\n+CIMI:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 5.6 - Request international mobile subscriber identity */
154     {"AT+CIND=?\r", "\r\n+CIND:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 8.9 - Indicator control */
155     {"AT+CKPD=?\r", "\r\n+CKPD:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 8.7 - Keypad control */
156     {"AT+CLAC=?\r", "\r\n+CLAC:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 8.37 - List all available AT commands */
157     {"AT+CLAE=?\r", "\r\n+CLAE:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 8.31 - Language Event */
158     {"AT+CLAN=?\r", "\r\n+CLAN:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 8.30 - Set Language */
159     {"AT+CLCC=?\r", "\r\n+CLCC:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 7.18 - List current calls */
160     {"AT+CLCK=?\r", "\r\n+CLCK:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 7.4 - Facility lock */
161     {"AT+CLIP=?\r", "\r\n+CLIP:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 7.6 - Calling line identification presentation */
162     {"AT+CLIR=?\r", "\r\n+CLIR:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 7.7 - Calling line identification restriction */
163     {"AT+CLVL=?\r", "\r\n+CLVL:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 8.23 - Loudspeaker volume level */
164     {"AT+CMAR=?\r", "\r\n+CMAR:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 8.36 - Master Reset */
165     {"AT+CMEC=?\r", "\r\n+CMEC:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 8.6 - Mobile Termination control mode */
166     {"AT+CMER=?\r", "\r\n+CMER:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 8.10 - Mobile Termination event reporting */
167     {"AT+CMOD=?\r", "\r\n+CMOD:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 6.4 - Call mode */
168     {"AT+CMUT=?\r", "\r\n+CMUT:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 8.24 - Mute control */
169     {"AT+CMUX=?\r", "\r\n+CMUX:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 5.7 - Multiplexing mode */
170     {"AT+CNUM=?\r", "\r\n+CNUM:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 7.1 - Subscriber number */
171     {"AT+COLP=?\r", "\r\n+COLP:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 7.8 - Connected line identification presentation */
172     {"AT+COPN=?\r", "\r\n+COPN:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 7.21 - Read operator names */
173     {"AT+COPS=?\r", "\r\n+COPS:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 7.3 - PLMN selection */
174     {"AT+COTDI=?\r", "\r\n+COTDI:\r\n\r\nOK\r\n"},                  /* 3GPP TS 27.007 11.1.9 - Originator to Dispatcher Information */
175     {"AT+CPAS=?\r", "\r\n+CPAS:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 8.1 - Phone activity status */
176     {"AT+CPBF=?\r", "\r\n+CPBF:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 8.13 - Find phonebook entries */
177     {"AT+CPBR=?\r", "\r\n+CPBR:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 8.12 - Read phonebook entries */
178     {"AT+CPBS=?\r", "\r\n+CPBS:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 8.11 - Select phonebook memory storage */
179     {"AT+CPBW=?\r", "\r\n+CPBW:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 8.14 - Write phonebook entry */
180     {"AT+CPIN=?\r", "\r\n+CPIN:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 8.3 - Enter PIN */
181     {"AT+CPLS=?\r", "\r\n+CPLS:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 7.20 - Selection of preferred PLMN list */
182     {"AT+CPOL=?\r", "\r\n+CPOL:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 7.19 - Preferred PLMN list */
183     {"AT+CPPS=?\r", "\r\n+CPPS:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 7.23 - eMLPP subscriptions */
184     {"AT+CPROT=?\r", "\r\n+CPROT:\r\n\r\nOK\r\n"},                  /* 3GPP TS 27.007 8.42 - Enter protocol mode */
185     {"AT+CPUC=?\r", "\r\n+CPUC:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 8.27 - Price per unit and currency table */
186     {"AT+CPWC=?\r", "\r\n+CPWC:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 8.29 - Power class */
187     {"AT+CPWD=?\r", "\r\n+CPWD:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 7.5 - Change password */
188     {"AT+CR=?\r", "\r\n+CR:\r\n\r\nOK\r\n"},                        /* 3GPP TS 27.007 6.9 - Service reporting control */
189     {"AT+CRC=?\r", "\r\n+CRC:\r\n\r\nOK\r\n"},                      /* 3GPP TS 27.007 6.11 - Cellular result codes */
190     {"AT+CREG=?\r", "\r\n+CREG:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 7.2 - Network registration */
191     {"AT+CRLP=?\r", "\r\n+CRLP:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 6.8 - Radio link protocol */
192     {"AT+CRMC=?\r", "\r\n+CRMC:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 8.34 - Ring Melody Control */
193     {"AT+CRMP=?\r", "\r\n+CRMP:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 8.35 - Ring Melody Playback */
194     {"AT+CRSL=?\r", "\r\n+CRSL:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 8.21 - Ringer sound level */
195     {"AT+CRSM=?\r", "\r\n+CRSM:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 8.18 - Restricted SIM access */
196     {"AT+CSCC=?\r", "\r\n+CSCC:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 8.19 - Secure control command */
197     {"AT+CSCS=?\r", "\r\n+CSCS:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 5.5 - Select TE character set */
198     {"AT+CSDF=?\r", "\r\n+CSDF:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 6.22 - Settings date format */
199     {"AT+CSGT=?\r", "\r\n+CSGT:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 8.32 - Set Greeting Text */
200     {"AT+CSIL=?\r", "\r\n+CSIL:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 6.23 - Silence Command */
201     {"AT+CSIM=?\r", "\r\n+CSIM:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 8.17 - Generic SIM access */
202     {"AT+CSNS=?\r", "\r\n+CSNS:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 6.19 - Single numbering scheme */
203     {"AT+CSQ=?\r", "\r\n+CSQ:\r\n\r\nOK\r\n"},                      /* 3GPP TS 27.007 8.5 - Signal quality */
204     {"AT+CSSN=?\r", "\r\n+CSSN:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 7.17 - Supplementary service notifications */
205     {"AT+CSTA=?\r", "\r\n+CSTA:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 6.1 - Select type of address */
206     {"AT+CSTF=?\r", "\r\n+CSTF:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 6.24 - Settings time format */
207     {"AT+CSVM=?\r", "\r\n+CSVM:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 8.33 - Set Voice Mail Number */
208     {"AT+CTFR=?\r", "\r\n+CTFR:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 7.14 - Call deflection */
209     {"AT+CTZR=?\r", "\r\n+CTZR:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 8.41 - Time Zone Reporting */
210     {"AT+CTZU=?\r", "\r\n+CTZU:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 8.40 - Automatic Time Zone Update */
211     {"AT+CUSD=?\r", "\r\n+CUSD:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 7.15 - Unstructured supplementary service data */
212     {"AT+CUUS1=?\r", "\r\n+CUUS1:\r\n\r\nOK\r\n"},                  /* 3GPP TS 27.007 7.26 - User to User Signalling Service 1 */
213     {"AT+CV120=?\r", "\r\n+CV120:\r\n\r\nOK\r\n"},                  /* 3GPP TS 27.007 6.21 - V.120 rate adaption protocol */
214     {"AT+CVHU=?\r", "\r\n+CVHU:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 6.20 - Voice Hangup Control */
215     {"AT+CVIB=?\r", "\r\n+CVIB:\r\n\r\nOK\r\n"},                    /* 3GPP TS 27.007 8.22 - Vibrator mode */
216     {"AT+DR=?\r", "\r\n+DR:\r\n\r\nOK\r\n"},                        /* V.250 6.6.2 - Data compression reporting */
217     {"AT+DS=?\r", "\r\n+DS:\r\n\r\nOK\r\n"},                        /* V.250 6.6.1 - Data compression */
218     {"AT+EB=?\r", "\r\n+EB:\r\n\r\nOK\r\n"},                        /* V.250 6.5.2 - Break handling in error control operation */
219     {"AT+EFCS=?\r", "\r\n+EFCS:(0-2)\r\n\r\nOK\r\n"},               /* V.250 6.5.4 - 32-bit frame check sequence */
220     {"AT+EFCS?\r", "\r\n+EFCS:0\r\n\r\nOK\r\n"},
221     {"AT+EFRAM=?\r", "\r\n+EFRAM:(1-65535),(1-65535)\r\n\r\nOK\r\n"},
222                                                                     /* V.250 6.5.8 - Frame length */
223     {"AT+ER=?\r", "\r\n+ER:(0,1)\r\n\r\nOK\r\n"},                   /* V.250 6.5.5 - Error control reporting */
224     {"AT+ES=?\r", "\r\n+ES:(0-7),(0-4),(0-9)\r\n\r\nOK\r\n"},       /* V.250 6.5.1 - Error control selection */
225     {"AT+ES?\r", "\r\n+ES:0,0,0\r\n\r\nOK\r\n"},
226     {"AT+ESA=?\r", "\r\n+ESA:(0-2),(0-1),(0-1),(0-1),(0-2),(0-1),(0-255),(0-255)\r\n\r\nOK\r\n"},
227                                                                     /* V.80 8.2 - Synchronous access mode configuration */
228     {"AT+ESA?\r", "\r\n+ESA:0,0,0,0,0,0,0,0\r\n\r\nOK\r\n"},
229     {"AT+ESR\r", "\r\nOK\r\n"},                                     /* V.250 6.5.3 - Selective repeat */
230     {"AT+ETBM=?\r", "\r\n+ETBM:(0-2),(0-2),(0-30)\r\n\r\nOK\r\n"},  /* T.31 8.5.1 - Adaptive reception control */
231     {"AT+ETBM?\r", "\r\n+ETBM:0,0\r\n\r\nOK\r\n"},
232     {"AT+EWIND=?\r", "\r\n+EWIND:(1-127),(1-127)\r\n\r\nOK\r\n"},   /* V.250 6.5.7 - Window size */
233     {"AT+EWIND?\r", "\r\n+EWIND:0,0\r\n\r\nOK\r\n"},
234     {"AT+F34=?\r",  "\r\n+F34:(0-14),(0-14),(0-2),(0-14),(0-14)\r\n\r\nOK\r\n"},
235                                                                     /* T.31 B.6.1 - Initial V.34 rate controls for FAX */
236     {"AT+F34?\r", "\r\n+F34:0,0,0,0,0\r\n\r\nOK\r\n"},
237     {"AT+FAR=?\r", "\r\n0,1\r\n\r\nOK\r\n"},                        /* T.31 8.5.1 - Adaptive reception control */
238     {"AT+FAR?\r", "\r\n0\r\n\r\nOK\r\n"},
239     {"AT+FCL=?\r", "\r\n(0-255)\r\n\r\nOK\r\n"},                    /* T.31 8.5.2 - Carrier loss timeout */
240     {"AT+FCLASS=?\r", "\r\n0,1,1.0\r\n\r\nOK\r\n"},                 /* T.31 8.2 - Capabilities identification and control */
241     {"AT+FCLASS?\r", "\r\n1\r\n\r\nOK\r\n"},
242     {"AT+FDD=?\r", "\r\n(0,1)\r\n\r\nOK\r\n"},                      /* T.31 8.5.3 - Double escape character replacement */
243     {"AT+FDD?\r", "\r\n0\r\n\r\nOK\r\n"},
244     {"AT+FIT=?\r", "\r\n+FIT:(0-255),(0-1)\r\n\r\nOK\r\n"},         /* T.31 8.5.4 - DTE inactivity timeout */
245     {"AT+FIT?\r", "\r\n+FIT:0,0\r\n\r\nOK\r\n"},
246     {"AT+FLO=?\r", "\r\n+FLO:(0-2)\r\n\r\nOK\r\n"},                 /* T.31 says to implement something similar to +IFC */
247     {"AT+FLO?\r", "\r\n+FLO:2\r\n\r\nOK\r\n"},
248     {"AT+FMI?\r", "\r\n" MANUFACTURER "\r\n\r\nOK\r\n"},            /* T.31 says to duplicate +GMI */
249     {"AT+FMM?\r", "\r\n" PACKAGE "\r\n\r\nOK\r\n"},                 /* T.31 says to duplicate +GMM */
250     {"AT+FMR?\r", "\r\n" VERSION "\r\n\r\nOK\r\n"},                 /* T.31 says to duplicate +GMR */
251     {"AT+FPR=?\r", "\r\n115200\r\n\r\nOK\r\n"},                     /* T.31 says to implement something similar to +IPR */
252     {"AT+FPR?\r", "\r\n0\r\n\r\nOK\r\n"},
253     {"AT+FRH=?\r", "\r\n3\r\n\r\nOK\r\n"},                          /* T.31 8.3.6 - HDLC receive */
254     {"AT+FRH?\r", "\r\n-1\r\n\r\nOK\r\n"},
255     {"AT+FRM=?\r", "\r\n24,48,72,73,74,96,97,98,121,122,145,146\r\n\r\nOK\r\n"}, /* T.31 8.3.4 - Facsimile receive */
256     {"AT+FRM?\r", "\r\n-1\r\n\r\nOK\r\n"},
257     {"AT+FRS=?\r", "\r\n0-255\r\n\r\nOK\r\n"},                      /* T.31 8.3.2 - Receive silence */
258     {"AT+FRS?\r", "\r\n-1\r\n\r\nOK\r\n"},
259     {"AT+FTH=?\r", "\r\n3\r\n\r\nOK\r\n"},                          /* T.31 8.3.5 - HDLC transmit */
260     {"AT+FTH?\r", "\r\n-1\r\n\r\nOK\r\n"},
261     {"AT+FTM=?\r", "\r\n24,48,72,73,74,96,97,98,121,122,145,146\r\n\r\nOK\r\n"}, /* T.31 8.3.3 - Facsimile transmit */
262     {"AT+FTM?\r", "\r\n-1\r\n\r\nOK\r\n"},
263     {"AT+FTS=?\r", "\r\n0-255\r\n\r\nOK\r\n"},                      /* T.31 8.3.1 - Transmit silence */
264     {"AT+FTS?\r", "\r\n-1\r\n\r\nOK\r\n"},
265     {"AT+GCAP\r", "\r\nOK\r\n"},                                    /* V.250 6.1.9 - Request complete capabilities list */
266     {"AT+GCI=?\r", "\r\n+GCI:(00-FF)\r\n\r\nOK\r\n"},               /* V.250 6.1.10 - Country of installation, */
267     {"AT+GCI?\r", "\r\n+GCI:00\r\n\r\nOK\r\n"},
268     {"AT+GMI?\r", "\r\n" MANUFACTURER "\r\n\r\nOK\r\n"},            /* V.250 6.1.4 - Request manufacturer identification */
269     {"AT+GMM?\r", "\r\n" PACKAGE "\r\n\r\nOK\r\n"},                 /* V.250 6.1.5 - Request model identification */
270     {"AT+GMR?\r", "\r\n" VERSION "\r\n\r\nOK\r\n"},                 /* V.250 6.1.6 - Request revision identification */
271     {"AT+GOI\r", "\r\nOK\r\n"},                                     /* V.250 6.1.8 - Request global object identification */
272     {"AT+GSN?\r", "\r\n42\r\n\r\nOK\r\n"},                          /* V.250 6.1.7 - Request product serial number identification */
273     {"AT+IBC=?\r", "\r\n+IBC:(0-2),(0,1),(0,1),(0,1),(0,1),(0,1),(0,1),(0,1),(0,1),(0,1),(0,1),(0.1),(0,1)\r\n\r\nOK\r\n"},
274                                                                     /* V.80 7.9 - Control of in-band control */
275     {"AT+IBC?\r", "\r\n+IBC:0,0,0,0,0,0,0,0,0,0,0,0,0\r\n\r\nOK\r\n"},
276     {"AT+IBM=?\r", "\r\n+IBM:(0-7),(0-255),(0-255)\r\n\r\nOK\r\n"}, /* V.80 7.10 - In-band MARK idle reporting control */
277     {"AT+IBM?\r", "\r\n+IBM:0,0,0\r\n\r\nOK\r\n"},
278     {"AT+ICF?\r", "\r\n+ICF:0,0\r\n\r\nOK\r\n"},                    /* V.250 6.2.11 - DTE-DCE character framing */
279     {"AT+ICLOK?\r", "\r\n+ICLOK:0\r\n\r\nOK\r\n"},                  /* V.250 6.2.14 - Select sync transmit clock source */
280     {"AT+IDSR?\r", "\r\n+IDSR:0\r\n\r\nOK\r\n"},                    /* V.250 6.2.16 - Select data set ready option */
281     {"AT+IFC=?\r", "\r\n+IFC:(0-2),(0-2)\r\n\r\nOK\r\n"},           /* V.250 6.2.12 - DTE-DCE local flow control */
282     {"AT+IFC?\r", "\r\n+IFC:2,2\r\n\r\nOK\r\n"},
283     {"AT+ILRR\r", "\r\nOK\r\n"},                                    /* V.250 6.2.13 - DTE-DCE local rate reporting */
284     {"AT+ILSD=?\r", "\r\n+ILSD:(0,1)\r\n\r\nOK\r\n"},               /* V.250 6.2.15 - Select long space disconnect option */
285     {"AT+ILSD?\r", "\r\n+ILSD:0\r\n\r\nOK\r\n"},
286     {"AT+IPR=?\r", "\r\n+IPR:(115200),(115200)\r\n\r\nOK\r\n"},     /* V.250 6.2.10 - Fixed DTE rate */
287     {"AT+IPR?\r", "\r\n+IPR:0\r\n\r\nOK\r\n"},
288     {"AT+IRTS=?\r", "\r\n+IRTS:(0,1)\r\n\r\nOK\r\n"},               /* V.250 6.2.17 - Select synchronous mode RTS option */
289     {"AT+IRTS?\r", "\r\n+IRTS:0\r\n\r\nOK\r\n"},
290     {"AT+MA\r", "\r\nOK\r\n"},                                      /* V.250 6.4.2 - Modulation automode control */
291     {"AT+MR=?\r", "\r\n+MR:(0,1)\r\n\r\nOK\r\n"},                   /* V.250 6.4.3 - Modulation reporting control */
292     {"AT+MR?\r", "\r\n+MR:0\r\n\r\nOK\r\n"},
293     {"AT+MS\r", "\r\nOK\r\n"},                                      /* V.250 6.4.1 - Modulation selection */
294     {"AT+MSC=?\r", "\r\n+MSC:(0,1)\r\n\r\nOK\r\n"},                 /* V.250 6.4.8 - Seamless rate change enable */
295     {"AT+MSC?\r", "\r\n+MSC:0\r\n\r\nOK\r\n"},
296     {"AT+MV18AM\r", "\r\nOK\r\n"},                                  /* V.250 6.4.6 - V.18 answering message editing */
297     {"AT+MV18P=?\r", "\r\n+MV18P:(2-7)\r\n\r\nOK\r\n"},             /* V.250 6.4.7 - Order of probes */
298     {"AT+MV18P?\r", "\r\n+MV18P:0\r\n\r\nOK\r\n"},
299     {"AT+MV18R=?\r", "\r\n+MV18R:(0,1)\r\n\r\nOK\r\n"},             /* V.250 6.4.5 - V.18 reporting control */
300     {"AT+MV18R?\r", "\r\n+MV18R:0\r\n\r\nOK\r\n"},
301     {"AT+MV18S\r", "\r\nOK\r\n"},                                   /* V.250 6.4.4 - V.18 selection */
302     {"AT+TADR\r", "\r\nOK\r\n"},                                    /* V.250 6.7.2.9 - Local V.54 address */
303     {"AT+TAL=?\r", "\r\n+TAL:(0,1),(0,1)\r\n\r\nOK\r\n"},           /* V.250 6.7.2.15 - Local analogue loop */
304     {"AT+TAL?\r", "\r\n+TAL:0,0\r\n\r\nOK\r\n"},
305     {"AT+TALS=?\r", "\r\n+TALS:(0-3)\r\n\r\nOK\r\n"},               /* V.250 6.7.2.6 - Analogue loop status */
306     {"AT+TALS?\r", "\r\n+TALS:0\r\n\r\nOK\r\n"},
307     {"AT+TDLS=?\r", "\r\n+TDLS:(0-4)\r\n\r\nOK\r\n"},               /* V.250 6.7.2.7 - Local digital loop status */
308     {"AT+TDLS?\r", "\r\n+TDLS:0\r\n\r\nOK\r\n"},
309     {"AT+TE140=?\r", "\r\n+TE140:(0,1)\r\n\r\nOK\r\n"},             /* V.250 6.7.2.1 - Enable ckt 140 */
310     {"AT+TE140?\r", "\r\n+TE140:0\r\n\r\nOK\r\n"},
311     {"AT+TE141=?\r", "\r\n+TE141:(0,1)\r\n\r\nOK\r\n"},             /* V.250 6.7.2.2 - Enable ckt 141 */
312     {"AT+TE141?\r", "\r\n+TE141:0\r\n\r\nOK\r\n"},
313     {"AT+TEPAL=?\r", "\r\n+TEPAL:(0,1)\r\n\r\nOK\r\n"},             /* V.250 6.7.2.5 - Enable front panel analogue loop */
314     {"AT+TEPAL?\r", "\r\n+TEPAL:0\r\n\r\nOK\r\n"},
315     {"AT+TEPDL=?\r", "\r\n+TEPDL:(0,1)\r\n\r\nOK\r\n"},             /* V.250 6.7.2.4 - Enable front panel RDL */
316     {"AT+TEPDL?\r", "\r\n+TEPDL:0\r\n\r\nOK\r\n"},
317     {"AT+TERDL=?\r", "\r\n+TERDL:(0,1)\r\n\r\nOK\r\n"},             /* V.250 6.7.2.3 - Enable RDL from remote */
318     {"AT+TERDL?\r", "\r\n+TERDL:0\r\n\r\nOK\r\n"},
319     {"AT+TLDL=?\r", "\r\n+TLDL:(0,1)\r\n\r\nOK\r\n"},               /* V.250 6.7.2.13 - Local digital loop */
320     {"AT+TLDL?\r", "\r\n+TLDL:0\r\n\r\nOK\r\n"},
321     {"AT+TMODE=?\r", "\r\n+TMODE:(0,1)\r\n\r\nOK\r\n"},             /* V.250 6.7.2.10 - Set V.54 mode */
322     {"AT+TMODE?\r", "\r\n+TMODE:0\r\n\r\nOK\r\n"},
323     {"AT+TNUM\r", "\r\nOK\r\n"},                                    /* V.250 6.7.2.12 - Errored bit and block counts */
324     {"AT+TRDL=?\r", "\r\n+TRDL:(0,1)\r\n\r\nOK\r\n"},               /* V.250 6.7.2.14 - Request remote digital loop */
325     {"AT+TRDL?\r", "\r\n+TRDL:0\r\n\r\nOK\r\n"},
326     {"AT+TRDLS\r", "\r\nOK\r\n"},                                   /* V.250 6.7.2.8 - Remote digital loop status */
327     {"AT+TRES=?\r", "\r\n+TRES:(0-2)\r\n\r\nOK\r\n"},               /* V.250 6.7.2.17 - Self test result */
328     {"AT+TRES?\r", "\r\n+TRES:0\r\n\r\nOK\r\n"},
329     {"AT+TSELF=?\r", "\r\n+TSELF:(0,1)\r\n\r\nOK\r\n"},             /* V.250 6.7.2.16 - Self test */
330     {"AT+TSELF?\r", "\r\n+TSELF:0\r\n\r\nOK\r\n"},
331     {"AT+TTER=?\r", "\r\n+TTER:(0-65535),(0-65535)\r\n\r\nOK\r\n"}, /* V.250 6.7.2.11 - Test error rate */
332     {"AT+TTER?\r", "\r\n+TTER:0,0\r\n\r\nOK\r\n"},
333     {"AT+VBT\r", "\r\nOK\r\n"},                                     /* 3GPP TS 27.007 C.2.2 - Buffer threshold setting */
334     {"AT+VCID=?\r", "\r\n0,1\r\n\r\nOK\r\n"},                       /* 3GPP TS 27.007 C.2.3 - Calling number ID presentation */
335     {"AT+VCID?\r", "\r\n0\r\n\r\nOK\r\n"},
336     {"AT+VDR\r", "\r\nOK\r\n"},                                     /* V.253 10.3.1 - Distinctive ring (ring cadence reporting) */
337     {"AT+VDT\r", "\r\nOK\r\n"},                                     /* V.253 10.3.2 - Control tone cadence reporting */
338     {"AT+VDX\r", "\r\nOK\r\n"},                                     /* V.253 10.5.6 - Speakerphone duplex mode */
339     {"AT+VEM\r", "\r\nOK\r\n"},                                     /* V.253 10.5.7 - Deliver event reports */
340     {"AT+VGM\r", "\r\nOK\r\n"},                                     /* V.253 10.5.2 - Microphone gain */
341     {"AT+VGR\r", "\r\nOK\r\n"},                                     /* V.253 10.2.1 - Receive gain selection */
342     {"AT+VGS\r", "\r\nOK\r\n"},                                     /* V.253 10.5.3 - Speaker gain */
343     {"AT+VGT\r", "\r\nOK\r\n"},                                     /* V.253 10.2.2 - Volume selection */
344     {"AT+VIP\r", "\r\nOK\r\n"},                                     /* V.253 10.1.1 - Initialize voice parameters */
345     {"AT+VIT\r", "\r\nOK\r\n"},                                     /* V.253 10.2.3 - DTE/DCE inactivity timer */
346     {"AT+VLS\r", "\r\nOK\r\n"},                                     /* V.253 10.2.4 - Analogue source/destination selection */
347     {"AT+VPP\r", "\r\nOK\r\n"},                                     /* V.253 10.4.2 - Voice packet protocol */
348     {"AT+VRA\r", "\r\nOK\r\n"},                                     /* V.253 10.2.5 - Ringing tone goes away timer */
349     {"AT+VRID?\r", "\r\n0\r\n\r\nOK\r\n"},                          /* Extension - Find the originating and destination numbers */
350     {"AT+VRL\r", "\r\nOK\r\n"},                                     /* V.253 10.1.2 - Ring local phone */
351     {"AT+VRN\r", "\r\nOK\r\n"},                                     /* V.253 10.2.6 - Ringing tone never appeared timer */
352     {"AT+VRX\r", "\r\nOK\r\n"},                                     /* V.253 10.1.3 - Voice receive state */
353     {"AT+VSD\r", "\r\nOK\r\n"},                                     /* V.253 10.2.7 - Silence detection (QUIET and SILENCE) */
354     {"AT+VSID=12345\r", "\r\nOK\r\n"},                              /* Extension - Set the originating number */
355     {"AT+VSID?\r", "\r\n12345\r\n\r\nOK\r\n"},
356     {"AT+VSM\r", "\r\nOK\r\n"},                                     /* V.253 10.2.8 - Compression method selection */
357     {"AT+VSP\r", "\r\nOK\r\n"},                                     /* V.253 10.5.1 - Voice speakerphone state */
358     {"AT+VTA\r", "\r\nOK\r\n"},                                     /* V.253 10.5.4 - Train acoustic echo-canceller */
359     {"AT+VTD\r", "\r\nOK\r\n"},                                     /* V.253 10.2.9 - Beep tone duration timer */
360     {"AT+VTH\r", "\r\nOK\r\n"},                                     /* V.253 10.5.5 - Train line echo-canceller */
361     {"AT+VTR\r", "\r\nOK\r\n"},                                     /* V.253 10.1.4 - Voice duplex state */
362     {"AT+VTS\r", "\r\nOK\r\n"},                                     /* V.253 10.1.5 - DTMF and tone generation in voice */
363     {"AT+VTX\r", "\r\nOK\r\n"},                                     /* V.253 10.1.6 - Transmit data state */
364     {"AT+WS46\r", "\r\nOK\r\n"},                                    /* 3GPP TS 27.007 5.9 - PCCA STD-101 [17] select wireless network */
365     {"ATA\r", "\r\nERROR\r\n"},                                     /* V.250 6.3.5 - Answer */
366     {"ATDT -1234567890ABCDPSTW*#+,!@\r;", ""},                      /* V.250 6.3.1 - Dial */
367     {"ATE1\r", "\r\nOK\r\n"},                                       /* V.250 6.2.4 - Command echo */
368     {"ATE0\r", "ATE0\r\r\nOK\r\n"},                                 /* V.250 6.2.4 - Command echo */
369     {"ATH\r", "\r\nOK\r\n"},                                        /* V.250 6.3.6 - Hook control */
370     {"ATI\r", "\r\n" PACKAGE "\r\n\r\nOK\r\n"},                     /* V.250 6.1.3 - Request identification information */
371     {"ATL\r", "\r\nOK\r\n"},                                        /* V.250 6.3.13 - Monitor speaker loudness */
372     {"ATM\r", "\r\nOK\r\n"},                                        /* V.250 6.3.14 - Monitor speaker mode */
373     {"ATO\r", "\r\nCONNECT\r\n\r\nOK\r\n"},                         /* V.250 6.3.7 - Return to online data state */
374     {"ATP\r", "\r\nOK\r\n"},                                        /* V.250 6.3.3 - Select pulse dialling (command) */
375     {"ATQ\r", "\r\nOK\r\n"},                                        /* V.250 6.2.5 - Result code suppression */
376     {"ATS0=?\r", "\r\n000\r\n\r\nOK\r\n"},                          /* V.250 6.3.8 - Automatic answer */
377     {"ATS0?\r", "\r\n000\r\n\r\nOK\r\n"},
378     {"ATS10=?\r", "\r\n000\r\n\r\nOK\r\n"},                         /* V.250 6.3.12 - Automatic disconnect delay */
379     {"ATS10?\r", "\r\n000\r\n\r\nOK\r\n"},
380     {"ATS3=?\r", "\r\n000\r\n\r\nOK\r\n"},                          /* V.250 6.2.1 - Command line termination character */
381     {"ATS3?\r", "\r\n013\r\n\r\nOK\r\n"},
382     {"ATS4=?\r", "\r\n000\r\n\r\nOK\r\n"},                          /* V.250 6.2.2 - Response formatting character */
383     {"ATS4?\r", "\r\n010\r\n\r\nOK\r\n"},
384     {"ATS5=?\r", "\r\n000\r\n\r\nOK\r\n"},                          /* V.250 6.2.3 - Command line editing character */
385     {"ATS5?\r", "\r\n008\r\n\r\nOK\r\n"},
386     {"ATS6=?\r", "\r\n000\r\n\r\nOK\r\n"},                          /* V.250 6.3.9 - Pause before blind dialling */
387     {"ATS6?\r", "\r\n001\r\n\r\nOK\r\n"},
388     {"ATS7=?\r", "\r\n000\r\n\r\nOK\r\n"},                          /* V.250 6.3.10 - Connection completion timeout */
389     {"ATS7?\r", "\r\n060\r\n\r\nOK\r\n"},
390     {"ATS8=?\r", "\r\n000\r\n\r\nOK\r\n"},                          /* V.250 6.3.11 - Comma dial modifier time */
391     {"ATS8?\r", "\r\n005\r\n\r\nOK\r\n"},
392     {"ATT\r", "\r\nOK\r\n"},                                        /* V.250 6.3.2 - Select tone dialling (command) */
393     {"ATV0\r", "0\r"},                                              /* V.250 6.2.6 - DCE response format */
394     {"ATV1\r", "\r\nOK\r\n"},
395     {"ATX4\r", "\r\nOK\r\n"},                                       /* V.250 6.2.7 - Result code selection and call progress monitoring control */
396     {"ATZ\r", "\r\nOK\r\n"},                                        /* V.250 6.1.1 - Reset to default configuration */
397     {"", ""}
398 };
399 
400 char *decode_test_file = NULL;
401 int countdown = 0;
402 int command_response_test_step = -1;
403 char response_buf[1000];
404 int response_buf_ptr = 0;
405 
at_rx(at_state_t * s,const char * t,int len)406 static int at_rx(at_state_t *s, const char *t, int len)
407 {
408     at_interpreter(s, t, len);
409     return 0;
410 }
411 /*- End of function --------------------------------------------------------*/
412 
at_send(at_state_t * s,const char * t)413 static int at_send(at_state_t *s, const char *t)
414 {
415     printf("%s", t);
416     at_rx(s, t, strlen(t));
417     return 0;
418 }
419 /*- End of function --------------------------------------------------------*/
420 
421 #if 0
422 static int at_send_at(at_state_t *s, const char *t)
423 {
424     uint8_t buf[500];
425 
426     sprintf((char *) buf, "AT%s\r", t);
427     printf("%s", t);
428     at_rx(s, t, strlen(t));
429     return 0;
430 }
431 /*- End of function --------------------------------------------------------*/
432 
433 static int at_expect(at_state_t *s, const char *t)
434 {
435     return 0;
436 }
437 /*- End of function --------------------------------------------------------*/
438 
439 static int at_send_hdlc(at_state_t *s, uint8_t *t, int len)
440 {
441     uint8_t buf[100];
442     int i;
443     int j;
444 
445     for (i = 0, j = 0;  i < len;  i++)
446     {
447         if (*t == DLE)
448             buf[j++] = DLE;
449         buf[j++] = *t++;
450     }
451     buf[j++] = DLE;
452     buf[j++] = ETX;
453     at_rx(s, (char *) buf, j);
454     return 0;
455 }
456 /*- End of function --------------------------------------------------------*/
457 #endif
458 
general_test(at_state_t * s)459 static int general_test(at_state_t *s)
460 {
461     int i;
462 
463     for (i = 0;  general_test_seq[i].command[0];  i++)
464     {
465         response_buf_ptr = 0;
466         response_buf[0] = '\0';
467         command_response_test_step = i;
468         at_send(s, general_test_seq[i].command);
469         if (strcmp(general_test_seq[command_response_test_step].response, response_buf) != 0)
470         {
471             printf("Incorrect response\n");
472             printf("Expected: '%s'\n", general_test_seq[command_response_test_step].response);
473             printf("Received: '%s'\n", response_buf);
474             return -1;
475         }
476     }
477     return 0;
478 }
479 /*- End of function --------------------------------------------------------*/
480 
modem_call_control(void * user_data,int op,const char * num)481 static int modem_call_control(void *user_data, int op, const char *num)
482 {
483     switch (op)
484     {
485     case AT_MODEM_CONTROL_CALL:
486         printf("\nModem control - Dialing '%s'\n", num);
487         break;
488     case AT_MODEM_CONTROL_ANSWER:
489         printf("\nModem control - Answering\n");
490         /* Force an error response, so we get something well defined for the test. */
491         return -1;
492     case AT_MODEM_CONTROL_HANGUP:
493         printf("\nModem control - Hanging up\n");
494         break;
495     case AT_MODEM_CONTROL_OFFHOOK:
496         printf("\nModem control - Going off hook\n");
497         break;
498     case AT_MODEM_CONTROL_ONHOOK:
499         printf("\nModem control - Going on hook\n");
500         break;
501     case AT_MODEM_CONTROL_DTR:
502         printf("\nModem control - DTR %d\n", (int) (intptr_t) num);
503         break;
504     case AT_MODEM_CONTROL_RTS:
505         printf("\nModem control - RTS %d\n", (int) (intptr_t) num);
506         break;
507     case AT_MODEM_CONTROL_CTS:
508         printf("\nModem control - CTS %d\n", (int) (intptr_t) num);
509         break;
510     case AT_MODEM_CONTROL_CAR:
511         printf("\nModem control - CAR %d\n", (int) (intptr_t) num);
512         break;
513     case AT_MODEM_CONTROL_RNG:
514         printf("\nModem control - RNG %d\n", (int) (intptr_t) num);
515         break;
516     case AT_MODEM_CONTROL_DSR:
517         printf("\nModem control - DSR %d\n", (int) (intptr_t) num);
518         break;
519     case AT_MODEM_CONTROL_SETID:
520         printf("\nModem control - Set ID '%s'\n", num);
521         break;
522     case AT_MODEM_CONTROL_RESTART:
523         printf("\nModem control - Restart %d\n", (int) (intptr_t) num);
524         break;
525     case AT_MODEM_CONTROL_DTE_TIMEOUT:
526         printf("\nModem control - Set DTE timeout %d\n", (int) (intptr_t) num);
527         break;
528     default:
529         printf("\nModem control - operation %d\n", op);
530         break;
531     }
532     /*endswitch*/
533     return 0;
534 }
535 /*- End of function --------------------------------------------------------*/
536 
at_tx_handler(void * user_data,const uint8_t * buf,size_t len)537 static int at_tx_handler(void *user_data, const uint8_t *buf, size_t len)
538 {
539     int i;
540 
541     for (i = 0;  i < len;  i++)
542     {
543         response_buf[response_buf_ptr++] = buf[i];
544         putchar(buf[i]);
545     }
546     response_buf[response_buf_ptr] = '\0';
547 
548     return 0;
549 }
550 /*- End of function --------------------------------------------------------*/
551 
main(int argc,char * argv[])552 int main(int argc, char *argv[])
553 {
554     at_state_t *at_state;
555 
556     if ((at_state = at_init(NULL, at_tx_handler, NULL, modem_call_control, NULL)) == NULL)
557     {
558         fprintf(stderr, "Cannot start the AT interpreter\n");
559         exit(2);
560     }
561     if (general_test(at_state))
562     {
563         printf("Tests failed.\n");
564         exit(2);
565     }
566     printf("Tests passed.\n");
567     at_free(at_state);
568     return 0;
569 }
570 /*- End of function --------------------------------------------------------*/
571 /*- End of file ------------------------------------------------------------*/
572