FreeCalypso > hg > freecalypso-sw
comparison gsm-fw/g23m-aci/aci/ati_src_sat.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 | beb8e9851a07 |
comparison
equal
deleted
inserted
replaced
774:40a721fd9854 | 775:eedbf248bac0 |
---|---|
1 /* | |
2 +----------------------------------------------------------------------------- | |
3 | Project : GSM-PS (6147) | |
4 | Modul : ATI_SRC_SATC | |
5 +----------------------------------------------------------------------------- | |
6 | Copyright 2002 Texas Instruments Berlin, AG | |
7 | All rights reserved. | |
8 | | |
9 | This file is confidential and a trade secret of Texas | |
10 | Instruments Berlin, AG | |
11 | The receipt of or possession of this file does not convey | |
12 | any rights to reproduce or disclose its contents or to | |
13 | manufacture, use, or sell anything it may describe, in | |
14 | whole, or in part, without the specific written consent of | |
15 | Texas Instruments Berlin, AG. | |
16 +----------------------------------------------------------------------------- | |
17 | Purpose : . | |
18 +----------------------------------------------------------------------------- | |
19 */ | |
20 | |
21 #ifdef SIM_TOOLKIT | |
22 | |
23 #ifndef ATI_SRC_SAT_C | |
24 #define ATI_SRC_SAT_C | |
25 #endif | |
26 | |
27 #include "aci_all.h" | |
28 /*==== INCLUDES ===================================================*/ | |
29 #include "aci_cmh.h" | |
30 #include "ati_cmd.h" | |
31 #include "aci_cmd.h" | |
32 | |
33 #ifdef UART | |
34 #include "dti.h" /* functionality of the dti library */ | |
35 #endif | |
36 | |
37 #include "aci_lst.h" | |
38 | |
39 #include "ati_src_sat.h" | |
40 #include "psa.h" | |
41 #include "psa_cc.h" | |
42 #include "psa_sat.h" | |
43 #include "cmh.h" | |
44 | |
45 #include "aci_mem.h" | |
46 | |
47 #ifdef UART | |
48 #include "dti_conn_mng.h" | |
49 #include "psa_uart.h" | |
50 #endif | |
51 | |
52 #include "ati_io.h" | |
53 | |
54 #include "ati_int.h" | |
55 | |
56 /*==== CONSTANTS ==================================================*/ | |
57 | |
58 /*==== TYPES ======================================================*/ | |
59 | |
60 /*==== EXPORT =====================================================*/ | |
61 EXTERN T_ACI_LIST *ati_src_list; | |
62 | |
63 /*==== VARIABLES ==================================================*/ | |
64 USHORT sat_out_buf_len = 0; | |
65 UBYTE *sat_out_buf = NULL; | |
66 | |
67 UBYTE run_at_id = 0xFF; /* srce id of source where run at cmd is processed */ | |
68 | |
69 /*==== FUNCTIONS ==================================================*/ | |
70 EXTERN USHORT format_output (UBYTE *src, USHORT src_len, UBYTE *dst, | |
71 T_ATI_OUTPUT_TYPE output_type); | |
72 | |
73 /* | |
74 +----------------------------------------------------------------+ | |
75 | PROJECT : GSM-PS (6147) MODULE : | | |
76 | ROUTINE : sat_buffer_output | | |
77 +----------------------------------------------------------------+ | |
78 | |
79 PURPOSE : Buffer messages for RUN AT. Send buffered messages with | |
80 confirm respond later | |
81 */ | |
82 LOCAL void sat_buffer_output(T_ACI_SAT_TERM_RESP resp_data) | |
83 { | |
84 UBYTE *new_buf; | |
85 UBYTE *old_buf; | |
86 | |
87 TRACE_FUNCTION("sat_buffer_output"); | |
88 | |
89 if ( sat_out_buf EQ NULL ) /* first message to buffer */ | |
90 { | |
91 ACI_MALLOC(sat_out_buf, resp_data.at_resp_count +1); | |
92 } | |
93 else | |
94 { | |
95 /* enlarge buffer */ | |
96 old_buf = sat_out_buf; | |
97 ACI_MALLOC(new_buf, sat_out_buf_len + resp_data.at_resp_count +1); | |
98 memcpy(new_buf, sat_out_buf, sat_out_buf_len); | |
99 sat_out_buf = new_buf; | |
100 ACI_MFREE(old_buf); | |
101 } | |
102 | |
103 /* add new message text to the end of the output buffer */ | |
104 memcpy(sat_out_buf + sat_out_buf_len, | |
105 resp_data.at_resp, resp_data.at_resp_count); | |
106 sat_out_buf_len += resp_data.at_resp_count; | |
107 sat_out_buf[sat_out_buf_len] = 0; | |
108 | |
109 } | |
110 | |
111 | |
112 /* | |
113 +-------------------------------------------------------------------+ | |
114 | PROJECT : GSM-PS (6147) MODULE : | | |
115 | ROUTINE :sat_send_buffered_output | | |
116 +-------------------------------------------------------------------+ | |
117 | |
118 PURPOSE : for RUN AT : send buffered messages with confirm respond | |
119 */ | |
120 LOCAL void sat_send_buffered_output(T_ACI_SAT_TERM_RESP resp_data) | |
121 { | |
122 TRACE_FUNCTION("sat_send_buffered_output"); | |
123 | |
124 /* copy confirm respond to end of output buffer */ | |
125 sat_buffer_output(resp_data); | |
126 | |
127 /* send buffered respond */ | |
128 resp_data.at_resp = sat_out_buf; | |
129 resp_data.at_resp_count = sat_out_buf_len; | |
130 TRACE_EVENT_P2("Buffer (%d): %s", resp_data.at_resp_count, (char*) resp_data.at_resp); | |
131 psaSAT_SendTrmResp( RSLT_PERF_SUCCESS, &resp_data ); | |
132 | |
133 /* free buffered output */ | |
134 ACI_MFREE(sat_out_buf); | |
135 sat_out_buf = NULL; | |
136 sat_out_buf_len = 0; | |
137 | |
138 } | |
139 | |
140 | |
141 /* | |
142 +-------------------------------------------------------------------+ | |
143 | PROJECT : GSM-PS (6147) MODULE : | | |
144 | ROUTINE : sat_src_result_cb | | |
145 +-------------------------------------------------------------------+ | |
146 | |
147 PURPOSE : | |
148 */ | |
149 | |
150 | |
151 GLOBAL void sat_src_result_cb ( UBYTE src_id, | |
152 T_ATI_OUTPUT_TYPE output_type, | |
153 UBYTE *output, | |
154 USHORT output_len) | |
155 { | |
156 UBYTE *formated_response; | |
157 T_ACI_SAT_TERM_RESP resp_data; | |
158 T_ATI_SRC_PARAMS *src_params; | |
159 // T_at_resp *at_response; | |
160 | |
161 psaSAT_InitTrmResp( &resp_data ); | |
162 | |
163 TRACE_FUNCTION("sat_src_result_cb()"); | |
164 | |
165 /* search for SAT source Id */ | |
166 src_params = find_element (ati_src_list, src_id, search_ati_src_id); | |
167 if (src_params EQ NULL) | |
168 { | |
169 TRACE_EVENT ("[ERR] source ID not found"); | |
170 return; | |
171 } | |
172 else if( src_params->src_type NEQ ATI_SRC_TYPE_SAT) | |
173 { | |
174 TRACE_EVENT ("[ERR] source ID is not from type SAT"); | |
175 return; | |
176 } | |
177 else if( !IS_INDICATION_OUTPUT(output_type) ) | |
178 { | |
179 /* size of response goes up to MAX_CMD_AT_LEN | |
180 The rest will be truncated */ | |
181 ACI_MALLOC(formated_response, MAX_CMD_AT_LEN+5); | |
182 if( output_len > MAX_CMD_AT_LEN ) | |
183 { | |
184 output_len = MAX_CMD_AT_LEN; | |
185 } | |
186 | |
187 resp_data.at_resp_count | |
188 = format_output(output, output_len, formated_response, output_type); | |
189 resp_data.at_resp = formated_response; | |
190 | |
191 | |
192 if ( resp_data.at_resp NEQ NULL AND !IS_CONFIRM_OUTPUT(output_type)) | |
193 { /* Buffer messages for RUN AT. Send buffered messages with | |
194 confirm respond later */ | |
195 | |
196 TRACE_EVENT("buffer OUTPUT"); | |
197 sat_buffer_output(resp_data); | |
198 } | |
199 else if ( resp_data.at_resp NEQ NULL AND sat_out_buf_len > 0 ) | |
200 { /* for RUN AT: send buffered messages with confirm respond */ | |
201 sat_send_buffered_output(resp_data); | |
202 } | |
203 else | |
204 { /* send respond */ | |
205 psaSAT_SendTrmResp( RSLT_PERF_SUCCESS, &resp_data ); | |
206 } | |
207 | |
208 ACI_MFREE(formated_response); | |
209 } | |
210 } | |
211 | |
212 | |
213 /* | |
214 +-------------------------------------------------------------------+ | |
215 | PROJECT : GSM-PS (6147) MODULE : | | |
216 | ROUTINE : sat_new_source | | |
217 +-------------------------------------------------------------------+ | |
218 | |
219 PURPOSE : Create a new source for ATI with the corresponding struct. | |
220 */ | |
221 | |
222 GLOBAL void sat_new_source( void ) | |
223 { | |
224 /*#ifdef _SIMULATION_ | |
225 static BOOL already_done = FALSE; | |
226 static UBYTE id; | |
227 | |
228 TRACE_FUNCTION("sat_new_source: Win 32"); | |
229 | |
230 if( already_done ) | |
231 { | |
232 TRACE_EVENT_P1("SAT related id: %d", id); | |
233 satShrdPrm.run_at_id = id; | |
234 return; | |
235 } | |
236 already_done = TRUE; | |
237 #else | |
238 UBYTE id; | |
239 | |
240 TRACE_FUNCTION("sat_new_source: target"); | |
241 #endif*/ | |
242 /* _SIMULATION_ */ | |
243 run_at_id = ati_init(ATI_SRC_TYPE_SAT, sat_src_result_cb, NULL); | |
244 if (run_at_id<CMD_SRC_MAX) | |
245 { | |
246 if (run_at_id==CMD_SRC_LCL) | |
247 aci_cmd_src_mode_set(run_at_id,CMD_MODE_ACI); | |
248 else | |
249 aci_cmd_src_mode_set(run_at_id,CMD_MODE_ATI); | |
250 } | |
251 | |
252 TRACE_EVENT_P1 ("sat_new_source: SAT srcId=%d", run_at_id); | |
253 } | |
254 | |
255 /* | |
256 +-------------------------------------------------------------------+ | |
257 | PROJECT : GSM-PS (6147) MODULE : CMH_DTIR | | |
258 | ROUTINE : sat_src_proc_chars | | |
259 +-------------------------------------------------------------------+ | |
260 | |
261 PURPOSE : | |
262 */ | |
263 | |
264 GLOBAL BOOL sat_src_proc_chars ( UBYTE *chars ) | |
265 { | |
266 T_ATI_SRC_PARAMS *src_params = NULL; | |
267 T_ACI_SAT_TERM_RESP resp_data; | |
268 | |
269 psaSAT_InitTrmResp( &resp_data ); | |
270 | |
271 TRACE_FUNCTION ("sat_src_proc_chars()"); | |
272 | |
273 /* search for SAT source Id */ | |
274 src_params = find_element (ati_src_list, run_at_id, search_ati_src_id); | |
275 if (src_params EQ NULL) | |
276 { | |
277 TRACE_EVENT ("[ERR] ati_execute: no SAT source ID present"); | |
278 psaSAT_SendTrmResp( RSLT_ME_UNAB_PROC, &resp_data ); | |
279 return(FALSE); | |
280 } | |
281 | |
282 /* do not echo AT-cmds which are sent by SAT */ | |
283 ati_user_output_cfg[src_params->src_id].atE = 0; | |
284 | |
285 return(ati_execute_sat_cmd (src_params, chars, MAX_CMD_AT_LEN)); | |
286 } | |
287 | |
288 | |
289 | |
290 #endif /* SIM_TOOLKIT */ |