test/le_audio: support nRF5340 ADK and counter mode

This commit is contained in:
Dirk Helbig 2023-12-11 12:26:28 +01:00 committed by Matthias Ringwald
parent a18990d3f4
commit 0c30abb230
2 changed files with 29 additions and 8 deletions

View File

@ -87,8 +87,6 @@
static void show_usage(void);
static const char * filename_wav = "le_audio_broadcast_sink.wav";
static enum {
APP_W4_WORKING,
APP_W4_BROADCAST_ADV,
@ -177,7 +175,6 @@ static le_audio_big_sync_params_t big_sync_params;
// lc3 codec config
static uint16_t sampling_frequency_hz;
static btstack_lc3_frame_duration_t frame_duration;
static uint16_t number_samples_per_frame;
static uint16_t octets_per_frame;
static uint8_t num_bis;
@ -656,13 +653,20 @@ static void stdin_process(char c){
}
static void iso_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size) {
void (*packet_receive)(uint8_t stream_index, uint8_t *packet, uint16_t size) = le_audio_demo_util_sink_receive;
// get stream_index from con_handle
uint16_t header = little_endian_read_16(packet, 0);
hci_con_handle_t con_handle = header & 0x0fff;
uint8_t i;
if (count_mode){
packet_receive = le_audio_demo_util_sink_count;
}
for (i=0;i<num_bis;i++){
if (bis_con_handles[i] == con_handle) {
le_audio_demo_util_sink_receive(i, packet, size);
packet_receive(i, packet, size);
}
}
}

View File

@ -62,6 +62,9 @@
#include "mods/mod.h"
#include "le_audio_demo_util_source.h"
// Interoperability with Nordic LE Audio demo
//#define NRF5340_BROADCAST_MODE
// PTS mode
// #define PTS_MODE
@ -105,11 +108,17 @@ static const uint8_t extended_adv_data[] = {
BROADCAST_ID & 0xff,
// name
#ifdef PTS_MODE
7, BLUETOOTH_DATA_TYPE_COMPLETE_LOCAL_NAME, 'P', 'T', 'S', '-', 'x', 'x'
7, BLUETOOTH_DATA_TYPE_COMPLETE_LOCAL_NAME, 'P', 'T', 'S', '-', 'x', 'x',
7, BLUETOOTH_DATA_TYPE_BROADCAST_NAME , 'P', 'T', 'S', '-', 'x', 'x',
#elif defined(COUNT_MODE)
6, BLUETOOTH_DATA_TYPE_COMPLETE_LOCAL_NAME, 'C', 'O', 'U', 'N', 'T'
6, BLUETOOTH_DATA_TYPE_COMPLETE_LOCAL_NAME, 'C', 'O', 'U', 'N', 'T',
6, BLUETOOTH_DATA_TYPE_BROADCAST_NAME, 'C', 'O', 'U', 'N', 'T',
#elif defined(NRF5340_BROADCAST_MODE)
20, BLUETOOTH_DATA_TYPE_COMPLETE_LOCAL_NAME, 'N','R','F','5','3','4','0','_','B','R','O','A','D','C','A','S','T','E','R',
20, BLUETOOTH_DATA_TYPE_BROADCAST_NAME, 'N','R','F','5','3','4','0','_','B','R','O','A','D','C','A','S','T','E','R',
#else
7, BLUETOOTH_DATA_TYPE_COMPLETE_LOCAL_NAME, 'S', 'o', 'u', 'r', 'c', 'e'
7, BLUETOOTH_DATA_TYPE_COMPLETE_LOCAL_NAME, 'S', 'o', 'u', 'r', 'c', 'e',
7, BLUETOOTH_DATA_TYPE_BROADCAST_NAME, 'S', 'o', 'u', 'r', 'c', 'e',
#endif
};
@ -162,7 +171,11 @@ static uint8_t encryption = 0;
static uint8_t broadcast_code [] = {0x01, 0x02, 0x68, 0x05, 0x53, 0xF1, 0x41, 0x5A, 0xA2, 0x65, 0xBB, 0xAF, 0xC6, 0xEA, 0x03, 0xB8, };
// audio producer
#ifdef COUNT_MODE
static le_audio_demo_source_generator audio_source = AUDIO_SOURCE_COUNTER;
#else
static le_audio_demo_source_generator audio_source = AUDIO_SOURCE_MODPLAYER;
#endif
static enum {
APP_IDLE,
@ -323,7 +336,7 @@ static void start_broadcast() {// use values from table
0x05, 0x03, 0x02, 0x00, 0x00, 0x00
};
le_audio_base_builder_t builder;
le_audio_base_builder_init(&builder, period_adv_data, sizeof(period_adv_data), 40);
le_audio_base_builder_init(&builder, period_adv_data, sizeof(period_adv_data), 20000);
le_audio_base_builder_add_subgroup(&builder, codec_id,
sizeof(subgroup_codec_specific_configuration),
subgroup_codec_specific_configuration,
@ -358,6 +371,10 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
menu_sampling_frequency = 5;
menu_variant = 4;
start_broadcast();
#elif defined( NRF5340_BROADCAST_MODE )
num_bis = 1;
menu_sampling_frequency = 5;
menu_variant = 1;
#else
show_usage();
printf("Please select sample frequency and variation, then start broadcast\n");