chegewara / EspTinyUSB

ESP32S2 native USB library. Implemented few common classes, like MIDI, CDC, HID or DFU (update).
MIT License
488 stars 70 forks source link

HID generic can't perform multiple chunk write #102

Closed lorespaul closed 2 years ago

lorespaul commented 2 years ago

I'm developing a FIDO security key with esp32s2, and I need to perform write of buffer with length greater then max HID_REPORT_COUNT (64 bytes).

I have extended HIDusb, with a custom CTAPHID class similar to HIDgeneric with a different hid report descriptor. I'm also using version from tag 2.0.1 of this repository.

So when data is less then 64 bytes write goes right, but when I start to split data in chunk the second and subsequent writes returns -1.

This is mi report desc:

#define TUD_HID_REPORT_DESC_CTAP_INOUT(report_size, ...) \ 
    HID_USAGE_PAGE_N ( 0xF1D0, 2                  ),\
    HID_USAGE        ( 0x01                       ),\
    HID_COLLECTION   ( HID_COLLECTION_APPLICATION ),\
      /* Report ID if any */\
      __VA_ARGS__ \
      /* Input */ \
      HID_USAGE       ( 0x20                                   ),\
      HID_LOGICAL_MIN ( 0x00                                   ),\
      HID_LOGICAL_MAX_N ( 0xff, 2                              ),\
      HID_REPORT_SIZE ( 8                                      ),\
      HID_REPORT_COUNT( report_size                            ),\
      HID_INPUT       ( HID_DATA | HID_ABSOLUTE | HID_VARIABLE ),\
      /* Output */ \
      HID_USAGE       ( 0x21                                   ),\
      HID_LOGICAL_MIN ( 0x00                                   ),\
      HID_LOGICAL_MAX_N ( 0xff, 2                              ),\
      HID_REPORT_SIZE ( 8                                      ),\
      HID_REPORT_COUNT( report_size                            ),\
      HID_OUTPUT      ( HID_DATA | HID_ABSOLUTE | HID_VARIABLE ),\
    HID_COLLECTION_END \

instantiated with:

uint8_t const desc_hid_report[] =   
{TUD_HID_REPORT_DESC_CTAP_INOUT(CFG_TUD_HID_BUFSIZE, HID_REPORT_ID(report_id))}; // report_id = 0

Is there any chance to make this work?

EDIT: It seems that multiple write can't b performed in onData callback. Can close this issue.