Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH 2/8] Bluetooth: Clean up socket locking in l2cap_sock_recvmsg
From: johan.hedberg @ 2013-09-24 14:02 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1380031363-1266-1-git-send-email-johan.hedberg@gmail.com>

From: Johan Hedberg <johan.hedberg@intel.com>

This patch cleans up the locking login in l2cap_sock_recvmsg by pairing
up each lock_sock call with a release_sock call. The function already
has a "done" label that handles releasing the socket and returning from
the function so the fix is rather simple.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
 net/bluetooth/l2cap_sock.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index ad95b42..5853c1e 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -795,7 +795,7 @@ static int l2cap_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
 {
 	struct sock *sk = sock->sk;
 	struct l2cap_pinfo *pi = l2cap_pi(sk);
-	int err;
+	int err = 0;
 
 	lock_sock(sk);
 
@@ -805,8 +805,7 @@ static int l2cap_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
 		pi->chan->state = BT_CONFIG;
 
 		__l2cap_connect_rsp_defer(pi->chan);
-		release_sock(sk);
-		return 0;
+		goto done;
 	}
 
 	release_sock(sk);
-- 
1.8.4.rc3


^ permalink raw reply related

* [PATCH 1/8] Bluetooth: Add clarifying comment to bt_sock_wait_state()
From: johan.hedberg @ 2013-09-24 14:02 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1380031363-1266-1-git-send-email-johan.hedberg@gmail.com>

From: Johan Hedberg <johan.hedberg@intel.com>

The bt_sock_wait_state requires the sk lock to be held (through
lock_sock) so document it clearly in the code.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
 net/bluetooth/af_bluetooth.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c
index c600631..e6e1278 100644
--- a/net/bluetooth/af_bluetooth.c
+++ b/net/bluetooth/af_bluetooth.c
@@ -490,6 +490,7 @@ int bt_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
 }
 EXPORT_SYMBOL(bt_sock_ioctl);
 
+/* This function expects the sk lock to be held when called */
 int bt_sock_wait_state(struct sock *sk, int state, unsigned long timeo)
 {
 	DECLARE_WAITQUEUE(wait, current);
-- 
1.8.4.rc3


^ permalink raw reply related

* [PATCH 0/8] Bluetooth: Cleanups and LE advertising support
From: johan.hedberg @ 2013-09-24 14:02 UTC (permalink / raw)
  To: linux-bluetooth

Hi,

This patch set is a combination of cleanups that I had in my tree
(patches 1-3) a fix for set_powered (patch 4) and a new mgmt setting to
allow enabling LE advertising (patches 5-8). What's still open is
whether we want to rename the internal HCI_LE_PERIPHERAL flag to match
the "advertising" name used for the mgmt setting, however that can be
done as an independent patch on top of this set if necessary.

I've tested this through my own additions to user space btmgmt and
mgmt-tester tools. Once the general API is acked I'll push those
additions to bluez.git.

Johan

----------------------------------------------------------------
Johan Hedberg (8):
      Bluetooth: Add clarifying comment to bt_sock_wait_state()
      Bluetooth: Clean up socket locking in l2cap_sock_recvmsg
      Bluetooth: Test for HCI_SETUP and HCI_USER_CHANNEL in mgmt_valid_hdev()
      Bluetooth: Fix busy return for mgmt_set_powered in some cases
      Bluetooth: Move mgmt response convenience functions to a better location
      Bluetooth: Use async request for LE enable/disable
      Bluetooth: Add new mgmt setting for LE advertising
      Bluetooth: Add new mgmt_set_advertising command

 include/net/bluetooth/hci_core.h |   1 -
 include/net/bluetooth/mgmt.h     |   3 +
 net/bluetooth/af_bluetooth.c     |   1 +
 net/bluetooth/hci_core.c         |   4 +-
 net/bluetooth/hci_event.c        |  11 --
 net/bluetooth/l2cap_sock.c       |   5 +-
 net/bluetooth/mgmt.c             | 276 ++++++++++++++++++++++++++------------
 7 files changed, 199 insertions(+), 102 deletions(-)


^ permalink raw reply

* Re: [PATCH v2 1/3] build: Add skeleton for BlueZ Android
From: Anderson Lizardo @ 2013-09-24 12:57 UTC (permalink / raw)
  To: Frederic Danis; +Cc: BlueZ development
In-Reply-To: <1380024798-32017-1-git-send-email-frederic.danis@linux.intel.com>

Hi Frederic,

On Tue, Sep 24, 2013 at 8:13 AM, Frederic Danis
<frederic.danis@linux.intel.com> wrote:
> --- /dev/null
> +++ b/android/Android.mk
> @@ -0,0 +1,5 @@
> +LOCAL_PATH := $(call my-dir)
> +
> +# Retrieve BlueZ version from configure.ac file
> +BLUEZ_VERSION := $(shell grep AC_INIT $(LOCAL_PATH)/../configure.ac | tr -d ' ' | sed -e 's/.*(.*,\(.*\))/\1/')

It also works if you use the C preprocessor to get the version:

BLUEZ_VERSION := $(shell grep ^AC_INIT $(LOCAL_PATH)/../configure.ac |
cpp -P -D'AC_INIT(_,v)=v')


Best Regards,
-- 
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil

^ permalink raw reply

* [PATCH v2 3/3] android: Android version of log.c
From: Frederic Danis @ 2013-09-24 12:13 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1380024798-32017-1-git-send-email-frederic.danis@linux.intel.com>

Add logging system to BlueZ Android daemon.
Android build will use android/log.c file while autotools build will use
src/log.c instead.
---
 Makefile.android   |    4 +-
 android/Android.mk |    1 +
 android/log.c      |  172 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 android/main.c     |   34 +++++++++++
 4 files changed, 209 insertions(+), 2 deletions(-)
 create mode 100644 android/log.c

diff --git a/Makefile.android b/Makefile.android
index e056dce..1184e5f 100644
--- a/Makefile.android
+++ b/Makefile.android
@@ -2,8 +2,8 @@
 if ANDROID
 noinst_PROGRAMS += android/bluetoothd
 
-android_bluetoothd_SOURCES = android/main.c
+android_bluetoothd_SOURCES = android/main.c src/log.c
 android_bluetoothd_LDADD = @GLIB_LIBS@
 
-EXTRA_DIST += android/Android.mk
+EXTRA_DIST += android/Android.mk android/log.c
 endif
diff --git a/android/Android.mk b/android/Android.mk
index 06a93b3..04413de 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -14,6 +14,7 @@ include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := \
 	main.c \
+	log.c \
 
 LOCAL_C_INCLUDES := \
 	$(call include-path-for, glib) \
diff --git a/android/log.c b/android/log.c
new file mode 100644
index 0000000..908f883
--- /dev/null
+++ b/android/log.c
@@ -0,0 +1,172 @@
+/*
+ *
+ *  BlueZ - Bluetooth protocol stack for Linux
+ *
+ *  Copyright (C) 2013  Intel Corporation. All rights reserved.
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <unistd.h>
+#include <sys/uio.h>
+
+#include <glib.h>
+
+#include "log.h"
+
+#define LOG_DEBUG	3
+#define LOG_INFO	4
+#define LOG_WARN	5
+#define LOG_ERR		6
+
+static const char tag[] = "BlueZ";
+static int system_fd;
+
+static void android_log(int pri, const char *fmt, va_list ap)
+{
+	char *msg;
+	struct iovec vec[3];
+
+	if (system_fd == -1)
+		return;
+
+	msg = g_strdup_vprintf(fmt, ap);
+
+	vec[0].iov_base = (unsigned char *) &pri;
+	vec[0].iov_len = 1;
+	vec[1].iov_base = (void *) tag;
+	vec[1].iov_len = strlen(tag) + 1;
+	vec[2].iov_base = (void *) msg;
+	vec[2].iov_len = strlen(msg) + 1;
+
+	writev(system_fd, vec, 3);
+
+	g_free(msg);
+}
+
+void info(const char *format, ...)
+{
+	va_list ap;
+
+	va_start(ap, format);
+
+	android_log(LOG_INFO, format, ap);
+
+	va_end(ap);
+}
+
+void warn(const char *format, ...)
+{
+	va_list ap;
+
+	va_start(ap, format);
+
+	android_log(LOG_WARN, format, ap);
+
+	va_end(ap);
+}
+
+void error(const char *format, ...)
+{
+	va_list ap;
+
+	va_start(ap, format);
+
+	android_log(LOG_ERR, format, ap);
+
+	va_end(ap);
+}
+
+void btd_debug(const char *format, ...)
+{
+	va_list ap;
+
+	va_start(ap, format);
+
+	android_log(LOG_DEBUG, format, ap);
+
+	va_end(ap);
+}
+
+extern struct btd_debug_desc __start___debug[];
+extern struct btd_debug_desc __stop___debug[];
+
+static char **enabled = NULL;
+
+static gboolean is_enabled(struct btd_debug_desc *desc)
+{
+	int i;
+
+	if (enabled == NULL)
+		return 0;
+
+	for (i = 0; enabled[i] != NULL; i++)
+		if (desc->file != NULL && g_pattern_match_simple(enabled[i],
+							desc->file) == TRUE)
+			return 1;
+
+	return 0;
+}
+
+void __btd_enable_debug(struct btd_debug_desc *start,
+					struct btd_debug_desc *stop)
+{
+	struct btd_debug_desc *desc;
+
+	if (start == NULL || stop == NULL)
+		return;
+
+	for (desc = start; desc < stop; desc++) {
+		if (is_enabled(desc))
+			desc->flags |= BTD_DEBUG_FLAG_PRINT;
+	}
+}
+
+void __btd_toggle_debug(void)
+{
+	struct btd_debug_desc *desc;
+
+	for (desc = __start___debug; desc < __stop___debug; desc++)
+		desc->flags |= BTD_DEBUG_FLAG_PRINT;
+}
+
+void __btd_log_init(const char *debug, int detach)
+{
+	if (debug != NULL)
+		enabled = g_strsplit_set(debug, ":, ", 0);
+
+	__btd_enable_debug(__start___debug, __stop___debug);
+
+	system_fd = open("/dev/log/system", O_WRONLY);
+
+	info("Bluetooth daemon %s", VERSION);
+}
+
+void __btd_log_cleanup(void)
+{
+	close(system_fd);
+	system_fd = -1;
+
+	g_strfreev(enabled);
+}
diff --git a/android/main.c b/android/main.c
index 1dba2d4..c0a56b1 100644
--- a/android/main.c
+++ b/android/main.c
@@ -34,6 +34,8 @@
 
 #include <glib.h>
 
+#include "log.h"
+
 #define SHUTDOWN_GRACE_SECONDS 10
 
 static GMainLoop *event_loop;
@@ -57,10 +59,31 @@ static void sig_term(int sig)
 	__terminated = true;
 }
 
+static char *option_debug = NULL;
 static gboolean option_detach = TRUE;
 static gboolean option_version = FALSE;
 
+static void free_options(void)
+{
+	g_free(option_debug);
+	option_debug = NULL;
+}
+
+static gboolean parse_debug(const char *key, const char *value,
+				gpointer user_data, GError **error)
+{
+	if (value)
+		option_debug = g_strdup(value);
+	else
+		option_debug = g_strdup("*");
+
+	return TRUE;
+}
+
 static GOptionEntry options[] = {
+	{ "debug", 'd', G_OPTION_FLAG_OPTIONAL_ARG,
+				G_OPTION_ARG_CALLBACK, parse_debug,
+				"Specify debug options to enable", "DEBUG" },
 	{ "nodetach", 'n', G_OPTION_FLAG_REVERSE,
 				G_OPTION_ARG_NONE, &option_detach,
 				"Run with logging in foreground", NULL },
@@ -102,9 +125,20 @@ int main(int argc, char *argv[])
 	sigaction(SIGINT, &sa, NULL);
 	sigaction(SIGTERM, &sa, NULL);
 
+	__btd_log_init(option_debug, option_detach);
+
+	/* no need to keep parsed option in memory */
+	free_options();
+
+	DBG("Entering main loop");
+
 	g_main_loop_run(event_loop);
 
 	g_main_loop_unref(event_loop);
 
+	info("Exit");
+
+	__btd_log_cleanup();
+
 	return EXIT_SUCCESS;
 }
