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_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_CI_OPEN, 66 BTA_GATTC_CI_LOAD, 67 BTA_GATTC_CI_SAVE, 68 BTA_GATTC_CACHE_OPEN, 69 BTA_GATTC_IGNORE_OP_CMPL, 70 BTA_GATTC_DISC_CLOSE, 71 BTA_GATTC_RESTART_DISCOVER, 72 73 BTA_GATTC_IGNORE 74 }; 75 /* type for action functions */ 76 typedef void (*tBTA_GATTC_ACTION)(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data); 77 78 /* action function list */ 79 const tBTA_GATTC_ACTION bta_gattc_action[] = 80 { 81 bta_gattc_open, 82 bta_gattc_open_fail, 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 bta_gattc_disc_close, 109 bta_gattc_restart_discover 110 }; 111 112 113 /* state table information */ 114 #define BTA_GATTC_ACTIONS 1 /* number of actions */ 115 #define BTA_GATTC_NEXT_STATE 1 /* position of next state */ 116 #define BTA_GATTC_NUM_COLS 2 /* number of columns in state tables */ 117 118 /* state table for idle state */ 119 static const UINT8 bta_gattc_st_idle[][BTA_GATTC_NUM_COLS] = 120 { 121 /* Event Action 1 Next state */ 122 /* BTA_GATTC_API_OPEN_EVT */ {BTA_GATTC_OPEN, BTA_GATTC_W4_CONN_ST}, 123 /* BTA_GATTC_INT_OPEN_FAIL_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST}, 124 /* BTA_GATTC_API_CANCEL_OPEN_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST}, 125 /* BTA_GATTC_INT_CANCEL_OPEN_OK_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST}, 126 127 /* BTA_GATTC_API_READ_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_IDLE_ST}, 128 /* BTA_GATTC_API_WRITE_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_IDLE_ST}, 129 /* BTA_GATTC_API_EXEC_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_IDLE_ST}, 130 131 /* BTA_GATTC_API_CLOSE_EVT */ {BTA_GATTC_CLOSE_FAIL, BTA_GATTC_IDLE_ST}, 132 133 /* BTA_GATTC_API_SEARCH_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_IDLE_ST}, 134 /* BTA_GATTC_API_CONFIRM_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_IDLE_ST}, 135 /* BTA_GATTC_API_READ_MULTI_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_IDLE_ST}, 136 /* BTA_GATTC_API_REFRESH_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST}, 137 138 /* BTA_GATTC_INT_CONN_EVT */ {BTA_GATTC_CONN, BTA_GATTC_CONN_ST}, 139 /* BTA_GATTC_INT_DISCOVER_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST}, 140 /* BTA_GATTC_DISCOVER_CMPL_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST}, 141 /* BTA_GATTC_OP_CMPL_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST}, 142 /* BTA_GATTC_INT_DISCONN_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST}, 143 144 145 /* ===> for cache loading, saving */ 146 /* BTA_GATTC_START_CACHE_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST}, 147 /* BTA_GATTC_CI_CACHE_OPEN_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST}, 148 /* BTA_GATTC_CI_CACHE_LOAD_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST}, 149 /* BTA_GATTC_CI_CACHE_SAVE_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST} 150 }; 151 152 /* state table for wait for open state */ 153 static const UINT8 bta_gattc_st_w4_conn[][BTA_GATTC_NUM_COLS] = 154 { 155 /* Event Action 1 Next state */ 156 /* BTA_GATTC_API_OPEN_EVT */ {BTA_GATTC_OPEN, BTA_GATTC_W4_CONN_ST}, 157 /* BTA_GATTC_INT_OPEN_FAIL_EVT */ {BTA_GATTC_OPEN_FAIL, BTA_GATTC_IDLE_ST}, 158 /* BTA_GATTC_API_CANCEL_OPEN_EVT */ {BTA_GATTC_CANCEL_OPEN, BTA_GATTC_W4_CONN_ST}, 159 /* BTA_GATTC_INT_CANCEL_OPEN_OK_EVT */ {BTA_GATTC_CANCEL_OPEN_OK, BTA_GATTC_IDLE_ST}, 160 161 /* BTA_GATTC_API_READ_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_W4_CONN_ST}, 162 /* BTA_GATTC_API_WRITE_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_W4_CONN_ST}, 163 /* BTA_GATTC_API_EXEC_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_W4_CONN_ST}, 164 165 /* BTA_GATTC_API_CLOSE_EVT */ {BTA_GATTC_CLOSE_FAIL, BTA_GATTC_W4_CONN_ST}, 166 167 /* BTA_GATTC_API_SEARCH_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_W4_CONN_ST}, 168 /* BTA_GATTC_API_CONFIRM_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_W4_CONN_ST}, 169 /* BTA_GATTC_API_READ_MULTI_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_W4_CONN_ST}, 170 /* BTA_GATTC_API_REFRESH_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_W4_CONN_ST}, 171 172 /* BTA_GATTC_INT_CONN_EVT */ {BTA_GATTC_CONN, BTA_GATTC_CONN_ST}, 173 /* BTA_GATTC_INT_DISCOVER_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_W4_CONN_ST}, 174 /* BTA_GATTC_DISCOVER_CMPL_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_W4_CONN_ST}, 175 /* BTA_GATTC_OP_CMPL_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_W4_CONN_ST}, 176 /* BTA_GATTC_INT_DISCONN_EVT */ {BTA_GATTC_CLOSE, BTA_GATTC_IDLE_ST}, 177 178 /* ===> for cache loading, saving */ 179 /* BTA_GATTC_START_CACHE_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_W4_CONN_ST}, 180 /* BTA_GATTC_CI_CACHE_OPEN_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_W4_CONN_ST}, 181 /* BTA_GATTC_CI_CACHE_LOAD_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_W4_CONN_ST}, 182 /* BTA_GATTC_CI_CACHE_SAVE_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_W4_CONN_ST} 183 }; 184 185 /* state table for open state */ 186 static const UINT8 bta_gattc_st_connected[][BTA_GATTC_NUM_COLS] = 187 { 188 /* Event Action 1 Next state */ 189 /* BTA_GATTC_API_OPEN_EVT */ {BTA_GATTC_OPEN_ERROR, BTA_GATTC_CONN_ST}, 190 /* BTA_GATTC_INT_OPEN_FAIL_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_CONN_ST}, 191 /* BTA_GATTC_API_CANCEL_OPEN_EVT */ {BTA_GATTC_CANCEL_OPEN_ERROR, BTA_GATTC_CONN_ST}, 192 /* BTA_GATTC_INT_CANCEL_OPEN_OK_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_CONN_ST}, 193 194 /* BTA_GATTC_API_READ_EVT */ {BTA_GATTC_READ, BTA_GATTC_CONN_ST}, 195 /* BTA_GATTC_API_WRITE_EVT */ {BTA_GATTC_WRITE, BTA_GATTC_CONN_ST}, 196 /* BTA_GATTC_API_EXEC_EVT */ {BTA_GATTC_EXEC, BTA_GATTC_CONN_ST}, 197 198 /* BTA_GATTC_API_CLOSE_EVT */ {BTA_GATTC_CLOSE, BTA_GATTC_IDLE_ST}, 199 200 /* BTA_GATTC_API_SEARCH_EVT */ {BTA_GATTC_SEARCH, BTA_GATTC_CONN_ST}, 201 /* BTA_GATTC_API_CONFIRM_EVT */ {BTA_GATTC_CONFIRM, BTA_GATTC_CONN_ST}, 202 /* BTA_GATTC_API_READ_MULTI_EVT */ {BTA_GATTC_READ_MULTI, BTA_GATTC_CONN_ST}, 203 /* BTA_GATTC_API_REFRESH_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_CONN_ST}, 204 205 /* BTA_GATTC_INT_CONN_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_CONN_ST}, 206 /* BTA_GATTC_INT_DISCOVER_EVT */ {BTA_GATTC_START_DISCOVER, BTA_GATTC_DISCOVER_ST}, 207 /* BTA_GATTC_DISCOVER_CMPL_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_CONN_ST}, 208 /* BTA_GATTC_OP_CMPL_EVT */ {BTA_GATTC_OP_CMPL, BTA_GATTC_CONN_ST}, 209 210 /* BTA_GATTC_INT_DISCONN_EVT */ {BTA_GATTC_CLOSE, BTA_GATTC_IDLE_ST}, 211 212 /* ===> for cache loading, saving */ 213 /* BTA_GATTC_START_CACHE_EVT */ {BTA_GATTC_CACHE_OPEN, BTA_GATTC_DISCOVER_ST}, 214 /* BTA_GATTC_CI_CACHE_OPEN_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_CONN_ST}, 215 /* BTA_GATTC_CI_CACHE_LOAD_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_CONN_ST}, 216 /* BTA_GATTC_CI_CACHE_SAVE_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_CONN_ST} 217 }; 218 219 /* state table for discover state */ 220 static const UINT8 bta_gattc_st_discover[][BTA_GATTC_NUM_COLS] = 221 { 222 /* Event Action 1 Next state */ 223 /* BTA_GATTC_API_OPEN_EVT */ {BTA_GATTC_OPEN_ERROR, BTA_GATTC_DISCOVER_ST}, 224 /* BTA_GATTC_INT_OPEN_FAIL_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_DISCOVER_ST}, 225 /* BTA_GATTC_API_CANCEL_OPEN_EVT */ {BTA_GATTC_CANCEL_OPEN_ERROR, BTA_GATTC_DISCOVER_ST}, 226 /* BTA_GATTC_INT_CANCEL_OPEN_OK_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_DISCOVER_ST}, 227 228 /* BTA_GATTC_API_READ_EVT */ {BTA_GATTC_Q_CMD, BTA_GATTC_DISCOVER_ST}, 229 /* BTA_GATTC_API_WRITE_EVT */ {BTA_GATTC_Q_CMD, BTA_GATTC_DISCOVER_ST}, 230 /* BTA_GATTC_API_EXEC_EVT */ {BTA_GATTC_Q_CMD, BTA_GATTC_DISCOVER_ST}, 231 232 /* BTA_GATTC_API_CLOSE_EVT */ {BTA_GATTC_DISC_CLOSE, BTA_GATTC_DISCOVER_ST}, 233 234 /* BTA_GATTC_API_SEARCH_EVT */ {BTA_GATTC_Q_CMD, BTA_GATTC_DISCOVER_ST}, 235 /* BTA_GATTC_API_CONFIRM_EVT */ {BTA_GATTC_CONFIRM, BTA_GATTC_DISCOVER_ST}, 236 /* BTA_GATTC_API_READ_MULTI_EVT */ {BTA_GATTC_Q_CMD, BTA_GATTC_DISCOVER_ST}, 237 /* BTA_GATTC_API_REFRESH_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_DISCOVER_ST}, 238 239 /* BTA_GATTC_INT_CONN_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_DISCOVER_ST}, 240 /* BTA_GATTC_INT_DISCOVER_EVT */ {BTA_GATTC_RESTART_DISCOVER, BTA_GATTC_DISCOVER_ST}, 241 /* BTA_GATTC_DISCOVER_CMPL_EVT */ {BTA_GATTC_DISC_CMPL, BTA_GATTC_CONN_ST}, 242 /* BTA_GATTC_OP_CMPL_EVT */ {BTA_GATTC_IGNORE_OP_CMPL, BTA_GATTC_DISCOVER_ST}, 243 /* BTA_GATTC_INT_DISCONN_EVT */ {BTA_GATTC_CLOSE, BTA_GATTC_IDLE_ST}, 244 245 /* ===> for cache loading, saving */ 246 /* BTA_GATTC_START_CACHE_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_DISCOVER_ST}, 247 /* BTA_GATTC_CI_CACHE_OPEN_EVT */ {BTA_GATTC_CI_OPEN, BTA_GATTC_DISCOVER_ST}, 248 /* BTA_GATTC_CI_CACHE_LOAD_EVT */ {BTA_GATTC_CI_LOAD, BTA_GATTC_DISCOVER_ST}, 249 /* BTA_GATTC_CI_CACHE_SAVE_EVT */ {BTA_GATTC_CI_SAVE, BTA_GATTC_DISCOVER_ST} 250 }; 251 252 /* type for state table */ 253 typedef const UINT8 (*tBTA_GATTC_ST_TBL)[BTA_GATTC_NUM_COLS]; 254 255 /* state table */ 256 const tBTA_GATTC_ST_TBL bta_gattc_st_tbl[] = 257 { 258 bta_gattc_st_idle, 259 bta_gattc_st_w4_conn, 260 bta_gattc_st_connected, 261 bta_gattc_st_discover 262 }; 263 264 /***************************************************************************** 265 ** Global data 266 *****************************************************************************/ 267 268 /* GATTC control block */ 269 #if BTA_DYNAMIC_MEMORY == FALSE 270 tBTA_GATTC_CB bta_gattc_cb; 271 #endif 272 273 #if BTA_GATT_DEBUG == TRUE 274 static char *gattc_evt_code(tBTA_GATTC_INT_EVT evt_code); 275 static char *gattc_state_code(tBTA_GATTC_STATE state_code); 276 #endif 277 278 /******************************************************************************* 279 ** 280 ** Function bta_gattc_sm_execute 281 ** 282 ** Description State machine event handling function for GATTC 283 ** 284 ** 285 ** Returns void 286 ** 287 *******************************************************************************/ 288 void bta_gattc_sm_execute(tBTA_GATTC_CLCB *p_clcb, UINT16 event, tBTA_GATTC_DATA *p_data) 289 { 290 tBTA_GATTC_ST_TBL state_table; 291 UINT8 action; 292 int i; 293 #if BTA_GATT_DEBUG == TRUE 294 tBTA_GATTC_STATE in_state = p_clcb->state; 295 UINT16 in_event = event; 296 APPL_TRACE_DEBUG4("bta_gattc_sm_execute: State 0x%02x [%s], Event 0x%x[%s]", in_state, 297 gattc_state_code(in_state), 298 in_event, 299 gattc_evt_code(in_event)); 300 #endif 301 302 303 /* look up the state table for the current state */ 304 state_table = bta_gattc_st_tbl[p_clcb->state]; 305 306 event &= 0x00FF; 307 308 /* set next state */ 309 p_clcb->state = state_table[event][BTA_GATTC_NEXT_STATE]; 310 311 /* execute action functions */ 312 for (i = 0; i < BTA_GATTC_ACTIONS; i++) 313 { 314 if ((action = state_table[event][i]) != BTA_GATTC_IGNORE) 315 { 316 (*bta_gattc_action[action])(p_clcb, p_data); 317 } 318 else 319 { 320 break; 321 } 322 } 323 324 #if BTA_GATT_DEBUG == TRUE 325 if (in_state != p_clcb->state) 326 { 327 APPL_TRACE_DEBUG3("GATTC State Change: [%s] -> [%s] after Event [%s]", 328 gattc_state_code(in_state), 329 gattc_state_code(p_clcb->state), 330 gattc_evt_code(in_event)); 331 } 332 #endif 333 } 334 335 /******************************************************************************* 336 ** 337 ** Function bta_gattc_hdl_event 338 ** 339 ** Description GATT client main event handling function. 340 ** 341 ** 342 ** Returns void 343 ** 344 *******************************************************************************/ 345 BOOLEAN bta_gattc_hdl_event(BT_HDR *p_msg) 346 { 347 tBTA_GATTC_CB *p_cb = &bta_gattc_cb; 348 tBTA_GATTC_CLCB *p_clcb = NULL; 349 350 #if BTA_GATT_DEBUG == TRUE 351 APPL_TRACE_DEBUG1("bta_gattc_hdl_event: Event [%s]", gattc_evt_code(p_msg->event)); 352 #endif 353 switch (p_msg->event) 354 { 355 case BTA_GATTC_API_REG_EVT: 356 bta_gattc_register(p_cb, (tBTA_GATTC_DATA *) p_msg); 357 break; 358 359 case BTA_GATTC_INT_START_IF_EVT: 360 bta_gattc_start_if(p_cb, (tBTA_GATTC_DATA *) p_msg); 361 break; 362 363 case BTA_GATTC_API_DEREG_EVT: 364 bta_gattc_deregister(p_cb, (tBTA_GATTC_DATA *) p_msg); 365 break; 366 367 case BTA_GATTC_INT_DEREG_EVT: 368 bta_gattc_int_deregister(p_cb, (tBTA_GATTC_DATA *) p_msg); 369 break; 370 371 case BTA_GATTC_API_OPEN_EVT: 372 bta_gattc_process_api_open(p_cb, (tBTA_GATTC_DATA *) p_msg); 373 break; 374 375 case BTA_GATTC_API_CANCEL_OPEN_EVT: 376 bta_gattc_process_api_open_cancel(p_cb, (tBTA_GATTC_DATA *) p_msg); 377 break; 378 379 case BTA_GATTC_API_REFRESH_EVT: 380 bta_gattc_process_api_refresh(p_cb, (tBTA_GATTC_DATA *) p_msg); 381 break; 382 383 default: 384 if ((p_clcb = bta_gattc_find_clcb_by_conn_id(p_msg->layer_specific)) 385 != NULL) 386 { 387 bta_gattc_sm_execute(p_clcb, p_msg->event, (tBTA_GATTC_DATA *) p_msg); 388 } 389 else 390 { 391 APPL_TRACE_ERROR1("Unknown conn ID: %d", p_msg->layer_specific); 392 } 393 394 break; 395 } 396 397 398 return(TRUE); 399 } 400 401 402 /***************************************************************************** 403 ** Debug Functions 404 *****************************************************************************/ 405 #if BTA_GATT_DEBUG == TRUE 406 407 /******************************************************************************* 408 ** 409 ** Function gattc_evt_code 410 ** 411 ** Description 412 ** 413 ** Returns void 414 ** 415 *******************************************************************************/ 416 static char *gattc_evt_code(tBTA_GATTC_INT_EVT evt_code) 417 { 418 switch (evt_code) 419 { 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_START_CACHE_EVT: 453 return "BTA_GATTC_START_CACHE_EVT"; 454 case BTA_GATTC_CI_CACHE_OPEN_EVT: 455 return "BTA_GATTC_CI_CACHE_OPEN_EVT"; 456 case BTA_GATTC_CI_CACHE_LOAD_EVT: 457 return "BTA_GATTC_CI_CACHE_LOAD_EVT"; 458 case BTA_GATTC_CI_CACHE_SAVE_EVT: 459 return "BTA_GATTC_CI_CACHE_SAVE_EVT"; 460 case BTA_GATTC_INT_START_IF_EVT: 461 return "BTA_GATTC_INT_START_IF_EVT"; 462 case BTA_GATTC_API_REG_EVT: 463 return "BTA_GATTC_API_REG_EVT"; 464 case BTA_GATTC_API_DEREG_EVT: 465 return "BTA_GATTC_API_DEREG_EVT"; 466 case BTA_GATTC_API_REFRESH_EVT: 467 return "BTA_GATTC_API_REFRESH_EVT"; 468 default: 469 return "unknown GATTC event code"; 470 } 471 } 472 473 /******************************************************************************* 474 ** 475 ** Function gattc_state_code 476 ** 477 ** Description 478 ** 479 ** Returns void 480 ** 481 *******************************************************************************/ 482 static char *gattc_state_code(tBTA_GATTC_STATE state_code) 483 { 484 switch (state_code) 485 { 486 case BTA_GATTC_IDLE_ST: 487 return "GATTC_IDLE_ST"; 488 case BTA_GATTC_W4_CONN_ST: 489 return "GATTC_W4_CONN_ST"; 490 case BTA_GATTC_CONN_ST: 491 return "GATTC_CONN_ST"; 492 case BTA_GATTC_DISCOVER_ST: 493 return "GATTC_DISCOVER_ST"; 494 default: 495 return "unknown GATTC state code"; 496 } 497 } 498 499 #endif /* Debug Functions */ 500 #endif /* BTA_GATT_INCLUDED */ 501