From patchwork Mon Aug 5 12:04:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 13753555 Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11011011.outbound.protection.outlook.com [52.101.65.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 146F0156984 for ; Mon, 5 Aug 2024 12:04:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.65.11 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722859484; cv=fail; b=Jl2oCWXfi5jiFnhvOMsIamve4K/KZTEaKLtyhloguWRMthTsQj5ps4cmZbOe847JSLpFzodPd1TPlyii0VArOP/WUJwRkJNtp7hWfd3sWr45pycFWbFz6OjNsuBLO6saSqKCgGgdKU7wsbi8GXqaS+jDo6WG2UZMolUj/+s2r7E= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722859484; c=relaxed/simple; bh=Dm12jg2pSklaaacwSlbmlsh6UHqM89yOEzBpX2MEoWU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=h1huI0qvrBFdYn19o2zhnPQrwhJp2CriSOoHyCGHexkn0vuwQ7fs97ajQulIMZsFeElRnTQnzP3SxLqJnmJa7kxASmf5RgJRJePBk1dpRL3ERpq9GvfTjWGwD6zZ95yzf7r7LmNIZVmVbTnTCu4bIVrwVvHD+uFg37pEDpre0Cw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=WFbmau/z; arc=fail smtp.client-ip=52.101.65.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="WFbmau/z" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=u8/FeXIT6jShpU4KyZETMzBQkcnX16q0WDaSfU73Gbrs/PfaGizBZo02E7u2v6yktzY/uAW3l7BtR2S2+Lf9Urb3jI8RLzLK5jXVTUt9PuBrZpiim4MBQYOQW9WILKsdas6JweICiwxbJffQSNk+fB31VOJgX0aKyUywUzg4H+ngz4OJUewmGV+dQqBiwggEWF3qIwWa4qai0dEjbcW+m19W6yvdTNSTjX8HY2KeOYUxrSJuieBLqX4n+ZE55gNmnL7fVOjjld4F0LRkhsosDsmOxYhjqJwDxwN7iY06dj0u4u5z4a/gM3DIbRdqsriUAQkv8ApwF1uyV7GciQvlPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=lTM+jvPG9/QfVnetjLd7Qn2KKAkjhBlo6TkN/w5IylE=; b=EMDoGQn4TdEgQuLw3Fx0uYCNlSqOO7OZxHQz5XK+GKYOS7LdIdAsx+A6M7+3wEJj3bqoFKlI/j1gUcXDVBjfgTJIIFJvj6kUK9A2nyUvwiNyV6xuEzsOU1J5w2wIrOnIIrTVeYOz+uL7mdP/7tnXyAXDFHp4POe1bbnIYc0NiDL93phPYo3lJLDs7eXAqU7mngpXOp3PTUW8Vxo7bYyn5ylJRoWQFoi0Qm5fxC1JlUncP/NrqgSaQp9Fj4LurjI3FgoB9zHR0HDyqOQJ6LozfF3sqIeqPe+m5dEMFbEPyl+A6Rq5ZcrVJUWW0IN5Coyeh5m6/cT3SlBsLB/8LYf6Rw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lTM+jvPG9/QfVnetjLd7Qn2KKAkjhBlo6TkN/w5IylE=; b=WFbmau/zI5cQthqy4/TuI4KzVzikxtHWTwHIfvCLZibqCaqfatw7GNirXkrLcbc2/S1GO1lrToiqUKv1n71GkH0cQgFwEvRpu2PMzv+4iejHQ00Y9DPh/oy8LUgWSgsADx6lM7PVIw9d7j8XLZ9bCdVL5fbTAf9rza+0afJbbUhHJNZHtFjke9Row+H44iwFHK8rCD1I1eCQl2X4P4ujmAgeixkdUfPVb8MIUZ0PpTzd0He2LYXtkmyeTyNsz9TuKLDjtr1CqTR5JZQsnUzqYAK8TA5zALYy77g8oRlorBcssbSyK6sLmuBztJ13PYNAYhCdc6C+LB8JBMGzsl6r4Q== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) by DU4PR04MB10499.eurprd04.prod.outlook.com (2603:10a6:10:568::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.26; Mon, 5 Aug 2024 12:04:38 +0000 Received: from AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654]) by AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654%5]) with mapi id 15.20.7828.023; Mon, 5 Aug 2024 12:04:38 +0000 From: Iulia Tanasescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, vlad.pruteanu@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Iulia Tanasescu Subject: [PATCH BlueZ 1/7] shared/bass: Add API to send GATT write command Date: Mon, 5 Aug 2024 15:04:23 +0300 Message-Id: <20240805120429.67606-2-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240805120429.67606-1-iulia.tanasescu@nxp.com> References: <20240805120429.67606-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AS4P192CA0027.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:5e1::17) To AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8898:EE_|DU4PR04MB10499:EE_ X-MS-Office365-Filtering-Correlation-Id: a770b237-a3d4-4d8d-5122-08dcb546c7c7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014; X-Microsoft-Antispam-Message-Info: KAq2P5Syv76mE3EoU3mRVmpi9OnNNQFsUQDlJiJIdzrg3aEBQVMVAlKbMxfiuWdPtNAGaLpR8HMIqjXrYLu8BIk/rZHN5iDR9l5fLZGGvK1WcXYTZU6Mq2J+a76jxpBdCqAdZ4cnAPNJmHn713zR+mAB/l4sOg5In5hSJzfRT3wBRI85FIpzETzwr5bFipTW+t0hBggg9i+esjbokZaUG8kYOoF1qM64Wk7BVqDLbi8afRPMT5c+Bi3UFPwA5luS7212mY794gcEvhUDdwgBA9kqeG3M/a2+iE42Q2dGstXahOaAmx/TFgmMhj8d0poxrMKTnNaDhsB35oV5fedRGrFwJDGl70b7gmi0JLvoBN8UbW5CYD0HtbL99+LCU/Mr8l491OovybzpILyRz7Zu1ya/agjfjzf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FS:(13230040)(366016)(1800799024)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9Yr6ZVFycMbYRwpCYuscq2XNUlnKY7rkqfwM+8DK3aTvCvpEnhw8t3H9TzBOdPPmNqIU92l2MFLVDcNeIpzkxzoN1gYgya7I7oAKazm2foaKM0+r52ta/WskObvTnYKUY+z2aaZlXMtuRcs3EYFn3L0o5/u8U2Vd8j/7GH09vDtmytwptqqDn3GNzyA7O7lUexlpzlbMe5CIqzp9JXtskZ9xidvJTmHlB5IVepSju/azW/etOw1qSww7/09jYNonqONUzYrXM+LyHk0Mt076Naqi2F7jEGnk/uJUI3EUYaJBPmw3jujrqG6gPhcjTsqn28FHiWQF2des1fNyj7ziMkXC4eDY6NGg+vUdcqR03ju0Kz1f9xfL10RJ/FeB7oZPcG5T7p+GGTD+sHEdNKa4l7QoTBS8zllY+G90Yqo1GEzWuhnLiwnJ6cQs+74KeJCGt7eMpUKXHeOkRkQbWXji7MJziTqYcoZnoXpBHmH/vkgiSQ6tqmc/pDqkYRX6MLqxTy7o8aQiFgpKYWBdkFeZ1+q3G7dD9PC4klfHK8m3BzfXfT2II4PWpUfkDDZQPjkq9aDi9RcKrTbAmdf1utvEx9djxPmcQgEahnbgj8DJdh0/wN5G1RsmKES0i4TxxpjoV1MiPnwwYX3d4jO75sQKFLhqd9UitRGnzQqnT0S1HTCfkBvtjn1HZvqMJ1+oD91ndvbYN528+SQuv4cNLgtIxd+8U73w0JIIVomj47U9owJ16b1S0OYu7eVcoWb0iti4h46u58Je5i9EcGmOoq5+6vQEs3n3sPgo+w38Hv2AKZ2MNhtubexyu+p2SbLB0Nk6lZ9gXN9BIwotORWp90Ugl1BwtlVhVxWNBogvgReHxCpnBbw1mGZsDsyH3K2sjbgFt/+7mavzPdZ+gqLEphAQK6uBM2thav+HlhWVaScR2RJySTdnd+rwhRmPOV4vwpQlZJj80rtvupEK/O5gLupExGR3q8ayaTvzwxjPEmJtLkVONMpEw0w/vNNPUUX6xzeVt1eNqB+4MnprpRmHhVF3/ClBE2TUrJF9e+JOLTJk43uLXpuTzVAOL3zmcoqnmYJR22+gUahcJSGuOUj45ZGhMDQ+2mHrIiyBiHeXx2NIcE3dLHzGvT36YfitHSUNN2TcD/08Fg9AwyI1eqF1hZip+AbobtSRXb2QSyliG1QFsRgYHDGTvdKpVYRxpmqX8iTikgfYcKEiL99CtgdTjEi00lq4Dz+hlfBMThhr87Cit+1IkiHGWyYbDmKy2lCum+yxEMnNSi3d/8PRO18AyB3OXSvOYzgPuV71VWTrqk1KpcyZK136YlhpkBQjCC5v4Dj+NBa2iq3vJyFd5yNxg9iai5ifoYOesuepee8Y1lm2mrKJ9pA+fYMNUOuDFwImbP5F3wpj7F9L84Y1uyte5w3s8EVVSEmxV9UGM/h4IlPoPxYzMfgfeBGN8Pjqa8ss5BPMziwmA4rlFMFfHSf7gzwAlCPHuBd2+A/lzLHWcL/sSHfFsnH3MmYG2DnZ5Jizp7S0ucMZ9aEBl8rOUVbMxB45nNgJY5XAz/9VW8m26c9wX2nOW2N3XdURG0drfPG1L5TzcEcnoegeESra4Gv6WsfsEg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a770b237-a3d4-4d8d-5122-08dcb546c7c7 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Aug 2024 12:04:38.4675 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: R7M4cYAhuhemEX+Y5fDpyLrE7USvK5n0hAVzZcGeL8EWa4jv0yNiQbH55m8dlsoSXcaiqghm7e8PsIEi5Ridvw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU4PR04MB10499 This adds a BASS API to send a GATT write command for the Broadcast Audio Scan Control Point characteristic. --- src/shared/bass.c | 38 +++++++++++++++++++++++++++++++++++++- src/shared/bass.h | 5 ++++- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/src/shared/bass.c b/src/shared/bass.c index 268e3bd86..d9ab210b7 100644 --- a/src/shared/bass.c +++ b/src/shared/bass.c @@ -3,7 +3,7 @@ * * BlueZ - Bluetooth protocol stack for Linux * - * Copyright 2023 NXP + * Copyright 2023-2024 NXP * */ @@ -1754,3 +1754,39 @@ void bt_bass_add_db(struct gatt_db *db, const bdaddr_t *adapter_bdaddr) { bass_db_new(db, adapter_bdaddr); } + +int bt_bass_send(struct bt_bass *bass, + struct bt_bass_bcast_audio_scan_cp_hdr *hdr, + struct iovec *params) +{ + struct iovec req = {0}; + uint16_t handle; + int err = 0; + + if (!bass || !bass->client || !bass->rdb) + return -EINVAL; + + DBG(bass, "bass %p", bass); + + req.iov_base = malloc0(sizeof(*hdr) + params->iov_len); + if (!req.iov_base) + return -EINVAL; + + util_iov_push_mem(&req, sizeof(*hdr), hdr); + util_iov_push_mem(&req, params->iov_len, params->iov_base); + + if (!gatt_db_attribute_get_char_data(bass->rdb->bcast_audio_scan_cp, + NULL, &handle, NULL, NULL, NULL)) { + err = -EINVAL; + goto done; + } + + if (!bt_gatt_client_write_without_response(bass->client, handle, + false, req.iov_base, req.iov_len)) + err = -EINVAL; + +done: + free(req.iov_base); + + return err; +} diff --git a/src/shared/bass.h b/src/shared/bass.h index 1674146bc..864b01637 100644 --- a/src/shared/bass.h +++ b/src/shared/bass.h @@ -3,7 +3,7 @@ * * BlueZ - Bluetooth protocol stack for Linux * - * Copyright 2023 NXP + * Copyright 2023-2024 NXP * */ @@ -135,3 +135,6 @@ bool bt_bass_attach(struct bt_bass *bass, struct bt_gatt_client *client); bool bt_bass_set_att(struct bt_bass *bass, struct bt_att *att); void bt_bass_detach(struct bt_bass *bass); void bt_bass_add_db(struct gatt_db *db, const bdaddr_t *adapter_bdaddr); +int bt_bass_send(struct bt_bass *bass, + struct bt_bass_bcast_audio_scan_cp_hdr *hdr, + struct iovec *params); From patchwork Mon Aug 5 12:04:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 13753556 Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11011011.outbound.protection.outlook.com [52.101.65.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 690AA156F37 for ; Mon, 5 Aug 2024 12:04:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.65.11 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722859486; cv=fail; b=jVL+llIwInbC9mNdcB4vX4hxLbKvIcFCUGKpZBQOgeks+SO97DExaghgBd7r+Y0nWgJUOnXgnBqwqLxf8N1VM95VehBAjppfug24KqAvdauQrLgJeuShdp5HNsPNwX7bO1JyGi/o6SetZe+zElSm21HilQj57vabablwyXXVATY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722859486; c=relaxed/simple; bh=TnAeWgDBmNzggLQvmiET41tVW25Dfronvkn2/sdGRog=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=lPX3W6pugrtdJyvjYctcURagVAbUbweuTsHZLPlEZQzQvZD4+gxhOlwI+LKrTd/zHNCICII8Zmh78TRtEaODluUb45nWwfumZprLZEbLexszhjW5c0HZZ7vuIdQ1M25N1rnjAcC8JQBLdqdi1F8REwSrPb8HtQNp/zfuUTqPmsw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=WBwWBaHp; arc=fail smtp.client-ip=52.101.65.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="WBwWBaHp" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=DIyW43NIfJSKrtQNNo3y1jGzpt27IqXYWmykS6EHca3NM9qBg+MWO7b9lvAoh3HSSA0Ud33TAdE1vGhmDCA3eeTZH8uOGXLJUIzLeRTkGF1P3HtKddzrlamVR+OcybXxhZPwS854uV8QqsoOSNqvlZGqq9vhsCkNXIHJMTRws0oqROoLyjwOHJ6U/71nh2W0voWm4Zge9I44etApqvhSS84HIyfCG+68BJe63Jc0E05Gbngq0O9Anaenxo9hC2u7dmPu6cQqLAMoeyCAX2AzXnch0wtTeamPd4FTeMxm+qhr0DEzStL++4njnmZwmlPHhArtyGf14vS/w6eFNlCXhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=CPxi3BWbCSoTNTrb5HY2wFmx/1sJ2a1EVXyQS2VPzoE=; b=KOMYPC1FP3oKN7RrrMmPBE2S7lS7wISKRyrDxuD0/SJMS0TTnFEoeXBhEbSzB7WvzkqapQ91vUfv1MtCVyXj2/mlOFx7qelaSgW0GRNTZk7yyEP4Nw7b+no2ZoGgAMbtWtTgj2SETwzFK0Z1PO2C5UrB9ypKufvvJKnmR5JgYw22Y1xP4CSYRt+IVyyCqFvZtdSKZjI6q/JGlI6EWOvp1f4ml2xTg8RcAOs1P+1F6TZjwjIMmARIk4DSj4kyjlVrz0fTlr5EC4jvAWv48hnotMxZv53mPB4+oM6sNh49u3aCuK3DPx4dHFgPJuOh0taS+KjdfPmU1nh1VclqgCe9OQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CPxi3BWbCSoTNTrb5HY2wFmx/1sJ2a1EVXyQS2VPzoE=; b=WBwWBaHpypUOdHjpR3fySdE/Jr7AclO6jhIjYww16eiMMjVte6TStQ+y0YABhTKfBtSFckFIlPnIhzUl+gHjEFLk4UPdtY7zyGqhAKYzimKj3QJrHYCGO2ndWa2brQOcuCwRNpjHSexlgpKIPnDik8asc2jKr/4LCOKNyulriGpgZ9+LUYY3UF5CNyoR8GwMqsKHGLtCsRleVIgqQyrB6+87r6UYQ1tMxxGqj9b5hwLp9JJ8kNYIsQ0TbLMgrou2VqhYaZqeS/ccFGhfKcA40MagoWn1pUQBKcp8BErltOk2uFegMpIYFjqj+OyauYTYEX9u46GpMl3OR6SzCVOnow== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) by DU4PR04MB10499.eurprd04.prod.outlook.com (2603:10a6:10:568::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.26; Mon, 5 Aug 2024 12:04:41 +0000 Received: from AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654]) by AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654%5]) with mapi id 15.20.7828.023; Mon, 5 Aug 2024 12:04:40 +0000 From: Iulia Tanasescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, vlad.pruteanu@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Iulia Tanasescu Subject: [PATCH BlueZ 2/7] device: Add support to iterate through service data Date: Mon, 5 Aug 2024 15:04:24 +0300 Message-Id: <20240805120429.67606-3-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240805120429.67606-1-iulia.tanasescu@nxp.com> References: <20240805120429.67606-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AS4P195CA0023.EURP195.PROD.OUTLOOK.COM (2603:10a6:20b:5d6::14) To AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8898:EE_|DU4PR04MB10499:EE_ X-MS-Office365-Filtering-Correlation-Id: 45c18427-a4d7-45a4-9447-08dcb546c936 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014; X-Microsoft-Antispam-Message-Info: MKF1y5bx3WayHwdhdpKseHO9CvNonge7Nl0i6y7ryhmbtPpqtJboxc7R/jXgqSXQNOdY9/XeQ49xxtFXxjtpIOJbo/bnCphsjKg8rDiShY+Dr9K09wFnliFctU2vtPMsdo61XCGQbU2Pa2Pd6NpAnWE0MjRBFR1Hwxk+LjKK5VGTIe9ySdG9ZGgwZOd8eq+2wRaoBiZamwYXzs8B9AzrrvQ0i+c/9mWhIo1LyQXl8zAi73sgxBMXnWvlY8qTyD8bt1O2nohWAqw6AZwg9Hq5/cFBP9iBF8js2syU5KQjBhGbwnOM3qUR57C/JmTPSx1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.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS8PR04MB8898.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: kUrqQharIPZJq/rzuO4rMxIRdXTsifHqQz9K9SjuF8bJ+rUnVt4Zsa+SDtZj2PwKhztznX7dYtmP/3ubpXjQy7VIgTlJWBI7De4hP9phExF10CglY9br3YOoBVofLvFkrRcrfNCAUmlNJZ+lQtf+66RRNbMonoqxQ4WF1/Jfu7n3pvvk/8Uo9BgM3AIyI+4E+OYOxtrcZ3rZg9ZWNl1SrK4g/ouu1oYWcAylVxzMyJ9Quhbw2nTPgH6S+OreyTuXEZluJXhuBqQpFIaTmB9XXTMcxVn2viritfOqii2UmuOQwsFFlGOOdBRmanezYHS06SEY2XSdvlDKCmjyNHXizT15Y9kA28WtLjHrIAm+y56iKQBNBhI3PGxYTSIJcAxKVlrMRqQ//NNNRX5nnhYJU7bt0ixwnXlDT/ShwGueYaJY7uuOSFRcYr6dHV/Z7LRLaIzOMJUsySxtIJ+hxZpJTk20+t7xBeA4zfG311l+ldfB48bSDjieIaACj5B8bHDM5rX7cf7zh+g9J8YDE2JTNXV13KYts5tSvemAQ7tDO3CVKBKOXG5+9O106nbAPMja/4yrzBfaOA/KU67T/gAfst2KDvODPeGjNBjc0YR/YhYOcA6/PI9r4ckkvACcseAVtnfEx4Aur9cQUlLkFo6u54vxBrrVcvd+rTyBuOsdYkxssMBOfnxiB0VKEXkkjpi+cQJMvn5PNfAtGzihqlQQBzba2X16uUSmbU9f7nmFAqXaX/vrS4+CnrzAtqnULw2D+77UQE7ZAX35tR3HBuTleN+LxDeJbps4MFwRBuZOEaXv+7/1Gg1/rRNcQZ2EakE80BaVs7OQNAUbeNYXwS2ITJCUnGMAhunnK6sqCIHGo46O5ROmkUuVVGESGH/7GZjsf+yKmS94/LnoBO936/uGSd+a8d9WapC9/3HILtkVypKYQFqMyKZrhkISsG4phtHHhy3ypMEH61jt/oP5u3CqITp43cTDwsMTpjyr7O2Kff1d9rqbxxOVQYSiN+boeemjaar6bTD9Pw1KRgr1V1HZIvE8S+MWZiLlnpQ1RSUPA5FQTOzaQOPNZN9Di25zubyl8O/6FxXlhC1TUeVudmYKji6nz7PNtgtZ8WkrzR2pNvHS5xKpFgQpNS555fRUioANslilt8DG36D/BjtKcofGfRJ4j9z48JOuac5a8QTQ6r+zN/OYnWH+q0LxV75eBOq0z0C2sNUyBI+A31/FDHf96FWmp6LUrAGOwWXbcyXyIlKvaxreBO7pBmlsueTraYOIkji/c7UcKTQch5R/za/SdRr1RzXg1JwXi9An3Pwy2KtA4bvml4m7GCztPKcYDcieMOVx3GdcC1ASOC5cBxlRpAXvPf4oBUdnqS4p1eF8h28UQy7wnXw00H9xp0lBQPwRI6THxfTl+krI2xLUrg6W3FYi2Yr1hr27WrbpVJ3nbCizABQICNTjGHJwsLPhXfJpW6gxZsp8o2l89oVMvECQppzMrUhUtm5C+aFUWGJgwmDzS060BMIY6T2nHdc25Z6M/vKfvhaCLCU1vQ85q/NcSpO44DYtpgB7VKd1jGHUWWsKTogMKQFSamOaulMYvykUMGBpWMsfAjY3pWZsvvDdhQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 45c18427-a4d7-45a4-9447-08dcb546c936 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Aug 2024 12:04:40.8775 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: cWXKjJjB2oM/+DNkltYphVhaICkLDtCyEJw92cCQ7QwT3611ptB15Bc9S6oSzPPBTAbqiPXaLYT2O2ZZgXbOhQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU4PR04MB10499 Some usecases require iterating through the service data structures advertised by a scanned device - for example, a Broadcast Source advertises the Broadcast Audio Announcement Service UUID, with the Broadcast ID as service data. The Broadcast ID is used by audio profiles to uniquely identify the Broadcast Source. This adds an API to iterate through the service data advertised by a device. --- src/device.c | 8 +++++++- src/device.h | 5 ++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/device.c b/src/device.c index a1dc0750c..cf7264051 100644 --- a/src/device.c +++ b/src/device.c @@ -5,7 +5,7 @@ * * Copyright (C) 2006-2010 Nokia Corporation * Copyright (C) 2004-2010 Marcel Holtmann - * + * Copyright 2024 NXP * */ @@ -7374,3 +7374,9 @@ void btd_device_set_conn_param(struct btd_device *device, uint16_t min_interval, max_interval, latency, timeout); } + +void btd_device_foreach_service_data(struct btd_device *dev, bt_ad_func_t func, + void *data) +{ + bt_ad_foreach_service_data(dev->ad, func, data); +} diff --git a/src/device.h b/src/device.h index 3742f6028..97536774e 100644 --- a/src/device.h +++ b/src/device.h @@ -5,7 +5,7 @@ * * Copyright (C) 2006-2010 Nokia Corporation * Copyright (C) 2004-2010 Marcel Holtmann - * + * Copyright 2024 NXP * */ @@ -211,3 +211,6 @@ void btd_device_foreach_ad(struct btd_device *dev, bt_device_ad_func_t func, void btd_device_set_conn_param(struct btd_device *device, uint16_t min_interval, uint16_t max_interval, uint16_t latency, uint16_t timeout); +void btd_device_foreach_service_data(struct btd_device *dev, + bt_device_ad_func_t func, + void *data); From patchwork Mon Aug 5 12:04:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 13753557 Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11011011.outbound.protection.outlook.com [52.101.65.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8BD3F155747 for ; Mon, 5 Aug 2024 12:04:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.65.11 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722859488; cv=fail; b=pYb1PRVR/LTgasAJtdouhafikvfE8jElIRjEDz/AWx0Ch2oS1kDH5fe+VeqrJjsmmEzlJSWCrWcq6/YOJd+NT/YBx0ylnfakhM7IRtYL/1pxL6IA+/6QxLEdQFzgEWVxJ5dt355D8g+Chi9Mijlfauvc85YWUPUIdqc7gWxBDGI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722859488; c=relaxed/simple; bh=u/DVDsUI2PhuBLsnQK8cISHem/kIW3LZyerUZkvlVc0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=N3DViilci6TMJEucbFV9OH40LKTdoykCKrK5SFbmK1ZfpHUpfc0j3oFaVuj1hR1U4L2YT/regeU+sxjIHUFwZaFiIU7YDQ1yZvYd1mAZ8qlqxCes3LYBXiQFDsoXTaGdQasVj7YpAgY4XnmK6Fbxw5078oYblzM7yUDrym/w4kA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=IfEM2g2Q; arc=fail smtp.client-ip=52.101.65.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="IfEM2g2Q" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=a0d4ezCtbn4TFvCtS47EClO/f6Y6m1kXBjGNtBXmsYhb6b4xeL976dRtvJurdNXt8pX50qmxwRNnKIlHwCdyg8gHaoKPI4YxVp+ITWqWFAE4Lu2qnFkqDKGYrmxoUgk4VaqgAqUQcZu7icXNJOH9RoODiirlVta4lW/5TmXoVx26ZaanXWLPTPKrRvYQQYjGsCD/ZyvxE5cbtINXsHo+udRzTa91UgzECXKm7R4NxwpVngh1Bb0zH11MP136Rnn+0Nlq5FIydx9TuApscHJL4W8XVz+PI6rVyhMRfstJNBC5iOQNaeX4EQDD6MfAwJqUkJtAQqY4wnErStleQRCjUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=brBeZVYskFsi/K8ynm0D3tXWGxunNLJsYcaI2D+p9vc=; b=pS+A5HKUNE0JUfqi3yesUioSEA7FHufac1vFq5d5E+9IM2QGV9fW71yjsXBSMOrJMx9AxV8qolxBZ6E1CvsJpM6fDpSHpsDaeVyi9LfBXks9M/PWOhk3GbI5kQyAY7jmwk7uoPzqjehs6pJDiX+mJrAhVXEsGNidAVjJoaLXm5Y3fwUeRp/LXgGzbwcTAyVzoXiuTSUESRf0aKPcK9C6vyJNxD2Ev5nIbrWmm9MwbVRDxEFPS14LEWBNxlIUB8Z+JMAiYFdypvlilgBUjir8xc0TerP4hvvYL+pbI3IvCzbV9Ox7DeQgGKOSSzAwTkl87cXfxnwF29Zy9R8hhtfYZA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=brBeZVYskFsi/K8ynm0D3tXWGxunNLJsYcaI2D+p9vc=; b=IfEM2g2Q9TLDxNRAKneknMhsmQwBN4VKK7P/w+Vg4oZ6jH2BGq3ajDa74zNkvZjakpZFVQoU9dDwHBuF9VKUccEbEJ6URYek4Q+qFVJ3xlm6N7BVlgnRi6LNsf8Nz5nZ4EMLxuyQsq8kW2r32HP2dl6WFiPlUB2X5xKr37I5TP58M3qXj8v2o+NqJfocdfz4+RdJ/8/Xj6alQgZwLXmz+88EiBowAUM3PQ6PZf3BQc0r6wx0D3fy9cdbIiFb+0BHOOfVaDx3npeTYxiEVvPjx8F6hF1xB39rqZ3e9j2ARy1/AjMePUWud+BGuh8HyO3rBNDxS98G6hQPPzv3Pkq7Ww== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) by DU4PR04MB10499.eurprd04.prod.outlook.com (2603:10a6:10:568::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.26; Mon, 5 Aug 2024 12:04:43 +0000 Received: from AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654]) by AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654%5]) with mapi id 15.20.7828.023; Mon, 5 Aug 2024 12:04:43 +0000 From: Iulia Tanasescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, vlad.pruteanu@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Iulia Tanasescu Subject: [PATCH BlueZ 3/7] bass: Store Broadcast ID inside assistant struct Date: Mon, 5 Aug 2024 15:04:25 +0300 Message-Id: <20240805120429.67606-4-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240805120429.67606-1-iulia.tanasescu@nxp.com> References: <20240805120429.67606-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AS4P190CA0043.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:5d1::14) To AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8898:EE_|DU4PR04MB10499:EE_ X-MS-Office365-Filtering-Correlation-Id: 2d56a3b3-9997-49f3-fb65-08dcb546cac7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014; X-Microsoft-Antispam-Message-Info: Q0ykqxTYTpJNOtmdHQHJgfoZV+nqXQ5Xug7vJyK6HFDMOBCS2cw1vTNBqR8/wcQeimoTWzJ/v5e6WhYMYCl51CCwQsQzP/IDyq6a10W1kKlf/4DNJ/8LM6Dl6XrWT60JqzSeT78tVD7EvYNAKEPWVs4zRDz1AzH1uaVkri+OF0liYsd+H9UcC1kldO07/rp6f8bGE1prAf6ePmER0+sYH/Y6rt2s5CwfiU5LvuYwY5TTf8iO0bwepK8MUFvlmYHygTk0YhM0cQ3FQ07wIUy3uwZEHt5Y4CjIH9DgFYc+tHJTvZfli95j0ncxf9tbWA2C4kl8UWRP5zp//B16x5XnIVakXXdorpEvQfO5Sv84i1M9UTWeqcgC3+7h+klBlt8VN37X7q3bE56jr4Q36Vx2gKBapEwqwI7DsJ96LzV7SDfR5/BZ48GacNMMLQZHUn452nY2r4fwRONBjfyd0bA4SO0/Qr2xfb39Hwj3kpTbP8CySLExgL6ZyqwcnVorH0oR+/xwMxcttJ8DnxgwbB2CKqlG5X/fabwvlYsjd4O8VJNVoAiC35u0dMAZOc7M3L4Op2RouNIO7o8hBnUW2S7jDW3DyUtMF/W+b2+zvyk3XNI+CnI1MRekNz7NB3gARX7ugxEXe61mNz5ROLr+dvo+Q7AApO7lGD53mw4qyBaTYJBrtHfEP5IBtuXM5TOINRBnKpRCviDupNww/D0f6BJJxXkmwrzKnnq8VgkcajLUMkhfuLX9SH+fkBv173IQL4gN3vC75F3oE0PWLbFvcWjhiRN4I0gB+GOD//3G1FkwXTHRFkHjtCJm2l1b01QxIhT6Ms8bJNAP8GpfKZhzZDVEa7FNIxxakPyETxBpqEgN2z+mhHOmU+K5oEz7RLT0NQwQaZHmrsbDQGnsBlCmQUmpEEtOmVqW2ygfxdGM1/jhh49Ywvs4wKhXcGEEDSrUPg8vP5Ptmyo8mT5RlbrqCfOgUrJ+SKMMKS41Z6GcEvbhoY7g0mXenKIYu/v/91gkzrrSoD/noP04aAhcejBizUD19F76VFJNNuwUEuOeKjXQmTrqln8d5vv2UHnm2GhpgiNGGvfZKCO/uaCMGp9LUOVdYZjckW9pejmBiMsPO3Qk+pf8BKE+7v39Mqx0Gobrp72FMTiNv772Z/OVYHWLB5MBAEkmSCuHVgVrl8zvO5JswCj8ofbSfzkG9c6qLgAza3uu+b7nBY8Qm2bTHAlBdWdQd07tTdBUeZmPAuHlMZVtJFNh374e/bZs+t8r0JNivHz+3mUaiORctLv6fDef3ZAn8iQ3gZd6iKFBcst9oPRbdObfP+iaTBzQ7EqBYoAvShp87AsiHGaa1+L4c0Kyua3wBw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS8PR04MB8898.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +urYs0Oi18TGVH/ZiEXuQshE0iOwBhUYnjrJ3Wvsc4/UvjKhjBdn/D7mf4yh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Y98cxA9Xkq2WULJueb+c25bGshH6Pjnk10jMsAXN1CJObNeglpmrIHgMfQuiGAD8K4rpq3ztYD4vIvZRsm+Kus4hJ4UtWteSK3uR9+99nUSx7rkK+hiFhnTLxHTpV3TN5jqkTByPo3AAK78vJFQ/7/QqmjjV5arpS88Ra6A1Ts7H2uJCoJpbtF0gyRtKkIOaE28oCriOrxTiRx9KAYxCGVqmCrm2CJdzZn5bvaAAojXz2I2bBenGbSy/pI/mi+kqJVEarqs15Gp3JqCJQpdS7I1MPpabDgXRoA06N5skdHmgkjPnsAjgNNMfJ/TFgrOy4GgC44BZf9NFW1pX6NtmtB4Oe6POdiOvRavzwTFsmXlw68wH9OOKd5UhlHxWaYRgJz6w/dwavvOFfaEwKQuMDFUA3b0GPyCQguZXKl8Lpp8IGN05pNXsoeZcQNiJK98Yh/mYSTM0cG8GTZB6EyxlW0S4+gOqX0tpcLwOw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2d56a3b3-9997-49f3-fb65-08dcb546cac7 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Aug 2024 12:04:43.5476 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: HQI0HfrT0t0SoCMPTTQ6hZtXx2e7R42LMD9+2SRbN9/G2KrO51D8Jdo9xJ9Be7X12zjBa/sw23PQB08amvKUhg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU4PR04MB10499 A Broadcast Source is uniquely identified by its Broadcast ID, which is being advertised in the Extended Advertising Data. After discovering a Broadcast Source, a BAP Broadcast Assistant needs to internally store the Broadcast ID, which will be transmitted to the peer Scan Delegator via the BASS "Add Source" operation. --- profiles/audio/bass.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/profiles/audio/bass.c b/profiles/audio/bass.c index 083988358..795b4b80a 100644 --- a/profiles/audio/bass.c +++ b/profiles/audio/bass.c @@ -3,7 +3,7 @@ * * BlueZ - Bluetooth protocol stack for Linux * - * Copyright 2023 NXP + * Copyright 2023-2024 NXP * */ @@ -40,6 +40,7 @@ #include "src/adapter.h" #include "src/shared/bass.h" #include "src/shared/bap.h" +#include "src/shared/ad.h" #include "src/plugin.h" #include "src/gatt-database.h" @@ -80,6 +81,7 @@ struct bass_assistant { struct bass_data *data; /* BASS session with peer device */ uint8_t sgrp; uint8_t bis; + uint32_t bid; struct bt_iso_qos qos; struct iovec *meta; struct iovec *caps; @@ -198,6 +200,21 @@ static void assistant_free(void *data) free(assistant); } +static void src_ad_search_bid(void *data, void *user_data) +{ + struct bt_ad_service_data *sd = data; + struct bass_assistant *assistant = user_data; + struct iovec iov; + + if (sd->uuid.type != BT_UUID16 || sd->uuid.value.u16 != BCAA_SERVICE) + return; + + iov.iov_base = sd->data; + iov.iov_len = sd->len; + + util_iov_pull_le24(&iov, &assistant->bid); +} + static struct bass_assistant *assistant_new(struct btd_adapter *adapter, struct btd_device *device, struct bass_data *data, uint8_t sgrp, uint8_t bis, struct bt_iso_qos *qos, @@ -221,6 +238,9 @@ static struct bass_assistant *assistant_new(struct btd_adapter *adapter, assistant->meta = util_iov_dup(meta, 1); assistant->caps = util_iov_dup(caps, 1); + btd_device_foreach_service_data(assistant->device, src_ad_search_bid, + assistant); + ba2str(device_get_address(device), src_addr); ba2str(device_get_address(data->device), dev_addr); From patchwork Mon Aug 5 12:04:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 13753558 Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11011011.outbound.protection.outlook.com [52.101.65.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C885A156F41 for ; Mon, 5 Aug 2024 12:04:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.65.11 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722859490; cv=fail; b=WSbBDeTgg7wCNqWS47VNYa++QERTw8jjayDsxOUKhu0PWrVyfCD7wELr77yLgBW07IfGLQqZjPvVEkNtLIfL8wXbeXZk44j4fuyaGhXzlWgzRMalrhh2VPaFjPFl9aX0reTfXHGd/5ibkduPyex10iHmBkJE0dZ5e0g0xdSligE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722859490; c=relaxed/simple; bh=xfcJrAwt+06PNZqjD3RQnimQ9UwdR7Z5qJLwUEcUGyI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=elIg552xCvJp3cBO2/OlppjK/I6gQCiiEhSr1RfjEcRVlY4+LLcNW2U+NNlAi/SypVcc8oyvo8bS6oyXof5Fwi1HQlv8MDN7otP46NP9OowxUk17kvO/D1Vh61PHjHK7UQVOvVm080YbWKacNLkSve0+YsFboU3QI4cndH0M454= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=ic7YCTXy; arc=fail smtp.client-ip=52.101.65.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="ic7YCTXy" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=mRxVhlczBa2Wrgl+t7nvzeUCSIOC30JXd3L7rs+6jHLQsQHeB/3P+zGbT3m8vFQf+7kJx45JcuQFGFVjOdY0IPfJa7rulne573j6CKkrS9GHn/Xg+QkV0iF/lqCXomOPzXvHURAtgrwcj1ATBlgUphtYQspaHlKAX2FcIvd+AuS24coRVxW606FPXJaj6yxaGDA0D4/i5WewpE5DuKfkkvLs7S/vBWIpQGGUoHfgdeTWvBqan1N7aPdrrQXwuWwMX29LOE4IJ1zXdIOIjnNxPCPxOL7Jd7NoepBP70KnjsS9O1I/sb/ce1506sHxGBK2a5U6pjMKxCQeM3EfAwcUNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=n7hvhC227PZ8nEM98BLq7s6OpzOOErPdsk2RTW1HKWs=; b=g2E5eppjOmFPEwYcPnq0zxVEX/xtwfSaqFmnlYj3TZY58mvPZlpwd2Fi/N0/YIVfqU5/49Vh1BAg7P6I+PfrHZtr9zIXDDMF2+8d98yIajxqSUABaViDlAwUmmNtJtZDxyV3DCiQkRh7FVJX0i1uRa6cyLRnxzl+/+zXWEleK4zWjvtx9TsKTYCBtc37n2iQGtiYZNTI7ah/qUYNemFUQz8PDWYwBwPVpVnZH9h4IK26yliiKzGJYObGdIZ20NbkUuNrnIWEsjMZgkh0NuYDdztQqay5h7H8kHbzxBhgj77bSSb0SarTBimlBZJFvUjA3EWJrTiccGvOvTtqFMSHHQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=n7hvhC227PZ8nEM98BLq7s6OpzOOErPdsk2RTW1HKWs=; b=ic7YCTXyPXSJoRFP0WzZsaH6SGOWWurGSHjfMpNhasx8LOCUZxhtnkjQ+aEWF5UuiCFcp5egmR7yyMUcwIV1XK72Q+QKv5N4ADqMIhHsV46Pfb3/p7YC3Jd2R+fF8A+JJIWsQafkE10S+Nmue+/xwsA1v3IqZC6m+ob5Gk6t6rUxA2Up3GkW09TWj9o4gaWms0qcNNr8BBdzex3c3Ih9zqXdwnoWAiZLxmCORdzqkUlFDJJe+AJKXbSF0rveTisjGJvVQ5OBpQ1T0s1nc/3JGN4qOl89qeh/APMHbCdKOn28dF+JuUVxOh5Kr2Ht3+xfxVBlXnkZvOfFIOKzVJNnRg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) by DU4PR04MB10499.eurprd04.prod.outlook.com (2603:10a6:10:568::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.26; Mon, 5 Aug 2024 12:04:46 +0000 Received: from AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654]) by AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654%5]) with mapi id 15.20.7828.023; Mon, 5 Aug 2024 12:04:46 +0000 From: Iulia Tanasescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, vlad.pruteanu@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Iulia Tanasescu Subject: [PATCH BlueZ 4/7] shared/bass: Add APIs to register bcast src changed cb Date: Mon, 5 Aug 2024 15:04:26 +0300 Message-Id: <20240805120429.67606-5-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240805120429.67606-1-iulia.tanasescu@nxp.com> References: <20240805120429.67606-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AS4P195CA0030.EURP195.PROD.OUTLOOK.COM (2603:10a6:20b:5d6::17) To AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8898:EE_|DU4PR04MB10499:EE_ X-MS-Office365-Filtering-Correlation-Id: 41663558-256a-4097-89f1-08dcb546cc3b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014; X-Microsoft-Antispam-Message-Info: +y2bsoExxWc65/GGJEJR/ePFifIcLMhvnED6fnzzxZ4qROZCMv6J1FomvbJnotQvzSj/RHZm9HGBivEjPD3Lq32scI+z3eIrVRq2bU9XDU133SdC3uqhOrZx806O/ICJK2enPxbkvPysI32oUQeDyETc1stdMFNxNpNyuxs9fi62YlqvUAfqn4CQ5XIn9baVA3E6OIfz8iTGHKLJ1DS2aqy8cNK6wuxjph9xzGsklQW8bfLd30u+CfgscWw3Eq7gn7xunb8DHpd1tD1SCJVtjWvd4whF+d7WMVi2z3yLTJT5FcH0Iju3UCM10i9i3xo11AstekhF0gW3U/hB1jK0W4Hxkfuhk0SjrpotimAg2NqZmd4OtDzttq4pc75J4VELiacinnuyzw28OsWRadHa0gKU5o5Ned8gQpB4WiYteG7wb3FcmElR89U0JXCGVE8T2hrqfqvi+CYk0Uk9YKK1ekrRx6qykkmpZ7dBKwOTivWF3Jug4fT1FWfNstttmn4fmxd3Nwe3OlgTuP4mfgFXigqm0PJIviWZJzfrhCHKwd9HazaSQ1QHtemTluRBVhT9N6egFpWBLSIuk1aw10J1tlEEHGzDCTli2AfP2sOb1vuXicuuZZBHKAqDcVapgR3SU79Cx6grWKWggA4oETvEN8vOf5Gy4fCh0YcjD3w/w2JbaVaytWUaYUT2RM9vUequb/uf9clWHcFk5SS2bTEXJnhl+KwQaVuY9Tj+A/IsXvL2c51A6M85S1WiI+NqvzqpMxvoUlxgKqDvcNpNbz9XhQ6oSPpn9RfFxrPjUlm25iWD7tpxQqd+bwAuI9kqx3Y9qCEl4G+d0Taavev1myHFP1eAJYTN/YK+tnZcz0WrIB4P7j+qs0qVzH+XFDu5eoBB5N9yzqd3uuA1oNsAHle6t8Q9D6TSpbp0hFw0FE/T2KCYrSG2pBStkNXqZrA7rBvIUx6AEv7OTXNel4OfpKZEzqrI1ffCZ7HIMnfiU0HJv4EAYyYQVhyE8uvoyZiMmyJLJHjS8Ibgc7KazEZk6wDMZyPx65R1CobGwqdHViQrhXOV1UHnsqoCTU/Ja1sR26ALY0jutI19jQ77m3XgZNsTO33kYHKtBhiCOIL87MqpWutOFo8nvUK5G9KYk5flpadPCbn5hu8sAYKpEMVmF++57ofd+Sa+E6fHm75Vnkkdpu4ID0T2GIukG1VeBZ8Due4GJSZ7plckhN+bYvHSf4QgK01+MOWzCS1BTRShmuoZVlED5URkG20Lps6ZB4rKuxFBEGO0zBP/qqiQLNEb+Ev0n+xjT1VU69w4aEwR3FyF3seebdpfPdbAoFDEM8RzFc5T4VqFVzkEuql48CfLnbEtXA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS8PR04MB8898.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: JTKpy0J/fTJZk6nKqApDbQ207XLivQeVsSL8/UXBJrmbt39h1L9l7S8xbo/yBKmGuSTF9DHzxSCsE00u5ODly1ZCqI3LxuI4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b+okWBQZlTWntYNSfoESxD/XbQZq+4KQ7VnFU+Qx9nQ2GATV72s2CC9cP/URUW0/AjuVJNv+kFcs3KYbJ1IMgiWOhDY61EEMDVexlP//JNy00LNG07rde7v5hFacHgE/pArWBSRtyfEDYBYO2xDMsab9FGTNXOe6siyY9NZNvqLBSF/63A4eV4aQI6U0Wz9DfioHz9I3iFipg+elS0GjzlWbRgyA4M5gZadyF6ovn2jNLx+DfS7Bdg6v937RrmiCN1OyiKgKeQ8MxGuOlzwvdyRN4eoEsLrurqzFkb84IRlke3nkAyaExmObsi6FVV/e6qSxo7y62i8VyWs0JI6OQQdUA08SKbafo8mqNb0Xavr3OKnJ+jhNZeMIpErNn/DE8hS18wG36P/otGdv9F+118ACrzSDt4I6yyZCi7kOrC5ti5ie3GtW419t5g== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 41663558-256a-4097-89f1-08dcb546cc3b X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Aug 2024 12:04:45.9824 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: TcWdGHiw0scz+LaxKSqpNMX/inygAmR3gaqR9LrCTR8T4WfbKTxc20dp2YW2/HCt+R1AsdGv9Xb7BkGzCBnrTQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU4PR04MB10499 A BAP Broadcast Assistant (BASS Client) needs to listen for GATT notifications for Broadcast Receive State characteristics from peer Scan Delegators (BASS Servers), in order to learn about updates in Broadcasters known by the peer - for example, the Assistant can be informed if the peer requires a Broadcast Code to decrypt an encrypted stream. This adds APIs that the BASS plugin can use to register/unregister callbacks to be called on each received notification. --- src/shared/bass.c | 95 +++++++++++++++++++++++++++++++++++++++++++++++ src/shared/bass.h | 5 +++ 2 files changed, 100 insertions(+) diff --git a/src/shared/bass.c b/src/shared/bass.c index d9ab210b7..b54bf3094 100644 --- a/src/shared/bass.c +++ b/src/shared/bass.c @@ -71,6 +71,8 @@ struct bt_bass { bt_bass_destroy_func_t debug_destroy; void *debug_data; + struct queue *src_cbs; + void *user_data; }; @@ -118,6 +120,13 @@ static struct bt_iso_qos default_qos = { } }; +struct bt_bass_src_changed { + unsigned int id; + bt_bass_src_func_t cb; + bt_bass_destroy_func_t destroy; + void *data; +}; + static void bass_bcast_src_free(void *data); static void bass_debug(struct bt_bass *bass, const char *format, ...) @@ -132,6 +141,64 @@ static void bass_debug(struct bt_bass *bass, const char *format, ...) va_end(ap); } +unsigned int bt_bass_src_register(struct bt_bass *bass, bt_bass_src_func_t cb, + void *user_data, bt_bass_destroy_func_t destroy) +{ + struct bt_bass_src_changed *changed; + static unsigned int id; + + if (!bass) + return 0; + + changed = new0(struct bt_bass_src_changed, 1); + if (!changed) + return 0; + + changed->id = ++id ? id : ++id; + changed->cb = cb; + changed->destroy = destroy; + changed->data = user_data; + + queue_push_tail(bass->src_cbs, changed); + + return changed->id; +} + +static void bass_src_changed_free(void *data) +{ + struct bt_bass_src_changed *changed = data; + + if (changed->destroy) + changed->destroy(changed->data); + + free(changed); +} + +static bool match_src_changed_id(const void *data, const void *match_data) +{ + const struct bt_bass_src_changed *changed = data; + unsigned int id = PTR_TO_UINT(match_data); + + return (changed->id == id); +} + +bool bt_bass_src_unregister(struct bt_bass *bass, unsigned int id) +{ + struct bt_bass_src_changed *changed; + + if (!bass) + return false; + + changed = queue_remove_if(bass->src_cbs, match_src_changed_id, + UINT_TO_PTR(id)); + if (!changed) + return false; + + bass_src_changed_free(changed); + + return true; +} + static int bass_build_bcast_src(struct bt_bcast_src *bcast_src, const uint8_t *value, uint16_t length) { @@ -1321,6 +1388,27 @@ static void read_bcast_recv_state(bool success, uint8_t att_ecode, } } +static void notify_src_changed(void *data, void *user_data) +{ + struct bt_bass_src_changed *changed = data; + struct bt_bcast_src *bcast_src = user_data; + uint32_t bis_sync = 0; + + for (uint8_t i = 0; i < bcast_src->num_subgroups; i++) { + struct bt_bass_subgroup_data *sgrp = + &bcast_src->subgroup_data[i]; + + /* Create a bitmask of all BIS indices that the peer has + * synchronized with. + */ + bis_sync |= sgrp->bis_sync; + } + + if (changed->cb) + changed->cb(bcast_src->id, bcast_src->bid, bcast_src->enc, + bis_sync, changed->data); +} + static void bcast_recv_state_notify(struct bt_bass *bass, uint16_t value_handle, const uint8_t *value, uint16_t length, void *user_data) @@ -1353,6 +1441,11 @@ static void bcast_recv_state_notify(struct bt_bass *bass, uint16_t value_handle, if (new_src) queue_push_tail(bass->rdb->bcast_srcs, bcast_src); + + /* Notify the update in the Broadcast Receive State characteristic + * to all drivers that registered a callback. + */ + queue_foreach(bass->src_cbs, notify_src_changed, bcast_src); } static void bass_register(uint16_t att_ecode, void *user_data) @@ -1562,6 +1655,7 @@ static void bass_free(void *data) bt_bass_detach(bass); bass_db_free(bass->rdb); queue_destroy(bass->notify, NULL); + queue_destroy(bass->src_cbs, bass_src_changed_free); free(bass); } @@ -1656,6 +1750,7 @@ struct bt_bass *bt_bass_new(struct gatt_db *ldb, struct gatt_db *rdb, bass = new0(struct bt_bass, 1); bass->ldb = db; bass->notify = queue_new(); + bass->src_cbs = queue_new(); if (!rdb) goto done; diff --git a/src/shared/bass.h b/src/shared/bass.h index 864b01637..01c1279bb 100644 --- a/src/shared/bass.h +++ b/src/shared/bass.h @@ -119,6 +119,8 @@ struct bt_bass_remove_src_params { typedef void (*bt_bass_func_t)(struct bt_bass *bass, void *user_data); typedef void (*bt_bass_destroy_func_t)(void *user_data); typedef void (*bt_bass_debug_func_t)(const char *str, void *user_data); +typedef void (*bt_bass_src_func_t)(uint8_t id, uint32_t bid, uint8_t enc, + uint32_t bis_sync, void *user_data); struct bt_att *bt_bass_get_att(struct bt_bass *bass); struct bt_gatt_client *bt_bass_get_client(struct bt_bass *bass); @@ -138,3 +140,6 @@ void bt_bass_add_db(struct gatt_db *db, const bdaddr_t *adapter_bdaddr); int bt_bass_send(struct bt_bass *bass, struct bt_bass_bcast_audio_scan_cp_hdr *hdr, struct iovec *params); +unsigned int bt_bass_src_register(struct bt_bass *bass, bt_bass_src_func_t cb, + void *user_data, bt_bass_destroy_func_t destroy); +bool bt_bass_src_unregister(struct bt_bass *bass, unsigned int id); From patchwork Mon Aug 5 12:04:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 13753559 Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11011011.outbound.protection.outlook.com [52.101.65.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 096FB156993 for ; Mon, 5 Aug 2024 12:04:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.65.11 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722859492; cv=fail; b=eA5piUzFRjpOYN8u0X+IdZti3rpWxeEoNlXRWC36iYZ0lNwt5NI0COQL263nEwRBV1y62aIORyO4ZuADnzUh360I/yymuGS+bvXqGyh3y2iLHjUm19qg5hdY6FmTfH+53j5tC37h1+Y/fUASMDZHZRnIWM8yEO2EoOnSGg1ej6M= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722859492; c=relaxed/simple; bh=bADFmirTvQUC1e9/Wp2C5pijbT+KBU/vBsh8GbgEmMM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=tfBbPJFyGRUtleI8q0MGK1LEbXp1BcJlNOxVg0vrhHklGMhu0QbNkTnX1z/QNge139Jth6DQ5M8OC7emPgEn+h19DQYx21XCBIZTJ3fiCGFFiAg52vvtSb+NKU5jp6vS1ahsgYJNZuonqx+jWFUvPy08kdRt/l1rra6sq1oud24= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=c19rGHE1; arc=fail smtp.client-ip=52.101.65.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="c19rGHE1" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NZoHuixaS4bx6aOG7CGRjY3mXep4Wnpoi7/oaNeXEeRI5rilGCmihlcKCPsIGjU3m31km7mz4sVNeD7WxmhjblVtUOueZBn68OukOqrbkw/6dL4EW6vD//p7cFPSH9K2rBlV+drQ+5/DQPL9A+tenszdJlqWweK0GKKP/z28wG6u4WU0SEFP35h3fEWGQ69/h5o2nNOvcVs8gC0JhUxRV/UUXxrsOVNouJa7R/4FkfYUTh6lHwnrw3473aRGpBaxY5MLPVQOrezrQgNVUMIrfOY1oUzhNmj8uR8uWMARai5LLRBCvctbs4WnMv8tiplzLq+v2veBOejBvFWOFtIgWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=fXkn+mKQ0y4rSovFLAO/ar2FdpBuCZ3JPhI4t0NnA1s=; b=PK1oeFKnv7tic72DLMrfD+hR6OvsPXpHMfEbtLP01KqxjvQvlVloqI3iwjr8ZVG56ZbXjJO6KYbw5naiecccVHbh2+vz0E84CemzpTFyqoikbQ/YrNJhicrQ94Su31If00pONIG63LgwfYlu7rf9+ua4CJGYKzydNNJos8WIW6nIzarWJcmIgsC8AEWdC1vN1HFNcfFS9ySMz3GkTc+PYO+n0PxfDeivz31u0r7A01ItcmkOtTL38mKeLFpbRgOjoDBXoPvesk5wryS75zADtgpa9vghxbRjZJkjqLG3A0zA+8uTDuoyC6BNxCnz5mCcLl+XZMgQUA71kU+5v+zz4g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fXkn+mKQ0y4rSovFLAO/ar2FdpBuCZ3JPhI4t0NnA1s=; b=c19rGHE1s6x1llrmWMVFpxMKnoifk/DXJk1CIobGWeBcvVG0R1NTdslqCw8eN2LHp9+D9VvH4CVDM+uV/l5yREtlVGmstizij5l0rlRH558b/hDvD+noJWX3nQz1arTxUjSG+8umLrzZa/dZe+HU8jd736coX8MuFYob027aTcBgpjMe5z1cQgOwFzwmYIRh01WLZZ/y26fhPbOt+L2ISjX566+9QXndpw13wOB5SDcnOI/C0IoUfWrGyXR/SnvP289QdPLRjG0nStVI6q1affCwxJYUB073CC68RpybDJTJCrZsUJ6qvC4NP/CjjW8boIxdIBsQ475kSwlN4IBJTA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) by DU4PR04MB10499.eurprd04.prod.outlook.com (2603:10a6:10:568::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.26; Mon, 5 Aug 2024 12:04:49 +0000 Received: from AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654]) by AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654%5]) with mapi id 15.20.7828.023; Mon, 5 Aug 2024 12:04:49 +0000 From: Iulia Tanasescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, vlad.pruteanu@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Iulia Tanasescu Subject: [PATCH BlueZ 5/7] shared/bass: Add additional defines Date: Mon, 5 Aug 2024 15:04:27 +0300 Message-Id: <20240805120429.67606-6-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240805120429.67606-1-iulia.tanasescu@nxp.com> References: <20240805120429.67606-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AM8P189CA0025.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:218::30) To AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8898:EE_|DU4PR04MB10499:EE_ X-MS-Office365-Filtering-Correlation-Id: cda1a52a-d7d5-4691-ec55-08dcb546ce18 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014; X-Microsoft-Antispam-Message-Info: ZN96QiTyuiC/GRGXR70mBqOz84nl48ib11dkd9rxIDMObabF2mz+YORS1AG5QhbRsqJN+PVs8BNELZhDdoGdu+aLx1akkkV4UJAPdbcvPxNqBkRiW8FBD+6I1EgFzoIcFyTjzY3FlyMxFmi+DtX62zsyOP/kaFfDsoJWM/pQk/x8If8oZy1gOXXUIViyrZnej8xcgdQfo+F9Dqjko/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NaLp28uH3I0ZCXl0eA+VDFWYWc6/DC08tnYEUqZ069Od3KcC3cQHsCKuz7EKIhIQUKBzA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS8PR04MB8898.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mETvsvjy+fmcC8OlEoR3OcwsZcFUkYdFM9vMwWNN0q6KLnYW8RtRQUrX+fmarVwLwYS5tfQvr9Eb++Fpoc9bDeKAPBCwQ8g4om52A4fFF78uBgZRD/XGjTEyTeMIBAWDwpBebBmTV0GAHLm+tx8bMbwFCE8ENDODmDVodM6g8cGSXqOa47MZBN3HvdAaC4Quvun+BXlh1LKnbTNb/uXL6DbN0HlI13TjHxZbpZTNv0HfFIczJn1JJuiFDzITiLiMBFMONLszBkHJBnZYOs14Ib6vMQjFMjHWp6ktF3c/TNP7BDogi0QfM7FdJLXv/ZAtxvekEvUJIBH0GpUD8ZtVrOuQ2sYhrb0xjfqBSLpP4ZL7o+zINRTG3d5LWDzlbk9Ix5Eg3NGjDW/86/4VyKB4Cy1/Rqd3xy3/aYpKyN3hNs5f9whaNEV1QMOMGgTmNU03Jd0MNHrM2vvE/IVTyz1+exBdYWbpvotsKMJTgDFQVPpV92tYbq0yvqKxjj5H2jsDLDCxRAkL8nnsEwz9C3i0MpBfd6gkETp4h1Nz2ZdxtG15uI16J7Cd9bVXseo9g8OaNjbniByQPHJIchQ3+aSYcz03EMsNmTjnjgSQfOHyq1IiiH+2BF9MVugMOjc4W9R54lhEZ/Lis0AEkOqcGkk1eQiMMNP356IP0KiJuSFRiL5mLVM5b0X2rhojvN8qzRUASQiBg670gnb1UT71o7AxH2Zj7OajvTX1Ynzj4kTYnoEQyInBAu8sf+2F/6JGkAuDUhLwTcHEJDA+j4baHpbLNcqLYlKVHK+PJELBAU6NEefPqEBvLwoJgHZdTqxm4LOwutQEMhcQSzQNZNmybY9lT5qEAb8tFz0OADsWIKZDYza6b+Rx/5hUYRxTQ0+GgpGRQ2zMKwpTi1C8mqZ34ryMbbgKv4KrjrsOWkFNCCDggNA5wvOadn6kBrGLjUhPLukY92AZoBd8mI+EF16cuTd4Vg/cWLOo1+wMDT1qxbqOcAEmIGY/6HHlJHVM7rt6U4WNWDU76nz504MT3vGmtcBaIWYJIP4vhjNLRM3HWf0wTqs0I9qg4Hv/bLANV0MxRHa/UMa1xYlnFYl6VLHSF3ca1hnCM36/8RWwZdXPXXHo5Jg3BxUq4LAxVV1EN9AzvqRT8kYIL59K4ES9rOnCKec2ux2UDjCb9MCHB/QHgUsuPTJByXwevQX5GYjX1/05SNPm4Vk6OwZ+4NmIechACBZzwdcrTHJe8Gw5UtYhhlVSe9M1WYu/rzq54yj6UfeiLkieQ9zumSGTa+gJMjI1BIk9SrFMJzXcTqr7WFOKaKQ8y4NIHf1oDDRvB6wqrNV0fRqifVtfEWY6tNIpczPOC+mJpbycx2E4dB/D8w5ZJGpk51LAxCG3Q9FLQB8ng3l+H/PIICe5z9m6Sc7kHNRCv8c1lJc87pULXOWmJ5oG30/QaehdlKOzJnTmI2aZO+/bi+W99TVGnYPyDZ66bWg0J+BfPjkbkSvhhusNuK/7/f5fRwsYJ63MDIZHevNur+sv8zsuHv5woBg8wy6yrJgiyvOS0XE7XQz+u6XczVUHDWDCzCo1JNOjptpA+5NXEocteeKAq/e8RbMg8lorqlVwHeD1dA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: cda1a52a-d7d5-4691-ec55-08dcb546ce18 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Aug 2024 12:04:49.0597 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: obzu4MhfpCKP78w/SttiCxV7sv1EwOl8KSiKMnp+7YN4niFFxQNXs+dsJudR9omTWwMWrnwvXnyL123pD466QQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU4PR04MB10499 This adds BASS macros for Broadcast Source address types and for the unknown PA interval value. These values are to be used as parameters for the "Add Source" command. --- src/shared/bass.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/shared/bass.h b/src/shared/bass.h index 01c1279bb..878bab51a 100644 --- a/src/shared/bass.h +++ b/src/shared/bass.h @@ -74,6 +74,9 @@ struct bt_bass_bcast_audio_scan_cp_hdr { #define BT_BASS_ADD_SRC 0x02 +#define BT_BASS_ADDR_PUBLIC 0x00 +#define BT_BASS_ADDR_RANDOM 0x01 + /* PA_Sync values */ #define PA_SYNC_NO_SYNC 0x00 #define PA_SYNC_PAST 0x01 @@ -82,6 +85,8 @@ struct bt_bass_bcast_audio_scan_cp_hdr { /* BIS_Sync no preference bitmask */ #define BIS_SYNC_NO_PREF 0xFFFFFFFF +#define PA_INTERVAL_UNKNOWN 0xFFFF + struct bt_bass_add_src_params { uint8_t addr_type; bdaddr_t addr; From patchwork Mon Aug 5 12:04:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 13753560 Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11011011.outbound.protection.outlook.com [52.101.65.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 31DA1156F48 for ; Mon, 5 Aug 2024 12:04:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.65.11 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722859495; cv=fail; b=FP8LnfVHw8IiQOpt8h/3Goax3h5JTXEZH8t5nQOc1/Y2irQJTVDkujIV1cayYiiBBODkH6abnTds4nad4bsASAQ5sgWZOIWaBkM8r1hn8q6YqSO/JmEe0p/wl6TjCWpcHP5QdjL2f3nLYh4f9Zud6/fqiinQ02sVOcpCTUW3+bY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722859495; c=relaxed/simple; bh=j6gvTI+bJ7k28rh2d+w6H3NeCpw1RdhIy3vtUIiMYgk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=XZMdrN7FfS2jR+D5JWUSwbdsQlFhZY/Zf90G0eng4PdEZLNjLziOrIpVr4Wwo11HsYk2PIgQS+MG8rFTgRL1xVlVqAwgWNoAJwuG5hEl5fMVLDNSlo6oTZl59T9U8424eXlZ3aGk5XBE3SNI+ssvJ7fY+r4H9L3Acez1IGdwgYM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=TdyHKZfs; arc=fail smtp.client-ip=52.101.65.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="TdyHKZfs" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hVDrLpRKZhWyPOCt/6+vv4E/MOI86WCl9iQZkF1RY49tyQPPY8byzF9q0HhnRpIE7xMvNhYQuBb8UbIl5BZPptOSOAFqGiQOeQoDsmxFXMWcMXCCtL/t4PtUbKoNIs/TCm3/lg9uSK+h40opLcmfBcW59wAyAxwBWRzgp44T7L3K2nMZ8S2Z3li5RtzGTDPTL+QUuVzeWgcylG9o61+St2jks1GNAVN0lD+T2Qmjh/u0jlQzZMFlz4EWjlK0eXb8fbpFV8PLnBEzmeCbfWbo9BRJqOyE2B1xt3zJ1wIHaTnHTpzbpjXmBrLDrF9jF2volJhJBGaFqwQJwOUkpOQqXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Zrpot0YDEBBZnfYFkguLklbCwu1oOwLX8hRdLNVMRKk=; b=MYEztRpdyR+KRMcZUWKLa2/rax+mBlCWmZhn93DDW6/Ql9tz1eh2Xa6H+AiX+irLwv36xKidGaSUR5LDh9jDXMEPyHwqsvkGWtc3OvzHmtO5uLIpPUuXOYGSwVPGtuoZcXw10H9V6WIV0ijV/yeNAjh7gJ1D3vXI21egdNVPADjNPLxyiDkcbJe5+LXY2IfJFPw5FC3E+6flno8iUGinc/sderIh0JFs8xZGNAYvz6qBwN62h+kB3PalIVhLCMfjtRUu+/1T98sx91nlsG65hXATt+a7OMBp+aef9+0VI+EABm/fFXUF3SxPguSjbIbcsEmcSw3kxlM1rrdLdIDFvw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Zrpot0YDEBBZnfYFkguLklbCwu1oOwLX8hRdLNVMRKk=; b=TdyHKZfsltFWNh5nbl+6ZtxUlhYqRCZ71a5fq2cR2aQWovbNfAcWMEqHFa3nkijPZwNgtEHkxX+EIrHF9qSogLu07dTrjtqbQGlpD7UCHpanBRdUIKOqxhBVuPbnlEBiqnsYaQzxwOBBQw0OrJJEhikb2u7IVdzaXVkC8Q9TPlX5mn0NZBNRxghT70d97myaqwHCloYfeYnuic/PDokyBoAGOe2mGn6/y9llHFORcyOVvLKZLlW7DRP5VtABLEcdjq/As55CRcq7jbNpigeth9f4L1iRQxgMWlp0PKgk0SyCFtldBfaKQRmQY6wAHav4ECJkasGWkb9Xjdd3QWDb5w== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) by DU4PR04MB10499.eurprd04.prod.outlook.com (2603:10a6:10:568::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.26; Mon, 5 Aug 2024 12:04:51 +0000 Received: from AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654]) by AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654%5]) with mapi id 15.20.7828.023; Mon, 5 Aug 2024 12:04:51 +0000 From: Iulia Tanasescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, vlad.pruteanu@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Iulia Tanasescu Subject: [PATCH BlueZ 6/7] bass: Implement MediaAssistant Push method Date: Mon, 5 Aug 2024 15:04:28 +0300 Message-Id: <20240805120429.67606-7-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240805120429.67606-1-iulia.tanasescu@nxp.com> References: <20240805120429.67606-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AS4P250CA0006.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:5df::8) To AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8898:EE_|DU4PR04MB10499:EE_ X-MS-Office365-Filtering-Correlation-Id: ff44e418-7bdc-48e6-29dc-08dcb546cfa1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014; X-Microsoft-Antispam-Message-Info: RmaCiGLDhvFzZ4YzBpSa/+jFHNF1JmnJszYlxK+KfVUlKxheMhEXYNVs+QkpCoNalOohvg60v9c8LPaFnaKupdZUYtyOVGWeGVzkeEHxs+Vq5TskjE6ddyOQdbXKmhLnKhUFSKwCGotRVVoEUAxTIBk8EuRqzggkJtVPGRhCUe2CYnmUEHTCo2IniSVhHn3oVACrRnBzZS8VG3mEcze4AVenHTSiyS53KpRvH16bRiL1ytM6/+UdbGfDMk2Fm0+BL0rBOSfjFBYYCrlmZPPrux4namlQ/O8FcWTXT04VJ3ZOuD2Z/taLqmzwivKkIRL54L2s0iGCme+TXJCl0S+zMwoPq5OP5JqKN+p7ncz3l1MDV9ANrUu1yg6I8620MBmVRBPjfeicaHhLNCUXAfV8pz6S7W5B3yb4unFpeYWxVdTbmqRZ8Ur2unmi2SvWAUK3vJnUI0FVCsMm4Vabsx0eUWTQi8pqDyFfNS1ScXxICwErohY81Lz2FnLisIaYKhHNIqr2n45jcBsZ1gduqzs3WyBytvTtjKOtdfmARbOJ33pULPSnPV34ReEl3IqbS5HifWYGIRgk+Al/O9aj1b2b9sIDpP7p3dSnQRmVBtpXSCX6eN4MdUXsgl6dAUc6QayiTZLq2b7vUdT4HNp7zUoZ8N25yaIDBJ8NQYatlnvB0sgErViSR/DYO2txy3nNslssj1No6wAXhBwBU4eMnjMdC+OyY2D3xtOTSM/FMcm2sRqMNoGmQBuOxjjE0MEVuQQwsPhYPsaWqMXP5TQmIQ+VJFbk3/qlY4yP7yMm6OQFpN3rL8l4McDPnzUfH/AuZSff1v/s4rof2UTRmvbzY4o9ZFjZJypsBbfc6tLOXI8tqATFih7yaSkb5tGX6FwAOilMVAK9TMVpTjbdyA4o3y62maRzhFVoQiGA/rBG60UxQxwPdVHGcblKJV0/Hs7uFdGaz3p9B+ZkmsntpfY85kaBZWx/1ZjRxDEiPQ5IaCOHglwDwMXF9swFij7hcKmTej1gnXHxvcwagg8KfI8RnvylZPOVvgX5CU3ajtCDBZyP9dmaupEJx9Wan2Tt52hxMidrHnS4SgzqMeMWgswVIWF4F9YqnCl6A0nDbYrZRv/c8vqCQTyPz49NXEm8E96FvZnHqSk1LG78JrAFcy/w4DL50EDTXtVZMBoKB/RUH1y+vVxTFwFHsOsfLj+2bfC0bZink+yT1cWXN0Tvg7aZPxx5mv+ILO1RbCf0eEKCXuD/CXqb78PHsQBcebwppce3oF1hdXS66AIFFb/s68KOQi3nPr0GU9qB1XwveKA7ayahWK5oC1Cfv0Gx7oqvpfgWP6TQD3nW4N8D2B0EolJUDfRlsg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS8PR04MB8898.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2eAINssomf6409Wpc9cufOVdGe+XgoO2DeH4ODAS6UPRTygKmg0hdoKbcWejqQtiEt7ZVRbmKvX6lFrNnb1KSCHrddbbv6T3cziNstbTMT3FuejvZj1hdTfeJgqV84Y1iNsQ8SLCOWzt0fMTAKad0fAPTdWxK5iJ+8S4tAg0mvAp+h8kS1DqiiKrnDKYeth0fJw1t/0eVL9ur03Nje/mrey+YhSXU83pqxmZAJ/AC09p1P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TDa/pBAj06B0YdBtEUME+SE6jXWzaPlNuLYnXXVcB6IAAl93e7tnY4ZRJh1yr76TmRopiOaABwaK1VNQ8cEtgRIgHzOKae6bJxx96r385zkjvq6eyV7qY7PXQG8VUhWZOa6EGSxjRaQ4xbM7tm9UFira/nSPGD//KU9yfOpW/ws7mylcHLGsM3R0qDB81GGhakBcLHfABH3ZZICZaAXVrnmV5tryr449UcSjmSukpBMDnnQ8R7TkhfkfhbQV4MsUrDPFK0KTTTNV0iO7di94uvSuLOdXPsbb8iyKigpCghNPA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ff44e418-7bdc-48e6-29dc-08dcb546cfa1 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Aug 2024 12:04:51.7022 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 8gJ9qN6/V5iqsHkMk2MKBJzsvYRyZyhRLS+EbY0QPamBenIn2R9DDOVejbI73mMXuZx488g9WeqxDwsSYJtb0A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU4PR04MB10499 This implements the MediaAssistant "Push" method, which sends a GATT write command for the Broadcast Audio Scan Control Point characteristic with the "Add Source" opcode. This also registers a callback with shared/bass, to handle GATT notifications from the peer. A MediaAssistant object transitions to different states, depending on information received in the callback. The callback is also useful to check if the peer requires a Broadcast Code to decrypt the stream - in this case, the Assistant uses the "Set Broadcast_Code" operation to provide the code. --- profiles/audio/bass.c | 295 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 295 insertions(+) diff --git a/profiles/audio/bass.c b/profiles/audio/bass.c index 795b4b80a..b3740f64e 100644 --- a/profiles/audio/bass.c +++ b/profiles/audio/bass.c @@ -70,10 +70,18 @@ enum assistant_state { */ }; +static const char *const str_state[] = { + "ASSISTANT_STATE_IDLE", + "ASSISTANT_STATE_PENDING", + "ASSISTANT_STATE_REQUESTING", + "ASSISTANT_STATE_ACTIVE", +}; + struct bass_data { struct btd_device *device; struct btd_service *service; struct bt_bass *bass; + unsigned int src_id; }; struct bass_assistant { @@ -92,14 +100,206 @@ struct bass_assistant { static struct queue *sessions; static struct queue *assistants; +static const char *state2str(enum assistant_state state); + static void bass_debug(const char *str, void *user_data) { DBG_IDX(0xffff, "%s", str); } +static void assistant_set_state(struct bass_assistant *assistant, + enum assistant_state state) +{ + enum assistant_state old_state = assistant->state; + const char *str; + + if (old_state == state) + return; + + assistant->state = state; + + DBG("State changed %s: %s -> %s", assistant->path, str_state[old_state], + str_state[state]); + + str = state2str(state); + + if (g_strcmp0(str, state2str(old_state)) != 0) + g_dbus_emit_property_changed(btd_get_dbus_connection(), + assistant->path, + MEDIA_ASSISTANT_INTERFACE, + "State"); +} + +static int assistant_parse_qos(struct bass_assistant *assistant, + DBusMessageIter *iter) +{ + DBusMessageIter dict; + const char *key; + + dbus_message_iter_recurse(iter, &dict); + + while (dbus_message_iter_get_arg_type(&dict) == DBUS_TYPE_DICT_ENTRY) { + DBusMessageIter value, entry; + int var; + + dbus_message_iter_recurse(&dict, &entry); + dbus_message_iter_get_basic(&entry, &key); + + dbus_message_iter_next(&entry); + dbus_message_iter_recurse(&entry, &value); + + var = dbus_message_iter_get_arg_type(&value); + + if (!strcasecmp(key, "BCode")) { + DBusMessageIter array; + struct iovec iov = {0}; + + if (var != DBUS_TYPE_ARRAY) + return -EINVAL; + + dbus_message_iter_recurse(&value, &array); + dbus_message_iter_get_fixed_array(&array, + &iov.iov_base, + (int *)&iov.iov_len); + + if (iov.iov_len != BT_BASS_BCAST_CODE_SIZE) { + error("Invalid size for BCode: %zu != 16", + iov.iov_len); + return -EINVAL; + } + + memcpy(assistant->qos.bcast.bcode, iov.iov_base, + iov.iov_len); + + return 0; + } + + dbus_message_iter_next(&dict); + } + + return 0; +} + +static int assistant_parse_props(struct bass_assistant *assistant, + DBusMessageIter *props) +{ + DBusMessageIter value, entry, array; + const char *key; + + while (dbus_message_iter_get_arg_type(props) == DBUS_TYPE_DICT_ENTRY) { + dbus_message_iter_recurse(props, &entry); + dbus_message_iter_get_basic(&entry, &key); + + dbus_message_iter_next(&entry); + dbus_message_iter_recurse(&entry, &value); + + if (!strcasecmp(key, "Metadata")) { + struct iovec iov; + + if (dbus_message_iter_get_arg_type(&value) != + DBUS_TYPE_ARRAY) + goto fail; + + dbus_message_iter_recurse(&value, &array); + dbus_message_iter_get_fixed_array(&array, + &iov.iov_base, + (int *)&iov.iov_len); + + util_iov_free(assistant->meta, 1); + assistant->meta = util_iov_dup(&iov, 1); + DBG("Parsed Metadata"); + } else if (!strcasecmp(key, "QoS")) { + if (dbus_message_iter_get_arg_type(&value) != + DBUS_TYPE_ARRAY) + goto fail; + + if (assistant_parse_qos(assistant, &value)) + goto fail; + + DBG("Parsed QoS"); + } + + dbus_message_iter_next(props); + } + + return 0; + +fail: + DBG("Failed parsing %s", key); + + return -EINVAL; +} + static DBusMessage *push(DBusConnection *conn, DBusMessage *msg, void *user_data) { + struct bass_assistant *assistant = user_data; + struct bt_bass_bcast_audio_scan_cp_hdr hdr; + struct bt_bass_add_src_params params; + struct iovec iov = {0}; + uint32_t bis_sync = 0; + uint8_t meta_len = 0; + int err; + DBusMessageIter props, dict; + + DBG(""); + + dbus_message_iter_init(msg, &props); + + if (dbus_message_iter_get_arg_type(&props) != DBUS_TYPE_ARRAY) { + DBG("Unable to parse properties"); + return btd_error_invalid_args(msg); + } + + dbus_message_iter_recurse(&props, &dict); + + if (assistant_parse_props(assistant, &dict)) { + DBG("Unable to parse properties"); + return btd_error_invalid_args(msg); + } + + hdr.op = BT_BASS_ADD_SRC; + + if (device_get_le_address_type(assistant->device) == BDADDR_LE_PUBLIC) + params.addr_type = BT_BASS_ADDR_PUBLIC; + else + params.addr_type = BT_BASS_ADDR_RANDOM; + + bacpy(¶ms.addr, device_get_address(assistant->device)); + put_le24(assistant->bid, params.bid); + params.pa_sync = PA_SYNC_NO_PAST; + params.pa_interval = PA_INTERVAL_UNKNOWN; + params.num_subgroups = assistant->sgrp + 1; + + util_iov_append(&iov, ¶ms, sizeof(params)); + + /* Metadata and the BIS index associated with the MediaAssistant + * object will be set in the subgroup they belong to. For the other + * subgroups, no metadata and no BIS index will be provided. + */ + for (uint8_t sgrp = 0; sgrp < assistant->sgrp; sgrp++) { + util_iov_append(&iov, &bis_sync, sizeof(bis_sync)); + util_iov_append(&iov, &meta_len, sizeof(meta_len)); + } + + bis_sync = (1 << (assistant->bis - 1)); + meta_len = assistant->meta->iov_len; + + util_iov_append(&iov, &bis_sync, sizeof(bis_sync)); + util_iov_append(&iov, &meta_len, sizeof(meta_len)); + util_iov_append(&iov, assistant->meta->iov_base, + assistant->meta->iov_len); + + err = bt_bass_send(assistant->data->bass, &hdr, &iov); + if (err) { + DBG("Unable to send BASS Write Command"); + return btd_error_failed(msg, strerror(-err)); + } + + free(iov.iov_base); + + assistant_set_state(assistant, ASSISTANT_STATE_PENDING); + return g_dbus_create_reply(msg, DBUS_TYPE_INVALID); } @@ -381,6 +581,8 @@ static void bass_data_free(struct bass_data *data) bt_bass_set_user_data(data->bass, NULL); } + bt_bass_src_unregister(data->bass, data->src_id); + bt_bass_unref(data->bass); queue_remove_all(assistants, assistant_match_data, @@ -453,6 +655,93 @@ static void bass_attached(struct bt_bass *bass, void *user_data) bass_data_add(data); } +static void bass_handle_bcode_req(struct bass_assistant *assistant, int id) +{ + struct bt_bass_bcast_audio_scan_cp_hdr hdr; + struct bt_bass_set_bcast_code_params params; + struct iovec iov = {0}; + int err; + + assistant_set_state(assistant, ASSISTANT_STATE_REQUESTING); + + hdr.op = BT_BASS_SET_BCAST_CODE; + + params.id = id; + memcpy(params.bcast_code, assistant->qos.bcast.bcode, + BT_BASS_BCAST_CODE_SIZE); + + iov.iov_base = malloc0(sizeof(params)); + if (!iov.iov_base) + return; + + util_iov_push_mem(&iov, sizeof(params), ¶ms); + + err = bt_bass_send(assistant->data->bass, &hdr, &iov); + if (err) { + DBG("Unable to send BASS Write Command"); + return; + } + + free(iov.iov_base); +} + +static void bass_src_changed(uint8_t id, uint32_t bid, uint8_t enc, + uint32_t bis_sync, void *user_data) +{ + const struct queue_entry *entry; + + for (entry = queue_get_entries(assistants); entry; + entry = entry->next) { + struct bass_assistant *assistant = entry->data; + uint32_t bis = 1 << (assistant->bis - 1); + + if (assistant->bid != bid) + /* Only handle assistant objects + * that match the source + */ + continue; + + switch (enc) { + case BT_BASS_BIG_ENC_STATE_BCODE_REQ: + if (assistant->state != ASSISTANT_STATE_PENDING) + /* Only handle assistant objects that + * have been pushed by the user + */ + break; + + /* Provide Broadcast Code to peer */ + bass_handle_bcode_req(assistant, id); + break; + case BT_BASS_BIG_ENC_STATE_NO_ENC: + if (assistant->state != ASSISTANT_STATE_PENDING) + /* Only handle assistant objects that + * have been pushed by the user + */ + break; + + /* Match BIS index */ + if (bis & bis_sync) + assistant_set_state(assistant, + ASSISTANT_STATE_ACTIVE); + break; + case BT_BASS_BIG_ENC_STATE_DEC: + /* Only handle assistant objects that + * have requested a Broadcast Code + */ + if (assistant->state != ASSISTANT_STATE_REQUESTING) + break; + + /* Match BIS index */ + if (bis & bis_sync) + assistant_set_state(assistant, + ASSISTANT_STATE_ACTIVE); + break; + default: + continue; + } + } +} + static int bass_probe(struct btd_service *service) { struct btd_device *device = btd_service_get_device(service); @@ -485,6 +774,12 @@ static int bass_probe(struct btd_service *service) bass_data_add(data); bt_bass_set_user_data(data->bass, service); + /* Register callback to be called when notifications for + * Broadcast Receive State characteristics are received. + */ + data->src_id = bt_bass_src_register(data->bass, bass_src_changed, + data, NULL); + return 0; } From patchwork Mon Aug 5 12:04:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 13753561 Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazon11013031.outbound.protection.outlook.com [52.101.67.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2F7D3156980 for ; Mon, 5 Aug 2024 12:04:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.67.31 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722859501; cv=fail; b=Qm3+mIrsVB9mQYq5kz6YEzMmPt7S0LOtLJIRHyIMhFSw1G3sxWcazgeMcbwZIjxohyTl9v3RJjfCZIKQG6huzd+uLuFCtPsWrb5FN65kLlnmfqt1MplQcF6IlBYrKtWYMTTtYtHtb6JyFnbFahHR/pJnZfpltbQYRRiaSjEYmPg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722859501; c=relaxed/simple; bh=ZebobFKVVlRQoBo1057thmYwxiIJws7CsPO1R4jUQ2E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=V/D9je9zC9L50s34Cdk/S4xeq8rZTHC5Qfk6TOccg+zlu7BhCWmQFz8VVhuF6cGmycMWnEWtK2pO09DH95YtQZg2IrMTD89ozs+rhkOrubif8mFZPcMorZCE9hBGbsMbOy6nenV8axLMXxBKZ4NEtM236R9zI38Do3s8OT5a5uw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=PEO3gyBR; arc=fail smtp.client-ip=52.101.67.31 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="PEO3gyBR" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tPoS5DXeQrVD2q1EZyeIDHnjEGqKbE22oP54v4aB22hrTYZT4znwRJPLCUNoRY39HDiaok1xSaSp4aQNtb8fCWua6QCjMl8sxv+BJikVx4MU8tBY3kwL2cJNGSkkiJJUSaW6+KE/4aEpkVTNHmeTYJPsSOL/NbibDGBHiJzeqEnYr1LvBa+7aruNrP1LSzIlQsCcze2YPQYee+HBZf1EchGXuEpy/j0ufBwv1ZHjA6HMjCsvT8fGAXBcBhYYuFxQYaS99c89g59BL18jr/BRC0LqN9e8rHl6jG8zrhCxsV5Q9oYX0ddpGVJ1VXSrIiYlD3q4dEXNwG0T3ci7B+P+Cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=VlQveIIE7GNZf1JFQ04sEvTtPHBYjPtyvRlb8ikQL3Q=; b=o+EdPWC6GDR0MK0tzW/p3a06Gpyw6BQ4Sp3oX1ZI6OGRSHrN4j65QLBOKa+Kb56613LcVazIBTy0Mm7UJemOiXU7dz6SjPJuC6JyB6YMfzX5OH6JBYwbuTtIikysxWqwJRwFpMvigQnrAEOFq1N3+YbIX7G8hEdSNCt3TennngzBPHOkmCidGg7cwMQPV9oLPq1JmzYkR9CvJ9HtqBjfNOwD5Wt/iQ6XvIFLMoSGyV23OGpreulRlZlm3mZUjaZVy7WuOfUIgD/SZHDl7gNQXTPmYTMdPTLMj6unAMBPa1PH8mE/66cihWsHBp8eklKHXs9j1AzQGB1q0pvNjR9PWg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VlQveIIE7GNZf1JFQ04sEvTtPHBYjPtyvRlb8ikQL3Q=; b=PEO3gyBRk45Vl7NtwJpm1tqLXM/bwGxz3w0cn0KrxFrTDGpX1Zrf1Es54TGF75+H+7TqovfmF2o0qLTP1OeoMUc5Uy7qKwCC1Iu8yDC1GFciZ1ueZZcBVgVWKoFmIgFa0fEroVw8ewav5p1rQRwXNuTXjCF0uNDFglIo0Bx6NRdX+qUZZ4jy0KxhXfJLHI+YBNFI49G6j1YB5HciiWDflpiWY/MNPyMwYeXqbb0io12jOeT2qVtBA0xWhKHQ4HTS7VisCVmepx3D60CiO+a3qVAZdLYh6taPkndaXCtSKYJfqd20U9ACxdqsuJripKyTuxwSupo9JF5/JOLqWwuwBw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) by DU4PR04MB10499.eurprd04.prod.outlook.com (2603:10a6:10:568::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.26; Mon, 5 Aug 2024 12:04:54 +0000 Received: from AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654]) by AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654%5]) with mapi id 15.20.7828.023; Mon, 5 Aug 2024 12:04:54 +0000 From: Iulia Tanasescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, vlad.pruteanu@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Iulia Tanasescu Subject: [PATCH BlueZ 7/7] assistant: Implement MediaAssistant Push command Date: Mon, 5 Aug 2024 15:04:29 +0300 Message-Id: <20240805120429.67606-8-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240805120429.67606-1-iulia.tanasescu@nxp.com> References: <20240805120429.67606-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AM4PR07CA0031.eurprd07.prod.outlook.com (2603:10a6:205:1::44) To AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8898:EE_|DU4PR04MB10499:EE_ X-MS-Office365-Filtering-Correlation-Id: 7409ee90-7036-47ef-9b34-08dcb546d15a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014; X-Microsoft-Antispam-Message-Info: nkQdnLJ9lBgQTPr3qkntVp5aiC91rJvldIJjGZ+Zq7fDCvBvmg0w/NB2aFZ2ccJdkF0GM5599GI1yv57uRad8dbHf4phazKuJ6pC0sxcFJSJvAw0fh2O1xblz/Q/GjXfLS5+Umht1bengt62zeZilyKKBcb4rybSeZz6fNWQfFoLnA35puPOZ2fX5O1HGPD/pR0StdXvB5Gv5KmB/9kBIEKaj+a516Mt7jj6SOadfImCuyWJoQrsomd1OYjiheNkhJ3Z0YrTEWqwyYJ4EnuSUNfrL8u/zesMarHYGASI/P/f644T2CVuNqJcd9xS1fgCs2Niy0T3R0fd4AOXQGLo1XHI5WWyUYXPTkjsDwrKcVw8KLn12hiErdyi+c4JzcKJNEt+GgcxH6GmOC1uddPKozjGiBPFO1KAc9KuvjlgSGuV0gdFeK+mrn/O/r8gGGuWgE1cc53Us3w66qvTnz20i0KlvK3JFckvcFhwuO19YnsiGvozoIlmrEgEqxV8vWfCrrTEsnRIFXiKmrSSHlY7mzU568iW3t9Pjx18k6JD/eEl0ty5T5chNe3ZLBQYsfCw+Q1A29jYJ5NFIzpp+t9lBbI+w0rxmJo0BMTTd+7l7Oa86F3hQsQu9zRObGw8gt1MOaBdSz+5tcreaZ1y5ixr7fuhw4Ex+aLtEfnnQWJBj8dPuaVGYqz1IUhT3/oIH5jzAWHYh12P7FV/9up3uw7Y6oI0frHi/39s5rNLHXB3ivKXyQw1hUaUiXQ8Wvh1wKApT1GDp22u3bh0164jeTBLnzec94dosY/pIhv1DAzRiPl0SPOhTTmxNx9jF7Qf0/SsW2ce3P4dEbspqVB8Hfj6acWXloXkmStGEktRJkbP1pyenge7RM4m8D5jYiLraluCxxDJeyCdJhASzLiOgXhieYzakZ+ptBTRwgJM/T7CoHQU8AieHxFUlmeqoh0FQdgXZwSOGrp4LlH5WWmQvPp2dc5JBTU6Cmk6aBR5FHeAaB6M4DJowKpNVM/AMT0rCSSjhcTldYyN4gSYVoCEb0iqdbfziykemNBEUtM5kiJwpvxWkuv0KPIUfLDB3SC7ioVK0SmMiV/kllzGrNgURwksHMZPQzNbqlS277PTfGwQa821LrQCHI+5wW08D7dvobBDpYTiZQs8TAigMRaRN6fRPKfIcU3aeNNsZJ2El08HcglToshNep6KypaT1ltymq+LHcbSXemOp4xkQdVcrbe9YybL1QdJPtnrSGIy95ms6xrVC42mQ+BDLa3f0cDwP2Eeb9THhxc75BKITKjawDfYNE8Avnx9nNUcCiHxVHrVSB4m7yYTknZxM36vK/E02KivQyj148rjlnVDAL7TMMoAUg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS8PR04MB8898.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0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vzVKE0hqSqDDy9ToyA+81iB60eS0z1QrCgKOcG85ycUS0fOSPSaXlt7bVjJuQKPbnfDo1KzrvQNUgGQ4GoFF/M27mQHK/4WP7WzyQr9wxgOlSKELDI4O8rLpNRoC+ZWtGRf3wJsd6WMuyRQQIMV4LiuvOstJ2x5IKsV6AF+U97yuMULcIKVV/6C9G6eYoY2jIJHFGTiFnhPNmLFq5MmiPREHqOHnDnOkqVDAePwkryZCUDd6hN4cdo7cvNMpmMFDlknE3UEE09Ns6hK6lsr0ErMWD7Uf19VDbueZHLNrLaJamP32DeziJ2Wee3K1r8Vd5ZKDqmX/27f6mCVrU93bSot7Oeafn4S+SdO0nUfKeOTE+girqDKPpTzRwVCYgUFfu5blX3dTlo0tOjXwD/euXplLA9T6Znj235vcW+lcQyIERanaifpJjwGtPIy00UBRvYiIzP0gE0AziEZVcsd3F50tCcXP4Xrpsd8vPEPBJMn7XofZrE/sccdkk5f4xqpWQdO7RgJiPnv4DzdmRWOUvg7uabslANw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7409ee90-7036-47ef-9b34-08dcb546d15a X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Aug 2024 12:04:54.6492 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: UPWCwtTB+Ni5PCYosPUr7JhYE156+WwXYTjAEeEidEmPpc4xSO3OYqWqdjPZZZ6gXxR6qMLdUOUIWoLM8j8FNQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU4PR04MB10499 This implements the MediaAssistant "Push" command, to trigger the BlueZ Broadcast Assistant to send stream information to the peer. After issuing the "Push" command, the user is prompted to enter any stream metadata to be sent to the peer. If the "auto" value is chosen, the default metadata found in the BASE will be sent. Otherwise, the LTVs found in the BASE will be overwritten by the user input. If the stream is encrypted, the user is also prompted to enter the Broadcast Code for decrypting. If the "auto" value is chosen, a zero filled array will be provided over DBus. Below is a bluetoothctl log to exercise the "Push" command for an unencrypted stream: client/bluetoothctl [bluetooth]# [CHG] Controller 00:60:37:31:7E:3F Pairable: yes [bluetooth]# AdvertisementMonitor path registered [bluetooth]# scan on [bluetooth]# [NEW] Device 00:60:37:31:7E:3F 00-60-37-31-7E-3F [bluetooth]# connect 00:60:37:31:7E:3F Attempting to connect to 00:60:37:31:7E:3F [CHG] Device 00:60:37:31:7E:3F Connected: yes [00-60-37-31-7E-3F]# Connection successful [00-60-37-31-7E-3F]# [NEW] Device 15:19:44:63:76:7A 15-19-44-63-76-7A [00-60-37-31-7E-3F]# [NEW] Assistant /org/bluez/hci0/src_15_19_44_63_76_7A/dev_00_60_37_31_7E_3F/bis1 [00-60-37-31-7E-3F]# assistant.push /org/bluez/hci0/src_15_19_44_63_76_7A/dev_00_60_37_31_7E_3F/bis1 [Assistant] Enter Metadata (auto/value): 0x03 0x02 0x04 0x00 [00-60-37-31-7E-3F]# [CHG] Assistant /org/bluez/hci0/src_15_19_44_63_76_7A/dev_00_60_37_31_7E_3F/bis1 State: pending [00-60-37-31-7E-3F]# Assistant /org/bluez/hci0/src_15_19_44_63_76_7A/dev_00_60_37_31_7E_3F/bis1 pushed [00-60-37-31-7E-3F]# [CHG] Assistant /org/bluez/hci0/src_15_19_44_63_76_7A/dev_00_60_37_31_7E_3F/bis1 State: active The btmon log below shows the GATT write command sent by the Assistant and the GATT notification received from the peer: < ACL Data TX: Handle 0 flags 0x00 dlen 32 ATT: Write Command (0x52) len 27 Handle: 0x0040 Type: Broadcast Audio Scan Control Point (0x2bc7) Data[25]: 02017a766344191500c21a3702ffff01010000000403020400 Opcode: Add Source (0x02) Source_Address_Type: 1 Source_Address: 15:19:44:63:76:7A Source_Adv_SID: 0 Broadcast_ID: 0x371ac2 PA_Sync_State: Synchronize to PA - PAST not available PA_Interval: 0xffff Num_Subgroups: 1 Subgroup #0: BIS_Sync State: 0x00000001 Metadata: #0: len 0x03 type 0x02 Metadata: 04 00 > ACL Data RX: Handle 0 flags 0x01 dlen 6 ATT: Handle Multiple Value Notification (0x23) len 28 Length: 0x0018 Handle: 0x003a Type: Broadcast Receive State (0x2bc8) Data[24]: 01017a766344191500c21a37020001010000000403020400 Source_ID: 1 Source_Address_Type: 1 Source_Address: 15:19:44:63:76:7A Source_Adv_SID: 0 Broadcast_ID: 0x371ac2 PA_Sync_State: Synchronized to PA BIG_Encryption: Not encrypted Num_Subgroups: 1 Subgroup #0: BIS_Sync State: 0x00000001 Metadata: #0: len 0x03 type 0x02 Metadata: 04 00 The bluetoothctl log below shows the "Push" command flow for an encrypted stream: client/bluetoothctl [bluetooth]# [CHG] Controller 00:60:37:31:7E:3F Pairable: yes [bluetooth]# AdvertisementMonitor path registered [bluetooth]# scan on [bluetooth]# [NEW] Device 00:60:37:31:7E:3F 00-60-37-31-7E-3F [bluetooth]# connect 00:60:37:31:7E:3F Attempting to connect to 00:60:37:31:7E:3F [CHG] Device 00:60:37:31:7E:3F Connected: yes [00-60-37-31-7E-3F]# Connection successful [00-60-37-31-7E-3F]# [NEW] Device 05:1F:EE:F3:F8:7D 05-1F-EE-F3-F8-7D [00-60-37-31-7E-3F]# [NEW] Assistant /org/bluez/hci0/src_05_1F_EE_F3_F8_7D/dev_00_60_37_31_7E_3F/bis1 [00-60-37-31-7E-3F]# assistant.push /org/bluez/hci0/src_05_1F_EE_F3_F8_7D/dev_00_60_37_31_7E_3F/bis1 [Assistant] Enter Metadata (auto/value): 0x03 0x02 0x04 0x00 [Assistant] Enter Broadcast Code (auto/value): 0x01 0x02 0x68 0x05 0x53 0xf1 0x41 0x5a 0xa2 0x65 0xbb 0xaf 0xc6 0xea 0x03 0xb8 [00-60-37-31-7E-3F]# [CHG] Assistant /org/bluez/hci0/src_05_1F_EE_F3_F8_7D/dev_00_60_37_31_7E_3F/bis1 State: pending [00-60-37-31-7E-3F]# Assistant /org/bluez/hci0/src_05_1F_EE_F3_F8_7D/dev_00_60_37_31_7E_3F/bis1 pushed [00-60-37-31-7E-3F]# [CHG] Assistant /org/bluez/hci0/src_05_1F_EE_F3_F8_7D/dev_00_60_37_31_7E_3F/bis1 State: requesting [00-60-37-31-7E-3F]# [CHG] Assistant /org/bluez/hci0/src_05_1F_EE_F3_F8_7D/dev_00_60_37_31_7E_3F/bis1 State: active The GATT write commands and notifications for this scenario are shown in the btmon log below: < ACL Data TX: Handle 0 flags 0x00 dlen 32 ATT: Write Command (0x52) len 27 Handle: 0x0040 Type: Broadcast Audio Scan Control Point (0x2bc7) Data[25]: 02017df8f3ee1f0500f4015d02ffff01010000000403020400 Opcode: Add Source (0x02) Source_Address_Type: 1 Source_Address: 05:1F:EE:F3:F8:7D Source_Adv_SID: 0 Broadcast_ID: 0x5d01f4 PA_Sync_State: Synchronize to PA - PAST not available PA_Interval: 0xffff Num_Subgroups: 1 Subgroup #0: BIS_Sync State: 0x00000001 Metadata: #0: len 0x03 type 0x02 Metadata: 04 00 > ACL Data RX: Handle 0 flags 0x01 dlen 6 ATT: Handle Multiple Value Notification (0x23) len 28 Length: 0x0018 Handle: 0x003a Type: Broadcast Receive State (0x2bc8) Data[24]: 01017df8f3ee1f0500f4015d020101000000000403020400 Source_ID: 1 Source_Address_Type: 1 Source_Address: 05:1F:EE:F3:F8:7D Source_Adv_SID: 0 Broadcast_ID: 0x5d01f4 PA_Sync_State: Synchronized to PA BIG_Encryption: Broadcast_Code required Num_Subgroups: 1 Subgroup #0: BIS_Sync State: 0x00000000 Metadata: #0: len 0x03 type 0x02 Metadata: 04 00 < ACL Data TX: Handle 0 flags 0x00 dlen 25 ATT: Write Command (0x52) len 20 Handle: 0x0040 Type: Broadcast Audio Scan Control Point (0x2bc7) Data[18]: 04010102680553f1415aa265bbafc6ea03b8 Opcode: Set Broadcast_Code (0x04) Source_ID: 1 Broadcast_Code[16]: 0102680553f1415aa265bbafc6ea03b8 > ACL Data RX: Handle 0 flags 0x01 dlen 6 ATT: Handle Multiple Value Notification (0x23) len 28 Length: 0x0018 Handle: 0x003a Type: Broadcast Receive State (0x2bc8) Data[24]: 01017df8f3ee1f0500f4015d020201010000000403020400 Source_ID: 1 Source_Address_Type: 1 Source_Address: 05:1F:EE:F3:F8:7D Source_Adv_SID: 0 Broadcast_ID: 0x5d01f4 PA_Sync_State: Synchronized to PA BIG_Encryption: Decrypting Num_Subgroups: 1 Subgroup #0: BIS_Sync State: 0x00000001 Metadata: #0: len 0x03 type 0x02 Metadata: 04 00 --- client/assistant.c | 247 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 247 insertions(+) diff --git a/client/assistant.c b/client/assistant.c index 69a955c18..77fb78329 100644 --- a/client/assistant.c +++ b/client/assistant.c @@ -43,6 +43,14 @@ #define MEDIA_ASSISTANT_INTERFACE "org.bluez.MediaAssistant1" +#define BCODE_LEN 16 + +struct assistant_config { + GDBusProxy *proxy; /* DBus object reference */ + struct iovec *meta; /* Stream metadata LTVs */ + struct bt_iso_qos qos; /* Stream QoS parameters */ +}; + static DBusConnection *dbus_conn; static GList *assistants; @@ -141,10 +149,249 @@ static void disconnect_handler(DBusConnection *connection, void *user_data) assistants = NULL; } +static uint8_t *str2bytearray(char *arg, size_t *val_len) +{ + uint8_t value[UINT8_MAX]; + char *entry; + unsigned int i; + + for (i = 0; (entry = strsep(&arg, " \t")) != NULL; i++) { + long val; + char *endptr = NULL; + + if (*entry == '\0') + continue; + + if (i >= G_N_ELEMENTS(value)) { + bt_shell_printf("Too much data\n"); + return NULL; + } + + val = strtol(entry, &endptr, 0); + if (!endptr || *endptr != '\0' || val > UINT8_MAX) { + bt_shell_printf("Invalid value at index %d\n", i); + return NULL; + } + + value[i] = val; + } + + *val_len = i; + + return util_memdup(value, i); +} + +static void append_qos(DBusMessageIter *iter, struct assistant_config *cfg) +{ + DBusMessageIter entry, var, dict; + const char *key = "QoS"; + const char *bcode_key = "BCode"; + uint8_t *bcode = cfg->qos.bcast.bcode; + + dbus_message_iter_open_container(iter, DBUS_TYPE_DICT_ENTRY, + NULL, &entry); + + dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key); + + dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT, + "a{sv}", &var); + + dbus_message_iter_open_container(&var, DBUS_TYPE_ARRAY, "{sv}", + &dict); + + g_dbus_dict_append_basic_array(&dict, DBUS_TYPE_STRING, + &bcode_key, DBUS_TYPE_BYTE, + &bcode, BCODE_LEN); + + dbus_message_iter_close_container(&var, &dict); + dbus_message_iter_close_container(&entry, &var); + dbus_message_iter_close_container(iter, &entry); +} + +static void push_setup(DBusMessageIter *iter, void *user_data) +{ + struct assistant_config *cfg = user_data; + DBusMessageIter dict; + const char *meta = "Metadata"; + + dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, "{sv}", &dict); + + if (cfg->meta) + g_dbus_dict_append_basic_array(&dict, DBUS_TYPE_STRING, &meta, + DBUS_TYPE_BYTE, &cfg->meta->iov_base, + cfg->meta->iov_len); + + if (cfg->qos.bcast.encryption) + append_qos(&dict, cfg); + + dbus_message_iter_close_container(iter, &dict); +} + +static void push_reply(DBusMessage *message, void *user_data) +{ + struct assistant_config *cfg = user_data; + DBusError error; + + dbus_error_init(&error); + + if (dbus_set_error_from_message(&error, message)) { + bt_shell_printf("Failed to push assistant: %s\n", + error.name); + + dbus_error_free(&error); + + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + bt_shell_printf("Assistant %s pushed\n", + g_dbus_proxy_get_path(cfg->proxy)); + + free(cfg->meta); + g_free(cfg); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void assistant_set_bcode_cfg(const char *input, void *user_data) +{ + struct assistant_config *cfg = user_data; + char *endptr; + uint8_t *bcode = cfg->qos.bcast.bcode; + + if (!strcasecmp(input, "a") || !strcasecmp(input, "auto")) { + memset(bcode, 0, BCODE_LEN); + } else { + bcode[0] = strtol(input, &endptr, 16); + + for (uint8_t i = 1; i < BCODE_LEN; i++) + bcode[i] = strtol(endptr, &endptr, 16); + } + + if (!g_dbus_proxy_method_call(cfg->proxy, "Push", + push_setup, push_reply, + cfg, NULL)) { + bt_shell_printf("Failed to push assistant\n"); + + free(cfg->meta); + g_free(cfg); + + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } +} + +static void assistant_set_metadata_cfg(const char *input, void *user_data) +{ + struct assistant_config *cfg = user_data; + DBusMessageIter iter, dict, entry, value; + const char *key; + + if (!strcasecmp(input, "a") || !strcasecmp(input, "auto")) + goto done; + + if (!cfg->meta) + cfg->meta = g_new0(struct iovec, 1); + + cfg->meta->iov_base = str2bytearray((char *) input, + &cfg->meta->iov_len); + if (!cfg->meta->iov_base) { + free(cfg->meta); + cfg->meta = NULL; + } + +done: + /* Get QoS property to check if the stream is encrypted */ + if (!g_dbus_proxy_get_property(cfg->proxy, "QoS", &iter)) + goto fail; + + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY) + goto fail; + + dbus_message_iter_recurse(&iter, &dict); + + if (dbus_message_iter_get_arg_type(&dict) != DBUS_TYPE_DICT_ENTRY) + goto fail; + + dbus_message_iter_recurse(&dict, &entry); + dbus_message_iter_get_basic(&entry, &key); + + if (strcasecmp(key, "Encryption") != 0) + goto fail; + + dbus_message_iter_next(&entry); + dbus_message_iter_recurse(&entry, &value); + + if (dbus_message_iter_get_arg_type(&value) != DBUS_TYPE_BYTE) + goto fail; + + dbus_message_iter_get_basic(&value, &cfg->qos.bcast.encryption); + + if (cfg->qos.bcast.encryption) + /* Prompt user to enter the Broadcast Code to decrypt + * the stream + */ + bt_shell_prompt_input("Assistant", + "Enter Broadcast Code (auto/value):", + assistant_set_bcode_cfg, cfg); + else + if (!g_dbus_proxy_method_call(cfg->proxy, "Push", + push_setup, push_reply, + cfg, NULL)) { + bt_shell_printf("Failed to push assistant\n"); + goto fail; + } + + return; + +fail: + free(cfg->meta); + g_free(cfg); + + return bt_shell_noninteractive_quit(EXIT_FAILURE); +} + +static void cmd_push_assistant(int argc, char *argv[]) +{ + struct assistant_config *cfg; + + cfg = new0(struct assistant_config, 1); + if (!cfg) + goto fail; + + /* Search for DBus object */ + cfg->proxy = g_dbus_proxy_lookup(assistants, NULL, argv[1], + MEDIA_ASSISTANT_INTERFACE); + if (!cfg->proxy) { + bt_shell_printf("Assistant %s not found\n", argv[1]); + goto fail; + } + + /* Prompt user to enter metadata */ + bt_shell_prompt_input("Assistant", + "Enter Metadata (auto/value):", + assistant_set_metadata_cfg, cfg); + + return; + +fail: + g_free(cfg); + return bt_shell_noninteractive_quit(EXIT_FAILURE); +} + +static const struct bt_shell_menu assistant_menu = { + .name = "assistant", + .desc = "Media Assistant Submenu", + .entries = { + { "push", "", cmd_push_assistant, + "Send stream information to peer" }, + {} }, +}; + static GDBusClient * client; void assistant_add_submenu(void) { + bt_shell_add_submenu(&assistant_menu); + dbus_conn = bt_shell_get_env("DBUS_CONNECTION"); if (!dbus_conn || client) return;