4 * Contact: Anupam Roy (anupam.r@samsung.com)
6 * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
22 #ifndef __BLUETOOTH_GATT_CLIENT_API_H
23 #define __BLUETOOTH_GATT_CLIENT_API_H
29 #include <bluetooth-api.h>
30 #include <bluetooth-gatt-server-api.h>
32 #define BLUETOOTH_GATT_ATT_DATA_LENGTH_MAX 610 /**< GATT ATT value max len */
33 #define BLUETOOTH_UUID_HEX_MAX_LEN 16 /**< UUID complete len in hex */
44 } gatt_client_event_param_t;
47 bluetooth_device_address_t device_addr;
49 char uuids[BLUETOOTH_MAX_SERVICES_FOR_DEVICE][BLUETOOTH_UUID_STRING_MAX];
50 int inst_id[BLUETOOTH_MAX_SERVICES_FOR_DEVICE];
51 int primary[BLUETOOTH_MAX_SERVICES_FOR_DEVICE];
52 } bt_services_browse_info_t;
56 BLUETOOTH_GATT_TYPE_WRITE_NO_RESPONSE = 0x01, /* Write Without Response */
57 BLUETOOTH_GATT_TYPE_WRITE = 0x2, /* Write */
58 } bluetooth_gatt_write_type_e;
61 /* Structure used for browsing a particular service's properties(chars and Incldued svcs) */
63 bluetooth_device_address_t device_address; /**< device address */
64 bt_gatt_handle_property_t svc;
65 } bluetooth_gatt_client_svc_prop_info_t;
68 bluetooth_device_address_t device_addr;
70 unsigned char svc_uuid[BLUETOOTH_UUID_HEX_MAX_LEN];
72 char uuids[BLUETOOTH_MAX_SERVICES_FOR_DEVICE][BLUETOOTH_UUID_STRING_MAX];
73 int inst_id[BLUETOOTH_MAX_SERVICES_FOR_DEVICE];
74 int props[BLUETOOTH_MAX_SERVICES_FOR_DEVICE];
75 } bt_char_browse_info_t;
78 bluetooth_device_address_t device_addr;
80 unsigned char svc_uuid[BLUETOOTH_UUID_HEX_MAX_LEN];
82 char uuids[BLUETOOTH_MAX_SERVICES_FOR_DEVICE][BLUETOOTH_UUID_STRING_MAX];
83 int inst_id[BLUETOOTH_MAX_SERVICES_FOR_DEVICE];
84 } bt_included_services_browse_info_t;
87 bluetooth_device_address_t device_addr;
89 unsigned char svc_uuid[BLUETOOTH_UUID_HEX_MAX_LEN];
91 unsigned char char_uuid[BLUETOOTH_UUID_HEX_MAX_LEN];
94 char uuids[BLUETOOTH_MAX_SERVICES_FOR_DEVICE][BLUETOOTH_UUID_STRING_MAX];
95 int inst_id[BLUETOOTH_MAX_SERVICES_FOR_DEVICE];
96 } bt_descriptor_browse_info_t;
98 /* Structure used for browsing a particular charactertic's properties(descriptors) or reading char's value */
100 bluetooth_device_address_t device_address; /**< device address */
101 bt_gatt_handle_property_t svc;
102 bt_gatt_handle_property_t characteristic;
103 } bluetooth_gatt_client_char_prop_info_t;
105 /* Structure used for reading Descriptor's value */
107 bluetooth_device_address_t device_address; /**< device address */
108 bt_gatt_handle_property_t svc;
109 bt_gatt_handle_property_t characteristic;
110 bt_gatt_handle_property_t descriptor;
111 } bluetooth_gatt_client_desc_prop_info_t;
114 typedef void (*gatt_client_cb_func_ptr)(int, gatt_client_event_param_t *, void *);
117 * @fn int bluetooth_gatt_client_init(int *client_id, gatt_client_cb_func_ptr callback_ptr, void *user_data)
118 * @brief Initialize GATT Client instance with BT stack and register the callback
120 * This function is a synchronous call.
125 int bluetooth_gatt_client_init(int *client_id,
126 const bluetooth_device_address_t *address,
127 gatt_client_cb_func_ptr callback_ptr);
129 int bluetooth_gatt_client_deinit(int client_id);
131 int bluetooth_gatt_client_get_primary_services(const bluetooth_device_address_t *address,
132 bt_gatt_handle_info_t *prim_svc);
134 int bluetooth_gatt_client_get_service_property(const char *address,
135 bt_gatt_handle_property_t *service_handle,
136 bt_gatt_service_property_t *service);
138 int bluetooth_gatt_client_get_characteristics_property(const char *address,
139 bt_gatt_handle_property_t *service_handle,
140 bt_gatt_handle_property_t *char_handle,
141 bt_gatt_char_property_t *char_prop);
143 int bluetooth_gatt_client_get_char_descriptor_property(const char *address,
144 bt_gatt_handle_property_t *service_handle,
145 bt_gatt_handle_property_t *char_handle,
146 bt_gatt_handle_property_t *descriptor_handle,
147 bt_gatt_char_descriptor_property_t *desc_prop);
149 int bluetooth_gatt_client_read_characteristic_value(const char *address,
150 bt_gatt_handle_property_t *service_handle,
151 bt_gatt_handle_property_t *char_handle);
153 int bluetooth_gatt_client_read_descriptor_value(const char *address,
154 bt_gatt_handle_property_t *service_handle,
155 bt_gatt_handle_property_t *char_handle,
156 bt_gatt_handle_property_t *descriptor_handle);
159 int bluetooth_gatt_client_write_characteristic_value_by_type(
161 bt_gatt_handle_property_t *service_handle,
162 bt_gatt_handle_property_t *char_handle,
163 bluetooth_gatt_att_data_t *data,
164 bluetooth_gatt_write_type_e write_type);
166 int bluetooth_gatt_client_write_descriptor_value(
168 bt_gatt_handle_property_t *service_handle,
169 bt_gatt_handle_property_t *char_handle,
170 bt_gatt_handle_property_t *descriptor_handle,
171 bluetooth_gatt_att_data_t *data,
172 bluetooth_gatt_write_type_e write_type);
174 int bluetooth_gatt_client_set_service_change_watcher(
175 const bluetooth_device_address_t *address,
178 int bluetooth_gatt_client_watch_characteristics(
180 bt_gatt_handle_property_t *service_handle,
181 bt_gatt_handle_property_t *char_handle,
184 gboolean is_indicate);
189 #endif /* __BLUETOOTH_GATT_CLIENT_API_H */