comparison src/cs/services/cst/cst_exts.c @ 0:b6a5e36de839

src/cs: initial import from Magnetite
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 15 Jul 2018 04:39:26 +0000
parents
children ea4af6f4104d
comparison
equal deleted inserted replaced
-1:000000000000 0:b6a5e36de839
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 #if 1 /* FreeCalypso change */
300 sprintf (buf, "VBAT=%u, VCHG=%u, ICHG=%u, VBACKUP=%u, ADIN1=%u, ADIN2=%u, ADIN3=%u, RFTEMP=%u, ADIN5=%u",
301 adc_conversion[0], adc_conversion[1], adc_conversion[2],
302 adc_conversion[3], adc_conversion[4], adc_conversion[5],
303 adc_conversion[6], adc_conversion[7], adc_conversion[8]);
304 #elif defined(ALR)
305 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",
306 *adc_conversion++, *adc_conversion++, *adc_conversion++,
307 *adc_conversion++, *adc_conversion++, *adc_conversion++,
308 *adc_conversion++, *adc_conversion++, *adc_conversion);
309 #else
310 sprintf (buf, "ADC 0 = %x, ADC 1 = %x, ADC 2 = %x, ADC 3 = %x, ADC 4 = %x",
311 *adc_conversion++, *adc_conversion++, *adc_conversion++,
312 *adc_conversion++, *adc_conversion);
313 #endif
314
315 // Format output as a list of Pascal-like strings
316 size = strlen(buf);
317 output[0] = size;
318 strcpy(&(output[1]), buf);
319 output[size+1] = (CHAR) 0xFF; // terminate list of strings
320 }
321
322
323 /*
324 +--------------------------------------------------------------------+
325 | PROJECT : GSM-PS (8403) MODULE : CST_EXTS |
326 | STATE : code ROUTINE : AEC_Enable |
327 +--------------------------------------------------------------------+
328
329 PURPOSE : activate the Acoustic Echo Cancelation
330
331 */
332
333 GLOBAL void AEC_Enable (CHAR *command, CHAR *output)
334 {
335
336 /* -------------------------------------------------------------------------- */
337 /* MMI_AEC_REQ : 0283 = Long AEC, 105 = SPENH, 187 = AEC+SPENH, 1 = STOP */
338 /* aec_control register bits | 0 0 Sa t2|t1 g3 g2 g1|g0 e2 e1 ak| */
339 /* bit 0 : ACK bit : set to 1 in order to warn DSP that a new command */
340 /* is present. */
341 /* bit 1 : enable AEC */
342 /* bit 2 : enable SPENH (= Speech Enhancement = noise reduction) */
343 /* bit 3 : additionnal AEC gain attenuation (lsb) */
344 /* bit 4 : additionnal AEC gain attenuation (msb) */
345 /* bit 5 : additionnal SPENH gain attenuation (lsb) */
346 /* bit 6 : additionnal SPENH gain attenuation (msb) */
347 /* bit 7 : reset trigger for AEC */
348 /* bit 8 : reset trigger for SPENH */
349 /* bit 9 : AEC selector 0 : short AEC, 1 : long AEC */
350 /* */
351 /* for Short AEC 0083 */
352 /* for long AEC 0283 */
353 /* for long AEC -6 dB 028B */
354 /* for long AEC -12 dB 0293 */
355 /* for long AEC -18 dB 029B */
356 /* for SPENH 0105 */
357 /* for SPENH -6 dB 0125 */
358 /* for SPENH -12 dB 0145 */
359 /* for SPENH -18 dB 0165 */
360 /* for BOTH 0187 */
361 /* for STOP ALL 0001 (all bits reset + ACK to 1 to warn the DSP) */
362 /* -------------------------------------------------------------------------- */
363
364
365 command++; /* increment command pointer to point on the hexa value of the command */
366
367
368 if (!strncmp(command, "0083", 4))
369 {
370 output[0] = strlen ("Short AEC is active");
371 memcpy (&output[1], "Short AEC is active", 19);
372
373 /* end of string list */
374 output [20] = (CHAR) 0xff;
375 csf_aec_enable(0x0083);
376 }
377
378 else if (!strncmp(command, "0283", 4))
379 {
380 output[0] = strlen ("Long AEC is active");
381 memcpy (&output[1], "Long AEC is active", 18);
382
383 /* end of string list */
384 output [19] = (CHAR) 0xff;
385 csf_aec_enable(0x0283);
386 }
387
388 else if (!strncmp(command, "028B", 4))
389 {
390 output[0] = strlen ("Long AEC -6 dB is active");
391 memcpy (&output[1], "Long AEC -6 dB is active", 24);
392
393 /* end of string list */
394 output [25] = (CHAR) 0xff;
395 csf_aec_enable(0x028B);
396 }
397
398 else if (!strncmp(command, "0293", 4))
399 {
400 output[0] = strlen ("Long AEC -12 dB is active");
401 memcpy (&output[1], "Long AEC -12 dB is active", 25);
402
403 /* end of string list */
404 output [26] = (CHAR) 0xff;
405 csf_aec_enable(0x0293);
406 }
407
408 else if (!strncmp(command, "029B", 4))
409 {
410 output[0] = strlen ("Long AEC -18 dB is active");
411 memcpy (&output[1], "Long AEC -18 dB is active", 25);
412
413 /* end of string list */
414 output [26] = (CHAR) 0xff;
415 csf_aec_enable(0x029B);
416 }
417
418 else if (!strncmp(command, "0105", 4))
419 {
420 output[0] = strlen ("Noise reduction is active");
421 memcpy (&output[1], "Noise reduction is active", 25);
422
423 /* end of string list */
424 output [26] = (CHAR) 0xff;
425 csf_aec_enable(0x0105);
426 }
427
428 else if (!strncmp(command, "0125", 4))
429 {
430 output[0] = strlen ("Noise reduction -6 dB is active");
431 memcpy (&output[1], "Noise reduction -6 dB is active", 31);
432
433 /* end of string list */
434 output [32] = (CHAR) 0xff;
435 csf_aec_enable(0x0125);
436 }
437
438 else if (!strncmp(command, "0145", 4))
439 {
440 output[0] = strlen ("Noise reduction -12 dB is active");
441 memcpy (&output[1], "Noise reduction -12 dB is active", 32);
442
443 /* end of string list */
444 output [33] = (CHAR) 0xff;
445 csf_aec_enable(0x0145);
446 }
447
448 else if (!strncmp(command, "0165", 4))
449 {
450 output[0] = strlen ("Noise reduction -18 dB is active");
451 memcpy (&output[1], "Noise reduction -18 dB is active", 32);
452
453 /* end of string list */
454 output [33] = (CHAR) 0xff;
455 csf_aec_enable(0x0165);
456 }
457
458 else if (!strncmp(command, "0187", 4))
459 {
460 output[0] = strlen ("Both AEC and Noise reduction are active");
461 memcpy (&output[1], "Both AEC and Noise reduction are active", 39);
462
463 /* end of string list */
464 output [40] = (CHAR) 0xff;
465 csf_aec_enable(0x0187);
466 }
467
468 else if (!strncmp(command, "0001", 4))
469 {
470 output[0] = strlen ("AEC and Noise reduction are unactivated");
471 memcpy (&output[1], "AEC and Noise reduction are unactivated", 39);
472
473 /* end of string list */
474 output [40] = (CHAR) 0xff;
475 csf_aec_enable(0x0001);
476 }
477
478 else
479 {
480 output[0] = strlen ("Bad AT command");
481 memcpy (&output[1], "Bad AT command", 14);
482
483 /* end of string list */
484 output [15] = (CHAR) 0xff;
485 }
486
487 }
488
489
490
491
492 /*
493 +--------------------------------------------------------------------+
494 | PROJECT : GSM-PS (6147) MODULE : CST_EXTS |
495 | STATE : code ROUTINE : rAT_EXT |
496 +--------------------------------------------------------------------+
497
498 PURPOSE : This function is called by the interpreter part of the
499 ACI in case of the detection of an unknown command.
500
501 <cmd> : remaining unparsed command string.
502 <cmdLen> : length of command string. This value must be
503 incremented by the amount of parsed characters
504 by this function.
505 <out> : this parameter can be used to display some
506 strings at the AT command interface.
507 The first char of one string must contain
508 the length of the following string. The
509 special length 0xff must be used to define
510 the end of the string list.
511 <outLen> : maximum length of output buffer referenced
512 by parameter <out>.
513
514 */
515
516 GLOBAL T_ACI_RETURN rAT_EXT (
517 CHAR* cmd,
518 USHORT* cmdLen,
519 CHAR* out,
520 USHORT outLen
521 )
522 {
523 /*
524 * store command string in case it will be needed later on, when
525 * result code of this function is equal to AT_EXCT
526 */
527 extCmd = cmd;
528 extCmdLen = *cmdLen;
529
530 /*
531 * example how to send an unsolicited result code via the AT interface
532 */
533 ext_CreatePString ( extBuffer, EXT_ENTER );
534
535 sAT_URC ( extBuffer );
536
537 /*
538 * example how to process the command AT%H
539 */
540 if (*cmd == '%')
541 {
542 cmd++;
543
544 switch (*cmd)
545 {
546 case 'A':
547 /*
548 * Display AD conversions results
549 */
550 *cmdLen -= 2;
551 show_adc_conversion(out);
552 return( AT_CMPL );
553
554 case 'C':
555 case 'c':
556 case 'D':
557 case 'd':
558 {
559 CHAR* nextCmd;
560
561 *cmdLen -= 2;
562
563 switch ( *cmd )
564 {
565 case 'C':
566 case 'c':
567 /* dynamic configuration via AT command interface */
568 nextCmd = percentCFG ( ++cmd );
569
570 break;
571
572 case 'D':
573 case 'd':
574 /* set debug pin for reset purposes */
575 nextCmd = percentDBG ( ++cmd );
576
577 break;
578 }
579
580 *out = ( CHAR ) 0xFF;
581
582 if ( nextCmd EQ NULL )
583 {
584 return ( AT_FAIL );
585 }
586 else
587 {
588 *cmdLen -= ( nextCmd - cmd );
589
590 return ( AT_CMPL );
591 }
592 }
593
594 case 'N':
595 /*
596 * Enables the AEC by sending a primitive to L1A
597 */
598 *cmdLen -= 6;
599 AEC_Enable(cmd, out);
600 return( AT_CMPL );
601
602 //---------------------------------------------------------------------------//
603 // Added by Matthieu Vanin for the test of melody E2/E1
604 //---------------------------------------------------------------------------//
605
606
607
608 // End
609 //---------------------------------------------------------------------------//
610 case 'S':
611 case 's':
612 {
613 cmd++;
614
615 switch (*cmd) {
616
617 case 'e':
618 case 'E':
619 /* 's''e' already detected => assume the command is at%ser. */
620 {
621 cmd += 3; /* Discard the following characters */
622 *cmdLen -= 9;
623 if (SER_WriteConfig (cmd, (BOOL) (*(cmd + 3) - '0')))
624 return( AT_CMPL );
625 else
626 return( AT_FAIL );
627 }
628
629 case 'w':
630 case 'W':
631 /* 's''w' already detected => assume the command is at%switch. */
632 {
633 *cmdLen -= 7;
634 if (SER_ImmediateSwitch())
635 return( AT_CMPL );
636 else
637 return( AT_FAIL );
638 }
639
640 case 'l':
641 case 'L':
642 /* 's''l' already detected => assume the command is at%sleep. */
643 {
644 cmd += 5; /* Discard the following characters */
645 *cmdLen -= 8;
646 /*
647 * Checks if the parameter is valid:
648 * 0 -> NO_SLEEP
649 * 1 -> SMALL_SLEEP
650 * 2 -> BIG_SLEEP
651 * 3 -> DEEP_SLEEP
652 * 4 -> ALL_SLEEP
653 */
654
655 if (((*cmd - '0') >= 0) && ((*cmd - '0') <= 4))
656 {
657 power_down_config ((UBYTE) (*cmd - '0'), UWIRE_CLK_CUT);
658 return( AT_CMPL );
659 }
660 else
661 return( AT_FAIL );
662 }
663
664 default:
665 *cmdLen -= 2;
666 return ( AT_FAIL );
667
668 }
669 }
670
671 case 'H':
672 *cmdLen -= 2;
673
674 /*
675 * here you can perform some actions with drivers etc.
676 */
677
678 /*
679 * and create some additional output at the AT interface
680 * The strings:
681 *"Hello"
682 *""
683 *"World"
684 * will be displayed at the terminal.
685 *
686 * first string Hello
687 */
688 out[0] = strlen ("Hello");
689 memcpy (&out[1], "Hello", 5);
690 /*
691 * add a spare line with an empty string
692 */
693 out [6] = 0;
694 /*
695 * second string World
696 */
697 out [7] = strlen ("World");
698 memcpy (&out[8], "World", 5);
699
700 /*
701 * end of string list
702 */
703 out [13] = (CHAR) 0xff;
704 return( AT_CMPL );
705
706 #ifndef WIN32
707 case 'R':
708 case 'r':
709 *cmdLen -= 2;
710 l1dmacro_init_hw();
711 out[0] = 0;
712 out[1] = (CHAR) 0xFF;
713 return( AT_CMPL );
714 #endif
715
716 #ifndef WIN32
717 case 'V':
718 case 'v':
719 *cmdLen -= 2;
720
721 /*
722 * Display version numbers
723 */
724
725 cmh_show_version (cmd, cmdLen, out);
726 return( AT_CMPL );
727 #endif
728 #if defined (ALR)
729 case 'T':
730 case 't':
731 /*
732 * Enables RTC or AUDIO tests
733 */
734 cmd++;
735 *cmdLen -= 3;
736 if (!strncmp(cmd, "A", 1) || !strncmp(cmd, "a", 1))
737 {
738 //audio_test_misc();
739 out[0] = 22;
740 memcpy (&out[1], "Performing Audio Tests", 22);
741 out [23] = (CHAR) 0xff;
742 }
743 else
744 {
745 if (!strncmp(cmd, "R", 1) || !strncmp(cmd, "r", 1))
746 {
747 //rtc_test_misc();
748 out[0] = 20;
749 memcpy (&out[1], "Performing RTC Tests", 20);
750 out [21] = (CHAR) 0xff;
751 }
752 else
753 return( AT_FAIL );
754 }
755 return( AT_CMPL );
756 #endif
757 default:
758 *cmdLen -= 2;
759 return ( AT_FAIL );
760 }
761 }
762 else if ( *cmd EQ 'D' )
763 {
764 T_ACI_RETURN rslt;
765
766 /*
767 * this is only a test implementation. As soon as a "ATD" command
768 * string is detected in the AT interpreter and the mobile is not
769 * yet registered (neither limited nor full service is availbale)
770 * this function is called. Then instead of dialling immediately
771 * an activation of the mobile is performed in advance.
772 */
773 strncpy ( extDialNum, cmd + 1, MINIMUM ( MAX_PHB_NUM_LEN - 1,
774 *cmdLen - 1 ) );
775 extDialNum[MINIMUM ( MAX_PHB_NUM_LEN - 1, *cmdLen - 1 )] = '\0';
776
777 extCmdLen = 0;
778 *cmdLen = 0;
779
780 rslt = sAT_PlusCFUN ( CMD_SRC_LCL,
781 CFUN_FUN_Full,
782 CFUN_RST_NotPresent );
783
784 if ( rslt EQ AT_EXCT )
785 {
786 /*
787 * generate some output at the AT interface
788 */
789 ext_CreatePString ( out, EXT_ATCFUN );
790
791 /*
792 * indicating that an extended AT command is still in progress
793 */
794 currExtCmd = AT_CMD_CFUN;
795 }
796 else
797 {
798 ext_LeaveEXT ( TRUE );
799 rCI_PlusCME ( AT_CMD_EXT, CME_ERR_Unknown );
800 }
801
802 return ( rslt );
803 }
804 else
805 return( AT_FAIL );
806 }
807
808 /*
809 +--------------------------------------------------------------------+
810 | PROJECT : GSM-PS (6147) MODULE : CST_EXTS |
811 | STATE : code ROUTINE : percentCFG |
812 +--------------------------------------------------------------------+
813
814 PURPOSE : %CFG command (enables dynamic configuration of the
815 protocol stack using the AT command interface)
816 */
817
818 EXTERN char *parse (char *b, char *f, ...);
819
820 GLOBAL SHORT cc_pei_config (char * inString,
821 char * outString);
822 GLOBAL SHORT cst_pei_config (char * inString,
823 char * outString);
824 GLOBAL SHORT dl_pei_config (char * inString,
825 char * outString);
826 GLOBAL SHORT mm_pei_config (char * inString,
827 char * outString);
828 GLOBAL SHORT rr_pei_config (char * inString,
829 char * outString);
830 GLOBAL SHORT sim_pei_config (char * inString,
831 char * outString);
832 GLOBAL SHORT sms_pei_config (char * inString,
833 char * outString);
834 GLOBAL SHORT ss_pei_config (char * inString,
835 char * outString);
836 GLOBAL SHORT pl_pei_config (char * inString,
837 char * outString);
838
839 #ifdef FAX_AND_DATA
840 GLOBAL SHORT fad_pei_config (char * inString,
841 char * outString);
842 GLOBAL SHORT l2r_pei_config (char * inString,
843 char * outString);
844 GLOBAL SHORT ra_pei_config (char * inString,
845 char * outString);
846 GLOBAL SHORT rlp_pei_config (char * inString,
847 char * outString);
848 GLOBAL SHORT t30_pei_config (char * inString,
849 char * outString);
850 #endif
851
852 GLOBAL CHAR* percentCFG ( CHAR* cl )
853 {
854 CHAR entity[5];
855 CHAR config[40];
856 CHAR dummy;
857
858 TRACE_FUNCTION ( "percentCFG()" );
859
860 switch ( *cl )
861 {
862 case('='):
863 {
864 cl++;
865
866 cl = parse ( cl, "ss", ( LONG )sizeof(entity), entity,
867 ( LONG )sizeof(config), config );
868
869 if( !cl OR
870 *entity EQ '\0' OR
871 *config EQ '\0' )
872 {
873 return ( NULL );
874 }
875
876 break;
877 }
878
879 default:
880 {
881 return ( NULL );
882 }
883 }
884
885 if ( strcmp ( entity, CC_NAME ) EQ 0 )
886 {
887 cc_pei_config ( config, &dummy );
888 }
889 else if ( strcmp ( entity, CST_NAME ) EQ 0 )
890 {
891 cst_pei_config ( config, &dummy );
892 }
893 else if ( strcmp ( entity, DL_NAME ) EQ 0 )
894 {
895 dl_pei_config ( config, &dummy );
896 }
897 else if ( strcmp ( entity, MM_NAME ) EQ 0 )
898 {
899 mm_pei_config ( config, &dummy );
900 }
901 else if ( strcmp ( entity, RR_NAME ) EQ 0 )
902 {
903 rr_pei_config ( config, &dummy );
904 }
905 else if ( strcmp ( entity, SIM_NAME ) EQ 0 )
906 {
907 sim_pei_config ( config, &dummy );
908 }
909 else if ( strcmp ( entity, SMS_NAME ) EQ 0 )
910 {
911 sms_pei_config ( config, &dummy );
912 }
913 else if ( strcmp ( entity, SS_NAME ) EQ 0 )
914 {
915 ss_pei_config ( config, &dummy );
916 }
917 else if ( strcmp ( entity, PL_NAME ) EQ 0 )
918 {
919 pl_pei_config ( config, &dummy );
920 }
921
922 #ifdef FAX_AND_DATA
923
924 else if ( strcmp ( entity, FAD_NAME ) EQ 0 )
925 {
926 fad_pei_config ( config, &dummy );
927 }
928 else if ( strcmp ( entity, L2R_NAME ) EQ 0 )
929 {
930 l2r_pei_config ( config, &dummy );
931 }
932 else if ( strcmp ( entity, RA_NAME ) EQ 0 )
933 {
934 ra_pei_config ( config, &dummy );
935 }
936 else if ( strcmp ( entity, RLP_NAME ) EQ 0 )
937 {
938 rlp_pei_config ( config, &dummy );
939 }
940 else if ( strcmp ( entity, T30_NAME ) EQ 0 )
941 {
942 t30_pei_config ( config, &dummy );
943 }
944
945 #endif
946
947 else
948 {
949 return ( NULL );
950 }
951
952 return ( cl );
953 }
954
955 /*
956 +--------------------------------------------------------------------+
957 | PROJECT : GSM-PS (6147) MODULE : CST_EXTS |
958 | STATE : code ROUTINE : percentDBG |
959 +--------------------------------------------------------------------+
960
961 PURPOSE : %RST command (simulates pressing the reset button
962 of the ASample)
963 */
964
965 #ifndef TRACE_PORT_TIMING
966 #ifdef _TMS470
967 #if (CHIPSET == 0)
968 EXTERN void l1s_set_debug_pin ( UBYTE, UBYTE );
969 #endif
970 #endif
971 #endif
972
973 GLOBAL CHAR* percentDBG ( CHAR* cl )
974 {
975 SHORT line = 1;
976 SHORT polarity = 1;
977 SHORT delay = 650;
978
979 TRACE_FUNCTION ( "atPercentDBG()" );
980
981 switch ( *cl )
982 {
983 case( '\0' ):
984 {
985 break;
986 }
987
988 case('='):
989 {
990 cl++;
991
992 cl = parse ( cl, "rrr", &line, &polarity, &delay );
993
994 if( !cl OR
995 polarity < 0 OR polarity > 1 OR
996 line < 0 OR line > 7 OR
997 delay < 0 )
998 {
999 return ( NULL );
1000 }
1001
1002 break;
1003 }
1004
1005 default:
1006 {
1007 return ( NULL );
1008 }
1009 }
1010
1011 #ifndef TRACE_PORT_TIMING
1012 #ifdef _TMS470
1013 #if (CHIPSET == 0)
1014 #if defined (NEW_FRAME)
1015 vsi_t_sleep ( VSI_CALLER ( T_TIME ) delay );
1016 #else
1017 vsi_t_sleep ( VSI_CALLER ( T_VSI_TVALUE ) delay );
1018 #endif
1019
1020 l1s_set_debug_pin ( ( UBYTE ) line, ( UBYTE ) polarity );
1021 #endif
1022 #endif
1023 #endif
1024
1025 return ( cl );
1026 }
1027
1028 /*
1029 +--------------------------------------------------------------------+
1030 | PROJECT : GSM-PS (6147) MODULE : CMH_EXTS |
1031 | STATE : code ROUTINE : rAT_ACP |
1032 +--------------------------------------------------------------------+
1033
1034 PURPOSE : This function is called by the interpreter part of the
1035 ACI in case of aborting a pending extension command.
1036
1037 <out> : this parameter can be used to display some
1038 strings at the AT command interface.
1039 The first char of one string must contain
1040 the length of the following string. The
1041 special length 0xff must be used to define
1042 the end of the string list.
1043 <outLen> : maximum length of output buffer referenced
1044 by parameter <out>.
1045
1046 */
1047
1048 GLOBAL T_ACI_RETURN rAT_ACP (
1049 CHAR* out,
1050 USHORT outLen
1051 )
1052 {
1053 T_ACI_RETURN rslt = AT_CMPL;
1054
1055 /* call the abort function if necessary */
1056 if ( currExtCmd NEQ AT_CMD_NONE )
1057 rslt = sAT_Abort (CMD_SRC_LCL, currExtCmd );
1058
1059 switch ( rslt )
1060 {
1061 case ( AT_CMPL ):
1062 {
1063 currExtCmd = AT_CMD_NONE;
1064
1065 ext_LeaveEXT ( TRUE );
1066 }
1067 break;
1068
1069 case ( AT_EXCT ):
1070 {
1071 currExtCmd = AT_CMD_ABRT;
1072 }
1073 break;
1074
1075 default:
1076 {
1077 /* do nothing */
1078 }
1079 break;
1080 }
1081
1082 return rslt;
1083 }
1084
1085 /*
1086 +--------------------------------------------------------------------+
1087 | PROJECT : GSM-PS (6147) MODULE : CMH_EXTS |
1088 | STATE : code ROUTINE : ext_OK |
1089 +--------------------------------------------------------------------+
1090
1091 PURPOSE : This function is called by the MMI in case the positive
1092 result of the asynchronous command handling is available.
1093
1094 <cmdId>: command identity
1095
1096 */
1097 GLOBAL void ext_OK ( T_ACI_AT_CMD cmdId )
1098 {
1099 T_ACI_RETURN rslt;
1100
1101 if ( cmdId EQ AT_CMD_CFUN AND currAbrtCmd EQ AT_CMD_NONE )
1102 {
1103 rslt = sAT_PlusCOPS ( CMD_SRC_LCL,
1104 COPS_MOD_Auto,
1105 COPS_FRMT_NotPresent,
1106 NULL );
1107
1108 if ( rslt EQ AT_EXCT )
1109 {
1110 /*
1111 * generate some output at the AT interface
1112 */
1113 ext_CreatePString ( extBuffer, EXT_ATCOPS_START );
1114
1115 sAT_URC ( extBuffer );
1116
1117 /*
1118 * indicating that an extended AT command is still in progress
1119 */
1120 currExtCmd = AT_CMD_COPS;
1121 }
1122 else
1123 {
1124 ext_LeaveEXT ( TRUE );
1125 rCI_PlusCME ( AT_CMD_EXT, CME_ERR_Unknown );
1126 }
1127 }
1128 else if ( cmdId EQ AT_CMD_COPS AND currAbrtCmd EQ AT_CMD_NONE )
1129 {
1130 currExtCmd = AT_CMD_NONE;
1131
1132 /*
1133 * generate some output at the AT interface
1134 */
1135 ext_CreatePString ( extBuffer, EXT_ATCOPS_STOP );
1136
1137 sAT_URC ( extBuffer );
1138
1139 #ifndef WIN32
1140 ext_ContinueTest ( EXT_DIAL_VOICE_PASS );
1141 #endif
1142 }
1143 else if ( cmdId EQ AT_CMD_D AND currAbrtCmd EQ AT_CMD_NONE )
1144 {
1145 extCallId = 1;
1146
1147 ext_LeaveEXT ( TRUE );
1148 rCI_OK ( AT_CMD_EXT );
1149 }
1150 else if ( currAbrtCmd NEQ AT_CMD_NONE )
1151 {
1152 currAbrtCmd = AT_CMD_NONE;
1153
1154 ext_LeaveEXT ( TRUE );
1155 rCI_OK ( AT_CMD_EXT );
1156 }
1157 else
1158 {
1159 /*
1160 * generate some output at the AT interface
1161 */
1162 ext_CreatePString ( extBuffer, EXT_UNEXPCTD );
1163
1164 sAT_URC ( extBuffer );
1165 }
1166 }
1167
1168 /*
1169 +--------------------------------------------------------------------+
1170 | PROJECT : GSM-PS (6147) MODULE : CMH_EXTS |
1171 | STATE : code ROUTINE : ext_LeaveExtension |
1172 +--------------------------------------------------------------------+
1173
1174 PURPOSE : This function is called in case the extensin mechansim
1175 should be left finally.
1176
1177 <final>: indicates whether final result code should be
1178 sent explicitly
1179
1180 */
1181 LOCAL void ext_LeaveEXT ( BOOL final )
1182 {
1183 /*
1184 * generate some output at the AT interface
1185 */
1186 ext_CreatePString ( extBuffer, EXT_LEAVE );
1187
1188 /*
1189 * indicating that no extended AT command is still in progress
1190 */
1191 currExtCmd = AT_CMD_NONE;
1192
1193 /*
1194 * indicate end of extended command handling to the AT interpreter
1195 */
1196 sAT_URC ( extBuffer );
1197
1198 if ( final )
1199 {
1200 sAT_FRI ( extCmdLen );
1201 }
1202 }
1203
1204 /*
1205 +--------------------------------------------------------------------+
1206 | PROJECT : GSM-PS (6147) MODULE : CMH_EXTS |
1207 | STATE : code ROUTINE : ext_ContinueTest |
1208 +--------------------------------------------------------------------+
1209
1210 PURPOSE : This function is called in case the AT extension
1211 procedure should be continued.
1212
1213 <id>: identifies the specific procedure to be continued
1214
1215 */
1216 GLOBAL void ext_ContinueTest ( CHAR* id )
1217 {
1218 T_ACI_RETURN rslt;
1219
1220 if ( strcmp ( id, EXT_DIAL_VOICE_PASS ) EQ 0 )
1221 {
1222 T_ACI_D_TOC callType = D_TOC_Data;
1223
1224 if ( extDialNum [strlen ( extDialNum ) - 1] EQ EXT_VOICE_DELIMITER )
1225 callType = D_TOC_Voice;
1226
1227 extDialNum[strlen ( extDialNum ) - 1] = '\0';
1228
1229 rslt = sAT_Dn ( CMD_SRC_LCL,
1230 extDialNum,
1231 D_CLIR_OVRD_Default,
1232 D_CUG_CTRL_NotPresent,
1233 callType );
1234
1235 if ( rslt EQ AT_EXCT )
1236 {
1237 /*
1238 * generate some output at the AT interface
1239 */
1240 ext_CreatePString ( extBuffer, EXT_ATD );
1241
1242 sAT_URC ( extBuffer );
1243
1244 /*
1245 * indicating that an extended AT command is still in progress
1246 */
1247 currExtCmd = AT_CMD_D;
1248 }
1249 else
1250 {
1251 ext_LeaveEXT ( TRUE );
1252 rCI_PlusCME ( AT_CMD_EXT, CME_ERR_Unknown );
1253 }
1254 }
1255 }
1256
1257 /*
1258 +--------------------------------------------------------------------+
1259 | PROJECT : GSM-PS (6147) MODULE : CMH_EXTS |
1260 | STATE : code ROUTINE : ext_CreatePString |
1261 +--------------------------------------------------------------------+
1262
1263 PURPOSE :
1264
1265 */
1266 LOCAL void ext_CreatePString ( CHAR* buffer, CHAR* text )
1267 {
1268 buffer[0] = strlen (text);
1269 memcpy (&buffer[1], text, buffer[0]);
1270 buffer [buffer[0]+1] = (CHAR) 0xff;
1271 }