FreeCalypso > hg > fc-magnetite
comparison src/g23m-aci/aci/ati_bas.c @ 162:53929b40109c
src/g23m-aci: initial import from TCS3.2/LoCosto
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 11 Oct 2016 02:02:43 +0000 |
parents | |
children | 557041e392a9 |
comparison
equal
deleted
inserted
replaced
161:4557e2a9c18e | 162:53929b40109c |
---|---|
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, P_DBGINFO_NotPresent } | |
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((T_ACI_CMD_SRC)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 ( (T_ACI_CMD_SRC)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, ¶1, ¶2); | |
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, ¶3); | |
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 #else | |
927 int i; | |
928 #endif | |
929 /*the last letter x depends on the profile to read*/ | |
930 char ffsAddr[] = "/gsm/com/profilex"; | |
931 | |
932 TRACE_FUNCTION ("read_profile_from_ffs()"); | |
933 /*build the correct address in FFS according to nProfile*/ | |
934 ffsAddr[ strlen (ffsAddr) - 1] = '0' + nProfile; | |
935 TRACE_EVENT_P1 ("Read address is: %s", ffsAddr); | |
936 | |
937 #ifndef _SIMULATION_ | |
938 if ((val = ffs_fread (ffsAddr, profile_read, len_profile_read ))< 1) | |
939 { | |
940 TRACE_EVENT_P1("Read profile from FFS fail, returned val is %d", val); | |
941 cmdCmeError(CME_ERR_Unknown); | |
942 return (ATI_FAIL); | |
943 } | |
944 #endif /*_SIMULATION_*/ | |
945 | |
946 #ifdef _SIMULATION_ | |
947 for (i = 0; i < atw_profile_simu[nProfile][0] ; i ++) | |
948 { | |
949 profile_read [i] = atw_profile_simu [nProfile][i]; | |
950 TRACE_EVENT_P2 ("index %d, profile_read is: %d ", i, profile_read [i]); | |
951 } | |
952 #endif /*_SIMULATION_*/ | |
953 return (ATI_CMPL); | |
954 } | |
955 | |
956 /* | |
957 +------------------------------------------------------------------------------+ | |
958 | PROJECT : GSM-PS (6147) MODULE : ATI_BAS | | |
959 | STATE : code ROUTINE : set_param_to_the_retrieved_value | | |
960 +------------------------------------------------------------------------------+ | |
961 | |
962 PURPOSE : this function handles command parameters. | |
963 */ | |
964 LOCAL T_ATI_RSLT set_param_to_the_retrieved_value(UBYTE srcId, UBYTE *string) | |
965 { | |
966 int para = * (string+4); /*this is for functions with input param of type int*/ | |
967 CHAR para1 = * (string+4); /*this is for functions with input param of type char*/ | |
968 T_ATI_RSLT atiRet = ATI_FAIL; | |
969 T_ACI_RETURN aciRet = AT_FAIL; | |
970 | |
971 TRACE_FUNCTION ("set_param_to_the_retrieved_value()"); | |
972 | |
973 /* string[2] is always the token and string[3] always the length. | |
974 so far we only have parameters with 1 byte length.*/ | |
975 if ( *(string+2) EQ SIGNED_VALUE AND *(string+3) EQ sizeof (UBYTE)) | |
976 { | |
977 para = ((* (string+4) > 127) ? *(string+4) -256: *(string+4)); | |
978 } | |
979 para1 = (CHAR)(para + '0'); /*Transform to the corresponding inern value of the corresponding character*/ | |
980 switch (*string) | |
981 { | |
982 case AT_CMD_CGREG: | |
983 #if defined (GPRS) AND defined (DTI) | |
984 atiRet = setatPlusCGREG ( ¶1, srcId); | |
985 #else | |
986 atiRet = ATI_CMPL; | |
987 #endif /*GPRS*/ | |
988 break; | |
989 case AT_CMD_P_CGREG: | |
990 #if defined (GPRS) AND defined (DTI) | |
991 atiRet = setatPercentCGREG (¶1, srcId); | |
992 #else | |
993 atiRet = ATI_CMPL; | |
994 #endif /*GPRS*/ | |
995 break; | |
996 case AT_CMD_CGAATT: | |
997 #if defined (GPRS) AND defined (DTI) | |
998 aciRet = sAT_PercentCGAATT ((T_ACI_CMD_SRC)srcId, (T_CGAATT_ATTACH_MODE)para, | |
999 (T_CGAATT_DETACH_MODE)((*(string+7) > 127) ? (*(string+7) - 256 ): *(string+7))); | |
1000 #else | |
1001 aciRet = AT_CMPL; | |
1002 #endif /*GPRS*/ | |
1003 break; | |
1004 | |
1005 case AT_CMD_CLIP: | |
1006 atiRet = setatPlusCLIP ( ¶1, srcId ); | |
1007 break; | |
1008 case AT_CMD_CPI: | |
1009 ati_user_output_cfg[srcId].CPI_stat = string[4]; | |
1010 atiRet = ATI_CMPL; | |
1011 break; | |
1012 case AT_CMD_COLP: | |
1013 atiRet = setatPlusCOLP (¶1, srcId); | |
1014 break; | |
1015 case AT_CMD_CLIR: | |
1016 aciRet = sAT_PlusCLIR ( (T_ACI_CMD_SRC)srcId,(T_ACI_CLIR_MOD)para); | |
1017 break; | |
1018 case AT_CMD_ALS: | |
1019 aciRet = sAT_PercentALS ((T_ACI_CMD_SRC)srcId,(T_ACI_ALS_MOD)para); | |
1020 break; | |
1021 case AT_CMD_CREG: | |
1022 atiRet = setatPlusCREG ( ¶1, srcId); | |
1023 break; | |
1024 case AT_CMD_P_CREG: | |
1025 atiRet = setatPercentCREG ( ¶1, srcId); | |
1026 break; | |
1027 default: | |
1028 break; | |
1029 } | |
1030 | |
1031 if (atiRet EQ ATI_FAIL AND aciRet EQ AT_FAIL ) | |
1032 { | |
1033 TRACE_EVENT_P1("Set function fails for command id %d.", *string); | |
1034 cmdCmeError(CME_ERR_Unknown); | |
1035 return( ATI_FAIL ); | |
1036 } | |
1037 return (ATI_CMPL); | |
1038 } | |
1039 | |
1040 /* | |
1041 +--------------------------------------------------------------------+ | |
1042 | PROJECT : GSM-PS (6147) MODULE : ATI_BAS | | |
1043 | STATE : code ROUTINE : ati_zn_retrieve_params | | |
1044 +--------------------------------------------------------------------+ | |
1045 | |
1046 PURPOSE : This is the implementation of AT command ATZn (n>0), | |
1047 which retrieve profile from FFS. | |
1048 */ | |
1049 GLOBAL void ati_zn_retrieve_params ( UBYTE srcId ) | |
1050 { | |
1051 int index = 1; | |
1052 UBYTE *profile_read = NULL; | |
1053 UBYTE *string = NULL; | |
1054 USHORT len_prof_read = 0; | |
1055 | |
1056 TRACE_FUNCTION ("ati_zn_retrieve_params()"); | |
1057 /* | |
1058 *------------------------------------------------------------------- | |
1059 * check parameter profile | |
1060 *------------------------------------------------------------------- | |
1061 */ | |
1062 if( ATZprofile < 1 OR | |
1063 ATZprofile > MAX_ATW_STORED_PROFILE ) | |
1064 { | |
1065 return; | |
1066 } | |
1067 len_prof_read = (MAX_ATW_CHOSEN_CMD_NB) * (MAX_ONE_ATW_PRO_LEN) + 1; | |
1068 TRACE_EVENT_P1 ("length of profile read is %d", len_prof_read); | |
1069 ACI_MALLOC (profile_read, len_prof_read); | |
1070 | |
1071 if (read_profile_from_ffs ((SHORT)(ATZprofile - 1), profile_read, len_prof_read) NEQ ATI_CMPL) | |
1072 { | |
1073 TRACE_EVENT ("read_profile_from_ffs() fail..."); | |
1074 ACI_MFREE (profile_read); | |
1075 return; | |
1076 } | |
1077 /*profile has no content*/ | |
1078 if (*profile_read EQ 1) | |
1079 { | |
1080 ACI_MFREE (profile_read); | |
1081 return; | |
1082 } | |
1083 do | |
1084 { | |
1085 string = profile_read + index; /*index points to the first element of a command profile, which is command id*/ | |
1086 index += *(profile_read+index +1);/*the second element in the profile is profile length for the command*/ | |
1087 if (set_param_to_the_retrieved_value (srcId, string) EQ ATI_FAIL) | |
1088 { | |
1089 ACI_MFREE (profile_read); | |
1090 return; | |
1091 } | |
1092 }while (index < *profile_read);/*the first element of the whole profile is the total length*/ | |
1093 | |
1094 ACI_MFREE (profile_read); | |
1095 return; | |
1096 } | |
1097 | |
1098 /* | |
1099 +--------------------------------------------------------------------+ | |
1100 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD | | |
1101 | STATE : code ROUTINE : atAndW | | |
1102 +--------------------------------------------------------------------+ | |
1103 | |
1104 PURPOSE : &W command stores profiles to FFS | |
1105 */ | |
1106 | |
1107 GLOBAL T_ATI_RSLT atAndW (char *cl, UBYTE srcId) | |
1108 { | |
1109 long nProfile = ACI_NumParmNotPresent; | |
1110 char *end; | |
1111 | |
1112 TRACE_FUNCTION("atAndW()"); | |
1113 | |
1114 nProfile = strtol(cl, &end, 10); | |
1115 if(*end) | |
1116 { | |
1117 cmdAtError(atError); | |
1118 return ATI_FAIL; | |
1119 } | |
1120 /* | |
1121 * Normally omitted value should be assumed as zero | |
1122 * but AT&W does not support profile number zero. | |
1123 * So an omitted profile will be assumed as 1. | |
1124 */ | |
1125 if(cl EQ end) | |
1126 { | |
1127 nProfile = 1; | |
1128 } | |
1129 | |
1130 if( nProfile < 1 OR nProfile > MAX_ATW_STORED_PROFILE ) | |
1131 { | |
1132 cmdAtError(atError); | |
1133 return ATI_FAIL; | |
1134 } | |
1135 | |
1136 switch (ati_wn_store_params( srcId, (SHORT) (nProfile - 1))) | |
1137 { | |
1138 case ATI_CMPL: | |
1139 return ATI_CMPL; | |
1140 default: | |
1141 cmdAtError(atError); | |
1142 return ATI_FAIL; | |
1143 } | |
1144 } | |
1145 | |
1146 | |
1147 /* | |
1148 +--------------------------------------------------------------------+ | |
1149 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD | | |
1150 | STATE : code ROUTINE : atZ | | |
1151 +--------------------------------------------------------------------+ | |
1152 | |
1153 PURPOSE : Z command (reset DCE and terminate any call in progress) | |
1154 */ | |
1155 | |
1156 GLOBAL T_ATI_RSLT atZ(char *cl, UBYTE srcId) | |
1157 { | |
1158 char *end = NULL; | |
1159 UBYTE value = (UBYTE)strtol(cl, &end, 10); | |
1160 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id); | |
1161 | |
1162 TRACE_FUNCTION("atZ()"); | |
1163 | |
1164 if(*end) | |
1165 { | |
1166 cmdAtError(atError); | |
1167 return ATI_FAIL; | |
1168 } | |
1169 | |
1170 if( value > MAX_ATW_STORED_PROFILE ) | |
1171 { | |
1172 cmdAtError(atError); | |
1173 return( ATI_FAIL ); | |
1174 } | |
1175 | |
1176 ATZprofile = value; | |
1177 | |
1178 #ifdef FF_ATI_BAT | |
1179 { | |
1180 T_BAT_cmd_send cmd; | |
1181 T_BAT_no_parameter dummy; | |
1182 cmd.ctrl_params = BAT_CMD_AT_Z; | |
1183 dummy.bat_dummy = 0xFF; | |
1184 cmd.params.ptr_at_z = &dummy; | |
1185 if( at.rngPrms.isRng EQ TRUE ) | |
1186 { | |
1187 ati_stop_ring(); | |
1188 } | |
1189 src_params->curAtCmd = AT_CMD_Z; | |
1190 | |
1191 bat_send(ati_bat_get_client(srcId), &cmd); | |
1192 | |
1193 return (ATI_EXCT); /* executing, because response is passed by callback function */ | |
1194 } | |
1195 #else /* no FF_ATI_BAT */ | |
1196 | |
1197 switch(sAT_Z( (T_ACI_CMD_SRC)srcId, 0 )) | |
1198 { | |
1199 case AT_CMPL: | |
1200 return ATI_CMPL; | |
1201 case AT_EXCT: | |
1202 if( at.rngPrms.isRng EQ TRUE ) | |
1203 { | |
1204 ati_stop_ring(); | |
1205 } | |
1206 src_params->curAtCmd = AT_CMD_Z; | |
1207 return ATI_EXCT; | |
1208 default: | |
1209 cmdAtError(atError); | |
1210 return ATI_FAIL; | |
1211 } | |
1212 | |
1213 #endif /* no FF_ATI_BAT */ | |
1214 } | |
1215 | |
1216 /* | |
1217 +--------------------------------------------------------------------+ | |
1218 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD | | |
1219 | STATE : code ROUTINE : atPlusCPAS | | |
1220 +--------------------------------------------------------------------+ | |
1221 | |
1222 PURPOSE : Phone activity status | |
1223 */ | |
1224 GLOBAL T_ATI_RSLT setatPlusCPAS(char *cl, UBYTE srcId) | |
1225 { | |
1226 T_ACI_CPAS_PAS pas = CPAS_PAS_NotPresent; | |
1227 T_ACI_RETURN ret = AT_FAIL; | |
1228 | |
1229 TRACE_FUNCTION("setatPlusCPAS()"); | |
1230 | |
1231 if (*cl NEQ '\0' AND *cl NEQ ';') | |
1232 { | |
1233 cmdAtError(atError); | |
1234 return ATI_FAIL; | |
1235 } | |
1236 | |
1237 #ifdef FF_ATI_BAT | |
1238 { | |
1239 T_BAT_cmd_send cmd; | |
1240 T_BAT_no_parameter my_bat_set_plus_cpas; | |
1241 | |
1242 TRACE_FUNCTION("setatPlusCPAS() calls bat_send() <=== as APPLICATION"); | |
1243 | |
1244 ret = qAT_PlusCPAS( srcId, &pas ); | |
1245 if (ret EQ AT_CMPL) | |
1246 { | |
1247 resp_disp(srcId, cl, "e", &pas); | |
1248 } | |
1249 else | |
1250 { | |
1251 cmdAtError(atError); | |
1252 return ATI_FAIL; | |
1253 } | |
1254 | |
1255 cmd.params.ptr_set_plus_cpas = &my_bat_set_plus_cpas; | |
1256 bat_send(ati_bat_get_client(srcId), &cmd); | |
1257 return ATI_EXCT; /* executing, because response is passed by callback function */ | |
1258 } | |
1259 #else /* OLD FUNCTION BODY */ | |
1260 | |
1261 ret = qAT_PlusCPAS( (T_ACI_CMD_SRC)srcId, &pas ); | |
1262 if (ret EQ AT_CMPL) | |
1263 { | |
1264 resp_disp(srcId, cl, "e", &pas); | |
1265 return ATI_CMPL; | |
1266 } | |
1267 else | |
1268 { | |
1269 cmdAtError(atError); | |
1270 return ATI_FAIL; | |
1271 } | |
1272 | |
1273 #endif /* no FF_ATI_BAT*/ | |
1274 } | |
1275 /* | |
1276 +--------------------------------------------------------------------+ | |
1277 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD | | |
1278 | STATE : code ROUTINE : atPlusCLAE | | |
1279 +--------------------------------------------------------------------+ | |
1280 | |
1281 PURPOSE : +CLAE command (Language Event) | |
1282 */ | |
1283 | |
1284 GLOBAL T_ATI_RSLT setatPlusCLAE (char *cl, UBYTE srcId) | |
1285 { | |
1286 T_ACI_RETURN ret = AT_FAIL; | |
1287 T_ACI_CLAE_MOD mode = CLAE_MOD_NotPresent; | |
1288 | |
1289 TRACE_FUNCTION("setatPLusCLAE()"); | |
1290 | |
1291 switch(*cl) | |
1292 { | |
1293 case('0'): | |
1294 mode=CLAE_MOD_Disable; | |
1295 break; | |
1296 case('1'): | |
1297 mode=CLAE_MOD_Enable; | |
1298 break; | |
1299 default: | |
1300 cmdCmeError(CME_ERR_OpNotAllow); | |
1301 return ATI_FAIL; | |
1302 } | |
1303 ret = sAT_PlusCLAE((T_ACI_CMD_SRC)srcId,mode); | |
1304 if (ret EQ AT_CMPL) | |
1305 return ATI_CMPL; | |
1306 else | |
1307 return ATI_FAIL; | |
1308 } | |
1309 | |
1310 GLOBAL T_ATI_RSLT queatPlusCLAE (char *cl, UBYTE srcId) | |
1311 { | |
1312 char *me="+CLAE: "; | |
1313 T_ACI_RETURN ret = AT_FAIL; | |
1314 T_ACI_CLAE_MOD mode=CLAE_MOD_NotPresent; | |
1315 | |
1316 TRACE_FUNCTION("queatPLusCLAE()"); | |
1317 | |
1318 ret = qAT_PlusCLAE((T_ACI_CMD_SRC)srcId,&mode); | |
1319 if(ret EQ AT_CMPL) | |
1320 { | |
1321 sprintf(g_sa,"%s%d",me,mode); | |
1322 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT); | |
1323 return ATI_CMPL; | |
1324 } | |
1325 else | |
1326 { | |
1327 cmdCmeError(CME_ERR_Unknown); | |
1328 return ATI_FAIL; | |
1329 } | |
1330 } | |
1331 | |
1332 /* | |
1333 +--------------------------------------------------------------------+ | |
1334 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD | | |
1335 | STATE : code ROUTINE : atAndC | | |
1336 +--------------------------------------------------------------------+ | |
1337 | |
1338 PURPOSE : &C command reset to factory default (not the final version) | |
1339 */ | |
1340 | |
1341 | |
1342 GLOBAL T_ATI_RSLT atAndC (char *cl, UBYTE srcId) | |
1343 { | |
1344 T_ACI_DCD_MOD val; | |
1345 | |
1346 TRACE_FUNCTION("atAndC()"); | |
1347 | |
1348 switch(*cl) | |
1349 { | |
1350 case '\0': | |
1351 case '0': | |
1352 val = DCD_ALWAYS_ON; | |
1353 break; | |
1354 | |
1355 case '1': | |
1356 val = DCD_DISABLE_AFTER_CALL; | |
1357 break; | |
1358 #ifdef RMV_01_06_04 | |
1359 case ('?'): | |
1360 qAT_AndC( srcId, &val ); | |
1361 sprintf(g_sa, "&C: %d", val); | |
1362 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT); | |
1363 return (ATI_CMPL); | |
1364 #endif | |
1365 default: | |
1366 cmdAtError(atError); | |
1367 return(ATI_FAIL); | |
1368 } | |
1369 | |
1370 #ifdef DTI | |
1371 if (sAT_AndC( (T_ACI_CMD_SRC)srcId, val ) EQ AT_CMPL) | |
1372 { | |
1373 return (ATI_CMPL); | |
1374 } | |
1375 #endif | |
1376 cmdAtError(atError); | |
1377 return (ATI_FAIL); | |
1378 } | |
1379 | |
1380 /* | |
1381 +--------------------------------------------------------------------+ | |
1382 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD | | |
1383 | STATE : code ROUTINE : atAndD | | |
1384 +--------------------------------------------------------------------+ | |
1385 | |
1386 PURPOSE : &D command to set the DTR behaviour | |
1387 */ | |
1388 | |
1389 | |
1390 GLOBAL T_ATI_RSLT atAndD (char *cl, UBYTE srcId) | |
1391 { | |
1392 UBYTE val; | |
1393 | |
1394 TRACE_FUNCTION("atAndD()"); | |
1395 | |
1396 switch(*cl) | |
1397 { | |
1398 case ('\0'): | |
1399 case ('0'): | |
1400 val = 0; | |
1401 break; | |
1402 case ('1'): | |
1403 val = 1; | |
1404 break; | |
1405 case ('2'): | |
1406 val = 2; | |
1407 break; | |
1408 #ifdef RMV_01_06_04 | |
1409 case ('?'): | |
1410 query = TRUE; | |
1411 break; | |
1412 #endif | |
1413 default: | |
1414 cmdAtError(atError); | |
1415 return ATI_FAIL; | |
1416 } | |
1417 | |
1418 #ifdef RMV_01_06_04 | |
1419 if (query) | |
1420 { | |
1421 ret=qAT_AndD (srcId, &val); | |
1422 if(ret EQ AT_CMPL) | |
1423 { | |
1424 sprintf(g_sa,"&D: %d", val); | |
1425 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT); | |
1426 return ATI_CMPL; | |
1427 } | |
1428 } | |
1429 else | |
1430 #endif | |
1431 { | |
1432 #ifdef DTI | |
1433 if (sAT_AndD ( (T_ACI_CMD_SRC)srcId, val ) EQ AT_CMPL) | |
1434 { | |
1435 return ATI_CMPL; | |
1436 } | |
1437 #endif | |
1438 } | |
1439 cmdAtError(atError); | |
1440 return ATI_FAIL; | |
1441 } | |
1442 | |
1443 /* | |
1444 +--------------------------------------------------------------------+ | |
1445 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD | | |
1446 | STATE : code ROUTINE : atAndF | | |
1447 +--------------------------------------------------------------------+ | |
1448 | |
1449 PURPOSE : &F command reset to factory default (not the final version) | |
1450 */ | |
1451 GLOBAL T_ATI_RSLT atAndF (char *cl, UBYTE srcId) | |
1452 { | |
1453 T_ACI_RETURN ret = AT_FAIL; | |
1454 | |
1455 TRACE_FUNCTION("atAndF()"); | |
1456 | |
1457 switch(*cl) | |
1458 { | |
1459 case '\0': | |
1460 case ('0'): | |
1461 /* default like ATZ */ | |
1462 ati_cmd_reset(srcId); | |
1463 break; | |
1464 case ('1'): | |
1465 ati_cmd_reset(srcId); | |
1466 | |
1467 /* | |
1468 * An other manufacturer specific parameter set. | |
1469 * | |
1470 * This is different from the user specific profiles (ATZ1). | |
1471 * | |
1472 */ | |
1473 at.flags.COLP_stat = 1; | |
1474 ati_user_output_cfg[srcId].CR_stat = 1; | |
1475 ati_user_output_cfg[srcId].CRC_stat = 1; | |
1476 ati_user_output_cfg[srcId].CLIP_stat = 1; | |
1477 ati_user_output_cfg[srcId].DR_stat = 1; | |
1478 | |
1479 ati_user_output_cfg[srcId].creg.mod_lac_cid.pres_mode = CREG_MOD_ON; | |
1480 | |
1481 #ifdef GPRS | |
1482 ati_gprs_user_output_cfg[srcId].plus_cgreg.mod_lac_cid.pres_mode = CREG_MOD_ON; | |
1483 ati_gprs_user_output_cfg[srcId].percent_cgreg.mod_lac_cid.pres_mode = CREG_MOD_ON; | |
1484 #endif | |
1485 break; | |
1486 default: | |
1487 cmdAtError(atError); | |
1488 return ATI_FAIL; | |
1489 } | |
1490 | |
1491 /* | |
1492 * The function sAT_AndF will be called with value 0 -> AT&F0 | |
1493 * because the different behavior of value 0 to 1 is only ATI | |
1494 * related and sAT_AndF() is only CMH-related. | |
1495 * | |
1496 * This is different from sAT_Z(). | |
1497 */ | |
1498 ret = sAT_AndF( (T_ACI_CMD_SRC)srcId, 0 ); | |
1499 if (ret EQ AT_CMPL) | |
1500 { | |
1501 return ATI_CMPL; | |
1502 } | |
1503 cmdAtError(atError); | |
1504 return ATI_FAIL; | |
1505 | |
1506 } | |
1507 | |
1508 /* | |
1509 +--------------------------------------------------------------------+ | |
1510 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD | | |
1511 | STATE : code ROUTINE : atAndK | | |
1512 +--------------------------------------------------------------------+ | |
1513 | |
1514 PURPOSE : &K only for compatibility | |
1515 */ | |
1516 | |
1517 | |
1518 GLOBAL T_ATI_RSLT atAndK (char *cl, UBYTE srcId) | |
1519 { | |
1520 TRACE_FUNCTION("atAndK()"); | |
1521 | |
1522 switch(*cl) | |
1523 { | |
1524 case ('0'): | |
1525 case ('1'): | |
1526 case ('2'): | |
1527 case ('3'): | |
1528 case ('4'): | |
1529 return ATI_CMPL; | |
1530 default: | |
1531 cmdAtError(atError); | |
1532 return ATI_FAIL; | |
1533 } | |
1534 } | |
1535 | |
1536 /* | |
1537 +--------------------------------------------------------------------+ | |
1538 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD | | |
1539 | STATE : code ROUTINE : atPlusCSQ | | |
1540 +--------------------------------------------------------------------+ | |
1541 | |
1542 PURPOSE : +CSQ, signal quality | |
1543 */ | |
1544 | |
1545 GLOBAL T_ATI_RSLT setatPlusCSQ ( char *cl, UBYTE srcId) | |
1546 { | |
1547 rx_Status_Type rxStat; | |
1548 UBYTE rssi; | |
1549 UBYTE ber; | |
1550 | |
1551 TRACE_FUNCTION("setatPlusCSQ()"); | |
1552 | |
1553 if ( rx_GetStatus ( &rxStat ) NEQ DRV_OK ) | |
1554 { | |
1555 cmdCmeError ( CME_ERR_Unknown ); | |
1556 return ATI_FAIL; | |
1557 } | |
1558 else | |
1559 { | |
1560 if ( rxStat.gsmLevel EQ 0xFF OR rxStat.gsmLevel EQ 0 ) | |
1561 { | |
1562 rssi = ACI_RSSI_FAULT; | |
1563 } | |
1564 else if ( rxStat.gsmLevel > 59 ) | |
1565 { | |
1566 rssi = 31; | |
1567 } | |
1568 else | |
1569 { | |
1570 rssi = ( rxStat.gsmLevel / 2 ) + 2; | |
1571 } | |
1572 | |
1573 if ( rxStat.rxQuality EQ RX_QUAL_UNAVAILABLE ) | |
1574 { | |
1575 ber = ACI_BER_FAULT; | |
1576 } | |
1577 else | |
1578 { | |
1579 ber = rxStat.rxQuality; | |
1580 } | |
1581 | |
1582 sprintf (g_sa, "+CSQ: %d,%d ", rssi, ber ); | |
1583 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT); | |
1584 return ATI_CMPL; | |
1585 } | |
1586 } | |
1587 | |
1588 GLOBAL T_ATI_RSLT tesatPlusCSQ(CHAR *cl, UBYTE srcId) | |
1589 { | |
1590 TRACE_FUNCTION("tesatPLusCSQ()"); | |
1591 | |
1592 sprintf (g_sa, "+CSQ: 2-31,(%d),(%d)", ACI_RSSI_FAULT, ACI_BER_FAULT ); | |
1593 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT); | |
1594 return ATI_CMPL; | |
1595 } | |
1596 | |
1597 /* | |
1598 +--------------------------------------------------------------------+ | |
1599 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD | | |
1600 | STATE : code ROUTINE : atPlusCSQ | | |
1601 +--------------------------------------------------------------------+ | |
1602 | |
1603 PURPOSE : %CSQ, signal quality | |
1604 | |
1605 Shen,Chao Juni.12th.2003 | |
1606 */ | |
1607 | |
1608 GLOBAL T_ATI_RSLT setatPercentCSQ ( char *cl, UBYTE srcId) | |
1609 { | |
1610 T_ACI_CSQ_MODE CSQmode = CSQ_Disable; | |
1611 rx_Status_Type rxStat; | |
1612 | |
1613 | |
1614 TRACE_FUNCTION("setatPercentCSQ()"); | |
1615 | |
1616 if ( rx_GetStatus ( &rxStat ) NEQ DRV_OK ) | |
1617 { | |
1618 cmdCmeError ( CME_ERR_Unknown ); | |
1619 return ATI_FAIL; | |
1620 } | |
1621 else | |
1622 { | |
1623 switch( *cl ) | |
1624 { | |
1625 case '0': | |
1626 { | |
1627 CSQmode = CSQ_Disable; | |
1628 break; | |
1629 } | |
1630 | |
1631 case '1': | |
1632 { | |
1633 CSQmode = CSQ_Enable; | |
1634 break; | |
1635 } | |
1636 | |
1637 default: | |
1638 { | |
1639 cmdCmeError(CME_ERR_Unknown); | |
1640 return (ATI_FAIL); | |
1641 } | |
1642 } | |
1643 #ifdef FF_ATI_BAT | |
1644 { | |
1645 T_BAT_cmd_send cmd; | |
1646 T_BAT_cmd_set_percent_csq csq; | |
1647 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id); | |
1648 | |
1649 TRACE_FUNCTION("setatPercentCSQ() calls bat_send() <=== as APPLICATION"); | |
1650 | |
1651 cmd.ctrl_params = BAT_CMD_SET_PERCENT_CSQ; | |
1652 cmd.params.ptr_set_percent_csq = &csq; | |
1653 csq.csq_mode = CSQmode; | |
1654 src_params->curAtCmd = AT_CMD_P_CSQ; | |
1655 bat_send(ati_bat_get_client(srcId), &cmd); | |
1656 | |
1657 return ATI_EXCT; | |
1658 } | |
1659 #else | |
1660 if (sAT_PercentCSQ((T_ACI_CMD_SRC)srcId,CSQmode) NEQ AT_CMPL) | |
1661 { | |
1662 TRACE_EVENT("setatPercentCSQ call sAT_PercentCSQ Error!!"); | |
1663 } | |
1664 | |
1665 sprintf (g_sa, "%s%d ", "%CSQ: ", CSQmode); | |
1666 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT); | |
1667 return ATI_CMPL; | |
1668 #endif /* FF_ATI_BAT */ | |
1669 } | |
1670 } | |
1671 | |
1672 | |
1673 GLOBAL T_ATI_RSLT queatPercentCSQ(CHAR *cl, UBYTE srcId) | |
1674 { | |
1675 rx_Status_Type rxStat; | |
1676 | |
1677 TRACE_FUNCTION("queatPercentCSQ()"); | |
1678 | |
1679 #ifdef FF_PS_RSSI | |
1680 qAT_PercentCSQ((T_ACI_CMD_SRC)srcId,&rxStat.gsmLevel,&rxStat.rxQuality,&rxStat.actLevel,&rxStat.min_access_level); | |
1681 sprintf (g_sa, "%s %d, %d, %d, %d", "%CSQ: ",rxStat.gsmLevel, rxStat.rxQuality, rxStat.actLevel, rxStat.min_access_level); | |
1682 #else | |
1683 qAT_PercentCSQ((T_ACI_CMD_SRC)srcId,&rxStat.gsmLevel,&rxStat.rxQuality,&rxStat.actLevel); | |
1684 sprintf (g_sa, "%s %d, %d, %d", "%CSQ: ",rxStat.gsmLevel, rxStat.rxQuality, rxStat.actLevel); | |
1685 #endif | |
1686 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT); | |
1687 | |
1688 return ATI_CMPL; | |
1689 } | |
1690 | |
1691 | |
1692 GLOBAL T_ATI_RSLT tesatPercentCSQ(CHAR *cl, UBYTE srcId) | |
1693 { | |
1694 TRACE_FUNCTION("tesatPercentCSQ()"); | |
1695 | |
1696 #ifdef FF_PS_RSSI | |
1697 sprintf (g_sa, "%s (%d), (%d), (%d), 0-4", "%CSQ: ",ACI_RSSI_FAULT, ACI_BER_FAULT, ACI_MIN_RXLEV_FAULT); | |
1698 #else | |
1699 sprintf (g_sa, "%s (%d), (%d), 0-4", "%CSQ: ",ACI_RSSI_FAULT, ACI_BER_FAULT); | |
1700 #endif | |
1701 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT); | |
1702 return ATI_CMPL; | |
1703 } | |
1704 | |
1705 #ifdef TI_PS_FF_AT_P_CMD_DBGINFO | |
1706 /* | |
1707 +--------------------------------------------------------------------+ | |
1708 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD | | |
1709 | STATE : code ROUTINE : atPercentDBGINFO | | |
1710 +--------------------------------------------------------------------+ | |
1711 | |
1712 PURPOSE : %DBGINFO, query free mem pool blocks. | |
1713 */ | |
1714 | |
1715 GLOBAL T_ATI_RSLT setatPercentDBGINFO ( char *cl, UBYTE srcId) | |
1716 { | |
1717 char *me = "%DBGINFO:"; | |
1718 ULONG param = 0; | |
1719 T_ACI_DBG_INFO stor = P_DBGINFO_NotPresent; | |
1720 CHAR type[4] = {0}; | |
1721 USHORT free = 0, alloc = 0, i = 0; | |
1722 | |
1723 TRACE_FUNCTION("queatPercentDBGINFO()"); | |
1724 | |
1725 cl = parse(cl,"sd",(LONG)4, type, ¶m); | |
1726 if(!cl OR *type EQ '\0') | |
1727 { | |
1728 cmdCmeError(CME_ERR_OpNotAllow); | |
1729 return (ATI_FAIL); | |
1730 } | |
1731 strupper(type); | |
1732 for(i=0;dbg_mem_names[i].name NEQ 0;i++) | |
1733 { | |
1734 if (!strcmp(dbg_mem_names[i].name, type) ) | |
1735 { | |
1736 stor = dbg_mem_names[i].stor; | |
1737 break; | |
1738 } | |
1739 } | |
1740 if((dbg_mem_names[i].name EQ 0) OR (param EQ 0)) | |
1741 { | |
1742 cmdCmeError(CME_ERR_OpNotAllow); | |
1743 return (ATI_FAIL); | |
1744 } | |
1745 if (qAT_PercentDBGINFO((T_ACI_CMD_SRC)srcId, param, (USHORT)stor, &free, &alloc) NEQ AT_CMPL) | |
1746 { | |
1747 cmdCmeError(CME_ERR_Unknown); | |
1748 return (ATI_FAIL); | |
1749 } | |
1750 sprintf(g_sa, "%s%d", me, free); | |
1751 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT); | |
1752 | |
1753 return (ATI_CMPL); | |
1754 } | |
1755 #endif /* TI_PS_FF_AT_P_CMD_DBGINFO */ | |
1756 | |
1757 /* | |
1758 +--------------------------------------------------------------------+ | |
1759 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD | | |
1760 | STATE : code ROUTINE : atPlusCBC | | |
1761 +--------------------------------------------------------------------+ | |
1762 | |
1763 PURPOSE : +CBC, battery charge | |
1764 */ | |
1765 #define ACI_BCS_BattPower 0 | |
1766 #define ACI_BCS_BattCnctd 1 | |
1767 #define ACI_BCS_NoBatt 2 | |
1768 #define ACI_BCS_PowerFault 3 | |
1769 | |
1770 GLOBAL T_ATI_RSLT atPlusCBC ( char *cl, UBYTE srcId ) | |
1771 { | |
1772 pwr_Status_Type powerStat; | |
1773 UBYTE bcs; | |
1774 | |
1775 TRACE_FUNCTION("atPlusCBC()"); | |
1776 | |
1777 if ( pwr_GetStatus ( &powerStat ) NEQ DRV_OK ) | |
1778 { | |
1779 cmdCmeError ( CME_ERR_Unknown ); | |
1780 return ATI_FAIL; | |
1781 } | |
1782 else | |
1783 { | |
1784 switch ( powerStat.Status ) | |
1785 { | |
1786 case ( PWR_EXTPOWER_ON ): | |
1787 bcs = ACI_BCS_NoBatt; | |
1788 break; | |
1789 | |
1790 case ( PWR_CHARGER_ON ): | |
1791 bcs = ACI_BCS_BattCnctd; | |
1792 break; | |
1793 | |
1794 default: | |
1795 bcs = ACI_BCS_BattPower; | |
1796 break; | |
1797 } | |
1798 sprintf(g_sa, "+CBC: %d,%d", bcs, powerStat.ChargeLevel ); | |
1799 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT); | |
1800 return ATI_CMPL; | |
1801 } | |
1802 } | |
1803 | |
1804 /* | |
1805 +--------------------------------------------------------------------+ | |
1806 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD | | |
1807 | STATE : code ROUTINE : atPlusCLVL | | |
1808 +--------------------------------------------------------------------+ | |
1809 | |
1810 PURPOSE : +CLVL, loudspeaker volume level | |
1811 */ | |
1812 GLOBAL T_ATI_RSLT setatPlusCLVL ( char *cl, UBYTE srcId ) | |
1813 { | |
1814 #ifdef FF_ATI_BAT | |
1815 { | |
1816 T_BAT_cmd_send cmd; | |
1817 T_BAT_cmd_set_plus_clvl my_bat_set_plus_clvl; | |
1818 SHORT vol; | |
1819 | |
1820 TRACE_FUNCTION("setatPlusCLVL() calls bat_send() <=== as APPLICATION"); | |
1821 | |
1822 cl = parse ( cl, "d", &vol ); | |
1823 | |
1824 if( !cl OR vol > 255 OR vol < 0 ) | |
1825 { | |
1826 cmdCmeError ( CME_ERR_OpNotAllow ); | |
1827 return ATI_FAIL; | |
1828 } | |
1829 | |
1830 memset(&my_bat_set_plus_clvl, 0, sizeof(my_bat_set_plus_clvl)); | |
1831 cmd.ctrl_params = BAT_CMD_SET_PLUS_CLVL; | |
1832 cmd.params.ptr_set_plus_clvl = &my_bat_set_plus_clvl; | |
1833 | |
1834 my_bat_set_plus_clvl.level = (U8)vol; | |
1835 | |
1836 bat_send(ati_bat_get_client(srcId), &cmd); | |
1837 | |
1838 return ATI_EXCT; /* executing, because response is passed by callback function */ | |
1839 } | |
1840 #else /* OLD FUNCTION BODY */ | |
1841 | |
1842 TRACE_FUNCTION("setatPlusCLVL()"); | |
1843 | |
1844 return setaciPrcsVolLevel ( cl, AUDIO_SPEAKER ); | |
1845 | |
1846 #endif /* no FF_ATI_BAT*/ | |
1847 } | |
1848 | |
1849 GLOBAL T_ATI_RSLT tesatPlusCLVL ( char *cl, UBYTE srcId ) | |
1850 { | |
1851 TRACE_FUNCTION("tesatPlusCLVL()"); | |
1852 | |
1853 return tesaciPrcsVolLevel ( srcId, cl, AUDIO_SPEAKER ); | |
1854 } | |
1855 | |
1856 GLOBAL T_ATI_RSLT queatPlusCLVL ( char *cl, UBYTE srcId ) | |
1857 { | |
1858 TRACE_FUNCTION("queatPlusCLVL()"); | |
1859 | |
1860 return queaciPrcsVolLevel ( srcId, cl, AUDIO_SPEAKER ); | |
1861 } | |
1862 | |
1863 /* | |
1864 +--------------------------------------------------------------------+ | |
1865 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD | | |
1866 | STATE : code ROUTINE : atPlusCRSL | | |
1867 +--------------------------------------------------------------------+ | |
1868 | |
1869 PURPOSE : +CRSL, ringer sound level | |
1870 */ | |
1871 GLOBAL T_ATI_RSLT setatPlusCRSL ( char *cl, UBYTE srcId ) | |
1872 { | |
1873 TRACE_FUNCTION("atPlusCRSL()"); | |
1874 | |
1875 return setaciPrcsVolLevel ( cl, AUDIO_BUZZER ); | |
1876 } | |
1877 | |
1878 GLOBAL T_ATI_RSLT tesatPlusCRSL ( char *cl, UBYTE srcId ) | |
1879 { | |
1880 TRACE_FUNCTION("tesatPlusCRSL()"); | |
1881 | |
1882 return tesaciPrcsVolLevel ( srcId, cl, AUDIO_BUZZER ); | |
1883 } | |
1884 | |
1885 GLOBAL T_ATI_RSLT queatPlusCRSL ( char *cl, UBYTE srcId ) | |
1886 { | |
1887 TRACE_FUNCTION("queatPlusCRSL()"); | |
1888 | |
1889 return queaciPrcsVolLevel ( srcId, cl, AUDIO_BUZZER ); | |
1890 } | |
1891 | |
1892 /* | |
1893 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD | | |
1894 | STATE : code ROUTINE : aciPrcsVolLevel | | |
1895 | |
1896 PURPOSE : +CLVL, +CRSL loudspeaker volume level | |
1897 */ | |
1898 LOCAL T_ATI_RSLT setaciPrcsVolLevel ( CHAR* cl, UBYTE device ) | |
1899 { | |
1900 SHORT vol; | |
1901 | |
1902 cl = parse ( cl, "d", &vol ); | |
1903 | |
1904 if( !cl OR vol > 255 OR vol < 0 ) | |
1905 { | |
1906 cmdCmeError ( CME_ERR_OpNotAllow ); | |
1907 return ATI_FAIL; | |
1908 } | |
1909 else | |
1910 { | |
1911 if ( audio_SetAmplf( device, ( UBYTE ) vol ) NEQ DRV_OK ) | |
1912 { | |
1913 cmdCmeError ( CME_ERR_Unknown ); | |
1914 return ATI_FAIL; | |
1915 } | |
1916 } | |
1917 return ATI_CMPL; | |
1918 } | |
1919 | |
1920 LOCAL T_ATI_RSLT tesaciPrcsVolLevel ( UBYTE srcId, CHAR* cl, UBYTE device ) | |
1921 { | |
1922 CHAR *p_sa; | |
1923 audio_Status_Type audioStat; | |
1924 | |
1925 switch (device) | |
1926 { | |
1927 case AUDIO_SPEAKER: | |
1928 p_sa = "CLVL"; | |
1929 break; | |
1930 case AUDIO_BUZZER: | |
1931 p_sa = "CRSL"; | |
1932 break; | |
1933 default: | |
1934 cmdCmeError ( CME_ERR_Unknown ); | |
1935 return ATI_FAIL; | |
1936 } | |
1937 | |
1938 if ( audio_GetStatus ( device, &audioStat ) NEQ DRV_OK ) | |
1939 { | |
1940 cmdCmeError ( CME_ERR_Unknown ); | |
1941 return ATI_FAIL; | |
1942 } | |
1943 { | |
1944 sprintf( g_sa, "+%s: (%d-%d)", p_sa, audioStat.min_volume, audioStat.max_volume ); | |
1945 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT); | |
1946 } | |
1947 return ATI_CMPL; | |
1948 } | |
1949 | |
1950 | |
1951 LOCAL T_ATI_RSLT queaciPrcsVolLevel ( UBYTE srcId, CHAR* cl, UBYTE device ) | |
1952 { | |
1953 SHORT vol; | |
1954 UBYTE drvVol; | |
1955 CHAR *p_sa; | |
1956 | |
1957 switch (device) | |
1958 { | |
1959 case AUDIO_SPEAKER: | |
1960 p_sa = "CLVL"; | |
1961 break; | |
1962 case AUDIO_BUZZER: | |
1963 p_sa = "CRSL"; | |
1964 break; | |
1965 default: | |
1966 cmdCmeError ( CME_ERR_Unknown ); | |
1967 return ATI_FAIL; | |
1968 } | |
1969 | |
1970 if ( audio_GetAmplf ( device, &drvVol ) NEQ DRV_OK ) | |
1971 { | |
1972 cmdCmeError ( CME_ERR_Unknown ); | |
1973 return ATI_FAIL; | |
1974 } | |
1975 else | |
1976 { | |
1977 vol = drvVol; | |
1978 sprintf ( g_sa, "+%s: %d", p_sa, vol ); | |
1979 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT); | |
1980 } | |
1981 return ATI_CMPL; | |
1982 } | |
1983 | |
1984 /* | |
1985 +--------------------------------------------------------------------+ | |
1986 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD | | |
1987 | STATE : code ROUTINE : atPlusCMUT | | |
1988 +--------------------------------------------------------------------+ | |
1989 | |
1990 PURPOSE : +CMUT, mute control | |
1991 */ | |
1992 #define ACI_MUTE_OFF 0 | |
1993 #define ACI_MUTE_ON 1 | |
1994 | |
1995 GLOBAL T_ATI_RSLT setatPlusCMUT(CHAR *cl, UBYTE srcId) | |
1996 { | |
1997 SHORT mute; | |
1998 UBYTE drvMute; | |
1999 | |
2000 cl = parse ( cl, "d", &mute ); | |
2001 | |
2002 if( !cl OR ( mute NEQ ACI_MUTE_OFF AND mute NEQ ACI_MUTE_ON ) ) | |
2003 { | |
2004 cmdCmeError ( CME_ERR_OpNotAllow ); | |
2005 return ATI_FAIL; | |
2006 } | |
2007 if ( mute EQ ACI_MUTE_OFF ) | |
2008 { | |
2009 drvMute = AUDIO_MUTING_OFF; | |
2010 } | |
2011 else | |
2012 { | |
2013 drvMute = AUDIO_MUTING_ON; | |
2014 } | |
2015 if (audio_SetMute (AUDIO_MICROPHONE, drvMute) NEQ DRV_OK) | |
2016 { | |
2017 cmdCmeError ( CME_ERR_Unknown ); | |
2018 return ATI_FAIL; | |
2019 } | |
2020 | |
2021 #ifdef FF_ATI_BAT | |
2022 { | |
2023 T_BAT_cmd_send cmd; | |
2024 T_BAT_cmd_set_plus_cmut my_bat_set_plus_cmut; | |
2025 | |
2026 TRACE_FUNCTION("setatPlusCMUT() calls bat_send() <=== as APPLICATION"); | |
2027 | |
2028 memset(&my_bat_set_plus_cmut, 0, sizeof(my_bat_set_plus_cmut)); | |
2029 cmd.ctrl_params = BAT_CMD_SET_PLUS_CMUT; | |
2030 cmd.params.ptr_set_plus_cmut = &my_bat_set_plus_cmut; | |
2031 my_bat_set_plus_cmut.n = (T_BAT_plus_cmut_n)drvMute; | |
2032 bat_send(ati_bat_get_client(srcId), &cmd); | |
2033 return ATI_EXCT; /* executing, because response is passed by callback function */ | |
2034 } | |
2035 #else /* OLD FUNCTION BODY */ | |
2036 | |
2037 TRACE_FUNCTION("setatPLusCMUT()"); | |
2038 | |
2039 return ATI_CMPL; | |
2040 | |
2041 #endif /* no FF_ATI_BAT */ | |
2042 } | |
2043 | |
2044 GLOBAL T_ATI_RSLT tesatPlusCMUT ( char *cl, UBYTE srcId ) | |
2045 { | |
2046 TRACE_FUNCTION("tesatPlusCMUT()"); | |
2047 | |
2048 sprintf(g_sa, "+CMUT: (%d,%d)", ACI_MUTE_OFF, ACI_MUTE_ON ); | |
2049 io_sendMessage (srcId, g_sa, ATI_NORMAL_OUTPUT); | |
2050 return ATI_CMPL; | |
2051 } | |
2052 | |
2053 GLOBAL T_ATI_RSLT queatPlusCMUT(CHAR *cl, UBYTE srcId) | |
2054 { | |
2055 SHORT mute; | |
2056 UBYTE drvMute; | |
2057 | |
2058 TRACE_FUNCTION("queatPlusCMUT()"); | |
2059 | |
2060 if ( audio_GetMute ( AUDIO_MICROPHONE, &drvMute ) NEQ DRV_OK ) | |
2061 { | |
2062 cmdCmeError ( CME_ERR_Unknown ); | |
2063 return ATI_FAIL; | |
2064 } | |
2065 else | |
2066 { | |
2067 if ( drvMute EQ AUDIO_MUTING_OFF ) | |
2068 { | |
2069 mute = ACI_MUTE_OFF; | |
2070 } | |
2071 else | |
2072 { | |
2073 mute = ACI_MUTE_ON; | |
2074 } | |
2075 | |
2076 sprintf ( g_sa, "+CMUT: %d", mute ); | |
2077 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT); | |
2078 return ATI_CMPL; | |
2079 } | |
2080 } | |
2081 | |
2082 /* | |
2083 +--------------------------------------------------------------------+ | |
2084 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD | | |
2085 | STATE : code ROUTINE : atPlusCGMI | | |
2086 +--------------------------------------------------------------------+ | |
2087 | |
2088 PURPOSE : +CGMI, show name of manufacturer | |
2089 */ | |
2090 GLOBAL T_ATI_RSLT atPlusCGMI ( char *cl, UBYTE srcId ) | |
2091 { | |
2092 TRACE_FUNCTION("atPlusCGMI()"); | |
2093 | |
2094 return aciPrcsPlusCG (srcId, cl, EF_CGMI_ID); | |
2095 } | |
2096 | |
2097 /* | |
2098 +--------------------------------------------------------------------+ | |
2099 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD | | |
2100 | STATE : code ROUTINE : atPlusCGMM | | |
2101 +--------------------------------------------------------------------+ | |
2102 | |
2103 PURPOSE : +CGMM, show name of prodcut | |
2104 */ | |
2105 GLOBAL T_ATI_RSLT atPlusCGMM ( char *cl, UBYTE srcId ) | |
2106 { | |
2107 TRACE_FUNCTION("atPlusCGMM()"); | |
2108 | |
2109 return aciPrcsPlusCG (srcId, cl, EF_CGMM_ID); | |
2110 } | |
2111 | |
2112 /* | |
2113 +--------------------------------------------------------------------+ | |
2114 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD | | |
2115 | STATE : code ROUTINE : atPlusCGMR | | |
2116 +--------------------------------------------------------------------+ | |
2117 | |
2118 PURPOSE : +CGMR, show version of product | |
2119 */ | |
2120 GLOBAL T_ATI_RSLT atPlusCGMR ( char *cl, UBYTE srcId ) | |
2121 { | |
2122 TRACE_FUNCTION("atPlusCGMR()"); | |
2123 | |
2124 return aciPrcsPlusCG (srcId, cl, EF_CGMR_ID); | |
2125 } | |
2126 | |
2127 /* | |
2128 +--------------------------------------------------------------------+ | |
2129 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD | | |
2130 | STATE : code ROUTINE : atPlusCGSN | | |
2131 +--------------------------------------------------------------------+ | |
2132 | |
2133 PURPOSE : +CGSN, show serial number | |
2134 */ | |
2135 GLOBAL T_ATI_RSLT atPlusCGSN ( char *cl, UBYTE srcId ) | |
2136 { | |
2137 TRACE_FUNCTION("atPlusCGSN()"); | |
2138 | |
2139 return aciPrcsPlusCG (srcId, cl, EF_CGSN_ID); | |
2140 } | |
2141 | |
2142 /* | |
2143 +--------------------------------------------------------------------+ | |
2144 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD | | |
2145 | STATE : code ROUTINE : atPlusFMI | | |
2146 +--------------------------------------------------------------------+ | |
2147 | |
2148 PURPOSE : +FMI, show name of manufacturer | |
2149 */ | |
2150 GLOBAL T_ATI_RSLT atPlusFMI ( char *cl, UBYTE srcId ) | |
2151 { | |
2152 TRACE_FUNCTION("atPlusFMI()"); | |
2153 | |
2154 if ( *cl NEQ '?') | |
2155 { | |
2156 cmdCmeError ( CME_ERR_OpNotAllow ); | |
2157 return ATI_FAIL; | |
2158 } | |
2159 return aciPrcsPlusCG (srcId, cl, EF_CGMI_ID); | |
2160 } | |
2161 | |
2162 /* | |
2163 +--------------------------------------------------------------------+ | |
2164 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD | | |
2165 | STATE : code ROUTINE : atPlusFMM | | |
2166 +--------------------------------------------------------------------+ | |
2167 | |
2168 PURPOSE : +FMM, show name of prodcut | |
2169 */ | |
2170 GLOBAL T_ATI_RSLT atPlusFMM ( char *cl, UBYTE srcId ) | |
2171 { | |
2172 TRACE_FUNCTION("atPlusFMM()"); | |
2173 | |
2174 if ( *cl NEQ '?') | |
2175 { | |
2176 cmdCmeError ( CME_ERR_OpNotAllow ); | |
2177 return ATI_FAIL; | |
2178 } | |
2179 return aciPrcsPlusCG (srcId, cl, EF_CGMM_ID); | |
2180 } | |
2181 | |
2182 /* | |
2183 +--------------------------------------------------------------------+ | |
2184 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD | | |
2185 | STATE : code ROUTINE : atPlusFMR | | |
2186 +--------------------------------------------------------------------+ | |
2187 | |
2188 PURPOSE : +FMR, show version of product | |
2189 */ | |
2190 GLOBAL T_ATI_RSLT atPlusFMR ( char *cl, UBYTE srcId ) | |
2191 { | |
2192 TRACE_FUNCTION("atPlusFMR()"); | |
2193 | |
2194 if ( *cl NEQ '?') | |
2195 { | |
2196 cmdCmeError ( CME_ERR_OpNotAllow ); | |
2197 return ATI_FAIL; | |
2198 } | |
2199 return aciPrcsPlusCG (srcId, cl, EF_CGMR_ID); | |
2200 } | |
2201 | |
2202 /* | |
2203 +--------------------------------------------------------------------+ | |
2204 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD | | |
2205 | STATE : code ROUTINE : aciPrcsPlusCG | | |
2206 +--------------------------------------------------------------------+ | |
2207 | |
2208 PURPOSE : | |
2209 */ | |
2210 LOCAL T_ATI_RSLT aciPrcsPlusCG (UBYTE srcId, CHAR* cl, CHAR* ef) | |
2211 { | |
2212 pcm_FileInfo_Type fileInfo; | |
2213 USHORT i; | |
2214 | |
2215 TRACE_FUNCTION("aciPrcsPlusCG()"); | |
2216 | |
2217 if (pcm_GetFileInfo ((UBYTE* )ef, &fileInfo) NEQ DRV_OK) | |
2218 { | |
2219 cmdCmeError (CME_ERR_MemFail); | |
2220 return ATI_FAIL; | |
2221 } | |
2222 | |
2223 | |
2224 if (pcm_ReadFile ((UBYTE*)ef, fileInfo.FileSize, | |
2225 (UBYTE*)g_sa, &fileInfo.Version) NEQ DRV_OK) | |
2226 { | |
2227 cmdCmeError (CME_ERR_MemFail); | |
2228 return ATI_FAIL; | |
2229 } | |
2230 | |
2231 i = 0; | |
2232 while ((UBYTE)g_sa[i] NEQ 0xFF) | |
2233 { | |
2234 i++; | |
2235 } | |
2236 g_sa[i] = '\0'; | |
2237 io_sendMessage (srcId, g_sa, ATI_NORMAL_OUTPUT ); | |
2238 | |
2239 return ATI_CMPL; | |
2240 } | |
2241 | |
2242 | |
2243 /* | |
2244 +--------------------------------------------------------------------+ | |
2245 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD | | |
2246 | STATE : code ROUTINE : atPlusCSCS | | |
2247 +--------------------------------------------------------------------+ | |
2248 | |
2249 PURPOSE : +CSCS command (Select TE character set) | |
2250 */ | |
2251 GLOBAL T_ATI_RSLT setatPlusCSCS (char *cl, UBYTE srcId) | |
2252 { | |
2253 CHAR txtChset[10]; | |
2254 T_ACI_CSCS_CHSET chset = CSCS_CHSET_NotPresent; | |
2255 | |
2256 TRACE_FUNCTION("setatPlusCSCS()"); | |
2257 | |
2258 cl = parse ( cl, "s", (LONG) sizeof (txtChset), txtChset); | |
2259 | |
2260 if ( strcmp ( txtChset, "GSM" ) EQ 0 ) | |
2261 chset = CSCS_CHSET_Gsm; | |
2262 else if ( strcmp ( txtChset, "IRA" ) EQ 0 ) | |
2263 chset = CSCS_CHSET_Ira; | |
2264 else if ( strcmp ( txtChset, "PCCP437" ) EQ 0 ) | |
2265 chset = CSCS_CHSET_Pccp_437; | |
2266 else if ( strcmp ( txtChset, "PCDN" ) EQ 0 ) | |
2267 chset = CSCS_CHSET_Pcdn; | |
2268 else if ( strcmp ( txtChset, "8859-1" ) EQ 0 ) | |
2269 chset = CSCS_CHSET_8859_1; | |
2270 else if ( strcmp ( txtChset, "HEX" ) EQ 0 ) | |
2271 chset = CSCS_CHSET_Hex; | |
2272 else if ( strcmp ( txtChset, "UCS2" ) EQ 0 ) | |
2273 chset = CSCS_CHSET_Ucs2; | |
2274 | |
2275 if ( !cl OR chset EQ CSCS_CHSET_NotPresent ) | |
2276 { | |
2277 cmdCmeError ( CME_ERR_OpNotAllow ); | |
2278 return ATI_FAIL; | |
2279 } | |
2280 | |
2281 #ifdef FF_ATI_BAT | |
2282 | |
2283 { | |
2284 T_BAT_cmd_send cmd; | |
2285 T_BAT_cmd_set_plus_cscs cscs; | |
2286 | |
2287 cmd.ctrl_params=BAT_CMD_SET_PLUS_CSCS; | |
2288 cmd.params.ptr_set_plus_cscs=&cscs; | |
2289 /* | |
2290 * This relies on T_BAT_plus_cscs being identical to | |
2291 * T_ACI_CSCS_CHSET. It is, apart from the NotPresent | |
2292 * value, which is taken care of earlier in this | |
2293 * function. | |
2294 */ | |
2295 cscs.cs=(T_BAT_plus_cscs_cs)chset; | |
2296 bat_send(ati_bat_get_client(srcId), &cmd); | |
2297 return(ATI_EXCT); | |
2298 } | |
2299 | |
2300 #else | |
2301 | |
2302 ati_user_output_cfg[srcId].cscsChset = chset; | |
2303 return ATI_CMPL; | |
2304 | |
2305 #endif | |
2306 } | |
2307 | |
2308 GLOBAL T_ATI_RSLT queatPlusCSCS (char *cl, UBYTE srcId) | |
2309 { | |
2310 TRACE_FUNCTION("queatPlusCSCS()"); | |
2311 | |
2312 #ifdef FF_ATI_BAT | |
2313 { | |
2314 T_BAT_cmd_send cmd; | |
2315 T_BAT_no_parameter dummy; | |
2316 | |
2317 cmd.ctrl_params=BAT_CMD_QUE_PLUS_CSCS; | |
2318 dummy.bat_dummy = 0xFF; | |
2319 cmd.params.ptr_que_plus_cscs = &dummy; | |
2320 bat_send(ati_bat_get_client(srcId), &cmd); | |
2321 } | |
2322 return(ATI_EXCT); | |
2323 | |
2324 #else /* no FF_ATI_BAT */ | |
2325 | |
2326 strcpy ( g_sa, "+CSCS: "); | |
2327 | |
2328 switch ( ati_user_output_cfg[srcId].cscsChset ) | |
2329 { | |
2330 case (CSCS_CHSET_Ira ): strcat (g_sa,"\"IRA\"" ); break; | |
2331 case (CSCS_CHSET_Pcdn ): strcat (g_sa,"\"PCDN\"" ); break; | |
2332 case (CSCS_CHSET_8859_1 ): strcat (g_sa,"\"8859-1\"" ); break; | |
2333 case (CSCS_CHSET_Pccp_437): strcat (g_sa,"\"PCCP437\""); break; | |
2334 case (CSCS_CHSET_Gsm ): strcat (g_sa,"\"GSM\"" ); break; | |
2335 case (CSCS_CHSET_Hex ): strcat (g_sa,"\"HEX\"" ); break; | |
2336 case (CSCS_CHSET_Ucs2 ): strcat (g_sa,"\"UCS2\"" ); break; | |
2337 | |
2338 /* | |
2339 *----------------------------------------------------------- | |
2340 * This case will be prevented during settings procedure of | |
2341 * the TE character set ( CSCS=... ) | |
2342 *----------------------------------------------------------- | |
2343 */ | |
2344 default: cmdCmeError ( CME_ERR_Unknown ); return ATI_FAIL; | |
2345 } | |
2346 | |
2347 io_sendMessage ( srcId, g_sa, ATI_NORMAL_OUTPUT ); | |
2348 return ATI_CMPL; | |
2349 | |
2350 #endif /* no FF_ATI_BAT */ | |
2351 } | |
2352 | |
2353 /* | |
2354 +--------------------------------------------------------------------+ | |
2355 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD | | |
2356 | STATE : code ROUTINE : atPlusCMEE | | |
2357 +--------------------------------------------------------------------+ | |
2358 | |
2359 PURPOSE : +CMEE command (Error display mode) | |
2360 */ | |
2361 | |
2362 GLOBAL T_ATI_RSLT setatPlusCMEE(CHAR *cl, UBYTE srcId) | |
2363 { | |
2364 SHORT val; | |
2365 | |
2366 TRACE_FUNCTION("setatPLusCMEE()"); | |
2367 | |
2368 cl=parse(cl,"r",&val); | |
2369 if ( !cl OR val > CMEE_MOD_Verbose OR val < CMEE_MOD_Disable ) | |
2370 { | |
2371 cmdAtError(atError); | |
2372 return ATI_FAIL; | |
2373 } | |
2374 else | |
2375 { | |
2376 TRACE_EVENT_P2("setatPlusCMEE: srcId = %d Value = %d", srcId, val); | |
2377 ati_user_output_cfg[srcId].CMEE_stat = (UBYTE)val; | |
2378 return ATI_CMPL; | |
2379 } | |
2380 } | |
2381 | |
2382 | |
2383 /* query function */ | |
2384 | |
2385 GLOBAL T_ATI_RSLT queatPlusCMEE(CHAR *cl, UBYTE srcId) | |
2386 { | |
2387 TRACE_FUNCTION("queatPLusCMEE()"); | |
2388 | |
2389 TRACE_EVENT_P1("queatPlusCMEE: srcId = %d", srcId); | |
2390 resp_disp(srcId, cl,"b",&ati_user_output_cfg[srcId].CMEE_stat); | |
2391 return ATI_CMPL; | |
2392 } | |
2393 | |
2394 /* | |
2395 +--------------------------------------------------------------------+ | |
2396 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD | | |
2397 | STATE : code ROUTINE : atPlusGCAP | | |
2398 +--------------------------------------------------------------------+ | |
2399 | |
2400 PURPOSE : +GCAP command (capability information) | |
2401 */ | |
2402 GLOBAL T_ATI_RSLT atPlusGCAP(char *cl, UBYTE srcId) | |
2403 { | |
2404 if (*cl EQ '\0') | |
2405 { | |
2406 #ifdef FAX_AND_DATA | |
2407 | |
2408 #ifdef FF_FAX | |
2409 | |
2410 #ifdef V42BIS | |
2411 sprintf(g_sa,"+GCAP: +CGSM,+FCLASS,+DS"); | |
2412 #else | |
2413 sprintf(g_sa,"+GCAP: +CGSM,+FCLASS"); | |
2414 #endif | |
2415 | |
2416 #else /* no FAX */ | |
2417 | |
2418 #ifdef V42BIS | |
2419 sprintf(g_sa,"+GCAP: +CGSM,+DS"); | |
2420 #else | |
2421 sprintf(g_sa,"+GCAP: +CGSM"); | |
2422 #endif | |
2423 | |
2424 #endif /* FF_FAX */ | |
2425 | |
2426 #else /* Voice only */ | |
2427 | |
2428 sprintf(g_sa,"+GCAP: +CGSM"); | |
2429 | |
2430 #endif /* FAX_AND_DATA */ | |
2431 | |
2432 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT); | |
2433 return ATI_CMPL; | |
2434 } | |
2435 else | |
2436 { | |
2437 cmdAtError(atError); | |
2438 return ATI_FAIL; | |
2439 } | |
2440 } | |
2441 | |
2442 /* | |
2443 +--------------------------------------------------------------------+ | |
2444 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD | | |
2445 | STATE : code ROUTINE : atPercentCCBS | | |
2446 +--------------------------------------------------------------------+ | |
2447 | |
2448 PURPOSE : %CCBS command (Call Completion to Busy Subscriber) | |
2449 */ | |
2450 | |
2451 GLOBAL T_ATI_RSLT setatPercentCCBS(char *cl, UBYTE srcId) | |
2452 { | |
2453 SHORT mode = ACI_NumParmNotPresent; | |
2454 SHORT idx = ACI_NumParmNotPresent; | |
2455 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id); | |
2456 T_ACI_RETURN ret = AT_FAIL; | |
2457 | |
2458 TRACE_FUNCTION("setatPercentCCBS()"); | |
2459 | |
2460 cl = parse (cl,"rr",&mode,&idx); | |
2461 if(!cl OR (mode NEQ ACI_NumParmNotPresent AND (mode > 1 OR mode < 0))) | |
2462 { | |
2463 cmdCmeError (CME_ERR_OpNotAllow); | |
2464 return ATI_FAIL; | |
2465 } | |
2466 | |
2467 if( mode NEQ ACI_NumParmNotPresent ) | |
2468 at.flags.CCBS_stat=(UBYTE)mode; | |
2469 | |
2470 #ifdef FF_ATI_BAT | |
2471 | |
2472 if (idx NEQ ACI_NumParmNotPresent) | |
2473 { | |
2474 T_BAT_cmd_send cmd; | |
2475 T_BAT_cmd_set_percent_ccbs ccbs; | |
2476 | |
2477 cmd.ctrl_params=BAT_CMD_SET_PERCENT_CCBS; | |
2478 cmd.params.ptr_set_percent_ccbs=&ccbs; | |
2479 ccbs.idx=(T_BAT_percent_ccbs_idx)idx; | |
2480 bat_send(ati_bat_get_client(srcId), &cmd); | |
2481 return(ATI_EXCT); | |
2482 } | |
2483 else | |
2484 { | |
2485 return(ATI_CMPL); | |
2486 } | |
2487 | |
2488 #else /* no FF_ATI_BAT */ | |
2489 | |
2490 if( idx NEQ ACI_NumParmNotPresent ) | |
2491 { | |
2492 ret = sAT_PercentCCBS((T_ACI_CMD_SRC)srcId, idx); | |
2493 if( ret NEQ AT_EXCT ) | |
2494 { | |
2495 cmdCmeError(CME_ERR_Unknown); | |
2496 return ATI_FAIL; | |
2497 } | |
2498 src_params->curAtCmd = AT_CMD_CCBS; | |
2499 } | |
2500 else | |
2501 { | |
2502 ret = AT_CMPL; | |
2503 } | |
2504 return (map_aci_2_ati_rslt(ret)); | |
2505 | |
2506 #endif /* no FF_ATI_BAT */ | |
2507 } | |
2508 | |
2509 GLOBAL T_ATI_RSLT queatPercentCCBS(char *cl, UBYTE srcId) | |
2510 { | |
2511 T_ACI_RETURN ret = AT_FAIL; | |
2512 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id); | |
2513 | |
2514 TRACE_FUNCTION("queatPercentCCBS()"); | |
2515 | |
2516 ret = qAT_PercentCCBS((T_ACI_CMD_SRC)srcId); | |
2517 | |
2518 if( ret NEQ AT_EXCT ) | |
2519 { | |
2520 cmdCmeError(CME_ERR_Unknown); | |
2521 return ATI_FAIL; | |
2522 } | |
2523 src_params->curAtCmd = AT_CMD_CCBS; | |
2524 return (map_aci_2_ati_rslt(ret)); | |
2525 } | |
2526 | |
2527 | |
2528 /* | |
2529 +--------------------------------------------------------------------+ | |
2530 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD | | |
2531 | STATE : code ROUTINE : atPlusCMUX | | |
2532 +--------------------------------------------------------------------+ | |
2533 | |
2534 PURPOSE : +CMUX command (multiplexer) | |
2535 */ | |
2536 GLOBAL T_ATI_RSLT setatPlusCMUX (char *cl, UBYTE srcId) | |
2537 { | |
2538 T_ACI_RETURN ret = AT_FAIL; | |
2539 SHORT mode = ACI_NumParmNotPresent; | |
2540 SHORT subset = 0; /* default value */ | |
2541 UBYTE port_speed = NOT_PRESENT_8BIT; | |
2542 int N1 = 64; | |
2543 /* default value in advanced mode (other modes not supported */ | |
2544 SHORT T1 = 10; /* (100 ms) */ | |
2545 SHORT N2 = 3; | |
2546 SHORT T2 = 30; /* (30 ms) */ | |
2547 SHORT T3 = 10; /* (10 s) */ | |
2548 SHORT k = 2; | |
2549 | |
2550 TRACE_FUNCTION("setatPlusCMUX()"); | |
2551 | |
2552 cl = parse (cl,"rrrdrrrrr",&mode,&subset,&port_speed,&N1,&T1,&N2,&T2,&T3,&k); | |
2553 if (!cl) | |
2554 { | |
2555 cmdCmeError(CME_ERR_OpNotAllow); | |
2556 return ATI_FAIL; | |
2557 } | |
2558 | |
2559 #ifdef DTI | |
2560 /* values not supported */ | |
2561 if ( mode NEQ 1 | |
2562 OR subset NEQ 0 | |
2563 OR ((port_speed NEQ NOT_PRESENT_8BIT) | |
2564 AND (convert_mux_port_speed(port_speed) EQ BD_RATE_NotPresent)) | |
2565 OR N1 < 1 OR N1 > 32768 | |
2566 OR T1 < 1 OR T1 > 255 | |
2567 OR N2 < 0 OR N2 > 100 | |
2568 OR T2 < 2 OR T2 > 255 | |
2569 OR T3 < 1 OR T3 > 255 | |
2570 OR k < 1 OR k > 7 ) | |
2571 { | |
2572 TRACE_EVENT("at least one value is beyond capabilities"); | |
2573 cmdCmeError(CME_ERR_OpNotAllow); | |
2574 return ATI_FAIL; | |
2575 } | |
2576 | |
2577 #ifdef FF_ATI_BAT | |
2578 | |
2579 { | |
2580 T_BAT_cmd_send cmd; | |
2581 T_BAT_cmd_set_plus_cmux cmux; | |
2582 | |
2583 cmd.ctrl_params=BAT_CMD_SET_PLUS_CMUX; | |
2584 cmd.params.ptr_set_plus_cmux=&cmux; | |
2585 | |
2586 cmux.mode=(T_BAT_plus_cmux_mode)mode; | |
2587 cmux.subset=(T_BAT_plus_cmux_subset)subset; | |
2588 cmux.port_speed=(T_BAT_plus_cmux_port_speed)port_speed; | |
2589 cmux.n1=(U16)N1; | |
2590 cmux.t1=(U8)T1; | |
2591 cmux.n2=(U8)N2; | |
2592 cmux.t2=(U8)T2; | |
2593 cmux.t3=(U8)T3; | |
2594 cmux.k=(S16)k; | |
2595 | |
2596 bat_send(ati_bat_get_client(srcId), &cmd); | |
2597 return(ATI_EXCT); | |
2598 } | |
2599 | |
2600 #else /* no FF_ATI_BAT */ | |
2601 | |
2602 ret = sAT_PlusCMUX((T_ACI_CMD_SRC)srcId, | |
2603 (UBYTE)mode, | |
2604 (UBYTE)subset, | |
2605 port_speed, | |
2606 (USHORT)N1, | |
2607 (UBYTE)T1, | |
2608 (UBYTE)N2, | |
2609 (UBYTE)T2, | |
2610 (UBYTE)T3); | |
2611 | |
2612 #endif /* no FF_ATI_BAT */ | |
2613 | |
2614 #endif /* DTI */ | |
2615 | |
2616 if( ret EQ AT_FAIL ) | |
2617 { | |
2618 cmdCmeError(CME_ERR_Unknown); | |
2619 return ATI_FAIL; | |
2620 } | |
2621 return ATI_CMPL_NO_OUTPUT; | |
2622 } | |
2623 | |
2624 GLOBAL T_ATI_RSLT tesatPlusCMUX (char *cl, UBYTE srcId) | |
2625 { | |
2626 TRACE_FUNCTION("tesatPlusCMUX()"); | |
2627 | |
2628 sprintf(g_sa,"+CMUX: %s","(1),(0),(1-5),(10-100),(1-255),(0-100),(2-255),(1-255),(1-7)"); | |
2629 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT); | |
2630 | |
2631 io_sendConfirm(srcId, cmdAtError(atOk), ATI_NORMAL_OUTPUT); | |
2632 | |
2633 cmdErrStr = NULL; | |
2634 | |
2635 return ATI_CMPL_NO_OUTPUT; | |
2636 } | |
2637 | |
2638 GLOBAL T_ATI_RSLT queatPlusCMUX (char *cl, UBYTE srcId) | |
2639 { | |
2640 T_ACI_RETURN ret = AT_FAIL; | |
2641 UBYTE mode; | |
2642 UBYTE subset; | |
2643 UBYTE port_speed; | |
2644 USHORT N1; | |
2645 UBYTE T1; | |
2646 UBYTE N2; | |
2647 UBYTE T2; | |
2648 UBYTE T3; | |
2649 SHORT k = 2; | |
2650 | |
2651 TRACE_FUNCTION("queatPlusCMUX()"); | |
2652 | |
2653 #ifdef FF_ATI_BAT | |
2654 { | |
2655 T_BAT_cmd_send cmd; | |
2656 T_BAT_no_parameter dummy; | |
2657 | |
2658 cmd.ctrl_params = BAT_CMD_QUE_PLUS_CMUX; | |
2659 dummy.bat_dummy = 0xFF; | |
2660 cmd.params.ptr_que_plus_cmux = &dummy; | |
2661 bat_send(ati_bat_get_client(srcId), &cmd); | |
2662 return(ATI_EXCT); | |
2663 } | |
2664 #else /* no FF_ATI_BAT */ | |
2665 | |
2666 #ifdef DTI | |
2667 ret = qAT_PlusCMUX((T_ACI_CMD_SRC)srcId, | |
2668 &mode, | |
2669 &subset, | |
2670 &port_speed, | |
2671 &N1, | |
2672 &T1, | |
2673 &N2, | |
2674 &T2, | |
2675 &T3); | |
2676 if (ret EQ AT_CMPL) | |
2677 { | |
2678 sprintf(g_sa,"+CMUX: %d,%d,%d,%d,%d,%d,%d,%d,%d", mode, subset, port_speed, N1, T1, N2, T2, T3, k); | |
2679 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT); | |
2680 return ATI_CMPL; | |
2681 } | |
2682 else if (ret EQ AT_FAIL) | |
2683 { | |
2684 cmdCmeError(CME_ERR_Unknown); | |
2685 } | |
2686 #endif /* DTI */ | |
2687 return ATI_FAIL; | |
2688 | |
2689 #endif /* no FF_ATI_BAT */ | |
2690 } | |
2691 | |
2692 /* | |
2693 +--------------------------------------------------------------------+ | |
2694 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD | | |
2695 | STATE : code ROUTINE : atPlusIPR | | |
2696 +--------------------------------------------------------------------+ | |
2697 | |
2698 PURPOSE : +IPR command (DTE speed setting) | |
2699 */ | |
2700 | |
2701 GLOBAL T_ATI_RSLT setatPlusIPR(char *cl, UBYTE srcId) | |
2702 { | |
2703 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id); | |
2704 T_ACI_BD_RATE speed; | |
2705 char *end; | |
2706 | |
2707 src_params->curAtCmd = AT_CMD_IPR; | |
2708 | |
2709 switch ( strtol(cl, &end, 10) ) | |
2710 { | |
2711 case 0: speed = BD_RATE_AUTO; break; | |
2712 case 75: speed = BD_RATE_75; break; | |
2713 case 150: speed = BD_RATE_150; break; | |
2714 case 300: speed = BD_RATE_300; break; | |
2715 case 600: speed = BD_RATE_600; break; | |
2716 case 1200: speed = BD_RATE_1200; break; | |
2717 case 2400: speed = BD_RATE_2400; break; | |
2718 case 4800: speed = BD_RATE_4800; break; | |
2719 case 7200: speed = BD_RATE_7200; break; | |
2720 case 9600: speed = BD_RATE_9600; break; | |
2721 case 14400: speed = BD_RATE_14400; break; | |
2722 case 19200: speed = BD_RATE_19200; break; | |
2723 case 28800: speed = BD_RATE_28800; break; | |
2724 case 33900: speed = BD_RATE_33900; break; | |
2725 case 38400: speed = BD_RATE_38400; break; | |
2726 case 57600: speed = BD_RATE_57600; break; | |
2727 case 115200: speed = BD_RATE_115200; break; | |
2728 case 203125: speed = BD_RATE_203125; break; | |
2729 case 406250: speed = BD_RATE_406250; break; | |
2730 case 812500: speed = BD_RATE_812500; break; | |
2731 default: | |
2732 cmdCmeError(CME_ERR_OpNotSupp); | |
2733 return ATI_FAIL; | |
2734 } | |
2735 | |
2736 #ifdef FF_ATI_BAT | |
2737 { | |
2738 T_BAT_cmd_send cmd; | |
2739 T_BAT_cmd_set_plus_ipr my_bat_set_plus_ipr; | |
2740 | |
2741 TRACE_FUNCTION("setatPlusIPR() calls bat_send() <=== as APPLICATION"); | |
2742 | |
2743 memset(&my_bat_set_plus_ipr, 0, sizeof(my_bat_set_plus_ipr)); | |
2744 cmd.ctrl_params = BAT_CMD_SET_PLUS_IPR; | |
2745 cmd.params.ptr_set_plus_ipr = &my_bat_set_plus_ipr; | |
2746 | |
2747 my_bat_set_plus_ipr.rate = (T_BAT_plus_ipr_rate)speed; | |
2748 | |
2749 bat_send(ati_bat_get_client(srcId), &cmd); | |
2750 | |
2751 return ATI_EXCT; /* executing, because response is passed by callback function */ | |
2752 } | |
2753 #else /* OLD FUNCTION BODY */ | |
2754 | |
2755 TRACE_FUNCTION("setatPlusIPR()"); | |
2756 | |
2757 #ifdef UART | |
2758 | |
2759 if(!end) | |
2760 { | |
2761 cmdCmeError(CME_ERR_OpNotSupp); | |
2762 return ATI_FAIL; | |
2763 } | |
2764 | |
2765 switch ( sAT_PlusIPR((T_ACI_CMD_SRC)srcId, speed) ) | |
2766 { | |
2767 case (AT_CMPL): /* operation completed */ | |
2768 return ATI_CMPL_NO_OUTPUT; /* OK was already sent at old baudrate by sAT_PlusIPR, | |
2769 so must not be sent twice! */ | |
2770 default: | |
2771 cmdCmeError(CME_ERR_NotPresent); | |
2772 return ATI_FAIL; | |
2773 } | |
2774 #else | |
2775 cmdCmeError(CME_ERR_NotPresent); | |
2776 return ATI_FAIL; | |
2777 | |
2778 #endif /* UART */ | |
2779 | |
2780 #endif /* no FF_ATI_BAT*/ | |
2781 } | |
2782 | |
2783 GLOBAL T_ATI_RSLT queatPlusIPR(char *cl, UBYTE srcId) | |
2784 { | |
2785 T_ACI_BD_RATE rate; | |
2786 int rate_value; | |
2787 | |
2788 TRACE_FUNCTION("queatPlusIPR()"); | |
2789 #ifdef DTI | |
2790 if ( AT_CMPL EQ qAT_PlusIPR((T_ACI_CMD_SRC)srcId, &rate) ) | |
2791 { | |
2792 switch ( rate ) | |
2793 { | |
2794 case BD_RATE_AUTO: rate_value = 0; break; | |
2795 case BD_RATE_75: rate_value = 75; break; | |
2796 case BD_RATE_150: rate_value = 150; break; | |
2797 case BD_RATE_300: rate_value = 300; break; | |
2798 case BD_RATE_600: rate_value = 600; break; | |
2799 case BD_RATE_1200: rate_value = 1200; break; | |
2800 case BD_RATE_2400: rate_value = 2400; break; | |
2801 case BD_RATE_4800: rate_value = 4800; break; | |
2802 case BD_RATE_7200: rate_value = 7200; break; | |
2803 case BD_RATE_9600: rate_value = 9600; break; | |
2804 case BD_RATE_14400: rate_value = 14400; break; | |
2805 case BD_RATE_19200: rate_value = 19200; break; | |
2806 case BD_RATE_28800: rate_value = 28800; break; | |
2807 case BD_RATE_33900: rate_value = 33900; break; | |
2808 case BD_RATE_38400: rate_value = 38400; break; | |
2809 case BD_RATE_57600: rate_value = 57600; break; | |
2810 case BD_RATE_115200: rate_value = 115200; break; | |
2811 case BD_RATE_203125: rate_value = 203125; break; | |
2812 case BD_RATE_406250: rate_value = 406250; break; | |
2813 case BD_RATE_812500: rate_value = 812500; break; | |
2814 default: rate_value = 0; break; | |
2815 } | |
2816 | |
2817 sprintf(g_sa,"+IPR: %d", rate_value); | |
2818 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT); | |
2819 return ATI_CMPL; | |
2820 } | |
2821 #endif | |
2822 cmdAtError(atError); | |
2823 return(ATI_FAIL); | |
2824 } | |
2825 /* | |
2826 +--------------------------------------------------------------------+ | |
2827 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD | | |
2828 | STATE : code ROUTINE : atPlusICF | | |
2829 +--------------------------------------------------------------------+ | |
2830 | |
2831 PURPOSE : +ICF command (DTE character frame setting) | |
2832 */ | |
2833 | |
2834 GLOBAL T_ATI_RSLT setatPlusICF(char *cl, UBYTE srcId) | |
2835 { | |
2836 T_ACI_BS_FRM format = BS_FRM_NotPresent; | |
2837 T_ACI_BS_PAR parity = BS_PAR_NotPresent; | |
2838 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id); | |
2839 | |
2840 TRACE_FUNCTION("setatPlusICF()"); | |
2841 | |
2842 cl=parse(cl,"dd",&format,&parity); | |
2843 | |
2844 if(!cl) | |
2845 { | |
2846 cmdAtError(atError); | |
2847 return ATI_FAIL; | |
2848 } | |
2849 #ifdef DTI | |
2850 | |
2851 #ifdef FF_ATI_BAT | |
2852 | |
2853 { | |
2854 T_BAT_cmd_send cmd; | |
2855 T_BAT_cmd_set_plus_icf icf; | |
2856 | |
2857 cmd.ctrl_params=BAT_CMD_SET_PLUS_ICF; | |
2858 cmd.params.ptr_set_plus_icf=&icf; | |
2859 | |
2860 /* | |
2861 * This relies on T_ACI_BS_FRM being identical to | |
2862 * T_BAT_framing_format and T_ACI_BS_PAR being identical | |
2863 * to T_BAT_framing_parity. | |
2864 */ | |
2865 icf.framing_format=(T_BAT_framing_format)format; | |
2866 icf.framing_parity=(T_BAT_framing_parity)parity; | |
2867 | |
2868 bat_send(ati_bat_get_client(srcId), &cmd); | |
2869 } | |
2870 | |
2871 src_params->curAtCmd=AT_CMD_ICF; | |
2872 | |
2873 return(ATI_EXCT); | |
2874 | |
2875 #else /* no FF_ATI_BAT */ | |
2876 | |
2877 switch ( sAT_PlusICF((T_ACI_CMD_SRC)srcId, format, parity) ) | |
2878 { | |
2879 case (AT_CMPL): /*operation completed*/ | |
2880 return ATI_CMPL; | |
2881 case (AT_EXCT): | |
2882 src_params->curAtCmd = AT_CMD_ICF; | |
2883 return ATI_EXCT; | |
2884 default: | |
2885 cmdAtError(atError); /*Command failed*/ | |
2886 return ATI_FAIL; | |
2887 } | |
2888 | |
2889 #endif /* no FF_ATI_BAT */ | |
2890 | |
2891 #else | |
2892 cmdAtError(atError); /*Command failed*/ | |
2893 return ATI_FAIL; | |
2894 #endif | |
2895 } | |
2896 | |
2897 GLOBAL T_ATI_RSLT queatPlusICF(char *cl, UBYTE srcId) | |
2898 { | |
2899 #ifndef FF_ATI_BAT | |
2900 T_ACI_BS_FRM format; | |
2901 T_ACI_BS_PAR parity; | |
2902 #endif | |
2903 | |
2904 TRACE_FUNCTION("queatPlusICF()"); | |
2905 | |
2906 #ifdef DTI | |
2907 | |
2908 #ifdef FF_ATI_BAT | |
2909 { | |
2910 T_BAT_cmd_send cmd; | |
2911 T_BAT_no_parameter dummy; | |
2912 | |
2913 cmd.ctrl_params = BAT_CMD_QUE_PLUS_ICF; | |
2914 dummy.bat_dummy = 0xFF; | |
2915 cmd.params.ptr_que_plus_icf = &dummy; | |
2916 bat_send(ati_bat_get_client(srcId), &cmd); | |
2917 return(ATI_EXCT); | |
2918 } | |
2919 #else /* no FF_ATI_BAT */ | |
2920 | |
2921 switch ( qAT_PlusICF((T_ACI_CMD_SRC)srcId,&format,&parity) ) | |
2922 { | |
2923 case AT_CMPL: | |
2924 if (format EQ BS_FRM_Dat8_Par1_St1 OR format EQ BS_FRM_Dat7_Par1_St1 ) | |
2925 { | |
2926 resp_disp(srcId, cl,"ee",&format,&parity); | |
2927 } | |
2928 else | |
2929 { | |
2930 resp_disp(srcId, cl,"e",&format); | |
2931 } | |
2932 return ATI_CMPL; | |
2933 } | |
2934 | |
2935 #endif /* no FF_ATI_BAT */ | |
2936 | |
2937 #endif /* DTI */ | |
2938 cmdAtError(atError); | |
2939 return ATI_FAIL; | |
2940 } | |
2941 | |
2942 GLOBAL T_ATI_RSLT setflowCntr(CHAR* cl, UBYTE srcId) | |
2943 { | |
2944 T_ACI_RX_FLOW_CTRL DCE_by_DTE = RX_FLOW_NotPresent; /* by TE: Rx flow control */ | |
2945 T_ACI_RX_FLOW_CTRL DTE_by_DCE = RX_FLOW_NotPresent; /* by TA: Tx flow control */ | |
2946 | |
2947 cl = parse (cl,"dd",&DCE_by_DTE,&DTE_by_DCE); | |
2948 | |
2949 if(!cl) | |
2950 { | |
2951 cmdAtError(atError); | |
2952 return ATI_FAIL; | |
2953 } | |
2954 | |
2955 #ifdef DTI | |
2956 switch ( sAT_PlusIFC((T_ACI_CMD_SRC)srcId, DCE_by_DTE, DTE_by_DCE) ) | |
2957 { | |
2958 case (AT_CMPL): /*operation completed*/ | |
2959 return ATI_CMPL; | |
2960 case (AT_EXCT): | |
2961 /* ATTENTION: no setting of 'curAtCmd' allowed because the value is set before */ | |
2962 return ATI_EXCT; | |
2963 default: | |
2964 cmdAtError(atError); /*Command failed*/ | |
2965 return ATI_FAIL; | |
2966 } | |
2967 #else | |
2968 cmdAtError(atError); /*Command failed*/ | |
2969 return ATI_FAIL; | |
2970 #endif | |
2971 } | |
2972 | |
2973 /* | |
2974 +--------------------------------------------------------------------+ | |
2975 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD | | |
2976 | STATE : code ROUTINE : atPlusIFC | | |
2977 +--------------------------------------------------------------------+ | |
2978 | |
2979 PURPOSE : +IFC command (DTE DCE / DCE DTE flow control) | |
2980 */ | |
2981 | |
2982 GLOBAL T_ATI_RSLT setatPlusIFC(char *cl, UBYTE srcId) | |
2983 { | |
2984 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id); | |
2985 TRACE_FUNCTION("setatPlusIFC()"); | |
2986 | |
2987 src_params->curAtCmd = AT_CMD_IFC; | |
2988 return setflowCntr(cl, srcId); | |
2989 } | |
2990 | |
2991 | |
2992 GLOBAL T_ATI_RSLT queflowCntr(CHAR* cl, UBYTE srcId) | |
2993 { | |
2994 T_ACI_RX_FLOW_CTRL DCE_by_DTE; | |
2995 T_ACI_RX_FLOW_CTRL DTE_by_DCE; | |
2996 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id); | |
2997 | |
2998 #ifdef DTI | |
2999 if ( AT_CMPL EQ qAT_PlusIFC((T_ACI_CMD_SRC)srcId,&DCE_by_DTE,&DTE_by_DCE) ) | |
3000 { | |
3001 #ifdef FF_FAX | |
3002 if (src_params->curAtCmd EQ AT_CMD_FLO) | |
3003 { | |
3004 sprintf(g_sa,"+FLO: %d",DCE_by_DTE); | |
3005 } | |
3006 else | |
3007 #endif | |
3008 if (src_params->curAtCmd EQ AT_CMD_IFC) | |
3009 { | |
3010 sprintf(g_sa,"+IFC: %d,%d",DCE_by_DTE,DTE_by_DCE); | |
3011 } | |
3012 | |
3013 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT); | |
3014 return ATI_CMPL; | |
3015 } | |
3016 else | |
3017 { | |
3018 cmdAtError(atError); | |
3019 return ATI_FAIL; | |
3020 } | |
3021 #else | |
3022 cmdAtError(atError); | |
3023 return ATI_FAIL; | |
3024 #endif | |
3025 } | |
3026 | |
3027 /* | |
3028 +--------------------------------------------------------------------+ | |
3029 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD | | |
3030 | STATE : code ROUTINE : atPlusIFC | | |
3031 +--------------------------------------------------------------------+ | |
3032 | |
3033 PURPOSE : +IFC command (DTE DCE / DCE DTE flow control) | |
3034 */ | |
3035 | |
3036 GLOBAL T_ATI_RSLT queatPlusIFC(char *cl, UBYTE srcId) | |
3037 { | |
3038 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id); | |
3039 TRACE_FUNCTION("queatPlusIFC()"); | |
3040 | |
3041 src_params->curAtCmd = AT_CMD_IFC; | |
3042 return queflowCntr(cl, srcId); | |
3043 } | |
3044 | |
3045 /* | |
3046 +--------------------------------------------------------------------+ | |
3047 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD | | |
3048 | STATE : code ROUTINE : atPlusILRR | | |
3049 +--------------------------------------------------------------------+ | |
3050 | |
3051 PURPOSE : +ILRR command (display +ILRR setting) | |
3052 */ | |
3053 | |
3054 GLOBAL T_ATI_RSLT setatPlusILRR(char *cl, UBYTE srcId) | |
3055 { | |
3056 SHORT val=-1; | |
3057 | |
3058 TRACE_FUNCTION("setatPLusILRR()"); | |
3059 | |
3060 cl = parse (cl,"r",&val); | |
3061 if(!cl OR val > 1 OR val < 0) | |
3062 { | |
3063 cmdAtError(atError); | |
3064 return ATI_FAIL; | |
3065 } | |
3066 ati_user_output_cfg[srcId].ILRR_stat=(UBYTE)val; | |
3067 return ATI_CMPL; | |
3068 } | |
3069 | |
3070 GLOBAL T_ATI_RSLT queatPlusILRR(char *cl, UBYTE srcId) | |
3071 { | |
3072 TRACE_FUNCTION("queatPLusILRR()"); | |
3073 | |
3074 resp_disp(srcId, cl,"b",&ati_user_output_cfg[srcId].ILRR_stat); | |
3075 return ATI_CMPL; | |
3076 } | |
3077 | |
3078 /* | |
3079 +--------------------------------------------------------------------+ | |
3080 | PROJECT : MODULE : ACI_CMD | | |
3081 | STATE : code ROUTINE : setatPlusCCLK | | |
3082 +--------------------------------------------------------------------+ | |
3083 | |
3084 PURPOSE : +CCLK command (Set the real time clock of the MT) | |
3085 */ | |
3086 GLOBAL T_ATI_RSLT setatPlusCCLK (char *cl, UBYTE srcId) | |
3087 { | |
3088 T_ACI_RETURN ret = AT_FAIL; | |
3089 T_ACI_RTC_DATE date_s; | |
3090 T_ACI_RTC_TIME time_s; | |
3091 char date_time_string[DATE_TIME_LENGTH+1]={0}; | |
3092 int items_conv = 0; | |
3093 U8 days = 0, months = 0; | |
3094 U8 hrs = 0, mins = 0, secs = 0; | |
3095 U8 years = 0; | |
3096 U8 tz = 0; /* to parse timezone from date_time_string */ | |
3097 SHORT timeZone = 0; | |
3098 char sign = '+'; | |
3099 | |
3100 TRACE_FUNCTION("setatPlusCCLK()"); | |
3101 | |
3102 cl=parse(cl,"s", DATE_TIME_LENGTH, date_time_string); | |
3103 | |
3104 /* Expected format: yy/MM/dd,hh:mm:ss+zz (20 bytes). DATE_TIME_LENGTH(22 bytes) | |
3105 * allows length for yyyy/MM/dd,hh:mm:ss+zz */ | |
3106 if(!cl OR strlen(date_time_string) NEQ DATE_TIME_LENGTH-2) | |
3107 { | |
3108 cmdCmeError(CME_ERR_OpNotAllow); | |
3109 return (ATI_FAIL); | |
3110 } | |
3111 | |
3112 TRACE_EVENT_P1("Date and time are: %s",date_time_string); | |
3113 items_conv = parseTimeStamp( date_time_string, &years,&months,&days,&hrs,&mins,&secs,&sign,&tz); | |
3114 | |
3115 timeZone = tz; | |
3116 | |
3117 if (sign EQ '-') | |
3118 { | |
3119 timeZone = timeZone * (-1); | |
3120 } | |
3121 | |
3122 TRACE_EVENT_P1("items_conv %d",items_conv); | |
3123 TRACE_EVENT_P1("days %d",days); | |
3124 TRACE_EVENT_P1("months %d",months); | |
3125 TRACE_EVENT_P1("years %d",years); | |
3126 TRACE_EVENT_P1("hours %d",hrs); | |
3127 TRACE_EVENT_P1("mins %d",mins); | |
3128 TRACE_EVENT_P1("secs %d",secs); | |
3129 TRACE_EVENT_P1("sign %c",sign); | |
3130 TRACE_EVENT_P1("timeZone %d",timeZone); | |
3131 | |
3132 | |
3133 /* If 8 data items not extracted from date_time_string then date_time_string data with TZ info is incorrect. */ | |
3134 if ( items_conv NEQ MAX_TIME_STAMP_FIELDS ) | |
3135 { | |
3136 cmdCmeError(CME_ERR_OpNotAllow); | |
3137 return (ATI_FAIL); | |
3138 } | |
3139 | |
3140 #ifndef _SIMULATION_ | |
3141 /* Ensure 'years' passed in from the AT command is not in 4 digit format | |
3142 The spec requires the years to be passed in in 2 digit format | |
3143 Also ensure the sign char is either a '+' or '-' */ | |
3144 if ( (years > 99 ) OR | |
3145 ((sign NEQ '-') AND (sign NEQ '+')) OR | |
3146 ( timeZone < (-48)) OR (timeZone > 48) | |
3147 ) | |
3148 { | |
3149 cmdCmeError(CME_ERR_OpNotAllow); | |
3150 return (ATI_FAIL); | |
3151 } | |
3152 #else /* _SIMULATION_ */ | |
3153 /* On the target code these checks are done in the RTC code. In the simulation code- | |
3154 the RTC routines are not used so these checks have to be done. */ | |
3155 if ( (years < 0) OR (years > 99) | |
3156 OR (months < 1) OR (months > 12) | |
3157 OR (days < 1) OR (days > 31) | |
3158 OR (hrs < 0) OR (hrs > 23) | |
3159 OR (mins < 0) OR (mins > 59) | |
3160 OR (secs < 0) OR (secs > 59) | |
3161 OR (timeZone < (-48)) OR (timeZone > 48) | |
3162 ) | |
3163 { | |
3164 cmdCmeError(CME_ERR_OpNotAllow); | |
3165 return (ATI_FAIL); | |
3166 } | |
3167 #endif /* _SIMULATION_ */ | |
3168 | |
3169 | |
3170 /* Populate date time structs */ | |
3171 date_s.day = days; | |
3172 date_s.month = months; | |
3173 date_s.year = years + 2000; /* Convert years to 4 digit format for passing to lower layer RTC function */ | |
3174 time_s.hour = hrs; | |
3175 time_s.minute = mins; | |
3176 time_s.PM_flag = 0; | |
3177 time_s.second = secs; | |
3178 time_s.format = TIME_FORMAT_24HOUR; | |
3179 | |
3180 /* Pass separated date and time and timezone info to set the clock */ | |
3181 | |
3182 #ifdef FF_ATI_BAT | |
3183 | |
3184 { | |
3185 T_BAT_cmd_send cmd; | |
3186 T_BAT_cmd_set_plus_cclk cclk; | |
3187 | |
3188 cmd.ctrl_params=BAT_CMD_SET_PLUS_CCLK; | |
3189 cmd.params.ptr_set_plus_cclk=&cclk; | |
3190 | |
3191 cclk.year=(U8)date_s.year; | |
3192 cclk.month=(U8)date_s.month; | |
3193 cclk.day=(U8)date_s.day; | |
3194 | |
3195 cclk.hour=(U8)time_s.hour; | |
3196 | |
3197 cclk.minutes=(U8)time_s.minute; | |
3198 cclk.seconds=(U8)time_s.second; | |
3199 | |
3200 cclk.time_zone=(S8)timeZone; | |
3201 | |
3202 bat_send(ati_bat_get_client(srcId), &cmd); | |
3203 } | |
3204 | |
3205 return(ATI_EXCT); | |
3206 | |
3207 #else /* no FF_ATI_BAT */ | |
3208 | |
3209 ret = sAT_PlusCCLK ( (T_ACI_CMD_SRC)srcId, &date_s, &time_s, timeZone); | |
3210 | |
3211 TRACE_EVENT_P1("sAT_PlusCCLK ret = %d", ret); | |
3212 | |
3213 /* Deal with return value */ | |
3214 | |
3215 switch (ret) | |
3216 { | |
3217 case (AT_CMPL): /*operation completed*/ | |
3218 break; | |
3219 | |
3220 default: | |
3221 cmdCmeError(CME_ERR_Unknown); /*Command failed*/ | |
3222 break; | |
3223 } | |
3224 return (map_aci_2_ati_rslt(ret)); | |
3225 | |
3226 #endif /* no FF_ATI_BAT */ | |
3227 } | |
3228 | |
3229 /* | |
3230 +--------------------------------------------------------------------+ | |
3231 | PROJECT : MODULE : ACI_CMD | | |
3232 | STATE : code ROUTINE : queatPlusCCLK | | |
3233 +--------------------------------------------------------------------+ | |
3234 | |
3235 PURPOSE : +CCLK query command (Read the real time clock of the MT) | |
3236 */ | |
3237 GLOBAL T_ATI_RSLT queatPlusCCLK (char *cl, UBYTE srcId) | |
3238 { | |
3239 #ifndef FF_ATI_BAT | |
3240 T_ACI_RETURN ret = AT_FAIL; | |
3241 T_ACI_RTC_DATE date_s; /* Structures to obtain date time info */ | |
3242 T_ACI_RTC_TIME time_s; | |
3243 UBYTE days, months; | |
3244 UBYTE hrs, mins, secs; | |
3245 USHORT years; | |
3246 #if defined FF_TIMEZONE OR defined _SIMULATION_ | |
3247 char sign ; | |
3248 #endif /* defined FF_TIMEZONE OR defined _SIMULATION_ */ | |
3249 int tz ; | |
3250 char *me="+CCLK: "; | |
3251 #endif | |
3252 | |
3253 | |
3254 TRACE_FUNCTION("queatPlusCCLK()"); | |
3255 | |
3256 #ifdef FF_ATI_BAT | |
3257 { | |
3258 T_BAT_cmd_send cmd; | |
3259 T_BAT_no_parameter dummy; | |
3260 | |
3261 cmd.ctrl_params=BAT_CMD_QUE_PLUS_CCLK; | |
3262 dummy.bat_dummy = 0xFF; | |
3263 cmd.params.ptr_que_plus_cclk = &dummy; | |
3264 bat_send(ati_bat_get_client(srcId), &cmd); | |
3265 return(ATI_EXCT); | |
3266 } | |
3267 #else /* no FF_ATI_BAT */ | |
3268 | |
3269 ret = qAT_PlusCCLK( (T_ACI_CMD_SRC)srcId, &date_s, &time_s, &tz); | |
3270 | |
3271 if (ret EQ AT_CMPL) | |
3272 { | |
3273 /* Command completed successfully */ | |
3274 /* convert time date struct data into string */ | |
3275 days = date_s.day; | |
3276 months = date_s.month; | |
3277 years = date_s.year; | |
3278 hrs = time_s.hour; | |
3279 mins = time_s.minute; | |
3280 secs = time_s.second; | |
3281 | |
3282 #ifndef _SIMULATION_ | |
3283 #ifdef FF_TIMEZONE | |
3284 if ( tz < 0) | |
3285 { | |
3286 sign = '-'; | |
3287 tz = tz * (-1); | |
3288 } | |
3289 else | |
3290 sign = '+'; | |
3291 #endif /* FF_TIMEZONE */ | |
3292 #else /* _SIMULATION_ */ | |
3293 sign = '-'; | |
3294 tz = tz * (-1); | |
3295 #endif /* _SIMULATION_ */ | |
3296 | |
3297 /* Convert years to 2 digit format for reporting back to user */ | |
3298 years = years - 2000; /* Subtract 2000 years from number returned */ | |
3299 | |
3300 TRACE_EVENT_P3("Date -> %d - %d - %d",days,months,years); | |
3301 TRACE_EVENT_P3("Time -> %d - %d - %d",hrs,mins,secs); | |
3302 /* Not using time_s.format or time_s.PM_flag */ | |
3303 | |
3304 /* CONVERT DATE TIME INFO INTO STRING FOR OUTPUTTING BACK TO DISPLAY */ | |
3305 | |
3306 #ifndef _SIMULATION_ | |
3307 | |
3308 #ifndef FF_TIMEZONE | |
3309 sprintf(g_sa, "%s\"%d/%d/%d,%d:%d:%d\"", me, years, months, days, hrs, mins, secs); | |
3310 #else /* FF_TIMEZONE */ | |
3311 TRACE_EVENT_P2("TimeZone -> %c%d", sign, tz); | |
3312 sprintf(g_sa, "%s\"%d/%d/%d,%d:%d:%d%c%d\"", me, years, months, days, hrs, mins, secs, sign, tz); | |
3313 #endif /* FF_TIMEZONE */ | |
3314 | |
3315 #else /* _SIMULATION_ */ | |
3316 TRACE_EVENT_P2("TimeZone -> %c%d", sign, tz); | |
3317 sprintf(g_sa, "%s\"%d/%d/%d,%d:%d:%d%c%d\"", me, years, months, days, hrs, mins, secs, sign, tz); | |
3318 #endif /* _SIMULATION_ */ | |
3319 | |
3320 /* REPORT DATE TIME INFO STRING */ | |
3321 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT); | |
3322 | |
3323 return ATI_CMPL; | |
3324 } | |
3325 else | |
3326 { | |
3327 cmdCmeError(CME_ERR_Unknown); | |
3328 return ATI_FAIL; | |
3329 } | |
3330 | |
3331 #endif /* no FF_ATI_BAT */ | |
3332 | |
3333 } | |
3334 #endif /* ATI_BAS_C */ | |
3335 | |
3336 |