Linux bluetooth development
 help / color / mirror / Atom feed
* Re: [PATCH] android/pts: Correct typo
From: Szymon Janc @ 2014-01-31 13:44 UTC (permalink / raw)
  To: Sebastian Chlad; +Cc: linux-bluetooth
In-Reply-To: <1391186806-18925-1-git-send-email-sebastianchlad@gmail.com>

Hi Sebastian,

On Friday 31 of January 2014 18:46:46 Sebastian Chlad wrote:
> ---
>  android/pts-hid.txt | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/android/pts-hid.txt b/android/pts-hid.txt
> index 7e9f986..c29c9dc 100644
> --- a/android/pts-hid.txt
> +++ b/android/pts-hid.txt
> @@ -1,4 +1,4 @@
> -PTS test results for DID
> +PTS test results for HID
> 
>  PTS version: 4.9
>  Tested: 14.11.2013

Pushed, thanks.

-- 
BR
Szymon Janc

^ permalink raw reply

* Re: [PATCH] android/pts: Add Android version to PTS tests
From: Szymon Janc @ 2014-01-31 13:44 UTC (permalink / raw)
  To: Sebastian Chlad; +Cc: linux-bluetooth
In-Reply-To: <1391186602-18769-1-git-send-email-sebastianchlad@gmail.com>

Hi Sebastian,

On Friday 31 of January 2014 18:43:22 Sebastian Chlad wrote:
> This trivial patch adds Android version to the PTS test results.
> It helps tracking tests status.
> ---
>  android/pts-a2dp.txt  | 1 +
>  android/pts-avctp.txt | 1 +
>  android/pts-avrcp.txt | 1 +
>  android/pts-did.txt   | 1 +
>  android/pts-gap.txt   | 1 +
>  android/pts-l2cap.txt | 1 +
>  android/pts-opp.txt   | 1 +
>  android/pts-pbap.txt  | 1 +
>  8 files changed, 8 insertions(+)
> 
> diff --git a/android/pts-a2dp.txt b/android/pts-a2dp.txt
> index 3d1085e..301b1e7 100644
> --- a/android/pts-a2dp.txt
> +++ b/android/pts-a2dp.txt
> @@ -2,6 +2,7 @@ PTS test results for A2DP
> 
>  PTS version: 5.0
>  Tested: 28.01.2014
> +Android version: 4.4.2
> 
>  Results:
>  PASS	test passed
> diff --git a/android/pts-avctp.txt b/android/pts-avctp.txt
> index a57ecee..4090ec0 100644
> --- a/android/pts-avctp.txt
> +++ b/android/pts-avctp.txt
> @@ -2,6 +2,7 @@ PTS test results for AVCTP
> 
>  PTS version: 5.0
>  Tested: 29.01.2014
> +Android version: 4.4.2
> 
>  Results:
>  PASS	test passed
> diff --git a/android/pts-avrcp.txt b/android/pts-avrcp.txt
> index 454e26c..8bd0b4d 100644
> --- a/android/pts-avrcp.txt
> +++ b/android/pts-avrcp.txt
> @@ -2,6 +2,7 @@ PTS test results for AVRCP
> 
>  PTS version: 5.0
>  Tested: 28.01.2014
> +Android version: 4.4.2
> 
>  Results:
>  PASS	test passed
> diff --git a/android/pts-did.txt b/android/pts-did.txt
> index d764f09..841b257 100644
> --- a/android/pts-did.txt
> +++ b/android/pts-did.txt
> @@ -2,6 +2,7 @@ PTS test results for DID
> 
>  PTS version: 5.0
>  Tested: 28.01.2014
> +Android version: 4.4.2
> 
>  Results:
>  PASS	test passed
> diff --git a/android/pts-gap.txt b/android/pts-gap.txt
> index 1c0feec..7c88f1f 100644
> --- a/android/pts-gap.txt
> +++ b/android/pts-gap.txt
> @@ -2,6 +2,7 @@ PTS test results for GAP
> 
>  PTS version: 5.0
>  Tested: 28.01.2014
> +Android version: 4.4.2
> 
>  Results:
>  PASS	test passed
> diff --git a/android/pts-l2cap.txt b/android/pts-l2cap.txt
> index 3e46309..f04c3e5 100644
> --- a/android/pts-l2cap.txt
> +++ b/android/pts-l2cap.txt
> @@ -2,6 +2,7 @@ PTS test results for L2CAP
> 
>  PTS version: 5.0
>  Tested: 29.01.2014
> +Android version: 4.4.2
> 
>  Results:
>  PASS   test passed
> diff --git a/android/pts-opp.txt b/android/pts-opp.txt
> index 3c4ab47..d5dfcf0 100644
> --- a/android/pts-opp.txt
> +++ b/android/pts-opp.txt
> @@ -2,6 +2,7 @@ PTS test results for OPP
> 
>  PTS version: 5.0
>  Tested: 28.01.2014
> +Android version: 4.4.2
> 
>  Results:
>  PASS	test passed
> diff --git a/android/pts-pbap.txt b/android/pts-pbap.txt
> index 4312921..41442c6 100644
> --- a/android/pts-pbap.txt
> +++ b/android/pts-pbap.txt
> @@ -2,6 +2,7 @@ PTS test results for PBAP
> 
>  PTS version: 5.0
>  Tested: 28.01.2014
> +Android version: 4.4.2
> 
>  Results:
>  PASS	test passed

