Set MTU size in Zephyr

Hello,

I ran the throughput example ,but I found that setting the MTU size actually requires calling the bt_gatt_exchange_mtu function, which is different from sdk16.0 .

In sdk16.0 or other versions, I can set the MTU size by calling nrf_ble_gatt_att_mtu_periph_set()  and nrf_ble_gatt_att_mtu_central_set() .

Is there any way to automatically set the MTU size in Zephyr?

Best Regards,

Gray

  • What do you mean by automatically?

  • Hello, haakonsh

    Sorry, my description is not clear enough.
    What I mean is how to set the MTU before the connection, without calling bt_gatt_exchange_mtu() to set it after the connection.

    Best Regards,

    Gray

  • You can't set it before a connection as the MTU exchange is a negotiation between the Central and Peripheral (where the Central ultimately decides what value to use). You'll have to initiate such an exchange for each established connection. 

  • Hi,haakonsh

    My doubt is why the Central does not choose to set MTU_SIZE?

    After connecting, I called bt_gatt_get_mtu() and the read size was 23 instead of the set size.

    https://github.com/nrfconnect/sdk-nrf/blob/master/samples/bluetooth/throughput/prj.conf

  • Hey Gray,

    You configs looks good.

    We need more information however. I suggest you start by enabling debug logs for the BT stack and share that. A sniffer trace would also help. 

1 2