device: Fix bearer selection with single mode controller
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
@@ -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
@@ -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
@@ -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
Johan Hedberg
AppliedHi 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