Skip to content

Commit b7c6e21

Browse files
alexsvenrlubos
authored andcommitted
applications: nrf5340_audio: Multi-channel support unicast client
Changed when and how a client discovers a server. Changed how a unicast group is created. Added new ZBUS messages for Bluetooth LE events. Now using CIS and CIG ID from the host. Added server_store for handling unicast servers/headsets Bonds will created a server entry in server_store. Added test framework for server_store. Prints and docs changed. OCT-3290 Signed-off-by: Alexander Svensen <[email protected]> Signed-off-by: Kristoffer Skøien <[email protected]>
1 parent 64ea52b commit b7c6e21

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+5025
-1366
lines changed

applications/nrf5340_audio/Kconfig.defaults

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ config MAIN_STACK_SIZE
1515
default 1600
1616

1717
config SYSTEM_WORKQUEUE_STACK_SIZE
18-
default 1200
18+
default 2000
1919

2020
# As long as thread names are used, config must be set to "y"
2121
config THREAD_NAME

applications/nrf5340_audio/broadcast_sink/README.rst

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ The following limitations apply to this application:
1515
* One BIG, one of the two BIS streams or a mixed stereo comprising of the two (selectable).
1616
See :file:`overlay-broadcast_sink.conf` for more information.
1717
* Audio output: I2S/Analog headset output.
18-
* Configuration: 16 bit, several bit rates ranging from 32 kbps to 124 kbps.
18+
* Configuration: 16-bit, several bit rates ranging from 32 kbps to 124 kbps.
1919

2020
.. _nrf53_audio_broadcast_sink_app_requirements:
2121

@@ -68,6 +68,18 @@ For other configuration options, see :ref:`nrf53_audio_app_configuration` and :r
6868

6969
For information about how to configure applications in the |NCS|, see :ref:`configure_application`.
7070

71+
.. _nrf53_audio_broadcast_sink_app_configuration_stereo:
72+
73+
Stereo configuration
74+
====================
75+
76+
The broadcast sink can receive audio from two BISes and play it on the left and right channels of the audio output.
77+
In this mode, the I2S output is stereo, but :zephyr:board:`nrf5340_audio_dk` still only has one audio output channel, since it has a mono codec (CS47L63).
78+
79+
To configure stereo, program the :ref:`correct headset location <nrf53_audio_app_configuration_headset_location>` for each headset.
80+
81+
See also :file:`overlay-broadcast_sink.conf` for more information.
82+
7183
.. _nrf53_audio_broadcast_sink_app_building:
7284

7385
Building and running

applications/nrf5340_audio/broadcast_source/README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ Play and pause are emulated by enabling and disabling stream, respectively.
1515
The following limitations apply to this application:
1616

1717
* One BIG with two BIS streams.
18-
* Audio input: USB or I2S (Line in or using Pulse Density Modulation).
19-
* Configuration: 16 bit, several bit rates ranging from 32 kbps to 124 kbps.
18+
* Audio input: USB or I2S (Line-in or using Pulse Density Modulation).
19+
* Configuration: 16-bit, several bit rates ranging from 32 kbps to 124 kbps.
2020

2121
.. _nrf53_audio_broadcast_source_app_requirements:
2222

applications/nrf5340_audio/doc/adapting_application.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ Adapting nRF5340 Audio applications for end products
99

1010
This page describes the relevant configuration sources and lists the steps required for adapting the :ref:`nrf53_audio_app` to end products.
1111

12+
.. note::
13+
14+
Addresses and other sensitive information are printed for debug purposes.
15+
This information must not be exposed in a final product.
16+
1217
Board configuration sources
1318
***************************
1419

applications/nrf5340_audio/doc/audio_api.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,14 @@ Bluetooth Audio Rendering and Capture
7272
7373
.. doxygengroup:: audio_app_bt_rendering_and_capture
7474

75+
Bluetooth Content Control
76+
*************************
77+
78+
| Header file: :file:`applications/nrf5340_audio/src/bluetooth/bt_content_control/bt_content_ctrl.h`
79+
| Source file: :file:`applications/nrf5340_audio/src/bluetooth/bt_content_control/bt_content_ctrl.c`
80+
81+
.. doxygengroup:: audio_app_bt_content_ctrl
82+
7583
Audio I2S
7684
*********
7785

applications/nrf5340_audio/doc/building.rst

