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

sd_ble_gatts_exchange_mtu_reply() returns NRF_ERROR_INVALID_PARAM given ATT MTU of 247

Hi. The same issue I have is described here, but I've been asked to post a new question:

https://devzone.nordicsemi.com/f/nordic-q-a/29084/why-sd_ble_gatts_exchange_mtu_reply-returns-nrf_error_invalid_param

I've tried to copy the throughput example in SDK 14.0.0 to increase the ATT MTU. Here's my handling of the BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST event (the peer is requesting 230):

case BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST:
NRF_LOG_DEBUG("BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST, client_rx_mtu: %d", p_ble_evt->evt.gatts_evt.params.exchange_mtu_request.client_rx_mtu);
err_code = sd_ble_gatts_exchange_mtu_reply(p_ble_evt->evt.gatts_evt.conn_handle, BLE_ATT_MTU);
APP_ERROR_CHECK(err_code);
break;

In app_config.h:

#define NRF_BLE_GATT_MAX_MTU_SIZE 247
Before enabling the BLE stack:
ble_cfg.conn_cfg.params.gatt_conn_cfg.att_mtu = NRF_BLE_GATT_MAX_MTU_SIZE;
NRF_ERROR_INVALID_PARAM here means "Invalid Server RX MTU size supplied". How is it invalid?
[Edit]
I'm using the advertising module and setting the tag as follows:
#define APP_BLE_CONN_CFG_TAG 1
ble_advertising_conn_cfg_tag_set(&m_advertising, APP_BLE_CONN_CFG_TAG);
err_code = ble_advertising_start(&m_advertising, BLE_ADV_MODE_SLOW);
APP_ERROR_CHECK(err_code);
Related