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