webusb / arduino

WebUSB demos running on Arduino (and compatible) hardware.
566 stars 152 forks source link

Dynamically choose interface number #54

Closed jpliew closed 5 years ago

jpliew commented 5 years ago

The current serial.js assumed all WebUSB device has an interface number of 2, in endpoint of 5 and out endpoint of 4, hard coded.

This is correct if the device is just acting as WebUSB alone. When a device has a few other interfaces, the WebUSB interface might not be on interface number 2.

This pull request will loop through the this.device_ and detect a class of 0xFF (I can't find any other differentiation for other device interface other than this to guess if the interface is WebUSB), loop through the endpoints and get the correct interface number, ID for in and out endpoints .

Hope this helps.

Cheers JP

jpliew commented 5 years ago

Tested with ATmega32U4 compatible board with

jpliew commented 5 years ago

Done.