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