-- 
1.7.9.5


^ permalink raw reply related

* [PATCH v2 2/3] android: Add skeleton of BlueZ Android daemon
From: Frederic Danis @ 2013-09-24 12:13 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1380024798-32017-1-git-send-email-frederic.danis@linux.intel.com>

Define local mapping to glib path, otherwise this has to be inside central
place in the build repository.

Retrieve Bluetooth version from configure.ac.
---
 .gitignore         |    2 +
 Makefile.android   |    5 +++
 android/Android.mk |   24 ++++++++++++
 android/main.c     |  110 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 141 insertions(+)
 create mode 100644 android/main.c

diff --git a/.gitignore b/.gitignore
index 8a25a3e..3707209 100644
--- a/.gitignore
+++ b/.gitignore
@@ -98,3 +98,5 @@ unit/test-gobex-packet
 unit/test-gobex-transfer
 unit/test-*.log
 unit/test-*.trs
+
+android/bluetoothd
diff --git a/Makefile.android b/Makefile.android
index 5e43730..e056dce 100644
--- a/Makefile.android
+++ b/Makefile.android
@@ -1,4 +1,9 @@
 
 if ANDROID
+noinst_PROGRAMS += android/bluetoothd
+
+android_bluetoothd_SOURCES = android/main.c
+android_bluetoothd_LDADD = @GLIB_LIBS@
+
 EXTRA_DIST += android/Android.mk
 endif
diff --git a/android/Android.mk b/android/Android.mk
index e810654..06a93b3 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -3,3 +3,27 @@ LOCAL_PATH := $(call my-dir)
 # Retrieve BlueZ version from configure.ac file
 BLUEZ_VERSION := $(shell grep AC_INIT $(LOCAL_PATH)/../configure.ac | tr -d ' ' | sed -e 's/.*(.*,\(.*\))/\1/')
 
