From patchwork Tue Jan 28 16:54:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 13952820 Received: from mail-vs1-f42.google.com (mail-vs1-f42.google.com [209.85.217.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 46B3E1B86EF for ; Tue, 28 Jan 2025 16:54:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.217.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738083269; cv=none; b=GlUPNVCqd0h50mbQnjnpW/fxSQmLZdnOMGHmkapyxEZ9bbzO2fMrK1gHFyap3juv+1gY2CHAMdBiw2BGvQVK/rLAYQk13jruIkRVxY1Cq44jGn8sr8XtXLjy5835f38bT9Yanh8nD+DCzvFu9OpwoKeHcKfPxlD+KHQs6eZckjU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738083269; c=relaxed/simple; bh=GHC7nNaM9Ja2GBOeHZTrfLxLzxfxx5uGHOBruMND45k=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=Oz7a8PR7W8tffRnW/5JL+cktJKisq7Q5VkcH3mX6FjK22bskPBEmnc1kQmmGwrum3PPYG6wS8f+UJTz0X5Cfdjvi/z3ZKa8lgVCLDl7sNiAsQBYtsA7ASHqNDey3PnjxYIJFsAuCLP1QCxTiCFnsjJi5iDT5xfKOmgf74YSyGjE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=PRugxrHD; arc=none smtp.client-ip=209.85.217.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PRugxrHD" Received: by mail-vs1-f42.google.com with SMTP id ada2fe7eead31-4b6398d477fso1739781137.0 for ; Tue, 28 Jan 2025 08:54:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738083266; x=1738688066; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=m5z1vuIlLSpz5GZoP3gLiDPSVcxkxUP8tVeGSspK174=; b=PRugxrHDRrVjjLp6957n2iNUeBiUHQ5Qv9MmD1eZuiXJZdJW3alsEjg32kQe+AVuEs cxNgXHl6XOY9edyfoX8cmP0n3tUhbnyG1q9UuP90iC41imUXvSG4CBefyZo2XHOGJQwt 2mplz40+Z9tnCdVJjZBIiU4iuQF7HHI4fUFHsK0Q6QvrgDTEZl2OAORJPrL35JFpBM/e fOzlVmbrLXAtntzwFmAacvCwpbzcljIqJyPzyFFCT1b9Q2/9iHMAKlbaFjMfz2HJWdjr AV94VsWM6nHfLtHxvFwrC0hxp3NUeQ8sbrDtOdIzYurbQsd7Er7WW/EG8O/zeS+FUXtr JcVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738083266; x=1738688066; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=m5z1vuIlLSpz5GZoP3gLiDPSVcxkxUP8tVeGSspK174=; b=xHC7uLEhOOg4nhl/YqyI4Rq0FBd+z85bHV53T/KLWWD0vZe2bxP4YhDTJ4KmSodPrM ycrs33rpk03DWLM0GcLD2Q+9OBMdOdI4iRBYE/dLipTw7JW6a7vZ33sMK7qtkByDWGSw sPhwCaptwkNc0ulKztQBExTiPJ56Udu+aNXuH+DieQIxUxO2+5bet5z47I9TLYLc1x83 tF9Vq+aRZfx48PbZIQFLMddGp5XK6qBCuoQr18mZRMuVj97c/KPobdnpJIvH7Kaj7j57 mIjCK1nb0BSKaV9yUz7EnjLXWpuLJgqZMxs2oSF+l+zHnodPq/7Zj98PO4tNQpc4ucYe 1Mig== X-Gm-Message-State: AOJu0YyNMe2S9/v6YPimNVWPjTXVRkcCnlOTBCYB4uA90udKbFpitxuE 9kvMg/73HcJHI+2vHENWajXfBq2Gu7zUo/i54pmBSe5JDlK9RvRmKg/zMw== X-Gm-Gg: ASbGncsXFNubQsfqhVsbvRDc9ssmrNSQVJiP+2eJIZ94KXOX6Eg3EiWN0j1KJhL+1D1 1tbsqkDsDsqWCKdpQ5VQKC5lK0EWAjPEWVF87kLZyxjUno3kgWf7Q4TH+ixupCvX9fx0z5tGWB9 ZILdnF5Hi6XUmzfmH5mtY+77oQd0OWXEhr8W0HLj4pcNqEaWq9S75c+bYePLlthYT7+vwHagsgM FwLO+EfwyeGcKZY8z2aJvcjaoO9tNOfQkbFiW3+ZkfmzcaO6VQThvHpowP090ZwyylXtn1rCFDN m7Z+vUDb7XUk6VDc5SOckp7lMd/2dGmcM4qAn1WbgF1EXjTFxu2OdEuduP115ehcLGWAkRf+vQ= = X-Google-Smtp-Source: AGHT+IEvWZ1kzsUl7aGUT6S5WA/5SYM8vKchYeXpxqJVEwcflY/BFaGbt/NR7A8Ua3Xzo4pf5XWZIQ== X-Received: by 2002:a05:6102:2d0d:b0:4b6:44ff:414e with SMTP id ada2fe7eead31-4b690ce4767mr44363556137.17.1738083266275; Tue, 28 Jan 2025 08:54:26 -0800 (PST) Received: from lvondent-mobl5.. (syn-107-146-107-067.res.spectrum.com. [107.146.107.67]) by smtp.gmail.com with ESMTPSA id a1e0cc1a2514c-864a9c40d58sm2575254241.32.2025.01.28.08.54.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jan 2025 08:54:25 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v1 1/2] org.bluez.GattCharacteristic: Add confirmation support to AcquireNotify Date: Tue, 28 Jan 2025 11:54:22 -0500 Message-ID: <20250128165424.1044479-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.48.1 Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Luiz Augusto von Dentz 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(+) diff --git a/doc/org.bluez.GattCharacteristic.rst b/doc/org.bluez.GattCharacteristic.rst index 784445234fe5..7b1b3fbb5446 100644 --- a/doc/org.bluez.GattCharacteristic.rst +++ b/doc/org.bluez.GattCharacteristic.rst @@ -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 From patchwork Tue Jan 28 16:54:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 13952821 Received: from mail-vk1-f175.google.com (mail-vk1-f175.google.com [209.85.221.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2BC701DC99A for ; Tue, 28 Jan 2025 16:54:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738083271; cv=none; b=ahwzbuU7cudC984ZdYzWgC//JfghiFh5C/fUF4yU31xWhBU+1bfVm1J0PcQKdKW7naqeUwsI7FCW7orvSoNfKQ9leNbfUZo/kNM9XAdbGXKfGjy9WhBY/07j0qZb04zBUE46SSnizkPBxLIq7/XdnPgDdhq1CYv4nHH0cBFJTDQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738083271; c=relaxed/simple; bh=z4HCfqxZ3sQHJraAewbv9m8eLcNZcSwl/KeinOVOl/Q=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jQ6U2w/NmqiLRzC6UBcOILQEF7Fuuf1Iy2vIOvj4StF4NhNXCzikDIyMUpoxNSOctqNLcOkHeayOmuO8EQRyjyWC15a5XZa2gbBx60e+UG9ZThuw04omOHPeC7GgLzrHkqXapk2ToJzYB3TUYkBe6ECvjTt4T8H7MTSnys3eXHY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Yn91VQpe; arc=none smtp.client-ip=209.85.221.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Yn91VQpe" Received: by mail-vk1-f175.google.com with SMTP id 71dfb90a1353d-518799f2828so2811038e0c.0 for ; Tue, 28 Jan 2025 08:54:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738083268; x=1738688068; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=r4pIkOBbYPJjp4YwcPUEGpvrvFRBkcnv6neCh7t+e7c=; b=Yn91VQpeL9ZDgHfk5czjaNhfZ9Z5+f9Rs8VRWKxMObhMatw/lPu11TzHak/8C642SV kuq/sKGh3SsxbwFy2bg7MF4DTNE32701PS4+SxRNSBKAMAwxYVGeWU0kwzcbtUNdyeYg aunaObCrgMMyf5O0B+xp3xEioSeTKVQjQjjhOSNi9clm1OaHgF6WpmIyvjDvV2EB7FKZ GdyUy+Tyy1F6j/mnQD1nRjc1+QVhWkHsyqehPE3VyXy/gVd8tKdZadsA6OJdRsrhF3OQ EcoVAklcY5cMJ9uGG5BDPhvWUUE7g0mcai0l5CDuwZD0kBXcgosYIY/UOR2JNSEIVEJX aPJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738083268; x=1738688068; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=r4pIkOBbYPJjp4YwcPUEGpvrvFRBkcnv6neCh7t+e7c=; b=uMSDsEdUYYEXiq7VtrIEFn4qDMlv0TckmggeJLFMufslTUaUMlV8ZBKvltprjaXZxJ 5Ya63Igd8PYdJJgh8hL5tEdUVSJRm9UEZOKomE6zRvrDgGSWodfDCzyF6++vckjyaA9j vWQJOilfo/NHFcFp5HB3nBTItDvGOPUcLD46zvE+aoB9kcwVBARjMMCQkmSMCiLYruBB nmy0ihV07EpduRyeL9E7V4o3o7QhvbGnFSapAMlNSJQ0FDMYgonuGr43bPLNaqhXYcWG 0bjv4xg6A3VtVDQ/FrJPqkf+tzu0NnavlbPwwWybo50o5ZUCRcB8DbhT5F5Bq53v37hz E+kQ== X-Gm-Message-State: AOJu0YwBYLEPRlsjDFxc3iLFgzg3nnl4sqV9t2If9j3Tg6Kne1cnbLo8 LuyePBhS1ZnhCV6fuq7Nss64wf4Qkn9SeF0gjPDFWRGyVVZNv35WOAHMjA== X-Gm-Gg: ASbGnct4elaroDIo8LDUmVIBEXrDCMx645hNbfy/czscm4ctVn737+jMgqsWXmBSN1b ofx+8UDSDpV8yDsYB/hPr20zGgZhqKqFmklHakgfDSH12744W+5sl30IANLRTya7Yw/IySvO7EJ Z6a7xGjGTiCACmQ19rE5ZBwN7IZ6KWz3a/ZxCxCDdO+EoGqGXaF5jvGig90vaLcLXiOacQdC5Ks bUrXuA1EFy1T56184zRG7YxADkZi82XF+g01XUDlXmX/v3xAtpmnCj+5ZeLNtZ/SmpRlsMDkKAd fcn/pZbSEzr9cdxUdj8cVAtJO2oLOqll/mRpc6NeGK9XTTZzkhyfkB0MgKib1Cc= X-Google-Smtp-Source: AGHT+IFZcMRJCuViT/EKhRlCUiZEhaOWpE1LhcT+ZOIZP5DEd4qn7crlobRYf4MWzL4V93pgA31y2Q== X-Received: by 2002:a05:6122:e5f:b0:516:dc0f:c925 with SMTP id 71dfb90a1353d-51e8e307315mr3345718e0c.6.1738083268310; Tue, 28 Jan 2025 08:54:28 -0800 (PST) Received: from lvondent-mobl5.. (syn-107-146-107-067.res.spectrum.com. [107.146.107.67]) by smtp.gmail.com with ESMTPSA id a1e0cc1a2514c-864a9c40d58sm2575254241.32.2025.01.28.08.54.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jan 2025 08:54:27 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v1 2/2] gatt: Implement confirmation support for AcquireNotify Date: Tue, 28 Jan 2025 11:54:23 -0500 Message-ID: <20250128165424.1044479-2-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250128165424.1044479-1-luiz.dentz@gmail.com> References: <20250128165424.1044479-1-luiz.dentz@gmail.com> Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Luiz Augusto von Dentz This implements AcquireNotify (fd based) confirmation so servers can be notified when a client confirm the reception of an indication. Fixes: https://github.com/bluez/bluez/issues/1081 --- src/gatt-database.c | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/src/gatt-database.c b/src/gatt-database.c index a5a01add40f7..7a105b8fe64a 100644 --- a/src/gatt-database.c +++ b/src/gatt-database.c @@ -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(¬ify, 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, ¬ify); return true; }