FreeCalypso > hg > fc-magnetite
comparison src/aci2/aci/ati_src_rvt.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 | 41742552e98b |
comparison
equal
deleted
inserted
replaced
2:c41a534f33c6 | 3:93999a60b835 |
---|---|
1 /* | |
2 * This module is a FreeCalypso addition. Here we are going to implement | |
3 * a mechanism for passing AT commands and responses over RVTMUX. | |
4 */ | |
5 | |
6 #if 0 | |
7 #include "config.h" | |
8 #include "fixedconf.h" | |
9 #include "condat-features.h" | |
10 #include "aci_conf.h" | |
11 #endif | |
12 | |
13 /* includes copied from ati_cmd.c */ | |
14 | |
15 #undef DUMMY_ATI_STRINGS | |
16 | |
17 #include "aci_all.h" | |
18 | |
19 #include "dti.h" /* functionality of the dti library */ | |
20 #include "line_edit.h" /* SKA 2002-09-05 */ | |
21 #include "aci_cmh.h" | |
22 #include "ati_cmd.h" | |
23 #include "aci_io.h" | |
24 #include "aci_cmd.h" | |
25 #include "l4_tim.h" | |
26 | |
27 #include <string.h> | |
28 #include <stdarg.h> | |
29 #include <stdio.h> | |
30 | |
31 #include "psa.h" | |
32 #include "cmh.h" | |
33 | |
34 #include "aci_lst.h" | |
35 #include "dti_conn_mng.h" | |
36 #ifdef UART | |
37 #include "psa_uart.h" | |
38 #endif | |
39 #include "ati_io.h" | |
40 #include "aci_mem.h" | |
41 | |
42 #ifdef SIM_TOOLKIT | |
43 #include "ati_src_sat.h" | |
44 #include "psa_cc.h" | |
45 #include "psa_sat.h" | |
46 #endif /* SIM_TOOLKIT */ | |
47 | |
48 #ifdef GPRS | |
49 #include "gaci_cmh.h" | |
50 #include "gaci_cmd.h" | |
51 #endif /* GPRS */ | |
52 | |
53 #include "aci_prs.h" | |
54 | |
55 | |
56 #ifndef _SIMULATION_ | |
57 #ifdef UART | |
58 #include "cmh_uart.h" | |
59 #endif | |
60 #endif | |
61 | |
62 #include "psa_sms.h" | |
63 #include "aci.h" | |
64 #include "ati_ext_mech.h" | |
65 | |
66 #ifdef FF_ATI_BAT | |
67 #include "ati_bat.h" | |
68 #include "aci_bat.h" | |
69 #endif | |
70 | |
71 EXTERN T_ACI_LIST *ati_src_list; | |
72 | |
73 #include "rvt/rvt_gen.h" | |
74 | |
75 static UBYTE rvt_src_id; | |
76 static T_RVT_USER_ID rvt_user_id; | |
77 | |
78 /* | |
79 * The following function is the callback registered with RVT; it gets | |
80 * called in RVT HISR context. We allocate an ACI_CMD_REQ primitive, | |
81 * copy the received string into it and post it to ACI to be processed | |
82 * in our own task context. | |
83 */ | |
84 GLOBAL void ati_src_rvt_input_callback (T_RVT_BUFFER in_str, UINT16 in_str_len) | |
85 { | |
86 PALLOC (aci_cmd_req, ACI_CMD_REQ); | |
87 | |
88 aci_cmd_req->cmd_src = rvt_src_id; | |
89 aci_cmd_req->cmd_len = in_str_len; | |
90 memcpy(aci_cmd_req->cmd_seq, in_str, in_str_len); | |
91 | |
92 PSENDX (ACI, aci_cmd_req); | |
93 } | |
94 | |
95 /* | |
96 * The following function is called from aci_aci.c when an ACI_CMD_REQ | |
97 * primitive (sent by the previous function) has been received. | |
98 */ | |
99 GLOBAL BOOL ati_src_rvt_proc_cmd (T_ACI_CMD_REQ *aci_cmd_req) | |
100 { | |
101 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, rvt_src_id, | |
102 search_ati_src_id); | |
103 | |
104 ati_user_output_cfg[rvt_src_id].atE = 0; | |
105 | |
106 if (src_params->text_mode EQ CMD_MODE) | |
107 { | |
108 TRACE_FUNCTION ("ati_src_rvt_proc_cmd () CMD MODE"); | |
109 | |
110 aci_cmd_req->cmd_seq[aci_cmd_req->cmd_len] = '\r'; /* make it V.25 ter compatible */ | |
111 aci_cmd_req->cmd_seq[(aci_cmd_req->cmd_len) + 1] = '\0'; | |
112 aci_cmd_req->cmd_len++; | |
113 } | |
114 else /* text has to be terminated by Ctrl-Z */ | |
115 { | |
116 TRACE_FUNCTION ("ati_src_rvt_proc_cmd () TEXT MODE"); | |
117 | |
118 aci_cmd_req->cmd_seq[aci_cmd_req->cmd_len] = 0x1a; /* make it V.25 ter compatible */ | |
119 aci_cmd_req->cmd_seq[(aci_cmd_req->cmd_len) + 1] = '\0'; | |
120 aci_cmd_req->cmd_len++; | |
121 } | |
122 | |
123 return (ati_execute (rvt_src_id, | |
124 aci_cmd_req->cmd_seq, | |
125 aci_cmd_req->cmd_len)); | |
126 } | |
127 | |
128 /* | |
129 * The following function is the callback registered with ATI; it gets | |
130 * called when ATI has something to send to the user. | |
131 */ | |
132 GLOBAL void ati_src_rvt_result_cb (UBYTE src_id, | |
133 T_ATI_OUTPUT_TYPE output_type, | |
134 UBYTE *output, | |
135 USHORT output_len) | |
136 { | |
137 TRACE_FUNCTION ("ati_src_rvt_result_cb ()"); | |
138 rvt_send_trace_cpy (output, rvt_user_id, output_len, RVT_ASCII_FORMAT); | |
139 } | |
140 | |
141 /* | |
142 * The following function is the other callback registered with ATI. | |
143 */ | |
144 GLOBAL void ati_src_rvt_line_state_cb (UBYTE src_id, | |
145 T_ATI_LINE_STATE_TYPE line_state_type, | |
146 ULONG line_state_param) | |
147 { | |
148 TRACE_FUNCTION ("ati_src_rvt_line_state_cb ()"); | |
149 | |
150 switch (line_state_type) | |
151 { | |
152 case ATI_LINE_STATE_OUTPUT_TYPE: | |
153 TRACE_EVENT_P1 ("[DBG] ati_src_rvt_line_state_cb (): ATI_LINE_STATE_OUTPUT_TYPE = %d", line_state_param); | |
154 break; | |
155 | |
156 case ATI_LINE_STATE_DCD: | |
157 TRACE_EVENT_P1 ("[DBG] ati_src_rvt_line_state_cb (): ATI_LINE_STATE_DCD = %d", line_state_param); | |
158 break; | |
159 | |
160 case ATI_LINE_STATE_RNG: /* TODO */ | |
161 { | |
162 T_IO_RING_PARAMS rng_params; | |
163 | |
164 memcpy (&rng_params, (T_IO_RING_PARAMS*)line_state_param, | |
165 sizeof(T_IO_RING_PARAMS)); | |
166 | |
167 TRACE_EVENT_P1 ("[DBG] ati_src_rvt_line_state_cb (): ATI_LINE_STATE_RNG = %d", rng_params.ring_stat); | |
168 | |
169 break; | |
170 } | |
171 | |
172 default: | |
173 TRACE_EVENT_P1 ("[WRN] ati_src_rvt_line_state_cb (): UNKNOWN line_state_type = %d", line_state_type); | |
174 break; | |
175 } | |
176 } | |
177 | |
178 /* | |
179 * The following function is called from ati_cmd_init() in ati_cmd.c | |
180 * to register our mechanism. | |
181 */ | |
182 GLOBAL void ati_src_rvt_register (void) | |
183 { | |
184 rvt_register_id ("AT", &rvt_user_id, ati_src_rvt_input_callback); | |
185 rvt_src_id = ati_init (ATI_SRC_TYPE_TST, | |
186 ati_src_rvt_result_cb, | |
187 ati_src_rvt_line_state_cb); | |
188 ati_switch_mode(rvt_src_id, ATI_CMD_MODE); | |
189 } |