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