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

Not able to transmit more than 20bytes with sample application "central_uart"

Hello,

I am working on nrf5340DK board and with a sample example "central_uart" under ncs->nrf->samples->bluetooth & "peripheral_uart" from ncs v1.5.1. I wanted to send approx 200~300bytes but not able to send more than 20bytes. 

When trying to send more than 20bytes getting warning " ATT error code: 0x06" from the function ble_data_sent() at central_uart side and not receiving any data at peripheral side.

I tried the following changes but did not worked out for me:

1. Changed  BT_NUS_UART_BUFFER_SIZE  to 200 in prj.cnf of peripheral_uart 

2. Increased  default BT_L2CAP_RX_MTU and BT_L2CAP_TX_MTU  in ncs/zephyr/subsys/bluetooth/host/Kconfig.l2cap

Please help me to send approx 200~300 bytes from central_uart to peripheral_uart overl BLE. 

Best Regards,

SanketC

Parents
  • Hi Sanket

    I would recommend taking a look at the throughput example:
    nrf/samples/bluetooth/throughput

    If you copy the configuration from this example into your own you should be able to get better throughput. 

    For the nRF5340 app you need the following configuration (as show in prj_nrf5340dk_nrf5340_cpuapp.conf):

    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_BUF_ACL_RX_SIZE=251
    CONFIG_BT_L2CAP_DYNAMIC_CHANNEL=y

    In the child image folder you can see the config needed for the hci_rpmsg project running on the network core:

    CONFIG_BT_BUF_ACL_TX_SIZE=251
    CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
    CONFIG_BT_BUF_ACL_RX_SIZE=251

    CONFIG_BT_MAX_CONN=2

    Best regards
    Torbjørn

Reply
  • Hi Sanket

    I would recommend taking a look at the throughput example:
    nrf/samples/bluetooth/throughput

    If you copy the configuration from this example into your own you should be able to get better throughput. 

    For the nRF5340 app you need the following configuration (as show in prj_nrf5340dk_nrf5340_cpuapp.conf):

    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_BUF_ACL_RX_SIZE=251
    CONFIG_BT_L2CAP_DYNAMIC_CHANNEL=y

    In the child image folder you can see the config needed for the hci_rpmsg project running on the network core:

    CONFIG_BT_BUF_ACL_TX_SIZE=251
    CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
    CONFIG_BT_BUF_ACL_RX_SIZE=251

    CONFIG_BT_MAX_CONN=2

    Best regards
    Torbjørn

Children
  • Hello Torbjørn,

    Thank you for your reply. As per your suggestion, I tried adding configurations in prj.conf of ncs/nrf/samples/bluetooth/central_uart & ncs/nrf/samples/bluetooth/peripheral_uart and also added configuration of child imahe in prj.conf in ncs/zephyr/samples/bluetooth/hci_rpmsg

    But while building the project from the cmd line I am getting this error:

    ncs_1_5_1/ncs/nrf/samples/bluetooth/central_uart/prj.conf:48: warning: attempt to assign the value '251' to the undefined symbol BT_BUF_ACL_RX_SIZE

    Please note that in my throughput example also I am not able to find "ACL" related stuff in any conf file.

    For your information, I am using ncs v1.5.1

    Please help to guide me.

    Best Regards,

    Sanket Chadawar

  • Adding to above,

    I also tried by adding following configuration in prj.conf of peripheral_uart & central_uart (ncs default sample application)

    CONFIG_BT_USER_DATA_LEN_UPDATE=y
    CONFIG_BT_RX_BUF_LEN=255
    #CONFIG_BT_GATT_CLIENT=y
    CONFIG_BT_ATT_TX_MAX=10
    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_RX_MTU=247
    CONFIG_BT_CTLR_TX_BUFFER_SIZE=251
    CONFIG_BT_CTLR_DATA_LENGTH_MAX=251

    And following configuration in prj.conf of ncs/zephyr/samples/bluetooth/hci_rpmsg

    CONFIG_BT_USER_DATA_LEN_UPDATE=y
    CONFIG_BT_RX_BUF_LEN=255
    CONFIG_BT_L2CAP_TX_MTU=247
    CONFIG_BT_L2CAP_RX_MTU=247
    CONFIG_BT_CTLR_TX_BUFFER_SIZE=251
    CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
    CONFIG_BT_MAX_CONN=2    #default value was 16 

    Also updated connect() api in main.c of peripheral_uart. as 

    static void connected(struct bt_conn *conn, uint8_t err)
    {
    	char addr[BT_ADDR_LE_STR_LEN];
    
    	if (err) {
    		LOG_ERR("Connection failed (err %u)", err);
    		return;
    	}
    
    	bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));
    	LOG_INF("Connected %s", log_strdup(addr));
    
    	current_conn = bt_conn_ref(conn);
    
    	dk_set_led_on(CON_STATUS_LED);
    
            printk("Start DLE...\n");
            
            //below code is added to increase MTU size as per throughput example
    	struct bt_conn_le_data_len_param data_len_param;
    
    	data_len_param.tx_max_len = 200; // byte
    	data_len_param.tx_max_time = 3750; // us
    
    	err = bt_conn_le_data_len_update(current_conn, &data_len_param);
    	if (err)
    	{
    		printk("LE data length update failed: %d\n", err);
    	}
            else
    	{
    		printk("LE data length update success \n");
    	}
    }

    updated UART_BUF_SIZE to 100.

    Still, I am not able to send more than 36 characters from central to peripheral and getting an error as  central_uart: ATT error code: 0x09

    Note: Data received at the peripheral side are in a chunk of 18bytes.

  • Hi Sanket

    My bad, I didn't realize you were using the UART examples for both the peripheral and the central. 

    Normally the central needs to initiate a data length and MTU update, and the central_uart example does not do this. 

    In order to fix this all you have to do is add some code in the connected(..) callback function, in order to request larger MTU:

    static struct bt_gatt_exchange_params params;
    params.func = mtu_exchange_func;
    err = bt_gatt_exchange_mtu(conn, &params);
    if (err) {
    	LOG_WRN("Failed to exchange MTU: %d", err);
    }

    You also need to implement the callback function, but it doesn't need to do anything in particular. If the exchange fails you will be notified through this function:

    void mtu_exchange_func(struct bt_conn *conn, uint8_t err, struct bt_gatt_exchange_params *params)
    {
    
    }

    Best regards
    Torbjørn

  • Hello Torbjørn,

    Thank you for your inputs. By looking and your suggestions and throughput example I could able to achieve 247B MTU size.

    Thanks for the help.

    Best Regards,

    SanketC

  • Hi Sanket

    That is great news. I will close the case then Slight smile

    Best regards
    Torbjørn

Related