Search code examples
androidaccessorywebusb

Is it possible to access an android accessory through WebUSB?


I have a custom hardware, that works as an android accessory connected to a phone through USB. I managed to communicate with it through a native android app. I'd like to know if it's possible to communicate with it through the WebUSB API.

So far I just tried listing the available devices with requestDevice() using an empty filter but my device doesn't show up in the list. The site is served through https so that's not the issue and other devices that work with otg show up.

I haven't managed to found anything in docs regarding support for android accessories.


Solution

  • WebUSB is a wrapper around the Android USB Host API, which supports communicating with peripherals connected in client mode. The Android USB Accessory API requires the peripheral instead to be in host mode (with the Android device being the client) and provides a very different interface for reading and writing data.

    This interface looks more like what is provided by the Serial API so it may make sense to expose accessories through that API instead. This is an area to research further. I have filed issue 987271 in the Chromium repository to track this exploration.