FreeCalypso > hg > fc-magnetite
comparison src/g23m-aci/aci/dcm_env.c @ 162:53929b40109c
src/g23m-aci: initial import from TCS3.2/LoCosto
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 11 Oct 2016 02:02:43 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
161:4557e2a9c18e | 162:53929b40109c |
---|---|
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 : Define dcm_functions to initialize dcm | |
18 | Define mfw callback function to be used in mfw_cb.c | |
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 | |
31 /*************** LOCAL VARIABLE DEFINITION ***********************************/ | |
32 | |
33 /*************** EXTERN VARIABLE DEFINITION **********************************/ | |
34 /* | |
35 * Pointer on the structure gathering all the global variables | |
36 * used by DCM instance. | |
37 */ | |
38 T_DCM_ENV_CTRL_BLK *dcm_env_ctrl_blk_p; | |
39 | |
40 /*************** LOCAL FUCNTION DEFINITION ***********************************/ | |
41 static T_DCM_ENV_CTRL_BLK dcm_env_ctrl_blk; | |
42 | |
43 /************* EXTERN FUCNTION DEFINITION ************************************/ | |
44 | |
45 | |
46 /******************************************************************************* | |
47 * Function : dcm_start | |
48 * Parameter : none | |
49 * Description : dcm main state change to DCM_IDLE | |
50 *******************************************************************************/ | |
51 LOCAL void dcm_start(void) | |
52 { | |
53 TRACE_FUNCTION("DCM: dcm_start()"); | |
54 dcm_new_state(DCM_IDLE, DCM_SUB_NO_ACTION); | |
55 } | |
56 | |
57 | |
58 | |
59 /******************************************************************************* | |
60 * Function : dcm_init | |
61 * Parameter : none | |
62 * Description : this function initialize DCM global variable and change dcm main state | |
63 *******************************************************************************/ | |
64 void dcm_init (void) | |
65 { | |
66 TRACE_FUNCTION("DCM: dcm_init()"); | |
67 | |
68 dcm_env_ctrl_blk_p = &dcm_env_ctrl_blk; | |
69 | |
70 memset(dcm_env_ctrl_blk_p, 0x00, sizeof(T_DCM_ENV_CTRL_BLK)); | |
71 dcm_env_ctrl_blk_p->dcm_call_back = NULL; | |
72 | |
73 /* initalize main state , sub state */ | |
74 dcm_new_state(DCM_OFF, DCM_SUB_NO_ACTION); | |
75 | |
76 /* | |
77 * dcm start : this means that dcm main state change to DCM IDLE | |
78 * from now, dcm will be operated if application send request | |
79 * primitive to DCM | |
80 */ | |
81 dcm_start(); | |
82 } | |
83 | |
84 | |
85 LOCAL char* message_id_to_string(U8 msg_id) | |
86 { | |
87 switch(msg_id) | |
88 { | |
89 case DCM_OPEN_CONN_REQ_MSG: return "DCM_OPEN_CONN_REQ_MSG"; | |
90 case DCM_CLOSE_CONN_REQ_MSG: return "DCM_CLOSE_CONN_REQ_MSG"; | |
91 case DCM_GET_CURRENT_CONN_REQ_MSG: return "DCM_GET_CURRENT_CONN_REQ_MSG"; | |
92 case DCM_OPEN_CONN_CNF_MSG: return "DCM_OPEN_CONN_CNF_MSG"; | |
93 case DCM_CLOSE_CONN_CNF_MSG: return "DCM_CLOSE_CONN_CNF_MSG"; | |
94 case DCM_GET_CURRENT_CONN_CNF_MSG: return "DCM_GET_CURRENT_CONN_CNF_MSG"; | |
95 case DCM_ERROR_IND_MSG: return "DCM_ERROR_IND_MSG"; | |
96 case DCM_NEXT_CMD_READY_MSG: return "DCM_NEXT_CMD_READY_MSG"; | |
97 case DCM_NEXT_CMD_STOP_MSG: return "DCM_NEXT_CMD_STOP_MSG"; | |
98 default: return "Unkown Msg_Id"; | |
99 } | |
100 } | |
101 | |
102 void dcm_display_message(U8 msg_id) | |
103 { | |
104 TRACE_EVENT_P1("DCM: Message= %s",message_id_to_string(msg_id)); | |
105 } | |
106 | |
107 | |
108 | |
109 /******************************************************************************* | |
110 Function : dcm_send_message | |
111 Parameter : UBYTE | |
112 Description : this function is used in mfw to send result about AT command to DCM | |
113 ********************************************************************************/ | |
114 void dcm_send_message(T_DCM_STATUS_IND_MSG msg, T_DCM_INTERNAL_SUBSTATE sub_state) | |
115 { | |
116 TRACE_FUNCTION("DCM: dcm_send_message()"); | |
117 | |
118 /* No need to check state if an error occurs */ | |
119 if(msg.hdr.msg_id == DCM_ERROR_IND_MSG AND dcm_env_ctrl_blk_p->dcm_call_back) | |
120 { | |
121 /* FST: Is here a special handling necessary -> | |
122 see function dcm_mfw_callback(...) above() */ | |
123 (void)dcm_env_ctrl_blk_p->dcm_call_back(&msg.hdr); | |
124 | |
125 } | |
126 else if(msg.hdr.msg_id != DCM_ERROR_IND_MSG AND | |
127 dcm_env_ctrl_blk_p->dcm_call_back AND | |
128 dcm_env_ctrl_blk_p->substate[0] == sub_state) | |
129 { | |
130 (void)dcm_env_ctrl_blk_p->dcm_call_back(&msg.hdr); | |
131 } | |
132 | |
133 /* This else handles the case if connection has been interrupted due to user | |
134 or loss of network before connect cnf to app has been sent */ | |
135 else if(msg.hdr.msg_id == DCM_NEXT_CMD_STOP_MSG AND | |
136 dcm_env_ctrl_blk_p->dcm_call_back AND | |
137 (dcm_env_ctrl_blk_p->substate[0] == sub_state AND | |
138 (sub_state == DCM_SUB_WAIT_SATDN_CNF OR sub_state == DCM_SUB_WAIT_CGATT_CNF ) )) //pinghua DCM_OPEN_CLOSE patch 20080429 | |
139 { | |
140 (void)dcm_env_ctrl_blk_p->dcm_call_back(&msg.hdr); | |
141 } | |
142 else if(dcm_env_ctrl_blk_p->state[0] == DCM_IDLE AND | |
143 dcm_env_ctrl_blk_p->dcm_call_back) | |
144 { | |
145 (void)dcm_env_ctrl_blk_p->dcm_call_back(&msg.hdr); | |
146 } | |
147 else if(dcm_env_ctrl_blk_p->substate[0] != sub_state) | |
148 { | |
149 TRACE_ERROR("DCM: Error: mismatch in substate"); | |
150 dcm_dispay_sub_state((U8)sub_state,(U8)dcm_env_ctrl_blk_p->substate[0]); | |
151 } | |
152 } |