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