comparison src/g23m-aci/aci/ati_ss.c @ 162:53929b40109c

src/g23m-aci: initial import from TCS3.2/LoCosto
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 11 Oct 2016 02:02:43 +0000
parents
children
comparison
equal deleted inserted replaced
161:4557e2a9c18e 162:53929b40109c
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: Supplementary Service related commands.
18 +-----------------------------------------------------------------------------
19 */
20
21 #ifndef ATI_SS_C
22 #define ATI_SS_C
23
24 #undef DUMMY_ATI_STRINGS
25
26 #include "aci_all.h"
27
28 #include "aci_lst.h"
29 #include "aci_cmh.h"
30 #include "ati_cmd.h"
31 #include "aci_io.h"
32 #include "aci_cmd.h"
33 #include "l4_tim.h"
34
35 #include "aci_mem.h"
36 #include "aci_prs.h"
37
38 #include "ati_int.h"
39
40 #ifdef FF_ATI_BAT
41
42 #include "typedefs.h"
43 #include "gdd.h"
44 #include "bat.h"
45
46 #include "ati_bat.h"
47
48 #endif /*FF_ATI_BAT*/
49
50 typedef struct
51 {
52 char *name;
53 T_ACI_FAC fac;
54 } net_fac;
55
56 const net_fac fac[] =
57 {
58 {"SC", FAC_Sc},
59 {"AO", FAC_Ao},
60 {"OI", FAC_Oi},
61 {"OX", FAC_Ox},
62 {"AI", FAC_Ai},
63 {"IR", FAC_Ir},
64 {"AB", FAC_Ab},
65 {"AG", FAC_Ag},
66 {"AC", FAC_Ac},
67 {"FD", FAC_Fd},
68 {"PN", FAC_Pn}, /* Network personalisation of the ME */
69 {"PU", FAC_Pu}, /* Network subset personalisation of the ME */
70 {"PP", FAC_Pp}, /* Service provider personalisation of the ME */
71 {"PC", FAC_Pc}, /* Corporate personalisation of the ME */
72 {"PS", FAC_Ps}, /* SIM personalisation */
73 {"PF", FAC_Pf}, /* Personalisation on first inserted SIM */
74 {"AL", FAC_Al}, /* ALS settings locked by CHV2 */
75 {"P2", FAC_P2},
76 #ifdef SIM_PERS
77 {"BP", FAC_Bl}, /* Blocked Network personalisation of the ME */
78 {"FC", FAC_Fc},
79 {"FM", FAC_Fcm},
80 {"MU", FAC_Mu},
81 {"MM", FAC_Mum},
82 #endif
83 #ifdef FF_PHONE_LOCK
84 {"PL", FAC_Pl},
85 {"LA", FAC_Apl},
86 #endif
87 {0, FAC_NotPresent}
88
89 };
90
91 #ifdef SIM_PERS
92
93 typedef struct
94 {
95 char *name;
96 T_SUP_INFO_TYPE sup_info;
97 } net_mepd_sup_info;
98
99 const net_mepd_sup_info mepd_sup_info[] =
100 {
101 {"MAX", FCMAX},
102 {"ALE", FCATTEMPTSLEFT},
103 {"RFM", FCRESETFAILMAX},
104 {"RFA", FCRESETFAILATTEMPTSLEFT},
105 {"RSM", FCRESETSUCCESSMAX},
106 {"RSA", FCRESETSUCCESSATTEMPTSLEFT},
107 {"TMF", TIMERFLAG},
108 {"ETF", ETSIFLAG},
109 {"AIF", AIRTELINDFLAG},
110 {0, CMEPD_SUP_INFO_NotPresent}
111 };
112
113 #endif
114 GLOBAL char dialBuf[MAX_DIAL_LEN];
115 GLOBAL char subBuf[MAX_SUBADDR_LEN];
116
117 /*
118 +--------------------------------------------------------------------+
119 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
120 | STATE : code ROUTINE : setatPlusCTFR |
121 +--------------------------------------------------------------------+
122
123 PURPOSE : +CTFR command (Call TRansfer, Call Deflection)
124 */
125 GLOBAL T_ATI_RSLT setatPlusCTFR (char * cl, UBYTE srcId)
126 {
127 T_ACI_RETURN ret = AT_FAIL;
128 T_ACI_TOA type;
129 T_ACI_TOA *p_type;
130 T_ACI_TOS satype;
131 T_ACI_TOS *p_satype;
132 CHAR *subadr = subBuf;
133 SHORT toa_oct = 0;
134 SHORT tos_oct = 0;
135 CHAR numBuf[MAX_B_SUBSCR_NUM_LEN];
136
137 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
138
139 src_params->curAtCmd = AT_CMD_CTFR;
140
141 /* init */
142 p_type = &type;
143 p_satype = &satype;
144 memset( numBuf, 0, sizeof(numBuf));
145 memset( subadr, 0, MAX_SUBADDR_LEN);
146
147 cl = parse(cl,"srsr",(LONG)MAX_B_SUBSCR_NUM_LEN, numBuf, &toa_oct,
148 (LONG)MAX_SUBADDR_LEN, subadr, &tos_oct);
149
150 /* Process number parameter (mandatory) */
151 if(!cl OR numBuf[0] EQ '\0')
152 {
153 /* Number is mandatory. No number parameter => error */
154 cmdCmeError (CME_ERR_OpNotAllow);
155 return (ATI_FAIL);
156 }
157
158 /* Process Type Of Address (optional) */
159 if(toa_oct EQ 0)
160 {
161 /* Type Of Address not present */
162 p_type = NULL;
163 }
164 else
165 {
166 /* Type Of Address present */
167 type = toa_demerge (toa_oct);
168 if (type.ton < 0 OR type.npi < 0)
169 {
170 cmdCmeError (CME_ERR_OpNotAllow);
171 return (ATI_FAIL);
172 }
173 }
174
175 /* Process subadr (optional) */
176 if( subadr[0] EQ 0 )
177 {
178 /* subadr not present */
179 subadr = NULL;
180 }
181
182 /* Process Type Of Subaddress (optional) */
183 if(tos_oct EQ 0)
184 {
185 /* Type Of Subaddress not present */
186 p_satype = NULL;
187 }
188 else
189 {
190 satype = tos_demerge (tos_oct);
191 if (satype.tos < 0 OR satype.oe < 0)
192 {
193 cmdCmeError (CME_ERR_OpNotAllow);
194 return (ATI_FAIL);
195 }
196 }
197
198 #ifdef FF_ATI_BAT
199 {
200 T_BAT_cmd_send cmd;
201 T_BAT_cmd_set_plus_ctfr my_bat_set_plus_ctfr;
202
203 TRACE_FUNCTION("setatPlusCTFR() calls bat_send() <=== as APPLICATION");
204
205 memset(&my_bat_set_plus_ctfr, 0, sizeof(my_bat_set_plus_ctfr));
206 cmd.ctrl_params = BAT_CMD_SET_PLUS_CTFR;
207 cmd.params.ptr_set_plus_ctfr = &my_bat_set_plus_ctfr;
208
209 my_bat_set_plus_ctfr.c_number = strlen(numBuf);
210 memcpy(my_bat_set_plus_ctfr.number, numBuf, my_bat_set_plus_ctfr.c_number);
211 my_bat_set_plus_ctfr.type = (S16)p_type;
212 my_bat_set_plus_ctfr.v_subaddr = 0; /*??? */
213 my_bat_set_plus_ctfr.c_subaddr = strlen(subadr);
214 memcpy(my_bat_set_plus_ctfr.subaddr, subadr, my_bat_set_plus_ctfr.c_subaddr);
215 my_bat_set_plus_ctfr.satype = (S16)p_satype;
216
217 bat_send(ati_bat_get_client(srcId), &cmd);
218
219 return ATI_EXCT; /* executing, because response is passed by callback function */
220 }
221 #else /* OLD FUNCTION BODY */
222
223 TRACE_FUNCTION("setatPlusCTFR()");
224
225 ret = sAT_PlusCTFR ((T_ACI_CMD_SRC)srcId, numBuf, p_type, subadr, p_satype);
226
227 if (ret NEQ AT_EXCT)
228 {
229 cmdCmeError(CME_ERR_Unknown);
230 }
231 return (map_aci_2_ati_rslt(ret));
232
233 #endif /* no FF_ATI_BAT*/
234 }
235
236 /*
237 +--------------------------------------------------------------------+
238 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
239 | STATE : code ROUTINE : atiSShandleCSSN |
240 +--------------------------------------------------------------------+
241
242 PURPOSE : Handles the +CSSN and %CSSN set commands.*/
243
244 GLOBAL T_ATI_RSLT atiSShandleCSSN (char* cl, UBYTE srcId)
245 {
246 int cssiMode = ati_user_output_cfg[srcId].CSSI_stat, cssuMode = ati_user_output_cfg[srcId].CSSU_stat;
247
248 TRACE_FUNCTION("atiSShandleCSSN()");
249
250 if (*cl EQ 0 OR *cl EQ ';')
251 {
252 cmdCmeError(CME_ERR_OpNotAllow);
253 return (ATI_FAIL);
254 }
255 cl = parse(cl,"dd",&cssiMode,&cssuMode);
256 /* A value of 2 for cssiMode is now accepted. This value will only be set by %CSSN */
257 if(!cl OR cssiMode > 2 OR cssiMode < 0 OR
258 cssuMode > 1 OR cssuMode < 0 )
259 {
260 cmdCmeError(CME_ERR_OpNotAllow);
261 return (ATI_FAIL);
262 }
263 ati_user_output_cfg[srcId].CSSI_stat=(UBYTE)cssiMode;
264 ati_user_output_cfg[srcId].CSSU_stat=(UBYTE)cssuMode;
265
266 if (*cl NEQ '\0' AND *cl NEQ ';')
267 {
268 cmdCmeError(CME_ERR_OpNotAllow);
269 return (ATI_FAIL);
270 }
271 return (ATI_CMPL);
272
273 }
274
275
276 /*
277 +--------------------------------------------------------------------+
278 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
279 | STATE : code ROUTINE : atPlusCSSN |
280 +--------------------------------------------------------------------+
281
282 PURPOSE : +CSSN command (supplementary service notifications)
283 */
284 GLOBAL T_ATI_RSLT setatPlusCSSN (char* cl, UBYTE srcId)
285 {
286 TRACE_FUNCTION("setatPLusCSSN()");
287
288 /*Check that the range of the first parameter "CSSI mode" is valid (0 or 1).Further parameters are
289 checked in the function atiSShandleCSSN()*/
290 if ((*cl EQ '0') OR (*cl EQ '1') OR (*cl EQ ','))
291 return atiSShandleCSSN(cl,srcId);
292 else
293 {
294 cmdCmeError(CME_ERR_OpNotAllow);
295 return (ATI_FAIL);
296 }
297 }
298
299
300 /*
301 +--------------------------------------------------------------------+
302 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
303 | STATE : code ROUTINE : atPercentCSSN |
304 +--------------------------------------------------------------------+
305
306 PURPOSE : %CSSN command (supplementary service notifications extension)
307 */
308 GLOBAL T_ATI_RSLT setatPercentCSSN (char* cl, UBYTE srcId)
309 {
310 TRACE_FUNCTION("setatPercentCSSN()");
311
312 return atiSShandleCSSN(cl,srcId);
313 }
314
315
316
317 GLOBAL T_ATI_RSLT queatPlusCSSN (char* cl, UBYTE srcId)
318 {
319 TRACE_FUNCTION("queatPLusCSSN()");
320
321 resp_disp(srcId, cl,"bb",&ati_user_output_cfg[srcId].CSSI_stat,&ati_user_output_cfg[srcId].CSSU_stat);
322 return (ATI_CMPL);
323 }
324
325 /*
326 +--------------------------------------------------------------------+
327 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
328 | STATE : code ROUTINE : queatPercentCSSN |
329 +--------------------------------------------------------------------+
330
331 PURPOSE : Handles the %CSSN query command.*/
332
333
334 GLOBAL T_ATI_RSLT queatPercentCSSN (char* cl, UBYTE srcId)
335 {
336 TRACE_FUNCTION("queatPercentCSSN()");
337
338 resp_disp(srcId, cl,"bb",&ati_user_output_cfg[srcId].CSSI_stat,&ati_user_output_cfg[srcId].CSSU_stat);
339 return (ATI_CMPL);
340 }
341
342
343
344 /*
345 +--------------------------------------------------------------------+
346 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
347 | STATE : code ROUTINE : atPlusCCFC |
348 +--------------------------------------------------------------------+
349
350 PURPOSE : +CCFC call forwarding
351 */
352
353 GLOBAL T_ATI_RSLT setatPlusCCFC(char *cl, UBYTE srcId)
354 {
355 T_ACI_RETURN ret = AT_FAIL;
356 T_ACI_CCFC_RSN reason=CCFC_RSN_NotPresent;
357 T_ACI_CCFC_MOD mode=CCFC_MOD_NotPresent;
358 T_ACI_TOA type;
359 T_ACI_TOA *p_type;
360 T_ACI_TOS satype;
361 T_ACI_TOS *p_satype;
362 T_ACI_CLASS class_type=CLASS_NotPresent;
363 CHAR *subadr = subBuf;
364 SHORT time=-1;
365 SHORT toa_oct=0;
366 SHORT tos_oct=0;
367 CHAR numBuf[MAX_B_SUBSCR_NUM_LEN];
368 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
369
370 /* init */
371 memset( numBuf, 0, sizeof(numBuf));
372 memset( subadr, 0, MAX_SUBADDR_LEN);
373
374 TRACE_FUNCTION("setatPLusCCFC()");
375
376 p_type=&type;
377 p_satype=&satype;
378
379 cl = parse(cl,"ddsrdsrr",&reason,&mode,
380 (LONG)MAX_B_SUBSCR_NUM_LEN,numBuf,&toa_oct,&class_type,
381 (LONG)MAX_SUBADDR_LEN,subadr,&tos_oct,&time);
382
383 if(!cl)
384 {
385 cmdCmeError(CME_ERR_OpNotAllow);
386 return (ATI_FAIL);
387 }
388 if (mode EQ 2) /*query mode*/
389 {
390 #ifdef FF_ATI_BAT
391 {
392 T_BAT_cmd_send cmd;
393 T_BAT_cmd_set_plus_ccfc my_bat_set_plus_ccfc = {0};
394
395 TRACE_FUNCTION("setatPlusCCFC() {Query mode=2} calls bat_send() <=== as APPLICATION");
396
397 cmd.ctrl_params = BAT_CMD_SET_PLUS_CCFC;
398 cmd.params.ptr_set_plus_ccfc = &my_bat_set_plus_ccfc;
399
400 my_bat_set_plus_ccfc.reason = (T_BAT_plus_ccfc_reason)reason;
401 my_bat_set_plus_ccfc.mode = (T_BAT_plus_ccfc_mode)mode;
402 my_bat_set_plus_ccfc.bearer_class = (T_BAT_plus_ccfc_bearer_class)class_type;
403 src_params->curAtCmd = AT_CMD_CCFC;
404
405 bat_send(ati_bat_get_client(srcId), &cmd);
406 return ATI_EXCT; /* executing, because response is passed by callback function */
407 }
408 #else /* no FF_ATI_BAT */
409 ret = qAT_PlusCCFC((T_ACI_CMD_SRC)srcId,reason,class_type);
410 switch (ret)
411 {
412 case AT_EXCT:
413 {
414 src_params->curAtCmd = AT_CMD_CCFC;
415 return (ATI_EXCT);
416 }
417 case AT_BUSY:
418 {
419 TRACE_EVENT("setatPLusCCFC(): qAT_PlusCCFC returns BUSY");
420 return (ATI_BUSY);
421 }
422 case AT_FAIL:
423 {
424 TRACE_EVENT("setatPLusCCFC(): qAT_PlusCCFC returns FAIL");
425 cmdCmeError(CME_ERR_Unknown); /* Extended error returned by qAT_PlusCCFC */
426 return (ATI_FAIL);
427 }
428 default:
429 {
430 cmdCmeError(CME_ERR_Unknown);
431 return (ATI_FAIL);
432 }
433 }
434 #endif /* no FF_ATI_BAT */
435 }
436 else /*set mode*/
437 {
438 if( subadr[0] EQ 0 )
439 {
440 /* subadr has been omitted in command */
441 subadr = NULL;
442 }
443
444 if(toa_oct EQ 0)
445 p_type=NULL;
446 else
447 {
448 type=toa_demerge(toa_oct);
449 if (type.ton < 0 OR type.npi < 0)
450 {
451 cmdCmeError(CME_ERR_OpNotAllow);
452 return (ATI_FAIL);
453 }
454 }
455 if(tos_oct EQ 0)
456 p_satype=NULL;
457 else
458 {
459 satype=tos_demerge(tos_oct);
460 if(satype.tos < 0 OR satype.oe < 0)
461 {
462 cmdCmeError(CME_ERR_OpNotAllow);
463 return (ATI_FAIL);
464 }
465 }
466 #ifdef FF_ATI_BAT
467 {
468 T_BAT_cmd_send cmd;
469 T_BAT_cmd_set_plus_ccfc my_bat_set_plus_ccfc = {0};
470
471 TRACE_FUNCTION("setatPlusCCFC() calls bat_send() <=== as APPLICATION");
472
473 cmd.ctrl_params = BAT_CMD_SET_PLUS_CCFC;
474 cmd.params.ptr_set_plus_ccfc = &my_bat_set_plus_ccfc;
475
476 my_bat_set_plus_ccfc.reason = (T_BAT_plus_ccfc_reason)reason;
477 my_bat_set_plus_ccfc.mode = (T_BAT_plus_ccfc_mode)mode;
478
479 /* check for number string and store for BAT send */
480 if (my_bat_set_plus_ccfc.c_number = strlen(numBuf))
481 {
482 my_bat_set_plus_ccfc.v_number = TRUE;
483 memcpy(my_bat_set_plus_ccfc.number, numBuf, my_bat_set_plus_ccfc.c_number);
484 }
485
486 my_bat_set_plus_ccfc.type = (S16)toa_oct;
487
488 /* check for subaddr string and store for BAT send */
489 if (subadr NEQ NULL AND
490 (my_bat_set_plus_ccfc.c_subaddr = strlen(subadr)))
491 {
492 my_bat_set_plus_ccfc.v_subaddr = TRUE;
493 memcpy(my_bat_set_plus_ccfc.subaddr, subadr, my_bat_set_plus_ccfc.c_subaddr);
494 }
495
496 my_bat_set_plus_ccfc.satype = (S16)tos_oct;
497 my_bat_set_plus_ccfc.bearer_class = (T_BAT_plus_ccfc_bearer_class)class_type;
498 my_bat_set_plus_ccfc.time = (T_BAT_plus_ccfc_time)time;
499
500 src_params->curAtCmd = AT_CMD_CCFC;
501
502 bat_send(ati_bat_get_client(srcId), &cmd);
503 return ATI_EXCT; /* executing, because response is passed by callback function */
504 }
505 #else /* no FF_ATI_BAT */
506 if( numBuf[0] EQ '\0' )
507 {
508 /* number has been omitted in command */
509 ret = sAT_PlusCCFC((T_ACI_CMD_SRC)srcId,reason,mode,NULL,p_type,class_type,subadr,p_satype,time);
510 }
511 else
512 {
513 ret = sAT_PlusCCFC((T_ACI_CMD_SRC)srcId,reason,mode,numBuf,p_type,class_type,subadr,p_satype,time);
514 }
515 if (ret EQ AT_EXCT)
516 {
517 src_params->curAtCmd = AT_CMD_CCFC;
518 }
519 else
520 {
521 cmdCmeError(CME_ERR_Unknown);
522 }
523 #endif /* no FF_ATI_BAT */
524 }
525 return (map_aci_2_ati_rslt(ret));
526 }
527
528 /*
529 +--------------------------------------------------------------------+
530 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
531 | STATE : code ROUTINE : atPlusCLCK |
532 +--------------------------------------------------------------------+
533
534 PURPOSE : +CLCK command (Select facility lock settings)
535 */
536
537 GLOBAL T_ATI_RSLT setatPlusCLCK(char *cl, UBYTE srcId)
538 {
539 T_ACI_RETURN ret = AT_FAIL;
540 T_ACI_FAC fac_num = FAC_NotPresent;
541 T_ACI_CLCK_MOD mod = CLCK_MOD_NotPresent;
542 T_ACI_CLASS class_type = CLASS_NotPresent;
543 char passwd[MAX_PWD_LENGTH] = {0};
544 char fac_str[3] = {0,0,0};
545 USHORT i;
546
547 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
548
549 src_params->curAtCmd = AT_CMD_CLCK;
550 TRACE_FUNCTION("setatPLusCLCK() ");
551
552 cl = parse(cl, "sdnd", (LONG)3, fac_str, &mod, (LONG)MAX_PWD_LENGTH, passwd, &class_type);
553
554 if (!cl OR *fac_str EQ 0)
555 {
556 cmdCmeError(CME_ERR_OpNotAllow);
557 return (ATI_FAIL);
558 }
559 strcpy(fac_str, strupper(fac_str));
560 for (i=0;fac[i].name NEQ 0; i++)
561 {
562 if (strcmp(fac[i].name, fac_str) EQ 0 )
563 {
564 fac_num = fac[i].fac; /*translates facility string in facility number */
565 break;
566 }
567 }
568 if (fac_num EQ FAC_NotPresent) /* facility non existent*/
569 {
570 cmdCmeError(CME_ERR_OpNotAllow);
571 return (ATI_FAIL);
572 }
573
574 #ifdef FF_ATI_BAT
575 {
576 T_BAT_cmd_send cmd;
577 T_BAT_cmd_set_plus_clck my_bat_set_plus_clck;
578
579 TRACE_FUNCTION("setatPLusCLCK() calls bat_send() <=== as APPLICATION");
580
581 memset(&my_bat_set_plus_clck, 0, sizeof(my_bat_set_plus_clck));
582 cmd.ctrl_params = BAT_CMD_SET_PLUS_CLCK;
583 cmd.params.ptr_set_plus_clck = &my_bat_set_plus_clck;
584
585 my_bat_set_plus_clck.fac = fac_num;
586 my_bat_set_plus_clck.mode = mod;
587 if(mod NEQ CLCK_MODE_QUERY) /*query mode*/
588 {
589 my_bat_set_plus_clck.v_passwd = 1;
590 my_bat_set_plus_clck.c_passwd = strlen(passwd);
591 memcpy(my_bat_set_plus_clck.passwd, passwd, my_bat_set_plus_clck.c_passwd);
592 }
593
594 my_bat_set_plus_clck.bearer_class = class_type;
595
596 bat_send(ati_bat_get_client(srcId), &cmd);
597
598 return ATI_EXCT; /* executing, because response is passed by callback function */
599 }
600 #else /* OLD FUNCTION BODY */
601 {
602 T_ACI_CLSSTAT clsStat;
603 SHORT pos;
604
605 TRACE_FUNCTION("setatPLusCLCK()");
606
607 if (mod EQ CLCK_MOD_NotPresent) /* mode non existent*/
608 {
609 cmdCmeError(CME_ERR_OpNotAllow);
610 return(ATI_FAIL);
611 }
612 if (mod EQ CLCK_MODE_QUERY) /*query mode*/
613 {
614 ret = qAT_PlusCLCK((T_ACI_CMD_SRC)srcId, fac_num, class_type, &clsStat);
615
616 if(ret EQ AT_CMPL)
617 {
618 pos = sprintf(g_sa,"+CLCK: ");
619
620 if (clsStat.status NEQ STATUS_NotPresent)
621 {
622 pos += sprintf(g_sa+pos,"%d,",clsStat.status);
623 }
624 else
625 {
626 pos += sprintf(g_sa+pos,",");
627 }
628 if (clsStat.class_type NEQ CLASS_NotPresent)
629 {
630 pos += sprintf(g_sa+pos,"%d,",clsStat.class_type);
631 }
632 ci_remTrailCom(g_sa, pos);
633 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
634 return (ATI_CMPL);
635 }
636 }
637 else /*set mode*/
638 {
639 ret = sAT_PlusCLCK((T_ACI_CMD_SRC)srcId, fac_num, mod, passwd, class_type);
640 }
641
642 switch(ret)
643 {
644 case(AT_EXCT):
645 break;
646
647 case(AT_BUSY):
648 cmdCmeError(CME_ERR_Unknown);
649 TRACE_EVENT("ME is busy");
650 break;
651
652 case(AT_FAIL):
653 cmdCmeError(CME_ERR_Unknown);
654 break;
655 }
656 return (map_aci_2_ati_rslt(ret));
657 }
658 #endif /* no FF_ATI_BAT*/
659 }
660
661 /*
662 +--------------------------------------------------------------------+
663 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
664 | STATE : code ROUTINE : atPlusCPWD |
665 +--------------------------------------------------------------------+
666
667 PURPOSE : +CPWD command (changes password)
668 */
669
670 GLOBAL T_ATI_RSLT setatPlusCPWD(char *cl, UBYTE srcId)
671 {
672 T_ACI_RETURN ret = AT_FAIL;
673 T_ACI_FAC fac_num = FAC_NotPresent;
674 CHAR oldpwd[MAX_PWD_LENGTH]={0};
675 CHAR newpwd[MAX_PWD_LENGTH]={0};
676 CHAR fac_str[3]={0};
677 USHORT i;
678
679 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
680
681 src_params->curAtCmd = AT_CMD_CPWD;
682
683 cl = parse(cl, "snn", (LONG)3, fac_str, (LONG)MAX_PWD_LENGTH, oldpwd, (LONG)MAX_PWD_LENGTH, newpwd);
684 strcpy(fac_str, (char *)strupper(fac_str));
685 if(!cl OR *fac_str EQ 0 OR *oldpwd EQ 0 OR *newpwd EQ 0)
686 {
687 cmdCmeError(CME_ERR_OpNotAllow);
688 return (ATI_FAIL);
689 }
690 for (i = 0; fac[i].name NEQ 0; i++)
691 {
692 if (strcmp(fac[i].name,fac_str) EQ 0 )
693 {
694 fac_num=fac[i].fac; /*translates facility string in facility number */
695 break;
696 }
697 }
698 if (fac[i].name EQ 0) /* facility non existent*/
699 {
700 cmdCmeError(CME_ERR_OpNotAllow);
701 return (ATI_FAIL);
702 }
703 #ifdef FF_ATI_BAT
704 {
705 T_BAT_cmd_send cmd;
706 T_BAT_cmd_set_plus_cpwd my_bat_set_plus_cpwd;
707
708 TRACE_FUNCTION("setatPLusCPWD() calls bat_send() <=== as APPLICATION");
709
710 memset(&my_bat_set_plus_cpwd, 0, sizeof(my_bat_set_plus_cpwd));
711 cmd.ctrl_params = BAT_CMD_SET_PLUS_CPWD;
712 cmd.params.ptr_set_plus_cpwd = &my_bat_set_plus_cpwd;
713
714 my_bat_set_plus_cpwd.fac = fac_num;
715 my_bat_set_plus_cpwd.c_oldpwd = strlen(oldpwd);
716 memcpy(my_bat_set_plus_cpwd.oldpwd, oldpwd, my_bat_set_plus_cpwd.c_oldpwd);
717 my_bat_set_plus_cpwd.c_newpwd = strlen(newpwd);
718 memcpy(my_bat_set_plus_cpwd.newpwd, newpwd, my_bat_set_plus_cpwd.c_newpwd);
719
720 bat_send(ati_bat_get_client(srcId), &cmd);
721
722 return ATI_EXCT; /* executing, because response is passed by callback function */
723 }
724 #else /* OLD FUNCTION BODY */
725
726 TRACE_FUNCTION("setatPLusCPWD()");
727
728 ret = sAT_PlusCPWD((T_ACI_CMD_SRC)srcId, fac_num, oldpwd, newpwd);
729 if (ret EQ AT_CMPL)
730 {
731 return (ATI_CMPL);
732 }
733 else if (ret EQ AT_EXCT)
734 {
735 src_params->curAtCmd = AT_CMD_CPWD;
736 }
737 else
738 {
739 cmdCmeError(CME_ERR_Unknown);
740 }
741 return (map_aci_2_ati_rslt(ret));
742
743 #endif /* no FF_ATI_BAT*/
744 }
745
746 /*
747 +--------------------------------------------------------------------+
748 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
749 | STATE : code ROUTINE : atPlusCUSD |
750 +--------------------------------------------------------------------+
751
752 PURPOSE : +CUSD Unstructured supplementary data
753 */
754 GLOBAL T_ATI_RSLT setatPlusCUSD(char *cl, UBYTE srcId)
755 {
756 T_ACI_RETURN ret = AT_FAIL;
757 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
758 CHAR ussd [MAX_USSD_LEN] = {0x00};
759 USHORT lenUssd = 0;
760
761 #ifndef FF_ATI_BAT
762 T_ACI_USSD_DATA cvtdUssd;
763 T_ACI_USSD_DATA* p_cvtdUssd = NULL;
764 USHORT lenCvtdUssd = 0;
765 #endif
766
767 SHORT dcs = ACI_NumParmNotPresent,
768 stat = ACI_NumParmNotPresent;
769 BOOL status_changed = FALSE;
770
771 TRACE_FUNCTION("setatPlusCUSD()");
772
773 cl = parse(cl,"rzr",
774 &stat,
775 (LONG)MAX_USSD_LEN,
776 strlen(cl),
777 cl,
778 &lenUssd,
779 ussd,
780 &dcs);
781
782 if(cl EQ NULL OR
783 stat > 2)
784 {
785 cmdCmeError(CME_ERR_OpNotAllow);
786 return (ATI_FAIL);
787 }
788
789 if(stat EQ 2)
790 {
791 /* CANCEL ONGOING USSD OPERATION */
792 ret = sAT_end_ussd((T_ACI_CMD_SRC)srcId);
793 }
794 else
795 {
796 if (dcs EQ 17 AND ati_user_output_cfg[srcId].cscsChset NEQ CSCS_CHSET_Ucs2)
797 {
798 cmdCmeError(CME_ERR_OpNotAllow); /* it makes no sense if TE<->MS is GSM7 but we talk to the Network
799 in UCS2 since afterwards we need to convert it back to GSM7 and
800 we will loose some characters */
801 return (ATI_FAIL);
802 }
803
804 if (stat NEQ ACI_NumParmNotPresent )
805 {
806 /* SET CUSD Presentation Flag only for values stat 0 and 1 */
807 ati_user_output_cfg[srcId].CUSD_stat = (UBYTE)stat;
808 status_changed = TRUE;
809 }
810
811 if (dcs EQ ACI_NumParmNotPresent )
812 {
813 /* GSM 03.38 [25] Cell Broadcast Data Coding Scheme in integer format (default 0) */
814 dcs = 0;
815 }
816
817 srcId_cb = srcId;
818
819 #ifdef FF_ATI_BAT
820
821 {
822 T_BAT_cmd_send cmd;
823 T_BAT_cmd_set_plus_cusd cusd;
824
825 cmd.ctrl_params=BAT_CMD_SET_PLUS_CUSD;
826 cmd.params.ptr_set_plus_cusd=&cusd;
827
828 /*
829 * This is the only possible value for 'n', as the other is
830 * dealt with further up this function.
831 */
832 cusd.n=BAT_CUSD_N_NOT_PRESENT;
833
834 /*
835 * Simplest thing to do is copy in as much data as the BAT
836 * structure can handle. If there is too much we won't
837 * overwrite memory.
838 */
839 memcpy(cusd.str,ussd,BAT_MAX_USSD_LEN);
840
841 /*
842 * Set the length. If there is too much data it will
843 * effectively be truncated.
844 */
845 cusd.c_str=(U8)((lenUssd>BAT_MAX_USSD_LEN) ? BAT_MAX_USSD_LEN:lenUssd);
846 cusd.v_str=TRUE;
847
848 cusd.dcs=(S16)dcs;
849
850 bat_send(ati_bat_get_client(srcId), &cmd);
851
852 src_params->curAtCmd=AT_CMD_CUSD;
853
854 return(ATI_EXCT);
855 }
856
857 #else /* no FF_ATI_BAT */
858
859 utl_ussdDtaFromTe ((UBYTE*)ussd,
860 lenUssd,
861 (UBYTE*)cvtdUssd.data,
862 &lenCvtdUssd,
863 #ifdef REL99
864 sizeof(cvtdUssd.data),
865 #endif /* REL99 */
866 (UBYTE)dcs);
867
868 cvtdUssd.len = (UBYTE)lenCvtdUssd;
869
870 if (cvtdUssd.len NEQ 0)
871 {
872 p_cvtdUssd=&cvtdUssd;
873 }
874
875 if( p_cvtdUssd NEQ NULL )
876 {
877 ret = sAT_PlusCUSD((T_ACI_CMD_SRC)srcId, p_cvtdUssd, dcs);
878 }
879 else
880 {
881 if (lenUssd NEQ 0)
882 {
883 cmdCmeError(CME_ERR_Unknown);
884 return (ATI_FAIL);
885 }
886 }
887 #endif /* no FF_ATI_BAT */
888
889 }
890
891 if (ret EQ AT_CMPL)
892 {
893 return (ATI_CMPL);
894 }
895 else if (ret EQ AT_EXCT)
896 {
897 src_params->curAtCmd = AT_CMD_CUSD;
898 return (ATI_EXCT);
899 }
900 else if(status_changed)
901 {
902 return (ATI_CMPL);
903 }
904
905 cmdCmeError(CME_ERR_Unknown);
906 return (ATI_FAIL);
907 }
908
909 GLOBAL T_ATI_RSLT queatPlusCUSD(char *cl, UBYTE srcId)
910 {
911 TRACE_FUNCTION("queatPlusCUSD()");
912
913 resp_disp(srcId, cl,"b",&ati_user_output_cfg[srcId].CUSD_stat);
914 return (ATI_CMPL);
915 }
916
917 #ifdef TI_PS_FF_AT_P_CMD_CSCN
918 /*
919 +--------------------------------------------------------------------+
920 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
921 | STATE : code ROUTINE : atPercentCSCN |
922 +--------------------------------------------------------------------+
923
924 PURPOSE : %CSCN - network service change notifications
925 */
926 GLOBAL T_ATI_RSLT setatPercentCSCN (char *cl, UBYTE srcId)
927 {
928 T_ACI_SS_CSCN_MOD_STATE ss_switch = SS_CSCN_MOD_STATE_INVALID;
929 T_ACI_SS_CSCN_MOD_DIRECTION ss_direction = SS_CSCN_MOD_DIR_INVALID;
930 T_ACI_CC_CSCN_MOD_STATE cc_switch = CC_CSCN_MOD_STATE_INVALID;
931 T_ACI_CC_CSCN_MOD_DIRECTION cc_direction = CC_CSCN_MOD_DIR_INVALID;
932
933 TRACE_FUNCTION("setatPercentCSCN()");
934
935 if((cl EQ NULL) OR (*cl EQ '\0')) /* No parameter passed ?? */
936 {
937 cmdCmeError(CME_ERR_OpNotAllow);
938 return (ATI_FAIL);
939 }
940
941 cl = parse(cl,"dddd", &ss_switch, &ss_direction, &cc_switch, &cc_direction);
942
943 /* valid parameter ?? */
944 if( (ss_switch >= SS_CSCN_MOD_STATE_MAX) OR
945 (ss_direction >= SS_CSCN_MOD_DIR_MAX) OR
946 (cc_switch >= CC_CSCN_MOD_STATE_MAX) OR
947 (cc_direction >= CC_CSCN_MOD_DIR_MAX) )
948 {
949 cmdCmeError(CME_ERR_OpNotAllow);
950 return (ATI_FAIL);
951 }
952
953 if (sAT_PercentCSCN( (T_ACI_CMD_SRC)srcId, ss_switch, ss_direction, cc_switch, cc_direction ) NEQ AT_CMPL)
954 return (ATI_FAIL);
955
956 return (ATI_CMPL);
957 }
958
959 /* ------------------------------------------------------------------------- */
960 GLOBAL T_ATI_RSLT queatPercentCSCN (char* cl, UBYTE srcId)
961 /* ------------------------------------------------------------------------- */
962 {
963 T_ACI_SS_CSCN_MOD_STATE ss_switch;
964 T_ACI_SS_CSCN_MOD_DIRECTION ss_direction;
965 T_ACI_CC_CSCN_MOD_STATE cc_switch;
966 T_ACI_CC_CSCN_MOD_DIRECTION cc_direction;
967
968 TRACE_FUNCTION("queatPercentCSCN()");
969
970 if (qAT_PercentCSCN( (T_ACI_CMD_SRC)srcId, &ss_switch, &ss_direction, &cc_switch, &cc_direction ) NEQ AT_CMPL)
971 return (ATI_FAIL);
972
973 if( ss_switch EQ SS_CSCN_MOD_STATE_INVALID ) ss_switch = SS_CSCN_MOD_STATE_OFF;
974 if( ss_direction EQ SS_CSCN_MOD_DIR_INVALID ) ss_direction = SS_CSCN_MOD_DIR_IN;
975 if( cc_switch EQ CC_CSCN_MOD_STATE_INVALID ) cc_switch = CC_CSCN_MOD_STATE_OFF;
976 if( cc_direction EQ CC_CSCN_MOD_DIR_INVALID ) cc_direction = CC_CSCN_MOD_DIR_IN;
977
978 resp_disp(srcId, cl, "ssss", &ss_switch, &ss_direction, &cc_switch, &cc_direction);
979 return (ATI_CMPL);
980 }
981 #endif /* TI_PS_FF_AT_P_CMD_CSCN */
982
983 #ifdef TI_PS_FF_AT_P_CMD_CUSDR
984 /*
985 +--------------------------------------------------------------------+
986 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
987 | STATE : code ROUTINE : setatPercentCUSDR |
988 +--------------------------------------------------------------------+
989
990 PURPOSE : %CUSDR - Extended response for n/w initiated USSD.
991 */
992 GLOBAL T_ATI_RSLT setatPercentCUSDR(char* cl, UBYTE srcId)
993 {
994 T_ACI_CUSDR_RES response;
995 T_ACI_RETURN ret = AT_FAIL;
996
997 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
998
999 TRACE_FUNCTION("setatPercentCUSDR()");
1000
1001 cl = parse(cl,"d",&response);
1002
1003 if(!cl)
1004 {
1005 cmdCmeError(CME_ERR_OpNotAllow);
1006 return (ATI_FAIL);
1007 }
1008
1009 ret = sAT_PercentCUSDR((T_ACI_CMD_SRC)srcId, response);
1010
1011 return (map_aci_2_ati_rslt(ret));
1012
1013 }
1014 #endif /* TI_PS_FF_AT_P_CMD_CUSDR */
1015
1016
1017 #ifdef SIM_PERS
1018
1019 /* ----------Added on 11/03/2005--------------------*/
1020 /*-------------For %MEPD AT comand----------------- */
1021 /* ------------------------------------------------------------------------- */
1022 /*
1023 +------------------------------------------------------------------------------
1024 | Function : setatPercentMEPD
1025 +------------------------------------------------------------------------------
1026 | Description : For %MEPD= AT comand
1027 |
1028 | Parameters :char* cl
1029 | UBYTE srcId
1030 |
1031 | Return : ATI_FAIL - at command failed
1032 | ATI_FAIL_NO_OUTPUT - at command failed with no output
1033 | ATI_BUSY - ATI busy
1034 | ATI_EXCT - ATI is executing the command
1035 | ATI_CMPL - at command successfully executed
1036 | ATI_CMPL_NO_OUTPUT - at command successfully executed with no output
1037 |
1038 +------------------------------------------------------------------------------
1039 */
1040 GLOBAL T_ATI_RSLT setatPercentMEPD (char* cl, UBYTE srcId)
1041 {
1042 T_ACI_RETURN ret = AT_FAIL;
1043 char sup_info_str[4] = {0,0,0,0};
1044 T_SUP_INFO_TYPE sup_info_num = CMEPD_SUP_INFO_NotPresent;
1045 T_SUP_INFO sup_info; /*return Value of MEPD CFG Data */
1046 USHORT i;
1047 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
1048
1049 src_params->curAtCmd = AT_CMD_MEPD;
1050 TRACE_FUNCTION("setatPercentMEPD()");
1051
1052 /*input functionality*/
1053 cl = parse (cl,"s",(LONG)4, sup_info_str);
1054
1055 if ( !cl OR (sup_info_str[0] EQ 0))
1056 {
1057 cmdCmeError (CME_ERR_OpNotAllow);
1058 return (ATI_FAIL);
1059 }
1060
1061 strcpy(sup_info_str, strupper(sup_info_str));
1062 for (i=0;mepd_sup_info[i].name NEQ 0; i++)
1063 {
1064 if (strcmp(mepd_sup_info[i].name, sup_info_str) EQ 0 )
1065 {
1066 sup_info_num = mepd_sup_info[i].sup_info; /*translates facility string in facility number */
1067 break;
1068 }
1069 }
1070 if (sup_info_num EQ CMEPD_SUP_INFO_NotPresent) /* facility non existent*/
1071 {
1072 cmdCmeError(CME_ERR_OpNotAllow);
1073 return (ATI_FAIL);
1074 }
1075
1076 sup_info.infoType=sup_info_num;
1077
1078 #ifdef FF_ATI_BAT
1079 {
1080 T_BAT_cmd_send cmd;
1081 T_BAT_cmd_set_percent_mepd mepd;
1082
1083 memset(&mepd, 0, sizeof(mepd));
1084 cmd.ctrl_params = BAT_CMD_SET_PERCENT_MEPD;
1085 cmd.params.ptr_set_percent_mepd = &mepd;
1086 mepd.sup_info_type = (T_BAT_percent_mepd_sup_info)sup_info_num;
1087
1088 bat_send(ati_bat_get_client(srcId), &cmd);
1089
1090 return ATI_EXCT; /* executing, because response is passed by callback function */
1091 }
1092 #else
1093 ret = qAT_PercentMEPD((T_ACI_CMD_SRC)srcId, &sup_info);
1094 if (ret EQ AT_CMPL)
1095 {
1096 resp_disp(srcId,cl,"b", &sup_info.datavalue);
1097 return (ATI_CMPL);
1098 }
1099 else
1100 {
1101 cmdCmeError(CME_ERR_OpNotAllow);
1102 return (ATI_FAIL);
1103 }
1104 #endif /* FF_ATI_BAT */
1105 }
1106
1107 #endif /* SIM_PERS */
1108 #endif /* ATI_SS_C */