comparison src/g23m-aci/aci/cmh_simr.c @ 162:53929b40109c

src/g23m-aci: initial import from TCS3.2/LoCosto
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 11 Oct 2016 02:02:43 +0000
parents
children
comparison
equal deleted inserted replaced
161:4557e2a9c18e 162:53929b40109c
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : GSM-PS (6147)
4 | Modul : CMH_SIMR
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 defines the functions which are responsible
18 | for the responses of the protocol stack adapter for
19 | the subscriber identity module.
20 +-----------------------------------------------------------------------------
21 */
22
23 #ifndef CMH_SIMR_C
24 #define CMH_SIMR_C
25 #endif
26
27 #include "aci_all.h"
28 /*==== INCLUDES ===================================================*/
29 #include "aci_mem.h"
30
31 #include "aci_cmh.h"
32 #include "ati_cmd.h"
33 #include "aci_cmd.h"
34 #include "pcm.h"
35
36 #ifdef FAX_AND_DATA
37 #include "aci_fd.h"
38 #endif /* of #ifdef FAX_AND_DATA */
39
40 #ifndef _SIMULATION_
41 #include "ffs/ffs.h"
42 #include "ffs_coat.h"
43 #endif
44
45 #ifdef DTI
46 #include "dti.h" /* functionality of the dti library */
47 #include "dti_conn_mng.h"
48 #include "dti_cntrl_mng.h"
49 #endif /* DTI */
50
51 #include "phb.h"
52 #include "ksd.h"
53 #include "aci.h"
54 #include "psa.h"
55 #include "psa_sim.h"
56 #include "psa_cc.h"
57 #include "psa_sat.h"
58 #include "psa_mm.h"
59 #include "cmh.h"
60 #include "cmh_sim.h"
61 #include "cmh_mm.h"
62 #include "cmh_phb.h"
63
64 #include "aci_ext_pers.h"
65 #include "aci_slock.h"
66 #include "psa_sms.h"
67
68 #ifdef SIM_PERS
69 #include "general.h" // included for compilation error UNIT8 in sec_drv.h
70 #include "sec_drv.h"
71 #endif
72
73 #ifdef GPRS
74 #include "gaci.h"
75 #include "gaci_cmh.h"
76 #include "psa_gmm.h"
77 #include "cmh_gmm.h"
78 #endif
79
80 #include "p_mmcm.h"
81 #include "m_cc.h"
82
83 #include "aoc.h"
84
85 #ifdef DTI
86 #include "wap_aci.h"
87 #include "psa_tcpip.h"
88 #include "psa_l2r.h"
89 #endif
90
91 #ifdef SIM_PERS
92 EXTERN T_ACI_SIM_CONFIG aci_slock_sim_config; /* SIM configuration, initialised by a T_SIM_MMI_INSERT_IND */
93 EXTERN T_SEC_DRV_CONFIGURATION *cfg_data ;
94 #endif
95
96 /*==== CONSTANTS ==================================================*/
97
98
99 /*==== TYPES ======================================================*/
100
101
102 /*==== EXPORT =====================================================*/
103
104
105 /*==== VARIABLES ==================================================*/
106
107 /*==== FUNCTIONS ==================================================*/
108 LOCAL void cmhSIM_ProcessEvents ( T_ACI_AT_CMD at_cmd_id );
109 LOCAL void cmhSIM_Compare_CNUMMsisdnIdx ( void );
110 LOCAL void cmhSIM_SndError( T_ACI_CMD_SRC ownBuf,
111 T_ACI_AT_CMD cmdBuf,
112 T_ACI_CME_ERR cme_err );
113
114 /*
115 +-------------------------------------------------------------------+
116 | PROJECT : GSM-PS (6147) MODULE : CMH_SIMR |
117 | ROUTINE : cmhSIM_SIMSync |
118 +-------------------------------------------------------------------+
119
120 PURPOSE : SIM data synchronized
121
122 */
123
124 GLOBAL void cmhSIM_SIMSync ( void )
125 {
126 TRACE_FUNCTION ("cmhSIM_SIMSync()");
127
128 /* process event */
129 switch( simEntStat.curCmd )
130 {
131 case( AT_CMD_CFUN ):
132 if (mmEntStat.curCmd NEQ AT_CMD_CFUN) /* Has MM already deregistered? */
133 {
134 R_AT( RAT_OK, simEntStat.entOwn )
135 ( AT_CMD_CFUN );
136
137 /* log result */
138 cmh_logRslt ( simEntStat.entOwn, RAT_OK, AT_CMD_CFUN,
139 -1, BS_SPEED_NotPresent,CME_ERR_NotPresent );
140 }
141 /*lint -fallthrough*/
142 case( AT_CMD_COPS ):
143 case( AT_CMD_P_COPS ):
144
145 simEntStat.curCmd = AT_CMD_NONE;
146 break;
147 }
148 }
149
150 /*
151 +-------------------------------------------------------------------+
152 | PROJECT : GSM-PS (6147) MODULE : CMH_SIMR |
153 | ROUTINE : clck_fdn_accepted() |
154 +-------------------------------------------------------------------+
155
156 PURPOSE : PIN2 status allows CLCK changing the status concerning FDN.
157
158 */
159
160 LOCAL void clck_fdn_accepted ( void )
161 {
162 switch( simShrdPrm.setPrm[simEntStat.entOwn].actProc )
163 {
164 case( SIM_FDN_ENABLE ):
165 if( simShrdPrm.crdFun EQ SIM_ADN_ENABLED )
166 {
167 simShrdPrm.crdFun = SIM_FDN_ENABLED;
168 }
169 if( simShrdPrm.crdFun EQ SIM_ADN_BDN_ENABLED )
170 {
171 simShrdPrm.crdFun = SIM_FDN_BDN_ENABLED;
172 }
173
174 pb_switch_adn_fdn( FDN_ENABLE, simShrdPrm.classFDN ); /* inform PHB */
175 break;
176
177 case( SIM_FDN_DISABLE ):
178 if( simShrdPrm.crdFun EQ SIM_FDN_ENABLED )
179 {
180 simShrdPrm.crdFun = SIM_ADN_ENABLED;
181 }
182 if( simShrdPrm.crdFun EQ SIM_FDN_BDN_ENABLED )
183 {
184 simShrdPrm.crdFun = SIM_ADN_BDN_ENABLED;
185 }
186 pb_switch_adn_fdn( FDN_DISABLE, simShrdPrm.classFDN ); /* inform PHB */
187 break;
188 }
189 }
190
191 /*
192 +-------------------------------------------------------------------+
193 | PROJECT : GSM-PS (6147) MODULE : CMH_SIMR |
194 | ROUTINE : cmhsim_simactivated_clck |
195 +-------------------------------------------------------------------+
196 PURPOSE : SIM activated after AT+CLCK
197 */
198
199 LOCAL void cmhsim_simactivated_clck( void )
200 {
201 T_ACI_CME_ERR err = CME_ERR_Unknown;
202
203 TRACE_FUNCTION ("cmhsim_simactivated_clck()");
204
205 simEntStat.curCmd = AT_CMD_NONE;
206
207 switch( simShrdPrm.rslt )
208 {
209 case( SIM_NO_ERROR ):
210 clck_fdn_accepted();
211
212 R_AT( RAT_OK, simEntStat.entOwn )
213 ( AT_CMD_CLCK );
214 cmh_logRslt ( simEntStat.entOwn, RAT_OK, AT_CMD_CLCK, -1,
215 BS_SPEED_NotPresent,CME_ERR_NotPresent );
216 return;
217
218 case( SIM_CAUSE_PIN2_EXPECT ):
219 TRACE_EVENT_P1("simShrdPrm.pn2Stat: %d", simShrdPrm.pn2Stat);
220
221 if ( simShrdPrm.pn2Stat EQ PS_PIN2 )
222 {
223 if ( ( simShrdPrm.setPrm[simEntStat.entOwn].curPIN[0] NEQ 0x00 ) AND
224 ( simShrdPrm.setPrm[simEntStat.entOwn].curPIN[0] NEQ NOT_PRESENT_CHAR ) )
225 {
226 /* if PIN2 is required and a pin is given, then check pin with PIN2 */
227 simEntStat.curCmd = AT_CMD_CLCK; /* further processing */
228
229 simShrdPrm.setPrm[simEntStat.entOwn].PINType = PHASE_2_PIN_2;
230 psaSIM_VerifyPIN(); /* verify PIN */
231 return;
232 }
233 else
234 {
235 /* if PIN2 is required and no pin is given, then send cme_err with PIN2
236 required message code */
237 if ( simShrdPrm.PINStat EQ PS_RDY )
238 {
239 simShrdPrm.PINStat = PS_PIN2;
240 }
241 err = CME_ERR_SimPin2Req;
242 }
243 }
244 else
245 {
246 err = CME_ERR_WrongPasswd;
247 }
248 break;
249
250 /*case( SIM_CAUSE_PIN1_EXPECT ):
251 case( SIM_CAUSE_PUK1_EXPECT ):*/
252
253 /* Should be CME_ERR_SimPuk2Req, and it is done
254 in the default case
255 case( SIM_CAUSE_PIN2_BLOCKED):
256 case( SIM_CAUSE_PUK2_EXPECT ):
257 err = CME_ERR_WrongPasswd;
258 break;*/
259
260 default:
261 err = cmhSIM_GetCmeFromSim( simShrdPrm.rslt );
262 break;
263 }
264
265 R_AT( RAT_CME, simEntStat.entOwn )
266 ( AT_CMD_CLCK, err );
267 cmh_logRslt ( simEntStat.entOwn, RAT_CME, AT_CMD_CLCK,
268 -1, BS_SPEED_NotPresent, err );
269
270 }
271
272 /*
273 +-------------------------------------------------------------------+
274 | PROJECT : GSM-PS (6147) MODULE : CMH_SIMR |
275 | ROUTINE : cmhsim_simactivated_start |
276 +-------------------------------------------------------------------+
277 PURPOSE : SIM activated after AT+CFUN, +CPIN, +CIMI and %NRG
278 */
279 LOCAL void simactivated_cpinresult( T_ACI_CPIN_RSLT cpin_result )
280 {
281 R_AT( RAT_CPIN, simEntStat.entOwn )
282 ( cpin_result );
283 R_AT( RAT_OK, simEntStat.entOwn )
284 ( AT_CMD_CPIN );
285 cmh_logRslt ( simEntStat.entOwn, RAT_OK, AT_CMD_CPIN,
286 -1, BS_SPEED_NotPresent,CME_ERR_NotPresent );
287 }
288
289 LOCAL void simactivated_errorresult( T_ACI_CME_ERR error_result, T_ACI_AT_CMD cmdBuf )
290 {
291 R_AT( RAT_CME, simEntStat.entOwn )
292 ( cmdBuf, error_result );
293
294 if( cmdBuf NEQ AT_CMD_CIMI )
295 {
296 cmh_logRslt ( simEntStat.entOwn, RAT_CME, cmdBuf,
297 -1, BS_SPEED_NotPresent, error_result );
298 }
299 }
300
301 LOCAL void cmhsim_simactivated_start( void )
302 {
303 T_ACI_AT_CMD cmdBuf = simEntStat.curCmd; /* buffers current command */
304
305 TRACE_FUNCTION ("cmhsim_simactivated_start()");
306
307 simEntStat.curCmd = AT_CMD_NONE;
308
309 switch( simShrdPrm.SIMStat )
310 {
311 case( SS_INV ):
312 simactivated_errorresult( CME_ERR_SimWrong, cmdBuf );
313 return;
314
315 case( SS_URCHB ):
316 simactivated_errorresult( CME_ERR_SimNotIns, cmdBuf );
317 return;
318
319 case( NO_VLD_SS ):
320 simactivated_errorresult( CME_ERR_NotPresent, cmdBuf );
321 return;
322
323 case( SS_OK ):
324 switch( simShrdPrm.PINStat )
325 {
326 case( PS_PIN1 ):
327 if( cmdBuf EQ AT_CMD_CPIN )
328 {
329 simactivated_cpinresult( CPIN_RSLT_SimPinReq );
330 }
331 else
332 {
333 simactivated_errorresult( CME_ERR_SimPinReq, cmdBuf );
334 }
335 break;
336
337 case( PS_PIN2 ):
338 if( cmdBuf EQ AT_CMD_CPIN )
339 {
340 simactivated_cpinresult( CPIN_RSLT_SimPin2Req );
341 }
342 else
343 {
344 simactivated_errorresult( CME_ERR_SimPin2Req, cmdBuf );
345 }
346 break;
347
348 case( PS_RDY ):
349 /* wait for SIM insert indication to complete command */
350 simEntStat.curCmd = cmdBuf;
351 break;
352 }
353 break;
354
355 case( SS_BLKD ):
356
357 switch( simShrdPrm.PINStat )
358 {
359 case( PS_PUK1 ):
360 if( cmdBuf EQ AT_CMD_CPIN )
361 {
362 simactivated_cpinresult( CPIN_RSLT_SimPukReq );
363 }
364 else
365 {
366 simactivated_errorresult( CME_ERR_SimPukReq, cmdBuf );
367 }
368 break;
369
370 case( PS_PUK2 ):
371 if( cmdBuf EQ AT_CMD_CPIN )
372 {
373 simactivated_cpinresult( CPIN_RSLT_SimPuk2Req );
374 }
375 else
376 {
377 simactivated_errorresult( CME_ERR_SimPuk2Req, cmdBuf );
378 }
379 break;
380 }
381 break;
382
383 }
384 }
385
386 /*
387 +-------------------------------------------------------------------+
388 | PROJECT : GSM-PS (6147) MODULE : CMH_SIMR |
389 | ROUTINE : cmhSIM_SIMActivated |
390 +-------------------------------------------------------------------+
391
392 PURPOSE : SIM activated
393
394 */
395
396 GLOBAL void cmhSIM_SIMActivated ( void )
397 {
398 T_ACI_CMD_SRC idx;
399
400 TRACE_FUNCTION ("cmhSIM_SIMActivated()");
401
402 /* check for command context */
403 switch( simEntStat.curCmd )
404 {
405 case( AT_CMD_CFUN ):
406 case( AT_CMD_CPIN ):
407 case( AT_CMD_CIMI ):
408 case( AT_CMD_NRG ):
409 case( AT_CMD_SIMRST):
410 /* process event for +CFUN, +CPIN, +CIMI and for %NRG command */
411 cmhsim_simactivated_start( );
412 break;
413
414 case( AT_CMD_CLCK ):
415 /* process event for +CLCK command */
416 cmhsim_simactivated_clck( );
417 break;
418
419 case( AT_CMD_NONE ):
420 /* process event spontaneous insertion */
421 if (simShrdPrm.rslt EQ SIM_NO_ERROR)
422 {
423 ; /* do nothing right now since the %SIMINS: -1 must be
424 syncronized with SIM_MMI_INSERT_IND which will come later! */
425 }
426 else
427 {
428 for( idx = CMD_SRC_LCL; idx < CMD_SRC_MAX; idx++ )
429 {
430 R_AT( RAT_SIMINS, idx )(cmhSIM_GetCmeFromSim (simShrdPrm.rslt));
431 }
432 }
433 break;
434 }
435 }
436
437 /*
438 +-------------------------------------------------------------------+
439 | PROJECT : GSM-PS (6147) MODULE : CMH_SIMR |
440 | ROUTINE : cmhSIM_SIMInserted |
441 +-------------------------------------------------------------------+
442
443 PURPOSE : SIM inserted
444
445 */
446
447 GLOBAL void cmhSIM_SIMInserted ( void )
448 {
449 USHORT cmdBuf; /* buffers current command */
450 CHAR imsiBuf[MAX_IMSI_LEN+1]; /* buffer IMSI representation +1 for '\0'*/
451 T_ACI_CME_ERR err_code = CME_ERR_NotPresent; /* code holding the correct error code calculated */
452 #ifdef SIM_PERS
453 T_ACI_CPIN_RSLT code = CPIN_RSLT_NotPresent;
454 #endif
455 BOOL return_rat_ok = 1; /* return ok? */
456
457 TRACE_FUNCTION ("cmhSIM_SIMInserted()");
458
459 /* Check if the SIM is functional and the IMSI value is valid*/
460 if ( simShrdPrm.crdFun EQ SIM_NO_OPERATION OR
461 simShrdPrm.imsi.c_field EQ 0 )
462 {
463 simShrdPrm.SIMStat = SS_INV;
464 err_code = CME_ERR_SimWrong;
465 }
466 cmdBuf = simEntStat.curCmd;
467 switch( cmdBuf )
468 {
469 case( AT_CMD_CFUN ):
470 case( AT_CMD_CPIN ):
471 case( AT_CMD_PVRF ):
472 case( AT_CMD_SIMRST):
473 case( KSD_CMD_UBLK):
474 /*
475 *----------------------------------------------------------------
476 * process event for +CFUN, +CPIN, %PVRF commands and for the
477 SIM reset condition
478 *----------------------------------------------------------------
479 */
480
481 simEntStat.curCmd = AT_CMD_NONE;
482 #ifdef SIM_PERS
483 if((aci_slock_sim_config.sim_type EQ SIM_TYPEAPPROVAL) AND AciSLockShrd.blocked)
484 {
485 simShrdPrm.SIMStat = SS_INV;
486 err_code = CME_ERR_SimWrong;
487 }
488 if(cfg_data EQ NULL)
489 {
490 simShrdPrm.SIMStat = SS_INV;
491 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_NoMEPD );
492 err_code = CME_ERR_Unknown;
493 aci_slock_send_RAT(cmdBuf,err_code);
494 simShrdPrm.PINQuery = 0;
495 AciSLockShrd.cpin_query = SEND_CPIN_REQ_CODE_NONE;
496 return;
497 }
498 #endif
499
500 if( err_code EQ CME_ERR_SimWrong )
501 {
502 R_AT( RAT_CME, simEntStat.entOwn ) ((T_ACI_AT_CMD) cmdBuf, err_code );
503 cmh_logRslt ( simEntStat.entOwn, RAT_CME, (T_ACI_AT_CMD)cmdBuf, -1, BS_SPEED_NotPresent, err_code );
504 simShrdPrm.PINQuery = 0;
505 #ifdef SIM_PERS
506 AciSLockShrd.cpin_query = SEND_CPIN_REQ_CODE_NONE;
507 #endif
508 return;
509 }
510
511 #ifdef SIM_PERS
512 /* check for personalisation locking. If SIM was detected as not correct, do signal AT_CPIN */
513
514 if ( AciSLockShrd.blocked)
515 {
516 return_rat_ok = 0;
517 if(AciSLockShrd.cpin_query EQ SEND_CPIN_REQ_CODE_NONE)
518 {
519 /* @GBR: Alternativly CME_ERR_SimWrong might be returned, but this way is telling the MMI mor specific, what went wrong. */
520
521 aci_set_cme_error_code_and_logRslt( cmdBuf );
522 }
523 else
524 {
525 if(AciSLockShrd.cpin_query EQ SEND_CPIN_REQ_CODE_RAT )
526 {
527 aci_set_cpin_code(AciSLockShrd.current_lock,&code);
528 R_AT( RAT_CPIN, simEntStat.entOwn )
529 ( code );
530 }
531 AciSLockShrd.cpin_query = SEND_CPIN_REQ_CODE_NONE;
532 }
533 }
534
535 #endif
536 if ( (cmdBuf EQ AT_CMD_CPIN) AND (simShrdPrm.PINQuery EQ 1) ) /* Case when PIN is disabled and CFUN=0 */
537 {
538 R_AT( RAT_CPIN, simEntStat.entOwn )
539 ( CPIN_RSLT_SimReady );
540 simShrdPrm.PINQuery = 0;
541 }
542
543 #if defined (GPRS) AND defined (DTI)
544 gprs_sim_inserted();
545 #endif /* GPRS */
546
547 if (return_rat_ok EQ 1) /* @gbr: only send ok, if everhing went okay. The +CFUN might not be ready here, so don't send something! */
548 {
549
550 R_AT( RAT_OK, simEntStat.entOwn ) ((T_ACI_AT_CMD) cmdBuf );
551 cmh_logRslt ( simEntStat.entOwn, RAT_OK,(T_ACI_AT_CMD) cmdBuf, -1, BS_SPEED_NotPresent, CME_ERR_NotPresent );
552 #ifdef SIM_PERS
553 AciSLockShrd.cpin_query = SEND_CPIN_REQ_CODE_NONE;
554 #endif
555 }
556 break;
557
558 case( AT_CMD_CIMI ):
559 /*
560 *----------------------------------------------------------------
561 * process event for +CIMI command
562 *----------------------------------------------------------------
563 */
564
565
566 if( err_code EQ CME_ERR_SimWrong )
567 {
568 R_AT( RAT_CME, simEntStat.entOwn ) ( AT_CMD_CIMI, err_code );
569 cmh_logRslt ( simEntStat.entOwn, RAT_CME, AT_CMD_CIMI, -1, BS_SPEED_NotPresent, err_code );
570 return;
571 }
572
573 R_AT( RAT_CIMI, simEntStat.entOwn )
574 ( psaSIM_cnvrtIMSI2ASCII( imsiBuf ));
575
576 simEntStat.curCmd = AT_CMD_NONE;
577
578 R_AT( RAT_OK, simEntStat.entOwn )
579 ( AT_CMD_CIMI );
580 break;
581
582 case( AT_CMD_NRG ):
583 /*
584 *----------------------------------------------------------------
585 * process event for %NRG
586 *----------------------------------------------------------------
587 */
588 if( err_code EQ CME_ERR_SimWrong )
589 {
590 simEntStat.curCmd = AT_CMD_NONE;
591 mmEntStat.curCmd = AT_CMD_NONE;
592 R_AT( RAT_CME, simEntStat.entOwn ) ( (T_ACI_AT_CMD)cmdBuf, err_code );
593 cmh_logRslt ( simEntStat.entOwn, RAT_CME, (T_ACI_AT_CMD)cmdBuf, -1, BS_SPEED_NotPresent, err_code );
594 return;
595 }
596
597 switch( cmhPrm[simShrdPrm.owner].mmCmdPrm.NRGregMode )
598 {
599 case( NRG_RGMD_Auto ):
600
601 mmShrdPrm.regMode = MODE_AUTO;
602
603 simEntStat.curCmd = AT_CMD_NONE;
604 mmEntStat.curCmd = AT_CMD_NRG;
605 mmShrdPrm.owner = simShrdPrm.owner;
606 mmEntStat.entOwn = (T_ACI_CMD_SRC)simShrdPrm.owner;
607
608 #if defined (GPRS) AND defined (DTI)
609 (void)psaG_MM_CMD_REG (); /* register to network */
610 #else
611 (void)psaMM_Registrate (); /* register to network */
612 #endif
613
614 cmhMM_Ntfy_NtwRegistrationStatus(CREG_STAT_Search);
615 break;
616
617 case( NRG_RGMD_Manual ):
618
619 mmShrdPrm.regMode = MODE_MAN;
620
621 simEntStat.curCmd = AT_CMD_NONE;
622 mmEntStat.curCmd = AT_CMD_NRG;
623 mmShrdPrm.owner = simShrdPrm.owner;
624 mmEntStat.entOwn = (T_ACI_CMD_SRC) simShrdPrm.owner;
625
626 #if defined (GPRS) && defined (DTI)
627 psaG_MM_CMD_NET_SEL ( ); /* register to network */
628 #else
629 psaMM_NetSel (); /* register to network */
630 #endif
631
632 cmhMM_Ntfy_NtwRegistrationStatus(CREG_STAT_Search);
633 break;
634 }
635 break;
636
637 case( AT_CMD_NONE ):
638 {
639 T_ACI_CMD_SRC idx;
640 //TISH, patch for ASTec31853
641 //start
642 /*modified for Roaming issue*/
643 TRACE_EVENT("reset mm reg stat");
644 mmShrdPrm.regStat = NO_VLD_RS;
645 //end
646 /* process event spontaneous insertion */
647 for( idx = CMD_SRC_LCL; idx < CMD_SRC_MAX; idx++ )
648 {
649 R_AT( RAT_SIMINS, idx )( err_code );
650 }
651 }
652 break;
653
654 }
655 }
656
657 /*
658 +-------------------------------------------------------------------+
659 | PROJECT : GSM-PS (6147) MODULE : CMH_SIMR |
660 | ROUTINE : cmhSIM_SIMRemoved |
661 +-------------------------------------------------------------------+
662
663 PURPOSE : SIM removed
664
665 */
666
667 GLOBAL void cmhSIM_SIMRemoved ( void )
668 {
669 T_ACI_AT_CMD cmdBuf; /* buffers command */
670 T_ACI_CMD_SRC idx;
671 T_ACI_CME_ERR cme_error; /* CME error code */
672 T_ACI_SIMREM_TYPE srt; /* type of SIM remove */
673
674 TRACE_FUNCTION ("cmhSIM_SIMRemoved()");
675
676 if (simEntStat.curCmd NEQ AT_CMD_NONE)
677 {
678 cmdBuf = simEntStat.curCmd;
679 simEntStat.curCmd = AT_CMD_NONE;
680
681 if (simShrdPrm.rslt EQ SIM_NO_ERROR)
682 cme_error = CME_ERR_SimBusy;
683 else
684 cme_error = cmhSIM_GetCmeFromSim (simShrdPrm.rslt);
685
686 R_AT( RAT_CME, simEntStat.entOwn )
687 ( cmdBuf, cme_error );
688 cmh_logRslt ( simEntStat.entOwn, RAT_CME, cmdBuf,
689 -1, BS_SPEED_NotPresent, cme_error );
690 }
691 EfPLMNselStat = EF_STAT_UNKNWN;
692 /*
693 *----------------------------------------------------------------
694 * send unsolicited result
695 *----------------------------------------------------------------
696 */
697 TRACE_EVENT_P1("Result of SIM remove indication: %x", simShrdPrm.rslt);
698 switch (simShrdPrm.rslt)
699 {
700 case SIM_NO_ERROR:
701 /* In this case the AT command state is set to SIM RESET */
702 /* NO, don't do this!
703 This line would prevent a %SIMIND: 11 and instead leads to
704 "+CME ERROR: SIM PIN required" without any command context which is wrong */
705 /* simEntStat.curCmd = AT_CMD_SIMRST; */
706 srt = SIMREM_RESET;
707 break;
708 case SIM_CAUSE_DRV_TEMPFAIL:
709 srt = SIMREM_RETRY;
710 break;
711 default:
712 srt = SIMREM_FAILURE;
713 break;
714 }
715
716 for( idx = CMD_SRC_LCL; idx < CMD_SRC_MAX; idx++ )
717 {
718 R_AT( RAT_SIMREM, idx )(srt);
719 }
720 }
721
722 /*
723 +-------------------------------------------------------------------+
724 | PROJECT : GSM-PS (6147) MODULE : CMH_SIMR |
725 | ROUTINE : cmhSIM_PINVerified |
726 +-------------------------------------------------------------------+
727
728 PURPOSE : SIM verified
729
730 */
731 LOCAL void pin_verified_clck (USHORT sim_result)
732 {
733 TRACE_FUNCTION ("pin_verified_clck()");
734
735 switch(sim_result)
736 {
737 case( SIM_NO_ERROR ):
738 /* now do it ! */
739
740 /* Check if we want to do FDN Lock or ALS Lock */
741 switch (simShrdPrm.setPrm[simShrdPrm.owner].actProc)
742 {
743 case SIM_FDN_ENABLE:
744 case SIM_FDN_DISABLE:
745 /* FDN Lock */
746 if( psaSIM_ActivateSIM() < 0 ) /* activate SIM card */
747 {
748 simEntStat.curCmd = AT_CMD_NONE;
749
750 R_AT( RAT_CME, simEntStat.entOwn )
751 ( AT_CMD_CLCK, CME_ERR_Unknown );
752 cmh_logRslt ( simEntStat.entOwn, RAT_CME, AT_CMD_CLCK,
753 -1, BS_SPEED_NotPresent, CME_ERR_Unknown );
754 }
755 break;
756
757 case SIM_ALS_LOCK:
758 case SIM_ALS_UNLOCK:
759 /* ALS Lock to PIN2 */
760 if (simShrdPrm.setPrm[simShrdPrm.owner].actProc EQ SIM_ALS_LOCK)
761 {
762 ALSlock = cmhPrm[simShrdPrm.owner].ccCmdPrm.ALSmode;
763 /* pull all sources to the current ALSmode, otherwise a lock won't make sense */
764 {
765 int i;
766 for (i=0; i<OWN_SRC_MAX; i++)
767 cmhPrm[i].ccCmdPrm.ALSmode = ALSlock;
768 /* and lock them all */
769 }
770 #ifndef _SIMULATION_
771 /* write Lock to FFS */
772 /* Implements Measure#32: Row 1071 */
773 FFS_fwrite(gsm_com_alslock_path, &ALSlock, sizeof(ALSlock));
774 #endif
775 }
776 else
777 /* unlock ALS */
778 {
779 ALSlock = ALS_MOD_NOTPRESENT;
780 #ifndef _SIMULATION_
781 /* remove lock from FFS */
782 /* Implements Measure#32: Row 1071 */
783 FFS_remove(gsm_com_alslock_path);
784 #endif
785 }
786
787 simEntStat.curCmd = AT_CMD_NONE;
788
789 R_AT( RAT_OK, simEntStat.entOwn )
790 ( AT_CMD_CLCK );
791 cmh_logRslt ( simEntStat.entOwn, RAT_OK, AT_CMD_CLCK, -1, BS_SPEED_NotPresent,CME_ERR_NotPresent);
792 break;
793
794 }
795 break; /* SIM_NO_ERROR */
796
797 case( SIM_CAUSE_PIN1_EXPECT ):
798 case( SIM_CAUSE_PIN2_EXPECT ):
799 case( SIM_CAUSE_PIN1_BLOCKED ):
800 case( SIM_CAUSE_PUK1_EXPECT ):
801 case( SIM_CAUSE_PIN2_BLOCKED ):
802 case( SIM_CAUSE_PUK2_EXPECT ):
803 simEntStat.curCmd = AT_CMD_NONE;
804
805 R_AT( RAT_CME, simEntStat.entOwn )
806 ( AT_CMD_CLCK, cmhSIM_GetCmeFromSim ( sim_result ) /*CME_ERR_WrongPasswd*/ );
807 cmh_logRslt ( simEntStat.entOwn, RAT_CME, AT_CMD_CLCK,
808 -1,BS_SPEED_NotPresent, CME_ERR_WrongPasswd );
809 break;
810
811 default:
812 simEntStat.curCmd = AT_CMD_NONE;
813 R_AT( RAT_CME, simEntStat.entOwn )
814 ( AT_CMD_CLCK, CME_ERR_SimFail );
815 cmh_logRslt ( simEntStat.entOwn, RAT_CME, AT_CMD_CLCK,
816 -1, BS_SPEED_NotPresent, CME_ERR_SimFail );
817 break;
818 }
819 }
820
821 GLOBAL void cmhSIM_PINVerified ( void )
822 {
823 T_ACI_AT_CMD cmdBuf; /* buffers command */
824 T_PHB_CMD_PRM * pPHBCmdPrm; /* points to PHB command parameters */
825
826 TRACE_FUNCTION ("cmhSIM_PINVerified()");
827
828 pPHBCmdPrm = &cmhPrm[simShrdPrm.owner].phbCmdPrm;
829
830 /*
831 *-------------------------------------------------------------------
832 * check for command context
833 *-------------------------------------------------------------------
834 */
835 switch( simEntStat.curCmd )
836 {
837 case( AT_CMD_CLCK ):
838 /* process event for +CLCK command */
839 pin_verified_clck( simShrdPrm.rslt );
840 return;
841
842 case( AT_CMD_CPIN ):
843 case( AT_CMD_PVRF ):
844 /*
845 *----------------------------------------------------------------
846 * process event for +CPIN and %PVRF command
847 *----------------------------------------------------------------
848 */
849 switch( simShrdPrm.rslt )
850 {
851 case( SIM_NO_ERROR ):
852
853 /* if verified PIN was PIN 2 or PIN 1 was already entered */
854 if( simShrdPrm.setPrm[simEntStat.entOwn].PINType EQ
855 PHASE_2_PIN_2 OR
856 simShrdPrm.crdPhs NEQ 0xFF )
857 {
858 cmdBuf = simEntStat.curCmd;
859 simEntStat.curCmd = AT_CMD_NONE;
860
861 R_AT( RAT_OK, simEntStat.entOwn )
862 ( cmdBuf );
863 cmh_logRslt ( simEntStat.entOwn, RAT_OK, cmdBuf, -1, BS_SPEED_NotPresent,CME_ERR_NotPresent);
864 }
865 /* otherwise wait for SIM insert indication to complete command */
866 break;
867
868 case( SIM_CAUSE_PIN1_EXPECT ):
869 case( SIM_CAUSE_PIN2_EXPECT ):
870 case( SIM_CAUSE_PUK1_EXPECT ):
871 case( SIM_CAUSE_PUK2_EXPECT ):
872 cmdBuf = simEntStat.curCmd;
873 simEntStat.curCmd = AT_CMD_NONE;
874
875 R_AT( RAT_CME, simEntStat.entOwn )
876 ( cmdBuf, CME_ERR_WrongPasswd );
877 cmh_logRslt ( simEntStat.entOwn, RAT_CME, cmdBuf,
878 -1, BS_SPEED_NotPresent, CME_ERR_WrongPasswd );
879 break;
880 case( SIM_CAUSE_PIN1_BLOCKED):
881 cmdBuf = simEntStat.curCmd;
882 simEntStat.curCmd = AT_CMD_NONE;
883
884 R_AT( RAT_CME, simEntStat.entOwn )
885 ( cmdBuf, CME_ERR_SimPukReq );
886 cmh_logRslt ( simEntStat.entOwn, RAT_CME, cmdBuf,
887 -1, BS_SPEED_NotPresent, CME_ERR_SimPukReq );
888 break;
889 case( SIM_CAUSE_PIN2_BLOCKED):
890 cmdBuf = simEntStat.curCmd;
891 simEntStat.curCmd = AT_CMD_NONE;
892
893 R_AT( RAT_CME, simEntStat.entOwn )
894 ( cmdBuf, CME_ERR_SimPuk2Req );
895 cmh_logRslt ( simEntStat.entOwn, RAT_CME, cmdBuf,
896 -1,BS_SPEED_NotPresent, CME_ERR_SimPuk2Req );
897 break;
898 default:
899 cmdBuf = simEntStat.curCmd;
900 simEntStat.curCmd = AT_CMD_NONE;
901 R_AT( RAT_CME, simEntStat.entOwn )
902 ( cmdBuf, CME_ERR_SimFail );
903 break;
904 }
905 break;
906
907 /* Implements Measure 106 */
908 case( AT_CMD_CAMM ):
909 case( AT_CMD_CPUC ):
910 case( AT_CMD_CACM ):
911 cmhSIM_ProcessEvents( simEntStat.curCmd );
912 break;
913 /*----------------------------------------------------------*
914 * The below code is for CPBW SIM verification response *
915 *----------------------------------------------------------*/
916
917 case( AT_CMD_CPBS ):
918 /*
919 *----------------------------------------------------------------
920 * process event for +CPBW command
921 *----------------------------------------------------------------
922 */
923 switch( simShrdPrm.rslt )
924 {
925 case( SIM_NO_ERROR ):
926
927 /*-----------------------------------------------*
928 * if verified PIN was PIN 2 was already entered *
929 *-----------------------------------------------*/
930
931 cmdBuf = simEntStat.curCmd;
932 simEntStat.curCmd = AT_CMD_NONE;
933
934 pPHBCmdPrm->cmhStor = (T_ACI_PB_STOR)pPHBCmdPrm->temp_cmhStor;
935 pPHBCmdPrm->phbStor = pPHBCmdPrm->temp_phbStor;
936
937 R_AT( RAT_OK, simEntStat.entOwn )
938 ( cmdBuf );
939
940 cmh_logRslt ( simEntStat.entOwn, RAT_OK, cmdBuf, -1, BS_SPEED_NotPresent,CME_ERR_NotPresent );
941
942 /*---------------------------------------------------------------*
943 * otherwise wait for SIM insert indication to complete command *
944 *---------------------------------------------------------------*/
945
946 break;
947
948 case( SIM_CAUSE_PUK2_EXPECT ):
949 case( SIM_CAUSE_PIN2_BLOCKED):
950 case( SIM_CAUSE_PIN2_EXPECT ):
951
952 cmdBuf = simEntStat.curCmd;
953 simEntStat.curCmd = AT_CMD_NONE;
954
955 R_AT( RAT_CME, simEntStat.entOwn )
956 ( cmdBuf, CME_ERR_WrongPasswd );
957 cmh_logRslt ( simEntStat.entOwn, RAT_CME, cmdBuf,
958 -1, BS_SPEED_NotPresent, CME_ERR_WrongPasswd );
959 break;
960
961 default:
962 cmdBuf = simEntStat.curCmd;
963 simEntStat.curCmd = AT_CMD_NONE;
964 R_AT( RAT_CME, simEntStat.entOwn )
965 ( cmdBuf, CME_ERR_SimFail );
966 break;
967 }
968 break;
969
970 default:
971
972 simEntStat.curCmd = AT_CMD_NONE;
973 R_AT( RAT_CME, simEntStat.entOwn )
974 ( AT_CMD_CPIN, CME_ERR_Unknown );
975 cmh_logRslt ( simEntStat.entOwn, RAT_CME, AT_CMD_CPIN,
976 -1,BS_SPEED_NotPresent, CME_ERR_Unknown );
977 break;
978 }
979 }
980
981 /*
982 +-------------------------------------------------------------------+
983 | PROJECT : GSM-PS (6147) MODULE : CMH_SIMR |
984 | ROUTINE : cmhSIM_PINChanged |
985 +-------------------------------------------------------------------+
986
987 PURPOSE : SIM changed
988
989 */
990
991 GLOBAL void cmhSIM_PINChanged ( void )
992 {
993 T_ACI_CME_ERR err;
994 USHORT cmdBuf = simEntStat.curCmd;
995
996 TRACE_FUNCTION ("cmhSIM_PINChanged()");
997
998 /*
999 *-------------------------------------------------------------------
1000 * check for command context
1001 *-------------------------------------------------------------------
1002 */
1003 switch( cmdBuf )
1004 {
1005 case( AT_CMD_CPWD ):
1006 /*lint -e{408} */
1007 case( KSD_CMD_PWD ): /* KSD_CMD_* extends AT_CMD_* */
1008 /*
1009 *----------------------------------------------------------------
1010 * process event for +CPWD and KSD PWD command
1011 *----------------------------------------------------------------
1012 */
1013 switch( simShrdPrm.rslt )
1014 {
1015 case( SIM_NO_ERROR ):
1016
1017 simEntStat.curCmd = AT_CMD_NONE;
1018
1019 R_AT( RAT_OK, simEntStat.entOwn )
1020 ((T_ACI_AT_CMD) cmdBuf );
1021 cmh_logRslt ( simEntStat.entOwn, RAT_OK, (T_ACI_AT_CMD)cmdBuf, -1, BS_SPEED_NotPresent, CME_ERR_NotPresent );
1022 return;
1023
1024 /* why not use a meaningful CME error code?
1025 case( SIM_CAUSE_PUK1_EXPECT ):
1026 case( SIM_CAUSE_PUK2_EXPECT ): */
1027 case( SIM_CAUSE_PIN1_EXPECT ):
1028 case( SIM_CAUSE_PIN2_EXPECT ):
1029 err = CME_ERR_WrongPasswd;
1030 break;
1031
1032 default:
1033 err = cmhSIM_GetCmeFromSim ( simShrdPrm.rslt );
1034 break;
1035 }
1036
1037 simEntStat.curCmd = AT_CMD_NONE;
1038
1039 R_AT( RAT_CME, simEntStat.entOwn )
1040 ( (T_ACI_AT_CMD)cmdBuf, err );
1041 cmh_logRslt ( simEntStat.entOwn, RAT_CME, (T_ACI_AT_CMD)cmdBuf,
1042 -1, BS_SPEED_NotPresent, err );
1043 break;
1044 }
1045 }
1046
1047 /*
1048 +-------------------------------------------------------------------+
1049 | PROJECT : GSM-PS (6147) MODULE : CMH_SIMR |
1050 | ROUTINE : cmhSIM_CardUnblocked |
1051 +-------------------------------------------------------------------+
1052
1053 PURPOSE : Card unblocked
1054
1055 */
1056
1057 GLOBAL void cmhSIM_CardUnblocked ( void )
1058 {
1059 USHORT cmdBuf =simEntStat.curCmd ;
1060 T_ACI_CME_ERR err;
1061
1062 TRACE_FUNCTION ("cmhSIM_CardUnblocked()");
1063
1064 /*
1065 *-------------------------------------------------------------------
1066 * check for command context
1067 *-------------------------------------------------------------------
1068 */
1069 switch( cmdBuf )
1070 {
1071 case( AT_CMD_CPIN ):
1072 case( AT_CMD_PVRF ):
1073 /*lint -e{408} */
1074 case( KSD_CMD_UBLK ):
1075 /*
1076 *----------------------------------------------------------------
1077 * process event for +CPIN, %PVRF and KSD UBLK command
1078 *----------------------------------------------------------------
1079 */
1080 switch( simShrdPrm.rslt )
1081 {
1082 case( SIM_NO_ERROR ):
1083
1084 if(simShrdPrm.crdPhs NEQ 0xFF)/* If SIM insert indication is already received*/
1085 {
1086 simEntStat.curCmd = AT_CMD_NONE;
1087
1088 R_AT( RAT_OK, simEntStat.entOwn )
1089 ( (T_ACI_AT_CMD)cmdBuf );
1090 cmh_logRslt ( simEntStat.entOwn, RAT_OK,(T_ACI_AT_CMD) cmdBuf, -1, BS_SPEED_NotPresent, CME_ERR_NotPresent );
1091 }/* else wait till SIM insert indication is received*/
1092 return;
1093
1094 /* why not use a meaningful CME error code?
1095 case( SIM_CAUSE_PUK1_EXPECT ):
1096 case( SIM_CAUSE_PUK2_EXPECT ): */
1097 case( SIM_CAUSE_PIN1_EXPECT ):
1098 case( SIM_CAUSE_PIN2_EXPECT ):
1099 err = CME_ERR_WrongPasswd;
1100 break;
1101
1102 default:
1103 err = cmhSIM_GetCmeFromSim ( simShrdPrm.rslt );
1104 break;
1105 }
1106
1107 simEntStat.curCmd = AT_CMD_NONE;
1108
1109 R_AT( RAT_CME, simEntStat.entOwn )
1110 ( (T_ACI_AT_CMD)cmdBuf, err );
1111 cmh_logRslt ( simEntStat.entOwn, RAT_CME,(T_ACI_AT_CMD) cmdBuf,
1112 -1, BS_SPEED_NotPresent, err );
1113 break;
1114 }
1115 }
1116
1117 /*
1118 +-------------------------------------------------------------------+
1119 | PROJECT : GSM-PS (6147) MODULE : CMH_SIMR |
1120 | ROUTINE : cmhSIM_SIMResponseData |
1121 +-------------------------------------------------------------------+
1122
1123 PURPOSE : SIM response data
1124
1125 */
1126
1127 GLOBAL void cmhSIM_SIMResponseData( T_SIM_TRNS_RSP_PRM* rsp )
1128 {
1129 T_ACI_AT_CMD cmdBuf; /* buffers command */
1130 T_ACI_CMD_SRC ownBuf; /* buffers current owner */
1131 UBYTE *rspData;
1132
1133 TRACE_FUNCTION ("cmhSIM_SIMResponseData()");
1134
1135 cmdBuf = simEntStat.curCmd;
1136 simEntStat.curCmd = AT_CMD_NONE;
1137
1138 ownBuf = simEntStat.entOwn;
1139 simShrdPrm.owner = (T_OWN)CMD_SRC_NONE;
1140 simEntStat.entOwn = CMD_SRC_NONE;
1141
1142 /*
1143 *-------------------------------------------------------------------
1144 * check for command context
1145 *-------------------------------------------------------------------
1146 */
1147 switch( cmdBuf )
1148 {
1149 case( AT_CMD_CRSM ):
1150 if (simShrdPrm.rslt NEQ SIM_NO_ERROR AND
1151 GET_CAUSE_DEFBY(simShrdPrm.rslt) EQ DEFBY_CONDAT )
1152 {
1153 /*
1154 *----------------------------------------------------------------
1155 * error event for +CRSM
1156 *----------------------------------------------------------------
1157 */
1158 R_AT( RAT_CME, ownBuf )
1159 (
1160 cmdBuf,
1161 cmhSIM_GetCmeFromSim ( simShrdPrm.rslt )
1162 );
1163 }
1164 else
1165 {
1166 /*
1167 *----------------------------------------------------------------
1168 * process event for +CRSM
1169 *----------------------------------------------------------------
1170 */
1171 R_AT( RAT_CRSM, ownBuf )
1172 ( rsp->sw1, rsp->sw2, rsp->rspLen, ((rsp->rspLen)?rsp->rsp:NULL));
1173
1174 R_AT( RAT_OK, ownBuf )
1175 ( cmdBuf );
1176 }
1177 break;
1178
1179 case( AT_CMD_CSIM ):
1180 /*
1181 *----------------------------------------------------------------
1182 * error event for +CSIM
1183 *----------------------------------------------------------------
1184 */
1185 if (simShrdPrm.rslt NEQ SIM_NO_ERROR)
1186 {
1187 R_AT( RAT_CME, ownBuf )
1188 (
1189 cmdBuf,
1190 cmhSIM_GetCmeFromSim ( simShrdPrm.rslt )
1191 );
1192
1193 return;
1194 }
1195 /*
1196 *----------------------------------------------------------------
1197 * process event for +CSIM
1198 *----------------------------------------------------------------
1199 */
1200 ACI_MALLOC(rspData, MAX_SIM_CMD+2); /* alloc 2 byte more for sw1 and sw2 */
1201 memcpy (rspData, rsp->rsp, rsp->rspLen);
1202 rspData[rsp->rspLen++] = rsp->sw1;
1203 rspData[rsp->rspLen++] = rsp->sw2;
1204
1205 R_AT( RAT_CSIM, ownBuf )
1206 ( rsp->rspLen, rspData);
1207
1208 ACI_MFREE(rspData);
1209
1210 R_AT( RAT_OK, ownBuf )
1211 ( cmdBuf );
1212 break;
1213
1214 default:
1215 TRACE_EVENT("wrong command context (+CRSM or +CSIM expected)");
1216 break;
1217 }
1218 }
1219
1220 /*
1221 +--------------------------------------------------------------------+
1222 | PROJECT : GSM-PS (6147) MODULE : CMH_SIMR |
1223 | ROUTINE : cmhSIM_CnfMsisdn |
1224 +--------------------------------------------------------------------+
1225
1226 PURPOSE : This function handles the confirmation of reading
1227 EF MSISDN from SIM.
1228 */
1229 GLOBAL void cmhSIM_CnfMsisdn ( SHORT table_id )
1230 {
1231 T_SIM_CMD_PRM* pSIMCmdPrm; /* points to SIM command parameters */
1232 T_ACI_AT_CMD cmdBuf; /* buffers current command */
1233 T_ACI_CMD_SRC ownBuf; /* buffers current owner */
1234
1235 UBYTE* ptr; /* pointer to decoded data */
1236 UBYTE alphaLen; /* max. length of alpha identifier */
1237 UBYTE* pExchData; /* points to exchange data buffer */
1238 UBYTE dataLen; /* holds length of data */
1239
1240 TRACE_FUNCTION ("cmhSIM_CnfMsisdn()");
1241
1242 pSIMCmdPrm = &cmhPrm[simEntStat.entOwn].simCmdPrm;
1243 cmdBuf = simEntStat.curCmd;
1244 ownBuf = simEntStat.entOwn;
1245 pExchData = simShrdPrm.atb[table_id].exchData;
1246 dataLen = simShrdPrm.atb[table_id].dataLen;
1247
1248
1249 switch ( simShrdPrm.atb[table_id].errCode )
1250 {
1251 case ( SIM_NO_ERROR ):
1252 {
1253 /*
1254 *-------------------------------------------------------------
1255 * check basic consistency of read data
1256 *-------------------------------------------------------------
1257 */
1258 if ( pExchData EQ NULL OR
1259 dataLen < ACI_MIN_SIZE_EF_MSISDN )
1260 {
1261 /* Implements Measure 7, 17, 24, 35 */
1262 cmhSIM_SndError( ownBuf, cmdBuf, CME_ERR_Unknown );
1263 }
1264 else
1265 {
1266 ptr = pExchData;
1267 alphaLen = dataLen - ACI_MIN_SIZE_EF_MSISDN;
1268
1269 /*
1270 *-----------------------------------------------------------
1271 * process parameter <lenEfMsisdn>
1272 *-----------------------------------------------------------
1273 */
1274 CNUMLenEfMsisdn = dataLen;
1275
1276 /*
1277 *-----------------------------------------------------------
1278 * process parameter <cnumMaxRec>
1279 *-----------------------------------------------------------
1280 */
1281 if ( pSIMCmdPrm -> CNUMActRec EQ 1 )
1282 CNUMMaxRec = simShrdPrm.atb[table_id].recMax;
1283
1284 /*
1285 *-----------------------------------------------------------
1286 * process parameter <alpha>
1287 *-----------------------------------------------------------
1288 */
1289 cmhPHB_getTagNt ( ptr,
1290 alphaLen,
1291 CNUMMsisdn[CNUMMsisdnIdx].alpha,
1292 MAX_ALPHA_LEN );
1293
1294 ptr += alphaLen;
1295
1296 /*
1297 *-----------------------------------------------------------
1298 * process parameter <number>
1299 *-----------------------------------------------------------
1300 */
1301 cmhPHB_getAdrStr ( CNUMMsisdn[CNUMMsisdnIdx].number,
1302 MAX_PHB_NUM_LEN - 1,
1303 ptr + 2,
1304 *ptr );
1305
1306 /*
1307 *-----------------------------------------------------------
1308 * validate entry of MSISDN list
1309 *-----------------------------------------------------------
1310 */
1311 /* VO patch 14.03.01
1312 * move validate entry to after decoding alpha and number
1313 * and set the vldFlag only when the alpha or the number exists. */
1314 if ( strlen(CNUMMsisdn[CNUMMsisdnIdx].number) OR
1315 strlen(CNUMMsisdn[CNUMMsisdnIdx].alpha) )
1316 {
1317 CNUMMsisdn[CNUMMsisdnIdx].vldFlag = TRUE;
1318 pSIMCmdPrm -> CNUMOutput++;
1319 }
1320
1321 /*
1322 *-----------------------------------------------------------
1323 * process parameter <type>
1324 *-----------------------------------------------------------
1325 */
1326 cmhPHB_toaDmrg ( *( ptr + 1 ),
1327 &CNUMMsisdn[CNUMMsisdnIdx].type );
1328
1329 ptr += 12;
1330
1331 /*
1332 *-----------------------------------------------------------
1333 * invalidate parameter <speed>, <service>, <itc>
1334 *-----------------------------------------------------------
1335 */
1336 CNUMMsisdn[CNUMMsisdnIdx].speed = BS_SPEED_NotPresent;
1337 CNUMMsisdn[CNUMMsisdnIdx].service = CNUM_SERV_NotPresent;
1338 CNUMMsisdn[CNUMMsisdnIdx].itc = CNUM_ITC_NotPresent;
1339
1340 if ( *ptr NEQ 0xFF )
1341 {
1342 /*
1343 *---------------------------------------------------------
1344 * bearer capability EF present
1345 *---------------------------------------------------------
1346 */
1347 if ( cmhSIM_ReqCcp ( ownBuf, *ptr++ ) NEQ AT_EXCT )
1348 {
1349 /* Implements Measure 7, 17, 24, 35 */
1350 cmhSIM_SndError( ownBuf, cmdBuf, CME_ERR_Unknown );
1351 }
1352 }
1353 else
1354 {
1355 /* Implements Measure 200 */
1356
1357 if ( CNUMMsisdn[CNUMMsisdnIdx].vldFlag EQ FALSE )
1358 {
1359 CNUMMsisdnIdx--;
1360 }
1361
1362 cmhSIM_Compare_CNUMMsisdnIdx();
1363 }
1364 }
1365
1366 break;
1367 }
1368
1369 default:
1370 {
1371 /* Implements Measure 7, 17, 24, 35 */
1372 cmhSIM_SndError( ownBuf, cmdBuf,
1373 cmhSIM_GetCmeFromSim (simShrdPrm.atb[table_id].errCode) );
1374 break;
1375 }
1376
1377 }
1378
1379 simShrdPrm.atb[table_id].ntryUsdFlg = FALSE;
1380 }
1381
1382 /*
1383 +--------------------------------------------------------------------+
1384 | PROJECT : GSM-F&D (8411) MODULE : CMH_SIMR |
1385 | STATE : code ROUTINE : cmhSIM_CnfCcp |
1386 +--------------------------------------------------------------------+
1387
1388 PURPOSE : This function handles the confirmation of reading
1389 EF CCP from SIM.
1390 */
1391 GLOBAL void cmhSIM_CnfCcp ( SHORT table_id )
1392 {
1393 T_ACI_AT_CMD cmdBuf; /* buffers current command */
1394 T_ACI_CMD_SRC ownBuf; /* buffers current owner */
1395
1396 T_U_CALL_CONF* callCnf; /* call confirm message */
1397 T_M_CC_bearer_cap* bearCap; /* bearer capability */
1398 UBYTE* pExchData; /* points to exchange data buffer */
1399 UBYTE dataLen; /* holds length of data */
1400
1401 TRACE_FUNCTION ("cmhSIM_CnfCcp()");
1402
1403 cmdBuf = simEntStat.curCmd;
1404 ownBuf = simEntStat.entOwn;
1405 dataLen = simShrdPrm.atb[table_id].dataLen;
1406 pExchData = simShrdPrm.atb[table_id].exchData;
1407
1408 switch ( simShrdPrm.atb[table_id].errCode )
1409 {
1410 case ( SIM_NO_ERROR ):
1411 {
1412 /*
1413 *-------------------------------------------------------------
1414 * check basic consistency of read data
1415 *-------------------------------------------------------------
1416 */
1417 if ( pExchData EQ NULL OR
1418 dataLen NEQ ACI_SIZE_EF_CCP )
1419 {
1420 /* Implements Measure 7, 17, 24, 35 */
1421 cmhSIM_SndError( ownBuf, cmdBuf, CME_ERR_Unknown );
1422 }
1423 else
1424 {
1425 /*
1426 *-----------------------------------------------------------
1427 * extracting the relevant data from bearer capability IE
1428 *-----------------------------------------------------------
1429 */
1430 UBYTE bearCapLen = pExchData[0];
1431
1432 if (bearCapLen <= 13 ) /* do not decode empty or invalid entries,
1433 see 11.11/10.5.4.1 max 14 bytes */
1434 {
1435 /*lint -e415 -e416 -e669 (Waring: creation of out of bound ptr or data overrun)*/
1436 PALLOC_MSG ( msg, MMCM_DATA_REQ, U_CALL_CONF);
1437
1438 msg -> sdu.l_buf = bearCapLen * 0x08;
1439 msg -> sdu.o_buf = 0x08;
1440 msg -> sdu.buf[0] = 0x83;
1441 msg -> sdu.buf[1] = U_CALL_CONF;
1442
1443 memcpy ( &msg -> sdu.buf[2],
1444 pExchData,
1445 bearCapLen+1);
1446 /*lint +e415 +e416 +e669 (Waring: creation of out of bound ptr or data overrun)*/
1447 /*
1448 *-----------------------------------------------------------
1449 * use of CCD for decoding of bearer capability
1450 *-----------------------------------------------------------
1451 */
1452 CCD_START;
1453
1454 memset (_decodedMsg, 0, sizeof (_decodedMsg));
1455
1456 if ( ccd_decodeMsg ( CCDENT_CC,
1457 UPLINK,
1458 (T_MSGBUF *) &msg->sdu,
1459 (UBYTE *) _decodedMsg,
1460 NOT_PRESENT_8BIT) EQ ccdOK
1461 AND
1462
1463 _decodedMsg[0] EQ U_CALL_CONF )
1464 {
1465 callCnf = ( T_U_CALL_CONF * )&_decodedMsg[0];
1466
1467 if ( callCnf -> v_bearer_cap )
1468 {
1469 bearCap = &callCnf -> bearer_cap;
1470
1471 /*
1472 *-------------------------------------------------------
1473 * process parameter <speed> of MSISDN
1474 *-------------------------------------------------------
1475 */
1476 if ( bearCap -> v_user_rate )
1477 {
1478 CNUMMsisdn[CNUMMsisdnIdx].speed =
1479 cmhSIM_GetUserRate ( bearCap -> user_rate );
1480 }
1481
1482 /*
1483 *-------------------------------------------------------
1484 * process parameter <itc> and <service> of MSISDN
1485 *-------------------------------------------------------
1486 */
1487 if ( bearCap -> v_trans_cap )
1488 {
1489 CNUMMsisdn[CNUMMsisdnIdx].itc =
1490 cmhSIM_GetItc ( bearCap -> trans_cap );
1491 }
1492
1493 if ( bearCap -> v_user_inf_l2_prot AND
1494 bearCap -> user_inf_l2_prot EQ M_CC_L2_X25 AND
1495 bearCap -> v_sync_async AND
1496 bearCap -> sync_async EQ M_CC_SYNCHRONOUS )
1497 {
1498 CNUMMsisdn[CNUMMsisdnIdx].service =
1499 CNUM_SERV_PacketSynch;
1500 }
1501 else if
1502 ( bearCap -> v_sig_access_prot
1503 AND
1504 ( bearCap -> sig_access_prot EQ M_CC_SIAP_X28_INDIV_NUI OR
1505 bearCap -> sig_access_prot EQ M_CC_SIAP_X28_UNIV_NUI OR
1506 bearCap -> sig_access_prot EQ M_CC_SIAP_X28_NON_DEDIC
1507 )
1508
1509 AND
1510 bearCap -> v_sync_async
1511 AND
1512 bearCap -> sync_async EQ M_CC_ASYNCHRONOUS
1513 )
1514 {
1515 CNUMMsisdn[CNUMMsisdnIdx].service =
1516 CNUM_SERV_PadAsynch;
1517 }
1518 else if ( bearCap -> v_sync_async )
1519 {
1520 CNUMMsisdn[CNUMMsisdnIdx].service =
1521 cmhSIM_GetSrvFromSync ( bearCap -> sync_async );
1522
1523 }
1524 else if ( bearCap -> v_trans_cap )
1525 {
1526 CNUMMsisdn[CNUMMsisdnIdx].service =
1527 cmhSIM_GetSrvFromItc ( bearCap -> trans_cap );
1528 }
1529 }
1530 }
1531 CCD_END;
1532
1533 PFREE ( msg );
1534 }
1535
1536 /*
1537 *-----------------------------------------------------------
1538 * tmpActRec is used to prevent conflicts with global
1539 * variable pSIMCmdPrm -> CNUMActRec
1540 *-----------------------------------------------------------
1541 */
1542 /* Implements Measure 200 */
1543 cmhSIM_Compare_CNUMMsisdnIdx();
1544 }
1545
1546 break;
1547 }
1548
1549 default:
1550 {
1551 /* Implements Measure 7, 17, 24, 35 */
1552 cmhSIM_SndError( ownBuf, cmdBuf,
1553 cmhSIM_GetCmeFromSim(simShrdPrm.atb[table_id].errCode));
1554 break;
1555 }
1556
1557 }
1558
1559 simShrdPrm.atb[table_id].ntryUsdFlg = FALSE;
1560 }
1561
1562 /*
1563 +--------------------------------------------------------------------+
1564 | PROJECT : GSM-F&D (8411) MODULE : CMH_SIMR |
1565 | STATE : code ROUTINE : cmhSIM_RdCnfPlmnSel|
1566 +--------------------------------------------------------------------+
1567
1568 PURPOSE : This function handles the confirmation of reading
1569 EF PLMN SEL from SIM.
1570 */
1571 GLOBAL void cmhSIM_RdCnfPlmnSel ( SHORT table_id )
1572 {
1573 T_SIM_CMD_PRM * pSIMCmdPrm; /* points to SIM command parameters */
1574 T_ACI_AT_CMD cmdBuf; /* buffers current command */
1575 T_ACI_CMD_SRC ownBuf; /* buffers current owner */
1576 T_ACI_CPOL_LST CPOLPlmnSelLst; /* PLMN SEL list */
1577 T_ACI_RETURN ret;
1578 SHORT lastIdx; /* holds last index */
1579 SHORT usdNtry; /* holds number of used entries */
1580
1581 TRACE_FUNCTION ("cmhSIM_RdCnfPlmnSel()");
1582
1583 pSIMCmdPrm = &cmhPrm[simEntStat.entOwn].simCmdPrm;
1584 cmdBuf = simEntStat.curCmd;
1585 ownBuf = simEntStat.entOwn;
1586
1587
1588 switch ( simShrdPrm.atb[table_id].errCode )
1589 {
1590 case ( SIM_NO_ERROR ):
1591 {
1592 /*
1593 *-------------------------------------------------------------
1594 * check basic consistency of read data
1595 *-------------------------------------------------------------
1596 */
1597 if ( simShrdPrm.atb[table_id].exchData EQ NULL OR
1598 simShrdPrm.atb[table_id].dataLen < ACI_MIN_SIZE_EF_PLMN_SEL)
1599 {
1600 pSIMCmdPrm->CPOLact = CPOL_ACT_None;
1601 /* Implements Measure 7, 17, 24, 35 */
1602 cmhSIM_SndError( ownBuf, cmdBuf, CME_ERR_Unknown );
1603 break;
1604 }
1605
1606 EfPLMNselStat = EF_STAT_READ;
1607 CPOLSimEfDataLen = simShrdPrm.atb[table_id].dataLen;
1608
1609 if( pSIMCmdPrm->CPOLmode EQ CPOL_MOD_CompactList )
1610 {
1611 cmhSIM_CmpctPlmnSel( simShrdPrm.atb[table_id].dataLen,
1612 simShrdPrm.atb[table_id].exchData );
1613 }
1614
1615 /*
1616 *-----------------------------------------------------------
1617 * what is to do ?
1618 *-----------------------------------------------------------
1619 */
1620 switch( pSIMCmdPrm->CPOLact )
1621 {
1622 /*
1623 *-----------------------------------------------------------
1624 * read out PLMN SEL list
1625 *-----------------------------------------------------------
1626 */
1627 case( CPOL_ACT_Read ):
1628
1629 /* fill in buffer */
1630 lastIdx = cmhSIM_FillPlmnSelList(pSIMCmdPrm->CPOLidx,
1631 pSIMCmdPrm->CPOLfrmt,
1632 &CPOLPlmnSelLst[0],
1633 simShrdPrm.atb[table_id].dataLen,
1634 (UBYTE *)simShrdPrm.atb[table_id].exchData);
1635 /* notify about PLMN SEL list */
1636 simEntStat.curCmd = AT_CMD_NONE;
1637 simShrdPrm.owner = (T_OWN)CMD_SRC_NONE;
1638 simEntStat.entOwn = CMD_SRC_NONE;
1639
1640 R_AT( RAT_CPOL, ownBuf ) ( ACI_NumParmNotPresent,
1641 lastIdx,
1642 &CPOLPlmnSelLst[0],
1643 ACI_NumParmNotPresent );
1644
1645 R_AT( RAT_OK, ownBuf )( AT_CMD_CPOL );
1646 break;
1647
1648 /*
1649 *-----------------------------------------------------------
1650 * write PLMN SEL list
1651 *-----------------------------------------------------------
1652 */
1653 case( CPOL_ACT_Write ):
1654
1655 if( pSIMCmdPrm->CPOLidx EQ NOT_PRESENT_8BIT )
1656
1657 ret = cmhSIM_FndEmptyPlmnSel( simEntStat.entOwn,
1658 pSIMCmdPrm->CPOLplmn );
1659 else
1660
1661 ret = cmhSIM_UpdPlmnSel( simEntStat.entOwn,
1662 pSIMCmdPrm->CPOLidx,
1663 pSIMCmdPrm->CPOLplmn,
1664 pSIMCmdPrm->CPOLmode);
1665 if( ret EQ AT_FAIL )
1666 {
1667 pSIMCmdPrm->CPOLact = CPOL_ACT_None;
1668 /* Implements Measure 7, 17, 24, 35 */
1669
1670 /* T_ACI_CME_ERR is used for TypeCast as the
1671 * ACI_ERR_DESC_NR() will retrun ULONG and the function expects
1672 * T_ACI_CME_ERR and there will no major harm as well.
1673 */
1674 cmhSIM_SndError( simEntStat.entOwn, AT_CMD_CPOL,
1675 (T_ACI_CME_ERR) ACI_ERR_DESC_NR( aciErrDesc ));
1676 }
1677 break;
1678
1679 /*
1680 *-----------------------------------------------------------
1681 * delete PLMN SEL entry
1682 *-----------------------------------------------------------
1683 */
1684 case( CPOL_ACT_Delete ):
1685
1686 if( pSIMCmdPrm->CPOLidx2 EQ NOT_PRESENT_8BIT )
1687
1688 ret = cmhSIM_DelPlmnSel( simEntStat.entOwn,
1689 pSIMCmdPrm->CPOLidx,
1690 pSIMCmdPrm->CPOLmode );
1691 else
1692
1693 ret = cmhSIM_ChgPlmnSel( simEntStat.entOwn,
1694 pSIMCmdPrm->CPOLidx,
1695 pSIMCmdPrm->CPOLidx2 );
1696
1697 if( ret EQ AT_FAIL )
1698 {
1699 pSIMCmdPrm->CPOLact = CPOL_ACT_None;
1700 /* Implements Measure 7, 17, 24, 35 */
1701
1702 /* T_ACI_CME_ERR is used for TypeCast as the ACI_ERR_DESC_NR()
1703 * will retrun ULONG and the function expects T_ACI_CME_ERR
1704 * and there will no major harm as well
1705 */
1706 cmhSIM_SndError( simEntStat.entOwn, AT_CMD_CPOL,
1707 (T_ACI_CME_ERR) ACI_ERR_DESC_NR( aciErrDesc ));
1708 }
1709 break;
1710
1711 /*
1712 *-----------------------------------------------------------
1713 * test PLMN SEL entry number
1714 *-----------------------------------------------------------
1715 */
1716 case( CPOL_ACT_Test ):
1717
1718 /* notify about PLMN SEL entry number */
1719 simEntStat.curCmd = AT_CMD_NONE;
1720 simShrdPrm.owner = (T_OWN)CMD_SRC_NONE;
1721 simEntStat.entOwn = CMD_SRC_NONE;
1722
1723 lastIdx = CPOLSimEfDataLen / ACI_LEN_PLMN_SEL_NTRY;
1724 usdNtry = cmhSIM_UsdPlmnSelNtry( CPOLSimEfDataLen,
1725 (UBYTE *)simShrdPrm.atb[table_id].exchData );
1726
1727 R_AT( RAT_CPOL, ownBuf ) ( ACI_NumParmNotPresent,
1728 lastIdx,
1729 NULL,
1730 usdNtry );
1731
1732 R_AT( RAT_OK, ownBuf )( AT_CMD_CPOL );
1733 break;
1734 }
1735 break;
1736 }
1737
1738 case ( SIM_CAUSE_UNKN_FILE_ID ):
1739 EfPLMNselStat = EF_STAT_NOT_AVAIL;
1740 /*lint -fallthrough*/
1741 /*lint -fallthrough*/
1742 default:
1743 {
1744 pSIMCmdPrm->CPOLact = CPOL_ACT_None;
1745 /* Implements Measure 7, 17, 24, 35 */
1746 cmhSIM_SndError( ownBuf, cmdBuf,
1747 cmhSIM_GetCmeFromSim(simShrdPrm.atb[table_id].errCode));
1748 break;
1749 }
1750
1751 }
1752
1753 simShrdPrm.atb[table_id].ntryUsdFlg = FALSE;
1754
1755 }
1756
1757 /*
1758 +--------------------------------------------------------------------+
1759 | PROJECT : GSM-F&D (8411) MODULE : CMH_SIMR |
1760 | STATE : code ROUTINE : cmhSIM_WrCnfPlmnSel|
1761 +--------------------------------------------------------------------+
1762
1763 PURPOSE : This function handles the confirmation of writing
1764 EF PLMN SEL to SIM.
1765 */
1766 GLOBAL void cmhSIM_WrCnfPlmnSel ( SHORT table_id )
1767 {
1768 T_SIM_CMD_PRM * pSIMCmdPrm; /* points to SIM command parameters */
1769 UBYTE ownBuf;
1770
1771 TRACE_FUNCTION ("cmhSIM_WrCnfPlmnSel()");
1772
1773 pSIMCmdPrm = &cmhPrm[simEntStat.entOwn].simCmdPrm;
1774 ownBuf = simEntStat.entOwn;
1775
1776 switch ( simShrdPrm.atb[table_id].errCode )
1777 {
1778 /* successful PLMN SEL list update */
1779 case ( SIM_NO_ERROR ):
1780 {
1781 pSIMCmdPrm->CPOLact = CPOL_ACT_None;
1782 simEntStat.curCmd = AT_CMD_NONE;
1783 simShrdPrm.owner = (T_OWN)CMD_SRC_NONE;
1784 simEntStat.entOwn = CMD_SRC_NONE;
1785
1786 R_AT( RAT_OK, (T_ACI_CMD_SRC)ownBuf )( AT_CMD_CPOL );
1787 break;
1788 }
1789 case SIM_CAUSE_ACCESS_PROHIBIT:
1790 {
1791 pSIMCmdPrm->CPOLact = CPOL_ACT_None;
1792 /* Implements Measure 7, 17, 24, 35 */
1793 cmhSIM_SndError((T_ACI_CMD_SRC)ownBuf, AT_CMD_CPOL, CME_ERR_OpNotAllow );
1794 break;
1795 }
1796
1797 /* unsuccessful PLMN SEL list update */
1798 default:
1799 {
1800 pSIMCmdPrm->CPOLact = CPOL_ACT_None;
1801 /* Implements Measure 7, 17, 24, 35 */
1802 cmhSIM_SndError((T_ACI_CMD_SRC)ownBuf, AT_CMD_CPOL,
1803 cmhSIM_GetCmeFromSim(simShrdPrm.atb[table_id].errCode));
1804 break;
1805 }
1806 }
1807
1808 simShrdPrm.atb[table_id].ntryUsdFlg = FALSE;
1809 }
1810
1811 /*
1812 +--------------------------------------------------------------------+
1813 | PROJECT : GSM-F&D (8411) MODULE : CMH_SIMR |
1814 | STATE : code ROUTINE : cmhSIM_RdCnfLangELP|
1815 +--------------------------------------------------------------------+
1816
1817 PURPOSE : This function handles the confirmation of reading
1818 from the SIM (EF ELP).
1819 */
1820 GLOBAL void cmhSIM_RdCnfLangELP ( SHORT table_id )
1821 {
1822 T_SIM_CMD_PRM *pSIMCmdPrm; /* points to SIM command parameters */
1823 T_PHB_CMD_PRM *pPHBCmdPrm; /* points to PHB command parameter */
1824
1825 T_ACI_AT_CMD cmdBuf; /* buffers current command */
1826 T_ACI_CMD_SRC ownBuf; /* buffers current owner */
1827 CHAR Clang_buffer[3]={0};/* Current language */
1828 T_ACI_LAN_SUP clng;
1829 EF_CLNG lng;
1830 BOOL Suplng = FALSE;
1831 T_ACI_LAN_SUP LngPCMsupLst[MAX_LAN];
1832 SHORT lastIdx;
1833 T_ACI_RETURN ret ;
1834
1835 TRACE_FUNCTION ("cmhSIM_RdCnfLangELP()");
1836
1837 pSIMCmdPrm = &cmhPrm[simEntStat.entOwn].simCmdPrm;
1838 cmdBuf = simEntStat.curCmd;
1839 ownBuf = simEntStat.entOwn;
1840 pPHBCmdPrm = &cmhPrm[ownBuf].phbCmdPrm;
1841 simShrdPrm.atb[table_id].ntryUsdFlg = FALSE;
1842 simEntStat.curCmd = AT_CMD_NONE;
1843
1844 clng.str = Clang_buffer;
1845
1846 switch ( simShrdPrm.atb[table_id].errCode )
1847 {
1848 case ( SIM_NO_ERROR ):
1849 /*
1850 *-------------------------------------------------------------
1851 * check basic consistency of read data
1852 *-------------------------------------------------------------
1853 */
1854 if ( simShrdPrm.atb[table_id].exchData EQ NULL OR
1855 simShrdPrm.atb[table_id].dataLen < ACI_MIN_SIZE_EF_LAN)
1856
1857 {
1858 pSIMCmdPrm->CLANact = CLAN_ACT_None;
1859 simShrdPrm.owner = (T_OWN)CMD_SRC_NONE;
1860 simEntStat.entOwn = CMD_SRC_NONE;
1861
1862 R_AT( RAT_CME, ownBuf ) ( cmdBuf, CME_ERR_Unknown );
1863 return;
1864 }
1865
1866 memcpy(clng.str, (UBYTE *)simShrdPrm.atb[table_id].exchData, CLAN_CODE_LEN);
1867 ret=getSupLangFromPCM(&LngPCMsupLst[0], &lastIdx);
1868 if (ret EQ AT_FAIL)
1869 {
1870 return;
1871 }
1872 Suplng=checkSuppLang(&LngPCMsupLst[0],lastIdx, &clng);
1873 simShrdPrm.owner = (T_OWN)CMD_SRC_NONE;
1874 simEntStat.entOwn = CMD_SRC_NONE;
1875
1876 /*
1877 *---------------------------------------------------------------------
1878 * check if the language,which was read from EF ELP is supported in PCM
1879 *---------------------------------------------------------------------
1880 */
1881 if(Suplng)
1882 {
1883 switch( pSIMCmdPrm->CLANact )
1884 {
1885 case( CLAN_ACT_Read ):
1886 R_AT( RAT_CLAN, ownBuf ) (&clng);
1887 R_AT( RAT_OK, ownBuf )( AT_CMD_CLAN );
1888 break;
1889 case( CLAN_ACT_Write ):
1890 memcpy(lng.data,clng.str ,CLAN_CODE_LEN);
1891 /* Implements Measure#32 Row 1072 */
1892 pcm_WriteFile (( UBYTE* )ef_clng_id,SIZE_EF_CLNG,( UBYTE*) &lng);
1893
1894 if (pPHBCmdPrm->CLAEmode EQ CLAE_MOD_Enable)
1895 R_AT( RAT_CLAE, ownBuf ) (&clng);
1896
1897 R_AT( RAT_OK, ownBuf )( AT_CMD_CLAN );
1898 break;
1899 }
1900 }
1901 else
1902 /*
1903 *-------------------------------------------------------------
1904 * read the EF LP if the language is not supported in PCM
1905 *-------------------------------------------------------------
1906 */
1907 /* Implements Measure 150 and 159 */
1908 cmhSIM_ReqLanguage_LP_or_ELP ( ownBuf, SIM_LP );
1909 break;
1910
1911 /*
1912 *-------------------------------------------------------------
1913 * read the EF LP if the EF ELP not available
1914 *-------------------------------------------------------------
1915 */
1916 case ( SIM_CAUSE_UNKN_FILE_ID ):
1917 /* Implements Measure 150 and 159 */
1918 cmhSIM_ReqLanguage_LP_or_ELP ( ownBuf, SIM_LP );
1919 break;
1920
1921 default:
1922 pSIMCmdPrm->CLANact = CLAN_ACT_None;
1923 simShrdPrm.owner = (T_OWN)CMD_SRC_NONE;
1924 simEntStat.entOwn = CMD_SRC_NONE;
1925
1926 R_AT( RAT_CME, ownBuf) ( AT_CMD_CLAN, CME_ERR_Unknown );
1927 break;
1928
1929 }
1930
1931 }
1932
1933
1934 /*
1935 +------------------------------------------------------------------------+
1936 | PROJECT : GSM-F&D (8411) MODULE : CMH_SIMR |
1937 | STATE : code ROUTINE : cmhSIM_RdCnfLangPrfELP |
1938 +------------------------------------------------------------------------+
1939
1940 PURPOSE : This function handles the confirmation of reading
1941 from the SIM (EF ELP) for SAT feature LS.
1942 */
1943 GLOBAL void cmhSIM_RdCnfLangPrfELP ( SHORT table_id )
1944 {
1945
1946 T_ACI_SAT_TERM_RESP resp_data;
1947 CHAR Clang_buffer[3]={0};/* Current language */
1948 T_ACI_LAN_SUP clng;
1949 BOOL Suplng = FALSE;
1950 T_ACI_LAN_SUP LngPCMsupLst[MAX_LAN];
1951 SHORT lastIdx;
1952 T_ACI_RETURN ret ;
1953
1954
1955 TRACE_FUNCTION ("cmhSIM_RdCnfLangPrfELP()");
1956
1957 psaSAT_InitTrmResp( &resp_data );
1958
1959 simShrdPrm.atb[table_id].ntryUsdFlg = FALSE;
1960
1961 clng.str = Clang_buffer;
1962
1963 switch ( simShrdPrm.atb[table_id].errCode )
1964 {
1965 case ( SIM_NO_ERROR ):
1966 /*
1967 *-------------------------------------------------------------
1968 * check basic consistency of read data
1969 *-------------------------------------------------------------
1970 */
1971 if ( simShrdPrm.atb[table_id].exchData EQ NULL OR
1972 simShrdPrm.atb[table_id].dataLen < ACI_MIN_SIZE_EF_LAN)
1973
1974 {
1975 psaSAT_SendTrmResp( RSLT_ME_UNAB_PROC, &resp_data );
1976 return;
1977 }
1978
1979 memcpy(clng.str, (UBYTE *)simShrdPrm.atb[table_id].exchData, CLAN_CODE_LEN);
1980 ret=getSupLangFromPCM(&LngPCMsupLst[0], &lastIdx);
1981 if (ret EQ AT_FAIL)
1982 {
1983 psaSAT_SendTrmResp( RSLT_ME_UNAB_PROC, &resp_data );
1984 return;
1985 }
1986
1987 Suplng=checkSuppLang(&LngPCMsupLst[0],lastIdx, &clng);
1988
1989
1990 /*
1991 *---------------------------------------------------------------------
1992 * check if the language,which was read from EF ELP is supported in PCM
1993 *---------------------------------------------------------------------
1994 */
1995 if(Suplng)
1996 {
1997 /* Send Terminal resp*/
1998 memcpy(&resp_data.lang, (UBYTE *)simShrdPrm.atb[table_id].exchData, CLAN_CODE_LEN);
1999 psaSAT_SendTrmResp( RSLT_PERF_SUCCESS, &resp_data );
2000
2001 }
2002 else
2003 {
2004 /*
2005 *-------------------------------------------------------------
2006 * read the EF LP if the language is not supported in PCM
2007 *-------------------------------------------------------------
2008 */
2009 /* Implements Measure 119 */
2010 if ( cmhSIM_ReqLanguagePrf_LP_or_ELP( SIM_LP, ACI_MAX_LAN_LP_NTRY,
2011 CLANSimEfDataLP,
2012 cmhSIM_RdCnfLangPrfLP ) EQ FALSE )
2013 {
2014 psaSAT_SendTrmResp( RSLT_ME_UNAB_PROC, &resp_data );
2015 }
2016 }
2017 break;
2018
2019 /*
2020 *-------------------------------------------------------------
2021 * read the EF LP if the EF ELP not available
2022 *-------------------------------------------------------------
2023 */
2024 case ( SIM_CAUSE_UNKN_FILE_ID ):
2025 /* Implements Measure 119 */
2026 if (cmhSIM_ReqLanguagePrf_LP_or_ELP ( SIM_LP, ACI_MAX_LAN_LP_NTRY,
2027 CLANSimEfDataLP,
2028 cmhSIM_RdCnfLangPrfLP ) EQ FALSE )
2029 {
2030 psaSAT_SendTrmResp( RSLT_ME_UNAB_PROC, &resp_data );
2031 }
2032 break;
2033
2034 default:
2035 psaSAT_SendTrmResp( RSLT_ME_UNAB_PROC, &resp_data );
2036 break;
2037
2038 }
2039 }
2040
2041
2042 /*
2043 +--------------------------------------------------------------------+
2044 | PROJECT : GSM-F&D (8411) MODULE : CMH_SIMR |
2045 | STATE : code ROUTINE : cmhSIM_RdCnfLangLP |
2046 +--------------------------------------------------------------------+
2047
2048 PURPOSE : This function handles the confirmation of reading
2049 EF LP from SIM.
2050 */
2051 GLOBAL void cmhSIM_RdCnfLangLP ( SHORT table_id )
2052 {
2053 T_SIM_CMD_PRM * pSIMCmdPrm; /* points to SIM command parameters */
2054 T_PHB_CMD_PRM * pPHBCmdPrm; /* points to PHB command parameter */
2055 T_ACI_AT_CMD cmdBuf; /* buffers current command */
2056 T_ACI_CMD_SRC ownBuf; /* buffers current owner */
2057 T_ACI_LAN_SUP clng;
2058 EF_CLNG lng;
2059 BOOL Suplng= FALSE;
2060 SHORT lastIdx;
2061 T_ACI_LAN_SUP LngPCMsupLst[MAX_LAN];
2062
2063
2064 TRACE_FUNCTION ("cmhSIM_RdCnfLangLP()");
2065
2066 pSIMCmdPrm = &cmhPrm[simEntStat.entOwn].simCmdPrm;
2067 cmdBuf = simEntStat.curCmd;
2068 ownBuf = simEntStat.entOwn;
2069 pPHBCmdPrm = &cmhPrm[ownBuf].phbCmdPrm;
2070 simShrdPrm.atb[table_id].ntryUsdFlg = FALSE;
2071 simEntStat.curCmd = AT_CMD_NONE;
2072
2073 clng.lng=(T_ACI_CLAN_LNG)simShrdPrm.atb[table_id].exchData[0];
2074
2075 getSupLangFromPCM(&LngPCMsupLst[0], &lastIdx);
2076 Suplng=checkSuppLangInLP(&LngPCMsupLst[0],lastIdx, &clng);
2077
2078 if ( simShrdPrm.atb[table_id].errCode EQ SIM_NO_ERROR AND
2079 Suplng )
2080 {
2081 simShrdPrm.owner = (T_OWN)CMD_SRC_NONE;
2082 simEntStat.entOwn = CMD_SRC_NONE;
2083 /*
2084 *-------------------------------------------------------------
2085 * check basic consistency of read data
2086 *-------------------------------------------------------------
2087 */
2088 if ( simShrdPrm.atb[table_id].exchData EQ NULL OR
2089 simShrdPrm.atb[table_id].dataLen < ACI_LEN_LAN_LP_NTRY)
2090
2091 {
2092 simShrdPrm.owner = (T_OWN)CMD_SRC_NONE;
2093 simEntStat.entOwn = CMD_SRC_NONE;
2094 pSIMCmdPrm->CLANact = CLAN_ACT_None;
2095 R_AT( RAT_CME, ownBuf ) ( cmdBuf, CME_ERR_Unknown );
2096 return;
2097 }
2098
2099 #ifdef SIM_TOOLKIT
2100 if (simShrdPrm.fuRef >= 0)
2101 {
2102 psaSAT_FUConfirm (simShrdPrm.fuRef, SIM_FU_SUCCESS);
2103 }
2104 #endif
2105
2106 /*
2107 *-----------------------------------------------------
2108 * read the supported laguage or write it PCM
2109 *-----------------------------------------------------
2110 */
2111 switch( pSIMCmdPrm->CLANact )
2112 {
2113 case( CLAN_ACT_Read ):
2114 R_AT( RAT_CLAN, ownBuf ) (&clng);
2115 R_AT( RAT_OK, ownBuf )( AT_CMD_CLAN );
2116 break;
2117 case( CLAN_ACT_Write ):
2118 memcpy(lng.data,(UBYTE *) clng.str,CLAN_CODE_LEN);
2119 /* Implements Measure#32 Row 1072 */
2120 pcm_WriteFile (( UBYTE* )ef_clng_id,SIZE_EF_CLNG,( UBYTE*) &lng);
2121 if (pPHBCmdPrm->CLAEmode EQ CLAE_MOD_Enable)
2122 { R_AT( RAT_CLAE, ownBuf ) (&clng);}
2123
2124 R_AT( RAT_OK, ownBuf )( AT_CMD_CLAN );
2125 break;
2126
2127 }
2128 }
2129 else
2130 {
2131
2132 #ifdef SIM_TOOLKIT
2133 if (simShrdPrm.fuRef >= 0)
2134 {
2135 psaSAT_FUConfirm (simShrdPrm.fuRef, SIM_FU_ERROR);
2136 }
2137 #endif
2138 /*
2139 *---------------------------------------------------------------
2140 * Preferred language is not supported in MS
2141 *---------------------------------------------------------------
2142 */
2143 if ( simShrdPrm.atb[table_id].errCode EQ SIM_CAUSE_UNKN_FILE_ID OR
2144 !Suplng )
2145 {
2146 TRACE_FUNCTION ("preferred language not supported");
2147
2148 switch( pSIMCmdPrm->CLANact )
2149 {
2150 case( CLAN_ACT_Read ):
2151 R_AT( RAT_CLAN, ownBuf ) (&LngPCMsupLst[0]);
2152 R_AT( RAT_OK, ownBuf )( AT_CMD_CLAN );
2153 break;
2154 case( CLAN_ACT_Write ): /* Preferred Language not supported,so not change CLAN */
2155 R_AT( RAT_OK, ownBuf )( AT_CMD_CLAN );
2156 break;
2157 }
2158 }
2159 else
2160 {
2161 pSIMCmdPrm->CLANact = CLAN_ACT_None;
2162 simShrdPrm.owner = (T_OWN)CMD_SRC_NONE;
2163 simEntStat.entOwn = CMD_SRC_NONE;
2164 R_AT( RAT_CME, ownBuf) ( AT_CMD_CLAN, CME_ERR_Unknown );
2165 }
2166 }
2167 }
2168
2169
2170 /*
2171 +-----------------------------------------------------------------------+
2172 | PROJECT : GSM-F&D (8411) MODULE : CMH_SIMR |
2173 | STATE : code ROUTINE : cmhSIM_RdCnfLangPrfLP |
2174 +-----------------------------------------------------------------------+
2175
2176 PURPOSE : This function handles the confirmation of reading
2177 EF LP from SIM for SAT feature LS.
2178 */
2179 GLOBAL void cmhSIM_RdCnfLangPrfLP ( SHORT table_id )
2180 {
2181
2182 T_ACI_SAT_TERM_RESP resp_data;
2183 T_ACI_LAN_SUP clng;
2184 BOOL Suplng= FALSE;
2185 SHORT lastIdx;
2186 T_ACI_LAN_SUP lngPCMsupLst[MAX_LAN];
2187 T_ACI_RETURN ret;
2188
2189 TRACE_FUNCTION ("cmhSIM_RdCnfLangPrfLP()");
2190
2191 psaSAT_InitTrmResp( &resp_data );
2192
2193 simShrdPrm.atb[table_id].ntryUsdFlg = FALSE;
2194
2195 clng.lng=(T_ACI_CLAN_LNG)simShrdPrm.atb[table_id].exchData[0];
2196 ret = getSupLangFromPCM(&lngPCMsupLst[0], &lastIdx);
2197 if(ret EQ AT_FAIL)
2198 {
2199 psaSAT_SendTrmResp( RSLT_ME_UNAB_PROC, &resp_data );
2200 return;
2201 }
2202
2203 Suplng=checkSuppLangInLP(&lngPCMsupLst[0],lastIdx, &clng);
2204
2205 if ( simShrdPrm.atb[table_id].errCode EQ SIM_NO_ERROR AND
2206 Suplng )
2207 {
2208 /*
2209 *-------------------------------------------------------------
2210 * check basic consistency of read data
2211 *-------------------------------------------------------------
2212 */
2213 if ( simShrdPrm.atb[table_id].exchData EQ NULL OR
2214 simShrdPrm.atb[table_id].dataLen < ACI_LEN_LAN_LP_NTRY)
2215
2216 {
2217 psaSAT_SendTrmResp( RSLT_ME_UNAB_PROC, &resp_data );
2218 return;
2219 }
2220
2221 #ifdef SIM_TOOLKIT
2222 if (simShrdPrm.fuRef >= 0)
2223 {
2224 psaSAT_FUConfirm (simShrdPrm.fuRef, SIM_FU_SUCCESS);
2225 }
2226 #endif
2227
2228 /*
2229 *-----------------------------------------------------
2230 * Send the Terminal Response
2231 *-----------------------------------------------------
2232 */
2233 memcpy(&resp_data.lang, clng.str, CLAN_CODE_LEN);
2234 psaSAT_SendTrmResp( RSLT_PERF_SUCCESS, &resp_data );
2235 }
2236 else
2237 {
2238
2239 #ifdef SIM_TOOLKIT
2240 if (simShrdPrm.fuRef >= 0)
2241 {
2242 psaSAT_FUConfirm (simShrdPrm.fuRef, SIM_FU_ERROR);
2243 }
2244 #endif
2245 /*
2246 *---------------------------------------------------------------
2247 * read default language from ME
2248 *---------------------------------------------------------------
2249 */
2250
2251 if ( simShrdPrm.atb[table_id].errCode EQ SIM_CAUSE_UNKN_FILE_ID OR
2252 !Suplng )
2253 {
2254 TRACE_FUNCTION ("default language is selected");
2255 memcpy(&resp_data.lang, &lngPCMsupLst[0].str, CLAN_CODE_LEN);
2256 psaSAT_SendTrmResp( RSLT_PERF_SUCCESS, &resp_data );
2257
2258 }
2259 else
2260 {
2261 psaSAT_SendTrmResp( RSLT_ME_UNAB_PROC, &resp_data );
2262 }
2263
2264 }
2265
2266 }
2267
2268
2269 /*
2270 +--------------------------------------------------------------------------+
2271 | PROJECT : GSM-F&D (8411) MODULE : CMH_SIMR |
2272 | STATE : code ROUTINE : SIM_ENT_CSDconnect_dti_cb |
2273 +--------------------------------------------------------------------------+
2274
2275 PURPOSE : Callback for connection between SIM and TRA/L2R for CSD.
2276
2277 */
2278 #ifdef FF_SAT_E
2279 #ifdef DTI
2280 GLOBAL BOOL SIM_ENT_CSDconnect_dti_cb(UBYTE dti_id, T_DTI_CONN_STATE result_type)
2281 {
2282 TRACE_FUNCTION("SIM_ENT_CSDconnect_dti_cb");
2283
2284 switch( result_type)
2285 {
2286 case DTI_CONN_STATE_DISCONNECTING:
2287 break;
2288 case DTI_CONN_STATE_DISCONNECTED:
2289 /* wap_state is set to IPA_Deactivated in psaTCPIP_config_dispatch() */
2290 if (wap_state EQ UDPA_Deactivation)
2291 {
2292 wap_state = IPA_Deactivation;
2293 psaUDPIP_config_dispatch();
2294 }
2295 dti_cntrl_erase_entry(dti_id);
2296 dti_cntrl_clear_conn_parms(dti_id);
2297 if (simShrdPrm.sat_class_e_dti_id EQ dti_id)
2298 {
2299 simShrdPrm.sat_class_e_dti_id = DTI_DTI_ID_NOTPRESENT;
2300 TRACE_EVENT("sat_class_e_dti_id reset");
2301 }
2302 break;
2303 case DTI_CONN_STATE_CONNECTING:
2304 break;
2305 case DTI_CONN_STATE_CONNECTED:
2306 /* the SIM-SNDCP connection has been established, now send SIM_BIP_CONFIG
2307 * request to SIM */
2308 psaSIM_Bip_Config_Req();
2309
2310 break;
2311 case DTI_CONN_STATE_ERROR:
2312 /* connection not possible: disconnect UDP, L2R or TRA */
2313 TRACE_EVENT("SIM_ENT_CSDconnect_dti_cb connection not possible: disconnect UDP,L2R or TRA");
2314 dti_cntrl_close_dpath_from_dti_id( dti_id );
2315 break;
2316 case DTI_CONN_STATE_UNKNOWN:
2317 default:
2318 TRACE_EVENT("SIM_ENT_CSDconnect_dti_cb call with not awaited value");
2319 break;
2320 }
2321 return TRUE;
2322 }
2323 #endif /* DTI */
2324
2325 #if defined (GPRS) AND defined (DTI)
2326 /*
2327 +---------------------------------------------------------------------------+
2328 | PROJECT : GSM-F&D (8411) MODULE : CMH_SIMR |
2329 | STATE : code ROUTINE : SIM_SNDCP_connect_dti_cb |
2330 +---------------------------------------------------------------------------+
2331
2332 PURPOSE : Callback for connection between SIM and SNDCP.
2333
2334 */
2335 GLOBAL BOOL SIM_SNDCP_connect_dti_cb(UBYTE dti_id, T_DTI_CONN_STATE result_type)
2336 {
2337 TRACE_FUNCTION("SIM_SNDCP_connect_dti_cb");
2338
2339 switch( result_type)
2340 {
2341 case DTI_CONN_STATE_DISCONNECTING:
2342 break;
2343 case DTI_CONN_STATE_DISCONNECTED:
2344 dti_cntrl_erase_entry(dti_id);
2345 if (simShrdPrm.sat_class_e_dti_id EQ dti_id)
2346 {
2347 simShrdPrm.sat_class_e_dti_id = DTI_DTI_ID_NOTPRESENT;
2348 TRACE_EVENT("sat_class_e_dti_id reset");
2349 }
2350 break;
2351 case DTI_CONN_STATE_CONNECTING:
2352 break;
2353 case DTI_CONN_STATE_CONNECTED:
2354 /* the SIM-SNDCP connection has been established, now send SIM_BIP_CONFIG
2355 * request to SIM */
2356 psaSIM_Bip_Config_Req();
2357 break;
2358 case DTI_CONN_STATE_ERROR:
2359 /* connection not possible: disconnect SNDCP */
2360 dti_cntrl_close_dpath_from_dti_id( dti_id );
2361 break;
2362 case DTI_CONN_STATE_UNKNOWN:
2363 default:
2364 TRACE_EVENT("SIM_SNDCP_connect_dti_cb call with not awaited value");
2365 break;
2366 }
2367 return TRUE;
2368 }
2369
2370
2371 /*
2372 +--------------------------------------------------------------------------+
2373 | PROJECT : GSM-F&D (8411) MODULE : CMH_SIMR |
2374 | STATE : code ROUTINE : SIM_ENT_GPRSconnect_dti_cb|
2375 +--------------------------------------------------------------------------+
2376
2377 PURPOSE : Callback for connection between SIM and UDP/SNDCP for GPRS.
2378
2379 */
2380
2381 GLOBAL BOOL SIM_ENT_GPRSconnect_dti_cb(UBYTE dti_id, T_DTI_CONN_STATE result_type)
2382 {
2383 TRACE_FUNCTION("SIM_ENT_GPRSconnect_dti_cb");
2384
2385 switch( result_type)
2386 {
2387 case DTI_CONN_STATE_DISCONNECTING:
2388 break;
2389 case DTI_CONN_STATE_DISCONNECTED:
2390 dti_cntrl_erase_entry(dti_id);
2391 if (simShrdPrm.sat_class_e_dti_id EQ dti_id)
2392 {
2393 simShrdPrm.sat_class_e_dti_id = DTI_DTI_ID_NOTPRESENT;
2394 TRACE_EVENT("sat_class_e_dti_id reset");
2395 }
2396 break;
2397 case DTI_CONN_STATE_CONNECTING:
2398 case DTI_CONN_STATE_CONNECTED:
2399 break;
2400 case DTI_CONN_STATE_ERROR:
2401 /* connection not possible: disconnect UDP or SNDCP */
2402 TRACE_EVENT("SIM_ENT_GPRSconnect_dti_cb connection not possible: disconnect UDP or SNDCP");
2403 dti_cntrl_close_dpath_from_dti_id( dti_id );
2404 break;
2405 case DTI_CONN_STATE_UNKNOWN:
2406 default:
2407 TRACE_EVENT("SIM_ENT_GPRSconnect_dti_cb call with not awaited value");
2408 break;
2409 }
2410 return TRUE;
2411 }
2412
2413 #endif /* GPRS */
2414
2415 #endif /* FF_SAT_E */
2416
2417 #ifdef FF_DUAL_SIM
2418
2419 /*
2420 +-------------------------------------------------------------------+
2421 | PROJECT : GSM-PS (6147) MODULE : CMH_SIMR |
2422 | ROUTINE : cmhSIM_SIMSelected |
2423 +-------------------------------------------------------------------+
2424
2425 PURPOSE : Informs the upper layer the result of the SIM Selection process.
2426
2427 */
2428 GLOBAL void cmhSIM_SIMSelected ( void )
2429 {
2430 T_ACI_AT_CMD cmdBuf;
2431 T_ACI_CME_ERR err;
2432
2433 TRACE_FUNCTION("cmhSIM_SIMSelected()");
2434
2435 switch(simEntStat.curCmd)
2436 {
2437 case(AT_CMD_SIM):
2438
2439 switch( simShrdPrm.rslt )
2440 {
2441 case( SIM_NO_ERROR ):
2442
2443 simEntStat.curCmd = AT_CMD_NONE;
2444
2445 R_AT( RAT_OK, simEntStat.entOwn )
2446 ( AT_CMD_SIM );
2447 cmh_logRslt ( simEntStat.entOwn, RAT_OK, AT_CMD_SIM,
2448 -1, BS_SPEED_NotPresent,CME_ERR_NotPresent);
2449 return;
2450
2451 default:
2452 err = cmhSIM_GetCmeFromSim ( simShrdPrm.rslt );
2453 break;
2454 }
2455
2456 cmdBuf = simEntStat.curCmd;
2457 simEntStat.curCmd = AT_CMD_NONE;
2458
2459 R_AT( RAT_CME, simEntStat.entOwn )
2460 ( cmdBuf, err );
2461 cmh_logRslt ( simEntStat.entOwn, RAT_CME, cmdBuf,
2462 -1, BS_SPEED_NotPresent, err );
2463 break;
2464 }
2465 }
2466 #endif /*FF_DUAL_SIM*/
2467
2468 #ifdef FF_CPHS_REL4
2469 /*
2470 +--------------------------------------------------------------------+
2471 | PROJECT : GSM-PS (6147) MODULE : CMH_SIMR |
2472 | ROUTINE : cmhSIM_RdCnfCfis |
2473 +--------------------------------------------------------------------+
2474
2475 PURPOSE : This function handles the confirmation of reading
2476 EF CFIS from SIM.
2477 */
2478 GLOBAL void cmhSIM_RdCnfCfis ( SHORT table_id )
2479 {
2480 T_ACI_AT_CMD cmdBuf; /* buffers current command */
2481 T_ACI_CMD_SRC ownBuf; /* buffers current owner */
2482 T_ACI_CFIS_CFU cfisData; /* CFIS data */
2483
2484 UBYTE *pExchData; /* points to exchange data buffer */
2485 UBYTE dataLen; /* holds length of data */
2486 UBYTE CFISmaxRcd; /* holds no. of records in EF-CFIS */
2487
2488 TRACE_FUNCTION ("cmhSIM_RdCnfCfis()");
2489
2490 cmdBuf = simEntStat.curCmd;
2491 ownBuf = simEntStat.entOwn;
2492 pExchData = simShrdPrm.atb[table_id].exchData;
2493 dataLen = simShrdPrm.atb[table_id].dataLen;
2494
2495 switch ( simShrdPrm.atb[table_id].errCode )
2496 {
2497 case ( SIM_NO_ERROR ):
2498 {
2499 /*
2500 *-------------------------------------------------------------
2501 * check basic consistency of read data
2502 *-------------------------------------------------------------
2503 */
2504 if ( pExchData EQ NULL OR
2505 dataLen < ACI_SIZE_EF_CFIS OR *pExchData EQ 0xFF)
2506 {
2507 simEntStat.curCmd = AT_CMD_NONE;
2508 simEntStat.entOwn = simShrdPrm.owner = OWN_NONE;
2509
2510 R_AT( RAT_CME, ownBuf ) ( cmdBuf, CME_ERR_Unknown );
2511 }
2512 else
2513 {
2514 /*
2515 *-----------------------------------------------------------
2516 * process parameter <msp>
2517 *-----------------------------------------------------------
2518 */
2519 cfisData.mspId = *pExchData;
2520
2521 /*
2522 *-----------------------------------------------------------
2523 * process parameter <cfustat>
2524 *-----------------------------------------------------------
2525 */
2526 cfisData.cfuStat = *(pExchData+1);
2527
2528 /*
2529 *-----------------------------------------------------------
2530 * process parameter <type>
2531 *-----------------------------------------------------------
2532 */
2533 cmhPHB_toaDmrg ( *( pExchData + 3 ),
2534 &cfisData.type );
2535
2536 /*
2537 *-----------------------------------------------------------
2538 * process parameter <number>
2539 *-----------------------------------------------------------
2540 */
2541 cmhPHB_getAdrStr ( cfisData.number ,
2542 MAX_PHB_NUM_LEN - 1,
2543 pExchData + 4,
2544 *(pExchData+2) );
2545
2546 CFISmaxRcd = simShrdPrm.atb[table_id].recMax;
2547
2548 R_AT( RAT_P_CFIS, ownBuf ) ( &cfisData );
2549
2550 if( CFISIndex )
2551 {
2552 if( CFISIndex NEQ CFISmaxRcd )
2553 {
2554 CFISIndex++;
2555 if ( cmhSIM_ReadRecordEF (ownBuf, AT_CMD_P_CFIS, SIM_CFIS,
2556 CFISIndex, NOT_PRESENT_8BIT, NULL, cmhSIM_RdCnfCfis) NEQ AT_EXCT )
2557 {
2558 simEntStat.curCmd = AT_CMD_NONE;
2559 simEntStat.entOwn = simShrdPrm.owner = OWN_NONE;
2560
2561 R_AT( RAT_CME, ownBuf ) ( cmdBuf, CME_ERR_Unknown );
2562 }
2563 }
2564 else
2565 {
2566 CFISIndex=0;
2567 }
2568 }
2569 if( CFISIndex EQ 0 )
2570 {
2571 simEntStat.curCmd = AT_CMD_NONE;
2572 simEntStat.entOwn = simShrdPrm.owner = OWN_NONE;
2573 R_AT( RAT_OK, ownBuf ) ( cmdBuf );
2574 }
2575 }
2576 break;
2577 }
2578 default:
2579 {
2580 simEntStat.curCmd = AT_CMD_NONE;
2581 simEntStat.entOwn = simShrdPrm.owner = OWN_NONE;
2582
2583 R_AT( RAT_CME, ownBuf )
2584 (
2585 cmdBuf,
2586 cmhSIM_GetCmeFromSim ( simShrdPrm.atb[table_id].errCode )
2587 );
2588 break;
2589 }
2590 }
2591 simShrdPrm.atb[table_id].ntryUsdFlg = FALSE;
2592 }
2593
2594 /*
2595 +--------------------------------------------------------------------+
2596 | PROJECT : GSM-PS (6147) MODULE : CMH_SIMR |
2597 | ROUTINE : cmhSIM_WrCnfCfis |
2598 +--------------------------------------------------------------------+
2599
2600 PURPOSE : This function handles the confirmation of writing data
2601 into EF-CFIS in SIM.
2602 */
2603 GLOBAL void cmhSIM_WrCnfCfis ( SHORT table_id )
2604 {
2605
2606 T_ACI_AT_CMD cmdBuf; /* buffers current command */
2607 T_ACI_CMD_SRC ownBuf; /* buffers current owner */
2608
2609 TRACE_FUNCTION ("cmhSIM_WrCnfCfis ()");
2610
2611 cmdBuf = simEntStat.curCmd;
2612 ownBuf = simEntStat.entOwn;
2613 simEntStat.curCmd = AT_CMD_NONE;
2614 simEntStat.entOwn = simShrdPrm.owner = OWN_NONE;
2615
2616 if ( simShrdPrm.atb[table_id].errCode EQ SIM_NO_ERROR)
2617 {
2618 R_AT( RAT_OK, ownBuf ) ( cmdBuf );
2619 }
2620 else
2621 {
2622 R_AT( RAT_CME, ownBuf ) /* unsuccessful SIM write */
2623 (
2624 cmdBuf,
2625 cmhSIM_GetCmeFromSim ( simShrdPrm.atb[table_id].errCode )
2626 );
2627 }
2628 simShrdPrm.atb[table_id].ntryUsdFlg = FALSE;
2629 }
2630 /*
2631 +--------------------------------------------------------------------+
2632 | PROJECT : GSM-PS (6147) MODULE : CMH_SIMR |
2633 | ROUTINE : cmhSIM_RdCnfMbi |
2634 +--------------------------------------------------------------------+
2635
2636 PURPOSE : This function handles the confirmation of reading
2637 EF-MBI from SIM.
2638 */
2639 GLOBAL void cmhSIM_RdCnfMbi ( SHORT table_id )
2640 {
2641 T_ACI_AT_CMD cmdBuf; /* buffers current command */
2642 T_ACI_CMD_SRC ownBuf; /* buffers current owner */
2643 T_ACI_MBI mbiData; /* MBT data */
2644
2645 UBYTE *pExchData; /* points to exchange data buffer */
2646 UBYTE dataLen; /* holds length of data */
2647 UBYTE MBImaxRcd; /* holds no. of records in EF-MBI */
2648
2649
2650 TRACE_FUNCTION ("cmhSIM_RdCnfMbi()");
2651
2652 cmdBuf = simEntStat.curCmd;
2653 ownBuf = simEntStat.entOwn;
2654 simEntStat.curCmd = AT_CMD_NONE;
2655 simEntStat.entOwn = simShrdPrm.owner = OWN_NONE;
2656 pExchData = simShrdPrm.atb[table_id].exchData;
2657 dataLen = simShrdPrm.atb[table_id].dataLen;
2658 MBImaxRcd = simShrdPrm.atb[table_id].recMax;
2659
2660 switch ( simShrdPrm.atb[table_id].errCode )
2661 {
2662 case ( SIM_NO_ERROR ):
2663 {
2664 /*
2665 *-------------------------------------------------------------
2666 * check basic consistency of read data
2667 *-------------------------------------------------------------
2668 */
2669 if ( pExchData EQ NULL OR
2670 dataLen < ACI_SIZE_EF_MBI )
2671 {
2672 R_AT( RAT_CME, ownBuf ) ( cmdBuf, CME_ERR_Unknown );
2673 }
2674 else
2675 {
2676 mbiData.mbdn_id_voice = *pExchData;
2677 mbiData.mbdn_id_fax = *( pExchData + 1 );
2678 mbiData.mbdn_id_email = *( pExchData + 2 );
2679 mbiData.mbdn_id_other = *( pExchData + 3 );
2680
2681 R_AT( RAT_P_MBI, ownBuf ) ( &mbiData );
2682
2683 if( MBI_Index )
2684 {
2685 if( MBI_Index NEQ MBImaxRcd )
2686 {
2687 MBI_Index++;
2688 if ( cmhSIM_ReadRecordEF (ownBuf, AT_CMD_P_MBI, SIM_MBI,
2689 MBI_Index, NOT_PRESENT_8BIT, NULL, cmhSIM_RdCnfMbi) NEQ AT_EXCT )
2690 {
2691 R_AT( RAT_CME, ownBuf ) ( cmdBuf, CME_ERR_Unknown );
2692 }
2693 }
2694 else
2695 {
2696 MBI_Index = 0;
2697 }
2698 }
2699 if( MBI_Index EQ 0 )
2700 {
2701 R_AT( RAT_OK, ownBuf ) ( cmdBuf );
2702 }
2703 }
2704 break;
2705 }
2706 default:
2707 {
2708 R_AT( RAT_CME, ownBuf )
2709 (
2710 cmdBuf,
2711 cmhSIM_GetCmeFromSim ( simShrdPrm.atb[table_id].errCode )
2712 );
2713 break;
2714 }
2715 }
2716 simShrdPrm.atb[table_id].ntryUsdFlg = FALSE;
2717 }
2718 /*
2719 +--------------------------------------------------------------------+
2720 | PROJECT : GSM-PS (6147) MODULE : CMH_SIMR |
2721 | ROUTINE : cmhSIM_RdCnfMbdn |
2722 +--------------------------------------------------------------------+
2723
2724 PURPOSE : This function handles the confirmation of reading
2725 EF-MBDN from SIM.
2726 */
2727 GLOBAL void cmhSIM_RdCnfMbdn ( SHORT table_id )
2728 {
2729 T_ACI_AT_CMD cmdBuf; /* buffers current command */
2730 T_ACI_CMD_SRC ownBuf; /* buffers current owner */
2731 T_ACI_MBDN mbdnData; /* MBDN data */
2732
2733 UBYTE *pExchData; /* points to exchange data buffer */
2734 UBYTE dataLen; /* holds length of data */
2735 UBYTE alphaLen; /* max. length of alpha identifier */
2736
2737 TRACE_FUNCTION ("cmhSIM_RdCnfMbdn()");
2738
2739 cmdBuf = simEntStat.curCmd;
2740 ownBuf = simEntStat.entOwn;
2741 pExchData = simShrdPrm.atb[table_id].exchData;
2742 dataLen = simShrdPrm.atb[table_id].dataLen;
2743 simEntStat.curCmd = AT_CMD_NONE;
2744 simEntStat.entOwn = simShrdPrm.owner = OWN_NONE;
2745
2746 switch ( simShrdPrm.atb[table_id].errCode )
2747 {
2748 case ( SIM_NO_ERROR ):
2749 {
2750 /*
2751 *-------------------------------------------------------------
2752 * check basic consistency of read data
2753 *-------------------------------------------------------------
2754 */
2755 if ( pExchData EQ NULL OR
2756 dataLen < ACI_SIZE_EF_MBDN )
2757 {
2758 R_AT( RAT_CME, ownBuf ) ( cmdBuf, CME_ERR_Unknown );
2759 }
2760 else
2761 {
2762 alphaLen = dataLen - ACI_MIN_SIZE_EF_MSISDN;
2763 /*
2764 *-----------------------------------------------------------
2765 * process parameter <alpha>
2766 *-----------------------------------------------------------
2767 */
2768 cmhPHB_getTagNt ( pExchData,
2769 alphaLen,
2770 mbdnData.alpha,
2771 MAX_ALPHA_LEN );
2772
2773 pExchData += alphaLen;
2774 /*
2775 *-----------------------------------------------------------
2776 * process parameter <type>
2777 *-----------------------------------------------------------
2778 */
2779 cmhPHB_toaDmrg ( *( pExchData + 1 ),
2780 &mbdnData.type );
2781
2782 /*
2783 *-----------------------------------------------------------
2784 * process parameter <number>
2785 *-----------------------------------------------------------
2786 */
2787 cmhPHB_getAdrStr ( mbdnData.number ,
2788 MAX_MB_NUM_LEN - 1,
2789 pExchData + 2,
2790 *pExchData );
2791
2792 R_AT( RAT_P_MBDN, ownBuf ) ( &mbdnData );
2793 R_AT( RAT_OK, ownBuf ) ( cmdBuf );
2794 }
2795 break;
2796 }
2797 default:
2798 {
2799 R_AT( RAT_CME, ownBuf )
2800 (
2801 cmdBuf,
2802 cmhSIM_GetCmeFromSim ( simShrdPrm.atb[table_id].errCode )
2803 );
2804 break;
2805 }
2806 }
2807 simShrdPrm.atb[table_id].ntryUsdFlg = FALSE;
2808 }
2809
2810 /*
2811 +--------------------------------------------------------------------+
2812 | PROJECT : GSM-PS (6147) MODULE : CMH_SIMR |
2813 | ROUTINE : cmhSIM_WrCnfMbdn |
2814 +--------------------------------------------------------------------+
2815
2816 PURPOSE : This function handles the confirmation of writing data
2817 into EF-MBDN in SIM.
2818 */
2819 GLOBAL void cmhSIM_WrCnfMbdn ( SHORT table_id )
2820 {
2821
2822 T_ACI_AT_CMD cmdBuf; /* buffers current command */
2823 T_ACI_CMD_SRC ownBuf; /* buffers current owner */
2824
2825 TRACE_FUNCTION ("cmhSIM_WrCnfMbdn ()");
2826
2827 cmdBuf = simEntStat.curCmd;
2828 ownBuf = simEntStat.entOwn;
2829 simEntStat.curCmd = AT_CMD_NONE;
2830 simEntStat.entOwn = simShrdPrm.owner = OWN_NONE;
2831
2832 if ( simShrdPrm.atb[table_id].errCode EQ SIM_NO_ERROR)
2833 {
2834 R_AT( RAT_OK, ownBuf ) ( cmdBuf );
2835 }
2836 else
2837 {
2838 R_AT( RAT_CME, ownBuf ) /* unsuccessful SIM write */
2839 (
2840 cmdBuf,
2841 cmhSIM_GetCmeFromSim ( simShrdPrm.atb[table_id].errCode )
2842 );
2843 }
2844 simShrdPrm.atb[table_id].ntryUsdFlg = FALSE;
2845 }
2846
2847 /*
2848 +--------------------------------------------------------------------+
2849 | PROJECT : GSM-PS (6147) MODULE : CMH_SIMR |
2850 | ROUTINE : cmhSIM_RdCnfMwis |
2851 +--------------------------------------------------------------------+
2852
2853 PURPOSE : This function handles the confirmation of reading
2854 EF MWIS from SIM.
2855 */
2856 GLOBAL void cmhSIM_RdCnfMwis ( SHORT table_id )
2857 {
2858 T_ACI_AT_CMD cmdBuf; /* buffers current command */
2859 T_ACI_CMD_SRC ownBuf; /* buffers current owner */
2860 T_ACI_MWIS_MWI mwisData; /* MWIS data */
2861
2862 UBYTE *pExchData; /* points to exchange data buffer */
2863 UBYTE dataLen; /* holds length of data */
2864 UBYTE MWISmaxRcd; /* holds no. of records in EF-MWIS */
2865
2866 TRACE_FUNCTION ("cmhSIM_RdCnfMwis()");
2867
2868 cmdBuf = simEntStat.curCmd;
2869 ownBuf = simEntStat.entOwn;
2870 pExchData = simShrdPrm.atb[table_id].exchData;
2871 dataLen = simShrdPrm.atb[table_id].dataLen;
2872
2873 switch ( simShrdPrm.atb[table_id].errCode )
2874 {
2875 case ( SIM_NO_ERROR ):
2876 {
2877 /*
2878 *-------------------------------------------------------------
2879 * check basic consistency of read data
2880 *-------------------------------------------------------------
2881 */
2882 if ( pExchData EQ NULL OR
2883 dataLen < ACI_SIZE_EF_MWIS OR *pExchData EQ 0x00)
2884 {
2885 simEntStat.curCmd = AT_CMD_NONE;
2886 simEntStat.entOwn = simShrdPrm.owner = OWN_NONE;
2887
2888 R_AT( RAT_CME, ownBuf ) ( cmdBuf, CME_ERR_Unknown );
2889 }
2890 else
2891 {
2892 /*
2893 *-----------------------------------------------------------
2894 * process parameter <mwisStat>
2895 *-----------------------------------------------------------
2896 */
2897 mwisData.mwiStat = *pExchData;
2898
2899 /*
2900 *-----------------------------------------------------------
2901 * process parameter <mwis_count_voice>
2902 *-----------------------------------------------------------
2903 */
2904 mwisData.mwis_count_voice = *(pExchData+1);
2905
2906 /*
2907 *-----------------------------------------------------------
2908 * process parameter <mwis_count_fax>
2909 *-----------------------------------------------------------
2910 */
2911 mwisData.mwis_count_fax = *(pExchData+2);
2912
2913 /*
2914 *-----------------------------------------------------------
2915 * process parameter <mwis_count_email>
2916 *-----------------------------------------------------------
2917 */
2918 mwisData.mwis_count_email = *(pExchData+3);
2919
2920 /*
2921 *-----------------------------------------------------------
2922 * process parameter <mwis_count_other>
2923 *-----------------------------------------------------------
2924 */
2925 mwisData.mwis_count_other = *(pExchData+4);
2926
2927 MWISmaxRcd = simShrdPrm.atb[table_id].recMax;
2928
2929 R_AT( RAT_P_MWIS, ownBuf ) ( &mwisData );
2930
2931 if( MWISIndex )
2932 {
2933 if( MWISIndex NEQ MWISmaxRcd )
2934 {
2935 MWISIndex++;
2936 if ( cmhSIM_ReadRecordEF (ownBuf, AT_CMD_P_MWIS, SIM_MWIS,
2937 MWISIndex, NOT_PRESENT_8BIT, NULL, cmhSIM_RdCnfMwis) NEQ AT_EXCT )
2938 {
2939 simEntStat.curCmd = AT_CMD_NONE;
2940 simEntStat.entOwn = simShrdPrm.owner = OWN_NONE;
2941
2942 R_AT( RAT_CME, ownBuf ) ( cmdBuf, CME_ERR_Unknown );
2943 }
2944 }
2945 else
2946 {
2947 MWISIndex=0;
2948 }
2949 }
2950 if( MWISIndex EQ 0 )
2951 {
2952 simEntStat.curCmd = AT_CMD_NONE;
2953 simEntStat.entOwn = simShrdPrm.owner = OWN_NONE;
2954 R_AT( RAT_OK, ownBuf ) ( cmdBuf );
2955 }
2956 }
2957 break;
2958 }
2959 default:
2960 {
2961 simEntStat.curCmd = AT_CMD_NONE;
2962 simEntStat.entOwn = simShrdPrm.owner = OWN_NONE;
2963
2964 R_AT( RAT_CME, ownBuf )
2965 (
2966 cmdBuf,
2967 cmhSIM_GetCmeFromSim ( simShrdPrm.atb[table_id].errCode )
2968 );
2969 break;
2970 }
2971 }
2972 simShrdPrm.atb[table_id].ntryUsdFlg = FALSE;
2973 }
2974
2975 /*
2976 +--------------------------------------------------------------------+
2977 | PROJECT : GSM-PS (6147) MODULE : CMH_SIMR |
2978 | ROUTINE : cmhSIM_WrCnfMwis |
2979 +--------------------------------------------------------------------+
2980
2981 PURPOSE : This function handles the confirmation of writing data
2982 into EF-MWIS in SIM.
2983 */
2984 GLOBAL void cmhSIM_WrCnfMwis ( SHORT table_id )
2985 {
2986
2987 T_ACI_AT_CMD cmdBuf; /* buffers current command */
2988 T_ACI_CMD_SRC ownBuf; /* buffers current owner */
2989 U8 i = 0;
2990 T_ACI_MWIS_MWI mwisData; /* MWIS data */
2991
2992 TRACE_FUNCTION ("cmhSIM_WrCnfMwis ()");
2993
2994 cmdBuf = simEntStat.curCmd;
2995 ownBuf = simEntStat.entOwn;
2996 simEntStat.curCmd = AT_CMD_NONE;
2997 simEntStat.entOwn = simShrdPrm.owner = OWN_NONE;
2998
2999 if ( simShrdPrm.atb[table_id].errCode EQ SIM_NO_ERROR)
3000 {
3001 if( cmdBuf NEQ AT_CMD_P_MWIS )
3002 {
3003 memcpy(&mwisData,&smsShrdPrm.MWISdata,sizeof(T_ACI_MWIS_MWI));
3004 for(i; i < CMD_SRC_MAX; i++)
3005 {
3006 R_AT( RAT_P_MWI, i)(1,&mwisData);
3007 }
3008 }
3009 else
3010 {
3011 R_AT( RAT_OK, ownBuf ) ( cmdBuf );
3012 }
3013 }
3014 else
3015 {
3016 R_AT( RAT_CME, ownBuf ) /* unsuccessful SIM write */
3017 (
3018 cmdBuf,
3019 cmhSIM_GetCmeFromSim ( simShrdPrm.atb[table_id].errCode )
3020 );
3021 }
3022 simShrdPrm.atb[table_id].ntryUsdFlg = FALSE;
3023 }
3024 #endif /* FF_CPHS_REL4 */
3025
3026 /* Implements Measure 97 */
3027 /*
3028 +------------------------------------------------------------------------------
3029 | Function : cmhSIM_CardUnblocked_PINChanged
3030 +------------------------------------------------------------------------------
3031 | Purpose : This function can check whether the Card is Unblocked
3032 | or PIN is Changed.
3033 | When this function will be called for checking whether
3034 | the PIN is changed then the argument PINChanged will be
3035 | TRUE otherwise it will be FALSE
3036 |
3037 | Parameters : PINChanged - TRUE or FALSE
3038 |
3039 | Return : void
3040 +------------------------------------------------------------------------------
3041 */
3042
3043 GLOBAL void cmhSIM_CardUnblocked_PINChanged ( BOOL PINChanged )
3044 {
3045 UBYTE cmdBuf;
3046 T_ACI_CME_ERR err;
3047
3048 TRACE_FUNCTION ( "cmhSIM_CardUnblocked_PINChanged()" );
3049
3050 /*
3051 *-------------------------------------------------------------------
3052 * check for command context
3053 *-------------------------------------------------------------------
3054 */
3055
3056 switch( simEntStat.curCmd )
3057 {
3058 case( AT_CMD_CPIN ):
3059 case( AT_CMD_PVRF ):
3060 /*lint -e{408}*/
3061 case( KSD_CMD_UBLK ):
3062 case( AT_CMD_CPWD ):
3063 /*lint -e{408}*/
3064 case( KSD_CMD_PWD ):
3065 /*
3066 *----------------------------------------------------------------
3067 * process event for +CPIN, %PVRF and KSD UBLK command
3068 * also
3069 * process event for +CPWD and KSD PWD command
3070 *----------------------------------------------------------------
3071 */
3072 switch( simShrdPrm.rslt )
3073 {
3074 case( SIM_NO_ERROR ):
3075 if( (PINChanged EQ TRUE) OR (simShrdPrm.crdPhs NEQ 0xFF) )
3076 {
3077 cmdBuf = simEntStat.curCmd;
3078 simEntStat.curCmd = AT_CMD_NONE;
3079
3080 R_AT( RAT_OK, simEntStat.entOwn )
3081 ( cmdBuf );
3082 cmh_logRslt ( simEntStat.entOwn, RAT_OK, (T_ACI_AT_CMD)cmdBuf, -1, BS_SPEED_NotPresent, CME_ERR_NotPresent );
3083 }
3084 return;
3085
3086 case( SIM_CAUSE_PIN1_EXPECT ):
3087 case( SIM_CAUSE_PIN2_EXPECT ):
3088 err = CME_ERR_WrongPasswd;
3089 break;
3090
3091 default:
3092 err = cmhSIM_GetCmeFromSim ( simShrdPrm.rslt );
3093 break;
3094 }
3095
3096 cmdBuf = simEntStat.curCmd;
3097 simEntStat.curCmd = AT_CMD_NONE;
3098
3099 R_AT( RAT_CME, simEntStat.entOwn )
3100 ( cmdBuf, err );
3101
3102 cmh_logRslt ( simEntStat.entOwn, RAT_CME, (T_ACI_AT_CMD)cmdBuf,
3103 -1, BS_SPEED_NotPresent, err );
3104 break;
3105 }
3106 }
3107
3108 /* Implements Measure 106 */
3109 /*
3110 +------------------------------------------------------------------------------
3111 | Function : cmhSIM_ProcessEvents
3112 |------------------------------------------------------------------------------
3113 | Purpose : Process Events for +CAMM, +CPUC, +CACM commands.
3114 |
3115 | Parameters : at_cmd_id - AT command identifier
3116 |
3117 | Return : void
3118 +------------------------------------------------------------------------------
3119 */
3120
3121 LOCAL void cmhSIM_ProcessEvents ( T_ACI_AT_CMD at_cmd_id )
3122 {
3123 TRACE_FUNCTION ( "cmhSIM_ProcessEvents()" );
3124
3125 simEntStat.curCmd = AT_CMD_NONE;
3126
3127 if( simShrdPrm.rslt EQ SIM_NO_ERROR )
3128 {
3129 /*
3130 * Try it again
3131 */
3132 switch ( at_cmd_id )
3133 {
3134 case ( AT_CMD_CAMM ):
3135 aoc_update_sim_datafield ( SECOND_UPDATE, ACT_WR_DAT,
3136 SIM_ACMMAX, aoc_update_acmmax_cb );
3137 break;
3138
3139 case ( AT_CMD_CPUC ):
3140 aoc_update_puct (SECOND_UPDATE, 0L);
3141 break;
3142
3143 case ( AT_CMD_CACM ):
3144 aoc_update_sim_datafield ( SECOND_UPDATE, ACT_WR_REC,
3145 SIM_ACM, aoc_update_acm_cb );
3146 break;
3147 }
3148 }
3149 else
3150 {
3151 R_AT( RAT_CME, simEntStat.entOwn )
3152 ( at_cmd_id, CME_ERR_WrongPasswd );
3153 }
3154 }
3155
3156 /* Implements Measure 183 */
3157 /*
3158 +------------------------------------------------------------------------------
3159 | Function : cmhSIM_PINEnabledDisabled
3160 |------------------------------------------------------------------------------
3161 | Purpose : SIM Enabled or Disabled
3162 |
3163 | Parameters : void
3164 |
3165 | Return : void
3166 +------------------------------------------------------------------------------
3167 */
3168
3169 GLOBAL void cmhSIM_PINEnabledDisabled ( void )
3170 {
3171 T_ACI_CME_ERR err;
3172
3173 TRACE_FUNCTION ( "cmhSIM_PINEnabledDisabled()" );
3174
3175 /*
3176 *-------------------------------------------------------------------
3177 * check for command context
3178 *-------------------------------------------------------------------
3179 */
3180 if( simEntStat.curCmd EQ AT_CMD_CLCK )
3181 {
3182 /*
3183 *----------------------------------------------------------------
3184 * process event for +CLCK command
3185 *----------------------------------------------------------------
3186 */
3187 switch( simShrdPrm.rslt )
3188 {
3189 case( SIM_NO_ERROR ):
3190
3191 simEntStat.curCmd = AT_CMD_NONE;
3192
3193 R_AT( RAT_OK, simEntStat.entOwn )
3194 ( AT_CMD_CLCK );
3195 cmh_logRslt ( simEntStat.entOwn, RAT_OK, AT_CMD_CLCK, -1, BS_SPEED_NotPresent, CME_ERR_NotPresent );
3196 return;
3197
3198 case( SIM_CAUSE_PIN1_EXPECT ):
3199 case( SIM_CAUSE_PIN1_BLOCKED ):
3200 err = CME_ERR_WrongPasswd;
3201 break;
3202
3203 default:
3204 err = cmhSIM_GetCmeFromSim ( simShrdPrm.rslt );
3205 break;
3206 }
3207
3208 simEntStat.curCmd = AT_CMD_NONE;
3209
3210 R_AT( RAT_CME, simEntStat.entOwn )
3211 ( AT_CMD_CLCK, err );
3212 cmh_logRslt ( simEntStat.entOwn, RAT_CME, AT_CMD_CLCK,
3213 -1, BS_SPEED_NotPresent, err );
3214 }
3215 }
3216
3217 /* Implements Measure 200 */
3218 /*
3219 +------------------------------------------------------------------------------
3220 | Function : cmhSIM_Compare_CNUMMsisdnIdx
3221 |------------------------------------------------------------------------------
3222 | Purpose : Comapres CNUMMsisdnIdx
3223 |
3224 | Parameters : void
3225 |
3226 | Return : void
3227 +------------------------------------------------------------------------------
3228 */
3229
3230 LOCAL void cmhSIM_Compare_CNUMMsisdnIdx ( void )
3231 {
3232 T_SIM_CMD_PRM* pSIMCmdPrm;
3233 T_ACI_AT_CMD cmdBuf;
3234 T_ACI_CMD_SRC ownBuf;
3235
3236 TRACE_FUNCTION ( "cmhSIM_Compare_CNUMMsisdnIdx()" );
3237
3238 pSIMCmdPrm = &cmhPrm[simEntStat.entOwn].simCmdPrm;
3239 cmdBuf = simEntStat.curCmd;
3240 ownBuf = simEntStat.entOwn;
3241
3242 if ( (CNUMMsisdnIdx EQ MAX_MSISDN - 1) OR
3243 ((pSIMCmdPrm -> CNUMActRec) EQ CNUMMaxRec) )
3244 {
3245 simEntStat.curCmd = AT_CMD_NONE;
3246 simShrdPrm.owner = (T_OWN)CMD_SRC_NONE;
3247 simEntStat.entOwn = CMD_SRC_NONE;
3248
3249 R_AT( RAT_CNUM, ownBuf ) ( &CNUMMsisdn[0], CNUMMaxRec );
3250
3251 if ( (pSIMCmdPrm -> CNUMActRec) EQ CNUMMaxRec )
3252 {
3253 if (pSIMCmdPrm -> CNUMOutput)
3254 {
3255 R_AT( RAT_OK, ownBuf ) ( cmdBuf );
3256 }
3257 else
3258 {
3259 R_AT( RAT_CME, ownBuf ) ( cmdBuf, CME_ERR_NotFound );
3260 }
3261 }
3262 }
3263 else
3264 {
3265 CNUMMsisdnIdx++;
3266 pSIMCmdPrm -> CNUMActRec++;
3267
3268 if ( cmhSIM_ReqMsisdn ( ownBuf, pSIMCmdPrm -> CNUMActRec ) NEQ AT_EXCT )
3269 {
3270 cmhSIM_SndError( ownBuf, cmdBuf, CME_ERR_Unknown );
3271 }
3272 }
3273
3274 }
3275
3276 /* Implements Measure 7, 17, 24, 35 */
3277 /*
3278 +------------------------------------------------------------------------------
3279 | Function : cmhSIM_SndError
3280 |------------------------------------------------------------------------------
3281 | Purpose : Reports Error
3282 |
3283 | Parameters : ownBuf - AT Command Source Identifier
3284 | cmdBuf - AT Command Identifier
3285 | cme_err - +CME ERROR parameter
3286 |
3287 | Return : void
3288 +------------------------------------------------------------------------------
3289 */
3290 LOCAL void cmhSIM_SndError( T_ACI_CMD_SRC ownBuf, T_ACI_AT_CMD cmdBuf,
3291 T_ACI_CME_ERR cme_err )
3292 {
3293 TRACE_FUNCTION ( "cmhSIM_SndError()" );
3294
3295 simEntStat.curCmd = AT_CMD_NONE;
3296 simShrdPrm.owner = (T_OWN)CMD_SRC_NONE;
3297 simEntStat.entOwn = CMD_SRC_NONE;
3298
3299 R_AT( RAT_CME, ownBuf ) ( cmdBuf, cme_err );
3300
3301 }
3302
3303 /*==== EOF ========================================================*/
3304