mtrust_urp_ble_strategy 9.1.0-dev.20
mtrust_urp_ble_strategy: ^9.1.0-dev.20 copied to clipboard
Bluetooth Low Energy connection strategy for M-Trust URP readers, covering scanning, pairing and the GATT transport.
example/README.md
BLE strategy example #
Connect to a reader over Bluetooth Low Energy.
import 'package:mtrust_urp_core/mtrust_urp_core.dart';
import 'package:mtrust_urp_ble_strategy/mtrust_urp_ble_strategy.dart';
Future<void> main() async {
final strategy = UrpBleStrategy();
// Bluetooth may be unsupported, off, or missing runtime permissions.
final availability = await strategy.availability;
if (availability != StrategyAvailability.ready) {
print('bluetooth not ready: $availability');
return;
}
await strategy.findAndConnectDevice(readerTypes: {UrpDeviceType.urpImz});
await strategy.disconnectDevice();
}
Android needs BLUETOOTH_SCAN and BLUETOOTH_CONNECT granted at runtime, and
iOS needs NSBluetoothAlwaysUsageDescription. See the package README.