Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HIDgeneric host-side example? #154

Open
IU5HKU opened this issue Apr 3, 2024 · 4 comments
Open

HIDgeneric host-side example? #154

IU5HKU opened this issue Apr 3, 2024 · 4 comments

Comments

@IU5HKU
Copy link

IU5HKU commented Apr 3, 2024

The library works great for me, all the examples compiles and works as expected with ESP32-S2, but i don't understands how to set S2 when some HIDgeneric client is connected to usb port. I've read a lot and found that the raw communications is done through reports, so you need a reportID...when you are a client...you initialize the device and the library under the hood makes the work for you, so you end in a simple write() to communicate with the host, the callback routine will provide data who comes back from the host, and this is ok. But if S2 act as host? How can i "open" a client to communicate in raw mode by means of reports? Please could you point me to the solution of this particular case? Thank you so much for your time.
Regards
Marco

@chegewara
Copy link
Owner

It is actually very simple.
First byte of raw data is reportID.
Thats all.

@IU5HKU
Copy link
Author

IU5HKU commented Apr 3, 2024

So when i check the bInterfaceClass for the HIDgeneric, i don't need to initialize the just connected client device in some way? As per ACM or MSC examples? I don't need endpoints in this case, but i've not understood how i can retrieve or send data without tell to the device object where to put them, there's no need to a callback routine for data handling host-side? Something like this:

       case 0x03: // HID Generic
                device = new HIDgeneric;
                device->begin();
                device->setCallbacks(new MyHIDCallbacks());
                break;

Sorry, i know, i'm quite a newbie in the usb field...

@chegewara
Copy link
Owner

Making this library was my learning curve, and i am still newbie.

Yes, of course you need to get descriptor etc like in ACM or MSC, but i dont remember now how to do it exactly (i dont work with USB for a year or so).

@IU5HKU
Copy link
Author

IU5HKU commented Apr 6, 2024

Never mind, thank you so much anyway, i'll keep searching around and reading...:-)
For who need to read something about how USB works i suggest this link:

https://www.keil.com/pack/doc/mw/USB/html/_u_s_b__concepts.html

is simple and well explained, it only scratch the surface, but isn't bad at all to get in touch with USB.
Have a nice day!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants