aboutsummaryrefslogtreecommitdiffstats
path: root/attrib/client.c
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2011-07-12 17:28:36 -0300
committerJohan Hedberg <johan.hedberg@intel.com>2011-07-27 10:30:55 +0300
commit95bf1f076a607fa84a52d6e48db8f2ac6036fa70 (patch)
tree1c5a0b22323f2f689a4cd3b2097e3ddef9d916a9 /attrib/client.c
parent3b010c0a14cf721082e5eb5fd1a03416607af700 (diff)
downloadbluez-95bf1f076a607fa84a52d6e48db8f2ac6036fa70.tar.gz
bluez-95bf1f076a607fa84a52d6e48db8f2ac6036fa70.tar.xz
bluez-95bf1f076a607fa84a52d6e48db8f2ac6036fa70.zip
Register the ATT connection callbacks
Registers the ATT connection and disconnection callbacks in the generic attribute API. First commit to remove implicit L2CAP connection establishment.
Diffstat (limited to 'attrib/client.c')
-rw-r--r--attrib/client.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/attrib/client.c b/attrib/client.c
index 482aff1f..29cb34ab 100644
--- a/attrib/client.c
+++ b/attrib/client.c
@@ -48,6 +48,7 @@
#include "att.h"
#include "gattrib.h"
+#include "attio.h"
#include "gatt.h"
#include "client.h"
@@ -66,6 +67,7 @@ struct gatt_service {
struct att_primary *prim;
DBusConnection *conn;
GAttrib *attrib;
+ guint attioid;
int psm;
char *path;
GSList *chars;
@@ -976,6 +978,20 @@ static GDBusMethodTable prim_methods[] = {
{ }
};
+static void attio_connected(GAttrib *attrib, gpointer user_data)
+{
+ struct gatt_service *gatt = user_data;
+
+ gatt->attrib = attrib;
+}
+
+static void attio_disconnected(gpointer user_data)
+{
+ struct gatt_service *gatt = user_data;
+
+ gatt->attrib = NULL;
+}
+
static struct gatt_service *primary_register(DBusConnection *conn,
struct btd_device *device,
struct att_primary *prim,
@@ -995,6 +1011,9 @@ static struct gatt_service *primary_register(DBusConnection *conn,
gatt->path = g_strdup_printf("%s/service%04x", device_path,
prim->start);
+ gatt->attioid = btd_device_add_attio_callback(device, attio_connected,
+ attio_disconnected, gatt);
+
g_dbus_register_interface(gatt->conn, gatt->path,
CHAR_INTERFACE, prim_methods,
NULL, NULL, gatt, NULL);
@@ -1020,6 +1039,7 @@ GSList *attrib_client_register(DBusConnection *connection,
services = g_slist_append(services, g_strdup(gatt->path));
gatt_services = g_slist_append(gatt_services, gatt);
+
}
return services;
@@ -1029,6 +1049,8 @@ static void primary_unregister(struct gatt_service *gatt)
{
GSList *l;
+ btd_device_remove_attio_callback(gatt->dev, gatt->attioid);
+
for (l = gatt->chars; l; l = l->next) {
struct characteristic *chr = l->data;
g_dbus_unregister_interface(gatt->conn, chr->path,