Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH] Move set_nonblocking function to audio/unix.c
@ 2010-11-04 19:43 Claudio Takahasi
  2010-11-04 19:43 ` [PATCH] Enable GATT over LE link on the attribute client Claudio Takahasi
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Claudio Takahasi @ 2010-11-04 19:43 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi

---
 audio/unix.c      |   20 ++++++++++++++++++++
 src/glib-helper.c |   20 --------------------
 src/glib-helper.h |    2 --
 3 files changed, 20 insertions(+), 22 deletions(-)

diff --git a/audio/unix.c b/audio/unix.c
index ad822bd..62eee31 100644
--- a/audio/unix.c
+++ b/audio/unix.c
@@ -27,6 +27,7 @@
 #endif
 
 #include <stdio.h>
+#include <fcntl.h>
 #include <sys/socket.h>
 #include <sys/un.h>
 #include <stdlib.h>
@@ -115,6 +116,25 @@ static void client_free(struct unix_client *client)
 	g_free(client);
 }
 
+static int set_nonblocking(int fd)
+{
+	long arg;
+
+	arg = fcntl(fd, F_GETFL);
+	if (arg < 0)
+		return -errno;
+
+	/* Return if already nonblocking */
+	if (arg & O_NONBLOCK)
+		return 0;
+
+	arg |= O_NONBLOCK;
+	if (fcntl(fd, F_SETFL, arg) < 0)
+		return -errno;
+
+	return 0;
+}
+
 /* Pass file descriptor through local domain sockets (AF_LOCAL, formerly
  * AF_UNIX) and the sendmsg() system call with the cmsg_type field of a "struct
  * cmsghdr" set to SCM_RIGHTS and the data being an integer value equal to the
diff --git a/src/glib-helper.c b/src/glib-helper.c
index b3c5003..9d76626 100644
--- a/src/glib-helper.c
+++ b/src/glib-helper.c
@@ -27,7 +27,6 @@
 
 #include <stdlib.h>
 #include <errno.h>
-#include <fcntl.h>
 #include <unistd.h>
 #include <sys/ioctl.h>
 #include <sys/socket.h>
@@ -113,25 +112,6 @@ static void cache_sdp_session(bdaddr_t *src, bdaddr_t *dst,
 						cached);
 }
 
-int set_nonblocking(int fd)
-{
-	long arg;
-
-	arg = fcntl(fd, F_GETFL);
-	if (arg < 0)
-		return -errno;
-
-	/* Return if already nonblocking */
-	if (arg & O_NONBLOCK)
-		return 0;
-
-	arg |= O_NONBLOCK;
-	if (fcntl(fd, F_SETFL, arg) < 0)
-		return -errno;
-
-	return 0;
-}
-
 struct search_context {
 	bdaddr_t		src;
 	bdaddr_t		dst;
diff --git a/src/glib-helper.h b/src/glib-helper.h
index 8a334e9..e89c2c6 100644
--- a/src/glib-helper.h
+++ b/src/glib-helper.h
@@ -21,8 +21,6 @@
  *
  */
 
-int set_nonblocking(int fd);
-
 typedef void (*bt_callback_t) (sdp_list_t *recs, int err, gpointer user_data);
 typedef void (*bt_destroy_t) (gpointer user_data);
 
-- 
1.7.3.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH] Enable GATT over LE link on the attribute client
  2010-11-04 19:43 [PATCH] Move set_nonblocking function to audio/unix.c Claudio Takahasi
@ 2010-11-04 19:43 ` Claudio Takahasi
  2010-11-05  5:03   ` Johan Hedberg
  2010-11-04 19:43 ` [PATCH] Fix invalid reference to GATT service structure Claudio Takahasi
  2010-11-05  5:02 ` [PATCH] Move set_nonblocking function to audio/unix.c Johan Hedberg
  2 siblings, 1 reply; 6+ messages in thread
From: Claudio Takahasi @ 2010-11-04 19:43 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi

---
 attrib/client.c   |   22 ++++++++++++----------
 attrib/gatt.h     |    2 ++
 attrib/gatttool.c |    1 -
 3 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/attrib/client.c b/attrib/client.c
index cd720e6..bcc903b 100644
--- a/attrib/client.c
+++ b/attrib/client.c
@@ -1352,23 +1352,25 @@ int attrib_client_register(struct btd_device *device, int psm)
 	}
 
 	if (psm < 0) {
-		/*
-		 * FIXME: when PSM is not given means that L2CAP fixed
-		 * channel shall be used. For this case, ATT CID(0x0004).
-		 */
-
-		DBG("GATT over LE");
-
-		return 0;
-	}
+		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_CID, GATT_CID,
+					BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_LOW,
+					BT_IO_OPT_INVALID);
 
-	io = bt_io_connect(BT_IO_L2CAP, connect_cb, gatt, NULL, &gerr,
+			DBG("GATT over Low Energy");
+	} else {
+		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_SEC_LEVEL, BT_IO_SEC_LOW,
 					BT_IO_OPT_INVALID);
 
+		DBG("GATT over Basic Rate");
+	}
+
 	if (!io) {
 		error("%s", gerr->message);
 		g_error_free(gerr);
diff --git a/attrib/gatt.h b/attrib/gatt.h
index a357f58..f1599c2 100644
--- a/attrib/gatt.h
+++ b/attrib/gatt.h
@@ -22,6 +22,8 @@
  *
  */
 
+#define GATT_CID 4
+
 guint gatt_discover_primary(GAttrib *attrib, uint16_t start,
 		uint16_t end, GAttribResultFunc func, gpointer user_data);
 
diff --git a/attrib/gatttool.c b/attrib/gatttool.c
index 2de3f8b..b9f5138 100644
--- a/attrib/gatttool.c
+++ b/attrib/gatttool.c
@@ -45,7 +45,6 @@
 
 /* Minimum MTU for L2CAP connections over BR/EDR */
 #define ATT_MIN_MTU_L2CAP 48
-#define GATT_CID 4
 
 static gchar *opt_src = NULL;
 static gchar *opt_dst = NULL;
-- 
1.7.3.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH] Fix invalid reference to GATT service structure
  2010-11-04 19:43 [PATCH] Move set_nonblocking function to audio/unix.c Claudio Takahasi
  2010-11-04 19:43 ` [PATCH] Enable GATT over LE link on the attribute client Claudio Takahasi
