comparison g23m/condat/ms/src/aci/ati_src_sat.c @ 0:509db1a7b7b8

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