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