comparison g23m-aci/aci/cmh_f.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_F
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 global functions of the command
18 | handler.
19 +-----------------------------------------------------------------------------
20 */
21
22 #ifndef CMH_F_C
23 #define CMH_F_C
24 #endif
25
26 #include "config.h"
27 #include "fixedconf.h"
28 #include "condat-features.h"
29 #include "aci_conf.h"
30
31 #include "aci_all.h"
32
33 /*==== INCLUDES ===================================================*/
34
35 #include "aci_cmh.h"
36 #include "cphs.h"
37 #include "aci_cphs.h"
38 #include "ati_cmd.h"
39 #include "aci_cmd.h"
40 #include "ksd.h"
41 #include "l4_tim.h"
42
43 #include "aci_io.h"
44
45 #ifdef FAX_AND_DATA
46 #include "aci_fd.h"
47 #endif
48
49 #ifdef DTI
50 #include "dti.h" /* functionality of the dti library */
51 #include "dti_conn_mng.h"
52 #endif
53 #include "psa.h"
54 #include "psa_mm.h"
55 #include "psa_sim.h"
56 #include "psa_cc.h"
57 #include "psa_sms.h"
58 #include "psa_ss.h"
59 #include "cmh.h"
60 #include "cmh_mm.h"
61 #include "cmh_sim.h"
62 #include "cmh_cc.h"
63 #include "cmh_sms.h"
64 #include "cmh_ss.h"
65
66 #include "aci.h"
67 #include "phb.h"
68 #include "aci_lst.h"
69 #include "conc_sms.h"
70
71
72 #ifdef FAX_AND_DATA
73 #include "psa_ra.h"
74 #include "cmh_ra.h"
75 #include "psa_l2r.h"
76 #include "cmh_l2r.h"
77 #include "psa_tra.h"
78
79 #ifdef FF_FAX
80 #include "psa_t30.h"
81 #include "cmh_t30.h"
82 #endif /* FF_FAX */
83
84 #endif /* FAX_AND_DATA */
85
86 #ifdef GPRS
87 #include "gaci.h"
88 #include "gaci_cmh.h"
89 #include "pcm.h"
90 #include "psa_gmm.h"
91 #include "cmh_gmm.h"
92 #include "psa_sm.h"
93 #include "cmh_sm.h"
94 #include "psa_gppp.h"
95 #include "cmh_gppp.h"
96
97 #endif /* GPRS */
98
99 #ifdef _CONC_TESTING_
100 #include "aci_mfw.h"
101 #endif
102
103 #ifdef UART
104 #include "psa_uart.h"
105 #include "cmh_uart.h"
106 #endif
107
108 #ifdef FF_PSI
109 #include "psa_psi.h"
110 #include "cmh_psi.h"
111 #endif /*FF_PSI*/
112
113
114 #include "rx.h"
115
116 #ifndef _SIMULATION_
117 #include "../../services/ffs/ffs.h"
118 #include "ffs_coat.h"
119 #endif
120
121 /*==== CONSTANTS ==================================================*/
122
123 /*==== GLOBALS ====================================================*/
124 #ifdef FF_ATI
125 EXTERN T_CIEV_SIGNAL_BUFFER asCievSignalBuf;
126 EXTERN T_CIEV_SMSFULL_BUFFER asCievSmsFullBuf;
127 #endif /* FF_ATI */
128
129 GLOBAL T_VOID_FUNC rat_fptr;
130 /*==== TYPES ======================================================*/
131
132
133 /*==== EXPORT =====================================================*/
134 /* MACRO CB_VC() for call-backs used by the voice stack */
135 #ifdef FF_BAT
136
137 #ifdef FF_ATI
138 #if defined SMI OR defined MFW OR defined FF_MMI_RIV
139 #define CB_VC( cbNam ){rAT_##cbNam,rCI_##cbNam,rBAT_##cbNam}
140 #define CB_VC_EXT( cbNam ){rAT_##cbNam##_Ext,rCI_##cbNam,rBAT_##cbNam}
141 #else
142 #define CB_VC( cbNam ){0,rCI_##cbNam,rBAT_##cbNam} /* ACI only */
143 #ifdef _CONC_TESTING_ /* for _CONC_TESTING for ACI-only */
144 #define CB_VC_EXT( cbNam ){rAT_##cbNam##_Ext,rCI_##cbNam,rBAT_##cbNam}
145 #else
146 #define CB_VC_EXT( cbNam ){0,rCI_##cbNam,rBAT_##cbNam}
147 #endif
148 #endif
149 #else
150 #if defined SMI OR defined MFW OR defined FF_MMI_RIV
151 #define CB_VC( cbNam ){rAT_##cbNam,0,rBAT_##cbNam}
152 #define CB_VC_EXT( cbNam ){rAT_##cbNam##_Ext,0,rBAT_##cbNam}
153 #else
154 #define CB_VC( cbNam ){0,0,0}
155 #define CB_EXT( cbNam ){0,0,0}
156 #endif
157 #endif
158
159 /* MACRO CB_FD() for call-backs used by the F&D stack */
160 #ifdef FAX_AND_DATA
161 #define CB_FD( cbNam ){0,rCI_##cbNam,rBAT_##cbNam}
162 #else
163 #define CB_FD( cbNam ){0,0,0}
164 #endif
165
166 /* MACRO CB_ST() for call-backs used by SIM toolkit */
167 #ifdef SIM_TOOLKIT
168 #ifdef FF_ATI
169 #if defined SMI OR defined MFW OR defined FF_MMI_RIV
170 #define CB_ST( cbNam ){rAT_##cbNam,rCI_##cbNam,rBAT_##cbNam}
171 #else
172 #define CB_ST( cbNam ){0,rCI_##cbNam,rBAT_##cbNam}
173 #endif
174 #else
175 #if defined SMI OR defined MFW OR defined FF_MMI_RIV
176 #define CB_ST( cbNam ){rAT_##cbNam,0,rBAT_##cbNam}
177 #else
178 #define CB_ST( cbNam ){0,0,0}
179 #endif
180 #endif
181 #else
182 #define CB_ST( cbNam ){0,0,0}
183 #endif
184
185 /* MACRO CB_GP() for call-backs used by GPRS */
186 #ifdef GPRS
187 #ifdef FF_ATI
188 #if defined SMI OR defined MFW OR defined FF_MMI_RIV
189 #define CB_GP( cbNam ){rAT_##cbNam,rCI_##cbNam,rBAT_##cbNam}
190 #else
191 #define CB_GP( cbNam ){0,rCI_##cbNam,rBAT_##cbNam}
192 #endif
193 #else
194 #if defined SMI OR defined MFW OR defined FF_MMI_RIV
195 #define CB_GP( cbNam ){rAT_##cbNam,0,rBAT_##cbNam}
196 #else
197 #define CB_GP( cbNam ){0,0,0}
198 #endif
199 #endif
200 #else
201 #define CB_GP( cbNam ){0,0,0}
202 #endif /* GPRS */
203
204 #else
205
206 #ifdef FF_ATI
207 #if defined SMI OR defined MFW OR defined FF_MMI_RIV
208 #define CB_VC( cbNam ){rAT_##cbNam,rCI_##cbNam}
209 #define CB_VC_EXT( cbNam ){rAT_##cbNam##_Ext,rCI_##cbNam}
210 #else
211 #define CB_VC( cbNam ){0,rCI_##cbNam}
212 #ifdef _CONC_TESTING_ /* for _CONC_TESTING for ACI-only */
213 #define CB_VC_EXT( cbNam ){rAT_##cbNam##_Ext,rCI_##cbNam}
214 #else
215 #define CB_VC_EXT( cbNam ){0,rCI_##cbNam}
216 #endif
217 #endif
218 #else
219 #if defined SMI OR defined MFW OR defined FF_MMI_RIV
220 #define CB_VC( cbNam ){rAT_##cbNam,0}
221 #define CB_VC_EXT( cbNam ){rAT_##cbNam##_Ext,0}
222 #else
223 #define CB_VC( cbNam ){0,0}
224 #define CB_EXT( cbNam ){0,0}
225 #endif
226 #endif
227
228 /* MACRO CB_FD() for call-backs used by the F&D stack */
229 #ifdef FAX_AND_DATA
230 #define CB_FD( cbNam ){0,rCI_##cbNam}
231 #else
232 #define CB_FD( cbNam ){0,0}
233 #endif
234
235 /* MACRO CB_ST() for call-backs used by SIM toolkit */
236 #ifdef SIM_TOOLKIT
237 #ifdef FF_ATI
238 #if defined SMI OR defined MFW OR defined FF_MMI_RIV
239 #define CB_ST( cbNam ){rAT_##cbNam,rCI_##cbNam}
240 #else
241 #define CB_ST( cbNam ){0,rCI_##cbNam}
242 #endif
243 #else
244 #if defined SMI OR defined MFW OR defined FF_MMI_RIV
245 #define CB_ST( cbNam ){rAT_##cbNam,0}
246 #else
247 #define CB_ST( cbNam ){0,0}
248 #endif
249 #endif
250 #else
251 #define CB_ST( cbNam ){0,0}
252 #endif
253
254 /* MACRO CB_GP() for call-backs used by GPRS */
255 #ifdef GPRS
256 #ifdef FF_ATI
257 #if defined SMI OR defined MFW OR defined FF_MMI_RIV
258 #define CB_GP( cbNam ){rAT_##cbNam,rCI_##cbNam}
259 #else
260 #define CB_GP( cbNam ){0,rCI_##cbNam}
261 #endif
262 #else
263 #if defined SMI OR defined MFW OR defined FF_MMI_RIV
264 #define CB_GP( cbNam ){rAT_##cbNam,0}
265 #else
266 #define CB_GP( cbNam ){0,0}
267 #endif
268 #endif
269 #else
270 #define CB_GP( cbNam )
271 #endif /* GPRS */
272
273 #endif /* FF_BAT */
274
275 /* call back jump table */
276 GLOBAL const T_VOID_FUNC RATJmpTbl[RAT_MAX][CMD_MODE_MAX] =
277 {
278 CB_VC( OK ), /* RAT_OK */
279 CB_VC( CONNECT ), /* RAT_CONNECT */
280 CB_VC( PlusCME ), /* RAT_CME */
281 CB_VC( NO_CARRIER ), /* RAT_NO_CARRIER */
282 CB_VC( PlusCRING ), /* RAT_CRING */
283 CB_FD( PlusDR ), /* RAT_DR */
284 CB_FD( PlusCR ), /* RAT_CR */
285 CB_VC( PlusCPIN ), /* RAT_CPIN */
286 CB_VC( PlusCOPS ), /* RAT_COPS */
287 CB_VC( PlusCREG ), /* RAT_CREG */
288 CB_VC( PlusCCWA ), /* RAT_CCWA */
289 CB_VC( PlusCLIP ), /* RAT_CLIP */
290 CB_VC( PlusCDIP ), /* RAT_CDIP */
291 CB_VC( PlusCOLP ), /* RAT_COLP */
292 CB_VC( PlusCRING_OFF ), /* RAT_CRING_OFF */
293
294 #if defined (FF_FAX) AND defined (DTI)
295 CB_FD( PlusFCO ), /* RAT_FCO */
296 CB_FD( PlusFIS ), /* RAT_FIS */
297 CB_FD( PlusFTI ), /* RAT_FTI */
298 CB_FD( PlusFCS ), /* RAT_FCS */
299 CB_FD( PlusFCI ), /* RAT_FCI */
300 #endif /* FF_FAX */
301
302 CB_VC( PlusCMS ), /* RAT_CMS */
303 CB_VC( PlusCSMS ), /* RAT_CSMS */
304 CB_VC( PlusCMGS ), /* RAT_CMGS */
305 CB_VC( PlusCMSS ), /* RAT_CMSS */
306 CB_VC( PlusCMGW ), /* RAT_CMGW */
307 CB_VC( PlusCDS ), /* RAT_CDS */
308 CB_VC( PlusCMGC ), /* RAT_CMGC */
309 CB_VC( PlusCMGD ), /* RAT_CMGD */
310 CB_VC( PlusCMGR ), /* RAT_CMGR */
311 CB_VC( PlusCMGL ), /* RAT_CMGL */
312 #if defined _CONC_TESTING_ AND defined TI_PS_FF_CONC_SMS
313 CB_VC_EXT( PlusCMTI ), /* RAT_CMTI */
314 CB_VC_EXT( PlusCMT ), /* RAT_CMT */
315 #else
316 CB_VC( PlusCMTI ), /* RAT_CMTI */
317 CB_VC( PlusCMT ), /* RAT_CMT */
318 #endif
319 CB_VC( PlusCBM ), /* RAT_CBM */
320 CB_VC( PlusCPMS ), /* RAT_CPMS */
321
322 #if defined (FF_FAX) AND defined (DTI)
323
324 CB_FD( PlusFHT ), /* RAT_FHT */
325 CB_FD( PlusFHR ), /* RAT_FHR */
326 CB_FD( PlusFSA ), /* RAT_FSA */
327 CB_FD( PlusFPA ), /* RAT_FPA */
328 CB_FD( PlusFPW ), /* RAT_FPW */
329 CB_FD( PlusFET ), /* RAT_FET */
330 CB_FD( PlusFVO ), /* RAT_FVO */
331 CB_FD( PlusFPO ), /* RAT_FPO */
332 CB_FD( PlusFPI ), /* RAT_FPI */
333 CB_FD( PlusFNF ), /* RAT_FNF */
334 CB_FD( PlusFNS ), /* RAT_FNS */
335 CB_FD( PlusFNC ), /* RAT_FNC */
336 CB_FD( PlusFHS ), /* RAT_FHS */
337 CB_FD( PlusFPS ), /* RAT_FPS */
338 CB_FD( PlusFTC ), /* RAT_FTC */
339 #endif /* FF_FAX */
340
341 CB_FD( PlusILRR ), /* RAT_ILRR */
342 CB_VC( BUSY ), /* RAT_BUSY */
343 CB_VC( NO_ANSWER ), /* RAT_NO_ANSWER */
344 CB_VC( PercentSIMREM ), /* RAT_SIMREM */
345 CB_VC( PlusCLIR ), /* RAT_CLIR */
346 CB_VC( PercentCOLR ), /* RAT_COLR */
347 CB_VC( PlusCSSI ), /* RAT_CSSI */
348 CB_VC( PlusCSSU ), /* RAT_CSSU */
349 CB_VC( PlusCUSD ), /* RAT_CUSD */
350 CB_VC( PlusCCFC ), /* RAT_CCFC */
351 CB_VC( PlusCLCK ), /* RAT_CLCK */
352 CB_VC( PlusCIMI ), /* RAT_CIMI */
353 CB_ST( PercentSATI ), /* RAT_SATI */
354 CB_ST( PercentSATE ), /* RAT_SATE */
355 CB_VC( PercentKSIR ), /* RAT_KSIR */
356 CB_VC( PercentCPI ), /* RAT_CPI */
357 CB_VC( PercentCTYI ), /* RAT_CTYI */
358 CB_VC( PlusCNUM ), /* RAT_CNUM */
359 CB_VC( PlusCPOL ), /* RAT_CPOL */
360 CB_VC( PlusCCCM ), /* RAT_CCCM */
361 CB_VC( PercentCTV ), /* RAT_CTV */
362 CB_ST( PercentSATN ), /* RAT_SATN */
363 CB_ST( PercentSATA ), /* RAT_SATA */
364 CB_VC( sms_ready), /* RAT_SMS_READY */
365 CB_VC( phb_status), /* RAT_PHB_STATUS */
366 CB_VC( PercentSIMINS ), /* RAT_SIMINS */
367 CB_VC( PlusCRSM ), /* RAT_CRSM */
368 CB_VC( PlusCSIM ), /* RAT_CSIM */
369 CB_VC( PercentCCBS ), /* RAT_CCBS */
370 CB_VC( PlusCCWV ), /* RAT_CCWV */
371 CB_VC( PercentCNAP ), /* RAT_CNAP */
372 CB_VC( SignalSMS ), /* RAT_SIG_SMS */
373 CB_VC( PlusCLAN ), /* RAT_CLAN */
374 CB_VC( PlusCLAE ), /* RAT_CLAE */
375 CB_VC( PercentCSQ ), /* RAT_CSQ */
376 CB_VC( PercentALS ), /* RAT_ALS */
377
378 CB_VC( PlusCTZV ), /* RAT_CTZR */
379 CB_VC( PercentCREG ), /* RAT_P_CREG */
380 #ifdef REL99
381 CB_VC( PercentCMGRS ), /* RAT_P_CMGRS */
382 #endif
383
384 #ifdef GPRS
385
386 CB_GP( PlusCGACT ), /* RAT_CGACT */
387 CB_GP( PlusCGDATA ), /* RAT_CGDATA */
388 CB_GP( PlusCGANS ), /* RAT_CGANS */
389 CB_GP( PlusCGEREP ), /* RAT_CGEREP */
390 CB_GP( PlusCGREG ), /* RAT_CGREG */
391 CB_GP( changedQOS ), /* RAT_QOS_MOD */
392 CB_GP( PercentSNCNT ), /* RAT_SNCNT */
393 CB_GP( PercentCGREG ), /* RAT_P_CGREG */
394 #ifdef REL99
395 CB_GP( PlusCGCMOD ), /* RAT_CGCMOD */
396 #endif /* REL99 */
397 CB_GP( PercentCGEV ), /* RAT_P_CGEV */
398 #endif /* GPRS */
399
400 #ifdef FF_EM_MODE
401 CB_VC( PercentEM ), /* RAT_EM */
402 CB_VC( PercentEMET ), /* RAT_EMET */
403 CB_VC( PercentEMETS ), /* RAT_EMETS */
404 #endif /* FF_EM_MODE */
405
406 #ifdef FF_CPHS
407 CB_VC( PercentCPNUMS ), /* RAT_CPNUMS */
408 CB_VC( PercentCPVWI ), /* RAT_CPVWI */
409 CB_VC( PercentCPROAM ), /* RAT_CPROAM */
410 #endif /* FF_CPHS */
411 CB_VC( PlusCIEV ), /* RAT_CIEV */
412 CB_VC( PercentRDL ), /* RAT_RDL */
413 #ifdef TI_PS_FF_AT_P_CMD_RDLB
414 CB_VC( PercentRDLB ), /* RAT_RDLB */
415 #endif /* TI_PS_FF_AT_P_CMD_RDLB */
416 CB_VC( PercentCCCN ), /* RAT_CCCN */
417 CB_VC( PercentCSSN ), /* RAT_CSSN */
418
419
420 CB_VC( PercentCSTAT ), /* RAT_CSTAT */
421
422
423
424 CB_VC( Z ), /* RAT_Z */
425 #ifdef TI_PS_FF_AT_P_CMD_CPRSM
426 CB_VC( PercentCPRSM ), /* RAT_CPRSM */
427 #endif /* TI_PS_FF_AT_P_CMD_CPRSM */
428 CB_VC( PercentCTZV ), /*RAT_P_CTZV*/
429 CB_VC( PercentCPRI ), /*RAT_P_CPRI*/
430 CB_VC( PercentSIMEF ), /*RAT_P_SIMEF*/
431
432 CB_VC( PercentCNIV ), /*RAT_P_CNIV*/
433 CB_VC( PercentCOPS ), /* RAT_P_COPS */
434 CB_VC( PercentCMGR ), /* RAT_P_CMGR */
435 CB_VC( PercentCMGL ) /* RAT_P_CMGL */
436 #ifdef FF_CPHS_REL4
437 ,CB_VC( PercentCFIS ), /* RAT_P_CFIS */
438 CB_VC( PercentMWIS ), /* RAT_P_MWIS */
439 CB_VC( PercentMWI ), /* RAT_P_MWI */
440 CB_VC( PercentMBI ), /* RAT_P_MBI */
441 CB_VC( PercentMBDN ) /* RAT_P_MBDN */
442 #endif /* FF_CPHS_REL4 */
443 };
444
445 /*==== VARIABLES ==================================================*/
446 /* needed for function percentCSTAT_indication() */
447 static UBYTE percentCSTAT_stateField;
448
449 LOCAL T_ACI_CMD_MODE aci_cmd_src_mode[CMD_SRC_MAX];
450
451 /* Implements Measure#32: Row 105, 1115 & 1151 */
452 const char * const ffff_str = "FFFF";
453 /*==== FUNCTIONS ==================================================*/
454 LOCAL UBYTE cmh_ClearCall ( T_ACI_CMD_SRC srcId,
455 T_ACI_AT_CMD cmd,
456 UBYTE idx );
457 LOCAL BOOL cmh_tstAndUnflagCall( T_ACI_AT_CMD cmd , UBYTE *srcBuf );
458
459
460 /*
461 +-------------------------------------------------------------------+
462 | PROJECT : GSM-PS (6147) MODULE : CMH |
463 | ROUTINE : cmh_Init |
464 +-------------------------------------------------------------------+
465
466 PURPOSE : Handles all deallocation of dynamic allocated memory.
467
468 */
469
470
471 GLOBAL void cmh_Exit ( void )
472 {
473 TRACE_FUNCTION ("cmh_Exit()");
474 #ifdef GPRS
475 cmhSM_free_pdpcontext_list();
476 #endif
477 }
478
479
480 /*
481 +-------------------------------------------------------------------+
482 | PROJECT : GSM-PS (6147) MODULE : CMH |
483 | ROUTINE : cmh_Init |
484 +-------------------------------------------------------------------+
485
486 PURPOSE : initialize the command handler.
487
488 */
489
490
491 GLOBAL void cmh_Init ( void )
492 {
493 T_ACI_ENTITY_ID_MSG index_entiy_id_msg;
494
495 #ifdef FF_ATI
496 UBYTE index_cievbuf_size;
497 #endif
498
499 #ifdef UART
500 T_ACI_CMD_SRC index;
501 #endif
502
503
504 TRACE_FUNCTION ("cmh_Init()");
505
506 mmEntStat.curCmd = AT_CMD_NONE;
507 mmEntStat.entOwn = CMD_SRC_NONE;
508 simEntStat.curCmd = AT_CMD_NONE;
509 simEntStat.entOwn = CMD_SRC_NONE;
510 smsShrdPrm.smsEntStat.curCmd = AT_CMD_NONE;
511 smsShrdPrm.smsEntStat.entOwn = CMD_SRC_NONE;
512
513 #ifdef UART
514 for (index=CMD_SRC_LCL; index<CMD_SRC_MAX; index++)
515 {
516 uartEntcurCmd[index] = AT_CMD_NONE;
517 }
518
519 uartShrdPrm.dtr_behaviour = DTR_BEHAVIOUR_Ignore;
520 uartShrdPrm.dtr_clearcall = FALSE;
521 cmhUART_init_ipr_params();
522 #endif
523
524 #ifdef FF_PSI
525 psiShrdPrm.dtr_behaviour = DTR_BEHAVIOUR_Ignore;
526 psiShrdPrm.dtr_clearcall = FALSE;
527 #endif /*FF_PSI*/
528
529
530 #ifdef FAX_AND_DATA
531 #ifdef FF_FAX
532 t30EntStat.curCmd = AT_CMD_NONE;
533 t30EntStat.entOwn = CMD_SRC_NONE;
534 #endif
535
536 l2rEntStat.curCmd = AT_CMD_NONE;
537 l2rEntStat.entOwn = CMD_SRC_NONE;
538 raEntStat.curCmd = AT_CMD_NONE;
539 raEntStat.entOwn = CMD_SRC_NONE;
540 #endif
541
542 #ifndef _SIMULATION_
543 /* Read status of ALSlock */
544 /* Implements Measure#32: Row 103 */
545 if (FFS_fread (gsm_com_alslock_path,&ALSlock,sizeof(ALSlock)) NEQ sizeof(ALSlock))
546 /* if failed, reset to default */
547 ALSlock = ALS_MOD_NOTPRESENT;
548 else if (ALSlock NEQ ALS_MOD_SPEECH AND ALSlock NEQ ALS_MOD_AUX_SPEECH)
549 /* if unknown value was stored */
550 ALSlock = ALS_MOD_NOTPRESENT;
551 #else
552 ALSlock = ALS_MOD_NOTPRESENT;
553 #endif
554
555 #ifdef GPRS
556 gaci_init();
557 #endif
558
559 #ifdef FF_ATI
560 for( index_cievbuf_size=CMD_SRC_LCL; index_cievbuf_size < CIEV_BUF_SIZE; index_cievbuf_size ++ )
561 {
562
563 asCievSignalBuf.asBufferValues[index_cievbuf_size ] = CIND_SIGNAL_INDICATOR_INVALID;
564 asCievSmsFullBuf.asBufferValues[index_cievbuf_size ] = CIND_SMSFULL_INDICATOR_INVALID;
565
566 }
567
568 asCievSignalBuf.uiLastIndex = 0;
569 asCievSmsFullBuf.uiLastIndex = 0;
570 #endif /* FF_ATI */
571
572 rx_Init(NULL); /* reset the signal strength callback */
573
574 for(percentCSTAT_stateField = 0,index_entiy_id_msg = STATE_MSG_PBOOK;
575 index_entiy_id_msg < STATE_MSG_MAX_ENTITIES; index_entiy_id_msg++)
576 {
577 percentCSTAT_stateField |= 1U << index_entiy_id_msg;
578 }
579
580 }
581
582 /*
583 +-------------------------------------------------------------------+
584 | PROJECT : GSM-PS (6147) MODULE : CMH |
585 | ROUTINE : cmh_Reset |
586 +-------------------------------------------------------------------+
587
588 PURPOSE : Reset the command handler to defaults.
589 */
590
591 /* MACRO: initializer for command parameter */
592 #define INIT_PARM( entity, dest, def )\
593 {cmhPrm[srcId].entity##CmdPrm.dest = def;}
594
595 #ifdef FAX_AND_DATA
596 #define INIT_PARM_FND( entity, dest, def )\
597 {fnd_cmhPrm[srcId].entity##CmdPrm.dest = def;}
598 #endif /* FAX_AND_DATA */
599
600 GLOBAL void cmh_Reset ( T_ACI_CMD_SRC srcId, BOOL atz )
601 {
602 #ifdef FF_ATI
603 UINT uiCount;
604 #endif
605
606 TRACE_EVENT_P1("Parameters reset for source: %d", srcId);
607
608 /* set default parms for command parameters */
609
610 INIT_PARM( cc, CLIRmode, CLIR_MOD_Subscript );
611 INIT_PARM( cc, DCDmode, DCD_DISABLE_AFTER_CALL );
612 INIT_PARM( cc, CSTAtoa.ton, TON_Unknown );
613 INIT_PARM( cc, CSTAtoa.npi, NPI_IsdnTelephony ); /* according to GSM 07.07 description of AT+CSTA */
614 INIT_PARM( cc, CSTAdef, TRUE );
615 INIT_PARM( cc, CHLDmode, CHLD_MOD_NotPresent );
616 INIT_PARM( cc, CCUGidx, CCUG_IDX_0 );
617 INIT_PARM( cc, CCUGinfo, CCUG_INFO_No );
618 INIT_PARM( cc, CCUGmode, CCUG_MOD_DisableTmp );
619 INIT_PARM( cc, mltyCncFlg, 0 );
620 INIT_PARM( cc, mltyDscFlg, 0 );
621
622 /* Check if ALS is locked to a line */
623 if (ALSlock EQ ALS_MOD_NOTPRESENT)
624 {
625 INIT_PARM( cc, ALSmode, ALS_MOD_SPEECH ); /* Use Default line */
626 }
627 else
628 {
629 INIT_PARM( cc, ALSmode, ALSlock ); /* Lock to specific line */
630 }
631
632 INIT_PARM( cc, CTTYmode, CTTY_MOD_Disable );
633
634 INIT_PARM( cc, CSCNcc_mode.CcCSCNModeState, CC_CSCN_MOD_STATE_INVALID ); /* initialize the shared params for %CSCN */
635 INIT_PARM( cc, CSCNcc_mode.CcCSCNModeDirection, CC_CSCN_MOD_DIR_INVALID );
636
637
638 INIT_PARM( mm, COPSfrmt, COPS_FRMT_Long );
639 INIT_PARM( mm, NRGsrvMode, NRG_SVMD_Full );
640 INIT_PARM( mm, NRGregMode, NRG_RGMD_Auto );
641 INIT_PARM( mm, NRGoprFrmt, NRG_FRMT_Long );
642 INIT_PARM( mm, CTZRMode, CTZR_MODE_OFF );
643 INIT_PARM( mm, CSQworkStat, CSQ_Disable );
644
645 INIT_PARM( mm, sIndicationParam.sMmCINDSettings.sCindSignalParam, CIND_SIGNAL_INDICATOR_INVALID ); /* initialize the shared params for %CIND */
646 INIT_PARM( mm, sIndicationParam.sMmCINDSettings.sCindSmsFullParam, CIND_SMSFULL_INDICATOR_INVALID );
647 INIT_PARM( mm, sIndicationParam.sMmCMERSettings.sCmerModeParam, CMER_MODE_INVALID );
648 INIT_PARM( mm, sIndicationParam.sMmCMERSettings.sCmerIndParam, CMER_INDICATOR_INVALID );
649 INIT_PARM( mm, sIndicationParam.sMmCMERSettings.sCmerBfrParam, CMER_BFR_INVALID );
650
651
652
653 /* initalize SS password */
654 /* INIT_PARM( ss, CXXXpwd[0], 0x0 ); */
655 /* Implements Measure#32: Row 105 */
656 strcpy((CHAR *)cmhPrm[srcId].ssCmdPrm.CXXXpwd, ffff_str);
657 INIT_PARM( ss, CXXXnewPwd[0],0x0 );
658 INIT_PARM( ss, mltyTrnFlg, 0 );
659
660 #ifdef TI_PS_FF_AT_P_CMD_CSCN
661 INIT_PARM( ss, CSCNss_mode.SsCSCNModeState, SS_CSCN_MOD_STATE_INVALID ); /* initialize the shared params for %CSCN */
662 INIT_PARM( ss, CSCNss_mode.SsCSCNModeDirection, SS_CSCN_MOD_DIR_INVALID );
663 #endif /* TI_PS_FF_AT_P_CMD_CSCN */
664
665 if (!atz)
666 INIT_PARM( sim, CNUMActRec, 1 );
667
668 INIT_PARM( sim, CPOLfrmt, CPOL_FRMT_Numeric );
669 INIT_PARM( sim, CPOLact, CPOL_ACT_None );
670 INIT_PARM( sim, CPOLidx, NOT_PRESENT_8BIT );
671 INIT_PARM( sim, CPOLidx2, NOT_PRESENT_8BIT );
672 INIT_PARM( sim, CPOLmode, CPOL_MOD_NotPresent );
673
674 INIT_PARM( phb, cmhStor, PB_STOR_Ad );
675 INIT_PARM( phb, phbStor, ADN );
676 INIT_PARM( phb, fndRec, 0 );
677 INIT_PARM( phb, wrtRec, 0 );
678 INIT_PARM( phb, curCmd, AT_CMD_NONE );
679
680 #ifdef FAX_AND_DATA
681 INIT_PARM_FND( l2r, CRLPiws, L2R_K_IWF_MS_DEF );
682 INIT_PARM_FND( l2r, CRLPmws, L2R_K_MS_IWF_DEF );
683 INIT_PARM_FND( l2r, CRLPt1, L2R_T1_DEF );
684 INIT_PARM_FND( l2r, CRLPn2, L2R_N2_DEF );
685 INIT_PARM_FND( l2r, DSdir, DS_DIR_Negotiated );
686 INIT_PARM_FND( l2r, DScomp, DS_COMP_DoNotDisc );
687 INIT_PARM_FND( l2r, DSmaxDict, L2R_P1_DEF );
688 INIT_PARM_FND( l2r, DSmaxStr, L2R_P2_DEF );
689
690 #ifdef FF_FAX
691 cmhT30_InitFAXPrms( srcId );
692 cmhT30_RstNgtPrms();
693 #endif /* FF_FAX */
694 #endif /* FAX_AND_DATA */
695
696 /* only if ATZ */
697 if(atz)
698 {
699 psaCC_init_mtcbearer();
700 }
701
702 #ifdef FF_ATI
703 for( uiCount=0; uiCount < CIEV_BUF_SIZE; uiCount++ )
704 {
705 asCievSignalBuf.asBufferValues[uiCount] = CIND_SIGNAL_INDICATOR_INVALID;
706 asCievSmsFullBuf.asBufferValues[uiCount] = CIND_SMSFULL_INDICATOR_INVALID;
707 }
708 asCievSignalBuf.uiLastIndex = 0;
709 asCievSmsFullBuf.uiLastIndex = 0;
710 #endif /* FF_ATI */
711 rx_Init(NULL); /* reset the signal strength callback */
712 }
713
714 /*
715 +-------------------------------------------------------------------+
716 | PROJECT : GSM-PS (6147) MODULE : CMH |
717 | ROUTINE : cmh_IsVldCmdSrc |
718 +-------------------------------------------------------------------+
719
720 PURPOSE : check for a valid command source.
721
722 */
723
724 GLOBAL BOOL cmh_IsVldCmdSrc ( T_ACI_CMD_SRC srcId )
725 {
726 if( srcId > CMD_SRC_NONE AND srcId < CMD_SRC_MAX )
727
728 return TRUE;
729
730 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
731 return( FALSE );
732 }
733
734 /*
735 +-------------------------------------------------------------------+
736 | PROJECT : GSM-PS (6147) MODULE : CMH |
737 | ROUTINE : qAT_ErrDesc |
738 +-------------------------------------------------------------------+
739
740 PURPOSE : query error description of last error.
741
742 */
743
744 GLOBAL T_ACI_ERR_DESC qAT_ErrDesc ( void )
745 {
746 return( aciErrDesc );
747 }
748
749 /*
750 +-------------------------------------------------------------------+
751 | PROJECT : GSM-PS (6147) MODULE : CMH |
752 | ROUTINE : sAT_end_ussd |
753 +-------------------------------------------------------------------+
754
755 PURPOSE : Give the user the opportunity to end at any time a USSD transaction.
756 */
757
758 GLOBAL T_ACI_RETURN sAT_end_ussd ( T_ACI_CMD_SRC srcId )
759 {
760 UBYTE srcBuf; /* buffers current source of command */
761 SHORT sId;
762
763 TRACE_FUNCTION("sAT_end_ussd( )");
764
765 sId = psaSS_stbFindActSrv( NO_ENTRY );
766
767 if( sId NEQ NO_ENTRY )
768 {
769 if(ssShrdPrm.stb[sId].ussd_operation)
770 {
771 psaSS_EndTrns(sId);
772 ssShrdPrm.stb[sId].ntryUsdFlg = FALSE;
773 ssShrdPrm.stb[sId].ussd_operation = FALSE; /* probably not really necessary */
774 return(AT_CMPL);
775 }
776 if(ssShrdPrm.stb[sId].curCmd EQ ((T_ACI_AT_CMD)KSD_CMD_USSD) OR
777 ssShrdPrm.stb[sId].curCmd EQ AT_CMD_CUSD)
778 {
779 srcBuf = ssShrdPrm.stb[sId].srvOwn;
780 psaSS_EndTrns(sId);
781 ssShrdPrm.stb[sId].ntryUsdFlg = FALSE;
782 ssShrdPrm.stb[sId].ussd_operation = FALSE; /* probably not really necessary */
783 ssShrdPrm.stb[sId].curCmd = AT_CMD_NONE;
784 if( srcBuf NEQ srcId )
785 {
786 R_AT( RAT_CME, (T_ACI_CMD_SRC)srcBuf )
787 ( ssShrdPrm.stb[sId].curCmd, CME_ERR_Unknown );
788 }
789 return( AT_CMPL );
790 }
791 }
792 return( AT_FAIL );
793
794 }
795
796
797 /*
798 +-------------------------------------------------------------------+
799 | PROJECT : GSM-PS (6147) MODULE : CMH |
800 | ROUTINE : sAT_Abort |
801 +-------------------------------------------------------------------+
802
803 PURPOSE : abort command execution for passed command.
804
805 */
806
807 GLOBAL T_ACI_RETURN sAT_Abort ( T_ACI_CMD_SRC srcId,
808 T_ACI_AT_CMD cmd )
809 {
810 UBYTE idx; /* holds call table index */
811 UBYTE srcBuf = 0; /* buffers current source of command */
812 BOOL doneFlg = FALSE; /* flags that an action was done */
813 SHORT ret_val = -1; /* Return value used when AT+COPS is aborted */
814 TRACE_FUNCTION ("sAT_Abort()");
815 /*
816 *-------------------------------------------------------------------
817 * determine if command is abortable
818 *-------------------------------------------------------------------
819 */
820 switch( cmd )
821 {
822 /*
823 *---------------------------------------------------------------
824 * for SIM related commands
825 *---------------------------------------------------------------
826 */
827 case( AT_CMD_CFUN ): /* +CFUN command id */
828 case( AT_CMD_BAND ): /* %BAND command id */
829 case( AT_CMD_CPIN ): /* +CPIN command id */
830 if( simEntStat.curCmd EQ cmd )
831 {
832 TRACE_EVENT("Command abortion for CFUN/CPIN");
833 if( simEntStat.entOwn NEQ srcId )
834 {
835 R_AT( RAT_CME, simEntStat.entOwn )
836 ( cmd, CME_ERR_Unknown );
837 }
838 simEntStat.entOwn = CMD_SRC_NONE;
839 simEntStat.curCmd = AT_CMD_NONE;
840 return( AT_CMPL );
841 }
842 else if( mmEntStat.curCmd EQ cmd ) /* can happen with AT%band */
843 {
844 TRACE_EVENT("Command abortion for %%BAND");
845 if( mmEntStat.entOwn NEQ srcId )
846 {
847 R_AT( RAT_CME, simEntStat.entOwn )
848 ( cmd, CME_ERR_Unknown );
849 }
850 mmEntStat.entOwn = CMD_SRC_NONE;
851 mmEntStat.curCmd = AT_CMD_NONE;
852 return( AT_CMPL );
853 }
854 break;
855
856 /*
857 *---------------------------------------------------------------
858 * for phone book related commands
859 *---------------------------------------------------------------
860 */
861 case( AT_CMD_CPBW ):
862 if (cmhPrm[srcId].phbCmdPrm.curCmd EQ AT_CMD_CPBW)
863 {
864 cmhPrm[srcId].phbCmdPrm.curCmd = AT_CMD_NONE;
865 return (AT_CMPL);
866 }
867 break;
868
869 /*
870 *---------------------------------------------------------------
871 * for MM related commands
872 *---------------------------------------------------------------
873 */
874 case( AT_CMD_COPS ): /* +COPS command id */
875 case( AT_CMD_P_COPS ): /* %COPS command id */
876 case( AT_CMD_NRG ): /* %NRG command id */
877 if( mmEntStat.curCmd EQ cmd )
878 {
879 TRACE_EVENT("Command abortion for COPS/NRG");
880 if( mmEntStat.entOwn NEQ srcId )
881 {
882 R_AT( RAT_CME, mmEntStat.entOwn )
883 ( cmd, CME_ERR_Unknown );
884 }
885 if( (cmd EQ AT_CMD_COPS) OR (cmd EQ AT_CMD_P_COPS) )
886 {
887 mmShrdPrm.regMode = mmShrdPrm.regModeBeforeAbort; /* AT_CMD_COPS aborted, restore regMode and COPSmode */
888 mmShrdPrm.COPSmode = mmShrdPrm.COPSmodeBeforeAbort;
889
890 switch (mmShrdPrm.COPSmode)
891 {
892 case COPS_MOD_Dereg:
893 #if defined (GPRS) AND defined (DTI)
894 mmShrdPrm.nrgCs = GMMREG_DT_COMB;
895 ret_val = psaG_MM_CMD_DEREG ( mmShrdPrm.nrgCs );
896 #else
897 mmShrdPrm.nrgCs = CS_SIM_REM;
898 ret_val = psaMM_DeRegistrate();
899 #endif
900 break;
901
902 case COPS_MOD_Auto:
903 #if defined (GPRS) AND defined (DTI)
904 ret_val = psaG_MM_CMD_REG (); /* register to network */
905 #else
906 ret_val = psaMM_Registrate(); /* register to network */
907 #endif
908 break;
909
910 case COPS_MOD_Man:
911 if( mmShrdPrm.usedPLMN.v_plmn EQ VLD_PLMN )
912 {
913 mmShrdPrm.slctPLMN = mmShrdPrm.usedPLMN;
914 }
915 else
916 {
917 mmShrdPrm.slctPLMN.v_plmn = VLD_PLMN;
918 cmhMM_CnvrtINT2PLMN( 0xFFF,
919 0xFFF,
920 mmShrdPrm.slctPLMN.mcc,
921 mmShrdPrm.slctPLMN.mnc );
922 }
923
924 #if defined (GPRS) AND defined (DTI)
925 ret_val = psaG_MM_CMD_NET_SEL(); /* register to network */
926 #else
927 ret_val = psaMM_NetSel(); /* register to network */
928 #endif
929 break;
930
931 case COPS_MOD_Both:
932 if (mmShrdPrm.regMode EQ MODE_AUTO)
933 {
934 mmShrdPrm.regModeAutoBack = FALSE;
935 #if defined (GPRS) AND defined (DTI)
936 ret_val = psaG_MM_CMD_REG (); /* register to network */
937 #else
938 ret_val = psaMM_Registrate(); /* register to network */
939 #endif
940 }
941 else
942 {
943 mmShrdPrm.regModeAutoBack = TRUE;
944 if( mmShrdPrm.usedPLMN.v_plmn EQ VLD_PLMN )
945 {
946 mmShrdPrm.slctPLMN = mmShrdPrm.usedPLMN;
947 }
948 else
949 {
950 mmShrdPrm.slctPLMN.v_plmn = VLD_PLMN;
951 cmhMM_CnvrtINT2PLMN( 0xFFF,
952 0xFFF,
953 mmShrdPrm.slctPLMN.mcc,
954 mmShrdPrm.slctPLMN.mnc );
955 }
956 }
957 #if defined (GPRS) AND defined (DTI)
958 ret_val = psaG_MM_CMD_NET_SEL(); /* register to network */
959 #else
960 ret_val = psaMM_NetSel(); /* register to network */
961 #endif
962 break;
963 } /* end of switch case */
964
965 if (ret_val < 0)
966 {
967 TRACE_EVENT( "FATAL RETURN in sAT_Abort()" );
968 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Internal );
969 }
970 } /* end of AT_CMD_COPS */
971
972 mmEntStat.entOwn = CMD_SRC_NONE;
973 mmEntStat.curCmd = AT_CMD_NONE;
974 return( AT_CMPL );
975 }
976 break;
977
978 /*
979 *---------------------------------------------------------------
980 * for CC related commands
981 *---------------------------------------------------------------
982 */
983 case( AT_CMD_D ): /* D command id */
984
985 for (idx = 0; idx < MAX_CALL_NR; idx++)
986 {
987 if (ccShrdPrm.ctb[idx] NEQ NULL)
988 {
989 if ((psaCC_ctb(idx)->curCmd EQ cmd AND
990 (psaCC_ctb(idx)->calStat EQ CS_ACT_REQ OR
991 psaCC_ctb(idx)->calStat EQ CS_DSC_REQ))
992 OR
993 (psaCC_ctb(idx)->calStat EQ CS_ACT AND
994 (cmhCC_getcalltype(idx) NEQ VOICE_CALL)))
995 {
996 doneFlg = TRUE;
997 /* Implements Measure 178 */
998 srcBuf = cmh_ClearCall( srcId, AT_CMD_D, idx );
999 }
1000 }
1001 }
1002 if( doneFlg EQ TRUE)
1003 return( AT_EXCT );
1004
1005 /* Implements Measure 34 */
1006 doneFlg = cmh_tstAndUnflagCall( cmd, &srcBuf );
1007
1008 if( doneFlg )
1009 {
1010 if( /*lint -e(644)*/srcBuf NEQ srcId )
1011 {
1012 R_AT( RAT_CME, (T_ACI_CMD_SRC)srcBuf )
1013 ( AT_CMD_D, CME_ERR_Unknown );
1014 }
1015 return( AT_CMPL );
1016 }
1017
1018 for( idx = 0; idx < MAX_SS_NR; idx++ )
1019 {
1020 if( (ssShrdPrm.stb[idx].curCmd EQ ((T_ACI_AT_CMD)KSD_CMD_CB) OR
1021 ssShrdPrm.stb[idx].curCmd EQ ((T_ACI_AT_CMD)KSD_CMD_CF) OR
1022 ssShrdPrm.stb[idx].curCmd EQ ((T_ACI_AT_CMD)KSD_CMD_CW) OR
1023 ssShrdPrm.stb[idx].curCmd EQ ((T_ACI_AT_CMD)KSD_CMD_CL) OR
1024 ssShrdPrm.stb[idx].curCmd EQ ((T_ACI_AT_CMD)KSD_CMD_PWD) OR
1025 ssShrdPrm.stb[idx].curCmd EQ ((T_ACI_AT_CMD)KSD_CMD_USSD) ))
1026 {
1027 srcBuf = ssShrdPrm.stb[idx].srvOwn;
1028 /* PATCH LE 26.06.00 */
1029 /* End transaction in SS */
1030 psaSS_EndTrns(idx);
1031 /* END PATCH LE 26.06.00 */
1032 ssShrdPrm.stb[idx].ntryUsdFlg = FALSE;
1033 ssShrdPrm.stb[idx].curCmd = AT_CMD_NONE;
1034 doneFlg = TRUE;
1035 }
1036 }
1037 if( doneFlg )
1038 {
1039 if( srcBuf NEQ srcId )
1040 {
1041 R_AT( RAT_CME, (T_ACI_CMD_SRC)srcBuf )
1042 ( AT_CMD_D, CME_ERR_Unknown );
1043 }
1044 return( AT_CMPL );
1045 }
1046 break;
1047
1048 case( AT_CMD_A ): /* A command id */
1049
1050 for( idx = 0; idx < MAX_CALL_NR; idx++ )
1051 {
1052 if (ccShrdPrm.ctb[idx] NEQ NULL)
1053 {
1054 if (psaCC_ctb(idx)->curCmd EQ cmd AND
1055 (psaCC_ctb(idx)->calStat EQ CS_ACT_REQ OR
1056 psaCC_ctb(idx)->calStat EQ CS_CPL_REQ OR
1057 psaCC_ctb(idx)->calStat EQ CS_DSC_REQ))
1058 {
1059 doneFlg = TRUE;
1060 /* Implements Measure 178 */
1061 srcBuf = cmh_ClearCall( srcId, AT_CMD_A, idx );
1062 }
1063 }
1064 }
1065 if( doneFlg )
1066 return( AT_EXCT );
1067
1068 /* Implements Measure 34 */
1069 doneFlg = cmh_tstAndUnflagCall( cmd, &srcBuf);
1070
1071 if( doneFlg )
1072 {
1073 if( srcBuf NEQ srcId )
1074 {
1075 R_AT( RAT_CME, (T_ACI_CMD_SRC)srcBuf )
1076 ( AT_CMD_A, CME_ERR_Unknown );
1077 }
1078 return( AT_CMPL );
1079 }
1080 //patch for OMAPS00173631: if there is no call need to answer. just return AT_CMPL
1081 return( AT_CMPL );
1082 break;
1083
1084 case( AT_CMD_Z ): /* Z command id */
1085 case( AT_CMD_CHUP ): /* +CHUP command id */
1086 case( AT_CMD_CHLD ): /* +CHLD command id */
1087 case( AT_CMD_CTFR ): /* +CTFR command id */
1088
1089 for( idx = 0; idx < MAX_CALL_NR; idx++ )
1090 {
1091 if (ccShrdPrm.ctb[idx] NEQ NULL AND
1092 psaCC_ctb(idx)->curCmd EQ cmd)
1093 {
1094 srcBuf = psaCC_ctb(idx)->curSrc;
1095
1096 cmhCC_tstAndUnflagCall( idx, &cmhPrm[srcBuf].ccCmdPrm.mltyCncFlg );
1097 cmhCC_tstAndUnflagCall( idx, &cmhPrm[srcBuf].ccCmdPrm.mltyDscFlg );
1098
1099 psaCC_ctb(idx)->curCmd = AT_CMD_NONE;
1100 psaCC_ctb(idx)->curSrc = CMD_SRC_NONE;
1101 doneFlg = TRUE;
1102 }
1103 }
1104 if( doneFlg )
1105 {
1106 if( /*lint -e(644)*/srcBuf NEQ srcId )
1107 {
1108 R_AT( RAT_CME, (T_ACI_CMD_SRC)srcBuf )
1109 ( cmd, CME_ERR_Unknown );
1110 }
1111 return( AT_CMPL );
1112 }
1113 break;
1114
1115 case( AT_CMD_VTS ): /* +VTS command id */
1116
1117 for( idx = 0; idx < MAX_CALL_NR; idx++ )
1118 {
1119 if (ccShrdPrm.ctb[idx] NEQ NULL AND
1120 psaCC_ctb(idx)->dtmfCmd EQ cmd)
1121 {
1122 if (psaCC_ctb(idx)->dtmfMode NEQ MNCC_DTMF_MOD_AUTO) /* DTMF in Auto Mode is not abortable
1123 since the tone is always immediately stopped
1124 after the network confirmed the tone to CC. So
1125 it makes absolut no sense to abort the VTS nor
1126 does this have any effect on the length of the tone. */
1127 {
1128 srcBuf = psaCC_ctb(idx)->dtmfSrc;
1129 psaCC_ctb(idx)->dtmfCmd = AT_CMD_NONE;
1130 psaCC_ctb(idx)->dtmfSrc = (T_OWN)CMD_SRC_NONE;
1131 sAT_PlusVTS( srcId, ccShrdPrm.dtmf.dig[0], VTS_MOD_ManStop );
1132 doneFlg = TRUE;
1133 }
1134 }
1135 }
1136 if( doneFlg )
1137 {
1138 if( srcBuf NEQ srcId )
1139 {
1140 R_AT( RAT_CME,(T_ACI_CMD_SRC)srcBuf )
1141 ( AT_CMD_VTS, CME_ERR_Unknown );
1142 }
1143 return( AT_CMPL );
1144 }
1145
1146 break;
1147
1148 /*
1149 *---------------------------------------------------------------
1150 * for SS related commands
1151 *---------------------------------------------------------------
1152 */
1153 case( AT_CMD_CLIR ): /* +CLIR command id */
1154 case( AT_CMD_CLIP ): /* +CLIP command id */
1155 case( AT_CMD_COLP ): /* +COLP command id */
1156 case( AT_CMD_CCFC ): /* +CCFC command id */
1157 case( AT_CMD_CLCK ): /* +CLCK command id */
1158 case( AT_CMD_CCWA ): /* +CCWA command id */
1159 case( AT_CMD_CPWD ): /* +CPWD command id */
1160 case( AT_CMD_CUSD ): /* +CUSD command id */
1161
1162 for( idx = 0; idx < MAX_SS_NR; idx++ )
1163 {
1164 if( ssShrdPrm.stb[idx].curCmd EQ cmd )
1165 {
1166 srcBuf = ssShrdPrm.stb[idx].srvOwn;
1167 psaSS_EndTrns(idx);
1168 cmhPrm[srcId].ssCmdPrm.mltyTrnFlg = 0;
1169 ssShrdPrm.stb[idx].ntryUsdFlg = FALSE;
1170 ssShrdPrm.stb[idx].curCmd = AT_CMD_NONE;
1171 doneFlg = TRUE;
1172 }
1173 }
1174 if( simEntStat.curCmd EQ AT_CMD_CLCK )
1175 {
1176 simEntStat.curCmd = AT_CMD_NONE;
1177 doneFlg = TRUE;
1178 }
1179 if( doneFlg )
1180 {
1181 if( srcBuf NEQ srcId )
1182 {
1183 R_AT( RAT_CME, (T_ACI_CMD_SRC)srcBuf )
1184 ( cmd, CME_ERR_Unknown );
1185 }
1186 return( AT_CMPL );
1187 }
1188 break; /* SS not implemented */
1189
1190 /*
1191 *---------------------------------------------------------------
1192 * for SMS related commands
1193 *---------------------------------------------------------------
1194 */
1195 case( AT_CMD_CMGD ): /* +CMGD command id */
1196 case( AT_CMD_CMGW ): /* +CMGW command id */
1197 case( AT_CMD_CMGS ): /* +CMGS command id */
1198 case( AT_CMD_CMSS ): /* +CMSS command id */
1199 case( AT_CMD_CSMP ): /* +CSMP command id */
1200 case( AT_CMD_CSCA ): /* +CSCA command id */
1201
1202 if( smsShrdPrm.smsEntStat.curCmd EQ cmd )
1203 {
1204 if( smsShrdPrm.smsEntStat.entOwn NEQ srcId )
1205 {
1206 R_AT( RAT_CMS, smsShrdPrm.smsEntStat.entOwn )
1207 ( cmd, CMS_ERR_UnknownErr, NULL );
1208 }
1209
1210 smsShrdPrm.smsEntStat.entOwn = CMD_SRC_NONE;
1211 smsShrdPrm.smsEntStat.curCmd = AT_CMD_NONE;
1212 return( AT_CMPL );
1213 }
1214
1215 break;
1216
1217 #ifdef GPRS
1218 /* brz:to check
1219 *---------------------------------------------------------------
1220 * for GMM related commands
1221 *---------------------------------------------------------------
1222 */
1223 case( AT_CMD_CGATT ): /* +CGATT command id */
1224 case( AT_CMD_CGCLASS ): /* +CGCLASS command id */
1225 if( gmmEntStat.curCmd EQ cmd )
1226 {
1227 TRACE_EVENT("Command abortion for CGATT/CGCLASS/CGAUTO");
1228 if( gmmEntStat.entOwn NEQ srcId )
1229 {
1230 R_AT( RAT_CME, gmmEntStat.entOwn )
1231 ( cmd, CME_ERR_Unknown );
1232 }
1233 gmmEntStat.entOwn = CMD_SRC_NONE;
1234 gmmEntStat.curCmd = AT_CMD_NONE;
1235 return( AT_CMPL );
1236 }
1237
1238 break;
1239 /*
1240 *---------------------------------------------------------------
1241 * for SM related commands
1242 *---------------------------------------------------------------
1243 */
1244 case( AT_CMD_CGACT ): /* +CGACT command id */
1245 case( AT_CMD_CGDATA ): /* +CGDATA command id */
1246 if( gpppEntStat.curCmd EQ cmd OR
1247 smEntStat.curCmd EQ cmd )
1248 {
1249 TRACE_EVENT("Command abortion for CGDATA or CGACT");
1250 if( gpppEntStat.entOwn NEQ srcId AND
1251 smEntStat.entOwn NEQ srcId )
1252 {
1253 R_AT( RAT_CME, gpppEntStat.entOwn )
1254 ( cmd, CME_ERR_Unknown );
1255 }
1256
1257 /*
1258 * Deactivate all the activated contexts in the work cid list. Starting from the one
1259 * that is currently being activated. The work_cids array is reversed.
1260 */
1261 {
1262 U8 i, temp_work_cids[PDP_CONTEXT_CID_MAX + 1];
1263 memset(temp_work_cids, INVALID_CID, sizeof(temp_work_cids));
1264 for (i=0; i<=cid_pointer; i++)
1265 temp_work_cids[cid_pointer - i] = work_cids[i];
1266 memcpy(work_cids, temp_work_cids, sizeof(work_cids));
1267 cid_pointer = 0;
1268 }
1269 smEntStat.curCmd = AT_CMD_NONE;
1270 gpppEntStat.curCmd = AT_CMD_NONE;
1271 /*
1272 * Fake that the current command is +CGACT=0
1273 */
1274 return cmhSM_deactivateAContext(srcId, work_cids[cid_pointer] );
1275 }
1276 break;
1277
1278 case( AT_CMD_CGANS ): /* +CGANS command id */
1279
1280 if( smEntStat.curCmd EQ cmd )
1281 {
1282 TRACE_EVENT("Command abortion for CGANS");
1283 if( smEntStat.entOwn NEQ srcId )
1284 {
1285 R_AT( RAT_CME, smEntStat.entOwn )
1286 ( cmd, CME_ERR_Unknown );
1287 }
1288 smEntStat.entOwn = CMD_SRC_NONE;
1289 smEntStat.curCmd = AT_CMD_NONE;
1290 doneFlg = TRUE;
1291 }
1292
1293 if( gpppEntStat.curCmd EQ cmd )
1294 {
1295 if( gpppEntStat.entOwn NEQ srcId )
1296 {
1297 R_AT( RAT_CME, gpppEntStat.entOwn )
1298 ( cmd, CME_ERR_Unknown );
1299 }
1300 gpppEntStat.entOwn = CMD_SRC_NONE;
1301 gpppEntStat.curCmd = AT_CMD_NONE;
1302 return( AT_EXCT );
1303 }
1304
1305 if( doneFlg EQ TRUE )
1306 return( AT_EXCT );
1307 break;
1308
1309 case( AT_CMD_CGSMS ): /* +CGSMS command id */
1310 if( smEntStat.curCmd EQ cmd )
1311 {
1312 TRACE_EVENT("Command abortion for CGSMS");
1313 if( smEntStat.entOwn NEQ srcId )
1314 {
1315 R_AT( RAT_CME, smEntStat.entOwn )
1316 ( cmd, CME_ERR_Unknown );
1317 }
1318 smEntStat.entOwn = CMD_SRC_NONE;
1319 smEntStat.curCmd = AT_CMD_NONE;
1320 }
1321 return AT_CMPL;
1322 /*
1323 *---------------------------------------------------------------
1324 * for SM related UMTS commands
1325 *---------------------------------------------------------------
1326 */
1327 #ifdef REL99
1328 case( AT_CMD_CGCMOD ): /* +CGCMOD command id */
1329 if( smEntStat.curCmd EQ cmd )
1330 {
1331 TRACE_EVENT("Command abortion for CGCMOD");
1332 if( smEntStat.entOwn NEQ srcId )
1333 {
1334 R_AT( RAT_CME, smEntStat.entOwn )
1335 ( cmd, CME_ERR_Unknown );
1336 }
1337 switch(get_state_working_cid())
1338 {
1339 case PDP_CONTEXT_STATE_ACTIVATED_MODIFYING:
1340 /* Reset the state and remove the command. CmhSM will ignore any SMREG_PDP_MODIFY_CNF */
1341 set_state_working_cid( PDP_CONTEXT_STATE_ACTIVATED );
1342 smEntStat.entOwn = CMD_SRC_NONE;
1343 smEntStat.curCmd = AT_CMD_NONE;
1344 work_cids[0] = PDP_CONTEXT_CID_INVALID;
1345 cid_pointer = PDP_CONTEXT_CID_OMITTED;
1346 break;
1347
1348 case PDP_CONTEXT_STATE_DATA_LINK_MODIFYING:
1349 /* Reset the state and remove the command. CmhSM will ignore any SMREG_PDP_MODIFY_CNF */
1350 set_state_working_cid( PDP_CONTEXT_STATE_DATA_LINK );
1351 smEntStat.entOwn = CMD_SRC_NONE;
1352 smEntStat.curCmd = AT_CMD_NONE;
1353 work_cids[0] = PDP_CONTEXT_CID_INVALID;
1354 cid_pointer = PDP_CONTEXT_CID_OMITTED;
1355 break;
1356
1357 default:
1358 return( AT_FAIL );
1359 }
1360 return( AT_CMPL );
1361 }
1362 #endif /* REL99 */
1363
1364 #endif /*GPRS*/
1365
1366 }
1367
1368 return( AT_FAIL );
1369 }
1370
1371 /*
1372 +-------------------------------------------------------------------+
1373 | PROJECT : GSM-PS (6147) MODULE : CMH_F |
1374 | ROUTINE : cmh_mergeTOA |
1375 +-------------------------------------------------------------------+
1376
1377 PURPOSE : this function converts the type of number (TON) and the
1378 numbering plan identification into the octet representation
1379 according to GSM 04.08 ( 10.5.4.7 ).
1380 */
1381
1382 GLOBAL UBYTE cmh_mergeTOA ( UBYTE ton, UBYTE npi )
1383 {
1384
1385 /*
1386 *-------------------------------------------------------------------
1387 * convert TON and NPI
1388 *-------------------------------------------------------------------
1389 */
1390 return( ((ton & 0x07)<<4)+
1391 ((npi & 0x0F)<<0)+0x80 );
1392
1393 }
1394
1395 /*
1396 +-------------------------------------------------------------------+
1397 | PROJECT : GSM-PS (6147) MODULE : CMH_F |
1398 | ROUTINE : cmh_mergeTOS |
1399 +-------------------------------------------------------------------+
1400
1401 PURPOSE : this function converts the type of subaddress (TOS) and the
1402 odd/even indicator into the octet representation
1403 according to GSM 04.08 ( 10.5.4.8 ).
1404
1405 */
1406
1407 GLOBAL UBYTE cmh_mergeTOS ( UBYTE tos, UBYTE oe )
1408 {
1409
1410 /*
1411 *-------------------------------------------------------------------
1412 * convert TOS and odd/even
1413 *-------------------------------------------------------------------
1414 */
1415 return( ((tos & 0x07)<<4)+
1416 ((oe & 0x01)<<3)+0x80 );
1417 }
1418
1419 /*
1420 +-------------------------------------------------------------------+
1421 | PROJECT : GSM-PS (6147) MODULE : CMH_F |
1422 | ROUTINE : cmh_demergeTOA |
1423 +-------------------------------------------------------------------+
1424
1425 PURPOSE : this function converts the the octet representation
1426 according to GSM 04.08 ( 10.5.4.7 ) into type of number
1427 (TON) and the numbering plan identification.
1428 */
1429
1430 GLOBAL void cmh_demergeTOA ( UBYTE toa, UBYTE* ton, UBYTE* npi )
1431 {
1432
1433 /*
1434 *-------------------------------------------------------------------
1435 * convert TON and NPI
1436 *-------------------------------------------------------------------
1437 */
1438 *ton = (toa>>4) & 0x07;
1439 *npi = (toa>>0) & 0x0F;
1440 }
1441
1442 /*
1443 +-------------------------------------------------------------------+
1444 | PROJECT : GSM-PS (6147) MODULE : CMH_F |
1445 | ROUTINE : cmh_demergeTOS |
1446 +-------------------------------------------------------------------+
1447
1448 PURPOSE : this function converts the octet representation
1449 according to GSM 04.08 ( 10.5.4.8 ) into the type of
1450 subaddress (TOS) and the odd/even indicator.
1451
1452 */
1453
1454 GLOBAL void cmh_demergeTOS ( UBYTE tosa, UBYTE* tos, UBYTE* oe )
1455 {
1456
1457 /*
1458 *-------------------------------------------------------------------
1459 * convert TOS and odd/even
1460 *-------------------------------------------------------------------
1461 */
1462 *tos = (tosa>>4) & 0x07;
1463 *oe = (tosa>>3) & 0x01;
1464 }
1465
1466
1467
1468 /*
1469 +--------------------------------------------------------------------+
1470 | PROJECT : GSM-PS (6147) MODULE : CMH_F |
1471 | STATE : code ROUTINE : cmh_setToaDef |
1472 +--------------------------------------------------------------------+
1473
1474 PURPOSE : This function sets the type of address to default values
1475 (when the first character of address is '+' or the first
1476 two characters are '0' default is 145 otherwise default
1477 is 129)
1478 */
1479 GLOBAL CHAR* cmh_setToaDef ( CHAR* number, T_ACI_TOA *toa )
1480 {
1481 toa->npi = NPI_IsdnTelephony;
1482
1483 if ( *number EQ '+' )
1484 {
1485 toa->ton = TON_International;
1486 return number+1;
1487 }
1488 else
1489 {
1490 toa->ton = TON_Unknown;
1491 return number;
1492 }
1493 }
1494
1495
1496
1497
1498 /*
1499 +-------------------------------------------------------------------+
1500 | PROJECT : GSM-PS (6147) MODULE : CMH_F |
1501 | ROUTINE : cmh_packBCD |
1502 +-------------------------------------------------------------------+
1503
1504 PURPOSE : packing two BCD values in one octet
1505 <bcd_out> resulting packed BCD numbers
1506 <char_in> BCD values input per character
1507 <len_in> number of BCD values to be packed
1508 RETURN : number of packed octets
1509 */
1510
1511 GLOBAL USHORT cmh_packBCD (UBYTE *bcd_out, const UBYTE *char_in,
1512 USHORT len_in)
1513 {
1514 USHORT no_oct = 0, i;
1515
1516 if (len_in > MAX_SMS_ADDR_DIG) /* check length */
1517 len_in = MAX_SMS_ADDR_DIG;
1518
1519 for (i = 0; i < len_in; i++)
1520 {
1521 if ((i & 1) EQ 0) /* pack high nibble */
1522 {
1523 no_oct++;
1524 *bcd_out = *char_in++ | 0xF0; /* in case of odd length */
1525 }
1526 else /* pack low nibble */
1527 *bcd_out++ &= (*char_in++ << 4) | 0xF;
1528 }
1529 return no_oct;
1530 }
1531
1532 /*
1533 +-------------------------------------------------------------------+
1534 | PROJECT : GSM-PS (6147) MODULE : CMH_F |
1535 | ROUTINE : cmh_unpackBCD |
1536 +-------------------------------------------------------------------+
1537
1538 PURPOSE : unpacking one octet in two BCD values
1539 <char_out> resulting unpacked BCD values
1540 <bcd_in> BCD numbers input
1541 <len_in> number of octets to be unpacked
1542 RETURN : number of unpacked BCD values
1543 */
1544
1545 GLOBAL USHORT cmh_unpackBCD (UBYTE *char_out, const UBYTE *bcd_in,
1546 USHORT len_in)
1547 {
1548 USHORT no_bcd = 0, i;
1549
1550 if (len_in > MAX_SMS_ADDR_DIG/2) /* check length */
1551 len_in = MAX_SMS_ADDR_DIG/2;
1552
1553 for (i = 0; i < len_in; i++)
1554 {
1555 if ((*bcd_in & 0xF) NEQ 0xF) /* in case of wrong length */
1556 {
1557 *char_out++ = *bcd_in & 0xF; /* unpack low nibble */
1558 no_bcd++;
1559 }
1560 else
1561 break;
1562 if ((*bcd_in & 0xF0) NEQ 0xF0) /* in case of odd length */
1563 {
1564 *char_out++ = *bcd_in++ >> 4; /* unpack high nibble */
1565 no_bcd++;
1566 }
1567 else
1568 break;
1569 }
1570 return no_bcd;
1571 }
1572
1573 /*
1574 +-------------------------------------------------------------------+
1575 | PROJECT : GSM-PS (6147) MODULE : CMH_F |
1576 | ROUTINE : cmh_unpackSCTS |
1577 +-------------------------------------------------------------------+
1578
1579 PURPOSE : unpacking SCTS (or validity period absolute) to the
1580 T_ACI_VP_ABS structure
1581 */
1582 GLOBAL void cmh_unpackSCTS (T_ACI_VP_ABS *scts, const UBYTE *buf_in)
1583 {
1584
1585 UBYTE lsb, msb, sign;
1586
1587 cmh_unpackBCD ((UBYTE*)scts, buf_in, 6);
1588
1589 /* get the time zone octet */
1590 buf_in += 6;
1591
1592 lsb = *buf_in >> 4;
1593 msb = *buf_in & 0x07;
1594 scts->timezone = (msb *10) + lsb; /* BCD */
1595 sign = *buf_in & 0x08;
1596 if (sign)
1597 scts->timezone = -scts->timezone; /* ~scts->timezone + 1; */
1598 }
1599
1600 /*
1601 +-------------------------------------------------------------------+
1602 | PROJECT : GSM-PS (6147) MODULE : CMH_F |
1603 | ROUTINE : cmh_logRslt |
1604 +-------------------------------------------------------------------+
1605
1606 PURPOSE : log result code.
1607
1608 */
1609
1610 GLOBAL void cmh_logRslt ( T_ACI_CMD_SRC dest, RAT_ID rat,
1611 T_ACI_AT_CMD cmd, SHORT cId,
1612 T_ACI_BS_SPEED spd, T_ACI_CME_ERR err )
1613 {
1614 #if defined SMI OR defined MFW OR defined FF_MMI_RIV
1615 T_ACI_RLOG rslt; /* holds result pararmeter */
1616
1617 rslt.dest = dest;
1618
1619 switch( rat )
1620 {
1621 case( RAT_OK ):
1622
1623 rslt.atRslt = RLOG_RSLT_OK;
1624 rslt.rsltPrm.rOK.cmdId = cmd;
1625 rslt.rsltPrm.rOK.cId = cId;
1626 break;
1627
1628 case( RAT_NO_CARRIER ):
1629
1630 rslt.atRslt = RLOG_RSLT_NoCarrier;
1631 rslt.rsltPrm.rNO_CARRIER.cmdId = cmd;
1632 rslt.rsltPrm.rNO_CARRIER.cId = cId;
1633 break;
1634
1635 case( RAT_CONNECT ):
1636
1637 rslt.atRslt = RLOG_RSLT_Connect;
1638 rslt.rsltPrm.rCONNECT.cmdId = cmd;
1639 rslt.rsltPrm.rCONNECT.cId = cId;
1640 rslt.rsltPrm.rCONNECT.speed = spd;
1641 break;
1642
1643 case( RAT_BUSY ):
1644
1645 rslt.atRslt = RLOG_RSLT_Busy;
1646 rslt.rsltPrm.rBUSY.cmdId = cmd;
1647 rslt.rsltPrm.rBUSY.cId = cId;
1648 break;
1649
1650 case( RAT_NO_ANSWER ):
1651
1652 rslt.atRslt = RLOG_RSLT_NoAnswer;
1653 rslt.rsltPrm.rNO_ANSWER.cmdId = cmd;
1654 rslt.rsltPrm.rNO_ANSWER.cId = cId;
1655 break;
1656
1657 case( RAT_CME ):
1658
1659 rslt.atRslt = RLOG_RSLT_CME;
1660 rslt.rsltPrm.rCME.cmdId = cmd;
1661 rslt.rsltPrm.rCME.err = err;
1662 rslt.rsltPrm.rCME.cId = cId;
1663 break;
1664
1665 default:
1666
1667 return;
1668 }
1669
1670 rAT_PercentRLOG( &rslt );
1671 #endif
1672 }
1673
1674 /*
1675 +-------------------------------------------------------------------+
1676 | PROJECT : GSM-PS (6147) MODULE : CMH_F |
1677 | ROUTINE : cmh_cvtToDefGsm |
1678 +-------------------------------------------------------------------+
1679
1680 PURPOSE : converts from internal GSM to default GSM alphabet.
1681
1682 */
1683 GLOBAL void cmh_cvtToDefGsm ( CHAR* in, CHAR* out, USHORT* len )
1684 {
1685 USHORT i; /* used for counting */
1686
1687 *len = ( USHORT ) strlen ( in );
1688
1689 for ( i = 0; i < *len; i++ )
1690 out[i] = in[i] & 0x7F;
1691 }
1692
1693 /*
1694 +-------------------------------------------------------------------+
1695 | PROJECT : GSM-PS (6147) MODULE : CMH_F |
1696 | ROUTINE : cmh_cvtFromDefGsm |
1697 +-------------------------------------------------------------------+
1698
1699 PURPOSE : converts from default GSM to internal GSM alphabet.
1700
1701 */
1702 GLOBAL void cmh_cvtFromDefGsm ( CHAR* in, USHORT len, CHAR* out )
1703 {
1704 USHORT i; /* used for counting */
1705
1706 for ( i = 0; i < len; i++ )
1707 out[i] = in[i] | 0x80;
1708
1709 out[len] = '\0';
1710 }
1711
1712 /*
1713 +--------------------------------------------------------------------+
1714 | PROJECT: GSM-PS (6147) MODULE: ACI_CMD |
1715 | STATE : code ROUTINE: cmh_set_delayed_call|
1716 +--------------------------------------------------------------------+
1717
1718 PURPOSE : Set function pointer for general-purpose timer routine.
1719 TRUE, if delayed call timer slot is available
1720 FALSE otherwise
1721 setting call=NULL always succeeds.
1722 */
1723 static UCHAR (*cmh_timeout_delayed_call) (void*) = NULL;
1724 static void* cmh_timeout_delayed_arg = NULL;
1725
1726 GLOBAL UBYTE cmh_set_delayed_call (UCHAR (*call) (void*), void* arg)
1727 {
1728 UCHAR ret;
1729 if (cmh_timeout_delayed_call EQ NULL
1730 OR cmh_timeout_delayed_call EQ call
1731 OR call EQ NULL)
1732 {
1733 cmh_timeout_delayed_call = call;
1734 cmh_timeout_delayed_arg = arg;
1735 ret = TRUE;
1736 }
1737 else ret = FALSE;
1738 return ret;
1739 }
1740
1741 /*
1742 +--------------------------------------------------------------------+
1743 | PROJECT: GSM-PS (6147) MODULE: ACI_CMD |
1744 | STATE : code ROUTINE: cmh_set_delayed_call|
1745 +--------------------------------------------------------------------+
1746
1747 PURPOSE : start timer for general-purpose timer routine.
1748 TRUE, if delayed call timer slot has been set before
1749 */
1750
1751 GLOBAL UBYTE cmh_start_delayed_call (ULONG ms)
1752 {
1753 UBYTE ret;
1754 if (cmh_timeout_delayed_call NEQ NULL) {
1755 TRACE_FUNCTION ("cmh_start_delayed_call()");
1756 vsi_t_start (hCommACI, ACI_TDELAY, ms);
1757 ret = TRUE;
1758 } else ret = FALSE;
1759 return ret;
1760 }
1761
1762 /*
1763 +--------------------------------------------------------------------+
1764 | PROJECT: GSM-PS (6147) MODULE: ACI_CMD |
1765 | STATE : code ROUTINE: cmh_timeout |
1766 +--------------------------------------------------------------------+
1767
1768 PURPOSE : A timeout has occured for a timer. The function returns
1769 TRUE, if it is a timer which is handled by CMH, else FALSE
1770 is returned to indicate that the timer has not been
1771 processed.
1772
1773 */
1774
1775 GLOBAL UBYTE cmh_timeout (USHORT index)
1776 {
1777 TRACE_FUNCTION ("cmh_timeout()");
1778
1779 if (index EQ ACI_TMPTY)
1780 {
1781 /*
1782 * timeout multiparty timer
1783 */
1784 cmhCC_MPTYTimeout();
1785 return TRUE;
1786 }
1787
1788 if (index EQ ACI_TECT)
1789 {
1790 /*
1791 * timeout multiparty timer
1792 */
1793 cmhCC_ECTTimeout();
1794 return TRUE;
1795 }
1796
1797 #ifdef FF_FAX
1798 if (index EQ ACI_TFIT)
1799 {
1800 /*
1801 * timeout FAX inactivity timer
1802 */
1803 cmhT30_FITTimeout();
1804 return TRUE;
1805 }
1806 #endif /* FF_FAX */
1807
1808 if (index EQ ACI_TDELAY)
1809 {
1810 /*
1811 * timeout delayed call timer
1812 */
1813 if (cmh_timeout_delayed_call EQ NULL)
1814 {
1815 vsi_t_stop (hCommACI, ACI_TDELAY);
1816 }
1817 else if (!cmh_timeout_delayed_call (cmh_timeout_delayed_arg))
1818 {
1819 cmh_timeout_delayed_call = NULL;
1820 vsi_t_stop (hCommACI, ACI_TDELAY);
1821 }
1822 return TRUE;
1823 }
1824
1825 if (index EQ ACI_REPEAT_HND)
1826 {
1827 /* redial timer is elapsed */
1828 cmhCC_redialTimeout();
1829 }
1830
1831 #ifdef SIM_TOOLKIT
1832 if(index EQ ACI_SAT_MAX_DUR_HND)
1833 {
1834 /* SAT max redialling duration elapsed */
1835 cmhCC_satTimeout();
1836 }
1837 #endif /* SIM_TOOLKIT */
1838
1839 #ifdef SIM_PERS
1840 if(index EQ ACI_UNLOCK_TIMER_HANDLE)
1841 {
1842 cmhSIM_UnlockTimeout();
1843 return TRUE;
1844 }
1845 #endif
1846
1847 /*
1848 * the timeout is not for CMH
1849 */
1850 return FALSE;
1851 }
1852
1853 /*
1854 +-------------------------------------------------------------------+
1855 | PROJECT : GSM-PS (6147) MODULE : CMH_F |
1856 | ROUTINE : cmh_bldCalPrms |
1857 +-------------------------------------------------------------------+
1858
1859 PURPOSE : this function converts a dial string into the settings
1860 for the called address parameters.
1861 */
1862
1863 /*******************************************
1864 This function is intended only to be called ONCE
1865 for a given number...
1866 Otherwise, TOA info might be corrupted
1867 ********************************************/
1868 GLOBAL SHORT cmh_bldCalPrms ( char * pDialStr, T_CLPTY_PRM * calPrm )
1869 {
1870 char * pSubAdr; /* points to subaddress */
1871 int i;
1872 int len = strlen(pDialStr);
1873
1874 TRACE_FUNCTION("cmh_bldCalPrms()");
1875
1876 /* seach for subaddress */
1877 pSubAdr = strchr( pDialStr, '-' );
1878 if ( pSubAdr NEQ NULL ) /* subaddress found */
1879 {
1880 *pSubAdr = 0x0; /* cut off subaddress */
1881 pSubAdr++;
1882
1883 /*
1884 * fill in subaddress information
1885 */
1886 calPrm -> tos = MNCC_TOS_NSAP;
1887 strncpy( calPrm->sub, pSubAdr, MAX_SUBADDR_LEN-1 );
1888 calPrm->sub[MAX_SUBADDR_LEN-1] = 0x0;
1889 calPrm -> oe = (strlen(calPrm->sub) & 1)? MNCC_OE_ODD : MNCC_OE_EVEN;
1890 }
1891 else /* subaddress not found */
1892 {
1893 calPrm -> tos = MNCC_TOS_NOT_PRES;
1894 calPrm -> oe = MNCC_OE_EVEN;
1895 calPrm->sub[0] = 0x0;
1896 }
1897
1898 /* fill in address information */
1899
1900 /* Sign "+" could be found anywhere in the string:
1901 for instance in a Key Stroke Sequence */
1902
1903 /* Copy character until '+' digit */
1904 for (i = 0; (i < len) AND (pDialStr[i] NEQ '+'); i++)
1905 calPrm->num[i] = pDialStr[i];
1906
1907 if (i NEQ len)
1908 {
1909 calPrm->ton = MNCC_TON_INT_NUMB;
1910
1911 /* Skip '+' digit and copy next characters */
1912 for (i++; i < len; i++)
1913 calPrm->num[i-1] = pDialStr[i];
1914 i--;
1915 }
1916 else
1917 calPrm->ton = MNCC_TON_UNKNOWN;
1918
1919 /* Copy EOS */
1920 calPrm->num[i] = '\0';
1921
1922 calPrm -> npi = MNCC_NPI_ISDN_TEL_NUMB_PLAN;
1923
1924 return 0;
1925 }
1926
1927 /*
1928 +-------------------------------------------------------------------+
1929 | PROJECT : GSM-PS (6147) MODULE : CMH_F |
1930 | ROUTINE : percentCSTAT_stateField |
1931 +-------------------------------------------------------------------+
1932
1933 PURPOSE : This function calls the %CSTAT callback and
1934 handels the occurance of %CSTAT and
1935 %CSTAT: RDY indication.
1936 */
1937 GLOBAL void percentCSTAT_indication(T_ACI_ENTITY_ID_MSG entityId,
1938 T_ACI_ENTITY_STATE_MSG entityState)
1939 {
1940 T_ACI_STATE_MSG msgType;
1941 int i = 0;
1942 msgType.entityId = entityId;
1943 msgType.entityState = entityState;
1944
1945 TRACE_FUNCTION("percentCSTAT_indication");
1946
1947 /* ! EONS ready does not impact %CSTAT: RDY ! */
1948 if (entityId EQ STATE_MSG_EONS)
1949 {
1950 entityState = ENTITY_STATUS_Ready;
1951 }
1952
1953 /* Ready indication should be sent only once for all the entities */
1954
1955 if( (percentCSTAT_stateField >> entityId & 1U) EQ (unsigned) entityState )
1956 {
1957 for(; i < CMD_SRC_MAX; i++)
1958 {
1959 R_AT( RAT_CSTAT, (T_ACI_CMD_SRC)i)(msgType);
1960 }
1961 percentCSTAT_stateField ^= 1U << entityId;
1962
1963 if(!percentCSTAT_stateField)
1964 {
1965 msgType.entityId = STATE_MSG_RDY;
1966 for(i = 0; i < CMD_SRC_MAX; i++)
1967 {
1968 R_AT( RAT_CSTAT, (T_ACI_CMD_SRC)i)(msgType);
1969 }
1970 }
1971 }
1972 }
1973
1974
1975
1976 /* New Function Replacing Macro-code */
1977 /*
1978 +-------------------------------------------------------------------+
1979 | PROJECT : GSM-PS (6147) MODULE : CMH |
1980 | ROUTINE : aci_get_cb_cmd |
1981 +-------------------------------------------------------------------+
1982
1983 PURPOSE : check for valid srcId and return rAT function pointer.
1984
1985 */
1986
1987 GLOBAL BOOL aci_get_cb_cmd (RAT_ID cmd, T_ACI_CMD_SRC src)
1988 {
1989 T_ACI_CMD_MODE mode;
1990
1991 TRACE_FUNCTION ("aci_get_cb_cmd()");
1992
1993 if (src > CMD_SRC_LCL)
1994 {
1995 srcId_cb = (U8)src;
1996 }
1997
1998 if (src NEQ CMD_SRC_NONE AND src<CMD_SRC_MAX AND IS_SRC_USED(src))
1999 {
2000 // Get the command mode for the specified source.
2001 mode = aci_cmd_src_mode_get(src);
2002
2003 /*
2004 * If RATJmpTbl is populated for the specified command mode
2005 * and command, indicate this by returning the command mode.
2006 * The nature of the R_AT macro is such that it is not possible
2007 * to simply call the function in the table from here.
2008 */
2009
2010 if (mode NEQ CMD_MODE_NONE AND RATJmpTbl[cmd][mode])
2011 {
2012 rat_fptr = RATJmpTbl[cmd][mode];
2013 return (TRUE);
2014 }
2015 TRACE_EVENT_P2("RATJmpTbl[cmd=%d][mode=%d]", cmd, mode);
2016 }
2017
2018 /*
2019 * A return value of FALSE is meant to indicate that the
2020 * response should not be sent at all.
2021 */
2022
2023 TRACE_EVENT_P1("aci_get_cb_cmd(): CMD_MODE_NONE for src %d", src);
2024 return(FALSE);
2025 }
2026
2027
2028 /*
2029 +-------------------------------------------------------------------+
2030 | PROJECT : MODULE : CMH_F |
2031 | ROUTINE : aci_cmd_src_mode_get |
2032 +-------------------------------------------------------------------+
2033
2034 PURPOSE : Access function for reading aci_cmd_src_mode[] which
2035 stores the command mode of each command source.
2036
2037 */
2038 GLOBAL T_ACI_CMD_MODE aci_cmd_src_mode_get(
2039 T_ACI_CMD_SRC src_id)
2040 {
2041 T_ACI_CMD_MODE mode;
2042
2043
2044 if (src_id<CMD_SRC_MAX)
2045 {
2046 mode = aci_cmd_src_mode[src_id];
2047 TRACE_EVENT_P2("aci_cmd_src_mode_get(): aci_cmd_src_mode[%d] = %d", src_id, mode);
2048 return(mode);
2049 }
2050 else
2051 {
2052 TRACE_EVENT("aci_cmd_src_mode_get(): CMD_MODE_NONE");
2053 return(CMD_MODE_NONE);
2054 }
2055 }
2056
2057
2058 /*
2059 +-------------------------------------------------------------------+
2060 | PROJECT : MODULE : CMH_F |
2061 | ROUTINE : aci_cmd_src_mode_set |
2062 +-------------------------------------------------------------------+
2063
2064 PURPOSE : Access function for writing to aci_cmd_src_mode[] which
2065 stores the command mode of each command source.
2066
2067 */
2068 GLOBAL void aci_cmd_src_mode_set(
2069 UBYTE src_id,
2070 T_ACI_CMD_MODE mode)
2071 {
2072 if (src_id<CMD_SRC_MAX)
2073 {
2074 aci_cmd_src_mode[src_id]=mode;
2075 TRACE_EVENT_P2("aci_cmd_src_mode_set(): aci_cmd_src_mode[%d] = %d", src_id, mode);
2076 }
2077 }
2078
2079 /* Implements Measure 178 */
2080 /*
2081 +------------------------------------------------------------------------------
2082 | Function : cmh_ClearCall
2083 +------------------------------------------------------------------------------
2084 | Purpose : Clear a Call.
2085 |
2086 | Parameters : srcId - AT command source identifier.
2087 | cmd - At Command Identifier
2088 | idx - Holds call table index.
2089 |
2090 | Return : UBYTE
2091 +------------------------------------------------------------------------------
2092 */
2093
2094 LOCAL UBYTE cmh_ClearCall( T_ACI_CMD_SRC srcId, T_ACI_AT_CMD cmd, UBYTE idx )
2095 {
2096 UBYTE srcBuf;
2097
2098 TRACE_FUNCTION ("cmh_ClearCall()");
2099
2100 srcBuf = psaCC_ctb(idx)->curSrc;
2101
2102 cmhCC_tstAndUnflagCall( idx, &cmhPrm[srcBuf].ccCmdPrm.mltyCncFlg );
2103 cmhCC_flagCall ( idx, &cmhPrm[srcId ].ccCmdPrm.mltyDscFlg );
2104
2105 psaCC_ctb(idx)->curCmd = AT_CMD_ABRT;
2106 psaCC_ctb(idx)->curSrc = srcId;
2107 psaCC_ctb(idx)->nrmCs = MNCC_CAUSE_CALL_CLEAR;
2108
2109 psaCC_ClearCall (idx);
2110
2111 if( srcBuf NEQ srcId )
2112 {
2113 R_AT( RAT_NO_CARRIER, (T_ACI_CMD_SRC)srcBuf ) ( cmd, idx+1 );
2114 }
2115 return srcBuf;
2116 }
2117
2118 /* Implements Measure 34 */
2119 /*
2120 +------------------------------------------------------------------------------
2121 | Function : cmh_tstAndUnflagCall
2122 +------------------------------------------------------------------------------
2123 | Purpose : Test and unflag a call for multy-call operation.
2124 |
2125 | Parameters : cmd - At Command Identifier
2126 | srcBuf - buffers current source of command
2127 |
2128 | Return : Return the Test Result.
2129 +------------------------------------------------------------------------------
2130 */
2131
2132 LOCAL BOOL cmh_tstAndUnflagCall( T_ACI_AT_CMD cmd , UBYTE *srcBuf )
2133 {
2134 UBYTE idx; /* holds call table index */
2135 BOOL doneFlg = FALSE; /* flags that an action was done */
2136 UBYTE curSrc;
2137
2138 TRACE_FUNCTION ("cmh_tstAndUnflagCall()");
2139
2140 for( idx = 0; idx < MAX_CALL_NR; idx++ )
2141 {
2142 if (ccShrdPrm.ctb[idx] NEQ NULL AND
2143 psaCC_ctb(idx)->curCmd EQ cmd AND
2144 psaCC_ctb(idx)->calStat EQ CS_MDF_REQ)
2145 {
2146 curSrc = psaCC_ctb(idx)->curSrc;
2147
2148 cmhCC_tstAndUnflagCall( idx, &cmhPrm[curSrc].ccCmdPrm.mltyCncFlg );
2149
2150 psaCC_ctb(idx)->curCmd = AT_CMD_NONE;
2151 psaCC_ctb(idx)->curSrc = CMD_SRC_NONE;
2152 doneFlg = TRUE;
2153 *srcBuf = curSrc;
2154 }
2155 }
2156 return doneFlg;
2157 }
2158
2159
2160 /* Implements Measure 25 */
2161 /*
2162 +--------------------------------------------------------------------+
2163 | PROJECT : GSM-PS (6147) MODULE : CMF_SMSF |
2164 | STATE : code ROUTINE : cmhSMS_getAlphabetCb |
2165 +--------------------------------------------------------------------+
2166 PARAMETERS : dcs - Data coding scheme
2167 RETURN : Alphabet type
2168
2169 PURPOSE : This function is used to extract the used alphabet out
2170 of the data coding scheme for cell broadcast SMS.
2171 */
2172 GLOBAL UBYTE cmh_getAlphabetCb ( UBYTE dcs )
2173 {
2174 UBYTE alphabet = 0; /* means 7 bit default alphabet */
2175
2176 switch (dcs & 0xF0)
2177 {
2178 case( 0x10 ):
2179 if (dcs EQ 0x11)
2180 {
2181 alphabet = 2;
2182 }
2183 break;
2184
2185 case( 0x70 ):
2186 case( 0x60 ):
2187 case( 0x50 ):
2188 case( 0x40 ):
2189 alphabet = (dcs & 0x0C) >> 2;
2190 /* According to 03.38, "Any reserved codings shall be assumed
2191 * to be the GSM 7 bit default alphabet by a receiving entity".
2192 */
2193 if (alphabet EQ 3)
2194 {
2195 alphabet = 0;
2196 }
2197 break;
2198
2199 case( 0xF0 ):
2200 alphabet = (dcs & 0x04) >> 2;
2201 break;
2202 }
2203
2204 return alphabet;
2205 }
2206 /*==== EOF ========================================================*/