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

Question on connect/disconnect events #11

Closed
mame82 opened this issue Oct 30, 2019 · 7 comments
Closed

Question on connect/disconnect events #11

mame82 opened this issue Oct 30, 2019 · 7 comments

Comments

@mame82
Copy link

mame82 commented Oct 30, 2019

Hi,

as you have quit a bit of knowledge on WebHID, you could maybe answer my question.

O'm currently working on a Single Page App utilizing WebHID to interact with a custom device. Everything works well, so far (see BLExy videos on youtube for reference).

What I don't get to work are the disconnect events on navigator.hid, which is an issue, as I'm not able to recognize removal of the USB device and sending reports simply fails (HIDDevice instance is left behind with open property set to true).

I'm using latest Chrome 78 in Linux x64.

I hope you could drop a hint on how to detect device disconnection.

Cheers Marcus

@robatwilliams
Copy link
Owner

I've not tried those, but from the following comment I think they might not be implemented yet - https://bugs.chromium.org/p/chromium/issues/detail?id=890096#c38

@reillyeon
Copy link

Connect and disconnect events are not yet implemented.

CC @nondebug

@tijmenvangulik
Copy link
Contributor

tijmenvangulik commented Oct 31, 2019 via email

@robatwilliams
Copy link
Owner

Discussion is resolved by #11 (comment)

@mame82
Copy link
Author

mame82 commented Nov 3, 2019

Thx for the answers.

In my case, USB HID input reports are sent infrequently by the device, either to indicate state changes or in response to output reports from the host (representing requests in upper protocol layers).
This means sending kind of "keep-alive" HID reports, only to detect disconnects isn't ideal. Additionally it would introduce unnecessary overhead to the microcontroller of the USB device if it has to produce keep-alive reports or to filter out dummy reports, in case they're sent from the host.

So I think it would be the best to wait for implementation of connect/disconnect events.

@todbot
Copy link
Contributor

todbot commented Nov 3, 2019

Hi @mame82, I think you can send to the device from the host, even if the device isn’t configured to receive, and the HID driver will either send the packet or error out if device is disconnected. Basically do the keep-alive, but have it host-originated.

@mame82
Copy link
Author

mame82 commented Nov 3, 2019

@todbot

Yes, but afaik the respective (input) reports would end up as control transfers at ep0 and force an idle response from the device - or am I wrong in that?

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

5 participants