WebUSB 插件

此插件允许通过 WebUSB 从网页访问 USB 设备。

平台支持

Android iOS MacOS Web Linux Windows
✔️

用法

import 'package:usb_device/usb_device.dart';

final UsbDevice usbDevice = UsbDevice();

var pairedDevices = await usbDevice.pairedDevices; // get paired devices
var pairedDevice = await usbDevice.requestDevices([DeviceFilter(vendorId : 0x00, productId: 0x00)]); // par a device 
List<USBConfiguration> availableConfigurations = await usbDevice.getAvailableConfigurations(pairedDevice); // get device's configurations 
USBDeviceInfo deviceInfo = await usbDevice.getPairedDeviceInfo(pairedDevice); // get device's info
await usbDevice.open(pairedDevice); // start session
await usbDevice.close(pairedDevice); // close session

实施

USB

  • [x] getDevices() : 获取配对的连接设备
  • [x] requestDevice(filters): 根据过滤器配对设备或不配对

USBDevice

  • [x] 使用配置获取设备信息
  • [x] open(): _开始会话_
  • [x] close(): _关闭会话_
  • [x] selectConfiguration(configurationValue): _选择指定的配置_
  • [x] claimInterface(interfaceNumber): _声明接口以独占访问_
  • [x] releaseInterface(interfaceNumber): _释放已声明的接口_
  • [x] controlTransferIn(setup, length): _返回命令结果_
  • [x] controlTransferOut(setup, data) : _向设备发送命令_
  • [x] transferIn(): _从设备返回数据_
  • [x] transferOut(): _向设备发送数据_
  • [x] clearHalt()
  • [x] reset(): _重置设备_
  • [x] isochronousTransferIn()
  • [x] isochronousTransferOut()

事件

  • [x] OnConnect
  • [x] OnDisconnect

GitHub

https://github.com/Apparence-io/webUSB_plugin