comparison src/g23m-aci/aci/ati_sim.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
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: SIM related functions.
18 +-----------------------------------------------------------------------------
19 */
20
21 #ifndef ATI_SIM_C
22 #define ATI_SIM_C
23
24 #undef DUMMY_ATI_STRINGS
25
26 #include "aci_all.h"
27
28 #include "aci_cmh.h"
29 #include "ati_cmd.h"
30 #include "aci_io.h"
31 #include "aci_cmd.h"
32 #include "l4_tim.h"
33
34 #include "gdi.h"
35 #include "audio.h"
36
37 #include "aci_mem.h"
38 #include "aci_ext_pers.h"
39 #include "aci_slock.h"
40 #include "aci_prs.h"
41 #include "aci_lst.h"
42 #include "ati_int.h"
43
44 #ifdef FF_ATI_BAT
45
46 #include "typedefs.h"
47 #include "gdd.h"
48 #include "bat.h"
49
50 #include "ati_bat.h"
51
52 #endif /* FF_ATI_BAT */
53
54 /*==== EXPORT ==================================================*/
55
56 EXTERN CHAR *cmdExtError (T_ACI_EXT_ERR e);
57
58 #ifdef TI_PS_FF_AT_P_CMD_SECP
59 /*
60 +--------------------------------------------------------------------+
61 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
62 | STATE : code ROUTINE : setatPercentSECP |
63 +--------------------------------------------------------------------+
64
65 PURPOSE : %SECP command (PIN functionality for MMI Security)
66 */
67
68 GLOBAL T_ATI_RSLT setatPercentSECP(CHAR * cl, UBYTE srcId)
69 {
70 char pinOld [MAX_PWD_LENGTH]={0};
71 char pinNew [MAX_PWD_LENGTH]={0};
72 T_ACI_RETURN ret = AT_FAIL;
73
74 TRACE_FUNCTION ("setatPercentSECP()");
75
76 cl = parse(cl, "nn", (LONG)MAX_PWD_LENGTH, pinOld,(LONG)MAX_PWD_LENGTH, pinNew);
77 if ( !cl OR (*pinOld EQ '\0' AND *pinNew EQ '\0') )
78 {
79 cmdCmeError(CME_ERR_OpNotAllow);
80 return ATI_FAIL;
81 }
82
83 ret = sAT_PercentSECP((T_ACI_CMD_SRC)srcId, pinOld, pinNew);
84
85 return (map_aci_2_ati_rslt(ret));
86 }
87 #endif /* TI_PS_FF_AT_P_CMD_SECP */
88
89 #ifdef TI_PS_FF_AT_P_CMD_SECS
90 /*
91 +--------------------------------------------------------------------+
92 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
93 | STATE : code ROUTINE : setatPercentSECS |
94 +--------------------------------------------------------------------+
95
96 PURPOSE : %SECS command (This function changes the state of the MMI Security code
97 It requires the existing security code as one of the parameters)
98 */
99
100
101 GLOBAL T_ATI_RSLT setatPercentSECS (CHAR *cl, UBYTE srcId)
102 {
103 char code [MAX_PWD_LENGTH]={0};
104 T_ACI_SECS_STA securityState = SECS_STA_NotPresent;
105 T_ACI_RETURN ret = AT_FAIL;
106
107
108 TRACE_FUNCTION ("setatPercentSECS()");
109
110 /* Get the required state and the Security code from the command parameters*/
111 cl = parse(cl, "dn", &securityState, (LONG)MAX_PWD_LENGTH, code);
112
113 if ( !cl OR *code EQ '\0' )
114 {
115 cmdCmeError(CME_ERR_OpNotAllow);
116 return ATI_FAIL;
117 }
118
119 ret = sAT_PercentSECS((T_ACI_CMD_SRC)srcId,securityState,code);
120 return (map_aci_2_ati_rslt(ret));
121
122
123 }
124
125
126 /*
127 +--------------------------------------------------------------------+
128 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
129 | STATE : code ROUTINE : qetatPercentSECS |
130 +--------------------------------------------------------------------+
131
132 PURPOSE : %SECS? command (It queries the state of the MMI Security code)
133 */
134
135
136 GLOBAL T_ATI_RSLT quetatPercentSECS (CHAR *cl, UBYTE srcId)
137 {
138 T_ACI_SECS_STA securityState = SECS_STA_NotPresent;
139 T_ACI_RETURN ret = AT_FAIL;
140
141
142 TRACE_FUNCTION ("qetatPercentSECS()");
143
144 /* Get the State value from the Command Handler */
145 ret = qAT_PercentSECS((T_ACI_CMD_SRC)srcId, &securityState);
146
147 if (ret EQ AT_CMPL)
148 {
149 resp_disp(srcId, cl,"e",&securityState);
150 return ATI_CMPL;
151 }
152 else
153 {
154 cmdCmeError(CME_ERR_Unknown);
155 return ATI_FAIL;
156 }
157
158
159 }
160 #endif /* TI_PS_FF_AT_P_CMD_SECS */
161
162
163 GLOBAL CHAR *CPIN_RESULT(T_ACI_CPIN_RSLT code)
164 {
165 switch (code)
166 {
167 default:
168 case(CPIN_RSLT_NotPresent): return"not present";
169 case(CPIN_RSLT_SimReady): return"READY";
170 case(CPIN_RSLT_SimPinReq): return"SIM PIN";
171 case(CPIN_RSLT_SimPukReq): return"SIM PUK";
172 case(CPIN_RSLT_PhSimPinReq):return"PH-SIM PIN";
173 case(CPIN_RSLT_SimPin2Req): return"SIM PIN2";
174 case(CPIN_RSLT_SimPuk2Req): return"SIM PUK2";
175 /* OVK: Extended list of all possible result according to 07.07 */
176 case(CPIN_RSLT_PhFSimPinReq): return"PH-FSIM PIN";
177 case(CPIN_RSLT_PhFSimPukReq): return"PH-FSIM PUK";
178 case(CPIN_RSLT_PhNetPinReq): return"PH-NET PIN";
179 case(CPIN_RSLT_PhNetPukReq): return"PH_NET PUK";
180 case(CPIN_RSLT_PhNetSubPinReq): return"PH-NETSUB PIN";
181 case(CPIN_RSLT_PhNetSubPukReq): return"PH-NETSUB PUK";
182 case(CPIN_RSLT_PhSPPinReq): return"PH-SP PIN";
183 case(CPIN_RSLT_PhSPPukReq): return"PH-SP PUK";
184 case(CPIN_RSLT_PhCorpPinReq): return"PH-CORP PIN";
185 case(CPIN_RSLT_PhCorpPukReq): return"PH-CORP PUK";
186
187
188 }
189 }
190
191 /*
192 +--------------------------------------------------------------------+
193 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
194 | STATE : code ROUTINE : atPlusCPIN |
195 +--------------------------------------------------------------------+
196
197 PURPOSE : +CPIN command (PIN functionality of ME)
198 */
199
200 GLOBAL T_ATI_RSLT setatPlusCPIN (char *cl, UBYTE srcId)
201 {
202 char pinOld [MAX_PWD_LENGTH]={0}; /* ES!! enough for bad guys?*/
203 char pinNew [MAX_PWD_LENGTH]={0};
204 T_ACI_RETURN ret = AT_FAIL;
205 UBYTE slockBlocked = 0; /* @GBR: AT_CMPL is interpreted as error per default. This is wrong, if the ME is SIMLOCKed */
206
207 TRACE_FUNCTION ("setatPlusCPIN()");
208
209 cl = parse(cl,"nn",(LONG)MAX_PWD_LENGTH,&pinOld,(LONG)MAX_PWD_LENGTH,&pinNew);
210 if ( !cl OR *pinOld EQ '\0' )
211 {
212 cmdCmeError(CME_ERR_OpNotAllow);
213 return ATI_FAIL;
214 }
215 #ifdef SIM_PERS
216 slockBlocked = AciSLockShrd.blocked;
217 #endif
218 #ifdef FF_ATI_BAT
219 {
220 T_BAT_cmd_send cmd;
221 T_BAT_cmd_set_plus_cpin my_bat_set_plus_cpin = {0};
222 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
223
224 TRACE_FUNCTION("setatPlusCPIN() calls bat_send() <=== as APPLICATION");
225
226 /* memset(&my_bat_set_plus_cpin, FALSE, sizeof(my_bat_set_plus_cpin)); Already initilaised */
227 cmd.ctrl_params = BAT_CMD_SET_PLUS_CPIN;
228 cmd.params.ptr_set_plus_cpin = &my_bat_set_plus_cpin;
229
230 /* Set old pin BAT attribs */
231 my_bat_set_plus_cpin.c_pin = strlen(pinOld);
232 memcpy(my_bat_set_plus_cpin.pin, pinOld, BAT_MAX_CPIN_PIN_LEN);
233
234 /* Set new pin BAT attribs */
235 if(my_bat_set_plus_cpin.c_newpin = strlen(pinNew))
236 {
237 my_bat_set_plus_cpin.v_newpin = TRUE;
238 memcpy(my_bat_set_plus_cpin.pin, pinNew, BAT_MAX_CPIN_PIN_LEN);
239 }
240
241 src_params->curAtCmd = AT_CMD_CPIN;
242
243 bat_send(ati_bat_get_client(srcId), &cmd);
244 return ATI_EXCT; /* executing, because response is passed by callback function */
245 }
246
247 #else /* no FF_ATI_BAT */
248
249 TRACE_FUNCTION("setatPlusCPIN()");
250 ret = sAT_PlusCPIN ((T_ACI_CMD_SRC)srcId,pinOld,pinNew);
251
252 switch(ret)
253 {
254 case(AT_EXCT):
255 {
256 break;
257 }
258 case(AT_BUSY):
259 {
260 cmdCmeError(CME_ERR_SimBusy);
261 break;
262 }
263 case(AT_FAIL):
264 {
265 cmdCmeError(CME_ERR_Unknown);
266 break;
267 }
268 case(AT_CMPL):
269 {
270 if (!slockBlocked)
271 {
272 cmdCmeError(CME_ERR_Unknown);
273 }
274 break;
275 }
276 }
277 return (map_aci_2_ati_rslt(ret));
278 #endif /* FF_ATI_BAT */
279 }
280
281 GLOBAL T_ATI_RSLT queatPlusCPIN (char *cl, UBYTE srcId)
282 {
283 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
284 src_params->curAtCmd = AT_CMD_CPIN;
285
286 #ifdef FF_ATI_BAT
287 {
288 T_BAT_cmd_send cmd;
289 T_BAT_no_parameter dummy;
290
291 TRACE_FUNCTION("queatPlusCPIN() calls bat_send() <=== as APPLICATION");
292
293 cmd.ctrl_params = BAT_CMD_QUE_PLUS_CPIN;
294 dummy.bat_dummy = 0xFF;
295 cmd.params.ptr_que_plus_cpin = &dummy;
296 bat_send(ati_bat_get_client(srcId), &cmd);
297 return ATI_EXCT; /* executing, because response is passed by callback function */
298 }
299 #else /* no FF_ATI_BAT */
300 {
301 T_ACI_RETURN ret = AT_FAIL;
302 T_ACI_CPIN_RSLT code;
303
304 TRACE_FUNCTION ("queatPlusCPIN()");
305
306 ret= qAT_PlusCPIN ((T_ACI_CMD_SRC)srcId,&code); /*PIN status is requested*/
307 switch (ret)
308 {
309 case(AT_CMPL):
310 {
311 sprintf (g_sa,"+CPIN: %s",CPIN_RESULT(code));
312 io_sendMessage (srcId, g_sa, ATI_NORMAL_OUTPUT);
313 break;
314 }
315 case(AT_EXCT):
316 {
317 src_params->curAtCmd = AT_CMD_CPIN;
318 break;
319 }
320 default:
321 {
322 cmdCmeError (CME_ERR_Unknown);
323 break;
324 }
325 }
326 return (map_aci_2_ati_rslt(ret));
327 }
328 #endif /* no FF_ATI_BAT */
329 }
330
331 /*
332 +--------------------------------------------------------------------+
333 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
334 | STATE : code ROUTINE : atPlusCPOL |
335 +--------------------------------------------------------------------+
336
337 PURPOSE : +CPOL command (preferred operator list)
338 */
339
340 GLOBAL T_ATI_RSLT setatPlusCPOL (char *cl, UBYTE srcId)
341 {
342 T_ACI_CPOL_FRMT format = CPOL_FRMT_NotPresent;
343 SHORT index = ACI_NumParmNotPresent;
344 char op[20] = {0};
345 T_ACI_RETURN ret = AT_FAIL;
346 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
347
348 TRACE_FUNCTION("setatPlusCPOL()");
349
350 cl = parse(cl,"dds",&index,&format,(LONG)20,op);
351 if(!cl)
352 {
353 cmdCmeError(CME_ERR_OpNotAllow);
354 return ATI_FAIL;
355 }
356
357 #ifdef FF_ATI_BAT
358
359 {
360 T_BAT_cmd_send cmd;
361 T_BAT_cmd_set_plus_cpol cpol;
362 UBYTE len;
363
364 len=strlen(op);
365
366 /*
367 * If the operator name is too big for the BAT structure, there's
368 * nothing we can do. A truncated version would be meaningless, and
369 * to omit it would result in an operator being deleted from the
370 * list.
371 */
372 if (len>BAT_MAX_CPOL_OPER_LEN)
373 return(ATI_FAIL);
374
375 cmd.ctrl_params = BAT_CMD_SET_PLUS_CPOL;
376 cmd.params.ptr_set_plus_cpol=&cpol;
377
378 cpol.index=(S16)index;
379
380 /*
381 * This relies on T_ACI_CPOL_FRMT being identical to
382 * T_BAT_plus_cpol_format.
383 */
384 cpol.format=(T_BAT_plus_cpol_format)format;
385
386 if (len>0)
387 {
388 memcpy(cpol.oper,op,len);
389 cpol.v_oper=TRUE;
390 cpol.c_oper=(U8)len;
391 }
392 else
393 {
394 cpol.v_oper=FALSE;
395 }
396
397 bat_send(ati_bat_get_client(srcId), &cmd);
398 src_params->curAtCmd=AT_CMD_CPOL;
399 return(ATI_EXCT);
400 }
401
402 #else /* no FF_ATI_BAT */
403
404 #ifdef WIN32
405 ret=sAT_PlusCPOL(srcId,index,format,
406 ((op[0] NEQ 0x0)?op:NULL),
407 cpolIdx2,
408 cpolMode);
409 #else
410 ret=sAT_PlusCPOL((T_ACI_CMD_SRC)srcId,index,format,
411 ((op[0] NEQ 0x0)?op:NULL),
412 ACI_NumParmNotPresent,
413 CPOL_MOD_NotPresent);
414 #endif
415
416
417 switch (ret)
418 {
419 case (AT_CMPL):
420 return ATI_CMPL;
421 case (AT_EXCT):
422 src_params->curAtCmd = AT_CMD_CPOL;
423 return ATI_EXCT;
424 default:
425 cmdCmeError(CME_ERR_Unknown);
426 return ATI_FAIL;
427 }
428 #endif /* no FF_ATI_BAT */
429 }
430
431 GLOBAL T_ATI_RSLT tesatPlusCPOL (char *cl, UBYTE srcId)
432 {
433 SHORT lastIdx=0,usdNtry=0;
434 T_ACI_RETURN ret = AT_FAIL;
435 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
436
437 TRACE_FUNCTION("tesatPlusCPOL()");
438
439 src_params->curAtCmd=AT_CMD_CPOL;
440
441 #ifdef FF_ATI_BAT
442 {
443 T_BAT_cmd_send cmd;
444 T_BAT_no_parameter dummy;
445
446 cmd.ctrl_params = BAT_CMD_TST_PLUS_CPOL;
447 dummy.bat_dummy = 0xFF;
448 cmd.params.ptr_tst_plus_cpol = &dummy;
449 bat_send(ati_bat_get_client(srcId), &cmd);
450 return(ATI_EXCT);
451 }
452 #else /* no FF_ATI_BAT */
453
454 ret = tAT_PlusCPOL((T_ACI_CMD_SRC)srcId,&lastIdx,&usdNtry);
455 if (ret EQ AT_CMPL)
456 {
457 sprintf(g_sa,"+CPOL: (1-%d),(0-2)", lastIdx);
458 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
459 }
460 if (ret EQ AT_EXCT)
461 {
462 src_params->curAtCmd = AT_CMD_CPOL;
463 }
464 if (ret EQ AT_FAIL)
465 {
466 cmdCmeError(CME_ERR_Unknown);
467 }
468 return (map_aci_2_ati_rslt(ret));
469
470 #endif /* no FF_ATI_BAT */
471 }
472
473 GLOBAL T_ATI_RSLT queatPlusCPOL (char *cl, UBYTE srcId)
474 {
475 #ifndef FF_ATI_BAT
476 T_ACI_CPOL_LST plmnSelLst;
477 UBYTE idx;
478 BOOL loop;
479 #endif
480
481 SHORT startIdx=0,lastIdx=0;
482 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
483
484 src_params->curAtCmd=AT_CMD_CPOL;
485
486 TRACE_FUNCTION("queatPlusCPOL()");
487
488 #ifdef FF_ATI_BAT
489 {
490 T_BAT_cmd_send cmd;
491 T_BAT_no_parameter dummy;
492
493 cmd.ctrl_params = BAT_CMD_QUE_PLUS_CPOL;
494 dummy.bat_dummy = 0xFF;
495 cmd.params.ptr_que_plus_cpol = &dummy;
496 bat_send(ati_bat_get_client(srcId), &cmd);
497 return(ATI_EXCT);
498 }
499 #else /* no FF_ATI_BAT */
500
501 #ifdef WIN32
502 switch (qAT_PlusCPOL ( srcId,
503 1, &lastIdx,
504 &plmnSelLst[0],
505 cpolMode))
506 #else
507 switch (qAT_PlusCPOL ( (T_ACI_CMD_SRC)srcId,
508 1, &lastIdx,
509 &plmnSelLst[0],
510 CPOL_MOD_NotPresent))
511 #endif
512 {
513 case AT_CMPL:
514 loop = TRUE;
515 do
516 {
517 if( lastIdx EQ ACI_NumParmNotPresent )
518 break;
519
520 startIdx = lastIdx+1;
521
522 for( idx=0; idx < MAX_OPER; idx++ )
523 {
524 if( plmnSelLst[idx].index EQ ACI_NumParmNotPresent )
525 {
526 loop = FALSE;
527 break;
528 }
529 sprintf(g_sa,"+CPOL: %d,%d,\"%s\"", plmnSelLst[idx].index,
530 plmnSelLst[idx].format,
531 plmnSelLst[idx].oper );
532 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
533 }
534
535 if( qAT_PlusCPOL((T_ACI_CMD_SRC)srcId, startIdx, &lastIdx, &plmnSelLst[0],
536 #ifdef WIN32
537 cpolMode
538 #else
539 CPOL_MOD_NotPresent
540 #endif
541 ) EQ AT_FAIL OR !loop)
542 {
543 break;
544 }
545 }
546 while( loop );
547 return ATI_CMPL;
548
549 case AT_EXCT:
550 src_params->curAtCmd = AT_CMD_CPOL;
551 return ATI_EXCT;
552
553 default:
554 cmdCmeError(CME_ERR_Unknown);
555 return ATI_FAIL;
556 }
557
558 #endif /* no FF_ATI_BAT */
559 }
560
561 /*
562 +--------------------------------------------------------------------+
563 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
564 | STATE : code ROUTINE : atPlusCNUM |
565 +--------------------------------------------------------------------+
566
567 PURPOSE : +CNUM command (subscriber number)
568 */
569
570 GLOBAL T_ATI_RSLT setatPlusCNUM (char *cl, UBYTE srcId)
571 {
572 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
573 TRACE_FUNCTION("setatPlusCNUM()");
574
575 #ifdef FF_ATI_BAT
576
577 {
578 T_BAT_cmd_send cmd;
579 T_BAT_no_parameter dummy;
580
581 TRACE_FUNCTION("setatPlusCNUM() calls bat_send() <=== as APPLICATION");
582
583 cmd.ctrl_params = BAT_CMD_SET_PLUS_CNUM;
584 dummy.bat_dummy = 0xFF;
585 cmd.params.ptr_set_plus_cnum = &dummy;
586
587 bat_send(ati_bat_get_client(srcId), &cmd);
588
589 src_params->curAtCmd=AT_CMD_CNUM;
590 return(ATI_EXCT);
591 }
592
593 #else /* no FF_ATI_BAT */
594
595 if ( qAT_PlusCNUM ( (T_ACI_CMD_SRC)srcId, CNUM_MOD_NewRead ) EQ AT_EXCT )
596 {
597 src_params->curAtCmd = AT_CMD_CNUM;
598 return ATI_EXCT;
599 }
600 else
601 {
602 cmdCmeError ( CME_ERR_Unknown );
603 return ATI_FAIL;
604 }
605
606 #endif /* no FF_ATI_BAT */
607 }
608
609
610 /*
611 +--------------------------------------------------------------------+
612 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
613 | STATE : code ROUTINE : atPlusCFUN |
614 +--------------------------------------------------------------------+
615
616 PURPOSE : +CFUN command (Phone functionality)
617 */
618
619 GLOBAL T_ATI_RSLT setatPlusCFUN (char *cl, UBYTE srcId)
620 {
621 T_ACI_RETURN ret = AT_FAIL;
622 T_ACI_CFUN_FUN fun = CFUN_FUN_NotPresent;
623 T_ACI_CFUN_RST rst = CFUN_RST_NotPresent;
624 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
625
626 src_params->curAtCmd = AT_CMD_CFUN;
627
628 cl = parse (cl, "dd", &fun, &rst);
629 if ( !cl )
630 {
631 cmdCmeError (CME_ERR_OpNotAllow);
632 return (ATI_FAIL);
633 }
634
635 #ifdef FF_ATI_BAT
636 {
637 T_BAT_cmd_send cmd;
638 T_BAT_cmd_set_plus_cfun my_bat_set_plus_cfun;
639
640 TRACE_FUNCTION("setatPlusCFUN() calls bat_send() <=== as APPLICATION");
641
642 memset(&my_bat_set_plus_cfun, FALSE, sizeof(my_bat_set_plus_cfun));
643 cmd.ctrl_params = BAT_CMD_SET_PLUS_CFUN;
644 cmd.params.ptr_set_plus_cfun = &my_bat_set_plus_cfun;
645
646 my_bat_set_plus_cfun.fun = (T_BAT_VAL_plus_cfun_fun)fun;
647 my_bat_set_plus_cfun.rst = (T_BAT_VAL_plus_cfun_rst)rst;
648
649
650 bat_send(ati_bat_get_client(srcId), &cmd);
651 return ATI_EXCT; /* executing, because response is passed by callback function */
652 }
653 #else /* no FF_ATI_BAT */
654 {
655 TRACE_FUNCTION("setatPlusCFUN()");
656 ret = sAT_PlusCFUN ((T_ACI_CMD_SRC)srcId,fun,rst);
657 switch (ret)
658 {
659 case AT_EXCT: /*Command is executing*/
660 audio_SetAmplf (AUDIO_MICROPHONE, (UBYTE)75);
661 audio_SetAmplf (AUDIO_SPEAKER, (UBYTE)175);
662 src_params->curAtCmd = AT_CMD_CFUN;
663 break;
664
665 case AT_CMPL:
666 src_params->curAtCmd = AT_CMD_NONE;
667 break;
668
669 default: /* AT_FAIL or nothing was returned */
670 cmdExtError (EXT_ERR_NotPresent);
671 break;
672 }
673 return (map_aci_2_ati_rslt (ret));
674 }
675 #endif /* no FF_ATI_BAT */
676 }
677
678 GLOBAL T_ATI_RSLT queatPlusCFUN (char *cl, UBYTE srcId)
679 {
680 T_ACI_RETURN ret = AT_FAIL;
681 T_ACI_CFUN_FUN fun = CFUN_FUN_NotPresent;
682
683 #ifdef FF_ATI_BAT
684 {
685 T_BAT_cmd_send cmd;
686 T_BAT_no_parameter dummy;
687
688 TRACE_FUNCTION("queatPlusCFUN() calls bat_send() <=== as APPLICATION");
689
690 cmd.ctrl_params = BAT_CMD_QUE_PLUS_CFUN;
691 dummy.bat_dummy = 0xFF;
692 cmd.params.ptr_que_plus_cfun = &dummy;
693 bat_send(ati_bat_get_client(srcId), &cmd);
694 return ATI_EXCT; /* executing, because response is passed by callback function */
695 }
696 #else /* no FF_ATI_BAT */
697 TRACE_FUNCTION("queatPlusCFUN()");
698
699 ret = qAT_PlusCFUN((T_ACI_CMD_SRC)srcId, &fun);
700 if (ret EQ AT_CMPL)
701 {
702 resp_disp(srcId, cl,"e",&fun);
703 return ATI_CMPL;
704 }
705 else
706 {
707 cmdCmeError(CME_ERR_Unknown);
708 return ATI_FAIL;
709 }
710 #endif /* no FF_ATI_BAT */
711 }
712
713 /*
714 +--------------------------------------------------------------------+
715 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
716 | STATE : code ROUTINE : atPlusCIMI |
717 +--------------------------------------------------------------------+
718
719 PURPOSE : +CIMI command (request international mobile subscriber
720 identity)
721 */
722 GLOBAL T_ATI_RSLT setatPlusCIMI(char *cl, UBYTE srcId)
723 {
724 #ifndef FF_ATI_BAT
725 CHAR imsi[MAX_IMSI_LEN+1]; /* +1 for '\0' */
726 #endif
727
728 T_ACI_RETURN ret = AT_FAIL;
729 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
730
731 TRACE_FUNCTION("setatPlusCIMI()");
732
733 #ifdef FF_ATI_BAT
734
735 {
736 T_BAT_cmd_send cmd;
737 T_BAT_no_parameter dummy;
738
739 TRACE_FUNCTION("setatPlusCIMI() calls bat_send() <=== as APPLICATION");
740
741 cmd.ctrl_params = BAT_CMD_SET_PLUS_CIMI;
742 dummy.bat_dummy = 0xFF;
743 cmd.params.ptr_set_plus_cimi = &dummy;
744
745 bat_send(ati_bat_get_client(srcId), &cmd);
746
747 src_params->curAtCmd=AT_CMD_CIMI;
748 return(ATI_EXCT);
749 }
750
751 #else /* no FF_ATI_BAT */
752
753 ret = qAT_PlusCIMI((T_ACI_CMD_SRC)srcId, imsi);
754 switch (ret)
755 {
756 case( AT_CMPL ):
757
758 sprintf(g_sa,"%s",imsi);
759 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
760 break;
761
762 case( AT_EXCT ):
763 src_params->curAtCmd = AT_CMD_CIMI;
764 break;
765
766 default:
767
768 break;
769 }
770 return (map_aci_2_ati_rslt(ret));
771
772 #endif /* no FF_ATI_BAT */
773 }
774
775
776 /*
777 +--------------------------------------------------------------------+
778 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
779 | STATE : code ROUTINE : atPlusCRSM |
780 +--------------------------------------------------------------------+
781
782 PURPOSE : +CRSM Restricted SIM access
783 */
784 GLOBAL T_ATI_RSLT setatPlusCRSM(char *cl, UBYTE srcId)
785 {
786 T_ACI_RETURN ret = AT_FAIL;
787 UBYTE *data;
788 USHORT lenData = 0;
789 T_ACI_CRSM_CMD cmd = CRSM_CMD_NotPresent;
790 SHORT fileId = ACI_NumParmNotPresent,
791 p1 = ACI_NumParmNotPresent,
792 p2 = ACI_NumParmNotPresent,
793 p3 = ACI_NumParmNotPresent;
794 USHORT lenDataStr = 0;
795 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
796
797
798 TRACE_FUNCTION("setatPlusCRSM");
799
800 cl = parse(cl,"drrrrl", &cmd,&fileId, &p1, &p2, &p3,&lenDataStr,&data );
801 if(!cl)
802 {
803 cmdCmeError(CME_ERR_OpNotAllow);
804 return ATI_FAIL;
805 }
806
807 utl_hexToGsm( data, lenDataStr, data, &lenData, GSM_ALPHA_Def,
808 CSCS_ALPHA_Reserved );
809
810 #ifdef FF_ATI_BAT
811 {
812 T_BAT_cmd_send bat_cmd;
813 T_BAT_cmd_set_plus_crsm crsm;
814
815 /*
816 * If the data is too big for the BAT structure, there's
817 * nothing we can do. A truncated version would be meaningless.
818 */
819 if (lenData>BAT_MAX_CRSM_DATA_LEN)
820 return(ATI_FAIL);
821
822 bat_cmd.ctrl_params = BAT_CMD_SET_PLUS_CRSM;
823 bat_cmd.params.ptr_set_plus_crsm=&crsm;
824
825 /*
826 * This relies on T_ACI_CRSM_COMMAND and T_BAT_plus_crsm_command
827 * being identical. They are, except in that the ACI version has
828 * a 'not present' value. This is not an issue in this direction.
829 */
830 crsm.command=(T_BAT_plus_crsm_command)cmd;
831
832 crsm.fileid=(S32)fileId;
833 crsm.p1=(S16)p1;
834 crsm.p2=(S16)p2;
835 crsm.p3=(S16)p3;
836 crsm.c_data=(U8)lenData;
837 memcpy(crsm.data,data,lenData);
838
839 bat_send(ati_bat_get_client(srcId),&bat_cmd);
840
841 src_params->curAtCmd=AT_CMD_CRSM;
842 return(ATI_EXCT);
843 }
844 #else /* no FF_ATI_BAT */
845
846 ret = sAT_PlusCRSM( (T_ACI_CMD_SRC)srcId, cmd, fileId, p1, p2, p3,
847 lenData, data );
848 if (ret EQ AT_EXCT)
849 {
850 src_params->curAtCmd = AT_CMD_CRSM;
851 }
852 if (ret EQ AT_FAIL)
853 {
854 cmdCmeError(CME_ERR_Unknown);
855 }
856 return (map_aci_2_ati_rslt(ret));
857
858 #endif /* no FF_ATI_BAT */
859 }
860
861 /*
862 +--------------------------------------------------------------------+
863 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
864 | STATE : code ROUTINE : setatPlusCSIM |
865 +--------------------------------------------------------------------+
866
867 PURPOSE : +CSIM Generic SIM access
868 */
869 GLOBAL T_ATI_RSLT setatPlusCSIM(char *cl, UBYTE srcId)
870 {
871 T_ACI_RETURN ret = AT_FAIL;
872 USHORT given_length;
873 UBYTE *data;
874 USHORT lenData = 0;
875 USHORT lenDataStr = 0;
876
877
878 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
879
880
881 TRACE_FUNCTION("setatPlusCSIM");
882
883 cl = parse(cl,"rl", &given_length, &lenDataStr, &data );
884 if(!cl)
885 {
886 cmdCmeError(CME_ERR_OpNotAllow);
887 return ATI_FAIL;
888 }
889
890 if ((given_length > MAX_SIM_TRANSP*2)
891 OR (given_length NEQ lenDataStr)
892 OR (lenDataStr EQ 0))
893 {
894 cmdCmeError(CME_ERR_OpNotAllow);
895 return ATI_FAIL;
896 }
897
898 lenData = utl_HexStrToBin(data, lenDataStr, data, MAX_SIM_TRANSP);
899
900 if (lenData EQ 0)
901 {
902 TRACE_EVENT("invalid character in <command>");
903 cmdCmeError(CME_ERR_OpNotAllow);
904 return ATI_FAIL;
905 }
906
907 #ifdef FF_ATI_BAT
908
909 {
910 T_BAT_cmd_send bat_cmd;
911 T_BAT_cmd_set_plus_csim csim;
912
913 /*
914 * If the data is too big for the BAT structure, there's
915 * nothing we can do. A truncated version would be meaningless.
916 */
917 if (lenData>BAT_MAX_CSIM_CMD_LEN)
918 return(ATI_FAIL);
919
920 bat_cmd.ctrl_params = BAT_CMD_SET_PLUS_CSIM;
921 bat_cmd.params.ptr_set_plus_csim=&csim;
922
923 csim.c_command=(U8)lenData;
924 memcpy(csim.command,data,lenData);
925
926 bat_send(ati_bat_get_client(srcId),&bat_cmd);
927
928 src_params->curAtCmd=AT_CMD_CRSM;
929 return(ATI_EXCT);
930 }
931
932 #else /* no FF_ATI_BAT */
933
934 ret = sAT_PlusCSIM( (T_ACI_CMD_SRC)srcId, lenData, data );
935 if (ret EQ AT_EXCT)
936 {
937 src_params->curAtCmd = AT_CMD_CSIM;
938 }
939 if (ret EQ AT_FAIL)
940 {
941 cmdCmeError(CME_ERR_Unknown);
942 }
943 return (map_aci_2_ati_rslt(ret));
944
945 #endif /* no FF_ATI_BAT */
946 }
947
948 #ifdef TI_PS_FF_AT_P_CMD_ATR
949 /*
950 +--------------------------------------------------------------------+
951 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
952 | STATE : code ROUTINE : queatPercentATR |
953 +--------------------------------------------------------------------+
954
955 PURPOSE : %ATR answer to reset (query)
956 */
957 GLOBAL T_ATI_RSLT queatPercentATR ( char *cl, UBYTE srcId )
958 {
959 #ifndef FF_ATI_BAT
960 T_ACI_RETURN ret;
961 UBYTE i;
962 UBYTE phase;
963 UBYTE atr_len = 0;
964 UBYTE atr_info[MAX_SIM_ATR];
965 #endif
966
967 TRACE_FUNCTION( "queatPercentATR()" );
968
969 #ifdef FF_ATI_BAT
970 {
971 T_BAT_cmd_send cmd;
972 T_BAT_no_parameter dummy;
973
974 cmd.ctrl_params = BAT_CMD_QUE_PERCENT_ATR;
975 dummy.bat_dummy = 0xFF;
976 cmd.params.ptr_que_percent_atr = &dummy;
977
978 /*
979 * Without this we will lose track of the source ID by the time the
980 * response arrives.
981 */
982 srcId_cb=srcId;
983
984 bat_send(ati_bat_get_client(srcId), &cmd);
985 return(ATI_EXCT);
986 }
987 #else /* no FF_ATI_BAT */
988
989 ret = qAT_PercentATR( (T_ACI_CMD_SRC)srcId, &phase, &atr_len, atr_info );
990
991 if( ret NEQ AT_CMPL )
992 {
993 cmdCmeError(CME_ERR_Unknown);
994 }
995 else
996 {
997 if(phase NEQ NOT_PRESENT_8BIT)
998 {
999 i=sprintf(g_sa,"%s%d,", "%ATR: ", phase);/* if phase available.. return phase*/
1000 }
1001 else
1002 {
1003 i=sprintf(g_sa,"%s", "%ATR: FFFF");/* else return FFFF*/
1004 }
1005
1006 if(atr_len) /* if ATR data available... return ATR data*/
1007 {
1008 sprintf(g_sa+i,",");
1009 utl_binToHex( atr_info, atr_len, g_sa+i );
1010 }
1011
1012 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
1013 }
1014 return (map_aci_2_ati_rslt(ret));
1015
1016 #endif /* no FF_ATI_BAT */
1017 }
1018 #endif /* TI_PS_FF_AT_P_CMD_ATR */
1019
1020 /*
1021 +--------------------------------------------------------------------+
1022 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1023 | STATE : code ROUTINE : setatPercentCPRI |
1024 +--------------------------------------------------------------------+
1025
1026 PURPOSE : %CPRI command (select cipher indication mode)
1027 */
1028
1029 GLOBAL T_ATI_RSLT setatPercentCPRI ( char *cl, UBYTE srcId )
1030 {
1031 T_ACI_RETURN ACI_return = AT_FAIL;
1032 UBYTE CPRImode;
1033
1034 TRACE_FUNCTION( "setatPercentCPRI()" );
1035
1036 switch( *cl )
1037 {
1038 case '0':
1039 case '1':
1040 CPRImode = *cl - 0x30; /* make binary value */
1041 cl++;
1042 ACI_return = sAT_PercentCPRI( (T_ACI_CMD_SRC)srcId, CPRImode );
1043 if( ACI_return NEQ AT_CMPL )
1044 {
1045 cmdCmeError(CME_ERR_Unknown);
1046 }
1047 else /* If ACI_return is AT_CMPL,updates the CPRI_stat with CPRImode */
1048 {
1049 ati_user_output_cfg[srcId].CPRI_stat = CPRImode;
1050 }
1051 break;
1052 default:
1053 cmdCmeError(CME_ERR_OpNotAllow);
1054 break;
1055 }
1056 return (map_aci_2_ati_rslt(ACI_return));
1057 }
1058
1059
1060 GLOBAL T_ATI_RSLT queatPercentCPRI ( char *cl, UBYTE srcId )
1061 {
1062 T_ACI_RETURN ACI_return = AT_FAIL;
1063 UBYTE CPRIenabled;
1064
1065 TRACE_FUNCTION( "queatPercentCPRI()" );
1066
1067 ACI_return = qAT_PercentCPRI( (T_ACI_CMD_SRC)srcId, &CPRIenabled );
1068
1069 if( ACI_return NEQ AT_CMPL )
1070 {
1071 cmdCmeError(CME_ERR_Unknown);
1072 }
1073 else
1074 {
1075 if (CPRIenabled)
1076 {
1077 CPRIenabled = ati_user_output_cfg[srcId].CPRI_stat;
1078 }
1079 else
1080 {
1081 CPRIenabled = CI_DISABLED;
1082 }
1083 resp_disp(srcId, cl,"b",&CPRIenabled);
1084 }
1085 return (map_aci_2_ati_rslt(ACI_return));
1086 }
1087
1088 /*
1089 +--------------------------------------------------------------------+
1090 | PROJECT : GSM-F&D (8411) MODULE : |
1091 | STATE : code ROUTINE : setatPercentPVRF |
1092 +--------------------------------------------------------------------+
1093
1094 PURPOSE : return information relating to status of PIN.
1095
1096 */
1097
1098 GLOBAL T_ATI_RSLT setatPercentPVRF( char *cl, UBYTE srcId )
1099 {
1100 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
1101 T_ACI_PVRF_TYPE type;
1102 CHAR pin[10];
1103 CHAR newpin[10];
1104 T_ACI_RETURN ret = AT_FAIL;
1105
1106 TRACE_FUNCTION( "setatPercentPVRF()" );
1107
1108 /* parse mode */
1109 cl = parse (cl, "dss", &type, (LONG) sizeof (pin),pin, (LONG) sizeof (newpin), newpin);
1110 if (!cl OR (type > PVRF_TYPE_Puk2) OR (type <= PVRF_TYPE_NotPresent))/*lint !e685 (Warning -- :685 Relational operator '>' always evaluates to 'false ) */
1111 {
1112 cmdCmeError (CME_ERR_OpNotAllow);
1113 return (ATI_FAIL);
1114 }
1115
1116 #ifdef FF_ATI_BAT
1117
1118 {
1119 T_BAT_cmd_send cmd;
1120 T_BAT_cmd_set_percent_pvrf pvrf;
1121 UBYTE len;
1122
1123 cmd.ctrl_params = BAT_CMD_SET_PERCENT_PVRF;
1124 cmd.params.ptr_set_percent_pvrf=&pvrf;
1125
1126 /*
1127 * This relies on T_ACI_PVRF_TYPE and T_BAT_percent_pvrf_type
1128 * being identical. They are, except in that the ACI version has
1129 * a 'not present' value. In this direction, that doesn't matter.
1130 */
1131 pvrf.type=(T_BAT_percent_pvrf_type)type;
1132
1133 len=strlen(pin);
1134 if (len>BAT_MAX_PVRF_PIN_LEN)
1135 return(ATI_FAIL);
1136
1137 pvrf.c_pin=(U8)len;
1138 memcpy(pvrf.pin,pin,len);
1139
1140 len=strlen(newpin);
1141 if (len>BAT_MAX_PVRF_NEW_PIN_LEN)
1142 return(ATI_FAIL);
1143
1144 if (len)
1145 {
1146 pvrf.v_newpin=TRUE;
1147 pvrf.c_newpin=(U8)len;
1148 memcpy(pvrf.newpin,newpin,len);
1149 }
1150 else
1151 {
1152 pvrf.v_newpin=FALSE;
1153 }
1154 bat_send(ati_bat_get_client(srcId), &cmd);
1155
1156 src_params->curAtCmd=AT_CMD_PVRF;
1157 return(ATI_EXCT);
1158 }
1159
1160 #else /* no FF_ATI_BAT */
1161
1162 ret = sAT_PercentPVRF ((T_ACI_CMD_SRC)srcId, type, pin, newpin);
1163
1164 switch (ret)
1165 {
1166 case (AT_CMPL): /*operation completed*/
1167 break;
1168 case (AT_EXCT):
1169 src_params->curAtCmd = AT_CMD_PVRF;
1170 break;
1171 default:
1172 cmdCmeError(CME_ERR_Unknown); /*Command failed*/
1173 break;
1174 }
1175 return (map_aci_2_ati_rslt(ret));
1176
1177 #endif /* no FF_ATI_BAT */
1178 }
1179
1180 /*
1181 +--------------------------------------------------------------------+
1182 | PROJECT : GPRS (8441) MODULE : GACI_CMD |
1183 | STATE : code ROUTINE : queatPercentPVRF |
1184 +--------------------------------------------------------------------+
1185
1186 PURPOSE : %PVRF command
1187 */
1188 GLOBAL T_ATI_RSLT queatPercentPVRF (char *cl, UBYTE srcId)
1189 {
1190 TRACE_FUNCTION("queatPercentPVRF()");
1191
1192 #ifdef FF_ATI_BAT
1193 {
1194 T_BAT_cmd_send cmd;
1195 T_BAT_no_parameter dummy;
1196
1197 cmd.ctrl_params = BAT_CMD_QUE_PERCENT_PVRF;
1198 dummy.bat_dummy = 0xFF;
1199 cmd.params.ptr_que_percent_pvrf = &dummy;
1200 bat_send(ati_bat_get_client(srcId), &cmd);
1201 return(ATI_EXCT);
1202 }
1203 #else /* no FF_ATI_BAT */
1204 {
1205 T_ACI_PVRF_STAT ps1;
1206 T_ACI_PVRF_STAT ps2;
1207 CHAR *me = "%PVRF: ";
1208 SHORT pn1cnt = 0;
1209 SHORT pn2cnt = 0;
1210 SHORT pk1cnt = 0;
1211 SHORT pk2cnt = 0;
1212
1213 T_ACI_RETURN ret = qAT_PercentPVRF((T_ACI_CMD_SRC)srcId, &pn1cnt, &pn2cnt, &pk1cnt, &pk2cnt, &ps1, &ps2);
1214
1215 if (ret NEQ AT_CMPL)
1216 {
1217 cmdCmeError(CME_ERR_Unknown);
1218 return (ATI_FAIL);
1219 }
1220
1221 sprintf(g_sa,"%s%d, %d, %d, %d, %d, %d", me, pn1cnt, pn2cnt, pk1cnt, pk2cnt, ps1, ps2);
1222 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
1223
1224 return (ATI_CMPL);
1225 }
1226 #endif /* no FF_ATI_BAT */
1227 }
1228
1229 #ifdef TI_PS_FF_AT_P_CMD_CUST
1230 /*
1231 +--------------------------------------------------------------------+
1232 | PROJECT : GSM-F&D (8411) MODULE : |
1233 | STATE : code ROUTINE : setatPercentCUST |
1234 +--------------------------------------------------------------------+
1235
1236 PURPOSE : %CUST command ( Set Customisation Mode Function )
1237 */
1238
1239 GLOBAL T_ATI_RSLT setatPercentCUST ( char *cl, UBYTE srcId ) /* Function protype is T_ATI_RSLT not T_ACI_RETURN so it is changed */
1240 {
1241 TRACE_FUNCTION( "setatPercentCUST()" );
1242
1243 #ifdef FF_ATI_BAT
1244
1245 {
1246 T_BAT_cmd_send cmd;
1247 T_BAT_cmd_set_percent_cust cust;
1248
1249 cmd.ctrl_params = BAT_CMD_SET_PERCENT_CUST;
1250 cmd.params.ptr_set_percent_cust=&cust;
1251
1252 switch (*cl)
1253 {
1254 case '0':
1255 cust.mode=BAT_P_CUST_MODE_NORMAL;
1256 break;
1257
1258 case '1':
1259 cust.mode=BAT_P_CUST_MODE_BEHAVIOUR_1;
1260 break;
1261
1262 default:
1263 cmdCmeError(CME_ERR_OpNotAllow);
1264 return(ATI_FAIL);
1265 }
1266 bat_send(ati_bat_get_client(srcId), &cmd);
1267
1268 return(ATI_EXCT);
1269 }
1270 #else /* no FF_ATI_BAT */
1271
1272 switch( *cl )
1273 {
1274 case '0':
1275 if (sAT_PercentCUST((T_ACI_CMD_SRC)srcId, CUST_NORMAL_BEHAVIOUR) EQ AT_FAIL)
1276 {
1277 cmdCmeError(CME_ERR_Unknown);
1278 return (ATI_FAIL);
1279 }
1280 break;
1281
1282 case '1':
1283 if (sAT_PercentCUST ((T_ACI_CMD_SRC)srcId, CUST_MODE_BEHAVIOUR_1) EQ AT_FAIL)
1284 {
1285 cmdCmeError(CME_ERR_Unknown);
1286 return (ATI_FAIL);
1287 }
1288 break;
1289
1290 default:
1291 cmdCmeError(CME_ERR_OpNotAllow);
1292 return (ATI_FAIL);
1293 }
1294
1295 return (ATI_CMPL);
1296
1297 #endif /* no FF_ATI_BAT */
1298 }
1299
1300 /*
1301 +--------------------------------------------------------------------+
1302 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1303 | STATE : code ROUTINE : queatPercentCUST |
1304 +--------------------------------------------------------------------+
1305
1306 PURPOSE : %CUST command (Customisaton Mode)
1307 */
1308 GLOBAL T_ATI_RSLT queatPercentCUST (char *cl, UBYTE srcId)
1309 {
1310 TRACE_FUNCTION("queatPercentCUST()");
1311
1312 #ifdef FF_ATI_BAT
1313 {
1314 T_BAT_cmd_send cmd;
1315 T_BAT_no_parameter dummy;
1316
1317 cmd.ctrl_params = BAT_CMD_QUE_PERCENT_CUST;
1318 dummy.bat_dummy = 0xFF;
1319 cmd.params.ptr_que_percent_cust = &dummy;
1320 bat_send(ati_bat_get_client(srcId), &cmd);
1321 return(ATI_EXCT);
1322 }
1323 #else /* no FF_ATI_BAT */
1324 {
1325 T_CUST_MOD mode;
1326 T_ACI_RETURN ret = qAT_PercentCUST((T_ACI_CMD_SRC)srcId, &mode);
1327
1328 if (ret NEQ AT_CMPL)
1329 {
1330 cmdCmeError(CME_ERR_Unknown);
1331 return (ATI_FAIL);
1332 }
1333
1334 sprintf(g_sa,"%%CUST: %d", mode);
1335 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
1336
1337 return ATI_CMPL;
1338 }
1339 #endif /* no FF_ATI_BAT */
1340 }
1341 #endif /* TI_PS_FF_AT_P_CMD_CUST */
1342 /*
1343 +--------------------------------------------------------------------+
1344 | PROJECT : GSM-F&D (8411) MODULE : |
1345 | STATE : code ROUTINE : setatPercentSATCC |
1346 +--------------------------------------------------------------------+
1347
1348 PURPOSE : %SATCC command ( Enable/Disable the Call/Short Message Control By SIM )
1349 */
1350
1351 GLOBAL T_ATI_RSLT setatPercentSATCC ( char *cl, UBYTE srcId ) /* Function protype is T_ATI_RSLT not T_ACI_RETURN so it is changed */
1352
1353 {
1354 #ifdef FF_ATI_BAT
1355 T_BAT_cmd_send bat_cmd;
1356 T_BAT_cmd_set_percent_satcc satcc;
1357 #endif
1358 TRACE_FUNCTION( "setatPercentSATCC()" );
1359
1360 #ifdef FF_ATI_BAT
1361 switch( *cl )
1362 {
1363 case '0':
1364 satcc.mode = BAT_P_SATCC_MODE_INACTIVE;
1365 break;
1366 case '1':
1367 satcc.mode = BAT_P_SATCC_MODE_ACTIVE;
1368 break;
1369 default:
1370 cmdCmeError(CME_ERR_Unknown);
1371 return (ATI_FAIL);
1372 }
1373
1374 bat_cmd.ctrl_params = BAT_CMD_SET_PERCENT_SATCC;
1375 bat_cmd.params.ptr_set_percent_satcc = &satcc;
1376
1377 bat_send(ati_bat_get_client(srcId),&bat_cmd);
1378
1379 return(ATI_EXCT);
1380
1381 #else
1382 switch( *cl )
1383 {
1384 case '0':
1385 if (sAT_PercentSATCC((T_ACI_CMD_SRC)srcId, SATCC_CONTROL_BY_SIM_INACTIVE) EQ AT_FAIL)
1386 {
1387 cmdCmeError(CME_ERR_Unknown);
1388 return (ATI_FAIL);
1389 }
1390 break;
1391
1392 case '1':
1393 if (sAT_PercentSATCC ((T_ACI_CMD_SRC)srcId, SATCC_CONTROL_BY_SIM_ACTIVE) EQ AT_FAIL)
1394 {
1395 cmdCmeError(CME_ERR_Unknown);
1396 return (ATI_FAIL);
1397 }
1398 break;
1399
1400 default:
1401 cmdCmeError(CME_ERR_OpNotAllow);
1402 return (ATI_FAIL);
1403 }
1404
1405 return (ATI_CMPL);
1406
1407 #endif
1408 }
1409
1410 /*
1411 +--------------------------------------------------------------------+
1412 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1413 | STATE : code ROUTINE : queatPercentSATCC |
1414 +--------------------------------------------------------------------+
1415
1416 PURPOSE : %SATCC command (Query Call/Short Message control By SIM)
1417 */
1418 GLOBAL T_ATI_RSLT queatPercentSATCC (char *cl, UBYTE srcId)
1419 {
1420 #ifdef FF_ATI_BAT
1421 T_BAT_cmd_send bat_cmd;
1422 T_BAT_no_parameter satcc;
1423 #else
1424 T_SAT_CC_MOD mode;
1425 T_ACI_RETURN ret = AT_FAIL;
1426 #endif
1427
1428 TRACE_FUNCTION("queatPercentSATCC()");
1429
1430 #ifdef FF_ATI_BAT
1431 bat_cmd.ctrl_params = BAT_CMD_QUE_PERCENT_SATCC;
1432 bat_cmd.params.ptr_que_percent_satcc = &satcc;
1433
1434 bat_send(ati_bat_get_client(srcId),&bat_cmd);
1435
1436 return(ATI_EXCT);
1437
1438 #else
1439
1440 ret = qAT_PercentSATCC((T_ACI_CMD_SRC)srcId, &mode);
1441
1442 if (ret NEQ AT_CMPL)
1443 {
1444 cmdCmeError(CME_ERR_Unknown);
1445 return (ATI_FAIL);
1446 }
1447
1448 sprintf(g_sa,"%%SATCC: %d", mode);
1449 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
1450
1451 #endif /*FF_ATI_BAT*/
1452
1453 return ATI_CMPL;
1454 }
1455
1456 /*
1457 +--------------------------------------------------------------------+
1458 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1459 | STATE : code ROUTINE : setatPercentSIMIND |
1460 +--------------------------------------------------------------------+
1461
1462 PURPOSE : enable %SIMINS / %SIMREM indications
1463 */
1464
1465 GLOBAL T_ATI_RSLT setatPercentSIMIND(char *cl, UBYTE srcId)
1466 {
1467 int mode = 1;
1468
1469 TRACE_FUNCTION("setatPercentSIMIND()");
1470
1471 /* parse mode */
1472 cl = parse (cl, "d", &mode);
1473
1474 if (mode EQ 0 OR mode EQ 1)
1475 {
1476 ati_user_output_cfg[srcId].SIMIND_stat = mode;
1477 return (ATI_CMPL);
1478 }
1479 else
1480 {
1481 cmdCmeError(CME_ERR_OpNotAllow);
1482 return (ATI_FAIL);
1483 }
1484 }
1485
1486 /*
1487 +--------------------------------------------------------------------+
1488 | PROJECT : GPRS (8441) MODULE : ACI_CMD |
1489 | STATE : code ROUTINE : queatPercentSIMIND |
1490 +--------------------------------------------------------------------+
1491
1492 PURPOSE : query status of %SIMINS / %SIMREM indications
1493 */
1494 GLOBAL T_ATI_RSLT queatPercentSIMIND(char *cl, UBYTE srcId)
1495 {
1496 CHAR *me = "%SIMIND";
1497
1498 TRACE_FUNCTION("queatPercentSIMIND()");
1499
1500 sprintf(g_sa,"%s: %d", me, ati_user_output_cfg[srcId].SIMIND_stat);
1501 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
1502
1503 return (ATI_CMPL);
1504 }
1505
1506 #ifdef FF_DUAL_SIM
1507 /*
1508 +--------------------------------------------------------------------+
1509 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1510 | STATE : code ROUTINE : atPlusCFUN |
1511 +--------------------------------------------------------------------+
1512
1513 PURPOSE : %SIM command (SIM Selection)
1514 */
1515
1516 GLOBAL T_ATI_RSLT setatPercentSIM (char *cl, UBYTE srcId)
1517 {
1518 T_ACI_RETURN ret = AT_FAIL;
1519 UBYTE sim_num;
1520
1521 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
1522
1523 TRACE_FUNCTION("setatPercentSIM()");
1524
1525 /*input functionality*/
1526 cl = parse (cl,"d",&sim_num);
1527 if ( !cl )
1528 {
1529 cmdCmeError (CME_ERR_OpNotAllow);
1530 return(ATI_FAIL);
1531 }
1532
1533 ret = sAT_PercentSIM (srcId,sim_num);
1534 switch (ret)
1535 {
1536 case AT_EXCT: /*Command is executing*/
1537 src_params->curAtCmd = AT_CMD_SIM;
1538 break;
1539
1540 case AT_FAIL:
1541 src_params->curAtCmd = AT_CMD_NONE;
1542 break;
1543
1544 default:
1545 cmdCmeError(CME_ERR_Unknown);
1546 break;
1547 }
1548 return (map_aci_2_ati_rslt (ret));
1549 }
1550
1551 GLOBAL T_ATI_RSLT queatPercentSIM (char *cl, UBYTE srcId)
1552 {
1553 T_ACI_RETURN ret = AT_FAIL;
1554 UBYTE sim_num;
1555
1556 TRACE_FUNCTION("queatPercentSIM()");
1557
1558 ret = qAT_PercentSIM(srcId, &sim_num);
1559
1560 if (ret EQ AT_CMPL)
1561 {
1562 resp_disp(srcId, cl,"b",&sim_num);
1563 return ATI_CMPL;
1564 }
1565 else
1566 {
1567 cmdCmeError(CME_ERR_Unknown);
1568 return ATI_FAIL;
1569 }
1570 }
1571 #endif /*FF_DUAL_SIM*/
1572
1573 #ifdef FF_CPHS_REL4
1574 /*
1575 +--------------------------------------------------------------------+
1576 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1577 | STATE : code ROUTINE : setatPercentCFIS |
1578 +--------------------------------------------------------------------+
1579
1580 PURPOSE : %CFIS command (Call Forwarding Unconditional)
1581 */
1582
1583 GLOBAL T_ATI_RSLT setatPercentCFIS (char *cl, UBYTE srcId)
1584 {
1585 T_ACI_RETURN ret = AT_FAIL;
1586 T_ACI_CFIS_MOD cfisMode = CFIS_MOD_NotPresent;
1587 UBYTE index = NOT_PRESENT_8BIT;
1588 UBYTE mspId;
1589 UBYTE cfuStat;
1590 CHAR number[MAX_PHB_NUM_LEN];
1591 T_ACI_TOA type;
1592 T_ACI_TOA *p_type;
1593 SHORT toa_oct = 0;
1594 UBYTE cc2_Id = NOT_PRESENT_8BIT;
1595 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
1596
1597 TRACE_FUNCTION( "setatPercentCFIS()" );
1598
1599 /* init */
1600 memset( number, 0, sizeof(number));
1601
1602 cl = parse (cl, "ddddsdd", &cfisMode, &index, &mspId, &cfuStat,
1603 (LONG)MAX_PHB_NUM_LEN, number, &toa_oct , &cc2_Id);
1604
1605 if(!cl)
1606 {
1607 cmdCmeError(CME_ERR_OpNotAllow);
1608 return (ATI_FAIL);
1609 }
1610
1611 if (toa_oct EQ 0)
1612 {
1613 p_type = NULL;
1614 }
1615 else
1616 {
1617 type=toa_demerge(toa_oct);
1618 p_type = &type;
1619 }
1620
1621 if( cfisMode EQ CFIS_MOD_Read)
1622 {
1623 ret=qAT_PercentCFIS(srcId, index );
1624 }
1625 else
1626 {
1627 ret = sAT_PercentCFIS(srcId, cfisMode,index,mspId, cfuStat,
1628 number, p_type, cc2_Id);
1629 }
1630
1631 switch (ret)
1632 {
1633 case AT_EXCT: /*Command is executing*/
1634 src_params->curAtCmd = AT_CMD_P_CFIS;
1635 break;
1636
1637 default:
1638 src_params->curAtCmd = AT_CMD_NONE;
1639 cmdCmeError(CME_ERR_Unknown);
1640 break;
1641 }
1642 return (map_aci_2_ati_rslt (ret));
1643 }
1644
1645 /*
1646 +--------------------------------------------------------------------+
1647 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1648 | STATE : code ROUTINE : setatPercentMWIS |
1649 +--------------------------------------------------------------------+
1650
1651 PURPOSE : %MWIS command (Message Waiting Indication Status)
1652 */
1653
1654 GLOBAL T_ATI_RSLT setatPercentMWIS (char *cl, UBYTE srcId)
1655 {
1656 T_ACI_RETURN ret = AT_FAIL;
1657 T_ACI_MWIS_MOD mwisMode = MWIS_MOD_Invalid;
1658 UBYTE mspId = NOT_PRESENT_8BIT;
1659 T_ACI_MWIS_MWI mwis;
1660 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
1661
1662 TRACE_FUNCTION( "setatPercentMWIS()" );
1663
1664 memset(&mwis, 0, sizeof(T_ACI_MWIS_MWI));
1665 cl = parse (cl, "ddddddd", &mwisMode, &mspId, &mwis.mwiStat,
1666 &mwis.mwis_count_voice, &mwis.mwis_count_fax,
1667 &mwis.mwis_count_email,&mwis.mwis_count_other);
1668
1669 if(!cl)
1670 {
1671 cmdCmeError(CME_ERR_OpNotAllow);
1672 return (ATI_FAIL);
1673 }
1674
1675 if( mwisMode EQ MWIS_MOD_Read)
1676 {
1677 ret = qAT_PercentMWIS(srcId, mspId );
1678 }
1679 else
1680 {
1681 ret = sAT_PercentMWIS(srcId, mwisMode,mspId, &mwis);
1682 }
1683
1684 switch (ret)
1685 {
1686 case AT_EXCT: /*Command is executing*/
1687 src_params->curAtCmd = AT_CMD_P_MWIS;
1688 break;
1689
1690 default:
1691 src_params->curAtCmd = AT_CMD_NONE;
1692 cmdCmeError(CME_ERR_Unknown);
1693 break;
1694 }
1695 return (map_aci_2_ati_rslt (ret));
1696 }
1697
1698 /*
1699 +--------------------------------------------------------------------+
1700 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1701 | STATE : code ROUTINE : setatPercentMWI |
1702 +--------------------------------------------------------------------+
1703
1704 PURPOSE : %MWI command (Message Waiting Indication)
1705 */
1706
1707 GLOBAL T_ATI_RSLT setatPercentMWI(char *cl, UBYTE srcId)
1708 {
1709 SHORT mode = ACI_NumParmNotPresent;
1710
1711 TRACE_FUNCTION("setatPercentMWI()");
1712
1713 cl = parse(cl,"r",&mode);
1714 if(!cl OR mode > 1 OR mode < 0)
1715 {
1716 cmdCmeError(CME_ERR_OpNotAllow);
1717 return (ATI_FAIL);
1718 }
1719
1720 ati_user_output_cfg[srcId].MWI_stat=(UBYTE)mode;
1721 return (ATI_CMPL);
1722 }
1723
1724 /*
1725 +--------------------------------------------------------------------+
1726 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1727 | STATE : code ROUTINE : queatPercentMWI |
1728 +--------------------------------------------------------------------+
1729
1730 PURPOSE : %MWI command (Message Waiting Indication)
1731 */
1732
1733 GLOBAL T_ATI_RSLT queatPercentMWI(char *cl, UBYTE srcId)
1734 {
1735 UBYTE mode;
1736
1737 TRACE_FUNCTION("queatPercentMWI()");
1738
1739 mode = ati_user_output_cfg[srcId].MWI_stat;
1740 resp_disp(srcId, cl,"b",&mode);
1741 return (ATI_CMPL);
1742 }
1743
1744
1745 /*
1746 +--------------------------------------------------------------------+
1747 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1748 | STATE : code ROUTINE : setatPercentMBI |
1749 +--------------------------------------------------------------------+
1750
1751 PURPOSE : %MBI command (Mailbox Identifier)
1752 */
1753
1754 GLOBAL T_ATI_RSLT setatPercentMBI (char *cl, UBYTE srcId)
1755 {
1756 T_ACI_RETURN ret = AT_FAIL;
1757 T_ACI_MBN_MODE mbiMode = MBN_Mode_Invalid;
1758 UBYTE index = NOT_PRESENT_8BIT;
1759
1760 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
1761
1762 TRACE_FUNCTION( "setatPercentMBI()" );
1763
1764 cl = parse (cl, "dd", &mbiMode, &index);
1765
1766 if(!cl OR (mbiMode NEQ MBN_Mode_Read))
1767 {
1768 cmdCmeError(CME_ERR_OpNotAllow);
1769 return (ATI_FAIL);
1770 }
1771
1772 ret = qAT_PercentMBI(srcId, index );
1773
1774 switch (ret)
1775 {
1776 case AT_EXCT: /*Command is executing*/
1777 src_params->curAtCmd = AT_CMD_P_MBI;
1778 break;
1779
1780 default:
1781 src_params->curAtCmd = AT_CMD_NONE;
1782 cmdCmeError(CME_ERR_Unknown);
1783 break;
1784 }
1785 return (map_aci_2_ati_rslt (ret));
1786 }
1787 /*
1788 +--------------------------------------------------------------------+
1789 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1790 | STATE : code ROUTINE : setatPercentMBDN |
1791 +--------------------------------------------------------------------+
1792
1793 PURPOSE : %MBDN command (Mailbox Dialling Number)
1794 */
1795
1796 GLOBAL T_ATI_RSLT setatPercentMBDN (char *cl, UBYTE srcId)
1797 {
1798 T_ACI_RETURN ret = AT_FAIL;
1799 T_ACI_MBN_MODE mbdnMode = MBN_Mode_Invalid;
1800 UBYTE index = 0;
1801 CHAR number[MAX_MB_NUM_LEN];
1802 CHAR alpha_id[MAX_ALPHA_LEN] = {0x00};
1803 USHORT len_alpha_id = 0;
1804 USHORT lenCvtd = 0; /* holds length of converted text */
1805 T_ACI_PB_TEXT *p_text = NULL; /* holds pointer to converted text */
1806 T_ACI_PB_TEXT cvtdText; /* holds text converted to SIM alpha */
1807 T_ACI_TOA type;
1808 T_ACI_TOA *p_type;
1809 CHAR *p_number;
1810 SHORT toa_oct = 0;
1811 UBYTE cc2_Id = NOT_PRESENT_8BIT;
1812 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
1813
1814 TRACE_FUNCTION( "setatPercentMBDN()" );
1815
1816 /* init */
1817 memset( number, 0, sizeof(number));
1818
1819 cl = parse (cl, "ddsddz", &mbdnMode, &index,(LONG)MAX_MB_NUM_LEN, number,
1820 &toa_oct , &cc2_Id, (LONG)MAX_ALPHA_LEN,
1821 strlen(cl), cl, &len_alpha_id, alpha_id);
1822
1823 if(!cl OR (mbdnMode < 0 OR mbdnMode > 2) OR (!index))
1824 {
1825 cmdCmeError(CME_ERR_OpNotAllow);
1826 return (ATI_FAIL);
1827 }
1828
1829 /* translate alpha text to SIM */
1830 if ( len_alpha_id NEQ 0 )
1831 {
1832 utl_chsetToSim ((UBYTE*)alpha_id, len_alpha_id, (UBYTE*)cvtdText.data,
1833 &lenCvtd, GSM_ALPHA_Def);
1834 }
1835
1836 if (toa_oct EQ 0)
1837 {
1838 p_type = NULL;
1839 }
1840 else
1841 {
1842 type=toa_demerge(toa_oct);
1843 p_type = &type;
1844 }
1845
1846 /* when the text is empty p_text to NULL */
1847 if (lenCvtd EQ 0 )
1848 {
1849 p_text = NULL;
1850 }
1851 else
1852 {
1853 p_text = &cvtdText;
1854 cvtdText.len = (UBYTE)lenCvtd;
1855 }
1856
1857 /* set pointer for number */
1858 if (number[0] EQ '\0') /* The number given is empty */
1859 {
1860 p_number = NULL;
1861 }
1862 else
1863 {
1864 p_number = number;
1865 }
1866
1867 if( mbdnMode EQ MBN_Mode_Read)
1868 {
1869 ret = qAT_PercentMBDN(srcId, index );
1870 }
1871 else
1872 {
1873 ret = sAT_PercentMBDN(srcId, mbdnMode,index,
1874 p_number, p_type, cc2_Id, p_text);
1875 }
1876
1877 switch (ret)
1878 {
1879 case AT_EXCT: /*Command is executing*/
1880 src_params->curAtCmd = AT_CMD_P_MBDN;
1881 break;
1882
1883 default:
1884 src_params->curAtCmd = AT_CMD_NONE;
1885 cmdCmeError(CME_ERR_Unknown);
1886 break;
1887 }
1888 return (map_aci_2_ati_rslt (ret));
1889 }
1890 #endif /* FF_CPHS_REL4 */
1891
1892 #endif /* ATI_SIM_C */