1 /******************************************************************************
2 *
3 * Copyright 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 #define LOG_TAG "bta_gattc_main"
25
26 #include <base/logging.h>
27 #include <base/strings/stringprintf.h>
28
29 #include "bt_target.h" // Must be first to define build configuration"
30 #include "bta/gatt/bta_gattc_int.h"
31 #include "osi/include/log.h"
32 #include "stack/include/bt_hdr.h"
33
34 using base::StringPrintf;
35
36 /*****************************************************************************
37 * Constants and types
38 ****************************************************************************/
39
40 /* state machine action enumeration list */
41 enum {
42 BTA_GATTC_OPEN,
43 BTA_GATTC_OPEN_FAIL,
44 BTA_GATTC_OPEN_ERROR,
45 BTA_GATTC_CANCEL_OPEN,
46 BTA_GATTC_CANCEL_OPEN_OK,
47 BTA_GATTC_CANCEL_OPEN_ERROR,
48 BTA_GATTC_CONN,
49 BTA_GATTC_START_DISCOVER,
50 BTA_GATTC_DISC_CMPL,
51 BTA_GATTC_Q_CMD,
52 BTA_GATTC_CLOSE,
53 BTA_GATTC_CLOSE_FAIL,
54 BTA_GATTC_READ,
55 BTA_GATTC_WRITE,
56 BTA_GATTC_OP_CMPL,
57 BTA_GATTC_SEARCH,
58 BTA_GATTC_FAIL,
59 BTA_GATTC_CONFIRM,
60 BTA_GATTC_EXEC,
61 BTA_GATTC_READ_MULTI,
62 BTA_GATTC_OP_CMPL_DURING_DISCOVERY,
63 BTA_GATTC_DISC_CLOSE,
64 BTA_GATTC_RESTART_DISCOVER,
65 BTA_GATTC_CFG_MTU,
66
67 BTA_GATTC_IGNORE
68 };
69 /* type for action functions */
70 typedef void (*tBTA_GATTC_ACTION)(tBTA_GATTC_CLCB* p_clcb,
71 const tBTA_GATTC_DATA* p_data);
72
73 /* action function list */
74 const tBTA_GATTC_ACTION bta_gattc_action[] = {
75 bta_gattc_open, /* BTA_GATTC_OPEN */
76 bta_gattc_open_fail, /* BTA_GATTC_OPEN_FAIL */
77 bta_gattc_open_error, /* BTA_GATTC_OPEN_ERROR */
78 bta_gattc_cancel_open, /* BTA_GATTC_CANCEL_OPEN */
79 bta_gattc_cancel_open_ok, /* BTA_GATTC_CANCEL_OPEN_OK */
80 bta_gattc_cancel_open_error, /* BTA_GATTC_CANCEL_OPEN_ERROR */
81 bta_gattc_conn, /* BTA_GATTC_CONN */
82 bta_gattc_start_discover, /* BTA_GATTC_START_DISCOVER */
83 bta_gattc_disc_cmpl, /* BTA_GATTC_DISC_CMPL */
84 bta_gattc_q_cmd, /* BTA_GATTC_Q_CMD */
85 bta_gattc_close, /* BTA_GATTC_CLOSE */
86 bta_gattc_close_fail, /* BTA_GATTC_CLOSE_FAIL */
87 bta_gattc_read, /* BTA_GATTC_READ */
88 bta_gattc_write, /* BTA_GATTC_WRITE */
89 bta_gattc_op_cmpl, /* BTA_GATTC_OP_CMPL */
90 bta_gattc_search, /* BTA_GATTC_SEARCH */
91 bta_gattc_fail, /* BTA_GATTC_FAIL */
92 bta_gattc_confirm, /* BTA_GATTC_CONFIRM */
93 bta_gattc_execute, /* BTA_GATTC_EXEC */
94 bta_gattc_read_multi, /* BTA_GATTC_READ_MULTI */
95 bta_gattc_op_cmpl_during_discovery, /* BTA_GATTC_OP_CMPL_DURING_DISCOVERY */
96 bta_gattc_disc_close, /* BTA_GATTC_DISC_CLOSE */
97 bta_gattc_restart_discover, /* BTA_GATTC_RESTART_DISCOVER */
98 bta_gattc_cfg_mtu /* BTA_GATTC_CFG_MTU */
99 };
100
101 /* state table information */
102 #define BTA_GATTC_ACTIONS 1 /* number of actions */
103 #define BTA_GATTC_NEXT_STATE 1 /* position of next state */
104 #define BTA_GATTC_NUM_COLS 2 /* number of columns in state tables */
105
106 /* state table for idle state */
107 static const uint8_t bta_gattc_st_idle[][BTA_GATTC_NUM_COLS] = {
108 /* Event Action 1 Next state */
109 /* BTA_GATTC_API_OPEN_EVT */ {BTA_GATTC_OPEN,
110 BTA_GATTC_W4_CONN_ST},
111 /* BTA_GATTC_INT_OPEN_FAIL_EVT */ {BTA_GATTC_IGNORE,
112 BTA_GATTC_IDLE_ST},
113 /* BTA_GATTC_API_CANCEL_OPEN_EVT */ {BTA_GATTC_IGNORE,
114 BTA_GATTC_IDLE_ST},
115 /* BTA_GATTC_INT_CANCEL_OPEN_OK_EVT */ {BTA_GATTC_IGNORE,
116 BTA_GATTC_IDLE_ST},
117
118 /* BTA_GATTC_API_READ_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_IDLE_ST},
119 /* BTA_GATTC_API_WRITE_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_IDLE_ST},
120 /* BTA_GATTC_API_EXEC_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_IDLE_ST},
121 /* BTA_GATTC_API_CFG_MTU_EVT */ {BTA_GATTC_IGNORE,
122 BTA_GATTC_IDLE_ST},
123
124 /* BTA_GATTC_API_CLOSE_EVT */ {BTA_GATTC_CLOSE_FAIL,
125 BTA_GATTC_IDLE_ST},
126
127 /* BTA_GATTC_API_SEARCH_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_IDLE_ST},
128 /* BTA_GATTC_API_CONFIRM_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_IDLE_ST},
129 /* BTA_GATTC_API_READ_MULTI_EVT */ {BTA_GATTC_FAIL, 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
173 /* BTA_GATTC_INT_CONN_EVT */ {BTA_GATTC_CONN, BTA_GATTC_CONN_ST},
174 /* BTA_GATTC_INT_DISCOVER_EVT */ {BTA_GATTC_IGNORE,
175 BTA_GATTC_W4_CONN_ST},
176 /* BTA_GATTC_DISCOVER_CMPL_EVT */ {BTA_GATTC_IGNORE,
177 BTA_GATTC_W4_CONN_ST},
178 /* BTA_GATTC_OP_CMPL_EVT */ {BTA_GATTC_IGNORE,
179 BTA_GATTC_W4_CONN_ST},
180 /* BTA_GATTC_INT_DISCONN_EVT */ {BTA_GATTC_OPEN_FAIL,
181 BTA_GATTC_IDLE_ST},
182
183 };
184
185 /* state table for open state */
186 static const uint8_t bta_gattc_st_connected[][BTA_GATTC_NUM_COLS] = {
187 /* Event Action 1 Next state */
188 /* BTA_GATTC_API_OPEN_EVT */ {BTA_GATTC_OPEN, BTA_GATTC_CONN_ST},
189 /* BTA_GATTC_INT_OPEN_FAIL_EVT */ {BTA_GATTC_IGNORE,
190 BTA_GATTC_CONN_ST},
191 /* BTA_GATTC_API_CANCEL_OPEN_EVT */ {BTA_GATTC_CANCEL_OPEN_ERROR,
192 BTA_GATTC_CONN_ST},
193 /* BTA_GATTC_INT_CANCEL_OPEN_OK_EVT */ {BTA_GATTC_IGNORE,
194 BTA_GATTC_CONN_ST},
195
196 /* BTA_GATTC_API_READ_EVT */ {BTA_GATTC_READ, BTA_GATTC_CONN_ST},
197 /* BTA_GATTC_API_WRITE_EVT */ {BTA_GATTC_WRITE, BTA_GATTC_CONN_ST},
198 /* BTA_GATTC_API_EXEC_EVT */ {BTA_GATTC_EXEC, BTA_GATTC_CONN_ST},
199 /* BTA_GATTC_API_CFG_MTU_EVT */ {BTA_GATTC_CFG_MTU,
200 BTA_GATTC_CONN_ST},
201
202 /* BTA_GATTC_API_CLOSE_EVT */ {BTA_GATTC_CLOSE, BTA_GATTC_IDLE_ST},
203
204 /* BTA_GATTC_API_SEARCH_EVT */ {BTA_GATTC_SEARCH,
205 BTA_GATTC_CONN_ST},
206 /* BTA_GATTC_API_CONFIRM_EVT */ {BTA_GATTC_CONFIRM,
207 BTA_GATTC_CONN_ST},
208 /* BTA_GATTC_API_READ_MULTI_EVT */ {BTA_GATTC_READ_MULTI,
209 BTA_GATTC_CONN_ST},
210
211 /* BTA_GATTC_INT_CONN_EVT */ {BTA_GATTC_IGNORE,
212 BTA_GATTC_CONN_ST},
213 /* BTA_GATTC_INT_DISCOVER_EVT */ {BTA_GATTC_START_DISCOVER,
214 BTA_GATTC_DISCOVER_ST},
215 /* BTA_GATTC_DISCOVER_CMPL_EVT */ {BTA_GATTC_IGNORE,
216 BTA_GATTC_CONN_ST},
217 /* BTA_GATTC_OP_CMPL_EVT */ {BTA_GATTC_OP_CMPL,
218 BTA_GATTC_CONN_ST},
219
220 /* BTA_GATTC_INT_DISCONN_EVT */ {BTA_GATTC_CLOSE, BTA_GATTC_IDLE_ST},
221
222 };
223
224 /* state table for discover state */
225 static const uint8_t bta_gattc_st_discover[][BTA_GATTC_NUM_COLS] = {
226 /* Event Action 1 Next state */
227 /* BTA_GATTC_API_OPEN_EVT */ {BTA_GATTC_OPEN,
228 BTA_GATTC_DISCOVER_ST},
229 /* BTA_GATTC_INT_OPEN_FAIL_EVT */ {BTA_GATTC_IGNORE,
230 BTA_GATTC_DISCOVER_ST},
231 /* BTA_GATTC_API_CANCEL_OPEN_EVT */ {BTA_GATTC_CANCEL_OPEN_ERROR,
232 BTA_GATTC_DISCOVER_ST},
233 /* BTA_GATTC_INT_CANCEL_OPEN_OK_EVT */ {BTA_GATTC_FAIL,
234 BTA_GATTC_DISCOVER_ST},
235
236 /* BTA_GATTC_API_READ_EVT */ {BTA_GATTC_Q_CMD,
237 BTA_GATTC_DISCOVER_ST},
238 /* BTA_GATTC_API_WRITE_EVT */ {BTA_GATTC_Q_CMD,
239 BTA_GATTC_DISCOVER_ST},
240 /* BTA_GATTC_API_EXEC_EVT */ {BTA_GATTC_Q_CMD,
241 BTA_GATTC_DISCOVER_ST},
242 /* BTA_GATTC_API_CFG_MTU_EVT */ {BTA_GATTC_Q_CMD,
243 BTA_GATTC_DISCOVER_ST},
244
245 /* BTA_GATTC_API_CLOSE_EVT */ {BTA_GATTC_DISC_CLOSE,
246 BTA_GATTC_DISCOVER_ST},
247
248 /* BTA_GATTC_API_SEARCH_EVT */ {BTA_GATTC_Q_CMD,
249 BTA_GATTC_DISCOVER_ST},
250 /* BTA_GATTC_API_CONFIRM_EVT */ {BTA_GATTC_CONFIRM,
251 BTA_GATTC_DISCOVER_ST},
252 /* BTA_GATTC_API_READ_MULTI_EVT */ {BTA_GATTC_Q_CMD,
253 BTA_GATTC_DISCOVER_ST},
254
255 /* BTA_GATTC_INT_CONN_EVT */ {BTA_GATTC_CONN,
256 BTA_GATTC_DISCOVER_ST},
257 /* BTA_GATTC_INT_DISCOVER_EVT */ {BTA_GATTC_RESTART_DISCOVER,
258 BTA_GATTC_DISCOVER_ST},
259 /* BTA_GATTC_DISCOVER_CMPL_EVT */ {BTA_GATTC_DISC_CMPL,
260 BTA_GATTC_CONN_ST},
261 /* BTA_GATTC_OP_CMPL_EVT */ {BTA_GATTC_OP_CMPL_DURING_DISCOVERY,
262 BTA_GATTC_DISCOVER_ST},
263 /* BTA_GATTC_INT_DISCONN_EVT */ {BTA_GATTC_CLOSE, BTA_GATTC_IDLE_ST},
264
265 };
266
267 /* type for state table */
268 typedef const uint8_t (*tBTA_GATTC_ST_TBL)[BTA_GATTC_NUM_COLS];
269
270 /* state table */
271 const tBTA_GATTC_ST_TBL bta_gattc_st_tbl[] = {
272 bta_gattc_st_idle, /* BTA_GATTC_IDLE_ST */
273 bta_gattc_st_w4_conn, /* BTA_GATTC_W4_CONN_ST */
274 bta_gattc_st_connected, /* BTA_GATTC_CONN_ST */
275 bta_gattc_st_discover /* BTA_GATTC_DISCOVER_ST */
276 };
277
278 /*****************************************************************************
279 * Global data
280 ****************************************************************************/
281
282 /* GATTC control block */
283 tBTA_GATTC_CB bta_gattc_cb;
284
285 #if (BTA_GATT_DEBUG == TRUE)
286 static const char* gattc_evt_code(tBTA_GATTC_INT_EVT evt_code);
287 static const char* gattc_state_code(tBTA_GATTC_STATE state_code);
288 #endif
289
290 /*******************************************************************************
291 *
292 * Function bta_gattc_sm_execute
293 *
294 * Description State machine event handling function for GATTC
295 *
296 *
297 * Returns bool : true if queued client request buffer can be
298 * immediately released, else false
299 *
300 ******************************************************************************/
bta_gattc_sm_execute(tBTA_GATTC_CLCB * p_clcb,uint16_t event,const tBTA_GATTC_DATA * p_data)301 bool bta_gattc_sm_execute(tBTA_GATTC_CLCB* p_clcb, uint16_t event,
302 const tBTA_GATTC_DATA* p_data) {
303 tBTA_GATTC_ST_TBL state_table;
304 uint8_t action;
305 int i;
306 bool rt = true;
307 tBTA_GATTC_STATE in_state = p_clcb->state;
308 uint16_t in_event = event;
309 #if (BTA_GATT_DEBUG == TRUE)
310 VLOG(1) << StringPrintf("%s: State 0x%02x [%s], Event 0x%x[%s]", __func__,
311 in_state, gattc_state_code(in_state), in_event,
312 gattc_evt_code(in_event));
313 #else
314 VLOG(1) << StringPrintf("%s: State 0x%02x, Event 0x%x", __func__, in_state,
315 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 (bta_gattc_is_data_queued(p_clcb, 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 VLOG(1) << StringPrintf("GATTC State Change: [%s] -> [%s] after Event [%s]",
345 gattc_state_code(in_state),
346 gattc_state_code(p_clcb->state),
347 gattc_evt_code(in_event));
348 }
349 #else
350 VLOG(1) << StringPrintf(
351 "%s: GATTC State Change: 0x%02x -> 0x%02x after Event 0x%x", __func__,
352 in_state, p_clcb->state, in_event);
353 #endif
354 return rt;
355 }
356
357 /*******************************************************************************
358 *
359 * Function bta_gattc_hdl_event
360 *
361 * Description GATT client main event handling function.
362 *
363 *
364 * Returns bool
365 *
366 ******************************************************************************/
bta_gattc_hdl_event(BT_HDR_RIGID * p_msg)367 bool bta_gattc_hdl_event(BT_HDR_RIGID* p_msg) {
368 tBTA_GATTC_CLCB* p_clcb = NULL;
369 bool rt = true;
370 #if (BTA_GATT_DEBUG == TRUE)
371 VLOG(1) << __func__ << ": Event:" << gattc_evt_code(p_msg->event);
372 #endif
373 switch (p_msg->event) {
374
375 case BTA_GATTC_API_OPEN_EVT:
376 bta_gattc_process_api_open((tBTA_GATTC_DATA*)p_msg);
377 break;
378
379 case BTA_GATTC_API_CANCEL_OPEN_EVT:
380 bta_gattc_process_api_open_cancel((tBTA_GATTC_DATA*)p_msg);
381 break;
382
383 default:
384 if (p_msg->event == BTA_GATTC_INT_CONN_EVT)
385 p_clcb = bta_gattc_find_int_conn_clcb((tBTA_GATTC_DATA*)p_msg);
386 else if (p_msg->event == BTA_GATTC_INT_DISCONN_EVT)
387 p_clcb = bta_gattc_find_int_disconn_clcb((tBTA_GATTC_DATA*)p_msg);
388 else
389 p_clcb = bta_gattc_find_clcb_by_conn_id(p_msg->layer_specific);
390
391 if (p_clcb != nullptr) {
392 rt = bta_gattc_sm_execute(p_clcb, p_msg->event,
393 (const tBTA_GATTC_DATA*)p_msg);
394 } else {
395 LOG_ERROR("Ignore unknown conn ID: %d", +p_msg->layer_specific);
396 }
397
398 break;
399 }
400
401 return rt;
402 }
403
404 /*****************************************************************************
405 * Debug Functions
406 ****************************************************************************/
407 #if (BTA_GATT_DEBUG == TRUE)
408
409 /*******************************************************************************
410 *
411 * Function gattc_evt_code
412 *
413 * Description
414 *
415 * Returns void
416 *
417 ******************************************************************************/
gattc_evt_code(tBTA_GATTC_INT_EVT evt_code)418 static const char* gattc_evt_code(tBTA_GATTC_INT_EVT evt_code) {
419 switch (evt_code) {
420 case BTA_GATTC_API_OPEN_EVT:
421 return "BTA_GATTC_API_OPEN_EVT";
422 case BTA_GATTC_INT_OPEN_FAIL_EVT:
423 return "BTA_GATTC_INT_OPEN_FAIL_EVT";
424 case BTA_GATTC_API_CANCEL_OPEN_EVT:
425 return "BTA_GATTC_API_CANCEL_OPEN_EVT";
426 case BTA_GATTC_INT_CANCEL_OPEN_OK_EVT:
427 return "BTA_GATTC_INT_CANCEL_OPEN_OK_EVT";
428 case BTA_GATTC_API_READ_EVT:
429 return "BTA_GATTC_API_READ_EVT";
430 case BTA_GATTC_API_WRITE_EVT:
431 return "BTA_GATTC_API_WRITE_EVT";
432 case BTA_GATTC_API_EXEC_EVT:
433 return "BTA_GATTC_API_EXEC_EVT";
434 case BTA_GATTC_API_CLOSE_EVT:
435 return "BTA_GATTC_API_CLOSE_EVT";
436 case BTA_GATTC_API_SEARCH_EVT:
437 return "BTA_GATTC_API_SEARCH_EVT";
438 case BTA_GATTC_API_CONFIRM_EVT:
439 return "BTA_GATTC_API_CONFIRM_EVT";
440 case BTA_GATTC_API_READ_MULTI_EVT:
441 return "BTA_GATTC_API_READ_MULTI_EVT";
442 case BTA_GATTC_INT_CONN_EVT:
443 return "BTA_GATTC_INT_CONN_EVT";
444 case BTA_GATTC_INT_DISCOVER_EVT:
445 return "BTA_GATTC_INT_DISCOVER_EVT";
446 case BTA_GATTC_DISCOVER_CMPL_EVT:
447 return "BTA_GATTC_DISCOVER_CMPL_EVT";
448 case BTA_GATTC_OP_CMPL_EVT:
449 return "BTA_GATTC_OP_CMPL_EVT";
450 case BTA_GATTC_INT_DISCONN_EVT:
451 return "BTA_GATTC_INT_DISCONN_EVT";
452 case BTA_GATTC_API_CFG_MTU_EVT:
453 return "BTA_GATTC_API_CFG_MTU_EVT";
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 const char* gattc_state_code(tBTA_GATTC_STATE state_code) {
469 switch (state_code) {
470 case BTA_GATTC_IDLE_ST:
471 return "GATTC_IDLE_ST";
472 case BTA_GATTC_W4_CONN_ST:
473 return "GATTC_W4_CONN_ST";
474 case BTA_GATTC_CONN_ST:
475 return "GATTC_CONN_ST";
476 case BTA_GATTC_DISCOVER_ST:
477 return "GATTC_DISCOVER_ST";
478 default:
479 return "unknown GATTC state code";
480 }
481 }
482
483 #endif /* Debug Functions */
484