3
* MCAP for BlueZ - Bluetooth protocol stack for Linux
5
* Copyright (C) 2010 GSyC/LibreSoft, Universidad Rey Juan Carlos.
8
* Santiago Carot-Nemesio <sancane at gmail.com>
9
* Jose Antonio Santos-Cadenas <santoscadenas at gmail.com>
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.
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.
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
35
/* MCAP Error Response Codes */
36
MCAP_ERROR_INVALID_OP_CODE = 1,
37
MCAP_ERROR_INVALID_PARAM_VALUE,
38
MCAP_ERROR_INVALID_MDEP,
40
MCAP_ERROR_INVALID_MDL,
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,
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 */
68
struct sync_info_ind_data;
70
/************ Callbacks ************/
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,
79
typedef void (* mcap_mdl_notify_cb) (GError *err, gpointer data);
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,
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,
96
typedef void (* mcap_info_ind_event_cb) (struct mcap_mcl *mcl,
97
struct sync_info_ind_data *data);
99
typedef void (* mcap_sync_cap_cb) (struct mcap_mcl *mcl,
108
typedef void (* mcap_sync_set_cb) (struct mcap_mcl *mcl,
116
/************ Operations ************/
120
gboolean mcap_create_mdl(struct mcap_mcl *mcl,
123
mcap_mdl_operation_conf_cb connect_cb,
125
GDestroyNotify destroy,
127
gboolean mcap_reconnect_mdl(struct mcap_mdl *mdl,
128
mcap_mdl_operation_cb reconnect_cb,
130
GDestroyNotify destroy,
132
gboolean mcap_delete_all_mdls(struct mcap_mcl *mcl,
133
mcap_mdl_notify_cb delete_cb,
135
GDestroyNotify destroy,
137
gboolean mcap_delete_mdl(struct mcap_mdl *mdl,
138
mcap_mdl_notify_cb delete_cb,
140
GDestroyNotify destroy,
142
gboolean mcap_connect_mdl(struct mcap_mdl *mdl,
145
mcap_mdl_operation_cb connect_cb,
147
GDestroyNotify destroy,
149
gboolean mcap_mdl_abort(struct mcap_mdl *mdl,
150
mcap_mdl_notify_cb abort_cb,
152
GDestroyNotify destroy,
155
int mcap_mdl_get_fd(struct mcap_mdl *mdl);
156
uint16_t mcap_mdl_get_mdlid(struct mcap_mdl *mdl);
158
struct mcap_mdl *mcap_mdl_ref(struct mcap_mdl *mdl);
159
void mcap_mdl_unref(struct mcap_mdl *mdl);
163
gboolean mcap_create_mcl(struct mcap_instance *mi,
164
const bdaddr_t *addr,
166
mcap_mcl_connect_cb connect_cb,
168
GDestroyNotify destroy,
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);
175
struct mcap_mcl *mcap_mcl_ref(struct mcap_mcl *mcl);
176
void mcap_mcl_unref(struct mcap_mcl *mcl);
180
void mcap_enable_csp(struct mcap_instance *mi);
181
void mcap_disable_csp(struct mcap_instance *mi);
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);
187
void mcap_sync_cap_req(struct mcap_mcl *mcl,
193
void mcap_sync_set_req(struct mcap_mcl *mcl,
201
/* MCAP main operations */
203
struct mcap_instance *mcap_create_instance(bdaddr_t *src,
204
BtIOSecLevel sec, uint16_t ccpsm,
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,
213
void mcap_release_instance(struct mcap_instance *mi);
215
struct mcap_instance *mcap_instance_ref(struct mcap_instance *mi);
216
void mcap_instance_unref(struct mcap_instance *mi);
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);
221
gboolean mcap_set_data_chan_mode(struct mcap_instance *mi, uint8_t mode,
228
#endif /* __MCAP_LIB_H */