FreeCalypso > hg > freecalypso-citrine
comparison g23m-aci/aci/cphs_aci.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: $Workfile:: cphs_aci.c $| | |
4 | $Author:: $Revision:: $| | |
5 | CREATED: $Modtime:: $| | |
6 | STATE : code | | |
7 +--------------------------------------------------------------------+ | |
8 | |
9 MODULE : CPHS | |
10 | |
11 PURPOSE : This module contains the functions adapting CPHS module to ACI. | |
12 */ | |
13 | |
14 #ifndef CPHS_ACI_C | |
15 #define CPHS_ACI_C | |
16 | |
17 #include "config.h" | |
18 #include "fixedconf.h" | |
19 #include "condat-features.h" | |
20 #include "aci_conf.h" | |
21 | |
22 #include "aci_all.h" | |
23 | |
24 #include "cphs.h" | |
25 | |
26 #include "aci_cmh.h" | |
27 #include "psa.h" | |
28 #include "cmh.h" | |
29 | |
30 #include "psa_util.h" | |
31 #include "psa_sim.h" /* cos' of simShrdPrm !!! */ | |
32 | |
33 #include "cmh_cc.h" | |
34 #include "psa_cc.h" | |
35 | |
36 static UBYTE last_sim_operation; | |
37 | |
38 /* ACI/CPHS adapt layer... Only part of the CPHS where cmh calls are allowed */ | |
39 GLOBAL void cphs_aci_sim_access_cb(SHORT sim_shrd_id) | |
40 { | |
41 BOOL sim_failure = FALSE; | |
42 T_ACI_CME_ERR err; | |
43 | |
44 TRACE_FUNCTION("cphs_aci_sim_access_cb()"); | |
45 | |
46 if( simShrdPrm.atb[sim_shrd_id].errCode NEQ SIM_NO_ERROR ) | |
47 { | |
48 sim_failure = TRUE; | |
49 } | |
50 | |
51 switch(last_sim_operation) | |
52 { | |
53 case(CPHS_SIM_READ_TRANSP_EF): | |
54 case(CPHS_SIM_READ_RECORD): | |
55 if(simShrdPrm.atb[sim_shrd_id].dataLen <= 0) | |
56 { | |
57 sim_failure = TRUE; | |
58 } | |
59 break; | |
60 } | |
61 | |
62 /* free sim table entry */ | |
63 simShrdPrm.atb[sim_shrd_id].ntryUsdFlg = FALSE; | |
64 | |
65 if(sim_failure) | |
66 { | |
67 /* an error occured !!! */ | |
68 TRACE_EVENT("SIM Access Error !!!"); | |
69 err = (T_ACI_CME_ERR)cmhSIM_GetCmeFromSim(simShrdPrm.atb[sim_shrd_id].errCode); | |
70 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, err); | |
71 cphs_sim_data_failure(); | |
72 return; | |
73 } | |
74 | |
75 cphs_sim_data_accessed(simShrdPrm.atb[sim_shrd_id].recMax, | |
76 simShrdPrm.atb[sim_shrd_id].dataLen); | |
77 | |
78 } | |
79 | |
80 GLOBAL void cphs_sim_access_data(UBYTE cphs_sim_operation, | |
81 UBYTE cphs_sim_field, | |
82 UBYTE record, | |
83 UBYTE *data_buffer, | |
84 UBYTE data_buffer_size) | |
85 { | |
86 USHORT sim_field_id = 0; | |
87 | |
88 TRACE_FUNCTION("cphs_sim_access_data()"); | |
89 | |
90 /* The CPHS files are located under GSM standard DFs, therefore | |
91 * it is not possible that their identifier values conflict with | |
92 * standard values within the same DF. SIM code has incorporated | |
93 * the CPHS spec so that we are able to find these files without | |
94 * path information. We cannot totally rule out the possibility | |
95 * that future versions of 3GPP 51.011 (GSM 11.11) create file | |
96 * identifiers in DF(TELECOM), which are the same as CPHS identifiers | |
97 * in DF(GSM) or vice versa, but this is very unlikely, | |
98 * because CPHS is widely known and used by various operators | |
99 * in contrast to HOMEZONE, which is specific to one operator. */ | |
100 | |
101 switch(cphs_sim_field) | |
102 { | |
103 case(CPHS_SIM_CFU): | |
104 TRACE_EVENT("CPHS Access sim field: SIM_CPHS_CFF"); | |
105 sim_field_id = SIM_CPHS_CFF; | |
106 break; | |
107 | |
108 case(CPHS_SIM_VWI): | |
109 TRACE_EVENT("CPHS Access sim field: SIM_CPHS_VMW"); | |
110 sim_field_id = SIM_CPHS_VMW; | |
111 break; | |
112 | |
113 case(CPHS_SIM_CINF): | |
114 TRACE_EVENT("CPHS Access sim field: SIM_CPHS_CINF"); | |
115 sim_field_id = SIM_CPHS_CINF; | |
116 break; | |
117 | |
118 case(CPHS_SIM_CSP): | |
119 TRACE_EVENT("CPHS Access sim field: SIM_CPHS_CSP"); | |
120 sim_field_id = SIM_CPHS_CSP; | |
121 break; | |
122 | |
123 case(CPHS_SIM_ORANGE_CSP): | |
124 TRACE_EVENT("CPHS Access sim field: SIM_ORANGE_CSP2"); | |
125 sim_field_id = SIM_ORANGE_CSP2; | |
126 break; | |
127 | |
128 case(CPHS_SIM_OPNLONG): | |
129 TRACE_EVENT("CPHS Access sim field: SIM_CPHS_ONSTR"); | |
130 sim_field_id = SIM_CPHS_ONSTR; | |
131 break; | |
132 | |
133 case(CPHS_SIM_OPNSHORT): | |
134 TRACE_EVENT("CPHS Access sim field: SIM_CPHS_ONSHF"); | |
135 sim_field_id = SIM_CPHS_ONSHF; | |
136 break; | |
137 | |
138 case(CPHS_SIM_MB): | |
139 TRACE_EVENT("CPHS Access sim field: SIM_CPHS_MBXN"); | |
140 sim_field_id = SIM_CPHS_MBXN; | |
141 break; | |
142 | |
143 case(CPHS_SIM_INFO_NUMS): | |
144 TRACE_EVENT("CPHS Access sim field: SIM_CPHS_INFN"); | |
145 sim_field_id = SIM_CPHS_INFN; | |
146 break; | |
147 | |
148 case(CPHS_SIM_INFO_NUMS_EA01): /* in case of old sims */ | |
149 TRACE_EVENT("CPHS Access sim field: SIM_CPHS_INFN2"); | |
150 sim_field_id = SIM_CPHS_INFN2; | |
151 break; | |
152 | |
153 case(CPHS_SIM_ALSNAMES): | |
154 TRACE_EVENT("CPHS Access sim field: SIM_MSISDN"); | |
155 sim_field_id = SIM_MSISDN; | |
156 break; | |
157 | |
158 default: | |
159 TRACE_ERROR("cphs_sim_access_data(): wrong cphs_sim_field value !!!"); | |
160 break; | |
161 } | |
162 | |
163 last_sim_operation = cphs_sim_operation; | |
164 | |
165 switch(cphs_sim_operation) | |
166 { | |
167 case(CPHS_SIM_READ_TRANSP_EF): | |
168 cmhSIM_ReadTranspEF( CMD_SRC_NONE, | |
169 AT_CMD_NONE, | |
170 FALSE, | |
171 NULL, | |
172 sim_field_id, | |
173 0, | |
174 data_buffer_size, | |
175 data_buffer, | |
176 cphs_aci_sim_access_cb ); | |
177 break; | |
178 | |
179 case(CPHS_SIM_WRITE_TRANSP_EF): | |
180 cmhSIM_WriteTranspEF(CMD_SRC_NONE, | |
181 AT_CMD_NONE, | |
182 FALSE, | |
183 NULL, | |
184 sim_field_id, | |
185 0, | |
186 data_buffer_size, | |
187 data_buffer, | |
188 cphs_aci_sim_access_cb ); | |
189 break; | |
190 | |
191 case(CPHS_SIM_READ_RECORD): | |
192 cmhSIM_ReadRecordEF( CMD_SRC_NONE, | |
193 AT_CMD_CPHS, | |
194 FALSE, | |
195 NULL, | |
196 sim_field_id, | |
197 record, | |
198 data_buffer_size, | |
199 data_buffer, | |
200 cphs_aci_sim_access_cb ); | |
201 break; | |
202 | |
203 case(CPHS_SIM_WRITE_RECORD): | |
204 cmhSIM_WriteRecordEF( CMD_SRC_NONE, | |
205 AT_CMD_CPHS, | |
206 FALSE, | |
207 NULL, | |
208 sim_field_id, | |
209 record, | |
210 data_buffer_size, | |
211 data_buffer, | |
212 cphs_aci_sim_access_cb ); | |
213 break; | |
214 | |
215 default: | |
216 TRACE_ERROR("cphs_sim_access_data(): wrong cphs_sim_operation value !!!"); | |
217 break; | |
218 } | |
219 | |
220 } | |
221 | |
222 /* converts a BCD number bcd of bcd_size length | |
223 into a string of ascii digits and writes the result in number */ | |
224 GLOBAL void cphs_bcd2number(CHAR *number, | |
225 UBYTE *bcd, | |
226 UBYTE bcd_size) | |
227 { | |
228 int i; | |
229 UBYTE *num_buffer; | |
230 | |
231 TRACE_FUNCTION("cphs_bcd2number()"); | |
232 | |
233 MALLOC(num_buffer, 2*bcd_size); | |
234 | |
235 /* Decode BCD */ | |
236 for(i=0;i<bcd_size;i++) | |
237 { | |
238 num_buffer[2*i] = (bcd[i] & 0x0F); | |
239 num_buffer[2*i + 1] = (bcd[i] & 0xF0)>>4; | |
240 } | |
241 | |
242 utl_BCD2DialStr((const UBYTE *)num_buffer, number, (UBYTE)(2*bcd_size)); | |
243 | |
244 MFREE(num_buffer); | |
245 } | |
246 | |
247 GLOBAL T_CPHS_RET cphs_get_als_active_line(UBYTE srcId, T_CPHS_LINES *line) | |
248 { | |
249 T_ACI_ALS_MOD ALSmode; | |
250 | |
251 TRACE_FUNCTION("cphs_get_als_active_line()"); | |
252 | |
253 cmhCC_get_active_als_mode((T_ACI_CMD_SRC)srcId, &ALSmode ); | |
254 | |
255 switch( ALSmode ) | |
256 { | |
257 case(ALS_MOD_SPEECH): | |
258 *line = CPHS_LINE1; | |
259 break; | |
260 | |
261 case(ALS_MOD_AUX_SPEECH): | |
262 *line = CPHS_LINE2; | |
263 break; | |
264 | |
265 case(ALS_MOD_NOTPRESENT): | |
266 default: | |
267 *line = CPHS_LINE_NULL; | |
268 break; | |
269 } | |
270 | |
271 return(CPHS_OK); | |
272 } | |
273 | |
274 | |
275 /* if( ! psaSIM_ChkSIMSrvSup( SRV_MSISDN )) return( AT_CMPL ); */ | |
276 | |
277 | |
278 GLOBAL T_CPHS_LINES als_get_call_info(SHORT call_id) | |
279 { | |
280 T_CC_CALL_TBL *ctb; /* Pointer to call table entry */ | |
281 SHORT cId = call_id-1; /* tarnslation from +CLCC-like call_id and ACI cId */ | |
282 T_ACI_CRING_SERV_TYP cring_type; /* type of bearer of call */ | |
283 | |
284 TRACE_FUNCTION("als_get_call_info()"); | |
285 | |
286 /* ==== if the CPHS module is to be ported, then AT+CLCC shall be used... | |
287 Extra info might need to be added to differentiate AuxVoice from Voice... ==== | |
288 MALLOC(calLst, MAX_CALL_NR * sizeof(T_ACI_CLCC_CALDESC)); | |
289 if(qAT_PlusCLCC(srcId, calLst) NEQ AT_CMPL) | |
290 { | |
291 TRACE_ERROR("+CLCC: error"); | |
292 return(CPHS_FAIL); | |
293 }*/ | |
294 | |
295 if (!psaCC_ctbIsValid (cId)) | |
296 { | |
297 /* Call is not active ! */ | |
298 return(CPHS_LINE_NULL); | |
299 } | |
300 | |
301 ctb = ccShrdPrm.ctb[cId]; | |
302 | |
303 switch(cmhCC_getcalltype(cId)) | |
304 { | |
305 case(VOICE_CALL): | |
306 cring_type = (T_ACI_CRING_SERV_TYP)cmhCC_GetCallType_from_bearer (&ctb->BC[ctb->curBC]); | |
307 if(cring_type EQ CRING_SERV_TYP_Voice) | |
308 { | |
309 return(CPHS_LINE1); | |
310 } | |
311 else if(cring_type EQ CRING_SERV_TYP_AuxVoice) | |
312 { | |
313 return(CPHS_LINE2); | |
314 } | |
315 break; | |
316 #ifdef FAX_AND_DATA | |
317 case( TRANS_CALL ): | |
318 case( NON_TRANS_CALL ): | |
319 return(CPHS_LINE_DATA); | |
320 | |
321 case( FAX_CALL ): | |
322 return(CPHS_LINE_FAX); | |
323 #endif | |
324 } | |
325 | |
326 /* MFREE(calLst); */ | |
327 return(CPHS_LINE_NULL); | |
328 } | |
329 | |
330 void cphs_sim_read_mb_ext_rcd_cb(SHORT table_id) | |
331 { | |
332 BOOL sim_failure = FALSE; | |
333 T_ACI_CME_ERR err; | |
334 | |
335 if( simShrdPrm.atb[table_id].errCode NEQ SIM_NO_ERROR ) | |
336 { | |
337 sim_failure = TRUE; | |
338 } | |
339 | |
340 switch(last_sim_operation) | |
341 { | |
342 case(CPHS_SIM_READ_TRANSP_EF): | |
343 case(CPHS_SIM_READ_RECORD): | |
344 if(simShrdPrm.atb[table_id].dataLen <= 0) | |
345 { | |
346 sim_failure = TRUE; | |
347 } | |
348 break; | |
349 } | |
350 | |
351 /* free sim table entry */ | |
352 simShrdPrm.atb[table_id].ntryUsdFlg = FALSE; | |
353 | |
354 if(sim_failure) | |
355 { | |
356 /* an error occured !!! */ | |
357 TRACE_EVENT("SIM Access Error !!!"); | |
358 err = (T_ACI_CME_ERR)cmhSIM_GetCmeFromSim(simShrdPrm.atb[table_id].errCode); | |
359 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, err); | |
360 cphs_sim_data_failure(); | |
361 return; | |
362 } | |
363 | |
364 | |
365 cphs_write_sim_mb_ext_data(simShrdPrm.atb[table_id].dataLen); | |
366 | |
367 } | |
368 | |
369 #define DEFAULT_MAXSIZE_OF_RECORD (100) | |
370 GLOBAL void cphs_sim_read_mb_ext_rcd(UBYTE record,UBYTE *data_buffer) | |
371 { | |
372 | |
373 cmhSIM_ReadRecordEF ( CMD_SRC_NONE, | |
374 AT_CMD_NONE, | |
375 FALSE, | |
376 NULL, | |
377 SIM_EXT1, | |
378 record, | |
379 DEFAULT_MAXSIZE_OF_RECORD, | |
380 data_buffer, | |
381 cphs_sim_read_mb_ext_rcd_cb); | |
382 | |
383 | |
384 } | |
385 | |
386 | |
387 | |
388 #endif /* CPHS_ACI_C */ | |
389 |