Applied, thanks.

-- 
BR
Szymon Janc

^ permalink raw reply

* Re: [PATCH] android: Add avtest to debug builds
From: Szymon Janc @ 2014-01-31 13:43 UTC (permalink / raw)
  To: Sebastian Chlad; +Cc: linux-bluetooth
In-Reply-To: <1391160672-9088-1-git-send-email-sebastianx.chlad@intel.com>

Hi Sebastian,

On Friday 31 of January 2014 11:31:12 Sebastian Chlad wrote:
> ---
>  android/Android.mk | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
> 
> diff --git a/android/Android.mk b/android/Android.mk
> index 1d12da5..09ed32d 100644
> --- a/android/Android.mk
> +++ b/android/Android.mk
> @@ -354,6 +354,28 @@ LOCAL_MODULE := l2ping
>  include $(BUILD_EXECUTABLE)
> 
>  #
> +# avtest
> +#
> +
> +include $(CLEAR_VARS)
> +
> +LOCAL_SRC_FILES := \
> +        bluez/tools/avtest.c \
> +        bluez/lib/bluetooth.c \
> +        bluez/lib/hci.c \
> +
> +LOCAL_C_INCLUDES := \
> +        $(LOCAL_PATH)/bluez/lib \
> +
> +LOCAL_CFLAGS := $(BLUEZ_COMMON_CFLAGS)
> +
> +LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
> +LOCAL_MODULE_TAGS := debug
> +LOCAL_MODULE := avtest
> +
> +include $(BUILD_EXECUTABLE)
> +
> +#
>  # libsbc
>  #

Applied, thanks.

-- 
BR
Szymon Janc

^ permalink raw reply

* [PATCH 2/2] avrcp: Fix printing order for browsing avrcp header
From: Andrei Emeltchenko @ 2014-01-31 12:36 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1391171777-27512-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

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

---
 profiles/audio/avrcp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
index bc5cab3..4ece4af 100644
--- a/profiles/audio/avrcp.c
+++ b/profiles/audio/avrcp.c
@@ -1730,7 +1730,7 @@ static size_t handle_browsing_pdu(struct avctp *conn,
 	struct avrcp_browsing_header *pdu = (void *) operands;
 
 	DBG("AVRCP Browsing PDU 0x%02X, len 0x%04X", pdu->pdu_id,
-							pdu->param_len);
+							ntohs(pdu->param_len));
 
 	for (handler = browsing_handlers; handler->pdu_id; handler++) {
 		if (handler->pdu_id == pdu->pdu_id)
-- 
1.8.3.2


^ permalink raw reply related

* [PATCH 1/2] avrcp: Fix printing incorrect order for avrcp control header
From: Andrei Emeltchenko @ 2014-01-31 12:36 UTC (permalink / raw)
  To: linux-bluetooth

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

---
 profiles/audio/avrcp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
index 5030ce1..bc5cab3 100644
--- a/profiles/audio/avrcp.c
+++ b/profiles/audio/avrcp.c
@@ -1658,7 +1658,7 @@ static size_t handle_vendordep_pdu(struct avctp *conn, uint8_t transaction,
 	}
 
 	DBG("AVRCP PDU 0x%02X, company 0x%06X len 0x%04X",
-			pdu->pdu_id, company_id, pdu->params_len);
+			pdu->pdu_id, company_id, ntohs(pdu->params_len));
 
 	pdu->packet_type = 0;
 	pdu->rsvd = 0;
@@ -1755,7 +1755,7 @@ size_t avrcp_handle_vendor_reject(uint8_t *code, uint8_t *operands)
 	pdu->params[0] = AVRCP_STATUS_INTERNAL_ERROR;
 
 	DBG("rejecting AVRCP PDU 0x%02X, company 0x%06X len 0x%04X",
-				pdu->pdu_id, company_id, pdu->params_len);
+			pdu->pdu_id, company_id, ntohs(pdu->params_len));
 
 	return AVRCP_HEADER_LENGTH + 1;
 }
-- 
1.8.3.2


^ permalink raw reply related

* [PATCH] android: Add avtest to debug builds
From: Sebastian Chlad @ 2014-01-31  9:31 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Sebastian Chlad
In-Reply-To: <1390999219-15012-1-git-send-email-sebastianx.chlad@intel.com>

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

diff --git a/android/Android.mk b/android/Android.mk
index 1d12da5..09ed32d 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -354,6 +354,28 @@ LOCAL_MODULE := l2ping
 include $(BUILD_EXECUTABLE)
 
 #
+# avtest
+#
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+        bluez/tools/avtest.c \
+        bluez/lib/bluetooth.c \
+        bluez/lib/hci.c \
+
+LOCAL_C_INCLUDES := \
+        $(LOCAL_PATH)/bluez/lib \
+
+LOCAL_CFLAGS := $(BLUEZ_COMMON_CFLAGS)
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
+LOCAL_MODULE_TAGS := debug
+LOCAL_MODULE := avtest
+
+include $(BUILD_EXECUTABLE)
+
+#
 # libsbc
 #
 
-- 
1.8.3.2

---------------------------------------------------------------------
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 related

* [PATCH] avrcp: Fix wrong pointer check
From: Andrei Emeltchenko @ 2014-01-31  8:33 UTC (permalink / raw)
  To: linux-bluetooth

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

There is wrong assumption that handler might be NULL while it is a
pointer to a struct table so check instead for struct members. This
fixes accessing wrong memory.
---
 profiles/audio/avrcp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
