Skip to contentSkip to conversation

device: Fix bearer selection with single mode controller

PATCH Applied Szymon Janc 2 participants 2 messages Mar 5, 2018 – Mar 6, 2018 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 device: Fix bearer selection with single mode controller

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(-)
src/adapter.c +8 -0
index 0fc9f840e..67dd20b79 100644
@@ -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)
src/adapter.h +1 -0
index e619a5be9..016d3d75b 100644
@@ -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);
 
src/device.c +1 -1
index 8eb99e4bd..b86a35c81 100644
@@ -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;
Signature · 1 line
2.14.3
#1 lore raw

Hi Szymon,

Quoted 6 lines · 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.

Quoted 7 lines

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