Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH 01/14] android: Add missing bonding state definitions to IPC specification
From: Szymon Janc @ 2013-10-31  2:55 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1383188154-22905-1-git-send-email-szymon.janc@tieto.com>

---
 android/hal-ipc-api.txt | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index e7af8a3..a5d1980 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -370,6 +370,10 @@ Notifications:
 		                         Remote address (6 octets)
 		                         Bond state (1 octet)
 
+		Valid bond state values: 0x00 = None
+		                         0x01 = Bonding
+		                         0x02 = Bonded
+
 	Opcode 0x89 - ACL State Changed notification
 
 		Notification parameters: Status (1 octect)
-- 
1.8.4.rc3


^ permalink raw reply related

* [PATCH 02/14] android: Add missing bond state definition to IPC header
From: Szymon Janc @ 2013-10-31  2:55 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1383188154-22905-1-git-send-email-szymon.janc@tieto.com>

---
 android/hal-msg.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/android/hal-msg.h b/android/hal-msg.h
index d2a0e2a..b0ee73c 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -372,6 +372,10 @@ struct hal_ev_ssp_request {
 	uint32_t passkey;
 } __attribute__((packed));
 
+#define HAL_BOND_STATE_NONE 0
+#define HAL_BOND_STATE_BONDING 1
+#define HAL_BOND_STATE_BONDED 2
+
 #define HAL_EV_BOND_STATE_CHANGED	0x88
 struct hal_ev_bond_state_changed {
 	uint8_t status;
-- 
1.8.4.rc3


^ permalink raw reply related

* [PATCH 03/14] android: Add support for handling new link key mgmt event
From: Szymon Janc @ 2013-10-31  2:55 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1383188154-22905-1-git-send-email-szymon.janc@tieto.com>

When link key is emitted by kernel bond state change notification is
send to HAL. Storing link key is not yet implemented.
---
 android/adapter.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 57 insertions(+)

diff --git a/android/adapter.c b/android/adapter.c
index 15b65e5..4b4905b 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -195,6 +195,60 @@ static void mgmt_dev_class_changed_event(uint16_t index, uint16_t length,
 	/* TODO: Gatt attrib set*/
 }
 
+static void store_link_key(const bdaddr_t *dst, const uint8_t *key,
+					uint8_t type, uint8_t pin_length)
+{
+	/* TODO store link key */
+
+}
+
+static void send_bond_state_change(const bdaddr_t *addr, uint8_t status,
+								uint8_t state)
+{
+	struct hal_ev_bond_state_changed ev;
+
+	ev.status = status;
+	ev.state = state;
+	bdaddr2android(addr, ev.bdaddr);
+
+	ipc_send(notification_io, HAL_SERVICE_ID_BLUETOOTH,
+			HAL_EV_BOND_STATE_CHANGED, sizeof(ev), &ev, -1);
+}
+
+static void new_link_key_callback(uint16_t index, uint16_t length,
+					const void *param, void *user_data)
+{
+	const struct mgmt_ev_new_link_key *ev = param;
+	const struct mgmt_addr_info *addr = &ev->key.addr;
+	char dst[18];
+
+	if (length < sizeof(*ev)) {
+		error("Too small new link key event");
+		return;
+	}
+
+	ba2str(&addr->bdaddr, dst);
+
+	DBG("new key for %s type %u pin_len %u",
+					dst, ev->key.type, ev->key.pin_len);
+
+	if (ev->key.pin_len > 16) {
+		error("Invalid PIN length (%u) in new_key event",
+							ev->key.pin_len);
+		return;
+	}
+
+	if (ev->store_hint) {
+		const struct mgmt_link_key_info *key = &ev->key;
+
+		store_link_key(&addr->bdaddr, key->val, key->type,
+								key->pin_len);
+	}
+
+	send_bond_state_change(&addr->bdaddr, HAL_STATUS_SUCCESS,
+							HAL_BOND_STATE_BONDED);
+}
+
 static void register_mgmt_handlers(void)
 {
 	mgmt_register(adapter->mgmt, MGMT_EV_NEW_SETTINGS, adapter->index,
@@ -207,6 +261,9 @@ static void register_mgmt_handlers(void)
 	mgmt_register(adapter->mgmt, MGMT_EV_LOCAL_NAME_CHANGED,
 				adapter->index, mgmt_local_name_changed_event,
 				NULL, NULL);
+
+	mgmt_register(adapter->mgmt, MGMT_EV_NEW_LINK_KEY, adapter->index,
+					new_link_key_callback, NULL, NULL);
 }
 
 static void load_link_keys_complete(uint8_t status, uint16_t length,
-- 
1.8.4.rc3


^ permalink raw reply related

* [PATCH 04/14] android: Make load_link_keys function load keys
From: Szymon Janc @ 2013-10-31  2:55 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1383188154-22905-1-git-send-email-szymon.janc@tieto.com>

GSlist passed is expected to hold mgmt_link_key_info structures.
---
 android/adapter.c | 33 ++++++++++++++++++++++++---------
 1 file changed, 24 insertions(+), 9 deletions(-)

diff --git a/android/adapter.c b/android/adapter.c
index 4b4905b..d55a070 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -290,22 +290,37 @@ failed:
 static void load_link_keys(GSList *keys)
 {
 	struct mgmt_cp_load_link_keys *cp;
-	size_t key_len = g_slist_length(keys);
 	struct mgmt_link_key_info *key;
-	size_t len;
+	size_t key_count, cp_size;
+	unsigned int id;
 
-	DBG("");
+	key_count = g_slist_length(keys);
+
+	DBG("keys %zu ", key_count);
+
+	cp_size = sizeof(*cp) + (key_count * sizeof(*key));
+
+	cp = g_malloc0(cp_size);
 
-	len = sizeof(*cp) + key_len * sizeof(*key);
-	cp = g_malloc0(len);
+	/*
+	 * Even if the list of stored keys is empty, it is important to
+	 * load an empty list into the kernel. That way it is ensured
+	 * that no old keys from a previous daemon are present.
+	 */
+	cp->key_count = htobs(key_count);
 
-	cp->debug_keys = 0;
-	cp->key_count = htobs(key_len);
+	for (key = cp->keys; keys != NULL; keys = g_slist_next(keys), key++)
+		memcpy(key, keys->data, sizeof(*key));
 
-	mgmt_send(adapter->mgmt, MGMT_OP_LOAD_LINK_KEYS, adapter->index, len,
-				cp, load_link_keys_complete, NULL, NULL);
+	id = mgmt_send(adapter->mgmt, MGMT_OP_LOAD_LINK_KEYS, adapter->index,
+			cp_size, cp, load_link_keys_complete, NULL, NULL);
 
 	g_free(cp);
+
+	if (id == 0) {
+		error("Failed to load link keys");
+		adapter->ready(-EIO);
+	}
 }
 
 static void set_mode_complete(uint8_t status, uint16_t length,
-- 
1.8.4.rc3


^ permalink raw reply related

* [PATCH 05/14] android: Set default IO capability on daemon start
From: Szymon Janc @ 2013-10-31  2:55 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1383188154-22905-1-git-send-email-szymon.janc@tieto.com>

There is no HAL function for setting IO capabilities so this is
hardcoded to DisplayYesNo as Android devices usually have screen
and input.
---
 android/adapter.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/android/adapter.c b/android/adapter.c
index d55a070..d730dde 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -34,6 +34,9 @@
 #include "utils.h"
 #include "adapter.h"
 
+/* Default to DisplayYesNo */
+#define DEFAULT_IO_CAPABILITY 0x01
+
 static GIOChannel *notification_io = NULL;
 
 struct bt_adapter {
@@ -358,6 +361,19 @@ static bool set_mode(uint16_t opcode, uint8_t mode)
 	return false;
 }
 
+static void set_io_capability(void)
+{
+	struct mgmt_cp_set_io_capability cp;
+
+	memset(&cp, 0, sizeof(cp));
+	cp.io_capability = DEFAULT_IO_CAPABILITY;
+
+	if (mgmt_send(adapter->mgmt, MGMT_OP_SET_IO_CAPABILITY,
+				adapter->index, sizeof(cp), &cp,
+				NULL, NULL, NULL) == 0)
+		error("Failed to set IO capability");
+}
+
 static void read_info_complete(uint8_t status, uint16_t length, const void *param,
 							void *user_data)
 {
@@ -399,6 +415,7 @@ static void read_info_complete(uint8_t status, uint16_t length, const void *para
 
 	load_link_keys(NULL);
 
+	set_io_capability();
 	set_mode(MGMT_OP_SET_PAIRABLE, 0x01);
 
 	return;
-- 
1.8.4.rc3


^ permalink raw reply related

* [PATCH 06/14] android: Add support for handling create bond command
From: Szymon Janc @ 2013-10-31  2:55 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1383188154-22905-1-git-send-email-szymon.janc@tieto.com>

---
 android/adapter.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 63 insertions(+)

diff --git a/android/adapter.c b/android/adapter.c
index d730dde..8c5482b 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -568,6 +568,64 @@ static uint8_t set_property(void *buf, uint16_t len)
 	}
 }
 
+static uint8_t status_mgmt2hal(uint8_t mgmt)
+{
+	switch (mgmt) {
+	case MGMT_STATUS_SUCCESS:
+		return HAL_STATUS_SUCCESS;
+	case MGMT_STATUS_NO_RESOURCES:
+		return HAL_STATUS_NOMEM;
+	case MGMT_STATUS_BUSY:
+		return HAL_STATUS_BUSY;
+	case MGMT_STATUS_NOT_SUPPORTED:
+		return HAL_STATUS_UNSUPPORTED;
+	case MGMT_STATUS_INVALID_PARAMS:
+		return HAL_STATUS_INVALID;
+	case MGMT_STATUS_AUTH_FAILED:
+		return HAL_STATUS_AUTH_FAILURE;
+	case MGMT_STATUS_NOT_CONNECTED:
+		return HAL_STATUS_REMOTE_DEVICE_DOWN;
+	default:
+		return HAL_STATUS_FAILED;
+	}
+}
+
+static void pair_device_complete(uint8_t status, uint16_t length,
+					const void *param, void *user_data)
+{
+	const struct mgmt_rp_pair_device *rp = param;
+
+	DBG("status %u", status);
+
+	/* On success bond state change will be send when new link key event
+	 * is received */
+	if (status == MGMT_STATUS_SUCCESS)
+		return;
+
+	send_bond_state_change(&rp->addr.bdaddr, status_mgmt2hal(status),
+							HAL_BOND_STATE_NONE);
+}
+
+static bool create_bond(void *buf, uint16_t len)
+{
+	struct hal_cmd_create_bond *cmd = buf;
+	struct mgmt_cp_pair_device cp;
+
+	cp.io_cap = DEFAULT_IO_CAPABILITY;
+	cp.addr.type = BDADDR_BREDR;
+	android2bdaddr(cmd->bdaddr, &cp.addr.bdaddr);
+
+	if (mgmt_send(adapter->mgmt, MGMT_OP_PAIR_DEVICE, adapter->index,
+				sizeof(cp), &cp, pair_device_complete, NULL,
+				NULL) == 0)
+		return false;
+
+	send_bond_state_change(&cp.addr.bdaddr, HAL_STATUS_SUCCESS,
+						HAL_BOND_STATE_BONDING);
+
+	return true;
+}
+
 void bt_adapter_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf,
 								uint16_t len)
 {
@@ -605,6 +663,11 @@ void bt_adapter_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf,
 			goto error;
 
 		break;
+	case HAL_OP_CREATE_BOND:
+		if (!create_bond(buf, len))
+			goto error;
+
+		break;
 	default:
 		DBG("Unhandled command, opcode 0x%x", opcode);
 		goto error;
-- 
1.8.4.rc3


^ permalink raw reply related

* [PATCH 07/14] android: Add support for handling cancel bond command
From: Szymon Janc @ 2013-10-31  2:55 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1383188154-22905-1-git-send-email-szymon.janc@tieto.com>

---
 android/adapter.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/android/adapter.c b/android/adapter.c
index 8c5482b..0f174a6 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -626,6 +626,19 @@ static bool create_bond(void *buf, uint16_t len)
 	return true;
 }
 
+static bool cancel_bond(void *buf, uint16_t len)
+{
+	struct hal_cmd_cancel_bond *cmd = buf;
+	struct mgmt_addr_info cp;
+
+	cp.type = BDADDR_BREDR;
+	android2bdaddr(cmd->bdaddr, &cp.bdaddr);
+
+	return mgmt_reply(adapter->mgmt, MGMT_OP_CANCEL_PAIR_DEVICE,
+				adapter->index, sizeof(cp), &cp, NULL, NULL,
+				NULL) > 0;
+}
+
 void bt_adapter_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf,
 								uint16_t len)
 {
@@ -668,6 +681,11 @@ void bt_adapter_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf,
 			goto error;
 
 		break;
+	case HAL_OP_CANCEL_BOND:
+		if (!cancel_bond(buf, len))
+			goto error;
+
+		break;
 	default:
 		DBG("Unhandled command, opcode 0x%x", opcode);
 		goto error;
-- 
1.8.4.rc3


^ permalink raw reply related

* [PATCH 08/14] android: Add support for handling remove bond command
From: Szymon Janc @ 2013-10-31  2:55 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1383188154-22905-1-git-send-email-szymon.janc@tieto.com>

---
 android/adapter.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/android/adapter.c b/android/adapter.c
index 0f174a6..0a91149 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -639,6 +639,26 @@ static bool cancel_bond(void *buf, uint16_t len)
 				NULL) > 0;
 }
 
+static bool remove_bond(void *buf, uint16_t len)
+{
+	struct hal_cmd_remove_bond *cmd = buf;
+	struct mgmt_cp_unpair_device cp;
+
+	cp.disconnect = 1;
+	cp.addr.type = BDADDR_BREDR;
+	android2bdaddr(cmd->bdaddr, &cp.addr.bdaddr);
+
+	if (mgmt_send(adapter->mgmt, MGMT_OP_UNPAIR_DEVICE,
+				adapter->index, sizeof(cp), &cp,
+				NULL, NULL, NULL) == 0)
+		return false;
+
+	send_bond_state_change(&cp.addr.bdaddr, HAL_STATUS_SUCCESS,
+							HAL_BOND_STATE_NONE);
+
+	return true;
+}
+
 void bt_adapter_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf,
 								uint16_t len)
 {
@@ -686,6 +706,11 @@ void bt_adapter_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf,
 			goto error;
 
 		break;
+	case HAL_OP_REMOVE_BOND:
+		if (!remove_bond(buf, len))
+			goto error;
+
+		break;
 	default:
 		DBG("Unhandled command, opcode 0x%x", opcode);
 		goto error;
-- 
1.8.4.rc3


^ permalink raw reply related

* [PATCH 09/14] android: Add support for sending pin code request
From: Szymon Janc @ 2013-10-31  2:55 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1383188154-22905-1-git-send-email-szymon.janc@tieto.com>

---
 android/adapter.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/android/adapter.c b/android/adapter.c
index 0a91149..0c5ae8b 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -252,6 +252,30 @@ static void new_link_key_callback(uint16_t index, uint16_t length,
 							HAL_BOND_STATE_BONDED);
 }
 
