comparison g23m-aci/aci/cmh_smsr.c @ 0:75a11d740a02

initial import of gsm-fw from freecalypso-sw rev 1033:5ab737ac3ad7
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 09 Jun 2016 00:02:41 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:75a11d740a02
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : GSM-PS (6147)
4 | Modul : CMH_SMSR
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 functions which are responsible
18 | for the responses of the protocol stack adapter for
19 | the short message service.
20 +-----------------------------------------------------------------------------
21 */
22
23 #ifndef CMH_SMSR_C
24 #define CMH_SMSR_C
25 #endif
26
27 #include "config.h"
28 #include "fixedconf.h"
29 #include "condat-features.h"
30 #include "aci_conf.h"
31
32 #include "aci_all.h"
33 /*==== INCLUDES ===================================================*/
34 #include "aci_cmh.h"
35 #include "ati_cmd.h"
36 #include "aci_cmd.h"
37
38 #ifdef FAX_AND_DATA
39 #include "aci_fd.h"
40 #endif /* of #ifdef FAX_AND_DATA */
41
42 #ifdef UART
43 #include "dti.h"
44 #include "dti_conn_mng.h"
45 #endif
46
47 #include "aci.h"
48 #include "aci_lst.h"
49 #include "aci_mem.h"
50 #include "psa.h"
51 #include "psa_sms.h"
52 #include "psa_mmi.h"
53 #include "psa_cc.h"
54
55 #include "cmh.h"
56 #include "cmh_sms.h"
57 #include "psa_sim.h"
58 #include "cmh_sim.h"
59 #include "psa_util.h"
60 #include "phb.h"
61
62 #ifdef SIM_TOOLKIT
63 #include "psa_sat.h"
64 #include "cmh_sat.h"
65 #endif /* of SIM_TOOLKIT */
66
67 #if (defined (MFW) AND !defined (FF_MMI_RIV)) OR defined (_CONC_TESTING_) OR defined (SMI)
68 #include "conc_sms.h"
69 #endif /* ##if (defined (MFW) AND !defined (FF_MMI_RIV)) OR defined (_CONC_TESTING_) OR defined (SMI)*/
70
71 #ifdef _CONC_TESTING_
72 #include "aci_mfw.h"
73 #endif
74
75 /*==== CONSTANTS ==================================================*/
76
77 /* TP-User-Data-Header-Indicator (TP-UDHI) */
78 #define UDHI_MASK 0x40
79 #define UDHI_PRESENT 0x40
80 #define UDHI_ABSENT 0x00
81
82 /*==== TYPES ======================================================*/
83
84 /*==== EXPORT =====================================================*/
85
86 /*==== VARIABLES ==================================================*/
87
88 EXTERN T_ACI_LIST *set_prm_list;
89
90 /*==== FUNCTIONS ==================================================*/
91
92 /* Implements Measure # 59 */
93 LOCAL void cmhSMS_SendCbDwnlSIM(UBYTE *data, int data_len);
94 /* Implements Measure # 104 */
95 LOCAL void cmhSMS_ResCSAS(T_ACI_CMD_SRC ownBuf, T_ACI_AT_CMD cmdBuf, USHORT errCode);
96 /* Implements Measure 114 */
97 LOCAL void cmhSMS_ErrRes(T_ACI_CMD_SRC ownBuf, T_ACI_AT_CMD cmdBuf, USHORT cause);
98
99 LOCAL BOOL cmhSMS_cpySTtoSM(T_ACI_CMGL_SM *p_sm,T_MNSMS_READ_CNF * mnsms_read_cnf);
100
101 /* help function for cmhSMS_SMRead to inform user in case of
102 * CCD decoding error with SMS
103 * for this case the T_ACI_SMS_STAT has been extended with a value
104 * of SMS_STAT_Invalid = -2 (e.g to tell BMI to emit "INVALID MESSAGE") */
105 LOCAL void cmhSMS_invalidSMS_notification_to_user(T_MNSMS_READ_CNF * mnsms_read_cnf)
106 {
107 T_ACI_AT_CMD cmdBuf = smsShrdPrm.smsEntStat.curCmd;
108 T_ACI_CMD_SRC ownBuf = smsShrdPrm.smsEntStat.entOwn;
109
110 TRACE_FUNCTION ("cmhSMS_SMRead_invalidSMS_notification_to_user()");
111 if (smsShrdPrm.pDecMsg->stat EQ SMS_STAT_Invalid)
112 {
113 switch( smsShrdPrm.smsEntStat.curCmd )
114 {
115 case ( AT_CMD_CMGR ):
116 {
117 smsShrdPrm.smsEntStat.curCmd = AT_CMD_NONE;
118 smsShrdPrm.owner = (T_OWN)CMD_SRC_NONE;
119 smsShrdPrm.smsEntStat.entOwn =CMD_SRC_NONE;
120 if (smsShrdPrm.rplyCB.cmgr NEQ NULL)
121 {
122 smsShrdPrm.rplyCB.cmgr( smsShrdPrm.pDecMsg, NULL );
123 }
124 R_AT ( RAT_OK, ownBuf) ( cmdBuf );
125 break;
126 }
127 case ( AT_CMD_CMGL ):
128 {
129 R_AT ( RAT_CMGL, smsShrdPrm.smsEntStat.entOwn ) ( smsShrdPrm.pDecMsg ); /* intermediate result */
130 if (mnsms_read_cnf->rec_next NEQ SMS_RECORD_NOT_EXIST)
131 {
132 psaSMS_ReadReq ( smsShrdPrm.mem1, mnsms_read_cnf->rec_next,
133 smsShrdPrm.rdMode, cmglStat );
134 }
135 break;
136 }
137 }
138 }
139 else
140 {
141 /*
142 * SMS decoding failed, but the status has not been set to SMS_STAT_Invalid
143 */
144 TRACE_FUNCTION ("cmhSMS_SMRead_invalidSMS_notification_to_MFW(): [ERR] status not SMS_STAT_Invalid !");
145 }
146 }
147
148
149 #ifdef SIM_TOOLKIT
150 LOCAL void cmhSMS_SATResult (T_ACI_SAT_TERM_RESP *p_resp_data,
151 USHORT cause)
152 {
153 if (GET_CAUSE_ORIGIN_ENTITY(cause) EQ SMSCP_ORIGINATING_ENTITY)
154 { /* CP-CAUSE */
155 p_resp_data->add_content = GET_CAUSE_VALUE(cause) | 0x80;
156 psaSAT_SendTrmResp( RSLT_NTW_UNAB_PROC, p_resp_data );
157 }
158 else
159 { /* RP-CAUSE or other */
160 if (GET_CAUSE_ORIGIN_ENTITY(cause) EQ SMSRP_ORIGINATING_ENTITY)
161 p_resp_data->add_content = GET_CAUSE_VALUE(cause);
162 else
163 p_resp_data->add_content = ADD_NO_CAUSE;
164 psaSAT_SendTrmResp( RSLT_SMS_ERR, p_resp_data);
165 }
166 }
167 #endif /* #ifdef SIM_TOOLKIT */
168
169 /*
170 +-------------------------------------------------------------------+
171 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSR |
172 | STATE : code ROUTINE : cmhSMS_CBMIndication |
173 +-------------------------------------------------------------------+
174
175 PURPOSE : This function is used to notify the command handler of
176 the receiving of a cell broadcast message.
177 */
178 GLOBAL SHORT cmhSMS_CBMIndication ( T_MMI_CBCH_IND * mmi_cbch_ind )
179 {
180 USHORT sn; /* serial number */
181 USHORT mid; /* message identifier */
182 UBYTE dcs; /* data coding scheme */
183 UBYTE page; /* actual page number */
184 UBYTE pages; /* total number of pages */
185 T_ACI_CBM_DATA msg; /* cell broadcast message data */
186 UBYTE idx;
187
188 TRACE_FUNCTION ("cmhSMS_CBMIndication ()");
189
190 /*
191 *-----------------------------------------------------------------
192 * process parameters for new message indication
193 *-----------------------------------------------------------------
194 */
195 sn = ( ( SHORT )mmi_cbch_ind->cbch_msg[0] << 8 ) +
196 mmi_cbch_ind->cbch_msg[1];
197 mid = ( ( SHORT )mmi_cbch_ind->cbch_msg[2] << 8 ) +
198 mmi_cbch_ind->cbch_msg[3];
199 dcs = mmi_cbch_ind->cbch_msg[4];
200 page = ( mmi_cbch_ind->cbch_msg[5] & 0xF0 ) >> 4;
201 pages = ( mmi_cbch_ind->cbch_msg[5] & 0x0F );
202
203 /*
204 *-----------------------------------------------------------------
205 * process message data, expanding from 7 to 8 bit
206 *-----------------------------------------------------------------
207 */
208 cmhSMS_expdSmsCb ( dcs,
209 &mmi_cbch_ind->cbch_msg[CBCH_HEAD_LEN],
210 (UBYTE)(mmi_cbch_ind->cbch_len - CBCH_HEAD_LEN),
211 msg.data, &msg.len );
212
213 /*
214 *-----------------------------------------------------------------
215 * new message indication
216 *-----------------------------------------------------------------
217 */
218 #ifdef FF_MMI_RIV
219 {
220 T_ACI_CMGF_MOD sms_input_mode = CMGF_MOD_NotPresent;
221
222 qAT_PlusCMGF (CMD_SRC_LCL, &sms_input_mode);
223 if (sms_input_mode EQ CMGF_MOD_Pdu)
224 {
225 rAT_PlusCBMPdu (mmi_cbch_ind);
226 }
227 else
228 {
229 R_AT( RAT_CBM, CMD_SRC_LCL )
230 ( sn, mid, dcs, page, pages, &msg );
231 }
232 }
233 #else
234 R_AT( RAT_CBM, CMD_SRC_LCL )
235 ( sn, mid, dcs, page, pages, &msg );
236 #endif
237
238 /* If the SMS shared params indicate no valid source interested in
239 * the SMS indications, the indication is buffered */ /* Issue 25033 */
240 if( smsShrdPrm.smsSrcId EQ CMD_SRC_NONE )
241 {
242 #ifdef DTI
243 T_CNMI_IND ind;
244
245 memcpy (&ind.cbm, mmi_cbch_ind, sizeof(T_MMI_CBCH_IND));
246 cmd_addCnmiNtry ( CNMI_CBM, &ind );
247 #endif
248 }
249 else
250 {
251 #ifdef FF_ATI
252 /* tell any remote source */
253 for( idx = CMD_SRC_LCL+1; idx < CMD_SRC_MAX; idx++ )
254 {
255 if (IS_SRC_USED (idx))
256 {
257 R_AT( RAT_CBM, (T_ACI_CMD_SRC)idx ) ( mmi_cbch_ind );
258 }
259 }
260 #endif
261 }
262
263 return 0;
264 }
265
266 /* Implements Measure#32: Row 1105 */
267 /*
268 +-------------------------------------------------------------------+
269 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSR |
270 | STATE : code ROUTINE : cmhSMS_sdu_buf_print |
271 +-------------------------------------------------------------------+
272
273 PURPOSE : This function will print the sdu_bug contents
274
275 */
276 GLOBAL void cmhSMS_sdu_buf_print ( U8 *buf,
277 USHORT offset )
278 {
279 char trcBuf[80];
280 char *writeP;
281 int count,i,j;
282
283 TRACE_EVENT("buf: ");
284
285 count = offset;
286 for(i=0;i<2;i++)
287 {
288 writeP = trcBuf;
289 for (j=0; j<20; j++, count++)
290 {
291 writeP += sprintf (writeP, " %02X", buf[count]);
292 }
293 *writeP = '\0';
294 TRACE_EVENT(trcBuf);
295 }
296 }
297 /*
298 +-------------------------------------------------------------------+
299 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSR |
300 | STATE : code ROUTINE : cmhSMS_SMSInitState |
301 +-------------------------------------------------------------------+
302
303 PURPOSE : This function is used to handle the
304 SMS_STATE_INITIALISING state.
305 */
306 GLOBAL SHORT cmhSMS_SMSInitState ( T_MNSMS_MESSAGE_IND * mnsms_message_ind )
307 {
308 #if defined SMI OR defined MFW OR defined FF_MMI_RIV OR defined _CONC_TESTING_
309 T_ACI_CMGL_SM sm;
310 T_ACI_SMS_STOR mem; /* holds message storage */
311 UBYTE retCode = TRUE;
312 UBYTE msg_type;
313 #endif /* SMI OR defined MFW */
314
315 #ifdef _CONC_TESTING_
316 #ifndef NTRACE
317 /* Implements Measure#32: Row 1105 */
318 USHORT offset;
319
320 TRACE_EVENT_P1("initstate:rec_num: %d", mnsms_message_ind->rec_num);
321 TRACE_EVENT_P1("initstate:status: %d", mnsms_message_ind->status);
322 offset = mnsms_message_ind->sms_sdu.o_buf>>3;
323 /* Implements Measure#32: Row 1105 */
324 cmhSMS_sdu_buf_print(&(mnsms_message_ind->sms_sdu.buf[0]), offset);
325 #endif
326 #endif
327
328
329 TRACE_FUNCTION ("cmhSMS_SMSInitState()");
330
331
332 switch (mnsms_message_ind->mem_type)
333 {
334 case MEM_ME:
335 if (mnsms_message_ind->rec_num NEQ SMS_RECORD_NOT_EXIST)
336 {
337 smsShrdPrm.aci_sms_parameter.meUsed++;
338 }
339 if (smsShrdPrm.aci_sms_parameter.meTotal EQ 0)
340 {
341 smsShrdPrm.aci_sms_parameter.meTotal = mnsms_message_ind->rec_max;
342 }
343 break;
344 case MEM_SM:
345 if (mnsms_message_ind->rec_num NEQ SMS_RECORD_NOT_EXIST)
346 {
347 smsShrdPrm.aci_sms_parameter.simUsed++;
348 TRACE_EVENT_P1("simUsed: %d", smsShrdPrm.aci_sms_parameter.simUsed);
349 }
350 if (smsShrdPrm.aci_sms_parameter.simTotal EQ 0)
351 {
352 smsShrdPrm.aci_sms_parameter.simTotal = mnsms_message_ind->rec_max;
353 TRACE_EVENT_P1("simTotal: %d", smsShrdPrm.aci_sms_parameter.simTotal);
354 }
355 break;
356 default:
357 TRACE_EVENT("wrong memtype");
358 }
359
360 #if defined SMI OR defined MFW OR defined FF_MMI_RIV OR defined _CONC_TESTING_
361 cmhSMS_getMemCmh ( mnsms_message_ind->mem_type, &mem );
362 cmhSMS_SMSQueryType (&mnsms_message_ind->sms_sdu , &msg_type);
363 memset(&sm,0,sizeof(T_ACI_CMGL_SM) );
364 if(msg_type NEQ TP_MTI_SMS_STATUS_REP)
365 {
366 /* Implements Measure # 110 */
367 retCode = cmhSMS_cpyMsgIndReadCnf (&sm,
368 &mnsms_message_ind->status,
369 &mnsms_message_ind->sms_sdu,
370 mnsms_message_ind->rec_num);
371 }
372 if (retCode EQ FALSE)
373 {
374 TRACE_EVENT("cmhSMS_SMSInitState():[ERR] decoding of SMS");
375 if (sm.stat NEQ SMS_STAT_Invalid)
376 {
377 TRACE_EVENT("cmhSMS_SMSInitState():[ERR] SMS decoding failed, but status not SMS_STAT_Invalid");
378 }
379 }
380
381 #if defined FF_MMI_RIV
382 /* in case of RIV MMI: check if SMBS is enabled for sending also PDU data */
383 if(smsShrdPrm.perccmgf_smbs_mode EQ PERC_SMBS_MOD_ENABLE)
384 {
385 rAT_PlusCMTPdu (mnsms_message_ind);
386 }
387 #endif /* FF_MMI_RIV */
388 //TISH, patch for class 0 SMS when initializing.
389 //start
390 if (mnsms_message_ind->rec_num EQ SMS_RECORD_NOT_EXIST)
391 {
392
393 R_AT( RAT_CMT, CMD_SRC_LCL ) (&sm);
394
395 }
396 else
397 //end
398 R_AT( RAT_CMTI, CMD_SRC_LCL )
399 (mem, sm.msg_ref, &sm);
400 #endif /* defined SMI OR defined MFW OR defined FF_MMI_RIV */
401
402 return 0;
403 }
404
405
406 /*
407 +-------------------------------------------------------------------+
408 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSR |
409 | STATE : code ROUTINE : cmhSMS_SMSDelCnf |
410 +-------------------------------------------------------------------+
411
412 PURPOSE : This function is used to handle MNSMS_DELETE_CNF primitive.
413 */
414 GLOBAL SHORT cmhSMS_SMSDelCnf ( T_MNSMS_DELETE_CNF * mnsms_delete_cnf )
415 {
416 T_ACI_AT_CMD cmdBuf; /* buffers current command */
417 T_ACI_CMD_SRC ownBuf; /* buffers current owner */
418
419 #ifdef _CONC_TESTING_
420 T_ACI_CMD_SRC srcId; /* Hold the request Source ID */
421 T_CONC_INIT_RETURN ret;
422 #endif
423
424 TRACE_FUNCTION ("cmhSMS_SMSDelCnf()");
425
426 /*-------------------------------------------------------------------------*
427 * In R99 one more flag is added in CMGD command which is used to delete *
428 * multiple messages of the same status ( READ, UNSENT, SENT etc ). *
429 * For this purpose the setting of global variables are done, once *
430 * the it is confirmed that all the messages of the same status are *
431 * deleted. *
432 *-------------------------------------------------------------------------*/
433
434 cmdBuf = smsShrdPrm.smsEntStat.curCmd;
435 ownBuf = smsShrdPrm.smsEntStat.entOwn;
436 #ifdef _CONC_TESTING_
437 srcId = smsShrdPrm.smsEntStat.entOwn;
438 #endif
439 #if defined SMI OR defined MFW OR defined FF_MMI_RIV OR defined _CONC_TESTING_
440 SET_OWNBUF_CONC;
441 #endif /*#if defined SMI OR defined MFW*/
442
443
444 if(smsShrdPrm.status > CMGD_DEL_INDEX)
445 {
446 ownBuf = smsShrdPrm.smsEntStat.entOwn;
447 }
448
449 if (IS_CAUSE_INVALID(mnsms_delete_cnf->cause)) /* no error */
450 {
451 /* Check if the mnsms_delete_req for deleting messages of particular
452 status returned indicating no messages of requested status. Note
453 that in this case also we return OK to the user */
454 if(mnsms_delete_cnf->rec_num NEQ 0)
455 {
456 switch (mnsms_delete_cnf->mem_type)
457 {
458 case MEM_ME:
459 smsShrdPrm.aci_sms_parameter.meUsed--;
460 break;
461 case MEM_SM:
462 smsShrdPrm.aci_sms_parameter.simUsed--;
463 break;
464 default:
465 TRACE_EVENT("wrong memtype");
466 return AT_FAIL;
467 }
468 }
469 /*-----------------------------------------------------------------------*
470 * The below code is the new code added on 07/08/2003 due to the new *
471 * flag for CMGD command as mentioned in R99. This flag handles the *
472 * deletion of multiple messages. The deletion of concatination is *
473 * handled with different way other than handling normal indexed *
474 * messages. The deletion of normal concatination messages is done as *
475 * in the exiting code. But deletion of concatination message is handled *
476 * in the different way when delete flag is greater than ZERO. If the *
477 * delete flag in CMGD command is greater than ZERO, then there is no *
478 * concatination check is done. After receiving the response from SMS *
479 * with the deleted messages number, then we will do the concatination *
480 * check. If CONC_NEEDED flag is set, then we will clear the *
481 * concatinated list from the ACI. If CONC_NOT_NEEDED is set then check *
482 * for the next record values, if it is greater than ZERO then send one *
483 * more request for SMS to delete that message and repeat the above *
484 * process untill ACI recive's the next record values as ZERO. *
485 *-----------------------------------------------------------------------*/
486
487 if( smsShrdPrm.status > CMGD_DEL_INDEX AND
488 mnsms_delete_cnf->rec_num NEQ 0)
489 {
490 #if defined _CONC_TESTING_
491 /*-----------------------------------------------------------------*
492 * Check for the concatination *
493 *-----------------------------------------------------------------*/
494
495 ret= concSMS_initDeleteFromMem (srcId, mnsms_delete_cnf->rec_num);
496
497 if( ret EQ CONC_NEEDED )
498 {
499 SET_CONC;
500 concSMS_DeleteConcList();
501 }
502 #endif
503 if ( mnsms_delete_cnf->delete_rec_next NEQ 0 )
504 {
505 cmhSMS_SendDelete_Req (mnsms_delete_cnf->delete_rec_next,
506 smsShrdPrm.status);
507 return 0;
508 }
509 }
510 /*-----------------------------------------------------------------------*
511 * Reset the command context *
512 *-----------------------------------------------------------------------*/
513
514 smsShrdPrm.smsEntStat.curCmd = AT_CMD_NONE;
515 smsShrdPrm.smsEntStat.entOwn = CMD_SRC_NONE;
516 smsShrdPrm.owner = (T_OWN)CMD_SRC_NONE;
517
518 /*-----------------------------------------------------------------------*
519 * The below code is used to handle the existing way where there is no *
520 * delete falg is set ( i.e. delete flag == 0 ) *
521 *-----------------------------------------------------------------------*/
522
523 #if defined SMI OR defined MFW OR defined FF_MMI_RIV
524 if (ownBuf EQ CMD_SRC_LCL)
525 {
526 if( smsShrdPrm.status EQ CMGD_DEL_INDEX )
527 {
528 #ifdef _CONC_TESTING_
529 if (!ISSET_CONC)
530 {
531 #endif /* _CONC_TESTING_ */
532 TRACE_EVENT("you just erased a normal SMS !");
533 if(smsShrdPrm.rplyCB.cmgd NEQ NULL)
534 {
535 smsShrdPrm.rplyCB.cmgd( );
536 }
537 R_AT ( RAT_OK, ownBuf ) ( cmdBuf );
538 #ifdef _CONC_TESTING_
539 }
540 else
541 {
542 /*-----------------------------------------------------------------*
543 * Looks just about the same BUT: ISSET_CONC could be unsent *
544 * in RAT_CMGD, so let this after checking ISSET_CONC *
545 *-----------------------------------------------------------------*/
546
547 if(smsShrdPrm.rplyCB.cmgd NEQ NULL)
548 {
549 smsShrdPrm.rplyCB.cmgd( );
550 }
551 }
552 #endif /* _CONC_TESTING_ */
553 }
554 else
555 {
556 R_AT ( RAT_OK, ownBuf ) ( cmdBuf );
557 if(smsShrdPrm.rplyCB.cmgd NEQ NULL)
558 {
559 smsShrdPrm.rplyCB.cmgd( );
560 }
561
562 #if defined FF_MMI_RIV
563 R_AT ( RAT_OK, ownBuf ) ( cmdBuf );
564 #else
565 /* GPF-MMI */
566 #ifdef _CONC_TESTING_
567 if (!ISSET_CONC)
568 #endif /* _CONC_TESTING_ */
569 R_AT ( RAT_OK, ownBuf ) ( cmdBuf );
570 }
571 #endif
572 }
573 else /* if (ownBuf EQ CMD_SRC_LCL) */
574 #endif /*defined MFW OR defined FF_MMI_RIV*/
575 {
576 R_AT ( RAT_OK, ownBuf ) ( cmdBuf );
577 }
578 }
579 else
580 {
581 /*-----------------------------------------------------------------------*
582 * Reset the command context *
583 *-----------------------------------------------------------------------*/
584
585 smsShrdPrm.smsEntStat.curCmd = AT_CMD_NONE;
586 smsShrdPrm.smsEntStat.entOwn = CMD_SRC_NONE;
587 smsShrdPrm.owner = (T_OWN)CMD_SRC_NONE;
588
589 if (smsShrdPrm.errorCB NEQ NULL)
590 {
591 smsShrdPrm.errorCB
592 (
593 cmdBuf,
594 cmhSMS_GetCmsFromSms(mnsms_delete_cnf->cause),
595 NULL
596 );
597 }
598 else
599 {
600 R_AT ( RAT_CMS, ownBuf ) ( cmdBuf, cmhSMS_GetCmsFromSms(mnsms_delete_cnf->cause), NULL );
601 }
602 }
603 /* Reset status flag to CMGD_DEL_INDEX = 0 */
604 smsShrdPrm.status = CMGD_DEL_INDEX;
605 return 0;
606 }
607
608
609 /*
610 +-------------------------------------------------------------------+
611 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSR |
612 | STATE : code ROUTINE : cmhSMS_SMSStoCnf |
613 +-------------------------------------------------------------------+
614
615 PURPOSE : This function is used to handle MNSMS_STORE_CNF primitive.
616 */
617 GLOBAL SHORT cmhSMS_SMSStoCnf ( T_MNSMS_STORE_CNF * mnsms_store_cnf )
618 {
619 T_ACI_AT_CMD cmdBuf; /* buffers current command */
620 T_ACI_CMD_SRC ownBuf; /* buffers current owner */
621
622 TRACE_FUNCTION ("cmhSMS_SMSStoCnf()");
623
624 /*
625 *-----------------------------------------------------------------
626 * reset the command context
627 *-----------------------------------------------------------------
628 */
629 cmdBuf = smsShrdPrm.smsEntStat.curCmd;
630 smsShrdPrm.smsEntStat.curCmd = AT_CMD_NONE;
631 ownBuf = smsShrdPrm.smsEntStat.entOwn;
632
633 #ifdef _CONC_TESTING_
634 /* this is only for testing */
635 SET_OWNBUF_CONC;
636 #endif
637
638 smsShrdPrm.smsEntStat.entOwn = CMD_SRC_NONE;
639 smsShrdPrm.owner = (T_OWN)CMD_SRC_NONE;
640
641 /* Check for current cmd is CMGMDU */
642 if ( cmdBuf EQ AT_CMD_P_CMGMDU )
643 {
644 if (IS_CAUSE_INVALID(mnsms_store_cnf->cause))
645 {
646 #if defined MFW OR defined FF_MMI_RIV OR defined _CONC_TESTING_
647 if (ownBuf EQ CMD_SRC_LCL)
648 {
649 if(smsShrdPrm.rplyCB.cmgmdu NEQ NULL)
650 {
651 smsShrdPrm.rplyCB.cmgmdu();
652 }
653 }
654 else
655 #endif /*#if defined MFW OR defined FF_MMI_RIV OR defined _CONC_TESTING_ */
656 {
657 R_AT ( RAT_OK, ownBuf ) ( cmdBuf );
658 }
659 }
660 else
661 {
662 if ( ownBuf NEQ CMD_SRC_LCL )
663 R_AT ( RAT_CMS, ownBuf )
664 (
665 cmdBuf,
666 cmhSMS_GetCmsFromSms(mnsms_store_cnf->cause),
667 NULL
668 );
669 return -1;
670 }
671 }
672 else if (IS_CAUSE_INVALID(mnsms_store_cnf->cause))
673 {
674 switch (mnsms_store_cnf->mem_type)
675 {
676 case MEM_ME:
677 smsShrdPrm.aci_sms_parameter.meUsed++;
678 break;
679 case MEM_SM:
680 smsShrdPrm.aci_sms_parameter.simUsed++;
681 break;
682 default:
683 TRACE_EVENT("incorrect memtype");
684 return AT_FAIL;
685 }
686 #ifdef FF_ATI
687 /* "internal storage" handling -> storing from CNMI-buf to SIM/MS */
688 if( smsShrdPrm.uiInternalSmsStorage NEQ CMD_SRC_NONE )
689 {
690 if(mnsms_store_cnf->cause NEQ SMS_NO_ERROR)
691 {
692 TRACE_EVENT("cmhSMS_SMSStoCnf() : error at internal SMS storaging");
693 cmd_clearCnmiBuf(); /* clear CNMI buffer */
694 smsShrdPrm.uiInternalSmsStorage = CMD_SRC_NONE;
695 return -1;
696 }
697
698 /* storing was succesful -> clear the stored msg. in CNMI buf */
699 cmd_clearFirstCnmiMessage();
700
701 /* try with the next msg. in CNMI-buf */
702 if( cmd_storeNextCnmiBufMsgToSim() NEQ TRUE ) /* do nothing if no more Msg's in CNMI buffer */
703 { /* no more messagees could be sent */
704 smsShrdPrm.uiInternalSmsStorage = CMD_SRC_NONE;
705 }
706 return 0; /* returns immediately if internal storage is running */
707 }
708 #endif /* FF_ATI */
709 #if defined MFW OR defined FF_MMI_RIV OR defined _CONC_TESTING_
710 if (ownBuf EQ CMD_SRC_LCL)
711 {
712 if(smsShrdPrm.rplyCB.cmgw NEQ NULL)
713 {
714 smsShrdPrm.rplyCB.cmgw( mnsms_store_cnf->rec_num, 1, mnsms_store_cnf->mem_type);
715 }
716 #if defined FF_MMI_RIV
717 R_AT ( RAT_OK, ownBuf ) ( cmdBuf );
718 #else
719 /* GPF-MMI */
720 if (!ISSET_CONC)
721 {
722 TRACE_EVENT("you just wrote a normal SMS !");
723 R_AT ( RAT_OK, ownBuf ) ( cmdBuf );
724 }
725 #endif /*#if !defined FF_MMI_RIV*/
726 }
727 else
728 #endif /*#if defined MFW OR defined FF_MMI_RIV*/
729 {
730 R_AT ( RAT_CMGW, ownBuf ) ( mnsms_store_cnf->rec_num );
731 R_AT ( RAT_OK, ownBuf ) ( cmdBuf );
732 /* inform BMI */
733 cmh_logRslt ( ownBuf, RAT_OK, AT_CMD_CMGW, mnsms_store_cnf->rec_num,
734 BS_SPEED_NotPresent,CME_ERR_NotPresent);
735 }
736 }
737 else
738 {
739 if( smsShrdPrm.uiInternalSmsStorage NEQ CMD_SRC_NONE )
740 {
741 smsShrdPrm.uiInternalSmsStorage = CMD_SRC_NONE;
742 return 0;
743 }
744
745 /* Implements Measure 114 */
746 cmhSMS_ErrRes(ownBuf, cmdBuf, mnsms_store_cnf->cause);
747 }
748 return 0;
749 }
750
751
752
753 /*
754 +-------------------------------------------------------------------+
755 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSR |
756 | STATE : code ROUTINE : cmhSMS_SMSSbmCnf |
757 +-------------------------------------------------------------------+
758
759 PURPOSE : This function is used to handle MNSMS_SUBMIT_CNF primitive.
760 */
761 GLOBAL SHORT cmhSMS_SMSSbmCnf ( T_MNSMS_SUBMIT_CNF * mnsms_submit_cnf )
762 {
763 T_ACI_AT_CMD cmdBuf; /* buffers current command */
764 T_ACI_CMD_SRC ownBuf; /* buffers current owner */
765 #ifdef SIM_TOOLKIT
766 T_ACI_SAT_TERM_RESP resp_data;
767 #endif
768
769
770 #ifdef _CONC_TESTING_
771 #ifndef NTRACE
772 /* Implements Measure#32: Row 1105 */
773 USHORT offset;
774
775 TRACE_EVENT_P1("cause: %d", mnsms_submit_cnf->cause);
776 offset = mnsms_submit_cnf->sms_sdu.o_buf>>3;
777 /* Implements Measure#32: Row 1105 */
778 cmhSMS_sdu_buf_print(&(mnsms_submit_cnf->sms_sdu.buf[0]), offset);
779 #endif
780 #endif
781
782 TRACE_FUNCTION ("cmhSMS_SMSSbmCnf()");
783
784 /*
785 *-----------------------------------------------------------------
786 * reset the command context
787 *-----------------------------------------------------------------
788 */
789 cmdBuf = smsShrdPrm.smsEntStat.curCmd;
790 smsShrdPrm.smsEntStat.curCmd = AT_CMD_NONE;
791
792 ownBuf = smsShrdPrm.smsEntStat.entOwn;
793
794 #ifdef _CONC_TESTING_
795 /* this is only for testing */
796 SET_OWNBUF_CONC;
797 #endif
798 smsShrdPrm.smsEntStat.entOwn = CMD_SRC_NONE;
799 smsShrdPrm.owner = (T_OWN)CMD_SRC_NONE;
800
801 #ifdef SIM_TOOLKIT
802 psaSAT_InitTrmResp( &resp_data );
803 #endif
804
805 if (IS_CAUSE_INVALID(mnsms_submit_cnf->cause))
806 {
807 #ifdef REL99
808 /* Since message transmission is successful, set the manual
809 retransmission flag as FALSE */
810 smsShrdPrm.is_msg_present_for_retrans = FALSE;
811 #endif
812 smsShrdPrm.aci_sms_parameter.snd_msg_ref = mnsms_submit_cnf->tp_mr;
813 switch (cmdBuf)
814 {
815 case( AT_CMD_CMSS ):
816 #if defined MFW OR defined FF_MMI_RIV OR defined _CONC_TESTING_
817 if (ownBuf EQ CMD_SRC_LCL)
818 {
819 if(smsShrdPrm.rplyCB.cmss NEQ NULL)
820 {
821 smsShrdPrm.rplyCB.cmss( mnsms_submit_cnf->tp_mr, 1 );
822 }
823 #if defined FF_MMI_RIV
824 R_AT ( RAT_OK, ownBuf ) ( cmdBuf );
825 #else
826 if (!ISSET_CONC)
827 {
828 R_AT ( RAT_OK, ownBuf ) ( cmdBuf );
829 }
830 #endif /* FF_MMI_RIV */
831 }
832 else /* if (ownBuf EQ CMD_SRC_LCL) */
833 #endif /*#if defined MFW OR defined FF_MMI_RIV*/
834 {
835 R_AT ( RAT_CMSS, ownBuf ) ( mnsms_submit_cnf );
836 R_AT ( RAT_OK, ownBuf ) ( cmdBuf );
837 /* inform BMI */
838 cmh_logRslt ( ownBuf, RAT_OK, AT_CMD_CMSS, mnsms_submit_cnf->rec_num,
839 BS_SPEED_NotPresent,CME_ERR_NotPresent );
840 }
841 break;
842 case( AT_CMD_CMGS ):
843 #if defined (SIM_TOOLKIT)
844 if (ownBuf EQ ((T_ACI_CMD_SRC)OWN_SRC_SAT))
845 {
846 psaSAT_SendTrmResp( RSLT_PERF_SUCCESS, &resp_data );
847 break;
848 }
849 #endif
850 if (mnsms_submit_cnf->rec_num NEQ SMS_RECORD_NOT_EXIST)
851 {
852 switch (mnsms_submit_cnf->mem_type)
853 {
854 case MEM_ME:
855 smsShrdPrm.aci_sms_parameter.meUsed++;
856 break;
857 case MEM_SM:
858 smsShrdPrm.aci_sms_parameter.simUsed++;
859 break;
860 default:
861 TRACE_EVENT("incorrect memtype");
862 return AT_FAIL;
863 }
864 }
865 #if defined MFW OR defined FF_MMI_RIV OR defined _CONC_TESTING_
866 if (ownBuf EQ CMD_SRC_LCL)
867 {
868 if(smsShrdPrm.rplyCB.cmgs NEQ NULL)
869 {
870 smsShrdPrm.rplyCB.cmgs( mnsms_submit_cnf->tp_mr, 1 );
871 }
872 #if defined FF_MMI_RIV
873 R_AT ( RAT_OK, ownBuf ) ( cmdBuf );
874 #else
875 if (!ISSET_CONC)
876 {
877 R_AT ( RAT_OK, ownBuf ) ( cmdBuf );
878 }
879 #endif /* FF_MMI_RIV */
880 }
881 else /* if (ownBuf EQ CMD_SRC_LCL) */
882 #endif /*#if defined MFW OR defined FF_MMI_RIV*/
883 {
884 R_AT ( RAT_CMGS, ownBuf ) ( mnsms_submit_cnf );
885 R_AT ( RAT_OK, ownBuf ) ( cmdBuf );
886 /* inform BMI */
887 cmh_logRslt ( ownBuf, RAT_OK, AT_CMD_CMGS, mnsms_submit_cnf->rec_num,
888 BS_SPEED_NotPresent,CME_ERR_NotPresent );
889 }
890 } /* switch */
891 }
892 else /* if (mnsms_submit_cnf->rslt_type EQ SMS_RT_NON) */
893 {
894 #if defined (SIM_TOOLKIT)
895 if (ownBuf EQ ((T_ACI_CMD_SRC)OWN_SRC_SAT))
896 {
897 #ifdef REL99
898 /* Manual retransmission is not allowed when last failed message
899 was sent from SAT */
900 smsShrdPrm.is_msg_present_for_retrans = FALSE;
901 #endif /* REL99 */
902 cmhSMS_SATResult (&resp_data, mnsms_submit_cnf->cause);
903 }
904 #endif
905
906 #ifdef REL99
907 #if defined _CONC_TESTING_
908 if (ISSET_CONC)
909 {
910 /* Manual retransmission is not allowed when last failed message
911 is part of a long message */
912 smsShrdPrm.is_msg_present_for_retrans = FALSE;
913 }
914 else
915 #endif
916 {
917 /* Last failed message is available for retransmission */
918 smsShrdPrm.is_msg_present_for_retrans = TRUE;
919 }
920 #endif /* REL99 */
921
922 /* Implements Measure 114 */
923 cmhSMS_ErrRes (ownBuf, cmdBuf, mnsms_submit_cnf->cause);
924 }
925 return 0;
926 }
927
928 /*
929 +-------------------------------------------------------------------+
930 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSR |
931 | STATE : code ROUTINE : cmhSMS_SMSCmdCnf |
932 +-------------------------------------------------------------------+
933
934 PURPOSE : This function is used to handle MNSMS_COMMAND_CNF primitive.
935 */
936 GLOBAL SHORT cmhSMS_SMSCmdCnf ( T_MNSMS_COMMAND_CNF * mnsms_command_cnf )
937 {
938 T_ACI_AT_CMD cmdBuf; /* buffers current command */
939 T_ACI_CMD_SRC ownBuf; /* buffers current owner */
940 #ifdef SIM_TOOLKIT
941 T_ACI_SAT_TERM_RESP resp_data;
942 psaSAT_InitTrmResp( &resp_data );
943 #endif
944
945 TRACE_FUNCTION ("cmhSMS_SMSCmdCnf()");
946
947
948 /*
949 *-----------------------------------------------------------------
950 * reset the command context
951 *-----------------------------------------------------------------
952 */
953 cmdBuf = smsShrdPrm.smsEntStat.curCmd;
954 smsShrdPrm.smsEntStat.curCmd = AT_CMD_NONE;
955
956 ownBuf = smsShrdPrm.smsEntStat.entOwn;
957
958 smsShrdPrm.smsEntStat.entOwn = CMD_SRC_NONE;
959 smsShrdPrm.owner = (T_OWN)CMD_SRC_NONE;
960
961 if (IS_CAUSE_INVALID(mnsms_command_cnf->cause))
962 {
963 #ifdef REL99
964 /* Since message transmission is successful, set the manual
965 retransmission flag as FALSE */
966 smsShrdPrm.is_msg_present_for_retrans = FALSE;
967 #endif /* REL99 */
968 #ifdef _CONC_TESTING_
969 /* this is only for testing */
970 SET_OWNBUF_CONC;
971 #endif
972
973 #if defined (SIM_TOOLKIT)
974 if (ownBuf EQ ((T_ACI_CMD_SRC)OWN_SRC_SAT))
975 {
976 psaSAT_SendTrmResp( RSLT_PERF_SUCCESS, &resp_data );
977 }
978 #endif
979 #if defined MFW OR defined FF_MMI_RIV OR defined _CONC_TESTING_
980 if (ownBuf EQ CMD_SRC_LCL)
981 {
982 if(smsShrdPrm.rplyCB.cmgc NEQ NULL)
983 {
984 smsShrdPrm.rplyCB.cmgc( mnsms_command_cnf->tp_mr );
985 }
986 #if defined FF_MMI_RIV
987 R_AT ( RAT_OK, ownBuf ) ( cmdBuf );
988 #else
989 if (!ISSET_CONC)
990 {
991 R_AT ( RAT_OK, ownBuf ) ( cmdBuf );
992 }
993 #endif /*!defined FF_MMI_RIV*/
994 }
995 else /* if (ownBuf EQ CMD_SRC_LCL) */
996 #endif /*defined MFW OR defined FF_MMI_RIV*/
997 {
998 R_AT ( RAT_CMGC, ownBuf ) ( mnsms_command_cnf );
999 R_AT ( RAT_OK, ownBuf ) ( cmdBuf );
1000 /* inform BMI */
1001 /* This does not make much sense, but nice to have it for future requests */
1002 /* cmh_logRslt ( ownBuf, RAT_OK, AT_CMD_CMGC, -1, -1, -1 ); */
1003 }
1004
1005 }
1006 else
1007 {
1008 #if defined (SIM_TOOLKIT)
1009 if (ownBuf EQ ((T_ACI_CMD_SRC)OWN_SRC_SAT))
1010 {
1011 #ifdef REL99
1012 /* Manual retransmission is not allowed when last failed message
1013 was sent from SAT */
1014 smsShrdPrm.is_msg_present_for_retrans = FALSE;
1015 #endif /* REL99 */
1016 cmhSMS_SATResult (&resp_data, mnsms_command_cnf->cause);
1017 }
1018 #endif
1019
1020 #ifdef REL99
1021 #if defined _CONC_TESTING_
1022 if (ISSET_CONC)
1023 {
1024 /* Manual retransmission is not allowed when last failed message
1025 is part of a long message */
1026 smsShrdPrm.is_msg_present_for_retrans = FALSE;
1027 }
1028 else
1029 #endif
1030 {
1031 /* Last failed message is available for retransmission */
1032 smsShrdPrm.is_msg_present_for_retrans = TRUE;
1033 }
1034 #endif /* REL99 */
1035
1036 #ifdef REL99
1037 if (ownBuf NEQ (T_ACI_CMD_SRC)OWN_SRC_SAT)
1038 #endif
1039
1040
1041 R_AT ( RAT_CMS, ownBuf )
1042 (
1043 cmdBuf,
1044 cmhSMS_GetCmsFromSms(mnsms_command_cnf->cause),
1045 NULL
1046 );
1047 }
1048 return 0;
1049 }
1050
1051 #ifdef REL99
1052 /*
1053 +-------------------------------------------------------------------+
1054 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSR |
1055 | STATE : code ROUTINE : cmhSMS_SMSRetransCnf |
1056 +-------------------------------------------------------------------+
1057
1058 PURPOSE : This function is used to handle MNSMS_RETRANS_CNF primitive.
1059 */
1060 GLOBAL SHORT cmhSMS_SMSRetransCnf ( T_MNSMS_RETRANS_CNF * mnsms_retrans_cnf )
1061 {
1062 T_ACI_AT_CMD cmdBuf; /* buffers current command */
1063 T_ACI_CMD_SRC ownBuf; /* buffers current owner */
1064
1065 TRACE_FUNCTION ("cmhSMS_SMSRetransCnf()");
1066
1067 /*
1068 *-----------------------------------------------------------------
1069 * reset the command context
1070 *-----------------------------------------------------------------
1071 */
1072 cmdBuf = smsShrdPrm.smsEntStat.curCmd;
1073 smsShrdPrm.smsEntStat.curCmd = AT_CMD_NONE;
1074
1075 ownBuf = smsShrdPrm.smsEntStat.entOwn;
1076
1077 smsShrdPrm.smsEntStat.entOwn = CMD_SRC_NONE;
1078 smsShrdPrm.owner = OWN_SRC_INV;
1079
1080 if (IS_CAUSE_INVALID(mnsms_retrans_cnf->cause))
1081 {
1082 /* Since message transmission is successful, set the manual
1083 retransmission flag as FALSE */
1084 smsShrdPrm.is_msg_present_for_retrans = FALSE;
1085
1086 smsShrdPrm.aci_sms_parameter.snd_msg_ref = mnsms_retrans_cnf->tp_mr;
1087
1088 if (mnsms_retrans_cnf->rec_num NEQ SMS_RECORD_NOT_EXIST)
1089 {
1090 switch (mnsms_retrans_cnf->mem_type)
1091 {
1092 case MEM_ME:
1093 smsShrdPrm.aci_sms_parameter.meUsed++;
1094 break;
1095 case MEM_SM:
1096 smsShrdPrm.aci_sms_parameter.simUsed++;
1097 break;
1098 default:
1099 TRACE_EVENT("incorrect memtype");
1100 return AT_FAIL;
1101 }
1102 }
1103 #if defined MFW OR defined FF_MMI_RIV OR defined _CONC_TESTING_
1104 if (ownBuf EQ CMD_SRC_LCL)
1105 {
1106 if (smsShrdPrm.rplyCB.cmgrs NEQ NULL)
1107 {
1108 smsShrdPrm.rplyCB.cmgrs( CMGRS_MODE_MANUAL_RETRANS,
1109 mnsms_retrans_cnf->tp_mr,
1110 NOT_PRESENT_8BIT, NOT_PRESENT_8BIT);
1111 }
1112 R_AT ( RAT_OK, ownBuf ) ( cmdBuf );
1113 }
1114 else /* if (ownBuf EQ CMD_SRC_LCL) */
1115 #endif /*#if defined MFW OR defined FF_MMI_RIV OR defined _CONC_TESTING_*/
1116 {
1117 R_AT ( RAT_P_CMGRS, ownBuf ) ( CMGRS_MODE_MANUAL_RETRANS,
1118 mnsms_retrans_cnf, NULL );
1119 R_AT ( RAT_OK, ownBuf ) ( cmdBuf );
1120 }
1121 }
1122 else /* if (IS_CAUSE_INVALID(mnsms_retrans_cnf->cause)) */
1123 {
1124 if (ownBuf EQ CMD_SRC_LCL)
1125 {
1126 if (smsShrdPrm.errorCB NEQ NULL)
1127 {
1128 smsShrdPrm.errorCB
1129 (
1130 cmdBuf,
1131 cmhSMS_GetCmsFromSms(mnsms_retrans_cnf->cause),
1132 NULL
1133 );
1134 }
1135 }
1136 else if (ownBuf NEQ (T_ACI_CMD_SRC)OWN_SRC_SAT)
1137 {
1138 R_AT ( RAT_CMS, ownBuf )
1139 (
1140 cmdBuf,
1141 cmhSMS_GetCmsFromSms(mnsms_retrans_cnf->cause),
1142 NULL
1143 );
1144 }
1145 }
1146 return 0;
1147 }
1148
1149 /*
1150 +-------------------------------------------------------------------+
1151 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSR |
1152 | STATE : code ROUTINE : cmhSMS_SMSSendProgInd |
1153 +-------------------------------------------------------------------+
1154
1155 PURPOSE : This function is used to handle MNSMS_SEND_PROG_IND primitive.
1156 */
1157
1158 GLOBAL SHORT cmhSMS_SMSSendProgInd (T_MNSMS_SEND_PROG_IND * mnsms_send_prog_ind)
1159 {
1160 T_ACI_CMD_SRC ownBuf; /* buffers current owner */
1161
1162 TRACE_FUNCTION ("cmhSMS_SMSSendProgInd()");
1163
1164 ownBuf = smsShrdPrm.smsEntStat.entOwn;
1165
1166 #if defined (MFW) OR defined (FF_MMI_RIV) OR defined (_CONC_TESTING_)
1167 if (ownBuf EQ CMD_SRC_LCL)
1168 {
1169 rAT_PercentCMGRS( CMGRS_MODE_ENABLE_AUTO_RETRANS, NOT_PRESENT_8BIT,
1170 mnsms_send_prog_ind->resend_count,
1171 mnsms_send_prog_ind->max_retrans);
1172 }
1173 else
1174 #endif /*#if defined MFW OR defined FF_MMI_RIV OR defined _CONC_TESTING_*/
1175 {
1176 R_AT ( RAT_P_CMGRS, ownBuf ) ( CMGRS_MODE_ENABLE_AUTO_RETRANS,
1177 NULL,
1178 mnsms_send_prog_ind );
1179 }
1180 return 0;
1181 }
1182 #endif /* REl99 */
1183
1184
1185 /*
1186 +-------------------------------------------------------------------+
1187 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSR |
1188 | STATE : code ROUTINE : cmhSMS_SMSErrorInd |
1189 +-------------------------------------------------------------------+
1190
1191 PURPOSE : This function is used to handle MNSMS_ERROR_IND primitive.
1192 */
1193 GLOBAL SHORT cmhSMS_SMSErrorInd ( T_MNSMS_ERROR_IND * mnsms_error_ind )
1194 {
1195 T_ACI_MM_CIND_VAL_TYPE sIndValues;
1196 int i;
1197
1198 TRACE_FUNCTION ("cmhSMS_SMSErrorInd()");
1199
1200 TRACE_EVENT_P1("MNSMS_ERROR_IND: 0x%4.4X", (int)mnsms_error_ind->cause);
1201
1202 if( (mnsms_error_ind->cause NEQ SMS_CAUSE_MEM_FULL) AND
1203 (mnsms_error_ind->cause NEQ SMS_CAUSE_MEM_AVAIL) )
1204 {
1205 smsShrdPrm.cnma_ack_expected = FALSE;
1206 cmhSMS_resetMtDsCnmiParam();
1207 }
1208 else
1209 { /* process the SMS memory full/avail indication */
1210 sIndValues.sCindSmsFullParam = (mnsms_error_ind->cause EQ SMS_CAUSE_MEM_AVAIL)
1211 ? CIND_SMSFULL_INDICATOR_MEMAVAIL
1212 : CIND_SMSFULL_INDICATOR_MEMFULL;
1213 sIndValues.sCindSignalParam = CIND_SIGNAL_INDICATOR_INVALID;
1214
1215 for( i = CMD_SRC_LCL; i < CMD_SRC_MAX; i++)
1216 {
1217 if( ((cmhPrm[i].mmCmdPrm.sIndicationParam.sMmCINDSettings.sCindSmsFullParam EQ CIND_SMSFULL_INDICATOR_MEMFULL) AND
1218 (cmhPrm[i].mmCmdPrm.sIndicationParam.sMmCMERSettings.sCmerIndParam EQ CMER_INDICATOR_2)) OR
1219 ((cmhPrm[i].mmCmdPrm.sIndicationParam.sMmCINDSettings.sCindSmsFullParam <= CIND_SMSFULL_INDICATOR_MEMAVAIL) AND
1220 (cmhPrm[i].mmCmdPrm.sIndicationParam.sMmCMERSettings.sCmerIndParam EQ CMER_INDICATOR_1)) )
1221 { /* process the service of +CIEV */
1222 TRACE_EVENT("send +CIEV (SMS-full/avail)");
1223 R_AT (RAT_CIEV, (T_ACI_CMD_SRC)i) ( sIndValues, cmhPrm[i].mmCmdPrm.sIndicationParam.sMmCMERSettings );
1224 }
1225 }
1226 }
1227 return 0;
1228 }
1229
1230 /*
1231 +-------------------------------------------------------------------+
1232 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSR |
1233 | STATE : code ROUTINE : cmhSMS_SMSDeliver |
1234 +-------------------------------------------------------------------+
1235
1236 PURPOSE : This function is used to notify the command handler of
1237 the receiving of a SMS-DELIVER.
1238 */
1239 #ifndef NTRACE
1240 LOCAL void trace_SMSDeliver ( T_MNSMS_MESSAGE_IND * mnsms_message_ind )
1241 {
1242 #ifdef _CONC_TESTING_
1243
1244 /* Implements Measure#32: Row 1105 */
1245 USHORT offset;
1246
1247 TRACE_FUNCTION ("trace_SMSDeliver");
1248
1249 TRACE_EVENT_P1("cmt:bitoffset:%d", mnsms_message_ind->sms_sdu.o_buf);
1250 TRACE_EVENT_P1("cmt:lenght:%d", mnsms_message_ind->sms_sdu.l_buf);
1251 offset = mnsms_message_ind->sms_sdu.o_buf>>3;
1252 /* Implements Measure#32: Row 1105 */
1253 cmhSMS_sdu_buf_print(&(mnsms_message_ind->sms_sdu.buf[0]), offset);
1254 #endif
1255 }
1256 #endif
1257
1258 #if defined SMI OR defined MFW OR defined FF_MMI_RIV
1259 LOCAL void rAT_SMS_Deliver(T_MNSMS_MESSAGE_IND * mnsms_message_ind, T_ACI_CMGL_SM *p_sm)
1260 {
1261 #ifdef FF_MMI_RIV
1262 T_ACI_CMGF_MOD sms_input_mode = CMGF_MOD_NotPresent;
1263 #endif /* FF_MMI_RIV */
1264
1265 TRACE_FUNCTION ("rAT_SMS_Deliver");
1266
1267 #ifdef FF_MMI_RIV
1268 if(smsShrdPrm.perccmgf_smbs_mode EQ PERC_SMBS_MOD_ENABLE)
1269 {
1270 /*send both formats*/
1271 rAT_PlusCMTPdu (mnsms_message_ind);
1272 R_AT( RAT_CMT, CMD_SRC_LCL ) (p_sm);
1273 return;
1274 }
1275
1276 /* else: no SMBS enabled, CMGF mode decides */
1277 qAT_PlusCMGF (CMD_SRC_LCL, &sms_input_mode);
1278 if (sms_input_mode EQ CMGF_MOD_Pdu)
1279 {
1280 rAT_PlusCMTPdu (mnsms_message_ind);
1281 }
1282 else
1283 {
1284 R_AT( RAT_CMT, CMD_SRC_LCL ) (p_sm);
1285 }
1286 return;
1287 #endif /* FF_MMI_RIV */
1288
1289 /* if GPF MMI call usual callback */
1290 R_AT( RAT_CMT, CMD_SRC_LCL ) (p_sm);
1291 }
1292 #endif /* SMI OR defined MFW OR defined FF_MMI_RIV */
1293
1294 GLOBAL SHORT cmhSMS_SMSDeliver ( T_MNSMS_MESSAGE_IND * mnsms_message_ind )
1295 {
1296 UBYTE idx;
1297 #if defined SMI OR defined MFW OR defined FF_MMI_RIV OR defined _CONC_TESTING_
1298 T_ACI_CMGL_SM *p_sm;
1299 #endif /* SMI OR defined MFW OR defined FF_MMI_RIV OR defined _CONC_TESTING_*/
1300
1301 TRACE_FUNCTION ("cmhSMS_SMSDeliver");
1302
1303 #ifndef NTRACE
1304 trace_SMSDeliver ( mnsms_message_ind );
1305 #endif
1306
1307 if( smsShrdPrm.CNMImt EQ 0 )
1308 {
1309 TRACE_EVENT("cmhSMS_SMSDeliver():[ERR] <mt>==0 -> SMS will not be routed ");
1310 return 0;
1311 }
1312
1313 #if defined SMI OR defined MFW OR defined FF_MMI_RIV OR defined _CONC_TESTING_
1314 ACI_MALLOC(smsShrdPrm.pDecMsg, sizeof(T_ACI_CMGL_SM) );
1315 p_sm = smsShrdPrm.pDecMsg;
1316 /* Implements Measure # 110 */
1317 if (cmhSMS_cpyMsgIndReadCnf (p_sm, &mnsms_message_ind->status,
1318 &mnsms_message_ind->sms_sdu, mnsms_message_ind->rec_num) EQ FALSE )
1319 {
1320 TRACE_EVENT("cmhSMS_SMSDeliver():[ERR] decoding of SMS");
1321 if (p_sm->stat NEQ SMS_STAT_Invalid)
1322 {
1323 TRACE_EVENT("cmhSMS_SMSDeliver():[ERR] SMS decoding failed, but status not SMS_STAT_Invalid");
1324 }
1325 }
1326 #endif /* SMI OR defined MFW OR defined FF_MMI_RIV */
1327
1328
1329 if (smsShrdPrm.CSMSservice EQ CSMS_SERV_GsmPh2Plus)
1330 smsShrdPrm.cnma_ack_expected = TRUE;
1331
1332 /*
1333 *-----------------------------------------------------------------
1334 * new message indication
1335 *-----------------------------------------------------------------
1336 */
1337
1338 /* inform LOCAL MMI of new message */
1339 #if defined SMI OR defined MFW OR defined FF_MMI_RIV
1340 rAT_SMS_Deliver(mnsms_message_ind, p_sm);
1341 #endif /* SMI OR defined MFW OR defined FF_MMI_RIV */
1342
1343 /* If the SMS shared params indicate no valid source interested in
1344 * the SMS indications, the indication is buffered */ /* Issue 25033 */
1345 if( smsShrdPrm.smsSrcId EQ CMD_SRC_NONE )
1346 {
1347 T_CNMI_IND ind;
1348
1349 TRACE_EVENT("cmhSMS_SMSDeliver(): No registered source for ");
1350 memcpy ( &ind.cmt, mnsms_message_ind, sizeof ( T_MNSMS_MESSAGE_IND) );
1351 #ifdef DTI
1352 cmd_addCnmiNtry ( CNMI_CMT, &ind );
1353 #endif
1354 if ( smsShrdPrm.cnma_ack_expected EQ TRUE )
1355 { /* the acknowledge must be send automatically, because terminal is busy */
1356 PALLOC (mnsms_ack_res, MNSMS_ACK_RES);
1357
1358 TRACE_EVENT("rCI_PlusCMT(): send 'automatic' acknowledge (Phase2+ mode and buffer)");
1359
1360 mnsms_ack_res->resp = SMS_RP_ACK;
1361 mnsms_ack_res->sms_sdu.o_buf = 0;
1362 mnsms_ack_res->sms_sdu.l_buf = 0;
1363
1364 PSENDX (SMS, mnsms_ack_res);
1365
1366 smsShrdPrm.cnma_ack_expected = FALSE;
1367 }
1368 }
1369 else
1370 {
1371 /* tell any remote source */
1372 for( idx = CMD_SRC_LCL+1; idx < CMD_SRC_MAX; idx++ )
1373 {
1374 #if defined _SIMULATION_ AND defined _CONC_TESTING_
1375 /* don't display "+CMT: ..." in simulation if conc testing */
1376 if (!concShrdPrm.concTesting)
1377 #endif
1378 {
1379 R_AT( RAT_CMT, (T_ACI_CMD_SRC)idx ) ( mnsms_message_ind );
1380 }
1381 }
1382 }
1383
1384 if (smsShrdPrm.pDecMsg)
1385 {
1386 ACI_MFREE(smsShrdPrm.pDecMsg);
1387 smsShrdPrm.pDecMsg = NULL;
1388 }
1389
1390 return 0;
1391 }
1392
1393
1394 /*
1395 +-------------------------------------------------------------------+
1396 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSR |
1397 | STATE : code ROUTINE : cmhSMS_SMSMemory |
1398 +-------------------------------------------------------------------+
1399
1400 PURPOSE : This function is used to notify the command handler of
1401 an incoming SMS written to preferred message storage.
1402 */
1403 GLOBAL SHORT cmhSMS_SMSMemory ( T_MNSMS_MESSAGE_IND * mnsms_message_ind)
1404 {
1405 USHORT idx; /* holds command source id */
1406 T_ACI_SMS_STOR mem; /* holds message storage */
1407 T_ACI_CMGL_SM sm;
1408
1409 #ifdef _CONC_TESTING_
1410 #ifndef NTRACE
1411 /* Implements Measure#32: Row 1105 */
1412 USHORT offset;
1413
1414 TRACE_EVENT_P1("cmti:rec_num: %d", mnsms_message_ind->rec_num);
1415 TRACE_EVENT_P1("cmti:status: %d", mnsms_message_ind->status);
1416 offset = mnsms_message_ind->sms_sdu.o_buf>>3;
1417 /* Implements Measure#32: Row 1105 */
1418 cmhSMS_sdu_buf_print(&(mnsms_message_ind->sms_sdu.buf[0]), offset);
1419 #endif
1420 #endif
1421
1422 TRACE_FUNCTION ("cmhSMS_SMSMemory ()");
1423
1424 cmhSMS_getMemCmh ( mnsms_message_ind->mem_type, &mem );
1425
1426 switch (mnsms_message_ind->mem_type)
1427 {
1428 case MEM_ME:
1429 smsShrdPrm.aci_sms_parameter.meUsed++;
1430 break;
1431 case MEM_SM:
1432 smsShrdPrm.aci_sms_parameter.simUsed++;
1433 break;
1434 default:
1435 TRACE_EVENT("wrong memtype");
1436 return AT_FAIL;
1437 }
1438
1439 #if defined SMI OR defined MFW OR defined FF_MMI_RIV OR defined _CONC_TESTING_
1440 /* Implements Measure # 110 */
1441 if (cmhSMS_cpyMsgIndReadCnf (&sm, &mnsms_message_ind->status,
1442 &mnsms_message_ind->sms_sdu, mnsms_message_ind->rec_num) EQ FALSE )
1443 {
1444 TRACE_EVENT("cmhSMS_SMSMemory ():[ERR] decoding of SMS");
1445 if (sm.stat NEQ SMS_STAT_Invalid)
1446 {
1447 TRACE_EVENT("cmhSMS_SMSMemory():[ERR] SMS decoding failed, but status not SMS_STAT_Invalid");
1448 }
1449 }
1450 #endif
1451
1452
1453 /*
1454 *-----------------------------------------------------------------
1455 * new message indication
1456 *-----------------------------------------------------------------
1457 */
1458
1459
1460 #if defined FF_MMI_RIV
1461 /* in case of RIV MMI: check if SMBS is enabled for sending also PDU data */
1462 if(smsShrdPrm.perccmgf_smbs_mode EQ PERC_SMBS_MOD_ENABLE)
1463 {
1464 rAT_PlusCMTPdu (mnsms_message_ind);
1465 }
1466 #endif /* FF_MMI_RIV */
1467
1468 R_AT( RAT_CMTI, CMD_SRC_LCL ) (mem, sm.msg_ref, &sm);
1469
1470 /* If the SMS shared params indicate no valid source interested in
1471 * the SMS indications, the indication is buffered */ /* Issue 25033 */
1472 if( smsShrdPrm.smsSrcId EQ CMD_SRC_NONE )
1473 {
1474 T_CNMI_IND ind;
1475 ind.cmti.mem = mem;
1476 ind.cmti.index = mnsms_message_ind->rec_num;
1477 #ifdef DTI
1478 cmd_addCnmiNtry ( CNMI_CMTI, &ind );
1479 #endif
1480 }
1481 else
1482 {
1483 for( idx = CMD_SRC_LCL+1; idx < CMD_SRC_MAX; idx++ )
1484 {
1485 #if defined _SIMULATION_ AND defined _CONC_TESTING_
1486 /* don't display "+CMT: ..." in simulation if conc testing */
1487 if (!concShrdPrm.concTesting)
1488 #endif
1489 {
1490 /* don't need the decoded message for Command Interpreter */
1491 R_AT( RAT_CMTI, (T_ACI_CMD_SRC)idx ) ( mem, mnsms_message_ind->rec_num );
1492 }
1493 }
1494 }
1495
1496 return AT_CMPL;
1497 }
1498
1499 /*
1500 +-------------------------------------------------------------------+
1501 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSR |
1502 | STATE : code ROUTINE : cmhSMS_SMSStatRpt |
1503 +-------------------------------------------------------------------+
1504
1505 PURPOSE : This function is used to notify the command handler of
1506 the receiving of a SMS-STATUS-REPORT.
1507 */
1508 GLOBAL SHORT cmhSMS_SMSStatRpt ( T_MNSMS_STATUS_IND * mnsms_status_ind )
1509 {
1510 USHORT idx; /* holds command source id */
1511 T_ACI_CDS_SM* p_st;
1512
1513 TRACE_FUNCTION ("cmhSMS_SMSStatRpt ()");
1514
1515
1516 #if defined SMI OR defined MFW OR defined FF_MMI_RIV
1517 ACI_MALLOC(smsShrdPrm.pDecMsg, sizeof(T_ACI_CDS_SM) );
1518 p_st = (T_ACI_CDS_SM*)smsShrdPrm.pDecMsg;
1519 cmhSMS_cpyStatInd ( p_st, mnsms_status_ind);
1520 #endif
1521
1522
1523 if (smsShrdPrm.CSMSservice EQ CSMS_SERV_GsmPh2Plus)
1524 smsShrdPrm.cnma_ack_expected = TRUE;
1525
1526 /*
1527 *-----------------------------------------------------------------
1528 * new message indication
1529 *-----------------------------------------------------------------
1530 */
1531 {
1532 #ifdef FF_MMI_RIV
1533 T_ACI_CMGF_MOD sms_input_mode = CMGF_MOD_NotPresent;
1534 #endif /* FF_MMI_RIV */
1535
1536 /* If the SMS shared params indicate no valid source interested in
1537 * the SMS indications, the indication is buffered */ /* Issue 25033 */
1538 if( smsShrdPrm.smsSrcId EQ CMD_SRC_NONE )
1539 {
1540 T_CNMI_IND ind;
1541
1542 memcpy ( &ind.cds, mnsms_status_ind, sizeof ( T_MNSMS_STATUS_IND) );
1543 #ifdef DTI
1544 cmd_addCnmiNtry ( CNMI_CDS, &ind );
1545 #endif
1546 }
1547
1548 for( idx = 0; idx < CMD_SRC_MAX; idx++ )
1549 {
1550 if (idx EQ CMD_SRC_LCL)
1551 {
1552 #ifdef FF_MMI_RIV
1553 qAT_PlusCMGF (CMD_SRC_LCL, &sms_input_mode);
1554 if (sms_input_mode EQ CMGF_MOD_Pdu)
1555 {
1556 rAT_PlusCDSPdu (mnsms_status_ind);
1557 }
1558 else
1559 {
1560 R_AT( RAT_CDS, idx ) ( p_st );
1561 }
1562 #else
1563 R_AT( RAT_CDS,(T_ACI_CMD_SRC)idx ) ( p_st );
1564 #endif
1565 }
1566 else
1567 {
1568 R_AT( RAT_CDS, (T_ACI_CMD_SRC)idx ) ( mnsms_status_ind );
1569 }
1570
1571 }
1572 }
1573
1574 if (smsShrdPrm.pDecMsg)
1575 {
1576 ACI_MFREE(smsShrdPrm.pDecMsg);
1577 smsShrdPrm.pDecMsg = NULL;
1578 }
1579
1580 return 0;
1581 }
1582
1583
1584 /*
1585 +-------------------------------------------------------------------+
1586 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSR |
1587 | STATE : code ROUTINE : cmhSMS_cpyLstData |
1588 +-------------------------------------------------------------------+
1589
1590 PURPOSE : This function is used to copy the data read from memory.
1591 It sends a notification using the callback mechanism of
1592 ACI if necessary.
1593 */
1594 GLOBAL void cmhSMS_cpyLstData ( T_ACI_AT_CMD curCmd,
1595 T_ACI_CMD_SRC entOwn,
1596 T_MNSMS_READ_CNF * mnsms_read_cnf )
1597 {
1598 SHORT nextIdx; /* index of next short message */
1599
1600 TRACE_FUNCTION ("cmhSMS_cpyLstData ()");
1601
1602 nextIdx = mnsms_read_cnf->rec_next;
1603
1604 if ( entOwn EQ CMD_SRC_LCL)
1605 {
1606 #ifdef FF_MMI_RIV
1607 {
1608 T_ACI_CMGF_MOD sms_input_mode = CMGF_MOD_NotPresent;
1609
1610 qAT_PlusCMGF (CMD_SRC_LCL, &sms_input_mode);
1611 if (sms_input_mode EQ CMGF_MOD_Pdu )
1612 {
1613 if (curCmd EQ AT_CMD_CMGL)
1614 {
1615 rAT_PlusCMGLPdu (mnsms_read_cnf);
1616 }
1617 else if (curCmd EQ AT_CMD_P_CMGL)
1618 {
1619 rAT_PercentCMGLPdu (mnsms_read_cnf);
1620 }
1621 }
1622 else if (curCmd EQ AT_CMD_CMGL)
1623 {
1624 R_AT ( RAT_CMGL, entOwn ) ( smsShrdPrm.pDecMsg );
1625 }
1626 else if (curCmd EQ AT_CMD_P_CMGL)
1627 {
1628 R_AT ( RAT_P_CMGL, entOwn ) ( smsShrdPrm.pDecMsg );
1629 }
1630 }
1631 #else
1632 if (curCmd EQ AT_CMD_CMGL)
1633 {
1634 R_AT ( RAT_CMGL, entOwn ) ( smsShrdPrm.pDecMsg );
1635 }
1636 else if (curCmd EQ AT_CMD_P_CMGL)
1637 {
1638 R_AT ( RAT_P_CMGL, entOwn ) ( smsShrdPrm.pDecMsg );
1639 }
1640
1641 #endif
1642 }
1643 else if (curCmd EQ AT_CMD_CMGL)
1644 {
1645 R_AT ( RAT_CMGL, entOwn ) ( mnsms_read_cnf );
1646 /* inform BMI */
1647 cmh_logRslt ( entOwn, RAT_OK, AT_CMD_CMGL, mnsms_read_cnf->rec_num,
1648 BS_SPEED_NotPresent,CME_ERR_NotPresent);
1649 }
1650 else if (curCmd EQ AT_CMD_P_CMGL)
1651 {
1652 /* the message shall not be displayed for ReadMode as Status Change */
1653 if (smsShrdPrm.rdMode NEQ SMS_READ_StatusChange)
1654 {
1655 R_AT ( RAT_P_CMGL, entOwn ) ( mnsms_read_cnf );
1656 /* inform BMI */
1657 cmh_logRslt ( entOwn, RAT_OK, AT_CMD_P_CMGL, mnsms_read_cnf->rec_num,
1658 BS_SPEED_NotPresent,CME_ERR_NotPresent );
1659 }
1660 }
1661
1662 if (nextIdx NEQ SMS_RECORD_NOT_EXIST)
1663 {
1664 /*
1665 *-----------------------------------------------------------
1666 * request the next list elements of given cmglStat state
1667 *-----------------------------------------------------------
1668 */
1669 psaSMS_ReadReq ( smsShrdPrm.mem1, nextIdx,
1670 smsShrdPrm.rdMode, cmglStat );
1671 }
1672 else
1673 {
1674 /*
1675 *-----------------------------------------------------------
1676 * no more messages are available
1677 *-----------------------------------------------------------
1678 */
1679
1680 /* reset the command context */
1681 smsShrdPrm.smsEntStat.curCmd = AT_CMD_NONE;
1682 smsShrdPrm.owner = (T_OWN)CMD_SRC_NONE;
1683 smsShrdPrm.smsEntStat.entOwn = CMD_SRC_NONE;
1684
1685 R_AT ( RAT_OK, entOwn ) ( curCmd );
1686 }
1687 }
1688
1689
1690 /*
1691 +-------------------------------------------------------------------+
1692 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSR |
1693 | STATE : code ROUTINE : cmhSMS_SMReadCMSS |
1694 +-------------------------------------------------------------------+
1695
1696 PURPOSE : This function processes the mnsms_read_cnf which was
1697 triggered by +CMSS.
1698 */
1699 GLOBAL void cmhSMS_SMReadCMSS ( T_MNSMS_READ_CNF * mnsms_read_cnf)
1700 {
1701 T_SMS_SET_PRM * pSMSSetPrm; /* points to SMS parameter set */
1702 UBYTE srcId;
1703 UBYTE fo;
1704 T_ACI_CMGL_SM *p_sm;
1705 T_tp_da da_addr;
1706 T_ACI_RETURN ret=AT_CMPL;
1707 UBYTE modify=SMS_MODIFY_NON;
1708
1709 #ifdef _CONC_TESTING_
1710 /* Implements Measure#32: Row 1105 */
1711 #endif
1712
1713 TRACE_FUNCTION ("cmhSMS_SMReadCMSS ()");
1714
1715
1716 srcId = smsShrdPrm.smsEntStat.entOwn;
1717 pSMSSetPrm = smsShrdPrm.pSetPrm[srcId];
1718
1719 if (smsShrdPrm.pDecMsg EQ NULL)
1720 {
1721 ACI_MALLOC(smsShrdPrm.pDecMsg, sizeof(T_ACI_CMGL_SM) );
1722 p_sm = smsShrdPrm.pDecMsg;
1723 /* decode message */
1724 /* Implements Measure # 110 */
1725 cmhSMS_cpyMsgIndReadCnf (p_sm,
1726 &mnsms_read_cnf->status,
1727 &mnsms_read_cnf->sms_sdu,
1728 mnsms_read_cnf->rec_num);
1729 }
1730 else
1731 p_sm = smsShrdPrm.pDecMsg;
1732
1733 memset (&da_addr, 0, sizeof(T_tp_da));
1734
1735 /* start: check FDN if enabled */
1736 if (pb_get_fdn_mode () EQ FDN_ENABLE AND
1737 pb_get_fdn_classtype() EQ CLASS_VceDatFaxSms )
1738 {
1739
1740 TRACE_EVENT_P1("cmhSMS_SMReadCMSS: FDN check: %s", p_sm->adress );
1741
1742 if (pb_check_fdn (0, (const UBYTE*) p_sm->adress) EQ PHB_OK)
1743 {
1744 TRACE_EVENT("cmhSMS_SMReadCMSS: Found match in FDN!");
1745 }
1746 else
1747 {
1748 TRACE_EVENT("cmhSMS_SMReadCMSS: No match in FDN found, SMS rejected!");
1749 /* error notification */
1750 R_AT( RAT_CMS, smsShrdPrm.smsEntStat.entOwn )
1751 ( smsShrdPrm.smsEntStat.curCmd, CMS_ERR_OpNotAllowed, NULL );
1752 /* release context */
1753 smsShrdPrm.smsEntStat.curCmd = AT_CMD_NONE;
1754 smsShrdPrm.owner = (T_OWN)CMD_SRC_NONE;
1755 smsShrdPrm.smsEntStat.entOwn =CMD_SRC_NONE;
1756 return;
1757 }
1758 }
1759 /* end: check FDN if enabled */
1760
1761 /*
1762 * ACI-SPR-17004: set RFU bits of status to 0 if present since these
1763 * should be ignored in a GSM session (GSM 11.11 section 9.3)
1764 */
1765 cmhSMS_removeStatusRFUBits( &mnsms_read_cnf->status );
1766
1767 ACI_MALLOC(smsShrdPrm.tpdu.tp_submit, sizeof(T_TP_SUBMIT));
1768
1769 /* SMS-SUBMIT received */
1770 if ((mnsms_read_cnf->status EQ SMS_RECORD_STO_UNSENT) OR
1771 (mnsms_read_cnf->status EQ SMS_RECORD_STO_SENT) OR
1772 (mnsms_read_cnf->status EQ SMS_RECORD_STAT_UNRCVD) OR
1773 (mnsms_read_cnf->status EQ SMS_RECORD_STAT_UNSTRD) OR
1774 (mnsms_read_cnf->status EQ SMS_RECORD_STAT_STRD) )
1775 {
1776
1777 /* destination address from stored message */
1778 if (p_sm->adress[0] NEQ '\0')
1779 {
1780 da_addr.ton = p_sm->toa.ton;
1781 da_addr.npi = p_sm->toa.npi;
1782
1783 if ( da_addr.ton EQ TON_Alphanumeric )
1784 {
1785 cmhSMS_packAlphaNumAddr(p_sm->adress, &da_addr);
1786 }
1787 else
1788 {
1789 cmhSMS_getAdrBcd ( da_addr.num, &da_addr.c_num, MAX_SMS_ADDR_DIG, p_sm->adress);
1790 da_addr.digits = da_addr.c_num;
1791 }
1792
1793 }
1794
1795 /* service center address from shared parameter */
1796 if (pSMSSetPrm->sca.c_num NEQ 0)
1797 {
1798 memcpy (&smsShrdPrm.tpdu.sc_addr, &pSMSSetPrm->sca, sizeof(T_rp_addr));
1799 modify |= SMS_MODIFY_SCA;
1800
1801 }
1802
1803 /* ACI-SPR-22528.The memory is allocated for smsShrdPrm.tpdu.tp_submit
1804 only when it is necessary*/
1805
1806
1807 cmhSMS_fillTpSubmit (smsShrdPrm.tpdu.tp_submit,
1808 (T_ACI_CMD_SRC)srcId,
1809 0, /* fo */
1810 0,
1811 &da_addr,
1812 NULL,
1813 0,
1814 NULL );
1815 }
1816 else
1817 {
1818 /* SMS-DELIVER received */
1819
1820 T_ACI_SM_DATA packedData;
1821 UBYTE byte_offset=0;
1822
1823 /* service center address from shared parameter */
1824 if (pSMSSetPrm->sca.c_num NEQ 0)
1825 {
1826 memcpy (&smsShrdPrm.tpdu.sc_addr, &pSMSSetPrm->sca, sizeof(T_rp_addr));
1827 }
1828 else
1829 {
1830 if (p_sm->sca[0] NEQ '\0')
1831 {
1832 cmhSMS_getAdrBcd( smsShrdPrm.tpdu.sc_addr.num,
1833 &smsShrdPrm.tpdu.sc_addr.c_num,
1834 MAX_SMS_ADDR_DIG, p_sm->sca);
1835 smsShrdPrm.tpdu.sc_addr.ton = p_sm->tosca.ton;
1836 smsShrdPrm.tpdu.sc_addr.npi = p_sm->tosca.npi;
1837 smsShrdPrm.tpdu.sc_addr.v_ton = TRUE;
1838 smsShrdPrm.tpdu.sc_addr.v_npi = TRUE;
1839 }
1840 }
1841
1842 fo = (pSMSSetPrm->msgType & (~TP_MTI_MASK)) | TP_MTI_SMS_SUBMIT;
1843
1844 if (p_sm->udh.len)
1845 byte_offset = p_sm->udh.len+1;
1846
1847 /* ACI-SPR-22528.The memory is allocated for smsShrdPrm.tpdu.tp_submit
1848 only when it is necessary*/
1849
1850 cmhSMS_rdcSmsPp ( byte_offset,
1851 p_sm -> dcs,
1852 ( UBYTE * ) p_sm->data.data, ( UBYTE ) p_sm->data.len,
1853 packedData.data, &packedData.len);
1854
1855 if (p_sm->adress[0] NEQ '\0')
1856 {
1857 cmhSMS_getAdrBcd ( da_addr.num, &da_addr.c_num, MAX_SMS_ADDR_DIG, p_sm->adress);
1858 da_addr.ton = p_sm->toa.ton;
1859 da_addr.npi = p_sm->toa.npi;
1860 da_addr.digits = da_addr.c_num;
1861 }
1862
1863 cmhSMS_fillTpSubmit (smsShrdPrm.tpdu.tp_submit,
1864 (T_ACI_CMD_SRC)srcId,
1865 fo,
1866 0,
1867 &da_addr,
1868 &packedData,
1869 p_sm->data.len,
1870 &p_sm->udh );
1871
1872 modify = SMS_MODIFY_ALL;
1873 }
1874
1875 {
1876 PALLOC (mnsms_submit_req, MNSMS_SUBMIT_REQ);
1877 mnsms_submit_req->rec_num = mnsms_read_cnf->rec_num;
1878 mnsms_submit_req->mem_type = smsShrdPrm.mem2;
1879 mnsms_submit_req->condx = SMS_CONDX_OVR_ANY;
1880 mnsms_submit_req->modify = modify;
1881
1882 #ifdef REL99
1883 if(srcId NEQ OWN_SRC_SAT)
1884 {
1885 mnsms_submit_req -> auto_rep_flag = smsShrdPrm.auto_repeat_flag;
1886 }
1887 else
1888 {
1889 mnsms_submit_req -> auto_rep_flag = FALSE;
1890 }
1891 #endif /* REL99 */
1892
1893
1894 #ifdef SIM_TOOLKIT
1895 if (psaSIM_ChkSIMSrvSup( SRV_MOSMCtrlSIM ))
1896 {
1897 if (simShrdPrm.setPrm[srcId].sat_cc_mode EQ SATCC_CONTROL_BY_SIM_ACTIVE)
1898 {
1899 ret = cmhSAT_MoSmCntr( smsShrdPrm.tpdu.sc_addr,
1900 da_addr,
1901 srcId);
1902 }
1903 else
1904 {
1905 simShrdPrm.setPrm[srcId].sat_cc_mode = SATCC_CONTROL_BY_SIM_ACTIVE;
1906 }
1907
1908 }
1909
1910 if (ret NEQ AT_CMPL)
1911 {
1912 /* save primitive address for SIM_TOOLKIT response */
1913 sat_mnsms_submit_req = mnsms_submit_req;
1914 return;
1915 }
1916 #endif
1917 /* code SMS-SUBMIT here */
1918 cmhSMS_codeMsg (&mnsms_submit_req->sms_sdu, SMS_VT_SUBMIT,
1919 &smsShrdPrm.tpdu.sc_addr, SMS_SUBMIT,
1920 (UBYTE*)smsShrdPrm.tpdu.tp_submit);
1921
1922 PSENDX (SMS, mnsms_submit_req);
1923 #ifdef _CONC_TESTING_
1924 #ifndef NTRACE
1925 /* Implements Measure#32: Row 1105 */
1926 cmhSMS_sdu_buf_print(&(mnsms_submit_req->sms_sdu.buf[0]), 0);
1927 #endif
1928 #endif
1929 if (smsShrdPrm.tpdu.tp_submit NEQ NULL)
1930 {
1931 ACI_MFREE(smsShrdPrm.tpdu.tp_submit);
1932 smsShrdPrm.tpdu.tp_submit = NULL;
1933 }
1934 }
1935 }
1936
1937 /*
1938 +-------------------------------------------------------------------+
1939 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSR |
1940 | STATE : code ROUTINE : cmhSMS_SMRead |
1941 +-------------------------------------------------------------------+
1942
1943 PURPOSE : This function is used to notify the command handler of
1944 a successfull reading of a short message from preferred
1945 message storage.
1946 */
1947 #ifndef NTRACE
1948 LOCAL void trace_read_sms( T_MNSMS_READ_CNF * mnsms_read_cnf)
1949 {
1950 /* Implements Measure#32: Row 1105 */
1951
1952 TRACE_FUNCTION ("trace_read_sms ()");
1953
1954 TRACE_EVENT_P1(" rec_num: %u", mnsms_read_cnf->rec_num);
1955 TRACE_EVENT_P1(" rec_next: %u", mnsms_read_cnf->rec_next);
1956 TRACE_EVENT_P1(" rec_max: %u", mnsms_read_cnf->rec_max);
1957 TRACE_EVENT_P1(" status %u", mnsms_read_cnf->status);
1958 TRACE_EVENT_P1(" cause 0x%04x", mnsms_read_cnf->cause);
1959 /* Implements Measure#32: Row 1105 */
1960 cmhSMS_sdu_buf_print(&(mnsms_read_cnf->sms_sdu.buf[0]), 0);
1961 }
1962 #endif
1963
1964
1965
1966 GLOBAL SHORT cmhSMS_SMRead ( T_MNSMS_READ_CNF * mnsms_read_cnf)
1967 {
1968 T_ACI_AT_CMD cmdBuf; /* buffers current command */
1969 T_ACI_CMD_SRC ownBuf; /* buffers current owner */
1970 T_ACI_CMGL_SM *p_sm=NULL;
1971 T_rp_addr rp_addr;
1972 UBYTE* message;
1973 T_TP_DELIVER *sms_deliver, decoded_mesg;
1974 BOOL retCode = FALSE;
1975 UBYTE msg_type;
1976
1977 TRACE_FUNCTION ("cmhSMS_SMRead ()");
1978
1979 #ifndef NTRACE
1980 trace_read_sms(mnsms_read_cnf);
1981 #endif
1982
1983 cmdBuf = smsShrdPrm.smsEntStat.curCmd;
1984 ownBuf = smsShrdPrm.smsEntStat.entOwn;
1985
1986 /* (SIM) error occurred */
1987 if (!IS_CAUSE_INVALID(mnsms_read_cnf->cause))
1988 {
1989 if (mnsms_read_cnf->cause NEQ SMS_NO_ERROR)
1990 {
1991 /* reset the command context */
1992 smsShrdPrm.smsEntStat.curCmd = AT_CMD_NONE;
1993 smsShrdPrm.owner = (T_OWN)CMD_SRC_NONE;
1994 smsShrdPrm.smsEntStat.entOwn = CMD_SRC_NONE;
1995
1996 if( ownBuf NEQ CMD_SRC_LCL OR cmdBuf NEQ AT_CMD_P_CMGMDU )
1997 {
1998 R_AT ( RAT_CMS, ownBuf )
1999 (
2000 cmdBuf,
2001 cmhSMS_GetCmsFromSms(mnsms_read_cnf->cause),
2002 NULL
2003 );
2004 }
2005 return 1;
2006 }
2007 }
2008
2009 #ifdef _CONC_TESTING_
2010 /* this is only for testing */
2011 SET_OWNBUF_CONC;
2012 #endif
2013
2014 /*
2015 *-----------------------------------------------------------------
2016 * ignore primitives with incorrect message status
2017 *-----------------------------------------------------------------
2018 */
2019 TRACE_EVENT_P1("mnsms_read_cnf->status: %d", mnsms_read_cnf->status);
2020
2021 if ( (mnsms_read_cnf->status EQ SMS_RECORD_FREE) OR
2022 (mnsms_read_cnf->status EQ SMS_RECORD_INVALID) )
2023 {
2024 /* reset the command context */
2025 smsShrdPrm.smsEntStat.curCmd = AT_CMD_NONE;
2026 smsShrdPrm.owner = (T_OWN)CMD_SRC_NONE;
2027 smsShrdPrm.smsEntStat.entOwn = CMD_SRC_NONE;
2028
2029 TRACE_EVENT("incorrect message status");
2030 return 1;
2031 }
2032
2033 /* always decode for local source */
2034 if (ownBuf EQ CMD_SRC_LCL) /* ACI-SPR-9528 */
2035 { /* pass dummy p_sm to CB */
2036 if (((cmdBuf EQ AT_CMD_CMGL OR cmdBuf EQ AT_CMD_CMGR) OR
2037 (cmdBuf EQ AT_CMD_P_CMGR OR cmdBuf EQ AT_CMD_P_CMGL))
2038 AND smsShrdPrm.rdMode NEQ READ_STATUS_CHANGE) /* ACI-FIX-9510 */
2039 {
2040 retCode = cmhSMS_SMSQueryType (&mnsms_read_cnf->sms_sdu, &msg_type);
2041 if (retCode EQ FALSE)
2042 {
2043 /* reset the command context */
2044 smsShrdPrm.smsEntStat.curCmd = AT_CMD_NONE;
2045 smsShrdPrm.owner = (T_OWN)CMD_SRC_NONE;
2046 smsShrdPrm.smsEntStat.entOwn = CMD_SRC_NONE;
2047
2048 TRACE_EVENT("Error decoding message type");
2049 return 1;
2050 }
2051 ACI_MALLOC(smsShrdPrm.pDecMsg, sizeof(T_ACI_CMGL_SM) );
2052 memset(smsShrdPrm.pDecMsg,0,sizeof(T_ACI_CMGL_SM) );
2053 p_sm = smsShrdPrm.pDecMsg;
2054 if (msg_type EQ TP_MTI_SMS_STATUS_REP)
2055 {
2056 retCode=cmhSMS_cpySTtoSM(p_sm ,mnsms_read_cnf);
2057 }
2058 else
2059 {
2060 /* Implements Measure # 110 */
2061 retCode = cmhSMS_cpyMsgIndReadCnf (p_sm,
2062 &mnsms_read_cnf->status,
2063 &mnsms_read_cnf->sms_sdu,
2064 mnsms_read_cnf->rec_num);
2065 }
2066 if (retCode EQ FALSE)
2067 {
2068 TRACE_EVENT("cmhSMS_SMRead ():[ERR] decoding of SMS");
2069 cmhSMS_invalidSMS_notification_to_user (mnsms_read_cnf);
2070
2071 ACI_MFREE(smsShrdPrm.pDecMsg);
2072
2073 /* reset the command context */
2074 //Added by Jinshu Wang, 23/05/2005 OMAPS00108199
2075 //start
2076 if (smsShrdPrm.smsEntStat.curCmd!=AT_CMD_CMGL)
2077 {
2078 smsShrdPrm.smsEntStat.curCmd = AT_CMD_NONE;
2079 smsShrdPrm.owner = (T_OWN)CMD_SRC_NONE;
2080 smsShrdPrm.smsEntStat.entOwn = CMD_SRC_NONE;
2081
2082 smsShrdPrm.pDecMsg = NULL;
2083 }
2084 //end
2085 if (mnsms_read_cnf->rec_next EQ SMS_RECORD_NOT_EXIST)
2086 {
2087 smsShrdPrm.smsEntStat.curCmd = AT_CMD_NONE;
2088 smsShrdPrm.owner = (T_OWN)CMD_SRC_NONE;
2089 smsShrdPrm.smsEntStat.entOwn = CMD_SRC_NONE;
2090 if( cmdBuf NEQ AT_CMD_P_CMGMDU )
2091 {
2092 R_AT ( RAT_OK, ownBuf ) ( cmdBuf );
2093 }
2094 }
2095 return 1;
2096 }
2097 }
2098 }
2099 else
2100 p_sm = smsShrdPrm.pDecMsg;
2101
2102 /*
2103 *-----------------------------------------------------------------
2104 * check for command context
2105 *-----------------------------------------------------------------
2106 */
2107 switch( smsShrdPrm.smsEntStat.curCmd )
2108 {
2109 case ( AT_CMD_CMGR ):
2110 case ( AT_CMD_P_CMGR ):
2111 {
2112 /*
2113 *-------------------------------------------------------------
2114 * process event for +CGMR
2115 *-------------------------------------------------------------
2116 */
2117
2118 /* reset the command context */
2119 smsShrdPrm.smsEntStat.curCmd = AT_CMD_NONE;
2120 smsShrdPrm.owner = (T_OWN)CMD_SRC_NONE;
2121 smsShrdPrm.smsEntStat.entOwn = CMD_SRC_NONE;
2122
2123 /* The message need not be displayed for Status Change */
2124 if (cmdBuf EQ AT_CMD_P_CMGR
2125 AND smsShrdPrm.rdMode EQ READ_STATUS_CHANGE)
2126 {
2127 R_AT ( RAT_OK, ownBuf ) ( cmdBuf );
2128 /* inform BMI */
2129 cmh_logRslt ( ownBuf, RAT_OK, AT_CMD_P_CMGR, mnsms_read_cnf->rec_num,
2130 BS_SPEED_NotPresent,CME_ERR_NotPresent );
2131 break;
2132 }
2133
2134
2135 #if defined MFW OR defined FF_MMI_RIV OR defined _CONC_TESTING_
2136 if (ownBuf EQ CMD_SRC_LCL) /* AND ACI-FIX-9510 */
2137 /* smsShrdPrm.rdMode NEQ READ_STATUS_CHANGE) */ /* call rplyCB (with invalid p_sm) anyway
2138 to touch all segments while in
2139 READ_STATUS_CHANGE */
2140 {
2141 #if defined FF_MMI_RIV
2142 T_ACI_CMGF_MOD sms_input_mode = CMGF_MOD_NotPresent;
2143 qAT_PlusCMGF (CMD_SRC_LCL, &sms_input_mode);
2144 if (sms_input_mode EQ CMGF_MOD_Pdu )
2145 {
2146 if (cmdBuf EQ AT_CMD_CMGR )
2147 {
2148 rAT_PlusCMGRPdu (mnsms_read_cnf);
2149 }
2150 else if (cmdBuf EQ AT_CMD_P_CMGR )
2151 {
2152 rAT_PercentCMGRPdu (mnsms_read_cnf);
2153 }
2154 }
2155 else
2156 {
2157 if (smsShrdPrm.rplyCB.cmgr NEQ NULL)
2158 {
2159 smsShrdPrm.rplyCB.cmgr( p_sm, NULL );
2160 }
2161 }
2162 R_AT ( RAT_OK, ownBuf ) ( cmdBuf );
2163 #else
2164 /* GPF-MMI */
2165 if (smsShrdPrm.rplyCB.cmgr NEQ NULL)
2166 {
2167 smsShrdPrm.rplyCB.cmgr( p_sm, NULL );
2168 }
2169 if (!ISSET_CONC)
2170 {
2171 R_AT ( RAT_OK, ownBuf ) ( cmdBuf );
2172 }
2173 #endif
2174 }
2175 else /* if (ownBuf EQ CMD_SRC_LCL) */
2176 #endif /*#if defined MFW OR defined FF_MMI_RIV*/
2177 {
2178 if (cmdBuf EQ AT_CMD_CMGR )
2179 {
2180 R_AT ( RAT_CMGR, ownBuf ) ( mnsms_read_cnf, NULL );
2181 }
2182 else if (cmdBuf EQ AT_CMD_P_CMGR )
2183 {
2184 R_AT ( RAT_P_CMGR, ownBuf ) ( mnsms_read_cnf, NULL );
2185 }
2186
2187 R_AT ( RAT_OK, ownBuf ) ( cmdBuf );
2188 /* inform BMI */
2189 cmh_logRslt ( ownBuf, RAT_OK, AT_CMD_CMGR, mnsms_read_cnf->rec_num,
2190 BS_SPEED_NotPresent,CME_ERR_NotPresent );
2191 }
2192
2193 break;
2194 }
2195
2196 case ( AT_CMD_P_CMGL ):
2197 case ( AT_CMD_CMGL ):
2198 {
2199 /*
2200 *-------------------------------------------------------------
2201 * process event for +CMGL
2202 *-------------------------------------------------------------
2203 */
2204 cmhSMS_cpyLstData ( cmdBuf, ownBuf, mnsms_read_cnf );
2205
2206 break;
2207 }
2208
2209 case ( AT_CMD_P_CMGMDU ):
2210 {
2211 /*
2212 *-------------------------------------------------------------
2213 * process event for %CMGMDU
2214 *-------------------------------------------------------------
2215 */
2216 message = cmhSMS_decodeMsg(&mnsms_read_cnf->sms_sdu, &rp_addr, SMS_VT_DELIVER);
2217 sms_deliver = (T_TP_DELIVER*)message;
2218 sms_deliver->tp_rp = 0;
2219 memcpy(&decoded_mesg, sms_deliver, sizeof(T_TP_DELIVER));
2220
2221 {
2222 PALLOC (mnsms_store_req, MNSMS_STORE_REQ);
2223
2224 mnsms_store_req -> mem_type = smsShrdPrm.mem1;
2225 mnsms_store_req -> condx = SMS_CONDX_OVR_ANY;
2226 mnsms_store_req -> rec_num = mnsms_read_cnf->rec_num;
2227 mnsms_store_req -> status = mnsms_read_cnf->status;
2228
2229 cmhSMS_codeMsg ( &mnsms_store_req->sms_sdu,
2230 SMS_VT_DELIVER,
2231 &rp_addr,
2232 SMS_DELIVER,
2233 (UBYTE*) &decoded_mesg);
2234
2235 PSENDX (SMS, mnsms_store_req);
2236 }
2237 break;
2238 }
2239 #if defined (SIM_TOOLKIT)
2240 case ( AT_CMD_CMSS ):
2241 {
2242 /*
2243 *-------------------------------------------------------------
2244 * process event for +CMSS (only for SAT)
2245 *-------------------------------------------------------------
2246 */
2247 cmhSMS_SMReadCMSS (mnsms_read_cnf);
2248
2249 break;
2250 }
2251 #endif
2252
2253 default:
2254 {
2255 TRACE_EVENT("error in command context");
2256 }
2257 }
2258
2259 if (smsShrdPrm.pDecMsg)
2260 {
2261 ACI_MFREE(smsShrdPrm.pDecMsg);
2262 smsShrdPrm.pDecMsg = NULL;
2263 }
2264
2265 return 0;
2266 }
2267
2268 /*
2269 +-------------------------------------------------------------------+
2270 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSR |
2271 | STATE : code ROUTINE : cmhSMS_Result |
2272 +-------------------------------------------------------------------+
2273
2274 PURPOSE : This function is used to notify the command handler of
2275 a successfull transaction concerning the short message
2276 service.
2277 */
2278 GLOBAL SHORT cmhSMS_Result ( T_MNSMS_REPORT_IND * mnsms_report_ind )
2279 {
2280 T_ACI_AT_CMD cmdBuf; /* buffers current command */
2281 T_ACI_CMD_SRC ownBuf; /* buffers current owner */
2282
2283
2284 TRACE_FUNCTION ("cmhSMS_Result ()");
2285
2286 if (mnsms_report_ind->v_cmms_mode)
2287 {
2288 smsShrdPrm.CMMSmode = mnsms_report_ind->cmms_mode;
2289 return 0;
2290 }
2291
2292 cmdBuf = AT_CMD_NONE;
2293 ownBuf = CMD_SRC_LCL;
2294
2295 smsShrdPrm.smsStat = mnsms_report_ind->state;
2296
2297
2298 if (mnsms_report_ind->state EQ SMS_STATE_READY)
2299 {
2300 /* reading of SMs from SIM is completed,
2301 * read SMSP, CBMIR, CMBI fields now
2302 */
2303 if (cmhSMS_ReadParams ((T_ACI_CMD_SRC)OWN_SRC_INV, AT_CMD_CFUN, 1) NEQ AT_EXCT)
2304 {
2305 cmhSMS_ready ();
2306 }
2307 R_AT ( RAT_SIG_SMS, ownBuf ) ( SMS_STATE_READY );
2308 }
2309 else if (mnsms_report_ind->state EQ SMS_STATE_INITIALISING)
2310 {
2311 { /*ACI-FIX-18055 resetting total and used storage counters of SIM and ME storages which will be updated by cmhSMS_SMSInitState */
2312 smsShrdPrm.aci_sms_parameter.simTotal = 0;
2313 smsShrdPrm.aci_sms_parameter.simUsed = 0;
2314 smsShrdPrm.aci_sms_parameter.meTotal = 0;
2315 smsShrdPrm.aci_sms_parameter.meUsed = 0;
2316 } /*ACI-FIX-18055 Changes end here */
2317 R_AT ( RAT_SIG_SMS, ownBuf ) ( SMS_STATE_INITIALISING );
2318 }
2319 else if (mnsms_report_ind->state > SMS_STATE_INITIALISING)
2320 {
2321 R_AT ( RAT_CMS, ownBuf ) ( cmdBuf, CMS_ERR_UnknownErr, NULL );
2322 }
2323
2324 return 0;
2325 }
2326
2327 /*
2328 +-------------------------------------------------------------------+
2329 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSR |
2330 | STATE : code ROUTINE : cmhSMS_WrCnfCSAS |
2331 +-------------------------------------------------------------------+
2332
2333 PURPOSE : This function is used to notify the command handler of
2334 the usage of SIM and ME memory.
2335 */
2336 GLOBAL void cmhSMS_WrCnfCSAS (SHORT aId)
2337 {
2338 T_ACI_AT_CMD cmdBuf; /* buffers current command */
2339 T_ACI_CMD_SRC ownBuf; /* buffers current owner */
2340 USHORT errCode;
2341 USHORT dataField = 0xFF;
2342 UBYTE dataLen = 0;
2343 UBYTE data[MAX_SIM_CMD];
2344
2345 TRACE_FUNCTION ("cmhSMS_WrCnfCSAS ()");
2346
2347 cmdBuf = smsShrdPrm.smsEntStat.curCmd;
2348 ownBuf = smsShrdPrm.smsEntStat.entOwn;
2349
2350 /*
2351 *-----------------------------------------------------------------
2352 * check for next SIM access
2353 *-----------------------------------------------------------------
2354 */
2355 switch (smsShrdPrm.prmRdSeq)
2356 {
2357 case SMS_READ_SIM_SMSP: /* EF(SMSP) written */
2358 errCode = simShrdPrm.atb[aId].errCode;
2359
2360 if (smsShrdPrm.cbmPrm.cbmSIMmaxIdRge > 0 AND
2361 cmhSMS_PutCbmirSIM (ownBuf, data,
2362 (int)smsShrdPrm.cbmPrm.cbmSIMmaxIdRge * 4)) /* write CBMIR */
2363 {
2364 dataField = SIM_CBMIR;
2365 dataLen = smsShrdPrm.cbmPrm.cbmSIMmaxIdRge * 4;
2366 break;
2367 }
2368 else
2369 smsShrdPrm.prmRdSeq--;
2370
2371 if (smsShrdPrm.cbmPrm.cbmSIMmaxId > 0 AND
2372 cmhSMS_PutCbmiSIM (ownBuf, data,
2373 (int)smsShrdPrm.cbmPrm.cbmSIMmaxId * 2)) /* write CBMI */
2374 {
2375 dataField = SIM_CBMI;
2376 dataLen = smsShrdPrm.cbmPrm.cbmSIMmaxId * 2;
2377 }
2378 else /* nothing else to write */
2379 {
2380 smsShrdPrm.prmRdSeq = SMS_READ_SIM_CMPL;
2381 }
2382 break;
2383
2384 case SMS_READ_SIM_CBMIR: /* CBMIR written */
2385 errCode = simShrdPrm.atb[aId].errCode;
2386
2387 if (smsShrdPrm.cbmPrm.cbmSIMmaxId > 0 AND /* write CBMI */
2388 cmhSMS_PutCbmiSIM (ownBuf, data,
2389 (int)smsShrdPrm.cbmPrm.cbmSIMmaxId * 2))
2390 {
2391 dataField = SIM_CBMI;
2392 dataLen = smsShrdPrm.cbmPrm.cbmSIMmaxId * 2;
2393 }
2394 else /* nothing else to write */
2395 smsShrdPrm.prmRdSeq = SMS_READ_SIM_CMPL;
2396 break;
2397
2398 case SMS_READ_SIM_CBMI: /* CBMI written */
2399 errCode = simShrdPrm.atb[aId].errCode;
2400
2401 smsShrdPrm.prmRdSeq = SMS_READ_SIM_CMPL; /* nothing else to write */
2402 break;
2403
2404 default: /* nothing else to write */
2405 smsShrdPrm.prmRdSeq = SMS_READ_SIM_CMPL;
2406 errCode = SIM_CAUSE_OTHER_ERROR;
2407 break;
2408 }
2409 if ( smsShrdPrm.prmRdSeq EQ SMS_READ_SIM_CMPL)
2410 {
2411 /* Implements Measure # 104 */
2412 cmhSMS_ResCSAS(ownBuf, cmdBuf, errCode);
2413 }
2414 else
2415 {
2416 if (cmhSIM_WriteTranspEF (CMD_SRC_NONE, cmdBuf, FALSE, NULL,
2417 dataField, 0, dataLen,
2418 data, cmhSMS_WrCnfCSAS) EQ AT_FAIL)
2419 {
2420 smsShrdPrm.smsEntStat.curCmd = AT_CMD_NONE;
2421 smsShrdPrm.owner = (T_OWN)CMD_SRC_NONE;
2422 smsShrdPrm.smsEntStat.entOwn = CMD_SRC_NONE;
2423
2424 smsShrdPrm.prmRdSeq = SMS_READ_SIM_CMPL;
2425
2426 R_AT( RAT_CMS, ownBuf ) ( cmdBuf, CMS_ERR_UnknownErr, NULL );
2427 }
2428 else
2429 smsShrdPrm.prmRdSeq--;
2430 }
2431
2432 simShrdPrm.atb[aId].ntryUsdFlg = FALSE;
2433 }
2434
2435 /*
2436 +-------------------------------------------------------------------+
2437 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSR |
2438 | STATE : code ROUTINE : cmhSMS_RdCnfCRES |
2439 +-------------------------------------------------------------------+
2440
2441 PURPOSE : This function is used to notify the command handler of
2442 the usage of SIM and ME memory.
2443 */
2444 GLOBAL void cmhSMS_RdCnfCRES (SHORT aId)
2445 {
2446 T_ACI_AT_CMD cmdBuf; /* buffers current command */
2447 T_ACI_CMD_SRC ownBuf; /* buffers current owner */
2448
2449 USHORT errCode;
2450 USHORT dataField = 0xFF;
2451 UBYTE dataLen = 0;
2452 TRACE_FUNCTION ("cmhSMS_RdCnfCRES ()");
2453
2454 cmdBuf = smsShrdPrm.smsEntStat.curCmd;
2455 ownBuf = smsShrdPrm.smsEntStat.entOwn;
2456
2457 /*
2458 *-----------------------------------------------------------------
2459 * check for next SIM access
2460 *-----------------------------------------------------------------
2461 */
2462 switch (smsShrdPrm.prmRdSeq)
2463 {
2464 case SMS_READ_SIM_SMSP:
2465 if ((errCode = simShrdPrm.atb[aId].errCode) EQ SIM_NO_ERROR)
2466 {
2467 /* successful EF(SMSP) read */
2468
2469
2470 if (!cmhSMS_GetPrmSIM (ownBuf,
2471 simShrdPrm.atb[aId].exchData,
2472 simShrdPrm.atb[aId].dataLen))
2473 {
2474 errCode = SIM_CAUSE_OTHER_ERROR;
2475 }
2476 }
2477 if (smsShrdPrm.cbmPrm.cbmSIMmaxIdRge > 0)
2478 {
2479 dataField = SIM_CBMIR;
2480 dataLen = smsShrdPrm.cbmPrm.cbmSIMmaxIdRge * 4;
2481 break;
2482 }
2483 else
2484 smsShrdPrm.prmRdSeq--;
2485
2486 if (smsShrdPrm.cbmPrm.cbmSIMmaxId > 0)
2487 {
2488 dataField = SIM_CBMI;
2489 dataLen = smsShrdPrm.cbmPrm.cbmSIMmaxId * 2;
2490 break;
2491 }
2492 else
2493 smsShrdPrm.prmRdSeq--;
2494
2495 smsShrdPrm.cbmPrm.cbchOwner = (T_OWN)ownBuf;
2496 psaMMI_Cbch();
2497 smsShrdPrm.cbmPrm.cbchOwner = (T_OWN)CMD_SRC_NONE;
2498
2499 #ifdef SIM_TOOLKIT
2500 smsShrdPrm.prmRdSeq--; /* when SAT is on, then SMS_READ_CBMID is defined
2501 which is irrelevant for +CRES */
2502 #endif /* of SIM_TOOLKIT */
2503
2504 break;
2505
2506 case SMS_READ_SIM_CBMIR:
2507 if ((errCode = simShrdPrm.atb[aId].errCode) EQ SIM_NO_ERROR)
2508 { /* successful EF(CBMIR) read */
2509 if (!cmhSMS_GetCbmirSIM (ownBuf,
2510 simShrdPrm.atb[aId].exchData,
2511 simShrdPrm.atb[aId].dataLen))
2512 {
2513 errCode = SIM_CAUSE_OTHER_ERROR;
2514 }
2515 }
2516 if (smsShrdPrm.cbmPrm.cbmSIMmaxId > 0)
2517 {
2518 dataField = SIM_CBMI;
2519 dataLen = smsShrdPrm.cbmPrm.cbmSIMmaxId * 2;
2520 }
2521 else
2522 {
2523 smsShrdPrm.prmRdSeq--;
2524
2525 smsShrdPrm.cbmPrm.cbchOwner = (T_OWN)ownBuf;
2526 psaMMI_Cbch();
2527 smsShrdPrm.cbmPrm.cbchOwner = (T_OWN)CMD_SRC_NONE;
2528
2529 #ifdef SIM_TOOLKIT
2530 smsShrdPrm.prmRdSeq--; /* when SAT is on, then SMS_READ_CBMID is defined
2531 which is irrelevant for +CRES */
2532 #endif /* of SIM_TOOLKIT */
2533
2534 }
2535 break;
2536
2537 case SMS_READ_SIM_CBMI:
2538 if ((errCode = simShrdPrm.atb[aId].errCode) EQ SIM_NO_ERROR)
2539 { /* successful EF(CBMI) read */
2540 if (!cmhSMS_GetCbmiSIM (ownBuf,
2541 simShrdPrm.atb[aId].exchData,
2542 simShrdPrm.atb[aId].dataLen))
2543 {
2544 errCode = SIM_CAUSE_OTHER_ERROR;
2545 }
2546 }
2547 smsShrdPrm.cbmPrm.cbchOwner = (T_OWN)ownBuf;
2548 psaMMI_Cbch();
2549 smsShrdPrm.cbmPrm.cbchOwner = (T_OWN)CMD_SRC_NONE;
2550
2551 #ifdef SIM_TOOLKIT
2552 smsShrdPrm.prmRdSeq--; /* when SAT is on, then SMS_READ_CBMID is defined
2553 which is irrelevant for +CRES */
2554 #endif /* of SIM_TOOLKIT */
2555
2556 break;
2557
2558 default:
2559 smsShrdPrm.prmRdSeq = SMS_READ_SIM_CMPL;
2560 errCode = SIM_CAUSE_OTHER_ERROR;
2561 break;
2562 }
2563 if (--smsShrdPrm.prmRdSeq <= SMS_READ_SIM_CMPL)
2564 {
2565
2566 /* Implements Measure # 104 */
2567 cmhSMS_ResCSAS(ownBuf, cmdBuf, errCode);
2568 }
2569 else
2570 if (cmhSIM_ReadTranspEF (CMD_SRC_NONE, cmdBuf, FALSE, NULL,
2571 dataField, 0, dataLen,
2572 NULL, cmhSMS_RdCnfCRES) EQ AT_FAIL)
2573
2574 {
2575 smsShrdPrm.smsEntStat.curCmd = AT_CMD_NONE;
2576 smsShrdPrm.owner = (T_OWN)CMD_SRC_NONE;
2577 smsShrdPrm.smsEntStat.entOwn = CMD_SRC_NONE;
2578
2579 smsShrdPrm.prmRdSeq = SMS_READ_SIM_CMPL;
2580
2581 #ifdef SIM_TOOLKIT
2582 if (ownBuf EQ ((T_ACI_CMD_SRC)OWN_SRC_SAT )/*smsShrdPrm.fuRef >= 0*/)
2583 {
2584 psaSAT_FUConfirm ((int)simShrdPrm.fuRef, SIM_FU_ERROR);
2585 }
2586 else
2587 {
2588 #endif
2589 R_AT( RAT_CMS, ownBuf ) ( cmdBuf, CMS_ERR_UnknownErr, NULL );
2590 #ifdef SIM_TOOLKIT
2591 }
2592 #endif
2593 }
2594
2595 simShrdPrm.atb[aId].ntryUsdFlg = FALSE;
2596 }
2597
2598 /*
2599 +-------------------------------------------------------------------+
2600 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSR |
2601 | STATE : code ROUTINE : cmhSMS_InitSMSP |
2602 +-------------------------------------------------------------------+
2603
2604 PURPOSE : This function is used to store the parameters of EF(SMSP).
2605 */
2606 GLOBAL void cmhSMS_InitSMSP (SHORT aId)
2607 {
2608 T_ACI_CMD_SRC srcId;
2609 T_SMS_SET_PRM * elem ; /* points to SMS parameter set */
2610 UBYTE idx;
2611 UBYTE profile;
2612
2613 TRACE_FUNCTION ("cmhSMS_InitSMSP ()");
2614
2615 /*
2616 *-----------------------------------------------------------------
2617 * process SIM result
2618 *-----------------------------------------------------------------
2619 */
2620 srcId = (T_ACI_CMD_SRC)smsShrdPrm.owner;
2621
2622 switch (smsShrdPrm.prmRdSeq)
2623 {
2624 case SMS_READ_SIM_SMSP:
2625 if (simShrdPrm.atb[aId].errCode EQ SIM_NO_ERROR)
2626 { /* successful EF(SMSP) read */
2627 smsShrdPrm.aci_sms_parameter.smsParamMaxRec = simShrdPrm.atb[aId].recMax;
2628 smsShrdPrm.aci_sms_parameter.smsParamRecLen = simShrdPrm.atb[aId].dataLen;
2629
2630 if (set_prm_list EQ NULL)
2631 {
2632 set_prm_list = new_list();
2633 }
2634 profile = simShrdPrm.atb[aId].recNr;
2635 elem = find_element(set_prm_list, profile, cmhSMS_findPrflId);
2636
2637 if (elem EQ NULL)
2638 {
2639 ACI_MALLOC(elem, sizeof(T_SMS_SET_PRM));
2640 memset(elem, 0, sizeof(T_SMS_SET_PRM));
2641 insert_list(set_prm_list, elem);
2642 elem->prflId = profile;
2643 elem->numOfRefs = OWN_SRC_MAX;
2644 for( idx = 0; idx < OWN_SRC_MAX; idx++ )
2645 {
2646 smsShrdPrm.pSetPrm[idx] = (T_SMS_SET_PRM*) elem;
2647 }
2648
2649 }
2650 else
2651 {
2652 smsShrdPrm.pSetPrm[0] = (T_SMS_SET_PRM*) elem;
2653 }
2654
2655 cmhSMS_GetPrmSIM (CMD_SRC_LCL,
2656 simShrdPrm.atb[aId].exchData,
2657 simShrdPrm.atb[aId].dataLen);
2658 }
2659 else
2660 {
2661 smsShrdPrm.aci_sms_parameter.smsParamMaxRec = 0;
2662 smsShrdPrm.aci_sms_parameter.smsParamRecLen = 0;
2663 }
2664 if( !psaSIM_ChkSIMSrvSup( SRV_CBMIdRnge ))
2665 {
2666 smsShrdPrm.prmRdSeq--;
2667 goto CBMIR;
2668 }
2669 if (cmhSIM_ReadTranspEF (CMD_SRC_NONE, smsShrdPrm.smsEntStat.curCmd,
2670 FALSE, NULL, SIM_CBMIR, 0, 255,
2671 NULL, cmhSMS_InitSMSP) NEQ AT_FAIL)
2672 smsShrdPrm.prmRdSeq--;
2673 else
2674 {
2675 goto CBMIR;
2676 }
2677 break;
2678
2679 case SMS_READ_SIM_CBMIR:
2680 if (simShrdPrm.atb[aId].errCode EQ SIM_NO_ERROR)
2681 {
2682 smsShrdPrm.cbmPrm.cbmSIMmaxIdRge = simShrdPrm.atb[aId].dataLen / 4;
2683 cmhSMS_GetCbmirSIM (CMD_SRC_NONE,
2684 simShrdPrm.atb[aId].exchData,
2685 simShrdPrm.atb[aId].dataLen);
2686 }
2687 else
2688 smsShrdPrm.cbmPrm.cbmSIMmaxIdRge = 0;
2689
2690 CBMIR:
2691 if( !psaSIM_ChkSIMSrvSup( SRV_CBM_Ident ))
2692 {
2693 smsShrdPrm.prmRdSeq--;
2694 goto CBMI;
2695 }
2696 if (cmhSIM_ReadTranspEF (CMD_SRC_NONE, smsShrdPrm.smsEntStat.curCmd,
2697 FALSE, NULL, SIM_CBMI, 0, 255,
2698 NULL, cmhSMS_InitSMSP) NEQ AT_FAIL)
2699 smsShrdPrm.prmRdSeq--;
2700 else
2701 {
2702 #ifdef SIM_TOOLKIT
2703 goto CBMI;
2704 #else
2705 smsShrdPrm.prmRdSeq = SMS_READ_SIM_CMPL;
2706
2707 smsShrdPrm.smsEntStat.curCmd = AT_CMD_NONE;
2708 smsShrdPrm.smsEntStat.entOwn = simShrdPrm.owner = CMD_SRC_NONE;
2709 #endif /* of SIM_TOOLKIT */
2710 }
2711 break;
2712
2713 case SMS_READ_SIM_CBMI:
2714 if (simShrdPrm.atb[aId].errCode EQ SIM_NO_ERROR)
2715 {
2716 smsShrdPrm.cbmPrm.cbmSIMmaxId = simShrdPrm.atb[aId].dataLen / 2;
2717 cmhSMS_GetCbmiSIM (CMD_SRC_NONE,
2718 simShrdPrm.atb[aId].exchData,
2719 simShrdPrm.atb[aId].dataLen);
2720 }
2721 else
2722 smsShrdPrm.cbmPrm.cbmSIMmaxId = 0;
2723
2724 #ifdef SIM_TOOLKIT
2725 CBMI:
2726 if( (!psaSIM_ChkSIMSrvSup( SRV_DtaDownlCB )) OR
2727 smsShrdPrm.owner NEQ OWN_SRC_SAT)
2728 {
2729 smsShrdPrm.prmRdSeq--;
2730 goto CBMID;
2731 }
2732 if (cmhSIM_ReadTranspEF (CMD_SRC_NONE, smsShrdPrm.smsEntStat.curCmd,
2733 FALSE, NULL, SIM_CBMID, 0, 255,
2734 NULL, cmhSMS_InitSMSP) NEQ AT_FAIL)
2735 smsShrdPrm.prmRdSeq--;
2736 else
2737 {
2738 smsShrdPrm.prmRdSeq = SMS_READ_SIM_CMPL;
2739
2740 smsShrdPrm.smsEntStat.curCmd = AT_CMD_NONE;
2741 simShrdPrm.owner = (T_OWN)CMD_SRC_NONE;
2742 smsShrdPrm.smsEntStat.entOwn = CMD_SRC_NONE;
2743 }
2744 break;
2745
2746 case SMS_READ_SIM_CBMID:
2747 if (simShrdPrm.atb[aId].errCode EQ SIM_NO_ERROR)
2748 {
2749 /* Implements Measure # 59 */
2750 cmhSMS_SendCbDwnlSIM (simShrdPrm.atb[aId].exchData,
2751 simShrdPrm.atb[aId].dataLen);
2752 }
2753 else
2754 smsShrdPrm.cbmPrm.cbmSIMmaxSATId = 0;
2755
2756
2757 /*lint -fallthrough */
2758 default:
2759 CBMID:
2760
2761 #else
2762 /*lint -fallthrough*/
2763 default:
2764 CBMI:
2765 #endif /*SIM_TOOLKIT */
2766
2767 smsShrdPrm.cbmPrm.cbchOwner = (T_OWN)srcId;
2768 psaMMI_Cbch();
2769 smsShrdPrm.cbmPrm.cbchOwner = (T_OWN)CMD_SRC_NONE;
2770 {
2771 smsShrdPrm.prmRdSeq = SMS_READ_SIM_CMPL;
2772
2773 smsShrdPrm.smsEntStat.curCmd = AT_CMD_NONE;
2774 simShrdPrm.owner = (T_OWN)CMD_SRC_NONE;
2775 smsShrdPrm.smsEntStat.entOwn = CMD_SRC_NONE;
2776 }
2777 #ifdef SIM_TOOLKIT
2778 if (srcId EQ ((T_ACI_CMD_SRC)OWN_SRC_SAT) /*smsShrdPrm.fuRef >= 0*/)
2779 {
2780 smsShrdPrm.accessEnabled = TRUE;
2781 psaSAT_FUConfirm (simShrdPrm.fuRef,(USHORT)
2782 ((simShrdPrm.atb[aId].errCode EQ SIM_NO_ERROR)?
2783 SIM_FU_SUCC_ADD: SIM_FU_ERROR));
2784 }
2785 else
2786 #endif
2787 cmhSMS_ready ();
2788 break;
2789 }
2790
2791 simShrdPrm.atb[aId].ntryUsdFlg = FALSE;
2792 }
2793
2794 /*
2795 +-------------------------------------------------------------------+
2796 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSR |
2797 | STATE : code ROUTINE : cmhSMS_SMSResumeCnf |
2798 +-------------------------------------------------------------------+
2799
2800 PURPOSE : This function processes the MNSMS_RESUME_CNF primitive.
2801
2802 */
2803 GLOBAL void cmhSMS_SMSResumeCnf (T_MNSMS_RESUME_CNF * mnsms_resume_cnf)
2804 {
2805 UBYTE cmdBuf;
2806 UBYTE ownBuf;
2807
2808 TRACE_FUNCTION("cmhSMS_ResumeCnf()");
2809
2810 cmdBuf = smsShrdPrm.smsEntStat.curCmd;
2811 ownBuf = smsShrdPrm.smsEntStat.entOwn;
2812
2813 /* check whether resume has been successfully processed */
2814 if (mnsms_resume_cnf->cause EQ SMS_NO_ERROR)
2815 {
2816 R_AT( RAT_OK, (T_ACI_CMD_SRC)ownBuf ) ( cmdBuf );
2817 }
2818 else
2819 {
2820 /* command unsuccessful */
2821 R_AT ( RAT_CMS, (T_ACI_CMD_SRC)ownBuf )
2822 (
2823 cmdBuf,
2824 cmhSMS_GetCmsFromSms(mnsms_resume_cnf->cause),
2825 NULL
2826 );
2827 }
2828
2829 /* reset command */
2830 smsShrdPrm.smsEntStat.curCmd = AT_CMD_NONE;
2831 smsShrdPrm.owner = (T_OWN)CMD_SRC_NONE;
2832 smsShrdPrm.smsEntStat.entOwn = CMD_SRC_NONE;
2833 }
2834
2835 /*
2836 +-------------------------------------------------------------------+
2837 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSR |
2838 | STATE : code ROUTINE : cmhSMS_SMSQueryCnf |
2839 +-------------------------------------------------------------------+
2840
2841 PURPOSE : This function processes the MNSMS_QUERY_CNF primitive.
2842
2843 */
2844 GLOBAL void cmhSMS_SMSQueryCnf (T_MNSMS_QUERY_CNF * mnsms_query_cnf)
2845 {
2846 UBYTE cmdBuf;
2847 UBYTE ownBuf;
2848
2849 TRACE_FUNCTION("cmhSMS_SMSQueryCnf()");
2850
2851 cmdBuf = smsShrdPrm.smsEntStat.curCmd;
2852 ownBuf = smsShrdPrm.smsEntStat.entOwn;
2853
2854 /* check type of query request and process it */
2855 switch (mnsms_query_cnf->query_type)
2856 {
2857 case SMS_QUERY_DELIVER_STATUS:
2858 {
2859 if ( mnsms_query_cnf->v_deliver_status )
2860 {
2861 #ifdef TI_PS_FF_AT_P_CMD_CPRSM
2862 R_AT ( RAT_CPRSM, (T_ACI_CMD_SRC)ownBuf )
2863 ( cmhSMS_convertDeliverStatusToACI(mnsms_query_cnf->deliver_status ) );
2864 #endif /* TI_PS_FF_AT_P_CMD_CPRSM */
2865 R_AT( RAT_OK, (T_ACI_CMD_SRC)ownBuf ) ( cmdBuf );
2866 }
2867 else /* paramter inalid - unspecified protocol error */
2868 {
2869 TRACE_EVENT("cmhSMS_QueryCnf: ERROR: paramter invalid");
2870 R_AT ( RAT_CMS, (T_ACI_CMD_SRC)ownBuf )( cmdBuf, CMS_ERR_InValManInfo, NULL );
2871 }
2872 break;
2873 }
2874 default: /* unsupported query type - ME failure */
2875 {
2876 TRACE_EVENT("cmhSMS_QueryCnf: ERROR: unsupported query type");
2877 R_AT ( RAT_CMS, (T_ACI_CMD_SRC)ownBuf )( cmdBuf, CMS_ERR_MeFail, NULL );
2878 }
2879 } /* end switch */
2880
2881 /* reset command */
2882 smsShrdPrm.smsEntStat.curCmd = AT_CMD_NONE;
2883 smsShrdPrm.owner = (T_OWN)CMD_SRC_NONE;
2884 smsShrdPrm.smsEntStat.entOwn = CMD_SRC_NONE;
2885 }
2886
2887 /*
2888 +-------------------------------------------------------------------+
2889 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSR |
2890 | STATE : code ROUTINE : cmhSMS_ReadCbDtaDwnl |
2891 +-------------------------------------------------------------------+
2892
2893 PURPOSE : This function processes the T_SIM_MMI_INSERT_IND primitive.
2894
2895 */
2896 GLOBAL void cmhSMS_ReadCbDtaDwnl (T_SIM_MMI_INSERT_IND *sim_mmi_insert_ind)
2897 {
2898
2899 TRACE_FUNCTION("cmhSMS_ReadCbDtaDwnl()");
2900
2901 if (sim_mmi_insert_ind->cbmid_rec.c_rec NEQ 0)
2902 {
2903 /* Implements Measure # 59 */
2904 cmhSMS_SendCbDwnlSIM (sim_mmi_insert_ind->cbmid_rec.rec,
2905 sim_mmi_insert_ind->cbmid_rec.c_rec);
2906 }
2907 else
2908 {
2909 TRACE_EVENT(" CBMID records zero");
2910 smsShrdPrm.cbmPrm.cbmSIMmaxSATId = 0;
2911 }
2912 }
2913
2914 /*
2915 +-------------------------------------------------------------------+
2916 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSR |
2917 | STATE : code ROUTINE : cmhSMS_SMSQueryType |
2918 +-------------------------------------------------------------------+
2919
2920 PURPOSE : This function queries the message type of the T_MNSMS_MESSAGE_IND.
2921
2922 */
2923 GLOBAL BOOL cmhSMS_SMSQueryType (T_sms_sdu *sms_sdu,
2924 UBYTE *msg_type)
2925 {
2926 UBYTE ccdRet;
2927
2928 TRACE_FUNCTION("cmhSMS_SMSQueryType()");
2929
2930 if (sms_sdu->l_buf EQ 0)
2931 {
2932 TRACE_EVENT("empty SDU: no decoding");
2933 return FALSE;
2934 }
2935
2936 CCD_START;
2937 {
2938
2939 MCAST( sim_pdu, SIM_PDU ); /* sim_pdu points to _decodedMsg */
2940
2941 /* decoding outer layer */
2942 ccdRet = ccd_decodeMsg ( CCDENT_SMS,
2943 BOTH /* doesn't work with DOWNLINK!!! */,
2944 (T_MSGBUF *) sms_sdu,
2945 (UBYTE *) _decodedMsg, /* target */
2946 SMS_VT_SIM_PDU);
2947
2948 if ((ccdRet NEQ ccdOK) OR (!sim_pdu->v_tpdu)
2949 OR (_decodedMsg[0] NEQ SMS_VT_SIM_PDU))
2950 {
2951 TRACE_EVENT_P1("CCD Decoding Error: %d", ccdRet);
2952 CCD_END;
2953 return FALSE;
2954 }
2955 *msg_type = sim_pdu->tp_mti;
2956 }
2957 CCD_END;
2958
2959 return TRUE;
2960
2961 }
2962
2963 LOCAL BOOL cmhSMS_cpySTtoSM(T_ACI_CMGL_SM *p_sm,T_MNSMS_READ_CNF * mnsms_read_cnf)
2964 {
2965 T_ACI_CDS_SM p_st;
2966 T_MNSMS_STATUS_IND mnsms_status_ind;
2967 BOOL retCode = FALSE;
2968
2969 memcpy (&mnsms_status_ind.sms_sdu, &mnsms_read_cnf->sms_sdu,
2970 sizeof (T_sms_sdu));
2971 retCode = cmhSMS_cpyStatInd ( &p_st, &mnsms_status_ind);
2972 memcpy(p_sm->adress, p_st.addr, MAX_SMS_ADDR_DIG - 1 );
2973 cmhSMS_getStatCmh ( mnsms_read_cnf->status, &p_sm->stat );
2974 p_sm->msg_ref = mnsms_read_cnf->rec_num ;
2975 p_sm->tp_status=p_st.tp_status ;
2976 p_sm->toa .ton = p_st.toa .ton ;
2977 p_sm->toa.npi = p_st.toa.npi;
2978 p_sm->fo = p_st.fo;
2979 p_sm->scts =p_st.vpabs_scts ;
2980
2981 return (retCode);
2982 }
2983 /* Implements Measure # 59 */
2984 /*
2985 +-------------------------------------------------------------------+
2986 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSR |
2987 | STATE : code ROUTINE : cmhSMS_SendCbDwnlSIM |
2988 +-------------------------------------------------------------------+
2989 PARAMETERS : data - CBMID information
2990 data_len - Number of bytes in 'data' parameter
2991 RETURN : None
2992
2993 PURPOSE : This function gets the CBMID information and sends to SIM
2994
2995 */
2996
2997 LOCAL void cmhSMS_SendCbDwnlSIM(UBYTE *data, int data_len)
2998 {
2999 TRACE_FUNCTION("cmhSMS_SendCbDwnlSIM()");
3000 smsShrdPrm.cbmPrm.cbmSIMmaxSATId = data_len / 2;
3001 cmhSMS_GetCbDtaDwnlSIM (CMD_SRC_NONE,
3002 data,
3003 data_len);
3004 {
3005 PALLOC (sat_cbch_req, MMI_SAT_CBCH_DWNLD_REQ);
3006
3007 sat_cbch_req->count = (USHORT)smsShrdPrm.cbmPrm.CBDtaDwnlFoundIds;
3008 memset (sat_cbch_req->msg_id, NOT_PRESENT_16BIT,
3009 sizeof (sat_cbch_req->msg_id));
3010 memcpy (sat_cbch_req->msg_id, smsShrdPrm.cbmPrm.CBDtaDwnlIdent,
3011 (size_t)smsShrdPrm.cbmPrm.CBDtaDwnlFoundIds * 2);
3012
3013 PSENDX (PL, sat_cbch_req);
3014 }
3015 }
3016
3017 /* Implements Measure # 104 */
3018 /*
3019 +-------------------------------------------------------------------+
3020 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSR |
3021 | STATE : code ROUTINE : cmhSMS_ResCSAS |
3022 +-------------------------------------------------------------------+
3023 PARAMETERS : ownBuf - ACI command source
3024 cmdBuf - ACI Command type
3025 errCode - Error Code from SIM
3026 RETURN : None
3027
3028 PURPOSE : This function sends response to CSAS
3029
3030 */
3031 LOCAL void cmhSMS_ResCSAS(T_ACI_CMD_SRC ownBuf, T_ACI_AT_CMD cmdBuf, USHORT errCode)
3032 {
3033 TRACE_FUNCTION("cmhSMS_ResCSAS()");
3034
3035 smsShrdPrm.smsEntStat.curCmd = AT_CMD_NONE;
3036 smsShrdPrm.owner = (T_OWN)CMD_SRC_NONE;
3037 smsShrdPrm.smsEntStat.entOwn = CMD_SRC_NONE;
3038
3039 if (errCode EQ SIM_NO_ERROR)
3040 {
3041 R_AT( RAT_OK, ownBuf ) ( cmdBuf );
3042 }
3043 else
3044 {
3045 R_AT( RAT_CMS, ownBuf ) /* unsuccessful SIM write */
3046 (
3047 cmdBuf,
3048 cmhSMS_GetCmsFromSim ( errCode ),
3049 NULL
3050 );
3051 }
3052 }
3053
3054 /* Implements Measure # 114 */
3055 /*
3056 +-------------------------------------------------------------------+
3057 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSR |
3058 | STATE : code ROUTINE : cmhSMS_ErrRes |
3059 +-------------------------------------------------------------------+
3060 PARAMETERS : ownBuf - ACI command source
3061 cmdBuf - ACI Command type
3062 cause - Error cause that has come from SMS entity
3063 RETURN : None
3064
3065 PURPOSE : This function sends error response.
3066
3067 */
3068 LOCAL void cmhSMS_ErrRes(T_ACI_CMD_SRC ownBuf, T_ACI_AT_CMD cmdBuf, USHORT cause)
3069 {
3070 TRACE_FUNCTION("cmhSMS_ErrRes()");
3071
3072 if (ownBuf EQ CMD_SRC_LCL)
3073 {
3074 if (smsShrdPrm.errorCB NEQ NULL)
3075 {
3076 smsShrdPrm.errorCB
3077 (
3078 cmdBuf,
3079 cmhSMS_GetCmsFromSms(cause),
3080 NULL
3081 );
3082 }
3083 }
3084 else
3085 {
3086 R_AT ( RAT_CMS, ownBuf )
3087 (
3088 cmdBuf,
3089 cmhSMS_GetCmsFromSms(cause),
3090 NULL
3091 );
3092 }
3093 }
3094 /*==== EOF ========================================================*/