[PATCH BlueZ 2/2] input: device: Browse SDP records if not cached

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



For a HID paired device, if the cache file containing the SDP records
is not present this will prevent the device to connect and need to
remove it and pair again.

Current bluetoothd traces:
src/shared/mgmt.c:can_read_data() [0x0000] event 0x000b
src/adapter.c:connected_callback() hci0 device EC:83:50:76:BD:67
  connected eir_len 31
src/shared/mgmt.c:can_read_data() [0x0000] event 0x0006
profiles/input/server.c:connect_event_cb() Incoming connection from
  EC:83:50:76:BD:67 on PSM 17
profiles/input/device.c:input_device_set_channel() idev 0x5580c6a331b0
  psm 17
profiles/input/server.c:confirm_event_cb()
profiles/input/server.c:connect_event_cb() Incoming connection from
  EC:83:50:76:BD:67 on PSM 19
profiles/input/device.c:input_device_set_channel() idev 0x5580c6a331b0
  psm 19
profiles/input/device.c:hidp_add_connection() Could not parse HID SDP
  record: No such file or directory (2)
profiles/input/device.c:ctrl_watch_cb() Device EC:83:50:76:BD:67
  disconnected
profiles/input/device.c:intr_watch_cb() Device EC:83:50:76:BD:67
  disconnected

This commit tries to retrieve the SDP record from the remote HID then
to add the HIDP connection.
---
 profiles/input/device.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/profiles/input/device.c b/profiles/input/device.c
index b162c0bc7..c1bb5588d 100644
--- a/profiles/input/device.c
+++ b/profiles/input/device.c
@@ -86,6 +86,7 @@ struct input_device {
 	bool			virtual_cable_unplug;
 	uint8_t			type;
 	unsigned int		idle_timer;
+	bool			sdp_rediscover;
 };
 
 static int idle_timeout = 0;
@@ -1045,6 +1046,22 @@ static gboolean encrypt_notify(GIOChannel *io, GIOCondition condition,
 	return FALSE;
 }
 
+static void input_device_update_rec(struct input_device *idev);
+static int hidp_add_connection(struct input_device *idev);
+
+static void hidp_sdp_cb(struct btd_device *dev, int err, void *user_data)
+{
+	struct input_device *idev = user_data;
+
+	DBG("");
+
+	/* Attempt to update SDP record if it had changed */
+	input_device_update_rec(idev);
+
+	if (hidp_add_connection(idev) < 0)
+		btd_service_disconnect(idev->service);
+}
+
 static int hidp_add_connection(struct input_device *idev)
 {
 	struct hidp_connadd_req *req;
@@ -1061,6 +1078,18 @@ static int hidp_add_connection(struct input_device *idev)
 	if (err < 0) {
 		error("Could not parse HID SDP record: %s (%d)", strerror(-err),
 									-err);
+		if (err == -ENOENT && !idev->sdp_rediscover) {
+			err = device_discover_services(idev->device);
+			if (err < 0) {
+				error("Could not discover services: %s (%d)",
+							strerror(-err), -err);
+				goto cleanup;
+			}
+
+			idev->sdp_rediscover = TRUE;
+			device_wait_for_svc_complete(idev->device,
+				hidp_sdp_cb, idev);
+		}
 		goto cleanup;
 	}
 
-- 
2.43.0





[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux