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
UsbDevice manufacturer, product & serial number description #30
Conversation
Any common USB device to test the usecase? |
Not quite sure what you mean. In my case I need to allow user to select POS printer attached to the host. With this PR I can offer human friendly devices list and instead of vendorId/productId display something like "Logitech Mouse", "Logitech USB receiver", "POS PRINTER". User selects the item and I can save vendorId/productId to be used in a future.
Notice how it literally says: POS PRINTER |
Keep in mind on Linux user needs write permission for device to get the description.
save it and reload udev rules with
and make sure to re-attach device. If you want to enable it for all devices just ommit ATTRS{idVendor}=="0525", something like this
Or if this is too much you can always run the app as root (not recommended). |
android/src/main/kotlin/com/example/quick_usb/QuickUsbPlugin.kt
Outdated
Show resolved
Hide resolved
android/src/main/kotlin/com/example/quick_usb/QuickUsbPlugin.kt
Outdated
Show resolved
Hide resolved
I re-test it on Android/Windows/macOS/Linux and it works with my Logitech mouse Thanks for your contribution :) |
There was permission bug when permission was asked, user would allow it and getDescription would still return null values. |
Currently there is no way to present human friendly list of devices for user to select (IE. select pos printer).
I added 2 new functions to get human friendly info about UsbDevice.
getDeviceDescription
returns new object ofUsbDeviceDescription
type with manufacturer, product & serial number info.getDevicesWithDescription
returns list ofUsbDeviceDescription
type with manufacturer, product & serial number info.All devices/handles are opened/closed automatically.
Default device handle is neither populated or used since this opens and closes multiple devices.
Existing object model and api is left as is.
See #21