comparison src/aci2/aci/psa_satp.c @ 3:93999a60b835

src/aci2, src/condat2: import of g23m/condat source pieces from TCS211
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 26 Sep 2016 00:29:36 +0000
parents
children
comparison
equal deleted inserted replaced
2:c41a534f33c6 3:93999a60b835
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : GSM-PS (6147)
4 | Modul : PSA_SATP
5 +-----------------------------------------------------------------------------
6 | Copyright 2002 Texas Instruments Berlin, AG
7 | All rights reserved.
8 |
9 | This file is confidential and a trade secret of Texas
10 | Instruments Berlin, AG
11 | The receipt of or possession of this file does not convey
12 | any rights to reproduce or disclose its contents or to
13 | manufacture, use, or sell anything it may describe, in
14 | whole, or in part, without the specific written consent of
15 | Texas Instruments Berlin, AG.
16 +-----------------------------------------------------------------------------
17 | Purpose : This module defines the processing functions for the
18 | primitives send to the protocol stack adapter by the
19 | SIM application toolkit.
20 +-----------------------------------------------------------------------------
21 */
22
23 #ifdef SIM_TOOLKIT
24
25 #ifndef PSA_SATP_C
26 #define PSA_SATP_C
27 #endif
28
29 #include "aci_all.h"
30
31 /*==== INCLUDES ===================================================*/
32 #include "aci_cmh.h"
33 #include "aci_mem.h"
34
35 #ifdef FAX_AND_DATA
36 #include "aci_fd.h"
37 #endif /* of #ifdef FAX_AND_DATA */
38
39 #include "aci.h"
40 #include "psa.h"
41 #include "psa_cc.h"
42 #include "psa_sim.h" /* for simShrdPrm declaration */
43 #include "psa_sat.h"
44 #include "psa_sms.h"
45 #include "cmh.h"
46 #include "cmh_sat.h"
47
48 /*==== CONSTANTS ==================================================*/
49
50
51 /*==== TYPES ======================================================*/
52
53
54 /*==== EXPORT =====================================================*/
55
56
57 /*==== VARIABLES ==================================================*/
58
59 /*==== FUNCTIONS ==================================================*/
60
61 /*
62 +-------------------------------------------------------------------+
63 | PROJECT : GSM-PS (6147) MODULE : PSA_SATP |
64 | ROUTINE : psa_sim_toolkit_ind |
65 +-------------------------------------------------------------------+
66
67 PURPOSE : processes the SIM_TOOLKIT_IND primitive send by SIM.
68 this is an indication that a STK command was received.
69
70 */
71
72 GLOBAL const void psa_sim_toolkit_ind
73 ( T_SIM_TOOLKIT_IND *sim_toolkit_ind )
74 {
75 T_ACI_SAT_TERM_RESP resp_data;
76
77 TRACE_FUNCTION ("psa_sim_toolkit_ind()");
78
79 /*
80 *-------------------------------------------------------------------
81 * update shared parameter
82 *-------------------------------------------------------------------
83 */
84
85 satShrdPrm.stkCmdLen = sim_toolkit_ind -> stk_cmd.l_cmd;
86 satShrdPrm.stkCmd = sim_toolkit_ind -> stk_cmd.cmd;
87
88 psaSAT_DumpCmd ( &sim_toolkit_ind -> stk_cmd );
89
90 /*
91 *-------------------------------------------------------------------
92 * decode SIM toolkit command
93 *-------------------------------------------------------------------
94 */
95 CCD_START;
96 {
97 UBYTE ccdRet;
98
99 MCAST( cmd, STK_CMD );
100 memset( cmd, 0, sizeof( T_STK_CMD ));
101
102 ccdRet = ccd_decodeMsg (CCDENT_SAT,
103 DOWNLINK,
104 (T_MSGBUF *) &sim_toolkit_ind -> stk_cmd,
105 (UBYTE *) _decodedMsg,
106 STK_CMD);
107
108 if( ccdRet NEQ ccdOK OR !cmd->v_pas_cmd)
109 {
110 cmhSAT_STKCmdInd();
111 }
112 else if( cmd->pas_cmd.v_cmd_details AND cmd->pas_cmd.v_dev_ids )
113 {
114 /* store command details */
115 satShrdPrm.cmdDet.cmdNr = cmd->pas_cmd.cmd_details.cmd_nr;
116 satShrdPrm.cmdDet.cmdType = cmd->pas_cmd.cmd_details.cmd_typ;
117 satShrdPrm.cmdDet.cmdQlf = cmd->pas_cmd.cmd_details.cmd_qlf;
118
119 if (simShrdPrm.overall_cust_mode == (UBYTE)CUST_MODE_BEHAVIOUR_1)
120 {
121 /*
122 ** Customised behaviour for the Cust1 MMI
123 */
124 switch (cmd->pas_cmd.cmd_details.cmd_typ)
125 {
126 case SAT_CMD_SETUP_CALL:
127 case SAT_CMD_SEND_SMS:
128 case SAT_CMD_SEND_SS:
129 case SAT_CMD_SEND_USSD:
130 if (satShrdPrm.cust1StkCmd != (void *)0)
131 {
132 /*
133 ** The previous command has not been deleted.
134 */
135 ACI_MFREE(satShrdPrm.cust1StkCmd);
136
137 satShrdPrm.cust1StkCmd = (void *)0;
138 satShrdPrm.cust1StkCmdLen = 0;
139 }
140
141 /*
142 ** Allocate memory to store the command
143 */
144 ACI_MALLOC(satShrdPrm.cust1StkCmd, MAX_STK_CMD);
145 if (satShrdPrm.cust1StkCmd == (void *)0)
146 {
147 /*
148 ** Memory allocation has failed, return ME Unable to Process Cmd
149 */
150 TRACE_EVENT("Memory Allocation Failure");
151 psaSAT_InitTrmResp( &resp_data );
152 psaSAT_SendTrmResp( RSLT_ME_UNAB_PROC, &resp_data );
153 break;
154 }
155
156 /*
157 ** Save the received data before proceeding
158 */
159 memset(satShrdPrm.cust1StkCmd, 0, MAX_STK_CMD);
160 /*
161 ** stkCmdLen is the BIT length of the received data, so shift right 3 (divide by 8)
162 ** in order to get the BYTE length
163 */
164 memcpy(satShrdPrm.cust1StkCmd, satShrdPrm.stkCmd, satShrdPrm.stkCmdLen >> 3);
165 satShrdPrm.cust1StkCmdLen = satShrdPrm.stkCmdLen;
166
167 /*
168 ** Continue the processing as for normal behaviour,
169 ** special processing will be applied later
170 **
171 ** No Break!
172 */
173
174 case SAT_CMD_EVENT_LIST:
175 /*
176 ** This command is processed normally
177 */
178 if( !cmd->pas_cmd.v_cmd_prms OR !cmd->pas_cmd.cmd_prms.l_cmd_prms )
179 {
180 TRACE_EVENT("no parameters in envelope");
181 psaSAT_dasmMECmd( NULL );
182 }
183 else
184 psaSAT_dasmMECmd( &cmd->pas_cmd.cmd_prms );
185 break;
186
187 case SAT_CMD_REFRESH:
188 /*
189 ** This command is to be forwarded to the MMI, for the user to be given the
190 ** chance to accept or reject the Refresh action. The user response will be
191 ** contained in a SATR Response indication, and we must be prepared to
192 ** process that indication in a different manner.
193 */
194 satShrdPrm.cust1SimRefreshRespRqd = TRUE;
195
196 /*
197 ** Forward the command to the MMI
198 */
199 cmhSAT_STKCmdInd();
200 break;
201
202 default:
203 /*
204 ** If the command is handled by the MMI pass it up in a %SATI indication
205 */
206 if (cmhSAT_IsStkCmdForMmi(cmd->pas_cmd.cmd_details.cmd_typ,
207 cmd->pas_cmd.cmd_details.cmd_qlf) == FALSE)
208 {
209 /*
210 ** Otherwise Determine whether the command is handled in the Modem Part
211 */
212 switch (cmd->pas_cmd.cmd_details.cmd_typ)
213 {
214 case( SAT_CMD_SEND_DTMF ):
215 case( SAT_CMD_RUN_AT ):
216 case( SAT_CMD_LAUNCH_BROWSER ):
217 case (SAT_CMD_PROV_LOC_INFO):
218 #ifdef FF_SAT_E
219 case( SAT_CMD_OPEN_CHANNEL ):
220 #endif /* FF_SAT_E */
221 if( !cmd->pas_cmd.v_cmd_prms OR !cmd->pas_cmd.cmd_prms.l_cmd_prms )
222 {
223 TRACE_EVENT("no parameters in envelope");
224 psaSAT_dasmMECmd( NULL );
225 }
226 else
227 psaSAT_dasmMECmd( &cmd->pas_cmd.cmd_prms );
228 break;
229 #ifdef FF_SAT_E
230 /* special handling for CLOSE CHANNEL, no further decoding required.
231 all that is needed can be found in device identities */
232 case( SAT_CMD_CLOSE_CHANNEL ):
233 cmhSAT_CloseChannel();
234 break;
235
236 /* special handling for SEND DATA, no further decoding required.
237 all that is needed can be found in command details */
238 case( SAT_CMD_SEND_DATA ):
239 cmhSAT_SendData();
240 break;
241
242 /* special handling for GET CHANNEL STATUS, no further decoding required */
243 case( SAT_CMD_GET_CHANNEL_STATUS ):
244 cmhSAT_GetChannelStatus();
245 break;
246
247 /* special handling for RECEIVE DATA, no further decoding required */
248 case( SAT_CMD_RECEIVE_DATA ):
249 cmhSAT_STKUsrNtfy();
250 break;
251 #endif /* FF_SAT_E */
252
253 /*
254 ** If the command is not handled by the Modem Part, return a "Beyond ME
255 ** Capabilities" response to the SIM Entity.
256 */
257 default:
258 TRACE_EVENT("Unable to handle command");
259 psaSAT_InitTrmResp( &resp_data );
260 psaSAT_SendTrmResp( RSLT_ME_CAP, &resp_data );
261 }
262 }
263 }
264 }
265 else
266 {
267 /* if command is addressed to ACI */
268 switch( cmd->pas_cmd.cmd_details.cmd_typ )
269 {
270 case( SAT_CMD_SETUP_CALL ):
271 case( SAT_CMD_SEND_SS ):
272 case( SAT_CMD_SEND_SMS ):
273 case( SAT_CMD_SEND_USSD ):
274 case( SAT_CMD_SEND_DTMF ):
275 case( SAT_CMD_EVENT_LIST ):
276 case( SAT_CMD_RUN_AT ):
277 case( SAT_CMD_LAUNCH_BROWSER ):
278 case (SAT_CMD_PROV_LOC_INFO):
279 #ifdef FF_SAT_E
280 case( SAT_CMD_OPEN_CHANNEL ):
281 #endif /* FF_SAT_E */
282 if( !cmd->pas_cmd.v_cmd_prms OR !cmd->pas_cmd.cmd_prms.l_cmd_prms )
283 {
284 TRACE_EVENT("no parameters in envelope");
285 psaSAT_dasmMECmd( NULL );
286 }
287 else
288 psaSAT_dasmMECmd( &cmd->pas_cmd.cmd_prms );
289 break;
290 #ifdef FF_SAT_E
291 /* special handling for CLOSE CHANNEL, no further decoding required.
292 all that is needed can be found in device identities */
293 case( SAT_CMD_CLOSE_CHANNEL ):
294
295 cmhSAT_CloseChannel();
296 break;
297
298 /* special handling for SEND DATA, no further decoding required.
299 all that is needed can be found in command details */
300 case( SAT_CMD_SEND_DATA ):
301
302 cmhSAT_SendData();
303 break;
304
305 /* special handling for GET CHANNEL STATUS, no further decoding required */
306 case( SAT_CMD_GET_CHANNEL_STATUS ):
307
308 cmhSAT_GetChannelStatus();
309 break;
310
311 /* special handling for RECEIVE DATA, no further decoding required */
312 case( SAT_CMD_RECEIVE_DATA ):
313
314 cmhSAT_STKUsrNtfy();
315 break;
316 #endif /* FF_SAT_E */
317 /* otherwise pass command to user */
318 default:
319 cmhSAT_STKCmdInd();
320 }
321 }
322 }
323 else
324 {
325 /* respond with "error, required values are missing" */
326 TRACE_EVENT("parameters are missing");
327 psaSAT_InitTrmResp( &resp_data );
328 psaSAT_SendTrmResp( RSLT_ERR_REQ_VAL, &resp_data );
329 }
330 }
331 CCD_END;
332
333 /*
334 *-------------------------------------------------------------------
335 * free the primitive buffer
336 *-------------------------------------------------------------------
337 */
338 PFREE (sim_toolkit_ind);
339
340 }
341
342 /*
343 +-------------------------------------------------------------------+
344 | PROJECT : GSM-PS (6147) MODULE : PSA_SATP |
345 | ROUTINE : psa_sim_toolkit_cnf |
346 +-------------------------------------------------------------------+
347
348 PURPOSE : processes the SIM_TOOLKIT_CNF primitive send by SIM.
349 this is a confirmation to a previous STK command.
350
351 */
352
353 GLOBAL const void psa_sim_toolkit_cnf( T_SIM_TOOLKIT_CNF *sim_toolkit_cnf )
354 {
355 void *p = NULL;
356 BOOL SIM_error = FALSE;
357 BOOL not_allw = FALSE;
358 BOOL allw = FALSE;
359 void *p_allw = NULL;
360 UBYTE *p_v_allw = NULL;
361 void *p_not_allw = NULL;
362 UBYTE *p_v_not_allw = NULL;
363 void *p_allw_mdfy = NULL;
364 UBYTE *p_v_allw_mdfy = NULL;
365 SHORT StructSize = 0;
366 UBYTE DynEnv = '\0';
367
368 TRACE_FUNCTION ("psa_sim_toolkit_cnf()");
369 /*
370 *-------------------------------------------------------------------
371 * update shared parameter
372 *-------------------------------------------------------------------
373 */
374 satShrdPrm.stkCmdLen = sim_toolkit_cnf -> stk_cmd.l_cmd;
375 satShrdPrm.stkCmd = sim_toolkit_cnf -> stk_cmd.cmd;
376 satShrdPrm.stkError = sim_toolkit_cnf -> cause;
377
378 psaSAT_DumpCmd ( &sim_toolkit_cnf -> stk_cmd );
379
380 /*
381 *-------------------------------------------------------------------
382 * if request was invoked by MMI pass reply to MMI
383 *-------------------------------------------------------------------
384 */
385 if( sim_toolkit_cnf -> req_id EQ SRQ_MMI )
386 {
387 cmhSAT_STKCmdCnf();
388 }
389
390 /*
391 *-------------------------------------------------------------------
392 * if request was invoked by ACI decode envelope command result
393 *-------------------------------------------------------------------
394 */
395 else if( sim_toolkit_cnf -> req_id EQ SRQ_ACI )
396 {
397 if( sim_toolkit_cnf -> stk_cmd.l_cmd EQ 0 OR
398 sim_toolkit_cnf -> cause EQ SIM_CAUSE_SAT_BUSY)
399 {
400 SIM_error = TRUE;
401
402 switch ( sim_toolkit_cnf -> cause )
403 {
404 case SIM_CAUSE_OTHER_ERROR:
405 case SIM_CAUSE_SAT_BUSY:
406 case SIM_CAUSE_CARD_REMOVED:
407 case SIM_CAUSE_PIN1_EXPECT:
408 case SIM_CAUSE_PIN1_BLOCKED:
409 case SIM_CAUSE_PUK1_EXPECT:
410 case SIM_CAUSE_PUK1_BLOCKED:
411 case SIM_CAUSE_PIN2_EXPECT:
412 case SIM_CAUSE_PIN2_BLOCKED:
413 case SIM_CAUSE_PUK2_EXPECT:
414 case SIM_CAUSE_PUK2_BLOCKED:
415 /* in case of certain errors, assume not allowed */
416 not_allw = TRUE;
417 sim_toolkit_cnf -> stk_cmd.cmd[0] = CCR_NOT_ALLW;
418 break;
419
420 default:
421 /* in case of a positive result without further info,
422 assume allowed not modified */
423 allw = TRUE;
424 sim_toolkit_cnf -> stk_cmd.cmd[0] = CCR_ALLW_NO_MDFY;
425 break;
426 }
427 sim_toolkit_cnf -> stk_cmd.cmd[1] = 0; /* no extra TLVs */
428 satShrdPrm.stkCmdLen = 2<<3; /* 2 bytes result */
429 }
430
431 else
432 {
433 SIM_error = FALSE;
434 }
435
436
437 {
438 CCD_START;
439 {
440 UBYTE ccdRet;
441 MCAST( env, ENV_RES );
442 MCAST( smc_env, ENV_RES_SMC );
443
444 switch( satShrdPrm.SIMCCParm.ccAct )
445 {
446 case( CC_ACT_CAL ):
447 case( CC_ACT_SS ):
448 case( CC_ACT_USSD ):
449 memset( env, 0, sizeof( T_ENV_RES ));
450 p_v_not_allw = &env->v_ccr_not_allw;
451 p_v_allw = &env->v_ccr_allw;
452 p_v_allw_mdfy = &env->v_ccr_allw_mdfy;
453 p_not_allw = &env->ccr_not_allw;
454 p_allw = &env->ccr_allw;
455 p_allw_mdfy = &env->ccr_allw_mdfy;
456 DynEnv = ENV_RES;
457 break;
458 case( SMC_ACT_MO ):
459 memset( smc_env, 0, sizeof( T_ENV_RES_SMC ));
460 p_v_not_allw = &smc_env->v_smcr_not_allw;
461 p_v_allw = &smc_env->v_smcr_allw;
462 p_v_allw_mdfy = &smc_env->v_smcr_allw_mdfy;
463 p_not_allw = &smc_env->smcr_not_allw;
464 p_allw = &smc_env->smcr_allw;
465 p_allw_mdfy = &smc_env->smcr_allw_mdfy;
466 DynEnv = ENV_RES_SMC;
467 break;
468 }
469
470 if (SIM_error)
471 {
472 *p_v_not_allw = not_allw;
473 *p_v_allw = allw;
474 }
475 /* otherwise decode message */
476 else
477 {
478 ccdRet = ccd_decodeMsg (CCDENT_SAT,
479 DOWNLINK,
480 (T_MSGBUF *) &sim_toolkit_cnf -> stk_cmd,
481 (UBYTE *) _decodedMsg,
482 DynEnv );
483
484 if( ccdRet NEQ ccdOK )
485 {
486 /* in case of a result failure, pretend allowed not modified */
487 if( psaSAT_ccdErrChk() NEQ 0 AND
488 (!(*p_v_allw) AND !(*p_v_not_allw) AND !(*p_v_allw_mdfy)))
489 {
490 memset( env, 0, StructSize );
491 *p_v_allw = TRUE;
492 sim_toolkit_cnf -> stk_cmd.cmd[0] = CCR_ALLW_NO_MDFY;
493 sim_toolkit_cnf -> stk_cmd.cmd[1] = 0;
494 satShrdPrm.stkCmdLen = 2<<3; /* 2 bytes result */
495 }
496 }
497 }
498
499 /* process result */
500
501 if ( *p_v_allw ) p = p_allw;
502 else if( *p_v_not_allw ) p = p_not_allw;
503 else if( *p_v_allw_mdfy ) p = p_allw_mdfy;
504
505
506 satShrdPrm.ntfy = USR_NTF_CC_SIM;
507 cmhSAT_STKUsrNtfy();
508
509 switch( satShrdPrm.SIMCCParm.ccAct )
510 {
511 case( CC_ACT_CAL ):
512
513 if( cmhSAT_ResCalCntrlBySIM( sim_toolkit_cnf -> stk_cmd.cmd, p ))
514 {
515 /* keep primitive for terminal response */
516 satShrdPrm.stkCnfPrim = sim_toolkit_cnf;
517 CCD_END;
518 return;
519 }
520 break;
521
522 case( CC_ACT_SS ):
523
524 if( cmhSAT_ResSSCntrlBySIM( sim_toolkit_cnf -> stk_cmd.cmd, p ))
525 {
526 /* keep primitive for terminal response */
527 satShrdPrm.stkCnfPrim = sim_toolkit_cnf;
528 CCD_END;
529 return;
530 }
531 break;
532
533 case( CC_ACT_USSD ):
534
535 if( cmhSAT_ResUSSDCntrlBySIM( sim_toolkit_cnf -> stk_cmd.cmd, p ))
536 {
537 /* keep primitive for terminal response */
538 /*satShrdPrm.stkCnfPrim = sim_toolkit_cnf;*/
539 CCD_END;
540 return;
541 }
542 break;
543
544 case( SMC_ACT_MO ):
545 if( cmhSAT_ResSMCntrlBySIM( sim_toolkit_cnf -> stk_cmd.cmd, p ))
546 {
547 /* keep primitive for terminal response */
548 /*satShrdPrm.stkCnfPrim = sim_toolkit_cnf;*/
549 CCD_END;
550 return;
551 }
552 break;
553
554 default:
555 TRACE_EVENT("UNEXP CC ACTION IN SAT PARMS");
556 break;
557 }
558 }
559
560 satShrdPrm.SIMCCParm.ccAct = NO_CC_ACT;
561 CCD_END;
562 }
563 }
564
565 /*
566 *-------------------------------------------------------------------
567 * free the primitive buffer
568 *-------------------------------------------------------------------
569 */
570 PFREE (sim_toolkit_cnf);
571
572 }
573
574 /*
575 +-------------------------------------------------------------------+
576 | PROJECT : GSM-PS (6147) MODULE : PSA_SATP |
577 | ROUTINE : psa_sim_file_update_ind |
578 +-------------------------------------------------------------------+
579
580 PURPOSE : processes the FILE_UPDATE_IND primitive send by SIM.
581 It provides a list of updated EFs.
582
583 */
584
585 GLOBAL const void psa_sim_file_update_ind
586 ( T_SIM_FILE_UPDATE_IND *sim_file_update_ind )
587 {
588 SHORT i;
589 BOOL send_confirm_now=TRUE;
590
591 TRACE_FUNCTION ("psa_sim_file_update_ind()");
592
593 /*
594 *-------------------------------------------------------------------
595 * store the primitive and start processing
596 *-------------------------------------------------------------------
597 */
598 satShrdPrm.fu_ind = sim_file_update_ind;
599
600 /*
601 * Broadcast %SIMEF unsolicited event to all interested parties.
602 */
603 for(i=CMD_SRC_LCL;i<CMD_SRC_MAX;i++)
604 {
605 /*
606 * For a source in BAT mode, this event is permanently
607 * enabled. However, it is useful to make it configurable
608 * in ATI/BAT mode in order to ensure that by default
609 * psaSAT_FUConfirm() is called, maintaining compatibility
610 * with existing tests.
611 */
612 #if defined(FF_BAT) && !defined(FF_ATI_BAT)
613 if ((simShrdPrm.SIMEFMode[i] EQ SIMEF_MODE_ON)
614 OR (aci_cmd_src_mode_get(i) EQ CMD_MODE_BAT))
615 #else
616 if (simShrdPrm.SIMEFMode[i] EQ SIMEF_MODE_ON)
617 #endif
618 {
619 /*
620 * As we have reported the EF update, it is not now the
621 * responsibility of this function to send the response
622 * immediately.
623 */
624 send_confirm_now=FALSE;
625
626 R_AT(RAT_P_SIMEF,i)(
627 (SHORT *)sim_file_update_ind->file_id,
628 (UBYTE)sim_file_update_ind->val_nr);
629 }
630 }
631
632 /*
633 * If we didn't report the EF update to anyone we must send
634 * the response now.
635 */
636 if (send_confirm_now NEQ FALSE)
637 psaSAT_FUConfirm (-1, NOT_PRESENT_16BIT);
638 }
639
640 #endif /* #ifdef SIM_TOOLKIT */
641
642 /*==== EOF =========================================================*/