nRF5340 BLE: the configuration for BLE MTU

Hi Support Team,

I tried the BLE communication with the Nordic UART Service (NUS) and used the code in the 'Bluetooth Low Energy Fundamentals Lesson 4 - Exercise 3' course.

The default MTU size was too small for my application. I preferred not to change the code in the hci_rpmsg on the netCore, so I added the below configuration on the appCore side:

1. In the files \bt-fund-main\lesson4\blefund_less4_exer3_solution\child_image\hci_rpmsg.conf:

#GATT_CLIENT needed for requesting ATT_MTU update
CONFIG_BT_GATT_CLIENT=y
#PHY update needed for updating PHY request
CONFIG_BT_USER_PHY_UPDATE=y
#For data length update
CONFIG_BT_USER_DATA_LEN_UPDATE=y
#This is the maximum data length with Nordic Softdevice controller
CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
#These buffers are needed for the data length max. 
CONFIG_BT_BUF_ACL_TX_SIZE=251
CONFIG_BT_BUF_ACL_RX_SIZE=251
#This is the maximum MTU size with Nordic Softdevice controller
CONFIG_BT_L2CAP_TX_MTU=247

# Maxmum 2 connections are enough
CONFIG_BT_MAX_CONN=2

2. In the \bt-fund-main\lesson4\blefund_less4_exer3_solution\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

CONFIG_BT_NUS_UART_BUFFER_SIZE=400

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

CONFIG_HEAP_MEM_POOL_SIZE=2048
CONFIG_MAIN_STACK_SIZE=4096

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_RX_STACK_SIZE=2048
# Enable the NUS service
# STEP 1 - Enable the Kconfig symbol of the NUS service
CONFIG_BT_NUS=y
CONFIG_BT_NUS_AUTHEN=n
CONFIG_BT_NUS_SECURITY_ENABLED=n
# Enable bonding
CONFIG_BT_SETTINGS=n
CONFIG_FLASH=n
CONFIG_FLASH_PAGE_LAYOUT=n
CONFIG_FLASH_MAP=n
CONFIG_NVS=n
CONFIG_SETTINGS=n

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

#########################Added to increase the MTU###############################
CONFIG_BT_GATT_CLIENT=y
# STEP 8 - Enable PHY updates.
CONFIG_BT_USER_PHY_UPDATE=y

# STEP 12 - Update Data Length and MTU
CONFIG_BT_USER_DATA_LEN_UPDATE=y
#CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
CONFIG_BT_BUF_ACL_RX_SIZE=251
CONFIG_BT_BUF_ACL_TX_SIZE=251
CONFIG_BT_L2CAP_TX_MTU=247

But it did not work. Could you help me with the below questions:

(1). Could you help review the above configurations? what was missed for the MTU setting?

(2). I'm a little confused about the configuration alignment on the host and controller sides.  For Data Length, MTU, and PHY_UPDATE, which need to align the configuration on both host and controller? which only needs to change single side configuration? In Lesson 3 – Exercise 2, it sets all in the host's prj.conf file.

Thank you very much,

Best regards,

