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