虹膜模块暂无协议,删去无用协议调用

This commit is contained in:
Daisy 2024-04-09 18:29:54 +08:00
parent 68f5eaddb3
commit d76f52a081
2 changed files with 0 additions and 256 deletions

View File

@ -20,261 +20,6 @@ import '../../../../../tools/storage.dart';
class AddIrisLogic extends BaseGetXController {
final AddFaceState state = AddFaceState();
//
late StreamSubscription<Reply> _replySubscription;
void _initReplySubscription() {
_replySubscription =
EventBusManager().eventBus!.on<Reply>().listen((reply) async {
//
if (reply is SenderAddFaceReply) {
_replyAddFaceBegin(reply);
}
//
if (reply is SenderAddFaceProcessReply) {
_replyAddFaceProcess(reply);
}
//
if (reply is SenderAddFaceConfirmationReply) {
_replyAddFaceConfirmation(reply);
}
});
}
Future<void> _replyAddFaceBegin(Reply reply) async {
int status = reply.data[2];
print("status:$status");
switch (status) {
case 0x00:
//
// print("${reply.commandType!.typeValue} 人脸开始数据解析成功");
state.ifConnectScuess.value = true;
//
state.maxRegCount.value = reply.data[10];
print("人脸开始state.maxRegCount.value:${state.maxRegCount.value}");
// state.fingerprintNumber.value = reply.data.last.toString();
break;
case 0x06:
//
print("${reply.commandType!.typeValue} 需要鉴权");
var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
var publicKey = await Storage.getStringList(saveBluePublicKey);
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
var token = reply.data.sublist(5, 9);
var saveStrList = changeIntListToStringList(token);
print("_replyAddFaceReplyToken:$token");
Storage.setStringList(saveBlueToken, saveStrList);
IoSenderManage.senderAddFaceCommand(
keyID: "1",
userID: await Storage.getUid(),
faceNo: 1,
useCountLimit: 0xff,
// startTime:0x11223344,
// endTime:0x11223344,
startTime: state.startDate.value ~/ 1000,
endTime: state.endDate.value ~/ 1000,
needAuthor: 1,
publicKey: publicKeyDataList,
privateKey: getPrivateKeyList,
token: token,
);
break;
case 0x07:
//
print("${reply.commandType!.typeValue} 用户无权限");
break;
case 0x09:
//
print("${reply.commandType!.typeValue} 权限校验错误");
break;
default:
//
print("${reply.commandType!.typeValue} 失败");
break;
}
}
Future<void> _replyAddFaceProcess(Reply reply) async {
int status = reply.data[2];
print("******33 status:$status");
switch (status) {
case 0x00:
//
print("${reply.commandType!.typeValue} 注册人脸过程数据解析成功");
if (reply.data[5] == 255) {
//
print("${reply.commandType!.typeValue} 注册人脸过程失败");
showToast("添加失败");
Get.close(2);
} else {
// state.addFaceProcessNumber.value++;
//
state.regIndex.value = reply.data[6];
print("注册人脸过程state.regIndex.value:${state.regIndex.value}");
}
break;
case 0x06:
//
break;
case 0x07:
//
print("${reply.commandType!.typeValue} 用户无权限");
break;
case 0x09:
//
print("${reply.commandType!.typeValue} 权限校验错误");
break;
default:
//
print("${reply.commandType!.typeValue} 注册人脸过程default失败");
break;
}
}
Future<void> _replyAddFaceConfirmation(Reply reply) async {
int status = reply.data[2];
print("status:$status");
switch (status) {
case 0x00:
//
print("${reply.commandType!.typeValue} 人脸确认数据解析成功");
// print("添加人脸确认成功,调用添加指纹接口");
if (state.faceNumber.value == (reply.data[6]).toString()) {
return;
} else {
state.faceNumber.value = (reply.data[6]).toString();
}
addFaceData();
break;
case 0x06:
//
break;
case 0x07:
//
print("${reply.commandType!.typeValue} 用户无权限");
break;
case 0x09:
//
print("${reply.commandType!.typeValue} 权限校验错误");
break;
default:
//
print("${reply.commandType!.typeValue} 人脸确认default失败");
break;
}
}
//
Future<void> senderAddFace() async {
showBlueConnetctToastTimer(action: () {
Get.close(1);
});
BlueManage().bludSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected) {
cancelBlueConnetctToastTimer();
var publicKey = await Storage.getStringList(saveBluePublicKey);
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
var token = await Storage.getStringList(saveBlueToken);
List<int> getTokenList = changeStringListToIntList(token!);
print(
"openDoorTokenPubToken:$getTokenList state.startDate.value:${state.startDate.value}");
print(
"限时人脸开始时间:${state.startDate.value ~/ 1000} 限时人脸结束时间:${state.endDate.value ~/ 1000}");
IoSenderManage.senderAddFaceCommand(
keyID: "1",
userID: await Storage.getUid(),
faceNo: state.isAdministrator.value == true ? 254 : 1,
useCountLimit: 0xff,
// startTime:0x11223344,
// endTime:0x11223344,
startTime: state.startDate.value ~/ 1000,
endTime: state.endDate.value ~/ 1000,
needAuthor: 1,
publicKey: publicKeyDataList,
privateKey: getPrivateKeyList,
token: getTokenList,
);
} else if (deviceConnectionState ==
BluetoothConnectionState.disconnected) {
if (state.ifCurrentScreen.value == true) {
showBlueConnetctToast();
}
cancelBlueConnetctToastTimer();
Get.close(1);
}
});
}
//
void addFaceData() async {
var entity = await ApiRepository.to.addFaceData(
lockId: state.lockId.value,
faceName: state.faceName.value,
faceNumber: state.faceNumber.value,
faceType: state.faceType.value,
startDate: state.startDate.value,
endDate: state.endDate.value,
featureData: state.featureData.value,
addType: state.addType.value,
cyclicConfig: state.cyclicConfig.value,
faceRight: state.isAdministrator.value == true ? 1 : 0,
);
if (entity.errorCode!.codeIsSuccessful) {
// Toast.show(msg: "添加成功");
print('更新人脸用户账号成功了么1');
updateFaceUserNoLoadData(entity.data!.faceId!);
}
}
//
void updateFaceUserNoLoadData(int faceId) async {
var entity = await ApiRepository.to.updateFaceUserNo(
faceId: faceId,
lockId: state.lockId.value,
faceUserNo: state.faceNumber.value,
);
if (entity.errorCode!.codeIsSuccessful) {
print('更新人脸用户账号成功了么2');
showToast("添加成功");
if (state.fromType.value == 2) {
//
eventBus.fire(ChickInAddStaffCardAndFingerprintBlockNumberEvent(
state.faceNumber.value));
} else if (state.fromType.value == 1) {
eventBus.fire(OtherTypeRefreshListEvent());
}
Get.close(2);
}
}
@override
void onReady() {
// TODO: implement onReady

View File

@ -72,7 +72,6 @@ class _AddIrisPageState extends State<AddIrisPage> {
borderRadius: 20.w,
onClick: () {
state.isClickAddFace.value = true;
logic.senderAddFace();
}),
)
: Row(