本文整理汇总了C++中device_get_adapter函数的典型用法代码示例。如果您正苦于以下问题:C++ device_get_adapter函数的具体用法?C++ device_get_adapter怎么用?C++ device_get_adapter使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了device_get_adapter函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: connection_connect
/* Connect and initiate BNEP session */
int connection_connect(struct btd_service *service)
{
struct network_conn *nc = btd_service_get_user_data(service);
struct network_peer *peer = nc->peer;
uint16_t id = get_service_id(service);
GError *err = NULL;
const bdaddr_t *src;
const bdaddr_t *dst;
DBG("id %u", id);
if (nc->state != DISCONNECTED)
return -EALREADY;
src = btd_adapter_get_address(device_get_adapter(peer->device));
dst = device_get_address(peer->device);
nc->io = bt_io_connect(connect_cb, nc,
NULL, &err,
BT_IO_OPT_SOURCE_BDADDR, src,
BT_IO_OPT_DEST_BDADDR, dst,
BT_IO_OPT_PSM, BNEP_PSM,
BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_MEDIUM,
BT_IO_OPT_OMTU, BNEP_MTU,
BT_IO_OPT_IMTU, BNEP_MTU,
BT_IO_OPT_INVALID);
if (!nc->io)
return -EIO;
nc->state = CONNECTING;
return 0;
}
示例2: csc_device_remove
static void csc_device_remove(struct btd_service *service)
{
struct btd_device *device = btd_service_get_device(service);
struct btd_adapter *adapter;
struct csc_adapter *cadapter;
struct csc *csc;
GSList *l;
adapter = device_get_adapter(device);
cadapter = find_csc_adapter(adapter);
if (cadapter == NULL)
return;
l = g_slist_find_custom(cadapter->devices, device, cmp_device);
if (l == NULL)
return;
csc = l->data;
cadapter->devices = g_slist_remove(cadapter->devices, csc);
g_dbus_unregister_interface(btd_get_dbus_connection(),
device_get_path(device),
CYCLINGSPEED_INTERFACE);
}
示例3: mcap_get_mdep
gboolean mcap_get_mdep(struct mcap_device *device, struct mcap_application *app,
mcap_continue_mdep_f func, gpointer data,
GDestroyNotify destroy, GError **err)
{
DBG("");
struct get_mdep_data *mdep_data;
bdaddr_t dst, src;
uuid_t uuid;
device_get_address(device->dev, &dst,NULL);
adapter_get_address(device_get_adapter(device->dev), &src);
mdep_data = g_new0(struct get_mdep_data, 1);
mdep_data->app = mcap_application_ref(app);
mdep_data->func = func;
mdep_data->data = data;
mdep_data->destroy = destroy;
char dd[100] = {};
ba2str(&dst,dd);
DBG("dst device = %s",dd);
sdp_uuid32_create(&uuid, 0x1400);
// bt_string2uuid(&uuid, 0x1400);
if (bt_search_service(&src, &dst, &uuid, get_mdep_cb, mdep_data,
free_mdep_data)) {
g_set_error(err, MCAP_ERROR, MCAP_CONNECTION_ERROR,
"Can't get remote SDP record");
g_free(mdep_data);
return FALSE;
}
return TRUE;
}
示例4: serial_probe
static int serial_probe(struct btd_device *device, const char *uuid)
{
struct btd_adapter *adapter = device_get_adapter(device);
const gchar *path = device_get_path(device);
sdp_list_t *protos;
int ch;
bdaddr_t src, dst;
const sdp_record_t *rec;
DBG("path %s: %s", path, uuid);
rec = btd_device_get_record(device, uuid);
if (!rec)
return -EINVAL;
if (sdp_get_access_protos(rec, &protos) < 0)
return -EINVAL;
ch = sdp_get_proto_port(protos, RFCOMM_UUID);
sdp_list_foreach(protos, (sdp_list_func_t) sdp_list_free, NULL);
sdp_list_free(protos, NULL);
if (ch < 1 || ch > 30) {
error("Channel out of range: %d", ch);
return -EINVAL;
}
adapter_get_address(adapter, &src);
device_get_address(device, &dst);
return port_register(connection, path, &src, &dst, uuid, ch);
}
示例5: hid_device_probe
static int hid_device_probe(struct btd_device *device, GSList *uuids)
{
struct btd_adapter *adapter = device_get_adapter(device);
const gchar *path = device_get_path(device);
const sdp_record_t *rec = btd_device_get_record(device, uuids->data);
bdaddr_t src, dst;
DBG("path %s", path);
#ifndef BT_ALT_STACK
if (!rec)
return -1;
#endif
adapter_get_address(adapter, &src);
device_get_address(device, &dst);
#ifdef BT_ALT_STACK
return input_device_register(connection, device, path, &src, &dst,
HID_UUID, 0 /* rec->handle */, idle_timeout * 60);
#else
return input_device_register(connection, device, path, &src, &dst,
HID_UUID, rec->handle, idle_timeout * 60);
#endif
}
示例6: hdp_get_mdep
gboolean hdp_get_mdep(struct hdp_device *device, struct hdp_application *app,
hdp_continue_mdep_f func, gpointer data,
GDestroyNotify destroy, GError **err)
{
struct get_mdep_data *mdep_data;
const bdaddr_t *src;
const bdaddr_t *dst;
uuid_t uuid;
src = btd_adapter_get_address(device_get_adapter(device->dev));
dst = device_get_address(device->dev);
mdep_data = g_new0(struct get_mdep_data, 1);
mdep_data->app = hdp_application_ref(app);
mdep_data->func = func;
mdep_data->data = data;
mdep_data->destroy = destroy;
bt_string2uuid(&uuid, HDP_UUID);
if (bt_search_service(src, dst, &uuid, get_mdep_cb, mdep_data,
free_mdep_data, 0) < 0) {
g_set_error(err, HDP_ERROR, HDP_CONNECTION_ERROR,
"Can't get remote SDP record");
g_free(mdep_data);
return FALSE;
}
return TRUE;
}
示例7: pincode_cb
static void pincode_cb(struct agent *agent, DBusError *derr,
const char *pincode, struct btd_device *device)
{
struct btd_adapter *adapter = device_get_adapter(device);
bdaddr_t dba;
int err;
size_t len;
char rawpin[16];
device_get_address(device, &dba);
len = decode_pin(pincode, rawpin);
if (derr || !len) {
err = btd_adapter_pincode_reply(adapter, &dba, NULL, 0);
if (err < 0)
goto fail;
return;
}
err = btd_adapter_pincode_reply(adapter, &dba, rawpin, len);
if (err < 0)
goto fail;
return;
fail:
error("Sending PIN code reply failed: %s (%d)", strerror(-err), -err);
}
示例8: hdp_establish_mcl
gboolean hdp_establish_mcl(struct hdp_device *device,
hdp_continue_proc_f func,
gpointer data,
GDestroyNotify destroy,
GError **err)
{
struct conn_mcl_data *conn_data;
const bdaddr_t *src;
const bdaddr_t *dst;
uuid_t uuid;
src = btd_adapter_get_address(device_get_adapter(device->dev));
dst = device_get_address(device->dev);
conn_data = g_new0(struct conn_mcl_data, 1);
conn_data->refs = 1;
conn_data->func = func;
conn_data->data = data;
conn_data->destroy = destroy;
conn_data->dev = health_device_ref(device);
bt_string2uuid(&uuid, HDP_UUID);
if (bt_search_service(src, dst, &uuid, search_cb, conn_data,
destroy_con_mcl_data, 0) < 0) {
g_set_error(err, HDP_ERROR, HDP_CONNECTION_ERROR,
"Can't get remote SDP record");
g_free(conn_data);
return FALSE;
}
return TRUE;
}
示例9: btd_service_get_device
static struct input_device *input_device_new(struct btd_service *service)
{
struct btd_device *device = btd_service_get_device(service);
struct btd_profile *p = btd_service_get_profile(service);
const char *path = device_get_path(device);
const sdp_record_t *rec = btd_device_get_record(device, p->remote_uuid);
struct btd_adapter *adapter = device_get_adapter(device);
struct input_device *idev;
char name[HCI_MAX_NAME_LENGTH + 1];
idev = g_new0(struct input_device, 1);
bacpy(&idev->src, btd_adapter_get_address(adapter));
bacpy(&idev->dst, device_get_address(device));
idev->service = btd_service_ref(service);
idev->device = btd_device_ref(device);
idev->path = g_strdup(path);
idev->handle = rec->handle;
idev->disable_sdp = is_device_sdp_disable(rec);
device_get_name(device, name, HCI_MAX_NAME_LENGTH);
if (strlen(name) > 0)
idev->name = g_strdup(name);
/* Initialize device properties */
extract_hid_props(idev, rec);
return idev;
}
示例10: pincode_cb
static void pincode_cb(struct agent *agent, DBusError *derr,
const char *pincode, struct btd_device *device)
{
struct btd_adapter *adapter = device_get_adapter(device);
bdaddr_t dba;
int err;
device_get_address(device, &dba, NULL);
if (derr) {
err = btd_adapter_pincode_reply(adapter, &dba, NULL, 0);
if (err < 0)
goto fail;
return;
}
err = btd_adapter_pincode_reply(adapter, &dba, pincode,
pincode ? strlen(pincode) : 0);
if (err < 0)
goto fail;
return;
fail:
error("Sending PIN code reply failed: %s (%d)", strerror(-err), -err);
}
示例11: btd_error_invalid_args
static DBusMessage *set_link_loss_alert(DBusConnection *conn, DBusMessage *msg,
const char *level, void *data)
{
struct monitor *monitor = data;
struct btd_device *device = monitor->device;
bdaddr_t sba, dba;
if (!level_is_valid(level))
return btd_error_invalid_args(msg);
if (g_strcmp0(monitor->linklosslevel, level) == 0)
return dbus_message_new_method_return(msg);
g_free(monitor->linklosslevel);
monitor->linklosslevel = g_strdup(level);
adapter_get_address(device_get_adapter(device), &sba);
device_get_address(device, &dba);
write_proximity_config(&sba, &dba, "LinkLossAlertLevel", level);
if (monitor->attrib)
write_alert_level(monitor);
return dbus_message_new_method_return(msg);
}
示例12: hid_device_probe
static int hid_device_probe(struct btd_device *device, GSList *uuids)
{
struct btd_adapter *adapter = device_get_adapter(device);
const gchar *path = device_get_path(device);
const sdp_record_t *rec = btd_device_get_record(device, uuids->data);
bdaddr_t src, dst;
sdp_data_t *pdlist;
DBG("path %s", path);
if (!rec)
return -1;
adapter_get_address(adapter, &src);
device_get_address(device, &dst);
if (rec)
pdlist = sdp_data_get(rec, SDP_ATTR_HID_SDP_DISABLE);
if (pdlist && pdlist->val.uint8) {
DBG("cancel discovery is issued");
bt_cancel_discovery(&src, &dst);
}
return input_device_register(connection, device, path, &src, &dst,
HID_UUID, rec->handle, idle_timeout * 60);
}
示例13: avctp_control_confirm
static void avctp_control_confirm(struct avctp *session, GIOChannel *chan,
struct btd_device *dev)
{
const bdaddr_t *src;
const bdaddr_t *dst;
if (session->control != NULL) {
error("Control: Refusing unexpected connect");
g_io_channel_shutdown(chan, TRUE, NULL);
return;
}
avctp_set_state(session, AVCTP_STATE_CONNECTING);
session->control = avctp_channel_create(session, chan, NULL);
src = adapter_get_address(device_get_adapter(dev));
dst = device_get_address(dev);
session->auth_id = btd_request_authorization(src, dst,
AVRCP_TARGET_UUID,
auth_cb, session);
if (session->auth_id == 0)
goto drop;
session->control->watch = g_io_add_watch(chan, G_IO_ERR | G_IO_HUP |
G_IO_NVAL, session_cb, session);
return;
drop:
avctp_set_state(session, AVCTP_STATE_DISCONNECTED);
}
示例14: hdp_get_dcpsm
gboolean hdp_get_dcpsm(struct hdp_device *device, hdp_continue_dcpsm_f func,
gpointer data,
GDestroyNotify destroy,
GError **err)
{
struct get_dcpsm_data *dcpsm_data;
bdaddr_t dst, src;
uuid_t uuid;
device_get_address(device->dev, &dst, NULL);
adapter_get_address(device_get_adapter(device->dev), &src);
dcpsm_data = g_new0(struct get_dcpsm_data, 1);
dcpsm_data->func = func;
dcpsm_data->data = data;
dcpsm_data->destroy = destroy;
bt_string2uuid(&uuid, HDP_UUID);
if (bt_search_service(&src, &dst, &uuid, get_dcpsm_cb, dcpsm_data,
free_dcpsm_data)) {
g_set_error(err, HDP_ERROR, HDP_CONNECTION_ERROR,
"Can't get remote SDP record");
g_free(dcpsm_data);
return FALSE;
}
return TRUE;
}
示例15: mcap_establish_mcl
gboolean mcap_establish_mcl(struct mcap_device *device,
mcap_continue_proc_f func,
gpointer data,
GDestroyNotify destroy,
GError **err)
{ DBG("");
DBG("");
struct conn_mcl_data *conn_data;
bdaddr_t dst, src;
uuid_t uuid;
device_get_address(device->dev, &dst,NULL);
adapter_get_address(device_get_adapter(device->dev), &src);
conn_data = g_new0(struct conn_mcl_data, 1);
conn_data->refs = 1;
conn_data->func = func;
conn_data->data = data;
conn_data->destroy = destroy;
conn_data->dev = mcap_device_ref(device);
sdp_uuid32_create(&uuid, 0x001e);
//bt_string2uuid(&uuid, 0x001e);
if (bt_search_service(&src, &dst, &uuid, search_cb, conn_data,
destroy_con_mcl_data)) {
g_set_error(err, MCAP_ERROR, MCAP_CONNECTION_ERROR,
"Can't get remote SDP record");
g_free(conn_data);
return FALSE;
}
return TRUE;
}