Lines changed: 42 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ When preparing the JSON file, update the following fields:
6868
You can check this ten-digit number on the sticker on the nRF5340 Audio development kit.
6969
Alternatively, connect the development kit to your PC and run ``nrfutil device list`` in a command window to print the SEGGER serial number of all connected kits.
7070
* ``nrf5340_audio_dk_dev`` - This field assigns the specific nRF5340 Audio development kit to be ``headset`` or ``gateway``.
71-
* ``channel`` - This field is valid only for headsets.
72-
It sets the channels on which the headset is meant to work.
73-
When no channel is set, the headset is programmed as a left channel one.
71+
* ``location`` - This field is valid only for headsets.
72+
It sets the location on which the headset is meant to work, especially when using the :ref:`default CIS transport mode configuration <nrf53_audio_transport_mode_configuration>`.
73+
For more information, see :ref:`nrf53_audio_app_configuration_headset_location`.
7474

7575
.. _nrf53_audio_app_building_script_running:
7676

@@ -226,14 +226,14 @@ Application configuration files
226226
===============================
227227

228228
The application uses a :file:`prj.conf` configuration file located in the sample root directory for the default configuration.
229-
It also provides additional files for different custom configurations.
229+
It also uses application-specific overlay files and can use additional files for different custom configurations.
230230
When you build the sample, you can select one of these configurations using the :makevar:`FILE_SUFFIX` variable.
231231

232-
See :ref:`app_build_file_suffixes` and :ref:`cmake_options` for more information.
232+
See :ref:`nrf53_audio_app_configuration_files`, :ref:`app_build_file_suffixes`, and :ref:`cmake_options` for more information.
233233

234-
The application supports the following custom configurations:
234+
The application supports the following configuration files:
235235

236-
.. list-table:: Application custom configurations
236+
.. list-table:: Application configurations
237237
:widths: auto
238238
:header-rows: 1
239239

@@ -252,8 +252,24 @@ The application supports the following custom configurations:
252252
* - FOTA DFU
253253
- :file:`prj_fota.conf`
254254
- ``fota``
255-
- | Builds the debug version of the application with the features needed to perform DFU over Bluetooth LE, and includes bootloaders so that the applications on both the application core and network core can be updated.
255+
- | Builds the debug version of the application (:file:`prj.conf`) with the features needed to perform DFU over Bluetooth LE, and includes bootloaders so that the applications on both the application core and network core can be updated.
256256
| See :ref:`nrf53_audio_app_fota` for more information.
257+
* - Application-specific overlay file
258+
- :file:`unicast_server/overlay-unicast_server.conf`
259+
- ``unicast_server``
260+
- Configuration file for the unicast server application.
261+
* - Application-specific overlay file
262+
- :file:`unicast_client/overlay-unicast_client.conf`
263+
- ``unicast_client``
264+
- Configuration file for the unicast client application.
265+
* - Application-specific overlay file
266+
- :file:`broadcast_sink/overlay-broadcast_sink.conf`
267+
- ``broadcast_sink``
268+
- Configuration file for the broadcast sink application.
269+
* - Application-specific overlay file
270+
- :file:`broadcast_source/overlay-broadcast_source.conf`
271+
- ``broadcast_source``
272+
- Configuration file for the broadcast source application.
257273

258274
.. _nrf53_audio_app_configuration_select_build:
259275

