From 7036010169e7278e1651608c92ce6cf5ca4c10e3 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Thu, 13 Mar 2014 17:00:19 +0200 Subject: core: Use device_attach_attrib for attrib-server --- src/attrib-server.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'src/attrib-server.c') diff --git a/src/attrib-server.c b/src/attrib-server.c index 3f68fea06..3f579bbbe 100644 --- a/src/attrib-server.c +++ b/src/attrib-server.c @@ -1247,7 +1247,10 @@ gboolean attrib_channel_detach(GAttrib *attrib, guint id) static void connect_event(GIOChannel *io, GError *gerr, void *user_data) { - GAttrib *attrib; + struct btd_adapter *adapter; + struct btd_device *device; + uint8_t dst_type; + bdaddr_t src, dst; DBG(""); @@ -1256,12 +1259,26 @@ static void connect_event(GIOChannel *io, GError *gerr, void *user_data) return; } - attrib = g_attrib_new(io); - if (!attrib) + bt_io_get(io, &gerr, + BT_IO_OPT_SOURCE_BDADDR, &src, + BT_IO_OPT_DEST_BDADDR, &dst, + BT_IO_OPT_DEST_TYPE, &dst_type, + BT_IO_OPT_INVALID); + if (gerr) { + error("bt_io_get: %s", gerr->message); + g_error_free(gerr); + return; + } + + adapter = adapter_find(&src); + if (!adapter) + return; + + device = btd_adapter_get_device(adapter, &dst, dst_type); + if (!device) return; - attrib_channel_attach(attrib); - g_attrib_unref(attrib); + device_attach_attrib(device, io); } static gboolean register_core_services(struct gatt_server *server) -- cgit v1.2.1