comparison src/aci2/aci/ati_cphs.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: $Workfile:: ati_cphs.c $|
4 | $Author:: $Revision:: $|
5 | CREATED: $Modtime:: $|
6 | STATE : code |
7 +--------------------------------------------------------------------+
8
9 MODULE : ATI
10
11 PURPOSE : CPHS related proprietery AT commands.
12 */
13
14 #ifdef FF_CPHS
15
16 #ifndef ATI_CPHS_C
17 #define ATI_CPHS_C
18
19 #include "aci_all.h"
20 #include "aci_cmh.h"
21 #include "ati_cmd.h"
22 #include "aci_cmd.h"
23 #include "aci_lst.h"
24 #include "ati_int.h"
25 #include "aci_prs.h"
26 #include "aci_mem.h"
27 #include "aci_io.h"
28
29 #include "cphs.h"
30 #include "aci_cphs.h"
31
32 #ifdef FF_ATI_BAT
33
34 #include "typedefs.h"
35 #include "gdd.h"
36 #include "bat.h"
37
38 #include "ati_bat.h"
39
40 #endif /* FF_ATI_BAT */
41
42 LOCAL T_ATI_RSLT query_indicator_flags(UBYTE srcId, T_CPHS_LINES queried_lines, T_ACI_AT_CMD indicator_type);
43
44 /*
45 +--------------------------------------------------------------------+
46 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
47 | STATE : code ROUTINE : atPercentCPHS |
48 +--------------------------------------------------------------------+
49
50 PURPOSE : %CPHS: CPHS module initialing/closing/refreshing
51 */
52
53 GLOBAL T_ATI_RSLT setatPercentCPHS (CHAR *cl, UBYTE srcId)
54 {
55 T_ACI_CPHS_INIT initMode;
56 T_ACI_RETURN ret = ATI_FAIL;
57 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
58
59 cl = parse(cl, "d", &initMode);
60 if (cl EQ NULL)
61 {
62 cmdCmeError(CME_ERR_OpNotAllow);
63 return ret;
64 }
65
66 #ifdef FF_ATI_BAT
67 {
68 T_BAT_cmd_send cmd;
69 T_BAT_cmd_set_percent_cphs my_bat_set_percent_cphs;
70
71 TRACE_FUNCTION("setatPercentCPHS() calls bat_send() <=== as APPLICATION");
72
73 memset(&my_bat_set_percent_cphs, 0, sizeof(my_bat_set_percent_cphs));
74 cmd.ctrl_params = BAT_CMD_SET_PERCENT_CPHS;
75 cmd.params.ptr_set_percent_cphs = &my_bat_set_percent_cphs;
76
77 my_bat_set_percent_cphs.init_mode = initMode;
78 src_params->curAtCmd = AT_CMD_CPHS;
79 bat_send(ati_bat_get_client(srcId), &cmd);
80
81 return ATI_EXCT; /* executing, because response is passed by callback function */
82 }
83 #else /* OLD FUNCTION BODY */
84 TRACE_FUNCTION("setatPercentCPHS()");
85
86 ret=sAT_PercentCPHS(srcId, initMode);
87
88 switch (ret)
89 {
90 case (AT_EXCT):
91 src_params->curAtCmd = AT_CMD_CPHS;
92 break;
93
94 case (AT_BUSY):
95 cmdCmeError(CME_ERR_SimBusy);
96 return(ATI_FAIL);
97
98 case (AT_FAIL):
99 cmdCmeError(CME_ERR_Unknown);
100 return(ATI_FAIL);
101 }
102
103 return(map_aci_2_ati_rslt(ret));
104
105 #endif /* no FF_ATI_BAT*/
106 }
107
108 GLOBAL T_ATI_RSLT queatPercentCPHS (CHAR *cl, UBYTE srcId)
109 {
110 T_ACI_CPHS_INIT initMode;
111 T_ACI_RETURN ret;
112
113 TRACE_FUNCTION("queatPercentCPHS()");
114
115 ret = qAT_PercentCPHS(srcId, &initMode);
116
117 if (ret NEQ AT_CMPL)
118 {
119 cmdCmeError(CME_ERR_Unknown);
120 return(ATI_FAIL);
121 }
122
123 sprintf(g_sa, "%s%d", "%CPHS: ", initMode);
124 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
125 return(ATI_CMPL);
126 }
127
128
129 /*
130 +--------------------------------------------------------------------+
131 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
132 | STATE : code ROUTINE : atPercentCPNUMS |
133 +--------------------------------------------------------------------+
134
135 PURPOSE : %CPNUMS: CPHS information numbers management.
136 */
137
138 GLOBAL T_ATI_RSLT setatPercentCPNUMS (CHAR *cl, UBYTE srcId)
139 {
140 SHORT element_id;
141 T_CPHS_CPNUMS_MODE mode;
142 T_ACI_RETURN ret = ATI_FAIL;
143
144 cl = parse(cl, "rd", &element_id, &mode);
145 if (cl EQ NULL)
146 {
147 cmdCmeError(CME_ERR_OpNotAllow);
148 return ret;
149 }
150
151 #ifdef FF_ATI_BAT
152 {
153 T_BAT_cmd_send cmd;
154 T_BAT_cmd_set_percent_cpnums my_bat_set_percent_cpnums;
155
156 TRACE_FUNCTION("setatPercentYYYY() calls bat_send() <=== as APPLICATION");
157
158 memset(&my_bat_set_percent_cpnums, 0, sizeof(my_bat_set_percent_cpnums));
159 cmd.ctrl_params = BAT_CMD_SET_PERCENT_CPNUMS;
160 cmd.params.ptr_set_percent_cpnums = &my_bat_set_percent_cpnums;
161
162 my_bat_set_percent_cpnums.element_id = (U8)element_id;
163 my_bat_set_percent_cpnums.mode = mode;
164
165 bat_send(ati_bat_get_client(srcId), &cmd);
166
167 return ATI_EXCT; /* executing, because response is passed by callback function */
168 }
169 #else /* OLD FUNCTION BODY */
170
171 TRACE_FUNCTION("setatPercentCPNUMS()");
172
173 ret=sAT_PercentCPNUMS(srcId, (UBYTE)element_id, (UBYTE)mode);
174
175 if (ret NEQ AT_CMPL)
176 {
177 cmdCmeError(CME_ERR_Unknown);
178 return(ATI_FAIL);
179 }
180
181 return(ATI_CMPL);
182
183 #endif /* no FF_ATI_BAT*/
184 }
185
186 GLOBAL T_ATI_RSLT tesatPercentCPNUMS (CHAR *cl, UBYTE srcId)
187 {
188 T_ACI_RETURN ret;
189
190 TRACE_FUNCTION("tesatPercentCPNUMS()");
191
192 ret = tAT_PercentCPNUMS(srcId);
193
194 if (ret NEQ AT_CMPL)
195 {
196 cmdCmeError(CME_ERR_Unknown);
197 return(ATI_FAIL);
198 }
199 return(ATI_CMPL);
200 }
201
202 /*
203 +--------------------------------------------------------------------+
204 | PROJECT : GSM-F&D (8411) MODULE : ACI_RET |
205 | STATE : code ROUTINE : rCI_PercentCPNUMS |
206 +--------------------------------------------------------------------+
207
208 PURPOSE : handles AT%CPNUMS call back
209 */
210 GLOBAL void rCI_PercentCPNUMS(UBYTE element_index,
211 UBYTE index_level,
212 CHAR *alpha_tag,
213 CHAR *number,
214 BOOL premium_flag,
215 BOOL network_flag,
216 UBYTE type_of_address)
217 {
218 UBYTE srcId = srcId_cb;
219 CHAR cvtd_text[4*CPHS_MAX_INF_ALPHA_TAG];
220 USHORT len_cvtd=0;
221 USHORT pos=0;
222
223 TRACE_FUNCTION("rCI_PercentCPNUMS()");
224
225 utl_chsetFromSim(
226 (UBYTE *)alpha_tag,
227 (USHORT)strlen(alpha_tag),
228 (UBYTE *)cvtd_text,
229 sizeof(cvtd_text),
230 &len_cvtd,
231 GSM_ALPHA_Def);
232
233 pos=sprintf(g_sa,"%s%d,","%CPNUMS: ",element_index);
234 pos+=sprints(g_sa+pos,cvtd_text,len_cvtd);
235 pos+=sprintf(g_sa+pos,",\"%s\",%d,%d,%d,%d",number,index_level,premium_flag,network_flag,type_of_address);
236
237 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
238 }
239
240 #ifndef MFW
241 #ifndef FF_MMI_RIV
242 /* dummy in case of SMI */
243 GLOBAL void rAT_PercentCPNUMS(UBYTE element_index,
244 UBYTE index_level,
245 CHAR *alpha_tag,
246 CHAR *number,
247 BOOL premium_flag,
248 BOOL network_flag,
249 UBYTE type_of_address)
250 {
251 }
252 #endif /*ndef FF_MMI_RIV */
253 #endif /* ndef MFW */
254
255 /*
256 +--------------------------------------------------------------------+
257 | PROJECT : GSM-F&D (8411) MODULE : ACI_RET |
258 | STATE : code ROUTINE : rCI_PercentCPROAM |
259 +--------------------------------------------------------------------+
260
261 PURPOSE : handles %CPROAM indication
262 roam_status = 1 mobile entering roaming service // = 0 going back to home netwrok
263 */
264 GLOBAL void rCI_PercentCPROAM(UBYTE roam_status)
265 {
266 UBYTE srcId = srcId_cb;
267
268 TRACE_FUNCTION("rCI_PercentCPROAM()");
269
270 sprintf(g_sa, "%s: %d", "%CPROAM", roam_status);
271
272 io_sendIndication(srcId, g_sa, ATI_NORMAL_OUTPUT);
273 }
274
275 #ifndef MFW
276 #ifndef FF_MMI_RIV
277 /* dummy in case of SMI */
278 GLOBAL void rAT_PercentCPROAM(UBYTE roam_status)
279 {}
280 #endif /* ndef FF_MMI_RIV */
281 #endif /* ndef MFW */
282
283 /*
284 +--------------------------------------------------------------------+
285 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
286 | STATE : code ROUTINE : atPercentCPALS |
287 +--------------------------------------------------------------------+
288
289 PURPOSE : %CPALS: CPHS Alternate Line Service.
290 */
291
292 LOCAL T_ATI_RSLT proceed_CPALS(UBYTE srcId, UBYTE call_id)
293 {
294 T_ACI_RETURN ret;
295 T_CPHS_LINES active_line;
296 CHAR *line_desc;
297 UBYTE max_line_desc;
298
299 max_line_desc = 30; /* should be enough ! */
300 MALLOC(line_desc, max_line_desc);
301
302 ret = qAT_PercentCPALS(srcId, call_id, &active_line, line_desc, &max_line_desc);
303
304 if (ret EQ AT_EXCT)
305 {
306 TRACE_EVENT_P1("Quite a line_desc !: %d", max_line_desc);
307 MFREE(line_desc);
308 MALLOC(line_desc, MINIMUM(max_line_desc, (MAX_CMD_LEN-10)));
309
310 /* retry */
311 ret = qAT_PercentCPALS(srcId, call_id, &active_line, line_desc, &max_line_desc);
312 }
313
314 if (ret NEQ AT_CMPL)
315 {
316 cmdCmeError(CME_ERR_OpNotAllow);
317 return(ATI_FAIL);
318 }
319
320 sprintf(g_sa, "%s: %d,\"%s\"", "%CPALS", active_line, line_desc);
321 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
322 MFREE(line_desc);
323
324 return(ATI_CMPL);
325 }
326
327 GLOBAL T_ATI_RSLT setatPercentCPALS (CHAR *cl, UBYTE srcId)
328 {
329 SHORT call_id;
330 T_ACI_RETURN ret = AT_FAIL;
331
332 cl = parse(cl, "r", &call_id);
333 if (cl EQ NULL)
334 {
335 cmdCmeError(CME_ERR_OpNotAllow);
336 return ret;
337 }
338
339 #ifdef FF_ATI_BAT
340 {
341 T_BAT_cmd_send cmd;
342 T_BAT_cmd_set_percent_cpals my_bat_set_percent_cpals;
343
344 TRACE_FUNCTION("setatPercentCPALS() calls bat_send() <=== as APPLICATION");
345
346 memset(&my_bat_set_percent_cpals, 0, sizeof(my_bat_set_percent_cpals));
347 cmd.ctrl_params = BAT_CMD_SET_PERCENT_CPALS;
348 cmd.params.ptr_set_percent_cpals = &my_bat_set_percent_cpals;
349
350 my_bat_set_percent_cpals.call_id = (U8)call_id;
351
352 bat_send(ati_bat_get_client(srcId), &cmd);
353
354 return ATI_EXCT; /* executing, because response is passed by callback function */
355 }
356 #else /* OLD FUNCTION BODY */
357
358 TRACE_FUNCTION("setatPercentCPALS()");
359
360 ret = proceed_CPALS(srcId, (UBYTE)call_id);
361 return ret;
362
363 #endif /* no FF_ATI_BAT */
364 }
365
366 GLOBAL T_ATI_RSLT queatPercentCPALS (CHAR *cl, UBYTE srcId)
367 {
368 TRACE_FUNCTION("queatPercentCPALS()");
369
370 return(proceed_CPALS(srcId, NOT_PRESENT_8BIT));
371 }
372
373 GLOBAL T_ATI_RSLT tesatPercentCPALS (CHAR *cl, UBYTE srcId)
374 {
375 TRACE_FUNCTION("tesatPercentCPALS()");
376
377 return(ATI_CMPL);
378 }
379
380 /*
381 +--------------------------------------------------------------------+
382 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
383 | STATE : code ROUTINE : atPercentCPVWI |
384 +--------------------------------------------------------------------+
385
386 PURPOSE : %CPVWI: set/clear/query voice message waiting flags
387 */
388
389 GLOBAL T_ATI_RSLT setatPercentCPVWI(CHAR *cl, UBYTE srcId)
390 {
391 T_CPHS_LINES i = 0,
392 typed_lines = NOT_PRESENT_16BIT,
393 line = 0;
394 SHORT action = 0;
395 T_ACI_RETURN ret = AT_FAIL;
396 T_ATI_SRC_PARAMS *src_params = find_element( ati_src_list, srcId, search_ati_src_id);
397
398 cl = parse(cl,"rr", &action, &typed_lines);
399 if (cl EQ NULL)
400 {
401 cmdCmeError(CME_ERR_OpNotAllow);
402 return(ATI_FAIL);
403 }
404
405 if (typed_lines EQ NOT_PRESENT_16BIT)
406 {
407 TRACE_EVENT("typed_lines omitted");
408
409 typed_lines = 0;
410
411 /* lines parameter omitted: Provides VWI flags for all lines */
412 for(i=0;i<8*sizeof(T_CPHS_LINES);i++)
413 {
414 line = CPHS_LINE1 << i;
415
416 if (cphs_line_makes_sense(line))
417 {
418 typed_lines |= line;
419 }
420 }
421 }
422
423 TRACE_EVENT_P2("setatPercentCPVWI action: %d, lines: %d", action, typed_lines);
424
425
426 #ifdef FF_ATI_BAT
427 {
428 T_BAT_cmd_send cmd;
429 T_BAT_cmd_set_percent_cpvwi my_bat_set_percent_cpvwi;
430
431 TRACE_FUNCTION("setatPercentCPVWI() calls bat_send() <=== as APPLICATION");
432
433 memset(&my_bat_set_percent_cpvwi, 0, sizeof(my_bat_set_percent_cpvwi));
434 cmd.ctrl_params = BAT_CMD_SET_PERCENT_CPVWI;
435 cmd.params.ptr_set_percent_cpvwi = &my_bat_set_percent_cpvwi;
436
437 my_bat_set_percent_cpvwi.mode = action;
438 my_bat_set_percent_cpvwi.lines = typed_lines;
439 src_params->curAtCmd = AT_CMD_CPVWI;
440 bat_send(ati_bat_get_client(srcId), &cmd);
441
442 return ATI_EXCT; /* executing, because response is passed by callback function */
443 }
444 #else /* OLD FUNCTION BODY */
445
446 /******* QUERY ********/
447 if (action EQ CPHS_QUERY_WAITING_FLAG)
448 {
449 ret = query_indicator_flags(srcId, typed_lines, AT_CMD_CPVWI);
450 return ret;
451 }
452
453 TRACE_FUNCTION("setatPercentCPVWI()");
454
455 /******* SETTING ********/
456 ret = sAT_PercentCPVWI(srcId, (UBYTE)action, typed_lines);
457
458 switch (ret)
459 {
460 case (AT_EXCT):
461 src_params->curAtCmd = AT_CMD_CPVWI;
462 break;
463
464 case (AT_BUSY):
465 cmdCmeError(CME_ERR_SimBusy);
466 return(ATI_FAIL);
467
468 case (AT_FAIL):
469 cmdCmeError(CME_ERR_Unknown);
470 return(ATI_FAIL);
471 }
472
473 return(map_aci_2_ati_rslt(ret));
474
475 #endif /* no FF_ATI_BAT*/
476 }
477
478
479 /*
480 +--------------------------------------------------------------------+
481 | PROJECT : GSM-F&D (8411) MODULE : ATI_CPHS |
482 | STATE : code ROUTINE : rCI_PercentCPVWI |
483 +--------------------------------------------------------------------+
484
485 PURPOSE : handles AT_PercentCPVWI call back
486
487 */
488
489 GLOBAL void rCI_PercentCPVWI (UBYTE flag_set,
490 USHORT line)
491 {
492 UBYTE srcId = srcId_cb;
493
494 TRACE_FUNCTION("rCI_PercentCPVWI()");
495
496 sprintf(g_sa, "%s: %d,%d", "%CPVWI", flag_set, line);
497 io_sendIndication((UBYTE)srcId, g_sa, ATI_NORMAL_OUTPUT);
498 }
499
500 #ifndef MFW
501 #ifndef FF_MMI_RIV
502 /* dummy in case of SMI */
503 GLOBAL void rAT_PercentCPVWI ( UBYTE flag_set,
504 USHORT line)
505 { }
506 #endif /* FF_MMI_RIV */
507 #endif /* MFW */
508
509
510 /*
511 +--------------------------------------------------------------------+
512 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
513 | STATE : code ROUTINE : atPercentCPOPN |
514 +--------------------------------------------------------------------+
515
516 PURPOSE : %CPOPN: query operator name string
517 */
518
519 GLOBAL T_ATI_RSLT queatPercentCPOPN(CHAR *cl, UBYTE srcId)
520 {
521 CHAR long_name[CPHS_MAX_OPER_LONG];
522 CHAR short_name[CPHS_MAX_OPER_SHORT];
523 UBYTE long_len;
524 UBYTE short_len;
525 T_ACI_RETURN ret;
526
527 TRACE_FUNCTION("queatPercentCPOPN()");
528
529 long_len = CPHS_MAX_OPER_LONG;
530 short_len = CPHS_MAX_OPER_SHORT;
531 ret = qAT_PercentCPOPN(srcId, long_name, &long_len, short_name, &short_len);
532
533 if (ret NEQ AT_CMPL)
534 {
535 if (short_len > 0 OR
536 long_len > 0)
537 {
538 TRACE_EVENT_P2("Buffer for Long Name or Short Name too small needed: %d, %d", long_len, short_len);
539 }
540
541 cmdCmeError(CME_ERR_Unknown);
542 return(ATI_FAIL);
543 }
544
545 if ( short_len > 0 )
546 {
547 sprintf(g_sa, "%s: \"%s\",\"%s\"", "%CPOPN", long_name, short_name);
548 }
549 else
550 {
551 sprintf(g_sa, "%s: \"%s\"", "%CPOPN", long_name);
552 }
553 io_sendMessage((UBYTE)srcId, g_sa, ATI_NORMAL_OUTPUT);
554
555 return(ATI_CMPL);
556 }
557
558
559 /*
560 +--------------------------------------------------------------------+
561 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
562 | STATE : code ROUTINE : setatPercentCPINF |
563 +--------------------------------------------------------------------+
564
565 PURPOSE : %CPINF: set customer service profile
566 */
567
568 GLOBAL T_ATI_RSLT setatPercentCPINF(CHAR *cl, UBYTE srcId)
569 {
570 CHAR csp[CPHS_MAX_CSP*2 + 1];
571 USHORT csp_size = 0;
572 UBYTE index; /* for parsing failure analysis */
573 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
574
575 /* initialize the local varibles */
576 memset(csp,0,sizeof(csp));
577
578 cl = parse(cl, "z",
579 (LONG)sizeof (csp),
580 strlen(cl),
581 cl,
582 &csp_size,
583 csp);
584
585 if (cl EQ NULL)
586 {
587 index = get_parse_index(); /* get the problematic component */
588 TRACE_EVENT_P1("index %d",index);
589 switch (index)
590 {
591 case 1:
592 cmdCmeError(CME_ERR_TxtToLong);
593 break;
594 default:
595 cmdCmeError(CME_ERR_OpNotAllow);
596 break;
597 }
598 return ATI_FAIL;
599 }
600
601 #ifdef FF_ATI_BAT
602 {
603 T_BAT_cmd_send cmd;
604 T_BAT_cmd_set_percent_cpinf cpinf;
605 TRACE_FUNCTION("setatPercentCPINF() calls bat_send() <=== as APPLICATION");
606
607 memset(&cpinf, 0, sizeof(cpinf));
608 cmd.ctrl_params = BAT_CMD_SET_PERCENT_CPINF;
609 cmd.params.ptr_set_percent_cpinf = &cpinf;
610 cpinf.c_csp = (U8)csp_size;
611 memcpy(cpinf.csp, csp, csp_size);
612 src_params->curAtCmd = AT_CMD_CPINF;
613 bat_send(ati_bat_get_client(srcId), &cmd);
614
615 return ATI_EXCT;
616 }
617 #else
618 {
619 T_ACI_RETURN ret = AT_FAIL;
620 UBYTE serv_group[CPHS_MAX_CSP];
621 UBYTE serv_len = 0;
622
623 TRACE_FUNCTION("setatPercentCPINF()");
624
625 memset(serv_group,0,sizeof(serv_group));
626
627 serv_len = utl_HexStrToBin((UBYTE*)csp, csp_size, serv_group, CPHS_MAX_CSP);
628
629 /* Odd length CSP or empty CSP display operation not allowed */
630 if(((serv_len % 2) NEQ 0) OR (serv_len EQ 0))
631 {
632 cmdCmeError(CME_ERR_OpNotAllow);
633 return ATI_FAIL;
634 }
635 /* write customer service profile (csp) */
636 ret = sAT_PercentCPINF( srcId,
637 serv_group,
638 serv_len);
639
640 switch (ret)
641 {
642 case (AT_EXCT):
643 src_params->curAtCmd = AT_CMD_CPINF;
644 break;
645 case (AT_CMPL):
646 break;
647 default:
648 break;
649 }
650 return(map_aci_2_ati_rslt(ret));
651 }
652 #endif /* no FF_ATI_BAT*/
653 }
654
655 /*
656 +--------------------------------------------------------------------+
657 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
658 | STATE : code ROUTINE : atPercentCPINF |
659 +--------------------------------------------------------------------+
660
661 PURPOSE : %CPINF: query cphs information and customer service profile
662 */
663
664 GLOBAL T_ATI_RSLT queatPercentCPINF(CHAR *cl, UBYTE srcId)
665 {
666 #ifdef FF_ATI_BAT
667 T_BAT_cmd_send cmd;
668 T_BAT_no_parameter dummy;
669
670 TRACE_FUNCTION("queatPercentCPINF() calls bat_send() <=== as APPLICATION");
671
672 cmd.ctrl_params = BAT_CMD_QUE_PERCENT_CPINF;
673 dummy.bat_dummy = 0xFF;
674 cmd.params.ptr_que_percent_cpinf = &dummy;
675
676 bat_send(ati_bat_get_client(srcId),&cmd);
677
678 return ATI_EXCT; /* executing, because response is passed by callback function */
679
680 #else /* FF_ATI_BAT */
681
682 UBYTE phase;
683 USHORT sst;
684 CHAR csp[CPHS_MAX_CSP*2 + 1];
685 CHAR csp2[CPHS_MAX_CSP2*2 + 1];
686 UBYTE max_csp_size = CPHS_MAX_CSP*2 + 1;
687 UBYTE max_csp2_size = CPHS_MAX_CSP2*2 + 1;
688 T_ACI_RETURN ret;
689
690 TRACE_FUNCTION("queatPercentCPINF()");
691
692 ret = qAT_PercentCPINF (srcId,
693 &phase,
694 &sst,
695 csp,
696 csp2,
697 &max_csp_size,
698 &max_csp2_size);
699
700 if (ret NEQ AT_CMPL)
701 {
702 if (max_csp_size > 0)
703 {
704 TRACE_EVENT_P1("Buffer for CSP is too small ! needed: %d", max_csp_size);
705 }
706
707 if (max_csp2_size > 0)
708 {
709 TRACE_EVENT_P1("Buffer for CSP2 is too small ! needed: %d", max_csp2_size);
710 }
711 cmdCmeError(CME_ERR_Unknown);
712 return(ATI_FAIL);
713 }
714
715 if ( max_csp_size > 0 )
716 {
717 if ( max_csp2_size > 0 )
718 {
719 sprintf(g_sa, "%s: %d,\"%04X\",\"%s\",\"%s\"", "%CPINF",phase, sst, csp, csp2);
720 }
721 else
722 {
723 sprintf(g_sa, "%s: %d,\"%04X\",\"%s\"", "%CPINF",phase, sst, csp);
724 }
725 }
726 else
727 {
728 sprintf(g_sa, "%s: %d,\"%04X\"", "%CPINF", phase, sst);
729 }
730 io_sendMessage((UBYTE)srcId, g_sa, ATI_NORMAL_OUTPUT);
731
732 return(ATI_CMPL);
733
734 #endif /* FF_ATI_BAT */
735 }
736
737 /*
738 +--------------------------------------------------------------------+
739 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
740 | STATE : code ROUTINE : atPercentCPMB |
741 +--------------------------------------------------------------------+
742
743 PURPOSE : %CPMB: query mailbox numbers
744 */
745
746 GLOBAL T_ATI_RSLT setatPercentCPMB(CHAR *cl, UBYTE srcId)
747 {
748 SHORT rec_id;
749 T_ACI_RETURN ret = ATI_FAIL;
750
751 cl = parse(cl, "r", &rec_id);
752 if (cl EQ NULL)
753 {
754 cmdCmeError(CME_ERR_OpNotAllow);
755 return ret;
756 }
757
758 #ifdef FF_ATI_BAT
759 {
760 T_BAT_cmd_send cmd;
761 T_BAT_cmd_set_percent_cpmb my_bat_set_percent_cpmb;
762
763 TRACE_FUNCTION("setatPercentCPMB() calls bat_send() <=== as APPLICATION");
764
765 memset(&my_bat_set_percent_cpmb, 0, sizeof(my_bat_set_percent_cpmb));
766 cmd.ctrl_params = BAT_CMD_SET_PERCENT_CPMB;
767 cmd.params.ptr_set_percent_cpmb = &my_bat_set_percent_cpmb;
768
769 my_bat_set_percent_cpmb.record_id = rec_id;
770
771 bat_send(ati_bat_get_client(srcId), &cmd);
772
773 return ATI_EXCT; /* executing, because response is passed by callback function */
774 }
775 #else /* OLD FUNCTION BODY */
776 {
777 T_CPHS_LINES line;
778 CHAR number[CPHS_MAX_MB_NUMBER_LEN];
779 CHAR alpha_id[CPHS_MAX_MB_ALPHA_LEN];
780 T_ACI_TOA_TON ton;
781 T_ACI_TOA_NPI npi;
782 UBYTE toa;
783 CHAR cvtd_text[4*CPHS_MAX_MB_ALPHA_LEN];
784 USHORT len_cvtd=0;
785 USHORT pos=0;
786
787
788 TRACE_FUNCTION("setatPercentCPMB()");
789
790 ret = qAT_PercentCPMB(srcId, (UBYTE)rec_id, &line, number, &ton, &npi, alpha_id, NULL);
791
792 if (ret NEQ AT_CMPL)
793 {
794 cmdCmeError(CME_ERR_Unknown);
795 return(ATI_FAIL);
796 }
797
798 /* check if empty mb entry */
799 if (number[0] EQ '\0')
800 { /* do not send to ATI */
801 cmdCmeError(CME_ERR_NotFound);
802 return(ATI_FAIL);
803 }
804
805 toa = ( ( ( ton << 4 ) & 0xF0 ) + ( npi & 0x0F ) ) | 0x80;
806
807 utl_chsetFromSim(
808 (UBYTE *)alpha_id,
809 (USHORT)strlen(alpha_id),
810 (UBYTE *)cvtd_text,
811 sizeof(cvtd_text),
812 &len_cvtd,
813 GSM_ALPHA_Def);
814
815 pos=sprintf(g_sa,"%s: %d,%d,\"%s\",%d,", "%CPMB", rec_id, line, number, toa);
816 pos+=sprints(g_sa+pos,cvtd_text,len_cvtd);
817
818 io_sendMessage((UBYTE)srcId, g_sa, ATI_NORMAL_OUTPUT);
819
820 return(ATI_CMPL);
821 }
822 #endif /* no FF_ATI_BAT*/
823 }
824
825
826 /*
827 +--------------------------------------------------------------------+
828 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
829 | STATE : code ROUTINE : queatPercentCPMB |
830 +--------------------------------------------------------------------+
831
832 PURPOSE : %CPMB?: query mailbox numbers
833 */
834 GLOBAL T_ATI_RSLT queatPercentCPMB(char *cl, UBYTE srcId)
835 {
836 #ifdef FF_ATI_BAT
837 T_BAT_cmd_send cmd;
838 T_BAT_no_parameter dummy;
839
840 TRACE_FUNCTION("queatPercentCPMB() calls bat_send() <=== as APPLICATION");
841
842 cmd.ctrl_params=BAT_CMD_QUE_PERCENT_CPMB;
843 dummy.bat_dummy=0xFF;
844 cmd.params.ptr_que_percent_cpmb=&dummy;
845
846 bat_send(ati_bat_get_client(srcId),&cmd);
847
848 return ATI_EXCT; /* executing, because response is passed by callback function */
849
850 #else /* FF_ATI_BAT */
851 char *me="%CPMB: ";
852 T_ACI_RETURN ret;
853 UBYTE first;
854
855 TRACE_FUNCTION("queatPercentCPMB()");
856
857 /*
858 * Call the corresponding ACI function.
859 */
860 ret=qAT_PercentCPMB(srcId,(UBYTE)ACI_NumParmNotPresent,NULL,NULL,NULL,NULL,NULL,&first);
861
862 /*
863 * If the query completes successfully, build and send the
864 * answer.
865 */
866 if (ret EQ AT_CMPL)
867 {
868 sprintf(g_sa,"%s%d",me,first);
869 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
870 }
871
872 return (map_aci_2_ati_rslt(ret));
873 #endif /* FF_ATI_BAT */
874 }
875
876
877 /*
878 +--------------------------------------------------------------------+
879 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
880 | STATE : code ROUTINE : atPercentCPMBW |
881 +--------------------------------------------------------------------+
882
883 PURPOSE : %CPMB: write mailbox numbers
884 */
885
886 GLOBAL T_ATI_RSLT setatPercentCPMBW(CHAR *cl, UBYTE srcId)
887 {
888 CHAR number[CPHS_MAX_MB_NUMBER_LEN];
889
890 #ifndef FF_ATI_BAT
891 CHAR *p_number;
892
893 T_CPHS_PB_TEXT cvtdText; /* holds text converted to SIM alpha */
894 T_ACI_TOA toa; /* holds the type of record */
895 T_ACI_RETURN ret;
896 #endif
897
898 UBYTE index; /* for parsing failure analysis */
899
900 CHAR alpha_id[CPHS_MAX_MB_ALPHA_LEN] = {0x00};
901 USHORT len_alpha_id = 0;
902 USHORT lenCvtd = 0; /* holds length of converted text */
903 T_CPHS_PB_TEXT *p_text = NULL; /* holds pointer to converted text */
904
905 T_ACI_TOA *p_toa = NULL; /* holds pointer to type of record */
906 SHORT toa_val = 0; /* holds type of record value */
907 SHORT rec_id = -1; /* holds index of record */
908
909 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
910
911 TRACE_FUNCTION("setatPercentCPMBW()");
912
913 /* initialize */
914 memset(number,0,sizeof(number));
915
916 /***********************************************/
917 /*** prepare parameters and test their range ***/
918 /***********************************************/
919
920 /* parse command string */
921 cl = parse(cl,"rsrz",
922 &rec_id,
923 (LONG)CPHS_MAX_MB_NUMBER_LEN,
924 number,
925 &toa_val,
926 (LONG)CPHS_MAX_MB_ALPHA_LEN,
927 strlen(cl),
928 cl,
929 &len_alpha_id,
930 alpha_id);
931
932 /* Throw error if parsing has been failed */
933 if (!cl)
934 {
935 TRACE_ERROR("ERROR: parsing failed !");
936 /* analyse error component of input */
937 index = get_parse_index(); /* get the problematic component */
938 switch (index)
939 {
940 case 3: /* component 2 is the number */
941 cmdCmeError(CME_ERR_DialToLong);
942 break;
943 case 5: /* component 4 is the alpha tag */
944 cmdCmeError(CME_ERR_TxtToLong);
945 break;
946 default:
947 cmdCmeError(CME_ERR_OpNotAllow);
948 break;
949 }
950 return ATI_FAIL;
951 }
952
953 /* test if values are in correct ranges */
954 if ( rec_id >= CPHS_MAX_MB_ENTRIES) /* phonebook index is greater than max. */
955 {
956 TRACE_ERROR("ERROR: phonebook index is greater than max possible index of SIM");
957 cmdCmeError(CME_ERR_InvIdx);
958 return ATI_FAIL;
959 }
960
961 #ifdef FF_ATI_BAT
962
963 {
964 T_BAT_cmd_send cmd;
965 T_BAT_cmd_set_percent_cpmbw cpmbw;
966 int len;
967
968 cmd.ctrl_params = BAT_CMD_SET_PERCENT_CPMBW;
969 cmd.params.ptr_set_percent_cpmbw=&cpmbw;
970
971 cpmbw.record_id=(T_BAT_record_id)rec_id;
972
973 len=strlen(number);
974
975 if ((len<0) || (len>BAT_MAX_CPMBW_NUMBER_LEN))
976 {
977 /*
978 * Either the number wasn't present, or it was too big to
979 * fit in the BAT message.
980 */
981 cpmbw.v_number=FALSE;
982 cpmbw.type=-1;
983 }
984 else
985 {
986 cpmbw.v_number=TRUE;
987 cpmbw.c_number=(U8)len;
988 memcpy(cpmbw.number,number,len);
989 cpmbw.type=(toa_val>0) ? toa_val:-1;
990 }
991
992 if ((len_alpha_id>0) && (len_alpha_id<=BAT_MAX_CPMBW_TEXT_LEN))
993 {
994 cpmbw.v_text=TRUE;
995 cpmbw.c_text=(U8)len_alpha_id;
996 memcpy(cpmbw.text,alpha_id,len_alpha_id);
997 }
998 else
999 {
1000 /*
1001 * Either the alphanumeric data wasn't present, or it was
1002 * too big to fit in the BAT message.
1003 */
1004 cpmbw.v_text=FALSE;
1005 }
1006
1007 bat_send(ati_bat_get_client(srcId),&cmd);
1008 return(ATI_EXCT);
1009 }
1010
1011 #else /* OLD FUNCTION BODY */
1012
1013 /*
1014 * Initialise 'converted text'.
1015 */
1016 cvtdText.len = 0;
1017 memset(cvtdText.data,0,sizeof(cvtdText.data));
1018
1019 /* extract type structure from type value */
1020 if (toa_val > 0)
1021 {
1022 toa = toa_demerge(toa_val);
1023 p_toa = &toa;
1024 }
1025 else
1026 {
1027 p_toa = NULL;
1028 }
1029
1030 /* translate alpha text to SIM */
1031 if ( len_alpha_id NEQ 0 )
1032 {
1033 srcId_cb = srcId;
1034 utl_chsetToSim ((UBYTE*)alpha_id, len_alpha_id, (UBYTE*)cvtdText.data,
1035 &lenCvtd, GSM_ALPHA_Def);
1036 }
1037
1038 /* set pointer for number */
1039 if (number[0] EQ '\0') /* The number given is empty */
1040 {
1041 p_number = NULL;
1042 }
1043 else
1044 {
1045 p_number = number;
1046 }
1047
1048 /* when the text and the number are both empty, set p_text to NULL */
1049 if (lenCvtd EQ 0 AND p_number EQ NULL)
1050 {
1051 p_text = NULL;
1052 }
1053 else
1054 {
1055 p_text = &cvtdText;
1056 cvtdText.len = (UBYTE)lenCvtd;
1057 }
1058
1059 /* write number into cphs mailbox number phonebook */
1060 ret = sAT_PercentCPMBW(srcId, rec_id, number, &toa, p_text);
1061
1062 switch (ret)
1063 {
1064 case (AT_CMPL): /*operation completed*/
1065 break;
1066 case (AT_EXCT):
1067 src_params->curAtCmd = AT_CMD_CPMBW;
1068 break;
1069 default:
1070 cmdCmeError(CME_ERR_Unknown); /*Command failed*/
1071 break;
1072 }
1073
1074 return (map_aci_2_ati_rslt(ret));
1075
1076 #endif /* no FF_ATI_BAT*/
1077 }
1078
1079 /*
1080 +--------------------------------------------------------------------+
1081 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1082 | STATE : code ROUTINE : atPercentCPMBW |
1083 +--------------------------------------------------------------------+
1084
1085 PURPOSE : %CPMB: test command
1086 */
1087
1088 GLOBAL T_ATI_RSLT tesatPercentCPMBW(char *cl, UBYTE srcId)
1089 {
1090
1091 char *me = "%CPMBW: ";
1092 SHORT first_idx = 0;
1093 SHORT last_idx = 0;
1094 UBYTE tlength = 0;
1095 UBYTE nlength = 0;
1096 T_ACI_RETURN ret = AT_FAIL;
1097
1098 TRACE_FUNCTION("tesatPercentCPMBW");
1099
1100 ret = tAT_PercentCPMBW(srcId,&first_idx,&last_idx,&nlength,&tlength);
1101
1102 if (ret EQ AT_CMPL)
1103 {
1104 sprintf(g_sa,"%s(%d-%d),%d,%s,%d",me,first_idx,last_idx,nlength,"(128-201)",tlength);
1105 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
1106 }
1107 else
1108 {
1109 cmdCmeError(CME_ERR_Unknown);
1110 }
1111 return (map_aci_2_ati_rslt(ret));
1112 }
1113
1114 /*
1115 +--------------------------------------------------------------------+
1116 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1117 | STATE : code ROUTINE : atPercentCPCFU |
1118 +--------------------------------------------------------------------+
1119
1120 PURPOSE : %CPCFU: call diverted flag status
1121 */
1122 typedef T_ACI_RETURN T_QUERY_INDICATOR_CMH_CPHS_FNC (T_ACI_CMD_SRC srcId, UBYTE *cfu_set, T_CPHS_LINES line);
1123
1124 LOCAL T_ATI_RSLT query_indicator_flags(UBYTE srcId, T_CPHS_LINES queried_lines, T_ACI_AT_CMD indicator_type)
1125 {
1126 T_ACI_RETURN ret;
1127 UBYTE flag_set;
1128 T_CPHS_LINES line = CPHS_LINE_NULL,
1129 set_line_bitmask = CPHS_LINE_NULL;
1130 USHORT i;
1131 T_QUERY_INDICATOR_CMH_CPHS_FNC *cmh_query_ind_fnc = NULL;
1132 CHAR *cmd_name = NULL;
1133
1134 switch(indicator_type)
1135 {
1136 case(AT_CMD_CPCFU):
1137 cmh_query_ind_fnc = &qAT_PercentCPCFU;
1138 cmd_name = "%CPCFU";
1139 break;
1140
1141 case(AT_CMD_CPVWI):
1142 cmh_query_ind_fnc = &qAT_PercentCPVWI;
1143 cmd_name = "%CPVWI";
1144 break;
1145 }
1146
1147 /* Provides flags for queried lines */
1148 for(i=0; i<8*sizeof(T_CPHS_LINES); i++)
1149 {
1150 line = CPHS_LINE1 << i;
1151
1152 if ((line & queried_lines) EQ 0x00)
1153 {
1154 /* line has not been queried */
1155 continue;
1156 }
1157
1158 ret = cmh_query_ind_fnc(srcId, &flag_set, line)/*lint -e613*/;
1159
1160 if (ret NEQ AT_CMPL)
1161 {
1162 TRACE_EVENT_P1("query_indicator_flags error: %d", ret);
1163 return(map_aci_2_ati_rslt(ret));
1164 }
1165
1166 if (flag_set EQ CPHS_FLAG_ACTIVATED)
1167 {
1168 set_line_bitmask |= line;
1169 }
1170 }
1171
1172 if (set_line_bitmask NEQ CPHS_LINE_NULL)
1173 {
1174 sprintf(g_sa, "%s: %d,%d", cmd_name, CPHS_FLAG_ACTIVATED, set_line_bitmask);
1175 }
1176 else
1177 {
1178 sprintf(g_sa, "%s: %d",cmd_name, CPHS_FLAG_DEACTIVATED);
1179 }
1180
1181 io_sendMessage((UBYTE)srcId, g_sa, ATI_NORMAL_OUTPUT);
1182
1183 return(ATI_CMPL);
1184 }
1185
1186
1187 /*
1188 +--------------------------------------------------------------------+
1189 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1190 | STATE : code ROUTINE : atPercentCPCFU |
1191 +--------------------------------------------------------------------+
1192
1193 PURPOSE : %CPVWI: set/clear/query CFU flags
1194 */
1195
1196 GLOBAL T_ATI_RSLT setatPercentCPCFU(CHAR *cl, UBYTE srcId)
1197 {
1198 T_CPHS_LINES i,
1199 typed_lines = NOT_PRESENT_16BIT,
1200 line;
1201 SHORT action;
1202 T_ACI_RETURN ret;
1203 T_ATI_SRC_PARAMS *src_params = find_element( ati_src_list, srcId, search_ati_src_id);
1204
1205 cl = parse(cl,"rr", &action, &typed_lines);
1206 if (cl EQ NULL)
1207 {
1208 cmdCmeError(CME_ERR_OpNotAllow);
1209 return(ATI_FAIL);
1210 }
1211
1212 if (typed_lines EQ NOT_PRESENT_16BIT)
1213 {
1214 TRACE_EVENT("typed_lines omitted");
1215
1216 typed_lines = 0;
1217
1218 /* lines parameter omitted: Provides CFU flags for all lines */
1219 for(i=0;i<8*sizeof(T_CPHS_LINES);i++)
1220 {
1221 line = CPHS_LINE1 << i;
1222
1223 if (cphs_line_makes_sense(line))
1224 {
1225 typed_lines |= line;
1226 }
1227 }
1228 }
1229
1230 TRACE_EVENT_P2("setatPercentCPCFU action: %d, lines: %d", action, typed_lines);
1231
1232 #ifdef FF_ATI_BAT
1233 {
1234 T_BAT_cmd_send cmd;
1235 T_BAT_cmd_set_percent_cpcfu my_bat_set_percent_cpcfu;
1236
1237 TRACE_FUNCTION("setatPercentCPCFU() calls bat_send() <=== as APPLICATION");
1238
1239 memset(&my_bat_set_percent_cpcfu, 0, sizeof(my_bat_set_percent_cpcfu));
1240 cmd.ctrl_params = BAT_CMD_SET_PERCENT_CPCFU;
1241 cmd.params.ptr_set_percent_cpcfu = &my_bat_set_percent_cpcfu;
1242
1243 my_bat_set_percent_cpcfu.mode = action;
1244 my_bat_set_percent_cpcfu.line = typed_lines;
1245 src_params->curAtCmd = AT_CMD_CPCFU;
1246 bat_send(ati_bat_get_client(srcId), &cmd);
1247
1248 return ATI_EXCT; /* executing, because response is passed by callback function */
1249 }
1250 #else /* OLD FUNCTION BODY */
1251
1252 /******* QUERY ********/
1253 if (action EQ CPHS_QUERY_CFU_FLAG)
1254 {
1255 ret = query_indicator_flags(srcId, typed_lines, AT_CMD_CPCFU);
1256 return ret;
1257 }
1258
1259 TRACE_FUNCTION("setatPercentCPCFU()");
1260
1261 /******* SETTING ********/
1262 ret = sAT_PercentCPCFU(srcId, (UBYTE)action, typed_lines);
1263
1264 switch (ret)
1265 {
1266 case (AT_EXCT):
1267 src_params->curAtCmd = AT_CMD_CPCFU;
1268 break;
1269
1270 case (AT_BUSY):
1271 cmdCmeError(CME_ERR_SimBusy);
1272 return(ATI_FAIL);
1273
1274 case (AT_FAIL):
1275 cmdCmeError(CME_ERR_Unknown);
1276 return(ATI_FAIL);
1277 }
1278
1279 return(map_aci_2_ati_rslt(ret));
1280
1281 #endif /* no FF_ATI_BAT*/
1282 }
1283
1284
1285 #endif /* CPHS_C */
1286 #endif /* FF_CPHS */
1287
1288