+# Specify pathmap for glib
+pathmap_INCL += glib:external/bluetooth/glib
+
+#
+# Android BlueZ daemon (bluetoothd)
+#
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+	main.c \
+
+LOCAL_C_INCLUDES := \
+	$(call include-path-for, glib) \
+	$(call include-path-for, glib)/glib \
+
+LOCAL_CFLAGS := -DVERSION=\"$(BLUEZ_VERSION)\"
+
+LOCAL_SHARED_LIBRARIES := \
+	libglib \
+
+LOCAL_MODULE := bluetoothd
+
+include $(BUILD_EXECUTABLE)
diff --git a/android/main.c b/android/main.c
new file mode 100644
index 0000000..1dba2d4
--- /dev/null
+++ b/android/main.c
@@ -0,0 +1,110 @@
+/*
+ *
+ *  BlueZ - Bluetooth protocol stack for Linux
+ *
+ *  Copyright (C) 2013  Intel Corporation. All rights reserved.
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <signal.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <string.h>
+
+#include <glib.h>
+
+#define SHUTDOWN_GRACE_SECONDS 10
+
+static GMainLoop *event_loop;
+
+static gboolean quit_eventloop(gpointer user_data)
+{
+	g_main_loop_quit(event_loop);
+
+	return FALSE;
+}
+
+static void sig_term(int sig)
+{
+	static bool __terminated = false;
+
+	if (!__terminated) {
+		g_timeout_add_seconds(SHUTDOWN_GRACE_SECONDS,
+						quit_eventloop, NULL);
+	}
+
+	__terminated = true;
+}
+
+static gboolean option_detach = TRUE;
+static gboolean option_version = FALSE;
+
+static GOptionEntry options[] = {
+	{ "nodetach", 'n', G_OPTION_FLAG_REVERSE,
+				G_OPTION_ARG_NONE, &option_detach,
+				"Run with logging in foreground", NULL },
+	{ "version", 'v', 0, G_OPTION_ARG_NONE, &option_version,
+				"Show version information and exit", NULL },
+	{ NULL }
+};
+
+int main(int argc, char *argv[])
+{
+	GOptionContext *context;
+	GError *err = NULL;
+	struct sigaction sa;
+
+	context = g_option_context_new(NULL);
+	g_option_context_add_main_entries(context, options, NULL);
+
+	if (g_option_context_parse(context, &argc, &argv, &err) == FALSE) {
+		if (err != NULL) {
+			g_printerr("%s\n", err->message);
+			g_error_free(err);
+		} else
+			g_printerr("An unknown error occurred\n");
+
+		exit(EXIT_FAILURE);
+	}
+
+	g_option_context_free(context);
+
+	if (option_version == TRUE) {
+		printf("%s\n", VERSION);
+		exit(EXIT_SUCCESS);
+	}
+
+	event_loop = g_main_loop_new(NULL, FALSE);
+
+	memset(&sa, 0, sizeof(sa));
+	sa.sa_handler = sig_term;
+	sigaction(SIGINT, &sa, NULL);
+	sigaction(SIGTERM, &sa, NULL);
+
+	g_main_loop_run(event_loop);
+
+	g_main_loop_unref(event_loop);
+
+	return EXIT_SUCCESS;
+}
-- 
1.7.9.5


^ permalink raw reply related

* [PATCH v2 1/3] build: Add skeleton for BlueZ Android
From: Frederic Danis @ 2013-09-24 12:13 UTC (permalink / raw)
  To: linux-bluetooth

---
 Makefile.am         |    4 +++-
 Makefile.android    |    4 ++++
 android/Android.mk  |    5 +++++
 bootstrap-configure |    3 ++-
 configure.ac        |    4 ++++
 5 files changed, 18 insertions(+), 2 deletions(-)
 create mode 100644 Makefile.android
 create mode 100644 android/Android.mk

diff --git a/Makefile.am b/Makefile.am
index 4e4b1c5..51204f4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -179,6 +179,7 @@ test_scripts =
 
 include Makefile.tools
 include Makefile.obexd
+include Makefile.android
 
 if HID2HCI
 rulesdir = @UDEV_DIR@/rules.d
@@ -293,7 +294,8 @@ pkgconfig_DATA = lib/bluez.pc
 endif
 
 DISTCHECK_CONFIGURE_FLAGS = --disable-datafiles --enable-library \
-					--disable-systemd --disable-udev
+					--disable-systemd --disable-udev \
+					--enable-android
 
 DISTCLEANFILES = $(pkgconfig_DATA)
 
diff --git a/Makefile.android b/Makefile.android
new file mode 100644
index 0000000..5e43730
--- /dev/null
+++ b/Makefile.android
@@ -0,0 +1,4 @@
+
+if ANDROID
+EXTRA_DIST += android/Android.mk
+endif
diff --git a/android/Android.mk b/android/Android.mk
new file mode 100644
index 0000000..e810654
--- /dev/null
+++ b/android/Android.mk
@@ -0,0 +1,5 @@
+LOCAL_PATH := $(call my-dir)
+
+# Retrieve BlueZ version from configure.ac file
+BLUEZ_VERSION := $(shell grep AC_INIT $(LOCAL_PATH)/../configure.ac | tr -d ' ' | sed -e 's/.*(.*,\(.*\))/\1/')
+
diff --git a/bootstrap-configure b/bootstrap-configure
index 7a6e7d1..8bde920 100755
--- a/bootstrap-configure
+++ b/bootstrap-configure
@@ -12,4 +12,5 @@ fi
 		--sysconfdir=/etc \
 		--localstatedir=/var \
 		--enable-experimental \
-		--disable-datafiles $*
+		--disable-datafiles \
+		--enable-android $*
diff --git a/configure.ac b/configure.ac
index 41c2935..22ab240 100644
--- a/configure.ac
+++ b/configure.ac
@@ -242,4 +242,8 @@ AC_DEFINE_UNQUOTED(CONFIGDIR, "${configdir}",
 			[Directory for the configuration files])
 AC_SUBST(CONFIGDIR, "${configdir}")
 
+AC_ARG_ENABLE(android, AC_HELP_STRING([--enable-android],
+			[enable BlueZ Android]), [android=${enableval}])
+AM_CONDITIONAL(ANDROID, test "${android}" = "yes")
+
 AC_OUTPUT(Makefile src/bluetoothd.8 lib/bluez.pc)
-- 
1.7.9.5


^ permalink raw reply related

* [PATCH 1/1] obexd: Fix emitting Type property changed signals for messages
From: Christian Fetzer @ 2013-09-24 11:27 UTC (permalink / raw)
  To: linux-bluetooth

From: Christian Fetzer <christian.fetzer@bmw-carit.de>

In order to determine if the message Type property has changed,
the stored type needs to be compared with the parsed type and not with
the raw value received from the MSE.

This fixes the issue that the property changed signal for the Type
property is emitted for every message on every ListMessage call.
---
 obexd/client/map.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/obexd/client/map.c b/obexd/client/map.c
index 9fe872d..d349ef7 100644
--- a/obexd/client/map.c
+++ b/obexd/client/map.c
@@ -920,21 +920,22 @@ static void parse_recipient_address(struct map_msg *msg, const char *value)
 
 static void parse_type(struct map_msg *msg, const char *value)
 {
-	if (g_strcmp0(msg->type, value) == 0)
-		return;
-
-	g_free(msg->type);
+	const char *type = NULL;
 
 	if (strcasecmp(value, "SMS_GSM") == 0)
-		msg->type = g_strdup("sms-gsm");
+		type = "sms-gsm";
 	else if (strcasecmp(value, "SMS_CDMA") == 0)
-		msg->type = g_strdup("sms-cdma");
+		type = "sms-cdma";
 	else if (strcasecmp(value, "EMAIL") == 0)
-		msg->type = g_strdup("email");
+		type = "email";
 	else if (strcasecmp(value, "MMS") == 0)
-		msg->type = g_strdup("mms");
-	else
-		msg->type = NULL;
+		type = "mms";
+
+	if (g_strcmp0(msg->type, type) == 0)
+		return;
+
+	g_free(msg->type);
+	msg->type = g_strdup(type);
 
 	g_dbus_emit_property_changed(conn, msg->path,
 						MAP_MSG_INTERFACE, "Type");
-- 
1.8.3.4


^ permalink raw reply related

* Re: [PATCH 2/2] android: Android version of log.c
From: Frederic Danis @ 2013-09-24  9:05 UTC (permalink / raw)
  To: Marcel Holtmann; +Cc: linux-bluetooth
In-Reply-To: <708DB870-5A40-4056-86C8-79092784757C@holtmann.org>

Hello Marcel,

On 21/09/2013 19:20, Marcel Holtmann wrote:
<snip>
>> @@ -110,10 +137,22 @@ int main(int argc, char *argv[])
>> 	sa.sa_handler = signal_handler;
>> 	sigaction(SIGINT, &sa, NULL);
>> 	sigaction(SIGTERM, &sa, NULL);
>> +	sigaction(SIGUSR2, &sa, NULL);
>> +
>> +	__btd_log_init(option_debug, option_detach);
>> +
>> +	/* no need to keep parsed option in memory */
>> +	free_options();
>> +
>> +	DBG("Entering main loop");
>
> Don't do this debug. It is not helpful. The main() is so short, no point in logging that.

I need at least one DBG call to be able to build, otherwise I got 
"undefined reference to `__start___debug'" error messages.
So, this one seems ok to me.

Regards

Fred

-- 
Frederic Danis                            Open Source Technology Center
frederic.danis@intel.com                              Intel Corporation

^ permalink raw reply

* [RFC 2/2] android: Add Socket Bluetooth HAL template
From: Andrei Emeltchenko @ 2013-09-24  8:31 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1380011516-7847-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

