comparison g23m-aci/aci/cmh_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:: cmh_cphs.c $|
4 | $Author:: $Revision:: $|
5 | CREATED: $Modtime:: $|
6 | STATE : code |
7 +--------------------------------------------------------------------+
8
9 MODULE : CMH
10
11 PURPOSE : CPHS related ACI functions.
12 */
13
14
15 #ifndef CMH_CPHS_C
16 #define CMH_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 "psa.h"
26 #include "cmh.h"
27
28 #include "cphs.h"
29 #include "aci_cphs.h"
30
31 #include "ksd.h"
32 #include "cmh_ss.h"
33
34 #include "phb.h"
35 #include "cmh_phb.h"
36
37 typedef enum
38 {
39 CMN_FULL_PRSNT, /* all parameter present */
40 CMN_PRTLY_PRSNT, /* only some parameter present */
41 CMN_NOT_PRSNT /* no parameter present */
42 }
43 T_CPHS_MB_CMH_CMN_STAT;
44
45 typedef enum
46 {
47 SNGL_VLD_PRSNT, /* parameter is present and in valid range */
48 SNGL_INVLD_PRSNT, /* parameter is present and not in valid range */
49 SNGL_NOT_PRSNT /* parameter is not present */
50 }
51 T_CPHS_MB_CMH_SNGL_STAT;
52
53 typedef struct CPHSShrdParm
54 {
55 T_ACI_CMD_SRC srcId;
56
57 } T_CPHS_SHRD_PRM;
58
59 LOCAL T_CPHS_SHRD_PRM cphsShrdPrm;
60
61 /*
62 +--------------------------------------------------------------------+
63 | PROJECT : GSM-PS (6147) MODULE : CMH_CPHS |
64 | STATE : code ROUTINE : cmhCPHS_user_cb |
65 +--------------------------------------------------------------------+
66
67 PURPOSE : This is the callback used by the CPHS module to inform ACI
68 of the result of an asynchroneous operation.
69 */
70 GLOBAL void cmhCPHS_user_cb( T_CPHS_PARAMS *params )
71 {
72 T_ACI_CMD_SRC cphsId = cphsShrdPrm.srcId;
73 int i;
74 BOOL final_result = FALSE;
75
76 /* Deal with Final Results */
77 switch(params->cb_type)
78 {
79 case(CPHS_INIT_RES):
80 final_result = TRUE;
81 break;
82
83 case(CPHS_VOICE_MAIL_RES):
84 final_result = TRUE;
85 break;
86
87 case(CPHS_CFU_RES):
88 final_result = TRUE;
89 break;
90 }
91
92 if(final_result)
93 {
94 if(params->operation_result EQ CPHS_OK)
95 {
96 R_AT( RAT_OK, cphsId )
97 ( AT_CMD_CPHS );
98 }
99 else
100 {
101 R_AT( RAT_CME, cphsId )
102 ( AT_CMD_CPHS, CME_ERR_NotPresent );
103 }
104
105 /* reset cphsId */
106 cphsShrdPrm.srcId = CMD_SRC_NONE;
107 return;
108 }
109
110
111 /* Deal with Unsolicited Messages */
112 switch(params->cb_type)
113 {
114 case(CPHS_VOICE_MAIL_IND):
115 for (i=0; i < CMD_SRC_MAX; i++)
116 {
117 R_AT( RAT_CPVWI, (T_ACI_CMD_SRC)i ) (params->set_flag, params->line);
118 }
119 return;
120
121 case(CPHS_ROAM_IND):
122 for (i=0; i < CMD_SRC_MAX; i++)
123 {
124 R_AT( RAT_CPROAM, (T_ACI_CMD_SRC)i ) (params->set_flag);
125 }
126 return;
127 }
128 }
129
130 /*
131 +--------------------------------------------------------------------+
132 | PROJECT : GSM-F&D (8411) MODULE : CMH_CPHS |
133 | STATE : code ROUTINE : cmhCPHS_convertSimTag |
134 +--------------------------------------------------------------------+
135
136 PURPOSE : This function converts the actual tag string in the
137 format used when storing it on the SIM.
138 */
139 LOCAL void cmhCPHS_convertSimTag ( T_CPHS_PB_TEXT* inTag,
140 UBYTE* outTag,
141 UBYTE* outTagLen,
142 UBYTE maxOutLen )
143 {
144 UBYTE i = MINIMUM ( maxOutLen, inTag->len);
145 SHORT restLen = maxOutLen - inTag->len;
146 UBYTE j;
147
148 /*
149 *-----------------------------------------------------------------
150 * Convert from internal GSM to default GSM alphabet
151 *-----------------------------------------------------------------
152 */
153 for ( j = 0; j < i; j++ )
154 outTag[j] = inTag->data[j];
155
156 *outTagLen = i;
157
158 if ( restLen > 0 )
159 memset ( &outTag[i], NOT_PRESENT_8BIT, restLen);
160 }
161
162 /*
163 +----------------------------------------------------------------------+
164 | PROJECT : GSM-F&D (8411) MODULE : CMH_CPHS |
165 | STATE : code ROUTINE : cmhCPHS_add_mb_record|
166 +----------------------------------------------------------------------+
167
168 PURPOSE : %CPMBW: write mailbox numbers to ME cache and SIM
169 */
170
171 LOCAL T_ACI_RETURN cmhCPHS_add_mb_record( T_ACI_CMD_SRC srcId,
172 T_CPHS_MB_CMH_SNGL_STAT indexStat,
173 T_CPHS_PB_TEXT* text,
174 CHAR* number,
175 T_ACI_TOA* type,
176 SHORT index)
177 {
178
179 T_PHB_RECORD entry; /* reuse of phonebook type */
180
181
182 CHAR *pNumber = NULL; /* pointer to the number that will be saved */
183 T_CPHS_RET cphs_ret;
184
185 memset(&entry,0,sizeof(T_PHB_RECORD));
186
187 TRACE_FUNCTION ("cmhCPHS_add_mb_record()");
188
189 switch ( indexStat )
190 {
191 case ( SNGL_NOT_PRSNT ):
192 case ( SNGL_VLD_PRSNT ):
193 {
194 /* fill in the structure elements */
195
196 /* process the <index> */
197 #ifdef TI_PS_FFS_PHB
198 entry.phy_recno = ( indexStat EQ SNGL_NOT_PRSNT ?
199 0 : ( UBYTE ) index );
200 #else
201 entry.index = ( indexStat EQ SNGL_NOT_PRSNT ?
202 0 : ( UBYTE ) index );
203 #endif
204
205 /* process the <tag> */
206 if (text NEQ NULL)
207 {
208 if (text->len > PHB_MAX_TAG_LEN)
209 {
210 TRACE_FUNCTION_P2("ERROR: text length (%d) > max tag length (%d)",
211 text->len, PHB_MAX_TAG_LEN);
212 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_TxtToLong );
213 return (AT_FAIL);
214 }
215 cmhCPHS_convertSimTag( text, entry.tag, &(entry.tag_len),
216 (UBYTE)PHB_MAX_TAG_LEN );
217 }
218
219 /* calculate the TON/NPI field */
220 entry.ton_npi = PHB_TONPI_NO_DIAL;
221 pNumber = number;
222
223 if ( type EQ NULL )
224 {
225 cmhPHB_ksdDecodeToa(number, &pNumber, &entry);
226 }
227 else
228 {
229 cmhPHB_toaMrg ( type, &entry.ton_npi );
230 }
231
232 /* process the <number>, convert to BCD */
233 if ( pNumber NEQ NULL)
234 {
235 cmhPHB_getAdrBcd ( entry.number, &entry.len,
236 PHB_PACKED_NUM_LEN, pNumber );
237 }
238 /*********************/
239 /* update the record */
240 /*********************/
241
242 /* in SIM & Cache */
243 cphs_ret = cphs_write_mb_number(srcId,
244 #ifdef TI_PS_FFS_PHB
245 (UBYTE)entry.phy_recno,
246 #else
247 entry.index,
248 #endif
249 entry.tag,
250 entry.tag_len,
251 entry.len,
252 entry.number,
253 entry.ton_npi);
254
255 /* map return value */
256 switch (cphs_ret)
257 {
258 case CPHS_EXEC:
259 return (AT_EXCT);
260 case CPHS_OK:
261 return (AT_CMPL);
262 case CPHS_NOT_INIT:
263 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_OpNotAllow );
264 return (AT_FAIL);
265 case CPHS_BUSY:
266 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_SimBusy );
267 return (AT_FAIL);
268 case CPHS_FAIL:
269 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_TxtToLong );
270 return (AT_FAIL);
271 default:
272 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_Unknown );
273 return (AT_FAIL);
274 }
275 }
276
277 case ( SNGL_INVLD_PRSNT ):
278 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
279 return( AT_FAIL );
280 }
281 return(AT_FAIL);
282 }
283
284
285 /*
286 +--------------------------------------------------------------------+
287 | PROJECT : GSM-PS (6147) MODULE : CMH_CPHS |
288 | STATE : code ROUTINE : sAT_PercentCPHS |
289 +--------------------------------------------------------------------+
290
291 PURPOSE : This is the functional counterpart to the %CPHS AT command
292 which is responsible for initialise/close/refresh the CPHS module.
293 */
294
295 GLOBAL T_ACI_RETURN sAT_PercentCPHS( T_ACI_CMD_SRC srcId,
296 T_ACI_CPHS_INIT init_cphs )
297 {
298 T_CPHS_RET cphs_ret = CPHS_FAIL;
299
300 TRACE_FUNCTION ("sAT_PercentCPHS");
301
302 /* check command source */
303 if(!cmh_IsVldCmdSrc (srcId))
304 {
305 return( AT_FAIL );
306 }
307
308 /* check parameter <init_cphs> */
309 switch(init_cphs)
310 {
311 case(ACI_CPHS_CLOSE):
312 cphs_ret = cphs_stop( );
313 break;
314
315 case(ACI_CPHS_INIT):
316 cphs_ret = cphs_start( cmhCPHS_user_cb );
317 break;
318
319 case(ACI_CPHS_REFRESH):
320 cphs_ret = cphs_refresh_data( );
321 break;
322
323 default:
324 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
325 break;
326 }
327
328 switch(cphs_ret)
329 {
330 case(CPHS_OK):
331 return(AT_CMPL);
332
333 case(CPHS_EXEC):
334 cphsShrdPrm.srcId = srcId;
335 return(AT_EXCT);
336
337 case(CPHS_BUSY):
338 return(AT_BUSY);
339
340 default:
341 return(AT_FAIL);
342 }
343 }
344
345
346 GLOBAL T_ACI_RETURN qAT_PercentCPHS( T_ACI_CMD_SRC srcId,
347 T_ACI_CPHS_INIT *init_cphs )
348 {
349 T_CPHS_RET cphs_ret;
350
351 TRACE_FUNCTION ("qAT_PercentCPHS");
352
353 /* check command source */
354 if(!cmh_IsVldCmdSrc (srcId))
355 {
356 return( AT_FAIL );
357 }
358
359 cphs_ret = cphs_check_status( );
360
361 switch(cphs_ret)
362 {
363 case(CPHS_OK):
364 *init_cphs = ACI_CPHS_INIT;
365 break;
366
367 case(CPHS_BUSY):
368 *init_cphs = ACI_CPHS_BUSY;
369 break;
370
371 case(CPHS_NOT_INIT):
372 *init_cphs = ACI_CPHS_CLOSE;
373 break;
374 }
375
376 return( AT_CMPL );
377 }
378
379 /*
380 +--------------------------------------------------------------------+
381 | PROJECT : GSM-PS (6147) MODULE : CMH_CPHS |
382 | STATE : code ROUTINE : sAT_PercentCPNUMS |
383 +--------------------------------------------------------------------+
384
385 PURPOSE : This is the functional counterpart to the %CPNUMS AT command
386 which is responsible for managing the CPHS information numbers feature.
387 */
388
389 LOCAL T_ACI_RETURN cmhCPHS_get_info_number_element( T_ACI_CMD_SRC srcId,
390 UBYTE element_id )
391 {
392 T_CPHS_RET cphs_ret;
393 T_CPHS_INF_NUM info_number; /* dynamic ??? */
394
395 TRACE_FUNCTION ("cmhCPHS_get_info_number_element( )");
396
397 cphs_ret = cphs_read_info_nb (element_id, &info_number);
398
399 if(cphs_ret NEQ CPHS_OK)
400 {
401 TRACE_ERROR("cmhCPHS_get_info_number_element: unexpected error");
402 return(AT_FAIL);
403 }
404
405 R_AT( RAT_CPNUMS, srcId )
406 (element_id,
407 info_number.index_level,
408 info_number.alpha_tag,
409 info_number.number,
410 info_number.premium_flag,
411 info_number.network_flag,
412 info_number.type_of_address);
413
414 return(AT_CMPL);
415 }
416
417 LOCAL T_ACI_RETURN cmhCPHS_get_folder_elements( T_ACI_CMD_SRC srcId,
418 UBYTE element_id )
419 {
420 T_CPHS_RET cphs_ret;
421 UBYTE *info_nums_list;
422 UBYTE list_size;
423 UBYTE i;
424 T_ACI_RETURN ret;
425
426 TRACE_FUNCTION ("cmhCPHS_get_folder_elements( )");
427
428 list_size = 10; /* first try with 10 entries */
429 MALLOC(info_nums_list, list_size);
430 cphs_ret = cphs_explore_info_nbs(element_id, info_nums_list, &list_size);
431
432 TRACE_EVENT_P3("cphs_ret: %d, info_nums_list: %s, list_size: %d", cphs_ret, info_nums_list, list_size);
433
434 switch(cphs_ret)
435 {
436 case(CPHS_OK):
437 if((*info_nums_list EQ 0) AND (list_size NEQ 0))
438 {
439 TRACE_EVENT_P1("Folder element %d is empty", element_id);
440 return(AT_FAIL);
441 }
442 break;
443
444 case(CPHS_EXEC):
445 /* list was too small: size needed has been written in list_size */
446 TRACE_EVENT_P1("List was too small: needed: %d bytes", list_size);
447 MFREE(info_nums_list);
448
449 MALLOC(info_nums_list, list_size);
450 cphs_ret = cphs_explore_info_nbs(element_id, info_nums_list, &list_size);
451
452 if(cphs_ret NEQ CPHS_OK)
453 {
454 TRACE_ERROR("cmhCPHS_get_folder_elements: unexpected error");
455 MFREE(info_nums_list);
456 return(AT_FAIL);
457 }
458 break;
459
460 default:
461 MFREE(info_nums_list);
462 return(AT_FAIL);
463 }
464
465 /* Get all elements of folder and send to user */
466 for(i=0;i<list_size;i++)
467 {
468 ret = cmhCPHS_get_info_number_element(srcId, info_nums_list[i]);
469
470 if(ret NEQ AT_CMPL)
471 {
472 TRACE_EVENT_P1("Wrong Information Number: index ignored: %d...", info_nums_list[i]);
473 }
474 }
475 MFREE(info_nums_list);
476 return(AT_CMPL);
477 }
478
479 GLOBAL T_ACI_RETURN sAT_PercentCPNUMS( T_ACI_CMD_SRC srcId,
480 UBYTE element_id,
481 UBYTE mode )
482 {
483 T_ACI_RETURN ret;
484
485 TRACE_FUNCTION ("sAT_PercentCPNUMS");
486
487 TRACE_EVENT_P1("elemt: %d", element_id);
488
489 /* check command source */
490 if(!cmh_IsVldCmdSrc (srcId))
491 {
492 return( AT_FAIL );
493 }
494
495 /* check parameter <mode> */
496 switch(mode)
497 {
498 case(CPNUMS_MODE_EXPLORE):
499 TRACE_EVENT_P1("CPNUMS mode exploring: folder: %d", element_id);
500 return(cmhCPHS_get_folder_elements(srcId, element_id));
501
502 case(CPNUMS_MODE_QUERY):
503 TRACE_EVENT_P1("CPNUMS mode querying: element: %d", element_id);
504
505 ret = cmhCPHS_get_info_number_element(srcId, element_id);
506
507 if(ret NEQ AT_CMPL)
508 {
509 TRACE_ERROR("sAT_PercentCPNUMS: unexpected error");
510 return(AT_FAIL);
511 }
512 return(AT_CMPL);
513
514 default:
515 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
516 return(AT_FAIL);
517 }
518 }
519
520 /* returns whole table */
521 GLOBAL T_ACI_RETURN tAT_PercentCPNUMS( T_ACI_CMD_SRC srcId )
522 {
523 T_CPHS_RET cphs_ret;
524 T_ACI_RETURN ret;
525 UBYTE i;
526 UBYTE max_index;
527
528 TRACE_FUNCTION ("tAT_PercentCPNUMS");
529
530 /* check command source */
531 if(!cmh_IsVldCmdSrc (srcId))
532 {
533 return( AT_FAIL );
534 }
535
536 cphs_ret = cphs_info_num_get_max(&max_index);
537
538 if(cphs_ret NEQ CPHS_OK)
539 {
540 return(AT_FAIL);
541 }
542
543 for(i=1; i<(max_index+1); i++)
544 {
545 ret = cmhCPHS_get_info_number_element(srcId, i);
546
547 if(ret NEQ AT_CMPL)
548 {
549 return(AT_FAIL);
550 }
551 }
552 return( AT_CMPL );
553 }
554
555 /*
556 +--------------------------------------------------------------------+
557 | PROJECT : GSM-PS (6147) MODULE : CMH_CPHS |
558 | STATE : code ROUTINE : qAT_PercentCPALS |
559 +--------------------------------------------------------------------+
560
561 PURPOSE : This is the functional counterpart to the %CPALS AT command
562 which is responsible for managing the CPHS alternate line service feature.
563 */
564
565 GLOBAL T_ACI_RETURN qAT_PercentCPALS( T_ACI_CMD_SRC srcId,
566 UBYTE call_id,
567 T_CPHS_LINES *line,
568 CHAR *line_desc,
569 UBYTE *max_line_desc)
570 {
571 T_CPHS_RET ret_val;
572 TRACE_FUNCTION ("qAT_PercentCPALS");
573
574 /* check command source */
575 if(!cmh_IsVldCmdSrc (srcId))
576 {
577 return( AT_FAIL );
578 }
579
580 ret_val=cphs_get_line((UBYTE)srcId, call_id, line, line_desc, max_line_desc);
581 switch(ret_val)
582 {
583 case(CPHS_OK): return(AT_CMPL);
584 case(CPHS_EXEC): return(AT_EXCT);
585 case(CPHS_BUSY):
586 case(CPHS_NOT_INIT): return(AT_BUSY);
587 case(CPHS_FAIL):
588 default: return(AT_FAIL);
589 }
590
591 }
592
593 /*
594 +--------------------------------------------------------------------+
595 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
596 | STATE : code ROUTINE : AT_PercentCPVWI |
597 +--------------------------------------------------------------------+
598
599 PURPOSE : %CPVWI: set/clear/query voice message waiting flags
600 */
601
602 GLOBAL T_ACI_RETURN sAT_PercentCPVWI( T_ACI_CMD_SRC srcId,
603 UBYTE flag_set,
604 USHORT lines)
605 {
606 T_CPHS_RET cphs_ret = CPHS_OK;
607
608 TRACE_FUNCTION ("sAT_PercentCPVWI()");
609
610 /* check command source */
611 if(!cmh_IsVldCmdSrc (srcId))
612 {
613 return( AT_FAIL );
614 }
615
616 /* check parameter <flag_set> */
617 switch(flag_set)
618 {
619 case(CPHS_SET_WAITING_FLAG):
620 case(CPHS_ERASE_WAITING_FLAG):
621 cphs_ret = cphs_set_waiting_flag(flag_set, lines);
622 break;
623
624 default:
625 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
626 return(AT_FAIL);
627 }
628
629 switch(cphs_ret)
630 {
631 case(CPHS_EXEC):
632 cphsShrdPrm.srcId = srcId;
633 return(AT_EXCT);
634
635 case(CPHS_BUSY):
636 return(AT_BUSY);
637
638 default:
639 return(AT_FAIL);
640 }
641 }
642
643
644 GLOBAL T_ACI_RETURN qAT_PercentCPVWI( T_ACI_CMD_SRC srcId,
645 UBYTE *flag_set,
646 USHORT line)
647 {
648 T_CPHS_RET cphs_ret;
649
650 TRACE_FUNCTION ("qAT_PercentCPVWI()");
651
652 /* check command source */
653 if(!cmh_IsVldCmdSrc (srcId))
654 {
655 return( AT_FAIL );
656 }
657
658 cphs_ret = cphs_get_waiting_flag(flag_set, line);
659
660 switch(cphs_ret)
661 {
662 case(CPHS_OK):
663 return(AT_CMPL);
664
665 case(CPHS_BUSY):
666 *flag_set = CPHS_FLAG_ERROR;
667 return(AT_BUSY);
668
669 default:
670 *flag_set = CPHS_FLAG_ERROR;
671 return(AT_FAIL);
672 }
673
674 }
675
676
677 /*
678 +--------------------------------------------------------------------+
679 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
680 | STATE : code ROUTINE : AT_PercentCPOPN |
681 +--------------------------------------------------------------------+
682
683 PURPOSE : %CPOPN: query operator name long and short string
684 */
685
686 GLOBAL T_ACI_RETURN qAT_PercentCPOPN( T_ACI_CMD_SRC srcId,
687 CHAR *longname,
688 UBYTE *max_longname,
689 CHAR *shortname,
690 UBYTE *max_shortname)
691 {
692 T_CPHS_RET cphs_ret;
693
694 TRACE_FUNCTION ("qAT_PercentCPOPN()");
695
696 /* check command source */
697 if(!cmh_IsVldCmdSrc (srcId))
698 {
699 return( AT_FAIL );
700 }
701
702 cphs_ret = cphs_get_opn( longname, max_longname, shortname, max_shortname);
703
704 switch(cphs_ret)
705 {
706 case(CPHS_OK):
707 return(AT_CMPL);
708
709 default:
710 return(AT_FAIL);
711 }
712 }
713
714 /*
715 +--------------------------------------------------------------------+
716 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
717 | STATE : code ROUTINE : AT_PercentCPINF |
718 +--------------------------------------------------------------------+
719
720 PURPOSE : %CPINF: write CSP ( Customer Service Profile )
721 */
722
723 GLOBAL T_ACI_RETURN sAT_PercentCPINF( T_ACI_CMD_SRC srcId,
724 UBYTE *csp,
725 UBYTE csp_len)
726 {
727 UBYTE phase;
728 USHORT sst;
729 T_CPHS_RET cphs_ret;
730
731 TRACE_FUNCTION ("sAT_PercentCPINF()");
732
733 /* check command source */
734 if(!cmh_IsVldCmdSrc (srcId))
735 {
736 return( AT_FAIL );
737 }
738
739 cphs_ret = cphs_get_cphs_info(&phase, &sst);
740
741 if ( cphs_ret EQ CPHS_OK)
742 {
743 if ( CPHS_CHECK_SST(sst, CPHS_SERVICE_CSP, CPHS_SERVICE_ACTIVATED) )
744 {
745 cphs_ret = cphs_set_csp_value(srcId, csp, csp_len);
746 }
747 else
748 {
749 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_OpNotAllow );
750 return (AT_FAIL);
751 }
752 }
753
754 switch (cphs_ret)
755 {
756 case CPHS_EXEC:
757 return (AT_EXCT);
758 case CPHS_OK:
759 return (AT_CMPL);
760 case CPHS_BUSY:
761 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_SimBusy );
762 return (AT_FAIL);
763 default:
764 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_OpNotAllow );
765 return (AT_FAIL);
766 }
767 }
768
769 /*
770 +--------------------------------------------------------------------+
771 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
772 | STATE : code ROUTINE : AT_PercentCPINF |
773 +--------------------------------------------------------------------+
774
775 PURPOSE : %CPINF: query cphs information and customer service profile
776 */
777
778 GLOBAL T_ACI_RETURN qAT_PercentCPINF( T_ACI_CMD_SRC srcId,
779 UBYTE *phase,
780 USHORT *sst,
781 CHAR *csp,
782 CHAR *csp2,
783 UBYTE *max_csp_size,
784 UBYTE *max_csp2_size)
785 {
786 T_CPHS_RET cphs_ret;
787
788 TRACE_FUNCTION ("qAT_PercentCPINF()");
789
790 /* check command source */
791 if(!cmh_IsVldCmdSrc (srcId))
792 {
793 return( AT_FAIL );
794 }
795
796 cphs_ret = cphs_get_cphs_info(phase, sst);
797
798 if ( cphs_ret EQ CPHS_OK)
799 {
800 if ( CPHS_CHECK_SST(*sst, CPHS_SERVICE_CSP, CPHS_SERVICE_ACTIVATED) )
801 {
802 cphs_ret = cphs_get_csprof( csp, csp2, max_csp_size, max_csp2_size);
803 }
804 else
805 {
806 TRACE_EVENT("CSP is not activated in the SST");
807 *max_csp_size = 0;
808 *max_csp2_size = 0;
809 }
810 }
811 else
812 {
813 *max_csp_size = 0;
814 *max_csp2_size = 0;
815 }
816
817 switch(cphs_ret)
818 {
819 case(CPHS_OK):
820 return(AT_CMPL);
821
822 default:
823 return(AT_FAIL);
824 }
825 }
826
827 /*
828 +--------------------------------------------------------------------+
829 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
830 | STATE : code ROUTINE : sAT_PercentCPCFU |
831 +--------------------------------------------------------------------+
832
833 PURPOSE : %CPFCU: set call forwarding flags
834 */
835
836 GLOBAL T_ACI_RETURN sAT_PercentCPCFU( T_ACI_CMD_SRC srcId,
837 UBYTE cfu_set,
838 T_CPHS_LINES lines )
839 {
840 T_CPHS_RET cphs_ret;
841
842 TRACE_FUNCTION ("sAT_PercentCPCFU()");
843
844 /* check command source */
845 if(!cmh_IsVldCmdSrc (srcId))
846 {
847 return( AT_FAIL );
848 }
849
850 /* check parameter <cfu_set> */
851 switch(cfu_set)
852 {
853 case(CPHS_SET_CFU_FLAG):
854 case(CPHS_ERASE_CFU_FLAG):
855 cphs_ret = cphs_set_cfu_flag(cfu_set, lines);
856 break;
857
858 default:
859 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
860 return(AT_FAIL);
861 }
862
863 switch(cphs_ret)
864 {
865 case(CPHS_EXEC):
866 cphsShrdPrm.srcId = srcId;
867 return(AT_EXCT);
868
869 case(CPHS_BUSY):
870 return(AT_BUSY);
871
872 default:
873 return(AT_FAIL);
874 }
875 }
876
877 /*
878 +--------------------------------------------------------------------+
879 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
880 | STATE : code ROUTINE : AT_PercentCPCFU |
881 +--------------------------------------------------------------------+
882
883 PURPOSE : %CPCFU: query call forwarding flags
884 */
885
886 GLOBAL T_ACI_RETURN qAT_PercentCPCFU(T_ACI_CMD_SRC srcId, UBYTE *cfu_set, T_CPHS_LINES line)
887 {
888 T_CPHS_RET cphs_ret;
889
890 TRACE_FUNCTION ("qAT_PercentCPCFU()");
891
892 /* check command source */
893 if(!cmh_IsVldCmdSrc (srcId))
894 {
895 return( AT_FAIL );
896 }
897
898 cphs_ret = cphs_get_fwd_flag(cfu_set, line);
899
900 switch(cphs_ret)
901 {
902 case(CPHS_OK):
903 return(AT_CMPL);
904
905 case(CPHS_BUSY):
906 *cfu_set = CPHS_FLAG_ERROR;
907 return(AT_BUSY);
908
909 case(CPHS_NOT_INIT):
910 *cfu_set = CPHS_FLAG_ERROR;
911 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_OpNotAllow );
912 return(AT_FAIL);
913 default:
914 *cfu_set = CPHS_FLAG_ERROR;
915 return(AT_FAIL);
916 }
917 }
918
919 /*
920 +--------------------------------------------------------------------+
921 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
922 | STATE : code ROUTINE : AT_PercentCPMB |
923 +--------------------------------------------------------------------+
924
925 PURPOSE : %CPMB: query mailbox numbers
926
927 This function deals with both the set and query aspects of the
928 %CPMB command. If 'rec_id' is present, indicating a set operation,
929 it will return information about the specified mailbox number
930 (parameters 'line', 'number', 'ton', 'npi' and 'alpha_id'). If\
931 'rec_id' is set to ACI_NumParmNotPresent, indicating a query
932 operation, it will return the index of the first unused entry in
933 the list (parameter 'first').
934 */
935
936 GLOBAL T_ACI_RETURN qAT_PercentCPMB( T_ACI_CMD_SRC srcId,
937 UBYTE rec_id,
938 T_CPHS_LINES *line,
939 CHAR *number,
940 T_ACI_TOA_TON *ton,
941 T_ACI_TOA_NPI *npi,
942 CHAR *alpha_id,
943 UBYTE *first)
944 {
945 T_CPHS_MB mb_number;
946 T_CPHS_RET cphs_ret;
947
948 TRACE_FUNCTION ("qAT_PercentCPMB()");
949
950 /* check command source */
951 if(!cmh_IsVldCmdSrc (srcId))
952 {
953 return( AT_FAIL );
954 }
955
956 /*
957 * Determine the first free location, and write it to the
958 * memory pointed to by 'first', having first checked that
959 * it is not set to NULL.
960 */
961 if (first NEQ NULL)
962 {
963 if (cphs_first_free(first) NEQ CPHS_OK)
964 {
965 /*
966 * It is assumed that cphs_first_free() will have filled in
967 * the error number (ACI_ERR_DESC).
968 */
969 return(AT_FAIL);
970 }
971 }
972
973 /*
974 * No further processing needed for the 'query' command, so
975 * unless we are dealing with the 'set' command, get
976 * out now.
977 */
978 if (rec_id EQ (UBYTE)ACI_NumParmNotPresent)
979 return(AT_CMPL);
980
981 cphs_ret = cphs_read_mb_number(rec_id, &mb_number);
982
983 switch(cphs_ret)
984 {
985 case(CPHS_OK):
986 memcpy(number, mb_number.number, sizeof(mb_number.number));
987 memcpy(alpha_id, mb_number.alpha_id, sizeof(mb_number.alpha_id));
988 *line = mb_number.line;
989 if ( mb_number.toa EQ NOT_PRESENT_8BIT)
990 {
991 *ton = TON_NotPresent;
992 *npi = NPI_NotPresent;
993 }
994 else
995 {
996 *ton = (T_ACI_TOA_TON)(( mb_number.toa & 0x70 ) >> 4);
997 *npi = (T_ACI_TOA_NPI)(mb_number.toa & 0x0F);
998 }
999 return(AT_CMPL);
1000
1001 default:
1002 /* All errors are filled in cphs_read_mb_number(), thus do not fill any CmeError,
1003 just returning AT_FAIL */
1004 return(AT_FAIL);
1005 }
1006 }
1007
1008 /*
1009 +--------------------------------------------------------------------+
1010 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1011 | STATE : code ROUTINE : AT_PercentCPMBW |
1012 +--------------------------------------------------------------------+
1013
1014 PURPOSE : %CPMBW: write mailbox numbers
1015 */
1016
1017 GLOBAL T_ACI_RETURN sAT_PercentCPMBW( T_ACI_CMD_SRC srcId,
1018 SHORT index,
1019 CHAR* number,
1020 T_ACI_TOA* type,
1021 T_CPHS_PB_TEXT* text)
1022 {
1023
1024 T_CPHS_MB_CMH_SNGL_STAT indexStat; /* status of parameter <index> */
1025 T_CPHS_MB_CMH_CMN_STAT entryStat; /* status of parameter <number>, */
1026 /* <type> and <text> */
1027 T_ACI_RETURN aci_result;
1028 T_CPHS_RET cphs_result;
1029
1030 TRACE_FUNCTION ("sAT_PercentCPMBW()");
1031
1032 #ifndef NO_ASCIIZ
1033 /* convert Text */
1034 if ( text NEQ NULL )
1035 {
1036 UBYTE tmpBuf[CPHS_MAX_MB_ALPHA_LEN];
1037 USHORT len;
1038 text->cs = CS_Sim;
1039 cmh_cvtToDefGsm ( (CHAR*)text->data, (CHAR*)tmpBuf, &len );
1040 text->len = (UBYTE)len;
1041 memcpy ( text->data, tmpBuf, text->len );
1042 }
1043 #endif /* #ifndef NO_ASCIIZ */
1044
1045 /* check command source */
1046 if(!cmh_IsVldCmdSrc (srcId))
1047 {
1048 return( AT_FAIL );
1049 }
1050
1051 /* process the status of parameter <index> */
1052 if ( index EQ ACI_NumParmNotPresent )
1053 {
1054 indexStat = SNGL_NOT_PRSNT; /* NOT PRESENT */
1055 }
1056 else if( index > CPHS_MAX_MB_ENTRIES OR
1057 index < CPHS_MIN_MB_ENTRIES )
1058 {
1059 indexStat = SNGL_INVLD_PRSNT; /* INVALID */
1060 }
1061 else
1062 {
1063 indexStat = SNGL_VLD_PRSNT; /* VALID */
1064 }
1065
1066 /* process the status of parameter <number>, <type> and <text> */
1067 if ( number EQ NULL AND
1068 type EQ NULL AND
1069 text EQ NULL )
1070 {
1071 entryStat = CMN_NOT_PRSNT;
1072 }
1073 else if ( number NEQ NULL AND
1074 text NEQ NULL )
1075 {
1076 entryStat = CMN_FULL_PRSNT;
1077 }
1078 else
1079 {
1080 entryStat = CMN_PRTLY_PRSNT;
1081 }
1082
1083 /*
1084 *-----------------------------------------------------------------
1085 * process the parameter:
1086 *
1087 * A -> number, type, text
1088 * B -> index
1089 *
1090 * 0 -> all elements not present
1091 * 1 -> all elements present
1092 *
1093 * A | B | result
1094 * --+---+---------------------------
1095 * 0 | 0 | fail
1096 * 0 | 1 | delete entry
1097 * 1 | 0 | write to first empty entry
1098 * 1 | 1 | write to specific entry
1099 *-----------------------------------------------------------------
1100 */
1101
1102 switch ( entryStat )
1103 {
1104 case ( CMN_FULL_PRSNT):
1105 case ( CMN_PRTLY_PRSNT ):
1106 /* parameters are full or partly present --> add entry to phonebook */
1107
1108 aci_result = cmhCPHS_add_mb_record(srcId, indexStat, text, number, type, index);
1109
1110 return(aci_result);
1111
1112 /* process variable <entryStat> with value <CMN_NOT_PRSNT> */
1113 case ( CMN_NOT_PRSNT ):
1114
1115 if ( indexStat NEQ SNGL_VLD_PRSNT )
1116 {
1117 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
1118 return( AT_FAIL );
1119 }
1120
1121 if (indexStat EQ SNGL_VLD_PRSNT)
1122 {
1123 /* delete this very entry */
1124 cphs_result = cphs_write_mb_number(srcId,
1125 (UBYTE)index,
1126 NULL, /* tag */
1127 0,
1128 0,
1129 NULL, /* number */
1130 0);
1131 }
1132 else
1133 {
1134 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_InvIdx );
1135 return (AT_FAIL);
1136 }
1137
1138 switch (cphs_result)
1139 {
1140 case CPHS_EXEC:
1141 return (AT_EXCT);
1142 case CPHS_OK:
1143 return (AT_CMPL);
1144 case CPHS_NOT_INIT:
1145 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_OpNotAllow );
1146 return (AT_FAIL);
1147 case CPHS_FAIL:
1148 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_InvIdx );
1149 return (AT_FAIL);
1150 default:
1151 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_TxtToLong );
1152 return (AT_FAIL);
1153 }
1154 }
1155
1156 return ( AT_CMPL );
1157
1158 }
1159
1160 /*
1161 +--------------------------------------------------------------------+
1162 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
1163 | STATE : code ROUTINE : AT_PercentCPMBW |
1164 +--------------------------------------------------------------------+
1165
1166 PURPOSE : %CPMBW: test command
1167 */
1168
1169 GLOBAL T_ACI_RETURN tAT_PercentCPMBW ( T_ACI_CMD_SRC srcId,
1170 SHORT* firstIdx,
1171 SHORT* lastIdx,
1172 UBYTE* nlength,
1173 UBYTE* tlength )
1174 {
1175 T_CPHS_RET cphs_result;
1176
1177 TRACE_FUNCTION("tAT_PercentCPMBW()");
1178
1179 /* check command source */
1180 if(!cmh_IsVldCmdSrc (srcId))
1181 {
1182 return( AT_FAIL );
1183 }
1184
1185 cphs_result = cphs_get_mb_parameter ( firstIdx, lastIdx, nlength, tlength );
1186 switch (cphs_result)
1187 {
1188 case CPHS_OK:
1189 return (AT_CMPL);
1190 case CPHS_NOT_INIT:
1191 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_OpNotAllow );
1192 return (AT_FAIL);
1193 default:
1194 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_Unknown );
1195 return (AT_FAIL);
1196 }
1197 }
1198 #endif /* CPHS_C */