comparison g23m-aci/aci/ati_src_sat.c @ 0:75a11d740a02

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