~ubuntu-branches/ubuntu/wily/bluez/wily

« back to all changes in this revision

Viewing changes to health/mcap_lib.h

ImportĀ upstreamĀ versionĀ 4.81

Show diffs side-by-side

added added

removed removed

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