index df88138..5030ce1 100644
--- a/profiles/audio/avrcp.c
+++ b/profiles/audio/avrcp.c
@@ -1673,7 +1673,7 @@ static size_t handle_vendordep_pdu(struct avctp *conn, uint8_t transaction,
 			break;
 	}
 
-	if (!handler || handler->code != *code) {
+	if (!handler->code || handler->code != *code) {
 		pdu->params[0] = AVRCP_STATUS_INVALID_COMMAND;
 		goto err_metadata;
 	}
@@ -1737,7 +1737,7 @@ static size_t handle_browsing_pdu(struct avctp *conn,
 			break;
 	}
 
-	if (handler == NULL || handler->func == NULL)
+	if (!handler->func)
 		return avrcp_browsing_general_reject(operands);
 
 	session->transaction = transaction;
-- 
1.8.3.2


^ permalink raw reply related

* Re: [PATCH BlueZ 4/4] audio/AVRCP: Fix coding style
From: Andrei Emeltchenko @ 2014-01-31  7:55 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
In-Reply-To: <1391123008-26767-4-git-send-email-luiz.dentz@gmail.com>

Hi Luiz,

On Thu, Jan 30, 2014 at 03:03:28PM -0800, Luiz Augusto von Dentz wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> 
> ---
>  profiles/audio/avrcp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
> index ac861d2..4521bc4 100644
> --- a/profiles/audio/avrcp.c
> +++ b/profiles/audio/avrcp.c
> @@ -2161,7 +2161,7 @@ static struct media_item *parse_media_folder(struct avrcp *session,
>  		name[namelen] = '\0';
>  	}
>  
> -	item =  media_player_create_folder(mp, name, type, uid);
> +	item = media_player_create_folder(mp, name, type, uid);

what is the point creating this patch instead of merging with previous one
which introduced this style issue?

Best regards 
Andrei Emeltchenko 

>  	if (!item)
>  		return NULL;
>  
> -- 
> 1.8.4.2
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: [PATCH 0/4] Bluetooth: SMP LTK fixes
From: Marcel Holtmann @ 2014-01-31  3:51 UTC (permalink / raw)
  To: Johan Hedberg; +Cc: BlueZ development
In-Reply-To: <1391139600-15366-1-git-send-email-johan.hedberg@gmail.com>

Hi Johan,

> Now that my LTK key distribution patch is already applied I
> unfortunately uncovered several bugs due to it. The main issue is that
> the kernel code was not accounting for the possibility of there being
> two LTKs for the same remote device in the hdev->long_term_keys list.
> 
> There are still fixes needed on the user space side which I haven't
> completely sorted out yet (to pushable form - it's more or less working
> already through). Right now the storage format doesn't allow storing two
> LTKs for the same device.
> 
> ----------------------------------------------------------------
> Johan Hedberg (4):
>      Bluetooth: Fix long_term_keys debugfs output
>      Bluetooth: Make LTK key type check more readable
>      Bluetooth: Remove unnecessary LTK type check from hci_add_ltk
>      Bluetooth: Fix differentiating stored master vs slave LTK types
> 
> include/net/bluetooth/hci_core.h |  5 +++--
> net/bluetooth/hci_core.c         | 31 +++++++++++++++++++++----------
> net/bluetooth/hci_event.c        |  2 +-
> net/bluetooth/smp.c              |  3 ++-
> 4 files changed, 27 insertions(+), 14 deletions(-)

all 4 patches have been applied to bluetooth-next tree.

Regards

Marcel


^ permalink raw reply

* [PATCH 4/4] Bluetooth: Fix differentiating stored master vs slave LTK types
From: johan.hedberg @ 2014-01-31  3:40 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1391139600-15366-1-git-send-email-johan.hedberg@gmail.com>

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

If LTK distribution happens in both directions we will have two LTKs for
the same remote device: one which is used when we're connecting as
master and another when we're connecting as slave. When looking up LTKs
from the locally stored list we shouldn't blindly return the first match
but also consider which type of key is in question. If we do not do this
we may end up selecting an incorrect encryption key for a connection.

This patch fixes the issue by always specifying to the LTK lookup
functions whether we're looking for a master or a slave key.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
 include/net/bluetooth/hci_core.h |  5 +++--
 net/bluetooth/hci_core.c         | 22 ++++++++++++++++++----
 net/bluetooth/hci_event.c        |  2 +-
 net/bluetooth/smp.c              |  3 ++-
 4 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 8d225e4ea2ce..378e2f32cfa0 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -757,12 +757,13 @@ int hci_link_keys_clear(struct hci_dev *hdev);
 struct link_key *hci_find_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr);
 int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key,
 		     bdaddr_t *bdaddr, u8 *val, u8 type, u8 pin_len);
-struct smp_ltk *hci_find_ltk(struct hci_dev *hdev, __le16 ediv, u8 rand[8]);
+struct smp_ltk *hci_find_ltk(struct hci_dev *hdev, __le16 ediv, u8 rand[8],
+			     bool master);
 int hci_add_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 addr_type, u8 type,
 		int new_key, u8 authenticated, u8 tk[16], u8 enc_size,
 		__le16 ediv, u8 rand[8]);
 struct smp_ltk *hci_find_ltk_by_addr(struct hci_dev *hdev, bdaddr_t *bdaddr,
-				     u8 addr_type);
+				     u8 addr_type, bool master);
 int hci_remove_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr);
 int hci_smp_ltks_clear(struct hci_dev *hdev);
 int hci_remove_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr);
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 180473d965f6..d370b432aea6 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -2605,7 +2605,16 @@ static bool hci_persistent_key(struct hci_dev *hdev, struct hci_conn *conn,
 	return false;
 }
 