@@ -302,25 +318,35 @@ The following command example builds the application for :ref:`nrf53_audio_app_f
302318
The command uses ``-DFILE_SUFFIX=fota`` to pick :file:`prj_fota.conf` instead of the default :file:`prj.conf`.
303319
It also uses the ``--pristine`` to clean the existing directory before starting the build process.
304320

321+
.. _nrf53_audio_app_building_standard_programming:
322+
305323
Programming the application
306324
===========================
307325

308326
After building the files for the development kit you want to program, follow the :ref:`standard procedure for programming applications <building>` in the |NCS|.
309327

310-
When using the default CIS configuration, if you want to use two headset devices, you must also populate the UICR with the desired channel for each headset.
311-
Use the following commands, depending on which headset you want to populate:
328+
When using the :ref:`default CIS transport mode configuration <nrf53_audio_transport_mode_configuration>`, if you want to use two headset devices or the stereo configuration, you must :ref:`configure the headset location <nrf53_audio_app_configuration_headset_location>`.
329+
Use the combined bitfield values, depending on which headset you want to configure:
312330

313-
* Left headset (``--value 0``):
331+
* Two headsets, left and right:
314332

315-
.. code-block:: console
333+
* Left headset (``--value 1``):
316334

317-
nrfutil device x-write --address 0x00FF80F4 --value 0
335+
.. code-block:: console
318336
319-
* Right headset (``--value 1``):
337+
nrfutil device x-write --address 0x00FF80F4 --value 1
320338
321-
.. code-block:: console
339+
* Right headset (``--value 2``):
340+
341+
.. code-block:: console
342+
343+
nrfutil device x-write --address 0x00FF80F4 --value 2
344+
345+
* One stereo headset (``--value 3``):
346+
347+
.. code-block:: console
322348
323-
nrfutil device x-write --address 0x00FF80F4 --value 1
349+
nrfutil device x-write --address 0x00FF80F4 --value 3
324350
325351
Select the correct board when prompted with the popup.
326352
Alternatively, you can add the ``--serial-number`` parameter followed by the SEGGER serial number of the correct board at the end of the ``nrfutil device`` command.

applications/nrf5340_audio/doc/configuration.rst

Lines changed: 73 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ The nRF5340 Audio applications align the configuration with the nRF5340 Audio us
1515
Among others, the Kconfig options for Bluetooth, Zephyr's audio subsystems, and hardware peripherals are selected to ensure they are enabled.
1616

1717
The :option:`CONFIG_NRF5340_AUDIO` option is the main Kconfig option that activates all nRF5340 Audio functionality.
18-
See the :file:`Kconfig.defaults` file for details related to the default common configuration.
18+
See the :file:`Kconfig.defaults` file in the :file:`nrf5340_audio` directory for details related to the default common configuration.
1919

2020
.. note::
2121
Part of the default configuration is applied by modifying the default values of Kconfig options.
@@ -80,7 +80,7 @@ Enabling the walkie-talkie demo
8080

8181
The walkie-talkie demo uses one or two bidirectional streams from the gateway to one or two headsets.
8282
The PDM microphone is used as input on both the gateway and headset device.
83-
To switch to using the walkie-talkie, set the :option:`CONFIG_WALKIE_TALKIE_DEMO` Kconfig option to ``y`` in the :file:`applications/nrf5340_audio/prj.conf` file (for the debug version) or in the :file:`applications/nrf5340_audio/prj_release.conf` file (for the release version).
83+
To switch to using the walkie-talkie, set the :option:`CONFIG_WALKIE_TALKIE_DEMO` Kconfig option to ``y`` in the :file:`applications/nrf5340_audio/prj.conf` file (for the debug version) or in the :file:`applications/nrf5340_audio/prj_release.conf` file (for the release version).
8484

8585
Enabling the Auracast™ (broadcast) mode
8686
=======================================
@@ -93,7 +93,7 @@ Enabling the BIS mode with two gateways
9393
=======================================
9494

9595
In addition to the standard BIS mode with one gateway, you can also add a second gateway device.
96-
The BIS headsets can then switch between the two gateways and receive audio stream from one of the two gateways.
96+
The BIS headsets can then switch between the two gateways and receive the audio stream from one of the two gateways.
9797

9898
To configure the second gateway, add both the :option:`CONFIG_TRANSPORT_BIS` and the :option:`CONFIG_BT_AUDIO_USE_BROADCAST_NAME_ALT` Kconfig options set to ``y`` to the :file:`applications/nrf5340_audio/prj.conf` file for the debug version and to the :file:`applications/nrf5340_audio/prj_release.conf` file for the release version.
9999
You can provide an alternative name to the second gateway using the :option:`CONFIG_BT_AUDIO_BROADCAST_NAME_ALT` or use the default alternative name.
@@ -102,6 +102,62 @@ You build each BIS gateway separately using the normal procedures from :ref:`nrf
102102
After building the first gateway, configure the required Kconfig options for the second gateway and build the second gateway firmware.
103103
Remember to program the two firmware versions to two separate gateway devices.
104104

