FreeCalypso > hg > tcs211-l1-reconst
comparison g23m/condat/ms/src/aci/gaci.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 : | |
4 | Modul : J:\g23m-aci\aci\gaci.c | |
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 #if defined (GPRS) && defined (DTI) | |
21 | |
22 #ifndef GACI_C | |
23 #define GACI_C | |
24 #endif | |
25 | |
26 #include "aci_all.h" | |
27 /*==== INCLUDES ===================================================*/ | |
28 #include "dti.h" /* functionality of the dti library */ | |
29 #include "aci_cmh.h" | |
30 #include "ati_cmd.h" | |
31 #include "aci_cmd.h" | |
32 | |
33 #include "dti_conn_mng.h" | |
34 | |
35 #include "gaci.h" | |
36 #include "gaci_cmh.h" | |
37 #include "psa.h" | |
38 #include "psa_sm.h" | |
39 #include "psa_gppp.h" | |
40 #include "psa_gmm.h" | |
41 | |
42 #include "cmh.h" | |
43 #ifdef SIM_TOOLKIT | |
44 #include "psa_cc.h" | |
45 #include "psa_sat.h" | |
46 #include "cmh_sat.h" | |
47 #endif /* SIM_TOOLKIT */ | |
48 #include "cmh_sm.h" | |
49 #include "cmh_gppp.h" | |
50 #include "cmh_gmm.h" | |
51 #include "gaci_srcc.h" | |
52 | |
53 /*==== CONSTANTS ==================================================*/ | |
54 static T_ACI_CMD_SRC _ATZ_srcId; | |
55 | |
56 #ifdef FF_SAT_E | |
57 static USHORT SAT_error_cause = SAT_GPRS_INV_CAUSE; | |
58 #endif /* FF_SAT_E */ | |
59 | |
60 /*==== EXPORT =====================================================*/ | |
61 | |
62 /*==== VARIABLES ==================================================*/ | |
63 | |
64 GLOBAL void gaci_init ( void ) | |
65 { | |
66 /* Init of intern variable */ | |
67 _ATZ_srcId = CMD_SRC_NONE; | |
68 | |
69 /* GPRS Init */ | |
70 gpppEntStat.curCmd = AT_CMD_NONE; | |
71 gpppEntStat.entOwn = OWN_NONE; | |
72 | |
73 cmhGMM_Init(); | |
74 cmhSM_Init(); | |
75 | |
76 srcc_init(); | |
77 | |
78 gaci_reset(); | |
79 } | |
80 | |
81 GLOBAL void gaci_reset( void ) | |
82 { | |
83 cmhSM_Reset(); | |
84 } | |
85 | |
86 GLOBAL void gaci_ATZ_reset( void ) | |
87 { | |
88 cmhSM_ResetNonWorkingContexts(); | |
89 } | |
90 | |
91 GLOBAL void gaci_finit ( void ) | |
92 { | |
93 /* here will be a functionality */ | |
94 } | |
95 | |
96 EXTERN T_ACI_RETURN sGsmAT_Z ( T_ACI_CMD_SRC srcId ); | |
97 | |
98 GLOBAL T_ACI_RETURN sGprsAT_Z ( T_ACI_CMD_SRC srcId ) | |
99 { | |
100 SHORT cid_array[1] = { INVALID_CID }; | |
101 | |
102 /* | |
103 *------------------------------------------------------------------- | |
104 * rejects waiting network requests for PDP context activation | |
105 *------------------------------------------------------------------- | |
106 */ | |
107 if ( ( at.rngPrms.isRng EQ TRUE ) && ( at.rngPrms.mode EQ CRING_MOD_Gprs) ) /* GPRS call */ | |
108 { | |
109 /* | |
110 * brz patch: In the case of context reactivation over SMREG_PDP_ACTIVATE_IND with an used ti | |
111 * the GPRS ATZ command doesn't do anything! | |
112 * | |
113 * Why? Because the Windows Dial-Up Networking client send every time an ATZ after termination | |
114 * of the connection and with this a context reactivation was impossible. | |
115 */ | |
116 if ( gprs_call_table[current_gprs_ct_index].reactivation EQ GCTT_NORMAL ) | |
117 { | |
118 sAT_PlusCGANS(srcId, CGANS_RESPONSE_REJECT, NULL, GPRS_CID_OMITTED); | |
119 } | |
120 else | |
121 { /* Reactivation: stop GPRS ATZ */ | |
122 return sGsmAT_Z ( srcId ); | |
123 } | |
124 } | |
125 if ( AT_EXCT EQ sAT_PlusCGACT ( srcId, CGACT_STATE_DEACTIVATED, cid_array )) | |
126 { | |
127 _ATZ_srcId = srcId; /* hold source Id */ | |
128 return( AT_EXCT ); | |
129 } | |
130 | |
131 srcId_cb = srcId; | |
132 gaci_ATZ_reset(); | |
133 return sGsmAT_Z ( srcId ); | |
134 } | |
135 | |
136 LOCAL void endOfGprsAT_Z ( void ) | |
137 { | |
138 srcId_cb = _ATZ_srcId; | |
139 gaci_ATZ_reset(); | |
140 if ( AT_CMPL EQ sGsmAT_Z ( _ATZ_srcId ) ) | |
141 { | |
142 R_AT( RAT_OK, _ATZ_srcId ) ( AT_CMD_Z ); | |
143 | |
144 /* log result */ | |
145 cmh_logRslt ( _ATZ_srcId, | |
146 RAT_OK, AT_CMD_Z, -1, -1, -1 ); | |
147 } | |
148 | |
149 _ATZ_srcId = CMD_SRC_NONE; | |
150 } | |
151 | |
152 GLOBAL BOOL gaci_isATZcmd ( void ) | |
153 { | |
154 if ( _ATZ_srcId NEQ CMD_SRC_NONE ) | |
155 { | |
156 endOfGprsAT_Z(); | |
157 return TRUE; | |
158 } | |
159 | |
160 return FALSE; | |
161 } | |
162 | |
163 | |
164 GLOBAL SHORT gaci_get_cid_over_dti_id ( UBYTE dti_id ) | |
165 { | |
166 SHORT i = 0; | |
167 | |
168 /* compare only the DTI ID part of the Link ID */ | |
169 for (i = 0; i < MAX_CID; i++) | |
170 { | |
171 if ( dti_id EQ EXTRACT_DTI_ID(pdp_context[i].link_id_sn) OR | |
172 dti_id EQ EXTRACT_DTI_ID(pdp_context[i].link_id_uart) OR | |
173 dti_id EQ EXTRACT_DTI_ID(pdp_context[i].link_id_new) ) | |
174 { | |
175 return i + 1; | |
176 } | |
177 } | |
178 return INVALID_CID; | |
179 } | |
180 | |
181 GLOBAL SHORT gaci_get_cid_over_link_id ( T_DTI_CONN_LINK_ID link_id ) | |
182 { | |
183 return gaci_get_cid_over_dti_id((UBYTE)EXTRACT_DTI_ID(link_id)); | |
184 } | |
185 | |
186 /* | |
187 * Assumption: there is only one connection between SNDCP and the peer | |
188 */ | |
189 GLOBAL T_DTI_CONN_LINK_ID gaci_get_link_id_over_peer ( T_DTI_ENTITY_ID entity_id ) | |
190 { | |
191 SHORT i; | |
192 | |
193 for (i = 0; i < MAX_CID; i++) | |
194 { | |
195 if(pdp_context[i].entity_id EQ entity_id) | |
196 { | |
197 return cmhSM_get_link_id_SNDCP_peer((SHORT)(i + 1), SNDCP_PEER_NORMAL); | |
198 } | |
199 } | |
200 return DTI_LINK_ID_NOTPRESENT; | |
201 } | |
202 | |
203 #ifdef FF_SAT_E | |
204 GLOBAL void gaci_SAT_err(USHORT cause) | |
205 { | |
206 SAT_error_cause = cause; | |
207 } | |
208 #endif /* FF_SAT_E */ | |
209 | |
210 GLOBAL void gaci_RAT_caller ( SHORT rat_id, SHORT cid, UBYTE cmdBuf, UBYTE cme_err ) | |
211 { | |
212 T_ACI_CMD_SRC rat_owner = get_owner_over_cid( cid ); | |
213 | |
214 TRACE_FUNCTION("gaci_RAT_caller()"); | |
215 | |
216 #ifdef FF_SAT_E | |
217 if ( !cmhSAT_OpChnGPRSPend( cid, OPCH_NONE )) | |
218 #endif /* FF_SAT_E */ | |
219 { | |
220 switch ( rat_id ) | |
221 { | |
222 case RAT_OK: | |
223 R_AT( RAT_OK, rat_owner ) ( cmdBuf ); | |
224 break; | |
225 case RAT_CME: | |
226 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, cme_err ); /* align aciErrDesc to cme_err */ | |
227 R_AT( RAT_CME, rat_owner ) ( cmdBuf, cme_err ); | |
228 /* log result */ | |
229 cmh_logRslt ( (T_ACI_CMD_SRC) rat_owner, RAT_CME, (T_ACI_AT_CMD) cmdBuf, -1, -1, cme_err ); | |
230 break; | |
231 case RAT_NO_CARRIER: | |
232 if (!(cmhSM_getSrcIdOfRunningCGACTDeactivation(cid) EQ rat_owner)) | |
233 { | |
234 R_AT( RAT_NO_CARRIER, rat_owner ) ( cmdBuf, 0 ); | |
235 } | |
236 /* log result */ | |
237 cmh_logRslt ( (T_ACI_CMD_SRC) rat_owner, RAT_NO_CARRIER, (T_ACI_AT_CMD)cmdBuf, (SHORT) 0, -1, -1 ); | |
238 break; | |
239 } | |
240 } | |
241 #ifdef FF_SAT_E | |
242 else | |
243 { | |
244 /* | |
245 * SIM callback for SAT-class CE | |
246 */ | |
247 switch ( rat_id ) | |
248 { | |
249 case RAT_OK: | |
250 /* connection deactivated */ | |
251 cmhSAT_OpChnGPRSStat(SAT_GPRS_ACT, SAT_GPRS_INV_CAUSE); /* no cause given by primitive */ | |
252 break; | |
253 case RAT_CME: | |
254 if ( cmdBuf EQ AT_CMD_CGDATA ) | |
255 { /* Attach before ATD (SNDCP <-> IP <-> UDP <-> SIM) fails */ | |
256 cmhSAT_OpChnGPRSStat(SAT_GPRS_ATT_FAILED, SAT_error_cause); | |
257 } | |
258 else | |
259 { /* activate connection SNDCP <-> SIM fails */ | |
260 cmhSAT_OpChnGPRSStat(SAT_GPRS_ACT_FAILED, SAT_error_cause); | |
261 } | |
262 break; | |
263 case RAT_NO_CARRIER: | |
264 /* activate connection SNDCP <-> IP <-> UDP <-> SIM fails */ | |
265 cmhSAT_OpChnGPRSStat(SAT_GPRS_ACT_FAILED, SAT_error_cause); | |
266 break; | |
267 } | |
268 } | |
269 #endif /* FF_SAT_E */ | |
270 } | |
271 | |
272 #endif /* GPRS */ |