4 * BlueZ - Bluetooth protocol stack for Linux
6 * Copyright (C) 2014 Instituto Nokia de Tecnologia - INdT
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.
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.
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
29 void gatt_cleanup(void);
32 * Read operation result callback. Called from the service implementation
33 * informing the core (ATT layer) the result of read operation.
34 * @err: error in -errno format.
35 * @value: value of the attribute read.
36 * @len: length of value.
37 * @user_data: user_data passed in btd_attr_read_t callback.
39 #ifdef __TIZEN_PATCH__
40 typedef uint8_t (*btd_attr_read_result_t) (int err, uint8_t *value, size_t len,
43 typedef void (*btd_attr_read_result_t) (int err, uint8_t *value, size_t len,
48 * Service implementation callback passed to core (ATT layer). It manages read
49 * operations received from remote devices.
50 * @attr: reference of the attribute to be read.
51 * @bdaddr: Remote device address, which requets read value
52 * @result: callback called from the service implementation informing the
53 * value of attribute read.
54 * @user_data: user_data passed in btd_attr_read_result_t callback.
56 #ifdef __TIZEN_PATCH__
57 typedef uint8_t (*btd_attr_read_t) (struct btd_attribute *attr, bdaddr_t *bdaddr,
58 btd_attr_read_result_t result,
61 typedef void (*btd_attr_read_t) (struct btd_attribute *attr,
62 btd_attr_read_result_t result,
67 * Write operation result callback. Called from the service implementation
68 * informing the core (ATT layer) the result of the write operation. It is used
69 * to manage Write Request operations.
70 * @err: error in -errno format.
71 * @user_data: user_data passed in btd_attr_write_t callback.
73 #ifdef __TIZEN_PATCH__
74 typedef uint8_t (*btd_attr_write_result_t) (int err, void *user_data);
76 typedef void (*btd_attr_write_result_t) (int err, void *user_data);
79 * Service implementation callback passed to core (ATT layer). It manages write
80 * operations received from remote devices.
81 * @attr: reference of the attribute to be changed.
82 * @value: new attribute value.
83 * @len: length of value.
84 * @result: callback called from the service implementation informing the
85 * result of the write operation.
86 * @user_data: user_data passed in btd_attr_write_result_t callback.
88 #ifdef __TIZEN_PATCH__
89 typedef uint8_t (*btd_attr_write_t) (struct btd_attribute *attr,
90 const uint8_t *value, size_t len,
91 btd_attr_write_result_t result,
94 typedef void (*btd_attr_write_t) (struct btd_attribute *attr,
95 const uint8_t *value, size_t len,
96 btd_attr_write_result_t result,
100 /* btd_gatt_add_service - Add a service declaration to local attribute database.
101 * @uuid: Service UUID.
102 * @path: Service object path.
104 * Returns a reference to service declaration attribute. In case of error,
107 #ifdef __TIZEN_PATCH__
108 struct btd_attribute *btd_gatt_add_service(const bt_uuid_t *uuid, const char *path);
110 struct btd_attribute *btd_gatt_add_service(const bt_uuid_t *uuid);
113 #ifdef __TIZEN_PATCH__
115 * btd_gatt_update_attr_db - updates the attribute data base.
117 bool btd_gatt_update_attr_db(void);
120 * btd_get_service_path - Gets the Service object path if registerd.
122 char *btd_get_service_path(bt_uuid_t uuid);
125 * btd_get_attrib_path - Gets the attribute path if registerd.
127 const char *btd_get_attrib_path(struct btd_attribute *attrib);
130 * btd_find_service_from_attr - Gets the Service from attribute if registerd.
132 const char *btd_find_service_from_attr(struct btd_attribute *attrib);
135 * service_append_dict - Prepare the dictionar entry for a Service
136 * along with characteristics and discriptors.
138 DBusMessage *service_append_dict(bt_uuid_t uuid, DBusMessage *msg);
141 * btd_gatt_set_notify_indicate_flag - Set the notification and indication flag.
142 * @attrib: attribute.
143 * @notify_indicate: flag to set
145 void btd_gatt_set_notify_indicate_flag(struct btd_attribute *attrib,
146 bool notify_indicate);
150 * btd_gatt_remove_service - Remove a service (along with all its
151 * characteristics) from the local attribute database.
152 * @service: Service declaration attribute.
154 void btd_gatt_remove_service(struct btd_attribute *service);
157 * btd_gatt_add_char - Add a characteristic (declaration and value attributes)
158 * to local attribute database.
159 * @uuid: Characteristic UUID (16-bits or 128-bits).
160 * @properties: Characteristic properties. See Core SPEC 4.1 page 2183.
161 * @path: Characteristic object path.
162 * @read_cb: Callback used to provide the characteristic value.
163 * @write_cb: Callback called to notify the implementation that a new value
166 * Returns a reference to characteristic value attribute. In case of error,
169 #ifdef __TIZEN_PATCH__
170 struct btd_attribute *btd_gatt_add_char(const bt_uuid_t *uuid,
173 btd_attr_read_t read_cb,
174 btd_attr_write_t write_cb);
176 struct btd_attribute *btd_gatt_add_char(const bt_uuid_t *uuid,
178 btd_attr_read_t read_cb,
179 btd_attr_write_t write_cb);
183 * btd_gatt_add_char_desc - Add a characteristic descriptor to the local
184 * attribute database.
185 * @uuid: Characteristic Descriptor UUID (16-bits or 128-bits).
186 * @path: Characteristic object path.
187 * @read_cb: Callback that should be called once the characteristic
188 * descriptor attribute is read.
189 * @write_cb: Callback that should be called once the characteristic
190 * descriptor attribute is written.
192 * Returns a reference to characteristic descriptor attribute. In case of
193 * error, NULL is returned.
195 #ifdef __TIZEN_PATCH__
196 struct btd_attribute *btd_gatt_add_char_desc(const bt_uuid_t *uuid,
198 btd_attr_read_t read_cb,
199 btd_attr_write_t write_cb);
201 struct btd_attribute *btd_gatt_add_char_desc(const bt_uuid_t *uuid,
202 btd_attr_read_t read_cb,
203 btd_attr_write_t write_cb);
206 #ifdef __TIZEN_PATCH__
208 * btd_gatt_update_char - update characteristic value to the local
209 * attribute database.
210 * @uuid: Characteristic UUID (16-bits or 32-bits or 128-bits).
211 * @value: charateristci value to update the databas with
212 * @len: length of the value.
214 * Returns a TRUE or FALSE.
216 bool btd_gatt_update_char(const bt_uuid_t *uuid, uint8_t *value, size_t len);