comparison src/g23m-fad/app/app_bat.c @ 1:fa8dc04885d8

src/g23m-*: import from Magnetite
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 16 Oct 2020 06:25:50 +0000
parents
children
comparison
equal deleted inserted replaced
0:4e78acac3d88 1:fa8dc04885d8
1 /*
2 +------------------------------------------------------------------------------
3 | File: app_bat.c
4 +------------------------------------------------------------------------------
5 | Copyright 2004 Texas Instruments Berlin, AG
6 | All rights reserved.
7 |
8 | This file is confidential and a trade secret of Texas
9 | Instruments Berlin, AG
10 | The receipt of or possession of this file does not convey
11 | any rights to reproduce or disclose its contents or to
12 | manufacture, use, or sell anything it may describe, in
13 | whole, or in part, without the specific written consent of
14 | Texas Instruments Berlin, AG.
15 +-----------------------------------------------------------------------------
16 | Purpose : Test functions for testing the BAT interface -- command parser.
17 +-----------------------------------------------------------------------------
18 */
19
20
21 #define APP_BAT_C
22
23 /*==== INCLUDES =============================================================*/
24
25 #include "app_util.h"
26 #include "bat.h"
27 #include "bat_ctrl.h"
28 #include "bat_intern.h"
29
30
31 #include <string.h> /* String functions, e. g. strncpy(). */
32 #include <ctype.h>
33 #include <stdlib.h>
34
35 #include "vsi.h" /* A lot of macros. */
36 #ifndef _SIMULATION_
37 #include "custom.h"
38 #include "gsm.h" /* A lot of macros. */
39 #include "tools.h" /* Common tools. */
40 #endif /* _SIMULATION_ */
41
42 #include "bat_cfg.h"
43 #include "p_app.h"
44
45 #ifdef FF_GPF_TCPIP
46 #include "socket_api.h"
47 #endif
48
49 #include "app.h"
50
51
52 #define NO_ADD_VAL 0xFFFFFFFF
53
54 GLOBAL void app_bat_send_result_prim (U8 result, U32 add_info);
55
56 /*
57 * Command handler
58 */
59 GLOBAL char *app_bat_close(app_cmd_entry_t *, char *, char *, char *, core_func_t);
60 GLOBAL char *app_bat_cmd_data(app_cmd_entry_t *, char *, char *, char *, core_func_t);
61 GLOBAL char *app_bat_complete_test(app_cmd_entry_t *, char *, char *, char *, core_func_t);
62 GLOBAL char *app_bat_flow_control_test1(app_cmd_entry_t *, char *, char *, char *, core_func_t);
63 GLOBAL char *app_bat_uns_rcv_and_abort_test(app_cmd_entry_t *, char *, char *, char *, core_func_t);
64 GLOBAL char *app_bat_multi_channel_creation_test(app_cmd_entry_t *, char *, char *, char *, core_func_t);
65 GLOBAL char *app_bat_ctrl(app_cmd_entry_t *, char *, char *, char *, core_func_t);
66 GLOBAL char *app_bat_deinit(app_cmd_entry_t *, char *, char *, char *, core_func_t);
67 GLOBAL char *app_bat_delete(app_cmd_entry_t *, char *, char *, char *, core_func_t);
68 GLOBAL char *app_bat_init(app_cmd_entry_t *, char *, char *, char *, core_func_t);
69 GLOBAL char *app_bat_new(app_cmd_entry_t *, char *, char *, char *, core_func_t);
70 GLOBAL char *app_bat_open(app_cmd_entry_t *, char *, char *, char *, core_func_t);
71 GLOBAL char *app_bat_receive_data_cb(app_cmd_entry_t *, char *, char *, char *, core_func_t);
72 GLOBAL char *app_bat_send_cpin(app_cmd_entry_t *, char *, char *, char *, core_func_t);
73 GLOBAL char *app_bat_send_cnmi(app_cmd_entry_t *, char *, char *, char *, core_func_t);
74 GLOBAL char *app_bat_send_ata(app_cmd_entry_t *, char *, char *, char *, core_func_t);
75 GLOBAL char *app_bat_send_atd(app_cmd_entry_t *, char *, char *, char *, core_func_t);
76 GLOBAL char *app_bat_send_ath(app_cmd_entry_t *, char *, char *, char *, core_func_t);
77 GLOBAL char *app_bat_send_q_cscb(app_cmd_entry_t *, char *, char *, char *, core_func_t);
78 GLOBAL char *app_bat_send_q_cpinf(app_cmd_entry_t *, char *, char *, char *, core_func_t);
79 GLOBAL char *app_bat_send_q_cpol(app_cmd_entry_t *, char *, char *, char *, core_func_t);
80 GLOBAL char *app_bat_send_t_cpol(app_cmd_entry_t *, char *, char *, char *, core_func_t);
81 GLOBAL char *app_bat_send_cfun(app_cmd_entry_t *, char *, char *, char *, core_func_t);
82 GLOBAL char *app_bat_send_cmgs(app_cmd_entry_t *, char *, char *, char *, core_func_t);
83 GLOBAL char *app_bat_send_cmgl(app_cmd_entry_t *, char *, char *, char *, core_func_t);
84 GLOBAL char *app_bat_send_cops(app_cmd_entry_t *, char *, char *, char *, core_func_t);
85 GLOBAL char *app_bat_send_ccwa(app_cmd_entry_t *, char *, char *, char *, core_func_t);
86 GLOBAL char *app_bat_signal_cb(app_cmd_entry_t *, char *, char *, char *, core_func_t);
87 GLOBAL char *app_bat_uns_open (app_cmd_entry_t *, char *, char *, char *, core_func_t );
88
89 GLOBAL char *app_bat_send_cpbr(app_cmd_entry_t *, char *, char *, char *, core_func_t);
90 GLOBAL char *app_bat_send_cpbw(app_cmd_entry_t *, char *, char *, char *, core_func_t);
91 GLOBAL char *app_bat_send_q_cgatt(app_cmd_entry_t *, char *, char *, char *, core_func_t);
92 GLOBAL char *app_bat_send_q_cgact(app_cmd_entry_t *, char *, char *, char *, core_func_t);
93 GLOBAL char *app_bat_send_cgatt(app_cmd_entry_t *, char *, char *, char *, core_func_t);
94 GLOBAL char *app_bat_send_cgact(app_cmd_entry_t *, char *, char *, char *, core_func_t);
95 GLOBAL char *app_bat_send_cgdcont(app_cmd_entry_t *, char *, char *, char *, core_func_t);
96 GLOBAL char *app_bat_send_cgpco(app_cmd_entry_t *, char *, char *, char *, core_func_t);
97 GLOBAL char *app_bat_send_q_cgpco(app_cmd_entry_t *, char *, char *, char *, core_func_t);
98 GLOBAL char *app_bat_quer_set_clck (app_cmd_entry_t *, char *, char *, char *, core_func_t );
99 GLOBAL char *app_bat_send_per_als (app_cmd_entry_t *, char *, char *, char *, core_func_t );
100 GLOBAL char *app_bat_send_q_cscs(app_cmd_entry_t *, char *, char *, char *, core_func_t);
101 GLOBAL char *app_bat_send_q_clcc(app_cmd_entry_t *, char *, char *, char *, core_func_t);
102 GLOBAL char *app_bat_send_cscs(app_cmd_entry_t *, char *, char *, char *, core_func_t);
103 GLOBAL char *app_bat_send_csms(app_cmd_entry_t *, char *, char *, char *, core_func_t);
104 GLOBAL char *app_bat_send_cgsms(app_cmd_entry_t *, char *, char *, char *, core_func_t);
105 GLOBAL char *app_bat_send_cpbf(app_cmd_entry_t *, char *, char *, char *, core_func_t);
106 GLOBAL char *app_bat_send_cgmi(app_cmd_entry_t *, char *, char *, char *, core_func_t);
107 GLOBAL char *app_bat_send_cgmm(app_cmd_entry_t *, char *, char *, char *, core_func_t);
108 GLOBAL char *app_bat_send_cgmr(app_cmd_entry_t *, char *, char *, char *, core_func_t);
109 GLOBAL char *app_bat_send_cgsn(app_cmd_entry_t *, char *, char *, char *, core_func_t);
110 GLOBAL char *app_bat_stress_test(app_cmd_entry_t *, char *, char *, char *, core_func_t);
111 GLOBAL char *app_bat_send_cniv(app_cmd_entry_t *, char *, char *,char *, core_func_t);
112 GLOBAL char *app_bat_send_q_cniv(app_cmd_entry_t *, char *, char *,char *, core_func_t);
113 GLOBAL char *app_bat_send_custom(app_cmd_entry_t *, char *, char *, char *, core_func_t);
114
115 /*
116 * Core functions (to be called by the command handler, if applicable)
117 */
118
119 /* -- No core functions required for now */
120
121
122 /* Command handler table. */
123 static app_cmd_entry_t app_bat_cmd_table[] = {
124 { "bat_init", app_bat_init, 0, "[InstNum]" },
125 { "bat_deinit", app_bat_deinit, 0, "" },
126 { "bat_new", app_bat_new, 0, "[ClntNum]" },
127 { "bat_delete", app_bat_delete, 0, "[InstHndl]" },
128 { "bat_open", app_bat_open, 0, "[InstHndl]" },
129 { "bat_uns_open", app_bat_uns_open, 0, "" },
130 { "bat_close", app_bat_close, 0, "[ClntHndl]"},
131 { "bat_ctrl", app_bat_ctrl, 0, "" },
132 { "bat_receive_data_cb", app_bat_receive_data_cb, 0, "[ConHndl]" },
133 { "bat_signal_cb", app_bat_signal_cb, 0, "[ConHndl][SigNum]" },
134 { "bat_complete_test", app_bat_complete_test, 0, "" },
135 { "bat_flow_control_test1", app_bat_flow_control_test1, 0, "" },
136 { "bat_uns_rcv_and_abort_test", app_bat_uns_rcv_and_abort_test, 0, "" },
137 { "bat_multi_channel_creation_test", app_bat_multi_channel_creation_test, 0, "" },
138 { "bat_send_q_cscb", app_bat_send_q_cscb, 0, "[ClntHndl]" },
139 { "bat_send_q_clcc", app_bat_send_q_clcc, 0, "[ClntHndl]" },
140 { "bat_send_q_cscs", app_bat_send_q_cscs, 0, "[ClntHndl]" },
141 { "bat_send_q_cpinf", app_bat_send_q_cpinf, 0, "[ClntHndl]" },
142 { "bat_send_q_cpol", app_bat_send_q_cpol, 0, "[ClntHndl]" },
143 { "bat_send_q_cgatt", app_bat_send_q_cgatt, 0, "[ClntHndl]" },
144 { "bat_send_q_cgact", app_bat_send_q_cgact, 0, "[ClntHndl]" },
145 { "bat_send_q_cgpco", app_bat_send_q_cgpco, 0, "[ClntHndl]" },
146 { "bat_send_t_cpol", app_bat_send_t_cpol, 0, "[ClntHndl]" },
147 { "bat_send_cfun", app_bat_send_cfun, 0, "[ClntHndl]" },
148 { "bat_send_cgmi", app_bat_send_cgmi, 0, "[ClntHndl]" },
149 { "bat_send_cgmm", app_bat_send_cgmm, 0, "[ClntHndl]" },
150 { "bat_send_cgmr", app_bat_send_cgmr, 0, "[ClntHndl]" },
151 { "bat_send_cgsn", app_bat_send_cgsn, 0, "[ClntHndl]" },
152 { "bat_send_cmgs", app_bat_send_cmgs, 0, "[ClntHndl]" },
153 { "bat_send_cmgl", app_bat_send_cmgl, 0, "[ClntHndl] [UNREAD|READ|UNSENT|SENT|ALL]" },
154 { "bat_send_cops", app_bat_send_cops, 0, "[ClntHndl]" },
155 { "bat_send_cpin", app_bat_send_cpin, 0, "[ClntHndl]" },
156 { "bat_send_cnmi", app_bat_send_cnmi, 0, "[ClntHndl]" },
157 { "bat_send_csms", app_bat_send_csms, 0, "[ClntHndl] [service]" },
158 { "bat_send_cgsms", app_bat_send_cgsms, 0, "[ClntHndl] [service]" },
159 { "bat_send_ccwa", app_bat_send_ccwa, 0, "[ClntHndl]" },
160 { "bat_send_ata", app_bat_send_ata, 0, "[ClntHndl]" },
161 { "bat_send_atd", app_bat_send_atd, 0, "[ClntHndl] [phone number]" },
162 { "bat_send_ath", app_bat_send_ath, 0, "[ClntHndl]" },
163 { "bat_send_cscs", app_bat_send_cscs, 0, "[ClntHndl] [charset]" },
164 { "bat_send_cpbr", app_bat_send_cpbr, 0, "[ClntHndl] [index]" },
165 { "bat_send_cpbw", app_bat_send_cpbw, 0, "[ClntHndl] [index] [name]" },
166 { "bat_send_cpbf", app_bat_send_cpbf, 0, "[ClntHndl] [search string]" },
167 { "bat_send_cgatt", app_bat_send_cgatt, 0, "[ClntHndl]" },
168 { "bat_send_cgact", app_bat_send_cgact, 0, "[ClntHndl]" },
169 { "bat_send_cgdcont", app_bat_send_cgdcont, 0, "[ClntHndl]" },
170 { "bat_send_cgpco", app_bat_send_cgpco, 0, "[ClntHndl]" },
171 { "bat_clck_query", app_bat_quer_set_clck, 0, "[ConHndl] [ConCom]" },
172 { "bat_send_per_als", app_bat_send_per_als, 0, "[ConHndl] [ConCom]" },
173 { "bat_stress_test", app_bat_stress_test, 0, "[ClntHndl]" },
174 { "bat_send_cniv", app_bat_send_cniv, 0, "[ClntHndl]"},
175 { "bat_send_q_cniv", app_bat_send_q_cniv, 0, "[ClntHndl]"},
176 { "bat_send_custom", app_bat_send_custom, 0, "[ClntHndl] [custom string]" },
177 { 0, 0, 0, 0},
178 } ;
179
180
181 /*==== Local data ============================================================*/
182
183 typedef struct
184 {
185 size_t size;
186 } T_app_map_response_2_size;
187
188 static T_app_map_response_2_size response_2_size[] =
189 {
190 {sizeof(T_BAT_no_parameter)}, /* BAT_RES_AT_OK = 0x0 */
191 {sizeof(T_BAT_res_at_connect)}, /* BAT_RES_AT_CONNECT = 0x1 */
192 {sizeof(T_BAT_no_parameter)}, /* BAT_RES_AT_NO_CARRIER_FINAL = 0x2 */
193 {sizeof(T_BAT_res_plus_cme_error)}, /* BAT_RES_PLUS_CME_ERROR = 0x3 */
194 {sizeof(T_BAT_res_plus_cms_error)}, /* BAT_RES_PLUS_CMS_ERROR = 0x4 */
195 {sizeof(T_BAT_no_parameter)}, /* BAT_RES_AT_BUSY = 0x5 */
196 {sizeof(T_BAT_no_parameter)}, /* BAT_RES_AT_CHANNEL_BUSY = 0x6 */
197 {sizeof(T_BAT_no_parameter)}, /* BAT_RES_AT_NO_ANSWER = 0x7 */
198 {sizeof(T_BAT_res_plus_ext_error)}, /* BAT_RES_PLUS_EXT_ERROR = 0x8 */
199 {sizeof(T_BAT_res_que_percent_als)}, /* BAT_RES_QUE_PERCENT_ALS = 0x9 */
200 {sizeof(T_BAT_res_tst_percent_als)}, /* BAT_RES_TST_PERCENT_ALS = 0xa */
201 {sizeof(T_BAT_res_que_percent_atr)}, /* BAT_RES_QUE_PERCENT_ATR = 0xb */
202 {sizeof(T_BAT_res_que_percent_band)}, /* BAT_RES_QUE_PERCENT_BAND = 0xc */
203 {sizeof(T_BAT_res_tst_percent_band)}, /* BAT_RES_TST_PERCENT_BAND = 0xd */
204 {sizeof(T_BAT_res_que_plus_cacm)}, /* BAT_RES_QUE_PLUS_CACM = 0xe */
205 {sizeof(T_BAT_res_que_plus_camm)}, /* BAT_RES_QUE_PLUS_CAMM = 0xf */
206 {sizeof(T_BAT_res_set_plus_caoc)}, /* BAT_RES_SET_PLUS_CAOC = 0x10 */
207 {sizeof(T_BAT_res_set_plus_cbc)}, /* BAT_RES_SET_PLUS_CBC = 0x11 */
208 {sizeof(T_BAT_res_que_percent_cbhz)}, /* BAT_RES_QUE_PERCENT_CBHZ = 0x12 */
209 {sizeof(T_BAT_res_tst_percent_cbhz)}, /* BAT_RES_TST_PERCENT_CBHZ = 0x13 */
210 {sizeof(T_BAT_res_que_plus_cbst)}, /* BAT_RES_QUE_PLUS_CBST = 0x14 */
211 {sizeof(T_BAT_res_que_percent_ccbs)}, /* BAT_RES_QUE_PERCENT_CCBS = 0x15 */
212 {sizeof(T_BAT_res_set_plus_ccfc)}, /* BAT_RES_SET_PLUS_CCFC = 0x16 */
213 {sizeof(T_BAT_res_que_plus_cclk)}, /* BAT_RES_QUE_PLUS_CCLK = 0x17 */
214 {sizeof(T_BAT_res_que_plus_ccug)}, /* BAT_RES_QUE_PLUS_CCUG = 0x18 */
215 {sizeof(T_BAT_res_set_plus_ccwa)}, /* BAT_RES_SET_PLUS_CCWA = 0x19 */
216 {sizeof(T_BAT_res_set_plus_ccwa_w)}, /* BAT_RES_SET_PLUS_CCWA_W = 0x1a */
217 {sizeof(T_BAT_res_set_plus_ceer)}, /* BAT_RES_SET_PLUS_CEER = 0x1b */
218 {sizeof(T_BAT_res_que_plus_cfun)}, /* BAT_RES_QUE_PLUS_CFUN = 0x1c */
219 {sizeof(T_BAT_res_que_percent_cgaatt)}, /* BAT_RES_QUE_PERCENT_CGAATT = 0x1d */
220 {sizeof(T_BAT_res_que_plus_cgact)}, /* BAT_RES_QUE_PLUS_CGACT = 0x1e */
221 {sizeof(T_BAT_res_que_plus_cgatt)}, /* BAT_RES_QUE_PLUS_CGATT = 0x1f */
222 {sizeof(T_BAT_res_que_percent_cgclass)}, /* BAT_RES_QUE_PERCENT_CGCLASS = 0x20 */
223 {sizeof(T_BAT_res_que_plus_cgclass)}, /* BAT_RES_QUE_PLUS_CGCLASS = 0x21 */
224 {sizeof(T_BAT_res_que_plus_cgdcont)}, /* BAT_RES_QUE_PLUS_CGDCONT = 0x22 */
225 {sizeof(T_BAT_res_set_plus_cgpaddr)}, /* BAT_RES_SET_PLUS_CGPADDR = 0x23 */
226 {sizeof(T_BAT_res_tst_plus_cgpaddr)}, /* BAT_RES_TST_PLUS_CGPADDR = 0x24 */
227 {sizeof(T_BAT_res_set_percent_cgpco)}, /* BAT_RES_SET_PERCENT_CGPCO = 0x25 */
228 {sizeof(T_BAT_res_que_percent_cgppp)}, /* BAT_RES_QUE_PERCENT_CGPPP = 0x26 */
229 {sizeof(T_BAT_res_que_plus_cgqmin)}, /* BAT_RES_QUE_PLUS_CGQMIN = 0x27 */
230 {sizeof(T_BAT_res_que_plus_cgqreq)}, /* BAT_RES_QUE_PLUS_CGQREQ = 0x28 */
231 {sizeof(T_BAT_res_que_percent_cgreg)}, /* BAT_RES_QUE_PERCENT_CGREG = 0x29 */
232 {sizeof(T_BAT_res_que_plus_cgreg)}, /* BAT_RES_QUE_PLUS_CGREG = 0x2a */
233 {sizeof(T_BAT_res_que_plus_cgsms)}, /* BAT_RES_QUE_PLUS_CGSMS = 0x2b */
234 {sizeof(T_BAT_res_set_percent_chpl)}, /* BAT_RES_SET_PERCENT_CHPL = 0x2c */
235 {sizeof(T_BAT_res_set_percent_chpl_w)}, /* BAT_RES_SET_PERCENT_CHPL_W = 0x2d */
236 {sizeof(T_BAT_res_set_plus_cimi)}, /* BAT_RES_SET_PLUS_CIMI = 0x2e */
237 {sizeof(T_BAT_res_que_plus_cind)}, /* BAT_RES_QUE_PLUS_CIND = 0x2f */
238 {sizeof(T_BAT_res_que_plus_clan)}, /* BAT_RES_QUE_PLUS_CLAN = 0x30 */
239 {sizeof(T_BAT_res_tst_plus_clan)}, /* BAT_RES_TST_PLUS_CLAN = 0x31 */
240 {sizeof(T_BAT_res_que_plus_clcc)}, /* BAT_RES_QUE_PLUS_CLCC = 0x32 */
241 {sizeof(T_BAT_res_set_plus_clck)}, /* BAT_RES_SET_PLUS_CLCK = 0x33 */
242 {sizeof(T_BAT_res_que_plus_clip)}, /* BAT_RES_QUE_PLUS_CLIP = 0x34 */
243 {sizeof(T_BAT_res_que_plus_clip_w)}, /* BAT_RES_QUE_PLUS_CLIP_W = 0x35 */
244 {sizeof(T_BAT_res_que_plus_clir)}, /* BAT_RES_QUE_PLUS_CLIR = 0x36 */
245 {sizeof(T_BAT_no_parameter)}, /* BAT_RES_SET_PLUS_CLVL = 0x37 */
246 {sizeof(T_BAT_res_que_plus_clvl)}, /* BAT_RES_QUE_PLUS_CLVL = 0x38 */
247 {sizeof(T_BAT_res_que_plus_cmer)}, /* BAT_RES_QUE_PLUS_CMER = 0x39 */
248 {sizeof(T_BAT_res_set_plus_cmgc)}, /* BAT_RES_SET_PLUS_CMGC = 0x3a */
249 {sizeof(T_BAT_res_set_plus_cmgl)}, /* BAT_RES_SET_PLUS_CMGL = 0x3b */
250 {sizeof(T_BAT_res_set_plus_cmgl_w)}, /* BAT_RES_SET_PLUS_CMGL_W = 0x3c */
251 {sizeof(T_BAT_res_set_plus_cmgr)}, /* BAT_RES_SET_PLUS_CMGR = 0x3d */
252 {sizeof(T_BAT_res_set_plus_cmgr_w)}, /* BAT_RES_SET_PLUS_CMGR_W = 0x3e */
253 {sizeof(T_BAT_res_set_plus_cmgs)}, /* BAT_RES_SET_PLUS_CMGS = 0x3f */
254 {sizeof(T_BAT_res_set_plus_cmgw)}, /* BAT_RES_SET_PLUS_CMGW = 0x40 */
255 {sizeof(T_BAT_res_que_plus_cmod)}, /* BAT_RES_QUE_PLUS_CMOD = 0x41 */
256 {sizeof(T_BAT_res_que_plus_cmut)}, /* BAT_RES_QUE_PLUS_CMUT = 0x42 */
257 {sizeof(T_BAT_res_que_plus_cmux)}, /* BAT_RES_QUE_PLUS_CMUX = 0x43 */
258 {sizeof(T_BAT_res_que_percent_cnap)}, /* BAT_RES_QUE_PERCENT_CNAP = 0x44 */
259 {sizeof(T_BAT_res_que_plus_cnmi)}, /* BAT_RES_QUE_PLUS_CNMI = 0x45 */
260 {sizeof(T_BAT_res_set_plus_cnum)}, /* BAT_RES_SET_PLUS_CNUM = 0x46 */
261 {sizeof(T_BAT_res_set_plus_cnum_w)}, /* BAT_RES_SET_PLUS_CNUM_W = 0x47 */
262 {sizeof(T_BAT_res_que_plus_colp)}, /* BAT_RES_QUE_PLUS_COLP = 0x48 */
263 {sizeof(T_BAT_res_que_plus_colp_w)}, /* BAT_RES_QUE_PLUS_COLP_W = 0x49 */
264 {sizeof(T_BAT_res_que_percent_cops)}, /* BAT_RES_QUE_PERCENT_COPS = 0x4a */
265 {sizeof(T_BAT_res_tst_percent_cops)}, /* BAT_RES_TST_PERCENT_COPS = 0x4b */
266 {sizeof(T_BAT_res_que_plus_cops)}, /* BAT_RES_QUE_PLUS_COPS = 0x4c */
267 {sizeof(T_BAT_res_tst_plus_cops)}, /* BAT_RES_TST_PLUS_COPS = 0x4d */
268 {sizeof(T_BAT_res_que_percent_cops_w)}, /* BAT_RES_QUE_PERCENT_COPS_W = 0x4e */
269 {sizeof(T_BAT_res_tst_percent_cops_w)}, /* BAT_RES_TST_PERCENT_COPS_W = 0x4f */
270 {sizeof(T_BAT_res_set_percent_cpals)}, /* BAT_RES_SET_PERCENT_CPALS = 0x50 */
271 {sizeof(T_BAT_res_que_percent_cpals)}, /* BAT_RES_QUE_PERCENT_CPALS = 0x51 */
272 {sizeof(T_BAT_res_set_percent_cpals_w)}, /* BAT_RES_SET_PERCENT_CPALS_W = 0x52 */
273 {sizeof(T_BAT_res_que_percent_cpals_w)}, /* BAT_RES_QUE_PERCENT_CPALS_W = 0x53 */
274 {sizeof(T_BAT_res_set_plus_cpas)}, /* BAT_RES_SET_PLUS_CPAS = 0x54 */
275 {sizeof(T_BAT_res_set_plus_cpbf)}, /* BAT_RES_SET_PLUS_CPBF = 0x55 */
276 {sizeof(T_BAT_res_tst_plus_cpbf)}, /* BAT_RES_TST_PLUS_CPBF = 0x56 */
277 {sizeof(T_BAT_res_set_plus_cpbf_w)}, /* BAT_RES_SET_PLUS_CPBF_W = 0x57 */
278 {sizeof(T_BAT_res_tst_plus_cpbf_w)}, /* BAT_RES_TST_PLUS_CPBF_W = 0x58 */
279 {sizeof(T_BAT_res_set_plus_cpbr)}, /* BAT_RES_SET_PLUS_CPBR = 0x59 */
280 {sizeof(T_BAT_res_tst_plus_cpbr)}, /* BAT_RES_TST_PLUS_CPBR = 0x5a */
281 {sizeof(T_BAT_res_set_plus_cpbr_w)}, /* BAT_RES_SET_PLUS_CPBR_W = 0x5b */
282 {sizeof(T_BAT_res_tst_plus_cpbr_w)}, /* BAT_RES_TST_PLUS_CPBR_W = 0x5c */
283 {sizeof(T_BAT_res_que_percent_cpbs)}, /* BAT_RES_QUE_PERCENT_CPBS = 0x5d */
284 {sizeof(T_BAT_res_que_plus_cpbs)}, /* BAT_RES_QUE_PLUS_CPBS = 0x5e */
285 {sizeof(T_BAT_res_tst_plus_cpbw)}, /* BAT_RES_TST_PLUS_CPBW = 0x5f */
286 {sizeof(T_BAT_res_tst_plus_cpbw_w)}, /* BAT_RES_TST_PLUS_CPBW_W = 0x60 */
287 {sizeof(T_BAT_res_set_percent_cpcfu)}, /* BAT_RES_SET_PERCENT_CPCFU = 0x61 */
288 {sizeof(T_BAT_res_que_percent_cphs)}, /* BAT_RES_QUE_PERCENT_CPHS = 0x62 */
289 {sizeof(T_BAT_res_que_plus_cpin)}, /* BAT_RES_QUE_PLUS_CPIN = 0x63 */
290 {sizeof(T_BAT_res_que_percent_cpinf)}, /* BAT_RES_QUE_PERCENT_CPINF = 0x64 */
291 {sizeof(T_BAT_res_set_percent_cpmb)}, /* BAT_RES_SET_PERCENT_CPMB = 0x65 */
292 {sizeof(T_BAT_res_que_percent_cpmb)}, /* BAT_RES_QUE_PERCENT_CPMB = 0x66 */
293 {sizeof(T_BAT_res_tst_percent_cpmbw)}, /* BAT_RES_TST_PERCENT_CPMBW = 0x67 */
294 {sizeof(T_BAT_res_tst_percent_cpmbw_w)}, /* BAT_RES_TST_PERCENT_CPMBW_W = 0x68 */
295 {sizeof(T_BAT_res_set_percent_cpmb_w)}, /* BAT_RES_SET_PERCENT_CPMB_W = 0x69 */
296 {sizeof(T_BAT_res_set_plus_cpms)}, /* BAT_RES_SET_PLUS_CPMS = 0x6a */
297 {sizeof(T_BAT_res_que_plus_cpms)}, /* BAT_RES_QUE_PLUS_CPMS = 0x6b */
298 {sizeof(T_BAT_res_set_percent_cpnums)}, /* BAT_RES_SET_PERCENT_CPNUMS = 0x6c */
299 {sizeof(T_BAT_res_tst_percent_cpnums)}, /* BAT_RES_TST_PERCENT_CPNUMS = 0x6d */
300 {sizeof(T_BAT_res_set_percent_cpnums_w)},/* BAT_RES_SET_PERCENT_CPNUMS_W = 0x6e */
301 {sizeof(T_BAT_res_tst_percent_cpnums_w)},/* BAT_RES_TST_PERCENT_CPNUMS_W = 0x6f */
302 {sizeof(T_BAT_res_que_plus_cpol)}, /* BAT_RES_QUE_PLUS_CPOL = 0x70 */
303 {sizeof(T_BAT_res_tst_plus_cpol)}, /* BAT_RES_TST_PLUS_CPOL = 0x71 */
304 {sizeof(T_BAT_res_que_plus_cpol_w)}, /* BAT_RES_QUE_PLUS_CPOL_W = 0x72 */
305 {sizeof(T_BAT_res_tst_plus_cpol_w)}, /* BAT_RES_TST_PLUS_CPOL_W = 0x73 */
306 {sizeof(T_BAT_res_que_percent_cpopn)}, /* BAT_RES_QUE_PERCENT_CPOPN = 0x74 */
307 {sizeof(T_BAT_res_que_percent_cprsm)}, /* BAT_RES_QUE_PERCENT_CPRSM = 0x75 */
308 {sizeof(T_BAT_res_que_plus_cpuc)}, /* BAT_RES_QUE_PLUS_CPUC = 0x76 */
309 {sizeof(T_BAT_res_que_plus_cpuc_w)}, /* BAT_RES_QUE_PLUS_CPUC_W = 0x77 */
310 {sizeof(T_BAT_res_set_percent_cpvwi)}, /* BAT_RES_SET_PERCENT_CPVWI = 0x78 */
311 {sizeof(T_BAT_res_que_percent_creg)}, /* BAT_RES_QUE_PERCENT_CREG = 0x79 */
312 {sizeof(T_BAT_res_tst_plus_cres)}, /* BAT_RES_TST_PLUS_CRES = 0x7a */
313 {sizeof(T_BAT_res_que_plus_crlp)}, /* BAT_RES_QUE_PLUS_CRLP = 0x7b */
314 {sizeof(T_BAT_res_set_plus_crsm)}, /* BAT_RES_SET_PLUS_CRSM = 0x7c */
315 {sizeof(T_BAT_res_tst_plus_csas)}, /* BAT_RES_TST_PLUS_CSAS = 0x7d */
316 {sizeof(T_BAT_res_que_plus_csca)}, /* BAT_RES_QUE_PLUS_CSCA = 0x7e */
317 {sizeof(T_BAT_res_que_plus_cscb)}, /* BAT_RES_QUE_PLUS_CSCB = 0x7f */
318 {sizeof(T_BAT_res_que_plus_cscs)}, /* BAT_RES_QUE_PLUS_CSCS = 0x80 */
319 {sizeof(T_BAT_res_set_plus_csim)}, /* BAT_RES_SET_PLUS_CSIM = 0x81 */
320 {sizeof(T_BAT_res_que_plus_csms)}, /* BAT_RES_QUE_PLUS_CSMS = 0x82 */
321 {sizeof(T_BAT_res_que_plus_csns)}, /* BAT_RES_QUE_PLUS_CSNS = 0x83 */
322 {sizeof(T_BAT_res_que_percent_csq)}, /* BAT_RES_QUE_PERCENT_CSQ = 0x84 */
323 {sizeof(T_BAT_res_set_plus_csq)}, /* BAT_RES_SET_PLUS_CSQ = 0x85 */
324 {sizeof(T_BAT_res_que_plus_csta)}, /* BAT_RES_QUE_PLUS_CSTA = 0x86 */
325 {sizeof(T_BAT_res_que_plus_csvm)}, /* BAT_RES_QUE_PLUS_CSVM = 0x87 */
326 {sizeof(T_BAT_res_que_percent_ctty)}, /* BAT_RES_QUE_PERCENT_CTTY = 0x88 */
327 {sizeof(T_BAT_res_que_plus_ctzu)}, /* BAT_RES_QUE_PLUS_CTZU = 0x89 */
328 {sizeof(T_BAT_res_que_percent_cust)}, /* BAT_RES_QUE_PERCENT_CUST = 0x8a */
329 {sizeof(T_BAT_res_que_percent_data)}, /* BAT_RES_QUE_PERCENT_DATA = 0x8b */
330 {sizeof(T_BAT_res_set_percent_dinf)}, /* BAT_RES_SET_PERCENT_DINF = 0x8c */
331 {sizeof(T_BAT_res_que_plus_ds)}, /* BAT_RES_QUE_PLUS_DS = 0x8d */
332 {sizeof(T_BAT_res_que_plus_fap)}, /* BAT_RES_QUE_PLUS_FAP = 0x8e */
333 {sizeof(T_BAT_res_que_plus_fbo)}, /* BAT_RES_QUE_PLUS_FBO = 0x8f */
334 {sizeof(T_BAT_res_que_plus_fbs)}, /* BAT_RES_QUE_PLUS_FBS = 0x90 */
335 {sizeof(T_BAT_res_que_plus_fbu)}, /* BAT_RES_QUE_PLUS_FBU = 0x91 */
336 {sizeof(T_BAT_res_que_plus_fcc)}, /* BAT_RES_QUE_PLUS_FCC = 0x92 */
337 {sizeof(T_BAT_res_que_plus_fclass)}, /* BAT_RES_QUE_PLUS_FCLASS = 0x93 */
338 {sizeof(T_BAT_res_que_plus_fcq)}, /* BAT_RES_QUE_PLUS_FCQ = 0x94 */
339 {sizeof(T_BAT_res_que_plus_fcr)}, /* BAT_RES_QUE_PLUS_FCR = 0x95 */
340 {sizeof(T_BAT_res_que_plus_fcs)}, /* BAT_RES_QUE_PLUS_FCS = 0x96 */
341 {sizeof(T_BAT_res_que_plus_fct)}, /* BAT_RES_QUE_PLUS_FCT = 0x97 */
342 {sizeof(T_BAT_res_que_plus_fea)}, /* BAT_RES_QUE_PLUS_FEA = 0x98 */
343 {sizeof(T_BAT_res_que_plus_ffc)}, /* BAT_RES_QUE_PLUS_FFC = 0x99 */
344 {sizeof(T_BAT_res_que_plus_fhs)}, /* BAT_RES_QUE_PLUS_FHS = 0x9a */
345 {sizeof(T_BAT_res_que_plus_fie)}, /* BAT_RES_QUE_PLUS_FIE = 0x9b */
346 {sizeof(T_BAT_res_que_plus_fis)}, /* BAT_RES_QUE_PLUS_FIS = 0x9c */
347 {sizeof(T_BAT_res_que_plus_fit)}, /* BAT_RES_QUE_PLUS_FIT = 0x9d */
348 {sizeof(T_BAT_res_que_plus_fli)}, /* BAT_RES_QUE_PLUS_FLI = 0x9e */
349 {sizeof(T_BAT_res_que_plus_flo)}, /* BAT_RES_QUE_PLUS_FLO = 0x9f */
350 {sizeof(T_BAT_res_que_plus_flp)}, /* BAT_RES_QUE_PLUS_FLP = 0xa0 */
351 {sizeof(T_BAT_res_que_plus_fms)}, /* BAT_RES_QUE_PLUS_FMS = 0xa1 */
352 {sizeof(T_BAT_res_que_plus_fns)}, /* BAT_RES_QUE_PLUS_FNS = 0xa2 */
353 {sizeof(T_BAT_res_que_plus_fpa)}, /* BAT_RES_QUE_PLUS_FPA = 0xa3 */
354 {sizeof(T_BAT_res_que_plus_fpi)}, /* BAT_RES_QUE_PLUS_FPI = 0xa4 */
355 {sizeof(T_BAT_res_que_plus_fps)}, /* BAT_RES_QUE_PLUS_FPS = 0xa5 */
356 {sizeof(T_BAT_res_que_plus_fpw)}, /* BAT_RES_QUE_PLUS_FPW = 0xa6 */
357 {sizeof(T_BAT_res_que_plus_frq)}, /* BAT_RES_QUE_PLUS_FRQ = 0xa7 */
358 {sizeof(T_BAT_res_que_plus_fsa)}, /* BAT_RES_QUE_PLUS_FSA = 0xa8 */
359 {sizeof(T_BAT_res_que_plus_fsp)}, /* BAT_RES_QUE_PLUS_FSP = 0xa9 */
360 {sizeof(T_BAT_res_que_plus_icf)}, /* BAT_RES_QUE_PLUS_ICF = 0xaa */
361 {sizeof(T_BAT_res_que_plus_ifc)}, /* BAT_RES_QUE_PLUS_IFC = 0xab */
362 {sizeof(T_BAT_res_que_percent_imei)}, /* BAT_RES_QUE_PERCENT_IMEI = 0xac */
363 {sizeof(T_BAT_res_que_plus_ipr)}, /* BAT_RES_QUE_PLUS_IPR = 0xad */
364 {sizeof(T_BAT_res_que_percent_pbcf)}, /* BAT_RES_QUE_PERCENT_PBCF = 0xae */
365 {sizeof(T_BAT_res_que_percent_ppp)}, /* BAT_RES_QUE_PERCENT_PPP = 0xaf */
366 {sizeof(T_BAT_res_que_percent_pvrf)}, /* BAT_RES_QUE_PERCENT_PVRF = 0xb0 */
367 {sizeof(T_BAT_res_que_percent_rdl)}, /* BAT_RES_QUE_PERCENT_RDL = 0xb1 */
368 {sizeof(T_BAT_res_que_percent_rdlb)}, /* BAT_RES_QUE_PERCENT_RDLB = 0xb2 */
369 {sizeof(T_BAT_res_que_percent_satc)}, /* BAT_RES_QUE_PERCENT_SATC = 0xb3 */
370 {sizeof(T_BAT_res_que_percent_satcc)}, /* BAT_RES_QUE_PERCENT_SATCC = 0xb4 */
371 {sizeof(T_BAT_res_set_percent_sate)}, /* BAT_RES_SET_PERCENT_SATE = 0xb5 */
372 {sizeof(T_BAT_res_que_plus_ws46)}, /* BAT_RES_QUE_PLUS_WS46 = 0xb6 */
373 {sizeof(T_BAT_res_que_plus_cdip)}, /* BAT_RES_QUE_PLUS_CDIP = 0xb7 */
374 {sizeof(T_BAT_res_set_percent_cmgr)}, /* BAT_RES_SET_PERCENT_CMGR = 0xb8 */
375 {sizeof(T_BAT_res_set_percent_cmgl)}, /* BAT_RES_SET_PERCENT_CMGL = 0xb9 */
376 {sizeof(T_BAT_res_set_plus_cmss)}, /* BAT_RES_SET_PLUS_CMSS = 0xba */
377 {sizeof(T_BAT_res_set_plus_cgmi)}, /* BAT_RES_SET_PLUS_CGMI = 0xbb */
378 {sizeof(T_BAT_res_set_plus_cgmm)}, /* BAT_RES_SET_PLUS_CGMM = 0xbc */
379 {sizeof(T_BAT_res_set_plus_cgmr)}, /* BAT_RES_SET_PLUS_CGMR = 0xbd */
380 {sizeof(T_BAT_res_set_plus_cgsn)}, /* BAT_RES_SET_PLUS_CGSN = 0xbe */
381 {0}, /*As response structure of command id=0xbf is absent still to get the proper size of structure of response according to the command id */
382 {0}, /*As response structure of command id=0xc0 is absent still to get the proper size of structure of response according to the command id */
383 {sizeof(T_BAT_res_que_percent_cniv)}, /* BAT_RES_QUE_PERCENT_CNIV = 0xc1 */
384 };
385
386 static T_app_map_response_2_size unsolicited_2_size[] =
387 {
388 {sizeof(T_BAT_no_parameter)}, /* BAT_RES_UNS_AT_BUSY = 0x1000 */
389 {sizeof(T_BAT_no_parameter)}, /* BAT_RES_UNS_AT_NO_ANSWER = 0x1001 */
390 {sizeof(T_BAT_res_uns_plus_cbm)}, /* BAT_RES_UNS_PLUS_CBM = 0x1002 */
391 {sizeof(T_BAT_res_uns_plus_cbmi)}, /* BAT_RES_UNS_PLUS_CBMI = 0x1003 */
392 {sizeof(T_BAT_res_uns_percent_ccbs)}, /* BAT_RES_UNS_PERCENT_CCBS = 0x1004 */
393 // {sizeof(T_BAT_res_uns_percent_cccm)}, /* BAT_RES_UNS_PERCENT_CCCM = 0x1005 */
394 {sizeof(T_BAT_res_uns_plus_cccm)}, /* BAT_RES_UNS_PLUS_CCCM = 0x1006 */
395 {sizeof(T_BAT_res_uns_percent_cccn)}, /* BAT_RES_UNS_PERCENT_CCCN = 0x1007 */
396 {sizeof(T_BAT_res_uns_plus_ccwa)}, /* BAT_RES_UNS_PLUS_CCWA = 0x1008 */
397 {sizeof(T_BAT_res_uns_plus_ccwa_w)}, /* BAT_RES_UNS_PLUS_CCWA_W = 0x1009 */
398 {sizeof(T_BAT_no_parameter)}, /* BAT_RES_UNS_PLUS_CCWE = 0x100a */
399 {sizeof(T_BAT_res_uns_plus_cds)}, /* BAT_RES_UNS_PLUS_CDS = 0x100b */
400 {sizeof(T_BAT_no_parameter)}, /* BAT_RES_UNS_PLUS_CCWV = 0x100c */
401 {sizeof(T_BAT_res_uns_percent_cgev)}, /* BAT_RES_UNS_PERCENT_CGEV = 0x100d */
402 {sizeof(T_BAT_res_uns_plus_cgev)}, /* BAT_RES_UNS_PLUS_CGEV = 0x100e */
403 {sizeof(T_BAT_res_uns_percent_cgreg)}, /* BAT_RES_UNS_PERCENT_CGREG = 0x100f */
404 {sizeof(T_BAT_res_uns_plus_cgreg)}, /* BAT_RES_UNS_PLUS_CGREG = 0x1010 */
405 {sizeof(T_BAT_res_uns_plus_clae)}, /* BAT_RES_UNS_PLUS_CLAE = 0x1011 */
406 {sizeof(T_BAT_res_uns_plus_clav)}, /* BAT_RES_UNS_PLUS_CLAV = 0x1012 */
407 {sizeof(T_BAT_res_uns_plus_clip)}, /* BAT_RES_UNS_PLUS_CLIP = 0x1013 */
408 {sizeof(T_BAT_res_uns_plus_clip_w)}, /* BAT_RES_UNS_PLUS_CLIP_W = 0x1014 */
409 {sizeof(T_BAT_res_uns_plus_cmt)}, /* BAT_RES_UNS_PLUS_CMT = 0x1015 */
410 {sizeof(T_BAT_res_uns_plus_cmti)}, /* BAT_RES_UNS_PLUS_CMTI = 0x1016 */
411 {sizeof(T_BAT_res_uns_plus_cmt_w)}, /* BAT_RES_UNS_PLUS_CMT_W = 0x1017 */
412 {sizeof(T_BAT_res_uns_percent_cnap)}, /* BAT_RES_UNS_PERCENT_CNAP = 0x1018 */
413 {sizeof(T_BAT_res_uns_plus_colp)}, /* BAT_RES_UNS_PLUS_COLP = 0x1019 */
414 {sizeof(T_BAT_res_uns_plus_colp_w)}, /* BAT_RES_UNS_PLUS_COLP_W = 0x101a */
415 {sizeof(T_BAT_res_uns_percent_cpi)}, /* BAT_RES_UNS_PERCENT_CPI = 0x101b */
416 {sizeof(T_BAT_res_uns_percent_cpi_w)}, /* BAT_RES_UNS_PERCENT_CPI_W = 0x101c */
417 {sizeof(T_BAT_res_uns_percent_cpri)}, /* BAT_RES_UNS_PERCENT_CPRI = 0x101d */
418 {sizeof(T_BAT_res_uns_percent_cproam)}, /* BAT_RES_UNS_PERCENT_CPROAM = 0x101e */
419 {sizeof(T_BAT_res_uns_percent_cpvwi)}, /* BAT_RES_UNS_PERCENT_CPVWI = 0x101f */
420 {sizeof(T_BAT_res_uns_plus_cr)}, /* BAT_RES_UNS_PLUS_CR = 0x1020 */
421 {sizeof(T_BAT_res_uns_percent_creg)}, /* BAT_RES_UNS_PERCENT_CREG = 0x1021 */
422 {sizeof(T_BAT_res_uns_plus_cring)}, /* BAT_RES_UNS_PLUS_CRING = 0x1022 */
423 {sizeof(T_BAT_res_uns_percent_csq)}, /* BAT_RES_UNS_PERCENT_CSQ = 0x1023 */
424 {sizeof(T_BAT_res_uns_plus_cssi)}, /* BAT_RES_UNS_PLUS_CSSI = 0x1024 */
425 {sizeof(T_BAT_res_uns_percent_cssn)}, /* BAT_RES_UNS_PERCENT_CSSN = 0x1025 */
426 {sizeof(T_BAT_res_uns_plus_cssu)}, /* BAT_RES_UNS_PLUS_CSSU = 0x1026 */
427 {sizeof(T_BAT_res_uns_percent_cstat)}, /* BAT_RES_UNS_PERCENT_CSTAT = 0x1027 */
428 {sizeof(T_BAT_res_uns_percent_ctyi)}, /* BAT_RES_UNS_PERCENT_CTYI = 0x1028 */
429 {sizeof(T_BAT_res_uns_plus_ctzr)}, /* BAT_RES_UNS_PLUS_CTZR = 0x1029 */
430 {sizeof(T_BAT_res_uns_percent_ctzv)}, /* BAT_RES_UNS_PERCENT_CTZV = 0x102a */
431 {sizeof(T_BAT_res_uns_plus_ctzv)}, /* BAT_RES_UNS_PLUS_CTZV = 0x102b */
432 {sizeof(T_BAT_res_uns_percent_ctzv_w)}, /* BAT_RES_UNS_PERCENT_CTZV_W = 0x102c */
433 {sizeof(T_BAT_res_uns_plus_cusd)}, /* BAT_RES_UNS_PLUS_CUSD = 0x102d */
434 {sizeof(T_BAT_res_uns_plus_cusd_w)}, /* BAT_RES_UNS_PLUS_CUSD_W = 0x102e */
435 {sizeof(T_BAT_no_parameter)}, /* BAT_RES_UNS_AT_NO_CARRIER = 0x102f */
436 {sizeof(T_BAT_res_uns_plus_fhs)}, /* BAT_RES_UNS_PLUS_FHS = 0x1030 */
437 {sizeof(T_BAT_res_uns_plus_ilrr)}, /* BAT_RES_UNS_PLUS_ILRR = 0x1031 */
438 {sizeof(T_BAT_res_uns_percent_rdl)}, /* BAT_RES_UNS_PERCENT_RDL = 0x1032 */
439 {sizeof(T_BAT_res_uns_percent_rdlb)}, /* BAT_RES_UNS_PERCENT_RDLB = 0x1033 */
440 {sizeof(T_BAT_res_uns_percent_sata)}, /* BAT_RES_UNS_PERCENT_SATA = 0x1034 */
441 {sizeof(T_BAT_res_uns_percent_sati)}, /* BAT_RES_UNS_PERCENT_SATI = 0x1035 */
442 {sizeof(T_BAT_res_uns_percent_satn)}, /* BAT_RES_UNS_PERCENT_SATN = 0x1036 */
443 {sizeof(T_BAT_res_uns_percent_simef)}, /* BAT_RES_UNS_PERCENT_SIMEF = 0x1037 */
444 {sizeof(T_BAT_res_uns_percent_simins)}, /* BAT_RES_UNS_PERCENT_SIMINS = 0x1038 */
445 {sizeof(T_BAT_res_uns_percent_simrem)}, /* BAT_RES_UNS_PERCENT_SIMREM = 0x1039 */
446 {sizeof(T_BAT_res_uns_percent_sncnt)}, /* BAT_RES_UNS_PERCENT_SNCNT = 0x103a */
447 {sizeof(T_BAT_res_uns_percent_cniv)} /* BAT_RES_UNS_PERCENT_CNIV = 0x103b */
448 };
449
450
451
452 GLOBAL T_BAT_client clnt_table[BAT_MAX_TEST_INST_NUM][BAT_MAX_TEST_CLNT_NUM+1] =
453 /* NrOfCl, Clnt0, Clnt1, Clnt2, Clnt3 */
454 {{0,0xffff,0xffff,0xffff,0xffff}, /* instance 0 */
455 {0,0xffff,0xffff,0xffff,0xffff}}; /* instance 1 */
456
457 #define RESP_LINES 20
458 #define RESP_LINE_LEN 256
459 LOCAL CHAR at_cmd_resp_param [RESP_LINES][RESP_LINE_LEN];
460
461 struct app_bat_globals
462 {
463 T_BAT_plus_cscs_cs cs;
464 } app_bat_globs = {BAT_CSCS_CS_IRA};
465
466 /*==== Local functions =======================================================*/
467
468 /*---------------------------------------------------------------------------
469 * Definition of command handler functions
470 *---------------------------------------------------------------------------*/
471 GLOBAL void signal_cb (T_BAT_client client, T_BAT_signal signal)
472 {
473 TRACE_FUNCTION ("signal_cb()");
474 TRACE_EVENT_P2("CLIENT HNDL IS: 0x%04x, SIGNAL IS: %d", client, signal);
475 return;
476 }
477
478 GLOBAL void signal_cb1 (T_BAT_client client, T_BAT_signal signal)
479 {
480 TRACE_FUNCTION ("signal_cb1()");
481 TRACE_EVENT_P2("CLIENT HNDL IS: 0x%04x, SIGNAL IS: %d", client, signal);
482 return;
483 }
484
485 GLOBAL void signal_cb2 (T_BAT_client client, T_BAT_signal signal)
486 {
487 TRACE_FUNCTION ("signal_cb2()");
488 TRACE_EVENT_P2("CLIENT HNDL IS: 0x%04x, SIGNAL IS: %d", client, signal);
489 return;
490 }
491
492 #define BITFIELD_CHECK(x, y) (x & y)
493
494 LOCAL int app_bat_get_size (T_BAT_ctrl_response ctrl_response)
495 {
496 if (BITFIELD_CHECK(ctrl_response, 0x1000)) /* BAT_BIT_12 */
497 {
498 return (unsolicited_2_size[ctrl_response - 0x1000].size);
499 }
500 else
501 {
502 return (response_2_size[ctrl_response].size);
503 }
504 }
505
506
507 LOCAL void response_content (T_BAT_cmd_response *resp)
508 {
509 int resp_len = app_bat_get_size(resp->ctrl_response);
510 TRACE_EVENT_P2("response_content(): response = 0x%04X, size = %i", resp->ctrl_response, resp_len);
511 TRACE_BINDUMP(GDD_DIO_handle, TC_USER4, "BAT RESPONSE PARAMETER", (U8 *)resp->response.ptr_at_ok, resp_len);
512 }
513
514
515 typedef enum
516 {
517 CLIENT_HANDLE_OK = 0,
518 CLIENT_HANDLE_OUT_OF_BOUNDS,
519 CLIENT_HANDLE_NOT_VALID
520 } T_CLIENT_HANDLE_ERROR;
521
522 LOCAL T_CLIENT_HANDLE_ERROR check_client_handle (T_BAT_client clnt_hndl)
523 {
524 U8 clnt_hndl_upper = (U8)((clnt_hndl&0xff00)>>8); /* the instance */
525 U8 clnt_hndl_lower = (U8) (clnt_hndl&0x00ff); /* the client */
526
527 TRACE_EVENT_P2("check_client_handle(): instance = %d, client = %d", clnt_hndl_upper, clnt_hndl_lower);
528
529 if((clnt_hndl_lower >= BAT_MAX_TEST_CLNT_NUM) OR (clnt_hndl_upper >= BAT_MAX_TEST_INST_NUM))
530 {
531 app_bat_send_result_prim(1, NO_ADD_VAL);
532 return (CLIENT_HANDLE_OUT_OF_BOUNDS);
533 }
534 if(clnt_table[clnt_hndl_upper][0] EQ 0) /* first element in clnt_table informs about Nr of Clnts */
535 {
536 app_bat_send_result_prim(1, NO_ADD_VAL);
537 return (CLIENT_HANDLE_NOT_VALID);
538 }
539
540 if(clnt_table[clnt_hndl_upper][clnt_hndl_lower] EQ 0xffff) /* invalid client */
541 {
542 app_bat_send_result_prim(1, NO_ADD_VAL);
543 return (CLIENT_HANDLE_NOT_VALID);
544 }
545
546 return (CLIENT_HANDLE_OK);
547 }
548
549 LOCAL char *error_client_handle (T_CLIENT_HANDLE_ERROR err)
550 {
551 TRACE_FUNCTION("error_client_handle()");
552 switch (err)
553 {
554 case (CLIENT_HANDLE_OUT_OF_BOUNDS):
555 {
556 TRACE_ERROR("Input clnt_hndl out of bounds");
557 return ("Input clnt_hndl out of bounds");
558 }
559 case (CLIENT_HANDLE_NOT_VALID):
560 {
561 TRACE_ERROR("client handle not valid");
562 return ("client handle not valid");
563 }
564 default:
565 {
566 TRACE_ERROR("unknown client handle error");
567 return ("unknown client handle error");
568 }
569 }
570 }
571
572
573 GLOBAL int response_cb (T_BAT_client client, T_BAT_cmd_response *rsp)
574 {
575 TRACE_FUNCTION("response_cb()");
576 TRACE_EVENT_P2("CLIENT HNDL IS: 0x%04x, RESPONSE TAG IS: 0x%04x", client, rsp->ctrl_response);
577 response_content (rsp);
578
579 switch (rsp->ctrl_response)
580 {
581 case (BAT_RES_SET_PLUS_CMGL):
582 {
583 T_BAT_res_set_plus_cmgl *ptr_set_plus_cmgl;
584 ptr_set_plus_cmgl =( void *) (rsp->response.ptr_set_plus_cmgl);
585 TRACE_EVENT("BAT_RES_SET_PLUS_CMGL response");
586 TRACE_EVENT_P1("index = %d", ptr_set_plus_cmgl->sms_index);
587 TRACE_EVENT_P1("status = %d", ptr_set_plus_cmgl->stat);
588 break;
589 }
590 case (BAT_RES_SET_PLUS_CPBR):
591 {
592 T_BAT_res_set_plus_cpbr *ptr_set_plus_cpbr;
593 ptr_set_plus_cpbr =( void *) (rsp->response.ptr_set_plus_cpbr);
594 TRACE_EVENT("BAT_RES_SET_PLUS_CPBR response");
595 memset(at_cmd_resp_param[0], 0x00, RESP_LINE_LEN) ;
596 memset(at_cmd_resp_param[1], 0x00, RESP_LINE_LEN) ;
597 memcpy(at_cmd_resp_param[0], ptr_set_plus_cpbr->number, ptr_set_plus_cpbr->c_number) ;
598 memcpy(at_cmd_resp_param[1], ptr_set_plus_cpbr->text, ptr_set_plus_cpbr->c_text) ;
599
600 TRACE_EVENT_P4("+CPBR: %d,\"%s\",%d,\"%s\"", ptr_set_plus_cpbr->index,
601 at_cmd_resp_param[0],
602 ptr_set_plus_cpbr->type,
603 at_cmd_resp_param[1]);
604 break ;
605 }
606 case (BAT_RES_SET_PLUS_CPBF):
607 {
608 T_BAT_res_set_plus_cpbf *ptr_set_plus_cpbf;
609 ptr_set_plus_cpbf =( void *) (rsp->response.ptr_set_plus_cpbf);
610 TRACE_EVENT("BAT_RES_SET_PLUS_CPBF response");
611 memset(at_cmd_resp_param[0], 0x00, RESP_LINE_LEN) ;
612 memset(at_cmd_resp_param[1], 0x00, RESP_LINE_LEN) ;
613 memcpy(at_cmd_resp_param[0], ptr_set_plus_cpbf->number, ptr_set_plus_cpbf->c_number) ;
614 memcpy(at_cmd_resp_param[1], ptr_set_plus_cpbf->text, ptr_set_plus_cpbf->c_text) ;
615
616 TRACE_EVENT_P4("+CPBF: %d,\"%s\",%d,\"%s\"", ptr_set_plus_cpbf->index,
617 at_cmd_resp_param[0],
618 ptr_set_plus_cpbf->type,
619 at_cmd_resp_param[1]);
620 break ;
621 }
622 case (BAT_RES_QUE_PLUS_CGATT):
623 {
624 T_BAT_res_que_plus_cgatt *ptr_que_plus_cgatt;
625 ptr_que_plus_cgatt =( void *) (rsp->response.ptr_que_plus_cgatt);
626
627 TRACE_EVENT("BAT_RES_QUE_PLUS_CGATT:");
628
629 if (ptr_que_plus_cgatt->state EQ BAT_CGATT_STATE_DETACHED)
630 TRACE_EVENT("BAT_RES_QUE_PLUS_CGATT: GPRS DETACHED");
631 else
632 TRACE_EVENT("BAT_RES_QUE_PLUS_CGATT: GPRS ATTACHED");
633
634 break ;
635 }
636 case (BAT_RES_QUE_PLUS_CGACT):
637 {
638 T_BAT_res_que_plus_cgact *ptr_que_plus_cgact;
639 ptr_que_plus_cgact =( void *) (rsp->response.ptr_que_plus_cgact);
640
641 if(ptr_que_plus_cgact->state EQ BAT_CGACT_STATE_DEACTIVATED)
642 TRACE_EVENT("BAT_RES_QUE_PLUS_CGACT: GPRS DEACTIVATED");
643 else
644 TRACE_EVENT("BAT_RES_QUE_PLUS_CGACT: GPRS ACTIVATED");
645 break ;
646 }
647 case (BAT_RES_QUE_PLUS_CGDCONT):
648 {
649 T_BAT_res_que_plus_cgdcont *ptr_que_plus_cgdcont;
650 ptr_que_plus_cgdcont =( void *) (rsp->response.ptr_que_plus_cgdcont);
651
652 memset(at_cmd_resp_param[0], 0x00, RESP_LINE_LEN) ;
653 memset(at_cmd_resp_param[1], 0x00, RESP_LINE_LEN) ;
654
655 memcpy(at_cmd_resp_param[0], ptr_que_plus_cgdcont->apn, ptr_que_plus_cgdcont->c_apn) ;
656 memcpy(at_cmd_resp_param[1], ptr_que_plus_cgdcont->pdp_addr, ptr_que_plus_cgdcont->c_pdp_addr) ;
657
658 TRACE_EVENT_P1("BAT_RES_QUE_PLUS_CGCONT: APN is %s", at_cmd_resp_param[0]) ;
659 TRACE_EVENT_P1("BAT_RES_QUE_PLUS_CGCONT: PDP Address is %s", at_cmd_resp_param[1]);
660 break ;
661 }
662 case (BAT_RES_SET_PERCENT_CGPCO):
663 {
664 T_BAT_res_set_percent_cgpco *ptr_que_per_cgpco;
665 ptr_que_per_cgpco =( void *) (rsp->response.ptr_set_percent_cgpco);
666
667 memset(at_cmd_resp_param[0], 0x00, RESP_LINE_LEN) ;
668 memset(at_cmd_resp_param[1], 0x00, RESP_LINE_LEN) ;
669
670 memcpy(at_cmd_resp_param[0], ptr_que_per_cgpco->pco, ptr_que_per_cgpco->c_pco) ;
671
672 TRACE_EVENT_P1("BAT_RES_SET_PERCENT_CGPCO: PCO STRING %s", at_cmd_resp_param[0]) ;
673 break ;
674 }
675 case (BAT_RES_QUE_PLUS_CPOL):
676 {
677 rsp->response.ptr_que_plus_cpol->oper[rsp->response.ptr_que_plus_cpol->c_oper] = '\0';
678 TRACE_EVENT_P3("BAT_RES_QUE_PLUS_CPOL: %d,%d,\"%s\"",
679 rsp->response.ptr_que_plus_cpol->index,
680 rsp->response.ptr_que_plus_cpol->format,
681 rsp->response.ptr_que_plus_cpol->oper);
682 break;
683 }
684 case (BAT_RES_TST_PLUS_CPOL):
685 {
686 TRACE_EVENT_P2("BAT_RES_TST_PLUS_CPOL: %d,%d",
687 rsp->response.ptr_tst_plus_cpol->index1,
688 rsp->response.ptr_tst_plus_cpol->index2);
689 break;
690 }
691 case (BAT_RES_QUE_PLUS_CSCS):
692 {
693 TRACE_EVENT_P1("BAT_RES_QUE_PLUS_CSCS: %d",
694 rsp->response.ptr_que_plus_cscs->cs);
695 break;
696 }
697 case (BAT_RES_SET_PLUS_CCWA):
698 {
699 TRACE_EVENT_P1("BAT_RES_SET_PLUS_CCWA: %d",
700 rsp->response.ptr_set_plus_ccwa->status);
701 break;
702 }
703 case (BAT_RES_SET_PLUS_CGMI):
704 {
705 TRACE_EVENT_P1("BAT_RES_SET_PLUS_CGMI: %s",
706 rsp->response.ptr_set_plus_cgmi->manufacturer);
707 break;
708 }
709 case (BAT_RES_SET_PLUS_CGMM):
710 {
711 TRACE_EVENT_P1("BAT_RES_SET_PLUS_CGMM: %s",
712 rsp->response.ptr_set_plus_cgmm->model);
713 break;
714 }
715 case (BAT_RES_SET_PLUS_CGMR):
716 {
717 TRACE_EVENT_P1("BAT_RES_SET_PLUS_CGMR: %s",
718 rsp->response.ptr_set_plus_cgmr->revision);
719 break;
720 }
721 case (BAT_RES_SET_PLUS_CGSN):
722 {
723 TRACE_EVENT_P1("BAT_RES_SET_PLUS_CGSN: %s",
724 rsp->response.ptr_set_plus_cgsn->sn);
725 break;
726 }
727 case (BAT_RES_AT_OK):
728 {
729 TRACE_EVENT("BAT_RES_AT_OK");
730 break;
731 }
732 case (BAT_RES_AT_CONNECT):
733 {
734 TRACE_EVENT("BAT_RES_AT_CONNECT");
735 break;
736 }
737 case (BAT_RES_AT_NO_CARRIER_FINAL):
738 {
739 TRACE_EVENT("BAT_RES_AT_NO_CARRIER_FINAL");
740 break;
741 }
742 case (BAT_RES_PLUS_CME_ERROR):
743 {
744 TRACE_EVENT("BAT_RES_PLUS_CME_ERROR");
745 break;
746 }
747 case (BAT_RES_PLUS_CMS_ERROR):
748 {
749 TRACE_EVENT("BAT_RES_PLUS_CMS_ERROR");
750 break;
751 }
752
753 case (BAT_RES_AT_BUSY):
754 {
755 TRACE_EVENT("BAT_RES_AT_BUSY");
756 break;
757 }
758 case BAT_RES_UNS_AT_BUSY:
759 {
760 TRACE_EVENT("BAT_RES_UNS_AT_BUSY");
761 break;
762 }
763 case BAT_RES_AT_CHANNEL_BUSY:
764 {
765 TRACE_EVENT("BAT_RES_AT_CHANNEL_BUSY");
766 break;
767 }
768 case (BAT_RES_AT_NO_ANSWER):
769 {
770 TRACE_EVENT("BAT_RES_AT_NO_ANSWER");
771 break;
772 }
773 case BAT_RES_UNS_AT_NO_ANSWER:
774 {
775 TRACE_EVENT("BAT_RES_UNS_AT_NO_ANSWER");
776 break;
777 }
778 case (BAT_RES_PLUS_EXT_ERROR):
779 {
780 TRACE_EVENT("BAT_RES_PLUS_EXT_ERROR");
781 break;
782 }
783 default:
784 {
785 TRACE_EVENT("response_cb(): THIS BAT CMD RESPONSE IS STILL UNCOVERED");
786 break ;
787 }
788 }
789 return 0;
790 }
791
792
793 GLOBAL int response_cb_busy (T_BAT_client client, T_BAT_cmd_response *rsp)
794 {
795 static int i = 0;
796 TRACE_FUNCTION ("response_cb_busy()");
797
798 TRACE_EVENT_P2("CLIENT HNDL IS: 0x%04x, RESPONSE TAG IS: 0x%04x", client, rsp->ctrl_response);
799 TRACE_EVENT_P1("CONTENT OF RESPONSE IS: %s", rsp->response.ptr_at_ok);
800
801 /* returns 1 (busy) for the the first call and 0 (ok) for the second call */
802 if (i EQ 0)
803 {
804 i++;
805 return 1;
806 }
807
808 return 0;
809 }
810
811 typedef enum
812 {
813 MOTO_CMD_MAID = 0x2001,
814 MOTO_CMD_MAPV,
815 MOTO_CMD_MDBAD,
816 MOTO_CMD_MDBL,
817 MOTO_CMD_MDBR,
818 MOTO_CMD_MDBW,
819 MOTO_CMD_MDFILE,
820 MOTO_CMD_MDIR,
821 MOTO_CMD_MFOLDER,
822 MOTO_CMD_MODE,
823 MOTO_CMD_MPBR,
824 MOTO_CMD_MPBW,
825 MOTO_CMD_MPDPM ,
826 MOTO_CMD_MR,
827 MOTO_CMD_MSYN,
828 MOTO_CMD_MTDR,
829 MOTO_CMD_MW
830 } T_MOTO_CMD;
831
832
833 GLOBAL int unsolicited_result_cb (T_BAT_client client, T_BAT_cmd_response *rsp)
834 {
835 TRACE_FUNCTION ("unsolicited_result_cb()");
836
837 TRACE_EVENT_P2("CLIENT HNDL IS: 0x%04x, RESPONSE TAG IS: 0x%04x", client, rsp->ctrl_response);
838
839 if (rsp->ctrl_response & 0x2000)
840 {
841 rsp->response.ptr_custom->buf[rsp->response.ptr_custom->c_buf] = '\0';
842 TRACE_BINDUMP(GDD_DIO_handle, TC_USER4, "USER DATA", (U8 *)rsp->response.ptr_custom->buf,
843 rsp->response.ptr_custom->c_buf);
844
845 TRACE_EVENT_P2("unsolicited_result_cb(): custom: len = %d %s",
846 rsp->response.ptr_custom->c_buf, rsp->response.ptr_custom->buf);
847 return 0;
848 }
849 else
850 {
851 response_content (rsp);
852 }
853
854 switch (rsp->ctrl_response)
855 {
856 case (BAT_RES_UNS_PERCENT_CPI):
857 {
858 T_BAT_res_uns_percent_cpi *cpi = rsp->response.ptr_res_percent_cpi;
859
860 switch(cpi->msgtype)
861 {
862 case(BAT_P_CPI_TYPE_SETUP):
863 {
864 TRACE_EVENT("BAT_P_CPI_TYPE_SETUP");
865 break;
866 }
867 case(BAT_P_CPI_TYPE_DISC):
868 {
869 TRACE_EVENT("BAT_P_CPI_TYPE_DISC");
870 break;
871 }
872 case(BAT_P_CPI_TYPE_ALERTING):
873 {
874 TRACE_EVENT("BAT_P_CPI_TYPE_ALERTING");
875 break;
876 }
877 case(BAT_P_CPI_TYPE_PROC):
878 {
879 TRACE_EVENT("BAT_P_CPI_TYPE_PROC");
880 break;
881 }
882 case(BAT_P_CPI_TYPE_SYNC):
883 {
884 TRACE_EVENT("BAT_P_CPI_TYPE_SYNC");
885 break;
886 }
887 case(BAT_P_CPI_TYPE_PROGRESS):
888 {
889 TRACE_EVENT("BAT_P_CPI_TYPE_PROGRESS");
890 break;
891 }
892 case(BAT_P_CPI_TYPE_CONNECT):
893 {
894 TRACE_EVENT("BAT_P_CPI_TYPE_CONNECT");
895 break;
896 }
897 case(BAT_P_CPI_TYPE_RELEASE):
898 {
899 TRACE_EVENT("BAT_P_CPI_TYPE_RELEASE");
900 break;
901 }
902 case(BAT_P_CPI_TYPE_REJECT):
903 {
904 TRACE_EVENT("BAT_P_CPI_TYPE_REJECT");
905 break;
906 }
907 }
908 break;
909 }
910 default:
911 {
912 TRACE_EVENT("unsolicited_result_cb(): THIS BAT CMD RESPONSE IS STILL UNCOVERED");
913 break ;
914 }
915 }
916
917 return 0;
918 }
919 GLOBAL void instance_signal_cb (T_BAT_signal result)
920 {
921 TRACE_FUNCTION ("instance_signal_cb()");
922 TRACE_EVENT_P1("SIGNAL IS: %d", result);
923 return;
924 }
925
926
927 /*
928 +-------------------------------------------------------------------+
929 | PROJECT : MODULE : app_bat |
930 | ROUTINE : app_bat_send_result_prim|
931 +-------------------------------------------------------------------+
932
933 PURPOSE : Provides the output over APP.
934
935 */
936 GLOBAL void app_bat_send_result_prim (U8 result, U32 add_info)
937 {
938 #ifndef _TARGET_
939 /* send message to the test interface*/
940 PALLOC (app_bat_test_result, APP_BAT_TEST_RSLT);
941
942 TRACE_FUNCTION_P2("app_bat_send_result_prim(): result is: %d, add_info is: %d", result, add_info);
943
944 app_bat_test_result->test_rslt = result;
945 app_bat_test_result->additional_info = add_info;
946 PSEND (hCommMMI, app_bat_test_result);
947 #endif /* _TARGET_ */
948 return;
949 }
950
951 GLOBAL char *app_bat_init (app_cmd_entry_t *cmd_entry_ptr, char *param1,
952 char *param2, char *param3, core_func_t core_func)
953 {
954 T_BAT_return result = BAT_ERROR;
955 void *mem = NULL;
956 int inst_num = get_item(param1, BAT_MAX_TEST_INST_NUM, TRUE);
957
958 TRACE_FUNCTION("app_bat_init()");
959 MALLOC(mem, BAT_INSTANCE_HEADER_SIZE*inst_num);
960 result = bat_init(mem, (U8)inst_num);
961 if(result NEQ BAT_OK)
962 {
963 app_bat_send_result_prim(1, NO_ADD_VAL);
964 return "Call to bat_init() failed";
965 }
966
967 app_bat_send_result_prim(0, NO_ADD_VAL);
968 return 0;
969 }
970
971 GLOBAL char *app_bat_deinit (app_cmd_entry_t *cmd_entry_ptr, char *param1,
972 char *param2, char *param3, core_func_t core_func)
973 {
974 T_BAT_return result = bat_deinit();
975 TRACE_FUNCTION("app_bat_deinit()");
976
977 if(result NEQ BAT_OK)
978 {
979 app_bat_send_result_prim(1, NO_ADD_VAL);
980 return ("Call to bat_deinit() failed");
981 }
982 app_bat_send_result_prim(0, NO_ADD_VAL);
983 return 0;
984 }
985
986 GLOBAL char *app_bat_new (app_cmd_entry_t *cmd_entry_ptr, char *param1,
987 char *param2, char *param3, core_func_t core_func)
988 {
989 T_BAT_return result = BAT_ERROR;
990 void *mem = NULL;
991 T_BAT_instance inst_hndl = BAT_INVALID_INSTANCE_HANDLE;
992 int i = 0;
993 int clnt_num = get_item(param1, BAT_MAX_TEST_CLNT_NUM, TRUE);
994
995 TRACE_FUNCTION("app_bat_new()");
996
997 /* Find free slot for connection handle */
998 for (i = 0; i < BAT_MAX_TEST_INST_NUM && clnt_table[i][0] != 0; i++)
999 {
1000
1001 }
1002
1003 if(clnt_num > BAT_MAX_TEST_CLNT_NUM OR i > BAT_MAX_TEST_INST_NUM)
1004 {
1005 app_bat_send_result_prim(1, NO_ADD_VAL);
1006 return ("Max instance num too big");
1007 }
1008
1009
1010 MALLOC(mem, (clnt_num*BAT_CLIENT_SIZE + BAT_INSTANCE_SIZE));
1011
1012 app_set_config ();
1013
1014 result = bat_new (&inst_hndl, mem, (U8)clnt_num, BAT_APP_CONFIG, instance_signal_cb);
1015
1016 TRACE_EVENT_P1 ("inst_hndl is %d", inst_hndl);
1017
1018 if(result != BAT_OK)
1019 {
1020 app_bat_send_result_prim(1, NO_ADD_VAL);
1021 return("Call to bat_new() failed");
1022 }
1023
1024 clnt_table[inst_hndl][0]++;
1025
1026 app_bat_send_result_prim(0, NO_ADD_VAL);
1027 return 0;
1028 }
1029
1030 GLOBAL char *app_bat_delete (app_cmd_entry_t *cmd_entry_ptr, char *param1,
1031 char *param2, char *param3, core_func_t core_func)
1032 {
1033 T_BAT_return result = BAT_ERROR;
1034 T_BAT_instance inst_hndl = BAT_BROADCAST_CHANNEL; /* connection number -index into local static connection table */
1035
1036 TRACE_FUNCTION("app_bat_delete()");
1037
1038 inst_hndl = get_item(param1, 0, FALSE);
1039 if(inst_hndl >= BAT_MAX_TEST_INST_NUM)
1040 {
1041 app_bat_send_result_prim(1, NO_ADD_VAL);
1042 return ("Connection number out of bounds");
1043 }
1044 result = bat_delete (inst_hndl);
1045 if(result != BAT_OK )
1046 {
1047 app_bat_send_result_prim(1, NO_ADD_VAL);
1048 return ("Call to gdd_close failed");
1049 }
1050
1051 clnt_table[inst_hndl][0] = 0;
1052 app_bat_send_result_prim(0, NO_ADD_VAL);
1053 return 0;
1054 }
1055
1056 GLOBAL char *app_bat_uns_open (app_cmd_entry_t *cmd_entry_ptr, char *param1,
1057 char *param2, char *param3, core_func_t core_func)
1058 {
1059 T_BAT_client client;
1060 TRACE_FUNCTION("app_bat_uns_open()");
1061 if (bat_uns_open(0, &client, unsolicited_result_cb))
1062 {
1063 app_bat_send_result_prim(1, NO_ADD_VAL);
1064 return ("Call to bat_uns_open() failed");
1065 }
1066 app_bat_send_result_prim(0, NO_ADD_VAL);
1067 return 0;
1068 }
1069
1070 GLOBAL char *app_bat_open (app_cmd_entry_t *cmd_entry_ptr, char *param1,
1071 char *param2, char *param3, core_func_t core_func)
1072 {
1073 T_BAT_return result = BAT_ERROR;
1074 T_BAT_client clnt_hndl = BAT_INVALID_CLIENT_HANDLE; /* connection number -index into local static connection table */
1075 T_BAT_instance inst_hndl = BAT_BROADCAST_CHANNEL;
1076 U8 clnt_hndl_upper = 0;
1077 U8 clnt_hndl_lower = 0;
1078
1079 TRACE_FUNCTION("app_bat_open()");
1080
1081 inst_hndl = get_item(param1, 0, TRUE);
1082 if (inst_hndl >= BAT_MAX_TEST_INST_NUM)
1083 {
1084 app_bat_send_result_prim(1, NO_ADD_VAL);
1085 return ("input inst_hndl is wrong");
1086 }
1087
1088 if ( clnt_table[inst_hndl][0] EQ 0)
1089 {
1090 app_bat_send_result_prim(1, NO_ADD_VAL);
1091 return("input inst_hndl is wrong, instance is not opened yet");
1092 }
1093
1094 result = bat_open (inst_hndl, &clnt_hndl, response_cb, signal_cb);
1095 if(result != BAT_OK)
1096 {
1097 app_bat_send_result_prim(1, NO_ADD_VAL);
1098 return("Call to bat_open() failed");
1099 }
1100
1101 clnt_hndl_upper = (U8)((0xff00&clnt_hndl)>>8);
1102 clnt_hndl_lower = (U8) (0x00ff&clnt_hndl);
1103 TRACE_EVENT_P2("The returned clnt_hndl is 0x%02X%02X", clnt_hndl_upper, clnt_hndl_lower);
1104
1105 if(clnt_hndl_upper NEQ inst_hndl)
1106 {
1107 app_bat_send_result_prim(1, NO_ADD_VAL);
1108 return("clnt_hndl is wrong");
1109 }
1110
1111 clnt_table[inst_hndl][clnt_hndl_lower+1] = clnt_hndl;
1112 clnt_table[inst_hndl][0]++;
1113
1114 TRACE_EVENT_P3("app_bat_open(): clnt_table[%d][%d] = 0x%04X", inst_hndl, clnt_hndl_lower+1, clnt_hndl);
1115
1116 app_bat_uns_open (cmd_entry_ptr, param1, param2, param3, core_func);
1117 app_bat_send_result_prim(0, NO_ADD_VAL);
1118
1119 return 0;
1120 }
1121
1122 GLOBAL char *app_bat_close (app_cmd_entry_t *cmd_entry_ptr, char *param1,
1123 char *param2, char *param3, core_func_t core_func)
1124 {
1125 T_BAT_return result = BAT_ERROR;
1126 T_BAT_client clnt_hndl = BAT_INVALID_CLIENT_HANDLE; /* connection number -index into local static connection table */
1127 U8 clnt_hndl_upper;
1128 U8 clnt_hndl_lower;
1129 T_CLIENT_HANDLE_ERROR err;
1130
1131 clnt_hndl = get_item(param1, 0, FALSE);
1132
1133 err = check_client_handle (clnt_hndl);
1134 if (err NEQ CLIENT_HANDLE_OK)
1135 {
1136 return (error_client_handle(err));
1137 }
1138
1139 clnt_hndl_upper = (U8)((clnt_hndl&0xff00)>>8);
1140 clnt_hndl_lower = (U8) (clnt_hndl&0x00ff);
1141
1142 result = bat_close (clnt_hndl);
1143 if(result NEQ BAT_OK)
1144 {
1145 app_bat_send_result_prim(1, NO_ADD_VAL);
1146 return ("Call to bat_close() failed");
1147 }
1148
1149 clnt_table[clnt_hndl_upper][clnt_hndl_lower+1] = 0xffff;
1150 clnt_table[clnt_hndl_upper][0]--;
1151
1152 app_bat_send_result_prim(0, NO_ADD_VAL);
1153 return 0;
1154 }
1155
1156 /*
1157 * sending of BAT commands
1158 */
1159
1160 GLOBAL char *app_bat_send_q_clcc(app_cmd_entry_t *cmd_entry_ptr, char *param1,
1161 char *param2, char *param3, core_func_t core_func)
1162 {
1163 T_BAT_return result = BAT_ERROR;
1164 T_BAT_client clnt_hndl = BAT_CONTROL_CHANNEL;
1165 T_BAT_no_parameter my_que_plus_clcc;
1166 T_BAT_cmd_send my_bat_cmd_send;
1167 T_CLIENT_HANDLE_ERROR err;
1168
1169 TRACE_FUNCTION("app_bat_send_q_clcc()");
1170
1171 clnt_hndl = get_item(param1, 0, FALSE);
1172
1173 err = check_client_handle (clnt_hndl);
1174 if (err NEQ CLIENT_HANDLE_OK)
1175 {
1176 return (error_client_handle(err));
1177 }
1178
1179 my_bat_cmd_send.ctrl_params = BAT_CMD_QUE_PLUS_CLCC;
1180 my_bat_cmd_send.params.ptr_que_plus_clcc = &my_que_plus_clcc ;
1181 my_que_plus_clcc.bat_dummy = 0xFF;
1182
1183 result = bat_send (clnt_hndl, &my_bat_cmd_send);
1184
1185 if (result NEQ BAT_OK)
1186 {
1187 app_bat_send_result_prim(1, NO_ADD_VAL);
1188 return ("Call to bat_send_q_clcc() failed");
1189 }
1190 app_bat_send_result_prim(0, NO_ADD_VAL);
1191 return 0;
1192 }
1193
1194 GLOBAL char *app_bat_send_q_cscs(app_cmd_entry_t *cmd_entry_ptr, char *param1,
1195 char *param2, char *param3, core_func_t core_func)
1196 {
1197 T_BAT_return result = BAT_ERROR;
1198 T_BAT_client clnt_hndl = BAT_CONTROL_CHANNEL;
1199 T_BAT_no_parameter my_que_plus_cscs;
1200 T_BAT_cmd_send my_bat_cmd_send;
1201 T_CLIENT_HANDLE_ERROR err;
1202
1203 TRACE_FUNCTION("app_bat_send_q_cscs()");
1204
1205 clnt_hndl = get_item(param1, 0, FALSE);
1206
1207 err = check_client_handle (clnt_hndl);
1208 if (err NEQ CLIENT_HANDLE_OK)
1209 {
1210 return (error_client_handle(err));
1211 }
1212
1213 my_bat_cmd_send.ctrl_params = BAT_CMD_QUE_PLUS_CSCS ;
1214 my_bat_cmd_send.params.ptr_que_plus_cscs = &my_que_plus_cscs ;
1215 my_que_plus_cscs.bat_dummy = 0xFF;
1216
1217 result = bat_send (clnt_hndl, &my_bat_cmd_send);
1218
1219 if (result NEQ BAT_OK)
1220 {
1221 app_bat_send_result_prim(1, NO_ADD_VAL);
1222 return ("Call to bat_send_q_cscs() failed");
1223 }
1224 app_bat_send_result_prim(0, NO_ADD_VAL);
1225 return 0;
1226 }
1227
1228 GLOBAL char *app_bat_send_csms(app_cmd_entry_t *cmd_entry_ptr, char *param1,
1229 char *param2, char *param3, core_func_t core_func)
1230 {
1231 T_BAT_return result = BAT_ERROR;
1232 T_BAT_client clnt_hndl = BAT_CONTROL_CHANNEL;
1233 T_BAT_cmd_set_plus_csms my_set_plus_csms;
1234 T_BAT_cmd_send my_bat_cmd_send;
1235 T_CLIENT_HANDLE_ERROR err;
1236
1237 TRACE_FUNCTION("app_bat_send_csms()");
1238
1239 clnt_hndl = get_item(param1, 0, FALSE);
1240
1241 err = check_client_handle (clnt_hndl);
1242 if (err NEQ CLIENT_HANDLE_OK)
1243 {
1244 return (error_client_handle(err));
1245 }
1246
1247 memset(&my_set_plus_csms, sizeof(my_set_plus_csms), FALSE);
1248 my_bat_cmd_send.ctrl_params = BAT_CMD_SET_PLUS_CSMS;
1249
1250 my_bat_cmd_send.params.ptr_set_plus_csms = &my_set_plus_csms;
1251
1252 /* resolve the service requested */
1253 my_set_plus_csms.service = (T_BAT_plus_csms_service)atoi(param2);;
1254
1255 result = bat_send (clnt_hndl, &my_bat_cmd_send);
1256
1257 if(result NEQ BAT_OK)
1258 {
1259 app_bat_send_result_prim(1, NO_ADD_VAL);
1260 return ("Call to bat_send_csms() failed");
1261 }
1262 app_bat_send_result_prim(0, NO_ADD_VAL);
1263 return 0;
1264 }
1265
1266 GLOBAL char *app_bat_send_ccwa (app_cmd_entry_t *cmd_entry_ptr, char *param1,
1267 char *param2, char *param3, core_func_t core_func)
1268 {
1269 T_BAT_return result = BAT_ERROR;
1270 T_BAT_client clnt_hndl = BAT_CONTROL_CHANNEL;
1271 T_BAT_cmd_set_plus_ccwa my_set_plus_ccwa;
1272 T_BAT_cmd_send my_bat_cmd_send;
1273 T_CLIENT_HANDLE_ERROR err;
1274
1275 TRACE_FUNCTION("app_bat_send_ccwa()");
1276
1277 clnt_hndl = get_item(param1, 0, FALSE);
1278
1279 err = check_client_handle (clnt_hndl);
1280 if (err NEQ CLIENT_HANDLE_OK)
1281 {
1282 return (error_client_handle(err));
1283 }
1284
1285 memset(&my_set_plus_ccwa, sizeof(my_set_plus_ccwa), FALSE);
1286 my_bat_cmd_send.ctrl_params = BAT_CMD_SET_PLUS_CCWA;
1287 my_bat_cmd_send.params.ptr_set_plus_ccwa = &my_set_plus_ccwa;
1288 my_set_plus_ccwa.mode = (T_BAT_plus_ccwa_mode) atoi(param2);
1289 my_set_plus_ccwa.bearer_class = BAT_CCWA_CLASS_NOT_PRESENT;
1290
1291 result = bat_send (clnt_hndl, &my_bat_cmd_send);
1292
1293 if(result NEQ BAT_OK)
1294 {
1295 app_bat_send_result_prim(1, NO_ADD_VAL);
1296 return ("Call to bat_send_ccwa() failed");
1297 }
1298
1299 app_bat_send_result_prim(0, NO_ADD_VAL);
1300 return 0;
1301 }
1302
1303 GLOBAL char *app_bat_send_cgsms(app_cmd_entry_t *cmd_entry_ptr, char *param1,
1304 char *param2, char *param3, core_func_t core_func)
1305 {
1306 T_BAT_return result = BAT_ERROR;
1307 T_BAT_client clnt_hndl = BAT_CONTROL_CHANNEL;
1308 T_BAT_cmd_set_plus_cgsms my_set_plus_cgsms;
1309 T_BAT_cmd_send my_bat_cmd_send;
1310 T_CLIENT_HANDLE_ERROR err;
1311
1312 TRACE_FUNCTION("app_bat_send_cgsms()");
1313
1314 clnt_hndl = get_item(param1, 0, FALSE);
1315
1316 err = check_client_handle (clnt_hndl);
1317 if (err NEQ CLIENT_HANDLE_OK)
1318 {
1319 return (error_client_handle(err));
1320 }
1321
1322 memset(&my_set_plus_cgsms, sizeof(my_set_plus_cgsms), FALSE);
1323 my_bat_cmd_send.ctrl_params = BAT_CMD_SET_PLUS_CGSMS;
1324
1325 my_bat_cmd_send.params.ptr_set_plus_cgsms = &my_set_plus_cgsms;
1326
1327 /* resolve the service requested */
1328 my_set_plus_cgsms.service = (T_BAT_plus_cgsms_service) atoi(param2);
1329
1330 result = bat_send (clnt_hndl, &my_bat_cmd_send);
1331
1332 if(result NEQ BAT_OK)
1333 {
1334 app_bat_send_result_prim(1, NO_ADD_VAL);
1335 return ("Call to bat_send_cgsms() failed");
1336 }
1337 app_bat_send_result_prim(0, NO_ADD_VAL);
1338 return 0;
1339 }
1340
1341 GLOBAL char *app_bat_send_cscs(app_cmd_entry_t *cmd_entry_ptr, char *param1,
1342 char *param2, char *param3, core_func_t core_func)
1343 {
1344 T_BAT_return result = BAT_ERROR;
1345 T_BAT_client clnt_hndl = BAT_CONTROL_CHANNEL;
1346 T_BAT_cmd_set_plus_cscs my_set_plus_cscs;
1347 T_BAT_cmd_send my_bat_cmd_send;
1348 T_CLIENT_HANDLE_ERROR err;
1349
1350 TRACE_FUNCTION("app_bat_send_cscs()");
1351
1352 clnt_hndl = get_item(param1, 0, FALSE);
1353
1354 err = check_client_handle (clnt_hndl);
1355 if (err NEQ CLIENT_HANDLE_OK)
1356 {
1357 return (error_client_handle(err));
1358 }
1359
1360 my_bat_cmd_send.ctrl_params = BAT_CMD_SET_PLUS_CSCS ;
1361 my_bat_cmd_send.params.ptr_set_plus_cscs = &my_set_plus_cscs;
1362
1363 /* on ATI is also supported some Scandinavian smoerebroed */
1364 if (param2 NEQ NULL)
1365 {
1366 if (strcmp(param2, "IRA") EQ 0) my_set_plus_cscs.cs = BAT_CSCS_CS_IRA;
1367 else if (strcmp(param2, "GSM") EQ 0) my_set_plus_cscs.cs = BAT_CSCS_CS_GSM;
1368 else if (strcmp(param2, "HEX") EQ 0) my_set_plus_cscs.cs = BAT_CSCS_CS_HEX;
1369 else if (strcmp(param2, "UCS2") EQ 0) my_set_plus_cscs.cs = BAT_CSCS_CS_UCS2;
1370 else
1371 {
1372 TRACE_EVENT("app_bat_send_cscs(): support only UCS2, HEX, GSM, IRA (default)");
1373 my_set_plus_cscs.cs = BAT_CSCS_CS_IRA;
1374 }
1375 }
1376 else
1377 {
1378 my_set_plus_cscs.cs = BAT_CSCS_CS_IRA; /*default = International Reference Alphabet */
1379 }
1380
1381 app_bat_globs.cs = my_set_plus_cscs.cs;
1382
1383 result = bat_send (clnt_hndl, &my_bat_cmd_send);
1384
1385 if (result NEQ BAT_OK)
1386 {
1387 app_bat_send_result_prim(1, NO_ADD_VAL);
1388 return ("Call to bat_send_cscs() failed");
1389 }
1390 app_bat_send_result_prim(0, NO_ADD_VAL);
1391 return 0;
1392 }
1393
1394
1395 GLOBAL char *app_bat_send_cpbr (app_cmd_entry_t *cmd_entry_ptr, char *param1,
1396 char *param2, char *param3, core_func_t core_func)
1397 {
1398 T_BAT_return result = BAT_ERROR;
1399 T_BAT_client clnt_hndl = BAT_CONTROL_CHANNEL;
1400 T_BAT_cmd_set_plus_cpbr my_set_plus_cpbr;
1401 T_BAT_cmd_send my_bat_cmd_send;
1402 T_CLIENT_HANDLE_ERROR err;
1403
1404 TRACE_FUNCTION("app_bat_send_cpbr()");
1405
1406 clnt_hndl = get_item(param1, 0, FALSE);
1407
1408 err = check_client_handle (clnt_hndl);
1409 if (err NEQ CLIENT_HANDLE_OK)
1410 {
1411 return (error_client_handle(err));
1412 }
1413
1414 memset(&my_set_plus_cpbr, sizeof(my_set_plus_cpbr), 0);
1415 my_bat_cmd_send.ctrl_params = BAT_CMD_SET_PLUS_CPBR;
1416 my_bat_cmd_send.params.ptr_set_plus_cpbr = &my_set_plus_cpbr;
1417
1418 /* without given any parameters, set to the same as AT+CPBR=1,1 */
1419 if (param2 EQ NULL)
1420 {
1421 my_set_plus_cpbr.index1 = 1;
1422 }
1423 else
1424 {
1425 my_set_plus_cpbr.index1 = atoi(param2);
1426 }
1427 if (param3 EQ NULL)
1428 {
1429 my_set_plus_cpbr.index2 = my_set_plus_cpbr.index1;
1430 }
1431 else
1432 {
1433 my_set_plus_cpbr.index2 = atoi(param3) ;
1434 }
1435 TRACE_EVENT_P2("app_bat_send_cpbr(): send binary AT+CPBR=%d,%d", my_set_plus_cpbr.index1, my_set_plus_cpbr.index2);
1436
1437 result = bat_send (clnt_hndl, &my_bat_cmd_send);
1438
1439 if(result NEQ BAT_OK)
1440 {
1441 app_bat_send_result_prim(1, NO_ADD_VAL);
1442 return ("Call to bat_send_cfun() failed");
1443 }
1444 app_bat_send_result_prim(0, NO_ADD_VAL);
1445 return 0;
1446 }
1447
1448
1449 GLOBAL char *app_bat_send_cpbw (app_cmd_entry_t *cmd_entry_ptr, char *param1,
1450 char *param2, char *param3, core_func_t core_func)
1451 {
1452 T_BAT_return result = BAT_ERROR;
1453 T_BAT_client clnt_hndl = BAT_CONTROL_CHANNEL;
1454 T_BAT_cmd_set_plus_cpbw my_set_plus_cpbw;
1455 T_BAT_cmd_send my_bat_cmd_send;
1456 T_CLIENT_HANDLE_ERROR err;
1457
1458 TRACE_FUNCTION("app_bat_send_cpbw()");
1459
1460 clnt_hndl = get_item(param1, 0, FALSE);
1461
1462 err = check_client_handle (clnt_hndl);
1463 if (err NEQ CLIENT_HANDLE_OK)
1464 {
1465 return (error_client_handle(err));
1466 }
1467
1468 memset(&my_set_plus_cpbw, sizeof(my_set_plus_cpbw), 0);
1469 my_bat_cmd_send.ctrl_params = BAT_CMD_SET_PLUS_CPBW;
1470 my_bat_cmd_send.params.ptr_set_plus_cpbw = &my_set_plus_cpbw;
1471
1472 if( param2 EQ NULL)
1473 {
1474 my_set_plus_cpbw.index = 1;
1475 }
1476 else
1477 {
1478 my_set_plus_cpbw.index = atoi(param2);
1479 }
1480
1481 /*
1482 * AT+CPBW=index,"number",type,"name"
1483 * with test application we can only get 3 parameters,
1484 * where normally param1 --> clnt_hndl
1485 * param2 --> index
1486 * param3 --> number
1487 *
1488 * But we are more interrested in changing the phone book name
1489 * due to different character sets.
1490 * That's why we assign param3 to the name and hard code the number
1491 */
1492
1493 if(param3==NULL)
1494 {
1495 strcpy((char *)(my_set_plus_cpbw.text), "Doe, John");
1496 my_set_plus_cpbw.c_text = strlen("Doe, John");
1497 }
1498 else
1499 {
1500 strcpy((char *)my_set_plus_cpbw.text, param3);
1501 my_set_plus_cpbw.c_text = strlen(param3);
1502 }
1503 my_set_plus_cpbw.v_text = TRUE;
1504
1505 my_set_plus_cpbw.v_number = TRUE;
1506 strcpy((char *)(my_set_plus_cpbw.number), "12345678" );
1507 my_set_plus_cpbw.c_number = strlen((const char *)(my_set_plus_cpbw.number));
1508
1509 TRACE_EVENT_P2("app_bat_send_cpbw(): %s, %s", my_set_plus_cpbw.number, my_set_plus_cpbw.text);
1510
1511 result = bat_send (clnt_hndl, &my_bat_cmd_send);
1512
1513 if (result NEQ BAT_OK)
1514 {
1515 app_bat_send_result_prim(1, NO_ADD_VAL);
1516 return ("Call to bat_send_cfun() failed");
1517 }
1518 app_bat_send_result_prim(0, NO_ADD_VAL);
1519 return 0;
1520 }
1521
1522
1523 GLOBAL char *app_bat_send_cpbf (app_cmd_entry_t *cmd_entry_ptr, char *param1,
1524 char *param2, char *param3, core_func_t core_func)
1525 {
1526 T_BAT_return result = BAT_ERROR;
1527 T_BAT_client clnt_hndl = BAT_CONTROL_CHANNEL;
1528 T_BAT_cmd_set_plus_cpbf my_set_plus_cpbf;
1529 T_BAT_cmd_send my_bat_cmd_send;
1530 T_CLIENT_HANDLE_ERROR err;
1531
1532 TRACE_FUNCTION("app_bat_send_cpbf()");
1533
1534 clnt_hndl = get_item(param1, 0, FALSE);
1535
1536 err = check_client_handle (clnt_hndl);
1537 if (err NEQ CLIENT_HANDLE_OK)
1538 {
1539 return (error_client_handle(err));
1540 }
1541
1542 memset(&my_set_plus_cpbf, sizeof(my_set_plus_cpbf), 0);
1543 my_bat_cmd_send.ctrl_params = BAT_CMD_SET_PLUS_CPBF;
1544 my_bat_cmd_send.params.ptr_set_plus_cpbf = &my_set_plus_cpbf;
1545
1546 if( param2 EQ NULL)
1547 {
1548 my_set_plus_cpbf.c_findtext = sizeof("Hello")-1;
1549 strcpy((char *)my_set_plus_cpbf.findtext,"Hello");
1550 }
1551 else
1552 {
1553 my_set_plus_cpbf.c_findtext = strlen(param2);
1554 strcpy((char *)my_set_plus_cpbf.findtext,param2);
1555 }
1556
1557 result = bat_send (clnt_hndl, &my_bat_cmd_send);
1558
1559 if (result NEQ BAT_OK)
1560 {
1561 app_bat_send_result_prim(1, NO_ADD_VAL);
1562 return ("Call to bat_send_cfun() failed");
1563 }
1564 app_bat_send_result_prim(0, NO_ADD_VAL);
1565 return 0;
1566 }
1567
1568 GLOBAL char *app_bat_send_cgmi(app_cmd_entry_t *cmd_entry_ptr, char *param1,
1569 char *param2, char *param3, core_func_t core_func)
1570 {
1571 T_BAT_return result = BAT_ERROR;
1572 T_BAT_client clnt_hndl = BAT_CONTROL_CHANNEL;
1573 T_BAT_cmd_send lbatSend;
1574 T_BAT_no_parameter lbatDummy;
1575 T_CLIENT_HANDLE_ERROR err;
1576
1577 TRACE_FUNCTION("app_bat_send_cgmi()");
1578
1579 clnt_hndl = get_item(param1, 0, FALSE);
1580
1581 err = check_client_handle (clnt_hndl);
1582 if (err NEQ CLIENT_HANDLE_OK)
1583 {
1584 return (error_client_handle(err));
1585 }
1586
1587 lbatSend.ctrl_params = BAT_CMD_SET_PLUS_CGMI;
1588 lbatDummy.bat_dummy = 0xFF;
1589 lbatSend.params.ptr_set_plus_cgmi = &lbatDummy;
1590
1591 result = bat_send (clnt_hndl, &lbatSend);
1592
1593 if(result NEQ BAT_OK)
1594 {
1595 app_bat_send_result_prim(1, NO_ADD_VAL);
1596 return ("Call to app_bat_send_cgmi() failed");
1597 }
1598 app_bat_send_result_prim(0, NO_ADD_VAL);
1599 return 0;
1600 }
1601
1602 GLOBAL char *app_bat_send_cgmm(app_cmd_entry_t *cmd_entry_ptr, char *param1,
1603 char *param2, char *param3, core_func_t core_func)
1604 {
1605 T_BAT_return result = BAT_ERROR;
1606 T_BAT_client clnt_hndl = BAT_CONTROL_CHANNEL;
1607 T_BAT_cmd_send lbatSend;
1608 T_BAT_no_parameter lbatDummy;
1609 T_CLIENT_HANDLE_ERROR err;
1610
1611 TRACE_FUNCTION("app_bat_send_cgmm()");
1612
1613 clnt_hndl = get_item(param1, 0, FALSE);
1614
1615 err = check_client_handle (clnt_hndl);
1616 if (err NEQ CLIENT_HANDLE_OK)
1617 {
1618 return (error_client_handle(err));
1619 }
1620
1621 lbatSend.ctrl_params = BAT_CMD_SET_PLUS_CGMM;
1622 lbatDummy.bat_dummy = 0xFF;
1623 lbatSend.params.ptr_set_plus_cgmm = &lbatDummy;
1624
1625 result = bat_send (clnt_hndl, &lbatSend);
1626
1627 if(result NEQ BAT_OK)
1628 {
1629 app_bat_send_result_prim(1, NO_ADD_VAL);
1630 return ("Call to app_bat_send_cgmm() failed");
1631 }
1632 app_bat_send_result_prim(0, NO_ADD_VAL);
1633 return 0;
1634 }
1635
1636 GLOBAL char *app_bat_send_cgmr(app_cmd_entry_t *cmd_entry_ptr, char *param1,
1637 char *param2, char *param3, core_func_t core_func)
1638 {
1639 T_BAT_return result = BAT_ERROR;
1640 T_BAT_client clnt_hndl = BAT_CONTROL_CHANNEL;
1641 T_BAT_cmd_send lbatSend;
1642 T_BAT_no_parameter lbatDummy;
1643 T_CLIENT_HANDLE_ERROR err;
1644
1645 TRACE_FUNCTION("app_bat_send_cgmr()");
1646
1647 clnt_hndl = get_item(param1, 0, FALSE);
1648
1649 err = check_client_handle (clnt_hndl);
1650 if (err NEQ CLIENT_HANDLE_OK)
1651 {
1652 return (error_client_handle(err));
1653 }
1654
1655 lbatSend.ctrl_params = BAT_CMD_SET_PLUS_CGMR;
1656 lbatDummy.bat_dummy = 0xFF;
1657 lbatSend.params.ptr_set_plus_cgmr = &lbatDummy;
1658
1659 result = bat_send (clnt_hndl, &lbatSend);
1660
1661 if(result NEQ BAT_OK)
1662 {
1663 app_bat_send_result_prim(1, NO_ADD_VAL);
1664 return ("Call to app_bat_send_cgmr() failed");
1665 }
1666 app_bat_send_result_prim(0, NO_ADD_VAL);
1667 return 0;
1668 }
1669
1670 GLOBAL char *app_bat_send_cgsn(app_cmd_entry_t *cmd_entry_ptr, char *param1,
1671 char *param2, char *param3, core_func_t core_func)
1672 {
1673 T_BAT_return result = BAT_ERROR;
1674 T_BAT_client clnt_hndl = BAT_CONTROL_CHANNEL;
1675 T_BAT_cmd_send lbatSend;
1676 T_BAT_no_parameter lbatDummy;
1677 T_CLIENT_HANDLE_ERROR err;
1678
1679 TRACE_FUNCTION("app_bat_send_cgsn()");
1680
1681 clnt_hndl = get_item(param1, 0, FALSE);
1682
1683 err = check_client_handle (clnt_hndl);
1684 if (err NEQ CLIENT_HANDLE_OK)
1685 {
1686 return (error_client_handle(err));
1687 }
1688
1689 lbatSend.ctrl_params = BAT_CMD_SET_PLUS_CGSN;
1690 lbatDummy.bat_dummy = 0xFF;
1691 lbatSend.params.ptr_set_plus_cgsn = &lbatDummy;
1692
1693 result = bat_send (clnt_hndl, &lbatSend);
1694
1695 if(result NEQ BAT_OK)
1696 {
1697 app_bat_send_result_prim(1, NO_ADD_VAL);
1698 return("Call to app_bat_send_cgsn() failed");
1699 }
1700 app_bat_send_result_prim(0, NO_ADD_VAL);
1701 return 0;
1702 }
1703
1704 /*
1705 * add some gprs command for test TCPIP
1706 */
1707 GLOBAL char *app_bat_send_q_cgatt(app_cmd_entry_t *cmd_entry_ptr, char *param1,
1708 char *param2, char *param3, core_func_t core_func)
1709 {
1710 T_BAT_return result = BAT_ERROR;
1711 T_BAT_client clnt_hndl = BAT_CONTROL_CHANNEL;
1712 T_BAT_no_parameter my_que_plus_cgatt;
1713 T_BAT_cmd_send my_bat_cmd_send;
1714 T_CLIENT_HANDLE_ERROR err;
1715
1716 TRACE_FUNCTION("app_bat_send_q_cgactt()");
1717
1718 clnt_hndl = get_item(param1, 0, FALSE);
1719
1720 err = check_client_handle (clnt_hndl);
1721 if (err NEQ CLIENT_HANDLE_OK)
1722 {
1723 return (error_client_handle(err));
1724 }
1725
1726 my_bat_cmd_send.ctrl_params = BAT_CMD_QUE_PLUS_CGATT ;
1727 my_bat_cmd_send.params.ptr_que_plus_cgatt = &my_que_plus_cgatt ;
1728 /* full functionality mode*/
1729 /* Reset the MT before changing functionality level */
1730 result = bat_send (clnt_hndl, &my_bat_cmd_send);
1731
1732 if(result NEQ BAT_OK)
1733 {
1734 app_bat_send_result_prim(1, NO_ADD_VAL);
1735 return ("Call to bat_send_cfun() failed");
1736 }
1737 app_bat_send_result_prim(0, NO_ADD_VAL);
1738 return 0;
1739 }
1740
1741
1742
1743 GLOBAL char *app_bat_send_q_cgact(app_cmd_entry_t *cmd_entry_ptr, char *param1,
1744 char *param2, char *param3, core_func_t core_func)
1745 {
1746 T_BAT_return result = BAT_ERROR;
1747 T_BAT_client clnt_hndl = BAT_CONTROL_CHANNEL;
1748 T_BAT_no_parameter my_que_plus_cgact;
1749 T_BAT_cmd_send my_bat_cmd_send;
1750 T_CLIENT_HANDLE_ERROR err;
1751
1752 TRACE_FUNCTION("app_bat_send_q_cgact()");
1753
1754 clnt_hndl = get_item(param1, 0, FALSE);
1755
1756 err = check_client_handle (clnt_hndl);
1757 if (err NEQ CLIENT_HANDLE_OK)
1758 {
1759 return (error_client_handle(err));
1760 }
1761
1762 my_bat_cmd_send.ctrl_params = BAT_CMD_QUE_PLUS_CGACT ;
1763 my_bat_cmd_send.params.ptr_que_plus_cgact = &my_que_plus_cgact ;
1764 /* full functionality mode*/
1765 /* Reset the MT before changing functionality level */
1766 result = bat_send (clnt_hndl, &my_bat_cmd_send);
1767
1768 if(result NEQ BAT_OK)
1769 {
1770 app_bat_send_result_prim(1, NO_ADD_VAL);
1771 return ("Call to bat_send_cfun() failed");
1772 }
1773 app_bat_send_result_prim(0, NO_ADD_VAL);
1774 return 0;
1775 }
1776
1777
1778
1779 GLOBAL char *app_bat_send_cgatt(app_cmd_entry_t *cmd_entry_ptr, char *param1,
1780 char *param2, char *param3, core_func_t core_func)
1781 {
1782
1783 T_BAT_return result = BAT_ERROR;
1784 T_BAT_client clnt_hndl = BAT_CONTROL_CHANNEL;
1785 T_BAT_cmd_set_plus_cgatt my_set_plus_cgatt;
1786 T_BAT_cmd_send my_bat_cmd_send;
1787 T_CLIENT_HANDLE_ERROR err;
1788
1789 TRACE_FUNCTION("app_bat_send_cgatt()");
1790
1791 clnt_hndl = get_item(param1, 0, FALSE);
1792
1793 err = check_client_handle (clnt_hndl);
1794 if (err NEQ CLIENT_HANDLE_OK)
1795 {
1796 return (error_client_handle(err));
1797 }
1798
1799 memset(&my_set_plus_cgatt , sizeof(my_set_plus_cgatt), 0 );
1800 my_bat_cmd_send.ctrl_params = BAT_CMD_SET_PLUS_CGATT ;
1801 my_bat_cmd_send.params.ptr_set_plus_cgatt = &my_set_plus_cgatt ;
1802 /* full functionality mode*/
1803 if(param2 EQ NULL)
1804 my_set_plus_cgatt.state = BAT_CGATT_STATE_ATTACHED;
1805 else
1806 my_set_plus_cgatt.state = (T_BAT_plus_cgatt_state) atoi(param2) ;
1807
1808 result = bat_send (clnt_hndl, &my_bat_cmd_send);
1809
1810 if(result NEQ BAT_OK)
1811 {
1812 app_bat_send_result_prim(1, NO_ADD_VAL);
1813 return ("Call to bat_send_cgatt() failed");
1814 }
1815 app_bat_send_result_prim(0, NO_ADD_VAL);
1816 return 0;
1817 }
1818
1819
1820 GLOBAL char *app_bat_send_cgact(app_cmd_entry_t *cmd_entry_ptr, char *param1,
1821 char *param2, char *param3, core_func_t core_func)
1822 {
1823
1824 T_BAT_return result = BAT_ERROR;
1825 T_BAT_client clnt_hndl = BAT_CONTROL_CHANNEL;
1826 T_BAT_cmd_set_plus_cgact my_set_plus_cgact;
1827 T_BAT_cmd_send my_bat_cmd_send;
1828 T_CLIENT_HANDLE_ERROR err;
1829
1830 TRACE_FUNCTION("app_bat_send_cgact()");
1831
1832 clnt_hndl = get_item(param1, 0, FALSE);
1833
1834 err = check_client_handle (clnt_hndl);
1835 if (err NEQ CLIENT_HANDLE_OK)
1836 {
1837 return (error_client_handle(err));
1838 }
1839
1840 memset(&my_set_plus_cgact , sizeof(my_set_plus_cgact), 0 );
1841 my_bat_cmd_send.ctrl_params = BAT_CMD_SET_PLUS_CGACT ;
1842 my_bat_cmd_send.params.ptr_set_plus_cgact = &my_set_plus_cgact ;
1843 /* full functionality mode*/
1844 if(param2==NULL)
1845 my_set_plus_cgact.state =(T_BAT_plus_cgact_state) 1 ;
1846 else
1847 my_set_plus_cgact.state=(T_BAT_plus_cgact_state) atoi(param2) ;
1848
1849 /* set Activate which pdp context !!! */
1850 my_set_plus_cgact.c_cid = 1 ;
1851 my_set_plus_cgact.cid[0] = (T_BAT_pdp_cid) 1 ;
1852
1853 result = bat_send (clnt_hndl, &my_bat_cmd_send);
1854
1855 if(result NEQ BAT_OK)
1856 {
1857 app_bat_send_result_prim(1, NO_ADD_VAL);
1858 return ("Call to bat_send_cgact() failed");
1859 }
1860 app_bat_send_result_prim(0, NO_ADD_VAL);
1861 return 0;
1862 }
1863
1864
1865
1866 GLOBAL char *app_bat_send_cgpco(app_cmd_entry_t *cmd_entry_ptr, char *param1,
1867 char *param2, char *param3, core_func_t core_func)
1868 {
1869 T_BAT_return result = BAT_ERROR;
1870 T_BAT_client clnt_hndl = BAT_CONTROL_CHANNEL;
1871 T_BAT_cmd_set_percent_cgpco my_set_per_cgpco ;
1872 T_BAT_cmd_send my_bat_cmd_send;
1873 T_CLIENT_HANDLE_ERROR err;
1874 CHAR User[10] ;
1875 CHAR Pass[10] ;
1876 USHORT pco_len = 100;
1877 UBYTE pco_array[100];
1878
1879 TRACE_FUNCTION("app_bat_send_cgpco()");
1880
1881 clnt_hndl = get_item(param1, 0, FALSE);
1882
1883 err = check_client_handle (clnt_hndl);
1884 if (err NEQ CLIENT_HANDLE_OK)
1885 {
1886 return (error_client_handle(err));
1887 }
1888
1889 memset(&my_set_per_cgpco , sizeof(my_set_per_cgpco), 0 );
1890 memset(pco_array , 0x00 , sizeof(pco_array));
1891 memset(User , 0x00 , sizeof(User)) ;
1892 memset(Pass , 0x00 , sizeof(Pass)) ;
1893
1894
1895 my_bat_cmd_send.ctrl_params = BAT_CMD_SET_PERCENT_CGPCO ;
1896 my_bat_cmd_send.params.ptr_set_percent_cgpco= &my_set_per_cgpco ;
1897 /* full functionality mode*/
1898 if(param2!=NULL)
1899 strcpy(User ,param2);
1900 else
1901 strcpy(User ,"WAP");
1902
1903 if(param3!=NULL)
1904 strcpy(Pass ,param3);
1905 else
1906 strcpy(Pass ,"WAP");
1907
1908 my_set_per_cgpco.cid = (T_BAT_pdp_cid)1 ;
1909 my_set_per_cgpco.format = (T_BAT_percent_cgpco_format) 1 ; /* ASCII mode */
1910 my_set_per_cgpco.mode = (T_BAT_percent_cgpco_mode) 0 ; /* Set parameter command */
1911
1912 my_set_per_cgpco.v_pco = 1 ;
1913 my_set_per_cgpco.c_pco = 0 ;
1914
1915 #if 0
1916 ret = utl_create_pco (pco_array, &pco_len,
1917 ACI_PCO_CONTENTMASK_AUTH |
1918 ACI_PCO_CONTENTMASK_DNS1 |
1919 ACI_PCO_CONTENTMASK_DNS2,
1920 ACI_PCO_CONFIG_PROT_PPP,
1921 ACI_PCO_AUTH_PROT_PAP, (UBYTE*)&User, (UBYTE*)&Pass, dns_adr1, dns_adr2);
1922
1923 ret = utl_create_pco (pco_array, &pco_len,
1924 0x00000001 |
1925 0x00000002 |
1926 0x00000004,
1927 0,
1928 0xc023, (UBYTE*)&User, (UBYTE*)&Pass, dns_adr1, dns_adr2);
1929
1930 #endif
1931
1932 strcpy((char *)pco_array, "PAP,WAP,WAP,10.2.3.4,10.0.0.10" ) ;
1933
1934 TRACE_EVENT_P2("=======Input PCO common string is ===%s==== len is %d", pco_array, pco_len) ;
1935
1936 memcpy(&my_set_per_cgpco.pco, &pco_array, pco_len ) ;
1937 my_set_per_cgpco.c_pco = pco_len ;
1938
1939 result = bat_send (clnt_hndl, &my_bat_cmd_send);
1940
1941 if(result NEQ BAT_OK)
1942 {
1943 app_bat_send_result_prim(1, NO_ADD_VAL);
1944 return ("Call to bat_send_cgpco() failed");
1945 }
1946 app_bat_send_result_prim(0, NO_ADD_VAL);
1947 return 0;
1948 }
1949
1950 GLOBAL char *app_bat_send_q_cgpco(app_cmd_entry_t *cmd_entry_ptr, char *param1,
1951 char *param2, char *param3, core_func_t core_func)
1952 {
1953 T_BAT_return result = BAT_ERROR;
1954 T_BAT_client clnt_hndl = BAT_CONTROL_CHANNEL;
1955 T_BAT_cmd_set_percent_cgpco my_set_per_cgpco ;
1956 T_BAT_cmd_send my_bat_cmd_send;
1957 T_CLIENT_HANDLE_ERROR err;
1958 USHORT pco_len = 100;
1959 UBYTE pco_array[100];
1960
1961
1962 TRACE_FUNCTION("app_bat_send_q_cgpco()");
1963
1964 clnt_hndl = get_item(param1, 0, FALSE);
1965
1966 err = check_client_handle (clnt_hndl);
1967 if (err NEQ CLIENT_HANDLE_OK)
1968 {
1969 return (error_client_handle(err));
1970 }
1971
1972 memset(&my_set_per_cgpco , sizeof(my_set_per_cgpco), 0 );
1973 memset(pco_array , 0x00 , sizeof(pco_array));
1974
1975
1976 my_bat_cmd_send.ctrl_params = (T_BAT_ctrl_params) BAT_CMD_SET_PERCENT_CGPCO ;
1977 my_bat_cmd_send.params.ptr_set_percent_cgpco= &my_set_per_cgpco ;
1978 /* full functionality mode*/
1979
1980 my_set_per_cgpco.cid = (T_BAT_pdp_cid) 1 ;
1981 my_set_per_cgpco.format = (T_BAT_percent_cgpco_format) 1 ; /* ASCII mode */
1982 my_set_per_cgpco.mode = (T_BAT_percent_cgpco_mode) 1 ; /* Query parameter command */
1983
1984 my_set_per_cgpco.v_pco = 1 ;
1985 my_set_per_cgpco.c_pco = 0 ;
1986
1987
1988 TRACE_EVENT_P2("pco_array = %s, len = %d", pco_array, pco_len) ;
1989
1990 memcpy(&my_set_per_cgpco.pco, &pco_array, pco_len ) ;
1991 my_set_per_cgpco.c_pco = pco_len ;
1992
1993 result = bat_send (clnt_hndl, &my_bat_cmd_send);
1994
1995 if(result NEQ BAT_OK)
1996 {
1997 app_bat_send_result_prim(1, NO_ADD_VAL);
1998 return ("Call to bat_send_cgpco() failed");
1999 }
2000 app_bat_send_result_prim(0, NO_ADD_VAL);
2001 return 0;
2002 }
2003
2004
2005 GLOBAL char *app_bat_send_cgdcont(app_cmd_entry_t *cmd_entry_ptr, char *param1,
2006 char *param2, char *param3, core_func_t core_func)
2007 {
2008
2009 T_BAT_return result = BAT_ERROR;
2010 T_BAT_client clnt_hndl = BAT_CONTROL_CHANNEL;
2011 T_BAT_cmd_set_plus_cgdcont my_set_plus_cgdcont ;
2012 T_BAT_cmd_send my_bat_cmd_send;
2013 T_CLIENT_HANDLE_ERROR err;
2014
2015 TRACE_FUNCTION("app_bat_send_cgdcont()");
2016
2017 clnt_hndl = get_item(param1, 0, FALSE);
2018
2019 err = check_client_handle (clnt_hndl);
2020 if (err NEQ CLIENT_HANDLE_OK)
2021 {
2022 return (error_client_handle(err));
2023 }
2024
2025 memset(&my_set_plus_cgdcont , sizeof(my_set_plus_cgdcont), 0 );
2026 my_bat_cmd_send.ctrl_params = BAT_CMD_SET_PLUS_CGDCONT ;
2027 my_bat_cmd_send.params.ptr_set_plus_cgdcont = &my_set_plus_cgdcont ;
2028 /* full functionality mode*/
2029 if(param2!=NULL )
2030 {
2031 memcpy( my_set_plus_cgdcont.apn , param2, strlen(param2) );
2032 my_set_plus_cgdcont.c_apn = strlen(param2) ;
2033 my_set_plus_cgdcont.v_apn = 1 ;
2034 my_set_plus_cgdcont.pdp_type = BAT_PDP_TYPE_IPV4 ; //PDP_T_IP ;
2035
2036 my_set_plus_cgdcont.cid =(T_BAT_pdp_cid) 1 ;
2037 my_set_plus_cgdcont.v_pdp_addr= 1 ;
2038 my_set_plus_cgdcont.c_pdp_addr= 16 ;
2039 memset(my_set_plus_cgdcont.pdp_addr , '\0' , 16 ) ;
2040 my_set_plus_cgdcont.d_comp = (T_BAT_plus_cgdcont_d_comp) -1 ;
2041 my_set_plus_cgdcont.h_comp = (T_BAT_plus_cgdcont_h_comp) -1 ;
2042
2043
2044 }
2045 else
2046 {
2047 strcpy( (char *)my_set_plus_cgdcont.apn , "CMWAP" );
2048 my_set_plus_cgdcont.c_apn = strlen("CMWAP") ;
2049
2050 my_set_plus_cgdcont.v_apn = 1 ;
2051 my_set_plus_cgdcont.pdp_type = BAT_PDP_TYPE_IPV4; //PDP_T_IP ;
2052 my_set_plus_cgdcont.cid = (T_BAT_pdp_cid) 1 ;
2053
2054 my_set_plus_cgdcont.v_pdp_addr= 1 ;
2055 my_set_plus_cgdcont.c_pdp_addr= 16 ;
2056 memset(my_set_plus_cgdcont.pdp_addr ,'\0' , 16 ) ;
2057 my_set_plus_cgdcont.d_comp = (T_BAT_plus_cgdcont_d_comp) -1 ;
2058 my_set_plus_cgdcont.h_comp = (T_BAT_plus_cgdcont_h_comp) -1 ;
2059 }
2060
2061 result = bat_send (clnt_hndl, &my_bat_cmd_send);
2062
2063 if(result NEQ BAT_OK)
2064 {
2065 app_bat_send_result_prim(1, NO_ADD_VAL);
2066 return ("Call to bat_send_cgdcont() failed");
2067 }
2068 app_bat_send_result_prim(0, NO_ADD_VAL);
2069 return 0;
2070 }
2071
2072
2073 GLOBAL char *app_bat_send_cfun (app_cmd_entry_t *cmd_entry_ptr, char *param1,
2074 char *param2, char *param3, core_func_t core_func)
2075 {
2076 T_BAT_return result = BAT_ERROR;
2077 T_BAT_client clnt_hndl = BAT_CONTROL_CHANNEL;
2078 T_BAT_cmd_set_plus_cfun my_set_plus_cfun;
2079 T_BAT_cmd_send my_bat_cmd_send;
2080 T_CLIENT_HANDLE_ERROR err;
2081
2082 TRACE_FUNCTION("app_bat_send_cfun()");
2083
2084 clnt_hndl = get_item(param1, 0, FALSE);
2085
2086 err = check_client_handle (clnt_hndl);
2087 if (err NEQ CLIENT_HANDLE_OK)
2088 {
2089 return (error_client_handle(err));
2090 }
2091
2092 memset(&my_set_plus_cfun, sizeof(my_set_plus_cfun), FALSE);
2093 my_bat_cmd_send.ctrl_params = BAT_CMD_SET_PLUS_CFUN;
2094 my_bat_cmd_send.params.ptr_set_plus_cfun = &my_set_plus_cfun;
2095 /* full functionality mode*/
2096 my_set_plus_cfun.fun = BAT_CFUN_FUN_FULL;
2097 /* Reset the MT before changing functionality level */
2098 my_set_plus_cfun.rst = BAT_CFUN_RST_NOT_PRESENT;
2099 result = bat_send (clnt_hndl, &my_bat_cmd_send);
2100
2101 if(result NEQ BAT_OK)
2102 {
2103 app_bat_send_result_prim(1, NO_ADD_VAL);
2104 return ("Call to bat_send_cfun() failed");
2105 }
2106 app_bat_send_result_prim(0, NO_ADD_VAL);
2107 return 0;
2108 }
2109
2110 #define MAX_SM_LEN 176
2111
2112 typedef struct /* data buffer for Short Messages */
2113 {
2114 UBYTE data[MAX_SM_LEN];
2115 UBYTE len;
2116 } T_ACI_SM_DATA;
2117
2118 LOCAL char *HexToGsm(char *cl, U8 *value)
2119 {
2120 int i;
2121 U8 character;
2122
2123 *value = 0;
2124
2125 /*
2126 * for both nibbles
2127 */
2128 for (i=0;i<2;i++)
2129 {
2130 /*
2131 * shift the result of the last loop
2132 */
2133 *value = (*value) << 4;
2134
2135 /*
2136 * Isolate next nibble in ASCII
2137 */
2138 character = toupper(*cl++);
2139
2140 /*
2141 * convert Nibble character to value
2142 */
2143 switch (character)
2144 {
2145 case 'A':
2146 case 'B':
2147 case 'C':
2148 case 'D':
2149 case 'E':
2150 case 'F':
2151 *value = *value + (character - 'A' + 10);
2152 break;
2153 default:
2154 /*
2155 * 0-9
2156 */
2157 *value = *value + (character - '0');
2158 break;
2159 }
2160 }
2161
2162 /*
2163 * return pointer to the rest of PDU
2164 */
2165 return cl;
2166 }
2167
2168 GLOBAL char *app_bat_send_cmgs (app_cmd_entry_t *cmd_entry_ptr, char *param1,
2169 char *param2, char *param3, core_func_t core_func)
2170 {
2171 T_BAT_return result = BAT_ERROR;
2172 T_BAT_client clnt_hndl = BAT_CONTROL_CHANNEL;
2173 T_BAT_cmd_set_plus_cmgs my_set_plus_cmgs;
2174 T_BAT_cmd_send my_bat_cmd_send;
2175 char *cl, cl_str[] = "079194710600403401000B811027513356F8000008C22015442FCFE9";
2176 T_ACI_SM_DATA pdu;
2177 T_CLIENT_HANDLE_ERROR err;
2178
2179 TRACE_FUNCTION("app_bat_send_cmgs()");
2180
2181 clnt_hndl = get_item(param1, 0, FALSE);
2182
2183 err = check_client_handle (clnt_hndl);
2184 if (err NEQ CLIENT_HANDLE_OK)
2185 {
2186 return (error_client_handle(err));
2187 }
2188
2189 pdu.len = 0;
2190 cl = cl_str;
2191
2192 {
2193 U8 i = 0;
2194 U8 sca_len = 0;
2195 U8 offset = 0;
2196 U8 pdu_message_octets_length = 0;
2197
2198 /*
2199 * Extract the length (excluding SCA octets) outto be parsed from
2200 * the input pointer cl
2201 */
2202
2203 SHORT length_of_pdu_message = strlen(cl)/2 - 8;
2204 TRACE_EVENT_P1("length_of_pdu_message: %d", length_of_pdu_message);
2205
2206 HexToGsm (cl, &sca_len);
2207
2208 /*
2209 calculation of the real length of PDU string
2210 The first octet in the input is an indicator of the length of the SMSC information supplied.
2211 And this Octet and the SMSC content do not count in the real length of PDU string.
2212 so here, the length of the input needs to minus 2 + sca_len*2 and then divide 2.
2213 */
2214 pdu_message_octets_length = (strlen(cl)-2-sca_len*2)/2;
2215 TRACE_EVENT_P1("pdu_message_octets_length: %d", pdu_message_octets_length);
2216
2217 pdu.len = length_of_pdu_message + sca_len + 1;
2218 TRACE_EVENT_P1("pdu.len: %d", pdu.len);
2219
2220 for (i = offset; i < pdu.len AND *cl NEQ '\0' AND i < MAX_SM_LEN; i++)
2221 {
2222 cl = HexToGsm(cl, &pdu.data[i]);
2223 }
2224 }
2225 memset(&my_set_plus_cmgs, sizeof(my_set_plus_cmgs), 0);
2226 my_bat_cmd_send.ctrl_params = BAT_CMD_SET_PLUS_CMGS;
2227 my_bat_cmd_send.params.ptr_set_plus_cmgs = &my_set_plus_cmgs;
2228 memcpy(my_set_plus_cmgs.pdu, pdu.data, pdu.len);
2229 my_set_plus_cmgs.c_pdu = pdu.len; /* total length */
2230 my_set_plus_cmgs.length = my_set_plus_cmgs.c_pdu; /* length without SCA */
2231
2232 result = bat_send (clnt_hndl, &my_bat_cmd_send);
2233
2234 if(result NEQ BAT_OK)
2235 {
2236 app_bat_send_result_prim(1, NO_ADD_VAL);
2237 return ("Call to bat_send_cmgs() failed");
2238 }
2239 app_bat_send_result_prim(0, NO_ADD_VAL);
2240 return 0;
2241 }
2242
2243
2244 GLOBAL char *app_bat_send_cmgl (app_cmd_entry_t *cmd_entry_ptr, char *param1,
2245 char *param2, char *param3, core_func_t core_func)
2246 {
2247 T_BAT_return result = BAT_ERROR;
2248 T_BAT_client clnt_hndl = BAT_CONTROL_CHANNEL;
2249 T_BAT_cmd_set_plus_cmgl my_set_plus_cmgl;
2250 T_BAT_cmd_send my_bat_cmd_send;
2251 T_CLIENT_HANDLE_ERROR err;
2252
2253 TRACE_FUNCTION("app_bat_send_cmgs()");
2254
2255 clnt_hndl = get_item(param1, 0, FALSE);
2256
2257 err = check_client_handle (clnt_hndl);
2258 if (err NEQ CLIENT_HANDLE_OK)
2259 {
2260 return (error_client_handle(err));
2261 }
2262
2263 if( param2 EQ NULL)
2264 {
2265 my_set_plus_cmgl.stat = BAT_CMGL_STAT_ALL;
2266 }
2267 else
2268 {
2269 if (strcmp(param2, "ALL") EQ 0)
2270 {
2271 my_set_plus_cmgl.stat = BAT_CMGL_STAT_ALL;
2272 }
2273 if (strcmp(param2, "SENT") EQ 0)
2274 {
2275 my_set_plus_cmgl.stat = BAT_CMGL_STAT_STO_SEND;
2276 }
2277 if (strcmp(param2, "UNSENT") EQ 0)
2278 {
2279 my_set_plus_cmgl.stat = BAT_CMGL_STAT_STO_UNSENT;
2280 }
2281 if (strcmp(param2, "READ") EQ 0)
2282 {
2283 my_set_plus_cmgl.stat = BAT_CMGL_STAT_REC_READ;
2284 }
2285 if (strcmp(param2, "UNREAD") EQ 0)
2286 {
2287 my_set_plus_cmgl.stat = BAT_CMGL_STAT_REC_UNREAD;
2288 }
2289 }
2290
2291 my_bat_cmd_send.ctrl_params = BAT_CMD_SET_PLUS_CMGL;
2292 my_bat_cmd_send.params.ptr_set_plus_cmgl = &my_set_plus_cmgl;
2293
2294 result = bat_send (clnt_hndl, &my_bat_cmd_send);
2295
2296 if(result NEQ BAT_OK)
2297 {
2298 app_bat_send_result_prim(1, NO_ADD_VAL);
2299 return ("Call to bat_send_cmgl() failed");
2300 }
2301 app_bat_send_result_prim(0, NO_ADD_VAL);
2302 return 0;
2303
2304 }
2305
2306
2307 GLOBAL char *app_bat_send_cops (app_cmd_entry_t *cmd_entry_ptr, char *param1,
2308 char *param2, char *param3, core_func_t core_func)
2309 {
2310 T_BAT_return result = BAT_ERROR;
2311 T_BAT_client clnt_hndl = BAT_CONTROL_CHANNEL;
2312 T_BAT_cmd_set_plus_cops my_set_plus_cops;
2313 T_BAT_cmd_send my_bat_cmd_send;
2314 T_CLIENT_HANDLE_ERROR err;
2315
2316 TRACE_FUNCTION("app_bat_send_cops()");
2317
2318 clnt_hndl = get_item(param1, 0, FALSE);
2319
2320 err = check_client_handle (clnt_hndl);
2321 if (err NEQ CLIENT_HANDLE_OK)
2322 {
2323 return (error_client_handle(err));
2324 }
2325
2326 memset(&my_set_plus_cops, sizeof(my_set_plus_cops), FALSE);
2327 my_bat_cmd_send.ctrl_params = BAT_CMD_SET_PLUS_COPS;
2328 my_bat_cmd_send.params.ptr_set_plus_cops = &my_set_plus_cops;
2329 my_set_plus_cops.mode = BAT_COPS_MODE_AUTO;
2330 my_set_plus_cops.format = BAT_COPS_FORMAT_NOT_PRESENT;
2331 my_set_plus_cops.v_oper = FALSE;
2332 my_set_plus_cops.c_oper = 0;
2333
2334 result = bat_send (clnt_hndl, &my_bat_cmd_send);
2335
2336 if(result NEQ BAT_OK)
2337 {
2338 app_bat_send_result_prim(1, NO_ADD_VAL);
2339 return ("Call to bat_send_cops() failed");
2340 }
2341
2342 app_bat_send_result_prim(0, NO_ADD_VAL);
2343 return 0;
2344 }
2345
2346 GLOBAL char *app_bat_send_cpin (app_cmd_entry_t *cmd_entry_ptr, char *param1,
2347 char *param2, char *param3, core_func_t core_func)
2348 {
2349 T_BAT_return result = BAT_ERROR;
2350 T_BAT_client clnt_hndl = BAT_CONTROL_CHANNEL;
2351 T_BAT_cmd_set_plus_cpin my_cmd_plus_cpin;
2352 T_BAT_cmd_send my_bat_cmd_send;
2353 T_CLIENT_HANDLE_ERROR err;
2354 char number[] = "1236";
2355
2356 clnt_hndl = get_item(param1, 0, TRUE);
2357
2358 err = check_client_handle (clnt_hndl);
2359 if (err NEQ CLIENT_HANDLE_OK)
2360 {
2361 return (error_client_handle(err));
2362 }
2363
2364 memset(&my_cmd_plus_cpin, sizeof(my_cmd_plus_cpin), FALSE);
2365 my_bat_cmd_send.ctrl_params = BAT_CMD_SET_PLUS_CPIN;
2366 my_bat_cmd_send.params.ptr_set_plus_cpin = &my_cmd_plus_cpin;
2367
2368 if (param2)
2369 {
2370 strcpy((char *)&(my_cmd_plus_cpin.pin), (const char *)param2);
2371 my_cmd_plus_cpin.c_pin = strlen(param2);
2372 }
2373 else
2374 {
2375 strcpy((char *)&(my_cmd_plus_cpin.pin), (const char *)number);
2376 my_cmd_plus_cpin.c_pin = strlen(number);
2377 }
2378
2379 if (param3)
2380 {
2381 strcpy((char *)&(my_cmd_plus_cpin.newpin), (const char *)param3);
2382 my_cmd_plus_cpin.c_newpin = strlen(param3);
2383 my_cmd_plus_cpin.v_newpin = 1;
2384 }
2385
2386 TRACE_EVENT_P1("app_bat_send_cpin(): PIN = %s", my_cmd_plus_cpin.pin);
2387 result = bat_send (clnt_hndl, &my_bat_cmd_send);
2388
2389 if(result NEQ BAT_OK)
2390 {
2391 app_bat_send_result_prim(1, NO_ADD_VAL);
2392 return ("Call to bat_send_cpin() failed");
2393 }
2394 app_bat_send_result_prim(0, NO_ADD_VAL);
2395 return 0;
2396 }
2397
2398 GLOBAL char *app_bat_send_cnmi (app_cmd_entry_t *cmd_entry_ptr, char *param1,
2399 char *param2, char *param3, core_func_t core_func)
2400 {
2401 T_BAT_return result = BAT_ERROR;
2402 T_BAT_client clnt_hndl = BAT_CONTROL_CHANNEL;
2403 T_BAT_cmd_set_plus_cnmi my_cmd_plus_cnmi;
2404 T_BAT_cmd_send my_bat_cmd_send;
2405 T_CLIENT_HANDLE_ERROR err;
2406 SHORT mt = BAT_CNMI_MT_NOT_PRESENT;
2407 SHORT bm = BAT_CNMI_BM_NOT_PRESENT;
2408 SHORT ds = BAT_CNMI_DS_NOT_PRESENT;
2409
2410 clnt_hndl = get_item(param1, 0, TRUE);
2411
2412 err = check_client_handle (clnt_hndl);
2413 if (err NEQ CLIENT_HANDLE_OK)
2414 {
2415 return (error_client_handle(err));
2416 }
2417
2418 memset(&my_cmd_plus_cnmi, sizeof(my_cmd_plus_cnmi), FALSE);
2419 my_bat_cmd_send.ctrl_params = BAT_CMD_SET_PLUS_CNMI;
2420 my_bat_cmd_send.params.ptr_set_plus_cnmi = &my_cmd_plus_cnmi;
2421
2422 /*
2423 * +CNMI has up to three parameters. These may as well all be
2424 * delivered in "param2", separated by commas. We can extract them
2425 * using the ATI function "parse()". The extraction is done
2426 * not to elements of the BAT message directly, but via intermediate local
2427 * variables. This is to avoid any issues with variable sizes.
2428 */
2429 TRACE_EVENT_P1("app_bat_send_cnmi(): param2 = :%s:", param2);
2430 if (!parse(param2,"ddd", &mt, &bm, &ds))
2431 {
2432 app_bat_send_result_prim(1,NO_ADD_VAL);
2433 return("Failed to parse +CNMI");
2434 }
2435
2436 /*
2437 * Now copy the data into the BAT message structure.
2438 */
2439 my_cmd_plus_cnmi.mt = (T_BAT_VAL_plus_cnmi_mt)mt;
2440 my_cmd_plus_cnmi.bm = (T_BAT_VAL_plus_cnmi_bm)bm;
2441 my_cmd_plus_cnmi.ds = (T_BAT_VAL_plus_cnmi_ds)ds;
2442
2443 TRACE_EVENT_P3("app_bat_send_cnmi(): mt = %d bm = %d ds = %d", my_cmd_plus_cnmi.mt,
2444 my_cmd_plus_cnmi.bm, my_cmd_plus_cnmi.ds);
2445 result = bat_send (clnt_hndl, &my_bat_cmd_send);
2446
2447 if(result NEQ BAT_OK)
2448 {
2449 app_bat_send_result_prim(1, NO_ADD_VAL);
2450 return ("Call to bat_send_cnmi() failed");
2451 }
2452 app_bat_send_result_prim(0, NO_ADD_VAL);
2453 return 0;
2454 }
2455
2456
2457 GLOBAL char *app_bat_send_atd (app_cmd_entry_t *cmd_entry_ptr, char *param1,
2458 char *param2, char *param3, core_func_t core_func)
2459 {
2460 T_BAT_return result = BAT_ERROR;
2461 T_BAT_client clnt_hndl = BAT_CONTROL_CHANNEL;
2462 T_BAT_cmd_at_d my_cmd_atd;
2463 T_BAT_cmd_send my_bat_cmd_send;
2464 char number[] = "03039831270;";
2465 T_CLIENT_HANDLE_ERROR err;
2466
2467 TRACE_FUNCTION("app_bat_send_atd()");
2468
2469 clnt_hndl = get_item(param1, 0, FALSE);
2470
2471 err = check_client_handle (clnt_hndl);
2472 if (err NEQ CLIENT_HANDLE_OK)
2473 {
2474 return (error_client_handle(err));
2475 }
2476
2477 memset(&my_cmd_atd, sizeof(my_cmd_atd), FALSE);
2478 my_bat_cmd_send.ctrl_params = BAT_CMD_AT_D;
2479 my_bat_cmd_send.params.ptr_at_d = &my_cmd_atd;
2480
2481 if (param2)
2482 {
2483 strcpy((char *)&(my_cmd_atd.dial_string), (const char *)param2);
2484 my_cmd_atd.c_dial_string = strlen(param2);
2485 }
2486 else
2487 {
2488 strcpy((char *)&(my_cmd_atd.dial_string), (const char *)number);
2489 my_cmd_atd.c_dial_string = strlen(number);
2490 }
2491
2492 TRACE_EVENT_P1("app_bat_send_atd(): call %s", my_cmd_atd.dial_string);
2493 result = bat_send (clnt_hndl, &my_bat_cmd_send);
2494
2495 if(result NEQ BAT_OK)
2496 {
2497 app_bat_send_result_prim(1, NO_ADD_VAL);
2498 return ("Call to bat_send_atd() failed");
2499 }
2500 app_bat_send_result_prim(0, NO_ADD_VAL);
2501 return 0;
2502 }
2503
2504
2505 GLOBAL char *app_bat_send_ata (app_cmd_entry_t *cmd_entry_ptr, char *param1,
2506 char *param2, char *param3, core_func_t core_func)
2507 {
2508 T_BAT_return result = BAT_ERROR;
2509 T_BAT_client clnt_hndl = BAT_CONTROL_CHANNEL;
2510 T_BAT_cmd_send my_bat_cmd_send;
2511 T_BAT_no_parameter dummy;
2512 T_CLIENT_HANDLE_ERROR err;
2513
2514 TRACE_FUNCTION("app_bat_send_ata()");
2515
2516 clnt_hndl = get_item(param1, 0, FALSE);
2517
2518 err = check_client_handle (clnt_hndl);
2519 if (err NEQ CLIENT_HANDLE_OK)
2520 {
2521 return (error_client_handle(err));
2522 }
2523
2524 dummy.bat_dummy = 0xFF;
2525 my_bat_cmd_send.ctrl_params = BAT_CMD_AT_A;
2526 my_bat_cmd_send.params.ptr_at_a = &dummy;
2527 result = bat_send (clnt_hndl, &my_bat_cmd_send);
2528
2529 if(result NEQ BAT_OK)
2530 {
2531 app_bat_send_result_prim(1, NO_ADD_VAL);
2532 return ("Call to bat_send_ata() failed");
2533 }
2534 app_bat_send_result_prim(0, NO_ADD_VAL);
2535 return 0;
2536 }
2537
2538 GLOBAL char *app_bat_send_per_als (app_cmd_entry_t *cmd_entry_ptr, char *param1,
2539 char *param2, char *param3, core_func_t core_func)
2540 {
2541 T_BAT_return result = BAT_ERROR;
2542 T_BAT_client clnt_hndl = BAT_CONTROL_CHANNEL;
2543 T_BAT_cmd_send my_bat_cmd_send;
2544 T_BAT_cmd_set_percent_als my_set_per_als;
2545 T_BAT_no_parameter my_quer_per_als;
2546 int clnt_com = get_item(param2, 0, TRUE);
2547 T_CLIENT_HANDLE_ERROR err;
2548
2549 TRACE_FUNCTION("app_bat_send_per_als()");
2550
2551 clnt_hndl = get_item(param1, 0, FALSE);
2552
2553 err = check_client_handle (clnt_hndl);
2554 if (err NEQ CLIENT_HANDLE_OK)
2555 {
2556 return (error_client_handle(err));
2557 }
2558
2559 if(clnt_com EQ BAT_CMD_SET_PERCENT_ALS) /* AT%ALS = 0 or 1 */
2560 {
2561 memset(&my_set_per_als, sizeof(my_set_per_als), FALSE);
2562 my_bat_cmd_send.ctrl_params = BAT_CMD_SET_PERCENT_ALS;
2563 my_bat_cmd_send.params.ptr_set_percent_als = &my_set_per_als;
2564 my_set_per_als.mode = BAT_P_ALS_MOD_SPEECH;
2565 }
2566 else /* AT%ALS? */
2567 {
2568 my_bat_cmd_send.ctrl_params = BAT_CMD_QUE_PERCENT_ALS;
2569 my_bat_cmd_send.params.ptr_que_percent_als = &my_quer_per_als;
2570 }
2571
2572 result = bat_send (clnt_hndl, &my_bat_cmd_send);
2573
2574 if(result NEQ BAT_OK)
2575 {
2576 app_bat_send_result_prim(1, NO_ADD_VAL);
2577 return ("Call to bat_send_per_als() failed");
2578 }
2579 app_bat_send_result_prim(0, NO_ADD_VAL);
2580 return 0;
2581 }
2582
2583 GLOBAL char *app_bat_send_ath (app_cmd_entry_t *cmd_entry_ptr, char *param1,
2584 char *param2, char *param3, core_func_t core_func)
2585 {
2586 T_BAT_return result = BAT_ERROR;
2587 T_BAT_client clnt_hndl = BAT_CONTROL_CHANNEL;
2588 T_BAT_cmd_send my_bat_cmd_send;
2589 T_BAT_no_parameter dummy;
2590 T_CLIENT_HANDLE_ERROR err;
2591
2592 TRACE_FUNCTION("app_bat_send_ath()");
2593
2594 clnt_hndl = get_item(param1, 0, FALSE);
2595
2596 err = check_client_handle (clnt_hndl);
2597 if (err NEQ CLIENT_HANDLE_OK)
2598 {
2599 return (error_client_handle(err));
2600 }
2601
2602 dummy.bat_dummy = 0xFF;
2603
2604 my_bat_cmd_send.ctrl_params = BAT_CMD_AT_H;
2605 my_bat_cmd_send.params.ptr_at_h = &dummy;
2606 result = bat_send (clnt_hndl, &my_bat_cmd_send);
2607
2608 if(result NEQ BAT_OK)
2609 {
2610 app_bat_send_result_prim(1, NO_ADD_VAL);
2611 return ("Call to bat_send_ath() failed");
2612 }
2613 app_bat_send_result_prim(0, NO_ADD_VAL);
2614
2615 return 0;
2616 }
2617
2618
2619 GLOBAL char *app_bat_send_q_cscb(app_cmd_entry_t *cmd_entry_ptr, char *param1,
2620 char *param2, char *param3, core_func_t core_func)
2621 {
2622 T_BAT_return result = BAT_ERROR;
2623 T_BAT_client clnt_hndl = BAT_CONTROL_CHANNEL;
2624 T_BAT_cmd_send lbatSend;
2625 T_BAT_no_parameter lbatDummy;
2626 T_CLIENT_HANDLE_ERROR err;
2627
2628 TRACE_FUNCTION("app_bat_send_q_cscb()");
2629
2630 clnt_hndl = get_item(param1, 0, FALSE);
2631
2632 err = check_client_handle (clnt_hndl);
2633 if (err NEQ CLIENT_HANDLE_OK)
2634 {
2635 return (error_client_handle(err));
2636 }
2637
2638 lbatSend.ctrl_params = BAT_CMD_QUE_PLUS_CSCB;
2639 lbatDummy.bat_dummy = 0xFF;
2640 lbatSend.params.ptr_que_plus_cscb = &lbatDummy;
2641
2642 result = bat_send (clnt_hndl, &lbatSend);
2643
2644 if(result NEQ BAT_OK)
2645 {
2646 TRACE_ERROR("Call to app_bat_send_q_cscb() failed");
2647 return 0;
2648 }
2649 return 0;
2650 }
2651
2652 GLOBAL char *app_bat_send_q_cpinf(app_cmd_entry_t *cmd_entry_ptr, char *param1,
2653 char *param2, char *param3, core_func_t core_func)
2654 {
2655 T_BAT_return result = BAT_ERROR;
2656 T_BAT_client clnt_hndl = BAT_CONTROL_CHANNEL;
2657 T_BAT_cmd_send lbatSend;
2658 T_BAT_no_parameter lbatDummy;
2659 T_CLIENT_HANDLE_ERROR err;
2660
2661 TRACE_FUNCTION("bat_send_q_cpinf()");
2662
2663 clnt_hndl = get_item(param1, 0, FALSE);
2664
2665 err = check_client_handle (clnt_hndl);
2666 if (err NEQ CLIENT_HANDLE_OK)
2667 {
2668 return (error_client_handle(err));
2669 }
2670
2671 lbatSend.ctrl_params = BAT_CMD_QUE_PERCENT_CPINF;
2672 lbatDummy.bat_dummy = 0xFF;
2673 lbatSend.params.ptr_que_percent_cpinf = &lbatDummy;
2674
2675 result = bat_send (clnt_hndl, &lbatSend);
2676
2677 if(result NEQ BAT_OK)
2678 {
2679 TRACE_ERROR("Call to bat_send_q_cpinf() failed");
2680 return 0;
2681 }
2682 return 0;
2683 }
2684
2685
2686 GLOBAL char *app_bat_send_q_cpol(app_cmd_entry_t *cmd_entry_ptr, char *param1,
2687 char *param2, char *param3, core_func_t core_func)
2688 {
2689 T_BAT_return result = BAT_ERROR;
2690 T_BAT_client clnt_hndl = BAT_CONTROL_CHANNEL;
2691 T_BAT_cmd_send lbatSend;
2692 T_BAT_no_parameter lbatDummy;
2693 T_CLIENT_HANDLE_ERROR err;
2694
2695 TRACE_FUNCTION("bat_send_q_cpol()");
2696
2697 clnt_hndl = get_item(param1, 0, FALSE);
2698
2699 err = check_client_handle (clnt_hndl);
2700 if (err NEQ CLIENT_HANDLE_OK)
2701 {
2702 return (error_client_handle(err));
2703 }
2704
2705 lbatSend.ctrl_params = BAT_CMD_QUE_PLUS_CPOL;
2706 lbatDummy.bat_dummy = 0xFF;
2707 lbatSend.params.ptr_que_plus_cpol = &lbatDummy;
2708
2709 result = bat_send (clnt_hndl, &lbatSend);
2710
2711 if(result NEQ BAT_OK)
2712 {
2713 TRACE_ERROR("Call to app_bat_send_q_cpinf() failed");
2714 return 0;
2715 }
2716 return 0;
2717 }
2718
2719 GLOBAL char *app_bat_send_t_cpol(app_cmd_entry_t *cmd_entry_ptr, char *param1,
2720 char *param2, char *param3, core_func_t core_func)
2721 {
2722 T_BAT_return result = BAT_ERROR;
2723 T_BAT_client clnt_hndl = BAT_CONTROL_CHANNEL;
2724 T_BAT_cmd_send lbatSend;
2725 T_BAT_no_parameter lbatDummy;
2726 T_CLIENT_HANDLE_ERROR err;
2727
2728 TRACE_FUNCTION("bat_send_t_cpol()");
2729
2730 clnt_hndl = get_item(param1, 0, FALSE);
2731
2732 err = check_client_handle (clnt_hndl);
2733 if (err NEQ CLIENT_HANDLE_OK)
2734 {
2735 return (error_client_handle(err));
2736 }
2737
2738 lbatSend.ctrl_params = BAT_CMD_TST_PLUS_CPOL;
2739 lbatDummy.bat_dummy = 0xFF;
2740 lbatSend.params.ptr_tst_plus_cpol = &lbatDummy;
2741
2742 result = bat_send (clnt_hndl, &lbatSend);
2743
2744 if(result NEQ BAT_OK)
2745 {
2746 TRACE_ERROR("Call to app_bat_send_t_cpinf() failed");
2747 return 0;
2748 }
2749 return 0;
2750 }
2751
2752
2753
2754
2755
2756 GLOBAL char *app_bat_quer_set_clck (app_cmd_entry_t *cmd_entry_ptr, char *param1,
2757 char *param2, char *param3, core_func_t core_func)
2758 {
2759 /* bat_clck_query 0 0 --> unlock FDN, 0 1 --> lock FDN, 0 2 --> query status FDN */
2760 T_BAT_return result = BAT_ERROR;
2761 T_BAT_client clnt_hndl = BAT_CONTROL_CHANNEL;
2762 T_BAT_cmd_set_plus_clck my_set_plus_clck;
2763 T_BAT_cmd_send my_bat_cmd_send;
2764 int mode = BAT_CLCK_MODE_QUERY;
2765 char passwd[] = "0000";
2766 T_CLIENT_HANDLE_ERROR err;
2767
2768 TRACE_FUNCTION("app_bat_quer_set_clck()");
2769
2770 clnt_hndl = get_item(param1, 0, FALSE);
2771
2772 err = check_client_handle (clnt_hndl);
2773 if (err NEQ CLIENT_HANDLE_OK)
2774 {
2775 return (error_client_handle(err));
2776 }
2777
2778 mode = get_item(param2, 0, FALSE);
2779
2780 memset(&my_set_plus_clck, sizeof(my_set_plus_clck), FALSE);
2781 my_bat_cmd_send.ctrl_params = BAT_CMD_SET_PLUS_CLCK;
2782 my_bat_cmd_send.params.ptr_set_plus_clck= &my_set_plus_clck;
2783 my_set_plus_clck.fac = BAT_CLCK_FAC_FD;
2784 my_set_plus_clck.bearer_class = BAT_CLASS_NOT_PRESENT;
2785
2786 if(mode NEQ BAT_CLCK_MODE_QUERY)
2787 {
2788 memset(&my_set_plus_clck.passwd, sizeof(my_set_plus_clck.passwd), 0);
2789 strcpy((char *)&(my_set_plus_clck.passwd), (const char *)passwd);
2790 my_set_plus_clck.c_passwd = strlen(passwd);
2791 my_set_plus_clck.v_passwd = 1;
2792 }
2793 my_set_plus_clck.mode =(T_BAT_plus_clck_mode) mode;
2794
2795 result = bat_send (clnt_hndl, &my_bat_cmd_send);
2796
2797 if(result NEQ BAT_OK)
2798 {
2799 app_bat_send_result_prim(1, NO_ADD_VAL);
2800 return ("Call to app_bat_send_cops() failed");
2801 }
2802 app_bat_send_result_prim(0, NO_ADD_VAL);
2803 return 0;
2804 }
2805
2806
2807
2808 GLOBAL char *app_bat_ctrl(app_cmd_entry_t *cmd_entry_ptr,
2809 char *param1, char *param2, char *param3, core_func_t core_func)
2810 {
2811 T_BAT_return result = BAT_ERROR;
2812 T_BAT_client clnt_hndl = BAT_INVALID_CLIENT_HANDLE;
2813 T_BAT_ctrl app_bat_ctrl;
2814 app_bat_ctrl.event = BAT_ABORT;
2815
2816 clnt_hndl = get_item(param1, 0, FALSE);
2817
2818 if(param2 && !strcmp(string_to_lower(param2), "READY"))
2819 app_bat_ctrl.event = BAT_APP_READY_RESOURCE;
2820
2821
2822 result = bat_ctrl (clnt_hndl, &app_bat_ctrl);
2823
2824 if(result != BAT_OK)
2825 {
2826 app_bat_send_result_prim(1, NO_ADD_VAL);
2827 return ("Call to bat_ctrl() failed");
2828 }
2829 app_bat_send_result_prim(0, NO_ADD_VAL);
2830 return 0;
2831 }
2832
2833 GLOBAL char *app_bat_receive_data_cb(app_cmd_entry_t *cmd_entry_ptr,
2834 char *param1, char *param2, char *param3, core_func_t core_func)
2835 {
2836 T_BAT_return result = BAT_ERROR;
2837 T_GDD_CON_HANDLE con_hndl = 0xffff;
2838 char *buf = "BAT_LIB_TEST";
2839
2840 TRACE_FUNCTION("app_bat_receive_data_cb()") ;
2841 con_hndl = (T_GDD_CON_HANDLE) get_item(param1, 0x0100, FALSE);
2842
2843 result = (T_BAT_return) bat_gdd_receive_data_cb(con_hndl, (T_GDD_BUF *)buf);
2844
2845 if(result != BAT_OK)
2846 {
2847 app_bat_send_result_prim(1, NO_ADD_VAL);
2848 return ("Call to app_bat_receive_data_cb() failed");
2849 }
2850 app_bat_send_result_prim(0, NO_ADD_VAL);
2851 return 0;
2852 }
2853
2854 GLOBAL char *app_bat_signal_cb(app_cmd_entry_t *cmd_entry_ptr,
2855 char *param1, char *param2, char *param3, core_func_t core_func)
2856 {
2857 T_GDD_CON_HANDLE con_hndl = 0xffff;
2858 T_GDD_SIGNAL gdd_sig = {(T_GDD_SIGTYPE)0};
2859
2860 con_hndl = get_item(param1, 0x0100, FALSE);
2861 gdd_sig.sig = (T_GDD_SIGTYPE) get_item(param2, 1, FALSE);
2862
2863 bat_gdd_signal_cb(con_hndl, gdd_sig);
2864 app_bat_send_result_prim(0, NO_ADD_VAL);
2865
2866 return 0;
2867 }
2868
2869
2870 /*****************************************************************************************
2871 *
2872 * This test case tests the complete use scenario: initializing the instances, opening
2873 * different clients, sending cmd, closing the clients, deiniting the instances. Then repeat
2874 * this once more.
2875 *
2876 *****************************************************************************************/
2877
2878 LOCAL void free_mem(void *mem1, void *mem2, void *mem3, void *mem4, void *mem5)
2879 {
2880 if (mem1 NEQ NULL)
2881 MFREE(mem1);
2882 if (mem2 NEQ NULL)
2883 MFREE(mem2);
2884 if (mem3 NEQ NULL)
2885 MFREE(mem3);
2886 if (mem4 NEQ NULL)
2887 MFREE(mem4);
2888 if (mem5 NEQ NULL)
2889 MFREE(mem5);
2890 return;
2891 }
2892
2893 GLOBAL char *app_bat_complete_test(app_cmd_entry_t *cmd_entry_ptr,
2894 char *param1, char *param2, char *param3, core_func_t core_func)
2895 {
2896 T_BAT_return result = BAT_ERROR;
2897 void *mem1 = NULL;
2898 void *mem2 = NULL;
2899 int inst_num = 2;
2900 int clnt_num = 2;
2901 int i;
2902
2903 T_BAT_instance inst_hndl = BAT_INVALID_INSTANCE_HANDLE;
2904 T_BAT_client clnt_hndl = BAT_INVALID_CLIENT_HANDLE;
2905 T_BAT_client client = BAT_INVALID_CLIENT_HANDLE;
2906
2907 T_BAT_cmd_set_plus_cfun my_set_plus_cfun;
2908 T_BAT_cmd_send my_bat_cmd_send;
2909
2910 TRACE_FUNCTION("app_bat_complete_test()");
2911 for (i = 0; i < 2; i ++)
2912 {
2913 MALLOC(mem1, BAT_INSTANCE_HEADER_SIZE*inst_num);
2914 MALLOC(mem2, (clnt_num*BAT_CLIENT_SIZE + BAT_INSTANCE_SIZE));
2915
2916
2917 TRACE_EVENT_P1 ("calling bat_init() the %d th time", i);
2918
2919 if (bat_init(mem1, (U8)inst_num) NEQ BAT_OK)
2920 {
2921 TRACE_ERROR("ERROR: Call to bat_init() failed");
2922 free_mem(mem1,mem2,NULL,NULL,NULL);
2923 return 0;
2924 }
2925
2926 app_set_config ();
2927
2928 if (bat_new (&inst_hndl, mem2, (U8)clnt_num, BAT_APP_CONFIG, instance_signal_cb) NEQ BAT_OK)
2929 {
2930 TRACE_ERROR("Call to bat_new() failed");
2931 free_mem(mem1,mem2,NULL,NULL,NULL);
2932 return 0;
2933 }
2934 vsi_t_sleep (VSI_CALLER 100);
2935
2936 if (bat_open (inst_hndl, &clnt_hndl, response_cb, signal_cb) NEQ BAT_OK)
2937 {
2938 TRACE_ERROR("Call to bat_open() failed");
2939 free_mem(mem1,mem2,NULL,NULL,NULL);
2940 return 0;
2941 }
2942 vsi_t_sleep (VSI_CALLER 100);
2943
2944 if (bat_uns_open(0, &client, unsolicited_result_cb))
2945 {
2946 TRACE_ERROR("Call to bat_uns_open() failed");
2947 free_mem(mem1,mem2,NULL,NULL,NULL);
2948 return 0;
2949 }
2950
2951 memset(&my_set_plus_cfun, sizeof(my_set_plus_cfun), FALSE);
2952 my_bat_cmd_send.ctrl_params = BAT_CMD_SET_PLUS_CFUN;
2953 my_bat_cmd_send.params.ptr_set_plus_cfun = &my_set_plus_cfun;
2954 /* full functionality mode*/
2955 my_set_plus_cfun.fun = BAT_CFUN_FUN_FULL;
2956 /* Reset the MT before changing functionality level */
2957 my_set_plus_cfun.rst = BAT_CFUN_RST_NOT_PRESENT;
2958
2959 TRACE_EVENT("calling bat_send()");
2960
2961 result = bat_send (clnt_hndl, &my_bat_cmd_send);
2962
2963 if(result NEQ BAT_OK)
2964 {
2965 TRACE_ERROR("Call to bat_send() failed");
2966 free_mem(mem1,mem2,NULL,NULL,NULL);
2967 return 0;
2968 }
2969
2970 vsi_t_sleep (VSI_CALLER 200);
2971
2972 TRACE_EVENT("calling bat_close()");
2973
2974 result = bat_close (clnt_hndl);
2975
2976 if(result NEQ BAT_OK)
2977 {
2978 TRACE_ERROR("Call to bat_close() failed");
2979 free_mem(mem1,mem2,NULL,NULL,NULL);
2980 return 0;
2981 }
2982 vsi_t_sleep (VSI_CALLER 100);
2983
2984 TRACE_EVENT("calling bat_close() for unsolicited");
2985
2986 result = bat_close (client);
2987
2988 if(result NEQ BAT_OK)
2989 {
2990 TRACE_ERROR("Call to bat_close() failed");
2991 free_mem(mem1,mem2,NULL,NULL,NULL);
2992 return 0;
2993 }
2994 result = bat_delete(inst_hndl);
2995 vsi_t_sleep (VSI_CALLER 300);
2996
2997 if(result NEQ BAT_OK)
2998 {
2999 TRACE_ERROR("Call to bat_delete() failed");
3000 free_mem(mem1,mem2,NULL,NULL,NULL);
3001 return 0;
3002 }
3003
3004 result = bat_deinit();
3005
3006 if(result NEQ BAT_OK)
3007 {
3008 TRACE_ERROR("Call to bat_deinit() failed");
3009 free_mem(mem1,mem2,NULL,NULL,NULL);
3010 return 0;
3011 }
3012
3013 free_mem(mem1,mem2,NULL,NULL,NULL);
3014 }
3015 app_bat_send_result_prim(0, NO_ADD_VAL);
3016 return 0;
3017 }
3018
3019 /*****************************************************************************************
3020 *
3021 * This test case tests the flow control between app and BAT Lib
3022 *
3023 *****************************************************************************************/
3024
3025 GLOBAL char *app_bat_flow_control_test1(app_cmd_entry_t *cmd_entry_ptr,
3026 char *param1, char *param2, char *param3, core_func_t core_func)
3027 {
3028 T_BAT_return result = BAT_ERROR;
3029 void *mem1 = NULL;
3030 void *mem2 = NULL;
3031 int inst_num = 2;
3032 int clnt_num = 2;
3033 T_BAT_instance inst_hndl = BAT_INVALID_INSTANCE_HANDLE;
3034 T_BAT_client clnt_hndl = BAT_INVALID_CLIENT_HANDLE;
3035
3036 T_BAT_cmd_set_plus_cfun my_set_plus_cfun;
3037 T_BAT_cmd_send my_bat_cmd_send;
3038 T_BAT_ctrl app_bat_ctrl;
3039
3040 TRACE_FUNCTION("app_bat_complete_test1()");
3041 MALLOC(mem1, BAT_INSTANCE_HEADER_SIZE*inst_num);
3042 MALLOC(mem2, (clnt_num*BAT_CLIENT_SIZE + BAT_INSTANCE_SIZE));
3043
3044
3045 TRACE_EVENT("calling bat_init()");
3046
3047 result = bat_init(mem1, (U8)inst_num);
3048
3049 if(result NEQ BAT_OK)
3050 {
3051 TRACE_ERROR("ERROR: Call to bat_init() failed");
3052 free_mem(mem1,mem2,NULL,NULL,NULL);
3053 return 0;
3054 }
3055
3056 app_set_config ();
3057
3058 TRACE_EVENT("calling bat_new()");
3059
3060 result = bat_new (&inst_hndl, mem2, (U8)clnt_num, BAT_APP_CONFIG, instance_signal_cb);
3061
3062 TRACE_EVENT_P1 ("inst_hndl is %d", inst_hndl);
3063
3064 if(result != BAT_OK)
3065 {
3066 TRACE_ERROR("Call to bat_new() failed");
3067 free_mem(mem1,mem2,NULL,NULL,NULL);
3068 return 0;
3069 }
3070
3071 TRACE_EVENT("calling bat_open()");
3072
3073 result = bat_open (inst_hndl, &clnt_hndl, response_cb_busy, signal_cb);
3074
3075 if(result NEQ BAT_OK)
3076 {
3077 TRACE_ERROR("Call to bat_open() failed");
3078 free_mem(mem1,mem2,NULL,NULL,NULL);
3079 return 0;
3080 }
3081
3082 TRACE_EVENT("calling bat_uns_open()");
3083
3084 memset(&my_set_plus_cfun, sizeof(my_set_plus_cfun), FALSE);
3085 my_bat_cmd_send.ctrl_params = BAT_CMD_SET_PLUS_CFUN;
3086 my_bat_cmd_send.params.ptr_set_plus_cfun = &my_set_plus_cfun;
3087 /* full functionality mode*/
3088 my_set_plus_cfun.fun = BAT_CFUN_FUN_FULL;
3089 /* Reset the MT before changing functionality level */
3090 my_set_plus_cfun.rst = BAT_CFUN_RST_NOT_PRESENT;
3091
3092 TRACE_EVENT("calling bat_send()");
3093
3094 result = bat_send (clnt_hndl, &my_bat_cmd_send);
3095 if(result NEQ BAT_OK)
3096 {
3097 TRACE_ERROR("Call to bat_send() failed");
3098 free_mem(mem1,mem2,NULL,NULL,NULL);
3099 return 0;
3100 }
3101
3102 app_bat_ctrl.event = BAT_APP_READY_RESOURCE;
3103 result = bat_ctrl(clnt_hndl, &app_bat_ctrl);
3104 vsi_t_sleep (VSI_CALLER 500);
3105
3106 if(result NEQ BAT_OK)
3107 {
3108 TRACE_ERROR("Call to bat_ctrl() failed");
3109 free_mem(mem1,mem2,NULL,NULL,NULL);
3110 return 0;
3111 }
3112 result = bat_send (clnt_hndl, &my_bat_cmd_send);
3113 vsi_t_sleep (VSI_CALLER 500);
3114
3115 if(result NEQ BAT_OK)
3116 {
3117 TRACE_ERROR("Call to bat_send() failed");
3118 free_mem(mem1,mem2,NULL,NULL,NULL);
3119 return 0;
3120 }
3121 app_bat_send_result_prim(0, NO_ADD_VAL);
3122 return 0;
3123 }
3124
3125
3126 /*****************************************************************************************
3127 *
3128 * This test case specifically tests receiving of unsolicited code, aborting of a
3129 * running command and running a 2nd BAT cmd afterwords.
3130 *
3131 * NOTE: this test case has to be used together with the PSI simulation stub.
3132 *
3133 *****************************************************************************************/
3134
3135 GLOBAL char *app_bat_uns_rcv_and_abort_test(app_cmd_entry_t *cmd_entry_ptr,
3136 char *param1, char *param2, char *param3, core_func_t core_func)
3137 {
3138 T_BAT_instance inst_hndl = BAT_INVALID_INSTANCE_HANDLE;
3139 T_BAT_client clnt_hndl = BAT_INVALID_CLIENT_HANDLE;
3140 int i;
3141
3142 static T_BAT_client test_clnt_table[1][8+1] = {
3143 {0,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff}};
3144 static void *mem_hdr = NULL;
3145 void *mem_inst = NULL;
3146
3147 T_BAT_cmd_set_plus_cfun my_set_plus_cfun;
3148 T_BAT_cmd_send my_bat_cmd_send;
3149 T_BAT_ctrl app_bat_ctrl;
3150
3151
3152 memset(&my_set_plus_cfun, sizeof(my_set_plus_cfun), FALSE);
3153 my_bat_cmd_send.ctrl_params = BAT_CMD_SET_PLUS_CFUN;
3154 my_bat_cmd_send.params.ptr_set_plus_cfun = &my_set_plus_cfun;
3155 /* full functionality mode*/
3156 my_set_plus_cfun.fun = BAT_CFUN_FUN_FULL;
3157 /* Reset the MT before changing functionality level */
3158 my_set_plus_cfun.rst = BAT_CFUN_RST_RESET;
3159
3160 TRACE_FUNCTION("app_bat_uns_rcv_and_abort_test()");
3161
3162 MALLOC(mem_hdr, BAT_INSTANCE_HEADER_SIZE*4);
3163 MALLOC(mem_inst, BAT_INSTANCE_SIZE + 8*BAT_CLIENT_SIZE);
3164
3165 TRACE_EVENT("calling bat_init()");
3166 /* init BAT */
3167 if ( bat_init(mem_hdr, 1))
3168 {
3169 TRACE_ERROR ("Call to bat_init () failed!");
3170 MFREE(mem_hdr);
3171 return 0;
3172 }
3173 app_set_config ();
3174
3175 TRACE_EVENT("calling bat_new()");
3176
3177 if (bat_new (&inst_hndl, mem_inst, 8, BAT_APP_CONFIG, instance_signal_cb) OR inst_hndl NEQ 0)
3178 {
3179 TRACE_ERROR("Call to bat_new() failed");
3180 free_mem(mem_hdr, mem_inst,NULL,NULL,NULL);
3181 return 0;
3182 }
3183 TRACE_EVENT_P1 ("inst_hndl is %d", inst_hndl);
3184 vsi_t_sleep (VSI_CALLER 300);
3185
3186 TRACE_EVENT("calling bat_uns_open()");
3187
3188 if (bat_uns_open(0, &clnt_hndl, unsolicited_result_cb))
3189 {
3190 free_mem(mem_hdr, mem_inst,NULL,NULL,NULL);
3191 return 0;
3192 }
3193
3194 /* create BAT client for this instance */
3195 for (i = 0; i < 8; i ++)
3196 {
3197 TRACE_EVENT_P1("Open clnt_id %d for inst 0", i);
3198 if (bat_open(inst_hndl, &test_clnt_table[inst_hndl][i+1],response_cb, signal_cb))
3199 {
3200 TRACE_ERROR("Call to bat_open() failed");
3201 free_mem(mem_hdr, mem_inst,NULL,NULL,NULL);
3202 return 0;
3203 }
3204 vsi_t_sleep (VSI_CALLER 100);
3205 test_clnt_table[inst_hndl][0]++;
3206
3207 TRACE_EVENT("calling bat_send()");
3208
3209 /* send out a command from all clients */
3210 if (bat_send (test_clnt_table[inst_hndl][i+1], &my_bat_cmd_send))
3211 {
3212 TRACE_ERROR("Call to 1st bat_send() failed");
3213 free_mem(mem_hdr, mem_inst,NULL,NULL,NULL);
3214 return 0;
3215 }
3216 vsi_t_sleep (VSI_CALLER 300);
3217
3218 /* abort the cmd running on client 7 */
3219 if (i EQ 7)
3220 {
3221 app_bat_ctrl.event = BAT_ABORT;
3222 if (bat_ctrl(test_clnt_table[inst_hndl][i+1], &app_bat_ctrl))
3223 {
3224 TRACE_ERROR("Call to bat_ctrl() failed");
3225 MFREE(mem_inst);
3226 return 0;
3227 }
3228 vsi_t_sleep (VSI_CALLER 300);
3229 }
3230
3231 /* send out another command from all clients */
3232 if (bat_send (test_clnt_table[inst_hndl][i+1], &my_bat_cmd_send))
3233 {
3234 TRACE_ERROR("Call to 2nd bat_send() failed");
3235 free_mem(mem_hdr, mem_inst,NULL,NULL,NULL);
3236 return 0;
3237 }
3238 vsi_t_sleep (VSI_CALLER 300);
3239 }
3240 app_bat_send_result_prim(0, NO_ADD_VAL);
3241 return 0;
3242 }
3243
3244
3245 /*****************************************************************************************
3246 *
3247 * This test case tests the opening of multiple channels, sending of AT cmds, receiving of
3248 * unsolicited code, aborting of a running command.
3249 *
3250 * NOTE: this test case has to be used together with the PSI simulation stub.
3251 *
3252 *****************************************************************************************/
3253
3254 GLOBAL char *app_bat_multi_channel_creation_test(app_cmd_entry_t *cmd_entry_ptr,
3255 char *param1, char *param2, char *param3, core_func_t core_func)
3256 {
3257 T_BAT_instance inst_hndl[4] = {0xff,0xff,0xff,0xff};
3258 int i,j;
3259
3260 /* 4 instance with 8 clnts each, the first element is the num of opened clnts */
3261 static T_BAT_client test_clnt_table[4][6+1] = {
3262 {0,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff},
3263 {0,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff},
3264 {0,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff},
3265 {0,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff}};
3266 void *mem_hdr = NULL;
3267
3268 void *mem_inst[4] = {NULL,NULL,NULL,NULL};
3269
3270 T_BAT_cmd_set_plus_cfun my_set_plus_cfun;
3271 T_BAT_cmd_send my_bat_cmd_send;
3272
3273
3274 memset(&my_set_plus_cfun, sizeof(my_set_plus_cfun), FALSE);
3275 my_bat_cmd_send.ctrl_params = BAT_CMD_SET_PLUS_CFUN;
3276 my_bat_cmd_send.params.ptr_set_plus_cfun = &my_set_plus_cfun;
3277 /* full functionality mode*/
3278 my_set_plus_cfun.fun = BAT_CFUN_FUN_FULL;
3279 /* Reset the MT before changing functionality level */
3280 my_set_plus_cfun.rst = BAT_CFUN_RST_RESET;
3281
3282
3283
3284 TRACE_FUNCTION("app_bat_multi_channel_creation_test()");
3285
3286 MALLOC(mem_hdr, BAT_INSTANCE_HEADER_SIZE*4);
3287
3288 TRACE_EVENT("calling bat_init()");
3289 /* init BAT */
3290 if ( bat_init(mem_hdr, 4))
3291 {
3292 TRACE_ERROR ("Call to bat_init () failed!");
3293 MFREE(mem_hdr);
3294 return 0;
3295 }
3296 app_set_config ();
3297
3298
3299 /*************************************************************************************************
3300 *
3301 * create 4 BAT instances with each instance 6 clients
3302 *
3303 ************************************************************************************************/
3304 for (i = 0; i < 4; i ++)
3305 {
3306 TRACE_EVENT_P1("calling bat_new() for the %d th instance", i);
3307 MALLOC(mem_inst[i], BAT_INSTANCE_SIZE + 8*BAT_CLIENT_SIZE);
3308 if (bat_new (&inst_hndl[i], mem_inst[i], 8, BAT_APP_CONFIG, instance_signal_cb) OR inst_hndl[i] NEQ i)
3309 {
3310 free_mem (mem_hdr,mem_inst[0],mem_inst[1],mem_inst[2],mem_inst[3]);
3311 return 0;
3312 }
3313 TRACE_EVENT_P1 ("created inst_hndl: %d", inst_hndl[i]);
3314 for (j = 0; j < 6; j ++)
3315 {
3316 TRACE_EVENT_P1("Opened clnt_id: %d ", j);
3317 if (bat_open(inst_hndl[i], &test_clnt_table[i][j+1],response_cb, signal_cb))
3318 {
3319 free_mem (mem_hdr,mem_inst[0],mem_inst[1],mem_inst[2],mem_inst[3]);
3320 return 0;
3321 }
3322 vsi_t_sleep (VSI_CALLER 100);
3323 test_clnt_table[inst_hndl[i]][0]++;
3324 /* send out a command from all clients */
3325 if (bat_send (test_clnt_table[i][j+1], &my_bat_cmd_send))
3326 {
3327 free_mem (mem_hdr,mem_inst[0],mem_inst[1],mem_inst[2],mem_inst[3]);
3328 return 0;
3329 }
3330 vsi_t_sleep (VSI_CALLER 300);
3331 }
3332 }
3333 app_bat_send_result_prim(0, NO_ADD_VAL);
3334 return 0;
3335 }
3336
3337 GLOBAL char *app_bat_stress_test (app_cmd_entry_t *cmd_entry_ptr, char *param1,
3338 char *param2, char *param3, core_func_t core_func)
3339 {
3340 T_BAT_return result = BAT_ERROR;
3341 T_BAT_client clnt_hndl = BAT_CONTROL_CHANNEL;
3342 T_BAT_cmd_set_plus_cfun my_set_plus_cfun;
3343 T_BAT_cmd_send my_bat_cmd_send;
3344 T_CLIENT_HANDLE_ERROR err;
3345 U16 i = 0;
3346
3347 clnt_hndl = get_item(param1, 0, FALSE);
3348
3349 err = check_client_handle (clnt_hndl);
3350 if (err NEQ CLIENT_HANDLE_OK)
3351 {
3352 return (error_client_handle(err));
3353 }
3354
3355 while (i<400)
3356 {
3357 TRACE_EVENT_P1("Processing cycle %d",i);
3358
3359 memset(&my_set_plus_cfun, sizeof(my_set_plus_cfun), FALSE);
3360
3361 my_bat_cmd_send.ctrl_params = BAT_CMD_SET_PLUS_CFUN;
3362
3363 my_bat_cmd_send.params.ptr_set_plus_cfun = &my_set_plus_cfun;
3364
3365 /* full functionality mode*/
3366 my_set_plus_cfun.fun = BAT_CFUN_FUN_FULL;
3367
3368 /* Reset the MT before changing functionality level */
3369 my_set_plus_cfun.rst = BAT_CFUN_RST_NOT_PRESENT;
3370
3371 result = bat_send (clnt_hndl, &my_bat_cmd_send);
3372
3373 if(result NEQ BAT_OK)
3374 {
3375 app_bat_send_result_prim(1, NO_ADD_VAL);
3376 break;
3377 }
3378
3379 vsi_t_sleep (VSI_CALLER 3000);
3380 i++;
3381 }
3382
3383 if(result NEQ BAT_OK)
3384 {
3385 return ("Call to bat_send_cfun() failed");
3386 }
3387
3388 app_bat_send_result_prim(0, NO_ADD_VAL);
3389 return 0;
3390 }
3391
3392 GLOBAL char *app_bat_send_cniv(app_cmd_entry_t *cmd_entry_ptr, char *param1,
3393 char *param2, char *param3, core_func_t core_func)
3394 {
3395 T_BAT_return result = BAT_ERROR;
3396 T_BAT_client clnt_hndl = BAT_CONTROL_CHANNEL;
3397 T_BAT_cmd_set_percent_cniv my_cmd_percent_cniv;
3398 T_BAT_cmd_send my_bat_cmd_send;
3399 T_CLIENT_HANDLE_ERROR err;
3400
3401 TRACE_FUNCTION("app_bat_send_cniv()");
3402
3403 clnt_hndl = get_item(param1, 0, FALSE);
3404
3405 err = check_client_handle (clnt_hndl);
3406 if (err NEQ CLIENT_HANDLE_OK)
3407 {
3408 return (error_client_handle(err));
3409 }
3410 memset(&my_cmd_percent_cniv, 0 , sizeof(my_cmd_percent_cniv));
3411 my_bat_cmd_send.ctrl_params = BAT_CMD_SET_PERCENT_CNIV;
3412 my_bat_cmd_send.params.ptr_set_percent_cniv = &my_cmd_percent_cniv;
3413
3414 if ( (param2 NEQ NULL) AND atoi(param2) )
3415 {
3416 my_cmd_percent_cniv.mode= BAT_CNIV_MODE_ON;
3417 }
3418
3419 result = bat_send (clnt_hndl, &my_bat_cmd_send);
3420
3421 if(result NEQ BAT_OK)
3422 {
3423 app_bat_send_result_prim(1, NO_ADD_VAL);
3424 return ("Call to bat_send_cniv() failed");
3425 }
3426 app_bat_send_result_prim(0, NO_ADD_VAL);
3427 return 0;
3428
3429
3430 }
3431
3432 GLOBAL char *app_bat_send_q_cniv(app_cmd_entry_t *cmd_entry_ptr, char *param1,
3433 char *param2, char *param3, core_func_t core_func)
3434 {
3435 T_BAT_return result = BAT_ERROR;
3436 T_BAT_client clnt_hndl = BAT_CONTROL_CHANNEL;
3437 T_BAT_no_parameter my_que_percent_cniv;
3438 T_BAT_cmd_send my_bat_cmd_send;
3439 T_CLIENT_HANDLE_ERROR err;
3440
3441 TRACE_FUNCTION("app_bat_send_q_cniv()");
3442
3443 clnt_hndl = get_item(param1, 0, FALSE);
3444
3445 err = check_client_handle (clnt_hndl);
3446 if (err NEQ CLIENT_HANDLE_OK)
3447 {
3448 return (error_client_handle(err));
3449 }
3450
3451 my_bat_cmd_send.ctrl_params = BAT_CMD_QUE_PERCENT_CNIV;
3452 my_bat_cmd_send.params.ptr_que_percent_cniv = &my_que_percent_cniv;
3453
3454 result = bat_send (clnt_hndl, &my_bat_cmd_send);
3455
3456 if(result NEQ BAT_OK)
3457 {
3458 app_bat_send_result_prim(1, NO_ADD_VAL);
3459 return ("Call to bat_send_q_cniv() failed");
3460 }
3461 app_bat_send_result_prim(0, NO_ADD_VAL);
3462 return 0;
3463
3464 }
3465
3466 GLOBAL char *app_bat_send_custom (app_cmd_entry_t *cmd_entry_ptr, char *param1,
3467 char *param2, char *param3, core_func_t core_func)
3468 {
3469 T_BAT_return result = BAT_ERROR;
3470 T_BAT_client clnt_hndl = BAT_CONTROL_CHANNEL;
3471 T_BAT_cmd_send send;
3472 T_BAT_custom custom;
3473 T_CLIENT_HANDLE_ERROR err;
3474
3475 TRACE_FUNCTION("app_bat_send_custom()");
3476
3477 clnt_hndl = get_item(param1, 0, FALSE);
3478
3479 err = check_client_handle (clnt_hndl);
3480 if (err NEQ CLIENT_HANDLE_OK)
3481 {
3482 return (error_client_handle(err));
3483 }
3484
3485 send.ctrl_params = BAT_CMD_CUSTOM;
3486 send.params.ptr_custom = &custom;
3487
3488 if (param2 EQ NULL)
3489 {
3490 strcpy((char *)custom.buf, "OK");
3491 }
3492 else if (strcmp(param2, "DATA") EQ 0)
3493 {
3494 custom.buf[0] = 0x80;
3495 custom.buf[1] = 0x81;
3496 custom.buf[2] = 0x82;
3497 custom.buf[3] = 0x83;
3498 custom.buf[4] = 0x84;
3499 custom.buf[5] = 0x85;
3500 custom.buf[6] = 0x86;
3501 custom.buf[7] = 0x87;
3502 custom.buf[8] = 0x88;
3503 custom.buf[9] = 0x89;
3504 custom.buf[10] = 0x8A;
3505 custom.buf[11] = 0x8B;
3506 custom.buf[12] = 0x8C;
3507 custom.buf[13] = 0x8D;
3508 custom.buf[14] = 0x8E;
3509 custom.buf[15] = 0x8F;
3510 custom.buf[16] = 0x90;
3511 custom.buf[17] = 0x91;
3512 custom.buf[18] = 0x92;
3513 custom.buf[19] = 0x93;
3514 custom.buf[20] = 0x94;
3515 custom.buf[21] = 0x95;
3516 custom.buf[22] = 0x96;
3517 custom.buf[23] = 0x97;
3518 custom.buf[24] = 0x98;
3519 custom.buf[25] = 0x99;
3520 custom.buf[26] = 0x9A;
3521 custom.buf[27] = 0x9B;
3522 custom.buf[28] = 0x9C;
3523 custom.buf[29] = 0x9D;
3524 custom.buf[30] = 0x9E;
3525 custom.buf[31] = 0x9F;
3526 custom.buf[32] = 0xA0;
3527 custom.buf[33] = 0xA1;
3528 custom.buf[34] = 0xA2;
3529 custom.buf[35] = 0xA3;
3530 custom.buf[36] = 0xA4;
3531 custom.buf[37] = 0xA5;
3532 custom.buf[38] = 0xA6;
3533 custom.buf[39] = 0xA7;
3534 custom.buf[40] = 0xA8;
3535 custom.buf[41] = 0xA9;
3536 custom.buf[42] = 0xAA;
3537 custom.buf[43] = 0xAB;
3538 custom.buf[44] = 0xAC;
3539 custom.buf[45] = 0xAD;
3540 custom.buf[46] = 0xAE;
3541 custom.buf[47] = 0xAF;
3542 custom.buf[48] = 0xB0;
3543 custom.buf[49] = 0xB1;
3544 custom.buf[50] = 0xB2;
3545 custom.buf[51] = 0xB3;
3546 custom.buf[52] = 0xB4;
3547 custom.buf[53] = 0xB5;
3548 custom.buf[54] = 0xB6;
3549 custom.buf[55] = 0xB7;
3550 custom.buf[56] = 0xB8;
3551 custom.buf[57] = 0xB9;
3552 custom.buf[58] = 0xBA;
3553 custom.buf[59] = 0xBB;
3554 custom.buf[60] = 0xBC;
3555 custom.buf[61] = 0xBD;
3556 custom.buf[62] = 0xBE;
3557 custom.buf[63] = 0xBF;
3558 custom.buf[64] = 0xC0;
3559 custom.buf[65] = 0xC1;
3560 custom.buf[66] = 0xC2;
3561 custom.buf[67] = 0xC3;
3562 custom.buf[68] = 0xC4;
3563 custom.buf[69] = 0xC5;
3564 custom.buf[70] = 0xC6;
3565 custom.buf[71] = 0xC7;
3566 custom.buf[72] = 0xC8;
3567 custom.buf[73] = 0xC9;
3568 custom.buf[74] = 0xCA;
3569 custom.buf[75] = 0xCB;
3570 custom.buf[76] = 0xCC;
3571 custom.buf[77] = 0xCD;
3572 custom.buf[78] = 0xCE;
3573 custom.buf[79] = 0xCF;
3574 custom.buf[80] = 0xD0;
3575 custom.buf[81] = 0xD1;
3576 custom.buf[82] = 0xD2;
3577 custom.buf[83] = 0xD3;
3578 custom.buf[84] = 0xD4;
3579 custom.buf[85] = 0xD5;
3580 custom.buf[86] = 0xD6;
3581 custom.buf[87] = 0xD7;
3582 custom.buf[88] = 0xD8;
3583 custom.buf[89] = 0xD9;
3584 custom.buf[90] = 0xDA;
3585 custom.buf[91] = 0xDB;
3586 custom.buf[92] = 0xDC;
3587 custom.buf[93] = 0xDD;
3588 custom.buf[94] = 0xDE;
3589 custom.buf[95] = 0xDF;
3590 custom.buf[96] = 0xE0;
3591 custom.buf[97] = 0xE1;
3592 custom.buf[98] = 0xE2;
3593 custom.buf[99] = 0xE3;
3594 custom.buf[100] = 0xE4;
3595 custom.buf[101] = 0xE5;
3596 custom.buf[102] = 0xE6;
3597 custom.buf[103] = 0xE7;
3598 custom.buf[104] = 0xE8;
3599 custom.buf[105] = 0xE9;
3600 custom.buf[106] = 0xEA;
3601 custom.buf[107] = 0xEB;
3602 custom.buf[108] = 0xEC;
3603 custom.buf[109] = 0xED;
3604 custom.buf[110] = 0xEE;
3605 custom.buf[111] = 0xEF;
3606 custom.buf[112] = 0xF0;
3607 custom.buf[113] = 0xF1;
3608 custom.buf[114] = 0xF2;
3609 custom.buf[115] = 0xF3;
3610 custom.buf[116] = 0xF4;
3611 custom.buf[117] = 0xF5;
3612 custom.buf[118] = 0xF6;
3613 custom.buf[119] = 0xF7;
3614 custom.buf[120] = 0xF8;
3615 custom.buf[121] = 0xF9;
3616 custom.buf[122] = 0xFA;
3617 custom.buf[123] = 0xFB;
3618 custom.buf[124] = 0xFC;
3619 custom.buf[125] = 0xFD;
3620 custom.buf[126] = 0xFE;
3621 custom.buf[127] = 0x00;
3622 }
3623 else
3624 {
3625 strcpy((char *)custom.buf, param2);
3626 }
3627
3628 if (param3 && strcmp(param3, "MR") EQ 0)
3629 {
3630 send.ctrl_params = (T_BAT_ctrl_params)MOTO_CMD_MR;
3631 TRACE_EVENT_P1("app_bat_send_custom(): len = %d ", custom.c_buf);
3632 }
3633 else
3634 {
3635 TRACE_EVENT_P2("app_bat_send_custom(): cmd = %s, len = %d ", custom.buf, custom.c_buf);
3636 }
3637 custom.c_buf = strlen((char *)custom.buf);
3638
3639 result = bat_send (clnt_hndl, &send);
3640
3641 if(result NEQ BAT_OK)
3642 {
3643 app_bat_send_result_prim(1, NO_ADD_VAL);
3644 return ("Call to bat_send_ata() failed");
3645 }
3646 app_bat_send_result_prim(0, NO_ADD_VAL);
3647 return 0;
3648 }
3649
3650
3651
3652
3653
3654
3655 /*---------------------------------------------------------------------------
3656 * Definition of core functions
3657 *---------------------------------------------------------------------------*/
3658
3659 /* -- No core functions required for now */
3660
3661
3662 /*==== Exported functions ====================================================*/
3663
3664 char *app_handle_command_bat(char *command)
3665 {
3666 TRACE_FUNCTION ("app_handle_command_bat()");
3667 return app_handle_command(command, app_bat_cmd_table);
3668 }
3669
3670
3671 /* EOF */