Skip to content

Commit

Permalink
samples: Bluetooth: Audio: Add/fix API includes and references
Browse files Browse the repository at this point in the history
Update the includes for Bluetooth Audio samples so they
properly include what they use.

The includes are then used to determine which relevant APIs
to refer to in the READMEs.

Finally improve the naming and description of the samples
using the Profile names and role.

(cherry picked from commit c0f71e9)

Original-Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
GitOrigin-RevId: c0f71e9
Cr-Build-Id: 8735895478936220081
Cr-Build-Url: https://cr-buildbucket.appspot.com/build/8735895478936220081
Copybot-Job-Name: zephyr-main-copybot-downstream
Change-Id: I7f075207dc93ef44eb86af24be7a31d3b2aafc36
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/zephyr/+/5887641
Commit-Queue: Fabio Baltieri <fabiobaltieri@google.com>
Tested-by: Fabio Baltieri <fabiobaltieri@google.com>
Tested-by: ChromeOS Prod (Robot) <chromeos-ci-prod@chromeos-bot.iam.gserviceaccount.com>
Reviewed-by: Fabio Baltieri <fabiobaltieri@google.com>
  • Loading branch information
Thalley authored and Chromeos LUCI committed Sep 24, 2024
1 parent 24c90b5 commit d9d428e
Show file tree
Hide file tree
Showing 41 changed files with 353 additions and 145 deletions.
12 changes: 6 additions & 6 deletions samples/bluetooth/bap_broadcast_assistant/README.rst
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
.. zephyr:code-sample:: bluetooth_bap_broadcast_assistant
:name: Broadcast Audio Assistant
:relevant-api: bt_bap
:name: Basic Audio Profile (BAP) Broadcast Audio Assistant
:relevant-api: bluetooth bt_audio bt_bap bt_conn

Use LE Audio Broadcast Assistant functionality.
Use BAP Broadcast Assistant functionality.

Overview
********

Application demonstrating the LE Audio broadcast assistant functionality.
Application demonstrating the BAP Broadcast Assistant functionality.

The sample will automatically try to connect to a device in the BAP Scan Delegator
role (advertising support for the Broadcast Audio Scan Service (BASS)).
It will then search for a broadcast source and (if found) add the broadcast ID to
the BAP Scan Delegator.

