ble_gatt_client
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
gatt-db.h
Go to the documentation of this file.
1 /*
2  *
3  * BlueZ - Bluetooth protocol stack for Linux
4  *
5  * Copyright (C) 2014 Intel Corporation. All rights reserved.
6  *
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21  *
22  */
23 
24 struct gatt_db;
25 struct gatt_db_attribute;
26 
27 struct gatt_db *gatt_db_new(void);
28 
29 struct gatt_db *gatt_db_ref(struct gatt_db *db);
30 void gatt_db_unref(struct gatt_db *db);
31 
32 bool gatt_db_isempty(struct gatt_db *db);
33 
35  const bt_uuid_t *uuid,
36  bool primary,
37  uint16_t num_handles);
38 
39 bool gatt_db_remove_service(struct gatt_db *db,
40  struct gatt_db_attribute *attrib);
41 bool gatt_db_clear(struct gatt_db *db);
42 bool gatt_db_clear_range(struct gatt_db *db, uint16_t start_handle,
43  uint16_t end_handle);
44 
46  uint16_t handle,
47  const bt_uuid_t *uuid,
48  bool primary,
49  uint16_t num_handles);
50 
51 typedef void (*gatt_db_read_t) (struct gatt_db_attribute *attrib,
52  unsigned int id, uint16_t offset,
53  uint8_t opcode, struct bt_att *att,
54  void *user_data);
55 
56 typedef void (*gatt_db_write_t) (struct gatt_db_attribute *attrib,
57  unsigned int id, uint16_t offset,
58  const uint8_t *value, size_t len,
59  uint8_t opcode, struct bt_att *att,
60  void *user_data);
61 
62 struct gatt_db_attribute *
64  const bt_uuid_t *uuid,
65  uint32_t permissions,
66  uint8_t properties,
69  void *user_data);
70 struct gatt_db_attribute *
72  uint16_t handle,
73  const bt_uuid_t *uuid,
74  uint32_t permissions,
75  uint8_t properties,
78  void *user_data);
79 
80 struct gatt_db_attribute *
82  const bt_uuid_t *uuid,
83  uint32_t permissions,
86  void *user_data);
87 struct gatt_db_attribute *
89  uint16_t handle,
90  const bt_uuid_t *uuid,
91  uint32_t permissions,
94  void *user_data);
95 
96 struct gatt_db_attribute *
98  struct gatt_db_attribute *include);
99 
100 bool gatt_db_service_set_active(struct gatt_db_attribute *attrib, bool active);
101 bool gatt_db_service_get_active(struct gatt_db_attribute *attrib);
102 
104  bool claimed);
106 
107 typedef void (*gatt_db_attribute_cb_t)(struct gatt_db_attribute *attrib,
108  void *user_data);
109 
110 void gatt_db_read_by_group_type(struct gatt_db *db, uint16_t start_handle,
111  uint16_t end_handle,
112  const bt_uuid_t type,
113  struct queue *queue);
114 
115 unsigned int gatt_db_find_by_type(struct gatt_db *db, uint16_t start_handle,
116  uint16_t end_handle,
117  const bt_uuid_t *type,
119  void *user_data);
120 
121 unsigned int gatt_db_find_by_type_value(struct gatt_db *db,
122  uint16_t start_handle,
123  uint16_t end_handle,
124  const bt_uuid_t *type,
125  const void *value,
126  size_t value_len,
128  void *user_data);
129 
130 void gatt_db_read_by_type(struct gatt_db *db, uint16_t start_handle,
131  uint16_t end_handle,
132  const bt_uuid_t type,
133  struct queue *queue);
134 
135 void gatt_db_find_information(struct gatt_db *db, uint16_t start_handle,
136  uint16_t end_handle,
137  struct queue *queue);
138 
139 
140 void gatt_db_foreach_service(struct gatt_db *db, const bt_uuid_t *uuid,
142  void *user_data);
144  const bt_uuid_t *uuid,
146  void *user_data,
147  uint16_t start_handle,
148  uint16_t end_handle);
149 
150 void gatt_db_service_foreach(struct gatt_db_attribute *attrib,
151  const bt_uuid_t *uuid,
153  void *user_data);
156  void *user_data);
159  void *user_data);
162  void *user_data);
163 
164 typedef void (*gatt_db_destroy_func_t)(void *user_data);
165 
166 unsigned int gatt_db_register(struct gatt_db *db,
167  gatt_db_attribute_cb_t service_added,
168  gatt_db_attribute_cb_t service_removed,
169  void *user_data,
170  gatt_db_destroy_func_t destroy);
171 bool gatt_db_unregister(struct gatt_db *db, unsigned int id);
172 
174  uint16_t handle);
175 
177  const bt_uuid_t *uuid);
178 
180  const struct gatt_db_attribute *attrib);
181 
182 uint16_t gatt_db_attribute_get_handle(const struct gatt_db_attribute *attrib);
183 
184 bool gatt_db_attribute_get_service_uuid(const struct gatt_db_attribute *attrib,
185  bt_uuid_t *uuid);
186 
188  const struct gatt_db_attribute *attrib,
189  uint16_t *start_handle,
190  uint16_t *end_handle);
191 
192 bool gatt_db_attribute_get_service_data(const struct gatt_db_attribute *attrib,
193  uint16_t *start_handle,
194  uint16_t *end_handle,
195  bool *primary,
196  bt_uuid_t *uuid);
197 
198 bool gatt_db_attribute_get_char_data(const struct gatt_db_attribute *attrib,
199  uint16_t *handle,
200  uint16_t *value_handle,
201  uint8_t *properties,
202  bt_uuid_t *uuid);
203 
204 bool gatt_db_attribute_get_incl_data(const struct gatt_db_attribute *attrib,
205  uint16_t *handle,
206  uint16_t *start_handle,
207  uint16_t *end_handle);
208 
209 uint32_t
211 
212 typedef void (*gatt_db_attribute_read_t) (struct gatt_db_attribute *attrib,
213  int err, const uint8_t *value,
214  size_t length, void *user_data);
215 
216 bool gatt_db_attribute_read(struct gatt_db_attribute *attrib, uint16_t offset,
217  uint8_t opcode, struct bt_att *att,
219 
221  unsigned int id, int err,
222  const uint8_t *value, size_t length);
223 
224 typedef void (*gatt_db_attribute_write_t) (struct gatt_db_attribute *attrib,
225  int err, void *user_data);
226 
227 bool gatt_db_attribute_write(struct gatt_db_attribute *attrib, uint16_t offset,
228  const uint8_t *value, size_t len,
229  uint8_t opcode, struct bt_att *att,
231  void *user_data);
232 
234  unsigned int id, int err);
235 
236 bool gatt_db_attribute_reset(struct gatt_db_attribute *attrib);
uint16_t gatt_db_attribute_get_handle(const struct gatt_db_attribute *attrib)
Definition: gatt-db.c:1409
command_func_t func
void(* gatt_db_read_t)(struct gatt_db_attribute *attrib, unsigned int id, uint16_t offset, uint8_t opcode, struct bt_att *att, void *user_data)
Definition: gatt-db.h:51
bool gatt_db_attribute_reset(struct gatt_db_attribute *attrib)
Definition: gatt-db.c:1752
enum att_op_type type
Definition: att.c:141
void gatt_db_service_foreach_desc(struct gatt_db_attribute *attrib, gatt_db_attribute_cb_t func, void *user_data)
Definition: gatt-db.c:1291
bool gatt_db_attribute_get_service_data(const struct gatt_db_attribute *attrib, uint16_t *start_handle, uint16_t *end_handle, bool *primary, bt_uuid_t *uuid)
Definition: gatt-db.c:1465
struct gatt_db_attribute * gatt_db_get_service_with_uuid(struct gatt_db *db, const bt_uuid_t *uuid)
Definition: gatt-db.c:1385
uint8_t * value
Definition: gatt-db.c:100
void(* gatt_db_attribute_write_t)(struct gatt_db_attribute *attrib, int err, void *user_data)
Definition: gatt-db.h:224
bool gatt_db_attribute_get_char_data(const struct gatt_db_attribute *attrib, uint16_t *handle, uint16_t *value_handle, uint8_t *properties, bt_uuid_t *uuid)
Definition: gatt-db.c:1495
void(* gatt_db_attribute_cb_t)(struct gatt_db_attribute *attrib, void *user_data)
Definition: gatt-db.h:107
uint32_t gatt_db_attribute_get_permissions(const struct gatt_db_attribute *attrib)
Definition: gatt-db.c:1569
bool gatt_db_service_get_claimed(struct gatt_db_attribute *attrib)
Definition: gatt-db.c:960
uint16_t value_len
Definition: gatt-db.c:99
bool gatt_db_attribute_write_result(struct gatt_db_attribute *attrib, unsigned int id, int err)
Definition: gatt-db.c:1734
void gatt_db_read_by_group_type(struct gatt_db *db, uint16_t start_handle, uint16_t end_handle, const bt_uuid_t type, struct queue *queue)
Definition: gatt-db.c:968
struct gatt_db_attribute * gatt_db_get_attribute(struct gatt_db *db, uint16_t handle)
Definition: gatt-db.c:1349
bool gatt_db_clear(struct gatt_db *db)
Definition: gatt-db.c:442
Definition: queue.c:40
bool gatt_db_unregister(struct gatt_db *db, unsigned int id)
Definition: gatt-db.c:638
void * user_data
Definition: gatt-db.c:104
struct gatt_db * gatt_db_ref(struct gatt_db *db)
Definition: gatt-db.c:208
uint32_t permissions
Definition: gatt-db.c:98
struct gatt_db_attribute * gatt_db_service_insert_descriptor(struct gatt_db_attribute *attrib, uint16_t handle, const bt_uuid_t *uuid, uint32_t permissions, gatt_db_read_t read_func, gatt_db_write_t write_func, void *user_data)
Definition: gatt-db.c:835
unsigned int gatt_db_find_by_type_value(struct gatt_db *db, uint16_t start_handle, uint16_t end_handle, const bt_uuid_t *type, const void *value, size_t value_len, gatt_db_attribute_cb_t func, void *user_data)
Definition: gatt-db.c:1077
bool gatt_db_attribute_read_result(struct gatt_db_attribute *attrib, unsigned int id, int err, const uint8_t *value, size_t length)
Definition: gatt-db.c:1642
struct gatt_db_attribute * gatt_db_service_add_characteristic(struct gatt_db_attribute *attrib, const bt_uuid_t *uuid, uint32_t permissions, uint8_t properties, gatt_db_read_t read_func, gatt_db_write_t write_func, void *user_data)
Definition: gatt-db.c:785
void gatt_db_foreach_service(struct gatt_db *db, const bt_uuid_t *uuid, gatt_db_attribute_cb_t func, void *user_data)
Definition: gatt-db.c:1200
void gatt_db_service_foreach_char(struct gatt_db_attribute *attrib, gatt_db_attribute_cb_t func, void *user_data)
Definition: gatt-db.c:1284
bool gatt_db_clear_range(struct gatt_db *db, uint16_t start_handle, uint16_t end_handle)
Definition: gatt-db.c:481
void gatt_db_find_information(struct gatt_db *db, uint16_t start_handle, uint16_t end_handle, struct queue *queue)
Definition: gatt-db.c:1187
const bt_uuid_t * gatt_db_attribute_get_type(const struct gatt_db_attribute *attrib)
Definition: gatt-db.c:1400
uint16_t handle
Definition: gatt-db.c:96
bool gatt_db_attribute_read(struct gatt_db_attribute *attrib, uint16_t offset, uint8_t opcode, struct bt_att *att, gatt_db_attribute_read_t func, void *user_data)
Definition: gatt-db.c:1590
struct gatt_db_attribute * gatt_db_service_add_included(struct gatt_db_attribute *attrib, struct gatt_db_attribute *include)
Definition: gatt-db.c:868
void(* gatt_db_destroy_func_t)(void *user_data)
Definition: gatt-db.h:164
gatt_db_read_t read_func
Definition: gatt-db.c:102
void gatt_db_unref(struct gatt_db *db)
Definition: gatt-db.c:328
bool gatt_db_attribute_get_service_handles(const struct gatt_db_attribute *attrib, uint16_t *start_handle, uint16_t *end_handle)
Definition: gatt-db.c:1448
gatt_db_write_t write_func
Definition: gatt-db.c:103
struct gatt_db_attribute * gatt_db_add_service(struct gatt_db *db, const bt_uuid_t *uuid, bool primary, uint16_t num_handles)
Definition: gatt-db.c:596
bt_uuid_t uuid
Definition: gatt-db.c:97
unsigned int gatt_db_find_by_type(struct gatt_db *db, uint16_t start_handle, uint16_t end_handle, const bt_uuid_t *type, gatt_db_attribute_cb_t func, void *user_data)
Definition: gatt-db.c:1056
struct gatt_db_attribute * gatt_db_service_insert_characteristic(struct gatt_db_attribute *attrib, uint16_t handle, const bt_uuid_t *uuid, uint32_t permissions, uint8_t properties, gatt_db_read_t read_func, gatt_db_write_t write_func, void *user_data)
Definition: gatt-db.c:766
void(* gatt_db_attribute_read_t)(struct gatt_db_attribute *attrib, int err, const uint8_t *value, size_t length, void *user_data)
Definition: gatt-db.h:212
void gatt_db_read_by_type(struct gatt_db *db, uint16_t start_handle, uint16_t end_handle, const bt_uuid_t type, struct queue *queue)
Definition: gatt-db.c:1136
Definition: att.c:64
bool gatt_db_service_set_active(struct gatt_db_attribute *attrib, bool active)
Definition: gatt-db.c:922
bool gatt_db_service_set_claimed(struct gatt_db_attribute *attrib, bool claimed)
Definition: gatt-db.c:949
void gatt_db_service_foreach(struct gatt_db_attribute *attrib, const bt_uuid_t *uuid, gatt_db_attribute_cb_t func, void *user_data)
Definition: gatt-db.c:1258
struct gatt_db_attribute * gatt_db_insert_service(struct gatt_db *db, uint16_t handle, const bt_uuid_t *uuid, bool primary, uint16_t num_handles)
Definition: gatt-db.c:531
unsigned int gatt_db_register(struct gatt_db *db, gatt_db_attribute_cb_t service_added, gatt_db_attribute_cb_t service_removed, void *user_data, gatt_db_destroy_func_t destroy)
Definition: gatt-db.c:605
bool gatt_db_attribute_write(struct gatt_db_attribute *attrib, uint16_t offset, const uint8_t *value, size_t len, uint8_t opcode, struct bt_att *att, gatt_db_attribute_write_t func, void *user_data)
Definition: gatt-db.c:1674
struct gatt_db * gatt_db_new(void)
Definition: gatt-db.c:218
struct gatt_db_attribute * gatt_db_service_add_descriptor(struct gatt_db_attribute *attrib, const bt_uuid_t *uuid, uint32_t permissions, gatt_db_read_t read_func, gatt_db_write_t write_func, void *user_data)
Definition: gatt-db.c:852
void gatt_db_foreach_service_in_range(struct gatt_db *db, const bt_uuid_t *uuid, gatt_db_attribute_cb_t func, void *user_data, uint16_t start_handle, uint16_t end_handle)
Definition: gatt-db.c:1237
void(* gatt_db_write_t)(struct gatt_db_attribute *attrib, unsigned int id, uint16_t offset, const uint8_t *value, size_t len, uint8_t opcode, struct bt_att *att, void *user_data)
Definition: gatt-db.h:56
void gatt_db_service_foreach_incl(struct gatt_db_attribute *attrib, gatt_db_attribute_cb_t func, void *user_data)
Definition: gatt-db.c:1330
bool gatt_db_isempty(struct gatt_db *db)
Definition: gatt-db.c:339
uint8_t opcode
Definition: att.c:140
bool gatt_db_service_get_active(struct gatt_db_attribute *attrib)
Definition: gatt-db.c:941
bool gatt_db_attribute_get_incl_data(const struct gatt_db_attribute *attrib, uint16_t *handle, uint16_t *start_handle, uint16_t *end_handle)
Definition: gatt-db.c:1532
bool gatt_db_remove_service(struct gatt_db *db, struct gatt_db_attribute *attrib)
Definition: gatt-db.c:425
bool gatt_db_attribute_get_service_uuid(const struct gatt_db_attribute *attrib, bt_uuid_t *uuid)
Definition: gatt-db.c:1417