comparison src/g23m-fad/tcpip/include/atp_cmd.h @ 1:fa8dc04885d8

src/g23m-*: import from Magnetite
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 16 Oct 2020 06:25:50 +0000
parents
children
comparison
equal deleted inserted replaced
0:4e78acac3d88 1:fa8dc04885d8
1 /*******************************************************************************
2 *
3 * File Name : atp_cmd.h
4 *
5 * External definition for commands supported by ATP
6 *
7 * (C) Texas Instruments, all rights reserved
8 *
9 * Version number : 0.1 Date : 7-Marsh-2000
10 *
11 * History : 0.1 - Created by E. Baissus
12 *
13 *
14 * Author : Eric Baissus : e-baissus@ti.com
15 *
16 * (C) Copyright 2000 by Texas Instruments Incorporated, All Rights Reserved
17 ******************************************************************************/
18 #include "rv_general.h"
19 #include "rvf_api.h"
20 #include "atp_config.h"
21 #include "atp_api.h"
22
23 #include <stdlib.h>
24
25 #ifndef ATP_CMD_H
26 #define ATP_CMD_H
27
28 /************************** LOCAL DCE-DTE PORT CONTROL **************************/
29 /* */
30 /* Define the number of word needed to mask the commands executed by the ATP. */
31 #define NB_WORD_OF_DCE_CMD_MASK (0x01)
32
33 /* Define the default command line termination character (See ITU-T */
34 /* Recommendation V.250 ter page 21). */
35 #define ATP_CR_CHARACTER ('\x0D')
36
37 /* Define the default response formatting character (See ITU-T Recommendation */
38 /* V.250 ter page 22). */
39 #define ATP_LF_CHARACTER ('\x0A')
40
41 /* Define the default command line editing character (See ITU-T Recommendation */
42 /* V.250 ter page 22). */
43 #define ATP_BS_CHARACTER ('\x08')
44
45 /* Define the escape sequence (See ITU-T Recommendation V.250 ter page 24). */
46 #define MAX_NB_OF_CHARACTER_FOR_END_SEQUENCE (0x03)
47
48 static const char ATP_ESCAPE_SEQUENCE[] = "+++";
49
50 /* Define the command echo (See ITU-T Recommendation V.250 ter page 23). */
51 typedef enum
52 {
53 ECHO_OFF = 0x00000000,
54 ECHO_ON
55 } T_ATP_ECHO_MODE;
56
57 /* Define the result code suppression (See ITU-T Recommendation V.250 ter page */
58 /* 23). */
59 typedef enum
60 {
61 RESULT_CODE_ON = 0x00000000,
62 RESULT_CODE_OFF
63 } T_ATP_RESULT_CODE_MODE;
64
65 /* Define the DCE response format (See ITU-T Recommendation V.250 ter page 24). */
66 typedef enum
67 {
68 ATP_VERBOSE_0 = 0x00000000,
69 ATP_VERBOSE_1
70 } T_ATP_VERBOSE_MODE;
71
72 /* Define the structure used to store information related to DCE handling. */
73 typedef UINT16 T_ATP_DCE_MASK[NB_WORD_OF_DCE_CMD_MASK];
74
75 typedef struct
76 {
77 char cr_character;
78 char lf_character;
79 char bs_character;
80 char escape_sequence[MAX_NB_OF_CHARACTER_FOR_END_SEQUENCE];
81 T_ATP_ECHO_MODE echo_mode;
82 T_ATP_RESULT_CODE_MODE result_code_mode;
83 T_ATP_VERBOSE_MODE verbose_mode;
84 T_ATP_DCE_MASK dce_mask;
85 UINT8 nb_plus_received; // Number of exit character that have been previously received
86 UINT8 *escape_sequence_tmp_buffer_p[MAX_NB_OF_CHARACTER_FOR_END_SEQUENCE]; // Used as temp buffer by the escape sequence algo
87 UINT8 length_of_escape_sequence_tmp_buffer_p[MAX_NB_OF_CHARACTER_FOR_END_SEQUENCE];
88 } T_ATP_DCE_INFO;
89
90 /********************************** AT COMMANDS *********************************/
91 /* */
92 /* Define all supported AT commands. */
93 /* __________________________________________________________________________ */
94 /* | | | | | */
95 /* | Binary code | Len | Command | Description | */
96 /* |___________________|_____|_________|______________________________________| */
97 /* | | | | | */
98 /* | ATP_ATA_NB | 1 | ATA | Answer. | */
99 /* | ATP_ATD_NB | 1 | ATD | Dial. | */
100 /* | ATP_ATE_NB | 1 | ATE | Command echo. | */
101 /* | ATP_ATH_NB | 1 | ATH | Hook control. | */
102 /* | ATP_ATI_NB | 1 | ATI | Request Identification Information | */
103 /* | ATP_ATL_NB | 1 | ATL | Monitor speaker loudness. | */
104 /* | ATP_ATM_NB | 1 | ATM | Monitor speaker mode. | */
105 /* | ATP_ATO_NB | 1 | ATO | Return to online data state. | */
106 /* | ATP_ATP_NB | 1 | ATP | Select pulse dialling. | */
107 /* | ATP_ATQ_NB | 1 | ATQ | Result code suppression. | */
108 /* | ATP_ATS0_NB | 2 | ATS0 | Automatic answer. | */
109 /* | ATP_ATS10_NB | 3 | ATS10 | Automatic disconnect delay. | */
110 /* | ATP_ATS3_NB | 2 | ATS3 | Command line termination character. | */
111 /* | ATP_ATS4_NB | 2 | ATS4 | Response formatting character. | */
112 /* | ATP_ATS5_NB | 2 | ATS5 | Command line editing character. | */
113 /* | ATP_ATS6_NB | 2 | ATS6 | Pause before blind dialling. | */
114 /* | ATP_ATS7_NB | 2 | ATS7 | Connection completion timeout. | */
115 /* | ATP_ATS8_NB | 2 | ATS8 | Comma dial modifier time. | */
116 /* | ATP_ATT_NB | 1 | ATT | Select tone dialling. | */
117 /* | ATP_ATV_NB | 1 | ATV | DCE response format. | */
118 /* | ATP_ATX_NB | 1 | ATX | Result code selection and call | */
119 /* | | | | progress monitoring control. | */
120 /* | ATP_ATZ_NB | 1 | ATZ | Reset to default configuration. | */
121 /* | ATP_AT_AND_C_NB | 2 | AT&C | Circuit 109 (received line signal | */
122 /* | | | | detector) behavior. | */
123 /* | ATP_AT_AND_D_NB | 2 | AT&D | Circuit 108 (data terminal ready) | */
124 /* | | | | behavior. | */
125 /* | ATP_AT_AND_F_NB | 2 | AT&F | Set to factory defined | */
126 /* | | | | configuration. | */
127 /* |___________________|_____|_________|______________________________________| */
128 /* | | | | | */
129 /* |ATP_AT_PLUS_CKPD_NB| 5 | AT+CKPD | Keypad control command (See GSM TS | */
130 /* | | | | 07.07, Section 8.7). For <keys>, the | */
131 /* | | | | value of 200 indicates the button on | */
132 /* | | | | the headset being pushed. The <time> | */
133 /* | | | | and <pause> parameters have no | */
134 /* | | | | meaning in the headset profile. | */
135 /* |ATP_AT_PLUS_FDR_NB | 4 | AT+FDR | Receive a page. | */
136 /* |ATP_AT_PLUS_FDT_NB | 4 | AT+FDT | Send a page. | */
137 /* |ATP_AT_PLUS_FKS_NB | 4 | AT+FKS | Session termination. | */
138 /* |ATP_AT_PLUS_GMI_NB | 4 | AT+GMI | Request manufacturer identification. | */
139 /* |ATP_AT_PLUS_GMM_NB | 4 | AT+GMM | Request model identification. | */
140 /* |ATP_AT_PLUS_GMR_NB | 4 | AT+GMR | Request revision identification. | */
141 /* |ATP_AT_PLUS_GCAP_NB| 5 | AT+GCAP | Request complete capabilities list. | */
142 /* |ATP_AT_PLUS_VGM_NB | 4 | AT+VGM | Command issued by the HS to report | */
143 /* | | | | the current microphone gain level | */
144 /* | | | | setting to the AG (See Headset | */
145 /* | | | | Specification, Section 4.7.3). | */
146 /* |ATP_AT_PLUS_VGS_NB | 4 | AT+VGS | Command issued by the HS to report | */
147 /* | | | | the current speaker gain level | */
148 /* | | | | setting to the AG (See Headset | */
149 /* | | | | Specification, Section 4.7.3). | */
150 /* |___________________|_____|_________|______________________________________| */
151 /* */
152 /* Define the command line prefix "AT" (See ITU-T Recommendation V.250 ter page */
153 /* page 4). */
154 #define ATP_AT_PREFIX ("AT")
155 #define ATP_AT_PREFIX_LEN (0x02)
156
157 /* Text codes for AT commands. */
158 static const char ATP_AT_TXT_TABLE[] = {'A', \
159 'D', \
160 'E', \
161 'H', \
162 'I', \
163 'L', \
164 'M', \
165 'O', \
166 'P', \
167 'Q', \
168 'S', '0', \
169 'S', '1', '0', \
170 'S', '3', \
171 'S', '4', \
172 'S', '5', \
173 'S', '6', \
174 'S', '7', \
175 'S', '8', \
176 'T', \
177 'V', \
178 'X', \
179 'Z', \
180 '&', 'C', \
181 '&', 'D', \
182 '&', 'F', \
183 '+', 'C', 'K', 'P', 'D', \
184 '+', 'F', 'D', 'R', \
185 '+', 'F', 'D', 'T', \
186 '+', 'F', 'K', 'S', \
187 '+', 'G', 'M', 'I', \
188 '+', 'G', 'M', 'M', \
189 '+', 'G', 'M', 'R', \
190 '+', 'G', 'C', 'A', 'P', \
191 '+', 'V', 'G', 'M', \
192 '+', 'V', 'G', 'S', \
193 '\xFF'};
194
195 /* Binary related codes. */
196 typedef enum
197 {
198 ATP_ATA_NB = (0x00000000),
199 ATP_ATD_NB,
200 ATP_ATE_NB,
201 ATP_ATH_NB,
202 ATP_ATI_NB,
203 ATP_ATL_NB,
204 ATP_ATM_NB,
205 ATP_ATO_NB,
206 ATP_ATP_NB,
207 ATP_ATQ_NB,
208 ATP_ATS0_NB,
209 ATP_ATS10_NB,
210 ATP_ATS3_NB,
211 ATP_ATS4_NB,
212 ATP_ATS5_NB,
213 ATP_ATS6_NB,
214 ATP_ATS7_NB,
215 ATP_ATS8_NB,
216 ATP_ATT_NB,
217 ATP_ATV_NB,
218 ATP_ATX_NB,
219 ATP_ATZ_NB,
220 ATP_AT_AND_C_NB,
221 ATP_AT_AND_D_NB,
222 ATP_AT_AND_F_NB,
223 ATP_AT_PLUS_CKPD_NB,
224 ATP_AT_PLUS_FDR_NB,
225 ATP_AT_PLUS_FDT_NB,
226 ATP_AT_PLUS_FKS_NB,
227 ATP_AT_PLUS_GMI_NB,
228 ATP_AT_PLUS_GMM_NB,
229 ATP_AT_PLUS_GMR_NB,
230 ATP_AT_PLUS_GCAP_NB,
231 ATP_AT_PLUS_VGM_NB,
232 ATP_AT_PLUS_VGS_NB,
233 ATP_MAX_NB_OF_AT_COMMANDS
234 } T_ATP_BINARY_AT_COMMANDS;
235
236 /* Related offsets. */
237 #define ATP_ATA_OFFSET (0x00)
238 #define ATP_ATD_OFFSET (ATP_ATA_OFFSET + 0x01)
239 #define ATP_ATE_OFFSET (ATP_ATD_OFFSET + 0x01)
240 #define ATP_ATH_OFFSET (ATP_ATE_OFFSET + 0x01)
241 #define ATP_ATI_OFFSET (ATP_ATH_OFFSET + 0x01)
242 #define ATP_ATL_OFFSET (ATP_ATI_OFFSET + 0x01)
243 #define ATP_ATM_OFFSET (ATP_ATL_OFFSET + 0x01)
244 #define ATP_ATO_OFFSET (ATP_ATM_OFFSET + 0x01)
245 #define ATP_ATP_OFFSET (ATP_ATO_OFFSET + 0x01)
246 #define ATP_ATQ_OFFSET (ATP_ATP_OFFSET + 0x01)
247 #define ATP_ATS0_OFFSET (ATP_ATQ_OFFSET + 0x01)
248 #define ATP_ATS10_OFFSET (ATP_ATS0_OFFSET + 0x02)
249 #define ATP_ATS3_OFFSET (ATP_ATS10_OFFSET + 0x03)
250 #define ATP_ATS4_OFFSET (ATP_ATS3_OFFSET + 0x02)
251 #define ATP_ATS5_OFFSET (ATP_ATS4_OFFSET + 0x02)
252 #define ATP_ATS6_OFFSET (ATP_ATS5_OFFSET + 0x02)
253 #define ATP_ATS7_OFFSET (ATP_ATS6_OFFSET + 0x02)
254 #define ATP_ATS8_OFFSET (ATP_ATS7_OFFSET + 0x02)
255 #define ATP_ATT_OFFSET (ATP_ATS8_OFFSET + 0x02)
256 #define ATP_ATV_OFFSET (ATP_ATT_OFFSET + 0x01)
257 #define ATP_ATX_OFFSET (ATP_ATV_OFFSET + 0x01)
258 #define ATP_ATZ_OFFSET (ATP_ATX_OFFSET + 0x01)
259 #define ATP_AT_AND_C_OFFSET (ATP_ATZ_OFFSET + 0x01)
260 #define ATP_AT_AND_D_OFFSET (ATP_AT_AND_C_OFFSET + 0x02)
261 #define ATP_AT_AND_F_OFFSET (ATP_AT_AND_D_OFFSET + 0x02)
262 #define ATP_AT_PLUS_CKPD_OFFSET (ATP_AT_AND_F_OFFSET + 0x02)
263 #define ATP_AT_PLUS_FDR_OFFSET (ATP_AT_PLUS_CKPD_OFFSET + 0x05)
264 #define ATP_AT_PLUS_FDT_OFFSET (ATP_AT_PLUS_FDR_OFFSET + 0x04)
265 #define ATP_AT_PLUS_FKS_OFFSET (ATP_AT_PLUS_FDT_OFFSET + 0x04)
266 #define ATP_AT_PLUS_GMI_OFFSET (ATP_AT_PLUS_FKS_OFFSET + 0x04)
267 #define ATP_AT_PLUS_GMM_OFFSET (ATP_AT_PLUS_GMI_OFFSET + 0x04)
268 #define ATP_AT_PLUS_GMR_OFFSET (ATP_AT_PLUS_GMM_OFFSET + 0x04)
269 #define ATP_AT_PLUS_GCAP_OFFSET (ATP_AT_PLUS_GMR_OFFSET + 0x04)
270 #define ATP_AT_PLUS_VGM_OFFSET (ATP_AT_PLUS_GCAP_OFFSET + 0x05)
271 #define ATP_AT_PLUS_VGS_OFFSET (ATP_AT_PLUS_VGM_OFFSET + 0x04)
272 #define ATP_AT_LAST_OFFSET (ATP_AT_PLUS_VGS_OFFSET + 0x04)
273
274 /* Related structures. */
275 typedef enum
276 {
277 ATP_CMD_NOT_DEFINED = (0x00000000),
278 ATP_NO_PARAM,
279 ATP_BASIC_PARAM,
280 ATP_DIAL_PARAM,
281 ATP_S_PARAM,
282 ATP_NO_EXTENDED_PARAM,
283 ATP_SINGLE_EXTENDED_PARAM,
284 ATP_PLUS_CKPD_PARAM
285 } T_ATP_CMD_FORMAT;
286
287 #define ATP_ATA_PARAM (ATP_NO_PARAM)
288 #define ATP_ATD_PARAM (ATP_DIAL_PARAM)
289 #define ATP_ATE_PARAM (ATP_BASIC_PARAM)
290 #define ATP_ATH_PARAM (ATP_BASIC_PARAM)
291 #define ATP_ATI_PARAM (ATP_BASIC_PARAM)
292 #define ATP_ATL_PARAM (ATP_BASIC_PARAM)
293 #define ATP_ATM_PARAM (ATP_BASIC_PARAM)
294 #define ATP_ATO_PARAM (ATP_BASIC_PARAM)
295 #define ATP_ATP_PARAM (ATP_NO_PARAM)
296 #define ATP_ATQ_PARAM (ATP_BASIC_PARAM)
297 #define ATP_ATS0_PARAM (ATP_S_PARAM)
298 #define ATP_ATS10_PARAM (ATP_S_PARAM)
299 #define ATP_ATS3_PARAM (ATP_S_PARAM)
300 #define ATP_ATS4_PARAM (ATP_S_PARAM)
301 #define ATP_ATS5_PARAM (ATP_S_PARAM)
302 #define ATP_ATS6_PARAM (ATP_S_PARAM)
303 #define ATP_ATS7_PARAM (ATP_S_PARAM)
304 #define ATP_ATS8_PARAM (ATP_S_PARAM)
305 #define ATP_ATT_PARAM (ATP_NO_PARAM)
306 #define ATP_ATV_PARAM (ATP_BASIC_PARAM)
307 #define ATP_ATX_PARAM (ATP_BASIC_PARAM)
308 #define ATP_ATZ_PARAM (ATP_BASIC_PARAM)
309 #define ATP_AT_AND_C_PARAM (ATP_BASIC_PARAM)
310 #define ATP_AT_AND_D_PARAM (ATP_BASIC_PARAM)
311 #define ATP_AT_AND_F_PARAM (ATP_BASIC_PARAM)
312 #define ATP_AT_PLUS_CKPD_PARAM (ATP_PLUS_CKPD_PARAM)
313 #define ATP_AT_PLUS_FDR_PARAM (ATP_NO_EXTENDED_PARAM)
314 #define ATP_AT_PLUS_FDT_PARAM (ATP_NO_EXTENDED_PARAM)
315 #define ATP_AT_PLUS_FKS_PARAM (ATP_NO_EXTENDED_PARAM)
316 #define ATP_AT_PLUS_GMI_PARAM (ATP_NO_EXTENDED_PARAM)
317 #define ATP_AT_PLUS_GMM_PARAM (ATP_NO_EXTENDED_PARAM)
318 #define ATP_AT_PLUS_GMR_PARAM (ATP_NO_EXTENDED_PARAM)
319 #define ATP_AT_PLUS_GCAP_PARAM (ATP_NO_EXTENDED_PARAM)
320 #define ATP_AT_PLUS_VGM_PARAM (ATP_SINGLE_EXTENDED_PARAM)
321 #define ATP_AT_PLUS_VGS_PARAM (ATP_SINGLE_EXTENDED_PARAM)
322
323 #define ATP_AT_OFFSET_COLUMN (0x00)
324 #define ATP_AT_PARAM_COLUMN (0x01)
325
326 static const UINT8 ATP_AT_INFO[ATP_MAX_NB_OF_AT_COMMANDS + 0x01][0x02] \
327 = {{ATP_ATA_OFFSET, ATP_ATA_PARAM}, \
328 {ATP_ATD_OFFSET, ATP_ATD_PARAM}, \
329 {ATP_ATE_OFFSET, ATP_ATE_PARAM}, \
330 {ATP_ATH_OFFSET, ATP_ATH_PARAM}, \
331 {ATP_ATI_OFFSET, ATP_ATI_PARAM}, \
332 {ATP_ATL_OFFSET, ATP_ATL_PARAM}, \
333 {ATP_ATM_OFFSET, ATP_ATM_PARAM}, \
334 {ATP_ATO_OFFSET, ATP_ATO_PARAM}, \
335 {ATP_ATP_OFFSET, ATP_ATP_PARAM}, \
336 {ATP_ATQ_OFFSET, ATP_ATQ_PARAM}, \
337 {ATP_ATS0_OFFSET, ATP_ATS0_PARAM}, \
338 {ATP_ATS10_OFFSET, ATP_ATS10_PARAM}, \
339 {ATP_ATS3_OFFSET, ATP_ATS3_PARAM}, \
340 {ATP_ATS4_OFFSET, ATP_ATS4_PARAM}, \
341 {ATP_ATS5_OFFSET, ATP_ATS5_PARAM}, \
342 {ATP_ATS6_OFFSET, ATP_ATS6_PARAM}, \
343 {ATP_ATS7_OFFSET, ATP_ATS7_PARAM}, \
344 {ATP_ATS8_OFFSET, ATP_ATS8_PARAM}, \
345 {ATP_ATT_OFFSET, ATP_ATT_PARAM}, \
346 {ATP_ATV_OFFSET, ATP_ATV_PARAM}, \
347 {ATP_ATX_OFFSET, ATP_ATX_PARAM}, \
348 {ATP_ATZ_OFFSET, ATP_ATZ_PARAM}, \
349 {ATP_AT_AND_C_OFFSET, ATP_AT_AND_C_PARAM}, \
350 {ATP_AT_AND_D_OFFSET, ATP_AT_AND_D_PARAM}, \
351 {ATP_AT_AND_F_OFFSET, ATP_AT_AND_F_PARAM}, \
352 {ATP_AT_PLUS_CKPD_OFFSET, ATP_AT_PLUS_CKPD_PARAM}, \
353 {ATP_AT_PLUS_FDR_OFFSET, ATP_AT_PLUS_FDR_PARAM}, \
354 {ATP_AT_PLUS_FDT_OFFSET, ATP_AT_PLUS_FDT_PARAM}, \
355 {ATP_AT_PLUS_FKS_OFFSET, ATP_AT_PLUS_FKS_PARAM}, \
356 {ATP_AT_PLUS_GMI_OFFSET, ATP_AT_PLUS_GMI_PARAM}, \
357 {ATP_AT_PLUS_GMM_OFFSET, ATP_AT_PLUS_GMM_PARAM}, \
358 {ATP_AT_PLUS_GMR_OFFSET, ATP_AT_PLUS_GMR_PARAM}, \
359 {ATP_AT_PLUS_GCAP_OFFSET, ATP_AT_PLUS_GCAP_PARAM}, \
360 {ATP_AT_PLUS_VGM_OFFSET, ATP_AT_PLUS_VGM_PARAM}, \
361 {ATP_AT_PLUS_VGS_OFFSET, ATP_AT_PLUS_VGS_PARAM}, \
362 {ATP_AT_LAST_OFFSET, ATP_CMD_NOT_DEFINED}};
363
364 /* Define the maximum length (text format) of <numbers> appearing in basic */
365 /* syntax commands. */
366 /* - <number> (up to 65535). */
367 #define MAX_BASIC_CMD_PARAM_LEN (0x05)
368
369 /* Define the structure associated with basic syntax commands (except for the */
370 /* D and S commands). The format of such commands is <command>[<number>], where */
371 /* <number> may be a string of one or more characters from "0" through "9" */
372 /* representing the decimal integer value (See ITU-T Recommendation V.250 ter */
373 /* page 5). */
374 typedef struct
375 {
376 UINT16 number;
377 } T_ATP_BASIC_CMD;
378
379 /* Define all basic syntax commands do not expext any <number>. */
380 /* __________________________________________________________________________ */
381 /* | | | | | */
382 /* | Binary code | Len | Command | Description | */
383 /* |___________________|_____|_________|______________________________________| */
384 /* | | | | | */
385 /* | ATP_ATA_NB | 1 | ATA | Answer. | */
386 /* | ATP_ATP_NB | 1 | ATP | Select pulse dialling. | */
387 /* | ATP_ATT_NB | 1 | ATT | Select tone dialling. | */
388 /* |___________________|_____|_________|______________________________________| */
389 /* */
390 /* Define all other basic syntax commands. */
391 /* __________________________________________________________________________ */
392 /* | | | | | */
393 /* | Binary code | Len | Command | Description | */
394 /* |___________________|_____|_________|______________________________________| */
395 /* | | | | | */
396 /* | ATP_ATE_NB | 1 | ATE | Command echo. | */
397 /* | ATP_ATH_NB | 1 | ATH | Hook control. | */
398 /* | ATP_ATI_NB | 1 | ATI | Request Identification Information | */
399 /* | ATP_ATL_NB | 1 | ATL | Monitor speaker loudness. | */
400 /* | ATP_ATM_NB | 1 | ATM | Monitor speaker mode. | */
401 /* | ATP_ATO_NB | 1 | ATO | Return to online data state. | */
402 /* | ATP_ATQ_NB | 1 | ATQ | Result code suppression. | */
403 /* | ATP_ATV_NB | 1 | ATV | DCE response format. | */
404 /* | ATP_ATX_NB | 1 | ATX | Result code selection and call | */
405 /* | | | | progress monitoring control. | */
406 /* | ATP_ATZ_NB | 1 | ATZ | Reset to default configuration. | */
407 /* | ATP_AT_AND_C_NB | 2 | AT&C | Circuit 109 (received line signal | */
408 /* | | | | detector) behavior. | */
409 /* | ATP_AT_AND_D_NB | 2 | AT&D | Circuit 108 (data terminal ready) | */
410 /* | | | | behavior. | */
411 /* | ATP_AT_AND_F_NB | 2 | AT&F | Set to factory defined | */
412 /* | | | | configuration. | */
413 /* |___________________|_____|_________|______________________________________| */
414 typedef T_ATP_BASIC_CMD T_ATP_ATE_PARAM;
415 typedef T_ATP_BASIC_CMD T_ATP_ATH_PARAM;
416 typedef T_ATP_BASIC_CMD T_ATP_ATI_PARAM;
417 typedef T_ATP_BASIC_CMD T_ATP_ATL_PARAM;
418 typedef T_ATP_BASIC_CMD T_ATP_ATM_PARAM;
419 typedef T_ATP_BASIC_CMD T_ATP_ATO_PARAM;
420 typedef T_ATP_BASIC_CMD T_ATP_ATQ_PARAM;
421 typedef T_ATP_BASIC_CMD T_ATP_ATV_PARAM;
422 typedef T_ATP_BASIC_CMD T_ATP_ATX_PARAM;
423 typedef T_ATP_BASIC_CMD T_ATP_ATZ_PARAM;
424 typedef T_ATP_BASIC_CMD T_ATP_AT_AND_C_PARAM;
425 typedef T_ATP_BASIC_CMD T_ATP_AT_AND_D_PARAM;
426 typedef T_ATP_BASIC_CMD T_ATP_AT_AND_F_PARAM;
427
428 /* Define the maximum number of characters appearing in the <dial_string>. */
429 #define MAX_DIAL_STRING_LEN (30)
430
431 /* Define the structure associated with "Dial" command whose format is */
432 /* D[<dial_string>][;] (See ITU-T Recommendation V.250 ter page 31). Note that */
433 /* all characters appearing on the same command line after D are considered */
434 /* part of the call addressing information to be signalled to the network, or */
435 /* modifiers used to control the signalling process, up to a semicolon */
436 /* character or the end of the command line. If the <dial_string> is terminated */
437 /* by a semicolon, the DCE does not start the call origination procedure, but */
438 /* instead returns to command state after completion of the signalling of call */
439 /* addressing information to the network. */
440 typedef struct
441 {
442 char dial_string_p[MAX_DIAL_STRING_LEN];
443 UINT8 dial_string_length;
444 enum
445 {
446 DATA_CALL = 0x00000000,
447 VOICE_CALL
448 } call_type;
449 } T_ATP_DIAL;
450
451 /* Define all dial commands. */
452 /* __________________________________________________________________________ */
453 /* | | | | | */
454 /* | Binary code | Len | Command | Description | */
455 /* |___________________|_____|_________|______________________________________| */
456 /* | | | | | */
457 /* | ATP_ATD_NB | 1 | ATD | Dial. | */
458 /* |___________________|_____|_________|______________________________________| */
459 typedef T_ATP_DIAL T_ATP_ATD_PARAM;
460
461 /* Define the maximum length (text format) of <values> appearing in */
462 /* S-parameters. */
463 /* - '=' + <value> (up to 65535). */
464 #define MAX_S_PARAM_LEN (0x06)
465
466 /* Define the structure associated with S-parameters. Formats of such commands */
467 /* are S<parameter_number>? and S<parameter_number>=[<value>], where <value> */
468 /* shall consist of a decimal constant (See ITU-T Recommendation V.250 ter */
469 /* pages 5 and 6). */
470 typedef struct
471 {
472 enum
473 {
474 READ_S_PARAM = 0x00000001,
475 SET_S_PARAM
476 } s_operator;
477 UINT16 value;
478 } T_ATP_S_PARAM;
479
480 /* Define all S-parameters. */
481 /* __________________________________________________________________________ */
482 /* | | | | | */
483 /* | Binary code | Len | Command | Description | */
484 /* |___________________|_____|_________|______________________________________| */
485 /* | | | | | */
486 /* | ATP_ATS0_NB | 2 | ATS0 | Automatic answer. | */
487 /* | ATP_ATS10_NB | 3 | ATS10 | Automatic disconnect delay. | */
488 /* | ATP_ATS3_NB | 2 | ATS3 | Command line termination character. | */
489 /* | ATP_ATS4_NB | 2 | ATS4 | Response formatting character. | */
490 /* | ATP_ATS5_NB | 2 | ATS5 | Command line editing character. | */
491 /* | ATP_ATS6_NB | 2 | ATS6 | Pause before blind dialling. | */
492 /* | ATP_ATS7_NB | 2 | ATS7 | Connection completion timeout. | */
493 /* | ATP_ATS8_NB | 2 | ATS8 | Comma dial modifier time. | */
494 /* |___________________|_____|_________|______________________________________| */
495 typedef T_ATP_S_PARAM T_ATP_ATS0_PARAM;
496 typedef T_ATP_S_PARAM T_ATP_ATS10_PARAM;
497 typedef T_ATP_S_PARAM T_ATP_ATS3_PARAM;
498 typedef T_ATP_S_PARAM T_ATP_ATS4_PARAM;
499 typedef T_ATP_S_PARAM T_ATP_ATS5_PARAM;
500 typedef T_ATP_S_PARAM T_ATP_ATS6_PARAM;
501 typedef T_ATP_S_PARAM T_ATP_ATS7_PARAM;
502 typedef T_ATP_S_PARAM T_ATP_ATS8_PARAM;
503
504 /* Define operators dedicated to extended syntax commands. "=" is used to set */
505 /* the indicated extended syntax command to a new value (See ITU-T */
506 /* Recommendation V.250 ter page 8). Note that if no value is given, the */
507 /* extended syntax command specified may be set to 0. "?" is used to read the */
508 /* current value of the indicated extended syntax command (See ITU-T */
509 /* Recommendation V.250 ter page 9). "=?" is used to test whether the extended */
510 /* syntax command is implemented in the DCE. */
511 typedef enum
512 {
513 NO_SUBPARAMETER = 0x00000000,
514 READ_EXTENDED_CMD,
515 SET_EXTENDED_CMD,
516 TEST_EXTENDED_CMD
517 } T_ATP_EXTENDED_OPERATOR;
518
519 /* Define the maximum length (text format) of extended syntax commands that */
520 /* have no subparameter. */
521 /* - '=?'. */
522 #define MAX_NO_SUBPARAMETER_LEN (0x02)
523
524 /* Define the structure associated with extended syntax commands that have no */
525 /* subparameter. Formats of such commands are +<name> and +<name>=?, where */
526 /* <name> may be a string of one or sixteen characters selected from the */
527 /* following set (See ITU-T Recommendation V.250 ter page 6): */
528 /* "A" through "Z", */
529 /* "0" through "9", */
530 /* "!", "%", "-", ".", "/", ":" and "_". */
531 typedef struct
532 {
533 T_ATP_EXTENDED_OPERATOR extended_operator;
534 } T_ATP_NO_SUBPARAMETER;
535
536 /* Define all extended syntax commands do not expext any <value>. */
537 /* __________________________________________________________________________ */
538 /* | | | | | */
539 /* | Binary code | Len | Command | Description | */
540 /* |___________________|_____|_________|______________________________________| */
541 /* | | | | | */
542 /* |ATP_AT_PLUS_FDR_NB | 4 | AT+FDR | Receive a page. | */
543 /* |ATP_AT_PLUS_FDT_NB | 4 | AT+FDT | Send a page. | */
544 /* |ATP_AT_PLUS_FKS_NB | 4 | AT+FKS | Session termination. | */
545 /* |ATP_AT_PLUS_GMI_NB | 4 | AT+GMI | Request manufacturer identification. | */
546 /* |ATP_AT_PLUS_GMM_NB | 4 | AT+GMM | Request model identification. | */
547 /* |ATP_AT_PLUS_GMR_NB | 4 | AT+GMR | Request revision identification. | */
548 /* |ATP_AT_PLUS_GCAP_NB| 5 | AT+GCAP | Request complete capabilities list. | */
549 /* |___________________|_____|_________|______________________________________| */
550 typedef T_ATP_NO_SUBPARAMETER T_ATP_AT_PLUS_FDR_PARAM;
551 typedef T_ATP_NO_SUBPARAMETER T_ATP_AT_PLUS_FDT_PARAM;
552 typedef T_ATP_NO_SUBPARAMETER T_ATP_AT_PLUS_FKS_PARAM;
553 typedef T_ATP_NO_SUBPARAMETER T_ATP_AT_PLUS_GMI_PARAM;
554 typedef T_ATP_NO_SUBPARAMETER T_ATP_AT_PLUS_GMM_PARAM;
555 typedef T_ATP_NO_SUBPARAMETER T_ATP_AT_PLUS_GMR_PARAM;
556 typedef T_ATP_NO_SUBPARAMETER T_ATP_AT_PLUS_GCAP_PARAM;
557
558 /* Define the maximum length (text format) of <values> appearing in extended */
559 /* syntax commands whose subparameter is a numeric constant. */
560 /* - '=' + <value> (up to 65535). */
561 #define MAX_SINGLE_SUBPARAMETER_LEN (0x06)
562
563 /* Define the structure associated with extended syntax commands whose */
564 /* subparameter is a numeric constant. Formats of such commands are +<name>?, */
565 /* +<name>[=<value>] and and +<name>=?, where <name> may be a string of one or */
566 /* sixteen characters selected from the following set (See ITU-T Recommendation */
567 /* V.250 ter page 6): */
568 /* "A" through "Z", */
569 /* "0" through "9", */
570 /* "!", "%", "-", ".", "/", ":" and "_". */
571 /* */
572 /* <value> shall consist of a numeric constant (See ITU-T Recommendation V.250 */
573 /* ter page 6). */
574 /* Some additional commands may follow an extended syntax command on the same */
575 /* command line if a semicolon is inserted after the preceding extended command */
576 /* as a separator. The semicolon is not necessary when the extended syntax */
577 /* command is the last command on the command line (See ITU-T Recommendation */
578 /* V.250 ter page 9). Besides, extended syntax commands may appear on the same */
579 /* command line after a basic syntax command without a separator, in the same */
580 /* manner as concatenation of basic syntax commands. */
581 typedef struct
582 {
583 T_ATP_EXTENDED_OPERATOR extended_operator;
584 UINT16 value;
585 } T_ATP_SINGLE_SUBPARAMETER;
586
587 /* Define all extended syntax commands whose subparameter is a numeric */
588 /* constant. */
589 /* __________________________________________________________________________ */
590 /* | | | | | */
591 /* | Binary code | Len | Command | Description | */
592 /* |___________________|_____|_________|______________________________________| */
593 /* | | | | meaning in the headset profile. | */
594 /* |ATP_AT_PLUS_VGM_NB | 4 | AT+VGM | Command issued by the HS to report | */
595 /* | | | | the current microphone gain level | */
596 /* | | | | setting to the AG (See Headset | */
597 /* | | | | Specification, Section 4.7.3). | */
598 /* |ATP_AT_PLUS_VGS_NB | 4 | AT+VGS | Command issued by the HS to report | */
599 /* | | | | the current speaker gain level | */
600 /* | | | | setting to the AG (See Headset | */
601 /* | | | | Specification, Section 4.7.3). | */
602 /* |___________________|_____|_________|______________________________________| */
603 typedef T_ATP_SINGLE_SUBPARAMETER T_ATP_AT_PLUS_VGM_PARAM;
604 typedef T_ATP_SINGLE_SUBPARAMETER T_ATP_AT_PLUS_VGS_PARAM;
605
606 /* Define the maximum number of keys appearing in the <keys>. */
607 #define MAX_NB_OF_KEYS (5)
608
609 /* Define the maximum length (text format) of the <compound_value> appearing in */
610 /* keypad control commands. */
611 /* - "=" + """ + MAX_NB_OF_KEYS * [";" + <keys> (up to 65535) + ";"] + """ + */
612 /* + "," + <time> (up to 65535) */
613 /* + "," + <pause> (up to 65535). */
614 #define MAX_CKPD_PARAM_LEN (0x0F + MAX_NB_OF_KEYS * 0x07)
615
616 /* Define the structure associated with the extended syntax command +CKPD. */
617 /* Formats of such command are +<name>=<keys>[,<time>[,<pause>]] and +<name>=?, */
618 /* where <name> may be a string of one or sixteen characters selected from the */
619 /* following set (See ITU-T Recommendation V.250 ter page 6): */
620 /* "A" through "Z", */
621 /* "0" through "9", */
622 /* "!", "%", "-", ".", "/", ":" and "_". */
623 /* */
624 /* <keys> shall consist of a string constant (See ETS 300 916 (GSM 07.07) */
625 /* Version 5.8.1 page 62). */
626 /* <time> and <pause> shall consist of numeric constants in tenths of a second */
627 /* (See ETS 300 916 (GSM 07.07) Version 5.8.1 page 62). */
628 /* Some additional commands may follow an extended syntax command on the same */
629 /* command line if a semicolon is inserted after the preceding extended command */
630 /* as a separator. The semicolon is not necessary when the extended syntax */
631 /* command is the last command on the command line (See ITU-T Recommendation */
632 /* V.250 ter page 9). Besides, extended syntax commands may appear on the same */
633 /* command line after a basic syntax command without a separator, in the same */
634 /* manner as concatenation of basic syntax commands. */
635 typedef struct
636 {
637 T_ATP_EXTENDED_OPERATOR extended_operator;
638 UINT16 keys[MAX_NB_OF_KEYS];
639 UINT8 nb_keys;
640 UINT16 time;
641 UINT16 pause;
642 } T_ATP_PLUS_CKPD;
643
644 /* Define all extended syntax commands. */
645 /* __________________________________________________________________________ */
646 /* | | | | | */
647 /* | Binary code | Len | Command | Description | */
648 /* |___________________|_____|_________|______________________________________| */
649 /* | | | | | */
650 /* |ATP_AT_PLUS_CKPD_NB| 5 | AT+CKPD | Keypad control command (See GSM TS | */
651 /* | | | | 07.07, Section 8.7). For <keys>, the | */
652 /* | | | | value of 200 indicates the button on | */
653 /* | | | | the headset being pushed. The <time> | */
654 /* | | | | and <pause> parameters have no | */
655 /* | | | | meaning in the headset profile. | */
656 /* |___________________|_____|_________|______________________________________| */
657 typedef T_ATP_PLUS_CKPD T_ATP_AT_PLUS_CKPD_PARAM;
658
659 /* Define the default time value. */
660 #define DEFAULT_TIME (0x0000)
661
662 /* Define an unspecified time value. */
663 #define TIME_DO_NOT_CARE (0x0000)
664
665 /* Define the default pause value. */
666 #define DEFAULT_PAUSE (0x0000)
667
668 /* Define an unspecified pause value. */
669 #define PAUSE_DO_NOT_CARE (0x0000)
670
671 /********************************* RESULT CODES *********************************/
672 /* */
673 /* Define all supported result codes. */
674 /* */
675 /* __________________________________________________________________________ */
676 /* | | | | | | */
677 /* | Binary code | Len | Result code | Numeric | Description | */
678 /* |__________________|_____|_____________|_________|_________________________| */
679 /* | | | | | | */
680 /* | ATP_OK_NB | 2 | OK | 0 | Acknoledges execution | */
681 /* | | | | | of a command. | */
682 /* | ATP_CONNECT_NB | 7 | CONNECT | 1 | A connection has been | */
683 /* | | | | | established. | */
684 /* | ATP_RING_NB | 4 | RING | 2 | Incoming call detected. | */
685 /* |ATP_NO_CARRIER_NB | 10 | NO CARRIER | 3 | The connection has been | */
686 /* | | | | | terminated or the | */
687 /* | | | | | attempt to establish a | */
688 /* | | | | | connection failed. | */
689 /* | ATP_ERROR_NB | 5 | ERROR | 4 | Problem with processing | */
690 /* | | | | | the command line. | */
691 /* |ATP_NO_DIALTONE_NB| 11 | NO DIALTONE | 6 | No dial tone detected. | */
692 /* | ATP_BUSY_NB | 4 | BUSY | 7 | Busy signal detected. | */
693 /* | ATP_NO_ANSWER_NB | 9 | NO ANSWER | 8 | '@' dial modifier was | */
694 /* | | | | | used, but remote | */
695 /* | | | | | ringing followed by 5 | */
696 /* | | | | | seconds of silence was | */
697 /* | | | | | not detected before | */
698 /* | | | | | expiration of the | */
699 /* | | | | | connection timer. | */
700 /* |__________________|_____|_____________|_________|_________________________| */
701 /* | | | | | | */
702 /* |ATP_CONNECT_TXT_NB| 7 | CONNECT | X | A connection has been | */
703 /* | | | | | established. | */
704 /* |__________________|_____|_____________|_________|_________________________| */
705 /* | | | | | | */
706 /* | ATP_PLUS_VGM_NB | 4 | +VGM | X | Unsolicited result code | */
707 /* | | | | | issued by the AG to set | */
708 /* | | | | | the microphone gain of | */
709 /* | | | | | the HS (See Headset | */
710 /* | | | | | Specification, Section | */
711 /* | | | | | 4.7.3). | */
712 /* | ATP_PLUS_VGS_NB | 4 | +VGS | X | Unsolicited result code | */
713 /* | | | | | issued by the AG to set | */
714 /* | | | | | the speaker gain of the | */
715 /* | | | | | HS (See Headset | */
716 /* | | | | | Specification, Section | */
717 /* | | | | | 4.7.3). | */
718 /* |__________________|_____|_____________|_________|_________________________| */
719 /* */
720 /* Define the length of <CR><LF> headers of information responses (See ETS 300 */
721 /* 916 (GSM 07.07) Version 4.1 page 13). */
722 #define ATP_RESULT_CODE_HEADER_LEN (0x02)
723
724 /* Text codes for result codes (verbose responses disabled). */
725 static const char ATP_RESULT_CODE_TXT_TABLE_V0[] = {'0', \
726 '1', \
727 '2', \
728 '3', \
729 '4', \
730 '6', \
731 '7', \
732 '8', \
733 'C', 'O', 'N', 'N', 'E', 'C', 'T', \
734 '+', 'V', 'G', 'M', \
735 '+', 'V', 'G', 'S', \
736 '\xFF'};
737
738 /* Text codes for result codes (verbose responses enabled). */
739 static const char ATP_RESULT_CODE_TXT_TABLE_V1[] = {'O', 'K', \
740 'C', 'O', 'N', 'N', 'E', 'C', 'T', \
741 'R', 'I', 'N', 'G', \
742 'N', 'O', ' ', 'C', 'A', 'R', 'R', 'I', 'E', 'R', \
743 'E', 'R', 'R', 'O', 'R', \
744 'N', 'O', ' ', 'D', 'I', 'A', 'L', 'T', 'O', 'N', 'E', \
745 'B', 'U', 'S', 'Y', \
746 'N', 'O', ' ', 'A', 'N', 'S', 'W', 'E', 'R', \
747 'C', 'O', 'N', 'N', 'E', 'C', 'T', \
748 '+', 'V', 'G', 'M', \
749 '+', 'V', 'G', 'S', \
750 '\xFF'};
751
752 /* Binary related codes. */
753 typedef enum
754 {
755 ATP_OK_NB = (0x00000000),
756 ATP_CONNECT_NB,
757 ATP_RING_NB,
758 ATP_NO_CARRIER_NB,
759 ATP_ERROR_NB,
760 ATP_NO_DIALTONE_NB = (0x00000006),
761 ATP_BUSY_NB,
762 ATP_NO_ANSWER_NB,
763 ATP_CONNECT_TXT_NB,
764 ATP_PLUS_VGM_NB,
765 ATP_PLUS_VGS_NB,
766 ATP_MAX_NB_OF_RESULT_CODES
767 } T_ATP_BINARY_RESULT_CODES;
768
769 /* Related offsets (verbose responses disabled). */
770 #define ATP_OK_OFFSET_V0 (0x00)
771 #define ATP_CONNECT_OFFSET_V0 (ATP_OK_OFFSET_V0 + 0x01)
772 #define ATP_RING_OFFSET_V0 (ATP_CONNECT_OFFSET_V0 + 0x01)
773 #define ATP_NO_CARRIER_OFFSET_V0 (ATP_RING_OFFSET_V0 + 0x01)
774 #define ATP_ERROR_OFFSET_V0 (ATP_NO_CARRIER_OFFSET_V0 + 0x01)
775 #define ATP_NO_DIALTONE_OFFSET_V0 (ATP_ERROR_OFFSET_V0 + 0x01)
776 #define ATP_BUSY_OFFSET_V0 (ATP_NO_DIALTONE_OFFSET_V0 + 0x01)
777 #define ATP_NO_ANSWER_OFFSET_V0 (ATP_BUSY_OFFSET_V0 + 0x01)
778 #define ATP_CONNECT_TXT_OFFSET_V0 (ATP_NO_ANSWER_OFFSET_V0 + 0x01)
779 #define ATP_PLUS_VGM_OFFSET_V0 (ATP_CONNECT_TXT_OFFSET_V0 + 0x07)
780 #define ATP_PLUS_VGS_OFFSET_V0 (ATP_PLUS_VGM_OFFSET_V0 + 0x04)
781 #define ATP_RESULT_CODE_LAST_OFFSET_V0 (ATP_PLUS_VGS_OFFSET_V0 + 0x04)
782
783 /* Related offsets (verbose responses enabled). */
784 #define ATP_OK_OFFSET_V1 (0x00)
785 #define ATP_CONNECT_OFFSET_V1 (ATP_OK_OFFSET_V1 + 0x02)
786 #define ATP_RING_OFFSET_V1 (ATP_CONNECT_OFFSET_V1 + 0x07)
787 #define ATP_NO_CARRIER_OFFSET_V1 (ATP_RING_OFFSET_V1 + 0x04)
788 #define ATP_ERROR_OFFSET_V1 (ATP_NO_CARRIER_OFFSET_V1 + 0x0A)
789 #define ATP_NO_DIALTONE_OFFSET_V1 (ATP_ERROR_OFFSET_V1 + 0x05)
790 #define ATP_BUSY_OFFSET_V1 (ATP_NO_DIALTONE_OFFSET_V1 + 0x0B)
791 #define ATP_NO_ANSWER_OFFSET_V1 (ATP_BUSY_OFFSET_V1 + 0x04)
792 #define ATP_CONNECT_TXT_OFFSET_V1 (ATP_NO_ANSWER_OFFSET_V1 + 0x09)
793 #define ATP_PLUS_VGM_OFFSET_V1 (ATP_CONNECT_TXT_OFFSET_V1 + 0x07)
794 #define ATP_PLUS_VGS_OFFSET_V1 (ATP_PLUS_VGM_OFFSET_V1 + 0x04)
795 #define ATP_RESULT_CODE_LAST_OFFSET_V1 (ATP_PLUS_VGS_OFFSET_V1 + 0x04)
796
797 /* Related structures. */
798 typedef enum
799 {
800 ATP_RESULT_CODE_NOT_DEFINED = (0x00000000),
801 ATP_BASIC_RESULT_CODE,
802 ATP_EXTENDED_RESULT_CODE,
803 ATP_CONNECT_TXT_RESULT_CODE
804 } T_ATP_RESULT_CODE_FORMAT;
805
806 #define ATP_OK_PARAM (ATP_BASIC_RESULT_CODE)
807 #define ATP_CONNECT_PARAM (ATP_BASIC_RESULT_CODE)
808 #define ATP_RING_PARAM (ATP_BASIC_RESULT_CODE)
809 #define ATP_NO_CARRIER_PARAM (ATP_BASIC_RESULT_CODE)
810 #define ATP_ERROR_PARAM (ATP_BASIC_RESULT_CODE)
811 #define ATP_NO_DIALTONE_PARAM (ATP_BASIC_RESULT_CODE)
812 #define ATP_BUSY_PARAM (ATP_BASIC_RESULT_CODE)
813 #define ATP_NO_ANSWER_PARAM (ATP_BASIC_RESULT_CODE)
814 #define ATP_CONNECT_TXT_PARAM (ATP_CONNECT_TXT_RESULT_CODE)
815 #define ATP_PLUS_VGM_PARAM (ATP_EXTENDED_RESULT_CODE)
816 #define ATP_PLUS_VGS_PARAM (ATP_EXTENDED_RESULT_CODE)
817
818 #define ATP_RESULT_OFFSET_V0_COLUMN (0x00)
819 #define ATP_RESULT_OFFSET_V1_COLUMN (0x01)
820 #define ATP_RESULT_PARAM_COLUMN (0x02)
821
822 static const UINT8 ATP_RESULT_CODE_INFO[ATP_MAX_NB_OF_RESULT_CODES + 0x01][0x03] \
823 = {{ATP_OK_OFFSET_V0, ATP_OK_OFFSET_V1, ATP_OK_PARAM}, \
824 {ATP_CONNECT_OFFSET_V0, ATP_CONNECT_OFFSET_V1, ATP_CONNECT_PARAM}, \
825 {ATP_RING_OFFSET_V0, ATP_RING_OFFSET_V1, ATP_RING_PARAM}, \
826 {ATP_NO_CARRIER_OFFSET_V0, ATP_NO_CARRIER_OFFSET_V1, ATP_NO_CARRIER_PARAM}, \
827 {ATP_ERROR_OFFSET_V0, ATP_ERROR_OFFSET_V1, ATP_ERROR_PARAM}, \
828 {ATP_NO_DIALTONE_OFFSET_V0, ATP_NO_DIALTONE_OFFSET_V1, ATP_RESULT_CODE_NOT_DEFINED}, \
829 {ATP_NO_DIALTONE_OFFSET_V0, ATP_NO_DIALTONE_OFFSET_V1, ATP_NO_DIALTONE_PARAM}, \
830 {ATP_BUSY_OFFSET_V0, ATP_BUSY_OFFSET_V1, ATP_BUSY_PARAM}, \
831 {ATP_NO_ANSWER_OFFSET_V0, ATP_NO_ANSWER_OFFSET_V1, ATP_NO_ANSWER_PARAM}, \
832 {ATP_CONNECT_TXT_OFFSET_V0, ATP_CONNECT_TXT_OFFSET_V1, ATP_CONNECT_TXT_PARAM}, \
833 {ATP_PLUS_VGM_OFFSET_V0, ATP_PLUS_VGM_OFFSET_V1, ATP_PLUS_VGM_PARAM}, \
834 {ATP_PLUS_VGS_OFFSET_V0, ATP_PLUS_VGS_OFFSET_V1, ATP_PLUS_VGS_PARAM}, \
835 {ATP_RESULT_CODE_LAST_OFFSET_V0, ATP_RESULT_CODE_LAST_OFFSET_V1, ATP_RESULT_CODE_NOT_DEFINED}};
836
837 /* Define the maximum extended result code parameter length: */
838 /* - '=' + <value> (up to 65535). */
839 #define MAX_SINGLE_RESULT_CODE_VALUE_LEN (0x06)
840
841 /* Define the structure associated with extended result codes. The format of */
842 /* such result codes is <result_code>[=<value>] (See Headset Specification, */
843 /* Section 4.7.3). <value> shall consist of a numeric constant. */
844 typedef struct
845 {
846 UINT16 value;
847 } T_ATP_SINGLE_RESULT_CODE_VALUE;
848
849 /* Define all extended syntax result codes. */
850 /* __________________________________________________________________________ */
851 /* | | | | | | */
852 /* | Binary code | Len | Result code | Numeric | Description | */
853 /* |__________________|_____|_____________|_________|_________________________| */
854 /* | | | | | | */
855 /* | ATP_PLUS_VGM_NB | 4 | +VGM | X | Unsolicited result code | */
856 /* | | | | | issued by the AG to set | */
857 /* | | | | | the microphone gain of | */
858 /* | | | | | the HS (See Headset | */
859 /* | | | | | Specification, Section | */
860 /* | | | | | 4.7.3). | */
861 /* | ATP_PLUS_VGS_NB | 4 | +VGS | X | Unsolicited result code | */
862 /* | | | | | issued by the AG to set | */
863 /* | | | | | the speaker gain of the | */
864 /* | | | | | HS (See Headset | */
865 /* | | | | | Specification, Section | */
866 /* | | | | | 4.7.3). | */
867 /* |__________________|_____|_____________|_________|_________________________| */
868 typedef T_ATP_SINGLE_RESULT_CODE_VALUE T_ATP_PLUS_VGM_PARAM;
869 typedef T_ATP_SINGLE_RESULT_CODE_VALUE T_ATP_PLUS_VGS_PARAM;
870
871 /* Define the maximum number of characters appearing in the <text>. */
872 /* - '=' + <value> (up to 65535). */
873 #define MAX_CONNECT_TXT_LEN (MAX_SINGLE_RESULT_CODE_VALUE_LEN)
874
875 /* Define the structure associated with CONNECT<text> result code whose format */
876 /* is CONNECT <text> (See ITU-T Recommendation V.250 ter page 11). <text> */
877 /* should specify the baudrate (1200, 2400, 4800, 9600 ...). */
878 /* __________________________________________________________________________ */
879 /* | | | | | | */
880 /* | Binary code | Len | Result code | Numeric | Description | */
881 /* |__________________|_____|_____________|_________|_________________________| */
882 /* | | | | | | */
883 /* |ATP_CONNECT_TXT_NB| 7 | CONNECT | X | A connection has been | */
884 /* | | | | | established. | */
885 /* |__________________|_____|_____________|_________|_________________________| */
886 typedef T_ATP_SINGLE_RESULT_CODE_VALUE T_ATP_CONNECT_TXT_PARAM;
887
888 /************************************ MACROS ************************************/
889 /* */
890 /* Define a macro used to compare the first "count" characters of the two */
891 /* buffers "reference" and "buffer". The comparison is not case sensitive. Note */
892 /* that the "reference" must be in all caps. Therefore, the gap between */
893 /* alphabetic lower-case characters and their upper-case equivalents is 0x20 */
894 /* (See CCITT T.50 (1992), International Reference Alphabet). */
895 /* */
896 /* Prototype: */
897 /* ATP_MEM_I_CMP (T_ATP_TXT_CMD reference, */
898 /* T_ATP_TXT_CMD buffer, */
899 /* UINT8 count, */
900 /* BOOLEAN *equal); */
901 #define ATP_MEM_I_CMP(reference, \
902 buffer, \
903 count, \
904 equal) \
905 { \
906 UINT8 nb_byte = 0x00; \
907 while ((nb_byte < (count)) && \
908 (((buffer)[nb_byte] == (reference)[nb_byte]) || \
909 (((buffer)[nb_byte] >= 'a') && \
910 ((buffer)[nb_byte] <= 'z') && \
911 ((reference)[nb_byte] == ((buffer)[nb_byte] - '\x20'))))) \
912 { \
913 nb_byte++; \
914 } \
915 *(equal) = (BOOLEAN) ((nb_byte == (count)) ? (TRUE) : (FALSE)); \
916 }
917
918 /* Define a macro used to compare the first "count" characters of the two */
919 /* buffers "reference" and "buffer". The comparison is not case sensitive. */
920 /* Besides, space characters are ignored and may be used freely for formatting */
921 /* purposes (See ITU-T Recommendation V.250 ter page 4). Note that the */
922 /* "reference" must be in all caps. Therefore, the gap between alphabetic */
923 /* lower-case characters and their upper-case equivalents is 0x20 (See CCITT */
924 /* T.50 (1992), International Reference Alphabet). */
925 /* */
926 /* Prototype: */
927 /* ATP_MEM_SP_I_CMP (T_ATP_TXT_CMD reference, */
928 /* T_ATP_TXT_CMD buffer, */
929 /* UINT8 *count, */
930 /* BOOLEAN *equal); */
931 #define ATP_MEM_SP_I_CMP(reference, \
932 buffer, \
933 count, \
934 equal) \
935 { \
936 UINT8 nb_byte_ref = 0x00; \
937 UINT8 nb_byte_buf = 0x00; \
938 while ((nb_byte_ref < *(count)) && \
939 (((buffer)[nb_byte_buf] == '\x20') || \
940 ((buffer)[nb_byte_buf] == (reference)[nb_byte_ref]) || \
941 (((buffer)[nb_byte_buf] >= 'a') && \
942 ((buffer)[nb_byte_buf] <= 'z') && \
943 ((reference)[nb_byte_ref] == ((buffer)[nb_byte_buf] - '\x20'))))) \
944 { \
945 if ((buffer)[nb_byte_buf++] == '\x20') \
946 { \
947 continue; \
948 } \
949 nb_byte_ref++; \
950 } \
951 *(equal) = (BOOLEAN) ((nb_byte_ref == *(count)) ? (TRUE) : (FALSE)); \
952 *(count) = nb_byte_buf; \
953 }
954
955 /************************ MACROS DEDICATED TO AT COMMANDS ***********************/
956 /* */
957 /* Define a macro used to get the <number> of basic syntax commands. Note that */
958 /* <number> may be a string of one or more characters from "0" through "9" */
959 /* representing the decimal integer value (See ITU-T Recommendation V.250 ter */
960 /* page 5). Besides, if <number> is missing, the "initial_value" is assumed. */
961 /* */
962 /* Prototype: */
963 /* ATP_GET_NUMBER (T_ATP_TXT_CMD cmd_line_p, */
964 /* UINT16 *number_p, */
965 /* const char initial_value); */
966 #define ATP_GET_NUMBER(cmd_line_p, \
967 number_p, \
968 initial_value) \
969 { \
970 char nb_value_p[0x05] = {'\x00','\x00','\x00','\x00','\x00'}; \
971 UINT8 nb_digit = 0x00; \
972 for (*nb_value_p = initial_value; \
973 ((*(cmd_line_p) >= '0') && (*(cmd_line_p) <= '9')) || \
974 (*(cmd_line_p) == ' '); \
975 (cmd_line_p)++) \
976 { \
977 if (((*(cmd_line_p) == '0') && (nb_digit == 0x00)) || \
978 (*(cmd_line_p) == ' '))\
979 { \
980 continue; \
981 } \
982 nb_value_p[nb_digit++] = *(cmd_line_p); \
983 } \
984 *(number_p) = (UINT16) atoi (nb_value_p); \
985 }
986
987 /* Define a macro used to get the <dial_string> of dial (See ITU-T */
988 /* Recommendation V.250 ter page 31). All characters appearing on the same */
989 /* command line after D are considered part of the call addressing information */
990 /* to be signalled to the network, or modifiers used to control the signalling */
991 /* process, up to a semicolon character or the end of the command line. If the */
992 /* <dial_string> is terminated by a semicolon, the DCE does not start the call */
993 /* origination procedure, but instead returns to command state after completion */
994 /* of the signalling of call addressing information to the network. */
995 /* */
996 /* Prototype: */
997 /* ATP_GET_DIAL_STRING (T_ATP_TXT_CMD cmd_line_p, */
998 /* T_ATP_TXT_CMD dial_string_p, */
999 /* UINT8 *dial_string_length_p, */
1000 /* UINT8 *call_type_p, */
1001 /* const char termination_char); */
1002 #define ATP_GET_DIAL_STRING(cmd_line_p, \
1003 dial_string_p, \
1004 dial_string_length_p, \
1005 call_type_p, \
1006 termination_char) \
1007 { \
1008 *(call_type_p) = DATA_CALL; \
1009 *(dial_string_length_p) = 0x00; \
1010 while (*(cmd_line_p) != termination_char) \
1011 { \
1012 if (*(cmd_line_p) == ';') \
1013 { \
1014 *(call_type_p) = VOICE_CALL; \
1015 break; \
1016 } \
1017 (dial_string_p)[(*(dial_string_length_p))++] = *(cmd_line_p)++; \
1018 } \
1019 }
1020
1021 /* Define a macro used to get operators such as "=", "?" or "=?". */
1022 /* */
1023 /* Prototype: */
1024 /* ATP_GET_OPERATOR (T_ATP_TXT_CMD cmd_line_p, */
1025 /* T_ATP_EXTENDED_OPERATOR *s_operator_p); */
1026 #define ATP_GET_OPERATOR(cmd_line_p, \
1027 s_operator_p) \
1028 { \
1029 for (*(s_operator_p) = 0x00; \
1030 ((*(cmd_line_p) == '=') || (*(cmd_line_p) == '?') || \
1031 (*(cmd_line_p) == ' ')); \
1032 (cmd_line_p)++) \
1033 { \
1034 switch (*(cmd_line_p)) \
1035 { \
1036 case '?': \
1037 { \
1038 *(s_operator_p) += 0x01; \
1039 break; \
1040 } \
1041 case '=': \
1042 { \
1043 *(s_operator_p) += 0x02; \
1044 break; \
1045 } \
1046 default: \
1047 { \
1048 break; \
1049 } \
1050 } \
1051 } \
1052 }
1053
1054 /* Define a macro used to get the <value> of S-parameters. Note that <value> */
1055 /* shall consist of a decimal constant (See ITU-T Recommendation V.250 ter page */
1056 /* 6). */
1057 /* */
1058 /* Prototype: */
1059 /* ATP_GET_PARAMETER_VALUE (T_ATP_TXT_CMD cmd_line_p, */
1060 /* T_ATP_EXTENDED_OPERATOR *s_operator_p, */
1061 /* UINT16 *value_p); */
1062 #define ATP_GET_PARAMETER_VALUE(cmd_line_p, \
1063 s_operator_p, \
1064 value_p) \
1065 { \
1066 ATP_GET_OPERATOR((cmd_line_p), \
1067 (s_operator_p)); \
1068 ATP_GET_NUMBER((cmd_line_p), \
1069 (value_p), \
1070 '0'); \
1071 }
1072
1073 /* Define a macro used to proceed with subsequent commands that might follow an */
1074 /* extended syntax command (See ITU-T Recommendation V.250 ter page 9). */
1075 /* */
1076 /* Prototype: */
1077 /* ATP_GET_ADDITIONAL_CMD (T_ATP_TXT_CMD cmd_line_p, */
1078 /* const char termination_char); */
1079 #define ATP_GET_ADDITIONAL_CMD(cmd_line_p, \
1080 termination_char) \
1081 { \
1082 while (*(cmd_line_p) != termination_char) \
1083 { \
1084 if (*(cmd_line_p)++ == ';') \
1085 { \
1086 break; \
1087 } \
1088 } \
1089 }
1090
1091 /* Define a macro used to get the <value> of extended syntax commands. Note */
1092 /* that <value> shall consist of either a numeric constant or a string constant */
1093 /* (See ITU-T Recommendation V.250 ter page 6). However, only numeric constants */
1094 /* are supported for now. */
1095 /* */
1096 /* Prototype: */
1097 /* ATP_GET_VALUE (T_ATP_TXT_CMD cmd_line_p, */
1098 /* T_ATP_EXTENDED_OPERATOR *extended_operator_p, */
1099 /* UINT16 *value_p, */
1100 /* const char termination_char); */
1101 #define ATP_GET_VALUE(cmd_line_p, \
1102 extended_operator_p, \
1103 value_p, \
1104 termination_char) \
1105 { \
1106 ATP_GET_OPERATOR((cmd_line_p), \
1107 (extended_operator_p)); \
1108 ATP_GET_NUMBER((cmd_line_p), \
1109 (value_p), \
1110 '0'); \
1111 ATP_GET_ADDITIONAL_CMD((cmd_line_p), \
1112 (termination_char)); \
1113 }
1114
1115 /* Define a macro used to get the <keys> of keypad control command. Note that */
1116 /* <keys> shall consist of a string constant (See ETS 300 916 (GSM 07.07) */
1117 /* Version 5.8.1 page 62). Note also that <keys> is a string of characters */
1118 /* representing keys (See See ETS 300 916 (GSM 07.07) Version 5.8.1 page 62). */
1119 /* Colon character followed by one character can be used to indicate a */
1120 /* manufacturer specific key not listed here. All characters from a semicolon */
1121 /* character to the next single semicolon character are treated as alpha */
1122 /* entries and are not converted to key equivalents. All semicolon characters */
1123 /* inside alpha entries should be duplicated in the DTE. Pause characters "W" */
1124 /* and "w" can be used to pause between key pressings for a time specified by */
1125 /* <pause>. */
1126 /* */
1127 /* Prototype: */
1128 /* ATP_GET_KEYS (T_ATP_TXT_CMD cmd_line_p, */
1129 /* T_ATP_AT_PLUS_CKPD_PARAM *ckpd_param_p, */
1130 /* const char termination_char); */
1131 #define ATP_GET_KEYS(cmd_line_p, \
1132 ckpd_param_p, \
1133 termination_char) \
1134 { \
1135 ATP_GET_NUMBER((cmd_line_p), \
1136 &((ckpd_param_p)->keys[0x00]), \
1137 '0'); \
1138 (ckpd_param_p)->nb_keys = 0x01; \
1139 ATP_GET_ADDITIONAL_CMD((cmd_line_p), \
1140 (termination_char)); \
1141 }
1142 /* { \ */
1143 /* UINT8 nb_keys = 0x00; \ */
1144 /* while (*(cmd_line_p) != termination_char) \ */
1145 /* { \ */
1146 /* if (*(cmd_line_p)++ == '\"') \ */
1147 /* { \ */
1148 /* break; \ */
1149 /* } \ */
1150 /* } \ */
1151 /* while (*(cmd_line_p) != termination_char) \ */
1152 /* { \ */
1153 /* switch (*(cmd_line_p)++) \ */
1154 /* { \ */
1155 /* case ' ': \ */
1156 /* { \ */
1157 /* continue; \ */
1158 /* } \ */
1159 /* case ';': \ */
1160 /* { \ */
1161 /* ATP_GET_NUMBER((cmd_line_p), \ */
1162 /* &((ckpd_param_p)->keys[nb_keys]), \ */
1163 /* '0'); \ */
1164 /* nb_keys++; \ */
1165 /* while (*(cmd_line_p) != termination_char) \ */
1166 /* { \ */
1167 /* if (*(cmd_line_p)++ == ';') \ */
1168 /* { \ */
1169 /* break; \ */
1170 /* } \ */
1171 /* } \ */
1172 /* continue; \ */
1173 /* } \ */
1174 /* case ':': \ */
1175 /* { \ */
1176 /* while (*(cmd_line_p) != termination_char) \ */
1177 /* { \ */
1178 /* if (*(cmd_line_p)++ == ':') \ */
1179 /* { \ */
1180 /* break; \ */
1181 /* } \ */
1182 /* } \ */
1183 /* continue; \ */
1184 /* } \ */
1185 /* case '\"': \ */
1186 /* { \ */
1187 /* break; \ */
1188 /* } \ */
1189 /* default: \ */
1190 /* { \ */
1191 /* (ckpd_param_p)->keys[nb_keys] = (UINT16) (*(cmd_line_p - 0x01)); \ */
1192 /* nb_keys++; \ */
1193 /* continue; \ */
1194 /* } \ */
1195 /* } \ */
1196 /* break; \ */
1197 /* } \ */
1198 /* (ckpd_param_p)->nb_keys = nb_keys; \ */
1199 /* } */
1200
1201 /* Define a macro used to proceed with subsequent numeric and string values */
1202 /* that might appear in a compound value (See ITU-T Recommendation V.250 ter */
1203 /* page 7). */
1204 /* */
1205 /* Prototype: */
1206 /* ATP_GET_ADDITIONAL_VALUE (T_ATP_TXT_CMD cmd_line_p, */
1207 /* const char termination_char); */
1208 #define ATP_GET_ADDITIONAL_VALUE(cmd_line_p, \
1209 termination_char) \
1210 { \
1211 while (*(cmd_line_p) != termination_char) \
1212 { \
1213 switch (*(cmd_line_p)) \
1214 { \
1215 case ',': \
1216 { \
1217 cmd_line_p++; \
1218 } \
1219 case ';': \
1220 { \
1221 break; \
1222 } \
1223 default: \
1224 { \
1225 cmd_line_p++; \
1226 continue; \
1227 } \
1228 } \
1229 break; \
1230 } \
1231 }
1232
1233 /* Define a macro used to get the <keys>,<time> and <pause> of keypad control */
1234 /* command. Note that <keys> shall consist of a string constant and <time> and */
1235 /* <pause> shall consist of numeric constants in tenths of a second (See ETS */
1236 /* 300 916 (GSM 07.07) Version 5.8.1 page 62). */
1237 /* */
1238 /* Prototype: */
1239 /* ATP_GET_CKPD_PARAM (T_ATP_TXT_CMD cmd_line_p, */
1240 /* T_ATP_AT_PLUS_CKPD_PARAM *ckpd_param_p, */
1241 /* const char termination_char); */
1242 #define ATP_GET_CKPD_PARAM(cmd_line_p, \
1243 ckpd_param_p, \
1244 termination_char) \
1245 { \
1246 ATP_GET_OPERATOR((cmd_line_p), \
1247 &((ckpd_param_p)->extended_operator)); \
1248 ATP_GET_KEYS((cmd_line_p), \
1249 (ckpd_param_p), \
1250 (termination_char)); \
1251 ATP_GET_ADDITIONAL_VALUE((cmd_line_p), \
1252 (termination_char)); \
1253 ATP_GET_NUMBER((cmd_line_p), \
1254 &((ckpd_param_p)->time), \
1255 '0'); \
1256 ATP_GET_ADDITIONAL_VALUE((cmd_line_p), \
1257 (termination_char)); \
1258 ATP_GET_NUMBER((cmd_line_p), \
1259 &((ckpd_param_p)->pause), \
1260 '0'); \
1261 ATP_GET_ADDITIONAL_CMD((cmd_line_p), \
1262 (termination_char)); \
1263 }
1264
1265 /************************ MACRO DEDICATED TO RESULT CODES ***********************/
1266 /* */
1267 /* Define a macro used to get the <value> associated with extended result codes */
1268 /* (See Headset Specification, Section 4.7.3). Note that <value> shall consist */
1269 /* of a numeric constant. */
1270 /* */
1271 /* Prototype: */
1272 /* ATP_GET_RESULT_CODE_VALUE (T_ATP_TXT_CMD cmd_line_p, */
1273 /* UINT16 *value_p); */
1274 #define ATP_GET_RESULT_CODE_VALUE(cmd_line_p, \
1275 value_p) \
1276 { \
1277 UINT8 result_operator = 0x00; \
1278 ATP_GET_OPERATOR((cmd_line_p), \
1279 &result_operator); \
1280 ATP_GET_NUMBER((cmd_line_p), \
1281 (value_p), \
1282 '0'); \
1283 }
1284
1285 /* Define a macro used to get the <text> associated with CONNECT <text> result */
1286 /* code (See ITU-T Recommendation V.250 ter page 11). */
1287 /* */
1288 /* Prototype: */
1289 /* ATP_GET_CONNECT_TXT (T_ATP_TXT_CMD cmd_line_p, */
1290 /* UINT16 *value_p); */
1291 #define ATP_GET_CONNECT_TXT(cmd_line_p, \
1292 value_p) \
1293 { \
1294 ATP_GET_NUMBER((cmd_line_p), \
1295 (value_p), \
1296 '0'); \
1297 }
1298
1299 /************************** MACRO DEDICATED TO RAW DATA *************************/
1300 /* */
1301 /* Define a macro used to get the length of unknown commands from raw data, */
1302 /* <CR> not included. Note that all characters appearing on the same command */
1303 /* line are considered part of the unknown command, up to the end of the */
1304 /* command line. */
1305 /* */
1306 /* Prototype: */
1307 /* ATP_GET_UNKNOWN_CMD_LEN (T_ATP_TXT_CMD cmd_line_p, */
1308 /* UINT8 *cmd_length_p); */
1309 /* const char termination_char); */
1310 #define ATP_GET_UNKNOWN_CMD_LEN(cmd_line_p, \
1311 cmd_length_p, \
1312 termination_char) \
1313 { \
1314 for (*(cmd_length_p) = 0x00; \
1315 (cmd_line_p)[*(cmd_length_p)] != termination_char; \
1316 (*(cmd_length_p))++) \
1317 { \
1318 } \
1319 }
1320
1321 /* Define a macro used to get the length of unknown AT commands from raw data, */
1322 /* <CR> or semicolon not included. Note that all characters appearing on the */
1323 /* same command line are considered part of the unknown command, up to a */
1324 /* semicolon character or the end of the command line. */
1325 /* */
1326 /* Prototype: */
1327 /* ATP_GET_UNKNOWN_AT_CMD_LEN (T_ATP_TXT_CMD cmd_line_p, */
1328 /* UINT8 *cmd_length_p); */
1329 /* const char termination_char); */
1330 #define ATP_GET_UNKNOWN_AT_CMD_LEN(cmd_line_p, \
1331 cmd_length_p, \
1332 termination_char) \
1333 { \
1334 for (*(cmd_length_p) = 0x00; \
1335 ((cmd_line_p)[*(cmd_length_p)] != termination_char) && \
1336 ((cmd_line_p)[*(cmd_length_p)] != ';'); \
1337 (*(cmd_length_p))++) \
1338 { \
1339 } \
1340 }
1341
1342 #endif
1343