public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ] device: warn on BR/EDR connection key mismatch
@ 2026-04-03 23:42 Harsh
  2026-04-04  0:39 ` [BlueZ] " bluez.test.bot
  0 siblings, 1 reply; 2+ messages in thread
From: Harsh @ 2026-04-03 23:42 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: lazy-pir8

From: lazy-pir8 <harshsahuxlr9@gmail.com>

Log a clear message when a device fails to connect due to
Bluetooth BR/EDR keys changing (e.g., after pairing from
another system). Advises user to remove and re-pair the device.
---
 src/device.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/src/device.c b/src/device.c
index cfbde307b..cd62abd73 100644
--- a/src/device.c
+++ b/src/device.c
@@ -2066,10 +2066,23 @@ void device_request_disconnect(struct btd_device *device, DBusMessage *msg)
 		const char *err_str;
 		DBusMessage *reply;
 
-		if (device->bonding_status == MGMT_STATUS_AUTH_FAILED)
-			err_str = ERR_BREDR_CONN_KEY_MISSING;
-		else
-			err_str = ERR_BREDR_CONN_CANCELED;
+	if (device->bonding_status == MGMT_STATUS_AUTH_FAILED) {
+		char name[256] = {0};
+	
+		device_get_name(device, name, sizeof(name));
+	
+		if (name[0] == '\0')
+			snprintf(name, sizeof(name), "unknown");
+	
+		error("DEBUG HIT: Connection failed for %s (key missing case)", name);
+	
+		warn("Connection failed for %s. The device keys may have changed (e.g. pairing from another system). Consider removing and re-pairing.",
+		     name);
+		
+		err_str = ERR_BREDR_CONN_KEY_MISSING;
+	} else {
+		err_str = ERR_BREDR_CONN_CANCELED;
+	}
 		reply = btd_error_failed(device->connect, err_str);
 		g_dbus_send_message(dbus_conn, reply);
 		dbus_message_unref(device->connect);
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-04-04  0:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-03 23:42 [PATCH BlueZ] device: warn on BR/EDR connection key mismatch Harsh
2026-04-04  0:39 ` [BlueZ] " bluez.test.bot

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