comparison g23m/condat/ms/src/aci/ati_src_lc.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_LC
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 #if defined FF_EOTD
22 #ifndef ATI_SRC_LC_C
23 #define ATI_SRC_LC_C
24 #endif
25
26 #if defined (SMI)
27 #define ENTITY_SMI
28 #elif defined (MFW)
29 #define ENTITY_MFW
30 #else
31 #define ENTITY_ACI
32 #endif
33
34 #define ACI_MEMBER
35
36 /*==== INCLUDES ===================================================*/
37 #if 0
38 #include <string.h>
39 #include <stdlib.h>
40 #include <stdio.h>
41 #include "typedefs.h"
42 #include "pconst.cdg"
43 #include "mconst.cdg"
44 #include "message.h"
45 #include "ccdapi.h"
46 #include "vsi.h"
47 #include "custom.h"
48 #include "gsm.h"
49 #include "prim.h"
50 #include "cnf_aci.h"
51 #include "mon_aci.h"
52 #include "pei.h"
53 #include "tok.h"
54 #include "aci_cmh.h"
55 #include "ati_cmd.h"
56 #include "aci_cmd.h"
57
58 #include "aci_lst.h"
59 #include "dti_conn_mng.h"
60 #include "psa_uart.h"
61 #include "cmh_uart.h"
62 #include "aci_io.h"
63 #include "aci_mem.h"
64 #include "aci.h"
65 #include "ati_io.h"
66 #include "ati_src_lc.h"
67
68 #include "cmh_lc.h"
69 #endif
70
71 #include "aci_all.h"
72 #include "aci_cmh.h"
73 #include "ati_cmd.h"
74 #include "aci_cmd.h"
75 #include "dti.h" /* functionality of the dti library */
76
77 #include "aci_lst.h"
78 #include "dti_conn_mng.h"
79 #ifdef UART
80 #include "psa_uart.h"
81 #include "cmh_uart.h"
82 #endif
83 #include "aci_io.h"
84 #include "aci_mem.h"
85 #include "aci.h"
86 #include "ati_io.h"
87 #include "ati_int.h"
88
89 #include "cmh_lc.h"
90 #include "ati_src_lc.h"
91
92 /*==== CONSTANTS ==================================================*/
93
94 /*==== TYPES ======================================================*/
95
96 /*==== EXPORT =====================================================*/
97 EXTERN CHAR *parse(CHAR *b,CHAR *f, ...);
98 EXTERN T_ACI_LIST *ati_src_list;
99 /*==== VARIABLES ==================================================*/
100 LOCAL BOOL CLPS_flag = FALSE;
101
102 /*==== FUNCTIONS ==================================================*/
103 GLOBAL void ati_src_lc_result_cb (UBYTE src_id,
104 T_ATI_OUTPUT_TYPE output_type,
105 UBYTE *output,
106 USHORT output_len)
107 {
108 T_ATI_SRC_PARAMS *src_params = 0;
109 T_LOC_SERV_PARA *p_lsprm = 0;
110 char orig_addr[MAX_SMS_ADDR_DIG]; /* SMS originating address */
111 char mlc_source_addr[MAX_SMS_ADDR_DIG]; /* Mobile Location Center source address */
112 UBYTE *pos_data = 0;
113 T_ACI_SM_DATA sms_data;
114 UBYTE sms_buf[30];
115 static U8 sms_cnt = 0;
116
117
118 TRACE_FUNCTION ("ati_src_lc_result_cb ()");
119
120 memset (orig_addr, 0, sizeof(orig_addr));
121 memset (mlc_source_addr, 0, sizeof(mlc_source_addr));
122 p_lsprm = &locServPrm;
123
124 /* search for LC source Id */
125 src_params = find_element (ati_src_list, src_id, search_ati_src_id);
126 if (src_params EQ NULL)
127 {
128 TRACE_EVENT ("[ERR] source ID not found");
129 return;
130 }
131 else if( src_params->src_type NEQ ATI_SRC_TYPE_LC)
132 {
133 TRACE_EVENT ("[ERR] source ID is not from type LC");
134 return;
135 }
136 /* check length of delivered string */
137 if( output_len EQ 0 )
138 return;
139
140 /*
141 * check client id ???
142 *
143 */
144
145
146 /* check E-OTD flag */
147 if(location_service_flag EQ TRUE)
148 {
149 if(!strncmp((char *)output,"+CMT: ",6))
150 {
151 /* look for MLC source address in LC paramters */
152 if (qAT_PlusCLSA(p_lsprm->lc_src_id,mlc_source_addr,NULL) EQ AT_CMPL)
153 {/* compare stored MLC source address with SMS originated address */
154 if(!strcmp(lc_orig_addr.address,mlc_source_addr))
155 {
156 /* immediately position data request */
157 if(sAT_PlusCLPS(p_lsprm->lc_src_id,CLPS_LCS_ACT,lc_orig_addr.address,IMM_POS_DATA_REQ) NEQ AT_EXCT)
158 {
159 TRACE_EVENT ("[ERR] position data request failed");
160 }
161 else
162 {
163 src_params->curAtCmd = AT_CMD_CLPS;
164 }
165 }
166 }
167 }
168 else
169 { /* CLPS indicates LC position data */
170 if(strstr((char *)output,"%CLPS:") NEQ NULL)
171 {
172 memset(&sms_data.data,0,MAX_SM_LEN);
173 memcpy(&sms_data.data,&aci_lc_data.position_data,aci_lc_data.pos_data_length);
174 sms_data.len = aci_lc_data.pos_data_length;
175
176 strncpy((char *)sms_buf, (char *)&sms_data.data, 28);
177 sms_buf[28] = 0;
178 TRACE_EVENT_P1("SMS before send:%s...", sms_buf);
179 TRACE_EVENT_P2("*** #%d SMS to %s", sms_cnt++, p_lsprm->mlcdest.address);
180
181
182 sAT_PlusCSMP (p_lsprm->lc_src_id, TP_MTI_SMS_SUBMIT | TP_VPF_RELATIVE,
183 0xA7/*TP_VP_RELATIVE_DEFAULT*/, NULL, NULL, SMS_PID_DEFAULT, 0xF4);
184 #if 0
185 GLOBAL T_ACI_RETURN sAT_PlusCSMP ( T_ACI_CMD_SRC srcId,
186 SHORT fo,
187 SHORT vprel,
188 T_ACI_VP_ABS* vpabs,
189 SHORT pid,
190 SHORT dcs )
191 #endif
192 if (sAT_PlusCMGF (p_lsprm->lc_src_id, CMGF_MOD_Txt) NEQ AT_CMPL)
193 {
194 TRACE_ERROR("ati_src_lc_result_cb():[ERR] invalid return for sAT_PlusCMGF");
195 }
196 if (sAT_PlusCMGS_Gl (p_lsprm->lc_src_id,
197 p_lsprm->mlcdest.address,
198 &p_lsprm->mlcdest.toa,
199 &sms_data,
200 NULL,
201 NULL,
202 NULL,
203 -1,
204 NULL,
205 NULL) NEQ AT_EXCT)
206 {
207 TRACE_ERROR ("[ERR] sms position data failed");
208 }
209 else
210 {
211 src_params->curAtCmd = AT_CMD_CMGS;
212 }
213 }
214 }
215 } /* E-OTD */
216 return;
217 }
218
219
220 GLOBAL void ati_src_lc_line_state_cb (UBYTE src_id,
221 T_ATI_LINE_STATE_TYPE line_state_type,
222 ULONG line_state_param)
223 {
224 char trcBuf[80];
225
226 TRACE_FUNCTION ("ati_src_lc_line_state_cb ()");
227
228 switch (line_state_type)
229 {
230 case ATI_LINE_STATE_OUTPUT_TYPE:
231 sprintf (trcBuf, "[DBG] ati_src_tst_line_state_cb (): "\
232 "ATI_LINE_STATE_OUTPUT_TYPE = %d", line_state_param);
233 TRACE_EVENT (trcBuf);
234 break;
235 default:
236 sprintf (trcBuf, "[WRN] ati_src_tst_line_state_cb (): "\
237 "UNKNOWN line_state_type = %d", line_state_type);
238 TRACE_EVENT (trcBuf);
239 break;
240 }
241 }
242
243
244 /*
245 +-------------------------------------------------------------------+
246 | PROJECT : GSM-PS (6147) MODULE : ati_src_lc |
247 | ROUTINE : ati_src_lc_init |
248 +-------------------------------------------------------------------+
249
250 PURPOSE : register the location service source
251 */
252
253 GLOBAL void ati_src_lc_init ( UBYTE cmd_src )
254 {
255 T_LOC_SERV_PARA *lc_para = 0;
256
257 TRACE_FUNCTION ("ati_src_lc_init ()");
258
259 lc_para = &locServPrm;
260
261 /* initialize LC parameters */
262
263
264 /* register the location service source */
265 lc_para->lc_src_id = ati_init (ATI_SRC_TYPE_LC,
266 ati_src_lc_result_cb,
267 ati_src_lc_line_state_cb);
268
269 lclist_init();
270
271 TRACE_EVENT_P1 ("ati_src_lc_init: srcId=%d", lc_para->lc_src_id);
272 }
273
274
275 /*
276 +-------------------------------------------------------------------+
277 | PROJECT : GSM-PS (6147) MODULE : ati_src_lc |
278 | ROUTINE : ati_src_lc_finit |
279 +-------------------------------------------------------------------+
280
281 PURPOSE : deregister the location service source
282 */
283
284 GLOBAL void ati_src_lc_finit (void)
285 {
286 TRACE_FUNCTION ("ati_src_lc_finit ()");
287
288 ati_finit (locServPrm.lc_src_id);
289
290 }
291
292
293
294 #endif /* FF_EOTD */
295