comparison g23m/condat/ms/src/aci/dcm_state.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-F&D (8411)
4 | Modul : ACI
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 | Description : This file contains Functions corresponding to each state
18 of DCM state machine.
19 +-----------------------------------------------------------------------------
20 */
21
22
23 /*********************************** INCLUDES ********************************/
24 #include "aci_all.h"
25 #include "dcm.h"
26 #include "dcm_utils.h"
27 #include "dcm_state.h"
28 #include "dcm_env.h"
29
30 /**************************** LOCAL VARIABLE DEFINITION **********************/
31 /**************************** EXTERN VARIABLE DEFINITION *********************/
32 extern T_DCM_ENV_CTRL_BLK *dcm_env_ctrl_blk_p;
33
34 /**************************** LOCAL FUCNTION DEFINITION **********************/
35 /************************** EXTERN FUCNTION DEFINITION ***********************/
36
37
38
39 /*******************************************************************************
40 * Function : dcm_idle
41 * Description : Called when DCM state is DCM_IDLE
42 * and DCM has received a message.
43 * Parameter : T_DCM_HDR
44 * -Pointer on the header of the message.
45 * Return : T_DCM_RET
46 * -DCM Result : DCM_OK, DCM_NOT_READY, DCM_UNKNOWN_EVENT
47 *******************************************************************************/
48 T_DCM_RET dcm_idle (T_DCM_HDR * msg_p)
49 {
50 TRACE_FUNCTION("DCM: dcm_idle()");
51
52 if(msg_p->msg_id == DCM_OPEN_CONN_REQ_MSG)
53 {
54 return dcm_process_open_conn_event((T_DCM_OPEN_CONN_REQ_MSG*)msg_p);
55 }
56 else
57 {
58 return dcm_process_unknown_event_in_idle(msg_p);
59 }
60 }
61
62
63 /*******************************************************************************
64 * Function : dcm_activating_conn
65 * Description : Called when DCM state is DCM_ACTIVATING_CONN
66 * and DCM has received a message.
67 * Parameter : T_DCM_HDR
68 * -Pointer on the header of the message.
69 * Return : T_DCM_RET
70 * -DCM Result : DCM_OK, DCM_NOT_READY, DCM_UNKNOWN_EVENT
71 *******************************************************************************/
72 T_DCM_RET dcm_activating_conn(T_DCM_HDR * msg_p)
73 {
74 U8 current_row = dcm_env_ctrl_blk_p->current_row;
75
76 TRACE_FUNCTION("DCM: dcm_activating_conn()");
77
78 switch(dcm_env_ctrl_blk_p->substate[0])
79 {
80 case DCM_SUB_WAIT_CGATT_CNF :
81 dcm_env_ctrl_blk_p->dcm_call_back = NULL;
82 if(msg_p->msg_id == DCM_NEXT_CMD_READY_MSG OR
83 msg_p->msg_id == DCM_NEXT_CMD_STOP_MSG)
84 {
85 return dcm_process_cgatt_ans(msg_p, current_row);
86 }
87 else
88 {
89 return dcm_process_unwaited_events_state_intermediate_conn(msg_p);
90 }
91
92 case DCM_SUB_WAIT_CGACT_CNF :
93 dcm_env_ctrl_blk_p->dcm_call_back = NULL;
94 if(msg_p->msg_id == DCM_NEXT_CMD_READY_MSG OR
95 msg_p->msg_id == DCM_NEXT_CMD_STOP_MSG)
96 {
97 return dcm_process_cgact_ans(msg_p, current_row);
98 }
99 else
100 {
101 return dcm_process_unwaited_events_state_intermediate_conn(msg_p);
102 }
103
104 case DCM_SUB_WAIT_SATDN_CNF:
105 dcm_env_ctrl_blk_p->dcm_call_back = NULL;
106 if(msg_p->msg_id == DCM_NEXT_CMD_READY_MSG OR
107 msg_p->msg_id == DCM_NEXT_CMD_STOP_MSG OR msg_p->msg_id == DCM_ERROR_IND_MSG)
108 {
109 return dcm_process_sat_dn_ans(msg_p, current_row);
110 }
111 else
112 {
113 return dcm_process_unwaited_events_state_intermediate_conn(msg_p);
114 }
115
116 default:
117 return DCM_OK;
118 }
119
120 }
121
122
123 /*******************************************************************************
124 * Function : dcm_conn_activated
125 * Description : if DCM receive message from application or PS,
126 * when DCM state is DCM_CONN_ACTIVATED
127 * this function is called and process reciving message.
128 * Parameter : T_DCM_HDR
129 * -Pointer on the header of the message.
130 * Return : T_DCM_RET
131 * -DCM Result : DCM_OK, DCM_NOT_READY, DCM_UNKNOWN_EVENT
132 *******************************************************************************/
133
134 T_DCM_RET dcm_conn_activated(T_DCM_HDR * msg_p)
135 {
136 U8 current_row = dcm_env_ctrl_blk_p->current_row;
137
138 TRACE_FUNCTION("DCM: dcm_conn_activated()");
139
140 switch(msg_p->msg_id)
141 {
142 case DCM_OPEN_CONN_REQ_MSG:
143 return dcm_process_open_conn_event((T_DCM_OPEN_CONN_REQ_MSG*)msg_p);
144
145 case DCM_CLOSE_CONN_REQ_MSG:
146 return dcm_process_close_conn_event((T_DCM_CLOSE_CONN_REQ_MSG *)msg_p);
147
148 case DCM_ERROR_IND_MSG :
149 return dcm_process_event_error_reception(msg_p);
150
151 default:
152 /* Ignore event - Stay in the same state. */
153 return DCM_UNKNOWN_EVENT;
154 }
155 }
156
157
158 /*******************************************************************************
159 * Function : dcm_closing_conn
160 * Description : if DCM receive message from application or PS,
161 * when DCM state is DCM_CLOSING_CONN
162 * this function is called and process reciving message.
163 * Parameter : T_DCM_HDR
164 * -Pointer on the header of the message.
165 * Return : T_DCM_RET
166 * -DCM Result : DCM_OK, DCM_NOT_READY, DCM_UNKNOWN_EVENT
167 *******************************************************************************/
168 T_DCM_RET dcm_closing_conn(T_DCM_HDR * msg_p )
169 {
170 U8 current_row = dcm_env_ctrl_blk_p->current_row;
171
172 TRACE_FUNCTION("DCM: dcm_closing_conn()");
173
174 switch(dcm_env_ctrl_blk_p->substate[0])
175 {
176 case DCM_SUB_WAIT_CGDEACT_CNF:
177 dcm_env_ctrl_blk_p->dcm_call_back = NULL;
178 if(msg_p->msg_id == DCM_NEXT_CMD_READY_MSG OR
179 msg_p->msg_id == DCM_NEXT_CMD_STOP_MSG)
180 {
181 return dcm_process_cgdeact_ans(msg_p,current_row);
182 }
183 else
184 {
185 return dcm_process_unwaited_events_state_intermediate_conn(msg_p);
186 }
187 /*lint -e527 suppress Warning -- Unreachable */
188 break;
189 /*lint +e527 */
190 case DCM_SUB_WAIT_SATH_CNF:
191 dcm_env_ctrl_blk_p->dcm_call_back = NULL;
192 if(msg_p->msg_id == DCM_NEXT_CMD_READY_MSG OR
193 msg_p->msg_id == DCM_NEXT_CMD_STOP_MSG)
194 {
195 return dcm_process_sat_h_ans(msg_p,current_row);
196 }
197 else
198 {
199 return dcm_process_unwaited_events_state_intermediate_conn(msg_p);
200 }
201 /*lint -e527 suppress Warning -- Unreachable */
202 break;
203 /*lint +e527 */
204 default:
205 return DCM_UNKNOWN_EVENT;
206 }
207
208 }
209
210
211 /******************************************************************************/
212 LOCAL char* state_to_string(U8 state)
213 {
214 switch(state)
215 {
216 case DCM_OFF: return "DCM_OFF";
217 case DCM_IDLE: return "DCM_IDLE";
218 case DCM_ACTIVATING_CONN: return "DCM_ACTIVATING_CONN";
219 case DCM_CONN_ACTIVATED: return "DCM_CONN_ACTIVATED";
220 case DCM_CLOSING_CONN: return "DCM_CLOSING_CONN";
221 default: return "Unkown DCM-state";
222 }
223 }
224
225 LOCAL char* substate_to_string(U8 sub_state)
226 {
227 switch(sub_state)
228 {
229 case DCM_SUB_NO_ACTION: return "DCM_SUB_NO_ACTION";
230 case DCM_SUB_WAIT_CGATT_CNF: return "DCM_SUB_WAIT_CGATT_CNF";
231 case DCM_SUB_WAIT_CGACT_CNF: return "DCM_SUB_WAIT_CGACT_CNF";
232 case DCM_SUB_WAIT_SATDN_CNF: return "DCM_SUB_WAIT_SATDN_CNF";
233 case DCM_SUB_WAIT_SATH_CNF: return "DCM_SUB_WAIT_SATH_CNF";
234 case DCM_SUB_WAIT_CGDEATT_CNF: return "DCM_SUB_WAIT_CGDEATT_CNF";
235 case DCM_SUB_WAIT_CGDEACT_CNF: return "DCM_SUB_WAIT_CGDEACT_CNF";
236 default: return "Unkown DCM-sub_state";
237 }
238 }
239
240
241 void dcm_dispay_state(U8 state, U8 substate)
242 {
243 TRACE_EVENT_P2("DCM: State= %s : Substate= %s", state_to_string(state),
244 substate_to_string(substate));
245 }
246
247 void dcm_dispay_sub_state(U8 substate_1, U8 substate_2)
248 {
249 TRACE_EVENT_P2("DCM: Substate_1= %s : Substate_2= %s" ,
250 substate_to_string(substate_1),substate_to_string(substate_2));
251 }
252
253
254 /**
255 * Function used to change of automaton state
256 *
257 * @param state and associated substate
258 * @return DCM_OK or DCM errors
259 */
260 T_DCM_RET dcm_new_state(U8 state, U8 substate)
261 {
262 TRACE_FUNCTION("DCM: dcm_new_state()");
263 dcm_dispay_state(state, substate);
264
265 dcm_env_ctrl_blk_p->state[0] = state;
266 dcm_env_ctrl_blk_p->substate[0] = substate;
267
268 return DCM_OK;
269 }
270
271
272 /**
273 * Function used to save of automaton state
274 *
275 * @param none
276 * @return DCM_OK or DCM errors
277 */
278 T_DCM_RET dcm_save_state(void)
279 {
280 TRACE_FUNCTION("DCM: dcm_save_state()");
281
282 dcm_env_ctrl_blk_p->state[1] = dcm_env_ctrl_blk_p->state[0];
283 dcm_env_ctrl_blk_p->substate[1] = dcm_env_ctrl_blk_p->substate[0];
284
285 return DCM_OK;
286 }
287
288
289 /**
290 * Function used to restore the automaton state (before saving)
291 *
292 * @param none
293 * @return DCM_OK or DCM errors
294 */
295 T_DCM_RET dcm_restore_state(void)
296 {
297 TRACE_FUNCTION("DCM: dcm_restore_state()");
298 dcm_env_ctrl_blk_p->state[0] = dcm_env_ctrl_blk_p->state[1];
299 dcm_env_ctrl_blk_p->substate[0] = dcm_env_ctrl_blk_p->substate[1];
300
301 return DCM_OK;
302 }
303