FreeCalypso > hg > tcs211-fcmodem
comparison chipsetsw/services/cst/cst_exts.c @ 0:509db1a7b7b8
initial import: leo2moko-r1
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Mon, 01 Jun 2015 03:24:05 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:509db1a7b7b8 |
---|---|
1 /* | |
2 +--------------------------------------------------------------------+ | |
3 | PROJECT: GSM-F&D (8411) $Workfile:: CST_EXTS.C $| | |
4 | $Author:: Sa $ CONDAT GmbH $Revision:: 7 $| | |
5 | CREATED: 03.08.99 $Modtime:: 14.02.00 16:06 $| | |
6 | STATE : code | | |
7 +--------------------------------------------------------------------+ | |
8 | |
9 | |
10 MODULE : CST_EXTS | |
11 | |
12 PURPOSE : This Modul defines the custom specific AT commands | |
13 */ | |
14 | |
15 #ifndef CST_EXTS_C | |
16 #define CST_EXTS_C | |
17 #endif | |
18 | |
19 | |
20 #include "config/swconfig.cfg" | |
21 #include "config/chipset.cfg" | |
22 #include "config/l1sw.cfg" | |
23 | |
24 | |
25 | |
26 #define ENTITY_CST | |
27 /*==== INCLUDES ===================================================*/ | |
28 | |
29 #include <stdlib.h> | |
30 #include <string.h> | |
31 #include <stdio.h> | |
32 #include "typedefs.h" | |
33 #include "m_sms.val" | |
34 #include "m_fac.h" | |
35 #include "p_mnsms.h" | |
36 #include "p_mmreg.h" | |
37 #include "p_mncc.h" | |
38 #include "aci_cmh.h" | |
39 #include "vsi.h" | |
40 #include "gsm.h" | |
41 #include "p_cst.h" | |
42 #include "cst/cst.h" | |
43 #include "custom.h" | |
44 | |
45 #ifdef ALR | |
46 #include "main/sys_ver.h" | |
47 #endif | |
48 | |
49 /*==== MELODY TEST ==================================================*/ | |
50 | |
51 #define MELODY_E1 0 | |
52 | |
53 extern void enable_tch_vocoder(BOOL vocoder); | |
54 | |
55 #if (MELODY_E1) | |
56 extern void audio_melo_e1_demo1_start(void); | |
57 extern void audio_melo_e1_demo1_stop(void); | |
58 extern void audio_melo_e1_demo2_start(void); | |
59 extern void audio_melo_e1_demo2_stop(void); | |
60 #endif | |
61 | |
62 #if (MELODY_E2) | |
63 extern void audio_melo_e2_load_lsi(void); | |
64 extern void audio_melo_e2_demo1_start(void); | |
65 extern void audio_melo_e2_demo1_stop(void); | |
66 extern void audio_melo_e2_demo2_start(void); | |
67 extern void audio_melo_e2_demo2_stop(void); | |
68 #endif | |
69 | |
70 | |
71 | |
72 /*==== CONSTANTS ==================================================*/ | |
73 | |
74 #define EXT_ATD "EXT: D, I" | |
75 #define EXT_ATCFUN "EXT: +CFUN, I" | |
76 #define EXT_ATCOPS_START "EXT: +COPS, I" | |
77 #define EXT_ATCOPS_STOP "EXT: +COPS, O" | |
78 #define EXT_ENTER "EXT: I" | |
79 #define EXT_LEAVE "EXT: O" | |
80 #define EXT_UNEXPCTD "EXT: E" | |
81 | |
82 #define EXT_DIAL_VOICE_PASS "DVCP" | |
83 | |
84 #define EXT_MAX_BUF_LEN 41 | |
85 | |
86 #define EXT_VOICE_DELIMITER ';' | |
87 | |
88 /*==== EXPORT =====================================================*/ | |
89 | |
90 /*==== TYPES ======================================================*/ | |
91 | |
92 #ifndef WIN32 | |
93 extern USHORT IQ_GetBuild(void); | |
94 #ifndef ALR | |
95 extern USHORT IQ_GetPoleStarVersion(void); | |
96 #endif | |
97 extern USHORT IQ_GetJtagId(void); | |
98 extern USHORT IQ_GetRevision(void); | |
99 extern void l1dmacro_init_hw(void); | |
100 | |
101 extern BOOL SER_WriteConfig (char *new_config, | |
102 BOOL write_to_flash); | |
103 extern BOOL SER_ImmediateSwitch (void); | |
104 #endif | |
105 | |
106 LOCAL CHAR* percentCFG ( CHAR* cmd ); | |
107 LOCAL CHAR* percentDBG ( CHAR* cmd ); | |
108 LOCAL void ext_LeaveEXT ( BOOL final ); | |
109 LOCAL void ext_CreatePString ( CHAR* buffer, | |
110 CHAR* text ); | |
111 GLOBAL void ext_ContinueTest ( CHAR* id ); | |
112 | |
113 /*==== VARIABLES ==================================================*/ | |
114 | |
115 LOCAL CHAR* extCmd; /* remaining unparsed command string, */ | |
116 /* will be needed in case of asynchronous */ | |
117 /* command handling */ | |
118 LOCAL USHORT extCmdLen; /* length of command string, will be */ | |
119 /* needed in case of asynchronous */ | |
120 /* command handling */ | |
121 LOCAL CHAR extBuffer[EXT_MAX_BUF_LEN]; /* outbut buffer */ | |
122 | |
123 LOCAL CHAR extDialNum[MAX_PHB_NUM_LEN]; | |
124 /* number to be dialled during testing */ | |
125 GLOBAL SHORT extCallId = ACI_NumParmNotPresent; | |
126 /* identifier of the call which was */ | |
127 /* set-up using AT extension mechansim */ | |
128 GLOBAL T_ACI_AT_CMD currExtCmd = AT_CMD_NONE; | |
129 /* used for indicating asynchronous */ | |
130 /* command handling */ | |
131 LOCAL T_ACI_AT_CMD currAbrtCmd = AT_CMD_NONE; | |
132 /* used for indicating abort of */ | |
133 /* asynchronous command handling */ | |
134 | |
135 /*==== FUNCTIONS ==================================================*/ | |
136 | |
137 USHORT * csf_return_adc (void); | |
138 | |
139 /* | |
140 +--------------------------------------------------------------------+ | |
141 | PROJECT : GSM-PS (8403) MODULE : TIL_CSF | | |
142 | STATE : code ROUTINE : cmh_show_version | | |
143 +--------------------------------------------------------------------+ | |
144 | |
145 PURPOSE : Trace Layer 1 DSP version numbers | |
146 | |
147 */ | |
148 | |
149 #ifndef WIN32 | |
150 | |
151 | |
152 static void jtagid_to_chipset (USHORT jtagid, CHAR *chipset) | |
153 { | |
154 | |
155 switch (jtagid) { | |
156 | |
157 case 0xB268: | |
158 | |
159 strcpy (chipset, "Hercules"); | |
160 break; | |
161 | |
162 case 0xB2B5: | |
163 | |
164 strcpy (chipset, "Ulysse 1Mbits rev. B"); | |
165 break; | |
166 | |
167 case 0xB335: | |
168 | |
169 strcpy (chipset, "Ulysse 1Mbits rev. A"); | |
170 break; | |
171 | |
172 case 0xB334: | |
173 | |
174 strcpy (chipset, "Ulysse 2Mbits"); | |
175 break; | |
176 | |
177 case 0xB393: | |
178 | |
179 strcpy (chipset, "Ulysse G1"); | |
180 break; | |
181 | |
182 | |
183 case 0xB396: | |
184 | |
185 strcpy (chipset, "Calypso rev. B"); | |
186 break; | |
187 | |
188 case 0xB2AC: | |
189 | |
190 // Samson and Calypso rev. A share the same JTAG ID. | |
191 #if (CHIPSET != 7) | |
192 strcpy (chipset, "Samson"); | |
193 #else | |
194 strcpy (chipset, "Calypso rev. A"); | |
195 #endif | |
196 break; | |
197 | |
198 case 0xB217: | |
199 | |
200 strcpy (chipset, "Ulysse C035"); | |
201 break; | |
202 | |
203 case 0xB496: | |
204 | |
205 strcpy (chipset, "Calypso C035"); | |
206 break; | |
207 | |
208 case 0xB4FB: | |
209 | |
210 strcpy (chipset, "Calypso Lite C035"); | |
211 break; | |
212 | |
213 default: | |
214 | |
215 strcpy (chipset, "Unknown"); | |
216 break; | |
217 } | |
218 } | |
219 | |
220 GLOBAL void cmh_show_version ( | |
221 CHAR *command, | |
222 USHORT *len, | |
223 CHAR *output | |
224 ) | |
225 { | |
226 #ifndef ALR | |
227 CHAR buf[80]; | |
228 USHORT build, hw, rev; | |
229 #else | |
230 CHAR buf[160]; | |
231 CHAR chipset[25]; | |
232 #endif | |
233 USHORT jtag; | |
234 UCHAR size; | |
235 | |
236 /* | |
237 * Retrieve hardware JTAG ID info | |
238 */ | |
239 jtag = IQ_GetJtagId(); | |
240 | |
241 #ifndef ALR | |
242 /* | |
243 * Retrieve others hardware info and build from library | |
244 */ | |
245 build = IQ_GetBuild(); | |
246 hw = IQ_GetPoleStarVersion(); | |
247 rev = IQ_GetRevision(); | |
248 | |
249 sprintf (buf, "Build %d, Silicon Revision %04X/%04X/%04X", | |
250 build, hw, jtag, rev); | |
251 #else | |
252 | |
253 /* | |
254 * Retrieve CHIPSET name from JTAG ID | |
255 */ | |
256 jtagid_to_chipset (jtag, chipset); | |
257 | |
258 sprintf (buf, | |
259 "Chipset Version:\n\r\t%s\n\rS/W Versions:\n\n\r\tLayer1\t%4X_%3X\n\r\tLayer2-3 %3XBERLIN_S420\n\r\tNICE\t %3X_I64", | |
260 chipset, | |
261 OFFICIAL_VERSION, | |
262 INTERNAL_VERSION, | |
263 G23VERSION, | |
264 SYSTEMVERSION); | |
265 #endif | |
266 | |
267 // Format output as a list of Pascal-like strings | |
268 size = strlen(buf); | |
269 output[0] = size; | |
270 strcpy(&(output[1]), buf); | |
271 output[size+1] = (CHAR) 0xFF; // terminate list of strings | |
272 } | |
273 | |
274 #endif /* #ifndef WIN32 */ | |
275 | |
276 | |
277 | |
278 /* | |
279 +--------------------------------------------------------------------+ | |
280 | PROJECT : GSM-PS (8403) MODULE : TIL_CSF | | |
281 | STATE : code ROUTINE : show_adc_conversion | | |
282 +--------------------------------------------------------------------+ | |
283 | |
284 PURPOSE : Trace Layer 1 AD conversions results | |
285 | |
286 */ | |
287 | |
288 GLOBAL void show_adc_conversion (CHAR *output) | |
289 { | |
290 USHORT * adc_conversion; | |
291 #ifdef ALR | |
292 CHAR buf[160]; | |
293 #else | |
294 CHAR buf[80]; | |
295 #endif | |
296 UCHAR size; | |
297 | |
298 adc_conversion = csf_return_adc (); | |
299 #ifdef ALR | |
300 sprintf (buf, "ADC 0 = %x, ADC 1 = %x, ADC 2 = %x, ADC 3 = %x, ADC 4 = %x, ADC 5 = %x, ADC 6 = %x, ADC 7 = %x, ADC 8 = %x", | |
301 *adc_conversion++, *adc_conversion++, *adc_conversion++, | |
302 *adc_conversion++, *adc_conversion++, *adc_conversion++, | |
303 *adc_conversion++, *adc_conversion++, *adc_conversion); | |
304 | |
305 #else | |
306 sprintf (buf, "ADC 0 = %x, ADC 1 = %x, ADC 2 = %x, ADC 3 = %x, ADC 4 = %x", | |
307 *adc_conversion++, *adc_conversion++, *adc_conversion++, | |
308 *adc_conversion++, *adc_conversion); | |
309 #endif | |
310 | |
311 // Format output as a list of Pascal-like strings | |
312 size = strlen(buf); | |
313 output[0] = size; | |
314 strcpy(&(output[1]), buf); | |
315 output[size+1] = (CHAR) 0xFF; // terminate list of strings | |
316 } | |
317 | |
318 | |
319 /* | |
320 +--------------------------------------------------------------------+ | |
321 | PROJECT : GSM-PS (8403) MODULE : CST_EXTS | | |
322 | STATE : code ROUTINE : AEC_Enable | | |
323 +--------------------------------------------------------------------+ | |
324 | |
325 PURPOSE : activate the Acoustic Echo Cancelation | |
326 | |
327 */ | |
328 | |
329 GLOBAL void AEC_Enable (CHAR *command, CHAR *output) | |
330 { | |
331 | |
332 /* -------------------------------------------------------------------------- */ | |
333 /* MMI_AEC_REQ : 0283 = Long AEC, 105 = SPENH, 187 = AEC+SPENH, 1 = STOP */ | |
334 /* aec_control register bits | 0 0 Sa t2|t1 g3 g2 g1|g0 e2 e1 ak| */ | |
335 /* bit 0 : ACK bit : set to 1 in order to warn DSP that a new command */ | |
336 /* is present. */ | |
337 /* bit 1 : enable AEC */ | |
338 /* bit 2 : enable SPENH (= Speech Enhancement = noise reduction) */ | |
339 /* bit 3 : additionnal AEC gain attenuation (lsb) */ | |
340 /* bit 4 : additionnal AEC gain attenuation (msb) */ | |
341 /* bit 5 : additionnal SPENH gain attenuation (lsb) */ | |
342 /* bit 6 : additionnal SPENH gain attenuation (msb) */ | |
343 /* bit 7 : reset trigger for AEC */ | |
344 /* bit 8 : reset trigger for SPENH */ | |
345 /* bit 9 : AEC selector 0 : short AEC, 1 : long AEC */ | |
346 /* */ | |
347 /* for Short AEC 0083 */ | |
348 /* for long AEC 0283 */ | |
349 /* for long AEC -6 dB 028B */ | |
350 /* for long AEC -12 dB 0293 */ | |
351 /* for long AEC -18 dB 029B */ | |
352 /* for SPENH 0105 */ | |
353 /* for SPENH -6 dB 0125 */ | |
354 /* for SPENH -12 dB 0145 */ | |
355 /* for SPENH -18 dB 0165 */ | |
356 /* for BOTH 0187 */ | |
357 /* for STOP ALL 0001 (all bits reset + ACK to 1 to warn the DSP) */ | |
358 /* -------------------------------------------------------------------------- */ | |
359 | |
360 | |
361 command++; /* increment command pointer to point on the hexa value of the command */ | |
362 | |
363 | |
364 if (!strncmp(command, "0083", 4)) | |
365 { | |
366 output[0] = strlen ("Short AEC is active"); | |
367 memcpy (&output[1], "Short AEC is active", 19); | |
368 | |
369 /* end of string list */ | |
370 output [20] = (CHAR) 0xff; | |
371 csf_aec_enable(0x0083); | |
372 } | |
373 | |
374 else if (!strncmp(command, "0283", 4)) | |
375 { | |
376 output[0] = strlen ("Long AEC is active"); | |
377 memcpy (&output[1], "Long AEC is active", 18); | |
378 | |
379 /* end of string list */ | |
380 output [19] = (CHAR) 0xff; | |
381 csf_aec_enable(0x0283); | |
382 } | |
383 | |
384 else if (!strncmp(command, "028B", 4)) | |
385 { | |
386 output[0] = strlen ("Long AEC -6 dB is active"); | |
387 memcpy (&output[1], "Long AEC -6 dB is active", 24); | |
388 | |
389 /* end of string list */ | |
390 output [25] = (CHAR) 0xff; | |
391 csf_aec_enable(0x028B); | |
392 } | |
393 | |
394 else if (!strncmp(command, "0293", 4)) | |
395 { | |
396 output[0] = strlen ("Long AEC -12 dB is active"); | |
397 memcpy (&output[1], "Long AEC -12 dB is active", 25); | |
398 | |
399 /* end of string list */ | |
400 output [26] = (CHAR) 0xff; | |
401 csf_aec_enable(0x0293); | |
402 } | |
403 | |
404 else if (!strncmp(command, "029B", 4)) | |
405 { | |
406 output[0] = strlen ("Long AEC -18 dB is active"); | |
407 memcpy (&output[1], "Long AEC -18 dB is active", 25); | |
408 | |
409 /* end of string list */ | |
410 output [26] = (CHAR) 0xff; | |
411 csf_aec_enable(0x029B); | |
412 } | |
413 | |
414 else if (!strncmp(command, "0105", 4)) | |
415 { | |
416 output[0] = strlen ("Noise reduction is active"); | |
417 memcpy (&output[1], "Noise reduction is active", 25); | |
418 | |
419 /* end of string list */ | |
420 output [26] = (CHAR) 0xff; | |
421 csf_aec_enable(0x0105); | |
422 } | |
423 | |
424 else if (!strncmp(command, "0125", 4)) | |
425 { | |
426 output[0] = strlen ("Noise reduction -6 dB is active"); | |
427 memcpy (&output[1], "Noise reduction -6 dB is active", 31); | |
428 | |
429 /* end of string list */ | |
430 output [32] = (CHAR) 0xff; | |
431 csf_aec_enable(0x0125); | |
432 } | |
433 | |
434 else if (!strncmp(command, "0145", 4)) | |
435 { | |
436 output[0] = strlen ("Noise reduction -12 dB is active"); | |
437 memcpy (&output[1], "Noise reduction -12 dB is active", 32); | |
438 | |
439 /* end of string list */ | |
440 output [33] = (CHAR) 0xff; | |
441 csf_aec_enable(0x0145); | |
442 } | |
443 | |
444 else if (!strncmp(command, "0165", 4)) | |
445 { | |
446 output[0] = strlen ("Noise reduction -18 dB is active"); | |
447 memcpy (&output[1], "Noise reduction -18 dB is active", 32); | |
448 | |
449 /* end of string list */ | |
450 output [33] = (CHAR) 0xff; | |
451 csf_aec_enable(0x0165); | |
452 } | |
453 | |
454 else if (!strncmp(command, "0187", 4)) | |
455 { | |
456 output[0] = strlen ("Both AEC and Noise reduction are active"); | |
457 memcpy (&output[1], "Both AEC and Noise reduction are active", 39); | |
458 | |
459 /* end of string list */ | |
460 output [40] = (CHAR) 0xff; | |
461 csf_aec_enable(0x0187); | |
462 } | |
463 | |
464 else if (!strncmp(command, "0001", 4)) | |
465 { | |
466 output[0] = strlen ("AEC and Noise reduction are unactivated"); | |
467 memcpy (&output[1], "AEC and Noise reduction are unactivated", 39); | |
468 | |
469 /* end of string list */ | |
470 output [40] = (CHAR) 0xff; | |
471 csf_aec_enable(0x0001); | |
472 } | |
473 | |
474 else | |
475 { | |
476 output[0] = strlen ("Bad AT command"); | |
477 memcpy (&output[1], "Bad AT command", 14); | |
478 | |
479 /* end of string list */ | |
480 output [15] = (CHAR) 0xff; | |
481 } | |
482 | |
483 } | |
484 | |
485 | |
486 | |
487 | |
488 /* | |
489 +--------------------------------------------------------------------+ | |
490 | PROJECT : GSM-PS (6147) MODULE : CST_EXTS | | |
491 | STATE : code ROUTINE : rAT_EXT | | |
492 +--------------------------------------------------------------------+ | |
493 | |
494 PURPOSE : This function is called by the interpreter part of the | |
495 ACI in case of the detection of an unknown command. | |
496 | |
497 <cmd> : remaining unparsed command string. | |
498 <cmdLen> : length of command string. This value must be | |
499 incremented by the amount of parsed characters | |
500 by this function. | |
501 <out> : this parameter can be used to display some | |
502 strings at the AT command interface. | |
503 The first char of one string must contain | |
504 the length of the following string. The | |
505 special length 0xff must be used to define | |
506 the end of the string list. | |
507 <outLen> : maximum length of output buffer referenced | |
508 by parameter <out>. | |
509 | |
510 */ | |
511 | |
512 GLOBAL T_ACI_RETURN rAT_EXT ( | |
513 CHAR* cmd, | |
514 USHORT* cmdLen, | |
515 CHAR* out, | |
516 USHORT outLen | |
517 ) | |
518 { | |
519 /* | |
520 * store command string in case it will be needed later on, when | |
521 * result code of this function is equal to AT_EXCT | |
522 */ | |
523 extCmd = cmd; | |
524 extCmdLen = *cmdLen; | |
525 | |
526 /* | |
527 * example how to send an unsolicited result code via the AT interface | |
528 */ | |
529 ext_CreatePString ( extBuffer, EXT_ENTER ); | |
530 | |
531 sAT_URC ( extBuffer ); | |
532 | |
533 /* | |
534 * example how to process the command AT%H | |
535 */ | |
536 if (*cmd == '%') | |
537 { | |
538 cmd++; | |
539 | |
540 switch (*cmd) | |
541 { | |
542 case 'A': | |
543 /* | |
544 * Display AD conversions results | |
545 */ | |
546 *cmdLen -= 2; | |
547 show_adc_conversion(out); | |
548 return( AT_CMPL ); | |
549 | |
550 case 'C': | |
551 case 'c': | |
552 case 'D': | |
553 case 'd': | |
554 { | |
555 CHAR* nextCmd; | |
556 | |
557 *cmdLen -= 2; | |
558 | |
559 switch ( *cmd ) | |
560 { | |
561 case 'C': | |
562 case 'c': | |
563 /* dynamic configuration via AT command interface */ | |
564 nextCmd = percentCFG ( ++cmd ); | |
565 | |
566 break; | |
567 | |
568 case 'D': | |
569 case 'd': | |
570 /* set debug pin for reset purposes */ | |
571 nextCmd = percentDBG ( ++cmd ); | |
572 | |
573 break; | |
574 } | |
575 | |
576 *out = ( CHAR ) 0xFF; | |
577 | |
578 if ( nextCmd EQ NULL ) | |
579 { | |
580 return ( AT_FAIL ); | |
581 } | |
582 else | |
583 { | |
584 *cmdLen -= ( nextCmd - cmd ); | |
585 | |
586 return ( AT_CMPL ); | |
587 } | |
588 } | |
589 | |
590 case 'N': | |
591 /* | |
592 * Enables the AEC by sending a primitive to L1A | |
593 */ | |
594 *cmdLen -= 6; | |
595 AEC_Enable(cmd, out); | |
596 return( AT_CMPL ); | |
597 | |
598 //---------------------------------------------------------------------------// | |
599 // Added by Matthieu Vanin for the test of melody E2/E1 | |
600 //---------------------------------------------------------------------------// | |
601 | |
602 | |
603 | |
604 // End | |
605 //---------------------------------------------------------------------------// | |
606 case 'S': | |
607 case 's': | |
608 { | |
609 cmd++; | |
610 | |
611 switch (*cmd) { | |
612 | |
613 case 'e': | |
614 case 'E': | |
615 /* 's''e' already detected => assume the command is at%ser. */ | |
616 { | |
617 cmd += 3; /* Discard the following characters */ | |
618 *cmdLen -= 9; | |
619 if (SER_WriteConfig (cmd, (BOOL) (*(cmd + 3) - '0'))) | |
620 return( AT_CMPL ); | |
621 else | |
622 return( AT_FAIL ); | |
623 } | |
624 | |
625 case 'w': | |
626 case 'W': | |
627 /* 's''w' already detected => assume the command is at%switch. */ | |
628 { | |
629 *cmdLen -= 7; | |
630 if (SER_ImmediateSwitch()) | |
631 return( AT_CMPL ); | |
632 else | |
633 return( AT_FAIL ); | |
634 } | |
635 | |
636 case 'l': | |
637 case 'L': | |
638 /* 's''l' already detected => assume the command is at%sleep. */ | |
639 { | |
640 cmd += 5; /* Discard the following characters */ | |
641 *cmdLen -= 8; | |
642 /* | |
643 * Checks if the parameter is valid: | |
644 * 0 -> NO_SLEEP | |
645 * 1 -> SMALL_SLEEP | |
646 * 2 -> BIG_SLEEP | |
647 * 3 -> DEEP_SLEEP | |
648 * 4 -> ALL_SLEEP | |
649 */ | |
650 | |
651 if (((*cmd - '0') >= 0) && ((*cmd - '0') <= 4)) | |
652 { | |
653 power_down_config ((UBYTE) (*cmd - '0'), UWIRE_CLK_CUT); | |
654 return( AT_CMPL ); | |
655 } | |
656 else | |
657 return( AT_FAIL ); | |
658 } | |
659 | |
660 default: | |
661 *cmdLen -= 2; | |
662 return ( AT_FAIL ); | |
663 | |
664 } | |
665 } | |
666 | |
667 case 'H': | |
668 *cmdLen -= 2; | |
669 | |
670 /* | |
671 * here you can perform some actions with drivers etc. | |
672 */ | |
673 | |
674 /* | |
675 * and create some additional output at the AT interface | |
676 * The strings: | |
677 *"Hello" | |
678 *"" | |
679 *"World" | |
680 * will be displayed at the terminal. | |
681 * | |
682 * first string Hello | |
683 */ | |
684 out[0] = strlen ("Hello"); | |
685 memcpy (&out[1], "Hello", 5); | |
686 /* | |
687 * add a spare line with an empty string | |
688 */ | |
689 out [6] = 0; | |
690 /* | |
691 * second string World | |
692 */ | |
693 out [7] = strlen ("World"); | |
694 memcpy (&out[8], "World", 5); | |
695 | |
696 /* | |
697 * end of string list | |
698 */ | |
699 out [13] = (CHAR) 0xff; | |
700 return( AT_CMPL ); | |
701 | |
702 #ifndef WIN32 | |
703 case 'R': | |
704 case 'r': | |
705 *cmdLen -= 2; | |
706 l1dmacro_init_hw(); | |
707 out[0] = 0; | |
708 out[1] = (CHAR) 0xFF; | |
709 return( AT_CMPL ); | |
710 #endif | |
711 | |
712 #ifndef WIN32 | |
713 case 'V': | |
714 case 'v': | |
715 *cmdLen -= 2; | |
716 | |
717 /* | |
718 * Display version numbers | |
719 */ | |
720 | |
721 cmh_show_version (cmd, cmdLen, out); | |
722 return( AT_CMPL ); | |
723 #endif | |
724 #if defined (ALR) | |
725 case 'T': | |
726 case 't': | |
727 /* | |
728 * Enables RTC or AUDIO tests | |
729 */ | |
730 cmd++; | |
731 *cmdLen -= 3; | |
732 if (!strncmp(cmd, "A", 1) || !strncmp(cmd, "a", 1)) | |
733 { | |
734 //audio_test_misc(); | |
735 out[0] = 22; | |
736 memcpy (&out[1], "Performing Audio Tests", 22); | |
737 out [23] = (CHAR) 0xff; | |
738 } | |
739 else | |
740 { | |
741 if (!strncmp(cmd, "R", 1) || !strncmp(cmd, "r", 1)) | |
742 { | |
743 //rtc_test_misc(); | |
744 out[0] = 20; | |
745 memcpy (&out[1], "Performing RTC Tests", 20); | |
746 out [21] = (CHAR) 0xff; | |
747 } | |
748 else | |
749 return( AT_FAIL ); | |
750 } | |
751 return( AT_CMPL ); | |
752 #endif | |
753 default: | |
754 *cmdLen -= 2; | |
755 return ( AT_FAIL ); | |
756 } | |
757 } | |
758 else if ( *cmd EQ 'D' ) | |
759 { | |
760 T_ACI_RETURN rslt; | |
761 | |
762 /* | |
763 * this is only a test implementation. As soon as a "ATD" command | |
764 * string is detected in the AT interpreter and the mobile is not | |
765 * yet registered (neither limited nor full service is availbale) | |
766 * this function is called. Then instead of dialling immediately | |
767 * an activation of the mobile is performed in advance. | |
768 */ | |
769 strncpy ( extDialNum, cmd + 1, MINIMUM ( MAX_PHB_NUM_LEN - 1, | |
770 *cmdLen - 1 ) ); | |
771 extDialNum[MINIMUM ( MAX_PHB_NUM_LEN - 1, *cmdLen - 1 )] = '\0'; | |
772 | |
773 extCmdLen = 0; | |
774 *cmdLen = 0; | |
775 | |
776 rslt = sAT_PlusCFUN ( CMD_SRC_LCL, | |
777 CFUN_FUN_Full, | |
778 CFUN_RST_NotPresent ); | |
779 | |
780 if ( rslt EQ AT_EXCT ) | |
781 { | |
782 /* | |
783 * generate some output at the AT interface | |
784 */ | |
785 ext_CreatePString ( out, EXT_ATCFUN ); | |
786 | |
787 /* | |
788 * indicating that an extended AT command is still in progress | |
789 */ | |
790 currExtCmd = AT_CMD_CFUN; | |
791 } | |
792 else | |
793 { | |
794 ext_LeaveEXT ( TRUE ); | |
795 rCI_PlusCME ( AT_CMD_EXT, CME_ERR_Unknown ); | |
796 } | |
797 | |
798 return ( rslt ); | |
799 } | |
800 else | |
801 return( AT_FAIL ); | |
802 } | |
803 | |
804 /* | |
805 +--------------------------------------------------------------------+ | |
806 | PROJECT : GSM-PS (6147) MODULE : CST_EXTS | | |
807 | STATE : code ROUTINE : percentCFG | | |
808 +--------------------------------------------------------------------+ | |
809 | |
810 PURPOSE : %CFG command (enables dynamic configuration of the | |
811 protocol stack using the AT command interface) | |
812 */ | |
813 | |
814 EXTERN char *parse (char *b, char *f, ...); | |
815 | |
816 GLOBAL SHORT cc_pei_config (char * inString, | |
817 char * outString); | |
818 GLOBAL SHORT cst_pei_config (char * inString, | |
819 char * outString); | |
820 GLOBAL SHORT dl_pei_config (char * inString, | |
821 char * outString); | |
822 GLOBAL SHORT mm_pei_config (char * inString, | |
823 char * outString); | |
824 GLOBAL SHORT rr_pei_config (char * inString, | |
825 char * outString); | |
826 GLOBAL SHORT sim_pei_config (char * inString, | |
827 char * outString); | |
828 GLOBAL SHORT sms_pei_config (char * inString, | |
829 char * outString); | |
830 GLOBAL SHORT ss_pei_config (char * inString, | |
831 char * outString); | |
832 GLOBAL SHORT pl_pei_config (char * inString, | |
833 char * outString); | |
834 | |
835 #ifdef FAX_AND_DATA | |
836 GLOBAL SHORT fad_pei_config (char * inString, | |
837 char * outString); | |
838 GLOBAL SHORT l2r_pei_config (char * inString, | |
839 char * outString); | |
840 GLOBAL SHORT ra_pei_config (char * inString, | |
841 char * outString); | |
842 GLOBAL SHORT rlp_pei_config (char * inString, | |
843 char * outString); | |
844 GLOBAL SHORT t30_pei_config (char * inString, | |
845 char * outString); | |
846 #endif | |
847 | |
848 GLOBAL CHAR* percentCFG ( CHAR* cl ) | |
849 { | |
850 CHAR entity[5]; | |
851 CHAR config[40]; | |
852 CHAR dummy; | |
853 | |
854 TRACE_FUNCTION ( "percentCFG()" ); | |
855 | |
856 switch ( *cl ) | |
857 { | |
858 case('='): | |
859 { | |
860 cl++; | |
861 | |
862 cl = parse ( cl, "ss", ( LONG )sizeof(entity), entity, | |
863 ( LONG )sizeof(config), config ); | |
864 | |
865 if( !cl OR | |
866 *entity EQ '\0' OR | |
867 *config EQ '\0' ) | |
868 { | |
869 return ( NULL ); | |
870 } | |
871 | |
872 break; | |
873 } | |
874 | |
875 default: | |
876 { | |
877 return ( NULL ); | |
878 } | |
879 } | |
880 | |
881 if ( strcmp ( entity, CC_NAME ) EQ 0 ) | |
882 { | |
883 cc_pei_config ( config, &dummy ); | |
884 } | |
885 else if ( strcmp ( entity, CST_NAME ) EQ 0 ) | |
886 { | |
887 cst_pei_config ( config, &dummy ); | |
888 } | |
889 else if ( strcmp ( entity, DL_NAME ) EQ 0 ) | |
890 { | |
891 dl_pei_config ( config, &dummy ); | |
892 } | |
893 else if ( strcmp ( entity, MM_NAME ) EQ 0 ) | |
894 { | |
895 mm_pei_config ( config, &dummy ); | |
896 } | |
897 else if ( strcmp ( entity, RR_NAME ) EQ 0 ) | |
898 { | |
899 rr_pei_config ( config, &dummy ); | |
900 } | |
901 else if ( strcmp ( entity, SIM_NAME ) EQ 0 ) | |
902 { | |
903 sim_pei_config ( config, &dummy ); | |
904 } | |
905 else if ( strcmp ( entity, SMS_NAME ) EQ 0 ) | |
906 { | |
907 sms_pei_config ( config, &dummy ); | |
908 } | |
909 else if ( strcmp ( entity, SS_NAME ) EQ 0 ) | |
910 { | |
911 ss_pei_config ( config, &dummy ); | |
912 } | |
913 else if ( strcmp ( entity, PL_NAME ) EQ 0 ) | |
914 { | |
915 pl_pei_config ( config, &dummy ); | |
916 } | |
917 | |
918 #ifdef FAX_AND_DATA | |
919 | |
920 else if ( strcmp ( entity, FAD_NAME ) EQ 0 ) | |
921 { | |
922 fad_pei_config ( config, &dummy ); | |
923 } | |
924 else if ( strcmp ( entity, L2R_NAME ) EQ 0 ) | |
925 { | |
926 l2r_pei_config ( config, &dummy ); | |
927 } | |
928 else if ( strcmp ( entity, RA_NAME ) EQ 0 ) | |
929 { | |
930 ra_pei_config ( config, &dummy ); | |
931 } | |
932 else if ( strcmp ( entity, RLP_NAME ) EQ 0 ) | |
933 { | |
934 rlp_pei_config ( config, &dummy ); | |
935 } | |
936 else if ( strcmp ( entity, T30_NAME ) EQ 0 ) | |
937 { | |
938 t30_pei_config ( config, &dummy ); | |
939 } | |
940 | |
941 #endif | |
942 | |
943 else | |
944 { | |
945 return ( NULL ); | |
946 } | |
947 | |
948 return ( cl ); | |
949 } | |
950 | |
951 /* | |
952 +--------------------------------------------------------------------+ | |
953 | PROJECT : GSM-PS (6147) MODULE : CST_EXTS | | |
954 | STATE : code ROUTINE : percentDBG | | |
955 +--------------------------------------------------------------------+ | |
956 | |
957 PURPOSE : %RST command (simulates pressing the reset button | |
958 of the ASample) | |
959 */ | |
960 | |
961 #ifndef TRACE_PORT_TIMING | |
962 #ifdef _TMS470 | |
963 #if (CHIPSET == 0) | |
964 EXTERN void l1s_set_debug_pin ( UBYTE, UBYTE ); | |
965 #endif | |
966 #endif | |
967 #endif | |
968 | |
969 GLOBAL CHAR* percentDBG ( CHAR* cl ) | |
970 { | |
971 SHORT line = 1; | |
972 SHORT polarity = 1; | |
973 SHORT delay = 650; | |
974 | |
975 TRACE_FUNCTION ( "atPercentDBG()" ); | |
976 | |
977 switch ( *cl ) | |
978 { | |
979 case( '\0' ): | |
980 { | |
981 break; | |
982 } | |
983 | |
984 case('='): | |
985 { | |
986 cl++; | |
987 | |
988 cl = parse ( cl, "rrr", &line, &polarity, &delay ); | |
989 | |
990 if( !cl OR | |
991 polarity < 0 OR polarity > 1 OR | |
992 line < 0 OR line > 7 OR | |
993 delay < 0 ) | |
994 { | |
995 return ( NULL ); | |
996 } | |
997 | |
998 break; | |
999 } | |
1000 | |
1001 default: | |
1002 { | |
1003 return ( NULL ); | |
1004 } | |
1005 } | |
1006 | |
1007 #ifndef TRACE_PORT_TIMING | |
1008 #ifdef _TMS470 | |
1009 #if (CHIPSET == 0) | |
1010 #if defined (NEW_FRAME) | |
1011 vsi_t_sleep ( VSI_CALLER ( T_TIME ) delay ); | |
1012 #else | |
1013 vsi_t_sleep ( VSI_CALLER ( T_VSI_TVALUE ) delay ); | |
1014 #endif | |
1015 | |
1016 l1s_set_debug_pin ( ( UBYTE ) line, ( UBYTE ) polarity ); | |
1017 #endif | |
1018 #endif | |
1019 #endif | |
1020 | |
1021 return ( cl ); | |
1022 } | |
1023 | |
1024 /* | |
1025 +--------------------------------------------------------------------+ | |
1026 | PROJECT : GSM-PS (6147) MODULE : CMH_EXTS | | |
1027 | STATE : code ROUTINE : rAT_ACP | | |
1028 +--------------------------------------------------------------------+ | |
1029 | |
1030 PURPOSE : This function is called by the interpreter part of the | |
1031 ACI in case of aborting a pending extension command. | |
1032 | |
1033 <out> : this parameter can be used to display some | |
1034 strings at the AT command interface. | |
1035 The first char of one string must contain | |
1036 the length of the following string. The | |
1037 special length 0xff must be used to define | |
1038 the end of the string list. | |
1039 <outLen> : maximum length of output buffer referenced | |
1040 by parameter <out>. | |
1041 | |
1042 */ | |
1043 | |
1044 GLOBAL T_ACI_RETURN rAT_ACP ( | |
1045 CHAR* out, | |
1046 USHORT outLen | |
1047 ) | |
1048 { | |
1049 T_ACI_RETURN rslt = AT_CMPL; | |
1050 | |
1051 /* call the abort function if necessary */ | |
1052 if ( currExtCmd NEQ AT_CMD_NONE ) | |
1053 rslt = sAT_Abort (CMD_SRC_LCL, currExtCmd ); | |
1054 | |
1055 switch ( rslt ) | |
1056 { | |
1057 case ( AT_CMPL ): | |
1058 { | |
1059 currExtCmd = AT_CMD_NONE; | |
1060 | |
1061 ext_LeaveEXT ( TRUE ); | |
1062 } | |
1063 break; | |
1064 | |
1065 case ( AT_EXCT ): | |
1066 { | |
1067 currExtCmd = AT_CMD_ABRT; | |
1068 } | |
1069 break; | |
1070 | |
1071 default: | |
1072 { | |
1073 /* do nothing */ | |
1074 } | |
1075 break; | |
1076 } | |
1077 | |
1078 return rslt; | |
1079 } | |
1080 | |
1081 /* | |
1082 +--------------------------------------------------------------------+ | |
1083 | PROJECT : GSM-PS (6147) MODULE : CMH_EXTS | | |
1084 | STATE : code ROUTINE : ext_OK | | |
1085 +--------------------------------------------------------------------+ | |
1086 | |
1087 PURPOSE : This function is called by the MMI in case the positive | |
1088 result of the asynchronous command handling is available. | |
1089 | |
1090 <cmdId>: command identity | |
1091 | |
1092 */ | |
1093 GLOBAL void ext_OK ( T_ACI_AT_CMD cmdId ) | |
1094 { | |
1095 T_ACI_RETURN rslt; | |
1096 | |
1097 if ( cmdId EQ AT_CMD_CFUN AND currAbrtCmd EQ AT_CMD_NONE ) | |
1098 { | |
1099 rslt = sAT_PlusCOPS ( CMD_SRC_LCL, | |
1100 COPS_MOD_Auto, | |
1101 COPS_FRMT_NotPresent, | |
1102 NULL ); | |
1103 | |
1104 if ( rslt EQ AT_EXCT ) | |
1105 { | |
1106 /* | |
1107 * generate some output at the AT interface | |
1108 */ | |
1109 ext_CreatePString ( extBuffer, EXT_ATCOPS_START ); | |
1110 | |
1111 sAT_URC ( extBuffer ); | |
1112 | |
1113 /* | |
1114 * indicating that an extended AT command is still in progress | |
1115 */ | |
1116 currExtCmd = AT_CMD_COPS; | |
1117 } | |
1118 else | |
1119 { | |
1120 ext_LeaveEXT ( TRUE ); | |
1121 rCI_PlusCME ( AT_CMD_EXT, CME_ERR_Unknown ); | |
1122 } | |
1123 } | |
1124 else if ( cmdId EQ AT_CMD_COPS AND currAbrtCmd EQ AT_CMD_NONE ) | |
1125 { | |
1126 currExtCmd = AT_CMD_NONE; | |
1127 | |
1128 /* | |
1129 * generate some output at the AT interface | |
1130 */ | |
1131 ext_CreatePString ( extBuffer, EXT_ATCOPS_STOP ); | |
1132 | |
1133 sAT_URC ( extBuffer ); | |
1134 | |
1135 #ifndef WIN32 | |
1136 ext_ContinueTest ( EXT_DIAL_VOICE_PASS ); | |
1137 #endif | |
1138 } | |
1139 else if ( cmdId EQ AT_CMD_D AND currAbrtCmd EQ AT_CMD_NONE ) | |
1140 { | |
1141 extCallId = 1; | |
1142 | |
1143 ext_LeaveEXT ( TRUE ); | |
1144 rCI_OK ( AT_CMD_EXT ); | |
1145 } | |
1146 else if ( currAbrtCmd NEQ AT_CMD_NONE ) | |
1147 { | |
1148 currAbrtCmd = AT_CMD_NONE; | |
1149 | |
1150 ext_LeaveEXT ( TRUE ); | |
1151 rCI_OK ( AT_CMD_EXT ); | |
1152 } | |
1153 else | |
1154 { | |
1155 /* | |
1156 * generate some output at the AT interface | |
1157 */ | |
1158 ext_CreatePString ( extBuffer, EXT_UNEXPCTD ); | |
1159 | |
1160 sAT_URC ( extBuffer ); | |
1161 } | |
1162 } | |
1163 | |
1164 /* | |
1165 +--------------------------------------------------------------------+ | |
1166 | PROJECT : GSM-PS (6147) MODULE : CMH_EXTS | | |
1167 | STATE : code ROUTINE : ext_LeaveExtension | | |
1168 +--------------------------------------------------------------------+ | |
1169 | |
1170 PURPOSE : This function is called in case the extensin mechansim | |
1171 should be left finally. | |
1172 | |
1173 <final>: indicates whether final result code should be | |
1174 sent explicitly | |
1175 | |
1176 */ | |
1177 LOCAL void ext_LeaveEXT ( BOOL final ) | |
1178 { | |
1179 /* | |
1180 * generate some output at the AT interface | |
1181 */ | |
1182 ext_CreatePString ( extBuffer, EXT_LEAVE ); | |
1183 | |
1184 /* | |
1185 * indicating that no extended AT command is still in progress | |
1186 */ | |
1187 currExtCmd = AT_CMD_NONE; | |
1188 | |
1189 /* | |
1190 * indicate end of extended command handling to the AT interpreter | |
1191 */ | |
1192 sAT_URC ( extBuffer ); | |
1193 | |
1194 if ( final ) | |
1195 { | |
1196 sAT_FRI ( extCmdLen ); | |
1197 } | |
1198 } | |
1199 | |
1200 /* | |
1201 +--------------------------------------------------------------------+ | |
1202 | PROJECT : GSM-PS (6147) MODULE : CMH_EXTS | | |
1203 | STATE : code ROUTINE : ext_ContinueTest | | |
1204 +--------------------------------------------------------------------+ | |
1205 | |
1206 PURPOSE : This function is called in case the AT extension | |
1207 procedure should be continued. | |
1208 | |
1209 <id>: identifies the specific procedure to be continued | |
1210 | |
1211 */ | |
1212 GLOBAL void ext_ContinueTest ( CHAR* id ) | |
1213 { | |
1214 T_ACI_RETURN rslt; | |
1215 | |
1216 if ( strcmp ( id, EXT_DIAL_VOICE_PASS ) EQ 0 ) | |
1217 { | |
1218 T_ACI_D_TOC callType = D_TOC_Data; | |
1219 | |
1220 if ( extDialNum [strlen ( extDialNum ) - 1] EQ EXT_VOICE_DELIMITER ) | |
1221 callType = D_TOC_Voice; | |
1222 | |
1223 extDialNum[strlen ( extDialNum ) - 1] = '\0'; | |
1224 | |
1225 rslt = sAT_Dn ( CMD_SRC_LCL, | |
1226 extDialNum, | |
1227 D_CLIR_OVRD_Default, | |
1228 D_CUG_CTRL_NotPresent, | |
1229 callType ); | |
1230 | |
1231 if ( rslt EQ AT_EXCT ) | |
1232 { | |
1233 /* | |
1234 * generate some output at the AT interface | |
1235 */ | |
1236 ext_CreatePString ( extBuffer, EXT_ATD ); | |
1237 | |
1238 sAT_URC ( extBuffer ); | |
1239 | |
1240 /* | |
1241 * indicating that an extended AT command is still in progress | |
1242 */ | |
1243 currExtCmd = AT_CMD_D; | |
1244 } | |
1245 else | |
1246 { | |
1247 ext_LeaveEXT ( TRUE ); | |
1248 rCI_PlusCME ( AT_CMD_EXT, CME_ERR_Unknown ); | |
1249 } | |
1250 } | |
1251 } | |
1252 | |
1253 /* | |
1254 +--------------------------------------------------------------------+ | |
1255 | PROJECT : GSM-PS (6147) MODULE : CMH_EXTS | | |
1256 | STATE : code ROUTINE : ext_CreatePString | | |
1257 +--------------------------------------------------------------------+ | |
1258 | |
1259 PURPOSE : | |
1260 | |
1261 */ | |
1262 LOCAL void ext_CreatePString ( CHAR* buffer, CHAR* text ) | |
1263 { | |
1264 buffer[0] = strlen (text); | |
1265 memcpy (&buffer[1], text, buffer[0]); | |
1266 buffer [buffer[0]+1] = (CHAR) 0xff; | |
1267 } |