FreeCalypso > hg > tcs211-fcmodem
comparison g23m/condat/ms/src/aci/cmh_sats.c @ 0:509db1a7b7b8
initial import: leo2moko-r1
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Mon, 01 Jun 2015 03:24:05 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:509db1a7b7b8 |
---|---|
1 /* | |
2 +----------------------------------------------------------------------------- | |
3 | Project : GSM-PS (6147) | |
4 | Modul : CMH_SATS | |
5 +----------------------------------------------------------------------------- | |
6 | Copyright 2002 Texas Instruments Berlin, AG | |
7 | All rights reserved. | |
8 | | |
9 | This file is confidential and a trade secret of Texas | |
10 | Instruments Berlin, AG | |
11 | The receipt of or possession of this file does not convey | |
12 | any rights to reproduce or disclose its contents or to | |
13 | manufacture, use, or sell anything it may describe, in | |
14 | whole, or in part, without the specific written consent of | |
15 | Texas Instruments Berlin, AG. | |
16 +----------------------------------------------------------------------------- | |
17 | Purpose : This module provides the set functions related to the | |
18 | SIM application toolkit module. | |
19 +----------------------------------------------------------------------------- | |
20 */ | |
21 | |
22 #ifdef SIM_TOOLKIT | |
23 | |
24 #ifndef CMH_SATS_C | |
25 #define CMH_SATS_C | |
26 #endif | |
27 | |
28 #include "aci_all.h" | |
29 /*==== INCLUDES ===================================================*/ | |
30 #include "aci_cmh.h" | |
31 | |
32 #ifdef GPRS | |
33 #include "gaci_cmh.h" | |
34 #endif | |
35 | |
36 #ifdef FAX_AND_DATA | |
37 #include "aci_fd.h" | |
38 #endif /* of #ifdef FAX_AND_DATA */ | |
39 | |
40 #include "psa.h" | |
41 #include "psa_cc.h" | |
42 #include "psa_sat.h" | |
43 #include "psa_sim.h" | |
44 #include "cmh.h" | |
45 #include "cmh_sat.h" | |
46 | |
47 #include "cmh_cc.h" | |
48 /*==== CONSTANTS ==================================================*/ | |
49 | |
50 /*==== EXPORT =====================================================*/ | |
51 | |
52 /*==== VARIABLES ==================================================*/ | |
53 | |
54 /*==== FUNCTIONS ==================================================*/ | |
55 | |
56 /* | |
57 +--------------------------------------------------------------------+ | |
58 | PROJECT : GSM-PS (6147) MODULE : CMH_SATS | | |
59 | STATE : code ROUTINE : sAT_PercentSATC | | |
60 +--------------------------------------------------------------------+ | |
61 | |
62 PURPOSE : This is the functional counterpart to the %SATC AT command | |
63 which is responsible to configure the SIM toolkit profile. | |
64 */ | |
65 | |
66 GLOBAL T_ACI_RETURN sAT_PercentSATC ( T_ACI_CMD_SRC srcId, | |
67 SHORT len, UBYTE *satCnfg ) | |
68 { | |
69 SHORT idx; /* holds profile index */ | |
70 UBYTE *mmiMask; | |
71 | |
72 TRACE_FUNCTION ("sAT_PercentSATC()"); | |
73 /* | |
74 *------------------------------------------------------------------- | |
75 * check command source | |
76 *------------------------------------------------------------------- | |
77 */ | |
78 if (!cmh_IsVldCmdSrc (srcId)) | |
79 return AT_FAIL; | |
80 | |
81 /* | |
82 *------------------------------------------------------------------- | |
83 * check parameters | |
84 *------------------------------------------------------------------- | |
85 */ | |
86 if (len < 0 OR !satCnfg) | |
87 return ( AT_FAIL ); | |
88 | |
89 if (len > MAX_STK_PRF) | |
90 { | |
91 for (idx = MAX_STK_PRF; idx < len; idx++) | |
92 { | |
93 if (satCnfg[idx] NEQ 0) /* TP bit set beyond MAX_STK_PRF? */ | |
94 return AT_FAIL; | |
95 } | |
96 } | |
97 /* | |
98 *------------------------------------------------------------------- | |
99 * update SIM toolkit profile | |
100 *------------------------------------------------------------------- | |
101 */ | |
102 if (simShrdPrm.setPrm[srcId].cust_mode EQ (UBYTE)CUST_MODE_BEHAVIOUR_1) | |
103 mmiMask = satMaskCust1Prfl; | |
104 else | |
105 mmiMask = satMaskMMIPrfl; | |
106 | |
107 for( idx = 0; idx < MAX_STK_PRF; idx++ ) | |
108 { | |
109 simShrdPrm.setPrm[srcId].STKprof[idx] = | |
110 ((idx < len)? (satCnfg[idx] & mmiMask[idx]): 0) | |
111 | satDefPrfl[idx]; | |
112 } | |
113 return AT_CMPL; | |
114 } | |
115 | |
116 /* | |
117 +--------------------------------------------------------------------+ | |
118 | PROJECT : GSM-PS (6147) MODULE : CMH_SATS | | |
119 | STATE : code ROUTINE : sAT_PercentSATR | | |
120 +--------------------------------------------------------------------+ | |
121 | |
122 PURPOSE : This is the functional counterpart to the %SATR AT command | |
123 which is responses to a previous SIM toolkit command. | |
124 */ | |
125 | |
126 GLOBAL T_ACI_RETURN sAT_PercentSATR ( T_ACI_CMD_SRC srcId, | |
127 SHORT len, UBYTE *satCmd ) | |
128 { | |
129 BOOL sendRes = TRUE; /* holds indicator whether to send terminal res or not */ | |
130 | |
131 TRACE_FUNCTION ("sAT_PercentSATR()"); | |
132 /* | |
133 *------------------------------------------------------------------- | |
134 * send STK command | |
135 *------------------------------------------------------------------- | |
136 */ | |
137 if(!cmh_IsVldCmdSrc (srcId)) | |
138 | |
139 return( AT_FAIL ); | |
140 | |
141 /* | |
142 *------------------------------------------------------------------- | |
143 * update SIM toolkit profile | |
144 *------------------------------------------------------------------- | |
145 */ | |
146 if( len > MAX_SAT_CMD_LEN OR !satCmd ) return ( AT_FAIL ); | |
147 | |
148 satShrdPrm.setPrm[srcId].stkCmd = satCmd; | |
149 satShrdPrm.setPrm[srcId].stkCmdLen = (UBYTE)len; | |
150 satShrdPrm.owner = srcId; | |
151 | |
152 /* | |
153 *------------------------------------------------------------------- | |
154 * If Cust1 and Refresh Response Expected | |
155 *------------------------------------------------------------------- | |
156 */ | |
157 if ((simShrdPrm.overall_cust_mode EQ (UBYTE)CUST_MODE_BEHAVIOUR_1) AND | |
158 (satShrdPrm.cust1SimRefreshRespRqd EQ TRUE)) | |
159 { | |
160 psaSAT_SendRefreshUserRes(len, satCmd); | |
161 satShrdPrm.cust1SimRefreshRespRqd = FALSE; | |
162 return(AT_CMPL); | |
163 } | |
164 | |
165 /* | |
166 * check if MMI answers a setup event list and process it | |
167 */ | |
168 sendRes = cmhSAT_CheckSetEventResp( ); | |
169 | |
170 if( sendRes ) | |
171 { | |
172 if( psaSAT_STKResponse() < 0 ) /* respond to STK command */ | |
173 { | |
174 TRACE_EVENT( "FATAL RETURN psaSIM in %%SATR" ); | |
175 return( AT_FAIL ); | |
176 } | |
177 } | |
178 return (AT_CMPL); | |
179 } | |
180 | |
181 /* | |
182 +--------------------------------------------------------------------+ | |
183 | PROJECT : GSM-PS (6147) MODULE : CMH_SATS | | |
184 | STATE : code ROUTINE : sAT_PercentSATE | | |
185 +--------------------------------------------------------------------+ | |
186 | |
187 PURPOSE : This is the functional counterpart to the %SATE AT command | |
188 which envelopes a SIM toolkit command. | |
189 */ | |
190 | |
191 GLOBAL T_ACI_RETURN sAT_PercentSATE ( T_ACI_CMD_SRC srcId, | |
192 SHORT len, UBYTE *satCmd ) | |
193 { | |
194 | |
195 TRACE_FUNCTION ("sAT_PercentSATE()"); | |
196 /* | |
197 *------------------------------------------------------------------- | |
198 * check command source | |
199 *------------------------------------------------------------------- | |
200 */ | |
201 if(!cmh_IsVldCmdSrc (srcId)) | |
202 | |
203 return( AT_FAIL ); | |
204 | |
205 /* | |
206 *------------------------------------------------------------------- | |
207 * check entity status | |
208 *------------------------------------------------------------------- | |
209 */ | |
210 if( satEntStat.curCmd NEQ AT_CMD_NONE ) | |
211 | |
212 return( AT_BUSY ); | |
213 | |
214 /* | |
215 *------------------------------------------------------------------- | |
216 * send STK command | |
217 *------------------------------------------------------------------- | |
218 */ | |
219 if( len > MAX_SAT_CMD_LEN OR !satCmd ) return ( AT_FAIL ); | |
220 | |
221 satShrdPrm.setPrm[srcId].stkCmd = satCmd; | |
222 satShrdPrm.setPrm[srcId].stkCmdLen = (UBYTE)len; | |
223 | |
224 satEntStat.curCmd = AT_CMD_SATE; | |
225 satEntStat.entOwn = satShrdPrm.owner = srcId; | |
226 | |
227 if( psaSAT_STKEnvelope (NULL) < 0 ) /* envelope STK command */ | |
228 { | |
229 TRACE_EVENT( "FATAL RETURN psaSIM in %%SATE" ); | |
230 return( AT_FAIL ); | |
231 } | |
232 | |
233 return (AT_EXCT); | |
234 } | |
235 | |
236 /* | |
237 +--------------------------------------------------------------------+ | |
238 | PROJECT : GSM-PS (6147) MODULE : CMH_SATS | | |
239 | STATE : code ROUTINE : sAT_PercentSATT | | |
240 +--------------------------------------------------------------------+ | |
241 | |
242 PURPOSE : This is the functional counterpart to the %SATT AT command | |
243 which terminates a SAT session. | |
244 */ | |
245 | |
246 GLOBAL T_ACI_RETURN sAT_PercentSATT( T_ACI_CMD_SRC srcId, | |
247 T_ACI_SATT_CS cause ) | |
248 { | |
249 SHORT cId, dtmfId; | |
250 T_ACI_SAT_TERM_RESP resp_data; | |
251 | |
252 psaSAT_InitTrmResp( &resp_data ); | |
253 | |
254 TRACE_FUNCTION ("sAT_PercentSATT()"); | |
255 | |
256 /* | |
257 *------------------------------------------------------------------- | |
258 * check command source | |
259 *------------------------------------------------------------------- | |
260 */ | |
261 if(!cmh_IsVldCmdSrc (srcId)) | |
262 | |
263 return( AT_FAIL ); | |
264 | |
265 | |
266 cId = psaCC_ctbFindCall( NO_VLD_OWN, CS_SAT_REQ, NO_VLD_CT ); | |
267 | |
268 if( cId EQ NO_ENTRY ) | |
269 { | |
270 /* Try to stop processing of proactive command SEND DTMF */ | |
271 dtmfId = cmhCC_find_call_for_DTMF(); | |
272 if( dtmfId NEQ NO_ENTRY ) | |
273 { | |
274 if (psaCC_ctb(dtmfId)->dtmfSrc EQ OWN_SAT) | |
275 { | |
276 ccShrdPrm.dtmf.cnt = 0; /* to avoid double terminal response to SAT */ | |
277 psaCC_StopDTMF( dtmfId ); | |
278 psaSAT_SendTrmResp( RSLT_SESS_USR_TERM, &resp_data ); | |
279 return( AT_CMPL ); | |
280 } | |
281 /* else it means there is a Send DTMF on process */ | |
282 } | |
283 } | |
284 | |
285 #ifdef FF_SAT_E | |
286 if( cId EQ NO_ENTRY ) | |
287 | |
288 cId = psaCC_ctbFindCall( NO_VLD_OWN, CS_SAT_CSD_REQ, NO_VLD_CT ); | |
289 | |
290 if( (cId EQ NO_ENTRY OR !psaCC_ctb(cId)->SATinv) AND | |
291 !( satShrdPrm.opchStat NEQ OPCH_IDLE AND | |
292 (satShrdPrm.cmdDet.cmdType EQ SAT_CMD_OPEN_CHANNEL OR | |
293 satShrdPrm.cmdDet.cmdType EQ SAT_CMD_SEND_DATA)) | |
294 ) | |
295 { | |
296 return( AT_FAIL ); | |
297 } | |
298 #else | |
299 | |
300 if( cId EQ NO_ENTRY OR | |
301 !psaCC_ctb(cId)->SATinv OR | |
302 psaCC_ctb(cId)->calStat NEQ CS_SAT_REQ) | |
303 { | |
304 return( AT_FAIL ); | |
305 } | |
306 #endif /* else, #ifdef FF_SAT_E */ | |
307 | |
308 /* | |
309 *------------------------------------------------------------------- | |
310 * check termination cause | |
311 *------------------------------------------------------------------- | |
312 */ | |
313 switch( cause ) | |
314 { | |
315 case( SATT_CS_UserRedialStop ): | |
316 case( SATT_CS_EndRedial ): | |
317 | |
318 if ((cId EQ NO_ENTRY) OR | |
319 (cause EQ SATT_CS_UserRedialStop)) | |
320 { | |
321 /* respond with "user cleared down..." */ | |
322 psaSAT_SendTrmResp( RSLT_USR_CLR_DWN, &resp_data ); | |
323 } | |
324 else | |
325 { | |
326 /* return network error cause GSM 11.14 / 12.12.3 */ | |
327 /* | |
328 * Use ctb here because TI compiler 1.22e may have a problem otherwise here. | |
329 * See cmhCC_SndDiscRsn() for the details. | |
330 */ | |
331 cmhSAT_NtwErr ((UBYTE)((GET_CAUSE_VALUE(psaCC_ctb(cId)->nrmCs) NEQ NOT_PRESENT_8BIT) ? | |
332 (psaCC_ctb(cId)->nrmCs|0x80) : ADD_NO_CAUSE)); | |
333 } | |
334 break; | |
335 case( SATT_CS_EndSession ): | |
336 /* respond with "session terminated by user" */ | |
337 psaSAT_SendTrmResp( RSLT_SESS_USR_TERM, &resp_data ); | |
338 break; | |
339 } | |
340 | |
341 if( cId NEQ NO_ENTRY ) | |
342 psaCC_FreeCtbNtry (cId); | |
343 | |
344 #ifdef FF_SAT_E | |
345 if( satShrdPrm.opchStat NEQ OPCH_IDLE AND | |
346 (satShrdPrm.cmdDet.cmdType EQ SAT_CMD_OPEN_CHANNEL OR | |
347 satShrdPrm.cmdDet.cmdType EQ SAT_CMD_SEND_DATA) ) | |
348 { | |
349 cmhSAT_cleanupOpChnPrms(); | |
350 satShrdPrm.chnTb.chnUsdFlg = FALSE; | |
351 } | |
352 #endif /* FF_SAT_E */ | |
353 | |
354 return( AT_CMPL ); | |
355 } | |
356 | |
357 /* | |
358 +-------------------------------------------------------------------+ | |
359 | PROJECT : GSM-PS (6147) MODULE : CMH_SATS | | |
360 | ROUTINE : sAT_PercentEFRSLT | | |
361 +-------------------------------------------------------------------+ | |
362 | |
363 PURPOSE : | |
364 */ | |
365 GLOBAL T_ACI_RETURN sAT_PercentEFRSLT (T_ACI_CMD_SRC srcId, | |
366 T_ACI_EFRSLT_RES result) | |
367 { | |
368 TRACE_FUNCTION("sAT_PercentEFRSLT()"); | |
369 | |
370 if(!cmh_IsVldCmdSrc(srcId)) | |
371 { | |
372 ACI_ERR_DESC(ACI_ERR_CLASS_Ext,EXT_ERR_Parameter); | |
373 return(AT_FAIL); | |
374 } | |
375 | |
376 switch(result) | |
377 { | |
378 case EFRSLT_RES_FAIL: | |
379 psaSAT_FUConfirm(simShrdPrm.fuRef,SIM_FU_ERROR); | |
380 break; | |
381 | |
382 case EFRSLT_RES_OK: | |
383 psaSAT_FUConfirm(simShrdPrm.fuRef,SIM_FU_SUCCESS); | |
384 break; | |
385 | |
386 default: | |
387 ACI_ERR_DESC(ACI_ERR_CLASS_Ext,EXT_ERR_Parameter); | |
388 return(AT_FAIL); | |
389 } | |
390 | |
391 return(AT_CMPL); | |
392 } | |
393 | |
394 /* | |
395 +-------------------------------------------------------------------+ | |
396 | PROJECT : GSM-PS (6147) MODULE : CMH_SATS | | |
397 | ROUTINE : sAT_PercentSIMEF | | |
398 +-------------------------------------------------------------------+ | |
399 | |
400 PURPOSE : | |
401 */ | |
402 GLOBAL T_ACI_RETURN sAT_PercentSIMEF (T_ACI_CMD_SRC srcId, | |
403 T_ACI_SIMEF_MODE mode) | |
404 { | |
405 TRACE_FUNCTION("sAT_PercentSIMEF()"); | |
406 | |
407 if(!cmh_IsVldCmdSrc(srcId)) | |
408 { | |
409 ACI_ERR_DESC(ACI_ERR_CLASS_Ext,EXT_ERR_Parameter); | |
410 return(AT_FAIL); | |
411 } | |
412 | |
413 switch(mode) | |
414 { | |
415 case SIMEF_MODE_ON: | |
416 case SIMEF_MODE_OFF: | |
417 simShrdPrm.SIMEFMode[srcId]=mode; | |
418 break; | |
419 | |
420 default: | |
421 ACI_ERR_DESC(ACI_ERR_CLASS_Ext,EXT_ERR_Parameter); | |
422 return(AT_FAIL); | |
423 } | |
424 return(AT_CMPL); | |
425 } | |
426 | |
427 #endif /* #ifdef SIM_TOOLKIT */ | |
428 | |
429 /*==== EOF ========================================================*/ |