bt_sock HAL handles Bluetooth sockets for Android.
---
 android/Android.mk    |    1 +
 android/hal_bt_sock.c |   86 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 87 insertions(+)
 create mode 100644 android/hal_bt_sock.c

diff --git a/android/Android.mk b/android/Android.mk
index ca9501f..93de803 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -32,6 +32,7 @@ include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := \
 	hal_bluetooth.c \
+	hal_bt_sock.c \
 
 LOCAL_SHARED_LIBRARIES := \
 	libcutils \
diff --git a/android/hal_bt_sock.c b/android/hal_bt_sock.c
new file mode 100644
index 0000000..cd36e1f
--- /dev/null
+++ b/android/hal_bt_sock.c
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2013 Intel Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdlib.h>
+
+#include <hardware/bluetooth.h>
+#include <hardware/bt_sock.h>
+
+#define LOG_TAG "BlueZ"
+#include <cutils/log.h>
+
+static bt_status_t btsock_listen_rfcomm(const char *service_name,
+					const uint8_t *uuid, int channel,
+					int *sock_fd, int flags)
+{
+	ALOGI(__func__);
+
+	return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t btsock_listen(btsock_type_t type, const char *service_name,
+					const uint8_t *uuid, int channel,
+					int *sock_fd, int flags)
+{
+	if ((uuid == NULL && channel <= 0) || sock_fd == NULL) {
+		ALOGE("%s: invalid params: uuid %p, chan %d, sock %p",
+					__func__, uuid, channel, sock_fd);
+		return BT_STATUS_PARM_INVALID;
+	}
+
+	ALOGI("%s: uuid %p chan %d sock %p type %d service_name %s",
+			__func__, uuid, channel, sock_fd, type, service_name);
+
+	switch (type) {
+	case BTSOCK_RFCOMM:
+		return btsock_listen_rfcomm(service_name, uuid, channel,
+					    sock_fd, flags);
+	default:
+		ALOGE("%s: Socket type %d not supported", __func__, type);
+	}
+
+	return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t btsock_connect(const bt_bdaddr_t *bd_addr,
+					btsock_type_t type,
+					const uint8_t *uuid, int channel,
+					int *sock_fd, int flags)
+{
+	if ((uuid == NULL && channel <= 0) || bd_addr == NULL ||
+							sock_fd == NULL) {
+		ALOGE("invalid params: bd_addr %p, uuid %p, chan %d, sock %p",
+					bd_addr, uuid, channel, sock_fd);
+		return BT_STATUS_PARM_INVALID;
+	}
+
+	ALOGI("%s: uuid %p chan %d sock %p type %d", __func__,
+						uuid, channel, sock_fd, type);
+
+	return BT_STATUS_UNSUPPORTED;
+}
+
+static btsock_interface_t sock_if = {
+	sizeof(sock_if),
+	btsock_listen,
+	btsock_connect
+};
+
+btsock_interface_t *bt_get_sock_interface(void)
+{
+	return &sock_if;
+}
-- 
1.7.10.4


^ permalink raw reply related

* [RFC 1/2] android: Add Adapter Bluetooth HAL template
From: Andrei Emeltchenko @ 2013-09-24  8:31 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1380011516-7847-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

Add template for bluetooth.h Android HAL.
---
 android/Android.mk      |   19 +++
 android/hal_bluetooth.c |  367 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 386 insertions(+)
 create mode 100644 android/hal_bluetooth.c

diff --git a/android/Android.mk b/android/Android.mk
index 5d09f00..ca9501f 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -23,3 +23,22 @@ LOCAL_SHARED_LIBRARIES := \
 LOCAL_MODULE := bluezd
 
 include $(BUILD_EXECUTABLE)
+
+#
+# bluetooth.default.so HAL
+#
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+	hal_bluetooth.c \
+
+LOCAL_SHARED_LIBRARIES := \
+	libcutils \
+
+LOCAL_MODULE := bluetooth.default
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_CLASS := SHARED_LIBRARIES
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/android/hal_bluetooth.c b/android/hal_bluetooth.c
new file mode 100644
index 0000000..4447bed
--- /dev/null
+++ b/android/hal_bluetooth.c
@@ -0,0 +1,367 @@
+/*
+ * Copyright (C) 2013 Intel Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdbool.h>
+
+#include <hardware/bluetooth.h>
+
+#define LOG_TAG "BlueZ"
+#include <cutils/log.h>
+
+bt_callbacks_t *bt_hal_cbacks = NULL;
+
+static bool interface_ready(void)
+{
+	return bt_hal_cbacks != NULL;
+}
+
+static int init(bt_callbacks_t *callbacks)
+{
+	ALOGI(__func__);
+
+	/* sanity check */
+	if (interface_ready() == true)
+		return BT_STATUS_SUCCESS;
+
+	/* store reference to user callbacks */
+	bt_hal_cbacks = callbacks;
+
+	/* TODO: Init here bluezd task */
+
+	return BT_STATUS_UNSUPPORTED;
+}
+
+static int enable(void)
+{
+	ALOGI(__func__);
+
+	return BT_STATUS_UNSUPPORTED;
+}
+
+static int disable(void)
+{
+	ALOGI(__func__);
+
+	/* sanity check */
+	if (interface_ready() == false)
+		return BT_STATUS_NOT_READY;
+
+	return BT_STATUS_UNSUPPORTED;
+}
+
+static void cleanup(void)
+{
+	ALOGI(__func__);
+
+	/* sanity check */
+	if (interface_ready() == false)
+		return;
+
+	bt_hal_cbacks = NULL;
+}
+
+static int get_adapter_properties(void)
+{
+	ALOGI(__func__);
+
+	/* sanity check */
+	if (interface_ready() == false)
+		return BT_STATUS_NOT_READY;
+
+	return BT_STATUS_UNSUPPORTED;
+}
+
+static int get_adapter_property(bt_property_type_t type)
+{
+	ALOGI(__func__);
+
+	/* sanity check */
+	if (interface_ready() == false)
+		return BT_STATUS_NOT_READY;
+
+	return BT_STATUS_UNSUPPORTED;
+}
+
+static int set_adapter_property(const bt_property_t *property)
+{
+	ALOGI(__func__);
+
+	/* sanity check */
+	if (interface_ready() == false)
+		return BT_STATUS_NOT_READY;
+
+	if (property == NULL)
+		return BT_STATUS_PARM_INVALID;
+
+	return BT_STATUS_UNSUPPORTED;
+}
+
+int get_remote_device_properties(bt_bdaddr_t *remote_addr)
+{
+	ALOGI(__func__);
+
+	/* sanity check */
+	if (interface_ready() == false)
+		return BT_STATUS_NOT_READY;
+
+	return BT_STATUS_UNSUPPORTED;
+}
+
+int get_remote_device_property(bt_bdaddr_t *remote_addr,
+						bt_property_type_t type)
+{
+	ALOGI(__func__);
+
+	/* sanity check */
+	if (interface_ready() == false)
+		return BT_STATUS_NOT_READY;
+
+	return BT_STATUS_UNSUPPORTED;
+}
+
+int set_remote_device_property(bt_bdaddr_t *remote_addr,
+						const bt_property_t *property)
+{
+	ALOGI(__func__);
+
+	/* sanity check */
+	if (interface_ready() == false)
+		return BT_STATUS_NOT_READY;
+
+	return BT_STATUS_UNSUPPORTED;
+}
+
+int get_remote_service_record(bt_bdaddr_t *remote_addr, bt_uuid_t *uuid)
+{
+	ALOGI(__func__);
+
+	/* sanity check */
+	if (interface_ready() == false)
+		return BT_STATUS_NOT_READY;
+
+	return BT_STATUS_UNSUPPORTED;
+}
+
+int get_remote_services(bt_bdaddr_t *remote_addr)
+{
+	ALOGI(__func__);
+
+	/* sanity check */
+	if (interface_ready() == false)
+		return BT_STATUS_NOT_READY;
+
+	return BT_STATUS_UNSUPPORTED;
+}
+
+static int start_discovery(void)
+{
+	ALOGI(__func__);
+
+	/* sanity check */
+	if (interface_ready() == false)
+		return BT_STATUS_NOT_READY;
+
+	return BT_STATUS_UNSUPPORTED;
+}
+
+static int cancel_discovery(void)
+{
+	ALOGI(__func__);
+
+	/* sanity check */
+	if (interface_ready() == false)
+		return BT_STATUS_NOT_READY;
+
+	return BT_STATUS_UNSUPPORTED;
+}
+
+static int create_bond(const bt_bdaddr_t *bd_addr)
+{
+	ALOGI(__func__);
+
+	/* sanity check */
+	if (interface_ready() == false)
+		return BT_STATUS_NOT_READY;
+
+	if (bd_addr == NULL)
+		return BT_STATUS_PARM_INVALID;
+
+	return BT_STATUS_UNSUPPORTED;
+}
+
+static int cancel_bond(const bt_bdaddr_t *bd_addr)
+{
+	ALOGI(__func__);
+
+	/* sanity check */
+	if (interface_ready() == false)
+		return BT_STATUS_NOT_READY;
+
+	return BT_STATUS_UNSUPPORTED;
+}
+
+static int remove_bond(const bt_bdaddr_t *bd_addr)
+{
+	ALOGI(__func__);
+
+	/* sanity check */
+	if (interface_ready() == false)
+		return BT_STATUS_NOT_READY;
+
+	return BT_STATUS_UNSUPPORTED;
+}
+
+static int pin_reply(const bt_bdaddr_t *bd_addr, uint8_t accept,
+				uint8_t pin_len, bt_pin_code_t *pin_code)
+{
+	ALOGI(__func__);
+
+	/* sanity check */
+	if (interface_ready() == false)
+		return BT_STATUS_NOT_READY;
+
+	return BT_STATUS_UNSUPPORTED;
+}
+
+static int ssp_reply(const bt_bdaddr_t *bd_addr, bt_ssp_variant_t variant,
+					uint8_t accept, uint32_t passkey)
+{
+
+	ALOGI(__func__);
+
+	/* sanity check */
+	if (interface_ready() == false)
+		return BT_STATUS_NOT_READY;
+
+	if (bd_addr == NULL)
+		return BT_STATUS_PARM_INVALID;
+
+	return BT_STATUS_UNSUPPORTED;
+}
+
+static const void *get_profile_interface(const char *profile_id)
+{
+	ALOGI("%s: %s", __func__, profile_id);
+
+	/* sanity check */
+	if (interface_ready() == false)
+		return NULL;
+
+	return NULL;
+}
+
+int dut_mode_configure(uint8_t enable)
+{
+	ALOGI(__func__);
+
+	/* sanity check */
+	if (interface_ready() == false)
+		return BT_STATUS_NOT_READY;
+
+	return BT_STATUS_UNSUPPORTED;
+}
+
+int dut_mode_send(uint16_t opcode, uint8_t *buf, uint8_t len)
+{
+	ALOGI(__func__);
+
+	/* sanity check */
+	if (interface_ready() == false)
+		return BT_STATUS_NOT_READY;
+
+	return BT_STATUS_UNSUPPORTED;
+}
+
+/**
+ * HAL Interface declaration
+ */
+static const bt_interface_t bluetoothInterface = {
+	sizeof(bt_interface_t),
+	init,
+	enable,
+	disable,
+	cleanup,
+	get_adapter_properties,
+	get_adapter_property,
+	set_adapter_property,
+	get_remote_device_properties,
+	get_remote_device_property,
+	set_remote_device_property,
+	get_remote_service_record,
+	get_remote_services,
+	start_discovery,
+	cancel_discovery,
+	create_bond,
+	remove_bond,
+	cancel_bond,
+	pin_reply,
+	ssp_reply,
+	get_profile_interface,
+	dut_mode_configure,
+	dut_mode_send
+};
+
+const bt_interface_t *bluetooth__get_bluetooth_interface(void)
+{
+	ALOGI(__func__);
+
+	return &bluetoothInterface;
+}
+
+static int close_bluetooth_stack(struct hw_device_t *device)
+{
+	ALOGI(__func__);
+
+	cleanup();
+
+	return 0;
+}
+
+static int open_bluetooth_stack(const struct hw_module_t *module,
+			char const *name, struct hw_device_t **abstraction)
+{
+	bluetooth_device_t *stack = malloc(sizeof(bluetooth_device_t));
+
+	ALOGI(__func__);
+
+	memset(stack, 0, sizeof(bluetooth_device_t));
+	stack->common.tag = HARDWARE_DEVICE_TAG;
+	stack->common.version = 0;
+	stack->common.module = (struct hw_module_t *) module;
+	stack->common.close = close_bluetooth_stack;
+	stack->get_bluetooth_interface = bluetooth__get_bluetooth_interface;
+	*abstraction = (struct hw_device_t *) stack;
+
+	return 0;
+}
+
+static struct hw_module_methods_t bt_stack_module_methods = {
+	.open = open_bluetooth_stack,
+};
+
+struct hw_module_t HAL_MODULE_INFO_SYM = {
+	.tag = HARDWARE_MODULE_TAG,
+	.version_major = 1,
+	.version_minor = 0,
+	.id = BT_HARDWARE_MODULE_ID,
+	.name = "Bluetooth Stack",
+	.author = "The Android Open Source Project",
+	.methods = &bt_stack_module_methods
+};
-- 
1.7.10.4


^ permalink raw reply related

* [RFC 0/2] Adapter and Socket templates
From: Andrei Emeltchenko @ 2013-09-24  8:31 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

First versions of adapter and socket templates.

Andrei Emeltchenko (2):
  android: Add Adapter Bluetooth HAL template
  android: Add Socket Bluetooth HAL template

 android/Android.mk      |   20 +++
 android/hal_bluetooth.c |  367 +++++++++++++++++++++++++++++++++++++++++++++++
 android/hal_bt_sock.c   |   86 +++++++++++
 3 files changed, 473 insertions(+)
 create mode 100644 android/hal_bluetooth.c
 create mode 100644 android/hal_bt_sock.c

-- 
1.7.10.4


^ permalink raw reply

* [PATCH 2/2] obexd:Add get_address property to transfer properties
From: Wu Zheng @ 2013-09-24  7:37 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Wu Zheng

Sometime, address is needed by the Bluetooth OBEX APP.
Therefore, add the property to transfer properties
---
 obexd/src/manager.c |   37 +++++++++++++++++++++++++++++++++++++
 1 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/obexd/src/manager.c b/obexd/src/manager.c
index 96976ec..b338a72 100644
--- a/obexd/src/manager.c
+++ b/obexd/src/manager.c
@@ -551,6 +551,41 @@ static gboolean transfer_get_operation(const GDBusPropertyTable *property,
 	return TRUE;
 }
 
+static gboolean transfer_address_exists(const GDBusPropertyTable *property,
+								void *data)
+{
+	struct obex_transfer *transfer = data;
+	struct obex_session *session = transfer->session;
+	char *address;
+	int err;
+
+	err = obex_getpeername(session, &address);
+	if (err < 0)
+		return FALSE;
+
+	g_free(address);
+
+	return TRUE;
+}
+
+static gboolean transfer_get_address(const GDBusPropertyTable *property,
+					DBusMessageIter *iter, void *data)
+{
+	struct obex_transfer *transfer = data;
+	struct obex_session *session = transfer->session;
+	char *address;
+	int err;
+
+	err = obex_getpeername(session, &address);
+	if (err < 0)
+		return FALSE;
+
+	dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &address);
+	g_free(address);
+
+	return TRUE;
+}
+
 static gboolean transfer_get_transferred(const GDBusPropertyTable *property,
 					DBusMessageIter *iter, void *data)
 {
@@ -587,6 +622,8 @@ static const GDBusPropertyTable transfer_properties[] = {
 						transfer_filename_exists },
 	{ "Operation", "s", transfer_get_operation, NULL,
 						transfer_operation_exists },
+	{ "Address", "s", transfer_get_address, NULL,
+						transfer_address_exists },
 	{ "Transferred", "t", transfer_get_transferred },
 	{ }
 };
