comparison gsm-fw/g23m-aci/aci/dcm_state.c @ 775:eedbf248bac0

gsm-fw/g23m-aci subtree: initial import from LoCosto source
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 12 Oct 2014 01:45:14 +0000
parents
children
comparison
equal deleted inserted replaced
774:40a721fd9854 775:eedbf248bac0
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
137 TRACE_FUNCTION("DCM: dcm_conn_activated()");
138
139 switch(msg_p->msg_id)
140 {
141 case DCM_OPEN_CONN_REQ_MSG:
142 return dcm_process_open_conn_event((T_DCM_OPEN_CONN_REQ_MSG*)msg_p);
143
144 case DCM_CLOSE_CONN_REQ_MSG:
145 return dcm_process_close_conn_event((T_DCM_CLOSE_CONN_REQ_MSG *)msg_p);
146
147 case DCM_ERROR_IND_MSG :
148 return dcm_process_event_error_reception(msg_p);
149
150 default:
151 /* Ignore event - Stay in the same state. */
152 return DCM_UNKNOWN_EVENT;
153 }
154 }
155
156
157 /*******************************************************************************
158 * Function : dcm_closing_conn
159 * Description : if DCM receive message from application or PS,
160 * when DCM state is DCM_CLOSING_CONN
161 * this function is called and process reciving message.
162 * Parameter : T_DCM_HDR
163 * -Pointer on the header of the message.
164 * Return : T_DCM_RET
165 * -DCM Result : DCM_OK, DCM_NOT_READY, DCM_UNKNOWN_EVENT
166 *******************************************************************************/
167 T_DCM_RET dcm_closing_conn(T_DCM_HDR * msg_p )
168 {
169 U8 current_row = dcm_env_ctrl_blk_p->current_row;
170
171 TRACE_FUNCTION("DCM: dcm_closing_conn()");
172
173 switch(dcm_env_ctrl_blk_p->substate[0])
174 {
175 case DCM_SUB_WAIT_CGDEACT_CNF:
176 // dcm_env_ctrl_blk_p->dcm_call_back = NULL; //pinghua DCM_OPEN_CLOSE patch 20080429
177 if(msg_p->msg_id == DCM_NEXT_CMD_READY_MSG OR
178 msg_p->msg_id == DCM_NEXT_CMD_STOP_MSG)
179 {
180 dcm_env_ctrl_blk_p->dcm_call_back = NULL; //pinghua DCM_OPEN_CLOSE patch 20080429
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 is removed ,as case is returning before break so it is not needed */
189 /*lint +e527 */
190 case DCM_SUB_WAIT_SATH_CNF:
191 // dcm_env_ctrl_blk_p->dcm_call_back = NULL; //pinghua DCM_OPEN_CLOSE patch 20080429
192 if(msg_p->msg_id == DCM_NEXT_CMD_READY_MSG OR
193 msg_p->msg_id == DCM_NEXT_CMD_STOP_MSG)
194 {
195 dcm_env_ctrl_blk_p->dcm_call_back = NULL; //pinghua DCM_OPEN_CLOSE patch 20080429
196 return dcm_process_sat_h_ans(msg_p,current_row);
197 }
198 else
199 {
200 return dcm_process_unwaited_events_state_intermediate_conn(msg_p);
201 }
202 /*lint -e527 suppress Warning -- Unreachable */
203 /* break is removed ,as case is returning before break so it is not needed */
204 /*lint +e527 */
205 default:
206 return DCM_UNKNOWN_EVENT;
207 }
208
209 }
210
211
212 /******************************************************************************/
213 LOCAL char* state_to_string(U8 state)
214 {
215 switch(state)
216 {
217 case DCM_OFF: return "DCM_OFF";
218 case DCM_IDLE: return "DCM_IDLE";
219 case DCM_ACTIVATING_CONN: return "DCM_ACTIVATING_CONN";
220 case DCM_CONN_ACTIVATED: return "DCM_CONN_ACTIVATED";
221 case DCM_CLOSING_CONN: return "DCM_CLOSING_CONN";
222 default: return "Unkown DCM-state";
223 }
224 }
225
226 LOCAL char* substate_to_string(U8 sub_state)
227 {
228 switch(sub_state)
229 {
230 case DCM_SUB_NO_ACTION: return "DCM_SUB_NO_ACTION";
231 case DCM_SUB_WAIT_CGATT_CNF: return "DCM_SUB_WAIT_CGATT_CNF";
232 case DCM_SUB_WAIT_CGACT_CNF: return "DCM_SUB_WAIT_CGACT_CNF";
233 case DCM_SUB_WAIT_SATDN_CNF: return "DCM_SUB_WAIT_SATDN_CNF";
234 case DCM_SUB_WAIT_SATH_CNF: return "DCM_SUB_WAIT_SATH_CNF";
235 case DCM_SUB_WAIT_CGDEATT_CNF: return "DCM_SUB_WAIT_CGDEATT_CNF";
236 case DCM_SUB_WAIT_CGDEACT_CNF: return "DCM_SUB_WAIT_CGDEACT_CNF";
237 default: return "Unkown DCM-sub_state";
238 }
239 }
240
241
242 void dcm_dispay_state(U8 state, U8 substate)
243 {
244 TRACE_EVENT_P2("DCM: State= %s : Substate= %s", state_to_string(state),
245 substate_to_string(substate));
246 }
247
248 void dcm_dispay_sub_state(U8 substate_1, U8 substate_2)
249 {
250 TRACE_EVENT_P2("DCM: Substate_1= %s : Substate_2= %s" ,
251 substate_to_string(substate_1),substate_to_string(substate_2));
252 }
253
254
255 /**
256 * Function used to change of automaton state
257 *
258 * @param state and associated substate
259 * @return DCM_OK or DCM errors
260 */
261 T_DCM_RET dcm_new_state(U8 state, U8 substate)
262 {
263 TRACE_FUNCTION("DCM: dcm_new_state()");
264 dcm_dispay_state(state, substate);
265
266 dcm_env_ctrl_blk_p->state[0] = (T_DCM_INTERNAL_STATE)state;
267 dcm_env_ctrl_blk_p->substate[0] = (T_DCM_INTERNAL_SUBSTATE)substate;
268
269 return DCM_OK;
270 }
271
272
273 /**
274 * Function used to save of automaton state
275 *
276 * @param none
277 * @return DCM_OK or DCM errors
278 */
279 T_DCM_RET dcm_save_state(void)
280 {
281 TRACE_FUNCTION("DCM: dcm_save_state()");
282
283 dcm_env_ctrl_blk_p->state[1] = dcm_env_ctrl_blk_p->state[0];
284 dcm_env_ctrl_blk_p->substate[1] = dcm_env_ctrl_blk_p->substate[0];
285
286 return DCM_OK;
287 }
288
289
290 /**
291 * Function used to restore the automaton state (before saving)
292 *
293 * @param none
294 * @return DCM_OK or DCM errors
295 */
296 T_DCM_RET dcm_restore_state(void)
297 {
298 TRACE_FUNCTION("DCM: dcm_restore_state()");
299 dcm_env_ctrl_blk_p->state[0] = dcm_env_ctrl_blk_p->state[1];
300 dcm_env_ctrl_blk_p->substate[0] = dcm_env_ctrl_blk_p->substate[1];
301
302 return DCM_OK;
303 }
304