init
This commit is contained in:
214
lib/idcard.dart
Normal file
214
lib/idcard.dart
Normal file
@@ -0,0 +1,214 @@
|
||||
|
||||
import 'idcard_platform_interface.dart';
|
||||
|
||||
/// 身份证读卡器插件主类
|
||||
/// 基于神思标准化接口规范实现的Flutter插件
|
||||
class Idcard {
|
||||
/// 获取平台版本
|
||||
Future<String?> getPlatformVersion() {
|
||||
return IdcardPlatform.instance.getPlatformVersion();
|
||||
}
|
||||
|
||||
/// 获取USB权限
|
||||
/// [vid] - USB设备的厂商ID,默认为0x261A(神思USB读卡器厂商ID)
|
||||
/// [pid] - USB设备的产品ID,默认为0x0011
|
||||
Future<int> getUsbPermission({int vid = 0x261A, int pid = 0x0011}) {
|
||||
return IdcardPlatform.instance.getUsbPermission(vid, pid);
|
||||
}
|
||||
|
||||
/// 打开设备连接
|
||||
/// [portType] - 端口类型,支持"USB"、"COM"、"SKT"、"BTH"、"AUTO"
|
||||
/// [portPara] - 端口参数,根据端口类型不同而不同
|
||||
/// [extendPara] - 扩展参数
|
||||
/// 返回值:大于0表示成功(设备句柄),其他为失败
|
||||
Future<int> openDevice({String portType = 'USB', String portPara = '', String extendPara = ''}) {
|
||||
return IdcardPlatform.instance.openDevice(
|
||||
portType: portType,
|
||||
portPara: portPara,
|
||||
extendPara: extendPara,
|
||||
);
|
||||
}
|
||||
|
||||
/// 设置当前设备(多设备操作)
|
||||
/// [devHandle] - 设备句柄
|
||||
/// 返回值:0表示成功;非0表示失败
|
||||
Future<int> setCurrentDevice(int devHandle) {
|
||||
return IdcardPlatform.instance.setCurrentDevice(devHandle);
|
||||
}
|
||||
|
||||
/// 获取当前设备(多设备操作)
|
||||
/// 返回值:返回当前设备的句柄
|
||||
Future<int> getCurrentDevice() {
|
||||
return IdcardPlatform.instance.getCurrentDevice();
|
||||
}
|
||||
|
||||
/// 获取接口库信息
|
||||
/// 返回值:包含version和description的Map
|
||||
Future<Map<String, String>> getLibraryInfo() {
|
||||
return IdcardPlatform.instance.getLibraryInfo();
|
||||
}
|
||||
|
||||
/// 获取设备型号
|
||||
/// 返回值:设备型号字符串
|
||||
Future<String> getTerminalModel() {
|
||||
return IdcardPlatform.instance.getTerminalModel();
|
||||
}
|
||||
|
||||
/// 设备轮询心跳
|
||||
/// 用于检测与读卡器是否已建立连接并且通讯正常
|
||||
/// 返回值:0表示成功;非0表示失败
|
||||
Future<int> terminalHeartBeat() {
|
||||
return IdcardPlatform.instance.terminalHeartBeat();
|
||||
}
|
||||
|
||||
/// 获取接收数据
|
||||
/// 获取最后一次通讯收到的数据,一般用于获取读卡器协议层错误信息
|
||||
/// 返回值:最后一次通讯收到的数据
|
||||
Future<List<int>> getLastRecvData() {
|
||||
return IdcardPlatform.instance.getLastRecvData();
|
||||
}
|
||||
|
||||
/// 获取设备固件版本
|
||||
/// 返回值:包含firmVersion和hardwareVersion的Map
|
||||
Future<Map<String, String>> getTerminalFirmVersion() {
|
||||
return IdcardPlatform.instance.getTerminalFirmVersion();
|
||||
}
|
||||
|
||||
/// 获取设备序列号
|
||||
/// 返回值:设备序列号字符串
|
||||
Future<String> getTerminalSn() {
|
||||
return IdcardPlatform.instance.getTerminalSn();
|
||||
}
|
||||
|
||||
/// 关闭设备连接
|
||||
/// 返回值:0表示成功;非0表示失败
|
||||
Future<int> closeDevice() {
|
||||
return IdcardPlatform.instance.closeDevice();
|
||||
}
|
||||
|
||||
/// 寻找身份证卡片
|
||||
/// 返回值:大于0表示成功找到卡片,小于等于0表示错误码
|
||||
Future<int> findCard() {
|
||||
return IdcardPlatform.instance.findCard();
|
||||
}
|
||||
|
||||
/// 选择身份证卡片
|
||||
/// 返回值:大于0表示成功选择卡片,小于等于0表示错误码
|
||||
Future<int> selectCard() {
|
||||
return IdcardPlatform.instance.selectCard();
|
||||
}
|
||||
|
||||
/// 读取身份证(新版接口,支持多种证件类型)
|
||||
/// [cardType] - 读取卡类型:
|
||||
/// 0x00:读取二代证或外国人或港澳台
|
||||
/// 0x01:只读二代证
|
||||
/// 0x02:只读外国人
|
||||
/// 0x03:只读港澳台
|
||||
/// 0x10-0x13:对应上述类型但包含指纹信息
|
||||
/// [infoEncoding] - 返回信息的编码方式:
|
||||
/// 0x01:GB18030编码(GBK)
|
||||
/// 0x02:UTF16-LE编码
|
||||
/// 0x03:UTF-8编码
|
||||
/// [timeOut] - 读卡超时时间(毫秒),0表示不等待,>0表示等待放卡
|
||||
/// 返回值:包含result(错误码)和data(冒号分隔的身份证信息字符串)的Map
|
||||
Future<Map<String, dynamic>> idReadCard({int cardType = 0x00, int infoEncoding = 0x01, int timeOut = 30000}) {
|
||||
return IdcardPlatform.instance.idReadCard(
|
||||
cardType: cardType,
|
||||
infoEncoding: infoEncoding,
|
||||
timeOut: timeOut,
|
||||
);
|
||||
}
|
||||
|
||||
/// 读取身份证原始数据(兼容旧版接口)
|
||||
/// [cardType] - 卡片类型,1表示身份证
|
||||
/// [infoEncoding] - 信息编码,0表示默认编码
|
||||
/// [timeOut] - 超时时间(毫秒),默认30秒
|
||||
/// 返回值:包含result(错误码)和data(原始数据)的Map
|
||||
Future<Map<String, dynamic>> readCard({int cardType = 1, int infoEncoding = 0, int timeOut = 30000}) {
|
||||
return IdcardPlatform.instance.readCard(
|
||||
cardType: cardType,
|
||||
infoEncoding: infoEncoding,
|
||||
timeOut: timeOut,
|
||||
);
|
||||
}
|
||||
|
||||
/// 读取身份证详细信息
|
||||
/// 返回值:IdCardInfo对象,包含姓名、性别、民族等详细信息
|
||||
/// 抛出异常:如果读取失败会抛出Exception
|
||||
Future<IdCardInfo> readCardInfo() {
|
||||
return IdcardPlatform.instance.readCardInfo();
|
||||
}
|
||||
|
||||
/// 读取追加住址
|
||||
/// 返回值:追加住址信息字符串
|
||||
Future<String> readNewAddress() {
|
||||
return IdcardPlatform.instance.readNewAddress();
|
||||
}
|
||||
|
||||
/// 获取SAM模块状态
|
||||
/// 返回值:0表示成功;非0表示失败
|
||||
Future<int> getSamStatus() {
|
||||
return IdcardPlatform.instance.getSamStatus();
|
||||
}
|
||||
|
||||
/// 获取SAM模块编号字符串
|
||||
/// 返回值:SAM模块编号字符串
|
||||
Future<String> getSamIdStr() {
|
||||
return IdcardPlatform.instance.getSamIdStr();
|
||||
}
|
||||
|
||||
/// 完整的身份证读取流程
|
||||
/// 自动执行寻卡、选卡、读取信息的完整流程
|
||||
/// [timeOut] - 超时时间(毫秒),默认30秒
|
||||
/// [retryInterval] - 重试间隔时间(毫秒),默认500毫秒
|
||||
/// 返回值:IdCardInfo对象
|
||||
/// 抛出异常:如果超时或读取失败会抛出Exception
|
||||
Future<IdCardInfo> readCardComplete({int timeOut = 30000, int retryInterval = 500}) async {
|
||||
final startTime = DateTime.now().millisecondsSinceEpoch;
|
||||
|
||||
while (true) {
|
||||
try {
|
||||
// 1. 寻卡
|
||||
int findResult = await findCard();
|
||||
print("寻卡结果:$findResult");
|
||||
|
||||
if (findResult == 0) {
|
||||
// 2. 选卡
|
||||
int selectResult = await selectCard();
|
||||
print("选卡结果:$selectResult");
|
||||
|
||||
if (selectResult == 0) {
|
||||
// 3. 读取信息
|
||||
return await readCardInfo();
|
||||
} else {
|
||||
print('选卡失败,错误码:$selectResult,继续重试...');
|
||||
}
|
||||
} else {
|
||||
print('寻卡失败,错误码:$findResult,继续重试...');
|
||||
}
|
||||
} catch (e) {
|
||||
print('读卡过程中发生异常:$e,继续重试...');
|
||||
}
|
||||
|
||||
// 检查是否超时
|
||||
final currentTime = DateTime.now().millisecondsSinceEpoch;
|
||||
if (currentTime - startTime >= timeOut) {
|
||||
throw Exception('读卡超时,超时时间:$timeOut毫秒');
|
||||
}
|
||||
|
||||
// 等待重试间隔
|
||||
await Future.delayed(Duration(milliseconds: retryInterval));
|
||||
}
|
||||
}
|
||||
|
||||
/// 检查设备是否已连接
|
||||
/// 通过尝试获取平台版本来检查设备连接状态
|
||||
Future<bool> isDeviceConnected() async {
|
||||
try {
|
||||
final version = await getPlatformVersion();
|
||||
return version != null;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
180
lib/idcard_method_channel.dart
Normal file
180
lib/idcard_method_channel.dart
Normal file
@@ -0,0 +1,180 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import 'idcard_platform_interface.dart';
|
||||
|
||||
/// 使用方法通道的IdcardPlatform实现
|
||||
class MethodChannelIdcard extends IdcardPlatform {
|
||||
/// 与原生平台交互的方法通道
|
||||
@visibleForTesting
|
||||
final methodChannel = const MethodChannel('idcard');
|
||||
|
||||
@override
|
||||
Future<String?> getPlatformVersion() async {
|
||||
final version = await methodChannel.invokeMethod<String>('getPlatformVersion');
|
||||
return version;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<int> getUsbPermission(int vid, int pid) async {
|
||||
final result = await methodChannel.invokeMethod<int>('getUsbPermission', {
|
||||
'vid': vid,
|
||||
'pid': pid,
|
||||
});
|
||||
return result ?? -1;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<int> openDevice({String portType = 'USB', String portPara = '', String extendPara = ''}) async {
|
||||
final result = await methodChannel.invokeMethod<int>('openDevice', {
|
||||
'portType': portType,
|
||||
'portPara': portPara,
|
||||
'extendPara': extendPara,
|
||||
});
|
||||
return result ?? -1;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<int> setCurrentDevice(int devHandle) async {
|
||||
final result = await methodChannel.invokeMethod<int>('setCurrentDevice', {
|
||||
'devHandle': devHandle,
|
||||
});
|
||||
return result ?? -1;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<int> getCurrentDevice() async {
|
||||
final result = await methodChannel.invokeMethod<int>('getCurrentDevice');
|
||||
return result ?? -1;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Map<String, String>> getLibraryInfo() async {
|
||||
final result = await methodChannel.invokeMethod('getLibraryInfo');
|
||||
if (result == null) return {'version': '', 'description': ''};
|
||||
// 安全地转换类型
|
||||
final Map<String, dynamic> data = Map<String, dynamic>.from(result as Map);
|
||||
return {
|
||||
'version': data['version']?.toString() ?? '',
|
||||
'description': data['description']?.toString() ?? '',
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String> getTerminalModel() async {
|
||||
final result = await methodChannel.invokeMethod<String>('getTerminalModel');
|
||||
return result ?? '';
|
||||
}
|
||||
|
||||
@override
|
||||
Future<int> terminalHeartBeat() async {
|
||||
final result = await methodChannel.invokeMethod<int>('terminalHeartBeat');
|
||||
return result ?? -1;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<int>> getLastRecvData() async {
|
||||
final result = await methodChannel.invokeMethod<List<dynamic>>('getLastRecvData');
|
||||
return result?.cast<int>() ?? [];
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Map<String, String>> getTerminalFirmVersion() async {
|
||||
final result = await methodChannel.invokeMethod('getTerminalFirmVersion');
|
||||
if (result == null) return {'firmVersion': '', 'hardwareVersion': ''};
|
||||
// 安全地转换类型
|
||||
final Map<String, dynamic> data = Map<String, dynamic>.from(result as Map);
|
||||
return {
|
||||
'firmVersion': data['firmVersion']?.toString() ?? '',
|
||||
'hardwareVersion': data['hardwareVersion']?.toString() ?? '',
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String> getTerminalSn() async {
|
||||
final result = await methodChannel.invokeMethod<String>('getTerminalSn');
|
||||
return result ?? '';
|
||||
}
|
||||
|
||||
@override
|
||||
Future<int> closeDevice() async {
|
||||
final result = await methodChannel.invokeMethod<int>('closeDevice');
|
||||
return result ?? -1;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<int> findCard() async {
|
||||
final result = await methodChannel.invokeMethod<int>('findCard');
|
||||
return result ?? -1;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<int> selectCard() async {
|
||||
final result = await methodChannel.invokeMethod<int>('selectCard');
|
||||
return result ?? -1;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Map<String, dynamic>> idReadCard({int cardType = 0x00, int infoEncoding = 0x01, int timeOut = 30000}) async {
|
||||
final result = await methodChannel.invokeMethod('idReadCard', {
|
||||
'cardType': cardType,
|
||||
'infoEncoding': infoEncoding,
|
||||
'timeOut': timeOut,
|
||||
});
|
||||
if (result == null) {
|
||||
return {'result': -1};
|
||||
}
|
||||
// 安全地转换类型
|
||||
return Map<String, dynamic>.from(result as Map);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Map<String, dynamic>> readCard({int cardType = 1, int infoEncoding = 0, int timeOut = 30000}) async {
|
||||
final result = await methodChannel.invokeMethod('readCard', {
|
||||
'cardType': cardType,
|
||||
'infoEncoding': infoEncoding,
|
||||
'timeOut': timeOut,
|
||||
});
|
||||
if (result == null) {
|
||||
return {'result': -1};
|
||||
}
|
||||
// 安全地转换类型
|
||||
return Map<String, dynamic>.from(result as Map);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<IdCardInfo> readCardInfo() async {
|
||||
// 使用idReadCard方法读取身份证信息
|
||||
final result = await idReadCard();
|
||||
|
||||
if (result['result'] != 0) {
|
||||
throw Exception('Failed to read card info, error code: ${result['result']}');
|
||||
}
|
||||
|
||||
final String? dataStr = result['data'];
|
||||
if (dataStr == null || dataStr.isEmpty) {
|
||||
throw Exception('Card data is empty');
|
||||
}
|
||||
|
||||
// 根据文档,数据是冒号分隔的字符串格式
|
||||
return IdCardInfo.fromColonString(dataStr);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String> readNewAddress() async {
|
||||
final result = await methodChannel.invokeMethod<String>('readNewAddress');
|
||||
return result ?? '';
|
||||
}
|
||||
|
||||
@override
|
||||
Future<int> getSamStatus() async {
|
||||
final result = await methodChannel.invokeMethod<int>('getSamStatus');
|
||||
return result ?? -1;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String> getSamIdStr() async {
|
||||
final result = await methodChannel.invokeMethod<String>('getSamIdStr');
|
||||
return result ?? '';
|
||||
}
|
||||
}
|
||||
276
lib/idcard_platform_interface.dart
Normal file
276
lib/idcard_platform_interface.dart
Normal file
@@ -0,0 +1,276 @@
|
||||
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
|
||||
import 'idcard_method_channel.dart';
|
||||
|
||||
/// 身份证信息数据模型
|
||||
class IdCardInfo {
|
||||
final String cardType; // 证件类型 (A-二代证, I/Y-外国人, J-港澳台)
|
||||
final String name; // 中文姓名
|
||||
final String nameEn; // 英文姓名
|
||||
final String gender; // 性别
|
||||
final String genderId; // 性别代码
|
||||
final String nation; // 民族/国籍
|
||||
final String nationId; // 民族代码/国籍代码/通行证号码
|
||||
final String birthDate; // 出生日期
|
||||
final String address; // 住址
|
||||
final String idNumber; // 身份证号码/永久居留证号码
|
||||
final String signOrgan; // 签发机关
|
||||
final String beginTerm; // 有效期起始日期
|
||||
final String validTerm; // 有效期截止日期
|
||||
final String version; // 证件版本号
|
||||
final String? photoBase64; // 头像JPG照片base64编码
|
||||
final String? fingerprintBase64; // 指纹特征值base64编码
|
||||
final List<int>? photo; // 照片数据(原始格式)
|
||||
|
||||
IdCardInfo({
|
||||
required this.cardType,
|
||||
required this.name,
|
||||
this.nameEn = '',
|
||||
required this.gender,
|
||||
this.genderId = '',
|
||||
required this.nation,
|
||||
this.nationId = '',
|
||||
required this.birthDate,
|
||||
required this.address,
|
||||
required this.idNumber,
|
||||
required this.signOrgan,
|
||||
this.beginTerm = '',
|
||||
required this.validTerm,
|
||||
this.version = '',
|
||||
this.photoBase64,
|
||||
this.fingerprintBase64,
|
||||
this.photo,
|
||||
});
|
||||
|
||||
/// 从Map创建IdCardInfo对象
|
||||
factory IdCardInfo.fromMap(Map<String, dynamic> map) {
|
||||
return IdCardInfo(
|
||||
cardType: map['cardType'] ?? '',
|
||||
name: map['name'] ?? '',
|
||||
nameEn: map['nameEn'] ?? '',
|
||||
gender: map['gender'] ?? '',
|
||||
genderId: map['genderId'] ?? '',
|
||||
nation: map['nation'] ?? '',
|
||||
nationId: map['nationId'] ?? '',
|
||||
birthDate: map['birthDate'] ?? '',
|
||||
address: map['address'] ?? '',
|
||||
idNumber: map['idNumber'] ?? '',
|
||||
signOrgan: map['signOrgan'] ?? '',
|
||||
beginTerm: map['beginTerm'] ?? '',
|
||||
validTerm: map['validTerm'] ?? '',
|
||||
version: map['version'] ?? '',
|
||||
photoBase64: map['photoBase64'],
|
||||
fingerprintBase64: map['fingerprintBase64'],
|
||||
photo: map['photo'] != null ? List<int>.from(map['photo']) : null,
|
||||
);
|
||||
}
|
||||
|
||||
/// 从冒号分隔的字符串创建IdCardInfo对象
|
||||
/// 根据接口文档格式:证件类型:中文姓名:英文姓名:性别:性别代码:民族:民族代码:出生日期:住址:身份证号码:签发机关:发卡日期:卡有效期:证件版本号:头像JPG照片base64编码:指纹特征值base64编码
|
||||
factory IdCardInfo.fromColonString(String colonString) {
|
||||
final parts = colonString.split(':');
|
||||
// 确保至少有16个部分
|
||||
while (parts.length < 16) {
|
||||
parts.add('');
|
||||
}
|
||||
|
||||
return IdCardInfo(
|
||||
cardType: parts[0],
|
||||
name: parts[1],
|
||||
nameEn: parts[2],
|
||||
gender: parts[3],
|
||||
genderId: parts[4],
|
||||
nation: parts[5],
|
||||
nationId: parts[6],
|
||||
birthDate: parts[7],
|
||||
address: parts[8],
|
||||
idNumber: parts[9],
|
||||
signOrgan: parts[10],
|
||||
beginTerm: parts[11],
|
||||
validTerm: parts[12],
|
||||
version: parts[13],
|
||||
photoBase64: parts[14].isNotEmpty ? parts[14] : null,
|
||||
fingerprintBase64: parts[15].isNotEmpty ? parts[15] : null,
|
||||
);
|
||||
}
|
||||
|
||||
/// 转换为Map
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'cardType': cardType,
|
||||
'name': name,
|
||||
'nameEn': nameEn,
|
||||
'gender': gender,
|
||||
'genderId': genderId,
|
||||
'nation': nation,
|
||||
'nationId': nationId,
|
||||
'birthDate': birthDate,
|
||||
'address': address,
|
||||
'idNumber': idNumber,
|
||||
'signOrgan': signOrgan,
|
||||
'beginTerm': beginTerm,
|
||||
'validTerm': validTerm,
|
||||
'version': version,
|
||||
'photoBase64': photoBase64,
|
||||
'fingerprintBase64': fingerprintBase64,
|
||||
'photo': photo,
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'IdCardInfo{cardType: $cardType, name: $name, nameEn: $nameEn, gender: $gender, genderId: $genderId, nation: $nation, nationId: $nationId, birthDate: $birthDate, address: $address, idNumber: $idNumber, signOrgan: $signOrgan, beginTerm: $beginTerm, validTerm: $validTerm, version: $version}';
|
||||
}
|
||||
}
|
||||
|
||||
/// 身份证读卡器平台接口
|
||||
abstract class IdcardPlatform extends PlatformInterface {
|
||||
/// 构造函数
|
||||
IdcardPlatform() : super(token: _token);
|
||||
|
||||
static final Object _token = Object();
|
||||
|
||||
static IdcardPlatform _instance = MethodChannelIdcard();
|
||||
|
||||
/// 默认实例
|
||||
static IdcardPlatform get instance => _instance;
|
||||
|
||||
/// 设置平台特定的实现
|
||||
static set instance(IdcardPlatform instance) {
|
||||
PlatformInterface.verifyToken(instance, _token);
|
||||
_instance = instance;
|
||||
}
|
||||
|
||||
/// 获取平台版本
|
||||
Future<String?> getPlatformVersion() {
|
||||
throw UnimplementedError('platformVersion() has not been implemented.');
|
||||
}
|
||||
|
||||
/// 获取USB权限
|
||||
/// [vid] - USB设备的厂商ID
|
||||
/// [pid] - USB设备的产品ID
|
||||
Future<int> getUsbPermission(int vid, int pid) {
|
||||
throw UnimplementedError('getUsbPermission() has not been implemented.');
|
||||
}
|
||||
|
||||
/// 打开设备
|
||||
/// [portType] - 端口类型,如"USB", "COM", "SKT", "BTH", "AUTO"
|
||||
/// [portPara] - 端口参数
|
||||
/// [extendPara] - 扩展参数
|
||||
/// 返回值:大于0表示成功(设备句柄),其他为失败
|
||||
Future<int> openDevice({String portType = 'USB', String portPara = '', String extendPara = ''}) {
|
||||
throw UnimplementedError('openDevice() has not been implemented.');
|
||||
}
|
||||
|
||||
/// 设置当前设备(多设备操作)
|
||||
/// [devHandle] - 设备句柄
|
||||
/// 返回值:0表示成功;非0表示失败
|
||||
Future<int> setCurrentDevice(int devHandle) {
|
||||
throw UnimplementedError('setCurrentDevice() has not been implemented.');
|
||||
}
|
||||
|
||||
/// 获取当前设备(多设备操作)
|
||||
/// 返回值:返回当前设备的句柄
|
||||
Future<int> getCurrentDevice() {
|
||||
throw UnimplementedError('getCurrentDevice() has not been implemented.');
|
||||
}
|
||||
|
||||
/// 获取接口库信息
|
||||
/// 返回值:包含version和description的Map
|
||||
Future<Map<String, String>> getLibraryInfo() {
|
||||
throw UnimplementedError('getLibraryInfo() has not been implemented.');
|
||||
}
|
||||
|
||||
/// 获取设备型号
|
||||
/// 返回值:设备型号字符串
|
||||
Future<String> getTerminalModel() {
|
||||
throw UnimplementedError('getTerminalModel() has not been implemented.');
|
||||
}
|
||||
|
||||
/// 设备轮询心跳
|
||||
/// 返回值:0表示成功;非0表示失败
|
||||
Future<int> terminalHeartBeat() {
|
||||
throw UnimplementedError('terminalHeartBeat() has not been implemented.');
|
||||
}
|
||||
|
||||
/// 获取接收数据
|
||||
/// 返回值:最后一次通讯收到的数据
|
||||
Future<List<int>> getLastRecvData() {
|
||||
throw UnimplementedError('getLastRecvData() has not been implemented.');
|
||||
}
|
||||
|
||||
/// 获取设备固件版本
|
||||
/// 返回值:包含firmVersion和hardwareVersion的Map
|
||||
Future<Map<String, String>> getTerminalFirmVersion() {
|
||||
throw UnimplementedError('getTerminalFirmVersion() has not been implemented.');
|
||||
}
|
||||
|
||||
/// 获取设备序列号
|
||||
/// 返回值:设备序列号字符串
|
||||
Future<String> getTerminalSn() {
|
||||
throw UnimplementedError('getTerminalSn() has not been implemented.');
|
||||
}
|
||||
|
||||
/// 关闭设备
|
||||
/// 返回值:0表示成功;非0表示失败
|
||||
Future<int> closeDevice() {
|
||||
throw UnimplementedError('closeDevice() has not been implemented.');
|
||||
}
|
||||
|
||||
/// 寻卡
|
||||
Future<int> findCard() {
|
||||
throw UnimplementedError('findCard() has not been implemented.');
|
||||
}
|
||||
|
||||
/// 选卡
|
||||
Future<int> selectCard() {
|
||||
throw UnimplementedError('selectCard() has not been implemented.');
|
||||
}
|
||||
|
||||
/// 读取身份证(新版接口,支持多种证件类型)
|
||||
/// [cardType] - 读取卡类型:
|
||||
/// 0x00:读取二代证或外国人或港澳台
|
||||
/// 0x01:只读二代证
|
||||
/// 0x02:只读外国人
|
||||
/// 0x03:只读港澳台
|
||||
/// 0x10-0x13:对应上述类型但包含指纹信息
|
||||
/// [infoEncoding] - 返回信息的编码方式:
|
||||
/// 0x01:GB18030编码(GBK)
|
||||
/// 0x02:UTF16-LE编码
|
||||
/// 0x03:UTF-8编码
|
||||
/// [timeOut] - 读卡超时时间(毫秒),0表示不等待,>0表示等待放卡
|
||||
/// 返回值:0表示成功;非0表示失败,成功时返回冒号分隔的身份证信息字符串
|
||||
Future<Map<String, dynamic>> idReadCard({int cardType = 0x00, int infoEncoding = 0x01, int timeOut = 30000}) {
|
||||
throw UnimplementedError('idReadCard() has not been implemented.');
|
||||
}
|
||||
|
||||
/// 读取身份证(兼容旧版接口)
|
||||
/// [cardType] - 卡片类型
|
||||
/// [infoEncoding] - 信息编码
|
||||
/// [timeOut] - 超时时间(毫秒)
|
||||
Future<Map<String, dynamic>> readCard({int cardType = 1, int infoEncoding = 0, int timeOut = 30000}) {
|
||||
throw UnimplementedError('readCard() has not been implemented.');
|
||||
}
|
||||
|
||||
/// 读取身份证详细信息
|
||||
Future<IdCardInfo> readCardInfo() {
|
||||
throw UnimplementedError('readCardInfo() has not been implemented.');
|
||||
}
|
||||
|
||||
/// 读取追加住址
|
||||
/// 返回值:追加住址信息字符串
|
||||
Future<String> readNewAddress() {
|
||||
throw UnimplementedError('readNewAddress() has not been implemented.');
|
||||
}
|
||||
|
||||
/// 获取SAM模块状态
|
||||
/// 返回值:0表示成功;非0表示失败
|
||||
Future<int> getSamStatus() {
|
||||
throw UnimplementedError('getSamStatus() has not been implemented.');
|
||||
}
|
||||
|
||||
/// 获取SAM模块编号字符串
|
||||
/// 返回值:SAM模块编号字符串
|
||||
Future<String> getSamIdStr() {
|
||||
throw UnimplementedError('getSamIdStr() has not been implemented.');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user