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

src: partial import from FC Selenite
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 15 May 2020 01:28:16 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:92470e5d0b9e
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 * 5 -> BIG_SMALL_SLEEP
654 */
655
656 if (((*cmd - '0') >= 0) && ((*cmd - '0') <= 5))
657 {
658 power_down_config ((UBYTE) (*cmd - '0'), UWIRE_CLK_CUT);
659 return( AT_CMPL );
660 }
661 else
662 return( AT_FAIL );
663 }
664
665 default:
666 *cmdLen -= 2;
667 return ( AT_FAIL );
668
669 }
670 }
671
672 case 'H':
673 *cmdLen -= 2;
674
675 /*
676 * here you can perform some actions with drivers etc.
677 */
678
679 /*
680 * and create some additional output at the AT interface
681 * The strings:
682 *"Hello"
683 *""
684 *"World"
685 * will be displayed at the terminal.
686 *
687 * first string Hello
688 */
689 out[0] = strlen ("Hello");
690 memcpy (&out[1], "Hello", 5);
691 /*
692 * add a spare line with an empty string
693 */
694 out [6] = 0;
695 /*
696 * second string World
697 */
698 out [7] = strlen ("World");
699 memcpy (&out[8], "World", 5);
700
701 /*
702 * end of string list
703 */
704 out [13] = (CHAR) 0xff;
705 return( AT_CMPL );
706
707 #ifndef WIN32
708 case 'R':
709 case 'r':
710 *cmdLen -= 2;
711 l1dmacro_init_hw();
712 out[0] = 0;
713 out[1] = (CHAR) 0xFF;
714 return( AT_CMPL );
715 #endif
716
717 #ifndef WIN32
718 case 'V':
719 case 'v':
720 *cmdLen -= 2;
721
722 /*
723 * Display version numbers
724 */
725
726 cmh_show_version (cmd, cmdLen, out);
727 return( AT_CMPL );
728 #endif
729 #if defined (ALR)
730 case 'T':
731 case 't':
732 /*
733 * Enables RTC or AUDIO tests
734 */
735 cmd++;
736 *cmdLen -= 3;
737 if (!strncmp(cmd, "A", 1) || !strncmp(cmd, "a", 1))
738 {
739 //audio_test_misc();
740 out[0] = 22;
741 memcpy (&out[1], "Performing Audio Tests", 22);
742 out [23] = (CHAR) 0xff;
743 }
744 else
745 {
746 if (!strncmp(cmd, "R", 1) || !strncmp(cmd, "r", 1))
747 {
748 //rtc_test_misc();
749 out[0] = 20;
750 memcpy (&out[1], "Performing RTC Tests", 20);
751 out [21] = (CHAR) 0xff;
752 }
753 else
754 return( AT_FAIL );
755 }
756 return( AT_CMPL );
757 #endif
758 default:
759 *cmdLen -= 2;
760 return ( AT_FAIL );
761 }
762 }
763 else if ( *cmd EQ 'D' )
764 {
765 T_ACI_RETURN rslt;
766
767 /*
768 * this is only a test implementation. As soon as a "ATD" command
769 * string is detected in the AT interpreter and the mobile is not
770 * yet registered (neither limited nor full service is availbale)
771 * this function is called. Then instead of dialling immediately
772 * an activation of the mobile is performed in advance.
773 */
774 strncpy ( extDialNum, cmd + 1, MINIMUM ( MAX_PHB_NUM_LEN - 1,
775 *cmdLen - 1 ) );
776 extDialNum[MINIMUM ( MAX_PHB_NUM_LEN - 1, *cmdLen - 1 )] = '\0';
777
778 extCmdLen = 0;
779 *cmdLen = 0;
780
781 rslt = sAT_PlusCFUN ( CMD_SRC_LCL,
782 CFUN_FUN_Full,
783 CFUN_RST_NotPresent );
784
785 if ( rslt EQ AT_EXCT )
786 {
787 /*
788 * generate some output at the AT interface
789 */
790 ext_CreatePString ( out, EXT_ATCFUN );
791
792 /*
793 * indicating that an extended AT command is still in progress
794 */
795 currExtCmd = AT_CMD_CFUN;
796 }
797 else
798 {
799 ext_LeaveEXT ( TRUE );
800 rCI_PlusCME ( AT_CMD_EXT, CME_ERR_Unknown );
801 }
802
803 return ( rslt );
804 }
805 else
806 return( AT_FAIL );
807 }
808
809 /*
810 +--------------------------------------------------------------------+
811 | PROJECT : GSM-PS (6147) MODULE : CST_EXTS |
812 | STATE : code ROUTINE : percentCFG |
813 +--------------------------------------------------------------------+
814
815 PURPOSE : %CFG command (enables dynamic configuration of the
816 protocol stack using the AT command interface)
817 */
818
819 EXTERN char *parse (char *b, char *f, ...);
820
821 GLOBAL SHORT cc_pei_config (char * inString,
822 char * outString);
823 GLOBAL SHORT cst_pei_config (char * inString,
824 char * outString);
825 GLOBAL SHORT dl_pei_config (char * inString,
826 char * outString);
827 GLOBAL SHORT mm_pei_config (char * inString,
828 char * outString);
829 GLOBAL SHORT rr_pei_config (char * inString,
830 char * outString);
831 GLOBAL SHORT sim_pei_config (char * inString,
832 char * outString);
833 GLOBAL SHORT sms_pei_config (char * inString,
834 char * outString);
835 GLOBAL SHORT ss_pei_config (char * inString,
836 char * outString);
837 GLOBAL SHORT pl_pei_config (char * inString,
838 char * outString);
839
840 #ifdef FAX_AND_DATA
841 GLOBAL SHORT fad_pei_config (char * inString,
842 char * outString);
843 GLOBAL SHORT l2r_pei_config (char * inString,
844 char * outString);
845 GLOBAL SHORT ra_pei_config (char * inString,
846 char * outString);
847 GLOBAL SHORT rlp_pei_config (char * inString,
848 char * outString);
849 GLOBAL SHORT t30_pei_config (char * inString,
850 char * outString);
851 #endif
852
853 GLOBAL CHAR* percentCFG ( CHAR* cl )
854 {
855 CHAR entity[5];
856 CHAR config[40];
857 CHAR dummy;
858
859 TRACE_FUNCTION ( "percentCFG()" );
860
861 switch ( *cl )
862 {
863 case('='):
864 {
865 cl++;
866
867 cl = parse ( cl, "ss", ( LONG )sizeof(entity), entity,
868 ( LONG )sizeof(config), config );
869
870 if( !cl OR
871 *entity EQ '\0' OR
872 *config EQ '\0' )
873 {
874 return ( NULL );
875 }
876
877 break;
878 }
879
880 default:
881 {
882 return ( NULL );
883 }
884 }
885
886 if ( strcmp ( entity, CC_NAME ) EQ 0 )
887 {
888 cc_pei_config ( config, &dummy );
889 }
890 else if ( strcmp ( entity, CST_NAME ) EQ 0 )
891 {
892 cst_pei_config ( config, &dummy );
893 }
894 else if ( strcmp ( entity, DL_NAME ) EQ 0 )
895 {
896 dl_pei_config ( config, &dummy );
897 }
898 else if ( strcmp ( entity, MM_NAME ) EQ 0 )
899 {
900 mm_pei_config ( config, &dummy );
901 }
902 else if ( strcmp ( entity, RR_NAME ) EQ 0 )
903 {
904 rr_pei_config ( config, &dummy );
905 }
906 else if ( strcmp ( entity, SIM_NAME ) EQ 0 )
907 {
908 sim_pei_config ( config, &dummy );
909 }
910 else if ( strcmp ( entity, SMS_NAME ) EQ 0 )
911 {
912 sms_pei_config ( config, &dummy );
913 }
914 else if ( strcmp ( entity, SS_NAME ) EQ 0 )
915 {
916 ss_pei_config ( config, &dummy );
917 }
918 else if ( strcmp ( entity, PL_NAME ) EQ 0 )
919 {
920 pl_pei_config ( config, &dummy );
921 }
922
923 #ifdef FAX_AND_DATA
924
925 else if ( strcmp ( entity, FAD_NAME ) EQ 0 )
926 {
927 fad_pei_config ( config, &dummy );
928 }
929 else if ( strcmp ( entity, L2R_NAME ) EQ 0 )
930 {
931 l2r_pei_config ( config, &dummy );
932 }
933 else if ( strcmp ( entity, RA_NAME ) EQ 0 )
934 {
935 ra_pei_config ( config, &dummy );
936 }
937 else if ( strcmp ( entity, RLP_NAME ) EQ 0 )
938 {
939 rlp_pei_config ( config, &dummy );
940 }
941 else if ( strcmp ( entity, T30_NAME ) EQ 0 )
942 {
943 t30_pei_config ( config, &dummy );
944 }
945
946 #endif
947
948 else
949 {
950 return ( NULL );
951 }
952
953 return ( cl );
954 }
955
956 /*
957 +--------------------------------------------------------------------+
958 | PROJECT : GSM-PS (6147) MODULE : CST_EXTS |
959 | STATE : code ROUTINE : percentDBG |
960 +--------------------------------------------------------------------+
961
962 PURPOSE : %RST command (simulates pressing the reset button
963 of the ASample)
964 */
965
966 #ifndef TRACE_PORT_TIMING
967 #ifdef _TMS470
968 #if (CHIPSET == 0)
969 EXTERN void l1s_set_debug_pin ( UBYTE, UBYTE );
970 #endif
971 #endif
972 #endif
973
974 GLOBAL CHAR* percentDBG ( CHAR* cl )
975 {
976 SHORT line = 1;
977 SHORT polarity = 1;
978 SHORT delay = 650;
979
980 TRACE_FUNCTION ( "atPercentDBG()" );
981
982 switch ( *cl )
983 {
984 case( '\0' ):
985 {
986 break;
987 }
988
989 case('='):
990 {
991 cl++;
992
993 cl = parse ( cl, "rrr", &line, &polarity, &delay );
994
995 if( !cl OR
996 polarity < 0 OR polarity > 1 OR
997 line < 0 OR line > 7 OR
998 delay < 0 )
999 {
1000 return ( NULL );
1001 }
1002
1003 break;
1004 }
1005
1006 default:
1007 {
1008 return ( NULL );
1009 }
1010 }
1011
1012 #ifndef TRACE_PORT_TIMING
1013 #ifdef _TMS470
1014 #if (CHIPSET == 0)
1015 #if defined (NEW_FRAME)
1016 vsi_t_sleep ( VSI_CALLER ( T_TIME ) delay );
1017 #else
1018 vsi_t_sleep ( VSI_CALLER ( T_VSI_TVALUE ) delay );
1019 #endif
1020
1021 l1s_set_debug_pin ( ( UBYTE ) line, ( UBYTE ) polarity );
1022 #endif
1023 #endif
1024 #endif
1025
1026 return ( cl );
1027 }
1028
1029 /*
1030 +--------------------------------------------------------------------+
1031 | PROJECT : GSM-PS (6147) MODULE : CMH_EXTS |
1032 | STATE : code ROUTINE : rAT_ACP |
1033 +--------------------------------------------------------------------+
1034
1035 PURPOSE : This function is called by the interpreter part of the
1036 ACI in case of aborting a pending extension command.
1037
1038 <out> : this parameter can be used to display some
1039 strings at the AT command interface.
1040 The first char of one string must contain
1041 the length of the following string. The
1042 special length 0xff must be used to define
1043 the end of the string list.
1044 <outLen> : maximum length of output buffer referenced
1045 by parameter <out>.
1046
1047 */
1048
1049 GLOBAL T_ACI_RETURN rAT_ACP (
1050 CHAR* out,
1051 USHORT outLen
1052 )
1053 {
1054 T_ACI_RETURN rslt = AT_CMPL;
1055
1056 /* call the abort function if necessary */
1057 if ( currExtCmd NEQ AT_CMD_NONE )
1058 rslt = sAT_Abort (CMD_SRC_LCL, currExtCmd );
1059
1060 switch ( rslt )
1061 {
1062 case ( AT_CMPL ):
1063 {
1064 currExtCmd = AT_CMD_NONE;
1065
1066 ext_LeaveEXT ( TRUE );
1067 }
1068 break;
1069
1070 case ( AT_EXCT ):
1071 {
1072 currExtCmd = AT_CMD_ABRT;
1073 }
1074 break;
1075
1076 default:
1077 {
1078 /* do nothing */
1079 }
1080 break;
1081 }
1082
1083 return rslt;
1084 }
1085
1086 /*
1087 +--------------------------------------------------------------------+
1088 | PROJECT : GSM-PS (6147) MODULE : CMH_EXTS |
1089 | STATE : code ROUTINE : ext_OK |
1090 +--------------------------------------------------------------------+
1091
1092 PURPOSE : This function is called by the MMI in case the positive
1093 result of the asynchronous command handling is available.
1094
1095 <cmdId>: command identity
1096
1097 */
1098 GLOBAL void ext_OK ( T_ACI_AT_CMD cmdId )
1099 {
1100 T_ACI_RETURN rslt;
1101
1102 if ( cmdId EQ AT_CMD_CFUN AND currAbrtCmd EQ AT_CMD_NONE )
1103 {
1104 rslt = sAT_PlusCOPS ( CMD_SRC_LCL,
1105 COPS_MOD_Auto,
1106 COPS_FRMT_NotPresent,
1107 NULL );
1108
1109 if ( rslt EQ AT_EXCT )
1110 {
1111 /*
1112 * generate some output at the AT interface
1113 */
1114 ext_CreatePString ( extBuffer, EXT_ATCOPS_START );
1115
1116 sAT_URC ( extBuffer );
1117
1118 /*
1119 * indicating that an extended AT command is still in progress
1120 */
1121 currExtCmd = AT_CMD_COPS;
1122 }
1123 else
1124 {
1125 ext_LeaveEXT ( TRUE );
1126 rCI_PlusCME ( AT_CMD_EXT, CME_ERR_Unknown );
1127 }
1128 }
1129 else if ( cmdId EQ AT_CMD_COPS AND currAbrtCmd EQ AT_CMD_NONE )
1130 {
1131 currExtCmd = AT_CMD_NONE;
1132
1133 /*
1134 * generate some output at the AT interface
1135 */
1136 ext_CreatePString ( extBuffer, EXT_ATCOPS_STOP );
1137
1138 sAT_URC ( extBuffer );
1139
1140 #ifndef WIN32
1141 ext_ContinueTest ( EXT_DIAL_VOICE_PASS );
1142 #endif
1143 }
1144 else if ( cmdId EQ AT_CMD_D AND currAbrtCmd EQ AT_CMD_NONE )
1145 {
1146 extCallId = 1;
1147
1148 ext_LeaveEXT ( TRUE );
1149 rCI_OK ( AT_CMD_EXT );
1150 }
1151 else if ( currAbrtCmd NEQ AT_CMD_NONE )
1152 {
1153 currAbrtCmd = AT_CMD_NONE;
1154
1155 ext_LeaveEXT ( TRUE );
1156 rCI_OK ( AT_CMD_EXT );
1157 }
1158 else
1159 {
1160 /*
1161 * generate some output at the AT interface
1162 */
1163 ext_CreatePString ( extBuffer, EXT_UNEXPCTD );
1164
1165 sAT_URC ( extBuffer );
1166 }
1167 }
1168
1169 /*
1170 +--------------------------------------------------------------------+
1171 | PROJECT : GSM-PS (6147) MODULE : CMH_EXTS |
1172 | STATE : code ROUTINE : ext_LeaveExtension |
1173 +--------------------------------------------------------------------+
1174
1175 PURPOSE : This function is called in case the extensin mechansim
1176 should be left finally.
1177
1178 <final>: indicates whether final result code should be
1179 sent explicitly
1180
1181 */
1182 LOCAL void ext_LeaveEXT ( BOOL final )
1183 {
1184 /*
1185 * generate some output at the AT interface
1186 */
1187 ext_CreatePString ( extBuffer, EXT_LEAVE );
1188
1189 /*
1190 * indicating that no extended AT command is still in progress
1191 */
1192 currExtCmd = AT_CMD_NONE;
1193
1194 /*
1195 * indicate end of extended command handling to the AT interpreter
1196 */
1197 sAT_URC ( extBuffer );
1198
1199 if ( final )
1200 {
1201 sAT_FRI ( extCmdLen );
1202 }
1203 }
1204
1205 /*
1206 +--------------------------------------------------------------------+
1207 | PROJECT : GSM-PS (6147) MODULE : CMH_EXTS |
1208 | STATE : code ROUTINE : ext_ContinueTest |
1209 +--------------------------------------------------------------------+
1210
1211 PURPOSE : This function is called in case the AT extension
1212 procedure should be continued.
1213
1214 <id>: identifies the specific procedure to be continued
1215
1216 */
1217 GLOBAL void ext_ContinueTest ( CHAR* id )
1218 {
1219 T_ACI_RETURN rslt;
1220
1221 if ( strcmp ( id, EXT_DIAL_VOICE_PASS ) EQ 0 )
1222 {
1223 T_ACI_D_TOC callType = D_TOC_Data;
1224
1225 if ( extDialNum [strlen ( extDialNum ) - 1] EQ EXT_VOICE_DELIMITER )
1226 callType = D_TOC_Voice;
1227
1228 extDialNum[strlen ( extDialNum ) - 1] = '\0';
1229
1230 rslt = sAT_Dn ( CMD_SRC_LCL,
1231 extDialNum,
1232 D_CLIR_OVRD_Default,
1233 D_CUG_CTRL_NotPresent,
1234 callType );
1235
1236 if ( rslt EQ AT_EXCT )
1237 {
1238 /*
1239 * generate some output at the AT interface
1240 */
1241 ext_CreatePString ( extBuffer, EXT_ATD );
1242
1243 sAT_URC ( extBuffer );
1244
1245 /*
1246 * indicating that an extended AT command is still in progress
1247 */
1248 currExtCmd = AT_CMD_D;
1249 }
1250 else
1251 {
1252 ext_LeaveEXT ( TRUE );
1253 rCI_PlusCME ( AT_CMD_EXT, CME_ERR_Unknown );
1254 }
1255 }
1256 }
1257
1258 /*
1259 +--------------------------------------------------------------------+
1260 | PROJECT : GSM-PS (6147) MODULE : CMH_EXTS |
1261 | STATE : code ROUTINE : ext_CreatePString |
1262 +--------------------------------------------------------------------+
1263
1264 PURPOSE :
1265
1266 */
1267 LOCAL void ext_CreatePString ( CHAR* buffer, CHAR* text )
1268 {
1269 buffer[0] = strlen (text);
1270 memcpy (&buffer[1], text, buffer[0]);
1271 buffer [buffer[0]+1] = (CHAR) 0xff;
1272 }