패키지, 저장소 및 앱 카테고리 검색

패키지 상세v1.0.2

usb_device

USB 장치와 통신하기 위한 플러터 플러그인(세션 시작, 데이터 전송, 구성 설정 등).

Web
30일 다운로드
674
좋아요
35
Pub 점수
150

패키지 설치

flutter pub add usb_device

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

usb_device 패키지는 웹에서 USB 장치와의 통신을 가능하게 하는 플러터 플러그인입니다. WebUSB를 지원하는 웹 브라우저를 통해 사용자가 세션을 시작하고 데이터를 전송 및 수신하며 USB 장치를 직접 구성할 수 있습니다. 웹 애플리케이션에서 장치 상호작용을 위해 설계되었으며, 브라우저 수준의 USB API를 활용하여 연결된 주변기기로의 저수준 접근을 제공합니다. 센서, 컨트롤러 또는 맞춤형 장치와 인터페이스하는 웹 기반 도구를 개발하는 개발자에게 특히 유용합니다. 이 플러그인은 웹 플랫폼만 지원하며, 장치에 대한 액세스를 위해서는 사용자의 허가가 필요합니다.

사용 사례

  • 웹 앱에서 USB를 통해 하드웨어에 연결하기
  • USB 연결 장치에 명령 전송
  • 외부 USB 주변 장치에서 데이터 읽기
  • 웹 기반 장치 제어 인터페이스 개발
  • 임베디드 장치와의 실시간 통신 활성화

주요 기능

  • 웹 전용 USB 통신
  • 세션 관리 지원
  • 데이터 전송 및 수신
  • 장치 구성 옵션
  • 브라우저 기반 웹유스비 통합

적합한 대상

  • 하드웨어를 사용하는 웹 개발자
  • 사물인터넷 웹 애플리케이션
  • 사용자 지정 장치 제어 대시보드
  • USB 기능을 갖춘 웹 도구의 프로토타이핑
  • USB 장치를 포함하는 교육 프로젝트

고려 사항

  • 웹 플랫폼에만 제한됨
  • WebUSB 브라우저 지원 필요
  • 장치 접근을 위해 사용자 권한이 필요합니다
  • 모바일 또는 데스크톱 네이티브 앱에 대한 지원 없음
  • WebUSB과의 장치 호환성에 따라 다름

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

web usb logo



License: MIT pub dev usb_device




🚀  Overview

WebUSB plugin provide access to USB devices from Flutter Web 💙 by using web usb official API.

  • 📱 Get device info with configuration.
  • 🔌 Pair a device with filter.
  • 📤 Send data to USB device.
  • 📥 Receive data from USB device.
  • 🎛️ Change USB device configuration.

💻  Platform Support

Android iOS MacOS Web Linux Windows
➖ ➖ ➖ ✔️ ➖ ➖

📖  Installation

Install the package
flutter pub add usb_device
Import the package
import 'package:usb_device/usb_device.dart';

🚀  Get started

  • Import & instanciate the plugin.
import 'package:usb_device/usb_device.dart';

final UsbDevice usbDevice = UsbDevice();
  • Common used methods.

// 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);

📚  Methods

USB

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>

📣  Sponsor

logo apparence io

Initiated and sponsored by Apparence.io.

👥  Contribution

Contributions are welcome. Contribute by creating a PR or create an issue 🎉.

카테고리

의존성

의존성 목록 2 개

  • usb_device_platform_interface^1.0.0
  • usb_device_web^1.0.0

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.