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