Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Obtaining maximum packet size

Hi,

My device is peripheral and server and is connected to an (android) phone. I have two related questions:

a) I understand that maximal packet size is obtained by calling sd_ble_gap_data_length_update with null p_dl_params and null p_dl_limitation. Is this correct?

b) How can I know the maximal GATT payload size? (Is it dependant on the phone?)

Thanks,

Daniel  

Parents
  • Hi,

    a) Providing NULL for p_dl_params means all parameters use BLE_GAP_DATA_LENGTH_AUTO, which means the SoftDevice chooses the highest value supported in the current configuration and connection parameters, see the sd_ble_gap_data_length_update() documentation.

    p_dl_limitation is an output parameter, which is used when sd_ble_gap_data_length_update() is used to respond to a Data Length Update request. If the values in the request can not be met, p_dl_limitation will contain the maximum values supported (which is also what is sent as the response.) If you set it to NULL there is still sent a response, but the values can not be read by the application as there is no ble_gap_data_length_limit_t structure holding them.

    b) Both link layer payload (which is the one set with GAP data length update) and GATT MTU depend on the phone yes. (I.e. both vary from device to device, which is why there are procedures for negotiating an increase from the mandatory default values.)

    Regards,
    Terje

  • Terje,

    Thanks for the clear answer.

    I have a follow-up questions:

    When calling sd_ble_gap_data_length_update with null p_dl_params and not null p_dl_limitation, the phone accepts the requested limitations (all field are zero). Yet, the maximal payload is 27 and the actual maximal data I can send is 20 bytes. 

    Are these the expected values? If so, is there a way to ask for more? (since I see from the BLE specs the the payload can be up to 251 bytes).

    Thanks again,

    Daniel

  • Hi,

    Sorry for not getting back to you earlier.

    First, just to be clear and to avoid any confusion, it is the value of p_dl_params which is null, i.e. it is a null pointer. (It is not the fields of the structure that are set to null. There is no structure.)

    You should then get the maximum values possible (as negotiated with the peer), limited by the maximum values configured for the SoftDevice. Most examples set up SoftDevice configuration with the SoftDevice Handler library function nrf_sdh_ble_default_cfg_set(), which again uses the NRF_SDH_BLE_* defines from sdk_config.h for the  configuration.

    This means, if you provide null instead of a structure, and sdk_config.h uses large values, and the peer accepts those values, then you should get those values.

    Regards,
    Terje

Reply
  • Hi,

    Sorry for not getting back to you earlier.

    First, just to be clear and to avoid any confusion, it is the value of p_dl_params which is null, i.e. it is a null pointer. (It is not the fields of the structure that are set to null. There is no structure.)

    You should then get the maximum values possible (as negotiated with the peer), limited by the maximum values configured for the SoftDevice. Most examples set up SoftDevice configuration with the SoftDevice Handler library function nrf_sdh_ble_default_cfg_set(), which again uses the NRF_SDH_BLE_* defines from sdk_config.h for the  configuration.

    This means, if you provide null instead of a structure, and sdk_config.h uses large values, and the peer accepts those values, then you should get those values.

    Regards,
    Terje

Children
Related