This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Updating MTU Size for Tx and Rx with Android BLE Client

Hello,

I am developing FW on NRF52840_DK for a BLE Peripheral as a Reader.

Reader to Mobile App Tx size is 32 bytes

Mobile App to Reader Rx size is 133 bytes.

When Mobile (GATT Client), sends read request, it reads the 32 byte data in two attempts.

While Mobile, sends data, my code is only able to read first 20 bytes !!

Looks like the MTU is set by default to works as BLE 4.0/4.1 and  ATT data is set to max 20 bytes

How can i increase MTU size so that Client Reads all 32 bytes in 1 attempt and Reader Code can read all 133 bytes in 1 attempt.

I added these Kconfig settings, but still doesnt work. I dont want to change MTU dynamically, just want to set it once during build time.

CONFIG_BT_USER_DATA_LEN_UPDATE=y
CONFIG_BT_BUF_ACL_RX_SIZE=251
CONFIG_BT_BUF_ACL_TX_SIZE=251
CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
Parents
  • Hello,

    Please try to add CONFIG_BT_L2CAP_TX_MTU=247 as well (default is usually 65 or 23). As you can see from the defines below, this symbol may actually limit your ATT_MTU size even if CONFIG_BT_BUF_ACL_<RX/TX>_SIZE are properly configured.

    /** L2CAP PDU header size, used for buffer size calculations */
    #define BT_L2CAP_HDR_SIZE               4
    
    /** Maximum Transmission Unit (MTU) for an outgoing L2CAP PDU. */
    #define BT_L2CAP_TX_MTU (CONFIG_BT_L2CAP_TX_MTU)
    
    
    /** Maximum Transmission Unit (MTU) for an incoming L2CAP PDU. */
    #define BT_L2CAP_RX_MTU (CONFIG_BT_BUF_ACL_RX_SIZE - BT_L2CAP_HDR_SIZE)
    
    
    /* ATT MTU must be equal for RX and TX, so select the smallest value */
    #define BT_ATT_MTU (MIN(BT_L2CAP_RX_MTU, BT_L2CAP_TX_MTU))

    Best regards,

    Vidar

Reply
  • Hello,

    Please try to add CONFIG_BT_L2CAP_TX_MTU=247 as well (default is usually 65 or 23). As you can see from the defines below, this symbol may actually limit your ATT_MTU size even if CONFIG_BT_BUF_ACL_<RX/TX>_SIZE are properly configured.

    /** L2CAP PDU header size, used for buffer size calculations */
    #define BT_L2CAP_HDR_SIZE               4
    
    /** Maximum Transmission Unit (MTU) for an outgoing L2CAP PDU. */
    #define BT_L2CAP_TX_MTU (CONFIG_BT_L2CAP_TX_MTU)
    
    
    /** Maximum Transmission Unit (MTU) for an incoming L2CAP PDU. */
    #define BT_L2CAP_RX_MTU (CONFIG_BT_BUF_ACL_RX_SIZE - BT_L2CAP_HDR_SIZE)
    
    
    /* ATT MTU must be equal for RX and TX, so select the smallest value */
    #define BT_ATT_MTU (MIN(BT_L2CAP_RX_MTU, BT_L2CAP_TX_MTU))

    Best regards,

    Vidar

Children
No Data
Related