comparison src/aci2/aci/cphs_aci.c @ 3:93999a60b835

src/aci2, src/condat2: import of g23m/condat source pieces from TCS211
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 26 Sep 2016 00:29:36 +0000
parents
children
comparison
equal deleted inserted replaced
2:c41a534f33c6 3:93999a60b835
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 #ifdef FF_CPHS
15
16 #ifndef CPHS_ACI_C
17 #define CPHS_ACI_C
18
19 #include "aci_all.h"
20
21 #include "cphs.h"
22
23 #include "aci_cmh.h"
24 #include "psa.h"
25 #include "cmh.h"
26
27 #include "psa_util.h"
28 #include "psa_sim.h" /* cos' of simShrdPrm !!! */
29
30 #include "cmh_cc.h"
31 #include "psa_cc.h"
32
33 static UBYTE last_sim_operation;
34
35 /* ACI/CPHS adapt layer... Only part of the CPHS where cmh calls are allowed */
36 GLOBAL void cphs_aci_sim_access_cb(SHORT sim_shrd_id)
37 {
38 BOOL sim_failure = FALSE;
39 T_ACI_CME_ERR err;
40
41 TRACE_FUNCTION("cphs_aci_sim_access_cb()");
42
43 if( simShrdPrm.atb[sim_shrd_id].errCode NEQ SIM_NO_ERROR )
44 {
45 sim_failure = TRUE;
46 }
47
48 switch(last_sim_operation)
49 {
50 case(CPHS_SIM_READ_TRANSP_EF):
51 case(CPHS_SIM_READ_RECORD):
52 if(simShrdPrm.atb[sim_shrd_id].dataLen <= 0)
53 {
54 sim_failure = TRUE;
55 }
56 break;
57 }
58
59 /* free sim table entry */
60 simShrdPrm.atb[sim_shrd_id].ntryUsdFlg = FALSE;
61
62 if(sim_failure)
63 {
64 /* an error occured !!! */
65 TRACE_EVENT("SIM Access Error !!!");
66 err = cmhSIM_GetCmeFromSim(simShrdPrm.atb[sim_shrd_id].errCode);
67 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, err);
68 cphs_sim_data_failure();
69 return;
70 }
71
72 cphs_sim_data_accessed(simShrdPrm.atb[sim_shrd_id].recMax,
73 simShrdPrm.atb[sim_shrd_id].dataLen);
74
75 }
76
77 GLOBAL void cphs_sim_access_data(UBYTE cphs_sim_operation,
78 UBYTE cphs_sim_field,
79 UBYTE record,
80 UBYTE *data_buffer,
81 UBYTE data_buffer_size)
82 {
83 USHORT sim_field_id = 0;
84
85 TRACE_FUNCTION("cphs_sim_access_data()");
86
87 switch(cphs_sim_field)
88 {
89 case(CPHS_SIM_CFU):
90 TRACE_EVENT("CPHS Access sim field: SIM_CPHS_CFF");
91 sim_field_id = SIM_CPHS_CFF;
92 break;
93
94 case(CPHS_SIM_VWI):
95 TRACE_EVENT("CPHS Access sim field: SIM_CPHS_VMW");
96 sim_field_id = SIM_CPHS_VMW;
97 break;
98
99 case(CPHS_SIM_CINF):
100 TRACE_EVENT("CPHS Access sim field: SIM_CPHS_CINF");
101 sim_field_id = SIM_CPHS_CINF;
102 break;
103
104 case(CPHS_SIM_CSP):
105 TRACE_EVENT("CPHS Access sim field: SIM_CPHS_CSP");
106 sim_field_id = SIM_CPHS_CSP;
107 break;
108
109 case(CPHS_SIM_ORANGE_CSP):
110 TRACE_EVENT("CPHS Access sim field: SIM_ORANGE_CSP2");
111 sim_field_id = SIM_ORANGE_CSP2;
112 break;
113
114 case(CPHS_SIM_OPNLONG):
115 TRACE_EVENT("CPHS Access sim field: SIM_CPHS_ONSTR");
116 sim_field_id = SIM_CPHS_ONSTR;
117 break;
118
119 case(CPHS_SIM_OPNSHORT):
120 TRACE_EVENT("CPHS Access sim field: SIM_CPHS_ONSHF");
121 sim_field_id = SIM_CPHS_ONSHF;
122 break;
123
124 case(CPHS_SIM_MB):
125 TRACE_EVENT("CPHS Access sim field: SIM_CPHS_MBXN");
126 sim_field_id = SIM_CPHS_MBXN;
127 break;
128
129 case(CPHS_SIM_INFO_NUMS):
130 TRACE_EVENT("CPHS Access sim field: SIM_CPHS_INFN");
131 sim_field_id = SIM_CPHS_INFN;
132 break;
133
134 case(CPHS_SIM_INFO_NUMS_EA01): /* in case of old sims */
135 TRACE_EVENT("CPHS Access sim field: SIM_CPHS_INFN2");
136 sim_field_id = SIM_CPHS_INFN2;
137 break;
138
139 case(CPHS_SIM_ALSNAMES):
140 TRACE_EVENT("CPHS Access sim field: SIM_MSISDN");
141 sim_field_id = SIM_MSISDN;
142 break;
143
144 default:
145 TRACE_ERROR("cphs_sim_access_data(): wrong cphs_sim_field value !!!");
146 break;
147 }
148
149 last_sim_operation = cphs_sim_operation;
150
151 switch(cphs_sim_operation)
152 {
153 case(CPHS_SIM_READ_TRANSP_EF):
154 cmhSIM_ReadTranspEF( CMD_SRC_NONE,
155 AT_CMD_NONE,
156 sim_field_id,
157 0,
158 data_buffer_size,
159 data_buffer,
160 cphs_aci_sim_access_cb );
161 break;
162
163 case(CPHS_SIM_WRITE_TRANSP_EF):
164 cmhSIM_WriteTranspEF(CMD_SRC_NONE,
165 AT_CMD_NONE,
166 sim_field_id,
167 0,
168 data_buffer_size,
169 data_buffer,
170 cphs_aci_sim_access_cb );
171 break;
172
173 case(CPHS_SIM_READ_RECORD):
174 cmhSIM_ReadRecordEF( CMD_SRC_NONE,
175 AT_CMD_CPHS,
176 sim_field_id,
177 record,
178 data_buffer_size,
179 data_buffer,
180 cphs_aci_sim_access_cb );
181 break;
182
183 case(CPHS_SIM_WRITE_RECORD):
184 cmhSIM_WriteRecordEF( CMD_SRC_NONE,
185 AT_CMD_CPHS,
186 sim_field_id,
187 record,
188 data_buffer_size,
189 data_buffer,
190 cphs_aci_sim_access_cb );
191 break;
192
193 default:
194 TRACE_ERROR("cphs_sim_access_data(): wrong cphs_sim_operation value !!!");
195 break;
196 }
197
198 }
199
200 /* converts a BCD number bcd of bcd_size length
201 into a string of ascii digits and writes the result in number */
202 GLOBAL void cphs_bcd2number(CHAR *number,
203 UBYTE *bcd,
204 UBYTE bcd_size)
205 {
206 int i;
207 UBYTE *num_buffer;
208
209 TRACE_FUNCTION("cphs_bcd2number()");
210
211 MALLOC(num_buffer, 2*bcd_size);
212
213 /* Decode BCD */
214 for(i=0;i<bcd_size;i++)
215 {
216 num_buffer[2*i] = (bcd[i] & 0x0F);
217 num_buffer[2*i + 1] = (bcd[i] & 0xF0)>>4;
218 }
219
220 utl_BCD2DialStr((const UBYTE *)num_buffer, number, (UBYTE)(2*bcd_size));
221
222 MFREE(num_buffer);
223 }
224
225 GLOBAL T_CPHS_RET cphs_get_als_active_line(UBYTE srcId, T_CPHS_LINES *line)
226 {
227 T_ACI_ALS_MOD ALSmode;
228
229 TRACE_FUNCTION("cphs_get_als_active_line()");
230
231 cmhCC_get_active_als_mode(srcId, &ALSmode );
232
233 switch( ALSmode )
234 {
235 case(ALS_MOD_SPEECH):
236 *line = CPHS_LINE1;
237 break;
238
239 case(ALS_MOD_AUX_SPEECH):
240 *line = CPHS_LINE2;
241 break;
242
243 case(ALS_MOD_NOTPRESENT):
244 default:
245 *line = CPHS_LINE_NULL;
246 break;
247 }
248
249 return(CPHS_OK);
250 }
251
252
253 //if( ! psaSIM_ChkSIMSrvSup( SRV_MSISDN )) return( AT_CMPL );
254
255
256 GLOBAL T_CPHS_LINES als_get_call_info(SHORT call_id)
257 {
258 T_CC_CALL_TBL *ctb; /* Pointer to call table entry */
259 SHORT cId = call_id-1; /* tarnslation from +CLCC-like call_id and ACI cId */
260 T_ACI_CRING_TYP cring_type; /* type of bearer of call */
261
262 TRACE_FUNCTION("als_get_call_info()");
263
264 /* ==== if the CPHS module is to be ported, then AT+CLCC shall be used...
265 Extra info might need to be added to differentiate AuxVoice from Voice... ====
266 MALLOC(calLst, MAX_CALL_NR * sizeof(T_ACI_CLCC_CALDESC));
267 if(qAT_PlusCLCC(srcId, calLst) NEQ AT_CMPL)
268 {
269 TRACE_ERROR("+CLCC: error");
270 return(CPHS_FAIL);
271 }*/
272
273 if (!psaCC_ctbIsValid (cId))
274 {
275 /* Call is not active ! */
276 return(CPHS_LINE_NULL);
277 }
278
279 ctb = ccShrdPrm.ctb[cId];
280
281 switch(cmhCC_getcalltype(cId))
282 {
283 case(VOICE_CALL):
284 cring_type = cmhCC_GetCallType_from_bearer (&ctb->BC[ctb->curBC]);
285 if(cring_type EQ CRING_TYP_Voice)
286 {
287 return(CPHS_LINE1);
288 }
289 else if(cring_type EQ CRING_TYP_AuxVoice)
290 {
291 return(CPHS_LINE2);
292 }
293 break;
294 #ifdef FAX_AND_DATA
295 case( TRANS_CALL ):
296 case( NON_TRANS_CALL ):
297 return(CPHS_LINE_DATA);
298
299 case( FAX_CALL ):
300 return(CPHS_LINE_FAX);
301 #endif
302 }
303
304 // MFREE(calLst);
305 return(CPHS_LINE_NULL);
306 }
307
308 #endif /* CPHS_ACI_C */
309 #endif /* FF_CPHS */