espressif / idf-extra-components

Additional components for ESP-IDF, maintained by Espressif
147 stars 89 forks source link

usb_host_hid get string_descriptor[] and report_descriptor[] (IEC-42) #230

Closed Postlast closed 1 year ago

Postlast commented 1 year ago

Is your feature request related to a problem?

usb_host_hid get string_descriptor[] and report_descriptor[]

Describe the solution you'd like.

I used https://components.espressif.com/components/espressif/usb_host_hid and it works. I still have little experience with the host and I can not find the functionality of how to get from the device in the program string_descriptor[] and report_descriptor[] Is there such a possibility?

Describe alternatives you've considered.

No response

Additional context.

No response

roma-jam commented 1 year ago

Hi @Postlast,

To get the report descriptor you can use the hid_host_get_report_descriptor call from HID Driver.

    uint8_t *hid_report_buffer;
    size_t hid_report_length = 0;

    ESP_ERROR_CHECK( hid_host_device_open(hid_device_handle, &dev_config) );
    hid_report_buffer = hid_host_get_report_descriptor(hid_device_handle,
                                                &hid_report_length);

    ESP_LOG_BUFFER_HEX(TAG, hid_report_buffer, hid_report_length);

Report descriptor is in raw format. Example of output during the HID Device connection:

I (382) main_task: Returned from app_main()
I (3682) example: HID Device, protocol 'KEYBOARD' CONNECTED
I (3682) example: 05 01 09 06 a1 01 95 08 75 01 15 00 25 01 05 07 
I (3682) example: 19 e0 29 e7 81 02 81 03 95 05 05 08 19 01 29 05 
I (3692) example: 91 02 95 01 75 03 91 01 95 06 75 08 15 00 26 ff 
I (3692) example: 00 05 07 19 00 2a ff 00 81 00 c0 
I (3702) example: HID Device, protocol 'MOUSE' CONNECTED
I (3712) example: 05 01 09 02 a1 01 85 02 09 01 a1 00 95 10 75 01 
I (3712) example: 15 00 25 01 05 09 19 01 29 10 81 02 95 02 75 0c 
I (3722) example: 16 01 f8 26 ff 07 05 01 09 30 09 31 81 06 95 01 
I (3732) example: 75 08 15 81 25 7f 09 38 81 06 95 01 05 0c 0a 38 
I (3732) example: 02 81 06 c0 c0 05 0c 09 01 a1 01 85 03 95 02 75 
I (3742) example: 10 15 01 26 ff 02 19 01 2a ff 02 81 00 c0 05 01 
I (3752) example: 09 80 a1 01 85 04 95 01 75 02 15 01 25 03 09 82 
I (3752) example: 09 81 09 83 81 00 75 06 81 03 c0 06 bc ff 09 88 
I (3762) example: a1 01 85 08 95 01 75 08 15 01 26 ff 00 19 01 29 
I (3772) example: ff 81 00 c0 

Unfortunately, right now there is no chance to get serial descriptor easily with the HID Driver, we will add that to the next HID example and HID Host driver update.

I'll close this ticket and update it when the API will be available. Thanks for reporting.