1 /******************************************************************************
2 *
3 * Copyright (C) 2003-2012 Broadcom Corporation
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 ******************************************************************************/
18
19 /******************************************************************************
20 *
21 * This file contains the GATT client main functions and state machine.
22 *
23 ******************************************************************************/
24
25 #include "bt_target.h"
26
27 #if defined(BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE)
28
29 #include <string.h>
30
31 #include "bta_gattc_int.h"
32 #include "gki.h"
33
34
35 /*****************************************************************************
36 ** Constants and types
37 *****************************************************************************/
38
39
40 /* state machine action enumeration list */
41 enum
42 {
43 BTA_GATTC_OPEN,
44 BTA_GATTC_OPEN_FAIL,
45 //BTA_GATTC_OPEN_FAIL_IN_CONN, //<--- need to remove this?
46 BTA_GATTC_OPEN_ERROR,
47 BTA_GATTC_CANCEL_OPEN,
48 BTA_GATTC_CANCEL_OPEN_OK,
49 BTA_GATTC_CANCEL_OPEN_ERROR,
50 BTA_GATTC_CONN,
51 BTA_GATTC_START_DISCOVER,
52 BTA_GATTC_DISC_CMPL,
53
54 BTA_GATTC_Q_CMD,
55 BTA_GATTC_CLOSE,
56 BTA_GATTC_CLOSE_FAIL,
57 BTA_GATTC_READ,
58 BTA_GATTC_WRITE,
59
60 BTA_GATTC_OP_CMPL,
61 BTA_GATTC_SEARCH,
62 BTA_GATTC_FAIL,
63 BTA_GATTC_CONFIRM,
64 BTA_GATTC_EXEC,
65 BTA_GATTC_READ_MULTI,
66 BTA_GATTC_CI_OPEN,
67 BTA_GATTC_CI_LOAD,
68 BTA_GATTC_CI_SAVE,
69 BTA_GATTC_CACHE_OPEN,
70 BTA_GATTC_IGNORE_OP_CMPL,
71
72 BTA_GATTC_IGNORE
73 };
74 /* type for action functions */
75 typedef void (*tBTA_GATTC_ACTION)(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
76
77 /* action function list */
78 const tBTA_GATTC_ACTION bta_gattc_action[] =
79 {
80 bta_gattc_open,
81 bta_gattc_open_fail,
82 //bta_gattc_open_fail_in_conn, //<--- need to remove this?
83 bta_gattc_open_error,
84 bta_gattc_cancel_open,
85 bta_gattc_cancel_open_ok,
86 bta_gattc_cancel_open_error,
87 bta_gattc_conn,
88 bta_gattc_start_discover,
89 bta_gattc_disc_cmpl,
90
91 bta_gattc_q_cmd,
92 bta_gattc_close,
93 bta_gattc_close_fail,
94 bta_gattc_read,
95 bta_gattc_write,
96
97 bta_gattc_op_cmpl,
98 bta_gattc_search,
99 bta_gattc_fail,
100 bta_gattc_confirm,
101 bta_gattc_execute,
102 bta_gattc_read_multi,
103 bta_gattc_ci_open,
104 bta_gattc_ci_load,
105 bta_gattc_ci_save,
106 bta_gattc_cache_open,
107 bta_gattc_ignore_op_cmpl
108 };
109
110
111 /* state table information */
112 #define BTA_GATTC_ACTIONS 1 /* number of actions */
113 #define BTA_GATTC_NEXT_STATE 1 /* position of next state */
114 #define BTA_GATTC_NUM_COLS 2 /* number of columns in state tables */
115
116 /* state table for idle state */
117 static const UINT8 bta_gattc_st_idle[][BTA_GATTC_NUM_COLS] =
118 {
119 /* Event Action 1 Next state */
120 /* BTA_GATTC_API_OPEN_EVT */ {BTA_GATTC_OPEN, BTA_GATTC_W4_CONN_ST},
121 /* BTA_GATTC_INT_OPEN_FAIL_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST},
122 /* BTA_GATTC_API_CANCEL_OPEN_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST},
123 /* BTA_GATTC_INT_CANCEL_OPEN_OK_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST},
124
125 /* BTA_GATTC_API_READ_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_IDLE_ST},
126 /* BTA_GATTC_API_WRITE_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_IDLE_ST},
127 /* BTA_GATTC_API_EXEC_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_IDLE_ST},
128
129 /* BTA_GATTC_API_CLOSE_EVT */ {BTA_GATTC_CLOSE_FAIL, BTA_GATTC_IDLE_ST},
130
131 /* BTA_GATTC_API_SEARCH_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_IDLE_ST},
132 /* BTA_GATTC_API_CONFIRM_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_IDLE_ST},
133 /* BTA_GATTC_API_READ_MULTI_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_IDLE_ST},
134 /* BTA_GATTC_INT_CONN_EVT */ {BTA_GATTC_CONN, BTA_GATTC_CONN_ST},
135 /* BTA_GATTC_INT_DISCOVER_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST},
136 /* BTA_GATTC_DISCOVER_CMPL_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST},
137 /* BTA_GATTC_OP_CMPL_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST},
138 /* BTA_GATTC_INT_DISCONN_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST},
139
140
141 /* ===> for cache loading, saving */
142 /* BTA_GATTC_START_CACHE_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST},
143 /* BTA_GATTC_CI_CACHE_OPEN_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST},
144 /* BTA_GATTC_CI_CACHE_LOAD_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST},
145 /* BTA_GATTC_CI_CACHE_SAVE_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST}
146 };
147
148 /* state table for wait for open state */
149 static const UINT8 bta_gattc_st_w4_conn[][BTA_GATTC_NUM_COLS] =
150 {
151 /* Event Action 1 Next state */
152 /* BTA_GATTC_API_OPEN_EVT */ {BTA_GATTC_OPEN, BTA_GATTC_W4_CONN_ST},
153 /* BTA_GATTC_INT_OPEN_FAIL_EVT */ {BTA_GATTC_OPEN_FAIL, BTA_GATTC_IDLE_ST},
154 /* BTA_GATTC_API_CANCEL_OPEN_EVT */ {BTA_GATTC_CANCEL_OPEN, BTA_GATTC_W4_CONN_ST},
155 /* BTA_GATTC_INT_CANCEL_OPEN_OK_EVT */ {BTA_GATTC_CANCEL_OPEN_OK, BTA_GATTC_IDLE_ST},
156
157 /* BTA_GATTC_API_READ_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_W4_CONN_ST},
158 /* BTA_GATTC_API_WRITE_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_W4_CONN_ST},
159 /* BTA_GATTC_API_EXEC_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_W4_CONN_ST},
160
161 /* BTA_GATTC_API_CLOSE_EVT */ {BTA_GATTC_CLOSE_FAIL, BTA_GATTC_W4_CONN_ST},
162
163 /* BTA_GATTC_API_SEARCH_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_W4_CONN_ST},
164 /* BTA_GATTC_API_CONFIRM_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_W4_CONN_ST},
165 /* BTA_GATTC_API_READ_MULTI_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_W4_CONN_ST},
166
167 /* BTA_GATTC_INT_CONN_EVT */ {BTA_GATTC_CONN, BTA_GATTC_CONN_ST},
168 /* BTA_GATTC_INT_DISCOVER_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_W4_CONN_ST},
169 /* BTA_GATTC_DISCOVER_CMPL_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_W4_CONN_ST},
170 /* BTA_GATTC_OP_CMPL_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_W4_CONN_ST},
171 /* BTA_GATTC_INT_DISCONN_EVT */ {BTA_GATTC_CLOSE, BTA_GATTC_IDLE_ST},
172
173 /* ===> for cache loading, saving */
174 /* BTA_GATTC_START_CACHE_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_W4_CONN_ST},
175 /* BTA_GATTC_CI_CACHE_OPEN_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_W4_CONN_ST},
176 /* BTA_GATTC_CI_CACHE_LOAD_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_W4_CONN_ST},
177 /* BTA_GATTC_CI_CACHE_SAVE_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_W4_CONN_ST}
178 };
179
180 /* state table for open state */
181 static const UINT8 bta_gattc_st_connected[][BTA_GATTC_NUM_COLS] =
182 {
183 /* Event Action 1 Next state */
184 /* BTA_GATTC_API_OPEN_EVT */ {BTA_GATTC_OPEN_ERROR, BTA_GATTC_CONN_ST},
185 /* BTA_GATTC_INT_OPEN_FAIL_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_CONN_ST},
186 /* BTA_GATTC_API_CANCEL_OPEN_EVT */ {BTA_GATTC_CANCEL_OPEN_ERROR, BTA_GATTC_CONN_ST},
187 /* BTA_GATTC_INT_CANCEL_OPEN_OK_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_CONN_ST},
188
189 /* BTA_GATTC_API_READ_EVT */ {BTA_GATTC_READ, BTA_GATTC_CONN_ST},
190 /* BTA_GATTC_API_WRITE_EVT */ {BTA_GATTC_WRITE, BTA_GATTC_CONN_ST},
191 /* BTA_GATTC_API_EXEC_EVT */ {BTA_GATTC_EXEC, BTA_GATTC_CONN_ST},
192
193 /* BTA_GATTC_API_CLOSE_EVT */ {BTA_GATTC_CLOSE, BTA_GATTC_IDLE_ST}, //BTA_GATTC_CLOSING_ST
194
195 /* BTA_GATTC_API_SEARCH_EVT */ {BTA_GATTC_SEARCH, BTA_GATTC_CONN_ST},
196 /* BTA_GATTC_API_CONFIRM_EVT */ {BTA_GATTC_CONFIRM, BTA_GATTC_CONN_ST},
197 /* BTA_GATTC_API_READ_MULTI_EVT */ {BTA_GATTC_READ_MULTI, BTA_GATTC_CONN_ST},
198 /* BTA_GATTC_INT_CONN_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_CONN_ST},
199 /* BTA_GATTC_INT_DISCOVER_EVT */ {BTA_GATTC_START_DISCOVER, BTA_GATTC_DISCOVER_ST},
200 /* BTA_GATTC_DISCOVER_CMPL_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_CONN_ST},
201 /* BTA_GATTC_OP_CMPL_EVT */ {BTA_GATTC_OP_CMPL, BTA_GATTC_CONN_ST},
202
203 /* BTA_GATTC_INT_DISCONN_EVT */ {BTA_GATTC_CLOSE, BTA_GATTC_IDLE_ST},
204
205 /* ===> for cache loading, saving */
206 /* BTA_GATTC_START_CACHE_EVT */ {BTA_GATTC_CACHE_OPEN, BTA_GATTC_DISCOVER_ST},
207 /* BTA_GATTC_CI_CACHE_OPEN_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_CONN_ST},
208 /* BTA_GATTC_CI_CACHE_LOAD_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_CONN_ST},
209 /* BTA_GATTC_CI_CACHE_SAVE_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_CONN_ST}
210 };
211
212 /* state table for discover state */
213 static const UINT8 bta_gattc_st_discover[][BTA_GATTC_NUM_COLS] =
214 {
215 /* Event Action 1 Next state */
216 /* BTA_GATTC_API_OPEN_EVT */ {BTA_GATTC_OPEN_ERROR, BTA_GATTC_DISCOVER_ST},
217 /* BTA_GATTC_INT_OPEN_FAIL_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_DISCOVER_ST},
218 /* BTA_GATTC_API_CANCEL_OPEN_EVT */ {BTA_GATTC_CANCEL_OPEN_ERROR, BTA_GATTC_DISCOVER_ST},
219 /* BTA_GATTC_INT_CANCEL_OPEN_OK_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_DISCOVER_ST},
220
221 /* BTA_GATTC_API_READ_EVT */ {BTA_GATTC_Q_CMD, BTA_GATTC_DISCOVER_ST},
222 /* BTA_GATTC_API_WRITE_EVT */ {BTA_GATTC_Q_CMD, BTA_GATTC_DISCOVER_ST},
223 /* BTA_GATTC_API_EXEC_EVT */ {BTA_GATTC_Q_CMD, BTA_GATTC_DISCOVER_ST},
224
225 /* BTA_GATTC_API_CLOSE_EVT */ {BTA_GATTC_CLOSE, BTA_GATTC_IDLE_ST }, //BTA_GATTC_CLOSING_ST
226
227 /* BTA_GATTC_API_SEARCH_EVT */ {BTA_GATTC_Q_CMD, BTA_GATTC_DISCOVER_ST},
228 /* BTA_GATTC_API_CONFIRM_EVT */ {BTA_GATTC_CONFIRM, BTA_GATTC_DISCOVER_ST},
229 /* BTA_GATTC_API_READ_MULTI_EVT */ {BTA_GATTC_Q_CMD, BTA_GATTC_DISCOVER_ST},
230 /* BTA_GATTC_INT_CONN_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_DISCOVER_ST},
231 /* BTA_GATTC_INT_DISCOVER_EVT */ {BTA_GATTC_START_DISCOVER, BTA_GATTC_DISCOVER_ST},
232 /* BTA_GATTC_DISCOVER_CMPL_EVT */ {BTA_GATTC_DISC_CMPL, BTA_GATTC_CONN_ST},
233 /* BTA_GATTC_OP_CMPL_EVT */ {BTA_GATTC_IGNORE_OP_CMPL, BTA_GATTC_DISCOVER_ST},
234 /* BTA_GATTC_INT_DISCONN_EVT */ {BTA_GATTC_CLOSE, BTA_GATTC_IDLE_ST},
235
236 /* ===> for cache loading, saving */
237 /* BTA_GATTC_START_CACHE_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_DISCOVER_ST},
238 /* BTA_GATTC_CI_CACHE_OPEN_EVT */ {BTA_GATTC_CI_OPEN, BTA_GATTC_DISCOVER_ST},
239 /* BTA_GATTC_CI_CACHE_LOAD_EVT */ {BTA_GATTC_CI_LOAD, BTA_GATTC_DISCOVER_ST},
240 /* BTA_GATTC_CI_CACHE_SAVE_EVT */ {BTA_GATTC_CI_SAVE, BTA_GATTC_DISCOVER_ST}
241 };
242
243 /* type for state table */
244 typedef const UINT8 (*tBTA_GATTC_ST_TBL)[BTA_GATTC_NUM_COLS];
245
246 /* state table */
247 const tBTA_GATTC_ST_TBL bta_gattc_st_tbl[] =
248 {
249 bta_gattc_st_idle,
250 bta_gattc_st_w4_conn,
251 bta_gattc_st_connected,
252 bta_gattc_st_discover
253 };
254
255 /*****************************************************************************
256 ** Global data
257 *****************************************************************************/
258
259 /* GATTC control block */
260 #if BTA_DYNAMIC_MEMORY == FALSE
261 tBTA_GATTC_CB bta_gattc_cb;
262 #endif
263
264 #if BTA_GATT_DEBUG == TRUE
265 static char *gattc_evt_code(tBTA_GATTC_INT_EVT evt_code);
266 static char *gattc_state_code(tBTA_GATTC_STATE state_code);
267 #endif
268
269 /*******************************************************************************
270 **
271 ** Function bta_gattc_sm_execute
272 **
273 ** Description State machine event handling function for GATTC
274 **
275 **
276 ** Returns void
277 **
278 *******************************************************************************/
bta_gattc_sm_execute(tBTA_GATTC_CLCB * p_clcb,UINT16 event,tBTA_GATTC_DATA * p_data)279 void bta_gattc_sm_execute(tBTA_GATTC_CLCB *p_clcb, UINT16 event, tBTA_GATTC_DATA *p_data)
280 {
281 tBTA_GATTC_ST_TBL state_table;
282 UINT8 action;
283 int i;
284 #if BTA_GATT_DEBUG == TRUE
285 tBTA_GATTC_STATE in_state = p_clcb->state;
286 UINT16 in_event = event;
287 APPL_TRACE_DEBUG4("bta_gattc_sm_execute: State 0x%02x [%s], Event 0x%x[%s]", in_state,
288 gattc_state_code(in_state),
289 in_event,
290 gattc_evt_code(in_event));
291 #endif
292
293
294 /* look up the state table for the current state */
295 state_table = bta_gattc_st_tbl[p_clcb->state];
296
297 event &= 0x00FF;
298
299 /* set next state */
300 p_clcb->state = state_table[event][BTA_GATTC_NEXT_STATE];
301
302 /* execute action functions */
303 for (i = 0; i < BTA_GATTC_ACTIONS; i++)
304 {
305 if ((action = state_table[event][i]) != BTA_GATTC_IGNORE)
306 {
307 (*bta_gattc_action[action])(p_clcb, p_data);
308 }
309 else
310 {
311 break;
312 }
313 }
314
315 #if BTA_GATT_DEBUG == TRUE
316 if (in_state != p_clcb->state)
317 {
318 APPL_TRACE_DEBUG3("GATTC State Change: [%s] -> [%s] after Event [%s]",
319 gattc_state_code(in_state),
320 gattc_state_code(p_clcb->state),
321 gattc_evt_code(in_event));
322 }
323 #endif
324 }
325
326 /*******************************************************************************
327 **
328 ** Function bta_gattc_hdl_event
329 **
330 ** Description GATT client main event handling function.
331 **
332 **
333 ** Returns void
334 **
335 *******************************************************************************/
bta_gattc_hdl_event(BT_HDR * p_msg)336 BOOLEAN bta_gattc_hdl_event(BT_HDR *p_msg)
337 {
338 tBTA_GATTC_CB *p_cb = &bta_gattc_cb;
339 tBTA_GATTC_CLCB *p_clcb = NULL;
340
341 #if BTA_GATT_DEBUG == TRUE
342 APPL_TRACE_DEBUG1("bta_gattc_hdl_event: Event [%s]", gattc_evt_code(p_msg->event));
343 #endif
344 switch (p_msg->event)
345 {
346 case BTA_GATTC_API_REG_EVT:
347 bta_gattc_register(p_cb, (tBTA_GATTC_DATA *) p_msg);
348 break;
349
350 case BTA_GATTC_INT_START_IF_EVT:
351 bta_gattc_start_if(p_cb, (tBTA_GATTC_DATA *) p_msg);
352 break;
353
354 case BTA_GATTC_API_DEREG_EVT:
355 bta_gattc_deregister(p_cb, (tBTA_GATTC_DATA *) p_msg);
356 break;
357
358 case BTA_GATTC_INT_DEREG_EVT:
359 bta_gattc_int_deregister(p_cb, (tBTA_GATTC_DATA *) p_msg);
360 break;
361
362 case BTA_GATTC_API_OPEN_EVT:
363 bta_gattc_process_api_open(p_cb, (tBTA_GATTC_DATA *) p_msg);
364 break;
365
366 case BTA_GATTC_API_CANCEL_OPEN_EVT:
367 bta_gattc_process_api_open_cancel(p_cb, (tBTA_GATTC_DATA *) p_msg);
368 break;
369
370 default:
371 if ((p_clcb = bta_gattc_find_clcb_by_conn_id(p_msg->layer_specific))
372 != NULL)
373 {
374 bta_gattc_sm_execute(p_clcb, p_msg->event, (tBTA_GATTC_DATA *) p_msg);
375 }
376 else
377 {
378 APPL_TRACE_ERROR1("Unknown conn ID: %d", p_msg->layer_specific);
379 }
380
381 break;
382 }
383
384
385 return(TRUE);
386 }
387
388
389 /*****************************************************************************
390 ** Debug Functions
391 *****************************************************************************/
392 #if BTA_GATT_DEBUG == TRUE
393
394 /*******************************************************************************
395 **
396 ** Function gattc_evt_code
397 **
398 ** Description
399 **
400 ** Returns void
401 **
402 *******************************************************************************/
gattc_evt_code(tBTA_GATTC_INT_EVT evt_code)403 static char *gattc_evt_code(tBTA_GATTC_INT_EVT evt_code)
404 {
405 switch (evt_code)
406 {
407 case BTA_GATTC_API_OPEN_EVT:
408 return "BTA_GATTC_API_OPEN_EVT";
409 case BTA_GATTC_INT_OPEN_FAIL_EVT:
410 return "BTA_GATTC_INT_OPEN_FAIL_EVT";
411 case BTA_GATTC_API_CANCEL_OPEN_EVT:
412 return "BTA_GATTC_API_CANCEL_OPEN_EVT";
413 case BTA_GATTC_INT_CANCEL_OPEN_OK_EVT:
414 return "BTA_GATTC_INT_CANCEL_OPEN_OK_EVT";
415 case BTA_GATTC_API_READ_EVT:
416 return "BTA_GATTC_API_READ_EVT";
417 case BTA_GATTC_API_WRITE_EVT:
418 return "BTA_GATTC_API_WRITE_EVT";
419 case BTA_GATTC_API_EXEC_EVT:
420 return "BTA_GATTC_API_EXEC_EVT";
421 case BTA_GATTC_API_CLOSE_EVT:
422 return "BTA_GATTC_API_CLOSE_EVT";
423 case BTA_GATTC_API_SEARCH_EVT:
424 return "BTA_GATTC_API_SEARCH_EVT";
425 case BTA_GATTC_API_CONFIRM_EVT:
426 return "BTA_GATTC_API_CONFIRM_EVT";
427 case BTA_GATTC_API_READ_MULTI_EVT:
428 return "BTA_GATTC_API_READ_MULTI_EVT";
429 case BTA_GATTC_INT_CONN_EVT:
430 return "BTA_GATTC_INT_CONN_EVT";
431 case BTA_GATTC_INT_DISCOVER_EVT:
432 return "BTA_GATTC_INT_DISCOVER_EVT";
433 case BTA_GATTC_DISCOVER_CMPL_EVT:
434 return "BTA_GATTC_DISCOVER_CMPL_EVT";
435 case BTA_GATTC_OP_CMPL_EVT:
436 return "BTA_GATTC_OP_CMPL_EVT";
437 case BTA_GATTC_INT_DISCONN_EVT:
438 return "BTA_GATTC_INT_DISCONN_EVT";
439 case BTA_GATTC_START_CACHE_EVT:
440 return "BTA_GATTC_START_CACHE_EVT";
441 case BTA_GATTC_CI_CACHE_OPEN_EVT:
442 return "BTA_GATTC_CI_CACHE_OPEN_EVT";
443 case BTA_GATTC_CI_CACHE_LOAD_EVT:
444 return "BTA_GATTC_CI_CACHE_LOAD_EVT";
445 case BTA_GATTC_CI_CACHE_SAVE_EVT:
446 return "BTA_GATTC_CI_CACHE_SAVE_EVT";
447 case BTA_GATTC_INT_START_IF_EVT:
448 return "BTA_GATTC_INT_START_IF_EVT";
449 case BTA_GATTC_API_REG_EVT:
450 return "BTA_GATTC_API_REG_EVT";
451 case BTA_GATTC_API_DEREG_EVT:
452 return "BTA_GATTC_API_DEREG_EVT";
453
454 default:
455 return "unknown GATTC event code";
456 }
457 }
458
459 /*******************************************************************************
460 **
461 ** Function gattc_state_code
462 **
463 ** Description
464 **
465 ** Returns void
466 **
467 *******************************************************************************/
gattc_state_code(tBTA_GATTC_STATE state_code)468 static char *gattc_state_code(tBTA_GATTC_STATE state_code)
469 {
470 switch (state_code)
471 {
472 case BTA_GATTC_IDLE_ST:
473 return "GATTC_IDLE_ST";
474 case BTA_GATTC_W4_CONN_ST:
475 return "GATTC_W4_CONN_ST";
476 case BTA_GATTC_CONN_ST:
477 return "GATTC_CONN_ST";
478 case BTA_GATTC_DISCOVER_ST:
479 return "GATTC_DISCOVER_ST";
480 default:
481 return "unknown GATTC state code";
482 }
483 }
484
485 #endif /* Debug Functions */
486 #endif /* BTA_GATT_INCLUDED */
487