This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

ncs 1.6.1 peripheral_uart example - increasing NUS size

Hi,

I'm working with the ncs 1.6.1 peripheral_uart example and am looking to increase the size of the data frame to send 240 bytes per data frame.

I have seen several threads regarding this, but have not seen the complete solution shown anywhere.

Could you post an example of main.c and prj.conf where the NUS data frame is 240 bytes?

Thanks

Parents
  • Hi Alvin

    There are no changes necessary in main.c, but you'll need to add the following configs to the prj.conf file:

    CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS=n
    
    CONFIG_BT_BUF_ACL_RX_SIZE=251
    CONFIG_BT_GATT_CLIENT=y
    CONFIG_BT_ATT_PREPARE_COUNT=2
    CONFIG_BT_CONN_TX_MAX=10
    CONFIG_BT_L2CAP_TX_BUF_COUNT=10
    CONFIG_BT_L2CAP_TX_MTU=247
    CONFIG_BT_L2CAP_DYNAMIC_CHANNEL=y
    CONFIG_BT_CTLR_PHY_2M=y
    CONFIG_BT_CTLR_RX_BUFFERS=2
    CONFIG_BT_BUF_ACL_TX_COUNT=10
    CONFIG_BT_BUF_ACL_TX_SIZE=251
    CONFIG_BT_CTLR_DATA_LENGTH_MAX=251

    The project must also be configured to set the BT_NUS_UART_BUFFER_SIZE to 240 and UART_0_NRF_TX_BUFFER_SIZE in your project's Kconfig file to 240. After that the peripheral_uart sample will be able to transmit 240 bytes at a time (I just tested it on my end). You should make sure that the central you use to connect to the device supports MTU sizes of up to 240 though.

    Best regards,

    Simon

  • That worked, thank you.

    I could not get UART_0_NRF_TX_BUFFER_SIZE to update when adding it to the Kconfig file, so I just added the following line into the prj.conf file:

    CONFIG_UART_0_NRF_TX_BUFFER_SIZE=240

    In main.c, would it be appropriate use bt_conn_le_data_len_update() to update the MTU to 240?

Reply Children
No Data
Related