Remove wrong dependency in the systemd service file
[platform/core/connectivity/bluetooth-frwk.git] / include / bluetooth-gatt-client-api.h
1 /*
2  * Bluetooth-frwk
3  *
4  * Contact: Anupam Roy (anupam.r@samsung.com)
5  *
6  * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
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 __BLUETOOTH_GATT_CLIENT_API_H
23 #define __BLUETOOTH_GATT_CLIENT_API_H
24
25 #include <stdint.h>
26 #include <glib.h>
27 #include <dlog.h>
28
29 #include <bluetooth-api.h>
30 #include <bluetooth-gatt-server-api.h>
31
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 */
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38
39 typedef struct {
40         int event;
41         int result;
42         void *param_data;
43         void *user_data;
44 } gatt_client_event_param_t;
45
46 typedef struct {
47         bluetooth_device_address_t device_addr;
48         int count;
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;
53
54
55 typedef enum {
56         BLUETOOTH_GATT_TYPE_WRITE_NO_RESPONSE = 0x01,      /* Write Without Response */
57         BLUETOOTH_GATT_TYPE_WRITE = 0x2,                           /* Write */
58 } bluetooth_gatt_write_type_e;
59
60
61 /* Structure used for browsing a particular service's properties(chars and Incldued svcs) */
62 typedef struct {
63         bluetooth_device_address_t device_address;      /**< device address */
64         bt_gatt_handle_property_t svc;
65 } bluetooth_gatt_client_svc_prop_info_t;
66
67 typedef struct {
68         bluetooth_device_address_t device_addr;
69         int count;
70         unsigned char svc_uuid[BLUETOOTH_UUID_HEX_MAX_LEN];
71         int svc_inst_id;
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;
76
77 typedef struct {
78         bluetooth_device_address_t device_addr;
79         int count;
80         unsigned char svc_uuid[BLUETOOTH_UUID_HEX_MAX_LEN];
81         int svc_inst_id;
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;
85
86 typedef struct {
87         bluetooth_device_address_t device_addr;
88         int count;
89         unsigned char svc_uuid[BLUETOOTH_UUID_HEX_MAX_LEN];
90         int svc_inst_id;
91         unsigned char char_uuid[BLUETOOTH_UUID_HEX_MAX_LEN];
92         int char_inst_id;
93         int char_props_map;
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;
97
98 /* Structure used for browsing a particular charactertic's properties(descriptors)  or reading char's value */
99 typedef struct {
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;
104
105 /* Structure used for reading Descriptor's value */
106 typedef struct {
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;
112
113
114 typedef void (*gatt_client_cb_func_ptr)(int, gatt_client_event_param_t *, void *);
115
116 /**
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
119  *
120  * This function is a synchronous call.
121  *
122  * @remark      None
123  *
124  */
125 int bluetooth_gatt_client_init(int *client_id,
126                 const bluetooth_device_address_t *address,
127                 gatt_client_cb_func_ptr callback_ptr);
128
129 int bluetooth_gatt_client_deinit(int client_id);
130
131 int bluetooth_gatt_client_get_primary_services(const bluetooth_device_address_t *address,
132                 bt_gatt_handle_info_t *prim_svc);
133
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);
137
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);
142
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);
148
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);
152
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);
157
158
159 int bluetooth_gatt_client_write_characteristic_value_by_type(
160                 const char *address,
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);
165
166 int bluetooth_gatt_client_write_descriptor_value(
167                 const char *address,
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);
173
174 int bluetooth_gatt_client_set_service_change_watcher(
175                 const bluetooth_device_address_t *address,
176                 gboolean enable);
177
178 int bluetooth_gatt_client_watch_characteristics(
179                         const char *address,
180                         bt_gatt_handle_property_t *service_handle,
181                         bt_gatt_handle_property_t *char_handle,
182                         int client_id,
183                         gboolean is_notify,
184                         gboolean is_indicate);
185
186 #ifdef __cplusplus
187 }
188 #endif
189 #endif /* __BLUETOOTH_GATT_CLIENT_API_H */