Yanpeng Wu

  • Update: These are some compiled warning

    (SOC_SERIES_STM32WBX || (BT_PHY_UPDATE && BT_CONN && BT_HCI_HOST && BT_RPC_STACK) || (BT_PHY_UPDATE
    && BT_CONN && BT_HCI_HOST && BT_HCI && BT)) (=n). See
    http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_BT_USER_PHY_UPDATE and/or look up
    BT_USER_PHY_UPDATE in the menuconfig/guiconfig interface. The Application Development Primer,
    Setting Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be
    helpful too.
    
    warning: BT_L2CAP_TX_MTU (defined at C:/ncs/v2.5.2/nrf\samples\common\mcumgr_bt_ota_dfu/Kconfig:122,
    C:/ncs/v2.5.2/nrf\subsys\bluetooth\services\fast_pair/Kconfig.fast_pair:80,
    C:/ncs/v2.5.2/zephyr/subsys/bluetooth/host\Kconfig.l2cap:30, subsys/bluetooth\host\Kconfig.l2cap:30)
    was assigned the value '247' but got the value ''. Check these unsatisfied dependencies:
    (NCS_SAMPLE_MCUMGR_BT_OTA_DFU_SPEEDUP || (BT_FAST_PAIR_GATT_SERVICE && BT_FAST_PAIR && BT) ||
    (BT_CONN && BT_HCI_HOST && BT_RPC_STACK) || (BT_CONN && BT_HCI_HOST && BT_HCI && BT)) (=n). See
    http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_BT_L2CAP_TX_MTU and/or look up
    BT_L2CAP_TX_MTU in the menuconfig/guiconfig interface. The Application Development Primer, Setting
    Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be helpful
    too.
    
    warning: BT_USER_DATA_LEN_UPDATE (defined at C:/ncs/v2.5.2/zephyr/subsys/bluetooth/host/Kconfig:341,
    subsys/bluetooth\host/Kconfig:341) was assigned the value 'y' but got the value 'n'. Check these
    unsatisfied dependencies: ((BT_DATA_LEN_UPDATE && BT_CONN && BT_HCI_HOST && BT_RPC_STACK) ||
    (BT_DATA_LEN_UPDATE && BT_CONN && BT_HCI_HOST && BT_HCI && BT)) (=n). See
    http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_BT_USER_DATA_LEN_UPDATE and/or look up
    BT_USER_DATA_LEN_UPDATE in the menuconfig/guiconfig interface. The Application Development Primer,
    Setting Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be
    helpful too.
    
    warning: BT_GATT_CLIENT (defined at C:/ncs/v2.5.2/zephyr/subsys/bluetooth/host\Kconfig.gatt:170,
    subsys/bluetooth\host\Kconfig.gatt:170) was assigned the value 'y' but got the value 'n'. Check
    these unsatisfied dependencies: ((BT_CONN && BT_HCI_HOST && BT_RPC_STACK) || (BT_CONN && BT_HCI_HOST
    && BT_HCI && BT)) (=n). See http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_BT_GATT_CLIENT
    and/or look up BT_GATT_CLIENT in the menuconfig/guiconfig interface. The Application Development
    Primer, Setting Configuration Values, and Kconfig - Tips and Best Practices sections of the manual
    might be helpful too.

    My Bluetooth is only used for the system configuration and provision, and FOTA, and will not be used for sensor data reporting like that. Could you help give a reference setting for MTU and Data Length for both appCore and netCore? With the default MTU, I can only send length=20 from the nRF mobile APP to the appCore's terminal with NUS. Thank you very much.

  • Hello,

    I believe the DevAcademy course should work. At least it did back when we worked on it, but I can't guarantee that something hasn't changed in more recent NCS versions.

    Can you please zip and upload your application folder, so that I can build it and see for myself?

    Due to Easter Holidays, we have some expected delay in our replys. I am sorry for this inconvenience.

    Best regards,

    Edvin

  • Hi Edvin,

    Thank you for the reply. Please find my attached project.
    The remote MTU setting is in \blefund_less4_exer3_solution\child_image\hci_rpmsg.conf.
    With this setting, I can only send strings less than 18 chars from 'UART terminal' to 'Nordic Connect Mobile APP', the vice direction is 20 chars.

    7462.blefund_less4_exer3_solution.zip

    Best regards,
    Yanpeng Wu

  • I can't see that you triggers the MTU exchange functions like it is done in Lesson 3 exercise 2

    Go through that, and implement those snippets to your application.

    Best regards,

    Edvin

  • Hi Edvin,

    Thank you for your reply. I created my ble services and met some problems. When I fix it and the BLE communication works, I will continue to try the MTU on my project.
    Thank you very much.

    Best regards,
    Yanpeng Wu

Related