All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ v3 2/4] hog-lib: Make use of bt_uhid_replay
Date: Wed, 10 Apr 2024 10:02:03 -0400	[thread overview]
Message-ID: <20240410140205.4056047-2-luiz.dentz@gmail.com> (raw)
In-Reply-To: <20240410140205.4056047-1-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This makes use of bt_uhid_replay to replay the GET/SET_REPORT messages
recorded during the first time the device is created.
---
 profiles/input/hog-lib.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/profiles/input/hog-lib.c b/profiles/input/hog-lib.c
index 8071e1364b10..0291adb6eb23 100644
--- a/profiles/input/hog-lib.c
+++ b/profiles/input/hog-lib.c
@@ -856,12 +856,14 @@ static void set_report(struct uhid_event *ev, void *user_data)
 		--size;
 	}
 
+	if (hog->attrib == NULL) {
+		err = -ENOTCONN;
+		goto fail;
+	}
+
 	DBG("Sending report type %d ID %d to handle 0x%X", report->type,
 				report->id, report->value_handle);
 
-	if (hog->attrib == NULL)
-		return;
-
 	hog->setrep_att = gatt_write_char(hog->attrib,
 						report->value_handle,
 						data, size, set_report_cb,
@@ -1726,6 +1728,11 @@ bool bt_hog_attach(struct bt_hog *hog, void *gatt)
 				"handle 0x%04x", r->value_handle);
 	}
 
+	/* Attempt to replay get/set report messages since the driver might not
+	 * be aware the device has been disconnected in the meantime.
+	 */
+	bt_uhid_replay(hog->uhid);
+
 	return true;
 }
 
-- 
2.44.0


  reply	other threads:[~2024-04-10 14:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-10 14:02 [PATCH BlueZ v3 1/4] shared/uhid: Add support for bt_uhid_replay Luiz Augusto von Dentz
2024-04-10 14:02 ` Luiz Augusto von Dentz [this message]
2024-04-10 14:02 ` [PATCH BlueZ v3 3/4] input/device: Make use of bt_uhid_replay Luiz Augusto von Dentz
2024-04-10 14:02 ` [PATCH BlueZ v3 4/4] hog-lib: Destroy uHID device if there is traffic while disconnected Luiz Augusto von Dentz
2024-04-10 15:30 ` [PATCH BlueZ v3 1/4] shared/uhid: Add support for bt_uhid_replay patchwork-bot+bluetooth
2024-04-10 16:54 ` [BlueZ,v3,1/4] " 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=20240410140205.4056047-2-luiz.dentz@gmail.com \
    --to=luiz.dentz@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 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.