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