diff --git a/src/device.c b/src/device.c
index e9630ed..84ba88e 100644
--- a/src/device.c
+++ b/src/device.c
#include "log.h"
#include "src/shared/util.h"
+#include "src/shared/att.h"
#include "btio/btio.h"
#include "lib/uuid.h"
#include "lib/mgmt.h"
GSList *attios_offline;
guint attachid; /* Attrib server attach */
+ struct bt_att *att; /* The new ATT transport */
+ unsigned int att_disconn_id;
+
struct bearer_state bredr_state;
struct bearer_state le_state;
int8_t rssi;
GIOChannel *att_io;
- guint cleanup_id;
guint store_id;
};
device->attachid = 0;
}
- if (device->cleanup_id) {
- g_source_remove(device->cleanup_id);
- device->cleanup_id = 0;
- }
+ if (device->att_disconn_id)
+ bt_att_unregister_disconnect(device->att,
+ device->att_disconn_id);
if (device->att_io) {
g_io_channel_shutdown(device->att_io, FALSE, NULL);
device->att_io = NULL;
}
+ if (device->att) {
+ bt_att_unref(device->att);
+ device->att = NULL;
+ }
+
if (device->attrib) {
GAttrib *attrib = device->attrib;
device->attrib = NULL;
attio->dcfunc(attio->user_data);
}
-static gboolean attrib_disconnected_cb(GIOChannel *io, GIOCondition cond,
- gpointer user_data)
+static void att_disconnected_cb(int err, void *user_data)
{
struct btd_device *device = user_data;
- int sock, err = 0;
- socklen_t len;
DBG("");
if (device->browse)
goto done;
- sock = g_io_channel_unix_get_fd(io);
- len = sizeof(err);
- getsockopt(sock, SOL_SOCKET, SO_ERROR, &err, &len);
-
DBG("%s (%d)", strerror(err), err);
g_slist_foreach(device->attios, attio_disconnected, NULL);
done:
attio_cleanup(device);
-
- return FALSE;
}
static void register_all_services(struct browse_req *req, GSList *services)
}
if (cid == ATT_CID)
- mtu = ATT_DEFAULT_LE_MTU;
+ mtu = BT_ATT_DEFAULT_LE_MTU;
attrib = g_attrib_new(io, mtu);
if (!attrib) {
}
dev->attrib = attrib;
- dev->cleanup_id = g_io_add_watch(io, G_IO_HUP,
- attrib_disconnected_cb, dev);
+ dev->att = g_attrib_get_att(attrib);
+
+ bt_att_ref(dev->att);
+
+ dev->att_disconn_id = bt_att_register_disconnect(dev->att,
+ att_disconnected_cb, dev, NULL);
+ bt_att_set_close_on_unref(dev->att, true);
/*
* Remove the device from the connect_list and give the passive