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