1 /****************************************************************************** 2 * 3 * Copyright (C) 1999-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 #ifndef GATT_API_H 19 #define GATT_API_H 20 21 #include "common/bt_target.h" 22 #include "stack/gattdefs.h" 23 #include "stack/btm_ble_api.h" 24 25 /***************************************************************************** 26 ** Constants 27 *****************************************************************************/ 28 /* Success code and error codes */ 29 #define GATT_SUCCESS 0x00 30 #define GATT_INVALID_HANDLE 0x01 31 #define GATT_READ_NOT_PERMIT 0x02 32 #define GATT_WRITE_NOT_PERMIT 0x03 33 #define GATT_INVALID_PDU 0x04 34 #define GATT_INSUF_AUTHENTICATION 0x05 35 #define GATT_REQ_NOT_SUPPORTED 0x06 36 #define GATT_INVALID_OFFSET 0x07 37 #define GATT_INSUF_AUTHORIZATION 0x08 38 #define GATT_PREPARE_Q_FULL 0x09 39 #define GATT_NOT_FOUND 0x0a 40 #define GATT_NOT_LONG 0x0b 41 #define GATT_INSUF_KEY_SIZE 0x0c 42 #define GATT_INVALID_ATTR_LEN 0x0d 43 #define GATT_ERR_UNLIKELY 0x0e 44 #define GATT_INSUF_ENCRYPTION 0x0f 45 #define GATT_UNSUPPORT_GRP_TYPE 0x10 46 #define GATT_INSUF_RESOURCE 0x11 47 48 49 #define GATT_NO_RESOURCES 0x80 50 #define GATT_INTERNAL_ERROR 0x81 51 #define GATT_WRONG_STATE 0x82 52 #define GATT_DB_FULL 0x83 53 #define GATT_BUSY 0x84 54 #define GATT_ERROR 0x85 55 #define GATT_CMD_STARTED 0x86 56 #define GATT_ILLEGAL_PARAMETER 0x87 57 #define GATT_PENDING 0x88 58 #define GATT_AUTH_FAIL 0x89 59 #define GATT_MORE 0x8a 60 #define GATT_INVALID_CFG 0x8b 61 #define GATT_SERVICE_STARTED 0x8c 62 #define GATT_ENCRYPED_MITM GATT_SUCCESS 63 #define GATT_ENCRYPED_NO_MITM 0x8d 64 #define GATT_NOT_ENCRYPTED 0x8e 65 #define GATT_CONGESTED 0x8f 66 67 #define GATT_DUP_REG 0x90 68 #define GATT_ALREADY_OPEN 0x91 69 #define GATT_CANCEL 0x92 70 71 /* 0xE0 ~ 0xFC reserved for future use */ 72 #define GATT_STACK_RSP 0xE0 73 #define GATT_APP_RSP 0xE1 74 //Error caused by customer application or stack bug 75 #define GATT_UNKNOWN_ERROR 0XEF 76 77 #define GATT_CCC_CFG_ERR 0xFD /* Client Characteristic Configuration Descriptor Improperly Configured */ 78 #define GATT_PRC_IN_PROGRESS 0xFE /* Procedure Already in progress */ 79 #define GATT_OUT_OF_RANGE 0xFF /* Attribute value out of range */ 80 81 typedef UINT8 tGATT_STATUS; 82 83 84 #define GATT_RSP_ERROR 0x01 85 #define GATT_REQ_MTU 0x02 86 #define GATT_RSP_MTU 0x03 87 #define GATT_REQ_FIND_INFO 0x04 88 #define GATT_RSP_FIND_INFO 0x05 89 #define GATT_REQ_FIND_TYPE_VALUE 0x06 90 #define GATT_RSP_FIND_TYPE_VALUE 0x07 91 #define GATT_REQ_READ_BY_TYPE 0x08 92 #define GATT_RSP_READ_BY_TYPE 0x09 93 #define GATT_REQ_READ 0x0A 94 #define GATT_RSP_READ 0x0B 95 #define GATT_REQ_READ_BLOB 0x0C 96 #define GATT_RSP_READ_BLOB 0x0D 97 #define GATT_REQ_READ_MULTI 0x0E 98 #define GATT_RSP_READ_MULTI 0x0F 99 #define GATT_REQ_READ_BY_GRP_TYPE 0x10 100 #define GATT_RSP_READ_BY_GRP_TYPE 0x11 101 #define GATT_REQ_WRITE 0x12 /* 0001-0010 (write)*/ 102 #define GATT_RSP_WRITE 0x13 103 #define GATT_CMD_WRITE 0x52 /* changed in V4.0 01001-0010(write cmd)*/ 104 #define GATT_REQ_PREPARE_WRITE 0x16 105 #define GATT_RSP_PREPARE_WRITE 0x17 106 #define GATT_REQ_EXEC_WRITE 0x18 107 #define GATT_RSP_EXEC_WRITE 0x19 108 #define GATT_HANDLE_VALUE_NOTIF 0x1B 109 #define GATT_HANDLE_VALUE_IND 0x1D 110 #define GATT_HANDLE_VALUE_CONF 0x1E 111 #define GATT_SIGN_CMD_WRITE 0xD2 /* changed in V4.0 1101-0010 (signed write) see write cmd above*/ 112 #define GATT_OP_CODE_MAX GATT_HANDLE_VALUE_CONF + 1 /* 0x1E = 30 + 1 = 31*/ 113 114 #define GATT_COMMAND_FLAG 0x40 /* Command Flag: set to one means command */ 115 116 #define GATT_HANDLE_IS_VALID(x) ((x) != 0) 117 118 #define GATT_CONN_UNKNOWN 0 119 #define GATT_CONN_L2C_FAILURE 1 /* general L2cap failure */ 120 #define GATT_CONN_TIMEOUT HCI_ERR_CONNECTION_TOUT /* 0x08 connection timeout */ 121 #define GATT_CONN_TERMINATE_PEER_USER HCI_ERR_PEER_USER /* 0x13 connection terminate by peer user */ 122 #define GATT_CONN_TERMINATE_LOCAL_HOST HCI_ERR_CONN_CAUSE_LOCAL_HOST /* 0x16 connectionterminated by local host */ 123 #define GATT_CONN_FAIL_ESTABLISH HCI_ERR_CONN_FAILED_ESTABLISHMENT/* 0x03E connection fail to establish */ 124 #define GATT_CONN_LMP_TIMEOUT HCI_ERR_LMP_RESPONSE_TIMEOUT /* 0x22 connection fail for LMP response tout */ 125 #define GATT_CONN_CANCEL L2CAP_CONN_CANCEL /* 0x0100 L2CAP connection cancelled */ 126 typedef UINT16 tGATT_DISCONN_REASON; 127 128 /* MAX GATT MTU size 129 */ 130 #ifndef GATT_MAX_MTU_SIZE 131 #define GATT_MAX_MTU_SIZE 517 132 #endif 133 134 /* max length of an attribute value 135 */ 136 #ifndef GATT_MAX_ATTR_LEN 137 #define GATT_MAX_ATTR_LEN 600 138 #endif 139 140 /* default GATT MTU size over LE link 141 */ 142 #define GATT_DEF_BLE_MTU_SIZE 23 143 144 /* invalid connection ID 145 */ 146 #define GATT_INVALID_CONN_ID 0xFFFF 147 148 #ifndef GATT_CL_MAX_LCB 149 #define GATT_CL_MAX_LCB 12 // 22 150 #endif 151 152 #ifndef GATT_MAX_SCCB 153 #define GATT_MAX_SCCB 10 154 #endif 155 156 157 /* GATT notification caching timer, default to be three seconds 158 */ 159 #ifndef GATTC_NOTIF_TIMEOUT 160 #define GATTC_NOTIF_TIMEOUT 3 161 #endif 162 163 /***************************************************************************** 164 ** GATT Structure Definition 165 *****************************************************************************/ 166 167 /* Attribute permissions 168 */ 169 #define GATT_PERM_READ (1 << 0) /* bit 0 */ 170 #define GATT_PERM_READ_ENCRYPTED (1 << 1) /* bit 1 */ 171 #define GATT_PERM_READ_ENC_MITM (1 << 2) /* bit 2 */ 172 #define GATT_PERM_WRITE (1 << 4) /* bit 4 */ 173 #define GATT_PERM_WRITE_ENCRYPTED (1 << 5) /* bit 5 */ 174 #define GATT_PERM_WRITE_ENC_MITM (1 << 6) /* bit 6 */ 175 #define GATT_PERM_WRITE_SIGNED (1 << 7) /* bit 7 */ 176 #define GATT_PERM_WRITE_SIGNED_MITM (1 << 8) /* bit 8 */ 177 #define GATT_PERM_READ_AUTHORIZATION (1 << 9) /* bit 9 */ 178 #define GATT_PERM_WRITE_AUTHORIZATION (1 << 10)/* bit 10 */ 179 typedef UINT16 tGATT_PERM; 180 181 #define GATT_ENCRYPT_KEY_SIZE_MASK (0xF000) /* the MS nibble of tGATT_PERM; key size 7=0; size 16=9 */ 182 183 #define GATT_READ_ALLOWED (GATT_PERM_READ | GATT_PERM_READ_ENCRYPTED | GATT_PERM_READ_ENC_MITM | GATT_PERM_READ_AUTHORIZATION) 184 #define GATT_READ_AUTH_REQUIRED (GATT_PERM_READ_ENCRYPTED) 185 #define GATT_READ_MITM_REQUIRED (GATT_PERM_READ_ENC_MITM) 186 #define GATT_READ_ENCRYPTED_REQUIRED (GATT_PERM_READ_ENCRYPTED | GATT_PERM_READ_ENC_MITM) 187 #define GATT_READ_AUTHORIZATION (GATT_PERM_READ_AUTHORIZATION) 188 189 190 #define GATT_WRITE_ALLOWED (GATT_PERM_WRITE | GATT_PERM_WRITE_ENCRYPTED | GATT_PERM_WRITE_ENC_MITM | \ 191 GATT_PERM_WRITE_SIGNED | GATT_PERM_WRITE_SIGNED_MITM | GATT_PERM_WRITE_AUTHORIZATION) 192 193 #define GATT_WRITE_AUTH_REQUIRED (GATT_PERM_WRITE_ENCRYPTED | GATT_PERM_WRITE_SIGNED) 194 195 #define GATT_WRITE_MITM_REQUIRED (GATT_PERM_WRITE_ENC_MITM | GATT_PERM_WRITE_SIGNED_MITM) 196 197 #define GATT_WRITE_ENCRYPTED_PERM (GATT_PERM_WRITE_ENCRYPTED | GATT_PERM_WRITE_ENC_MITM) 198 199 #define GATT_WRITE_SIGNED_PERM (GATT_PERM_WRITE_SIGNED | GATT_PERM_WRITE_SIGNED_MITM) 200 201 #define GATT_WRITE_AUTHORIZATION (GATT_PERM_WRITE_AUTHORIZATION) 202 203 204 /* Characteristic properties 205 */ 206 #define GATT_CHAR_PROP_BIT_BROADCAST (1 << 0) 207 #define GATT_CHAR_PROP_BIT_READ (1 << 1) 208 #define GATT_CHAR_PROP_BIT_WRITE_NR (1 << 2) 209 #define GATT_CHAR_PROP_BIT_WRITE (1 << 3) 210 #define GATT_CHAR_PROP_BIT_NOTIFY (1 << 4) 211 #define GATT_CHAR_PROP_BIT_INDICATE (1 << 5) 212 #define GATT_CHAR_PROP_BIT_AUTH (1 << 6) 213 #define GATT_CHAR_PROP_BIT_EXT_PROP (1 << 7) 214 typedef UINT8 tGATT_CHAR_PROP; 215 216 217 /* Format of the value of a characteristic. enumeration type 218 */ 219 enum { 220 GATT_FORMAT_RES, /* rfu */ 221 GATT_FORMAT_BOOL, /* 0x01 boolean */ 222 GATT_FORMAT_2BITS, /* 0x02 2 bit */ 223 GATT_FORMAT_NIBBLE, /* 0x03 nibble */ 224 GATT_FORMAT_UINT8, /* 0x04 uint8 */ 225 GATT_FORMAT_UINT12, /* 0x05 uint12 */ 226 GATT_FORMAT_UINT16, /* 0x06 uint16 */ 227 GATT_FORMAT_UINT24, /* 0x07 uint24 */ 228 GATT_FORMAT_UINT32, /* 0x08 uint32 */ 229 GATT_FORMAT_UINT48, /* 0x09 uint48 */ 230 GATT_FORMAT_UINT64, /* 0x0a uint64 */ 231 GATT_FORMAT_UINT128, /* 0x0B uint128 */ 232 GATT_FORMAT_SINT8, /* 0x0C signed 8 bit integer */ 233 GATT_FORMAT_SINT12, /* 0x0D signed 12 bit integer */ 234 GATT_FORMAT_SINT16, /* 0x0E signed 16 bit integer */ 235 GATT_FORMAT_SINT24, /* 0x0F signed 24 bit integer */ 236 GATT_FORMAT_SINT32, /* 0x10 signed 32 bit integer */ 237 GATT_FORMAT_SINT48, /* 0x11 signed 48 bit integer */ 238 GATT_FORMAT_SINT64, /* 0x12 signed 64 bit integer */ 239 GATT_FORMAT_SINT128, /* 0x13 signed 128 bit integer */ 240 GATT_FORMAT_FLOAT32, /* 0x14 float 32 */ 241 GATT_FORMAT_FLOAT64, /* 0x15 float 64*/ 242 GATT_FORMAT_SFLOAT, /* 0x16 IEEE-11073 16 bit SFLOAT */ 243 GATT_FORMAT_FLOAT, /* 0x17 IEEE-11073 32 bit SFLOAT */ 244 GATT_FORMAT_DUINT16, /* 0x18 IEEE-20601 format */ 245 GATT_FORMAT_UTF8S, /* 0x19 UTF-8 string */ 246 GATT_FORMAT_UTF16S, /* 0x1a UTF-16 string */ 247 GATT_FORMAT_STRUCT, /* 0x1b Opaque structure*/ 248 GATT_FORMAT_MAX /* 0x1c or above reserved */ 249 }; 250 typedef UINT8 tGATT_FORMAT; 251 252 /* Characteristic Presentation Format Descriptor value 253 */ 254 typedef struct { 255 UINT16 unit; /* as UUID defined by SIG */ 256 UINT16 descr; /* as UUID as defined by SIG */ 257 tGATT_FORMAT format; 258 INT8 exp; 259 UINT8 name_spc; /* The name space of the description */ 260 } tGATT_CHAR_PRES; 261 262 /* Characteristic Report reference Descriptor format 263 */ 264 typedef struct { 265 UINT8 rpt_id; /* report ID */ 266 UINT8 rpt_type; /* report type */ 267 } tGATT_CHAR_RPT_REF; 268 269 270 #define GATT_VALID_RANGE_MAX_SIZE 16 271 typedef struct { 272 UINT8 format; 273 UINT16 len; 274 UINT8 lower_range[GATT_VALID_RANGE_MAX_SIZE]; /* in little endian format */ 275 UINT8 upper_range[GATT_VALID_RANGE_MAX_SIZE]; 276 } tGATT_VALID_RANGE; 277 278 /* Characteristic Aggregate Format attribute value 279 */ 280 #define GATT_AGGR_HANDLE_NUM_MAX 10 281 typedef struct { 282 UINT8 num_handle; 283 UINT16 handle_list[GATT_AGGR_HANDLE_NUM_MAX]; 284 } tGATT_CHAR_AGGRE; 285 286 /* Characteristic descriptor: Extended Properties value 287 */ 288 #define GATT_CHAR_BIT_REL_WRITE 0x0001 /* permits reliable writes of the Characteristic Value */ 289 #define GATT_CHAR_BIT_WRITE_AUX 0x0002 /* permits writes to the characteristic descriptor */ 290 291 292 /* characteristic descriptor: client configuration value 293 */ 294 #define GATT_CLT_CONFIG_NONE 0x0000 295 #define GATT_CLT_CONFIG_NOTIFICATION 0x0001 296 #define GATT_CLT_CONFIG_INDICATION 0x0002 297 typedef UINT16 tGATT_CLT_CHAR_CONFIG; 298 299 300 /* characteristic descriptor: server configuration value 301 */ 302 #define GATT_SVR_CONFIG_NONE 0x0000 303 #define GATT_SVR_CONFIG_BROADCAST 0x0001 304 typedef UINT16 tGATT_SVR_CHAR_CONFIG; 305 306 /* Characteristic descriptor: Extended Properties value 307 */ 308 #define GATT_CHAR_BIT_REL_WRITE 0x0001 /* permits reliable writes of the Characteristic Value */ 309 #define GATT_CHAR_BIT_WRITE_AUX 0x0002 /* permits writes to the characteristic descriptor */ 310 311 /* authentication requirement 312 */ 313 #define GATT_AUTH_REQ_NONE 0 314 #define GATT_AUTH_REQ_NO_MITM 1 /* unauthenticated encryption */ 315 #define GATT_AUTH_REQ_MITM 2 /* authenticated encryption */ 316 #define GATT_AUTH_REQ_SIGNED_NO_MITM 3 317 #define GATT_AUTH_REQ_SIGNED_MITM 4 318 typedef UINT8 tGATT_AUTH_REQ; 319 320 /* Attribute Value structure 321 */ 322 typedef struct { 323 UINT16 conn_id; 324 UINT16 handle; /* attribute handle */ 325 UINT16 offset; /* attribute value offset, if no offset is needed for the command, ignore it */ 326 UINT16 len; /* length of attribute value */ 327 tGATT_AUTH_REQ auth_req; /* authentication request */ 328 UINT8 value[GATT_MAX_ATTR_LEN]; /* the actual attribute value */ 329 } tGATT_VALUE; 330 331 typedef struct{ 332 UINT16 attr_max_len; 333 UINT16 attr_len; 334 UINT8 *attr_val; 335 }tGATT_ATTR_VAL; 336 337 typedef struct{ 338 uint8_t auto_rsp; 339 }tGATTS_ATTR_CONTROL; 340 341 /* Mask for gatt server attribute */ 342 #define GATT_ATTR_VALUE_ALLOCATED 0x01 343 typedef UINT8 tGATT_ATTR_MASK; 344 345 /* Union of the event data which is used in the server respond API to carry the server response information 346 */ 347 typedef union { 348 /* data type member event */ 349 tGATT_VALUE attr_value; /* READ, HANDLE_VALUE_IND, PREPARE_WRITE */ 350 /* READ_BLOB, READ_BY_TYPE */ 351 UINT16 handle; /* WRITE, WRITE_BLOB */ 352 353 } tGATTS_RSP; 354 355 /* Transports for the primary service */ 356 #define GATT_TRANSPORT_LE BT_TRANSPORT_LE 357 #define GATT_TRANSPORT_BR_EDR BT_TRANSPORT_BR_EDR 358 #define GATT_TRANSPORT_LE_BR_EDR (BT_TRANSPORT_LE|BT_TRANSPORT_BR_EDR) 359 typedef UINT8 tGATT_TRANSPORT; 360 361 #define GATT_PREP_WRITE_CANCEL 0x00 362 #define GATT_PREP_WRITE_EXEC 0x01 363 typedef UINT8 tGATT_EXEC_FLAG; 364 365 /* read request always based on UUID */ 366 typedef struct { 367 UINT16 handle; 368 UINT16 offset; 369 BOOLEAN is_long; 370 BOOLEAN need_rsp; 371 } tGATT_READ_REQ; 372 373 /* write request data */ 374 typedef struct { 375 UINT16 handle; /* attribute handle */ 376 UINT16 offset; /* attribute value offset, if no offset is needed for the command, ignore it */ 377 UINT16 len; /* length of attribute value */ 378 UINT8 value[GATT_MAX_ATTR_LEN]; /* the actual attribute value */ 379 BOOLEAN need_rsp; /* need write response */ 380 BOOLEAN is_prep; /* is prepare write */ 381 } tGATT_WRITE_REQ; 382 383 /* callback data for server access request from client */ 384 typedef union { 385 tGATT_READ_REQ read_req; /* read request, read by Type, read blob */ 386 387 tGATT_WRITE_REQ write_req; /* write */ 388 /* prepare write */ 389 /* write blob */ 390 UINT16 handle; /* handle value confirmation */ 391 UINT16 mtu; /* MTU exchange request */ 392 tGATT_EXEC_FLAG exec_write; /* execute write */ 393 } tGATTS_DATA; 394 395 typedef UINT8 tGATT_SERV_IF; /* GATT Service Interface */ 396 397 enum { 398 GATTS_REQ_TYPE_READ = 1, /* Attribute read request */ 399 GATTS_REQ_TYPE_WRITE, /* Attribute write request */ 400 GATTS_REQ_TYPE_WRITE_EXEC, /* Execute write */ 401 GATTS_REQ_TYPE_MTU, /* MTU exchange information */ 402 GATTS_REQ_TYPE_CONF /* handle value confirmation */ 403 }; 404 typedef UINT8 tGATTS_REQ_TYPE; 405 406 407 408 /* Client Used Data Structure 409 */ 410 /* definition of different discovery types */ 411 enum { 412 GATT_DISC_SRVC_ALL = 1, /* discover all services */ 413 GATT_DISC_SRVC_BY_UUID, /* discover service of a special type */ 414 GATT_DISC_INC_SRVC, /* discover the included service within a service */ 415 GATT_DISC_CHAR, /* discover characteristics of a service with/without type requirement */ 416 GATT_DISC_CHAR_DSCPT, /* discover characteristic descriptors of a character */ 417 GATT_DISC_MAX /* maximnun discover type */ 418 }; 419 typedef UINT8 tGATT_DISC_TYPE; 420 421 /* Discover parameters of different discovery types 422 */ 423 typedef struct { 424 tBT_UUID service; 425 UINT16 s_handle; 426 UINT16 e_handle; 427 } tGATT_DISC_PARAM; 428 429 /* GATT read type enumeration 430 */ 431 enum { 432 GATT_READ_BY_TYPE = 1, 433 GATT_READ_BY_HANDLE, 434 GATT_READ_MULTIPLE, 435 GATT_READ_CHAR_VALUE, 436 GATT_READ_PARTIAL, 437 GATT_READ_MAX 438 }; 439 typedef UINT8 tGATT_READ_TYPE; 440 441 /* Read By Type Request (GATT_READ_BY_TYPE) Data 442 */ 443 typedef struct { 444 tGATT_AUTH_REQ auth_req; 445 UINT16 s_handle; 446 UINT16 e_handle; 447 tBT_UUID uuid; 448 } tGATT_READ_BY_TYPE; 449 450 /* GATT_READ_MULTIPLE request data 451 */ 452 #define GATT_MAX_READ_MULTI_HANDLES 10 /* Max attributes to read in one request */ 453 typedef struct { 454 tGATT_AUTH_REQ auth_req; 455 UINT16 num_handles; /* number of handles to read */ 456 UINT16 handles[GATT_MAX_READ_MULTI_HANDLES]; /* handles list to be read */ 457 } tGATT_READ_MULTI; 458 459 /* Read By Handle Request (GATT_READ_BY_HANDLE) data */ 460 typedef struct { 461 tGATT_AUTH_REQ auth_req; 462 UINT16 handle; 463 } tGATT_READ_BY_HANDLE; 464 465 /* READ_BT_HANDLE_Request data */ 466 typedef struct { 467 tGATT_AUTH_REQ auth_req; 468 UINT16 handle; 469 UINT16 offset; 470 } tGATT_READ_PARTIAL; 471 472 /* Read Request Data 473 */ 474 typedef union { 475 tGATT_READ_BY_TYPE service; 476 tGATT_READ_BY_TYPE char_type; /* characteristic type */ 477 tGATT_READ_MULTI read_multiple; 478 tGATT_READ_BY_HANDLE by_handle; 479 tGATT_READ_PARTIAL partial; 480 } tGATT_READ_PARAM; 481 482 /* GATT write type enumeration */ 483 enum { 484 GATT_WRITE_NO_RSP = 1, 485 GATT_WRITE , 486 GATT_WRITE_PREPARE 487 }; 488 typedef UINT8 tGATT_WRITE_TYPE; 489 490 /* Client Operation Complete Callback Data 491 */ 492 typedef union { 493 tGATT_VALUE att_value; 494 UINT16 mtu; 495 UINT16 handle; 496 } tGATT_CL_COMPLETE; 497 498 /* GATT client operation type, used in client callback function 499 */ 500 #define GATTC_OPTYPE_NONE 0 501 #define GATTC_OPTYPE_DISCOVERY 1 502 #define GATTC_OPTYPE_READ 2 503 #define GATTC_OPTYPE_WRITE 3 504 #define GATTC_OPTYPE_EXE_WRITE 4 505 #define GATTC_OPTYPE_CONFIG 5 506 #define GATTC_OPTYPE_NOTIFICATION 6 507 #define GATTC_OPTYPE_INDICATION 7 508 typedef UINT8 tGATTC_OPTYPE; 509 510 /* characteristic declaration 511 */ 512 typedef struct { 513 tGATT_CHAR_PROP char_prop; /* characteristic properties */ 514 UINT16 val_handle; /* characteristic value attribute handle */ 515 tBT_UUID char_uuid; /* characteristic UUID type */ 516 } tGATT_CHAR_DCLR_VAL; 517 518 /* primary service group data 519 */ 520 typedef struct { 521 UINT16 e_handle; /* ending handle of the group */ 522 tBT_UUID service_type; /* group type */ 523 } tGATT_GROUP_VALUE; 524 525 526 /* included service attribute value 527 */ 528 typedef struct { 529 tBT_UUID service_type; /* included service UUID */ 530 UINT16 s_handle; /* starting handle */ 531 UINT16 e_handle; /* ending handle */ 532 } tGATT_INCL_SRVC; 533 534 typedef union { 535 tGATT_INCL_SRVC incl_service; /* include service value */ 536 tGATT_GROUP_VALUE group_value; /* Service UUID type. 537 This field is used with GATT_DISC_SRVC_ALL 538 or GATT_DISC_SRVC_BY_UUID 539 type of discovery result callback. */ 540 541 UINT16 handle; /* When used with GATT_DISC_INC_SRVC type discovery result, 542 it is the included service starting handle.*/ 543 544 tGATT_CHAR_DCLR_VAL dclr_value; /* Characteristic declaration value. 545 This field is used with GATT_DISC_CHAR type discovery.*/ 546 } tGATT_DISC_VALUE; 547 548 /* discover result record 549 */ 550 typedef struct { 551 tBT_UUID type; 552 UINT16 handle; 553 tGATT_DISC_VALUE value; 554 } tGATT_DISC_RES; 555 556 557 #define GATT_LINK_IDLE_TIMEOUT_WHEN_NO_APP 0 /* start a idle timer for this duration 558 when no application need to use the link */ 559 560 #define GATT_LINK_NO_IDLE_TIMEOUT 0xFFFF 561 562 #define GATT_INVALID_ACL_HANDLE 0xFFFF 563 /* discover result callback function */ 564 typedef void (tGATT_DISC_RES_CB) (UINT16 conn_id, tGATT_DISC_TYPE disc_type, 565 tGATT_DISC_RES *p_data); 566 567 /* discover complete callback function */ 568 typedef void (tGATT_DISC_CMPL_CB) (UINT16 conn_id, tGATT_DISC_TYPE disc_type, tGATT_STATUS status); 569 570 /* Define a callback function for when read/write/disc/config operation is completed. */ 571 typedef void (tGATT_CMPL_CBACK) (UINT16 conn_id, tGATTC_OPTYPE op, tGATT_STATUS status, 572 tGATT_CL_COMPLETE *p_data); 573 574 /* Define a callback function when an initialized connection is established. */ 575 typedef void (tGATT_CONN_CBACK) (tGATT_IF gatt_if, BD_ADDR bda, UINT16 conn_id, BOOLEAN connected, 576 tGATT_DISCONN_REASON reason, tBT_TRANSPORT transport); 577 578 /* attribute request callback for ATT server */ 579 typedef void (tGATT_REQ_CBACK )(UINT16 conn_id, UINT32 trans_id, tGATTS_REQ_TYPE type, 580 tGATTS_DATA *p_data); 581 582 /* channel congestion/uncongestion callback */ 583 typedef void (tGATT_CONGESTION_CBACK )(UINT16 conn_id, BOOLEAN congested); 584 585 /* Define a callback function when encryption is established. */ 586 typedef void (tGATT_ENC_CMPL_CB)(tGATT_IF gatt_if, BD_ADDR bda); 587 588 589 /* Define the structure that applications use to register with 590 ** GATT. This structure includes callback functions. All functions 591 ** MUST be provided. 592 */ 593 typedef struct { 594 tGATT_CONN_CBACK *p_conn_cb; 595 tGATT_CMPL_CBACK *p_cmpl_cb; 596 tGATT_DISC_RES_CB *p_disc_res_cb; 597 tGATT_DISC_CMPL_CB *p_disc_cmpl_cb; 598 tGATT_REQ_CBACK *p_req_cb; 599 tGATT_ENC_CMPL_CB *p_enc_cmpl_cb; 600 tGATT_CONGESTION_CBACK *p_congestion_cb; 601 } tGATT_CBACK; 602 603 /*********************** Start Handle Management Definitions ********************** 604 */ 605 606 607 typedef struct { 608 tBT_UUID app_uuid128; 609 tBT_UUID svc_uuid; 610 UINT16 svc_inst; 611 UINT16 s_handle; 612 UINT16 e_handle; 613 BOOLEAN is_primary; /* primary service or secondary */ 614 } tGATTS_HNDL_RANGE; 615 616 617 618 #define GATTS_SRV_CHG_CMD_ADD_CLIENT 1 619 #define GATTS_SRV_CHG_CMD_UPDATE_CLIENT 2 620 #define GATTS_SRV_CHG_CMD_REMOVE_CLIENT 3 621 #define GATTS_SRV_CHG_CMD_READ_NUM_CLENTS 4 622 #define GATTS_SRV_CHG_CMD_READ_CLENT 5 623 typedef UINT8 tGATTS_SRV_CHG_CMD; 624 625 typedef struct { 626 BD_ADDR bda; 627 BOOLEAN srv_changed; 628 } tGATTS_SRV_CHG; 629 630 631 typedef union { 632 tGATTS_SRV_CHG srv_chg; 633 UINT8 client_read_index; /* only used for sequential reading client srv chg info */ 634 } tGATTS_SRV_CHG_REQ; 635 636 typedef union { 637 tGATTS_SRV_CHG srv_chg; 638 UINT8 num_clients; 639 } tGATTS_SRV_CHG_RSP; 640 641 642 643 typedef struct { 644 tGATTS_HNDL_RANGE *p_new_srv_start; 645 } tGATTS_PENDING_NEW_SRV_START; 646 647 /* Attribute server handle ranges NV storage callback functions 648 */ 649 typedef void (tGATTS_NV_SAVE_CBACK)(BOOLEAN is_saved, tGATTS_HNDL_RANGE *p_hndl_range); 650 typedef BOOLEAN (tGATTS_NV_SRV_CHG_CBACK)(tGATTS_SRV_CHG_CMD cmd, tGATTS_SRV_CHG_REQ *p_req, 651 tGATTS_SRV_CHG_RSP *p_rsp); 652 653 typedef struct { 654 tGATTS_NV_SAVE_CBACK *p_nv_save_callback; 655 tGATTS_NV_SRV_CHG_CBACK *p_srv_chg_callback; 656 } tGATT_APPL_INFO; 657 658 /* 659 *********************** End Handle Management Definitions **********************/ 660 661 /***************************************************************************** 662 ** External Function Declarations 663 *****************************************************************************/ 664 #ifdef __cplusplus 665 extern "C" 666 { 667 #endif 668 669 /******************************************************************************* 670 ** 671 ** Function GATT_SetTraceLevel 672 ** 673 ** Description This function sets the trace level. If called with 674 ** a value of 0xFF, it simply returns the current trace level. 675 ** 676 ** Returns The new or current trace level 677 ** 678 *******************************************************************************/ 679 extern UINT8 GATT_SetTraceLevel (UINT8 new_level); 680 681 682 /*******************************************************************************/ 683 /* GATT Profile API Functions */ 684 /*******************************************************************************/ 685 /* GATT Profile Server Functions */ 686 /*******************************************************************************/ 687 /******************************************************************************* 688 ** 689 ** Function GATTS_AddHandleRange 690 ** 691 ** Description This function add the allocated handles range for the specifed 692 ** application UUID, service UUID and service instance 693 ** 694 ** Parameter p_hndl_range: pointer to allocated handles information 695 ** 696 ** Returns TRUE if handle range is added successfully; otherwise FALSE. 697 ** 698 *******************************************************************************/ 699 700 extern BOOLEAN GATTS_AddHandleRange(tGATTS_HNDL_RANGE *p_hndl_range); 701 702 /******************************************************************************* 703 ** 704 ** Function GATTS_NVRegister 705 ** 706 ** Description Application manager calls this function to register for 707 ** NV save callback function. There can be one and only one 708 ** NV save callback function. 709 ** 710 ** Parameter p_cb_info : callback informaiton 711 ** 712 ** Returns TRUE if registered OK, else FALSE 713 ** 714 *******************************************************************************/ 715 extern BOOLEAN GATTS_NVRegister (const tGATT_APPL_INFO *p_cb_info); 716 717 718 /******************************************************************************* 719 ** 720 ** Function GATTS_CreateService 721 ** 722 ** Description This function is called to reserve a block of handles for a service. 723 ** 724 ** *** It should be called only once per service instance *** 725 ** 726 ** Parameter gatt_if : application if 727 ** p_svc_uuid : service UUID 728 ** svc_inst : instance of the service inside the application 729 ** num_handles : number of handles needed by the service. 730 ** is_pri : is a primary service or not. 731 ** 732 ** Returns service handle if successful, otherwise 0. 733 ** 734 *******************************************************************************/ 735 extern UINT16 GATTS_CreateService (tGATT_IF gatt_if, tBT_UUID *p_svc_uuid, 736 UINT16 svc_inst, UINT16 num_handles, BOOLEAN is_pri); 737 738 739 /******************************************************************************* 740 ** 741 ** Function GATTS_AddIncludeService 742 ** 743 ** Description This function is called to add an included service. 744 ** 745 ** Parameter service_handle : To which service this included service is added to. 746 ** include_svc_handle : included service handle. 747 ** 748 ** Returns included service attribute handle. If 0, add included service 749 ** fail. 750 ** 751 *******************************************************************************/ 752 extern UINT16 GATTS_AddIncludeService (UINT16 service_handle, 753 UINT16 include_svc_handle); 754 755 756 /******************************************************************************* 757 ** 758 ** Function GATTS_AddCharacteristic 759 ** 760 ** Description This function is called to add a characteristic into a service. 761 ** It will add a characteristic declaration and characteristic 762 ** value declaration into the service database identified by the 763 ** service handle. 764 ** 765 ** Parameter service_handle : To which service this included service is added to. 766 ** char_uuid : Characteristic UUID. 767 ** perm : Characteristic value declaration attribute permission. 768 ** property : Characteristic Properties 769 ** 770 ** Returns Characteristic value declaration attribute handle. 0 if add 771 ** characteristic failed. 772 ** 773 *******************************************************************************/ 774 extern UINT16 GATTS_AddCharacteristic (UINT16 service_handle, tBT_UUID *p_char_uuid, 775 tGATT_PERM perm, tGATT_CHAR_PROP property, 776 tGATT_ATTR_VAL *attr_val, tGATTS_ATTR_CONTROL *control); 777 778 /******************************************************************************* 779 ** 780 ** Function GATTS_AddCharDescriptor 781 ** 782 ** Description This function is called to add a characteristic descriptor 783 ** into a service database. Add descriptor should follow add char 784 ** to which it belongs, and next add char should be done only 785 ** after all add descriptors for the previous char. 786 ** 787 ** Parameter service_handle : To which service this characteristic descriptor 788 ** is added to. 789 ** perm : Characteristic value declaration attribute 790 ** permission. 791 ** p_descr_uuid : Characteristic descriptor UUID. 792 ** 793 ** Returns Characteristic descriptor attribute handle. 0 if add 794 ** characteristic descriptor failed. 795 ** 796 *******************************************************************************/ 797 extern UINT16 GATTS_AddCharDescriptor (UINT16 service_handle, tGATT_PERM perm, 798 tBT_UUID *p_descr_uuid, tGATT_ATTR_VAL *attr_val, 799 tGATTS_ATTR_CONTROL *control); 800 801 /******************************************************************************* 802 ** 803 ** Function GATTS_DeleteService 804 ** 805 ** Description This function is called to delete a service. 806 ** 807 ** Parameter gatt_if : application interface 808 ** p_svc_uuid : service UUID 809 ** svc_inst : instance of the service inside the application 810 ** 811 ** Returns TRUE if operation succeed, FALSE if handle block was not found. 812 ** 813 *******************************************************************************/ 814 extern BOOLEAN GATTS_DeleteService (tGATT_IF gatt_if, tBT_UUID *p_svc_uuid, 815 UINT16 svc_inst); 816 817 /******************************************************************************* 818 ** 819 ** Function GATTS_StartService 820 ** 821 ** Description This function is called to start a service with GATT 822 ** 823 ** Parameter gatt_if : service handle. 824 ** p_cback : application service callback functions. 825 ** sup_transport : supported transport(s) for this primary service 826 ** 827 ** return GATT_SUCCESS if successfully started; otherwise error code. 828 ** 829 *******************************************************************************/ 830 extern tGATT_STATUS GATTS_StartService (tGATT_IF gatt_if, UINT16 service_handle, 831 tGATT_TRANSPORT sup_transport); 832 833 834 /******************************************************************************* 835 ** 836 ** Function GATTS_StopService 837 ** 838 ** Description This function is called to stop a service 839 ** 840 ** Parameter service_handle : this is the start handle of a service 841 ** 842 ** Returns None. 843 ** 844 *******************************************************************************/ 845 extern void GATTS_StopService (UINT16 service_handle); 846 847 848 /******************************************************************************* 849 ** 850 ** Function GATTs_HandleValueIndication 851 ** 852 ** Description This function sends a handle value indication to a client. 853 ** 854 ** Parameter conn_id: connection identifier. 855 ** attr_handle: Attribute handle of this handle value indication. 856 ** val_len: Length of the indicated attribute value. 857 ** p_val: Pointer to the indicated attribute value data. 858 ** 859 ** Returns GATT_SUCCESS if successfully sent or queued; otherwise error code. 860 ** 861 *******************************************************************************/ 862 extern tGATT_STATUS GATTS_HandleValueIndication (UINT16 conn_id, 863 UINT16 attr_handle, 864 UINT16 val_len, UINT8 *p_val); 865 866 /******************************************************************************* 867 ** 868 ** Function GATTS_HandleValueNotification 869 ** 870 ** Description This function sends a handle value notification to a client. 871 ** 872 ** Parameter conn_id: connection identifier. 873 ** attr_handle: Attribute handle of this handle value indication. 874 ** val_len: Length of the indicated attribute value. 875 ** p_val: Pointer to the indicated attribute value data. 876 ** 877 ** Returns GATT_SUCCESS if successfully sent; otherwise error code. 878 ** 879 *******************************************************************************/ 880 extern tGATT_STATUS GATTS_HandleValueNotification (UINT16 conn_id, UINT16 attr_handle, 881 UINT16 val_len, UINT8 *p_val); 882 883 884 /******************************************************************************* 885 ** 886 ** Function GATTS_SendRsp 887 ** 888 ** Description This function sends the server response to client. 889 ** 890 ** Parameter conn_id: connection identifier. 891 ** trans_id: transaction id 892 ** status: response status 893 ** p_msg: pointer to message parameters structure. 894 ** 895 ** Returns GATT_SUCCESS if successfully sent; otherwise error code. 896 ** 897 *******************************************************************************/ 898 extern tGATT_STATUS GATTS_SendRsp (UINT16 conn_id, UINT32 trans_id, 899 tGATT_STATUS status, tGATTS_RSP *p_msg); 900 901 902 /******************************************************************************* 903 ** 904 ** Function GATTS_SetAttributeValue 905 ** 906 ** Description This function sends to set the attribute value . 907 ** 908 ** Parameter attr_handle:the attribute handle 909 ** length: the attribute length 910 ** value: the value to be set to the attribute in the database 911 ** 912 ** Returns GATT_SUCCESS if successfully sent; otherwise error code. 913 ** 914 *******************************************************************************/ 915 tGATT_STATUS GATTS_SetAttributeValue(UINT16 attr_handle, UINT16 length, UINT8 *value); 916 917 918 /******************************************************************************* 919 ** 920 ** Function GATTS_GetAttributeValue 921 ** 922 ** Description This function sends to set the attribute value . 923 ** 924 ** Parameter attr_handle: the attribute handle 925 ** length:the attribute value length in the database 926 ** value: the attribute value out put 927 ** 928 ** Returns GATT_SUCCESS if successfully sent; otherwise error code. 929 ** 930 *******************************************************************************/ 931 tGATT_STATUS GATTS_GetAttributeValue(UINT16 attr_handle, UINT16 *length, UINT8 **value); 932 933 934 935 /*******************************************************************************/ 936 /* GATT Profile Client Functions */ 937 /*******************************************************************************/ 938 939 /******************************************************************************* 940 ** 941 ** Function GATTC_ConfigureMTU 942 ** 943 ** Description This function is called to configure the ATT MTU size for 944 ** a connection on an LE transport. 945 ** 946 ** Parameters conn_id: connection identifier. 947 ** mtu - attribute MTU size.. 948 ** 949 ** Returns GATT_SUCCESS if command started successfully. 950 ** 951 *******************************************************************************/ 952 extern tGATT_STATUS GATTC_ConfigureMTU (UINT16 conn_id); 953 954 /******************************************************************************* 955 ** 956 ** Function GATTC_Discover 957 ** 958 ** Description This function is called to do a discovery procedure on ATT server. 959 ** 960 ** Parameters conn_id: connection identifier. 961 ** disc_type:discovery type. 962 ** p_param: parameters of discovery requirement. 963 ** 964 ** Returns GATT_SUCCESS if command received/sent successfully. 965 ** 966 *******************************************************************************/ 967 extern tGATT_STATUS GATTC_Discover (UINT16 conn_id, 968 tGATT_DISC_TYPE disc_type, 969 tGATT_DISC_PARAM *p_param ); 970 /******************************************************************************* 971 ** 972 ** Function GATTC_Read 973 ** 974 ** Description This function is called to read the value of an attribute from 975 ** the server. 976 ** 977 ** Parameters conn_id: connection identifier. 978 ** type - attribute read type. 979 ** p_read - read operation parameters. 980 ** 981 ** Returns GATT_SUCCESS if command started successfully. 982 ** 983 *******************************************************************************/ 984 extern tGATT_STATUS GATTC_Read (UINT16 conn_id, tGATT_READ_TYPE type, 985 tGATT_READ_PARAM *p_read); 986 987 /******************************************************************************* 988 ** 989 ** Function GATTC_Write 990 ** 991 ** Description This function is called to read the value of an attribute from 992 ** the server. 993 ** 994 ** Parameters conn_id: connection identifier. 995 ** type - attribute write type. 996 ** p_write - write operation parameters. 997 ** 998 ** Returns GATT_SUCCESS if command started successfully. 999 ** 1000 *******************************************************************************/ 1001 extern tGATT_STATUS GATTC_Write (UINT16 conn_id, tGATT_WRITE_TYPE type, 1002 tGATT_VALUE *p_write); 1003 1004 1005 /******************************************************************************* 1006 ** 1007 ** Function GATTC_ExecuteWrite 1008 ** 1009 ** Description This function is called to send an Execute write request to 1010 ** the server. 1011 ** 1012 ** Parameters conn_id: connection identifier. 1013 ** is_execute - to execute or cancel the prepare write request(s) 1014 ** 1015 ** Returns GATT_SUCCESS if command started successfully. 1016 ** 1017 *******************************************************************************/ 1018 extern tGATT_STATUS GATTC_ExecuteWrite (UINT16 conn_id, BOOLEAN is_execute); 1019 1020 /******************************************************************************* 1021 ** 1022 ** Function GATTC_SendHandleValueConfirm 1023 ** 1024 ** Description This function is called to send a handle value confirmation 1025 ** as response to a handle value notification from server. 1026 ** 1027 ** Parameters conn_id: connection identifier. 1028 ** handle: the handle of the attribute confirmation. 1029 ** 1030 ** Returns GATT_SUCCESS if command started successfully. 1031 ** 1032 *******************************************************************************/ 1033 extern tGATT_STATUS GATTC_SendHandleValueConfirm (UINT16 conn_id, UINT16 handle); 1034 1035 1036 /******************************************************************************* 1037 ** 1038 ** Function GATT_SetIdleTimeout 1039 ** 1040 ** Description This function (common to both client and server) sets the idle 1041 ** timeout for a tansport connection 1042 ** 1043 ** Parameter bd_addr: target device bd address. 1044 ** idle_tout: timeout value in seconds. 1045 ** transport: transport option. 1046 ** 1047 ** Returns void 1048 ** 1049 *******************************************************************************/ 1050 extern void GATT_SetIdleTimeout (BD_ADDR bd_addr, UINT16 idle_tout, 1051 tGATT_TRANSPORT transport); 1052 1053 1054 /******************************************************************************* 1055 ** 1056 ** Function GATT_Register 1057 ** 1058 ** Description This function is called to register an application 1059 ** with GATT 1060 ** 1061 ** Parameter p_app_uuid128: Application UUID 1062 ** p_cb_info: callback functions. 1063 ** 1064 ** Returns 0 for error, otherwise the index of the client registered with GATT 1065 ** 1066 *******************************************************************************/ 1067 extern tGATT_IF GATT_Register (tBT_UUID *p_app_uuid128, const tGATT_CBACK *p_cb_info); 1068 1069 /******************************************************************************* 1070 ** 1071 ** Function GATT_Deregister 1072 ** 1073 ** Description This function deregistered the application from GATT. 1074 ** 1075 ** Parameters gatt_if: application interface. 1076 ** 1077 ** Returns None. 1078 ** 1079 *******************************************************************************/ 1080 extern void GATT_Deregister (tGATT_IF gatt_if); 1081 1082 /******************************************************************************* 1083 ** 1084 ** Function GATT_StartIf 1085 ** 1086 ** Description This function is called after registration to start receiving 1087 ** callbacks for registered interface. Function may call back 1088 ** with connection status and queued notifications 1089 ** 1090 ** Parameter gatt_if: application interface. 1091 ** 1092 ** Returns None 1093 ** 1094 *******************************************************************************/ 1095 extern void GATT_StartIf (tGATT_IF gatt_if); 1096 1097 /******************************************************************************* 1098 ** 1099 ** Function GATT_Connect 1100 ** 1101 ** Description This function initiate a connection to a remote device on GATT 1102 ** channel. 1103 ** 1104 ** Parameters gatt_if: application interface 1105 ** bd_addr: peer device address. 1106 ** bd_addr_type: peer device address type. 1107 ** is_direct: is a direct connection or a background auto connection 1108 ** transport : Physical transport for GATT connection (BR/EDR or LE) 1109 ** 1110 ** Returns TRUE if connection started; FALSE if connection start failure. 1111 ** 1112 *******************************************************************************/ 1113 extern BOOLEAN GATT_Connect (tGATT_IF gatt_if, BD_ADDR bd_addr, tBLE_ADDR_TYPE bd_addr_type, 1114 BOOLEAN is_direct, tBT_TRANSPORT transport, BOOLEAN is_aux); 1115 1116 1117 /******************************************************************************* 1118 ** 1119 ** Function GATT_CancelConnect 1120 ** 1121 ** Description This function terminate the connection initaition to a remote 1122 ** device on GATT channel. 1123 ** 1124 ** Parameters gatt_if: client interface. If 0 used as unconditionally disconnect, 1125 ** typically used for direct connection cancellation. 1126 ** bd_addr: peer device address. 1127 ** is_direct: is a direct connection or a background auto connection 1128 ** 1129 ** Returns TRUE if connection started; FALSE if connection start failure. 1130 ** 1131 *******************************************************************************/ 1132 extern BOOLEAN GATT_CancelConnect (tGATT_IF gatt_if, BD_ADDR bd_addr, 1133 BOOLEAN is_direct); 1134 1135 /******************************************************************************* 1136 ** 1137 ** Function GATT_Disconnect 1138 ** 1139 ** Description This function disconnect the GATT channel for this registered 1140 ** application. 1141 ** 1142 ** Parameters conn_id: connection identifier. 1143 ** 1144 ** Returns GATT_SUCCESS if disconnected. 1145 ** 1146 *******************************************************************************/ 1147 extern tGATT_STATUS GATT_Disconnect (UINT16 conn_id); 1148 1149 /******************************************************************************* 1150 ** 1151 ** Function GATT_SendServiceChangeIndication 1152 ** 1153 ** Description This function is to send a service change indication 1154 ** 1155 ** Parameters bd_addr: peer device address. 1156 ** 1157 ** Returns status. 1158 ** 1159 *******************************************************************************/ 1160 extern tGATT_STATUS GATT_SendServiceChangeIndication (BD_ADDR bd_addr); 1161 1162 /******************************************************************************* 1163 ** 1164 ** Function GATT_GetConnectionInfor 1165 ** 1166 ** Description This function use conn_id to find its associated BD address and application 1167 ** interface 1168 ** 1169 ** Parameters conn_id: connection id (input) 1170 ** p_gatt_if: application interface (output) 1171 ** bd_addr: peer device address. (output) 1172 ** transport : physical transport of the GATT connection (BR/EDR or LE) 1173 ** 1174 ** Returns TRUE the logical link information is found for conn_id 1175 ** 1176 *******************************************************************************/ 1177 extern BOOLEAN GATT_GetConnectionInfor(UINT16 conn_id, tGATT_IF *p_gatt_if, 1178 BD_ADDR bd_addr, tBT_TRANSPORT *p_transport); 1179 1180 1181 /******************************************************************************* 1182 ** 1183 ** Function GATT_GetConnIdIfConnected 1184 ** 1185 ** Description This function find the conn_id if the logical link for BD address 1186 ** and application interface is connected 1187 ** 1188 ** Parameters gatt_if: application interface (input) 1189 ** bd_addr: peer device address. (input) 1190 ** p_conn_id: connection id (output) 1191 ** transport : physical transport of the GATT connection (BR/EDR or LE) 1192 ** 1193 ** Returns TRUE the logical link is connected 1194 ** 1195 *******************************************************************************/ 1196 extern BOOLEAN GATT_GetConnIdIfConnected(tGATT_IF gatt_if, BD_ADDR bd_addr, 1197 UINT16 *p_conn_id, tBT_TRANSPORT transport); 1198 1199 1200 /******************************************************************************* 1201 ** 1202 ** Function GATT_Listen 1203 ** 1204 ** Description This function start or stop LE advertisement and listen for 1205 ** connection. 1206 ** 1207 ** Parameters gatt_if: application interface 1208 ** p_bd_addr: listen for specific address connection, or NULL for 1209 ** listen to all device connection. 1210 ** start: is a direct connection or a background auto connection 1211 ** 1212 ** Returns TRUE if advertisement is started; FALSE if adv start failure. 1213 ** 1214 *******************************************************************************/ 1215 extern BOOLEAN GATT_Listen (tGATT_IF gatt_if, BOOLEAN start, BD_ADDR_PTR bd_addr); 1216 1217 /******************************************************************************* 1218 ** 1219 ** Function GATT_ConfigServiceChangeCCC 1220 ** 1221 ** Description Configure service change indication on remote device 1222 ** 1223 ** Returns None. 1224 ** 1225 *******************************************************************************/ 1226 extern void GATT_ConfigServiceChangeCCC (BD_ADDR remote_bda, BOOLEAN enable, 1227 tBT_TRANSPORT transport); 1228 1229 #ifdef __cplusplus 1230 1231 } 1232 #endif 1233 1234 #endif /* GATT_API_H */ 1235