comparison gsm-fw/g23m-aci/aci/cmh_f.c @ 775:eedbf248bac0

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