+static void pin_code_request_callback(uint16_t index, uint16_t length,
+					const void *param, void *user_data)
+{
+	const struct mgmt_ev_pin_code_request *ev = param;
+	struct hal_ev_pin_request hal_ev;
+	char dst[18];
+
+	if (length < sizeof(*ev)) {
+		error("Too small PIN code request event");
+		return;
+	}
+
+	ba2str(&ev->addr.bdaddr, dst);
+
+	DBG("%s type %u secure %u", dst, ev->addr.type, ev->secure);
+
+	/* TODO name and CoD of remote devices should probably be cached */
+	memset(&hal_ev, 0, sizeof(hal_ev));
+	bdaddr2android(&ev->addr.bdaddr, hal_ev.bdaddr);
+
+	ipc_send(notification_io, HAL_SERVICE_ID_BLUETOOTH, HAL_EV_PIN_REQUEST,
+						sizeof(hal_ev), &hal_ev, -1);
+}
+
 static void register_mgmt_handlers(void)
 {
 	mgmt_register(adapter->mgmt, MGMT_EV_NEW_SETTINGS, adapter->index,
@@ -267,6 +291,9 @@ static void register_mgmt_handlers(void)
 
 	mgmt_register(adapter->mgmt, MGMT_EV_NEW_LINK_KEY, adapter->index,
 					new_link_key_callback, NULL, NULL);
+
+	mgmt_register(adapter->mgmt, MGMT_EV_PIN_CODE_REQUEST, adapter->index,
+					pin_code_request_callback, NULL, NULL);
 }
 
 static void load_link_keys_complete(uint8_t status, uint16_t length,
-- 
1.8.4.rc3


^ permalink raw reply related

* [PATCH 10/14] android: Add initial support for sending SSP request event
From: Szymon Janc @ 2013-10-31  2:55 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1383188154-22905-1-git-send-email-szymon.janc@tieto.com>

Only consent and confirm variants are supported in this patch.
---
 android/adapter.c | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/android/adapter.c b/android/adapter.c
index 0c5ae8b..b99c860 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -276,6 +276,42 @@ static void pin_code_request_callback(uint16_t index, uint16_t length,
 						sizeof(hal_ev), &hal_ev, -1);
 }
 
+static void send_ssp_request(const bdaddr_t *addr, uint8_t variant,
+							uint32_t passkey)
+{
+	struct hal_ev_ssp_request ev;
+
+	/* TODO name and CoD of remote devices should probably be cached */
+	memset(&ev, 0, sizeof(ev));
+	bdaddr2android(addr, ev.bdaddr);
+	ev.pairing_variant = variant;
+	ev.passkey = passkey;
+
+	ipc_send(notification_io, HAL_SERVICE_ID_BLUETOOTH, HAL_EV_SSP_REQUEST,
+						sizeof(ev), &ev, -1);
+}
+
+static void user_confirm_request_callback(uint16_t index, uint16_t length,
+					const void *param, void *user_data)
+{
+	const struct mgmt_ev_user_confirm_request *ev = param;
+	char dst[18];
+
+	if (length < sizeof(*ev)) {
+		error("Too small user confirm request event");
+		return;
+	}
+
+	ba2str(&ev->addr.bdaddr, dst);
+	DBG("%s confirm_hint %u", dst, ev->confirm_hint);
+
+	if (ev->confirm_hint)
+		send_ssp_request(&ev->addr.bdaddr, HAL_SSP_VARIANT_CONSENT, 0);
+	else
+		send_ssp_request(&ev->addr.bdaddr, HAL_SSP_VARIANT_CONFIRM,
+								ev->value);
+}
+
 static void register_mgmt_handlers(void)
 {
 	mgmt_register(adapter->mgmt, MGMT_EV_NEW_SETTINGS, adapter->index,
@@ -294,6 +330,10 @@ static void register_mgmt_handlers(void)
 
 	mgmt_register(adapter->mgmt, MGMT_EV_PIN_CODE_REQUEST, adapter->index,
 					pin_code_request_callback, NULL, NULL);
+
+	mgmt_register(adapter->mgmt, MGMT_EV_USER_CONFIRM_REQUEST,
+				adapter->index, user_confirm_request_callback,
+				NULL, NULL);
 }
 
 static void load_link_keys_complete(uint8_t status, uint16_t length,
-- 
1.8.4.rc3


^ permalink raw reply related

* [PATCH 11/14] android: Add support for entry variant in SSP request event
From: Szymon Janc @ 2013-10-31  2:55 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1383188154-22905-1-git-send-email-szymon.janc@tieto.com>

---
 android/adapter.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/android/adapter.c b/android/adapter.c
index b99c860..1be0fb3 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -312,6 +312,23 @@ static void user_confirm_request_callback(uint16_t index, uint16_t length,
 								ev->value);
 }
 
+static void user_passkey_request_callback(uint16_t index, uint16_t length,
+					const void *param, void *user_data)
+{
+	const struct mgmt_ev_user_passkey_request *ev = param;
+	char dst[18];
+
+	if (length < sizeof(*ev)) {
+		error("Too small passkey request event");
+		return;
+	}
+
+	ba2str(&ev->addr.bdaddr, dst);
+	DBG("%s", dst);
+
+	send_ssp_request(&ev->addr.bdaddr, HAL_SSP_VARIANT_ENTRY, 0);
+}
+
 static void register_mgmt_handlers(void)
 {
 	mgmt_register(adapter->mgmt, MGMT_EV_NEW_SETTINGS, adapter->index,
@@ -334,6 +351,10 @@ static void register_mgmt_handlers(void)
 	mgmt_register(adapter->mgmt, MGMT_EV_USER_CONFIRM_REQUEST,
 				adapter->index, user_confirm_request_callback,
 				NULL, NULL);
+
+	mgmt_register(adapter->mgmt, MGMT_EV_USER_PASSKEY_REQUEST,
+				adapter->index, user_passkey_request_callback,
+				NULL, NULL);
 }
 
 static void load_link_keys_complete(uint8_t status, uint16_t length,
-- 
1.8.4.rc3


^ permalink raw reply related

* [PATCH 12/14] android: Add support for notify variant in SSP request event
From: Szymon Janc @ 2013-10-31  2:55 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1383188154-22905-1-git-send-email-szymon.janc@tieto.com>

---
 android/adapter.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/android/adapter.c b/android/adapter.c
index 1be0fb3..00766eb 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -329,6 +329,26 @@ static void user_passkey_request_callback(uint16_t index, uint16_t length,
 	send_ssp_request(&ev->addr.bdaddr, HAL_SSP_VARIANT_ENTRY, 0);
 }
 
+static void user_passkey_notify_callback(uint16_t index, uint16_t length,
+					const void *param, void *user_data)
+{
+	const struct mgmt_ev_passkey_notify *ev = param;
+	char dst[18];
+
+	if (length < sizeof(*ev)) {
+		error("Too small passkey notify event");
+		return;
+	}
+
+	ba2str(&ev->addr.bdaddr, dst);
+	DBG("%s entered %u", dst, ev->entered);
+
+	/* HAL seems to not support entered characters */
+	if (!ev->entered)
+		send_ssp_request(&ev->addr.bdaddr, HAL_SSP_VARIANT_NOTIF,
+								ev->passkey);
+}
+
 static void register_mgmt_handlers(void)
 {
 	mgmt_register(adapter->mgmt, MGMT_EV_NEW_SETTINGS, adapter->index,
@@ -355,6 +375,10 @@ static void register_mgmt_handlers(void)
 	mgmt_register(adapter->mgmt, MGMT_EV_USER_PASSKEY_REQUEST,
 				adapter->index, user_passkey_request_callback,
 				NULL, NULL);
+
+	mgmt_register(adapter->mgmt, MGMT_EV_PASSKEY_NOTIFY, adapter->index,
+				user_passkey_notify_callback, NULL, NULL);
+
 }
 
 static void load_link_keys_complete(uint8_t status, uint16_t length,
-- 
1.8.4.rc3


^ permalink raw reply related

* [PATCH 13/14] android: Add support for handling pin reply command
From: Szymon Janc @ 2013-10-31  2:55 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1383188154-22905-1-git-send-email-szymon.janc@tieto.com>

---
 android/adapter.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/android/adapter.c b/android/adapter.c
index 00766eb..a6382dd 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -771,6 +771,49 @@ static bool remove_bond(void *buf, uint16_t len)
 	return true;
 }
 
+static uint8_t pin_reply(void *buf, uint16_t len)
+{
+	struct hal_cmd_pin_reply *cmd = buf;
+	bdaddr_t bdaddr;
+	char addr[18];
+
+	android2bdaddr(cmd->bdaddr, &bdaddr);
+	ba2str(&bdaddr, addr);
+
+	DBG("%s accept %u pin_len %u", addr, cmd->accept, cmd->pin_len);
+
+	if (!cmd->accept && cmd->pin_len)
+		return HAL_STATUS_INVALID;
+
+	if (cmd->accept) {
+		struct mgmt_cp_pin_code_reply rp;
+
+		memset(&rp, 0, sizeof(rp));
+
+		bacpy(&rp.addr.bdaddr, &bdaddr);
+		rp.addr.type = BDADDR_BREDR;
+		rp.pin_len = cmd->pin_len;
+		memcpy(rp.pin_code, cmd->pin_code, rp.pin_len);
+
+		if (mgmt_reply(adapter->mgmt, MGMT_OP_PIN_CODE_REPLY,
+					adapter->index, sizeof(rp), &rp,
+					NULL, NULL, NULL) == 0)
+			return HAL_STATUS_FAILED;
+	} else {
+		struct mgmt_cp_pin_code_neg_reply rp;
+
+		bacpy(&rp.addr.bdaddr, &bdaddr);
+		rp.addr.type = BDADDR_BREDR;
+
+		if (mgmt_reply(adapter->mgmt, MGMT_OP_PIN_CODE_NEG_REPLY,
+					adapter->index, sizeof(rp), &rp,
+					NULL, NULL, NULL) == 0)
+			return HAL_STATUS_FAILED;
+	}
+
+	return HAL_STATUS_SUCCESS;
+}
+
 void bt_adapter_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf,
 								uint16_t len)
 {
@@ -823,6 +866,12 @@ void bt_adapter_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf,
 			goto error;
 
 		break;
+	case HAL_OP_PIN_REPLY:
+		status = pin_reply(buf, len);
+		if (status != HAL_STATUS_SUCCESS)
+			goto error;
+
+		break;
 	default:
 		DBG("Unhandled command, opcode 0x%x", opcode);
 		goto error;
-- 
1.8.4.rc3


^ permalink raw reply related

* [PATCH 14/14] android: Add support for handling SSP reply command
From: Szymon Janc @ 2013-10-31  2:55 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1383188154-22905-1-git-send-email-szymon.janc@tieto.com>

---
 android/adapter.c | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 94 insertions(+)

diff --git a/android/adapter.c b/android/adapter.c
index a6382dd..9e12879 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -814,6 +814,94 @@ static uint8_t pin_reply(void *buf, uint16_t len)
 	return HAL_STATUS_SUCCESS;
 }
 
+static uint8_t user_confirm_reply(const bdaddr_t *bdaddr, bool accept)
+{
+	struct mgmt_addr_info cp;
+	uint16_t opcode;
+
+	if (accept)
+		opcode = MGMT_OP_USER_CONFIRM_REPLY;
+	else
+		opcode = MGMT_OP_USER_CONFIRM_NEG_REPLY;
+
+	bacpy(&cp.bdaddr, bdaddr);
+	cp.type = BDADDR_BREDR;
+
+	if (mgmt_reply(adapter->mgmt, opcode, adapter->index, sizeof(cp), &cp,
+							NULL, NULL, NULL) > 0)
+		return HAL_STATUS_SUCCESS;
+
+	return HAL_STATUS_FAILED;
+}
+
+static uint8_t user_passkey_reply(const bdaddr_t *bdaddr, bool accept,
+							uint32_t passkey)
+{
+	unsigned int id;
+
+	if (accept) {
+		struct mgmt_cp_user_passkey_reply cp;
+
+		memset(&cp, 0, sizeof(cp));
+		bacpy(&cp.addr.bdaddr, bdaddr);
+		cp.addr.type = BDADDR_BREDR;
+		cp.passkey = htobl(passkey);
+
+		id = mgmt_reply(adapter->mgmt, MGMT_OP_USER_PASSKEY_REPLY,
+					adapter->index, sizeof(cp), &cp,
+					NULL, NULL, NULL);
+	} else {
+		struct mgmt_cp_user_passkey_neg_reply cp;
+
+		memset(&cp, 0, sizeof(cp));
+		bacpy(&cp.addr.bdaddr, bdaddr);
+		cp.addr.type = BDADDR_BREDR;
+
+		id = mgmt_reply(adapter->mgmt, MGMT_OP_USER_PASSKEY_NEG_REPLY,
+					adapter->index, sizeof(cp), &cp,
+					NULL, NULL, NULL);
+	}
+
+	if (id == 0)
+		return HAL_STATUS_FAILED;
+
+	return HAL_STATUS_SUCCESS;
+}
+
+static uint8_t ssp_reply(void *buf, uint16_t len)
+{
+	struct hal_cmd_ssp_reply *cmd = buf;
+	uint8_t status;
+	bdaddr_t bdaddr;
+	char addr[18];
+
+	/* TODO should parameters sanity be verified here? */
+
+	android2bdaddr(cmd->bdaddr, &bdaddr);
+	ba2str(&bdaddr, addr);
+
+	DBG("%s variant %u accept %u", addr, cmd->ssp_variant, cmd->accept);
+
+	switch (cmd->ssp_variant) {
+	case HAL_SSP_VARIANT_CONFIRM:
+	case HAL_SSP_VARIANT_CONSENT:
+		status = user_confirm_reply(&bdaddr, cmd->accept);
+		break;
+	case HAL_SSP_VARIANT_ENTRY:
+		status = user_passkey_reply(&bdaddr, cmd->accept,
+								cmd->passkey);
+		break;
+	case HAL_SSP_VARIANT_NOTIF:
+		status = HAL_STATUS_SUCCESS;
+		break;
+	default:
+		status = HAL_STATUS_INVALID;
+		break;
+	}
+
+	return status;
+}
+
 void bt_adapter_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf,
 								uint16_t len)
 {
@@ -872,6 +960,12 @@ void bt_adapter_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf,
 			goto error;
 
 		break;
+	case HAL_OP_SSP_REPLY:
+		status = ssp_reply(buf, len);
+		if (status != HAL_STATUS_SUCCESS)
+			goto error;
+
+		break;
 	default:
 		DBG("Unhandled command, opcode 0x%x", opcode);
 		goto error;
-- 
1.8.4.rc3


^ permalink raw reply related

* Re: Intel 7260 bluetooth malfunction when it is connected to EHCI bus
From: Hui Wang @ 2013-10-31  5:15 UTC (permalink / raw)
  To: Tedd Ho-Jeong An
  Cc: Marcel Holtmann, Johan Hedberg, xiong.y.zhang, Gustavo F. Padovan,
	linux-bluetooth@vger.kernel.org development
In-Reply-To: <1415253.BKnruDjiCq@han1-desk-dev>


[-- Attachment #1.1: Type: text/plain, Size: 1797 bytes --]

On 10/31/2013 03:36 AM, Tedd Ho-Jeong An wrote:
>
> On Wednesday, October 30, 2013 10:51:20 AM Hui Wang wrote:
>
> > On 10/29/2013 07:16 PM, Marcel Holtmann wrote:
>
> > > Hi Hui,
>
> > >
>
> > >> The problem is:
>
> > >> On the machine which has Intel 7260 BT module, i use it to connect a
>
> > >> bluetooth headset, it can successfully scan and connect to the 
> headset,
>
> > >> when i play sound to the bt headset, the problem comes, if the bt 
> module
>
> > >> is connected to the XHCI, it can work very well.
>
> > >>
>
> > >> u@u-Lenovo-B4400:~$ lsusb -t
>
> > >> 1-7:1.0: No such file or directory
>
> > >> /: Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 5000M
>
<snip>
>
> >
>
> > > Regards
>
> > >
>
> > > Marcel
>
> Hi Hui,
>
> Could you capture the HCI dump and send to me? Also, what's the 
> platform/machine are you using for testing?
>
> Regards,
>
> Tedd
>

Hi Tedd,

The attachment is the log generated by hcidump, i used below commands to 
generate the log,

$hcidump -w ./lenovo-k4450-bt-ascii-hex.log -X -t

Then i start the bluetooth scan from the ubuntu bluetooth applet

it found the hm1700 headset, then it connected the headset successfully

play sound to the headset, can't hear any sound

Ctrl+C to terminate the hcidump


I have three machines on which install the intel 7260 BT module 
(8087:07dc), and BT module firmware version is 370710018002030d2e, and 
those modules are connected to the EHCI bus, they all have the same 
problem when i want them to work with the BT headset. The three machines 
are lenovo b4400, lenovo k4450 and lenovo m4400s.

I also have dozens of other machines on which the 7260 BT modules are 
connected to XHCI, they all work well to play sound to a headset.

So do you think it is a firmware issue?

Regards,
Hui.







[-- Attachment #1.2: Type: text/html, Size: 6834 bytes --]

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: lenovo-k4450-bt-ascii-hex.log --]
[-- Type: text/x-log; name="lenovo-k4450-bt-ascii-hex.log", Size: 2060 bytes --]

btsnoop\0\0\0\0\x01\0\0\x03ê\0\0\0\r\0\0\0\r\0\0\0\x03\0\0\0\0\0áǵY\\x02¢\x04\x04
ß^\b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\0\0\0\0\0\0\0\0\0\0\0\0\0\0\a\0\0\0\a\0\0\0\x03\0\0\0\0\0áǵZ`Q^[\x04\x0f\x04\0\x01\x11\x04\0\0\0\r\0\0\0\r\0\0\0\x03\0\0\0\0\0áǵZa/—\x04\x0e
\x01\f\x04\0ß^\b¾÷x\0\0\0\r\0\0\0\r\0\0\0\x03\0\0\0\0\0áǵZa7c\x04\x0e
\x01+\x04\0ß^\b¾÷x\0\0\0\r\0\0\0\r\0\0\0\x03\0\0\0\0\0áǵZdô8\x04\x0e
\x01,\x04\0ß^\b¾÷x\0\0\0\x06\0\0\0\x06\0\0\0\x03\0\0\0\0\0áǵZl|¸\x04\x06\x03\0\0\x01\0\0\0\a\0\0\0\a\0\0\0\x03\0\0\0\0\0áǵZl€×\x04\x0f\x04\0\x01\x13\x04\0\0\0\a\0\0\0\a\0\0\0\x03\0\0\0\0\0áǵZm(y\x04\b\x04\0\0\x01\x01\0\0\0\a\0\0\0\a\0\0\0\x03\0\0\0\0\0áǵZɈï\x04\x0f\x04\0\x01(\x04\0\0\0\x14\0\0\0\x14\0\0\0\x03\0\0\0\0\0áǵZÉâÆ\x04,\x11\0\x01\x01ß^\b¾÷x\x02\f\x02<\0<\0\x02\0\0\0\a\0\0\0\a\0\0\0\x03\0\0\0\0\0áǵ[\x16•Z\x04\x0f\x04\0\x01\x06\x04\0\0\0\a\0\0\0\a\0\0\0\x03\0\0\0\0\0áǵ[\x18;\x06\x04\x05\x04\0\x01\x01\x16\0\0\0\a\0\0\0\a\0\0\0\x03\0\0\0\0\0áǵ[X"\a\x04\x0f\x04\0\x01(\x04\0\0\0\x14\0\0\0\x14\0\0\0\x03\0\0\0\0\0áǵ[X{Ò\x04,\x11\0\x01\x01ß^\b¾÷x\x02\f\x02<\0<\0\x02\0\0\0\a\0\0\0\a\0\0\0\x03\0\0\0\0\0áǵ[Üá\a\x04\x0f\x04\0\x01\x06\x04

^ permalink raw reply

* Re: Intel 7260 bluetooth malfunction when it is connected to EHCI bus
From: Hui Wang @ 2013-10-31  5:29 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Tedd An, Johan Hedberg, xiong.y.zhang, Gustavo F. Padovan,
	linux-bluetooth@vger.kernel.org development
In-Reply-To: <6091DDC7-7B00-4457-82A0-F8CC9B4EE9DD@holtmann.org>

On 10/31/2013 03:44 AM, Marcel Holtmann wrote:
> Hi Hui,
>
>>>> The problem is:
>>>> On the machine which has Intel 7260 BT module, i use it to connect a bluetooth headset,
>>>> it can successfully scan and connect to the headset, when i play sound to the bt headset,
>>>> the problem comes, if the bt module is connected to the XHCI, it can work very well.
>>>>
>>>> u@u-Lenovo-B4400:~$ lsusb -t
>>>> 1-7:1.0: No such file or directory
>>>> /: Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 5000M
>>>> /: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/14p, 480M
>>>>     |__ Port 6: Dev 8, If 0, Class=HID, Driver=usbhid, 1.5M
>>>>     |__ Port 7: Dev 2, If 0, Class=vend., Driver=, 12M
>>>>     |__ Port 11: Dev 3, If 0, Class='bInterfaceClass 0xe0 not yet handled', Driver=btusb, 12M
>>>>     |__ Port 11: Dev 3, If 1, Class='bInterfaceClass 0xe0 not yet handled', Driver=btusb, 12M
>>>>
>>>> But if the bt module is connected to the EHCI, it always fails to play sound.
>>>>
>>>> u@u-Lenovo-B4400:~$ lsusb -t
>>>> /: Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 5000M
>>>> /: Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/14p, 480M
>>>> /: Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ehci_hcd/3p, 480M
>>>>     |__ Port 1: Dev 2, If 0, Class=hub, Driver=hub/8p, 480M
>>>> /: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci_hcd/3p, 480M
>>>>     |__ Port 1: Dev 2, If 0, Class=hub, Driver=hub/6p, 480M
>>>>         |__ Port 5: Dev 3, If 0, Class='bInterfaceClass 0xe0 not yet handled', Driver=btusb, 12M
>>>>         |__ Port 5: Dev 3, If 1, Class='bInterfaceClass 0xe0 not yet handled', Driver=btusb, 12M
>>>>         |__ Port 6: Dev 4, If 0, Class='bInterfaceClass 0x0e not yet handled', Driver=uvcvideo, 480M
>>>>         |__ Port 6: Dev 4, If 1, Class='bInterfaceClass 0x0e not yet handled', Driver=uvcvideo, 480M
>>> can you paste /sys/kernel/debug/usb/devices here.
>>>
>>> If the uvcvideo driver is also using ISOC URBs, we might have just exhausted the bandwidth of the USB bus here or these two devices just do not play nice with each other.
>>>
>>> Try to unload the uvcvideo driver and try it again.
>> Thanks for your reply, follow your instruction, i totally disabled the camera from the BIOS, then the usb tree like this,
>> u@u-Lenovo-B4400:~$ lsusb -t
>> 1-1.3:1.0: No such file or directory
>> /:  Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 5000M
>> /:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/14p, 480M
>> /:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/3p, 480M
>>     |__ Port 1: Dev 2, If 0, Class=hub, Driver=hub/8p, 480M
>> /:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/3p, 480M
>>     |__ Port 1: Dev 2, If 0, Class=hub, Driver=hub/6p, 480M
>>         |__ Port 2: Dev 3, If 0, Class=HID, Driver=usbhid, 1.5M
>>         |__ Port 3: Dev 4, If 0, Class=vend., Driver=, 12M
>>         |__ Port 5: Dev 5, If 0, Class='bInterfaceClass 0xe0 not yet handled', Driver=btusb, 12M
>>         |__ Port 5: Dev 5, If 1, Class='bInterfaceClass 0xe0 not yet handled', Driver=btusb, 12M
>> u@u-Lenovo-B4400:~$ uname -a
>> Linux u-Lenovo-B4400 3.12.0-031200rc6-generic #201310191635 SMP Sat Oct 19 20:36:43 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
>>
>> I re-did the test, the result is same as before, after the headset is connected and i play audio, no sound is heard from the headset.
>> And hciconfig output shows still no SCO packets received by BT driver.
>> u@u-Lenovo-B4400:~$ hciconfig
>> hci0:    Type: BR/EDR  Bus: USB
>>     BD Address: 00:15:00:CC:2D:D2  ACL MTU: 1021:5  SCO MTU: 96:5
>>     UP RUNNING PSCAN
>>     RX bytes:5853 acl:61 sco:0 events:298 errors:0
>>     TX bytes:19212 acl:68 sco:1 commands:179 errors:0
> this is strange. The only reason I can think of is that you do not have the firmware installed and or it is not loaded correctly. Does dmesg give any indication that something failed here.
I can confirm the firmware file is the 
/lib/firmware/intel/ibt-hw-37.7.10-fw-1.80.2.3.d.bseq, and it is in the 
filesystem. And from the dmesg, the firmware was successfully loaded.

[    8.600217] Bluetooth: hci0: Intel Bluetooth firmware file: 
intel/ibt-hw-37.7.10-fw-1.80.2.3.d.bseq
[    8.653635] kvm: disabled by bios
[    8.672981] psmouse serio1: synaptics: Touchpad model: 1, fw: 8.1, 
id: 0x1e2b1, caps: 0xd00123/0x840300/0x126c00
[    8.707034] input: SynPS/2 Synaptics TouchPad as 
/devices/platform/i8042/serio1/input/input13
[    8.717725] Registered led device: phy0-led
[    8.722730] ieee80211 phy0: Selected rate control algorithm 'iwl-mvm-rs'
[    8.752626] Bluetooth: hci0: Intel Bluetooth firmware patch completed 
and activated

> Since this is a 3.12 kernel it should have native support for Intel specific setup routing. Any chance you can run btmon -w <file> before plugging the device into the bus. Maybe something goes wrong with the setup routine on EHCI.
Do you mean the hcidump file i just sent in my previous email.

In case some of you can't receive the attachment, i decode the log file 
here:

u@u-Lenovo-K4450:~$ hcidump -r lenovo-k4450-bt-ascii-hex.log
HCI sniffer - Bluetooth packet analyzer ver 2.2
btsnoop version: 1 datalink type: 1002
 > HCI Event: Connect Request (0x04) plen 10
     bdaddr 78:F7:BE:08:5E:DF class 0x240404 type ACL
 > HCI Event: Command Status (0x0f) plen 4
     Accept Connection Request (0x01|0x0009) status 0x00 ncmd 1
 > HCI Event: Connect Complete (0x03) plen 11
     status 0x00 handle 256 bdaddr 78:F7:BE:08:5E:DF type ACL encrypt 0x00
 > HCI Event: Command Status (0x0f) plen 4
     Read Remote Supported Features (0x01|0x001b) status 0x00 ncmd 1
 > HCI Event: Read Remote Supported Features (0x0b) plen 11
     status 0x00 handle 256
     Features: 0xbf 0xfe 0x8f 0xfe 0x9b 0xff 0x79 0x87
 > HCI Event: Command Status (0x0f) plen 4
     Read Remote Extended Features (0x01|0x001c) status 0x00 ncmd 1
 > HCI Event: Read Remote Extended Features (0x23) plen 13
     status 0x00 handle 256 page 1 max 0
     Features: 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00
 > HCI Event: Command Status (0x0f) plen 4
     Remote Name Request (0x01|0x0019) status 0x00 ncmd 1
 > HCI Event: Remote Name Req Complete (0x07) plen 255
     status 0x00 bdaddr 78:F7:BE:08:5E:DF name 'HM1700'
 > HCI Event: Command Complete (0x0e) plen 10
     Link Key Request Negative Reply (0x01|0x000c) ncmd 1
     status 0x00 bdaddr 78:F7:BE:08:5E:DF
 > HCI Event: Command Complete (0x0e) plen 10
     IO Capability Request Reply (0x01|0x002b) ncmd 1
     status 0x00 bdaddr 78:F7:BE:08:5E:DF
 > HCI Event: Command Complete (0x0e) plen 10
     User Confirmation Request Negative Reply (0x01|0x002d) ncmd 1
     status 0x00 bdaddr 78:F7:BE:08:5E:DF
 > HCI Event: Disconn Complete (0x05) plen 4
     status 0x00 handle 256 reason 0x13
     Reason: Remote User Terminated Connection
 > HCI Event: Command Status (0x0f) plen 4
     Inquiry (0x01|0x0001) status 0x00 ncmd 2
 > HCI Event: Extended Inquiry Result (0x2f) plen 255
     bdaddr 78:F7:BE:08:5E:DF mode 1 clkoffset 0x0391 class 0x240404 
rssi -52
     Unknown type 0x48 with 8 bytes data
     Shortened local name: '..'
 > HCI Event: Command Complete (0x0e) plen 4
     Inquiry Cancel (0x01|0x0002) ncmd 2
     status 0x00
 > HCI Event: Command Status (0x0f) plen 4
     Create Connection (0x01|0x0005) status 0x00 ncmd 1
 > HCI Event: Connect Complete (0x03) plen 11
     status 0x00 handle 256 bdaddr 78:F7:BE:08:5E:DF type ACL encrypt 0x00
 > HCI Event: Command Status (0x0f) plen 4
     Read Remote Supported Features (0x01|0x001b) status 0x00 ncmd 1
 > HCI Event: Read Remote Supported Features (0x0b) plen 11
     status 0x00 handle 256
     Features: 0xbf 0xfe 0x8f 0xfe 0x9b 0xff 0x79 0x87
 > HCI Event: Command Status (0x0f) plen 4
     Read Remote Extended Features (0x01|0x001c) status 0x00 ncmd 1
 > HCI Event: Read Remote Extended Features (0x23) plen 13
     status 0x00 handle 256 page 1 max 0
     Features: 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00
 > HCI Event: Command Status (0x0f) plen 4
     Remote Name Request (0x01|0x0019) status 0x00 ncmd 1
 > HCI Event: Remote Name Req Complete (0x07) plen 255
     status 0x00 bdaddr 78:F7:BE:08:5E:DF name 'HM1700'
 > HCI Event: Command Status (0x0f) plen 4
     Authentication Requested (0x01|0x0011) status 0x00 ncmd 1
 > HCI Event: Command Complete (0x0e) plen 10
     Link Key Request Negative Reply (0x01|0x000c) ncmd 1
     status 0x00 bdaddr 78:F7:BE:08:5E:DF
 > HCI Event: Command Complete (0x0e) plen 10
     IO Capability Request Reply (0x01|0x002b) ncmd 1
     status 0x00 bdaddr 78:F7:BE:08:5E:DF
 > HCI Event: Command Complete (0x0e) plen 10
     User Confirmation Request Reply (0x01|0x002c) ncmd 1
     status 0x00 bdaddr 78:F7:BE:08:5E:DF
 > HCI Event: Auth Complete (0x06) plen 3
     status 0x00 handle 256
 > HCI Event: Command Status (0x0f) plen 4
     Set Connection Encryption (0x01|0x0013) status 0x00 ncmd 1
 > HCI Event: Encrypt Change (0x08) plen 4
     status 0x00 handle 256 encrypt 0x01
 > HCI Event: Command Status (0x0f) plen 4
     Setup Synchronous Connection (0x01|0x0028) status 0x00 ncmd 1
 > HCI Event: Synchronous Connect Complete (0x2c) plen 17
     status 0x00 handle 257 bdaddr 78:F7:BE:08:5E:DF type eSCO
     Air mode: CVSD
 > HCI Event: Command Status (0x0f) plen 4
     Disconnect (0x01|0x0006) status 0x00 ncmd 1
 > HCI Event: Disconn Complete (0x05) plen 4
     status 0x00 handle 257 reason 0x16
     Reason: Connection Terminated by Local Host
 > HCI Event: Command Status (0x0f) plen 4
     Setup Synchronous Connection (0x01|0x0028) status 0x00 ncmd 1
 > HCI Event: Synchronous Connect Complete (0x2c) plen 17
     status 0x00 handle 257 bdaddr 78:F7:BE:08:5E:DF type eSCO
     Air mode: CVSD
 > HCI Event: Command Status (0x0f) plen 4
     Disconnect (0x01|0x0006) status 0x00 ncmd 1


Regards,
Hui.

>
> Regards
>
> Marcel
>
>

^ permalink raw reply

* Re: [PATCH 1/2] android/hal: Add initial socket implementation
From: Johan Hedberg @ 2013-10-31  8:33 UTC (permalink / raw)
  To: Marcin Kraglak; +Cc: linux-bluetooth
In-Reply-To: <1383146193-13240-1-git-send-email-marcin.kraglak@tieto.com>

Hi Marcin,

On Wed, Oct 30, 2013, Marcin Kraglak wrote:
> Added socket api opcodes and structures and its implementation
> in hal-sock.c.
> ---
>  android/hal-msg.h  | 20 ++++++++++++++++++++
>  android/hal-sock.c | 28 ++++++++++++++++++++++++++--
>  2 files changed, 46 insertions(+), 2 deletions(-)

Both patches have been applied. Thanks.

Johan

^ permalink raw reply

* Re: [PATCH 1/2] android: Add initial sdp implementation
From: Johan Hedberg @ 2013-10-31  8:34 UTC (permalink / raw)
  To: Marcin Kraglak; +Cc: linux-bluetooth
In-Reply-To: <1383146314-13456-1-git-send-email-marcin.kraglak@tieto.com>

Hi Marcin,

On Wed, Oct 30, 2013, Marcin Kraglak wrote:
> Add and remove records to sdp server. This api will
> be used in android's profiles implementations.
> ---
>  android/adapter.c | 11 +++++++++++
>  android/adapter.h |  4 ++++
>  2 files changed, 15 insertions(+)
> 
> diff --git a/android/adapter.c b/android/adapter.c
> index 15b65e5..325d0f0 100644
> --- a/android/adapter.c
> +++ b/android/adapter.c
> @@ -26,6 +26,7 @@
>  #include <glib.h>
>  
>  #include "lib/bluetooth.h"
> +#include "src/sdpd.h"
>  #include "src/shared/mgmt.h"
>  #include "lib/mgmt.h"
>  #include "log.h"
> @@ -528,6 +529,16 @@ error:
>  	ipc_send_rsp(io, HAL_SERVICE_ID_BLUETOOTH, status);
>  }
>  
> +int bt_adapter_service_add(sdp_record_t *rec)
> +{
> +	return add_record_to_server(&adapter->bdaddr, rec);
> +}
> +
> +void bt_adapter_service_remove(uint32_t handle)
> +{
> +	remove_record_from_server(handle);
> +}
> +
>  const bdaddr_t *bt_adapter_get_address(void)
>  {
>  	return &adapter->bdaddr;
> diff --git a/android/adapter.h b/android/adapter.h
> index 2afc67a..c5ba76b 100644
> --- a/android/adapter.h
> +++ b/android/adapter.h
> @@ -27,6 +27,7 @@
>  #include <glib.h>
>  
>  #include "lib/bluetooth.h"
> +#include "lib/sdp.h"
>  
>  typedef void (*bt_adapter_ready)(int err);
>  
> @@ -38,5 +39,8 @@ void bt_adapter_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf,
>  
>  const bdaddr_t *bt_adapter_get_address(void);
>  
> +int bt_adapter_service_add(sdp_record_t *rec);
> +void bt_adapter_service_remove(uint32_t handle);
> +
>  bool bt_adapter_register(GIOChannel *io);
>  void bt_adapter_unregister(void);

I'd like to see some code that actually uses these functions before
applying this patch.

Johan

^ permalink raw reply

* [PATCH 1/2] android/haltest: Use Android system headers instead of local
From: Andrei Emeltchenko @ 2013-10-31  8:37 UTC (permalink / raw)
  To: linux-bluetooth

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

---
 android/Android.mk |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/android/Android.mk b/android/Android.mk
index 3c4a825..e47f4a9 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -121,6 +121,10 @@ LOCAL_SRC_FILES := \
 	client/if-pan.c \
 	client/if-sock.c \
 
+LOCAL_C_INCLUDES += \
+	$(call include-path-for, system-core) \
+	$(call include-path-for, libhardware) \
+
 LOCAL_CFLAGS := $(BLUEZ_COMMON_CFLAGS)
 
 LOCAL_SHARED_LIBRARIES := libhardware
-- 
1.7.10.4


^ permalink raw reply related

* [PATCH 2/2] android/haltest: Fix bug when building for Android 4.2.2
From: Andrei Emeltchenko @ 2013-10-31  8:37 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1383208640-6644-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

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

Since I started to use system Android headers instead of local this
bug was found.
---
 android/client/if-bt.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/android/client/if-bt.c b/android/client/if-bt.c
index cbb828b..f1410f7 100644
--- a/android/client/if-bt.c
+++ b/android/client/if-bt.c
@@ -679,10 +679,10 @@ static void get_profile_interface_c(int argc, const char **argv,
 		BT_PROFILE_SOCKETS_ID,
 		BT_PROFILE_HIDHOST_ID,
 		BT_PROFILE_PAN_ID,
-#if PLATFORM_SDK_VERSION >= 18
+#if PLATFORM_SDK_VERSION > 17
 		BT_PROFILE_GATT_ID,
-#endif
 		BT_PROFILE_AV_RC_ID,
+#endif
 		NULL
 	};
 
-- 
1.7.10.4


^ permalink raw reply related

* Re: [PATCH 2/2] android: Add supported uuids when adapter initialized
From: Johan Hedberg @ 2013-10-31  8:41 UTC (permalink / raw)
  To: Marcin Kraglak; +Cc: linux-bluetooth
In-Reply-To: <1383146314-13456-2-git-send-email-marcin.kraglak@tieto.com>

Hi Marcin,

On Wed, Oct 30, 2013, Marcin Kraglak wrote:
> +/*
> + * This is an array of supported uuids and service hints. We add them via mgmt
> + * interface when adapter is initialized. Uuids are in reverse orded.
> + */
> +static const struct mgmt_cp_add_uuid sup_uuids[] = {
> +	/* OBEX */
> +	{{0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80, 0x00,
> +	0x10, 0x00, 0x00, 0x05, 0x11, 0x00, 0x00}, 0x10},
> +	/* TELEPHONY */
> +	{{0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80, 0x00,
> +	0x10, 0x00, 0x00, 0x1f, 0x11, 0x00, 0x00}, 0x40},
> +	/* CAPTURING */
> +	{{0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80, 0x00,
> +	0x10, 0x00, 0x00, 0x0d, 0x11, 0x00, 0x00}, 0x08},
> +	/* NETWORKING */
> +	{{0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80, 0x00,
> +	0x10, 0x00, 0x00, 0x15, 0x11, 0x00, 0x00}, 0x02} };

I think you should at least mention here exactly which UUIDs you're
adding. It looks like it's OPP, HFP AG, Advanced Audio and PANU but it'd
be nicer to be clear about this in the code comment.

The table would also be more readable if you did something like

static const struct mgmt_cp_add_uuid uuids[] = {
	{ .uuid = ...,
	  .svc_hint = ... },
	{ .uuid = ...,
	  .svc_hint = ... },
};

Note that our coding style puts a space after { and before }.

Johan

^ permalink raw reply

* Re: [PATCH] android: Use Android headers instead of local ones
From: Johan Hedberg @ 2013-10-31  8:42 UTC (permalink / raw)
  To: Andrei Emeltchenko; +Cc: linux-bluetooth
In-Reply-To: <1383148285-20937-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

Hi Andrei,

On Wed, Oct 30, 2013, Andrei Emeltchenko wrote:
> Add path to Android libhardware library headers
> ---
>  android/Android.mk |    1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/android/Android.mk b/android/Android.mk
> index fc1b276..88dff4b 100644
> --- a/android/Android.mk
> +++ b/android/Android.mk
> @@ -86,6 +86,7 @@ LOCAL_SRC_FILES := \
>  
>  LOCAL_C_INCLUDES += \
>  	$(call include-path-for, system-core) \
> +	$(call include-path-for, libhardware) \
>  
>  LOCAL_SHARED_LIBRARIES := \
>  	libcutils \

Applied. Thanks.

Johan

^ permalink raw reply

* Re: [PATCH 08/14] android: Add support for handling remove bond command
From: Johan Hedberg @ 2013-10-31  8:48 UTC (permalink / raw)
  To: Szymon Janc; +Cc: linux-bluetooth, Szymon Janc
In-Reply-To: <1383188154-22905-9-git-send-email-szymon.janc@tieto.com>

Hi Szymon,

On Thu, Oct 31, 2013, Szymon Janc wrote:
> ---
>  android/adapter.c | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
> 
> diff --git a/android/adapter.c b/android/adapter.c
> index 0f174a6..0a91149 100644
> --- a/android/adapter.c
> +++ b/android/adapter.c
> @@ -639,6 +639,26 @@ static bool cancel_bond(void *buf, uint16_t len)
>  				NULL) > 0;
>  }
>  
> +static bool remove_bond(void *buf, uint16_t len)
> +{
> +	struct hal_cmd_remove_bond *cmd = buf;
> +	struct mgmt_cp_unpair_device cp;
> +
> +	cp.disconnect = 1;
> +	cp.addr.type = BDADDR_BREDR;
> +	android2bdaddr(cmd->bdaddr, &cp.addr.bdaddr);
> +
> +	if (mgmt_send(adapter->mgmt, MGMT_OP_UNPAIR_DEVICE,
> +				adapter->index, sizeof(cp), &cp,
> +				NULL, NULL, NULL) == 0)
> +		return false;
> +
> +	send_bond_state_change(&cp.addr.bdaddr, HAL_STATUS_SUCCESS,
> +							HAL_BOND_STATE_NONE);

Wouldn't this state change make more sense to send in the mgmt command
complete callback?

Johan

^ permalink raw reply

* Re: [PATCH 07/14] android: Add support for handling cancel bond command
From: Johan Hedberg @ 2013-10-31  8:50 UTC (permalink / raw)
  To: Szymon Janc; +Cc: linux-bluetooth, Szymon Janc
In-Reply-To: <1383188154-22905-8-git-send-email-szymon.janc@tieto.com>

Hi Szymon,

On Thu, Oct 31, 2013, Szymon Janc wrote:
> ---
>  android/adapter.c | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)

Patches 1-7 have been applied. Thanks.

Johan

^ permalink raw reply

* Re: [PATCH 14/14] android: Add support for handling SSP reply command
From: Johan Hedberg @ 2013-10-31  8:52 UTC (permalink / raw)
  To: Szymon Janc; +Cc: linux-bluetooth, Szymon Janc
In-Reply-To: <1383188154-22905-15-git-send-email-szymon.janc@tieto.com>

Hi Szymon,

On Thu, Oct 31, 2013, Szymon Janc wrote:
> ---
>  android/adapter.c | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 94 insertions(+)

Patches 9-14 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