1
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /*
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 +-----------------------------------------------------------------------------
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 | Project : GSM-F&D (8411)
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 | Modul : ACI
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 +-----------------------------------------------------------------------------
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 | Copyright 2002 Texas Instruments Berlin, AG
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 | All rights reserved.
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 |
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 | This file is confidential and a trade secret of Texas
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 | Instruments Berlin, AG
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 | The receipt of or possession of this file does not convey
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 | any rights to reproduce or disclose its contents or to
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 | manufacture, use, or sell anything it may describe, in
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 | whole, or in part, without the specific written consent of
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 | Texas Instruments Berlin, AG.
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 +-----------------------------------------------------------------------------
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 | Description : Define dcm_functions to initialize dcm
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 | Define mfw callback function to be used in mfw_cb.c
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 +-----------------------------------------------------------------------------
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 */
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 /*********************** INCLUDES ********************************************/
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 #include "aci_all.h"
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 #include "dcm.h"
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 #include "dcm_utils.h"
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 #include "dcm_state.h"
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 #include "dcm_env.h"
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 /*************** LOCAL VARIABLE DEFINITION ***********************************/
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 /*************** EXTERN VARIABLE DEFINITION **********************************/
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 /*
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 * Pointer on the structure gathering all the global variables
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 * used by DCM instance.
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 */
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 T_DCM_ENV_CTRL_BLK *dcm_env_ctrl_blk_p;
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 /*************** LOCAL FUCNTION DEFINITION ***********************************/
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 static T_DCM_ENV_CTRL_BLK dcm_env_ctrl_blk;
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 /************* EXTERN FUCNTION DEFINITION ************************************/
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 /*******************************************************************************
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 * Function : dcm_start
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 * Parameter : none
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 * Description : dcm main state change to DCM_IDLE
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 *******************************************************************************/
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 LOCAL void dcm_start(void)
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 {
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 TRACE_FUNCTION("DCM: dcm_start()");
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 dcm_new_state(DCM_IDLE, DCM_SUB_NO_ACTION);
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 }
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 /*******************************************************************************
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 * Function : dcm_init
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 * Parameter : none
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 * Description : this function initialize DCM global variable and change dcm main state
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 *******************************************************************************/
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 void dcm_init (void)
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 {
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 TRACE_FUNCTION("DCM: dcm_init()");
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 dcm_env_ctrl_blk_p = &dcm_env_ctrl_blk;
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 memset(dcm_env_ctrl_blk_p, 0x00, sizeof(T_DCM_ENV_CTRL_BLK));
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 dcm_env_ctrl_blk_p->dcm_call_back = NULL;
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 /* initalize main state , sub state */
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 dcm_new_state(DCM_OFF, DCM_SUB_NO_ACTION);
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 /*
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 * dcm start : this means that dcm main state change to DCM IDLE
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 * from now, dcm will be operated if application send request
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 * primitive to DCM
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 */
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 dcm_start();
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 }
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 LOCAL char* message_id_to_string(U8 msg_id)
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 {
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 switch(msg_id)
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 {
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 case DCM_OPEN_CONN_REQ_MSG: return "DCM_OPEN_CONN_REQ_MSG";
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 case DCM_CLOSE_CONN_REQ_MSG: return "DCM_CLOSE_CONN_REQ_MSG";
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 case DCM_GET_CURRENT_CONN_REQ_MSG: return "DCM_GET_CURRENT_CONN_REQ_MSG";
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 case DCM_OPEN_CONN_CNF_MSG: return "DCM_OPEN_CONN_CNF_MSG";
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 case DCM_CLOSE_CONN_CNF_MSG: return "DCM_CLOSE_CONN_CNF_MSG";
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 case DCM_GET_CURRENT_CONN_CNF_MSG: return "DCM_GET_CURRENT_CONN_CNF_MSG";
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 case DCM_ERROR_IND_MSG: return "DCM_ERROR_IND_MSG";
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 case DCM_NEXT_CMD_READY_MSG: return "DCM_NEXT_CMD_READY_MSG";
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 case DCM_NEXT_CMD_STOP_MSG: return "DCM_NEXT_CMD_STOP_MSG";
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 default: return "Unkown Msg_Id";
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 }
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 }
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 void dcm_display_message(U8 msg_id)
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 {
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 TRACE_EVENT_P1("DCM: Message= %s",message_id_to_string(msg_id));
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 }
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 /*******************************************************************************
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 Function : dcm_send_message
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 Parameter : UBYTE
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 Description : this function is used in mfw to send result about AT command to DCM
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 ********************************************************************************/
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 void dcm_send_message(T_DCM_STATUS_IND_MSG msg, T_DCM_INTERNAL_SUBSTATE sub_state)
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 {
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 TRACE_FUNCTION("DCM: dcm_send_message()");
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 /* No need to check state if an error occurs */
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 if(msg.hdr.msg_id == DCM_ERROR_IND_MSG AND dcm_env_ctrl_blk_p->dcm_call_back)
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 {
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 /* FST: Is here a special handling necessary ->
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 see function dcm_mfw_callback(...) above() */
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 (void)dcm_env_ctrl_blk_p->dcm_call_back(&msg.hdr);
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 }
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 else if(msg.hdr.msg_id != DCM_ERROR_IND_MSG AND
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 dcm_env_ctrl_blk_p->dcm_call_back AND
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 dcm_env_ctrl_blk_p->substate[0] == sub_state)
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 {
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 (void)dcm_env_ctrl_blk_p->dcm_call_back(&msg.hdr);
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 }
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 /* This else handles the case if connection has been interrupted due to user
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 or loss of network before connect cnf to app has been sent */
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 else if(msg.hdr.msg_id == DCM_NEXT_CMD_STOP_MSG AND
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 dcm_env_ctrl_blk_p->dcm_call_back AND
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 (dcm_env_ctrl_blk_p->substate[0] == sub_state AND
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 (sub_state == DCM_SUB_WAIT_SATDN_CNF OR sub_state == DCM_SUB_WAIT_CGATT_CNF ) )) //pinghua DCM_OPEN_CLOSE patch 20080429
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 {
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 (void)dcm_env_ctrl_blk_p->dcm_call_back(&msg.hdr);
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 }
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 else if(dcm_env_ctrl_blk_p->state[0] == DCM_IDLE AND
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 dcm_env_ctrl_blk_p->dcm_call_back)
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 {
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 (void)dcm_env_ctrl_blk_p->dcm_call_back(&msg.hdr);
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 }
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 else if(dcm_env_ctrl_blk_p->substate[0] != sub_state)
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 {
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
149 TRACE_ERROR("DCM: Error: mismatch in substate");
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
150 dcm_dispay_sub_state((U8)sub_state,(U8)dcm_env_ctrl_blk_p->substate[0]);
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
151 }
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
152 }
|