-struct smp_ltk *hci_find_ltk(struct hci_dev *hdev, __le16 ediv, u8 rand[8])
+static bool ltk_type_master(u8 type)
+{
+	if (type == HCI_SMP_STK || type == HCI_SMP_LTK)
+		return true;
+
+	return false;
+}
+
+struct smp_ltk *hci_find_ltk(struct hci_dev *hdev, __le16 ediv, u8 rand[8],
+			     bool master)
 {
 	struct smp_ltk *k;
 
@@ -2614,6 +2623,9 @@ struct smp_ltk *hci_find_ltk(struct hci_dev *hdev, __le16 ediv, u8 rand[8])
 		    memcmp(rand, k->rand, sizeof(k->rand)))
 			continue;
 
+		if (ltk_type_master(k->type) != master)
+			continue;
+
 		return k;
 	}
 
@@ -2621,13 +2633,14 @@ struct smp_ltk *hci_find_ltk(struct hci_dev *hdev, __le16 ediv, u8 rand[8])
 }
 
 struct smp_ltk *hci_find_ltk_by_addr(struct hci_dev *hdev, bdaddr_t *bdaddr,
-				     u8 addr_type)
+				     u8 addr_type, bool master)
 {
 	struct smp_ltk *k;
 
 	list_for_each_entry(k, &hdev->long_term_keys, list)
 		if (addr_type == k->bdaddr_type &&
-		    bacmp(bdaddr, &k->bdaddr) == 0)
+		    bacmp(bdaddr, &k->bdaddr) == 0 &&
+		    ltk_type_master(k->type) == master)
 			return k;
 
 	return NULL;
