mtrust_urp_core

pub package pub points Documentation

The foundation of the M-Trust URP SDK. Every other package in this repository builds on it, and every reader kit speaks through it.

URP (Universal Reader Protocol) is the wire protocol M-Trust readers use. This package implements it independently of how the device is reached — Bluetooth, USB, WiFi or a simulator are all interchangeable ConnectionStrategy implementations.

What it provides

Type Purpose
ConnectionStrategy The transport abstraction. Discovery, connect/disconnect, framed I/O, status stream
CompositeConnectionStrategy Scans several transports at once and connects over whichever finds the device
CmdWrapper The URP command set: ping, info, power, naming, keys, DFU, WiFi provisioning
FoundDevice A discovered device: address, name, type, transport, serial
ApiService / ConfigApiService / OtaApiService M-Trust backend calls for tokens, config and firmware
urpLogger Shared logging

Installation

flutter pub add mtrust_urp_core

You also need a transport. See the strategy packages listed in the repository README.

Usage

Core is rarely used directly — normally a kit such as mtrust_imz_kit or mtrust_sec_kit drives it. When you do use it directly:

import 'package:mtrust_urp_core/mtrust_urp_core.dart';
import 'package:mtrust_urp_usb_strategy/mtrust_urp_usb_strategy.dart';

final strategy = UrpUsbStrategy();

await for (final device in strategy.findDevices({UrpDeviceType.urpImz})) {
  print('${device.name} over ${device.transportName}');
}

await strategy.findAndConnectDevice(readerTypes: {UrpDeviceType.urpImz});

Combining transports

final strategy = CompositeConnectionStrategy([
  UrpUsbStrategy(),
  UrpBleStrategy(),
]);

The composite reports isWired and activeTransportName for whichever transport is actually carrying the connection, so callers can treat a cabled reader differently from a wireless one. It owns its children — dispose the composite, not the strategies you passed in.

Connection status

ConnectionStatus is idle, searching, connecting or connected. There is no disconnected: an unexpected loss reports idle, the same as a deliberate release.

License

Apache 2.0. See LICENSE.

Libraries

mtrust_urp_core