nrf5340 data length extension

hello, i'm using nrf connect sdk version 2.3, and nrf5340dk board.

1. i want ble data length extension, so i am using this function after connected call back ,in central uart example project

static int connection_configuration_set()
{
	int err;
	struct bt_le_conn_param* conn_param;
	struct bt_conn_le_phy_param phy;
	struct bt_conn_le_data_len_param data_len;

	conn_param = BT_LE_CONN_PARAM(INTERVAL_MIN, INTERVAL_MAX, 0, 400);

	phy.pref_tx_phy = BT_GAP_LE_PHY_2M;
	phy.pref_rx_phy = BT_GAP_LE_PHY_2M;
	
	data_len.tx_max_len 	= 251;
	data_len.tx_max_time 	= 2120;

	err = bt_conn_le_phy_update(default_conn, &phy);
	if (err) {
		printk("PHY update failed: %d\n", err);
		return err;
	}

	printk("PHY update pending");
	err = k_sem_take(&throughput_sem, THROUGHPUT_CONFIG_TIMEOUT);
	if (err) {
		printk("PHY update timeout");
		return err;
	}

	data_length_req = true;

	err = bt_conn_le_data_len_update(default_conn, &data_len);
	if (err) {
		printk("LE data length update failed: %d",
				err);
		return err;
	}

	printk("LE Data length update pending");
	err = k_sem_take(&throughput_sem, THROUGHPUT_CONFIG_TIMEOUT);
	if (err) {
		printk("LE Data Length update timeout");
		return err;
	}


	err = bt_conn_le_param_update(default_conn, conn_param);
	if (err) {
		printk(
				"Connection parameters update failed: %d",
				err);
		return err;
	}

	printk("Connection parameters update pending");
	err = k_sem_take(&throughput_sem, THROUGHPUT_CONFIG_TIMEOUT);
	if (err) {
		printk("Connection parameters update timeout");
		return err;
	}
	

	return 0;
}

but le_data_length_updated print that log:

it looks like data length not updated, so i have question for update data length

how can i set 251 byte ble data length

this is my prj.conf

central uart prj.conf

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

# Enable the UART driver
CONFIG_UART_ASYNC_API=y
CONFIG_NRFX_UARTE0=y
CONFIG_SERIAL=y
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y

# Enable the BLE stack with GATT Client configuration
CONFIG_BT=y
CONFIG_BT_CENTRAL=y
CONFIG_BT_SMP=y
CONFIG_BT_GATT_CLIENT=y

# Enable the BLE modules from NCS
CONFIG_BT_NUS_CLIENT=y
CONFIG_BT_SCAN=y
CONFIG_BT_SCAN_FILTER_ENABLE=y
CONFIG_BT_SCAN_UUID_CNT=1
CONFIG_BT_GATT_DM=y
CONFIG_HEAP_MEM_POOL_SIZE=2048

CONFIG_BT_USER_DATA_LEN_UPDATE=y
CONFIG_BT_USER_PHY_UPDATE=y
CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS=n
CONFIG_BT_L2CAP_TX_MTU=247
#CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
CONFIG_BT_BUF_ACL_TX_SIZE=251
CONFIG_BT_BUF_ACL_RX_SIZE=251

# This example requires more workqueue stack
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048

# Enable bonding
CONFIG_BT_SETTINGS=y
CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FLASH_MAP=y
CONFIG_NVS=y
CONFIG_SETTINGS=y

# Config logger
CONFIG_LOG=y
CONFIG_USE_SEGGER_RTT=y
CONFIG_LOG_BACKEND_RTT=y

CONFIG_LOG_BACKEND_UART=n
CONFIG_LOG_PRINTK=n


CONFIG_ASSERT=y

central uart child_image/rpc_host.conf

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

CONFIG_BT=y
CONFIG_BT_PERIPHERAL=n
CONFIG_BT_CENTRAL=y
CONFIG_BT_OBSERVER=y
CONFIG_BT_DEVICE_NAME="Zephyr"
CONFIG_BT_SMP=y
CONFIG_BT_GATT_CLIENT=y
CONFIG_BT_GATT_DM=y
CONFIG_HEAP_MEM_POOL_SIZE=2048
CONFIG_BT_DEBUG_LOG=y
CONFIG_BT_GATT_DM_DATA_PRINT=y
CONFIG_SETTINGS=y
CONFIG_BT_SETTINGS=y
CONFIG_NRF_RPC_THREAD_STACK_SIZE=2048


CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
CONFIG_BT_BUF_ACL_RX_SIZE=251
CONFIG_BT_AUTO_DATA_LEN_UPDATE=y

peripheral uart prj.conf

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

# Enable the UART driver
CONFIG_UART_ASYNC_API=y
CONFIG_NRFX_UARTE0=y
CONFIG_SERIAL=y

CONFIG_GPIO=y

# Make sure printk is printing to the UART console
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y

CONFIG_HEAP_MEM_POOL_SIZE=2048

CONFIG_BT=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_DEVICE_NAME="Nordic_UART_Service"
CONFIG_BT_DEVICE_APPEARANCE=833
CONFIG_BT_MAX_CONN=1
CONFIG_BT_MAX_PAIRED=1

CONFIG_BT_USER_DATA_LEN_UPDATE=y
CONFIG_BT_USER_PHY_UPDATE=y
CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS=n
CONFIG_BT_L2CAP_TX_MTU=247
#CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
CONFIG_BT_BUF_ACL_TX_SIZE=251
CONFIG_BT_BUF_ACL_RX_SIZE=251

# Enable the NUS service
CONFIG_BT_NUS=y

# Enable bonding
CONFIG_BT_SETTINGS=y
CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FLASH_MAP=y
CONFIG_NVS=y
CONFIG_SETTINGS=y

# Enable DK LED and Buttons library
CONFIG_DK_LIBRARY=y

# This example requires more workqueue stack
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048

# Config logger
CONFIG_LOG=y
CONFIG_USE_SEGGER_RTT=y
CONFIG_LOG_BACKEND_RTT=y

CONFIG_LOG_BACKEND_UART=n
CONFIG_LOG_PRINTK=n

CONFIG_ASSERT=y

CONFIG_SPI=y
CONFIG_SPI_ASYNC=y

CONFIG_SPI_SLAVE=y

peripheral uart project no child_image/rpc_host.conf

Parents Reply
  • Hi,

    Do you use a nRF5340 DK as both a central and peripheral? If so, you need to configure both the application on the app core and the hci_rpmsg on the net core to support data length extension. From what I can see you have not doen this for the peripheral code. Other than that, the configurations you use seems good. You can refer to the configuration under 12. Configure the application to enable data length extension in Exercise 2 in the Bluetooth fundamentals course on the DevAcademy for more details (note that you need to click on "nRF5340 DK" to see the configurations relevant for that).

Children
Related