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 "bt_common.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_ERROR,
46 BTA_GATTC_CANCEL_OPEN,
47 BTA_GATTC_CANCEL_OPEN_OK,
48 BTA_GATTC_CANCEL_OPEN_ERROR,
49 BTA_GATTC_CONN,
50 BTA_GATTC_START_DISCOVER,
51 BTA_GATTC_DISC_CMPL,
52
53 BTA_GATTC_Q_CMD,
54 BTA_GATTC_CLOSE,
55 BTA_GATTC_CLOSE_FAIL,
56 BTA_GATTC_READ,
57 BTA_GATTC_WRITE,
58
59 BTA_GATTC_OP_CMPL,
60 BTA_GATTC_SEARCH,
61 BTA_GATTC_FAIL,
62 BTA_GATTC_CONFIRM,
63 BTA_GATTC_EXEC,
64 BTA_GATTC_READ_MULTI,
65 BTA_GATTC_IGNORE_OP_CMPL,
66 BTA_GATTC_DISC_CLOSE,
67 BTA_GATTC_RESTART_DISCOVER,
68 BTA_GATTC_CFG_MTU,
69
70 BTA_GATTC_IGNORE
71 };
72 /* type for action functions */
73 typedef void (*tBTA_GATTC_ACTION)(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
74
75 /* action function list */
76 const tBTA_GATTC_ACTION bta_gattc_action[] =
77 {
78 bta_gattc_open,
79 bta_gattc_open_fail,
80 bta_gattc_open_error,
81 bta_gattc_cancel_open,
82 bta_gattc_cancel_open_ok,
83 bta_gattc_cancel_open_error,
84 bta_gattc_conn,
85 bta_gattc_start_discover,
86 bta_gattc_disc_cmpl,
87
88 bta_gattc_q_cmd,
89 bta_gattc_close,
90 bta_gattc_close_fail,
91 bta_gattc_read,
92 bta_gattc_write,
93
94 bta_gattc_op_cmpl,
95 bta_gattc_search,
96 bta_gattc_fail,
97 bta_gattc_confirm,
98 bta_gattc_execute,
99 bta_gattc_read_multi,
100 bta_gattc_ignore_op_cmpl,
101 bta_gattc_disc_close,
102 bta_gattc_restart_discover,
103 bta_gattc_cfg_mtu
104 };
105
106
107 /* state table information */
108 #define BTA_GATTC_ACTIONS 1 /* number of actions */
109 #define BTA_GATTC_NEXT_STATE 1 /* position of next state */
110 #define BTA_GATTC_NUM_COLS 2 /* number of columns in state tables */
111
112 /* state table for idle state */
113 static const UINT8 bta_gattc_st_idle[][BTA_GATTC_NUM_COLS] =
114 {
115 /* Event Action 1 Next state */
116 /* BTA_GATTC_API_OPEN_EVT */ {BTA_GATTC_OPEN, BTA_GATTC_W4_CONN_ST},
117 /* BTA_GATTC_INT_OPEN_FAIL_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST},
118 /* BTA_GATTC_API_CANCEL_OPEN_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST},
119 /* BTA_GATTC_INT_CANCEL_OPEN_OK_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST},
120
121 /* BTA_GATTC_API_READ_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_IDLE_ST},
122 /* BTA_GATTC_API_WRITE_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_IDLE_ST},
123 /* BTA_GATTC_API_EXEC_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_IDLE_ST},
124 /* BTA_GATTC_API_CFG_MTU_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST},
125
126 /* BTA_GATTC_API_CLOSE_EVT */ {BTA_GATTC_CLOSE_FAIL, BTA_GATTC_IDLE_ST},
127
128 /* BTA_GATTC_API_SEARCH_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_IDLE_ST},
129 /* BTA_GATTC_API_CONFIRM_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_IDLE_ST},
130 /* BTA_GATTC_API_READ_MULTI_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_IDLE_ST},
131 /* BTA_GATTC_API_REFRESH_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST},
132
133 /* BTA_GATTC_INT_CONN_EVT */ {BTA_GATTC_CONN, BTA_GATTC_CONN_ST},
134 /* BTA_GATTC_INT_DISCOVER_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST},
135 /* BTA_GATTC_DISCOVER_CMPL_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST},
136 /* BTA_GATTC_OP_CMPL_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST},
137 /* BTA_GATTC_INT_DISCONN_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST},
138
139 };
140
141 /* state table for wait for open state */
142 static const UINT8 bta_gattc_st_w4_conn[][BTA_GATTC_NUM_COLS] =
143 {
144 /* Event Action 1 Next state */
145 /* BTA_GATTC_API_OPEN_EVT */ {BTA_GATTC_OPEN, BTA_GATTC_W4_CONN_ST},
146 /* BTA_GATTC_INT_OPEN_FAIL_EVT */ {BTA_GATTC_OPEN_FAIL, BTA_GATTC_IDLE_ST},
147 /* BTA_GATTC_API_CANCEL_OPEN_EVT */ {BTA_GATTC_CANCEL_OPEN, BTA_GATTC_W4_CONN_ST},
148 /* BTA_GATTC_INT_CANCEL_OPEN_OK_EVT */ {BTA_GATTC_CANCEL_OPEN_OK, BTA_GATTC_IDLE_ST},
149
150 /* BTA_GATTC_API_READ_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_W4_CONN_ST},
151 /* BTA_GATTC_API_WRITE_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_W4_CONN_ST},
152 /* BTA_GATTC_API_EXEC_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_W4_CONN_ST},
153 /* BTA_GATTC_API_CFG_MTU_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_W4_CONN_ST},
154
155 /* BTA_GATTC_API_CLOSE_EVT */ {BTA_GATTC_CANCEL_OPEN, BTA_GATTC_W4_CONN_ST},
156
157 /* BTA_GATTC_API_SEARCH_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_W4_CONN_ST},
158 /* BTA_GATTC_API_CONFIRM_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_W4_CONN_ST},
159 /* BTA_GATTC_API_READ_MULTI_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_W4_CONN_ST},
160 /* BTA_GATTC_API_REFRESH_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_W4_CONN_ST},
161
162 /* BTA_GATTC_INT_CONN_EVT */ {BTA_GATTC_CONN, BTA_GATTC_CONN_ST},
163 /* BTA_GATTC_INT_DISCOVER_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_W4_CONN_ST},
164 /* BTA_GATTC_DISCOVER_CMPL_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_W4_CONN_ST},
165 /* BTA_GATTC_OP_CMPL_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_W4_CONN_ST},
166 /* BTA_GATTC_INT_DISCONN_EVT */ {BTA_GATTC_OPEN_FAIL, BTA_GATTC_IDLE_ST},
167
168 };
169
170 /* state table for open state */
171 static const UINT8 bta_gattc_st_connected[][BTA_GATTC_NUM_COLS] =
172 {
173 /* Event Action 1 Next state */
174 /* BTA_GATTC_API_OPEN_EVT */ {BTA_GATTC_OPEN, BTA_GATTC_CONN_ST},
175 /* BTA_GATTC_INT_OPEN_FAIL_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_CONN_ST},
176 /* BTA_GATTC_API_CANCEL_OPEN_EVT */ {BTA_GATTC_CANCEL_OPEN_ERROR, BTA_GATTC_CONN_ST},
177 /* BTA_GATTC_INT_CANCEL_OPEN_OK_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_CONN_ST},
178
179 /* BTA_GATTC_API_READ_EVT */ {BTA_GATTC_READ, BTA_GATTC_CONN_ST},
180 /* BTA_GATTC_API_WRITE_EVT */ {BTA_GATTC_WRITE, BTA_GATTC_CONN_ST},
181 /* BTA_GATTC_API_EXEC_EVT */ {BTA_GATTC_EXEC, BTA_GATTC_CONN_ST},
182 /* BTA_GATTC_API_CFG_MTU_EVT */ {BTA_GATTC_CFG_MTU, BTA_GATTC_CONN_ST},
183
184 /* BTA_GATTC_API_CLOSE_EVT */ {BTA_GATTC_CLOSE, BTA_GATTC_IDLE_ST},
185
186 /* BTA_GATTC_API_SEARCH_EVT */ {BTA_GATTC_SEARCH, BTA_GATTC_CONN_ST},
187 /* BTA_GATTC_API_CONFIRM_EVT */ {BTA_GATTC_CONFIRM, BTA_GATTC_CONN_ST},
188 /* BTA_GATTC_API_READ_MULTI_EVT */ {BTA_GATTC_READ_MULTI, BTA_GATTC_CONN_ST},
189 /* BTA_GATTC_API_REFRESH_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_CONN_ST},
190
191 /* BTA_GATTC_INT_CONN_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_CONN_ST},
192 /* BTA_GATTC_INT_DISCOVER_EVT */ {BTA_GATTC_START_DISCOVER, BTA_GATTC_DISCOVER_ST},
193 /* BTA_GATTC_DISCOVER_CMPL_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_CONN_ST},
194 /* BTA_GATTC_OP_CMPL_EVT */ {BTA_GATTC_OP_CMPL, BTA_GATTC_CONN_ST},
195
196 /* BTA_GATTC_INT_DISCONN_EVT */ {BTA_GATTC_CLOSE, BTA_GATTC_IDLE_ST},
197
198 };
199
200 /* state table for discover state */
201 static const UINT8 bta_gattc_st_discover[][BTA_GATTC_NUM_COLS] =
202 {
203 /* Event Action 1 Next state */
204 /* BTA_GATTC_API_OPEN_EVT */ {BTA_GATTC_OPEN, BTA_GATTC_DISCOVER_ST},
205 /* BTA_GATTC_INT_OPEN_FAIL_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_DISCOVER_ST},
206 /* BTA_GATTC_API_CANCEL_OPEN_EVT */ {BTA_GATTC_CANCEL_OPEN_ERROR, BTA_GATTC_DISCOVER_ST},
207 /* BTA_GATTC_INT_CANCEL_OPEN_OK_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_DISCOVER_ST},
208
209 /* BTA_GATTC_API_READ_EVT */ {BTA_GATTC_Q_CMD, BTA_GATTC_DISCOVER_ST},
210 /* BTA_GATTC_API_WRITE_EVT */ {BTA_GATTC_Q_CMD, BTA_GATTC_DISCOVER_ST},
211 /* BTA_GATTC_API_EXEC_EVT */ {BTA_GATTC_Q_CMD, BTA_GATTC_DISCOVER_ST},
212 /* BTA_GATTC_API_CFG_MTU_EVT */ {BTA_GATTC_Q_CMD, BTA_GATTC_DISCOVER_ST},
213
214 /* BTA_GATTC_API_CLOSE_EVT */ {BTA_GATTC_DISC_CLOSE, BTA_GATTC_DISCOVER_ST},
215
216 /* BTA_GATTC_API_SEARCH_EVT */ {BTA_GATTC_Q_CMD, BTA_GATTC_DISCOVER_ST},
217 /* BTA_GATTC_API_CONFIRM_EVT */ {BTA_GATTC_CONFIRM, BTA_GATTC_DISCOVER_ST},
218 /* BTA_GATTC_API_READ_MULTI_EVT */ {BTA_GATTC_Q_CMD, BTA_GATTC_DISCOVER_ST},
219 /* BTA_GATTC_API_REFRESH_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_DISCOVER_ST},
220
221 /* BTA_GATTC_INT_CONN_EVT */ {BTA_GATTC_CONN, BTA_GATTC_DISCOVER_ST},
222 /* BTA_GATTC_INT_DISCOVER_EVT */ {BTA_GATTC_RESTART_DISCOVER, BTA_GATTC_DISCOVER_ST},
223 /* BTA_GATTC_DISCOVER_CMPL_EVT */ {BTA_GATTC_DISC_CMPL, BTA_GATTC_CONN_ST},
224 /* BTA_GATTC_OP_CMPL_EVT */ {BTA_GATTC_IGNORE_OP_CMPL, BTA_GATTC_DISCOVER_ST},
225 /* BTA_GATTC_INT_DISCONN_EVT */ {BTA_GATTC_CLOSE, BTA_GATTC_IDLE_ST},
226
227 };
228
229 /* type for state table */
230 typedef const UINT8 (*tBTA_GATTC_ST_TBL)[BTA_GATTC_NUM_COLS];
231
232 /* state table */
233 const tBTA_GATTC_ST_TBL bta_gattc_st_tbl[] =
234 {
235 bta_gattc_st_idle,
236 bta_gattc_st_w4_conn,
237 bta_gattc_st_connected,
238 bta_gattc_st_discover
239 };
240
241 /*****************************************************************************
242 ** Global data
243 *****************************************************************************/
244
245 /* GATTC control block */
246 #if BTA_DYNAMIC_MEMORY == FALSE
247 tBTA_GATTC_CB bta_gattc_cb;
248 #endif
249
250 #if BTA_GATT_DEBUG == TRUE
251 static char *gattc_evt_code(tBTA_GATTC_INT_EVT evt_code);
252 static char *gattc_state_code(tBTA_GATTC_STATE state_code);
253 #endif
254
255 /*******************************************************************************
256 **
257 ** Function bta_gattc_sm_execute
258 **
259 ** Description State machine event handling function for GATTC
260 **
261 **
262 ** Returns BOOLEAN : TRUE if queued client request buffer can be immediately released
263 ** else FALSE
264 **
265 *******************************************************************************/
bta_gattc_sm_execute(tBTA_GATTC_CLCB * p_clcb,UINT16 event,tBTA_GATTC_DATA * p_data)266 BOOLEAN bta_gattc_sm_execute(tBTA_GATTC_CLCB *p_clcb, UINT16 event, tBTA_GATTC_DATA *p_data)
267 {
268 tBTA_GATTC_ST_TBL state_table;
269 UINT8 action;
270 int i;
271 BOOLEAN rt = TRUE;
272 #if BTA_GATT_DEBUG == TRUE
273 tBTA_GATTC_STATE in_state = p_clcb->state;
274 UINT16 in_event = event;
275 APPL_TRACE_DEBUG("bta_gattc_sm_execute: State 0x%02x [%s], Event 0x%x[%s]", in_state,
276 gattc_state_code(in_state),
277 in_event,
278 gattc_evt_code(in_event));
279 #endif
280
281
282 /* look up the state table for the current state */
283 state_table = bta_gattc_st_tbl[p_clcb->state];
284
285 event &= 0x00FF;
286
287 /* set next state */
288 p_clcb->state = state_table[event][BTA_GATTC_NEXT_STATE];
289
290 /* execute action functions */
291 for (i = 0; i < BTA_GATTC_ACTIONS; i++)
292 {
293 if ((action = state_table[event][i]) != BTA_GATTC_IGNORE)
294 {
295 (*bta_gattc_action[action])(p_clcb, p_data);
296 if (p_clcb->p_q_cmd == p_data) {
297 /* buffer is queued, don't free in the bta dispatcher.
298 * we free it ourselves when a completion event is received.
299 */
300 rt = FALSE;
301 }
302 }
303 else
304 {
305 break;
306 }
307 }
308
309 #if BTA_GATT_DEBUG == TRUE
310 if (in_state != p_clcb->state)
311 {
312 APPL_TRACE_DEBUG("GATTC State Change: [%s] -> [%s] after Event [%s]",
313 gattc_state_code(in_state),
314 gattc_state_code(p_clcb->state),
315 gattc_evt_code(in_event));
316 }
317 #endif
318 return rt;
319 }
320
321 /*******************************************************************************
322 **
323 ** Function bta_gattc_hdl_event
324 **
325 ** Description GATT client main event handling function.
326 **
327 **
328 ** Returns BOOLEAN
329 **
330 *******************************************************************************/
bta_gattc_hdl_event(BT_HDR * p_msg)331 BOOLEAN bta_gattc_hdl_event(BT_HDR *p_msg)
332 {
333 tBTA_GATTC_CB *p_cb = &bta_gattc_cb;
334 tBTA_GATTC_CLCB *p_clcb = NULL;
335 tBTA_GATTC_RCB *p_clreg;
336 BOOLEAN rt = TRUE;
337 #if BTA_GATT_DEBUG == TRUE
338 APPL_TRACE_DEBUG("bta_gattc_hdl_event: Event [%s]", gattc_evt_code(p_msg->event));
339 #endif
340 switch (p_msg->event)
341 {
342 case BTA_GATTC_API_DISABLE_EVT:
343 bta_gattc_disable(p_cb);
344 break;
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 p_clreg = bta_gattc_cl_get_regcb(((tBTA_GATTC_DATA *)p_msg)->api_dereg.client_if);
356 bta_gattc_deregister(p_cb, p_clreg);
357 break;
358
359 case BTA_GATTC_API_OPEN_EVT:
360 bta_gattc_process_api_open(p_cb, (tBTA_GATTC_DATA *) p_msg);
361 break;
362
363 case BTA_GATTC_API_CANCEL_OPEN_EVT:
364 bta_gattc_process_api_open_cancel(p_cb, (tBTA_GATTC_DATA *) p_msg);
365 break;
366
367 case BTA_GATTC_API_REFRESH_EVT:
368 bta_gattc_process_api_refresh(p_cb, (tBTA_GATTC_DATA *) p_msg);
369 break;
370
371 #if BLE_INCLUDED == TRUE
372 case BTA_GATTC_API_LISTEN_EVT:
373 bta_gattc_listen(p_cb, (tBTA_GATTC_DATA *) p_msg);
374 break;
375 case BTA_GATTC_API_BROADCAST_EVT:
376 bta_gattc_broadcast(p_cb, (tBTA_GATTC_DATA *) p_msg);
377 break;
378 #endif
379
380 case BTA_GATTC_ENC_CMPL_EVT:
381 bta_gattc_process_enc_cmpl(p_cb, (tBTA_GATTC_DATA *) p_msg);
382 break;
383
384 default:
385 if (p_msg->event == BTA_GATTC_INT_CONN_EVT)
386 p_clcb = bta_gattc_find_int_conn_clcb((tBTA_GATTC_DATA *) p_msg);
387 else if (p_msg->event == BTA_GATTC_INT_DISCONN_EVT)
388 p_clcb = bta_gattc_find_int_disconn_clcb((tBTA_GATTC_DATA *) p_msg);
389 else
390 p_clcb = bta_gattc_find_clcb_by_conn_id(p_msg->layer_specific);
391
392 if (p_clcb != NULL)
393 {
394 rt = bta_gattc_sm_execute(p_clcb, p_msg->event, (tBTA_GATTC_DATA *) p_msg);
395 }
396 else
397 {
398 APPL_TRACE_DEBUG("Ignore unknown conn ID: %d", p_msg->layer_specific);
399 }
400
401 break;
402 }
403
404
405 return rt;
406 }
407
408
409 /*****************************************************************************
410 ** Debug Functions
411 *****************************************************************************/
412 #if BTA_GATT_DEBUG == TRUE
413
414 /*******************************************************************************
415 **
416 ** Function gattc_evt_code
417 **
418 ** Description
419 **
420 ** Returns void
421 **
422 *******************************************************************************/
gattc_evt_code(tBTA_GATTC_INT_EVT evt_code)423 static char *gattc_evt_code(tBTA_GATTC_INT_EVT evt_code)
424 {
425 switch (evt_code)
426 {
427 case BTA_GATTC_API_OPEN_EVT:
428 return "BTA_GATTC_API_OPEN_EVT";
429 case BTA_GATTC_INT_OPEN_FAIL_EVT:
430 return "BTA_GATTC_INT_OPEN_FAIL_EVT";
431 case BTA_GATTC_API_CANCEL_OPEN_EVT:
432 return "BTA_GATTC_API_CANCEL_OPEN_EVT";
433 case BTA_GATTC_INT_CANCEL_OPEN_OK_EVT:
434 return "BTA_GATTC_INT_CANCEL_OPEN_OK_EVT";
435 case BTA_GATTC_API_READ_EVT:
436 return "BTA_GATTC_API_READ_EVT";
437 case BTA_GATTC_API_WRITE_EVT:
438 return "BTA_GATTC_API_WRITE_EVT";
439 case BTA_GATTC_API_EXEC_EVT:
440 return "BTA_GATTC_API_EXEC_EVT";
441 case BTA_GATTC_API_CLOSE_EVT:
442 return "BTA_GATTC_API_CLOSE_EVT";
443 case BTA_GATTC_API_SEARCH_EVT:
444 return "BTA_GATTC_API_SEARCH_EVT";
445 case BTA_GATTC_API_CONFIRM_EVT:
446 return "BTA_GATTC_API_CONFIRM_EVT";
447 case BTA_GATTC_API_READ_MULTI_EVT:
448 return "BTA_GATTC_API_READ_MULTI_EVT";
449 case BTA_GATTC_INT_CONN_EVT:
450 return "BTA_GATTC_INT_CONN_EVT";
451 case BTA_GATTC_INT_DISCOVER_EVT:
452 return "BTA_GATTC_INT_DISCOVER_EVT";
453 case BTA_GATTC_DISCOVER_CMPL_EVT:
454 return "BTA_GATTC_DISCOVER_CMPL_EVT";
455 case BTA_GATTC_OP_CMPL_EVT:
456 return "BTA_GATTC_OP_CMPL_EVT";
457 case BTA_GATTC_INT_DISCONN_EVT:
458 return "BTA_GATTC_INT_DISCONN_EVT";
459 case BTA_GATTC_INT_START_IF_EVT:
460 return "BTA_GATTC_INT_START_IF_EVT";
461 case BTA_GATTC_API_REG_EVT:
462 return "BTA_GATTC_API_REG_EVT";
463 case BTA_GATTC_API_DEREG_EVT:
464 return "BTA_GATTC_API_DEREG_EVT";
465 case BTA_GATTC_API_REFRESH_EVT:
466 return "BTA_GATTC_API_REFRESH_EVT";
467 case BTA_GATTC_API_LISTEN_EVT:
468 return "BTA_GATTC_API_LISTEN_EVT";
469 case BTA_GATTC_API_DISABLE_EVT:
470 return "BTA_GATTC_API_DISABLE_EVT";
471 case BTA_GATTC_API_CFG_MTU_EVT:
472 return "BTA_GATTC_API_CFG_MTU_EVT";
473 default:
474 return "unknown GATTC event code";
475 }
476 }
477
478 /*******************************************************************************
479 **
480 ** Function gattc_state_code
481 **
482 ** Description
483 **
484 ** Returns void
485 **
486 *******************************************************************************/
gattc_state_code(tBTA_GATTC_STATE state_code)487 static char *gattc_state_code(tBTA_GATTC_STATE state_code)
488 {
489 switch (state_code)
490 {
491 case BTA_GATTC_IDLE_ST:
492 return "GATTC_IDLE_ST";
493 case BTA_GATTC_W4_CONN_ST:
494 return "GATTC_W4_CONN_ST";
495 case BTA_GATTC_CONN_ST:
496 return "GATTC_CONN_ST";
497 case BTA_GATTC_DISCOVER_ST:
498 return "GATTC_DISCOVER_ST";
499 default:
500 return "unknown GATTC state code";
501 }
502 }
503
504 #endif /* Debug Functions */
505 #endif /* BTA_GATT_INCLUDED */
506