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