3 * MCAP for BlueZ - Bluetooth protocol stack for Linux
5 * Copyright (C) 2010 GSyC/LibreSoft, Universidad Rey Juan Carlos.
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.
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.
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
31 /* MCAP Error Response Codes */
32 MCAP_ERROR_INVALID_OP_CODE = 1,
33 MCAP_ERROR_INVALID_PARAM_VALUE,
34 MCAP_ERROR_INVALID_MDEP,
36 MCAP_ERROR_INVALID_MDL,
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,
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 */
64 struct sync_info_ind_data;
66 /************ Callbacks ************/
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,
75 typedef void (* mcap_mdl_notify_cb) (GError *err, gpointer data);
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,
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,
92 typedef void (* mcap_info_ind_event_cb) (struct mcap_mcl *mcl,
93 struct sync_info_ind_data *data);
95 typedef void (* mcap_sync_cap_cb) (struct mcap_mcl *mcl,
104 typedef void (* mcap_sync_set_cb) (struct mcap_mcl *mcl,
112 /************ Operations ************/
116 gboolean mcap_create_mdl(struct mcap_mcl *mcl,
119 mcap_mdl_operation_conf_cb connect_cb,
121 GDestroyNotify destroy,
123 gboolean mcap_reconnect_mdl(struct mcap_mdl *mdl,
124 mcap_mdl_operation_cb reconnect_cb,
126 GDestroyNotify destroy,
128 gboolean mcap_delete_all_mdls(struct mcap_mcl *mcl,
129 mcap_mdl_notify_cb delete_cb,
131 GDestroyNotify destroy,
133 gboolean mcap_delete_mdl(struct mcap_mdl *mdl,
134 mcap_mdl_notify_cb delete_cb,
136 GDestroyNotify destroy,
138 gboolean mcap_connect_mdl(struct mcap_mdl *mdl,
141 mcap_mdl_operation_cb connect_cb,
143 GDestroyNotify destroy,
145 gboolean mcap_mdl_abort(struct mcap_mdl *mdl,
146 mcap_mdl_notify_cb abort_cb,
148 GDestroyNotify destroy,
151 int mcap_mdl_get_fd(struct mcap_mdl *mdl);
152 uint16_t mcap_mdl_get_mdlid(struct mcap_mdl *mdl);
154 struct mcap_mdl *mcap_mdl_ref(struct mcap_mdl *mdl);
155 void mcap_mdl_unref(struct mcap_mdl *mdl);
159 gboolean mcap_create_mcl(struct mcap_instance *mi,
160 const bdaddr_t *addr,
162 mcap_mcl_connect_cb connect_cb,
164 GDestroyNotify destroy,
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);
171 struct mcap_mcl *mcap_mcl_ref(struct mcap_mcl *mcl);
172 void mcap_mcl_unref(struct mcap_mcl *mcl);
176 void mcap_enable_csp(struct mcap_instance *mi);
177 void mcap_disable_csp(struct mcap_instance *mi);
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);
183 void mcap_sync_cap_req(struct mcap_mcl *mcl,
189 void mcap_sync_set_req(struct mcap_mcl *mcl,
197 /* MCAP main operations */
199 struct mcap_instance *mcap_create_instance(bdaddr_t *src,
200 BtIOSecLevel sec, uint16_t ccpsm,
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,
209 void mcap_release_instance(struct mcap_instance *mi);
211 struct mcap_instance *mcap_instance_ref(struct mcap_instance *mi);
212 void mcap_instance_unref(struct mcap_instance *mi);
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);
217 gboolean mcap_set_data_chan_mode(struct mcap_instance *mi, uint8_t mode,
224 #endif /* __MCAP_LIB_H */