Multiple ACL Connections (extended advertising)

Hi,

I'm using nRF5340 Audio DK with a modified example code provided by   (thanks again!), which integrates peripheral NUS through extended advertisement in parallel to audio streaming (see ModifiedFiles.7z in the above support case).

Currently, I'm able to successfully connect with nRF Connect for Mobile to my DK while it's also broadcasting audio.

My goal is to be able to connect with 2 different clients simultaneously (e.g, with 2 different smartphones). I've modified main.c in broadcast_source, and as part of the main() fuction I call bt_le_ext_adv_create() twice in a row. The issue is that I receive "ENOMEM" for the second call and I'm not sure how to solve this:

static struct bt_le_ext_adv *adv_for_conn[CONFIG_BT_MAX_CONN]; //CONFIG_BT_MAX_CONN=2

...

for (int i = 0; i < CONFIG_BT_MAX_CONN; i++) 
{
	err = bt_le_ext_adv_create(BT_LE_EXT_ADV_CONN, NULL, &(adv_for_conn[i]));
	if (err) {
		LOG_ERR("Failed to create advertising set (err %d)", err);
		break;
	}

	err = bt_le_ext_adv_set_data(adv_for_conn[i], ad, ARRAY_SIZE(ad), NULL, 0);
	if (err) {
		LOG_ERR("Failed to set advertising data (err %d)", err);
	}
}

prj.conf:

#
# Copyright (c) 2022 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

# nRF5340 Audio
CONFIG_NRF5340_AUDIO=y

CONFIG_SAMPLE_RATE_CONVERTER=y
CONFIG_SAMPLE_RATE_CONVERTER_FILTER_SIMPLE=y

# General
CONFIG_DEBUG=y
CONFIG_DEBUG_INFO=y
CONFIG_ASSERT=y
CONFIG_STACK_USAGE=y
CONFIG_THREAD_RUNTIME_STATS=y
CONFIG_STACK_SENTINEL=y
CONFIG_INIT_STACKS=y

# 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_BACKEND_UART=y

# Use this for debugging thread usage
#CONFIG_LOG_THREAD_ID_PREFIX=y

# Console related defines
CONFIG_CONSOLE=y
CONFIG_RTT_CONSOLE=y
CONFIG_UART_CONSOLE=y

# Shell related defines
CONFIG_SHELL=y
CONFIG_KERNEL_SHELL=y
CONFIG_USE_SEGGER_RTT=y
## Disable logs on RTT
CONFIG_SHELL_RTT_INIT_LOG_LEVEL_NONE=n
CONFIG_SHELL_BACKEND_RTT=y
CONFIG_SHELL_BACKEND_SERIAL=n
CONFIG_SHELL_VT100_COMMANDS=y
CONFIG_SHELL_VT100_COLORS=y
CONFIG_SHELL_STACK_SIZE=4096
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

#Adding for NUS peri.
CONFIG_AUDIO_SOURCE_I2S=y
CONFIG_TRANSPORT_BIS=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_NUS=y
CONFIG_BT_MAX_CONN=2
CONFIG_BT_EXT_ADV_MAX_ADV_SET=2
CONFIG_BT_AUDIO_MAX_TRANSPORT_LATENCY_MS=80
CONFIG_BT_AUDIO_RETRANSMITS=1
CONFIG_BT_AUDIO_BITRATE_BROADCAST_SRC=32000


# 1=headset, 2=gateway (for flashing through VSCode)
CONFIG_AUDIO_DEV=2

#required by Raytac
CONFIG_BOARD_ENABLE_DCDC_NET=n
CONFIG_BOARD_ENABLE_DCDC_APP=n
CONFIG_BOARD_ENABLE_DCDC_HV=n
CONFIG_CLOCK_CONTROL_NRF=y
CONFIG_CLOCK_CONTROL=y
CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y
CONFIG_CLOCK_CONTROL_NRF_K32SRC_500PPM=y
CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC_CALIBRATION=y
CONFIG_CLOCK_CONTROL_NRF_CALIBRATION_PERIOD=1000

#Debug terminal
CONFIG_PRINTK=y
CONFIG_CBPRINTF_FP_SUPPORT=y

#peripherals
CONFIG_GPIO=y
CONFIG_PWM=y
CONFIG_PWM_LOG_LEVEL_DBG=y

I'd appreciate any help with solving this!

thanks.

Parents
  • Hello,

    Glad to hear that you've already got the example made by Brian up and running! :) 

    The good news is that you do not need to re-do the calls to bt_le_ext_adv_create in the for loop - you can start advertising once, and so long as you are not at the limit for concurrent connections you can continue to use the same advertising set to connect multiple devices.
    If you comment out the for loop (i.e only do the _create and _set once), and you connect to a device (still using MAX_CONN=2), are you seeing the advertisements stop after having connected the first one?
    If so, could you share more of your code around the connection establishments?


    Best regards,
    Karl

  • Thanks for the feedback.

    So I tried advertising once as you suggested (the loop runs once), and the first connection is established successfully. At this point, the advertisement is not seen anymore in the smartphone app, although MAX_CONN=2.

    Therefore, I tried calling bt_le_ext_adv_start() after a successful connection, but I receive "ENOMEM". I'll mention that I call this function with the same bt_le_ext_adv* parameter (1st one) that I used on the previous call.

    What am I doing wrong here?

  • Hi,

    Karl is unfortunately no longer in office so we will reassign this case. It will however take some time to sync up with the information, but I'll discuss the issue with Brian. I'll get back to you when I have something more constructive for you. 

    In the meanwhile let me know if you've resolved the issue or not.

    Kind regards,
    Andreas

Reply
  • Hi,

    Karl is unfortunately no longer in office so we will reassign this case. It will however take some time to sync up with the information, but I'll discuss the issue with Brian. I'll get back to you when I have something more constructive for you. 

    In the meanwhile let me know if you've resolved the issue or not.

    Kind regards,
    Andreas

Children
Related