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

sd_ble_gatts_hvx() returns NRF_ERROR_INVALID_STATE (error code 8)

Hi

Try to send characteristic notification by invoking sd_ble_gatts_hvx() with the following parameters:

	uint32_t err_code = NRF_SUCCESS;
	ble_gatts_hvx_params_t params;

	memset(&params, 0, sizeof(params));
	params.type = BLE_GATT_HVX_NOTIFICATION;
	params.handle = GetValueHandle();
	params.p_data = pData;
	params.offset = 0;
	params.p_len = &length;

	if (srv::ble::ConnectionHandleInvalid != mrBleInterface.GetConnectionHandle())
	{
		err_code = sd_ble_gatts_hvx(mrBleInterface.GetConnectionHandle(), &params);
		assert(err_code == NRF_SUCCESS);
	}

Unfortunately, the error code 8 NRF_ERROR_INVALID_STATE occurs. The connection is established and bonding is completed. ( checked by the DM_EVT_LINK_SECURED event from the device manager)

Do you have any suggestion what "invalid state" coulde be?

Thanks for your help.

BR Armin

Related