Tizen 2.0 Release
[profile/ivi/bluez.git] / attrib / gatt.h
1 /*
2  *
3  *  BlueZ - Bluetooth protocol stack for Linux
4  *
5  *  Copyright (C) 2010  Nokia Corporation
6  *  Copyright (C) 2010  Marcel Holtmann <marcel@holtmann.org>
7  *
8  *
9  *  This program is free software; you can redistribute it and/or modify
10  *  it under the terms of the GNU General Public License as published by
11  *  the Free Software Foundation; either version 2 of the License, or
12  *  (at your option) any later version.
13  *
14  *  This program is distributed in the hope that it will be useful,
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  *  GNU General Public License for more details.
18  *
19  *  You should have received a copy of the GNU General Public License
20  *  along with this program; if not, write to the Free Software
21  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
22  *
23  */
24
25 #include <bluetooth/sdp.h>
26
27 /* GATT Profile Attribute types */
28 #define GATT_PRIM_SVC_UUID              0x2800
29 #define GATT_SND_SVC_UUID               0x2801
30 #define GATT_INCLUDE_UUID               0x2802
31 #define GATT_CHARAC_UUID                0x2803
32
33 /* GATT Characteristic Types */
34 #define GATT_CHARAC_DEVICE_NAME                 0x2A00
35 #define GATT_CHARAC_APPEARANCE                  0x2A01
36 #define GATT_CHARAC_PERIPHERAL_PRIV_FLAG        0x2A02
37 #define GATT_CHARAC_RECONNECTION_ADDRESS        0x2A03
38 #define GATT_CHARAC_PERIPHERAL_PREF_CONN        0x2A04
39 #define GATT_CHARAC_SERVICE_CHANGED             0x2A05
40
41 /* GATT Characteristic Descriptors */
42 #define GATT_CHARAC_EXT_PROPER_UUID     0x2900
43 #define GATT_CHARAC_USER_DESC_UUID      0x2901
44 #define GATT_CLIENT_CHARAC_CFG_UUID     0x2902
45 #define GATT_SERVER_CHARAC_CFG_UUID     0x2903
46 #define GATT_CHARAC_FMT_UUID            0x2904
47 #define GATT_CHARAC_AGREG_FMT_UUID      0x2905
48 #define GATT_CHARAC_VALID_RANGE_UUID    0x2906
49
50 /* Client Characteristic Configuration bit field */
51 #define GATT_CLIENT_CHARAC_CFG_NOTIF_BIT        0x0001
52 #define GATT_CLIENT_CHARAC_CFG_IND_BIT          0x0002
53
54 typedef void (*gatt_cb_t) (GSList *l, guint8 status, gpointer user_data);
55
56 struct gatt_primary {
57         char uuid[MAX_LEN_UUID_STR + 1];
58         struct att_range range;
59 };
60
61 struct gatt_char {
62         char uuid[MAX_LEN_UUID_STR + 1];
63         uint16_t handle;
64         uint8_t properties;
65         uint16_t value_handle;
66 };
67
68 guint gatt_discover_primary(GAttrib *attrib, bt_uuid_t *uuid, gatt_cb_t func,
69                                                         gpointer user_data);
70
71 guint gatt_discover_char(GAttrib *attrib, uint16_t start, uint16_t end,
72                                         bt_uuid_t *uuid, gatt_cb_t func,
73                                         gpointer user_data);
74
75 guint gatt_read_char(GAttrib *attrib, uint16_t handle, uint16_t offset,
76                                 GAttribResultFunc func, gpointer user_data);
77
78 guint gatt_write_char(GAttrib *attrib, uint16_t handle, uint8_t *value,
79                         int vlen, GAttribResultFunc func, gpointer user_data);
80
81 guint gatt_find_info(GAttrib *attrib, uint16_t start, uint16_t end,
82                                 GAttribResultFunc func, gpointer user_data);
83
84 guint gatt_write_cmd(GAttrib *attrib, uint16_t handle, uint8_t *value, int vlen,
85                                 GDestroyNotify notify, gpointer user_data);
86
87 guint gatt_read_char_by_uuid(GAttrib *attrib, uint16_t start, uint16_t end,
88                                 bt_uuid_t *uuid, GAttribResultFunc func,
89                                 gpointer user_data);
90
91 guint gatt_exchange_mtu(GAttrib *attrib, uint16_t mtu, GAttribResultFunc func,
92                                                         gpointer user_data);
93
94 gboolean gatt_parse_record(const sdp_record_t *rec,
95                                         uuid_t *prim_uuid, uint16_t *psm,
96                                         uint16_t *start, uint16_t *end);