comparison src/g23m-aci/aci/cmh_sats.c @ 1:d393cd9bb723

src/g23m-*: initial import from Magnetite
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 15 Jul 2018 04:40:46 +0000
parents
children
comparison
equal deleted inserted replaced
0:b6a5e36de839 1:d393cd9bb723
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 #ifdef TI_PS_FF_AT_P_CMD_CUST
103 if (simShrdPrm.setPrm[srcId].cust_mode EQ (UBYTE)CUST_MODE_BEHAVIOUR_1)
104 mmiMask = satMaskCust1Prfl;
105 else
106 #endif /* TI_PS_FF_AT_P_CMD_CUST */
107 mmiMask = satMaskMMIPrfl;
108
109 for( idx = 0; idx < MAX_STK_PRF; idx++ )
110 {
111 simShrdPrm.setPrm[srcId].STKprof[idx] =
112 ((idx < len)? (satCnfg[idx] & mmiMask[idx]): 0)
113 | satDefPrfl[idx];
114 }
115 return AT_CMPL;
116 }
117
118 /*
119 +--------------------------------------------------------------------+
120 | PROJECT : GSM-PS (6147) MODULE : CMH_SATS |
121 | STATE : code ROUTINE : sAT_PercentSATR |
122 +--------------------------------------------------------------------+
123
124 PURPOSE : This is the functional counterpart to the %SATR AT command
125 which is responses to a previous SIM toolkit command.
126 */
127
128 GLOBAL T_ACI_RETURN sAT_PercentSATR ( T_ACI_CMD_SRC srcId,
129 SHORT len, UBYTE *satCmd )
130 {
131 BOOL sendRes = TRUE; /* holds indicator whether to send terminal res or not */
132
133 TRACE_FUNCTION ("sAT_PercentSATR()");
134 /*
135 *-------------------------------------------------------------------
136 * send STK command
137 *-------------------------------------------------------------------
138 */
139 if(!cmh_IsVldCmdSrc (srcId))
140
141 return( AT_FAIL );
142
143 /*
144 *-------------------------------------------------------------------
145 * update SIM toolkit profile
146 *-------------------------------------------------------------------
147 */
148 if( len > MAX_SAT_CMD_LEN OR !satCmd ) return ( AT_FAIL );
149
150 satShrdPrm.setPrm[srcId].stkCmd = satCmd;
151 satShrdPrm.setPrm[srcId].stkCmdLen = (UBYTE)len;
152 satShrdPrm.owner = srcId;
153
154 #ifdef TI_PS_FF_AT_P_CMD_CUST
155 /*
156 *-------------------------------------------------------------------
157 * If Cust1 and Refresh Response Expected
158 *-------------------------------------------------------------------
159 */
160 if ((simShrdPrm.overall_cust_mode EQ (UBYTE)CUST_MODE_BEHAVIOUR_1) AND
161 (satShrdPrm.cust1SimRefreshRespRqd EQ TRUE))
162 {
163 psaSAT_SendRefreshUserRes(len, satCmd);
164 satShrdPrm.cust1SimRefreshRespRqd = FALSE;
165 return(AT_CMPL);
166 }
167 #endif /* TI_PS_FF_AT_P_CMD_CUST */
168
169 /*
170 * check if MMI answers a setup event list and process it
171 */
172 sendRes = cmhSAT_CheckSetEventResp( );
173
174 if( sendRes )
175 {
176 if( psaSAT_STKResponse() < 0 ) /* respond to STK command */
177 {
178 TRACE_EVENT( "FATAL RETURN psaSIM in %%SATR" );
179 return( AT_FAIL );
180 }
181 }
182 return (AT_CMPL);
183 }
184
185 /*
186 +--------------------------------------------------------------------+
187 | PROJECT : GSM-PS (6147) MODULE : CMH_SATS |
188 | STATE : code ROUTINE : sAT_PercentSATE |
189 +--------------------------------------------------------------------+
190
191 PURPOSE : This is the functional counterpart to the %SATE AT command
192 which envelopes a SIM toolkit command.
193 */
194
195 GLOBAL T_ACI_RETURN sAT_PercentSATE ( T_ACI_CMD_SRC srcId,
196 SHORT len, UBYTE *satCmd )
197 {
198
199 TRACE_FUNCTION ("sAT_PercentSATE()");
200 /*
201 *-------------------------------------------------------------------
202 * check command source
203 *-------------------------------------------------------------------
204 */
205 if(!cmh_IsVldCmdSrc (srcId))
206
207 return( AT_FAIL );
208
209 /*
210 *-------------------------------------------------------------------
211 * check entity status
212 *-------------------------------------------------------------------
213 */
214 if( satEntStat.curCmd NEQ AT_CMD_NONE )
215
216 return( AT_BUSY );
217
218 /*
219 *-------------------------------------------------------------------
220 * send STK command
221 *-------------------------------------------------------------------
222 */
223 if( len > MAX_SAT_CMD_LEN OR !satCmd ) return ( AT_FAIL );
224
225 satShrdPrm.setPrm[srcId].stkCmd = satCmd;
226 satShrdPrm.setPrm[srcId].stkCmdLen = (UBYTE)len;
227
228 satEntStat.curCmd = AT_CMD_SATE;
229 satShrdPrm.owner = (UBYTE)srcId;
230 satEntStat.entOwn = srcId;
231
232 if( psaSAT_STKEnvelope (NULL) < 0 ) /* envelope STK command */
233 {
234 TRACE_EVENT( "FATAL RETURN psaSIM in %%SATE" );
235 return( AT_FAIL );
236 }
237
238 return (AT_EXCT);
239 }
240
241 /*
242 +--------------------------------------------------------------------+
243 | PROJECT : GSM-PS (6147) MODULE : CMH_SATS |
244 | STATE : code ROUTINE : sAT_PercentSATT |
245 +--------------------------------------------------------------------+
246
247 PURPOSE : This is the functional counterpart to the %SATT AT command
248 which terminates a SAT session.
249 */
250
251 GLOBAL T_ACI_RETURN sAT_PercentSATT( T_ACI_CMD_SRC srcId,
252 T_ACI_SATT_CS cause )
253 {
254 SHORT cId, dtmfId;
255 T_ACI_SAT_TERM_RESP resp_data;
256
257 psaSAT_InitTrmResp( &resp_data );
258
259 TRACE_FUNCTION ("sAT_PercentSATT()");
260
261 /*
262 *-------------------------------------------------------------------
263 * check command source
264 *-------------------------------------------------------------------
265 */
266 if(!cmh_IsVldCmdSrc (srcId))
267
268 return( AT_FAIL );
269
270
271 cId = psaCC_ctbFindCall( OWN_SRC_INV, CS_SAT_REQ, NO_VLD_CT );
272
273 if( cId EQ NO_ENTRY )
274 {
275 /* Try to stop processing of proactive command SEND DTMF */
276 dtmfId = cmhCC_find_call_for_DTMF();
277 if( dtmfId NEQ NO_ENTRY )
278 {
279 if (psaCC_ctb(dtmfId)->dtmfSrc EQ OWN_SRC_SAT)
280 {
281 ccShrdPrm.dtmf.cnt = 0; /* to avoid double terminal response to SAT */
282 psaCC_StopDTMF( dtmfId );
283 psaSAT_SendTrmResp( RSLT_SESS_USR_TERM, &resp_data );
284 return( AT_CMPL );
285 }
286 /* else it means there is a Send DTMF on process */
287 }
288 }
289
290 #ifdef FF_SAT_E
291 if( cId EQ NO_ENTRY )
292
293 cId = psaCC_ctbFindCall( OWN_SRC_INV, CS_SAT_CSD_REQ, NO_VLD_CT );
294
295 if( (cId EQ NO_ENTRY OR !psaCC_ctb(cId)->SATinv) AND
296 !( satShrdPrm.opchStat NEQ OPCH_IDLE AND
297 (satShrdPrm.cmdDet.cmdType EQ SAT_CMD_OPEN_CHANNEL OR
298 satShrdPrm.cmdDet.cmdType EQ SAT_CMD_SEND_DATA))
299 )
300 {
301 return( AT_FAIL );
302 }
303 #else
304
305 if( cId EQ NO_ENTRY OR
306 !psaCC_ctb(cId)->SATinv OR
307 psaCC_ctb(cId)->calStat NEQ CS_SAT_REQ)
308 {
309 return( AT_FAIL );
310 }
311 #endif /* else, #ifdef FF_SAT_E */
312
313 /*
314 *-------------------------------------------------------------------
315 * check termination cause
316 *-------------------------------------------------------------------
317 */
318 switch( cause )
319 {
320 case( SATT_CS_UserRedialStop ):
321 case( SATT_CS_EndRedial ):
322
323 if ((cId EQ NO_ENTRY) OR
324 (cause EQ SATT_CS_UserRedialStop))
325 {
326 /* respond with "user cleared down..." */
327 psaSAT_SendTrmResp( RSLT_USR_CLR_DWN, &resp_data );
328 }
329 else
330 {
331 /* return network error cause GSM 11.14 / 12.12.3 */
332 /*
333 * Use ctb here because TI compiler 1.22e may have a problem otherwise here.
334 * See cmhCC_SndDiscRsn() for the details.
335 */
336 cmhSAT_NtwErr ((UBYTE)((GET_CAUSE_VALUE(psaCC_ctb(cId)->nrmCs) NEQ NOT_PRESENT_8BIT) ?
337 (psaCC_ctb(cId)->nrmCs|0x80) : ADD_NO_CAUSE));
338 }
339 break;
340 case( SATT_CS_EndSession ):
341 /* respond with "session terminated by user" */
342 psaSAT_SendTrmResp( RSLT_SESS_USR_TERM, &resp_data );
343 break;
344 }
345
346 if( cId NEQ NO_ENTRY )
347 psaCC_FreeCtbNtry (cId);
348
349 #ifdef FF_SAT_E
350 if( satShrdPrm.opchStat NEQ OPCH_IDLE AND
351 (satShrdPrm.cmdDet.cmdType EQ SAT_CMD_OPEN_CHANNEL OR
352 satShrdPrm.cmdDet.cmdType EQ SAT_CMD_SEND_DATA) )
353 {
354 cmhSAT_cleanupOpChnPrms();
355 satShrdPrm.chnTb.chnUsdFlg = FALSE;
356 }
357 #endif /* FF_SAT_E */
358
359 return( AT_CMPL );
360 }
361
362 /*
363 +-------------------------------------------------------------------+
364 | PROJECT : GSM-PS (6147) MODULE : CMH_SATS |
365 | ROUTINE : sAT_PercentEFRSLT |
366 +-------------------------------------------------------------------+
367
368 PURPOSE :
369 */
370 GLOBAL T_ACI_RETURN sAT_PercentEFRSLT (T_ACI_CMD_SRC srcId,
371 T_ACI_EFRSLT_RES result)
372 {
373 TRACE_FUNCTION("sAT_PercentEFRSLT()");
374
375 if(!cmh_IsVldCmdSrc(srcId))
376 {
377 return(AT_FAIL);
378 }
379
380 switch(result)
381 {
382 case EFRSLT_RES_FAIL:
383 psaSAT_FUConfirm(simShrdPrm.fuRef,SIM_FU_ERROR);
384 break;
385
386 case EFRSLT_RES_OK:
387 psaSAT_FUConfirm(simShrdPrm.fuRef,SIM_FU_SUCCESS);
388 break;
389
390 default:
391 ACI_ERR_DESC(ACI_ERR_CLASS_Ext,EXT_ERR_Parameter);
392 return(AT_FAIL);
393 }
394
395 return(AT_CMPL);
396 }
397
398 /*
399 +-------------------------------------------------------------------+
400 | PROJECT : GSM-PS (6147) MODULE : CMH_SATS |
401 | ROUTINE : sAT_PercentSIMEF |
402 +-------------------------------------------------------------------+
403
404 PURPOSE :
405 */
406 GLOBAL T_ACI_RETURN sAT_PercentSIMEF (T_ACI_CMD_SRC srcId,
407 T_ACI_SIMEF_MODE mode)
408 {
409 TRACE_FUNCTION("sAT_PercentSIMEF()");
410
411 if(!cmh_IsVldCmdSrc(srcId))
412 {
413 return(AT_FAIL);
414 }
415
416 switch(mode)
417 {
418 case SIMEF_MODE_ON:
419 case SIMEF_MODE_OFF:
420 simShrdPrm.SIMEFMode[srcId]=mode;
421 break;
422
423 default:
424 ACI_ERR_DESC(ACI_ERR_CLASS_Ext,EXT_ERR_Parameter);
425 return(AT_FAIL);
426 }
427 return(AT_CMPL);
428 }
429
430 #endif /* #ifdef SIM_TOOLKIT */
431
432 /*==== EOF ========================================================*/