FreeCalypso > hg > leo2moko-debug
comparison g23m/condat/ms/src/aci/ati_omcompat.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 * This module has been added to the Leonardo GSM firmware source by | |
3 * Spacefalcon the Outlaw. It contains the implementation of the AT@ | |
4 * commands which were invented by Openmoko. The addition of this code | |
5 * to the present leo2moko source tree allows our fw to serve as a | |
6 * compatible and fully functional replacement for the closed original | |
7 * mokoN firmware. | |
8 */ | |
9 | |
10 #ifndef ATI_OMCOMPAT_C | |
11 #define ATI_OMCOMPAT_C | |
12 | |
13 #include "aci_all.h" | |
14 | |
15 #include <ctype.h> | |
16 #include <string.h> | |
17 | |
18 #include "aci_cmh.h" | |
19 #include "ati_cmd.h" | |
20 #include "aci_cmd.h" | |
21 #include "aci_io.h" | |
22 #include "aci_cmd.h" | |
23 #include "l4_tim.h" | |
24 #include "line_edit.h" | |
25 #include "aci_lst.h" | |
26 | |
27 #include "pcm.h" | |
28 #include "audio.h" | |
29 #include "aci.h" | |
30 #include "rx.h" | |
31 #include "pwr.h" | |
32 #include "l4_tim.h" | |
33 | |
34 #ifdef GPRS | |
35 #ifdef DTI | |
36 #include "dti.h" | |
37 #include "dti_conn_mng.h" | |
38 #include "dti_cntrl_mng.h" | |
39 #endif /* DTI */ | |
40 #include "gaci.h" | |
41 #include "gaci_cmh.h" | |
42 #include "gaci_cmd.h" | |
43 #endif /* GPRS */ | |
44 | |
45 #include "aci_mem.h" | |
46 #include "aci_prs.h" | |
47 | |
48 #include "ati_int.h" | |
49 | |
50 #ifndef _SIMULATION_ | |
51 #include "ffs\ffs.h" | |
52 #endif | |
53 | |
54 #ifdef FF_ATI_BAT | |
55 | |
56 #include "typedefs.h" | |
57 #include "gdd.h" | |
58 #include "bat.h" | |
59 | |
60 #include "ati_bat.h" | |
61 | |
62 #endif /*FF_ATI_BAT*/ | |
63 | |
64 #include "audio\audio_api.h" | |
65 #include "abb.h" | |
66 #include "..\drivers\drv_app\power\power.h" | |
67 | |
68 #ifdef GPRS | |
69 #include "p_mph.h" | |
70 #include "p_mphc.h" | |
71 #include "..\alr\alr_gprs.h" | |
72 #endif | |
73 #include "p_tb.h" | |
74 #include "..\alr\alr.h" | |
75 | |
76 /* | |
77 * PURPOSE : @ST command (Configure the sidetone level) | |
78 */ | |
79 GLOBAL T_ATI_RSLT atAtST (char *cl, UBYTE srcId) | |
80 { | |
81 T_ACI_RETURN ret = AT_FAIL; | |
82 char tmp[8]={0}; | |
83 INT8 gain = -26; | |
84 TRACE_FUNCTION("atAtST()"); | |
85 | |
86 /* | |
87 * input functionality | |
88 */ | |
89 cl = parse(cl,"s", (LONG)8, tmp); | |
90 | |
91 gain = atoi(tmp); | |
92 | |
93 if ( cl ) | |
94 { | |
95 if ( gain == -23 || gain == -20 || gain == -17 || gain == -14 || gain == -11 || gain == -8 || gain == -5 || gain == -2 || gain == 1 || gain == -26 ) | |
96 { | |
97 Side_Tone_Write(gain); | |
98 return (ATI_CMPL); | |
99 } | |
100 else | |
101 { | |
102 cmdCmsError(CMS_ERR_OpNotAllowed); | |
103 return (ATI_FAIL); | |
104 } | |
105 } | |
106 } | |
107 | |
108 GLOBAL T_ATI_RSLT queatAtST (char *cl, UBYTE srcId) | |
109 { | |
110 char *me="+ST: "; | |
111 INT8 ST1; | |
112 T_ACI_RETURN ret = AT_FAIL; | |
113 | |
114 TRACE_FUNCTION("queatAtST()"); | |
115 | |
116 ST1 = Side_Tone_Read(); | |
117 | |
118 sprintf(g_sa,"%s%d",me,ST1); | |
119 | |
120 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT); | |
121 | |
122 return (ATI_CMPL); | |
123 | |
124 } | |
125 | |
126 /* | |
127 * PURPOSE : @AUL command (Audio table load) | |
128 */ | |
129 | |
130 static char tmp[8]={0}; | |
131 | |
132 GLOBAL T_ATI_RSLT atAtAUL (char *cl, UBYTE srcId) | |
133 { | |
134 T_ACI_RETURN ret = AT_FAIL; | |
135 T_AUDIO_MODE_LOAD audio_mode_load_parameter; | |
136 T_RV_RETURN return_path; | |
137 | |
138 /* initalize the return path, for this test the return path is an message */ | |
139 return_path.callback_func = NULL; | |
140 return_path.addr_id = rvf_get_taskid(); | |
141 | |
142 TRACE_FUNCTION("atAtAUL()"); | |
143 | |
144 /* | |
145 * input functionality | |
146 */ | |
147 cl = parse(cl,"s", (LONG)8, tmp); | |
148 | |
149 sprintf(audio_mode_load_parameter.audio_mode_filename, "para%s", tmp); | |
150 | |
151 if ( audio_mode_load(&audio_mode_load_parameter, return_path) == AUDIO_ERROR ) | |
152 return (ATI_FAIL); | |
153 else | |
154 return (ATI_CMPL); | |
155 | |
156 } | |
157 | |
158 GLOBAL T_ATI_RSLT queatAtAUL (char *cl, UBYTE srcId) | |
159 { | |
160 char *me="@AUL: "; | |
161 T_ACI_RETURN ret = AT_FAIL; | |
162 | |
163 TRACE_FUNCTION("queatAtAUL()"); | |
164 | |
165 if (strlen(tmp)) | |
166 sprintf(g_sa,"%s/aud/para%s.cfg",me, tmp); | |
167 else | |
168 sprintf(g_sa,"%s",me); | |
169 | |
170 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT); | |
171 | |
172 return (ATI_CMPL); | |
173 | |
174 } | |
175 | |
176 /* | |
177 * PURPOSE : @POFF command (Power Off GSM Modem) | |
178 */ | |
179 | |
180 GLOBAL T_ATI_RSLT atAtPOFF (char *cl, UBYTE srcId) | |
181 { | |
182 TRACE_FUNCTION("atAtPOFF"); | |
183 | |
184 sprintf(g_sa,"%s","OK"); | |
185 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT); | |
186 | |
187 ABB_Power_Off(); | |
188 | |
189 return (ATI_CMPL); | |
190 } | |
191 | |
192 /* | |
193 * PURPOSE : @RST command (Reset GSM Modem) | |
194 */ | |
195 | |
196 GLOBAL T_ATI_RSLT atAtRST (char *cl, UBYTE srcId) | |
197 { | |
198 TRACE_FUNCTION("atAtRST"); | |
199 | |
200 Power_OFF_Button(); | |
201 | |
202 return (ATI_CMPL); | |
203 } | |
204 | |
205 /* | |
206 * Openmoko's firmware contains an undocumented AT@SC command that | |
207 * sets/changes the IMEI of the modem. However, it takes the IMEI | |
208 * input in an obfuscated form, and the implementation code is | |
209 * rather ugly - hence I don't feel like reimplementing it here. | |
210 * | |
211 * If you feel like changing your modem's IMEI, you can do it quite | |
212 * easily with FreeCalypso tools: use fc-loadtool to read the FFS | |
213 * sectors out of flash, then mpffs-edit to change the /pcm/IMEI file | |
214 * in the FFS image, then fc-loadtool again to program the modified | |
215 * FFS image back into flash. | |
216 */ | |
217 | |
218 GLOBAL T_ATI_RSLT atAtSC (char *cl, UBYTE srcId) | |
219 { | |
220 TRACE_FUNCTION("atAtSC"); | |
221 | |
222 return (ATI_FAIL); | |
223 } | |
224 | |
225 /* | |
226 * PURPOSE : @BAND command (Get RF band) | |
227 */ | |
228 | |
229 GLOBAL T_ATI_RSLT atAtBAND (char *cl, UBYTE srcId) | |
230 { | |
231 char szDummy[32]; // to produce the exact same assembler code | |
232 char szBand[32]; | |
233 UBYTE band_sc = get_band (alr_data->serving_cell); // to produce the exact same assembler code | |
234 | |
235 TRACE_FUNCTION("atAtBAND"); | |
236 band_sc = alr_data->sc_band; | |
237 switch(band_sc) | |
238 { | |
239 case BAND_GSM_900: | |
240 strcpy(szBand, "GSM 900"); | |
241 break; | |
242 case BAND_DCS_1800: | |
243 strcpy(szBand, "DCS 1800"); | |
244 break; | |
245 case BAND_PCS_1900: | |
246 strcpy(szBand, "PCS 1900"); | |
247 break; | |
248 case BAND_E_GSM: | |
249 strcpy(szBand, "EGSM"); | |
250 break; | |
251 case BAND_GSM_850: | |
252 strcpy(szBand, "GSM 850"); | |
253 break; | |
254 default: | |
255 strcpy(szBand, "Unknown"); | |
256 break; | |
257 } | |
258 sprintf(g_sa,"%s", szBand); | |
259 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT); | |
260 | |
261 return (ATI_CMPL); | |
262 } | |
263 | |
264 #endif /* ATI_OMCOMPAT_C */ | |
265 |