comparison g23m/condat/ms/src/aci/ati_mm.c @ 0:509db1a7b7b8

initial import: leo2moko-r1
author Space Falcon <falcon@ivan.Harhan.ORG>
date Mon, 01 Jun 2015 03:24:05 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:509db1a7b7b8
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: Mobility Management related functions.
18 +-----------------------------------------------------------------------------
19 */
20
21 #ifndef ATI_MM_C
22 #define ATI_MM_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 UART
41 #include "dti.h"
42 #include "dti_conn_mng.h"
43 #endif
44
45 #include "psa.h"
46 #include "cmh.h"
47 #include "psa_sim.h"
48 #include "cmh_sim.h"
49 #include "psa_mm.h"
50
51 #ifdef FF_ATI_BAT
52
53 #include "typedefs.h"
54 #include "gdd.h"
55 #include "bat.h"
56
57 #include "ati_bat.h"
58
59 #endif /* FF_ATI_BAT */
60
61 EXTERN T_ACI_CFUN_FUN CFUNfun;
62 EXTERN T_CIEV_SIGNAL_BUFFER asCievSignalBuf;
63 EXTERN T_CIEV_SMSFULL_BUFFER asCievSmsFullBuf;
64
65 /*
66 +--------------------------------------------------------------------+
67 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
68 | STATE : code ROUTINE : atPlusCops |
69 +--------------------------------------------------------------------+
70
71 PURPOSE : +COPS command (operator selection)
72 */
73
74 GLOBAL T_ATI_RSLT setatPlusCOPS (char *cl, UBYTE srcId)
75 {
76 CHAR op[MAX_ALPHA_OPER_LEN] = {0};
77 T_ACI_RETURN ret = AT_FAIL;
78 T_ACI_COPS_MOD mode = COPS_MOD_NotPresent;
79 T_ACI_COPS_FRMT format = COPS_FRMT_NotPresent;
80 SHORT startIdx = 0,
81 lastIdx = 0;
82 SHORT pos=0;
83 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
84
85 TRACE_FUNCTION("setatPlusCops()");
86
87 if (CFUNfun NEQ CFUN_FUN_Full)
88 {
89 TRACE_EVENT_P1("+COPS error: cannot proceed Mobile has no Full CFUN: %d", CFUNfun);
90 cmdCmeError(CME_ERR_OpNotAllow);
91 return ATI_FAIL;
92 }
93
94 cl = parse (cl,"dds",&mode,&format,(LONG)(MAX_ALPHA_OPER_LEN-1),op); /*split parameter string in int,int,str*/
95 if (!cl OR ((mode EQ COPS_MOD_Man OR mode EQ COPS_MOD_Both)
96 AND op[0] EQ 0))
97 {
98 cmdCmeError(CME_ERR_OpNotAllow);
99 return ATI_FAIL;
100 }
101
102 #ifdef FF_ATI_BAT
103 {
104 T_BAT_cmd_send cmd;
105 T_BAT_cmd_set_plus_cops cops;
106 UBYTE len;
107
108 len=strlen(op);
109
110 /*
111 * If the operator name is too long we can't really do anything
112 * meaningful, so generate an error and give up.
113 */
114 if (len>BAT_MAX_COPS_OPER_LEN)
115 {
116 cmdCmeError(CME_ERR_Unknown);
117 return(ATI_FAIL);
118 }
119
120 cmd.ctrl_params = BAT_CMD_SET_PLUS_COPS;
121 cmd.params.ptr_set_plus_cops=&cops;
122
123 /*
124 * This relies on T_ACI_COPS_MOD and T_BAT_plus_cops_mode being
125 * equivalent.
126 */
127 cops.mode=(T_BAT_plus_cops_mode)mode;
128
129 /*
130 * This relies on T_ACI_COPS_FRMT and T_BAT_plus_cops_format being
131 * equivalent.
132 */
133 cops.format=(T_BAT_plus_cops_format)format;
134
135 cops.c_oper=(U8)len;
136
137 if (len)
138 {
139 memcpy(cops.oper,op,BAT_MAX_COPS_OPER_LEN);
140 cops.v_oper=TRUE;
141 }
142 else
143 {
144 cops.v_oper=FALSE;
145 }
146 bat_send(ati_bat_get_client(srcId), &cmd);
147 src_params->curAtCmd = AT_CMD_COPS;
148 return ATI_EXCT;
149 }
150 #else
151
152 ret = sAT_PlusCOPS (srcId,mode,format,op);
153 switch (ret)
154 {
155 case (AT_CMPL): /*operation completed*/
156 break;
157 case (AT_EXCT):
158 src_params->curAtCmd = AT_CMD_COPS;
159 break;
160 default:
161 cmdCmeError(CME_ERR_Unknown); /*Command failed*/
162 break;
163 }
164 return (map_aci_2_ati_rslt(ret));
165
166 #endif /*FF_ATI_BAT*/
167 }
168
169 #ifdef FF_ATI_BAT
170 /*
171 +--------------------------------------------------------------------+
172 | PROJECT : GSM-F&D (8411) MODULE : ACI_BAT |
173 | STATE : code ROUTINE : aci_bat_HandleTestCOPS |
174 +--------------------------------------------------------------------+
175
176 PURPOSE :
177 */
178 T_ATI_RSLT atiHandleTestCOPS(UBYTE srcId)
179 {
180 T_BAT_cmd_send cmd;
181 T_BAT_no_parameter dummy;
182
183 cmd.ctrl_params = BAT_CMD_TST_PERCENT_COPS;
184 dummy.bat_dummy = 0xFF;
185 cmd.params.ptr_que_plus_cops = &dummy;
186
187 TRACE_FUNCTION("aci_bat_HandleTestCOPS() calls bat_send() <=== as APPLICATION");
188
189 #ifndef FF_DUAL_SIM
190 if (CFUNfun NEQ CFUN_FUN_Full)
191 {
192 cmdCmeError(CME_ERR_OpNotAllow);
193 return ATI_FAIL;
194 }
195 #endif /*FF_DUAL_SIM*/
196
197 bat_send(ati_bat_get_client(srcId), &cmd);
198 return ATI_EXCT; /* executing, because response is passed by callback function */
199 }
200
201 #else /* no FF_ATI_BAT */
202
203 GLOBAL T_ATI_RSLT atiHandleTestCOPS(char *cl, UBYTE srcId)
204 {
205 T_ACI_RETURN ret = AT_FAIL;
206 T_ACI_COPS_MOD mode = COPS_MOD_NotPresent;
207 T_ACI_COPS_FRMT format = COPS_FRMT_NotPresent;
208 SHORT startIdx = 0,
209 lastIdx = 0,
210 length1,
211 length2;
212 T_ACI_COPS_LST operLst;
213 BOOL END_OF_LIST = FALSE;
214 SHORT i,
215 pos=0;
216 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
217 char* outputCommand;
218
219
220 TRACE_FUNCTION("atiHandleTestCOPS()");
221
222 #ifndef FF_DUAL_SIM
223 if (CFUNfun NEQ CFUN_FUN_Full)
224 {
225 cmdCmeError(CME_ERR_OpNotAllow);
226 return ATI_FAIL;
227 }
228 #endif /*FF_DUAL_SIM*/
229 do
230 {
231 startIdx += lastIdx;
232 switch (src_params->curAtCmd)
233 {
234 case AT_CMD_COPS:
235 ret = tAT_PlusCOPS(srcId,startIdx,&lastIdx,&operLst[0]);
236 break;
237 case AT_CMD_P_COPS:
238 ret = tAT_PercentCOPS(srcId,startIdx,&lastIdx,&operLst[0]);
239 break;
240 default:
241 cmdCmeError(CME_ERR_Unknown);
242 return ATI_FAIL;
243 }
244 if (ret EQ AT_CMPL)
245 {
246 for(i=0;i<lastIdx;i++)
247 {
248 if ((operLst[i].status < 0) AND (*operLst[i].numOper EQ 0))
249 {
250 END_OF_LIST = TRUE;
251 break;
252 }
253
254
255 length1 = strlen(operLst[i].longOper);
256 length2 = strlen(operLst[i].shortOper);
257
258 /* What COPS command is active? */
259 switch (src_params->curAtCmd)
260 {
261 case AT_CMD_COPS:
262 outputCommand = "+COPS";
263 break;
264 case AT_CMD_P_COPS:
265 outputCommand ="%COPS";
266 break;
267 default:
268 cmdCmeError(CME_ERR_Unknown);
269 return ATI_FAIL;
270 }
271
272 sprintf(g_sa,"%s: %d,\"%s\",\"%s\",%s",outputCommand,
273 operLst[i].status,operLst[i].longOper,
274 operLst[i].shortOper,operLst[i].numOper);
275 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
276
277 }
278 }
279
280 switch(ret)
281 {
282 case AT_EXCT:
283 return ATI_EXCT;
284
285 case AT_FAIL:
286 cmdCmeError(CME_ERR_Unknown);
287 return ATI_FAIL;
288
289 case AT_BUSY:
290 return ATI_BUSY;
291
292 default:
293 break;/* Does nothing in this case */
294 }
295
296 }
297 while(!END_OF_LIST);
298
299 return ATI_CMPL;
300 }
301
302 #endif /* no FF_ATI_BAT */
303
304
305 GLOBAL T_ATI_RSLT tesatPlusCOPS (char *cl, UBYTE srcId)
306 {
307 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
308
309 #ifdef FF_ATI_BAT
310 TRACE_FUNCTION("tesatPlusCOPS() calls bat_send() <=== as APPLICATION");
311 return atiHandleTestCOPS(srcId);
312
313 #else /* FF_ATI_BAT */
314 TRACE_FUNCTION("tesatPlusCOPS()");
315 return atiHandleTestCOPS(cl,srcId);
316 #endif /* FF_ATI_BAT */
317
318 }
319
320 GLOBAL T_ATI_RSLT queatPlusCOPS (char *cl, UBYTE srcId)
321 {
322 CHAR op[MAX_ALPHA_OPER_LEN] = {0};
323 T_ACI_RETURN ret = AT_FAIL;
324 T_ACI_COPS_MOD mode = COPS_MOD_NotPresent;
325 T_ACI_COPS_FRMT format = COPS_FRMT_NotPresent;
326 SHORT startIdx = 0,
327 lastIdx = 0;
328 SHORT pos = 0;
329
330 TRACE_FUNCTION("queatPlusCops()");
331
332 #ifdef FF_ATI_BAT
333 {
334 T_BAT_cmd_send cmd;
335 T_BAT_no_parameter dummy;
336
337 cmd.ctrl_params = BAT_CMD_QUE_PLUS_COPS;
338 dummy.bat_dummy = 0xFF;
339 cmd.params.ptr_que_plus_cops = &dummy;
340 bat_send(ati_bat_get_client(srcId), &cmd);
341 return(ATI_EXCT);
342 }
343 #else /* no FF_ATI_BAT */
344
345 ret = qAT_PlusCOPS(srcId,&mode,&format,op);
346 if (ret EQ AT_CMPL)
347 {
348 if (*op)
349 sprintf(g_sa,"+COPS: %d,%d,\"%s\"",mode,format,op);
350 else
351 sprintf(g_sa,"+COPS: %d",mode);
352
353 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
354 }
355 else
356 {
357 cmdCmeError(CME_ERR_Unknown);
358 }
359 return (map_aci_2_ati_rslt(ret));
360
361 #endif /* no FF_ATI_BAT */
362 }
363
364 /*
365 +--------------------------------------------------------------------+
366 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
367 | STATE : code ROUTINE : setatPercentCOPS |
368 +--------------------------------------------------------------------+
369
370 PURPOSE : %COPS command (operator selection)
371 */
372
373 GLOBAL T_ATI_RSLT setatPercentCOPS (char *cl, UBYTE srcId)
374 {
375 CHAR op[MAX_ALPHA_OPER_LEN] = {0};
376 T_ACI_RETURN ret = AT_FAIL;
377 T_ACI_COPS_MOD mode = COPS_MOD_NotPresent;
378 T_ACI_COPS_FRMT format = COPS_FRMT_NotPresent;
379 SHORT startIdx = 0,
380 lastIdx = 0;
381 SHORT pos=0;
382 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
383
384 if (CFUNfun NEQ CFUN_FUN_Full)
385 {
386 TRACE_EVENT_P1("%COPS error: cannot proceed Mobile has no Full CFUN: %d", CFUNfun);
387 cmdCmeError(CME_ERR_OpNotAllow);
388 return ATI_FAIL;
389 }
390 cl = parse (cl,"dds",&mode,&format,(LONG)(MAX_ALPHA_OPER_LEN-1),op); /*split parameter string in int,int,str*/
391 if (!cl) /*For %COPS, Manual selection without Operator parameter is allowed */
392 {
393 cmdCmeError(CME_ERR_OpNotAllow);
394 return ATI_FAIL;
395 }
396
397 #ifdef FF_ATI_BAT
398 {
399 T_BAT_cmd_send cmd;
400 T_BAT_cmd_set_percent_cops my_bat_set_percent_cops;
401 UBYTE OperLength = strlen(op);
402
403 TRACE_FUNCTION("setatPercentCOPS() calls bat_send() <=== as APPLICATION");
404
405 memset(&my_bat_set_percent_cops, sizeof(my_bat_set_percent_cops), FALSE);
406 cmd.ctrl_params = BAT_CMD_SET_PERCENT_COPS;
407 cmd.params.ptr_set_percent_cops = &my_bat_set_percent_cops;
408
409 my_bat_set_percent_cops.mode = (T_BAT_VAL_percent_cops_mode)mode;
410 my_bat_set_percent_cops.format = (T_BAT_VAL_percent_cops_format)format;
411
412 if (OperLength NEQ 0 &&
413 OperLength <= BAT_MAX_COPS_LONG_OPER_LEN)
414 {
415 memcpy(&my_bat_set_percent_cops.oper, op, BAT_MAX_COPS_LONG_OPER_LEN);
416 }
417
418 src_params->curAtCmd = AT_CMD_P_COPS;
419
420 bat_send(ati_bat_get_client(srcId), &cmd);
421 return ATI_EXCT; /* executing, because response is passed by callback function */
422 }
423
424 #else /* no FF_ATI_BAT */
425
426 TRACE_FUNCTION("setatPercentCOPS()");
427 ret = sAT_PercentCOPS (srcId,mode,format,op);
428 switch (ret)
429 {
430 case (AT_CMPL): /*operation completed*/
431 break;
432 case (AT_EXCT):
433 src_params->curAtCmd = AT_CMD_P_COPS;
434 break;
435 default:
436 cmdCmeError(CME_ERR_Unknown); /*Command failed*/
437 break;
438 }
439 return (map_aci_2_ati_rslt(ret));
440
441 #endif /* no FF_ATI_BAT */
442 }
443
444
445 /*
446 +--------------------------------------------------------------------+
447 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
448 | STATE : code ROUTINE : tesatPercentCOPS |
449 +--------------------------------------------------------------------+
450
451 PURPOSE : %COPS command (operator test)
452 */
453
454
455 GLOBAL T_ATI_RSLT tesatPercentCOPS (char *cl, UBYTE srcId)
456 {
457 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
458
459 #ifdef FF_ATI_BAT
460 TRACE_FUNCTION("tesatPercentCOPS() calls bat_send() <=== as APPLICATION");
461 return atiHandleTestCOPS(srcId);
462
463 #else /* FF_ATI_BAT */
464 TRACE_FUNCTION("tesatPercentCOPS()");
465 return atiHandleTestCOPS(cl,srcId);
466 #endif /* FF_ATI_BAT */
467 }
468
469 /*
470 +--------------------------------------------------------------------+
471 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
472 | STATE : code ROUTINE : queatPercentCOPS |
473 +--------------------------------------------------------------------+
474
475 PURPOSE : %COPS command (operator query)
476 */
477
478
479 GLOBAL T_ATI_RSLT queatPercentCOPS (char *cl, UBYTE srcId)
480 {
481 CHAR op[MAX_ALPHA_OPER_LEN] = {0};
482 T_ACI_RETURN ret = AT_FAIL;
483 T_ACI_COPS_MOD mode = COPS_MOD_NotPresent;
484 T_ACI_COPS_FRMT format = COPS_FRMT_NotPresent;
485 T_ACI_COPS_SVST svrStatus = COPS_SVST_NotPresent;
486 SHORT startIdx = 0,
487 lastIdx = 0;
488 SHORT pos = 0;
489
490 #ifdef FF_ATI_BAT
491 {
492 T_BAT_cmd_send cmd;
493 T_BAT_no_parameter dummy;
494
495 TRACE_FUNCTION("queatPercentCOPS() calls bat_send() <=== as APPLICATION");
496 cmd.ctrl_params = BAT_CMD_QUE_PERCENT_COPS;
497 dummy.bat_dummy = 0xFF;
498 cmd.params.ptr_que_percent_cops = &dummy;
499 bat_send(ati_bat_get_client(srcId), &cmd);
500 return ATI_EXCT; /* executing, because response is passed by callback function */
501 }
502 #else /* no FF_ATI_BAT */
503
504 TRACE_FUNCTION("queatPercentCOPS()");
505
506 ret = qAT_PercentCOPS(srcId,&mode,&format,&svrStatus,op);
507 if (ret EQ AT_CMPL)
508 {
509 /* Added an empty comma and the service Status parameter */
510 sprintf(g_sa,"%s: %d,%d,\"%s\",,%d","%COPS",mode,format,op,svrStatus);
511 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
512
513 }
514 else
515 {
516 cmdCmeError(CME_ERR_Unknown); /*command failed*/
517 }
518 return (map_aci_2_ati_rslt(ret));
519
520 #endif /* no FF_ATI_BAT */
521 }
522
523
524
525 /*
526 +--------------------------------------------------------------------+
527 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
528 | STATE : code ROUTINE : setatPercentCREG |
529 +--------------------------------------------------------------------+
530
531 PURPOSE : %CREG command (Network registration)
532 */
533
534 GLOBAL T_ATI_RSLT setatPercentCREG (char *cl, UBYTE srcId)
535 {
536 T_ATI_CREG_MOD mode=CREG_MOD_OFF;
537
538 TRACE_FUNCTION("setatPercentCREG()");
539
540 cl=parse(cl,"d",&mode);
541
542 switch(mode)
543 {
544 case CREG_MOD_OFF:
545 case CREG_MOD_ON:
546 case CREG_MOD_LOC_INF_ON:
547 /* user wants to set mode: reset CREG related ATI parameters */
548 ati_creg_init(srcId, PercentCREG_CMD);
549 ati_user_output_cfg[srcId].percent_creg.mod_lac_cid.pres_mode = mode;
550 return ATI_CMPL;
551
552 default:
553 cmdCmeError(CME_ERR_OpNotAllow);
554 return ATI_FAIL;
555 }
556 }
557
558
559 /*
560 +--------------------------------------------------------------------+
561 | PROJECT : GPRS (8441) MODULE : GACI_CMD |
562 | STATE : code ROUTINE : queatPercentCREG |
563 +--------------------------------------------------------------------+
564
565 PURPOSE : %CREG command
566 */
567 GLOBAL T_ATI_RSLT queatPercentCREG (char *cl, UBYTE srcId)
568 {
569
570 #ifndef FF_ATI_BAT
571 T_ACI_CREG_STAT stat;
572 USHORT lac, cid;
573 T_ATI_CREG_MOD mode;
574 T_ACI_P_CREG_GPRS_IND gprs_ind;
575 short pos;
576 #endif
577
578 TRACE_FUNCTION("queatPercentCREG()");
579
580 #ifdef FF_ATI_BAT
581 {
582 T_BAT_cmd_send cmd;
583 T_BAT_no_parameter dummy;
584
585 cmd.ctrl_params = BAT_CMD_QUE_PERCENT_CREG;
586 dummy.bat_dummy = 0xFF;
587 cmd.params.ptr_que_percent_creg = &dummy;
588 bat_send(ati_bat_get_client(srcId), &cmd);
589 return(ATI_EXCT);
590 }
591 #else /* no FF_ATI_BAT */
592
593 mode = ati_user_output_cfg[srcId].percent_creg.mod_lac_cid.pres_mode;
594
595 if (qAT_PercentCREG(srcId, &stat, &lac, &cid, &gprs_ind) NEQ AT_CMPL)
596 {
597 cmdCmeError(CME_ERR_Unknown);
598 return ATI_FAIL;
599 }
600
601 pos = sprintf(g_sa, "%s: %d,%d", "%CREG", mode, stat);
602
603 if ( (mode EQ CREG_MOD_LOC_INF_ON) AND
604 (stat EQ CREG_STAT_Reg OR stat EQ CREG_STAT_Roam) )
605 pos += sprintf(g_sa+pos, ",\"%04X\",\"%04X\"", lac, cid);
606 else
607 pos += sprintf(g_sa+pos, ",,");
608
609 sprintf(g_sa+pos,",%d", gprs_ind);
610
611 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
612 return ATI_CMPL;
613
614 #endif /* no FF_ATI_BAT */
615 }
616
617 /*
618 +--------------------------------------------------------------------+
619 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
620 | STATE : code ROUTINE : setatPlusCREG |
621 +--------------------------------------------------------------------+
622
623 PURPOSE : +CREG command (Network registration)
624 */
625
626 GLOBAL T_ATI_RSLT setatPlusCREG (char *cl, UBYTE srcId)
627 {
628 T_ATI_CREG_MOD mode=CREG_MOD_OFF;
629
630 TRACE_FUNCTION("setatPlusCREG()");
631
632 cl=parse(cl,"d",&mode);
633
634 switch(mode)
635 {
636 case CREG_MOD_OFF:
637 case CREG_MOD_ON:
638 case CREG_MOD_LOC_INF_ON:
639 /* user wants to set mode: reset CREG related ATI parameters */
640 ati_creg_init(srcId, CREG_CMD);
641 ati_user_output_cfg[srcId].creg.mod_lac_cid.pres_mode = mode;
642 return ATI_CMPL;
643
644 default:
645 cmdCmeError(CME_ERR_OpNotAllow);
646 return ATI_FAIL;
647 }
648 }
649
650 GLOBAL T_ATI_RSLT queatPlusCREG (char *cl, UBYTE srcId)
651 {
652 T_ACI_CREG_STAT stat;
653 USHORT lac, cid;
654 T_ATI_CREG_MOD mode;
655 short pos;
656
657 TRACE_FUNCTION("queatPlusCREG()");
658
659 mode = ati_user_output_cfg[srcId].creg.mod_lac_cid.pres_mode;
660
661 if (qAT_PlusCREG(srcId, &stat, &lac, &cid) NEQ AT_CMPL)
662 {
663 cmdCmeError(CME_ERR_Unknown);
664 return ATI_FAIL;
665 }
666
667 pos = sprintf(g_sa, "+CREG: %d,%d", mode, stat);
668
669 if (mode EQ CREG_MOD_LOC_INF_ON)
670 {
671 if (stat EQ CREG_STAT_Reg OR stat EQ CREG_STAT_Roam)
672 sprintf(g_sa+pos, ",\"%04X\",\"%04X\"", lac, cid);
673 }
674
675 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
676 return ATI_CMPL;
677 }
678
679
680
681
682 /*
683 +--------------------------------------------------------------------+
684 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
685 | STATE : code ROUTINE : atPlusCopn |
686 +--------------------------------------------------------------------+
687
688 PURPOSE : +COPN command (read operator names)
689 */
690
691 GLOBAL T_ATI_RSLT setatPlusCOPN (char *cl, UBYTE srcId)
692 {
693 SHORT startIdx, lastIdx;
694 T_ACI_COPN_LST operLst;
695 T_COPN_VAR *COPN_Var;
696 UBYTE idx;
697 BOOL loop;
698 BOOL ret;
699 COPN_Var = &mmShrdPrm.COPN_VAR[srcId];
700
701 TRACE_FUNCTION("setatPlusCOPN()");
702
703 /* read out the PCM list */
704 startIdx = 0;
705 loop = TRUE;
706
707 do
708 {
709 if ( qAT_PlusCOPN(srcId, COPN_LID_Pcm, startIdx,
710 &lastIdx, operLst) EQ AT_FAIL )
711 break;
712
713 for( idx=0; idx < MAX_OPER; idx++ )
714 {
715 if ( operLst[idx].numOper[0] EQ 0x0 )
716 {
717 loop = FALSE;
718 break;
719 }
720
721 sprintf(g_sa,"+COPN: \"%s\",\"%s\"",operLst[idx].numOper,
722 operLst[idx].alphaOper );
723 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
724 }
725 startIdx = lastIdx+1;
726 }
727 while( loop );
728
729 /* read out the constant list */
730 startIdx = 0;
731
732 ret = cmd_readCOPNBlock(startIdx,srcId);
733
734 if (ret EQ TRUE)
735 return ATI_CMPL;
736 else
737 return ATI_EXCT;
738
739 }
740
741 /*
742 +--------------------------------------------------------------------+
743 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
744 | STATE : code ROUTINE : setatPercentCOPN |
745 +--------------------------------------------------------------------+
746
747 PURPOSE : %COPN command (get MCC and MNC, long name or short name given one of the them)
748 */
749
750 GLOBAL T_ATI_RSLT setatPercentCOPN (char *cl, UBYTE srcId)
751 {
752 T_ACI_COPS_FRMT format = COPS_FRMT_NotPresent;
753 CHAR op[MAX_ALPHA_OPER_LEN] = {0};
754 T_ACI_OPER_NTRY * oper_ntry;
755 USHORT i;
756
757 TRACE_FUNCTION ("setatPercentCOPN()");
758
759 cl = parse (cl,"ds", &format, (LONG)MAX_ALPHA_OPER_LEN, op);
760
761 if ((!cl) OR (format < COPS_FRMT_Long) OR (format > COPS_FRMT_Numeric) OR *op EQ '\0')
762 {
763 cmdCmeError(CME_ERR_OpNotAllow);
764 return ATI_FAIL;
765 }
766
767 if (format EQ COPS_FRMT_Numeric)
768 {
769 if ((strlen(op) NEQ (SIZE_MNC + SIZE_MCC -1)) AND
770 (strlen(op) NEQ (SIZE_MNC + SIZE_MCC)))
771 {
772 cmdCmeError(CME_ERR_OpNotAllow);
773 return ATI_FAIL;
774 }
775
776 for (i = 0; *(op+i) NEQ '\0'; i ++)
777 {
778 if (!((*(op+i) >= '0')AND(*(op+i) <= '9')))
779 {
780 cmdCmeError(CME_ERR_OpNotAllow);
781 return ATI_FAIL;
782 }
783 }
784 }
785
786 ACI_MALLOC (oper_ntry, sizeof (T_ACI_OPER_NTRY));
787
788 if (qAT_PercentCOPN( srcId, format, op, oper_ntry) EQ AT_FAIL)
789 {
790 sprintf (g_sa, "%s", "%COPN: ");
791 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
792 ACI_MFREE (oper_ntry);
793 return ATI_CMPL;
794 }
795
796 if ((oper_ntry->mnc & 0x00F) EQ 0xF)
797 {
798 sprintf (g_sa, "%s\"%s\",\"%s\",\"%03X%02X\",%d", "%COPN: ", oper_ntry->longName, oper_ntry->shrtName,
799 oper_ntry->mcc, oper_ntry->mnc >> 4, oper_ntry->source);
800 }
801 else
802 {
803 sprintf (g_sa, "%s\"%s\",\"%s\",\"%03X%03X\",%d", "%COPN: ", oper_ntry->longName, oper_ntry->shrtName,
804 oper_ntry->mcc, oper_ntry->mnc, oper_ntry->source);
805 }
806 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
807
808 ACI_MFREE (oper_ntry);
809 return ATI_CMPL;
810
811
812 }
813
814 /*
815 +--------------------------------------------------------------------+
816 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
817 | STATE : code ROUTINE : atPlusWS46 |
818 +--------------------------------------------------------------------+
819
820 PURPOSE : +WS46 command (select wireless network)
821 */
822
823 GLOBAL T_ATI_RSLT setatPlusWS46 (char *cl, UBYTE srcId)
824 {
825 T_ACI_RETURN ret = AT_FAIL;
826 T_ACI_WS46_MOD mode=WS46_MOD_NotPresent;
827
828 TRACE_FUNCTION("setatPLusWS46()");
829
830 cl = parse(cl,"d",&mode);
831 if (!cl)
832 {
833 cmdCmeError(CME_ERR_OpNotAllow);
834 return ATI_FAIL;
835 }
836
837 #ifdef FF_ATI_BAT
838
839 {
840 T_BAT_cmd_send cmd;
841 T_BAT_cmd_set_plus_ws46 ws46;
842
843 cmd.ctrl_params = BAT_CMD_SET_PLUS_WS46;
844 cmd.params.ptr_set_plus_ws46=&ws46;
845
846 ws46.n=(T_BAT_plus_ws46_n)mode;
847
848 bat_send(ati_bat_get_client(srcId), &cmd);
849 return(ATI_EXCT);
850 }
851
852 #else /* no FF_ATI_BAT */
853
854 ret=sAT_PlusWS46(srcId,mode);
855
856 if (ret EQ AT_CMPL)
857 {
858 return ATI_CMPL;
859 }
860 else
861 {
862 cmdCmeError(CME_ERR_OpNotAllow);
863 return ATI_FAIL;
864 }
865
866 #endif /* no FF_ATI_BAT */
867 }
868
869 GLOBAL T_ATI_RSLT queatPlusWS46 (char *cl, UBYTE srcId)
870 {
871 T_ACI_RETURN ret = AT_FAIL;
872 T_ACI_WS46_MOD mode=WS46_MOD_NotPresent;
873
874 TRACE_FUNCTION("queatPLusWS46()");
875
876 #ifdef FF_ATI_BAT
877 {
878 T_BAT_cmd_send cmd;
879 T_BAT_no_parameter dummy;
880
881 cmd.ctrl_params = BAT_CMD_QUE_PLUS_WS46;
882 dummy.bat_dummy = 0xFF;
883 cmd.params.ptr_que_plus_ws46 = &dummy;
884 bat_send(ati_bat_get_client(srcId), &cmd);
885 return(ATI_EXCT);
886 }
887 #else /* no FF_ATI_BAT */
888
889 ret = qAT_PlusWS46(srcId,&mode);
890
891 if (ret EQ AT_CMPL)
892 {
893 resp_disp(srcId, cl,"e",&mode);
894 return ATI_CMPL;
895 }
896 else if (ret EQ AT_FAIL)
897 {
898 cmdCmeError(CME_ERR_OpNotAllow);
899 return ATI_FAIL;
900 }
901 return (map_aci_2_ati_rslt(ret));
902
903 #endif /* no FF_ATI_BAT */
904 }
905
906 /*
907 +--------------------------------------------------------------------+
908 | PROJECT : GSM-F&D (8411) MODULE : |
909 | STATE : code ROUTINE : setatPercentCHPL |
910 +--------------------------------------------------------------------+
911
912 PURPOSE : show list of all available entries in the SIM field EF_HPLMNwAcT.
913
914 Command Possible Response
915 %CHPL=oprFrmt %CHPL: <opr>
916 %CHPL=? %CHPL: (list of supported <oprFrmt>s)
917
918 <oprFrmt>:
919 0 long format alphanumeric <opr>
920 1 short format alphanumeric <opr>
921 2 numeric <opr>
922
923 <opr>: string type; <oprFrmt> indicates if the format is
924 alphanumeric or numeric.
925 Long alphanumeric can be up to 16 characters.
926 Short alphanumeric can be up to 8 characters.
927 Numeric format is the GSM LAI number, which consists of:
928 3 BCD country code.
929 2 BCD network code.
930 The returned <opr> string shall not be in BCD format, but
931 in IRA characters converted from BCD. Hence the number
932 will have the structure (CC digit 3)(CC digit 2)(CC digit 1)
933 (NW digit 2)(NW digit 1).
934
935 */
936
937 GLOBAL T_ATI_RSLT setatPercentCHPL( char *cl, UBYTE srcId )
938 {
939 T_ACI_CHPL_FRMT format = CHPL_FRMT_NotPresent;
940
941 #ifndef FF_ATI_BAT
942 T_ACI_OPER_NTRY oper;
943 #endif
944
945 T_ACI_RETURN ret = AT_FAIL;
946
947 TRACE_FUNCTION( "setatPercentCHPL()" );
948
949 if (CFUNfun NEQ CFUN_FUN_Full)
950 {
951 TRACE_EVENT_P1("+COPS error: cannot proceed Mobile has no Full CFUN: %d", CFUNfun);
952 cmdCmeError(CME_ERR_OpNotAllow);
953 return ATI_FAIL;
954 }
955
956 /* parse mode */
957 cl = parse (cl, "d", &format);
958 if ((!cl) OR (format > CHPL_FRMT_Numeric) OR (format < CHPL_FRMT_NotPresent))
959 {
960 cmdCmeError (CME_ERR_OpNotAllow);
961 return (ATI_FAIL);
962 }
963
964 #ifdef FF_ATI_BAT
965
966 {
967 T_BAT_cmd_send cmd;
968 T_BAT_cmd_set_percent_chpl chpl;
969
970 cmd.ctrl_params = BAT_CMD_SET_PERCENT_CHPL;
971 cmd.params.ptr_set_percent_chpl=&chpl;
972
973 /*
974 * This relies on T_ACI_CHPL_FRMT and T_BAT_percent_chpl_oprfrmt being
975 * identical.
976 */
977 chpl.oprfrmt=(T_BAT_percent_chpl_oprfrmt)format;
978
979 bat_send(ati_bat_get_client(srcId), &cmd);
980 return(ATI_EXCT);
981 }
982
983 #else /* no FF_ATI_BAT */
984
985 ret = sAT_PercentCHPL (srcId, &oper);
986 if (ret NEQ AT_CMPL)
987 {
988 cmdCmeError(CME_ERR_Unknown);
989 return (ATI_FAIL);
990 }
991
992 switch (format)
993 {
994 case CHPL_FRMT_Long :
995 sprintf(g_sa, "%s: %s", "%CHPL", oper.longName);
996 break;
997
998 case CHPL_FRMT_Short :
999 sprintf(g_sa, "%s: %s", "%CHPL", oper.shrtName);
1000 break;
1001
1002 case CHPL_FRMT_Numeric :
1003 if ((oper.mnc & 0x00F) EQ 0xF)
1004 /*lint -e{702} */
1005 sprintf(g_sa, "%s: %03x,%02x", "%CHPL", oper.mcc, oper.mnc >> 4);
1006 else
1007 sprintf(g_sa, "%s: %03x,%03x", "%CHPL", oper.mcc, oper.mnc);
1008 break;
1009
1010 default :
1011 cmdCmeError(CME_ERR_Unknown);
1012 return (ATI_FAIL);
1013 }
1014 io_sendMessage (srcId, g_sa, ATI_NORMAL_OUTPUT);
1015
1016 return(ATI_CMPL);
1017
1018 #endif /* no FF_ATI_BAT */
1019 }
1020
1021 /*
1022 +--------------------------------------------------------------------+
1023 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1024 | STATE : code ROUTINE : setatPlusCTZR |
1025 +--------------------------------------------------------------------+
1026
1027 PURPOSE : %CTZR command (Timezone Mode)
1028 */
1029 GLOBAL T_ATI_RSLT setatPlusCTZR (char *cl, UBYTE srcId)
1030 {
1031 T_ACI_CTZR_MODE mode = CTZR_MODE_OFF; /* CTZR */
1032 T_ACI_RETURN ret = AT_FAIL;
1033
1034 TRACE_FUNCTION( "setatPlusCTZR()" );
1035
1036 /* parse mode */
1037 cl = parse (cl, "d", &mode);
1038 if ((!cl) OR (mode > CTZR_MODE_ON) OR (mode < CTZR_MODE_OFF))
1039 {
1040 cmdCmeError (CME_ERR_OpNotAllow);
1041 return (ATI_FAIL);
1042 }
1043
1044 ret = sAT_PlusCTZR (srcId, mode);
1045
1046 switch (ret)
1047 {
1048 case (AT_CMPL): /*operation completed*/
1049 break;
1050
1051 default:
1052 cmdCmeError(CME_ERR_Unknown); /*Command failed*/
1053 break;
1054 }
1055 return (map_aci_2_ati_rslt(ret));
1056
1057 }
1058
1059 /*
1060 +--------------------------------------------------------------------+
1061 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1062 | STATE : code ROUTINE : queatPlusCTZR |
1063 +--------------------------------------------------------------------+
1064
1065 PURPOSE : %CTZR command (Timezone Mode)
1066 */
1067 GLOBAL T_ATI_RSLT queatPlusCTZR (char *cl, UBYTE srcId)
1068 {
1069 T_ACI_CTZR_MODE mode;
1070 T_ACI_RETURN ret = AT_FAIL;
1071
1072 TRACE_FUNCTION("queatPlusCTZR()");
1073
1074 ret = qAT_PlusCTZR(srcId, &mode);
1075 if (ret NEQ AT_CMPL)
1076 {
1077 cmdCmeError(CME_ERR_Unknown);
1078 return (ATI_FAIL);
1079 }
1080
1081 sprintf(g_sa,"+CTZR: %d", mode);
1082 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
1083
1084 return ATI_CMPL;
1085 }
1086
1087 /*
1088 +--------------------------------------------------------------------+
1089 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1090 | STATE : code ROUTINE : setatPlusCTZU |
1091 +--------------------------------------------------------------------+
1092
1093 PURPOSE : +CTZU command (Timezone Update)
1094 */
1095 GLOBAL T_ATI_RSLT setatPlusCTZU (char *cl, UBYTE srcId)
1096 {
1097 T_ACI_CTZU_MODE mode = CTZU_MODE_OFF; /* CTZU */
1098 T_ACI_RETURN ret = AT_FAIL;
1099
1100 TRACE_FUNCTION( "setatPlusCTZU()" );
1101
1102 /* parse mode */
1103 cl = parse (cl, "d", &mode);
1104 if ((!cl) OR (mode > CTZU_MODE_ON) OR (mode < CTZU_MODE_OFF))
1105 {
1106 cmdCmeError (CME_ERR_OpNotAllow);
1107 return (ATI_FAIL);
1108 }
1109
1110 #ifdef FF_ATI_BAT
1111
1112 {
1113 T_BAT_cmd_send cmd;
1114 T_BAT_cmd_set_plus_ctzu ctzu;
1115
1116 cmd.ctrl_params = BAT_CMD_SET_PLUS_CTZU;
1117 cmd.params.ptr_set_plus_ctzu=&ctzu;
1118
1119 /*
1120 * This relies on T_ACI_CTZU_MODE and T_BAT_plus_ctzu_onoff being
1121 * identical.
1122 */
1123 ctzu.onoff=(T_BAT_plus_ctzu_onoff)mode;
1124
1125 bat_send(ati_bat_get_client(srcId), &cmd);
1126 return(ATI_EXCT);
1127 }
1128
1129 #else /* no FF_ATI_BAT */
1130
1131 ret = sAT_PlusCTZU (srcId, mode);
1132
1133 switch (ret)
1134 {
1135 case (AT_CMPL): /*operation completed*/
1136 break;
1137
1138 default:
1139 cmdCmeError(CME_ERR_Unknown); /*Command failed*/
1140 break;
1141 }
1142 return (map_aci_2_ati_rslt(ret));
1143
1144 #endif /* no FF_ATI_BAT */
1145 }
1146
1147
1148 /*
1149 +--------------------------------------------------------------------+
1150 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1151 | STATE : code ROUTINE : setatPercentCTZV |
1152 +--------------------------------------------------------------------+
1153
1154 PURPOSE : %CTZV command (time and date report)
1155 */
1156 GLOBAL T_ATI_RSLT setatPercentCTZV (char *cl, UBYTE srcId)
1157 {
1158 T_ACI_PCTZV_MODE mode = PCTZV_MODE_OFF; /* %CTZV */
1159 T_ACI_RETURN ret = AT_FAIL;
1160
1161 TRACE_FUNCTION( "setatPercentCTZV()" );
1162
1163 /* parse mode */
1164 cl = parse (cl, "d", &mode);
1165 if ((!cl) OR (mode > PCTZV_MODE_ON) OR (mode < PCTZV_MODE_OFF))
1166 {
1167 cmdCmeError (CME_ERR_OpNotAllow);
1168 return (ATI_FAIL);
1169 }
1170
1171 ret = sAT_PercentCTZV (srcId, mode);
1172
1173 switch (ret)
1174 {
1175 case (AT_CMPL): /*operation completed*/
1176 break;
1177
1178 default:
1179 cmdCmeError(CME_ERR_Unknown); /*Command failed*/
1180 break;
1181 }
1182 return (map_aci_2_ati_rslt(ret));
1183
1184 }
1185
1186
1187
1188 /*
1189 +--------------------------------------------------------------------+
1190 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1191 | STATE : code ROUTINE : setatPercentCNIV |
1192 +--------------------------------------------------------------------+
1193
1194 PURPOSE : %CNIV command (network identity report)
1195 */
1196 GLOBAL T_ATI_RSLT setatPercentCNIV (char *cl, UBYTE srcId)
1197 {
1198 T_ACI_CNIV_MODE mode = CNIV_MODE_OFF; /* CNIV */
1199 T_ACI_RETURN ret = AT_FAIL;
1200
1201 TRACE_FUNCTION( "setatPercentCNIV()" );
1202
1203 /* parse mode */
1204 cl = parse (cl, "d", &mode);
1205 if ((!cl) OR (mode > CNIV_MODE_ON) OR (mode < CNIV_MODE_OFF))
1206 {
1207 cmdCmeError (CME_ERR_OpNotAllow);
1208 return (ATI_FAIL);
1209 }
1210
1211 ret = sAT_PercentCNIV (srcId, mode);
1212
1213 switch (ret)
1214 {
1215 case (AT_CMPL): /*operation completed*/
1216 break;
1217
1218 default:
1219 cmdCmeError(CME_ERR_Unknown); /*Command failed*/
1220 break;
1221 }
1222 return (map_aci_2_ati_rslt(ret));
1223
1224 }
1225
1226
1227
1228
1229 /*
1230 +--------------------------------------------------------------------+
1231 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1232 | STATE : code ROUTINE : queatPlusCTZU |
1233 +--------------------------------------------------------------------+
1234
1235 PURPOSE : +CTZU query command (Timezone update)
1236 */
1237 GLOBAL T_ATI_RSLT queatPlusCTZU (char *cl, UBYTE srcId)
1238 {
1239 #ifndef FF_ATI_BAT
1240 T_ACI_CTZU_MODE mode;
1241 T_ACI_RETURN ret = AT_FAIL;
1242 #endif
1243
1244 TRACE_FUNCTION("queatPlusCTZU()");
1245
1246 #ifdef FF_ATI_BAT
1247 {
1248 T_BAT_cmd_send cmd;
1249 T_BAT_no_parameter dummy;
1250
1251 cmd.ctrl_params = BAT_CMD_QUE_PLUS_CTZU;
1252 dummy.bat_dummy = 0xFF;
1253 cmd.params.ptr_que_plus_ctzu = &dummy;
1254 bat_send(ati_bat_get_client(srcId), &cmd);
1255 return(ATI_EXCT);
1256 }
1257 #else /* no FF_ATI_BAT */
1258
1259 ret = qAT_PlusCTZU(srcId, &mode);
1260 if (ret NEQ AT_CMPL)
1261 {
1262 cmdCmeError(CME_ERR_Unknown);
1263 return (ATI_FAIL);
1264 }
1265
1266 sprintf(g_sa,"+CTZU: %d", mode);
1267 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
1268
1269 return ATI_CMPL;
1270
1271 #endif /* no FF_ATI_BAT */
1272 }
1273
1274
1275
1276 /*
1277 +--------------------------------------------------------------------+
1278 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1279 | STATE : code ROUTINE : queatPercentCTZV |
1280 +--------------------------------------------------------------------+
1281
1282 PURPOSE : %CTZV command (time and date report)
1283 */
1284 GLOBAL T_ATI_RSLT queatPercentCTZV (char *cl, UBYTE srcId)
1285 {
1286 T_ACI_PCTZV_MODE mode;
1287 T_ACI_RETURN ret = AT_FAIL;
1288
1289 TRACE_FUNCTION("queatPercentCTZV()");
1290
1291 ret = qAT_PercentCTZV(srcId, &mode);
1292 if (ret NEQ AT_CMPL)
1293 {
1294 cmdCmeError(CME_ERR_Unknown);
1295 return (ATI_FAIL);
1296 }
1297
1298 sprintf(g_sa,"%s: %d","%CTZV", mode);
1299 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
1300
1301 return ATI_CMPL;
1302 }
1303
1304
1305 /*
1306 +--------------------------------------------------------------------+
1307 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1308 | STATE : code ROUTINE : queatPercentCNIV |
1309 +--------------------------------------------------------------------+
1310
1311 PURPOSE : %CNIV command (time and date report)
1312 */
1313 GLOBAL T_ATI_RSLT queatPercentCNIV (char *cl, UBYTE srcId)
1314 {
1315 T_ACI_CNIV_MODE mode;
1316 T_ACI_RETURN ret = AT_FAIL;
1317
1318 TRACE_FUNCTION("queatPercentCNIV()");
1319
1320 ret = qAT_PercentCNIV(srcId, &mode);
1321 if (ret NEQ AT_CMPL)
1322 {
1323 cmdCmeError(CME_ERR_Unknown);
1324 return (ATI_FAIL);
1325 }
1326 sprintf(g_sa,"%s: %d","%CNIV", mode);
1327 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
1328
1329 return ATI_CMPL;
1330 }
1331
1332 /*
1333 +--------------------------------------------------------------------+
1334 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1335 | STATE : code ROUTINE : setatPercentTREG |
1336 +--------------------------------------------------------------------+
1337
1338 PURPOSE : %CWUP command (force power campaign)
1339 */
1340
1341 GLOBAL T_ATI_RSLT setatPercentCWUP (char *cl, UBYTE srcId)
1342 {
1343 T_ACI_RETURN ret = AT_FAIL;
1344 T_ACI_CWUP_TYPE type;
1345
1346 TRACE_FUNCTION( "setatPercentCWUP()" );
1347
1348 /* parse mode */
1349 cl = parse (cl, "d", &type);
1350 if ((!cl) OR (type NEQ CWUP_TYPE_RR))
1351 {
1352 cmdCmeError (CME_ERR_OpNotAllow);
1353 return (ATI_FAIL);
1354 }
1355
1356 #ifdef FF_ATI_BAT
1357
1358 {
1359 T_BAT_cmd_send cmd;
1360 T_BAT_cmd_set_percent_cwup cwup;
1361
1362 cmd.ctrl_params = BAT_CMD_SET_PERCENT_CWUP;
1363 cmd.params.ptr_set_percent_cwup=&cwup;
1364
1365 /*
1366 * This relies on T_ACI_CWUP_TYPE and T_BAT_percent_cwup_type being
1367 * identical.
1368 */
1369 cwup.type=(T_BAT_percent_cwup_type)type;
1370
1371 bat_send(ati_bat_get_client(srcId), &cmd);
1372 return(ATI_EXCT);
1373 }
1374
1375 #else /* no FF_ATI_BAT */
1376
1377 ret = sAT_PercentCWUP (srcId, type);
1378
1379 switch (ret)
1380 {
1381 case (AT_CMPL): /*operation completed*/
1382 break;
1383
1384 default:
1385 cmdCmeError(CME_ERR_Unknown); /*Command failed*/
1386 break;
1387 }
1388 return (map_aci_2_ati_rslt(ret));
1389
1390 #endif /* no FF_ATI_BAT */
1391 }
1392
1393 /*
1394 +--------------------------------------------------------------------+
1395 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1396 | STATE : code ROUTINE : atPlusCIND |
1397 +--------------------------------------------------------------------+
1398
1399 PURPOSE : +CIND command
1400 (configures the signal strength and SMS full indication)
1401 */
1402 GLOBAL T_ATI_RSLT setatPlusCIND (char *cl, UBYTE srcId)
1403 {
1404 T_ACI_RETURN tRet = AT_FAIL;
1405 T_ACI_MM_CIND_VAL_TYPE sCindSettings;
1406
1407 TRACE_FUNCTION("setatPLusCIND()");
1408
1409 if (!cl)
1410 {
1411 cmdCmeError(CME_ERR_OpNotAllow);
1412 return ATI_FAIL;
1413 }
1414
1415 sCindSettings.sCindSignalParam = 0;
1416 sCindSettings.sCindSmsFullParam = 0;
1417
1418 cl = parse(cl,"dd", &sCindSettings.sCindSignalParam,
1419 &sCindSettings.sCindSmsFullParam);
1420
1421 if ((sCindSettings.sCindSignalParam < CIND_SIGNAL_INDICATOR_LVL0 ||
1422 sCindSettings.sCindSignalParam > CIND_SIGNAL_INDICATOR_LVL5) ||
1423 (sCindSettings.sCindSmsFullParam < CIND_SMSFULL_INDICATOR_MEMAVAIL ||
1424 sCindSettings.sCindSmsFullParam > CIND_SMSFULL_INDICATOR_MEMFULL))
1425 {
1426 cmdCmeError(CME_ERR_OpNotAllow);
1427 return ATI_FAIL;
1428 }
1429
1430 #ifdef FF_ATI_BAT
1431 {
1432 T_BAT_cmd_send cmd;
1433 T_BAT_cmd_set_plus_cind cind;
1434
1435 /*
1436 * Without this we will lose track of the source ID by the time the
1437 * response arrives.
1438 */
1439 srcId_cb=srcId;
1440
1441 cmd.ctrl_params = BAT_CMD_SET_PLUS_CIND;
1442 cmd.params.ptr_set_plus_cind=&cind;
1443
1444 /*
1445 * This relies on T_ACI_CIND_SIGNAL_TYPE being identical to
1446 * T_BAT_plus_cind_signal_ctrl and T_ACI_CIND_SMSFULL_TYPE being
1447 * identical to T_BAT_plus_cind_smsfull_ctrl.
1448 */
1449 cind.signal_ctrl=(T_BAT_plus_cind_signal_ctrl)sCindSettings.sCindSignalParam;
1450 cind.smsfull_ctrl=(T_BAT_plus_cind_smsfull_ctrl)sCindSettings.sCindSmsFullParam;
1451
1452 bat_send(ati_bat_get_client(srcId), &cmd);
1453 return(ATI_EXCT);
1454 }
1455 #else /* no FF_ATI_BAT */
1456
1457 tRet = sAT_PlusCIND( srcId, sCindSettings.sCindSignalParam,
1458 sCindSettings.sCindSmsFullParam );
1459
1460 if (tRet EQ AT_FAIL)
1461 {
1462 cmdCmeError(CME_ERR_OpNotAllow);
1463 return ATI_FAIL;
1464 }
1465 return ATI_CMPL;
1466
1467 #endif /* no FF_ATI_BAT */
1468 }
1469
1470 /*
1471 +--------------------------------------------------------------------+
1472 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1473 | STATE : code ROUTINE : queatPlusCIND |
1474 +--------------------------------------------------------------------+
1475
1476 PURPOSE : +CIND query command
1477 (query the configured unsolicited signal strength
1478 and SMS full indication settings)
1479 */
1480 GLOBAL T_ATI_RSLT queatPlusCIND ( char *cl, UBYTE srcId )
1481 {
1482 #ifndef FF_ATI_BAT
1483 T_ACI_RETURN sRet = AT_FAIL;
1484 T_ACI_MM_CIND_VAL_TYPE sCindSettings;
1485 #endif
1486
1487 TRACE_FUNCTION("queatPlusCIND()");
1488
1489 #ifdef FF_ATI_BAT
1490 {
1491 T_BAT_cmd_send cmd;
1492 T_BAT_no_parameter dummy;
1493
1494 cmd.ctrl_params = BAT_CMD_QUE_PLUS_CIND;
1495 dummy.bat_dummy = 0xFF;
1496 cmd.params.ptr_que_plus_cind = &dummy;
1497 bat_send(ati_bat_get_client(srcId), &cmd);
1498 return(ATI_EXCT);
1499 }
1500 #else /* no FF_ATI_BAT */
1501
1502 sRet = qAT_PlusCIND( srcId, &sCindSettings.sCindSignalParam,
1503 &sCindSettings.sCindSmsFullParam );
1504
1505 if ( sCindSettings.sCindSignalParam == CIND_SIGNAL_INDICATOR_INVALID ) { sCindSettings.sCindSignalParam = CIND_SIGNAL_INDICATOR_LVL0; }
1506 if ( sCindSettings.sCindSmsFullParam == CIND_SMSFULL_INDICATOR_INVALID ) { sCindSettings.sCindSmsFullParam = CIND_SMSFULL_INDICATOR_MEMAVAIL; }
1507
1508 if (sRet EQ AT_CMPL)
1509 {
1510 resp_disp( srcId, cl,"ee", &sCindSettings.sCindSignalParam,
1511 &sCindSettings.sCindSmsFullParam );
1512 return ATI_CMPL;
1513 }
1514 else
1515 { /* error case */
1516 cmdCmeError(CME_ERR_OpNotAllow);
1517 return ATI_FAIL;
1518 }
1519
1520 #endif /* no FF_ATI_BAT */
1521 }
1522
1523 /*
1524 +--------------------------------------------------------------------+
1525 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1526 | STATE : code ROUTINE : atPlusCMER |
1527 +--------------------------------------------------------------------+
1528
1529 PURPOSE : +CMER command
1530 (configures the kind of indication handling toward terminal)
1531 */
1532 GLOBAL T_ATI_RSLT setatPlusCMER ( char *cl, UBYTE srcId )
1533 {
1534 // UINT uiBufferCounter;
1535 T_ACI_RETURN tRet = AT_FAIL;
1536 T_ACI_MM_CMER_VAL_TYPE sCmerSettings;
1537 T_ACI_MM_CMER_VAL_TYPE sOldCmerSettings;
1538 T_ACI_MM_CMER_VAL_TYPE sEnteredCmerSettings;
1539 UINT uiDummy1 = 0u;
1540 UINT uiDummy2 = 0u;
1541
1542 TRACE_FUNCTION("setatPLusCMER()");
1543
1544 if (!cl)
1545 {
1546 cmdCmeError(CME_ERR_OpNotAllow);
1547 return ATI_FAIL;
1548 }
1549
1550 sCmerSettings.sCmerModeParam = CMER_MODE_INVALID;
1551 sCmerSettings.sCmerIndParam = CMER_INDICATOR_INVALID;
1552 sCmerSettings.sCmerBfrParam = CMER_BFR_INVALID;
1553
1554 cl = parse(cl,"ddddd", &sCmerSettings.sCmerModeParam,
1555 &uiDummy1,
1556 &uiDummy2,
1557 &sCmerSettings.sCmerIndParam,
1558 &sCmerSettings.sCmerBfrParam );
1559
1560 if ((sCmerSettings.sCmerModeParam < CMER_MODE_INVALID||
1561 sCmerSettings.sCmerModeParam > CMER_MODE_2) ||
1562 (sCmerSettings.sCmerIndParam < CMER_INDICATOR_INVALID||
1563 sCmerSettings.sCmerIndParam > CMER_INDICATOR_2) ||
1564 (sCmerSettings.sCmerBfrParam < CMER_BFR_INVALID||
1565 sCmerSettings.sCmerBfrParam > CMER_BFR_1) ||
1566 (uiDummy1 != 0u) || ((uiDummy2 != 0u)))
1567 {
1568 cmdCmeError(CME_ERR_OpNotAllow);
1569 return ATI_FAIL;
1570 }
1571
1572 cmhMM_GetCmerSettings( srcId, &sOldCmerSettings );
1573
1574 sEnteredCmerSettings.sCmerModeParam = sCmerSettings.sCmerModeParam;
1575
1576 #ifdef FF_ATI_BAT
1577 {
1578 T_BAT_cmd_send cmd;
1579 T_BAT_cmd_set_plus_cmer cmer;
1580
1581 /*
1582 * Without this we will lose track of the source ID by the time the
1583 * response arrives.
1584 */
1585 srcId_cb=srcId;
1586
1587 cmd.ctrl_params = BAT_CMD_SET_PLUS_CMER;
1588 cmd.params.ptr_set_plus_cmer=&cmer;
1589
1590 cmer.ind_option=BAT_CMER_IND_OPTION_NOT_PRESENT;
1591
1592 bat_send(ati_bat_get_client(srcId), &cmd);
1593 return(ATI_EXCT);
1594 }
1595 #else /* no FF_ATI_BAT */
1596
1597 tRet = sAT_PlusCMER( srcId, sCmerSettings.sCmerModeParam,
1598 sCmerSettings.sCmerIndParam,
1599 sCmerSettings.sCmerBfrParam );
1600 if (tRet EQ AT_FAIL)
1601 {
1602 cmdCmeError(CME_ERR_OpNotAllow);
1603 return ATI_FAIL;
1604 }
1605
1606 if ( sCmerSettings.sCmerModeParam == CMER_MODE_INVALID ) { sCmerSettings.sCmerModeParam = sOldCmerSettings.sCmerModeParam; }
1607 if ( sCmerSettings.sCmerIndParam == CMER_INDICATOR_INVALID ) { sCmerSettings.sCmerIndParam = sOldCmerSettings.sCmerIndParam; }
1608 if ( sCmerSettings.sCmerBfrParam == CMER_BFR_INVALID ) { sCmerSettings.sCmerBfrParam = sOldCmerSettings.sCmerBfrParam; }
1609 if ( sCmerSettings.sCmerIndParam == CMER_INDICATOR_INVALID ) { sCmerSettings.sCmerIndParam = 0; }
1610 if ( sCmerSettings.sCmerBfrParam == CMER_BFR_INVALID ) { sCmerSettings.sCmerBfrParam = 0; }
1611
1612 switch( sCmerSettings.sCmerModeParam )
1613 {
1614 case CMER_MODE_INVALID :
1615 case CMER_MODE_0 :
1616 { /* always buffer --> do nothing */
1617 break;
1618 }
1619 case CMER_MODE_1 :
1620 case CMER_MODE_2 :
1621 { /* flush and/or clear buffer */
1622 if ( (sEnteredCmerSettings.sCmerModeParam == CMER_MODE_1) ||
1623 (sEnteredCmerSettings.sCmerModeParam == CMER_MODE_2) )
1624 {
1625 if ( sCmerSettings.sCmerBfrParam == CMER_BFR_0 )
1626 {
1627 cmd_clearCievBuf( srcId );
1628 }
1629 else
1630 { /* BFR == '2' */
1631 cmd_flushCievBuf( srcId );
1632 }
1633
1634 }
1635 break;
1636 }
1637 default :
1638 { /* error case */
1639 cmdCmeError(CME_ERR_OpNotAllow);
1640 return ATI_FAIL;
1641 }
1642 }
1643 return ATI_CMPL;
1644
1645 #endif /* no FF_ATI_BAT */
1646 }
1647
1648 /*
1649 +--------------------------------------------------------------------+
1650 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1651 | STATE : code ROUTINE : queatPlusCMER |
1652 +--------------------------------------------------------------------+
1653
1654 PURPOSE : +CMER query command
1655 (query the configured indication handling settings
1656 toward terminal )
1657 */
1658 GLOBAL T_ATI_RSLT queatPlusCMER ( char *cl, UBYTE srcId )
1659 {
1660 #ifndef FF_ATI_BAT
1661 T_ACI_RETURN sRet = AT_FAIL;
1662 T_ACI_MM_CMER_VAL_TYPE sCmerSettings;
1663 UINT uiDummy = 0u;
1664 #endif
1665
1666 TRACE_FUNCTION("queatPLusCMER()");
1667
1668 #ifdef FF_ATI_BAT
1669 {
1670 T_BAT_cmd_send cmd;
1671 T_BAT_no_parameter dummy;
1672
1673 cmd.ctrl_params = BAT_CMD_QUE_PLUS_CMER;
1674 dummy.bat_dummy = 0xFF;
1675 cmd.params.ptr_que_plus_cmer = &dummy;
1676 bat_send(ati_bat_get_client(srcId), &cmd);
1677 return(ATI_EXCT);
1678 }
1679 #else /* no FF_ATI_BAT */
1680
1681 sRet = qAT_PlusCMER( srcId, &sCmerSettings.sCmerModeParam,
1682 &sCmerSettings.sCmerIndParam,
1683 &sCmerSettings.sCmerBfrParam );
1684
1685 if (sRet NEQ AT_CMPL)
1686 {
1687 cmdCmeError(CME_ERR_OpNotAllow);
1688 return ATI_FAIL;
1689 }
1690
1691 if ( sCmerSettings.sCmerModeParam == CMER_MODE_INVALID ) { sCmerSettings.sCmerModeParam = CMER_MODE_0; };
1692 if ( sCmerSettings.sCmerIndParam == CMER_MODE_INVALID ) { sCmerSettings.sCmerIndParam = CMER_INDICATOR_0; };
1693 if ( sCmerSettings.sCmerBfrParam == CMER_MODE_INVALID ) { sCmerSettings.sCmerBfrParam = CMER_BFR_0; };
1694
1695 resp_disp( srcId, cl,"eeeee",&sCmerSettings.sCmerModeParam,
1696 &uiDummy,
1697 &uiDummy,
1698 &sCmerSettings.sCmerIndParam,
1699 &sCmerSettings.sCmerBfrParam );
1700 return ATI_CMPL;
1701
1702 #endif /* no FF_ATI_BAT */
1703 }
1704
1705 /*
1706 +--------------------------------------------------------------------+
1707 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1708 | STATE : code ROUTINE : cmd_flushCievBuf |
1709 +--------------------------------------------------------------------+
1710
1711 PURPOSE : This function flushes the buffer for storing new signal-
1712 and/or SMS-full indications while the serial interface is
1713 released from data transmission.
1714 */
1715 GLOBAL void cmd_flushCievBuf ( UBYTE srcId )
1716 {
1717 UINT uiBufferCounter;
1718 UINT uiTempLastIndex;
1719 T_ACI_MM_CIND_VAL_TYPE sCindValues;
1720 T_ACI_MM_CMER_VAL_TYPE sCmerSettings;
1721
1722 TRACE_FUNCTION("cmd_flushCievBuf");
1723
1724 /* Signal buffer */
1725 uiTempLastIndex = asCievSignalBuf.uiLastIndex;
1726 cmhMM_GetCmerSettings(srcId, &sCmerSettings);
1727 for( uiBufferCounter=0; uiBufferCounter < uiTempLastIndex; uiBufferCounter++ )
1728 {
1729 sCindValues.sCindSignalParam = asCievSignalBuf.asBufferValues[uiBufferCounter];
1730 sCindValues.sCindSmsFullParam = CIND_SMSFULL_INDICATOR_INVALID;
1731 rCI_PlusCIEV( sCindValues, sCmerSettings );
1732 asCievSignalBuf.asBufferValues[uiBufferCounter] = CIND_SIGNAL_INDICATOR_INVALID;
1733 asCievSignalBuf.uiLastIndex--;
1734 }
1735
1736 /* SMS Full buffer */
1737 uiTempLastIndex = asCievSmsFullBuf.uiLastIndex;
1738 for( uiBufferCounter=0; uiBufferCounter < uiTempLastIndex; uiBufferCounter++ )
1739 {
1740 sCindValues.sCindSmsFullParam = asCievSmsFullBuf.asBufferValues[uiBufferCounter];
1741 sCindValues.sCindSignalParam = CIND_SIGNAL_INDICATOR_INVALID;
1742 rCI_PlusCIEV( sCindValues, sCmerSettings );
1743 asCievSmsFullBuf.asBufferValues[uiBufferCounter] = CIND_SMSFULL_INDICATOR_INVALID;
1744 asCievSmsFullBuf.uiLastIndex--;
1745 }
1746 }
1747
1748 /*
1749 +--------------------------------------------------------------------+
1750 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1751 | STATE : code ROUTINE : cmd_clearCievBuf |
1752 +--------------------------------------------------------------------+
1753
1754 PURPOSE : This function clear the buffer for storing new signal-
1755 and/or SMS-full indications
1756 */
1757 GLOBAL void cmd_clearCievBuf ( UBYTE srcId )
1758 {
1759 UBYTE tSrc;
1760
1761 for( tSrc=0; tSrc < CIEV_BUF_SIZE; tSrc++ )
1762 {
1763 asCievSignalBuf.asBufferValues[tSrc] = CIND_SIGNAL_INDICATOR_INVALID;
1764 asCievSmsFullBuf.asBufferValues[tSrc] = CIND_SMSFULL_INDICATOR_INVALID;
1765 }
1766 asCievSignalBuf.uiLastIndex = 0u;
1767 asCievSmsFullBuf.uiLastIndex = 0u;
1768 }
1769
1770 /*
1771 +--------------------------------------------------------------------+
1772 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1773 | STATE : code ROUTINE : cmd_PlusCOPN_CB |
1774 +--------------------------------------------------------------------+
1775
1776 PURPOSE : Call back function for cmd_PlusCOPN_CB
1777 */
1778
1779 GLOBAL void cmd_PlusCOPN_CB ( UBYTE src_id )
1780 {
1781 SHORT startIdx;
1782 UBYTE curCmd;
1783 T_ATI_SRC_PARAMS *src_params;
1784 T_COPN_VAR *COPN_Var;
1785 BOOL ret;
1786
1787
1788 COPN_Var = &mmShrdPrm.COPN_VAR[src_id];
1789
1790
1791 startIdx = COPN_Var->Start_Count;
1792
1793
1794 TRACE_FUNCTION("cmd_PlusCOPN_CB()");
1795
1796 ret = cmd_readCOPNBlock(startIdx,src_id);
1797
1798 if (ret EQ TRUE)
1799 {
1800 src_params = find_element (ati_src_list, src_id, search_ati_src_id);
1801 curCmd = src_params->curAtCmd;
1802 R_AT( RAT_OK, src_id )
1803 ( curCmd );
1804 }
1805 }
1806
1807 GLOBAL BOOL cmd_readCOPNBlock( SHORT startIdx, UBYTE src_id )
1808 {
1809 SHORT lastIdx;
1810 UBYTE idx;
1811 T_ACI_COPN_LST operLst;
1812 T_COPN_VAR *COPN_Var;
1813
1814 COPN_Var = &mmShrdPrm.COPN_VAR[src_id];
1815
1816 TRACE_FUNCTION("cmd_readCOPNBlock()");
1817
1818 if( qAT_PlusCOPN(src_id, COPN_LID_Cnst, startIdx,
1819 &lastIdx, operLst) EQ AT_FAIL )
1820 return TRUE;
1821
1822 for( idx=0; idx < MAX_OPER; idx++ )
1823 {
1824 if( operLst[idx].numOper[0] EQ 0x0 )
1825 return TRUE;
1826
1827 sprintf(g_sa,"+COPN: \"%s\",\"%s\"",operLst[idx].numOper,
1828 operLst[idx].alphaOper );
1829 io_sendMessage(src_id, g_sa, ATI_NORMAL_OUTPUT);
1830 }
1831 startIdx = lastIdx+1;
1832 COPN_Var->Start_Count = startIdx;
1833 return FALSE;
1834 }
1835
1836
1837 #endif /* ATI_MM_C */