diff mbox series

[BlueZ,4/5] device: Fix pairing with dual mode devices

Message ID 20230728053153.584222-5-simon.mikuda@streamunlimited.com (mailing list archive)
State New, archived
Headers show
Series Device pairing and discovery fixes | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/CheckPatch warning WARNING:COMMIT_LOG_LONG_LINE: Possible unwrapped commit description (prefer a maximum 75 chars per line) #82: even when we have connection to LE bearer only. In these situation we should /github/workspace/src/src/13331217.patch total: 0 errors, 1 warnings, 11 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. /github/workspace/src/src/13331217.patch has style problems, please review. NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS.
tedd_an/GitLint success Gitlint PASS
tedd_an/IncrementalBuild success Incremental Build PASS

Commit Message

Simon Mikuda July 28, 2023, 5:31 a.m. UTC
We'll prefer to pair services on connected bearer first.

There was a problem with pairing, that select_conn_bearer returned BR/EDR
even when we have connection to LE bearer only. In these situation we should
pair over connected bearer, since connection to another bearer can fail.
---
 src/device.c | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox series

Patch

diff --git a/src/device.c b/src/device.c
index 5a39a6f83..367e2f046 100644
--- a/src/device.c
+++ b/src/device.c
@@ -3017,6 +3017,11 @@  static DBusMessage *pair_device(DBusConnection *conn, DBusMessage *msg,
 		bdaddr_type = device->bdaddr_type;
 	else if (device->le_state.bonded)
 		bdaddr_type = BDADDR_BREDR;
+	else if (device->bredr_state.connected && !device->le_state.connected)
+		bdaddr_type = BDADDR_BREDR;
+	else if (!device->bredr_state.connected && device->le_state.connected)
+		bdaddr_type = device->bdaddr_type == BDADDR_BREDR
+			? BDADDR_LE_PUBLIC : device->bdaddr_type;
 	else
 		bdaddr_type = select_conn_bearer(device);