comparison src/aci2/aci/ati_gprs.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 :
4 | Modul :
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 : GPRS AT Command Handler.
18 +-----------------------------------------------------------------------------
19 */
20
21 #if defined (GPRS) && defined (DTI)
22
23 #ifndef GACI_CMD_C
24 #define GACI_CMD_C
25 #endif
26
27 #undef DUMMY_ATI_STRINGS
28
29 #include "aci_all.h"
30
31 /*includes*/
32 #include "dti.h" /* functionality of the dti library */
33 #include "aci_cmh.h"
34 #include "ati_cmd.h"
35 #include "aci_io.h"
36 #include "aci_cmd.h"
37 #include "aci_lst.h"
38 #include "l4_tim.h"
39
40 #include "gdi.h"
41 #include "audio.h"
42 #include "p_sim.h"
43 #include "p_aci.h"
44 #include "aoc.h"
45 #include "aci.h"
46 #include "pcm.h"
47 #include "rx.h"
48 #include "pwr.h"
49
50 #include "dti_conn_mng.h"
51 #include "dti_cntrl_mng.h"
52
53 #include "gaci.h"
54 #include "gaci_cmh.h"
55 #include "psa.h"
56 #include "psa_sm.h"
57
58 #ifdef FAX_AND_DATA
59 //#include "aci_fd.h"
60 #endif
61
62 #include "cmh.h"
63 #include "cmh_sm.h"
64
65 #include "aci_io.h"
66 #include "aci_mem.h"
67
68 #if defined(FF_WAP) OR defined (FF_GPF_TCPIP) || defined (FF_SAT_E)
69 #include "gaci_srcc.h"
70 #include "psa_tcpip.h"
71 #include "wap_aci.h"
72 #endif /* defined(WAP) OR defined (FF_GPF_TCPIP) || defined (FF_SAT_E)*/
73
74 #include "gaci_cmd.h"
75 #include "aci_prs.h"
76
77 #include "ati_int.h"
78
79 #include "dcm_f.h"
80
81 #ifdef FF_ATI_BAT
82
83 #include "typedefs.h"
84 #include "gdd.h"
85 #include "bat.h"
86
87 #include "ati_bat.h"
88
89 #endif /*FF_ATI_BAT*/
90
91 EXTERN char *cmdErrStr;
92 EXTERN T_ACI_LIST *ati_src_list;
93
94 GLOBAL T_ATI_RSLT setatPlusCGDCONT (char *cl, UBYTE srcId);
95 GLOBAL T_ATI_RSLT setatPlusCGQREQ (char *cl, UBYTE srcId);
96 GLOBAL T_ATI_RSLT setatPlusCGQMIN (char *cl, UBYTE srcId);
97 GLOBAL T_ATI_RSLT setatPlusCGATT (char *cl, UBYTE srcId);
98 GLOBAL T_ATI_RSLT setatPlusCGACT (char *cl, UBYTE srcId);
99 GLOBAL T_ATI_RSLT setatPlusCGDATA (char *cl, UBYTE srcId);
100 GLOBAL T_ATI_RSLT setatPlusCGPADDR (char *cl, UBYTE srcId);
101 GLOBAL T_ATI_RSLT setatPlusCGAUTO (char *cl, UBYTE srcId);
102 GLOBAL T_ATI_RSLT setatPlusCGANS (char *cl, UBYTE srcId);
103 GLOBAL T_ATI_RSLT setatPlusCGCLASS (char *cl, UBYTE srcId);
104 GLOBAL T_ATI_RSLT setatPlusCGEREP (char *cl, UBYTE srcId);
105 GLOBAL T_ATI_RSLT setatPlusCGREG (char *cl, UBYTE srcId);
106 GLOBAL T_ATI_RSLT setatPlusCGSMS (char *cl, UBYTE srcId);
107 GLOBAL T_ATI_RSLT setatPercentCGEREP (char *cl, UBYTE srcId);
108
109 GLOBAL T_ATI_RSLT queatPlusCGDCONT (char *cl, UBYTE srcId);
110 GLOBAL T_ATI_RSLT queatPlusCGQREQ (char *cl, UBYTE srcId);
111 GLOBAL T_ATI_RSLT queatPlusCGQMIN (char *cl, UBYTE srcId);
112 GLOBAL T_ATI_RSLT queatPlusCGATT (char *cl, UBYTE srcId);
113 GLOBAL T_ATI_RSLT queatPlusCGACT (char *cl, UBYTE srcId);
114 GLOBAL T_ATI_RSLT queatPlusCGAUTO (char *cl, UBYTE srcId);
115 GLOBAL T_ATI_RSLT queatPlusCGCLASS (char *cl, UBYTE srcId);
116 GLOBAL T_ATI_RSLT queatPlusCGEREP (char *cl, UBYTE srcId);
117 GLOBAL T_ATI_RSLT queatPlusCGREG (char *cl, UBYTE srcId);
118 GLOBAL T_ATI_RSLT queatPlusCGSMS (char *cl, UBYTE srcId);
119 GLOBAL T_ATI_RSLT queatPercentCGEREP (char *cl, UBYTE srcId);
120
121 GLOBAL T_ATI_RSLT tesatPlusCGDCONT (char *cl, UBYTE srcId);
122 GLOBAL T_ATI_RSLT tesatPlusCGPADDR (char *cl, UBYTE srcId);
123 GLOBAL T_ATI_RSLT tesatPlusCGSMS (char *cl, UBYTE srcId);
124
125 GLOBAL T_ATI_RSLT atGD (char *cl, UBYTE srcId, BOOL *gprs_command);
126
127 GLOBAL T_ATI_RSLT setatPercentCGAATT (char *cl, UBYTE srcId);
128 GLOBAL T_ATI_RSLT queatPercentCGAATT (char *cl, UBYTE srcId);
129
130 GLOBAL T_ATI_RSLT setatPercentCGREG (char *cl, UBYTE srcId);
131 GLOBAL T_ATI_RSLT queatPercentCGREG (char *cl, UBYTE srcId);
132 GLOBAL T_ATI_RSLT queatPercentCGPCO (UBYTE srcId,USHORT cid);
133 GLOBAL T_ATI_RSLT setatPercentCGCLASS (CHAR *cl, UBYTE srcId);
134 GLOBAL T_ATI_RSLT queatPercentCGCLASS (CHAR *cl, UBYTE srcId);
135 /*
136 +------------------------------------------------------------------------------------+
137 | PROJECT : GPRS (8441) MODULE : GACI_CMD |
138 | STATE : finnished ROUTINE : gaci_ati_cmd_init_each_source |
139 +------------------------------------------------------------------------------------+
140
141 PURPOSE : initialize GACI relevant ATI parameters.
142 */
143
144 GLOBAL void gaci_ati_cmd_init_each_source( UBYTE srcId )
145 {
146 /* init +CGREG param */
147 ati_creg_init(srcId, PlusCGREG_CMD);
148
149 /* init %CGREG param */
150 ati_creg_init(srcId, PercentCGREG_CMD);
151
152 /* init %CGEREP param */
153 ati_user_output_cfg[srcId].Percent_CGEREP_stat = 0;
154 ati_user_output_cfg[srcId].CGEREP_mode = 0;
155 ati_user_output_cfg[srcId].CGEREP_bfr = 0;
156 }
157
158 /*
159 +--------------------------------------------------------------------+
160 | PROJECT : GPRS (8441) MODULE : GACI_CMD |
161 | STATE : finnished ROUTINE : atPlusCGDCONT |
162 +--------------------------------------------------------------------+
163
164 PURPOSE : +CGDCONT command ( PDP context definition )
165 */
166
167 #define MAGIC_EMPTY_APN "\x0ff"
168
169 GLOBAL T_ATI_RSLT setatPlusCGDCONT (char *cl, UBYTE srcId)
170 {
171 T_ACI_RETURN ret = AT_FAIL;
172 T_GPRS_CONT_REC inputCtxt = {MAGIC_EMPTY_APN,
173 "",
174 "",
175 CGDCONT_D_COMP_OMITTED,
176 CGDCONT_H_COMP_OMITTED,
177 {GPRS_QOS_OMITTED, GPRS_QOS_OMITTED, GPRS_QOS_OMITTED, GPRS_QOS_OMITTED, GPRS_QOS_OMITTED},
178 {GPRS_QOS_OMITTED, GPRS_QOS_OMITTED, GPRS_QOS_OMITTED, GPRS_QOS_OMITTED, GPRS_QOS_OMITTED} };
179 SHORT cid = GPRS_CID_OMITTED;
180 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
181
182 TRACE_FUNCTION("setatPlusCGDCONT ()");
183
184 cl=parse(cl,"rsssrr",&cid
185 ,(LONG)MAX_PDP_TYPE_LEN, inputCtxt.pdp_type
186 ,(LONG)MAX_APN_LEN, inputCtxt.apn
187 ,(LONG)MAX_PDP_ADDR_LEN, inputCtxt.pdp_addr
188 ,&inputCtxt.d_comp
189 ,&inputCtxt.h_comp);
190
191 if (!strcmp(inputCtxt.apn, MAGIC_EMPTY_APN))
192 {
193 /* if APN was ommitted then parse leaves the string untouched */
194 inputCtxt.apn[0]='\0'; /* so clear the apn */
195 }
196 else if (inputCtxt.apn[0] EQ '\0')
197 {
198 /* if entered APN was "", parse clears the buffer */
199 strcpy(inputCtxt.apn, MAGIC_EMPTY_APN); /* fill magic empty apn */
200 }
201
202 if ( !cl )
203 {
204 cmdCmeError(CME_ERR_OpNotAllow);
205 return (ATI_FAIL);
206 }
207
208 #ifdef FF_ATI_BAT
209
210 {
211 T_BAT_cmd_send cmd;
212 T_BAT_cmd_set_plus_cgdcont cgdcont;
213 UBYTE len;
214
215 cmd.ctrl_params = BAT_CMD_SET_PLUS_CGDCONT;
216 cmd.params.ptr_set_plus_cgdcont=&cgdcont;
217
218 cgdcont.cid=(T_BAT_pdp_cid)cid;
219
220 if (utl_strcasecmp((const char *)inputCtxt.pdp_type, (const char *)"ip"))
221 cgdcont.pdp_type=BAT_PDP_TYPE_NOT_PRESENT;
222 else
223 cgdcont.pdp_type=BAT_PDP_TYPE_IPV4;
224
225 len=strlen(inputCtxt.apn);
226
227 if (len<=BAT_MAX_APN_LEN)
228 {
229 cgdcont.v_apn=TRUE;
230 cgdcont.c_apn=(U8)len;
231 memcpy(cgdcont.apn,inputCtxt.apn,len);
232 }
233 else
234 {
235 cgdcont.v_apn=FALSE;
236 }
237
238 len=strlen(inputCtxt.pdp_addr);
239
240 if (len<=BAT_MAX_PDP_ADD)
241 {
242 cgdcont.v_pdp_addr=TRUE;
243 cgdcont.c_pdp_addr=(U8)len;
244 memcpy(cgdcont.pdp_addr,inputCtxt.pdp_addr,len);
245 }
246 else
247 {
248 cgdcont.v_pdp_addr=FALSE;
249 }
250
251 cgdcont.d_comp=(T_BAT_plus_cgdcont_d_comp)inputCtxt.d_comp;
252 cgdcont.h_comp=(T_BAT_plus_cgdcont_h_comp)inputCtxt.h_comp;
253
254 bat_send(ati_bat_get_client(srcId), &cmd);
255
256 src_params->curAtCmd=AT_CMD_CGDCONT;
257 return(ATI_EXCT);
258 }
259
260 #else
261
262 ret = sAT_PlusCGDCONT (srcId, cid ,&inputCtxt);
263 switch (ret)
264 {
265 case (AT_CMPL): /*operation completed*/
266 return (ATI_CMPL);
267 case (AT_EXCT):
268 src_params->curAtCmd = AT_CMD_CGDCONT;
269 return (ATI_EXCT);
270 default:
271 cmdCmeError(CME_ERR_Unknown); /*Command failed*/
272 return (ATI_FAIL);
273 }
274
275 #endif
276 }
277
278 GLOBAL T_ATI_RSLT queatPlusCGDCONT (char *cl, UBYTE srcId)
279 {
280 #ifndef FF_ATI_BAT
281 char *me="+CGDCONT: ";
282 T_ACI_RETURN ret = AT_FAIL;
283 T_GPRS_CONT_REC defCtxts[MAX_CID_PLUS_EINS];
284 SHORT cid_array[MAX_CID_PLUS_EINS];
285 int i = 0, pos = 0, pos2 = 0;
286 #endif
287
288 TRACE_FUNCTION("queatPlusCGDCONT ()");
289
290 #ifdef FF_ATI_BAT
291 {
292 T_BAT_cmd_send cmd;
293 T_BAT_no_parameter dummy;
294
295 cmd.ctrl_params = BAT_CMD_QUE_PLUS_CGDCONT;
296 dummy.bat_dummy = 0xFF;
297 cmd.params.ptr_que_plus_cgdcont = &dummy;
298 bat_send(ati_bat_get_client(srcId), &cmd);
299 return(ATI_EXCT);
300 }
301 #else
302
303 ret = qAT_PlusCGDCONT (srcId, &defCtxts, cid_array);
304 if (ret EQ AT_CMPL)
305 {
306 for ( i = 0; i < MAX_CID && cid_array[i] NEQ INVALID_CID; i++ )
307 {
308 if (!strcmp(defCtxts[i].apn, MAGIC_EMPTY_APN)) /* special empty APN detected, printout "" */
309 {
310 sprintf(g_sa,"%s%hd,\"%s\",\"\",\"%s\",%hd,%hd",
311 me,
312 cid_array[i],
313 defCtxts[i].pdp_type,
314 /* defCtxts[i].apn, */
315 defCtxts[i].pdp_addr,
316 defCtxts[i].d_comp,
317 defCtxts[i].h_comp );
318 }
319
320 else if (defCtxts[i].apn[0] == '\0')
321 { /* no APN defined, printout nothing */
322 sprintf(g_sa,"%s%hd,\"%s\",,\"%s\",%hd,%hd",
323 me,
324 cid_array[i],
325 defCtxts[i].pdp_type,
326 /* defCtxts[i].apn, */
327 defCtxts[i].pdp_addr,
328 defCtxts[i].d_comp,
329 defCtxts[i].h_comp );
330 }
331 else
332 { /* normal, printout the "apn" */
333 sprintf(g_sa,"%s%hd,\"%s\",\"%s\",\"%s\",%hd,%hd",
334 me,
335 cid_array[i],
336 defCtxts[i].pdp_type,
337 defCtxts[i].apn,
338 defCtxts[i].pdp_addr,
339 defCtxts[i].d_comp,
340 defCtxts[i].h_comp );
341 }
342 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
343 }
344 return (ATI_CMPL);
345 }
346 else
347 {
348 cmdCmeError(CME_ERR_Unknown);
349 return (ATI_FAIL);
350 }
351
352 #endif /*FF_ATI_BAT*/
353 }
354
355
356 GLOBAL T_ATI_RSLT tesatPlusCGDCONT (char *cl, UBYTE srcId)
357 {
358 char *me="+CGDCONT: ";
359
360 sprintf(g_sa,"%s(1-%d),\"IP\",,,(0),(0,1)",
361 me, MAX_CID );
362
363 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
364 return (ATI_CMPL);
365 }
366
367 /*
368 +--------------------------------------------------------------------+
369 | PROJECT : GPRS (8441) MODULE : GACI_CMD |
370 | STATE : finnished ROUTINE : atPlusCGQREQ |
371 +--------------------------------------------------------------------+
372
373 PURPOSE : +CGQREQ command (context QOS request)
374 */
375
376 GLOBAL T_ATI_RSLT setatPlusCGQREQ (char *cl, UBYTE srcId)
377 {
378 T_ACI_RETURN ret = AT_FAIL;
379 T_QOS input_qos = { ( UBYTE ) GPRS_QOS_OMITTED };
380 SHORT cid = GPRS_CID_OMITTED;
381 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
382
383 TRACE_FUNCTION("setatPlusCGQREQ ()");
384
385 cl=parse(cl,"raaaar",&cid
386 ,1L ,&input_qos.preced
387 ,1L ,&input_qos.delay
388 ,1L ,&input_qos.relclass
389 ,1L ,&input_qos.peak
390 ,&input_qos.mean);
391
392 if (cl EQ NULL)
393 {
394 cmdCmeError(CME_ERR_OpNotAllow);
395 return (ATI_FAIL);
396 }
397
398 if ( input_qos.preced NEQ GPRS_QOS_OMITTED )
399 input_qos.preced -= '0';
400 if ( input_qos.delay NEQ GPRS_QOS_OMITTED )
401 input_qos.delay -= '0';
402 if ( input_qos.relclass NEQ GPRS_QOS_OMITTED )
403 input_qos.relclass -= '0';
404 if ( input_qos.peak NEQ GPRS_QOS_OMITTED )
405 input_qos.peak -= '0';
406 if ( input_qos.mean EQ 0xff )
407 input_qos.mean = 0;
408
409 #ifdef FF_ATI_BAT
410
411 {
412 T_BAT_cmd_send cmd;
413 T_BAT_cmd_set_plus_cgqreq cgqreq;
414
415 cmd.ctrl_params = BAT_CMD_SET_PLUS_CGQREQ;
416 cmd.params.ptr_set_plus_cgqreq=&cgqreq;
417
418 cgqreq.cid=(T_BAT_pdp_cid)cid;
419 /*
420 if (input_qos.preced!=GPRS_QOS_OMITTED)
421 cgqreq.precedence=(T_BAT_precedence)input_qos.preced;
422 else
423 cgqreq.precedence=BAT_PRECEDENCE_NOT_PRESENT;
424
425 if (input_qos.delay!=GPRS_QOS_OMITTED)
426 cgqreq.delay=(T_BAT_delay)input_qos.delay;
427 else
428 cgqreq.delay=BAT_DELAY_NOT_PRESENT;
429
430 if (input_qos.relclass!=GPRS_QOS_OMITTED)
431 cgqreq.reliability=(T_BAT_reliability)input_qos.relclass;
432 else
433 cgqreq.reliability=BAT_RELIABILITY_NOT_PRESENT;
434
435 if (input_qos.peak!=GPRS_QOS_OMITTED)
436 cgqreq.peak=(T_BAT_peak)input_qos.peak;
437 else
438 cgqreq.peak=BAT_PEAK_NOT_PRESENT;
439
440 if (input_qos.mean)
441 cgqreq.mean=(T_BAT_mean)input_qos.mean;
442 else
443 cgqreq.mean=BAT_MEAN_NOT_PRESENT;
444 */
445
446 cgqreq.precedence = (T_BAT_precedence)input_qos.preced;
447 cgqreq.delay = (T_BAT_delay)input_qos.delay;
448 cgqreq.reliability = (T_BAT_reliability)input_qos.relclass;
449 cgqreq.peak = (T_BAT_peak)input_qos.peak;
450 cgqreq.mean = (T_BAT_mean)input_qos.mean;
451
452 bat_send(ati_bat_get_client(srcId), &cmd);
453
454 src_params->curAtCmd=AT_CMD_CGQREQ;
455 return(ATI_EXCT);
456 }
457
458 #else
459
460 ret = sAT_PlusCGQREQ (srcId, cid ,&input_qos);
461 switch (ret)
462 {
463 case (AT_CMPL): /*operation completed*/
464 return (ATI_CMPL);
465 case (AT_EXCT):
466 src_params->curAtCmd = AT_CMD_CGQREQ;
467 return (ATI_EXCT);
468 default:
469 cmdCmeError(CME_ERR_Unknown); /*Command failed*/
470 return (ATI_FAIL);
471 }
472
473 #endif
474 }
475
476 GLOBAL T_ATI_RSLT queatPlusCGQREQ (char *cl, UBYTE srcId)
477 {
478 #ifndef FF_ATI_BAT
479 char *me="+CGQREQ: ";
480 T_ACI_RETURN ret = AT_FAIL;
481 T_QOS *pdef_qos[MAX_CID_PLUS_EINS];
482 SHORT cid_array[MAX_CID_PLUS_EINS];
483 int i = 0;
484 #endif
485
486 TRACE_FUNCTION("queatPlusCGQREQ ()");
487
488 #ifdef FF_ATI_BAT
489 {
490 T_BAT_cmd_send cmd;
491 T_BAT_no_parameter dummy;
492
493 cmd.ctrl_params = BAT_CMD_QUE_PLUS_CGQREQ;
494 dummy.bat_dummy = 0xFF;
495 cmd.params.ptr_que_plus_cgqreq = &dummy;
496 bat_send(ati_bat_get_client(srcId), &cmd);
497 return(ATI_EXCT);
498 }
499 #else
500
501 ret=qAT_PlusCGQREQ (srcId, pdef_qos, cid_array);
502 if (ret EQ AT_CMPL)
503 {
504 for ( i = 0; i < MAX_CID && pdef_qos[i]; i++ )
505 {
506 sprintf(g_sa,"%s%hd,%d,%d,%d,%d,%d", me, cid_array[i],
507 pdef_qos[i]->preced,
508 pdef_qos[i]->delay,
509 pdef_qos[i]->relclass,
510 pdef_qos[i]->peak,
511 pdef_qos[i]->mean );
512
513 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
514 }
515 }
516 else
517 {
518 cmdCmeError(CME_ERR_Unknown);
519 return (ATI_FAIL);
520 }
521
522 return (map_aci_2_ati_rslt(ret));
523
524 #endif
525 }
526
527 /*
528 +--------------------------------------------------------------------+
529 | PROJECT : GPRS (8441) MODULE : GACI_CMD |
530 | STATE : finished ROUTINE : atPlusCGQMIN |
531 +--------------------------------------------------------------------+
532
533 PURPOSE : +CGQMIN command (context min QOS requirement)
534 */
535
536 GLOBAL T_ATI_RSLT setatPlusCGQMIN (char *cl, UBYTE srcId)
537 {
538 T_ACI_RETURN ret = AT_FAIL;
539 T_QOS input_qos = { ( UBYTE ) GPRS_QOS_OMITTED };
540 SHORT cid = GPRS_CID_OMITTED;
541 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
542
543 TRACE_FUNCTION("setatPlusCGQMIN ()");
544
545 cl=parse(cl,"raaaar",&cid
546 ,1L ,&input_qos.preced
547 ,1L ,&input_qos.delay
548 ,1L ,&input_qos.relclass
549 ,1L ,&input_qos.peak
550 ,&input_qos.mean);
551
552 if ( input_qos.preced NEQ GPRS_QOS_OMITTED )
553 input_qos.preced -= '0';
554 if ( input_qos.delay NEQ GPRS_QOS_OMITTED )
555 input_qos.delay -= '0';
556 if ( input_qos.relclass NEQ GPRS_QOS_OMITTED )
557 input_qos.relclass -= '0';
558 if ( input_qos.peak NEQ GPRS_QOS_OMITTED )
559 input_qos.peak -= '0';
560
561 if ( input_qos.mean EQ 0xff )
562 input_qos.mean = 0;
563
564 if ( !cl )
565 {
566 cmdCmeError(CME_ERR_OpNotAllow);
567 return (ATI_FAIL);
568 }
569
570 #ifdef FF_ATI_BAT
571
572 {
573 T_BAT_cmd_send cmd;
574 T_BAT_cmd_set_plus_cgqmin cgqmin;
575
576 cmd.ctrl_params = BAT_CMD_SET_PLUS_CGQMIN;
577 cmd.params.ptr_set_plus_cgqmin=&cgqmin;
578
579 cgqmin.cid=(T_BAT_pdp_cid)cid;
580 /*
581 if (input_qos.preced!=GPRS_QOS_OMITTED)
582 cgqmin.precedence=(T_BAT_precedence)input_qos.preced;
583 else
584 cgqmin.precedence=BAT_PRECEDENCE_NOT_PRESENT;
585
586 if (input_qos.delay!=GPRS_QOS_OMITTED)
587 cgqmin.delay=(T_BAT_delay)input_qos.delay;
588 else
589 cgqmin.delay=BAT_DELAY_NOT_PRESENT;
590
591 if (input_qos.relclass!=GPRS_QOS_OMITTED)
592 cgqmin.reliability=(T_BAT_reliability)input_qos.relclass;
593 else
594 cgqmin.reliability=BAT_RELIABILITY_NOT_PRESENT;
595
596 if (input_qos.peak!=GPRS_QOS_OMITTED)
597 cgqmin.peak=(T_BAT_peak)input_qos.peak;
598 else
599 cgqmin.peak=BAT_PEAK_NOT_PRESENT;
600
601 if (input_qos.mean)
602 cgqmin.mean=(T_BAT_mean)input_qos.mean;
603 else
604 cgqmin.mean=BAT_MEAN_NOT_PRESENT;
605 */
606
607 cgqmin.precedence = (T_BAT_precedence)input_qos.preced;
608 cgqmin.delay = (T_BAT_delay)input_qos.delay;
609 cgqmin.reliability = (T_BAT_reliability)input_qos.relclass;
610 cgqmin.peak = (T_BAT_peak)input_qos.peak;
611 cgqmin.mean = (T_BAT_mean)input_qos.mean;
612
613 bat_send(ati_bat_get_client(srcId), &cmd);
614
615 src_params->curAtCmd=AT_CMD_CGQMIN;
616 return(ATI_EXCT);
617 }
618
619 #else
620
621 ret = sAT_PlusCGQMIN (srcId, cid ,&input_qos);
622 switch (ret)
623 {
624 case (AT_CMPL): /*operation completed*/
625 return (ATI_CMPL);
626 case (AT_EXCT):
627 src_params->curAtCmd = AT_CMD_CGQMIN;
628 return (ATI_EXCT);
629 default:
630 cmdCmeError(CME_ERR_Unknown); /*Command failed*/
631 return (ATI_FAIL);
632 }
633 #endif
634 }
635
636 GLOBAL T_ATI_RSLT queatPlusCGQMIN (char *cl, UBYTE srcId)
637 {
638 #ifndef FF_ATI_BAT
639 char *me="+CGQMIN: ";
640 T_ACI_RETURN ret = AT_FAIL;
641 T_QOS *pdef_qos[MAX_CID_PLUS_EINS];
642 SHORT cid_array[MAX_CID_PLUS_EINS];
643 int i = 0;
644 #endif
645
646 TRACE_FUNCTION("queatPlusCGQMIN ()");
647
648 #ifdef FF_ATI_BAT
649 {
650 T_BAT_cmd_send cmd;
651 T_BAT_no_parameter dummy;
652
653 cmd.ctrl_params = BAT_CMD_QUE_PLUS_CGQMIN;
654 dummy.bat_dummy = 0xFF;
655 cmd.params.ptr_que_plus_cgqmin = &dummy;
656
657 bat_send(ati_bat_get_client(srcId), &cmd);
658
659 return(ATI_EXCT);
660 }
661 #else
662
663 ret=qAT_PlusCGQMIN (srcId, pdef_qos, cid_array);
664 if (ret EQ AT_CMPL)
665 {
666 for ( i = 0; i < MAX_CID && pdef_qos[i]; i++ )
667 {
668 sprintf(g_sa,"%s%hd,%d,%d,%d,%d,%d", me, cid_array[i],
669 pdef_qos[i]->preced,
670 pdef_qos[i]->delay,
671 pdef_qos[i]->relclass,
672 pdef_qos[i]->peak,
673 pdef_qos[i]->mean );
674
675 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
676 }
677 }
678 else
679 {
680 cmdCmeError(CME_ERR_Unknown);
681 return (ATI_FAIL);
682 }
683
684 return (map_aci_2_ati_rslt(ret));
685
686 #endif /*FF_ATI_BAT*/
687 }
688
689 /*
690 +--------------------------------------------------------------------+
691 | PROJECT : GPRS (8441) MODULE : GACI_CMD |
692 | STATE : finished ROUTINE : atPlusCGATT |
693 +--------------------------------------------------------------------+
694
695 PURPOSE : +CGATT command ( GPRS attach/detach )
696 */
697
698 GLOBAL T_ATI_RSLT setatPlusCGATT (char *cl, UBYTE srcId)
699 {
700 T_ACI_RETURN ret = AT_FAIL;
701 T_CGATT_STATE state = CGATT_STATE_OMITTED;
702 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
703
704 TRACE_FUNCTION("setatPlusCGATT ()");
705
706 cl=parse(cl,"d",&state);
707
708 if ( !cl )
709 {
710 cmdCmeError(CME_ERR_OpNotAllow);
711 return (ATI_FAIL);
712 }
713
714 #ifdef FF_ATI_BAT
715
716 {
717 T_BAT_cmd_send cmd;
718 T_BAT_cmd_set_plus_cgatt cgatt;
719
720 cmd.ctrl_params = BAT_CMD_SET_PLUS_CGATT;
721 cmd.params.ptr_set_plus_cgatt=&cgatt;
722
723 /*
724 * This relies on T_CGATT_STATE being identical to
725 * T_BAT_plus_cgatt_state.
726 */
727 cgatt.state=(T_BAT_plus_cgatt_state)state;
728
729 bat_send(ati_bat_get_client(srcId), &cmd);
730
731 src_params->curAtCmd=AT_CMD_CGATT;
732 return(ATI_EXCT);
733 }
734
735 #else
736
737 ret = sAT_PlusCGATT ( srcId, state );
738 switch (ret)
739 {
740 case (AT_CMPL): /*operation completed*/
741 return (ATI_CMPL);
742 case (AT_EXCT):
743 src_params->curAtCmd = AT_CMD_CGATT;
744 return (ATI_EXCT);
745 default:
746 cmdCmeError(CME_ERR_Unknown); /*Command failed*/
747 return (ATI_FAIL);
748 }
749
750 #endif /*FF_ATI_BAT*/
751 }
752
753 GLOBAL T_ATI_RSLT queatPlusCGATT (char *cl, UBYTE srcId)
754 {
755 #ifndef FF_ATI_BAT
756 char *me="+CGATT: ";
757 T_ACI_RETURN ret = AT_FAIL;
758 T_CGATT_STATE state = CGATT_STATE_OMITTED;
759 #endif
760
761 TRACE_FUNCTION("queatPlusCGATT ()");
762
763 #ifdef FF_ATI_BAT
764 {
765 T_BAT_cmd_send cmd;
766 T_BAT_no_parameter dummy;
767
768 cmd.ctrl_params = BAT_CMD_QUE_PLUS_CGATT;
769 dummy.bat_dummy = 0xFF;
770 cmd.params.ptr_que_plus_cgatt = &dummy;
771
772 bat_send(ati_bat_get_client(srcId), &cmd);
773
774 return(ATI_EXCT);
775 }
776 #else
777
778 ret = qAT_PlusCGATT(srcId, &state);
779 if (ret EQ AT_CMPL)
780 {
781 sprintf(g_sa,"%s%d", me, state);
782 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
783 }
784 else
785 {
786 cmdCmeError(CME_ERR_Unknown);
787 return (ATI_FAIL);
788 }
789
790 return (map_aci_2_ati_rslt(ret));
791
792 #endif /*FF_ATI_BAT*/
793 }
794
795
796 /*
797 +--------------------------------------------------------------------+
798 | PROJECT : GPRS (8441) MODULE : GACI_CMD |
799 | STATE : finished ROUTINE : atPlusCGCLASS |
800 +--------------------------------------------------------------------+
801
802 PURPOSE : +CGCLASS command (GPRS class change)
803 */
804
805 GLOBAL T_ATI_RSLT setatPlusCGCLASS (char *cl, UBYTE srcId)
806 {
807 char *me="+CGCLASS: ";
808 T_ACI_RETURN ret = AT_FAIL;
809 T_CGCLASS_CLASS m_class = CGCLASS_CLASS_OMITTED;
810 char test_class[3]="";
811 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
812
813 TRACE_FUNCTION("atPlusCGCLASS ()");
814
815 cl = parse (cl,"s", (LONG)3, &test_class );
816
817 switch (*test_class)
818 {
819 case 'A':
820 break;
821 case 'B':
822 m_class = CGCLASS_CLASS_B;
823 break;
824 case 'C':
825 switch(*(test_class + 1))
826 {
827 case 'G':
828 m_class = CGCLASS_CLASS_CG;
829 break;
830 case 'C':
831 m_class = CGCLASS_CLASS_CC;
832 break;
833 default:
834 break;
835 }
836 break;
837 default:
838 break;
839 }
840
841 if ( !cl || m_class == CGCLASS_CLASS_OMITTED )
842 {
843 cmdCmeError(CME_ERR_OpNotAllow);
844 return (ATI_FAIL);
845 }
846
847 #ifdef FF_ATI_BAT
848
849 {
850 T_BAT_cmd_send cmd;
851 T_BAT_cmd_set_plus_cgclass cgclass;
852
853 cmd.ctrl_params = BAT_CMD_SET_PLUS_CGCLASS;
854 cmd.params.ptr_set_plus_cgclass=&cgclass;
855
856 /*
857 * This relies on T_BAT_mobile_class and T_CGCLASS_CLASS
858 * being identical.
859 */
860 cgclass.mobile_class=(T_BAT_mobile_class)m_class;
861
862 bat_send(ati_bat_get_client(srcId), &cmd);
863
864 src_params->curAtCmd=AT_CMD_CGCLASS;
865 return(ATI_EXCT);
866 }
867
868 #else
869
870 ret = sAT_PlusCGCLASS ( srcId, m_class );
871 switch (ret)
872 {
873 case (AT_CMPL): /*operation completed*/
874 return (ATI_CMPL);
875 case (AT_EXCT):
876 src_params->curAtCmd = AT_CMD_CGCLASS;
877 return (ATI_EXCT);
878 default:
879 cmdCmeError(CME_ERR_Unknown); /*Command failed*/
880 return (ATI_FAIL);
881 }
882
883 #endif /*FF_ATI_BAT*/
884 }
885
886 GLOBAL T_ATI_RSLT queatPlusCGCLASS (char *cl, UBYTE srcId)
887 {
888
889 #ifndef FF_ATI_BAT
890 char *me="+CGCLASS: ";
891 char *classes[] = {"A","B","CG","CC"};
892 T_ACI_RETURN ret = AT_FAIL;
893 T_CGCLASS_CLASS m_class = CGCLASS_CLASS_OMITTED;
894 char test_class[3]="";
895 #endif
896
897 TRACE_FUNCTION("queatPlusCGCLASS ()");
898
899 #ifdef FF_ATI_BAT
900 {
901 T_BAT_cmd_send cmd;
902 T_BAT_no_parameter dummy;
903
904 cmd.ctrl_params = BAT_CMD_QUE_PLUS_CGCLASS;
905 dummy.bat_dummy = 0xFF;
906 cmd.params.ptr_que_plus_cgclass = &dummy;
907 bat_send(ati_bat_get_client(srcId), &cmd);
908 return(ATI_EXCT);
909 }
910 #else
911
912 ret = qAT_PlusCGCLASS(srcId, &m_class);
913 if (ret EQ AT_CMPL)
914 {
915 sprintf(g_sa,"%s\"%s\"", me, classes[m_class]);
916 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
917 }
918 else
919 {
920 cmdCmeError(CME_ERR_Unknown);
921 return (ATI_FAIL);
922 }
923
924 return (map_aci_2_ati_rslt(ret));
925
926 #endif /*FF_ATI_BAT*/
927 }
928
929
930 /*
931 +--------------------------------------------------------------------+
932 | PROJECT : GPRS (8441) MODULE : GACI_CMD |
933 | STATE : finnished ROUTINE : atPlusCGACT |
934 +--------------------------------------------------------------------+
935
936 PURPOSE : +CGACT command (context activation/deactivation)
937 */
938
939 GLOBAL T_ATI_RSLT setatPlusCGACT (char *cl, UBYTE srcId)
940 {
941 char *end;
942 T_ACI_RETURN ret = AT_FAIL;
943 T_CGACT_STATE state = CGACT_STATE_OMITTED;
944 SHORT count = 0;
945 SHORT cid, cid_array[MAX_CID_PLUS_EINS];
946 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
947
948 TRACE_FUNCTION("setatPlusCGACT ()");
949
950 end = cl;
951
952 if ( *cl != ',' )
953 state = (T_CGACT_STATE) strtol(cl, &end, 10);
954
955 while ( *end EQ ',' )
956 {
957 cl = end; /* advace to the next delimiter */
958 cl ++; /* skip the delimiter */
959 cid = INVALID_CID;
960
961 cid = ( SHORT ) strtol (cl, &end, 10);
962
963 if (cid < 1 || cid > MAX_CID || count >= MAX_CID)
964 {
965 cmdCmeError(CME_ERR_OpNotAllow);
966 return (ATI_FAIL);
967 }
968 cid_array[count] = cid;
969 count ++;
970 }
971
972 cid_array[count] = INVALID_CID;
973 cl = end;
974
975 #ifdef FF_ATI_BAT
976
977 {
978 T_BAT_cmd_send cmd;
979 T_BAT_cmd_set_plus_cgact cgact;
980 UBYTE n;
981
982 cmd.ctrl_params = BAT_CMD_SET_PLUS_CGACT;
983 cmd.params.ptr_set_plus_cgact=&cgact;
984
985 /*
986 * This relies on T_BAT_plus_cgact_state and T_CGACT_STATE
987 * being identical.
988 */
989 cgact.state=(T_BAT_plus_cgact_state)state;
990
991 for (n=0;((n<count) && (n<BAT_MAX_PDP_CID));n++)
992 cgact.cid[n]=(T_BAT_pdp_cid)cid_array[n];
993
994 cgact.c_cid=(U8)n;
995
996 bat_send(ati_bat_get_client(srcId), &cmd);
997
998 src_params->curAtCmd=AT_CMD_CGACT;
999 return(ATI_EXCT);
1000 }
1001
1002 #else
1003
1004 /* (De) Activate necessary contexts */
1005 ret = sAT_PlusCGACT ( srcId, state, cid_array );
1006 switch (ret)
1007 {
1008 case (AT_CMPL): /*operation completed*/
1009 return (ATI_CMPL);
1010 case (AT_EXCT):
1011 src_params->curAtCmd = AT_CMD_CGACT;
1012 return (ATI_EXCT);
1013 default:
1014 cmdCmeError(CME_ERR_Unknown); /*Command failed*/
1015 return (ATI_FAIL);
1016 }
1017
1018 #endif /*FF_ATI_BAT*/
1019 }
1020
1021 GLOBAL T_ATI_RSLT queatPlusCGACT (char *cl, UBYTE srcId)
1022 {
1023 #ifndef FF_ATI_BAT
1024 char *me="+CGACT: ";
1025 T_ACI_RETURN ret = AT_FAIL;
1026 SHORT count = 0;
1027 SHORT cid_array[MAX_CID_PLUS_EINS];
1028 BOOL states[MAX_CID_PLUS_EINS];
1029 #endif
1030
1031 TRACE_FUNCTION("queatPlusCGACT ()");
1032
1033 #ifdef FF_ATI_BAT
1034 {
1035 T_BAT_cmd_send cmd;
1036 T_BAT_no_parameter dummy;
1037
1038 cmd.ctrl_params = BAT_CMD_QUE_PLUS_CGACT;
1039 dummy.bat_dummy = 0xFF;
1040 cmd.params.ptr_que_plus_cgact = &dummy;
1041 bat_send(ati_bat_get_client(srcId), &cmd);
1042 return(ATI_EXCT);
1043 }
1044 #else
1045
1046 ret=qAT_PlusCGACT(srcId, states, cid_array);
1047 if (ret EQ AT_CMPL)
1048 {
1049 for ( count = 0; count < MAX_CID && cid_array[count] NEQ INVALID_CID; count++ )
1050 {
1051 sprintf(g_sa,"%s%hd,%d", me, cid_array[count], states[count] EQ TRUE? 1 : 0);
1052 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
1053 }
1054 }
1055 else
1056 {
1057 cmdCmeError(CME_ERR_Unknown);
1058 return (ATI_FAIL);
1059 }
1060
1061 return (map_aci_2_ati_rslt(ret));
1062
1063 #endif /*FF_ATI_BAT*/
1064 }
1065
1066
1067 /*
1068 +--------------------------------------------------------------------+
1069 | PROJECT : GPRS (8441) MODULE : GACI_CMD |
1070 | STATE : finnished ROUTINE : atPlusCGDATA |
1071 +--------------------------------------------------------------------+
1072
1073 PURPOSE : +CGDATA command (data connect)
1074 */
1075
1076 GLOBAL T_ATI_RSLT setatPlusCGDATA (char *cl, UBYTE srcId)
1077 {
1078 char L2P[MAX_L2P_LENGTH] = "", *end;
1079 T_ACI_RETURN ret = AT_FAIL;
1080 SHORT count = 0, stop = 1;
1081 SHORT cid_array[MAX_CID_PLUS_EINS] = { GPRS_CID_OMITTED };
1082 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
1083
1084 TRACE_FUNCTION("setatPlusCGDATA ()");
1085
1086 switch ( *cl )
1087 {
1088 case ',':
1089 /* the L2P is unspecified */
1090 *L2P = 0;
1091 break;
1092 case '\"':
1093 cl++;
1094 while (*cl && stop)
1095 {
1096 if ( *cl NEQ '\"' && count < MAX_L2P_LENGTH - 1 )
1097 {
1098 L2P[count] = *cl;
1099 count ++;
1100 cl ++;
1101 }
1102 else
1103 {
1104 L2P[count] = 0;
1105 stop = 0;
1106 }
1107 }
1108
1109 if ( *cl NEQ '\"' )
1110 { /* Bad user input, abort */
1111 cmdCmeError(CME_ERR_OpNotAllow);
1112 return (ATI_FAIL);
1113 }
1114
1115 cl++;
1116 break;
1117 case 0:
1118 break;
1119 default:
1120 /* Bad user input, abort */
1121 cmdCmeError(CME_ERR_OpNotAllow);
1122 return (ATI_FAIL);
1123 }
1124
1125 end = cl;
1126 count = 0;
1127 while ( *end EQ ',' )
1128 {
1129 cl = end;
1130 cl ++;
1131
1132 cid_array[count] = ( SHORT ) strtol (cl, &end, 10);
1133
1134 if ( count >= MAX_CID )
1135 {
1136 cmdCmeError(CME_ERR_OpNotAllow);
1137 return (ATI_FAIL);
1138 }
1139 count ++;
1140 }
1141
1142 if ( count )
1143 cid_array[count] = INVALID_CID;
1144
1145 cl = end;
1146
1147 /*
1148 * if no cid is given or if there is no matching context definition
1149 * the function sAT_PlusCGDATA will process this
1150 */
1151
1152 #ifdef FF_ATI_BAT
1153
1154 {
1155 T_BAT_cmd_send cmd;
1156 T_BAT_cmd_set_plus_cgdata cgdata;
1157 UBYTE n;
1158 UBYTE len;
1159
1160 cmd.ctrl_params = BAT_CMD_SET_PLUS_CGDATA;
1161 cmd.params.ptr_set_plus_cgdata=&cgdata;
1162
1163 cgdata.v_cid=FALSE;
1164
1165 if (count)
1166 {
1167 for (n=0;((n<count) && (n<BAT_MAX_PDP_CID));n++)
1168 cgdata.cid[n]=(T_BAT_pdp_cid)cid_array[n];
1169
1170 cgdata.c_cid=(U8)n;
1171 cgdata.v_cid=TRUE;
1172 }
1173
1174 cgdata.v_l2p=FALSE;
1175
1176 if (L2P[0])
1177 {
1178 if ((len=strlen(L2P))<=BAT_MAX_CGDATA_L2P_LEN)
1179 {
1180 cgdata.v_l2p=TRUE;
1181 memcpy(cgdata.l2p,L2P,len);
1182 cgdata.c_l2p=len;
1183 }
1184 }
1185 bat_send(ati_bat_get_client(srcId), &cmd);
1186
1187 src_params->curAtCmd=AT_CMD_CGDATA;
1188 return(ATI_EXCT);
1189 }
1190
1191 #else
1192
1193 /* establish communication between the TE and the network */
1194 ret = sAT_PlusCGDATA ( srcId, L2P, cid_array );
1195 switch (ret)
1196 {
1197 case (AT_CMPL): /*operation completed*/
1198 return (ATI_CMPL);
1199 case (AT_EXCT):
1200 cmdErrStr = NULL;
1201 src_params->curAtCmd = AT_CMD_CGDATA;
1202 return (ATI_EXCT);
1203 default:
1204 cmdCmeError(CME_ERR_Unknown); /*Command failed*/
1205 return (ATI_FAIL);
1206 }
1207
1208 #endif /*FF_ATI_BAT*/
1209 }
1210
1211 /*
1212 +--------------------------------------------------------------------+
1213 | PROJECT : GPRS (8441) MODULE : GACI_CMD |
1214 | STATE : code ROUTINE : atPlusCGPADDR |
1215 +--------------------------------------------------------------------+
1216
1217 PURPOSE : +CGPADDR command (show PDP addresses)
1218 active command returns a list of last used PDP addresses
1219 for specified cids. If unspecified, returns list for all
1220 defined cids.
1221 */
1222
1223 GLOBAL T_ATI_RSLT setatPlusCGPADDR (char *cl, UBYTE srcId)
1224 {
1225 char *me="+CGPADDR: ", *end;
1226 #ifndef FF_ATI_BAT
1227 T_ACI_RETURN ret;
1228 T_PDP_ADDRESS pdp_addresses[MAX_CID];
1229 #endif
1230
1231 SHORT count = 0;
1232 SHORT cid_array[MAX_CID_PLUS_EINS];
1233
1234 TRACE_FUNCTION("setatPlusCGPADDR ()");
1235
1236 do
1237 {
1238 cid_array[count] = ( SHORT ) strtol (cl, &end, 10);
1239 count ++;
1240 cl = end;
1241 if ( *cl EQ ',' )
1242 cl++;
1243 }
1244 while ( *end EQ ',' );
1245
1246 cid_array[count] = INVALID_CID;
1247 cl = end;
1248
1249 #ifdef FF_ATI_BAT
1250
1251 {
1252 T_BAT_cmd_send cmd;
1253 T_BAT_cmd_set_plus_cgpaddr cgpaddr;
1254 UBYTE n;
1255
1256 cmd.ctrl_params = BAT_CMD_SET_PLUS_CGPADDR;
1257 cmd.params.ptr_set_plus_cgpaddr=&cgpaddr;
1258
1259 cgpaddr.c_cid=0;
1260
1261 if (count)
1262 {
1263 for (n=0;((n<count) && (n<BAT_MAX_PDP_CID));n++)
1264 cgpaddr.cid[n]=(T_BAT_pdp_cid)cid_array[n];
1265
1266 cgpaddr.c_cid=(U8)n;
1267 }
1268 bat_send(ati_bat_get_client(srcId), &cmd);
1269 return(ATI_EXCT);
1270 }
1271
1272 #else
1273
1274 /* return a list of PDP addresses for the specified context identifier */
1275 ret = sAT_PlusCGPADDR ( srcId, cid_array, pdp_addresses );
1276 switch (ret)
1277 {
1278 case (AT_CMPL): /*operation completed*/
1279 count = 0;
1280 if (cid_array[0] NEQ INVALID_CID)
1281 {
1282 while ( cid_array[count] NEQ INVALID_CID )
1283 {
1284 if (*pdp_addresses[count])
1285 sprintf(g_sa,"%s%hd,\"%s\"", me, cid_array[count], pdp_addresses[count]);
1286 else
1287 sprintf(g_sa,"%s%hd", me, cid_array[count]);
1288
1289 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
1290 count ++;
1291 }
1292 }
1293 return (ATI_CMPL);
1294 default:
1295 cmdCmeError(CME_ERR_Unknown); /*Command failed*/
1296 return (ATI_FAIL);
1297 }
1298
1299 #endif /*FF_ATI_BAT*/
1300
1301 }
1302
1303 GLOBAL T_ATI_RSLT tesatPlusCGPADDR (char *cl, UBYTE srcId)
1304 {
1305 #ifndef FF_ATI_BAT
1306 char *me="+CGPADDR: ";
1307 T_ACI_RETURN ret;
1308 SHORT count = 0;
1309 SHORT cid_array[MAX_CID_PLUS_EINS];
1310 int pos = 0;
1311 #endif
1312
1313 TRACE_FUNCTION("tesatPlusCGPADDR ()");
1314
1315 #ifdef FF_ATI_BAT
1316 {
1317 T_BAT_cmd_send cmd;
1318 T_BAT_no_parameter dummy;
1319
1320 cmd.ctrl_params = BAT_CMD_TST_PLUS_CGPADDR;
1321 dummy.bat_dummy = 0xFF;
1322 cmd.params.ptr_tst_plus_cgpaddr = &dummy;
1323 bat_send(ati_bat_get_client(srcId), &cmd);
1324 return(ATI_EXCT);
1325 }
1326 #else
1327
1328 /* return a list of defined context identifier */
1329 ret = tAT_PlusCGPADDR ( srcId, cid_array );
1330 switch (ret)
1331 {
1332 case (AT_CMPL): /*operation completed*/
1333 pos = sprintf(g_sa,"%s(", me);
1334 while ( cid_array[count] NEQ INVALID_CID )
1335 {
1336 if ( count NEQ 0 )
1337 {
1338 g_sa[pos] = ','; pos++;
1339 }
1340 pos += sprintf(g_sa + pos,"%hd", cid_array[count]);
1341 count ++;
1342 }
1343 g_sa[pos] = ')'; pos++;
1344 g_sa[pos] = 0;
1345 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
1346 return (ATI_CMPL);
1347 default:
1348 cmdCmeError(CME_ERR_Unknown); /*Command failed*/
1349 return (ATI_FAIL);
1350 }
1351
1352 #endif /*FF_ATI_BAT*/
1353 }
1354
1355 /*
1356 +--------------------------------------------------------------------+
1357 | PROJECT : GPRS (8441) MODULE : GACI_CMD |
1358 | STATE : finnished ROUTINE : atPlusCGAUTO |
1359 +--------------------------------------------------------------------+
1360
1361 PURPOSE : +CGAUTO command (auto answer/modem compatibility control)
1362 */
1363
1364 GLOBAL T_ATI_RSLT setatPlusCGAUTO (char *cl, UBYTE srcId)
1365 {
1366 T_ACI_RETURN ret = AT_FAIL;
1367 T_CGAUTO_N n = CGAUTO_N_OMITTED; /* Invalid range value to detect an empty parameter */
1368 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
1369
1370 TRACE_FUNCTION("setatPlusCGAUTO ()");
1371
1372 cl = parse (cl,"d", &n );
1373 ret = sAT_PlusCGAUTO ( srcId, n );
1374 switch (ret)
1375 {
1376 case (AT_CMPL): /*operation completed*/
1377 at.rngPrms.srcID_CGAUTO = srcId;
1378 return (ATI_CMPL);
1379 case (AT_EXCT):
1380 src_params->curAtCmd = AT_CMD_CGATT;
1381 at.rngPrms.srcID_CGAUTO = srcId;
1382 return (ATI_EXCT);
1383 default:
1384 cmdCmeError(CME_ERR_Unknown); /*Command failed*/
1385 return (ATI_FAIL);
1386 }
1387 }
1388
1389 GLOBAL T_ATI_RSLT queatPlusCGAUTO (char *cl, UBYTE srcId)
1390 {
1391 char *me="+CGAUTO: ";
1392 T_ACI_RETURN ret = AT_FAIL;
1393 T_CGAUTO_N n = CGAUTO_N_OMITTED; /* Invalid range value to detect an empty parameter */
1394
1395 TRACE_FUNCTION("queatPlusCGAUTO ()");
1396
1397 ret = qAT_PlusCGAUTO(srcId, &n);
1398 if (ret EQ AT_CMPL)
1399 {
1400 sprintf(g_sa,"%s%hd", me, n);
1401 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
1402 }
1403 else
1404 {
1405 cmdCmeError(CME_ERR_Unknown);
1406 return (ATI_FAIL);
1407 }
1408
1409 return (map_aci_2_ati_rslt(ret));
1410 }
1411
1412 /*
1413 +--------------------------------------------------------------------+
1414 | PROJECT : GPRS (8441) MODULE : GACI_CMD |
1415 | STATE : code ROUTINE : atPlusCGANS |
1416 +--------------------------------------------------------------------+
1417
1418 PURPOSE : +CGANS command (answer NW context req)
1419 */
1420
1421 GLOBAL T_ATI_RSLT setatPlusCGANS (char *cl, UBYTE srcId)
1422 {
1423 char L2P[MAX_L2P_LENGTH] = "", *end;
1424 T_ACI_RETURN ret = AT_FAIL;
1425 SHORT cid = GPRS_CID_OMITTED, response = -1, count = 0, stop = 1;
1426 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
1427
1428 TRACE_FUNCTION("setatPlusCGANS ()");
1429
1430 response = ( SHORT ) strtol (cl, &end, 10);
1431 cl = end;
1432
1433 if ( *cl EQ ',' )
1434 {
1435 cl++;
1436 switch ( *cl )
1437 {
1438 case ',':
1439 /* the L2P is unspecified */
1440 *L2P = 0;
1441 break;
1442 case '\"':
1443 cl++;
1444 while (*cl && stop)
1445 {
1446 if ( *cl NEQ '\"' && count < MAX_L2P_LENGTH - 1 )
1447 {
1448 L2P[count] = *cl;
1449 count ++;
1450 cl ++;
1451 }
1452 else
1453 {
1454 L2P[count] = 0;
1455 stop = 0;
1456 }
1457 }
1458
1459 if ( *cl NEQ '\"' )
1460 { /* Bad user input, abort */
1461 cmdCmeError(CME_ERR_OpNotAllow);
1462 return (ATI_FAIL);
1463 }
1464
1465 cl++;
1466 break;
1467 default:
1468 /* Bad user input, abort */
1469 cmdCmeError(CME_ERR_OpNotAllow);
1470 return (ATI_FAIL);
1471 }
1472 if ( *cl EQ ',' )
1473 {
1474 cl++;
1475 cid = ( SHORT ) strtol (cl, &end, 10);
1476 cl = end;
1477 }
1478 }
1479
1480 #ifdef FF_ATI_BAT
1481 {
1482 T_BAT_cmd_send cmd;
1483 T_BAT_cmd_set_plus_cgans cgans;
1484 UBYTE len;
1485
1486 cmd.ctrl_params = BAT_CMD_SET_PLUS_CGANS;
1487 cmd.params.ptr_set_plus_cgans=&cgans;
1488
1489 cgans.cid=(T_BAT_pdp_cid)cid;
1490
1491 /*
1492 * This relies on T_BAT_plus_cgans_response and T_CGANS_RESPONSE
1493 * being identical.
1494 */
1495 cgans.response=(T_BAT_plus_cgans_response)response;
1496
1497 len=strlen(L2P);
1498
1499 cgans.v_l2p=FALSE;
1500
1501 if ((len) && (len<=BAT_MAX_CGANS_L2P_LEN))
1502 {
1503 memcpy(cgans.l2p,L2P,len);
1504 cgans.c_l2p=(U8)len;
1505 cgans.v_l2p=TRUE;
1506 }
1507 bat_send(ati_bat_get_client(srcId), &cmd);
1508
1509 src_params->curAtCmd=AT_CMD_CGANS;
1510
1511 if ((at.rngPrms.isRng==TRUE) && (at.rngPrms.mode==CRING_MOD_Gprs))
1512 ati_stop_ring();
1513
1514 return(ATI_EXCT);
1515 }
1516
1517 #else
1518
1519 /* return a list of PDP addresses for the specified context identifier */
1520 ret = sAT_PlusCGANS ( srcId, response, L2P, cid );
1521
1522 switch (ret)
1523 {
1524 case (AT_CMPL): /*operation completed*/
1525 return (ATI_CMPL);
1526
1527 case (AT_EXCT):
1528 src_params->curAtCmd = AT_CMD_CGANS;
1529 if ( at.rngPrms.isRng EQ TRUE AND
1530 at.rngPrms.mode EQ CRING_MOD_Gprs )
1531 {
1532 ati_stop_ring();
1533 }
1534 return (ATI_EXCT);
1535
1536 default:
1537 cmdCmeError(CME_ERR_Unknown); /*Command failed*/
1538 return (ATI_FAIL);
1539 }
1540
1541 #endif /*FF_ATI_BAT*/
1542 }
1543
1544 /*
1545 +--------------------------------------------------------------------+
1546 | PROJECT : GPRS (8441) MODULE : GACI_CMD |
1547 | STATE : code ROUTINE : setatPlusCGEREP |
1548 +--------------------------------------------------------------------+
1549
1550 PURPOSE : +CGEREP command
1551 */
1552
1553 GLOBAL T_ATI_RSLT setatPlusCGEREP (char *cl, UBYTE srcId)
1554 {
1555 T_ACI_RETURN ret;
1556 T_CGEREP_MODE mode = CGEREP_MODE_OMITTED;
1557 T_CGEREP_BFR bfr = CGEREP_BFR_OMITTED;
1558 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
1559
1560 TRACE_FUNCTION("setatPlusCGEREP ()");
1561
1562 cl=parse(cl,"dd",&mode, &bfr);
1563
1564 ret = sAT_PlusCGEREP ( srcId, mode, bfr );
1565 switch (ret)
1566 {
1567 case (AT_CMPL): /*operation completed*/
1568 return (ATI_CMPL);
1569 case (AT_EXCT):
1570 src_params->curAtCmd = AT_CMD_CGEREP;
1571 return (ATI_EXCT);
1572 default:
1573 cmdCmeError(CME_ERR_Unknown); /*Command failed*/
1574 return (ATI_FAIL);
1575 }
1576 }
1577
1578 GLOBAL T_ATI_RSLT queatPlusCGEREP (char *cl, UBYTE srcId)
1579 {
1580 char *me="+CGEREP: ";
1581 T_ACI_RETURN ret;
1582 T_CGEREP_MODE mode = CGEREP_MODE_OMITTED;
1583 T_CGEREP_BFR bfr = CGEREP_BFR_OMITTED;
1584
1585 TRACE_FUNCTION("queatPlusCGEREP ()");
1586
1587 ret=qAT_PlusCGEREP(srcId, &mode, &bfr);
1588 if (ret EQ AT_CMPL)
1589 {
1590 sprintf(g_sa,"%s%d,%d", me, mode, bfr);
1591 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
1592 }
1593 else
1594 {
1595 cmdCmeError(CME_ERR_Unknown);
1596 return (ATI_FAIL);
1597 }
1598
1599 return (map_aci_2_ati_rslt(ret));
1600 }
1601
1602 /*
1603 +--------------------------------------------------------------------+
1604 | PROJECT : GPRS (8441) MODULE : GACI_CMD |
1605 | STATE : code ROUTINE : atPercentCGEREP |
1606 +--------------------------------------------------------------------+
1607
1608 PURPOSE : %CGEREP command
1609 */
1610
1611 GLOBAL T_ATI_RSLT setatPercentCGEREP (char *cl, UBYTE srcId)
1612 {
1613 TRACE_FUNCTION("setatPercentCGEREP ()");
1614
1615 switch( *cl )
1616 {
1617 case '0':
1618 ati_user_output_cfg[srcId].Percent_CGEREP_stat = 0;
1619 return (ATI_CMPL);
1620
1621 case '1':
1622 ati_user_output_cfg[srcId].Percent_CGEREP_stat = 1;
1623 return (ATI_CMPL);
1624
1625 default:
1626 cmdCmeError(CME_ERR_OpNotAllow);
1627 return (ATI_FAIL);
1628 }
1629 }
1630
1631 GLOBAL T_ATI_RSLT queatPercentCGEREP (char *cl, UBYTE srcId)
1632 {
1633 char *me="%CGEREP: ";
1634 UBYTE mode;
1635
1636 TRACE_FUNCTION("queatPercentCGEREP ()");
1637
1638 mode = ati_user_output_cfg[srcId].Percent_CGEREP_stat;
1639
1640 sprintf(g_sa,"%s%d", me, mode);
1641 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
1642
1643 return (ATI_CMPL);
1644 }
1645
1646
1647 /*
1648 +--------------------------------------------------------------------+
1649 | PROJECT : GPRS (8441) MODULE : GACI_CMD |
1650 | STATE : code ROUTINE : setatPlusCGREG |
1651 +--------------------------------------------------------------------+
1652
1653 PURPOSE : +CGREG command
1654 */
1655
1656 GLOBAL T_ATI_RSLT setatPlusCGREG (char *cl, UBYTE srcId)
1657 {
1658 T_ATI_CREG_MOD mode=CREG_MOD_OFF;
1659
1660 TRACE_FUNCTION("setatPlusCGREG()");
1661
1662 cl=parse(cl,"d",&mode);
1663
1664 switch(mode)
1665 {
1666 case CREG_MOD_OFF:
1667 case CREG_MOD_ON:
1668 case CREG_MOD_LOC_INF_ON:
1669 /* user wants to set mode: reset CREG related ATI parameters */
1670 ati_creg_init(srcId, PlusCGREG_CMD);
1671 ati_gprs_user_output_cfg[srcId].plus_cgreg.mod_lac_cid.pres_mode = mode;
1672 return ATI_CMPL;
1673
1674 default:
1675 cmdCmeError(CME_ERR_OpNotAllow);
1676 return ATI_FAIL;
1677 }
1678 }
1679
1680 GLOBAL T_ATI_RSLT queatPlusCGREG (char *cl, UBYTE srcId)
1681 {
1682 #ifndef FF_ATI_BAT
1683 T_CGREG_STAT stat;
1684 USHORT lac, cid;
1685 T_ATI_CREG_MOD mode;
1686 short pos;
1687 #endif
1688
1689 TRACE_FUNCTION("queatPlusCGREG()");
1690
1691 #ifdef FF_ATI_BAT
1692 {
1693 T_BAT_cmd_send cmd;
1694 T_BAT_no_parameter dummy;
1695
1696 cmd.ctrl_params = BAT_CMD_QUE_PLUS_CGREG;
1697 dummy.bat_dummy = 0xFF;
1698 cmd.params.ptr_que_plus_cgreg = &dummy;
1699 bat_send(ati_bat_get_client(srcId), &cmd);
1700 return(ATI_EXCT);
1701 }
1702 #else
1703
1704 mode = ati_gprs_user_output_cfg[srcId].plus_cgreg.mod_lac_cid.pres_mode;
1705
1706 if (qAT_PlusCGREG(srcId, &stat, &lac, &cid) NEQ AT_CMPL)
1707 {
1708 cmdCmeError(CME_ERR_Unknown);
1709 return ATI_FAIL;
1710 }
1711
1712 pos = sprintf(g_sa, "+CGREG: %d,%d", mode, stat);
1713
1714 if(mode EQ CREG_MOD_LOC_INF_ON)
1715 {
1716 if(stat EQ CGREG_STAT_REG_HOME OR stat EQ CGREG_STAT_REG_ROAM)
1717 sprintf(g_sa+pos, ",\"%04X\",\"%04X\"", lac, cid);
1718 }
1719
1720 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
1721 return ATI_CMPL;
1722
1723 #endif /*FF_ATI_BAT*/
1724 }
1725
1726
1727 /*
1728 +--------------------------------------------------------------------+
1729 | PROJECT : GPRS (8441) MODULE : GACI_CMD |
1730 | STATE : code ROUTINE : setatPercentCGREG |
1731 +--------------------------------------------------------------------+
1732
1733 PURPOSE : %CGREG command
1734 */
1735
1736 GLOBAL T_ATI_RSLT setatPercentCGREG (char *cl, UBYTE srcId)
1737 {
1738 T_ATI_CREG_MOD mode=CREG_MOD_OFF;
1739
1740 TRACE_FUNCTION("setatPercentCGREG()");
1741
1742 cl=parse(cl,"d",&mode);
1743
1744 switch(mode)
1745 {
1746 case CREG_MOD_OFF:
1747 case CREG_MOD_ON:
1748 case CREG_MOD_LOC_INF_ON:
1749 case CREG_MOD_LOC_INF_ON_CTXACT:
1750 /* user wants to set mode: reset CREG related ATI parameters */
1751 ati_creg_init(srcId, PercentCGREG_CMD);
1752 ati_gprs_user_output_cfg[srcId].percent_cgreg.mod_lac_cid.pres_mode = mode;
1753 return ATI_CMPL;
1754
1755 default:
1756 cmdCmeError(CME_ERR_OpNotAllow);
1757 return ATI_FAIL;
1758 }
1759 }
1760
1761 GLOBAL T_ATI_RSLT queatPercentCGREG (char *cl, UBYTE srcId)
1762 {
1763 #ifndef FF_ATI_BAT
1764 T_P_CGREG_STAT stat;
1765 USHORT lac, cid;
1766 T_ATI_CREG_MOD mode;
1767 SHORT pos;
1768 #endif
1769
1770 TRACE_FUNCTION("queatPercentCGREG()");
1771
1772 #ifdef FF_ATI_BAT
1773 {
1774 T_BAT_cmd_send cmd;
1775 T_BAT_no_parameter dummy;
1776
1777 cmd.ctrl_params = BAT_CMD_QUE_PERCENT_CGREG;
1778 dummy.bat_dummy = 0xFF;
1779 cmd.params.ptr_que_plus_cgreg = &dummy;
1780
1781 bat_send(ati_bat_get_client(srcId), &cmd);
1782 return(ATI_EXCT);
1783 }
1784 #else
1785
1786 mode = ati_gprs_user_output_cfg[srcId].percent_cgreg.mod_lac_cid.pres_mode;
1787
1788 if (qAT_PercentCGREG(srcId, &stat, &lac, &cid) NEQ AT_CMPL)
1789 {
1790 cmdCmeError(CME_ERR_Unknown);
1791 return ATI_FAIL;
1792 }
1793
1794 pos = sprintf(g_sa,"%s: %d,%d", "%CGREG", mode, stat);
1795
1796 if (mode EQ CREG_MOD_LOC_INF_ON OR mode EQ CREG_MOD_LOC_INF_ON_CTXACT)
1797 {
1798 if (stat EQ P_CGREG_STAT_REG_HOME OR stat EQ P_CGREG_STAT_REG_ROAM)
1799 pos += sprintf(g_sa+pos, ",\"%04X\",\"%04X\"", lac, cid);
1800 else if (mode EQ CREG_MOD_LOC_INF_ON_CTXACT)
1801 pos += sprintf(g_sa+pos, ",,"); /* if CTXACT follows so lac and cid are ommitted */
1802 }
1803
1804 if (mode EQ CREG_MOD_LOC_INF_ON_CTXACT)
1805 sprintf(g_sa+pos, (cmhSM_isContextActive() ? ",1" : ",0"));
1806
1807 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
1808 return ATI_CMPL;
1809
1810 #endif /*FF_ATI_BAT*/
1811 }
1812
1813
1814 /*
1815 +--------------------------------------------------------------------+
1816 | PROJECT : GPRS (8441) MODULE : GACI_CMD |
1817 | STATE : code ROUTINE : atPlusCGSMS |
1818 +--------------------------------------------------------------------+
1819
1820 PURPOSE : +CGSMS command (define MO SMS behaviour)
1821 */
1822
1823 GLOBAL T_ATI_RSLT setatPlusCGSMS (char *cl, UBYTE srcId)
1824 {
1825 #ifndef FF_ATI_BAT
1826 T_ACI_RETURN ret;
1827 #endif
1828 T_CGSMS_SERVICE service = CGSMS_SERVICE_OMITTED; /* Invalid range value to detect an empty parameter */
1829 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
1830
1831 TRACE_FUNCTION("setatPlusCGSMS ()");
1832
1833 cl=parse(cl,"d",&service);
1834
1835 #ifdef FF_ATI_BAT
1836
1837 {
1838 T_BAT_cmd_send cmd;
1839 T_BAT_cmd_set_plus_cgsms cgsms;
1840
1841 cmd.ctrl_params = BAT_CMD_SET_PLUS_CGSMS;
1842 cmd.params.ptr_set_plus_cgsms=&cgsms;
1843
1844 /*
1845 * This relies on T_BAT_plus_cgsms_service and T_CGSMS_SERVICE
1846 * being identical.
1847 */
1848 cgsms.service=(T_BAT_plus_cgsms_service)service;
1849
1850 bat_send(ati_bat_get_client(srcId), &cmd);
1851
1852 src_params->curAtCmd=AT_CMD_CGSMS;
1853 return(ATI_EXCT);
1854 }
1855
1856 #else
1857
1858 ret = sAT_PlusCGSMS ( srcId, service );
1859 switch (ret)
1860 {
1861 case (AT_CMPL): /*operation completed*/
1862 return (ATI_CMPL);
1863 case (AT_EXCT):
1864 src_params->curAtCmd = AT_CMD_CGSMS;
1865 return (ATI_EXCT);
1866 default:
1867 cmdCmeError(CME_ERR_Unknown); /*Command failed*/
1868 return (ATI_FAIL);
1869 }
1870
1871 #endif /*FF_ATI_BAT*/
1872 }
1873
1874 GLOBAL T_ATI_RSLT queatPlusCGSMS (char *cl, UBYTE srcId)
1875 {
1876 #ifndef FF_ATI_BAT
1877 char *me="+CGSMS: ";
1878 T_ACI_RETURN ret;
1879 T_CGSMS_SERVICE service = CGSMS_SERVICE_OMITTED; /* Invalid range value to detect an empty parameter */
1880 #endif
1881
1882 TRACE_FUNCTION("queatPlusCGSMS ()");
1883
1884 #ifdef FF_ATI_BAT
1885 {
1886 T_BAT_cmd_send cmd;
1887 T_BAT_no_parameter dummy;
1888
1889 cmd.ctrl_params = BAT_CMD_QUE_PLUS_CGSMS;
1890 dummy.bat_dummy = 0xFF;
1891 cmd.params.ptr_que_plus_cgsms = &dummy;
1892 bat_send(ati_bat_get_client(srcId), &cmd);
1893 return(ATI_EXCT);
1894 }
1895 #else
1896
1897 ret = qAT_PlusCGSMS(srcId, &service);
1898 if (ret EQ AT_CMPL)
1899 {
1900 sprintf(g_sa,"%s%hd", me, service);
1901 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
1902 return (ATI_CMPL);
1903 }
1904 else
1905 {
1906 cmdCmeError(CME_ERR_Unknown);
1907 return (ATI_FAIL);
1908 }
1909
1910 #endif /*FF_ATI_BAT*/
1911 }
1912
1913 GLOBAL T_ATI_RSLT tesatPlusCGSMS (char *cl, UBYTE srcId)
1914 {
1915 char *me="+CGSMS: ", list[10] = "(0-3)";
1916 T_ACI_RETURN ret;
1917 T_CGSMS_SERVICE service = CGSMS_SERVICE_OMITTED; /* Invalid range value to detect an empty parameter */
1918 SHORT service_list;
1919
1920 TRACE_FUNCTION("tesatPlusCGSMS ()");
1921
1922 ret = tAT_PlusCGSMS ( srcId, &service_list );
1923 switch (ret)
1924 {
1925 case (AT_CMPL): /*operation completed*/
1926 if ( service_list NEQ 15 )
1927 {
1928 list[1] = service EQ 1 ? '0':'1';
1929 list[2] = ')';
1930 list[3] = 0;
1931 }
1932 cl++;
1933 sprintf(g_sa,"%s%s", me, list);
1934 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
1935 return (ATI_CMPL);
1936 default:
1937 cmdCmeError(CME_ERR_Unknown); /*Command failed*/
1938 return (ATI_FAIL);
1939 }
1940 }
1941
1942 /*
1943 +--------------------------------------------------------------------+
1944 | PROJECT : GPRS (8441) MODULE : GACI_CMD |
1945 | STATE : finnished ROUTINE : atGD |
1946 +--------------------------------------------------------------------+
1947
1948 PURPOSE : +ATD command
1949 */
1950
1951 GLOBAL T_ATI_RSLT atGD (char *cl, UBYTE srcId, BOOL *gprs_command)
1952 {
1953
1954 SHORT count = 0, cid_array[2] = { GPRS_CID_OMITTED, INVALID_CID }, i = 0;
1955 T_ACI_RETURN ret = AT_FAIL;
1956 char L2P[MAX_L2P_LENGTH] = "PPP", save_char, *p_save_char, *end;
1957 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
1958 int l2pID = -1;
1959
1960 TRACE_FUNCTION ("atGD()");
1961
1962 if (cl EQ NULL)
1963 {
1964 *gprs_command = FALSE;
1965 return (ATI_FAIL);
1966 }
1967
1968 /* ignore modifier */
1969 switch ( *cl )
1970 {
1971 case 'T':
1972 case 't':
1973 case 'P':
1974 case 'p':
1975 if ( *(cl + 1) EQ '*' )
1976 {
1977 cl ++;
1978 }
1979 else
1980 {
1981 *gprs_command = FALSE;
1982 return (ATI_FAIL);
1983 }
1984 break;
1985 case '*':
1986 break;
1987 default:
1988 *gprs_command = FALSE;
1989 return (ATI_FAIL);
1990 }
1991
1992 /* check the service code */
1993
1994 #if defined(FF_WAP) OR defined(FF_GPF_TCPIP) || defined (FF_SAT_E)
1995 if ( (*(cl + 1) NEQ '9') ||
1996 ( ( *(cl + 2) NEQ '9' ) && ( *(cl + 2) NEQ '8' ) ) )
1997 {
1998 *gprs_command = FALSE;
1999 return (ATI_FAIL);
2000 }
2001
2002 else if ( *(cl + 2) EQ '8' ) /* atd*98# -> WAP over GPRS */
2003 {
2004 /* if call not yet marked as WAP call, mark it now */
2005 if (!Wap_Call)
2006 {
2007 TRACE_EVENT ("ati_gprs, atGD, cmd is atd*98#");
2008 sAT_PercentWAP(srcId, 1);
2009 }
2010 l2pID = GPRS_CID_OMITTED;
2011 }
2012
2013 #else /* defined(WAP) OR defined(FF_GPF_TCPIP) || defined (FF_SAT_E)*/
2014 if ( *(cl + 1) NEQ '9' || *(cl + 2) NEQ '9' )
2015 {
2016 *gprs_command = FALSE;
2017 return (ATI_FAIL);
2018 }
2019 #endif /*defined(WAP) OR defined(FF_GPF_TCPIP) || defined (FF_SAT_E)*/
2020
2021 cl += 3;
2022 /* now *98 or *99 detected */
2023 /* the next character must be # or * for GPRS, otherwise this is USSD and not GPRS related! */
2024
2025 if (*cl NEQ '#' AND *cl NEQ '*')
2026 {
2027 *gprs_command = FALSE;
2028 return (ATI_FAIL);
2029 }
2030
2031 *gprs_command = TRUE;
2032
2033 /* parse the parameter list */
2034 while ( *cl EQ '*' )
2035 {
2036 count ++; /* count the parameter of the command */
2037 cl ++;
2038 p_save_char = strpbrk (cl, "*#" );
2039 if ( !p_save_char )
2040 { /* Bad user input*/
2041 cmdCmeError(CME_ERR_OpNotAllow);
2042 return (ATI_FAIL);
2043 }
2044
2045 #if defined(FF_WAP) OR defined(FF_GPF_TCPIP) || defined (FF_SAT_E)
2046 if( Wap_Call )
2047 {
2048 l2pID = *cl - '0';
2049 cl++;
2050 break;
2051 }
2052 else
2053 #endif /* defined(WAP) OR defined(FF_GPF_TCPIP) || defined (FF_SAT_E)*/
2054 {
2055 /* parse one parameter */
2056 switch ( count )
2057 {
2058 case 1: /* called_address */
2059 cl = p_save_char;
2060 break;
2061 case 2: /* L2P */
2062 if ( *cl NEQ '*' )
2063 {
2064 l2pID = (SHORT) strtol(cl, &end, 10);
2065
2066 if(cl + 1 EQ end)
2067 { /* L2P obmitted */
2068 l2pID = -1;
2069 }
2070 else if(-1 EQ l2pID)
2071 {
2072 cmdCmeError(CME_ERR_OpNotAllow);
2073 return (ATI_FAIL);
2074 }
2075 cl = end;
2076 }
2077 break;
2078 case 3: /* cid */
2079 save_char = *p_save_char;
2080 *p_save_char = 0;
2081
2082 cid_array[0] = (SHORT) strtol(cl, &end, 10);
2083
2084 *p_save_char = save_char;
2085
2086 cl = end;
2087 break;
2088 default:
2089 /* Bad user input*/
2090 cmdCmeError(CME_ERR_OpNotAllow);
2091 return (ATI_FAIL);
2092 }
2093 }
2094
2095 } /* while */
2096
2097 /* check end of line charakter */
2098 if ( *cl NEQ '#')
2099 { /* Bad user input*/
2100 cmdCmeError(CME_ERR_OpNotAllow);
2101 return (ATI_FAIL);
2102 }
2103
2104 #if defined(FF_WAP) OR defined(FF_GPF_TCPIP) || defined (FF_SAT_E)
2105 if ( Wap_Call )
2106 {
2107 BYTE options;
2108 SHORT j = 0;
2109 SRCC_LINK_NO link_no = SRCC_INVALID_LINK;
2110 /* process WAP over GPRS */
2111
2112 /*
2113 *-------------------------------------------------------------------
2114 * check entity status
2115 *-------------------------------------------------------------------
2116 */
2117 if( smEntStat.curCmd NEQ AT_CMD_NONE )
2118 return( ATI_BUSY );
2119
2120 cid_array[0] = l2pID;
2121
2122 if(is_gpf_tcpip_call()) {
2123 GPF_TCPIP_STATEMENT(link_no = SRCC_TCPIP_SNDCP_LINK);
2124 }
2125 else {
2126 link_no = SRCC_IP_SNDCP_LINK;
2127 }
2128 /* check number of context */
2129 if ( TRUE NEQ srcc_reserve_sources( link_no, 1 ) )
2130 {
2131 TRACE_EVENT ("srcc_reserve_sources failed!");
2132 cmdCmeError(CME_ERR_Unknown);
2133 return ( ATI_FAIL );
2134 }
2135
2136 if ( cmhSM_define_cid_list( srcId, cid_array ) EQ 0) /* process cid list */
2137 {
2138 TRACE_EVENT ("*** cmhSM_define_cid_list failed! ***");
2139 cmdCmeError(CME_ERR_Unknown);
2140 return( ATI_FAIL );
2141 }
2142
2143 /* get dti id */
2144 srcc_new_count(link_no);
2145
2146 wap_dti_id = dti_cntrl_new_dti(DTI_DTI_ID_NOTPRESENT);
2147 pdp_context[work_cids[cid_pointer] - 1].link_id_new =
2148 dti_conn_compose_link_id (0,0, wap_dti_id, DTI_TUPLE_NO_NOTPRESENT );
2149 pdp_context[work_cids[cid_pointer] - 1].owner = srcId;
2150
2151 TRACE_EVENT_P1 ("ati_gprs, atGD, link_id_new = %0X", pdp_context[work_cids[0] - 1].link_id_new);
2152
2153 /* set IP options */
2154 if(is_gpf_tcpip_call()) {
2155 options = TCPIP_ACT_OPTION_V4 | TCPIP_ACT_OPTION_TCPIP;
2156 }
2157 else {
2158 options = TCPIP_ACT_OPTION_V4 | TCPIP_ACT_OPTION_UDP;
2159 }
2160
2161 /* send request to ACI WAP to activate WAP */
2162 smShrdPrm.owner = srcId;
2163 smEntStat.entOwn = smShrdPrm.owner;
2164 smEntStat.curCmd = AT_CMD_CGDATA;
2165
2166 if(src_params)
2167 {
2168 src_params->curAtCmd = AT_CMD_CGDATA;
2169 }
2170
2171 psaTCPIP_Activate( srcId, wap_dti_id,
2172 wapId, options, TCPIP_CONNECTION_TYPE_GPRS_WAP,
2173 cmhSM_IP_activate_cb);
2174 return (ATI_EXCT);
2175
2176 }
2177 #endif /* defined(WAP) OR defined(FF_GPF_TCPIP) || defined (FF_SAT_E) */
2178 /*
2179 * patch for testing of network requested context activation
2180 * and answer by dial-up-network (ATD -> ATA)
2181 */
2182 if ( cmhSM_sAT_A( srcId, &ret ) EQ TRUE )
2183 {
2184 switch (ret)
2185 {
2186 case (AT_CMPL): /*operation completed*/
2187 return (ATI_CMPL);
2188 case (AT_EXCT):
2189 if(src_params)
2190 {
2191 src_params->curAtCmd = AT_CMD_CGANS;
2192 }
2193 return (ATI_EXCT);
2194 default:
2195 cmdCmeError(CME_ERR_Unknown); /*Command failed*/
2196 return (ATI_FAIL);
2197 }
2198 }
2199 else
2200 {
2201 /* process function */
2202 switch(l2pID)
2203 {
2204 case -1: /* L2P obmitted */
2205 case 1: /* PPP */
2206 break;
2207
2208 #if defined(FF_PKTIO) OR defined(FF_TCP_IP) || defined(FF_GPF_TCPIP) OR defined (FF_PSI)
2209 case 901: /* M-PKT */
2210 strcpy(L2P, "M-PKT");
2211 break;
2212 #endif /* FF_PKTIO || FF_TCP_IP || FF_GPF_TCPIP OR FF_PSI */
2213 case 0: /* NULL - not supported at this moment -> use CGACT */
2214 default:
2215 cmdCmeError(CME_ERR_Unknown); /*Command failed*/
2216 return (ATI_FAIL);
2217 }
2218
2219 ret = sAT_PlusCGDATA ( srcId, L2P, cid_array );
2220 switch (ret)
2221 {
2222 case (AT_CMPL): /*operation completed*/
2223 return (ATI_CMPL);
2224 case (AT_EXCT):
2225 if(src_params)
2226 {
2227 src_params->curAtCmd = AT_CMD_CGDATA;
2228 }
2229 return (ATI_EXCT);
2230 case (AT_BUSY):
2231 cmdCmeError(CME_ERR_Unknown); /*Command failed*/
2232 return (ATI_FAIL);
2233 default:
2234 cmdCmeError(CME_ERR_NotPresent); /*Command failed*/
2235 return (ATI_FAIL);
2236 }
2237 }
2238 }
2239
2240
2241 /*
2242 +--------------------------------------------------------------------+
2243 | PROJECT : GPRS (8441) MODULE : GACI_CMD |
2244 | STATE : finished ROUTINE : setatPercentCGAATT |
2245 +--------------------------------------------------------------------+
2246
2247 PURPOSE : %CGAATT command ( GPRS automatic attach mode )
2248 */
2249
2250 GLOBAL T_ATI_RSLT setatPercentCGAATT (char *cl, UBYTE srcId)
2251 {
2252
2253 T_ACI_RETURN ret = AT_FAIL;
2254 T_CGAATT_ATTACH_MODE att_m = CGAATT_ATTACH_MODE_OMITTED;
2255 T_CGAATT_DETACH_MODE det_m = CGAATT_DETACH_MODE_OMITTED;
2256
2257 TRACE_FUNCTION("setatPercentCGAATT ()");
2258
2259 cl=parse(cl,"dd",&att_m, &det_m);
2260
2261 #ifdef FF_ATI_BAT
2262
2263 {
2264 T_BAT_cmd_send cmd;
2265 T_BAT_cmd_set_percent_cgaatt cgaatt;
2266
2267 cmd.ctrl_params = BAT_CMD_SET_PERCENT_CGAATT;
2268 cmd.params.ptr_set_percent_cgaatt=&cgaatt;
2269
2270 /*
2271 * This relies on T_CGAATT_ATTACH_MODE and T_GGAATT_DETACH_MODE being
2272 * identical to T_BAT_percent_cgaatt_att_m and T_BAT_percent_cgaatt_det_m.
2273 */
2274 cgaatt.att_m=(T_BAT_percent_cgaatt_att_m)att_m;
2275 cgaatt.det_m=(T_BAT_percent_cgaatt_det_m)det_m;
2276
2277 bat_send(ati_bat_get_client(srcId), &cmd);
2278 return(ATI_EXCT);
2279 }
2280
2281 #else
2282
2283 ret = sAT_PercentCGAATT ( srcId, att_m, det_m );
2284 switch (ret)
2285 {
2286 case (AT_CMPL): /*operation completed*/
2287 return (ATI_CMPL);
2288 case (AT_EXCT):
2289 default:
2290 cmdCmeError(CME_ERR_Unknown); /*Command failed*/
2291 return (ATI_FAIL);
2292 }
2293
2294 #endif /*FF_ATI_BAT*/
2295 }
2296
2297 GLOBAL T_ATI_RSLT queatPercentCGAATT (char *cl, UBYTE srcId)
2298 {
2299 #ifndef FF_ATI_BAT
2300 T_ACI_RETURN ret;
2301 T_CGAATT_ATTACH_MODE att_m = CGAATT_ATTACH_MODE_OMITTED;
2302 T_CGAATT_DETACH_MODE det_m = CGAATT_DETACH_MODE_OMITTED;
2303 #endif
2304
2305 TRACE_FUNCTION("atPercentCGAATT ()");
2306
2307 #ifdef FF_ATI_BAT
2308 {
2309 T_BAT_cmd_send cmd;
2310 T_BAT_no_parameter dummy;
2311
2312 cmd.ctrl_params = BAT_CMD_QUE_PERCENT_CGAATT;
2313 dummy.bat_dummy = 0xFF;
2314 cmd.params.ptr_que_percent_cgaatt = &dummy;
2315 bat_send(ati_bat_get_client(srcId), &cmd);
2316 return(ATI_EXCT);
2317 }
2318 #else
2319
2320 ret = qAT_PercentCGAATT(srcId, &att_m, &det_m);
2321 if (ret EQ AT_CMPL)
2322 {
2323 sprintf(g_sa,"%s: %d,%d", "%CGAATT", att_m, det_m);
2324 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
2325 return (ATI_CMPL);
2326 }
2327 else
2328 {
2329 cmdCmeError(CME_ERR_Unknown);
2330 return (ATI_FAIL);
2331 }
2332
2333 #endif /*FF_ATI_BAT*/
2334 }
2335
2336 /*
2337 +--------------------------------------------------------------------+
2338 | PROJECT : GPRS (8441) MODULE : GACI_CMD |
2339 | STATE : finished ROUTINE : setatPercentSNCNT |
2340 +--------------------------------------------------------------------+
2341
2342 PURPOSE : %SNCNT command ( SNDCP Counter )
2343 = 0: reset SNCNT counter.
2344 ?: ask for current count.
2345 */
2346
2347 GLOBAL T_ATI_RSLT setatPercentSNCNT (CHAR *cl, UBYTE srcId)
2348 {
2349 T_ACI_RETURN ret = AT_CMPL;
2350
2351 TRACE_FUNCTION("setatPercentSNCNT ()");
2352
2353 if( *cl NEQ '0' )
2354 {
2355 cmdCmeError(CME_ERR_OpNotAllow);
2356 return (ATI_FAIL);
2357 }
2358
2359 cl++;
2360
2361 #ifdef FF_ATI_BAT
2362
2363 {
2364 T_BAT_cmd_send cmd;
2365 T_BAT_cmd_set_percent_sncnt sncnt;
2366
2367 cmd.ctrl_params = BAT_CMD_SET_PERCENT_SNCNT;
2368 cmd.params.ptr_set_percent_sncnt=&sncnt;
2369
2370 sncnt.rst=BAT_P_SNCNT_RESET_RESET;
2371
2372 bat_send(ati_bat_get_client(srcId), &cmd);
2373 return(ATI_EXCT);
2374 }
2375
2376 #else
2377
2378 /* AT%SNCNT = 0 resets counter */
2379 ret = sAT_PercentSNCNT( srcId, TRUE );
2380
2381 return (map_aci_2_ati_rslt(ret));
2382
2383 #endif /*FF_ATI_BAT*/
2384 }
2385
2386 GLOBAL T_ATI_RSLT queatPercentSNCNT (CHAR *cl, UBYTE srcId)
2387 {
2388 T_ACI_RETURN ret = AT_CMPL;
2389
2390 TRACE_FUNCTION("queatPercentSNCNT ()");
2391
2392 #ifdef FF_ATI_BAT
2393 {
2394 T_BAT_cmd_send cmd;
2395 T_BAT_no_parameter dummy;
2396
2397 cmd.ctrl_params = BAT_CMD_QUE_PERCENT_SNCNT;
2398 dummy.bat_dummy = 0xFF;
2399 cmd.params.ptr_que_percent_sncnt = &dummy;
2400 bat_send(ati_bat_get_client(srcId), &cmd);
2401 return(ATI_EXCT);
2402 }
2403
2404 #else
2405
2406 /* AT%SNCNT? returns current counter without resetting */
2407 ret = sAT_PercentSNCNT( srcId, FALSE );
2408
2409 return (map_aci_2_ati_rslt(ret));
2410
2411 #endif /*FF_ATI_BAT*/
2412 }
2413
2414 /*
2415 +--------------------------------------------------------------------+
2416 | PROJECT : GPRS (8441) MODULE : GACI_CMD |
2417 | STATE : finished ROUTINE : setatPercentCGMM |
2418 +--------------------------------------------------------------------+
2419
2420 PURPOSE : %CGMM command ( Configure GMM )
2421 %CGMM = cipher_on, tlli_handling
2422 */
2423
2424 GLOBAL T_ATI_RSLT setatPercentCGMM(CHAR *cl, UBYTE srcId)
2425 {
2426 T_ACI_RETURN ret = AT_CMPL;
2427 USHORT cipher_on, tlli_handling;
2428
2429 cl=parse(cl, "rr", &cipher_on, &tlli_handling);
2430
2431 if(!cl)
2432 {
2433 cmdCmeError(CME_ERR_OpNotAllow);
2434 return (ATI_FAIL);
2435 }
2436
2437 #ifdef FF_ATI_BAT
2438 {
2439 T_BAT_cmd_send cmd;
2440 T_BAT_cmd_set_percent_cgmm my_bat_set_percent_cgmm;
2441
2442 TRACE_FUNCTION("setatPercentCGMM() calls bat_send() <=== as APPLICATION");
2443
2444 memset(&my_bat_set_percent_cgmm, 0, sizeof(my_bat_set_percent_cgmm));
2445 cmd.ctrl_params = BAT_CMD_SET_PERCENT_CGMM;
2446 cmd.params.ptr_set_percent_cgmm = &my_bat_set_percent_cgmm;
2447
2448 my_bat_set_percent_cgmm.cipher_on = cipher_on;
2449 my_bat_set_percent_cgmm.tlli_handling = tlli_handling;
2450
2451 bat_send(ati_bat_get_client(srcId), &cmd);
2452
2453 return ATI_EXCT; /* executing, because response is passed by callback function */
2454 }
2455 #else /* OLD FUNCTION BODY */
2456
2457 TRACE_FUNCTION("setatPercentCGMM()");
2458
2459 ret = sAT_PercentCGMM( srcId, (UBYTE)cipher_on, (UBYTE)tlli_handling );
2460
2461 if (ret NEQ AT_CMPL)
2462 {
2463 cmdCmeError(CME_ERR_Unknown);
2464 return (ATI_FAIL);
2465 }
2466 return (ATI_CMPL);
2467
2468 #endif /* no FF_ATI_BAT*/
2469 }
2470
2471
2472 GLOBAL T_ATI_RSLT setatPercentCGPCO_HEX (USHORT cid,
2473 UBYTE *pco_hex_string, USHORT len)
2474 {
2475 USHORT pco_len;
2476 UBYTE *pco_array;
2477 int i;
2478
2479 ACI_MALLOC (pco_array, ACI_PCO_MAX_LEN + 1);
2480
2481 pco_len = utl_HexStrToBin (pco_hex_string, len,
2482 pco_array, ACI_PCO_MAX_LEN + 1);
2483 if (pco_len EQ 0)
2484 {
2485 cmdCmeError (CME_ERR_InvalidTxtChar);
2486 ACI_MFREE (pco_array);
2487 return (ATI_FAIL);
2488 }
2489
2490 if (cid EQ 0)
2491 {
2492 for (i = 0; i < MAX_CID; i++)
2493 {
2494 pdp_context[i].user_pco.len = (UBYTE)pco_len;
2495 memcpy (pdp_context[i].user_pco.pco, pco_array, pco_len);
2496 }
2497 }
2498 else
2499 {
2500 pdp_context[cid - 1].user_pco.len = (UBYTE)pco_len;
2501 memcpy (pdp_context[cid - 1].user_pco.pco, pco_array, pco_len);
2502 }
2503
2504 ACI_MFREE (pco_array);
2505
2506 return (ATI_CMPL);
2507 }
2508
2509 GLOBAL T_ATI_RSLT setatPercentCGPCO_ASCII (UBYTE srcId, USHORT cid,
2510 UBYTE *pco_ascii_string, USHORT len)
2511 {
2512 CHAR aut_prot[5];
2513 CHAR user[MAX_USER_LEN+1]; /* + '\0' */
2514 CHAR pwd[MAX_PWD_LEN+1]; /* + '\0' */
2515 CHAR dns1[MAX_DNS_LEN];
2516 CHAR dns2[MAX_DNS_LEN];
2517 CHAR *cl;
2518
2519 TRACE_FUNCTION("setatPercentCGPCO_ASCII():");
2520
2521 /* Initialize arrays */
2522 user[0] = '\0';
2523 pwd[0] = '\0';
2524 dns1[0] = '\0';
2525 dns2[0] = '\0';
2526
2527 cl = parse ((CHAR*)pco_ascii_string, "qqqqq",
2528 sizeof (aut_prot), aut_prot,
2529 sizeof (user), user, sizeof (pwd), pwd, sizeof(dns1), dns1, sizeof(dns2), dns2);
2530
2531 if(cl EQ NULL)
2532 {
2533 cmdCmeError (CME_ERR_InvalidTxtChar);
2534 return (ATI_FAIL);
2535 }
2536 if (strcmp (aut_prot, "PAP"))
2537 {
2538 cmdCmeError (CME_ERR_OpNotSupp);
2539 return (ATI_FAIL);
2540 }
2541
2542 if (sAT_PercentCGPCO (srcId, cid,
2543 ACI_PCO_AUTH_PROT_PAP, user, pwd, dns1, dns2) EQ AT_FAIL)
2544 {
2545 cmdCmeError (CME_ERR_Unknown);
2546 return (ATI_FAIL);
2547 }
2548
2549 return (ATI_CMPL);
2550 }
2551
2552 /*
2553 +--------------------------------------------------------------------+
2554 | PROJECT : GPRS MODULE : ATI_GPRS |
2555 | STATE : finished ROUTINE : ipaddr_to_string |
2556 +--------------------------------------------------------------------+
2557
2558 PURPOSE : print the IP address (little endian!) to the supplied string.
2559
2560 */
2561 GLOBAL void ipaddr_to_string(ULONG ipaddr, char *ipaddr_string)
2562 {
2563 UBYTE *addrbyte_p ; /* Pointer to single address bytes. */
2564
2565 if (ipaddr_string)
2566 {
2567 addrbyte_p = (UBYTE *) &ipaddr ;
2568 if (ipaddr NEQ 0)
2569 {
2570 /* This is for little endian *only*! */
2571 sprintf(ipaddr_string,"%u.%u.%u.%u",
2572 addrbyte_p[3], addrbyte_p[2], addrbyte_p[1], addrbyte_p[0]);
2573 }
2574 else
2575 {
2576 *ipaddr_string = '\0' ;
2577 }
2578 }
2579 }
2580
2581
2582 /*
2583 +--------------------------------------------------------------------+
2584 | PROJECT : GPRS MODULE : GACI_CMD |
2585 | STATE : finished ROUTINE : queatPercentCGPCO |
2586 +--------------------------------------------------------------------+
2587
2588 PURPOSE : %CGPCO command
2589 * query network pco for cid
2590 */
2591
2592 GLOBAL T_ATI_RSLT queatPercentCGPCO (UBYTE srcId, USHORT cid)
2593 {
2594 char *me="%CGPCO: ";
2595 ULONG gateway,dns1,dns2;
2596 char dns1_str[sizeof("255.255.255.255")];
2597 char dns2_str[sizeof("255.255.255.255")];
2598 char gatew_str[sizeof("255.255.255.255")];
2599 USHORT i; /* Counter for loop over context IDs. */
2600
2601 TRACE_FUNCTION("queatPercentCGPCO( )");
2602
2603 if(!cid) /* for all available cid's: recurse */
2604 {
2605 for (i=1; i<MAX_CID; i++)
2606 {
2607 queatPercentCGPCO(srcId, i) ;
2608 }
2609 }
2610 else /* for a specific cid */
2611 {
2612 gateway = dns1 = dns2 = 0 ; /* Just in case... */
2613 qAT_PercentCGPCO(srcId,&gateway,&dns1,&dns2,cid);
2614 if(dns1 OR dns2 OR gateway)
2615 {
2616 ipaddr_to_string(dns1, dns1_str);
2617 ipaddr_to_string(dns2, dns2_str);
2618 ipaddr_to_string(gateway, gatew_str);
2619 sprintf(g_sa, "%s\"%s,%s,%s\",%d",
2620 me, dns1_str, dns2_str, gatew_str, cid) ;
2621
2622 io_sendMessage (srcId, g_sa, ATI_NORMAL_OUTPUT);
2623 }
2624 }
2625 return (ATI_CMPL);
2626 }
2627
2628 /*
2629 +--------------------------------------------------------------------+
2630 | PROJECT : GPRS MODULE : GACI_CMD |
2631 | STATE : finished ROUTINE : setatPercentCGPCO |
2632 +--------------------------------------------------------------------+
2633
2634 PURPOSE : %CGPCO command
2635 * set the PCO for context activation
2636 */
2637
2638 GLOBAL T_ATI_RSLT setatPercentCGPCO(CHAR *cl, UBYTE srcId)
2639 {
2640 USHORT cid = 0;
2641 T_ACI_CGPCO_FORMAT format;
2642 T_ATI_RSLT ret = ATI_FAIL;
2643 CHAR *pco_string;
2644 T_ACI_CGPCO_MODE mode;
2645
2646 TRACE_FUNCTION("setatPercentCGPCO()");
2647
2648 ACI_MALLOC (pco_string, ACI_PCO_MAX_LEN * 2 + 1);
2649
2650 cl = parse(cl, "ddsr",&mode, &format, ACI_PCO_MAX_LEN * 2 + 1, pco_string, &cid);
2651
2652 if(cl EQ NULL)
2653 {
2654 cmdCmeError (CME_ERR_OpNotAllow);
2655 }
2656 else if (cid > MAX_CID)
2657 {
2658 cmdCmeError (CME_ERR_OpNotSupp);
2659 }
2660 else
2661 {
2662
2663 #ifdef FF_ATI_BAT
2664
2665 T_BAT_cmd_send cmd;
2666 T_BAT_cmd_set_percent_cgpco cgpco;
2667 SHORT len;
2668
2669 cmd.ctrl_params = BAT_CMD_SET_PERCENT_CGPCO;
2670 cmd.params.ptr_set_percent_cgpco=&cgpco;
2671
2672 cgpco.cid=(T_BAT_pdp_cid)cid;
2673 cgpco.v_pco=FALSE;
2674
2675 ret=ATI_EXCT;
2676
2677 switch (mode)
2678 {
2679 case CGPCO_MODE_QUERY_PCO:
2680 cgpco.mode=BAT_P_CGPCO_MODE_QUERY_PCO;
2681 cgpco.format=(T_BAT_percent_cgpco_format)format;
2682 break;
2683
2684 case CGPCO_MODE_SET_PCO:
2685 cgpco.mode=BAT_P_CGPCO_MODE_SET_PCO;
2686 cgpco.format=(T_BAT_percent_cgpco_format)format;
2687
2688 len=strlen(pco_string);
2689
2690 if (len>BAT_MAX_CGPCO_PCO_LEN)
2691 {
2692 ret=ATI_FAIL;
2693 }
2694 else
2695 {
2696 memcpy(cgpco.pco,pco_string,len);
2697 cgpco.c_pco=(U8)len;
2698 cgpco.v_pco=TRUE;
2699 }
2700 break;
2701
2702 default:
2703 cmdCmeError(CME_ERR_OpNotSupp);
2704 ret=ATI_FAIL;
2705 break;
2706 }
2707
2708 if (ret==ATI_EXCT)
2709 {
2710 bat_send(ati_bat_get_client(srcId), &cmd);
2711 }
2712
2713 #else
2714
2715 switch (mode)
2716 {
2717 case CGPCO_MODE_QUERY_PCO:
2718 ret = queatPercentCGPCO (srcId,cid);
2719 break;
2720 case CGPCO_MODE_SET_PCO:
2721 switch (format)
2722 {
2723 case CGPCO_FORMAT_HEX:
2724 ret = setatPercentCGPCO_HEX (cid, (UBYTE*)pco_string, (USHORT)strlen (pco_string));
2725 break;
2726 case CGPCO_FORMAT_ASCII:
2727 ret = setatPercentCGPCO_ASCII (srcId, cid, (UBYTE*)pco_string, (USHORT)strlen (pco_string));
2728 break;
2729 default:
2730 cmdCmeError (CME_ERR_OpNotSupp);
2731 break;
2732 }
2733 break;
2734 default:
2735 cmdCmeError (CME_ERR_OpNotSupp);
2736 break;
2737 }
2738 #endif
2739
2740 }
2741
2742 ACI_MFREE (pco_string);
2743
2744 return (ret);
2745 }
2746
2747 /*
2748 +--------------------------------------------------------------------+
2749 | PROJECT : GPRS MODULE : GACI_CMD |
2750 | STATE : finished ROUTINE : setatPercentCGPPP |
2751 +--------------------------------------------------------------------+
2752
2753 PURPOSE : %CGPPP command
2754 * set PPP values in GPRS case
2755
2756 PPP_AP_NO 0x0 no authentication
2757 PPP_AP_PAP 0x1 password authentication protocol
2758 PPP_AP_CHAP 0x2 challenge handshake authentication protocol
2759 PPP_AP_AUTO 0x3 automatic authentication
2760
2761 */
2762
2763 GLOBAL T_ATI_RSLT setatPercentCGPPP (CHAR *cl, UBYTE srcId)
2764 {
2765 T_ACI_PPP_PROT protocol;
2766 T_ACI_RETURN ret = ATI_FAIL;
2767
2768 cl = parse(cl, "d", &protocol);
2769
2770 if (!cl)
2771 {
2772 cmdCmeError(CME_ERR_OpNotAllow);
2773 return ret;
2774 }
2775
2776 #ifdef FF_ATI_BAT
2777 {
2778 T_BAT_cmd_send cmd;
2779 T_BAT_cmd_set_percent_cgppp my_bat_set_percent_cgppp;
2780
2781 TRACE_FUNCTION("setatPercentCGPPP() calls bat_send() <=== as APPLICATION");
2782
2783 memset(&my_bat_set_percent_cgppp, 0, sizeof(my_bat_set_percent_cgppp));
2784 cmd.ctrl_params = BAT_CMD_SET_PERCENT_CGPPP;
2785 cmd.params.ptr_set_percent_cgppp = &my_bat_set_percent_cgppp;
2786
2787 my_bat_set_percent_cgppp.protocol = protocol;
2788
2789 bat_send(ati_bat_get_client(srcId), &cmd);
2790
2791 return ATI_EXCT; /* executing, because response is passed by callback function */
2792 }
2793 #else /* OLD FUNCTION BODY */
2794
2795 TRACE_FUNCTION("setatPercentCGPPP( )");
2796
2797 ret = sAT_PercentCGPPP(srcId, protocol);
2798 if (ret EQ AT_FAIL)
2799 {
2800 cmdCmeError(CME_ERR_Unknown);
2801 return (ATI_FAIL);
2802 }
2803 return (map_aci_2_ati_rslt(ret));
2804
2805 #endif /* no FF_ATI_BAT*/
2806 }
2807
2808 /*
2809 +--------------------------------------------------------------------+
2810 | PROJECT : GPRS MODULE : GACI_CMD |
2811 | STATE : finished ROUTINE : queatPercentCGPPP |
2812 +--------------------------------------------------------------------+
2813
2814 PURPOSE : %CGPPP command
2815 * query PPP values in GPRS case
2816
2817 PPP_AP_NO 0x0 no authentication
2818 PPP_AP_PAP 0x1 password authentication protocol
2819 PPP_AP_CHAP 0x2 challenge handshake authentication protocol
2820 PPP_AP_AUTO 0x3 automatic authentication
2821
2822 */
2823
2824 GLOBAL T_ATI_RSLT queatPercentCGPPP (CHAR *cl, UBYTE srcId)
2825 {
2826 #ifndef FF_ATI_BAT
2827 T_ACI_PPP_PROT protocol;
2828 T_ACI_RETURN ret;
2829 #endif
2830
2831 TRACE_FUNCTION("queatPercentCGPPP( )");
2832
2833 #ifdef FF_ATI_BAT
2834 {
2835 T_BAT_cmd_send cmd;
2836 T_BAT_no_parameter dummy;
2837
2838 cmd.ctrl_params = BAT_CMD_QUE_PERCENT_CGPPP;
2839 dummy.bat_dummy = 0xFF;
2840 cmd.params.ptr_que_percent_cgppp = &dummy;
2841 bat_send(ati_bat_get_client(srcId), &cmd);
2842 return(ATI_EXCT);
2843 }
2844 #else
2845
2846 ret = qAT_PercentCGPPP(srcId, &protocol);
2847 if (ret EQ AT_FAIL)
2848 {
2849 cmdCmeError(CME_ERR_Unknown);
2850 return (ATI_FAIL);
2851 }
2852
2853 sprintf (g_sa, "%s: %d", "%CGPPP", protocol);
2854 io_sendMessage (srcId, g_sa, ATI_NORMAL_OUTPUT);
2855
2856 return (map_aci_2_ati_rslt(ret));
2857
2858 #endif /*FF_ATI_BAT*/
2859 }
2860 /*
2861 +--------------------------------------------------------------------+
2862 | PROJECT : GPRS (8441) MODULE : GACI_CMD |
2863 | STATE : finished ROUTINE : atPercentCGCLASS |
2864 +--------------------------------------------------------------------+
2865
2866 PURPOSE : %CGCLASS command (GPRS class change)
2867 */
2868
2869 GLOBAL T_ATI_RSLT setatPercentCGCLASS (CHAR *cl, UBYTE srcId)
2870 {
2871 #ifndef FF_ATI_BAT
2872 char *me="+CGCLASS: ";
2873 T_ACI_RETURN ret;
2874 #endif
2875
2876 T_PERCENT_CGCLASS m_class = PERCENT_CGCLASS_OMITTED;
2877 char test_class[3]="";
2878
2879 TRACE_FUNCTION("setatPercentCGCLASS ()");
2880
2881 cl = parse (cl,"s", (LONG)3, &test_class );
2882
2883 switch (*test_class)
2884 {
2885 case 'A':
2886 break;
2887 case 'B':
2888 switch(*(test_class + 1))
2889 {
2890 case 'G':
2891 m_class = PERCENT_CGCLASS_BG;
2892 break;
2893 case 'C':
2894 m_class = PERCENT_CGCLASS_BC;
2895 break;
2896 case 'X':
2897 m_class = PERCENT_CGCLASS_BX;
2898 break;
2899 case '\0':
2900 m_class = PERCENT_CGCLASS_B;
2901 break;
2902 default:
2903 break;
2904 }
2905 break;
2906 case 'C':
2907 switch(*(test_class + 1))
2908 {
2909 case 'G':
2910 m_class = PERCENT_CGCLASS_CG;
2911 break;
2912 case 'C':
2913 m_class = PERCENT_CGCLASS_CC;
2914 break;
2915 default:
2916 break;
2917 }
2918 break;
2919 default:
2920 break;
2921 }
2922
2923 if ( !cl OR m_class == PERCENT_CGCLASS_OMITTED )
2924 {
2925 cmdCmeError(CME_ERR_OpNotAllow);
2926 return (ATI_FAIL);
2927 }
2928
2929 #ifdef FF_ATI_BAT
2930
2931 {
2932 T_BAT_cmd_send cmd;
2933 T_BAT_cmd_set_percent_cgclass cgclass;
2934
2935 cmd.ctrl_params = BAT_CMD_SET_PERCENT_CGCLASS;
2936 cmd.params.ptr_set_percent_cgclass=&cgclass;
2937
2938 /*
2939 * BAT and ACI versions of mobile class are different enough
2940 * to require this conversion.
2941 */
2942
2943 /*
2944 * This relies on T_BAT_p_mobile_class and T_PERCENT_CGCLASS
2945 * being identical.
2946 */
2947 cgclass.p_mobile_class=(T_BAT_p_mobile_class)m_class;
2948
2949 bat_send(ati_bat_get_client(srcId), &cmd);
2950 return(ATI_EXCT);
2951 }
2952
2953 #else
2954
2955 ret = sAT_PercentCGCLASS ( srcId, m_class );
2956 if (ret EQ AT_FAIL)
2957 {
2958 cmdCmeError (CME_ERR_OpNotAllow);
2959 return (ATI_FAIL);
2960 }
2961 return (map_aci_2_ati_rslt(ret));
2962
2963 #endif
2964 }
2965
2966 GLOBAL T_ATI_RSLT queatPercentCGCLASS (CHAR *cl, UBYTE srcId)
2967 {
2968 #ifndef FF_ATI_BAT
2969 char *classes[] = {"A","B","BG","BC","BX","CG","CC"};
2970 T_ACI_RETURN ret;
2971 T_PERCENT_CGCLASS m_class, currentClass;
2972 char test_class[3]="";
2973 #endif
2974
2975 TRACE_FUNCTION("queatPercentCGCLASS ()");
2976
2977 #ifdef FF_ATI_BAT
2978 {
2979 T_BAT_cmd_send cmd;
2980 T_BAT_no_parameter dummy;
2981
2982 cmd.ctrl_params = BAT_CMD_QUE_PERCENT_CGCLASS;
2983 dummy.bat_dummy = 0xFF;
2984 cmd.params.ptr_que_plus_cgclass = &dummy;
2985 bat_send(ati_bat_get_client(srcId), &cmd);
2986 return(ATI_EXCT);
2987 }
2988 #else
2989
2990 ret = qAT_PercentCGCLASS(srcId, &m_class, &currentClass);
2991 if (ret EQ AT_CMPL)
2992 {
2993 if(m_class NEQ currentClass)
2994 {
2995 sprintf(g_sa,"%s: \"%s\",\"%s\"", "%CGCLASS", classes[m_class], classes[currentClass]);
2996 }
2997 else
2998 {
2999 sprintf(g_sa,"%s: \"%s\"", "%CGCLASS", classes[m_class]);
3000 }
3001 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
3002 }
3003
3004 return (map_aci_2_ati_rslt(ret));
3005
3006 #endif /*FF_ATI_BAT*/
3007 }
3008 #endif /* GPRS */
3009