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

initial import: leo2moko-r1
author Space Falcon <falcon@ivan.Harhan.ORG>
date Mon, 01 Jun 2015 03:24:05 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:509db1a7b7b8
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : GSM-PS (6147)
4 | Modul : CMH_PHBQ
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 query functions related to the
18 | protocol stack adapter for phonebook management.
19 +-----------------------------------------------------------------------------
20 */
21
22 #ifndef CMH_PHBQ_C
23 #define CMH_PHBQ_C
24 #endif
25
26 #include "aci_all.h"
27 /*==== INCLUDES ===================================================*/
28 #include "aci_cmh.h"
29
30 #ifdef FAX_AND_DATA
31 #include "aci_fd.h"
32 #endif /* of #ifdef FAX_AND_DATA */
33
34 #include "psa.h"
35 #include "psa_sim.h"
36 #include "phb.h"
37 #include "cmh.h"
38 #include "cmh_phb.h"
39 #include "pcm.h"
40 /*==== CONSTANTS ==================================================*/
41
42 /*==== EXPORT =====================================================*/
43
44 /*==== VARIABLES ==================================================*/
45
46 /*==== FUNCTIONS ==================================================*/
47 /*
48 +--------------------------------------------------------------------+
49 | PROJECT : GSM-PS (6147) MODULE : CMH_PHBQ |
50 | STATE : code ROUTINE : cmh_QueryCPBS |
51 +--------------------------------------------------------------------+
52
53 PURPOSE : This is the functional counterpart to the +CPBS? and %CPBS?
54 AT commands which return the current selected phonebook
55 memrory storage.
56
57 <storage>: pbonebook memory storage
58 <used>: number of used records
59 <total>: total number of records
60 <first>: first free location
61 */
62 LOCAL T_ACI_RETURN cmh_QueryCPBS ( T_ACI_CMD_SRC srcId,
63 T_ACI_PB_STOR* storage,
64 SHORT* used,
65 SHORT* total,
66 SHORT* first )
67 {
68 T_PHB_CMD_PRM * pPHBCmdPrm; /* points to PHB command parameter */
69
70 TRACE_FUNCTION ("cmh_QueryCPBS ()");
71
72 /*
73 *-----------------------------------------------------------------
74 * check command source
75 *-----------------------------------------------------------------
76 */
77 if( ! cmh_IsVldCmdSrc (srcId) )
78 {
79 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
80 return( AT_FAIL );
81 }
82
83 pPHBCmdPrm = &cmhPrm[srcId].phbCmdPrm;
84
85 /*
86 *-----------------------------------------------------------------
87 * fill in parameter <storage>
88 *-----------------------------------------------------------------
89 */
90 *storage = pPHBCmdPrm -> cmhStor;
91
92 /*
93 *-----------------------------------------------------------------
94 * fill in parameters <used>, <total> and <first>
95 *-----------------------------------------------------------------
96 */
97 *used = 0;
98 *total = 0;
99
100 if (first)
101 *first=0;
102
103 #ifdef TI_PS_FFS_PHB
104 if ( pPHBCmdPrm -> cmhStor NEQ PB_STOR_NotPresent )
105 {
106 UBYTE dmyNumLen;
107 UBYTE dmyTagLen;
108
109 switch (simShrdPrm.pb_stat)
110 {
111 case PB_STAT_Ready:
112 break;
113
114 case PB_STAT_Busy:
115 TRACE_EVENT("Error: Phonebook busy accessing SIM");
116 ACI_ERR_DESC(ACI_ERR_CLASS_Cme, CME_ERR_SimBusy);
117 return AT_FAIL;
118
119 case PB_STAT_Blocked:
120 default:
121 TRACE_EVENT("Error: Phonebook blocked");
122 ACI_ERR_DESC(ACI_ERR_CLASS_Cme,CME_ERR_Unknown);
123 return AT_FAIL;
124 }
125
126 switch (pb_read_sizes (pPHBCmdPrm->phbStor,
127 total,
128 used,
129 &dmyNumLen,
130 &dmyTagLen))
131 {
132 case PHB_OK:
133 break;
134
135 case PHB_FAIL:
136 default:
137 return (AT_FAIL);
138 }
139
140 /*
141 * Now try and determine the first free location in the
142 * currently selected phonebook, but only if the output pointer
143 * is valid.
144 */
145 if (first NEQ NULL)
146 {
147 *first = (SHORT)pb_find_free_record (pPHBCmdPrm->phbStor);
148 if (*first < 0)
149 {
150 ACI_ERR_DESC(ACI_ERR_CLASS_Cme,CME_ERR_Unknown);
151 *first = 0;
152 }
153 }
154 }
155 #else
156 if ( pPHBCmdPrm -> cmhStor NEQ PB_STOR_NotPresent )
157 {
158 UBYTE dmySrvc;
159 UBYTE dmyTagLen;
160 SHORT dmyAvail;
161 T_PHB_RETURN ret = PHB_FAIL;
162
163 ret = pb_read_status (pPHBCmdPrm -> phbStor,
164 &dmySrvc,
165 total,
166 used,
167 &dmyTagLen,
168 &dmyAvail);
169 switch (ret)
170 {
171 case (PHB_FAIL):
172 {
173 if ((*used EQ 0) AND (*total EQ 0))
174 {
175 /*
176 * this kind of phonebook has no entries, respectively no memory at all
177 * output should be +CPBS: <storage>,0,0
178 * and not +CME: 100 <=== unknown error
179 */
180 break;
181 }
182 return (AT_FAIL);
183 }
184 case (PHB_OK):
185 {
186 break;
187 }
188 default:
189 {
190 return (AT_FAIL);
191 }
192 }
193
194 /*
195 * Now try and determine the first free location in the
196 * currently selected phonebook, but only if the output pointer
197 * is valid.
198 */
199 if (first NEQ NULL)
200 {
201 if (ret EQ PHB_OK)
202 {
203 ret=pb_first_free(pPHBCmdPrm->phbStor,first);
204
205 switch(ret)
206 {
207 default:
208 case PHB_FAIL:
209 /*
210 * It is assumed that pb_first_free() will have filled in
211 * the error number (ACI_ERR_DESC).
212 */
213 return(AT_FAIL);
214
215 case PHB_FULL:
216 case PHB_OK:
217 break;
218 }
219 }
220 }
221 }
222 #endif
223
224 return ( AT_CMPL );
225 }
226
227 /*
228 +--------------------------------------------------------------------+
229 | PROJECT : GSM-PS (6147) MODULE : CMH_PHBQ |
230 | STATE : code ROUTINE : qAT_PercentCPBS |
231 +--------------------------------------------------------------------+
232
233 PURPOSE : This is the functional counterpart to the %CPBS?
234 AT command which returns the current selected phonebook
235 memrory storage.
236
237 <storage>: pbonebook memory storage
238 <used>: number of used records
239 <total>: total number of records
240 <first>: first free location
241 */
242 GLOBAL T_ACI_RETURN qAT_PercentCPBS ( T_ACI_CMD_SRC srcId,
243 T_ACI_PB_STOR* storage,
244 SHORT* used,
245 SHORT* total,
246 SHORT* first )
247 {
248 TRACE_FUNCTION ("qAT_PercentCPBS ()");
249
250 return(cmh_QueryCPBS(srcId,storage,used,total,first));
251 }
252
253 /*
254 +--------------------------------------------------------------------+
255 | PROJECT : GSM-PS (6147) MODULE : CMH_PHBQ |
256 | STATE : code ROUTINE : qAT_PlusCPBS |
257 +--------------------------------------------------------------------+
258
259 PURPOSE : This is the functional counterpart to the +CPBS?
260 AT command which returns the current selected phonebook
261 memrory storage.
262
263 <storage>: pbonebook memory storage
264 <used>: number of used records
265 <total>: total number of records
266 */
267 GLOBAL T_ACI_RETURN qAT_PlusCPBS ( T_ACI_CMD_SRC srcId,
268 T_ACI_PB_STOR* storage,
269 SHORT* used,
270 SHORT* total )
271 {
272 TRACE_FUNCTION ("qAT_PlusCPBS ()");
273
274 return(cmh_QueryCPBS(srcId,storage,used,total,NULL));
275 }
276
277 /*
278 +--------------------------------------------------------------------+
279 | PROJECT : GSM-PS (6147) MODULE : CMH_PHBQ |
280 | STATE : code ROUTINE : qAT_PercentPBCF |
281 +--------------------------------------------------------------------+
282
283 PURPOSE : This is the functional counterpart to the %PBCF?
284 AT command which returns the current phonebook
285 configuration.
286
287 <ldn>: last dialed number configuration.
288 <lrn>: last received number configuration.
289 */
290 GLOBAL T_ACI_RETURN qAT_PercentPBCF( T_ACI_CMD_SRC srcId,
291 T_ACI_PBCF_LDN *ldn,
292 T_ACI_PBCF_LRN *lrn,
293 T_ACI_PBCF_LMN *lmn )
294 {
295
296 TRACE_FUNCTION ("qAT_PercentPBCF ()");
297
298 /*
299 *-----------------------------------------------------------------
300 * fill in parameters
301 *-----------------------------------------------------------------
302 */
303 *ldn = PBCFldn;
304 *lrn = PBCFlrn;
305 *lmn = PBCFlmn;
306
307 return ( AT_CMPL );
308 }
309
310 /*
311 +--------------------------------------------------------------------+
312 | PROJECT : GSM-PS (6147) MODULE : CMH_CCQ |
313 | STATE : code ROUTINE : qAT_PlusCSVM |
314 +--------------------------------------------------------------------+
315
316 PURPOSE : This is the functional counterpart to the +CSVM? AT command
317 which returns the current setting of mode, number and type.
318
319 <mode>: Enable or Disable the voice mail number
320 <number>: Number of the voice mail server
321 <num_len>:Number length
322 <toa>: type of address.
323 */
324
325 GLOBAL T_ACI_RETURN qAT_PlusCSVM (T_ACI_CMD_SRC srcId,
326 T_ACI_CSVM_MOD *mode,
327 CHAR *number,
328 UBYTE num_len,
329 SHORT *toa_val)
330
331 {
332 CHAR* ef = EF_VMN_ID;
333 pcm_FileInfo_Type fileInfo;
334 EF_VMN vmn;
335
336 T_PHB_CMD_PRM * pPHBCmdPrm; /* points to PHB command parameter */
337
338 TRACE_FUNCTION ("qAT_PlusCSVM()");
339
340 /*
341 *-------------------------------------------------------------------
342 * check command source
343 *-------------------------------------------------------------------
344 */
345 if(!cmh_IsVldCmdSrc (srcId))
346 {
347 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
348 return( AT_FAIL );
349 }
350
351 pPHBCmdPrm = &cmhPrm[srcId].phbCmdPrm;
352
353 /*
354 *-------------------------------------------------------------------
355 * fill parameter mode
356 *-------------------------------------------------------------------
357 */
358 *mode= pPHBCmdPrm -> CSVMmode;
359
360 /*
361 *-------------------------------------------------------------------
362 * fill in parameters number
363 *-------------------------------------------------------------------
364 */
365
366 if (pcm_GetFileInfo ( ( UBYTE* ) ef, &fileInfo) NEQ PCM_OK)
367 {
368 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_MemFail );
369 return( AT_FAIL );
370 }
371 else
372 {
373 if ( pcm_ReadFile ( ( UBYTE* )ef,fileInfo.FileSize,
374 ( UBYTE*) &vmn,
375 &fileInfo.Version) EQ PCM_OK )
376 {
377 USHORT i = 0;
378 while (i<sizeof(vmn.vmNum))
379 {
380 if ((UBYTE)vmn.vmNum[i] EQ 0xFF)
381 break;
382 i++;
383 }
384
385 if( i>num_len)
386 {
387 TRACE_EVENT("Error: Number buffer is not big enough");
388 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_Unknown );
389 return (AT_FAIL);
390 }
391
392 if(i NEQ 0) /* there is a number on PCM */
393 {
394 memcpy (number, vmn.vmNum, i);
395 *toa_val=(SHORT)vmn.numTp;
396 }
397 else
398 {
399 *toa_val = 145; /* default international, see 07.07 */
400 }
401 if (i<num_len) /* Check if destination is big enough */
402 number[i]='\0';
403 }
404 else
405 {
406 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_MemFail );
407 return( AT_FAIL );
408 }
409 }
410
411 return( AT_CMPL );
412 }
413 /*==== EOF ========================================================*/