hid_int_ep_write error "Failed to write endpoint buffer 0x81"

I make a ble hid usb dongle with ncs2.0, ble keyboard send keycode to hid dongle, hid dongle send the keycode to computer.

When keyboard send keycode slow, it's work fine. But when keyboard send keycode fast, it show "Failed to write endpoint buffer 0x81" sometimes, and in computer side, some keyboard data lost.

Some code:

static uint8_t hogp_notify_cb(struct bt_hogp *hogp,
			     struct bt_hogp_rep_info *rep,
			     uint8_t err,
			     const uint8_t *data)
{
	uint8_t report[20];
	uint8_t size = bt_hogp_rep_size(rep);
	uint8_t i;
	int ret;

	if (!data) {
		return BT_GATT_ITER_STOP;
	}
	memcpy(&report[1], data, size);
	report[0] = INPUT_REP_KEYS_REF_ID;
	ret = hid_int_ep_write(usb_hid_dev, report, INPUT_REPORT_KEYS_MAX_LEN+1, NULL);
	if (ret) {
		printk("HID write error, %d\n", ret);
	}
	return BT_GATT_ITER_CONTINUE;
}

Log info:

00> W: Failed to write endpoint buffer 0x81
00> W: Failed to write endpoint buffer 0x81
00> W: Failed to write endpoint buffer 0x81
00> W: Failed to write endpoint buffer 0x81
00> W: Failed to write endpoint buffer 0x81
00> W: Failed to write endpoint buffer 0x81
00> W: Failed to write endpoint buffer 0x81
00> W: Failed to write endpoint buffer 0x81
00> W: Failed to write endpoint buffer 0x81
00> HID write error, -11
00> W: Failed to write endpoint buffer 0x81
00> W: Failed to write endpoint buffer 0x81
00> W: Failed to write endpoint buffer 0x81
00> W: Failed to write endpoint buffer 0x81
00> W: Failed to write endpoint buffer 0x81
00> W: Failed to write endpoint buffer 0x81
00> HID write error, -11
00> W: Failed to write endpoint buffer 0x81
00> W: Failed to write endpoint buffer 0x81
00> W: Failed to write endpoint buffer 0x81

Parents Reply Children
  • As a note on this since I had the same issue, I first checked that CONFIG_USB_HID_POLL_INTERVAL_MS was set to 1 in the prj.conf. On top of it, It's always good to set up a semaphore that is released only on the previous usb transfer being set succesfully, before initiating a new one. The lack of speed in DMA transfer is due to some other limitation in the firmware which slows it down won't probably depend on the USB transfer speed. 

Related