increase the size of the buffer used to store the data of the received transmissions

Hi, I am trying to increase the size of the data received by bluetooth, at the moment it allows me to receive a data up to 20 bytes, and I have been reading about how to configure for a larger data, and I have found in some parts that CONFIG_BT_L2CAP_RX_MTU, or CONFIG_BT_BUF_ACL_RX_SIZE is used, but both appear to me as undeclared symbols. 

I found this ticket, but it is not clear to me: https://devzone.nordicsemi.com/f/nordic-q-a/76585/extends-the-mtu-size-in-latest-zephyr?ReplyFilter=Answers&ReplySortBy=Answers&ReplySortOrder=Descending

im using nRF Connect 2.3.0

CONFIG_NCS_SAMPLES_DEFAULTS=y

CONFIG_BT=y
CONFIG_BT_DEBUG_LOG=y
CONFIG_BT_MAX_CONN=2
CONFIG_BT_MAX_PAIRED=2
CONFIG_BT_SMP=y
CONFIG_BT_L2CAP_TX_BUF_COUNT=6



CONFIG_BT_PERIPHERAL=y
CONFIG_BT_DEVICE_NAME="IPG PINNACLE"
CONFIG_BT_DEVICE_APPEARANCE=961

CONFIG_BT_BAS=y
CONFIG_BT_HIDS=y
CONFIG_BT_HIDS_MAX_CLIENT_COUNT=2
CONFIG_BT_HIDS_DEFAULT_PERM_RW_ENCRYPT=y
CONFIG_BT_GATT_UUID16_POOL_SIZE=40
CONFIG_BT_GATT_CHRC_POOL_SIZE=20

CONFIG_BT_CONN_CTX=y
CONFIG_BT_DIS=y
CONFIG_BT_DIS_PNP=y
CONFIG_BT_DIS_MANUF="NordicSemiconductor"
CONFIG_BT_DIS_PNP_VID_SRC=2
CONFIG_BT_DIS_PNP_VID=0x1915
CONFIG_BT_DIS_PNP_PID=0xEEEF
CONFIG_BT_DIS_PNP_VER=0x0100

CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048

CONFIG_BT_SETTINGS=y
CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FLASH_MAP=y
CONFIG_NVS=y
CONFIG_SETTINGS=y

CONFIG_DK_LIBRARY=y

