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

src/aci2, src/condat2: import of g23m/condat source pieces from TCS211
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 26 Sep 2016 00:29:36 +0000
parents
children e9e72ec7b318
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 /* send CMS error code for SMS memory full */
1026 if(mnsms_error_ind->cause == SMS_CAUSE_MEM_FULL)
1027 {
1028 char *sa;
1029 ACI_MALLOC(sa,KEY + BYTE_LTH);
1030 sprintf(sa,"+CMS ERROR: %d",CMS_ERR_MemFull);
1031 io_sendMessage(3, sa, ATI_NORMAL_OUTPUT);
1032 ACI_MFREE(sa);
1033 rCI_PlusCMS ( 0, CMS_ERR_MemFull, NULL );
1034 }
1035
1036 if( (mnsms_error_ind->cause != SMS_CAUSE_MEM_FULL) &&
1037 (mnsms_error_ind->cause != SMS_CAUSE_MEM_AVAIL) )
1038 {
1039 smsShrdPrm.cnma_ack_expected = FALSE;
1040 cmhSMS_resetMtDsCnmiParam();
1041 }
1042 else
1043 { /* process the SMS memory full/avail indication */
1044 sIndValues.sCindSmsFullParam = (mnsms_error_ind->cause EQ SMS_CAUSE_MEM_AVAIL)
1045 ? CIND_SMSFULL_INDICATOR_MEMAVAIL
1046 : CIND_SMSFULL_INDICATOR_MEMFULL;
1047 sIndValues.sCindSignalParam = CIND_SIGNAL_INDICATOR_INVALID;
1048
1049 for( i = CMD_SRC_LCL; i < CMD_SRC_MAX; i++)
1050 {
1051 if( ((cmhPrm[i].mmCmdPrm.sIndicationParam.sMmCINDSettings.sCindSmsFullParam EQ CIND_SMSFULL_INDICATOR_MEMFULL) AND
1052 (cmhPrm[i].mmCmdPrm.sIndicationParam.sMmCMERSettings.sCmerIndParam EQ CMER_INDICATOR_2)) OR
1053 ((cmhPrm[i].mmCmdPrm.sIndicationParam.sMmCINDSettings.sCindSmsFullParam <= CIND_SMSFULL_INDICATOR_MEMAVAIL) AND
1054 (cmhPrm[i].mmCmdPrm.sIndicationParam.sMmCMERSettings.sCmerIndParam EQ CMER_INDICATOR_1)) )
1055 { /* process the service of +CIEV */
1056 TRACE_EVENT("send +CIEV (SMS-full/avail)");
1057 R_AT (RAT_CIEV, i) ( sIndValues, cmhPrm[i].mmCmdPrm.sIndicationParam.sMmCMERSettings );
1058 }
1059 }
1060 }
1061 return 0;
1062 }
1063
1064 /*
1065 +-------------------------------------------------------------------+
1066 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSR |
1067 | STATE : code ROUTINE : cmhSMS_SMSDeliver |
1068 +-------------------------------------------------------------------+
1069
1070 PURPOSE : This function is used to notify the command handler of
1071 the receiving of a SMS-DELIVER.
1072 */
1073 #ifndef NTRACE
1074 LOCAL void trace_SMSDeliver ( T_MNSMS_MESSAGE_IND * mnsms_message_ind )
1075 {
1076 #ifdef _CONC_TESTING_
1077
1078 char trcBuf[80];
1079 char *writeP;
1080 int count;
1081 USHORT offset;
1082
1083 TRACE_FUNCTION ("trace_SMSDeliver");
1084
1085 TRACE_EVENT_P1("cmt:bitoffset:%d", mnsms_message_ind->sms_sdu.o_buf);
1086 TRACE_EVENT_P1("cmt:lenght:%d", mnsms_message_ind->sms_sdu.l_buf);
1087 offset = mnsms_message_ind->sms_sdu.o_buf>>3;
1088 writeP = trcBuf;
1089 for (count=offset; count<offset+20; count++)
1090 {
1091 writeP += sprintf (writeP, " %02X", mnsms_message_ind->sms_sdu.buf[count]);
1092 }
1093 TRACE_EVENT("buf: ");
1094 *writeP = '\0';
1095 TRACE_EVENT(trcBuf);
1096
1097 writeP = trcBuf;
1098 for (; count<offset+40; count++)
1099 {
1100 writeP += sprintf (writeP, " %02X", mnsms_message_ind->sms_sdu.buf[count]);
1101 }
1102 *writeP = '\0';
1103 TRACE_EVENT(trcBuf);
1104 #endif
1105 }
1106 #endif
1107
1108 #if defined SMI OR defined MFW OR defined FF_MMI_RIV
1109 LOCAL void rAT_SMS_Deliver(T_MNSMS_MESSAGE_IND * mnsms_message_ind, T_ACI_CMGL_SM *p_sm)
1110 {
1111 #ifdef FF_MMI_RIV
1112 T_ACI_CMGF_MOD sms_input_mode = CMGF_MOD_NotPresent;
1113 #endif /* FF_MMI_RIV */
1114
1115 TRACE_FUNCTION ("rAT_SMS_Deliver");
1116
1117 #ifdef FF_MMI_RIV
1118 if(smsShrdPrm.perccmgf_smbs_mode EQ PERC_SMBS_MOD_ENABLE)
1119 {
1120 /*send both formats*/
1121 rAT_PlusCMTPdu (mnsms_message_ind);
1122 R_AT( RAT_CMT, CMD_SRC_LCL ) (p_sm);
1123 return;
1124 }
1125
1126 /* else: no SMBS enabled, CMGF mode decides */
1127 qAT_PlusCMGF (CMD_SRC_LCL, &sms_input_mode);
1128 if (sms_input_mode EQ CMGF_MOD_Pdu)
1129 {
1130 rAT_PlusCMTPdu (mnsms_message_ind);
1131 }
1132 else
1133 {
1134 R_AT( RAT_CMT, CMD_SRC_LCL ) (p_sm);
1135 }
1136 return;
1137 #endif /* FF_MMI_RIV */
1138
1139 /* if GPF MMI call usual callback */
1140 R_AT( RAT_CMT, CMD_SRC_LCL ) (p_sm);
1141 }
1142 #endif /* SMI OR defined MFW OR defined FF_MMI_RIV */
1143
1144 GLOBAL SHORT cmhSMS_SMSDeliver ( T_MNSMS_MESSAGE_IND * mnsms_message_ind )
1145 {
1146 UBYTE idx;
1147 #if defined SMI OR defined MFW OR defined FF_MMI_RIV OR defined _CONC_TESTING_
1148 T_ACI_CMGL_SM *p_sm;
1149 #endif /* SMI OR defined MFW OR defined FF_MMI_RIV OR defined _CONC_TESTING_*/
1150
1151 TRACE_FUNCTION ("cmhSMS_SMSDeliver");
1152
1153 #ifndef NTRACE
1154 trace_SMSDeliver ( mnsms_message_ind );
1155 #endif
1156
1157 if( smsShrdPrm.CNMImt EQ 0 )
1158 {
1159 TRACE_EVENT("cmhSMS_SMSDeliver():[ERR] <mt>==0 -> SMS will not be routed ");
1160 return 0;
1161 }
1162
1163 #if defined SMI OR defined MFW OR defined FF_MMI_RIV OR defined _CONC_TESTING_
1164 ACI_MALLOC(smsShrdPrm.pDecMsg, sizeof(T_ACI_CMGL_SM) );
1165 p_sm = smsShrdPrm.pDecMsg;
1166 if (cmhSMS_cpyMsgInd ( p_sm, mnsms_message_ind) EQ FALSE)
1167 {
1168 TRACE_EVENT("cmhSMS_SMSDeliver():[ERR] decoding of SMS");
1169 if (p_sm->stat NEQ SMS_STAT_Invalid)
1170 {
1171 TRACE_EVENT("cmhSMS_SMSDeliver():[ERR] SMS decoding failed, but status not SMS_STAT_Invalid");
1172 }
1173 }
1174 #endif /* SMI OR defined MFW OR defined FF_MMI_RIV */
1175
1176
1177 if (smsShrdPrm.CSMSservice EQ CSMS_SERV_GsmPh2Plus)
1178 smsShrdPrm.cnma_ack_expected = TRUE;
1179
1180 /*
1181 *-----------------------------------------------------------------
1182 * new message indication
1183 *-----------------------------------------------------------------
1184 */
1185
1186 /* inform LOCAL MMI of new message */
1187 #if defined SMI OR defined MFW OR defined FF_MMI_RIV
1188 rAT_SMS_Deliver(mnsms_message_ind, p_sm);
1189 #endif /* SMI OR defined MFW OR defined FF_MMI_RIV */
1190
1191 /* If the SMS shared params indicate no valid source interested in
1192 * the SMS indications, the indication is buffered */ /* Issue 25033 */
1193 if( smsShrdPrm.smsSrcId EQ CMD_SRC_NONE )
1194 {
1195 T_CNMI_IND ind;
1196
1197 TRACE_EVENT("cmhSMS_SMSDeliver(): No registered source for ");
1198 memcpy ( &ind.cmt, mnsms_message_ind, sizeof ( T_MNSMS_MESSAGE_IND) );
1199 #ifdef DTI
1200 cmd_addCnmiNtry ( CNMI_CMT, &ind );
1201 #endif
1202 if ( smsShrdPrm.cnma_ack_expected EQ TRUE )
1203 { /* the acknowledge must be send automatically, because terminal is busy */
1204 PALLOC (mnsms_ack_res, MNSMS_ACK_RES);
1205
1206 TRACE_EVENT("rCI_PlusCMT(): send 'automatic' acknowledge (Phase2+ mode and buffer)");
1207
1208 mnsms_ack_res->resp = SMS_RP_ACK;
1209 mnsms_ack_res->sms_sdu.o_buf = 0;
1210 mnsms_ack_res->sms_sdu.l_buf = 0;
1211
1212 PSENDX (SMS, mnsms_ack_res);
1213
1214 smsShrdPrm.cnma_ack_expected = FALSE;
1215 }
1216 }
1217 else
1218 {
1219 /* tell any remote source */
1220 for( idx = CMD_SRC_LCL+1; idx < CMD_SRC_MAX; idx++ )
1221 {
1222 #if defined _SIMULATION_ AND defined _CONC_TESTING_
1223 /* don't display "+CMT: ..." in simulation if conc testing */
1224 if (!concShrdPrm.concTesting)
1225 #endif
1226 {
1227 R_AT( RAT_CMT, idx ) ( mnsms_message_ind );
1228 }
1229 }
1230 }
1231
1232 if (smsShrdPrm.pDecMsg)
1233 {
1234 ACI_MFREE(smsShrdPrm.pDecMsg);
1235 smsShrdPrm.pDecMsg = NULL;
1236 }
1237
1238 return 0;
1239 }
1240
1241
1242 /*
1243 +-------------------------------------------------------------------+
1244 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSR |
1245 | STATE : code ROUTINE : cmhSMS_SMSMemory |
1246 +-------------------------------------------------------------------+
1247
1248 PURPOSE : This function is used to notify the command handler of
1249 an incoming SMS written to preferred message storage.
1250 */
1251 GLOBAL SHORT cmhSMS_SMSMemory ( T_MNSMS_MESSAGE_IND * mnsms_message_ind)
1252 {
1253 USHORT idx; /* holds command source id */
1254 T_ACI_SMS_STOR mem; /* holds message storage */
1255 T_ACI_CMGL_SM sm;
1256
1257 #ifdef _CONC_TESTING_
1258 #ifndef NTRACE
1259 char trcBuf[80];
1260 char *writeP;
1261 int count;
1262 USHORT offset;
1263
1264 TRACE_EVENT_P1("cmti:rec_num: %d", mnsms_message_ind->rec_num);
1265 TRACE_EVENT_P1("cmti:status: %d", mnsms_message_ind->status);
1266 offset = mnsms_message_ind->sms_sdu.o_buf>>3;
1267 writeP = trcBuf;
1268 for (count=offset; count<offset+20; count++)
1269 {
1270 writeP += sprintf (writeP, " %02X", mnsms_message_ind->sms_sdu.buf[count]);
1271 }
1272 TRACE_EVENT("buf: ");
1273 *writeP = '\0';
1274 TRACE_EVENT(trcBuf);
1275
1276 writeP = trcBuf;
1277 for (; count<offset+40; count++)
1278 {
1279 writeP += sprintf (writeP, " %02X", mnsms_message_ind->sms_sdu.buf[count]);
1280 }
1281 *writeP = '\0';
1282 TRACE_EVENT(trcBuf);
1283 #endif
1284 #endif
1285
1286 TRACE_FUNCTION ("cmhSMS_SMSMemory ()");
1287
1288 cmhSMS_getMemCmh ( mnsms_message_ind->mem_type, &mem );
1289
1290 switch (mnsms_message_ind->mem_type)
1291 {
1292 case MEM_ME:
1293 smsShrdPrm.aci_sms_parameter.meUsed++;
1294 break;
1295 case MEM_SM:
1296 smsShrdPrm.aci_sms_parameter.simUsed++;
1297 break;
1298 default:
1299 TRACE_EVENT("wrong memtype");
1300 return AT_FAIL;
1301 }
1302
1303 #if defined SMI OR defined MFW OR defined FF_MMI_RIV OR defined _CONC_TESTING_
1304 if (cmhSMS_cpyMsgInd ( &sm, mnsms_message_ind ) EQ FALSE)
1305 {
1306 TRACE_EVENT("cmhSMS_SMSMemory ():[ERR] decoding of SMS");
1307 if (sm.stat NEQ SMS_STAT_Invalid)
1308 {
1309 TRACE_EVENT("cmhSMS_SMSMemory():[ERR] SMS decoding failed, but status not SMS_STAT_Invalid");
1310 }
1311 }
1312 #endif
1313
1314
1315 /*
1316 *-----------------------------------------------------------------
1317 * new message indication
1318 *-----------------------------------------------------------------
1319 */
1320
1321
1322 #if defined FF_MMI_RIV
1323 /* in case of RIV MMI: check if SMBS is enabled for sending also PDU data */
1324 if(smsShrdPrm.perccmgf_smbs_mode EQ PERC_SMBS_MOD_ENABLE)
1325 {
1326 rAT_PlusCMTPdu (mnsms_message_ind);
1327 }
1328 #endif /* FF_MMI_RIV */
1329
1330 R_AT( RAT_CMTI, CMD_SRC_LCL ) (mem, sm.msg_ref, &sm);
1331
1332 /* If the SMS shared params indicate no valid source interested in
1333 * the SMS indications, the indication is buffered */ /* Issue 25033 */
1334 if( smsShrdPrm.smsSrcId EQ CMD_SRC_NONE )
1335 {
1336 T_CNMI_IND ind;
1337
1338 ind.cmti.mem = mem;
1339 ind.cmti.index = mnsms_message_ind->rec_num;
1340 #ifdef DTI
1341 cmd_addCnmiNtry ( CNMI_CMTI, &ind );
1342 #endif
1343 }
1344 else
1345 {
1346 for( idx = CMD_SRC_LCL+1; idx < CMD_SRC_MAX; idx++ )
1347 {
1348 #if defined _SIMULATION_ AND defined _CONC_TESTING_
1349 /* don't display "+CMT: ..." in simulation if conc testing */
1350 if (!concShrdPrm.concTesting)
1351 #endif
1352 {
1353 /* don't need the decoded message for Command Interpreter */
1354 R_AT( RAT_CMTI, idx ) ( mem, mnsms_message_ind->rec_num );
1355 }
1356 }
1357 }
1358
1359 return AT_CMPL;
1360 }
1361
1362 /*
1363 +-------------------------------------------------------------------+
1364 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSR |
1365 | STATE : code ROUTINE : cmhSMS_SMSStatRpt |
1366 +-------------------------------------------------------------------+
1367
1368 PURPOSE : This function is used to notify the command handler of
1369 the receiving of a SMS-STATUS-REPORT.
1370 */
1371 GLOBAL SHORT cmhSMS_SMSStatRpt ( T_MNSMS_STATUS_IND * mnsms_status_ind )
1372 {
1373 USHORT idx; /* holds command source id */
1374 T_ACI_CDS_SM* p_st;
1375
1376 TRACE_FUNCTION ("cmhSMS_SMSStatRpt ()");
1377
1378
1379 #if defined SMI OR defined MFW OR defined FF_MMI_RIV
1380 ACI_MALLOC(smsShrdPrm.pDecMsg, sizeof(T_ACI_CDS_SM) );
1381 p_st = (T_ACI_CDS_SM*)smsShrdPrm.pDecMsg;
1382 cmhSMS_cpyStatInd ( p_st, mnsms_status_ind);
1383 #endif
1384
1385
1386 if (smsShrdPrm.CSMSservice EQ CSMS_SERV_GsmPh2Plus)
1387 smsShrdPrm.cnma_ack_expected = TRUE;
1388
1389 /*
1390 *-----------------------------------------------------------------
1391 * new message indication
1392 *-----------------------------------------------------------------
1393 */
1394 {
1395 T_ACI_CMGF_MOD sms_input_mode = CMGF_MOD_NotPresent;
1396
1397 /* If the SMS shared params indicate no valid source interested in
1398 * the SMS indications, the indication is buffered */ /* Issue 25033 */
1399 if( smsShrdPrm.smsSrcId EQ CMD_SRC_NONE )
1400 {
1401 T_CNMI_IND ind;
1402
1403 memcpy ( &ind.cds, mnsms_status_ind, sizeof ( T_MNSMS_STATUS_IND) );
1404 #ifdef DTI
1405 cmd_addCnmiNtry ( CNMI_CDS, &ind );
1406 #endif
1407 }
1408
1409 for( idx = 0; idx < CMD_SRC_MAX; idx++ )
1410 {
1411 if (idx EQ CMD_SRC_LCL)
1412 {
1413 #ifdef FF_MMI_RIV
1414 qAT_PlusCMGF (CMD_SRC_LCL, &sms_input_mode);
1415 if (sms_input_mode EQ CMGF_MOD_Pdu)
1416 {
1417 rAT_PlusCDSPdu (mnsms_status_ind);
1418 }
1419 else
1420 {
1421 R_AT( RAT_CDS, idx ) ( p_st );
1422 }
1423 #else
1424 R_AT( RAT_CDS, idx ) ( p_st );
1425 #endif
1426 }
1427 else
1428 {
1429 R_AT( RAT_CDS, idx ) ( mnsms_status_ind );
1430 }
1431
1432 }
1433 }
1434
1435 if (smsShrdPrm.pDecMsg)
1436 {
1437 ACI_MFREE(smsShrdPrm.pDecMsg);
1438 smsShrdPrm.pDecMsg = NULL;
1439 }
1440
1441 return 0;
1442 }
1443
1444
1445 /*
1446 +-------------------------------------------------------------------+
1447 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSR |
1448 | STATE : code ROUTINE : cmhSMS_cpyLstData |
1449 +-------------------------------------------------------------------+
1450
1451 PURPOSE : This function is used to copy the data read from memory.
1452 It sends a notification using the callback mechanism of
1453 ACI if necessary.
1454 */
1455 GLOBAL void cmhSMS_cpyLstData ( T_ACI_AT_CMD curCmd,
1456 T_ACI_CMD_SRC entOwn,
1457 T_MNSMS_READ_CNF * mnsms_read_cnf )
1458 {
1459 SHORT nextIdx; /* index of next short message */
1460
1461 TRACE_FUNCTION ("cmhSMS_cpyLstData ()");
1462
1463 nextIdx = mnsms_read_cnf->rec_next;
1464
1465 if ( entOwn EQ CMD_SRC_LCL)
1466 {
1467 #ifdef FF_MMI_RIV
1468 {
1469 T_ACI_CMGF_MOD sms_input_mode = CMGF_MOD_NotPresent;
1470
1471 qAT_PlusCMGF (CMD_SRC_LCL, &sms_input_mode);
1472 if (sms_input_mode EQ CMGF_MOD_Pdu )
1473 {
1474 if (curCmd EQ AT_CMD_CMGL)
1475 {
1476 rAT_PlusCMGLPdu (mnsms_read_cnf);
1477 }
1478 else if (curCmd EQ AT_CMD_P_CMGL)
1479 {
1480 rAT_PercentCMGLPdu (mnsms_read_cnf);
1481 }
1482 }
1483 else if (curCmd EQ AT_CMD_CMGL)
1484 {
1485 R_AT ( RAT_CMGL, entOwn ) ( smsShrdPrm.pDecMsg );
1486 }
1487 else if (curCmd EQ AT_CMD_P_CMGL)
1488 {
1489 R_AT ( RAT_P_CMGL, entOwn ) ( smsShrdPrm.pDecMsg );
1490 }
1491 }
1492 #else
1493 if (curCmd EQ AT_CMD_CMGL)
1494 {
1495 R_AT ( RAT_CMGL, entOwn ) ( smsShrdPrm.pDecMsg );
1496 }
1497 else if (curCmd EQ AT_CMD_P_CMGL)
1498 {
1499 R_AT ( RAT_P_CMGL, entOwn ) ( smsShrdPrm.pDecMsg );
1500 }
1501
1502 #endif
1503 }
1504 else if (curCmd EQ AT_CMD_CMGL)
1505 {
1506 R_AT ( RAT_CMGL, entOwn ) ( mnsms_read_cnf );
1507 /* inform BMI */
1508 cmh_logRslt ( entOwn, RAT_OK, AT_CMD_CMGL, mnsms_read_cnf->rec_num, -1, -1 );
1509 }
1510 else if (curCmd EQ AT_CMD_P_CMGL)
1511 {
1512 /* the message shall not be displayed for ReadMode as Status Change */
1513 if (smsShrdPrm.rdMode NEQ SMS_READ_StatusChange)
1514 {
1515 R_AT ( RAT_P_CMGL, entOwn ) ( mnsms_read_cnf );
1516 /* inform BMI */
1517 cmh_logRslt ( entOwn, RAT_OK, AT_CMD_P_CMGL, mnsms_read_cnf->rec_num, -1, -1 );
1518 }
1519 }
1520
1521 if (nextIdx NEQ SMS_RECORD_NOT_EXIST)
1522 {
1523 /*
1524 *-----------------------------------------------------------
1525 * request the next list elements of given cmglStat state
1526 *-----------------------------------------------------------
1527 */
1528 psaSMS_ReadReq ( smsShrdPrm.mem1, nextIdx,
1529 smsShrdPrm.rdMode, cmglStat );
1530 }
1531 else
1532 {
1533 /*
1534 *-----------------------------------------------------------
1535 * no more messages are available
1536 *-----------------------------------------------------------
1537 */
1538
1539 /* reset the command context */
1540 smsShrdPrm.smsEntStat.curCmd = AT_CMD_NONE;
1541 smsShrdPrm.smsEntStat.entOwn = smsShrdPrm.owner = OWN_NONE;
1542
1543 R_AT ( RAT_OK, entOwn ) ( curCmd );
1544 }
1545 }
1546
1547
1548 /*
1549 +-------------------------------------------------------------------+
1550 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSR |
1551 | STATE : code ROUTINE : cmhSMS_SMReadCMSS |
1552 +-------------------------------------------------------------------+
1553
1554 PURPOSE : This function processes the mnsms_read_cnf which was
1555 triggered by +CMSS.
1556 */
1557 GLOBAL void cmhSMS_SMReadCMSS ( T_MNSMS_READ_CNF * mnsms_read_cnf)
1558 {
1559 T_SMS_SET_PRM * pSMSSetPrm; /* points to SMS parameter set */
1560 UBYTE srcId;
1561 UBYTE fo;
1562 T_ACI_CMGL_SM *p_sm;
1563 T_tp_da da_addr;
1564 T_ACI_RETURN ret=AT_CMPL;
1565 UBYTE modify=SMS_MODIFY_NON;
1566
1567 #ifdef _CONC_TESTING_
1568 char trcBuf[80];
1569 char *writeP;
1570 int count;
1571 #endif
1572
1573 TRACE_FUNCTION ("cmhSMS_SMReadCMSS ()");
1574
1575
1576 srcId = smsShrdPrm.smsEntStat.entOwn;
1577 pSMSSetPrm = smsShrdPrm.pSetPrm[srcId];
1578
1579 if (smsShrdPrm.pDecMsg EQ NULL)
1580 {
1581 ACI_MALLOC(smsShrdPrm.pDecMsg, sizeof(T_ACI_CMGL_SM) );
1582 p_sm = smsShrdPrm.pDecMsg;
1583 /* decode message */
1584 cmhSMS_cpyReadCnf ( p_sm, mnsms_read_cnf );
1585 }
1586 else
1587 p_sm = smsShrdPrm.pDecMsg;
1588
1589 memset (&da_addr, 0, sizeof(T_tp_da));
1590
1591 /* start: check FDN if enabled */
1592 if (pb_get_fdn_mode () EQ FDN_ENABLE AND
1593 pb_get_fdn_classtype() EQ CLASS_VceDatFaxSms )
1594 {
1595
1596 TRACE_EVENT_P1("cmhSMS_SMReadCMSS: FDN check: %s", p_sm->adress );
1597
1598 if (pb_check_fdn (0, (const UBYTE*) p_sm->adress) EQ PHB_OK)
1599 {
1600 TRACE_EVENT("cmhSMS_SMReadCMSS: Found match in FDN!");
1601 }
1602 else
1603 {
1604 TRACE_EVENT("cmhSMS_SMReadCMSS: No match in FDN found, SMS rejected!");
1605 /* error notification */
1606 R_AT( RAT_CMS, smsShrdPrm.smsEntStat.entOwn )
1607 ( smsShrdPrm.smsEntStat.curCmd, CMS_ERR_OpNotAllowed, NULL );
1608 /* release context */
1609 smsShrdPrm.smsEntStat.curCmd = AT_CMD_NONE;
1610 smsShrdPrm.smsEntStat.entOwn = smsShrdPrm.owner = CMD_SRC_NONE;
1611 return;
1612 }
1613 }
1614 /* end: check FDN if enabled */
1615
1616 /*
1617 * ACI-SPR-17004: set RFU bits of status to 0 if present since these
1618 * should be ignored in a GSM session (GSM 11.11 section 9.3)
1619 */
1620 cmhSMS_removeStatusRFUBits( &mnsms_read_cnf->status );
1621
1622 ACI_MALLOC(smsShrdPrm.tpdu.tp_submit, sizeof(T_TP_SUBMIT));
1623
1624 /* SMS-SUBMIT received */
1625 if ((mnsms_read_cnf->status EQ SMS_RECORD_STO_UNSENT) OR
1626 (mnsms_read_cnf->status EQ SMS_RECORD_STO_SENT) OR
1627 (mnsms_read_cnf->status EQ SMS_RECORD_STAT_UNRCVD) OR
1628 (mnsms_read_cnf->status EQ SMS_RECORD_STAT_UNSTRD) OR
1629 (mnsms_read_cnf->status EQ SMS_RECORD_STAT_STRD) )
1630 {
1631
1632 /* destination address from stored message */
1633 if (p_sm->adress[0] NEQ '\0')
1634 {
1635 cmhSMS_getAdrBcd ( da_addr.num, &da_addr.c_num, MAX_SMS_ADDR_DIG, p_sm->adress);
1636 da_addr.ton = p_sm->toa.ton;
1637 da_addr.npi = p_sm->toa.npi;
1638 da_addr.digits = da_addr.c_num;
1639 }
1640
1641 /* service center address from shared parameter */
1642 if (pSMSSetPrm->sca.c_num NEQ 0)
1643 {
1644 memcpy (&smsShrdPrm.tpdu.sc_addr, &pSMSSetPrm->sca, sizeof(T_rp_addr));
1645 modify |= SMS_MODIFY_SCA;
1646
1647 }
1648
1649 /* ACI-SPR-22528.The memory is allocated for smsShrdPrm.tpdu.tp_submit
1650 only when it is necessary*/
1651
1652
1653 cmhSMS_fillTpSubmit (smsShrdPrm.tpdu.tp_submit,
1654 srcId,
1655 0, /* fo */
1656 0,
1657 &da_addr,
1658 NULL,
1659 0,
1660 NULL );
1661 }
1662 else
1663 {
1664 /* SMS-DELIVER received */
1665
1666 T_ACI_SM_DATA packedData;
1667 UBYTE byte_offset=0;
1668
1669 /* service center address from shared parameter */
1670 if (pSMSSetPrm->sca.c_num NEQ 0)
1671 {
1672 memcpy (&smsShrdPrm.tpdu.sc_addr, &pSMSSetPrm->sca, sizeof(T_rp_addr));
1673 }
1674 else
1675 {
1676 if (p_sm->sca[0] NEQ '\0')
1677 {
1678 cmhSMS_getAdrBcd( smsShrdPrm.tpdu.sc_addr.num,
1679 &smsShrdPrm.tpdu.sc_addr.c_num,
1680 MAX_SMS_ADDR_DIG, p_sm->sca);
1681 smsShrdPrm.tpdu.sc_addr.ton = p_sm->tosca.ton;
1682 smsShrdPrm.tpdu.sc_addr.npi = p_sm->tosca.npi;
1683 smsShrdPrm.tpdu.sc_addr.v_ton = TRUE;
1684 smsShrdPrm.tpdu.sc_addr.v_npi = TRUE;
1685 }
1686 }
1687
1688 fo = (pSMSSetPrm->msgType & (~TP_MTI_MASK)) | TP_MTI_SMS_SUBMIT;
1689
1690 if (p_sm->udh.len)
1691 byte_offset = p_sm->udh.len+1;
1692
1693 /* ACI-SPR-22528.The memory is allocated for smsShrdPrm.tpdu.tp_submit
1694 only when it is necessary*/
1695
1696 cmhSMS_rdcSmsPp ( byte_offset,
1697 p_sm -> dcs,
1698 ( UBYTE * ) p_sm->data.data, ( UBYTE ) p_sm->data.len,
1699 packedData.data, &packedData.len);
1700
1701 if (p_sm->adress[0] NEQ '\0')
1702 {
1703 cmhSMS_getAdrBcd ( da_addr.num, &da_addr.c_num, MAX_SMS_ADDR_DIG, p_sm->adress);
1704 da_addr.ton = p_sm->toa.ton;
1705 da_addr.npi = p_sm->toa.npi;
1706 da_addr.digits = da_addr.c_num;
1707 }
1708
1709 cmhSMS_fillTpSubmit (smsShrdPrm.tpdu.tp_submit,
1710 srcId,
1711 fo,
1712 0,
1713 &da_addr,
1714 &packedData,
1715 p_sm->data.len,
1716 &p_sm->udh );
1717
1718 modify = SMS_MODIFY_ALL;
1719 }
1720
1721 {
1722 PALLOC (mnsms_submit_req, MNSMS_SUBMIT_REQ);
1723 mnsms_submit_req->rec_num = mnsms_read_cnf->rec_num;
1724 mnsms_submit_req->mem_type = smsShrdPrm.mem2;
1725 mnsms_submit_req->condx = SMS_CONDX_OVR_ANY;
1726 mnsms_submit_req->modify = modify;
1727
1728 #ifdef SIM_TOOLKIT
1729 if (psaSIM_ChkSIMSrvSup( SRV_MOSMCtrlSIM ))
1730 {
1731 if (simShrdPrm.setPrm[srcId].sat_cc_mode EQ SATCC_CONTROL_BY_SIM_ACTIVE)
1732 {
1733 ret = cmhSAT_MoSmCntr( smsShrdPrm.tpdu.sc_addr,
1734 da_addr,
1735 srcId);
1736 }
1737 else
1738 {
1739 simShrdPrm.setPrm[srcId].sat_cc_mode = SATCC_CONTROL_BY_SIM_ACTIVE;
1740 }
1741
1742 }
1743
1744 if (ret NEQ AT_CMPL)
1745 {
1746 /* save primitive address for SIM_TOOLKIT response */
1747 sat_mnsms_submit_req = mnsms_submit_req;
1748 return;
1749 }
1750 #endif
1751 /* code SMS-SUBMIT here */
1752 cmhSMS_codeMsg (&mnsms_submit_req->sms_sdu, SMS_VT_SUBMIT,
1753 &smsShrdPrm.tpdu.sc_addr, SMS_SUBMIT,
1754 (UBYTE*)smsShrdPrm.tpdu.tp_submit);
1755
1756 PSENDX (SMS, mnsms_submit_req);
1757 #ifdef _CONC_TESTING_
1758 #ifndef NTRACE
1759 writeP = trcBuf;
1760 for (count=0; count<20; count++)
1761 {
1762 writeP += sprintf (writeP, " %02X", mnsms_submit_req->sms_sdu.buf[count]);
1763 }
1764 TRACE_EVENT("buf: ");
1765 *writeP = '\0';
1766 TRACE_EVENT(trcBuf);
1767
1768 writeP = trcBuf;
1769 for (; count<40; count++)
1770 {
1771 writeP += sprintf (writeP, " %02X", mnsms_submit_req->sms_sdu.buf[count]);
1772 }
1773 *writeP = '\0';
1774 TRACE_EVENT(trcBuf);
1775 #endif
1776 #endif
1777 if (smsShrdPrm.tpdu.tp_submit NEQ NULL)
1778 {
1779 ACI_MFREE(smsShrdPrm.tpdu.tp_submit);
1780 smsShrdPrm.tpdu.tp_submit = NULL;
1781 }
1782 }
1783 }
1784
1785 /*
1786 +-------------------------------------------------------------------+
1787 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSR |
1788 | STATE : code ROUTINE : cmhSMS_SMRead |
1789 +-------------------------------------------------------------------+
1790
1791 PURPOSE : This function is used to notify the command handler of
1792 a successfull reading of a short message from preferred
1793 message storage.
1794 */
1795 #ifndef NTRACE
1796 LOCAL void trace_read_sms( T_MNSMS_READ_CNF * mnsms_read_cnf)
1797 {
1798 char trcBuf[80];
1799 char *writeP;
1800 int count;
1801
1802 TRACE_FUNCTION ("trace_read_sms ()");
1803
1804 TRACE_EVENT_P1(" rec_num: %u", mnsms_read_cnf->rec_num);
1805 TRACE_EVENT_P1(" rec_next: %u", mnsms_read_cnf->rec_next);
1806 TRACE_EVENT_P1(" rec_max: %u", mnsms_read_cnf->rec_max);
1807 TRACE_EVENT_P1(" status %u", mnsms_read_cnf->status);
1808 TRACE_EVENT_P1(" cause 0x%04x", mnsms_read_cnf->cause);
1809 writeP = trcBuf;
1810 for (count=0; count<20; count++)
1811 {
1812 writeP += sprintf (writeP, " %02X", mnsms_read_cnf->sms_sdu.buf[count]);
1813 }
1814 TRACE_EVENT("buf: ");
1815 *writeP = '\0';
1816 TRACE_EVENT(trcBuf);
1817
1818 writeP = trcBuf;
1819 for (; count<40; count++)
1820 {
1821 writeP += sprintf (writeP, " %02X", mnsms_read_cnf->sms_sdu.buf[count]);
1822 }
1823 *writeP = '\0';
1824 TRACE_EVENT(trcBuf);
1825 }
1826 #endif
1827
1828
1829
1830 GLOBAL SHORT cmhSMS_SMRead ( T_MNSMS_READ_CNF * mnsms_read_cnf)
1831 {
1832 T_ACI_AT_CMD cmdBuf; /* buffers current command */
1833 T_ACI_CMD_SRC ownBuf; /* buffers current owner */
1834 T_ACI_CMGL_SM *p_sm;
1835 T_rp_addr rp_addr;
1836 UBYTE* message;
1837 T_TP_DELIVER *sms_deliver, decoded_mesg;
1838 BOOL retCode = FALSE;
1839 UBYTE msg_type;
1840
1841 TRACE_FUNCTION ("cmhSMS_SMRead ()");
1842
1843 #ifndef NTRACE
1844 trace_read_sms(mnsms_read_cnf);
1845 #endif
1846
1847 cmdBuf = smsShrdPrm.smsEntStat.curCmd;
1848 ownBuf = smsShrdPrm.smsEntStat.entOwn;
1849
1850 /* (SIM) error occurred */
1851 if (!IS_CAUSE_INVALID(mnsms_read_cnf->cause))
1852 {
1853 if (mnsms_read_cnf->cause NEQ SMS_NO_ERROR)
1854 {
1855 /* reset the command context */
1856 smsShrdPrm.smsEntStat.curCmd = AT_CMD_NONE;
1857 smsShrdPrm.smsEntStat.entOwn = smsShrdPrm.owner = OWN_NONE;
1858
1859 if( ownBuf NEQ CMD_SRC_LCL OR cmdBuf NEQ AT_CMD_P_CMGMDU )
1860 {
1861 R_AT ( RAT_CMS, ownBuf )
1862 (
1863 cmdBuf,
1864 cmhSMS_GetCmsFromSms(mnsms_read_cnf->cause),
1865 NULL
1866 );
1867 }
1868 return 1;
1869 }
1870 }
1871
1872 #ifdef _CONC_TESTING_
1873 /* this is only for testing */
1874 SET_OWNBUF_CONC;
1875 #endif
1876
1877 /*
1878 *-----------------------------------------------------------------
1879 * ignore primitives with incorrect message status
1880 *-----------------------------------------------------------------
1881 */
1882 TRACE_EVENT_P1("mnsms_read_cnf->status: %d", mnsms_read_cnf->status);
1883
1884 if ( (mnsms_read_cnf->status EQ SMS_RECORD_FREE) OR
1885 (mnsms_read_cnf->status EQ SMS_RECORD_INVALID) )
1886 {
1887 /* reset the command context */
1888 smsShrdPrm.smsEntStat.curCmd = AT_CMD_NONE;
1889 smsShrdPrm.smsEntStat.entOwn = smsShrdPrm.owner = OWN_NONE;
1890
1891 TRACE_EVENT("incorrect message status");
1892 return 1;
1893 }
1894
1895 /* always decode for local source */
1896 if (ownBuf EQ CMD_SRC_LCL) /* ACI-SPR-9528 */
1897 { /* pass dummy p_sm to CB */
1898 if (((cmdBuf EQ AT_CMD_CMGL OR cmdBuf EQ AT_CMD_CMGR) OR
1899 (cmdBuf EQ AT_CMD_P_CMGR OR cmdBuf EQ AT_CMD_P_CMGL))
1900 AND smsShrdPrm.rdMode NEQ READ_STATUS_CHANGE) /* ACI-FIX-9510 */
1901 {
1902 retCode = cmhSMS_SMSQueryType (&mnsms_read_cnf->sms_sdu, &msg_type);
1903 if (retCode EQ FALSE)
1904 {
1905 /* reset the command context */
1906 smsShrdPrm.smsEntStat.curCmd = AT_CMD_NONE;
1907 smsShrdPrm.smsEntStat.entOwn = smsShrdPrm.owner = OWN_NONE;
1908
1909 TRACE_EVENT("Error decoding message type");
1910 return 1;
1911 }
1912 ACI_MALLOC(smsShrdPrm.pDecMsg, sizeof(T_ACI_CMGL_SM) );
1913 memset(smsShrdPrm.pDecMsg,0,sizeof(T_ACI_CMGL_SM) );
1914 p_sm = smsShrdPrm.pDecMsg;
1915 if (msg_type EQ TP_MTI_SMS_STATUS_REP)
1916 {
1917 retCode=cmhSMS_cpySTtoSM(p_sm ,mnsms_read_cnf);
1918 }
1919 else
1920 {
1921 retCode = cmhSMS_cpyReadCnf ( p_sm, mnsms_read_cnf );
1922 }
1923 if (retCode EQ FALSE)
1924 {
1925 TRACE_EVENT("cmhSMS_SMRead ():[ERR] decoding of SMS");
1926 cmhSMS_invalidSMS_notification_to_user (mnsms_read_cnf);
1927
1928 ACI_MFREE(smsShrdPrm.pDecMsg);
1929
1930 /* reset the command context */
1931 smsShrdPrm.smsEntStat.curCmd = AT_CMD_NONE;
1932 smsShrdPrm.smsEntStat.entOwn = smsShrdPrm.owner = OWN_NONE;
1933
1934 smsShrdPrm.pDecMsg = NULL;
1935 if (mnsms_read_cnf->rec_next EQ SMS_RECORD_NOT_EXIST)
1936 {
1937 smsShrdPrm.smsEntStat.curCmd = AT_CMD_NONE;
1938 smsShrdPrm.smsEntStat.entOwn = smsShrdPrm.owner = OWN_NONE;
1939 if( cmdBuf NEQ AT_CMD_P_CMGMDU )
1940 {
1941 R_AT ( RAT_OK, ownBuf ) ( cmdBuf );
1942 }
1943 }
1944 return 1;
1945 }
1946 }
1947 }
1948 else
1949 p_sm = smsShrdPrm.pDecMsg;
1950
1951 /*
1952 *-----------------------------------------------------------------
1953 * check for command context
1954 *-----------------------------------------------------------------
1955 */
1956 switch( smsShrdPrm.smsEntStat.curCmd )
1957 {
1958 case ( AT_CMD_CMGR ):
1959 case ( AT_CMD_P_CMGR ):
1960 {
1961 /*
1962 *-------------------------------------------------------------
1963 * process event for +CGMR
1964 *-------------------------------------------------------------
1965 */
1966
1967 /* reset the command context */
1968 smsShrdPrm.smsEntStat.curCmd = AT_CMD_NONE;
1969 smsShrdPrm.smsEntStat.entOwn = smsShrdPrm.owner = OWN_NONE;
1970
1971 /* The message need not be displayed for Status Change */
1972 if (cmdBuf EQ AT_CMD_P_CMGR
1973 AND smsShrdPrm.rdMode EQ READ_STATUS_CHANGE)
1974 {
1975 R_AT ( RAT_OK, ownBuf ) ( cmdBuf );
1976 /* inform BMI */
1977 cmh_logRslt ( ownBuf, RAT_OK, AT_CMD_P_CMGR, mnsms_read_cnf->rec_num, -1, -1 );
1978 break;
1979 }
1980
1981
1982 #if defined MFW OR defined FF_MMI_RIV OR defined _CONC_TESTING_
1983 if (ownBuf EQ CMD_SRC_LCL) /* AND /* ACI-FIX-9510 */
1984 /* smsShrdPrm.rdMode NEQ READ_STATUS_CHANGE) */ /* call rplyCB (with invalid p_sm) anyway
1985 to touch all segments while in
1986 READ_STATUS_CHANGE */
1987 {
1988 #if defined FF_MMI_RIV
1989 T_ACI_CMGF_MOD sms_input_mode = CMGF_MOD_NotPresent;
1990 qAT_PlusCMGF (CMD_SRC_LCL, &sms_input_mode);
1991 if (sms_input_mode EQ CMGF_MOD_Pdu )
1992 {
1993 if (cmdBuf EQ AT_CMD_CMGR )
1994 {
1995 rAT_PlusCMGRPdu (mnsms_read_cnf);
1996 }
1997 else if (cmdBuf EQ AT_CMD_P_CMGR )
1998 {
1999 rAT_PercentCMGRPdu (mnsms_read_cnf);
2000 }
2001 }
2002 else
2003 {
2004 if (smsShrdPrm.rplyCB.cmgr NEQ NULL)
2005 {
2006 smsShrdPrm.rplyCB.cmgr( p_sm, NULL );
2007 }
2008 }
2009 R_AT ( RAT_OK, ownBuf ) ( cmdBuf );
2010 #else
2011 /* GPF-MMI */
2012 if (smsShrdPrm.rplyCB.cmgr NEQ NULL)
2013 {
2014 smsShrdPrm.rplyCB.cmgr( p_sm, NULL );
2015 }
2016 if (!ISSET_CONC)
2017 {
2018 R_AT ( RAT_OK, ownBuf ) ( cmdBuf );
2019 }
2020 #endif
2021 }
2022 else /* if (ownBuf EQ CMD_SRC_LCL) */
2023 #endif /*#if defined MFW OR defined FF_MMI_RIV*/
2024 {
2025 if (cmdBuf EQ AT_CMD_CMGR )
2026 {
2027 R_AT ( RAT_CMGR, ownBuf ) ( mnsms_read_cnf, NULL );
2028 }
2029 else if (cmdBuf EQ AT_CMD_P_CMGR )
2030 {
2031 R_AT ( RAT_P_CMGR, ownBuf ) ( mnsms_read_cnf, NULL );
2032 }
2033
2034 R_AT ( RAT_OK, ownBuf ) ( cmdBuf );
2035 /* inform BMI */
2036 cmh_logRslt ( ownBuf, RAT_OK, AT_CMD_CMGR, mnsms_read_cnf->rec_num, -1, -1 );
2037 }
2038
2039 break;
2040 }
2041
2042 case ( AT_CMD_P_CMGL ):
2043 case ( AT_CMD_CMGL ):
2044 {
2045 /*
2046 *-------------------------------------------------------------
2047 * process event for +CMGL
2048 *-------------------------------------------------------------
2049 */
2050 cmhSMS_cpyLstData ( cmdBuf, ownBuf, mnsms_read_cnf );
2051
2052 break;
2053 }
2054
2055 case ( AT_CMD_P_CMGMDU ):
2056 {
2057 /*
2058 *-------------------------------------------------------------
2059 * process event for %CMGMDU
2060 *-------------------------------------------------------------
2061 */
2062 message = cmhSMS_decodeMsg(&mnsms_read_cnf->sms_sdu, &rp_addr, SMS_VT_DELIVER);
2063 sms_deliver = (T_TP_DELIVER*)message;
2064 sms_deliver->tp_rp = 0;
2065 memcpy(&decoded_mesg, sms_deliver, sizeof(T_TP_DELIVER));
2066
2067 {
2068 PALLOC (mnsms_store_req, MNSMS_STORE_REQ);
2069
2070 mnsms_store_req -> mem_type = smsShrdPrm.mem1;
2071 mnsms_store_req -> condx = SMS_CONDX_OVR_ANY;
2072 mnsms_store_req -> rec_num = mnsms_read_cnf->rec_num;
2073 mnsms_store_req -> status = mnsms_read_cnf->status;
2074
2075 cmhSMS_codeMsg ( &mnsms_store_req->sms_sdu,
2076 SMS_VT_DELIVER,
2077 &rp_addr,
2078 SMS_DELIVER,
2079 (UBYTE*) &decoded_mesg);
2080
2081 PSENDX (SMS, mnsms_store_req);
2082 }
2083 break;
2084 }
2085 #if defined (SIM_TOOLKIT)
2086 case ( AT_CMD_CMSS ):
2087 {
2088 /*
2089 *-------------------------------------------------------------
2090 * process event for +CMSS (only for SAT)
2091 *-------------------------------------------------------------
2092 */
2093 cmhSMS_SMReadCMSS (mnsms_read_cnf);
2094
2095 break;
2096 }
2097 #endif
2098
2099 default:
2100 {
2101 TRACE_EVENT("error in command context");
2102 }
2103 }
2104
2105 if (smsShrdPrm.pDecMsg)
2106 {
2107 ACI_MFREE(smsShrdPrm.pDecMsg);
2108 smsShrdPrm.pDecMsg = NULL;
2109 }
2110
2111 return 0;
2112 }
2113
2114 /*
2115 +-------------------------------------------------------------------+
2116 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSR |
2117 | STATE : code ROUTINE : cmhSMS_Result |
2118 +-------------------------------------------------------------------+
2119
2120 PURPOSE : This function is used to notify the command handler of
2121 a successfull transaction concerning the short message
2122 service.
2123 */
2124 GLOBAL SHORT cmhSMS_Result ( T_MNSMS_REPORT_IND * mnsms_report_ind )
2125 {
2126 T_ACI_AT_CMD cmdBuf; /* buffers current command */
2127 T_ACI_CMD_SRC ownBuf; /* buffers current owner */
2128
2129
2130 TRACE_FUNCTION ("cmhSMS_Result ()");
2131
2132 if (mnsms_report_ind->v_cmms_mode)
2133 {
2134 smsShrdPrm.CMMSmode = mnsms_report_ind->cmms_mode;
2135 return 0;
2136 }
2137
2138 cmdBuf = AT_CMD_NONE;
2139 ownBuf = CMD_SRC_LCL;
2140
2141 smsShrdPrm.smsStat = mnsms_report_ind->state;
2142
2143
2144 if (mnsms_report_ind->state EQ SMS_STATE_READY)
2145 {
2146 /* reading of SMs from SIM is completed,
2147 * read SMSP, CBMIR, CMBI fields now
2148 */
2149 if (cmhSMS_ReadParams (NO_VLD_OWN, AT_CMD_CFUN, 1) NEQ AT_EXCT)
2150 {
2151 cmhSMS_ready ();
2152 }
2153 R_AT ( RAT_SIG_SMS, ownBuf ) ( SMS_STATE_READY );
2154 }
2155 else if (mnsms_report_ind->state EQ SMS_STATE_INITIALISING)
2156 {
2157 { /*ACI-FIX-18055 resetting total and used storage counters of SIM and ME storages which will be updated by cmhSMS_SMSInitState */
2158 smsShrdPrm.aci_sms_parameter.simTotal = 0;
2159 smsShrdPrm.aci_sms_parameter.simUsed = 0;
2160 smsShrdPrm.aci_sms_parameter.meTotal = 0;
2161 smsShrdPrm.aci_sms_parameter.meUsed = 0;
2162 } /*ACI-FIX-18055 Changes end here */
2163 R_AT ( RAT_SIG_SMS, ownBuf ) ( SMS_STATE_INITIALISING );
2164 }
2165 else if (mnsms_report_ind->state > SMS_STATE_INITIALISING)
2166 {
2167 R_AT ( RAT_CMS, ownBuf ) ( cmdBuf, CMS_ERR_UnknownErr, NULL );
2168 }
2169
2170 return 0;
2171 }
2172
2173 /*
2174 +-------------------------------------------------------------------+
2175 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSR |
2176 | STATE : code ROUTINE : cmhSMS_WrCnfCSAS |
2177 +-------------------------------------------------------------------+
2178
2179 PURPOSE : This function is used to notify the command handler of
2180 the usage of SIM and ME memory.
2181 */
2182 GLOBAL void cmhSMS_WrCnfCSAS (SHORT aId)
2183 {
2184 T_ACI_AT_CMD cmdBuf; /* buffers current command */
2185 T_ACI_CMD_SRC ownBuf; /* buffers current owner */
2186 USHORT errCode;
2187 USHORT dataField = 0xFF;
2188 UBYTE dataLen = 0;
2189 UBYTE data[MAX_SIM_CMD];
2190
2191 TRACE_FUNCTION ("cmhSMS_WrCnfCSAS ()");
2192
2193 cmdBuf = smsShrdPrm.smsEntStat.curCmd;
2194 ownBuf = smsShrdPrm.smsEntStat.entOwn;
2195
2196 /*
2197 *-----------------------------------------------------------------
2198 * check for next SIM access
2199 *-----------------------------------------------------------------
2200 */
2201 switch (smsShrdPrm.prmRdSeq)
2202 {
2203 case SMS_READ_SIM_SMSP: /* EF(SMSP) written */
2204 errCode = simShrdPrm.atb[aId].errCode;
2205
2206 if (smsShrdPrm.cbmPrm.cbmSIMmaxIdRge > 0 AND
2207 cmhSMS_PutCbmirSIM (ownBuf, data,
2208 (int)smsShrdPrm.cbmPrm.cbmSIMmaxIdRge * 4)) /* write CBMIR */
2209 {
2210 dataField = SIM_CBMIR;
2211 dataLen = smsShrdPrm.cbmPrm.cbmSIMmaxIdRge * 4;
2212 break;
2213 }
2214 else
2215 smsShrdPrm.prmRdSeq--;
2216
2217 if (smsShrdPrm.cbmPrm.cbmSIMmaxId > 0 AND
2218 cmhSMS_PutCbmiSIM (ownBuf, data,
2219 (int)smsShrdPrm.cbmPrm.cbmSIMmaxId * 2)) /* write CBMI */
2220 {
2221 dataField = SIM_CBMI;
2222 dataLen = smsShrdPrm.cbmPrm.cbmSIMmaxId * 2;
2223 }
2224 else /* nothing else to write */
2225 {
2226 smsShrdPrm.prmRdSeq = SMS_READ_SIM_CMPL;
2227 }
2228 break;
2229
2230 case SMS_READ_SIM_CBMIR: /* CBMIR written */
2231 errCode = simShrdPrm.atb[aId].errCode;
2232
2233 if (smsShrdPrm.cbmPrm.cbmSIMmaxId > 0 AND /* write CBMI */
2234 cmhSMS_PutCbmiSIM (ownBuf, data,
2235 (int)smsShrdPrm.cbmPrm.cbmSIMmaxId * 2))
2236 {
2237 dataField = SIM_CBMI;
2238 dataLen = smsShrdPrm.cbmPrm.cbmSIMmaxId * 2;
2239 }
2240 else /* nothing else to write */
2241 smsShrdPrm.prmRdSeq = SMS_READ_SIM_CMPL;
2242 break;
2243
2244 case SMS_READ_SIM_CBMI: /* CBMI written */
2245 errCode = simShrdPrm.atb[aId].errCode;
2246
2247 smsShrdPrm.prmRdSeq = SMS_READ_SIM_CMPL; /* nothing else to write */
2248 break;
2249
2250 default: /* nothing else to write */
2251 smsShrdPrm.prmRdSeq = SMS_READ_SIM_CMPL;
2252 errCode = SIM_CAUSE_OTHER_ERROR;
2253 break;
2254 }
2255 if ( smsShrdPrm.prmRdSeq EQ SMS_READ_SIM_CMPL)
2256 {
2257 smsShrdPrm.smsEntStat.curCmd = AT_CMD_NONE;
2258 smsShrdPrm.smsEntStat.entOwn = smsShrdPrm.owner = OWN_NONE;
2259
2260 if (errCode EQ SIM_NO_ERROR)
2261 {
2262 R_AT( RAT_OK, ownBuf ) ( cmdBuf );
2263 }
2264 else
2265 {
2266 R_AT( RAT_CMS, ownBuf ) /* unsuccessful SIM write */
2267 (
2268 cmdBuf,
2269 cmhSMS_GetCmsFromSim ( errCode ),
2270 NULL
2271 );
2272 }
2273 }
2274 else
2275 {
2276 if (cmhSIM_WriteTranspEF (CMD_SRC_NONE, cmdBuf,
2277 dataField, 0, dataLen,
2278 data, cmhSMS_WrCnfCSAS) EQ AT_FAIL)
2279 {
2280 smsShrdPrm.smsEntStat.curCmd = AT_CMD_NONE;
2281 smsShrdPrm.smsEntStat.entOwn = smsShrdPrm.owner = OWN_NONE;
2282
2283 smsShrdPrm.prmRdSeq = SMS_READ_SIM_CMPL;
2284
2285 R_AT( RAT_CMS, ownBuf ) ( cmdBuf, CMS_ERR_UnknownErr, NULL );
2286 }
2287 else
2288 smsShrdPrm.prmRdSeq--;
2289 }
2290
2291 simShrdPrm.atb[aId].ntryUsdFlg = FALSE;
2292 }
2293
2294 /*
2295 +-------------------------------------------------------------------+
2296 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSR |
2297 | STATE : code ROUTINE : cmhSMS_RdCnfCRES |
2298 +-------------------------------------------------------------------+
2299
2300 PURPOSE : This function is used to notify the command handler of
2301 the usage of SIM and ME memory.
2302 */
2303 GLOBAL void cmhSMS_RdCnfCRES (SHORT aId)
2304 {
2305 T_ACI_AT_CMD cmdBuf; /* buffers current command */
2306 T_ACI_CMD_SRC ownBuf; /* buffers current owner */
2307
2308 USHORT errCode;
2309 USHORT dataField = 0xFF;
2310 UBYTE dataLen = 0;
2311 UBYTE profile;
2312
2313 TRACE_FUNCTION ("cmhSMS_RdCnfCRES ()");
2314
2315 cmdBuf = smsShrdPrm.smsEntStat.curCmd;
2316 ownBuf = smsShrdPrm.smsEntStat.entOwn;
2317
2318 /*
2319 *-----------------------------------------------------------------
2320 * check for next SIM access
2321 *-----------------------------------------------------------------
2322 */
2323 switch (smsShrdPrm.prmRdSeq)
2324 {
2325 case SMS_READ_SIM_SMSP:
2326 if ((errCode = simShrdPrm.atb[aId].errCode) EQ SIM_NO_ERROR)
2327 {
2328 /* successful EF(SMSP) read */
2329
2330 profile = simShrdPrm.atb[aId].recNr;
2331
2332 if (!cmhSMS_GetPrmSIM (ownBuf,
2333 simShrdPrm.atb[aId].exchData,
2334 simShrdPrm.atb[aId].dataLen))
2335 {
2336 errCode = SIM_CAUSE_OTHER_ERROR;
2337 }
2338 }
2339 if (smsShrdPrm.cbmPrm.cbmSIMmaxIdRge > 0)
2340 {
2341 dataField = SIM_CBMIR;
2342 dataLen = smsShrdPrm.cbmPrm.cbmSIMmaxIdRge * 4;
2343 break;
2344 }
2345 else
2346 smsShrdPrm.prmRdSeq--;
2347
2348 if (smsShrdPrm.cbmPrm.cbmSIMmaxId > 0)
2349 {
2350 dataField = SIM_CBMI;
2351 dataLen = smsShrdPrm.cbmPrm.cbmSIMmaxId * 2;
2352 break;
2353 }
2354 else
2355 smsShrdPrm.prmRdSeq--;
2356
2357 smsShrdPrm.cbmPrm.cbchOwner = ownBuf;
2358 psaMMI_Cbch();
2359 smsShrdPrm.cbmPrm.cbchOwner = OWN_NONE;
2360
2361 #ifdef SIM_TOOLKIT
2362 smsShrdPrm.prmRdSeq--; /* when SAT is on, then SMS_READ_CBMID is defined
2363 which is irrelevant for +CRES */
2364 #endif /* of SIM_TOOLKIT */
2365
2366 break;
2367
2368 case SMS_READ_SIM_CBMIR:
2369 if ((errCode = simShrdPrm.atb[aId].errCode) EQ SIM_NO_ERROR)
2370 { /* successful EF(CBMIR) read */
2371 if (!cmhSMS_GetCbmirSIM (ownBuf,
2372 simShrdPrm.atb[aId].exchData,
2373 simShrdPrm.atb[aId].dataLen))
2374 {
2375 errCode = SIM_CAUSE_OTHER_ERROR;
2376 }
2377 }
2378 if (smsShrdPrm.cbmPrm.cbmSIMmaxId > 0)
2379 {
2380 dataField = SIM_CBMI;
2381 dataLen = smsShrdPrm.cbmPrm.cbmSIMmaxId * 2;
2382 }
2383 else
2384 {
2385 smsShrdPrm.prmRdSeq--;
2386
2387 smsShrdPrm.cbmPrm.cbchOwner = ownBuf;
2388 psaMMI_Cbch();
2389 smsShrdPrm.cbmPrm.cbchOwner = OWN_NONE;
2390
2391 #ifdef SIM_TOOLKIT
2392 smsShrdPrm.prmRdSeq--; /* when SAT is on, then SMS_READ_CBMID is defined
2393 which is irrelevant for +CRES */
2394 #endif /* of SIM_TOOLKIT */
2395
2396 }
2397 break;
2398
2399 case SMS_READ_SIM_CBMI:
2400 if ((errCode = simShrdPrm.atb[aId].errCode) EQ SIM_NO_ERROR)
2401 { /* successful EF(CBMI) read */
2402 if (!cmhSMS_GetCbmiSIM (ownBuf,
2403 simShrdPrm.atb[aId].exchData,
2404 simShrdPrm.atb[aId].dataLen))
2405 {
2406 errCode = SIM_CAUSE_OTHER_ERROR;
2407 }
2408 }
2409 smsShrdPrm.cbmPrm.cbchOwner = ownBuf;
2410 psaMMI_Cbch();
2411 smsShrdPrm.cbmPrm.cbchOwner = OWN_NONE;
2412
2413 #ifdef SIM_TOOLKIT
2414 smsShrdPrm.prmRdSeq--; /* when SAT is on, then SMS_READ_CBMID is defined
2415 which is irrelevant for +CRES */
2416 #endif /* of SIM_TOOLKIT */
2417
2418 break;
2419
2420 default:
2421 smsShrdPrm.prmRdSeq = SMS_READ_SIM_CMPL;
2422 errCode = SIM_CAUSE_OTHER_ERROR;
2423 break;
2424 }
2425 if (--smsShrdPrm.prmRdSeq <= SMS_READ_SIM_CMPL)
2426 {
2427 smsShrdPrm.smsEntStat.curCmd = AT_CMD_NONE;
2428 smsShrdPrm.smsEntStat.entOwn = smsShrdPrm.owner = OWN_NONE;
2429
2430 if (errCode EQ SIM_NO_ERROR)
2431 {
2432 R_AT( RAT_OK, ownBuf ) ( cmdBuf );
2433 }
2434 else
2435 {
2436 R_AT( RAT_CMS, ownBuf ) /* unsuccessful SIM read */
2437 (
2438 cmdBuf,
2439 cmhSMS_GetCmsFromSim ( errCode ),
2440 NULL
2441 );
2442 }
2443 }
2444 else
2445 if (cmhSIM_ReadTranspEF (CMD_SRC_NONE, cmdBuf,
2446 dataField, 0, dataLen,
2447 NULL, cmhSMS_RdCnfCRES) EQ AT_FAIL)
2448 {
2449 smsShrdPrm.smsEntStat.curCmd = AT_CMD_NONE;
2450 smsShrdPrm.smsEntStat.entOwn = smsShrdPrm.owner = OWN_NONE;
2451
2452 smsShrdPrm.prmRdSeq = SMS_READ_SIM_CMPL;
2453
2454 #ifdef SIM_TOOLKIT
2455 if (ownBuf EQ OWN_SAT /*smsShrdPrm.fuRef >= 0*/)
2456 {
2457 psaSAT_FUConfirm ((int)simShrdPrm.fuRef, SIM_FU_ERROR);
2458 }
2459 else
2460 {
2461 #endif
2462 R_AT( RAT_CMS, ownBuf ) ( cmdBuf, CMS_ERR_UnknownErr, NULL );
2463 #ifdef SIM_TOOLKIT
2464 }
2465 #endif
2466 }
2467
2468 simShrdPrm.atb[aId].ntryUsdFlg = FALSE;
2469 }
2470
2471 /*
2472 +-------------------------------------------------------------------+
2473 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSR |
2474 | STATE : code ROUTINE : cmhSMS_InitSMSP |
2475 +-------------------------------------------------------------------+
2476
2477 PURPOSE : This function is used to store the parameters of EF(SMSP).
2478 */
2479 GLOBAL void cmhSMS_InitSMSP (SHORT aId)
2480 {
2481 T_ACI_CMD_SRC srcId;
2482 T_SMS_SET_PRM * elem ; /* points to SMS parameter set */
2483 UBYTE idx;
2484 UBYTE profile;
2485
2486 TRACE_FUNCTION ("cmhSMS_InitSMSP ()");
2487
2488 /*
2489 *-----------------------------------------------------------------
2490 * process SIM result
2491 *-----------------------------------------------------------------
2492 */
2493 srcId = smsShrdPrm.owner;
2494
2495 switch (smsShrdPrm.prmRdSeq)
2496 {
2497 case SMS_READ_SIM_SMSP:
2498 if (simShrdPrm.atb[aId].errCode EQ SIM_NO_ERROR)
2499 { /* successful EF(SMSP) read */
2500 smsShrdPrm.aci_sms_parameter.smsParamMaxRec = simShrdPrm.atb[aId].recMax;
2501 smsShrdPrm.aci_sms_parameter.smsParamRecLen = simShrdPrm.atb[aId].dataLen;
2502
2503 if (set_prm_list EQ NULL)
2504 {
2505 set_prm_list = new_list();
2506 }
2507 profile = simShrdPrm.atb[aId].recNr;
2508 elem = find_element(set_prm_list, profile, cmhSMS_findPrflId);
2509
2510 if (elem EQ NULL)
2511 {
2512 ACI_MALLOC(elem, sizeof(T_SMS_SET_PRM));
2513 memset(elem, 0, sizeof(T_SMS_SET_PRM));
2514 insert_list(set_prm_list, elem);
2515 elem->prflId = profile;
2516 elem->numOfRefs = OWN_MAX;
2517 for( idx = 0; idx < OWN_MAX; idx++ )
2518 {
2519 smsShrdPrm.pSetPrm[idx] = (T_SMS_SET_PRM*) elem;
2520 }
2521
2522 }
2523 else
2524 {
2525 smsShrdPrm.pSetPrm[0] = (T_SMS_SET_PRM*) elem;
2526 }
2527
2528 cmhSMS_GetPrmSIM (0,
2529 simShrdPrm.atb[aId].exchData,
2530 simShrdPrm.atb[aId].dataLen);
2531 }
2532 else
2533 {
2534 smsShrdPrm.aci_sms_parameter.smsParamMaxRec = 0;
2535 smsShrdPrm.aci_sms_parameter.smsParamRecLen = 0;
2536 }
2537 if( !psaSIM_ChkSIMSrvSup( SRV_CBMIdRnge ))
2538 {
2539 smsShrdPrm.prmRdSeq--;
2540 goto CBMIR;
2541 }
2542 if (cmhSIM_ReadTranspEF (CMD_SRC_NONE, smsShrdPrm.smsEntStat.curCmd,
2543 SIM_CBMIR, 0, 255,
2544 NULL, cmhSMS_InitSMSP) NEQ AT_FAIL)
2545 smsShrdPrm.prmRdSeq--;
2546 else
2547 {
2548 goto CBMIR;
2549 }
2550 break;
2551
2552 case SMS_READ_SIM_CBMIR:
2553 if (simShrdPrm.atb[aId].errCode EQ SIM_NO_ERROR)
2554 {
2555 smsShrdPrm.cbmPrm.cbmSIMmaxIdRge = simShrdPrm.atb[aId].dataLen / 4;
2556 cmhSMS_GetCbmirSIM (CMD_SRC_NONE,
2557 simShrdPrm.atb[aId].exchData,
2558 simShrdPrm.atb[aId].dataLen);
2559 }
2560 else
2561 smsShrdPrm.cbmPrm.cbmSIMmaxIdRge = 0;
2562
2563 CBMIR:
2564 if( !psaSIM_ChkSIMSrvSup( SRV_CBM_Ident ))
2565 {
2566 smsShrdPrm.prmRdSeq--;
2567 goto CBMI;
2568 }
2569 if (cmhSIM_ReadTranspEF (CMD_SRC_NONE, smsShrdPrm.smsEntStat.curCmd,
2570 SIM_CBMI, 0, 255,
2571 NULL, cmhSMS_InitSMSP) NEQ AT_FAIL)
2572 smsShrdPrm.prmRdSeq--;
2573 else
2574 {
2575 #ifdef SIM_TOOLKIT
2576 goto CBMI;
2577 #else
2578 smsShrdPrm.prmRdSeq = SMS_READ_SIM_CMPL;
2579
2580 smsShrdPrm.smsEntStat.curCmd = AT_CMD_NONE;
2581 smsShrdPrm.smsEntStat.entOwn = simShrdPrm.owner = OWN_NONE;
2582 #endif /* of SIM_TOOLKIT */
2583 }
2584 break;
2585
2586 case SMS_READ_SIM_CBMI:
2587 if (simShrdPrm.atb[aId].errCode EQ SIM_NO_ERROR)
2588 {
2589 smsShrdPrm.cbmPrm.cbmSIMmaxId = simShrdPrm.atb[aId].dataLen / 2;
2590 cmhSMS_GetCbmiSIM (CMD_SRC_NONE,
2591 simShrdPrm.atb[aId].exchData,
2592 simShrdPrm.atb[aId].dataLen);
2593 }
2594 else
2595 smsShrdPrm.cbmPrm.cbmSIMmaxId = 0;
2596
2597 #ifdef SIM_TOOLKIT
2598 CBMI:
2599 if( (!psaSIM_ChkSIMSrvSup( SRV_DtaDownlCB )) OR
2600 smsShrdPrm.owner NEQ OWN_SAT)
2601 {
2602 smsShrdPrm.prmRdSeq--;
2603 goto CBMID;
2604 }
2605 if (cmhSIM_ReadTranspEF (CMD_SRC_NONE, smsShrdPrm.smsEntStat.curCmd,
2606 SIM_CBMID, 0, 255,
2607 NULL, cmhSMS_InitSMSP) NEQ AT_FAIL)
2608 smsShrdPrm.prmRdSeq--;
2609 else
2610 {
2611 smsShrdPrm.prmRdSeq = SMS_READ_SIM_CMPL;
2612
2613 smsShrdPrm.smsEntStat.curCmd = AT_CMD_NONE;
2614 smsShrdPrm.smsEntStat.entOwn = simShrdPrm.owner = OWN_NONE;
2615 }
2616 break;
2617
2618 case SMS_READ_SIM_CBMID:
2619 if (simShrdPrm.atb[aId].errCode EQ SIM_NO_ERROR)
2620 {
2621 smsShrdPrm.cbmPrm.cbmSIMmaxSATId = simShrdPrm.atb[aId].dataLen / 2;
2622 cmhSMS_GetCbDtaDwnlSIM (CMD_SRC_NONE,
2623 simShrdPrm.atb[aId].exchData,
2624 simShrdPrm.atb[aId].dataLen);
2625 {
2626 PALLOC (sat_cbch_req, MMI_SAT_CBCH_DWNLD_REQ);
2627
2628 sat_cbch_req->count = (USHORT)smsShrdPrm.cbmPrm.CBDtaDwnlFoundIds;
2629 memset (sat_cbch_req->msg_id, NOT_PRESENT_16BIT,
2630 sizeof (sat_cbch_req->msg_id));
2631 memcpy (sat_cbch_req->msg_id, smsShrdPrm.cbmPrm.CBDtaDwnlIdent,
2632 (size_t)smsShrdPrm.cbmPrm.CBDtaDwnlFoundIds * 2);
2633
2634 PSENDX (PL, sat_cbch_req);
2635 }
2636 }
2637 else
2638 smsShrdPrm.cbmPrm.cbmSIMmaxSATId = 0;
2639
2640 default:
2641 CBMID:
2642
2643 #else
2644 /*lint -fallthrough*/
2645 default:
2646 CBMI:
2647 #endif /*SIM_TOOLKIT */
2648
2649 smsShrdPrm.cbmPrm.cbchOwner = srcId;
2650 psaMMI_Cbch();
2651 smsShrdPrm.cbmPrm.cbchOwner = OWN_NONE;
2652 {
2653 smsShrdPrm.prmRdSeq = SMS_READ_SIM_CMPL;
2654
2655 smsShrdPrm.smsEntStat.curCmd = AT_CMD_NONE;
2656 smsShrdPrm.smsEntStat.entOwn = simShrdPrm.owner = OWN_NONE;
2657 }
2658 #ifdef SIM_TOOLKIT
2659 if (srcId EQ OWN_SAT /*smsShrdPrm.fuRef >= 0*/)
2660 {
2661 smsShrdPrm.accessEnabled = TRUE;
2662 psaSAT_FUConfirm (simShrdPrm.fuRef,(USHORT)
2663 ((simShrdPrm.atb[aId].errCode EQ SIM_NO_ERROR)?
2664 SIM_FU_SUCC_ADD: SIM_FU_ERROR));
2665 }
2666 else
2667 #endif
2668 cmhSMS_ready ();
2669 break;
2670 }
2671
2672 simShrdPrm.atb[aId].ntryUsdFlg = FALSE;
2673 }
2674
2675 /*
2676 +-------------------------------------------------------------------+
2677 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSR |
2678 | STATE : code ROUTINE : cmhSMS_SMSResumeCnf |
2679 +-------------------------------------------------------------------+
2680
2681 PURPOSE : This function processes the MNSMS_RESUME_CNF primitive.
2682
2683 */
2684 GLOBAL void cmhSMS_SMSResumeCnf (T_MNSMS_RESUME_CNF * mnsms_resume_cnf)
2685 {
2686 UBYTE cmdBuf;
2687 UBYTE ownBuf;
2688
2689 TRACE_FUNCTION("cmhSMS_ResumeCnf()");
2690
2691 cmdBuf = smsShrdPrm.smsEntStat.curCmd;
2692 ownBuf = smsShrdPrm.smsEntStat.entOwn;
2693
2694 /* check whether resume has been successfully processed */
2695 if (mnsms_resume_cnf->cause EQ SMS_NO_ERROR)
2696 {
2697 R_AT( RAT_OK, ownBuf ) ( cmdBuf );
2698 }
2699 else
2700 {
2701 /* command unsuccessful */
2702 R_AT ( RAT_CMS, ownBuf )
2703 (
2704 cmdBuf,
2705 cmhSMS_GetCmsFromSms(mnsms_resume_cnf->cause),
2706 NULL
2707 );
2708 }
2709
2710 /* reset command */
2711 smsShrdPrm.smsEntStat.curCmd = AT_CMD_NONE;
2712 smsShrdPrm.smsEntStat.entOwn = smsShrdPrm.owner = OWN_NONE;
2713 }
2714
2715 /*
2716 +-------------------------------------------------------------------+
2717 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSR |
2718 | STATE : code ROUTINE : cmhSMS_SMSQueryCnf |
2719 +-------------------------------------------------------------------+
2720
2721 PURPOSE : This function processes the MNSMS_QUERY_CNF primitive.
2722
2723 */
2724 GLOBAL void cmhSMS_SMSQueryCnf (T_MNSMS_QUERY_CNF * mnsms_query_cnf)
2725 {
2726 UBYTE cmdBuf;
2727 UBYTE ownBuf;
2728
2729 TRACE_FUNCTION("cmhSMS_SMSQueryCnf()");
2730
2731 cmdBuf = smsShrdPrm.smsEntStat.curCmd;
2732 ownBuf = smsShrdPrm.smsEntStat.entOwn;
2733
2734 /* check type of query request and process it */
2735 switch (mnsms_query_cnf->query_type)
2736 {
2737 case SMS_QUERY_DELIVER_STATUS:
2738 {
2739 if ( mnsms_query_cnf->v_deliver_status )
2740 {
2741 R_AT ( RAT_CPRSM, ownBuf )
2742 ( cmhSMS_convertDeliverStatusToACI(mnsms_query_cnf->deliver_status ) );
2743 R_AT( RAT_OK, ownBuf ) ( cmdBuf );
2744 }
2745 else /* paramter inalid - unspecified protocol error */
2746 {
2747 TRACE_EVENT("cmhSMS_QueryCnf: ERROR: paramter invalid");
2748 R_AT ( RAT_CMS, ownBuf )( cmdBuf, CMS_ERR_InValManInfo, NULL );
2749 }
2750 break;
2751 }
2752 default: /* unsupported query type - ME failure */
2753 {
2754 TRACE_EVENT("cmhSMS_QueryCnf: ERROR: unsupported query type");
2755 R_AT ( RAT_CMS, ownBuf )( cmdBuf, CMS_ERR_MeFail, NULL );
2756 }
2757 } /* end switch */
2758
2759 /* reset command */
2760 smsShrdPrm.smsEntStat.curCmd = AT_CMD_NONE;
2761 smsShrdPrm.smsEntStat.entOwn = smsShrdPrm.owner = OWN_NONE;
2762 }
2763
2764
2765 /*
2766 +-------------------------------------------------------------------+
2767 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSR |
2768 | STATE : code ROUTINE : cmhSMS_ReadCbDtaDwnl |
2769 +-------------------------------------------------------------------+
2770
2771 PURPOSE : This function processes the T_SIM_MMI_INSERT_IND primitive.
2772
2773 */
2774 GLOBAL void cmhSMS_ReadCbDtaDwnl (T_SIM_MMI_INSERT_IND *sim_mmi_insert_ind)
2775 {
2776
2777 TRACE_FUNCTION("cmhSMS_ReadCbDtaDwnl()");
2778
2779 if (sim_mmi_insert_ind->cbmid_rec.c_rec NEQ 0)
2780 {
2781 smsShrdPrm.cbmPrm.cbmSIMmaxSATId = sim_mmi_insert_ind->cbmid_rec.c_rec / 2;
2782 cmhSMS_GetCbDtaDwnlSIM (CMD_SRC_NONE,
2783 (UBYTE *) sim_mmi_insert_ind->cbmid_rec.rec,
2784 sim_mmi_insert_ind->cbmid_rec.c_rec);
2785 {
2786 PALLOC (sat_cbch_req, MMI_SAT_CBCH_DWNLD_REQ);
2787
2788 sat_cbch_req->count = (USHORT)smsShrdPrm.cbmPrm.CBDtaDwnlFoundIds;
2789 memset (sat_cbch_req->msg_id, NOT_PRESENT_16BIT,
2790 sizeof (sat_cbch_req->msg_id));
2791 memcpy (sat_cbch_req->msg_id, smsShrdPrm.cbmPrm.CBDtaDwnlIdent,
2792 (size_t)smsShrdPrm.cbmPrm.CBDtaDwnlFoundIds * 2);
2793
2794 PSENDX (PL, sat_cbch_req);
2795 }
2796 }
2797 else
2798 {
2799 TRACE_EVENT(" CBMID records zero");
2800 smsShrdPrm.cbmPrm.cbmSIMmaxSATId = 0;
2801 }
2802 }
2803
2804 /*
2805 +-------------------------------------------------------------------+
2806 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSR |
2807 | STATE : code ROUTINE : cmhSMS_SMSQueryType |
2808 +-------------------------------------------------------------------+
2809
2810 PURPOSE : This function queries the message type of the T_MNSMS_MESSAGE_IND.
2811
2812 */
2813 GLOBAL BOOL cmhSMS_SMSQueryType (T_sms_sdu *sms_sdu,
2814 UBYTE *msg_type)
2815 {
2816 UBYTE ccdRet;
2817
2818 TRACE_FUNCTION("cmhSMS_SMSQueryType()");
2819
2820 if (sms_sdu->l_buf EQ 0)
2821 {
2822 TRACE_EVENT("empty SDU: no decoding");
2823 return FALSE;
2824 }
2825
2826 CCD_START;
2827 {
2828
2829 MCAST( sim_pdu, SIM_PDU ); /* sim_pdu points to _decodedMsg */
2830
2831 /* decoding outer layer */
2832 ccdRet = ccd_decodeMsg ( CCDENT_SMS,
2833 BOTH /* doesn't work with DOWNLINK!!! */,
2834 (T_MSGBUF *) sms_sdu,
2835 (UBYTE *) _decodedMsg, /* target */
2836 SMS_VT_SIM_PDU);
2837
2838 if ((ccdRet NEQ ccdOK) OR (!sim_pdu->v_tpdu)
2839 OR (_decodedMsg[0] NEQ SMS_VT_SIM_PDU))
2840 {
2841 TRACE_EVENT_P1("CCD Decoding Error: %d", ccdRet);
2842 CCD_END;
2843 return FALSE;
2844 }
2845 *msg_type = sim_pdu->tp_mti;
2846 }
2847 CCD_END;
2848
2849 return TRUE;
2850
2851 }
2852
2853 LOCAL BOOL cmhSMS_cpySTtoSM(T_ACI_CMGL_SM *p_sm,T_MNSMS_READ_CNF * mnsms_read_cnf)
2854 {
2855 T_ACI_CDS_SM p_st;
2856 T_MNSMS_STATUS_IND mnsms_status_ind;
2857 BOOL retCode = FALSE;
2858
2859 memcpy (&mnsms_status_ind.sms_sdu, &mnsms_read_cnf->sms_sdu,
2860 sizeof (T_sms_sdu));
2861 retCode = cmhSMS_cpyStatInd ( &p_st, &mnsms_status_ind);
2862 memcpy(p_sm->adress, p_st.addr, MAX_SMS_ADDR_DIG - 1 );
2863 cmhSMS_getStatCmh ( mnsms_read_cnf->status, &p_sm->stat );
2864 p_sm->msg_ref = mnsms_read_cnf->rec_num ;
2865 p_sm->tp_status=p_st.tp_status ;
2866 p_sm->toa .ton = p_st.toa .ton ;
2867 p_sm->toa.npi = p_st.toa.npi;
2868 p_sm->fo = p_st.fo;
2869 p_sm->scts =p_st.vpabs_scts ;
2870
2871 return (retCode);
2872 }
2873 /*==== EOF ========================================================*/