예제 #1
0
파일: manager.c 프로젝트: Bisheg/bluez
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);
}
예제 #2
0
파일: device.c 프로젝트: padelt/bluez
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;
}
예제 #3
0
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);
}
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
}
예제 #5
0
static int hid_device_probe(struct btd_profile *p, struct btd_device *device,
								GSList *uuids)
{
	const char *path = device_get_path(device);
	const sdp_record_t *rec = btd_device_get_record(device, uuids->data);

	DBG("path %s", path);

	if (!rec)
		return -1;

	return input_device_register(device, path, HID_UUID, rec,
							idle_timeout * 60);
}
예제 #6
0
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);

    if (!rec)
        return -1;

    adapter_get_address(adapter, &src);
    device_get_address(device, &dst, NULL);

    return input_device_register(connection, device, path, &src, &dst,
                                 HID_UUID, rec, idle_timeout * 60);
}
예제 #7
0
static int headset_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 *record;
	sdp_list_t *protos;
	int ch;
	bdaddr_t src, dst;

	DBG("path %s", path);

	if (!g_slist_find_custom(uuids, HSP_HS_UUID,
					(GCompareFunc) strcasecmp))
		return -EINVAL;

	record = btd_device_get_record(device, uuids->data);

	if (!record || sdp_get_access_protos(record, &protos) < 0) {
		error("Invalid record");
		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 <= 0) {
		error("Invalid RFCOMM channel");
		return -EINVAL;
	}

	adapter_get_address(adapter, &src);
	device_get_address(device, &dst);

	return fake_input_register(connection, device, path, &src, &dst,
				HSP_HS_UUID, ch);
}