Skip to content

Commit f4360c0

Browse files
gWaceyrlubos
authored andcommitted
applications: nrf5340_audio: Change source of inline functions to Zephyr
OCT-3115 The static inline functions in broadcast_config_tool.h has been moved to upstream Zephyr. We need to remove the functions from broadcast_config_tool.h and use these instead. Signed-off-by: Graham Wacey <[email protected]>
1 parent 672ddd7 commit f4360c0

File tree

3 files changed

+46
-136
lines changed

3 files changed

+46
-136
lines changed

samples/bluetooth/broadcast_config_tool/README.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ In the BIS gateway mode, transmitting audio from the broadcast source happens us
1515
The following limitations apply to this sample:
1616

1717
* Audio input: Pre-encoded LC3 data from an SD-card.
18+
See :ref:`broadcast_configuration_tool_configuration_sd` for more information.
1819
* Maximum two BIG with four BIS streams each.
1920

2021
.. _broadcast_configuration_tool_requirements:
@@ -761,6 +762,15 @@ The sample is pre-configured with a generous default memory allocation, suitable
761762
You can modify these default settings in the :file:`prj.conf` file.
762763
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).
763764

765+
.. _broadcast_configuration_tool_configuration_sd:
766+
767+
SD card setup
768+
*************
769+
770+
The sample only supports pre-encoded LC3 data stored as LC3 files on an SD card.
771+
772+
Make sure you format the SD card with a FAT file system.
773+
764774
.. _broadcast_configuration_tool_building:
765775

766776
Building and running
@@ -782,6 +792,7 @@ In this testing procedure, the development kit is programmed with the Broadcast
782792

783793
To test the Broadcast Configuration Tool sample, complete the following steps:
784794

795+
1. Insert the SD card loaded with the pre-encoded LC3 data.
785796
#. Turn on the development kit.
786797
#. Set up the serial connection with the development kit.
787798
#. Configure a BIG using use case 1:

samples/bluetooth/broadcast_config_tool/include/broadcast_config_tool.h

Lines changed: 7 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,6 @@ struct bap_preset {
7878
char name[PRESET_NAME_MAX];
7979
};
8080

