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