aboutsummaryrefslogtreecommitdiffstats
path: root/attrib/client.c
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2010-07-08 10:38:59 -0300
committerJohan Hedberg <johan.hedberg@nokia.com>2010-08-09 18:06:44 -0400
commit97cd6046573d8acf8d98b0ee35c86126f0505dff (patch)
tree716cfd8dd1ac77baa7ebbedf7b8cdc2f6d36418d /attrib/client.c
parent5f722b2780dae76a11ecf8822b9aec150cc0e3ff (diff)
downloadbluez-97cd6046573d8acf8d98b0ee35c86126f0505dff.tar.gz
bluez-97cd6046573d8acf8d98b0ee35c86126f0505dff.tar.xz
bluez-97cd6046573d8acf8d98b0ee35c86126f0505dff.zip
Add BR/EDR connection establishment for GATT
Parses the psm for GATT and triggers the L2CAP connection for GATT.
Diffstat (limited to 'attrib/client.c')
-rw-r--r--attrib/client.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/attrib/client.c b/attrib/client.c
index 040c61e4..9b98ac70 100644
--- a/attrib/client.c
+++ b/attrib/client.c
@@ -32,6 +32,7 @@
#include "log.h"
#include "gdbus.h"
+#include "btio.h"
#include "client.h"
@@ -42,6 +43,7 @@ struct gatt_service {
bdaddr_t sba;
bdaddr_t dba;
char *path;
+ GIOChannel *io;
GSList *chars;
};
@@ -104,10 +106,30 @@ static GDBusMethodTable char_methods[] = {
{ }
};
-int attrib_client_register(bdaddr_t *sba, bdaddr_t *dba, const char *path)
+static void connect_cb(GIOChannel *chan, GError *gerr, gpointer user_data)
+{
+ struct gatt_service *gatt = user_data;
+
+ if (gerr) {
+ error("%s", gerr->message);
+ goto fail;
+ }
+
+ DBG("GATT connection established.");
+
+ return;
+fail:
+ g_io_channel_unref(gatt->io);
+ gatt->io = NULL;
+}
+
+int attrib_client_register(bdaddr_t *sba, bdaddr_t *dba, const char *path,
+ int psm)
{
struct gatt_service *gatt;
struct characteristic *chr;
+ GError *gerr = NULL;
+ GIOChannel *io;
/*
* Registering fake services/characteristics. The following
@@ -134,6 +156,21 @@ int attrib_client_register(bdaddr_t *sba, bdaddr_t *dba, const char *path)
return -1;
}
+ io = bt_io_connect(BT_IO_L2CAP, connect_cb, gatt, NULL, &gerr,
+ BT_IO_OPT_SOURCE_BDADDR, sba,
+ BT_IO_OPT_DEST_BDADDR, dba,
+ BT_IO_OPT_PSM, psm,
+ BT_IO_OPT_INVALID);
+
+ if (!io) {
+ error("%s", gerr->message);
+ g_error_free(gerr);
+ gatt_service_free(gatt);
+ return -1;
+ }
+
+ gatt->io = io;
+
services = g_slist_append(services, gatt);
DBG("Registered interface %s on path %s", CHAR_INTERFACE, path);