All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Frédéric Danis" <frederic.danis@collabora.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ 5/8] client/btpclient: Add BTP_OP_BAP_SEND support
Date: Fri,  4 Sep 2026 15:51:21 +0200	[thread overview]
Message-ID: <20260904135124.981346-6-frederic.danis@collabora.com> (raw)
In-Reply-To: <20260904135124.981346-1-frederic.danis@collabora.com>

---
 client/btpclient/bap.c | 41 +++++++++++++++++++++++++++++++++++++++++
 src/shared/btp.h       | 13 +++++++++++++
 2 files changed, 54 insertions(+)

diff --git a/client/btpclient/bap.c b/client/btpclient/bap.c
index d30d931f1..f7bee9831 100644
--- a/client/btpclient/bap.c
+++ b/client/btpclient/bap.c
@@ -31,6 +31,7 @@ static void btp_bap_read_commands(uint8_t index, const void *param,
 	const uint8_t supported_commands[] = {
 		BTP_OP_BAP_READ_SUPPORTED_COMMANDS,
 		BTP_OP_BAP_DISCOVER,
+		BTP_OP_BAP_SEND,
 	};
 	uint8_t *commands = NULL;
 	size_t commands_len = 0;
@@ -104,6 +105,43 @@ failed:
 	btp_send_error(btp, BTP_BAP_SERVICE, index, status);
 }
 
+static void btp_bap_send(uint8_t index, const void *param, uint16_t length,
+								void *user_data)
+{
+	const struct btp_bap_send_cp *cp = param;
+	struct btp_adapter *adapter = find_adapter_by_index(index);
+	uint8_t status = BTP_ERROR_FAIL;
+	struct btp_device *dev;
+	struct btp_ase *ase;
+	ssize_t bytes_written;
+	struct btp_bap_send_rp rp;
+
+	if (!adapter) {
+		status = BTP_ERROR_INVALID_INDEX;
+		goto failed;
+	}
+
+	dev = find_device_by_address(adapter, &cp->address, cp->address_type);
+	ase = find_ase_by_dir(dev, BTP_BAP_DIR_SINK);
+	if (!ase || !ase->io)
+		goto failed;
+
+	bytes_written = write(l_io_get_fd(ase->io), cp->data,
+		cp->data_len <= ase->tx_mtu ? cp->data_len : ase->tx_mtu);
+	if (bytes_written < 0) {
+		l_error("Failed to write (%d)", errno);
+		goto failed;
+	}
+	rp.data_len = bytes_written;
+
+	btp_send(btp, BTP_BAP_SERVICE, BTP_OP_BAP_SEND, index, sizeof(rp), &rp);
+
+	return;
+
+failed:
+	btp_send_error(btp, BTP_BAP_SERVICE, index, status);
+}
+
 static void bap_charac_read_setup(struct l_dbus_message *message,
 							void *user_data)
 {
@@ -304,6 +342,9 @@ bool bap_register_service(struct btp *btp_, struct l_dbus *dbus_,
 	btp_register(btp, BTP_BAP_SERVICE, BTP_OP_BAP_DISCOVER,
 					btp_bap_discover, NULL, NULL);
 
+	btp_register(btp, BTP_BAP_SERVICE, BTP_OP_BAP_SEND,
+					btp_bap_send, NULL, NULL);
+
 	bap_service_registered = true;
 
 	return true;
diff --git a/src/shared/btp.h b/src/shared/btp.h
index 8ad57f48f..fe93158aa 100644
--- a/src/shared/btp.h
+++ b/src/shared/btp.h
@@ -481,6 +481,19 @@ struct btp_bap_discover_cp {
 	bdaddr_t address;
 } __packed;
 
+#define BTP_OP_BAP_SEND				0x03
+struct btp_bap_send_cp {
+	uint8_t address_type;
+	bdaddr_t address;
+	uint8_t ase_id;
+	uint8_t data_len;
+	uint8_t data[];
+} __packed;
+
+struct btp_bap_send_rp {
+	uint8_t data_len;
+} __packed;
+
 #define BTP_EV_BAP_DISCOVERY_COMPLETED		0x80
 struct btp_bap_discovery_completed_ev {
 	uint8_t address_type;
-- 
2.43.0


  parent reply	other threads:[~2026-09-04 13:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-04 13:51 [PATCH BlueZ 0/8] client/btpclient: Add BAP/ASCS/PACS support for auto-pts BAP tests Frédéric Danis
2026-09-04 13:51 ` [PATCH BlueZ 1/8] client/btpclient: Add BTP_EV_BAP_ASE_FOUND support Frédéric Danis
2026-09-04 17:38   ` client/btpclient: Add BAP/ASCS/PACS support for auto-pts BAP tests bluez.test.bot
2026-09-04 13:51 ` [PATCH BlueZ 2/8] client/btpclient: Get Codec capabilities on ASE reply Frédéric Danis
2026-09-04 13:51 ` [PATCH BlueZ 3/8] client/btpclient: Add ASCS BTP support Frédéric Danis
2026-09-04 13:51 ` [PATCH BlueZ 4/8] client/btpclient: Add BTP_OP_PACS_SET_LOCATION support Frédéric Danis
2026-09-04 13:51 ` Frédéric Danis [this message]
2026-09-04 13:51 ` [PATCH BlueZ 6/8] client/btpclient: Add ASCS support for BAP/UCL/STR/* tests Frédéric Danis
2026-09-04 13:51 ` [PATCH BlueZ 7/8] client/btpclient: Defer CIG/CIS assignment based on Client/Server role Frédéric Danis
2026-09-04 13:51 ` [PATCH BlueZ 8/8] client/btpclient: Add stream auto acquire for BAP/USR/STR/* tests Frédéric Danis

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=20260904135124.981346-6-frederic.danis@collabora.com \
    --to=frederic.danis@collabora.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.