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