comparison g23m/condat/ms/src/aci/ati_bas.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)
4 | Modul : ATI
5 +-----------------------------------------------------------------------------
6 | Copyright 2002 Texas Instruments Berlin, AG
7 | All rights reserved.
8 |
9 | This file is confidential and a trade secret of Texas
10 | Instruments Berlin, AG
11 | The receipt of or possession of this file does not convey
12 | any rights to reproduce or disclose its contents or to
13 | manufacture, use, or sell anything it may describe, in
14 | whole, or in part, without the specific written consent of
15 | Texas Instruments Berlin, AG.
16 +-----------------------------------------------------------------------------
17 | Purpose : AT Command Interpreter: basic functions.
18 +-----------------------------------------------------------------------------
19 */
20
21 #ifndef ATI_BAS_C
22 #define ATI_BAS_C
23
24 #include "aci_all.h"
25
26 #include <ctype.h>
27 #include <string.h>
28
29 #include "aci_cmh.h"
30 #include "ati_cmd.h"
31 #include "aci_cmd.h"
32 #include "aci_io.h"
33 #include "aci_cmd.h"
34 #include "l4_tim.h"
35 #include "line_edit.h"
36 #include "aci_lst.h"
37
38 #include "pcm.h"
39 #include "audio.h"
40 #include "aci.h"
41 #include "rx.h"
42 #include "pwr.h"
43 #include "l4_tim.h"
44
45
46 #ifdef GPRS
47 #ifdef DTI
48 #include "dti.h"
49 #include "dti_conn_mng.h"
50 #include "dti_cntrl_mng.h"
51 #endif /* DTI */
52 #include "gaci.h"
53 #include "gaci_cmh.h"
54 #include "gaci_cmd.h"
55 #endif /* GPRS */
56
57 #include "aci_mem.h"
58 #include "aci_prs.h"
59
60 #include "ati_int.h"
61
62 #ifndef _SIMULATION_
63 #include "ffs\ffs.h"
64 #endif
65
66 #ifdef FF_ATI_BAT
67
68 #include "typedefs.h"
69 #include "gdd.h"
70 #include "bat.h"
71
72 #include "ati_bat.h"
73
74 #endif /*FF_ATI_BAT*/
75
76 LOCAL T_ATI_RSLT aciPrcsPlusCG (UBYTE srcId, CHAR* cl, CHAR* ef);
77 LOCAL T_ATI_RSLT setaciPrcsVolLevel ( CHAR* cl, UBYTE device );
78 LOCAL T_ATI_RSLT tesaciPrcsVolLevel ( UBYTE srcId, CHAR* cl, UBYTE device );
79 LOCAL T_ATI_RSLT queaciPrcsVolLevel ( UBYTE srcId, CHAR* cl, UBYTE device );
80
81 EXTERN T_ATI_RSLT setatPlusCLIP (char *cl, UBYTE srcId);
82 EXTERN T_ATI_RSLT setatPlusCOLP (char *cl, UBYTE srcId);
83 EXTERN T_ATI_RSLT setatPlusCREG (char *cl, UBYTE srcId);
84 EXTERN T_ATI_RSLT setatPercentCREG (char *cl, UBYTE srcId);
85 EXTERN T_ATI_RSLT setatPlusCGREG (char *cl, UBYTE srcId);
86 EXTERN T_ATI_RSLT setatPercentCGREG (char *cl, UBYTE srcId);
87 EXTERN T_ATI_RSLT setatPlusCCLK (char *cl, UBYTE srcId);
88 EXTERN T_ATI_RSLT queatPlusCCLK (char *cl, UBYTE srcId);
89
90 /* for atAndF */
91 EXTERN void ati_cmd_reset(UBYTE srcId);
92
93
94 GLOBAL const T_ACI_AT_CMD atw_cmd_list [] = {AT_CMD_CGREG, AT_CMD_CLIP, AT_CMD_CLIR,
95 AT_CMD_COLP, AT_CMD_CREG, AT_CMD_ALS, AT_CMD_CGAATT,
96 AT_CMD_P_CGREG, AT_CMD_CPI, AT_CMD_P_CREG, AT_CMD_NONE};
97
98
99 #define MAX_IDX_LTH (10)
100
101 #define MAX_ATW_STORED_PROFILE 2 /*profile number for AT&W*/
102 #define MAX_ATW_CMD_NAM_LEN 15 /*Max command name length in bytes, e.g. %CGAATT;*/
103 #define MAX_ONE_ATW_PRO_LEN 50 /*Max profile length of 1 command in bytes,so far %CGAATT has the longest
104 profile length /CmdId/Total Len/token/1st Para length/1st para/token/2nd para length/2nd para/'\0'/*/
105 #define STRING 1 /*Token: string*/
106 #define SIGNED_VALUE 2 /*Token: signed value*/
107 #define UNSIGNED_VALUE 3 /*Token: unsigned value*/
108 #define MAX_ATW_CHOSEN_CMD_NB (sizeof(atw_cmd_list)/sizeof(T_ACI_AT_CMD) -1)
109 /*Max number of AT commands can be chosen by user, -1 because the last entry is only an ending symbol*/
110
111
112 /* for profile handling ATZ and AT&W */
113 #ifdef _SIMULATION_
114 LOCAL CHAR atw_cmd_list_simu [(MAX_ATW_CMD_NAM_LEN) *( MAX_ATW_CHOSEN_CMD_NB) + 1] = {'\0'};
115 LOCAL UBYTE atw_profile_simu [MAX_ATW_STORED_PROFILE][(MAX_ATW_CHOSEN_CMD_NB) * (MAX_ONE_ATW_PRO_LEN)+1]={{'\0'},{'\0'}};
116 /* simulates the profile arrays for windows test*/
117 #endif
118 static UBYTE ATZprofile;
119
120 GLOBAL const DBG_Memory dbg_mem_names[] =
121 {
122 {"PRI", P_DBGINFO_PrimPoolPartition},
123 {"MEM", P_DBGINFO_DmemPoolPartition},
124 {"DAT", P_DBGINFO_DataPoolPartition},
125 {0, 0}
126 };
127
128 /*
129 +--------------------------------------------------------------------+
130 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
131 | STATE : code ROUTINE : atBW |
132 +--------------------------------------------------------------------+
133
134 PURPOSE : B command (only implemented to maintain compability)
135 W command (only implemented to maintain compability)
136 */
137
138 GLOBAL T_ATI_RSLT atBW(char *cl, UBYTE srcId)
139 {
140 SHORT i=0;
141 TRACE_FUNCTION("atB()");
142
143 while (*cl >= '0' AND *cl <= '9')
144 {
145 cl++;
146 i++;
147 if (i > 1)
148 {
149 cmdAtError(atError);
150 return ATI_FAIL;
151 }
152 }
153 return ATI_CMPL;
154 }
155
156
157
158 /*
159 +--------------------------------------------------------------------+
160 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
161 | STATE : code ROUTINE : atE |
162 +--------------------------------------------------------------------+
163
164 PURPOSE : E command (command echo setting)
165 F command (data echo setting)
166 L command (Speaker Volume)
167 M command (Speaker Mode)
168 Q command (result code supression)
169 V command (verbose response setting)
170 X command (Busy/Dial tone indication)
171 */
172
173 GLOBAL T_ATI_RSLT atEFLMQVX(char *cl, UBYTE srcId)
174 {
175 char *end = NULL;
176 UBYTE value = 0;
177 CHAR letter = *(cl - 1);
178 T_LEDIT line = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; /* init with values which say: do not change */
179 /* S3 S4 S5 atE smsEnd */
180 TRACE_FUNCTION("atEFLMQVX()");
181
182 TRACE_EVENT_P1 ("letter = %02X", letter);
183
184 value = (UBYTE)strtol(cl, &end, 10);
185 if(*end )
186 {
187 cmdAtError(atError);
188 return ATI_FAIL;
189 }
190
191 switch(letter)
192 {
193 case('E'):
194 if (value > 1)
195 {
196 cmdAtError(atError);
197 return ATI_FAIL;
198 }
199 ati_user_output_cfg[srcId].atE = value;
200 /*
201 * line edit need this piece of information, as well
202 */
203 line.atE = ati_user_output_cfg[srcId].atE;
204 ledit_set_config (srcId, line);
205 return ATI_CMPL; /* return to prevent non used p at the end of this function */
206 case('F'):
207 break;
208 case('L'):
209 if (value > 3)
210 {
211 cmdAtError(atError);
212 return ATI_FAIL;
213 }
214 at.s1415.atL = value;
215 break;
216 case('M'):
217 if (value > 2)
218 {
219 cmdAtError(atError);
220 return ATI_FAIL;
221 }
222 at.s1415.atM = value;
223 break;
224 case('Q'):
225 if (value > 1)
226 {
227 cmdAtError(atError);
228 return ATI_FAIL;
229 }
230 ati_user_output_cfg[srcId].atQ = value;
231 break;
232 case('V'):
233 if (value > 1)
234 {
235 cmdAtError(atError);
236 return ATI_FAIL;
237 }
238 at.s1415.atV = value;
239 break;
240 case('X'):
241 if (value > 4)
242 {
243 cmdAtError(atError);
244 return ATI_FAIL;
245 }
246 ati_user_output_cfg[srcId].atX = value;
247 break;
248 default:
249 cmdAtError(atError);
250 return ATI_FAIL;
251 }
252
253 return ATI_CMPL;
254 }
255
256 /*
257 +--------------------------------------------------------------------+
258 | PRIJECT : GSM-F&D (8411) MIDULE : ACI_CMD |
259 | STATE : code RIUTINE : atI |
260 +--------------------------------------------------------------------+
261
262 PURPOSE : I command (identification)
263 */
264
265 GLOBAL T_ATI_RSLT atI(char *cl, UBYTE srcId)
266 {
267 CHAR* ef = EF_INF0_ID;
268 pcm_FileInfo_Type fileInfo;
269 USHORT value;
270 USHORT maxRecords;
271 USHORT i;
272
273 TRACE_FUNCTION("atI()");
274
275 parse (cl, "r", &value);
276 if (!cl)
277 {
278 value = 0;
279 }
280
281 /*
282 * The switch case here is intended for values which are reserved for
283 * the protocol stack manufacturer and cannot be overridden by values
284 * in the PCM/FFS.
285 */
286 switch (value)
287 {
288 case 99:
289 io_sendMessage(srcId, "Texas Instruments", ATI_NORMAL_OUTPUT);
290 return ATI_CMPL;
291
292 default:
293 break;
294 }
295
296 if (pcm_GetFileInfo ((UBYTE*)ef, &fileInfo) NEQ DRV_OK)
297 {
298 cmdCmeError (CME_ERR_MemFail);
299 return ATI_FAIL;
300 }
301
302 if (pcm_ReadRecord ((UBYTE*)ef, (USHORT)(value + 1), fileInfo.FileSize,
303 (UBYTE*)g_sa, &fileInfo.Version, &maxRecords) NEQ DRV_OK)
304 {
305 cmdCmeError (CME_ERR_MemFail);
306 return ATI_FAIL;
307 }
308
309 i = 0;
310 while ((UBYTE)g_sa[i] NEQ 0xFF)
311 {
312 i++;
313 }
314 g_sa[i] = '\0';
315 io_sendMessage (srcId, g_sa, ATI_NORMAL_OUTPUT );
316
317 return ATI_CMPL;
318 }
319
320 /*
321 +--------------------------------------------------------------------+
322 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
323 | STATE : code ROUTINE : atTP |
324 +--------------------------------------------------------------------+
325
326 PURPOSE : TP command (select tone/pulse dialing < only implemented to
327 maintain compability>)
328 */
329
330 GLOBAL T_ATI_RSLT atTP(char *cl, UBYTE srcId)
331 {
332 TRACE_FUNCTION("atTP()");
333
334 if (*cl >= '0' AND *cl <= '9')
335 {
336 cmdAtError(atError);
337 return ATI_FAIL;
338 }
339 else
340 {
341 return ATI_CMPL;
342 }
343 }
344
345 /*
346 +--------------------------------------------------------------------+
347 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
348 | STATE : code ROUTINE : atS |
349 +--------------------------------------------------------------------+
350
351 PURPOSE : S command (S register setting)
352 */
353
354 GLOBAL T_ATI_RSLT atS(char *cl, UBYTE srcId)
355 {
356 SHORT reg_num,reg_cont,i=0;
357 char cont[4];
358 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
359 T_LEDIT line = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; /* init with values, which say: do not change */
360 T_ATI_RSLT retcd = ATI_CMPL;
361
362 TRACE_FUNCTION("atS()");
363
364 reg_num=0;
365 while (isdigit (*cl))
366 {
367 reg_num *= 10;
368 reg_num += *cl-'0';
369 ++cl;
370 }
371
372 switch (*cl)
373 {
374 case('?'):
375 {
376 cl++;
377 switch (reg_num)
378 {
379 case 0: /* supported registers for read access are listed here */
380 case 1:
381 case 2:
382 case 3:
383 case 4:
384 case 5:
385 case 6:
386 case 7:
387 case 8:
388 case 10: reg_cont = at.S[reg_num]; break; /* index access register */
389 case 30: reg_cont = at.S30; break; /* direct access register */
390 #ifdef GPRS
391 case 99: reg_cont = at.S99; break;
392 #endif /* GPRS */
393
394 default:
395 cmdAtError(atError);
396 return ATI_FAIL;
397 }
398
399 sprintf(g_sa,"%03d", reg_cont);
400
401 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
402 return ATI_CMPL;
403 }
404
405 case('='):
406 {
407 cl++;
408 if(*cl EQ '?')
409 {
410 cl++;
411
412 switch(reg_num)
413 {
414 case(0): sprintf(g_sa,"S%d:%s",reg_num,"(0-255)"); break;
415 /*case(1):*/ /* S1 register is read only !!! */
416 case(2):
417 case(3):
418 case(4):
419 case(5): sprintf(g_sa,"S%d:%s",reg_num,"(0-127)"); break;
420 case(6): sprintf(g_sa,"S%d:%s",reg_num,"(2-10)"); break;
421 case(7): sprintf(g_sa,"S%d:%s",reg_num,"(1-255)"); break;
422 case(8): sprintf(g_sa,"S%d:%s",reg_num,"(0-255)"); break;
423 case(10):
424 case(30): sprintf(g_sa,"S%d:%s",reg_num,"(1-254)"); break;
425 #ifdef GPRS
426 case(31): sprintf(g_sa,"S%d:%s",reg_num,"(0-255)"); break;
427 #endif /* GPRS */
428
429 default:
430 cmdAtError(atError);
431 return ATI_FAIL;
432 }
433 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
434 return ATI_CMPL;
435 }
436 else
437 {
438 while (*cl >= '0' AND *cl <= '9' AND i < 3)
439 {
440 cont[i] = (*cl);
441 i++;
442 cl++;
443 }
444 if (!i)
445 {
446 cmdAtError(atError);
447 return ATI_FAIL;
448 }
449 cont[i]='\0';
450 reg_cont=atoi(cont);
451 switch(reg_num)
452 {
453 case(0):
454 if (reg_cont<0 OR reg_cont > 255)
455 {
456 cmdAtError(atError);
457 return ATI_FAIL;
458 }
459 at.rngPrms.srcID_S0 = srcId;
460
461 #if defined (GPRS) AND defined (DTI)
462
463 /*
464 * Special case of implict attach to GACI when S0 is set to
465 * Non-zero value. GSM 7.07 version 6.4.0 10.2.2.1
466 */
467 if ( reg_cont > 0 )
468 {
469 T_CGCLASS_CLASS m_class;
470 T_ACI_RETURN ret;
471
472 if (AT_CMPL NEQ qAT_PlusCGCLASS(srcId, &m_class))
473 {
474 cmdAtError(atError);
475 return ATI_FAIL;
476 }
477 /*
478 * no GPRS attach requested if only GSM mobile
479 */
480 if ( CGCLASS_CLASS_CC NEQ m_class)
481 {
482 ret = sAT_PlusCGATT ( srcId, CGATT_STATE_ATTACHED );
483 switch (ret)
484 {
485 case (AT_CMPL): /*operation completed*/
486 break;
487 case (AT_EXCT):
488 src_params->curAtCmd = AT_CMD_CGATT;
489 retcd = ATI_EXCT;
490 break;
491 default:
492 cmdAtError(atError); /*Command failed*/
493 return ATI_FAIL;
494 }
495 }
496 }
497 #endif /* GPRS */
498 break;
499 case(2):
500 if (reg_cont<0 OR reg_cont > 127)
501 {
502 cmdAtError(atError);
503 return ATI_FAIL;
504 }
505 break;
506 case(3):
507 if (reg_cont<0 OR reg_cont > 127)
508 {
509 cmdAtError(atError);
510 return ATI_FAIL;
511 }
512 line.S3 = (UBYTE)reg_cont;
513 break;
514 case(4):
515 if (reg_cont<0 OR reg_cont > 127)
516 {
517 cmdAtError(atError);
518 return ATI_FAIL;
519 }
520 line.S4 = (UBYTE)reg_cont;
521 break;
522 case(5):
523 if (reg_cont<0 OR reg_cont > 127)
524 {
525 cmdAtError(atError);
526 return ATI_FAIL;
527 }
528 line.S5 = (UBYTE)reg_cont;
529 break;
530 case(6):
531 if (reg_cont<2 OR reg_cont > 10)
532 {
533 cmdAtError(atError);
534 return ATI_FAIL;
535 }
536 break;
537 case(7):
538 if (reg_cont<1 OR reg_cont > 255)
539 {
540 cmdAtError(atError);
541 return ATI_FAIL;
542 }
543 break;
544 case(8):
545 if (reg_cont<0 OR reg_cont > 255)
546 {
547 cmdAtError(atError);
548 return ATI_FAIL;
549 }
550 break;
551 case(10):
552 if (reg_cont<1 OR reg_cont > 254)
553 {
554 cmdAtError(atError);
555 return ATI_FAIL;
556 }
557 break;
558 case(30):
559 if (reg_cont<0 OR reg_cont > 254)
560 {
561 cmdAtError(atError);
562 return ATI_FAIL;
563 }
564 break;
565 #if defined (GPRS) AND defined (DTI)
566 case(99):
567
568 if (reg_cont<0 OR reg_cont > 255)
569 {
570 cmdAtError(atError);
571 return ATI_FAIL;
572 }
573 break;
574 #endif /* GPRS */
575
576 default:
577 cmdAtError(atError);
578 return ATI_FAIL;
579 }
580
581 switch (reg_num)
582 {
583
584 case 0: /* supported registers for write access are listed here */
585 /*case 1: Read Only */
586 case 2:
587 case 3:
588 case 4:
589 case 5:
590 case 6:
591 case 7:
592 case 8:
593 case 10: at.S[reg_num]=(UBYTE)reg_cont; break;
594
595 case 30: at.S30 =(UBYTE)reg_cont; break;
596 #if defined (GPRS) AND defined (DTI)
597 case 99: at.S99 =(UBYTE)reg_cont; break;
598 #endif
599
600 default:
601 cmdAtError(atError);
602 return ATI_FAIL;
603 }
604
605
606 /*
607 * line edit need this piece of information, as well
608 */
609 ledit_set_config (srcId, line);
610 break;
611 }
612 }
613 default:
614 cmdAtError(atError);
615 return ATI_FAIL;
616 }
617 return retcd;
618 }
619
620
621
622 /*
623 PURPOSE : this function stores the pre-chosen command list in FFS, but only for windows test.
624 */
625 #ifdef _SIMULATION_
626 LOCAL T_ATI_RSLT store_command_list (void)
627 {
628 char atw_cmd_list []= "+CGREG;+CLIP;+CLIR;+COLP;+CREG;%ALS;%CGAATT;%CGREG;%CPI;%CREG;";
629 TRACE_FUNCTION ("store_command_list()");
630
631 if ( !(strcpy (atw_cmd_list_simu, atw_cmd_list)))
632 {
633 cmdCmeError(CME_ERR_Unknown);
634 return ( ATI_FAIL);
635 }
636 return (ATI_CMPL);
637 }
638 #endif /*_SIMULATION_*/
639
640
641 /*
642 This function gets the command Id from input command name string if it is within the default listcmdList
643 */
644 LOCAL T_ACI_AT_CMD get_command_id_in_wn_list(CHAR *command_str)
645 {
646 int i;
647 T_ACI_AT_CMD command = AT_CMD_NONE;
648 TRACE_FUNCTION ("get_command_id_in_wn_list()");
649
650 command = get_command_id(command_str);
651 for (i = 0;*(atw_cmd_list+i) NEQ AT_CMD_NONE; i ++)
652 {
653 if (command EQ *(atw_cmd_list+i) )
654 {
655 return (command);
656 }
657 }
658 TRACE_EVENT_P1("AT&W: unrecognized command in the list: %s", command_str);
659 return (AT_CMD_NONE);
660 }
661
662 /*
663 PURPOSE : this function reads the pre-chosen command list in FFS and then builds a string
664 of all the command Ids according to the command list read.
665
666 Parameter:
667 cmd_id_read: To hold the list of command Ids
668 */
669
670 LOCAL T_ATI_RSLT read_command_list_from_ffs (UBYTE *cmd_id_read)
671 {
672 int i, k;
673 #ifndef _SIMULATION_
674 int val;
675 #endif /*_SIMULATION_*/
676 int j = 0;
677 CHAR *cmdList_temp;/*to hold the command name strings read from FFS*/
678 CHAR string_temp [MAX_ATW_CMD_NAM_LEN] = {'\0'};/* hold 1 command name string*/
679 T_ACI_AT_CMD command = AT_CMD_NONE;
680
681 TRACE_FUNCTION ("read_command_list_from_ffs()");
682 ACI_MALLOC (cmdList_temp, (MAX_ATW_CHOSEN_CMD_NB) *( MAX_ATW_CMD_NAM_LEN) + 1) ;
683
684 #ifndef _SIMULATION_
685 if ((val = ffs_fread ("/gsm/com/cmdList", cmdList_temp,
686 (MAX_ATW_CHOSEN_CMD_NB) *( MAX_ATW_CMD_NAM_LEN) + 1) )< 1)
687 {
688 TRACE_EVENT_P1("AT&W: Read command list from ffs fail. Returned val is %d", val);
689 #else /*!_SIMULATION_*/
690 if (!(strcpy (cmdList_temp, atw_cmd_list_simu)))
691 {
692 TRACE_EVENT("AT&W: Read command list fail. ");
693 #endif /*!_SIMULATION_*/
694 ACI_MFREE (cmdList_temp);
695 cmdCmeError(CME_ERR_Unknown);
696 return (ATI_FAIL);
697 }
698
699 /*The for loop builds the command string and then gets the corresponding command Id*/
700 for (i = 0, k = 0; *(cmdList_temp+i) NEQ '\0' AND k < (int)(MAX_ATW_CHOSEN_CMD_NB); i ++)
701 {
702 if (*(cmdList_temp+i) NEQ ';' )
703 {
704 /* No ";" is met*/
705 *(string_temp+j++) = *(cmdList_temp+i);
706 }
707 else
708 {
709 *(string_temp+j) = '\0';
710 command = get_command_id_in_wn_list (string_temp);
711 if (command NEQ AT_CMD_NONE) /* ignore it if unknown string met*/
712 {
713 *(cmd_id_read+k++) = (UBYTE)command;
714 }
715 j = 0;
716 *string_temp = '\0';
717 }
718 }
719 *(cmd_id_read+k) = (UBYTE)AT_CMD_NONE;
720 ACI_MFREE (cmdList_temp);
721 return (ATI_CMPL);
722 }
723
724 /*
725 PURPOSE : this function builds and stores the profile in FFS according to the command list read.
726 */
727 LOCAL T_ATI_RSLT store_profile_to_ffs (T_ACI_CMD_SRC srcId, SHORT nProfile)
728 {
729 int i;
730 #ifndef _SIMULATION_
731 int val;
732 #endif /*_SIMULATION_*/
733 int index = 1;
734 int command_length = 0;
735 /*to hold the content of parameters*/
736 #if defined (GPRS) AND defined (DTI)
737 T_CGAATT_ATTACH_MODE para1;
738 T_CGAATT_DETACH_MODE para2;
739 #endif /*GPRS*/
740 T_ACI_ALS_MOD para3 = ALS_MOD_NOTPRESENT;
741 T_ACI_CLIR_MOD mode = CLIR_MOD_NotPresent;
742 UBYTE *profile = NULL; /*to hold the content of profile, memory will be allocated later*/
743 UBYTE cmdIds [MAX_ATW_CHOSEN_CMD_NB +1] = {'\0'}; /*to hold the list of command Ids*/
744 char ffsAddr[] = "/gsm/com/profilex"; /*address in ffs, the x depends on which profile to save*/
745
746 TRACE_FUNCTION ("store_profile_to_ffs()");
747
748 ffsAddr[ strlen (ffsAddr) - 1] = '0' + nProfile;
749
750 /*before storing of profile read command list from FFS, cmdIds is used to hold the Ids of commands*/
751 if ( read_command_list_from_ffs (cmdIds) NEQ ATI_CMPL)
752 {
753 cmdCmeError(CME_ERR_Unknown);
754 return (ATI_FAIL);
755 }
756
757 /*command list is successfully read and now ready to build profile, allocate memory first*/
758 ACI_MALLOC (profile, (MAX_ATW_CHOSEN_CMD_NB) * (MAX_ONE_ATW_PRO_LEN) + 1);
759
760 /*this for_loop builds the profile*/
761 for (i = 0; *(cmdIds+i) NEQ AT_CMD_NONE; i ++)
762 {
763 command_length = 5;
764 TRACE_EVENT_P1 ("cmd id is: %d", *(cmdIds+i));
765 *(profile+index++) = *(cmdIds+i); /*stores command ID as the first element for each command*/
766
767 switch (*(cmdIds+i))
768 {
769 #if defined (GPRS) AND defined (DTI)
770 case AT_CMD_CGREG:
771 *(profile+index++) = command_length;/*total length in bytes for this command*/
772 *(profile+index++) = SIGNED_VALUE; /*token indicates the following parameter is signed*/
773 *(profile+index++) = sizeof (UBYTE); /*length of the following parameter*/
774 *(profile+index++) = (UBYTE)(ati_gprs_user_output_cfg[srcId].plus_cgreg.mod_lac_cid.pres_mode);
775 break;
776 case AT_CMD_P_CGREG:
777 *(profile+index++) = command_length;
778 *(profile+index++) = SIGNED_VALUE;
779 *(profile+index++) = sizeof (UBYTE);
780 *(profile+index++) = (UBYTE)(ati_gprs_user_output_cfg[srcId].percent_cgreg.mod_lac_cid.pres_mode);
781 break;
782 case AT_CMD_CGAATT:
783 qAT_PercentCGAATT(srcId, &para1, &para2);
784 command_length = 8;
785 *(profile+index++) = command_length;
786 *(profile+index++) = SIGNED_VALUE;
787 *(profile+index++) = sizeof (UBYTE);
788 *(profile+index++) = (UBYTE)para1; /*first param*/
789 *(profile+index++) = SIGNED_VALUE;
790 *(profile+index++) = sizeof (UBYTE);
791 *(profile+index++) = (UBYTE)para2; /*second param*/
792 break;
793 #endif /*GPRS*/
794 case AT_CMD_CLIP:
795 *(profile+index++) = command_length;
796 *(profile+index++) = UNSIGNED_VALUE;
797 *(profile+index++) = sizeof (UBYTE);
798 *(profile+index++) = ati_user_output_cfg[srcId].CLIP_stat;
799 break;
800 case AT_CMD_CPI:
801 *(profile+index++) = command_length;
802 *(profile+index++) = UNSIGNED_VALUE;
803 *(profile+index++) = sizeof (UBYTE);
804 *(profile+index++) = ati_user_output_cfg[srcId].CPI_stat;
805 break;
806 case AT_CMD_COLP:
807 *(profile+index++) = command_length;
808 *(profile+index++) = UNSIGNED_VALUE;
809 *(profile+index++) = sizeof (UBYTE);
810 *(profile+index++) = at.flags.COLP_stat;
811 break;
812
813 case AT_CMD_CLIR:
814 qAT_PercentCLIR (srcId, &mode);
815 *(profile+index++) = command_length;
816 *(profile+index++) = SIGNED_VALUE;
817 *(profile+index++) = sizeof (UBYTE);
818 *(profile+index++) = mode;
819 break;
820 case AT_CMD_ALS:
821 qAT_PercentALS (srcId, &para3);
822 *(profile+index++) = command_length;
823 *(profile+index++) = SIGNED_VALUE;
824 *(profile+index++) = sizeof (UBYTE);
825 *(profile+index++) = (UBYTE)para3;
826 break;
827 case AT_CMD_CREG:
828 *(profile+index++) = command_length;
829 *(profile+index++) = SIGNED_VALUE;
830 *(profile+index++) = sizeof (UBYTE);
831 *(profile+index++) = (UBYTE)ati_user_output_cfg[srcId].creg.mod_lac_cid.pres_mode;
832 break;
833 case AT_CMD_P_CREG:
834 *(profile+index++) = command_length;
835 *(profile+index++) = SIGNED_VALUE;
836 *(profile+index++) = sizeof (UBYTE);
837 *(profile+index++) = (UBYTE)(ati_user_output_cfg[srcId].percent_creg.mod_lac_cid.pres_mode);
838 break;
839
840 default:
841 TRACE_EVENT("Unknown AT command");
842 ACI_MFREE (profile);
843 cmdCmeError(CME_ERR_Unknown);
844 return (ATI_FAIL);
845 }
846 }
847
848 /*store the total length of the string in the first element, the max length of the profile should
849 not exceed 255, otherwise the stored structure in FFS should be redefined. Param <index>
850 is actually the length of the profile.
851 */
852 if (index > 255)
853 {
854 ACI_MFREE (profile);
855 TRACE_EVENT("Profile size exceed 255.");
856 cmdCmeError(CME_ERR_Unknown);
857 return (ATI_FAIL);
858 }
859 profile [0] = (UBYTE)index;
860
861 #ifndef _SIMULATION_
862 if((val = ffs_fwrite(ffsAddr, profile, index ) )NEQ EFFS_OK)
863 {
864 TRACE_EVENT_P1("Write to FFS fail. Returned value is %d", val);
865 ACI_MFREE (profile);
866 cmdCmeError(CME_ERR_Unknown);
867 return (ATI_FAIL);
868 }
869 #endif /*!_SIMULATION_*/
870
871 #ifdef _SIMULATION_
872 for (i = 0; i < index; i++)
873 {
874 atw_profile_simu[nProfile][i] = profile [i];
875 TRACE_EVENT_P2 ("index is %d, store profile is: %d", i, atw_profile_simu[nProfile][i]);
876 }
877 #endif /*_SIMULATION_*/
878 ACI_MFREE (profile);
879 return (ATI_CMPL);
880 }
881
882
883 /*
884 +--------------------------------------------------------------------+
885 | PROJECT : MODULE : |
886 | STATE : code ROUTINE : ati_wn_store_params|
887 +--------------------------------------------------------------------+
888
889 PURPOSE : This function is the implementation of of AT command AT&W
890 which stores the profile of some prechosen commands to FFS.
891 */
892
893 LOCAL T_ATI_RSLT ati_wn_store_params ( UBYTE srcId, SHORT nProfile)
894
895 {
896 TRACE_FUNCTION ("ati_wn_store_params()");
897
898 /*Stores pre-chosen AT commands. For windows test purpose only.*/
899 #ifdef _SIMULATION_
900 if (store_command_list () NEQ ATI_CMPL)
901 {
902 cmdCmeError(CME_ERR_Unknown);
903 return (ATI_FAIL) ;
904 }
905 #endif /*_SIMULATION_*/
906
907 /*Stores profile for chosen AT commands to FFS*/
908 if (store_profile_to_ffs ((T_ACI_CMD_SRC)srcId, nProfile) NEQ ATI_CMPL)
909 {
910 cmdCmeError(CME_ERR_Unknown);
911 return (ATI_FAIL) ;
912 }
913 return (ATI_CMPL);
914 }
915
916
917
918 /*
919 PURPOSE : this function reads the profile stored in FFS.
920 */
921
922 LOCAL T_ATI_RSLT read_profile_from_ffs (SHORT nProfile, UBYTE *profile_read, SHORT len_profile_read)
923 {
924 #ifndef _SIMULATION_
925 int val;
926 #endif
927 int i;
928 /*the last letter x depends on the profile to read*/
929 char ffsAddr[] = "/gsm/com/profilex";
930
931 TRACE_FUNCTION ("read_profile_from_ffs()");
932 /*build the correct address in FFS according to nProfile*/
933 ffsAddr[ strlen (ffsAddr) - 1] = '0' + nProfile;
934 TRACE_EVENT_P1 ("Read address is: %s", ffsAddr);
935
936 #ifndef _SIMULATION_
937 if ((val = ffs_fread (ffsAddr, profile_read, len_profile_read ))< 1)
938 {
939 TRACE_EVENT_P1("Read profile from FFS fail, returned val is %d", val);
940 cmdCmeError(CME_ERR_Unknown);
941 return (ATI_FAIL);
942 }
943 #endif /*_SIMULATION_*/
944
945 #ifdef _SIMULATION_
946 for (i = 0; i < atw_profile_simu[nProfile][0] ; i ++)
947 {
948 profile_read [i] = atw_profile_simu [nProfile][i];
949 TRACE_EVENT_P2 ("index %d, profile_read is: %d ", i, profile_read [i]);
950 }
951 #endif /*_SIMULATION_*/
952 return (ATI_CMPL);
953 }
954
955 /*
956 +------------------------------------------------------------------------------+
957 | PROJECT : GSM-PS (6147) MODULE : ATI_BAS |
958 | STATE : code ROUTINE : set_param_to_the_retrieved_value |
959 +------------------------------------------------------------------------------+
960
961 PURPOSE : this function handles command parameters.
962 */
963 LOCAL T_ATI_RSLT set_param_to_the_retrieved_value(UBYTE srcId, UBYTE *string)
964 {
965 int para = * (string+4); /*this is for functions with input param of type int*/
966 CHAR para1 = * (string+4); /*this is for functions with input param of type char*/
967 T_ATI_RSLT atiRet = ATI_FAIL;
968 T_ACI_RETURN aciRet = AT_FAIL;
969
970 TRACE_FUNCTION ("set_param_to_the_retrieved_value()");
971
972 /* string[2] is always the token and string[3] always the length.
973 so far we only have parameters with 1 byte length.*/
974 if ( *(string+2) EQ SIGNED_VALUE AND *(string+3) EQ sizeof (UBYTE))
975 {
976 para = ((* (string+4) > 127) ? *(string+4) -256: *(string+4));
977 }
978 para1 = (CHAR)(para + '0'); /*Transform to the corresponding inern value of the corresponding character*/
979 switch (*string)
980 {
981 case AT_CMD_CGREG:
982 #if defined (GPRS) AND defined (DTI)
983 atiRet = setatPlusCGREG ( &para1, srcId);
984 #else
985 atiRet = ATI_CMPL;
986 #endif /*GPRS*/
987 break;
988 case AT_CMD_P_CGREG:
989 #if defined (GPRS) AND defined (DTI)
990 atiRet = setatPercentCGREG (&para1, srcId);
991 #else
992 atiRet = ATI_CMPL;
993 #endif /*GPRS*/
994 break;
995 case AT_CMD_CGAATT:
996 #if defined (GPRS) AND defined (DTI)
997 aciRet = sAT_PercentCGAATT (srcId, para, (*(string+7) > 127) ? (*(string+7) - 256 ): *(string+7));
998 #else
999 aciRet = AT_CMPL;
1000 #endif /*GPRS*/
1001 break;
1002
1003 case AT_CMD_CLIP:
1004 atiRet = setatPlusCLIP ( &para1, srcId );
1005 break;
1006 case AT_CMD_CPI:
1007 ati_user_output_cfg[srcId].CPI_stat = string[4];
1008 atiRet = ATI_CMPL;
1009 break;
1010 case AT_CMD_COLP:
1011 atiRet = setatPlusCOLP (&para1, srcId);
1012 break;
1013 case AT_CMD_CLIR:
1014 aciRet = sAT_PlusCLIR ( (T_ACI_CMD_SRC)srcId, para);
1015 break;
1016 case AT_CMD_ALS:
1017 aciRet = sAT_PercentALS ((T_ACI_CMD_SRC)srcId, para);
1018 break;
1019 case AT_CMD_CREG:
1020 atiRet = setatPlusCREG ( &para1, srcId);
1021 break;
1022 case AT_CMD_P_CREG:
1023 atiRet = setatPercentCREG ( &para1, srcId);
1024 break;
1025 default:
1026 break;
1027 }
1028
1029 if (atiRet EQ ATI_FAIL AND aciRet EQ AT_FAIL )
1030 {
1031 TRACE_EVENT_P1("Set function fails for command id %d.", *string);
1032 cmdCmeError(CME_ERR_Unknown);
1033 return( ATI_FAIL );
1034 }
1035 return (ATI_CMPL);
1036 }
1037
1038 /*
1039 +--------------------------------------------------------------------+
1040 | PROJECT : GSM-PS (6147) MODULE : ATI_BAS |
1041 | STATE : code ROUTINE : ati_zn_retrieve_params |
1042 +--------------------------------------------------------------------+
1043
1044 PURPOSE : This is the implementation of AT command ATZn (n>0),
1045 which retrieve profile from FFS.
1046 */
1047 GLOBAL void ati_zn_retrieve_params ( UBYTE srcId )
1048 {
1049 int index = 1;
1050 UBYTE *profile_read = NULL;
1051 UBYTE *string = NULL;
1052 USHORT len_prof_read = 0;
1053
1054 TRACE_FUNCTION ("ati_zn_retrieve_params()");
1055 /*
1056 *-------------------------------------------------------------------
1057 * check parameter profile
1058 *-------------------------------------------------------------------
1059 */
1060 if( ATZprofile < 1 OR
1061 ATZprofile > MAX_ATW_STORED_PROFILE )
1062 {
1063 return;
1064 }
1065 len_prof_read = (MAX_ATW_CHOSEN_CMD_NB) * (MAX_ONE_ATW_PRO_LEN) + 1;
1066 TRACE_EVENT_P1 ("length of profile read is %d", len_prof_read);
1067 ACI_MALLOC (profile_read, len_prof_read);
1068
1069 if (read_profile_from_ffs ((SHORT)(ATZprofile - 1), profile_read, len_prof_read) NEQ ATI_CMPL)
1070 {
1071 TRACE_EVENT ("read_profile_from_ffs() fail...");
1072 ACI_MFREE (profile_read);
1073 return;
1074 }
1075 /*profile has no content*/
1076 if (*profile_read EQ 1)
1077 {
1078 ACI_MFREE (profile_read);
1079 return;
1080 }
1081 do
1082 {
1083 string = profile_read + index; /*index points to the first element of a command profile, which is command id*/
1084 index += *(profile_read+index +1);/*the second element in the profile is profile length for the command*/
1085 if (set_param_to_the_retrieved_value (srcId, string) EQ ATI_FAIL)
1086 {
1087 ACI_MFREE (profile_read);
1088 return;
1089 }
1090 }while (index < *profile_read);/*the first element of the whole profile is the total length*/
1091
1092 ACI_MFREE (profile_read);
1093 return;
1094 }
1095
1096 /*
1097 +--------------------------------------------------------------------+
1098 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1099 | STATE : code ROUTINE : atAndW |
1100 +--------------------------------------------------------------------+
1101
1102 PURPOSE : &W command stores profiles to FFS
1103 */
1104
1105 GLOBAL T_ATI_RSLT atAndW (char *cl, UBYTE srcId)
1106 {
1107 long nProfile = ACI_NumParmNotPresent;
1108 char *end;
1109
1110 TRACE_FUNCTION("atAndW()");
1111
1112 nProfile = strtol(cl, &end, 10);
1113 if(*end)
1114 {
1115 cmdAtError(atError);
1116 return ATI_FAIL;
1117 }
1118 /*
1119 * Normally omitted value should be assumed as zero
1120 * but AT&W does not support profile number zero.
1121 * So an omitted profile will be assumed as 1.
1122 */
1123 if(cl EQ end)
1124 {
1125 nProfile = 1;
1126 }
1127
1128 if( nProfile < 1 OR nProfile > MAX_ATW_STORED_PROFILE )
1129 {
1130 cmdAtError(atError);
1131 return ATI_FAIL;
1132 }
1133
1134 switch (ati_wn_store_params( srcId, (SHORT) (nProfile - 1)))
1135 {
1136 case ATI_CMPL:
1137 return ATI_CMPL;
1138 default:
1139 cmdAtError(atError);
1140 return ATI_FAIL;
1141 }
1142 }
1143
1144
1145 /*
1146 +--------------------------------------------------------------------+
1147 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1148 | STATE : code ROUTINE : atZ |
1149 +--------------------------------------------------------------------+
1150
1151 PURPOSE : Z command (reset DCE and terminate any call in progress)
1152 */
1153
1154 GLOBAL T_ATI_RSLT atZ(char *cl, UBYTE srcId)
1155 {
1156 char *end = NULL;
1157 UBYTE value = (UBYTE)strtol(cl, &end, 10);
1158 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
1159
1160 TRACE_FUNCTION("atZ()");
1161
1162 if(*end)
1163 {
1164 cmdAtError(atError);
1165 return ATI_FAIL;
1166 }
1167
1168 if( value > MAX_ATW_STORED_PROFILE )
1169 {
1170 cmdAtError(atError);
1171 return( ATI_FAIL );
1172 }
1173
1174 ATZprofile = value;
1175
1176 #ifdef FF_ATI_BAT
1177 {
1178 T_BAT_cmd_send cmd;
1179 T_BAT_no_parameter dummy;
1180 cmd.ctrl_params = BAT_CMD_AT_Z;
1181 dummy.bat_dummy = 0xFF;
1182 cmd.params.ptr_at_z = &dummy;
1183 if( at.rngPrms.isRng EQ TRUE )
1184 {
1185 ati_stop_ring();
1186 }
1187 src_params->curAtCmd = AT_CMD_Z;
1188
1189 bat_send(ati_bat_get_client(srcId), &cmd);
1190
1191 return (ATI_EXCT); /* executing, because response is passed by callback function */
1192 }
1193 #else /* no FF_ATI_BAT */
1194
1195 switch(sAT_Z( srcId, 0 ))
1196 {
1197 case AT_CMPL:
1198 return ATI_CMPL;
1199 case AT_EXCT:
1200 if( at.rngPrms.isRng EQ TRUE )
1201 {
1202 ati_stop_ring();
1203 }
1204 src_params->curAtCmd = AT_CMD_Z;
1205 return ATI_EXCT;
1206 default:
1207 cmdAtError(atError);
1208 return ATI_FAIL;
1209 }
1210
1211 #endif /* no FF_ATI_BAT */
1212 }
1213
1214 /*
1215 +--------------------------------------------------------------------+
1216 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1217 | STATE : code ROUTINE : atPlusCPAS |
1218 +--------------------------------------------------------------------+
1219
1220 PURPOSE : Phone activity status
1221 */
1222 GLOBAL T_ATI_RSLT setatPlusCPAS(char *cl, UBYTE srcId)
1223 {
1224 T_ACI_CPAS_PAS pas = CPAS_PAS_NotPresent;
1225 T_ACI_RETURN ret = AT_FAIL;
1226
1227 TRACE_FUNCTION("setatPlusCPAS()");
1228
1229 if (*cl NEQ '\0' AND *cl NEQ ';')
1230 {
1231 cmdAtError(atError);
1232 return ATI_FAIL;
1233 }
1234
1235 #ifdef FF_ATI_BAT
1236 {
1237 T_BAT_cmd_send cmd;
1238 T_BAT_no_parameter my_bat_set_plus_cpas;
1239
1240 TRACE_FUNCTION("setatPlusCPAS() calls bat_send() <=== as APPLICATION");
1241
1242 ret = qAT_PlusCPAS( srcId, &pas );
1243 if (ret EQ AT_CMPL)
1244 {
1245 resp_disp(srcId, cl, "e", &pas);
1246 }
1247 else
1248 {
1249 cmdAtError(atError);
1250 return ATI_FAIL;
1251 }
1252
1253 cmd.params.ptr_set_plus_cpas = &my_bat_set_plus_cpas;
1254 bat_send(ati_bat_get_client(srcId), &cmd);
1255 return ATI_EXCT; /* executing, because response is passed by callback function */
1256 }
1257 #else /* OLD FUNCTION BODY */
1258
1259 ret = qAT_PlusCPAS( srcId, &pas );
1260 if (ret EQ AT_CMPL)
1261 {
1262 resp_disp(srcId, cl, "e", &pas);
1263 return ATI_CMPL;
1264 }
1265 else
1266 {
1267 cmdAtError(atError);
1268 return ATI_FAIL;
1269 }
1270
1271 #endif /* no FF_ATI_BAT*/
1272 }
1273 /*
1274 +--------------------------------------------------------------------+
1275 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1276 | STATE : code ROUTINE : atPlusCLAE |
1277 +--------------------------------------------------------------------+
1278
1279 PURPOSE : +CLAE command (Language Event)
1280 */
1281
1282 GLOBAL T_ATI_RSLT setatPlusCLAE (char *cl, UBYTE srcId)
1283 {
1284 T_ACI_RETURN ret = AT_FAIL;
1285 T_ACI_CLAE_MOD mode = CLAE_MOD_NotPresent;
1286
1287 TRACE_FUNCTION("setatPLusCLAE()");
1288
1289 switch(*cl)
1290 {
1291 case('0'):
1292 mode=CLAE_MOD_Disable;
1293 break;
1294 case('1'):
1295 mode=CLAE_MOD_Enable;
1296 break;
1297 default:
1298 cmdCmeError(CME_ERR_OpNotAllow);
1299 return ATI_FAIL;
1300 }
1301 ret = sAT_PlusCLAE(srcId,mode);
1302 if (ret EQ AT_CMPL)
1303 return ATI_CMPL;
1304 else
1305 return ATI_FAIL;
1306 }
1307
1308 GLOBAL T_ATI_RSLT queatPlusCLAE (char *cl, UBYTE srcId)
1309 {
1310 char *me="+CLAE: ";
1311 T_ACI_RETURN ret = AT_FAIL;
1312 T_ACI_CLAE_MOD mode=CLAE_MOD_NotPresent;
1313
1314 TRACE_FUNCTION("queatPLusCLAE()");
1315
1316 ret = qAT_PlusCLAE(srcId,&mode);
1317 if(ret EQ AT_CMPL)
1318 {
1319 sprintf(g_sa,"%s%d",me,mode);
1320 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
1321 return ATI_CMPL;
1322 }
1323 else
1324 {
1325 cmdCmeError(CME_ERR_Unknown);
1326 return ATI_FAIL;
1327 }
1328 }
1329
1330 /*
1331 +--------------------------------------------------------------------+
1332 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1333 | STATE : code ROUTINE : atAndC |
1334 +--------------------------------------------------------------------+
1335
1336 PURPOSE : &C command reset to factory default (not the final version)
1337 */
1338
1339
1340 GLOBAL T_ATI_RSLT atAndC (char *cl, UBYTE srcId)
1341 {
1342 T_ACI_DCD_MOD val;
1343
1344 TRACE_FUNCTION("atAndC()");
1345
1346 switch(*cl)
1347 {
1348 case '\0':
1349 case '0':
1350 val = DCD_ALWAYS_ON;
1351 break;
1352
1353 case '1':
1354 val = DCD_DISABLE_AFTER_CALL;
1355 break;
1356 #ifdef RMV_01_06_04
1357 case ('?'):
1358 qAT_AndC( srcId, &val );
1359 sprintf(g_sa, "&C: %d", val);
1360 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
1361 return (ATI_CMPL);
1362 #endif
1363 default:
1364 cmdAtError(atError);
1365 return(ATI_FAIL);
1366 }
1367
1368 #ifdef DTI
1369 if (sAT_AndC( srcId, val ) EQ AT_CMPL)
1370 {
1371 return (ATI_CMPL);
1372 }
1373 #endif
1374 cmdAtError(atError);
1375 return (ATI_FAIL);
1376 }
1377
1378 /*
1379 +--------------------------------------------------------------------+
1380 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1381 | STATE : code ROUTINE : atAndD |
1382 +--------------------------------------------------------------------+
1383
1384 PURPOSE : &D command to set the DTR behaviour
1385 */
1386
1387
1388 GLOBAL T_ATI_RSLT atAndD (char *cl, UBYTE srcId)
1389 {
1390 UBYTE val;
1391
1392 TRACE_FUNCTION("atAndD()");
1393
1394 switch(*cl)
1395 {
1396 case ('\0'):
1397 case ('0'):
1398 val = 0;
1399 break;
1400 case ('1'):
1401 val = 1;
1402 break;
1403 case ('2'):
1404 val = 2;
1405 break;
1406 #ifdef RMV_01_06_04
1407 case ('?'):
1408 query = TRUE;
1409 break;
1410 #endif
1411 default:
1412 cmdAtError(atError);
1413 return ATI_FAIL;
1414 }
1415
1416 #ifdef RMV_01_06_04
1417 if (query)
1418 {
1419 ret=qAT_AndD (srcId, &val);
1420 if(ret EQ AT_CMPL)
1421 {
1422 sprintf(g_sa,"&D: %d", val);
1423 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
1424 return ATI_CMPL;
1425 }
1426 }
1427 else
1428 #endif
1429 {
1430 #ifdef DTI
1431 if (sAT_AndD ( srcId, val ) EQ AT_CMPL)
1432 {
1433 return ATI_CMPL;
1434 }
1435 #endif
1436 }
1437 cmdAtError(atError);
1438 return ATI_FAIL;
1439 }
1440
1441 /*
1442 +--------------------------------------------------------------------+
1443 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1444 | STATE : code ROUTINE : atAndF |
1445 +--------------------------------------------------------------------+
1446
1447 PURPOSE : &F command reset to factory default (not the final version)
1448 */
1449 GLOBAL T_ATI_RSLT atAndF (char *cl, UBYTE srcId)
1450 {
1451 T_ACI_RETURN ret = AT_FAIL;
1452
1453 TRACE_FUNCTION("atAndF()");
1454
1455 switch(*cl)
1456 {
1457 case '\0':
1458 case ('0'):
1459 /* default like ATZ */
1460 ati_cmd_reset(srcId);
1461 break;
1462 case ('1'):
1463 ati_cmd_reset(srcId);
1464
1465 /*
1466 * An other manufacturer specific parameter set.
1467 *
1468 * This is different from the user specific profiles (ATZ1).
1469 *
1470 */
1471 at.flags.COLP_stat = 1;
1472 ati_user_output_cfg[srcId].CR_stat = 1;
1473 ati_user_output_cfg[srcId].CRC_stat = 1;
1474 ati_user_output_cfg[srcId].CLIP_stat = 1;
1475 ati_user_output_cfg[srcId].DR_stat = 1;
1476
1477 ati_user_output_cfg[srcId].creg.mod_lac_cid.pres_mode = CREG_MOD_ON;
1478
1479 #ifdef GPRS
1480 ati_gprs_user_output_cfg[srcId].plus_cgreg.mod_lac_cid.pres_mode = CREG_MOD_ON;
1481 ati_gprs_user_output_cfg[srcId].percent_cgreg.mod_lac_cid.pres_mode = CREG_MOD_ON;
1482 #endif
1483 break;
1484 default:
1485 cmdAtError(atError);
1486 return ATI_FAIL;
1487 }
1488
1489 /*
1490 * The function sAT_AndF will be called with value 0 -> AT&F0
1491 * because the different behavior of value 0 to 1 is only ATI
1492 * related and sAT_AndF() is only CMH-related.
1493 *
1494 * This is different from sAT_Z().
1495 */
1496 ret = sAT_AndF( srcId, 0 );
1497 if (ret EQ AT_CMPL)
1498 {
1499 return ATI_CMPL;
1500 }
1501 cmdAtError(atError);
1502 return ATI_FAIL;
1503
1504 }
1505
1506 /*
1507 +--------------------------------------------------------------------+
1508 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1509 | STATE : code ROUTINE : atAndK |
1510 +--------------------------------------------------------------------+
1511
1512 PURPOSE : &K only for compatibility
1513 */
1514
1515
1516 GLOBAL T_ATI_RSLT atAndK (char *cl, UBYTE srcId)
1517 {
1518 TRACE_FUNCTION("atAndK()");
1519
1520 switch(*cl)
1521 {
1522 case ('0'):
1523 case ('1'):
1524 case ('2'):
1525 case ('3'):
1526 case ('4'):
1527 return ATI_CMPL;
1528 default:
1529 cmdAtError(atError);
1530 return ATI_FAIL;
1531 }
1532 }
1533
1534 /*
1535 +--------------------------------------------------------------------+
1536 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1537 | STATE : code ROUTINE : atPlusCSQ |
1538 +--------------------------------------------------------------------+
1539
1540 PURPOSE : +CSQ, signal quality
1541 */
1542
1543 GLOBAL T_ATI_RSLT setatPlusCSQ ( char *cl, UBYTE srcId)
1544 {
1545 rx_Status_Type rxStat;
1546 UBYTE rssi;
1547 UBYTE ber;
1548
1549 TRACE_FUNCTION("setatPlusCSQ()");
1550
1551 if ( rx_GetStatus ( &rxStat ) NEQ DRV_OK )
1552 {
1553 cmdCmeError ( CME_ERR_Unknown );
1554 return ATI_FAIL;
1555 }
1556 else
1557 {
1558 if ( rxStat.gsmLevel EQ 0xFF OR rxStat.gsmLevel EQ 0 )
1559 {
1560 rssi = ACI_RSSI_FAULT;
1561 }
1562 else if ( rxStat.gsmLevel > 59 )
1563 {
1564 rssi = 31;
1565 }
1566 else
1567 {
1568 rssi = ( rxStat.gsmLevel / 2 ) + 2;
1569 }
1570
1571 if ( rxStat.rxQuality EQ RX_QUAL_UNAVAILABLE )
1572 {
1573 ber = ACI_BER_FAULT;
1574 }
1575 else
1576 {
1577 ber = rxStat.rxQuality;
1578 }
1579
1580 sprintf (g_sa, "+CSQ: %d,%d ", rssi, ber );
1581 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
1582 return ATI_CMPL;
1583 }
1584 }
1585
1586 GLOBAL T_ATI_RSLT tesatPlusCSQ(CHAR *cl, UBYTE srcId)
1587 {
1588 TRACE_FUNCTION("tesatPLusCSQ()");
1589
1590 sprintf (g_sa, "+CSQ: 2-31,(%d),(%d)", ACI_RSSI_FAULT, ACI_BER_FAULT );
1591 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
1592 return ATI_CMPL;
1593 }
1594
1595 /*
1596 +--------------------------------------------------------------------+
1597 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1598 | STATE : code ROUTINE : atPlusCSQ |
1599 +--------------------------------------------------------------------+
1600
1601 PURPOSE : %CSQ, signal quality
1602
1603 Shen,Chao Juni.12th.2003
1604 */
1605
1606 GLOBAL T_ATI_RSLT setatPercentCSQ ( char *cl, UBYTE srcId)
1607 {
1608 T_ACI_CSQ_MODE CSQmode = CSQ_Disable;
1609 rx_Status_Type rxStat;
1610
1611
1612 TRACE_FUNCTION("setatPercentCSQ()");
1613
1614 if ( rx_GetStatus ( &rxStat ) NEQ DRV_OK )
1615 {
1616 cmdCmeError ( CME_ERR_Unknown );
1617 return ATI_FAIL;
1618 }
1619 else
1620 {
1621 switch( *cl )
1622 {
1623 case '0':
1624 {
1625 CSQmode = CSQ_Disable;
1626 break;
1627 }
1628
1629 case '1':
1630 {
1631 CSQmode = CSQ_Enable;
1632 break;
1633 }
1634
1635 default:
1636 {
1637 cmdCmeError(CME_ERR_Unknown);
1638 return (ATI_FAIL);
1639 }
1640 }
1641
1642 if (sAT_PercentCSQ(srcId,CSQmode) NEQ AT_CMPL)
1643 {
1644 TRACE_EVENT("setatPercentCSQ call sAT_PercentCSQ Error!!");
1645 }
1646
1647 sprintf (g_sa, "%s%d ", "%CSQ: ", CSQmode);
1648 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
1649 return ATI_CMPL;
1650 }
1651 }
1652
1653
1654 GLOBAL T_ATI_RSLT queatPercentCSQ(CHAR *cl, UBYTE srcId)
1655 {
1656 rx_Status_Type rxStat;
1657
1658 TRACE_FUNCTION("queatPercentCSQ()");
1659
1660 qAT_PercentCSQ(srcId,&rxStat.gsmLevel,&rxStat.rxQuality,&rxStat.actLevel);
1661
1662 sprintf (g_sa, "%s %d, %d, %d", "%CSQ: ",rxStat.gsmLevel, rxStat.rxQuality, rxStat.actLevel);
1663 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
1664
1665 return ATI_CMPL;
1666 }
1667
1668
1669 GLOBAL T_ATI_RSLT tesatPercentCSQ(CHAR *cl, UBYTE srcId)
1670 {
1671 TRACE_FUNCTION("tesatPercentCSQ()");
1672
1673 sprintf (g_sa, "%s (%d), (%d), 0-4", "%CSQ: ",ACI_RSSI_FAULT, ACI_BER_FAULT);
1674 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
1675 return ATI_CMPL;
1676 }
1677
1678 /*
1679 +--------------------------------------------------------------------+
1680 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1681 | STATE : code ROUTINE : atPercentDBGINFO |
1682 +--------------------------------------------------------------------+
1683
1684 PURPOSE : %DBGINFO, query free mem pool blocks.
1685 */
1686
1687 GLOBAL T_ATI_RSLT setatPercentDBGINFO ( char *cl, UBYTE srcId)
1688 {
1689 char *me = "%DBGINFO:";
1690 ULONG param = 0;
1691 T_ACI_DBG_INFO stor = P_DBGINFO_NotPresent;
1692 CHAR type[4] = {0};
1693 USHORT free = 0, alloc = 0, i = 0;
1694
1695 TRACE_FUNCTION("queatPercentDBGINFO()");
1696
1697 cl = parse(cl,"sd",(LONG)4, type, &param);
1698 if(!cl OR *type EQ '\0')
1699 {
1700 cmdCmeError(CME_ERR_OpNotAllow);
1701 return (ATI_FAIL);
1702 }
1703 strupper(type);
1704 for(i=0;dbg_mem_names[i].name NEQ 0;i++)
1705 {
1706 if (!strcmp(dbg_mem_names[i].name, type) )
1707 {
1708 stor = dbg_mem_names[i].stor;
1709 break;
1710 }
1711 }
1712 if((dbg_mem_names[i].name EQ 0) OR (param EQ 0))
1713 {
1714 cmdCmeError(CME_ERR_OpNotAllow);
1715 return (ATI_FAIL);
1716 }
1717 if (qAT_PercentDBGINFO(srcId, param, (USHORT)stor, &free, &alloc) NEQ ATI_CMPL)
1718 {
1719 cmdCmeError(CME_ERR_Unknown);
1720 return (ATI_FAIL);
1721 }
1722 sprintf(g_sa, "%s%d", me, free);
1723 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
1724
1725 return (ATI_CMPL);
1726 }
1727
1728 /*
1729 +--------------------------------------------------------------------+
1730 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1731 | STATE : code ROUTINE : atPlusCBC |
1732 +--------------------------------------------------------------------+
1733
1734 PURPOSE : +CBC, battery charge
1735 */
1736 #define ACI_BCS_BattPower 0
1737 #define ACI_BCS_BattCnctd 1
1738 #define ACI_BCS_NoBatt 2
1739 #define ACI_BCS_PowerFault 3
1740
1741 GLOBAL T_ATI_RSLT atPlusCBC ( char *cl, UBYTE srcId )
1742 {
1743 pwr_Status_Type powerStat;
1744 UBYTE bcs;
1745
1746 TRACE_FUNCTION("atPlusCBC()");
1747
1748 if ( pwr_GetStatus ( &powerStat ) NEQ DRV_OK )
1749 {
1750 cmdCmeError ( CME_ERR_Unknown );
1751 return ATI_FAIL;
1752 }
1753 else
1754 {
1755 switch ( powerStat.Status )
1756 {
1757 case ( PWR_EXTPOWER_ON ):
1758 bcs = ACI_BCS_NoBatt;
1759 break;
1760
1761 case ( PWR_CHARGER_ON ):
1762 bcs = ACI_BCS_BattCnctd;
1763 break;
1764
1765 default:
1766 bcs = ACI_BCS_BattPower;
1767 break;
1768 }
1769 sprintf(g_sa, "+CBC: %d,%d", bcs, powerStat.ChargeLevel );
1770 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
1771 return ATI_CMPL;
1772 }
1773 }
1774
1775 /*
1776 +--------------------------------------------------------------------+
1777 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1778 | STATE : code ROUTINE : atPlusCLVL |
1779 +--------------------------------------------------------------------+
1780
1781 PURPOSE : +CLVL, loudspeaker volume level
1782 */
1783 GLOBAL T_ATI_RSLT setatPlusCLVL ( char *cl, UBYTE srcId )
1784 {
1785 #ifdef FF_ATI_BAT
1786 {
1787 T_BAT_cmd_send cmd;
1788 T_BAT_cmd_set_plus_clvl my_bat_set_plus_clvl;
1789 SHORT vol;
1790
1791 TRACE_FUNCTION("setatPlusCLVL() calls bat_send() <=== as APPLICATION");
1792
1793 cl = parse ( cl, "d", &vol );
1794
1795 if( !cl OR vol > 255 OR vol < 0 )
1796 {
1797 cmdCmeError ( CME_ERR_OpNotAllow );
1798 return ATI_FAIL;
1799 }
1800
1801 memset(&my_bat_set_plus_clvl, 0, sizeof(my_bat_set_plus_clvl));
1802 cmd.ctrl_params = BAT_CMD_SET_PLUS_CLVL;
1803 cmd.params.ptr_set_plus_clvl = &my_bat_set_plus_clvl;
1804
1805 my_bat_set_plus_clvl.level = (U8)vol;
1806
1807 bat_send(ati_bat_get_client(srcId), &cmd);
1808
1809 return ATI_EXCT; /* executing, because response is passed by callback function */
1810 }
1811 #else /* OLD FUNCTION BODY */
1812
1813 TRACE_FUNCTION("setatPlusCLVL()");
1814
1815 return setaciPrcsVolLevel ( cl, AUDIO_SPEAKER );
1816
1817 #endif /* no FF_ATI_BAT*/
1818 }
1819
1820 GLOBAL T_ATI_RSLT tesatPlusCLVL ( char *cl, UBYTE srcId )
1821 {
1822 TRACE_FUNCTION("tesatPlusCLVL()");
1823
1824 return tesaciPrcsVolLevel ( srcId, cl, AUDIO_SPEAKER );
1825 }
1826
1827 GLOBAL T_ATI_RSLT queatPlusCLVL ( char *cl, UBYTE srcId )
1828 {
1829 TRACE_FUNCTION("queatPlusCLVL()");
1830
1831 return queaciPrcsVolLevel ( srcId, cl, AUDIO_SPEAKER );
1832 }
1833
1834 /*
1835 +--------------------------------------------------------------------+
1836 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1837 | STATE : code ROUTINE : atPlusCRSL |
1838 +--------------------------------------------------------------------+
1839
1840 PURPOSE : +CRSL, ringer sound level
1841 */
1842 GLOBAL T_ATI_RSLT setatPlusCRSL ( char *cl, UBYTE srcId )
1843 {
1844 TRACE_FUNCTION("atPlusCRSL()");
1845
1846 return setaciPrcsVolLevel ( cl, AUDIO_BUZZER );
1847 }
1848
1849 GLOBAL T_ATI_RSLT tesatPlusCRSL ( char *cl, UBYTE srcId )
1850 {
1851 TRACE_FUNCTION("tesatPlusCRSL()");
1852
1853 return tesaciPrcsVolLevel ( srcId, cl, AUDIO_BUZZER );
1854 }
1855
1856 GLOBAL T_ATI_RSLT queatPlusCRSL ( char *cl, UBYTE srcId )
1857 {
1858 TRACE_FUNCTION("queatPlusCRSL()");
1859
1860 return queaciPrcsVolLevel ( srcId, cl, AUDIO_BUZZER );
1861 }
1862
1863 /*
1864 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1865 | STATE : code ROUTINE : aciPrcsVolLevel |
1866
1867 PURPOSE : +CLVL, +CRSL loudspeaker volume level
1868 */
1869 LOCAL T_ATI_RSLT setaciPrcsVolLevel ( CHAR* cl, UBYTE device )
1870 {
1871 SHORT vol;
1872
1873 cl = parse ( cl, "d", &vol );
1874
1875 if( !cl OR vol > 255 OR vol < 0 )
1876 {
1877 cmdCmeError ( CME_ERR_OpNotAllow );
1878 return ATI_FAIL;
1879 }
1880 else
1881 {
1882 if ( audio_SetAmplf( device, ( UBYTE ) vol ) NEQ DRV_OK )
1883 {
1884 cmdCmeError ( CME_ERR_Unknown );
1885 return ATI_FAIL;
1886 }
1887 }
1888 return ATI_CMPL;
1889 }
1890
1891 LOCAL T_ATI_RSLT tesaciPrcsVolLevel ( UBYTE srcId, CHAR* cl, UBYTE device )
1892 {
1893 CHAR *p_sa;
1894 audio_Status_Type audioStat;
1895
1896 switch (device)
1897 {
1898 case AUDIO_SPEAKER:
1899 p_sa = "CLVL";
1900 break;
1901 case AUDIO_BUZZER:
1902 p_sa = "CRSL";
1903 break;
1904 default:
1905 cmdCmeError ( CME_ERR_Unknown );
1906 return ATI_FAIL;
1907 }
1908
1909 if ( audio_GetStatus ( device, &audioStat ) NEQ DRV_OK )
1910 {
1911 cmdCmeError ( CME_ERR_Unknown );
1912 return ATI_FAIL;
1913 }
1914 {
1915 sprintf( g_sa, "+%s: (%d-%d)", p_sa, audioStat.min_volume, audioStat.max_volume );
1916 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
1917 }
1918 return ATI_CMPL;
1919 }
1920
1921
1922 LOCAL T_ATI_RSLT queaciPrcsVolLevel ( UBYTE srcId, CHAR* cl, UBYTE device )
1923 {
1924 SHORT vol;
1925 UBYTE drvVol;
1926 CHAR *p_sa;
1927
1928 switch (device)
1929 {
1930 case AUDIO_SPEAKER:
1931 p_sa = "CLVL";
1932 break;
1933 case AUDIO_BUZZER:
1934 p_sa = "CRSL";
1935 break;
1936 default:
1937 cmdCmeError ( CME_ERR_Unknown );
1938 return ATI_FAIL;
1939 }
1940
1941 if ( audio_GetAmplf ( device, &drvVol ) NEQ DRV_OK )
1942 {
1943 cmdCmeError ( CME_ERR_Unknown );
1944 return ATI_FAIL;
1945 }
1946 else
1947 {
1948 vol = drvVol;
1949 sprintf ( g_sa, "+%s: %d", p_sa, vol );
1950 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
1951 }
1952 return ATI_CMPL;
1953 }
1954
1955 /*
1956 +--------------------------------------------------------------------+
1957 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1958 | STATE : code ROUTINE : atPlusCMUT |
1959 +--------------------------------------------------------------------+
1960
1961 PURPOSE : +CMUT, mute control
1962 */
1963 #define ACI_MUTE_OFF 0
1964 #define ACI_MUTE_ON 1
1965
1966 GLOBAL T_ATI_RSLT setatPlusCMUT(CHAR *cl, UBYTE srcId)
1967 {
1968 SHORT mute;
1969 UBYTE drvMute;
1970
1971 cl = parse ( cl, "d", &mute );
1972
1973 if( !cl OR ( mute NEQ ACI_MUTE_OFF AND mute NEQ ACI_MUTE_ON ) )
1974 {
1975 cmdCmeError ( CME_ERR_OpNotAllow );
1976 return ATI_FAIL;
1977 }
1978 if ( mute EQ ACI_MUTE_OFF )
1979 {
1980 drvMute = AUDIO_MUTING_OFF;
1981 }
1982 else
1983 {
1984 drvMute = AUDIO_MUTING_ON;
1985 }
1986 if (audio_SetMute (AUDIO_MICROPHONE, drvMute) NEQ DRV_OK)
1987 {
1988 cmdCmeError ( CME_ERR_Unknown );
1989 return ATI_FAIL;
1990 }
1991
1992 #ifdef FF_ATI_BAT
1993 {
1994 T_BAT_cmd_send cmd;
1995 T_BAT_cmd_set_plus_cmut my_bat_set_plus_cmut;
1996
1997 TRACE_FUNCTION("setatPlusCMUT() calls bat_send() <=== as APPLICATION");
1998
1999 memset(&my_bat_set_plus_cmut, 0, sizeof(my_bat_set_plus_cmut));
2000 cmd.ctrl_params = BAT_CMD_SET_PLUS_CMUT;
2001 cmd.params.ptr_set_plus_cmut = &my_bat_set_plus_cmut;
2002 my_bat_set_plus_cmut.n = (T_BAT_plus_cmut_n)drvMute;
2003 bat_send(ati_bat_get_client(srcId), &cmd);
2004 return ATI_EXCT; /* executing, because response is passed by callback function */
2005 }
2006 #else /* OLD FUNCTION BODY */
2007
2008 TRACE_FUNCTION("setatPLusCMUT()");
2009
2010 return ATI_CMPL;
2011
2012 #endif /* no FF_ATI_BAT */
2013 }
2014
2015 GLOBAL T_ATI_RSLT tesatPlusCMUT ( char *cl, UBYTE srcId )
2016 {
2017 TRACE_FUNCTION("tesatPlusCMUT()");
2018
2019 sprintf(g_sa, "+CMUT: (%d,%d)", ACI_MUTE_OFF, ACI_MUTE_ON );
2020 io_sendMessage (srcId, g_sa, ATI_NORMAL_OUTPUT);
2021 return ATI_CMPL;
2022 }
2023
2024 GLOBAL T_ATI_RSLT queatPlusCMUT(CHAR *cl, UBYTE srcId)
2025 {
2026 SHORT mute;
2027 UBYTE drvMute;
2028
2029 TRACE_FUNCTION("queatPlusCMUT()");
2030
2031 if ( audio_GetMute ( AUDIO_MICROPHONE, &drvMute ) NEQ DRV_OK )
2032 {
2033 cmdCmeError ( CME_ERR_Unknown );
2034 return ATI_FAIL;
2035 }
2036 else
2037 {
2038 if ( drvMute EQ AUDIO_MUTING_OFF )
2039 {
2040 mute = ACI_MUTE_OFF;
2041 }
2042 else
2043 {
2044 mute = ACI_MUTE_ON;
2045 }
2046
2047 sprintf ( g_sa, "+CMUT: %d", mute );
2048 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
2049 return ATI_CMPL;
2050 }
2051 }
2052
2053 /*
2054 +--------------------------------------------------------------------+
2055 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
2056 | STATE : code ROUTINE : atPlusCGMI |
2057 +--------------------------------------------------------------------+
2058
2059 PURPOSE : +CGMI, show name of manufacturer
2060 */
2061 GLOBAL T_ATI_RSLT atPlusCGMI ( char *cl, UBYTE srcId )
2062 {
2063 TRACE_FUNCTION("atPlusCGMI()");
2064
2065 return aciPrcsPlusCG (srcId, cl, EF_CGMI_ID);
2066 }
2067
2068 /*
2069 +--------------------------------------------------------------------+
2070 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
2071 | STATE : code ROUTINE : atPlusCGMM |
2072 +--------------------------------------------------------------------+
2073
2074 PURPOSE : +CGMM, show name of prodcut
2075 */
2076 GLOBAL T_ATI_RSLT atPlusCGMM ( char *cl, UBYTE srcId )
2077 {
2078 TRACE_FUNCTION("atPlusCGMM()");
2079
2080 return aciPrcsPlusCG (srcId, cl, EF_CGMM_ID);
2081 }
2082
2083 /*
2084 +--------------------------------------------------------------------+
2085 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
2086 | STATE : code ROUTINE : atPlusCGMR |
2087 +--------------------------------------------------------------------+
2088
2089 PURPOSE : +CGMR, show version of product
2090 */
2091 GLOBAL T_ATI_RSLT atPlusCGMR ( char *cl, UBYTE srcId )
2092 {
2093 TRACE_FUNCTION("atPlusCGMR()");
2094
2095 return aciPrcsPlusCG (srcId, cl, EF_CGMR_ID);
2096 }
2097
2098 /*
2099 +--------------------------------------------------------------------+
2100 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
2101 | STATE : code ROUTINE : atPlusCGSN |
2102 +--------------------------------------------------------------------+
2103
2104 PURPOSE : +CGSN, show serial number
2105 */
2106 GLOBAL T_ATI_RSLT atPlusCGSN ( char *cl, UBYTE srcId )
2107 {
2108 TRACE_FUNCTION("atPlusCGSN()");
2109
2110 return aciPrcsPlusCG (srcId, cl, EF_CGSN_ID);
2111 }
2112
2113 /*
2114 +--------------------------------------------------------------------+
2115 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
2116 | STATE : code ROUTINE : atPlusFMI |
2117 +--------------------------------------------------------------------+
2118
2119 PURPOSE : +FMI, show name of manufacturer
2120 */
2121 GLOBAL T_ATI_RSLT atPlusFMI ( char *cl, UBYTE srcId )
2122 {
2123 TRACE_FUNCTION("atPlusFMI()");
2124
2125 if ( *cl NEQ '?')
2126 {
2127 cmdCmeError ( CME_ERR_OpNotAllow );
2128 return ATI_FAIL;
2129 }
2130 return aciPrcsPlusCG (srcId, cl, EF_CGMI_ID);
2131 }
2132
2133 /*
2134 +--------------------------------------------------------------------+
2135 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
2136 | STATE : code ROUTINE : atPlusFMM |
2137 +--------------------------------------------------------------------+
2138
2139 PURPOSE : +FMM, show name of prodcut
2140 */
2141 GLOBAL T_ATI_RSLT atPlusFMM ( char *cl, UBYTE srcId )
2142 {
2143 TRACE_FUNCTION("atPlusFMM()");
2144
2145 if ( *cl NEQ '?')
2146 {
2147 cmdCmeError ( CME_ERR_OpNotAllow );
2148 return ATI_FAIL;
2149 }
2150 return aciPrcsPlusCG (srcId, cl, EF_CGMM_ID);
2151 }
2152
2153 /*
2154 +--------------------------------------------------------------------+
2155 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
2156 | STATE : code ROUTINE : atPlusFMR |
2157 +--------------------------------------------------------------------+
2158
2159 PURPOSE : +FMR, show version of product
2160 */
2161 GLOBAL T_ATI_RSLT atPlusFMR ( char *cl, UBYTE srcId )
2162 {
2163 TRACE_FUNCTION("atPlusFMR()");
2164
2165 if ( *cl NEQ '?')
2166 {
2167 cmdCmeError ( CME_ERR_OpNotAllow );
2168 return ATI_FAIL;
2169 }
2170 return aciPrcsPlusCG (srcId, cl, EF_CGMR_ID);
2171 }
2172
2173 /*
2174 +--------------------------------------------------------------------+
2175 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
2176 | STATE : code ROUTINE : aciPrcsPlusCG |
2177 +--------------------------------------------------------------------+
2178
2179 Conditioned-out below is TI's original version of the function
2180 responsible for generating responses to +CGMI, +CGMM, +CGMR and +CGSN
2181 commands. As you can see, it is very simple and straightforward.
2182 But see the comments afterward for why the FreeCalypso firmware has
2183 to use a not-very-clean hacked version instead.
2184 */
2185
2186 #if 0
2187 LOCAL T_ATI_RSLT aciPrcsPlusCG (UBYTE srcId, CHAR* cl, CHAR* ef)
2188 {
2189 pcm_FileInfo_Type fileInfo;
2190 USHORT i;
2191
2192 TRACE_FUNCTION("aciPrcsPlusCG()");
2193
2194 if (pcm_GetFileInfo ((UBYTE* )ef, &fileInfo) NEQ DRV_OK)
2195 {
2196 cmdCmeError (CME_ERR_MemFail);
2197 return ATI_FAIL;
2198 }
2199
2200
2201 if (pcm_ReadFile ((UBYTE*)ef, fileInfo.FileSize,
2202 (UBYTE*)g_sa, &fileInfo.Version) NEQ DRV_OK)
2203 {
2204 cmdCmeError (CME_ERR_MemFail);
2205 return ATI_FAIL;
2206 }
2207
2208 i = 0;
2209 while ((UBYTE)g_sa[i] NEQ 0xFF)
2210 {
2211 i++;
2212 }
2213 g_sa[i] = '\0';
2214 io_sendMessage (srcId, g_sa, ATI_NORMAL_OUTPUT );
2215
2216 return ATI_CMPL;
2217 }
2218 #endif
2219
2220 /*
2221 As you can see in the conditioned-out code above, TI's original
2222 implementation of +CGMI/+CGMM/+CGMR/+CGSN simply spits out whatever
2223 gets read out of PCM/FFS. But if one runs that original TI code
2224 on the Openmoko GSM modem, there are some undesirable effects:
2225
2226 * The strings stored in FFS in /pcm/CGM[IMR] (written there at the
2227 factory along with the IMEI and the RF calibration data, I presume)
2228 are just plain text, e.g., "FIC/OpenMoko" (w/o quotes) in /pcm/CGMI
2229 and "Neo1973 GTA02" (ditto) in /pcm/CGMM. The PCM code trustingly
2230 reads them out of FFS and into the in-RAM PCM table. But if you
2231 look at the PCM compiled-in defaults in
2232 ../../../../../chipsetsw/drivers/drv_app/ffs/board/pcmdata.c,
2233 it appears that at some point they were intended to be enclosed
2234 in angle brackets. The experiments I (Space Falcon) did suggest
2235 that the ATI layer is perfectly happy to emit these PlusCG responses
2236 either in the angle-bracketed form, or in the form used by Om's
2237 firmware, e.g., +CGMM: "Neo1973 whatever embedded modem".
2238 But if PCM contains an unencapsulated string like "Neo1973 GTA02"
2239 (read from FFS) and that string gets emitted raw, the ATI layer
2240 gets confused somewhere.
2241
2242 * TI's ATI layer is not the only code that needs to be kept happy.
2243 The code that talks AT commands to our modem (fsogsmd or whatever)
2244 probably expects the +CGMI/+CGMM/+CGMR/+CGSN responses to be
2245 formatted (encapsulated) in the form in which Om's firmware emits
2246 them, hence I reason we should do our best to reproduce that format.
2247 My version below implements +CGMI and +CGMM by reading the string
2248 value out of PCM (FFS in practice) and encapsulating it in the
2249 Om-like manner before handing it to the ATI layer for output.
2250
2251 * For +CGMR I return a compiled-in string identifying this FreeCalypso
2252 firmware. I see no point in reading anything out of FFS or PCM
2253 at all in this case, as the objective of the +CGMR query is to
2254 identify the firmware version in use, rather than factory FFS
2255 programming.
2256
2257 * With TI's vanilla code, the +CGSN query is logically independent of
2258 the IMEI seen by the GSM stack: it fetches the CGSN record (not the
2259 IMEI one) from PCM, and that record would have to be populated from
2260 a /pcm/CGSN file in FFS, if there was one - but Om's GTA0x modems
2261 have no such file in their FFS from the factory. If one runs TI's
2262 vanilla code, one would get this dummy output: <serial number>,
2263 coming from the compiled-in PCM default table. Om's firmware
2264 responds with "+CGSN: 123456789012345" (IMEI digits, no quotes)
2265 instead. My implementation below replicates Om's functionality.
2266
2267 So without further commentary, here is my hacked version of
2268 the aciPrcsPlusCG() function:
2269 */
2270
2271 LOCAL T_ATI_RSLT aciPrcsPlusCG (UBYTE srcId, CHAR* cl, CHAR* ef_req)
2272 {
2273 CHAR* ef_read;
2274 pcm_FileInfo_Type fileInfo;
2275 int c, i, j, is_imei;
2276 char buf[32];
2277
2278 TRACE_FUNCTION("aciPrcsPlusCG()");
2279
2280 if (!strcmp(ef_req, EF_CGMR_ID)) {
2281 sprintf(g_sa, "+%s: \"FreeCalypso leo2moko port\"", ef_req);
2282 io_sendMessage (srcId, g_sa, ATI_NORMAL_OUTPUT );
2283 return ATI_CMPL;
2284 } else if (!strcmp(ef_req, EF_CGSN_ID)) {
2285 ef_read = EF_IMEI_ID;
2286 is_imei = 1;
2287 } else {
2288 ef_read = ef_req;
2289 is_imei = 0;
2290 }
2291
2292 if (pcm_GetFileInfo ((UBYTE* )ef_read, &fileInfo) NEQ DRV_OK)
2293 {
2294 cmdCmeError (CME_ERR_MemFail);
2295 return ATI_FAIL;
2296 }
2297
2298 if (is_imei) {
2299
2300 for (i = 0, j = 0; i < fileInfo.FileSize; i++) {
2301 buf[j++] = (fileInfo.FileLocation[i] & 0x0F) + '0';
2302 buf[j++] = (fileInfo.FileLocation[i] >> 4) + '0';
2303 }
2304 buf[j-1] = '\0';
2305
2306 } else {
2307
2308 buf[0] = '\"';
2309 for (i = 0, j = 1; i < fileInfo.FileSize; i++) {
2310 c = fileInfo.FileLocation[i];
2311 if (c == 0 || c == 0xFF)
2312 break;
2313 buf[j++] = c;
2314 }
2315 buf[j++] = '\"';
2316 buf[j] = '\0';
2317
2318 }
2319
2320 sprintf(g_sa, "+%s: %s", ef_req, buf);
2321 io_sendMessage (srcId, g_sa, ATI_NORMAL_OUTPUT );
2322
2323 return ATI_CMPL;
2324 }
2325
2326 /*
2327 +--------------------------------------------------------------------+
2328 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
2329 | STATE : code ROUTINE : atPlusCSCS |
2330 +--------------------------------------------------------------------+
2331
2332 PURPOSE : +CSCS command (Select TE character set)
2333 */
2334 GLOBAL T_ATI_RSLT setatPlusCSCS (char *cl, UBYTE srcId)
2335 {
2336 CHAR txtChset[10];
2337 T_ACI_CSCS_CHSET chset = CSCS_CHSET_NotPresent;
2338
2339 TRACE_FUNCTION("setatPlusCSCS()");
2340
2341 cl = parse ( cl, "s", (LONG) sizeof (txtChset), txtChset);
2342
2343 if ( strcmp ( txtChset, "GSM" ) EQ 0 )
2344 chset = CSCS_CHSET_Gsm;
2345 else if ( strcmp ( txtChset, "IRA" ) EQ 0 )
2346 chset = CSCS_CHSET_Ira;
2347 else if ( strcmp ( txtChset, "PCCP437" ) EQ 0 )
2348 chset = CSCS_CHSET_Pccp_437;
2349 else if ( strcmp ( txtChset, "PCDN" ) EQ 0 )
2350 chset = CSCS_CHSET_Pcdn;
2351 else if ( strcmp ( txtChset, "8859-1" ) EQ 0 )
2352 chset = CSCS_CHSET_8859_1;
2353 else if ( strcmp ( txtChset, "HEX" ) EQ 0 )
2354 chset = CSCS_CHSET_Hex;
2355 else if ( strcmp ( txtChset, "UCS2" ) EQ 0 )
2356 chset = CSCS_CHSET_Ucs2;
2357
2358 if ( !cl OR chset EQ CSCS_CHSET_NotPresent )
2359 {
2360 cmdCmeError ( CME_ERR_OpNotAllow );
2361 return ATI_FAIL;
2362 }
2363
2364 #ifdef FF_ATI_BAT
2365
2366 {
2367 T_BAT_cmd_send cmd;
2368 T_BAT_cmd_set_plus_cscs cscs;
2369
2370 cmd.ctrl_params=BAT_CMD_SET_PLUS_CSCS;
2371 cmd.params.ptr_set_plus_cscs=&cscs;
2372 /*
2373 * This relies on T_BAT_plus_cscs being identical to
2374 * T_ACI_CSCS_CHSET. It is, apart from the NotPresent
2375 * value, which is taken care of earlier in this
2376 * function.
2377 */
2378 cscs.cs=(T_BAT_plus_cscs_cs)chset;
2379 bat_send(ati_bat_get_client(srcId), &cmd);
2380 return(ATI_EXCT);
2381 }
2382
2383 #else
2384
2385 ati_user_output_cfg[srcId].cscsChset = chset;
2386 return ATI_CMPL;
2387
2388 #endif
2389 }
2390
2391 GLOBAL T_ATI_RSLT queatPlusCSCS (char *cl, UBYTE srcId)
2392 {
2393 TRACE_FUNCTION("queatPlusCSCS()");
2394
2395 #ifdef FF_ATI_BAT
2396 {
2397 T_BAT_cmd_send cmd;
2398 T_BAT_no_parameter dummy;
2399
2400 cmd.ctrl_params=BAT_CMD_QUE_PLUS_CSCS;
2401 dummy.bat_dummy = 0xFF;
2402 cmd.params.ptr_que_plus_cscs = &dummy;
2403 bat_send(ati_bat_get_client(srcId), &cmd);
2404 }
2405 return(ATI_EXCT);
2406
2407 #else /* no FF_ATI_BAT */
2408
2409 strcpy ( g_sa, "+CSCS: ");
2410
2411 switch ( ati_user_output_cfg[srcId].cscsChset )
2412 {
2413 case (CSCS_CHSET_Ira ): strcat (g_sa,"\"IRA\"" ); break;
2414 case (CSCS_CHSET_Pcdn ): strcat (g_sa,"\"PCDN\"" ); break;
2415 case (CSCS_CHSET_8859_1 ): strcat (g_sa,"\"8859-1\"" ); break;
2416 case (CSCS_CHSET_Pccp_437): strcat (g_sa,"\"PCCP437\""); break;
2417 case (CSCS_CHSET_Gsm ): strcat (g_sa,"\"GSM\"" ); break;
2418 case (CSCS_CHSET_Hex ): strcat (g_sa,"\"HEX\"" ); break;
2419 case (CSCS_CHSET_Ucs2 ): strcat (g_sa,"\"UCS2\"" ); break;
2420
2421 /*
2422 *-----------------------------------------------------------
2423 * This case will be prevented during settings procedure of
2424 * the TE character set ( CSCS=... )
2425 *-----------------------------------------------------------
2426 */
2427 default: cmdCmeError ( CME_ERR_Unknown ); return ATI_FAIL;
2428 }
2429
2430 io_sendMessage ( srcId, g_sa, ATI_NORMAL_OUTPUT );
2431 return ATI_CMPL;
2432
2433 #endif /* no FF_ATI_BAT */
2434 }
2435
2436 /*
2437 +--------------------------------------------------------------------+
2438 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
2439 | STATE : code ROUTINE : atPlusCMEE |
2440 +--------------------------------------------------------------------+
2441
2442 PURPOSE : +CMEE command (Error display mode)
2443 */
2444
2445 GLOBAL T_ATI_RSLT setatPlusCMEE(CHAR *cl, UBYTE srcId)
2446 {
2447 SHORT val;
2448
2449 TRACE_FUNCTION("setatPLusCMEE()");
2450
2451 cl=parse(cl,"r",&val);
2452 if ( !cl OR val > CMEE_MOD_Verbose OR val < CMEE_MOD_Disable )
2453 {
2454 cmdAtError(atError);
2455 return ATI_FAIL;
2456 }
2457 else
2458 {
2459 TRACE_EVENT_P2("setatPlusCMEE: srcId = %d Value = %d", srcId, val);
2460 ati_user_output_cfg[srcId].CMEE_stat = (UBYTE)val;
2461 return ATI_CMPL;
2462 }
2463 }
2464
2465
2466 /* query function */
2467
2468 GLOBAL T_ATI_RSLT queatPlusCMEE(CHAR *cl, UBYTE srcId)
2469 {
2470 TRACE_FUNCTION("queatPLusCMEE()");
2471
2472 TRACE_EVENT_P1("queatPlusCMEE: srcId = %d", srcId);
2473 resp_disp(srcId, cl,"b",&ati_user_output_cfg[srcId].CMEE_stat);
2474 return ATI_CMPL;
2475 }
2476
2477 /*
2478 +--------------------------------------------------------------------+
2479 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
2480 | STATE : code ROUTINE : atPlusGCAP |
2481 +--------------------------------------------------------------------+
2482
2483 PURPOSE : +GCAP command (capability information)
2484 */
2485 GLOBAL T_ATI_RSLT atPlusGCAP(char *cl, UBYTE srcId)
2486 {
2487 if (*cl EQ '\0')
2488 {
2489 #ifdef FAX_AND_DATA
2490
2491 #ifdef FF_FAX
2492
2493 #ifdef V42BIS
2494 sprintf(g_sa,"+GCAP: +CGSM,+FCLASS,+DS");
2495 #else
2496 sprintf(g_sa,"+GCAP: +CGSM,+FCLASS");
2497 #endif
2498
2499 #else /* no FAX */
2500
2501 #ifdef V42BIS
2502 sprintf(g_sa,"+GCAP: +CGSM,+DS");
2503 #else
2504 sprintf(g_sa,"+GCAP: +CGSM");
2505 #endif
2506
2507 #endif /* FF_FAX */
2508
2509 #else /* Voice only */
2510
2511 sprintf(g_sa,"+GCAP: +CGSM");
2512
2513 #endif /* FAX_AND_DATA */
2514
2515 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
2516 return ATI_CMPL;
2517 }
2518 else
2519 {
2520 cmdAtError(atError);
2521 return ATI_FAIL;
2522 }
2523 }
2524
2525 /*
2526 +--------------------------------------------------------------------+
2527 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
2528 | STATE : code ROUTINE : atPercentCCBS |
2529 +--------------------------------------------------------------------+
2530
2531 PURPOSE : %CCBS command (Call Completion to Busy Subscriber)
2532 */
2533
2534 GLOBAL T_ATI_RSLT setatPercentCCBS(char *cl, UBYTE srcId)
2535 {
2536 SHORT mode = ACI_NumParmNotPresent;
2537 SHORT idx = ACI_NumParmNotPresent;
2538 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
2539 T_ACI_RETURN ret = AT_FAIL;
2540
2541 TRACE_FUNCTION("setatPercentCCBS()");
2542
2543 cl = parse (cl,"rr",&mode,&idx);
2544 if(!cl OR (mode NEQ ACI_NumParmNotPresent AND (mode > 1 OR mode < 0)))
2545 {
2546 cmdCmeError (CME_ERR_OpNotAllow);
2547 return ATI_FAIL;
2548 }
2549
2550 if( mode NEQ ACI_NumParmNotPresent )
2551 at.flags.CCBS_stat=(UBYTE)mode;
2552
2553 #ifdef FF_ATI_BAT
2554
2555 if (idx != ACI_NumParmNotPresent)
2556 {
2557 T_BAT_cmd_send cmd;
2558 T_BAT_cmd_set_percent_ccbs ccbs;
2559
2560 cmd.ctrl_params=BAT_CMD_SET_PERCENT_CCBS;
2561 cmd.params.ptr_set_percent_ccbs=&ccbs;
2562 ccbs.idx=(T_BAT_percent_ccbs_idx)idx;
2563 bat_send(ati_bat_get_client(srcId), &cmd);
2564 return(ATI_EXCT);
2565 }
2566 else
2567 {
2568 return(ATI_CMPL);
2569 }
2570
2571 #else /* no FF_ATI_BAT */
2572
2573 if( idx NEQ ACI_NumParmNotPresent )
2574 {
2575 ret = sAT_PercentCCBS(srcId, idx);
2576 if( ret NEQ AT_EXCT )
2577 {
2578 cmdCmeError(CME_ERR_Unknown);
2579 return ATI_FAIL;
2580 }
2581 src_params->curAtCmd = AT_CMD_CCBS;
2582 }
2583 else
2584 {
2585 ret = AT_CMPL;
2586 }
2587 return (map_aci_2_ati_rslt(ret));
2588
2589 #endif /* no FF_ATI_BAT */
2590 }
2591
2592 GLOBAL T_ATI_RSLT queatPercentCCBS(char *cl, UBYTE srcId)
2593 {
2594 T_ACI_RETURN ret = AT_FAIL;
2595 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
2596
2597 TRACE_FUNCTION("queatPercentCCBS()");
2598
2599 ret = qAT_PercentCCBS(srcId);
2600
2601 if( ret NEQ AT_EXCT )
2602 {
2603 cmdCmeError(CME_ERR_Unknown);
2604 return ATI_FAIL;
2605 }
2606 src_params->curAtCmd = AT_CMD_CCBS;
2607 return (map_aci_2_ati_rslt(ret));
2608 }
2609
2610
2611 /*
2612 +--------------------------------------------------------------------+
2613 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
2614 | STATE : code ROUTINE : atPlusCMUX |
2615 +--------------------------------------------------------------------+
2616
2617 PURPOSE : +CMUX command (multiplexer)
2618 */
2619 GLOBAL T_ATI_RSLT setatPlusCMUX (char *cl, UBYTE srcId)
2620 {
2621 T_ACI_RETURN ret = AT_FAIL;
2622 SHORT mode = ACI_NumParmNotPresent;
2623 SHORT subset = 0; /* default value */
2624 UBYTE port_speed = NOT_PRESENT_8BIT;
2625 int N1 = 64;
2626 /* default value in advanced mode (other modes not supported */
2627 SHORT T1 = 10; /* (100 ms) */
2628 SHORT N2 = 3;
2629 SHORT T2 = 30; /* (30 ms) */
2630 SHORT T3 = 10; /* (10 s) */
2631 SHORT k = 2;
2632
2633 TRACE_FUNCTION("setatPlusCMUX()");
2634
2635 cl = parse (cl,"rrrdrrrrr",&mode,&subset,&port_speed,&N1,&T1,&N2,&T2,&T3,&k);
2636 if (!cl)
2637 {
2638 cmdCmeError(CME_ERR_OpNotAllow);
2639 return ATI_FAIL;
2640 }
2641
2642 #ifdef DTI
2643 /* values not supported */
2644 if ( mode NEQ 1
2645 OR subset NEQ 0
2646 OR ((port_speed NEQ NOT_PRESENT_8BIT)
2647 AND (convert_mux_port_speed(port_speed) EQ BD_RATE_NotPresent))
2648 OR N1 < 1 OR N1 > 32768
2649 OR T1 < 1 OR T1 > 255
2650 OR N2 < 0 OR N2 > 100
2651 OR T2 < 2 OR T2 > 255
2652 OR T3 < 1 OR T3 > 255
2653 OR k < 1 OR k > 7 )
2654 {
2655 TRACE_EVENT("at least one value is beyond capabilities");
2656 cmdCmeError(CME_ERR_OpNotAllow);
2657 return ATI_FAIL;
2658 }
2659
2660 #ifdef FF_ATI_BAT
2661
2662 {
2663 T_BAT_cmd_send cmd;
2664 T_BAT_cmd_set_plus_cmux cmux;
2665
2666 cmd.ctrl_params=BAT_CMD_SET_PLUS_CMUX;
2667 cmd.params.ptr_set_plus_cmux=&cmux;
2668
2669 cmux.mode=(T_BAT_plus_cmux_mode)mode;
2670 cmux.subset=(T_BAT_plus_cmux_subset)subset;
2671 cmux.port_speed=(T_BAT_plus_cmux_port_speed)port_speed;
2672 cmux.n1=(U16)N1;
2673 cmux.t1=(U8)T1;
2674 cmux.n2=(U8)N2;
2675 cmux.t2=(U8)T2;
2676 cmux.t3=(U8)T3;
2677 cmux.k=(S16)k;
2678
2679 bat_send(ati_bat_get_client(srcId), &cmd);
2680 return(ATI_EXCT);
2681 }
2682
2683 #else /* no FF_ATI_BAT */
2684
2685 ret = sAT_PlusCMUX(srcId,
2686 (UBYTE)mode,
2687 (UBYTE)subset,
2688 port_speed,
2689 (USHORT)N1,
2690 (UBYTE)T1,
2691 (UBYTE)N2,
2692 (UBYTE)T2,
2693 (UBYTE)T3);
2694
2695 #endif /* no FF_ATI_BAT */
2696
2697 #endif /* DTI */
2698
2699 if( ret EQ AT_FAIL )
2700 {
2701 cmdCmeError(CME_ERR_Unknown);
2702 return ATI_FAIL;
2703 }
2704 return ATI_CMPL_NO_OUTPUT;
2705 }
2706
2707 GLOBAL T_ATI_RSLT tesatPlusCMUX (char *cl, UBYTE srcId)
2708 {
2709 TRACE_FUNCTION("tesatPlusCMUX()");
2710
2711 sprintf(g_sa,"+CMUX: %s","(1),(0),(1-5),(10-100),(1-255),(0-100),(2-255),(1-255),(1-7)");
2712 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
2713
2714 io_sendConfirm(srcId, cmdAtError(atOk), ATI_NORMAL_OUTPUT);
2715
2716 cmdErrStr = NULL;
2717
2718 return ATI_CMPL_NO_OUTPUT;
2719 }
2720
2721 GLOBAL T_ATI_RSLT queatPlusCMUX (char *cl, UBYTE srcId)
2722 {
2723 T_ACI_RETURN ret = AT_FAIL;
2724 UBYTE mode;
2725 UBYTE subset;
2726 UBYTE port_speed;
2727 USHORT N1;
2728 UBYTE T1;
2729 UBYTE N2;
2730 UBYTE T2;
2731 UBYTE T3;
2732 SHORT k = 2;
2733
2734 TRACE_FUNCTION("queatPlusCMUX()");
2735
2736 #ifdef FF_ATI_BAT
2737 {
2738 T_BAT_cmd_send cmd;
2739 T_BAT_no_parameter dummy;
2740
2741 cmd.ctrl_params = BAT_CMD_QUE_PLUS_CMUX;
2742 dummy.bat_dummy = 0xFF;
2743 cmd.params.ptr_que_plus_cmux = &dummy;
2744 bat_send(ati_bat_get_client(srcId), &cmd);
2745 return(ATI_EXCT);
2746 }
2747 #else /* no FF_ATI_BAT */
2748
2749 #ifdef DTI
2750 ret = qAT_PlusCMUX(srcId,
2751 &mode,
2752 &subset,
2753 &port_speed,
2754 &N1,
2755 &T1,
2756 &N2,
2757 &T2,
2758 &T3);
2759 if (ret EQ AT_CMPL)
2760 {
2761 sprintf(g_sa,"+CMUX: %d,%d,%d,%d,%d,%d,%d,%d,%d", mode, subset, port_speed, N1, T1, N2, T2, T3, k);
2762 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
2763 return ATI_CMPL;
2764 }
2765 else if (ret EQ AT_FAIL)
2766 {
2767 cmdCmeError(CME_ERR_Unknown);
2768 }
2769 #endif /* DTI */
2770 return ATI_FAIL;
2771
2772 #endif /* no FF_ATI_BAT */
2773 }
2774
2775 /*
2776 +--------------------------------------------------------------------+
2777 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
2778 | STATE : code ROUTINE : atPlusIPR |
2779 +--------------------------------------------------------------------+
2780
2781 PURPOSE : +IPR command (DTE speed setting)
2782 */
2783
2784 GLOBAL T_ATI_RSLT setatPlusIPR(char *cl, UBYTE srcId)
2785 {
2786 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
2787 T_ACI_BD_RATE speed;
2788 char *end;
2789
2790 src_params->curAtCmd = AT_CMD_IPR;
2791
2792 switch ( strtol(cl, &end, 10) )
2793 {
2794 case 0: speed = BD_RATE_AUTO; break;
2795 case 75: speed = BD_RATE_75; break;
2796 case 150: speed = BD_RATE_150; break;
2797 case 300: speed = BD_RATE_300; break;
2798 case 600: speed = BD_RATE_600; break;
2799 case 1200: speed = BD_RATE_1200; break;
2800 case 2400: speed = BD_RATE_2400; break;
2801 case 4800: speed = BD_RATE_4800; break;
2802 case 7200: speed = BD_RATE_7200; break;
2803 case 9600: speed = BD_RATE_9600; break;
2804 case 14400: speed = BD_RATE_14400; break;
2805 case 19200: speed = BD_RATE_19200; break;
2806 case 28800: speed = BD_RATE_28800; break;
2807 case 33900: speed = BD_RATE_33900; break;
2808 case 38400: speed = BD_RATE_38400; break;
2809 case 57600: speed = BD_RATE_57600; break;
2810 case 115200: speed = BD_RATE_115200; break;
2811 case 203125: speed = BD_RATE_203125; break;
2812 case 406250: speed = BD_RATE_406250; break;
2813 case 812500: speed = BD_RATE_812500; break;
2814 default:
2815 cmdCmeError(CME_ERR_OpNotSupp);
2816 return ATI_FAIL;
2817 }
2818
2819 #ifdef FF_ATI_BAT
2820 {
2821 T_BAT_cmd_send cmd;
2822 T_BAT_cmd_set_plus_ipr my_bat_set_plus_ipr;
2823
2824 TRACE_FUNCTION("setatPlusIPR() calls bat_send() <=== as APPLICATION");
2825
2826 memset(&my_bat_set_plus_ipr, 0, sizeof(my_bat_set_plus_ipr));
2827 cmd.ctrl_params = BAT_CMD_SET_PLUS_IPR;
2828 cmd.params.ptr_set_plus_ipr = &my_bat_set_plus_ipr;
2829
2830 my_bat_set_plus_ipr.rate = (T_BAT_plus_ipr_rate)speed;
2831
2832 bat_send(ati_bat_get_client(srcId), &cmd);
2833
2834 return ATI_EXCT; /* executing, because response is passed by callback function */
2835 }
2836 #else /* OLD FUNCTION BODY */
2837
2838 TRACE_FUNCTION("setatPlusIPR()");
2839
2840 #ifdef UART
2841
2842 if(!end)
2843 {
2844 cmdCmeError(CME_ERR_OpNotSupp);
2845 return ATI_FAIL;
2846 }
2847
2848 switch ( sAT_PlusIPR(srcId, speed) )
2849 {
2850 case (AT_CMPL): /* operation completed */
2851 return ATI_CMPL_NO_OUTPUT; /* OK was already sent at old baudrate by sAT_PlusIPR,
2852 so must not be sent twice! */
2853 default:
2854 cmdCmeError(CME_ERR_NotPresent);
2855 return ATI_FAIL;
2856 }
2857 #else
2858 cmdCmeError(CME_ERR_NotPresent);
2859 return ATI_FAIL;
2860
2861 #endif /* UART */
2862
2863 #endif /* no FF_ATI_BAT*/
2864 }
2865
2866 GLOBAL T_ATI_RSLT queatPlusIPR(char *cl, UBYTE srcId)
2867 {
2868 T_ACI_BD_RATE rate;
2869 int rate_value;
2870
2871 TRACE_FUNCTION("queatPlusIPR()");
2872 #ifdef DTI
2873 if ( AT_CMPL EQ qAT_PlusIPR(srcId, &rate) )
2874 {
2875 switch ( rate )
2876 {
2877 case BD_RATE_AUTO: rate_value = 0; break;
2878 case BD_RATE_75: rate_value = 75; break;
2879 case BD_RATE_150: rate_value = 150; break;
2880 case BD_RATE_300: rate_value = 300; break;
2881 case BD_RATE_600: rate_value = 600; break;
2882 case BD_RATE_1200: rate_value = 1200; break;
2883 case BD_RATE_2400: rate_value = 2400; break;
2884 case BD_RATE_4800: rate_value = 4800; break;
2885 case BD_RATE_7200: rate_value = 7200; break;
2886 case BD_RATE_9600: rate_value = 9600; break;
2887 case BD_RATE_14400: rate_value = 14400; break;
2888 case BD_RATE_19200: rate_value = 19200; break;
2889 case BD_RATE_28800: rate_value = 28800; break;
2890 case BD_RATE_33900: rate_value = 33900; break;
2891 case BD_RATE_38400: rate_value = 38400; break;
2892 case BD_RATE_57600: rate_value = 57600; break;
2893 case BD_RATE_115200: rate_value = 115200; break;
2894 case BD_RATE_203125: rate_value = 203125; break;
2895 case BD_RATE_406250: rate_value = 406250; break;
2896 case BD_RATE_812500: rate_value = 812500; break;
2897 default: rate_value = 0; break;
2898 }
2899
2900 sprintf(g_sa,"+IPR: %d", rate_value);
2901 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
2902 return ATI_CMPL;
2903 }
2904 #endif
2905 cmdAtError(atError);
2906 return 0;
2907 }
2908 /*
2909 +--------------------------------------------------------------------+
2910 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
2911 | STATE : code ROUTINE : atPlusICF |
2912 +--------------------------------------------------------------------+
2913
2914 PURPOSE : +ICF command (DTE character frame setting)
2915 */
2916
2917 GLOBAL T_ATI_RSLT setatPlusICF(char *cl, UBYTE srcId)
2918 {
2919 T_ACI_BS_FRM format = BS_FRM_NotPresent;
2920 T_ACI_BS_PAR parity = BS_PAR_NotPresent;
2921 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
2922
2923 TRACE_FUNCTION("setatPlusICF()");
2924
2925 cl=parse(cl,"dd",&format,&parity);
2926
2927 if(!cl)
2928 {
2929 cmdAtError(atError);
2930 return ATI_FAIL;
2931 }
2932 #ifdef DTI
2933
2934 #ifdef FF_ATI_BAT
2935
2936 {
2937 T_BAT_cmd_send cmd;
2938 T_BAT_cmd_set_plus_icf icf;
2939
2940 cmd.ctrl_params=BAT_CMD_SET_PLUS_ICF;
2941 cmd.params.ptr_set_plus_icf=&icf;
2942
2943 /*
2944 * This relies on T_ACI_BS_FRM being identical to
2945 * T_BAT_framing_format and T_ACI_BS_PAR being identical
2946 * to T_BAT_framing_parity.
2947 */
2948 icf.framing_format=(T_BAT_framing_format)format;
2949 icf.framing_parity=(T_BAT_framing_parity)parity;
2950
2951 bat_send(ati_bat_get_client(srcId), &cmd);
2952 }
2953
2954 src_params->curAtCmd=AT_CMD_ICF;
2955
2956 return(ATI_EXCT);
2957
2958 #else /* no FF_ATI_BAT */
2959
2960 switch ( sAT_PlusICF(srcId, format, parity) )
2961 {
2962 case (AT_CMPL): /*operation completed*/
2963 return ATI_CMPL;
2964 case (AT_EXCT):
2965 src_params->curAtCmd = AT_CMD_ICF;
2966 return ATI_EXCT;
2967 default:
2968 cmdAtError(atError); /*Command failed*/
2969 return ATI_FAIL;
2970 }
2971
2972 #endif /* no FF_ATI_BAT */
2973
2974 #else
2975 cmdAtError(atError); /*Command failed*/
2976 return ATI_FAIL;
2977 #endif
2978 }
2979
2980 GLOBAL T_ATI_RSLT queatPlusICF(char *cl, UBYTE srcId)
2981 {
2982 #ifndef FF_ATI_BAT
2983 T_ACI_BS_FRM format;
2984 T_ACI_BS_PAR parity;
2985 #endif
2986
2987 TRACE_FUNCTION("queatPlusICF()");
2988
2989 #ifdef DTI
2990
2991 #ifdef FF_ATI_BAT
2992 {
2993 T_BAT_cmd_send cmd;
2994 T_BAT_no_parameter dummy;
2995
2996 cmd.ctrl_params = BAT_CMD_QUE_PLUS_ICF;
2997 dummy.bat_dummy = 0xFF;
2998 cmd.params.ptr_que_plus_icf = &dummy;
2999 bat_send(ati_bat_get_client(srcId), &cmd);
3000 return(ATI_EXCT);
3001 }
3002 #else /* no FF_ATI_BAT */
3003
3004 switch ( qAT_PlusICF(srcId,&format,&parity) )
3005 {
3006 case AT_CMPL:
3007 if (format EQ BS_FRM_Dat8_Par1_St1 || format EQ BS_FRM_Dat7_Par1_St1 )
3008 {
3009 resp_disp(srcId, cl,"ee",&format,&parity);
3010 }
3011 else
3012 {
3013 resp_disp(srcId, cl,"e",&format);
3014 }
3015 return ATI_CMPL;
3016 }
3017
3018 #endif /* no FF_ATI_BAT */
3019
3020 #endif /* DTI */
3021 cmdAtError(atError);
3022 return ATI_FAIL;
3023 }
3024
3025 GLOBAL T_ATI_RSLT setflowCntr(CHAR* cl, UBYTE srcId)
3026 {
3027 T_ACI_RX_FLOW_CTRL DCE_by_DTE = RX_FLOW_NotPresent; /* by TE: Rx flow control */
3028 T_ACI_RX_FLOW_CTRL DTE_by_DCE = TX_FLOW_NotPresent; /* by TA: Tx flow control */
3029
3030 cl = parse (cl,"dd",&DCE_by_DTE,&DTE_by_DCE);
3031
3032 if(!cl)
3033 {
3034 cmdAtError(atError);
3035 return ATI_FAIL;
3036 }
3037
3038 #ifdef DTI
3039 switch ( sAT_PlusIFC(srcId, DCE_by_DTE, DTE_by_DCE) )
3040 {
3041 case (AT_CMPL): /*operation completed*/
3042 return ATI_CMPL;
3043 case (AT_EXCT):
3044 /* ATTENTION: no setting of 'curAtCmd' allowed because the value is set before */
3045 return ATI_EXCT;
3046 default:
3047 cmdAtError(atError); /*Command failed*/
3048 return ATI_FAIL;
3049 }
3050 #else
3051 cmdAtError(atError); /*Command failed*/
3052 return ATI_FAIL;
3053 #endif
3054 }
3055
3056 /*
3057 +--------------------------------------------------------------------+
3058 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
3059 | STATE : code ROUTINE : atPlusIFC |
3060 +--------------------------------------------------------------------+
3061
3062 PURPOSE : +IFC command (DTE DCE / DCE DTE flow control)
3063 */
3064
3065 GLOBAL T_ATI_RSLT setatPlusIFC(char *cl, UBYTE srcId)
3066 {
3067 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
3068 TRACE_FUNCTION("setatPlusIFC()");
3069
3070 src_params->curAtCmd = AT_CMD_IFC;
3071 return setflowCntr(cl, srcId);
3072 }
3073
3074
3075 GLOBAL T_ATI_RSLT queflowCntr(CHAR* cl, UBYTE srcId)
3076 {
3077 T_ACI_RX_FLOW_CTRL DCE_by_DTE;
3078 T_ACI_RX_FLOW_CTRL DTE_by_DCE;
3079 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
3080
3081 #ifdef DTI
3082 if ( AT_CMPL EQ qAT_PlusIFC(srcId,&DCE_by_DTE,&DTE_by_DCE) )
3083 {
3084 #ifdef FF_FAX
3085 if (src_params->curAtCmd EQ AT_CMD_FLO)
3086 {
3087 sprintf(g_sa,"+FLO: %d",DCE_by_DTE);
3088 }
3089 else
3090 #endif
3091 if (src_params->curAtCmd EQ AT_CMD_IFC)
3092 {
3093 sprintf(g_sa,"+IFC: %d,%d",DCE_by_DTE,DTE_by_DCE);
3094 }
3095
3096 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
3097 return ATI_CMPL;
3098 }
3099 else
3100 {
3101 cmdAtError(atError);
3102 return ATI_FAIL;
3103 }
3104 #else
3105 cmdAtError(atError);
3106 return ATI_FAIL;
3107 #endif
3108 }
3109
3110 /*
3111 +--------------------------------------------------------------------+
3112 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
3113 | STATE : code ROUTINE : atPlusIFC |
3114 +--------------------------------------------------------------------+
3115
3116 PURPOSE : +IFC command (DTE DCE / DCE DTE flow control)
3117 */
3118
3119 GLOBAL T_ATI_RSLT queatPlusIFC(char *cl, UBYTE srcId)
3120 {
3121 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
3122 TRACE_FUNCTION("queatPlusIFC()");
3123
3124 src_params->curAtCmd = AT_CMD_IFC;
3125 return queflowCntr(cl, srcId);
3126 }
3127
3128 /*
3129 +--------------------------------------------------------------------+
3130 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
3131 | STATE : code ROUTINE : atPlusILRR |
3132 +--------------------------------------------------------------------+
3133
3134 PURPOSE : +ILRR command (display +ILRR setting)
3135 */
3136
3137 GLOBAL T_ATI_RSLT setatPlusILRR(char *cl, UBYTE srcId)
3138 {
3139 SHORT val=-1;
3140
3141 TRACE_FUNCTION("setatPLusILRR()");
3142
3143 cl = parse (cl,"r",&val);
3144 if(!cl OR val > 1 OR val < 0)
3145 {
3146 cmdAtError(atError);
3147 return ATI_FAIL;
3148 }
3149 ati_user_output_cfg[srcId].ILRR_stat=(UBYTE)val;
3150 return ATI_CMPL;
3151 }
3152
3153 GLOBAL T_ATI_RSLT queatPlusILRR(char *cl, UBYTE srcId)
3154 {
3155 TRACE_FUNCTION("queatPLusILRR()");
3156
3157 resp_disp(srcId, cl,"b",&ati_user_output_cfg[srcId].ILRR_stat);
3158 return ATI_CMPL;
3159 }
3160
3161 /*
3162 +--------------------------------------------------------------------+
3163 | PROJECT : MODULE : ACI_CMD |
3164 | STATE : code ROUTINE : setatPlusCCLK |
3165 +--------------------------------------------------------------------+
3166
3167 PURPOSE : +CCLK command (Set the real time clock of the MT)
3168 */
3169 GLOBAL T_ATI_RSLT setatPlusCCLK (char *cl, UBYTE srcId)
3170 {
3171 T_ACI_RETURN ret = AT_FAIL;
3172 T_ACI_RTC_DATE date_s;
3173 T_ACI_RTC_TIME time_s;
3174 char date_time_string[DATE_TIME_LENGTH+1]={0};
3175
3176 int days, months, items_conv;
3177 int hrs, mins, secs;
3178 int years;
3179 int timeZone = 0;
3180 char sign = '+';
3181
3182 TRACE_FUNCTION("setatPlusCCLK()");
3183
3184 cl=parse(cl,"s", DATE_TIME_LENGTH, date_time_string);
3185
3186 if(!cl )
3187 {
3188 cmdCmeError(CME_ERR_OpNotAllow);
3189 return (ATI_FAIL);
3190 }
3191
3192 TRACE_EVENT_P1("Date and time are: %s",date_time_string);
3193
3194 items_conv = sscanf( date_time_string, "%d/%d/%d,%d:%d:%d%c%d",&years,&months,&days,&hrs,&mins,&secs,&sign,&timeZone );
3195
3196 if (sign == '-')
3197 {
3198 timeZone = timeZone * (-1);
3199 }
3200
3201 TRACE_EVENT_P1("items_conv %d",items_conv);
3202 TRACE_EVENT_P1("days %d",days);
3203 TRACE_EVENT_P1("months %d",months);
3204 TRACE_EVENT_P1("years %d",years);
3205 TRACE_EVENT_P1("hours %d",hrs);
3206 TRACE_EVENT_P1("mins %d",mins);
3207 TRACE_EVENT_P1("secs %d",secs);
3208 TRACE_EVENT_P1("sign %c",sign);
3209 TRACE_EVENT_P1("timeZone %d",timeZone);
3210
3211
3212 /* If 8 data items not extracted from date_time_string then date_time_string data with TZ info is incorrect. */
3213 if ( items_conv != 8 )
3214 {
3215 cmdCmeError(CME_ERR_OpNotAllow);
3216 return (ATI_FAIL);
3217 }
3218
3219 #ifndef _SIMULATION_
3220 /* Ensure 'years' passed in from the AT command is not in 4 digit format
3221 The spec requires the years to be passed in in 2 digit format
3222 Also ensure the sign char is either a '+' or '-' */
3223 if ( (years < 0) || (years > 99 ) ||
3224 ((sign != '-') && (sign != '+')) ||
3225 (timeZone < (-48)) || (timeZone > 48)
3226 )
3227 {
3228 cmdCmeError(CME_ERR_OpNotAllow);
3229 return (ATI_FAIL);
3230 }
3231 #else /* _SIMULATION_ */
3232 /* On the target code these checks are done in the RTC code. In the simulation code-
3233 the RTC routines are not used so these checks have to be done. */
3234 if ( (years < 0) || (years > 99)
3235 || (months < 1) || (months > 12)
3236 || (days < 1) || (days > 31)
3237 || (hrs < 0) || (hrs > 23)
3238 || (mins < 0) || (mins > 59)
3239 || (secs < 0) || (secs > 59)
3240 || (timeZone < (-48)) || (timeZone > 48)
3241 )
3242 {
3243 cmdCmeError(CME_ERR_OpNotAllow);
3244 return (ATI_FAIL);
3245 }
3246 #endif /* _SIMULATION_ */
3247
3248
3249 /* Populate date time structs */
3250 date_s.day = days;
3251 date_s.month = months;
3252 date_s.year = years + 2000; /* Convert years to 4 digit format for passing to lower layer RTC function */
3253 time_s.hour = hrs;
3254 time_s.minute = mins;
3255 time_s.PM_flag = 0;
3256 time_s.second = secs;
3257 time_s.format = TIME_FORMAT_24HOUR;
3258
3259 /* Pass separated date and time and timezone info to set the clock */
3260
3261 #ifdef FF_ATI_BAT
3262
3263 {
3264 T_BAT_cmd_send cmd;
3265 T_BAT_cmd_set_plus_cclk cclk;
3266
3267 cmd.ctrl_params=BAT_CMD_SET_PLUS_CCLK;
3268 cmd.params.ptr_set_plus_cclk=&cclk;
3269
3270 cclk.year=(U8)date_s.year;
3271 cclk.month=(U8)date_s.month;
3272 cclk.day=(U8)date_s.day;
3273
3274 cclk.hour=(U8)time_s.hour;
3275
3276 cclk.minutes=(U8)time_s.minute;
3277 cclk.seconds=(U8)time_s.second;
3278
3279 cclk.time_zone=(S8)timeZone;
3280
3281 bat_send(ati_bat_get_client(srcId), &cmd);
3282 }
3283
3284 return(ATI_EXCT);
3285
3286 #else /* no FF_ATI_BAT */
3287
3288 ret = sAT_PlusCCLK ( srcId, &date_s, &time_s, timeZone);
3289
3290 TRACE_EVENT_P1("sAT_PlusCCLK ret = %d", ret);
3291
3292 /* Deal with return value */
3293
3294 switch (ret)
3295 {
3296 case (AT_CMPL): /*operation completed*/
3297 break;
3298
3299 default:
3300 cmdCmeError(CME_ERR_Unknown); /*Command failed*/
3301 break;
3302 }
3303 return (map_aci_2_ati_rslt(ret));
3304
3305 #endif /* no FF_ATI_BAT */
3306 }
3307
3308 /*
3309 +--------------------------------------------------------------------+
3310 | PROJECT : MODULE : ACI_CMD |
3311 | STATE : code ROUTINE : queatPlusCCLK |
3312 +--------------------------------------------------------------------+
3313
3314 PURPOSE : +CCLK query command (Read the real time clock of the MT)
3315 */
3316 GLOBAL T_ATI_RSLT queatPlusCCLK (char *cl, UBYTE srcId)
3317 {
3318 #ifndef FF_ATI_BAT
3319 T_ACI_RETURN ret = AT_FAIL;
3320 T_ACI_RTC_DATE date_s; /* Structures to obtain date time info */
3321 T_ACI_RTC_TIME time_s;
3322 char date_time_string[DATE_TIME_LENGTH+1]={0};
3323 UBYTE days, months;
3324 UBYTE hrs, mins, secs, count;
3325 USHORT years;
3326 char sign ;
3327 int tz ;
3328 char *me="+CCLK: ";
3329 #endif
3330
3331 TRACE_FUNCTION("queatPlusCCLK()");
3332
3333 #ifdef FF_ATI_BAT
3334 {
3335 T_BAT_cmd_send cmd;
3336 T_BAT_no_parameter dummy;
3337
3338 cmd.ctrl_params=BAT_CMD_QUE_PLUS_CCLK;
3339 dummy.bat_dummy = 0xFF;
3340 cmd.params.ptr_que_plus_cclk = &dummy;
3341 bat_send(ati_bat_get_client(srcId), &cmd);
3342 return(ATI_EXCT);
3343 }
3344 #else /* no FF_ATI_BAT */
3345
3346 ret = qAT_PlusCCLK( srcId, &date_s, &time_s, &tz);
3347
3348 if (ret EQ AT_CMPL)
3349 {
3350 /* Command completed successfully */
3351 /* convert time date struct data into string */
3352 days = date_s.day;
3353 months = date_s.month;
3354 years = date_s.year;
3355 hrs = time_s.hour;
3356 mins = time_s.minute;
3357 secs = time_s.second;
3358
3359 #ifndef _SIMULATION_
3360 #ifdef FF_TIMEZONE
3361 if ( tz < 0)
3362 {
3363 sign = '-';
3364 tz = tz * (-1);
3365 }
3366 else
3367 sign = '+';
3368 #endif /* FF_TIMEZONE */
3369 #else /* _SIMULATION_ */
3370 sign = '-';
3371 tz = tz * (-1);
3372 #endif /* _SIMULATION_ */
3373
3374 /* Convert years to 2 digit format for reporting back to user */
3375 years = years - 2000; /* Subtract 2000 years from number returned */
3376
3377 TRACE_EVENT_P3("Date -> %d - %d - %d",days,months,years);
3378 TRACE_EVENT_P3("Time -> %d - %d - %d",hrs,mins,secs);
3379 /* Not using time_s.format or time_s.PM_flag */
3380
3381 /* CONVERT DATE TIME INFO INTO STRING FOR OUTPUTTING BACK TO DISPLAY */
3382
3383 #ifndef _SIMULATION_
3384
3385 #ifndef FF_TIMEZONE
3386 count = sprintf(date_time_string, "%s\"%d/%d/%d,%d:%d:%d\"", me, years, months, days, hrs, mins, secs);
3387 #else /* FF_TIMEZONE */
3388 TRACE_EVENT_P2("TimeZone -> %c%d", sign, tz);
3389 count = sprintf(date_time_string, "%s\"%d/%d/%d,%d:%d:%d%c%d\"", me, years, months, days, hrs, mins, secs, sign, tz);
3390 #endif /* FF_TIMEZONE */
3391
3392 #else /* _SIMULATION_ */
3393 TRACE_EVENT_P2("TimeZone -> %c%d", sign, tz);
3394 count = sprintf(date_time_string, "%s\"%d/%d/%d,%d:%d:%d%c%d\"", me, years, months, days, hrs, mins, secs, sign, tz);
3395 #endif /* _SIMULATION_ */
3396
3397 /* REPORT DATE TIME INFO STRING */
3398 io_sendMessage(srcId, date_time_string, ATI_NORMAL_OUTPUT);
3399
3400 return ATI_CMPL;
3401 }
3402 else
3403 {
3404 cmdCmeError(CME_ERR_Unknown);
3405 return ATI_FAIL;
3406 }
3407
3408 #endif /* no FF_ATI_BAT */
3409
3410 }
3411 #endif /* ATI_BAS_C */
3412