FreeCalypso > hg > tcs211-c139
comparison g23m/condat/ms/src/aci/cmh_phbs.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 : GSM-PS (6147) | |
4 | Modul : CMH_PHBS | |
5 +----------------------------------------------------------------------------- | |
6 | Copyright 2002 Texas Instruments Berlin, AG | |
7 | All rights reserved. | |
8 | | |
9 | This file is confidential and a trade secret of Texas | |
10 | Instruments Berlin, AG | |
11 | The receipt of or possession of this file does not convey | |
12 | any rights to reproduce or disclose its contents or to | |
13 | manufacture, use, or sell anything it may describe, in | |
14 | whole, or in part, without the specific written consent of | |
15 | Texas Instruments Berlin, AG. | |
16 +----------------------------------------------------------------------------- | |
17 | Purpose : This module provides the set functions related to the | |
18 | protocol stack adapter for the phonebook management. | |
19 +----------------------------------------------------------------------------- | |
20 */ | |
21 | |
22 #ifndef CMH_PHBS_C | |
23 #define CMH_PHBS_C | |
24 #endif | |
25 | |
26 #include "aci_all.h" | |
27 /*==== INCLUDES ===================================================*/ | |
28 #include "aci_cmh.h" | |
29 #include "ksd.h" | |
30 | |
31 #ifdef FAX_AND_DATA | |
32 #include "aci_fd.h" | |
33 #endif /* of #ifdef FAX_AND_DATA */ | |
34 | |
35 #include "psa.h" | |
36 #include "psa_sim.h" | |
37 #include "psa_sms.h" | |
38 #include "ati_cmd.h" | |
39 #include "aci_cmd.h" | |
40 #include "phb.h" | |
41 #include "cmh.h" | |
42 #include "cmh_phb.h" | |
43 #include "cmh_sms.h" | |
44 #include "pcm.h" | |
45 | |
46 /*--------------------------------------------------------------------* | |
47 * The Below include files are included for the SIM functions called * | |
48 * in CPBS command handler * | |
49 *--------------------------------------------------------------------*/ | |
50 | |
51 #include "dti_conn_mng.h" | |
52 #include "cmh_sim.h" | |
53 | |
54 | |
55 /*==== CONSTANTS ==================================================*/ | |
56 | |
57 #define PHB_CMH_CC_ID_NOT_USED 0xFF | |
58 #define PHB_CMH_EXT_NOT_USED 0xFF | |
59 | |
60 /*==== TYPES ======================================================*/ | |
61 | |
62 typedef enum | |
63 { | |
64 CMN_FULL_PRSNT, /* all parameter present */ | |
65 CMN_PRTLY_PRSNT, /* only some parameter present */ | |
66 CMN_NOT_PRSNT /* no parameter present */ | |
67 } | |
68 T_PHB_CMH_CMN_STAT; | |
69 | |
70 typedef enum | |
71 { | |
72 SNGL_VLD_PRSNT, /* parameter is present and in valid range */ | |
73 SNGL_INVLD_PRSNT, /* parameter is present and not in valid range */ | |
74 SNGL_NOT_PRSNT /* parameter is not present */ | |
75 } | |
76 T_PHB_CMH_SNGL_STAT; | |
77 | |
78 #ifdef TI_PS_FFS_PHB | |
79 typedef T_PHB_RETURN T_FCT_READ ( T_PHB_TYPE type, | |
80 SHORT index, | |
81 T_PHB_RECORD* entry ); | |
82 #else | |
83 typedef T_PHB_RETURN T_FCT_READ ( UBYTE type, | |
84 SHORT index, | |
85 T_PHB_RECORD* entry ); | |
86 #endif | |
87 | |
88 /*==== EXPORT =====================================================*/ | |
89 | |
90 /*==== VARIABLES ==================================================*/ | |
91 | |
92 /*==== FUNCTIONS ==================================================*/ | |
93 /* | |
94 +-------------------------------------------------------------------+ | |
95 | PROJECT : GSM-PS (6147) MODULE : CMH_PHBS | | |
96 | STATE : code ROUTINE : sAT_PlusCPBS | | |
97 +-------------------------------------------------------------------+ | |
98 | |
99 PURPOSE : This is the functional counterpart of the +CPBS | |
100 AT command which is responsible for setting the | |
101 phonebook memory storage. | |
102 | |
103 <mem>: phonebook memory storage | |
104 */ | |
105 GLOBAL T_ACI_RETURN sAT_PlusCPBS ( T_ACI_CMD_SRC srcId, | |
106 T_ACI_PB_STOR mem, | |
107 char* pin2) | |
108 { | |
109 T_PHB_CMD_PRM * pPHBCmdPrm; /* points to PHB command parameters */ | |
110 T_SIM_SET_PRM * pSIMSetPrm; /* To hold the SIM related values for CPBW | |
111 command */ | |
112 T_PHB_TYPE chkMem; /* checked and converted parameter <mem> */ | |
113 | |
114 TRACE_FUNCTION ("sAT_PlusCPBS ()"); | |
115 | |
116 /* | |
117 *----------------------------------------------------------------- | |
118 * check command source | |
119 *----------------------------------------------------------------- | |
120 */ | |
121 if(!cmh_IsVldCmdSrc (srcId)) | |
122 { | |
123 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter ); | |
124 return( AT_FAIL ); | |
125 } | |
126 | |
127 pPHBCmdPrm = &cmhPrm[srcId].phbCmdPrm; | |
128 | |
129 /* | |
130 *----------------------------------------------------------------- | |
131 * process the <mem> parameter | |
132 *----------------------------------------------------------------- | |
133 */ | |
134 if ( mem NEQ PB_STOR_NotPresent ) | |
135 { | |
136 if ( cmhPHB_cvtPhbType ( mem, &chkMem ) EQ TRUE ) | |
137 { | |
138 if (pin2 EQ NULL OR | |
139 (strlen ( pin2 ) EQ 0) ) | |
140 { | |
141 pPHBCmdPrm -> cmhStor = mem; | |
142 pPHBCmdPrm -> phbStor = chkMem; | |
143 } | |
144 else | |
145 { | |
146 if ( simShrdPrm.PINStat EQ PS_PUK2 ) | |
147 { | |
148 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_SimPuk2Req ); | |
149 return( AT_FAIL ); | |
150 } | |
151 /* check preselected phonebook storage for FDN or BDN */ | |
152 if ( ( mem EQ PB_STOR_Fd OR mem EQ PB_STOR_Bd ) | |
153 AND | |
154 ( simShrdPrm.pn2Stat EQ PS_PIN2 OR | |
155 simShrdPrm.pn2Stat EQ NO_VLD_PS ) ) | |
156 { | |
157 if ( simShrdPrm.PINStat EQ PS_RDY OR | |
158 simShrdPrm.PINStat EQ PS_PIN2 ) | |
159 { | |
160 simShrdPrm.PINStat = PS_PIN2; | |
161 } | |
162 else | |
163 { | |
164 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_SimFail ); | |
165 return( AT_FAIL ); | |
166 } | |
167 | |
168 /*-------------------------------------------------------------------------* | |
169 * The below code is added on 12/08/2003 as in R99 one more new paramter * | |
170 * is added in CPBS command <password>, this password is used to * | |
171 * verification of SIM PIN-2 before selecting any SIM related storages, * | |
172 * if it is already not done. * | |
173 * But now as password is provided by CPBS command. It is used for the * | |
174 * verification if it not done. * | |
175 *-------------------------------------------------------------------------*/ | |
176 | |
177 | |
178 pSIMSetPrm = &simShrdPrm.setPrm[srcId]; | |
179 | |
180 cmhSIM_FillInPIN ( (char *)pin2, pSIMSetPrm -> curPIN, | |
181 PIN_LEN); | |
182 pSIMSetPrm -> PINType = PHASE_2_PIN_2; | |
183 simEntStat.curCmd = AT_CMD_CPBS; | |
184 simEntStat.entOwn = simShrdPrm.owner = srcId; | |
185 | |
186 /*---------------------------------------------------------------------* | |
187 * During verification is the Owner ID is worng, then return the * | |
188 * AT_FAIL response. * | |
189 *---------------------------------------------------------------------*/ | |
190 if ( psaSIM_VerifyPIN() < 0 ) | |
191 { | |
192 TRACE_EVENT( "FATAL RETURN psaSIM in +CPBS: Not a valid owner ID" ); | |
193 return AT_FAIL; | |
194 } | |
195 | |
196 /*----------------------------------------------------------------* | |
197 * Hold the storage types in the temprory fields unless SIM PIN-2 * | |
198 * confirmation comes. * | |
199 *----------------------------------------------------------------*/ | |
200 | |
201 pPHBCmdPrm ->temp_cmhStor = mem; | |
202 pPHBCmdPrm ->temp_phbStor = chkMem; | |
203 | |
204 return ( AT_EXCT ); | |
205 } | |
206 else | |
207 { | |
208 pPHBCmdPrm -> cmhStor = mem; | |
209 pPHBCmdPrm -> phbStor = chkMem; | |
210 } | |
211 } | |
212 } | |
213 else | |
214 { | |
215 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter ); | |
216 return( AT_FAIL ); | |
217 } | |
218 } | |
219 | |
220 return ( AT_CMPL ); | |
221 } | |
222 | |
223 /* | |
224 +-------------------------------------------------------------------+ | |
225 | PROJECT : GSM-PS (6147) MODULE : CMH_PHBS | | |
226 | STATE : code ROUTINE : sAT_PlusCPBW | | |
227 +-------------------------------------------------------------------+ | |
228 | |
229 PURPOSE : This is the functional counterpart of the +CPBW | |
230 AT command which is responsible for writing a phonebook | |
231 entry to memory. | |
232 | |
233 <index>: location number of phonebook memory | |
234 <number>: phone number | |
235 <type>: type of phone number | |
236 <text>: text associated with phone number | |
237 */ | |
238 GLOBAL void cmhPHB_ksdDecodeToa(CHAR *number, CHAR **pNumber, T_PHB_RECORD *entry) | |
239 { | |
240 T_KSD_SEQGRP seqGrp = SEQGRP_UNKNOWN; | |
241 T_KSD_SEQPARAM seqPrm; | |
242 CHAR* restSeq; | |
243 T_ACI_TOA stdToa; | |
244 CHAR numBuf[MAX_PHB_NUM_LEN]; /* Phonebook number ASCII + '\0' */ | |
245 | |
246 TRACE_FUNCTION ("cmhksd_decode_toa()"); | |
247 | |
248 if ( strlen (number) EQ 0 ) | |
249 { | |
250 TRACE_EVENT("number has length 0"); | |
251 return; | |
252 } | |
253 | |
254 stdToa.ton = TON_Unknown; | |
255 stdToa.npi = NPI_IsdnTelephony; | |
256 | |
257 strncpy ( numBuf, number, MAX_PHB_NUM_LEN - 1 ); | |
258 numBuf[MAX_PHB_NUM_LEN - 1] = '\0'; | |
259 | |
260 | |
261 if ( ksd_decode ( numBuf, | |
262 TRUE, | |
263 &seqGrp, | |
264 &restSeq, | |
265 &seqPrm ) EQ FALSE ) | |
266 { | |
267 TRACE_EVENT("ksd_decode returned FALSE"); | |
268 return; | |
269 } | |
270 | |
271 switch (seqGrp) | |
272 { | |
273 case (SEQGRP_USSD): | |
274 if ( cmhPHB_rplcIntnl ( number, | |
275 numBuf, | |
276 0xFF ) EQ TRUE ) | |
277 { | |
278 stdToa.ton = TON_International; | |
279 } | |
280 | |
281 *pNumber = numBuf; | |
282 cmhPHB_toaMrg ( &stdToa, &entry->ton_npi ); | |
283 break; | |
284 | |
285 case (SEQGRP_DIAL): | |
286 if ( number[0] EQ '+' ) | |
287 { | |
288 *pNumber = &number[1]; | |
289 stdToa.ton = TON_International; | |
290 } | |
291 /* 00 is not an indication for an international number */ | |
292 cmhPHB_toaMrg ( &stdToa, &entry->ton_npi ); | |
293 break; | |
294 | |
295 case (SEQGRP_CF): | |
296 { | |
297 UBYTE cnt; | |
298 | |
299 if ( seqPrm.cf.num EQ NULL ) | |
300 { | |
301 break; | |
302 } | |
303 | |
304 if ( number [0] EQ '*' AND | |
305 number [1] EQ '*' ) | |
306 { | |
307 cnt = 3; | |
308 } | |
309 else if ( number[0] EQ '*' ) | |
310 { | |
311 cnt = 2; | |
312 } | |
313 else | |
314 { | |
315 cnt = 1; | |
316 } | |
317 | |
318 if ( cmhPHB_rplcIntnl ( number, | |
319 numBuf, | |
320 cnt ) EQ TRUE ) | |
321 { | |
322 stdToa.ton = TON_International; | |
323 } | |
324 | |
325 *pNumber = numBuf; | |
326 cmhPHB_toaMrg ( &stdToa, &entry->ton_npi ); | |
327 } | |
328 break; | |
329 | |
330 case (SEQGRP_SUP_CLIR): | |
331 case (SEQGRP_INV_CLIR): | |
332 if (strlen (restSeq) NEQ 0) | |
333 { | |
334 if ( restSeq[0] EQ '+' ) | |
335 { | |
336 strcpy ( &numBuf[4], &restSeq[1] ); | |
337 stdToa.ton = TON_International; | |
338 } | |
339 /* 00 is not an international number */ | |
340 else | |
341 { | |
342 strcpy ( &numBuf[4], &restSeq[0] ); | |
343 } | |
344 | |
345 *pNumber = numBuf; | |
346 cmhPHB_toaMrg ( &stdToa, &entry->ton_npi ); | |
347 } | |
348 break; | |
349 | |
350 default: | |
351 break; | |
352 } | |
353 } | |
354 | |
355 LOCAL T_ACI_RETURN cmhPHB_add_record(T_ACI_CMD_SRC srcId, | |
356 T_PHB_CMH_SNGL_STAT indexStat, | |
357 T_ACI_PB_TEXT *text, | |
358 CHAR *number, | |
359 T_ACI_TOA *type, | |
360 SHORT index, | |
361 T_ACI_VP_ABS *dateTime, | |
362 UBYTE phonebook_storage) | |
363 { | |
364 T_PHB_RECORD entry; | |
365 CHAR *pNumber = NULL; /* pointer to the number that will be saved */ | |
366 T_PHB_RETURN result; | |
367 | |
368 TRACE_FUNCTION ("cmhPHB_add_record()"); | |
369 | |
370 switch ( indexStat ) | |
371 { | |
372 case ( SNGL_NOT_PRSNT ): | |
373 case ( SNGL_VLD_PRSNT ): | |
374 { | |
375 /* fill in the structure elements */ | |
376 | |
377 /* process the <index> */ | |
378 #ifdef TI_PS_FFS_PHB | |
379 entry.phy_recno = ( indexStat EQ SNGL_NOT_PRSNT ? | |
380 0 : ( UBYTE ) index ); | |
381 #else | |
382 entry.index = ( indexStat EQ SNGL_NOT_PRSNT ? | |
383 0 : ( UBYTE ) index ); | |
384 #endif | |
385 | |
386 /* process the <tag> */ | |
387 if (text->len > PHB_MAX_TAG_LEN) | |
388 { | |
389 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_TxtToLong ); | |
390 return (AT_FAIL); | |
391 } | |
392 | |
393 cmhPHB_getMfwTagSim ( text, entry.tag, &entry.tag_len, | |
394 PHB_MAX_TAG_LEN ); | |
395 | |
396 /* calculate the TON/NPI field */ | |
397 entry.ton_npi = PHB_TONPI_NO_DIAL; | |
398 pNumber = number; | |
399 | |
400 if ( type EQ NULL ) | |
401 { | |
402 cmhPHB_ksdDecodeToa(number, &pNumber, &entry); | |
403 } | |
404 else | |
405 { | |
406 cmhPHB_toaMrg ( type, &entry.ton_npi ); | |
407 } | |
408 | |
409 /* process the <number> */ | |
410 cmhPHB_getAdrBcd ( entry.number, &entry.len, | |
411 PHB_PACKED_NUM_LEN, pNumber ); | |
412 | |
413 #if defined(TI_PS_FFS_PHB) OR defined(PHONEBOOK_EXTENSION) | |
414 /* Clear the subaddress (until fully supported here) */ | |
415 memset (entry.subaddr, 0xFF, sizeof (entry.subaddr)); | |
416 #endif | |
417 | |
418 /* process the <cc_id> */ | |
419 entry.cc_id = PHB_CMH_CC_ID_NOT_USED; | |
420 | |
421 /* process the <extension> */ | |
422 /* extension Mechansim not yet supported | |
423 entry.extension = PHB_CMH_EXT_NOT_USED; */ | |
424 | |
425 /* process the <date and time> */ | |
426 if ( dateTime EQ NULL OR | |
427 !cmhSMS_isVpabsVld ( dateTime ) ) | |
428 { | |
429 cmhPHB_invldPhbDateTime ( &entry ); | |
430 } | |
431 else | |
432 { | |
433 cmhPHB_cpyCmhDateTime ( dateTime, &entry ); | |
434 } | |
435 | |
436 /* add the record */ | |
437 result = pb_add_record (phonebook_storage, | |
438 #ifdef TI_PS_FFS_PHB | |
439 | |
440 entry.phy_recno, | |
441 #else | |
442 entry.index, | |
443 #endif | |
444 &entry); | |
445 switch (result) | |
446 { | |
447 case PHB_EXCT: | |
448 if (srcId EQ CMD_SRC_LCL) | |
449 { | |
450 TRACE_EVENT("Special handling with LCL source: return AT_CMPL"); | |
451 return (AT_CMPL); | |
452 } | |
453 return (AT_EXCT); | |
454 | |
455 case PHB_OK: | |
456 return (AT_CMPL); | |
457 | |
458 case PHB_FULL: | |
459 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_MemFull ); | |
460 return (AT_FAIL); | |
461 | |
462 case PHB_TAG_EXCEEDED: | |
463 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_TxtToLong ); | |
464 return (AT_FAIL); | |
465 | |
466 #ifdef TI_PS_FFS_PHB | |
467 case PHB_LOCKED: | |
468 return (AT_BUSY); | |
469 #endif | |
470 | |
471 case PHB_FAIL: | |
472 default: | |
473 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_Unknown ); | |
474 return (AT_FAIL); | |
475 } | |
476 } | |
477 | |
478 case ( SNGL_INVLD_PRSNT ): | |
479 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter ); | |
480 return( AT_FAIL ); | |
481 } | |
482 return(AT_FAIL); | |
483 } | |
484 | |
485 | |
486 GLOBAL T_ACI_RETURN sAT_PlusCPBW ( T_ACI_CMD_SRC srcId, | |
487 SHORT index, | |
488 CHAR* number, | |
489 T_ACI_TOA* type, | |
490 T_ACI_PB_TEXT* text, | |
491 T_ACI_VP_ABS* dateTime ) | |
492 { | |
493 T_PHB_CMD_PRM * pPHBCmdPrm; /* points to PHB command parameters */ | |
494 | |
495 T_PHB_CMH_SNGL_STAT indexStat; /* status of parameter <index> */ | |
496 T_PHB_CMH_CMN_STAT entryStat; /* status of parameter <number>, */ | |
497 /* <type> and <text> */ | |
498 T_PHB_RETURN result; | |
499 T_ACI_RETURN aci_return; | |
500 #ifndef TI_PS_FFS_PHB | |
501 UBYTE pb_status; | |
502 UBYTE ext_rcd_num = 0xFF; | |
503 #endif | |
504 | |
505 TRACE_FUNCTION ("sAT_PlusCPBW ()"); | |
506 | |
507 #ifndef NO_ASCIIZ | |
508 if ( text NEQ NULL ) | |
509 { | |
510 UBYTE tmpBuf[MAX_ALPHA_LEN]; | |
511 USHORT len; | |
512 | |
513 if (text->data[0] NEQ 0x80 AND text->data[0] NEQ 0x81 | |
514 AND text->data[0] NEQ 0x82) | |
515 { | |
516 text->cs = CS_Sim; | |
517 cmh_cvtToDefGsm ( (CHAR*)text->data, (CHAR*)tmpBuf, &len ); | |
518 text->len = (UBYTE)len; | |
519 memcpy ( text->data, tmpBuf, text->len ); | |
520 } | |
521 } | |
522 #endif /* #ifndef NO_ASCIIZ */ | |
523 | |
524 /* check command source */ | |
525 if(!cmh_IsVldCmdSrc (srcId)) | |
526 { | |
527 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter ); | |
528 return( AT_FAIL ); | |
529 } | |
530 | |
531 #ifndef TI_PS_FFS_PHB | |
532 /* If the phonebook status is not PHB_READY then SIM BUSY error is indicated to the user.*/ | |
533 pb_status_req(&pb_status); /* get phone book status */ | |
534 | |
535 TRACE_EVENT_P1("Current phonebook status: %d", pb_status); | |
536 | |
537 if(pb_status EQ PHB_BUSY) | |
538 { | |
539 return AT_BUSY; | |
540 } | |
541 else if(pb_status EQ PHB_UNKNOWN) | |
542 { | |
543 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_Unknown ); | |
544 return AT_FAIL; | |
545 } | |
546 #endif | |
547 | |
548 pPHBCmdPrm = &cmhPrm[srcId].phbCmdPrm; | |
549 | |
550 /* check preselected phonebook storage */ | |
551 if ( pPHBCmdPrm -> cmhStor EQ PB_STOR_NotPresent ) | |
552 { | |
553 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter ); | |
554 return( AT_FAIL ); | |
555 } | |
556 | |
557 /* check preselected phonebook storage for FDN or BDN */ | |
558 if ( ( simShrdPrm.pn2Stat EQ PS_PIN2 OR | |
559 simShrdPrm.pn2Stat EQ NO_VLD_PS ) | |
560 AND | |
561 ( pPHBCmdPrm -> cmhStor EQ PB_STOR_Fd OR | |
562 pPHBCmdPrm -> cmhStor EQ PB_STOR_Bd ) ) | |
563 { | |
564 if ( simShrdPrm.PINStat EQ PS_RDY ) | |
565 { | |
566 simShrdPrm.PINStat = PS_PIN2; | |
567 } | |
568 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_SimPin2Req ); | |
569 return( AT_FAIL ); | |
570 } | |
571 | |
572 /* process the status of parameter <index> */ | |
573 if ( index EQ ACI_NumParmNotPresent ) | |
574 { | |
575 indexStat = SNGL_NOT_PRSNT; | |
576 } | |
577 else if( index > PHB_CMH_IDX_MAX OR | |
578 index < PHB_CMH_IDX_MIN ) | |
579 { | |
580 indexStat = SNGL_INVLD_PRSNT; | |
581 } | |
582 else | |
583 { | |
584 indexStat = SNGL_VLD_PRSNT; | |
585 } | |
586 | |
587 /* process the status of parameter <number>, <type> and <text> */ | |
588 if ( number EQ NULL AND | |
589 type EQ NULL AND | |
590 text EQ NULL ) | |
591 { | |
592 entryStat = CMN_NOT_PRSNT; | |
593 } | |
594 else if ( number NEQ NULL AND | |
595 text NEQ NULL ) | |
596 { | |
597 entryStat = CMN_FULL_PRSNT; | |
598 } | |
599 else | |
600 { | |
601 entryStat = CMN_PRTLY_PRSNT; | |
602 } | |
603 | |
604 /* | |
605 *----------------------------------------------------------------- | |
606 * process the parameter: | |
607 * | |
608 * A -> number, type, text | |
609 * B -> index | |
610 * | |
611 * 0 -> all elements not present | |
612 * 1 -> all elements present | |
613 * | |
614 * A | B | result | |
615 * --+---+--------------------------- | |
616 * 0 | 0 | fail | |
617 * 0 | 1 | delete entry | |
618 * 1 | 0 | write to first empty entry | |
619 * 1 | 1 | write to specific entry | |
620 *----------------------------------------------------------------- | |
621 */ | |
622 switch ( entryStat ) | |
623 { | |
624 /* process variable <entryStat> with value <CMN_FULL_PRSNT> */ | |
625 case ( CMN_FULL_PRSNT): | |
626 case ( CMN_PRTLY_PRSNT ): | |
627 aci_return = cmhPHB_add_record(srcId, indexStat, text, number, type, index, dateTime, pPHBCmdPrm->phbStor); | |
628 if(aci_return EQ AT_EXCT) | |
629 { | |
630 pPHBCmdPrm->curCmd = AT_CMD_CPBW; | |
631 } | |
632 return(aci_return); | |
633 | |
634 /* process variable <entryStat> with value <CMN_NOT_PRSNT> */ | |
635 case ( CMN_NOT_PRSNT ): | |
636 | |
637 if ( indexStat NEQ SNGL_VLD_PRSNT ) | |
638 { | |
639 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter ); | |
640 return( AT_FAIL ); | |
641 } | |
642 | |
643 #ifdef TI_PS_FFS_PHB | |
644 result = pb_del_record (pPHBCmdPrm->phbStor, index); | |
645 #else | |
646 result = pb_delete_record (pPHBCmdPrm->phbStor, | |
647 (UBYTE) index, | |
648 &ext_rcd_num, | |
649 TRUE); | |
650 #endif | |
651 | |
652 switch (result) | |
653 { | |
654 case PHB_EXCT: | |
655 if (srcId EQ CMD_SRC_LCL) | |
656 { | |
657 TRACE_EVENT("Special handling with LCL source: return AT_CMPL"); | |
658 return (AT_CMPL); | |
659 } | |
660 pPHBCmdPrm->curCmd = AT_CMD_CPBW; | |
661 return (AT_EXCT); | |
662 | |
663 case PHB_OK: | |
664 return (AT_CMPL); | |
665 | |
666 #ifdef TI_PS_FFS_PHB | |
667 case PHB_LOCKED: | |
668 return (AT_BUSY); | |
669 #endif | |
670 | |
671 case PHB_FAIL: | |
672 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_InvIdx ); | |
673 return (AT_FAIL); | |
674 | |
675 default: | |
676 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_Unknown ); | |
677 return (AT_FAIL); | |
678 } | |
679 } | |
680 | |
681 return ( AT_CMPL ); | |
682 } | |
683 | |
684 /* | |
685 +-------------------------------------------------------------------+ | |
686 | PROJECT : GSM-PS (6147) MODULE : CMH_PHBS | | |
687 | STATE : code ROUTINE : sAT_PlusCPBR | | |
688 +-------------------------------------------------------------------+ | |
689 | |
690 PURPOSE : This is the functional counterpart of the +CPBR | |
691 AT command which is responsible for reading phonebook | |
692 entries from memory. | |
693 | |
694 <startIdx>: index of first location to be read | |
695 <stopIdx>: index of last location to be read | |
696 <lastIdx>: index of last location already read | |
697 <pbLst>: list of phonebook entries | |
698 */ | |
699 GLOBAL T_ACI_RETURN sAT_PlusCPBR ( T_ACI_CMD_SRC srcId, | |
700 SHORT startIdx, | |
701 SHORT stopIdx, | |
702 SHORT* lastIdx, | |
703 T_ACI_PB_ENTR* pbLst) | |
704 { | |
705 TRACE_FUNCTION ("sAT_PlusCPBR ()"); | |
706 | |
707 return cmhPHB_PlusCPBR ( srcId, | |
708 SR_TYP_Physical, | |
709 startIdx, | |
710 stopIdx, | |
711 lastIdx, | |
712 pbLst ); | |
713 } | |
714 | |
715 | |
716 | |
717 /* | |
718 PURPOSE : This is the functional counterpart of the %CPBR | |
719 AT command which is responsible for reading phonebook | |
720 entries from memory. | |
721 | |
722 ************************************************** | |
723 Added by Shen,Chao March.18th.2003 | |
724 ************************************************** | |
725 */ | |
726 GLOBAL T_ACI_RETURN sAT_PercentCPBR ( T_ACI_CMD_SRC srcId, | |
727 SHORT startIdx, | |
728 SHORT stopIdx, | |
729 T_ACI_SR_TYP searchMode, | |
730 SHORT* lastIdx, | |
731 T_ACI_PB_ENTR* pbLst ) | |
732 { | |
733 TRACE_FUNCTION ("sAT_PercentCPBR ()"); | |
734 | |
735 return cmhPHB_PlusCPBR ( srcId, | |
736 searchMode, | |
737 startIdx, | |
738 stopIdx, | |
739 lastIdx, | |
740 pbLst ); | |
741 } | |
742 | |
743 #ifdef TI_PS_FFS_PHB | |
744 /* | |
745 +-------------------------------------------------------------------+ | |
746 | PROJECT : GSM-PS (6147) MODULE : CMH_PHBS | | |
747 | STATE : code ROUTINE : cmhPHB_read_index_record | | |
748 +-------------------------------------------------------------------+ | |
749 | |
750 PURPOSE : This function reads the nth non-free record determined | |
751 by index. | |
752 This function could be implemented more efficiently | |
753 within the phonebook itself, on the other hand, | |
754 it is not used in the code for the big phonebooks like ADN, | |
755 so we should be able to live with this at least for a while. | |
756 | |
757 */ | |
758 LOCAL T_PHB_RETURN cmhPHB_read_index_record (T_PHB_TYPE type, | |
759 SHORT index, | |
760 T_PHB_RECORD *entry) | |
761 { | |
762 T_PHB_RETURN phb_result; | |
763 USHORT phy_recno; | |
764 | |
765 TRACE_FUNCTION ("cmhPHB_read_index_record()"); | |
766 | |
767 if (index < PHB_CMH_IDX_MIN) | |
768 return PHB_INVALID_IDX; | |
769 | |
770 phy_recno = PHB_CMH_IDX_MIN; | |
771 | |
772 do | |
773 { | |
774 do | |
775 { | |
776 phb_result = pb_read_record (type, phy_recno, entry); | |
777 phy_recno++; | |
778 } | |
779 while (phb_result EQ PHB_EMPTY_RECORD); | |
780 index--; | |
781 } | |
782 while (index NEQ 0); | |
783 return phb_result; | |
784 } | |
785 #endif | |
786 | |
787 /* | |
788 +-------------------------------------------------------------------+ | |
789 | PROJECT : GSM-PS (6147) MODULE : CMH_PHBS | | |
790 | STATE : code ROUTINE : cmhPHB_PlusCPBR | | |
791 +-------------------------------------------------------------------+ | |
792 | |
793 PURPOSE : This is the functional counterpart of the +CPBR | |
794 AT command which is responsible for reading phonebook | |
795 entries from memory. | |
796 | |
797 <type>: search type | |
798 <startIdx>: index of first location to be read | |
799 <stopIdx>: index of last location to be read | |
800 <lastIdx>: index of last location already read | |
801 <pbLst>: list of phonebook entries | |
802 */ | |
803 GLOBAL T_ACI_RETURN cmhPHB_PlusCPBR ( T_ACI_CMD_SRC srcId, | |
804 T_ACI_SR_TYP type, | |
805 SHORT startIdx, | |
806 SHORT stopIdx, | |
807 SHORT* lastIdx, | |
808 T_ACI_PB_ENTR* pbLst) | |
809 { | |
810 T_PHB_CMD_PRM * pPHBCmdPrm; /* points to PHB command parameters */ | |
811 SHORT toIdx; /* last used index */ | |
812 SHORT maxIdx; /* holds upper index bound */ | |
813 SHORT i; /* used for counting */ | |
814 SHORT readRec = 0; /* records already read */ | |
815 T_PHB_RECORD rec; /* read record */ | |
816 T_FCT_READ* readFct; /* selected read function */ | |
817 T_PHB_RETURN result; | |
818 #ifdef TI_PS_FFS_PHB | |
819 T_PHB_TYPE book; /* Phonebook */ | |
820 SHORT dummy_used_rcd; | |
821 UBYTE dummy_num_len; | |
822 UBYTE dummy_tag_len; | |
823 #endif | |
824 | |
825 /* | |
826 *----------------------------------------------------------------- | |
827 * check command source | |
828 *----------------------------------------------------------------- | |
829 */ | |
830 if(!cmh_IsVldCmdSrc (srcId)) | |
831 { | |
832 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter ); | |
833 return( AT_FAIL ); | |
834 } | |
835 | |
836 pPHBCmdPrm = &cmhPrm[srcId].phbCmdPrm; | |
837 | |
838 /* | |
839 *----------------------------------------------------------------- | |
840 * check preselected phonebook storage | |
841 *----------------------------------------------------------------- | |
842 */ | |
843 #ifdef TI_PS_FFS_PHB | |
844 if (!cmhPHB_cvtPhbType (pPHBCmdPrm->cmhStor, &book)) | |
845 #else | |
846 if ( pPHBCmdPrm -> cmhStor EQ PB_STOR_NotPresent ) | |
847 #endif | |
848 { | |
849 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter ); | |
850 return( AT_FAIL ); | |
851 } | |
852 | |
853 /* | |
854 *----------------------------------------------------------------- | |
855 * check input parameter <startIdx> | |
856 *----------------------------------------------------------------- | |
857 */ | |
858 #ifdef TI_PS_FFS_PHB | |
859 (void)pb_read_sizes (book, &maxIdx, | |
860 &dummy_used_rcd, &dummy_num_len, &dummy_tag_len); | |
861 #else | |
862 if( pPHBCmdPrm->cmhStor EQ PB_STOR_Af ) /* ADN-FDN phb */ | |
863 maxIdx = MAX_AFB_RECORDS; | |
864 else | |
865 maxIdx = PHB_CMH_IDX_MAX; | |
866 #endif | |
867 | |
868 if( startIdx > maxIdx OR startIdx < PHB_CMH_IDX_MIN ) | |
869 { | |
870 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_InvIdx ); | |
871 return( AT_FAIL ); | |
872 } | |
873 | |
874 /* | |
875 *----------------------------------------------------------------- | |
876 * check input parameter <stopIdx> | |
877 *----------------------------------------------------------------- | |
878 */ | |
879 if ( stopIdx EQ ACI_NumParmNotPresent ) | |
880 | |
881 toIdx = startIdx; | |
882 | |
883 else | |
884 { | |
885 if( stopIdx > maxIdx OR stopIdx < PHB_CMH_IDX_MIN OR | |
886 stopIdx < startIdx ) | |
887 { | |
888 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_InvIdx ); | |
889 return( AT_FAIL ); | |
890 } | |
891 | |
892 else | |
893 | |
894 toIdx = stopIdx; | |
895 } | |
896 | |
897 /* | |
898 *----------------------------------------------------------------- | |
899 * calculating the read function | |
900 *----------------------------------------------------------------- | |
901 */ | |
902 switch ( type ) | |
903 { | |
904 case ( SR_TYP_Name ): readFct = pb_read_alpha_record; break; | |
905 case ( SR_TYP_Number ): readFct = pb_read_number_record; break; | |
906 #ifdef TI_PS_FFS_PHB | |
907 /*case ( SR_TYP_Index ): readFct = pb_read_index_record; break;*/ | |
908 case ( SR_TYP_Index ): readFct = cmhPHB_read_index_record; break; | |
909 case ( SR_TYP_Physical ): readFct = pb_read_record; break; | |
910 #else | |
911 case ( SR_TYP_Index ): readFct = pb_read_index_record; break; | |
912 case ( SR_TYP_Physical ): readFct = pb_read_phys_record; break; | |
913 #endif | |
914 | |
915 default: | |
916 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter ); | |
917 return( AT_FAIL ); | |
918 } | |
919 | |
920 /* | |
921 *----------------------------------------------------------------- | |
922 * reading of records | |
923 *----------------------------------------------------------------- | |
924 */ | |
925 i = startIdx; | |
926 | |
927 while ( i <= toIdx AND readRec < MAX_PB_ENTR ) | |
928 { | |
929 result = readFct (pPHBCmdPrm->phbStor, i, &rec); | |
930 /* check for invalid index */ | |
931 if ((result EQ PHB_INVALID_IDX) AND (i EQ startIdx)) | |
932 { | |
933 ACI_ERR_DESC (ACI_ERR_CLASS_Cme, CME_ERR_InvIdx); | |
934 return( AT_FAIL ); | |
935 } | |
936 if (result EQ PHB_OK) | |
937 { | |
938 cmhPHB_cpyRecEntr (&pbLst[readRec], | |
939 #ifdef TI_PS_FFS_PHB | |
940 pPHBCmdPrm->phbStor, | |
941 #endif | |
942 &rec); | |
943 | |
944 readRec++; | |
945 } | |
946 if ( i EQ toIdx) /* this check is used in order to prevent the index = 0xFF */ | |
947 { | |
948 i++; | |
949 break; | |
950 } | |
951 else | |
952 i++; | |
953 } | |
954 | |
955 /* | |
956 *----------------------------------------------------------------- | |
957 * mark the first invalid entry | |
958 *----------------------------------------------------------------- | |
959 */ | |
960 if ( readRec < MAX_PB_ENTR ) | |
961 | |
962 cmhPHB_invldEntr ( &pbLst[readRec] ); | |
963 | |
964 /* | |
965 *----------------------------------------------------------------- | |
966 * process the parameter <lastIdx> | |
967 *----------------------------------------------------------------- | |
968 */ | |
969 /* *lastIdx = i - 1; */ | |
970 *lastIdx =(SHORT)(i - 1); /* set -1 to 255 */ | |
971 | |
972 return ( AT_CMPL ); | |
973 } | |
974 | |
975 /* | |
976 +-------------------------------------------------------------------+ | |
977 | PROJECT : GSM-PS (6147) MODULE : CMH_PHBS | | |
978 | STATE : code ROUTINE : sAT_PlusCPBF | | |
979 +-------------------------------------------------------------------+ | |
980 | |
981 PURPOSE : This is the functional counterpart of the +CPBF | |
982 AT command which is responsible for finding phonebook | |
983 entries in memory. | |
984 | |
985 <findText>: search string | |
986 <mode>: search mode | |
987 <found>: number of entries found | |
988 <pbLst>: list of found phonebook entries | |
989 */ | |
990 #ifdef NO_ASCIIZ | |
991 GLOBAL T_ACI_RETURN sAT_PlusCPBF ( T_ACI_CMD_SRC srcId, | |
992 T_ACI_PB_TEXT *findtext, | |
993 T_ACI_CPBF_MOD mode, | |
994 SHORT *found, | |
995 T_ACI_PB_ENTR *pbLst ) | |
996 #else /* ifdef NO_ASCIIZ */ | |
997 GLOBAL T_ACI_RETURN sAT_PlusCPBF ( T_ACI_CMD_SRC srcId, | |
998 CHAR *findtext_str, | |
999 T_ACI_CPBF_MOD mode, | |
1000 SHORT *found, | |
1001 T_ACI_PB_ENTR *pbLst ) | |
1002 #endif /* ifdef NO_ASCIIZ */ | |
1003 { | |
1004 SHORT firstIdx; /* dummy variable, not used */ | |
1005 T_ACI_PB_TEXT *find_text; | |
1006 #ifndef NO_ASCIIZ | |
1007 T_ACI_PB_TEXT findtext; | |
1008 #endif /* #ifndef NO_ASCIIZ */ | |
1009 | |
1010 TRACE_FUNCTION ("sAT_PlusCPBF ()"); | |
1011 | |
1012 #ifdef NO_ASCIIZ | |
1013 find_text = findtext; | |
1014 #else /* ifdef NO_ASCIIZ */ | |
1015 find_text = &findtext; | |
1016 | |
1017 if ( findtext_str NEQ NULL ) | |
1018 { | |
1019 USHORT len = (USHORT)strlen( findtext_str ); | |
1020 | |
1021 cmh_cvtToDefGsm ( findtext_str, (CHAR*)find_text->data, &len ); | |
1022 find_text->cs = CS_Sim; | |
1023 find_text->len = (UBYTE)len; | |
1024 } | |
1025 else | |
1026 { | |
1027 find_text->cs = CS_NotPresent; | |
1028 find_text->len = 0; | |
1029 } | |
1030 #endif /* ifdef NO_ASCIIZ */ | |
1031 | |
1032 return (cmhPHB_PlusCPBF ( srcId, | |
1033 find_text, | |
1034 SR_TYP_Name, | |
1035 mode, | |
1036 &firstIdx, | |
1037 found, | |
1038 pbLst )); | |
1039 } | |
1040 | |
1041 | |
1042 | |
1043 #ifdef NO_ASCIIZ | |
1044 GLOBAL T_ACI_RETURN sAT_PercentCPBF ( T_ACI_CMD_SRC srcId, | |
1045 T_ACI_PB_TEXT* findtext, | |
1046 T_ACI_CPBF_MOD mode, | |
1047 T_ACI_SR_TYP searchMode, | |
1048 U8 direction, | |
1049 SHORT* found, | |
1050 T_ACI_PB_ENTR* pbLst ) | |
1051 | |
1052 #else /* ifdef NO_ASCIIZ */ | |
1053 | |
1054 GLOBAL T_ACI_RETURN sAT_PercentCPBF ( T_ACI_CMD_SRC srcId, | |
1055 T_ACI_PB_TEXT* findtext, | |
1056 T_ACI_CPBF_MOD mode, | |
1057 T_ACI_SR_TYP searchMode, | |
1058 U8 direction, | |
1059 SHORT* found, | |
1060 T_ACI_PB_ENTR* pbLst ) | |
1061 #endif /* ifdef NO_ASCIIZ */ | |
1062 { | |
1063 SHORT firstIdx; /* dummy variable, not used */ | |
1064 T_ACI_PB_TEXT *find_text; | |
1065 #ifndef NO_ASCIIZ | |
1066 T_ACI_PB_TEXT findtext; | |
1067 #endif /* #ifndef NO_ASCIIZ */ | |
1068 | |
1069 TRACE_FUNCTION ("sAT_PercentCPBF ()"); | |
1070 | |
1071 #ifdef NO_ASCIIZ | |
1072 find_text = findtext; | |
1073 #else /* ifdef NO_ASCIIZ */ | |
1074 find_text = &findtext; | |
1075 | |
1076 if ( findtext_str NEQ NULL ) | |
1077 { | |
1078 USHORT len = (USHORT)strlen( findtext_str ); | |
1079 | |
1080 cmh_cvtToDefGsm ( findtext_str, (CHAR*)find_text->data, &len ); | |
1081 find_text->cs = CS_Sim; | |
1082 find_text->len = (UBYTE)len; | |
1083 } | |
1084 else | |
1085 { | |
1086 find_text->cs = CS_NotPresent; | |
1087 find_text->len = 0; | |
1088 } | |
1089 #endif /* ifdef NO_ASCIIZ */ | |
1090 | |
1091 return (cmhPHB_PlusCPBF ( srcId, | |
1092 find_text, | |
1093 searchMode, | |
1094 mode, | |
1095 &firstIdx, | |
1096 found, | |
1097 pbLst )); | |
1098 } | |
1099 | |
1100 | |
1101 /* | |
1102 +-------------------------------------------------------------------+ | |
1103 | PROJECT : GSM-PS (6147) MODULE : CMH_PHBS | | |
1104 | STATE : code ROUTINE : cmhPHB_PlusCPBF | | |
1105 +-------------------------------------------------------------------+ | |
1106 | |
1107 PURPOSE : This is the functional counterpart of the +CPBF | |
1108 AT command which is responsible for finding phonebook | |
1109 entries in memory. | |
1110 | |
1111 <findText>: search string | |
1112 <type>: search type | |
1113 <mode>: search mode | |
1114 <firstIdx>: first found index | |
1115 <found>: number of entries found | |
1116 <pbLst>: list of found phonebook entries | |
1117 | |
1118 HM 7-Sep-2005: Warning, MFW is using this function directly! | |
1119 | |
1120 */ | |
1121 GLOBAL T_ACI_RETURN cmhPHB_PlusCPBF ( T_ACI_CMD_SRC srcId, | |
1122 T_ACI_PB_TEXT *findtext, | |
1123 T_ACI_SR_TYP type, | |
1124 T_ACI_CPBF_MOD mode, | |
1125 SHORT* firstIdx, | |
1126 SHORT* found, | |
1127 T_ACI_PB_ENTR* pbLst ) | |
1128 { | |
1129 T_PHB_CMD_PRM * pPHBCmdPrm; /* points to PHB command parameters */ | |
1130 #ifdef TI_PS_FFS_PHB | |
1131 T_PHB_MATCH match_criteria; | |
1132 #else | |
1133 UBYTE cvtMode; /* converted parameter <mode> */ | |
1134 #endif | |
1135 USHORT i; /* used for counting */ | |
1136 T_PHB_RECORD fndRec; /* found records */ | |
1137 T_PHB_RETURN res; | |
1138 | |
1139 /* | |
1140 *----------------------------------------------------------------- | |
1141 * check command source | |
1142 *----------------------------------------------------------------- | |
1143 */ | |
1144 if(!cmh_IsVldCmdSrc (srcId)) | |
1145 { | |
1146 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter ); | |
1147 return( AT_FAIL ); | |
1148 } | |
1149 | |
1150 pPHBCmdPrm = &cmhPrm[srcId].phbCmdPrm; | |
1151 | |
1152 /* | |
1153 *----------------------------------------------------------------- | |
1154 * check preselected phonebook storage | |
1155 *----------------------------------------------------------------- | |
1156 */ | |
1157 if ( pPHBCmdPrm -> cmhStor EQ PB_STOR_NotPresent ) | |
1158 { | |
1159 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter ); | |
1160 return( AT_FAIL ); | |
1161 } | |
1162 | |
1163 /* | |
1164 *----------------------------------------------------------------- | |
1165 * check input parameter <findtext> | |
1166 *----------------------------------------------------------------- | |
1167 */ | |
1168 if ( ( findtext EQ NULL ) OR ( findtext->len EQ 0 ) ) | |
1169 { | |
1170 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter ); | |
1171 return( AT_FAIL ); | |
1172 } | |
1173 | |
1174 /* | |
1175 *----------------------------------------------------------------- | |
1176 * check input parameter <mode> | |
1177 *----------------------------------------------------------------- | |
1178 */ | |
1179 switch ( mode ) | |
1180 { | |
1181 #ifdef TI_PS_FFS_PHB | |
1182 case CPBF_MOD_NewSearch: | |
1183 case CPBF_MOD_NextSearch: | |
1184 break; | |
1185 #else | |
1186 case ( CPBF_MOD_NewSearch ): cvtMode = PHB_NEW_SEARCH; break; | |
1187 case ( CPBF_MOD_NextSearch ): cvtMode = PHB_NEXT_SEARCH; break; | |
1188 #endif | |
1189 | |
1190 default: | |
1191 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter ); | |
1192 return( AT_FAIL ); | |
1193 } | |
1194 | |
1195 /* | |
1196 *----------------------------------------------------------------- | |
1197 * searching for first records and reset information about found | |
1198 * and written records | |
1199 *----------------------------------------------------------------- | |
1200 */ | |
1201 #ifdef TI_PS_FFS_PHB | |
1202 if ( mode EQ CPBF_MOD_NewSearch ) | |
1203 { | |
1204 pPHBCmdPrm->order_num = 0; | |
1205 *firstIdx = 0; | |
1206 *found = 0; | |
1207 switch ( type ) | |
1208 { | |
1209 case ( SR_TYP_Name ): | |
1210 if (srcId EQ CMD_SRC_LCL) | |
1211 match_criteria = PHB_MATCH_GE; | |
1212 else | |
1213 match_criteria = PHB_MATCH_PARTIAL; | |
1214 | |
1215 res = pb_search_name_ex (pPHBCmdPrm -> phbStor, | |
1216 match_criteria, | |
1217 findtext, | |
1218 firstIdx, | |
1219 found, | |
1220 &fndRec); | |
1221 break; | |
1222 | |
1223 case ( SR_TYP_Number ): | |
1224 res = pb_search_number_ex (pPHBCmdPrm -> phbStor, | |
1225 findtext->data, | |
1226 firstIdx, | |
1227 found, | |
1228 &fndRec); | |
1229 break; | |
1230 | |
1231 default: | |
1232 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter ); | |
1233 return( AT_FAIL ); | |
1234 } | |
1235 | |
1236 switch (res) | |
1237 { | |
1238 case PHB_OK: | |
1239 break; | |
1240 | |
1241 case PHB_LOCKED: | |
1242 return AT_BUSY; | |
1243 | |
1244 default: | |
1245 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_NotFound ); | |
1246 return( AT_FAIL ); | |
1247 } | |
1248 | |
1249 pPHBCmdPrm -> fndRec = *found; | |
1250 pPHBCmdPrm -> wrtRec = 0; | |
1251 i = 0; | |
1252 | |
1253 if ( pPHBCmdPrm -> fndRec > 0 ) | |
1254 { | |
1255 cmhPHB_cpyRecEntr (&pbLst[i], | |
1256 pPHBCmdPrm->phbStor, | |
1257 &fndRec); | |
1258 | |
1259 pPHBCmdPrm -> wrtRec++; | |
1260 | |
1261 i++; | |
1262 } | |
1263 pPHBCmdPrm->order_num = *firstIdx + pPHBCmdPrm->wrtRec; | |
1264 } | |
1265 else | |
1266 { | |
1267 /* CPBF_MOD_NextSearch */ | |
1268 i = 0; | |
1269 } | |
1270 #else | |
1271 if ( mode EQ CPBF_MOD_NewSearch ) | |
1272 { | |
1273 *firstIdx = 0; | |
1274 *found = 0; | |
1275 switch ( type ) | |
1276 { | |
1277 case ( SR_TYP_Name ): | |
1278 res = pb_search_name ( srcId, | |
1279 pPHBCmdPrm -> phbStor, | |
1280 findtext, | |
1281 cvtMode, | |
1282 firstIdx, | |
1283 found, | |
1284 &fndRec ); | |
1285 break; | |
1286 case ( SR_TYP_Number ): | |
1287 res = pb_search_number ( pPHBCmdPrm -> phbStor, | |
1288 findtext->data, | |
1289 cvtMode, | |
1290 firstIdx, | |
1291 found, | |
1292 &fndRec ); | |
1293 break; | |
1294 default: | |
1295 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter ); | |
1296 return( AT_FAIL ); | |
1297 } | |
1298 | |
1299 if ( res EQ PHB_FAIL ) | |
1300 { | |
1301 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_NotFound ); | |
1302 return( AT_FAIL ); | |
1303 } | |
1304 | |
1305 pPHBCmdPrm -> fndRec = *found; | |
1306 pPHBCmdPrm -> wrtRec = 0; | |
1307 i = 0; | |
1308 | |
1309 if ( pPHBCmdPrm -> fndRec > 0 ) | |
1310 { | |
1311 cmhPHB_cpyRecEntr ( &pbLst[i], &fndRec ); | |
1312 | |
1313 pPHBCmdPrm -> wrtRec++; | |
1314 | |
1315 i++; | |
1316 } | |
1317 } | |
1318 else | |
1319 | |
1320 i = 0; | |
1321 #endif | |
1322 | |
1323 /* | |
1324 *----------------------------------------------------------------- | |
1325 * copying and searching of records | |
1326 *----------------------------------------------------------------- | |
1327 */ | |
1328 while ( i < MAX_PB_ENTR AND | |
1329 pPHBCmdPrm -> wrtRec < pPHBCmdPrm -> fndRec) | |
1330 { | |
1331 switch ( type ) | |
1332 { | |
1333 #ifdef TI_PS_FFS_PHB | |
1334 case ( SR_TYP_Name ): | |
1335 res = pb_read_alpha_record (pPHBCmdPrm->phbStor, | |
1336 pPHBCmdPrm->order_num, | |
1337 &fndRec); | |
1338 break; | |
1339 | |
1340 case ( SR_TYP_Number ): | |
1341 res = pb_read_number_record (pPHBCmdPrm->phbStor, | |
1342 pPHBCmdPrm->order_num, | |
1343 &fndRec); | |
1344 break; | |
1345 #else | |
1346 case ( SR_TYP_Name ): | |
1347 res = pb_search_name ( srcId, | |
1348 pPHBCmdPrm -> phbStor, | |
1349 findtext, | |
1350 CPBF_MOD_NextSearch, | |
1351 firstIdx, | |
1352 found, | |
1353 &fndRec ); | |
1354 break; | |
1355 case ( SR_TYP_Number ): | |
1356 res = pb_search_number ( pPHBCmdPrm -> phbStor, | |
1357 findtext->data, | |
1358 CPBF_MOD_NextSearch, | |
1359 firstIdx, | |
1360 found, | |
1361 &fndRec ); | |
1362 break; | |
1363 #endif | |
1364 | |
1365 default: | |
1366 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter ); | |
1367 return( AT_FAIL ); | |
1368 } | |
1369 if (res NEQ PHB_OK) | |
1370 { | |
1371 pPHBCmdPrm->order_num = 0; | |
1372 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_NotFound ); | |
1373 return( AT_FAIL ); | |
1374 } | |
1375 | |
1376 cmhPHB_cpyRecEntr (&pbLst[i], | |
1377 #ifdef TI_PS_FFS_PHB | |
1378 pPHBCmdPrm->phbStor, | |
1379 #endif | |
1380 &fndRec); | |
1381 | |
1382 pPHBCmdPrm -> wrtRec++; | |
1383 pPHBCmdPrm -> order_num++; | |
1384 | |
1385 i++; | |
1386 } | |
1387 | |
1388 if (pPHBCmdPrm->wrtRec >= pPHBCmdPrm->fndRec) // #HM# | |
1389 pPHBCmdPrm->order_num = 0; // #HM# | |
1390 | |
1391 /* | |
1392 *----------------------------------------------------------------- | |
1393 * mark the first invalid entry | |
1394 *----------------------------------------------------------------- | |
1395 */ | |
1396 if ( i < MAX_PB_ENTR ) | |
1397 | |
1398 cmhPHB_invldEntr ( &pbLst[i] ); | |
1399 | |
1400 return ( AT_CMPL ); | |
1401 } | |
1402 | |
1403 /* | |
1404 +-------------------------------------------------------------------+ | |
1405 | PROJECT : GSM-PS (6147) MODULE : CMH_PHBS | | |
1406 | STATE : code ROUTINE : sAT_PercentPBCF | | |
1407 +-------------------------------------------------------------------+ | |
1408 | |
1409 PURPOSE : This is the functional counterpart of the %PBCF | |
1410 AT command which is responsible for phone configuration. | |
1411 | |
1412 <ldn>: last dialed number configuration. | |
1413 <lrn>: last received number configuration. | |
1414 */ | |
1415 GLOBAL T_ACI_RETURN sAT_PercentPBCF( T_ACI_CMD_SRC srcId, | |
1416 T_ACI_PBCF_LDN ldn, | |
1417 T_ACI_PBCF_LRN lrn, | |
1418 T_ACI_PBCF_LMN lmn ) | |
1419 { | |
1420 | |
1421 TRACE_FUNCTION ("sAT_PercentPBCF ()"); | |
1422 | |
1423 /* | |
1424 *----------------------------------------------------------------- | |
1425 * process the <ldn> parameter | |
1426 *----------------------------------------------------------------- | |
1427 */ | |
1428 switch( ldn ) | |
1429 { | |
1430 case( PBCF_LDN_NotPresent ): | |
1431 | |
1432 ldn = PBCFldn; | |
1433 break; | |
1434 | |
1435 case( PBCF_LDN_Enable ): | |
1436 case( PBCF_LDN_Disable ): | |
1437 | |
1438 break; | |
1439 | |
1440 default: | |
1441 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter ); | |
1442 return( AT_FAIL ); | |
1443 } | |
1444 | |
1445 /* | |
1446 *----------------------------------------------------------------- | |
1447 * process the <lrn> parameter | |
1448 *----------------------------------------------------------------- | |
1449 */ | |
1450 switch( lrn ) | |
1451 { | |
1452 case( PBCF_LRN_NotPresent ): | |
1453 | |
1454 ldn = PBCFlrn; | |
1455 break; | |
1456 | |
1457 case( PBCF_LRN_Enable ): | |
1458 case( PBCF_LRN_Disable ): | |
1459 | |
1460 break; | |
1461 | |
1462 default: | |
1463 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter ); | |
1464 return( AT_FAIL ); | |
1465 } | |
1466 | |
1467 /* | |
1468 *----------------------------------------------------------------- | |
1469 * process the <lmn> parameter | |
1470 *----------------------------------------------------------------- | |
1471 */ | |
1472 switch( lmn ) | |
1473 { | |
1474 case( PBCF_LMN_NotPresent ): | |
1475 | |
1476 lmn = PBCFlmn; | |
1477 break; | |
1478 | |
1479 case( PBCF_LMN_Enable ): | |
1480 case( PBCF_LMN_Disable ): | |
1481 | |
1482 break; | |
1483 | |
1484 default: | |
1485 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter ); | |
1486 return( AT_FAIL ); | |
1487 } | |
1488 | |
1489 /* | |
1490 *-------------------------------------------------------------------- | |
1491 * assign the parameters | |
1492 *-------------------------------------------------------------------- | |
1493 */ | |
1494 PBCFldn = ldn; | |
1495 PBCFlrn = lrn; | |
1496 PBCFlmn = lmn; | |
1497 | |
1498 return ( AT_CMPL ); | |
1499 } | |
1500 | |
1501 /* | |
1502 +---------------------------------------------------------------------+ | |
1503 | PROJECT : GSM-PS (6147) MODULE : CMH_CCS | | |
1504 | STATE : code ROUTINE : sAT_PlusCSVM | | |
1505 +---------------------------------------------------------------------+ | |
1506 | |
1507 PURPOSE : This is the functional counterpart of the +CSVM AT command | |
1508 which is responsible for Setting a Voice Mail Number. | |
1509 | |
1510 <mode>: Enable or Disable the voice mail number | |
1511 <pnumber>: Number of the voice mail server | |
1512 <num_len>: Number length | |
1513 <type>: type of number | |
1514 */ | |
1515 | |
1516 GLOBAL T_ACI_RETURN sAT_PlusCSVM ( T_ACI_CMD_SRC srcId, | |
1517 T_ACI_CSVM_MOD mode, | |
1518 CHAR *pnumber, | |
1519 UBYTE num_len, | |
1520 T_ACI_TOA* toa) | |
1521 { | |
1522 CHAR* ef = EF_VMN_ID; | |
1523 UBYTE toa_val= 0; | |
1524 | |
1525 T_PHB_CMD_PRM * pPHBCmdPrm; /* points to PHB command parameter */ | |
1526 EF_VMN vmn; | |
1527 | |
1528 TRACE_FUNCTION ("sAT_PlusCSVM ()"); | |
1529 /* | |
1530 *----------------------------------------------------------------- | |
1531 * check command source | |
1532 *----------------------------------------------------------------- | |
1533 */ | |
1534 if(!cmh_IsVldCmdSrc (srcId)) | |
1535 { | |
1536 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter ); | |
1537 return( AT_FAIL ); | |
1538 } | |
1539 | |
1540 pPHBCmdPrm = &cmhPrm[srcId].phbCmdPrm; | |
1541 /* | |
1542 *------------------------------------------------------------------- | |
1543 * process the mode parameter | |
1544 *------------------------------------------------------------------- | |
1545 */ | |
1546 switch( mode ) | |
1547 { | |
1548 case( CSVM_MOD_NotPresent ): | |
1549 break; | |
1550 | |
1551 case( CSVM_MOD_Disable ): | |
1552 case( CSVM_MOD_Enable ): | |
1553 | |
1554 pPHBCmdPrm -> CSVMmode = mode; | |
1555 break; | |
1556 | |
1557 default: | |
1558 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_Unknown ); | |
1559 return( AT_FAIL ); | |
1560 } | |
1561 | |
1562 /* | |
1563 *------------------------------------------------------------------- | |
1564 * process the toa parameter | |
1565 *------------------------------------------------------------------- | |
1566 */ | |
1567 if( ! toa ) | |
1568 return( AT_CMPL ); | |
1569 | |
1570 switch( toa -> ton ) | |
1571 { | |
1572 case( TON_Unknown ): | |
1573 case( TON_International ): | |
1574 case( TON_National ): | |
1575 case( TON_NetSpecific ): | |
1576 case( TON_DedAccess ): | |
1577 | |
1578 break; | |
1579 | |
1580 default: | |
1581 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_Unknown ); | |
1582 return( AT_FAIL ); | |
1583 } | |
1584 | |
1585 switch( toa -> npi ) | |
1586 { | |
1587 case( NPI_Unknown ): | |
1588 case( NPI_IsdnTelephony ): | |
1589 case( NPI_Data ): | |
1590 case( NPI_Telex ): | |
1591 case( NPI_National ): | |
1592 case( NPI_Private ): | |
1593 | |
1594 break; | |
1595 | |
1596 default: | |
1597 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_Unknown ); | |
1598 return( AT_FAIL ); | |
1599 } | |
1600 | |
1601 /* | |
1602 *------------------------------------------------------------------- | |
1603 * process the phone number | |
1604 *------------------------------------------------------------------- | |
1605 */ | |
1606 /*init*/ | |
1607 memset( vmn.vmNum, 0xFF, sizeof(vmn.vmNum) ); | |
1608 | |
1609 memcpy ( vmn.vmNum, pnumber, num_len ); | |
1610 toa_val = toa_merge (*toa); | |
1611 | |
1612 vmn.numTp = toa_val; | |
1613 | |
1614 if (pcm_WriteFile((UBYTE*)ef, SIZE_EF_VMN, (UBYTE*)&vmn) EQ PCM_OK) | |
1615 { | |
1616 return( AT_CMPL ); | |
1617 } | |
1618 else | |
1619 { | |
1620 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_MemFail ); | |
1621 return( AT_FAIL ); | |
1622 } | |
1623 | |
1624 } | |
1625 /*==== EOF ========================================================*/ |