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

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