comparison gsm-fw/g23m-aci/aci/aci_bat_ss.c @ 775:eedbf248bac0

gsm-fw/g23m-aci subtree: initial import from LoCosto source
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 12 Oct 2014 01:45:14 +0000
parents
children
comparison
equal deleted inserted replaced
774:40a721fd9854 775:eedbf248bac0
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : GSM-F&D (8411)
4 | Modul : ACI_BAT
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 BAT wrapper modul is ...
18 |
19 +-----------------------------------------------------------------------------
20 */
21
22 #include "aci_all.h" /* includes prim.h, which includes p_bat.h */
23 #include "aci_cmh.h"
24 #include "ati_cmd.h"
25 #include "aci_cmd.h" /* prototypes of helper functions */
26 #include "psa.h"
27 #include "cmh.h"
28 #include "aci_bat_cmh.h" /* prototypes of sBAT_,qBAT_,tBAT_ */
29 #include "aci_bat.h"
30 #include "aci_bat_err.h" /*prototypes of err functions for BAT*/
31
32
33 /*
34 +--------------------------------------------------------------------+
35 | PROJECT : GSM-F&D (8411) MODULE : ACI_BAT |
36 | STATE : code ROUTINE : sBAT_PlusCTFR |
37 +--------------------------------------------------------------------+
38
39 PURPOSE :
40 */
41 GLOBAL T_ACI_BAT_RSLT sBAT_PlusCTFR (T_ACI_DTI_PRC_PSI *src_infos_psi,
42 T_BAT_cmd_send *cmd)
43 {
44 T_ACI_BAT_RSLT ret = ACI_BAT_FAIL;
45 T_ACI_TOA type;
46 T_ACI_TOA *p_type;
47 T_ACI_TOS satype;
48 T_ACI_TOS *p_satype;
49 //CHAR *subadr = subBuf;
50 char subBuf[MAX_SUBADDR_LEN]={0};
51 char* p_subBuf;
52 SHORT toa_oct = 0;
53 SHORT tos_oct = 0;
54 CHAR numBuf[MAX_B_SUBSCR_NUM_LEN];
55
56 TRACE_FUNCTION ("sBAT_PlusCTFR()");
57
58 p_type = &type;
59 p_satype = &satype;
60 p_subBuf = subBuf;
61 memset( numBuf, 0, sizeof(numBuf));
62
63 memcpy(numBuf,cmd->params.ptr_set_plus_ctfr->number,cmd->params.ptr_set_plus_ctfr->c_number);
64
65 if ( cmd->params.ptr_set_plus_ctfr->type EQ (S16)BAT_PARAMETER_NOT_PRESENT )
66 {
67 p_type = NULL;
68 }
69 else
70 {
71 toa_oct = cmd->params.ptr_set_plus_ctfr->type;
72 }
73 if ( cmd->params.ptr_set_plus_ctfr->satype EQ (S16)BAT_PARAMETER_NOT_PRESENT )
74 {
75 p_satype = NULL;
76 }
77 else
78 {
79 tos_oct = cmd->params.ptr_set_plus_ctfr->satype;
80 }
81 /* Type Of Address present */
82 type = toa_demerge (toa_oct);
83 if (type.ton < 0 OR type.npi < 0)
84 {
85 ACI_ERR_DESC(ACI_ERR_CLASS_Cme,CME_ERR_OpNotAllow);
86 return (ACI_BAT_FAIL);
87 }
88 satype = tos_demerge (tos_oct);
89 if (satype.tos < 0 OR satype.oe < 0)
90 {
91 ACI_ERR_DESC(ACI_ERR_CLASS_Cme,CME_ERR_OpNotAllow);
92 return (ACI_BAT_FAIL);
93 }
94
95 if(cmd->params.ptr_set_plus_ctfr->v_subaddr)
96 {
97 memcpy(subBuf,cmd->params.ptr_set_plus_ctfr->subaddr,cmd->params.ptr_set_plus_ctfr->c_subaddr);
98 }
99 else
100 {
101 p_subBuf = NULL;
102 }
103 ret = (T_ACI_BAT_RSLT)sAT_PlusCTFR ((T_ACI_CMD_SRC)src_infos_psi->srcId, numBuf, p_type, p_subBuf, p_satype);
104 return(ret);
105 }
106
107 /*
108 +--------------------------------------------------------------------+
109 | PROJECT : GSM-F&D (8411) MODULE : ACI_BAT |
110 | STATE : code ROUTINE : sBAT_PlusCCFC |
111 +--------------------------------------------------------------------+
112
113 PURPOSE :
114 */
115 GLOBAL T_ACI_BAT_RSLT sBAT_PlusCCFC (T_ACI_DTI_PRC_PSI *src_infos_psi,
116 T_BAT_cmd_send *cmd)
117 {
118 T_ACI_BAT_RSLT ret = ACI_BAT_FAIL;
119 T_BAT_plus_ccfc_reason reason;
120 T_BAT_plus_ccfc_mode mode;
121 T_ACI_TOA type;
122 T_ACI_TOA *p_type;
123 T_ACI_TOS satype;
124 T_ACI_TOS *p_satype;
125 T_BAT_plus_ccfc_bearer_class class_type=BAT_CCFC_CLASS_NOT_PRESENT;
126 //CHAR *subadr = subBuf;
127 char subBuf[MAX_SUBADDR_LEN]={0};
128 char* p_subBuf;
129 T_BAT_plus_ccfc_time time=BAT_CCFC_TIME_NOT_PRESENT;
130 SHORT toa_oct=0;
131 SHORT tos_oct=0;
132 CHAR numBuf[MAX_B_SUBSCR_NUM_LEN];
133 CHAR* p_numBuf;
134
135 TRACE_FUNCTION ("sBAT_PlusCCFC()");
136
137 p_type=&type;
138 p_satype=&satype;
139 p_subBuf = subBuf;
140 p_numBuf = numBuf;
141 memset( numBuf, 0, sizeof(numBuf));
142
143 reason = cmd->params.ptr_set_plus_ccfc->reason;
144 mode = cmd->params.ptr_set_plus_ccfc->mode;
145 toa_oct = cmd->params.ptr_set_plus_ccfc->type;
146 tos_oct = cmd->params.ptr_set_plus_ccfc->satype;
147 class_type = cmd->params.ptr_set_plus_ccfc->bearer_class;
148 time = cmd->params.ptr_set_plus_ccfc->time;
149
150 if (mode EQ BAT_CCFC_MODE_QUERY) /*query mode*/
151 {
152 ret = (T_ACI_BAT_RSLT)qAT_PlusCCFC((T_ACI_CMD_SRC)src_infos_psi->srcId,
153 (T_ACI_CCFC_RSN)reason,(T_ACI_CLASS)class_type);
154 switch ((T_ACI_RETURN)ret)
155 {
156 case AT_EXCT:
157 case AT_BUSY:
158 case AT_FAIL:
159 {
160 return ret;
161 }
162 default:
163 {
164 return (ACI_BAT_FAIL);
165 }
166 }
167 }
168 if(cmd->params.ptr_set_plus_ccfc->v_subaddr)
169 {
170 memcpy(subBuf,cmd->params.ptr_set_plus_ccfc->subaddr,cmd->params.ptr_set_plus_ccfc->c_subaddr);
171 }
172 else
173 {
174 p_subBuf = NULL;
175 }
176
177 if ( cmd->params.ptr_set_plus_ccfc->type EQ (S16)BAT_PARAMETER_NOT_PRESENT )
178 {
179 p_type = NULL;
180 }
181 else
182 {
183 toa_oct = cmd->params.ptr_set_plus_ccfc->type;
184 }
185
186 if ( cmd->params.ptr_set_plus_ccfc->satype EQ (S16)BAT_PARAMETER_NOT_PRESENT )
187 {
188 p_satype = NULL;
189 }
190 else
191 {
192 tos_oct = cmd->params.ptr_set_plus_ccfc->satype;
193 }
194 /* Type Of Address present */
195 type = toa_demerge (toa_oct);
196 if (type.ton < 0 OR type.npi < 0)
197 {
198 ACI_ERR_DESC(ACI_ERR_CLASS_Cme,CME_ERR_OpNotAllow);
199 return (ACI_BAT_FAIL);
200 }
201
202 satype = tos_demerge (tos_oct);
203 if (satype.tos < 0 OR satype.oe < 0)
204 {
205 ACI_ERR_DESC(ACI_ERR_CLASS_Cme,CME_ERR_OpNotAllow);
206 return (ACI_BAT_FAIL);
207 }
208
209 if(cmd->params.ptr_set_plus_ccfc->v_number)
210 {
211 memcpy(numBuf,cmd->params.ptr_set_plus_ccfc->number,cmd->params.ptr_set_plus_ccfc->c_number);
212 }
213 else
214 {
215 p_numBuf = NULL;
216 }
217 ret = (T_ACI_BAT_RSLT)sAT_PlusCCFC((T_ACI_CMD_SRC)src_infos_psi->srcId,(T_ACI_CCFC_RSN)reason,
218 (T_ACI_CCFC_MOD)mode,p_numBuf,p_type,(T_ACI_CLASS)class_type,p_subBuf,p_satype,time);
219 return(ret);
220 }
221
222 /*
223 +--------------------------------------------------------------------+
224 | PROJECT : GSM-F&D (8411) MODULE : ACI_BAT |
225 | STATE : code ROUTINE : sBAT_PlusCLCK |
226 +--------------------------------------------------------------------+
227
228 PURPOSE :
229 */
230 GLOBAL T_ACI_BAT_RSLT sBAT_PlusCLCK (T_ACI_DTI_PRC_PSI *src_infos_psi,
231 T_BAT_cmd_send *cmd)
232 {
233 T_ACI_BAT_RSLT ret = ACI_BAT_FAIL;
234 T_BAT_plus_clck_fac fac_num;
235 T_BAT_plus_clck_mode mod;
236 T_BAT_bearer_class class_type = BAT_CLASS_NOT_PRESENT;
237 T_BAT_cmd_response resp;
238 T_ACI_CLSSTAT clsStat;
239 char passwd[MAX_PWD_LENGTH]={0};
240
241 TRACE_FUNCTION ("sBAT_PlusCLCK()");
242
243 fac_num = cmd->params.ptr_set_plus_clck->fac;
244 mod = cmd->params.ptr_set_plus_clck->mode;
245 class_type = cmd->params.ptr_set_plus_clck->bearer_class;
246
247
248 if (mod EQ BAT_CLCK_MODE_QUERY) /*query mode*/
249 {
250 T_BAT_res_set_plus_clck clck;
251 ret=(T_ACI_BAT_RSLT)qAT_PlusCLCK((T_ACI_CMD_SRC)src_infos_psi->srcId,(T_ACI_FAC)fac_num,
252 (T_ACI_CLASS)class_type,&clsStat);
253 resp.ctrl_response = BAT_RES_SET_PLUS_CLCK;
254 resp.response.ptr_set_plus_clck = &clck;
255 resp.response.ptr_set_plus_clck->status = BAT_CLCK_STATUS_NOT_ACTIVE ;
256 resp.response.ptr_set_plus_clck->bearer_class = BAT_CLASS_NOT_PRESENT;
257
258 if(ret EQ ACI_BAT_CMPL)
259 {
260 switch(clsStat.status)
261 {
262 case STATUS_Active:
263 resp.response.ptr_set_plus_clck->status = BAT_CLCK_STATUS_ACTIVE;
264 break;
265 case STATUS_NotActive:
266 resp.response.ptr_set_plus_clck->status = BAT_CLCK_STATUS_NOT_ACTIVE;
267 break;
268 }
269
270 if(clsStat.class_type NEQ CLASS_NotPresent)
271 {
272 resp.response.ptr_set_plus_clck->bearer_class = (T_BAT_bearer_class)clsStat.class_type;
273 }
274 aci_bat_send(src_infos_psi , &resp);
275 return (ACI_BAT_CMPL);
276 }
277 }
278 else /*set mode*/
279 {
280 if(cmd->params.ptr_set_plus_clck->v_passwd)
281 {
282 memcpy(passwd,cmd->params.ptr_set_plus_clck->passwd,cmd->params.ptr_set_plus_clck->c_passwd);
283 }
284 ret = (T_ACI_BAT_RSLT)sAT_PlusCLCK((T_ACI_CMD_SRC)src_infos_psi->srcId,
285 (T_ACI_FAC)fac_num,(T_ACI_CLCK_MOD)mod,passwd,(T_ACI_CLASS)class_type);
286 }
287
288 switch((T_ACI_RETURN)ret)
289 {
290 case AT_EXCT:
291 case AT_FAIL:
292 {
293 break;
294 }
295 case(AT_BUSY):
296 {
297 TRACE_EVENT("sBAT_PlusCLCK(): ME is busy");
298 break;
299 }
300 }
301 return(ret);
302 }
303
304 /*
305 +--------------------------------------------------------------------+
306 | PROJECT : GSM-F&D (8411) MODULE : ACI_BAT |
307 | STATE : code ROUTINE : sBAT_PlusCPWD |
308 +--------------------------------------------------------------------+
309
310 PURPOSE :
311 */
312 GLOBAL T_ACI_BAT_RSLT sBAT_PlusCPWD (T_ACI_DTI_PRC_PSI *src_infos_psi,
313 T_BAT_cmd_send *cmd)
314 {
315 T_ACI_BAT_RSLT ret = ACI_BAT_FAIL;
316 T_BAT_plus_cpwd_fac fac_num;
317 CHAR oldpwd[MAX_PWD_LENGTH]={0};
318 CHAR newpwd[MAX_PWD_LENGTH]={0};
319
320 TRACE_FUNCTION ("sBAT_PlusCPWD()");
321
322 fac_num = cmd->params.ptr_set_plus_cpwd->fac;
323 memcpy(oldpwd, cmd->params.ptr_set_plus_cpwd->oldpwd,cmd->params.ptr_set_plus_cpwd->c_oldpwd);
324 memcpy(newpwd, cmd->params.ptr_set_plus_cpwd->newpwd,cmd->params.ptr_set_plus_cpwd->c_newpwd);
325 ret = (T_ACI_BAT_RSLT)sAT_PlusCPWD((T_ACI_CMD_SRC)src_infos_psi->srcId,(T_ACI_FAC)fac_num,oldpwd,newpwd);
326 return(ret);
327 }
328
329 /*
330 +--------------------------------------------------------------------+
331 | PROJECT : GSM-F&D (8411) MODULE : ACI_BAT |
332 | STATE : code ROUTINE : sBAT_PlusCUSD |
333 +--------------------------------------------------------------------+
334
335 PURPOSE :
336 */
337 GLOBAL T_ACI_BAT_RSLT sBAT_PlusCUSD (T_ACI_DTI_PRC_PSI *src_infos_psi,
338 T_BAT_cmd_send *cmd)
339 {
340 T_ACI_BAT_RSLT ret;
341 T_ACI_USSD_DATA ussd;
342 T_ACI_USSD_DATA *ussd_ptr;
343 T_BAT_cmd_set_plus_cusd *cusd;
344
345 TRACE_FUNCTION ("sBAT_PlusCUSD()");
346
347 /*
348 * Get a pointer to the BAT structure for convenience.
349 */
350 cusd=cmd->params.ptr_set_plus_cusd;
351
352 ussd_ptr=NULL;
353
354 if (cusd->v_str)
355 {
356 USHORT len;
357
358 utl_ussdDtaFromTe (
359 (UBYTE*)cusd->str,
360 cusd->c_str,
361 (UBYTE*)ussd.data,
362 &len,
363 #ifdef REL99
364 sizeof(ussd.data),
365 #endif /* REL99 */
366 (UBYTE)cusd->dcs);
367
368 if (len>MAX_USSD_LEN)
369 {
370 /*
371 * The USSD string is too big for the ACI structure. This should
372 * not happen, and if it does means that we have overwritten
373 * memory.
374 */
375 ACI_ERR_DESC(ACI_ERR_CLASS_Cme,CME_ERR_TxtToLong);
376 return(ACI_BAT_FAIL);
377 }
378
379 ussd.len=(UBYTE)len;
380 ussd_ptr=&ussd;
381 }
382
383 /*
384 * Call the corresponding sAT function. T_ACI_BAT_RSLT is
385 * assumed to be equivalent to T_ACI_RESULT.
386 */
387 ret=(T_ACI_BAT_RSLT)sAT_PlusCUSD(
388 (T_ACI_CMD_SRC)src_infos_psi->srcId,
389 ussd_ptr,
390 (SHORT)cusd->dcs);
391
392 return(ret);
393 }
394
395 #ifdef SIM_PERS
396 /*
397 +--------------------------------------------------------------------+
398 | PROJECT : GSM-F&D (8411) MODULE : ACI_BAT |
399 | STATE : code ROUTINE : sBAT_PercentMEPD |
400 +--------------------------------------------------------------------+
401
402 PURPOSE : Mobile Equipment Personalization Data (SIM LOCK)
403 The set command has query semantic
404 */
405
406 GLOBAL T_ACI_BAT_RSLT sBAT_PercentMEPD (T_ACI_DTI_PRC_PSI *src_infos_psi,
407 T_BAT_cmd_send *cmd)
408 {
409 T_ACI_RETURN ret;
410 T_SUP_INFO sup_info;
411
412 TRACE_FUNCTION("sBAT_PercentMEPD()");
413
414 memset(&sup_info, 0, sizeof(T_SUP_INFO));
415 sup_info.infoType =(T_SUP_INFO_TYPE)cmd->params.ptr_set_percent_mepd->sup_info_type;
416
417 ret = qAT_PercentMEPD((T_ACI_CMD_SRC)src_infos_psi->srcId, &sup_info);
418
419 if (ret EQ AT_CMPL)
420 {
421 T_BAT_cmd_response resp;
422 T_BAT_res_set_percent_mepd mepd;
423
424 resp.ctrl_response = BAT_RES_SET_PERCENT_MEPD;
425 resp.response.ptr_set_percent_mepd = &mepd;
426 mepd.datavalue = sup_info.datavalue;
427
428 aci_bat_send(src_infos_psi, &resp);
429 return(ACI_BAT_CMPL);
430 }
431
432 return((T_ACI_BAT_RSLT)ret);
433 }
434 #endif /* SIM_PERS */