smart_usb_android

Creator: coderz1093

Last updated:

0 purchases

TODO
Add to Cart

Description:

smart usb android

smart_usb_android #
Android USB plugin for Flutter
Usage #

List devices
List devices with additional description
Get device description
Connect device
Check permission
Request permission
Open/Close device
Get/Set configuration
Claim/Release interface
Printer
Bulk transfer in/out
Set auto detach kernel driver

List devices #
await SmartUsbAndroid.init();
// ...
var deviceList = await SmartUsbAndroid.getDeviceList();
// ...
await SmartUsbAndroid.exit();
copied to clipboard
List devices with additional description #
Returns devices list with manufacturer, product and serial number description.
Any of these attributes can be null.
var descriptions = await SmartUsbAndroid.getDevicesWithDescription();
var deviceList = descriptions.map((e) => e.device).toList();
print('descriptions $descriptions');
copied to clipboard
(Android Only) Android requires permission for each device in order to get the serial number. The user will be asked
for permission for each device if needed. If you do not require the serial number, you can avoid requesting permission using:
var descriptions = await SmartUsbAndroid.getDevicesWithDescription(requestPermission: false);
copied to clipboard
Get device description #
Returns manufacturer, product and serial number description for specified device.
Any of these attributes can be null.
var description = await SmartUsbAndroid.getDeviceDescription(device);
print('description ${description.toMap()}');
copied to clipboard
(Android Only) Android requires permission for each device in order to get the serial number. The user will be asked
for permission for each device if needed. If you do not require the serial number, you can avoid requesting permission using:
var description = await SmartUsbAndroid.getDeviceDescription(requestPermission: false);
copied to clipboard
Connect device #
var connectDevice = await SmartUsbAndroid.connectDevice(device);
print('connectDevice $connectDevice');
// ...
copied to clipboard
Check permission #
Android Only
var hasPermission = await SmartUsbAndroid.hasPermission(device);
print('hasPermission $hasPermission');
copied to clipboard
Request permission #
Android Only
Request permission for a device. The permission dialog is not shown
if the app already has permission to access the device.
var hasPermission = await SmartUsbAndroid.requestPermission(device);
print('hasPermission $hasPermission');
copied to clipboard
Open/Close device #
var openDevice = await SmartUsbAndroid.openDevice(device);
print('openDevice $openDevice');
// ...
await SmartUsbAndroid.closeDevice();
copied to clipboard
Get/Set configuration #
var configuration = await SmartUsbAndroid.getConfiguration(index);
print('getConfiguration $configuration');
// ...
var setConfiguration = await SmartUsbAndroid.setConfiguration(configuration);
print('setConfiguration $getConfiguration');
copied to clipboard
Claim/Release interface #
var claimInterface = await SmartUsbAndroid.claimInterface(interface);
print('claimInterface $claimInterface');
// ...
var releaseInterface = await SmartUsbAndroid.releaseInterface(interface);
print('releaseInterface $releaseInterface');
copied to clipboard
Printer #
var send = await SmartUsbAndroid.send(bytes);
print('send $send');
copied to clipboard
Bulk transfer in/out #
var bulkTransferIn = await SmartUsbAndroid.bulkTransferIn(endpoint, 1024, timeout: 2000);
print('bulkTransferIn ${hex.encode(bulkTransferIn)}');
// ...
var bulkTransferOut = await SmartUsbAndroid.bulkTransferOut(endpoint, data, timeout: 2000);
print('bulkTransferOut $bulkTransferOut');
copied to clipboard
Set auto detach kernel driver #
Enable/disable libusb's automatic kernel driver detachment on linux. When this is enabled libusb will automatically detach the kernel driver on an interface when claiming the interface, and attach it when releasing the interface.
Automatic kernel driver detachment is disabled on newly opened device handles by default.
This is supported only on linux, on other platforms this function does nothing.
await SmartUsbAndroid.setAutoDetachKernelDriver(true);
copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.