Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH 1/6] android/tester: Fix for not checking for BT_STATUS_SUCCESS
From: Jakub Tyszkowski @ 2013-12-19 12:42 UTC (permalink / raw)
  To: linux-bluetooth

For BT_STATUS_SUCCESS no checks were done as it is 0 in bt_status_t
enum. Valid status for no status expected should be STATUS_NOT_EXPECTED.

---
 android/android-tester.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/android/android-tester.c b/android/android-tester.c
index c24f5a6..5549dcb 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -72,7 +72,7 @@ enum hal_bluetooth_callbacks_id {
 };
 
 struct generic_data {
-	uint8_t expected_adapter_status;
+	int expected_adapter_status;
 	uint32_t expect_settings_set;
 	bt_property_t expected_property;
 	uint8_t expected_hal_callbacks[];
@@ -92,6 +92,8 @@ struct socket_data {
 #define WAIT_FOR_SIGNAL_TIME 2 /* in seconds */
 #define EMULATOR_SIGNAL "emulator_started"
 
+#define BT_STATUS_NOT_EXPECTED	-1
+
 struct test_data {
 	struct mgmt *mgmt;
 	uint16_t mgmt_index;
@@ -199,7 +201,7 @@ static void expected_status_init(struct test_data *data)
 {
 	const struct generic_data *test_data = data->test_data;
 
-	if (!(test_data->expected_adapter_status))
+	if (test_data->expected_adapter_status == BT_STATUS_NOT_EXPECTED)
 		data->status_checked = true;
 }
 
-- 
1.8.5


^ permalink raw reply related

* [PATCH v2 5/5] android: Set umask in system-emulator
From: Szymon Janc @ 2013-12-19 12:38 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1387456713-12794-1-git-send-email-szymon.janc@tieto.com>

This will make sure files are created with proper permissions so
Android daemon doesn't have to handle that. On Android umask is
set by init.
---
 android/system-emulator.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/android/system-emulator.c b/android/system-emulator.c
index 24f2741..299de0f 100644
--- a/android/system-emulator.c
+++ b/android/system-emulator.c
@@ -37,6 +37,8 @@
 #include <sys/param.h>
 #include <sys/socket.h>
 #include <sys/un.h>
+#include <sys/types.h>
+#include <sys/stat.h>
 
 #include "monitor/mainloop.h"
 
@@ -169,5 +171,7 @@ int main(int argc, char *argv[])
 
 	mainloop_add_fd(fd, EPOLLIN, system_socket_callback, NULL, NULL);
 
+	umask(0177);
+
 	return mainloop_run();
 }
-- 
1.8.3.2


^ permalink raw reply related

* [PATCH v2 4/5] android/bluetooth: Add support for restoring devices from storage
From: Szymon Janc @ 2013-12-19 12:38 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1387456713-12794-1-git-send-email-szymon.janc@tieto.com>

This adds support to restore bonded devices from storage (including
linkkeys).
---
 android/bluetooth.c | 113 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 112 insertions(+), 1 deletion(-)

diff --git a/android/bluetooth.c b/android/bluetooth.c
index 8f2a94c..c84bab6 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -1573,6 +1573,117 @@ static void clear_uuids(void)
 					sizeof(cp), &cp, NULL, NULL, NULL);
 }
 
