是否可以通过 WebUSB 访问 android 配件?

Is it possible to access an android accessory through WebUSB?

我有一个自定义硬件,它作为 android 配件通过 USB 连接到 phone。我设法通过本机 android 应用程序与它通信。我想知道是否可以通过 WebUSB 与它通信 API.

到目前为止,我只是尝试使用空过滤器通过 requestDevice() 列出可用设备,但我的设备没有显示在列表中。该网站通过 https 提供服务,所以这不是问题,其他支持 otg 的设备也会出现。

我没有在文档中找到任何关于支持 android 配件的信息。

WebUSB is a wrapper around the Android USB Host API, which supports communicating with peripherals connected in client mode. The Android USB Accessory API 要求外围设备处于主机模式(Android 设备是客户端)并提供一个非常不同的接口来读取和写入数据。

此界面看起来更像是 Chromium 存储库中 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 提供的用于跟踪此探索的界面。