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 is the public interface file for BTA GATT. 22 * 23 ******************************************************************************/ 24 #ifndef BTA_GATT_API_H 25 #define BTA_GATT_API_H 26 27 #include "bta_api.h" 28 #include "gatt_api.h" 29 30 #ifndef BTA_GATT_INCLUDED 31 #define BTA_GATT_INCLUDED FALSE 32 #endif 33 34 35 #if ((BLE_INCLUDED == FALSE) && (BTA_GATT_INCLUDED == TRUE)) 36 #undef BTA_GATT_INCLUDED 37 #define BTA_GATT_INCLUDED FALSE 38 #endif 39 40 41 #ifndef BTA_GATT_DEBUG 42 #define BTA_GATT_DEBUG FALSE 43 #endif 44 45 /***************************************************************************** 46 ** Constants and data types 47 *****************************************************************************/ 48 /************************** 49 ** Common Definitions 50 ***************************/ 51 /* GATT ID */ 52 typedef struct 53 { 54 tBT_UUID uuid; /* uuid of the attribute */ 55 UINT8 inst_id; /* instance ID */ 56 } tBTA_GATT_ID; 57 58 /* Success code and error codes */ 59 #define BTA_GATT_OK GATT_SUCCESS 60 #define BTA_GATT_INVALID_HANDLE GATT_INVALID_HANDLE /* 0x0001 */ 61 #define BTA_GATT_READ_NOT_PERMIT GATT_READ_NOT_PERMIT /* 0x0002 */ 62 #define BTA_GATT_WRITE_NOT_PERMIT GATT_WRITE_NOT_PERMIT /* 0x0003 */ 63 #define BTA_GATT_INVALID_PDU GATT_INVALID_PDU /* 0x0004 */ 64 #define BTA_GATT_INSUF_AUTHENTICATION GATT_INSUF_AUTHENTICATION /* 0x0005 */ 65 #define BTA_GATT_REQ_NOT_SUPPORTED GATT_REQ_NOT_SUPPORTED /* 0x0006 */ 66 #define BTA_GATT_INVALID_OFFSET GATT_INVALID_OFFSET /* 0x0007 */ 67 #define BTA_GATT_INSUF_AUTHORIZATION GATT_INSUF_AUTHORIZATION /* 0x0008 */ 68 #define BTA_GATT_PREPARE_Q_FULL GATT_PREPARE_Q_FULL /* 0x0009 */ 69 #define BTA_GATT_NOT_FOUND GATT_NOT_FOUND /* 0x000a */ 70 #define BTA_GATT_NOT_LONG GATT_NOT_LONG /* 0x000b */ 71 #define BTA_GATT_INSUF_KEY_SIZE GATT_INSUF_KEY_SIZE /* 0x000c */ 72 #define BTA_GATT_INVALID_ATTR_LEN GATT_INVALID_ATTR_LEN /* 0x000d */ 73 #define BTA_GATT_ERR_UNLIKELY GATT_ERR_UNLIKELY /* 0x000e */ 74 #define BTA_GATT_INSUF_ENCRYPTION GATT_INSUF_ENCRYPTION /* 0x000f */ 75 #define BTA_GATT_UNSUPPORT_GRP_TYPE GATT_UNSUPPORT_GRP_TYPE /* 0x0010 */ 76 #define BTA_GATT_INSUF_RESOURCE GATT_INSUF_RESOURCE /* 0x0011 */ 77 78 79 #define BTA_GATT_ILLEGAL_PARAMETER GATT_ILLEGAL_PARAMETER /* 0x0087 */ 80 #define BTA_GATT_NO_RESOURCES GATT_NO_RESOURCES /* 0x0080 */ 81 #define BTA_GATT_INTERNAL_ERROR GATT_INTERNAL_ERROR /* 0x0081 */ 82 #define BTA_GATT_WRONG_STATE GATT_WRONG_STATE /* 0x0082 */ 83 #define BTA_GATT_DB_FULL GATT_DB_FULL /* 0x0083 */ 84 #define BTA_GATT_BUSY GATT_BUSY /* 0x0084 */ 85 #define BTA_GATT_ERROR GATT_ERROR /* 0x0085 */ 86 #define BTA_GATT_CMD_STARTED GATT_CMD_STARTED /* 0x0086 */ 87 #define BTA_GATT_PENDING GATT_PENDING /* 0x0088 */ 88 #define BTA_GATT_AUTH_FAIL GATT_AUTH_FAIL /* 0x0089 */ 89 #define BTA_GATT_MORE GATT_MORE /* 0x008a */ 90 #define BTA_GATT_INVALID_CFG GATT_INVALID_CFG /* 0x008b */ 91 #define BTA_GATT_DUP_REG 0x008c 92 #define BTA_GATT_ALREADY_OPEN 0x008d /* 0x008d */ 93 typedef UINT8 tBTA_GATT_STATUS; 94 95 #define BTA_GATT_INVALID_CONN_ID GATT_INVALID_CONN_ID 96 97 98 /* Client callback function events */ 99 #define BTA_GATTC_REG_EVT 0 /* GATT client is registered. */ 100 #define BTA_GATTC_DEREG_EVT 1 /* GATT client deregistered event */ 101 #define BTA_GATTC_OPEN_EVT 2 /* GATTC open request status event */ 102 #define BTA_GATTC_READ_CHAR_EVT 3 /* GATT read characteristic event */ 103 #define BTA_GATTC_WRITE_CHAR_EVT 4 /* GATT write characteristic or char descriptor event */ 104 #define BTA_GATTC_CLOSE_EVT 5 /* GATTC close request status event */ 105 #define BTA_GATTC_SEARCH_CMPL_EVT 6 /* GATT discovery complete event */ 106 #define BTA_GATTC_SEARCH_RES_EVT 7 /* GATT discovery result event */ 107 #define BTA_GATTC_READ_DESCR_EVT 8 /* GATT read characterisitc descriptor event */ 108 #define BTA_GATTC_WRITE_DESCR_EVT 9 /* GATT write characteristic descriptor event */ 109 #define BTA_GATTC_NOTIF_EVT 10 /* GATT attribute notification event */ 110 #define BTA_GATTC_PREP_WRITE_EVT 11 /* GATT prepare write event */ 111 #define BTA_GATTC_EXEC_EVT 12 /* execute write complete event */ 112 #define BTA_GATTC_ACL_EVT 13 /* ACL up event */ 113 #define BTA_GATTC_CANCEL_OPEN_EVT 14 /* cancel open event */ 114 #define BTA_GATTC_SRVC_CHG_EVT 15 /* service change event */ 115 typedef UINT8 tBTA_GATTC_EVT; 116 117 typedef tGATT_IF tBTA_GATTC_IF; 118 119 typedef struct 120 { 121 UINT16 unit; /* as UUIUD defined by SIG */ 122 UINT16 descr; /* as UUID as defined by SIG */ 123 tGATT_FORMAT format; 124 INT8 exp; 125 UINT8 name_spc; /* The name space of the description */ 126 }tBTA_GATT_CHAR_PRES; 127 128 #define BTA_GATT_CLT_CONFIG_NONE GATT_CLT_CONFIG_NONE /* 0x0000 */ 129 #define BTA_GATT_CLT_CONFIG_NOTIFICATION GATT_CLT_CONFIG_NOTIFICATION /* 0x0001 */ 130 #define BTA_GATT_CLT_CONFIG_INDICATION GATT_CLT_CONFIG_INDICATION /* 0x0002 */ 131 typedef UINT16 tBTA_GATT_CLT_CHAR_CONFIG; 132 133 /* characteristic descriptor: server configuration value 134 */ 135 #define BTA_GATT_SVR_CONFIG_NONE GATT_SVR_CONFIG_NONE /* 0x0000 */ 136 #define BTA_GATT_SVR_CONFIG_BROADCAST GATT_SVR_CONFIG_BROADCAST /* 0x0001 */ 137 typedef UINT16 tBTA_GATT_SVR_CHAR_CONFIG; 138 139 /* Characteristic Aggregate Format attribute value 140 */ 141 #define BTA_GATT_AGGR_HANDLE_NUM_MAX 10 142 typedef struct 143 { 144 UINT8 num_handle; 145 UINT16 handle_list[BTA_GATT_AGGR_HANDLE_NUM_MAX]; 146 } tBTA_GATT_CHAR_AGGRE; 147 typedef tGATT_VALID_RANGE tBTA_GATT_VALID_RANGE; 148 149 typedef struct 150 { 151 UINT16 len; 152 UINT8 *p_value; 153 }tBTA_GATT_UNFMT; 154 155 #define BTA_GATT_MAX_ATTR_LEN GATT_MAX_ATTR_LEN 156 157 #define BTA_GATTC_TYPE_WRITE GATT_WRITE 158 #define BTA_GATTC_TYPE_WRITE_NO_RSP GATT_WRITE_NO_RSP 159 typedef UINT8 tBTA_GATTC_WRITE_TYPE; 160 161 #define BTA_GATT_CONN_UNKNOWN 0 162 #define BTA_GATT_CONN_NO_RESOURCES GATT_CONN_NO_RESOURCES /* connection fail for l2cap resource failure */ 163 #define BTA_GATT_CONN_TIMEOUT GATT_CONN_TIMEOUT /* 0x08 connection timeout */ 164 #define BTA_GATT_CONN_TERMINATE_PEER_USER GATT_CONN_TERMINATE_PEER_USER /* 0x13 connection terminate by peer user */ 165 #define BTA_GATT_CONN_TERMINATE_LOCAL_HOST GATT_CONN_TERMINATE_LOCAL_HOST/* 0x16 connectionterminated by local host */ 166 #define BTA_GATT_CONN_FAIL_ESTABLISH GATT_CONN_FAIL_ESTABLISH /* 0x03E connection fail to establish */ 167 #define BTA_GATT_CONN_LMP_TIMEOUT GATT_CONN_LMP_TIMEOUT /* 0x22 connection fail for LMP response tout */ 168 #define BTA_GATT_CONN_CANCEL GATT_CONN_CANCEL /* 0x0100 L2CAP connection cancelled */ 169 #define BTA_GATT_CONN_NONE 0x0101 /* 0x0101 no connection to cancel */ 170 typedef UINT16 tBTA_GATT_REASON; 171 172 typedef struct 173 { 174 tBTA_GATT_ID id; 175 BOOLEAN is_primary; 176 }tBTA_GATT_SRVC_ID; 177 178 typedef struct 179 { 180 tBTA_GATT_SRVC_ID srvc_id; 181 tBTA_GATT_ID char_id; 182 }tBTA_GATTC_CHAR_ID; 183 184 typedef struct 185 { 186 tBTA_GATTC_CHAR_ID char_id; 187 tBT_UUID descr_type; 188 }tBTA_GATTC_CHAR_DESCR_ID; 189 190 typedef struct 191 { 192 tBTA_GATT_SRVC_ID srvc_id; 193 tBTA_GATT_SRVC_ID incl_svc_id; 194 }tBTA_GATTC_INCL_SVC_ID; 195 196 #define BTA_GATT_TYPE_CHAR 0 197 #define BTA_GATT_TYPE_CHAR_DESCR 1 198 typedef UINT8 tBTA_GATT_ID_TYPE; 199 200 typedef struct 201 { 202 tBTA_GATT_ID_TYPE id_type; 203 union 204 { 205 tBTA_GATTC_CHAR_ID char_id; 206 tBTA_GATTC_CHAR_DESCR_ID char_descr_id; 207 208 } id_value; 209 }tBTA_GATTC_ATTR_ID; 210 211 #define BTA_GATTC_MULTI_MAX GATT_MAX_READ_MULTI_HANDLES 212 213 typedef struct 214 { 215 UINT8 num_attr; 216 tBTA_GATTC_ATTR_ID id_list[BTA_GATTC_MULTI_MAX]; 217 218 }tBTA_GATTC_MULTI; 219 220 #define BTA_GATT_AUTH_REQ_NONE GATT_AUTH_REQ_NONE 221 #define BTA_GATT_AUTH_REQ_NO_MITM GATT_AUTH_REQ_NO_MITM /* unauthenticated encryption */ 222 #define BTA_GATT_AUTH_REQ_MITM GATT_AUTH_REQ_MITM /* authenticated encryption */ 223 #define BTA_GATT_AUTH_REQ_SIGNED_NO_MITM GATT_AUTH_REQ_SIGNED_NO_MITM 224 #define BTA_GATT_AUTH_REQ_SIGNED_MITM GATT_AUTH_REQ_SIGNED_MITM 225 226 typedef tGATT_AUTH_REQ tBTA_GATT_AUTH_REQ; 227 228 enum 229 { 230 BTA_GATTC_ATTR_TYPE_INCL_SRVC, 231 BTA_GATTC_ATTR_TYPE_CHAR, 232 BTA_GATTC_ATTR_TYPE_CHAR_DESCR, 233 BTA_GATTC_ATTR_TYPE_SRVC 234 }; 235 typedef UINT8 tBTA_GATTC_ATTR_TYPE; 236 237 238 typedef struct 239 { 240 tBT_UUID uuid; 241 UINT16 s_handle; 242 UINT16 e_handle; /* used for service only */ 243 UINT8 attr_type; 244 UINT8 id; 245 UINT8 prop; /* used when attribute type is characteristic */ 246 BOOLEAN is_primary; /* used when attribute type is service */ 247 }tBTA_GATTC_NV_ATTR; 248 249 /* callback data structure */ 250 typedef struct 251 { 252 tBTA_GATT_STATUS status; 253 tBTA_GATTC_IF client_if; 254 // btla-specific ++ 255 tBT_UUID app_uuid; 256 // btla-specific -- 257 }tBTA_GATTC_REG; 258 259 typedef struct 260 { 261 UINT8 num_pres_fmt; /* number of presentation format aggregated*/ 262 tBTA_GATTC_CHAR_DESCR_ID pre_format[BTA_GATTC_MULTI_MAX]; 263 }tBTA_GATT_CHAR_AGGRE_VALUE; 264 265 typedef union 266 { 267 tBTA_GATT_CHAR_AGGRE_VALUE aggre_value; 268 tBTA_GATT_UNFMT unformat; 269 270 }tBTA_GATT_READ_VAL; 271 272 typedef struct 273 { 274 UINT16 conn_id; 275 tBTA_GATT_STATUS status; 276 tBTA_GATT_SRVC_ID srvc_id; 277 tBTA_GATT_ID char_id; 278 tBT_UUID descr_type; 279 tBTA_GATT_READ_VAL *p_value; 280 }tBTA_GATTC_READ; 281 282 typedef struct 283 { 284 UINT16 conn_id; 285 tBTA_GATT_STATUS status; 286 tBTA_GATT_SRVC_ID srvc_id; 287 tBTA_GATT_ID char_id; 288 tBT_UUID descr_type; 289 }tBTA_GATTC_WRITE; 290 291 typedef struct 292 { 293 UINT16 conn_id; 294 tBTA_GATT_STATUS status; 295 }tBTA_GATTC_EXEC_CMPL; 296 297 typedef struct 298 { 299 UINT16 conn_id; 300 tBTA_GATT_STATUS status; 301 }tBTA_GATTC_SEARCH_CMPL; 302 303 typedef struct 304 { 305 UINT16 conn_id; 306 tBTA_GATT_SRVC_ID service_uuid; 307 }tBTA_GATTC_SRVC_RES; 308 309 310 typedef struct 311 { 312 tBTA_GATT_STATUS status; 313 UINT16 conn_id; 314 tBTA_GATTC_IF client_if; 315 BD_ADDR remote_bda; 316 }tBTA_GATTC_OPEN; 317 318 typedef struct 319 { 320 tBTA_GATT_STATUS status; 321 UINT16 conn_id; 322 tBTA_GATTC_IF client_if; 323 BD_ADDR remote_bda; 324 tBTA_GATT_REASON reason; /* disconnect reason code, not useful when connect event is reported */ 325 }tBTA_GATTC_CLOSE; 326 327 typedef struct 328 { 329 UINT16 conn_id; 330 BD_ADDR bda; 331 tBTA_GATTC_CHAR_ID char_id; 332 tBT_UUID descr_type; 333 UINT16 len; 334 UINT8 value[BTA_GATT_MAX_ATTR_LEN]; 335 BOOLEAN is_notify; 336 }tBTA_GATTC_NOTIFY; 337 338 // btla-specific ++ 339 typedef struct 340 { 341 tBTA_GATT_STATUS status; 342 tBTA_GATTC_IF client_if; 343 UINT16 conn_id; 344 BD_ADDR remote_bda; 345 }tBTA_GATTC_OPEN_CLOSE; 346 // btla-specific -- 347 348 typedef union 349 { 350 tBTA_GATT_STATUS status; 351 352 tBTA_GATTC_SEARCH_CMPL search_cmpl; /* discovery complete */ 353 tBTA_GATTC_SRVC_RES srvc_res; /* discovery result */ 354 tBTA_GATTC_REG reg_oper; /* registration data */ 355 tBTA_GATTC_OPEN open; 356 tBTA_GATTC_CLOSE close; 357 tBTA_GATTC_READ read; /* read attribute/descriptor data */ 358 tBTA_GATTC_WRITE write; /* write complete data */ 359 tBTA_GATTC_EXEC_CMPL exec_cmpl; /* execute complete */ 360 tBTA_GATTC_NOTIFY notify; /* notification/indication event data */ 361 BD_ADDR remote_bda; /* service change event */ 362 } tBTA_GATTC; 363 364 /* Client callback function */ 365 typedef void (tBTA_GATTC_CBACK)(tBTA_GATTC_EVT event, tBTA_GATTC *p_data); 366 367 368 /* GATT Server Data Structure */ 369 /* Server callback function events */ 370 #define BTA_GATTS_REG_EVT 0 371 #define BTA_GATTS_READ_EVT GATTS_REQ_TYPE_READ /* 1 */ 372 #define BTA_GATTS_WRITE_EVT GATTS_REQ_TYPE_WRITE /* 2 */ 373 #define BTA_GATTS_EXEC_WRITE_EVT GATTS_REQ_TYPE_WRITE_EXEC /* 3 */ 374 #define BTA_GATTS_MTU_EVT GATTS_REQ_TYPE_MTU /* 4 */ 375 #define BTA_GATTS_CONF_EVT GATTS_REQ_TYPE_CONF /* 5 */ 376 #define BTA_GATTS_DEREG_EVT 6 377 #define BTA_GATTS_CREATE_EVT 7 378 #define BTA_GATTS_ADD_INCL_SRVC_EVT 8 379 #define BTA_GATTS_ADD_CHAR_EVT 9 380 #define BTA_GATTS_ADD_CHAR_DESCR_EVT 10 381 #define BTA_GATTS_DELELTE_EVT 11 382 #define BTA_GATTS_START_EVT 12 383 #define BTA_GATTS_STOP_EVT 13 384 #define BTA_GATTS_CONNECT_EVT 14 385 #define BTA_GATTS_DISCONNECT_EVT 15 386 #define BTA_GATTS_OPEN_EVT 16 387 #define BTA_GATTS_CANCEL_OPEN_EVT 17 388 #define BTA_GATTS_CLOSE_EVT 18 389 390 typedef UINT8 tBTA_GATTS_EVT; 391 typedef tGATT_IF tBTA_GATTS_IF; 392 393 /* Attribute permissions 394 */ 395 #define BTA_GATT_PERM_READ GATT_PERM_READ /* bit 0 - 0x0001 */ 396 #define BTA_GATT_PERM_READ_ENCRYPTED GATT_PERM_READ_ENCRYPTED /* bit 1 - 0x0002 */ 397 #define BTA_GATT_PERM_READ_ENC_MITM GATT_PERM_READ_ENC_MITM /* bit 2 - 0x0004 */ 398 #define BTA_GATT_PERM_WRITE GATT_PERM_WRITE /* bit 4 - 0x0010 */ 399 #define BTA_GATT_PERM_WRITE_ENCRYPTED GATT_PERM_WRITE_ENCRYPTED /* bit 5 - 0x0020 */ 400 #define BTA_GATT_PERM_WRITE_ENC_MITM GATT_PERM_WRITE_ENC_MITM /* bit 6 - 0x0040 */ 401 #define BTA_GATT_PERM_WRITE_SIGNED GATT_PERM_WRITE_SIGNED /* bit 7 - 0x0080 */ 402 #define BTA_GATT_PERM_WRITE_SIGNED_MITM GATT_PERM_WRITE_SIGNED_MITM /* bit 8 - 0x0100 */ 403 typedef UINT16 tBTA_GATT_PERM; 404 405 #define BTA_GATTS_INVALID_APP 0xff 406 407 #define BTA_GATTS_INVALID_IF 0 408 409 /* definition of characteristic properties */ 410 #define BTA_GATT_CHAR_PROP_BIT_BROADCAST GATT_CHAR_PROP_BIT_BROADCAST /* 0x01 */ 411 #define BTA_GATT_CHAR_PROP_BIT_READ GATT_CHAR_PROP_BIT_READ /* 0x02 */ 412 #define BTA_GATT_CHAR_PROP_BIT_WRITE_NR GATT_CHAR_PROP_BIT_WRITE_NR /* 0x04 */ 413 #define BTA_GATT_CHAR_PROP_BIT_WRITE GATT_CHAR_PROP_BIT_WRITE /* 0x08 */ 414 #define BTA_GATT_CHAR_PROP_BIT_NOTIFY GATT_CHAR_PROP_BIT_NOTIFY /* 0x10 */ 415 #define BTA_GATT_CHAR_PROP_BIT_INDICATE GATT_CHAR_PROP_BIT_INDICATE /* 0x20 */ 416 #define BTA_GATT_CHAR_PROP_BIT_AUTH GATT_CHAR_PROP_BIT_AUTH /* 0x40 */ 417 #define BTA_GATT_CHAR_PROP_BIT_EXT_PROP GATT_CHAR_PROP_BIT_EXT_PROP /* 0x80 */ 418 typedef UINT8 tBTA_GATT_CHAR_PROP; 419 420 #ifndef BTA_GATTC_CHAR_DESCR_MAX 421 #define BTA_GATTC_CHAR_DESCR_MAX 7 422 #endif 423 424 /*********************** NV callback Data Definitions ********************** 425 */ 426 typedef struct 427 { 428 tBT_UUID app_uuid128; 429 tBT_UUID svc_uuid; 430 UINT16 svc_inst; 431 UINT16 s_handle; 432 UINT16 e_handle; 433 BOOLEAN is_primary; /* primary service or secondary */ 434 } tBTA_GATTS_HNDL_RANGE; 435 436 #define BTA_GATTS_SRV_CHG_CMD_ADD_CLIENT GATTS_SRV_CHG_CMD_ADD_CLIENT 437 #define BTA_GATTS_SRV_CHG_CMD_UPDATE_CLIENT GATTS_SRV_CHG_CMD_UPDATE_CLIENT 438 #define BTA_GATTS_SRV_CHG_CMD_REMOVE_CLIENT GATTS_SRV_CHG_CMD_REMOVE_CLIENT 439 #define BTA_GATTS_SRV_CHG_CMD_READ_NUM_CLENTS GATTS_SRV_CHG_CMD_READ_NUM_CLENTS 440 #define BTA_GATTS_SRV_CHG_CMD_READ_CLENT GATTS_SRV_CHG_CMD_READ_CLENT 441 typedef tGATTS_SRV_CHG_CMD tBTA_GATTS_SRV_CHG_CMD; 442 443 typedef tGATTS_SRV_CHG tBTA_GATTS_SRV_CHG; 444 typedef tGATTS_SRV_CHG_REQ tBTA_GATTS_SRV_CHG_REQ; 445 typedef tGATTS_SRV_CHG_RSP tBTA_GATTS_SRV_CHG_RSP; 446 447 enum 448 { 449 BTA_GATT_TRANSPORT_LE, 450 BTA_GATT_TRANSPORT_BR_EDR, 451 BTA_GATT_TRANSPORT_LE_BR_EDR 452 }; 453 typedef UINT8 tBTA_GATT_TRANSPORT; 454 455 /* attribute value */ 456 typedef tGATT_VALUE tBTA_GATT_VALUE; 457 458 /* attribute response data */ 459 typedef tGATTS_RSP tBTA_GATTS_RSP; 460 461 /* attribute request data from the client */ 462 #define BTA_GATT_PREP_WRITE_CANCEL 0x00 463 #define BTA_GATT_PREP_WRITE_EXEC 0x01 464 typedef tGATT_EXEC_FLAG tBTA_GATT_EXEC_FLAG; 465 466 /* read request always based on UUID */ 467 typedef tGATT_READ_REQ tTA_GBATT_READ_REQ; 468 469 /* write request data */ 470 typedef tGATT_WRITE_REQ tBTA_GATT_WRITE_REQ; 471 472 /* callback data for server access request from client */ 473 typedef tGATTS_DATA tBTA_GATTS_REQ_DATA; 474 475 typedef struct 476 { 477 BD_ADDR remote_bda; 478 UINT32 trans_id; 479 UINT16 conn_id; 480 tBTA_GATTS_REQ_DATA *p_data; 481 }tBTA_GATTS_REQ; 482 483 typedef struct 484 { 485 tBTA_GATTS_IF server_if; 486 tBTA_GATT_STATUS status; 487 // btla-specific ++ 488 tBT_UUID uuid; 489 // btla-specific -- 490 }tBTA_GATTS_REG_OPER; 491 492 493 typedef struct 494 { 495 tBTA_GATTS_IF server_if; 496 UINT16 service_id; 497 // btla-specific ++ 498 UINT16 svc_instance; 499 BOOLEAN is_primary; 500 tBTA_GATT_STATUS status; 501 tBT_UUID uuid; 502 // btla-specific -- 503 }tBTA_GATTS_CREATE; 504 505 typedef struct 506 { 507 tBTA_GATTS_IF server_if; 508 UINT16 service_id; 509 UINT16 attr_id; 510 tBTA_GATT_STATUS status; 511 // btla-specific ++ 512 tBT_UUID char_uuid; 513 // btla-specific -- 514 }tBTA_GATTS_ADD_RESULT; 515 516 typedef struct 517 { 518 tBTA_GATTS_IF server_if; 519 UINT16 service_id; 520 tBTA_GATT_STATUS status; 521 }tBTA_GATTS_SRVC_OPER; 522 523 524 typedef struct 525 { 526 tBTA_GATTS_IF server_if; 527 BD_ADDR remote_bda; 528 UINT16 conn_id; 529 tBTA_GATT_REASON reason; /* report disconnect reason */ 530 }tBTA_GATTS_CONN; 531 532 /* GATTS callback data */ 533 typedef union 534 { 535 tBTA_GATTS_REG_OPER reg_oper; 536 tBTA_GATTS_CREATE create; 537 tBTA_GATTS_SRVC_OPER srvc_oper; 538 tBTA_GATT_STATUS status; /* BTA_GATTS_CONF_EVT */ 539 tBTA_GATTS_ADD_RESULT add_result; /* add included service: BTA_GATTS_ADD_INCL_SRVC_EVT 540 add char : BTA_GATTS_ADD_CHAR_EVT 541 add char descriptor: BTA_GATTS_ADD_CHAR_DESCR_EVT */ 542 tBTA_GATTS_REQ req_data; 543 tBTA_GATTS_CONN conn; /* BTA_GATTS_CONN_EVT */ 544 545 }tBTA_GATTS; 546 547 548 /* Server callback function */ 549 typedef void (tBTA_GATTS_CBACK)(tBTA_GATTS_EVT event, tBTA_GATTS *p_data); 550 /***************************************************************************** 551 ** External Function Declarations 552 *****************************************************************************/ 553 554 #ifdef __cplusplus 555 extern "C" 556 { 557 #endif 558 559 /************************** 560 ** Client Functions 561 ***************************/ 562 563 /******************************************************************************* 564 ** 565 ** Function BTA_GATTC_AppRegister 566 ** 567 ** Description This function is called to register application callbacks 568 ** with BTA GATTC module. 569 ** 570 ** Parameters p_app_uuid - applicaiton UUID 571 ** p_client_cb - pointer to the application callback function. 572 ** 573 ** Returns None 574 ** 575 *******************************************************************************/ 576 BTA_API extern void BTA_GATTC_AppRegister(tBT_UUID *p_app_uuid, tBTA_GATTC_CBACK *p_client_cb); 577 578 /******************************************************************************* 579 ** 580 ** Function BTA_GATTC_AppDeregister 581 ** 582 ** Description This function is called to deregister an application 583 ** from BTA GATTC module. 584 ** 585 ** Parameters client_if - client interface identifier. 586 ** 587 ** Returns None 588 ** 589 *******************************************************************************/ 590 BTA_API extern void BTA_GATTC_AppDeregister (tBTA_GATTC_IF client_if); 591 592 /******************************************************************************* 593 ** 594 ** Function BTA_GATTC_Open 595 ** 596 ** Description Open a direct connection or add a background auto connection 597 ** bd address 598 ** 599 ** Parameters client_if: server interface. 600 ** remote_bda: remote device BD address. 601 ** is_direct: direct connection or background auto connection 602 ** 603 ** Returns void 604 ** 605 *******************************************************************************/ 606 BTA_API extern void BTA_GATTC_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, BOOLEAN is_direct); 607 608 /******************************************************************************* 609 ** 610 ** Function BTA_GATTC_CancelOpen 611 ** 612 ** Description Open a direct connection or add a background auto connection 613 ** bd address 614 ** 615 ** Parameters client_if: server interface. 616 ** remote_bda: remote device BD address. 617 ** is_direct: direct connection or background auto connection 618 ** 619 ** Returns void 620 ** 621 *******************************************************************************/ 622 BTA_API extern void BTA_GATTC_CancelOpen(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, BOOLEAN is_direct); 623 624 /******************************************************************************* 625 ** 626 ** Function BTA_GATTC_Close 627 ** 628 ** Description Close a connection to a GATT server. 629 ** 630 ** Parameters conn_id: connectino ID to be closed. 631 ** 632 ** Returns void 633 ** 634 *******************************************************************************/ 635 BTA_API extern void BTA_GATTC_Close(UINT16 conn_id); 636 637 /******************************************************************************* 638 ** 639 ** Function BTA_GATTC_ServiceSearchRequest 640 ** 641 ** Description This function is called to request a GATT service discovery 642 ** on a GATT server. This function report service search result 643 ** by a callback event, and followed by a service search complete 644 ** event. 645 ** 646 ** Parameters conn_id: connection ID. 647 ** p_srvc_uuid: a UUID of the service application is interested in. 648 ** If Null, discover for all services. 649 ** 650 ** Returns None 651 ** 652 *******************************************************************************/ 653 BTA_API extern void BTA_GATTC_ServiceSearchRequest(UINT16 conn_id, tBT_UUID *p_srvc_uuid); 654 655 /******************************************************************************* 656 ** 657 ** Function BTA_GATTC_GetFirstChar 658 ** 659 ** Description This function is called to find the first charatceristic of the 660 ** service on the given server. 661 ** 662 ** Parameters conn_id: connection ID which identify the server. 663 ** p_srvc_id: the service ID of which the characteristic is belonged to. 664 ** p_char_uuid_cond: Characteristic UUID, if NULL find the first available 665 ** characteristic. 666 ** p_char_result: output parameter which will store the GATT 667 ** characteristic ID. 668 ** p_property: output parameter to carry the characteristic property. 669 ** 670 ** Returns returns status. 671 ** 672 *******************************************************************************/ 673 BTA_API extern tBTA_GATT_STATUS BTA_GATTC_GetFirstChar (UINT16 conn_id, 674 tBTA_GATT_SRVC_ID *p_srvc_id, 675 tBT_UUID *p_char_uuid_cond, 676 tBTA_GATTC_CHAR_ID *p_char_result, 677 tBTA_GATT_CHAR_PROP *p_property); 678 679 /******************************************************************************* 680 ** 681 ** Function BTA_GATTC_GetNextChar 682 ** 683 ** Description This function is called to find the next charatceristic of the 684 ** service on the given server. 685 ** 686 ** Parameters conn_id: connection ID which identify the server. 687 ** p_start_char_id: start the characteristic search from the next record 688 ** after the one identified by char_id. 689 ** p_char_uuid_cond: Characteristic UUID, if NULL find the first available 690 ** characteristic. 691 ** p_char_result: output parameter which will store the GATT 692 ** characteristic ID. 693 ** p_property: output parameter, characteristic property. 694 ** 695 ** Returns returns status. 696 ** 697 *******************************************************************************/ 698 BTA_API extern tBTA_GATT_STATUS BTA_GATTC_GetNextChar (UINT16 conn_id, 699 tBTA_GATTC_CHAR_ID *p_start_char_id, 700 tBT_UUID *p_char_uuid_cond, 701 tBTA_GATTC_CHAR_ID *p_char_result, 702 tBTA_GATT_CHAR_PROP *p_property); 703 704 /******************************************************************************* 705 ** 706 ** Function BTA_GATTC_GetFirstCharDescr 707 ** 708 ** Description This function is called to find the first charatceristic descriptor of the 709 ** charatceristic on the given server. 710 ** 711 ** Parameters conn_id: connection ID which identify the server. 712 ** p_char_id: the characteristic ID of which the descriptor is belonged to. 713 ** p_descr_uuid_cond: Characteristic Descr UUID, if NULL find the first available 714 ** characteristic. 715 ** p_descr_result: output parameter which will store the GATT 716 ** characteristic descriptor ID. 717 ** 718 ** Returns returns status. 719 ** 720 *******************************************************************************/ 721 BTA_API extern tBTA_GATT_STATUS BTA_GATTC_GetFirstCharDescr (UINT16 conn_id, tBTA_GATTC_CHAR_ID *p_char_id, 722 tBT_UUID *p_descr_uuid_cond, 723 tBTA_GATTC_CHAR_DESCR_ID *p_descr_result); 724 725 /******************************************************************************* 726 ** 727 ** Function BTA_GATTC_GetNextCharDescr 728 ** 729 ** Description This function is called to find the next charatceristic of the 730 ** service on the given server. 731 ** 732 ** Parameters conn_id: connection ID which identify the server. 733 ** p_start_descr_id: start the characteristic search from the next record 734 ** after the one identified by p_start_descr_id. 735 ** p_descr_uuid_cond: Characteristic descriptor UUID, if NULL find 736 ** the first available characteristic descriptor. 737 ** p_descr_result: output parameter which will store the GATT 738 ** characteristic descriptor ID. 739 ** 740 ** Returns returns status. 741 ** 742 *******************************************************************************/ 743 BTA_API extern tBTA_GATT_STATUS BTA_GATTC_GetNextCharDescr (UINT16 conn_id, 744 tBTA_GATTC_CHAR_DESCR_ID *p_start_descr_id, 745 tBT_UUID *p_descr_uuid_cond, 746 tBTA_GATTC_CHAR_DESCR_ID *p_descr_result); 747 748 749 /******************************************************************************* 750 ** 751 ** Function BTA_GATTC_GetFirstIncludedService 752 ** 753 ** Description This function is called to find the first included service of the 754 ** service on the given server. 755 ** 756 ** Parameters conn_id: connection ID which identify the server. 757 ** p_srvc_id: the service ID of which the included service is belonged to. 758 ** p_uuid_cond: include service UUID, if NULL find the first available 759 ** included service. 760 ** p_result: output parameter which will store the GATT ID 761 ** of the included service found. 762 ** 763 ** Returns returns status. 764 ** 765 *******************************************************************************/ 766 BTA_API extern tBTA_GATT_STATUS BTA_GATTC_GetFirstIncludedService(UINT16 conn_id, 767 tBTA_GATT_SRVC_ID *p_srvc_id, 768 tBT_UUID *p_uuid_cond, 769 tBTA_GATTC_INCL_SVC_ID *p_result); 770 771 /******************************************************************************* 772 ** 773 ** Function BTA_GATTC_GetNextIncludedService 774 ** 775 ** Description This function is called to find the next included service of the 776 ** service on the given server. 777 ** 778 ** Parameters conn_id: connection ID which identify the server. 779 ** p_start_id: start the search from the next record 780 ** after the one identified by p_start_id. 781 ** p_uuid_cond: Included service UUID, if NULL find the first available 782 ** included service. 783 ** p_result: output parameter which will store the GATT ID 784 ** of the included service found. 785 ** 786 ** Returns returns status. 787 ** 788 *******************************************************************************/ 789 BTA_API extern tBTA_GATT_STATUS BTA_GATTC_GetNextIncludedService(UINT16 conn_id, 790 tBTA_GATTC_INCL_SVC_ID *p_start_id, 791 tBT_UUID *p_uuid_cond, 792 tBTA_GATTC_INCL_SVC_ID *p_result); 793 794 /******************************************************************************* 795 ** 796 ** Function BTA_GATTC_ReadCharacteristic 797 ** 798 ** Description This function is called to read a service's characteristics of 799 ** the given characteritisc ID. 800 ** 801 ** Parameters conn_id - connectino ID. 802 ** p_char_id - characteritic ID to read. 803 ** 804 ** Returns None 805 ** 806 *******************************************************************************/ 807 BTA_API extern void BTA_GATTC_ReadCharacteristic (UINT16 conn_id, 808 tBTA_GATTC_CHAR_ID *p_char_id, 809 tBTA_GATT_AUTH_REQ auth_req); 810 811 /******************************************************************************* 812 ** 813 ** Function BTA_GATTC_ReadCharDescr 814 ** 815 ** Description This function is called to read a characteristics descriptor. 816 ** 817 ** Parameters conn_id - connection ID. 818 ** p_char_descr_id - characteritic descriptor ID to read. 819 ** 820 ** Returns None 821 ** 822 *******************************************************************************/ 823 BTA_API extern void BTA_GATTC_ReadCharDescr (UINT16 conn_id, 824 tBTA_GATTC_CHAR_DESCR_ID *p_char_descr_id, 825 tBTA_GATT_AUTH_REQ auth_req); 826 827 /******************************************************************************* 828 ** 829 ** Function BTA_GATTC_WriteCharValue 830 ** 831 ** Description This function is called to write characteristic value. 832 ** 833 ** Parameters conn_id - connection ID. 834 ** p_char_id - characteristic ID to write. 835 ** write_type - type of write. 836 ** len: length of the data to be written. 837 ** p_value - the value to be written. 838 ** 839 ** Returns None 840 ** 841 *******************************************************************************/ 842 BTA_API extern void BTA_GATTC_WriteCharValue (UINT16 conn_id, 843 tBTA_GATTC_CHAR_ID *p_char_id, 844 tBTA_GATTC_WRITE_TYPE write_type, 845 UINT16 len, 846 UINT8 *p_value, 847 tBTA_GATT_AUTH_REQ auth_req); 848 849 /******************************************************************************* 850 ** 851 ** Function BTA_GATTC_WriteCharDescr 852 ** 853 ** Description This function is called to write characteristic descriptor value. 854 ** 855 ** Parameters conn_id - connection ID 856 ** p_char_descr_id - characteristic descriptor ID to write. 857 ** write_type - type of write. 858 ** p_value - the value to be written. 859 ** 860 ** Returns None 861 ** 862 *******************************************************************************/ 863 BTA_API extern void BTA_GATTC_WriteCharDescr (UINT16 conn_id, 864 tBTA_GATTC_CHAR_DESCR_ID *p_char_descr_id, 865 tBTA_GATTC_WRITE_TYPE write_type, 866 tBTA_GATT_UNFMT *p_data, 867 tBTA_GATT_AUTH_REQ auth_req); 868 869 /******************************************************************************* 870 ** 871 ** Function BTA_GATTC_SendIndConfirm 872 ** 873 ** Description This function is called to send handle value confirmation. 874 ** 875 ** Parameters conn_id - connection ID. 876 ** p_char_id - characteristic ID to confrim. 877 ** 878 ** Returns None 879 ** 880 *******************************************************************************/ 881 BTA_API extern void BTA_GATTC_SendIndConfirm (UINT16 conn_id, tBTA_GATTC_CHAR_ID *p_char_id); 882 883 /******************************************************************************* 884 ** 885 ** Function BTA_GATTC_RegisterForNotifications 886 ** 887 ** Description This function is called to register for notification of a service. 888 ** 889 ** Parameters client_if - client interface. 890 ** remote_bda - target GATT server. 891 ** p_char_id - pointer to GATT characteristic ID. 892 ** 893 ** Returns OK if registration succeed, otherwise failed. 894 ** 895 *******************************************************************************/ 896 BTA_API extern tBTA_GATT_STATUS BTA_GATTC_RegisterForNotifications (tBTA_GATTC_IF client_if, 897 BD_ADDR remote_bda, 898 tBTA_GATTC_CHAR_ID *p_char_id); 899 900 901 /******************************************************************************* 902 ** 903 ** Function BTA_GATTC_DeregisterForNotifications 904 ** 905 ** Description This function is called to de-register for notification of a servbice. 906 ** 907 ** Parameters client_if - client interface. 908 ** remote_bda - target GATT server. 909 ** p_char_id - pointer to a GATT characteristic ID. 910 ** 911 ** Returns OK if deregistration succeed, otherwise failed. 912 ** 913 *******************************************************************************/ 914 BTA_API extern tBTA_GATT_STATUS BTA_GATTC_DeregisterForNotifications (tBTA_GATTC_IF client_if, 915 BD_ADDR remote_bda, 916 tBTA_GATTC_CHAR_ID *p_char_id); 917 918 /******************************************************************************* 919 ** 920 ** Function BTA_GATTC_PrepareWrite 921 ** 922 ** Description This function is called to prepare write a characteristic value. 923 ** 924 ** Parameters conn_id - connection ID. 925 ** p_char_id - GATT characteritic ID of the service. 926 ** offset - offset of the write value. 927 ** len: length of the data to be written. 928 ** p_value - the value to be written. 929 ** 930 ** Returns None 931 ** 932 *******************************************************************************/ 933 BTA_API extern void BTA_GATTC_PrepareWrite (UINT16 conn_id, 934 tBTA_GATTC_CHAR_ID *p_char_id, 935 UINT16 offset, 936 UINT16 len, 937 UINT8 *p_value, 938 tBTA_GATT_AUTH_REQ auth_req); 939 940 /******************************************************************************* 941 ** 942 ** Function BTA_GATTC_ExecuteWrite 943 ** 944 ** Description This function is called to execute write a prepare write sequence. 945 ** 946 ** Parameters conn_id - connection ID. 947 ** is_execute - execute or cancel. 948 ** 949 ** Returns None 950 ** 951 *******************************************************************************/ 952 BTA_API extern void BTA_GATTC_ExecuteWrite (UINT16 conn_id, BOOLEAN is_execute); 953 954 /******************************************************************************* 955 ** 956 ** Function BTA_GATTC_ReadMultiple 957 ** 958 ** Description This function is called to read multiple characteristic or 959 ** characteristic descriptors. 960 ** 961 ** Parameters conn_id - connectino ID. 962 ** p_read_multi - read multiple parameters. 963 ** 964 ** Returns None 965 ** 966 *******************************************************************************/ 967 BTA_API extern void BTA_GATTC_ReadMultiple(UINT16 conn_id, tBTA_GATTC_MULTI *p_read_multi, 968 tBTA_GATT_AUTH_REQ auth_req); 969 970 971 972 973 /******************************************************************************* 974 ** BTA GATT Server API 975 ********************************************************************************/ 976 /******************************************************************************* 977 ** 978 ** Function BTA_GATTS_AppRegister 979 ** 980 ** Description This function is called to register application callbacks 981 ** with BTA GATTS module. 982 ** 983 ** Parameters p_app_uuid - applicaiton UUID 984 ** p_cback - pointer to the application callback function. 985 ** 986 ** Returns None 987 ** 988 *******************************************************************************/ 989 BTA_API extern void BTA_GATTS_AppRegister(tBT_UUID *p_app_uuid, tBTA_GATTS_CBACK *p_cback); 990 991 992 /******************************************************************************* 993 ** 994 ** Function BTA_GATTS_AppDeregister 995 ** 996 ** Description De-register with BTA GATT Server. 997 ** 998 ** Parameters server_if: server interface 999 ** 1000 ** Returns void 1001 ** 1002 *******************************************************************************/ 1003 BTA_API extern void BTA_GATTS_AppDeregister(tBTA_GATTS_IF server_if); 1004 1005 /******************************************************************************* 1006 ** 1007 ** Function BTA_GATTS_CreateService 1008 ** 1009 ** Description Create a service. When service creation is done, a callback 1010 ** event BTA_GATTS_CREATE_SRVC_EVT is called to report status 1011 ** and service ID to the profile. The service ID obtained in 1012 ** the callback function needs to be used when adding included 1013 ** service and characteristics/descriptors into the service. 1014 ** 1015 ** Parameters server_if: server interface. 1016 ** p_service_uuid: service UUID. 1017 ** inst: instance ID number of this service. 1018 ** num_handle: numble of handle requessted for this service. 1019 ** is_primary: is this service a primary one or not. 1020 ** 1021 ** Returns void 1022 ** 1023 *******************************************************************************/ 1024 BTA_API extern void BTA_GATTS_CreateService(tBTA_GATTS_IF server_if, tBT_UUID *p_service_uuid, 1025 UINT8 inst, UINT16 num_handle, BOOLEAN is_primary); 1026 1027 /******************************************************************************* 1028 ** 1029 ** Function BTA_GATTS_AddIncludeService 1030 ** 1031 ** Description This function is called to add an included service. After included 1032 ** service is included, a callback event BTA_GATTS_ADD_INCL_SRVC_EVT 1033 ** is reported the included service ID. 1034 ** 1035 ** Parameters service_id: service ID to which this included service is to 1036 ** be added. 1037 ** included_service_id: the service ID to be included. 1038 ** 1039 ** Returns void 1040 ** 1041 *******************************************************************************/ 1042 BTA_API extern void BTA_GATTS_AddIncludeService(UINT16 service_id, UINT16 included_service_id); 1043 1044 /******************************************************************************* 1045 ** 1046 ** Function BTA_GATTS_AddCharacteristic 1047 ** 1048 ** Description This function is called to add a characteristic into a service. 1049 ** 1050 ** Parameters service_id: service ID to which this included service is to 1051 ** be added. 1052 ** p_char_uuid : Characteristic UUID. 1053 ** perm : Characteristic value declaration attribute permission. 1054 ** property : Characteristic Properties 1055 ** 1056 ** Returns None 1057 ** 1058 *******************************************************************************/ 1059 BTA_API extern void BTA_GATTS_AddCharacteristic (UINT16 service_id, tBT_UUID *p_char_uuid, 1060 tBTA_GATT_PERM perm, tBTA_GATT_CHAR_PROP property); 1061 1062 /******************************************************************************* 1063 ** 1064 ** Function BTA_GATTS_AddCharDescriptor 1065 ** 1066 ** Description This function is called to add characteristic descriptor. When 1067 ** it's done, a callback event BTA_GATTS_ADD_DESCR_EVT is called 1068 ** to report the status and an ID number for this descriptor. 1069 ** 1070 ** Parameters service_id: service ID to which this charatceristic descriptor is to 1071 ** be added. 1072 ** perm: descriptor access permission. 1073 ** p_descr_uuid: descriptor UUID. 1074 ** p_descr_params: descriptor value if it's read only descriptor. 1075 ** 1076 ** Returns returns status. 1077 ** 1078 *******************************************************************************/ 1079 BTA_API extern void BTA_GATTS_AddCharDescriptor (UINT16 service_id, 1080 tBTA_GATT_PERM perm, 1081 tBT_UUID * p_descr_uuid); 1082 1083 /******************************************************************************* 1084 ** 1085 ** Function BTA_GATTS_DeleteService 1086 ** 1087 ** Description This function is called to delete a service. When this is done, 1088 ** a callback event BTA_GATTS_DELETE_EVT is report with the status. 1089 ** 1090 ** Parameters service_id: service_id to be deleted. 1091 ** 1092 ** Returns returns none. 1093 ** 1094 *******************************************************************************/ 1095 BTA_API extern void BTA_GATTS_DeleteService(UINT16 service_id); 1096 1097 /******************************************************************************* 1098 ** 1099 ** Function BTA_GATTS_StartService 1100 ** 1101 ** Description This function is called to start a service. 1102 ** 1103 ** Parameters service_id: the service ID to be started. 1104 ** sup_transport: supported trasnport. 1105 ** 1106 ** Returns None. 1107 ** 1108 *******************************************************************************/ 1109 BTA_API extern void BTA_GATTS_StartService(UINT16 service_id, tBTA_GATT_TRANSPORT sup_transport); 1110 1111 /******************************************************************************* 1112 ** 1113 ** Function BTA_GATTS_StopService 1114 ** 1115 ** Description This function is called to stop a service. 1116 ** 1117 ** Parameters service_id - service to be topped. 1118 ** 1119 ** Returns None 1120 ** 1121 *******************************************************************************/ 1122 BTA_API extern void BTA_GATTS_StopService(UINT16 service_id); 1123 1124 /******************************************************************************* 1125 ** 1126 ** Function BTA_GATTS_HandleValueIndication 1127 ** 1128 ** Description This function is called to read a characteristics descriptor. 1129 ** 1130 ** Parameters conn_id - connection identifier. 1131 ** attr_id - attribute ID to indicate. 1132 ** data_len - indicate data length. 1133 ** p_data: data to indicate. 1134 ** need_confirm - if this indication expects a confirmation or not. 1135 ** 1136 ** Returns None 1137 ** 1138 *******************************************************************************/ 1139 BTA_API extern void BTA_GATTS_HandleValueIndication (UINT16 conn_id, UINT16 attr_id, 1140 UINT16 data_len, 1141 UINT8 *p_data, 1142 BOOLEAN need_confirm); 1143 1144 /******************************************************************************* 1145 ** 1146 ** Function BTA_GATTS_SendRsp 1147 ** 1148 ** Description This function is called to send a response to a request. 1149 ** 1150 ** Parameters conn_id - connection identifier. 1151 ** trans_id - transaction ID. 1152 ** status - response status 1153 ** p_msg - response data. 1154 ** 1155 ** Returns None 1156 ** 1157 *******************************************************************************/ 1158 BTA_API extern void BTA_GATTS_SendRsp (UINT16 conn_id, UINT32 trans_id, 1159 tBTA_GATT_STATUS status, tBTA_GATTS_RSP *p_msg); 1160 1161 1162 1163 1164 /******************************************************************************* 1165 ** 1166 ** Function BTA_GATTS_Open 1167 ** 1168 ** Description Open a direct open connection or add a background auto connection 1169 ** bd address 1170 ** 1171 ** Parameters server_if: server interface. 1172 ** remote_bda: remote device BD address. 1173 ** is_direct: direct connection or background auto connection 1174 ** 1175 ** Returns void 1176 ** 1177 *******************************************************************************/ 1178 BTA_API extern void BTA_GATTS_Open(tBTA_GATTS_IF server_if, BD_ADDR remote_bda, BOOLEAN is_direct); 1179 1180 1181 /******************************************************************************* 1182 ** 1183 ** Function BTA_GATTS_CancelOpen 1184 ** 1185 ** Description Cancel a direct open connection or remove a background auto connection 1186 ** bd address 1187 ** 1188 ** Parameters server_if: server interface. 1189 ** remote_bda: remote device BD address. 1190 ** is_direct: direct connection or background auto connection 1191 ** 1192 ** Returns void 1193 ** 1194 *******************************************************************************/ 1195 BTA_API extern void BTA_GATTS_CancelOpen(tBTA_GATTS_IF server_if, BD_ADDR remote_bda, BOOLEAN is_direct); 1196 1197 1198 /******************************************************************************* 1199 ** 1200 ** Function BTA_GATTS_Close 1201 ** 1202 ** Description Close a connection a remote device. 1203 ** 1204 ** Parameters conn_id: connectino ID to be closed. 1205 ** 1206 ** Returns void 1207 ** 1208 *******************************************************************************/ 1209 BTA_API extern void BTA_GATTS_Close(UINT16 conn_id); 1210 1211 1212 #ifdef __cplusplus 1213 1214 } 1215 #endif 1216 1217 1218 #endif /* BTA_GATT_API_H */ 1219 1220