-- 
1.7.7


^ permalink raw reply related

* [PATCH 1/2] obexd:Add Operation property to transfer properties
From: Wu Zheng @ 2013-09-24  7:37 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Wu Zheng

Sometime, operation property is needed by the Bluetooth APP.
Therefore, add the property to transfer properties
---
 obexd/src/manager.c |   38 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/obexd/src/manager.c b/obexd/src/manager.c
index f64b7b9..96976ec 100644
--- a/obexd/src/manager.c
+++ b/obexd/src/manager.c
@@ -35,6 +35,7 @@
 
 #include <btio/btio.h>
 #include <gobex/gobex.h>
+#include <gobex/gobex-packet.h>
 
 #include "obexd.h"
 #include "obex.h"
@@ -515,6 +516,41 @@ static gboolean transfer_get_filename(const GDBusPropertyTable *property,
 	return TRUE;
 }
 
+static gboolean transfer_operation_exists(const GDBusPropertyTable *property,
+								void *data)
+{
+	struct obex_transfer *transfer = data;
+	struct obex_session *session = transfer->session;
+
+	if (session->cmd == G_OBEX_OP_PUT &&
+				session->size != OBJECT_SIZE_DELETE)
+		return TRUE;
+	else if (session->cmd == G_OBEX_OP_GET)
+		return TRUE;
+	else
+		return FALSE;
+}
+
+static gboolean transfer_get_operation(const GDBusPropertyTable *property,
+					DBusMessageIter *iter, void *data)
+{
+	struct obex_transfer *transfer = data;
+	struct obex_session *session = transfer->session;
+	const char *operation;
+
+	if (session->cmd == G_OBEX_OP_PUT &&
+				session->size != OBJECT_SIZE_DELETE)
+		operation = "PUT";
+	else if (session->cmd == G_OBEX_OP_GET)
+		operation = "GET";
+	else
+		return FALSE;
+
+	dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &operation);
+
+	return TRUE;
+}
+
 static gboolean transfer_get_transferred(const GDBusPropertyTable *property,
 					DBusMessageIter *iter, void *data)
 {
@@ -549,6 +585,8 @@ static const GDBusPropertyTable transfer_properties[] = {
 	{ "Time", "t", transfer_get_time, NULL, transfer_time_exists },
 	{ "Filename", "s", transfer_get_filename, NULL,
 						transfer_filename_exists },
+	{ "Operation", "s", transfer_get_operation, NULL,
+						transfer_operation_exists },
 	{ "Transferred", "t", transfer_get_transferred },
 	{ }
 };
-- 
1.7.7


^ permalink raw reply related

* Re: [PATCH 1/2] android: Add skeleton of BlueZ Android daemon
From: Andrei Emeltchenko @ 2013-09-24  7:32 UTC (permalink / raw)
  To: Lukasz Rymanowski; +Cc: Frederic Danis, Marcel Holtmann, linux-bluetooth
In-Reply-To: <CAN_7+YYSLwsPTfJoYwJKcVtP6EMxOeD8MHox+Pvzcrk_YKcSaQ@mail.gmail.com>

Hi All,

On Mon, Sep 23, 2013 at 09:28:44PM +0200, Lukasz Rymanowski wrote:
> Hi Marcel,
> 
> On Mon, Sep 23, 2013 at 11:51 AM, Frederic Danis
> <frederic.danis@linux.intel.com> wrote:
> > Hello Marcel,
> >
> > On 21/09/2013 19:14, Marcel Holtmann wrote:
> >>
> >> Hi Fred,
> >>
> >>> Define local mapping to glib path, otherwise this has to be inside
> >>> central
> >>> place in the build repository.
> >>>
> >>> Retrieve Bluetooth version from configure.ac.
> >>> ---
> >>> .gitignore         |    2 +
> >>> Android.mk         |    9 ++++
> >>> Makefile.am        |    1 +
> >>> Makefile.android   |    7 ++++
> >>> android/Android.mk |   24 +++++++++++
> >>> android/main.c     |  119
> >>> ++++++++++++++++++++++++++++++++++++++++++++++++++++
> >>> configure.ac       |    5 +++
> >>> 7 files changed, 167 insertions(+)
> >>> create mode 100644 Android.mk
> >>> create mode 100644 Makefile.android
> >>> create mode 100644 android/Android.mk
> >>> create mode 100644 android/main.c
> >>
> >>
> >> lets split this out a little bit. Code additions should not be intermixed
> >> with additions to the build system and especially configure options.
> >>
> >> I rather not have a top-level Android.mk. It should be enough to provide
> >> an android/Android.mk.
> 
>  BTW, do you expect to have only one Android.mk for the whole project or
> this is OK for you to have smaller Android.mk in different subfolders like
> /src/shared etc. Both ways are valid.

While having a single huge Android makefile is somehow make sense it would have
several disadvantages:
- we cannot use local build with "mm" for building for example only tools
  or libs
- Android.mk will become very large and difficult to read

Best regards 
Andrei Emeltchenko 

^ permalink raw reply

* [PATCH] sdptool: Clarify 'add' and 'remove' commands in manual
From: Szymon Janc @ 2013-09-24  7:09 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

Adapters are no longer notified about external changes in SDP
database. This results in 'add' and 'remove' commands being
usefull only for SDP testing or qualification.
---
 tools/sdptool.1 | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tools/sdptool.1 b/tools/sdptool.1
index 88ad818..ea95933 100644
--- a/tools/sdptool.1
+++ b/tools/sdptool.1
@@ -91,9 +91,15 @@ the \fB--handle\fP option.
 .IP "" 10
 You can specify a channel to add the service on
 using the \fB--channel\fP option.
+.IP "" 10
+NOTE: Local adapters configuration will not be updated and this command should
+be used only for SDP testing.
 .IP "\fBdel record_handle\fP" 10
 Remove a service from the local
 SDP database.
+.IP "" 10
+NOTE: Local adapters configuration will not be updated and this command should
+be used only for SDP testing.
 .IP "\fBget [--tree] [--raw] [--xml] [--bdaddr bdaddr] record_handle\fP" 10
 Retrieve a service from the local
 SDP database.
-- 
1.8.4


^ permalink raw reply related

* Re: [PATCH 08/12] bluetooth: Remove extern from function prototypes
From: Marcel Holtmann @ 2013-09-24  4:24 UTC (permalink / raw)
  To: Joe Perches
  Cc: netdev, David S. Miller, linux-kernel, Gustavo Padovan,
	Johan Hedberg, linux-bluetooth
In-Reply-To: <e9994a2b839277a9237364b59e655060f1fcb957.1379961014.git.joe@perches.com>

Hi Joe,

> There are a mix of function prototypes with and without extern
> in the kernel sources.  Standardize on not using extern for
> function prototypes.
> 
> Function prototypes don't need to be written with extern.
> extern is assumed by the compiler.  Its use is as unnecessary as
> using auto to declare automatic/local variables in a block.
> 
> Signed-off-by: Joe Perches <joe@perches.com>
> ---
> include/net/bluetooth/bluetooth.h | 16 ++++++++--------
> include/net/bluetooth/hci_core.h  | 23 +++++++++++------------
> include/net/bluetooth/rfcomm.h    |  4 ++--
> 3 files changed, 21 insertions(+), 22 deletions(-)

Acked-by: Marcel Holtmann <marcel@holtmann.org>

Regards

Marcel


^ permalink raw reply

* Re: [PATCH v5 1/2] Bluetooth: btmrvl: add setup handler
From: Marcel Holtmann @ 2013-09-24  4:23 UTC (permalink / raw)
  To: Bing Zhao
  Cc: linux-bluetooth@vger.kernel.org, Gustavo Padovan, Johan Hedberg,
	linux-wireless@vger.kernel.org, Mike Frysinger, Hyuckjoo Lee,
	Amitkumar Karwar
In-Reply-To: <477F20668A386D41ADCC57781B1F70430F44C59418@SC-VEXCH1.marvell.com>

Hi Bing,

>>> -	btmrvl_send_module_cfg_cmd(priv, MODULE_BRINGUP_REQ);
>>> +	hdev->setup = btmrvl_setup;
>> 
>> just to make sure you guys understand how ->setup() works. It is only called once. Bringing the
>> adapter down and up again does not call ->setup() a second time. So do you guys need this setup_done
>> variable and if so, then you need to be a bit more verbose and help me understand why.
> 
> It's observed that sometimes the setup handler is called twice when Bluetooth daemon is running in background. We will rebase to latest commit on bluetooth-next tree and test again. If the issue is gone with the latest code in -next tree we will remove the setup_done flag.

that is a bug. It should only be ever called once. Could this be due to RFKILL issue we had? Please re-test with Johan's patches applied and check if it makes a difference. Otherwise please send some logs since we want to get this fixed.

Regards

Marcel


^ permalink raw reply

* Re: [PATCH v5 2/2] Bluetooth: btmrvl: add calibration data download support
From: Marcel Holtmann @ 2013-09-24  4:21 UTC (permalink / raw)
  To: Bing Zhao
  Cc: linux-bluetooth@vger.kernel.org, Gustavo Padovan, Johan Hedberg,
	linux-wireless@vger.kernel.org, Mike Frysinger, Hyuckjoo Lee,
	Amitkumar Karwar
In-Reply-To: <477F20668A386D41ADCC57781B1F70430F44C59423@SC-VEXCH1.marvell.com>

Hi Bing,

>>> +	cmd = (struct btmrvl_cmd *)skb->data;
>>> +	cmd->ocf_ogf =
>>> +		cpu_to_le16(hci_opcode_pack(OGF, BT_CMD_LOAD_CONFIG_DATA));
>>> +	cmd->length = BT_CMD_DATA_SIZE;
>>> +	cmd->data[0] = 0x00;
>>> +	cmd->data[1] = 0x00;
>>> +	cmd->data[2] = 0x00;
>>> +	cmd->data[3] = BT_CMD_DATA_SIZE - 4;
>> 
>> why not use __hci_cmd_sync() here. It is designed to be used from ->setup() where it is guaranteed
>> that the HCI request lock is held. And it is guaranteed that ->setup() is executed in a workqueue.
> 
> The reason of not using __hci_cmd_sync() is that we are sending vendor specific command here (MRVL_VENDOR_PKT). The __hci_cmd_sync seems handle HCI_COMMAND_PKT only.
> Please let us know if you have any suggestion to solve this problem.

what is a MRVL_VENDOR_PKT actually?

If you guys are not using standard HCI command/event for vendor operation, then this obviously does not fit. However a similar model might make sense instead of manually building packets all the time.

Regards

Marcel


^ permalink raw reply

* pull request: bluetooth 2013-09-23
From: Gustavo Padovan @ 2013-09-23 21:00 UTC (permalink / raw)
  To: linville; +Cc: linux-wireless, linux-bluetooth, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2208 bytes --]

