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

MTU Update

Hi,

I am trying to update the MTU between the central and peripheral to the maximum MTU.

at the connection interrupt from the central side I added 

    err_code = sd_ble_gattc_exchange_mtu_request(p_ble_evt->evt.gap_evt.conn_handle, 247);
    APP_ERROR_CHECK(err_code);

but I got error 7, Invalid Parameter !! what parameter could be wrong !?

In my peripheral side I have the following code in the ble event handler:

	case BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST:
	  {
	    sd_ble_gatts_exchange_mtu_reply(m_conn_handle, NRF_SDH_BLE_GATT_MAX_MTU_SIZE);
	    
	  }break;

and in both sides I have the gatt_evt_handler() function.

what I am doing wrong !?

Please Help

BR

JK

Parents Reply Children
  • Hi,

    the function nrf_ble_gatt_att_mtu_central_set(&m_gatt, NRF_SDH_BLE_GATT_MAX_MTU_SIZE);

    return error invalid paramiter in the central side, in the gatt_init module, before any connection !

    BR

    JK

  • Is BLE_GATT_ATT_MTU_DEFAULT still 23 (it should not be changed)?

    Here is the param check inside nrf_ble_gatt_att_mtu_central_set:

    if ((desired_mtu < BLE_GATT_ATT_MTU_DEFAULT) || (desired_mtu >       NRF_SDH_BLE_GATT_MAX_MTU_SIZE))
    {
           return NRF_ERROR_INVALID_PARAM;
    }

  • Hi,

    this is the weirdest thing I seen !

    the desired_mtu is 247

    the BLE_GATT_ATT_MTU_DEFAULT is 23

    the NRF_SDH_BLE_GATT_MAX_MTU_SIZE is 247

    and still this nrf_ble_gatt_att_mtu_central_set function return NRF_ERROR_INVALID_PARAM

    Do you have any explenation for that ?

    I didn't change the anything in this function !

    BR

    JK

  • Hi,

    No, I'm afraid I don't have an explanation for that. Have you tried to only call gatt_init() and not nrf_ble_gatt_att_mtu_central_set()? nrf_ble_gatt_att_mtu_central_set() is redundant when you want to use the max. NRF_SDH_BLE_GATT_MAX_MTU_SIZE anyway.

  • Hi,

    How long should the central wait after the connection until it can request the MTU exchange ?

    what do you mean by using gatt_init() and not nrf_ble_gatt_att_mtu_central_set()?

    see the implementation of my gatt_init() below:

    /**@brief Function for initializing the GATT module.
     */
    static void gatt_init(void)
    {
        ret_code_t err_code = nrf_ble_gatt_init(&m_gatt, gatt_evt_handler);
        APP_ERROR_CHECK(err_code);
        
        err_code = nrf_ble_gatt_att_mtu_central_set(&m_gatt, NRF_SDH_BLE_GATT_MAX_MTU_SIZE);
        APP_ERROR_CHECK(err_code);
    }

    something else that maybe is related !

    I started my project with the ble_app_multilink_central example, and then added to it the nus service and the USB peripheral, and disabled the lbs_c_init() function that i don't need.

    can this example be cause a problem with MTU exchange ?

    BR 

    Jawad

Related