felHR85 / UsbSerial

Usb serial controller for Android
MIT License
1.78k stars 582 forks source link

Use proper control index on multi-class CDC devices #314

Closed mobilinkd closed 3 years ago

mobilinkd commented 4 years ago

Find the proper control index to use for CDC devices with multiple devices classes present. This fixes the problem which prevented the library from working with STM32 Nucleo boards, among others. Note that this does not change the behavior for devices without a USB_CLASS_COMM interface.

This assumes that if index 0 works today, that is what will be returned by findFirstControl(). And if none are returned, the default value of 0 is returned, which was the hard-coded value used before this change.

This has been tested on two CDC devices, one that has a single CDC interface and was working with this library, and another multi-class device (and STM32 Nucleo32 board) which did not work. After this change, both devices work with this library.

This change is needed to address https://github.com/ge0rg/aprsdroid/issues/264