3 * BlueZ - Bluetooth protocol stack for Linux
5 * Copyright (C) 2014 Google Inc.
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.
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.
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
28 #define BT_GATT_UUID_SIZE 16
30 struct bt_gatt_client;
32 struct bt_gatt_client *bt_gatt_client_new(struct gatt_db *db,
36 struct bt_gatt_client *bt_gatt_client_ref(struct bt_gatt_client *client);
37 void bt_gatt_client_unref(struct bt_gatt_client *client);
39 typedef void (*bt_gatt_client_destroy_func_t)(void *user_data);
40 typedef void (*bt_gatt_client_callback_t)(bool success, uint8_t att_ecode,
42 typedef void (*bt_gatt_client_debug_func_t)(const char *str, void *user_data);
43 typedef void (*bt_gatt_client_read_callback_t)(bool success, uint8_t att_ecode,
44 const uint8_t *value, uint16_t length,
46 typedef void (*bt_gatt_client_write_long_callback_t)(bool success,
47 bool reliable_error, uint8_t att_ecode,
49 typedef void (*bt_gatt_client_notify_callback_t)(uint16_t value_handle,
50 const uint8_t *value, uint16_t length,
52 typedef void (*bt_gatt_client_register_callback_t)(uint16_t att_ecode,
54 typedef void (*bt_gatt_client_service_changed_callback_t)(uint16_t start_handle,
58 bool bt_gatt_client_is_ready(struct bt_gatt_client *client);
59 bool bt_gatt_client_set_ready_handler(struct bt_gatt_client *client,
60 bt_gatt_client_callback_t callback,
62 bt_gatt_client_destroy_func_t destroy);
63 bool bt_gatt_client_set_service_changed(struct bt_gatt_client *client,
64 bt_gatt_client_service_changed_callback_t callback,
66 bt_gatt_client_destroy_func_t destroy);
67 bool bt_gatt_client_set_debug(struct bt_gatt_client *client,
68 bt_gatt_client_debug_func_t callback,
70 bt_gatt_client_destroy_func_t destroy);
72 uint16_t bt_gatt_client_get_mtu(struct bt_gatt_client *client);
73 struct gatt_db *bt_gatt_client_get_db(struct bt_gatt_client *client);
75 bool bt_gatt_client_cancel(struct bt_gatt_client *client, unsigned int id);
76 bool bt_gatt_client_cancel_all(struct bt_gatt_client *client);
78 unsigned int bt_gatt_client_read_value(struct bt_gatt_client *client,
79 uint16_t value_handle,
80 bt_gatt_client_read_callback_t callback,
82 bt_gatt_client_destroy_func_t destroy);
83 unsigned int bt_gatt_client_read_long_value(struct bt_gatt_client *client,
84 uint16_t value_handle, uint16_t offset,
85 bt_gatt_client_read_callback_t callback,
87 bt_gatt_client_destroy_func_t destroy);
88 unsigned int bt_gatt_client_read_multiple(struct bt_gatt_client *client,
89 uint16_t *handles, uint8_t num_handles,
90 bt_gatt_client_read_callback_t callback,
92 bt_gatt_client_destroy_func_t destroy);
94 #ifdef __TIZEN_PATCH__
95 unsigned int bt_gatt_client_write_without_response_async(
96 struct bt_gatt_client *client,
97 uint16_t value_handle,
99 const uint8_t *value, uint16_t length,
100 bt_gatt_client_callback_t callback,
102 bt_gatt_client_destroy_func_t destroy);
105 unsigned int bt_gatt_client_write_without_response(
106 struct bt_gatt_client *client,
107 uint16_t value_handle,
109 const uint8_t *value, uint16_t length);
110 unsigned int bt_gatt_client_write_value(struct bt_gatt_client *client,
111 uint16_t value_handle,
112 const uint8_t *value, uint16_t length,
113 bt_gatt_client_callback_t callback,
115 bt_gatt_client_destroy_func_t destroy);
116 unsigned int bt_gatt_client_write_long_value(struct bt_gatt_client *client,
118 uint16_t value_handle, uint16_t offset,
119 const uint8_t *value, uint16_t length,
120 bt_gatt_client_write_long_callback_t callback,
122 bt_gatt_client_destroy_func_t destroy);
123 unsigned int bt_gatt_client_prepare_write(struct bt_gatt_client *client,
125 uint16_t value_handle, uint16_t offset,
126 const uint8_t *value, uint16_t length,
127 bt_gatt_client_write_long_callback_t callback,
129 bt_gatt_client_destroy_func_t destroy);
130 unsigned int bt_gatt_client_write_execute(struct bt_gatt_client *client,
132 bt_gatt_client_callback_t callback,
134 bt_gatt_client_destroy_func_t destroy);
136 unsigned int bt_gatt_client_register_notify(struct bt_gatt_client *client,
137 uint16_t chrc_value_handle,
138 bt_gatt_client_register_callback_t callback,
139 bt_gatt_client_notify_callback_t notify,
141 bt_gatt_client_destroy_func_t destroy);
142 bool bt_gatt_client_unregister_notify(struct bt_gatt_client *client,
145 bool bt_gatt_client_set_security(struct bt_gatt_client *client, int level);
146 int bt_gatt_client_get_security(struct bt_gatt_client *client);
148 #if defined __TIZEN_PATCH__ && defined BLUEZ5_27_GATT_CLIENT
149 bool bt_gatt_discover_services(struct bt_gatt_client *client);
152 #ifdef __TIZEN_PATCH__
153 char *bt_gatt_client_get_gap_device_name(struct bt_gatt_client *client);
154 bool bt_gatt_request_att_mtu(struct bt_gatt_client *client, uint16_t mtu,
155 void *callback, void *user_data);
156 bool bt_gatt_client_svc_changed_received(struct bt_gatt_client *client);