Parents
  • Hi,

    Are you getting an error/warning in the build output, or does it show as "undefined" in the editor when you try to add the symbols to your prj.conf? 

    # ATT_MTU - 247
    CONFIG_BT_L2CAP_TX_MTU=251
    CONFIG_BT_BUF_ACL_RX_SIZE=251
    CONFIG_BT_BUF_ACL_TX_SIZE=251
    
    # Support max. Radio packet length
    CONFIG_BT_CTLR_DATA_LENGTH_MAX=251

    Related ticket:  Updating MTU Size for Tx and Rx with Android BLE Client  

    Best regards,

    Vidar

  • I was getting that warning, but now I implemented the related ticket you provided, the program builds and runs without errors or warnings, but it is only receiving at most 20 bytes. I am sending the packet from the nrf connect mobile application.

    CONFIG_NCS_SAMPLES_DEFAULTS=y
    
    CONFIG_BT=y
    CONFIG_BT_DEBUG_LOG=y
    CONFIG_BT_MAX_CONN=2
    CONFIG_BT_MAX_PAIRED=2
    CONFIG_BT_SMP=y
    
    CONFIG_BT_PERIPHERAL=y
    CONFIG_BT_DEVICE_NAME="IPG PINNACLE"
    CONFIG_BT_DEVICE_APPEARANCE=961
    
    CONFIG_BT_BAS=y
    CONFIG_BT_HIDS=y
    CONFIG_BT_HIDS_MAX_CLIENT_COUNT=2
    CONFIG_BT_HIDS_DEFAULT_PERM_RW_ENCRYPT=y
    CONFIG_BT_GATT_UUID16_POOL_SIZE=40
    CONFIG_BT_GATT_CHRC_POOL_SIZE=20
    
    
    CONFIG_BT_BUF_ACL_RX_SIZE=251
    CONFIG_BT_BUF_ACL_TX_SIZE=251
    CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
    CONFIG_BT_L2CAP_TX_MTU=247
    CONFIG_BT_L2CAP_TX_BUF_COUNT=6
    
    CONFIG_BT_CONN_CTX=y
    CONFIG_BT_DIS=y
    CONFIG_BT_DIS_PNP=y
    CONFIG_BT_DIS_MANUF="NordicSemiconductor"
    CONFIG_BT_DIS_PNP_VID_SRC=2
    CONFIG_BT_DIS_PNP_VID=0x1915
    CONFIG_BT_DIS_PNP_PID=0xEEEF
    CONFIG_BT_DIS_PNP_VER=0x0100
    
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
    
    CONFIG_BT_SETTINGS=y
    CONFIG_FLASH=y
    CONFIG_FLASH_PAGE_LAYOUT=y
    CONFIG_FLASH_MAP=y
    CONFIG_NVS=y
    CONFIG_SETTINGS=y
    
    
    CONFIG_DK_LIBRARY=y

  • Please register the "att_mtu_updated" callback to get notified when the ATT MTU is increased. 

    ...
    
    void mtu_updated(struct bt_conn *conn, uint16_t tx, uint16_t rx)
    {
    	printk("Updated MTU: TX: %d RX: %d bytes\n", tx, rx);
    }
    
    static struct bt_gatt_cb gatt_callbacks = {
    	.att_mtu_updated = mtu_updated
    };
    
    ...
    
    void main(void)
    { 
       ...
       	err = bt_enable(NULL);
    	if (err) {
    		error();
    	}
    	/* Callback must be registered after bt_enable() */
    	bt_gatt_cb_register(&gatt_callbacks);

    Also, what service are you trying to write to, and do you get any errors when trying to write more than 20 bytes to it?

Reply
  • Please register the "att_mtu_updated" callback to get notified when the ATT MTU is increased. 

    ...
    
    void mtu_updated(struct bt_conn *conn, uint16_t tx, uint16_t rx)
    {
    	printk("Updated MTU: TX: %d RX: %d bytes\n", tx, rx);
    }
    
    static struct bt_gatt_cb gatt_callbacks = {
    	.att_mtu_updated = mtu_updated
    };
    
    ...
    
    void main(void)
    { 
       ...
       	err = bt_enable(NULL);
    	if (err) {
    		error();
    	}
    	/* Callback must be registered after bt_enable() */
    	bt_gatt_cb_register(&gatt_callbacks);

    Also, what service are you trying to write to, and do you get any errors when trying to write more than 20 bytes to it?

Children
  • when 20 bytes are exceeded, no errors are displayed, only the data is not received.
    The service I used is based on the example of peripheral hids keyboard, the battery service, see below.

    static ssize_t write_blvl(struct bt_conn *conn, 
    						  const struct bt_gatt_attr *attr,
    			  			  const void *buf, 
    						  uint16_t len, 
    						  uint16_t offset,
    						  uint8_t flags)
    {
    	
    	if (offset + len > CMD_BUFFER_SIZE) {
    		return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
    	}
    
    	memcpy(cmd_buffer + offset, buf, len);
    	size_t current_cmd_size = offset + len;
    
    	
    	printk("\n");
    	set_command_data(cmd_buffer[2]);
    	printk("\nACK Package: ");
    	for(int i = 0; i < current_cmd_size; i++){
    		printk("%02x", cmd_buffer[i]);
    		
    		if(i+1 < current_cmd_size){
    			printk("-");
    		}
    	}
    	printk("\n-- End of command --\n");
    	
    	return len;
    }
    BT_GATT_SERVICE_DEFINE(bas,
    	BT_GATT_PRIMARY_SERVICE(BT_UUID_BAS),
    	BT_GATT_CHARACTERISTIC(BT_UUID_BAS_BATTERY_LEVEL,
    			       BT_GATT_CHRC_READ | BT_GATT_CHRC_NOTIFY | BT_GATT_CHRC_WRITE,
    			       BT_GATT_PERM_READ | BT_GATT_PERM_WRITE, read_blvl, write_blvl,
    			       &cmd_buffer),
    	BT_GATT_CHARACTERISTIC(BT_UUID_RESPONSE_COMM,
    			       BT_GATT_CHRC_READ,
    			       BT_GATT_PERM_READ | BT_GATT_PERM_WRITE, read_blvl, NULL,
    			       &comm_response),
    	
    	BT_GATT_CCC(blvl_ccc_cfg_changed,
    		    BT_GATT_PERM_READ | BT_GATT_PERM_WRITE),
    );

    here you can see updated MTU, but still the same size.

  • The log shows that the ATT MTU did not get increased. Do you have another phone you can test with? 

Related