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