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