From cda022c112b17156fed34c958f6087712ac0ea0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=8F=E5=B0=91=E9=98=B3?= <786612630@qq.com> Date: Fri, 19 Apr 2024 18:13:34 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E4=BF=AE=E5=A4=8D=E5=8D=A1=E6=8C=87?= =?UTF-8?q?=E7=BA=B9=E5=B8=B8=E5=BC=80=E6=A8=A1=E5=BC=8F=E5=BE=AA=E7=8E=AF?= =?UTF-8?q?=E6=97=A5=E6=9C=9F=E9=97=AE=E9=A2=98=E3=80=822=E3=80=81?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=B8=8E=E8=93=9D=E7=89=99=E4=BA=A4=E4=BA=92?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E7=BB=9F=E4=B8=80=E7=AE=A1=E7=90=86=E5=8D=8F?= =?UTF-8?q?=E8=AE=AE=E8=BF=94=E5=9B=9E=E7=9A=84=E9=94=99=E8=AF=AF=E7=A0=81?= =?UTF-8?q?=E3=80=823=E3=80=81=E6=B7=BB=E5=8A=A0=E9=83=A8=E5=88=86?= =?UTF-8?q?=E5=9B=BD=E9=99=85=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- star_lock/images/lan/lan_en.json | 2 + star_lock/images/lan/lan_keys.json | 2 + star_lock/images/lan/lan_zh.json | 2 + star_lock/lib/blue/blue_manage.dart | 11 +- .../lib/blue/io_protocol/io_addFace.dart | 7 +- .../blue/io_protocol/io_addFingerprint.dart | 277 +++++++++--------- ...o_addFingerprintWithTimeCycleCoercion.dart | 41 ++- .../lib/blue/io_protocol/io_addICCard.dart | 270 +++++++++-------- .../io_addICCardWithTimeCycleCoercion.dart | 39 ++- .../io_protocol/io_addStressFingerprint.dart | 258 ++++++++-------- .../blue/io_protocol/io_addStressICCard.dart | 260 ++++++++-------- .../io_protocol/io_addStressPassword.dart | 9 +- .../lib/blue/io_protocol/io_addUser.dart | 9 +- .../blue/io_protocol/io_automaticPadlock.dart | 143 ++++----- .../io_changeAdministratorPassword.dart | 9 +- .../io_protocol/io_checkingCardStatus.dart | 7 +- .../io_protocol/io_checkingUserInfoCount.dart | 9 +- .../blue/io_protocol/io_configuringWifi.dart | 9 +- .../lib/blue/io_protocol/io_deletUser.dart | 10 +- .../lib/blue/io_protocol/io_editUser.dart | 9 +- .../blue/io_protocol/io_factoryDataReset.dart | 9 +- .../lib/blue/io_protocol/io_getLockStatu.dart | 267 ++++++++--------- .../blue/io_protocol/io_getPrivateKey.dart | 6 +- .../lib/blue/io_protocol/io_getPublicKey.dart | 5 +- .../io_protocol/io_getStarLockStatusInfo.dart | 87 +----- .../lib/blue/io_protocol/io_getWifiList.dart | 9 +- .../lib/blue/io_protocol/io_openLock.dart | 10 +- .../io_protocol/io_queryingFaceStatus.dart | 10 +- .../io_queryingFingerprintStatus.dart | 9 +- .../io_protocol/io_readAdminPassword.dart | 10 +- .../io_readSupportFunctionsNoParameters.dart | 9 +- ...io_readSupportFunctionsWithParameters.dart | 9 +- .../io_referEventRecordNumber.dart | 10 +- .../io_protocol/io_referEventRecordTime.dart | 11 +- .../io_protocol/io_senderCustomPasswords.dart | 11 +- .../io_setSupportFunctionsNoParameters.dart | 9 +- .../io_setSupportFunctionsWithParameters.dart | 9 +- .../blue/io_protocol/io_soundSwitchSet.dart | 0 star_lock/lib/blue/io_protocol/io_timing.dart | 11 +- .../io_protocol/io_transferPermissions.dart | 7 +- star_lock/lib/blue/io_reply.dart | 118 +++++++- star_lock/lib/blue/io_type.dart | 27 +- star_lock/lib/blue/reciver_data.dart | 42 +-- star_lock/lib/blue/sender_manage.dart | 96 +++--- .../card/addCardType/addCardType_logic.dart | 4 +- .../card/addCardType/addCardType_page.dart | 4 +- .../card/addICCard/addICCard_logic.dart | 55 +--- .../card/cardDetail/cardDetail_logic.dart | 16 +- .../card/cardList/cardList_logic.dart | 27 +- .../keyOperationRecord_logic.dart | 26 +- .../addFingerprint/addFingerprint_logic.dart | 219 +++++++------- .../addFingerprint/addFingerprint_state.dart | 2 + .../addFingerprintType_logic.dart | 6 +- .../addFingerprintType_page.dart | 5 +- .../fingerprintDetail_logic.dart | 18 +- .../fingerprintList_logic.dart | 51 +--- .../iris/irisList/irisList_logic.dart | 12 +- .../lockDetail/lockDetail_logic.dart | 42 +-- .../automaticBlocking_logic.dart | 11 - .../adminOpenLockPassword_logic.dart | 23 +- .../basicInformation_page.dart | 13 + .../uploadElectricQuantity_logic.dart | 16 +- .../burglarAlarm/burglarAlarm_logic.dart | 36 --- .../configuringWifi_logic.dart | 8 - .../wifiList/wifiList_logic.dart | 40 ++- .../lockSet/lockSet/lockSet_logic.dart | 17 -- .../lockSoundSet/lockSoundSet_logic.dart | 11 - .../lockSet/lockTime/lockTime_logic.dart | 31 +- .../lockSet/motorPower/motorPower_logic.dart | 11 - .../normallyOpenMode_logic.dart | 13 +- .../openDoorDirection_logic.dart | 12 - .../remoteUnlocking_logic.dart | 12 +- .../resetButton/resetButton_logic.dart | 11 - .../passwordKey_perpetual_logic.dart | 9 +- .../addLock/nearbyLock/nearbyLock_logic.dart | 26 +- .../mine/addLock/saveLock/saveLock_logic.dart | 20 +- .../expireCard/expireCard_logic.dart | 9 +- .../expireFingerprint_logic.dart | 24 +- star_lock/lib/tools/commonDataManage.dart | 31 ++ 79 files changed, 1448 insertions(+), 1597 deletions(-) delete mode 100644 star_lock/lib/blue/io_protocol/io_soundSwitchSet.dart create mode 100644 star_lock/lib/tools/commonDataManage.dart diff --git a/star_lock/images/lan/lan_en.json b/star_lock/images/lan/lan_en.json index d1ea88b2..4f2d61ab 100644 --- a/star_lock/images/lan/lan_en.json +++ b/star_lock/images/lan/lan_en.json @@ -717,6 +717,8 @@ "请手动在系统设置中开启": "Please manually enable it in the system settings", "权限以继续使用应用": "Permission to continue using the application.", "去设置": "Go set it up", + "当前网络": "Current network", + "位置信息": "Location information", "虹膜":"iris", "手掌":"palm", diff --git a/star_lock/images/lan/lan_keys.json b/star_lock/images/lan/lan_keys.json index 9cc2ce0b..763c70e7 100644 --- a/star_lock/images/lan/lan_keys.json +++ b/star_lock/images/lan/lan_keys.json @@ -699,6 +699,8 @@ "重命名": "重命名", "分组下的锁将被移到未分组里": "分组下的锁将被移到未分组里", "编辑成功": "编辑成功", + "当前网络": "当前网络", + "位置信息": "位置信息", "相机": "相机", "相册": "相册", diff --git a/star_lock/images/lan/lan_zh.json b/star_lock/images/lan/lan_zh.json index 0107221a..f23dc80a 100644 --- a/star_lock/images/lan/lan_zh.json +++ b/star_lock/images/lan/lan_zh.json @@ -701,6 +701,8 @@ "重命名": "重命名", "分组下的锁将被移到未分组里": "分组下的锁将被移到未分组里", "编辑成功": "编辑成功", + "当前网络": "当前网络", + "位置信息": "位置信息", "相机": "相机", "相册": "相册", diff --git a/star_lock/lib/blue/blue_manage.dart b/star_lock/lib/blue/blue_manage.dart index 9219f6a7..a8fa4c12 100644 --- a/star_lock/lib/blue/blue_manage.dart +++ b/star_lock/lib/blue/blue_manage.dart @@ -287,27 +287,20 @@ class BlueManage { print("Error Turning On:"); } } - ; } else { Get.log("开始扫描 蓝牙不可用,不能进行蓝牙操作"); } }); } - /// 调用发送数据 - Future bludSendData(String deviceName, ConnectStateCallBack stateCallBack, - {bool isAddEquipment = false}) async { + /// 调用发送数据 List senderData, + Future bludSendData(String deviceName, ConnectStateCallBack stateCallBack, {bool isAddEquipment = false}) async { FlutterBluePlus.isSupported.then((isAvailable) async { if (isAvailable) { if (_adapterState == BluetoothAdapterState.on) { // 蓝牙已开启,可以进行蓝牙操作 if (bluetoothConnectionState != BluetoothConnectionState.connected) { _connect(deviceName, (state) { - // if(bluetoothConnectionState != BluetoothConnectionState.connected){ - // stateCallBack(bluetoothConnectionState!); - // }else{ - // stateCallBack(bluetoothConnectionState!); - // } stateCallBack(bluetoothConnectionState!); }, isAddEquipment: isAddEquipment); } else { diff --git a/star_lock/lib/blue/io_protocol/io_addFace.dart b/star_lock/lib/blue/io_protocol/io_addFace.dart index 60a1cb3a..dfdc821b 100644 --- a/star_lock/lib/blue/io_protocol/io_addFace.dart +++ b/star_lock/lib/blue/io_protocol/io_addFace.dart @@ -1,5 +1,7 @@ import 'dart:convert'; +import 'package:get/get.dart'; + import '../io_tool/io_tool.dart'; import '../sm4Encipher/sm4.dart'; import '../io_reply.dart'; @@ -104,8 +106,6 @@ class SenderAddFaceCommand extends SenderProtocol { authCodeData.addAll(publicKey!); - print("${commandType!.typeValue}-authCodeData:$authCodeData"); - // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode var authCode = crypto.md5.convert(authCodeData); @@ -122,7 +122,8 @@ class SenderAddFaceCommand extends SenderProtocol { data.add(0); } } - print("${commandType!.typeName} SM4Data:$data"); + + Get.log("${commandType!.typeName} SM4Data:$data"); // 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864 ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB); return ebcData; diff --git a/star_lock/lib/blue/io_protocol/io_addFingerprint.dart b/star_lock/lib/blue/io_protocol/io_addFingerprint.dart index 4d593b97..8d684f5a 100644 --- a/star_lock/lib/blue/io_protocol/io_addFingerprint.dart +++ b/star_lock/lib/blue/io_protocol/io_addFingerprint.dart @@ -9,146 +9,145 @@ import '../io_type.dart'; import 'package:crypto/crypto.dart' as crypto; ///TODO:添加指纹 +/// 该协议已弃用 使用新协议SenderAddFingerprintWithTimeCycleCoercionCommand 2024.4.16 addby 魏少阳 /* 备注: 删除单个指纹规则:UseCountLimit 设置为 0。删除全部指纹规则: UseCountLimit 设置为 0,FingerNo 设置为 255,userId 设置为“Delete All !@#”,只有门锁管理员才有权限 **/ -class SenderAddFingerprintCommand extends SenderProtocol { - - String? keyID; - String? userID; - int? fingerNo; - int? useCountLimit; - List? token; - int? startTime; - int? endTime; - int? needAuthor; - List? signKey; - List? privateKey; - - SenderAddFingerprintCommand({ - this.keyID, - this.userID, - this.fingerNo, - this.useCountLimit, - this.token, - this.startTime, - this.endTime, - this.needAuthor, - this.signKey, - this.privateKey, - }) : super(CommandType.generalExtendedCommond); - - @override - List messageDetail() { - List data = []; - List subData = []; - List ebcData = []; - - print("pwdNopwdNopwdNopwdNo:$fingerNo"); - - // 指令类型 - int type = commandType!.typeValue; - double typeDouble = type / 256; - int type1 = typeDouble.toInt(); - int type2 = type % 256; - data.add(type1); - data.add(type2); - - // 子命令类型 - data.add(31); - - // keyID 40 - int keyIDLength = utf8.encode(keyID!).length; - // print("${commandType!.typeValue}LockIDLength:$lockIDLength utf8.encode(lockID!)${utf8.encode(lockID!)}"); - subData.addAll(utf8.encode(keyID!)); - subData = getFixedLengthList(subData, 40 - keyIDLength); - - //userID 20 - int userIDLength = utf8.encode(userID!).length; - // print("${commandType!.typeValue}IDLength:$authUserIDLength utf8.encode(authUserID!)${utf8.encode(authUserID!)}"); - subData.addAll(utf8.encode(userID!)); - subData = getFixedLengthList(subData, 20 - userIDLength); - - // PwdNo - subData.add(fingerNo!); - - // UseCountLimit - subData.add(useCountLimit!); - - // token - subData.addAll(token!); - - // startTime 4 - subData.add((startTime! & 0xff000000) >> 24); - subData.add((startTime! & 0xff0000) >> 16); - subData.add((startTime! & 0xff00) >> 8); - subData.add((startTime! & 0xff)); - - // endTime 4 - subData.add((endTime! & 0xff000000) >> 24); - subData.add((endTime! & 0xff0000) >> 16); - subData.add((endTime! & 0xff00) >> 8); - subData.add((endTime! & 0xff)); - - if(needAuthor == 0){ - //AuthCodeLen 1 - subData.add(0); - } else { - List authCodeData = []; - //KeyID - authCodeData.addAll(utf8.encode(keyID!)); - - //authUserID - authCodeData.addAll(utf8.encode(userID!)); - - //token 4 首次请求 Token 填 0,如果锁需要鉴权操作者身份,则会分配动态口令并在应答消息中返回,二次请求时带上。 - authCodeData.addAll(token!); - - authCodeData.addAll(signKey!); - - print("${commandType!.typeValue}-authCodeData:$authCodeData"); - - // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode - var authCode = crypto.md5.convert(authCodeData); - - subData.add(authCode.bytes.length); - subData.addAll(authCode.bytes); - } - - data.add(subData.length); - data.addAll(subData); - - if ((data.length % 16) != 0) { - int add = (16 - data.length % 16); - for (int i = 0; i < add; i++) { - data.add(0); - } - } - print("${commandType!.typeName} SM4Data:$data"); - // 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864 - ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB); - return ebcData; - } -} - -class SenderAddFingerprintReply extends Reply { - SenderAddFingerprintReply.parseData(CommandType commandType, List dataDetail) - : super.parseData(commandType, dataDetail) { - data = dataDetail; - } -} - -class SenderAddFingerprintProcessReply extends Reply { - SenderAddFingerprintProcessReply.parseData(CommandType commandType, List dataDetail) - : super.parseData(commandType, dataDetail) { - data = dataDetail; - } -} - -class SenderAddFingerprintConfirmationReply extends Reply { - SenderAddFingerprintConfirmationReply.parseData(CommandType commandType, List dataDetail) - : super.parseData(commandType, dataDetail) { - data = dataDetail; - } -} \ No newline at end of file +// class SenderAddFingerprintCommand extends SenderProtocol { +// +// String? keyID; +// String? userID; +// int? fingerNo; +// int? useCountLimit; +// List? token; +// int? startTime; +// int? endTime; +// int? needAuthor; +// List? signKey; +// List? privateKey; +// +// SenderAddFingerprintCommand({ +// this.keyID, +// this.userID, +// this.fingerNo, +// this.useCountLimit, +// this.token, +// this.startTime, +// this.endTime, +// this.needAuthor, +// this.signKey, +// this.privateKey, +// }) : super(CommandType.generalExtendedCommond); +// +// @override +// List messageDetail() { +// List data = []; +// List subData = []; +// List ebcData = []; +// +// print("pwdNopwdNopwdNopwdNo:$fingerNo"); +// +// // 指令类型 +// int type = commandType!.typeValue; +// double typeDouble = type / 256; +// int type1 = typeDouble.toInt(); +// int type2 = type % 256; +// data.add(type1); +// data.add(type2); +// +// // 子命令类型 +// data.add(31); +// +// // keyID 40 +// int keyIDLength = utf8.encode(keyID!).length; +// // print("${commandType!.typeValue}LockIDLength:$lockIDLength utf8.encode(lockID!)${utf8.encode(lockID!)}"); +// subData.addAll(utf8.encode(keyID!)); +// subData = getFixedLengthList(subData, 40 - keyIDLength); +// +// //userID 20 +// int userIDLength = utf8.encode(userID!).length; +// // print("${commandType!.typeValue}IDLength:$authUserIDLength utf8.encode(authUserID!)${utf8.encode(authUserID!)}"); +// subData.addAll(utf8.encode(userID!)); +// subData = getFixedLengthList(subData, 20 - userIDLength); +// +// // PwdNo +// subData.add(fingerNo!); +// +// // UseCountLimit +// subData.add(useCountLimit!); +// +// // token +// subData.addAll(token!); +// +// // startTime 4 +// subData.add((startTime! & 0xff000000) >> 24); +// subData.add((startTime! & 0xff0000) >> 16); +// subData.add((startTime! & 0xff00) >> 8); +// subData.add((startTime! & 0xff)); +// +// // endTime 4 +// subData.add((endTime! & 0xff000000) >> 24); +// subData.add((endTime! & 0xff0000) >> 16); +// subData.add((endTime! & 0xff00) >> 8); +// subData.add((endTime! & 0xff)); +// +// if(needAuthor == 0){ +// //AuthCodeLen 1 +// subData.add(0); +// } else { +// List authCodeData = []; +// //KeyID +// authCodeData.addAll(utf8.encode(keyID!)); +// +// //authUserID +// authCodeData.addAll(utf8.encode(userID!)); +// +// //token 4 首次请求 Token 填 0,如果锁需要鉴权操作者身份,则会分配动态口令并在应答消息中返回,二次请求时带上。 +// authCodeData.addAll(token!); +// +// authCodeData.addAll(signKey!); +// +// // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode +// var authCode = crypto.md5.convert(authCodeData); +// +// subData.add(authCode.bytes.length); +// subData.addAll(authCode.bytes); +// } +// +// data.add(subData.length); +// data.addAll(subData); +// +// if ((data.length % 16) != 0) { +// int add = (16 - data.length % 16); +// for (int i = 0; i < add; i++) { +// data.add(0); +// } +// } +// print("${commandType!.typeName} SM4Data:$data"); +// // 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864 +// ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB); +// return ebcData; +// } +// } +// +// class SenderAddFingerprintReply extends Reply { +// SenderAddFingerprintReply.parseData(CommandType commandType, List dataDetail) +// : super.parseData(commandType, dataDetail) { +// data = dataDetail; +// } +// } +// +// class SenderAddFingerprintProcessReply extends Reply { +// SenderAddFingerprintProcessReply.parseData(CommandType commandType, List dataDetail) +// : super.parseData(commandType, dataDetail) { +// data = dataDetail; +// } +// } +// +// class SenderAddFingerprintConfirmationReply extends Reply { +// SenderAddFingerprintConfirmationReply.parseData(CommandType commandType, List dataDetail) +// : super.parseData(commandType, dataDetail) { +// data = dataDetail; +// } +// } \ No newline at end of file diff --git a/star_lock/lib/blue/io_protocol/io_addFingerprintWithTimeCycleCoercion.dart b/star_lock/lib/blue/io_protocol/io_addFingerprintWithTimeCycleCoercion.dart index 285aea9b..c954355a 100644 --- a/star_lock/lib/blue/io_protocol/io_addFingerprintWithTimeCycleCoercion.dart +++ b/star_lock/lib/blue/io_protocol/io_addFingerprintWithTimeCycleCoercion.dart @@ -1,6 +1,8 @@ import 'dart:convert'; +import 'package:get/get.dart'; + import '../io_tool/io_tool.dart'; import '../sm4Encipher/sm4.dart'; import '../io_reply.dart'; @@ -25,8 +27,8 @@ class SenderAddFingerprintWithTimeCycleCoercionCommand extends SenderProtocol { int? weekRound; int? startDate; int? endDate; - int? startTime; - int? endTime; + String? startTime; + String? endTime; int? needAuthor; List? signKey; List? privateKey; @@ -55,8 +57,6 @@ class SenderAddFingerprintWithTimeCycleCoercionCommand extends SenderProtocol { List subData = []; List ebcData = []; - print("pwdNopwdNopwdNopwdNo:$fingerNo"); - // 指令类型 int type = commandType!.typeValue; double typeDouble = type / 256; @@ -111,16 +111,22 @@ class SenderAddFingerprintWithTimeCycleCoercionCommand extends SenderProtocol { subData.add((endDate! & 0xff)); // startTime 4 - subData.add((startTime! & 0xff000000) >> 24); - subData.add((startTime! & 0xff0000) >> 16); - subData.add((startTime! & 0xff00) >> 8); - subData.add((startTime! & 0xff)); + List startTimeList = [0,0,0,0]; + if(startTime!.contains(":")){ + List getStartTimeList = startTime!.split(":"); + startTimeList[2] = int.parse(getStartTimeList[0]); + startTimeList[3] = int.parse(getStartTimeList[1]); + } + subData.addAll(startTimeList); // endTime 4 - subData.add((endTime! & 0xff000000) >> 24); - subData.add((endTime! & 0xff0000) >> 16); - subData.add((endTime! & 0xff00) >> 8); - subData.add((endTime! & 0xff)); + List endTimeList = [0,0,0,0]; + if(endTime!.contains(":")){ + List getendTimeList = endTime!.split(":"); + endTimeList[2] = int.parse(getendTimeList[0]); + endTimeList[3] = int.parse(getendTimeList[1]); + } + subData.addAll(endTimeList); if(needAuthor == 0){ //AuthCodeLen 1 @@ -138,8 +144,6 @@ class SenderAddFingerprintWithTimeCycleCoercionCommand extends SenderProtocol { authCodeData.addAll(signKey!); - print("${commandType!.typeValue}-authCodeData:$authCodeData"); - // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode var authCode = crypto.md5.convert(authCodeData); @@ -156,7 +160,8 @@ class SenderAddFingerprintWithTimeCycleCoercionCommand extends SenderProtocol { data.add(0); } } - print("${commandType!.typeName} SM4Data:$data"); + + Get.log("${commandType!.typeName} SM4Data:$data"); // 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864 ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB); return ebcData; @@ -167,6 +172,8 @@ class SenderAddFingerprintWithTimeCycleCoercionReply extends Reply { SenderAddFingerprintWithTimeCycleCoercionReply.parseData(CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { data = dataDetail; + int status = data[2]; + errorWithStstus(status); } } @@ -174,6 +181,8 @@ class SenderAddFingerprintProcessReply extends Reply { SenderAddFingerprintProcessReply.parseData(CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { data = dataDetail; + int status = data[2]; + errorWithStstus(status); } } @@ -181,5 +190,7 @@ class SenderAddFingerprintConfirmationReply extends Reply { SenderAddFingerprintConfirmationReply.parseData(CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { data = dataDetail; + int status = data[2]; + errorWithStstus(status); } } \ No newline at end of file diff --git a/star_lock/lib/blue/io_protocol/io_addICCard.dart b/star_lock/lib/blue/io_protocol/io_addICCard.dart index 00d5c2b9..a984db3d 100644 --- a/star_lock/lib/blue/io_protocol/io_addICCard.dart +++ b/star_lock/lib/blue/io_protocol/io_addICCard.dart @@ -11,139 +11,137 @@ import '../sm4Encipher/sm4.dart'; ///TODO:该协议已弃用 使用新协议SenderAddICCardWithTimeCycleCoercionCommand 2024.4.16 addby 魏少阳 /// ///TODO:设置自定义密码 -/* -备注: -删除单个指纹规则:UseCountLimit 设置为 0。删除全部指纹规则: UseCountLimit 设置为 0,FingerNo 设置为 255,userId 设置为“Delete All !@#”,只有门锁管理员才有权限 -**/ -class SenderAddICCardCommand extends SenderProtocol { - String? keyID; - String? userID; - int? cardNo; - int? useCountLimit; - List? token; - int? startTime; - int? endTime; - int? needAuthor; - List? signKey; - List? privateKey; - - SenderAddICCardCommand({ - this.keyID, - this.userID, - this.cardNo, - this.useCountLimit, - this.token, - this.startTime, - this.endTime, - this.needAuthor, - this.signKey, - this.privateKey, - }) : super(CommandType.generalExtendedCommond); - - @override - List messageDetail() { - List data = []; - List subData = []; - List ebcData = []; - - print("pwdNopwdNopwdNopwdNo:$cardNo"); - - // 指令类型 - int type = commandType!.typeValue; - double typeDouble = type / 256; - int type1 = typeDouble.toInt(); - int type2 = type % 256; - data.add(type1); - data.add(type2); - - // 子命令类型 - data.add(21); - - // keyID 40 - int keyIDLength = utf8.encode(keyID!).length; - // print("${commandType!.typeValue}LockIDLength:$lockIDLength utf8.encode(lockID!)${utf8.encode(lockID!)}"); - subData.addAll(utf8.encode(keyID!)); - subData = getFixedLengthList(subData, 40 - keyIDLength); - - //userID 20 - int userIDLength = utf8.encode(userID!).length; - // print("${commandType!.typeValue}IDLength:$authUserIDLength utf8.encode(authUserID!)${utf8.encode(authUserID!)}"); - subData.addAll(utf8.encode(userID!)); - subData = getFixedLengthList(subData, 20 - userIDLength); - - // PwdNo - subData.add(cardNo!); - - // UseCountLimit - subData.add(useCountLimit!); - - // token - subData.addAll(token!); - - // startTime 4 - subData.add((startTime! & 0xff000000) >> 24); - subData.add((startTime! & 0xff0000) >> 16); - subData.add((startTime! & 0xff00) >> 8); - subData.add((startTime! & 0xff)); - - // endTime 4 - subData.add((endTime! & 0xff000000) >> 24); - subData.add((endTime! & 0xff0000) >> 16); - subData.add((endTime! & 0xff00) >> 8); - subData.add((endTime! & 0xff)); - - if (needAuthor == 0) { - //AuthCodeLen 1 - subData.add(0); - } else { - List authCodeData = []; - //KeyID - authCodeData.addAll(utf8.encode(keyID!)); - - //authUserID - authCodeData.addAll(utf8.encode(userID!)); - - //token 4 首次请求 Token 填 0,如果锁需要鉴权操作者身份,则会分配动态口令并在应答消息中返回,二次请求时带上。 - authCodeData.addAll(token!); - - authCodeData.addAll(signKey!); - - print("${commandType!.typeValue}-authCodeData:$authCodeData"); - - // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode - var authCode = crypto.md5.convert(authCodeData); - - subData.add(authCode.bytes.length); - subData.addAll(authCode.bytes); - } - - data.add(subData.length); - data.addAll(subData); - - if ((data.length % 16) != 0) { - int add = (16 - data.length % 16); - for (int i = 0; i < add; i++) { - data.add(0); - } - } - print("${commandType!.typeName} SM4Data:$data"); - // 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864 - ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB); - return ebcData; - } -} - -class SenderAddICCardReply extends Reply { - SenderAddICCardReply.parseData(CommandType commandType, List dataDetail) - : super.parseData(commandType, dataDetail) { - data = dataDetail; - } -} - -class SenderAddICCardConfirmationReply extends Reply { - SenderAddICCardConfirmationReply.parseData( - CommandType commandType, List dataDetail) - : super.parseData(commandType, dataDetail) { - data = dataDetail; - } -} +// /* +// 备注: +// 删除单个指纹规则:UseCountLimit 设置为 0。删除全部指纹规则: UseCountLimit 设置为 0,FingerNo 设置为 255,userId 设置为“Delete All !@#”,只有门锁管理员才有权限 +// **/ +// class SenderAddICCardCommand extends SenderProtocol { +// String? keyID; +// String? userID; +// int? cardNo; +// int? useCountLimit; +// List? token; +// int? startTime; +// int? endTime; +// int? needAuthor; +// List? signKey; +// List? privateKey; +// +// SenderAddICCardCommand({ +// this.keyID, +// this.userID, +// this.cardNo, +// this.useCountLimit, +// this.token, +// this.startTime, +// this.endTime, +// this.needAuthor, +// this.signKey, +// this.privateKey, +// }) : super(CommandType.generalExtendedCommond); +// +// @override +// List messageDetail() { +// List data = []; +// List subData = []; +// List ebcData = []; +// +// print("pwdNopwdNopwdNopwdNo:$cardNo"); +// +// // 指令类型 +// int type = commandType!.typeValue; +// double typeDouble = type / 256; +// int type1 = typeDouble.toInt(); +// int type2 = type % 256; +// data.add(type1); +// data.add(type2); +// +// // 子命令类型 +// data.add(21); +// +// // keyID 40 +// int keyIDLength = utf8.encode(keyID!).length; +// // print("${commandType!.typeValue}LockIDLength:$lockIDLength utf8.encode(lockID!)${utf8.encode(lockID!)}"); +// subData.addAll(utf8.encode(keyID!)); +// subData = getFixedLengthList(subData, 40 - keyIDLength); +// +// //userID 20 +// int userIDLength = utf8.encode(userID!).length; +// // print("${commandType!.typeValue}IDLength:$authUserIDLength utf8.encode(authUserID!)${utf8.encode(authUserID!)}"); +// subData.addAll(utf8.encode(userID!)); +// subData = getFixedLengthList(subData, 20 - userIDLength); +// +// // PwdNo +// subData.add(cardNo!); +// +// // UseCountLimit +// subData.add(useCountLimit!); +// +// // token +// subData.addAll(token!); +// +// // startTime 4 +// subData.add((startTime! & 0xff000000) >> 24); +// subData.add((startTime! & 0xff0000) >> 16); +// subData.add((startTime! & 0xff00) >> 8); +// subData.add((startTime! & 0xff)); +// +// // endTime 4 +// subData.add((endTime! & 0xff000000) >> 24); +// subData.add((endTime! & 0xff0000) >> 16); +// subData.add((endTime! & 0xff00) >> 8); +// subData.add((endTime! & 0xff)); +// +// if (needAuthor == 0) { +// //AuthCodeLen 1 +// subData.add(0); +// } else { +// List authCodeData = []; +// //KeyID +// authCodeData.addAll(utf8.encode(keyID!)); +// +// //authUserID +// authCodeData.addAll(utf8.encode(userID!)); +// +// //token 4 首次请求 Token 填 0,如果锁需要鉴权操作者身份,则会分配动态口令并在应答消息中返回,二次请求时带上。 +// authCodeData.addAll(token!); +// +// authCodeData.addAll(signKey!); +// +// // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode +// var authCode = crypto.md5.convert(authCodeData); +// +// subData.add(authCode.bytes.length); +// subData.addAll(authCode.bytes); +// } +// +// data.add(subData.length); +// data.addAll(subData); +// +// if ((data.length % 16) != 0) { +// int add = (16 - data.length % 16); +// for (int i = 0; i < add; i++) { +// data.add(0); +// } +// } +// print("${commandType!.typeName} SM4Data:$data"); +// // 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864 +// ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB); +// return ebcData; +// } +// } +// +// class SenderAddICCardReply extends Reply { +// SenderAddICCardReply.parseData(CommandType commandType, List dataDetail) +// : super.parseData(commandType, dataDetail) { +// data = dataDetail; +// } +// } +// +// class SenderAddICCardConfirmationReply extends Reply { +// SenderAddICCardConfirmationReply.parseData( +// CommandType commandType, List dataDetail) +// : super.parseData(commandType, dataDetail) { +// data = dataDetail; +// } +// } diff --git a/star_lock/lib/blue/io_protocol/io_addICCardWithTimeCycleCoercion.dart b/star_lock/lib/blue/io_protocol/io_addICCardWithTimeCycleCoercion.dart index 8f45a470..6084f252 100644 --- a/star_lock/lib/blue/io_protocol/io_addICCardWithTimeCycleCoercion.dart +++ b/star_lock/lib/blue/io_protocol/io_addICCardWithTimeCycleCoercion.dart @@ -1,6 +1,8 @@ import 'dart:convert'; +import 'package:get/get.dart'; + import '../io_tool/io_tool.dart'; import '../sm4Encipher/sm4.dart'; import '../io_reply.dart'; @@ -25,8 +27,8 @@ class SenderAddICCardWithTimeCycleCoercionCommand extends SenderProtocol { int? weekRound; int? startDate; int? endDate; - int? startTime; - int? endTime; + String? startTime; + String? endTime; int? needAuthor; List? signKey; List? privateKey; @@ -55,8 +57,6 @@ class SenderAddICCardWithTimeCycleCoercionCommand extends SenderProtocol { List subData = []; List ebcData = []; - print("cardNocardNocardNocardNo:$cardNo"); - // 指令类型 int type = commandType!.typeValue; double typeDouble = type / 256; @@ -111,16 +111,22 @@ class SenderAddICCardWithTimeCycleCoercionCommand extends SenderProtocol { subData.add((endDate! & 0xff)); // startTime 4 - subData.add((startTime! & 0xff000000) >> 24); - subData.add((startTime! & 0xff0000) >> 16); - subData.add((startTime! & 0xff00) >> 8); - subData.add((startTime! & 0xff)); + List startTimeList = [0,0,0,0]; + if(startTime!.contains(":")){ + List getStartTimeList = startTime!.split(":"); + startTimeList[2] = int.parse(getStartTimeList[0]); + startTimeList[3] = int.parse(getStartTimeList[1]); + } + subData.addAll(startTimeList); // endTime 4 - subData.add((endTime! & 0xff000000) >> 24); - subData.add((endTime! & 0xff0000) >> 16); - subData.add((endTime! & 0xff00) >> 8); - subData.add((endTime! & 0xff)); + List endTimeList = [0,0,0,0]; + if(endTime!.contains(":")){ + List getendTimeList = endTime!.split(":"); + endTimeList[2] = int.parse(getendTimeList[0]); + endTimeList[3] = int.parse(getendTimeList[1]); + } + subData.addAll(endTimeList); if(needAuthor == 0){ //AuthCodeLen 1 @@ -138,8 +144,6 @@ class SenderAddICCardWithTimeCycleCoercionCommand extends SenderProtocol { authCodeData.addAll(signKey!); - print("${commandType!.typeValue}-authCodeData:$authCodeData"); - // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode var authCode = crypto.md5.convert(authCodeData); @@ -156,7 +160,8 @@ class SenderAddICCardWithTimeCycleCoercionCommand extends SenderProtocol { data.add(0); } } - print("${commandType!.typeName} SM4Data:$data"); + + Get.log("${commandType!.typeName} SM4Data:$data"); // 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864 ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB); return ebcData; @@ -167,6 +172,8 @@ class SenderAddICCardWithTimeCycleCoercionReply extends Reply { SenderAddICCardWithTimeCycleCoercionReply.parseData(CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { data = dataDetail; + int status = data[2]; + errorWithStstus(status); } } @@ -174,5 +181,7 @@ class SenderAddICCardConfirmationReply extends Reply { SenderAddICCardConfirmationReply.parseData(CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { data = dataDetail; + int status = data[2]; + errorWithStstus(status); } } diff --git a/star_lock/lib/blue/io_protocol/io_addStressFingerprint.dart b/star_lock/lib/blue/io_protocol/io_addStressFingerprint.dart index 75b567c5..afa3ff90 100644 --- a/star_lock/lib/blue/io_protocol/io_addStressFingerprint.dart +++ b/star_lock/lib/blue/io_protocol/io_addStressFingerprint.dart @@ -13,133 +13,131 @@ import 'package:crypto/crypto.dart' as crypto; 备注: 删除单个指纹规则:UseCountLimit 设置为 0。删除全部指纹规则: UseCountLimit 设置为 0,FingerNo 设置为 255,userId 设置为“Delete All !@#”,只有门锁管理员才有权限 **/ -class SenderAddStressFingerprintCommand extends SenderProtocol { - - String? keyID; - String? userID; - int? fingerNo; - int? fingerType; - int? useCountLimit; - List? token; - int? startTime; - int? endTime; - int? needAuthor; - List? publicKey; - List? privateKey; - List? signKey; - - SenderAddStressFingerprintCommand({ - this.keyID, - this.userID, - this.fingerNo, - this.fingerType, - this.useCountLimit, - this.token, - this.startTime, - this.endTime, - this.needAuthor, - this.publicKey, - this.privateKey, - this.signKey - }) : super(CommandType.generalExtendedCommond); - - @override - List messageDetail() { - List data = []; - List subData = []; - List ebcData = []; - - // 指令类型 - int type = commandType!.typeValue; - double typeDouble = type / 256; - int type1 = typeDouble.toInt(); - int type2 = type % 256; - data.add(type1); - data.add(type2); - - // 子命令类型 - data.add(62); - - // keyID 40 - int keyIDLength = utf8.encode(keyID!).length; - // print("${commandType!.typeValue}LockIDLength:$lockIDLength utf8.encode(lockID!)${utf8.encode(lockID!)}"); - subData.addAll(utf8.encode(keyID!)); - subData = getFixedLengthList(subData, 40 - keyIDLength); - - //userID 20 - int userIDLength = utf8.encode(userID!).length; - // print("${commandType!.typeValue}IDLength:$authUserIDLength utf8.encode(authUserID!)${utf8.encode(authUserID!)}"); - subData.addAll(utf8.encode(userID!)); - subData = getFixedLengthList(subData, 20 - userIDLength); - - // PwdNo - subData.add(fingerNo!); - - // fingerType - subData.add(fingerType!); - - // UseCountLimit - subData.add(255); - - // token - subData.addAll(token!); - - // startTime 4 - subData.add((startTime! & 0xff000000) >> 24); - subData.add((startTime! & 0xff0000) >> 16); - subData.add((startTime! & 0xff00) >> 8); - subData.add((startTime! & 0xff)); - - // endTime 4 - subData.add((endTime! & 0xff000000) >> 24); - subData.add((endTime! & 0xff0000) >> 16); - subData.add((endTime! & 0xff00) >> 8); - subData.add((endTime! & 0xff)); - - if(needAuthor == 0){ - //AuthCodeLen 1 - subData.add(0); - } else { - List authCodeData = []; - - //KeyID - authCodeData.addAll(utf8.encode(keyID!)); - - //authUserID - authCodeData.addAll(utf8.encode(userID!)); - - //token 4 首次请求 Token 填 0,如果锁需要鉴权操作者身份,则会分配动态口令并在应答消息中返回,二次请求时带上。 - authCodeData.addAll(token!); - - authCodeData.addAll(signKey!); - - print("${commandType!.typeValue}-authCodeData:$authCodeData"); - - // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode - var authCode = crypto.md5.convert(authCodeData); - subData.add(authCode.bytes.length); - subData.addAll(authCode.bytes); - } - - data.add(subData.length); - data.addAll(subData); - - if ((data.length % 16) != 0) { - int add = (16 - data.length % 16); - for (int i = 0; i < add; i++) { - data.add(0); - } - } - print("${commandType!.typeName} SM4Data:$data"); - // 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864 - ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB); - return ebcData; - } -} - -class SenderAddStressFingerprintReply extends Reply { - SenderAddStressFingerprintReply.parseData(CommandType commandType, List dataDetail) - : super.parseData(commandType, dataDetail) { - data = dataDetail; - } -} \ No newline at end of file +// class SenderAddStressFingerprintCommand extends SenderProtocol { +// +// String? keyID; +// String? userID; +// int? fingerNo; +// int? fingerType; +// int? useCountLimit; +// List? token; +// int? startTime; +// int? endTime; +// int? needAuthor; +// List? publicKey; +// List? privateKey; +// List? signKey; +// +// SenderAddStressFingerprintCommand({ +// this.keyID, +// this.userID, +// this.fingerNo, +// this.fingerType, +// this.useCountLimit, +// this.token, +// this.startTime, +// this.endTime, +// this.needAuthor, +// this.publicKey, +// this.privateKey, +// this.signKey +// }) : super(CommandType.generalExtendedCommond); +// +// @override +// List messageDetail() { +// List data = []; +// List subData = []; +// List ebcData = []; +// +// // 指令类型 +// int type = commandType!.typeValue; +// double typeDouble = type / 256; +// int type1 = typeDouble.toInt(); +// int type2 = type % 256; +// data.add(type1); +// data.add(type2); +// +// // 子命令类型 +// data.add(62); +// +// // keyID 40 +// int keyIDLength = utf8.encode(keyID!).length; +// // print("${commandType!.typeValue}LockIDLength:$lockIDLength utf8.encode(lockID!)${utf8.encode(lockID!)}"); +// subData.addAll(utf8.encode(keyID!)); +// subData = getFixedLengthList(subData, 40 - keyIDLength); +// +// //userID 20 +// int userIDLength = utf8.encode(userID!).length; +// // print("${commandType!.typeValue}IDLength:$authUserIDLength utf8.encode(authUserID!)${utf8.encode(authUserID!)}"); +// subData.addAll(utf8.encode(userID!)); +// subData = getFixedLengthList(subData, 20 - userIDLength); +// +// // PwdNo +// subData.add(fingerNo!); +// +// // fingerType +// subData.add(fingerType!); +// +// // UseCountLimit +// subData.add(255); +// +// // token +// subData.addAll(token!); +// +// // startTime 4 +// subData.add((startTime! & 0xff000000) >> 24); +// subData.add((startTime! & 0xff0000) >> 16); +// subData.add((startTime! & 0xff00) >> 8); +// subData.add((startTime! & 0xff)); +// +// // endTime 4 +// subData.add((endTime! & 0xff000000) >> 24); +// subData.add((endTime! & 0xff0000) >> 16); +// subData.add((endTime! & 0xff00) >> 8); +// subData.add((endTime! & 0xff)); +// +// if(needAuthor == 0){ +// //AuthCodeLen 1 +// subData.add(0); +// } else { +// List authCodeData = []; +// +// //KeyID +// authCodeData.addAll(utf8.encode(keyID!)); +// +// //authUserID +// authCodeData.addAll(utf8.encode(userID!)); +// +// //token 4 首次请求 Token 填 0,如果锁需要鉴权操作者身份,则会分配动态口令并在应答消息中返回,二次请求时带上。 +// authCodeData.addAll(token!); +// +// authCodeData.addAll(signKey!); +// +// // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode +// var authCode = crypto.md5.convert(authCodeData); +// subData.add(authCode.bytes.length); +// subData.addAll(authCode.bytes); +// } +// +// data.add(subData.length); +// data.addAll(subData); +// +// if ((data.length % 16) != 0) { +// int add = (16 - data.length % 16); +// for (int i = 0; i < add; i++) { +// data.add(0); +// } +// } +// print("${commandType!.typeName} SM4Data:$data"); +// // 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864 +// ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB); +// return ebcData; +// } +// } +// +// class SenderAddStressFingerprintReply extends Reply { +// SenderAddStressFingerprintReply.parseData(CommandType commandType, List dataDetail) +// : super.parseData(commandType, dataDetail) { +// data = dataDetail; +// } +// } \ No newline at end of file diff --git a/star_lock/lib/blue/io_protocol/io_addStressICCard.dart b/star_lock/lib/blue/io_protocol/io_addStressICCard.dart index a365cfeb..9e277648 100644 --- a/star_lock/lib/blue/io_protocol/io_addStressICCard.dart +++ b/star_lock/lib/blue/io_protocol/io_addStressICCard.dart @@ -15,134 +15,132 @@ import 'package:crypto/crypto.dart' as crypto; 备注: 删除单个指纹规则:UseCountLimit 设置为 0。删除全部指纹规则: UseCountLimit 设置为 0,FingerNo 设置为 255,userId 设置为“Delete All !@#”,只有门锁管理员才有权限 **/ -class SenderAddStressICCardCommand extends SenderProtocol { - - String? keyID; - String? userID; - int? icCardNo; - int? cardType; - int? useCountLimit; - List? token; - int? startTime; - int? endTime; - int? needAuthor; - List? publicKey; - List? privateKey; - List? signKey; - - SenderAddStressICCardCommand({ - this.keyID, - this.userID, - this.icCardNo, - this.cardType, - this.useCountLimit, - this.token, - this.startTime, - this.endTime, - this.needAuthor, - this.publicKey, - this.privateKey, - this.signKey - }) : super(CommandType.generalExtendedCommond); - - @override - List messageDetail() { - List data = []; - List subData = []; - List ebcData = []; - - // 指令类型 - int type = commandType!.typeValue; - double typeDouble = type / 256; - int type1 = typeDouble.toInt(); - int type2 = type % 256; - data.add(type1); - data.add(type2); - - // 子命令类型 - data.add(61); - - // keyID 40 - int keyIDLength = utf8.encode(keyID!).length; - // print("${commandType!.typeValue}LockIDLength:$lockIDLength utf8.encode(lockID!)${utf8.encode(lockID!)}"); - subData.addAll(utf8.encode(keyID!)); - subData = getFixedLengthList(subData, 40 - keyIDLength); - - //userID 20 - int userIDLength = utf8.encode(userID!).length; - // print("${commandType!.typeValue}IDLength:$authUserIDLength utf8.encode(authUserID!)${utf8.encode(authUserID!)}"); - subData.addAll(utf8.encode(userID!)); - subData = getFixedLengthList(subData, 20 - userIDLength); - - // icCardNo - subData.add(icCardNo!); - - // cardType - subData.add(cardType!); - - // UseCountLimit - subData.add(0xff); - - // token - subData.addAll(token!); - - // startTime 4 - subData.add((startTime! & 0xff000000) >> 24); - subData.add((startTime! & 0xff0000) >> 16); - subData.add((startTime! & 0xff00) >> 8); - subData.add((startTime! & 0xff)); - - // endTime 4 - subData.add((endTime! & 0xff000000) >> 24); - subData.add((endTime! & 0xff0000) >> 16); - subData.add((endTime! & 0xff00) >> 8); - subData.add((endTime! & 0xff)); - - if(needAuthor == 0){ - //AuthCodeLen 1 - subData.add(0); - } else { - List authCodeData = []; - - //KeyID - authCodeData.addAll(utf8.encode(keyID!)); - - //authUserID - authCodeData.addAll(utf8.encode(userID!)); - - //token 4 首次请求 Token 填 0,如果锁需要鉴权操作者身份,则会分配动态口令并在应答消息中返回,二次请求时带上。 - authCodeData.addAll(token!); - - authCodeData.addAll(signKey!); - - print("${commandType!.typeValue}-authCodeData:$authCodeData"); - - // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode - var authCode = crypto.md5.convert(authCodeData); - - subData.add(authCode.bytes.length); - subData.addAll(authCode.bytes); - } - - data.add(subData.length); - data.addAll(subData); - - if ((data.length % 16) != 0) { - int add = (16 - data.length % 16); - for (int i = 0; i < add; i++) { - data.add(0); - } - } - print("${commandType!.typeName} SM4Data:$data"); - // 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864 - ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB); - return ebcData; - } -} - -class SenderAddStressICCardReply extends Reply { - SenderAddStressICCardReply.parseData(CommandType commandType, List dataDetail) - : super.parseData(commandType, dataDetail) { - data = dataDetail; - } -} \ No newline at end of file +// class SenderAddStressICCardCommand extends SenderProtocol { +// +// String? keyID; +// String? userID; +// int? icCardNo; +// int? cardType; +// int? useCountLimit; +// List? token; +// int? startTime; +// int? endTime; +// int? needAuthor; +// List? publicKey; +// List? privateKey; +// List? signKey; +// +// SenderAddStressICCardCommand({ +// this.keyID, +// this.userID, +// this.icCardNo, +// this.cardType, +// this.useCountLimit, +// this.token, +// this.startTime, +// this.endTime, +// this.needAuthor, +// this.publicKey, +// this.privateKey, +// this.signKey +// }) : super(CommandType.generalExtendedCommond); +// +// @override +// List messageDetail() { +// List data = []; +// List subData = []; +// List ebcData = []; +// +// // 指令类型 +// int type = commandType!.typeValue; +// double typeDouble = type / 256; +// int type1 = typeDouble.toInt(); +// int type2 = type % 256; +// data.add(type1); +// data.add(type2); +// +// // 子命令类型 +// data.add(61); +// +// // keyID 40 +// int keyIDLength = utf8.encode(keyID!).length; +// // print("${commandType!.typeValue}LockIDLength:$lockIDLength utf8.encode(lockID!)${utf8.encode(lockID!)}"); +// subData.addAll(utf8.encode(keyID!)); +// subData = getFixedLengthList(subData, 40 - keyIDLength); +// +// //userID 20 +// int userIDLength = utf8.encode(userID!).length; +// // print("${commandType!.typeValue}IDLength:$authUserIDLength utf8.encode(authUserID!)${utf8.encode(authUserID!)}"); +// subData.addAll(utf8.encode(userID!)); +// subData = getFixedLengthList(subData, 20 - userIDLength); +// +// // icCardNo +// subData.add(icCardNo!); +// +// // cardType +// subData.add(cardType!); +// +// // UseCountLimit +// subData.add(0xff); +// +// // token +// subData.addAll(token!); +// +// // startTime 4 +// subData.add((startTime! & 0xff000000) >> 24); +// subData.add((startTime! & 0xff0000) >> 16); +// subData.add((startTime! & 0xff00) >> 8); +// subData.add((startTime! & 0xff)); +// +// // endTime 4 +// subData.add((endTime! & 0xff000000) >> 24); +// subData.add((endTime! & 0xff0000) >> 16); +// subData.add((endTime! & 0xff00) >> 8); +// subData.add((endTime! & 0xff)); +// +// if(needAuthor == 0){ +// //AuthCodeLen 1 +// subData.add(0); +// } else { +// List authCodeData = []; +// +// //KeyID +// authCodeData.addAll(utf8.encode(keyID!)); +// +// //authUserID +// authCodeData.addAll(utf8.encode(userID!)); +// +// //token 4 首次请求 Token 填 0,如果锁需要鉴权操作者身份,则会分配动态口令并在应答消息中返回,二次请求时带上。 +// authCodeData.addAll(token!); +// +// authCodeData.addAll(signKey!); +// +// // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode +// var authCode = crypto.md5.convert(authCodeData); +// +// subData.add(authCode.bytes.length); +// subData.addAll(authCode.bytes); +// } +// +// data.add(subData.length); +// data.addAll(subData); +// +// if ((data.length % 16) != 0) { +// int add = (16 - data.length % 16); +// for (int i = 0; i < add; i++) { +// data.add(0); +// } +// } +// print("${commandType!.typeName} SM4Data:$data"); +// // 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864 +// ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB); +// return ebcData; +// } +// } +// +// class SenderAddStressICCardReply extends Reply { +// SenderAddStressICCardReply.parseData(CommandType commandType, List dataDetail) +// : super.parseData(commandType, dataDetail) { +// data = dataDetail; +// } +// } \ No newline at end of file diff --git a/star_lock/lib/blue/io_protocol/io_addStressPassword.dart b/star_lock/lib/blue/io_protocol/io_addStressPassword.dart index 7af86a55..22e7b345 100644 --- a/star_lock/lib/blue/io_protocol/io_addStressPassword.dart +++ b/star_lock/lib/blue/io_protocol/io_addStressPassword.dart @@ -1,6 +1,8 @@ import 'dart:convert'; +import 'package:get/get.dart'; + import '../io_tool/io_tool.dart'; import '../sm4Encipher/sm4.dart'; import '../io_reply.dart'; @@ -106,8 +108,6 @@ class SenderAddStressPasswordCommand extends SenderProtocol { authCodeData.addAll(publicKey!); - print("${commandType!.typeValue}-authCodeData:$authCodeData"); - // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode var authCode = crypto.md5.convert(authCodeData); @@ -124,7 +124,8 @@ class SenderAddStressPasswordCommand extends SenderProtocol { data.add(0); } } - print("${commandType!.typeName} SM4Data:$data"); + + Get.log("${commandType!.typeName} SM4Data:$data"); // 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864 ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB); return ebcData; @@ -135,5 +136,7 @@ class SenderAddStressPasswordReply extends Reply { SenderAddStressPasswordReply.parseData(CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { data = dataDetail; + int status = data[2]; + errorWithStstus(status); } } \ No newline at end of file diff --git a/star_lock/lib/blue/io_protocol/io_addUser.dart b/star_lock/lib/blue/io_protocol/io_addUser.dart index 1f702f78..f2f9870e 100644 --- a/star_lock/lib/blue/io_protocol/io_addUser.dart +++ b/star_lock/lib/blue/io_protocol/io_addUser.dart @@ -1,6 +1,8 @@ import 'dart:convert'; +import 'package:get/get.dart'; + import '../io_tool/io_tool.dart'; import '../sm4Encipher/sm4.dart'; import '../io_reply.dart'; @@ -136,8 +138,6 @@ class AddUserCommand extends SenderProtocol { authCodeData.addAll(publicKey!); - print("${commandType!.typeValue}-authCodeData:$authCodeData"); - // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode var authCode = crypto.md5.convert(authCodeData); @@ -151,7 +151,8 @@ class AddUserCommand extends SenderProtocol { data.add(0); } } - print("${commandType!.typeName} SM4Data:$data"); + + Get.log("${commandType!.typeName} SM4Data:$data"); // 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864 ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB); return ebcData; @@ -162,5 +163,7 @@ class AddUserReply extends Reply { AddUserReply.parseData(CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { data = dataDetail; + int status = data[46]; + errorWithStstus(status); } } \ No newline at end of file diff --git a/star_lock/lib/blue/io_protocol/io_automaticPadlock.dart b/star_lock/lib/blue/io_protocol/io_automaticPadlock.dart index d49c0627..62672a0e 100644 --- a/star_lock/lib/blue/io_protocol/io_automaticPadlock.dart +++ b/star_lock/lib/blue/io_protocol/io_automaticPadlock.dart @@ -8,74 +8,75 @@ import '../io_type.dart'; import 'package:crypto/crypto.dart' as crypto; //TODO:自动落锁开关 -class AutomaticPadlockCommand extends SenderProtocol { - String? lockID; - String? userID; - int? autoLockFlag; - List? token; - int? needAuthor; - List? signKey; - List? privateKey; - AutomaticPadlockCommand({ - this.lockID, - this.userID, - this.autoLockFlag, - this.token, - this.needAuthor, - this.signKey, - this.privateKey - }) : super(CommandType.generalExtendedCommond); - - @override - List messageDetail() { - List data = []; - List subData = []; - List ebcData = []; - - // 指令类型 - int type = commandType!.typeValue; - double typeDouble = type / 256; - int type1 = typeDouble.toInt(); - int type2 = type % 256; - data.add(type1); - data.add(type2); - - // 子命令类型 - data.add(4); - - //lockID 40 - int lockIDLength = utf8.encode(lockID!).length; - subData.addAll(utf8.encode(lockID!)); - subData = getFixedLengthList(subData, 40 - lockIDLength); - - //userID 要接受钥匙的用户的useid 20 - int userIDLength = utf8.encode(userID!).length; - print("openDoorUserId:${utf8.encode(userID!)} utf8.encode(userID!).length:${utf8.encode(userID!).length}"); - subData.addAll(utf8.encode(userID!)); - subData = getFixedLengthList(subData, 20 - userIDLength); - - // autoLockFlag 0:不自动落锁,1:自动落锁 - subData.add(autoLockFlag!); - - data.add(subData.length); - data.addAll(subData); - - print("data:$data data.length:${data.length} (data.length % 16):${(data.length % 16)}"); - if ((data.length % 16) != 0) { - int add = (16 - data.length % 16); - for (int i = 0; i < add; i++) { - data.add(0); - } - } - print("${commandType!.typeName} SM4Data:$data"); - ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB); - return ebcData; - } -} - -class AutomaticPadlockReply extends Reply { - AutomaticPadlockReply.parseData(CommandType commandType, List dataDetail) - : super.parseData(commandType, dataDetail) { - data = dataDetail; - } -} \ No newline at end of file +/// 废弃 +// class AutomaticPadlockCommand extends SenderProtocol { +// String? lockID; +// String? userID; +// int? autoLockFlag; +// List? token; +// int? needAuthor; +// List? signKey; +// List? privateKey; +// AutomaticPadlockCommand({ +// this.lockID, +// this.userID, +// this.autoLockFlag, +// this.token, +// this.needAuthor, +// this.signKey, +// this.privateKey +// }) : super(CommandType.generalExtendedCommond); +// +// @override +// List messageDetail() { +// List data = []; +// List subData = []; +// List ebcData = []; +// +// // 指令类型 +// int type = commandType!.typeValue; +// double typeDouble = type / 256; +// int type1 = typeDouble.toInt(); +// int type2 = type % 256; +// data.add(type1); +// data.add(type2); +// +// // 子命令类型 +// data.add(4); +// +// //lockID 40 +// int lockIDLength = utf8.encode(lockID!).length; +// subData.addAll(utf8.encode(lockID!)); +// subData = getFixedLengthList(subData, 40 - lockIDLength); +// +// //userID 要接受钥匙的用户的useid 20 +// int userIDLength = utf8.encode(userID!).length; +// print("openDoorUserId:${utf8.encode(userID!)} utf8.encode(userID!).length:${utf8.encode(userID!).length}"); +// subData.addAll(utf8.encode(userID!)); +// subData = getFixedLengthList(subData, 20 - userIDLength); +// +// // autoLockFlag 0:不自动落锁,1:自动落锁 +// subData.add(autoLockFlag!); +// +// data.add(subData.length); +// data.addAll(subData); +// +// print("data:$data data.length:${data.length} (data.length % 16):${(data.length % 16)}"); +// if ((data.length % 16) != 0) { +// int add = (16 - data.length % 16); +// for (int i = 0; i < add; i++) { +// data.add(0); +// } +// } +// print("${commandType!.typeName} SM4Data:$data"); +// ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB); +// return ebcData; +// } +// } +// +// class AutomaticPadlockReply extends Reply { +// AutomaticPadlockReply.parseData(CommandType commandType, List dataDetail) +// : super.parseData(commandType, dataDetail) { +// data = dataDetail; +// } +// } \ No newline at end of file diff --git a/star_lock/lib/blue/io_protocol/io_changeAdministratorPassword.dart b/star_lock/lib/blue/io_protocol/io_changeAdministratorPassword.dart index 369d4957..b1cb7f2b 100644 --- a/star_lock/lib/blue/io_protocol/io_changeAdministratorPassword.dart +++ b/star_lock/lib/blue/io_protocol/io_changeAdministratorPassword.dart @@ -1,6 +1,8 @@ import 'dart:convert'; +import 'package:get/get.dart'; + import '../io_tool/io_tool.dart'; import '../sm4Encipher/sm4.dart'; import '../io_reply.dart'; @@ -110,8 +112,6 @@ class ChangeAdministratorPasswordCommand extends SenderProtocol { authCodeData.addAll(signKey!); - print("${commandType!.typeValue}-authCodeData:$authCodeData"); - // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode var authCode = crypto.md5.convert(authCodeData); @@ -128,7 +128,8 @@ class ChangeAdministratorPasswordCommand extends SenderProtocol { data.add(0); } } - print("${commandType!.typeName} SM4Data:$data"); + + Get.log("${commandType!.typeName} SM4Data:$data"); // 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864 ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB); return ebcData; @@ -139,5 +140,7 @@ class ChangeAdministratorPasswordReply extends Reply { ChangeAdministratorPasswordReply.parseData(CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { data = dataDetail; + int status = data[2]; + errorWithStstus(status); } } \ No newline at end of file diff --git a/star_lock/lib/blue/io_protocol/io_checkingCardStatus.dart b/star_lock/lib/blue/io_protocol/io_checkingCardStatus.dart index 672c7181..fdbc9d35 100644 --- a/star_lock/lib/blue/io_protocol/io_checkingCardStatus.dart +++ b/star_lock/lib/blue/io_protocol/io_checkingCardStatus.dart @@ -2,6 +2,8 @@ //TODO:查询指纹状态 import 'dart:convert'; +import 'package:get/get.dart'; + import '../io_reply.dart'; import '../io_sender.dart'; import '../io_tool/io_tool.dart'; @@ -86,8 +88,6 @@ class SenderCheckingCardStatusCommand extends SenderProtocol { authCodeData.addAll(publicKey!); - print("${commandType!.typeValue}-authCodeData:$authCodeData"); - // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode var authCode = crypto.md5.convert(authCodeData); @@ -104,7 +104,8 @@ class SenderCheckingCardStatusCommand extends SenderProtocol { data.add(0); } } - print("${commandType!.typeName} SM4Data:$data"); + + Get.log("${commandType!.typeName} SM4Data:$data"); // 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864 ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB); return ebcData; diff --git a/star_lock/lib/blue/io_protocol/io_checkingUserInfoCount.dart b/star_lock/lib/blue/io_protocol/io_checkingUserInfoCount.dart index e95bf38e..b7466def 100644 --- a/star_lock/lib/blue/io_protocol/io_checkingUserInfoCount.dart +++ b/star_lock/lib/blue/io_protocol/io_checkingUserInfoCount.dart @@ -2,6 +2,8 @@ //TODO:查询用户、指纹、密码、卡片数量(用于判断是否同步) import 'dart:convert'; +import 'package:get/get.dart'; + import '../io_reply.dart'; import '../io_sender.dart'; import '../io_tool/io_tool.dart'; @@ -87,8 +89,6 @@ class SenderCheckingUserInfoCountCommand extends SenderProtocol { authCodeData.addAll(publicKey!); - print("${commandType!.typeValue}-authCodeData:$authCodeData"); - // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode var authCode = crypto.md5.convert(authCodeData); @@ -105,7 +105,8 @@ class SenderCheckingUserInfoCountCommand extends SenderProtocol { data.add(0); } } - print("${commandType!.typeName} SM4Data:$data"); + + Get.log("${commandType!.typeName} SM4Data:$data"); // 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864 ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB); return ebcData; @@ -116,5 +117,7 @@ class SenderCheckingUserInfoCountReply extends Reply { SenderCheckingUserInfoCountReply.parseData(CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { data = dataDetail; + int status = data[2]; + errorWithStstus(status); } } \ No newline at end of file diff --git a/star_lock/lib/blue/io_protocol/io_configuringWifi.dart b/star_lock/lib/blue/io_protocol/io_configuringWifi.dart index 19500262..9dc0c61d 100644 --- a/star_lock/lib/blue/io_protocol/io_configuringWifi.dart +++ b/star_lock/lib/blue/io_protocol/io_configuringWifi.dart @@ -2,6 +2,8 @@ //TODO:WIFI配网 import 'dart:convert'; +import 'package:get/get.dart'; + import '../io_reply.dart'; import '../io_sender.dart'; import '../io_tool/io_tool.dart'; @@ -112,8 +114,6 @@ class SenderConfiguringWifiCommand extends SenderProtocol { authCodeData.addAll(publicKey!); - print("${commandType!.typeValue}-authCodeData:$authCodeData"); - // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode var authCode = crypto.md5.convert(authCodeData); @@ -130,7 +130,8 @@ class SenderConfiguringWifiCommand extends SenderProtocol { data.add(0); } } - print("${commandType!.typeName} SM4Data:$data"); + + Get.log("${commandType!.typeName} SM4Data:$data"); // 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864 ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB); return ebcData; @@ -141,5 +142,7 @@ class SenderConfiguringWifiReply extends Reply { SenderConfiguringWifiReply.parseData(CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { data = dataDetail; + int status = data[5]; + errorWithStstus(status); } } \ No newline at end of file diff --git a/star_lock/lib/blue/io_protocol/io_deletUser.dart b/star_lock/lib/blue/io_protocol/io_deletUser.dart index 315c8b2a..0f77fab0 100644 --- a/star_lock/lib/blue/io_protocol/io_deletUser.dart +++ b/star_lock/lib/blue/io_protocol/io_deletUser.dart @@ -3,6 +3,8 @@ //TODO:添加用户 import 'dart:convert'; +import 'package:get/get.dart'; + import '../io_tool/io_tool.dart'; import '../sm4Encipher/sm4.dart'; import '../io_reply.dart'; @@ -88,8 +90,6 @@ class DeletUserCommand extends SenderProtocol { authCodeData.addAll(publicKey!); - // print("${commandType!.typeValue}-authCodeData:$authCodeData"); - // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode var authCode = crypto.md5.convert(authCodeData); @@ -103,7 +103,8 @@ class DeletUserCommand extends SenderProtocol { data.add(0); } } - print("${commandType!.typeName} SM4Data:$data"); + + Get.log("${commandType!.typeName} SM4Data:$data"); // 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864 ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB); return ebcData; @@ -113,7 +114,8 @@ class DeletUserCommand extends SenderProtocol { class DeletUserReply extends Reply { DeletUserReply.parseData(CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { - print("$commandType:$dataDetail"); data = dataDetail; + int status = data[6]; + errorWithStstus(status); } } diff --git a/star_lock/lib/blue/io_protocol/io_editUser.dart b/star_lock/lib/blue/io_protocol/io_editUser.dart index 64d793be..9ef370dd 100644 --- a/star_lock/lib/blue/io_protocol/io_editUser.dart +++ b/star_lock/lib/blue/io_protocol/io_editUser.dart @@ -3,6 +3,8 @@ //TODO:修改用户 import 'dart:convert'; +import 'package:get/get.dart'; + import '../io_tool/io_tool.dart'; import '../sm4Encipher/sm4.dart'; import '../io_reply.dart'; @@ -136,8 +138,6 @@ class EditUserCommand extends SenderProtocol { authCodeData.addAll(publicKey!); - // print("${commandType!.typeValue}-authCodeData:$authCodeData"); - // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode var authCode = crypto.md5.convert(authCodeData); @@ -151,7 +151,8 @@ class EditUserCommand extends SenderProtocol { data.add(0); } } - print("${commandType!.typeName} SM4Data:$data"); + + Get.log("${commandType!.typeName} SM4Data:$data"); // 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864 ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB); return ebcData; @@ -162,5 +163,7 @@ class EditUserReply extends Reply { EditUserReply.parseData(CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { data = dataDetail; + // int status = data[6]; + // errorWithStstus(status); } } \ No newline at end of file diff --git a/star_lock/lib/blue/io_protocol/io_factoryDataReset.dart b/star_lock/lib/blue/io_protocol/io_factoryDataReset.dart index 497cd581..0212ebf8 100644 --- a/star_lock/lib/blue/io_protocol/io_factoryDataReset.dart +++ b/star_lock/lib/blue/io_protocol/io_factoryDataReset.dart @@ -2,6 +2,8 @@ //TODO:添加用户 import 'dart:convert'; +import 'package:get/get.dart'; + import '../../tools/storage.dart'; import '../blue_manage.dart'; import '../io_tool/io_manager.dart'; @@ -75,8 +77,6 @@ class FactoryDataResetCommand extends SenderProtocol { authCodeData.addAll(publicKey!); - print("${commandType!.typeValue}-authCodeData:$authCodeData"); - // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode var authCode = crypto.md5.convert(authCodeData); @@ -90,7 +90,8 @@ class FactoryDataResetCommand extends SenderProtocol { data.add(0); } } - print("${commandType!.typeName} SM4Data:$data"); + + Get.log("${commandType!.typeName} SM4Data:$data"); // 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864 ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB); return ebcData; @@ -101,5 +102,7 @@ class FactoryDataResetReply extends Reply { FactoryDataResetReply.parseData(CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { data = dataDetail; + int status = data[6]; + errorWithStstus(status); } } \ No newline at end of file diff --git a/star_lock/lib/blue/io_protocol/io_getLockStatu.dart b/star_lock/lib/blue/io_protocol/io_getLockStatu.dart index 7e51942d..3c5a1485 100644 --- a/star_lock/lib/blue/io_protocol/io_getLockStatu.dart +++ b/star_lock/lib/blue/io_protocol/io_getLockStatu.dart @@ -1,134 +1,135 @@ -//TODO:获取锁状态 -import 'dart:convert'; - -import '../io_tool/io_tool.dart'; -import '../sm4Encipher/sm4.dart'; -import '../io_reply.dart'; -import '../io_sender.dart'; -import '../io_type.dart'; - -class GetLockStatuCommand extends SenderProtocol { - - String? lockID; - String? userID; - List? privateKey; - GetLockStatuCommand({ - this.lockID, - this.userID, - this.privateKey - }) : super(CommandType.readLockStatusInfo); - - @override - List messageDetail() { - List data = []; - List ebcData = []; - - // 指令类型 - int type = commandType!.typeValue; - double typeDouble = type / 256; - int type1 = typeDouble.toInt(); - int type2 = type % 256; - data.add(type1); - data.add(type2); - - // 锁id 40 - int lockIDLength = utf8.encode(lockID!).length; - // print("addUserLockIDLength:$lockIDLength utf8.encode(lockID!)${utf8.encode(lockID!)}"); - data.addAll(utf8.encode(lockID!)); - data = getFixedLengthList(data, 40 - lockIDLength); - - //userID 要接受钥匙的用户的useid 20 - int userIDLength = utf8.encode(userID!).length; - // print("userIDLength:$userIDLength utf8.encode(userID!)${utf8.encode(userID!)}"); - data.addAll(utf8.encode(userID!)); - data = getFixedLengthList(data, 20 - userIDLength); - - if ((data.length % 16) != 0) { - int add = (16 - data.length % 16); - for (int i = 0; i < add; i++) { - data.add(0); - } - } - print("${commandType!.typeName} SM4Data:$data"); - // 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864 - ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB); - return ebcData; - } -} - -class GetLockStatuReply extends Reply { - GetLockStatuReply.parseData(CommandType commandType, List dataDetail) - : super.parseData(commandType, dataDetail) { - data = dataDetail; - - int status = data[2]; - switch(status){ - case 0x00: - //成功 - print("${commandType.typeValue} 数据解析成功"); - var softVersion = data.sublist(3, 7); - // print("softVersion:$softVersion"); - - var power = data[7]; - // print("power:$power"); - - // APP 用户数量 - var appUserCount = data.sublist(50, 53); - // print("appUserCount:$appUserCount"); - - // 黑名单用户数量 - var blacklistCount = data[53]; - // print("blacklistCount:$blacklistCount"); - - // 蓝牙钥匙数量 - var bleKeyCount = data[54]; - // print("bleKeyCount:$bleKeyCount"); - - // 剩余可添加用户数量 - var remainCount = data.sublist(54, 56); - // print("remainCount:$remainCount"); - - // 未上传开锁记录数量 - var notUploadCount = data.sublist(56, 58); - // print("notUploadCount:$notUploadCount"); - - // 已设置开门密码数量 - var pwdCount = data[58]; - // print("pwdCount:$pwdCount"); - - // 已设置开门指纹数量 - var fingerprintCount = data[59]; - // print("fingerprintCount:$fingerprintCount"); - - // 锁当前时间 - var lockTime = data.sublist(60, 64); - // print("lockTime:$lockTime"); - - // 硬件版本信息,为固件升级提供判断依据 - var hardVersion = data.sublist(64, 68); - // print("hardVersion:$hardVersion"); - break; - case 0x06: - //无权限 - print("${commandType.typeValue} 需要鉴权"); - - break; - case 0x07: - //无权限 - print("${commandType.typeValue} 用户无权限"); - - break; - case 0x09: - // 权限校验错误 - print("${commandType.typeValue} 权限校验错误"); - - break; - default: - //失败 - print("${commandType.typeValue} 领锁失败"); - - break; - } - } -} \ No newline at end of file +///TODO:获取锁状态 +/// 弃用 +// import 'dart:convert'; +// +// import '../io_tool/io_tool.dart'; +// import '../sm4Encipher/sm4.dart'; +// import '../io_reply.dart'; +// import '../io_sender.dart'; +// import '../io_type.dart'; +// +// class GetLockStatuCommand extends SenderProtocol { +// +// String? lockID; +// String? userID; +// List? privateKey; +// GetLockStatuCommand({ +// this.lockID, +// this.userID, +// this.privateKey +// }) : super(CommandType.readLockStatusInfo); +// +// @override +// List messageDetail() { +// List data = []; +// List ebcData = []; +// +// // 指令类型 +// int type = commandType!.typeValue; +// double typeDouble = type / 256; +// int type1 = typeDouble.toInt(); +// int type2 = type % 256; +// data.add(type1); +// data.add(type2); +// +// // 锁id 40 +// int lockIDLength = utf8.encode(lockID!).length; +// // print("addUserLockIDLength:$lockIDLength utf8.encode(lockID!)${utf8.encode(lockID!)}"); +// data.addAll(utf8.encode(lockID!)); +// data = getFixedLengthList(data, 40 - lockIDLength); +// +// //userID 要接受钥匙的用户的useid 20 +// int userIDLength = utf8.encode(userID!).length; +// // print("userIDLength:$userIDLength utf8.encode(userID!)${utf8.encode(userID!)}"); +// data.addAll(utf8.encode(userID!)); +// data = getFixedLengthList(data, 20 - userIDLength); +// +// if ((data.length % 16) != 0) { +// int add = (16 - data.length % 16); +// for (int i = 0; i < add; i++) { +// data.add(0); +// } +// } +// print("${commandType!.typeName} SM4Data:$data"); +// // 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864 +// ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB); +// return ebcData; +// } +// } +// +// class GetLockStatuReply extends Reply { +// GetLockStatuReply.parseData(CommandType commandType, List dataDetail) +// : super.parseData(commandType, dataDetail) { +// data = dataDetail; +// +// int status = data[2]; +// errorWithStstus(status); +// switch(status){ +// case 0x00: +// //成功 +// var softVersion = data.sublist(3, 7); +// // print("softVersion:$softVersion"); +// +// var power = data[7]; +// // print("power:$power"); +// +// // APP 用户数量 +// var appUserCount = data.sublist(50, 53); +// // print("appUserCount:$appUserCount"); +// +// // 黑名单用户数量 +// var blacklistCount = data[53]; +// // print("blacklistCount:$blacklistCount"); +// +// // 蓝牙钥匙数量 +// var bleKeyCount = data[54]; +// // print("bleKeyCount:$bleKeyCount"); +// +// // 剩余可添加用户数量 +// var remainCount = data.sublist(54, 56); +// // print("remainCount:$remainCount"); +// +// // 未上传开锁记录数量 +// var notUploadCount = data.sublist(56, 58); +// // print("notUploadCount:$notUploadCount"); +// +// // 已设置开门密码数量 +// var pwdCount = data[58]; +// // print("pwdCount:$pwdCount"); +// +// // 已设置开门指纹数量 +// var fingerprintCount = data[59]; +// // print("fingerprintCount:$fingerprintCount"); +// +// // 锁当前时间 +// var lockTime = data.sublist(60, 64); +// // print("lockTime:$lockTime"); +// +// // 硬件版本信息,为固件升级提供判断依据 +// var hardVersion = data.sublist(64, 68); +// // print("hardVersion:$hardVersion"); +// break; +// case 0x06: +// //无权限 +// print("${commandType.typeValue} 需要鉴权"); +// +// break; +// case 0x07: +// //无权限 +// print("${commandType.typeValue} 用户无权限"); +// +// break; +// case 0x09: +// // 权限校验错误 +// print("${commandType.typeValue} 权限校验错误"); +// +// break; +// default: +// //失败 +// print("${commandType.typeValue} 领锁失败"); +// +// break; +// } +// } +// } \ No newline at end of file diff --git a/star_lock/lib/blue/io_protocol/io_getPrivateKey.dart b/star_lock/lib/blue/io_protocol/io_getPrivateKey.dart index 5862925d..1a557625 100644 --- a/star_lock/lib/blue/io_protocol/io_getPrivateKey.dart +++ b/star_lock/lib/blue/io_protocol/io_getPrivateKey.dart @@ -1,9 +1,10 @@ + import 'dart:convert'; +import 'package:get/get.dart'; import 'package:star_lock/blue/blue_manage.dart'; import 'package:star_lock/blue/sm4Encipher/sm4.dart'; -import '../io_tool/io_manager.dart'; import '../io_tool/io_tool.dart'; import '../io_reply.dart'; import '../io_sender.dart'; @@ -106,7 +107,8 @@ class GetPrivateKeyCommand extends SenderProtocol { data.add(0); } } - print("${commandType!.typeName} SM4Data:$data"); + + Get.log("${commandType!.typeName} SM4Data:$data"); // 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864 ebcData = SM4.encrypt(data, key: utf8.encode(BlueManage().connectDeviceName), mode: SM4CryptoMode.ECB); diff --git a/star_lock/lib/blue/io_protocol/io_getPublicKey.dart b/star_lock/lib/blue/io_protocol/io_getPublicKey.dart index d0091bd8..9eb97822 100644 --- a/star_lock/lib/blue/io_protocol/io_getPublicKey.dart +++ b/star_lock/lib/blue/io_protocol/io_getPublicKey.dart @@ -1,6 +1,8 @@ import 'dart:convert'; import 'dart:typed_data'; +import 'package:get/get.dart'; + import '../../tools/storage.dart'; import '../io_tool/io_manager.dart'; import '../io_tool/io_tool.dart'; @@ -30,11 +32,10 @@ class GetPublicKeyCommand extends SenderProtocol { // print("type1:$type1"); // print("type2:$type2"); - print("lockID:${lockID!} lockID.utf8.encode${utf8.encode(lockID!)}"); + Get.log("lockID:${lockID!} lockID.utf8.encode${utf8.encode(lockID!)}"); int length = utf8.encode(lockID!).length; data.addAll(utf8.encode(lockID!)); data = getFixedLengthList(data, 40 - length); - // print("dataaaaaa:$data"); return data; } } diff --git a/star_lock/lib/blue/io_protocol/io_getStarLockStatusInfo.dart b/star_lock/lib/blue/io_protocol/io_getStarLockStatusInfo.dart index 852e88e2..304e57c9 100644 --- a/star_lock/lib/blue/io_protocol/io_getStarLockStatusInfo.dart +++ b/star_lock/lib/blue/io_protocol/io_getStarLockStatusInfo.dart @@ -1,6 +1,8 @@ import 'dart:convert'; +import 'package:get/get.dart'; + import '../io_reply.dart'; import '../io_sender.dart'; import '../io_tool/io_tool.dart'; @@ -33,13 +35,11 @@ class GetStarLockStatuInfoCommand extends SenderProtocol { // 锁id 40 int lockIDLength = utf8.encode(lockID!).length; - // print("addUserLockIDLength:$lockIDLength utf8.encode(lockID!)${utf8.encode(lockID!)}"); data.addAll(utf8.encode(lockID!)); data = getFixedLengthList(data, 40 - lockIDLength); //userID 要接受钥匙的用户的useid 20 int userIDLength = utf8.encode(userID!).length; - // print("userIDLength:$userIDLength utf8.encode(userID!)${utf8.encode(userID!)}"); data.addAll(utf8.encode(userID!)); data = getFixedLengthList(data, 20 - userIDLength); @@ -49,7 +49,8 @@ class GetStarLockStatuInfoCommand extends SenderProtocol { data.add(0); } } - print("${commandType!.typeName} SM4Data:$data"); + + Get.log("${commandType!.typeName} SM4Data:$data"); // 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864 ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB); return ebcData; @@ -62,84 +63,6 @@ class GetStarLockStatuInfoReply extends Reply { data = dataDetail; int status = data[2]; - switch(status){ - case 0x00: - //成功 - // print("${commandType.typeValue} 数据解析成功"); - - // // 厂商名称 - // var vendor = data.sublist(3, 23); - // // print("softVersion:$softVersion"); - // - // // 锁设备类型 - // var product = data[23]; - // // print("product:product"); - // - // // 产品名称 - // var model = data.sublist(24, 44); - // // print("model:model"); - // - // // 软件版本 - // var fwVersion = data.sublist(44, 64); - // // print("fwVersion:fwVersion"); - // - // // 硬件版本 - // var hwVersion = data.sublist(64, 84); - // // print("hwVersion:hwVersion"); - // - // // 厂商序列号 - // var serialNum0 = data.sublist(84, 100); - // // print("serialNum0:serialNum0"); - // - // // 成品商序列号 - // var serialNum1 = data.sublist(100, 116); - // // print("serialNum1:serialNum1"); - // - // // 蓝牙名称 - // var btDeviceName = data.sublist(116, 132); - // // print("btDeviceName:btDeviceName"); - // - // // 电池剩余电量 - // var battRemCap = data[132]; - // // print("battRemCap:battRemCap"); - // - // // 重置次数 - // var restoreCounter = data.sublist(133, 134); - // // print("restoreCounter:restoreCounter"); - // - // // 重置时间 - // var restoreDate = data.sublist(134, 138); - // // print("restoreDate:restoreDate"); - // - // // 主控芯片型号 - // var icPartNo = data.sublist(138, 148); - // // print("icPartNo:icPartNo"); - // - // // 有效时间 - // var indate = data.sublist(148, 152); - // // print("indate:indate"); - - break; - case 0x06: - //无权限 - print("${commandType.typeValue} 需要鉴权"); - - break; - case 0x07: - //无权限 - print("${commandType.typeValue} 用户无权限"); - - break; - case 0x09: - // 权限校验错误 - print("${commandType.typeValue} 权限校验错误"); - - break; - default: - //失败 - print("${commandType.typeValue} 领锁失败"); - - break; - } + errorWithStstus(status); } } \ No newline at end of file diff --git a/star_lock/lib/blue/io_protocol/io_getWifiList.dart b/star_lock/lib/blue/io_protocol/io_getWifiList.dart index 17cbbc3b..12210576 100644 --- a/star_lock/lib/blue/io_protocol/io_getWifiList.dart +++ b/star_lock/lib/blue/io_protocol/io_getWifiList.dart @@ -1,6 +1,8 @@ import 'dart:convert'; +import 'package:get/get.dart'; + import '../io_reply.dart'; import '../io_sender.dart'; import '../io_tool/io_tool.dart'; @@ -74,8 +76,6 @@ class SenderGetWifiCommand extends SenderProtocol { authCodeData.addAll(publicKey!); - print("${commandType!.typeValue}-authCodeData:$authCodeData"); - // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode var authCode = crypto.md5.convert(authCodeData); @@ -92,7 +92,8 @@ class SenderGetWifiCommand extends SenderProtocol { data.add(0); } } - print("${commandType!.typeName} SM4Data:$data"); + + Get.log("${commandType!.typeName} SM4Data:$data"); // 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864 ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB); return ebcData; @@ -103,6 +104,8 @@ class SenderGetWifiReply extends Reply { SenderGetWifiReply.parseData(CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { data = dataDetail; + int status = data[2]; + errorWithStstus(status); } } diff --git a/star_lock/lib/blue/io_protocol/io_openLock.dart b/star_lock/lib/blue/io_protocol/io_openLock.dart index 27b53e75..b250bc0a 100644 --- a/star_lock/lib/blue/io_protocol/io_openLock.dart +++ b/star_lock/lib/blue/io_protocol/io_openLock.dart @@ -1,5 +1,7 @@ import 'dart:convert'; +import 'package:get/get.dart'; + import '../io_tool/io_tool.dart'; import '../sm4Encipher/sm4.dart'; import '../io_reply.dart'; @@ -50,7 +52,6 @@ class OpenLockCommand extends SenderProtocol { //userID 要接受钥匙的用户的useid 20 int userIDLength = utf8.encode(userID!).length; - print("openDoorUserId:${utf8.encode(userID!)} utf8.encode(userID!).length:${utf8.encode(userID!).length}"); data.addAll(utf8.encode(userID!)); data = getFixedLengthList(data, 20 - userIDLength); @@ -93,10 +94,8 @@ class OpenLockCommand extends SenderProtocol { } //onlineToken 16 - print("onlineToken:$onlineToken"); if(onlineToken!.isNotEmpty){ int onlineTokenLength = utf8.encode(onlineToken!).length; - print("openDoorOnlineToken:${utf8.encode(onlineToken!)} utf8.encode(onlineToken!).length:${utf8.encode(onlineToken!).length}"); data.addAll(utf8.encode(onlineToken!)); data = getFixedLengthList(data, 16 - onlineTokenLength); } @@ -107,7 +106,8 @@ class OpenLockCommand extends SenderProtocol { data.add(0); } } - print("${commandType!.typeName} SM4Data:$data"); + + Get.log("${commandType!.typeName} SM4Data:$data"); // 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864 ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB); return ebcData; @@ -118,5 +118,7 @@ class OpenDoorReply extends Reply { OpenDoorReply.parseData(CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { data = dataDetail; + int status = data[6]; + errorWithStstus(status); } } \ No newline at end of file diff --git a/star_lock/lib/blue/io_protocol/io_queryingFaceStatus.dart b/star_lock/lib/blue/io_protocol/io_queryingFaceStatus.dart index ed7836ba..b9389706 100644 --- a/star_lock/lib/blue/io_protocol/io_queryingFaceStatus.dart +++ b/star_lock/lib/blue/io_protocol/io_queryingFaceStatus.dart @@ -1,6 +1,8 @@ //TODO:查询人脸状态 import 'dart:convert'; +import 'package:get/get.dart'; + import '../io_reply.dart'; import '../io_sender.dart'; import '../io_tool/io_tool.dart'; @@ -84,8 +86,6 @@ class SenderQueryingFaceStatusCommand extends SenderProtocol { authCodeData.addAll(publicKey!); - print("${commandType!.typeValue}-authCodeData:$authCodeData"); - // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode var authCode = crypto.md5.convert(authCodeData); @@ -102,8 +102,8 @@ class SenderQueryingFaceStatusCommand extends SenderProtocol { data.add(0); } } - print("${commandType!.typeName} SM4Data:$data"); - // 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864 + + Get.log("${commandType!.typeName} SM4Data:$data"); ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB); return ebcData; } @@ -114,5 +114,7 @@ class SenderQueryingFaceStatusReply extends Reply { CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { data = dataDetail; + int status = data[2]; + errorWithStstus(status); } } diff --git a/star_lock/lib/blue/io_protocol/io_queryingFingerprintStatus.dart b/star_lock/lib/blue/io_protocol/io_queryingFingerprintStatus.dart index 49a51bf0..73038965 100644 --- a/star_lock/lib/blue/io_protocol/io_queryingFingerprintStatus.dart +++ b/star_lock/lib/blue/io_protocol/io_queryingFingerprintStatus.dart @@ -2,6 +2,8 @@ //TODO:查询指纹状态 import 'dart:convert'; +import 'package:get/get.dart'; + import '../io_reply.dart'; import '../io_sender.dart'; import '../io_tool/io_tool.dart'; @@ -86,8 +88,6 @@ class SenderQueryingFingerprintStatusCommand extends SenderProtocol { authCodeData.addAll(publicKey!); - print("${commandType!.typeValue}-authCodeData:$authCodeData"); - // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode var authCode = crypto.md5.convert(authCodeData); @@ -104,7 +104,8 @@ class SenderQueryingFingerprintStatusCommand extends SenderProtocol { data.add(0); } } - print("${commandType!.typeName} SM4Data:$data"); + + Get.log("${commandType!.typeName} SM4Data:$data"); // 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864 ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB); return ebcData; @@ -115,5 +116,7 @@ class SenderQueryingFingerprintStatusReply extends Reply { SenderQueryingFingerprintStatusReply.parseData(CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { data = dataDetail; + int status = data[2]; + errorWithStstus(status); } } \ No newline at end of file diff --git a/star_lock/lib/blue/io_protocol/io_readAdminPassword.dart b/star_lock/lib/blue/io_protocol/io_readAdminPassword.dart index aa72c7d3..2a86bab3 100644 --- a/star_lock/lib/blue/io_protocol/io_readAdminPassword.dart +++ b/star_lock/lib/blue/io_protocol/io_readAdminPassword.dart @@ -1,6 +1,8 @@ import 'dart:convert'; +import 'package:get/get.dart'; + import '../io_tool/io_tool.dart'; import '../sm4Encipher/sm4.dart'; import '../io_reply.dart'; @@ -88,8 +90,6 @@ class SenderReadAdminPasswordCommand extends SenderProtocol { authCodeData.addAll(publicKey!); - print("${commandType!.typeValue}-authCodeData:$authCodeData"); - // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode var authCode = crypto.md5.convert(authCodeData); @@ -106,7 +106,8 @@ class SenderReadAdminPasswordCommand extends SenderProtocol { data.add(0); } } - print("${commandType!.typeName} SM4Data:$data"); + + Get.log("${commandType!.typeName} SM4Data:$data"); // 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864 ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB); return ebcData; @@ -117,5 +118,8 @@ class SenderReadAdminPasswordReply extends Reply { SenderReadAdminPasswordReply.parseData(CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { data = dataDetail; + + int status = data[2]; + errorWithStstus(status); } } diff --git a/star_lock/lib/blue/io_protocol/io_readSupportFunctionsNoParameters.dart b/star_lock/lib/blue/io_protocol/io_readSupportFunctionsNoParameters.dart index af029cdc..f478ec76 100644 --- a/star_lock/lib/blue/io_protocol/io_readSupportFunctionsNoParameters.dart +++ b/star_lock/lib/blue/io_protocol/io_readSupportFunctionsNoParameters.dart @@ -1,6 +1,8 @@ import 'dart:convert'; +import 'package:get/get.dart'; + import '../io_reply.dart'; import '../io_sender.dart'; import '../io_tool/io_tool.dart'; @@ -79,8 +81,6 @@ class ReadSupportFunctionsNoParametersCommand extends SenderProtocol { authCodeData.addAll(publicKey!); - print("${commandType!.typeValue}-authCodeData:$authCodeData"); - // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode var authCode = crypto.md5.convert(authCodeData); @@ -97,7 +97,8 @@ class ReadSupportFunctionsNoParametersCommand extends SenderProtocol { data.add(0); } } - print("${commandType!.typeName} SM4Data:$data"); + + Get.log("${commandType!.typeName} SM4Data:$data"); // 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864 ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB); return ebcData; @@ -108,5 +109,7 @@ class ReadSupportFunctionsNoParametersReply extends Reply { ReadSupportFunctionsNoParametersReply.parseData(CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { data = dataDetail; + int status = data[2]; + errorWithStstus(status); } } \ No newline at end of file diff --git a/star_lock/lib/blue/io_protocol/io_readSupportFunctionsWithParameters.dart b/star_lock/lib/blue/io_protocol/io_readSupportFunctionsWithParameters.dart index ac40a161..e91549cb 100644 --- a/star_lock/lib/blue/io_protocol/io_readSupportFunctionsWithParameters.dart +++ b/star_lock/lib/blue/io_protocol/io_readSupportFunctionsWithParameters.dart @@ -1,6 +1,8 @@ import 'dart:convert'; +import 'package:get/get.dart'; + import '../io_reply.dart'; import '../io_sender.dart'; import '../io_tool/io_tool.dart'; @@ -79,8 +81,6 @@ class ReadSupportFunctionsWithParametersCommand extends SenderProtocol { authCodeData.addAll(publicKey!); - print("${commandType!.typeValue}-authCodeData:$authCodeData"); - // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode var authCode = crypto.md5.convert(authCodeData); @@ -97,7 +97,8 @@ class ReadSupportFunctionsWithParametersCommand extends SenderProtocol { data.add(0); } } - print("${commandType!.typeName} SM4Data:$data"); + + Get.log("${commandType!.typeName} SM4Data:$data"); // 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864 ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB); return ebcData; @@ -108,5 +109,7 @@ class ReadSupportFunctionsWithParametersReply extends Reply { ReadSupportFunctionsWithParametersReply.parseData(CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { data = dataDetail; + int status = data[2]; + errorWithStstus(status); } } \ No newline at end of file diff --git a/star_lock/lib/blue/io_protocol/io_referEventRecordNumber.dart b/star_lock/lib/blue/io_protocol/io_referEventRecordNumber.dart index fb907e2a..0cd45589 100644 --- a/star_lock/lib/blue/io_protocol/io_referEventRecordNumber.dart +++ b/star_lock/lib/blue/io_protocol/io_referEventRecordNumber.dart @@ -2,6 +2,8 @@ //TODO:查询事件记录(序号、数量查询) import 'dart:convert'; +import 'package:get/get.dart'; + import '../io_reply.dart'; import '../io_sender.dart'; import '../io_tool/io_tool.dart'; @@ -47,7 +49,6 @@ class SenderReferEventRecordNumberCommand extends SenderProtocol { // 子命令类型 data.add(40); - print("timeType:${40}"); // keyID 40 int keyIDLength = utf8.encode(keyID!).length; @@ -85,8 +86,6 @@ class SenderReferEventRecordNumberCommand extends SenderProtocol { authCodeData.addAll(publicKey!); - print("${commandType!.typeValue}-authCodeData:$authCodeData"); - // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode var authCode = crypto.md5.convert(authCodeData); @@ -103,7 +102,8 @@ class SenderReferEventRecordNumberCommand extends SenderProtocol { data.add(0); } } - print("${commandType!.typeName} SM4Data:$data"); + + Get.log("${commandType!.typeName} SM4Data:$data"); // 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864 ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB); return ebcData; @@ -114,5 +114,7 @@ class SenderReferEventRecordNumberReply extends Reply { SenderReferEventRecordNumberReply.parseData(CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { data = dataDetail; + int status = data[2]; + errorWithStstus(status); } } \ No newline at end of file diff --git a/star_lock/lib/blue/io_protocol/io_referEventRecordTime.dart b/star_lock/lib/blue/io_protocol/io_referEventRecordTime.dart index a9c9230e..e8f84cb7 100644 --- a/star_lock/lib/blue/io_protocol/io_referEventRecordTime.dart +++ b/star_lock/lib/blue/io_protocol/io_referEventRecordTime.dart @@ -2,6 +2,8 @@ //TODO:查询事件记录(时间查询) import 'dart:convert'; +import 'package:get/get.dart'; + import '../io_reply.dart'; import '../io_sender.dart'; import '../io_tool/io_tool.dart'; @@ -47,7 +49,7 @@ class SenderReferEventRecordTimeCommand extends SenderProtocol { // 子命令类型 data.add(41); - print("timeType:${41}"); + // keyID 40 int keyIDLength = utf8.encode(keyID!).length; subData.addAll(utf8.encode(keyID!)); @@ -87,8 +89,6 @@ class SenderReferEventRecordTimeCommand extends SenderProtocol { authCodeData.addAll(publicKey!); - print("${commandType!.typeValue}-authCodeData:$authCodeData"); - // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode var authCode = crypto.md5.convert(authCodeData); @@ -105,7 +105,8 @@ class SenderReferEventRecordTimeCommand extends SenderProtocol { data.add(0); } } - print("${commandType!.typeName} SM4Data:$data"); + + Get.log("${commandType!.typeName} SM4Data:$data"); // 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864 ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB); return ebcData; @@ -116,5 +117,7 @@ class SenderReferEventRecordTimeReply extends Reply { SenderReferEventRecordTimeReply.parseData(CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { data = dataDetail; + int status = data[2]; + errorWithStstus(status); } } \ No newline at end of file diff --git a/star_lock/lib/blue/io_protocol/io_senderCustomPasswords.dart b/star_lock/lib/blue/io_protocol/io_senderCustomPasswords.dart index 85cf3bb8..aae0abad 100644 --- a/star_lock/lib/blue/io_protocol/io_senderCustomPasswords.dart +++ b/star_lock/lib/blue/io_protocol/io_senderCustomPasswords.dart @@ -1,6 +1,8 @@ import 'dart:convert'; +import 'package:get/get.dart'; + import '../io_tool/io_tool.dart'; import '../sm4Encipher/sm4.dart'; import '../io_reply.dart'; @@ -46,8 +48,6 @@ class SenderCustomPasswordsCommand extends SenderProtocol { List subData = []; List ebcData = []; - print("pwdNopwdNopwdNopwdNo:$pwdNo"); - // 指令类型 int type = commandType!.typeValue; double typeDouble = type / 256; @@ -115,8 +115,6 @@ class SenderCustomPasswordsCommand extends SenderProtocol { authCodeData.addAll(signKey!); - print("${commandType!.typeValue}-authCodeData:$authCodeData"); - // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode var authCode = crypto.md5.convert(authCodeData); @@ -133,7 +131,8 @@ class SenderCustomPasswordsCommand extends SenderProtocol { data.add(0); } } - print("${commandType!.typeName} SM4Data:$data"); + + Get.log("${commandType!.typeName} SM4Data:$data"); // 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864 ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB); return ebcData; @@ -144,5 +143,7 @@ class SenderCustomPasswordsReply extends Reply { SenderCustomPasswordsReply.parseData(CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { data = dataDetail; + int status = data[2]; + errorWithStstus(status); } } \ No newline at end of file diff --git a/star_lock/lib/blue/io_protocol/io_setSupportFunctionsNoParameters.dart b/star_lock/lib/blue/io_protocol/io_setSupportFunctionsNoParameters.dart index 84cefd81..5bf5fc3e 100644 --- a/star_lock/lib/blue/io_protocol/io_setSupportFunctionsNoParameters.dart +++ b/star_lock/lib/blue/io_protocol/io_setSupportFunctionsNoParameters.dart @@ -1,6 +1,8 @@ import 'dart:convert'; +import 'package:get/get.dart'; + import '../io_reply.dart'; import '../io_sender.dart'; import '../io_tool/io_tool.dart'; @@ -84,8 +86,6 @@ class SetSupportFunctionsNoParametersCommand extends SenderProtocol { authCodeData.addAll(publicKey!); - print("${commandType!.typeValue}-authCodeData:$authCodeData"); - // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode var authCode = crypto.md5.convert(authCodeData); @@ -102,7 +102,8 @@ class SetSupportFunctionsNoParametersCommand extends SenderProtocol { data.add(0); } } - print("${commandType!.typeName} SM4Data:$data"); + + Get.log("${commandType!.typeName} SM4Data:$data"); // 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864 ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB); return ebcData; @@ -113,5 +114,7 @@ class SetSupportFunctionsNoParametersReply extends Reply { SetSupportFunctionsNoParametersReply.parseData(CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { data = dataDetail; + int status = data[2]; + errorWithStstus(status); } } \ No newline at end of file diff --git a/star_lock/lib/blue/io_protocol/io_setSupportFunctionsWithParameters.dart b/star_lock/lib/blue/io_protocol/io_setSupportFunctionsWithParameters.dart index 33f7dea3..a264a13c 100644 --- a/star_lock/lib/blue/io_protocol/io_setSupportFunctionsWithParameters.dart +++ b/star_lock/lib/blue/io_protocol/io_setSupportFunctionsWithParameters.dart @@ -1,6 +1,8 @@ import 'dart:convert'; +import 'package:get/get.dart'; + import '../io_reply.dart'; import '../io_sender.dart'; import '../io_tool/io_tool.dart'; @@ -89,8 +91,6 @@ class SetSupportFunctionsWithParametersCommand extends SenderProtocol { authCodeData.addAll(publicKey!); - print("${commandType!.typeValue}-authCodeData:$authCodeData"); - // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode var authCode = crypto.md5.convert(authCodeData); @@ -107,7 +107,8 @@ class SetSupportFunctionsWithParametersCommand extends SenderProtocol { data.add(0); } } - print("${commandType!.typeName} SM4Data:$data"); + + Get.log("${commandType!.typeName} SM4Data:$data"); // 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864 ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB); return ebcData; @@ -118,5 +119,7 @@ class SetSupportFunctionsWithParametersReply extends Reply { SetSupportFunctionsWithParametersReply.parseData(CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { data = dataDetail; + int status = data[2]; + errorWithStstus(status); } } \ No newline at end of file diff --git a/star_lock/lib/blue/io_protocol/io_soundSwitchSet.dart b/star_lock/lib/blue/io_protocol/io_soundSwitchSet.dart deleted file mode 100644 index e69de29b..00000000 diff --git a/star_lock/lib/blue/io_protocol/io_timing.dart b/star_lock/lib/blue/io_protocol/io_timing.dart index 05fdb361..1a094af8 100644 --- a/star_lock/lib/blue/io_protocol/io_timing.dart +++ b/star_lock/lib/blue/io_protocol/io_timing.dart @@ -1,5 +1,7 @@ import 'dart:convert'; +import 'package:get/get.dart'; + import '../io_tool/io_tool.dart'; import '../sm4Encipher/sm4.dart'; import '../io_reply.dart'; @@ -46,13 +48,13 @@ class TimingCommand extends SenderProtocol { //userID 要接受钥匙的用户的useid 20 int userIDLength = utf8.encode(userID!).length; - print("openDoorUserId:${utf8.encode(userID!)} utf8.encode(userID!).length:${utf8.encode(userID!).length}"); + Get.log("openDoorUserId:${utf8.encode(userID!)} utf8.encode(userID!).length:${utf8.encode(userID!).length}"); data.addAll(utf8.encode(userID!)); data = getFixedLengthList(data, 20 - userIDLength); // nowTime 4 int? d1 = nowTime; - print("timing d1:$d1"); + Get.log("timing d1:$d1"); data.add((d1! & 0xff000000) >> 24); data.add((d1 & 0xff0000) >> 16); data.add((d1 & 0xff00) >> 8); @@ -64,7 +66,8 @@ class TimingCommand extends SenderProtocol { data.add(0); } } - print("${commandType!.typeName} SM4Data:$data"); + + Get.log("${commandType!.typeName} SM4Data:$data"); ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB); return ebcData; } @@ -74,5 +77,7 @@ class TimingReply extends Reply { TimingReply.parseData(CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { data = dataDetail; + int status = data[2]; + errorWithStstus(status); } } \ No newline at end of file diff --git a/star_lock/lib/blue/io_protocol/io_transferPermissions.dart b/star_lock/lib/blue/io_protocol/io_transferPermissions.dart index 02c5a78c..5ba78ef6 100644 --- a/star_lock/lib/blue/io_protocol/io_transferPermissions.dart +++ b/star_lock/lib/blue/io_protocol/io_transferPermissions.dart @@ -1,6 +1,8 @@ import 'dart:convert'; +import 'package:get/get.dart'; + import '../io_tool/io_tool.dart'; import '../sm4Encipher/sm4.dart'; import '../io_reply.dart'; @@ -96,8 +98,6 @@ class TransferPermissionsCommand extends SenderProtocol { authCodeData.addAll(publicKey!); - print("${commandType!.typeValue}-authCodeData:$authCodeData"); - // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode var authCode = crypto.md5.convert(authCodeData); @@ -111,7 +111,8 @@ class TransferPermissionsCommand extends SenderProtocol { data.add(0); } } - print("${commandType!.typeName} SM4Data:$data"); + + Get.log("${commandType!.typeName} SM4Data:$data"); ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB); return ebcData; } diff --git a/star_lock/lib/blue/io_reply.dart b/star_lock/lib/blue/io_reply.dart index bd63ff10..ec620a5b 100644 --- a/star_lock/lib/blue/io_reply.dart +++ b/star_lock/lib/blue/io_reply.dart @@ -1,4 +1,7 @@ +import 'package:flutter_easyloading/flutter_easyloading.dart'; +import 'package:get/get.dart'; + import 'io_type.dart'; abstract class Reply{ @@ -10,4 +13,117 @@ abstract class Reply{ List data = []; Reply.parseData(this.commandType, List dataDetail); -} \ No newline at end of file + void errorWithStstus(int status){ + Get.log("errorWithStstus status:$status commandType:$commandType"); + switch(status){ + case 0x00: + // 成功 + Get.log("$commandType成功"); + break; + case 0x01: + // 包格式错误 + Get.log("${commandType!.typeName}包格式错误"); + showErrorMessage("包格式错误"); + break; + case 0x02: + // 密码错误 + Get.log("${commandType!.typeName}密码错误"); + showErrorMessage("密码错误"); + break; + case 0x03: + // 网络中断 + Get.log("${commandType!.typeName}网络中断"); + break; + case 0x04: + // 用户未登记 + Get.log("${commandType!.typeName}用户未登记"); + showErrorMessage("用户未登记"); + break; + case 0x05: + // 参数错误 + Get.log("${commandType!.typeName}参数错误"); + break; + case 0x06: + // 需要鉴权 + Get.log("${commandType!.typeName}需要鉴权"); + break; + case 0x07: + // 无权限 + Get.log("${commandType!.typeName}无权限"); + break; + case 0x08: + // 应答超时 + Get.log("${commandType!.typeName}应答超时"); + break; + case 0x09: + // 权限校验错误 + Get.log("${commandType!.typeName}权限校验错误"); + break; + case 0x0a: + // 钥匙不存在 + // showErrorMessage("钥匙不存在"); + Get.log("${commandType!.typeName}钥匙不存在"); + break; + case 0x0b: + // 钥匙过期 + showErrorMessage("钥匙过期"); + Get.log("${commandType!.typeName}钥匙过期"); + break; + case 0x0c: + // 钥匙数量已到上限 + showErrorMessage("钥匙数量已到上限"); + Get.log("${commandType!.typeName}钥匙数量已到上限"); + break; + case 0x0d: + // 钥匙无效 + showErrorMessage("钥匙无效"); + Get.log("${commandType!.typeName}钥匙无效"); + break; + case 0x0e: + // 钥匙已存在 + showErrorMessage("钥匙已存在"); + Get.log("${commandType!.typeName}钥匙无效"); + break; + case 0x0f: + // 用户已存在 + Get.log("${commandType!.typeName}用户已存在"); + showErrorMessage("用户已存在"); + break; + case 0x10: + // 密码失效 + Get.log("${commandType!.typeName}密码失效"); + showErrorMessage("密码失效"); + break; + case 0x11: + // 无效指令 + Get.log("${commandType!.typeName}无效指令"); + break; + case 0x12: + // 门锁时间异常 + Get.log("${commandType!.typeName}门锁时间异常"); + break; + case 0x15: + // APP(手机)未联网 + Get.log("${commandType!.typeName}APP(手机)未联网"); + showErrorMessage("APP(手机)未联网"); + break; + case 0x16: + // 正在开锁中... + Get.log("${commandType!.typeName}正在开锁中..."); + showErrorMessage("正在开锁中..."); + break; + case 0xff: + // 异常,未知错误 + Get.log("${commandType!.typeName} 0xff"); + break; + default: + //失败 + Get.log("蓝牙返回其他错误问题"); + break; + } + } + + void showErrorMessage(String message){ + EasyLoading.showToast(message, duration: 2000.milliseconds); + } +} diff --git a/star_lock/lib/blue/io_type.dart b/star_lock/lib/blue/io_type.dart index 7ddd0c1f..4b919584 100644 --- a/star_lock/lib/blue/io_type.dart +++ b/star_lock/lib/blue/io_type.dart @@ -9,11 +9,36 @@ enum CommandType { readLockStatusInfo, //读取锁状态信息 = 0x300A transferPermissions, //转移权限 = 0x300B reportDoorOpenRecord, //开门记录上报 = 0x3020 - generalExtendedCommond, // 通用扩展指令 = 0x3030 getLockPublicKey, // 获取锁公钥 = 0x3090 getLockPrivateKey, // 获取锁私钥 = 0x3091 calibrationTime, // 校时 = 0x30f0 readStarLockStatusInfo, //读星锁状态信息 0x3040 + + generalExtendedCommond, // 通用扩展指令 = 0x3030 + gecChangeAdministratorPassword, // 通用扩展指令子命令-修改管理员密码 = 2 + gecSenderCustomPasswords, // 通用扩展指令子命令-设置开锁密码 = 3 + gecAutomaticPadlock, // 通用扩展指令子命令-自动落锁开关 = 4 + gecCheckingUserInfoCount, // 通用扩展指令子命令-查询用户、指纹、密码、卡片数量(用于判断是否同步) = 15 + gecCheckingCardStatus, // 通用扩展指令子命令-同步用户信息 = 20 + gecAddICCardConfirmation, // 通用扩展指令子命令-添加IC卡确认 = 22 + gecAddICCardWithTimeCycleCoercion, // 通用扩展指令子命令-添加IC卡开始 = 24 + gecQueryingFingerprintStatus, // 通用扩展指令子命令-查询指纹状态 = 30 + gecAddFingerprintConfirmation, // 通用扩展指令子命令-添加指纹确认 = 32 + gecAddFingerprintProcess, // 通用扩展指令子命令-注册指纹过程 = 33] + gecAddFingerprintWithTimeCycleCoercion, // 通用扩展指令子命令-注册指纹开始(带限时、循环、胁迫...) = 36 + gecReferEventRecordNumber, // 通用扩展指令子命令-事件查询记录 = 40 + gecReferEventRecordTime, // 通用扩展指令子命令-时间条件查询事件记录 = 41 + gecConfiguringWifi, // 通用扩展指令子命令-wifi配网结果 = 51 + gecGetWifiList, // 通用扩展指令子命令-门锁搜索2.4G WIFI SSID 结果 = 54 + gecAddStressPassword, // 通用扩展指令子命令-添加胁迫密码 = 60 + gecSetSupportFunctionsNoParameters, // 通用扩展指令子命令-支持的功能(无参数) = 70 + gecReadSupportFunctionsNoParameters, // 通用扩展指令子命令-读取支持的功能(无参数) = 71 + gecSetSupportFunctionsWithParameters, // 通用扩展指令子命令-支持的功能(有参数) = 72 + gecReadSupportFunctionsWithParameters, // 通用扩展指令子命令-读取支持的功能(有参数) = 73 + gecSenderReadAdminPassword, // 通用扩展指令子命令-读取管理员密码 = 74 + gecQueryingFaceStatus, // 通用扩展指令子命令-查询人脸状态 = 80 + gecAddFace, // 通用扩展指令子命令-注册人脸开始 = 82 + gecAddFaceConfirmation, // 通用扩展指令子命令-添加人脸确认 = 84 } extension ExtensionCommandType on CommandType { diff --git a/star_lock/lib/blue/reciver_data.dart b/star_lock/lib/blue/reciver_data.dart index 75b3acc3..7637dda2 100644 --- a/star_lock/lib/blue/reciver_data.dart +++ b/star_lock/lib/blue/reciver_data.dart @@ -158,11 +158,12 @@ class CommandReciverManager { reply = OpenDoorReply.parseData(commandType, data); } break; - case CommandType.readLockStatusInfo: - { - reply = GetLockStatuReply.parseData(commandType, data); - } - break; + // 弃用 + // case CommandType.readLockStatusInfo: + // { + // reply = GetLockStatuReply.parseData(commandType, data); + // } + // break; case CommandType.editUser: { reply = EditUserReply.parseData(commandType, data); @@ -207,12 +208,12 @@ class CommandReciverManager { SenderCustomPasswordsReply.parseData(commandType, data); } break; - case 4: - { - // 自动落锁开关 - reply = AutomaticPadlockReply.parseData(commandType, data); - } - break; + // case 4: + // { + // // 自动落锁开关 + // reply = AutomaticPadlockReply.parseData(commandType, data); + // } + // break; case 15: { // 查询用户、指纹、密码、卡片数量(用于判断是否同步) @@ -291,7 +292,7 @@ class CommandReciverManager { break; case 41: { - // 事件查询记录 + // 时间条件查询事件记录 reply = SenderReferEventRecordTimeReply.parseData( commandType, data); } @@ -312,8 +313,7 @@ class CommandReciverManager { case 53: { // 获取wifilist - reply = - SenderGetWifiReply.parseData(commandType, data); + reply = SenderGetWifiReply.parseData(commandType, data); } break; case 54: @@ -336,13 +336,13 @@ class CommandReciverManager { // SenderAddStressICCardReply.parseData(commandType, data); // } // break; - case 62: - { - // 注册胁迫指纹 - reply = SenderAddStressFingerprintReply.parseData( - commandType, data); - } - break; + // case 62: + // { + // // 注册胁迫指纹 + // reply = SenderAddStressFingerprintReply.parseData( + // commandType, data); + // } + // break; case 70: { // 设置支持功能(不带参数)启用/禁用 diff --git a/star_lock/lib/blue/sender_manage.dart b/star_lock/lib/blue/sender_manage.dart index 46109df0..4cb3214a 100644 --- a/star_lock/lib/blue/sender_manage.dart +++ b/star_lock/lib/blue/sender_manage.dart @@ -188,20 +188,20 @@ class IoSenderManage { callBack: callBack); } - //todo:获取锁状态 - static void senderGetLockStatu( - {String? lockID, - String? userID, - List? privateKey, - CommandSendCallBack? callBack}) { - CommandSenderManager().managerSendData( - command: GetLockStatuCommand( - lockID: lockID, - userID: userID, - privateKey: privateKey, - ), - callBack: callBack); - } + //todo:获取锁状态 弃用 + // static void senderGetLockStatu( + // {String? lockID, + // String? userID, + // List? privateKey, + // CommandSendCallBack? callBack}) { + // CommandSenderManager().managerSendData( + // command: GetLockStatuCommand( + // lockID: lockID, + // userID: userID, + // privateKey: privateKey, + // ), + // callBack: callBack); + // } //todo:获取星锁状态信息 static void senderGetStarLockStatuInfo( @@ -370,8 +370,8 @@ class IoSenderManage { required int? weekRound, required int? startDate, required int? endDate, - required int? startTime, - required int? endTime, + required String? startTime, + required String? endTime, required int? needAuthor, required List? signKey, required List? privateKey, @@ -439,8 +439,8 @@ class IoSenderManage { required int? weekRound, required int? startDate, required int? endDate, - required int? startTime, - required int? endTime, + required String? startTime, + required String? endTime, required int? needAuthor, required List? signKey, required List? privateKey, @@ -751,36 +751,36 @@ class IoSenderManage { } //todo:添加胁迫指纹 - static void senderAddStressFingerprintCommand( - {required String? keyID, - required String? userID, - required int? fingerNo, - required int? fingerType, - required int? useCountLimit, - required List? token, - required int? startTime, - required int? endTime, - required int? needAuthor, - required List? publicKey, - required List? privateKey, - required List? signKey, - CommandSendCallBack? callBack}) { - CommandSenderManager().managerSendData( - command: SenderAddStressFingerprintCommand( - keyID: keyID, - userID: userID, - fingerNo: fingerNo, - fingerType: fingerType, - useCountLimit: useCountLimit, - token: token, - startTime: startTime, - endTime: endTime, - needAuthor: needAuthor, - publicKey: publicKey, - privateKey: privateKey, - signKey: signKey), - callBack: callBack); - } + // static void senderAddStressFingerprintCommand( + // {required String? keyID, + // required String? userID, + // required int? fingerNo, + // required int? fingerType, + // required int? useCountLimit, + // required List? token, + // required int? startTime, + // required int? endTime, + // required int? needAuthor, + // required List? publicKey, + // required List? privateKey, + // required List? signKey, + // CommandSendCallBack? callBack}) { + // CommandSenderManager().managerSendData( + // command: SenderAddStressFingerprintCommand( + // keyID: keyID, + // userID: userID, + // fingerNo: fingerNo, + // fingerType: fingerType, + // useCountLimit: useCountLimit, + // token: token, + // startTime: startTime, + // endTime: endTime, + // needAuthor: needAuthor, + // publicKey: publicKey, + // privateKey: privateKey, + // signKey: signKey), + // callBack: callBack); + // } //todo:添加胁迫卡片 // static void senderAddStressICCardCommand( diff --git a/star_lock/lib/main/lockDetail/card/addCardType/addCardType_logic.dart b/star_lock/lib/main/lockDetail/card/addCardType/addCardType_logic.dart index fd757e91..ad989d33 100644 --- a/star_lock/lib/main/lockDetail/card/addCardType/addCardType_logic.dart +++ b/star_lock/lib/main/lockDetail/card/addCardType/addCardType_logic.dart @@ -60,7 +60,7 @@ class AddCardTypeLogic extends BaseGetXController{ fingerprintType = 4; } - var isCoerced = state.isStressFingerprint.value == false ? "1" : "2"; // 1:非胁迫卡 2:胁迫卡 + // var isCoerced = state.isStressFingerprint.value == false ? "1" : "2"; // 1:非胁迫卡 2:胁迫卡 Get.toNamed(Routers.addICCardPage, arguments: { "lockId": state.lockId.value, "endDate": endDate, @@ -68,7 +68,7 @@ class AddCardTypeLogic extends BaseGetXController{ "cardName": state.nameController.text, "cardNumber": "123456", "cardType": fingerprintType.toString(), - "isCoerced": isCoerced, + "isCoerced": state.isStressFingerprint.value == false ? "1" : "2", "startDate": startDate, "weekDay": state.weekdaysList.value, "fromType": state.fromType.value, diff --git a/star_lock/lib/main/lockDetail/card/addCardType/addCardType_page.dart b/star_lock/lib/main/lockDetail/card/addCardType/addCardType_page.dart index b72c1562..c17cddb9 100644 --- a/star_lock/lib/main/lockDetail/card/addCardType/addCardType_page.dart +++ b/star_lock/lib/main/lockDetail/card/addCardType/addCardType_page.dart @@ -46,7 +46,9 @@ class _AddCardPageState extends State { } state.fromType.value = widget.fromType; - return indexChangeWidget(); + return SingleChildScrollView( + child: indexChangeWidget() + ); } @override diff --git a/star_lock/lib/main/lockDetail/card/addICCard/addICCard_logic.dart b/star_lock/lib/main/lockDetail/card/addICCard/addICCard_logic.dart index f1d50c3b..5dae4cd0 100644 --- a/star_lock/lib/main/lockDetail/card/addICCard/addICCard_logic.dart +++ b/star_lock/lib/main/lockDetail/card/addICCard/addICCard_logic.dart @@ -14,6 +14,7 @@ import '../../../../blue/io_tool/io_tool.dart'; import '../../../../blue/io_tool/manager_event_bus.dart'; import '../../../../blue/sender_manage.dart'; import '../../../../network/api_repository.dart'; +import '../../../../tools/dateTool.dart'; import '../../../../tools/eventBusEventManage.dart'; import '../../../../tools/storage.dart'; import 'addICCard_state.dart'; @@ -68,8 +69,10 @@ class AddICCardLogic extends BaseGetXController{ int index = day % 7; // 将周日的索引转换为 0 weekStr = '${weekStr.substring(0, index)}1${weekStr.substring(index + 1)}'; } - // print("weekStrweekStrweekStr:$weekStr"); + // 倒序 weekStr + weekStr = weekStr.split('').reversed.join(''); int weekRound = int.parse(weekStr, radix: 2); + // print("weekStrweekStrweekStr:$weekStr weekRound:$weekRound"); var token = reply.data.sublist(5, 9); var saveStrList = changeIntListToStringList(token); @@ -85,22 +88,14 @@ class AddICCardLogic extends BaseGetXController{ weekRound:weekRound, // 周循环 startDate: int.parse(state.startDate.value)~/1000, endDate: int.parse(state.endDate.value)~/1000, - startTime:int.parse(state.effectiveDateTime.value)~/1000, - endTime:int.parse(state.failureDateTime.value)~/1000, + startTime:DateTool().dateToHNString(state.effectiveDateTime.value), + endTime:DateTool().dateToHNString(state.failureDateTime.value), needAuthor:1, signKey:signKeyDataList, privateKey:getPrivateKeyList, token: token, ); break; - case 0x07: - //无权限 - Get.log("${reply.commandType!.typeValue} 用户无权限"); - break; - case 0x09: - // 权限校验错误 - Get.log("${reply.commandType!.typeValue} 权限校验错误"); - break; default: //失败 Get.log("${reply.commandType!.typeValue} 失败"); @@ -134,20 +129,6 @@ class AddICCardLogic extends BaseGetXController{ // // 如果是胁迫指纹在 添加完之后以后再调用添加胁迫指纹的 // addICCardData(); // } - break; - case 0x06: - //无权限 - - break; - case 0x07: - //无权限 - Get.log("${reply.commandType!.typeValue} 用户无权限"); - - break; - case 0x09: - // 权限校验错误 - Get.log("${reply.commandType!.typeValue} 权限校验错误"); - break; default: //失败 @@ -225,12 +206,15 @@ class AddICCardLogic extends BaseGetXController{ // List publicKeyDataList = changeStringListToIntList(publicKey!); var weekStr = "00000000"; + print("state.weekDay.value:${state.weekDay.value}"); for (var day in state.weekDay.value) { int index = day % 7; // 将周日的索引转换为 0 weekStr = '${weekStr.substring(0, index)}1${weekStr.substring(index + 1)}'; } - // print("weekStrweekStrweekStr:$weekStr"); + // 倒序 weekStr + weekStr = weekStr.split('').reversed.join(''); int weekRound = int.parse(weekStr, radix: 2); + // print("weekStrweekStrweekStr:$weekStr weekRound:$weekRound"); var signKey = await Storage.getStringList(saveBlueSignKey); List signKeyDataList = changeStringListToIntList(signKey!); @@ -247,31 +231,18 @@ class AddICCardLogic extends BaseGetXController{ userID:await Storage.getUid(), cardNo:state.isAdministrator.value == "2" ? 254 : 1, useCountLimit:0xff, - isForce:state.isCoerced.value == "1" ? 0 : 1, // 是否是胁迫 + isForce:state.isCoerced.value == "2" ? 1 : 0, // 是否是胁迫 isRound:state.selectType.value == "2" ? 1: 0, // 是否是循环 weekRound:weekRound, // 周循环 startDate: int.parse(state.startDate.value)~/1000, endDate: int.parse(state.endDate.value)~/1000, - startTime:int.parse(state.effectiveDateTime.value)~/1000, - endTime:int.parse(state.failureDateTime.value)~/1000, + startTime:DateTool().dateToHNString(state.effectiveDateTime.value), + endTime:DateTool().dateToHNString(state.failureDateTime.value), needAuthor:1, signKey:signKeyDataList, privateKey:getPrivateKeyList, token: getTokenList, ); - - // IoSenderManage.senderAddICCardCommand( - // keyID:"1", - // userID:await Storage.getUid(), - // cardNo:state.isAdministrator.value == "2" ? 254 : 1, - // useCountLimit:0xff, - // startTime:int.parse(state.startDate.value)~/1000, - // endTime:int.parse(state.endDate.value)~/1000, - // needAuthor:1, - // signKey:signKeyDataList, - // privateKey:getPrivateKeyList, - // token: getTokenList, - // ); } else if (deviceConnectionState == BluetoothConnectionState.disconnected){ if(state.ifCurrentScreen.value == true){ showBlueConnetctToast(); diff --git a/star_lock/lib/main/lockDetail/card/cardDetail/cardDetail_logic.dart b/star_lock/lib/main/lockDetail/card/cardDetail/cardDetail_logic.dart index b67716d6..9d467b62 100644 --- a/star_lock/lib/main/lockDetail/card/cardDetail/cardDetail_logic.dart +++ b/star_lock/lib/main/lockDetail/card/cardDetail/cardDetail_logic.dart @@ -69,22 +69,14 @@ class CardDetailLogic extends BaseGetXController{ weekRound:0, // 周循环 startDate: 0x11223344, endDate: 0x11223344, - startTime:0x11223344, - endTime:0x11223344, + startTime:"0", + endTime:"0", needAuthor:1, signKey:signKeyDataList, privateKey:getPrivateKeyList, token: getTokenList, ); break; - case 0x07: - //无权限 - Get.log("${reply.commandType!.typeValue} 用户无权限"); - break; - case 0x09: - // 权限校验错误 - Get.log("${reply.commandType!.typeValue} 权限校验错误"); - break; default: //失败 Get.log("${reply.commandType!.typeValue} 失败"); @@ -128,8 +120,8 @@ class CardDetailLogic extends BaseGetXController{ weekRound:0, // 周循环 startDate: 0x11223344, endDate: 0x11223344, - startTime:0x11223344, - endTime:0x11223344, + startTime:"0", + endTime:"0", needAuthor:1, signKey:signKeyDataList, privateKey:getPrivateKeyList, diff --git a/star_lock/lib/main/lockDetail/card/cardList/cardList_logic.dart b/star_lock/lib/main/lockDetail/card/cardList/cardList_logic.dart index 0055e0c8..b6b501d1 100644 --- a/star_lock/lib/main/lockDetail/card/cardList/cardList_logic.dart +++ b/star_lock/lib/main/lockDetail/card/cardList/cardList_logic.dart @@ -46,7 +46,6 @@ class CardListLogic extends BaseGetXController { // 添加卡片开始(此处用作删除卡片) Future _replyAddICCardBegin(Reply reply) async { int status = reply.data[2]; - Get.log("_replyAddFingerprintStatus:$status"); switch(status){ case 0x00: @@ -82,22 +81,14 @@ class CardListLogic extends BaseGetXController { weekRound:0, // 周循环 startDate: 0x11223344, endDate: 0x11223344, - startTime:0x11223344, - endTime:0x11223344, + startTime:"0", + endTime:"0", needAuthor:1, signKey:signKeyDataList, privateKey:getPrivateKeyList, token: token, ); break; - case 0x07: - //无权限 - Get.log("${reply.commandType!.typeValue} 用户无权限"); - break; - case 0x09: - // 权限校验错误 - Get.log("${reply.commandType!.typeValue} 权限校验错误"); - break; default: //失败 Get.log("${reply.commandType!.typeValue} 失败"); @@ -186,17 +177,9 @@ class CardListLogic extends BaseGetXController { // _getLockStatus(); break; case 0x06: - //无权限 + //需要鉴权 Get.log("${reply.commandType}需要鉴权"); break; - case 0x07: - //无权限 - Get.log("${reply.commandType}用户无权限"); - break; - case 0x09: - // 权限校验错误 - Get.log("${reply.commandType}权限校验错误"); - break; default: //失败 Get.log("${reply.commandType}失败"); @@ -289,8 +272,8 @@ class CardListLogic extends BaseGetXController { weekRound:0, // 周循环 startDate: 0x11223344, endDate: 0x11223344, - startTime:0x11223344, - endTime:0x11223344, + startTime:"0", + endTime:"0", needAuthor:1, signKey:signKeyDataList, privateKey:getPrivateKeyList, diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_logic.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_logic.dart index c9e3da2c..7b176b1c 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_logic.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_logic.dart @@ -72,17 +72,17 @@ class KeyOperationRecordLogic extends BaseGetXController { int status = reply.data[2]; switch (status) { case 0x00: - //成功 - print("${reply.commandType}数据解析成功"); + //成功 + Get.log("${reply.commandType}数据解析成功"); if (reply.data[5] > 0) { reply.data.removeRange(0, 6); // 把得到的数据按8位分割成数组 然后塞进一个新的数组里面 var getList = splitList(reply.data, 8); - print("getList:$getList"); + // print("getList:$getList"); var uploadList = []; for (int i = 0; i < getList.length; i++) { var indexList = getList[i]; - print("indexList:$indexList"); + // print("indexList:$indexList"); var indexMap = {}; indexMap["seq"] = indexList[0].toString(); indexMap["user"] = indexList[3].toString(); @@ -105,24 +105,11 @@ class KeyOperationRecordLogic extends BaseGetXController { } break; case 0x06: - //无权限 + //无权限 print("${reply.commandType}需要鉴权"); - break; - case 0x07: - //无权限 - print("${reply.commandType}用户无权限"); - - break; - case 0x09: - // 权限校验错误 - print("${reply.commandType}权限校验错误"); - break; default: - //失败 - print("${reply.commandType}失败"); - break; } } @@ -156,8 +143,7 @@ class KeyOperationRecordLogic extends BaseGetXController { // 查询事件记录(时间查询) Future senderReferEventRecordTime(int time) async { - BlueManage().bludSendData(BlueManage().connectDeviceName, - (BluetoothConnectionState state) async { + BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState state) async { if (state == BluetoothConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); diff --git a/star_lock/lib/main/lockDetail/fingerprint/addFingerprint/addFingerprint_logic.dart b/star_lock/lib/main/lockDetail/fingerprint/addFingerprint/addFingerprint_logic.dart index 3bcf8af0..031be367 100644 --- a/star_lock/lib/main/lockDetail/fingerprint/addFingerprint/addFingerprint_logic.dart +++ b/star_lock/lib/main/lockDetail/fingerprint/addFingerprint/addFingerprint_logic.dart @@ -5,6 +5,7 @@ import 'dart:async'; import 'package:flutter_blue_plus/flutter_blue_plus.dart'; import 'package:get/get.dart'; import 'package:star_lock/blue/io_type.dart'; +import 'package:star_lock/tools/dateTool.dart'; import '../../../../../blue/blue_manage.dart'; // import '../../../../../blue/io_protocol/io_addFingerprint.dart'; @@ -43,15 +44,15 @@ class AddFingerprintLogic extends BaseGetXController { } // 添加胁迫指纹 - if(reply is SenderAddStressFingerprintReply) { - _replyAddStressFingerprint(reply); - } + // if(reply is SenderAddStressFingerprintReply) { + // _replyAddStressFingerprint(reply); + // } }); } Future _replyAddFingerprintBegin(Reply reply) async { int status = reply.data[2]; - Get.log("status:$status"); + // Get.log("status:$status"); switch(status){ case 0x00: @@ -77,7 +78,6 @@ class AddFingerprintLogic extends BaseGetXController { List signKeyDataList = changeStringListToIntList(signKey!); var token = reply.data.sublist(5, 9); - print("tokentokentokentoken:$token"); var saveStrList = changeIntListToStringList(token); Storage.setStringList(saveBlueToken, saveStrList); @@ -86,7 +86,8 @@ class AddFingerprintLogic extends BaseGetXController { int index = day % 7; // 将周日的索引转换为 0 weekStr = '${weekStr.substring(0, index)}1${weekStr.substring(index + 1)}'; } - // print("weekStrweekStrweekStr:$weekStr"); + // 倒序 weekStr + weekStr = weekStr.split('').reversed.join(''); int weekRound = int.parse(weekStr, radix: 2); IoSenderManage.senderAddFingerprintWithTimeCycleCoercionCommand( @@ -99,8 +100,8 @@ class AddFingerprintLogic extends BaseGetXController { weekRound:weekRound, // 周循环 startDate: int.parse(state.startDate.value)~/1000, endDate: int.parse(state.endDate.value)~/1000, - startTime:int.parse(state.effectiveDateTime.value)~/1000, - endTime:int.parse(state.failureDateTime.value)~/1000, + startTime:DateTool().dateToHNString(state.effectiveDateTime.value), + endTime:DateTool().dateToHNString(state.failureDateTime.value), needAuthor:1, signKey:signKeyDataList, privateKey:getPrivateKeyList, @@ -154,14 +155,6 @@ class AddFingerprintLogic extends BaseGetXController { case 0x06: //需要权限 break; - case 0x07: - //无权限 - Get.log("${reply.commandType!.typeValue} 用户无权限"); - break; - case 0x09: - // 权限校验错误 - Get.log("${reply.commandType!.typeValue} 权限校验错误"); - break; default: //失败 Get.log("${reply.commandType!.typeValue} 失败"); @@ -193,14 +186,6 @@ class AddFingerprintLogic extends BaseGetXController { case 0x06: //需要权限 break; - case 0x07: - //无权限 - Get.log("${reply.commandType!.typeValue} 用户无权限"); - break; - case 0x09: - // 权限校验错误 - Get.log("${reply.commandType!.typeValue} 权限校验错误"); - break; default: //失败 Get.log("${reply.commandType!.typeValue} 失败"); @@ -208,61 +193,61 @@ class AddFingerprintLogic extends BaseGetXController { } } - Future _replyAddStressFingerprint(Reply reply) async { - int status = reply.data[2]; - Get.log("status:$status"); - - switch(status){ - case 0x00: - //成功 - Get.log("${reply.commandType!.typeValue} 数据解析成功"); - // print("添加指纹确认成功,调用添加指纹接口"); - addFingerprintsData(); - break; - case 0x06: - //需要权限 - var privateKey = await Storage.getStringList(saveBluePrivateKey); - List getPrivateKeyList = changeStringListToIntList(privateKey!); - - var publicKey = await Storage.getStringList(saveBluePublicKey); - List publicKeyDataList = changeStringListToIntList(publicKey!); - - var signKey = await Storage.getStringList(saveBlueSignKey); - List getSignKeyList = changeStringListToIntList(signKey!); - - var token = reply.data.sublist(5, 9); - var saveStrList = changeIntListToStringList(token); - Storage.setStringList(saveBlueToken, saveStrList); - - IoSenderManage.senderAddStressFingerprintCommand( - keyID:"1", - userID:await Storage.getUid(), - fingerNo:state.isAdministrator.value == "2" ? 254 : 1, - fingerType:1, - useCountLimit:1, - startTime:int.parse(state.startDate.value)~/1000, - endTime:int.parse(state.endDate.value)~/1000, - needAuthor:1, - publicKey:publicKeyDataList, - privateKey:getPrivateKeyList, - token: token, - signKey: getSignKeyList - ); - break; - case 0x07: - //无权限 - Get.log("${reply.commandType!.typeValue} 用户无权限"); - break; - case 0x09: - // 权限校验错误 - Get.log("${reply.commandType!.typeValue} 权限校验错误"); - break; - default: - //失败 - Get.log("${reply.commandType!.typeValue} 失败"); - break; - } - } + // Future _replyAddStressFingerprint(Reply reply) async { + // int status = reply.data[2]; + // Get.log("status:$status"); + // + // switch(status){ + // case 0x00: + // //成功 + // Get.log("${reply.commandType!.typeValue} 数据解析成功"); + // // print("添加指纹确认成功,调用添加指纹接口"); + // addFingerprintsData(); + // break; + // case 0x06: + // //需要权限 + // var privateKey = await Storage.getStringList(saveBluePrivateKey); + // List getPrivateKeyList = changeStringListToIntList(privateKey!); + // + // var publicKey = await Storage.getStringList(saveBluePublicKey); + // List publicKeyDataList = changeStringListToIntList(publicKey!); + // + // var signKey = await Storage.getStringList(saveBlueSignKey); + // List getSignKeyList = changeStringListToIntList(signKey!); + // + // var token = reply.data.sublist(5, 9); + // var saveStrList = changeIntListToStringList(token); + // Storage.setStringList(saveBlueToken, saveStrList); + // + // IoSenderManage.senderAddStressFingerprintCommand( + // keyID:"1", + // userID:await Storage.getUid(), + // fingerNo:state.isAdministrator.value == "2" ? 254 : 1, + // fingerType:1, + // useCountLimit:1, + // startTime:int.parse(state.startDate.value)~/1000, + // endTime:int.parse(state.endDate.value)~/1000, + // needAuthor:1, + // publicKey:publicKeyDataList, + // privateKey:getPrivateKeyList, + // token: token, + // signKey: getSignKeyList + // ); + // break; + // case 0x07: + // //无权限 + // Get.log("${reply.commandType!.typeValue} 用户无权限"); + // break; + // case 0x09: + // // 权限校验错误 + // Get.log("${reply.commandType!.typeValue} 权限校验错误"); + // break; + // default: + // //失败 + // Get.log("${reply.commandType!.typeValue} 失败"); + // break; + // } + // } // 添加指纹开始 Future senderAddFingerprint() async { @@ -280,8 +265,10 @@ class AddFingerprintLogic extends BaseGetXController { int index = day % 7; // 将周日的索引转换为 0 weekStr = '${weekStr.substring(0, index)}1${weekStr.substring(index + 1)}'; } - // print("weekStrweekStrweekStr:$weekStr"); + // 倒序 weekStr + weekStr = weekStr.split('').reversed.join(''); int weekRound = int.parse(weekStr, radix: 2); + // Get.log("weekStrweekStrweekStr:$weekStr weekRound:$weekRound"); var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); @@ -292,19 +279,19 @@ class AddFingerprintLogic extends BaseGetXController { var token = await Storage.getStringList(saveBlueToken); List getTokenList = changeStringListToIntList(token!); - Get.log("state.isAdministrator.value:${state.isAdministrator.value}"); + Get.log("state.isCoerced.value:${state.isCoerced.value}"); IoSenderManage.senderAddFingerprintWithTimeCycleCoercionCommand( keyID:"1", userID:await Storage.getUid(), fingerNo:state.isAdministrator.value == "2" ? 254 : 1, useCountLimit:0xff, - isForce:state.isCoerced.value == "1" ? 0 : 1, // 是否是胁迫 + isForce:state.isCoerced.value == "2" ? 1 : 0, // 是否是胁迫 isRound:state.selectType.value == "2" ? 1: 0, // 是否是循环 weekRound:weekRound, // 周循环 startDate: int.parse(state.startDate.value)~/1000, endDate: int.parse(state.endDate.value)~/1000, - startTime:int.parse(state.effectiveDateTime.value)~/1000, - endTime:int.parse(state.failureDateTime.value)~/1000, + startTime:DateTool().dateToHNString(state.effectiveDateTime.value), + endTime:DateTool().dateToHNString(state.failureDateTime.value), needAuthor:1, signKey:signKeyDataList, privateKey:getPrivateKeyList, @@ -360,38 +347,38 @@ class AddFingerprintLogic extends BaseGetXController { } // 添加胁迫指纹 - Future senderAddStressFingerprint() async { - BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { - if (deviceConnectionState == BluetoothConnectionState.connected){ - var publicKey = await Storage.getStringList(saveBluePublicKey); - List publicKeyDataList = changeStringListToIntList(publicKey!); - - var privateKey = await Storage.getStringList(saveBluePrivateKey); - List getPrivateKeyList = changeStringListToIntList(privateKey!); - - var signKey = await Storage.getStringList(saveBlueSignKey); - List getSignKeyList = changeStringListToIntList(signKey!); - - var token = await Storage.getStringList(saveBlueToken); - List getTokenList = changeStringListToIntList(token!); - - IoSenderManage.senderAddStressFingerprintCommand( - keyID:"1", - userID:await Storage.getUid(), - fingerNo:state.isAdministrator.value == "2" ? 254 : 1, - fingerType:1, - useCountLimit:1, - startTime:int.parse(state.startDate.value)~/1000, - endTime:int.parse(state.endDate.value)~/1000, - needAuthor:1, - publicKey:publicKeyDataList, - privateKey:getPrivateKeyList, - token: getTokenList, - signKey: getSignKeyList - ); - } - }); - } + // Future senderAddStressFingerprint() async { + // BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { + // if (deviceConnectionState == BluetoothConnectionState.connected){ + // var publicKey = await Storage.getStringList(saveBluePublicKey); + // List publicKeyDataList = changeStringListToIntList(publicKey!); + // + // var privateKey = await Storage.getStringList(saveBluePrivateKey); + // List getPrivateKeyList = changeStringListToIntList(privateKey!); + // + // var signKey = await Storage.getStringList(saveBlueSignKey); + // List getSignKeyList = changeStringListToIntList(signKey!); + // + // var token = await Storage.getStringList(saveBlueToken); + // List getTokenList = changeStringListToIntList(token!); + // + // IoSenderManage.senderAddStressFingerprintCommand( + // keyID:"1", + // userID:await Storage.getUid(), + // fingerNo:state.isAdministrator.value == "2" ? 254 : 1, + // fingerType:1, + // useCountLimit:1, + // startTime:int.parse(state.startDate.value)~/1000, + // endTime:int.parse(state.endDate.value)~/1000, + // needAuthor:1, + // publicKey:publicKeyDataList, + // privateKey:getPrivateKeyList, + // token: getTokenList, + // signKey: getSignKeyList + // ); + // } + // }); + // } // 添加指纹 void addFingerprintsData() async{ diff --git a/star_lock/lib/main/lockDetail/fingerprint/addFingerprint/addFingerprint_state.dart b/star_lock/lib/main/lockDetail/fingerprint/addFingerprint/addFingerprint_state.dart index e3b439d9..c25fbcbc 100644 --- a/star_lock/lib/main/lockDetail/fingerprint/addFingerprint/addFingerprint_state.dart +++ b/star_lock/lib/main/lockDetail/fingerprint/addFingerprint/addFingerprint_state.dart @@ -40,7 +40,9 @@ class AddFingerprintState{ weekDay.value = map["weekDay"]; fromType.value = map["fromType"]; effectiveDateTime.value = map["effectiveTime"]; + Get.log("effectiveDateTime.value:${effectiveDateTime.value}"); failureDateTime.value = map["failureTime"]; + Get.log("failureDateTime.value:${failureDateTime.value}"); selectType.value = map["selectType"]; } } \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_logic.dart b/star_lock/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_logic.dart index fbd1415d..9d1aca91 100644 --- a/star_lock/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_logic.dart +++ b/star_lock/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_logic.dart @@ -59,8 +59,8 @@ class AddFingerprintTypeLogic extends BaseGetXController{ fingerprintType = 4; } - var isCoerced = state.isStressFingerprint.value == false ? "1" : "2"; // 1:非胁迫指纹 2:胁迫指纹 - Get.log("addOtherType startDate:$startDate endDate:$endDate isCoerced:$isCoerced"); + // var isCoerced = state.isStressFingerprint.value == false ? "1" : "2"; // 1:非胁迫指纹 2:胁迫指纹 + // Get.log("addOtherType startDate:$startDate endDate:$endDate isCoerced:$isCoerced"); // 指纹 Get.toNamed(Routers.addFingerprintPage, arguments: { @@ -70,7 +70,7 @@ class AddFingerprintTypeLogic extends BaseGetXController{ "fingerprintName": state.nameController.text, "fingerprintNumber": "123456", "fingerprintType": fingerprintType.toString(), - "isCoerced": isCoerced, // 1:非胁迫指纹 2:胁迫指纹 + "isCoerced": state.isStressFingerprint.value == false ? "1" : "2", // 1:非胁迫指纹 2:胁迫指纹 "startDate": startDate, "weekDay": state.weekdaysList.value, "fromType": state.fromType.value, diff --git a/star_lock/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_page.dart b/star_lock/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_page.dart index 95e5c6f9..425bb1d4 100644 --- a/star_lock/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_page.dart +++ b/star_lock/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_page.dart @@ -62,7 +62,9 @@ class _AddFingerprintTypePageState extends State { } state.fromType.value = widget.fromType; - return indexChangeWidget(); + return SingleChildScrollView( + child: indexChangeWidget() + ); } Widget indexChangeWidget() { @@ -415,6 +417,7 @@ class _AddFingerprintTypePageState extends State { value: state.isStressFingerprint.value, onChanged: (value) { state.isStressFingerprint.value = value; + // Get.log("state.isStressFingerprint.value:${state.isStressFingerprint.value}"); }, ); } diff --git a/star_lock/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_logic.dart b/star_lock/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_logic.dart index 62924f6e..0cb7ec9d 100644 --- a/star_lock/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_logic.dart +++ b/star_lock/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_logic.dart @@ -35,7 +35,7 @@ class FingerprintDetailLogic extends BaseGetXController{ Future _replyAddFingerprintBegin(Reply reply) async { int status = reply.data[2]; - Get.log("status:$status"); + // Get.log("status:$status"); switch(status){ case 0x00: @@ -71,22 +71,14 @@ class FingerprintDetailLogic extends BaseGetXController{ weekRound:0, // 周循环 startDate: 0x11223344, endDate: 0x11223344, - startTime:0x11223344, - endTime:0x11223344, + startTime:"0", + endTime:"0", needAuthor:1, signKey:signKeyDataList, privateKey:getPrivateKeyList, token: getTokenList, ); break; - case 0x07: - //无权限 - Get.log("${reply.commandType!.typeValue} 用户无权限"); - break; - case 0x09: - // 权限校验错误 - Get.log("${reply.commandType!.typeValue} 权限校验错误"); - break; default: //失败 Get.log("${reply.commandType!.typeValue} 失败"); @@ -130,8 +122,8 @@ class FingerprintDetailLogic extends BaseGetXController{ weekRound:0, // 周循环 startDate: 0x11223344, endDate: 0x11223344, - startTime:0x11223344, - endTime:0x11223344, + startTime:"0", + endTime:"0", needAuthor:1, signKey:signKeyDataList, privateKey:getPrivateKeyList, diff --git a/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_logic.dart b/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_logic.dart index 939cc133..c1cf4b1b 100644 --- a/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_logic.dart +++ b/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_logic.dart @@ -46,7 +46,7 @@ class FingerprintListLogic extends BaseGetXController{ // 添加指纹开始---这里用作删除指纹 Future _replyAddFingerprintBegin(Reply reply) async { int status = reply.data[2]; - Get.log("status:$status"); + // Get.log("status:$status"); switch(status){ case 0x00: @@ -95,23 +95,13 @@ class FingerprintListLogic extends BaseGetXController{ weekRound:0, // 周循环 startDate: 0x11223344, endDate: 0x11223344, - startTime:0x11223344, - endTime:0x11223344, + startTime:"0", + endTime:"0", needAuthor:1, signKey:signKeyDataList, privateKey:getPrivateKeyList, token: getTokenList, ); - break; - case 0x07: - //无权限 - Get.log("${reply.commandType!.typeValue} 用户无权限"); - - break; - case 0x09: - // 权限校验错误 - Get.log("${reply.commandType!.typeValue} 权限校验错误"); - break; default: //失败 @@ -124,32 +114,19 @@ class FingerprintListLogic extends BaseGetXController{ // 获取指纹状态 Future _replyQueryingFingerprintStatus(Reply reply) async { int status = reply.data[2]; - switch(status){ case 0x00: - //成功 + //成功 Get.log("${reply.commandType}数据解析成功"); - // _getLockStatus(); + break; case 0x06: - //无权限 + //需要鉴权 Get.log("${reply.commandType}需要鉴权"); - - break; - case 0x07: - //无权限 - Get.log("${reply.commandType}用户无权限"); - - break; - case 0x09: - // 权限校验错误 - Get.log("${reply.commandType}权限校验错误"); - break; default: - //失败 - print("${reply.commandType}失败"); - + //失败 + Get.log("${reply.commandType}失败"); break; } } @@ -242,14 +219,6 @@ class FingerprintListLogic extends BaseGetXController{ //无权限 Get.log("${reply.commandType}需要鉴权"); break; - case 0x07: - //无权限 - Get.log("${reply.commandType}用户无权限"); - break; - case 0x09: - // 权限校验错误 - Get.log("${reply.commandType}权限校验错误"); - break; default: //失败 Get.log("${reply.commandType}失败"); @@ -341,8 +310,8 @@ class FingerprintListLogic extends BaseGetXController{ weekRound:0, // 周循环 startDate: 0x11223344, endDate: 0x11223344, - startTime:0x11223344, - endTime:0x11223344, + startTime:"0", + endTime:"0", needAuthor:1, signKey:signKeyDataList, privateKey:getPrivateKeyList, diff --git a/star_lock/lib/main/lockDetail/iris/irisList/irisList_logic.dart b/star_lock/lib/main/lockDetail/iris/irisList/irisList_logic.dart index 772ca294..4e02d739 100644 --- a/star_lock/lib/main/lockDetail/iris/irisList/irisList_logic.dart +++ b/star_lock/lib/main/lockDetail/iris/irisList/irisList_logic.dart @@ -219,19 +219,9 @@ class IrisListLogic extends BaseGetXController { // _getLockStatus(); break; case 0x06: - //无权限 + //需要鉴权 print("${reply.commandType}需要鉴权"); - break; - case 0x07: - //无权限 - print("${reply.commandType}用户无权限"); - - break; - case 0x09: - // 权限校验错误 - print("${reply.commandType}权限校验错误"); - break; default: //失败 diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart index 586253e5..650c5760 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart @@ -66,7 +66,6 @@ class LockDetailLogic extends BaseGetXController { // 开门数据解析 Future _replyOpenLock(Reply reply) async { int status = reply.data[6]; - Get.log("replyOpenLock status:$status"); switch (status) { case 0x00: @@ -353,16 +352,6 @@ class LockDetailLogic extends BaseGetXController { privateKey: getPrivateKeyList, token: token); break; - case 0x07: - //无权限 - Get.log("用户无权限"); - - break; - case 0x09: - // 权限校验错误 - Get.log("添加用户权限校验错误"); - - break; default: //失败 Get.log("领锁失败"); @@ -378,6 +367,21 @@ class LockDetailLogic extends BaseGetXController { eventBus.fire(RefreshLockDetailInfoDataEvent()); }); + // var listData = AddUserCommand( + // lockID: BlueManage().connectDeviceName, + // authUserID: state.senderUserId.toString(), + // keyID: state.keyInfos.value.keyId.toString(), + // userID: await Storage.getUid(), + // openMode: 1, + // keyType: 0, + // startDate: state.keyInfos.value.startDate!~/10000, + // expireDate: state.keyInfos.value.endDate!~/10000, + // role: state.keyInfos.value.keyRight == 1 ? 1 : 0, + // password: "123456", + // needAuthor: 1, + // publicKey: publicKeyDataList, + // privateKey: getPrivateKeyList, + // token: getTokenList).packageData(); BlueManage().bludSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected) { // 私钥 @@ -409,8 +413,7 @@ class LockDetailLogic extends BaseGetXController { publicKey: publicKeyDataList, privateKey: getPrivateKeyList, token: getTokenList); - } else if (deviceConnectionState == - BluetoothConnectionState.disconnected) { + } else if (deviceConnectionState == BluetoothConnectionState.disconnected) { cancelBlueConnetctToastTimer(); if (state.ifCurrentScreen.value == true) { showBlueConnetctToast(); @@ -438,19 +441,6 @@ class LockDetailLogic extends BaseGetXController { var token = await Storage.getStringList(saveBlueToken); List getTokenList = changeStringListToIntList(token!); - // print("调用了开锁事件 openDoorTokenPubToken:$getTokenList getPrivateKeyList:$getPrivateKeyList"); - // ListlistData = await IoSenderManage.senderOpenLock( - // keyID: BlueManage().connectDeviceName, - // userID: await Storage.getUid(), - // openMode: openMode, - // openTime: DateTime.now().millisecondsSinceEpoch ~/ 1000, - // onlineToken: state.lockNetToken, - // token: getTokenList, - // needAuthor: 1, - // signKey: signKeyDataList, - // privateKey: getPrivateKeyList, - // ); - Get.log("openMode:${state.openDoorModel}"); BlueManage().bludSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected) { diff --git a/star_lock/lib/main/lockDetail/lockSet/automaticBlocking/automaticBlocking_logic.dart b/star_lock/lib/main/lockDetail/lockSet/automaticBlocking/automaticBlocking_logic.dart index 7f144aec..7ecad0e7 100644 --- a/star_lock/lib/main/lockDetail/lockSet/automaticBlocking/automaticBlocking_logic.dart +++ b/star_lock/lib/main/lockDetail/lockSet/automaticBlocking/automaticBlocking_logic.dart @@ -113,19 +113,8 @@ class AutomaticBlockingLogic extends BaseGetXController{ break; case 0x06: //无权限 - Get.log("${reply.commandType}需要鉴权"); - break; - case 0x07: - //无权限 - Get.log("${reply.commandType}用户无权限"); - break; - case 0x09: - // 权限校验错误 - Get.log("${reply.commandType}权限校验错误"); break; default: - //失败 - Get.log("${reply.commandType}失败"); break; } } diff --git a/star_lock/lib/main/lockDetail/lockSet/basicInformation/adminOpenLockPassword/adminOpenLockPassword_logic.dart b/star_lock/lib/main/lockDetail/lockSet/basicInformation/adminOpenLockPassword/adminOpenLockPassword_logic.dart index 4e1c12b3..5f10b31c 100644 --- a/star_lock/lib/main/lockDetail/lockSet/basicInformation/adminOpenLockPassword/adminOpenLockPassword_logic.dart +++ b/star_lock/lib/main/lockDetail/lockSet/basicInformation/adminOpenLockPassword/adminOpenLockPassword_logic.dart @@ -76,20 +76,8 @@ class AdminOpenLockPasswordLogic extends BaseGetXController{ 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; } } @@ -152,17 +140,8 @@ class AdminOpenLockPasswordLogic extends BaseGetXController{ privateKey: getPrivateKeyList ); break; - case 0x07: - //无权限 - Get.log("${reply.commandType!.typeValue} 用户无权限"); - break; - case 0x09: - // 权限校验错误 - Get.log("${reply.commandType!.typeValue} 权限校验错误"); - break; default: //失败 - Get.log("${reply.commandType!.typeValue} 失败"); break; } } diff --git a/star_lock/lib/main/lockDetail/lockSet/basicInformation/basicInformation/basicInformation_page.dart b/star_lock/lib/main/lockDetail/lockSet/basicInformation/basicInformation/basicInformation_page.dart index c01b707e..48860815 100644 --- a/star_lock/lib/main/lockDetail/lockSet/basicInformation/basicInformation/basicInformation_page.dart +++ b/star_lock/lib/main/lockDetail/lockSet/basicInformation/basicInformation/basicInformation_page.dart @@ -143,6 +143,19 @@ class _BasicInformationPageState extends State { }); }), )), + Obx(() => Visibility( + visible: state.lockBasicInfo.value.lockName!.contains("T9A"), + child: CommonItem( + leftTitel: "当前网络", + rightTitle: state.lockBasicInfo.value.lockName ?? "", + allHeight: 70.h, + isHaveLine: true), + )), + Obx(() => CommonItem( + leftTitel: "位置信息", + rightTitle: state.lockBasicInfo.value.lockName ?? "", + allHeight: 70.h, + isHaveLine: true)), /* 2024-01-12 会议确定去掉“微信二维码” by DaisyWu CommonItem( leftTitel: diff --git a/star_lock/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_logic.dart b/star_lock/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_logic.dart index 7217ad33..f793b9e5 100644 --- a/star_lock/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_logic.dart +++ b/star_lock/lib/main/lockDetail/lockSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_logic.dart @@ -106,14 +106,14 @@ class UploadElectricQuantityLogic extends BaseGetXController { case 0x06: //无权限 Get.log("${reply.commandType}需要鉴权"); - break; - case 0x07: - //无权限 - Get.log("${reply.commandType}用户无权限"); - break; - case 0x09: - // 权限校验错误 - Get.log("${reply.commandType}权限校验错误"); + + var privateKey = await Storage.getStringList(saveBluePrivateKey); + List getPrivateKeyList = changeStringListToIntList(privateKey!); + IoSenderManage.senderGetStarLockStatuInfo( + lockID: BlueManage().connectDeviceName, + userID: await Storage.getUid(), + privateKey: getPrivateKeyList, + ); break; default: //失败 diff --git a/star_lock/lib/main/lockDetail/lockSet/burglarAlarm/burglarAlarm_logic.dart b/star_lock/lib/main/lockDetail/lockSet/burglarAlarm/burglarAlarm_logic.dart index f728397e..9666bd36 100644 --- a/star_lock/lib/main/lockDetail/lockSet/burglarAlarm/burglarAlarm_logic.dart +++ b/star_lock/lib/main/lockDetail/lockSet/burglarAlarm/burglarAlarm_logic.dart @@ -96,17 +96,7 @@ class BurglarAlarmLogic extends BaseGetXController{ //无权限 Get.log("${reply.commandType}需要鉴权"); break; - case 0x07: - //无权限 - Get.log("${reply.commandType}用户无权限"); - break; - case 0x09: - // 权限校验错误 - Get.log("${reply.commandType}权限校验错误"); - break; default: - //失败 - Get.log("${reply.commandType}失败"); break; } } @@ -154,32 +144,6 @@ class BurglarAlarmLogic extends BaseGetXController{ }); } - // Timer? _timer; - // // CancelableOperation? _operation; - // void showBlueConnetctToastTimer({bool isShowBlueConnetctToast = true, Function? action}) { - // if (_timer != null && _timer!.isActive) { - // _timer!.cancel(); - // _timer = null; - // } - // _timer = Timer.periodic(15.seconds, (timer) { - // if (action != null) { - // action(); - // } - // cancelBlueConnetctToastTimer(); - // if (isShowBlueConnetctToast == true) { - // showBlueConnetctToast(); - // } - // }); - // } - - // void cancelBlueConnetctToastTimer() { - // Get.log('cancelBlueConnetctToastTimer'); - // if (_timer != null && _timer!.isActive) { - // _timer!.cancel(); - // _timer = null; - // } - // } - @override void onReady() { // TODO: implement onReady diff --git a/star_lock/lib/main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifi_logic.dart b/star_lock/lib/main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifi_logic.dart index c3664e70..416c70c5 100644 --- a/star_lock/lib/main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifi_logic.dart +++ b/star_lock/lib/main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifi_logic.dart @@ -117,14 +117,6 @@ class ConfiguringWifiLogic extends BaseGetXController{ privateKey: getPrivateKeyList, ); - break; - case 0x07: - //无权限 - Get.log("${reply.commandType}用户无权限"); - break; - case 0x09: - // 权限校验错误 - Get.log("${reply.commandType}校验错误"); break; case 0xff: //成功 diff --git a/star_lock/lib/main/lockDetail/lockSet/configuringWifi/wifiList/wifiList_logic.dart b/star_lock/lib/main/lockDetail/lockSet/configuringWifi/wifiList/wifiList_logic.dart index 9db646ed..9e9d217c 100644 --- a/star_lock/lib/main/lockDetail/lockSet/configuringWifi/wifiList/wifiList_logic.dart +++ b/star_lock/lib/main/lockDetail/lockSet/configuringWifi/wifiList/wifiList_logic.dart @@ -46,16 +46,26 @@ class WifiListLogic extends BaseGetXController { }); break; case 0x06: - //无权限 + // 需要鉴权 Get.log("${reply.commandType}需要鉴权"); - break; - case 0x07: - //无权限 - Get.log("${reply.commandType}用户无权限"); - break; - case 0x09: - // 权限校验错误 - Get.log("${reply.commandType}权限校验错误"); + + // var token = await Storage.getStringList(saveBlueToken); + // List getTokenList = changeStringListToIntList(token!); + // + // var privateKey = await Storage.getStringList(saveBluePrivateKey); + // List getPrivateKeyList = changeStringListToIntList(privateKey!); + // + // var publicKey = await Storage.getStringList(saveBluePublicKey); + // List publicKeyDataList = changeStringListToIntList(publicKey!); + // + // IoSenderManage.getWifiListCommand( + // keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(), + // userID: await Storage.getUid(), + // token: getTokenList, + // needAuthor: 1, + // publicKey: publicKeyDataList, + // privateKey: getPrivateKeyList, + // ); break; default: //失败 @@ -95,18 +105,6 @@ class WifiListLogic extends BaseGetXController { // print("reply.data:${reply.data} getList:$getList}"); } - break; - case 0x06: - //无权限 - Get.log("${reply.commandType}需要鉴权"); - break; - case 0x07: - //无权限 - Get.log("${reply.commandType}用户无权限"); - break; - case 0x09: - // 权限校验错误 - Get.log("${reply.commandType}权限校验错误"); break; default: //失败 diff --git a/star_lock/lib/main/lockDetail/lockSet/lockSet/lockSet_logic.dart b/star_lock/lib/main/lockDetail/lockSet/lockSet/lockSet_logic.dart index eb1d2c7c..d45ce630 100644 --- a/star_lock/lib/main/lockDetail/lockSet/lockSet/lockSet_logic.dart +++ b/star_lock/lib/main/lockDetail/lockSet/lockSet/lockSet_logic.dart @@ -120,8 +120,6 @@ class LockSetLogic extends BaseGetXController { Storage.setStringList(saveBlueToken, saveStrList); int status = reply.data[6]; - Get.log("status:$status"); - switch (status) { case 0x00: //成功 @@ -239,23 +237,8 @@ class LockSetLogic extends BaseGetXController { break; case 0x06: //无权限 - Get.log("${reply.commandType}需要鉴权"); - - break; - case 0x07: - //无权限 - Get.log("${reply.commandType}用户无权限"); - - break; - case 0x09: - // 权限校验错误 - Get.log("${reply.commandType}权限校验错误"); - break; default: - //失败 - Get.log("${reply.commandType}失败"); - break; } } diff --git a/star_lock/lib/main/lockDetail/lockSet/lockSoundSet/lockSoundSet_logic.dart b/star_lock/lib/main/lockDetail/lockSet/lockSoundSet/lockSoundSet_logic.dart index 68e4b974..1a84fe16 100644 --- a/star_lock/lib/main/lockDetail/lockSet/lockSoundSet/lockSoundSet_logic.dart +++ b/star_lock/lib/main/lockDetail/lockSet/lockSoundSet/lockSoundSet_logic.dart @@ -101,19 +101,8 @@ class LockSoundSetLogic extends BaseGetXController { break; case 0x06: //无权限 - Get.log("${reply.commandType}需要鉴权"); - break; - case 0x07: - //无权限 - Get.log("${reply.commandType}用户无权限"); - break; - case 0x09: - // 权限校验错误 - Get.log("${reply.commandType}权限校验错误"); break; default: - //失败 - Get.log("${reply.commandType}失败"); break; } } diff --git a/star_lock/lib/main/lockDetail/lockSet/lockTime/lockTime_logic.dart b/star_lock/lib/main/lockDetail/lockSet/lockTime/lockTime_logic.dart index 944a22fb..bebe6310 100644 --- a/star_lock/lib/main/lockDetail/lockSet/lockTime/lockTime_logic.dart +++ b/star_lock/lib/main/lockDetail/lockSet/lockTime/lockTime_logic.dart @@ -58,16 +58,16 @@ class LockTimeLogic extends BaseGetXController{ break; case 0x06: - //无权限 + //需要鉴权 Get.log("${reply.commandType}需要鉴权"); - break; - case 0x07: - //无权限 - Get.log("${reply.commandType}用户无权限"); - break; - case 0x09: - // 权限校验错误 - Get.log("${reply.commandType}权限校验错误"); + + var privateKey = await Storage.getStringList(saveBluePrivateKey); + List getPrivateKeyList = changeStringListToIntList(privateKey!); + IoSenderManage.senderGetStarLockStatuInfo( + lockID: BlueManage().connectDeviceName, + userID: await Storage.getUid(), + privateKey: getPrivateKeyList, + ); break; default: //失败 @@ -82,8 +82,6 @@ class LockTimeLogic extends BaseGetXController{ switch(status){ case 0x00: //成功 - Get.log("${reply.commandType}数据解析成功"); - String dataEime = DateTool().dateToYMDHNString("${state.dateTimestamp.value}"); state.dateTime.value = dataEime; @@ -94,19 +92,8 @@ class LockTimeLogic extends BaseGetXController{ break; case 0x06: //无权限 - Get.log("${reply.commandType}需要鉴权"); - break; - case 0x07: - //无权限 - Get.log("${reply.commandType}用户无权限"); - break; - case 0x09: - // 权限校验错误 - Get.log("${reply.commandType}权限校验错误"); break; default: - //失败 - Get.log("${reply.commandType}失败"); break; } } diff --git a/star_lock/lib/main/lockDetail/lockSet/motorPower/motorPower_logic.dart b/star_lock/lib/main/lockDetail/lockSet/motorPower/motorPower_logic.dart index 7d5a3b28..d20b8457 100644 --- a/star_lock/lib/main/lockDetail/lockSet/motorPower/motorPower_logic.dart +++ b/star_lock/lib/main/lockDetail/lockSet/motorPower/motorPower_logic.dart @@ -84,24 +84,13 @@ class MotorPowerLogic extends BaseGetXController { switch(status){ case 0x00: //成功 - Get.log("${reply.commandType}数据解析成功"); _setLockSetGeneralSetting(); break; case 0x06: //无权限 Get.log("${reply.commandType}需要鉴权"); break; - case 0x07: - //无权限 - Get.log("${reply.commandType}用户无权限"); - break; - case 0x09: - // 权限校验错误 - Get.log("${reply.commandType}权限校验错误"); - break; default: - //失败 - Get.log("${reply.commandType}失败"); break; } } diff --git a/star_lock/lib/main/lockDetail/lockSet/normallyOpenMode/normallyOpenMode_logic.dart b/star_lock/lib/main/lockDetail/lockSet/normallyOpenMode/normallyOpenMode_logic.dart index 1ea1c686..6e925428 100644 --- a/star_lock/lib/main/lockDetail/lockSet/normallyOpenMode/normallyOpenMode_logic.dart +++ b/star_lock/lib/main/lockDetail/lockSet/normallyOpenMode/normallyOpenMode_logic.dart @@ -119,19 +119,8 @@ class NormallyOpenModeLogic extends BaseGetXController{ break; case 0x06: //无权限 - Get.log("${reply.commandType}需要鉴权"); - break; - case 0x07: - //无权限 - Get.log("${reply.commandType}用户无权限"); - break; - case 0x09: - // 权限校验错误 - Get.log("${reply.commandType}权限校验错误"); break; default: - //失败 - Get.log("${reply.commandType}失败"); break; } } @@ -164,6 +153,8 @@ class NormallyOpenModeLogic extends BaseGetXController{ int index = day % 7; // 将周日的索引转换为 0 weekStr = '${weekStr.substring(0, index)}1${weekStr.substring(index + 1)}'; } + // 倒序 weekStr + weekStr = weekStr.split('').reversed.join(''); int number = int.parse(weekStr, radix: 2); List list = []; diff --git a/star_lock/lib/main/lockDetail/lockSet/openDoorDirection/openDoorDirection_logic.dart b/star_lock/lib/main/lockDetail/lockSet/openDoorDirection/openDoorDirection_logic.dart index 14060512..6e237c29 100644 --- a/star_lock/lib/main/lockDetail/lockSet/openDoorDirection/openDoorDirection_logic.dart +++ b/star_lock/lib/main/lockDetail/lockSet/openDoorDirection/openDoorDirection_logic.dart @@ -84,24 +84,12 @@ class OpenDoorDirectionLogic extends BaseGetXController { switch(status){ case 0x00: //成功 - Get.log("${reply.commandType}数据解析成功"); _setLockSetGeneralSetting(); break; case 0x06: //无权限 - Get.log("${reply.commandType}需要鉴权"); - break; - case 0x07: - //无权限 - Get.log("${reply.commandType}用户无权限"); - break; - case 0x09: - // 权限校验错误 - Get.log("${reply.commandType}权限校验错误"); break; default: - //失败 - Get.log("${reply.commandType}失败"); break; } } diff --git a/star_lock/lib/main/lockDetail/lockSet/remoteUnlocking/remoteUnlocking_logic.dart b/star_lock/lib/main/lockDetail/lockSet/remoteUnlocking/remoteUnlocking_logic.dart index 47e5822f..3a948783 100644 --- a/star_lock/lib/main/lockDetail/lockSet/remoteUnlocking/remoteUnlocking_logic.dart +++ b/star_lock/lib/main/lockDetail/lockSet/remoteUnlocking/remoteUnlocking_logic.dart @@ -100,19 +100,9 @@ class RemoteUnlockingLogic extends BaseGetXController { break; case 0x06: //无权限 - Get.log("${reply.commandType}需要鉴权"); - break; - case 0x07: - //无权限 - Get.log("${reply.commandType}用户无权限"); - break; - case 0x09: - // 权限校验错误 - Get.log("${reply.commandType}权限校验错误"); + break; default: - //失败 - Get.log("${reply.commandType}失败"); break; } } diff --git a/star_lock/lib/main/lockDetail/lockSet/resetButton/resetButton_logic.dart b/star_lock/lib/main/lockDetail/lockSet/resetButton/resetButton_logic.dart index 254d16b9..73379d19 100644 --- a/star_lock/lib/main/lockDetail/lockSet/resetButton/resetButton_logic.dart +++ b/star_lock/lib/main/lockDetail/lockSet/resetButton/resetButton_logic.dart @@ -93,19 +93,8 @@ class ResetButtonLogic extends BaseGetXController{ break; case 0x06: //无权限 - Get.log("${reply.commandType}需要鉴权"); - break; - case 0x07: - //无权限 - Get.log("${reply.commandType}用户无权限"); - break; - case 0x09: - // 权限校验错误 - Get.log("${reply.commandType}权限校验错误"); break; default: - //失败 - Get.log("${reply.commandType}失败"); break; } } diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart index ec5d6d0e..73adc26f 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart @@ -200,16 +200,12 @@ class PasswordKeyPerpetualLogic extends BaseGetXController { if (reply is SenderCustomPasswordsReply) { var token = reply.data.sublist(5, 9); var saveStrList = changeIntListToStringList(token); - print("_replyFactoryDataResetKeyToken:$token"); Storage.setStringList(saveBlueToken, saveStrList); int status = reply.data[2]; - print("status:$status"); - switch (status) { case 0x00: //成功 - print("${reply.commandType!.typeValue} 数据解析成功"); state.sureBtnState.value = 0; dismissEasyLoading(); cancelBlueConnetctToastTimer(); @@ -217,7 +213,7 @@ class PasswordKeyPerpetualLogic extends BaseGetXController { break; case 0x06: //无权限 - print("${reply.commandType!.typeValue} 需要鉴权"); + Get.log("${reply.commandType!.typeValue} 需要鉴权"); var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); @@ -239,17 +235,14 @@ class PasswordKeyPerpetualLogic extends BaseGetXController { break; case 0x07: //无权限 - print("${reply.commandType!.typeValue} 用户无权限"); cancelBlueConnetctToastTimer(); break; case 0x09: // 权限校验错误 - print("${reply.commandType!.typeValue} 权限校验错误"); cancelBlueConnetctToastTimer(); break; default: //失败 - print("${reply.commandType!.typeValue} 失败"); cancelBlueConnetctToastTimer(); break; } diff --git a/star_lock/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart b/star_lock/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart index d618407b..62b075c4 100644 --- a/star_lock/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart +++ b/star_lock/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart @@ -143,8 +143,8 @@ class NearbyLockLogic extends BaseGetXController { // 厂商名称 var vendor = reply.data.sublist(3, 23); var vendorStr = utf8String(vendor); - state.lockInfo["vendor"] = vendorStr; - // state.lockInfo["vendor"] = "XL"; + // state.lockInfo["vendor"] = vendorStr; + state.lockInfo["vendor"] = "XL"; Get.log("vendor:$vendor vendorStr:$vendorStr reply.data:${reply.data}"); // 锁设备类型 @@ -286,14 +286,20 @@ class NearbyLockLogic extends BaseGetXController { case 0x06: //无权限 Get.log("${reply.commandType}需要鉴权"); - break; - case 0x07: - //无权限 - Get.log("${reply.commandType}用户无权限"); - break; - case 0x09: - // 权限校验错误 - Get.log("${reply.commandType}权限校验错误"); + + var privateKey = await Storage.getStringList(saveBluePrivateKey); + List getPrivateKeyList = changeStringListToIntList(privateKey!); + // IoSenderManage.senderGetLockStatu( + // lockID:BlueManage().connectDeviceName, + // userID:await Storage.getUid(), + // privateKey:getPrivateKeyList, + // ); + IoSenderManage.senderGetStarLockStatuInfo( + lockID: BlueManage().connectDeviceName, + userID: await Storage.getUid(), + privateKey: getPrivateKeyList, + ); + break; default: //失败 diff --git a/star_lock/lib/mine/addLock/saveLock/saveLock_logic.dart b/star_lock/lib/mine/addLock/saveLock/saveLock_logic.dart index 146d7964..edd1ec73 100644 --- a/star_lock/lib/mine/addLock/saveLock/saveLock_logic.dart +++ b/star_lock/lib/mine/addLock/saveLock/saveLock_logic.dart @@ -47,7 +47,7 @@ class SaveLockLogic extends BaseGetXController { // 添加用户 Future _replyAddUserKey(Reply reply) async { - var lockId = reply.data.sublist(2, 42); + // var lockId = reply.data.sublist(2, 42); var token = reply.data.sublist(42, 46); List strTokenList = changeIntListToStringList(token); @@ -144,17 +144,7 @@ class SaveLockLogic extends BaseGetXController { privateKey: getPrivateKeyList, token: token); break; - case 0x07: - //无权限 - Get.log("${reply.commandType!.typeValue} 用户无权限"); - break; - case 0x09: - // 权限校验错误 - Get.log("${reply.commandType!.typeValue} 权限校验错误"); - break; default: - //失败 - Get.log("${reply.commandType!.typeValue} 失败"); break; } } @@ -198,14 +188,6 @@ class SaveLockLogic extends BaseGetXController { privateKey: getPrivateKeyList, token: token); break; - case 0x07: - // 无权限 - Get.log("${reply.commandType!.typeValue} 用户无权限"); - break; - case 0x09: - // 权限校验错误 - Get.log("${reply.commandType!.typeValue} 权限校验错误"); - break; default: // 失败 Get.log("${reply.commandType!.typeValue} 失败"); diff --git a/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireCard/expireCard_logic.dart b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireCard/expireCard_logic.dart index 61c3bb96..6c11a37b 100644 --- a/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireCard/expireCard_logic.dart +++ b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireCard/expireCard_logic.dart @@ -35,7 +35,6 @@ class ExpireCardLogic extends BaseGetXController { // 添加卡片开始(此处用作删除卡片) Future _replyAddICCardBegin(Reply reply) async { int status = reply.data[2]; - print("_replyAddFingerprintStatus:$status"); switch(status){ case 0x00: @@ -70,8 +69,8 @@ class ExpireCardLogic extends BaseGetXController { weekRound:0, // 周循环 startDate: 0x11223344, endDate: 0x11223344, - startTime:0x11223344, - endTime:0x11223344, + startTime:"0", + endTime:"0", needAuthor:1, signKey:signKeyDataList, privateKey:getPrivateKeyList, @@ -133,8 +132,8 @@ class ExpireCardLogic extends BaseGetXController { weekRound:0, // 周循环 startDate: 0x11223344, endDate: 0x11223344, - startTime:0x11223344, - endTime:0x11223344, + startTime:"0", + endTime:"0", needAuthor:1, signKey:signKeyDataList, privateKey:getPrivateKeyList, diff --git a/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireFingerprint/expireFingerprint_logic.dart b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireFingerprint/expireFingerprint_logic.dart index ea6059bd..e8cb6566 100644 --- a/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireFingerprint/expireFingerprint_logic.dart +++ b/star_lock/lib/mine/mineSet/lockUserManage/expireLockList/expireFingerprint/expireFingerprint_logic.dart @@ -34,9 +34,8 @@ class ExpireFingerprintLogic extends BaseGetXController { // 添加指纹开始 Future _replyAddFingerprintBegin(Reply reply) async { - int status = reply.data[2]; - print("status:$status"); + // print("status:$status"); switch(status){ case 0x00: @@ -72,28 +71,17 @@ class ExpireFingerprintLogic extends BaseGetXController { weekRound:0, // 周循环 startDate: 0x11223344, endDate: 0x11223344, - startTime:0x11223344, - endTime:0x11223344, + startTime:"0", + endTime:"0", needAuthor:1, signKey:signKeyDataList, privateKey:getPrivateKeyList, token: getTokenList, ); - break; - case 0x07: - //无权限 - print("${reply.commandType!.typeValue} 用户无权限"); - - break; - case 0x09: - // 权限校验错误 - print("${reply.commandType!.typeValue} 权限校验错误"); - break; default: - //失败 + //失败 print("${reply.commandType!.typeValue} 失败"); - break; } } @@ -136,8 +124,8 @@ class ExpireFingerprintLogic extends BaseGetXController { weekRound:0, // 周循环 startDate: 0x11223344, endDate: 0x11223344, - startTime:0x11223344, - endTime:0x11223344, + startTime:"0", + endTime:"0", needAuthor:1, signKey:signKeyDataList, privateKey:getPrivateKeyList, diff --git a/star_lock/lib/tools/commonDataManage.dart b/star_lock/lib/tools/commonDataManage.dart new file mode 100644 index 00000000..ab9037b3 --- /dev/null +++ b/star_lock/lib/tools/commonDataManage.dart @@ -0,0 +1,31 @@ + +// 实现一个CommonDataManage的单例,用来管理项目中使用的一些公共数据 +import 'package:get/get.dart'; + +class CommonDataManage { + static CommonDataManage? _manager; + CommonDataManage._init(); + + static CommonDataManage? shareManager() { + _manager ??= CommonDataManage._init(); + // _manager!._initBlue(); + return _manager; + } + + factory CommonDataManage() => shareManager()!; + CommonDataManage? get manager => shareManager(); + + // 首页列表锁长度 + final _mainLockCount = 0.obs; + set setMainLockCount(int v) => _mainLockCount.value = v; + get getMainLockCount => _mainLockCount; + + // 当前锁的用户编号 + int currentLockUserNo = 0; + // set setCurrentLockUserNo(int v) => _currentLockUserNo = v; + // get getCurrentLockUserNo => _currentLockUserNo; + + +} + +