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

got error while sending longer data via BLE

Hello, 

On nRF5340, sdk v1.6.1, I use this function to send data to center via BLE:

ble_data_send( ble_connection, data, 182 );

and here is the definition of the function:

bool ble_data_send( struct bt_conn * conn, const uint8_t * data, uint16_t len )
{
    const struct bt_gatt_attr *attr = &ble_collect_service.attrs[4];

    struct bt_gatt_notify_params params =
    {
        .uuid = BT_UUID_CLS_DATA,
        .attr = attr,
        .data = data,
        .len = len,
        .func = NULL
    };

    // Check whether notifications are enabled or not
    if( bt_gatt_is_subscribed( conn, attr, BT_GATT_CCC_NOTIFY ) )
    {
        if( bt_gatt_notify_cb( conn, &params ) )
        {
            return false; // Send failed
        }
        else
        {
            return true;
        }
    }
    else
    {
        return false; 
    }
}

but while running I got this error:

00> [00:00:26.132,934] <wrn> bt_att: No ATT channel for MTU 185
00> [00:00:26.132,934] <wrn> bt_gatt: No buffer available to send notification

It seems the length of the data to be sent is too long(182 bytes). If I set the data length to 4, then there is no error.

How to solve this problem? how to send longer(182 bytes) data?

Thanks.

Parents
  • Hi 

    In order to get long MTU and extended data length in the nRF Connect SDK it is necessary to configure the Bluetooth stack properly, and when using the nRF5340 it is necessary to change the configuration for both the application running on the app core and the hci_rpmsg example running on the network core. 

    You can try to add the following to prj.conf in the application core project:

    CONFIG_BT_BUF_ACL_RX_SIZE=251
    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

    And then for the hci_rpmsg example, add the following:

    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

    You can also take a look at how the throughput example does this (the configuration I included above is copied from the throughput example). 

    Best regards
    Torbjørn
     

Reply
  • Hi 

    In order to get long MTU and extended data length in the nRF Connect SDK it is necessary to configure the Bluetooth stack properly, and when using the nRF5340 it is necessary to change the configuration for both the application running on the app core and the hci_rpmsg example running on the network core. 

    You can try to add the following to prj.conf in the application core project:

    CONFIG_BT_BUF_ACL_RX_SIZE=251
    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

    And then for the hci_rpmsg example, add the following:

    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

    You can also take a look at how the throughput example does this (the configuration I included above is copied from the throughput example). 

    Best regards
    Torbjørn
     

Children
Related