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

src/aci2, src/condat2: import of g23m/condat source pieces from TCS211
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 26 Sep 2016 00:29:36 +0000
parents
children
comparison
equal deleted inserted replaced
2:c41a534f33c6 3:93999a60b835
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : GSM-F&D (8411)
4 | Modul : ATI
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 : AT Command Interpreter: SMS related functions.
18 +-----------------------------------------------------------------------------
19 */
20
21 #ifndef ATI_SMS_C
22 #define ATI_SMS_C
23
24 #undef DUMMY_ATI_STRINGS
25
26 #include "aci_all.h"
27
28 #include "aci_cmh.h"
29 #include "ati_cmd.h"
30 #include "aci_io.h"
31 #include "aci_cmd.h"
32 #include "l4_tim.h"
33
34 #include "aci_mem.h"
35
36 #include "aci_lst.h"
37 #include "conc_sms.h"
38 #include "aci_prs.h"
39
40 #include "ati_int.h"
41
42 #include "cmh_sms.h"
43 #include "psa.h"
44 #include "psa_sms.h"
45 #include "aci.h"
46
47 #ifdef FF_ATI_BAT
48
49 #include "typedefs.h"
50 #include "gdd.h"
51 #include "bat.h"
52
53 #include "ati_bat.h"
54
55 #endif /*FF_ATI_BAT*/
56
57 EXTERN T_SMS_SHRD_PRM smsShrdPrm;
58
59 const SMS_Memory sms_mem [] =
60 {
61 {"ME", SMS_STOR_Me},
62 {"SM", SMS_STOR_Sm},
63 {0,0}
64 };
65
66 #if defined (SMS_PDU_SUPPORT)
67 LOCAL T_ATI_RSLT atPlusCMGSText (char *cl, UBYTE srcId);
68 LOCAL T_ATI_RSLT atPlusCMGWText (char *cl, UBYTE srcId);
69 LOCAL T_ATI_RSLT atPlusCMGCText (char *cl, UBYTE srcId);
70 LOCAL T_ATI_RSLT atPlusCNMAText (char *cl, UBYTE srcId);
71 #endif
72
73 /* move the define into aci_cmd.h */
74
75 GLOBAL void cmd_clearCnmiBuf (void);
76
77 LOCAL T_CNMI_BUFFER cnmiBuf;
78 GLOBAL BOOL cnmiFlushInProgress = FALSE;
79 GLOBAL S16 waitForCnmaFromBuffer_SrcId = CMD_SRC_NONE;
80 LOCAL CHAR daBuf[MAX_SMS_NUM_LEN];
81
82 EXTERN SHORT cmhSMS_getPrfRge ( void );
83 EXTERN BOOL check_str(char * string,char * sample);
84
85 #ifdef _SIMULATION_
86 GLOBAL char subBuf[MAX_SUBADDR_LEN];
87 #endif /* _SIMULATION_ */
88
89 GLOBAL SHORT toda_val;
90 GLOBAL SHORT fo, ct, pid, mn;
91
92 GLOBAL UBYTE cpmsCallType = NONE_CALL;
93
94 /*
95 *
96 ----------------------------SMS Commands-----------------------------------
97 *
98 */
99
100 /*
101 +--------------------------------------------------------------------+
102 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
103 | STATE : code ROUTINE : atPlusCSMS |
104 +--------------------------------------------------------------------+
105
106 PURPOSE : +CSMS command (Select Message Service)
107 */
108
109 GLOBAL T_ATI_RSLT atPlusCSMS (char *cl, UBYTE srcId)
110 {
111 T_ACI_RETURN ret = AT_FAIL;
112 T_ACI_CSMS_SERV service;
113
114 TRACE_FUNCTION("atPlusCSMS()");
115
116 /*input functionality*/
117 cl = parse (cl,"d",&service);
118 if ( !cl OR service > 1)
119 {
120 cmdCmsError(CMS_ERR_OpNotAllowed);
121 return (ATI_FAIL);
122 }
123 ret = sAT_PlusCSMS(srcId,service);
124 if (ret EQ AT_FAIL)
125 {
126 cmdCmsError(CMS_ERR_NotPresent); // use aciErrDesc
127 return (ATI_FAIL);
128 }
129 return (ATI_CMPL);
130 }
131
132 GLOBAL T_ATI_RSLT queatPlusCSMS (char *cl, UBYTE srcId)
133 {
134 T_ACI_RETURN ret = AT_FAIL;
135 T_ACI_CSMS_SERV service;
136 T_ACI_CSMS_SUPP mt;
137 T_ACI_CSMS_SUPP mo;
138 T_ACI_CSMS_SUPP bm;
139 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
140
141
142 ret = qAT_PlusCSMS(srcId,&service,&mt,&mo,&bm);
143 if (ret EQ AT_CMPL)
144 {
145 sprintf(g_sa,"+CSMS: %d,%d,%d,%d",service,mt,mo,bm);
146 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
147 return (ATI_CMPL);
148 }
149 if (ret EQ AT_EXCT)
150 {
151 src_params->curAtCmd = AT_CMD_CSMS;
152 return (ATI_EXCT);
153 }
154 else
155 {
156 cmdCmsError(CMS_ERR_NotPresent); // use aciErrDesc
157 return (ATI_FAIL);
158 }
159 }
160
161 /*
162 +--------------------------------------------------------------------+
163 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
164 | STATE : code ROUTINE : atPlusCPMS |
165 +--------------------------------------------------------------------+
166
167 PURPOSE : +CPMS command (Select Preferred Message Storage)
168 */
169
170 GLOBAL T_ATI_RSLT atPlusCPMS (char *cl, UBYTE srcId)
171 {
172 CHAR* me = "+CPMS: ";
173 CHAR memstr1[3] = {0};
174 CHAR memstr2[3] = {0};
175 CHAR memstr3[3] = {0};
176 T_ACI_RETURN ret = AT_FAIL;
177 T_ACI_SMS_STOR_OCC mem1;
178 T_ACI_SMS_STOR_OCC mem2;
179 T_ACI_SMS_STOR_OCC mem3;
180 BOOL f1 = TRUE;
181 BOOL f2 = TRUE;
182 BOOL f3 = TRUE;
183 SHORT i;
184 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
185
186 TRACE_FUNCTION("atPlusCPMS()");
187
188 mem1.mem = SMS_STOR_NotPresent;
189 mem2.mem = SMS_STOR_NotPresent;
190 mem3.mem = SMS_STOR_NotPresent;
191
192 /*input functionality*/
193 cl = parse ( cl, "sss", (LONG)3, memstr1,
194 (LONG)3, memstr2,
195 (LONG)3, memstr3 );
196
197 strupper ( memstr1 );
198 strupper ( memstr2 );
199 strupper ( memstr3 );
200
201 for ( i=0; sms_mem[i].name NEQ NULL; i++ )
202 {
203 if ( ( strcmp ( sms_mem[i].name, memstr1 ) EQ 0 ) AND f1 )
204 {
205 mem1.mem = sms_mem[i].stor;
206 f1 = FALSE;
207 }
208
209 if ( ( strcmp ( sms_mem[i].name, memstr2 ) EQ 0 ) AND f2 )
210 {
211 mem2.mem = sms_mem[i].stor;
212 f2 = FALSE;
213 }
214
215 if ( ( strcmp ( sms_mem[i].name, memstr3 ) EQ 0 ) AND f3 )
216 {
217 mem3.mem = sms_mem[i].stor;
218 f3 = FALSE;
219 }
220 }
221
222 if (!cl OR f1 /*OR f2 OR f3*/ )
223 {
224 cmdCmsError ( CMS_ERR_OpNotAllowed );
225 return (ATI_FAIL);
226 }
227
228 #ifdef FF_ATI_BAT
229 {
230 T_BAT_cmd_send cmd;
231 T_BAT_cmd_set_plus_cpms cpms;
232 cmd.ctrl_params = BAT_CMD_SET_PLUS_CPMS;
233 cmd.params.ptr_set_plus_cpms = &cpms;
234
235 cpms.mem1 = (T_BAT_plus_cpms_mem1)mem1.mem;
236 cpms.mem2 = (T_BAT_plus_cpms_mem2)mem2.mem;
237 cpms.mem3 = (T_BAT_plus_cpms_mem3)mem3.mem;
238
239 TRACE_FUNCTION("atPlusCPMS() calls bat_send() <=== as APPLICATION");
240 bat_send(ati_bat_get_client(srcId), &cmd);
241
242 return (AT_EXCT);
243 }
244 #else /* FF_ATI_BAT */
245
246 ret = sAT_PlusCPMS ( srcId, mem1.mem, mem2.mem, mem3.mem );
247
248 switch(ret)
249 {
250 case(AT_CMPL):
251 {
252 src_params->curAtCmd = AT_CMD_NONE;
253 return (ATI_CMPL);
254 }
255 default:
256 {
257 cmdCmsError (CMS_ERR_NotPresent); // use aciErrDesc
258 return (ATI_FAIL);
259 }
260 }
261 #endif /* FF_ATI_BAT */
262 }
263
264 GLOBAL T_ATI_RSLT queatPlusCPMS (char *cl, UBYTE srcId)
265 {
266 T_ACI_RETURN ret;
267 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
268
269 /*returns current Memory setting*/
270 ret = qAT_PlusCPMS ( srcId );
271
272 if ( ret EQ AT_CMPL )
273 {
274 src_params->curAtCmd = AT_CMD_NONE;
275 return (ATI_CMPL);
276 }
277 else if ( ret EQ AT_EXCT )
278 {
279 src_params->curAtCmd = AT_CMD_CPMS;
280 return (ATI_EXCT);
281 }
282 else
283 {
284 cmdCmsError ( CMS_ERR_NotPresent); // use aciErrDesc
285 return (ATI_FAIL);
286 }
287 }
288
289 /*
290 +--------------------------------------------------------------------+
291 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
292 | STATE : code ROUTINE : atPlusCMGF |
293 +--------------------------------------------------------------------+
294
295 PURPOSE : +CMGF command (Select Message Format)
296 */
297
298 GLOBAL T_ATI_RSLT atPlusCMGF (char *cl, UBYTE srcId)
299 {
300 T_ACI_RETURN ret = AT_FAIL;
301 T_ACI_CMGF_MOD mode=CMGF_MOD_NotPresent;
302
303 TRACE_FUNCTION("atPlusCMGF()");
304
305 /*
306 * input functionality
307 */
308 cl = parse(cl,"d",&mode);
309 if ( cl)
310 {
311 switch (mode)
312 {
313 case CMGF_MOD_Pdu: /* PDU mode */
314 #if !defined (SMS_PDU_SUPPORT)
315 cmdCmsError(CMS_ERR_OpNotAllowed);
316 return (ATI_FAIL);
317 #else
318 break;
319 #endif
320 case CMGF_MOD_Txt: /* Text Mode */
321 default:
322 break;
323 }
324 }
325 else
326 {
327 /*
328 * parse problems
329 */
330 cmdCmsError(CMS_ERR_OpNotAllowed);
331 return (ATI_FAIL);
332 }
333 /*
334 * Parameter is allowed then set
335 */
336 ret = sAT_PlusCMGF (srcId,mode);
337 if (ret EQ AT_FAIL)
338 {
339 cmdCmsError(CMS_ERR_NotPresent); // use aciErrDesc
340 return (ATI_FAIL);
341 }
342 return (map_aci_2_ati_rslt(ret));
343 }
344
345 GLOBAL T_ATI_RSLT queatPlusCMGF (char *cl, UBYTE srcId)
346 {
347 char *me="+CMGF: ";
348 T_ACI_RETURN ret = AT_FAIL;
349 T_ACI_CMGF_MOD mode=CMGF_MOD_NotPresent;
350
351 TRACE_FUNCTION("queatPlusCMGF()");
352
353 /*
354 * returns current message format PDU/TEXT
355 */
356 ret = qAT_PlusCMGF(srcId, &mode);
357 if (ret EQ AT_CMPL)
358 {
359 sprintf(g_sa,"%s%d",me,mode);
360 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
361 return (ATI_CMPL);
362 }
363 else
364 {
365 cmdCmsError(CMS_ERR_NotPresent); // use aciErrDesc
366 return (ATI_FAIL);
367 }
368 }
369
370 /*
371 +--------------------------------------------------------------------+
372 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
373 | STATE : code ROUTINE : atPlusCSCA |
374 +--------------------------------------------------------------------+
375
376 PURPOSE : +CSCA command (Select Message Service Centre)
377 */
378
379 GLOBAL T_ATI_RSLT atPlusCSCA (char *cl, UBYTE srcId)
380 {
381 T_ACI_RETURN ret = ATI_FAIL;
382 T_ACI_TOA tosca;
383 T_ACI_TOA *p_tosca;
384 SHORT octet=0;
385 CHAR sca[MAX_SMS_NUM_LEN];
386
387 memset (sca, 0, sizeof(sca));
388 p_tosca=&tosca;
389
390 TRACE_FUNCTION("atPlusCSCA()");
391
392 /*input functionality*/
393 cl = parse (cl,"sr",(LONG)MAX_SMS_NUM_LEN,sca,&octet);
394 if ( !cl OR octet > 0xC9 OR sca[0] EQ '\0')
395 {
396 cmdCmsError(CMS_ERR_OpNotAllowed);
397 return (ATI_FAIL);
398 }
399 if(octet EQ 0)
400 p_tosca=NULL;
401 else
402 {
403 tosca=toa_demerge(octet);
404 if (tosca.ton < 0 OR tosca.npi < 0)
405 {
406 cmdCmsError(CMS_ERR_OpNotAllowed);
407 return (ATI_FAIL);
408 }
409 }
410 #ifdef FF_ATI_BAT
411 {
412 T_BAT_cmd_send cmd;
413 T_BAT_cmd_set_plus_csca csca;
414
415 cmd.ctrl_params = BAT_CMD_SET_PLUS_CSCA;
416 cmd.params.ptr_set_plus_csca = &csca;
417
418 csca.c_sca = strlen(sca);
419 memcpy(csca.sca, sca, csca.c_sca);
420 csca.tosca = octet;
421
422 TRACE_FUNCTION("atPlusCSCA() calls bat_send() <=== as APPLICATION");
423 bat_send(ati_bat_get_client(srcId), &cmd);
424
425 return (AT_EXCT);
426 }
427 #else /* FF_ATI_BAT */
428
429 ret = sAT_PlusCSCA(srcId,sca,p_tosca);
430 if (ret EQ AT_FAIL)
431 {
432 cmdCmsError(CMS_ERR_NotPresent); // use aciErrDesc
433 return (ATI_FAIL);
434 }
435 return (map_aci_2_ati_rslt(ret));
436 #endif /* FF_ATI_BAT */
437 }
438
439 GLOBAL T_ATI_RSLT queatPlusCSCA (char *cl, UBYTE srcId)
440 {
441 #ifdef FF_ATI_BAT
442 T_BAT_cmd_send cmd;
443 T_BAT_no_parameter dummy;
444
445 cmd.ctrl_params = BAT_CMD_QUE_PLUS_CSCA;
446 dummy.bat_dummy = 0xFF;
447 cmd.params.ptr_que_plus_csca = &dummy;
448
449 TRACE_FUNCTION("queatPlusCSCA() calls bat_send() <=== as APPLICATION");
450 bat_send(ati_bat_get_client(srcId), &cmd);
451
452 return (AT_EXCT);
453
454 #else /* FF_ATI_BAT */
455
456 T_ACI_RETURN ret = AT_FAIL;
457 T_ACI_TOA tosca;
458 SHORT octet=0;
459 CHAR sca[MAX_SMS_NUM_LEN];
460
461 ret = qAT_PlusCSCA (srcId,sca,&tosca);
462 if (ret EQ AT_CMPL)
463 {
464 octet=toa_merge(tosca);
465 sprintf(g_sa, "+CSCA: \"%s%s\",%d", (tosca.ton EQ TON_International)?"+":"", sca, octet);
466 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
467 return (ATI_CMPL);
468 }
469 else
470 {
471 cmdCmsError(CMS_ERR_NotPresent); // use aciErrDesc
472 return (ATI_FAIL);
473 }
474 #endif /* FF_ATI_BAT */
475 }
476
477 /*
478 +--------------------------------------------------------------------+
479 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
480 | STATE : code ROUTINE : aci_decodeVpabs |
481 +--------------------------------------------------------------------+
482
483 PURPOSE : This function decodes a given string to the T_ACI_VP_ABS
484 enumeration type.
485 */
486 LOCAL BOOL aci_decodeVpabs ( CHAR* vpabs_str,
487 T_ACI_VP_ABS* vpabs_enum )
488 {
489 if ( strlen( vpabs_str ) NEQ 20 OR
490
491 vpabs_str[2] NEQ '/' OR vpabs_str[5] NEQ '/' OR
492 vpabs_str[8] NEQ ',' OR vpabs_str[11] NEQ ':' OR
493 vpabs_str[14] NEQ ':' OR
494
495 ( vpabs_str[17] NEQ '+' AND vpabs_str[17] NEQ '-' ) OR
496
497 vpabs_str[18] < '0' OR vpabs_str[18] > '9' OR
498 vpabs_str[19] < '0' OR vpabs_str[19] > '9' )
499
500 return FALSE;
501
502 vpabs_enum->year [0] = vpabs_str[0] - 0x30;
503 vpabs_enum->year [1] = vpabs_str[1] - 0x30;
504
505 vpabs_enum->month [0] = vpabs_str[3] - 0x30;
506 vpabs_enum->month [1] = vpabs_str[4] - 0x30;
507
508 vpabs_enum->day [0] = vpabs_str[6] - 0x30;
509 vpabs_enum->day [1] = vpabs_str[7] - 0x30;
510
511 vpabs_enum->hour [0] = vpabs_str[9] - 0x30;
512 vpabs_enum->hour [1] = vpabs_str[10] - 0x30;
513
514 vpabs_enum->minute[0] = vpabs_str[12] - 0x30;
515 vpabs_enum->minute[1] = vpabs_str[13] - 0x30;
516
517 vpabs_enum->second[0] = vpabs_str[15] - 0x30;
518 vpabs_enum->second[1] = vpabs_str[16] - 0x30;
519
520 vpabs_enum->timezone = (SHORT) atoi( &vpabs_str[17] );
521
522 return TRUE;
523 }
524
525 /*
526 +--------------------------------------------------------------------+
527 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
528 | STATE : code ROUTINE : aci_decodeVpenh |
529 +--------------------------------------------------------------------+
530
531 PURPOSE : This function decodes a given string to the T_ACI_VP_ENH
532 type.
533 */
534 LOCAL BOOL aci_decodeVpenh ( CHAR* vpenh_str,
535 T_ACI_VP_ENH* vpenh )
536 {
537 UBYTE shift_byte = 0;
538
539 if (vpenh_str[0] EQ '\0')
540 {
541 return FALSE;
542 }
543
544 /* functionality indicator */
545 vpenh->func_ind = (vpenh_str[0] - 0x30) << 4;
546 vpenh->func_ind += (vpenh_str[1] - 0x30);
547
548 /* extension octet */
549 if (vpenh->func_ind & TP_VPF_ENH_EXT_BIT_MASK)
550 {
551 shift_byte = 2;
552 vpenh->ext_oct = (vpenh_str[2] - 0x30) << 4;
553 vpenh->ext_oct += (vpenh_str[3] - 0x30);
554 }
555
556 if ((vpenh->func_ind & TP_VPF_ENH_FORMAT_MASK) > TP_VPF_ENH_HRS)
557 {
558 return FALSE;
559 }
560
561 /* process validity period values */
562 if ((vpenh->func_ind & TP_VPF_ENH_FORMAT_MASK) EQ TP_VPF_ENH_REL)
563 {
564 utl_HexStrToBin ((UBYTE*)&vpenh_str[2+shift_byte], 2, &vpenh->val.vpenh_relative, 1);
565 }
566 else if ((vpenh->func_ind & TP_VPF_ENH_FORMAT_MASK) EQ TP_VPF_ENH_SEC)
567 {
568 utl_HexStrToBin ((UBYTE*)&vpenh_str[2+shift_byte], 2, &vpenh->val.vpenh_seconds, 1);
569 }
570 else if ((vpenh->func_ind & TP_VPF_ENH_FORMAT_MASK) EQ TP_VPF_ENH_HRS)
571 {
572 vpenh->val.vpenh_hours.hour [0] = vpenh_str[3+shift_byte] - 0x30;
573 vpenh->val.vpenh_hours.hour [1] = vpenh_str[2+shift_byte] - 0x30;
574
575 vpenh->val.vpenh_hours.minute[0] = vpenh_str[5+shift_byte] - 0x30;
576 vpenh->val.vpenh_hours.minute[1] = vpenh_str[4+shift_byte] - 0x30;
577
578 vpenh->val.vpenh_hours.second[0] = vpenh_str[7+shift_byte] - 0x30;
579 vpenh->val.vpenh_hours.second[1] = vpenh_str[6+shift_byte] - 0x30;
580 }
581
582 return TRUE;
583 }
584
585
586 /*
587 +--------------------------------------------------------------------+
588 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
589 | STATE : code ROUTINE : atPlusCSMP |
590 +--------------------------------------------------------------------+
591
592 PURPOSE : +CSMP command (Select Text Mode Parameters)
593 */
594
595 GLOBAL T_ATI_RSLT atPlusCSMP (char *cl, UBYTE srcId)
596 {
597
598 char* me = "+CSMP: ";
599 T_ACI_RETURN ret = AT_FAIL;
600 SHORT fo = ACI_NumParmNotPresent,
601 vprel = ACI_NumParmNotPresent,
602 pid = ACI_NumParmNotPresent,
603 dcs = ACI_NumParmNotPresent;
604 USHORT i = 0;
605 char vpabs_str[25] = {'\0'},
606 vpenh_str[15] = {'\0'},
607 fo_str[4];
608
609 T_ACI_VP_ABS vpabs;
610 T_ACI_VP_ABS* pVpabs = NULL;
611 T_ACI_VP_ENH vpenh;
612
613 TRACE_FUNCTION("atPlusCSMP()");
614
615 /*input functionality*/
616 while (*cl NEQ ',' AND *cl NEQ '\0' AND i < sizeof(fo_str) - 1)
617 {
618 fo_str[i]=*cl;
619 cl++;
620 i++;
621 }
622 if (*cl)
623 {
624 cl++;
625 }
626 fo_str[i]='\0';
627 if (strlen (fo_str) > 0)
628 {
629 fo=atoi(fo_str);
630 }
631 if (fo > 255)
632 {
633 cmdCmsError(CMS_ERR_OpNotAllowed);
634 return 0;
635 }
636 if (fo NEQ ACI_NumParmNotPresent AND
637 (fo & TP_VPF_MASK) EQ TP_VPF_ABSOLUTE)
638 {
639 pVpabs = &vpabs;
640
641 cl = parse(cl,"srr",(LONG)25,vpabs_str,&pid,&dcs);
642
643 if (!cl OR strlen(vpabs_str) > 20 OR pid > 255 OR
644 dcs > 255 OR !aci_decodeVpabs (vpabs_str, &vpabs))
645 {
646 cmdCmsError(CMS_ERR_OpNotAllowed);
647 return (ATI_FAIL);
648 }
649 }
650 else if (fo NEQ ACI_NumParmNotPresent AND
651 (fo & TP_VPF_MASK) EQ TP_VPF_ENHANCED)
652 {
653 cl = parse(cl,"srr",(LONG)19,vpenh_str,&pid,&dcs);
654 if (!cl OR strlen(vpenh_str) > 14 OR pid > 255 OR
655 dcs > 255 OR !aci_decodeVpenh (vpenh_str, &vpenh))
656 {
657 cmdCmsError(CMS_ERR_OpNotAllowed);
658 return (ATI_FAIL);
659 }
660 }
661 else if (fo NEQ ACI_NumParmNotPresent AND
662 (fo & TP_VPF_MASK) EQ TP_VPF_RELATIVE)
663 {
664 cl = parse(cl,"rrr",&vprel,&pid,&dcs);
665 }
666 else
667 {
668 if (*cl EQ '\"')
669 {
670 pVpabs = &vpabs;
671
672 cl = parse(cl,"srr",(LONG)25,vpabs_str,&pid,&dcs);
673
674 if (!cl OR strlen(vpabs_str) > 20 OR pid > 255 OR
675 dcs > 255 OR !aci_decodeVpabs (vpabs_str, &vpabs))
676 {
677 cmdCmsError(CMS_ERR_OpNotAllowed);
678 return (ATI_FAIL);
679 }
680 }
681 else
682 {
683 cl = parse(cl,"rrr",&vprel,&pid,&dcs);
684
685 if ( !cl OR vprel > 255 OR pid > 255 OR dcs > 255)
686 {
687 cmdCmsError(CMS_ERR_OpNotAllowed);
688 return (ATI_FAIL);
689 }
690 }
691 }
692 ret = sAT_PlusCSMP(srcId,fo,vprel,pVpabs,&vpenh,pid,dcs);
693 if (ret EQ AT_FAIL)
694 {
695 cmdCmsError(CMS_ERR_NotPresent); // use aciErrDesc
696 return (ATI_FAIL);
697 }
698 return (map_aci_2_ati_rslt(ret));
699 }
700
701 GLOBAL T_ATI_RSLT queatPlusCSMP (char *cl, UBYTE srcId)
702 {
703 char* me = "+CSMP: ";
704 T_ACI_RETURN ret = AT_FAIL;
705 SHORT fo = ACI_NumParmNotPresent,
706 vprel = ACI_NumParmNotPresent,
707 pid = ACI_NumParmNotPresent,
708 dcs = ACI_NumParmNotPresent,
709 i = 0;
710 char vpabs_str[25] = {'\0'};
711 char vpenh_str[15] = {'\0'};
712 T_ACI_VP_ABS vpabs;
713 T_ACI_VP_ENH vpenh;
714
715 TRACE_FUNCTION("queatPlusCSMP()");
716
717 ret = qAT_PlusCSMP(srcId,&fo,&vprel,&vpabs,&vpenh,&pid,&dcs);
718 if (ret EQ AT_CMPL)
719 {
720 if ((fo & TP_VPF_MASK) EQ TP_VPF_ABSOLUTE) /*Bits 4,3 -> 11*/
721 {
722 sprintf(vpabs_str,"\"%d%d/%d%d/%d%d,%d%d:%d%d:%d%d%+03d\"",
723 vpabs.year [0], vpabs.year [1],
724 vpabs.month [0], vpabs.month [1],
725 vpabs.day [0], vpabs.day [1],
726 vpabs.hour [0], vpabs.hour [1],
727 vpabs.minute[0], vpabs.minute[1],
728 vpabs.second[0], vpabs.second[1],
729 vpabs.timezone);
730 sprintf(g_sa,"%s%d,%s,%d,%d",me,fo,vpabs_str,pid,dcs);
731 }
732 else if ((fo & TP_VPF_MASK) EQ TP_VPF_ENHANCED)
733 {
734 aci_encodeVpenh ( vpenh_str, &vpenh );
735 sprintf(g_sa,"%s%d,\"%s\",%d,%d",me,fo,vpenh_str,pid,dcs);
736 }
737 else if ((fo & TP_VPF_MASK) EQ TP_VPF_RELATIVE) /*Bits 4,3 -> 10*/
738 {
739 sprintf(g_sa,"%s%d,%d,%d,%d",me,fo,vprel,pid,dcs);
740 }
741 else
742 {
743 sprintf(g_sa,"%s%d,,%d,%d",me,fo,pid,dcs);
744 }
745 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
746 return (ATI_CMPL);
747 }
748 else
749 {
750 cmdCmsError(CMS_ERR_NotPresent); // use aciErrDesc
751 return (ATI_FAIL);
752 }
753 }
754
755 /*
756 +--------------------------------------------------------------------+
757 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
758 | STATE : code ROUTINE : atPlusCSDH |
759 +--------------------------------------------------------------------+
760
761 PURPOSE : +CSDH command (Show Text Mode Parameters)
762 */
763
764 GLOBAL T_ATI_RSLT atPlusCSDH (char *cl, UBYTE srcId)
765 {
766
767 T_ACI_CSDH_SHOW ena = CSDH_SHOW_Disable;
768
769 TRACE_FUNCTION("atPlusCSDH()");
770
771 /*input functionality*/
772 cl = parse(cl,"d",&ena);
773 if ( !cl )
774 {
775 cmdCmsError(CMS_ERR_OpNotAllowed);
776 return (ATI_FAIL);
777 }
778 ati_user_output_cfg[srcId].CSDH_stat=ena;
779 return (ATI_CMPL);
780 }
781
782 GLOBAL T_ATI_RSLT tesatPlusCSDH (char *cl, UBYTE srcId)
783 {
784 return(atPlusCSDH (cl, srcId));
785 }
786
787 GLOBAL T_ATI_RSLT queatPlusCSDH (char *cl, UBYTE srcId)
788 {
789 sprintf(g_sa,"+CSDH: %d",ati_user_output_cfg[srcId].CSDH_stat);
790 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
791 return (ATI_CMPL);
792 }
793
794 /*
795 +--------------------------------------------------------------------+
796 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
797 | STATE : code ROUTINE : atPlusCSCB |
798 +--------------------------------------------------------------------+
799
800 PURPOSE : +CSCB command (select cell broadcast message type)
801 */
802
803 GLOBAL T_ATI_RSLT atPlusCSCB (char *cl, UBYTE srcId)
804 {
805 char *me="+CSCB: ";
806 T_ACI_RETURN ret = AT_FAIL;
807 T_ACI_CSCB_MOD mode;
808 char mids_str[6*MAX_CBM_TYPES]={0}; /* CHECK IF LONG ENOUGH !!*/
809 char dcss_str[4*MAX_CBM_TYPES]={0};
810 CHAR buf[6]={0};
811 USHORT mids[MAX_CBM_TYPES];
812 UBYTE dcss[MAX_CBM_TYPES];
813 SHORT pos=0,i=0,j=0;
814
815 #ifdef FF_ATI_BAT
816 T_BAT_cmd_set_plus_cscb cscb;
817 #endif
818
819
820 TRACE_FUNCTION("atPlusCSCB()");
821
822 /*input functionality*/
823 cl = parse(cl,"dss",&mode,(LONG)sizeof(mids_str),mids_str,(LONG)sizeof(dcss_str),dcss_str);
824 if ( !cl )
825 {
826 cmdCmsError(CMS_ERR_OpNotAllowed);
827 return (ATI_FAIL);
828 }
829 i = j = 0;
830 memset (mids, NOT_PRESENT_8BIT, sizeof (mids));
831 while (mids_str[i] NEQ '\0' AND j < MAX_CBM_TYPES - 1)
832 {
833 pos=0;
834 while (mids_str[i] >= '0' AND mids_str[i] <= '9')
835 {
836 if (pos >= 5)
837 {
838 cmdCmsError(CMS_ERR_OpNotAllowed);
839 return (ATI_FAIL);
840 }
841 buf[pos++]=mids_str[i];
842 i++;
843 }
844 buf[pos]='\0';
845 if (mids_str[i] NEQ ',' AND mids_str[i] NEQ '-' AND mids_str[i] NEQ '\0')
846 {
847 cmdCmsError(CMS_ERR_OpNotAllowed);
848 return (ATI_FAIL);
849 }
850 else
851 {
852 if (mids_str[i] EQ ',' OR mids_str[i] EQ '\0')
853 {
854 i++;
855 mids[j++]=atoi(buf);
856 mids[j++]=atoi(buf);
857 }
858 else
859 {
860 i++;
861 mids[j++]=atoi(buf);
862 pos=0;
863 while (mids_str[i] NEQ ',' AND mids_str[i] NEQ '\0')
864 {
865 if (pos >= 5)
866 {
867 cmdCmsError(CMS_ERR_OpNotAllowed);
868 return (ATI_FAIL);
869 }
870 buf[pos++]=mids_str[i];
871 i++;
872 }
873 i++;
874 mids[j++]=atoi(buf);
875 }
876 }
877 }
878
879 if (compact(&mids_str[i],(USHORT)strlen(&mids_str[i])) NEQ 0)
880 {
881 cmdCmsError(CMS_ERR_OpNotAllowed);
882 return (ATI_FAIL);
883 }
884
885 #ifdef FF_ATI_BAT
886 memset(cscb.mids, NOT_PRESENT_8BIT, sizeof(cscb.mids));
887 cscb.v_mids = j ? TRUE : FALSE;
888 cscb.c_mids = (U8)j;
889 memcpy(cscb.mids, mids, j*2);
890 #endif
891
892 i = j = 0;
893 memset (dcss, NOT_PRESENT_8BIT, sizeof (dcss));
894 while (dcss_str[i] NEQ '\0' AND j < MAX_CBM_TYPES - 1)
895 {
896 pos=0;
897 while (dcss_str[i] >= '0' AND dcss_str[i] <= '9')
898 {
899 if (pos >= 3)
900 {
901 cmdCmsError(CMS_ERR_OpNotAllowed);
902 return (ATI_FAIL);
903 }
904 buf[pos++]=dcss_str[i];
905 i++;
906 }
907 buf[pos]='\0';
908 if (dcss_str[i] NEQ ',' AND dcss_str[i] NEQ '-' AND dcss_str[i] NEQ '\0')
909 {
910 cmdCmsError(CMS_ERR_OpNotAllowed);
911 return (ATI_FAIL);
912 }
913 else
914 {
915 if (dcss_str[i] EQ ',' OR dcss_str[i] EQ '\0')
916 {
917 i++;
918 dcss[j++]=atoi(buf);
919 dcss[j++]=atoi(buf);
920 }
921 else
922 {
923 i++;
924 dcss[j++]=atoi(buf);
925 pos=0;
926 while (dcss_str[i] NEQ ',' AND dcss_str[i] NEQ '\0')
927 {
928 if (pos >= 3)
929 {
930 cmdCmsError(CMS_ERR_OpNotAllowed);
931 return (ATI_FAIL);
932 }
933 buf[pos++]=dcss_str[i];
934 i++;
935 }
936 i++;
937 dcss[j++]=atoi(buf);
938 }
939 }
940 }
941 if (compact(&dcss_str[i],(USHORT)strlen(&dcss_str[i])) NEQ 0)
942 {
943 cmdCmsError(CMS_ERR_OpNotAllowed);
944 return (ATI_FAIL);
945 }
946
947 #ifdef FF_ATI_BAT
948 {
949 T_BAT_cmd_send cmd;
950
951 cmd.ctrl_params = BAT_CMD_SET_PLUS_CSCB;
952 cmd.params.ptr_set_plus_cscb = &cscb;
953
954 cscb.mode = (T_BAT_VAL_plus_cscb_mode)mode;
955
956 memset(cscb.dcss, NOT_PRESENT_8BIT, sizeof(cscb.dcss));
957 cscb.v_dcss = j ? TRUE : FALSE;;
958 cscb.c_dcss = (U8)j;
959 memcpy(cscb.dcss, dcss, cscb.c_dcss);
960
961
962 TRACE_FUNCTION("atPlusCSCB() calls bat_send() <=== as APPLICATION");
963 bat_send(ati_bat_get_client(srcId), &cmd);
964 return (AT_EXCT);
965 }
966 #else /* FF_ATI_BAT */
967 ret=sAT_PlusCSCB(srcId,mode,mids,dcss);
968 if (ret EQ AT_FAIL)
969 {
970 cmdCmsError(CMS_ERR_NotPresent); // use aciErrDesc
971 return (ATI_FAIL);
972 }
973 return (map_aci_2_ati_rslt(ret));
974 #endif /* FF_ATI_BAT */
975 }
976
977 GLOBAL T_ATI_RSLT queatPlusCSCB (char *cl, UBYTE srcId)
978 {
979 #ifdef FF_ATI_BAT
980 T_BAT_cmd_send cmd;
981 T_BAT_no_parameter dummy;
982
983 cmd.ctrl_params = BAT_CMD_QUE_PLUS_CSCB;
984 dummy.bat_dummy = 0xFF;
985 cmd.params.ptr_que_plus_cscb = &dummy;
986
987 TRACE_FUNCTION("queatPlusCSCB() calls bat_send() <=== as APPLICATION");
988 bat_send(ati_bat_get_client(srcId), &cmd);
989
990 return (AT_EXCT);
991
992 #else /* FF_ATI_BAT */
993 T_ACI_CSCB_MOD mode;
994 char mids_str[6*MAX_CBM_TYPES+1]={'\0'}; /* +1 for '\0' */ /* CHECK IF LONG ENOUGH !!*/
995 char dcss_str[4*MAX_CBM_TYPES+1]={'\0'};
996 USHORT mids[MAX_CBM_TYPES];
997 UBYTE dcss[MAX_CBM_TYPES];
998 SHORT pos=0,i=0;
999 T_ACI_RETURN ret = AT_FAIL;
1000
1001 TRACE_FUNCTION("queatPlusCSCB()");
1002
1003 ret = qAT_PlusCSCB(srcId, &mode,mids,dcss);
1004 if (ret EQ AT_CMPL)
1005 {
1006 /*
1007 *-----------------------------------------------------------
1008 * assemble the string for message identifiers
1009 *-----------------------------------------------------------
1010 */
1011 pos = i = 0;
1012 while( mids[i] NEQ 0xFFFF AND
1013 mids[i+1] NEQ 0xFFFF AND
1014 i < MAX_CBM_TYPES - 1 )
1015 {
1016 if ( mids[i] EQ mids[i+1] )
1017 pos += sprintf ( mids_str + pos, "%d,", mids[i] );
1018 else
1019 pos += sprintf ( mids_str + pos, "%d-%d,", mids[i], mids[i+1] ); /* "65534-65535," max 12 chars */
1020
1021 i += 2;
1022 }
1023
1024 /*lint -e(661) -e(662) */ /* lint 7.5 has here some problems ... */
1025 if ( pos > 0 ) /* remove the last ',' */
1026 {
1027 mids_str[pos-1] = '\0';
1028 }
1029
1030 /*
1031 *-----------------------------------------------------------
1032 * assemble the string for data coding schemes
1033 *-----------------------------------------------------------
1034 */
1035 pos = i = 0;
1036 while( dcss[i] NEQ 0xFF AND
1037 dcss[i+1] NEQ 0xFF AND
1038 i < MAX_CBM_TYPES - 1 )
1039 {
1040 if ( dcss[i] EQ dcss[i+1] )
1041 pos += sprintf ( dcss_str + pos, "%d,", dcss[i] );
1042 else
1043 pos += sprintf ( dcss_str + pos, "%d-%d,", dcss[i], dcss[i+1] );
1044
1045 i += 2;
1046 }
1047
1048 /*lint -e(661) -e(662) */
1049 if ( pos > 0 ) /* remove the last ',' */
1050 {
1051 dcss_str[pos-1] = '\0';
1052 }
1053
1054 sprintf(g_sa,"+CSCB: %d,\"%s\",\"%s\"",mode,mids_str,dcss_str);
1055 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
1056 return (ATI_CMPL);
1057 }
1058 else
1059 {
1060 cmdCmsError(CMS_ERR_NotPresent); // use aciErrDesc
1061 return (ATI_FAIL);
1062 }
1063 #endif /* FF_ATI_BAT */
1064 }
1065
1066 #ifdef FF_HOMEZONE
1067 /*
1068 +--------------------------------------------------------------------+
1069 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1070 | STATE : code ROUTINE : atPercentCBHZ |
1071 +--------------------------------------------------------------------+
1072
1073 PURPOSE : %CBHZ command (set homezone activity)
1074 */
1075
1076 GLOBAL T_ATI_RSLT setatPercentCBHZ (char *cl, UBYTE srcId)
1077 {
1078 T_ACI_CBHZ_MOD mode = CBHZ_MOD_NotPresent;
1079 T_ACI_CS dcs = CS_NotPresent;
1080 UBYTE timeout = NOT_PRESENT_8BIT;
1081 T_ACI_RETURN ret = AT_FAIL;
1082
1083 TRACE_FUNCTION("setatPercentCBHZ()");
1084
1085
1086 /*input functionality*/
1087
1088 /*check first parameter */
1089 switch (*cl)
1090 {
1091 case '0':
1092 case '1':
1093 mode = *cl - 0x30;
1094 cl++;
1095 break;
1096
1097 default:
1098 cmdCmsError(CMS_ERR_OpNotAllowed);
1099 return (ATI_FAIL);
1100 }
1101
1102 /* check second parameter */
1103 if ( *cl NEQ '\0' )
1104 {
1105 if ( *cl NEQ ',')
1106 {
1107 cmdCmsError(CMS_ERR_OpNotAllowed);
1108 return (ATI_FAIL);
1109 }
1110 cl++;
1111
1112 if ( (*cl >= '0') AND (*cl <= '9') )
1113 {
1114 dcs = *cl -0x30;
1115 cl++;
1116 }
1117
1118 /* check third parameter */
1119 if ( *cl NEQ '\0' )
1120 {
1121 if ( *cl NEQ ',')
1122 {
1123 cmdCmsError(CMS_ERR_OpNotAllowed);
1124 return (ATI_FAIL);
1125 }
1126 cl++;
1127
1128 cl = parse(cl,"d",&timeout);
1129 if ( *cl NEQ '\0' )
1130 {
1131 cmdCmsError(CMS_ERR_OpNotAllowed);
1132 return (ATI_FAIL);
1133 }
1134 }
1135 }
1136
1137 /* parameters ok... process homezone request */
1138 ret = sAT_PercentCBHZ(srcId,mode,dcs,timeout);
1139 if (ret EQ AT_FAIL)
1140 {
1141 cmdCmeError(CME_ERR_Unknown);
1142 return (ATI_FAIL);
1143 }
1144
1145 return (ATI_CMPL);
1146 }
1147
1148
1149 GLOBAL T_ATI_RSLT tesatPercentCBHZ (char *cl, UBYTE srcId)
1150 {
1151 TRACE_FUNCTION("tesatPercentCBHZ()");
1152
1153 sprintf( g_sa, "%s: (%d,%d),(%d-%d),(%d-%d)",
1154 "%CBHZ", CBHZ_MOD_NotActive, CBHZ_MOD_Active,
1155 CS_GsmDef, CS_Ascii, CBHZ_MIN_TIMEOUT, CBHZ_MAX_TIMEOUT);
1156
1157
1158 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
1159
1160 return (ATI_CMPL);
1161 }
1162
1163 GLOBAL T_ATI_RSLT queatPercentCBHZ (char *cl, UBYTE srcId)
1164 {
1165 T_ACI_RETURN ret;
1166 T_ACI_CBHZ_MOD mode;
1167 T_ACI_CS dcs;
1168 UBYTE timeout;
1169
1170 TRACE_FUNCTION("queatPercentCBSHZ()");
1171
1172 ret = qAT_PercentCBHZ(srcId, &mode, &dcs, &timeout);
1173
1174 if (ret EQ AT_FAIL)
1175 {
1176 cmdCmeError(CME_ERR_Unknown);
1177 return (ATI_FAIL);
1178 }
1179
1180 /*
1181 *-----------------------------------------------------------
1182 * assemble the string for output
1183 *-----------------------------------------------------------
1184 */
1185
1186 sprintf( g_sa, "%s: %d,%d,%d", "%CBHZ", mode, dcs, timeout);
1187
1188 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
1189
1190 return (ATI_CMPL);
1191 }
1192 #endif /* FF_HOMEZONE */
1193
1194 /*
1195 +--------------------------------------------------------------------+
1196 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1197 | STATE : code ROUTINE : atPlusCSAS |
1198 +--------------------------------------------------------------------+
1199
1200 PURPOSE : +CSAS command (Save SMS Profile)
1201 */
1202
1203 GLOBAL T_ATI_RSLT atPlusCSAS (char *cl, UBYTE srcId)
1204 {
1205 SHORT profile = -1;
1206 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
1207
1208 TRACE_FUNCTION("atPlusCSAS()");
1209
1210 if ( *cl EQ '\0' )
1211 {
1212 profile = 1;
1213 }
1214 else
1215 {
1216 cl = parse ( cl, "r", &profile );
1217 if ( !cl )
1218 {
1219 cmdCmsError ( CMS_ERR_MemFail );
1220 return (ATI_FAIL);
1221 }
1222 profile++;
1223 }
1224 #ifdef FF_ATI_BAT
1225 {
1226 T_BAT_cmd_send cmd;
1227 T_BAT_cmd_set_plus_csas csas;
1228
1229 cmd.ctrl_params = BAT_CMD_SET_PLUS_CSAS;
1230 cmd.params.ptr_set_plus_csas = &csas;
1231
1232 csas.profile = profile;
1233
1234 TRACE_FUNCTION("atPlusCSAS() calls bat_send() <=== as APPLICATION");
1235 bat_send(ati_bat_get_client(srcId), &cmd);
1236 return (AT_EXCT);
1237 }
1238 #else /* FF_ATI_BAT */
1239 switch (sAT_PlusCSAS (srcId, profile))
1240 {
1241 case AT_EXCT:
1242 src_params->curAtCmd = AT_CMD_CSAS;
1243 return (ATI_EXCT);
1244
1245 case AT_BUSY:
1246 return (ATI_BUSY);
1247
1248 case AT_CMPL:
1249 return (ATI_CMPL_NO_OUTPUT);
1250
1251 case AT_FAIL: /* execution of command failed */
1252 default:
1253 cmdCmsError ( CMS_ERR_NotPresent); /* use aciErrDesc */
1254 return (ATI_FAIL);
1255 }
1256 #endif /* FF_ATI_BAT */
1257 }
1258
1259 GLOBAL T_ATI_RSLT tesatPlusCSAS (char *cl, UBYTE srcId)
1260 {
1261 SHORT profile = -1;
1262
1263 if ((profile = cmhSMS_getPrfRge ()) < 1)
1264 {
1265 cmdCmsError ( CMS_ERR_MemFail );
1266 return (ATI_FAIL);
1267 }
1268 else
1269 {
1270 sprintf ( g_sa, "+CSAS: (0-%d)", profile - 1 );
1271 io_sendMessage ( srcId, g_sa, ATI_NORMAL_OUTPUT );
1272 return (ATI_CMPL);
1273 }
1274 }
1275
1276 /*
1277 +--------------------------------------------------------------------+
1278 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1279 | STATE : code ROUTINE : atPlusCRES |
1280 +--------------------------------------------------------------------+
1281
1282 PURPOSE : +CRES command (Load SMS Profile)
1283 */
1284
1285 GLOBAL T_ATI_RSLT atPlusCRES (char *cl, UBYTE srcId)
1286 {
1287 SHORT profile = -1;
1288 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
1289
1290 TRACE_FUNCTION("atPlusCRES()");
1291
1292 if ( *cl EQ '\0' )
1293 {
1294 profile = 1;
1295 }
1296 else
1297 {
1298 cl = parse ( cl, "r", &profile );
1299
1300 if ( !cl )
1301 {
1302 cmdCmsError ( CMS_ERR_MemFail );
1303 return (ATI_FAIL);
1304 }
1305 profile++;
1306 }
1307
1308 switch (sAT_PlusCRES (srcId, profile))
1309 {
1310 case AT_EXCT:
1311 src_params->curAtCmd = AT_CMD_CRES;
1312 return (ATI_EXCT);
1313
1314 case AT_BUSY:
1315 return (ATI_BUSY);
1316
1317 case AT_CMPL:
1318 io_sendConfirm ( srcId, cmdAtError ( atOk ), ATI_NORMAL_OUTPUT );
1319 return (ATI_CMPL_NO_OUTPUT);
1320
1321 case AT_FAIL:
1322 default:
1323 cmdCmsError ( CMS_ERR_NotPresent); // use aciErrDesc
1324 return (ATI_FAIL);
1325 }
1326 }
1327
1328 GLOBAL T_ATI_RSLT tesatPlusCRES (char *cl, UBYTE srcId)
1329 {
1330 T_ACI_CRES profile;
1331 T_ACI_RETURN result;
1332
1333 result = tAT_PlusCRES (srcId, &profile);
1334 switch (result)
1335 {
1336 case AT_FAIL:
1337 cmdCmsError ( CMS_ERR_MemFail );
1338 return (ATI_FAIL);
1339
1340 case AT_CMPL:
1341 break;
1342
1343 default:
1344 cmdCmsError ( CMS_ERR_MemFail );
1345 return (ATI_FAIL);
1346 }
1347
1348 sprintf ( g_sa, "+CRES: (%d-%d)", profile.min, profile.max);
1349 io_sendMessage ( srcId, g_sa, ATI_NORMAL_OUTPUT );
1350 return (ATI_CMPL);
1351 }
1352
1353 /*
1354 +--------------------------------------------------------------------+
1355 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1356 | STATE : code ROUTINE : atPlusCMGR |
1357 +--------------------------------------------------------------------+
1358
1359 PURPOSE : +CMGR command (Read Message)
1360 */
1361
1362 GLOBAL T_ATI_RSLT atPlusCMGR (char *cl, UBYTE srcId)
1363 {
1364 char *me="+CMGR: ";
1365 T_ACI_RETURN ret = AT_FAIL;
1366 SHORT idx=-1;
1367 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
1368
1369 TRACE_FUNCTION("atPlusCMGR()");
1370
1371 #ifndef WIN32
1372 cl = parse(cl,"r",&idx);
1373 #else
1374 cl = parse(cl,"rd",&idx, &smsReadMode );
1375 #endif
1376 if ( !cl OR idx > 255 OR idx < 0)
1377 {
1378 cmdCmsError(CMS_ERR_OpNotAllowed);
1379 return (ATI_FAIL);
1380 }
1381
1382 #ifdef FF_ATI_BAT
1383
1384 {
1385 T_BAT_cmd_send cmd;
1386 T_BAT_cmd_set_plus_cmgr cmgr;
1387
1388 cmd.ctrl_params=BAT_CMD_SET_PLUS_CMGR;
1389 cmd.params.ptr_set_plus_cmgr=&cmgr;
1390
1391 cmgr.sms_index=(U16)idx;
1392
1393 bat_send(ati_bat_get_client(srcId), &cmd);
1394
1395 src_params->curAtCmd=AT_CMD_CMGR;
1396 return(ATI_EXCT);
1397 }
1398
1399 #else
1400
1401 #ifndef _CONC_TESTING_
1402 #ifndef _SIMULATION_
1403 ret = sAT_PlusCMGR_Gl(srcId, (UBYTE)idx, SMS_READ_Normal, NULL);
1404 #else
1405 ret = sAT_PlusCMGR_Gl(srcId, (UBYTE)idx, smsReadMode , NULL);
1406 #endif
1407 #else
1408 #ifndef _SIMULATION_
1409 ret = sAT_PlusCMGR (srcId, (UBYTE)idx, SMS_READ_Normal);
1410 #else
1411 ret = sAT_PlusCMGR (srcId, (UBYTE)idx, smsReadMode );
1412 #endif
1413 #endif
1414 if ( ret EQ AT_CMPL )
1415 {
1416 return (ATI_CMPL);
1417 }
1418 else if (ret EQ AT_EXCT)
1419 {
1420 src_params->curAtCmd = AT_CMD_CMGR;
1421 return (ATI_EXCT);
1422 }
1423 else
1424 {
1425 cmdCmsError(CMS_ERR_NotPresent); // use aciErrDesc
1426 return (ATI_FAIL);
1427 }
1428
1429 #endif /*FF_ATI_BAT*/
1430 }
1431
1432 /*
1433 +--------------------------------------------------------------------+
1434 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1435 | STATE : code ROUTINE : atPlusCMGS |
1436 +--------------------------------------------------------------------+
1437
1438 PURPOSE : +CMGS command (SEND Message)
1439 */
1440
1441 GLOBAL T_ATI_RSLT tesatPlusCMGS (char *cl, UBYTE srcId)
1442 {
1443 io_sendConfirm ( srcId, cmdAtError ( atOk ), ATI_NORMAL_OUTPUT );
1444 return ATI_CMPL_NO_OUTPUT;
1445 }
1446
1447 GLOBAL T_ATI_RSLT queatPlusCMGS (char *cl, UBYTE srcId)
1448 {
1449 cmdCmsError(CMS_ERR_OpNotAllowed); /* querying CMGS not specified in 07.05 */
1450 return (ATI_FAIL);
1451 }
1452
1453
1454 GLOBAL T_ATI_RSLT atPlusCMGS (char *cl, UBYTE srcId)
1455 #if defined (SMS_PDU_SUPPORT)
1456 {
1457 T_ACI_CMGF_MOD mode;
1458
1459 TRACE_FUNCTION("atPlusCMGS()");
1460 /*
1461 * request current mode
1462 */
1463 qAT_PlusCMGF(srcId, &mode);
1464 if (mode EQ 0)
1465 {
1466 /*
1467 * handle PDU mode
1468 */
1469 return (atPlusCMGSPdu (cl, srcId));
1470 }
1471 else
1472 {
1473 /*
1474 * handle Text mode
1475 */
1476 return (atPlusCMGSText (cl, srcId));
1477 }
1478 }
1479
1480
1481 /*
1482 +--------------------------------------------------------------------+
1483 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1484 | STATE : code ROUTINE : str_to_bcd |
1485 +--------------------------------------------------------------------+
1486
1487 PURPOSE : A very specialised routine for converting a 2-byte string
1488 into one byte of BCD, intended to be used by atPlusCMGSText()
1489 only.
1490 */
1491 LOCAL UBYTE str_to_bcd(
1492 CHAR *str)
1493 {
1494 UBYTE bcd;
1495 UBYTE n;
1496
1497 for (n=0;n<2;n++)
1498 {
1499 bcd>>=4;
1500
1501 if ((str[n]<'0') || (str[n]>'9'))
1502 bcd+=0xF0;
1503 else
1504 bcd+=(str[n]-'0')<<4;
1505 }
1506
1507 return(bcd);
1508 }
1509
1510
1511 LOCAL T_ATI_RSLT atPlusCMGSText(char *cl, UBYTE srcId)
1512 #endif /* (SMS_PDU_SUPPORT) */
1513 {
1514 T_ACI_VP_ABS vpabs;
1515 SHORT fo,
1516 vprel,
1517 pid,
1518 dcs;
1519 CHAR* me = "+CMGS: ";
1520 T_ACI_RETURN ret = AT_FAIL;
1521 T_ACI_TOA toda;
1522 T_ACI_TOA* p_toda;
1523 GLOBAL SHORT toda_val = 0;
1524 T_ACI_SM_DATA msg;
1525 USHORT lenMsg;
1526 CHAR* da = daBuf;
1527
1528 static T_ACI_TOA tosca;
1529 static T_ACI_TOA *p_tosca;
1530 #ifdef _SIMULATION_
1531 CHAR *sca =subBuf;
1532 #endif /* _SIMULATION_ */
1533 SHORT octet=0;
1534 static SHORT isReply;
1535
1536 #ifdef _CONC_TESTING_
1537 T_SM_DATA_EXT msg_conc;
1538 #endif
1539
1540 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
1541
1542 if (src_params->text_mode EQ CMD_MODE)
1543 {
1544 TRACE_FUNCTION("atPlusCMGSText() CMD_MODE");
1545 memset (da, 0, MAX_SMS_NUM_LEN);
1546 /* input functionality */
1547 da[0]='\0';
1548 #ifndef WIN32
1549 cl = parse (cl,"sr",(LONG)MAX_SMS_NUM_LEN,da,&toda_val);
1550 if ( !cl OR da[0] EQ '\0')
1551 {
1552 cmdCmsError (CMS_ERR_OpNotAllowed);
1553 return (ATI_FAIL);
1554 }
1555 #else
1556 *sca ='\0';
1557 isReply = -1;
1558 cl = parse (cl,"srsrb",(LONG)MAX_SMS_NUM_LEN,da,&toda_val,
1559 (LONG)MAX_SMS_NUM_LEN,sca,&octet,&isReply);
1560 if ( !cl OR da[0] EQ '\0')
1561 {
1562 cmdCmsError (CMS_ERR_OpNotAllowed);
1563 return (ATI_FAIL);
1564 }
1565 if (octet EQ 0)
1566 {
1567 p_tosca=NULL;
1568 }
1569 else
1570 {
1571 tosca=toa_demerge(octet);
1572 if (tosca.ton < 0 OR tosca.npi < 0)
1573 {
1574 cmdCmsError(CMS_ERR_OpNotAllowed);
1575 return (ATI_FAIL);
1576 }
1577 }
1578 #endif
1579 if (toda_val)
1580 {
1581 toda=toa_demerge(toda_val);
1582 if (toda.ton < 0 OR toda.npi < 0)
1583 {
1584 cmdCmsError(CMS_ERR_OpNotAllowed);
1585 return (ATI_FAIL);
1586 }
1587 }
1588
1589 src_params->text_mode = TXT_MODE;
1590 return (ATI_EXCT);
1591 } /* end of if (src_params->text_mode EQ CMD_MODE) */
1592 else
1593 {
1594 TRACE_FUNCTION("atPlusCMGSText() TXT_MODE");
1595
1596 src_params->text_mode = CMD_MODE;
1597 /* if the character sent is ESC, then abort command CLB 16.11.00 */
1598 if (*cl EQ 0x1B)
1599 {
1600 TRACE_EVENT("Send message command cancelled by user");
1601
1602 return ATI_CMPL_NO_OUTPUT;
1603 }
1604
1605 if ( toda_val EQ 0 )
1606 {
1607 #ifndef _SIMULATION_
1608 #endif /* ndef _SIMULATION_ */
1609 p_toda = NULL;
1610 }
1611 else
1612 {
1613 toda = toa_demerge ( toda_val );
1614 p_toda = &toda;
1615 }
1616
1617 qAT_PlusCSMP ( srcId, &fo, &vprel, &vpabs, NULL, &pid, &dcs );
1618
1619 srcId_cb = srcId;
1620 if (ati_user_output_cfg[srcId].cscsChset EQ CSCS_CHSET_Ucs2 )
1621 {
1622 utl_smDtaFromTe ((UBYTE*)cl,
1623 (USHORT)MINIMUM(strlen(cl),sizeof(msg.data)*4),
1624 msg.data,
1625 &lenMsg,
1626 (UBYTE)fo,
1627 (UBYTE)dcs );
1628 }
1629 else if (ati_user_output_cfg[srcId].cscsChset EQ CSCS_CHSET_Hex )
1630 {
1631 utl_smDtaFromTe ((UBYTE*)cl,
1632 (USHORT)MINIMUM(strlen(cl),sizeof(msg.data)*2),
1633 msg.data,
1634 &lenMsg,
1635 (UBYTE)fo,
1636 (UBYTE)dcs );
1637 }
1638 else
1639 {
1640 utl_smDtaFromTe ((UBYTE*)cl,
1641 (USHORT)MINIMUM(strlen(cl),sizeof(msg.data)),
1642 msg.data,
1643 &lenMsg,
1644 (UBYTE)fo,
1645 (UBYTE)dcs );
1646 }
1647 msg.len = (UBYTE)lenMsg;
1648
1649 #if 0 /* #ifdef FF_ATI_BAT */
1650
1651 {
1652 T_BAT_cmd_send cmd;
1653 T_BAT_cmd_set_plus_cmgs cmgs;
1654 UBYTE len;
1655 UBYTE i;
1656 U8 *p;
1657 CHAR clean_da[MAX_SMS_NUM_LEN+1];
1658
1659 cmd.ctrl_params=BAT_CMD_SET_PLUS_CMGS;
1660 cmd.params.ptr_set_plus_cmgs=&cmgs;
1661
1662 /*
1663 * The BAT uses only PDU format, so we must convert the data.
1664 * This code is sufficient to allow tests ACIPHB75-78 to pass - at
1665 * the time of writing, these are the only tests we have available
1666 * for +CMGS. When it comes to other tests, some enhancements will
1667 * certainly be required.
1668 */
1669
1670 p=cmgs.pdu;
1671
1672 /*
1673 * SCA - Service Centre Address
1674 */
1675 len=(UBYTE)strlen(sca);
1676
1677 if (len==0)
1678 {
1679 /*
1680 * No service centre address indicated. If we use a zero length
1681 * to indicate the default SCA, we will have problems later in
1682 * DecodeRPAddress(). The version below seems to be fine.
1683 */
1684 *p++=0x01;
1685 *p++=0x80;
1686 }
1687 else
1688 {
1689 /*
1690 * The length is the number of octets in the parameter, not
1691 * the number of address digits.
1692 */
1693 *p++=(U8)((len+1)/2)+1;
1694
1695 /*
1696 * Type of number.
1697 */
1698 *p++=(tosca.ton==TON_International) ? 0x91:0x81;
1699
1700 /*
1701 * Convert the address from string format to BCD format.
1702 */
1703 for (i=0;i<len;i+=2)
1704 *p++=str_to_bcd(&sca[i]);
1705 }
1706
1707 /*
1708 * PDU type
1709 */
1710 *p++=0x01;
1711
1712 /*
1713 * MR - Message reference
1714 */
1715 *p++=0x00;
1716
1717 /*
1718 * DA - Destination Address
1719 * The length is the number of address digits, not the number of
1720 * octets in the parameter.
1721 */
1722
1723 /*
1724 * First, make a clean version of the string, getting rid of
1725 * any unwanted characters.
1726 */
1727 {
1728 SHORT cctr,dctr;
1729 CHAR c;
1730
1731 memset(clean_da,0,sizeof(clean_da));
1732
1733 cctr=0;
1734
1735 for (dctr=0;dctr<MAX_SMS_NUM_LEN;dctr++)
1736 {
1737 c=da[dctr];
1738
1739 if ((c>='0') && (c<='9'))
1740 clean_da[cctr++]=c;
1741 }
1742 }
1743
1744 len=(UBYTE)strlen(clean_da);
1745
1746 *p++=(U8)len;
1747
1748 /*
1749 * Type of number.
1750 */
1751 *p++=(toda.ton==TON_International) ? 0x91:0x81;
1752
1753 /*
1754 * Convert the address from string format to BCD format.
1755 */
1756 for (i=0;i<len;i+=2)
1757 *p++=str_to_bcd(&clean_da[i]);
1758
1759 /*
1760 * PID - Protocol Identifier
1761 */
1762 *p++=(U8)pid;
1763
1764 /*
1765 * DCS - Data Coding Scheme
1766 */
1767 *p++=(U8)dcs;
1768
1769 /*
1770 * VP - Validity Period
1771 * Not included here.
1772 */
1773
1774 /*
1775 * UDL - User Data Length
1776 */
1777 *p++=0x00;
1778
1779 /*
1780 * UD - User Data
1781 * Not included here.
1782 */
1783
1784 /*
1785 * Length calculated by seeing how far the pointer has come
1786 * from where it started.
1787 */
1788 cmgs.c_pdu=(U8)(p-cmgs.pdu);
1789
1790 bat_send(ati_bat_get_client(srcId), &cmd);
1791 }
1792
1793 #else
1794
1795 #ifndef _CONC_TESTING_
1796 #ifndef _SIMULATION_
1797 ret = sAT_PlusCMGS_Gl(srcId, da, p_toda, &msg, NULL, NULL, NULL, -1, NULL, NULL);
1798 #else
1799 ret = sAT_PlusCMGS_Gl(srcId, da, p_toda, &msg, NULL, sca, p_tosca, isReply, NULL, NULL);
1800 #endif
1801 #else
1802 ACI_MALLOC(msg_conc.data, msg.len);
1803 memcpy ( msg_conc.data, msg.data, msg.len);
1804 msg_conc.len = msg.len;
1805 #ifndef _SIMULATION_
1806 ret = sAT_PlusCMGS (srcId, da, p_toda, &msg_conc, NULL, NULL, -1);
1807 #else
1808 ret = sAT_PlusCMGS (srcId, da, p_toda, &msg_conc, sca, p_tosca, isReply);
1809 #endif
1810 #endif
1811
1812 if ( ret NEQ AT_EXCT )
1813 {
1814 cmdCmsError (CMS_ERR_NotPresent); // use aciErrDesc
1815 return (ATI_FAIL);
1816 }
1817 /*
1818 * rCI_OK will emitting +CMGS: <mr>[,<scts>]
1819 */
1820 #endif
1821
1822 return (ATI_EXCT);
1823 }
1824 }
1825
1826
1827 /*
1828 +--------------------------------------------------------------------+
1829 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1830 | STATE : code ROUTINE : atPlusCMSS |
1831 +--------------------------------------------------------------------+
1832
1833 PURPOSE : +CMSS command (send message from storage)
1834 */
1835
1836 GLOBAL T_ATI_RSLT atPlusCMSS (char *cl, UBYTE srcId)
1837 {
1838 CHAR *me="+CMSS: ",
1839 *p_da;
1840 T_ACI_RETURN ret = AT_FAIL;
1841 T_ACI_TOA toda;
1842 T_ACI_TOA *p_toda;
1843 SHORT index=-1,
1844 toda_val=0;
1845 CHAR da[MAX_SMS_NUM_LEN];
1846 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
1847
1848 TRACE_FUNCTION("atPlusCMSS()");
1849
1850 p_toda=&toda;
1851 p_da=da;
1852 /*input functionality*/
1853 da[0]='\0';
1854 cl = parse(cl,"rsr",&index,(LONG)MAX_SMS_NUM_LEN,da,&toda_val);
1855 if ( !cl OR toda_val > 0xC9 OR index > 255 OR index < 0)
1856 {
1857 cmdCmsError(CMS_ERR_OpNotAllowed);
1858 return (ATI_FAIL);
1859 }
1860 p_toda=&toda;
1861 if(toda_val EQ 0)
1862 {
1863 p_toda=NULL;
1864 }
1865 else
1866 {
1867 toda=toa_demerge(toda_val);
1868 if (toda.ton < 0 OR toda.npi < 0)
1869 {
1870 cmdCmsError(CMS_ERR_OpNotAllowed);
1871 return (ATI_FAIL);
1872 }
1873 }
1874 if(!da[0])
1875 p_da=NULL;
1876
1877 #ifdef _CONC_TESTING_
1878 ret = sAT_PlusCMSS(srcId,(UBYTE)index,p_da,p_toda);
1879 #else
1880 ret = sAT_PlusCMSS_Gl(srcId, (UBYTE)index, p_da, p_toda, NULL, NULL);
1881 #endif
1882 if (ret EQ AT_EXCT)
1883 {
1884 src_params->curAtCmd = AT_CMD_CMSS;
1885 return (ATI_EXCT);
1886 }
1887 else
1888 {
1889 cmdCmsError(CMS_ERR_NotPresent); // use aciErrDesc
1890 return (ATI_FAIL);
1891 }
1892 }
1893
1894 /*
1895 +--------------------------------------------------------------------+
1896 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1897 | STATE : code ROUTINE : atPlusCNMA |
1898 +--------------------------------------------------------------------+
1899
1900 PURPOSE : +CNMA command (new message acknowledgement)
1901 */
1902 GLOBAL T_ATI_RSLT queatPlusCNMA (char *cl, UBYTE srcId)
1903 {
1904 cmdCmsError(CMS_ERR_OpNotAllowed); /* querying CNMA not specified in 07.05 */
1905 return (ATI_FAIL);
1906 }
1907
1908 GLOBAL T_ATI_RSLT tesatPlusCNMA (char *cl, UBYTE srcId)
1909 {
1910 T_ACI_CMGF_MOD mode;
1911
1912 /*
1913 * request current mode
1914 */
1915 qAT_PlusCMGF(srcId, &mode);
1916 if (mode EQ 0)
1917 {
1918 /*
1919 * handle PDU mode: response is +CNMA: (list of supported <n>s)
1920 */
1921 io_sendConfirm ( srcId, cmdAtError ( atOk ), ATI_NORMAL_OUTPUT );
1922 return ATI_CMPL_NO_OUTPUT;
1923 }
1924 else
1925 {
1926 /*
1927 * handle Text mode: there is no response
1928 */
1929 io_sendConfirm ( srcId, cmdAtError ( atOk ), ATI_NORMAL_OUTPUT );
1930 return ATI_CMPL_NO_OUTPUT;
1931 }
1932 }
1933
1934
1935 GLOBAL T_ATI_RSLT atPlusCNMA (char *cl, UBYTE srcId)
1936 #if defined (SMS_PDU_SUPPORT)
1937 {
1938 T_ACI_CMGF_MOD mode;
1939 T_CNMI_BUFFER_ELEMENT *psMsgInCnmiBuffer = NULL;
1940
1941 if(srcId NEQ smsShrdPrm.smsSrcId)
1942 {
1943 cmdCmsError(CMS_ERR_NoCnmaAckExpect);
1944 return ( ATI_FAIL );
1945 }
1946
1947 if( waitForCnmaFromBuffer_SrcId NEQ CMD_SRC_NONE )
1948 { /* incomming +CNMA acknowledges an +CMT from CNMI buffer
1949 -> acknowledge has been sent to SMS entity */
1950 TIMERSTOP( ACI_CNMA_TIMER_HANDLE );
1951 cmd_clearFirstCnmiMessage(); /* The first message in CNMI buffer is cleared */
1952 waitForCnmaFromBuffer_SrcId = CMD_SRC_NONE;
1953 /* look for more messages in CNMI buffer for this srcId */
1954 cmd_flushCnmiBufOneByOne();
1955 return(ATI_CMPL);
1956 }
1957 /*
1958 * request current mode
1959 */
1960 qAT_PlusCMGF(srcId, &mode);
1961 if (mode EQ 0)
1962 /*
1963 * handle PDU mode
1964 */
1965 return atPlusCNMAPdu (cl,srcId);
1966 else
1967 /*
1968 * handle Text mode
1969 */
1970 return atPlusCNMAText (cl,srcId);
1971 }
1972
1973 LOCAL T_ATI_RSLT atPlusCNMAText (char *cl, UBYTE srcId)
1974 #endif /* (SMS_PDU_SUPPORT) */
1975 {
1976 TRACE_FUNCTION("atPlusCNMAText()");
1977
1978 switch (*cl)
1979 {
1980 case(0x0):
1981 switch (sAT_PlusCNMA(srcId))
1982 {
1983 case( AT_CMPL ):
1984 cmdAtError ( atOk );
1985 return (ATI_CMPL);
1986
1987 default:
1988 cmdCmsError (CMS_ERR_NotPresent); // use aciErrDesc
1989 return (ATI_FAIL);
1990 }
1991 default:
1992 cmdCmeError(CME_ERR_Unknown);
1993 return (ATI_FAIL);
1994 }
1995 }
1996
1997
1998 /*
1999 +--------------------------------------------------------------------+
2000 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
2001 | STATE : code ROUTINE : atPlusCMGW |
2002 +--------------------------------------------------------------------+
2003
2004 PURPOSE : +CMGW command (Write message to memory)
2005 */
2006
2007 GLOBAL T_ATI_RSLT tesatPlusCMGW (char *cl, UBYTE srcId)
2008 {
2009 io_sendConfirm ( srcId, cmdAtError ( atOk ), ATI_NORMAL_OUTPUT );
2010 return ATI_CMPL_NO_OUTPUT;
2011 }
2012
2013 GLOBAL T_ATI_RSLT queatPlusCMGW (char *cl, UBYTE srcId)
2014 {
2015 cmdCmsError(CMS_ERR_OpNotAllowed); /* querying CMGW not specified in 07.05 */
2016 return (ATI_FAIL);
2017 }
2018
2019
2020 GLOBAL T_ATI_RSLT atPlusCMGW (char *cl, UBYTE srcId)
2021 #if defined (SMS_PDU_SUPPORT)
2022 {
2023 T_ACI_CMGF_MOD mode;
2024
2025 /*
2026 * request current mode
2027 */
2028 qAT_PlusCMGF(srcId, &mode);
2029 if (mode EQ 0)
2030 /*
2031 * handle PDU mode
2032 */
2033 return atPlusCMGWPdu (cl, srcId);
2034 else
2035 /*
2036 * handle Text mode
2037 */
2038 return atPlusCMGWText (cl, srcId);
2039 }
2040 LOCAL T_ATI_RSLT atPlusCMGWText(char *cl, UBYTE srcId)
2041 #endif /* (SMS_PDU_SUPPORT) */
2042 {
2043 T_ACI_VP_ABS vpabs;
2044 SHORT fo,
2045 vprel,
2046 pid,
2047 dcs;
2048 CHAR* me = "+CMGW: ";
2049 T_ACI_RETURN ret;
2050 T_ACI_TOA toa;
2051 T_ACI_TOA* p_toa;
2052 CHAR txtStat[15] = {0x00};
2053 USHORT i;
2054 T_ACI_SM_DATA msg;
2055 USHORT lenMsg;
2056 static T_ACI_SMS_STAT stat;
2057
2058 static T_ACI_TOA tosca;
2059 static T_ACI_TOA *p_tosca;
2060 #ifdef _SIMULATION_
2061 CHAR *sca =subBuf;
2062 #endif /* ndef _SIMULATION_ */
2063 SHORT octet=0;
2064 static SHORT isReply;
2065 #ifdef _CONC_TESTING_
2066 T_SM_DATA_EXT msg_conc;
2067 #endif
2068 CHAR *da = daBuf;
2069
2070 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
2071
2072 TRACE_FUNCTION("atPlusCMGWText()");
2073
2074 p_toa=&toa;
2075 toda_val=0;
2076
2077 if (src_params->text_mode EQ CMD_MODE)
2078 {
2079 memset(da, 0, MAX_SMS_NUM_LEN);
2080 stat = SMS_STAT_NotPresent;
2081 /*input functionality*/
2082 *da='\0'; /*sets global destination address to empty string*/
2083 #ifndef WIN32
2084 cl = parse(cl,"srs",(LONG)MAX_SMS_NUM_LEN,
2085 da,
2086 &toda_val,
2087 (LONG)sizeof(txtStat),
2088 txtStat);
2089 if ( !cl )
2090 {
2091 cmdCmsError(CMS_ERR_OpNotAllowed);
2092 return (ATI_FAIL);
2093 }
2094 #else
2095 *sca='\0';
2096 isReply = -1;
2097 cl = parse(cl,"srssrb",(LONG)MAX_SMS_NUM_LEN,
2098 da,
2099 &toda_val,
2100 (LONG)sizeof(txtStat),
2101 txtStat,
2102 (LONG)MAX_SMS_NUM_LEN,sca,&octet,&isReply);
2103 if ( !cl )
2104 {
2105 cmdCmsError(CMS_ERR_OpNotAllowed);
2106 return (ATI_FAIL);
2107 }
2108 if(octet EQ 0)
2109 p_tosca = NULL;
2110 else
2111 {
2112 tosca=toa_demerge(octet);
2113 if (tosca.ton < 0 OR tosca.npi < 0)
2114 {
2115 cmdCmsError(CMS_ERR_OpNotAllowed);
2116 return 0;
2117 }
2118 p_tosca = &tosca;
2119 }
2120 #endif
2121 if (toda_val)
2122 {
2123 toa = toa_demerge(toda_val);
2124 if (toa.ton < 0 OR toa.npi < 0)
2125 {
2126 cmdCmsError(CMS_ERR_OpNotAllowed);
2127 return (ATI_FAIL);
2128 }
2129 }
2130 i = 0;
2131 while ( sms_stat[i].name NEQ NULL AND
2132 strcmp ( sms_stat[i].name, txtStat ) NEQ 0 )
2133 {
2134 i++;
2135 }
2136 stat = sms_stat[i].stat;
2137
2138 src_params->text_mode = TXT_MODE;
2139 return (ATI_EXCT);
2140 } /* end of if (src_params->text_mode EQ CMD_MODE) */
2141 else
2142 {
2143 src_params->text_mode = CMD_MODE;
2144 /* if the character sent is ESC, then abort command CLB 16.11.00 */
2145 if (*cl EQ 0x1B)
2146 {
2147 TRACE_EVENT("Send message command cancelled by user");
2148
2149 return ATI_CMPL_NO_OUTPUT;
2150 }
2151
2152 if ( toda_val EQ 0 )
2153 p_toa = NULL;
2154 else
2155 {
2156 toa = toa_demerge ( toda_val );
2157 p_toa = &toa;
2158 }
2159
2160 qAT_PlusCSMP ( srcId, &fo, &vprel, &vpabs, NULL, &pid, &dcs );
2161
2162 srcId_cb = srcId;
2163 utl_smDtaFromTe ( (UBYTE*)cl,
2164 (USHORT)strlen(cl),
2165 (UBYTE*)msg.data,
2166 &lenMsg,
2167 (UBYTE)fo,
2168 (UBYTE)dcs );
2169
2170 msg.len = (UBYTE)lenMsg;
2171
2172 #ifndef _CONC_TESTING_
2173 #ifndef _SIMULATION_
2174 ret = sAT_PlusCMGW_Gl( srcId,
2175 CMGW_IDX_FREE_ENTRY,
2176 da, p_toa, stat, NOT_PRESENT_8BIT,
2177 &msg, NULL, NULL, NULL, -1,
2178 NULL, NULL);
2179 #else
2180 ret = sAT_PlusCMGW_Gl( srcId,
2181 CMGW_IDX_FREE_ENTRY,
2182 da, p_toa, stat, NOT_PRESENT_8BIT,
2183 &msg, NULL, sca, p_tosca, isReply,
2184 NULL, NULL);
2185 #endif
2186 #else
2187 ACI_MALLOC(msg_conc.data, msg.len);
2188 memcpy ( msg_conc.data, msg.data, msg.len);
2189 msg_conc.len = msg.len;
2190 #ifndef _SIMULATION_
2191 ret = sAT_PlusCMGW ( srcId,
2192 CMGW_IDX_FREE_ENTRY,
2193 da, p_toa, stat, NOT_PRESENT_8BIT,
2194 &msg_conc, NULL, NULL, -1 );
2195 #else
2196 ret = sAT_PlusCMGW ( srcId,
2197 CMGW_IDX_FREE_ENTRY,
2198 da, p_toa, stat, NOT_PRESENT_8BIT,
2199 &msg_conc, sca, p_tosca, isReply );
2200 #endif
2201 #endif
2202
2203 if ( ret NEQ AT_EXCT )
2204 {
2205 cmdCmsError (CMS_ERR_NotPresent); // use aciErrDesc
2206 return (ATI_FAIL);
2207 }
2208 /*
2209 * rCI_OK will emitting +CMGW: <index>
2210 */
2211 return (ATI_EXCT);
2212 }
2213 }
2214
2215
2216 /*
2217 +--------------------------------------------------------------------+
2218 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
2219 | STATE : code ROUTINE : atPlusCMGD |
2220 +--------------------------------------------------------------------+
2221
2222 PURPOSE : +CMGD command (delete message from storage)
2223 */
2224
2225 GLOBAL T_ATI_RSLT setatPlusCMGD (char *cl, UBYTE srcId)
2226 {
2227 T_ACI_RETURN ret = ATI_FAIL;
2228 SHORT index=-1;
2229 UBYTE status = CMGD_DEL_INDEX;
2230 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
2231
2232 src_params->curAtCmd = AT_CMD_CMGD;
2233
2234 /*input functionality*/
2235 if(!cl OR !*cl)
2236 {
2237 cmdCmsError(CMS_ERR_OpNotAllowed);
2238 return ret;
2239 }
2240
2241 cl=parse(cl,"rr",&index,&status);
2242 if ( !cl OR (index > 255) OR (index < 0) OR
2243 ((status < CMGD_DEL_INDEX) OR (status > CMGD_DEL_ALL)))
2244 {
2245 cmdCmsError(CMS_ERR_OpNotAllowed);
2246 return ret;
2247 }
2248
2249 #ifdef FF_ATI_BAT
2250 {
2251 T_BAT_cmd_send cmd;
2252 T_BAT_cmd_set_plus_cmgd my_bat_set_plus_cmgd;
2253
2254 TRACE_FUNCTION("setatPlusCMGD() calls bat_send() <=== as APPLICATION");
2255
2256 memset(&my_bat_set_plus_cmgd, 0, sizeof(my_bat_set_plus_cmgd));
2257 cmd.ctrl_params = BAT_CMD_SET_PLUS_CMGD;
2258 cmd.params.ptr_set_plus_cmgd = &my_bat_set_plus_cmgd;
2259
2260 my_bat_set_plus_cmgd.index = (U8)index;
2261 my_bat_set_plus_cmgd.status = status;
2262
2263 bat_send(ati_bat_get_client(srcId), &cmd);
2264
2265 return ATI_EXCT; /* executing, because response is passed by callback function */
2266 }
2267 #else /* OLD FUNCTION BODY */
2268
2269 TRACE_FUNCTION("setatPlusCMGD()");
2270 /*-----------------------------------------------------------------------
2271 * Del flag is greater than zero, set index as Zero so that SMS module
2272 * starts searching for records satisfying the status from first record
2273 *-----------------------------------------------------------------------
2274 */
2275 if ( status > CMGD_DEL_INDEX )
2276 {
2277 index = 0;
2278 }
2279 #ifdef _CONC_TESTING_
2280 ret = sAT_PlusCMGD(srcId,(UBYTE)index, status);
2281 #else
2282 ret = sAT_PlusCMGD_Gl(srcId, (UBYTE)index, status, NULL, NULL);
2283 #endif
2284
2285 if (ret EQ AT_EXCT)
2286 {
2287 return (ATI_EXCT);
2288 }
2289 else
2290 {
2291 cmdCmsError(CMS_ERR_NotPresent); // use aciErrDesc
2292 return (ATI_FAIL);
2293 }
2294
2295 #endif /* no FF_ATI_BAT*/
2296 }
2297
2298 /*
2299 +--------------------------------------------------------------------+
2300 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
2301 | STATE : code ROUTINE : atPlusCMGC |
2302 +--------------------------------------------------------------------+
2303
2304 PURPOSE : +CMGC command (Send SMS command)
2305 */
2306
2307 GLOBAL T_ATI_RSLT tesatPlusCMGC (char *cl, UBYTE srcId)
2308 {
2309 io_sendConfirm ( srcId, cmdAtError ( atOk ), ATI_NORMAL_OUTPUT );
2310 return ATI_CMPL_NO_OUTPUT;
2311 }
2312
2313 GLOBAL T_ATI_RSLT queatPlusCMGC (char *cl, UBYTE srcId)
2314 {
2315 cmdCmsError(CMS_ERR_OpNotAllowed); /* querying CMGC not specified in 07.05 */
2316 return (ATI_FAIL);
2317 }
2318
2319 GLOBAL T_ATI_RSLT atPlusCMGC (char *cl, UBYTE srcId)
2320 #if defined (SMS_PDU_SUPPORT)
2321 {
2322 T_ACI_CMGF_MOD mode;
2323
2324 /*
2325 * request current mode
2326 */
2327 qAT_PlusCMGF(srcId, &mode);
2328 if (mode EQ 0)
2329 /*
2330 * handle PDU mode
2331 */
2332 return atPlusCMGCPdu (cl, srcId);
2333 else
2334 /*
2335 * handle Text mode
2336 */
2337 return atPlusCMGCText (cl, srcId);
2338 }
2339
2340 LOCAL T_ATI_RSLT atPlusCMGCText(char *cl, UBYTE srcId)
2341 #endif /* (SMS_PDU_SUPPORT) */
2342 {
2343 /* char buf[80]; */
2344 T_ACI_RETURN ret = AT_FAIL;
2345 T_ACI_TOA toa;
2346 T_ACI_TOA* p_toa;
2347 T_ACI_CMD_DATA cmd;
2348 USHORT lenCmd;
2349 CHAR* da = daBuf;
2350
2351 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
2352
2353 TRACE_FUNCTION("atPlusCMGCText()");
2354 p_toa=&toa;
2355 if (src_params->text_mode EQ CMD_MODE)
2356 {
2357 memset(da, 0, MAX_SMS_NUM_LEN);
2358 fo=-1;
2359 ct=-1;
2360 pid=-1;
2361 mn=-1;
2362 toda_val=0;
2363 /*input functionality*/
2364 da[0]='\0';
2365 cl = parse(cl,"rrrrsr",&fo,&ct,&pid,&mn,(LONG)MAX_SMS_NUM_LEN,da,&toda_val);
2366
2367 if ( !cl OR fo > 255 OR ct > 255 OR
2368 pid > 255 OR mn > 255 OR toda_val > 0xC9 OR da[0] EQ '\0')
2369 {
2370 cmdCmsError(CMS_ERR_OpNotAllowed);
2371 return (ATI_FAIL);
2372 }
2373 if(toda_val)
2374 {
2375 toa = toa_demerge(toda_val);
2376 if (toa.ton < 0 OR toa.npi < 0)
2377 {
2378 cmdCmsError(CMS_ERR_OpNotAllowed);
2379 return (ATI_FAIL);
2380 }
2381 }
2382
2383 src_params->text_mode = TXT_MODE;
2384 return (ATI_EXCT);
2385 } /* end of if (src_params->text_mode EQ CMD_MODE) */
2386 else
2387 {
2388 src_params->text_mode = CMD_MODE;
2389 p_toa=&toa;
2390 if(toda_val EQ 0)
2391 {
2392 p_toa = NULL;
2393 }
2394 else
2395 {
2396 toa = toa_demerge(toda_val);
2397 }
2398 if (!(check_str(cl,"0123456789ABCDEF")))
2399 {
2400 cmdCmsError(CMS_ERR_OpNotAllowed);
2401 return (ATI_FAIL);
2402 }
2403 utl_hexToGsm ( (UBYTE*)cl,
2404 (USHORT)strlen(cl),
2405 (UBYTE*)cmd.data,
2406 &lenCmd,
2407 GSM_ALPHA_Def,
2408 CSCS_ALPHA_8_Bit);
2409 cmd.len = (UBYTE)lenCmd;
2410
2411 #ifndef _CONC_TESTING_
2412 ret = sAT_PlusCMGC_Gl (srcId,fo,ct,pid,mn,da,p_toa,&cmd,NULL);
2413 #else
2414 ret= sAT_PlusCMGC(srcId,fo,ct,pid,mn,da,p_toa,&cmd);
2415 #endif
2416
2417 if ( ret NEQ AT_EXCT )
2418 {
2419 cmdCmsError (CMS_ERR_NotPresent); // use aciErrDesc
2420 return (ATI_FAIL);
2421 }
2422 /*
2423 * rCI_OK will emitting +CMGC: <mr>[,<scts>]
2424 */
2425 return (ATI_EXCT);
2426 }
2427 }
2428
2429 /*
2430 +--------------------------------------------------------------------+
2431 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
2432 | STATE : code ROUTINE : atPlusCMGL |
2433 +--------------------------------------------------------------------+
2434
2435 PURPOSE : +CMGL command (List Messages)
2436 */
2437
2438 GLOBAL T_ATI_RSLT queatPlusCMGL (char *cl, UBYTE srcId)
2439 {
2440 TRACE_FUNCTION("queatPlusCMGL()");
2441 cmdCmsError ( CMS_ERR_OpNotAllowed );
2442 return (ATI_FAIL);
2443 }
2444
2445 GLOBAL T_ATI_RSLT tesatPlusCMGL (char *cl, UBYTE srcId)
2446 {
2447 #ifdef SMS_PDU_SUPPORT
2448 T_ACI_CMGF_MOD mode;
2449 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
2450
2451 TRACE_FUNCTION("tesatPlusCMGL()");
2452 /*
2453 * request current mode
2454 */
2455 qAT_PlusCMGF(srcId, &mode);
2456 if (mode EQ 0)
2457 /*
2458 * handle PDU mode
2459 */
2460 io_sendMessage(srcId, "+CMGL: (0,1,2,3,4)", ATI_NORMAL_OUTPUT);
2461 else
2462 /*
2463 * handle Text mode
2464 */
2465 #endif
2466 io_sendMessage(srcId, "+CMGL: (\"REC UNREAD\",\"REC READ\",\"STO UNSENT\",\"STO SENT\",\"ALL\")", ATI_NORMAL_OUTPUT);
2467
2468 return (ATI_CMPL);
2469 }
2470
2471 GLOBAL T_ATI_RSLT atPlusCMGL (char *cl, UBYTE srcId)
2472 {
2473 #ifndef FF_ATI_BAT
2474 T_ACI_RETURN ret;
2475 #endif
2476
2477 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
2478
2479 #ifdef SMS_PDU_SUPPORT
2480 T_ACI_CMGF_MOD mode;
2481 #endif
2482 CHAR txtStat[15];
2483 USHORT i;
2484
2485 TRACE_FUNCTION("atPlusCMGL()");
2486
2487
2488 if (*cl EQ '\0')
2489 {
2490 cmglStat = SMS_STAT_NotPresent;
2491 #ifdef WIN32
2492 smsReadMode = SMS_READ_Normal;
2493 #endif
2494 }
2495 else
2496 {
2497 /*
2498 * Request of a list of stored SMS messages
2499 * Parameter stat is optional
2500 */
2501 #ifdef SMS_PDU_SUPPORT
2502 /*
2503 * request current mode
2504 */
2505 qAT_PlusCMGF(srcId, &mode);
2506 if (mode EQ 0)
2507 {
2508 #ifndef WIN32
2509 /*
2510 * On the target is the definition according GSM 7.05 CMGL=[stat]
2511 */
2512 cmglStat = SMS_STAT_All;
2513 cl = parse (cl, "d", &cmglStat);
2514 if ( !cl OR cmglStat < SMS_STAT_RecUnread OR cmglStat > SMS_STAT_All)
2515 {
2516 cmdCmsError ( CMS_ERR_OpNotAllowed );
2517 return NULL;
2518 }
2519 #else
2520 /*
2521 * Under Windows the definition is CMGL=[stat],[preview]
2522 * to test the capabilities of the functional interface
2523 */
2524 cl = parse (cl, "dd", &cmglStat, &smsReadMode );
2525 if ( !cl OR ((cmglStat < SMS_STAT_RecUnread OR cmglStat > SMS_STAT_All)
2526 AND smsReadMode EQ SMS_READ_NotPresent))
2527 {
2528 cmdCmsError ( CMS_ERR_OpNotAllowed );
2529 return (ATI_FAIL);
2530 }
2531 #endif
2532 }
2533 else
2534 #endif
2535 {
2536 #ifndef WIN32
2537 /*
2538 * On the target is the definition according GSM 7.05 CMGL=[stat]
2539 */
2540 cl = parse (cl, "s", (LONG)sizeof(txtStat), txtStat);
2541 if ( !cl OR txtStat[0] EQ '\0')
2542 {
2543 cmdCmsError ( CMS_ERR_OpNotAllowed );
2544 return (ATI_FAIL);
2545 }
2546 #else
2547 /*
2548 * Under Windows the definition is CMGL=[stat],[preview]
2549 * to test the capabilities of the functional interface
2550 */
2551 cl = parse (cl, "sd", (LONG)sizeof(txtStat), txtStat, &smsReadMode );
2552 if ( !cl OR (txtStat[0] EQ '\0' AND smsReadMode EQ SMS_READ_NotPresent))
2553 {
2554 cmdCmsError ( CMS_ERR_OpNotAllowed );
2555 return (ATI_FAIL);
2556 }
2557 if (txtStat[0] EQ '\0')
2558 strcpy (txtStat, sms_stat[4].name); /* ALL as default */
2559 #endif
2560 i = 0;
2561 while ( sms_stat[i].name NEQ NULL AND
2562 strcmp ( sms_stat[i].name, txtStat ) NEQ 0 )
2563 i++;
2564
2565 if ( sms_stat[i].name EQ NULL )
2566 {
2567 cmdCmsError ( CMS_ERR_OpNotAllowed );
2568 return (ATI_FAIL);
2569 }
2570
2571 cmglStat = sms_stat[i].stat;
2572 }
2573 }
2574
2575 #ifdef FF_ATI_BAT
2576
2577 {
2578 T_BAT_cmd_send cmd;
2579 T_BAT_cmd_set_plus_cmgl cmgl;
2580
2581 cmd.ctrl_params=BAT_CMD_SET_PLUS_CMGL;
2582 cmd.params.ptr_set_plus_cmgl=&cmgl;
2583
2584 /*
2585 * T_ACI_SMS_STAT and T_BAT_plus_cmgl_stat are not quite
2586 * identical - the ACI version has the extra value
2587 * SMS_STAT_Invalid.
2588 */
2589 if (cmglStat EQ SMS_STAT_Invalid)
2590 cmgl.stat=BAT_CMGL_STAT_NOT_PRESENT;
2591 else
2592 cmgl.stat=(T_BAT_plus_cmgl_stat)cmglStat;
2593
2594 bat_send(ati_bat_get_client(srcId),&cmd);
2595
2596 src_params->curAtCmd=AT_CMD_CMGL;
2597 return(ATI_EXCT);
2598 }
2599
2600 #else
2601
2602 /*
2603 * Request the first five SMS messages
2604 */
2605 #ifndef WIN32
2606 ret = sAT_PlusCMGL ( srcId, cmglStat, 0, SMS_READ_Normal );
2607 #else
2608 ret = sAT_PlusCMGL ( srcId, cmglStat, 0, smsReadMode );
2609 #endif
2610
2611 if ( ret EQ AT_EXCT )
2612 {
2613 src_params->curAtCmd = AT_CMD_CMGL;
2614 return (ATI_EXCT);
2615 }
2616 else
2617 {
2618 cmdCmsError ( CMS_ERR_NotPresent ); // use aciErrDesc
2619 return (ATI_FAIL);
2620 }
2621
2622 #endif /*FF_ATI_BAT*/
2623 }
2624
2625 /*
2626 +--------------------------------------------------------------------+
2627 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
2628 | STATE : code ROUTINE : atPlusCNMI |
2629 +--------------------------------------------------------------------+
2630
2631 PURPOSE : +CNMI command (new messgae indication settings )
2632 */
2633
2634 GLOBAL T_ATI_RSLT atPlusCNMI (char *cl, UBYTE srcId)
2635 {
2636 T_ACI_CNMI_MT mt = CNMI_MT_NotPresent;
2637 T_ACI_CNMI_BM bm = CNMI_BM_NotPresent;
2638 T_ACI_CNMI_DS ds = CNMI_DS_NotPresent;
2639 T_ACI_CNMI_MOD mode = CNMI_MOD_NotPresent;
2640 T_ACI_CNMI_BFR bfr = CNMI_BFR_NotPresent;
2641 T_ACI_RETURN ret = AT_FAIL;
2642
2643 TRACE_FUNCTION("atPlusCNMI()");
2644
2645 /* input functionality */
2646 cl = parse ( cl, "ddddd", &mode, &mt, &bm, &ds, &bfr );
2647
2648 if ( !cl OR
2649 mode < CNMI_MOD_NotPresent OR
2650 mode > CNMI_MOD_BufferAndFlush OR
2651 bfr < CNMI_BFR_NotPresent OR
2652 bfr > CNMI_BFR_Clear OR
2653 ( bfr EQ CNMI_BFR_Flush AND
2654 strlen ( cl ) > 0 ) )
2655 {
2656 io_sendConfirm ( srcId, cmdCmsError ( CMS_ERR_OpNotAllowed ), ATI_ERROR_OUTPUT );
2657 cmdErrStr = NULL;
2658 return ATI_FAIL_NO_OUTPUT;
2659 }
2660
2661 ret = sAT_PlusCNMI ( srcId, mt, bm, ds );
2662 if ( (ret EQ AT_FAIL) OR (ret EQ AT_BUSY) )
2663 {
2664 io_sendConfirm ( srcId, cmdCmsError ( CMS_ERR_NotPresent ), ATI_ERROR_OUTPUT );
2665 cmdErrStr = NULL;
2666 return ATI_FAIL_NO_OUTPUT;
2667 }
2668
2669 /*
2670 *----------------------Issue 25033--------------------------------
2671 * The source ID issuing the CNMI command is stored and henceforth
2672 * all the unsolicited SMS indications are sent to this source
2673 *-----------------------------------------------------------------
2674 */
2675 if(srcId NEQ CMD_SRC_LCL)
2676 smsShrdPrm.smsSrcId = srcId;
2677
2678 if ( bfr NEQ CNMI_BFR_NotPresent )
2679 at.CNMI_bfr = ( UBYTE ) bfr;
2680
2681 if ( mode NEQ CNMI_MOD_NotPresent )
2682 at.CNMI_mode = ( UBYTE ) mode;
2683
2684 if (mode EQ CNMI_MOD_DiscardOrForward OR /* 07.05:3.4.1: check for <mode> 1...3 */
2685 mode EQ CNMI_MOD_BufferAndFlush)
2686 {
2687 if ( at.CNMI_bfr EQ CNMI_BFR_Flush )
2688 {
2689 io_sendConfirm ( srcId, cmdAtError ( atOk ), ATI_NORMAL_OUTPUT );
2690 cmdErrStr = NULL;
2691
2692 if( smsShrdPrm.CSMSservice NEQ CSMS_SERV_GsmPh2Plus )
2693 {
2694 cmd_flushCnmiBuf();
2695 }
2696 else
2697 {
2698 cmd_flushCnmiBufOneByOne();
2699 }
2700 return ATI_CMPL_NO_OUTPUT;
2701 }
2702 else
2703 {
2704 cmd_clearCnmiBuf ();
2705 }
2706 }
2707
2708 io_sendConfirm ( srcId, cmdAtError ( atOk ), ATI_NORMAL_OUTPUT );
2709 cmdErrStr = NULL;
2710
2711 return ATI_CMPL_NO_OUTPUT;
2712 }
2713
2714 GLOBAL T_ATI_RSLT tesatPlusCNMI (char *cl, UBYTE srcId)
2715 {
2716 /* query parameter ranges */
2717 io_sendMessage ( srcId, "+CNMI: (0-2),(0-3),(0,2),(0,1),(0,1)", ATI_NORMAL_OUTPUT );
2718 io_sendConfirm ( srcId, cmdAtError ( atOk ), ATI_NORMAL_OUTPUT );
2719 cmdErrStr = NULL;
2720
2721 return ATI_CMPL_NO_OUTPUT;
2722 }
2723
2724 GLOBAL T_ATI_RSLT queatPlusCNMI (char *cl, UBYTE srcId)
2725 {
2726 char* me = "+CNMI: ";
2727 T_ACI_CNMI_MT mt = CNMI_MT_NotPresent;
2728 T_ACI_CNMI_BM bm = CNMI_BM_NotPresent;
2729 T_ACI_CNMI_DS ds = CNMI_DS_NotPresent;
2730 T_ACI_CNMI_MOD mode = CNMI_MOD_NotPresent;
2731 T_ACI_CNMI_BFR bfr = CNMI_BFR_NotPresent;
2732
2733 if ( qAT_PlusCNMI ( srcId, &mt, &bm, &ds ) EQ AT_CMPL )
2734 {
2735 sprintf ( g_sa,"%s%d,%d,%d,%d,%d", me, at.CNMI_mode,
2736 mt, bm, ds, at.CNMI_bfr );
2737 io_sendMessage ( srcId, g_sa, ATI_NORMAL_OUTPUT );
2738 }
2739 else
2740 {
2741 io_sendConfirm ( srcId, cmdCmsError ( CMS_ERR_NotPresent ), ATI_ERROR_OUTPUT );
2742 cmdErrStr = NULL;
2743 return ATI_FAIL_NO_OUTPUT;
2744 }
2745
2746 io_sendConfirm ( srcId, cmdAtError ( atOk ), ATI_NORMAL_OUTPUT );
2747 cmdErrStr = NULL;
2748 return ATI_CMPL_NO_OUTPUT;
2749 }
2750
2751
2752 /*
2753 +--------------------------------------------------------------------+
2754 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
2755 | STATE : code ROUTINE : setatPercentCPRSM |
2756 +--------------------------------------------------------------------+
2757
2758 PURPOSE : %CPRSM set command
2759 set the receiving of SMS to
2760 1 -- Pause or
2761 2 -- Resume
2762
2763 */
2764
2765 GLOBAL T_ATI_RSLT setatPercentCPRSM (char *cl, UBYTE srcId)
2766 {
2767 T_ACI_RETURN ret = AT_FAIL;
2768 T_ACI_CPRSM_MOD mode = CPRSM_MOD_NotPresent;
2769 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
2770
2771 src_params->curAtCmd = AT_CMD_CPRSM;
2772
2773 /* parse command */
2774 cl = parse (cl, "d", &mode);
2775
2776 /* check whether parsing has been successful */
2777 if (!cl)
2778 {
2779 /* undefined value for mode */
2780 TRACE_EVENT("+CPRSM ERROR: parse cmd failed!");
2781 cmdCmsError(CMS_ERR_OpNotAllowed);
2782 return ATI_FAIL;
2783 }
2784
2785 #ifdef FF_ATI_BAT
2786 {
2787 T_BAT_cmd_send cmd;
2788 T_BAT_cmd_set_percent_cprsm my_bat_set_percent_cprsm;
2789
2790 TRACE_FUNCTION("setatPercentCPRSM() calls bat_send() <=== as APPLICATION");
2791
2792 memset(&my_bat_set_percent_cprsm, 0, sizeof(my_bat_set_percent_cprsm));
2793 cmd.ctrl_params = BAT_CMD_SET_PERCENT_CPRSM;
2794 cmd.params.ptr_set_percent_cprsm = &my_bat_set_percent_cprsm;
2795
2796 my_bat_set_percent_cprsm.mode = mode;
2797
2798 bat_send(ati_bat_get_client(srcId), &cmd);
2799
2800 return ATI_EXCT; /* executing, because response is passed by callback function */
2801 }
2802 #else /* OLD FUNCTION BODY */
2803
2804 TRACE_FUNCTION("setatPercentCPRSM()");
2805
2806 switch (mode) /* check which mode has to be set and set it */
2807 {
2808 case(CPRSM_MOD_Resume):
2809 case(CPRSM_MOD_Pause):
2810 {
2811 /* AT interface function called */
2812 ret = sAT_PercentCPRSM(srcId, mode);
2813 break;
2814 }
2815 default:
2816 /* undefined value for mode */
2817 TRACE_EVENT_P1("+CPRSM ERROR: undefined value for mode: %d", mode);
2818 cmdCmsError(CMS_ERR_OpNotSup);
2819 return ATI_FAIL;
2820 }
2821
2822 /* check result */
2823 switch (ret)
2824 {
2825 case (AT_CMPL):
2826 /* operation successfully completed */
2827 break;
2828 case (AT_EXCT):
2829 /* operation still executing */
2830 src_params->curAtCmd = AT_CMD_COPS;
2831 break;
2832 default:
2833 /* unknown result type */
2834 TRACE_EVENT_P1("+CPRSM ERROR: undefined result: %d", ret);
2835 cmdCmsError(CMS_ERR_UnknownErr); /*Command failed*/
2836 return ATI_FAIL;
2837 }
2838
2839 /* map error to ATI type and return */
2840 return (map_aci_2_ati_rslt(ret));
2841
2842 #endif /* no FF_ATI_BAT*/
2843 }
2844
2845 /*
2846 +--------------------------------------------------------------------+
2847 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
2848 | STATE : code ROUTINE : queatPercentCPRSM |
2849 +--------------------------------------------------------------------+
2850
2851 PURPOSE : %CPRSM query command
2852 request the current state of the pause flag for receiving SMS
2853 */
2854
2855 GLOBAL T_ATI_RSLT queatPercentCPRSM (char *cl, UBYTE srcId)
2856 {
2857 T_ACI_RETURN ret = ATI_FAIL;
2858 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
2859
2860 TRACE_FUNCTION("queatPercentCPRSM()");
2861
2862 ret = qAT_PercentCPRSM( srcId );
2863
2864
2865 if (ret EQ AT_EXCT)
2866 {
2867 src_params->curAtCmd = AT_CMD_CPRSM;
2868 return (ATI_EXCT);
2869 }
2870 else
2871 {
2872 cmdCmsError(CMS_ERR_NotPresent); // use aciErrDesc
2873 return (ATI_FAIL);
2874 }
2875 }
2876
2877
2878 /*
2879 +--------------------------------------------------------------------+
2880 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
2881 | STATE : code ROUTINE : cmd_clearCnmiBuf |
2882 +--------------------------------------------------------------------+
2883
2884 PURPOSE : This function clears the buffer for storing new message
2885 indications while the serial interface is reserved for
2886 data transmission.
2887 */
2888 GLOBAL void cmd_clearCnmiBuf (void)
2889 {
2890 UBYTE i;
2891
2892 for ( i = 0; i < CNMI_BUF_SIZE; i++ )
2893 cnmiBuf.sCnmiElement[i].type = CNMI_NONE;
2894
2895 cnmiBuf.next = 0;
2896 }
2897
2898 /*
2899 +--------------------------------------------------------------------+
2900 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
2901 | STATE : code ROUTINE : cmd_flushCnmiBuf |
2902 +--------------------------------------------------------------------+
2903
2904 PURPOSE : This function flushes the buffer for storing new message
2905 indications while the serial interface is released from
2906 data transmission.
2907 */
2908 GLOBAL void cmd_flushCnmiBuf (void)
2909 {
2910 UBYTE i = cnmiBuf.next;
2911 UBYTE entries_read = 0;
2912
2913 TRACE_FUNCTION("cmd_flushCnmiBuf");
2914
2915 if ( cnmiBuf.sCnmiElement[0].type EQ CNMI_NONE )
2916 {
2917 entries_read = CNMI_BUF_SIZE; /* no need to read anything at all */
2918 //moreEntries = FALSE;
2919 }
2920 else if ( cnmiBuf.next EQ CNMI_BUF_SIZE OR
2921 cnmiBuf.sCnmiElement[cnmiBuf.next].type EQ CNMI_NONE )
2922 {
2923 i = 0;
2924 }
2925
2926 cnmiFlushInProgress = TRUE;
2927
2928 while ( entries_read < CNMI_BUF_SIZE /*moreEntries*/ )
2929 {
2930 if (smsShrdPrm.pDecMsg)
2931 { /* clear p_sm buffer */
2932 ACI_MFREE(smsShrdPrm.pDecMsg);
2933 smsShrdPrm.pDecMsg = NULL;
2934 }
2935
2936 switch ( cnmiBuf.sCnmiElement[i].type )
2937 {
2938
2939 case ( CNMI_CMT ):
2940 srcId_cb = smsShrdPrm.smsSrcId;
2941 rCI_PlusCMT ( &cnmiBuf.sCnmiElement[i].indct.cmt );
2942 break;
2943
2944 case ( CNMI_CMTI ):
2945 srcId_cb = smsShrdPrm.smsSrcId;
2946 rCI_PlusCMTI ( cnmiBuf.sCnmiElement[i].indct.cmti.mem,
2947 cnmiBuf.sCnmiElement[i].indct.cmti.index );
2948 break;
2949
2950 case ( CNMI_CBM ):
2951 srcId_cb = smsShrdPrm.smsSrcId;
2952 rCI_PlusCBM ( &cnmiBuf.sCnmiElement[i].indct.cbm );
2953 break;
2954
2955 case ( CNMI_CDS ):
2956 srcId_cb = smsShrdPrm.smsSrcId;
2957 rCI_PlusCDS ( &cnmiBuf.sCnmiElement[i].indct.cds );
2958 break;
2959
2960 default:
2961 // moreEntries = FALSE;
2962 break;
2963 }
2964
2965 cnmiBuf.sCnmiElement[i].type = CNMI_NONE;
2966 i++;
2967 entries_read++;
2968
2969 if ( i EQ CNMI_BUF_SIZE )
2970 i = 0;
2971 }
2972
2973 cnmiFlushInProgress = FALSE;
2974 cnmiBuf.next = 0;
2975 }
2976
2977 /*
2978 +--------------------------------------------------------------------------+
2979 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
2980 | STATE : code ROUTINE : cmd_flushCnmiBufOneByOne |
2981 +--------------------------------------------------------------------------+
2982
2983 PURPOSE : This function flushes the CNMI buffer in case of Phase2+ mode,
2984 while the serial interface is released from
2985 data transmission or an +CNMI <bfr>==Flush is requested.
2986 */
2987
2988 GLOBAL void cmd_flushCnmiBufOneByOne(void)
2989 { /* flushing +CMT one by one, because acknowledge is necessary */
2990 T_CNMI_BUFFER_ELEMENT* psMsgInCnmiBuffer = NULL;
2991 UINT16 uiCnmiMsgCounter = 0;
2992 BOOL bEndLoop = FALSE;
2993
2994 for( uiCnmiMsgCounter=0;
2995 (uiCnmiMsgCounter<cmd_getNumberOfCnmiEntrys()) &&
2996 (waitForCnmaFromBuffer_SrcId EQ CMD_SRC_NONE);
2997 uiCnmiMsgCounter++ )
2998 { /* there are entrys in the CNMI buffer --> read it */
2999 psMsgInCnmiBuffer = cmd_getCnmiMessage(uiCnmiMsgCounter); /* FIFO */
3000
3001 if( psMsgInCnmiBuffer EQ NULL )
3002 {
3003 TRACE_EVENT("ati_switch_mode() : Error at CNMI-buffer handling: NULL-pointer access!!");
3004 return;
3005 }
3006
3007 cnmiFlushInProgress = TRUE; /* needed for the rCI_...commands */
3008
3009 if (smsShrdPrm.pDecMsg)
3010 { /* clear p_sm buffer */
3011 ACI_MFREE(smsShrdPrm.pDecMsg);
3012 smsShrdPrm.pDecMsg = NULL;
3013 }
3014
3015 switch ( psMsgInCnmiBuffer->type )
3016 {
3017 case ( CNMI_CMTI ) :
3018 srcId_cb = smsShrdPrm.smsSrcId;
3019 rCI_PlusCMTI ( psMsgInCnmiBuffer->indct.cmti.mem, psMsgInCnmiBuffer->indct.cmti.index );
3020 cmd_clearCnmiMessage(uiCnmiMsgCounter);
3021 uiCnmiMsgCounter--;
3022 break;
3023
3024 case ( CNMI_CBM ) :
3025 srcId_cb = smsShrdPrm.smsSrcId;
3026 rCI_PlusCBM ( &psMsgInCnmiBuffer->indct.cbm );
3027 cmd_clearCnmiMessage(uiCnmiMsgCounter);
3028 uiCnmiMsgCounter--;
3029 break;
3030
3031 case ( CNMI_CDS ) :
3032 srcId_cb = smsShrdPrm.smsSrcId;
3033 rCI_PlusCDS ( &psMsgInCnmiBuffer->indct.cds );
3034 cmd_clearCnmiMessage(uiCnmiMsgCounter);
3035 uiCnmiMsgCounter--;
3036 break;
3037
3038 /* special handling for +CMT --> acknowledge needed */
3039 case ( CNMI_CMT ) :
3040 {
3041 srcId_cb = smsShrdPrm.smsSrcId;
3042 rCI_PlusCMT ( &psMsgInCnmiBuffer->indct.cmt );
3043 TIMERSTART(ACI_CNMA_TIMER_VALUE, ACI_CNMA_TIMER_HANDLE);
3044 waitForCnmaFromBuffer_SrcId = smsShrdPrm.smsSrcId;
3045 break;
3046 }
3047 default:
3048 TRACE_EVENT("ati_switch_mode() : wrong CNMI-buffer handling: wrong Msg. type");
3049 }
3050 }
3051 cnmiFlushInProgress = FALSE;
3052 }
3053
3054 /*
3055 +--------------------------------------------------------------------+
3056 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
3057 | STATE : code ROUTINE : cmd_addCnmiNtry |
3058 +--------------------------------------------------------------------+
3059
3060 PURPOSE : This function add a new entry to the buffer for storing
3061 new message indications while the serial interface is
3062 reserved for data transmission.
3063 */
3064 GLOBAL void cmd_addCnmiNtry ( UBYTE type, T_CNMI_IND* newInd )
3065 {
3066 TRACE_FUNCTION("cmd_addCnmiNtry");
3067
3068 if ( type > CNMI_CDS OR type < CNMI_CMT )
3069 return;
3070
3071 if ( cnmiBuf.next EQ CNMI_BUF_SIZE )
3072 {
3073 cnmiBuf.next = 0;
3074 }
3075
3076 switch ( type )
3077 {
3078 case ( CNMI_CMT ):
3079 cnmiBuf.sCnmiElement[cnmiBuf.next].indct.cmt = newInd -> cmt;
3080 break;
3081
3082 case ( CNMI_CMTI ):
3083 cnmiBuf.sCnmiElement[cnmiBuf.next].indct.cmti = newInd -> cmti;
3084 break;
3085
3086
3087 case ( CNMI_CBM ):
3088 cnmiBuf.sCnmiElement[cnmiBuf.next].indct.cbm = newInd -> cbm;
3089 break;
3090
3091 case ( CNMI_CDS ):
3092 cnmiBuf.sCnmiElement[cnmiBuf.next].indct.cds = newInd -> cds;
3093 break;
3094 }
3095
3096 cnmiBuf.sCnmiElement[cnmiBuf.next].type = type;
3097 cnmiBuf.next++;
3098 }
3099
3100
3101 /*
3102 +-----------------------------------------------------------------------+
3103 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
3104 | STATE : code ROUTINE : getNumberOfCnmiEntrys |
3105 +-----------------------------------------------------------------------+
3106
3107 PURPOSE : This function is the responsible to get the count
3108 of CNMI entrys in the CNMI buffer.
3109 */
3110 GLOBAL UINT16 cmd_getNumberOfCnmiEntrys(void)
3111 {
3112 return cnmiBuf.next;
3113 }
3114
3115
3116 /*
3117 +-----------------------------------------------------------------------+
3118 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
3119 | STATE : code ROUTINE : getCnmiMessage |
3120 +-----------------------------------------------------------------------+
3121
3122 PURPOSE : This function is the responsible to get an entire Msg.
3123 from the CNMI buffer. That means, this function only returns
3124 the pointer to the beginning of the CNMI buffer element.
3125 If the buffer is empty or if the uiIndex parameter is bigger
3126 than allowed, the return pointer will be NULL.
3127 */
3128 GLOBAL T_CNMI_BUFFER_ELEMENT* cmd_getCnmiMessage(UINT16 uiIndex)
3129 {
3130 T_CNMI_BUFFER_ELEMENT* psCnmiBufferElement = NULL;
3131
3132 if( (cnmiBuf.next EQ 0) OR
3133 (cnmiBuf.sCnmiElement[0].type EQ CNMI_NONE) OR
3134 (uiIndex >= CNMI_BUF_SIZE ) )
3135 {
3136 return NULL;
3137 }
3138
3139 psCnmiBufferElement = &cnmiBuf.sCnmiElement[uiIndex];
3140 return psCnmiBufferElement; /* returns the pointer to the element */
3141 }
3142
3143
3144 /*
3145 +-----------------------------------------------------------------------+
3146 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
3147 | STATE : code ROUTINE : clearFirstCnmiMessage |
3148 +-----------------------------------------------------------------------+
3149
3150 PURPOSE : This function is the responsible to clear an entire Msg.
3151 specified by uiIndex from the CNMI buffer.
3152 After succesful return, the message was delete from the CNMI
3153 buffer and the buffer has been resorted.
3154 */
3155 GLOBAL BOOL cmd_clearCnmiMessage(UINT16 uiIndex)
3156 {
3157 UINT16 uiBufCount;
3158
3159 if( (cnmiBuf.next EQ 0) OR
3160 (cnmiBuf.sCnmiElement[0].type EQ CNMI_NONE))
3161 {
3162 return FALSE; /* CNMI buffer is empty or flushing is in progress */
3163 }
3164
3165 /* delete first entry while resorting the buffer */
3166 for( uiBufCount = uiIndex; uiBufCount<(CNMI_BUF_SIZE-1); uiBufCount++ )
3167 {
3168 memcpy( &cnmiBuf.sCnmiElement[uiBufCount], &cnmiBuf.sCnmiElement[uiBufCount+1], sizeof(T_CNMI_BUFFER_ELEMENT) );
3169 }
3170
3171 cnmiBuf.next--;
3172
3173 return TRUE;
3174 }
3175
3176 /*
3177 +-----------------------------------------------------------------------+
3178 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
3179 | STATE : code ROUTINE : getCnmiMessage |
3180 +-----------------------------------------------------------------------+
3181
3182 PURPOSE : This function is the responsible to get the first entire Msg.
3183 from the CNMI buffer. That means, this function only returns
3184 the pointer to the beginning of the CNMI buffer.
3185 If the buffer is empty, the return pointer will be NULL.
3186 */
3187 GLOBAL T_CNMI_BUFFER_ELEMENT* cmd_getFirstCnmiMessage(void)
3188 {
3189 return cmd_getCnmiMessage(0);
3190 }
3191
3192
3193 /*
3194 +-----------------------------------------------------------------------+
3195 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
3196 | STATE : code ROUTINE : clearFirstCnmiMessage |
3197 +-----------------------------------------------------------------------+
3198
3199 PURPOSE : This function is the responsible to clear the first entire Msg.
3200 from the CNMI buffer. After succesful return, the
3201 message was delete from the CNMI buffer.
3202 */
3203 GLOBAL BOOL cmd_clearFirstCnmiMessage(void)
3204 {
3205 return cmd_clearCnmiMessage(0);
3206 }
3207
3208
3209 /*
3210 +--------------------------------------------------------------------+
3211 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
3212 | STATE : code ROUTINE : rCI_IoMode |
3213 +--------------------------------------------------------------------+
3214
3215 PURPOSE : This function will be called when IO mode of serial
3216 interface has changed.
3217 */
3218 GLOBAL void rCI_IoMode ( void )
3219 {
3220 TRACE_FUNCTION ( "rCI_IoMode (): actually not awaited !!" );
3221
3222 /* if ( io_getIoMode () EQ IO_MODE_CMD AND
3223 at.CNMI_mode EQ CNMI_MOD_Buffer )
3224 cmd_flushCnmiBuf (CMD_SRC_ATI);*/
3225 }
3226
3227
3228 /*
3229 +-----------------------------------------------------------------------+
3230 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
3231 | STATE : code ROUTINE : cmd_handleCnmaTimeout |
3232 +-----------------------------------------------------------------------+
3233
3234 PURPOSE : This function will be called when the +CNMA Timer has expired.
3235 Now all to be acknowledged +CMT messages whithin the CNMI
3236 buffer must be stored in the non-volatile buffer e.g. SIM...
3237 Note: all other Msgs. different from +CMT will be deliver
3238 to the source and remove from buffer. */
3239
3240 GLOBAL void cmd_handleCnmaTimeout( void )
3241 {
3242 UINT16 uiCnmiMsgCounter = 0;
3243 T_CNMI_BUFFER_ELEMENT *psMsgInCnmiBuffer = NULL;
3244
3245 TRACE_FUNCTION ( "cmd_handleCnmaTimeout()" );
3246
3247 cmhSMS_resetMtDsCnmiParam();
3248
3249 if( waitForCnmaFromBuffer_SrcId EQ CMD_SRC_NONE OR
3250 waitForCnmaFromBuffer_SrcId NEQ smsShrdPrm.smsSrcId)
3251 {
3252 TRACE_EVENT("cmd_handleCnmaTimeout() : Error at CNMI-buffer handling: No +CNMA acknowledge expected!!");
3253 waitForCnmaFromBuffer_SrcId = CMD_SRC_NONE;
3254 return;
3255 }
3256
3257 for( uiCnmiMsgCounter=0; uiCnmiMsgCounter<cmd_getNumberOfCnmiEntrys(); uiCnmiMsgCounter++ )
3258 { /* there are entrys in the CNMI buffer --> read it */
3259 psMsgInCnmiBuffer = cmd_getCnmiMessage(uiCnmiMsgCounter); /* FIFO */
3260
3261 if( psMsgInCnmiBuffer EQ NULL )
3262 {
3263 TRACE_EVENT("cmd_handleCnmaTimeout() : Error at CNMI-buffer handling: NULL-pointer access!!");
3264 waitForCnmaFromBuffer_SrcId = CMD_SRC_NONE;
3265 return;
3266 }
3267
3268 cnmiFlushInProgress = TRUE;
3269
3270 switch ( psMsgInCnmiBuffer->type )
3271 {
3272 case ( CNMI_CMTI ) :
3273 srcId_cb = smsShrdPrm.smsSrcId;
3274 rCI_PlusCMTI ( psMsgInCnmiBuffer->indct.cmti.mem, psMsgInCnmiBuffer->indct.cmti.index );
3275 cmd_clearCnmiMessage(uiCnmiMsgCounter);
3276 uiCnmiMsgCounter--;
3277 break;
3278
3279 case ( CNMI_CBM ) :
3280 srcId_cb = smsShrdPrm.smsSrcId;
3281 rCI_PlusCBM ( &psMsgInCnmiBuffer->indct.cbm );
3282 cmd_clearCnmiMessage(uiCnmiMsgCounter);
3283 uiCnmiMsgCounter--;
3284 break;
3285
3286 case ( CNMI_CDS ) :
3287 srcId_cb = smsShrdPrm.smsSrcId;
3288 rCI_PlusCDS ( &psMsgInCnmiBuffer->indct.cds );
3289 cmd_clearCnmiMessage(uiCnmiMsgCounter);
3290 uiCnmiMsgCounter--;
3291 break;
3292
3293 /* special handling for +CMT --> acknowledge needed */
3294 case ( CNMI_CMT ) :
3295 {
3296 T_ACI_SM_DATA sPduData;
3297
3298 waitForCnmaFromBuffer_SrcId = CMD_SRC_NONE; /* clear CNMA waiting flag */
3299 srcId_cb = smsShrdPrm.smsSrcId;
3300 sPduData.len = psMsgInCnmiBuffer->indct.cmt.sms_sdu.l_buf / 8; /* l_buf is in BIT !! */
3301 memcpy( &sPduData.data, &psMsgInCnmiBuffer->indct.cmt.sms_sdu.buf, SIM_PDU_LEN );
3302 cmhSMS_storePduToSim( smsShrdPrm.smsSrcId, SMS_RECORD_REC_UNREAD, &sPduData );
3303 cnmiFlushInProgress = FALSE;
3304 return; /* only one SMS can be stored at the SIM here */
3305 }
3306
3307 default:
3308 TRACE_EVENT("cmd_handleCnmaTimeout() : wrong CNMI-buffer handling: wrong Msg. type");
3309 }
3310 cnmiFlushInProgress = FALSE;
3311 }
3312 }
3313
3314 /*
3315 +-----------------------------------------------------------------------+
3316 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
3317 | STATE : code ROUTINE : cmd_handleCnmaTimeout |
3318 +-----------------------------------------------------------------------+
3319
3320 PURPOSE : This function stores the next message - correxponding
3321 to a specified source - into the non volatile memory.
3322 Note: all other Msgs. different from +CMT will be deliver
3323 to the source and remove from buffer.
3324 */
3325 GLOBAL BOOL cmd_storeNextCnmiBufMsgToSim( void )
3326 {
3327 UINT16 uiCnmiMsgCounter = 0;
3328 T_CNMI_BUFFER_ELEMENT *psMsgInCnmiBuffer = NULL;
3329
3330 TRACE_FUNCTION ( "cmd_storeNextCnmiBufMsgToSim()" );
3331
3332 if( smsShrdPrm.uiInternalSmsStorage EQ CMD_SRC_NONE OR
3333 smsShrdPrm.uiInternalSmsStorage NEQ smsShrdPrm.smsSrcId)
3334 {
3335 TRACE_EVENT("cmd_storeNextCnmiBufMsgToSim() : no valid source -> abort !!");
3336 smsShrdPrm.uiInternalSmsStorage = CMD_SRC_NONE;
3337 return(FALSE);
3338 }
3339
3340 for( uiCnmiMsgCounter=0; uiCnmiMsgCounter<cmd_getNumberOfCnmiEntrys(); uiCnmiMsgCounter++ )
3341 { /* there are entrys in the CNMI buffer --> read it */
3342 psMsgInCnmiBuffer = cmd_getCnmiMessage(uiCnmiMsgCounter); /* FIFO */
3343
3344 if( psMsgInCnmiBuffer EQ NULL )
3345 {
3346 TRACE_EVENT("cmd_storeNextCnmiBufMsgToSim() : Error at CNMI-buffer handling: NULL-pointer access!!");
3347 smsShrdPrm.uiInternalSmsStorage = CMD_SRC_NONE;
3348 return(FALSE);
3349 }
3350
3351 cnmiFlushInProgress = TRUE;
3352
3353 switch ( psMsgInCnmiBuffer->type )
3354 {
3355 case ( CNMI_CMTI ) :
3356 srcId_cb = smsShrdPrm.smsSrcId;
3357 rCI_PlusCMTI ( psMsgInCnmiBuffer->indct.cmti.mem, psMsgInCnmiBuffer->indct.cmti.index );
3358 cmd_clearCnmiMessage(uiCnmiMsgCounter);
3359 uiCnmiMsgCounter--;
3360 break;
3361
3362 case ( CNMI_CBM ) :
3363 srcId_cb = smsShrdPrm.smsSrcId;
3364 rCI_PlusCBM ( &psMsgInCnmiBuffer->indct.cbm );
3365 cmd_clearCnmiMessage(uiCnmiMsgCounter);
3366 uiCnmiMsgCounter--;
3367 break;
3368
3369 case ( CNMI_CDS ) :
3370 srcId_cb = smsShrdPrm.smsSrcId;
3371 rCI_PlusCDS ( &psMsgInCnmiBuffer->indct.cds );
3372 cmd_clearCnmiMessage(uiCnmiMsgCounter);
3373 uiCnmiMsgCounter--;
3374 break;
3375
3376 /* special handling for +CMT --> acknowledge needed */
3377 case ( CNMI_CMT ) :
3378 {
3379 T_ACI_SM_DATA sPduData;
3380
3381 srcId_cb = smsShrdPrm.smsSrcId;
3382 sPduData.len = psMsgInCnmiBuffer->indct.cmt.sms_sdu.l_buf / 8; /* l_buf is in BIT !! */
3383 memcpy( &sPduData.data, &psMsgInCnmiBuffer->indct.cmt.sms_sdu.buf, SIM_PDU_LEN );
3384 cmhSMS_storePduToSim( smsShrdPrm.smsSrcId, SMS_RECORD_REC_UNREAD, &sPduData );
3385 cnmiFlushInProgress = FALSE;
3386 return(TRUE); /* only one SMS can be stored at the SIM here */
3387 }
3388
3389 default:
3390 TRACE_EVENT("cmd_handleCnmaTimeout() : wrong CNMI-buffer handling: wrong Msg. type");
3391 }
3392 cnmiFlushInProgress = FALSE;
3393 }
3394 smsShrdPrm.uiInternalSmsStorage = CMD_SRC_NONE; /* no more +CMT has to be store */
3395 return(FALSE);
3396 }
3397
3398 /*
3399 +--------------------------------------------------------------------+
3400 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
3401 | STATE : code ROUTINE : setatPlusCMMS |
3402 +--------------------------------------------------------------------+
3403
3404 PURPOSE : +CMMS command (More Messages To Send)
3405 */
3406
3407 GLOBAL T_ATI_RSLT setatPlusCMMS (char *cl, UBYTE srcId)
3408 {
3409 T_ACI_RETURN ret = AT_FAIL;
3410 UBYTE mode = 0;
3411
3412 TRACE_FUNCTION("setatPlusCMMS()");
3413
3414 cl = parse (cl,"r",&mode);
3415
3416 /*
3417 * no mode values allowed other than 0-2
3418 */
3419 if ( !cl OR (mode < CMMS_MODE_DEF OR mode > CMMS_MODE_TWO))
3420 {
3421 cmdCmsError(CMS_ERR_OpNotAllowed);
3422 return (ATI_FAIL);
3423 }
3424 ret = sAT_PlusCMMS(srcId,mode);
3425 if (ret NEQ AT_CMPL)
3426 {
3427 cmdCmsError(CMS_ERR_UnknownErr);
3428 return (ret);
3429 }
3430 return (map_aci_2_ati_rslt(ret));
3431 }
3432
3433 /*
3434 +--------------------------------------------------------------------+
3435 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
3436 | STATE : code ROUTINE : queatPlusCMMS |
3437 +--------------------------------------------------------------------+
3438
3439 PURPOSE : +CMMS query command
3440 */
3441 GLOBAL T_ATI_RSLT queatPlusCMMS (char *cl, UBYTE srcId)
3442 {
3443 T_ACI_RETURN ret = AT_FAIL;
3444 UBYTE mode = CMMS_MODE_DEF;
3445
3446 TRACE_FUNCTION("queatPlusCMMS()");
3447
3448 ret = qAT_PlusCMMS (srcId,&mode);
3449 if (ret EQ AT_CMPL)
3450 {
3451 sprintf(g_sa, "+CMMS: %d", mode);
3452 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
3453 return (ATI_CMPL);
3454 }
3455 else
3456 {
3457 cmdCmsError(CMS_ERR_NotPresent);
3458 return (ATI_FAIL);
3459 }
3460 }
3461
3462 /*
3463 +-------------------------------------------------------------------------+
3464 | PROJECT : GSM-F&D MODULE : ATI_SMS |
3465 | STATE : finished ROUTINE : txt_rdmode_to_smsrdmode|
3466 +-------------------------------------------------------------------------+
3467
3468 PURPOSE : converts the text read mode to smsReadMode.
3469
3470 */
3471 GLOBAL T_ATI_RSLT txt_rdmode_to_smsrdmode(char *txt_rdmode)
3472 {
3473 UBYTE i = 0;
3474
3475 if (txt_rdmode[0] EQ '\0')
3476 {
3477 strcpy (txt_rdmode, sms_rdmode[0].name); /* NORMAL as default */
3478 }
3479 while ( sms_rdmode[i].name NEQ NULL AND
3480 strcmp ( sms_rdmode[i].name, txt_rdmode ) NEQ 0 )
3481 {
3482 i++;
3483 }
3484
3485 if ( sms_rdmode[i].name EQ NULL )
3486 {
3487 cmdCmsError ( CMS_ERR_OpNotAllowed );
3488 return (ATI_FAIL);
3489 }
3490 smsReadMode = sms_rdmode[i].rdmode;
3491 return ATI_CMPL;
3492 }
3493
3494
3495 /*
3496 +--------------------------------------------------------------------+
3497 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
3498 | STATE : code ROUTINE : atPercentCMGL |
3499 +--------------------------------------------------------------------+
3500
3501 PURPOSE : %CMGL command (List Message)
3502 */
3503
3504 GLOBAL T_ATI_RSLT atPercentCMGL (char *cl, UBYTE srcId)
3505 {
3506 T_ACI_RETURN ret;
3507 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
3508
3509 #ifdef SMS_PDU_SUPPORT
3510 T_ACI_CMGF_MOD mode;
3511 #endif
3512 CHAR txtStat[15]= {0};
3513 CHAR txtRdMode[20] = {0};
3514 USHORT i;
3515
3516 TRACE_FUNCTION("atPercentCMGL()");
3517
3518 cmglStat = SMS_STAT_NotPresent;
3519 smsReadMode = SMS_READ_NotPresent;
3520
3521 if (*cl EQ '\0')
3522 {
3523 smsReadMode = SMS_READ_Normal;
3524 }
3525 else
3526 {
3527 /*
3528 * Request of a list of stored SMS messages
3529 * Parameter stat is optional
3530 */
3531 #ifdef SMS_PDU_SUPPORT
3532 /*
3533 * request current mode
3534 */
3535 qAT_PlusCMGF(srcId, &mode);
3536 if (mode EQ 0)
3537 {
3538
3539 /*
3540 * %CMGL=[stat],[preview]
3541 */
3542 cl = parse (cl, "dd", &cmglStat, &smsReadMode );
3543 if ( !cl
3544 OR ((cmglStat < SMS_STAT_RecUnread OR cmglStat > SMS_STAT_All)
3545 AND smsReadMode EQ SMS_READ_NotPresent)
3546 OR (cmglStat < SMS_STAT_RecUnread AND smsReadMode > SMS_READ_NotPresent)
3547 OR (smsReadMode > SMS_READ_StatusChange))
3548 {
3549 cmdCmsError ( CMS_ERR_OpNotAllowed );
3550 return (ATI_FAIL);
3551 }
3552 }
3553 else
3554 #endif
3555 {
3556
3557 /*
3558 * %CMGL=[stat],[preview]
3559 */
3560 cl = parse (cl, "ss", (LONG)sizeof(txtStat), txtStat,
3561 (LONG)sizeof(txtRdMode), txtRdMode);
3562 if ( !cl OR (txtStat[0] EQ '\0' AND txtRdMode[0] NEQ '\0'))
3563 {
3564 cmdCmsError ( CMS_ERR_OpNotAllowed );
3565 return (ATI_FAIL);
3566 }
3567 if (txtStat[0] EQ '\0')
3568 strcpy (txtStat, sms_stat[4].name); /* ALL as default */
3569
3570 i = 0;
3571 while ( sms_stat[i].name NEQ NULL AND
3572 strcmp ( sms_stat[i].name, txtStat ) NEQ 0 )
3573 i++;
3574
3575 if ( sms_stat[i].name EQ NULL )
3576 {
3577 cmdCmsError ( CMS_ERR_OpNotAllowed );
3578 return (ATI_FAIL);
3579 }
3580 cmglStat = sms_stat[i].stat;
3581
3582 ret = txt_rdmode_to_smsrdmode(txtRdMode);
3583 if (ret EQ ATI_FAIL)
3584 {
3585 return (ret);
3586 }
3587 }
3588 }
3589
3590 #ifdef FF_ATI_BAT
3591 {
3592 T_BAT_cmd_send cmd;
3593 T_BAT_cmd_set_percent_cmgl cmgl;
3594
3595 cmd.ctrl_params=BAT_CMD_SET_PERCENT_CMGL;
3596 cmd.params.ptr_set_percent_cmgl=&cmgl;
3597
3598 /*
3599 * T_ACI_SMS_STAT and T_BAT_percent_cmgl_stat are not quite
3600 * identical - the ACI version has the extra value
3601 * SMS_STAT_Invalid.
3602 */
3603 if (cmglStat EQ SMS_STAT_Invalid)
3604 cmgl.stat=BAT_CMGL_STAT_NOT_PRESENT;
3605 else
3606 cmgl.stat=(T_BAT_percent_cmgl_stat)cmglStat;
3607
3608 cmgl.rdmode = smsReadMode ;
3609
3610 bat_send(ati_bat_get_client(srcId),&cmd);
3611
3612 src_params->curAtCmd=AT_CMD_P_CMGL;
3613 return(ATI_EXCT);
3614 }
3615
3616 #else
3617
3618 ret = sAT_PercentCMGL ( srcId, cmglStat, smsReadMode );
3619
3620 if ( ret EQ AT_EXCT )
3621 {
3622 src_params->curAtCmd = AT_CMD_P_CMGL;
3623 return (ATI_EXCT);
3624 }
3625 else
3626 {
3627 cmdCmsError ( CMS_ERR_NotPresent );
3628 return (ATI_FAIL);
3629 }
3630 #endif
3631 }
3632
3633 /*
3634 +--------------------------------------------------------------------+
3635 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
3636 | STATE : code ROUTINE : atPercentCMGR |
3637 +--------------------------------------------------------------------+
3638
3639 PURPOSE : %CMGR command (Read Message)
3640 */
3641
3642 GLOBAL T_ATI_RSLT atPercentCMGR (char *cl, UBYTE srcId)
3643 {
3644 T_ACI_RETURN ret = AT_FAIL;
3645 SHORT idx=-1;
3646 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
3647 #ifdef SMS_PDU_SUPPORT
3648 T_ACI_CMGF_MOD mode;
3649 #endif
3650 CHAR txtRdMode[20]={0};
3651
3652
3653 TRACE_FUNCTION("atPercentCMGR()");
3654
3655 smsReadMode = SMS_READ_Normal;
3656
3657 #ifdef SMS_PDU_SUPPORT
3658 /*
3659 * request current mode
3660 */
3661 qAT_PlusCMGF(srcId, &mode);
3662 if (mode EQ 0)
3663 {
3664 /*
3665 * %CMGR=[index],[preview]
3666 */
3667 cl = parse (cl, "rd", &idx, &smsReadMode );
3668 if ( !cl OR idx > 255 OR idx < 0 OR smsReadMode > SMS_READ_StatusChange)
3669 {
3670 cmdCmsError ( CMS_ERR_OpNotAllowed );
3671 return (ATI_FAIL);
3672 }
3673 }
3674 else
3675 #endif
3676 {
3677 /*
3678 * %CMGR=[index],[preview]
3679 */
3680 cl = parse (cl, "rs", &idx,
3681 (LONG)sizeof(txtRdMode), txtRdMode);
3682
3683 if ( !cl OR idx > 255 OR idx < 0)
3684 {
3685 cmdCmsError(CMS_ERR_OpNotAllowed);
3686 return (ATI_FAIL);
3687 }
3688 ret = txt_rdmode_to_smsrdmode(txtRdMode);
3689 if (ret EQ ATI_FAIL)
3690 {
3691 return (ret);
3692 }
3693 }
3694
3695 #ifdef FF_ATI_BAT
3696 {
3697 T_BAT_cmd_send cmd;
3698 T_BAT_cmd_set_percent_cmgr cmgr;
3699
3700 cmd.ctrl_params=BAT_CMD_SET_PERCENT_CMGR;
3701 cmd.params.ptr_set_percent_cmgr=&cmgr;
3702
3703 cmgr.sms_index=(U16)idx;
3704
3705 cmgr.rdmode = smsReadMode ;
3706
3707 bat_send(ati_bat_get_client(srcId), &cmd);
3708
3709 src_params->curAtCmd=AT_CMD_P_CMGR;
3710 return(ATI_EXCT);
3711 }
3712
3713 #else
3714
3715 #ifndef _CONC_TESTING_
3716 ret = sAT_PercentCMGR_Gl(srcId, (UBYTE)idx, smsReadMode , NULL);
3717 #else
3718 ret = sAT_PercentCMGR (srcId, (UBYTE)idx, smsReadMode );
3719 #endif
3720 if ( ret EQ AT_CMPL )
3721 {
3722 return (ATI_CMPL);
3723 }
3724 else if (ret EQ AT_EXCT)
3725 {
3726 src_params->curAtCmd = AT_CMD_P_CMGR;
3727 return (ATI_EXCT);
3728 }
3729 else
3730 {
3731 cmdCmsError(CMS_ERR_NotPresent); // use aciErrDesc
3732 return (ATI_FAIL);
3733 }
3734
3735 #endif /*FF_ATI_BAT*/
3736 }
3737
3738 GLOBAL T_ATI_RSLT tesatPercentCMGL (char *cl, UBYTE srcId)
3739 {
3740 #ifdef SMS_PDU_SUPPORT
3741 T_ACI_CMGF_MOD mode;
3742 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
3743
3744 TRACE_FUNCTION("tesatPercentCMGL()");
3745 /*
3746 * request current mode
3747 */
3748 qAT_PlusCMGF(srcId, &mode);
3749 if (mode EQ 0)
3750 /*
3751 * handle PDU mode
3752 */
3753 io_sendMessage(srcId, "+CMGL: (0,1,2,3,4), (0,1,2)", ATI_NORMAL_OUTPUT);
3754 else
3755 /*
3756 * handle Text mode
3757 */
3758 #endif
3759 io_sendMessage(srcId, "+CMGL: (\"REC UNREAD\",\"REC READ\",\"STO UNSENT\",\"STO SENT\",\"ALL\"), \
3760 (\"READ NORMAL\",\"READ PREVIEW\",\"STATUS CHANGE\")", ATI_NORMAL_OUTPUT);
3761
3762 return (ATI_CMPL);
3763 }
3764
3765 #endif /* ATI_SMS_C */