Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from istornz/rework/readme
♻️ Rework readme + Upgrade deps
- Loading branch information
Showing
16 changed files
with
270 additions
and
532 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,116 @@ | ||
<p align="center"> | ||
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/license-MIT-purple.svg" alt="License: MIT"></a> | ||
<a href="https://pub.dev/packages/bart"><img src="https://img.shields.io/pub/v/usb_device" alt="pub dev webusb"></a> | ||
<img src="https://github.com/Apparence-io/webUSB_plugin/raw/master/assets/img/logo.jpg" alt="web usb logo" /> | ||
</p> | ||
<br><br> | ||
|
||
# **WebUSB plugin** | ||
<a href="https://en.apparence.io"><img src="https://github.com/Apparence-io/bart/raw/master/.github/img/logo.png" alt="Apparence.io logo"></a> | ||
<p><small>Developed with 💙 by Apparence.io</small></p> | ||
<p align="center"> | ||
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/license-MIT-purple.svg" alt="License: MIT"></a> | ||
<a href="https://pub.dev/packages/usb_device"><img src="https://img.shields.io/pub/v/usb_device" alt="pub dev usb_device"></a> | ||
</p> | ||
<br> | ||
<hr> | ||
<br> | ||
|
||
## 🚀 Overview | ||
|
||
**WebUSB** plugin provide access to USB devices from Flutter Web 💙 by using [**web usb official API**](https://wicg.github.io/webusb/). | ||
|
||
This plugin provide access to USB devices from web pages with WebUSB. | ||
- 📱 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 | ||
## 💻 Platform Support | ||
|
||
| Android | iOS | MacOS | Web | Linux | Windows | | ||
| :-----: | :-: | :---: | :-: | :---: | :----: | | ||
| ➖ | ➖ | ➖ | ✔️ | ➖ | ➖ | | ||
| ➖ | ➖ | ➖ | ✔️ | ➖ | ➖ | | ||
|
||
## 📖 Installation | ||
|
||
## Usage | ||
### Install the package | ||
|
||
```sh | ||
flutter pub add usb_device | ||
``` | ||
|
||
### Import the package | ||
|
||
```dart | ||
import 'package:usb_device/usb_device.dart'; | ||
``` | ||
|
||
## 🚀 Get started | ||
|
||
- Import & instanciate the plugin. | ||
|
||
```dart | ||
import 'package:usb_device/usb_device.dart'; | ||
final UsbDevice usbDevice = UsbDevice(); | ||
``` | ||
|
||
- Common used methods. | ||
|
||
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 | ||
```dart | ||
// 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); | ||
``` | ||
|
||
## Implementation | ||
|
||
### USB | ||
|
||
- [x] getDevices() : Get paired attached devices | ||
- [x] requestDevice(filters): pair a device with filter or not | ||
|
||
### USBDevice | ||
|
||
- [x] Get device info with configuration | ||
- [x] open(): *Start session* | ||
- [x] close(): *Close session* | ||
- [x] selectConfiguration(configurationValue): *Select a specified configuration* | ||
- [x] claimInterface(interfaceNumber): *Claim an interface for exclusive access* | ||
- [x] releaseInterface(interfaceNumber): *Release a claimed interface* | ||
- [x] controlTransferIn(setup, length): *Return result of a command* | ||
- [x] controlTransferOut(setup, data) : *Send a command to device* | ||
- [x] transferIn(): *Return data from device* | ||
- [x] transferOut(): *Send data to device* | ||
- [x] clearHalt() | ||
- [x] reset(): *Reset device* | ||
- [x] isochronousTransferIn() | ||
- [x] isochronousTransferOut() | ||
|
||
### Events | ||
- [x] OnConnect | ||
- [x] OnDisconnect | ||
## 📚 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 | ||
|
||
<img src="https://github.com/Apparence-io/bart/raw/master/.github/img/apparence_logo.png" alt="logo apparence io" /> | ||
<br /> | ||
<br /> | ||
|
||
[Initiated and sponsored by Apparence.io.](https://apparence.io) | ||
|
||
## 👥 Contribution | ||
|
||
Contributions are welcome. | ||
Contribute by creating a PR or create an issue 🎉. |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ | |
// Generated file. Do not edit. | ||
// | ||
|
||
// clang-format off | ||
|
||
#include "generated_plugin_registrant.h" | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.