Hi John,

First Bluetooth fixes to 3.12, it includes:

* 3 patches to add device id for 3 new hardwares.

* 2 patches from Johan to fix the rfkill behaviour during setup stage

* a small clean up in the rfcomm TTY code that fixes a potential racy
condition (by Gianluca Anzolin)

* 2 fixes to proper set encryption key size and security level in the
peripheral role of Bluetooth LE devices. (by Andre Guedes)

* a fix for dealing devices where pairing is not necessary, we were keeping
the Bluetooth ACL connection alive for too much time. (by Syam Sidhardhan)

Please pull or let me know of any problems! Thanks!


	Gustavo

---
The following changes since commit f4e1a4d3ecbb9e42bdf8e7869ee8a4ebfa27fb20:

  rt2800: change initialization sequence to fix system freeze (2013-09-09 14:44:34 -0400)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth master

for you to fetch changes up to 5bcecf325378218a8e248bb6bcae96ec7362f8ef:

  Bluetooth: btusb: Add support for Belkin F8065bf (2013-09-23 17:44:25 -0300)

----------------------------------------------------------------
Andre Guedes (2):
      Bluetooth: Fix security level for peripheral role
      Bluetooth: Fix encryption key size for peripheral role

Gianluca Anzolin (1):
      Bluetooth: don't release the port in rfcomm_dev_state_change()