81-
#define CONTEXT_NAME_LEN_MAX 20
82-
struct audio_context {
83-
enum bt_audio_context context;
84-
char name[CONTEXT_NAME_LEN_MAX];
85-
};
86-
87-
#define LOCATION_NAME_LEN_MAX 5
88-
struct audio_location {
89-
enum bt_audio_location location;
90-
char name[5];
91-
};
92-
9381
static struct bap_preset bap_presets[] = {
9482
{.preset = &lc3_preset_8_1_1, .name = "8_1_1"},
9583
{.preset = &lc3_preset_8_2_1, .name = "8_2_1"},
@@ -121,22 +109,15 @@ static struct bap_preset bap_presets[] = {
121109
{.preset = &lc3_preset_48_6_2, .name = "48_6_2"},
122110
};
123111

124-
static struct audio_context contexts[] = {
125-
{.context = BT_AUDIO_CONTEXT_TYPE_PROHIBITED, .name = "Prohibited"},
126-
{.context = BT_AUDIO_CONTEXT_TYPE_UNSPECIFIED, .name = "Unspecified"},
127-
{.context = BT_AUDIO_CONTEXT_TYPE_CONVERSATIONAL, .name = "Conversational"},
128-
{.context = BT_AUDIO_CONTEXT_TYPE_MEDIA, .name = "Media"},
129-
{.context = BT_AUDIO_CONTEXT_TYPE_GAME, .name = "Game"},
130-
{.context = BT_AUDIO_CONTEXT_TYPE_INSTRUCTIONAL, .name = "Instructional"},
131-
{.context = BT_AUDIO_CONTEXT_TYPE_VOICE_ASSISTANTS, .name = "Voice assistants"},
132-
{.context = BT_AUDIO_CONTEXT_TYPE_LIVE, .name = "Live"},
133-
{.context = BT_AUDIO_CONTEXT_TYPE_SOUND_EFFECTS, .name = "Sound effects"},
134-
{.context = BT_AUDIO_CONTEXT_TYPE_NOTIFICATIONS, .name = "Notifications"},
135-
{.context = BT_AUDIO_CONTEXT_TYPE_RINGTONE, .name = "Ringtone"},
136-
{.context = BT_AUDIO_CONTEXT_TYPE_ALERTS, .name = "Alerts"},
137-
{.context = BT_AUDIO_CONTEXT_TYPE_EMERGENCY_ALARM, .name = "Emergency alarm"},
112+
#define LOCATION_NAME_LEN_MAX 4
113+
struct audio_location {
114+
enum bt_audio_location location;
115+
char name[LOCATION_NAME_LEN_MAX + 1];
138116
};
139117

118+
/* Note: If there is any change to the specification of audio
119+
* locations then this structure must be checked for conformance.
120+
*/
140121
static struct audio_location locations[] = {
141122
{.location = BT_AUDIO_LOCATION_MONO_AUDIO, .name = "MA"},
142123
{.location = BT_AUDIO_LOCATION_FRONT_LEFT, .name = "FL"},
@@ -192,104 +173,4 @@ static struct usecase_info pre_defined_use_cases[] = {
192173
{.use_case = PERSONAL_MULTI_LANGUAGE, .name = "Personal multi-language"},
193174
};
194175

195-
static inline char *location_bit_to_str(enum bt_audio_location location)
196-
{
197-
switch (location) {
198-
case BT_AUDIO_LOCATION_MONO_AUDIO:
199-
return "Mono Audio";
200-
case BT_AUDIO_LOCATION_FRONT_LEFT:
201-
return "Front Left";
202-
case BT_AUDIO_LOCATION_FRONT_RIGHT:
203-
return "Front Right";
204-
case BT_AUDIO_LOCATION_FRONT_CENTER:
205-
return "Front Center";
206-
case BT_AUDIO_LOCATION_LOW_FREQ_EFFECTS_1:
207-
return "Low Frequency 1";
208-
case BT_AUDIO_LOCATION_BACK_LEFT:
209-
return "Back Left";
210-
case BT_AUDIO_LOCATION_BACK_RIGHT:
211-
return "Back Right";
212-
case BT_AUDIO_LOCATION_FRONT_LEFT_OF_CENTER:
213-
return "Front Left of Center";
214-
case BT_AUDIO_LOCATION_FRONT_RIGHT_OF_CENTER:
215-
return "Front Right of Center";
216-
case BT_AUDIO_LOCATION_BACK_CENTER:
217-
return "Back Center";
218-
case BT_AUDIO_LOCATION_LOW_FREQ_EFFECTS_2:
219-
return "Low Frequency 2";
220-
case BT_AUDIO_LOCATION_SIDE_LEFT:
221-
return "Side Left";
222-
case BT_AUDIO_LOCATION_SIDE_RIGHT:
223-
return "Side Right";
224-
case BT_AUDIO_LOCATION_TOP_FRONT_LEFT:
225-
return "Top Front Left";
226-
case BT_AUDIO_LOCATION_TOP_FRONT_RIGHT:
227-
return "Top Front Right";
228-
case BT_AUDIO_LOCATION_TOP_FRONT_CENTER:
229-
return "Top Front Center";
230-
case BT_AUDIO_LOCATION_TOP_CENTER:
231-
return "Top Center";
232-
case BT_AUDIO_LOCATION_TOP_BACK_LEFT:
233-
return "Top Back Left";
234-
case BT_AUDIO_LOCATION_TOP_BACK_RIGHT:
235-
return "Top Back Right";
236-
case BT_AUDIO_LOCATION_TOP_SIDE_LEFT:
237-
return "Top Side Left";
238-
case BT_AUDIO_LOCATION_TOP_SIDE_RIGHT:
239-
return "Top Side Right";
240-
case BT_AUDIO_LOCATION_TOP_BACK_CENTER:
241-
return "Top Back Center";
242-
case BT_AUDIO_LOCATION_BOTTOM_FRONT_CENTER:
243-
return "Bottom Front Center";
244-
case BT_AUDIO_LOCATION_BOTTOM_FRONT_LEFT:
245-
return "Bottom Front Left";
246-
case BT_AUDIO_LOCATION_BOTTOM_FRONT_RIGHT:
247-
return "Bottom Front Right";
248-
case BT_AUDIO_LOCATION_FRONT_LEFT_WIDE:
249-
return "Front Left Wide";
250-
case BT_AUDIO_LOCATION_FRONT_RIGHT_WIDE:
251-
return "Front Right Wide";
252-
case BT_AUDIO_LOCATION_LEFT_SURROUND:
253-
return "Left Surround";
254-
case BT_AUDIO_LOCATION_RIGHT_SURROUND:
255-
return "Right Surround";
256-
default:
257-
return "Unknown";
258-
}
259-
}
260-
261-
static inline char *context_bit_to_str(enum bt_audio_context context)
262-
{
263-
switch (context) {
264-
case BT_AUDIO_CONTEXT_TYPE_PROHIBITED:
265-
return "Prohibited";
266-
case BT_AUDIO_CONTEXT_TYPE_UNSPECIFIED:
267-
return "Unspecified";
268-
case BT_AUDIO_CONTEXT_TYPE_CONVERSATIONAL:
269-
return "Conversational";
270-
case BT_AUDIO_CONTEXT_TYPE_MEDIA:
271-
return "Media";
272-
case BT_AUDIO_CONTEXT_TYPE_GAME:
273-
return "Game";
274-
case BT_AUDIO_CONTEXT_TYPE_INSTRUCTIONAL:
275-
return "Instructional";
276-
case BT_AUDIO_CONTEXT_TYPE_VOICE_ASSISTANTS:
277-
return "Voice assistant";
278-
case BT_AUDIO_CONTEXT_TYPE_LIVE:
279-
return "Live";
280-
case BT_AUDIO_CONTEXT_TYPE_SOUND_EFFECTS:
281-
return "Sound effects";
282-
case BT_AUDIO_CONTEXT_TYPE_NOTIFICATIONS:
283-
return "Notifications";
284-
case BT_AUDIO_CONTEXT_TYPE_RINGTONE:
285-
return "Ringtone";
286-
case BT_AUDIO_CONTEXT_TYPE_ALERTS:
287-
return "Alerts";
288-
case BT_AUDIO_CONTEXT_TYPE_EMERGENCY_ALARM:
289-
return "Emergency alarm";
290-
default:
291-
return "Unknown";
292-
}
293-
}
294-
295176
#endif /* _BROADCAST_CONFIG_TOOL_H_ */

samples/bluetooth/broadcast_config_tool/src/main.c

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,18 @@ struct subgroup_lc3_stream_info {
106106
static struct subgroup_lc3_stream_info lc3_stream_infos[CONFIG_BT_ISO_MAX_BIG]
107107
[CONFIG_BT_BAP_BROADCAST_SRC_SUBGROUP_COUNT];
108108

109+
/* Find the most significant 1 in bits, bits will not be 0. */
110+
static int8_t context_msb_one(uint16_t bits)
111+
{
112+
uint8_t pos = 0;
113+
114+
while (bits >>= 1) {
115+
pos++;
116+
}
117+
118+
return pos;
119+
}
120+
109121
static struct bt_bap_lc3_preset *preset_find(const char *name)
110122
{
111123
for (size_t i = 0; i < ARRAY_SIZE(bap_presets); i++) {
@@ -615,8 +627,10 @@ int main(void)
615627

616628
static void context_print(const struct shell *shell)
617629
{
618-
for (size_t i = 0; i < ARRAY_SIZE(contexts); i++) {
619-
shell_print(shell, "%s", contexts[i].name);
630+
shell_print(shell, "%s", bt_audio_context_bit_to_str(0));
631+
632+
for (int i = 0; i <= context_msb_one(BT_AUDIO_CONTEXT_TYPE_ANY); i++) {
633+
shell_print(shell, "%s", bt_audio_context_bit_to_str(BIT(i)));
620634
}
621635
}
622636

@@ -732,12 +746,13 @@ static void broadcast_config_print(const struct shell *shell, uint8_t group_inde
732746

733747
shell_print(shell, "\t\tContext(s):");
734748

735-
/* Context container is a bit field with length 16 */
736-
for (size_t j = 0U; j < 16; j++) {
749+
/* Context container is a bit field */
750+
for (size_t j = 0U; j <= context_msb_one(BT_AUDIO_CONTEXT_TYPE_ANY); j++) {
737751
const uint16_t bit_val = BIT(j);
738752

739753
if (brdcst_param->subgroups[i].context & bit_val) {
740-
shell_print(shell, "\t\t\t%s", context_bit_to_str(bit_val));
754+
shell_print(shell, "\t\t\t%s",
755+
bt_audio_context_bit_to_str(bit_val));
741756
}
742757
}
743758

@@ -758,7 +773,8 @@ static void broadcast_config_print(const struct shell *shell, uint8_t group_inde
758773

759774
for (size_t j = 0; j < brdcst_param->subgroups[i].num_bises; j++) {
760775
shell_print(shell, "\t\t\tBIS %d: %s", j,
761-
location_bit_to_str(brdcst_param->subgroups[i].location[j]));
776+
bt_audio_location_bit_to_str(
777+
brdcst_param->subgroups[i].location[j]));
762778
}
763779

764780
shell_print(shell, "\t\tFiles:");
@@ -1347,9 +1363,10 @@ static int cmd_context(const struct shell *shell, size_t argc, char **argv)
13471363
return -EINVAL;
13481364
}
13491365

1350-
for (size_t i = 0; i < ARRAY_SIZE(contexts); i++) {
1351-
if (strcasecmp(argv[1], contexts[i].name) == 0) {
1352-
context = contexts[i].context;
1366+
/* Context container is a bit field */
1367+
for (size_t i = 0U; i <= context_msb_one(BT_AUDIO_CONTEXT_TYPE_ANY); i++) {
1368+
if (strcasecmp(argv[1], bt_audio_context_bit_to_str(BIT(i))) == 0) {
1369+
context = BIT(i);
13531370
break;
13541371
}
13551372
}
@@ -1387,7 +1404,7 @@ static void location_print(const struct shell *shell)
13871404
{
13881405
for (size_t i = 0; i < ARRAY_SIZE(locations); i++) {
13891406
shell_print(shell, "%s - %s", locations[i].name,
1390-
location_bit_to_str(locations[i].location));
1407+
bt_audio_location_bit_to_str(locations[i].location));
13911408
}
13921409
}
13931410

@@ -1429,6 +1446,7 @@ static int cmd_location(const struct shell *shell, size_t argc, char **argv)
14291446
int location = location_find(shell, argv[1]);
14301447

14311448
if (location < 0) {
1449+
shell_error(shell, "Location not found");
14321450
return -EINVAL;
14331451
}
14341452

0 commit comments

Comments
 (0)