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