FreeCalypso > hg > freecalypso-citrine
comparison g23m-aci/aci/cmh_mmr.c @ 0:75a11d740a02
initial import of gsm-fw from freecalypso-sw rev 1033:5ab737ac3ad7
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 09 Jun 2016 00:02:41 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:75a11d740a02 |
---|---|
1 /* | |
2 +----------------------------------------------------------------------------- | |
3 | Project : GSM-PS (6147) | |
4 | Modul : CMH_MMR | |
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 | mobility management. | |
20 +----------------------------------------------------------------------------- | |
21 */ | |
22 | |
23 #ifndef CMH_MMR_C | |
24 #define CMH_MMR_C | |
25 #endif | |
26 | |
27 #include "config.h" | |
28 #include "fixedconf.h" | |
29 #include "condat-features.h" | |
30 #include "aci_conf.h" | |
31 | |
32 #include "aci_all.h" | |
33 | |
34 /*==== INCLUDES ===================================================*/ | |
35 | |
36 #include "aci_cmh.h" | |
37 #include "ati_cmd.h" | |
38 #include "aci_cmd.h" | |
39 #include "aci_mem.h" | |
40 | |
41 #ifdef FAX_AND_DATA | |
42 #include "aci_fd.h" | |
43 #endif /* of #ifdef FAX_AND_DATA */ | |
44 | |
45 #include "aci.h" | |
46 #include "psa.h" | |
47 #include "psa_mm.h" | |
48 #include "psa_sim.h" | |
49 #include "cmh.h" | |
50 #include "cmh_mm.h" | |
51 | |
52 #ifdef DTI | |
53 #include "dti.h" /* functionality of the dti library */ | |
54 #include "dti_conn_mng.h" | |
55 #include "dti_cntrl_mng.h" | |
56 #endif | |
57 | |
58 #include "cmh_sim.h" | |
59 | |
60 #ifdef GPRS | |
61 #include "gaci.h" | |
62 #include "gaci_cmh.h" | |
63 #include "psa_gmm.h" | |
64 #include "cmh_gmm.h" | |
65 #endif | |
66 | |
67 /*==== CONSTANTS ==================================================*/ | |
68 | |
69 | |
70 /*==== TYPES ======================================================*/ | |
71 | |
72 | |
73 /*==== EXPORT =====================================================*/ | |
74 | |
75 | |
76 /*==== VARIABLES ==================================================*/ | |
77 | |
78 /*==== FUNCTIONS ==================================================*/ | |
79 LOCAL void cmhMM_Registration_AutoMode( T_ACI_AT_CMD at_cmd_id ); | |
80 /* | |
81 +-------------------------------------------------------------------+ | |
82 | PROJECT : GSM-PS (6147) MODULE : CMH_MMR | | |
83 | ROUTINE : cmhMM_Registered | | |
84 +-------------------------------------------------------------------+ | |
85 | |
86 PURPOSE : ME is registered to the network | |
87 | |
88 */ | |
89 | |
90 GLOBAL SHORT cmhMM_Registered ( void ) | |
91 { | |
92 SHORT mncCur, mccCur; /* holds mnc and mcc of current PLMN */ | |
93 UBYTE cmdBuf; /* buffers current command */ | |
94 | |
95 TRACE_FUNCTION ("cmhMM_Registered()"); | |
96 | |
97 /* | |
98 *------------------------------------------------------------------- | |
99 * check for command context | |
100 *------------------------------------------------------------------- | |
101 */ | |
102 switch( mmEntStat.curCmd ) | |
103 { | |
104 case( AT_CMD_NONE ): | |
105 case( AT_CMD_COPS ): | |
106 case (AT_CMD_P_COPS): | |
107 case( AT_CMD_NRG ): | |
108 | |
109 /* check for home PLMN or roaming */ | |
110 if( mmShrdPrm.usedPLMN.v_plmn EQ VLD_PLMN ) | |
111 { | |
112 cmhMM_CnvrtPLMN2INT( mmShrdPrm.usedPLMN.mcc, | |
113 mmShrdPrm.usedPLMN.mnc, | |
114 &mccCur, &mncCur ); | |
115 | |
116 /* Store the new PLMN and the IMSI in the FFS */ | |
117 if (!cmhMM_OperatorStoreInFFS(mmShrdPrm.usedPLMN.mcc, | |
118 mmShrdPrm.usedPLMN.mnc, | |
119 simShrdPrm.imsi.field)) | |
120 TRACE_EVENT("Could not write PLMN and IMSI in FFS"); | |
121 | |
122 | |
123 if( cmhSIM_plmn_is_hplmn (mccCur, mncCur)) | |
124 { | |
125 cmhMM_Ntfy_NtwRegistrationStatus(CREG_STAT_Reg); | |
126 } | |
127 else | |
128 { | |
129 cmhMM_Ntfy_NtwRegistrationStatus(CREG_STAT_Roam); | |
130 } | |
131 } | |
132 | |
133 if( mmEntStat.curCmd NEQ AT_CMD_NONE ) | |
134 { | |
135 #if defined (GPRS) AND defined (DTI) | |
136 psaG_MM_CMD_SET_REGMD ( mmShrdPrm.regMode ); /* restore former registration mode*/ | |
137 #else | |
138 /* restore former registration mode */ | |
139 psaMM_SetRegMode ( mmShrdPrm.regMode ); | |
140 #endif | |
141 | |
142 cmdBuf = mmEntStat.curCmd; | |
143 mmEntStat.curCmd = AT_CMD_NONE; | |
144 | |
145 /* From the flight mode if the user registers directly | |
146 change the variable to full functionality. */ | |
147 if (CFUNfun NEQ CFUN_FUN_Full) | |
148 { | |
149 CFUNfun = CFUN_FUN_Full; | |
150 } | |
151 | |
152 R_AT( RAT_OK, mmEntStat.entOwn ) | |
153 ( cmdBuf ); | |
154 | |
155 /* log result */ | |
156 cmh_logRslt ( mmEntStat.entOwn, RAT_OK, (T_ACI_AT_CMD)cmdBuf, | |
157 -1, BS_SPEED_NotPresent ,CME_ERR_NotPresent ); | |
158 } | |
159 break; | |
160 } | |
161 | |
162 return 0; | |
163 } | |
164 | |
165 /* | |
166 +-------------------------------------------------------------------+ | |
167 | PROJECT : GSM-PS (6147) MODULE : CMH_MMR | | |
168 | ROUTINE : cmhMM_Deregistered | | |
169 +-------------------------------------------------------------------+ | |
170 | |
171 PURPOSE : ME is deregistered from network | |
172 | |
173 */ | |
174 | |
175 GLOBAL SHORT cmhMM_Deregistered ( void ) | |
176 { | |
177 T_ACI_RETURN ret; | |
178 | |
179 TRACE_FUNCTION ("cmhMM_Deregistered()"); | |
180 | |
181 /* | |
182 *------------------------------------------------------------------- | |
183 * check for command context | |
184 *------------------------------------------------------------------- | |
185 */ | |
186 switch( mmEntStat.curCmd ) | |
187 { | |
188 case( AT_CMD_NONE ): | |
189 /* | |
190 *---------------------------------------------------------------- | |
191 * process event if no command was invoked | |
192 *---------------------------------------------------------------- | |
193 */ | |
194 switch( mmShrdPrm.deregCs ) | |
195 { | |
196 case( NREG_LIMITED_SERVICE ): | |
197 case( NREG_NO_SERVICE ): | |
198 | |
199 if (mmShrdPrm.regModeAutoBack) | |
200 { | |
201 /* | |
202 * Fallback to automatic mode is allowed, fallback. | |
203 * If MM is not in full service and the registration mode | |
204 * is switched from manual to automatic, | |
205 * MM starts a network search immediately. | |
206 */ | |
207 mmShrdPrm.regModeBeforeAbort = mmShrdPrm.regMode; | |
208 mmShrdPrm.regMode = MODE_AUTO; | |
209 mmShrdPrm.regModeAutoBack = FALSE; | |
210 #if defined (GPRS) AND defined (DTI) | |
211 psaG_MM_CMD_SET_REGMD ( MODE_AUTO ); | |
212 #else | |
213 psaMM_SetRegMode (MODE_AUTO); | |
214 #endif | |
215 } | |
216 | |
217 cmhMM_Ntfy_NtwRegistrationStatus(cmhMM_GetNregCREGStat()); | |
218 break; | |
219 } | |
220 break; | |
221 | |
222 case( AT_CMD_CFUN ): | |
223 /* | |
224 *---------------------------------------------------------------- | |
225 * process event for +CFUN command | |
226 *---------------------------------------------------------------- | |
227 */ | |
228 mmEntStat.curCmd = AT_CMD_NONE; | |
229 | |
230 cmhMM_Ntfy_NtwRegistrationStatus(CREG_STAT_NoSearch); | |
231 | |
232 if (simEntStat.curCmd NEQ AT_CMD_CFUN) /* Has SIM already finished flushing of LDN entries? */ | |
233 { | |
234 R_AT( RAT_OK, mmEntStat.entOwn ) | |
235 ( AT_CMD_CFUN ); | |
236 | |
237 /* log result */ | |
238 cmh_logRslt ( mmEntStat.entOwn, RAT_OK, AT_CMD_CFUN, -1, | |
239 BS_SPEED_NotPresent,CME_ERR_NotPresent ); | |
240 } | |
241 | |
242 break; | |
243 | |
244 case( AT_CMD_BAND ): | |
245 /* | |
246 *---------------------------------------------------------------- | |
247 * process event for %BAND command | |
248 *---------------------------------------------------------------- | |
249 */ | |
250 cmhMM_Ntfy_NtwRegistrationStatus(CREG_STAT_NoSearch); | |
251 | |
252 /* switch back to full functionnality */ | |
253 ret = sAT_PlusCFUN( mmEntStat.entOwn, | |
254 CFUN_FUN_Full, | |
255 CFUN_RST_NotPresent ); | |
256 | |
257 | |
258 /* SPR#919 - SH - fix advised by CLB */ | |
259 mmEntStat.curCmd = AT_CMD_NONE; | |
260 simEntStat.curCmd = AT_CMD_NONE; | |
261 /* end SH */ | |
262 | |
263 if( ret EQ AT_CMPL ) | |
264 { | |
265 R_AT( RAT_OK, mmEntStat.entOwn ) | |
266 (AT_CMD_BAND); | |
267 } | |
268 else | |
269 { | |
270 TRACE_EVENT_P1 | |
271 ("Fatal Error in sAT_PlusCFUN switching on !!!, ret_type: %d", ret); | |
272 R_AT( RAT_CME, mmEntStat.entOwn ) | |
273 ( AT_CMD_BAND, CME_ERR_Unknown ); | |
274 | |
275 } | |
276 /*SPR#919 - SH - fix advised by CLB | |
277 mmEntStat.curCmd = AT_CMD_NONE; | |
278 simEntStat.curCmd = AT_CMD_NONE; | |
279 */ | |
280 break; | |
281 | |
282 case( AT_CMD_COPS ): | |
283 case( AT_CMD_P_COPS): | |
284 /* | |
285 *---------------------------------------------------------------- | |
286 * process event for +COPS command | |
287 *---------------------------------------------------------------- | |
288 */ | |
289 switch( mmShrdPrm.COPSmode ) | |
290 { | |
291 case( COPS_MOD_Auto ): | |
292 case( COPS_MOD_Man ): | |
293 | |
294 cmhMM_Ntfy_NtwRegistrationStatus(CREG_STAT_Denied); | |
295 | |
296 /* If the current running command is AT+COPS=?, we should not do the below | |
297 actions. pnn_read_cnt will be valid when AT+COPS=? is running. */ | |
298 if (mmShrdPrm.pnn_read_cnt EQ 0) | |
299 { | |
300 mmEntStat.curCmd = AT_CMD_NONE; | |
301 #if defined (GPRS) AND defined (DTI) | |
302 psaG_MM_CMD_SET_REGMD ( mmShrdPrm.regMode ); /* restore former registration mode*/ | |
303 #else | |
304 /* restore former registration mode */ | |
305 psaMM_SetRegMode ( mmShrdPrm.regMode); | |
306 #endif | |
307 | |
308 R_AT( RAT_CME, mmEntStat.entOwn ) | |
309 ( mmEntStat.curCmd, cmhMM_GetNregCMEStat() ); | |
310 | |
311 /* log result */ | |
312 cmh_logRslt ( mmEntStat.entOwn, RAT_CME, AT_CMD_COPS, -1, BS_SPEED_NotPresent , | |
313 cmhMM_GetNregCMEStat() ); | |
314 } | |
315 break; | |
316 case( COPS_MOD_Dereg ): | |
317 | |
318 cmhMM_Ntfy_NtwRegistrationStatus(CREG_STAT_NoSearch); | |
319 | |
320 R_AT( RAT_OK, mmEntStat.entOwn ) | |
321 ( mmEntStat.curCmd ); | |
322 | |
323 /* log result */ | |
324 cmh_logRslt ( mmEntStat.entOwn, RAT_OK, mmEntStat.curCmd, -1, | |
325 BS_SPEED_NotPresent,CME_ERR_NotPresent ); | |
326 | |
327 mmEntStat.curCmd = AT_CMD_NONE; | |
328 break; | |
329 | |
330 case( COPS_MOD_SetOnly ): | |
331 | |
332 cmhMM_Ntfy_NtwRegistrationStatus(cmhMM_GetNregCREGStat()); | |
333 break; | |
334 | |
335 case( COPS_MOD_Both ): | |
336 | |
337 /* Implements Measure 87 */ | |
338 cmhMM_Registration_AutoMode( mmEntStat.curCmd ); | |
339 break; | |
340 } | |
341 break; | |
342 | |
343 case( AT_CMD_NRG ): | |
344 /* | |
345 *---------------------------------------------------------------- | |
346 * process event for %NRG command | |
347 *---------------------------------------------------------------- | |
348 */ | |
349 switch( cmhPrm[mmEntStat.entOwn].mmCmdPrm.NRGsrvMode ) | |
350 { | |
351 case( NRG_SVMD_Full ): | |
352 | |
353 switch( cmhPrm[mmEntStat.entOwn].mmCmdPrm.NRGregMode ) | |
354 { | |
355 case( NRG_RGMD_Auto ): | |
356 case( NRG_RGMD_Manual ): | |
357 | |
358 mmEntStat.curCmd = AT_CMD_NONE; | |
359 | |
360 cmhMM_Ntfy_NtwRegistrationStatus(CREG_STAT_Denied); | |
361 | |
362 #if defined (GPRS) AND defined (DTI) | |
363 psaG_MM_CMD_SET_REGMD ( mmShrdPrm.regMode ); /* restore former registration mode*/ | |
364 #else | |
365 /* restore former registration mode */ | |
366 psaMM_SetRegMode ( mmShrdPrm.regMode ); | |
367 #endif | |
368 | |
369 R_AT( RAT_CME, mmEntStat.entOwn ) | |
370 ( AT_CMD_NRG, cmhMM_GetNregCMEStat()); | |
371 | |
372 /* log result */ | |
373 cmh_logRslt ( mmEntStat.entOwn, RAT_CME, AT_CMD_NRG, -1, | |
374 BS_SPEED_NotPresent ,cmhMM_GetNregCMEStat() ); | |
375 break; | |
376 | |
377 case( NRG_RGMD_Both ): | |
378 | |
379 /* Implements Measure 87 */ | |
380 cmhMM_Registration_AutoMode( AT_CMD_NRG ); | |
381 | |
382 break; | |
383 } | |
384 break; | |
385 | |
386 case( NRG_SVMD_Limited ): | |
387 | |
388 /* pending registration request */ | |
389 if( regReqPnd EQ TRUE ) | |
390 { | |
391 mmShrdPrm.regMode = MODE_AUTO; | |
392 | |
393 #if defined (GPRS) AND defined (DTI) | |
394 (void)psaG_MM_CMD_REG (); /* register to network */ | |
395 #else | |
396 (void)psaMM_Registrate (); /* register to network */ | |
397 #endif | |
398 | |
399 regReqPnd = FALSE; | |
400 break; | |
401 } | |
402 | |
403 if( mmShrdPrm.regStat EQ RS_LMTD_SRV ) | |
404 { | |
405 mmEntStat.curCmd = AT_CMD_NONE; | |
406 | |
407 cmhMM_Ntfy_NtwRegistrationStatus(cmhMM_GetNregCREGStat()); | |
408 | |
409 R_AT( RAT_OK, mmEntStat.entOwn ) | |
410 ( AT_CMD_NRG ); | |
411 | |
412 /* log result */ | |
413 cmh_logRslt ( mmEntStat.entOwn, RAT_OK, AT_CMD_NRG, -1, | |
414 BS_SPEED_NotPresent, CME_ERR_NotPresent ); | |
415 } | |
416 else | |
417 { | |
418 mmEntStat.curCmd = AT_CMD_NONE; | |
419 | |
420 cmhMM_Ntfy_NtwRegistrationStatus(CREG_STAT_Denied); | |
421 | |
422 #if defined (GPRS) AND defined (DTI) | |
423 psaG_MM_CMD_SET_REGMD ( mmShrdPrm.regMode ); /* restore former registration mode*/ | |
424 #else | |
425 /* restore former registration mode */ | |
426 psaMM_SetRegMode ( mmShrdPrm.regMode ); | |
427 #endif | |
428 | |
429 R_AT( RAT_CME, mmEntStat.entOwn ) | |
430 ( AT_CMD_NRG, cmhMM_GetNregCMEStat() ); | |
431 | |
432 /* log result */ | |
433 cmh_logRslt ( mmEntStat.entOwn, RAT_CME, AT_CMD_NRG, -1, | |
434 BS_SPEED_NotPresent ,cmhMM_GetNregCMEStat() ); | |
435 } | |
436 break; | |
437 | |
438 case( NRG_SVMD_NoSrv ): | |
439 | |
440 mmEntStat.curCmd = AT_CMD_NONE; | |
441 | |
442 cmhMM_Ntfy_NtwRegistrationStatus(CREG_STAT_NoSearch); | |
443 | |
444 R_AT( RAT_OK, mmEntStat.entOwn ) | |
445 ( AT_CMD_NRG ); | |
446 | |
447 /* log result */ | |
448 cmh_logRslt ( mmEntStat.entOwn, RAT_OK, AT_CMD_NRG, -1, | |
449 BS_SPEED_NotPresent,CME_ERR_NotPresent ); | |
450 break; | |
451 | |
452 case( NRG_SVMD_SetRegModeOnly ): | |
453 | |
454 cmhMM_Ntfy_NtwRegistrationStatus(cmhMM_GetNregCREGStat()); | |
455 break; | |
456 | |
457 } | |
458 break; | |
459 } | |
460 | |
461 return 0; | |
462 } | |
463 | |
464 /* | |
465 +-------------------------------------------------------------------+ | |
466 | PROJECT : GSM-PS (6147) MODULE : CMH_MMR | | |
467 | ROUTINE : cmhMM_NetworkLst | | |
468 +-------------------------------------------------------------------+ | |
469 | |
470 PURPOSE : List of networks available | |
471 | |
472 */ | |
473 | |
474 GLOBAL SHORT cmhMM_NetworkLst ( void ) | |
475 { | |
476 /* | |
477 * We need a structure which has to fit into one not too big partition. | |
478 * sizeof (T_OP_NAME) = 36 (35 characters plus one alignment byte) | |
479 * with MAX_LONG_OPER_LEN = 26 and MAX_SHRT_OPER_LEN = 9 | |
480 * => sizeof (T_OP_NAME) * MAX_OPER = 432 | |
481 * => This fits into one of the 432er partitions of which we have some. | |
482 */ | |
483 typedef struct | |
484 { | |
485 char longNamBuf[MAX_LONG_OPER_LEN]; /* buffer long name */ | |
486 char shrtNamBuf[MAX_SHRT_OPER_LEN]; /* buffer short name*/ | |
487 } T_OP_NAME; | |
488 | |
489 T_OP_NAME * op_name = NULL; /* Holds operator names */ | |
490 T_OPER_ENTRY plmnDesc; /* PLMN description */ | |
491 T_ACI_COPS_OPDESC * operLst = NULL; /* operator list T_ACI_COPS_LST */ | |
492 SHORT lstIdx; /* holds list idx */ | |
493 SHORT mcc, mnc; /* holds converted mnc and mcc */ | |
494 BOOL found; /* Result of cmhMM_FindXXX() */ | |
495 T_ACI_AT_CMD bufCmd; | |
496 | |
497 TRACE_FUNCTION ("cmhMM_NetworkLst()"); | |
498 | |
499 /* | |
500 *------------------------------------------------------------------- | |
501 * check for command context | |
502 *------------------------------------------------------------------- | |
503 */ | |
504 switch( mmEntStat.curCmd ) | |
505 { | |
506 case( AT_CMD_COPS ): | |
507 case (AT_CMD_P_COPS): | |
508 | |
509 ACI_MALLOC (op_name, sizeof (T_OP_NAME) * MAX_OPER); | |
510 ACI_MALLOC (operLst, sizeof (T_ACI_COPS_OPDESC) * MAX_OPER); | |
511 | |
512 /* | |
513 *--------------------------------------------------------------- | |
514 * for every entry of the PLMN list | |
515 *--------------------------------------------------------------- | |
516 */ | |
517 for( lstIdx = 0; lstIdx < MAX_OPER AND lstIdx < MAX_PLMN_ID; lstIdx++ ) | |
518 { | |
519 /* | |
520 *------------------------------------------------------------- | |
521 * if last entry of PLMN list, close oper list and return | |
522 *------------------------------------------------------------- | |
523 */ | |
524 if( mmShrdPrm.PLMNLst[lstIdx].v_plmn EQ INVLD_PLMN ) | |
525 { | |
526 operLst[lstIdx].status = COPS_STAT_NotPresent; | |
527 operLst[lstIdx].longOper = NULL; | |
528 operLst[lstIdx].shortOper = NULL; | |
529 operLst[lstIdx].numOper[0]= '\0'; | |
530 break; | |
531 } | |
532 | |
533 /* | |
534 *------------------------------------------------------------- | |
535 * find PLMN description | |
536 *------------------------------------------------------------- | |
537 */ | |
538 cmhMM_CnvrtPLMN2INT( mmShrdPrm.PLMNLst[lstIdx].mcc, | |
539 mmShrdPrm.PLMNLst[lstIdx].mnc, | |
540 &mcc, &mnc ); | |
541 | |
542 found = cmhMM_FindPLMN (&plmnDesc, mcc, mnc, mmShrdPrm.LACLst[lstIdx], TRUE); | |
543 | |
544 if (!found) /* no description found */ | |
545 { | |
546 operLst[lstIdx].longOper = ""; | |
547 operLst[lstIdx].shortOper = ""; | |
548 } | |
549 else | |
550 { | |
551 /* Copy strings into dynamic buffer so that they don't get lost */ | |
552 memcpy (op_name[lstIdx].longNamBuf, plmnDesc.longName, MAX_LONG_OPER_LEN); | |
553 memcpy (op_name[lstIdx].shrtNamBuf, plmnDesc.shrtName, MAX_SHRT_OPER_LEN); | |
554 | |
555 /* EONS PLMN name conding scheme and source flag */ | |
556 operLst[lstIdx].pnn = plmnDesc.pnn; | |
557 operLst[lstIdx].longOper = op_name[lstIdx].longNamBuf; | |
558 operLst[lstIdx].long_len = plmnDesc.long_len; | |
559 operLst[lstIdx].long_ext_dcs = plmnDesc.long_ext_dcs; | |
560 operLst[lstIdx].shortOper = op_name[lstIdx].shrtNamBuf; | |
561 operLst[lstIdx].shrt_len = plmnDesc.shrt_len; | |
562 operLst[lstIdx].shrt_ext_dcs = plmnDesc.shrt_ext_dcs; | |
563 } | |
564 | |
565 /* | |
566 *------------------------------------------------------------- | |
567 * build numeric representation | |
568 *------------------------------------------------------------- | |
569 */ | |
570 /* Implements Measure#32: Row 987 & 986 */ | |
571 cmhMM_mcc_mnc_print(&(operLst[lstIdx].numOper[0]), mcc, mnc); | |
572 | |
573 /* | |
574 *------------------------------------------------------------- | |
575 * set PLMN status | |
576 *------------------------------------------------------------- | |
577 */ | |
578 if (mmShrdPrm.PLMNLst[lstIdx].v_plmn EQ mmShrdPrm.usedPLMN.v_plmn AND | |
579 memcmp (mmShrdPrm.PLMNLst[lstIdx].mcc, | |
580 mmShrdPrm.usedPLMN.mcc, | |
581 SIZE_MCC) EQ 0 AND | |
582 memcmp (mmShrdPrm.PLMNLst[lstIdx].mnc, | |
583 mmShrdPrm.usedPLMN.mnc, SIZE_MNC) EQ 0) | |
584 { | |
585 operLst[lstIdx].status = COPS_STAT_Current; | |
586 } | |
587 else | |
588 { | |
589 switch( mmShrdPrm.FRBLst[lstIdx] ) | |
590 { | |
591 case( FORB_PLMN_NOT_INCLUDED ): | |
592 operLst[lstIdx].status = COPS_STAT_Available; | |
593 break; | |
594 case( 1 /*FORB_PLMN_INCLUDED*/ ): | |
595 operLst[lstIdx].status = COPS_STAT_Forbidden; | |
596 break; | |
597 default: | |
598 operLst[lstIdx].status = COPS_STAT_Unknown; | |
599 break; | |
600 } | |
601 } | |
602 } | |
603 | |
604 #if defined (GPRS) AND defined (DTI) | |
605 psaG_MM_CMD_SET_REGMD ( mmShrdPrm.regMode ); /* restore former registration mode*/ | |
606 #else | |
607 /* restore former registration mode */ | |
608 psaMM_SetRegMode ( mmShrdPrm.regMode ); | |
609 #endif | |
610 bufCmd = mmEntStat.curCmd; | |
611 mmEntStat.curCmd = AT_CMD_NONE; | |
612 if(bufCmd EQ AT_CMD_COPS) | |
613 { | |
614 R_AT( RAT_COPS, mmEntStat.entOwn ) | |
615 ( --lstIdx, &operLst[0]); | |
616 } | |
617 else | |
618 { | |
619 R_AT( RAT_P_COPS, mmEntStat.entOwn ) | |
620 ( --lstIdx, &operLst[0]); | |
621 } | |
622 R_AT( RAT_OK, mmEntStat.entOwn ) | |
623 ( mmEntStat.curCmd ); | |
624 | |
625 /* log result */ | |
626 cmh_logRslt ( mmEntStat.entOwn, RAT_OK, mmEntStat.curCmd , -1, | |
627 BS_SPEED_NotPresent,CME_ERR_NotPresent ); | |
628 | |
629 ACI_MFREE (op_name); | |
630 ACI_MFREE (operLst); | |
631 | |
632 break; | |
633 } | |
634 | |
635 return 0; | |
636 } | |
637 | |
638 /* | |
639 +-------------------------------------------------------------------+ | |
640 | PROJECT : GSM-PS (6147) MODULE : CMH_MMR | | |
641 | ROUTINE : cmhMM_SelNetwork | | |
642 +-------------------------------------------------------------------+ | |
643 | |
644 PURPOSE : Select a network, cause for failure from MM is passed as parameter | |
645 to report appropriate error. | |
646 */ | |
647 | |
648 GLOBAL SHORT cmhMM_SelNetwork ( USHORT cause ) | |
649 { | |
650 TRACE_FUNCTION ("cmhMM_SelNetwork()"); | |
651 | |
652 switch( mmEntStat.curCmd ) | |
653 { | |
654 case( AT_CMD_COPS ): | |
655 | |
656 #if defined (GPRS) AND defined (DTI) | |
657 psaG_MM_CMD_SET_REGMD ( mmShrdPrm.regMode ); /* restore former registration mode*/ | |
658 #else | |
659 /* restore former registration mode */ | |
660 psaMM_SetRegMode ( mmShrdPrm.regMode ); | |
661 #endif | |
662 | |
663 switch(cause) | |
664 { | |
665 case MMCS_SIM_REMOVED: | |
666 /* If the SIM is not inserted or if the SIM requires a PIN, more meaningful error | |
667 * codes are returned*/ | |
668 if ( (cmhSIM_GetSIMError(mmEntStat.entOwn, mmEntStat.curCmd)) NEQ AT_CMPL) | |
669 { | |
670 R_AT( RAT_CME, mmEntStat.entOwn ) ( mmEntStat.curCmd , CME_ERR_NotPresent); | |
671 } | |
672 break; | |
673 | |
674 case MMCS_PLMN_NOT_IDLE_MODE: | |
675 R_AT( RAT_CME, mmEntStat.entOwn ) ( mmEntStat.curCmd , CME_ERR_AbortedByNetwork ); | |
676 break; | |
677 | |
678 default: | |
679 R_AT( RAT_CME, mmEntStat.entOwn ) ( mmEntStat.curCmd , CME_ERR_NotPresent); | |
680 break; | |
681 } | |
682 | |
683 /* log result */ | |
684 cmh_logRslt ( mmEntStat.entOwn, RAT_CME, mmEntStat.curCmd , -1, | |
685 BS_SPEED_NotPresent, CME_ERR_NotPresent ); | |
686 | |
687 mmEntStat.curCmd = AT_CMD_NONE; | |
688 | |
689 break; | |
690 } | |
691 | |
692 return 0; | |
693 } | |
694 | |
695 | |
696 /* | |
697 +-------------------------------------------------------------------+ | |
698 | PROJECT : GSM-PS (6147) MODULE : CMH_MMR | | |
699 | ROUTINE : cmhMM_CipheringInd | | |
700 +-------------------------------------------------------------------+ | |
701 | |
702 PURPOSE : ciphering indication received | |
703 | |
704 */ | |
705 | |
706 GLOBAL SHORT cmhMM_CipheringInd ( UBYTE ciph ) | |
707 { | |
708 SHORT idx; /* holds index counter */ | |
709 | |
710 TRACE_FUNCTION ("cmhMM_CipheringInd()"); | |
711 | |
712 if (simShrdPrm.ciSIMEnabled NEQ TRUE) | |
713 { | |
714 return 1; | |
715 } | |
716 | |
717 for (idx = 0; idx < CMD_SRC_MAX; idx++) | |
718 { | |
719 /* | |
720 *----------------------------------------------------------------- | |
721 * new message indication | |
722 *----------------------------------------------------------------- | |
723 */ | |
724 #ifndef GPRS | |
725 #define CIPH_NA 2 | |
726 #endif | |
727 R_AT(RAT_P_CPRI,(T_ACI_CMD_SRC)idx) ( ciph, CIPH_NA ); | |
728 } | |
729 return 0; | |
730 } | |
731 | |
732 /* Implements Measure 87 */ | |
733 /* | |
734 +------------------------------------------------------------------------------ | |
735 | Function : cmhMM_Registration_AutoMode | |
736 +------------------------------------------------------------------------------ | |
737 | Purpose : This Function will try to register into network in | |
738 | automatic mode. | |
739 | | |
740 | Parameters : void | |
741 | | |
742 | Return : void | |
743 +------------------------------------------------------------------------------ | |
744 */ | |
745 | |
746 LOCAL void cmhMM_Registration_AutoMode( T_ACI_AT_CMD at_cmd_id ) | |
747 { | |
748 TRACE_FUNCTION ("cmhMM_Registration_AutoMode()"); | |
749 | |
750 if ( mmShrdPrm.regModeAutoBack ) | |
751 { | |
752 /* | |
753 * Tried register to network in manual mode. Attempt failed. | |
754 * Now trying to register into network in automatic mode. | |
755 */ | |
756 | |
757 mmShrdPrm.regModeBeforeAbort = mmShrdPrm.regMode; | |
758 mmShrdPrm.regMode = MODE_AUTO; | |
759 mmShrdPrm.regModeAutoBack = FALSE; | |
760 | |
761 #if defined (GPRS) AND defined (DTI) | |
762 if( psaG_MM_CMD_REG ( ) EQ 0 ) | |
763 #else | |
764 if( psaMM_Registrate () EQ 0 ) | |
765 #endif | |
766 { | |
767 return; | |
768 } | |
769 | |
770 } | |
771 else | |
772 { | |
773 | |
774 cmhMM_Ntfy_NtwRegistrationStatus(CREG_STAT_Denied); | |
775 | |
776 /* If fallback to automatic mode is allowed, fall back */ | |
777 if ( at_cmd_id EQ AT_CMD_NRG ) | |
778 { | |
779 if (mmShrdPrm.regModeAutoBack) | |
780 { | |
781 mmShrdPrm.regModeBeforeAbort = mmShrdPrm.regMode; | |
782 mmShrdPrm.regModeAutoBack = FALSE; | |
783 mmShrdPrm.regMode = MODE_AUTO; | |
784 } | |
785 } | |
786 | |
787 #if defined (GPRS) AND defined (DTI) | |
788 /* restore former registration mode*/ | |
789 psaG_MM_CMD_SET_REGMD ( mmShrdPrm.regMode ); | |
790 #else | |
791 /* restore former registration mode or set new one */ | |
792 psaMM_SetRegMode ( mmShrdPrm.regMode ); | |
793 #endif | |
794 } | |
795 | |
796 mmEntStat.curCmd = AT_CMD_NONE; | |
797 | |
798 R_AT( RAT_CME, mmEntStat.entOwn ) | |
799 ( at_cmd_id, cmhMM_GetNregCMEStat()); | |
800 | |
801 /* log result */ | |
802 cmh_logRslt ( mmEntStat.entOwn, RAT_CME, mmEntStat.curCmd, -1, | |
803 BS_SPEED_NotPresent,cmhMM_GetNregCMEStat() ); | |
804 | |
805 } | |
806 | |
807 | |
808 /*==== EOF ========================================================*/ | |
809 |