comparison g23m-aci/aci/ati_dti.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: GSM-F&D (8411) $Workfile:: ati_dti.c $|
4 | $Author:: Rm $Revision:: 187 $|
5 | CREATED: 13.11.02 $Modtime:: $|
6 | STATE : code |
7 +--------------------------------------------------------------------+
8
9 MODULE : ATI
10
11 PURPOSE : AT Command to control data flow and devices in addition with DTI
12 managment
13 */
14
15 #include "config.h"
16 #include "fixedconf.h"
17 #include "condat-features.h"
18 #include "aci_conf.h"
19
20 #ifdef DTI
21
22 #ifndef ATI_DTI_C
23 #define ATI_DTI_C
24
25 #include "aci_all.h"
26
27 #include "aci_cmh.h"
28 #include "ati_cmd.h"
29 #include "aci_io.h"
30 #include "aci_cmd.h"
31 #include "dti.h" /* functionality of the dti library */
32 #include "aci_lst.h"
33 #include "ati_int.h"
34 #include "aci_mem.h"
35 #include "cmh_dti.h"
36 #include "dti_conn_mng.h"
37 #include "dti_cntrl_mng.h"
38
39 #ifdef GPRS
40 #include "gaci_cmh.h"
41 #endif
42
43 #ifdef FF_ATI_BAT
44
45 #include "typedefs.h"
46 #include "gdd.h"
47 #include "bat.h"
48
49 #include "ati_bat.h"
50
51 #endif /* FF_ATI_BAT */
52 /*==== EXPORT ==================================================*/
53 EXTERN CHAR *cmdCmeError ( T_ACI_CME_ERR e );
54 EXTERN CHAR *parse(CHAR *b,CHAR *f, ...);
55
56 /*==== VARIABLE====================================================*/
57
58 const T_CAP_NAME ati_cap_name[] =
59 {
60 {"CMD", DEV_CPBLTY_CMD },
61 {"SER", DEV_CPBLTY_SER },
62 {"PKT", DEV_CPBLTY_PKT },
63 {"CMD,SER", DEV_CPBLTY_CMD_SER },
64 {"CMD,PKT", DEV_CPBLTY_CMD_PKT },
65 {"PKT,SER", DEV_CPBLTY_PKT_SER },
66 {"CMD,PKT,SER", DEV_CPBLTY_CMD_PKT_SER},
67 {"", DEV_CPBLTY_NONE}
68 };
69
70 /*==== CONSTANT====================================================*/
71
72 #define DIO_DEVNO_MASK 0xFF
73
74 /*==============================================================*/
75
76
77
78 /*
79 +--------------------------------------------------------------------+
80 | PROJECT : GSM-F&D (8411) MODULE : |
81 | STATE : code ROUTINE : map_dti_cpblty |
82 +--------------------------------------------------------------------+
83
84 PURPOSE : help function to map the capability values of
85 DTI_CPBLTY_xxx to enum value of T_CAP_ID.
86 With the enum value we get the capability string in ati_cap_name[]
87 For DTI_CPBLTY_xxx see SAP document AAA.doc chapter Capability
88 Dor T_CAP_ID see cmh_dti.h
89 */
90 GLOBAL T_CAP_ID map_dti_cpblty (UBYTE dti_cpblty)
91 {
92 switch (dti_cpblty)
93 {
94 case (DTI_CPBLTY_NO):
95 return (DEV_CPBLTY_NONE);
96
97 case (DTI_CPBLTY_CMD):
98 return (DEV_CPBLTY_CMD);
99
100 case (DTI_CPBLTY_SER):
101 return (DEV_CPBLTY_SER);
102
103 case (DTI_CPBLTY_PKT):
104 return (DEV_CPBLTY_PKT);
105
106 case (DTI_CPBLTY_CMD + DTI_CPBLTY_SER):
107 return (DEV_CPBLTY_CMD_SER);
108
109 case (DTI_CPBLTY_CMD + DTI_CPBLTY_PKT):
110 return (DEV_CPBLTY_CMD_PKT);
111
112 case (DTI_CPBLTY_PKT + DTI_CPBLTY_SER):
113 return (DEV_CPBLTY_PKT_SER);
114
115 case (DTI_CPBLTY_CMD + DTI_CPBLTY_PKT + DTI_CPBLTY_SER):
116 return (DEV_CPBLTY_CMD_PKT_SER);
117
118 default:
119 {
120 TRACE_EVENT_P1("map_dti_cpblty():[ERR] unknown capability value = %d",dti_cpblty);
121 return (DEV_CPBLTY_NONE);
122 }
123 }
124 }
125
126 /*
127 +--------------------------------------------------------------------+
128 | PROJECT : GSM-F&D (8411) MODULE : |
129 | STATE : code ROUTINE : setatPercentDATA |
130 +--------------------------------------------------------------------+
131
132 PURPOSE : set %DATA command ( control data flow )
133 format:
134 %DATA=<mode>,<des_dev_name>,<des_dev_no>,[<sub_no>],<cap>[,<src_dev_name>,<src_dev_no>,[<sub_no>],[,<cid>]]
135 example:
136 %DATA=2,"RIV",1,,"PKT","SNDCP",1,,,
137 means, set a permanent(2) redirection for "RIV" with packet capability to "SNDCP"
138 */
139
140 GLOBAL T_ATI_RSLT setatPercentDATA ( char *cl, UBYTE srcId )
141
142 {
143 CHAR des_dev_name[MAX_SMS_ADDR_DIG]; /* destination device name */
144 CHAR src_dev_name[MAX_SMS_ADDR_DIG]; /* source device name */
145 CHAR dev_cap[MAX_SMS_ADDR_DIG]; /* device capability */
146 UBYTE red_mode = NOT_PRESENT_8BIT; /* redirection mode */
147 UBYTE pdp_cid = NOT_PRESENT_8BIT; /* context cid */
148 U32 des_devId = NOT_PRESENT_32BIT; /* destination device identifier */
149 SHORT des_sub_no = ACI_NumParmNotPresent; /* destination sub number */
150 U32 src_devId = NOT_PRESENT_32BIT; /* source device identifier */
151 SHORT src_sub_no = ACI_NumParmNotPresent; /* source sub number */
152 T_ACI_RETURN ret = AT_FAIL;
153
154 src_dev_name[0]='\0';
155 des_dev_name[0]='\0';
156
157 /* parse mode,des_dev_name, des_dev_no, cap, src_dev_name, src_dev_no, cid */
158 cl = parse (cl, "xsyrssyrx", &red_mode,
159 (LONG)MAX_SMS_ADDR_DIG,
160 des_dev_name, &des_devId, &des_sub_no,
161 (LONG)MAX_SMS_ADDR_DIG,
162 dev_cap,
163 (LONG)MAX_SMS_ADDR_DIG,
164 src_dev_name, &src_devId, &src_sub_no,
165 &pdp_cid );
166 if (!cl)
167 {
168 cmdCmeError (CME_ERR_Unknown);
169 return (ATI_FAIL);
170 }
171
172 /*
173
174 * if optional parameters have not been given, set to defaults
175 */
176 if (des_sub_no EQ ACI_NumParmNotPresent)
177 {
178 des_sub_no = 0;
179 }
180 if (src_sub_no EQ ACI_NumParmNotPresent)
181 {
182 src_sub_no = 0;
183 }
184 if (pdp_cid EQ NOT_PRESENT_8BIT)
185 {
186 pdp_cid = 0;
187 }
188
189 #ifdef FF_ATI_BAT
190 {
191 T_BAT_cmd_send cmd;
192 T_BAT_cmd_set_percent_data my_bat_set_percent_data;
193
194 TRACE_FUNCTION("setatPercentDATA() calls bat_send() <=== as APPLICATION");
195
196 memset(&my_bat_set_percent_data, 0, sizeof(my_bat_set_percent_data));
197 cmd.ctrl_params = BAT_CMD_SET_PERCENT_DATA;
198 cmd.params.ptr_set_percent_data = &my_bat_set_percent_data;
199
200 my_bat_set_percent_data.mode = red_mode;
201
202 if (!strcmp(des_dev_name, "UART"))
203 my_bat_set_percent_data.des_dev_name = BAT_DEV_NAME_UART;
204 else if (!strcmp(des_dev_name, "RIV"))
205 my_bat_set_percent_data.des_dev_name = BAT_DEV_NAME_RIV;
206 else if (!strcmp(des_dev_name, "PKTIO"))
207 my_bat_set_percent_data.des_dev_name = BAT_DEV_NAME_PKTIO;
208 else if (!strcmp(des_dev_name, "PSI"))
209 my_bat_set_percent_data.des_dev_name = BAT_DEV_NAME_PSI;
210
211 my_bat_set_percent_data.des_devId = des_devId;
212 my_bat_set_percent_data.des_sub_no = des_sub_no;
213
214 if (!strcmp(dev_cap, "CMD"))
215 my_bat_set_percent_data.capability = BAT_CAP_CMD;
216 else if (!strcmp(dev_cap, "SER"))
217 my_bat_set_percent_data.capability = BAT_CAP_SER;
218 else if(!strcmp(dev_cap, "PKT"))
219 my_bat_set_percent_data.capability = BAT_CAP_PKT;
220
221 if (!strcmp(des_dev_name, "UART"))
222 my_bat_set_percent_data.src_dev_name = BAT_DEV_NAME_UART;
223 else if (!strcmp(src_dev_name, "RIV"))
224 my_bat_set_percent_data.src_dev_name = BAT_DEV_NAME_RIV;
225 else if (!strcmp(src_dev_name, "PKTIO"))
226 my_bat_set_percent_data.src_dev_name = BAT_DEV_NAME_PKTIO;
227 else if (!strcmp(src_dev_name, "PSI"))
228 my_bat_set_percent_data.src_dev_name = BAT_DEV_NAME_PSI;
229
230 my_bat_set_percent_data.src_devId = des_devId;
231 my_bat_set_percent_data.src_sub_no = src_sub_no;
232 my_bat_set_percent_data.cid = pdp_cid;
233
234 bat_send(ati_bat_get_client(srcId), &cmd);
235
236 return ATI_EXCT; /* executing, because response is passed by callback function */
237 }
238 #else /* OLD FUNCTION BODY */
239
240 TRACE_FUNCTION( "setatPercentDATA()" );
241
242 ret = sAT_PercentDATA ((T_ACI_CMD_SRC)srcId, red_mode,
243 des_dev_name,(UBYTE)(des_devId&DIO_DEVNO_MASK),(UBYTE)des_sub_no,
244 dev_cap,src_dev_name,(UBYTE)(src_devId&DIO_DEVNO_MASK),
245 (UBYTE)src_sub_no,pdp_cid);
246
247 if (ret EQ AT_FAIL)
248 {
249 cmdCmeError (CME_ERR_Unknown);
250 return (ATI_FAIL);
251 }
252 else
253 {
254 return (map_aci_2_ati_rslt(ret));
255 }
256
257 #endif /* no FF_ATI_BAT*/
258 }
259
260 /*
261 +--------------------------------------------------------------------+
262 | PROJECT : GSM-F&D (8411) MODULE : |
263 | STATE : code ROUTINE : queatPercentDATA|
264 +--------------------------------------------------------------------+
265
266 PURPOSE : query %DATA command ( control data flow )
267 */
268
269 GLOBAL T_ATI_RSLT queatPercentDATA ( char *cl, UBYTE srcId )
270 {
271 UBYTE mode = (UBYTE)-1; /* mode is UBYTE type so typecasting -1 with UBYTE */
272 UBYTE cid = (UBYTE)-1; /* cid is UBYTE type so typecasting -1 with UBYTE */
273 T_DINF_PARAM des_param; /* des_dev_name, des_dev_no, des_sub_no, des_cap */
274 T_DINF_PARAM src_param; /* src_dev_name, src_dev_no, src_sub_no, pdp_cid */
275 T_CAP_ID capability = DEV_CPBLTY_NONE;
276
277 #ifdef GPRS
278 char *pktioName = "PKTIO";
279 #endif /* GPRS */
280
281 TRACE_FUNCTION( "queatPercentDATA()" );
282
283 des_param.dev_id = NOT_PRESENT_8BIT; /* in case of there is no redirection at all */
284 des_param.capability = 0xAA; /* init with a value which makes never sense */
285 /*
286 * we want to get the pieces of information to all redirected devices
287 */
288 while ((qAT_PercentDATA ((T_ACI_CMD_SRC)srcId, &mode, &cid, &des_param, &src_param)) EQ AT_CMPL)
289 {
290 U32 des_devId = NOT_PRESENT_32BIT;
291 U32 src_devId = NOT_PRESENT_32BIT;
292 char *tmp_des_name = dti_entity_name[des_param.dev_id].name;
293 char *tmp_src_name = dti_entity_name[src_param.dev_id].name;
294 capability = map_dti_cpblty (des_param.capability);
295 /* With the device number, driver number and the dio id, form
296 the device identifier of both the source and destination to
297 present to the terminal */
298
299 des_devId = (((U32)des_param.dev_no )
300 |((U32) (des_param.driver_id<<24))
301 |((U32) (des_param.dio_ctrl_id <<8)));
302
303 src_devId = (((U32)src_param.dev_no )
304 |((U32) (src_param.driver_id <<24))
305 |((U32) (src_param.dio_ctrl_id <<8)));
306
307
308 /*
309 * unfortunately in custom.h for PKTIO is defined "PKT" (Frame handles up to 4 chars only)
310 * but for the device name we want to emit "PKTIO" to distinguish from capability "PKT"
311 */
312 #ifdef GPRS
313 if (des_param.dev_id EQ DTI_ENTITY_PKTIO)
314 {
315 tmp_des_name = pktioName;
316 }
317
318 if (src_param.dev_id EQ DTI_ENTITY_PKTIO)
319 {
320 tmp_src_name = pktioName;
321 }
322 #endif
323 sprintf (g_sa,"%s: %d,\"%s\",%x,%d,\"%s\",\"%s\",%x,%d,%d", "%DATA",
324 mode,
325 tmp_des_name,
326 des_devId,
327 des_param.sub_no,
328 ati_cap_name[capability].name,
329 tmp_src_name,
330 src_devId,
331 src_param.sub_no,
332 cid);
333
334 io_sendMessage (srcId, g_sa, ATI_NORMAL_OUTPUT);
335 }
336 /*
337 * when qAT_PercentDATA reached the end it returns with AT_FAIL, but check capability as sentinel
338 */
339 if (des_param.capability EQ DEV_CPBLTY_NONE)
340 {
341 /*
342 * DEV_CPBLTY_NONE is the sentinel, that there are no further devices
343 */
344 return (ATI_CMPL);
345 }
346 else if (des_param.dev_id EQ NOT_PRESENT_8BIT)
347 {
348 /*
349 * NOT_PRESENT_8BIT, there is no redirection at all, but print default
350 */
351 sprintf (g_sa,"%s: 0,,0,0,,,0,0,0", "%DATA");
352 io_sendMessage (srcId, g_sa, ATI_NORMAL_OUTPUT);
353 return (ATI_CMPL);
354 }
355
356 cmdCmeError (CME_ERR_Unknown);
357 return (ATI_FAIL);
358 }
359
360
361 /*
362 +--------------------------------------------------------------------+
363 | PROJECT : GSM-F&D (8411) MODULE : |
364 | STATE : code ROUTINE : setatPercentDINF |
365 +--------------------------------------------------------------------+
366
367 PURPOSE : show list of available data and ATI channels and capabilities
368 %DINF=<mode> mode: 0=current, 1=other
369 */
370
371 GLOBAL T_ATI_RSLT setatPercentDINF( char *cl, UBYTE srcId )
372 {
373 UBYTE mode = (UBYTE)-1; /* mode is UBYTE type so typecasting -1 with UBYTE */
374 T_ACI_RETURN ret = AT_FAIL;
375 T_CAP_ID capability = DEV_CPBLTY_NONE;
376 T_CAP_ID cur_cap = DEV_CPBLTY_NONE;
377
378 #ifdef GPRS
379 char *pktioName = "PKTIO";
380 #endif /* GPRS */
381 U32 des_devId = NOT_PRESENT_32BIT;
382
383 cl = parse (cl, "x", &mode);
384 if (!cl)
385 {
386 cmdCmeError (CME_ERR_Unknown);
387 return (ATI_FAIL);
388 }
389
390 #ifdef FF_ATI_BAT
391 {
392 T_BAT_cmd_send cmd;
393 T_BAT_cmd_set_percent_dinf my_bat_set_percent_dinf;
394
395 TRACE_FUNCTION("setatPercentDINF() calls bat_send() <=== as APPLICATION");
396
397 memset(&my_bat_set_percent_dinf, 0, sizeof(my_bat_set_percent_dinf));
398 cmd.ctrl_params = BAT_CMD_SET_PERCENT_DINF;
399 cmd.params.ptr_set_percent_dinf = &my_bat_set_percent_dinf;
400
401 my_bat_set_percent_dinf.mode = mode;
402
403 bat_send(ati_bat_get_client(srcId), &cmd);
404
405 return ATI_EXCT; /* executing, because response is passed by callback function */
406 }
407 #else /* OLD FUNCTION BODY */
408 {
409 T_DINF_PARAM device_para;
410
411 TRACE_FUNCTION( "setatPercentDINF()" );
412
413 switch (mode)
414 {
415 case (SHOW_CURR_CHAN_INF):
416 {
417 /*
418 * we want to get the piece of information, which belongs to the srcId
419 */
420 ret = sAT_PercentDINF ((T_ACI_CMD_SRC)srcId, mode, &device_para);
421
422 if ((ret EQ AT_CMPL) AND (device_para.src_id EQ srcId))
423 {
424 char *tmp_des_name = dti_entity_name[device_para.dev_id].name;
425 capability = map_dti_cpblty (device_para.capability);
426 cur_cap = map_dti_cpblty (device_para.cur_cap);
427 /* With the device number, driver number and the dio id, form
428 the device identifier of the destination and
429 present to the terminal */
430
431 des_devId = (((U32)device_para.dev_no)
432 |((U32) (device_para.driver_id <<24))
433 |((U32) (device_para.dio_ctrl_id <<8)));
434
435
436 /*
437 * unfortunately in custom.h for PKTIO is defined "PKT" (Frame handles up to 4 chars only)
438 * but for the device name we want to emit "PKTIO" to distinguish from capability "PKT"
439 */
440 #ifdef GPRS
441 if (device_para.dev_id EQ DTI_ENTITY_PKTIO)
442 {
443 tmp_des_name = pktioName;
444 }
445 #endif
446
447 sprintf (g_sa,"%s:\"%s\",%x,%d,\"%s\",\"%s\",%d", "%DINF",
448 tmp_des_name,
449 des_devId,
450 device_para.sub_no,
451 ati_cap_name[capability].name,
452 ati_cap_name[cur_cap].name,
453 mode); /* current channel */
454
455
456
457 io_sendMessage (srcId, g_sa, ATI_NORMAL_OUTPUT);
458 return (ATI_CMPL);
459 }
460 else
461 {
462 break; /* an error */
463 }
464 }
465 case (SHOW_ALL_CHAN_INF):
466 {
467 device_para.capability = 0xAA; /* init with a value which makes never sense, but is valuable for debug */
468 /*
469 * we want to get the pieces of information to all devices
470 */
471 while ((ret = sAT_PercentDINF ((T_ACI_CMD_SRC)srcId, mode, &device_para)) EQ AT_CMPL)
472 {
473 char *tmp_des_name = dti_entity_name[device_para.dev_id].name;
474 if (device_para.src_id EQ srcId)
475 {
476 mode = SHOW_CURR_CHAN_INF; /* this is the current channel, so temporarily set mode */
477 }
478 else
479 {
480 mode = SHOW_ALL_CHAN_INF; /* other channel */
481 }
482
483 capability = map_dti_cpblty (device_para.capability);
484 cur_cap = map_dti_cpblty (device_para.cur_cap);
485 /* With the device number, driver number and the dio id, form
486 the device identifier of the destination and
487 present to the terminal */
488
489 des_devId = (((U32)device_para.dev_no)
490 |((U32) (device_para.driver_id <<24))
491 |((U32) (device_para.dio_ctrl_id <<8)));
492
493
494
495 /*
496 * unfortunately in custom.h for PKTIO is defined "PKT" (Frame handles up to 4 chars only)
497 * but for the device name we want to emit "PKTIO" to distinguish from capability "PKT"
498 */
499 #ifdef GPRS
500 if (device_para.dev_id EQ DTI_ENTITY_PKTIO)
501 {
502 tmp_des_name = pktioName;
503 }
504 #endif
505 sprintf (g_sa,"%s:\"%s\",%x,%d,\"%s\",\"%s\",%d", "%DINF",
506 tmp_des_name,
507 des_devId,
508 device_para.sub_no,
509 ati_cap_name[capability].name,
510 ati_cap_name[cur_cap].name,
511 mode);
512 io_sendMessage (srcId, g_sa, ATI_NORMAL_OUTPUT);
513 mode = SHOW_ALL_CHAN_INF; /* reset to show all channels */
514 }
515 /*
516 * when sAT_PercentDINF reached the end it returns with AT_FAIL, but check capability as sentinel
517 */
518 if (device_para.capability EQ DEV_CPBLTY_NONE)
519 {
520 /*
521 * DEV_CPBLTY_NONE is the sentinel, that there are no further devices
522 */
523 return (ATI_CMPL);
524 }
525
526 break; /* an error */
527 }
528 default:
529 {
530 break; /* an error */
531 }
532 }
533
534 cmdCmeError (CME_ERR_Unknown);
535 return (ATI_FAIL);
536 }
537 #endif /* no FF_ATI_BAT*/
538 }
539
540 #endif /* ATI_DTI_C */
541 #endif /* DTI */
542