+static void create_device_from_info(GKeyFile *key_file, const char *peer)
+{
+	struct device *dev;
+	uint8_t type;
+	bdaddr_t bdaddr;
+	char **uuids;
+	char *str;
+
+	DBG("%s", peer);
+
+	type = g_key_file_get_integer(key_file, peer, "Type", NULL);
+
+	str2ba(peer, &bdaddr);
+	dev = create_device(&bdaddr, type);
+
+	dev->bond_state = HAL_BOND_STATE_BONDED;
+
+	str = g_key_file_get_string(key_file, peer, "Name", NULL);
+	if (str) {
+		g_free(dev->name);
+		dev->name = str;
+	}
+
+	str = g_key_file_get_string(key_file, peer, "FriendlyName", NULL);
+	if (str) {
+		g_free(dev->friendly_name);
+		dev->friendly_name = str;
+	}
+
+	dev->class = g_key_file_get_integer(key_file, peer, "Class", NULL);
+
+	uuids = g_key_file_get_string_list(key_file, peer, "Services", NULL,
+									NULL);
+	if (uuids) {
+		char **uuid;
+
+		for (uuid = uuids; *uuid; uuid++) {
+			uint8_t *u = g_malloc0(16);
+			int i;
+
+			for (i = 0; i < 16; i++)
+				sscanf((*uuid) + (i * 2), "%02hhX", &u[i]);
+
+			dev->uuids = g_slist_append(dev->uuids, u);
+		}
+
+		g_strfreev(uuids);
+	}
+}
+
+static struct mgmt_link_key_info *get_key_info(GKeyFile *key_file, const char *peer)
+{
+	struct mgmt_link_key_info *info = NULL;
+	char *str;
+	unsigned int i;
+
+	str = g_key_file_get_string(key_file, peer, "LinkKey", NULL);
+	if (!str || strlen(str) != 32)
+		goto failed;
+
+	info = g_new0(struct mgmt_link_key_info, 1);
+
+	str2ba(peer, &info->addr.bdaddr);
+
+	info->addr.type = g_key_file_get_integer(key_file, peer, "Type", NULL);
+
+	for (i = 0; i < sizeof(info->val); i++)
+		sscanf(str + (i * 2), "%02hhX", &info->val[i]);
+
+	info->type = g_key_file_get_integer(key_file, peer, "LinkKeyType",
+									NULL);
+	info->pin_len = g_key_file_get_integer(key_file, peer,
+						"LinkKeyPINLength", NULL);
+
+failed:
+	g_free(str);
+
+	return info;
+}
+
+static void load_devices_info(bt_bluetooth_ready cb)
+{
+	GKeyFile *key_file;
+	gchar **devs;
+	gsize len = 0;
+	unsigned int i;
+	GSList *keys = NULL;
+
+	key_file = g_key_file_new();
+
+	g_key_file_load_from_file(key_file, ANDROID_STORAGEDIR"/devices", 0,
+									NULL);
+
+	devs = g_key_file_get_groups(key_file, &len);
+
+	for (i = 0; i < len; i++) {
+		struct mgmt_link_key_info *key_info;
+
+		create_device_from_info(key_file, devs[i]);
+
+		key_info = get_key_info(key_file, devs[i]);
+		if (key_info)
+			keys = g_slist_prepend(keys, key_info);
+
+		/* TODO ltk */
+	}
+
+	load_link_keys(keys, cb);
+	g_slist_free_full(keys, g_free);
+}
+
 static void read_info_complete(uint8_t status, uint16_t length,
 					const void *param, void *user_data)
 {
@@ -1627,7 +1738,7 @@ static void read_info_complete(uint8_t status, uint16_t length,
 
 	clear_uuids();
 
-	load_link_keys(NULL, cb);
+	load_devices_info(cb);
 
 	set_io_capability();
 	set_device_id();
-- 
1.8.3.2


^ permalink raw reply related

* [PATCH v2 3/5] android/bluetooth: Add support for storing link keys
From: Szymon Janc @ 2013-12-19 12:38 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1387456713-12794-1-git-send-email-szymon.janc@tieto.com>

When new linkkey event is received store linkkey in devices info file.
Stored info includes linkkey, linkkey type and pin length.
---
 android/bluetooth.c | 36 ++++++++++++++++++++++++++++++++----
 1 file changed, 32 insertions(+), 4 deletions(-)

diff --git a/android/bluetooth.c b/android/bluetooth.c
index ede844e..8f2a94c 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -490,7 +490,35 @@ static void mgmt_dev_class_changed_event(uint16_t index, uint16_t length,
 static void store_link_key(const bdaddr_t *dst, const uint8_t *key,
 					uint8_t type, uint8_t pin_length)
 {
-	/* TODO store link key */
+	GKeyFile *key_file;
+	char key_str[33];
+	gsize length = 0;
+	char addr[18];
+	char *data;
+	int i;
+
+	key_file = g_key_file_new();
+
+	if (!g_key_file_load_from_file(key_file, ANDROID_STORAGEDIR"/devices",
+								0, NULL))
+		return;
+
+	ba2str(dst, addr);
+
+	DBG("%s type %u pin_len %u", addr, type, pin_length);
+
+	for (i = 0; i < 16; i++)
+		sprintf(key_str + (i * 2), "%2.2X", key[i]);
+
+	g_key_file_set_string(key_file, addr, "LinkKey", key_str);
+	g_key_file_set_integer(key_file, addr, "LinkKeyType", type);
+	g_key_file_set_integer(key_file, addr, "LinkKeyPINLength", pin_length);
+
+	data = g_key_file_to_data(key_file, &length, NULL);
+	g_file_set_contents(ANDROID_STORAGEDIR"/devices", data, length, NULL);
+	g_free(data);
+
+	g_key_file_free(key_file);
 }
 
 static void send_bond_state_change(const bdaddr_t *addr, uint8_t status,
@@ -717,6 +745,9 @@ static void new_link_key_callback(uint16_t index, uint16_t length,
 		return;
 	}
 
+	set_device_bond_state(&addr->bdaddr, HAL_STATUS_SUCCESS,
+							HAL_BOND_STATE_BONDED);
+
 	if (ev->store_hint) {
 		const struct mgmt_link_key_info *key = &ev->key;
 
@@ -724,9 +755,6 @@ static void new_link_key_callback(uint16_t index, uint16_t length,
 								key->pin_len);
 	}
 
-	set_device_bond_state(&addr->bdaddr, HAL_STATUS_SUCCESS,
-							HAL_BOND_STATE_BONDED);
-
 	browse_remote_sdp(&addr->bdaddr);
 }
 
-- 
1.8.3.2


^ permalink raw reply related

* [PATCH v2 2/5] android/bluetooth: Add initial support for storing device info
From: Szymon Janc @ 2013-12-19 12:38 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1387456713-12794-1-git-send-email-szymon.janc@tieto.com>

This allows to store information about remote device. For now this is
stored only for bonded devices. Currently stored data includes devices
ddress, type, name, friendly name, class and uuids.
---
 android/bluetooth.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 75 insertions(+), 1 deletion(-)

diff --git a/android/bluetooth.c b/android/bluetooth.c
index ae136e4..ede844e 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -186,6 +186,76 @@ static void load_adapter_config(void)
 	g_key_file_free(key_file);
 }
 
+static void store_device_info(struct device *dev)
+{
+	GKeyFile *key_file;
+	char addr[18];
+	gsize length = 0;
+	char **uuids = NULL;
+	char *str;
+
+	if (dev->bond_state != HAL_BOND_STATE_BONDED &&
+			dev->bond_state != HAL_BOND_STATE_NONE)
+		return;
+
+	ba2str(&dev->bdaddr, addr);
+
+	key_file = g_key_file_new();
+	g_key_file_load_from_file(key_file, ANDROID_STORAGEDIR"/devices", 0,
+									NULL);
+
+	if (dev->bond_state == HAL_BOND_STATE_NONE) {
+		g_key_file_remove_group(key_file, addr, NULL);
+		goto done;
+	}
+
+	g_key_file_set_integer(key_file, addr, "Type", dev->bdaddr_type);
+
+	g_key_file_set_string(key_file, addr, "Name", dev->name);
+
+	if (dev->friendly_name)
+		g_key_file_set_string(key_file, addr, "FriendlyName",
+							dev->friendly_name);
+	else
+		g_key_file_remove_key(key_file, addr, "FriendlyName", NULL);
+
+	if (dev->class)
+		g_key_file_set_integer(key_file, addr, "Class", dev->class);
+	else
+		g_key_file_remove_key(key_file, addr, "Class", NULL);
+
+	if (dev->uuids) {
+		GSList *l;
+		int i;
+
+		uuids = g_new0(char *, g_slist_length(dev->uuids) + 1);
+
+		for (i = 0, l = dev->uuids; l; l = g_slist_next(l), i++) {
+			int j;
+			uint8_t *u = l->data;
+			char *uuid_str = g_malloc0(33);
+
+			for (j = 0; j < 16; j++)
+				sprintf(uuid_str + (j * 2), "%2.2X", u[j]);
+
+			uuids[i] = uuid_str;
+		}
+
+		g_key_file_set_string_list(key_file, addr, "Services",
+						(const char **)uuids, i);
+	} else {
+		g_key_file_remove_key(key_file, addr, "Services", NULL);
+	}
+
+done:
+	str = g_key_file_to_data(key_file, &length, NULL);
+	g_file_set_contents(ANDROID_STORAGEDIR"/devices", str, length, NULL);
+	g_free(str);
+
+	g_key_file_free(key_file);
+	g_strfreev(uuids);
+}
+
 static int bdaddr_cmp(gconstpointer a, gconstpointer b)
 {
 	const bdaddr_t *bda = a;
@@ -448,6 +518,8 @@ static void set_device_bond_state(const bdaddr_t *addr, uint8_t status,
 	if (dev->bond_state != state) {
 		dev->bond_state = state;
 		send_bond_state_change(&dev->bdaddr, status, state);
+
+		store_device_info(dev);
 	}
 }
 
@@ -488,6 +560,8 @@ static void set_device_uuids(struct device *dev, GSList *uuids)
 	g_slist_free_full(dev->uuids, g_free);
 	dev->uuids = uuids;
 
+	store_device_info(dev);
+
 	send_device_uuids_notif(dev);
 }
 
@@ -2529,7 +2603,7 @@ static uint8_t set_device_friendly_name(struct device *dev, const uint8_t *val,
 	g_free(dev->friendly_name);
 	dev->friendly_name = g_strndup((const char *) val, len);
 
-	/* TODO store friendly name */
+	store_device_info(dev);
 
 	send_device_property(&dev->bdaddr, HAL_PROP_DEVICE_FRIENDLY_NAME,
 				strlen(dev->friendly_name), dev->friendly_name);
-- 
1.8.3.2


^ permalink raw reply related

* [PATCH v2 1/5] android/bluetooth: Add initial support for permanent storage
From: Szymon Janc @ 2013-12-19 12:38 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1387456713-12794-1-git-send-email-szymon.janc@tieto.com>

This patch adds initial support for storing adapter configuration.
Currently stored data is address, name and discoverable timeout.

Since Android daemon storage format is to be simpler than Linux check
if correct adapter is used before going operational. This is
a precaution to avoid e.g. using linkkeys generated for different
controller.
---
 android/Android.mk  |  3 +-
 android/bluetooth.c | 85 +++++++++++++++++++++++++++++++++++++++++++++++++----
 configure.ac        |  3 ++
 3 files changed, 85 insertions(+), 6 deletions(-)

diff --git a/android/Android.mk b/android/Android.mk
index ebc3219..2953a6e 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -8,7 +8,8 @@ pathmap_INCL += glib:external/bluetooth/glib
 
 # Specify common compiler flags
 BLUEZ_COMMON_CFLAGS := -DVERSION=\"$(BLUEZ_VERSION)\" \
-	-DPLATFORM_SDK_VERSION=$(PLATFORM_SDK_VERSION)
+	-DPLATFORM_SDK_VERSION=$(PLATFORM_SDK_VERSION) \
+	-DANDROID_STORAGEDIR=\"/data/misc/bluetooth\" \
 
 # Disable warnings enabled by Android but not enabled in autotools build
 BLUEZ_COMMON_CFLAGS += -Wno-pointer-arith -Wno-missing-field-initializers
diff --git a/android/bluetooth.c b/android/bluetooth.c
index 97d4aae..ae136e4 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -27,6 +27,10 @@
 
 #include <errno.h>
 #include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
 
 #include <glib.h>
 
@@ -123,6 +127,65 @@ static GSList *devices = NULL;
 /* This list contains addresses which are asked for records */
 static GSList *browse_reqs;
 
+static void store_adapter_config(void)
+{
+	GKeyFile *key_file;
+	gsize length = 0;
+	char addr[18];
+	char *data;
+
+	key_file = g_key_file_new();
+
+	g_key_file_load_from_file(key_file, ANDROID_STORAGEDIR"/settings", 0,
+									NULL);
+
+	ba2str(&adapter.bdaddr, addr);
+
+	g_key_file_set_string(key_file, "General", "Address", addr);
+	g_key_file_set_string(key_file, "General", "Name", adapter.name);
+	g_key_file_set_integer(key_file, "General", "DiscoverableTimeout",
+						adapter.discoverable_timeout);
+
+	data = g_key_file_to_data(key_file, &length, NULL);
+
+	g_file_set_contents(ANDROID_STORAGEDIR"/settings", data, length, NULL);
+
+	g_free(data);
+	g_key_file_free(key_file);
+}
+
+static void load_adapter_config(void)
+{
+	GError *gerr = NULL;
+	GKeyFile *key_file;
+	char *str;
+
+	key_file = g_key_file_new();
+	g_key_file_load_from_file(key_file, ANDROID_STORAGEDIR"/settings", 0,
+									NULL);
+
+	str = g_key_file_get_string(key_file, "General", "Address", NULL);
+	if (!str) {
+		g_key_file_free(key_file);
+		return;
+	}
+
+	str2ba(str, &adapter.bdaddr);
+	g_free(str);
+
+	adapter.name = g_key_file_get_string(key_file, "General", "Name", NULL);
+
+	adapter.discoverable_timeout = g_key_file_get_integer(key_file,
+				"General", "DiscoverableTimeout", &gerr);
+	if (gerr) {
+		adapter.discoverable_timeout = DEFAULT_DISCOVERABLE_TIMEOUT;
+		g_error_free(gerr);
+		gerr = NULL;
+	}
+
+	g_key_file_free(key_file);
+}
+
 static int bdaddr_cmp(gconstpointer a, gconstpointer b)
 {
 	const bdaddr_t *bda = a;
@@ -215,6 +278,8 @@ static void adapter_set_name(const uint8_t *name)
 	g_free(adapter.name);
 	adapter.name = g_strdup((const char *) name);
 
+	store_adapter_config();
+
 	adapter_name_changed(name);
 }
 
@@ -1385,9 +1450,10 @@ static uint8_t set_adapter_discoverable_timeout(const void *buf, uint16_t len)
 	 * There is no need to use kernel feature for that.
 	 * Just need to store this value here */
 
-	/* TODO: This should be in some storage */
 	memcpy(&adapter.discoverable_timeout, timeout, sizeof(uint32_t));
 
+	store_adapter_config();
+
 	send_adapter_property(HAL_PROP_ADAPTER_DISC_TIMEOUT,
 					sizeof(adapter.discoverable_timeout),
 					&adapter.discoverable_timeout);
@@ -1434,17 +1500,26 @@ static void read_info_complete(uint8_t status, uint16_t length,
 		goto failed;
 	}
 
+	load_adapter_config();
+
+	if (!bacmp(&adapter.bdaddr, BDADDR_ANY)) {
+		bacpy(&adapter.bdaddr, &rp->bdaddr);
+		adapter.name = g_strdup((const char *) rp->name);
+		store_adapter_config();
+		set_adapter_name(rp->name, strlen((char *)rp->name));
+	} else if (bacmp(&adapter.bdaddr, &rp->bdaddr)) {
+		error("Bluetooth address mismatch");
+		err = -ENODEV;
+		goto failed;
+	}
+
 	/* Store adapter information */
-	bacpy(&adapter.bdaddr, &rp->bdaddr);
 	adapter.dev_class = rp->dev_class[0] | (rp->dev_class[1] << 8) |
 						(rp->dev_class[2] << 16);
-	adapter.name = g_strdup((const char *) rp->name);
 
 	supported_settings = btohs(rp->supported_settings);
 	adapter.current_settings = btohs(rp->current_settings);
 
-	/* TODO: Read discoverable timeout from storage here */
-
 	/* TODO: Register all event notification handlers */
 	register_mgmt_handlers();
 
diff --git a/configure.ac b/configure.ac
index 18d0b55..5171c38 100644
--- a/configure.ac
+++ b/configure.ac
@@ -252,4 +252,7 @@ AC_ARG_ENABLE(android, AC_HELP_STRING([--enable-android],
 					[enable_android=${enableval}])
 AM_CONDITIONAL(ANDROID, test "${enable_android}" = "yes")
 
+AC_DEFINE_UNQUOTED(ANDROID_STORAGEDIR, "${storagedir}/android",
+			[Directory for the Android daemon storage files])
+
 AC_OUTPUT(Makefile src/bluetoothd.8 lib/bluez.pc)
-- 
1.8.3.2


^ permalink raw reply related

* [PATCH v2 0/5] android: Permanent storage support
From: Szymon Janc @ 2013-12-19 12:38 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

V2:
 - removed file creation with open, it is up to init to set proper
   umask while staring bluetoothd
 - make system-emulator set proper umask

Szymon Janc (5):
  android/bluetooth: Add initial support for permanent storage
  android/bluetooth: Add initial support for storing device info
  android/bluetooth: Add support for storing link keys
  android/bluetooth: Add support for restoring devices from storage
  android: Set umask in system-emulator

 android/Android.mk        |   3 +-
 android/bluetooth.c       | 310 ++++++++++++++++++++++++++++++++++++++++++++--
 android/system-emulator.c |   4 +
 configure.ac              |   3 +
 4 files changed, 308 insertions(+), 12 deletions(-)

-- 
1.8.3.2


^ permalink raw reply

* [PATCH] android/pts: Add PICS, PIXITs and PTS for L2CAP
From: Sebastian Chlad @ 2013-12-19 12:26 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Sebastian Chlad
In-Reply-To: <2115852EF878384FA984E6B76A9F379E164297@IRSMSX104.ger.corp.intel.com>

This allows better tracking of the current state of implementation
---
 android/Makefile.am     |   4 +-
 android/pics-l2cap.txt  | 157 ++++++++++++++++++++++++++++++++++++++++++++++++
 android/pixit-l2cap.txt |  39 ++++++++++++
 android/pts-l2cap.txt   | 148 +++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 347 insertions(+), 1 deletion(-)
 create mode 100644 android/pics-l2cap.txt
 create mode 100644 android/pixit-l2cap.txt
 create mode 100644 android/pts-l2cap.txt

diff --git a/android/Makefile.am b/android/Makefile.am
index 909846e..a5533de 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -123,4 +123,6 @@ EXTRA_DIST += android/Android.mk android/hal-ipc-api.txt android/README \
 		android/pixit-pbap.txt android/pts-gap.txt android/pts-hid.txt \
 		android/pts-opp.txt android/pts-pbap.txt \
 		android/audio-ipc-api.txt android/pics-map.txt \
-		android/pixit-map.txt android/pts-map.txt
+		android/pixit-map.txt android/pts-map.txt \
+		android/pics-l2cap.txt android/pixit-l2cap.txt \
+		android/pts-l2cap.txt
diff --git a/android/pics-l2cap.txt b/android/pics-l2cap.txt
new file mode 100644
index 0000000..ef25133
--- /dev/null
+++ b/android/pics-l2cap.txt
@@ -0,0 +1,157 @@
+L2CAP PICS for the PTS tool.
+
+* - different than PTS defaults
+# - not yet implemented/supported
+
+M - mandatory
+O - optional
+
+		Roles
+-------------------------------------------------------------------------------
+Parameter Name	Selected	Description
+-------------------------------------------------------------------------------
+TSPC_L2CAP_1_1	True		Data Channel Initiator (C.1)
+TSPC_L2CAP_1_2	True		Data Channel Acceptor (C.1)
+TSPC_L2CAP_1_3	True (#)	LE Master (C.2)
+TSPC_L2CAP_1_4	True (#)	LE Slave (C.2)
+-------------------------------------------------------------------------------
+C.1: Mandatory IF BR/EDR or BR/EDR/LE is claimed, ELSE Excluded.
+C.2: Mandatory to support (at least one of TSPC_L2CAP_1_3 or TSPC_L2CAP_1_4)
+	IF LE or BR/EDR/LE claimed, ELSE Excluded.
+-------------------------------------------------------------------------------
+
+
+		General Operation
+-------------------------------------------------------------------------------
+Parameter Name	Selected	Description
+-------------------------------------------------------------------------------
+TSPC_L2CAP_2_1	True		Support of L2CAP signaling channel (C.20)
+TSPC_L2CAP_2_2	True		Support of configuration process (C.20)
+TSPC_L2CAP_2_4	True		Support of command echo request (C.21)
+TSPC_L2CAP_2_3  True            Support of connection oriented data
+                                        channel (C.20)
+TSPC_L2CAP_2_5	True		Support of command echo response (C.20)
+TSPC_L2CAP_2_6	True (*)	Support of command information request (C.21)
+TSPC_L2CAP_2_7	True		Support of command information response (C.20)
+TSPC_L2CAP_2_8	False		Support of a channel group (C.21)
+TSPC_L2CAP_2_9	False		Support of packet for connectionless
+					channel (C.21)
+TSPC_L2CAP_2_10	False		Support retransmission mode (C.21)
+TSPC_L2CAP_2_11	False		Support flow control mode(C.21)
+TSPC_L2CAP_2_12	True (*)	Enhanced Retransmission Mode (C.1, C.13)
+TSPC_L2CAP_2_13	True (*)	Streaming Mode (C.1, C.14)
+TSPC_L2CAP_2_14	True (*)	FCS Option (C.2)
+TSPC_L2CAP_2_15	True (*)	Generate Local Busy Condition (C.3)
+TSPC_L2CAP_2_16	True (*)	Send Reject (C.3)
+TSPC_L2CAP_2_17	True (*)	Send Selective Reject (C.3)
+TSPC_L2CAP_2_18	True (*)	Mandatory use of ERTM (C.4)
+TSPC_L2CAP_2_19	True (*)	Mandatory use of Streaming Mode (C.5)
+TSPC_L2CAP_2_20	True (*)	Optional use of ERTM (C.4)
+TSPC_L2CAP_2_21	True (*)	Optional use of Streaming Mode (C.5)
+TSPC_L2CAP_2_22	True (*)	Send data using SAR in ERTM (C.6)
+TSPC_L2CAP_2_23	True (*)	Send data using SAR in Streaming Mode (C.7)
+TSPC_L2CAP_2_24	True (*)	Actively request Basic Mode for a PSM that
+					supports the use of ERTM or Streaming
+					Mode (C.8)
+TSPC_L2CAP_2_25	True (*)	Supports performing L2CAP channel mode
+					configuration fallback from SM
+					 to ERTM (C.9)
+TSPC_L2CAP_2_26	True (*)	Supports sending more than one unacknowledged
+					I-Frame when operating in ERTM (C.10)
+TSPC_L2CAP_2_27	True (*)	Supports sending more than three unacknowledged
+					I-Frame when operating in ERTM (C.10)
+TSPC_L2CAP_2_28	True (*)	Supports configuring the peer TxWindow
+					greater than 1 (C.11)
+TSPC_L2CAP_2_29	False		AMP Support (C.12)
+TSPC_L2CAP_2_30	True (*)	Fixed Channel Support (C.12)
+TSPC_L2CAP_2_31	False		AMP Manager Support (C.12)
+TSPC_L2CAP_2_32	False		ERTM over AMP (C.12)
+TSPC_L2CAP_2_33	False		Streaming Mode Source over AMP Support (C.15)
+TSPC_L2CAP_2_34	False		Streaming Mode Sink over AMP Support (C.15)
+TSPC_L2CAP_2_35	False		Unicast Connectionless Data, Reception (C.1, C.16)
+TSPC_L2CAP_2_36	False		Ability to transmit an unencrypted packet over
+					a Unicast connectionless L2CAP
+					channel (C.16)
+TSPC_L2CAP_2_37	False		Ability to transmit an encrypted packet over
+					a Unicast connectionless L2CAP
+					channel (C.16)
+TSPC_L2CAP_2_38	False		Extended Flow Specification for BR/EDR (C.8)
+TSPC_L2CAP_2_39	False		Extended Window Size (C.8)
+TSPC_L2CAP_2_40	True (*)	Support of Low Energy signaling channel (C.17)
+TSPC_L2CAP_2_41	True (*)	Support of command reject (C.17)
+TSPC_L2CAP_2_42	True (*)	Send Connection Parameter Update Request (C.18)
+TSPC_L2CAP_2_43	True (*)	Send Connection Parameter Update Response (C.19)
+TSPC_L2CAP_2_44	False		Extended Flow Specification for AMP (C.22)
+TSPC_L2CAP_2_45	False		Send disconnect request command (O)
+-------------------------------------------------------------------------------
+C.1: Mandatory to support at least one of TSPC_L2CAP_2_12 OR TSPC_L2CAP_2_13 OR
+	TSPC_L2CAP_2_35 IF BR/EDR BR/EDR/LE AND SUM_ICS 31/7 (CSA1) OR
+	SUM_ICS 31/8 (3.0) OR SUM_ICS 31/9 (3.0+HS) OR SUM_ICS 31/10 (4.0))
+	is supported, ELSE Excluded
+C.2: Optional IF TSPC_L2CAP_2_12 OR TSPC_L2CAP_2_13 is claimed, ELSE Excluded.
+C.3: Optional IF TSPC_L2CAP_2_12 AND TSPC_L2CAP_2_28 is claimed, ELSE Excluded.
+C.4: IF TSPC_L2CAP_2_12 is claimed THEN either TSPC_L2CAP_2_18
+	OR TSPC_L2CAP_2_20 are Mandatory, ELSE Excluded.
+C.5: IF TSPC_L2CAP_2_13 is claimed THEN either TSPC_L2CAP_2_19
+	OR TSPC_L2CAP_2_21 are Mandatory, ELSE Excluded.
+C.6: Optional IF TSPC_L2CAP_2_12 is claimed, ELSE Excluded.
+C.7: Optional IF TSPC_L2CAP_2_13 is claimed, ELSE Excluded.
+C.8: Optional IF TSPC_L2CAP_2_12 OR TSPC_L2CAP_2_13 is claimed, ELSE Excluded.
+C.9: Mandatory IF TSPC_L2CAP_2_12 AND TSPC_L2CAP_2_13 AND TSPC_L2CAP_2_21
+       is claimed, ELSE Excluded.
+C.10: Optional IF TSPC_L2CAP_2_12 is claimed, ELSE Excluded.
+C.11: Optional IF TSPC_L2CAP_2_12 is claimed, ELSE Excluded.
+C.12: Mandatory IF SUM_ICS 31/9 (3.0 + HS) is claimed, ELSE Optional.
+C.13: Mandatory IF SUM_ICS 31/9 (3.0 + HS) is claimed, ELSE Optional.
+C.14: Optional IF SUM_ICS 31/8 OR 31/9 OR 31/10 OR 31/11 is claimed, ELSE Excluded.
+C.15: Optional IF TSPC_L2CAP_2_29 is claimed, ELSE Excluded.
+C.16: Optional IF (SUM_ICS 31/8 OR SUM_ICS 31/9 OR 31/10 OR 31/11) is claimed,
+       ELSE Excluded.
+C.17: Mandatory IF LE OR BR/EDR/LE is claimed, ELSE Excluded.
+C.18: Optional IF (SUM_ICS 31/10 AND 1/4) is claimed, ELSE Excluded.
+C.19: Mandatory IF (SUM_ICS 31/10 AND 1/3) is claimed, ELSE Excluded.
+C.20: Mandatory IF LE OR BR/EDR/LE, is claimed, ELSE Excluded
+C.21: Optional IF LE OR BR/EDR/LE, is claimed, ELSE Excluded
+C.22: Mandatory IF TSPC_L2CAP_2_29 is claimed, ELSE Excluded.
+-------------------------------------------------------------------------------
+
+
+		Configurable Parameters
+-------------------------------------------------------------------------------
+Parameter	Name Selected	Description
+-------------------------------------------------------------------------------
+TSPC_L2CAP_3_1	True		Support of RTX timer (M)
+TSPC_L2CAP_3_2	True		Support of ERTX timer (C.4)
+TSPC_L2CAP_3_3	True		Support minimum MTU size 48 octets (C.4)
+TSPC_L2CAP_3_4	True (*)	Support MTU size larger than 48 octets (C.5)
+TSPC_L2CAP_3_5	True		Support of flush timeout value for reliable
+					channel (C.4)
+TSPC_L2CAP_3_6	False		Support of flush timeout value for unreliable
+					channel (C.5)
+TSPC_L2CAP_3_7	False		Support of bi-directional quality of service
+					(QoS) option field (C.1)
+TSPC_L2CAP_3_8	False		Negotiate QoS service type (C.5)
+TSPC_L2CAP_3_9	False		Negotiate and support service type ‘No
+					traffic’ (C.2)
+TSPC_L2CAP_3_10	False		Negotiate and support service type ‘Best
+					effort’ (C.3)
+TSPC_L2CAP_3_11	False		Negotiate and support service type
+					‘Guaranteed’ (C.2)
+TSPC_L2CAP_3_12	True (*)	Support minimum MTU size 23 octets (C.6)
+TSPC_L2CAP_3_13	False		Negotiate and support service type ‘No traffic’
+					for Extended Flow Specification (C.7)
+TSPC_L2CAP_3_14	False		Negotiate and support service type ‘Best Effort'
+					for Extended Flow Specification (C.8)
+TSPC_L2CAP_3_15	False		Negotiate and support service type ‘Guaranteed’
+					for Extended Flow Specification (C.9)
+-------------------------------------------------------------------------------
+C.1: Mandatory if TSPC_L2CAP_3_8 is supported, ELSE Optional.
+C.2: Optional if TSPC_L2CAP_3_8 is supported, ELSE Excluded.
+C.3: Mandatory if TSPC_L2CAP_3_8 is supported, ELSE Excluded.
+C.4: Mandatory IF BR/EDR OR BR/EDR/LE is claimed, ELSE Excluded.
+C.5: Optional IF BR/EDR OR BR/EDR/LE is claimed, ELSE Excluded.
+C.6: Mandatory IF LE OR BR/EDR/LE is claimed, ELSE Excluded.
+C.7: Optional if TSPC_L2CAP_2_44 OR TSPC_L2CAP_2_38 is supported, ELSE Excluded.
+C.8: Mandatory if TSPC_L2CAP_2_44 OR TSPC_L2CAP_2_38 is supported, ELSE Excluded.
+C.9: Optional if TSPC_L2CAP_2_44 OR TSPC_L2CAP_2_38 is supported, ELSE Excluded.
+-------------------------------------------------------------------------------
diff --git a/android/pixit-l2cap.txt b/android/pixit-l2cap.txt
new file mode 100644
index 0000000..7de6638
--- /dev/null
+++ b/android/pixit-l2cap.txt
@@ -0,0 +1,39 @@
+L2CAP PIXIT for the PTS tool.
+
+* - different than PTS defaults
+& - should be set to IUT Bluetooth address
+
+               Required PIXIT settings
+-------------------------------------------------------------------------------
+Parameter Name                                         Value
+-------------------------------------------------------------------------------
+TSPX_bd_addr_iut                                       112233445566 (*&)
+TSPX_client_class_of_device                            100104
+TSPX_server_class_of_device                            100104
+TSPX_security_enabled                                  FALSE
+TSPX_delete_link_key                                   FALSE
+TSPX_pin_code                                          0000
+TSPX_flushto                                           FFFF
+TSPX_inmtu                                             02A0
+TSPX_no_fail_verditcs                                  FALSE
+TSPX_oumtu                                             02A0
+TSPX_iut_role_initiator                                FALSE
+TSPX_psm                                               1011 (*)
+TSPX_time_guard                                        180000
+TSPX_timer_ertx                                        120000
+TSPX_timer_ertx_max                                    300000
+TSPX_timer_ertx_min                                    60000
+TSPX_timer_rtx                                         10000
+TSPX_timer_rtx_max                                     60000
+TSPX_timer_rtx_min                                     1000
+TSPX_rfc_mode_tx_window_size                           08
+TSPX_rfc_mode_max_transmit                             03
+TSPX_rfc_mode_retransmission_timeout                   07D0
+TSPX_rfc_mode_monitor_timeout                          2EE0
+TSPX_rfc_mode_maximum_pdu_size                         02A0
+TSPX_extended_window_size                              0012
+TSPX_use_implicit_send                                 TRUE
+TSPX_use_dynamic_pin                                   FALSE
+TSPX_iut_SDU_size_in_bytes                             144
+TSPX_secure_simple_pairing_pass_key_confirmation       FALSE
+-------------------------------------------------------------------------------
diff --git a/android/pts-l2cap.txt b/android/pts-l2cap.txt
new file mode 100644
index 0000000..d293046
--- /dev/null
+++ b/android/pts-l2cap.txt
@@ -0,0 +1,148 @@
+PTS test results for L2CAP
+
+PTS version: 5.0
+Tested: 18.12.2013
+
+Results:
+PASS   test passed
+FAIL   test failed
+INC    test is inconclusive
+N/A    test is disabled due to PICS setup
+
+-------------------------------------------------------------------------------
+Test Name              Result  Notes
+-------------------------------------------------------------------------------
+TC_COS_CED_BV_01_C     PASS
+TC_COS_CED_BV_03_C     PASS
+TC_COS_CED_BV_04_C     N/A
+TC_COS_CED_BV_05_C     PASS
+TC_COS_CED_BV_07_C     PASS
+TC_COS_CED_BV_08_C     PASS
+TC_COS_CED_BV_09_C     INC
+TC_COS_CED_BV_10_C     N/A
+TC_COS_CED_BV_11_C     PASS
+TC_COS_CED_BI_01_C     PASS
+TC_COS_CFD_BV_01_C     PASS
+TC_COS_CFD_BV_02_C     PASS
+TC_COS_CFD_BV_03_C     PASS
+TC_COS_CFD_BV_08_C     INC
+TC_COS_CFD_BV_09_C     INC
+TC_COS_CFD_BV_10_C     N/A
+TC_COS_CFD_BI_11_C     PASS
+TC_COS_CFD_BV_12_C     PASS
+TC_COS_CFD_BV_13_C     N/A
+TC_COS_IEX_BV_01_C     PASS
+TC_COS_IEX_BV_02_C     PASS
+TC_COS_ECH_BV_01_C     PASS
+TC_COS_ECH_BV_02_C     INC
+TC_CLS_CLR_BV_01_C     N/A
+TC_CLS_UCD_BV_01_C     N/A
+TC_CLS_UCD_BV_02_C     N/A
+TC_CLS_UCD_BV_03_C     N/A
+TC_EXF_BV_01_C         PASS
+TC_EXF_BV_02_C         PASS
+TC_EXF_BV_03_C         PASS
+TC_EXF_BV_04_C         N/A
+TC_EXF_BV_05_C         PASS
+TC_EXF_BV_06_C         N/A
+TC_CMC_BV_01_C         INC
+TC_CMC_BV_02_C         INC
+TC_CMC_BV_03_C         INC
+TC_CMC_BV_04_C         INC
+TC_CMC_BV_05_C         INC
+TC_CMC_BV_06_C         INC
+TC_CMC_BV_07_C         INC
+TC_CMC_BV_08_C         INC
+TC_CMC_BV_09_C         INC
+TC_CMC_BV_10_C         INC
+TC_CMC_BV_11_C         INC
+TC_CMC_BV_12_C         INC
+TC_CMC_BV_13_C         INC
+TC_CMC_BV_14_C         INC
+TC_CMC_BV_15_C         INC
+TC_CMC_BI_01_C         INC
+TC_CMC_BI_02_C         INC
+TC_CMC_BI_03_C         INC
+TC_CMC_BI_04_C         INC
+TC_CMC_BI_05_C         INC
+TC_CMC_BI_06_C         INC
+TC_FOC_BV_01_C         INC
+TC_FOC_BV_02_C         INC
+TC_FOC_BV_03_C         INC
+TC_FOC_BV_04_C         INC
+TC_OFS_BV_01_C         INC
+TC_OFS_BV_02_C         INC
+TC_OFS_BV_03_C         INC
+TC_OFS_BV_04_C         INC
+TC_OFS_BV_05_C         INC
+TC_OFS_BV_06_C         INC
+TC_OFS_BV_07_C         INC
+TC_OFS_BV_08_C         INC
+TC_ERM_BV_01_C         INC
+TC_ERM_BV_02_C         INC
+TC_ERM_BV_03_C         INC
+TC_ERM_BV_04_C         INC
+TC_ERM_BV_05_C         INC
+TC_ERM_BV_06_C         INC
+TC_ERM_BV_07_C         INC
+TC_ERM_BV_08_C         INC
+TC_ERM_BV_09_C         INC
+TC_ERM_BV_10_C         INC
+TC_ERM_BV_11_C         INC
+TC_ERM_BV_12_C         INC
+TC_ERM_BV_13_C         INC
+TC_ERM_BV_14_C         INC
+TC_ERM_BV_15_C         INC
+TC_ERM_BV_16_C         INC
+TC_ERM_BV_17_C         INC
+TC_ERM_BV_18_C         INC
+TC_ERM_BV_19_C         INC
+TC_ERM_BV_20_C         INC
+TC_ERM_BV_21_C         INC
+TC_ERM_BV_22_C         INC
+TC_ERM_BV_23_C         INC
+TC_ERM_BI_01_C         INC
+TC_ERM_BI_02_C         INC
+TC_ERM_BI_03_C         INC
+TC_ERM_BI_04_C         INC
+TC_ERM_BI_05_C         INC
+TC_STM_BV_01_C         INC
+TC_STM_BV_02_C         INC
+TC_STM_BV_03_C         INC
+TC_STM_BV_11_C         N/A
+TC_STM_BV_12_C         N/A
+TC_STM_BV_13_C         N/A
+TC_FIX_BV_01_C         PASS
+TC_FIX_BV_02_C         PASS
+TC_EWC_BV_01_C         N/A
+TC_EWC_BV_02_C         N/A
+TC_EWC_BV_03_C         N/A
+TC_LSC_BV_01_C         N/A
+TC_LSC_BV_02_C         N/A
+TC_LSC_BV_03_C         N/A
+TC_LSC_BI_04_C         N/A
+TC_LSC_BI_05_C         N/A
+TC_LSC_BV_06_C         N/A
+TC_LSC_BV_07_C         N/A
+TC_LSC_BV_08_C         N/A
+TC_LSC_BV_09_C         N/A
+TC_LSC_BI_10_C         N/A
+TC_LSC_BI_11_C         N/A
+TC_LSC_BV_12_C         N/A
+TC_CCH_BV_01_C         N/A
+TC_CCH_BV_02_C         N/A
+TC_CCH_BV_03_C         N/A
+TC_CCH_BV_04_C         N/A
+TC_ECF_BV_01_C         N/A
+TC_ECF_BV_02_C         N/A
+TC_ECF_BV_03_C         N/A
+TC_ECF_BV_04_C         N/A
+TC_ECF_BV_05_C         N/A
+TC_ECF_BV_06_C         N/A
+TC_ECF_BV_07_C         N/A
+TC_ECF_BV_08_C         N/A
+TC_LE_CPU_BV_01_C      N/A
+TC_LE_CPU_BV_02_C      N/A
+TC_LE_CPU_BI_01_C      N/A
+TC_LE_CPU_BI_02_C      N/A
+TC_LE_REJ_BV_01_C      N/A
-- 
1.8.1.2


^ permalink raw reply related

* Re: [PATCH 2/6] emulator: Add connect callback when setting l2cap server
From: Johan Hedberg @ 2013-12-19 12:11 UTC (permalink / raw)
  To: Marcin Kraglak; +Cc: linux-bluetooth
In-Reply-To: <1387445406-20324-2-git-send-email-marcin.kraglak@tieto.com>

Hi Marcin,

On Thu, Dec 19, 2013, Marcin Kraglak wrote:
> Add possibility to set connect callback when client will be
> connected to bthost l2cap server.

I've applied the first patch, but there are some things in the
subsequent ones.

Regarding the commit messages, or code comments (or anything else except
actual code), please capitalize acronyms like L2CAP and PSM (I fixed
this in the first patch that I applied).

> +struct l2cap_conn_cb_data {
> +	uint16_t psm;
> +	bthost_l2cap_connect_cb func;
> +	void *user_data;
> +};
> +
>  struct bthost {
>  	uint8_t bdaddr[6];
>  	bthost_send_func send_handler;
> @@ -101,6 +107,7 @@ struct bthost {
>  	void *cmd_complete_data;
>  	bthost_new_conn_cb new_conn_cb;
>  	void *new_conn_data;
> +	struct l2cap_conn_cb_data *new_l2cap_conn_data;

You should  consider making this a list since otherwise you won't be
able to support profiles that use multiple different PSMs, like HID.

> -void bthost_set_server_psm(struct bthost *bthost, uint16_t psm)
> +void bthost_set_server_psm(struct bthost *bthost, uint16_t psm,
> +				bthost_l2cap_connect_cb func, void *user_data)

Since you're not updating any users of bthost_set_server_psm you'll
break bisectability of the git tree with this patch. In fact, I applied
all patches in your set and the tree still didn't compile.

I don't think set_server_psm is anymore an appropriate name for this
function when you add the two extra parameters. Instead it should be
something like bthost_add_l2cap_server().

Considering the above issues, it's probably better that you keep the
existing set_server_psm and have a add_l2cap_server along side of it
(the former would simply behave like the latter except with NULL
pointers as two last parameters).

Then, once you've updated all users to add_l2cap_server you can remove
the old set_server_psm.

Johan

^ permalink raw reply

* [PATCH] Bluetooth: hidp: make sure input buffers are big enough
From: David Herrmann @ 2013-12-19 11:09 UTC (permalink / raw)
  To: linux-input
  Cc: Jiri Kosina, linux-bluetooth, Marcel Holtmann, Gustavo Padovan,
	David Herrmann

HID core expects the input buffers to be at least of size 4096
(HID_MAX_BUFFER_SIZE). Other sizes will result in buffer-overflows if an
input-report is smaller than advertised. We could, like i2c, compute the
biggest report-size instead of using HID_MAX_BUFFER_SIZE, but this will
blow up if report-descriptors are changed after ->start() has been called.
So lets be safe and just use the biggest buffer we have.

Note that this adds an additional copy to the HIDP input path. If there is
a way to make sure the skb-buf is big enough, we should use that instead.

The best way would be to make hid-core honor the @size argument, though,
that sounds easier than it is. So lets just fix the buffer-overflows for
now and afterwards look for a faster way for all transport drivers.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
---
Hi

Any ideas how to improve this patch? I'd like to avoid the extra copy but I have
no clue how the skb stuff works exactly.

I also haven't figured out a nice way to make HID-core honor the "size"
parameter. hid-input depends on getting the whole input-report.

Comments welcome!
David

 net/bluetooth/hidp/core.c | 16 ++++++++++++++--
 net/bluetooth/hidp/hidp.h |  4 ++++
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c
index 292e619..d9fb934 100644
--- a/net/bluetooth/hidp/core.c
+++ b/net/bluetooth/hidp/core.c
@@ -430,6 +430,16 @@ static void hidp_del_timer(struct hidp_session *session)
 		del_timer(&session->timer);
 }
 
+static void hidp_process_report(struct hidp_session *session,
+				int type, const u8 *data, int len, int intr)
+{
+	if (len > HID_MAX_BUFFER_SIZE)
+		len = HID_MAX_BUFFER_SIZE;
+
+	memcpy(session->input_buf, data, len);
+	hid_input_report(session->hid, type, session->input_buf, len, intr);
+}
+
 static void hidp_process_handshake(struct hidp_session *session,
 					unsigned char param)
 {
@@ -502,7 +512,8 @@ static int hidp_process_data(struct hidp_session *session, struct sk_buff *skb,
 			hidp_input_report(session, skb);
 
 		if (session->hid)
-			hid_input_report(session->hid, HID_INPUT_REPORT, skb->data, skb->len, 0);
+			hidp_process_report(session, HID_INPUT_REPORT,
+					    skb->data, skb->len, 0);
 		break;
 
 	case HIDP_DATA_RTYPE_OTHER:
@@ -584,7 +595,8 @@ static void hidp_recv_intr_frame(struct hidp_session *session,
 			hidp_input_report(session, skb);
 
 		if (session->hid) {
-			hid_input_report(session->hid, HID_INPUT_REPORT, skb->data, skb->len, 1);
+			hidp_process_report(session, HID_INPUT_REPORT,
+					    skb->data, skb->len, 1);
 			BT_DBG("report len %d", skb->len);
 		}
 	} else {
diff --git a/net/bluetooth/hidp/hidp.h b/net/bluetooth/hidp/hidp.h
index ab52414..8798492 100644
--- a/net/bluetooth/hidp/hidp.h
+++ b/net/bluetooth/hidp/hidp.h
@@ -24,6 +24,7 @@
 #define __HIDP_H
 
 #include <linux/types.h>
+#include <linux/hid.h>
 #include <linux/kref.h>
 #include <net/bluetooth/bluetooth.h>
 #include <net/bluetooth/l2cap.h>
@@ -179,6 +180,9 @@ struct hidp_session {
 
 	/* Used in hidp_output_raw_report() */
 	int output_report_success; /* boolean */
+
+	/* temporary input buffer */
+	u8 input_buf[HID_MAX_BUFFER_SIZE];
 };
 
 /* HIDP init defines */
-- 
1.8.5.1

^ permalink raw reply related

* Re: [PATCH 1/4] android/bluetooth: Add initial support for permanent storage
From: Szymon Janc @ 2013-12-19  9:46 UTC (permalink / raw)
  To: Johan Hedberg; +Cc: linux-bluetooth
In-Reply-To: <20131219091423.GC6199@x220.p-661hnu-f1>

Hi Johan,

> Hi Szymon,
> 
> On Thu, Dec 19, 2013, Szymon Janc wrote:
> > > On Wed, Dec 18, 2013, Szymon Janc wrote:
> > > > +static void store_adapter_config(void)
> > > > +{
> > > > +	GKeyFile *key_file;
> > > > +	gsize length = 0;
> > > > +	char addr[18];
> > > > +	char *data;
> > > > +
> > > > +	key_file = g_key_file_new();
> > > > +
> > > > +	if (!g_key_file_load_from_file(key_file, ANDROID_STORAGEDIR"/settings",
> > > > +								0, NULL)) {
> > > > +		int fd = open(ANDROID_STORAGEDIR"/settings", O_CREAT, 0600);
> > > > +		if (fd < 0) {
> > > > +			error("Failed to create adapter config file: %d (%s)",
> > > > +							errno, strerror(errno));
> > > > +			return;
> > > > +		}
> > > > +
> > > > +		close(fd);
> > > > +	}
> > > > +
> > > > +	ba2str(&adapter.bdaddr, addr);
> > > > +
> > > > +	g_key_file_set_string(key_file, "General", "Address", addr);
> > > > +	g_key_file_set_string(key_file, "General", "Name", adapter.name);
> > > > +	g_key_file_set_integer(key_file, "General", "DiscoverableTimeout",
> > > > +						adapter.discoverable_timeout);
> > > > +
> > > > +	data = g_key_file_to_data(key_file, &length, NULL);
> > > > +
> > > > +	g_file_set_contents(ANDROID_STORAGEDIR"/settings", data, length, NULL);
> > > 
> > > The whole open(..., O_CREAT, ...) trick you do seems completely
> > > unnecessary as g_key_file_to_data will create the file if it doesn't
> > > exist. Instead, if you want to log an error you'd need to check if
> > > g_key_file_contents failed or not. Adding a GError into the mix and
> > > logging the exact error message would be even better.
> > 
> > This was done only to make sure proper permissions are used for file. Since
> > glib doens't offer any API (at least I couldn't find any) for that in g_file_*
> > (other than wrappers to standard unix calls)
> 
> What permissions does the file get created with if you omit this? Maybe
> the right fix is to set the umask explicitly in our main() or to modify
> how the daemon gets executed?

It was 0600 on Android so it looks like Android init is setting good mask, but
it was 0644 on Linux host.

I suppose we could fix system-emulator to set umask to have correct permissions
on host.

Will send V2.

-- 
BR
Szymon Janc



^ permalink raw reply

* RE: [PATCH] android/pts: Add PICS, PIXITs and PTS for L2CAP
From: Chlad, SebastianX @ 2013-12-19  9:45 UTC (permalink / raw)
  To: Szymon Janc, Sebastian Chlad
  Cc: Hedberg, Johan, linux-bluetooth@vger.kernel.org
In-Reply-To: <16520238.3ybnibyTNs@uw000953>


________________________________________
From: Szymon Janc [szymon.janc@tieto.com]
Sent: Thursday, December 19, 2013 11:42 AM
To: Sebastian Chlad
Cc: Hedberg, Johan; linux-bluetooth@vger.kernel.org; Chlad, SebastianX
Subject: Re: [PATCH] android/pts: Add PICS, PIXITs and PTS for L2CAP

Hi Sebastian,

> This allows better tracking of the current state of implementation
> ---
>  android/Makefile.am     |   4 +-
>  android/pics-l2cap.txt  | 157 ++++++++++++++++++++++++++++++++++++++++++++++++
>  android/pixit-l2cap.txt |  39 ++++++++++++
>  android/pts-l2cap.txt   | 149 +++++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 348 insertions(+), 1 deletion(-)
>  create mode 100644 android/pics-l2cap.txt
>  create mode 100644 android/pixit-l2cap.txt
>  create mode 100644 android/pts-l2cap.txt
>

This one doesn't apply:

yes, indeed. I'll correct that. 

Seb

Applying: android/pts: Add PICS, PIXITs and PTS for L2CAP
error: patch failed: android/Makefile.am:111
error: android/Makefile.am: patch does not apply
/home/janccszy/devel/bluez/.git/rebase-apply/patch:385: new blank line at EOF.

--
BR
Szymon Janc
---------------------------------------------------------------------
Intel Finland Oy
Registered Address: PL 281, 00181 Helsinki 
Business Identity Code: 0357606 - 4 
Domiciled in Helsinki 

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.


^ permalink raw reply

* Re: [PATCH] android/pts: Add PICS, PIXITs and PTS for L2CAP
From: Szymon Janc @ 2013-12-19  9:42 UTC (permalink / raw)
  To: Sebastian Chlad; +Cc: johan.hedberg, linux-bluetooth, Sebastian Chlad
In-Reply-To: <1387444450-1511-1-git-send-email-sebastianx.chlad@intel.com>

Hi Sebastian,

> This allows better tracking of the current state of implementation
> ---
>  android/Makefile.am     |   4 +-
>  android/pics-l2cap.txt  | 157 ++++++++++++++++++++++++++++++++++++++++++++++++
>  android/pixit-l2cap.txt |  39 ++++++++++++
>  android/pts-l2cap.txt   | 149 +++++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 348 insertions(+), 1 deletion(-)
>  create mode 100644 android/pics-l2cap.txt
>  create mode 100644 android/pixit-l2cap.txt
>  create mode 100644 android/pts-l2cap.txt
> 

This one doesn't apply:

Applying: android/pts: Add PICS, PIXITs and PTS for L2CAP
error: patch failed: android/Makefile.am:111
error: android/Makefile.am: patch does not apply
/home/janccszy/devel/bluez/.git/rebase-apply/patch:385: new blank line at EOF.

-- 
BR
Szymon Janc

^ permalink raw reply

* Re: [PATCH] android/build: Adding l2test to Android.mk
From: Szymon Janc @ 2013-12-19  9:33 UTC (permalink / raw)
  To: Sebastian Chlad; +Cc: linux-bluetooth, Sebastian Chlad
In-Reply-To: <1387443982-1017-1-git-send-email-sebastianx.chlad@intel.com>

Hi Sebastian,

> Enabling l2test tool for the android target
> ---
>  android/Android.mk | 28 ++++++++++++++++++++++++++++
>  1 file changed, 28 insertions(+)
> 
> diff --git a/android/Android.mk b/android/Android.mk
> index ebc3219..c59df7a 100644
> --- a/android/Android.mk
> +++ b/android/Android.mk
> @@ -226,3 +226,31 @@ LOCAL_MODULE_TAGS := optional
>  LOCAL_MODULE := audio.a2dp.default
>  
>  include $(BUILD_SHARED_LIBRARY)
> +
> +#
> +# l2cap-test
> +#
> +
> +include $(CLEAR_VARS)
> +
> +LOCAL_SRC_FILES := \
> +	../tools/l2test.c \
> +	../lib/bluetooth.c \
> +	../lib/hci.c \
> +
> +lib_headers := \
> +	../lib/bluetooth.h \
> +	../lib/l2cap.h \

This lib_header is not needed, please remove it.

> +
> +LOCAL_C_INCLUDES := \
> +	$(LOCAL_PATH)/.. \
> +	$(LOCAL_PATH)/../lib \
> +	$(LOCAL_PATH)/../src/shared \
> +
> +LOCAL_CFLAGS := $(BLUEZ_COMMON_CFLAGS)
> +
> +LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
> +LOCAL_MODULE_TAGS := eng
> +LOCAL_MODULE := l2test
> +
> +include $(BUILD_EXECUTABLE)
> 

Also please don't use gerund form in commit message ie. Adding -> Add.

-- 
BR
Szymon Janc

^ permalink raw reply

* [PATCH 6/6] tools/l2cap_tester: Add write server test case
From: Marcin Kraglak @ 2013-12-19  9:30 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1387445406-20324-1-git-send-email-marcin.kraglak@tieto.com>

These test case send data from local server to remote client.
---
 tools/l2cap-tester.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/tools/l2cap-tester.c b/tools/l2cap-tester.c
index ebf2191..b0f3ad2 100644
--- a/tools/l2cap-tester.c
+++ b/tools/l2cap-tester.c
@@ -297,6 +297,16 @@ static const struct l2cap_server_data l2cap_server_read_success_test = {
 	.data_len = sizeof(l2_data),
 };
 
+static const struct l2cap_server_data l2cap_server_write_success_test = {
+	.server_psm = 0x1001,
+	.send_req_code = BT_L2CAP_PDU_CONN_REQ,
+	.send_req = l2cap_connect_req,
+	.send_req_len = sizeof(l2cap_connect_req),
+	.expect_rsp_code = BT_L2CAP_PDU_CONN_RSP,
+	.write_data = l2_data,
+	.data_len = sizeof(l2_data),
+};
+
 static const uint8_t l2cap_nval_psm_rsp[] = {	0x00, 0x00,	/* dcid */
 						0x41, 0x00,	/* scid */
 						0x02, 0x00,	/* nval PSM */
@@ -547,6 +557,23 @@ static void bthost_received_data(const void *buf, uint16_t len,
 		tester_test_passed();
 }
 
+static void server_bthost_received_data(const void *buf, uint16_t len,
+							void *user_data)
+{
+	struct test_data *data = tester_get_data();
+	const struct l2cap_server_data *l2data = data->test_data;
+
+	if (len != l2data->data_len) {
+		tester_test_failed();
+		return;
+	}
+
+	if (memcmp(buf, l2data->write_data, l2data->data_len))
+		tester_test_failed();
+	else
+		tester_test_passed();
+}
+
 static gboolean l2cap_connect_cb(GIOChannel *io, GIOCondition cond,
 							gpointer user_data)
 {
@@ -753,6 +780,17 @@ static gboolean l2cap_listen_cb(GIOChannel *io, GIOCondition cond,
 					l2data->read_data, l2data->data_len);
 
 		return FALSE;
+	} else if (l2data->write_data) {
+		struct bthost *bthost;
+
+		bthost = hciemu_client_get_host(data->hciemu);
+		bthost_add_cid_hook(bthost, data->handle, data->scid,
+					server_bthost_received_data, NULL);
+
+		write(new_sk, l2data->write_data, l2data->data_len);
+		close(new_sk);
+
+		return FALSE;
 	}
 
 	tester_print("Successfully connected");
@@ -925,6 +963,10 @@ int main(int argc, char *argv[])
 					&l2cap_server_read_success_test,
 					setup_powered_server, test_server);
 
+	test_l2cap_bredr("L2CAP BR/EDR Server - Write Success",
+					&l2cap_server_write_success_test,
+					setup_powered_server, test_server);
+
 	test_l2cap_bredr("L2CAP BR/EDR Server - Invalid PSM",
 					&l2cap_server_nval_psm_test,
 					setup_powered_server, test_server);
-- 
1.8.3.1


^ permalink raw reply related

* [PATCH 5/6] tools/l2cap_tester: Add read server test case
From: Marcin Kraglak @ 2013-12-19  9:30 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1387445406-20324-1-git-send-email-marcin.kraglak@tieto.com>

This test checks data transfer from remote client to server.
---
 tools/l2cap-tester.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 69 insertions(+)

diff --git a/tools/l2cap-tester.c b/tools/l2cap-tester.c
index 7f37de3..ebf2191 100644
--- a/tools/l2cap-tester.c
+++ b/tools/l2cap-tester.c
@@ -72,6 +72,9 @@ struct l2cap_server_data {
 	uint8_t expect_rsp_code;
 	const void *expect_rsp;
 	uint16_t expect_rsp_len;
+	uint16_t data_len;
+	const void *read_data;
+	const void *write_data;
 };
 
 static void mgmt_debug(const char *str, void *user_data)
@@ -284,6 +287,16 @@ static const struct l2cap_server_data l2cap_server_success_test = {
 	.expect_rsp_code = BT_L2CAP_PDU_CONN_RSP,
 };
 
+static const struct l2cap_server_data l2cap_server_read_success_test = {
+	.server_psm = 0x1001,
+	.send_req_code = BT_L2CAP_PDU_CONN_REQ,
+	.send_req = l2cap_connect_req,
+	.send_req_len = sizeof(l2cap_connect_req),
+	.expect_rsp_code = BT_L2CAP_PDU_CONN_RSP,
+	.read_data = l2_data,
+	.data_len = sizeof(l2_data),
+};
+
 static const uint8_t l2cap_nval_psm_rsp[] = {	0x00, 0x00,	/* dcid */
 						0x41, 0x00,	/* scid */
 						0x02, 0x00,	/* nval PSM */
@@ -496,6 +509,27 @@ static gboolean client_received_data(GIOChannel *io, GIOCondition cond,
 	return FALSE;
 }
 
+static gboolean server_received_data(GIOChannel *io, GIOCondition cond,
+							gpointer user_data)
+{
+	struct test_data *data = tester_get_data();
+	const struct l2cap_server_data *l2data = data->test_data;
+	char buf[1024];
+	int sk;
+
+	sk = g_io_channel_unix_get_fd(io);
+	read(sk, buf, l2data->data_len);
+
+	if (memcmp(buf, l2data->read_data, l2data->data_len))
+		tester_test_failed();
+	else
+		tester_test_passed();
+
+	close(sk);
+
+	return FALSE;
+}
+
 static void bthost_received_data(const void *buf, uint16_t len,
 							void *user_data)
 {
@@ -693,6 +727,7 @@ static gboolean l2cap_listen_cb(GIOChannel *io, GIOCondition cond,
 							gpointer user_data)
 {
 	struct test_data *data = tester_get_data();
+	const struct l2cap_server_data *l2data = data->test_data;
 	int sk, new_sk;
 
 	data->io_id = 0;
@@ -706,6 +741,20 @@ static gboolean l2cap_listen_cb(GIOChannel *io, GIOCondition cond,
 		return FALSE;
 	}
 
+	if (l2data->read_data) {
+		struct bthost *bthost;
+		GIOChannel *new_io;
+
+		new_io = g_io_channel_unix_new(new_sk);
+
+		bthost = hciemu_client_get_host(data->hciemu);
+		g_io_add_watch(new_io, G_IO_IN, server_received_data, NULL);
+		bthost_send_cid(bthost, data->handle, data->dcid,
+					l2data->read_data, l2data->data_len);
+
+		return FALSE;
+	}
+
 	tester_print("Successfully connected");
 
 	close(new_sk);
@@ -729,6 +778,19 @@ static void client_l2cap_rsp(uint8_t code, const void *data, uint16_t len,
 		goto failed;
 	}
 
+	if (code == BT_L2CAP_PDU_CONN_RSP) {
+
+		const struct bt_l2cap_pdu_conn_rsp *rsp = data;
+		if (len == sizeof(rsp) && !rsp->result && !rsp->status)
+			return;
+
+		test_data->dcid = rsp->dcid;
+		test_data->scid = rsp->scid;
+
+		if (l2data->data_len)
+			return;
+	}
+
 	if (!l2data->expect_rsp) {
 		tester_test_passed();
 		return;
@@ -760,6 +822,8 @@ static void client_new_conn(uint16_t handle, void *user_data)
 
 	tester_print("New client connection with handle 0x%04x", handle);
 
+	data->handle = handle;
+
 	if (l2data->send_req) {
 		bthost_l2cap_rsp_cb cb;
 
@@ -856,6 +920,11 @@ int main(int argc, char *argv[])
 	test_l2cap_bredr("L2CAP BR/EDR Server - Success",
 					&l2cap_server_success_test,
 					setup_powered_server, test_server);
+
+	test_l2cap_bredr("L2CAP BR/EDR Server - Read Success",
+					&l2cap_server_read_success_test,
+					setup_powered_server, test_server);
+
 	test_l2cap_bredr("L2CAP BR/EDR Server - Invalid PSM",
 					&l2cap_server_nval_psm_test,
 					setup_powered_server, test_server);
-- 
1.8.3.1


^ permalink raw reply related

* [PATCH 4/6] tools/l2cap_tester: Add write client test case
From: Marcin Kraglak @ 2013-12-19  9:30 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1387445406-20324-1-git-send-email-marcin.kraglak@tieto.com>

This test case write data from client to remote server.
---
 tools/l2cap-tester.c | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/tools/l2cap-tester.c b/tools/l2cap-tester.c
index 1d00c93..7f37de3 100644
--- a/tools/l2cap-tester.c
+++ b/tools/l2cap-tester.c
@@ -262,6 +262,13 @@ static const struct  l2cap_client_data client_connect_read_success_test = {
 	.data_len = sizeof(l2_data),
 };
 
+static const struct  l2cap_client_data client_connect_write_success_test = {
+	.client_psm = 0x1001,
+	.server_psm = 0x1001,
+	.write_data = l2_data,
+	.data_len = sizeof(l2_data),
+};
+
 static const struct l2cap_client_data client_connect_nval_psm_test = {
 	.client_psm = 0x1001,
 	.expect_err = ECONNREFUSED,
@@ -489,6 +496,23 @@ static gboolean client_received_data(GIOChannel *io, GIOCondition cond,
 	return FALSE;
 }
 
+static void bthost_received_data(const void *buf, uint16_t len,
+							void *user_data)
+{
+	struct test_data *data = tester_get_data();
+	const struct l2cap_client_data *l2data = data->test_data;
+
+	if (len != l2data->data_len) {
+		tester_test_failed();
+		return;
+	}
+
+	if (memcmp(buf, l2data->write_data, l2data->data_len))
+		tester_test_failed();
+	else
+		tester_test_passed();
+}
+
 static gboolean l2cap_connect_cb(GIOChannel *io, GIOCondition cond,
 							gpointer user_data)
 {
@@ -521,6 +545,16 @@ static gboolean l2cap_connect_cb(GIOChannel *io, GIOCondition cond,
 					l2data->read_data, l2data->data_len);
 
 		return FALSE;
+	} else if (l2data->write_data) {
+		struct bthost *bthost;
+
+		bthost = hciemu_client_get_host(data->hciemu);
+		bthost_add_cid_hook(bthost, data->handle, data->dcid,
+					bthost_received_data, NULL);
+
+		write(sk, l2data->write_data, l2data->data_len);
+
+		return FALSE;
 	}
 
 	if (-err != l2data->expect_err)
@@ -811,6 +845,10 @@ int main(int argc, char *argv[])
 					&client_connect_read_success_test,
 					setup_powered_client, test_connect);
 
+	test_l2cap_bredr("L2CAP BR/EDR Client - Write Success",
+					&client_connect_write_success_test,
+					setup_powered_client, test_connect);
+
 	test_l2cap_bredr("L2CAP BR/EDR Client - Invalid PSM",
 					&client_connect_nval_psm_test,
 					setup_powered_client, test_connect);
-- 
1.8.3.1


^ permalink raw reply related

* [PATCH 3/6] tools/l2cap_tester: Add read client test case
From: Marcin Kraglak @ 2013-12-19  9:30 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1387445406-20324-1-git-send-email-marcin.kraglak@tieto.com>

This test case send data from remote device to client.
It verifies if data is passed corerctly through l2cap socket.
---
 tools/l2cap-tester.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 68 insertions(+), 1 deletion(-)

diff --git a/tools/l2cap-tester.c b/tools/l2cap-tester.c
index 9161953..1d00c93 100644
--- a/tools/l2cap-tester.c
+++ b/tools/l2cap-tester.c
@@ -50,12 +50,18 @@ struct test_data {
 	struct hciemu *hciemu;
 	enum hciemu_type hciemu_type;
 	unsigned int io_id;
+	uint16_t handle;
+	uint16_t scid;
+	uint16_t dcid;
 };
 
 struct l2cap_client_data {
 	uint16_t client_psm;
 	uint16_t server_psm;
 	int expect_err;
+	uint16_t data_len;
+	const void *read_data;
+	const void *write_data;
 };
 
 struct l2cap_server_data {
@@ -247,6 +253,15 @@ static const struct l2cap_client_data client_connect_success_test = {
 	.server_psm = 0x1001,
 };
 
+static uint8_t l2_data[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 };
+
+static const struct  l2cap_client_data client_connect_read_success_test = {
+	.client_psm = 0x1001,
+	.server_psm = 0x1001,
+	.read_data = l2_data,
+	.data_len = sizeof(l2_data),
+};
+
 static const struct l2cap_client_data client_connect_nval_psm_test = {
 	.client_psm = 0x1001,
 	.expect_err = ECONNREFUSED,
@@ -455,6 +470,25 @@ static void test_basic(const void *test_data)
 	tester_test_passed();
 }
 
+static gboolean client_received_data(GIOChannel *io, GIOCondition cond,
+							gpointer user_data)
+{
+	struct test_data *data = tester_get_data();
+	const struct l2cap_client_data *l2data = data->test_data;
+	char buf[1024];
+	int sk;
+
+	sk = g_io_channel_unix_get_fd(io);
+	read(sk, buf, l2data->data_len);
+
+	if (memcmp(buf, l2data->read_data, l2data->data_len))
+		tester_test_failed();
+	else
+		tester_test_passed();
+
+	return FALSE;
+}
+
 static gboolean l2cap_connect_cb(GIOChannel *io, GIOCondition cond,
 							gpointer user_data)
 {
@@ -477,6 +511,18 @@ static gboolean l2cap_connect_cb(GIOChannel *io, GIOCondition cond,
 	else
 		tester_print("Successfully connected");
 
+	if (l2data->read_data) {
+		struct bthost *bthost;
+
+		bthost = hciemu_client_get_host(data->hciemu);
+		g_io_add_watch(io, G_IO_IN, client_received_data, NULL);
+
+		bthost_send_cid(bthost, data->handle, data->dcid,
+					l2data->read_data, l2data->data_len);
+
+		return FALSE;
+	}
+
 	if (-err != l2data->expect_err)
 		tester_test_failed();
 	else
@@ -559,6 +605,15 @@ static int connect_l2cap_sock(struct test_data *data, int sk, uint16_t psm)
 	return 0;
 }
 
+static void client_l2cap_connect_cb(uint16_t handle, uint16_t cid,
+							void *user_data)
+{
+	struct test_data *data = user_data;
+
+	data->dcid = cid;
+	data->handle = handle;
+}
+
 static void test_connect(const void *test_data)
 {
 	struct test_data *data = tester_get_data();
@@ -568,7 +623,14 @@ static void test_connect(const void *test_data)
 
 	if (l2data->server_psm) {
 		struct bthost *bthost = hciemu_client_get_host(data->hciemu);
-		bthost_set_server_psm(bthost, l2data->server_psm, NULL, NULL);
+		bthost_l2cap_connect_cb cb;
+
+		if (l2data->data_len)
+			cb = client_l2cap_connect_cb;
+		else
+			cb = NULL;
+
+		bthost_set_server_psm(bthost, l2data->server_psm, cb, data);
 	}
 
 	sk = create_l2cap_sock(data, 0);
@@ -744,6 +806,11 @@ int main(int argc, char *argv[])
 	test_l2cap_bredr("L2CAP BR/EDR Client - Success",
 					&client_connect_success_test,
 					setup_powered_client, test_connect);
+
+	test_l2cap_bredr("L2CAP BR/EDR Client - Read Success",
+					&client_connect_read_success_test,
+					setup_powered_client, test_connect);
+
 	test_l2cap_bredr("L2CAP BR/EDR Client - Invalid PSM",
 					&client_connect_nval_psm_test,
 					setup_powered_client, test_connect);
-- 
1.8.3.1


^ permalink raw reply related

* [PATCH 2/6] emulator: Add connect callback when setting l2cap server
From: Marcin Kraglak @ 2013-12-19  9:30 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1387445406-20324-1-git-send-email-marcin.kraglak@tieto.com>

Add possibility to set connect callback when client will be
connected to bthost l2cap server.
---
 emulator/bthost.c    | 36 +++++++++++++++++++++++++++++++++++-
 emulator/bthost.h    |  5 ++++-
 tools/l2cap-tester.c |  2 +-
 3 files changed, 40 insertions(+), 3 deletions(-)

diff --git a/emulator/bthost.c b/emulator/bthost.c
index 430108e..b5852f3 100644
--- a/emulator/bthost.c
+++ b/emulator/bthost.c
@@ -90,6 +90,12 @@ struct l2cap_pending_req {
 	struct l2cap_pending_req *next;
 };
 
+struct l2cap_conn_cb_data {
+	uint16_t psm;
+	bthost_l2cap_connect_cb func;
+	void *user_data;
+};
+
 struct bthost {
 	uint8_t bdaddr[6];
 	bthost_send_func send_handler;
@@ -101,6 +107,7 @@ struct bthost {
 	void *cmd_complete_data;
 	bthost_new_conn_cb new_conn_cb;
 	void *new_conn_data;
+	struct l2cap_conn_cb_data *new_l2cap_conn_data;
 	uint16_t server_psm;
 	struct l2cap_pending_req *l2reqs;
 };
@@ -214,6 +221,8 @@ void bthost_destroy(struct bthost *bthost)
 		free(req);
 	}
 
+	free(bthost->new_l2cap_conn_data);
+
 	free(bthost);
 }
 
@@ -747,6 +756,8 @@ static bool l2cap_conn_req(struct bthost *bthost, struct btconn *conn,
 
 	if (!rsp.result) {
 		struct bt_l2cap_pdu_config_req conf_req;
+		struct l2cap_conn_cb_data *cb_data;
+		struct l2conn *l2conn;
 
 		bthost_add_l2cap_conn(bthost, conn, le16_to_cpu(rsp.dcid),
 							le16_to_cpu(rsp.scid),
@@ -757,6 +768,14 @@ static bool l2cap_conn_req(struct bthost *bthost, struct btconn *conn,
 
 		l2cap_sig_send(bthost, conn, BT_L2CAP_PDU_CONFIG_REQ, 0,
 						&conf_req, sizeof(conf_req));
+
+		cb_data = bthost->new_l2cap_conn_data;
+		l2conn  = btconn_find_l2cap_conn_by_scid(conn,
+							le16_to_cpu(rsp.scid));
+
+		if (cb_data && l2conn->psm == cb_data->psm)
+			cb_data->func(conn->handle, l2conn->dcid,
+							cb_data->user_data);
 	}
 
 	return true;
@@ -1249,9 +1268,24 @@ void bthost_le_start_encrypt(struct bthost *bthost, uint16_t handle,
 	send_command(bthost, BT_HCI_CMD_LE_START_ENCRYPT, &cmd, sizeof(cmd));
 }
 
-void bthost_set_server_psm(struct bthost *bthost, uint16_t psm)
+void bthost_set_server_psm(struct bthost *bthost, uint16_t psm,
+				bthost_l2cap_connect_cb func, void *user_data)
 {
 	bthost->server_psm = psm;
+
+	if (func) {
+		struct l2cap_conn_cb_data *data;
+
+		data = malloc(sizeof(struct l2cap_conn_cb_data));
+		if (!data)
+			return;
+
+		data->psm = psm;
+		data->user_data = user_data;
+		data->func = func;
+
+		bthost->new_l2cap_conn_data = data;
+	}
 }
 
 void bthost_start(struct bthost *bthost)
diff --git a/emulator/bthost.h b/emulator/bthost.h
index 474ada9..1d4f7f2 100644
--- a/emulator/bthost.h
+++ b/emulator/bthost.h
@@ -74,8 +74,11 @@ void bthost_set_adv_enable(struct bthost *bthost, uint8_t enable);
 
 void bthost_le_start_encrypt(struct bthost *bthost, uint16_t handle,
 							const uint8_t ltk[16]);
+typedef void (*bthost_l2cap_connect_cb) (uint16_t handle, uint16_t cid,
+							void *user_data);
 
-void bthost_set_server_psm(struct bthost *bthost, uint16_t psm);
+void bthost_set_server_psm(struct bthost *bthost, uint16_t psm,
+				bthost_l2cap_connect_cb func, void *user_data);
 
 void bthost_start(struct bthost *bthost);
 void bthost_stop(struct bthost *bthost);
diff --git a/tools/l2cap-tester.c b/tools/l2cap-tester.c
index e4dade2..9161953 100644
--- a/tools/l2cap-tester.c
+++ b/tools/l2cap-tester.c
@@ -568,7 +568,7 @@ static void test_connect(const void *test_data)
 
 	if (l2data->server_psm) {
 		struct bthost *bthost = hciemu_client_get_host(data->hciemu);
-		bthost_set_server_psm(bthost, l2data->server_psm);
+		bthost_set_server_psm(bthost, l2data->server_psm, NULL, NULL);
 	}
 
 	sk = create_l2cap_sock(data, 0);
-- 
1.8.3.1


^ permalink raw reply related

* [PATCH 1/6] emulator: Add psm handling to bthost
From: Marcin Kraglak @ 2013-12-19  9:30 UTC (permalink / raw)
  To: linux-bluetooth

Store psm of l2cap connections. We retrieve psm from
connection request frame.
---
 emulator/bthost.c | 29 +++++++++++++++++++++++------
 1 file changed, 23 insertions(+), 6 deletions(-)

diff --git a/emulator/bthost.c b/emulator/bthost.c
index b05072a..430108e 100644
--- a/emulator/bthost.c
+++ b/emulator/bthost.c
@@ -79,6 +79,7 @@ struct btconn {
 struct l2conn {
 	uint16_t scid;
 	uint16_t dcid;
+	uint16_t psm;
 	struct l2conn *next;
 };
 
@@ -154,7 +155,8 @@ static struct btconn *bthost_find_conn(struct bthost *bthost, uint16_t handle)
 }
 
 static void bthost_add_l2cap_conn(struct bthost *bthost, struct btconn *conn,
-						uint16_t scid, uint16_t dcid)
+						uint16_t scid, uint16_t dcid,
+						uint16_t psm)
 {
 	struct l2conn *l2conn;
 
@@ -164,6 +166,7 @@ static void bthost_add_l2cap_conn(struct bthost *bthost, struct btconn *conn,
 
 	memset(l2conn, 0, sizeof(*l2conn));
 
+	l2conn->psm = psm;
 	l2conn->scid = scid;
 	l2conn->dcid = dcid;
 
@@ -376,6 +379,15 @@ bool bthost_l2cap_req(struct bthost *bthost, uint16_t handle, uint8_t code,
 	if (!conn)
 		return false;
 
+	if (code == BT_L2CAP_PDU_CONN_REQ &&
+			len == sizeof(struct bt_l2cap_pdu_conn_req)) {
+		const struct bt_l2cap_pdu_conn_req *req = data;
+
+		bthost_add_l2cap_conn(bthost, conn, le16_to_cpu(req->scid),
+							le16_to_cpu(req->scid),
+							le16_to_cpu(req->psm));
+	}
+
 	ident = l2cap_sig_send(bthost, conn, code, 0, data, len);
 	if (!ident)
 		return false;
@@ -737,7 +749,8 @@ static bool l2cap_conn_req(struct bthost *bthost, struct btconn *conn,
 		struct bt_l2cap_pdu_config_req conf_req;
 
 		bthost_add_l2cap_conn(bthost, conn, le16_to_cpu(rsp.dcid),
-							le16_to_cpu(rsp.scid));
+							le16_to_cpu(rsp.scid),
+							le16_to_cpu(psm));
 
 		memset(&conf_req, 0, sizeof(conf_req));
 		conf_req.dcid = rsp.dcid;
@@ -753,12 +766,16 @@ static bool l2cap_conn_rsp(struct bthost *bthost, struct btconn *conn,
 				uint8_t ident, const void *data, uint16_t len)
 {
 	const struct bt_l2cap_pdu_conn_rsp *rsp = data;
+	struct l2conn *l2conn;
 
 	if (len < sizeof(*rsp))
 		return false;
 
-	bthost_add_l2cap_conn(bthost, conn, le16_to_cpu(rsp->scid),
-						le16_to_cpu(rsp->dcid));
+	l2conn = btconn_find_l2cap_conn_by_scid(conn, le16_to_cpu(rsp->scid));
+	if (l2conn)
+		l2conn->dcid = le16_to_cpu(rsp->dcid);
+	else
+		return false;
 
 	if (le16_to_cpu(rsp->result) == 0x0001) {
 		struct bt_l2cap_pdu_config_req req;
@@ -1013,8 +1030,8 @@ static bool l2cap_le_conn_rsp(struct bthost *bthost, struct btconn *conn,
 
 	if (len < sizeof(*rsp))
 		return false;
-
-	bthost_add_l2cap_conn(bthost, conn, 0, le16_to_cpu(rsp->dcid));
+	/* TODO add l2cap connection before with proper psm */
+	bthost_add_l2cap_conn(bthost, conn, 0, le16_to_cpu(rsp->dcid), 0);
 
 	return true;
 }
-- 
1.8.3.1


^ permalink raw reply related

* [PATCH_v5 1/5] android/pan: shutdown io channel on disconnect call
From: Ravi kumar Veeramally @ 2013-12-19  9:15 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Ravi kumar Veeramally

Shutdown io channel and send DISCONNECTING notification and send
DISCONNECTED notification and free the device on callback.
---
 android/pan.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/android/pan.c b/android/pan.c
index b83f534..187953b 100644
--- a/android/pan.c
+++ b/android/pan.c
@@ -284,14 +284,16 @@ static void bt_pan_disconnect(const void *buf, uint16_t len)
 	}
 
 	dev = l->data;
-	if (dev->watch) {
-		g_source_remove(dev->watch);
-		dev->watch = 0;
+
+	if (dev->io)
+		g_io_channel_shutdown(dev->io, TRUE, NULL);
+
+	if (dev->conn_state == HAL_PAN_STATE_CONNECTED) {
+		bnep_if_down(dev->iface);
+		bnep_conndel(&dst);
 	}
 
-	bnep_if_down(dev->iface);
-	bnep_conndel(&dst);
-	bt_pan_notify_conn_state(dev, HAL_PAN_STATE_DISCONNECTED);
+	bt_pan_notify_conn_state(dev, HAL_PAN_STATE_DISCONNECTING);
 	status = HAL_STATUS_SUCCESS;
 
 failed:
-- 
1.8.3.2


^ permalink raw reply related

* Re: [PATCH 1/4] android/bluetooth: Add initial support for permanent storage
From: Johan Hedberg @ 2013-12-19  9:14 UTC (permalink / raw)
  To: Szymon Janc; +Cc: linux-bluetooth
In-Reply-To: <8514937.6olCGu9n2J@uw000953>

Hi Szymon,

On Thu, Dec 19, 2013, Szymon Janc wrote:
> > On Wed, Dec 18, 2013, Szymon Janc wrote:
> > > +static void store_adapter_config(void)
> > > +{
> > > +	GKeyFile *key_file;
> > > +	gsize length = 0;
> > > +	char addr[18];
> > > +	char *data;
> > > +
> > > +	key_file = g_key_file_new();
> > > +
> > > +	if (!g_key_file_load_from_file(key_file, ANDROID_STORAGEDIR"/settings",
> > > +								0, NULL)) {
> > > +		int fd = open(ANDROID_STORAGEDIR"/settings", O_CREAT, 0600);
> > > +		if (fd < 0) {
> > > +			error("Failed to create adapter config file: %d (%s)",
> > > +							errno, strerror(errno));
> > > +			return;
> > > +		}
> > > +
> > > +		close(fd);
> > > +	}
> > > +
> > > +	ba2str(&adapter.bdaddr, addr);
> > > +
> > > +	g_key_file_set_string(key_file, "General", "Address", addr);
> > > +	g_key_file_set_string(key_file, "General", "Name", adapter.name);
> > > +	g_key_file_set_integer(key_file, "General", "DiscoverableTimeout",
> > > +						adapter.discoverable_timeout);
> > > +
> > > +	data = g_key_file_to_data(key_file, &length, NULL);
> > > +
> > > +	g_file_set_contents(ANDROID_STORAGEDIR"/settings", data, length, NULL);
> > 
> > The whole open(..., O_CREAT, ...) trick you do seems completely
> > unnecessary as g_key_file_to_data will create the file if it doesn't
> > exist. Instead, if you want to log an error you'd need to check if
> > g_key_file_contents failed or not. Adding a GError into the mix and
> > logging the exact error message would be even better.
> 
> This was done only to make sure proper permissions are used for file. Since
> glib doens't offer any API (at least I couldn't find any) for that in g_file_*
> (other than wrappers to standard unix calls)

What permissions does the file get created with if you omit this? Maybe
the right fix is to set the umask explicitly in our main() or to modify
how the daemon gets executed?

Johan

^ permalink raw reply

* [PATCH] android/pts: Add PICS, PIXITs and PTS for L2CAP
From: Sebastian Chlad @ 2013-12-19  9:14 UTC (permalink / raw)
  To: johan.hedberg; +Cc: linux-bluetooth, Sebastian Chlad
In-Reply-To: <2115852EF878384FA984E6B76A9F379E164297@IRSMSX104.ger.corp.intel.com>

This allows better tracking of the current state of implementation
---
 android/Makefile.am     |   4 +-
 android/pics-l2cap.txt  | 157 ++++++++++++++++++++++++++++++++++++++++++++++++
 android/pixit-l2cap.txt |  39 ++++++++++++
 android/pts-l2cap.txt   | 149 +++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 348 insertions(+), 1 deletion(-)
 create mode 100644 android/pics-l2cap.txt
 create mode 100644 android/pixit-l2cap.txt
 create mode 100644 android/pts-l2cap.txt

diff --git a/android/Makefile.am b/android/Makefile.am
index 79f30d7..b459102 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -111,4 +111,6 @@ EXTRA_DIST += android/Android.mk android/hal-ipc-api.txt android/README \
 		android/pixit-gap.txt android/pixit-hid.txt \
 		android/pixit-opp.txt android/pixit-pan.txt \
 		android/pixit-pbap.txt android/pts-gap.txt android/pts-hid.txt \
-		android/pts-opp.txt android/pts-pbap.txt
+		android/pts-opp.txt android/pts-pbap.txt \
+		android/pics-l2cap.txt android/pixit-l2cap.txt \
+		android/pts-l2cap.txt
diff --git a/android/pics-l2cap.txt b/android/pics-l2cap.txt
new file mode 100644
index 0000000..ef25133
--- /dev/null
+++ b/android/pics-l2cap.txt
@@ -0,0 +1,157 @@
+L2CAP PICS for the PTS tool.
+
+* - different than PTS defaults
+# - not yet implemented/supported
+
+M - mandatory
+O - optional
+
+		Roles
+-------------------------------------------------------------------------------
+Parameter Name	Selected	Description
+-------------------------------------------------------------------------------
+TSPC_L2CAP_1_1	True		Data Channel Initiator (C.1)
+TSPC_L2CAP_1_2	True		Data Channel Acceptor (C.1)
+TSPC_L2CAP_1_3	True (#)	LE Master (C.2)
+TSPC_L2CAP_1_4	True (#)	LE Slave (C.2)
+-------------------------------------------------------------------------------
+C.1: Mandatory IF BR/EDR or BR/EDR/LE is claimed, ELSE Excluded.
+C.2: Mandatory to support (at least one of TSPC_L2CAP_1_3 or TSPC_L2CAP_1_4)
+	IF LE or BR/EDR/LE claimed, ELSE Excluded.
+-------------------------------------------------------------------------------
+
+
+		General Operation
+-------------------------------------------------------------------------------
+Parameter Name	Selected	Description
+-------------------------------------------------------------------------------
+TSPC_L2CAP_2_1	True		Support of L2CAP signaling channel (C.20)
+TSPC_L2CAP_2_2	True		Support of configuration process (C.20)
+TSPC_L2CAP_2_4	True		Support of command echo request (C.21)
+TSPC_L2CAP_2_3  True            Support of connection oriented data
+                                        channel (C.20)
+TSPC_L2CAP_2_5	True		Support of command echo response (C.20)
+TSPC_L2CAP_2_6	True (*)	Support of command information request (C.21)
+TSPC_L2CAP_2_7	True		Support of command information response (C.20)
+TSPC_L2CAP_2_8	False		Support of a channel group (C.21)
+TSPC_L2CAP_2_9	False		Support of packet for connectionless
+					channel (C.21)
+TSPC_L2CAP_2_10	False		Support retransmission mode (C.21)
+TSPC_L2CAP_2_11	False		Support flow control mode(C.21)
+TSPC_L2CAP_2_12	True (*)	Enhanced Retransmission Mode (C.1, C.13)
+TSPC_L2CAP_2_13	True (*)	Streaming Mode (C.1, C.14)
+TSPC_L2CAP_2_14	True (*)	FCS Option (C.2)
+TSPC_L2CAP_2_15	True (*)	Generate Local Busy Condition (C.3)
+TSPC_L2CAP_2_16	True (*)	Send Reject (C.3)
+TSPC_L2CAP_2_17	True (*)	Send Selective Reject (C.3)
+TSPC_L2CAP_2_18	True (*)	Mandatory use of ERTM (C.4)
+TSPC_L2CAP_2_19	True (*)	Mandatory use of Streaming Mode (C.5)
+TSPC_L2CAP_2_20	True (*)	Optional use of ERTM (C.4)
+TSPC_L2CAP_2_21	True (*)	Optional use of Streaming Mode (C.5)
+TSPC_L2CAP_2_22	True (*)	Send data using SAR in ERTM (C.6)
+TSPC_L2CAP_2_23	True (*)	Send data using SAR in Streaming Mode (C.7)
+TSPC_L2CAP_2_24	True (*)	Actively request Basic Mode for a PSM that
+					supports the use of ERTM or Streaming
+					Mode (C.8)
+TSPC_L2CAP_2_25	True (*)	Supports performing L2CAP channel mode
+					configuration fallback from SM
+					 to ERTM (C.9)
+TSPC_L2CAP_2_26	True (*)	Supports sending more than one unacknowledged
+					I-Frame when operating in ERTM (C.10)
+TSPC_L2CAP_2_27	True (*)	Supports sending more than three unacknowledged
+					I-Frame when operating in ERTM (C.10)
+TSPC_L2CAP_2_28	True (*)	Supports configuring the peer TxWindow
+					greater than 1 (C.11)
+TSPC_L2CAP_2_29	False		AMP Support (C.12)
+TSPC_L2CAP_2_30	True (*)	Fixed Channel Support (C.12)
+TSPC_L2CAP_2_31	False		AMP Manager Support (C.12)
+TSPC_L2CAP_2_32	False		ERTM over AMP (C.12)
+TSPC_L2CAP_2_33	False		Streaming Mode Source over AMP Support (C.15)
+TSPC_L2CAP_2_34	False		Streaming Mode Sink over AMP Support (C.15)
+TSPC_L2CAP_2_35	False		Unicast Connectionless Data, Reception (C.1, C.16)
+TSPC_L2CAP_2_36	False		Ability to transmit an unencrypted packet over
+					a Unicast connectionless L2CAP
+					channel (C.16)
+TSPC_L2CAP_2_37	False		Ability to transmit an encrypted packet over
+					a Unicast connectionless L2CAP
+					channel (C.16)
+TSPC_L2CAP_2_38	False		Extended Flow Specification for BR/EDR (C.8)
+TSPC_L2CAP_2_39	False		Extended Window Size (C.8)
+TSPC_L2CAP_2_40	True (*)	Support of Low Energy signaling channel (C.17)
+TSPC_L2CAP_2_41	True (*)	Support of command reject (C.17)
+TSPC_L2CAP_2_42	True (*)	Send Connection Parameter Update Request (C.18)
+TSPC_L2CAP_2_43	True (*)	Send Connection Parameter Update Response (C.19)
+TSPC_L2CAP_2_44	False		Extended Flow Specification for AMP (C.22)
+TSPC_L2CAP_2_45	False		Send disconnect request command (O)
+-------------------------------------------------------------------------------
+C.1: Mandatory to support at least one of TSPC_L2CAP_2_12 OR TSPC_L2CAP_2_13 OR
+	TSPC_L2CAP_2_35 IF BR/EDR BR/EDR/LE AND SUM_ICS 31/7 (CSA1) OR
+	SUM_ICS 31/8 (3.0) OR SUM_ICS 31/9 (3.0+HS) OR SUM_ICS 31/10 (4.0))
+	is supported, ELSE Excluded
+C.2: Optional IF TSPC_L2CAP_2_12 OR TSPC_L2CAP_2_13 is claimed, ELSE Excluded.
+C.3: Optional IF TSPC_L2CAP_2_12 AND TSPC_L2CAP_2_28 is claimed, ELSE Excluded.
+C.4: IF TSPC_L2CAP_2_12 is claimed THEN either TSPC_L2CAP_2_18
+	OR TSPC_L2CAP_2_20 are Mandatory, ELSE Excluded.
+C.5: IF TSPC_L2CAP_2_13 is claimed THEN either TSPC_L2CAP_2_19
+	OR TSPC_L2CAP_2_21 are Mandatory, ELSE Excluded.
+C.6: Optional IF TSPC_L2CAP_2_12 is claimed, ELSE Excluded.
+C.7: Optional IF TSPC_L2CAP_2_13 is claimed, ELSE Excluded.
+C.8: Optional IF TSPC_L2CAP_2_12 OR TSPC_L2CAP_2_13 is claimed, ELSE Excluded.
+C.9: Mandatory IF TSPC_L2CAP_2_12 AND TSPC_L2CAP_2_13 AND TSPC_L2CAP_2_21
+       is claimed, ELSE Excluded.
+C.10: Optional IF TSPC_L2CAP_2_12 is claimed, ELSE Excluded.
+C.11: Optional IF TSPC_L2CAP_2_12 is claimed, ELSE Excluded.
+C.12: Mandatory IF SUM_ICS 31/9 (3.0 + HS) is claimed, ELSE Optional.
+C.13: Mandatory IF SUM_ICS 31/9 (3.0 + HS) is claimed, ELSE Optional.
+C.14: Optional IF SUM_ICS 31/8 OR 31/9 OR 31/10 OR 31/11 is claimed, ELSE Excluded.
+C.15: Optional IF TSPC_L2CAP_2_29 is claimed, ELSE Excluded.
+C.16: Optional IF (SUM_ICS 31/8 OR SUM_ICS 31/9 OR 31/10 OR 31/11) is claimed,
+       ELSE Excluded.
+C.17: Mandatory IF LE OR BR/EDR/LE is claimed, ELSE Excluded.
+C.18: Optional IF (SUM_ICS 31/10 AND 1/4) is claimed, ELSE Excluded.
+C.19: Mandatory IF (SUM_ICS 31/10 AND 1/3) is claimed, ELSE Excluded.
+C.20: Mandatory IF LE OR BR/EDR/LE, is claimed, ELSE Excluded
+C.21: Optional IF LE OR BR/EDR/LE, is claimed, ELSE Excluded
+C.22: Mandatory IF TSPC_L2CAP_2_29 is claimed, ELSE Excluded.
+-------------------------------------------------------------------------------
+
+
+		Configurable Parameters
+-------------------------------------------------------------------------------
+Parameter	Name Selected	Description
+-------------------------------------------------------------------------------
+TSPC_L2CAP_3_1	True		Support of RTX timer (M)
+TSPC_L2CAP_3_2	True		Support of ERTX timer (C.4)
+TSPC_L2CAP_3_3	True		Support minimum MTU size 48 octets (C.4)
+TSPC_L2CAP_3_4	True (*)	Support MTU size larger than 48 octets (C.5)
+TSPC_L2CAP_3_5	True		Support of flush timeout value for reliable
+					channel (C.4)
+TSPC_L2CAP_3_6	False		Support of flush timeout value for unreliable
+					channel (C.5)
+TSPC_L2CAP_3_7	False		Support of bi-directional quality of service
+					(QoS) option field (C.1)
+TSPC_L2CAP_3_8	False		Negotiate QoS service type (C.5)
+TSPC_L2CAP_3_9	False		Negotiate and support service type ‘No
+					traffic’ (C.2)
+TSPC_L2CAP_3_10	False		Negotiate and support service type ‘Best
+					effort’ (C.3)
+TSPC_L2CAP_3_11	False		Negotiate and support service type
+					‘Guaranteed’ (C.2)
+TSPC_L2CAP_3_12	True (*)	Support minimum MTU size 23 octets (C.6)
+TSPC_L2CAP_3_13	False		Negotiate and support service type ‘No traffic’
+					for Extended Flow Specification (C.7)
+TSPC_L2CAP_3_14	False		Negotiate and support service type ‘Best Effort'
+					for Extended Flow Specification (C.8)
+TSPC_L2CAP_3_15	False		Negotiate and support service type ‘Guaranteed’
+					for Extended Flow Specification (C.9)
+-------------------------------------------------------------------------------
+C.1: Mandatory if TSPC_L2CAP_3_8 is supported, ELSE Optional.
+C.2: Optional if TSPC_L2CAP_3_8 is supported, ELSE Excluded.
+C.3: Mandatory if TSPC_L2CAP_3_8 is supported, ELSE Excluded.
+C.4: Mandatory IF BR/EDR OR BR/EDR/LE is claimed, ELSE Excluded.
+C.5: Optional IF BR/EDR OR BR/EDR/LE is claimed, ELSE Excluded.
+C.6: Mandatory IF LE OR BR/EDR/LE is claimed, ELSE Excluded.
+C.7: Optional if TSPC_L2CAP_2_44 OR TSPC_L2CAP_2_38 is supported, ELSE Excluded.
+C.8: Mandatory if TSPC_L2CAP_2_44 OR TSPC_L2CAP_2_38 is supported, ELSE Excluded.
+C.9: Optional if TSPC_L2CAP_2_44 OR TSPC_L2CAP_2_38 is supported, ELSE Excluded.
+-------------------------------------------------------------------------------
diff --git a/android/pixit-l2cap.txt b/android/pixit-l2cap.txt
new file mode 100644
index 0000000..7de6638
--- /dev/null
+++ b/android/pixit-l2cap.txt
@@ -0,0 +1,39 @@
+L2CAP PIXIT for the PTS tool.
+
+* - different than PTS defaults
+& - should be set to IUT Bluetooth address
+
+               Required PIXIT settings
+-------------------------------------------------------------------------------
+Parameter Name                                         Value
+-------------------------------------------------------------------------------
+TSPX_bd_addr_iut                                       112233445566 (*&)
+TSPX_client_class_of_device                            100104
+TSPX_server_class_of_device                            100104
+TSPX_security_enabled                                  FALSE
+TSPX_delete_link_key                                   FALSE
+TSPX_pin_code                                          0000
+TSPX_flushto                                           FFFF
+TSPX_inmtu                                             02A0
+TSPX_no_fail_verditcs                                  FALSE
+TSPX_oumtu                                             02A0
+TSPX_iut_role_initiator                                FALSE
+TSPX_psm                                               1011 (*)
+TSPX_time_guard                                        180000
+TSPX_timer_ertx                                        120000
+TSPX_timer_ertx_max                                    300000
+TSPX_timer_ertx_min                                    60000
+TSPX_timer_rtx                                         10000
+TSPX_timer_rtx_max                                     60000
+TSPX_timer_rtx_min                                     1000
+TSPX_rfc_mode_tx_window_size                           08
+TSPX_rfc_mode_max_transmit                             03
+TSPX_rfc_mode_retransmission_timeout                   07D0
+TSPX_rfc_mode_monitor_timeout                          2EE0
+TSPX_rfc_mode_maximum_pdu_size                         02A0
+TSPX_extended_window_size                              0012
+TSPX_use_implicit_send                                 TRUE
+TSPX_use_dynamic_pin                                   FALSE
+TSPX_iut_SDU_size_in_bytes                             144
+TSPX_secure_simple_pairing_pass_key_confirmation       FALSE
+-------------------------------------------------------------------------------
diff --git a/android/pts-l2cap.txt b/android/pts-l2cap.txt
new file mode 100644
index 0000000..deff86c
--- /dev/null
+++ b/android/pts-l2cap.txt
@@ -0,0 +1,149 @@
+PTS test results for L2CAP
+
+PTS version: 5.0
+Tested: 18.12.2013
+
+Results:
+PASS   test passed
+FAIL   test failed
+INC    test is inconclusive
+N/A    test is disabled due to PICS setup
+
+-------------------------------------------------------------------------------
+Test Name              Result  Notes
+-------------------------------------------------------------------------------
+TC_COS_CED_BV_01_C     PASS
+TC_COS_CED_BV_03_C     PASS
+TC_COS_CED_BV_04_C     N/A
+TC_COS_CED_BV_05_C     PASS
+TC_COS_CED_BV_07_C     PASS
+TC_COS_CED_BV_08_C     PASS
+TC_COS_CED_BV_09_C     INC
+TC_COS_CED_BV_10_C     N/A
+TC_COS_CED_BV_11_C     PASS
+TC_COS_CED_BI_01_C     PASS
+TC_COS_CFD_BV_01_C     PASS
+TC_COS_CFD_BV_02_C     PASS
+TC_COS_CFD_BV_03_C     PASS
+TC_COS_CFD_BV_08_C     INC
+TC_COS_CFD_BV_09_C     INC
+TC_COS_CFD_BV_10_C     N/A
+TC_COS_CFD_BI_11_C     PASS
+TC_COS_CFD_BV_12_C     PASS
+TC_COS_CFD_BV_13_C     N/A
+TC_COS_IEX_BV_01_C     PASS
+TC_COS_IEX_BV_02_C     PASS
+TC_COS_ECH_BV_01_C     PASS
+TC_COS_ECH_BV_02_C     INC
+TC_CLS_CLR_BV_01_C     N/A
+TC_CLS_UCD_BV_01_C     N/A
+TC_CLS_UCD_BV_02_C     N/A
+TC_CLS_UCD_BV_03_C     N/A
+TC_EXF_BV_01_C         PASS
+TC_EXF_BV_02_C         PASS
+TC_EXF_BV_03_C         PASS
+TC_EXF_BV_04_C         N/A
+TC_EXF_BV_05_C         PASS
+TC_EXF_BV_06_C         N/A
+TC_CMC_BV_01_C         INC
+TC_CMC_BV_02_C         INC
+TC_CMC_BV_03_C         INC
+TC_CMC_BV_04_C         INC
+TC_CMC_BV_05_C         INC
+TC_CMC_BV_06_C         INC
+TC_CMC_BV_07_C         INC
+TC_CMC_BV_08_C         INC
+TC_CMC_BV_09_C         INC
+TC_CMC_BV_10_C         INC
+TC_CMC_BV_11_C         INC
+TC_CMC_BV_12_C         INC
+TC_CMC_BV_13_C         INC
+TC_CMC_BV_14_C         INC
+TC_CMC_BV_15_C         INC
+TC_CMC_BI_01_C         INC
+TC_CMC_BI_02_C         INC
+TC_CMC_BI_03_C         INC
+TC_CMC_BI_04_C         INC
+TC_CMC_BI_05_C         INC
+TC_CMC_BI_06_C         INC
+TC_FOC_BV_01_C         INC
+TC_FOC_BV_02_C         INC
+TC_FOC_BV_03_C         INC
+TC_FOC_BV_04_C         INC
+TC_OFS_BV_01_C         INC
+TC_OFS_BV_02_C         INC
+TC_OFS_BV_03_C         INC
+TC_OFS_BV_04_C         INC
+TC_OFS_BV_05_C         INC
+TC_OFS_BV_06_C         INC
+TC_OFS_BV_07_C         INC
+TC_OFS_BV_08_C         INC
+TC_ERM_BV_01_C         INC
+TC_ERM_BV_02_C         INC
+TC_ERM_BV_03_C         INC
+TC_ERM_BV_04_C         INC
+TC_ERM_BV_05_C         INC
+TC_ERM_BV_06_C         INC
+TC_ERM_BV_07_C         INC
+TC_ERM_BV_08_C         INC
+TC_ERM_BV_09_C         INC
+TC_ERM_BV_10_C         INC
+TC_ERM_BV_11_C         INC
+TC_ERM_BV_12_C         INC
+TC_ERM_BV_13_C         INC
+TC_ERM_BV_14_C         INC
+TC_ERM_BV_15_C         INC
+TC_ERM_BV_16_C         INC
+TC_ERM_BV_17_C         INC
+TC_ERM_BV_18_C         INC
+TC_ERM_BV_19_C         INC
+TC_ERM_BV_20_C         INC
+TC_ERM_BV_21_C         INC
+TC_ERM_BV_22_C         INC
+TC_ERM_BV_23_C         INC
+TC_ERM_BI_01_C         INC
+TC_ERM_BI_02_C         INC
+TC_ERM_BI_03_C         INC
+TC_ERM_BI_04_C         INC
+TC_ERM_BI_05_C         INC
+TC_STM_BV_01_C         INC
+TC_STM_BV_02_C         INC
+TC_STM_BV_03_C         INC
+TC_STM_BV_11_C         N/A
+TC_STM_BV_12_C         N/A
+TC_STM_BV_13_C         N/A
+TC_FIX_BV_01_C         PASS
+TC_FIX_BV_02_C         PASS
+TC_EWC_BV_01_C         N/A
+TC_EWC_BV_02_C         N/A
+TC_EWC_BV_03_C         N/A
+TC_LSC_BV_01_C         N/A
+TC_LSC_BV_02_C         N/A
+TC_LSC_BV_03_C         N/A
+TC_LSC_BI_04_C         N/A
+TC_LSC_BI_05_C         N/A
+TC_LSC_BV_06_C         N/A
+TC_LSC_BV_07_C         N/A
+TC_LSC_BV_08_C         N/A
+TC_LSC_BV_09_C         N/A
+TC_LSC_BI_10_C         N/A
+TC_LSC_BI_11_C         N/A
+TC_LSC_BV_12_C         N/A
+TC_CCH_BV_01_C         N/A
+TC_CCH_BV_02_C         N/A
+TC_CCH_BV_03_C         N/A
+TC_CCH_BV_04_C         N/A
+TC_ECF_BV_01_C         N/A
+TC_ECF_BV_02_C         N/A
+TC_ECF_BV_03_C         N/A
+TC_ECF_BV_04_C         N/A
+TC_ECF_BV_05_C         N/A
+TC_ECF_BV_06_C         N/A
+TC_ECF_BV_07_C         N/A
+TC_ECF_BV_08_C         N/A
+TC_LE_CPU_BV_01_C      N/A
+TC_LE_CPU_BV_02_C      N/A
+TC_LE_CPU_BI_01_C      N/A
+TC_LE_CPU_BI_02_C      N/A
+TC_LE_REJ_BV_01_C      N/A
+
-- 
1.8.1.2


^ permalink raw reply related

* [PATCH] avrcp: Remove unneeded code
From: Andrei Emeltchenko @ 2013-12-19  9:13 UTC (permalink / raw)
  To: linux-bluetooth

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

Checking (val & 0x7f) > 127 does not make any sense.
---
 profiles/audio/avrcp.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
index cd027c6..7731e88 100644
--- a/profiles/audio/avrcp.c
+++ b/profiles/audio/avrcp.c
@@ -1577,15 +1577,10 @@ static uint8_t avrcp_handle_set_absolute_volume(struct avrcp *session,
 {
 	struct avrcp_player *player = session->controller->player;
 	uint16_t len = ntohs(pdu->params_len);
-	uint8_t volume;
 
 	if (len != 1)
 		goto err;
 
-	volume = pdu->params[0] & 0x7F;
-	if (volume > 127)
-		goto err;
-
 	if (!player)
 		goto err;
 
-- 
1.8.3.2


^ permalink raw reply related

* Re: [PATCHv2 1/2] android/tester: Add Socket test close and listen
From: Johan Hedberg @ 2013-12-19  9:09 UTC (permalink / raw)
  To: Andrei Emeltchenko; +Cc: linux-bluetooth
In-Reply-To: <1387443100-4768-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

Hi Andrei,

On Thu, Dec 19, 2013, Andrei Emeltchenko wrote:
> This test the situation when Android close file descriptor we passed to
> it and try to listen() again.
> ---
>  android/android-tester.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 60 insertions(+)

Both patches have been applied. Thanks.

Johan

^ 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