* [PATCH 5/7] android/haltest: Improve EXEC macro robustness
From: Szymon Janc @ 2013-12-30 22:43 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1388443421-6295-1-git-send-email-szymon.janc@gmail.com>
Print info about method being NULL instead of crashing.
---
android/client/if-main.h | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/android/client/if-main.h b/android/client/if-main.h
index a83f48b..4a5d4cc 100644
--- a/android/client/if-main.h
+++ b/android/client/if-main.h
@@ -147,8 +147,12 @@ const struct method *get_interface_method(const char *iname,
/* Helper macro for executing function on interface and printing BT_STATUS */
#define EXEC(f, ...) \
{ \
- int err = f(__VA_ARGS__); \
- haltest_info("%s: %s\n", #f, bt_status_t2str(err)); \
+ if (f) { \
+ int err = f(__VA_ARGS__); \
+ haltest_info("%s: %s\n", #f, bt_status_t2str(err)); \
+ } else { \
+ haltest_info("%s is NULL\n", #f); \
+ } \
}
/* Helper macro for executing void function on interface */
--
1.8.5.2
^ permalink raw reply related
* [PATCH 4/7] android/hal-bluetooth: Add debug print to config_hci_snoop_log
From: Szymon Janc @ 2013-12-30 22:43 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1388443421-6295-1-git-send-email-szymon.janc@gmail.com>
Improves debugs and make it consistent with other methods.
---
android/hal-bluetooth.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index a95c4ea..7accdcc 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -829,6 +829,8 @@ static int le_test_mode(uint16_t opcode, uint8_t *buf, uint8_t len)
#if PLATFORM_SDK_VERSION > 18
static int config_hci_snoop_log(uint8_t enable)
{
+ DBG("enable %u", enable);
+
if (enable && property_set("ctl.start", SNOOP_SERVICE_NAME) < 0) {
error("Failed to start service %s", SNOOP_SERVICE_NAME);
return BT_STATUS_FAIL;
--
1.8.5.2
^ permalink raw reply related
* [PATCH 3/7] android: Add support for bluetoothd-snoop service in system-emulator
From: Szymon Janc @ 2013-12-30 22:43 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1388443421-6295-1-git-send-email-szymon.janc@gmail.com>
This allows to test bluetoothd-snoop service on Linux host.
---
android/system-emulator.c | 61 +++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 56 insertions(+), 5 deletions(-)
diff --git a/android/system-emulator.c b/android/system-emulator.c
index 611e46e..2dc9ad8 100644
--- a/android/system-emulator.c
+++ b/android/system-emulator.c
@@ -45,6 +45,7 @@
static char exec_dir[PATH_MAX + 1];
static pid_t daemon_pid = -1;
+static pid_t snoop_pid = -1;
static void ctl_start(void)
{
@@ -81,6 +82,47 @@ static void ctl_start(void)
daemon_pid = pid;
}
+static void snoop_start(void)
+{
+ char prg_name[PATH_MAX + 1];
+ char *prg_argv[3];
+ char *prg_envp[1];
+ pid_t pid;
+
+ snprintf(prg_name, sizeof(prg_name), "%s/%s", exec_dir,
+ "bluetoothd-snoop");
+
+ prg_argv[0] = prg_name;
+ prg_argv[1] = "/tmp/btsnoop_hci.log";
+ prg_argv[2] = NULL;
+
+ prg_envp[0] = NULL;
+
+ printf("Starting %s\n", prg_name);
+
+ pid = fork();
+ if (pid < 0) {
+ perror("Failed to fork new process");
+ return;
+ }
+
+ if (pid == 0) {
+ execve(prg_argv[0], prg_argv, prg_envp);
+ exit(0);
+ }
+
+ printf("New process %d created\n", pid);
+
+ snoop_pid = pid;
+}
+
+static void snoop_stop(void)
+{
+ printf("Stoping %s/%s\n", exec_dir, "bluetoothd-snoop");
+
+ kill(snoop_pid, SIGTERM);
+}
+
static void system_socket_callback(int fd, uint32_t events, void *user_data)
{
char buf[4096];
@@ -97,13 +139,20 @@ static void system_socket_callback(int fd, uint32_t events, void *user_data)
printf("Received %s\n", buf);
- if (strcmp(buf, "ctl.start=bluetoothd"))
- return;
+ if (!strcmp(buf, "ctl.start=bluetoothd")) {
+ if (daemon_pid > 0)
+ return;
- if (daemon_pid > 0)
- return;
+ ctl_start();
+ } else if (!strcmp(buf, "ctl.start=bluetoothd-snoop")) {
+ if (snoop_pid > 0)
+ return;
- ctl_start();
+ snoop_start();
+ } else if (!strcmp(buf, "ctl.stop=bluetoothd-snoop")) {
+ if (snoop_pid > 0)
+ snoop_stop();
+ }
}
static void signal_callback(int signum, void *user_data)
@@ -127,6 +176,8 @@ static void signal_callback(int signum, void *user_data)
if (pid == daemon_pid)
daemon_pid = -1;
+ else if (pid == snoop_pid)
+ snoop_pid = -1;
}
break;
}
--
1.8.5.2
^ permalink raw reply related
* [PATCH 2/7] android/hal-bluetooth: Update snoop service name
From: Szymon Janc @ 2013-12-30 22:43 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1388443421-6295-1-git-send-email-szymon.janc@gmail.com>
Match service name with android snoop binary name. It is more common
to use '-' instead of '_' in the code for binaries name.
---
android/hal-bluetooth.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index 9f9814a..a95c4ea 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -28,7 +28,7 @@
#include "hal-ipc.h"
#include "hal-utils.h"
-#define SNOOP_SERVICE_NAME "bluetoothd_snoop"
+#define SNOOP_SERVICE_NAME "bluetoothd-snoop"
static const bt_callbacks_t *bt_hal_cbacks = NULL;
--
1.8.5.2
^ permalink raw reply related
* [PATCH 1/7] android: Add HCI snooping tool
From: Szymon Janc @ 2013-12-30 22:43 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
This tool is intended to be run as Android service. It supports
writing HCI snoop data in old btsnoop format only. By default traffic
is stored in /sdcard/btsnoop_hci.log file (can be overridded with
option - mainly for testing on Linux host). Only index 0 is sniffed.
---
.gitignore | 1 +
android/Android.mk | 23 +++++
android/Makefile.am | 6 ++
android/bluetoothd-snoop.c | 219 +++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 249 insertions(+)
create mode 100644 android/bluetoothd-snoop.c
diff --git a/.gitignore b/.gitignore
index b97546e..1447c90 100644
--- a/.gitignore
+++ b/.gitignore
@@ -109,3 +109,4 @@ android/system-emulator
android/bluetoothd
android/haltest
android/android-tester
+android/bluetoothd-snoop
diff --git a/android/Android.mk b/android/Android.mk
index 7e29899..1720823 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -253,3 +253,26 @@ LOCAL_MODULE_TAGS := debug
LOCAL_MODULE := l2test
include $(BUILD_EXECUTABLE)
+
+#
+# bluetoothd-snoop
+#
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+ bluetoothd-snoop.c \
+ ../monitor/mainloop.c \
+ ../src/shared/btsnoop.c \
+
+LOCAL_C_INCLUDES := \
+ $(LOCAL_PATH)/.. \
+ $(LOCAL_PATH)/../lib \
+
+LOCAL_CFLAGS := $(BLUEZ_COMMON_CFLAGS)
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE := bluetoothd-snoop
+
+include $(BUILD_EXECUTABLE)
diff --git a/android/Makefile.am b/android/Makefile.am
index dec81ce..36210b9 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -4,6 +4,12 @@ noinst_PROGRAMS += android/system-emulator
android_system_emulator_SOURCES = android/system-emulator.c \
monitor/mainloop.h monitor/mainloop.c
+noinst_PROGRAMS += android/bluetoothd-snoop
+
+android_bluetoothd_snoop_SOURCES = android/bluetoothd-snoop.c \
+ monitor/mainloop.h monitor/mainloop.c \
+ src/shared/btsnoop.h src/shared/btsnoop.c
+
noinst_PROGRAMS += android/bluetoothd
android_bluetoothd_SOURCES = android/main.c \
diff --git a/android/bluetoothd-snoop.c b/android/bluetoothd-snoop.c
new file mode 100644
index 0000000..02f44e9
--- /dev/null
+++ b/android/bluetoothd-snoop.c
@@ -0,0 +1,219 @@
+/*
+ *
+ * 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 <stdio.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "lib/bluetooth.h"
+#include "lib/hci.h"
+#include "lib/mgmt.h"
+
+#include "monitor/mainloop.h"
+#include "src/shared/btsnoop.h"
+
+#define DEAULT_SNOOP_FILE "/sdcard/btsnoop_hci.log"
+
+#define MAX_PACKET_SIZE (1486 + 4)
+
+static struct btsnoop *snoop = NULL;
+static uint8_t monitor_buf[MAX_PACKET_SIZE];
+static int monitor_fd = -1;
+
+static void signal_callback(int signum, void *user_data)
+{
+ switch (signum) {
+ case SIGINT:
+ case SIGTERM:
+ mainloop_quit();
+ break;
+ }
+}
+
+static uint32_t get_flags_from_opcode(uint16_t opcode)
+{
+ switch (opcode) {
+ case BTSNOOP_OPCODE_NEW_INDEX:
+ case BTSNOOP_OPCODE_DEL_INDEX:
+ break;
+ case BTSNOOP_OPCODE_COMMAND_PKT:
+ return 0x02;
+ case BTSNOOP_OPCODE_EVENT_PKT:
+ return 0x03;
+ case BTSNOOP_OPCODE_ACL_TX_PKT:
+ return 0x00;
+ case BTSNOOP_OPCODE_ACL_RX_PKT:
+ return 0x01;
+ case BTSNOOP_OPCODE_SCO_TX_PKT:
+ case BTSNOOP_OPCODE_SCO_RX_PKT:
+ break;
+ }
+
+ return 0xff;
+}
+
+static void data_callback(int fd, uint32_t events, void *user_data)
+{
+ unsigned char control[32];
+ struct mgmt_hdr hdr;
+ struct msghdr msg;
+ struct iovec iov[2];
+
+ if (events & (EPOLLERR | EPOLLHUP)) {
+ mainloop_remove_fd(monitor_fd);
+ return;
+ }
+
+ iov[0].iov_base = &hdr;
+ iov[0].iov_len = MGMT_HDR_SIZE;
+ iov[1].iov_base = monitor_buf;
+ iov[1].iov_len = sizeof(monitor_buf);
+
+ memset(&msg, 0, sizeof(msg));
+ msg.msg_iov = iov;
+ msg.msg_iovlen = 2;
+ msg.msg_control = control;
+ msg.msg_controllen = sizeof(control);
+
+ while (true) {
+ struct cmsghdr *cmsg;
+ struct timeval *tv = NULL;
+ struct timeval ctv;
+ uint16_t opcode, index, pktlen;
+ uint32_t flags;
+ ssize_t len;
+
+ len = recvmsg(monitor_fd, &msg, MSG_DONTWAIT);
+ if (len < 0)
+ break;
+
+ if (len < MGMT_HDR_SIZE)
+ break;
+
+ for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL;
+ cmsg = CMSG_NXTHDR(&msg, cmsg)) {
+ if (cmsg->cmsg_level != SOL_SOCKET)
+ continue;
+
+ if (cmsg->cmsg_type == SCM_TIMESTAMP) {
+ memcpy(&ctv, CMSG_DATA(cmsg), sizeof(ctv));
+ tv = &ctv;
+ }
+ }
+
+ opcode = btohs(hdr.opcode);
+ index = btohs(hdr.index);
+ pktlen = btohs(hdr.len);
+
+ if (index)
+ continue;
+
+ flags = get_flags_from_opcode(opcode);
+ if (flags != 0xff)
+ btsnoop_write(snoop, tv, flags, monitor_buf, pktlen);
+ }
+}
+
+static int open_monitor(const char *path)
+{
+ struct sockaddr_hci addr;
+ int opt = 1;
+
+ snoop = btsnoop_create(path, BTSNOOP_TYPE_HCI);
+ if (!snoop)
+ return -1;
+
+ monitor_fd = socket(AF_BLUETOOTH, SOCK_RAW | SOCK_CLOEXEC, BTPROTO_HCI);
+ if (monitor_fd < 0)
+ goto failed;
+
+ memset(&addr, 0, sizeof(addr));
+ addr.hci_family = AF_BLUETOOTH;
+ addr.hci_dev = HCI_DEV_NONE;
+ addr.hci_channel = HCI_CHANNEL_MONITOR;
+
+ if (bind(monitor_fd, (struct sockaddr *) &addr, sizeof(addr)) < 0)
+ goto failed_close;
+
+ if (setsockopt(monitor_fd, SOL_SOCKET, SO_TIMESTAMP, &opt, sizeof(opt))
+ < 0)
+ goto failed_close;
+
+ mainloop_add_fd(monitor_fd, EPOLLIN, data_callback, NULL, NULL);
+
+ return 0;
+
+failed_close:
+ close(monitor_fd);
+ monitor_fd = -1;
+
+failed:
+ btsnoop_unref(snoop);
+ snoop = NULL;
+
+ return -1;
+}
+
+static void close_monitor(void)
+{
+ btsnoop_unref(snoop);
+ snoop = NULL;
+
+ close(monitor_fd);
+ monitor_fd = -1;
+}
+
+int main(int argc, char *argv[])
+{
+ const char *path;
+ sigset_t mask;
+
+ if (argc > 1)
+ path = argv[1];
+ else
+ path = DEAULT_SNOOP_FILE;
+
+ mainloop_init();
+
+ sigemptyset(&mask);
+ sigaddset(&mask, SIGINT);
+ sigaddset(&mask, SIGTERM);
+
+ mainloop_set_signal(&mask, signal_callback, NULL, NULL);
+
+ if (open_monitor(path) < 0) {
+ printf("Failed to start bluetoothd_snoop\n");
+ return EXIT_FAILURE;
+ }
+
+ mainloop_run();
+
+ close_monitor();
+
+ return EXIT_SUCCESS;
+}
--
1.8.5.2
^ permalink raw reply related
* Re: [PATCH v2] Bluetooth: Add hci_h4p driver
From: Pavel Machek @ 2013-12-30 22:28 UTC (permalink / raw)
To: Marcel Holtmann
Cc: Pali Rohár,
Ивайло Димитров,
Gustavo F. Padovan, Johan Hedberg, linux-kernel,
linux-bluetooth@vger.kernel.org development, Ville Tervo,
Sebastian Reichel
In-Reply-To: <C8D1F470-7964-4EAC-82E0-D53CF54DE086@holtmann.org>
Hi!
> > +++ b/drivers/bluetooth/hci_h4p/core.c
> > @@ -0,0 +1,1357 @@
> > +/*
> > + * This file is part of hci_h4p bluetooth driver
> > + *
> > + * Copyright (C) 2005-2008 Nokia Corporation.
> > + *
> > + * Contact: Ville Tervo <ville.tervo@nokia.com>
>
> I think you can just remove the contact names since I think nobody of the original authors is still working at Nokia and I bet this emails addresses just do not work anymore.
>
What about this?
commit 3f18ca6cd02a13baf4be9beb89b1470ad1ce008c
Author: Pavel <pavel@ucw.cz>
Date: Mon Dec 30 23:27:21 2013 +0100
Update comments, remove no longer relevant contacts.
Signed-off-by: Pavel Machek <pavel@ucw.cz>
diff --git a/drivers/bluetooth/nokia_core.c b/drivers/bluetooth/nokia_core.c
index a91bd7b..6dbd3b7 100644
--- a/drivers/bluetooth/nokia_core.c
+++ b/drivers/bluetooth/nokia_core.c
@@ -1,10 +1,8 @@
/*
- * This file is part of hci_h4p bluetooth driver
+ * This file is part of Nokia H4P bluetooth driver
*
* Copyright (C) 2005-2008 Nokia Corporation.
*
- * Contact: Ville Tervo <ville.tervo@nokia.com>
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
@@ -19,6 +17,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
+ * Thanks to all the Nokia people that helped with this driver,
+ * including Ville Tervo and Roger Quadros.
*/
#include <linux/module.h>
diff --git a/drivers/bluetooth/nokia_fw-bcm.c b/drivers/bluetooth/nokia_fw-bcm.c
index 390d021..9c01a6a 100644
--- a/drivers/bluetooth/nokia_fw-bcm.c
+++ b/drivers/bluetooth/nokia_fw-bcm.c
@@ -1,10 +1,8 @@
/*
- * This file is part of hci_h4p bluetooth driver
+ * This file is part of Nokia H4P bluetooth driver
*
* Copyright (C) 2005-2008 Nokia Corporation.
*
- * Contact: Ville Tervo <ville.tervo@nokia.com>
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
diff --git a/drivers/bluetooth/nokia_fw-csr.c b/drivers/bluetooth/nokia_fw-csr.c
index af880d9..23c5fc5 100644
--- a/drivers/bluetooth/nokia_fw-csr.c
+++ b/drivers/bluetooth/nokia_fw-csr.c
@@ -1,10 +1,8 @@
/*
- * This file is part of hci_h4p bluetooth driver
+ * This file is part of Nokia H4P bluetooth driver
*
* Copyright (C) 2005-2008 Nokia Corporation.
*
- * Contact: Ville Tervo <ville.tervo@nokia.com>
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
diff --git a/drivers/bluetooth/nokia_fw-ti1273.c b/drivers/bluetooth/nokia_fw-ti1273.c
index 32e5fa0..2825504 100644
--- a/drivers/bluetooth/nokia_fw-ti1273.c
+++ b/drivers/bluetooth/nokia_fw-ti1273.c
@@ -1,10 +1,8 @@
/*
- * This file is part of hci_h4p bluetooth driver
+ * This file is part of Nokia H4P bluetooth driver
*
* Copyright (C) 2009 Nokia Corporation.
*
- * Contact: Ville Tervo <ville.tervo@nokia.com>
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
diff --git a/drivers/bluetooth/nokia_uart.c b/drivers/bluetooth/nokia_uart.c
index 8e0a93c..fd94a98 100644
--- a/drivers/bluetooth/nokia_uart.c
+++ b/drivers/bluetooth/nokia_uart.c
@@ -1,10 +1,8 @@
/*
- * This file is part of hci_h4p bluetooth driver
+ * This file is part of Nokia H4P bluetooth driver
*
* Copyright (C) 2005, 2006 Nokia Corporation.
*
- * Contact: Ville Tervo <ville.tervo@nokia.com>
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
diff --git a/include/linux/bluetooth/hci_h4p.h b/include/linux/bluetooth/hci_h4p.h
index daf83fc..30d169d 100644
--- a/include/linux/bluetooth/hci_h4p.h
+++ b/include/linux/bluetooth/hci_h4p.h
@@ -1,10 +1,8 @@
/*
- * This file is part of hci_h4p bluetooth driver
+ * This file is part of Nokia H4P bluetooth driver
*
* Copyright (C) 2010 Nokia Corporation.
*
- * Contact: Roger Quadros <roger.quadros@nokia.com>
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
^ permalink raw reply related
* [PATCH] wilink: mention name of module in help text
From: Pavel Machek @ 2013-12-30 22:19 UTC (permalink / raw)
To: Marcel Holtmann, trivial
Cc: Pali Rohár,
Ивайло Димитров,
Gustavo F. Padovan, Johan Hedberg, linux-kernel,
linux-bluetooth@vger.kernel.org development, Ville Tervo,
Sebastian Reichel
In-Reply-To: <C8D1F470-7964-4EAC-82E0-D53CF54DE086@holtmann.org>
Mention module name in Kconfig.
Signed-off-by: Pavel Machek <pavel@ucw.cz>
diff --git a/drivers/bluetooth/Kconfig b/drivers/bluetooth/Kconfig
index 9d46f23..a53e8c7 100644
--- a/drivers/bluetooth/Kconfig
+++ b/drivers/bluetooth/Kconfig
@@ -241,7 +241,7 @@ config BT_WILINK
core driver to communicate with the BT core of the combo chip.
Say Y here to compile support for Texas Instrument's WiLink7 driver
- into the kernel or say M to compile it as module.
+ into the kernel or say M to compile it as module (btwilink).
config BT_NOKIA_H4P
tristate "HCI driver with H4 Nokia extensions"
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
^ permalink raw reply related
* Re: [PATCH v2] Bluetooth: Add hci_h4p driver
From: Pavel Machek @ 2013-12-30 22:18 UTC (permalink / raw)
To: Marcel Holtmann
Cc: Pali Rohár,
Ивайло Димитров,
Gustavo F. Padovan, Johan Hedberg, linux-kernel,
linux-bluetooth@vger.kernel.org development, Ville Tervo,
Sebastian Reichel
In-Reply-To: <C8D1F470-7964-4EAC-82E0-D53CF54DE086@holtmann.org>
Hi!
> > +config BT_HCIH4P
> > + tristate "HCI driver with H4 Nokia extensions"
> > + depends on BT && ARCH_OMAP
>
> Since then we moved away from doing hci_* prefix of drivers since that is misleading. See btusb.ko, btmrvl_sdio.ko etc.
>
> So this might be better named BT_NOK_H4P or BT_NOKIA_H4P and the module named btnok_h4p.ko or btnokia_h4p.ko.
>
Pali, please apply :-).
Pavel
commit b724166911dcdae2c43170ce4040427c00e834e3
Author: Pavel <pavel@ucw.cz>
Date: Mon Dec 30 23:16:25 2013 +0100
Rename nokia h4p driver object to btnokia_h4p.ko.
Signed-off-by: Pavel Machek <pavel@ucw.cz>
diff --git a/drivers/bluetooth/Kconfig b/drivers/bluetooth/Kconfig
index 9d46f23..a53e8c7 100644
--- a/drivers/bluetooth/Kconfig
+++ b/drivers/bluetooth/Kconfig
@@ -251,5 +251,5 @@ config BT_NOKIA_H4P
support for H4+ Bluetooth chip with vendor-specific H4 extensions.
Say Y here to compile support for h4 extended devices into the kernel
- or say M to compile it as module (hci_h4p).
+ or say M to compile it as module (btnokia_h4p).
endmenu
diff --git a/drivers/bluetooth/Makefile b/drivers/bluetooth/Makefile
index c286dbe..a5ed271 100644
--- a/drivers/bluetooth/Makefile
+++ b/drivers/bluetooth/Makefile
@@ -31,7 +31,7 @@ hci_uart-$(CONFIG_BT_HCIUART_ATH3K) += hci_ath.o
hci_uart-$(CONFIG_BT_HCIUART_3WIRE) += hci_h5.o
hci_uart-objs := $(hci_uart-y)
-obj-$(CONFIG_BT_NOKIA_H4P) += hci_h4p.o
-hci_h4p-objs := nokia_core.o nokia_fw.o nokia_uart.o nokia_fw-csr.o \
+obj-$(CONFIG_BT_NOKIA_H4P) += btnokia_h4p.o
+btnokia_h4p-objs := nokia_core.o nokia_fw.o nokia_uart.o nokia_fw-csr.o \
nokia_fw-bcm.o nokia_fw-ti1273.o
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
^ permalink raw reply related
* PATCH hid2hci for CSR 8510 A10
From: Gordon @ 2013-12-30 21:59 UTC (permalink / raw)
To: linux-bluetooth
[-- Attachment #1: Type: text/plain, Size: 551 bytes --]
Hi,
ich had a problem with the Sitecom CNT-524 as described by someone else
here:
http://blog.ruecker.fi/2013/10/06/adventures-in-bluetooth-4-0-part-i/
so i tried to fix that by introducing --mode csr2 for hid2hci
I neither know how to switch back to hid nor how to detect the EALREADY
state, otherwise the patch is very small.
I works on my machine in ubuntu 13.04 with bluez 4.101-0ubuntu8b1 and
said sitecom usb dongle. the patch is against bluez commit
fd00064e0bb2c81e53e9d0b7d22ce919b41dbe60
Could someone please review.
Cheers,
Gordon
[-- Attachment #2: bluez_hid2hci.patch --]
[-- Type: text/x-patch, Size: 2471 bytes --]
diff --git a/tools/hid2hci.1 b/tools/hid2hci.1
index 8c5d520..c6876a3 100644
--- a/tools/hid2hci.1
+++ b/tools/hid2hci.1
@@ -32,7 +32,7 @@ mode and back.
.B --mode= [hid, hci]
Sets the mode to switch the device into
.TP
-.B --method= [csr, logitech-hid, dell]
+.B --method= [csr, csr2, logitech-hid, dell]
Which vendor method to use for switching the device.
.TP
.B --devpath=
diff --git a/tools/hid2hci.c b/tools/hid2hci.c
index 95b4abf..514accc 100644
--- a/tools/hid2hci.c
+++ b/tools/hid2hci.c
@@ -118,6 +118,41 @@ static int usb_switch_csr(int fd, enum mode mode)
return err;
}
+static int usb_switch_csr2(int fd, enum mode mode)
+{
+ int err = 0;
+ struct usbfs_disconnect disconnect;
+ char report[] = { 0x1 , 0x5 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 };
+ switch (mode) {
+ case HCI:
+ //send report as is
+ disconnect.interface = 0;
+ disconnect.flags = USBFS_DISCONNECT_EXCEPT_DRIVER;
+ strcpy(disconnect.driver, "usbfs");
+
+ if (ioctl(fd, USBFS_IOCTL_DISCONNECT, &disconnect) < 0) {
+ fprintf(stderr, "Can't claim interface: %s (%d)\n",
+ strerror(errno), errno);
+ return -1;
+ }
+
+ err = control_message(fd, USB_ENDPOINT_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
+ USB_REQ_SET_CONFIGURATION, //Set_Report Request
+ 0x01 | (0x03 << 8), //report id: 0x01, report type: feature (0x03)
+ 0, //interface
+ report, sizeof(report), 5000);
+ //unable to detect EALREADY
+ break;
+ case HID:
+ // currently unknown what to do here
+ fprintf(stderr, "csr2: Switching to hid mode is not implemented\n");
+ return -1;
+ break;
+ }
+
+ return err;
+}
+
static int hid_logitech_send_report(int fd, const char *buf, size_t size)
{
struct hiddev_report_info rinfo;
@@ -257,7 +292,7 @@ static void usage(const char *error)
printf("Usage: hid2hci [options]\n"
" --mode= mode to switch to [hid|hci] (default hci)\n"
" --devpath= sys device path\n"
- " --method= method to use to switch [csr|logitech-hid|dell]\n"
+ " --method= method to use to switch [csr|csr2|logitech-hid|dell]\n"
" --help\n\n");
}
@@ -310,6 +345,9 @@ int main(int argc, char *argv[])
if (!strcmp(optarg, "csr")) {
method = METHOD_CSR;
usb_switch = usb_switch_csr;
+ } else if (!strcmp(optarg, "csr2")) {
+ method = METHOD_CSR;
+ usb_switch = usb_switch_csr2;
} else if (!strcmp(optarg, "logitech-hid")) {
method = METHOD_LOGITECH_HID;
} else if (!strcmp(optarg, "dell")) {
^ permalink raw reply related
* Re: [RFC 6/6] android/audio: Add listener thread on the Audio HAL socket
From: Lukasz Rymanowski @ 2013-12-30 20:57 UTC (permalink / raw)
To: Luiz Augusto von Dentz
Cc: Lukasz Rymanowski, linux-bluetooth@vger.kernel.org, Johan Hedberg
In-Reply-To: <CABBYNZK-c_AD2ZkxGs0XE4SkNwGnVxNByv-c-erV9DFJ9mry_w@mail.gmail.com>
Hi Luiz,
On Mon, Dec 30, 2013 at 2:07 PM, Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
> Hi Lukasz,
>
> On Mon, Dec 30, 2013 at 1:40 PM, Lukasz Rymanowski
> <lukasz.rymanowski@tieto.com> wrote:
>> Hi Luiz,
>>
>> On 30 December 2013 12:31, Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote:
>>> Hi Lukasz,
>>>
>>> On Mon, Dec 30, 2013 at 12:17 PM, Lukasz Rymanowski
>>> <lukasz.rymanowski@tieto.com> wrote:
>>>> This patch add thread which is reponsible for listen on audio HAL
>>>> socket, register a2dp endpoint(s) and maintain socket.
>>>> When bluetooth daemon goes down, HAL audio plugin starts to listen on Audio HAL
>>>> socket again.
>>>>
>>>> ---
>>>> android/Makefile.am | 2 +
>>>> android/hal-audio.c | 145 ++++++++++++++++++++++++++++++++++++++++++++++++++++
>>>> android/hal-audio.h | 18 +++++++
>>>> 3 files changed, 165 insertions(+)
>>>> create mode 100644 android/hal-audio.h
>>>>
>>>> diff --git a/android/Makefile.am b/android/Makefile.am
>>>> index eaf39bd..bd90c13 100644
>>>> --- a/android/Makefile.am
>>>> +++ b/android/Makefile.am
>>>> @@ -112,6 +112,8 @@ android_libaudio_internal_la_SOURCES = android/hal-audio.c \
>>>>
>>>> android_libaudio_internal_la_CFLAGS = -I$(srcdir)/android
>>>>
>>>> +android_libaudio_internal_la_LDFLAGS = -pthread
>>>> +
>>>> endif
>>>>
>>>> EXTRA_DIST += android/Android.mk android/hal-ipc-api.txt android/README \
>>>> diff --git a/android/hal-audio.c b/android/hal-audio.c
>>>> index 011a699..0e3bc70 100644
>>>> --- a/android/hal-audio.c
>>>> +++ b/android/hal-audio.c
>>>> @@ -16,18 +16,30 @@
>>>> */
>>>>
>>>> #include <errno.h>
>>>> +#include <pthread.h>
>>>> +#include <poll.h>
>>>> #include <stdio.h>
>>>> #include <stdlib.h>
>>>> #include <string.h>
>>>> +#include <sys/socket.h>
>>>> +#include <sys/un.h>
>>>> +#include <unistd.h>
>>>>
>>>> #include <hardware/audio.h>
>>>> #include <hardware/hardware.h>
>>>>
>>>> +#include "hal-audio.h"
>>>> #include "hal-log.h"
>>>>
>>>> struct a2dp_audio_dev {
>>>> struct audio_hw_device dev;
>>>> struct a2dp_stream_out *stream_out;
>>>> +
>>>> + pthread_t bt_watcher;
>>>> + pthread_mutex_t hal_sk_mutex;
>>>> + pthread_cond_t bt_watcher_cond;
>>>> +
>>>> + int hal_sk;
>>>> };
>>>>
>>>> struct a2dp_stream_out {
>>>> @@ -384,15 +396,135 @@ static int audio_dump(const audio_hw_device_t *device, int fd)
>>>>
>>>> static int audio_close(hw_device_t *device)
>>>> {
>>>> + struct audio_hw_device *dev = (struct audio_hw_device *)device;
>>>> + struct a2dp_audio_dev *a2dp_dev = (struct a2dp_audio_dev *)dev;
>>>> +
>
> Hmm, Im afraid these are not the same pointers as you do *device =
> &a2dp_dev->dev.common; so this will probably cause invalid accesses.
>
Actually this is same pointer and even I could do here direct cast
from hw_device_t to a2dp_audio_dev with some comment why I can do it.
Is that fine?
Also in audio_open(), to make code less confusing, will do *device =
(hw_device_t *)a2dp_dev
Is that fine for you? Not sure how discussion ends or IRC about that
as I had to go.
>>>> DBG("");
>>>> +
>>>> + if (a2dp_dev) {
>>>> + /* TODO: We could try to unregister Endpoint here */
>>>> + shutdown(a2dp_dev->hal_sk, 2);
>>>> +
>>>> + pthread_mutex_lock(&a2dp_dev->hal_sk_mutex);
>>>> + pthread_cond_signal(&a2dp_dev->bt_watcher_cond);
>>>> + pthread_mutex_unlock(&a2dp_dev->hal_sk_mutex);
>>>> +
>>>> + (void) pthread_join(a2dp_dev->bt_watcher, NULL);
>>>> + free(a2dp_dev);
>>>> + }
>>>> +
>>>> free(device);
>>>> return 0;
>>>> }
>>>>
>>>> +static int wait_for_client(void)
>>>> +{
>>>> + struct sockaddr_un addr;
>>>> + int err;
>>>> + int sk;
>>>> + int new_sk;
>>>> +
>>>> + DBG("");
>>>> +
>>>> + sk = socket(PF_LOCAL, SOCK_SEQPACKET, 0);
>>>> + if (sk < 0) {
>>>> + err = errno;
>>>> + error("Failed to create socket: %d (%s)", err, strerror(err));
>>>> + return -1;
>>>> + }
>>>> +
>>>> + memset(&addr, 0, sizeof(addr));
>>>> + addr.sun_family = AF_UNIX;
>>>> +
>>>> + memcpy(addr.sun_path, BLUEZ_AUDIO_HAL_SK_PATH,
>>>> + sizeof(BLUEZ_AUDIO_HAL_SK_PATH));
>>>> +
>>>> + if (bind(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
>>>> + err = errno;
>>>> + error("Failed to bind socket: %d (%s)", err, strerror(err));
>>>> + goto error;
>>>> + }
>>>> +
>>>> + if (listen(sk, 1) < 0) {
>>>> + err = errno;
>>>> + error("Failed to bind socket: %d (%s)", err, strerror(err));
>>>> + goto error;
>>>> + }
>>>> +
>>>> + new_sk = accept(sk, NULL, NULL);
>>>> + if (new_sk < 0) {
>>>> + err = errno;
>>>> + error("Failed to accept socket: %d (%s)", err, strerror(err));
>>>> + goto error;
>>>> + }
>>>> +
>>>> + close(sk);
>>>> + return new_sk;
>>>> +
>>>> +error:
>>>> + close(sk);
>>>> + return -1;
>>>> +}
>>>> +
>>>> +static void *bluetoothd_watcher(void *data)
>>>> +{
>>>> + int err;
>>>> + struct a2dp_audio_dev *a2dp_dev = (struct a2dp_audio_dev *)data;
>>>> + struct pollfd pfd;
>>>> + struct timeval now;
>>>> + struct timespec timeout;
>>>> +
>>>> + DBG("");
>>>> +
>>>> + while (1) {
>>>> + a2dp_dev->hal_sk = wait_for_client();
>>>> + if (a2dp_dev->hal_sk < 0) {
>>>> + error("Failed to create listening socket");
>>>> + continue;
>>>> + }
>>>> +
>>>> + DBG("Audio IPC: Connected");
>>>> +
>>>> + /* TODO: Register ENDPOINT here */
>>>> +
>>>> + memset(&pfd, 0, sizeof(pfd));
>>>> + pfd.fd = a2dp_dev->hal_sk;
>>>> + pfd.events = POLLHUP | POLLERR | POLLNVAL;
>>>> +
>>>> + pthread_mutex_lock(&a2dp_dev->hal_sk_mutex);
>>>> +
>>>> + /* Check if socket is still alive */
>>>> + err = poll(&pfd, 1, -1);
>>>> + if (pfd.revents & (POLLHUP | POLLERR | POLLNVAL)) {
>>>> + info("Audio HAL: Socket closed");
>>>> + a2dp_dev->hal_sk = -1;
>>>> + }
>>>> +
>>>> + /* Maybe audio system is closing and audio_close() has been called? */
>>>> + gettimeofday(&now, NULL);
>>>> + timeout.tv_sec = now.tv_sec;
>>>> + timeout.tv_nsec = now.tv_usec * 1000;
>>>> + timeout.tv_sec += 1;
>>>> +
>>>> + err = pthread_cond_timedwait(&a2dp_dev->bt_watcher_cond,
>>>> + &a2dp_dev->hal_sk_mutex, &timeout);
>>>> +
>>>> + pthread_mutex_unlock(&a2dp_dev->hal_sk_mutex);
>>>> + if (err != ETIMEDOUT)
>>>> + /* Seems that device has been closed */
>>>> + break;
>>>> + }
>>>> +
>>>> + info("Closing bluetooth_watcher thread");
>>>> + pthread_exit(NULL);
>>>> + return NULL;
>>>> +}
>>>> +
>>>> static int audio_open(const hw_module_t *module, const char *name,
>>>> hw_device_t **device)
>>>> {
>>>> struct a2dp_audio_dev *a2dp_dev;
>>>> + int err;
>>>>
>>>> DBG("");
>>>>
>>>> @@ -427,6 +559,19 @@ static int audio_open(const hw_module_t *module, const char *name,
>>>>
>>>> *device = &a2dp_dev->dev.common;
>>>>
>>>> + a2dp_dev->hal_sk = -1;
>>>> +
>>>> + pthread_mutex_init(&a2dp_dev->hal_sk_mutex, NULL);
>>>> + pthread_cond_init(&a2dp_dev->bt_watcher_cond, NULL);
>>>> +
>>>> + err = pthread_create(&a2dp_dev->bt_watcher, NULL, bluetoothd_watcher, a2dp_dev);
>>>> + if (err < 0) {
>>>> + a2dp_dev->bt_watcher = 0;
>>>> + error("Failed to start bluetoothd watcher thread: %d (%s)", -err,
>>>> + strerror(-err));
>>>> + return (-err);
>>>> + }
>>>> +
>>>> return 0;
>>>> }
>>>>
>>>> diff --git a/android/hal-audio.h b/android/hal-audio.h
>>>> new file mode 100644
>>>> index 0000000..93e49f6
>>>> --- /dev/null
>>>> +++ b/android/hal-audio.h
>>>> @@ -0,0 +1,18 @@
>>>> +/*
>>>> + *
>>>> + * 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.
>>>> + *
>>>> + */
>>>> +static const char BLUEZ_AUDIO_HAL_SK_PATH[] = "\0bluez_audio_socket";
>>>> --
>>>> 1.8.4
>>>
>>> Ive started working on the daemon side and should be able to post some
>>> patches today, Im not really sure we are going to need a thread for
>>> command handling since all the commands will be sent by the plugin
>>> side so they can be synchronous, the only problem would be if the
>>> plugin cannot really block even for a short period.
>>>
>>
>> This Thread is only going to be used for accept, endpoint register and
>> then listening for socket close (so we can start listen for connection
>> from new bluetoothd).
>>
>> Commands and response will be handled in main thread (ex.
>> audio_open(), out_write()) and we can block there for a while - no
>> problem with that
>
> Well it seems the init/listen stage needs to be non-blocking so we
> don't interrupt the audio init procedure which may block bluetooth HAL
> to initialized, the endpoint then should be registered whenever
> bluetoothd connects.
>
>
\Łukasz
> --
> Luiz Augusto von Dentz
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [RFC BlueZ 9/9] android: Add hal_audio_ipc_init and hal_audio_ipc_cleanup
From: Lukasz Rymanowski @ 2013-12-30 20:50 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1388406855-8809-9-git-send-email-luiz.dentz@gmail.com>
Hi Luiz,
On Mon, Dec 30, 2013 at 1:34 PM, Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> These function initialize the audio IPC in the HAL side.
> ---
> android/hal-audio.c | 9 +++++++++
> android/hal-ipc.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> android/hal-ipc.h | 3 +++
> 3 files changed, 68 insertions(+)
>
> diff --git a/android/hal-audio.c b/android/hal-audio.c
> index 7f4a3f2..2e7dcca 100644
> --- a/android/hal-audio.c
> +++ b/android/hal-audio.c
> @@ -24,6 +24,7 @@
> #include <hardware/hardware.h>
>
> #include "hal-log.h"
> +#include "hal-ipc.h"
>
> static ssize_t out_write(struct audio_stream_out *stream, const void *buffer,
> size_t bytes)
> @@ -374,6 +375,9 @@ static int audio_dump(const audio_hw_device_t *device, int fd)
> static int audio_close(hw_device_t *device)
> {
> DBG("");
> +
> + hal_audio_ipc_cleanup();
> +
> free(device);
> return 0;
> }
> @@ -391,6 +395,11 @@ static int audio_open(const hw_module_t *module, const char *name,
> return -EINVAL;
> }
>
> + if (!hal_audio_ipc_init()) {
> + error("Unable to initialize audio IPC");
> + return -ENOTCONN;
> + }
> +
> audio = calloc(1, sizeof(struct audio_hw_device));
> if (!audio)
> return -ENOMEM;
> diff --git a/android/hal-ipc.c b/android/hal-ipc.c
> index b19704a..3a1fcc7 100644
> --- a/android/hal-ipc.c
> +++ b/android/hal-ipc.c
> @@ -38,6 +38,7 @@
>
> static int cmd_sk = -1;
> static int notif_sk = -1;
> +static int audio_sk = -1;
>
> static pthread_mutex_t cmd_sk_mutex = PTHREAD_MUTEX_INITIALIZER;
>
> @@ -449,3 +450,58 @@ int hal_ipc_cmd(uint8_t service_id, uint8_t opcode, uint16_t len, void *param,
>
> return BT_STATUS_SUCCESS;
> }
> +
> +bool hal_audio_ipc_init(void)
> +{
> + struct sockaddr_un addr;
> + int sk;
> + int err;
> +
> + sk = socket(AF_LOCAL, SOCK_SEQPACKET, 0);
> + if (sk < 0) {
> + err = errno;
> + error("Failed to create socket: %d (%s)", err,
> + strerror(err));
> + return false;
> + }
> +
> + memset(&addr, 0, sizeof(addr));
> + addr.sun_family = AF_UNIX;
> +
> + memcpy(addr.sun_path, BLUEZ_AUDIO_SK_PATH, sizeof(BLUEZ_AUDIO_SK_PATH));
> +
> + if (bind(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
> + err = errno;
> + error("Failed to bind socket: %d (%s)", err, strerror(err));
> + close(sk);
> + return false;
> + }
> +
> + if (listen(sk, 2) < 0) {
Backlog = 1 should be enough here.
> + err = errno;
> + error("Failed to listen on socket: %d (%s)", err,
> + strerror(err));
> + close(sk);
> + return false;
> + }
> +
> + audio_sk = accept_connection(sk);
We can not block audio_open(), so as we discussed on IRC and as I
proposed in my patches, we need to call hal_audio_ipc_init in thread.
> + if (audio_sk < 0) {
> + close(sk);
> + return false;
> + }
> +
> + info("audio connected");
> +
> + close(sk);
> +
> + return true;
> +}
> +
> +void hal_audio_ipc_cleanup(void)
> +{
> + close(audio_sk);
> + audio_sk = -1;
> +
> + shutdown(audio_sk, SHUT_RD);
> +}
> diff --git a/android/hal-ipc.h b/android/hal-ipc.h
> index 2fbf30f..bd1682d 100644
> --- a/android/hal-ipc.h
> +++ b/android/hal-ipc.h
> @@ -30,3 +30,6 @@ int hal_ipc_cmd(uint8_t service_id, uint8_t opcode, uint16_t len, void *param,
> void hal_ipc_register(uint8_t service, const struct hal_ipc_handler *handlers,
> uint8_t size);
> void hal_ipc_unregister(uint8_t service);
> +
> +bool hal_audio_ipc_init(void);
> +void hal_audio_ipc_cleanup(void);
> --
> 1.8.4.2
>
\Lukasz
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [PATCH 1/5] android/tester: Add BDADDR set prop fail test case
From: Szymon Janc @ 2013-12-30 15:30 UTC (permalink / raw)
To: Grzegorz Kolodziejczyk; +Cc: linux-bluetooth
In-Reply-To: <1388413509-31265-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>
Hi Grzegorz,
On Monday 30 December 2013 15:25:05 Grzegorz Kolodziejczyk wrote:
> This adds BDADDR set property fail test case due to only get
> possibility.
> ---
> android/android-tester.c | 29 +++++++++++++++++++++++++++++
> 1 file changed, 29 insertions(+)
>
> diff --git a/android/android-tester.c b/android/android-tester.c
> index ee23fff..d7ebc02 100644
> --- a/android/android-tester.c
> +++ b/android/android-tester.c
> @@ -798,6 +798,17 @@ static const struct generic_data
> .set_property.len = sizeof(setprop_remote_service),
> };
>
> +static bt_bdaddr_t setprop_bdaddr = {
> + .address = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
> +};
> +
> +static const struct generic_data bluetooth_setprop_bdaddr_invalid_test = {
> + .expected_adapter_status = BT_STATUS_FAIL,
> + .set_property.type = BT_PROPERTY_BDADDR,
> + .set_property.val = &setprop_bdaddr,
> + .set_property.len = sizeof(setprop_bdaddr),
> +};
> +
> static const struct generic_data bluetooth_discovery_start_success_test = {
> .expected_hal_cb.discovery_state_changed_cb =
> discovery_start_success_cb,
> @@ -1134,6 +1145,19 @@ static void test_setprop_service_record_invalid(const
> void *test_data) check_expected_status(adapter_status);
> }
>
> +static void test_setprop_bdaddr_invalid(const void *test_data)
> +{
> + struct test_data *data = tester_get_data();
> + const struct generic_data *test = data->test_data;
> + const bt_property_t *prop = &test->expected_property;
> + bt_status_t adapter_status;
> +
> + init_test_conditions(data);
> +
> + adapter_status = data->if_bluetooth->set_adapter_property(prop);
> + check_expected_status(adapter_status);
> +}
> +
> static void test_discovery_start_success(const void *test_data)
> {
> struct test_data *data = tester_get_data();
> @@ -1693,6 +1717,11 @@ int main(int argc, char *argv[])
> setup_enabled_adapter,
> test_setprop_service_record_invalid, teardown);
>
> + test_bredrle("Bluetooth Set BDADDR - Invalid",
> + &bluetooth_setprop_bdaddr_invalid_test,
> + setup_enabled_adapter,
> + test_setprop_bdaddr_invalid, teardown);
> +
> test_bredrle("Bluetooth BREDR Discovery Start - Success",
> &bluetooth_discovery_start_success_test,
> setup_enabled_adapter,
All patches applied, thanks.
--
Szymon K. Janc
szymon.janc@gmail.com
^ permalink raw reply
* Re: [PATCH v2] Bluetooth: Add hci_h4p driver
From: Sebastian Reichel @ 2013-12-30 14:52 UTC (permalink / raw)
To: Pali Rohár
Cc: Marcel Holtmann,
Ивайло Димитров,
Gustavo F. Padovan, Johan Hedberg, Pavel Machek, linux-kernel,
linux-bluetooth@vger.kernel.org development
In-Reply-To: <201312301531.29768@pali>
[-- Attachment #1: Type: text/plain, Size: 3112 bytes --]
Hi,
On Mon, Dec 30, 2013 at 03:31:25PM +0100, Pali Rohár wrote:
> [...] I think that correct commit message is not needed now.
Please add patch descriptions as early as possible. Patches without
descriptions are anoying for misc. reasons. It's not too much work
to do and helps everyone to understand what's going on. Especially
if the patch gets forgotten for some reason and somebody wants to
pick it up at a later time.
Wolfram Sang gave a talk about that at 30C3 yesterday. Official
recordings of his talk are not yet ready, but the live stream
has been recorded and uploaded to youtube:
http://www.youtube.com/watch?v=DjI7IFbvU0s (starting at 14:30)
> > > diff --git a/drivers/bluetooth/Kconfig
> > > b/drivers/bluetooth/Kconfig index 11a6104..95155c3 100644
> > > --- a/drivers/bluetooth/Kconfig
> > > +++ b/drivers/bluetooth/Kconfig
> > > @@ -242,4 +242,14 @@ config BT_WILINK
> > >
> > > Say Y here to compile support for Texas Instrument's
> > > WiLink7 driver into the kernel or say M to compile it as
> > > module.
> > >
> > > +
> > > +config BT_HCIH4P
> > > + tristate "HCI driver with H4 Nokia extensions"
> > > + depends on BT && ARCH_OMAP
> >
> > Since then we moved away from doing hci_* prefix of drivers
> > since that is misleading. See btusb.ko, btmrvl_sdio.ko etc.
> >
> > So this might be better named BT_NOK_H4P or BT_NOKIA_H4P and
> > the module named btnok_h4p.ko or btnokia_h4p.ko.
> >
> > I still never understood what “p” was for.
> >
>
> I do not know too, I did not invent that name. I just copied
> kernel driver from nokia kernel and patched it to work with 3.12.
>
> Maybe 'p' means plus (+) as H4+.
AFAIR there is a H4+ reference in the code, so I also guess H4P =
H4+. Apart from that I assume, that it's meant as a short for "H4
plus some extensions"
> > Can we also make this just depend on some device tree
> > information and not on a specific architecture. I know that
> > this driver is pretty much OMAP specific, but if we want this
> > upstream, we should at least try to make it more generic.
> >
>
> Sebastian, can you look at code how hard is to add DT support?
I already have it on my TODO list.
> > > +MODULE_DESCRIPTION("Bluetooth h4 driver with nokia
> > > extensions"); +MODULE_LICENSE("GPL");
> > > +MODULE_AUTHOR("Ville Tervo");
> > > +MODULE_FIRMWARE(FW_NAME_TI1271_PRELE);
> > > +MODULE_FIRMWARE(FW_NAME_TI1271_LE);
> > > +MODULE_FIRMWARE(FW_NAME_TI1271);
> > > +MODULE_FIRMWARE(FW_NAME_BCM2048);
> > > +MODULE_FIRMWARE(FW_NAME_CSR);
> >
> > Do we actually have all these firmware files still available.
> > If not, then focus on the ones we have.
>
> Firmware files are available for download from nemo project:
>
> https://api.merproject.org/public/source/nemo:devel:hw:ti:omap3:n900/bcm-bt-firmware/bcm-bt-firmware-0.21rc3.tar.bz2
> https://api.merproject.org/public/source/nemo:devel:hw:ti:omap3:n950-n9/ti-wl1273-bt-firmware/bt-firmware-ti1273_0.23+0m6.tar.gz
Would be nice to have them added to the linux-firmware.git.
-- Sebastian
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply
* [PATCH] tools/bluetooth-player: Formatting commands
From: Sebastian Chlad @ 2013-12-30 14:31 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Sebastian Chlad
In-Reply-To: <1388153434-8459-1-git-send-email-sebastianx.chlad@intel.com>
Formatting commands passed to bluetooth player.
Whitespace character trimmed.
---
tools/bluetooth-player.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/bluetooth-player.c b/tools/bluetooth-player.c
index 622d391..2afdd17 100644
--- a/tools/bluetooth-player.c
+++ b/tools/bluetooth-player.c
@@ -1080,6 +1080,7 @@ static void rl_handler(char *input)
if (!strlen(input))
goto done;
+ g_strstrip(input);
add_history(input);
argv = g_strsplit(input, " ", -1);
--
1.7.9.5
^ permalink raw reply related
* Re: [PATCH v2] Bluetooth: Add hci_h4p driver
From: Pali Rohár @ 2013-12-30 14:31 UTC (permalink / raw)
To: Marcel Holtmann
Cc: Ивайло Димитров,
Gustavo F. Padovan, Johan Hedberg, Pavel Machek, linux-kernel,
linux-bluetooth@vger.kernel.org development, Sebastian Reichel
In-Reply-To: <C8D1F470-7964-4EAC-82E0-D53CF54DE086@holtmann.org>
[-- Attachment #1: Type: Text/Plain, Size: 2963 bytes --]
On Saturday 28 December 2013 02:21:23 Marcel Holtmann wrote:
> Hi Pali,
>
> > I'm sending updated version of hci_h4p bluetooth driver. It
> > is needed for Nokia N900 bluetooth hardware. This (v2) is
> > older version of hci_h4p driver, but I tested it with
> > v3.13-rc3 kernel on Nokia N900 and working without any
> > problems. Previous (v1) version had some problems. So for
> > future development please use this (v2) version of hci_h4p
> > driver.
>
> please create a proper commit message explaining this driver.
> Revision updates should go between the diffstat and the patch
> itself. Use git format-patch and you see what I mean.
>
Ok. First what I wanted was to have working driver with new kernel. I sent it so other people can look at code and fix what is
needed... I think that correct commit message is not needed now.
> > diff --git a/drivers/bluetooth/Kconfig
> > b/drivers/bluetooth/Kconfig index 11a6104..95155c3 100644
> > --- a/drivers/bluetooth/Kconfig
> > +++ b/drivers/bluetooth/Kconfig
> > @@ -242,4 +242,14 @@ config BT_WILINK
> >
> > Say Y here to compile support for Texas Instrument's
> > WiLink7 driver into the kernel or say M to compile it as
> > module.
> >
> > +
> > +config BT_HCIH4P
> > + tristate "HCI driver with H4 Nokia extensions"
> > + depends on BT && ARCH_OMAP
>
> Since then we moved away from doing hci_* prefix of drivers
> since that is misleading. See btusb.ko, btmrvl_sdio.ko etc.
>
> So this might be better named BT_NOK_H4P or BT_NOKIA_H4P and
> the module named btnok_h4p.ko or btnokia_h4p.ko.
>
> I still never understood what “p” was for.
>
I do not know too, I did not invent that name. I just copied
kernel driver from nokia kernel and patched it to work with 3.12.
Maybe 'p' means plus (+) as H4+.
> Can we also make this just depend on some device tree
> information and not on a specific architecture. I know that
> this driver is pretty much OMAP specific, but if we want this
> upstream, we should at least try to make it more generic.
>
Sebastian, can you look at code how hard is to add DT support?
> > +MODULE_DESCRIPTION("Bluetooth h4 driver with nokia
> > extensions"); +MODULE_LICENSE("GPL");
> > +MODULE_AUTHOR("Ville Tervo");
> > +MODULE_FIRMWARE(FW_NAME_TI1271_PRELE);
> > +MODULE_FIRMWARE(FW_NAME_TI1271_LE);
> > +MODULE_FIRMWARE(FW_NAME_TI1271);
> > +MODULE_FIRMWARE(FW_NAME_BCM2048);
> > +MODULE_FIRMWARE(FW_NAME_CSR);
>
> Do we actually have all these firmware files still available.
> If not, then focus on the ones we have.
>
Firmware files are available for download from nemo project:
https://api.merproject.org/public/source/nemo:devel:hw:ti:omap3:n900/bcm-bt-firmware/bcm-bt-firmware-0.21rc3.tar.bz2
https://api.merproject.org/public/source/nemo:devel:hw:ti:omap3:n950-n9/ti-wl1273-bt-firmware/bt-firmware-ti1273_0.23+0m6.tar.gz
--
Pali Rohár
pali.rohar@gmail.com
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply
* [PATCH 5/5] android/tester: Add TYPE_OF_DEVICE get prop success test case
From: Grzegorz Kolodziejczyk @ 2013-12-30 14:25 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1388413509-31265-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>
This adds TYPE_OF_DEVICE get property success test case.
---
android/android-tester.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/android/android-tester.c b/android/android-tester.c
index c548e35..c89b97a 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -844,6 +844,17 @@ static const struct generic_data bluetooth_getprop_cod_success_test = {
.expected_property.len = sizeof(getprop_cod),
};
+static bt_device_type_t getprop_tod = BT_DEVICE_DEVTYPE_BREDR;
+
+static const struct generic_data bluetooth_getprop_tod_success_test = {
+ .expected_hal_cb.adapter_properties_cb = getprop_success_cb,
+ .expected_cb_count = 1,
+ .expected_adapter_status = BT_STATUS_SUCCESS,
+ .expected_property.type = BT_PROPERTY_TYPE_OF_DEVICE,
+ .expected_property.val = &getprop_tod,
+ .expected_property.len = sizeof(getprop_tod),
+};
+
static const struct generic_data bluetooth_discovery_start_success_test = {
.expected_hal_cb.discovery_state_changed_cb =
discovery_start_success_cb,
@@ -1232,6 +1243,19 @@ static void test_getprop_cod_success(const void *test_data)
check_expected_status(adapter_status);
}
+static void test_getprop_tod_success(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ const struct generic_data *test = data->test_data;
+ const bt_property_t prop = test->expected_property;
+ bt_status_t adapter_status;
+
+ init_test_conditions(data);
+
+ adapter_status = data->if_bluetooth->get_adapter_property(prop.type);
+ check_expected_status(adapter_status);
+}
+
static void test_discovery_start_success(const void *test_data)
{
struct test_data *data = tester_get_data();
@@ -1811,6 +1835,11 @@ int main(int argc, char *argv[])
setup_enabled_adapter,
test_getprop_cod_success, teardown);
+ test_bredrle("Bluetooth Get TYPE_OF_DEVICE - Success",
+ &bluetooth_getprop_tod_success_test,
+ setup_enabled_adapter,
+ test_getprop_tod_success, teardown);
+
test_bredrle("Bluetooth BREDR Discovery Start - Success",
&bluetooth_discovery_start_success_test,
setup_enabled_adapter,
--
1.8.4.2
^ permalink raw reply related
* [PATCH 4/5] android/tester: Add CLASS_OF_DEVICE get prop success test case
From: Grzegorz Kolodziejczyk @ 2013-12-30 14:25 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1388413509-31265-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>
This adds CLASS_OF_DEVICE get property success test case.
---
android/android-tester.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/android/android-tester.c b/android/android-tester.c
index 15f427c..c548e35 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -833,6 +833,17 @@ static const struct generic_data
.set_property.len = sizeof(setprop_bonded_devices),
};
+static uint32_t getprop_cod = 0;
+
+static const struct generic_data bluetooth_getprop_cod_success_test = {
+ .expected_hal_cb.adapter_properties_cb = getprop_success_cb,
+ .expected_cb_count = 1,
+ .expected_adapter_status = BT_STATUS_SUCCESS,
+ .expected_property.type = BT_PROPERTY_CLASS_OF_DEVICE,
+ .expected_property.val = &getprop_cod,
+ .expected_property.len = sizeof(getprop_cod),
+};
+
static const struct generic_data bluetooth_discovery_start_success_test = {
.expected_hal_cb.discovery_state_changed_cb =
discovery_start_success_cb,
@@ -1208,6 +1219,19 @@ static void test_setprop_bonded_devices_invalid(const void *test_data)
check_expected_status(adapter_status);
}
+static void test_getprop_cod_success(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ const struct generic_data *test = data->test_data;
+ const bt_property_t prop = test->expected_property;
+ bt_status_t adapter_status;
+
+ init_test_conditions(data);
+
+ adapter_status = data->if_bluetooth->get_adapter_property(prop.type);
+ check_expected_status(adapter_status);
+}
+
static void test_discovery_start_success(const void *test_data)
{
struct test_data *data = tester_get_data();
@@ -1782,6 +1806,11 @@ int main(int argc, char *argv[])
setup_enabled_adapter,
test_setprop_bonded_devices_invalid, teardown);
+ test_bredrle("Bluetooth Get CLASS_OF_DEVICE - Success",
+ &bluetooth_getprop_cod_success_test,
+ setup_enabled_adapter,
+ test_getprop_cod_success, teardown);
+
test_bredrle("Bluetooth BREDR Discovery Start - Success",
&bluetooth_discovery_start_success_test,
setup_enabled_adapter,
--
1.8.4.2
^ permalink raw reply related
* [PATCH 3/5] android/tester: Add BONDED_DEVICES set prop fail test case
From: Grzegorz Kolodziejczyk @ 2013-12-30 14:25 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1388413509-31265-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>
This adds BONDED_DEVICES set property fail test case due to only
get possibility.
---
android/android-tester.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/android/android-tester.c b/android/android-tester.c
index 358c58b..15f427c 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -821,6 +821,18 @@ static const struct generic_data
.expected_property.len = sizeof(setprop_scanmode_connectable),
};
+static bt_bdaddr_t setprop_bonded_devices = {
+ .address = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05 },
+};
+
+static const struct generic_data
+ bluetooth_setprop_bonded_devices_invalid_test = {
+ .expected_adapter_status = BT_STATUS_FAIL,
+ .set_property.type = BT_PROPERTY_ADAPTER_BONDED_DEVICES,
+ .set_property.val = &setprop_bonded_devices,
+ .set_property.len = sizeof(setprop_bonded_devices),
+};
+
static const struct generic_data bluetooth_discovery_start_success_test = {
.expected_hal_cb.discovery_state_changed_cb =
discovery_start_success_cb,
@@ -1183,6 +1195,19 @@ static void test_setprop_scanmode_connectable_success(const void *test_data)
check_expected_status(adapter_status);
}
+static void test_setprop_bonded_devices_invalid(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ const struct generic_data *test = data->test_data;
+ const bt_property_t *prop = &test->expected_property;
+ bt_status_t adapter_status;
+
+ init_test_conditions(data);
+
+ adapter_status = data->if_bluetooth->set_adapter_property(prop);
+ check_expected_status(adapter_status);
+}
+
static void test_discovery_start_success(const void *test_data)
{
struct test_data *data = tester_get_data();
@@ -1752,6 +1777,11 @@ int main(int argc, char *argv[])
setup_enabled_adapter,
test_setprop_scanmode_connectable_success, teardown);
+ test_bredrle("Bluetooth Set BONDED_DEVICES - Invalid",
+ &bluetooth_setprop_bonded_devices_invalid_test,
+ setup_enabled_adapter,
+ test_setprop_bonded_devices_invalid, teardown);
+
test_bredrle("Bluetooth BREDR Discovery Start - Success",
&bluetooth_discovery_start_success_test,
setup_enabled_adapter,
--
1.8.4.2
^ permalink raw reply related
* [PATCH 2/5] android/tester: Add SCAN_MODE=CONNECTABLE set prop success test case
From: Grzegorz Kolodziejczyk @ 2013-12-30 14:25 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1388413509-31265-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>
This adds SCAN_MODE property set to CONNECTABLE - success test case.
---
android/android-tester.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/android/android-tester.c b/android/android-tester.c
index d7ebc02..358c58b 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -809,6 +809,18 @@ static const struct generic_data bluetooth_setprop_bdaddr_invalid_test = {
.set_property.len = sizeof(setprop_bdaddr),
};
+static bt_scan_mode_t setprop_scanmode_connectable = BT_SCAN_MODE_CONNECTABLE;
+
+static const struct generic_data
+ bluetooth_setprop_scanmode_connectable_success_test = {
+ .expected_hal_cb.adapter_properties_cb = getprop_success_cb,
+ .expected_cb_count = 1,
+ .expected_adapter_status = BT_STATUS_SUCCESS,
+ .expected_property.type = BT_PROPERTY_ADAPTER_SCAN_MODE,
+ .expected_property.val = &setprop_scanmode_connectable,
+ .expected_property.len = sizeof(setprop_scanmode_connectable),
+};
+
static const struct generic_data bluetooth_discovery_start_success_test = {
.expected_hal_cb.discovery_state_changed_cb =
discovery_start_success_cb,
@@ -1158,6 +1170,19 @@ static void test_setprop_bdaddr_invalid(const void *test_data)
check_expected_status(adapter_status);
}
+static void test_setprop_scanmode_connectable_success(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ const struct generic_data *test = data->test_data;
+ const bt_property_t *prop = &test->expected_property;
+ bt_status_t adapter_status;
+
+ init_test_conditions(data);
+
+ adapter_status = data->if_bluetooth->set_adapter_property(prop);
+ check_expected_status(adapter_status);
+}
+
static void test_discovery_start_success(const void *test_data)
{
struct test_data *data = tester_get_data();
@@ -1722,6 +1747,11 @@ int main(int argc, char *argv[])
setup_enabled_adapter,
test_setprop_bdaddr_invalid, teardown);
+ test_bredrle("Bluetooth Set SCAN_MODE CONNECTABLE - Success",
+ &bluetooth_setprop_scanmode_connectable_success_test,
+ setup_enabled_adapter,
+ test_setprop_scanmode_connectable_success, teardown);
+
test_bredrle("Bluetooth BREDR Discovery Start - Success",
&bluetooth_discovery_start_success_test,
setup_enabled_adapter,
--
1.8.4.2
^ permalink raw reply related
* [PATCH 1/5] android/tester: Add BDADDR set prop fail test case
From: Grzegorz Kolodziejczyk @ 2013-12-30 14:25 UTC (permalink / raw)
To: linux-bluetooth
This adds BDADDR set property fail test case due to only get
possibility.
---
android/android-tester.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/android/android-tester.c b/android/android-tester.c
index ee23fff..d7ebc02 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -798,6 +798,17 @@ static const struct generic_data
.set_property.len = sizeof(setprop_remote_service),
};
+static bt_bdaddr_t setprop_bdaddr = {
+ .address = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
+};
+
+static const struct generic_data bluetooth_setprop_bdaddr_invalid_test = {
+ .expected_adapter_status = BT_STATUS_FAIL,
+ .set_property.type = BT_PROPERTY_BDADDR,
+ .set_property.val = &setprop_bdaddr,
+ .set_property.len = sizeof(setprop_bdaddr),
+};
+
static const struct generic_data bluetooth_discovery_start_success_test = {
.expected_hal_cb.discovery_state_changed_cb =
discovery_start_success_cb,
@@ -1134,6 +1145,19 @@ static void test_setprop_service_record_invalid(const void *test_data)
check_expected_status(adapter_status);
}
+static void test_setprop_bdaddr_invalid(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ const struct generic_data *test = data->test_data;
+ const bt_property_t *prop = &test->expected_property;
+ bt_status_t adapter_status;
+
+ init_test_conditions(data);
+
+ adapter_status = data->if_bluetooth->set_adapter_property(prop);
+ check_expected_status(adapter_status);
+}
+
static void test_discovery_start_success(const void *test_data)
{
struct test_data *data = tester_get_data();
@@ -1693,6 +1717,11 @@ int main(int argc, char *argv[])
setup_enabled_adapter,
test_setprop_service_record_invalid, teardown);
+ test_bredrle("Bluetooth Set BDADDR - Invalid",
+ &bluetooth_setprop_bdaddr_invalid_test,
+ setup_enabled_adapter,
+ test_setprop_bdaddr_invalid, teardown);
+
test_bredrle("Bluetooth BREDR Discovery Start - Success",
&bluetooth_discovery_start_success_test,
setup_enabled_adapter,
--
1.8.4.2
^ permalink raw reply related
* Re: [PATCH v2] Bluetooth: Add hci_h4p driver
From: Pali Rohár @ 2013-12-30 14:04 UTC (permalink / raw)
To: Sebastian Reichel
Cc: Pavel Machek, Marcel Holtmann,
Ивайло Димитров,
Gustavo F. Padovan, Johan Hedberg, linux-kernel,
linux-bluetooth@vger.kernel.org development, Ville Tervo
In-Reply-To: <20131230131942.GA13816@earth.universe>
[-- Attachment #1: Type: Text/Plain, Size: 1029 bytes --]
On Monday 30 December 2013 14:19:44 Sebastian Reichel wrote:
> Hi,
>
> On Mon, Dec 30, 2013 at 01:13:50PM +0100, Pavel Machek wrote:
> > [...]
> >
> > Well, I can rename config option, but renaming the module
> > would break existing userland, no?
>
> Why is the userland depending on the module name?
>
grep told me that hci_h4p is used only in these (text) files:
* /etc/modprobe.d/maemo.conf
alias platform:hci_h4p hci_h4p
So this is not needed if kernel driver contains correct
MODULE_ALIAS macro.
* /etc/event.d/bluetooth-sysinfo
echo ... > /sys/devices/platform/hci_h4p/bdaddr
This upstart script contains code for reading mac address from
special sysinfod daemon and setting it to kernel driver. Once
there will be uniform way for setting mac address that script can
be changed.
So I think that renaming module will not break anything if kernel
module will get (somehow) correct mac address (or if random one
is acceptable).
--
Pali Rohár
pali.rohar@gmail.com
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply
* Re: [PATCH v2] Bluetooth: Add hci_h4p driver
From: Pali Rohár @ 2013-12-30 13:54 UTC (permalink / raw)
To: Pavel Machek
Cc: Marcel Holtmann,
Ивайло Димитров,
Gustavo F. Padovan, Johan Hedberg, linux-kernel,
linux-bluetooth@vger.kernel.org development, Ville Tervo,
Sebastian Reichel
In-Reply-To: <20131230121350.GB31236@amd.pavel.ucw.cz>
[-- Attachment #1: Type: Text/Plain, Size: 1015 bytes --]
On Monday 30 December 2013 13:13:50 Pavel Machek wrote:
> > > +
> > > + if (not_valid) {
> > > + dev_info(info->dev, "Valid bluetooth address not
found,
> > > setting some random\n"); + /* When address is not valid,
> > > use some random but Nokia MAC */ + memcpy(info-
>bd_addr,
> > > nokia_oui, 3);
> > > + get_random_bytes(info->bd_addr + 3, 3);
> > > + }
> >
> > This behavior is extremely dangerous. I would rather have
> > the device init or powering on the device fail instead of
> > making up a number that might clash with a real Nokia
> > device.
>
> Perhaps people can donate bt addresses from their
> no-longer-functional bluetooth devices and we can select from
> such pool here? ;-).
>
> Is there some experimental range we can allocate from?
>
Wifi driver wl1251 (it is already in mainline) is doing same:
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/net/wireless/ti/wl1251/main.c#n1431
--
Pali Rohár
pali.rohar@gmail.com
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply
* Re: [RFC BlueZ 3/9] android: Add audio open command/response struct
From: Luiz Augusto von Dentz @ 2013-12-30 13:36 UTC (permalink / raw)
To: Szymon Janc; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1532451.hxPrzbXmr3@athlon>
Hi Szymon,
On Mon, Dec 30, 2013 at 3:27 PM, Szymon Janc <szymon.janc@gmail.com> wrote:
> Hi Luiz,
>
> On Monday 30 December 2013 14:34:09 Luiz Augusto von Dentz wrote:
>> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>>
>> This adds the definitions to audio open command and response.
>> ---
>> android/a2dp.c | 9 +++++++++
>> android/audio-ipc-api.txt | 2 +-
>> android/hal-msg.h | 18 ++++++++++++++++++
>> android/ipc.c | 5 ++++-
>> 4 files changed, 32 insertions(+), 2 deletions(-)
>>
>> diff --git a/android/a2dp.c b/android/a2dp.c
>> index 63f1f58..5cb01f7 100644
>> --- a/android/a2dp.c
>> +++ b/android/a2dp.c
>> @@ -352,7 +352,16 @@ static sdp_record_t *a2dp_record(void)
>> return record;
>> }
>>
>> +static void bt_audio_open(const void *buf, uint16_t len)
>> +{
>> + DBG("Not Implemented");
>> +
>> + ipc_send_rsp(HAL_SERVICE_ID_AUDIO, AUDIO_OP_OPEN, HAL_STATUS_FAILED);
>> +}
>> +
>> static const struct ipc_handler audio_handlers[] = {
>> + /* AUDIO_OP_OPEN */
>> + { bt_audio_open, true, sizeof(struct audio_cmd_open) },
>> };
>>
>> bool bt_a2dp_register(const bdaddr_t *addr)
>> diff --git a/android/audio-ipc-api.txt b/android/audio-ipc-api.txt
>> index 1c42800..37a1569 100644
>> --- a/android/audio-ipc-api.txt
>> +++ b/android/audio-ipc-api.txt
>> @@ -49,9 +49,9 @@ Identifier: "audio" (BT_AUDIO_ID)
>>
>> Command parameters: Service UUID (16 octets)
>> Codec ID (1 octet)
>> + Number of codec presets (1 octet)
>> Codec capabilities length (1 octet)
>> Codec capabilities (variable)
>> - Number of codec presets (1 octet)
>> Codec preset # length (1 octet)
>> Codec preset # configuration (variable)
>> ...
>> diff --git a/android/hal-msg.h b/android/hal-msg.h
>> index 1afb1bc..4b52e5e 100644
>> --- a/android/hal-msg.h
>> +++ b/android/hal-msg.h
>> @@ -567,3 +567,21 @@ struct hal_ev_a2dp_audio_state {
>> uint8_t state;
>> uint8_t bdaddr[6];
>> } __attribute__((packed));
>> +
>> +#define AUDIO_OP_OPEN 0x01
>> +struct audio_cmd_open {
>> + uint16_t uuid;
>> + uint8_t codec;
>> + uint8_t presets;
>> + uint8_t len;
>> + uint8_t data[0];
>
> Maybe this could be
> struct audio_preset[0];
> ? (if that would make code cleaner)
Indeed, will fix it.
Luiz Augusto von Dentz
^ permalink raw reply
* Re: [RFC BlueZ 1/9] android: Add initial code for audio IPC
From: Luiz Augusto von Dentz @ 2013-12-30 13:34 UTC (permalink / raw)
To: Szymon Janc; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1919373.99Va0DTt5V@athlon>
Hi Szymon,
On Mon, Dec 30, 2013 at 3:26 PM, Szymon Janc <szymon.janc@gmail.com> wrote:
> Hi Luiz,
>
> On Monday 30 December 2013 14:34:07 Luiz Augusto von Dentz wrote:
>> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>>
>> This add initial code for listen and accept connections on the abstract
>> socket defined for the audio IPC.
>> ---
>> android/hal-msg.h | 1 +
>> android/ipc.c | 53
>> +++++++++++++++++++++++++++++++++++++++++++++++------ android/ipc.h |
>> 3 +++
>> 3 files changed, 51 insertions(+), 6 deletions(-)
>>
>> diff --git a/android/hal-msg.h b/android/hal-msg.h
>> index c351501..b14eced 100644
>> --- a/android/hal-msg.h
>> +++ b/android/hal-msg.h
>> @@ -24,6 +24,7 @@
>> #define BLUEZ_HAL_MTU 1024
>>
>> static const char BLUEZ_HAL_SK_PATH[] = "\0bluez_hal_socket";
>> +static const char BLUEZ_AUDIO_SK_PATH[] = "\0bluez_audio_socket";
>>
>> struct hal_hdr {
>> uint8_t service_id;
>> diff --git a/android/ipc.c b/android/ipc.c
>> index 9e8ccc3..6cdbf60 100644
>> --- a/android/ipc.c
>> +++ b/android/ipc.c
>> @@ -49,6 +49,7 @@ static struct service_handler services[HAL_SERVICE_ID_MAX
>> + 1];
>>
>> static GIOChannel *cmd_io = NULL;
>> static GIOChannel *notif_io = NULL;
>> +static GIOChannel *audio_io = NULL;
>>
>> static void ipc_handle_msg(const void *buf, ssize_t len)
>> {
>> @@ -145,7 +146,8 @@ static gboolean notif_watch_cb(GIOChannel *io,
>> GIOCondition cond, return FALSE;
>> }
>>
>> -static GIOChannel *connect_hal(GIOFunc connect_cb)
>> +static GIOChannel *connect_hal(const char *path, size_t size,
>> + GIOFunc connect_cb)
>> {
>> struct sockaddr_un addr;
>> GIOCondition cond;
>> @@ -167,11 +169,11 @@ static GIOChannel *connect_hal(GIOFunc connect_cb)
>> memset(&addr, 0, sizeof(addr));
>> addr.sun_family = AF_UNIX;
>>
>> - memcpy(addr.sun_path, BLUEZ_HAL_SK_PATH, sizeof(BLUEZ_HAL_SK_PATH));
>> + memcpy(addr.sun_path, path, size);
>>
>> if (connect(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
>> - error("IPC: failed to connect HAL socket: %d (%s)", errno,
>> - strerror(errno));
>> + error("IPC: failed to connect HAL socket %s: %d (%s)", &path[1],
>> + errno, strerror(errno));
>> g_io_channel_unref(io);
>> return NULL;
>> }
>> @@ -218,7 +220,8 @@ static gboolean cmd_connect_cb(GIOChannel *io,
>> GIOCondition cond, return FALSE;
>> }
>>
>> - notif_io = connect_hal(notif_connect_cb);
>> + notif_io = connect_hal(BLUEZ_HAL_SK_PATH, sizeof(BLUEZ_HAL_SK_PATH),
>> + notif_connect_cb);
>> if (!notif_io)
>> raise(SIGTERM);
>>
>> @@ -227,7 +230,8 @@ static gboolean cmd_connect_cb(GIOChannel *io,
>> GIOCondition cond,
>>
>> void ipc_init(void)
>> {
>> - cmd_io = connect_hal(cmd_connect_cb);
>> + cmd_io = connect_hal(BLUEZ_HAL_SK_PATH, sizeof(BLUEZ_HAL_SK_PATH),
>> + cmd_connect_cb);
>> if (!cmd_io)
>> raise(SIGTERM);
>> }
>> @@ -338,3 +342,40 @@ void ipc_unregister(uint8_t service)
>> services[service].handler = NULL;
>> services[service].size = 0;
>> }
>> +
>> +static gboolean audio_connect_cb(GIOChannel *io, GIOCondition cond,
>> + gpointer user_data)
>> +{
>> + DBG("");
>> +
>> + if (cond & (G_IO_NVAL | G_IO_ERR | G_IO_HUP)) {
>> + error("Audio IPC: socket connect failed, terminating");
>
> This message is misleading since we should raise(SIGTERM) to terminate.
>
> But I wonder if we should really terminate on audio IPC failure...
> That is failing on IPC error is OK (since that is a bug in our code anyway),
> but on not being able to connect we could simply fail to register a2dp HAL.
> Same goes with socket being closed - in such case we could fail any request to
> a2dp HAL until connection is recovered.
Yep, the terminating part of the message is misleading it should not
really exit just fail to initialize a2dp.
>> + audio_ipc_cleanup();
>> + return FALSE;
>> + }
>> +
>> + cond = G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL;
>> +
>> + g_io_add_watch(audio_io, cond, cmd_watch_cb, NULL);
>> +
>> + info("Audio IPC: successfully connected");
>> +
>> + return FALSE;
>> +}
>> +
>> +void audio_ipc_init(void)
>> +{
>> + audio_io = connect_hal(BLUEZ_AUDIO_SK_PATH, sizeof(BLUEZ_AUDIO_SK_PATH),
>> + audio_connect_cb);
>> + if (!cmd_io)
>
> audio_io here?
Yep, that is a bug.
--
Luiz Augusto von Dentz
^ permalink raw reply
* Re: [RFC BlueZ 3/9] android: Add audio open command/response struct
From: Szymon Janc @ 2013-12-30 13:27 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
In-Reply-To: <1388406855-8809-3-git-send-email-luiz.dentz@gmail.com>
Hi Luiz,
On Monday 30 December 2013 14:34:09 Luiz Augusto von Dentz wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> This adds the definitions to audio open command and response.
> ---
> android/a2dp.c | 9 +++++++++
> android/audio-ipc-api.txt | 2 +-
> android/hal-msg.h | 18 ++++++++++++++++++
> android/ipc.c | 5 ++++-
> 4 files changed, 32 insertions(+), 2 deletions(-)
>
> diff --git a/android/a2dp.c b/android/a2dp.c
> index 63f1f58..5cb01f7 100644
> --- a/android/a2dp.c
> +++ b/android/a2dp.c
> @@ -352,7 +352,16 @@ static sdp_record_t *a2dp_record(void)
> return record;
> }
>
> +static void bt_audio_open(const void *buf, uint16_t len)
> +{
> + DBG("Not Implemented");
> +
> + ipc_send_rsp(HAL_SERVICE_ID_AUDIO, AUDIO_OP_OPEN, HAL_STATUS_FAILED);
> +}
> +
> static const struct ipc_handler audio_handlers[] = {
> + /* AUDIO_OP_OPEN */
> + { bt_audio_open, true, sizeof(struct audio_cmd_open) },
> };
>
> bool bt_a2dp_register(const bdaddr_t *addr)
> diff --git a/android/audio-ipc-api.txt b/android/audio-ipc-api.txt
> index 1c42800..37a1569 100644
> --- a/android/audio-ipc-api.txt
> +++ b/android/audio-ipc-api.txt
> @@ -49,9 +49,9 @@ Identifier: "audio" (BT_AUDIO_ID)
>
> Command parameters: Service UUID (16 octets)
> Codec ID (1 octet)
> + Number of codec presets (1 octet)
> Codec capabilities length (1 octet)
> Codec capabilities (variable)
> - Number of codec presets (1 octet)
> Codec preset # length (1 octet)
> Codec preset # configuration (variable)
> ...
> diff --git a/android/hal-msg.h b/android/hal-msg.h
> index 1afb1bc..4b52e5e 100644
> --- a/android/hal-msg.h
> +++ b/android/hal-msg.h
> @@ -567,3 +567,21 @@ struct hal_ev_a2dp_audio_state {
> uint8_t state;
> uint8_t bdaddr[6];
> } __attribute__((packed));
> +
> +#define AUDIO_OP_OPEN 0x01
> +struct audio_cmd_open {
> + uint16_t uuid;
> + uint8_t codec;
> + uint8_t presets;
> + uint8_t len;
> + uint8_t data[0];
Maybe this could be
struct audio_preset[0];
? (if that would make code cleaner)
> +} __attribute__((packed));
> +
> +struct audio_preset {
> + uint8_t len;
> + uint8_t data[0];
> +} __attribute__((packed));
> +
> +struct audio_rsp_open {
> + uint8_t id;
> +} __attribute__((packed));
> diff --git a/android/ipc.c b/android/ipc.c
> index 6cdbf60..bb16553 100644
> --- a/android/ipc.c
> +++ b/android/ipc.c
> @@ -301,7 +301,10 @@ void ipc_send_rsp(uint8_t service_id, uint8_t opcode,
> uint8_t status) struct hal_status s;
> int sk;
>
> - sk = g_io_channel_unix_get_fd(cmd_io);
> + if (service_id == HAL_SERVICE_ID_AUDIO)
> + sk = g_io_channel_unix_get_fd(audio_io);
> + else
> + sk = g_io_channel_unix_get_fd(cmd_io);
>
> if (status == HAL_STATUS_SUCCESS) {
> ipc_send(sk, service_id, opcode, 0, NULL, -1);
--
Szymon K. Janc
szymon.janc@gmail.com
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox