OSDN Git Service

b3c4f4b312abb40c3789578b5f8a395dfcf47d8a
[android-x86/system-bt.git] / bta / include / bta_gatt_api.h
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_GetFirstIncludedService
819 **
820 ** Description      This function is called to find the first included service of the
821 **                  service on the given server.
822 **
823 ** Parameters       conn_id: connection ID which identify the server.
824 **                  p_srvc_id: the service ID of which the included service is belonged to.
825 **                  p_uuid_cond: include service UUID, if NULL find the first available
826 **                               included service.
827 **                  p_result: output parameter which will store the GATT ID
828 **                              of the included service found.
829 **
830 ** Returns          returns status.
831 **
832 *******************************************************************************/
833 extern tBTA_GATT_STATUS  BTA_GATTC_GetFirstIncludedService(UINT16 conn_id,
834                                                            tBTA_GATT_SRVC_ID    *p_srvc_id,
835                                                            tBT_UUID               *p_uuid_cond,
836                                                            tBTA_GATTC_INCL_SVC_ID *p_result);
837
838 /*******************************************************************************
839 **
840 ** Function         BTA_GATTC_GetGattDb
841 **
842 ** Description      This function is called to get gatt db.
843 **
844 ** Parameters       conn_id: connection ID which identify the server.
845 **                  db: output parameter which will contain gatt db copy.
846 **                      Caller is responsible for freeing it.
847 **                  count: number of elements in db.
848 **
849 *******************************************************************************/
850 extern void BTA_GATTC_GetGattDb(UINT16 conn_id, UINT16 start_handle, UINT16 end_handle,
851                                 btgatt_db_element_t **db, int *count);
852
853 /*******************************************************************************
854 **
855 ** Function         BTA_GATTC_ReadCharacteristic
856 **
857 ** Description      This function is called to read a service's characteristics of
858 **                    the given characteritisc ID.
859 **
860 ** Parameters       conn_id - connectino ID.
861 **                    p_char_id - characteritic ID to read.
862 **
863 ** Returns          None
864 **
865 *******************************************************************************/
866 extern void BTA_GATTC_ReadCharacteristic (UINT16 conn_id,
867                                           tBTA_GATTC_CHAR_ID *p_char_id,
868                                           tBTA_GATT_AUTH_REQ auth_req);
869
870 /*******************************************************************************
871 **
872 ** Function         BTA_GATTC_ReadCharDescr
873 **
874 ** Description      This function is called to read a characteristics descriptor.
875 **
876 ** Parameters       conn_id - connection ID.
877 **                    p_char_descr_id - characteritic descriptor ID to read.
878 **
879 ** Returns          None
880 **
881 *******************************************************************************/
882 extern void BTA_GATTC_ReadCharDescr (UINT16 conn_id,
883                                      tBTA_GATTC_CHAR_DESCR_ID *p_char_descr_id,
884                                      tBTA_GATT_AUTH_REQ auth_req);
885
886 /*******************************************************************************
887 **
888 ** Function         BTA_GATTC_WriteCharValue
889 **
890 ** Description      This function is called to write characteristic value.
891 **
892 ** Parameters       conn_id - connection ID.
893 **                    p_char_id - characteristic ID to write.
894 **                    write_type - type of write.
895 **                  len: length of the data to be written.
896 **                  p_value - the value to be written.
897 **
898 ** Returns          None
899 **
900 *******************************************************************************/
901 extern void BTA_GATTC_WriteCharValue (UINT16 conn_id,
902                                       tBTA_GATTC_CHAR_ID *p_char_id,
903                                       tBTA_GATTC_WRITE_TYPE  write_type,
904                                       UINT16 len,
905                                       UINT8 *p_value,
906                                       tBTA_GATT_AUTH_REQ auth_req);
907
908 /*******************************************************************************
909 **
910 ** Function         BTA_GATTC_WriteCharDescr
911 **
912 ** Description      This function is called to write characteristic descriptor value.
913 **
914 ** Parameters       conn_id - connection ID
915 **                    p_char_descr_id - characteristic descriptor ID to write.
916 **                    write_type - type of write.
917 **                  p_value - the value to be written.
918 **
919 ** Returns          None
920 **
921 *******************************************************************************/
922 extern void BTA_GATTC_WriteCharDescr (UINT16 conn_id,
923                                       tBTA_GATTC_CHAR_DESCR_ID *p_char_descr_id,
924                                       tBTA_GATTC_WRITE_TYPE  write_type,
925                                       tBTA_GATT_UNFMT   *p_data,
926                                       tBTA_GATT_AUTH_REQ auth_req);
927
928 /*******************************************************************************
929 **
930 ** Function         BTA_GATTC_SendIndConfirm
931 **
932 ** Description      This function is called to send handle value confirmation.
933 **
934 ** Parameters       conn_id - connection ID.
935 **                    p_char_id - characteristic ID to confrim.
936 **
937 ** Returns          None
938 **
939 *******************************************************************************/
940 extern void BTA_GATTC_SendIndConfirm (UINT16 conn_id, tBTA_GATTC_CHAR_ID *p_char_id);
941
942 /*******************************************************************************
943 **
944 ** Function         BTA_GATTC_RegisterForNotifications
945 **
946 ** Description      This function is called to register for notification of a service.
947 **
948 ** Parameters       client_if   - client interface.
949 **                  remote_bda  - target GATT server.
950 **                  p_char_id   - pointer to GATT characteristic ID.
951 **
952 ** Returns          OK if registration succeed, otherwise failed.
953 **
954 *******************************************************************************/
955 extern tBTA_GATT_STATUS BTA_GATTC_RegisterForNotifications (tBTA_GATTC_IF      client_if,
956                                                             BD_ADDR            remote_bda,
957                                                             tBTA_GATTC_CHAR_ID *p_char_id);
958
959
960 /*******************************************************************************
961 **
962 ** Function         BTA_GATTC_DeregisterForNotifications
963 **
964 ** Description      This function is called to de-register for notification of a servbice.
965 **
966 ** Parameters       client_if - client interface.
967 **                  remote_bda - target GATT server.
968 **                  p_char_id - pointer to a GATT characteristic ID.
969 **
970 ** Returns          OK if deregistration succeed, otherwise failed.
971 **
972 *******************************************************************************/
973 extern tBTA_GATT_STATUS BTA_GATTC_DeregisterForNotifications (tBTA_GATTC_IF      client_if,
974                                                               BD_ADDR            remote_bda,
975                                                               tBTA_GATTC_CHAR_ID *p_char_id);
976
977 /*******************************************************************************
978 **
979 ** Function         BTA_GATTC_PrepareWrite
980 **
981 ** Description      This function is called to prepare write a characteristic value.
982 **
983 ** Parameters       conn_id - connection ID.
984 **                    p_char_id - GATT characteritic ID of the service.
985 **                  offset - offset of the write value.
986 **                  len: length of the data to be written.
987 **                  p_value - the value to be written.
988 **
989 ** Returns          None
990 **
991 *******************************************************************************/
992 extern void BTA_GATTC_PrepareWrite  (UINT16 conn_id,
993                                      tBTA_GATTC_CHAR_ID *p_char_id,
994                                      UINT16 offset,
995                                      UINT16 len,
996                                      UINT8 *p_value,
997                                      tBTA_GATT_AUTH_REQ auth_req);
998
999 /*******************************************************************************
1000 **
1001 ** Function         BTA_GATTC_ExecuteWrite
1002 **
1003 ** Description      This function is called to execute write a prepare write sequence.
1004 **
1005 ** Parameters       conn_id - connection ID.
1006 **                    is_execute - execute or cancel.
1007 **
1008 ** Returns          None
1009 **
1010 *******************************************************************************/
1011 extern void BTA_GATTC_ExecuteWrite  (UINT16 conn_id, BOOLEAN is_execute);
1012
1013 /*******************************************************************************
1014 **
1015 ** Function         BTA_GATTC_ReadMultiple
1016 **
1017 ** Description      This function is called to read multiple characteristic or
1018 **                  characteristic descriptors.
1019 **
1020 ** Parameters       conn_id - connectino ID.
1021 **                    p_read_multi - read multiple parameters.
1022 **
1023 ** Returns          None
1024 **
1025 *******************************************************************************/
1026 extern void BTA_GATTC_ReadMultiple(UINT16 conn_id, tBTA_GATTC_MULTI *p_read_multi,
1027                                    tBTA_GATT_AUTH_REQ auth_req);
1028
1029
1030 /*******************************************************************************
1031 **
1032 ** Function         BTA_GATTC_Refresh
1033 **
1034 ** Description      Refresh the server cache of the remote device
1035 **
1036 ** Parameters       remote_bda: remote device BD address.
1037 **
1038 ** Returns          void
1039 **
1040 *******************************************************************************/
1041 extern void BTA_GATTC_Refresh(BD_ADDR remote_bda);
1042
1043
1044 /*******************************************************************************
1045 **
1046 ** Function         BTA_GATTC_Listen
1047 **
1048 ** Description      Start advertisement to listen for connection request.
1049 **
1050 ** Parameters       client_if: server interface.
1051 **                  start: to start or stop listening for connection
1052 **                  remote_bda: remote device BD address, if listen to all device
1053 **                              use NULL.
1054 **
1055 ** Returns          void
1056 **
1057 *******************************************************************************/
1058 extern void BTA_GATTC_Listen(tBTA_GATTC_IF client_if, BOOLEAN start, BD_ADDR_PTR target_bda);
1059
1060 /*******************************************************************************
1061 **
1062 ** Function         BTA_GATTC_Broadcast
1063 **
1064 ** Description      Start broadcasting (non-connectable advertisements)
1065 **
1066 ** Parameters       client_if: client interface.
1067 **                  start: to start or stop listening for connection
1068 **
1069 ** Returns          void
1070 **
1071 *******************************************************************************/
1072 extern void BTA_GATTC_Broadcast(tBTA_GATTC_IF client_if, BOOLEAN start);
1073
1074
1075 /*******************************************************************************
1076 **
1077 ** Function         BTA_GATTC_ConfigureMTU
1078 **
1079 ** Description      Configure the MTU size in the GATT channel. This can be done
1080 **                  only once per connection.
1081 **
1082 ** Parameters       conn_id: connection ID.
1083 **                  mtu: desired MTU size to use.
1084 **
1085 ** Returns          void
1086 **
1087 *******************************************************************************/
1088 extern void BTA_GATTC_ConfigureMTU (UINT16 conn_id, UINT16 mtu);
1089
1090 /*******************************************************************************
1091 **  BTA GATT Server API
1092 ********************************************************************************/
1093
1094 /*******************************************************************************
1095 **
1096 ** Function         BTA_GATTS_Init
1097 **
1098 ** Description      This function is called to initalize GATTS module
1099 **
1100 ** Parameters       None
1101 **
1102 ** Returns          None
1103 **
1104 *******************************************************************************/
1105 extern void BTA_GATTS_Init();
1106
1107 /*******************************************************************************
1108 **
1109 ** Function         BTA_GATTS_Disable
1110 **
1111 ** Description      This function is called to disable GATTS module
1112 **
1113 ** Parameters       None.
1114 **
1115 ** Returns          None
1116 **
1117 *******************************************************************************/
1118 extern void BTA_GATTS_Disable(void);
1119
1120 /*******************************************************************************
1121 **
1122 ** Function         BTA_GATTS_AppRegister
1123 **
1124 ** Description      This function is called to register application callbacks
1125 **                    with BTA GATTS module.
1126 **
1127 ** Parameters       p_app_uuid - applicaiton UUID
1128 **                  p_cback - pointer to the application callback function.
1129 **
1130 ** Returns          None
1131 **
1132 *******************************************************************************/
1133 extern void BTA_GATTS_AppRegister(tBT_UUID *p_app_uuid, tBTA_GATTS_CBACK *p_cback);
1134
1135
1136 /*******************************************************************************
1137 **
1138 ** Function         BTA_GATTS_AppDeregister
1139 **
1140 ** Description      De-register with BTA GATT Server.
1141 **
1142 ** Parameters       server_if: server interface
1143 **
1144 ** Returns          void
1145 **
1146 *******************************************************************************/
1147 extern void BTA_GATTS_AppDeregister(tBTA_GATTS_IF server_if);
1148
1149 /*******************************************************************************
1150 **
1151 ** Function         BTA_GATTS_CreateService
1152 **
1153 ** Description      Create a service. When service creation is done, a callback
1154 **                  event BTA_GATTS_CREATE_SRVC_EVT is called to report status
1155 **                  and service ID to the profile. The service ID obtained in
1156 **                  the callback function needs to be used when adding included
1157 **                  service and characteristics/descriptors into the service.
1158 **
1159 ** Parameters       server_if: server interface.
1160 **                  p_service_uuid: service UUID.
1161 **                  inst: instance ID number of this service.
1162 **                  num_handle: numble of handle requessted for this service.
1163 **                  is_primary: is this service a primary one or not.
1164 **
1165 ** Returns          void
1166 **
1167 *******************************************************************************/
1168 extern void BTA_GATTS_CreateService(tBTA_GATTS_IF server_if, tBT_UUID *p_service_uuid,
1169                                     UINT8 inst, UINT16 num_handle, BOOLEAN is_primary);
1170
1171 /*******************************************************************************
1172 **
1173 ** Function         BTA_GATTS_AddIncludeService
1174 **
1175 ** Description      This function is called to add an included service. After included
1176 **                  service is included, a callback event BTA_GATTS_ADD_INCL_SRVC_EVT
1177 **                  is reported the included service ID.
1178 **
1179 ** Parameters       service_id: service ID to which this included service is to
1180 **                              be added.
1181 **                  included_service_id: the service ID to be included.
1182 **
1183 ** Returns          void
1184 **
1185 *******************************************************************************/
1186 extern void BTA_GATTS_AddIncludeService(UINT16 service_id, UINT16 included_service_id);
1187
1188 /*******************************************************************************
1189 **
1190 ** Function         BTA_GATTS_AddCharacteristic
1191 **
1192 ** Description      This function is called to add a characteristic into a service.
1193 **
1194 ** Parameters       service_id: service ID to which this included service is to
1195 **                              be added.
1196 **                  p_char_uuid : Characteristic UUID.
1197 **                  perm      : Characteristic value declaration attribute permission.
1198 **                  property  : Characteristic Properties
1199 **
1200 ** Returns          None
1201 **
1202 *******************************************************************************/
1203 extern void BTA_GATTS_AddCharacteristic (UINT16 service_id,  tBT_UUID   *p_char_uuid,
1204                                          tBTA_GATT_PERM perm, tBTA_GATT_CHAR_PROP property);
1205
1206 /*******************************************************************************
1207 **
1208 ** Function         BTA_GATTS_AddCharDescriptor
1209 **
1210 ** Description      This function is called to add characteristic descriptor. When
1211 **                  it's done, a callback event BTA_GATTS_ADD_DESCR_EVT is called
1212 **                  to report the status and an ID number for this descriptor.
1213 **
1214 ** Parameters       service_id: service ID to which this charatceristic descriptor is to
1215 **                              be added.
1216 **                  perm: descriptor access permission.
1217 **                  p_descr_uuid: descriptor UUID.
1218 **                  p_descr_params: descriptor value if it's read only descriptor.
1219 **
1220 ** Returns          returns status.
1221 **
1222 *******************************************************************************/
1223 extern void BTA_GATTS_AddCharDescriptor (UINT16 service_id,
1224                                          tBTA_GATT_PERM perm,
1225                                          tBT_UUID  * p_descr_uuid);
1226
1227 /*******************************************************************************
1228 **
1229 ** Function         BTA_GATTS_DeleteService
1230 **
1231 ** Description      This function is called to delete a service. When this is done,
1232 **                  a callback event BTA_GATTS_DELETE_EVT is report with the status.
1233 **
1234 ** Parameters       service_id: service_id to be deleted.
1235 **
1236 ** Returns          returns none.
1237 **
1238 *******************************************************************************/
1239 extern void  BTA_GATTS_DeleteService(UINT16 service_id);
1240
1241 /*******************************************************************************
1242 **
1243 ** Function         BTA_GATTS_StartService
1244 **
1245 ** Description      This function is called to start a service.
1246 **
1247 ** Parameters       service_id: the service ID to be started.
1248 **                  sup_transport: supported trasnport.
1249 **
1250 ** Returns          None.
1251 **
1252 *******************************************************************************/
1253 extern void  BTA_GATTS_StartService(UINT16 service_id, tBTA_GATT_TRANSPORT sup_transport);
1254
1255 /*******************************************************************************
1256 **
1257 ** Function         BTA_GATTS_StopService
1258 **
1259 ** Description      This function is called to stop a service.
1260 **
1261 ** Parameters       service_id - service to be topped.
1262 **
1263 ** Returns          None
1264 **
1265 *******************************************************************************/
1266 extern void BTA_GATTS_StopService(UINT16 service_id);
1267
1268 /*******************************************************************************
1269 **
1270 ** Function         BTA_GATTS_HandleValueIndication
1271 **
1272 ** Description      This function is called to read a characteristics descriptor.
1273 **
1274 ** Parameters       conn_id - connection identifier.
1275 **                                      attr_id - attribute ID to indicate.
1276 **                  data_len - indicate data length.
1277 **                  p_data: data to indicate.
1278 **                  need_confirm - if this indication expects a confirmation or not.
1279 **
1280 ** Returns          None
1281 **
1282 *******************************************************************************/
1283 extern void BTA_GATTS_HandleValueIndication (UINT16 conn_id, UINT16 attr_id,
1284                                              UINT16 data_len,
1285                                              UINT8 *p_data,
1286                                              BOOLEAN need_confirm);
1287
1288 /*******************************************************************************
1289 **
1290 ** Function         BTA_GATTS_SendRsp
1291 **
1292 ** Description      This function is called to send a response to a request.
1293 **
1294 ** Parameters       conn_id - connection identifier.
1295 **                  trans_id - transaction ID.
1296 **                  status - response status
1297 **                  p_msg - response data.
1298 **
1299 ** Returns          None
1300 **
1301 *******************************************************************************/
1302 extern void BTA_GATTS_SendRsp (UINT16 conn_id, UINT32 trans_id,
1303                                tBTA_GATT_STATUS status, tBTA_GATTS_RSP *p_msg);
1304
1305
1306 /*******************************************************************************
1307 **
1308 ** Function         BTA_GATTS_Open
1309 **
1310 ** Description      Open a direct open connection or add a background auto connection
1311 **                  bd address
1312 **
1313 ** Parameters       server_if: server interface.
1314 **                  remote_bda: remote device BD address.
1315 **                  is_direct: direct connection or background auto connection
1316 **
1317 ** Returns          void
1318 **
1319 *******************************************************************************/
1320 extern void BTA_GATTS_Open(tBTA_GATTS_IF server_if, BD_ADDR remote_bda,
1321                            BOOLEAN is_direct, tBTA_GATT_TRANSPORT transport);
1322
1323
1324 /*******************************************************************************
1325 **
1326 ** Function         BTA_GATTS_CancelOpen
1327 **
1328 ** Description      Cancel a direct open connection or remove a background auto connection
1329 **                  bd address
1330 **
1331 ** Parameters       server_if: server interface.
1332 **                  remote_bda: remote device BD address.
1333 **                  is_direct: direct connection or background auto connection
1334 **
1335 ** Returns          void
1336 **
1337 *******************************************************************************/
1338 extern void BTA_GATTS_CancelOpen(tBTA_GATTS_IF server_if, BD_ADDR remote_bda, BOOLEAN is_direct);
1339
1340
1341 /*******************************************************************************
1342 **
1343 ** Function         BTA_GATTS_Close
1344 **
1345 ** Description      Close a connection  a remote device.
1346 **
1347 ** Parameters       conn_id: connectino ID to be closed.
1348 **
1349 ** Returns          void
1350 **
1351 *******************************************************************************/
1352 extern void BTA_GATTS_Close(UINT16 conn_id);
1353
1354 /*******************************************************************************
1355 **
1356 ** Function         BTA_GATTS_Listen
1357 **
1358 ** Description      Start advertisement to listen for connection request for a
1359 **                  GATT server
1360 **
1361 ** Parameters       server_if: server interface.
1362 **                  start: to start or stop listening for connection
1363 **                  remote_bda: remote device BD address, if listen to all device
1364 **                              use NULL.
1365 **
1366 ** Returns          void
1367 **
1368 *******************************************************************************/
1369 extern void BTA_GATTS_Listen(tBTA_GATTS_IF server_if, BOOLEAN start,
1370                              BD_ADDR_PTR target_bda);
1371
1372
1373 #ifdef __cplusplus
1374
1375 }
1376 #endif
1377
1378
1379 #endif /* BTA_GATT_API_H */