105+
.. _nrf53_audio_app_configuration_headset_location:
106+
107+
Configuring the headset location
108+
================================
109+
110+
When using the :ref:`default CIS transport mode configuration <nrf53_audio_transport_mode_configuration>`, if you want to use two headset devices or the stereo configuration, you must also define the correct headset location.
111+
112+
The nRF5340 Audio applications use audio location definitions from the Audio Location Definition chapter in the `Bluetooth Assigned Numbers`_ specification.
113+
These correspond to the bitfields in the :file:`bt_audio_location` enum in the :file:`zephyr/include/zephyr/bluetooth/assigned_numbers.h` file.
114+
When building the audio application, the location value is used to populate the UICR with the correct bitfield for each headset.
115+
116+
You can set the location for each headset in the following ways, depending on the building and programming method:
117+
118+
* When :ref:`nrf53_audio_app_building_script`, set the location for each headset in the :file:`nrf5340_audio_dk_devices.json` file.
119+
Use the location labels from the Audio Location Definition chapter in the `Bluetooth Assigned Numbers`_ specification.
120+
For example:
121+
122+
.. code-block:: json
123+
124+
[
125+
{
126+
"nrf5340_audio_dk_snr": 1000,
127+
"nrf5340_audio_dk_dev": "headset",
128+
"location": ["FRONT_LEFT"]
129+
}
130+
]
131+
132+
* When :ref:`nrf53_audio_app_building_standard`, set the location for each headset when running the :ref:`programming command <nrf53_audio_app_building_standard_programming>`.
133+
Use the combined bitfield values from the :file:`zephyr/include/zephyr/bluetooth/assigned_numbers.h` file to define the headset location.
134+
For example, if you want to use the stereo configuration, use the combined bitfield value of the left and right channels (``1`` and ``2``, respectively):
135+
136+
.. code-block:: console
137+
138+
nrfutil device x-write --address 0x00FF80F4 --value 3
139+
140+
The following table lists some of the available locations and their bitfield values:
141+
142+
.. list-table:: Example audio locations and their bitfield values
143+
:header-rows: 1
144+
145+
* - Audio location
146+
- Value from specification
147+
- Bitfield value
148+
* - Mono Audio
149+
- ``0x00000000``
150+
- n/a
151+
* - ``"FRONT_LEFT"``
152+
- ``0x00000001``
153+
- ``0``
154+
* - ``"FRONT_RIGHT"``
155+
- ``0x00000002``
156+
- ``1``
157+
* - Stereo
158+
- n/a
159+
- ``3`` (``0`` and ``1`` set)
160+
105161
.. _nrf53_audio_source_configuration:
106162

107163
Configuring the audio source
@@ -116,7 +172,7 @@ The audio source is selected using the following Kconfig options:
116172
* I2S audio source (:option:`CONFIG_AUDIO_SOURCE_I2S`) - Uses 3.5 mm jack analog input using I2S
117173

118174
In the default configuration, the gateway application uses USB as the audio source.
119-
The :ref:`nrf53_audio_app_building` and the testing steps also refer to using the USB serial connection.
175+
The :ref:`nrf53_audio_app_building` and testing steps also refer to using the USB serial connection.
120176

121177
The audio source selection affects the firmware architecture and available features.
122178
USB audio source is limited to unidirectional streams due to CPU load considerations, while I2S supports bidirectional communication.
@@ -172,6 +228,19 @@ These options configure the Bluetooth stack components described in :ref:`nrf53_
172228

173229
See :ref:`config_audio_app_options` for options starting with ``CONFIG_BT_AUDIO``.
174230

231+
.. _nrf53_audio_app_configuration_power_measurements:
232+
233+
Configuring power measurements
234+
******************************
235+
236+
The power measurements are disabled by default in the :ref:`debug version <nrf53_audio_app_overview_files>` of the application.
237+
238+
.. note::
239+
Enabling power measurements in the debug version together with :ref:`debug logging <ug_logging>` increases the power consumption compared with the release version of the application.
240+
For better results, consider using the `Power Profiler Kit II (PPK2)`_ and the `Power Profiler app`_ from nRF Connect for Desktop to measure the power consumption.
241+
242+
To enable power measurements in the debug version, set the :kconfig:option:`CONFIG_NRF5340_AUDIO_POWER_MEASUREMENT` Kconfig option to ``y`` in the :file:`applications/nrf5340_audio/prj.conf` file.
243+
175244
.. _nrf53_audio_app_configuration_sd_card_playback:
176245

177246
Enabling SD card playback

0 commit comments

Comments
 (0)