@@ -2691,8 +2704,9 @@ int hci_add_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 addr_type, u8 type,
 		ediv, u8 rand[8])
 {
 	struct smp_ltk *key, *old_key;
+	bool master = ltk_type_master(type);
 
-	old_key = hci_find_ltk_by_addr(hdev, bdaddr, addr_type);
+	old_key = hci_find_ltk_by_addr(hdev, bdaddr, addr_type, master);
 	if (old_key)
 		key = old_key;
 	else {
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 8c44bbe19add..7bb8094a3ff2 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -3650,7 +3650,7 @@ static void hci_le_ltk_request_evt(struct hci_dev *hdev, struct sk_buff *skb)
 	if (conn == NULL)
 		goto not_found;
 
-	ltk = hci_find_ltk(hdev, ev->ediv, ev->random);
+	ltk = hci_find_ltk(hdev, ev->ediv, ev->random, conn->out);
 	if (ltk == NULL)
 		goto not_found;
 
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
index 9b1167007653..efe51ccdc615 100644
--- a/net/bluetooth/smp.c
+++ b/net/bluetooth/smp.c
@@ -699,7 +699,8 @@ static u8 smp_ltk_encrypt(struct l2cap_conn *conn, u8 sec_level)
 	struct smp_ltk *key;
 	struct hci_conn *hcon = conn->hcon;
 
-	key = hci_find_ltk_by_addr(hcon->hdev, &hcon->dst, hcon->dst_type);
+	key = hci_find_ltk_by_addr(hcon->hdev, &hcon->dst, hcon->dst_type,
+				   hcon->out);
 	if (!key)
 		return 0;
 
-- 
1.8.5.3


^ permalink raw reply related

* [PATCH 3/4] Bluetooth: Remove unnecessary LTK type check from hci_add_ltk
From: johan.hedberg @ 2014-01-31  3:39 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1391139600-15366-1-git-send-email-johan.hedberg@gmail.com>

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

All callers of hci_add_ltk pass a valid value to it. There are no places
where e.g. user space, the controller or the remote peer would be able
to cause invalid values to be passed. Therefore, just remove the
potentially confusing check from the beginning of the function.

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

diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 754a59079de9..180473d965f6 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -2692,9 +2692,6 @@ int hci_add_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 addr_type, u8 type,
 {
 	struct smp_ltk *key, *old_key;
 
-	if (!(type & HCI_SMP_STK) && !(type & HCI_SMP_LTK))
-		return 0;
-
 	old_key = hci_find_ltk_by_addr(hdev, bdaddr, addr_type);
 	if (old_key)
 		key = old_key;
-- 
1.8.5.3


^ permalink raw reply related

* [PATCH 2/4] Bluetooth: Make LTK key type check more readable
From: johan.hedberg @ 2014-01-31  3:39 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1391139600-15366-1-git-send-email-johan.hedberg@gmail.com>

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

Instead of magic bitwise operations simply compare with the two possible
type values that we are interested in.

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

diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 8094a41c9a26..754a59079de9 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -2717,7 +2717,7 @@ int hci_add_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 addr_type, u8 type,
 	if (!new_key)
 		return 0;
 
-	if (type & HCI_SMP_LTK)
+	if (type == HCI_SMP_LTK || type == HCI_SMP_LTK_SLAVE)
 		mgmt_new_ltk(hdev, key, 1);
 
 	return 0;
-- 
1.8.5.3


^ permalink raw reply related

* [PATCH 1/4] Bluetooth: Fix long_term_keys debugfs output
From: johan.hedberg @ 2014-01-31  3:39 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1391139600-15366-1-git-send-email-johan.hedberg@gmail.com>

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

The code was previously iterating the wrong list (and what's worse
casting entries to a type which they were not) and also missing a proper
line terminator when printing each entry. The code now also prints the
LTK type in hex for easier comparison with the kernel-defined values.

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

diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 369d30750417..8094a41c9a26 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -620,9 +620,9 @@ static int long_term_keys_show(struct seq_file *f, void *ptr)
 	struct list_head *p, *n;
 
 	hci_dev_lock(hdev);
-	list_for_each_safe(p, n, &hdev->link_keys) {
+	list_for_each_safe(p, n, &hdev->long_term_keys) {
 		struct smp_ltk *ltk = list_entry(p, struct smp_ltk, list);
-		seq_printf(f, "%pMR (type %u) %u %u %u %.4x %*phN %*phN\\n",
+		seq_printf(f, "%pMR (type %u) %u 0x%02x %u %.4x %*phN %*phN\n",
 			   &ltk->bdaddr, ltk->bdaddr_type, ltk->authenticated,
 			   ltk->type, ltk->enc_size, __le16_to_cpu(ltk->ediv),
 			   8, ltk->rand, 16, ltk->val);
-- 
1.8.5.3


^ permalink raw reply related

* [PATCH 0/4] Bluetooth: SMP LTK fixes
From: johan.hedberg @ 2014-01-31  3:39 UTC (permalink / raw)
  To: linux-bluetooth

Hi,

Now that my LTK key distribution patch is already applied I
unfortunately uncovered several bugs due to it. The main issue is that
the kernel code was not accounting for the possibility of there being
two LTKs for the same remote device in the hdev->long_term_keys list.

There are still fixes needed on the user space side which I haven't
completely sorted out yet (to pushable form - it's more or less working
already through). Right now the storage format doesn't allow storing two
LTKs for the same device.

----------------------------------------------------------------
Johan Hedberg (4):
      Bluetooth: Fix long_term_keys debugfs output
      Bluetooth: Make LTK key type check more readable
      Bluetooth: Remove unnecessary LTK type check from hci_add_ltk
      Bluetooth: Fix differentiating stored master vs slave LTK types

 include/net/bluetooth/hci_core.h |  5 +++--
 net/bluetooth/hci_core.c         | 31 +++++++++++++++++++++----------
 net/bluetooth/hci_event.c        |  2 +-
 net/bluetooth/smp.c              |  3 ++-
 4 files changed, 27 insertions(+), 14 deletions(-)


^ permalink raw reply

* Re: [PATCH] Bluetooth: Remove Simultaneous LE & BR/EDR flags from AD
From: Marcel Holtmann @ 2014-01-31  3:12 UTC (permalink / raw)
  To: Johan Hedberg; +Cc: BlueZ development
In-Reply-To: <1391109410-8595-1-git-send-email-johan.hedberg@gmail.com>

Hi Johan,

> Starting with the 4.1 Core Specification these flags are no longer used
> and should always be cleared. From volume 3, part C, section 13.1.1:
> 
> "The 'Simultaneous LE and BR/EDR to Same Device Capable (Controller)'
> and ‘Simultaneous LE and BR/EDR to Same Device Capable (Host)’ bits in
> the Flags AD type shall be set to ‘0’."
> 
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> net/bluetooth/mgmt.c | 8 +-------
> 1 file changed, 1 insertion(+), 7 deletions(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel


^ permalink raw reply

* Re: BLE Peripheral on Ubuntu
From: Anderson Lizardo @ 2014-01-30 23:53 UTC (permalink / raw)
  To: Prashant R; +Cc: BlueZ development
In-Reply-To: <CAD-ALXKinmbiAaH3FMA-b4byXo0CMEm1H0Dfc=bCDBwONqsfTA@mail.gmail.com>

Hi,

On Thu, Jan 30, 2014 at 6:01 PM, Prashant R <ramapra@gmail.com> wrote:
> My goal is to be able to use a USB-BT adapter and make it behave like
> a BLE peripheral.
>
> So far I have been able to do LE advertising on it but would want to
> add GATT services for this device.
> I am unable to find documentation on how to control this as a BLE
> Peripheral.Can someone point me to this?

We are currently in the process of submitting patches upstream that
will allow applications to register GATT services using a D-Bus API.

> - Is there currently a tool (opposite of  gatttool) that I can use to
> publish services and characteristics ?

Once the API is upstream, you will be able to register your own
services using D-Bus. There will be example C code demonstrating the
API, and documentation in doc/gatt-api.txt.

> - My version of bluez is4.98-2ubuntu7 . I tried to upgrade to the
> latest but it complains about D-BUS version being <Ver 1.6. My version
> of DBUS  is  1.4.18
> My question is if the GATT server support is present at the user level
> using my version of 4.98-2ubuntu7?

Unfortunately, you will need to use a more recent BlueZ in order to
use the future API. You can build your own D-Bus library and BlueZ
from sources (make sure to install in a separate place , e.g.
/opt/bluez, instead of overwriting any files in /usr).

Current status of the upstreaming process:

- The internal C API for GATT service registration, as well as the
attribute database format, was rewritten. Therefore we need to migrate
existing internal profiles to this new API.

- We sent patches for GATT Service and Characteristic registration.
These initial patches do not export the services over the LE channel
yet (they are only available using a local UNIX socket). This
intermediary step is necessary in order to not break current supported
profiles.

- We will be able to export the services on the LE and BR/EDR channels
once the internal profiles are migrated to the new C API. I'm
currently working on this step.

Summary: the latest BlueZ does not support external GATT services yet,
but we hope to have basic support upstream (with an experimental API)
very soon.

Best Regards,
-- 
Anderson Lizardo
http://www.indt.org/?lang=en
INdT - Manaus - Brazil

^ permalink raw reply

* [PATCH BlueZ 4/4] audio/AVRCP: Fix coding style
From: Luiz Augusto von Dentz @ 2014-01-30 23:03 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1391123008-26767-1-git-send-email-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 profiles/audio/avrcp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
index ac861d2..4521bc4 100644
--- a/profiles/audio/avrcp.c
+++ b/profiles/audio/avrcp.c
@@ -2161,7 +2161,7 @@ static struct media_item *parse_media_folder(struct avrcp *session,
 		name[namelen] = '\0';
 	}
 
-	item =  media_player_create_folder(mp, name, type, uid);
+	item = media_player_create_folder(mp, name, type, uid);
 	if (!item)
 		return NULL;
 
-- 
1.8.4.2


^ permalink raw reply related

* [PATCH BlueZ 3/4] audio/AVRCP: Fix not setting playable flag for folder
From: Luiz Augusto von Dentz @ 2014-01-30 23:03 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1391123008-26767-1-git-send-email-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

When listing items some folders may be set as playable but the code was
ignoring it making it impossible to play any folder.
---
 profiles/audio/avrcp.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
index 2cf6b41..ac861d2 100644
--- a/profiles/audio/avrcp.c
+++ b/profiles/audio/avrcp.c
@@ -2141,16 +2141,19 @@ static struct media_item *parse_media_folder(struct avrcp *session,
 {
 	struct avrcp_player *player = session->controller->player;
 	struct media_player *mp = player->user_data;
+	struct media_item *item;
 	uint16_t namelen;
 	char name[255];
 	uint64_t uid;
 	uint8_t type;
+	uint8_t playable;
 
 	if (len < 12)
 		return NULL;
 
 	uid = bt_get_be64(&operands[0]);
 	type = operands[8];
+	playable = operands[9];
 
 	namelen = MIN(bt_get_be16(&operands[12]), sizeof(name) - 1);
 	if (namelen > 0) {
@@ -2158,7 +2161,13 @@ static struct media_item *parse_media_folder(struct avrcp *session,
 		name[namelen] = '\0';
 	}
 
-	return media_player_create_folder(mp, name, type, uid);
+	item =  media_player_create_folder(mp, name, type, uid);
+	if (!item)
+		return NULL;
+
+	media_item_set_playable(item, playable & 0x01);
+
+	return item;
 }
 
 static void avrcp_list_items(struct avrcp *session, uint32_t start,
-- 
1.8.4.2


^ permalink raw reply related

* [PATCH BlueZ 2/4] audio/AVRCP: Fix using the wrong octet for folder type
From: Luiz Augusto von Dentz @ 2014-01-30 23:03 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1391123008-26767-1-git-send-email-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

Folder type is the 9 octet not the 10.
---
 profiles/audio/avrcp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
index 63a6f7e..2cf6b41 100644
--- a/profiles/audio/avrcp.c
+++ b/profiles/audio/avrcp.c
@@ -2150,7 +2150,7 @@ static struct media_item *parse_media_folder(struct avrcp *session,
 		return NULL;
 
 	uid = bt_get_be64(&operands[0]);
-	type = operands[9];
+	type = operands[8];
 
 	namelen = MIN(bt_get_be16(&operands[12]), sizeof(name) - 1);
 	if (namelen > 0) {
-- 
1.8.4.2


^ permalink raw reply related

* [PATCH BlueZ 1/4] audio/player: Fix using invalid end index
From: Luiz Augusto von Dentz @ 2014-01-30 23:03 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

When the End index is not set in ListItems the code automatically pick
the number of items as end index but the start index start with 0 so
the correct is to use number of items - 1.
---
 profiles/audio/player.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/profiles/audio/player.c b/profiles/audio/player.c
index e6d24eb..2bd2d6e 100644
--- a/profiles/audio/player.c
+++ b/profiles/audio/player.c
@@ -808,7 +808,8 @@ static int parse_filters(struct media_player *player, DBusMessageIter *iter,
 	int ctype;
 
 	*start = 0;
-	*end = folder->number_of_items ? folder->number_of_items : UINT32_MAX;
+	*end = folder->number_of_items ? folder->number_of_items - 1 :
+								UINT32_MAX;
 
 	ctype = dbus_message_iter_get_arg_type(iter);
 	if (ctype != DBUS_TYPE_ARRAY)
-- 
1.8.4.2


^ permalink raw reply related

* BLE Peripheral on Ubuntu
From: Prashant R @ 2014-01-30 22:01 UTC (permalink / raw)
  To: linux-bluetooth

My goal is to be able to use a USB-BT adapter and make it behave like
a BLE peripheral.

So far I have been able to do LE advertising on it but would want to
add GATT services for this device.
I am unable to find documentation on how to control this as a BLE
Peripheral.Can someone point me to this?

- Is there currently a tool (opposite of  gatttool) that I can use to
publish services and characteristics ?

- My version of bluez is4.98-2ubuntu7 . I tried to upgrade to the
latest but it complains about D-BUS version being <Ver 1.6. My version
of DBUS  is  1.4.18
My question is if the GATT server support is present at the user level
using my version of 4.98-2ubuntu7?

Thanks for your help.

^ permalink raw reply

* Re: [PATCH] Bluetooth: Enable LTK distribution to slave devices
From: Marcel Holtmann @ 2014-01-30 21:39 UTC (permalink / raw)
  To: Johan Hedberg; +Cc: BlueZ development
In-Reply-To: <1391032559-25183-1-git-send-email-johan.hedberg@gmail.com>

Hi Johan,

> So far we've only been requesting the LTK to be distributed to the
> master (initiator) of pairing, which is usually enough since it's the
> master that will establish future connections and initiate encryption.
> However, in the case that both devices support switching to the opposing
> role (which seems to be increasingly common) pairing will have to
> performed again since the "new" master will not have all information.
> 
> As there is no real harm in it, this patch updates the code to always
> try distributing the LTK also to the slave device, thereby enabling role
> switches for future connections.
> 
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> net/bluetooth/smp.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel


^ permalink raw reply

* [RFC v6 14/14] Bluetooth: Add le_auto_conn file on debugfs
From: Andre Guedes @ 2014-01-30 21:22 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1391116937-28217-1-git-send-email-andre.guedes@openbossa.org>

This patch adds to debugfs the le_auto_conn file. This file will be
used to test LE auto connection infrastructure.

To add a new auto connection address we write on le_auto_conn file
following the format <address> <address type> <auto_connect>.

The <address type> values are:
  * 0 for public address
  * 1 for random address

The <auto_connect> values are (for more details see struct hci_
conn_params):
  * 0 for disabled
  * 1 for always
  * 2 for link loss

So for instance, if you want the kernel autonomously establishes
connections with device AA:BB:CC:DD:EE:FF (public address) every
time the device enters in connectable mode (starts advertising),
you should run the command:
$ echo "AA:BB:CC:DD:EE:FF 0 1" > /sys/kernel/debug/bluetooth/hci0/le_auto_conn

To get the list of connection parameters configured in kernel, read
the le_auto_conn file:
$ cat /sys/kernel/debug/bluetooth/hci0/le_auto_conn

Finally, to clear the connection parameters list, write an empty
string:
$ echo "" > /sys/kernel/debug/bluetooth/hci0/le_auto_conn

This file is created only if LE is enabled.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
---
 net/bluetooth/hci_core.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 85 insertions(+)

diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 9dba381..ec2a5a0 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -743,6 +743,89 @@ static const struct file_operations lowpan_debugfs_fops = {
 	.llseek		= default_llseek,
 };
 
+static int le_auto_conn_show(struct seq_file *sf, void *ptr)
+{
+	struct hci_dev *hdev = sf->private;
+	struct hci_conn_params *p;
+
+	hci_dev_lock(hdev);
+
+	list_for_each_entry(p, &hdev->le_conn_params, list) {
+		seq_printf(sf, "%pMR %u %u\n", &p->addr, p->addr_type,
+			   p->auto_connect);
+	}
+
+	hci_dev_unlock(hdev);
+
+	return 0;
+}
+
+static int le_auto_conn_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, le_auto_conn_show, inode->i_private);
+}
+
+static ssize_t le_auto_conn_write(struct file *file, const char __user *data,
+				  size_t count, loff_t *offset)
+{
+	struct seq_file *sf = file->private_data;
+	struct hci_dev *hdev = sf->private;
+	u8 auto_connect;
+	bdaddr_t addr;
+	u8 addr_type;
+	char *buf;
+	int n;
+
+	/* Don't allow partial write */
+	if (*offset != 0)
+		return -EINVAL;
+
+	/* If empty string, clear the connection parameters and pending LE
+	 * connection list.
+	 */
+	if (count == 1) {
+		hci_dev_lock(hdev);
+		hci_conn_params_clear(hdev);
+		hci_pend_le_conns_clear(hdev);
+		hci_dev_unlock(hdev);
+		return count;
+	}
+
+	buf = kzalloc(count, GFP_KERNEL);
+	if (!buf)
+		return -ENOMEM;
+
+	if (copy_from_user(buf, data, count)) {
+		kfree(buf);
+		return -EFAULT;
+	}
+
+	n = sscanf(buf, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx %hhu %hhu", &addr.b[5],
+		   &addr.b[4], &addr.b[3], &addr.b[2], &addr.b[1], &addr.b[0],
+		   &addr_type, &auto_connect);
+	if (n != 8) {
+		kfree(buf);
+		return -EINVAL;
+	}
+
+	hci_dev_lock(hdev);
+	hci_conn_params_add(hdev, &addr, addr_type, auto_connect,
+			    hdev->le_conn_min_interval,
+			    hdev->le_conn_max_interval);
+	hci_dev_unlock(hdev);
+
+	kfree(buf);
+	return count;
+}
+
+static const struct file_operations le_auto_conn_fops = {
+	.open		= le_auto_conn_open,
+	.read		= seq_read,
+	.write		= le_auto_conn_write,
+	.llseek		= seq_lseek,
+	.release	= single_release,
+};
+
 /* ---- HCI requests ---- */
 
 static void hci_req_sync_complete(struct hci_dev *hdev, u8 result)
@@ -1537,6 +1620,8 @@ static int __hci_init(struct hci_dev *hdev)
 				    hdev, &conn_max_interval_fops);
 		debugfs_create_file("6lowpan", 0644, hdev->debugfs, hdev,
 				    &lowpan_debugfs_fops);
+		debugfs_create_file("le_auto_conn", 0644, hdev->debugfs, hdev,
+				    &le_auto_conn_fops);
 	}
 
 	return 0;
-- 
1.8.5.3


^ permalink raw reply related

* [RFC v6 13/14] Bleutooth: Add support for auto connect options
From: Andre Guedes @ 2014-01-30 21:22 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1391116937-28217-1-git-send-email-andre.guedes@openbossa.org>

This patch adds support for the HCI_AUTO_CONN_ALWAYS and HCI_AUTO_
CONN_LINK_LOSS options from struct hci_conn_params.

The HCI_AUTO_CONN_ALWAYS option configures the kernel to always re-
establish the connection, no matter the reason the connection was
terminated. This feature is required by some LE profiles such as
HID over GATT, Health Thermometer and Blood Pressure. These profiles
require the host autonomously connect to the device as soon as it
enters in connectable mode (start advertising) so the device is able
to delivery notifications or indications.

The BT_AUTO_CONN_LINK_LOSS option configures the kernel to re-
establish the connection in case the connection was terminated due
to a link loss. This feature is required by the majority of LE
profiles such as Proximity, Find Me, Cycling Speed and Cadence and
Time.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
---
 net/bluetooth/hci_event.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 8f4686a..020fd9f 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -1825,6 +1825,7 @@ static void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
 {
 	struct hci_ev_disconn_complete *ev = (void *) skb->data;
 	u8 reason = hci_to_mgmt_reason(ev->reason);
+	struct hci_conn_params *params;
 	struct hci_conn *conn;
 	u8 type;
 
@@ -1851,6 +1852,23 @@ static void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
 	if (conn->type == ACL_LINK && conn->flush_key)
 		hci_remove_link_key(hdev, &conn->dst);
 
+	params = hci_conn_params_lookup(hdev, &conn->dst, conn->dst_type);
+	if (params) {
+		switch (params->auto_connect) {
+		case HCI_AUTO_CONN_LINK_LOSS:
+			if (ev->reason != HCI_ERROR_CONNECTION_TIMEOUT)
+				break;
+			/* Fall through */
+
+		case HCI_AUTO_CONN_ALWAYS:
+			hci_pend_le_conn_add(hdev, &conn->dst, conn->dst_type);
+			break;
+
+		default:
+			break;
+		}
+	}
+
 	type = conn->type;
 
 	hci_proto_disconn_cfm(conn, ev->reason);
-- 
1.8.5.3


^ permalink raw reply related

* [RFC v6 12/14] Bluetooth: Auto connection and power on
From: Andre Guedes @ 2014-01-30 21:22 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1391116937-28217-1-git-send-email-andre.guedes@openbossa.org>

When hdev is closed (e.g. Mgmt power off command, RFKILL or controller
is reset), the ongoing active connections are silently dropped by the
controller (no Disconnection Complete Event is sent to host). For that
reason, the devices that require HCI_AUTO_CONN_ALWAYS are not added to
hdev->pend_le_conns list and they won't auto connect.

So to fix this issue, during hdev closing, we remove all pending LE
connections. After adapter is powered on, we add a pending LE connection
for each HCI_AUTO_CONN_ALWAYS address.

This way, the auto connection mechanism works propely after a power
off and power on sequence as well as RFKILL block/unblock.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
---
 net/bluetooth/hci_core.c |  1 +
 net/bluetooth/mgmt.c     | 13 +++++++++++++
 2 files changed, 14 insertions(+)

diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index cc9053d..9dba381 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -2100,6 +2100,7 @@ static int hci_dev_do_close(struct hci_dev *hdev)
 	hci_dev_lock(hdev);
 	hci_inquiry_cache_flush(hdev);
 	hci_conn_hash_flush(hdev);
+	hci_pend_le_conns_clear(hdev);
 	hci_dev_unlock(hdev);
 
 	hci_notify(hdev, HCI_DEV_DOWN);
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 8026e5f..31acc44 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -4358,6 +4358,17 @@ void mgmt_index_removed(struct hci_dev *hdev)
 	mgmt_event(MGMT_EV_INDEX_REMOVED, hdev, NULL, 0, NULL);
 }
 
+/* This function requires the caller holds hdev->lock */
+static void restart_le_auto_conns(struct hci_dev *hdev)
+{
+	struct hci_conn_params *p;
+
+	list_for_each_entry(p, &hdev->le_conn_params, list) {
+		if (p->auto_connect == HCI_AUTO_CONN_ALWAYS)
+			hci_pend_le_conn_add(hdev, &p->addr, p->addr_type);
+	}
+}
+
 static void powered_complete(struct hci_dev *hdev, u8 status)
 {
 	struct cmd_lookup match = { NULL, hdev };
@@ -4366,6 +4377,8 @@ static void powered_complete(struct hci_dev *hdev, u8 status)
 
 	hci_dev_lock(hdev);
 
+	restart_le_auto_conns(hdev);
+
 	mgmt_pending_foreach(MGMT_OP_SET_POWERED, hdev, settings_rsp, &match);
 
 	new_settings(hdev, match.sk);
-- 
1.8.5.3


^ permalink raw reply related


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