Johan Hedberg (2):
      Bluetooth: Introduce a new HCI_RFKILLED flag
      Bluetooth: Fix rfkill functionality during the HCI setup stage

Ken O'Brien (1):
      Bluetooth: btusb: Add support for Belkin F8065bf

Peng Chen (1):
      Bluetooth: Add a new PID/VID 0cf3/e005 for AR3012.

Raphael Kubo da Costa (1):
      Bluetooth: Add support for BCM20702A0 [0b05, 17cb]

Syam Sidhardhan (1):
      Bluetooth: Fix ACL alive for long in case of non pariable devices

 drivers/bluetooth/ath3k.c   |  2 ++
 drivers/bluetooth/btusb.c   |  5 +++++
 include/net/bluetooth/hci.h |  1 +
 net/bluetooth/hci_core.c    | 26 ++++++++++++++++++++------
 net/bluetooth/hci_event.c   |  6 +++++-
 net/bluetooth/l2cap_core.c  |  7 +++++++
 net/bluetooth/rfcomm/tty.c  | 35 ++---------------------------------
 7 files changed, 42 insertions(+), 40 deletions(-)


[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply

* Re: [PATCH] drivers: bluetooth: btusb: Added support for Belkin F8065bf usb bluetooth device
From: Gustavo Padovan @ 2013-09-23 20:45 UTC (permalink / raw)
  To: Ken O'Brien; +Cc: marcel, johan.hedberg, linux-bluetooth, linux-kernel
In-Reply-To: <1379787283-5579-1-git-send-email-kernel@kenobrien.org>

Hi Ken,

2013-09-21 Ken O'Brien <kernel@kenobrien.org>:

> Adding generic rule on encountering Belkin bluetooth usb device F8065bf.
> 
> Relevant section from /sys/kernel/debug/usb/devices:
> 
> T:  Bus=03 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  2 Spd=12   MxCh= 0
> D:  Ver= 2.00 Cls=ff(vend.) Sub=01 Prot=01 MxPS=64 #Cfgs=  1
> P:  Vendor=050d ProdID=065a Rev= 1.12
> S:  Manufacturer=Broadcom Corp
> S:  Product=BCM20702A0
> S:  SerialNumber=0002723E2D29
> C:* #Ifs= 4 Cfg#= 1 Atr=a0 MxPwr=100mA
> I:* If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=01 Prot=01 Driver=btusb
> E:  Ad=81(I) Atr=03(Int.) MxPS=  16 Ivl=1ms
> E:  Ad=82(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
> E:  Ad=02(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms
> I:* If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=01 Prot=01 Driver=btusb
> E:  Ad=83(I) Atr=01(Isoc) MxPS=   0 Ivl=1ms
> E:  Ad=03(O) Atr=01(Isoc) MxPS=   0 Ivl=1ms
> I:  If#= 1 Alt= 1 #EPs= 2 Cls=ff(vend.) Sub=01 Prot=01 Driver=btusb
> E:  Ad=83(I) Atr=01(Isoc) MxPS=   9 Ivl=1ms
> E:  Ad=03(O) Atr=01(Isoc) MxPS=   9 Ivl=1ms
> I:  If#= 1 Alt= 2 #EPs= 2 Cls=ff(vend.) Sub=01 Prot=01 Driver=btusb
> E:  Ad=83(I) Atr=01(Isoc) MxPS=  17 Ivl=1ms
> E:  Ad=03(O) Atr=01(Isoc) MxPS=  17 Ivl=1ms
> I:  If#= 1 Alt= 3 #EPs= 2 Cls=ff(vend.) Sub=01 Prot=01 Driver=btusb
> E:  Ad=83(I) Atr=01(Isoc) MxPS=  25 Ivl=1ms
> E:  Ad=03(O) Atr=01(Isoc) MxPS=  25 Ivl=1ms
> I:  If#= 1 Alt= 4 #EPs= 2 Cls=ff(vend.) Sub=01 Prot=01 Driver=btusb
> E:  Ad=83(I) Atr=01(Isoc) MxPS=  33 Ivl=1ms
> E:  Ad=03(O) Atr=01(Isoc) MxPS=  33 Ivl=1ms
> I:  If#= 1 Alt= 5 #EPs= 2 Cls=ff(vend.) Sub=01 Prot=01 Driver=btusb
> E:  Ad=83(I) Atr=01(Isoc) MxPS=  49 Ivl=1ms
> E:  Ad=03(O) Atr=01(Isoc) MxPS=  49 Ivl=1ms
> I:* If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none)
> E:  Ad=84(I) Atr=02(Bulk) MxPS=  32 Ivl=0ms
> E:  Ad=04(O) Atr=02(Bulk) MxPS=  32 Ivl=0ms
> I:* If#= 3 Alt= 0 #EPs= 0 Cls=fe(app. ) Sub=01 Prot=01 Driver=(none)
> 
> Signed-off-by: Ken O'Brien <kernel@kenobrien.org>
> ---
>  drivers/bluetooth/btusb.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)

Patch has been applied to bluetooth.git. Thanks.

	Gustavo

^ permalink raw reply

* RE: [PATCH v5 2/2] Bluetooth: btmrvl: add calibration data download support
From: Bing Zhao @ 2013-09-23 19:35 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: linux-bluetooth@vger.kernel.org, Gustavo Padovan, Johan Hedberg,
	linux-wireless@vger.kernel.org, Mike Frysinger, Hyuckjoo Lee,
	Amitkumar Karwar
In-Reply-To: <05172D80-CE30-4B7D-A64E-11B8E320EF7F@holtmann.org>

Hi Marcel,

> > +	cmd =3D (struct btmrvl_cmd *)skb->data;
> > +	cmd->ocf_ogf =3D
> > +		cpu_to_le16(hci_opcode_pack(OGF, BT_CMD_LOAD_CONFIG_DATA));
> > +	cmd->length =3D BT_CMD_DATA_SIZE;
> > +	cmd->data[0] =3D 0x00;
> > +	cmd->data[1] =3D 0x00;
> > +	cmd->data[2] =3D 0x00;
> > +	cmd->data[3] =3D BT_CMD_DATA_SIZE - 4;
>=20
> why not use __hci_cmd_sync() here. It is designed to be used from ->setup=
() where it is guaranteed
> that the HCI request lock is held. And it is guaranteed that ->setup() is=
 executed in a workqueue.

The reason of not using __hci_cmd_sync() is that we are sending vendor spec=
ific command here (MRVL_VENDOR_PKT). The __hci_cmd_sync seems handle HCI_CO=
MMAND_PKT only.
Please let us know if you have any suggestion to solve this problem.

Thanks,
Bing

^ permalink raw reply

* Re: [PATCH 1/2] android: Add skeleton of BlueZ Android daemon
From: Lukasz Rymanowski @ 2013-09-23 19:28 UTC (permalink / raw)
  To: Frederic Danis; +Cc: Marcel Holtmann, linux-bluetooth
In-Reply-To: <52400F2B.9010501@linux.intel.com>

Hi Marcel,

On Mon, Sep 23, 2013 at 11:51 AM, Frederic Danis
<frederic.danis@linux.intel.com> wrote:
> Hello Marcel,
>
> On 21/09/2013 19:14, Marcel Holtmann wrote:
>>
>> Hi Fred,
>>
>>> Define local mapping to glib path, otherwise this has to be inside
>>> central
>>> place in the build repository.
>>>
>>> Retrieve Bluetooth version from configure.ac.
>>> ---
>>> .gitignore         |    2 +
>>> Android.mk         |    9 ++++
>>> Makefile.am        |    1 +
>>> Makefile.android   |    7 ++++
>>> android/Android.mk |   24 +++++++++++
>>> android/main.c     |  119
>>> ++++++++++++++++++++++++++++++++++++++++++++++++++++
>>> configure.ac       |    5 +++
>>> 7 files changed, 167 insertions(+)
>>> create mode 100644 Android.mk
>>> create mode 100644 Makefile.android
>>> create mode 100644 android/Android.mk
>>> create mode 100644 android/main.c
>>
>>
>> lets split this out a little bit. Code additions should not be intermixed
>> with additions to the build system and especially configure options.
>>
>> I rather not have a top-level Android.mk. It should be enough to provide
>> an android/Android.mk.

 BTW, do you expect to have only one Android.mk for the whole project or
this is OK for you to have smaller Android.mk in different subfolders like
/src/shared etc. Both ways are valid.

Br
Lukasz

^ permalink raw reply

* Re: [PATCH 1/2] android: Add skeleton of BlueZ Android daemon
From: Lukasz Rymanowski @ 2013-09-23 19:26 UTC (permalink / raw)
  To: Frederic Danis; +Cc: Marcel Holtmann, linux-bluetooth
In-Reply-To: <52400F2B.9010501@linux.intel.com>

[-- Attachment #1: Type: text/plain, Size: 1320 bytes --]

Hi Marcel


On Mon, Sep 23, 2013 at 11:51 AM, Frederic Danis <
frederic.danis@linux.intel.com> wrote:

> Hello Marcel,
>
> On 21/09/2013 19:14, Marcel Holtmann wrote:
>
>> Hi Fred,
>>
>>  Define local mapping to glib path, otherwise this has to be inside
>>> central
>>> place in the build repository.
>>>
>>> Retrieve Bluetooth version from configure.ac.
>>> ---
>>> .gitignore         |    2 +
>>> Android.mk         |    9 ++++
>>> Makefile.am        |    1 +
>>> Makefile.android   |    7 ++++
>>> android/Android.mk |   24 +++++++++++
>>> android/main.c     |  119 ++++++++++++++++++++++++++++++**
>>> ++++++++++++++++++++++
>>> configure.ac       |    5 +++
>>> 7 files changed, 167 insertions(+)
>>> create mode 100644 Android.mk
>>> create mode 100644 Makefile.android
>>> create mode 100644 android/Android.mk
>>> create mode 100644 android/main.c
>>>
>>
>> lets split this out a little bit. Code additions should not be intermixed
>> with additions to the build system and especially configure options.
>>
>> I rather not have a top-level Android.mk. It should be enough to provide
>> an android/Android.mk.
>>
>> BTW, do you expect to have only one Android.mk for the whole project or
this is OK for you to have smaller Android.mk in different subfolders like
/src/shared etc. Both ways are valid.

BR
Lukasz

[-- Attachment #2: Type: text/html, Size: 2206 bytes --]

^ permalink raw reply

* RE: [PATCH v5 1/2] Bluetooth: btmrvl: add setup handler
From: Bing Zhao @ 2013-09-23 19:18 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: linux-bluetooth@vger.kernel.org, Gustavo Padovan, Johan Hedberg,
	linux-wireless@vger.kernel.org, Mike Frysinger, Hyuckjoo Lee,
	Amitkumar Karwar
In-Reply-To: <18678858-E711-43E5-AFE6-E637D1CECFFB@holtmann.org>

Hi Marcel,

> > -	btmrvl_send_module_cfg_cmd(priv, MODULE_BRINGUP_REQ);
> > +	hdev->setup =3D btmrvl_setup;
>=20
> just to make sure you guys understand how ->setup() works. It is only cal=
led once. Bringing the
> adapter down and up again does not call ->setup() a second time. So do yo=
u guys need this setup_done
> variable and if so, then you need to be a bit more verbose and help me un=
derstand why.

It's observed that sometimes the setup handler is called twice when Bluetoo=
th daemon is running in background. We will rebase to latest commit on blue=
tooth-next tree and test again. If the issue is gone with the latest code i=
n -next tree we will remove the setup_done flag.

Thanks,
Bing

^ permalink raw reply


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