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