Hello,
I am working on a project that modified from ble_app_uart_c, with sdk v16.0, softdevice S140
In my case, I defined an event observer by
NRF_SDH_BLE_OBSERVER(m_ble_observer, APP_BLE_OBSERVER_PRIO, ble_evt_handler, &m_scan); in initial routine.
And
/**@brief Function for handling events from the GATT library. */
static void gatt_evt_handler(nrf_ble_gatt_t * p_gatt, nrf_ble_gatt_evt_t const * p_evt)
{
if (p_evt->evt_id == NRF_BLE_GATT_EVT_ATT_MTU_UPDATED)
{
printf("ATT MTU exchange completed.\n");
m_ble_nus_max_data_len = p_evt->params.att_mtu_effective - OPCODE_LENGTH - HANDLE_LENGTH;
printf("Ble NUS max data length set to 0x%X(%d)\n", m_ble_nus_max_data_len, m_ble_nus_max_data_len);
}
}
/**@brief Function for initializing the GATT library. */
void gatt_init(void)
{
ret_code_t err_code;
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);
}
Just want to observe NRF_BLE_GATT_EVT_ATT_MTU_UPDATED event, but the event handler gatt_evt_handler never triggered.
Have tried to put NRF_BLE_GATT_EVT_ATT_MTU_UPDATED event handler in ble_evt_handler defined above, not working. But other event such as BLE_GATTC_EVT_TIMEOUT can be triggered in this handler.
Thanks.