Skip to contentSkip to conversation

org.bluez.GattCharacteristic: Add confirmation support to AcquireNotify

PATCH Applied Luiz Augusto von Dentz 3 participants 4 messages Jan 28, 2025 – Jan 30, 2025 Bluetooth drivers

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH 1/2 org.bluez.GattCharacteristic: Add confirmation support to AcquireNotify

From: Luiz Augusto von Dentz <[email protected]>

This adds confirmation support for AcquireNotify when indication procedure is used, also document the behavior of clients vs servers.

---
 doc/org.bluez.GattCharacteristic.rst | 5 +++++
 1 file changed, 5 insertions(+)
doc/org.bluez.GattCharacteristic.rst +5 -0
index 784445234fe5..7b1b3fbb5446 100644
@@ -212,6 +212,11 @@ fd, uint16 AcquireNotify(dict options) [optional]
 	To release the lock the client shall close the file descriptor, a HUP is
 	generated in case the device is disconnected.
 
+	As a client if indication procedure is used the confirmation is
+	generated automatically once received, for a server if the file
+	descriptor is writable (POLLOUT) then upon receiving a confirmation from
+	the client one byte (0x01) is written to the file descriptor.
+
 	Note: the MTU can only be negotiated once and is symmetric therefore
 	this method may be delayed in order to have the exchange MTU completed,
 	because of that the file descriptor is closed during reconnections as
Signature · 1 line
2.48.1
author maintainer
#1 lore raw

PATCH 2/2 gatt: Implement confirmation support for AcquireNotify

From: Luiz Augusto von Dentz <[email protected]>

This implements AcquireNotify (fd based) confirmation so servers can be notified when a client confirm the reception of an indication.

---
 src/gatt-database.c | 38 ++++++++++++++++++++++++++++++++++++--
 1 file changed, 36 insertions(+), 2 deletions(-)
src/gatt-database.c +36 -2
index a5a01add40f7..7a105b8fe64a 100644
@@ -2601,6 +2601,24 @@ static bool sock_hup(struct io *io, void *user_data)
 	return false;
 }
 
+static bool sock_io_write(struct io *io, void *user_data)
+{
+	uint8_t buf[] = { 1 };
+	struct iovec iov = { buf, sizeof(buf) };
+
+	/* Send a 1 to the server as confirmation */
+	io_send(io, &iov, 1);
+
+	return false;
+}
+
+static void sock_io_conf(void *user_data)
+{
+	struct io *io = user_data;
+
+	io_set_write_handler(io, sock_io_write, NULL, NULL);
+}
+
 static bool sock_io_read(struct io *io, void *user_data)
 {
 	struct client_io *client = user_data;
@@ -2608,6 +2626,8 @@ static bool sock_io_read(struct io *io, void *user_data)
 	uint8_t buf[512];
 	int fd = io_get_fd(io);
 	ssize_t bytes_read;
+	struct notify notify;
+	struct device_state *state;
 
 	if (fd < 0) {
 		error("io_get_fd() returned %d\n", fd);
@@ -2618,8 +2638,22 @@ static bool sock_io_read(struct io *io, void *user_data)
 	if (bytes_read <= 0)
 		return false;
 
-	gatt_notify_cb(chrc->attrib, chrc->ccc, buf, bytes_read, client->att,
-				client->chrc->service->app->database);
+	memset(&notify, 0, sizeof(notify));
+
+	notify.database = client->chrc->service->app->database;
+	notify.handle = gatt_db_attribute_get_handle(chrc->attrib);
+	notify.ccc_handle = gatt_db_attribute_get_handle(chrc->ccc);
+	notify.value = (void *) buf;
+	notify.len = bytes_read;
+	notify.conf = sock_io_conf;
+	notify.user_data = io;
+
+
+	state = find_device_state_by_att(notify.database, client->att);
+	if (!state)
+		return false;
+
+	send_notification_to_device(state, &notify);
 
 	return true;
 }
Signature · 1 line
2.48.1
#2 lore raw
In reply to Luiz Augusto von Dentz

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=928892

---Test result---

Test Summary:

CheckPatch                    PENDING   0.21 seconds
GitLint                       PENDING   0.24 seconds
BuildEll                      PASS      20.08 seconds
BluezMake                     PASS      1559.01 seconds
MakeCheck                     PASS      13.12 seconds
MakeDistcheck                 PASS      156.65 seconds
CheckValgrind                 PASS      212.54 seconds
CheckSmatch                   PASS      267.63 seconds
bluezmakeextell               PASS      97.26 seconds
IncrementalBuild              PENDING   0.35 seconds
ScanBuild                     PASS      844.59 seconds

Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:

##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:

##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series Output:

---
Regards,
Linux Bluetooth

#3 lore raw
In reply to Luiz Augusto von Dentz
This series was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:

Hello:

This series was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:

Quoted 7 lines · On Tue, 28 Jan 2025 11:54:22 -0500 you wrote:

From: Luiz Augusto von Dentz <[email protected]>

This adds confirmation support for AcquireNotify when indication procedure is used, also document the behavior of clients vs servers.

---
 doc/org.bluez.GattCharacteristic.rst | 5 +++++
 1 file changed, 5 insertions(+)

Here is the summary with links:
- [BlueZ,v1,1/2] org.bluez.GattCharacteristic: Add confirmation support to AcquireNotify

    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=1f7a7c9dcadb
  - [BlueZ,v1,2/2] gatt: Implement confirmation support for AcquireNotify
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=6b34b055117c

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html