Fix build break for rpm
[framework/connectivity/bluez.git] / health / mcap_lib.h
1 /*
2  *
3  *  MCAP for BlueZ - Bluetooth protocol stack for Linux
4  *
5  *  Copyright (C) 2010 GSyC/LibreSoft, Universidad Rey Juan Carlos.
6  *
7  *  This program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License as published by
9  *  the Free Software Foundation; either version 2 of the License, or
10  *  (at your option) any later version.
11  *
12  *  This program is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *  GNU General Public License for more details.
16  *
17  *  You should have received a copy of the GNU General Public License
18  *  along with this program; if not, write to the Free Software
19  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20  *
21  */
22
23 #ifndef __MCAP_LIB_H
24 #define __MCAP_LIB_H
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
30 typedef enum {
31 /* MCAP Error Response Codes */
32         MCAP_ERROR_INVALID_OP_CODE = 1,
33         MCAP_ERROR_INVALID_PARAM_VALUE,
34         MCAP_ERROR_INVALID_MDEP,
35         MCAP_ERROR_MDEP_BUSY,
36         MCAP_ERROR_INVALID_MDL,
37         MCAP_ERROR_MDL_BUSY,
38         MCAP_ERROR_INVALID_OPERATION,
39         MCAP_ERROR_RESOURCE_UNAVAILABLE,
40         MCAP_ERROR_UNSPECIFIED_ERROR,
41         MCAP_ERROR_REQUEST_NOT_SUPPORTED,
42         MCAP_ERROR_CONFIGURATION_REJECTED,
43 /* MCAP Internal Errors */
44         MCAP_ERROR_INVALID_ARGS,
45         MCAP_ERROR_ALREADY_EXISTS,
46         MCAP_ERROR_REQ_IGNORED,
47         MCAP_ERROR_MCL_CLOSED,
48         MCAP_ERROR_FAILED
49 } McapError;
50
51 typedef enum {
52         MCAP_MDL_CB_INVALID,
53         MCAP_MDL_CB_CONNECTED,          /* mcap_mdl_event_cb */
54         MCAP_MDL_CB_CLOSED,             /* mcap_mdl_event_cb */
55         MCAP_MDL_CB_DELETED,            /* mcap_mdl_event_cb */
56         MCAP_MDL_CB_ABORTED,            /* mcap_mdl_event_cb */
57         MCAP_MDL_CB_REMOTE_CONN_REQ,    /* mcap_remote_mdl_conn_req_cb */
58         MCAP_MDL_CB_REMOTE_RECONN_REQ   /* mcap_remote_mdl_reconn_req_cb */
59 } McapMclCb;
60
61 struct mcap_instance;
62 struct mcap_mcl;
63 struct mcap_mdl;
64 struct sync_info_ind_data;
65
66 /************ Callbacks ************/
67
68 /* MDL callbacks */
69
70 typedef void (* mcap_mdl_event_cb) (struct mcap_mdl *mdl, gpointer data);
71 typedef void (* mcap_mdl_operation_conf_cb) (struct mcap_mdl *mdl, uint8_t conf,
72                                                 GError *err, gpointer data);
73 typedef void (* mcap_mdl_operation_cb) (struct mcap_mdl *mdl, GError *err,
74                                                 gpointer data);
75 typedef void (* mcap_mdl_notify_cb) (GError *err, gpointer data);
76
77 /* Next function should return an MCAP appropriate response code */
78 typedef uint8_t (* mcap_remote_mdl_conn_req_cb) (struct mcap_mcl *mcl,
79                                                 uint8_t mdepid, uint16_t mdlid,
80                                                 uint8_t *conf, gpointer data);
81 typedef uint8_t (* mcap_remote_mdl_reconn_req_cb) (struct mcap_mdl *mdl,
82                                                 gpointer data);
83
84 /* MCL callbacks */
85
86 typedef void (* mcap_mcl_event_cb) (struct mcap_mcl *mcl, gpointer data);
87 typedef void (* mcap_mcl_connect_cb) (struct mcap_mcl *mcl, GError *err,
88                                                                 gpointer data);
89
90 /* CSP callbacks */
91
92 typedef void (* mcap_info_ind_event_cb) (struct mcap_mcl *mcl,
93                                         struct sync_info_ind_data *data);
94
95 typedef void (* mcap_sync_cap_cb) (struct mcap_mcl *mcl,
96                                         uint8_t mcap_err,
97                                         uint8_t btclockres,
98                                         uint16_t synclead,
99                                         uint16_t tmstampres,
100                                         uint16_t tmstampacc,
101                                         GError *err,
102                                         gpointer data);
103
104 typedef void (* mcap_sync_set_cb) (struct mcap_mcl *mcl,
105                                         uint8_t mcap_err,
106                                         uint32_t btclock,
107                                         uint64_t timestamp,
108                                         uint16_t accuracy,
109                                         GError *err,
110                                         gpointer data);
111
112 /************ Operations ************/
113
114 /* MDL operations */
115
116 gboolean mcap_create_mdl(struct mcap_mcl *mcl,
117                                 uint8_t mdepid,
118                                 uint8_t conf,
119                                 mcap_mdl_operation_conf_cb connect_cb,
120                                 gpointer user_data,
121                                 GDestroyNotify destroy,
122                                 GError **err);
123 gboolean mcap_reconnect_mdl(struct mcap_mdl *mdl,
124                                 mcap_mdl_operation_cb reconnect_cb,
125                                 gpointer user_data,
126                                 GDestroyNotify destroy,
127                                 GError **err);
128 gboolean mcap_delete_all_mdls(struct mcap_mcl *mcl,
129                                 mcap_mdl_notify_cb delete_cb,
130                                 gpointer user_data,
131                                 GDestroyNotify destroy,
132                                 GError **err);
133 gboolean mcap_delete_mdl(struct mcap_mdl *mdl,
134                                 mcap_mdl_notify_cb delete_cb,
135                                 gpointer user_data,
136                                 GDestroyNotify destroy,
137                                 GError **err);
138 gboolean mcap_connect_mdl(struct mcap_mdl *mdl,
139                                 uint8_t mode,
140                                 uint16_t dcpsm,
141                                 mcap_mdl_operation_cb connect_cb,
142                                 gpointer user_data,
143                                 GDestroyNotify destroy,
144                                 GError **err);
145 gboolean mcap_mdl_abort(struct mcap_mdl *mdl,
146                                 mcap_mdl_notify_cb abort_cb,
147                                 gpointer user_data,
148                                 GDestroyNotify destroy,
149                                 GError **err);
150
151 int mcap_mdl_get_fd(struct mcap_mdl *mdl);
152 uint16_t mcap_mdl_get_mdlid(struct mcap_mdl *mdl);
153
154 struct mcap_mdl *mcap_mdl_ref(struct mcap_mdl *mdl);
155 void mcap_mdl_unref(struct mcap_mdl *mdl);
156
157 /* MCL operations */
158
159 gboolean mcap_create_mcl(struct mcap_instance *mi,
160                                 const bdaddr_t *addr,
161                                 uint16_t ccpsm,
162                                 mcap_mcl_connect_cb connect_cb,
163                                 gpointer user_data,
164                                 GDestroyNotify destroy,
165                                 GError **err);
166 void mcap_close_mcl(struct mcap_mcl *mcl, gboolean cache);
167 gboolean mcap_mcl_set_cb(struct mcap_mcl *mcl, gpointer user_data,
168                                         GError **gerr, McapMclCb cb1, ...);
169 void mcap_mcl_get_addr(struct mcap_mcl *mcl, bdaddr_t *addr);
170
171 struct mcap_mcl *mcap_mcl_ref(struct mcap_mcl *mcl);
172 void mcap_mcl_unref(struct mcap_mcl *mcl);
173
174 /* CSP operations */
175
176 void mcap_enable_csp(struct mcap_instance *mi);
177 void mcap_disable_csp(struct mcap_instance *mi);
178
179 uint64_t mcap_get_timestamp(struct mcap_mcl *mcl,
180                                 struct timespec *given_time);
181 uint32_t mcap_get_btclock(struct mcap_mcl *mcl);
182
183 void mcap_sync_cap_req(struct mcap_mcl *mcl,
184                         uint16_t reqacc,
185                         mcap_sync_cap_cb cb,
186                         gpointer user_data,
187                         GError **err);
188
189 void mcap_sync_set_req(struct mcap_mcl *mcl,
190                         uint8_t update,
191                         uint32_t btclock,
192                         uint64_t timestamp,
193                         mcap_sync_set_cb cb,
194                         gpointer user_data,
195                         GError **err);
196
197 /* MCAP main operations */
198
199 struct mcap_instance *mcap_create_instance(bdaddr_t *src,
200                                         BtIOSecLevel sec, uint16_t ccpsm,
201                                         uint16_t dcpsm,
202                                         mcap_mcl_event_cb mcl_connected,
203                                         mcap_mcl_event_cb mcl_reconnected,
204                                         mcap_mcl_event_cb mcl_disconnected,
205                                         mcap_mcl_event_cb mcl_uncached,
206                                         mcap_info_ind_event_cb mcl_sync_info_ind,
207                                         gpointer user_data,
208                                         GError **gerr);
209 void mcap_release_instance(struct mcap_instance *mi);
210
211 struct mcap_instance *mcap_instance_ref(struct mcap_instance *mi);
212 void mcap_instance_unref(struct mcap_instance *mi);
213
214 uint16_t mcap_get_ctrl_psm(struct mcap_instance *mi, GError **err);
215 uint16_t mcap_get_data_psm(struct mcap_instance *mi, GError **err);
216
217 gboolean mcap_set_data_chan_mode(struct mcap_instance *mi, uint8_t mode,
218                                                                 GError **err);
219
220 #ifdef __cplusplus
221 }
222 #endif
223
224 #endif /* __MCAP_LIB_H */