comparison src/g23m-aci/aci/cmh_simq.c @ 1:fa8dc04885d8

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