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

Parents
  • I have a similar issue as this. Using the Master Control Panel application on my Android device to connect to my nRF51822 module (acting as the GATT server), I have implemented the Device Manager onto my BLE module and am able to bond the phone and device. I then set notifications enabled onto my custom service through the phone, and start sending notifications from my module by pressing a key on my keyboard (UART communication). This works fine but once I disconnect with the phone and try to reconnect, it shows on the Master Control Panel that notifications are still enabled and that I don't have to write and set the CCCD value of the same characteristic value I was notifying before disconnection. However when I start sending notifications, it is displayed on my terminal that I am getting the NRF_ERROR_INVALID_STATE event. If the device manager is suppose to manage bonds, how come the CCCD value is set back to 0 on my module?

Reply
  • I have a similar issue as this. Using the Master Control Panel application on my Android device to connect to my nRF51822 module (acting as the GATT server), I have implemented the Device Manager onto my BLE module and am able to bond the phone and device. I then set notifications enabled onto my custom service through the phone, and start sending notifications from my module by pressing a key on my keyboard (UART communication). This works fine but once I disconnect with the phone and try to reconnect, it shows on the Master Control Panel that notifications are still enabled and that I don't have to write and set the CCCD value of the same characteristic value I was notifying before disconnection. However when I start sending notifications, it is displayed on my terminal that I am getting the NRF_ERROR_INVALID_STATE event. If the device manager is suppose to manage bonds, how come the CCCD value is set back to 0 on my module?

Children
Related