comparison g23m-aci/aci/aci_util.c @ 0:75a11d740a02

initial import of gsm-fw from freecalypso-sw rev 1033:5ab737ac3ad7
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 09 Jun 2016 00:02:41 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:75a11d740a02
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : GSM-PS (6147)
4 | Modul : ACI_UTIL
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 | Purpose : This module defines the utility functions for the AT
18 | command interpreter.
19 +-----------------------------------------------------------------------------
20 */
21
22
23
24 #ifndef ACI_UTIL_C
25 #define ACI_UTIL_C
26 #endif
27
28 #include "config.h"
29 #include "fixedconf.h"
30 #include "condat-features.h"
31 #include "aci_conf.h"
32
33 #include "aci_all.h"
34
35 #include "aci_cmh.h"
36 #include "ati_cmd.h"
37
38 #include "aci_cmd.h"
39
40 #ifdef FAX_AND_DATA
41 #include "aci_fd.h"
42 #endif /* of #ifdef FAX_AND_DATA */
43
44 #include "psa.h"
45 #include "psa_sms.h"
46 #include "phb.h"
47 #include "cmh.h"
48 #include "cmh_sms.h"
49
50 #if defined (FF_ATI) || defined (FF_BAT)
51 #include "aci_mem.h"
52 #include "aci_lst.h"
53 #include "aci_io.h"
54 #include "ksd.h"
55 #include "cmh_ss.h"
56 #include "psa_ss.h"
57 #endif
58 #ifdef FF_ATI
59 #include "ati_int.h"
60 #endif
61 #ifdef FF_BAT
62 #include "aci_bat_cb.h"
63 #endif
64
65 #ifdef GPRS
66 #include "gaci_cmh.h"
67 #endif /* GPRS */
68
69 #ifdef TI_PS_OP_CNV_TAB_ROMBASED
70 #include "rom_tables.h"
71 #endif /* TI_PS_OP_CNV_TAB_ROMBASED */
72
73
74 #ifdef TI_PS_OP_CNV_TAB_ROMBASED
75 /* If this flag is enabled CSCS_CHSET_Chars is defined in rom_tables.h file */
76 #else
77 #define CSCS_CHSET_Chars 256
78 #endif
79
80 /*==== CONSTANTS ==================================================*/
81 #ifdef REL99
82 #define NUM_EXT_TABLE_CHARS 9
83 #define NUM_IRA_8859_TABLE_CHARS 1
84 #endif
85
86
87 /*==== TYPES ======================================================*/
88
89 /*==== EXPORT =====================================================*/
90 /* This fucntion cuts the pathname from the file
91 used by ACI_ASSERT makro*/
92 GLOBAL char * getFileName(char * file)
93 {
94 char *cursor = file;
95 do {
96 #ifdef _SIMULATION_
97 if(*cursor EQ '\\') { file = cursor+1;}
98 #else
99 if(*cursor EQ '/') { file = cursor+1;}
100 #endif
101 cursor++;
102 } while(*cursor NEQ '\0');
103 return file;
104 }
105
106
107 LOCAL USHORT utl_ucs2FromGsm ( UBYTE* in,
108 USHORT inLen,
109 UBYTE* out,
110 USHORT maxOutLen,
111 USHORT* outLen,
112 T_ACI_GSM_ALPHA gsm,
113 T_ACI_CSCS_ALPHA alphabet );
114
115 /*==== VARIABLES ==================================================*/
116 #ifdef TI_PS_OP_CNV_TAB_ROMBASED
117 /* Changes for ROM data */
118 /* NHK:
119 * Once the tables chset and gsmToAsciiTable go to ROM, their names below should match corresponding ROM addresses
120 * KSR: Moved to g23m\condat\com\src\drivers\rom_tables
121 */
122 #else
123 GLOBAL const UBYTE chset [CSCS_CHSET_Tables][CSCS_CHSET_Chars] =
124 {
125 /*
126 *-------------------------------------------------------------------
127 * Conversion table: IRA -> internal GSM
128 *-------------------------------------------------------------------
129 */
130 /* 0x00 */ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
131 /* 0x08 */ 0x00, 0x00, 0x8A, 0x00, 0x00, 0x8D, 0x00, 0x00,
132 /* 0x10 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
133 /* 0x18 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
134 /* 0x20 */ 0xA0, 0xA1, 0xA2, 0xA3, 0x82, 0xA5, 0xA6, 0xA7,
135 /* 0x28 */ 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF,
136 /* 0x30 */ 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7,
137 /* 0x38 */ 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF,
138 /* 0x40 */ 0x80, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
139 /* 0x48 */ 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF,
140 /* 0x50 */ 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7,
141 /* 0x58 */ 0xD8, 0xD9, 0xDA, 0x00, 0x00, 0x00, 0x00, 0x91/*00*/,
142 /* 0x60 */ 0x00, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7,
143 /* 0x68 */ 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF,
144 /* 0x70 */ 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7,
145 /* 0x78 */ 0xF8, 0xF9, 0xFA, 0x00, 0x00, 0x00, 0x00, 0x00,
146 /* 0x80 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
147 /* 0x88 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
148 /* 0x90 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
149 /* 0x98 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
150 /* 0xA0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
151 /* 0xA8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
152 /* 0xB0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
153 /* 0xB8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
154 /* 0xC0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
155 /* 0xC8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
156 /* 0xD0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
157 /* 0xD8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
158 /* 0xE0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
159 /* 0xE8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
160 /* 0xF0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
161 /* 0xF8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
162
163 /*
164 *-------------------------------------------------------------------
165 * Conversion table: PC Danish/Norwegian -> internal GSM
166 *-------------------------------------------------------------------
167 */
168 /* 0x00 */ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
169 /* 0x08 */ 0x00, 0x00, 0x8A, 0x00, 0x00, 0x8D, 0x00, 0x00,
170 /* 0x10 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0xDF, 0x00, 0x00,
171 /* 0x18 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
172 /* 0x20 */ 0xA0, 0xA1, 0xA2, 0xA3, 0x82, 0xA5, 0xA6, 0xA7,
173 /* 0x28 */ 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF,
174 /* 0x30 */ 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7,
175 /* 0x38 */ 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF,
176 /* 0x40 */ 0x80, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
177 /* 0x48 */ 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF,
178 /* 0x50 */ 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7,
179 /* 0x58 */ 0xD8, 0xD9, 0xDA, 0x00, 0x00, 0x00, 0x00, 0x91/*00*/,
180 /* 0x60 */ 0x00, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7,
181 /* 0x68 */ 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF,
182 /* 0x70 */ 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7,
183 /* 0x78 */ 0xF8, 0xF9, 0xFA, 0x00, 0x00, 0x00, 0x00, 0x00,
184 /* 0x80 */ 0x89, 0xFE, 0x85, 0xE1, 0xFB, 0xFF, 0x8F, 0x89,
185 /* 0x88 */ 0xE5, 0xE5, 0x84, 0xE9, 0xE9, 0x87, 0xDB, 0x8E,
186 /* 0x90 */ 0x9F/*C5*/, 0x9D, 0x9C, 0xEF, 0xFC, 0x88, 0xF5/*E5*/, 0x86,
187 /* 0x98 */ 0xF9/*E9*/, 0xDC, 0xDE, 0x8C, 0x81, 0x8B, 0x00, 0x00,
188 /* 0xA0 */ 0xE1, 0xE9, 0xEF, 0xF5, 0xFD, 0xDD, 0x00, 0x00,
189 /* 0xA8 */ 0xE0, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00,
190 /* 0xB0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
191 /* 0xB8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
192 /* 0xC0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
193 /* 0xC8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
194 /* 0xD0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
195 /* 0xD8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
196 /* 0xE0 */ 0x00, 0x9E, 0x93, 0x00, 0x98, 0x00, 0x00, 0x00,
197 /* 0xE8 */ 0x92, 0x99, 0x95, 0x00, 0x00, 0x00, 0x00, 0x00,
198 /* 0xF0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
199 /* 0xF8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
200
201 /*
202 *-------------------------------------------------------------------
203 * Conversion table: ISO 8859 Latin 1 -> internal GSM
204 *-------------------------------------------------------------------
205 */
206 /* 0x00 */ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
207 /* 0x08 */ 0x00, 0x00, 0x8A, 0x00, 0x00, 0x8D, 0x00, 0x00,
208 /* 0x10 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
209 /* 0x18 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
210 /* 0x20 */ 0xA0, 0xA1, 0xA2, 0xA3, 0x82, 0xA5, 0xA6, 0xA7,
211 /* 0x28 */ 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF,
212 /* 0x30 */ 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7,
213 /* 0x38 */ 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF,
214 /* 0x40 */ 0x80, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
215 /* 0x48 */ 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF,
216 /* 0x50 */ 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7,
217 /* 0x58 */ 0xD8, 0xD9, 0xDA, 0x00, 0x00, 0x00, 0x00, 0x91/*00*/,
218 /* 0x60 */ 0x00, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7,
219 /* 0x68 */ 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF,
220 /* 0x70 */ 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7,
221 /* 0x78 */ 0xF8, 0xF9, 0xFA, 0x00, 0x00, 0x00, 0x00, 0x00,
222 /* 0x80 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
223 /* 0x88 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
224 /* 0x90 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
225 /* 0x98 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
226 /* 0xA0 */ 0x00, 0xC0, 0x00, 0x81, 0xA4, 0x83, 0x00, 0xDF,
227 /* 0xA8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
228 /* 0xB0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
229 /* 0xB8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0,
230 /* 0xC0 */ 0xC1, 0xC1, 0xC1, 0xC1, 0xDB, 0x8E, 0x9C, 0x89,
231 /* 0xC8 */ 0xC5, 0x9F/*C5*/, 0xC5, 0xC5, 0xC9, 0xC9, 0xC9, 0xC9,
232 /* 0xD0 */ 0x00, 0xDD, 0xCF, 0xCF, 0xCF, 0xCF, 0xDC, 0x00,
233 /* 0xD8 */ 0x8B, 0xD5, 0xD5, 0xD5, 0xDE, 0xD9, 0x00, 0x9E,
234 /* 0xE0 */ 0xFF, 0xE1, 0xE1, 0xE1, 0xFB, 0x8F, 0x9D, 0x89,
235 /* 0xE8 */ 0x84, 0x85, 0xE5, 0xE5, 0x87, 0xE9, 0xE9, 0xE9,
236 /* 0xF0 */ 0x00, 0xFD, 0x88, 0xEF, 0xEF, 0xEF, 0xFC, 0x00,
237 /* 0xF8 */ 0x8C, 0x86, 0xF5, 0xF5, 0xFE, 0xF9, 0x00, 0xF9 },
238
239 /*
240 *-------------------------------------------------------------------
241 * Conversion table: PC Code Page 437 -> internal GSM
242 *-------------------------------------------------------------------
243 */
244 /* 0x00 */ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
245 /* 0x08 */ 0x00, 0x00, 0x8A, 0x00, 0x00, 0x8D, 0x00, 0x00,
246 /* 0x10 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0xDF, 0x00, 0x00,
247 /* 0x18 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
248 /* 0x20 */ 0xA0, 0xA1, 0xA2, 0xA3, 0x82, 0xA5, 0xA6, 0xA7,
249 /* 0x28 */ 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF,
250 /* 0x30 */ 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7,
251 /* 0x38 */ 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF,
252 /* 0x40 */ 0x80, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
253 /* 0x48 */ 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF,
254 /* 0x50 */ 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7,
255 /* 0x58 */ 0xD8, 0xD9, 0xDA, 0x00, 0x00, 0x00, 0x00, 0x91/*00*/,
256 /* 0x60 */ 0x00, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7,
257 /* 0x68 */ 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF,
258 /* 0x70 */ 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7,
259 /* 0x78 */ 0xF8, 0xF9, 0xFA, 0x00, 0x00, 0x00, 0x00, 0x00,
260 /* 0x80 */ 0x89, 0xFE, 0x85, 0xE1, 0xFB, 0xFF, 0x8F, 0x89,
261 /* 0x88 */ 0xE5, 0xE5, 0x84, 0xE9, 0xE9, 0x87, 0xDB, 0x8E,
262 /* 0x90 */ 0x9F/*C5*/, 0x9D, 0x9C, 0xEF, 0xFC, 0x88, 0xF5/*E5*/, 0x86,
263 /* 0x98 */ 0xF9/*E9*/, 0xDC, 0xDE, 0x00, 0x81, 0x83, 0x00, 0x00,
264 /* 0xA0 */ 0xE1, 0xE9, 0xEF, 0xF5, 0xFD, 0xDD, 0x00, 0x00,
265 /* 0xA8 */ 0xE0, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00,
266 /* 0xB0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
267 /* 0xB8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
268 /* 0xC0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
269 /* 0xC8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
270 /* 0xD0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
271 /* 0xD8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
272 /* 0xE0 */ 0x00, 0x9E, 0x93, 0x00, 0x98, 0x00, 0x00, 0x00,
273 /* 0xE8 */ 0x92, 0x99, 0x95, 0x00, 0x00, 0x00, 0x00, 0x00,
274 /* 0xF0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
275 /* 0xF8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
276
277 /*
278 *-------------------------------------------------------------------
279 * Conversion table: GSM -> internal GSM
280 *-------------------------------------------------------------------
281 */
282 /* 0x00 */ { 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
283 /* 0x08 */ 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F,
284 /* 0x10 */ 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
285 /* 0x18 */ 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F,
286 /* 0x20 */ 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7,
287 /* 0x28 */ 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF,
288 /* 0x30 */ 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7,
289 /* 0x38 */ 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF,
290 /* 0x40 */ 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
291 /* 0x48 */ 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF,
292 /* 0x50 */ 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7,
293 /* 0x58 */ 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF,
294 /* 0x60 */ 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7,
295 /* 0x68 */ 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF,
296 /* 0x70 */ 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7,
297 /* 0x78 */ 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF,
298 /* 0x80 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
299 /* 0x88 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
300 /* 0x90 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
301 /* 0x98 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
302 /* 0xA0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
303 /* 0xA8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
304 /* 0xB0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
305 /* 0xB8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
306 /* 0xC0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
307 /* 0xC8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
308 /* 0xD0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
309 /* 0xD8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
310 /* 0xE0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
311 /* 0xE8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
312 /* 0xF0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
313 /* 0xF8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
314 };
315
316
317 /*
318 *-------------------------------------------------------------------
319 * Conversion table: ASCII <-> internal GSM
320 * ( needed for the conversion of UCS2 <-> internal GSM )
321 *-------------------------------------------------------------------
322 */
323 /* GSM alphabet characters unknown in the ASCII table have been
324 replaced by <SP> characters */
325 LOCAL const UBYTE gsmToAsciiTable[128] =
326 {
327 /*n = 0 1 2 3 4 5 6 7 8 9 A B C D E F */
328 /* 0x0n */ 64,163, 36,165,232,233,249,236,242,199, 10,216,248, 13,197,229,
329 /* 0x1n */ 128, 95,129,130,131,132,133,134,135,136,137, 27,198,230,223,201,
330 /* 0x2n */ 32, 33, 34, 35,164, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
331 /* 0x3n */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
332 /* 0x4n */ 161, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
333 /* 0x5n */ 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,196,214,209,220,167,
334 /* 0x6n */ 191, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111,
335 /* 0x7n */ 112,113,114,115,116,117,118,119,120,121,122,228,246,241,252,224
336 };
337
338 LOCAL const UBYTE hexVal[] = {"0123456789ABCDEF"};
339
340 #endif
341
342 /*
343 * These tables are moved out of TI_PS_OP_CNV_TAB_ROMBASED
344 */
345
346 #ifdef REL99
347 /*
348 *-------------------------------------------------------------------
349 * Conversion table: Extension character table that can be used for
350 mapping IRA or PC D/N or ISO 8859 Latin 1 or PCCP 437
351 characters to GSM 7 extension table characters
352 * The first column contains the GSM 7 extension table character value and
353 * the second column contains the corresponding character in the other
354 * character sets
355 * Ref: 23.038 Sec 6.2.1.1
356 *-------------------------------------------------------------------
357 */
358 GLOBAL const UBYTE ext_common_chset_map [NUM_EXT_TABLE_CHARS][2] =
359 {
360 { 0x14, 0x5E }, /* ^ */
361 { 0x1B, 0x20 }, /* Reserved for another extension table. To be replaced by space */
362 { 0x28, 0x7B }, /* { */
363 { 0x29, 0x7D }, /* } */
364 { 0x2F, 0x5C }, /* \ */
365 { 0x3C, 0x5B }, /* [ */
366 { 0x3D, 0x7E }, /* ~ */
367 { 0x3E, 0x5D }, /* ] */
368 { 0x40, 0x7C } /* | */
369 };
370
371 /*
372 *-------------------------------------------------------------------
373 * Conversion table: Extension table character that is used only for
374 IRA OR ISO 8859 Latin 1, in addition to the character table given
375 above.
376 * Ref: 23.038 Sec 6.2.1.1
377 * The Euro character is treated separately as it there is no mapping
378 * character in PCCP 437 and PCDN.
379 *-------------------------------------------------------------------
380 */
381 GLOBAL const UBYTE ext_ira_8859_chset_map [NUM_IRA_8859_TABLE_CHARS][2] =
382 {
383 { 0x65, 0x80 } /* Euro symbol */
384 };
385 #endif
386
387
388 /*
389 static const unsigned char
390 gsm_2_ascii_table[128] =
391 {
392 0x40, 0x9C, 0x24, 0x9D, 0x8A, 0x82, 0x97, 0x8D, 0x95, 0x80, 0x0A, 0x02, 0x07, 0x0D, 0x8F, 0x86,
393 0x04, 0x5F, 0xE8, 0xE2, 0xEF, 0xEA, 0xE3, 0x05, 0xE6, 0xE9, 0xF0, 0x20, 0x92, 0x91, 0xE1, 0x90,
394 0x20, 0x21, 0x22, 0x23, 0x01, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
395 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
396 0xAD, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F,
397 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x8E, 0x99, 0xA5, 0x9A, 0x06,
398 0xA8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F,
399 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x84, 0x94, 0xA4, 0x81, 0x85
400 };
401 */
402
403 /*==== FUNCTIONS ==================================================*/
404 #ifdef FF_ATI
405 /*
406 +-------------------------------------------------------------------+
407 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
408 | STATE : code ROUTINE : strupper |
409 +-------------------------------------------------------------------+
410
411 PURPOSE : Converts all characters from 'a' to 'z' to capital
412 characters from 'A' to 'Z'.
413 */
414 GLOBAL char* strupper ( char* s )
415 {
416 USHORT i = 0;
417
418 while ( s NEQ 0 AND s[i] NEQ '\0')
419 {
420 if ( s[i] >= 0x61 AND s[i] <= 0x7a )
421
422 s[i] = s[i] - 0x20;
423
424 i++;
425 }
426
427 return s;
428 }
429 #endif
430
431 #ifdef FF_ATI
432 /*
433 +-------------------------------------------------------------------+
434 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
435 | STATE : code ROUTINE : utl_chsetToSim |
436 +-------------------------------------------------------------------+
437
438 PURPOSE : This function converts the characters of a string from
439 the character set used within the AT command interpreter
440 to the SIM GSM character set.
441 */
442 GLOBAL void utl_chsetToSim ( UBYTE* in,
443 USHORT inLen,
444 UBYTE* out,
445 USHORT* outLen,
446 T_ACI_GSM_ALPHA gsm )
447 {
448 UBYTE cvtdVal;
449 USHORT outIdx = 0;
450 USHORT inIdx;
451 UBYTE corr = ( gsm EQ GSM_ALPHA_Int ? 0xFF : 0x7F );
452 T_ACI_CSCS_CHSET cscsChset;
453 UBYTE srcId = srcId_cb;
454
455 cscsChset = ati_user_output_cfg[srcId].cscsChset;
456
457 if ( cscsChset EQ CSCS_CHSET_Hex )
458 {
459 utl_hexToGsm ( in, inLen, out, outLen, gsm, CSCS_ALPHA_8_Bit );
460 }
461 else if ( cscsChset EQ CSCS_CHSET_Ucs2 )
462 {
463 /* If the user chooses UCS2, then the best mode of coding should be
464 * used to store the characters in the SIM */
465 utl_ucs2ToSim(in, inLen, out, outLen, gsm, CSCS_ALPHA_8_Bit);
466 }
467 else
468 {
469 for ( inIdx = 0; inIdx < inLen; inIdx++ )
470 {
471 cvtdVal = chset[cscsChset][( UBYTE ) in[inIdx]];
472
473 if ( cvtdVal NEQ 0x00 )
474 {
475 out[outIdx] = ( CHAR ) cvtdVal & corr;
476 outIdx++;
477 }
478 }
479
480 if ( gsm EQ GSM_ALPHA_Int )
481 out[outIdx] = '\0';
482
483 *outLen = outIdx;
484 }
485 }
486 #endif
487
488 #ifdef FF_ATI
489 /*
490 +-------------------------------------------------------------------+
491 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
492 | STATE : code ROUTINE : utl_codeUcs2 |
493 +-------------------------------------------------------------------+
494
495 PURPOSE : This function finds optimal coding format to store the
496 UCS2 character string in the phone book.
497 */
498 GLOBAL void utl_ucs2ToSim( UBYTE* in,
499 USHORT inLen,
500 UBYTE* out,
501 USHORT* outLen,
502 T_ACI_GSM_ALPHA gsm,
503 T_ACI_CSCS_ALPHA alphabet)
504 {
505 int i;
506 BOOL flag = TRUE;
507 UBYTE hexOut[MAX_ALPHA_LEN * 4];
508 USHORT hexOutLen = 0;
509
510 /* Convert the hex character string to actual hex values */
511 hexOutLen = utl_HexStrToBin(in, inLen, hexOut, (MAX_ALPHA_LEN * 4));
512
513 /* Initial check is done for GSM or ASCII only characters */
514 for(i = 0; i < (hexOutLen/2); i++)
515 {
516 if(( hexOut[i*2] NEQ 0x00 ))
517 {
518 flag = FALSE;
519 break;
520 }
521 }
522 if (flag EQ TRUE)
523 {
524 utl_ConvUcs2ToGSM(hexOut, hexOutLen, out, outLen, gsm, alphabet);
525 if (*outLen)
526 return;
527 }
528
529 /* If possible UCS2 character string is coded in 0x81 format which
530 uses a one byte base pointer */
531 utl_Ucs2InFormat1 (hexOut, hexOutLen, out, outLen);
532 if (*outLen)
533 return;
534
535 /* If possible UCS2 character string is coded in 0x82 format which
536 uses two byte base pointer */
537 utl_Ucs2InFormat2 (hexOut, hexOutLen, out, outLen);
538 if (*outLen)
539 return;
540
541 /* If none of the above work, UCS2 character string is coded in 0x80 */
542 *out = 0x80;
543 utl_hexToGsm ( in, inLen, out + 1, outLen, gsm, CSCS_ALPHA_8_Bit );
544 (*outLen)++;
545 }
546 #endif
547
548 #ifdef FF_ATI
549 /*
550 +-------------------------------------------------------------------+
551 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
552 | STATE : code ROUTINE : utl_ConvUcs2ToGSM |
553 +-------------------------------------------------------------------+
554
555 PURPOSE : This function converts UCS2 charecter string consisting of
556 only ASCII charecters to default GSM values.
557 */
558 GLOBAL void utl_ConvUcs2ToGSM ( UBYTE* in,
559 USHORT inLen,
560 UBYTE* out,
561 USHORT* outLen,
562 T_ACI_GSM_ALPHA gsm,
563 T_ACI_CSCS_ALPHA alphabet )
564 {
565 int i, j;
566 BOOL flag;
567 UBYTE val = 0x00;
568 USHORT len;
569 UBYTE tmpOut;
570 USHORT outIdx = 0;
571 UBYTE corr = ( gsm EQ GSM_ALPHA_Int ? 0xFF : 0x7F );
572
573 len = inLen/2;
574 for (i = 0;i < len; i++)
575 {
576 tmpOut = in[(i*2) + 1];
577 /* convert the hexadecimal ASCII value to GSM, if the value is
578 * not convertible then we exit */
579 if ( tmpOut EQ ( gsmToAsciiTable[tmpOut])) /* ASCII and GSM are identical */
580 {
581 val = tmpOut;
582 }
583 else /* find match in the table and copy index of match */
584 {
585 flag = FALSE;
586 for (j=0; j<128; j++)
587 {
588 if (tmpOut EQ gsmToAsciiTable[j])
589 {
590 val = (UBYTE)j;
591 flag = TRUE;
592 break;
593 }
594 #ifdef REL99
595 else
596 {
597 /* There is a chance that this is in the mapping table */
598 UBYTE ext_tbl_idx = 0;
599 while( ext_tbl_idx < NUM_EXT_TABLE_CHARS AND
600 ext_common_chset_map[ext_tbl_idx][1] NEQ tmpOut )
601 {
602 ext_tbl_idx++;
603 }
604 if(ext_tbl_idx < NUM_EXT_TABLE_CHARS)
605 {
606 /*Insert the escape character, 0x1B, to output stream*/
607 out[outIdx++] = 0x1B |(corr &0x80);
608 /* Insert the mapping character into the output stream */
609 val = ( UBYTE )ext_common_chset_map[ext_tbl_idx][0] |(corr &0x80);
610 flag = TRUE;
611 break;
612 }
613 }
614 #endif /* REL99 */
615 }
616 if (!flag)
617 {
618 *outLen = 0;
619 return;
620 }
621 }
622
623 /* if necessary, cut the GSM value to 7bit */
624 if ( alphabet EQ CSCS_ALPHA_7_Bit AND !( val & 0x80 ) )
625 {
626 if ( gsm EQ GSM_ALPHA_Int )
627 {
628 out[outIdx++] = val | 0x80;
629 }
630 else
631 {
632 out[outIdx++] = val;
633 }
634 }
635 else
636 {
637 out[outIdx++] = val;
638 }
639 }
640
641 if ( gsm EQ GSM_ALPHA_Int )
642 {
643 out[outIdx] = '\0';
644 }
645
646 /* set the outlength */
647 *outLen = outIdx;
648 }
649 #endif
650
651 #ifdef FF_ATI
652 /*
653 +-------------------------------------------------------------------+
654 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
655 | STATE : code ROUTINE : utl_Ucs2InFormat1 |
656 +-------------------------------------------------------------------+
657
658 PURPOSE : This function converts the UCS2 character string in the
659 0x81 coding scheme for UCS2.
660 Octet 1: 0x81
661 Octet 2: Num of Characters
662 Octet 3: Bits 15 to 8 of Base pointer
663 Octet 4 onwards: Characters
664 */
665 GLOBAL void utl_Ucs2InFormat1( UBYTE* in,
666 USHORT inLen,
667 UBYTE* out,
668 USHORT* outLen)
669 {
670 int i, j;
671 UBYTE base_ptr = 0x00;
672 UBYTE temp_ptr;
673 USHORT len = inLen/2;
674 USHORT tmp_base;
675 USHORT tmp;
676 USHORT outIdx = 0;
677 UBYTE corr = 0x7F;
678
679
680 /* We first check if the UCS2 string can be coded
681 * using a single base pointer */
682 for (i = 0; i < len; i++)
683 {
684 if (in[i*2])
685 {
686 if ((in[i*2] & 0x80))
687 {
688 *outLen = 0;
689 return;
690 }
691 temp_ptr = in[i*2] & 0x7f;
692 temp_ptr <<= 1;
693 temp_ptr |= ((in[(i*2)+1] & 0x80) >> 7);
694
695 if (base_ptr)
696 {
697 if (temp_ptr NEQ base_ptr)
698 {
699 *outLen = 0;
700 return;
701 }
702 } else
703 {
704 base_ptr = temp_ptr;
705 }
706 }
707 }
708
709
710 /* Characters are coded using the base pointer below */
711 /* For details, see GSM 11.11 Annex B (normative) */
712 out[0] = 0x81;
713 if (len < PHB_MAX_TAG_LEN - 3)
714 {
715 out[1] = (UBYTE)len;
716 } else
717 {
718 out[1] = PHB_MAX_TAG_LEN - 3;
719 }
720 out[2] = base_ptr;
721 tmp_base = 0;
722 tmp_base = base_ptr << 7;
723 outIdx = 3;
724
725 len = out[1];
726 for (i = 0; i < len; i++)
727 {
728 if (in[i*2])
729 {
730 tmp = 0;
731 tmp = in[i*2] << 8;
732 tmp |= in[(i*2)+1];
733 out[outIdx++] = (tmp - tmp_base) | 0x80;
734 } else
735 {
736 for (j=0; j<128; j++)
737 {
738 if (in[(i*2)+1] EQ gsmToAsciiTable[j])
739 {
740 out[outIdx++] = (UBYTE)j;
741 break;
742 }
743 #ifdef REL99
744 else
745 {
746 /* There is a chance that this is in the mapping table */
747 UBYTE ext_tbl_idx = 0;
748 while( ext_tbl_idx < NUM_EXT_TABLE_CHARS AND
749 ext_common_chset_map[ext_tbl_idx][1] NEQ in[(i*2)+1] )
750 {
751 ext_tbl_idx++;
752 }
753 if(ext_tbl_idx < NUM_EXT_TABLE_CHARS)
754 {
755 /*Insert the escape character, 0x1B, to output stream*/
756 out[outIdx++] = 0x1B |(corr &0x80);
757 /* Insert the mapping character into the output stream */
758 out[outIdx++] = ( UBYTE )ext_common_chset_map[ext_tbl_idx][0] |(corr &0x80);
759 break;
760 }
761 }
762 #endif /* REL99 */
763 }
764 }
765 /* If the charecter cannot be found in ASCII table exit */
766 if (j EQ 128)
767 {
768 *outLen = 0;
769 return ;
770 }
771 }
772
773 #ifdef REL99
774 if (outIdx -3 > len)
775 {
776 if (outIdx >= PHB_MAX_TAG_LEN)
777 {
778 if (out[PHB_MAX_TAG_LEN - 1] EQ 0x1B)
779 {
780 outIdx = PHB_MAX_TAG_LEN - 1;
781 out[1] = PHB_MAX_TAG_LEN - 4;
782 }
783 else
784 {
785 outIdx = PHB_MAX_TAG_LEN;
786 out[1] = PHB_MAX_TAG_LEN - 3;
787 }
788 }
789 else
790 {
791 out[1] = outIdx -3;
792 }
793 }
794 #endif /* REL99 */
795
796 *outLen = outIdx;
797 }
798 #endif
799
800 #ifdef FF_ATI
801 /*
802 +-------------------------------------------------------------------+
803 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
804 | STATE : code ROUTINE : utl_Ucs2InFormat2 |
805 +-------------------------------------------------------------------+
806
807 PURPOSE : This function converts the UCS2 character string in the
808 0x82 coding scheme for UCS2.
809 Octet 1: 0x82
810 Octet 2: Number of characters
811 Octet 3 and Octet 4: 2 byte base pointer
812 Octet 5 onwards: Characters
813
814 */
815 GLOBAL void utl_Ucs2InFormat2( UBYTE* in,
816 USHORT inLen,
817 UBYTE* out,
818 USHORT* outLen)
819 {
820 int i, j;
821 USHORT len = inLen/2;
822 USHORT lowest_ch = 0;
823 USHORT highest_ch = 0;
824 USHORT tmp;
825 USHORT outIdx = 0;
826 UBYTE corr = 0x7F;
827
828 /* We first check if the UCS2 string can be coded
829 * using a smallest char as the base pointer */
830 for (i = 0; i < len; i++)
831 {
832 if (in[i*2])
833 {
834 tmp = 0;
835 tmp = in[i*2] << 8;
836 tmp |= in[(i*2)+1];
837
838 if (lowest_ch EQ 0 OR tmp < lowest_ch)
839 lowest_ch = tmp;
840
841 if (tmp > highest_ch)
842 highest_ch = tmp;
843 }
844 }
845
846 /* To use lowest char can be used as the base pointer, the distance
847 * between the lowest and highest char must not be more then 128 */
848 /* correct here: must not equal or more then 128. the max offset will be less then 0x80 = 128 */
849 //TI-SH-TEST-PATCH for CSR OMAPS00168884
850 if ((highest_ch - lowest_ch) >= 0x80)
851 {
852 *outLen = 0;
853 return;
854 }
855
856 /* Characters are coded using the base pointer below */
857 /* For details, see GSM 11.11 Annex B (normative) */
858 out[0] = 0x82;
859 if (len < PHB_MAX_TAG_LEN - 4)
860 {
861 out[1] = (UBYTE)len;
862 } else
863 {
864 out[1] = PHB_MAX_TAG_LEN - 4;
865 }
866 out[2] = (lowest_ch & 0xff00) >> 8;
867 out[3] = (lowest_ch & 0x00ff);
868 outIdx = 4;
869
870 len = out[1];
871 for (i = 0; i < len; i++)
872 {
873 if (in[i*2])
874 {
875 tmp = 0;
876 tmp = in[i*2] << 8;
877 tmp |= in[(i*2)+1];
878 out[outIdx++] = (tmp - lowest_ch) | 0x80;
879 } else
880 {
881 for (j=0; j<128; j++)
882 {
883 if (in[(i*2)+1] EQ gsmToAsciiTable[j])
884 {
885 out[outIdx++] = (UBYTE)j;
886 break;
887 }
888 #ifdef REL99
889 else
890 {
891 /* There is a chance that this is in the mapping table */
892 UBYTE ext_tbl_idx = 0;
893 while( ext_tbl_idx < NUM_EXT_TABLE_CHARS AND
894 ext_common_chset_map[ext_tbl_idx][1] NEQ in[(i*2)+1] )
895 {
896 ext_tbl_idx++;
897 }
898 if(ext_tbl_idx < NUM_EXT_TABLE_CHARS)
899 {
900 /*Insert the escape character, 0x1B, to output stream*/
901 out[outIdx++] = 0x1B |(corr &0x80);
902 /* Insert the mapping character into the output stream */
903 out[outIdx++] = ( UBYTE )ext_common_chset_map[ext_tbl_idx][0] |(corr &0x80);
904 break;
905 }
906 }
907 #endif /* REL99 */
908 }
909
910 /* If the charecter cannot be found in ASCII table exit */
911 if (j EQ 128)
912 {
913 *outLen = 0;
914 return ;
915 }
916 }
917 }
918
919 #ifdef REL99
920 if (outIdx -4 > len)
921 {
922 if (outIdx >= PHB_MAX_TAG_LEN)
923 {
924 if (out[PHB_MAX_TAG_LEN - 1] EQ 0x1B)
925 {
926 outIdx = PHB_MAX_TAG_LEN - 1;
927 out[1] = PHB_MAX_TAG_LEN - 5;
928 }
929 else
930 {
931 outIdx = PHB_MAX_TAG_LEN;
932 out[1] = PHB_MAX_TAG_LEN - 4;
933 }
934 }
935 else
936 {
937 out[1] = outIdx -4;
938 }
939 }
940 #endif /* REL99 */
941
942 *outLen = outIdx;
943 }
944 #endif
945
946 #ifdef FF_ATI
947
948 /*
949 +-------------------------------------------------------------------+
950 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
951 | STATE : code ROUTINE : utl_chsetToGsm |
952 +-------------------------------------------------------------------+
953
954 PURPOSE : This function converts the characters of a string from
955 the character set used within the AT command interpreter
956 to the ACI internal GSM character set. The outBufLen was added
957 so that buffer overflow is kept in check when replacing one
958 non-GSM character with two characters - an escape character 0x1B
959 and a character from the extension table.
960 */
961 GLOBAL void utl_chsetToGsm ( UBYTE* in,
962 USHORT inLen,
963 UBYTE* out,
964 USHORT* outLen,
965 #ifdef REL99
966 USHORT outBufLen,
967 #endif
968 T_ACI_GSM_ALPHA gsm )
969 {
970 UBYTE cvtdVal;
971 USHORT outIdx = 0;
972 USHORT inIdx;
973 UBYTE corr = ( gsm EQ GSM_ALPHA_Int ? 0xFF : 0x7F );
974 T_ACI_CSCS_CHSET cscsChset;
975 UBYTE srcId = srcId_cb;
976
977 cscsChset = ati_user_output_cfg[srcId].cscsChset;
978
979 if ( ati_user_output_cfg[srcId].cscsChset EQ CSCS_CHSET_Hex )
980 {
981 utl_hexToGsm ( in, inLen, out, outLen, gsm, CSCS_ALPHA_8_Bit );
982 }
983 else if ( cscsChset EQ CSCS_CHSET_Ucs2 )
984 {
985 utl_ucs2ToGsm ( in, inLen, out, outLen, gsm, CSCS_ALPHA_8_Bit );
986 }
987 else
988 {
989 #ifndef REL99
990 for ( inIdx = 0; inIdx < inLen; inIdx++ )
991 {
992 cvtdVal = chset[cscsChset][( UBYTE ) in[inIdx]];
993 if ( cvtdVal NEQ 0x00 )
994 {
995 out[outIdx] = ( CHAR ) cvtdVal & corr;
996 outIdx++;
997 }
998 }
999 #else
1000 for ( inIdx = 0; inIdx < inLen AND outIdx < outBufLen; inIdx++ )
1001 {
1002 cvtdVal = chset[cscsChset][( UBYTE ) in[inIdx]];
1003
1004 if ( cvtdVal NEQ 0x00 )
1005 {
1006 out[outIdx] = ( CHAR ) cvtdVal & corr;
1007 outIdx++;
1008 }
1009 else
1010 {
1011 /* There is a chance that this is in the mapping table */
1012 UBYTE ext_tbl_idx = 0;
1013 while( ext_tbl_idx < NUM_EXT_TABLE_CHARS AND
1014 ext_common_chset_map[ext_tbl_idx][1] NEQ in[inIdx] )
1015 {
1016 ext_tbl_idx++;
1017 }
1018 if(ext_tbl_idx < NUM_EXT_TABLE_CHARS)
1019 {
1020 /*Insert the escape character, 0x1B, to output stream*/
1021 out[outIdx++] = 0x1B |(corr &0x80);
1022 /* Check that output buffer limit has not been reached */
1023 if(outIdx < outBufLen)
1024 {
1025 /* Insert the mapping character into the output stream */
1026 out[outIdx++] = ( UBYTE )ext_common_chset_map[ext_tbl_idx][0] |(corr &0x80);
1027 }
1028 }
1029 else if ( ( cscsChset EQ CSCS_CHSET_Ira ) OR ( cscsChset EQ CSCS_CHSET_8859_1 ) )
1030 {
1031 /* Check if the character is present in ext_ira_8859_chset_map */
1032 ext_tbl_idx = 0;
1033
1034 while( ext_tbl_idx < NUM_IRA_8859_TABLE_CHARS AND
1035 ext_ira_8859_chset_map[ext_tbl_idx][1] NEQ in[inIdx] )
1036 {
1037 ext_tbl_idx++;
1038 }
1039
1040 if( ext_tbl_idx < NUM_IRA_8859_TABLE_CHARS )
1041 {
1042 /*Insert the escape character, 0x1B, to output stream*/
1043 out[outIdx++] = 0x1B |(corr &0x80);
1044 /* Check that output buffer limit has not been reached */
1045 if(outIdx < outBufLen)
1046 {
1047 /* Insert the mapping character into the output stream */
1048 out[outIdx++] = ( UBYTE )ext_ira_8859_chset_map[ext_tbl_idx][0] |(corr &0x80);
1049 }
1050 }
1051 }
1052 }
1053 }
1054 #endif /* ifndef REL99 */
1055
1056 if ( gsm EQ GSM_ALPHA_Int )
1057 out[outIdx] = '\0';
1058
1059 *outLen = outIdx;
1060 }
1061 }
1062 #endif
1063
1064
1065 #ifdef FF_ATI
1066 /*
1067 +-------------------------------------------------------------------+
1068 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
1069 | STATE : code ROUTINE : utl_hexFromAlpha |
1070 +-------------------------------------------------------------------+
1071
1072 PURPOSE : This function converts the characters of a string from
1073 the SIM with UCS2 form 0x81 or 0x82 to 16 Bit hex values.
1074 see GSM 11.11 Annex B Coding of Alpha fields in the SIM for UCS2
1075 UCS2 form 0x81:
1076 - octet 1 = 0x81
1077 - octet 2 = length
1078 - octet 3 = Bits 15 to 8 of the base pointer to a half page in the UCS2 code space
1079 0hhh hhhh h000 0000 , with h = bits of the half page base pointer
1080 16... .... .... ...1
1081
1082 UCS2 form 0x82:
1083 - octet 1 = 0x81
1084 - octet 2 = length
1085 - octet 3 = upper 8 Bit of 16 Bit base pointer to a half page in the UCS2 code space
1086 - octet 4 = lower 8 Bit of 16 Bit base pointer to a half page in the UCS2 code space
1087 */
1088 GLOBAL void utl_hexFromUCS2 ( UBYTE *in,
1089 UBYTE *out,
1090 USHORT maxOutlen,
1091 USHORT *outlen,
1092 T_ACI_GSM_ALPHA gsm)
1093 {
1094 USHORT outIdx = 0;
1095 USHORT base_pointer;
1096 USHORT length = in[1];
1097 USHORT tmp;
1098 UBYTE corr = ( gsm EQ GSM_ALPHA_Int ? 0x00 : 0x80 );
1099
1100 if (*in EQ 0x81)
1101 {
1102 base_pointer = in[2] << 7;
1103 in += 3;
1104 }
1105 else /* if (*in EQ 0x82) */
1106 {
1107 base_pointer = in[2]<<8 | in[3];
1108 in += 4;
1109 }
1110
1111 while ( length-- AND outIdx < maxOutlen-2)
1112 {
1113 if (*in & 0x80)
1114 {
1115 tmp = base_pointer + (*in & 0x7F);
1116 }
1117 else if((*in | corr) NEQ 0x9B)
1118 {
1119 tmp = 0x0000 + gsmToAsciiTable[*in];
1120 }
1121 #ifdef REL99
1122 else
1123 {
1124 UBYTE ext_tbl_idx = 0;
1125 BOOL mapping_char_found = FALSE;
1126 in++;
1127
1128 while( ext_tbl_idx < NUM_EXT_TABLE_CHARS AND
1129 ext_common_chset_map[ext_tbl_idx][0] NEQ (*in & 0x7F))
1130 {
1131 ext_tbl_idx++;
1132 }
1133 if( ext_tbl_idx < NUM_EXT_TABLE_CHARS )
1134 {
1135 /* Insert the mapping character into the output stream */
1136 tmp = 0x0000 + ( UBYTE )ext_common_chset_map[ext_tbl_idx][1];
1137 }
1138 }
1139 #endif
1140 out[outIdx++] = hexVal[(tmp >> 12) & 0x0F ];
1141 out[outIdx++] = hexVal[(tmp >> 8) & 0x0F ];
1142 out[outIdx++] = hexVal[(tmp >> 4) & 0x0F ];
1143 out[outIdx++] = hexVal[(tmp ) & 0x0F ];
1144
1145 in++;
1146 }
1147
1148 out[outIdx] = '\0';
1149 *outlen = outIdx;
1150 }
1151 #endif
1152
1153
1154 #ifdef FF_ATI
1155 /*
1156 +-------------------------------------------------------------------+
1157 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
1158 | STATE : code ROUTINE : utl_chsetFromSim |
1159 +-------------------------------------------------------------------+
1160
1161 PURPOSE : This function converts the characters of a string from
1162 the SIM format to the character set
1163 used within the AT command interpreter.
1164 */
1165 GLOBAL void utl_chsetFromSim ( UBYTE* in,
1166 USHORT inLen,
1167 UBYTE* out,
1168 USHORT maxOutLen,
1169 USHORT* outLen,
1170 T_ACI_GSM_ALPHA gsm )
1171 {
1172 T_ACI_CSCS_CHSET cscsChset;
1173 UBYTE srcId = srcId_cb;
1174
1175 cscsChset = ati_user_output_cfg[srcId].cscsChset;
1176
1177 if ( cscsChset EQ CSCS_CHSET_Ucs2 AND
1178 (( *in EQ 0x80 ) OR ( *in EQ 0x81 ) OR ( *in EQ 0x82 )) )
1179 {
1180 /* UCS2 with form 0x81 or 0x82 as HEX string */
1181 if (( *in EQ 0x81 ) OR ( *in EQ 0x82 ))
1182 {
1183 utl_hexFromUCS2 ( in, out, maxOutLen, outLen, gsm);
1184 return;
1185 }
1186
1187 /* UCS2 form 0x80 as HEX string */
1188 utl_hexFromGsm ( in + 1, (USHORT)( inLen - 1 ), out, maxOutLen, outLen,
1189 gsm, CSCS_ALPHA_8_Bit );
1190 }
1191 else
1192 {
1193 utl_chsetFromGsm ( in, inLen, out, maxOutLen, outLen, gsm );
1194 }
1195 }
1196 #endif /* #ifdef FF_ATI */
1197
1198 #if defined(FF_ATI) || defined(FF_BAT)
1199 #ifdef TI_PS_OP_CNV_TAB_ROMBASED
1200 #endif
1201
1202 /*
1203 +-------------------------------------------------------------------+
1204 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
1205 | STATE : code ROUTINE : utl_chsetFromGsm |
1206 +-------------------------------------------------------------------+
1207
1208 PURPOSE : This function converts the characters of a string from
1209 the ACI internal GSM character set to the character set
1210 used within the AT command interpreter.
1211 */
1212
1213 GLOBAL USHORT utl_chsetFromGsm(
1214 UBYTE* in,
1215 USHORT inLen,
1216 UBYTE* out,
1217 USHORT maxOutLen,
1218 USHORT* outLen,
1219 T_ACI_GSM_ALPHA gsm)
1220 {
1221 USHORT outIdx = 0;
1222 USHORT inIdx = 0;
1223 USHORT actLen = ( gsm EQ GSM_ALPHA_Int ?
1224 ( USHORT ) strlen ( ( CHAR* ) in ) : inLen );
1225 UBYTE corr = ( gsm EQ GSM_ALPHA_Int ? 0x00 : 0x80 );
1226 T_ACI_CSCS_CHSET cscsChset;
1227 UBYTE srcId = srcId_cb;
1228 USHORT tblIdx;
1229
1230 cscsChset = ati_user_output_cfg[srcId].cscsChset;
1231
1232 if ( cscsChset EQ CSCS_CHSET_Hex )
1233 {
1234 return utl_hexFromGsm ( in, inLen, out, maxOutLen, outLen, gsm, CSCS_ALPHA_8_Bit );
1235 }
1236 else if ( cscsChset EQ CSCS_CHSET_Ucs2 )
1237 {
1238 return utl_ucs2FromGsm ( in, inLen, out, maxOutLen, outLen, gsm, CSCS_ALPHA_8_Bit );
1239 }
1240 else
1241 {
1242 #ifndef REL99
1243
1244 while ( inIdx < actLen AND outIdx < maxOutLen - 1 )
1245 {
1246 tblIdx = 0;
1247
1248
1249 while ( tblIdx <= 0xFF AND
1250 chset[cscsChset][tblIdx] NEQ (( UBYTE )in[inIdx] | corr ))
1251 tblIdx++;
1252 if ( tblIdx <= 0xFF )
1253 {
1254 out[outIdx] = ( UBYTE )tblIdx;
1255 outIdx++;
1256 }
1257
1258 inIdx++;
1259 }
1260
1261 #else
1262 /* TODO: What if the CSCS is GSM7 itself. Do we have to do this? The following check
1263 if( cscsChset NEQ CSCS_CHSET_Gsm AND gsm EQ GSM_ALPHA_Def */
1264 while ( inIdx < actLen AND outIdx < maxOutLen - 1 )
1265 {
1266 /* Check if the character is a escape to an extension of the GSM 7 bit
1267 * default alphabet table. */
1268 if( cscsChset NEQ CSCS_CHSET_Gsm AND ((in[inIdx] | corr) EQ 0x9B) )
1269 {
1270 UBYTE ext_tbl_idx = 0;
1271 BOOL mapping_char_found = FALSE;
1272 inIdx++;
1273
1274 /* Check if the end of the array is reached */
1275 if(inIdx EQ actLen)
1276 {
1277 break;
1278 }
1279
1280 while( ext_tbl_idx < NUM_EXT_TABLE_CHARS AND
1281 ext_common_chset_map[ext_tbl_idx][0] NEQ (in[inIdx] & 0x7F))
1282 {
1283 ext_tbl_idx++;
1284 }
1285 if( ext_tbl_idx < NUM_EXT_TABLE_CHARS )
1286 {
1287 /* Insert the mapping character into the output stream */
1288 out[outIdx++] = ( UBYTE )ext_common_chset_map[ext_tbl_idx][1];
1289 mapping_char_found = TRUE;
1290 }
1291 else if( cscsChset EQ CSCS_CHSET_Ira OR cscsChset EQ CSCS_CHSET_8859_1 )
1292 {
1293 ext_tbl_idx = 0;
1294
1295 while( ext_tbl_idx < NUM_IRA_8859_TABLE_CHARS AND
1296 ext_ira_8859_chset_map[ext_tbl_idx][0] NEQ (in[inIdx]&0x7F))
1297 {
1298 ext_tbl_idx++;
1299 }
1300
1301 if(ext_tbl_idx < NUM_IRA_8859_TABLE_CHARS)
1302 {
1303 /* Insert the mapping character into the output stream */
1304 out[outIdx++] = ( UBYTE )ext_ira_8859_chset_map[ext_tbl_idx][1];
1305 mapping_char_found = TRUE;
1306 }
1307 }
1308
1309 if(mapping_char_found EQ FALSE)
1310 {
1311 /* From 23.038: In the event that an MS receives a code where a symbol
1312 is not represented in the extension table then the MS shall display
1313 the character shown in the main GSM 7 bit default alphabet table */
1314 tblIdx = 0;
1315 while ( tblIdx <= 0xFF AND
1316 chset[cscsChset][tblIdx] NEQ (( UBYTE )in[inIdx] | corr ))
1317 tblIdx++;
1318
1319 if ( tblIdx <= 0xFF )
1320 {
1321 out[outIdx] = ( UBYTE )tblIdx;
1322 outIdx++;
1323 }
1324
1325 }
1326 }
1327 else
1328 {
1329 tblIdx = 0;
1330
1331 while ( tblIdx <= 0xFF AND
1332 chset[cscsChset][tblIdx] NEQ (( UBYTE )in[inIdx] | corr ))
1333 tblIdx++;
1334
1335 if ( tblIdx <= 0xFF )
1336 {
1337 out[outIdx] = ( UBYTE )tblIdx;
1338 outIdx++;
1339 }
1340
1341 }
1342
1343 inIdx++;
1344 }
1345 #endif
1346
1347 out[outIdx] = '\0';
1348 *outLen = outIdx;
1349
1350 return inIdx;
1351 }
1352 }
1353 #endif
1354
1355
1356 #ifdef FF_ATI
1357 /*
1358 +-------------------------------------------------------------------+
1359 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
1360 | STATE : code ROUTINE : utl_sprints |
1361 +-------------------------------------------------------------------+
1362
1363 PURPOSE : This function writes a not null terminated string to a
1364 buffer.
1365 */
1366 GLOBAL USHORT sprints ( CHAR* buf, CHAR* arg, USHORT len )
1367 {
1368 buf[0] = '\"';
1369
1370 memcpy ( &buf[1], arg, len );
1371
1372 buf[len + 1] = '\"';
1373 buf[len + 2] = '\0';
1374
1375 return (len + 2);
1376 }
1377 #endif
1378
1379 #ifdef FF_ATI
1380 /*
1381 +-------------------------------------------------------------------+
1382 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
1383 | STATE : code ROUTINE : utl_sprintq |
1384 +-------------------------------------------------------------------+
1385
1386 PURPOSE : This function writes a not null terminated string to a
1387 buffer.
1388 */
1389 GLOBAL USHORT sprintq ( CHAR* buf, CHAR* arg, USHORT len )
1390 {
1391 memcpy ( &buf[0], arg, len );
1392
1393 buf[len] = '\0';
1394
1395 return (len);
1396 }
1397 #endif
1398
1399 #ifdef FF_ATI
1400 /*
1401 +-------------------------------------------------------------------+
1402 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
1403 | STATE : code ROUTINE : utl_hexToIntGsm |
1404 +-------------------------------------------------------------------+
1405
1406 PURPOSE : This function converts the characters of a string from
1407 the "HEX" character set to the ACI internal GSM
1408 character set.
1409 */
1410 GLOBAL void utl_hexToGsm ( UBYTE* in,
1411 USHORT inLen,
1412 UBYTE* out,
1413 USHORT* outLen,
1414 T_ACI_GSM_ALPHA gsm,
1415 T_ACI_CSCS_ALPHA alphabet )
1416 {
1417 SHORT val = 0;
1418 UBYTE digit;
1419 USHORT inIdx = 0;
1420 USHORT outIdx = 0;
1421 SHORT base = 0x10;
1422
1423 while ( inIdx < inLen )
1424 {
1425 if ( in[inIdx] >= 0x30 AND in[inIdx] <= 0x39 ) /* '0' ... '9' */
1426 {
1427 digit = in[inIdx] - 0x30; /* ->0 ... 9 */
1428 }
1429 else if ( in[inIdx] >= 0x61 AND in[inIdx] <= 0x66 ) /* 'a' ... 'f' */
1430 {
1431 digit = in[inIdx] - 0x61 + 0x0A; /* ->0x0a...0x0f */
1432 }
1433 else if ( in[inIdx] >= 0x41 AND in[inIdx] <= 0x46 ) /* 'A' ... 'F' */
1434 {
1435 digit = in[inIdx] - 0x41 + 0x0A; /* ->0x0a...0x0f */
1436 }
1437 else
1438 {
1439 digit = 0xFF;
1440 }
1441
1442 if ( digit NEQ 0xFF ) /* skip invalid digit */
1443 {
1444 if ( base EQ 0x10 )
1445 {
1446 val = digit << 4;
1447 }
1448 else
1449 {
1450 val |= digit;
1451
1452 if ( alphabet EQ CSCS_ALPHA_7_Bit AND !( val & 0x80 ) )
1453 {
1454 if ( gsm EQ GSM_ALPHA_Int )
1455 {
1456 out[outIdx++] = ( CHAR ) val | 0x80;
1457 }
1458 else
1459 {
1460 out[outIdx++] = ( CHAR ) val;
1461 }
1462 }
1463 else if ( alphabet NEQ CSCS_ALPHA_7_Bit )
1464 {
1465 out[outIdx++] = ( CHAR ) val;
1466 }
1467 }
1468
1469 base ^= 0x10;
1470 }
1471
1472 inIdx++;
1473 }
1474
1475 if ( gsm EQ GSM_ALPHA_Int )
1476 out[outIdx] = '\0';
1477
1478 *outLen = outIdx;
1479 }
1480 #endif
1481
1482 #ifdef FF_ATI
1483 /*
1484 +-------------------------------------------------------------------+
1485 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
1486 | STATE : code ROUTINE : utl_ucs2ToGsm |
1487 +-------------------------------------------------------------------+
1488
1489 PURPOSE : This function converts the characters of a string from
1490 the "UCS2" character set to the ACI internal GSM
1491 character set.
1492 */
1493 GLOBAL void utl_ucs2ToGsm ( UBYTE* in,
1494 USHORT inLen,
1495 UBYTE* out,
1496 USHORT* outLen,
1497 T_ACI_GSM_ALPHA gsm,
1498 T_ACI_CSCS_ALPHA alphabet )
1499 {
1500 int i, j;
1501 UBYTE val;
1502 USHORT len;
1503 UBYTE tmpIn[2]; /* store temporary two chars (HEX conversion) */
1504 UBYTE tmpInIdx; /* holds a temporary index for two chars (HEX conversion)*/
1505 UBYTE digit; /* holds a digit (HEX conversion) */
1506 SHORT tmpVal; /* hold a temporary value (HEX conversion) */
1507 UBYTE tmpOut; /* the HEX output (HEX conversion) */
1508 SHORT base = 0x10;
1509 USHORT outIdx = 0;
1510 UBYTE corr = ( gsm EQ GSM_ALPHA_Int ? 0xFF : 0x7F );
1511
1512 /* TRACE_FUNCTION(" utl_ucs2ToGsm() "); */
1513
1514 len = inLen/4;
1515
1516 for (i=0;i<len;i++)
1517 {
1518 /* check if this is a UCS2 character in 00xy format */
1519 if ( ( in[i*4] EQ '0' ) AND ( in[i*4+1] EQ '0' ) )
1520 {
1521 /* convert the next two character to HEX */
1522 tmpIn[0] = in[i*4+2];
1523 tmpIn[1] = in[i*4+3];
1524
1525 tmpVal = tmpOut = val = 0;
1526
1527 /* convert the two characters into the real hexadecimal ASCII value */
1528 for( tmpInIdx=0; tmpInIdx<2; tmpInIdx++ )
1529 {
1530 if ( tmpIn[tmpInIdx] >= '0' AND tmpIn[tmpInIdx] <= '9' )
1531 {
1532 digit = tmpIn[tmpInIdx] - '0';
1533 }
1534 else if ( tmpIn[tmpInIdx] >= 'a' AND tmpIn[tmpInIdx] <= 'f' )
1535 {
1536 digit = tmpIn[tmpInIdx] - 'a' + 0x0A;
1537 }
1538 else if ( tmpIn[tmpInIdx] >= 'A' AND tmpIn[tmpInIdx] <= 'F' )
1539 {
1540 digit = tmpIn[tmpInIdx] - 'A' + 0x0A;
1541 }
1542 else
1543 {
1544 digit = 0xFF;
1545 }
1546
1547 if ( digit NEQ 0xFF )
1548 {
1549 if ( base EQ 0x10 )
1550 {
1551 tmpVal = digit * 0x10;
1552 }
1553 else
1554 {
1555 tmpVal += digit;
1556 tmpOut = (UBYTE) tmpVal;
1557 }
1558
1559 base ^= 0x10;
1560 }
1561 }
1562
1563 /* convert the hexadecimal ASCII value to GSM */
1564 if (!(tmpOut & 0x80))
1565 {
1566 if ( tmpOut EQ ( gsmToAsciiTable[tmpOut])) /* ASCII and GSM are identical */
1567 {
1568 val = tmpOut;
1569 }
1570 else /* find match in the table and copy index of match */
1571 {
1572 for (j=0; j<128; j++)
1573 {
1574 if (tmpOut EQ gsmToAsciiTable[j])
1575 {
1576 val = (UBYTE)j;
1577 break;
1578 }
1579 #ifdef REL99
1580 else
1581 {
1582 /* There is a chance that this is in the mapping table */
1583 UBYTE ext_tbl_idx = 0;
1584 while( ext_tbl_idx < NUM_EXT_TABLE_CHARS AND
1585 ext_common_chset_map[ext_tbl_idx][1] NEQ tmpOut )
1586 {
1587 ext_tbl_idx++;
1588 }
1589 if(ext_tbl_idx < NUM_EXT_TABLE_CHARS)
1590 {
1591 /*Insert the escape character, 0x1B, to output stream*/
1592 out[outIdx++] = 0x1B |(corr &0x80);
1593 /* Insert the mapping character into the output stream */
1594 val = ( UBYTE )ext_common_chset_map[ext_tbl_idx][0] |(corr &0x80);
1595 break;
1596 }
1597 }
1598 #endif /* REL99 */
1599 }
1600 }
1601 }
1602 else /* find match in the table and copy index of match */
1603 {
1604 for (j=0; j<128; j++)
1605 {
1606 if (tmpOut EQ gsmToAsciiTable[j])
1607 {
1608 val = (UBYTE)j;
1609 break;
1610 }
1611 #ifdef REL99
1612 else
1613 {
1614 /* There is a chance that this is in the mapping table */
1615 UBYTE ext_tbl_idx = 0;
1616 while( ext_tbl_idx < NUM_EXT_TABLE_CHARS AND
1617 ext_common_chset_map[ext_tbl_idx][1] NEQ tmpOut )
1618 {
1619 ext_tbl_idx++;
1620 }
1621 if(ext_tbl_idx < NUM_EXT_TABLE_CHARS)
1622 {
1623 /*Insert the escape character, 0x1B, to output stream*/
1624 out[outIdx++] = 0x1B |(corr &0x80);
1625 /* Insert the mapping character into the output stream */
1626 val = ( UBYTE )ext_common_chset_map[ext_tbl_idx][0] |(corr &0x80);
1627 break;
1628 }
1629 }
1630 #endif /* REL99 */
1631 }
1632 }
1633
1634 /* if necessary, cut the GSM value to 7bit */
1635 if ( alphabet EQ CSCS_ALPHA_7_Bit AND !( val & 0x80 ) )
1636 {
1637 if ( gsm EQ GSM_ALPHA_Int )
1638 {
1639 out[outIdx++] = val | 0x80;
1640 }
1641 else
1642 {
1643 out[outIdx++] = val;
1644 }
1645 }
1646 else
1647 {
1648 out[outIdx++] = val;
1649 }
1650 }
1651
1652 else /* unknown char, skip it */
1653 {
1654 /* TRACE_EVENT("UCS2 MISMATCH: Unknown UCS2 entry, character skipped!"); */
1655 /* out[outIdx++] = '?'; */
1656 }
1657 }
1658
1659 if ( gsm EQ GSM_ALPHA_Int )
1660 {
1661 out[outIdx] = '\0';
1662 }
1663
1664 /* set the outlength */
1665 *outLen = outIdx;
1666
1667 }
1668 #endif
1669
1670 #ifdef FF_ATI
1671 /*
1672 +-------------------------------------------------------------------+
1673 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
1674 | STATE : code ROUTINE : utl_hexFromGsm |
1675 +-------------------------------------------------------------------+
1676
1677 PURPOSE : This function converts the characters of a string from
1678 the ACI internal GSM character set to the "HEX"
1679 character set.
1680 */
1681 GLOBAL USHORT utl_hexFromGsm ( UBYTE* in,
1682 USHORT inLen,
1683 UBYTE* out,
1684 USHORT maxOutLen,
1685 USHORT* outLen,
1686 T_ACI_GSM_ALPHA gsm,
1687 T_ACI_CSCS_ALPHA alphabet )
1688 {
1689 USHORT inIdx = 0;
1690 USHORT outIdx = 0;
1691
1692 while ( inIdx < inLen AND outIdx < maxOutLen - 2 )
1693 {
1694 if ( alphabet NEQ CSCS_ALPHA_7_Bit OR
1695 ( gsm EQ GSM_ALPHA_Def AND !( in[inIdx] & 0x80 ) ) OR
1696 ( gsm EQ GSM_ALPHA_Int AND ( in[inIdx] & 0x80 ) ) )
1697 {
1698 /* Convert to 7bit default alphabet only if the data is
1699 coded in internal GSM character set */
1700 if ( gsm EQ GSM_ALPHA_Int AND ( in[inIdx] & 0x80 ) )
1701 {
1702 out[outIdx++] = hexVal[ (in[inIdx] & 0x7F) >> 4 ];
1703 }
1704 else
1705 {
1706 out[outIdx++] = hexVal[ in[inIdx] >> 4 ];
1707 }
1708 out[outIdx++] = hexVal[ in[inIdx] & 0x0F ];
1709 }
1710
1711 inIdx++;
1712 }
1713
1714 out[outIdx] = '\0';
1715 *outLen = outIdx;
1716
1717 return inIdx;
1718 }
1719 #endif
1720
1721 #ifdef FF_ATI
1722 /*
1723 +-------------------------------------------------------------------+
1724 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
1725 | STATE : code ROUTINE : utl_ucs2FromGsm |
1726 +-------------------------------------------------------------------+
1727
1728 PURPOSE : This function converts the characters of a string from
1729 the ACI internal GSM character set to the "UCS2"
1730 character set.
1731 */
1732 LOCAL USHORT utl_ucs2FromGsm (UBYTE* in,
1733 USHORT inLen,
1734 UBYTE* out,
1735 USHORT maxOutLen,
1736 USHORT* outLen,
1737 T_ACI_GSM_ALPHA gsm,
1738 T_ACI_CSCS_ALPHA alphabet )
1739 {
1740 USHORT inIdx = 0;
1741 USHORT outIdx = 0;
1742 UBYTE corr = ( gsm EQ GSM_ALPHA_Int ? 0x00 : 0x80 );
1743
1744 while ( inIdx < inLen AND outIdx < maxOutLen - 4 )
1745 {
1746 if ( alphabet NEQ CSCS_ALPHA_7_Bit OR
1747 ( gsm EQ GSM_ALPHA_Def AND !( in[inIdx] & 0x80 ) ) OR
1748 ( gsm EQ GSM_ALPHA_Int AND ( in[inIdx] & 0x80 ) ) )
1749 {
1750 /* Insert two leading Os, convert GSM to ASCII and print out as HEX */
1751 out[outIdx++] = '0';
1752 out[outIdx++] = '0';
1753 #ifdef REL99
1754 if( (in[inIdx] | corr) EQ 0x9B)
1755 {
1756 UBYTE ext_tbl_idx = 0;
1757 inIdx++;
1758 while( ext_tbl_idx < NUM_EXT_TABLE_CHARS AND
1759 ext_common_chset_map[ext_tbl_idx][0] NEQ (in[inIdx] & 0x7F))
1760 {
1761 ext_tbl_idx++;
1762 }
1763 if( ext_tbl_idx < NUM_EXT_TABLE_CHARS )
1764 {
1765 /* Insert the mapping character into the output stream */
1766 out[outIdx++] = hexVal[(ext_common_chset_map[ext_tbl_idx][1] & 0x7F) >> 4 ];
1767 out[outIdx++] = hexVal[(ext_common_chset_map[ext_tbl_idx][1] & 0x7F) & 0x0F ];
1768 }
1769 }
1770 else
1771 {
1772 #endif /* REL99 */
1773 out[outIdx++] = hexVal[ gsmToAsciiTable[in[inIdx] & 0x7F] >> 4 ];
1774 out[outIdx++] = hexVal[ gsmToAsciiTable[in[inIdx] & 0x7F] & 0x0F ];
1775 #ifdef REL99
1776 }
1777 #endif /* REL99 */
1778
1779 }
1780
1781 inIdx++;
1782 }
1783
1784 out[outIdx] = '\0';
1785 *outLen = outIdx;
1786
1787 return inIdx;
1788
1789 }
1790 #endif
1791
1792 #ifdef FF_ATI
1793 /*
1794 +-------------------------------------------------------------------+
1795 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
1796 | STATE : code ROUTINE : utl_ucs2FromGsm_ussd |
1797 +-------------------------------------------------------------------+
1798
1799 PURPOSE : This function converts the characters of USSD string from
1800 the ACI internal GSM character set to the "UCS2"
1801 character set with 2 bytes only.
1802 */
1803 GLOBAL USHORT utl_ucs2FromGsm_ussd(UBYTE* in,
1804 USHORT inLen,
1805 UBYTE* out,
1806 USHORT maxOutLen,
1807 USHORT* outLen,
1808 T_ACI_GSM_ALPHA gsm,
1809 T_ACI_CSCS_ALPHA alphabet )
1810 {
1811 USHORT inIdx = 0;
1812 USHORT outIdx = 0;
1813
1814 while ( inIdx < inLen AND outIdx < maxOutLen - 4 )
1815 {
1816 if ( alphabet NEQ CSCS_ALPHA_7_Bit OR
1817 ( gsm EQ GSM_ALPHA_Def AND !( in[inIdx] & 0x80 ) ) OR
1818 ( gsm EQ GSM_ALPHA_Int AND ( in[inIdx] & 0x80 ) ) )
1819 {
1820 /* 2 bytes for convertion from GSM to UCS2 */
1821 out[outIdx++] = 0x00;
1822 out[outIdx++] = gsmToAsciiTable[in[inIdx] & 0x7F];
1823 }
1824
1825 inIdx++;
1826 }
1827
1828 out[outIdx] = '\0';
1829 *outLen = outIdx;
1830
1831 return inIdx;
1832
1833 }
1834 #endif
1835 #ifdef FF_ATI
1836 /*
1837 +-------------------------------------------------------------------+
1838 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
1839 | STATE : code ROUTINE : utl_smDtaToTe |
1840 +-------------------------------------------------------------------+
1841
1842 PURPOSE : This function converts the SM data in the format
1843 specified in Rec. GSM 07.05, message data parameter
1844 <data>, to the format used by the AT Command Interface.
1845 */
1846 GLOBAL void utl_smDtaToTe ( UBYTE* in,
1847 USHORT inLen,
1848 UBYTE* out,
1849 USHORT maxOutLen,
1850 USHORT* outLen,
1851 UBYTE fo,
1852 UBYTE dcs )
1853 {
1854 UBYTE alphabet = cmhSMS_getAlphabetPp ( dcs );
1855
1856 if ( alphabet EQ CSCS_ALPHA_7_Bit AND
1857 (fo & TP_UDHI_MASK) EQ TP_UDHI_WITHOUT_HEADER )
1858 {
1859 utl_chsetFromGsm ( in, inLen, out, maxOutLen, outLen, GSM_ALPHA_Def );
1860 }
1861 else if ( alphabet NEQ CSCS_ALPHA_7_Bit OR
1862 (fo & TP_UDHI_MASK) EQ TP_UDHI_WITH_HEADER )
1863 {
1864 utl_hexFromGsm ( in, inLen, out, maxOutLen, outLen, GSM_ALPHA_Def,
1865 CSCS_ALPHA_8_Bit );
1866 }
1867 else
1868 {
1869 *outLen = MINIMUM ( inLen, maxOutLen - 1 );
1870 memcpy ( out, in, *outLen );
1871 out[*outLen] = '\0';
1872 }
1873 }
1874 #endif
1875
1876 #ifdef FF_ATI
1877 /*
1878 +-------------------------------------------------------------------+
1879 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
1880 | STATE : code ROUTINE : utl_smDtaFromTe |
1881 +-------------------------------------------------------------------+
1882
1883 PURPOSE : This function converts the SM data in the format used
1884 by the AT Command Interface to the format specified in
1885 Rec. GSM 07.05, message data parameter <data>.
1886 */
1887 GLOBAL void utl_smDtaFromTe ( UBYTE* in,
1888 USHORT inLen,
1889 UBYTE* out,
1890 USHORT* outLen,
1891 #ifdef REL99
1892 USHORT outBufLen,
1893 #endif
1894 UBYTE fo,
1895 UBYTE dcs )
1896 {
1897 UBYTE alphabet = cmhSMS_getAlphabetPp ( dcs );
1898
1899 if ( alphabet EQ CSCS_ALPHA_7_Bit AND
1900 ( fo & TP_UDHI_MASK ) EQ TP_UDHI_WITHOUT_HEADER )
1901 {
1902 #ifdef REL99
1903 utl_chsetToGsm ( in, inLen, out, outLen, outBufLen, GSM_ALPHA_Def );
1904 #else
1905 utl_chsetToGsm ( in, inLen, out, outLen, GSM_ALPHA_Def );
1906 #endif
1907
1908 }
1909 else if ( alphabet NEQ CSCS_ALPHA_7_Bit OR
1910 ( fo & TP_UDHI_MASK ) EQ TP_UDHI_WITH_HEADER )
1911 {
1912 utl_hexToGsm ( in, inLen, out, outLen, GSM_ALPHA_Def, (T_ACI_CSCS_ALPHA)alphabet );
1913 }
1914 else
1915 {
1916 memcpy ( out, in, inLen );
1917 *outLen = inLen;
1918 }
1919 }
1920 #endif
1921
1922 #ifdef FF_ATI
1923 /*
1924 +-------------------------------------------------------------------+
1925 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
1926 | STATE : code ROUTINE : utl_ussdDtaFromTe |
1927 +-------------------------------------------------------------------+
1928
1929 PURPOSE : This function converts the USSD data in the format used
1930 by the AT Command Interface to the format specified in
1931 Rec. GSM 07.07.
1932 */
1933 GLOBAL void utl_ussdDtaFromTe ( UBYTE* in,
1934 USHORT inLen,
1935 UBYTE* out,
1936 USHORT* outLen,
1937 #ifdef REL99
1938 USHORT outBufLen,
1939 #endif
1940 UBYTE dcs )
1941 {
1942 /* Implements Measure 25 */
1943 UBYTE alphabet = cmh_getAlphabetCb ( dcs );
1944
1945 if ( alphabet EQ CSCS_ALPHA_7_Bit )
1946 {
1947 #ifdef REL99
1948 utl_chsetToGsm ( in, inLen, out, outLen, outBufLen, GSM_ALPHA_Def );
1949 #else
1950 utl_chsetToGsm ( in, inLen, out, outLen, GSM_ALPHA_Def );
1951 #endif
1952
1953 }
1954 else
1955 {
1956 utl_hexToGsm ( in, inLen, out, outLen, GSM_ALPHA_Def, (T_ACI_CSCS_ALPHA)alphabet );
1957 }
1958 }
1959 #endif
1960
1961 #ifdef FF_ATI
1962 /*
1963 +-------------------------------------------------------------------+
1964 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
1965 | STATE : code ROUTINE : utl_ussdDtaToTe |
1966 +-------------------------------------------------------------------+
1967
1968 PURPOSE : This function converts the USSD data in the format
1969 specified in Rec. GSM 07.07 to the format used
1970 by the AT Command Interface.
1971 */
1972
1973 GLOBAL USHORT utl_ussdDtaToTe ( UBYTE* in,
1974 USHORT inLen,
1975 UBYTE* out,
1976 USHORT maxOutLen,
1977 USHORT* outLen,
1978 UBYTE dcs )
1979 {
1980 /* Implements Measure 25 */
1981 UBYTE alphabet = cmh_getAlphabetCb ( dcs );
1982 if ( alphabet EQ CSCS_ALPHA_7_Bit )
1983 {
1984 return utl_chsetFromGsm ( in, inLen, out, maxOutLen, outLen, GSM_ALPHA_Def );
1985 }
1986 else
1987 {
1988 return utl_hexFromGsm ( in, inLen, out, maxOutLen, outLen, GSM_ALPHA_Def, (T_ACI_CSCS_ALPHA)alphabet );
1989 }
1990 }
1991 #endif
1992
1993 #ifdef FF_ATI
1994 /*
1995 +-------------------------------------------------------------------+
1996 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
1997 | STATE : code ROUTINE : utl_cbmDtaToTe |
1998 +-------------------------------------------------------------------+
1999
2000 PURPOSE : This function converts the CBM data in the format
2001 specified in Rec. GSM 07.05, message data parameter
2002 <data>, to the format used by the AT Command Interface.
2003 */
2004 GLOBAL void utl_cbmDtaToTe ( UBYTE* in,
2005 USHORT inLen,
2006 UBYTE* out,
2007 USHORT maxOutLen,
2008 USHORT* outLen,
2009 UBYTE fo,
2010 UBYTE dcs )
2011 {
2012 /* Implements Measure 25 */
2013 UBYTE alphabet = cmh_getAlphabetCb ( dcs );
2014 if ( alphabet EQ CSCS_ALPHA_7_Bit AND
2015 ( fo & TP_UDHI_MASK ) EQ TP_UDHI_WITHOUT_HEADER )
2016 {
2017 utl_chsetFromGsm ( in, inLen, out, maxOutLen, outLen, GSM_ALPHA_Def );
2018 }
2019 else if ( alphabet NEQ CSCS_ALPHA_7_Bit OR
2020 ( fo & TP_UDHI_MASK ) EQ TP_UDHI_WITH_HEADER )
2021 {
2022 utl_hexFromGsm ( in, inLen, out, maxOutLen, outLen, GSM_ALPHA_Def, (T_ACI_CSCS_ALPHA)alphabet );
2023 }
2024 else
2025 {
2026 *outLen = MINIMUM ( inLen, maxOutLen );
2027 memcpy ( out, in, *outLen );
2028 }
2029 }
2030 #endif
2031
2032 /*
2033 +-------------------------------------------------------------------+
2034 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
2035 | STATE : code ROUTINE : utl_cvtGsmIra |
2036 +-------------------------------------------------------------------+
2037
2038 PURPOSE : This function converts the characters of a string from
2039 the ACI internal GSM character set to the IRA character
2040 set or vice versa.
2041 */
2042 GLOBAL BOOL utl_cvtGsmIra ( UBYTE* in,
2043 USHORT inLen,
2044 UBYTE* out,
2045 USHORT outLen,
2046 T_ACI_CSCS_DIR dir )
2047 {
2048 USHORT inIdx = 0;
2049 USHORT outIdx = 0;
2050 USHORT tblIdx;
2051 UBYTE cvtdVal;
2052
2053 TRACE_FUNCTION("utl_cvtGsmIra()");
2054
2055
2056 if ( inLen > outLen )
2057 {
2058 return ( FALSE );
2059 }
2060
2061 if ( dir EQ CSCS_DIR_GsmToIra )
2062 {
2063 while ( inIdx < inLen )
2064 {
2065 tblIdx = 0;
2066
2067 while ( tblIdx <= 0xFF AND
2068 chset[CSCS_CHSET_Ira][tblIdx] NEQ (( UBYTE )in[inIdx] | 0x80 ))
2069 tblIdx++;
2070
2071 if ( tblIdx <= 0xFF )
2072 {
2073 out[outIdx] = ( UBYTE )tblIdx;
2074 outIdx++;
2075 }
2076 else
2077 {
2078 return ( FALSE );
2079 }
2080
2081 inIdx++;
2082 }
2083 }
2084 else if ( dir EQ CSCS_DIR_IraToGsm )
2085 {
2086 for ( inIdx = 0; inIdx < inLen; inIdx++ )
2087 {
2088 cvtdVal = chset[CSCS_CHSET_Ira][( UBYTE ) in[inIdx]];
2089
2090 if ( cvtdVal NEQ 0x00 )
2091 {
2092 out[outIdx] = ( CHAR ) cvtdVal & 0x7F;
2093 outIdx++;
2094 }
2095 else
2096 {
2097 return ( FALSE );
2098 }
2099 }
2100
2101 }
2102 else
2103 {
2104 return ( FALSE );
2105 }
2106
2107 return ( TRUE );
2108 }
2109
2110
2111 /*
2112 +-------------------------------------------------------------------+
2113 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
2114 | STATE : code ROUTINE : utl_binToHex |
2115 +-------------------------------------------------------------------+
2116
2117 PURPOSE : This function converts a binary string of bytes with a
2118 given length into an null terminated ASCII string
2119 representation.
2120 */
2121 GLOBAL void utl_binToHex (UBYTE* in,
2122 SHORT inLen,
2123 CHAR* out )
2124 {
2125 SHORT idx = 0;
2126 UBYTE hNib;
2127 UBYTE lNib;
2128
2129 while( idx < inLen )
2130 {
2131 hNib = (in[idx]&0xF0)>>4;
2132
2133 if( hNib > 9 ) *out = (hNib-10)+0x41;
2134 else *out = hNib + 0x30;
2135
2136 out++;
2137
2138 lNib = in[idx]&0x0F;
2139
2140 if( lNib > 9 ) *out = (lNib-10)+0x41;
2141 else *out = lNib + 0x30;
2142
2143 out++;
2144 idx++;
2145 }
2146 *out = 0x0;
2147 }
2148
2149
2150 #ifdef FF_ATI
2151 /*
2152 +-------------------------------------------------------------------+
2153 | PROJECT : GSM MODULE : ACI_UTIL |
2154 | STATE : code ROUTINE : utl_HexStrToBin |
2155 +-------------------------------------------------------------------+
2156
2157 PURPOSE : This function converts a null terminated string of HEX
2158 values in a binary buffer.
2159 RETURN: byte count.
2160 */
2161 GLOBAL USHORT utl_HexStrToBin (UBYTE *in,
2162 USHORT inLen,
2163 UBYTE *out,
2164 USHORT outLen)
2165 {
2166 USHORT inIdx = 0;
2167 USHORT outIdx = 0;
2168 UBYTE value;
2169 BOOL hNib = TRUE;
2170
2171 while ((inIdx < inLen) AND (outIdx < outLen))
2172 {
2173 if ((in[inIdx] >= 0x30) AND (in[inIdx] <= 0x39))
2174 {
2175 value = in[inIdx] - 0x30;
2176 }
2177 else if ((in[inIdx] >= 0x61) AND (in[inIdx] <= 0x66))
2178 {
2179 value = in[inIdx] - 0x61 + 0x0A;
2180 }
2181 else if ((in[inIdx] >= 0x41) AND (in[inIdx] <= 0x46))
2182 {
2183 value = in[inIdx] - 0x41 + 0x0A;
2184 }
2185 else
2186 {
2187 return (0);
2188 }
2189
2190 if (hNib)
2191 {
2192 out[outIdx] = (value << 0x04) & 0xF0;
2193 hNib = FALSE;
2194 }
2195 else
2196 {
2197 out[outIdx] |= value & 0x0F;
2198 hNib = TRUE;
2199 outIdx++;
2200 }
2201 inIdx++;
2202 }
2203
2204 return (outIdx);
2205 }
2206 #endif
2207
2208 #ifdef FF_ATI
2209 /*
2210 +-------------------------------------------------------------------+
2211 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
2212 | STATE : code ROUTINE : trace_cmd_line |
2213 +-------------------------------------------------------------------+
2214
2215 PURPOSE : This function trace the command line and check
2216 this string for % character
2217 */
2218
2219 GLOBAL void trace_cmd_line (char *prefix, char *output, UBYTE srcId, USHORT output_len)
2220 {
2221 char trcBuf[80];
2222 int dst_i;
2223
2224 dst_i = sprintf (trcBuf, "%s(Src %d)[lth %d]", (prefix) ? prefix : "", srcId, output_len);
2225
2226 strncpy(&trcBuf[dst_i], output, 79-dst_i);
2227 trcBuf[79] = '\0';
2228
2229 if (trcBuf[76])
2230 {
2231 trcBuf[76] = trcBuf[77] = trcBuf[78] = '.'; /* add trailing "..." if string is >=76 */
2232 }
2233
2234 /* Send the trace if either EVENT or CLASS8 is turned on */
2235 TRACE_USER_CLASS_P1(TC_EVENT|TC_USER8, "%s",trcBuf);
2236 }
2237 #endif
2238
2239
2240 #ifdef FF_ATI
2241 /*
2242 +-------------------------------------------------------------------+
2243 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
2244 | STATE : code ROUTINE : trace_cmd_state |
2245 +-------------------------------------------------------------------+
2246
2247 PURPOSE : This function trace the command line state
2248 */
2249
2250 GLOBAL void trace_cmd_state (UBYTE srcId,
2251 T_ATI_CMD_STATE old_state,
2252 T_ATI_CMD_STATE new_state)
2253 {
2254 char trcBuf[50];
2255
2256 if (old_state EQ new_state)
2257 {
2258 return;
2259 }
2260
2261 sprintf (trcBuf, "(Src %d) cmd_state: ", srcId );
2262
2263 switch (old_state)
2264 {
2265 case (CMD_IDLE):
2266 strcat (trcBuf, "CMD_IDLE -> ");
2267 break;
2268 case (CMD_TYPING):
2269 strcat (trcBuf, "CMD_TYPING -> ");
2270 break;
2271 case (CMD_RUNNING):
2272 strcat (trcBuf, "CMD_RUNNING -> ");
2273 break;
2274 default:
2275 strcat (trcBuf, "CMD_UNKNOWN ! ");
2276 }
2277
2278 switch (new_state)
2279 {
2280 case (CMD_IDLE):
2281 strcat (trcBuf, "CMD_IDLE");
2282 break;
2283 case (CMD_TYPING):
2284 strcat (trcBuf, "CMD_TYPING");
2285 break;
2286 case (CMD_RUNNING):
2287 strcat (trcBuf, "CMD_RUNNING");
2288 break;
2289 default:
2290 strcat (trcBuf, "CMD_UNKNOWN !");
2291 }
2292
2293 TRACE_EVENT_P1("%s",trcBuf);
2294 }
2295 #endif
2296
2297 /*
2298 +--------------------------------------------------------------------+
2299 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
2300 | STATE : code ROUTINE : toa_merge |
2301 +--------------------------------------------------------------------+
2302
2303 PURPOSE : builds type of address octet from TOA structure
2304
2305 */
2306
2307 GLOBAL UBYTE toa_merge (T_ACI_TOA type)
2308 {
2309
2310 return ((type.ton << 4) & 0xF0)
2311 | ( type.npi & 0x0F)
2312 | 0x80;
2313 }
2314
2315
2316
2317 #ifdef GPRS
2318 /*
2319 +-----------------------------------------------------------------------------
2320 | Function : utl_create_pco
2321 +-----------------------------------------------------------------------------
2322 | Description : The function create_pco() creates protocol configuration
2323 | options needed to activate a PDPcontext.
2324 |
2325 | Parameters : buffer - buffer to write the PCOs
2326 | length - on call: buffer size; on return: written bytes
2327 | content - mask to specify the PCO content
2328 | config_prot - used configuration protocol (currently PPP)
2329 | auth_prot - authentication protocol (currently PAP)
2330 | user_name - string with the user name
2331 | password - string with the password
2332 | dns1 - requested primary DNS address
2333 | dns2 - requested secondary DNS address
2334 |
2335 | Return : 0 - operation successful
2336 | -1 - operation fails
2337 |
2338 +-----------------------------------------------------------------------------
2339 */
2340 GLOBAL int utl_create_pco (UBYTE* buffer,
2341 USHORT* length,
2342 ULONG content,
2343 UBYTE config_prot,
2344 USHORT auth_prot,
2345 UBYTE* user_name,
2346 UBYTE* password,
2347 ULONG dns1,
2348 ULONG dns2)
2349 {
2350 USHORT size;
2351 USHORT temp_len;
2352 USHORT len_user;
2353 USHORT len_pwd;
2354 USHORT written;
2355 UBYTE* pos;
2356 UBYTE* len_pos1;
2357 UBYTE* len_pos2;
2358
2359 TRACE_FUNCTION( "create_pco" );
2360
2361 /*
2362 * store buffer size
2363 */
2364 size = *length;
2365 /*
2366 * initialize values
2367 */
2368 *length = 0;
2369 written = 0;
2370 pos = buffer;
2371 /*
2372 * calculate if requested content is writeable
2373 */
2374 temp_len = 1;
2375 if(content & ACI_PCO_CONTENTMASK_AUTH)
2376 {
2377 len_user = strlen((char*)user_name);
2378 len_pwd = strlen((char*)password);
2379 temp_len+= ACI_PCO_PAP_OVERHEAD + len_user + len_pwd;
2380 }
2381 if((content & ACI_PCO_CONTENTMASK_DNS1) ||
2382 (content & ACI_PCO_CONTENTMASK_DNS2))
2383 {
2384 temp_len+= ACI_PCO_IPCP_OVERHEAD;
2385 if(content & ACI_PCO_CONTENTMASK_DNS1)
2386 temp_len+= ACI_PCO_IPCP_LENGTH_DNS1;
2387 if(content & ACI_PCO_CONTENTMASK_DNS2)
2388 temp_len+= ACI_PCO_IPCP_LENGTH_DNS2;
2389 }
2390 TRACE_EVENT_P2("temp_len=%d size=%d", temp_len, size);
2391 if(temp_len > size)
2392 {
2393 /*
2394 * content is to long
2395 */
2396 return -1;
2397 }
2398 /*
2399 * set configuration protocol identifier
2400 */
2401 *pos = 0x80 | config_prot;
2402 pos++;
2403 written++;
2404
2405 /*
2406 * authentication
2407 */
2408 if(content & ACI_PCO_CONTENTMASK_AUTH)
2409 {
2410 /*
2411 * set authentication protocol
2412 */
2413 *pos = (UBYTE)((auth_prot >> 8) & 0x00ff);
2414 pos++;
2415 written++;
2416 *pos = (UBYTE)(auth_prot & 0x00ff);
2417 pos++;
2418 written++;
2419 /*
2420 * store first length position
2421 */
2422 len_pos1 = pos;
2423 pos++;
2424 written++;
2425 /*
2426 * Code field
2427 */
2428 *pos = ACI_PCO_PAP_AUTH_REQ;
2429 pos++;
2430 written++;
2431 /*
2432 * Identifier field (just some value)
2433 */
2434 *pos = 0x01;
2435 pos++;
2436 written++;
2437 /*
2438 * Length field (store length position)
2439 */
2440 *pos = 0x00;
2441 pos++;
2442 written++;
2443 len_pos2 = pos;
2444 pos++;
2445 written++;
2446 /*
2447 * User Name Length field
2448 */
2449 *pos = (UBYTE)(/*lint -e(644) */len_user & 0x00ff);
2450 pos++;
2451 written++;
2452 /*
2453 * User Name field
2454 */
2455 memcpy(pos, user_name, len_user);
2456 pos += len_user;
2457 written+= len_user;
2458 /*
2459 * Password Length field
2460 */
2461 *pos = (UBYTE)(/*lint -e(644) */len_pwd & 0x00ff);
2462 pos++;
2463 written++;
2464 /*
2465 * Password field
2466 */
2467 memcpy(pos, password, len_pwd);
2468 pos += len_pwd;
2469 written+= len_pwd;
2470 /*
2471 * fill length fields
2472 */
2473 *len_pos1 = (UBYTE)(pos - len_pos1 - 1);
2474 *len_pos2 = *len_pos1;
2475 }
2476 /*
2477 * DNS addresses
2478 */
2479 if((content & ACI_PCO_CONTENTMASK_DNS1) ||
2480 (content & ACI_PCO_CONTENTMASK_DNS2))
2481 {
2482 /*
2483 * set IPCP protocol
2484 */
2485 *pos = ACI_PCO_IPCP_PROT_MSB;
2486 pos++;
2487 written++;
2488 *pos = ACI_PCO_IPCP_PROT_LSB;
2489 pos++;
2490 written++;
2491 /*
2492 * store first length position
2493 */
2494 len_pos1 = pos;
2495 pos++;
2496 written++;
2497 /*
2498 * Code field
2499 */
2500 *pos = ACI_PCO_IPCP_CONF_REQ;
2501 pos++;
2502 written++;
2503 /*
2504 * Identifier field (just some value)
2505 */
2506 *pos = 0x01;
2507 pos++;
2508 written++;
2509 /*
2510 * Length field (store length position)
2511 */
2512 *pos = 0x00;
2513 pos++;
2514 written++;
2515 len_pos2 = pos;
2516 pos++;
2517 written++;
2518 /*
2519 * primary DNS address
2520 */
2521 if(content & ACI_PCO_CONTENTMASK_DNS1)
2522 {
2523 /*
2524 * Type field
2525 */
2526 *pos = ACI_PCO_IPCP_TYPE_DNS1;
2527 pos++;
2528 written++;
2529 /*
2530 * Length field
2531 */
2532 *pos = ACI_PCO_IPCP_LENGTH_DNS1;
2533 pos++;
2534 written++;
2535 /*
2536 * primary DNS address
2537 */
2538 *pos = (UBYTE)((dns1 >> 24) & 0x000000ff);
2539 pos++;
2540 written++;
2541 *pos = (UBYTE)((dns1 >> 16) & 0x000000ff);
2542 pos++;
2543 written++;
2544 *pos = (UBYTE)((dns1 >> 8) & 0x000000ff);
2545 pos++;
2546 written++;
2547 *pos = (UBYTE)(dns1 & 0x000000ff);
2548 pos++;
2549 written++;
2550 }
2551 /*
2552 * secondary DNS address
2553 */
2554 if(content & ACI_PCO_CONTENTMASK_DNS2)
2555 {
2556 /*
2557 * Type field
2558 */
2559 *pos = ACI_PCO_IPCP_TYPE_DNS2;
2560 pos++;
2561 written++;
2562 /*
2563 * Length field
2564 */
2565 *pos = ACI_PCO_IPCP_LENGTH_DNS2;
2566 pos++;
2567 written++;
2568 /*
2569 * primary DNS address
2570 */
2571 *pos = (UBYTE)((dns2 >> 24) & 0x000000ff);
2572 pos++;
2573 written++;
2574 *pos = (UBYTE)((dns2 >> 16) & 0x000000ff);
2575 pos++;
2576 written++;
2577 *pos = (UBYTE)((dns2 >> 8) & 0x000000ff);
2578 pos++;
2579 written++;
2580 *pos = (UBYTE)(dns2 & 0x000000ff);
2581 pos++;
2582 written++;
2583 }
2584 /*
2585 * fill length fields
2586 */
2587 *len_pos1 = (UBYTE)(pos - len_pos1 - 1);
2588 *len_pos2 = *len_pos1;
2589 }
2590 /*
2591 * pass written bytes to caller
2592 */
2593 *length = written;
2594 /*
2595 * return result
2596 */
2597 return 0;
2598 } /* utl_create_pco() */
2599
2600
2601
2602 /*
2603 +-----------------------------------------------------------------------------
2604 | Function : utl_analyze_pco
2605 +-----------------------------------------------------------------------------
2606 | Description : The function analyze_pco() analyzes the response protocol
2607 | configuration from the network
2608 |
2609 | Parameters : buffer - buffer with the response PCOs
2610 | length - length of PCOs
2611 | dns1 - returns primary DNS address
2612 | dns2 - returns secondary DNS address
2613 | gateway - returns Gateway address
2614 |
2615 | Return : 0 - operation successful
2616 | -1 - operation fails
2617 |
2618 +-----------------------------------------------------------------------------
2619 */
2620 GLOBAL int utl_analyze_pco (UBYTE* buffer,
2621 USHORT length,
2622 ULONG* dns1,
2623 ULONG* dns2,
2624 ULONG* gateway)
2625 {
2626 UBYTE* pos;
2627 USHORT pos_len;
2628 USHORT packet_len;
2629 USHORT start_pos;
2630 USHORT dist_to_next;
2631 UBYTE type_len;
2632
2633 TRACE_FUNCTION( "utl_analyze_pco" );
2634
2635 /*
2636 * initialize values
2637 */
2638 pos = buffer;
2639 pos_len = 0;
2640 *dns1 = 0;
2641 *dns2 = 0;
2642 *gateway = 0;
2643 /*
2644 * check configuration protocol
2645 */
2646 if( (length <= pos_len) ||
2647 !(*pos & 0x80) )
2648 {
2649 return -1;
2650 }
2651
2652 #if 0
2653 /* Table 10.5.154/3GPP TS 24.008 states:
2654 "All other values are interpreded as PPP in this version of the protocol.
2655 so the next check should not be performed
2656 */
2657 if((*pos & 0x07) NEQ ACI_PCO_CONFIG_PROT_PPP)
2658 {
2659 /*
2660 * configuration protocol is not PPP
2661 */
2662 return 0;
2663 }
2664 #endif
2665
2666 pos++;
2667 pos_len++;
2668
2669 /*
2670 * search for IPCP packet
2671 */
2672 while(length > (pos_len + ACI_PCO_IPCP_OVERHEAD))
2673 {
2674 /*
2675 * initialize distance to next packet
2676 */
2677 dist_to_next = *(pos + 2) + 3;
2678 /*
2679 * check for IPCP packet
2680 */
2681 if((*pos EQ ACI_PCO_IPCP_PROT_MSB) AND
2682 (*(pos + 1) EQ ACI_PCO_IPCP_PROT_LSB))
2683 {
2684 /*
2685 * check for correct length field
2686 */
2687 pos += 2;
2688 pos_len += 2;
2689 dist_to_next-= 2;
2690 packet_len = *(pos + 3);
2691 packet_len = packet_len << 8;
2692 packet_len += *(pos + 4);
2693 if((packet_len EQ *pos) AND
2694 (length > (pos_len + packet_len)))
2695 {
2696 pos++;
2697 pos_len++;
2698 dist_to_next--;
2699 /*
2700 * check of code field
2701 */
2702 start_pos = pos_len;
2703 switch(*pos)
2704 {
2705 case ACI_PCO_IPCP_CONF_REQ:
2706 /*
2707 * search for Gateway address
2708 */
2709 pos += 4;
2710 pos_len+= 4;
2711 while((pos_len + 1 - start_pos) < packet_len)
2712 {
2713 type_len = *(pos + 1);
2714 if((*pos EQ ACI_PCO_IPCP_TYPE_IP) AND
2715 (type_len EQ ACI_PCO_IPCP_LENGTH_IP) AND
2716 ((pos_len +
2717 ACI_PCO_IPCP_LENGTH_IP -
2718 start_pos) <= packet_len))
2719 {
2720 *gateway = *(pos + 2);
2721 *gateway = ((*gateway) << 8);
2722 *gateway+= *(pos + 3);
2723 *gateway = ((*gateway) << 8);
2724 *gateway+= *(pos + 4);
2725 *gateway = ((*gateway) << 8);
2726 *gateway+= *(pos + 5);
2727 }
2728 pos += type_len;
2729 pos_len+= type_len;
2730 }
2731 if((pos_len - start_pos) <= packet_len)
2732 {
2733 dist_to_next = packet_len + start_pos - pos_len;
2734 }
2735 else
2736 {
2737 dist_to_next = 0;
2738 pos -= (pos_len - start_pos - packet_len);
2739 pos_len -= (pos_len - start_pos - packet_len);
2740 }
2741 break;
2742
2743 case ACI_PCO_IPCP_CONF_ACK:
2744 case ACI_PCO_IPCP_CONF_NAK:
2745 /*
2746 * search for DNS addresses
2747 */
2748 pos += 4;
2749 pos_len+= 4;
2750 while((pos_len + 1 - start_pos) < packet_len)
2751 {
2752 type_len = *(pos + 1);
2753 if((*pos EQ ACI_PCO_IPCP_TYPE_DNS1) AND
2754 (type_len EQ ACI_PCO_IPCP_LENGTH_DNS1) AND
2755 ((pos_len +
2756 ACI_PCO_IPCP_LENGTH_DNS1 -
2757 start_pos) <= packet_len))
2758 {
2759 *dns1 = *(pos + 2);
2760 *dns1 = ((*dns1) << 8);
2761 *dns1+= *(pos + 3);
2762 *dns1 = ((*dns1) << 8);
2763 *dns1+= *(pos + 4);
2764 *dns1 = ((*dns1) << 8);
2765 *dns1+= *(pos + 5);
2766 }
2767 else if((*pos EQ ACI_PCO_IPCP_TYPE_DNS2) AND
2768 (type_len EQ ACI_PCO_IPCP_LENGTH_DNS2) AND
2769 ((pos_len +
2770 ACI_PCO_IPCP_LENGTH_DNS2 -
2771 start_pos) <= packet_len))
2772 {
2773 *dns2 = *(pos + 2);
2774 *dns2 = ((*dns2) << 8);
2775 *dns2+= *(pos + 3);
2776 *dns2 = ((*dns2) << 8);
2777 *dns2+= *(pos + 4);
2778 *dns2 = ((*dns2) << 8);
2779 *dns2+= *(pos + 5);
2780 }
2781 pos += type_len;
2782 pos_len+= type_len;
2783 }
2784 if((pos_len - start_pos) <= packet_len)
2785 {
2786 dist_to_next = packet_len + start_pos - pos_len;
2787 }
2788 else
2789 {
2790 dist_to_next = 0;
2791 pos -= (pos_len - start_pos - packet_len);
2792 pos_len -= (pos_len - start_pos - packet_len);
2793 }
2794 break;
2795 }
2796 }
2797 }
2798 /*
2799 * go to next packet
2800 */
2801 pos_len+= dist_to_next;
2802 pos += dist_to_next;
2803 }
2804 /*
2805 * return
2806 */
2807 return 0;
2808 } /* utl_analyze_pco() */
2809
2810
2811
2812
2813 GLOBAL int utl_strcasecmp (const char *s1, const char *s2)
2814 {
2815 char c1, c2;
2816 int i;
2817
2818 int len1 = (s1 EQ NULL) ? 0 : strlen(s1);
2819 int len2 = (s2 EQ NULL) ? 0 : strlen(s2);
2820
2821 if (len1 > len2)
2822 {
2823 return (1);
2824 }
2825 if(len1 < len2)
2826 {
2827 return (-1);
2828 }
2829 for (i = 0; i < len1; i++)
2830 {
2831 c1 = s1[i]; /*lint !e613 (Warning -- 613: Possible use of null pointer 's1' in left argument to operator '[' [Reference: file condat\ms\src\aci\aci_util.c: line 2349] ) */
2832 c2 = s2[i]; /*lint !e613 (Warning -- 613: Possible use of null pointer 's2' in left argument to operator '[' [Reference: file condat\ms\src\aci\aci_util.c: line 2349] ) */
2833 if (c1 EQ c2)
2834 {
2835 continue ;
2836 }
2837 if (c1 >= 'a' AND c1 <= 'z')
2838 {
2839 c1 = c1 - ('a'-'A');
2840 }
2841 if (c2 >= 'a' AND c2 <= 'z')
2842 {
2843 c2 = c2 - ('a'-'A');
2844 }
2845 if (c1 NEQ c2)
2846 {
2847 return (1);
2848 }
2849 }
2850 return (0);
2851 }
2852
2853
2854 #endif /* GPRS */
2855
2856
2857
2858 #if defined (FF_ATI) || defined (FF_BAT)
2859
2860 /*
2861 +--------------------------------------------------------------------+
2862 | PROJECT : GSM-PS (6147) MODULE : ACI_UTIL |
2863 | STATE : code ROUTINE : rci_display_USSD |
2864 +--------------------------------------------------------------------+
2865
2866 PURPOSE : used by rCI_PlusCUSD and utl_cb_percentKSIR
2867 */
2868 GLOBAL void rci_display_USSD (UBYTE srcId,
2869 T_ACI_CUSD_MOD mode,
2870 UBYTE *ussd_str,
2871 UBYTE ussd_len,
2872 BOOL cvtStr,
2873 SHORT dcs )
2874 {
2875 SHORT pos = 0;
2876 USHORT chunksize;
2877 USHORT lenCvtdStr;
2878 CHAR sa[80];
2879
2880
2881 TRACE_FUNCTION("rci_display_USSD()");
2882
2883 pos = sprintf(sa,"+CUSD: ");
2884
2885 if (mode NEQ CUSD_MOD_NotPresent)
2886 {
2887 pos += sprintf(sa+pos,"%d,",mode);
2888 }
2889 else
2890 pos += sprintf(sa+pos,",");
2891
2892 if(ussd_str NEQ NULL)
2893 {
2894 pos += sprintf(sa+pos,"\""); /* beginning double quote */
2895 while (ussd_len)
2896 {
2897 if( cvtStr EQ CONVERT_STRING )
2898 {
2899 chunksize = utl_ussdDtaToTe( ussd_str,
2900 (USHORT)ussd_len,
2901 (UBYTE*)(sa + pos),
2902 sizeof(sa)-pos,
2903 &lenCvtdStr,
2904 (UBYTE)dcs );
2905
2906 pos += lenCvtdStr;
2907 }
2908 else
2909 {
2910 /*
2911 * How much space do we have left in the output array?
2912 */
2913 chunksize=(sizeof(sa)-pos)-1;
2914
2915 if (ussd_len<chunksize)
2916 {
2917 /*
2918 * Remaining data fits within the output array.
2919 */
2920 chunksize=ussd_len;
2921 }
2922 else if (chunksize>3)
2923 {
2924 /*
2925 * If the remaining data will not fit in the output
2926 * array, and we have more than 3 bytes available (which
2927 * we will), make sure that the amount of data output
2928 * divides by 4. This is so we don't split UCS2 characters
2929 * between two lines of output.
2930 */
2931 chunksize &= ~0x3;
2932 }
2933
2934 memcpy(sa+pos,ussd_str,chunksize);
2935
2936 pos += chunksize;
2937
2938 sa[pos]=0;
2939 }
2940 ussd_len-=chunksize;
2941 ussd_str+=chunksize;
2942
2943 if (ussd_len OR (sizeof(sa)-pos) < 10)
2944 {
2945 #ifdef _SIMULATION_
2946 io_sendMessage(srcId, sa, ATI_NORMAL_OUTPUT); /* append CR+LF only for testcase */
2947 #else
2948 io_sendMessage(srcId, sa, ATI_ECHO_OUTPUT); /* normal output a chunk */
2949 #endif
2950 pos=0;
2951 memset(sa, 0, 80);
2952 }
2953 }
2954
2955 pos+=sprintf(sa+pos,"\","); /* ending double quote */
2956
2957 if (dcs EQ ACI_NumParmNotPresent)
2958 {
2959 /* see 07.07: default is 0 */
2960 dcs = 0;
2961 }
2962
2963 pos+=sprintf(sa+pos,"%d",dcs);
2964 }
2965
2966 ci_remTrailCom(sa, pos);
2967 io_sendMessage(srcId, sa, ATI_NORMAL_OUTPUT);
2968 }
2969
2970 /*
2971 ****************************************************************
2972 */
2973 LOCAL void utl_cvtCLIRStat ( UBYTE clirOpt,
2974 UBYTE ssSt,
2975 T_ACI_CLIR_STAT *clirStat )
2976 {
2977 if ( clirOpt EQ KSD_CO_NOT_VALID )
2978 {
2979 /* SS Status of class - T_ACI_KSD_ST */
2980 if ( ssSt EQ KSD_ST_NOT_VALID )
2981 *clirStat = CLIR_STAT_Unknown;
2982 else if ( ssSt & SSS_P )
2983 *clirStat = CLIR_STAT_Permanent;
2984 else
2985 *clirStat = CLIR_STAT_NotProv;
2986 }
2987 else
2988 {
2989 switch ( clirOpt )
2990 {
2991 case( CLIR_OPT_PERMANENT ):
2992 *clirStat = CLIR_STAT_Permanent;
2993 break;
2994
2995 case( CLIR_OPT_TEMPORARY ):
2996 *clirStat = CLIR_STAT_RestrictTemp;
2997 break;
2998
2999 case( CLIR_OPT_ALLOWED ):
3000 *clirStat = CLIR_STAT_AllowTemp;
3001 break;
3002
3003 default:
3004 *clirStat = CLIR_STAT_Unknown;
3005 break;
3006 }
3007 }
3008 }
3009
3010 /*
3011 ****************************************************************
3012 */
3013 LOCAL void utl_cb_ccbs( UBYTE srcId, T_ACI_KSIR * ksStat )
3014 {
3015 T_ACI_CCBS_SET *CCBS_Setting = NULL;
3016
3017 T_ACI_CCBS_STAT status;
3018 T_basicService basicServ;
3019 int i;
3020 T_CC_FEAT *ccbs_features;
3021
3022 TRACE_FUNCTION("utl_cb_ccbs()");
3023
3024 /* SS Status of CCBS */
3025 if (ksStat->ir.rKSCC.ssSt EQ KSD_ST_NOT_VALID)
3026 status = CCBS_STAT_NotPresent;
3027 else if (!(ksStat->ir.rKSCC.ssSt & SSS_P))
3028 status = CCBS_STAT_NotProvisioned;
3029 else if (ksStat->ir.rKSCC.ssSt & SSS_A)
3030 status = CCBS_STAT_Active;
3031 else
3032 status = CCBS_STAT_Provisioned;
3033
3034 ACI_MALLOC(CCBS_Setting, sizeof(T_ACI_CCBS_SET));
3035
3036 /* CCBS_Setting infos */
3037 if (!ksStat->ir.rKSCC.c_ccFeatLst)
3038 {
3039 TRACE_EVENT("KSD_CMD_CCBS: no feature list");
3040
3041 if (aci_cmd_src_mode_get((T_ACI_CMD_SRC)srcId) EQ CMD_MODE_ATI)
3042 {
3043 rCI_PercentCCBS(CCBS_IND_IrgtResult,
3044 status,
3045 CCBS_Setting,
3046 TRUE);
3047 }
3048 #ifdef FF_BAT
3049 else /* CMD_MODE_BAT */
3050 {
3051 rBAT_PercentCCBS(CCBS_IND_IrgtResult,
3052 status,
3053 CCBS_Setting,
3054 TRUE);
3055 }
3056 #endif
3057 return;
3058 }
3059
3060 for (i=0; i<ksStat->ir.rKSCC.c_ccFeatLst; i++)
3061 {
3062 ccbs_features = ksStat->ir.rKSCC.ccFeatLst + i;
3063
3064 memcpy( CCBS_Setting->number, ccbs_features->num, MAX_B_SUBSCR_NUM_LEN);
3065 memcpy( CCBS_Setting->subaddr, ccbs_features->sub, MAX_SUBADDR_LEN);
3066
3067 CCBS_Setting->type.npi = ccbs_features->npi NEQ 0xFF
3068 ? (T_ACI_TOA_NPI)ccbs_features->npi
3069 : NPI_NotPresent;
3070 CCBS_Setting->type.ton = ccbs_features->ton NEQ 0xFF
3071 ? (T_ACI_TOA_TON)ccbs_features->ton
3072 : TON_NotPresent;
3073 CCBS_Setting->satype.tos = ccbs_features->tos NEQ 0xFF
3074 ? (T_ACI_TOS_TOS)ccbs_features->tos
3075 : TOS_NotPresent;
3076 CCBS_Setting->satype.oe = ccbs_features->oe NEQ 0xFF
3077 ? (T_ACI_TOS_OE)ccbs_features->oe
3078 : OE_NotPresent;
3079
3080 if( ccbs_features->bsTp EQ BS_TELE_SRV )
3081 {
3082 basicServ.v_teleservice = TRUE;
3083 basicServ.v_bearerService = FALSE;
3084 basicServ.teleservice = ccbs_features->bsCd;
3085 }
3086 else /* if( p_servType EQ BS_BEAR_SRV ) */
3087 {
3088 basicServ.v_bearerService = TRUE;
3089 basicServ.v_teleservice = FALSE;
3090 basicServ.bearerService = ccbs_features->bsCd;
3091 }
3092
3093 CCBS_Setting->class_type = cmhSS_GetClass( &basicServ );
3094
3095 CCBS_Setting->idx = ccbs_features->idx NEQ 0xFF
3096 ? ccbs_features->idx
3097 : ACI_NumParmNotPresent;
3098
3099 CCBS_Setting->alrtPtn = ALPT_NotPresent;
3100
3101 if (aci_cmd_src_mode_get((T_ACI_CMD_SRC)srcId) EQ CMD_MODE_ATI)
3102 {
3103 rCI_PercentCCBS(CCBS_IND_IrgtResult,
3104 status,
3105 CCBS_Setting,
3106 TRUE);
3107 }
3108 #ifdef FF_BAT
3109 else /* CMD_MODE_BAT */
3110 {
3111 rBAT_PercentCCBS(CCBS_IND_IrgtResult,
3112 status,
3113 CCBS_Setting,
3114 TRUE);
3115 }
3116 #endif
3117 }
3118
3119 ACI_MFREE( CCBS_Setting );
3120 }
3121
3122 /*
3123 ****************************************************************
3124 */
3125 LOCAL void utl_cb_callwaiting( UBYTE srcId, T_ACI_KSIR *ksStat )
3126 {
3127 T_ACI_CLSSTAT classStat;
3128 UBYTE idx;
3129 T_ACI_TOA type;
3130
3131 TRACE_FUNCTION("utl_cb_callwaiting()");
3132
3133 if ( ksStat->ir.rKSCW.opCd NEQ KSD_OP_IRGT )
3134 return;
3135
3136 /* SS Status of class - T_ACI_KSD_ST */
3137 if ( ksStat->ir.rKSCW.ssSt EQ KSD_ST_NOT_VALID )
3138 {
3139 classStat.status = STATUS_NotPresent;
3140 }
3141 else if ( ksStat->ir.rKSCW.ssSt & KSD_ST_A )
3142 {
3143 classStat.status = STATUS_Active;
3144 }
3145 else
3146 {
3147 classStat.status = STATUS_NotActive;
3148 }
3149
3150 /* init parameter type: */
3151 type.npi = NPI_NotPresent;
3152 type.ton = TON_NotPresent;
3153
3154 for( idx = 0; idx < ksStat->ir.rKSCW.c_cwBSGLst; idx++ )
3155 {
3156 /* type of class */
3157 classStat.class_type = cmhSS_GetClassType(ksStat->ir.rKSCW.cwBSGLst[idx].bsTp,
3158 ksStat->ir.rKSCW.cwBSGLst[idx].bsCd);
3159 if (aci_cmd_src_mode_get((T_ACI_CMD_SRC)srcId) EQ CMD_MODE_ATI)
3160 {
3161 }
3162 else /* CMD_MODE_BAT */
3163 {
3164 }
3165
3166 rCI_PlusCCWA(&classStat,"\0", &type, MNCC_PRES_NOT_PRES, CLASS_NotPresent, NULL);
3167 }
3168 }
3169
3170 /*
3171 ****************************************************************
3172 */
3173 LOCAL void utl_cb_lineidentification( UBYTE srcId, T_ACI_KSIR * ksStat )
3174 {
3175 T_ACI_CLIP_STAT clipStat;
3176 T_ACI_CLIR_MOD clirMode;
3177 T_ACI_CLIR_STAT clirStat;
3178 T_ACI_COLP_STAT colpStat;
3179 T_ACI_COLR_STAT colrStat;
3180
3181 TRACE_FUNCTION("utl_cb_lineidentification()");
3182
3183 if ( ksStat->ir.rKSCL.opCd NEQ KSD_OP_IRGT )
3184 return;
3185
3186 switch ( ksStat->ir.rKSCL.ssCd )
3187 {
3188 case KSD_SS_CLIP:
3189 {
3190 /* SS Status of class - T_ACI_KSD_ST */
3191 if ( ksStat->ir.rKSCL.ssSt EQ KSD_ST_NOT_VALID )
3192 clipStat = CLIP_STAT_Unknown;
3193 else if ( ksStat->ir.rKSCL.ssSt & SSS_P )
3194 clipStat = CLIP_STAT_Prov;
3195 else
3196 clipStat = CLIP_STAT_NotProv;
3197
3198 if (aci_cmd_src_mode_get((T_ACI_CMD_SRC)srcId) EQ CMD_MODE_ATI)
3199 {
3200 rCI_PlusCLIP ( clipStat, NULL, NULL, MNCC_PRES_NOT_PRES, NULL, NULL, NULL );
3201 }
3202 #ifdef FF_BAT
3203 else /* CMD_MODE_BAT */
3204 {
3205 rBAT_PlusCLIP ( clipStat, NULL, NULL, MNCC_PRES_NOT_PRES, NULL, NULL, NULL );
3206 }
3207 #endif
3208 break;
3209 }
3210 case KSD_SS_CLIR:
3211 {
3212 clirMode = ksStat->ir.rKSCL.mode;
3213 utl_cvtCLIRStat(ksStat->ir.rKSCL.clirOpt,
3214 ksStat->ir.rKSCL.ssSt,
3215 &clirStat);
3216 if (aci_cmd_src_mode_get((T_ACI_CMD_SRC)srcId) EQ CMD_MODE_ATI)
3217 {
3218 rCI_PlusCLIR (clirMode, clirStat);
3219 }
3220 #ifdef FF_BAT
3221 else /* CMD_MODE_BAT */
3222 {
3223 rBAT_PlusCLIR (clirMode, clirStat);
3224 }
3225 #endif
3226 break;
3227 }
3228 case KSD_SS_COLP:
3229 {
3230 /* SS Status of class - T_ACI_KSD_ST */
3231 if ( ksStat->ir.rKSCL.ssSt EQ KSD_ST_NOT_VALID )
3232 colpStat = COLP_STAT_Unknown;
3233 else if ( ksStat->ir.rKSCL.ssSt & SSS_P )
3234 colpStat = COLP_STAT_Prov;
3235 else
3236 colpStat = COLP_STAT_NotProv;
3237
3238 if (aci_cmd_src_mode_get((T_ACI_CMD_SRC)srcId) EQ CMD_MODE_ATI)
3239 {
3240 rCI_PlusCOLP ( colpStat, NULL, NULL, NULL, NULL, NULL );
3241 }
3242 #ifdef FF_BAT
3243 else /* CMD_MODE_BAT */
3244 {
3245 rBAT_PlusCOLP ( colpStat, NULL, NULL, NULL, NULL, NULL );
3246 }
3247 #endif
3248 break;
3249 }
3250 case KSD_SS_COLR:
3251 {
3252 /* SS Status of class - T_ACI_KSD_ST */
3253 if ( ksStat->ir.rKSCL.ssSt EQ KSD_ST_NOT_VALID )
3254 colrStat = COLR_STAT_Unknown;
3255 else if ( ksStat->ir.rKSCL.ssSt & SSS_P )
3256 colrStat = COLR_STAT_Prov;
3257 else
3258 colrStat = COLR_STAT_NotProv;
3259
3260 if (aci_cmd_src_mode_get((T_ACI_CMD_SRC)srcId) EQ CMD_MODE_ATI)
3261 {
3262 rCI_PercentCOLR(colrStat);
3263 }
3264 #ifdef FF_BAT
3265 else /* CMD_MODE_BAT */
3266 {
3267 rBAT_PercentCOLR(colrStat);
3268 }
3269 #endif
3270 break;
3271 }
3272 }
3273 }
3274
3275 /*
3276 ****************************************************************
3277 */
3278 LOCAL void utl_cb_callforwarding( UBYTE srcId, T_ACI_KSIR * ksStat )
3279 {
3280 T_ACI_CCFC_SET ccfcSetting;
3281 UBYTE idx;
3282
3283 TRACE_FUNCTION("utl_cb_callforwarding()");
3284
3285 if ( ksStat->ir.rKSCF.opCd NEQ KSD_OP_IRGT )
3286 return;
3287
3288 for( idx = 0; idx < ksStat->ir.rKSCF.c_cfFeatLst; idx++ )
3289 {
3290 /* SS Status of class - T_ACI_KSD_ST */
3291 if ( ksStat->ir.rKSCF.cfFeatLst[idx].ssSt EQ KSD_ST_NOT_VALID )
3292 ccfcSetting.clsstat.status = STATUS_NotPresent;
3293 else if ( ksStat->ir.rKSCF.cfFeatLst[idx].ssSt & SSS_A )
3294 ccfcSetting.clsstat.status = STATUS_Active;
3295 else
3296 ccfcSetting.clsstat.status = STATUS_NotActive;
3297 /* type of class */
3298 if ( ksStat->ir.rKSCF.cfFeatLst[idx].bsTp EQ KSD_BS_TP_None
3299 AND ksStat->ir.rKSCF.cfFeatLst[idx].bsCd EQ KSD_BS_TeleBearerUnknown)
3300 {
3301 if (ccfcSetting.clsstat.status EQ STATUS_NotPresent)
3302 ccfcSetting.clsstat.class_type = CLASS_None;
3303 else
3304 ccfcSetting.clsstat.class_type = CLASS_VceDatFax;
3305 }
3306 else
3307 ccfcSetting.clsstat.class_type = cmhSS_GetClassType(ksStat->ir.rKSCF.cfFeatLst[idx].bsTp,
3308 ksStat->ir.rKSCF.cfFeatLst[idx].bsCd);
3309 /* number */
3310 strcpy(ccfcSetting.number, (char *)ksStat->ir.rKSCF.cfFeatLst[idx].num);
3311 if ( !strlen ( ccfcSetting.number ))
3312 {
3313 ccfcSetting.type.npi = NPI_NotPresent;
3314 ccfcSetting.type.ton = TON_NotPresent;
3315 ccfcSetting.subaddr[0] = 0x0;
3316 ccfcSetting.satype.tos = TOS_NotPresent;
3317 ccfcSetting.satype.oe = OE_NotPresent;
3318 ccfcSetting.time = ACI_NumParmNotPresent;
3319 }
3320 else
3321 {
3322 T_CF_FEAT *cfFeat = &ksStat->ir.rKSCF.cfFeatLst[idx];
3323 /* toa */
3324 ccfcSetting.type.ton = cfFeat->ton NEQ 0xFF
3325 ? (T_ACI_TOA_TON)cfFeat->ton
3326 : TON_NotPresent;
3327 ccfcSetting.type.npi = cfFeat->npi NEQ 0xFF
3328 ? (T_ACI_TOA_NPI)cfFeat->npi
3329 : NPI_NotPresent;
3330 /* subaddr */
3331 strcpy(ccfcSetting.subaddr, (char *)ksStat->ir.rKSCF.cfFeatLst[idx].sub);
3332 /* tos */
3333 ccfcSetting.satype.tos = cfFeat->tos NEQ 0xFF
3334 ? (T_ACI_TOS_TOS)cfFeat->tos
3335 : TOS_NotPresent;
3336 ccfcSetting.satype.oe = cfFeat->oe NEQ 0xFF
3337 ? (T_ACI_TOS_OE)cfFeat->oe
3338 : OE_NotPresent;
3339 /* time */
3340 ccfcSetting.time = cfFeat->time NEQ 0xFF
3341 ? cfFeat->time
3342 : ACI_NumParmNotPresent;
3343 }
3344 if (aci_cmd_src_mode_get((T_ACI_CMD_SRC)srcId) EQ CMD_MODE_ATI)
3345 {
3346 rCI_PlusCCFC (&ccfcSetting);
3347 }
3348 #ifdef FF_BAT
3349 else
3350 {
3351 rBAT_PlusCCFC (&ccfcSetting);
3352 }
3353 #endif
3354 }
3355 }
3356
3357 /*
3358 ****************************************************************
3359 */
3360 LOCAL void utl_cb_callbarring( UBYTE srcId, T_ACI_KSIR * ksStat )
3361 {
3362 T_ACI_CLSSTAT classStat;
3363 UBYTE idx;
3364
3365 TRACE_FUNCTION("utl_cb_callbarring()");
3366
3367 if (ksStat->ir.rKSCB.opCd NEQ KSD_OP_IRGT)
3368 {
3369 return;
3370 }
3371 for (idx = 0; idx < ksStat->ir.rKSCB.c_cbInfoLst; idx++)
3372 {
3373 /* type of class */
3374 classStat.class_type = cmhSS_GetCbClassType(ksStat->ir.rKSCB.cbInfoLst[idx].bsTp,
3375 ksStat->ir.rKSCB.cbInfoLst[idx].bsCd);
3376
3377 /* SS Status of class */
3378 if (classStat.class_type EQ CLASS_VceDatFaxSms
3379 OR classStat.class_type EQ CLASS_None)
3380 {
3381 classStat.status = STATUS_NotActive;
3382 }
3383 else
3384 {
3385 classStat.status = STATUS_Active;
3386 }
3387 if (aci_cmd_src_mode_get((T_ACI_CMD_SRC)srcId) EQ CMD_MODE_ATI)
3388 {
3389 rCI_PlusCLCK(&classStat);
3390 }
3391 #ifdef FF_BAT
3392 else /* CMD_MODE_BAT */
3393 {
3394 rBAT_PlusCLCK(&classStat);
3395 }
3396 #endif
3397 }
3398 }
3399
3400 /*
3401 ****************************************************************
3402 */
3403 LOCAL void utl_cb_imei( UBYTE srcId, T_ACI_KSIR * ksStat )
3404 {
3405 TRACE_FUNCTION("utl_cb_imei()");
3406
3407 sprintf ( g_sa,
3408 "%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d",
3409 (ksStat->ir.rKSIMEI.tac1 >> 4) & 0x0F,
3410 ksStat->ir.rKSIMEI.tac1 & 0x0F,
3411
3412 (ksStat->ir.rKSIMEI.tac2 >> 4) & 0x0F,
3413 ksStat->ir.rKSIMEI.tac2 & 0x0F,
3414
3415 (ksStat->ir.rKSIMEI.tac3 >> 4) & 0x0F,
3416 ksStat->ir.rKSIMEI.tac3 & 0x0F,
3417
3418 (ksStat->ir.rKSIMEI.fac >> 4) & 0x0F,
3419 ksStat->ir.rKSIMEI.fac & 0x0F,
3420
3421 (ksStat->ir.rKSIMEI.snr1 >> 4) & 0x0F,
3422 ksStat->ir.rKSIMEI.snr1 & 0x0F,
3423
3424 (ksStat->ir.rKSIMEI.snr2 >> 4) & 0x0F,
3425 ksStat->ir.rKSIMEI.snr2 & 0x0F,
3426
3427 (ksStat->ir.rKSIMEI.snr3 >> 4) & 0x0F,
3428 ksStat->ir.rKSIMEI.snr3 & 0x0F,
3429
3430 ksStat->ir.rKSIMEI.cd,
3431 (ksStat->ir.rKSIMEI.svn >> 4) & 0x0F,
3432 ksStat->ir.rKSIMEI.svn & 0x0F );
3433
3434 io_sendMessage ( srcId, g_sa, ATI_NORMAL_OUTPUT );
3435 }
3436
3437 /*
3438 +--------------------------------------------------------------------+
3439 | PROJECT : GSM-F&D (8411) MODULE : ACI_UTIL |
3440 | STATE : code ROUTINE : |
3441 +--------------------------------------------------------------------+
3442
3443 PURPOSE : handles PercentKSIR call back
3444
3445 */
3446 GLOBAL void utl_cb_percentKSIR (U8 srcId, T_ACI_KSIR *ksStat)
3447 {
3448 #ifdef FF_BAT
3449 T_ACI_USSD_DATA ussd;
3450 #endif /* FF_BAT */
3451
3452 TRACE_FUNCTION("utl_cb_percentKSIR()");
3453
3454 switch (ksStat->ksdCmd)
3455 {
3456 case (KSD_CMD_IMEI):
3457 if (aci_cmd_src_mode_get((T_ACI_CMD_SRC)srcId) EQ CMD_MODE_ATI)
3458 {
3459 utl_cb_imei(srcId, ksStat);
3460 }
3461 #ifdef FF_BAT
3462 else /* CMD_MODE_BAT */
3463 {
3464 rBAT_PercentIMEI(&(ksStat->ir.rKSIMEI));
3465 }
3466 #endif
3467 break;
3468
3469 case (KSD_CMD_CB):
3470 utl_cb_callbarring(srcId, ksStat);
3471 break;
3472
3473 case (KSD_CMD_CF):
3474 utl_cb_callforwarding(srcId, ksStat);
3475 break;
3476
3477 case (KSD_CMD_CL):
3478 utl_cb_lineidentification(srcId, ksStat);
3479 break;
3480
3481 case (KSD_CMD_CW):
3482 utl_cb_callwaiting(srcId, ksStat);
3483 break;
3484
3485 case (KSD_CMD_PWD):
3486 /* no specific answer to +CPWD which is the corresponding AT cmd */
3487 break;
3488
3489 case (KSD_CMD_UBLK):
3490 /* no specific answer to +CPIN which is the corresponding AT cmd */
3491 break;
3492
3493 case (KSD_CMD_USSD):
3494 if (aci_cmd_src_mode_get((T_ACI_CMD_SRC)srcId) EQ CMD_MODE_ATI)
3495 {
3496 rci_display_USSD(srcId,
3497 ksStat->ir.rKSUS.mode,
3498 (UBYTE *)ksStat->ir.rKSUS.ussd,
3499 ksStat->ir.rKSUS.len,
3500 FALSE, /* means DO NOT CONVERT STRING */
3501 ksStat->ir.rKSUS.dcs);
3502 }
3503 #ifdef FF_BAT
3504 else /* CMD_MODE_BAT */
3505 {
3506 ussd.len = ksStat->ir.rKSUS.len;
3507 memcpy (ussd.data, (UBYTE *)ksStat->ir.rKSUS.ussd, ussd.len);
3508 rBAT_PlusCUSD(ksStat->ir.rKSUS.mode, &ussd, ksStat->ir.rKSUS.dcs);
3509 }
3510 #endif
3511 break;
3512
3513 case (KSD_CMD_CCBS):
3514 utl_cb_ccbs(srcId, ksStat);
3515 break;
3516 }
3517
3518 }
3519 #endif /* defined (FF_ATI) || defined (FF_BAT) */