comparison g23m-aci/aci/ati_cphs.c @ 0:75a11d740a02

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