4 * Copyright (c) 2016-2017 Samsung Electronics Co., Ltd.
6 * Contact: Anupam Roy (anupam.r@samsung.com)
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 BT_SERVICE_GATT_H_
23 #define BT_SERVICE_GATT_H_
26 #include <sys/types.h>
27 #include "bluetooth-api.h"
28 #include "bluetooth-gatt-server-api.h"
30 #ifdef TIZEN_GATT_CLIENT
31 #include "bluetooth-gatt-client-api.h"
38 int _bt_gatt_init(void);
40 void _bt_gatt_deinit(void);
42 int _bt_get_allocated_server_instance(const char *sender, int adv_handle, gboolean use_reserved_slot);
44 int _bt_register_server_instance(const char *sender, int adv_handle);
46 int _bt_unregister_server_instance(const char *sender, int adv_handle);
48 char* _bt_get_sender_and_handle(int server_instance, int *adv_handle);
50 int _bt_register_server_instance(const char *sender, int adv_handle);
52 void _bt_get_adv_handle_from_instance(int server_inst, int *adv_handle);
54 void _bt_set_new_scan_rsp_data(bluetooth_scan_resp_data_t *scan, int len, int instance);
56 void _bt_set_new_adv_data(bluetooth_advertising_data_t *adv, int len, int instance);
58 void _bt_update_adv_handle(const char *sender, int adv_handle);
60 void _bt_get_previous_adv_data(bluetooth_advertising_data_t *adv, int *len, int instance);
62 void _bt_get_previous_scan_rsp_data(bluetooth_scan_resp_data_t *scan, int *len, int instance);
64 int _bt_is_sender_gatt_server_with_no_adv(const char *sender, int adv_handle);
66 void _bt_check_adv_app_termination(const char *name);
68 int _bt_gatt_server_add_service(char *sender, int service_type,
69 int num_handles, char *svc_uuid, int instance_id);
71 int _bt_gatt_server_add_included_service(char *sender, int instance_id,
72 int service_handle, int included_svc_handle);
74 int _bt_gatt_server_add_characteristic(char *sender, char *char_uuid,
75 bluetooth_gatt_server_attribute_params_t *param);
77 int _bt_gatt_server_add_descriptor(char *sender, char *desc_uuid,
78 bt_gatt_permission_t *perm, int service_handle, int instance_id);
80 int _bt_gatt_server_start_service(char *sender, int service_handle, int instance_id);
82 int _bt_gatt_server_stop_service(char *sender, int service_handle, int instance_id);
84 int _bt_gatt_server_delete_service(char *sender, int service_handle, int instance_id);
86 int _bt_gatt_server_send_response(char *sender, bluetooth_gatt_att_data_t *data,
87 bluetooth_gatt_server_response_params_t *param);
89 int _bt_gatt_server_send_indication(char *sender, bluetooth_device_address_t *addr, bluetooth_gatt_att_data_t *data,
90 bluetooth_gatt_server_indication_params_t *param);
92 int _bt_gatt_server_update_attribute_value(char *sender, int instance_id,
93 bluetooth_gatt_server_update_value_t *param);
95 int _bt_get_att_mtu(bluetooth_device_address_t *address,
98 #ifdef TIZEN_GATT_CLIENT
99 char * _bt_gatt_get_default_gatt_client_uuid(void);
101 int _bt_register_gatt_client_instance(const char *sender,
102 bluetooth_device_address_t *address);
104 gboolean _bt_is_remote_gatt_device_connected(bluetooth_device_address_t *address);
107 int _bt_connect_le_device(bluetooth_device_address_t *address,
108 int auto_connect, int client_id);
110 int _bt_gatt_get_primary_services(char *address);
112 int _bt_gatt_get_all_characteristic(bluetooth_gatt_client_svc_prop_info_t *svc);
114 int _bt_gatt_get_all_characteristic_properties(
115 bluetooth_gatt_client_char_prop_info_t *prop);
117 int _bt_gatt_read_characteristic_value(
118 bluetooth_gatt_client_char_prop_info_t *desc);
120 int _bt_gatt_read_descriptor_value(
121 bluetooth_gatt_client_desc_prop_info_t *desc);
123 int _bt_gatt_write_characteristic_value_by_type(
124 bluetooth_gatt_client_char_prop_info_t *chr,
125 bluetooth_gatt_att_data_t *data,
126 bluetooth_gatt_write_type_e write_type);
128 int _bt_gatt_write_descriptor_value_by_type(
129 bluetooth_gatt_client_desc_prop_info_t *desc,
130 bluetooth_gatt_att_data_t *data,
131 bluetooth_gatt_write_type_e write_type);
133 int _bt_disconnect_le_device(bluetooth_device_address_t *address,
136 int _bt_gatt_watch_characteristic(bluetooth_gatt_client_char_prop_info_t *chr,
137 int client_id, gboolean is_notify);
139 int _bt_gatt_watch_service_changed_indication(const char *sender,
140 bluetooth_device_address_t *address,
141 gboolean is_enabled);
143 int _bt_unregister_gatt_client_instance(const char *sender,
147 //int _bt_gatt_server_enable_application(int instance_id);
149 int _bt_gatt_server_register(char *sender);
151 int _bt_gatt_server_unregister(char *sender);
153 int _bt_gatt_server_update_multi_adv_info(char *name, int instance_id);
155 int _bt_gatt_server_connect_remote_client(char *sender,
156 bluetooth_device_address_t *address, int instance_id);
158 int _bt_gatt_server_disconnect_remote_client(char *sender,
159 bluetooth_device_address_t *address,
162 int _bt_gatt_server_add_service(char *sender, int service_type,
163 int num_handles, char *svc_uuid, int instance_id);
165 int _bt_gatt_server_add_included_service(char *sender, int instance_id,
166 int service_handle, int included_svc_handle);
168 int _bt_gatt_server_add_characteristic(char *sender, char *char_uuid,
169 bluetooth_gatt_server_attribute_params_t *param);
171 int _bt_gatt_server_add_descriptor(char *sender, char *desc_uuid,
172 bt_gatt_permission_t *perm, int service_handle, int instance_id);
174 int _bt_gatt_server_start_service(char *sender, int service_handle, int instance_id);
176 int _bt_gatt_server_stop_service(char *sender, int service_handle, int instance_id);
178 int _bt_gatt_server_delete_service(char *sender, int service_handle, int instance_id);
180 int _bt_gatt_server_send_indication(char *sender, bluetooth_device_address_t *addr, bluetooth_gatt_att_data_t *data,
181 bluetooth_gatt_server_indication_params_t *param);
183 int _bt_gatt_server_send_response(char *sender, bluetooth_gatt_att_data_t *data,
184 bluetooth_gatt_server_response_params_t *param);
186 void _bt_gatt_server_clear_req_info(void);
188 void _bt_gatt_server_clear_connection_info(void);
190 bt_product_gatt_permission_t _bt_gatt_convert_attr_permission_to_stack_specific(
191 bt_gatt_permission_t perm);
193 void _bt_check_gatt_server_app_termination(const char *name);
195 int _bt_gatt_server_get_att_mtu(bluetooth_device_address_t *address, unsigned int *mtu);
201 #endif /* __cplusplus */
202 #endif /* BT_SERVICE_GATT_H_ */