nRF5 SDK v13.0.0
Experimental: GATT Module
This information applies to the following SoftDevices: S132, S140

To allow faster communication, a GATT client can request to change parameters for a Bluetooth low energy connection. The GATT server then replies with the parameter value that it can or wants to support, and the parameter value is adjusted accordingly.

The GATT Module (API documentation) can be used to handle this parameter exchange. The module also keeps track of the current parameters for all active links. The following connection parameters can be handled by the module:

Maximum ATT_MTU size

The Bluetooth Attribute Protocol (ATT) defines the default Maximum Transmission Unit (MTU) size to be 23 bytes. This means that in a connection, each transaction between a GATT server and GATT client can contain a maximum of 23 bytes. Of these 23 bytes, only 21 can be used for the actual payload. Increase the maximum ATT_MTU size to achieve longer payloads by sending several packets for one transaction.

The default value that the module uses is NRF_BLE_GATT_MAX_MTU_SIZE, which is set to 251 bytes. This is also the maximum value that the SoftDevice can handle.

Data length

The default data length for a radio packet is 27 bytes. Increase the data length to use bigger radio packets, so that more data can be sent in one packet.

The default value that the modules uses is NRF_BLE_GATT_MAX_MTU_SIZE + 4, thus 255 bytes. This is also the maximum value that the SoftDevice can handle.

Usage

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.

To set a new data length, use nrf_ble_gatt_data_length_set. A new data length can be set for an existing connection or before a connection is established.

After the new parameter value has been negotiated, the callback function is called with the value that has been agreed.

At any time, you can call nrf_ble_gatt_eff_mtu_get or nrf_ble_gatt_data_length_get to retrieve the current parameter value for a given connection.

For a complete usage example, see the Experimental: ATT_MTU Throughput Example.


Documentation feedback | Developer Zone | Subscribe | Updated