* [PATCH] device: Fix bearer selection with single mode controller
@ 2018-03-05 16:16 Szymon Janc
2018-03-06 7:47 ` Johan Hedberg
0 siblings, 1 reply; 2+ messages in thread
From: Szymon Janc @ 2018-03-05 16:16 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
If remote device is dual mode and advertises without "BR/EDR flag
not supported" set than device is marked as supporting BR/EDR
even if controller is doing LE only. This results in bluetoothd
trying to connect over BR/EDR since this is prefered transport
if none is connected.
Fix this by checking if adapter supports specified technology
before doing heuristic transport selection.
---
src/adapter.c | 8 ++++++++
src/adapter.h | 1 +
src/device.c | 2 +-
3 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/adapter.c b/src/adapter.c
index 0fc9f840e..67dd20b79 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -4326,6 +4326,14 @@ bool btd_adapter_get_discoverable(struct btd_adapter *adapter)
return false;
}
+bool btd_adapter_get_bredr(struct btd_adapter *adapter)
+{
+ if (adapter->current_settings & MGMT_SETTING_BREDR)
+ return true;
+
+ return false;
+}
+
struct btd_gatt_database *btd_adapter_get_database(struct btd_adapter *adapter)
{
if (!adapter)
diff --git a/src/adapter.h b/src/adapter.h
index e619a5be9..016d3d75b 100644
--- a/src/adapter.h
+++ b/src/adapter.h
@@ -75,6 +75,7 @@ bool btd_adapter_get_pairable(struct btd_adapter *adapter);
bool btd_adapter_get_powered(struct btd_adapter *adapter);
bool btd_adapter_get_connectable(struct btd_adapter *adapter);
bool btd_adapter_get_discoverable(struct btd_adapter *adapter);
+bool btd_adapter_get_bredr(struct btd_adapter *adapter);
struct btd_gatt_database *btd_adapter_get_database(struct btd_adapter *adapter);
diff --git a/src/device.c b/src/device.c
index 8eb99e4bd..b86a35c81 100644
--- a/src/device.c
+++ b/src/device.c
@@ -1863,7 +1863,7 @@ static uint8_t select_conn_bearer(struct btd_device *dev)
* Prefer BR/EDR if time is the same since it might be from an
* advertisement with BR/EDR flag set.
*/
- if (bredr_last <= le_last)
+ if (bredr_last <= le_last && btd_adapter_get_bredr(dev->adapter))
return BDADDR_BREDR;
return dev->bdaddr_type;
--
2.14.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] device: Fix bearer selection with single mode controller
2018-03-05 16:16 [PATCH] device: Fix bearer selection with single mode controller Szymon Janc
@ 2018-03-06 7:47 ` Johan Hedberg
0 siblings, 0 replies; 2+ messages in thread
From: Johan Hedberg @ 2018-03-06 7:47 UTC (permalink / raw)
To: Szymon Janc; +Cc: linux-bluetooth
Hi Szymon,
On Mon, Mar 05, 2018, Szymon Janc wrote:
> If remote device is dual mode and advertises without "BR/EDR flag
> not supported" set than device is marked as supporting BR/EDR
> even if controller is doing LE only. This results in bluetoothd
> trying to connect over BR/EDR since this is prefered transport
> if none is connected.
>
> Fix this by checking if adapter supports specified technology
> before doing heuristic transport selection.
> ---
> src/adapter.c | 8 ++++++++
> src/adapter.h | 1 +
> src/device.c | 2 +-
> 3 files changed, 10 insertions(+), 1 deletion(-)
Applied. Thanks.
Johan
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-03-06 7:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-05 16:16 [PATCH] device: Fix bearer selection with single mode controller Szymon Janc
2018-03-06 7:47 ` Johan Hedberg
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.