diff --git a/src/attrib-server.c b/src/attrib-server.c
index 1e8129d..623c91a 100644
--- a/src/attrib-server.c
+++ b/src/attrib-server.c
return l->data;
}
-static struct gatt_server *get_default_gatt_server(void)
-{
- struct btd_adapter *adapter;
- GSList *l;
-
- adapter = manager_get_default_adapter();
- if (adapter == NULL) {
- error("Can't get default adapter");
- return NULL;
- }
-
- l = g_slist_find_custom(servers, adapter, adapter_cmp);
- if (l == NULL) {
- error("Not GATT server initialized on adapter %s",
- adapter_get_path(adapter));
- return NULL;
- }
-
- return l->data;
-}
-
static sdp_record_t *server_record_new(uuid_t *uuid, uint16_t start, uint16_t end)
{
sdp_list_t *svclass_id, *apseq, *proto[2], *root, *aproto;
return channel->id - id;
}
-gboolean attrib_channel_detach(guint id)
+gboolean attrib_channel_detach(GAttrib *attrib, guint id)
{
struct gatt_server *server;
struct gatt_channel *channel;
+ GError *gerr = NULL;
+ GIOChannel *io;
+ bdaddr_t src;
GSList *l;
- DBG("Deprecated function");
+ io = g_attrib_get_channel(attrib);
+
+ bt_io_get(io, BT_IO_L2CAP, &gerr, BT_IO_OPT_SOURCE_BDADDR, &src,
+ BT_IO_OPT_INVALID);
+
+ if (gerr != NULL) {
+ error("bt_io_get: %s", gerr->message);
+ g_error_free(gerr);
+ return FALSE;
+ }
- server = get_default_gatt_server();
+ server = find_gatt_server(&src);
if (server == NULL)
return FALSE;
diff --git a/src/attrib-server.h b/src/attrib-server.h
index dc08bfb..2c6f428 100644
--- a/src/attrib-server.h
+++ b/src/attrib-server.h
const char *name);
void attrib_free_sdp(uint32_t sdp_handle);
guint attrib_channel_attach(GAttrib *attrib, gboolean out);
-gboolean attrib_channel_detach(guint id);
+gboolean attrib_channel_detach(GAttrib *attrib, guint id);
diff --git a/src/device.c b/src/device.c
index 570f678..16855b1 100644
--- a/src/device.c
+++ b/src/device.c
g_slist_foreach(device->attios, attio_disconnected, NULL);
- attrib_channel_detach(device->attachid);
+ attrib_channel_detach(device->attrib, device->attachid);
g_attrib_unref(device->attrib);
device->attrib = NULL;
device_probe_drivers(device, uuids);
if (device->attios == NULL && device->attios_offline == NULL) {
- attrib_channel_detach(device->attachid);
+ attrib_channel_detach(device->attrib, device->attachid);
g_attrib_unref(device->attrib);
device->attrib = NULL;
} else
return TRUE;
if (device->attachid) {
- attrib_channel_detach(device->attachid);
+ attrib_channel_detach(device->attrib, device->attachid);
device->attachid = 0;
}