FreeCalypso > hg > freecalypso-sw
comparison gsm-fw/g23m-aci/aci/ati_src_rvt.c @ 878:89c70b89dca5
gsm-fw: feature at-rvtmux implemented, compiles
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Sun, 31 May 2015 08:02:36 +0000 |
parents | |
children | 346a15ea8222 |
comparison
equal
deleted
inserted
replaced
877:cd04c43187cd | 878:89c70b89dca5 |
---|---|
1 /* | |
2 * This module is a FreeCalypso addition. Here we are going to implement | |
3 * a mechanism for passing AT commands and responses over RVTMUX. | |
4 */ | |
5 | |
6 #include "config.h" | |
7 #include "fixedconf.h" | |
8 #include "condat-features.h" | |
9 #include "aci_conf.h" | |
10 | |
11 /* includes copied from ati_cmd.c */ | |
12 | |
13 #undef DUMMY_ATI_STRINGS | |
14 | |
15 #include "aci_all.h" | |
16 | |
17 #include "dti.h" /* functionality of the dti library */ | |
18 #include "line_edit.h" /* SKA 2002-09-05 */ | |
19 #include "aci_cmh.h" | |
20 #include "ati_cmd.h" | |
21 #include "aci_io.h" | |
22 #include "aci_cmd.h" | |
23 #include "l4_tim.h" | |
24 | |
25 #include <string.h> | |
26 #include <stdarg.h> | |
27 #include <stdio.h> | |
28 | |
29 #include "psa.h" | |
30 #include "cmh.h" | |
31 | |
32 #include "aci_lst.h" | |
33 #include "dti_conn_mng.h" | |
34 #ifdef UART | |
35 #include "psa_uart.h" | |
36 #endif | |
37 #include "ati_io.h" | |
38 #include "aci_mem.h" | |
39 | |
40 #ifdef SIM_TOOLKIT | |
41 #include "ati_src_sat.h" | |
42 #include "psa_cc.h" | |
43 #include "psa_sat.h" | |
44 #endif /* SIM_TOOLKIT */ | |
45 | |
46 #ifdef GPRS | |
47 #include "gaci_cmh.h" | |
48 #include "gaci_cmd.h" | |
49 #endif /* GPRS */ | |
50 | |
51 #include "aci_prs.h" | |
52 | |
53 | |
54 #ifndef _SIMULATION_ | |
55 #ifdef UART | |
56 #include "cmh_uart.h" | |
57 #endif | |
58 #endif | |
59 | |
60 #include "psa_sms.h" | |
61 #include "aci.h" | |
62 #include "ati_ext_mech.h" | |
63 | |
64 #ifdef FF_ATI_BAT | |
65 #include "ati_bat.h" | |
66 #include "aci_bat.h" | |
67 #endif | |
68 | |
69 EXTERN T_ACI_LIST *ati_src_list; | |
70 | |
71 #include "../../riviera/rvt/rvt_gen.h" | |
72 | |
73 static UBYTE rvt_src_id; | |
74 static T_RVT_USER_ID rvt_user_id; | |
75 | |
76 /* | |
77 * The following function is the callback registered with RVT; it gets | |
78 * called in RVT HISR context. We allocate an ACI_CMD_REQ primitive, | |
79 * copy the received string into it and post it to ACI to be processed | |
80 * in our own task context. | |
81 */ | |
82 GLOBAL void ati_src_rvt_input_callback (T_RVT_BUFFER in_str, UINT16 in_str_len) | |
83 { | |
84 PALLOC (aci_cmd_req, ACI_CMD_REQ); | |
85 | |
86 aci_cmd_req->cmd_src = rvt_src_id; | |
87 aci_cmd_req->cmd_len = in_str_len; | |
88 bcopy(in_str, aci_cmd_req->cmd_seq, in_str_len); | |
89 | |
90 PSENDX (ACI, aci_cmd_req); | |
91 } | |
92 | |
93 /* | |
94 * The following function is called from aci_aci.c when an ACI_CMD_REQ | |
95 * primitive (sent by the previous function) has been received. | |
96 */ | |
97 GLOBAL BOOL ati_src_rvt_proc_cmd (T_ACI_CMD_REQ *aci_cmd_req) | |
98 { | |
99 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, rvt_src_id, | |
100 search_ati_src_id); | |
101 | |
102 ati_user_output_cfg[rvt_src_id].atE = 0; | |
103 | |
104 if (src_params->text_mode EQ CMD_MODE) | |
105 { | |
106 TRACE_FUNCTION ("ati_src_rvt_proc_cmd () CMD MODE"); | |
107 | |
108 aci_cmd_req->cmd_seq[aci_cmd_req->cmd_len] = '\r'; /* make it V.25 ter compatible */ | |
109 aci_cmd_req->cmd_seq[(aci_cmd_req->cmd_len) + 1] = '\0'; | |
110 aci_cmd_req->cmd_len++; | |
111 } | |
112 else /* text has to be terminated by Ctrl-Z */ | |
113 { | |
114 TRACE_FUNCTION ("ati_src_rvt_proc_cmd () TEXT MODE"); | |
115 | |
116 aci_cmd_req->cmd_seq[aci_cmd_req->cmd_len] = 0x1a; /* make it V.25 ter compatible */ | |
117 aci_cmd_req->cmd_seq[(aci_cmd_req->cmd_len) + 1] = '\0'; | |
118 aci_cmd_req->cmd_len++; | |
119 } | |
120 | |
121 return (ati_execute (rvt_src_id, | |
122 aci_cmd_req->cmd_seq, | |
123 aci_cmd_req->cmd_len)); | |
124 } | |
125 | |
126 /* | |
127 * The following function is the callback registered with ATI; it gets | |
128 * called when ATI has something to send to the user. | |
129 */ | |
130 GLOBAL void ati_src_rvt_result_cb (UBYTE src_id, | |
131 T_ATI_OUTPUT_TYPE output_type, | |
132 UBYTE *output, | |
133 USHORT output_len) | |
134 { | |
135 TRACE_FUNCTION ("ati_src_rvt_result_cb ()"); | |
136 rvt_send_trace_cpy (output, rvt_user_id, output_len, RVT_ASCII_FORMAT); | |
137 } | |
138 | |
139 /* | |
140 * The following function is the other callback registered with ATI. | |
141 */ | |
142 GLOBAL void ati_src_rvt_line_state_cb (UBYTE src_id, | |
143 T_ATI_LINE_STATE_TYPE line_state_type, | |
144 ULONG line_state_param) | |
145 { | |
146 TRACE_FUNCTION ("ati_src_rvt_line_state_cb ()"); | |
147 | |
148 switch (line_state_type) | |
149 { | |
150 case ATI_LINE_STATE_OUTPUT_TYPE: | |
151 TRACE_EVENT_P1 ("[DBG] ati_src_rvt_line_state_cb (): ATI_LINE_STATE_OUTPUT_TYPE = %d", line_state_param); | |
152 break; | |
153 | |
154 case ATI_LINE_STATE_DCD: | |
155 TRACE_EVENT_P1 ("[DBG] ati_src_rvt_line_state_cb (): ATI_LINE_STATE_DCD = %d", line_state_param); | |
156 break; | |
157 | |
158 case ATI_LINE_STATE_RNG: /* TODO */ | |
159 { | |
160 T_IO_RING_PARAMS rng_params; | |
161 | |
162 memcpy (&rng_params, (T_IO_RING_PARAMS*)line_state_param, | |
163 sizeof(T_IO_RING_PARAMS)); | |
164 | |
165 TRACE_EVENT_P1 ("[DBG] ati_src_rvt_line_state_cb (): ATI_LINE_STATE_RNG = %d", rng_params.ring_stat); | |
166 | |
167 break; | |
168 } | |
169 | |
170 default: | |
171 TRACE_EVENT_P1 ("[WRN] ati_src_rvt_line_state_cb (): UNKNOWN line_state_type = %d", line_state_type); | |
172 break; | |
173 } | |
174 } | |
175 | |
176 /* | |
177 * The following function is called from ati_cmd_init() in ati_cmd.c | |
178 * to register our mechanism. | |
179 */ | |
180 GLOBAL void ati_src_rvt_register (void) | |
181 { | |
182 rvt_register_id ("AT", &rvt_user_id, ati_src_rvt_input_callback); | |
183 rvt_src_id = ati_init (ATI_SRC_TYPE_TST, | |
184 ati_src_rvt_result_cb, | |
185 ati_src_rvt_line_state_cb); | |
186 } |