Initial commit for nrf_auraconfig

This commit is contained in:
2024-11-26 17:51:52 +01:00
commit 310abbc8c3
10 changed files with 3934 additions and 0 deletions

6
.gitignore vendored Normal file
View File

@@ -0,0 +1,6 @@
# editors
*.swp
*~
# build
/build*/

31
CMakeLists.txt Normal file
View File

@@ -0,0 +1,31 @@
#
# Copyright (c) 2024 Nordic Semiconductor
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#
cmake_minimum_required(VERSION 3.20.0)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(nrf_auraconfig)
# Include application events and configuration headers
zephyr_library_include_directories(app PRIVATE
${ZEPHYR_NRF_MODULE_DIR}/samples/bluetooth/nrf_auraconfig/include
${ZEPHYR_NRF_MODULE_DIR}/applications/nrf5340_audio/include
${ZEPHYR_NRF_MODULE_DIR}/applications/nrf5340_audio/src/bluetooth
${ZEPHYR_NRF_MODULE_DIR}/applications/nrf5340_audio/src/modules
${ZEPHYR_NRF_MODULE_DIR}/applications/nrf5340_audio/src/utils/macros
)
add_subdirectory(${ZEPHYR_NRF_MODULE_DIR}/applications/nrf5340_audio/src/bluetooth bluetooth_build)
target_sources(app PRIVATE ${ZEPHYR_NRF_MODULE_DIR}/applications/nrf5340_audio/src/modules/audio_sync_timer.c)
target_sources(app PRIVATE ${ZEPHYR_NRF_MODULE_DIR}/applications/nrf5340_audio/src/modules/led.c)
target_sources_ifdef(CONFIG_NRF5340_AUDIO_SD_CARD_MODULE app PRIVATE ${ZEPHYR_NRF_MODULE_DIR}/applications/nrf5340_audio/src/modules/sd_card.c)
target_sources_ifdef(CONFIG_NRF5340_AUDIO_SD_CARD_LC3_FILE app PRIVATE ${ZEPHYR_NRF_MODULE_DIR}/applications/nrf5340_audio/src/modules/lc3_file.c)
target_sources_ifdef(CONFIG_NRF5340_AUDIO_SD_CARD_LC3_STREAMER app PRIVATE ${ZEPHYR_NRF_MODULE_DIR}/applications/nrf5340_audio/src/modules/lc3_streamer.c)
FILE(GLOB app_sources src/*.c)
target_sources(app PRIVATE ${app_sources})

36
Kconfig Normal file
View File

@@ -0,0 +1,36 @@
#
# Copyright (c) 2024 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#
rsource "${ZEPHYR_NRF_MODULE_DIR}/applications/nrf5340_audio/src/audio/Kconfig"
rsource "${ZEPHYR_NRF_MODULE_DIR}/applications/nrf5340_audio/src/bluetooth/Kconfig"
rsource "${ZEPHYR_NRF_MODULE_DIR}/applications/nrf5340_audio/src/modules/Kconfig"
rsource "${ZEPHYR_NRF_MODULE_DIR}/applications/nrf5340_audio/src/utils/Kconfig"
#----------------------------------------------------------------------------#
config TRANSPORT_BIS
bool "Use BIS (Broadcast Isochronous Stream)"
config NRF_AURACONFIG
bool "nRF Auraconfig"
depends on TRANSPORT_BIS
select EXPERIMENTAL
default y
menu "Logging"
module = MAIN
module-str = main
source "subsys/logging/Kconfig.template.log_config"
config PRINT_STACK_USAGE_MS
depends on THREAD_ANALYZER && INIT_STACKS
int "Print stack usage every x milliseconds"
default 5000
endmenu # Log levels
source "Kconfig.zephyr"

10
Kconfig.sysbuild Normal file
View File

@@ -0,0 +1,10 @@
#
# Copyright (c) 2024 Nordic Semiconductor
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#
config NRF_DEFAULT_IPC_RADIO
default y
source "${ZEPHYR_BASE}/share/sysbuild/Kconfig"

816
README.rst Normal file
View File

@@ -0,0 +1,816 @@
.. _nrf_auraconfig:
nRF Auraconfig
##############
.. contents::
:local:
:depth: 2
The nRF Auraconfig sample implements the :ref:`BIS gateway mode <nrf53_audio_app_overview>` and may act as an `Auracast™`_ broadcaster if you are using a preset compatible with Auracast.
The sample features a shell interface that allows you to configure the broadcast source in many different ways.
In the BIS gateway mode, transmitting audio from the broadcast source happens using Broadcast Isochronous Stream (BIS) and Broadcast Isochronous Group (BIG).
.. note::
This sample is meant to be used with maximum two BIG with four BIS streams each.
.. _nrf_auraconfig_requirements:
Requirements
************
The sample supports only and exclusively the following development kits:
.. table-from-rows:: /includes/sample_board_rows.txt
:header: heading
:rows: nrf5340_audio_dk_nrf5340
.. note::
The sample supports PCA10121 revisions 1.0.0 or above.
The sample is also compatible with the following pre-launch revisions:
* Revisions 0.8.0 and above.
.. _nrf_auraconfig_ui:
Shell commands list
*******************
The nRF Auraconfig uses a shell interface for all user interactions.
This section lists the supported commands.
Description convention
======================
The command argument description uses the following convention:
* Angle brackets mean that an argument is mandatory:
.. parsed-literal::
:class: highlight
nac <*arg*>
* Square brackets mean that an argument is optional:
.. parsed-literal::
:class: highlight
nac [*arg*]
----
start
=====
Start the broadcaster with the current configuration.
If no configuration is set, the broadcaster will not start.
To view the current configuration, use the ``show`` command.
The optional argument sets the index of the BIG to start.
Usage:
.. code-block:: console
nac start [BIG_index]
Examples:
* The following commands starts any BIG that is configured:
.. code-block:: console
nac start
* The following command starts only the BIG 0:
.. code-block:: console
nac start 0
----
stop
====
Stop the broadcaster.
The optional argument sets the index of the BIG to stop.
Usage:
.. code-block:: console
nac stop [BIG_index]
Examples:
* The following commands stops any BIG that is running:
.. code-block:: console
nac stop
* The following command stops only the BIG 0:
.. code-block:: console
nac stop 0
----
show
====
Shows the configuration for the different BIGs that are currently configured.
Usage:
.. code-block:: console
nac show
Example output:
.. code-block:: console
BIG 0:
Streaming: false
Advertising name: Lecture hall
Broadcast name: Lecture
Packing: interleaved
Encryption: false
Broadcast code:
Subgroup 0:
Preset: 24_2_1
PHY: 2M
Framing: unframed
RTN: 2
SDU size: 60
Max Transport Latency: 10 ms
Frame Interval: 10000 us
Presentation Delay: 40000 us
Sampling rate: 24000 Hz
Bitrate: 48000 bps
Frame duration: 10000 us
Octets per frame: 60
Language: eng
Context(s):
Live
Program info: Mathematics 101
Immediate rendering flag: set
Number of BIS: 1
Location:
BIS 0: Mono Audio
----
file list
=========
Lists the files and directories in the given directory on the SD card.
If no directory is given, contents of the root directory is listed.
Usage:
.. code-block:: console
nac file list [directory]
Example output:
.. code-block:: console
nac file list
[DIR ] 16000hz
[DIR ] 24000hz
[DIR ] 32000hz
[FILE] left-channel-announcement.wav
[FILE] right-channel-announcement.wav
----
file select
===========
Selects a file from the SD card to be used as the audio source for the given stream.
The file must be in the LC3 format, and one file may be used for multiple streams at the same time.
Usage:
.. code-block:: console
nac file select <file> <BIG index> <subgroup index> <BIS index>
Example:
.. code-block:: console
nac file select 16000hz/24_kbps/left-channel-announcement_16kHz_left_24kbps.lc3 1 2 0
This command selects the file :file:`16000hz/24_kbps/left-channel-announcement_16kHz_left_24kbps.lc3` for the BIS 0 in the subgroup 2 in the BIG 1.
----
packing
=======
Set the type of packing for the BIS streams, either sequential or interleaved.
Usage:
.. code-block:: console
nac packing <seq/int> <BIG index>
Example:
.. code-block:: console
nac packing int 0
This command sets the packing for the BIG 0 to interleaved.
----
preset
======
Set the BAP preset for a BIG or subgroup.
The presets are defined in the `Basic Audio Profile specification`_.
The supported presets can be listed with the ``nac preset print`` command.
Usage:
.. code-block:: console
nac preset <preset> <BIG index> [subgroup index]
Examples:
* The following command sets the preset for the BIG 0 to ``24_2_1``:
.. code-block:: console
nac preset 24_2_1 0
* The following command sets the preset for the subgroup 0 in the BIG 0 to ``24_2_1``:
.. code-block:: console
nac preset 24_2_1 0 0
----
lang
====
Set the language metadata for a subgroup.
Usage:
.. code-block:: console
nac lang <language> <BIG index> <Subgroup index>
The ``language`` argument is a three-letter `ISO 639-2 code`_.
Example:
.. code-block:: console
nac lang eng 0 0
This command sets the language for the subgroup 0 in the BIG 0 to English.
----
immediate
=========
Set the immediate rendering flag for a subgroup.
Usage:
.. code-block:: console
nac immediate <0/1> <BIG index> <Subgroup index>
Example:
.. code-block:: console
nac immediate 1 0 0
This command sets the immediate rendering flag for the subgroup 0 in the BIG 0 to ``true``.
----
num_subgroups
=============
Set the number of subgroups for a BIG.
The maximum number of subgroups for each BIG is set by :kconfig:option:`CONFIG_BT_BAP_BROADCAST_SRC_SUBGROUP_COUNT`.
Usage:
.. code-block:: console
nac num_subgroups <number> <BIG index>
Example:
.. code-block:: console
nac num_subgroups 2 0
This command sets the number of subgroups for the BIG 0 to 2.
----
num_bises
=========
Set the number of BISes for a given subgroup.
The maximum number of BISes for each subgroup is set by :kconfig:option:`CONFIG_BT_BAP_BROADCAST_SRC_STREAM_COUNT`.
Usage:
.. code-block:: console
nac num_bises <number> <BIG index> <Subgroup index>
Example:
.. code-block:: console
nac num_bises 2 0 0
This command sets the number of BISes for the subgroup 0 in the BIG 0 to 2.
----
context
=======
Sets the context metadata for a subgroup.
The supported contexts can be listed with the ``nac context print`` command.
Usage:
.. code-block:: console
nac context <context> <BIG index> <Subgroup index>
Example:
.. code-block:: console
nac context Media 0 0
This command sets the context for the subgroup 0 in the BIG 0 to Media.
----
location
========
Set the location metadata for a BIS.
The supported locations can be listed with the ``nac location print`` command.
Usage:
.. code-block:: console
nac location <location> <BIG index> <Subgroup index> <BIS index>
Example:
.. code-block:: console
nac location fl 0 0 0
This command sets the location for the BIS 0 in the subgroup 0 in the BIG 0 to Front Left.
----
broadcast_name
==============
Set the broadcast name metadata for a BIG.
Usage:
.. code-block:: console
nac broadcast_name <name> <BIG index>
Examples:
* The following command sets the broadcast name for the BIG 0 to ``Lecture``:
.. code-block:: console
nac broadcast_name Lecture 0
* The following command uses quotation marks for a longer name with spaces:
.. code-block:: console
nac broadcast_name "Lecture hall" 0
----
encrypt
=======
Set the broadcast code by enabling or disabling encryption for a given BIG.
The broadcast code is a 16-character string that is used to encrypt the broadcast, but shorter codes are also possible.
Usage:
.. code-block:: console
nac encrypt <0/1> <BIG index> [broadcast_code]
Examples:
* The following command enables encryption for the BIG 0 with the broadcast code "Auratest":
.. code-block:: console
nac encrypt 1 0 Auratest
* The following command disables encryption for the BIG 0 after setting it:
.. code-block:: console
nac encrypt 0 0
----
usecase
=======
Set a pre-defined use case.
A use case is a set of configurations that are commonly used together.
The command typically sets the number of subgroups, the number of BISes, the context, the location, and potentially metadata.
All pre-defined use cases can be listed with the ``nac usecase print`` command.
Usage:
.. code-block:: console
nac usecase <use_case>
The ``use_case`` argument can either be an index or the name of a use case.
Example:
.. code-block:: console
nac usecase 0
This command sets a unique configuration for the given use case and then calls ``show`` to display the configuration.
----
clear
=====
Clear any previous configuration.
Usage:
.. code-block:: console
nac clear
----
adv_name
========
Set the advertising name metadata for a BIG.
.. note::
Make sure each BIG has a unique advertising name.
Usage:
.. code-block:: console
nac adv_name <name> <BIG index>
The maximum length of the advertising name is given by :kconfig:option:`CONFIG_BT_DEVICE_NAME_MAX`.
Example:
.. code-block:: console
nac adv_name "Lecture hall" 0
This command sets the advertising name for the BIG 0 to "Lecture hall".
.. note::
The name must be enclosed in quotation marks if it contains spaces.
----
program_info
============
Set the program info metadata for a subgroup.
Usage:
.. code-block:: console
nac program_info <info> <BIG index> <Subgroup index>
Example:
.. code-block:: console
nac program_info "Mathematics 101" 0 0
This command sets the program info for the subgroup 0 in the BIG 0 to "Mathematics 101".
----
phy
===
Set the PHY for a BIG.
The supported PHY values are:
* ``1`` - 1M
* ``2`` - 2M
* ``4`` - Coded
Usage:
.. code-block:: console
nac phy <phy> <BIG index> <subgroup index>
Example:
.. code-block:: console
nac phy 2 0 0
This command sets the PHY for the subgroup 0 in the BIG 0 to 2M.
----
framing
=======
Set the framing for a subgroup.
Usage:
.. code-block:: console
nac framing <unframed/framed> <BIG index> <subgroup index>
Example:
.. code-block:: console
nac framing unframed 0 0
This command sets the framing for the subgroup 0 in the BIG 0 to ``unframed``.
----
rtn
===
Set the number of retransmits for a subgroup.
Usage:
.. code-block:: console
nac rtn <number> <BIG index> <subgroup index>
Example:
.. code-block:: console
nac rtn 2 0 0
This command sets the number of retransmits for the subgroup 0 in the BIG 0 to 2.
----
sdu
===
Set the Service Data Unit (SDU) size in octets for a subgroup.
.. note::
This command does not change the bitrate, only the size of the SDU.
Usage:
.. code-block:: console
nac sdu <octets> <BIG index> <subgroup index>
Example:
.. code-block:: console
nac sdu 60 0 0
This command sets the SDU size for the subgroup 0 in the BIG 0 to 60 octets.
----
mtl
===
Set the maximum transport latency for a subgroup, in milliseconds.
Usage:
.. code-block:: console
nac mtl <ms> <BIG index> <subgroup index>
Example:
.. code-block:: console
nac mtl 10 0 0
This command sets the maximum transport latency for the subgroup 0 in the BIG 0 to 10 ms.
----
frame_interval
==============
Set the frame interval for a subgroup, in microseconds.
The command supports the following values:
* 7500
* 10000
Usage:
.. code-block:: console
nac frame_interval <us> <BIG index> <subgroup index>
Example:
.. code-block:: console
nac frame_interval 10000 0 0
This command sets the frame interval for the subgroup 0 in the BIG 0 to 10 ms (10000 us).
----
pd
==
Set the presentation delay for a subgroup, in microseconds.
Usage:
.. code-block:: console
nac pd <us> <BIG index> <subgroup index>
Example:
.. code-block:: console
nac pd 40000 0 0
This command sets the presentation delay for the subgroup 0 in BIG0 to 40 ms (40000 us).
----
broadcast_id fixed
==================
Set a fixed broadcast ID for a BIG.
The broadcast ID is used to identify the broadcast.
Its value is three octets long.
Usage:
.. code-block:: console
nac broadcast_id fixed <BIG index> <broadcast_id in hexadecimal (3 octets)>
Examples:
.. code-block:: console
nac broadcast_id fixed 0 0xAA1234
This command sets a fixed broadcast ID for the BIG 0 to ``0xAA1234``.
This value will remain if the broadcast is stopped and started again.
----
broadcast_id random
===================
Set a random broadcast ID for a BIG.
The broadcast ID is used to identify the broadcast.
The broadcast ID will be generated anew every time the broadcaster is started.
Usage:
.. code-block:: console
nac broadcast_id random <BIG index>
Examples:
.. code-block:: console
nac broadcast_id random 0
This command sets a random broadcast ID for the BIG 0 each time it is started.
----
.. _nrf_auraconfig_configuration:
Configuration
*************
|config|
The sample is pre-configured with a generous default memory allocation, suitable for a wide range of use cases.
You can modify these default settings in the :file:`prj.conf` file.
Using aggressive configurations can reduce air time availability for all streams, depending on the combination of options selected (like high bitrates, increased re-transmits, specific PHY settings).
.. _nrf_auraconfig_configuration_sd:
SD card setup
*************
This sample can support pre-encoded LC3 data stored as LC3 files on an SD card.
You can use the `nRF Auracast configuration files`_ provided by Nordic Semiconductor for populating the SD-card.
If you are not using an SD card, the system defaults to sending dummy data.
The purpose of the dummy data is to test that the broadcast source has been correctly configured.
Make sure you format the SD card with a FAT file system.
.. _nrf_auraconfig_building:
Building and running
********************
.. |sample path| replace:: :file:`samples/bluetooth/nrf_auraconfig`
.. include:: /includes/build_and_run.txt
The nRF5340 Audio DK comes pre-programmed with basic firmware that indicates if the kit is functional.
See :ref:`nrf53_audio_app_dk_testing_out_of_the_box` for more information.
.. _nrf_auraconfig_testing:
Testing
*******
In this testing procedure, the development kit is programmed with the nRF Auraconfig sample.
To test the nRF Auraconfig sample, complete the following steps:
1. If you are using an :ref:`SD card loaded with the pre-encoded LC3 data <nrf_auraconfig_configuration_sd>`, insert it into your development kit.
#. Turn on the development kit.
#. Set up the serial connection with the development kit.
#. Configure a BIG using use case 1:
.. code-block:: console
nac usecase 1
#. Start the broadcaster:
.. code-block:: console
nac start
You can now send other shell commands, as listed in the :ref:`nrf_auraconfig_ui`.
Dependencies
************
For the list of dependencies, check the application's source files.

176
include/nrf_auraconfig.h Normal file
View File

@@ -0,0 +1,176 @@
/*
* Copyright (c) 2024 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/
#ifndef _NRF_AURACONFIG_H_
#define _NRF_AURACONFIG_H_
#include <zephyr/bluetooth/audio/audio.h>
#include <zephyr/bluetooth/audio/bap_lc3_preset.h>
#define PRESET_NAME_MAX 8
#define LANGUAGE_LEN 3
/* The location and context type will be set by further down */
/* Low latency settings */
static struct bt_bap_lc3_preset lc3_preset_8_1_1 =
BT_BAP_LC3_BROADCAST_PRESET_8_1_1(BT_AUDIO_LOCATION_MONO_AUDIO, BT_AUDIO_CONTEXT_TYPE_ANY);
static struct bt_bap_lc3_preset lc3_preset_8_2_1 =
BT_BAP_LC3_BROADCAST_PRESET_8_2_1(BT_AUDIO_LOCATION_MONO_AUDIO, BT_AUDIO_CONTEXT_TYPE_ANY);
static struct bt_bap_lc3_preset lc3_preset_16_1_1 =
BT_BAP_LC3_BROADCAST_PRESET_16_1_1(BT_AUDIO_LOCATION_MONO_AUDIO, BT_AUDIO_CONTEXT_TYPE_ANY);
static struct bt_bap_lc3_preset lc3_preset_16_2_1 =
BT_BAP_LC3_BROADCAST_PRESET_16_2_1(BT_AUDIO_LOCATION_MONO_AUDIO, BT_AUDIO_CONTEXT_TYPE_ANY);
static struct bt_bap_lc3_preset lc3_preset_24_1_1 =
BT_BAP_LC3_BROADCAST_PRESET_24_1_1(BT_AUDIO_LOCATION_MONO_AUDIO, BT_AUDIO_CONTEXT_TYPE_ANY);
static struct bt_bap_lc3_preset lc3_preset_24_2_1 =
BT_BAP_LC3_BROADCAST_PRESET_24_2_1(BT_AUDIO_LOCATION_MONO_AUDIO, BT_AUDIO_CONTEXT_TYPE_ANY);
static struct bt_bap_lc3_preset lc3_preset_32_1_1 =
BT_BAP_LC3_BROADCAST_PRESET_32_1_1(BT_AUDIO_LOCATION_MONO_AUDIO, BT_AUDIO_CONTEXT_TYPE_ANY);
static struct bt_bap_lc3_preset lc3_preset_32_2_1 =
BT_BAP_LC3_BROADCAST_PRESET_32_2_1(BT_AUDIO_LOCATION_MONO_AUDIO, BT_AUDIO_CONTEXT_TYPE_ANY);
static struct bt_bap_lc3_preset lc3_preset_48_1_1 =
BT_BAP_LC3_BROADCAST_PRESET_48_1_1(BT_AUDIO_LOCATION_MONO_AUDIO, BT_AUDIO_CONTEXT_TYPE_ANY);
static struct bt_bap_lc3_preset lc3_preset_48_2_1 =
BT_BAP_LC3_BROADCAST_PRESET_48_2_1(BT_AUDIO_LOCATION_MONO_AUDIO, BT_AUDIO_CONTEXT_TYPE_ANY);
static struct bt_bap_lc3_preset lc3_preset_48_3_1 =
BT_BAP_LC3_BROADCAST_PRESET_48_3_1(BT_AUDIO_LOCATION_MONO_AUDIO, BT_AUDIO_CONTEXT_TYPE_ANY);
static struct bt_bap_lc3_preset lc3_preset_48_4_1 =
BT_BAP_LC3_BROADCAST_PRESET_48_4_1(BT_AUDIO_LOCATION_MONO_AUDIO, BT_AUDIO_CONTEXT_TYPE_ANY);
static struct bt_bap_lc3_preset lc3_preset_48_5_1 =
BT_BAP_LC3_BROADCAST_PRESET_48_5_1(BT_AUDIO_LOCATION_MONO_AUDIO, BT_AUDIO_CONTEXT_TYPE_ANY);
static struct bt_bap_lc3_preset lc3_preset_48_6_1 =
BT_BAP_LC3_BROADCAST_PRESET_48_6_1(BT_AUDIO_LOCATION_MONO_AUDIO, BT_AUDIO_CONTEXT_TYPE_ANY);
/* High reliability settings */
static struct bt_bap_lc3_preset lc3_preset_8_1_2 =
BT_BAP_LC3_BROADCAST_PRESET_8_1_2(BT_AUDIO_LOCATION_MONO_AUDIO, BT_AUDIO_CONTEXT_TYPE_ANY);
static struct bt_bap_lc3_preset lc3_preset_8_2_2 =
BT_BAP_LC3_BROADCAST_PRESET_8_2_2(BT_AUDIO_LOCATION_MONO_AUDIO, BT_AUDIO_CONTEXT_TYPE_ANY);
static struct bt_bap_lc3_preset lc3_preset_16_1_2 =
BT_BAP_LC3_BROADCAST_PRESET_16_1_2(BT_AUDIO_LOCATION_MONO_AUDIO, BT_AUDIO_CONTEXT_TYPE_ANY);
static struct bt_bap_lc3_preset lc3_preset_16_2_2 =
BT_BAP_LC3_BROADCAST_PRESET_16_2_2(BT_AUDIO_LOCATION_MONO_AUDIO, BT_AUDIO_CONTEXT_TYPE_ANY);
static struct bt_bap_lc3_preset lc3_preset_24_1_2 =
BT_BAP_LC3_BROADCAST_PRESET_24_1_2(BT_AUDIO_LOCATION_MONO_AUDIO, BT_AUDIO_CONTEXT_TYPE_ANY);
static struct bt_bap_lc3_preset lc3_preset_24_2_2 =
BT_BAP_LC3_BROADCAST_PRESET_24_2_2(BT_AUDIO_LOCATION_MONO_AUDIO, BT_AUDIO_CONTEXT_TYPE_ANY);
static struct bt_bap_lc3_preset lc3_preset_32_1_2 =
BT_BAP_LC3_BROADCAST_PRESET_32_1_2(BT_AUDIO_LOCATION_MONO_AUDIO, BT_AUDIO_CONTEXT_TYPE_ANY);
static struct bt_bap_lc3_preset lc3_preset_32_2_2 =
BT_BAP_LC3_BROADCAST_PRESET_32_2_2(BT_AUDIO_LOCATION_MONO_AUDIO, BT_AUDIO_CONTEXT_TYPE_ANY);
static struct bt_bap_lc3_preset lc3_preset_48_1_2 =
BT_BAP_LC3_BROADCAST_PRESET_48_1_2(BT_AUDIO_LOCATION_MONO_AUDIO, BT_AUDIO_CONTEXT_TYPE_ANY);
static struct bt_bap_lc3_preset lc3_preset_48_2_2 =
BT_BAP_LC3_BROADCAST_PRESET_48_2_2(BT_AUDIO_LOCATION_MONO_AUDIO, BT_AUDIO_CONTEXT_TYPE_ANY);
static struct bt_bap_lc3_preset lc3_preset_48_3_2 =
BT_BAP_LC3_BROADCAST_PRESET_48_3_2(BT_AUDIO_LOCATION_MONO_AUDIO, BT_AUDIO_CONTEXT_TYPE_ANY);
static struct bt_bap_lc3_preset lc3_preset_48_4_2 =
BT_BAP_LC3_BROADCAST_PRESET_48_4_2(BT_AUDIO_LOCATION_MONO_AUDIO, BT_AUDIO_CONTEXT_TYPE_ANY);
static struct bt_bap_lc3_preset lc3_preset_48_5_2 =
BT_BAP_LC3_BROADCAST_PRESET_48_5_2(BT_AUDIO_LOCATION_MONO_AUDIO, BT_AUDIO_CONTEXT_TYPE_ANY);
static struct bt_bap_lc3_preset lc3_preset_48_6_2 =
BT_BAP_LC3_BROADCAST_PRESET_48_6_2(BT_AUDIO_LOCATION_MONO_AUDIO, BT_AUDIO_CONTEXT_TYPE_ANY);
struct bap_preset {
struct bt_bap_lc3_preset *preset;
char name[PRESET_NAME_MAX];
};
static struct bap_preset bap_presets[] = {
{.preset = &lc3_preset_8_1_1, .name = "8_1_1"},
{.preset = &lc3_preset_8_2_1, .name = "8_2_1"},
{.preset = &lc3_preset_16_1_1, .name = "16_1_1"},
{.preset = &lc3_preset_16_2_1, .name = "16_2_1"},
{.preset = &lc3_preset_24_1_1, .name = "24_1_1"},
{.preset = &lc3_preset_24_2_1, .name = "24_2_1"},
{.preset = &lc3_preset_32_1_1, .name = "32_1_1"},
{.preset = &lc3_preset_32_2_1, .name = "32_2_1"},
{.preset = &lc3_preset_48_1_1, .name = "48_1_1"},
{.preset = &lc3_preset_48_2_1, .name = "48_2_1"},
{.preset = &lc3_preset_48_3_1, .name = "48_3_1"},
{.preset = &lc3_preset_48_4_1, .name = "48_4_1"},
{.preset = &lc3_preset_48_5_1, .name = "48_5_1"},
{.preset = &lc3_preset_48_6_1, .name = "48_6_1"},
{.preset = &lc3_preset_8_1_2, .name = "8_1_2"},
{.preset = &lc3_preset_8_2_2, .name = "8_2_2"},
{.preset = &lc3_preset_16_1_2, .name = "16_1_2"},
{.preset = &lc3_preset_16_2_2, .name = "16_2_2"},
{.preset = &lc3_preset_24_1_2, .name = "24_1_2"},
{.preset = &lc3_preset_24_2_2, .name = "24_2_2"},
{.preset = &lc3_preset_32_1_2, .name = "32_1_2"},
{.preset = &lc3_preset_32_2_2, .name = "32_2_2"},
{.preset = &lc3_preset_48_1_2, .name = "48_1_2"},
{.preset = &lc3_preset_48_2_2, .name = "48_2_2"},
{.preset = &lc3_preset_48_3_2, .name = "48_3_2"},
{.preset = &lc3_preset_48_4_2, .name = "48_4_2"},
{.preset = &lc3_preset_48_5_2, .name = "48_5_2"},
{.preset = &lc3_preset_48_6_2, .name = "48_6_2"},
};
#define LOCATION_NAME_LEN_MAX 4
struct audio_location {
enum bt_audio_location location;
char name[LOCATION_NAME_LEN_MAX + 1];
};
/* Note: If there is any change to the specification of audio
* locations then this structure must be checked for conformance.
*/
static struct audio_location locations[] = {
{.location = BT_AUDIO_LOCATION_MONO_AUDIO, .name = "MA"},
{.location = BT_AUDIO_LOCATION_FRONT_LEFT, .name = "FL"},
{.location = BT_AUDIO_LOCATION_FRONT_RIGHT, .name = "FR"},
{.location = BT_AUDIO_LOCATION_FRONT_CENTER, .name = "FC"},
{.location = BT_AUDIO_LOCATION_LOW_FREQ_EFFECTS_1, .name = "LFE1"},
{.location = BT_AUDIO_LOCATION_BACK_LEFT, .name = "BL"},
{.location = BT_AUDIO_LOCATION_BACK_RIGHT, .name = "BR"},
{.location = BT_AUDIO_LOCATION_FRONT_LEFT_OF_CENTER, .name = "FLC"},
{.location = BT_AUDIO_LOCATION_FRONT_RIGHT_OF_CENTER, .name = "FRC"},
{.location = BT_AUDIO_LOCATION_BACK_CENTER, .name = "BC"},
{.location = BT_AUDIO_LOCATION_LOW_FREQ_EFFECTS_2, .name = "LFE2"},
{.location = BT_AUDIO_LOCATION_SIDE_LEFT, .name = "SL"},
{.location = BT_AUDIO_LOCATION_SIDE_RIGHT, .name = "SR"},
{.location = BT_AUDIO_LOCATION_TOP_FRONT_LEFT, .name = "TFL"},
{.location = BT_AUDIO_LOCATION_TOP_FRONT_RIGHT, .name = "TFR"},
{.location = BT_AUDIO_LOCATION_TOP_FRONT_CENTER, .name = "TFC"},
{.location = BT_AUDIO_LOCATION_TOP_CENTER, .name = "TC"},
{.location = BT_AUDIO_LOCATION_TOP_BACK_LEFT, .name = "TBL"},
{.location = BT_AUDIO_LOCATION_TOP_BACK_RIGHT, .name = "TBR"},
{.location = BT_AUDIO_LOCATION_TOP_SIDE_LEFT, .name = "TSL"},
{.location = BT_AUDIO_LOCATION_TOP_SIDE_RIGHT, .name = "TSR"},
{.location = BT_AUDIO_LOCATION_TOP_BACK_CENTER, .name = "TBC"},
{.location = BT_AUDIO_LOCATION_BOTTOM_FRONT_CENTER, .name = "BFC"},
{.location = BT_AUDIO_LOCATION_BOTTOM_FRONT_LEFT, .name = "BFL"},
{.location = BT_AUDIO_LOCATION_BOTTOM_FRONT_RIGHT, .name = "BFR"},
{.location = BT_AUDIO_LOCATION_FRONT_LEFT_WIDE, .name = "FLW"},
{.location = BT_AUDIO_LOCATION_FRONT_RIGHT_WIDE, .name = "FRW"},
{.location = BT_AUDIO_LOCATION_LEFT_SURROUND, .name = "LS"},
{.location = BT_AUDIO_LOCATION_RIGHT_SURROUND, .name = "RS"},
};
enum usecase_type {
LECTURE,
SILENT_TV_1,
SILENT_TV_2,
MULTI_LANGUAGE,
PERSONAL_SHARING,
PERSONAL_MULTI_LANGUAGE,
};
struct usecase_info {
enum usecase_type use_case;
char name[40];
};
static struct usecase_info pre_defined_use_cases[] = {
{.use_case = LECTURE, .name = "Lecture"},
{.use_case = SILENT_TV_1, .name = "Silent TV 1"},
{.use_case = SILENT_TV_2, .name = "Silent TV 2"},
{.use_case = MULTI_LANGUAGE, .name = "Multi-language"},
{.use_case = PERSONAL_SHARING, .name = "Personal sharing"},
{.use_case = PERSONAL_MULTI_LANGUAGE, .name = "Personal multi-language"},
};
#endif /* _NRF_AURACONFIG_H_ */

156
prj.conf Normal file
View File

@@ -0,0 +1,156 @@
#
# Copyright (c) 2024 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#
# General
CONFIG_REBOOT=y
CONFIG_DEBUG=y
CONFIG_DEBUG_INFO=y
CONFIG_ASSERT=y
CONFIG_STACK_USAGE=y
CONFIG_THREAD_RUNTIME_STATS=y
CONFIG_MAIN_THREAD_PRIORITY=10
CONFIG_STACK_SENTINEL=y
CONFIG_INIT_STACKS=y
CONFIG_MAIN_STACK_SIZE=12000
CONFIG_THREAD_NAME=y
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=1200
# Uart driver
CONFIG_SERIAL=y
# Logging
CONFIG_LOG=y
CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
CONFIG_LOG_TAG_MAX_LEN=2
CONFIG_LOG_TAG_DEFAULT="--"
CONFIG_LOG_BUFFER_SIZE=4096
CONFIG_USE_SEGGER_RTT=n
CONFIG_LOG_BACKEND_RTT=n
CONFIG_SOC_NRF53_CPUNET_ENABLE=y
CONFIG_ZBUS=y
CONFIG_ZBUS_RUNTIME_OBSERVERS=y
CONFIG_ZBUS_MSG_SUBSCRIBER=y
CONFIG_REGULATOR=y
CONFIG_CONTIN_ARRAY=y
CONFIG_DATA_FIFO=y
# Enable NRFX_CLOCK for ACLK control
CONFIG_NRFX_CLOCK=y
CONFIG_NEWLIB_LIBC=y
# Audio codec LC3 related defines
# FPU_SHARING enables preservation of the hardware floating point registers
# across context switches to allow multiple threads to perform concurrent
# floating point operations.
CONFIG_FPU=y
CONFIG_FPU_SHARING=y
# Enable SDHC interface
CONFIG_DISK_DRIVERS=y
CONFIG_DISK_DRIVER_SDMMC=y
# Allocate buffer on RAM for transferring chunck of data
# from Flash to SPI
CONFIG_SPI_NRFX_RAM_BUFFER_SIZE=8
# CONFIG_the file system
CONFIG_FILE_SYSTEM=y
CONFIG_FAT_FILESYSTEM_ELM=y
CONFIG_FS_FATFS_LFN=y
CONFIG_FS_FATFS_LFN_MODE_STACK=y
# exFAT enabled to support longer file names and higher transfer speed
CONFIG_FS_FATFS_EXFAT=y
# Set the maximum file name length to 255
CONFIG_FS_FATFS_MAX_LFN=255
# Enable SPI interface
CONFIG_SPI=y
# Enable ADC for board version readback
CONFIG_ADC=y
CONFIG_WATCHDOG=y
CONFIG_TASK_WDT=y
# Use this for debugging thread usage
#CONFIG_LOG_THREAD_ID_PREFIX=y
# Console related defines
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y
# Shell related defines
CONFIG_SHELL=y
CONFIG_KERNEL_SHELL=y
CONFIG_SHELL_BACKEND_SERIAL=y
CONFIG_SHELL_VT100_COMMANDS=y
CONFIG_SHELL_VT100_COLORS=y
CONFIG_SHELL_STACK_SIZE=8096
CONFIG_SHELL_CMD_BUFF_SIZE=128
## Reduce shell memory usage
CONFIG_SHELL_WILDCARD=n
CONFIG_SHELL_HELP_ON_WRONG_ARGUMENT_COUNT=n
CONFIG_SHELL_STATS=n
CONFIG_SHELL_CMDS=n
CONFIG_SHELL_HISTORY=y
# Turn off default shell commands
CONFIG_I2C_SHELL=n
CONFIG_HWINFO_SHELL=n
CONFIG_CLOCK_CONTROL_NRF_SHELL=n
CONFIG_FLASH_SHELL=n
CONFIG_DEVICE_SHELL=n
# Suppress LOG_ERR messages from sd_check_card_type. Because SPI_SDHC has no card presence method,
# assume card is in slot. Thus error message is always shown if card is not inserted
CONFIG_SD_LOG_LEVEL_OFF=y
# Suppress LOG_INF messages from hci_core
CONFIG_BT_HCI_CORE_LOG_LEVEL_WRN=y
## ISO related configs ##
CONFIG_BT=y
CONFIG_BT_DEVICE_NAME_DYNAMIC=y
CONFIG_BT_CAP_INITIATOR=y
CONFIG_BT_ISO_BROADCASTER=y
CONFIG_BT_ISO_MAX_BIG=2
CONFIG_BT_ISO_MAX_CHAN=8
# Should be twice that of BT_ISO_MAX_CHAN
CONFIG_BT_ISO_TX_BUF_COUNT=16
CONFIG_BT_BAP_BROADCAST_SOURCE=y
CONFIG_BT_BAP_BROADCAST_SRC_COUNT=2
CONFIG_BT_EXT_ADV_MAX_ADV_SET=2
CONFIG_BT_BAP_BROADCAST_SRC_SUBGROUP_COUNT=4
CONFIG_BT_BAP_BROADCAST_SRC_STREAM_COUNT=8
# Broadcasting Device - 0x0885
CONFIG_BT_DEVICE_APPEARANCE=2181
CONFIG_TRANSPORT_BIS=y
CONFIG_BT_AUDIO_BROADCAST_CONFIGURABLE=y
CONFIG_BT_AUDIO_BROADCAST_ZBUS_EVT_STREAM_SENT=y
CONFIG_LE_AUDIO_MSG_SUB_THREAD_PRIO=3
CONFIG_SW_CODEC_LC3=n
CONFIG_NRF5340_AUDIO_SD_CARD_MODULE=y
CONFIG_NRF5340_AUDIO_SD_CARD_LC3_FILE=y
CONFIG_NRF5340_AUDIO_SD_CARD_LC3_STREAMER=y
CONFIG_SD_CARD_LC3_STREAMER_STACK_SIZE=8000
CONFIG_MODULE_SD_CARD_LOG_LEVEL_WRN=y

14
sample.yaml Normal file
View File

@@ -0,0 +1,14 @@
sample:
name: Bluetooth Low Energy nRF Auraconfig
description: Bluetooth LE shell configurable Auracast tool
common:
integration_platforms:
- nrf5340_audio_dk/nrf5340/cpuapp
platform_allow: nrf5340_audio_dk/nrf5340/cpuapp
platform_exclude: nrf5340_audio_dk/nrf5340/cpuapp_ns
sysbuild: true
build_only: true
tags: ci_build sysbuild bluetooth
tests:
sample.bluetooth.nrf_auraconfig.build:
extra_args: []

2651
src/main.c Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,38 @@
#
# Copyright (c) 2024 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#
CONFIG_HEAP_MEM_POOL_SIZE=8192
CONFIG_MAIN_STACK_SIZE=2048
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
CONFIG_MBOX=y
CONFIG_IPC_SERVICE=y
CONFIG_BT=y
CONFIG_BT_HCI_RAW=y
CONFIG_BT_CTLR_ASSERT_HANDLER=y
CONFIG_BT_ISO_BROADCASTER=y
CONFIG_BT_ISO_SYNC_RECEIVER=n
CONFIG_BT_EXT_ADV=y
CONFIG_BT_CTLR_ADV_SET=2
CONFIG_BT_EXT_ADV_MAX_ADV_SET=2
CONFIG_BT_CTLR_ADV_ISO_SET=2
CONFIG_BT_CTLR_ADV_ISO_STREAM_COUNT=8
CONFIG_BT_MAX_CONN=1
# Allow using more than default advertising event length
CONFIG_BT_CTLR_ADV_DATA_LEN_MAX=251
# To present the audio at the right point in time, we need the controller and
# audio clock to be synchronized
CONFIG_MPSL_TRIGGER_IPC_TASK_ON_RTC_START=y
CONFIG_MPSL_TRIGGER_IPC_TASK_ON_RTC_START_CHANNEL=4
CONFIG_IPC_RADIO_BT=y
CONFIG_IPC_RADIO_BT_HCI_IPC=y