BT 5.0: Add APIs to support set/read PHYs
[platform/core/connectivity/bluetooth-frwk.git] / bt-service / services / include / bt-service-gatt.h
1 /*
2  * Bluetooth-frwk
3  *
4  * Copyright (c) 2016-2017 Samsung Electronics Co., Ltd.
5  *
6  * Contact: Anupam Roy (anupam.r@samsung.com)
7  *
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
11  *
12  *              http://www.apache.org/licenses/LICENSE-2.0
13  *
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.
19  *
20  */
21
22 #ifndef BT_SERVICE_GATT_H_
23 #define BT_SERVICE_GATT_H_
24
25 #include <glib.h>
26 #include <sys/types.h>
27 #include "bluetooth-api.h"
28 #include "bluetooth-gatt-server-api.h"
29 #include "bluetooth-gatt-client-api.h"
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 int _bt_gatt_init(void);
36
37 void _bt_gatt_deinit(void);
38
39 int _bt_get_allocated_server_instance(const char *sender, int adv_handle, gboolean use_reserved_slot);
40
41 int _bt_register_server_instance(const char *sender, int adv_handle);
42
43 int _bt_unregister_server_instance(const char *sender, int adv_handle);
44
45 char* _bt_get_sender_and_handle(int server_instance, int *adv_handle);
46
47 int _bt_register_server_instance(const char *sender, int adv_handle);
48
49 void _bt_get_adv_handle_from_instance(int server_inst, int *adv_handle);
50
51 void _bt_set_new_scan_rsp_data(bluetooth_scan_resp_data_t *scan, int len, int instance);
52
53 void _bt_set_new_adv_data(bluetooth_advertising_data_t *adv, int len, int instance);
54
55 void _bt_update_adv_handle(const char *sender, int adv_handle);
56
57 void _bt_get_previous_adv_data(bluetooth_advertising_data_t *adv, int *len, int instance);
58
59 void _bt_get_previous_scan_rsp_data(bluetooth_scan_resp_data_t *scan, int *len, int instance);
60
61 int _bt_is_sender_gatt_server_with_no_adv(const char *sender, int adv_handle);
62
63 void _bt_check_adv_app_termination(const char *name);
64
65 int _bt_gatt_server_add_service(char *sender, int service_type,
66                 int num_handles, char *svc_uuid, int instance_id);
67
68 int _bt_gatt_server_add_included_service(char *sender, int instance_id,
69                 int service_handle, int included_svc_handle);
70
71 int _bt_gatt_server_add_characteristic(char *sender, char *char_uuid,
72                 bluetooth_gatt_server_attribute_params_t *param);
73
74 int _bt_gatt_server_add_descriptor(char *sender, char *desc_uuid,
75                 bt_gatt_permission_t *perm, int service_handle, int instance_id);
76
77 int _bt_gatt_server_start_service(char *sender, int service_handle, int instance_id);
78
79 int _bt_gatt_server_stop_service(char *sender, int service_handle, int instance_id);
80
81 int _bt_gatt_server_delete_service(char *sender, int service_handle, int instance_id);
82
83 int _bt_gatt_server_send_response(char *sender, bluetooth_gatt_att_data_t *data,
84                 bluetooth_gatt_server_response_params_t *param);
85
86 int _bt_gatt_server_send_indication(char *sender, bluetooth_device_address_t *addr, bluetooth_gatt_att_data_t *data,
87                 bluetooth_gatt_server_indication_params_t *param);
88
89 int _bt_gatt_server_update_attribute_value(char *sender, int instance_id,
90                 bluetooth_gatt_server_update_value_t *param);
91
92 int _bt_get_att_mtu(bluetooth_device_address_t *address,
93                 unsigned int *mtu);
94
95 int _bt_gatt_server_acquire_send_response(char *sender, bluetooth_gatt_server_acquire_response_params_t *param, void *);
96
97 int _bt_gatt_server_set_service_persistence(const char *uuid);
98
99 int _bt_gatt_server_unset_service_persistence(const char *uuid);
100
101 //#define __INTEGRATE_GATT_INFO__ // TODO: this feature can be used if easy setup scenario is fully supported
102 #ifndef __INTEGRATE_GATT_INFO__
103 struct gatt_client_info_t *_bt_find_remote_gatt_client_info(char *address);
104 #else
105 struct gatt_conn_info_t *_bt_find_remote_gatt_client_info(char *address);
106 #endif
107
108 char * _bt_gatt_get_default_gatt_client_uuid(void);
109
110 int _bt_register_gatt_client_instance(const char *sender,
111                 bluetooth_device_address_t *address);
112
113 gboolean _bt_is_remote_gatt_device_connected(bluetooth_device_address_t *address);
114
115 void _bt_handle_invocation_context(int function_name, void *data);
116
117 int _bt_connect_le_device(bluetooth_device_address_t *address,
118                 int auto_connect, int client_id);
119
120 int _bt_gatt_get_data_batching_available_packets(
121                 guint *available_packets);
122
123 int _bt_gatt_enable_data_batching(bluetooth_device_address_t *address,
124                 int packet_threshold, int timeout);
125
126 int _bt_gatt_disable_data_batching(bluetooth_device_address_t *address);
127
128 int _bt_gatt_get_primary_services(char *address);
129
130 int _bt_gatt_get_all_characteristic(bluetooth_gatt_client_svc_prop_info_t *svc);
131
132 int _bt_gatt_get_all_characteristic_properties(
133                 bluetooth_gatt_client_char_prop_info_t *prop);
134
135 int _bt_gatt_read_characteristic_value(
136                 bluetooth_gatt_client_char_prop_info_t *desc);
137
138 int _bt_gatt_read_descriptor_value(
139                 bluetooth_gatt_client_desc_prop_info_t *desc);
140
141 int _bt_gatt_write_characteristic_value_by_type(
142                 bluetooth_gatt_client_char_prop_info_t *chr,
143                 bluetooth_gatt_att_data_t *data,
144                 bluetooth_gatt_write_type_e write_type);
145
146 int _bt_gatt_acquire_notify(bluetooth_gatt_client_char_prop_info_t *chr, int *fd , int *mtu);
147
148 int _bt_gatt_acquire_write(bluetooth_gatt_client_char_prop_info_t *chr, int *fd , int *mtu);
149
150 int _bt_gatt_write_descriptor_value_by_type(
151                 bluetooth_gatt_client_desc_prop_info_t *desc,
152                 bluetooth_gatt_att_data_t *data,
153                 bluetooth_gatt_write_type_e write_type);
154
155 int _bt_disconnect_le_device(bluetooth_device_address_t *address,
156                 int client_id);
157
158 int _bt_gatt_watch_characteristic(bluetooth_gatt_client_char_prop_info_t *chr,
159                 int client_id, gboolean is_notify);
160
161 int _bt_gatt_watch_service_changed_indication(const char *sender,
162                 bluetooth_device_address_t *address,
163                 gboolean is_enabled);
164
165 int _bt_unregister_gatt_client_instance(const char *sender,
166                 int client_id);
167 int _bt_request_att_mtu(bluetooth_device_address_t *device_address, unsigned int mtu);
168
169 int _bt_gatt_server_read_phy(bluetooth_device_address_t *address);
170 int _bt_gatt_server_set_phy(bluetooth_device_address_t *device_address,
171                 int tx_phy, int rx_phy, int phy_options);
172 int _bt_gatt_client_read_phy(bluetooth_device_address_t *address);
173 int _bt_gatt_client_set_phy(bluetooth_device_address_t *device_address,
174                 int tx_phy, int rx_phy, int phy_options);
175
176
177 #ifndef __INTEGRATE_GATT_INFO__
178 struct gatt_server_info_t *_bt_find_remote_gatt_server_info(char *address);
179 #else
180 struct gatt_conn_info_t *_bt_find_remote_gatt_server_info(char *address);
181 #endif
182
183 #ifdef __cplusplus
184 }
185 #endif /* __cplusplus */
186 #endif /* BT_SERVICE_GATT_H_ */