v1.0.2
usb_device
USB 장치와 통신하기 위한 플러터 플러그인(세션 시작, 데이터 전송, 구성 설정 등).
35좋아요 38030일 다운로드150Pub 점수
Web
Flutter WebUSB 플러그인
아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.
web usb logo
License: MIT pub dev usb_device
WebUSB plugin provide access to USB devices from Flutter Web 💙 by using web usb official API.
| Android | iOS | MacOS | Web | Linux | Windows |
|---|---|---|---|---|---|
| ➖ | ➖ | ➖ | ✔️ | ➖ | ➖ |
flutter pub add usb_device
import 'package:usb_device/usb_device.dart';
import 'package:usb_device/usb_device.dart';
final UsbDevice usbDevice = UsbDevice();
// get paired devices
final pairedDevices = await usbDevice.pairedDevices;
// pair a device
final pairedDevice = await usbDevice.requestDevices([DeviceFilter(vendorId : 0x00, productId: 0x00)]);
// get device's configurations
List<USBConfiguration> availableConfigurations = await usbDevice.getAvailableConfigurations(pairedDevice);
// get device's info
USBDeviceInfo deviceInfo = await usbDevice.getPairedDeviceInfo(pairedDevice);
// start session
await usbDevice.open(pairedDevice);
// close session
await usbDevice.close(pairedDevice);
| Name | Description | Returned value |
|---|---|---|
pairedDevices |
Get paired attached devices | Future<List<dynamic>> |
requestDevice(List<DeviceFilter> filters) |
Pair a device with filter or not | Future<dynamic> |
isSupported() |
Pair a device with filter or not | Future<bool> |
open() |
Start a session | Future |
close() |
Close a session | Future |
claimInterface(dynamic device, int interfaceNumber) |
Claim an interface for exclusive access | Future |
releaseInterface(dynamic device, int interfaceNumber) |
Release a claimed interface | Future |
reset(dynamic device) |
Reset device | Future |
selectConfiguration(dynamic device, int configurationValue) |
Select a specified configuration | Future |
clearHalt(dynamic device, String direction, int endpointNumber) |
Returns a promise that resolves when a halt condition is cleared | Future |
controlTransferIn(dynamic device, SetupParam setup, {int? length}) |
Return result of a command | Future<USBInTransferResult> |
controlTransferOut(dynamic device, SetupParam setup, {dynamic data}) |
Send a command to device | Future<USBOutTransferResult> |
transferIn(dynamic device, int endpointNumber, int length) |
Return data from device | Future<USBInTransferResult> |
transferOut(dynamic device, int endpointNumber, dynamic data) |
Send data to device | Future<USBOutTransferResult> |
isochronousTransferIn(dynamic device, int endpointNumber, List<int> packetLengths) |
Resolves with a USBIsochronousInTransferResult when time sensitive information has been transmitted to (received by) the USB device | Future<USBIsochronousInTransferResult> |
isochronousTransferOut(dynamic device, int endpointNumber, List<int> packetLengths) |
Resolves with a USBIsochronousOutTransferResult when time sensitive information has been transmitted from the USB device | Future<USBIsochronousOutTransferResult> |
setOnConnectCallback(Function(dynamic) onConnect) |
Connect callback | Future |
setOnDisconnectCallback(Function(dynamic) onDisconnect) |
Disconnect callback | Future |
getSelectedConfiguration(dynamic pairedDevice) |
Get the selected configuration | Future<USBConfiguration?> |
getAvailableConfigurations(dynamic pairedDevice) |
Get available device's configurations | Future<List<USBConfiguration>> |
getPairedDeviceInfo(dynamic pairedDevice) |
Get info of paired device | Future<USBDeviceInfo> |
Initiated and sponsored by Apparence.io.
Contributions are welcome. Contribute by creating a PR or create an issue 🎉.