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