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

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