Practical use of this sample requires a sink (e.g. the Broadcast Audio Sink sample or
a set of LE Audio Broadcast capable earbuds) and a source (e.g. the Broadcast Audio
Practical use of this sample requires a sink (e.g. the BAP Broadcast Audio Sink sample or
a set of BAP Broadcast capable earbuds) and a source (e.g. the BAP Broadcast Audio
Source sample).

This sample can be found under
Expand Down
23 changes: 18 additions & 5 deletions samples/bluetooth/bap_broadcast_assistant/src/main.c
Original file line number Diff line number Diff line change
@@ -1,20 +1,33 @@
/*
* Copyright (c) 2024 Demant A/S
* Copyright (c) 2024 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/types.h>
#include <errno.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <strings.h>
#include <errno.h>
#include <zephyr/kernel.h>
#include <zephyr/sys/printk.h>

#include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/autoconf.h>
#include <zephyr/bluetooth/addr.h>
#include <zephyr/bluetooth/audio/audio.h>
#include <zephyr/bluetooth/audio/bap.h>
#include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/bluetooth/conn.h>
#include <zephyr/bluetooth/gap.h>
#include <zephyr/bluetooth/hci.h>
#include <zephyr/bluetooth/hci_types.h>
#include <zephyr/bluetooth/iso.h>
#include <zephyr/bluetooth/uuid.h>
#include <zephyr/kernel.h>
#include <zephyr/net_buf.h>
#include <zephyr/sys/byteorder.h>
#include <zephyr/sys/printk.h>
#include <zephyr/sys/util.h>
#include <zephyr/types.h>

#define NAME_LEN 30
#define PA_SYNC_SKIP 5
Expand Down
10 changes: 5 additions & 5 deletions samples/bluetooth/bap_broadcast_sink/README.rst
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
.. zephyr:code-sample:: bluetooth_bap_broadcast_sink
:name: Broadcast Audio Sink
:relevant-api: bluetooth
:name: Basic Audio Profile (BAP) Broadcast Audio Sink
:relevant-api: bluetooth bt_audio bt_bap bt_conn bt_pacs

Use LE Audio Broadcast Sink functionality.
Use BAP Broadcast Sink functionality.

Overview
********

Application demonstrating the LE Audio broadcast sink functionality.
Starts by scanning for LE Audio broadcast sources and then synchronizes to
Application demonstrating the BAP Broadcast Sink functionality.
Starts by scanning for BAP Broadcast Sources and then synchronizes to
the first found and listens to it until the source is (potentially) stopped.

This sample can be found under
Expand Down
25 changes: 23 additions & 2 deletions samples/bluetooth/bap_broadcast_sink/src/main.c
Original file line number Diff line number Diff line change
@@ -1,22 +1,43 @@
/*
* Copyright (c) 2022-2023 Nordic Semiconductor ASA
* Copyright (c) 2022-2024 Nordic Semiconductor ASA
* Copyright (c) 2024 Demant A/S
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <ctype.h>
#include <errno.h>
#include <stdint.h>
#include <string.h>
#include <strings.h>

#include <zephyr/autoconf.h>
#include <zephyr/bluetooth/addr.h>
#include <zephyr/bluetooth/audio/lc3.h>
#include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/bluetooth/audio/audio.h>
#include <zephyr/bluetooth/audio/bap.h>
#include <zephyr/bluetooth/audio/pacs.h>
#include <zephyr/bluetooth/conn.h>
#include <zephyr/bluetooth/gap.h>
#include <zephyr/bluetooth/hci.h>
#include <zephyr/bluetooth/hci_types.h>
#include <zephyr/bluetooth/iso.h>
#include <zephyr/bluetooth/uuid.h>
#include <zephyr/kernel.h>
#include <zephyr/net_buf.h>
#include <zephyr/sys/byteorder.h>
#include <zephyr/sys/printk.h>
#include <zephyr/sys/util.h>
#include <zephyr/sys/util_macro.h>
#include <zephyr/sys_clock.h>
#include <zephyr/toolchain.h>

#if defined(CONFIG_LIBLC3)
#include "lc3.h"
#endif /* defined(CONFIG_LIBLC3) */
#if defined(CONFIG_USB_DEVICE_AUDIO)
#include <zephyr/device.h>
#include <zephyr/devicetree.h>
#include <zephyr/usb/usb_device.h>
#include <zephyr/usb/class/usb_audio.h>
#include <zephyr/sys/ring_buffer.h>
Expand Down
12 changes: 6 additions & 6 deletions samples/bluetooth/bap_broadcast_source/README.rst
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
.. zephyr:code-sample:: bluetooth_bap_broadcast_source
:name: Broadcast Audio Source
:relevant-api: bluetooth
:name: Basic Audio Profile (BAP) Broadcast Audio Source
:relevant-api: bluetooth bt_audio bt_bap

Use LE Audio Broadcast Source functionality.
Use BAP Broadcast Source functionality.

Overview
********

Application demonstrating the LE Audio broadcast audio source functionality.
Application demonstrating the BAP Broadcast Source functionality.
Will start advertising extended advertising with audio flags, periodic advertising with the
broadcast audio source endpoint (BASE) and finally the BIGinfo together with
Broadcast Audio Source Endpoint (BASE) and finally the BIGinfo together with
(mock) Audio (ISO) data.

The broadcast source will reset every 30 seconds to show the full API.
The BAP Broadcast Source will reset every 30 seconds to show the full API.

This sample can be found under
:zephyr_file:`samples/bluetooth/bap_broadcast_source` in the Zephyr tree.
Expand Down
22 changes: 20 additions & 2 deletions samples/bluetooth/bap_broadcast_source/src/main.c
Original file line number Diff line number Diff line change
@@ -1,13 +1,31 @@
/*
* Copyright (c) 2022-2023 Nordic Semiconductor ASA
* Copyright (c) 2022-2024 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/bluetooth/bluetooth.h>
#include <errno.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>

#include <zephyr/autoconf.h>
#include <zephyr/bluetooth/audio/audio.h>
#include <zephyr/bluetooth/audio/bap.h>
#include <zephyr/bluetooth/audio/bap_lc3_preset.h>
#include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/bluetooth/byteorder.h>
#include <zephyr/bluetooth/gap.h>
#include <zephyr/bluetooth/iso.h>
#include <zephyr/bluetooth/uuid.h>
#include <zephyr/device.h>
#include <zephyr/devicetree.h>
#include <zephyr/kernel.h>
#include <zephyr/net_buf.h>
#include <zephyr/sys/printk.h>
#include <zephyr/sys/util.h>
#include <zephyr/sys_clock.h>
#include <zephyr/toolchain.h>

BUILD_ASSERT(strlen(CONFIG_BROADCAST_CODE) <= BT_AUDIO_BROADCAST_CODE_SIZE,
"Invalid broadcast code");
Expand Down
10 changes: 5 additions & 5 deletions samples/bluetooth/bap_unicast_client/README.rst
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
.. zephyr:code-sample:: bluetooth_bap_unicast_client
:name: Unicast Audio Client
:relevant-api: bt_bap bt_audio
:name: Basic Audio Profile (BAP) Unicast Audio Client
:relevant-api: bluetooth bt_audio bt_bap bt_conn

Use LE Audio Unicast Client functionality.
Use BAP Unicast Client functionality.

Overview
********

Application demonstrating the LE Audio unicast client functionality. Scans for and
connects to a LE Audio unicast server and establishes an audio stream.
Application demonstrating the BAP Unicast Client functionality. Scans for and
connects to a BAP Unicast Server and establishes an audio stream.

This sample can be found under
:zephyr_file:`samples/bluetooth/bap_unicast_client` in the Zephyr tree.
Expand Down
17 changes: 16 additions & 1 deletion samples/bluetooth/bap_unicast_client/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,32 @@
* SPDX-License-Identifier: Apache-2.0
*/

#include <stddef.h>
#include <errno.h>
#include <inttypes.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>

#include <zephyr/autoconf.h>
#include <zephyr/bluetooth/addr.h>
#include <zephyr/bluetooth/att.h>
#include <zephyr/bluetooth/audio/audio.h>
#include <zephyr/bluetooth/audio/bap.h>
#include <zephyr/bluetooth/audio/bap_lc3_preset.h>
#include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/bluetooth/conn.h>
#include <zephyr/bluetooth/gap.h>
#include <zephyr/bluetooth/gatt.h>
#include <zephyr/bluetooth/hci.h>
#include <zephyr/bluetooth/hci_types.h>
#include <zephyr/bluetooth/iso.h>
#include <zephyr/bluetooth/uuid.h>
#include <zephyr/kernel.h>
#include <zephyr/net_buf.h>
#include <zephyr/sys/__assert.h>
#include <zephyr/sys/byteorder.h>
#include <zephyr/sys/printk.h>
#include <zephyr/sys/util.h>
#include <zephyr/sys/util_macro.h>
#include <zephyr/types.h>

Expand Down
2 changes: 2 additions & 0 deletions samples/bluetooth/bap_unicast_client/src/stream_tx.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#ifndef STREAM_TX_H
#define STREAM_TX_H

#include <stdint.h>

#include <zephyr/bluetooth/conn.h>
#include <zephyr/bluetooth/audio/bap.h>
#include <zephyr/bluetooth/audio/cap.h>
Expand Down
10 changes: 5 additions & 5 deletions samples/bluetooth/bap_unicast_server/README.rst
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
.. zephyr:code-sample:: bluetooth_bap_unicast_server
:name: Unicast Audio Server
:relevant-api: bt_bap bt_audio
:name: Basic Audio Profile (BAP) Unicast Audio Server
:relevant-api: bluetooth bt_audio bt_bap bt_pacs

Use LE Audio Unicast Server functionality.
Use BAP Unicast Server functionality.

Overview
********

Application demonstrating the LE Audio unicast server functionality.
Starts advertising and awaits connection from a LE Audio unicast client.
Application demonstrating the BAP Unicast Server functionality.
Starts advertising and awaits connection from a BAP Unicast Client.

This sample can be found under
:zephyr_file:`samples/bluetooth/bap_unicast_server` in the Zephyr tree.
Expand Down
30 changes: 22 additions & 8 deletions samples/bluetooth/bap_unicast_server/src/main.c
Original file line number Diff line number Diff line change
@@ -1,22 +1,36 @@
/*
* Copyright (c) 2021-2023 Nordic Semiconductor ASA
* Copyright (c) 2021-2024 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/types.h>
#include <stddef.h>
#include <errno.h>
#include <zephyr/kernel.h>
#include <zephyr/sys/printk.h>
#include <stddef.h>
#include <stdint.h>

#include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/bluetooth/byteorder.h>
#include <zephyr/bluetooth/conn.h>
#include <zephyr/autoconf.h>
#include <zephyr/bluetooth/addr.h>
#include <zephyr/bluetooth/audio/audio.h>
#include <zephyr/bluetooth/audio/bap.h>
#include <zephyr/bluetooth/audio/lc3.h>
#include <zephyr/bluetooth/audio/pacs.h>
#include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/bluetooth/byteorder.h>
#include <zephyr/bluetooth/conn.h>
#include <zephyr/bluetooth/gap.h>
#include <zephyr/bluetooth/hci.h>
#include <zephyr/bluetooth/hci_types.h>
#include <zephyr/bluetooth/iso.h>
#include <zephyr/bluetooth/uuid.h>
#include <zephyr/kernel.h>
#include <zephyr/net_buf.h>
#include <zephyr/sys/__assert.h>
#include <zephyr/sys/byteorder.h>
#include <zephyr/sys/printk.h>
#include <zephyr/sys/util.h>
#include <zephyr/sys/util_macro.h>
#include <zephyr/sys_clock.h>
#include <zephyr/types.h>

#define AVAILABLE_SINK_CONTEXT (BT_AUDIO_CONTEXT_TYPE_UNSPECIFIED | \
BT_AUDIO_CONTEXT_TYPE_CONVERSATIONAL | \
Expand Down
4 changes: 2 additions & 2 deletions samples/bluetooth/cap_acceptor/README.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.. zephyr:code-sample:: bluetooth_cap_acceptor
:name: Common Audio Profile Acceptor
:relevant-api: bt_cap bt_bap bluetooth
:name: Common Audio Profile (CAP) Acceptor
:relevant-api: bluetooth bt_audio bt_bap bt_cap bt_pacs

Advertise audio availability to CAP Initiators using the CAP Acceptor role.

Expand Down
2 changes: 2 additions & 0 deletions samples/bluetooth/cap_acceptor/src/cap_acceptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* SPDX-License-Identifier: Apache-2.0
*/

#include <stdint.h>

#include <zephyr/bluetooth/audio/audio.h>
#include <zephyr/bluetooth/audio/cap.h>
#include <zephyr/bluetooth/conn.h>
Expand Down
1 change: 1 addition & 0 deletions samples/bluetooth/cap_acceptor/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <zephyr/bluetooth/byteorder.h>
#include <zephyr/bluetooth/conn.h>
#include <zephyr/bluetooth/gap.h>
#include <zephyr/bluetooth/hci.h>
#include <zephyr/bluetooth/hci_types.h>
#include <zephyr/bluetooth/uuid.h>
#include <zephyr/kernel.h>
Expand Down
4 changes: 2 additions & 2 deletions samples/bluetooth/cap_initiator/README.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.. zephyr:code-sample:: bluetooth_cap_initiator
:name: Common Audio Profile Initiator
:relevant-api: bt_cap bt_bap bluetooth
:name: Common Audio Profile (CAP) Initiator
:relevant-api: bluetooth bt_bap bt_cap bt_conn

Connect to CAP Acceptors and setup unicast audio streaming or broadcast audio streams.

Expand Down
8 changes: 8 additions & 0 deletions samples/bluetooth/cap_initiator/src/cap_initiator_broadcast.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,22 @@
* SPDX-License-Identifier: Apache-2.0
*/

#include <stddef.h>
#include <stdint.h>

#include <zephyr/bluetooth/audio/audio.h>
#include <zephyr/bluetooth/audio/bap_lc3_preset.h>
#include <zephyr/bluetooth/audio/cap.h>
#include <zephyr/bluetooth/audio/bap.h>
#include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/bluetooth/gap.h>
#include <zephyr/bluetooth/uuid.h>
#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
#include <zephyr/logging/log_core.h>
#include <zephyr/net_buf.h>
#include <zephyr/sys/byteorder.h>
#include <zephyr/sys/util.h>
#include <zephyr/types.h>

#include "cap_initiator.h"
Expand Down
Loading

0 comments on commit d9d428e

Please sign in to comment.