mtrust_urp_core 9.1.0-dev.20
mtrust_urp_core: ^9.1.0-dev.20 copied to clipboard
Core of the M-Trust URP SDK: connection strategy abstraction, command framing, device commands and firmware transfer for M-Trust readers.
example/README.md
URP core example #
Discover and connect to a reader over any transport.
import 'package:mtrust_urp_core/mtrust_urp_core.dart';
import 'package:mtrust_urp_usb_strategy/mtrust_urp_usb_strategy.dart';
import 'package:mtrust_urp_ble_strategy/mtrust_urp_ble_strategy.dart';
Future<void> main() async {
// Scan USB and Bluetooth at once; connect over whichever finds the reader.
final strategy = CompositeConnectionStrategy([
UrpUsbStrategy(),
UrpBleStrategy(),
]);
await for (final device in strategy.findDevices({UrpDeviceType.urpImz})) {
print('${device.name} over ${device.transportName}');
}
final connected = await strategy.findAndConnectDevice(
readerTypes: {UrpDeviceType.urpImz},
);
if (connected) {
// isWired distinguishes a cabled reader, which is unambiguously the one
// the user plugged in, from a wireless one that could be any nearby unit.
print('connected over ${strategy.activeTransportName}, wired=${strategy.isWired}');
await strategy.disconnectDevice();
}
}