@ 2010-11-04 19:43 ` Claudio Takahasi
  2010-11-05  5:03   ` Johan Hedberg
  2010-11-05  5:02 ` [PATCH] Move set_nonblocking function to audio/unix.c Johan Hedberg
  2 siblings, 1 reply; 6+ messages in thread
From: Claudio Takahasi @ 2010-11-04 19:43 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi

---
 attrib/client.c |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/attrib/client.c b/attrib/client.c
index bcc903b..1f2c217 100644
--- a/attrib/client.c
+++ b/attrib/client.c
@@ -1342,13 +1342,9 @@ int attrib_client_register(struct btd_device *device, int psm)
 	bacpy(&gatt->dba, &dba);
 	gatt->psm = psm;
 
-	gatt_services = g_slist_append(gatt_services, gatt);
-
-	/* FIXME: we should also listen for incoming connections */
-
 	if (load_primary_services(gatt)) {
 		DBG("Primary services loaded");
-		return 0;
+		goto done;
 	}
 
 	if (psm < 0) {
@@ -1385,6 +1381,9 @@ int attrib_client_register(struct btd_device *device, int psm)
 	g_attrib_set_disconnect_function(gatt->attrib, attrib_disconnect,
 									gatt);
 
+done:
+	gatt_services = g_slist_append(gatt_services, gatt);
+
 	return 0;
 }
 
-- 
1.7.3.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] Move set_nonblocking function to audio/unix.c
  2010-11-04 19:43 [PATCH] Move set_nonblocking function to audio/unix.c Claudio Takahasi
  2010-11-04 19:43 ` [PATCH] Enable GATT over LE link on the attribute client Claudio Takahasi
  2010-11-04 19:43 ` [PATCH] Fix invalid reference to GATT service structure Claudio Takahasi
@ 2010-11-05  5:02 ` Johan Hedberg
  2 siblings, 0 replies; 6+ messages in thread
From: Johan Hedberg @ 2010-11-05  5:02 UTC (permalink / raw)
  To: Claudio Takahasi; +Cc: linux-bluetooth

Hi Claudio,

On Thu, Nov 04, 2010, Claudio Takahasi wrote:
> ---
>  audio/unix.c      |   20 ++++++++++++++++++++
>  src/glib-helper.c |   20 --------------------
>  src/glib-helper.h |    2 --
>  3 files changed, 20 insertions(+), 22 deletions(-)

Pushed upstream. Thanks.

Johan

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Enable GATT over LE link on the attribute client
  2010-11-04 19:43 ` [PATCH] Enable GATT over LE link on the attribute client Claudio Takahasi
@ 2010-11-05  5:03   ` Johan Hedberg
  0 siblings, 0 replies; 6+ messages in thread
From: Johan Hedberg @ 2010-11-05  5:03 UTC (permalink / raw)
  To: Claudio Takahasi; +Cc: linux-bluetooth

Hi Claudio,

On Thu, Nov 04, 2010, Claudio Takahasi wrote:
> ---
>  attrib/client.c   |   22 ++++++++++++----------
>  attrib/gatt.h     |    2 ++
>  attrib/gatttool.c |    1 -
>  3 files changed, 14 insertions(+), 11 deletions(-)

Pushed upstream. Thanks.

Johan

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Fix invalid reference to GATT service structure
  2010-11-04 19:43 ` [PATCH] Fix invalid reference to GATT service structure Claudio Takahasi
@ 2010-11-05  5:03   ` Johan Hedberg
  0 siblings, 0 replies; 6+ messages in thread
From: Johan Hedberg @ 2010-11-05  5:03 UTC (permalink / raw)
  To: Claudio Takahasi; +Cc: linux-bluetooth

Hi Claudio,

On Thu, Nov 04, 2010, Claudio Takahasi wrote:
> ---
>  attrib/client.c |    9 ++++-----
>  1 files changed, 4 insertions(+), 5 deletions(-)

This one has also been pushed upstream. Thanks.

Johan

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-11-05  5:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-04 19:43 [PATCH] Move set_nonblocking function to audio/unix.c Claudio Takahasi
2010-11-04 19:43 ` [PATCH] Enable GATT over LE link on the attribute client Claudio Takahasi
2010-11-05  5:03   ` Johan Hedberg
2010-11-04 19:43 ` [PATCH] Fix invalid reference to GATT service structure Claudio Takahasi
2010-11-05  5:03   ` Johan Hedberg
2010-11-05  5:02 ` [PATCH] Move set_nonblocking function to audio/unix.c Johan Hedberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox