From: Harsh <harshsahuxlr9@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: lazy-pir8 <harshsahuxlr9@gmail.com>
Subject: [PATCH BlueZ] device: warn on BR/EDR connection key mismatch
Date: Sat, 4 Apr 2026 05:12:46 +0530 [thread overview]
Message-ID: <20260403234246.31501-1-harshsahuxlr9@gmail.com> (raw)
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
next reply other threads:[~2026-04-03 23:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-03 23:42 Harsh [this message]
2026-04-04 0:39 ` [BlueZ] device: warn on BR/EDR connection key mismatch bluez.test.bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260403234246.31501-1-harshsahuxlr9@gmail.com \
--to=harshsahuxlr9@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox