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

nRF connect app actively requested mtu negotiation failed

Based on 52832, sdk15.3 running ble_app_hrs example, requesting MTU through nRF connect, the first success, the second time is unsuccessful, the app prompts Error 4 (0x4): GATT INVALID PDU


Device prompt: NRF_ERROR_INVALID_STATE

I did not make any changes to ble_app_hrs.
why?
How can multiple MTU consultations be conducted?

  • Hi, 

    Regarding the MTU exchange request resulting in "Error 4 (0x4): GATT INVALID PDU": this behavior is expected according to the Bluetooth specification. According to the spec, MTU request shall only be sent once during a connection:

    3.4.2.1 Exchange MTU Request (Blueooth Core Specification v.5.0.0, vol 3, Part F)
    The Exchange MTU Request is used by the client to inform the server of the
    client’s maximum receive MTU size and request the server to respond with its
    maximum receive MTU size.
    The Client Rx MTU shall be greater than or equal to the default ATT_MTU.
    This request shall only be sent once during a connection by the client. The
    Client Rx MTU parameter shall be set to the maximum size of the attribute
    protocol PDU that the client can receive.

    To set a new maximum MTU size, use nrf_ble_gatt_att_mtu_periph_set for peripheral devices and nrf_ble_gatt_att_mtu_central_set for central devices. The new ATT_MTU value is a static value; it must be set before the connection is established. Please see the GATT Module documentation. 

    -Amanda H.

  • Hi,

    After Bluetooth connection, can my app request mtu negotiation again?
    Not Exchange MTU.

  • Hi,

    zero said:
    After Bluetooth connection, can my app request mtu negotiation again?

    No, the request shall only be sent once during a connection by the client. If you do sd_ble_gattc_exchange_mtu_request() again, in the same connection, you will get NRF_ERROR_INVALID_STATE. 

    I recommend to call nrf_ble_gatt_att_mtu_periph_set() before or right after you disconnect. You can still call  nrf_ble_gatt_att_mtu_periph_set() to set the desired MTU while in the connection, but it won't have any effect before the next connection.

    -Amanda H.

Related