comparison g23m-aci/aci/cmh_simq.c @ 0:75a11d740a02

initial import of gsm-fw from freecalypso-sw rev 1033:5ab737ac3ad7
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 09 Jun 2016 00:02:41 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:75a11d740a02
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : GSM-PS (6147)
4 | Modul : CMH_SIMQ
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 : This module provides the query functions related to the
18 | protocol stack adapter for subscriber identity module.
19 +-----------------------------------------------------------------------------
20 */
21
22 #ifndef CMH_SIMQ_C
23 #define CMH_SIMQ_C
24 #endif
25
26 #include "config.h"
27 #include "fixedconf.h"
28 #include "condat-features.h"
29 #include "aci_conf.h"
30
31 #include "aci_all.h"
32
33 #include "aci_cmh.h"
34
35 #ifdef FAX_AND_DATA
36 #include "aci_fd.h"
37 #endif /* of #ifdef FAX_AND_DATA */
38
39 #ifdef UART
40 #include "dti.h"
41 #include "dti_conn_mng.h"
42 #endif
43
44 #include "psa.h"
45 #include "psa_sim.h"
46 #include "cmh.h"
47 #include "cmh_sim.h"
48 #include "cmh_sms.h"
49
50 /* To include AciSLockShrd */
51 #include "aci_ext_pers.h"
52 #include "aci_slock.h"
53
54
55 #include "aoc.h"
56
57 /*==== CONSTANTS ==================================================*/
58
59 /*==== EXPORT =====================================================*/
60
61 /*==== VARIABLES ==================================================*/
62 #ifdef SIM_PERS
63 #include "general.h" // inluded for UINT8 compilation error in sec_drv.h
64 #include "sec_drv.h"
65 EXTERN T_SEC_DRV_CONFIGURATION *cfg_data;
66 #endif
67
68 /*==== FUNCTIONS ==================================================*/
69
70
71 #ifdef TI_PS_FF_AT_P_CMD_SECS
72 /*
73 +--------------------------------------------------------------------+
74 | PROJECT : GSM-PS (6147) MODULE : CMH_SIMS |
75 | STATE : code ROUTINE : qAT_PercentSECS |
76 +--------------------------------------------------------------------+
77
78 PURPOSE : This is the functional counterpart to the %SECS? AT command
79 which is responsible to query the status of the Security Code.
80
81 */
82
83
84 GLOBAL T_ACI_RETURN qAT_PercentSECS ( T_ACI_CMD_SRC srcId,T_ACI_SECS_STA *status)
85 {
86 T_SIMLOCK_STATUS result = SIMLOCK_FAIL;
87
88 TRACE_FUNCTION ("qAT_PercentSECS()");
89
90 result = aci_ext_personalisation_CS_get_status();
91
92 switch (result)
93 {
94 case SIMLOCK_ENABLED:
95 *status = SECS_STA_Enable;
96 return AT_CMPL;
97 case SIMLOCK_DISABLED:
98 *status = SECS_STA_Disable;
99 return AT_CMPL;
100 default:
101 *status = SECS_STA_NotPresent;
102 return AT_FAIL;
103 }
104 }
105 #endif /* TI_PS_FF_AT_P_CMD_SECS */
106
107 /*
108 +--------------------------------------------------------------------+
109 | PROJECT : GSM-PS (6147) MODULE : CMH_CCQ |
110 | STATE : code ROUTINE : qAT_PlusCFUN |
111 +--------------------------------------------------------------------+
112
113 PURPOSE : This is the functional counterpart to the +CFUN? AT command
114 which returns the current setting for phone functionality.
115
116 <fun>: phone functionality.
117 */
118
119 GLOBAL T_ACI_RETURN qAT_PlusCFUN ( T_ACI_CMD_SRC srcId,
120 T_ACI_CFUN_FUN *fun )
121 {
122 TRACE_FUNCTION ("qAT_PlusCFUN()");
123
124 /*
125 *-------------------------------------------------------------------
126 * check command source
127 *-------------------------------------------------------------------
128 */
129 if(!cmh_IsVldCmdSrc (srcId))
130 {
131 return( AT_FAIL );
132 }
133
134 /*
135 *-------------------------------------------------------------------
136 * fill in parameters
137 *-------------------------------------------------------------------
138 */
139 *fun = CFUNfun;
140
141 return( AT_CMPL );
142 }
143
144 /*
145 +--------------------------------------------------------------------+
146 | PROJECT : GSM-PS (6147) MODULE : CMH_CCQ |
147 | STATE : code ROUTINE : qAT_PlusCPIN |
148 +--------------------------------------------------------------------+
149
150 PURPOSE : This is the functional counterpart to the +CPIN? AT command
151 which returns the current PIN status.
152
153 <code>: PIN status.
154 */
155
156 GLOBAL T_ACI_RETURN qAT_PlusCPIN (T_ACI_CMD_SRC srcId,
157 T_ACI_CPIN_RSLT *code)
158 {
159 T_SIM_SET_PRM * pSIMSetPrm; /* points to SIM parameter set */
160 #ifdef SIM_PERS
161 T_SIMLOCK_STATUS retSlStatus; /* holds return code */
162 #endif
163
164 TRACE_FUNCTION ("qAT_PlusCPIN()");
165
166 /*
167 *-------------------------------------------------------------------
168 * check command source
169 *-------------------------------------------------------------------
170 */
171 if(!cmh_IsVldCmdSrc (srcId))
172 {
173 return( AT_FAIL );
174 }
175
176 pSIMSetPrm = &simShrdPrm.setPrm[srcId];
177
178 /*
179 *-------------------------------------------------------------------
180 * check SIM status
181 *-------------------------------------------------------------------
182 */
183 if( simShrdPrm.SIMStat NEQ SS_OK AND
184 simShrdPrm.SIMStat NEQ SS_BLKD )
185 {
186 pSIMSetPrm -> actProc = SIM_INITIALISATION;
187
188 simEntStat.curCmd = AT_CMD_CPIN;
189 simShrdPrm.owner = (T_OWN)srcId;
190 simEntStat.entOwn = srcId;
191 simShrdPrm.PINQuery = 1;
192
193 if( psaSIM_ActivateSIM() < 0 ) /* activate SIM card */
194 {
195 TRACE_EVENT( "FATAL RETURN psaSIM in +CPIN" );
196 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Internal );
197 simShrdPrm.PINQuery = 0;
198 return( AT_FAIL );
199 }
200 return( AT_EXCT );
201 }
202
203 #ifdef SIM_PERS
204 /*
205 *-------------------------------------------------------------------
206 * check PIN status
207 *-------------------------------------------------------------------
208 */
209 if ( simShrdPrm.PINStat EQ PS_RDY)
210 {
211 simEntStat.curCmd = AT_CMD_CPIN;
212 if(!aci_slock_set_CFG())
213 {
214 ACI_ERR_DESC( ACI_ERR_CLASS_Ext,EXT_ERR_NoMEPD);
215 return( AT_FAIL );
216 }
217 aci_slock_init();
218
219 retSlStatus = SIMLOCK_ENABLED;
220 AciSLockShrd.check_lock = SIMLOCK_CHECK_PERS;
221 AciSLockShrd.cpin_query = SEND_CPIN_REQ_CODE;
222 retSlStatus = aci_slock_checkpersonalisation(AciSLockShrd.current_lock);
223 switch(retSlStatus)
224 {
225 case SIMLOCK_ENABLED :
226 *code = CPIN_RSLT_SimReady;
227 break;
228 case SIMLOCK_BLOCKED :
229 aci_set_cpin_code(AciSLockShrd.current_lock,code);
230 break;
231
232 case SIMLOCK_WAIT :
233 AciSLockShrd.cpin_query = SEND_CPIN_REQ_CODE_RAT;
234 return (AT_EXCT);
235
236 }
237 /* OVK Check first if any Personalisations are active */
238 TRACE_EVENT_P3("qAT_PlusCPIN: Curr Lock = %d, Status = %d %s", AciSLockShrd.current_lock, AciSLockShrd.status[AciSLockShrd.current_lock],"" );
239 return (AT_CMPL);
240
241
242 }
243 else
244 #endif
245 {
246 switch( simShrdPrm.PINStat )
247 {
248 case( PS_RDY ):
249
250 *code = CPIN_RSLT_SimReady;
251 break;
252
253 case( PS_PIN1 ):
254
255 *code = CPIN_RSLT_SimPinReq;
256 break;
257
258 case( PS_PUK1 ):
259
260 *code = CPIN_RSLT_SimPukReq;
261 break;
262
263 case( PS_PIN2 ):
264
265 *code = CPIN_RSLT_SimPin2Req;
266 break;
267
268 case( PS_PUK2 ):
269
270 *code = CPIN_RSLT_SimPuk2Req;
271 break;
272
273 default:
274
275 TRACE_EVENT("UNEXPECTED PIN STATUS");
276 *code = CPIN_RSLT_NotPresent;
277 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_DataCorrupt );
278 return( AT_FAIL );
279 }
280
281
282 }
283
284 return( AT_CMPL );
285 }
286
287 /*
288 +--------------------------------------------------------------------+
289 | PROJECT : GSM-PS (6147) MODULE : CMH_SSQ |
290 | STATE : code ROUTINE : qAT_PlusCAOC |
291 +--------------------------------------------------------------------+
292
293 PURPOSE : This is the functional counterpart to the +CAOC AT command
294 which is responsible to query the current call meter value.
295
296 <ccm> : CCM value.
297 */
298
299 GLOBAL T_ACI_RETURN qAT_PlusCAOC ( T_ACI_CMD_SRC srcId,
300 LONG * ccm)
301 {
302 TRACE_FUNCTION ("qAT_PlusCAOC ()");
303
304 /*
305 *-------------------------------------------------------------------
306 * request value from advice of charge module.
307 *-------------------------------------------------------------------
308 */
309 aoc_get_values (AOC_CCM, (void *)ccm);
310
311 return( AT_CMPL );
312 }
313
314 /*
315 +--------------------------------------------------------------------+
316 | PROJECT : GSM-PS (6147) MODULE : CMH_SSQ |
317 | STATE : code ROUTINE : qAT_PlusCACM |
318 +--------------------------------------------------------------------+
319
320 PURPOSE : This is the functional counterpart to the +CACM AT command
321 which is responsible to query the accumulated call meter value.
322
323 <acm> : ACM value.
324 */
325
326 GLOBAL T_ACI_RETURN qAT_PlusCACM ( T_ACI_CMD_SRC srcId,
327 LONG * acm)
328 {
329 TRACE_FUNCTION ("qAT_PlusCACM ()");
330
331 /*
332 *-------------------------------------------------------------------
333 * request value from advice of charge module.
334 *-------------------------------------------------------------------
335 */
336 aoc_get_values (AOC_ACM, (ULONG *)acm);
337
338 return( AT_CMPL );
339 }
340
341 /*
342 +--------------------------------------------------------------------+
343 | PROJECT : GSM-PS (6147) MODULE : CMH_SSQ |
344 | STATE : code ROUTINE : qAT_PlusCAMM |
345 +--------------------------------------------------------------------+
346
347 PURPOSE : This is the functional counterpart to the +CAMM AT command
348 which is responsible to query the maximum of the
349 accumulated call meter value.
350
351 <acmmax> : ACMMax value.
352 */
353
354 GLOBAL T_ACI_RETURN qAT_PlusCAMM ( T_ACI_CMD_SRC srcId,
355 LONG * acmmax)
356 {
357 TRACE_FUNCTION ("qAT_PlusCAMM ()");
358
359 /*
360 *-------------------------------------------------------------------
361 * request value from advice of charge module.
362 *-------------------------------------------------------------------
363 */
364 aoc_get_values (AOC_ACMMAX, (ULONG *)acmmax);
365
366 return( AT_CMPL );
367 }
368
369 /*
370 +--------------------------------------------------------------------+
371 | PROJECT : GSM-PS (6147) MODULE : CMH_SSQ |
372 | STATE : code ROUTINE : qAT_PlusCPUC |
373 +--------------------------------------------------------------------+
374
375 PURPOSE : This is the functional counterpart to the +CPUC AT command
376 which is responsible to query the price per unit and
377 currency.
378
379 <cuurency> : Currency
380 <ppu> : Price per Unit
381 */
382
383 GLOBAL T_ACI_RETURN qAT_PlusCPUC ( T_ACI_CMD_SRC srcId,
384 CHAR *currency,
385 CHAR *ppu)
386 {
387 T_puct puct;
388
389 TRACE_FUNCTION ("qAT_PlusCPUC ()");
390
391 /*
392 *-------------------------------------------------------------------
393 * request value from advice of charge module.
394 *-------------------------------------------------------------------
395 */
396 aoc_get_values (AOC_PUCT, (void *)&puct);
397
398 strcpy ((char *) currency, (char *) puct.currency);
399 strcpy ((char *) ppu, (char *) puct.value);
400
401 return( AT_CMPL );
402 }
403
404 /*
405 +--------------------------------------------------------------------+
406 | PROJECT : GSM-PS (6147) MODULE : CMH_SIMS |
407 | STATE : code ROUTINE : sAT_PlusCIMI |
408 +--------------------------------------------------------------------+
409
410 PURPOSE : This is the functional counterpart to the +CIMI AT command
411 which is responsible to request the IMSI.
412
413 */
414
415 GLOBAL T_ACI_RETURN qAT_PlusCIMI ( T_ACI_CMD_SRC srcId,
416 CHAR * imsi )
417 {
418 T_SIM_SET_PRM * pSIMSetPrm; /* points to SIM parameter set */
419
420 TRACE_FUNCTION ("qAT_PlusCIMI()");
421
422 /*
423 *-------------------------------------------------------------------
424 * check command source
425 *-------------------------------------------------------------------
426 */
427 if(!cmh_IsVldCmdSrc (srcId))
428 {
429 return( AT_FAIL );
430 }
431
432 pSIMSetPrm = &simShrdPrm.setPrm[srcId];
433
434 /*
435 *-------------------------------------------------------------------
436 * check entity status
437 *-------------------------------------------------------------------
438 */
439 switch( simShrdPrm.SIMStat )
440 {
441 case( SS_OK ):
442 /*
443 *-----------------------------------------------------------------
444 * check if command executable
445 *-----------------------------------------------------------------
446 */
447 if((simShrdPrm.PINStat NEQ PS_RDY) AND (!cmhSMS_checkSIM ()))
448 {
449 return AT_FAIL;
450 }
451
452 /*
453 * Check required for CIMI after SIM_REMOVE_IND and SIM_ACTIVATE_IND
454 * with SIMStat as SS_OK and PINStat as PS_RDY
455 * but before receiving SIM_MMI_INSERT_IND
456 */
457 else if(simShrdPrm.imsi.c_field EQ 0)
458 {
459 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_Unknown);
460 return AT_FAIL;
461 }
462 else
463 {
464 psaSIM_cnvrtIMSI2ASCII( imsi );
465 return( AT_CMPL );
466 }
467
468 case( NO_VLD_SS ):
469
470 if( simEntStat.curCmd NEQ AT_CMD_NONE ) return( AT_BUSY );
471
472 pSIMSetPrm -> actProc = SIM_INITIALISATION;
473
474 simEntStat.curCmd = AT_CMD_CIMI;
475 simShrdPrm.owner = (T_OWN)srcId;
476 simEntStat.entOwn = srcId;
477
478 if( psaSIM_ActivateSIM() < 0 ) /* activate SIM card */
479 {
480 simEntStat.curCmd = AT_CMD_NONE;
481 TRACE_EVENT( "FATAL RETURN psaSIM in +CIMI" );
482 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_Unknown);
483 return( AT_FAIL );
484 }
485
486 return( AT_EXCT );
487
488 default: /* SIM failure */
489 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_SimFail );
490 return( AT_FAIL );
491 }
492 }
493
494 /*
495 +--------------------------------------------------------------------+
496 | PROJECT : GSM-PS (6147) MODULE : CMH_SSQ |
497 | STATE : code ROUTINE : qAT_PercentCACM |
498 +--------------------------------------------------------------------+
499
500 PURPOSE : This is the functional counterpart to the %CACM AT command
501 which is responsible to query the accumulated call meter value
502 using PUCT.
503
504 <cur> : currency.
505 <val> : ACM value.
506 */
507
508 GLOBAL T_ACI_RETURN qAT_PercentCACM( T_ACI_CMD_SRC srcId,
509 CHAR *cur,
510 CHAR *val)
511 {
512 T_puct puct;
513
514 TRACE_FUNCTION ("qAT_PercentCACM ()");
515
516 /*
517 *-------------------------------------------------------------------
518 * request value from advice of charge module.
519 *-------------------------------------------------------------------
520 */
521 aoc_get_values (AOC_ACM_PUCT, (T_puct *)&puct);
522
523 strcpy (cur, (char *) puct.currency);
524 strcpy (val, (char *) puct.value);
525
526 return( AT_CMPL );
527 }
528
529 /*
530 +--------------------------------------------------------------------+
531 | PROJECT : GSM-PS (6147) MODULE : CMH_SSQ |
532 | STATE : code ROUTINE : qAT_PercentCAOC |
533 +--------------------------------------------------------------------+
534
535 PURPOSE : This is the functional counterpart to the %CAOC AT command
536 which is responsible to query the current call meter value
537 using PUCT.
538
539 <cur> : currency.
540 <val> : CCM value.
541 */
542
543 GLOBAL T_ACI_RETURN qAT_PercentCAOC( T_ACI_CMD_SRC srcId,
544 CHAR *cur,
545 CHAR *val)
546 {
547 T_puct puct;
548
549 TRACE_FUNCTION ("qAT_PercentCAOC ()");
550
551 /*
552 *-------------------------------------------------------------------
553 * request value from advice of charge module.
554 *-------------------------------------------------------------------
555 */
556 aoc_get_values (AOC_CCM_PUCT, (T_puct *)&puct);
557
558 strcpy (cur, (char *) puct.currency);
559 strcpy (val, (char *) puct.value);
560
561 return( AT_CMPL );
562 }
563
564 /*
565 +--------------------------------------------------------------------+
566 | PROJECT : GSM-PS (6147) MODULE : CMH_SSQ |
567 | STATE : code ROUTINE : qAT_PercentCTV |
568 +--------------------------------------------------------------------+
569
570 PURPOSE : This is the functional counterpart to the %CTV AT command
571 which is responsible to query the current call timer value.
572
573 <ctv> : CTV value.
574 */
575
576 GLOBAL T_ACI_RETURN qAT_PercentCTV ( T_ACI_CMD_SRC srcId,
577 LONG * ctv)
578 {
579 TRACE_FUNCTION ("qAT_PercentCTV ()");
580
581 /*
582 *-------------------------------------------------------------------
583 * request value from advice of charge module.
584 *-------------------------------------------------------------------
585 */
586 aoc_get_values (AOC_CTV, (void *)ctv);
587
588 return( AT_CMPL );
589 }
590
591 /*
592 +--------------------------------------------------------------------+
593 | PROJECT : GSM-PS (6147) MODULE : CMH_SSQ |
594 | STATE : code ROUTINE : qAT_PercentRPCT |
595 +--------------------------------------------------------------------+
596
597 PURPOSE : This is the functional counterpart to the %RPCT AT command
598 which is responsible to query the raw SIM data for PUCT.
599
600 <rpuct> : PUCT values.
601 */
602
603 GLOBAL T_ACI_RETURN qAT_PercentRPCT( T_ACI_CMD_SRC srcId,
604 T_ACI_RPCT_VAL *rpuct)
605 {
606 T_puct_raw raw_puct;
607
608 TRACE_FUNCTION ("qAT_PercentRPCT ()");
609
610 /*
611 *-------------------------------------------------------------------
612 * request value from advice of charge module.
613 *-------------------------------------------------------------------
614 */
615 aoc_get_values (AOC_PUCT_RAW, (T_puct_raw *)&raw_puct);
616
617 memcpy(rpuct->currency, raw_puct.currency, MAX_CUR_LEN);
618 rpuct->eppu = raw_puct.eppu;
619 rpuct->exp = raw_puct.exp;
620 rpuct->sexp = raw_puct.sexp;
621
622 return( AT_CMPL );
623 }
624
625 /*
626 +--------------------------------------------------------------------+
627 | PROJECT : GSM-PS (6147) MODULE : CMH_SSQ |
628 | STATE : code ROUTINE : qAT_PercentPVRF |
629 +--------------------------------------------------------------------+
630
631 PURPOSE : This is the functional counterpart to the %PVRF AT command
632 which is responsible to query the current counter for
633 PIN and PUK.
634
635 <pn1Cnt> : PIN 1 counter.
636 <pn2Cnt> : PIN 2 counter.
637 <pk1Cnt> : PUK 1 counter.
638 <pk2Cnt> : PUK 2 counter.
639 <ps1> : PIN 1 status.
640 <ps2> : PIN 2 status.
641 */
642
643 GLOBAL T_ACI_RETURN qAT_PercentPVRF( T_ACI_CMD_SRC srcId,
644 SHORT *pn1Cnt,
645 SHORT *pn2Cnt,
646 SHORT *pk1Cnt,
647 SHORT *pk2Cnt,
648 T_ACI_PVRF_STAT *ps1,
649 T_ACI_PVRF_STAT *ps2 )
650 {
651 TRACE_FUNCTION ("qAT_PercentPVRF ()");
652
653 /*
654 *-------------------------------------------------------------------
655 * read PIN/PUK counter values
656 *-------------------------------------------------------------------
657 */
658 if( simShrdPrm.SIMStat NEQ SS_OK AND
659 simShrdPrm.SIMStat NEQ SS_BLKD )
660 {
661 *pn1Cnt = ACI_NumParmNotPresent;
662 *pn2Cnt = ACI_NumParmNotPresent;
663 *pk1Cnt = ACI_NumParmNotPresent;
664 *pk2Cnt = ACI_NumParmNotPresent;
665 *ps1 = PVRF_STAT_NotPresent;
666 *ps2 = PVRF_STAT_NotPresent;
667 }
668 else
669 {
670 *pn1Cnt = simShrdPrm.pn1Cnt;
671 *pn2Cnt = simShrdPrm.pn2Cnt;
672 *pk1Cnt = simShrdPrm.pk1Cnt;
673 *pk2Cnt = simShrdPrm.pk2Cnt;
674
675 switch( simShrdPrm.pn1Stat )
676 {
677 case( PS_RDY ): *ps1 = PVRF_STAT_NotRequired; break;
678 case( PS_PIN1 ): *ps1 = PVRF_STAT_Required; break;
679 default: *ps1 = PVRF_STAT_NotPresent;
680 }
681
682 switch( simShrdPrm.pn2Stat )
683 {
684 case( PS_RDY ): *ps2 = PVRF_STAT_NotRequired; break;
685 case( PS_PIN2 ): *ps2 = PVRF_STAT_Required; break;
686 default: *ps2 = PVRF_STAT_NotPresent;
687 }
688 }
689
690 return( AT_CMPL );
691 }
692
693 /*
694 +--------------------------------------------------------------------+
695 | PROJECT : GSM-PS (6147) MODULE : CMH_SIMS |
696 | STATE : code ROUTINE : qAT_PlusCNUM |
697 +--------------------------------------------------------------------+
698
699 PURPOSE : This is the functional counterpart to the +CNUM AT command
700 which is responsible for reading the subscriber number.
701
702 <mode>: indicates whether reading starts or continues
703 */
704 GLOBAL T_ACI_RETURN qAT_PlusCNUM ( T_ACI_CMD_SRC srcId,
705 T_ACI_CNUM_MOD mode )
706 {
707 T_SIM_CMD_PRM * pSIMCmdPrm; /* points to SIM command parameters */
708
709 UBYTE i; /* used for counting */
710
711 TRACE_FUNCTION ("qAT_PlusCNUM()");
712
713 /*
714 *-------------------------------------------------------------------
715 * check command source
716 *-------------------------------------------------------------------
717 */
718 if(!cmh_IsVldCmdSrc (srcId))
719 {
720 return( AT_FAIL );
721 }
722
723 pSIMCmdPrm = &cmhPrm[srcId].simCmdPrm;
724
725 /*
726 *-------------------------------------------------------------------
727 * check entity status
728 *-------------------------------------------------------------------
729 */
730 if( simEntStat.curCmd NEQ AT_CMD_NONE )
731
732 return( AT_BUSY );
733
734 /*
735 *-------------------------------------------------------------------
736 * check whether there are more EF to read
737 *-------------------------------------------------------------------
738 */
739 if ( mode EQ CNUM_MOD_NextRead AND
740 pSIMCmdPrm -> CNUMActRec EQ CNUMMaxRec )
741 {
742 return ( AT_CMPL );
743 }
744
745 /*
746 *-------------------------------------------------------------------
747 * process parameter <mode>
748 *-------------------------------------------------------------------
749 */
750 switch ( mode )
751 {
752 case ( CNUM_MOD_NewRead ):
753 pSIMCmdPrm -> CNUMActRec = 1;
754 pSIMCmdPrm -> CNUMOutput = 0;
755 break;
756
757 case ( CNUM_MOD_NextRead ):
758 pSIMCmdPrm -> CNUMActRec++;
759 break;
760
761 default:
762 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
763 return( AT_FAIL );
764 }
765
766 /*
767 *-------------------------------------------------------------------
768 * reset to start of MSISDN list
769 *-------------------------------------------------------------------
770 */
771 CNUMMsisdnIdx = 0;
772
773 /*
774 *-------------------------------------------------------------------
775 * invalidate contents of MSISDN list
776 *-------------------------------------------------------------------
777 */
778 for ( i = 0; i < MAX_MSISDN; i++ )
779
780 CNUMMsisdn[i].vldFlag = FALSE;
781
782 /*
783 *-------------------------------------------------------------------
784 * request EF MSISDN from SIM
785 *-------------------------------------------------------------------
786 */
787 return cmhSIM_ReqMsisdn ( srcId, pSIMCmdPrm -> CNUMActRec );
788 }
789
790 /*
791 +--------------------------------------------------------------------+
792 | PROJECT : GSM-F&D (8411) MODULE : CMH_SIMS |
793 | STATE : code ROUTINE : cmhSIM_ReqMsisdn |
794 +--------------------------------------------------------------------+
795
796 PURPOSE : This function starts reading of EF MSISDN from SIM.
797 */
798
799 GLOBAL T_ACI_RETURN cmhSIM_ReqMsisdn ( T_ACI_CMD_SRC srcId,
800 UBYTE record )
801 {
802 UBYTE length;
803
804 TRACE_FUNCTION ("cmhSIM_ReqMsisdn()");
805
806 if (record EQ 1)
807 length = NOT_PRESENT_8BIT;
808 else
809 length = CNUMLenEfMsisdn;
810
811 return cmhSIM_ReadRecordEF (srcId, AT_CMD_CNUM, FALSE, NULL, SIM_MSISDN,
812 record, length, NULL, cmhSIM_CnfMsisdn);
813 }
814
815 /*
816 +--------------------------------------------------------------------+
817 | PROJECT : GSM-F&D (8411) MODULE : CMH_SIMS |
818 | STATE : code ROUTINE : cmhSIM_ReqCcp |
819 +--------------------------------------------------------------------+
820
821 PURPOSE : This function starts reading of EF CCP from SIM.
822 */
823
824 GLOBAL T_ACI_RETURN cmhSIM_ReqCcp ( T_ACI_CMD_SRC srcId,
825 UBYTE record )
826 {
827 TRACE_FUNCTION ("cmhSIM_ReqCcp()");
828
829 return cmhSIM_ReadRecordEF (srcId, AT_CMD_CNUM, FALSE, NULL, SIM_CCP, record,
830 ACI_SIZE_EF_CCP, NULL, cmhSIM_CnfCcp);
831 }
832
833 /*
834 +--------------------------------------------------------------------+
835 | PROJECT : GSM-PS (6147) MODULE : CMH_SSQ |
836 | STATE : code ROUTINE : qAT_PlusCPOL |
837 +--------------------------------------------------------------------+
838
839 PURPOSE : This is the functional counterpart to the +CPOL AT command
840 which is responsible for reading the preferred operator
841 list.
842
843 <startIdx>: start index to read from
844 <lastIdx>: buffer for last index read
845 <operLst>: buffer for operator list
846 <mode>: supplemental read mode
847 */
848
849 GLOBAL T_ACI_RETURN qAT_PlusCPOL ( T_ACI_CMD_SRC srcId,
850 SHORT startIdx,
851 SHORT *lastIdx,
852 T_ACI_CPOL_OPDESC *operLst,
853 T_ACI_CPOL_MOD mode )
854
855 {
856 T_SIM_CMD_PRM * pSIMCmdPrm; /* points to SIM command parameters */
857
858 TRACE_FUNCTION ("qAT_PlusCPOL()");
859
860 /*
861 *-------------------------------------------------------------------
862 * check command source
863 *-------------------------------------------------------------------
864 */
865 if(!cmh_IsVldCmdSrc (srcId))
866 {
867 return( AT_FAIL );
868 }
869
870 pSIMCmdPrm = &cmhPrm[srcId].simCmdPrm;
871
872 /*
873 *-------------------------------------------------------------------
874 * check <mode> parameter
875 *-------------------------------------------------------------------
876 */
877 switch( mode )
878 {
879 case( CPOL_MOD_NotPresent ):
880 case( CPOL_MOD_CompactList ):
881
882 break;
883
884 case( CPOL_MOD_Insert ):
885 default:
886 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
887 return( AT_FAIL );
888 }
889
890 /*
891 *-------------------------------------------------------------------
892 * check if PLMNsel EF has to be read
893 *-------------------------------------------------------------------
894 */
895 if( startIdx EQ 0 OR EfPLMNselStat EQ EF_STAT_UNKNWN )
896 {
897 /*
898 *-------------------------------------------------------------
899 * check entity status
900 *-------------------------------------------------------------
901 */
902 if( simEntStat.curCmd NEQ AT_CMD_NONE )
903
904 return( AT_BUSY );
905
906 pSIMCmdPrm -> CPOLidx = (startIdx EQ 0)?1:startIdx;
907 pSIMCmdPrm -> CPOLmode = mode;
908 pSIMCmdPrm -> CPOLact = CPOL_ACT_Read;
909
910 /*
911 *-------------------------------------------------------------
912 * request EF PLMN SEL from SIM
913 *-------------------------------------------------------------
914 */
915 /* Implements Measure 150 and 159 */
916 return cmhSIM_Req_or_Write_PlmnSel( srcId, ACT_RD_DAT );
917 }
918
919 /*
920 *-------------------------------------------------------------
921 * fill PLMN SEL list
922 *-------------------------------------------------------------
923 */
924 if( startIdx * ACI_LEN_PLMN_SEL_NTRY > CPOLSimEfDataLen )
925 {
926 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_InvIdx );
927 return( AT_FAIL );
928 }
929
930 if( mode EQ CPOL_MOD_CompactList )
931 {
932 cmhSIM_CmpctPlmnSel( CPOLSimEfDataLen, CPOLSimEfData );
933 }
934
935 *lastIdx = cmhSIM_FillPlmnSelList((UBYTE)startIdx,
936 pSIMCmdPrm->CPOLfrmt,
937 operLst,
938 CPOLSimEfDataLen,
939 CPOLSimEfData);
940 return ( AT_CMPL );
941
942 }
943
944 /*
945 +--------------------------------------------------------------------+
946 | PROJECT : GSM-PS (6147) MODULE : CMH_SSQ |
947 | STATE : code ROUTINE : tAT_PlusCPOL |
948 +--------------------------------------------------------------------+
949
950 PURPOSE : This is the functional counterpart to the +CPOL AT command
951 which is responsible for testing the supported preferred
952 operator list length.
953
954 <lastIdx>: maximum number of entries
955 <usdNtry>: number of used entries
956 */
957
958 GLOBAL T_ACI_RETURN tAT_PlusCPOL ( T_ACI_CMD_SRC srcId,
959 SHORT * lastIdx,
960 SHORT * usdNtry )
961 {
962 T_SIM_CMD_PRM * pSIMCmdPrm; /* points to SIM command parameters */
963
964 TRACE_FUNCTION ("tAT_PlusCPOL()");
965
966 /*
967 *-------------------------------------------------------------------
968 * check command source
969 *-------------------------------------------------------------------
970 */
971 if(!cmh_IsVldCmdSrc (srcId))
972 {
973 return( AT_FAIL );
974 }
975
976 pSIMCmdPrm = &cmhPrm[srcId].simCmdPrm;
977
978 /*
979 *-------------------------------------------------------------------
980 * check if PLMNsel EF has to be read
981 *-------------------------------------------------------------------
982 */
983 if( EfPLMNselStat EQ EF_STAT_UNKNWN )
984 {
985 /*
986 *-------------------------------------------------------------
987 * check entity status
988 *-------------------------------------------------------------
989 */
990 if( simEntStat.curCmd NEQ AT_CMD_NONE )
991
992 return( AT_BUSY );
993
994 pSIMCmdPrm -> CPOLact = CPOL_ACT_Test;
995
996 /*
997 *-------------------------------------------------------------
998 * request EF PLMN SEL from SIM
999 *-------------------------------------------------------------
1000 */
1001 /* Implements Measure 150 and 159 */
1002 return cmhSIM_Req_or_Write_PlmnSel( srcId, ACT_RD_DAT );
1003 }
1004
1005 /*
1006 *-------------------------------------------------------------
1007 * return number of supported entries
1008 *-------------------------------------------------------------
1009 */
1010 *lastIdx = CPOLSimEfDataLen / ACI_LEN_PLMN_SEL_NTRY;
1011
1012 *usdNtry = cmhSIM_UsdPlmnSelNtry( CPOLSimEfDataLen, CPOLSimEfData );
1013
1014 return ( AT_CMPL );
1015
1016 }
1017
1018
1019 /*
1020 +-------------------------------------------------------------------+
1021 | PROJECT : GSM-PS (6147) MODULE : CMH_SIMQ |
1022 | ROUTINE : qAT_PercentCPRI |
1023 +-------------------------------------------------------------------+
1024
1025 PURPOSE : This is the functional counterpart to the %CPRI AT command
1026 which is responsible for reading the ciphering indicator
1027 mode.
1028 */
1029 GLOBAL T_ACI_RETURN qAT_PercentCPRI( T_ACI_CMD_SRC srcId,
1030 UBYTE *mode )
1031 {
1032 TRACE_FUNCTION ("qAT_PercentCPRI()");
1033
1034 if( !cmh_IsVldCmdSrc( srcId ) )
1035 {
1036 return( AT_FAIL );
1037 }
1038 *mode = simShrdPrm.ciSIMEnabled;
1039 return( AT_CMPL );
1040 }
1041
1042 #ifdef TI_PS_FF_AT_P_CMD_ATR
1043 /*
1044 +-------------------------------------------------------------------+
1045 | PROJECT : GSM-PS (6147) MODULE : CMH_SIMQ |
1046 | ROUTINE : qAT_PercentATR |
1047 +-------------------------------------------------------------------+
1048
1049 PURPOSE : This is the functional counterpart to the %ATR AT command
1050 which is responsible for reading the SIM phase and ATR
1051 (answer to reset information).
1052 */
1053 GLOBAL T_ACI_RETURN qAT_PercentATR( T_ACI_CMD_SRC srcId,
1054 UBYTE *phase,
1055 UBYTE *atr_len,
1056 UBYTE *atr_info)
1057 {
1058 TRACE_FUNCTION ("qAT_PercentATR()");
1059
1060 if( !cmh_IsVldCmdSrc( srcId ) )
1061 {
1062 return( AT_FAIL );
1063 }
1064
1065 *phase = simShrdPrm.crdPhs; /* SIM Phase... value is 0xFF if no phase is available*/
1066
1067
1068 *atr_len = simShrdPrm.atr.len; /* ATR length... 0 if no ATR data is available*/
1069 if (simShrdPrm.atr.len)
1070 {
1071 memcpy(atr_info, simShrdPrm.atr.data, simShrdPrm.atr.len);
1072 }
1073
1074 return( AT_CMPL );
1075 }
1076 #endif /* TI_PS_FF_AT_P_CMD_ATR */
1077
1078 #ifdef FF_DUAL_SIM
1079 /*
1080 +--------------------------------------------------------------------+
1081 | PROJECT : GSM-PS (6147) MODULE : CMH_SIMQ |
1082 | STATE : code ROUTINE : qAT_PercentSIM |
1083 +--------------------------------------------------------------------+
1084
1085 PURPOSE : This is the functional counterpart to the %SIM? AT command
1086 which returns the currently powered on SIM Number.
1087
1088 <sim_num>: sim_number.
1089 */
1090
1091 GLOBAL T_ACI_RETURN qAT_PercentSIM ( T_ACI_CMD_SRC srcId,
1092 UBYTE *sim_num )
1093 {
1094 TRACE_FUNCTION ("qAT_PercentSIM()");
1095
1096 /*
1097 *-------------------------------------------------------------------
1098 * check command source
1099 *-------------------------------------------------------------------
1100 */
1101 if(!cmh_IsVldCmdSrc (srcId))
1102 {
1103 return( AT_FAIL );
1104 }
1105
1106 /*
1107 *-------------------------------------------------------------------
1108 * fill in parameters
1109 *-------------------------------------------------------------------
1110 */
1111 *sim_num = simShrdPrm.SIM_Powered_on;
1112
1113 return( AT_CMPL );
1114 }
1115 #endif /*FF_DUAL_SIM*/
1116
1117
1118 #ifdef FF_CPHS_REL4
1119 /*
1120 +--------------------------------------------------------------------+
1121 | PROJECT : GSM-PS (6147) MODULE : CMH_SIMS |
1122 | STATE : code ROUTINE : qAT_PercentCFIS |
1123 +--------------------------------------------------------------------+
1124
1125 PURPOSE : This is the functional counterpart to the +CNUM AT command
1126 which is responsible for reading the subscriber number.
1127
1128 <mode>: indicates whether reading starts or continues
1129 */
1130 GLOBAL T_ACI_RETURN qAT_PercentCFIS ( T_ACI_CMD_SRC srcId,
1131 UBYTE index )
1132 {
1133
1134
1135 TRACE_FUNCTION ("qAT_PercntCFIS()");
1136
1137 /*
1138 *-------------------------------------------------------------------
1139 * check command source
1140 *-------------------------------------------------------------------
1141 */
1142 if(!cmh_IsVldCmdSrc (srcId))
1143 {
1144 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
1145 return( AT_FAIL );
1146 }
1147
1148 /* Make sure everytime query is called ,CFISIndex
1149 must be initialised to ZERO
1150 */
1151 CFISIndex = 0;
1152
1153 if(index EQ NOT_PRESENT_8BIT)
1154 {
1155 CFISIndex = 1;
1156 index =1;
1157 }
1158 return cmhSIM_ReadRecordEF (srcId, AT_CMD_P_CFIS, SIM_CFIS,
1159 index, NOT_PRESENT_8BIT, NULL, cmhSIM_RdCnfCfis);
1160 }
1161 /*
1162 +--------------------------------------------------------------------+
1163 | PROJECT : GSM-PS (6147) MODULE : CMH_SIMS |
1164 | STATE : code ROUTINE : qAT_PercentMWIS |
1165 +--------------------------------------------------------------------+
1166
1167 PURPOSE : This is the functional counterpart to the %MWIS AT command
1168 which is responsible for reading the MWIS records.
1169 */
1170
1171 GLOBAL T_ACI_RETURN qAT_PercentMWIS ( T_ACI_CMD_SRC srcId,
1172 UBYTE mspId )
1173 {
1174
1175 TRACE_FUNCTION ("qAT_PercntMWIS()");
1176
1177 /*
1178 *-------------------------------------------------------------------
1179 * check command source
1180 *-------------------------------------------------------------------
1181 */
1182 if(!cmh_IsVldCmdSrc (srcId))
1183 {
1184 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
1185 return( AT_FAIL );
1186 }
1187
1188 /* Make sure everytime query is called ,MWISIndex
1189 must be initialised to ZERO
1190 */
1191 MWISIndex = 0;
1192
1193 if(mspId EQ NOT_PRESENT_8BIT)
1194 {
1195 MWISIndex = 1;
1196 mspId =1;
1197 }
1198 return cmhSIM_ReadRecordEF (srcId, AT_CMD_P_MWIS, SIM_MWIS,
1199 mspId, NOT_PRESENT_8BIT, NULL, cmhSIM_RdCnfMwis);
1200 }
1201
1202 /*
1203 +--------------------------------------------------------------------+
1204 | PROJECT : GSM-PS (6147) MODULE : CMH_SIMQ |
1205 | STATE : code ROUTINE : qAT_PercentMBI |
1206 +--------------------------------------------------------------------+
1207
1208 PURPOSE : This is the functional counterpart to the %MBI AT command
1209 which is responsible for reading the Mailbox Identifier.
1210
1211 */
1212 GLOBAL T_ACI_RETURN qAT_PercentMBI ( T_ACI_CMD_SRC srcId,
1213 UBYTE index )
1214 {
1215
1216 MBI_Index = 0; /* Intialise the index value */
1217
1218 TRACE_FUNCTION ("qAT_PercntMBI()");
1219
1220 /*
1221 *-------------------------------------------------------------------
1222 * check command source
1223 *-------------------------------------------------------------------
1224 */
1225 if(!cmh_IsVldCmdSrc (srcId))
1226 {
1227 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
1228 return( AT_FAIL );
1229 }
1230
1231 /* If index not present then start reading from the first record
1232 till the maximum record */
1233 if (index EQ NOT_PRESENT_8BIT)
1234 {
1235 MBI_Index = 1;
1236 index = 1;
1237 }
1238
1239 return cmhSIM_ReadRecordEF (srcId, AT_CMD_P_MBI, SIM_MBI,
1240 index, NOT_PRESENT_8BIT, NULL, cmhSIM_RdCnfMbi);
1241 }
1242 /*
1243 +--------------------------------------------------------------------+
1244 | PROJECT : GSM-PS (6147) MODULE : CMH_SIMQ |
1245 | STATE : code ROUTINE : qAT_PercentMBDN |
1246 +--------------------------------------------------------------------+
1247
1248 PURPOSE : This is the functional counterpart to the %MBDN AT command
1249 which is responsible for reading the Mailbox number.
1250
1251 */
1252 GLOBAL T_ACI_RETURN qAT_PercentMBDN ( T_ACI_CMD_SRC srcId,
1253 UBYTE index )
1254 {
1255
1256
1257 TRACE_FUNCTION ("qAT_PercntMBDN()");
1258
1259 /*
1260 *-------------------------------------------------------------------
1261 * check command source
1262 *-------------------------------------------------------------------
1263 */
1264 if(!cmh_IsVldCmdSrc (srcId))
1265 {
1266 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
1267 return( AT_FAIL );
1268 }
1269 return cmhSIM_ReadRecordEF (srcId, AT_CMD_P_MBDN, SIM_MBDN,
1270 index, NOT_PRESENT_8BIT, NULL, cmhSIM_RdCnfMbdn);
1271 }
1272 #endif/* FF_CPHS_REL4 */
1273
1274 /*==== EOF ========================================================*/