comparison src/aci2/aci/cmh_simq.c @ 3:93999a60b835

src/aci2, src/condat2: import of g23m/condat source pieces from TCS211
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 26 Sep 2016 00:29:36 +0000
parents
children
comparison
equal deleted inserted replaced
2:c41a534f33c6 3:93999a60b835
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 "aci_all.h"
27
28 #include "aci_cmh.h"
29
30 #ifdef FAX_AND_DATA
31 #include "aci_fd.h"
32 #endif /* of #ifdef FAX_AND_DATA */
33
34 #ifdef UART
35 #include "dti.h"
36 #include "dti_conn_mng.h"
37 #endif
38
39 #include "psa.h"
40 #include "psa_sim.h"
41 #include "cmh.h"
42 #include "cmh_sim.h"
43 #include "cmh_sms.h"
44
45 /* To include AciSLockShrd */
46 #include "aci_ext_pers.h"
47 #include "aci_slock.h"
48
49
50 #include "aoc.h"
51
52 /*==== CONSTANTS ==================================================*/
53
54 /*==== EXPORT =====================================================*/
55
56 /*==== VARIABLES ==================================================*/
57
58 /*==== FUNCTIONS ==================================================*/
59
60
61 /*
62 +--------------------------------------------------------------------+
63 | PROJECT : GSM-PS (6147) MODULE : CMH_SIMS |
64 | STATE : code ROUTINE : qAT_PercentSECS |
65 +--------------------------------------------------------------------+
66
67 PURPOSE : This is the functional counterpart to the %SECS? AT command
68 which is responsible to query the status of the Security Code.
69
70 */
71
72
73 GLOBAL T_ACI_RETURN qAT_PercentSECS ( T_ACI_CMD_SRC srcId,T_ACI_SECS_STA *status)
74 {
75 T_SIMLOCK_STATUS result = SIMLOCK_FAIL;
76
77 TRACE_FUNCTION ("qAT_PercentSECS()");
78
79 result = aci_ext_personalisation_CS_get_status();
80
81 switch (result)
82 {
83 case SIMLOCK_ENABLED:
84 *status = SECS_STA_Enable;
85 return AT_CMPL;
86 case SIMLOCK_DISABLED:
87 *status = SECS_STA_Disable;
88 return AT_CMPL;
89 default:
90 *status = SECS_STA_NotPresent;
91 return AT_FAIL;
92 }
93 }
94
95
96 /*
97 +--------------------------------------------------------------------+
98 | PROJECT : GSM-PS (6147) MODULE : CMH_CCQ |
99 | STATE : code ROUTINE : qAT_PlusCFUN |
100 +--------------------------------------------------------------------+
101
102 PURPOSE : This is the functional counterpart to the +CFUN? AT command
103 which returns the current setting for phone functionality.
104
105 <fun>: phone functionality.
106 */
107
108 GLOBAL T_ACI_RETURN qAT_PlusCFUN ( T_ACI_CMD_SRC srcId,
109 T_ACI_CFUN_FUN *fun )
110 {
111 TRACE_FUNCTION ("qAT_PlusCFUN()");
112
113 /*
114 *-------------------------------------------------------------------
115 * check command source
116 *-------------------------------------------------------------------
117 */
118 if(!cmh_IsVldCmdSrc (srcId))
119 {
120 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
121 return( AT_FAIL );
122 }
123
124 /*
125 *-------------------------------------------------------------------
126 * fill in parameters
127 *-------------------------------------------------------------------
128 */
129 *fun = CFUNfun;
130
131 return( AT_CMPL );
132 }
133
134 /*
135 +--------------------------------------------------------------------+
136 | PROJECT : GSM-PS (6147) MODULE : CMH_CCQ |
137 | STATE : code ROUTINE : qAT_PlusCPIN |
138 +--------------------------------------------------------------------+
139
140 PURPOSE : This is the functional counterpart to the +CPIN? AT command
141 which returns the current PIN status.
142
143 <code>: PIN status.
144 */
145
146 GLOBAL T_ACI_RETURN qAT_PlusCPIN (T_ACI_CMD_SRC srcId,
147 T_ACI_CPIN_RSLT *code)
148 {
149 T_SIM_SET_PRM * pSIMSetPrm; /* points to SIM parameter set */
150
151 TRACE_FUNCTION ("qAT_PlusCPIN()");
152
153 /*
154 *-------------------------------------------------------------------
155 * check command source
156 *-------------------------------------------------------------------
157 */
158 if(!cmh_IsVldCmdSrc (srcId))
159 {
160 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
161 return( AT_FAIL );
162 }
163
164 pSIMSetPrm = &simShrdPrm.setPrm[srcId];
165
166 /*
167 *-------------------------------------------------------------------
168 * check SIM status
169 *-------------------------------------------------------------------
170 */
171 if( simShrdPrm.SIMStat NEQ SS_OK AND
172 simShrdPrm.SIMStat NEQ SS_BLKD )
173 {
174 pSIMSetPrm -> actProc = SIM_INITIALISATION;
175
176 simEntStat.curCmd = AT_CMD_CPIN;
177 simEntStat.entOwn = simShrdPrm.owner = srcId;
178 simShrdPrm.PINQuery = 1;
179
180 if( psaSIM_ActivateSIM() < 0 ) /* activate SIM card */
181 {
182 TRACE_EVENT( "FATAL RETURN psaSIM in +CPIN" );
183 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Internal );
184 simShrdPrm.PINQuery = 0;
185 return( AT_FAIL );
186 }
187 return( AT_EXCT );
188 }
189
190 #ifdef SIM_PERS
191 /*
192 *-------------------------------------------------------------------
193 * check PIN status
194 *-------------------------------------------------------------------
195 */
196 /* OVK Check first if any Personalisations are active */
197 if ( AciSLockShrd.blocked EQ TRUE)
198 {
199 TRACE_EVENT_P3("qAT_PlusCPIN: Curr Lock = %d, Status = %d %s", AciSLockShrd.current_lock, AciSLockShrd.status[AciSLockShrd.current_lock],"" );
200
201 switch (AciSLockShrd.current_lock)
202 {
203 case SIMLOCK_NETWORK:
204 if (AciSLockShrd.status[AciSLockShrd.current_lock] EQ SIMLOCK_BLOCKED)
205 *code = CPIN_RSLT_PhNetPukReq;
206 else
207 *code = CPIN_RSLT_PhNetPinReq;
208 break;
209 case SIMLOCK_NETWORK_SUBSET:
210 if (AciSLockShrd.status[AciSLockShrd.current_lock] EQ SIMLOCK_BLOCKED)
211 *code = CPIN_RSLT_PhNetSubPukReq;
212 else
213 *code = CPIN_RSLT_PhNetSubPinReq;
214 break;
215 case SIMLOCK_SERVICE_PROVIDER:
216 if (AciSLockShrd.status[AciSLockShrd.current_lock] EQ SIMLOCK_BLOCKED)
217 *code = CPIN_RSLT_PhSPPukReq;
218 else
219 *code = CPIN_RSLT_PhSPPinReq;
220 break;
221 case SIMLOCK_CORPORATE:
222 if (AciSLockShrd.status[AciSLockShrd.current_lock] EQ SIMLOCK_BLOCKED)
223 *code = CPIN_RSLT_PhCorpPukReq;
224 else
225 *code = CPIN_RSLT_PhCorpPinReq;
226 break;
227 case SIMLOCK_SIM:
228
229 *code = CPIN_RSLT_PhSimPinReq;
230 break;
231 case SIMLOCK_FIRST_SIM:
232 if (AciSLockShrd.status[AciSLockShrd.current_lock] EQ SIMLOCK_BLOCKED)
233 *code = CPIN_RSLT_PhFSimPukReq;
234 else
235 *code = CPIN_RSLT_PhFSimPinReq;
236 break;
237 default:
238 *code = CPIN_RSLT_NotPresent;
239 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_DataCorrupt );
240 return( AT_FAIL );
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 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
430 return( AT_FAIL );
431 }
432
433 pSIMSetPrm = &simShrdPrm.setPrm[srcId];
434
435 /*
436 *-------------------------------------------------------------------
437 * check entity status
438 *-------------------------------------------------------------------
439 */
440 switch( simShrdPrm.SIMStat )
441 {
442 case( SS_OK ):
443 /*
444 *-----------------------------------------------------------------
445 * check if command executable
446 *-----------------------------------------------------------------
447 */
448 if((simShrdPrm.PINStat NEQ PS_RDY) AND (!cmhSMS_checkSIM ()))
449 {
450 return AT_FAIL;
451 }
452
453 /*
454 * Check required for CIMI after SIM_REMOVE_IND and SIM_ACTIVATE_IND
455 * with SIMStat as SS_OK and PINStat as PS_RDY
456 * but before receiving SIM_MMI_INSERT_IND
457 */
458 else if(simShrdPrm.imsi.c_field EQ 0)
459 {
460 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_Unknown);
461 return AT_FAIL;
462 }
463 else
464 {
465 psaSIM_cnvrtIMSI2ASCII( imsi );
466 return( AT_CMPL );
467 }
468
469 case( NO_VLD_SS ):
470
471 if( simEntStat.curCmd NEQ AT_CMD_NONE ) return( AT_BUSY );
472
473 pSIMSetPrm -> actProc = SIM_INITIALISATION;
474
475 simEntStat.curCmd = AT_CMD_CIMI;
476 simEntStat.entOwn = simShrdPrm.owner = 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 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
721 return( AT_FAIL );
722 }
723
724 pSIMCmdPrm = &cmhPrm[srcId].simCmdPrm;
725
726 /*
727 *-------------------------------------------------------------------
728 * check entity status
729 *-------------------------------------------------------------------
730 */
731 if( simEntStat.curCmd NEQ AT_CMD_NONE )
732
733 return( AT_BUSY );
734
735 /*
736 *-------------------------------------------------------------------
737 * check whether there are more EF to read
738 *-------------------------------------------------------------------
739 */
740 if ( mode EQ CNUM_MOD_NextRead AND
741 pSIMCmdPrm -> CNUMActRec EQ CNUMMaxRec )
742 {
743 return ( AT_CMPL );
744 }
745
746 /*
747 *-------------------------------------------------------------------
748 * process parameter <mode>
749 *-------------------------------------------------------------------
750 */
751 switch ( mode )
752 {
753 case ( CNUM_MOD_NewRead ):
754 pSIMCmdPrm -> CNUMActRec = 1;
755 pSIMCmdPrm -> CNUMOutput = 0;
756 break;
757
758 case ( CNUM_MOD_NextRead ):
759 pSIMCmdPrm -> CNUMActRec++;
760 break;
761
762 default:
763 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
764 return( AT_FAIL );
765 }
766
767 /*
768 *-------------------------------------------------------------------
769 * reset to start of MSISDN list
770 *-------------------------------------------------------------------
771 */
772 CNUMMsisdnIdx = 0;
773
774 /*
775 *-------------------------------------------------------------------
776 * invalidate contents of MSISDN list
777 *-------------------------------------------------------------------
778 */
779 for ( i = 0; i < MAX_MSISDN; i++ )
780
781 CNUMMsisdn[i].vldFlag = FALSE;
782
783 /*
784 *-------------------------------------------------------------------
785 * request EF MSISDN from SIM
786 *-------------------------------------------------------------------
787 */
788 return cmhSIM_ReqMsisdn ( srcId, pSIMCmdPrm -> CNUMActRec );
789 }
790
791 /*
792 +--------------------------------------------------------------------+
793 | PROJECT : GSM-F&D (8411) MODULE : CMH_SIMS |
794 | STATE : code ROUTINE : cmhSIM_ReqMsisdn |
795 +--------------------------------------------------------------------+
796
797 PURPOSE : This function starts reading of EF MSISDN from SIM.
798 */
799
800 GLOBAL T_ACI_RETURN cmhSIM_ReqMsisdn ( T_ACI_CMD_SRC srcId,
801 UBYTE record )
802 {
803 UBYTE length;
804
805 TRACE_FUNCTION ("cmhSIM_ReqMsisdn()");
806
807 if (record EQ 1)
808 length = NOT_PRESENT_8BIT;
809 else
810 length = CNUMLenEfMsisdn;
811
812 return cmhSIM_ReadRecordEF (srcId, AT_CMD_CNUM, SIM_MSISDN,
813 record, length, NULL, cmhSIM_CnfMsisdn);
814 }
815
816 /*
817 +--------------------------------------------------------------------+
818 | PROJECT : GSM-F&D (8411) MODULE : CMH_SIMS |
819 | STATE : code ROUTINE : cmhSIM_ReqCcp |
820 +--------------------------------------------------------------------+
821
822 PURPOSE : This function starts reading of EF CCP from SIM.
823 */
824
825 GLOBAL T_ACI_RETURN cmhSIM_ReqCcp ( T_ACI_CMD_SRC srcId,
826 UBYTE record )
827 {
828 TRACE_FUNCTION ("cmhSIM_ReqCcp()");
829
830 return cmhSIM_ReadRecordEF (srcId, AT_CMD_CNUM, SIM_CCP, record,
831 ACI_SIZE_EF_CCP, NULL, cmhSIM_CnfCcp);
832 }
833
834 /*
835 +--------------------------------------------------------------------+
836 | PROJECT : GSM-PS (6147) MODULE : CMH_SSQ |
837 | STATE : code ROUTINE : qAT_PlusCPOL |
838 +--------------------------------------------------------------------+
839
840 PURPOSE : This is the functional counterpart to the +CPOL AT command
841 which is responsible for reading the preferred operator
842 list.
843
844 <startIdx>: start index to read from
845 <lastIdx>: buffer for last index read
846 <operLst>: buffer for operator list
847 <mode>: supplemental read mode
848 */
849
850 GLOBAL T_ACI_RETURN qAT_PlusCPOL ( T_ACI_CMD_SRC srcId,
851 SHORT startIdx,
852 SHORT *lastIdx,
853 T_ACI_CPOL_OPDESC *operLst,
854 T_ACI_CPOL_MOD mode )
855
856 {
857 T_SIM_CMD_PRM * pSIMCmdPrm; /* points to SIM command parameters */
858
859 TRACE_FUNCTION ("qAT_PlusCPOL()");
860
861 /*
862 *-------------------------------------------------------------------
863 * check command source
864 *-------------------------------------------------------------------
865 */
866 if(!cmh_IsVldCmdSrc (srcId))
867 {
868 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
869 return( AT_FAIL );
870 }
871
872 pSIMCmdPrm = &cmhPrm[srcId].simCmdPrm;
873
874 /*
875 *-------------------------------------------------------------------
876 * check <mode> parameter
877 *-------------------------------------------------------------------
878 */
879 switch( mode )
880 {
881 case( CPOL_MOD_NotPresent ):
882 case( CPOL_MOD_CompactList ):
883
884 break;
885
886 case( CPOL_MOD_Insert ):
887 default:
888 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
889 return( AT_FAIL );
890 }
891
892 /*
893 *-------------------------------------------------------------------
894 * check if PLMNsel EF has to be read
895 *-------------------------------------------------------------------
896 */
897 if( startIdx EQ 0 OR EfPLMNselStat EQ EF_STAT_UNKNWN )
898 {
899 /*
900 *-------------------------------------------------------------
901 * check entity status
902 *-------------------------------------------------------------
903 */
904 if( simEntStat.curCmd NEQ AT_CMD_NONE )
905
906 return( AT_BUSY );
907
908 pSIMCmdPrm -> CPOLidx = (startIdx EQ 0)?1:startIdx;
909 pSIMCmdPrm -> CPOLmode = mode;
910 pSIMCmdPrm -> CPOLact = CPOL_ACT_Read;
911
912 /*
913 *-------------------------------------------------------------
914 * request EF PLMN SEL from SIM
915 *-------------------------------------------------------------
916 */
917 return cmhSIM_ReqPlmnSel ( srcId );
918 }
919
920 /*
921 *-------------------------------------------------------------
922 * fill PLMN SEL list
923 *-------------------------------------------------------------
924 */
925 if( startIdx * ACI_LEN_PLMN_SEL_NTRY > CPOLSimEfDataLen )
926 {
927 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_InvIdx );
928 return( AT_FAIL );
929 }
930
931 if( mode EQ CPOL_MOD_CompactList )
932 {
933 cmhSIM_CmpctPlmnSel( CPOLSimEfDataLen, CPOLSimEfData );
934 }
935
936 *lastIdx = cmhSIM_FillPlmnSelList((UBYTE)startIdx,
937 pSIMCmdPrm->CPOLfrmt,
938 operLst,
939 CPOLSimEfDataLen,
940 CPOLSimEfData);
941 return ( AT_CMPL );
942
943 }
944
945 /*
946 +--------------------------------------------------------------------+
947 | PROJECT : GSM-PS (6147) MODULE : CMH_SSQ |
948 | STATE : code ROUTINE : tAT_PlusCPOL |
949 +--------------------------------------------------------------------+
950
951 PURPOSE : This is the functional counterpart to the +CPOL AT command
952 which is responsible for testing the supported preferred
953 operator list length.
954
955 <lastIdx>: maximum number of entries
956 <usdNtry>: number of used entries
957 */
958
959 GLOBAL T_ACI_RETURN tAT_PlusCPOL ( T_ACI_CMD_SRC srcId,
960 SHORT * lastIdx,
961 SHORT * usdNtry )
962 {
963 T_SIM_CMD_PRM * pSIMCmdPrm; /* points to SIM command parameters */
964
965 TRACE_FUNCTION ("tAT_PlusCPOL()");
966
967 /*
968 *-------------------------------------------------------------------
969 * check command source
970 *-------------------------------------------------------------------
971 */
972 if(!cmh_IsVldCmdSrc (srcId))
973 {
974 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
975 return( AT_FAIL );
976 }
977
978 pSIMCmdPrm = &cmhPrm[srcId].simCmdPrm;
979
980 /*
981 *-------------------------------------------------------------------
982 * check if PLMNsel EF has to be read
983 *-------------------------------------------------------------------
984 */
985 if( EfPLMNselStat EQ EF_STAT_UNKNWN )
986 {
987 /*
988 *-------------------------------------------------------------
989 * check entity status
990 *-------------------------------------------------------------
991 */
992 if( simEntStat.curCmd NEQ AT_CMD_NONE )
993
994 return( AT_BUSY );
995
996 pSIMCmdPrm -> CPOLact = CPOL_ACT_Test;
997
998 /*
999 *-------------------------------------------------------------
1000 * request EF PLMN SEL from SIM
1001 *-------------------------------------------------------------
1002 */
1003 return cmhSIM_ReqPlmnSel ( srcId );
1004 }
1005
1006 /*
1007 *-------------------------------------------------------------
1008 * return number of supported entries
1009 *-------------------------------------------------------------
1010 */
1011 *lastIdx = CPOLSimEfDataLen / ACI_LEN_PLMN_SEL_NTRY;
1012
1013 *usdNtry = cmhSIM_UsdPlmnSelNtry( CPOLSimEfDataLen, CPOLSimEfData );
1014
1015 return ( AT_CMPL );
1016
1017 }
1018
1019
1020 /*
1021 +-------------------------------------------------------------------+
1022 | PROJECT : GSM-PS (6147) MODULE : CMH_SIMQ |
1023 | ROUTINE : qAT_PercentCPRI |
1024 +-------------------------------------------------------------------+
1025
1026 PURPOSE : This is the functional counterpart to the %CPRI AT command
1027 which is responsible for reading the ciphering indicator
1028 mode.
1029 */
1030 GLOBAL T_ACI_RETURN qAT_PercentCPRI( T_ACI_CMD_SRC srcId,
1031 UBYTE *mode )
1032 {
1033 TRACE_FUNCTION ("qAT_PercentCPRI()");
1034
1035 if( !cmh_IsVldCmdSrc( srcId ) )
1036 {
1037 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
1038 return( AT_FAIL );
1039 }
1040 *mode = simShrdPrm.ciSIMEnabled;
1041 return( AT_CMPL );
1042 }
1043
1044
1045 /*
1046 +-------------------------------------------------------------------+
1047 | PROJECT : GSM-PS (6147) MODULE : CMH_SIMQ |
1048 | ROUTINE : qAT_PercentATR |
1049 +-------------------------------------------------------------------+
1050
1051 PURPOSE : This is the functional counterpart to the %ATR AT command
1052 which is responsible for reading the SIM phase and ATR
1053 (answer to reset information).
1054 */
1055 GLOBAL T_ACI_RETURN qAT_PercentATR( T_ACI_CMD_SRC srcId,
1056 UBYTE *phase,
1057 UBYTE *atr_len,
1058 UBYTE *atr_info)
1059 {
1060 TRACE_FUNCTION ("qAT_PercentATR()");
1061
1062 if( !cmh_IsVldCmdSrc( srcId ) )
1063 {
1064 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
1065 return( AT_FAIL );
1066 }
1067
1068 *phase = simShrdPrm.crdPhs; /* SIM Phase... value is 0xFF if no phase is available*/
1069
1070
1071 *atr_len = simShrdPrm.atr.len; /* ATR length... 0 if no ATR data is available*/
1072 if (simShrdPrm.atr.len)
1073 {
1074 memcpy(atr_info, simShrdPrm.atr.data, simShrdPrm.atr.len);
1075 }
1076
1077 return( AT_CMPL );
1078 }
1079
1080 #ifdef FF_DUAL_SIM
1081 /*
1082 +--------------------------------------------------------------------+
1083 | PROJECT : GSM-PS (6147) MODULE : CMH_SIMQ |
1084 | STATE : code ROUTINE : qAT_PercentSIM |
1085 +--------------------------------------------------------------------+
1086
1087 PURPOSE : This is the functional counterpart to the %SIM? AT command
1088 which returns the currently powered on SIM Number.
1089
1090 <sim_num>: sim_number.
1091 */
1092
1093 GLOBAL T_ACI_RETURN qAT_PercentSIM ( T_ACI_CMD_SRC srcId,
1094 UBYTE *sim_num )
1095 {
1096 TRACE_FUNCTION ("qAT_PercentSIM()");
1097
1098 /*
1099 *-------------------------------------------------------------------
1100 * check command source
1101 *-------------------------------------------------------------------
1102 */
1103 if(!cmh_IsVldCmdSrc (srcId))
1104 {
1105 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
1106 return( AT_FAIL );
1107 }
1108
1109 /*
1110 *-------------------------------------------------------------------
1111 * fill in parameters
1112 *-------------------------------------------------------------------
1113 */
1114 *sim_num = simShrdPrm.SIM_Powered_on;
1115
1116 return( AT_CMPL );
1117 }
1118 #endif /*FF_DUAL_SIM*/
1119 /*==== EOF ========================================================*/