All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ] device: Reply br-connection-key-missing on connection bonding error
@ 2025-05-14 11:20 Frédéric Danis
  2025-05-14 11:31 ` Paul Menzel
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Frédéric Danis @ 2025-05-14 11:20 UTC (permalink / raw)
  To: linux-bluetooth

Currently when connection is removed while the client is waiting for
Connect() the failed message is br-connection-canceled, even if this
is due to bonding error.

This commit reply br-connection-key-missing when connection request
fails due to bonding error, allowing the client to differentiate
connection failure reasons.
---
 src/device.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/device.c b/src/device.c
index c364d72c3..816282eab 100644
--- a/src/device.c
+++ b/src/device.c
@@ -246,6 +246,7 @@ struct btd_device {
 	struct browse_req *browse;		/* service discover request */
 	struct bonding_req *bonding;
 	struct authentication_req *authr;	/* authentication request */
+	uint8_t		bonding_status;
 	GSList		*disconnects;		/* disconnects message */
 	DBusMessage	*connect;		/* connect message */
 	DBusMessage	*disconnect;		/* disconnect message */
@@ -3636,6 +3637,7 @@ void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type,
 	DBusMessage *reply;
 	bool remove_device = false;
 	bool paired_status_updated = false;
+	uint8_t bonding_status = device->bonding_status;
 
 	if (!state->connected)
 		return;
@@ -3643,6 +3645,7 @@ void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type,
 	state->connected = false;
 	state->initiator = false;
 	device->general_connect = FALSE;
+	device->bonding_status = 0;
 
 	device_set_svc_refreshed(device, false);
 
@@ -3658,6 +3661,7 @@ void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type,
 	if (device->connect) {
 		DBG("connection removed while Connect() is waiting reply");
 		reply = btd_error_failed(device->connect,
+				bonding_status ? ERR_BREDR_CONN_KEY_MISSING :
 						ERR_BREDR_CONN_CANCELED);
 		g_dbus_send_message(dbus_conn, reply);
 		dbus_message_unref(device->connect);
@@ -6763,6 +6767,8 @@ void device_bonding_complete(struct btd_device *device, uint8_t bdaddr_type,
 
 	DBG("bonding %p status 0x%02x", bonding, status);
 
+	device->bonding_status = status;
+
 	if (auth && auth->agent)
 		agent_cancel(auth->agent);
 
-- 
2.43.0


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

end of thread, other threads:[~2025-05-14 14:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-14 11:20 [PATCH BlueZ] device: Reply br-connection-key-missing on connection bonding error Frédéric Danis
2025-05-14 11:31 ` Paul Menzel
2025-05-14 12:40 ` [BlueZ] " bluez.test.bot
2025-05-14 14:52 ` [PATCH BlueZ] " Luiz Augusto von Dentz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.