From 2368bb631c460931c76403bb64b3cfb4d4ff4d12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=8F=E5=B0=91=E9=98=B3?= <786612630@qq.com> Date: Tue, 15 Oct 2024 14:24:35 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E5=AE=8C=E6=88=90=E7=BD=91=E5=85=B3?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E5=9B=BD=E9=99=85=E5=8C=96=202=E3=80=81?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E8=93=9D=E7=89=99=E5=8D=8F=E8=AE=AE=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E4=B8=8D=E7=94=A8=E7=9A=84=E8=93=9D=E7=89=99=E5=8D=8F?= =?UTF-8?q?=E8=AE=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lan/lan_en.json | 4 +- lan/lan_keys.json | 4 +- lan/lan_zh.json | 4 +- lib/app_settings/app_style.dart | 188 +++++++++++------- lib/app_settings/app_theme.dart | 2 +- lib/blue/entity/lock_user_no_list_entity.dart | 10 +- lib/blue/io_protocol/io_addCardCancel.dart | 40 ++-- lib/blue/io_protocol/io_addFace.dart | 50 ++--- lib/blue/io_protocol/io_addFaceCancel.dart | 26 +-- .../io_addFaceWithTimeCycleCoercion.dart | 186 ----------------- lib/blue/io_protocol/io_addFingerprint.dart | 148 -------------- .../io_protocol/io_addFingerprintCancel.dart | 30 +-- ...o_addFingerprintWithTimeCycleCoercion.dart | 73 ++++--- lib/blue/io_protocol/io_addICCard.dart | 12 +- .../io_addICCardWithTimeCycleCoercion.dart | 74 +++---- lib/blue/io_protocol/io_addPalmCancel.dart | 14 +- .../io_addPalmWithTimeCycleCoercion.dart | 2 +- .../io_addRemoteControlCancel.dart | 14 +- ...addRemoteControlWithTimeCycleCoercion.dart | 2 +- .../io_protocol/io_addStressFingerprint.dart | 140 ------------- lib/blue/io_protocol/io_addStressICCard.dart | 143 ------------- .../io_protocol/io_addStressPassword.dart | 54 ++--- lib/blue/io_protocol/io_addUser.dart | 86 ++++---- lib/blue/io_protocol/io_automaticPadlock.dart | 79 -------- .../io_changeAdministratorPassword.dart | 51 +++-- .../io_protocol/io_checkingCardStatus.dart | 47 +++-- .../io_protocol/io_checkingUserInfoCount.dart | 51 ++--- lib/blue/io_protocol/io_cleanUpUsers.dart | 61 +++--- lib/blue/io_protocol/io_configuringWifi.dart | 65 +++--- lib/blue/io_protocol/io_deletUser.dart | 58 +++--- lib/blue/io_protocol/io_editUser.dart | 69 ++++--- lib/blue/io_protocol/io_factoryDataReset.dart | 41 ++-- .../io_gateway_configuringWifi.dart | 2 - .../io_protocol/io_gateway_getStatus.dart | 2 - .../io_protocol/io_gateway_getWifiList.dart | 1 - lib/blue/io_protocol/io_getLockStatu.dart | 117 ----------- lib/blue/io_protocol/io_getPrivateKey.dart | 29 +-- lib/blue/io_protocol/io_getWifiList.dart | 44 ++-- lib/blue/io_protocol/io_openLock.dart | 28 +-- lib/blue/io_protocol/io_otaUpgrade.dart | 44 ++-- .../io_protocol/io_processOtaUpgrade.dart | 30 ++- .../io_protocol/io_queryingFaceStatus.dart | 49 ++--- .../io_queryingFingerprintStatus.dart | 50 ++--- .../io_protocol/io_readAdminPassword.dart | 48 +++-- .../io_readSupportFunctionsNoParameters.dart | 44 ++-- ...io_readSupportFunctionsWithParameters.dart | 44 ++-- .../io_referEventRecordNumber.dart | 50 ++--- .../io_protocol/io_referEventRecordTime.dart | 23 ++- .../io_protocol/io_senderCustomPasswords.dart | 35 ++-- .../io_protocol/io_senderResetPasswords.dart | 43 ++-- .../io_setSupportFunctionsNoParameters.dart | 49 +++-- .../io_setSupportFunctionsWithParameters.dart | 48 +++-- lib/blue/io_protocol/io_timing.dart | 27 ++- .../io_protocol/io_transferPermissions.dart | 61 +++--- .../io_protocol/io_transferSmartLock.dart | 18 +- .../io_protocol/io_updataLockCardList.dart | 44 ++-- .../io_protocol/io_updataLockFaceList.dart | 48 ++--- .../io_updataLockFingerprintList.dart | 48 ++--- .../io_updataLockPalmVeinList.dart | 46 ++--- .../io_updataLockPasswordList.dart | 44 ++-- .../io_updataLockRemoteControlList.dart | 8 +- lib/blue/io_sender.dart | 53 +++-- lib/blue/io_tool/io_manager.dart | 10 +- lib/blue/io_tool/io_model.dart | 2 +- lib/blue/io_tool/io_tool.dart | 10 +- lib/blue/io_tool/manager_event_bus.dart | 8 +- lib/blue/io_type.dart | 2 +- lib/blue/reciver_data.dart | 4 +- lib/blue/sender_beforeDataManage.dart | 6 +- lib/blue/sender_data.dart | 4 +- lib/blue/sm4Encipher/sm4.dart | 87 ++++---- lib/blue/sm4Encipher/utils/asn1.dart | 10 +- lib/blue/sm4Encipher/utils/ec.dart | 165 ++++++++------- .../safetyVerification_state.dart | 9 +- .../starLock_forgetPassword_page.dart | 8 +- .../starLock_forgetPassword_xhj_page.dart | 10 +- lib/login/login/starLock_login_binding.dart | 2 - lib/login/login/starLock_login_page.dart | 4 +- .../selectGatewayList_logic.dart | 6 +- .../gatewayConnectionLockList_entity.dart | 81 ++++++++ .../gatewayConnectionLockList_logic.dart | 28 +++ .../gatewayConnectionLockList_page.dart | 57 +++--- .../gatewayConnectionLockList_state.dart | 17 ++ .../gatewayDetail/gatewayDetail_page.dart | 20 +- .../gatewayList/gatewayList_logic.dart | 27 ++- .../gateway/gatewayList/gatewayList_page.dart | 6 +- lib/network/api.dart | 1 + lib/network/api_provider.dart | 4 + lib/network/api_repository.dart | 8 + 89 files changed, 1490 insertions(+), 2111 deletions(-) delete mode 100755 lib/blue/io_protocol/io_addFaceWithTimeCycleCoercion.dart delete mode 100755 lib/blue/io_protocol/io_addFingerprint.dart delete mode 100755 lib/blue/io_protocol/io_addStressFingerprint.dart delete mode 100755 lib/blue/io_protocol/io_addStressICCard.dart delete mode 100755 lib/blue/io_protocol/io_automaticPadlock.dart delete mode 100755 lib/blue/io_protocol/io_getLockStatu.dart create mode 100644 lib/mine/gateway/gatewayConnectionLock/gatewayConnectionLockList_entity.dart create mode 100644 lib/mine/gateway/gatewayConnectionLock/gatewayConnectionLockList_logic.dart create mode 100644 lib/mine/gateway/gatewayConnectionLock/gatewayConnectionLockList_state.dart diff --git a/lan/lan_en.json b/lan/lan_en.json index 02a75423..d0b73a9c 100644 --- a/lan/lan_en.json +++ b/lan/lan_en.json @@ -1082,5 +1082,7 @@ "印度尼西亚语": "Indonesian", "芬兰语": "Finnish", "丹麦语": "Danish", - "重置后,该锁的掌静脉都将被删除哦,确认要重置吗?": "After reset, the metacarpal veins of the lock will be deleted. Are you sure you want to reset?" + "重置后,该锁的掌静脉都将被删除哦,确认要重置吗?": "After reset, the metacarpal veins of the lock will be deleted. Are you sure you want to reset?", + "在线": "Online", + "离线": "Offline" } diff --git a/lan/lan_keys.json b/lan/lan_keys.json index 7af6c17f..94a74acb 100755 --- a/lan/lan_keys.json +++ b/lan/lan_keys.json @@ -1082,5 +1082,7 @@ "印度尼西亚语": "印度尼西亚语", "芬兰语": "芬兰语", "丹麦语": "丹麦语", - "重置后,该锁的掌静脉都将被删除哦,确认要重置吗?": "重置后,该锁的掌静脉都将被删除哦,确认要重置吗?" + "重置后,该锁的掌静脉都将被删除哦,确认要重置吗?": "重置后,该锁的掌静脉都将被删除哦,确认要重置吗?", + "在线": "在线", + "离线": "离线" } diff --git a/lan/lan_zh.json b/lan/lan_zh.json index e651d878..c30f05bb 100755 --- a/lan/lan_zh.json +++ b/lan/lan_zh.json @@ -1082,5 +1082,7 @@ "印度尼西亚语": "印度尼西亚语", "芬兰语": "芬兰语", "丹麦语": "丹麦语", - "重置后,该锁的掌静脉都将被删除哦,确认要重置吗?": "重置后,该锁的掌静脉都将被删除哦,确认要重置吗?" + "重置后,该锁的掌静脉都将被删除哦,确认要重置吗?": "重置后,该锁的掌静脉都将被删除哦,确认要重置吗?", + "在线": "在线", + "离线": "离线" } diff --git a/lib/app_settings/app_style.dart b/lib/app_settings/app_style.dart index 00b9f14f..687acaf6 100755 --- a/lib/app_settings/app_style.dart +++ b/lib/app_settings/app_style.dart @@ -25,140 +25,186 @@ class AppStyle { ///textButtonStyle static ButtonStyle get textButtonStyle => ButtonStyle( - minimumSize: MaterialStateProperty.resolveWith((states) => btnMinSize), - shape: MaterialStateProperty.resolveWith((states) => buttonShape_16), - backgroundColor: MaterialStateProperty.resolveWith((states){ - if(states.contains(MaterialState.disabled)) return AppColors.buttonDisableColor; + minimumSize: MaterialStateProperty.resolveWith((Set states) => btnMinSize), + shape: MaterialStateProperty.resolveWith((Set states) => buttonShape_16), + backgroundColor: MaterialStateProperty.resolveWith((Set states){ + if(states.contains(MaterialState.disabled)) { + return AppColors.buttonDisableColor; + } return AppColors.buttonEnableColor; }), - foregroundColor: MaterialStateProperty.resolveWith((states){ - if(states.contains(MaterialState.disabled)) return AppColors.buttonDisableTextColor; + foregroundColor: MaterialStateProperty.resolveWith((Set states){ + if(states.contains(MaterialState.disabled)) { + return AppColors.buttonDisableTextColor; + } return AppColors.buttonEnableTextColor; }), - textStyle: MaterialStateProperty.resolveWith((states){ - if(states.contains(MaterialState.disabled)) return textStyle(textColor: AppColors.buttonDisableColor); + textStyle: MaterialStateProperty.resolveWith((Set states){ + if(states.contains(MaterialState.disabled)) { + return textStyle(textColor: AppColors.buttonDisableColor); + } return textStyle(); }) ); ///textButtonDeleteStyle static ButtonStyle get textButtonDeleteStyle => ButtonStyle( - minimumSize: MaterialStateProperty.resolveWith((states) => btnMinSize), - shape: MaterialStateProperty.resolveWith((states) => buttonShape_16), - backgroundColor: MaterialStateProperty.resolveWith((states){ - if(states.contains(MaterialState.disabled)) return AppColors.buttonDisableColor; + minimumSize: MaterialStateProperty.resolveWith((Set states) => btnMinSize), + shape: MaterialStateProperty.resolveWith((Set states) => buttonShape_16), + backgroundColor: MaterialStateProperty.resolveWith((Set states){ + if(states.contains(MaterialState.disabled)) { + return AppColors.buttonDisableColor; + } return AppColors.deleteBtnBgColor; }), - foregroundColor: MaterialStateProperty.resolveWith((states){ - if(states.contains(MaterialState.disabled)) return AppColors.buttonDisableTextColor; + foregroundColor: MaterialStateProperty.resolveWith((Set states){ + if(states.contains(MaterialState.disabled)) { + return AppColors.buttonDisableTextColor; + } return AppColors.buttonEnableTextColor; }), - textStyle: MaterialStateProperty.resolveWith((states){ - if(states.contains(MaterialState.disabled)) return textStyle(textColor: AppColors.buttonDisableColor); + textStyle: MaterialStateProperty.resolveWith((Set states){ + if(states.contains(MaterialState.disabled)) { + return textStyle(textColor: AppColors.buttonDisableColor); + } return textStyle(); }) ); //textButtonStyle2 static ButtonStyle get textButtonStyle2 => ButtonStyle( - minimumSize: MaterialStateProperty.resolveWith((states) => btnMinSize2), - shape: MaterialStateProperty.resolveWith((states) => buttonShape_11), - backgroundColor: MaterialStateProperty.resolveWith((states){ - if(states.contains(MaterialState.disabled)) return AppColors.buttonDisableColor; + minimumSize: MaterialStateProperty.resolveWith((Set states) => btnMinSize2), + shape: MaterialStateProperty.resolveWith((Set states) => buttonShape_11), + backgroundColor: MaterialStateProperty.resolveWith((Set states){ + if(states.contains(MaterialState.disabled)) { + return AppColors.buttonDisableColor; + } return AppColors.buttonEnableColor; }), - foregroundColor: MaterialStateProperty.resolveWith((states){ - if(states.contains(MaterialState.disabled)) return AppColors.buttonDisableTextColor; + foregroundColor: MaterialStateProperty.resolveWith((Set states){ + if(states.contains(MaterialState.disabled)) { + return AppColors.buttonDisableTextColor; + } return AppColors.buttonEnableTextColor; }), - textStyle: MaterialStateProperty.resolveWith((states){ - if(states.contains(MaterialState.disabled)) return textStyle(textColor: AppColors.buttonDisableColor,fontSize: 11.sp); + textStyle: MaterialStateProperty.resolveWith((Set states){ + if(states.contains(MaterialState.disabled)) { + return textStyle(textColor: AppColors.buttonDisableColor,fontSize: 11.sp); + } return textStyle(fontSize: 11.sp); }) ); static ButtonStyle get textButtonStyleOthers => ButtonStyle( - minimumSize: MaterialStateProperty.resolveWith((states) => btnMinSize), - shape: MaterialStateProperty.resolveWith((states) => buttonShape_16), - backgroundColor: MaterialStateProperty.resolveWith((states){ - if(states.contains(MaterialState.disabled)) return AppColors.buttonDisableTextColor; + minimumSize: MaterialStateProperty.resolveWith((Set states) => btnMinSize), + shape: MaterialStateProperty.resolveWith((Set states) => buttonShape_16), + backgroundColor: MaterialStateProperty.resolveWith((Set states){ + if(states.contains(MaterialState.disabled)) { + return AppColors.buttonDisableTextColor; + } return AppColors.buttonEnableTextColor; }), - foregroundColor: MaterialStateProperty.resolveWith((states){ - if(states.contains(MaterialState.disabled)) return AppColors.buttonDisableColor; + foregroundColor: MaterialStateProperty.resolveWith((Set states){ + if(states.contains(MaterialState.disabled)) { + return AppColors.buttonDisableColor; + } return AppColors.buttonEnableColor; }), - textStyle: MaterialStateProperty.resolveWith((states){ - if(states.contains(MaterialState.disabled)) return textStyle(textColor: AppColors.buttonDisableColor); + textStyle: MaterialStateProperty.resolveWith((Set states){ + if(states.contains(MaterialState.disabled)) { + return textStyle(textColor: AppColors.buttonDisableColor); + } return textStyle(textColor: AppColors.buttonEnableColor); }) ); static ButtonStyle get specialButtonStyle => ButtonStyle( - minimumSize: MaterialStateProperty.resolveWith((states) => btnMinSize3), - shape: MaterialStateProperty.resolveWith((states) => buttonShape_16), - backgroundColor: MaterialStateProperty.resolveWith((states){ - if(states.contains(MaterialState.disabled)) return AppColors.buttonDisableTextColor; + minimumSize: MaterialStateProperty.resolveWith((Set states) => btnMinSize3), + shape: MaterialStateProperty.resolveWith((Set states) => buttonShape_16), + backgroundColor: MaterialStateProperty.resolveWith((Set states){ + if(states.contains(MaterialState.disabled)) { + return AppColors.buttonDisableTextColor; + } return AppColors.deleteBtnBgColor; }), - foregroundColor: MaterialStateProperty.resolveWith((states){ - if(states.contains(MaterialState.disabled)) return AppColors.buttonDisableColor; + foregroundColor: MaterialStateProperty.resolveWith((Set states){ + if(states.contains(MaterialState.disabled)) { + return AppColors.buttonDisableColor; + } return AppColors.buttonEnableTextColor; }), - textStyle: MaterialStateProperty.resolveWith((states){ - if(states.contains(MaterialState.disabled)) return textStyle(textColor: AppColors.buttonDisableColor); + textStyle: MaterialStateProperty.resolveWith((Set states){ + if(states.contains(MaterialState.disabled)) { + return textStyle(textColor: AppColors.buttonDisableColor); + } return textStyle(textColor: AppColors.buttonEnableColor); }) ); static ButtonStyle clearTextButtonStyle({Color? textColor, Color? bgColor, double? fontSize, FontWeight? fontWeight}) => ButtonStyle( - minimumSize: MaterialStateProperty.resolveWith((states) => btnMinSize), - shape: MaterialStateProperty.resolveWith((states) => buttonShape_16), - backgroundColor: MaterialStateProperty.resolveWith((states){ + minimumSize: MaterialStateProperty.resolveWith((Set states) => btnMinSize), + shape: MaterialStateProperty.resolveWith((Set states) => buttonShape_16), + backgroundColor: MaterialStateProperty.resolveWith((Set states){ bgColor ??= AppColors.normalTextColor; - if(states.contains(MaterialState.disabled)) return bgColor?.withOpacity(0.6); + if(states.contains(MaterialState.disabled)) { + return bgColor?.withOpacity(0.6); + } return bgColor; }), - overlayColor: MaterialStateProperty.resolveWith((states){ + overlayColor: MaterialStateProperty.resolveWith((Set states){ textColor ??= AppColors.buttonEnableColor; - if(states.contains(MaterialState.pressed)) return textColor?.withOpacity(0.1); + if(states.contains(MaterialState.pressed)) { + return textColor?.withOpacity(0.1); + } return textColor?.withOpacity(0.1); }), - foregroundColor: MaterialStateProperty.resolveWith((states){ + foregroundColor: MaterialStateProperty.resolveWith((Set states){ textColor ??= AppColors.buttonEnableColor; - if(states.contains(MaterialState.disabled)) return textColor?.withOpacity(0.4); + if(states.contains(MaterialState.disabled)) { + return textColor?.withOpacity(0.4); + } return textColor; }), - textStyle: MaterialStateProperty.resolveWith((states){ - if(states.contains(MaterialState.disabled)) return textStyle(fontSize: fontSize,fontWeight: fontWeight); + textStyle: MaterialStateProperty.resolveWith((Set states){ + if(states.contains(MaterialState.disabled)) { + return textStyle(fontSize: fontSize,fontWeight: fontWeight); + } return textStyle(fontSize: fontSize,fontWeight: fontWeight); }), ); ///elevatedButtonButtonStyle static ButtonStyle get elevatedButtonButtonStyle => ButtonStyle( - minimumSize: MaterialStateProperty.resolveWith((states) => btnMinSize), - shape: MaterialStateProperty.resolveWith((states) => buttonShape_16), - backgroundColor: MaterialStateProperty.resolveWith((states){ - if(states.contains(MaterialState.disabled)) return AppColors.buttonDisableColor; + minimumSize: MaterialStateProperty.resolveWith((Set states) => btnMinSize), + shape: MaterialStateProperty.resolveWith((Set states) => buttonShape_16), + backgroundColor: MaterialStateProperty.resolveWith((Set states){ + if(states.contains(MaterialState.disabled)) { + return AppColors.buttonDisableColor; + } return AppColors.buttonEnableColor; }), - foregroundColor: MaterialStateProperty.resolveWith((states){ - if(states.contains(MaterialState.disabled)) return AppColors.buttonDisableTextColor; + foregroundColor: MaterialStateProperty.resolveWith((Set states){ + if(states.contains(MaterialState.disabled)) { + return AppColors.buttonDisableTextColor; + } return AppColors.buttonEnableTextColor; }), ); ///outlinedButtonButtonStyle static ButtonStyle get outlinedButtonButtonStyle => ButtonStyle( - minimumSize: MaterialStateProperty.resolveWith((states) => btnMinSize), - shape: MaterialStateProperty.resolveWith((states) => buttonShape_16), - backgroundColor: MaterialStateProperty.resolveWith((states){ - if(states.contains(MaterialState.disabled)) return AppColors.buttonDisableColor; + minimumSize: MaterialStateProperty.resolveWith((Set states) => btnMinSize), + shape: MaterialStateProperty.resolveWith((Set states) => buttonShape_16), + backgroundColor: MaterialStateProperty.resolveWith((Set states){ + if(states.contains(MaterialState.disabled)) { + return AppColors.buttonDisableColor; + } return AppColors.buttonEnableColor; }), - foregroundColor: MaterialStateProperty.resolveWith((states){ - if(states.contains(MaterialState.disabled)) return AppColors.buttonDisableTextColor; + foregroundColor: MaterialStateProperty.resolveWith((Set states){ + if(states.contains(MaterialState.disabled)) { + return AppColors.buttonDisableTextColor; + } return AppColors.buttonEnableTextColor; }), ); @@ -166,21 +212,25 @@ class AppStyle { ///outlinedButtonButtonStyle2 static ButtonStyle get outlinedButtonButtonStyle2_Selected => ButtonStyle( - minimumSize: MaterialStateProperty.resolveWith((states) => btnMinSize), - shape: MaterialStateProperty.resolveWith((states) => buttonShape_11), - backgroundColor: MaterialStateProperty.resolveWith((states){ - if(states.contains(MaterialState.disabled)) return AppColors.buttonDisableColor; + minimumSize: MaterialStateProperty.resolveWith((Set states) => btnMinSize), + shape: MaterialStateProperty.resolveWith((Set states) => buttonShape_11), + backgroundColor: MaterialStateProperty.resolveWith((Set states){ + if(states.contains(MaterialState.disabled)) { + return AppColors.buttonDisableColor; + } return AppColors.buttonEnableColor; }), - foregroundColor: MaterialStateProperty.resolveWith((states){ - if(states.contains(MaterialState.disabled)) return AppColors.buttonDisableTextColor; + foregroundColor: MaterialStateProperty.resolveWith((Set states){ + if(states.contains(MaterialState.disabled)) { + return AppColors.buttonDisableTextColor; + } return AppColors.buttonEnableTextColor; }), ); ///outlinedButtonButtonStyle2_Selected static ButtonStyle get outlinedButtonButtonStyle2 => ButtonStyle( - shape: MaterialStateProperty.resolveWith((states) => buttonShape_11), + shape: MaterialStateProperty.resolveWith((Set states) => buttonShape_11), side: MaterialStateProperty.all(BorderSide( width: 1.w, color: AppColors.buttonEnableColor.withOpacity(0.5), diff --git a/lib/app_settings/app_theme.dart b/lib/app_settings/app_theme.dart index 7e6c662b..c4b339bc 100755 --- a/lib/app_settings/app_theme.dart +++ b/lib/app_settings/app_theme.dart @@ -122,9 +122,9 @@ class AppTheme { class NoShadowScrollBehavior extends ScrollBehavior { + const NoShadowScrollBehavior({this.axisDirection = AxisDirection.up}):super(); final AxisDirection axisDirection; - const NoShadowScrollBehavior({this.axisDirection = AxisDirection.up}):super(); @override Widget buildOverscrollIndicator(BuildContext context, Widget child, ScrollableDetails details) { return GlowingOverscrollIndicator(axisDirection: axisDirection, color: Colors.red,showTrailing: false,showLeading: false,child: child,); diff --git a/lib/blue/entity/lock_user_no_list_entity.dart b/lib/blue/entity/lock_user_no_list_entity.dart index 513cf90f..144cfd30 100755 --- a/lib/blue/entity/lock_user_no_list_entity.dart +++ b/lib/blue/entity/lock_user_no_list_entity.dart @@ -1,8 +1,4 @@ class LockUserNoListEntity { - int? errorCode; - String? description; - String? errorMsg; - Data? data; LockUserNoListEntity( {this.errorCode, this.description, this.errorMsg, this.data}); @@ -15,6 +11,10 @@ class LockUserNoListEntity { data = Data.fromJson(json['data']); } } + int? errorCode; + String? description; + String? errorMsg; + Data? data; Map toJson() { final Map data = {}; @@ -27,7 +27,6 @@ class LockUserNoListEntity { } class Data { - List? userNos = []; Data({ this.userNos, @@ -40,6 +39,7 @@ class Data { }); } } + List? userNos = []; Map toJson() { final Map data = {}; diff --git a/lib/blue/io_protocol/io_addCardCancel.dart b/lib/blue/io_protocol/io_addCardCancel.dart index 734bc65f..b084928d 100755 --- a/lib/blue/io_protocol/io_addCardCancel.dart +++ b/lib/blue/io_protocol/io_addCardCancel.dart @@ -1,21 +1,15 @@ import 'dart:convert'; - -import '../io_tool/io_tool.dart'; -import '../sm4Encipher/sm4.dart'; -import '../io_sender.dart'; -import '../io_type.dart'; import 'package:crypto/crypto.dart' as crypto; -///TODO:取消添加指纹 +import '../io_sender.dart'; +import '../io_tool/io_tool.dart'; +import '../io_type.dart'; +import '../sm4Encipher/sm4.dart'; + +/// 取消添加指纹 class SenderCancelAddCardCommand extends SenderProtocol { - String? keyID; - String? userID; - List? token; - int? needAuthor; - List? signKey; - List? privateKey; SenderCancelAddCardCommand({ this.keyID, @@ -25,6 +19,12 @@ class SenderCancelAddCardCommand extends SenderProtocol { this.signKey, this.privateKey, }) : super(CommandType.generalExtendedCommond); + String? keyID; + String? userID; + List? token; + int? needAuthor; + List? signKey; + List? privateKey; @override String toString() { @@ -34,9 +34,9 @@ class SenderCancelAddCardCommand extends SenderProtocol { @override List messageDetail() { - List data = []; - List subData = []; - List ebcData = []; + final List data = []; + List subData = []; + List ebcData = []; // 指令类型 data.addAll(intChangList(commandType!.typeValue)); @@ -45,12 +45,12 @@ class SenderCancelAddCardCommand extends SenderProtocol { data.add(25); // keyID 40 - int keyIDLength = utf8.encode(keyID!).length; + final int keyIDLength = utf8.encode(keyID!).length; subData.addAll(utf8.encode(keyID!)); subData = getFixedLengthList(subData, 40 - keyIDLength); //userID 20 - int userIDLength = utf8.encode(userID!).length; + final int userIDLength = utf8.encode(userID!).length; subData.addAll(utf8.encode(userID!)); subData = getFixedLengthList(subData, 20 - userIDLength); @@ -58,7 +58,7 @@ class SenderCancelAddCardCommand extends SenderProtocol { //AuthCodeLen 1 subData.add(0); } else { - List authCodeData = []; + final List authCodeData = []; //KeyID authCodeData.addAll(utf8.encode(keyID!)); @@ -71,7 +71,7 @@ class SenderCancelAddCardCommand extends SenderProtocol { authCodeData.addAll(signKey!); // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode - var authCode = crypto.md5.convert(authCodeData); + final crypto.Digest authCode = crypto.md5.convert(authCodeData); subData.add(authCode.bytes.length); subData.addAll(authCode.bytes); @@ -81,7 +81,7 @@ class SenderCancelAddCardCommand extends SenderProtocol { data.addAll(subData); if ((data.length % 16) != 0) { - int add = (16 - data.length % 16); + final int add = 16 - data.length % 16; for (int i = 0; i < add; i++) { data.add(0); } diff --git a/lib/blue/io_protocol/io_addFace.dart b/lib/blue/io_protocol/io_addFace.dart index 9383071c..99a0db40 100755 --- a/lib/blue/io_protocol/io_addFace.dart +++ b/lib/blue/io_protocol/io_addFace.dart @@ -10,29 +10,12 @@ import '../io_tool/io_tool.dart'; import '../io_type.dart'; import '../sm4Encipher/sm4.dart'; -///TODO:添加人脸 +/// 添加人脸 /* 备注: 删除单个人脸规则:UseCountLimit 设置为 0。删除全部人脸规则: UseCountLimit 设置为 0,FaceNo 设置为 255,userId 设置为“Delete All !@#”,只有门锁管理员才有权限 **/ class SenderAddFaceCommand extends SenderProtocol { - String? keyID; - String? userID; - int? faceNo; - int? useCountLimit; - int? isForce; - int? operate; - int? isAdmin; - List? token; - int? isRound; - int? weekRound; - int? startDate; - int? endDate; - String? startTime; - String? endTime; - int? needAuthor; - List? signKey; - List? privateKey; SenderAddFaceCommand({ this.keyID, @@ -53,6 +36,23 @@ class SenderAddFaceCommand extends SenderProtocol { this.signKey, this.privateKey, }) : super(CommandType.generalExtendedCommond); + String? keyID; + String? userID; + int? faceNo; + int? useCountLimit; + int? isForce; + int? operate; + int? isAdmin; + List? token; + int? isRound; + int? weekRound; + int? startDate; + int? endDate; + String? startTime; + String? endTime; + int? needAuthor; + List? signKey; + List? privateKey; @override String toString() { @@ -70,9 +70,9 @@ class SenderAddFaceCommand extends SenderProtocol { @override List messageDetail() { - final List data = []; - List subData = []; - List ebcData = []; + final List data = []; + List subData = []; + List ebcData = []; // 指令类型 data.addAll(intChangList(commandType!.typeValue)); @@ -139,7 +139,7 @@ class SenderAddFaceCommand extends SenderProtocol { // AppLog.log("addFingerprint startDate:${DateTool().dateToYMDHNString(startDate.toString())} endDate:${DateTool().dateToYMDHNString(endDate.toString())}"); // startTime 4 - final List startTimeList = [0,0,0,0]; + final List startTimeList = [0,0,0,0]; if(startTime!.contains(':')){ final List getStartTimeList = startTime!.split(':'); startTimeList[2] = int.parse(getStartTimeList[0]); @@ -148,7 +148,7 @@ class SenderAddFaceCommand extends SenderProtocol { subData.addAll(startTimeList); // endTime 4 - final List endTimeList = [0,0,0,0]; + final List endTimeList = [0,0,0,0]; if(endTime!.contains(':')){ final List getendTimeList = endTime!.split(':'); endTimeList[2] = int.parse(getendTimeList[0]); @@ -160,7 +160,7 @@ class SenderAddFaceCommand extends SenderProtocol { //AuthCodeLen 1 subData.add(0); } else { - final List authCodeData = []; + final List authCodeData = []; //KeyID authCodeData.addAll(utf8.encode(keyID!)); @@ -173,7 +173,7 @@ class SenderAddFaceCommand extends SenderProtocol { authCodeData.addAll(signKey!); // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode - final authCode = crypto.md5.convert(authCodeData); + final crypto.Digest authCode = crypto.md5.convert(authCodeData); subData.add(authCode.bytes.length); subData.addAll(authCode.bytes); diff --git a/lib/blue/io_protocol/io_addFaceCancel.dart b/lib/blue/io_protocol/io_addFaceCancel.dart index a89c2ac0..d8e9ef90 100755 --- a/lib/blue/io_protocol/io_addFaceCancel.dart +++ b/lib/blue/io_protocol/io_addFaceCancel.dart @@ -7,14 +7,8 @@ import '../io_sender.dart'; import '../io_type.dart'; import 'package:crypto/crypto.dart' as crypto; -///TODO:取消添加人脸 +/// 取消添加人脸 class SenderCancelAddFaceCommand extends SenderProtocol { - String? keyID; - String? userID; - List? token; - int? needAuthor; - List? signKey; - List? privateKey; SenderCancelAddFaceCommand({ this.keyID, @@ -24,6 +18,12 @@ class SenderCancelAddFaceCommand extends SenderProtocol { this.signKey, this.privateKey, }) : super(CommandType.generalExtendedCommond); + String? keyID; + String? userID; + List? token; + int? needAuthor; + List? signKey; + List? privateKey; @override String toString() { @@ -33,7 +33,7 @@ class SenderCancelAddFaceCommand extends SenderProtocol { @override List messageDetail() { - List data = []; + final List data = []; List subData = []; List ebcData = []; @@ -44,12 +44,12 @@ class SenderCancelAddFaceCommand extends SenderProtocol { data.add(86); // keyID 40 - int keyIDLength = utf8.encode(keyID!).length; + final int keyIDLength = utf8.encode(keyID!).length; subData.addAll(utf8.encode(keyID!)); subData = getFixedLengthList(subData, 40 - keyIDLength); //userID 20 - int userIDLength = utf8.encode(userID!).length; + final int userIDLength = utf8.encode(userID!).length; subData.addAll(utf8.encode(userID!)); subData = getFixedLengthList(subData, 20 - userIDLength); @@ -57,7 +57,7 @@ class SenderCancelAddFaceCommand extends SenderProtocol { //AuthCodeLen 1 subData.add(0); } else { - List authCodeData = []; + final List authCodeData = []; //KeyID authCodeData.addAll(utf8.encode(keyID!)); @@ -70,7 +70,7 @@ class SenderCancelAddFaceCommand extends SenderProtocol { authCodeData.addAll(signKey!); // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode - var authCode = crypto.md5.convert(authCodeData); + final authCode = crypto.md5.convert(authCodeData); subData.add(authCode.bytes.length); subData.addAll(authCode.bytes); @@ -80,7 +80,7 @@ class SenderCancelAddFaceCommand extends SenderProtocol { data.addAll(subData); if ((data.length % 16) != 0) { - int add = 16 - data.length % 16; + final int add = 16 - data.length % 16; for (int i = 0; i < add; i++) { data.add(0); } diff --git a/lib/blue/io_protocol/io_addFaceWithTimeCycleCoercion.dart b/lib/blue/io_protocol/io_addFaceWithTimeCycleCoercion.dart deleted file mode 100755 index d10ecec2..00000000 --- a/lib/blue/io_protocol/io_addFaceWithTimeCycleCoercion.dart +++ /dev/null @@ -1,186 +0,0 @@ - -import '../io_sender.dart'; -import '../io_type.dart'; - -///TODO:添加人脸 -/* -备注: -删除单个指纹规则:UseCountLimit 设置为 0。删除全部指纹规则: UseCountLimit 设置为 0,FingerNo 设置为 255,userId 设置为“Delete All !@#”,只有门锁管理员才有权限 -**/ -// class SenderAddFaceWithTimeCycleCoercionCommand extends SenderProtocol { -// -// String? keyID; -// String? userID; -// int? fingerNo; -// int? useCountLimit; -// int? isForce; -// List? token; -// int? isRound; -// int? weekRound; -// int? startDate; -// int? endDate; -// String? startTime; -// String? endTime; -// int? needAuthor; -// List? signKey; -// List? privateKey; -// -// SenderAddFaceWithTimeCycleCoercionCommand({ -// this.keyID, -// this.userID, -// this.fingerNo, -// this.useCountLimit, -// this.isForce, -// this.token, -// this.isRound, -// this.weekRound, -// this.startDate, -// this.endDate, -// this.startTime, -// this.endTime, -// 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(36); -// -// // keyID 40 -// int keyIDLength = utf8.encode(keyID!).length; -// subData.addAll(utf8.encode(keyID!)); -// subData = getFixedLengthList(subData, 40 - keyIDLength); -// -// //userID 20 -// int userIDLength = utf8.encode(userID!).length; -// subData.addAll(utf8.encode(userID!)); -// subData = getFixedLengthList(subData, 20 - userIDLength); -// -// // fingerNo -// subData.add(fingerNo!); -// -// // UseCountLimit -// subData.add(useCountLimit!); -// -// // isForce -// subData.add(isForce!); -// -// // token -// subData.addAll(token!); -// -// // isRound -// subData.add(isRound!); -// -// // weekRound -// subData.add(weekRound!); -// -// // startDate 4 -// subData.add((startDate! & 0xff000000) >> 24); -// subData.add((startDate! & 0xff0000) >> 16); -// subData.add((startDate! & 0xff00) >> 8); -// subData.add((startDate! & 0xff)); -// -// // endDate 4 -// subData.add((endDate! & 0xff000000) >> 24); -// subData.add((endDate! & 0xff0000) >> 16); -// subData.add((endDate! & 0xff00) >> 8); -// subData.add((endDate! & 0xff)); -// -// // startTime 4 -// 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 -// 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 -// 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); -// } -// } -// -// Get.log("${commandType!.typeName} SM4Data:$data"); -// // 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864 -// ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB); -// return ebcData; -// } -// } -// -// class SenderAddFingerprintWithTimeCycleCoercionReply extends Reply { -// SenderAddFingerprintWithTimeCycleCoercionReply.parseData(CommandType commandType, List dataDetail) -// : super.parseData(commandType, dataDetail) { -// data = dataDetail; -// int status = data[2]; -// errorWithStstus(status); -// } -// } -// -// class SenderAddFingerprintProcessReply extends Reply { -// SenderAddFingerprintProcessReply.parseData(CommandType commandType, List dataDetail) -// : super.parseData(commandType, dataDetail) { -// data = dataDetail; -// int status = data[2]; -// errorWithStstus(status); -// } -// } -// -// 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/lib/blue/io_protocol/io_addFingerprint.dart b/lib/blue/io_protocol/io_addFingerprint.dart deleted file mode 100755 index fcd4d397..00000000 --- a/lib/blue/io_protocol/io_addFingerprint.dart +++ /dev/null @@ -1,148 +0,0 @@ - -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'; -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 = []; -// -// // 指令类型 -// 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; -// subData.addAll(utf8.encode(keyID!)); -// subData = getFixedLengthList(subData, 40 - keyIDLength); -// -// //userID 20 -// int userIDLength = utf8.encode(userID!).length; -// 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); -// } -// } -// // 拿到数据之后通过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/lib/blue/io_protocol/io_addFingerprintCancel.dart b/lib/blue/io_protocol/io_addFingerprintCancel.dart index 36e8277d..9ecf8c6c 100755 --- a/lib/blue/io_protocol/io_addFingerprintCancel.dart +++ b/lib/blue/io_protocol/io_addFingerprintCancel.dart @@ -7,14 +7,8 @@ import '../io_sender.dart'; import '../io_type.dart'; import 'package:crypto/crypto.dart' as crypto; -///TODO:取消添加指纹 +/// 取消添加指纹 class SenderCancelAddFingerprintCommand extends SenderProtocol { - String? keyID; - String? userID; - List? token; - int? needAuthor; - List? signKey; - List? privateKey; SenderCancelAddFingerprintCommand({ this.keyID, @@ -24,6 +18,12 @@ class SenderCancelAddFingerprintCommand extends SenderProtocol { this.signKey, this.privateKey, }) : super(CommandType.generalExtendedCommond); + String? keyID; + String? userID; + List? token; + int? needAuthor; + List? signKey; + List? privateKey; @override String toString() { @@ -33,9 +33,9 @@ class SenderCancelAddFingerprintCommand extends SenderProtocol { @override List messageDetail() { - List data = []; - List subData = []; - List ebcData = []; + final List data = []; + List subData = []; + List ebcData = []; // 指令类型 data.addAll(intChangList(commandType!.typeValue)); @@ -44,12 +44,12 @@ class SenderCancelAddFingerprintCommand extends SenderProtocol { data.add(37); // keyID 40 - int keyIDLength = utf8.encode(keyID!).length; + final int keyIDLength = utf8.encode(keyID!).length; subData.addAll(utf8.encode(keyID!)); subData = getFixedLengthList(subData, 40 - keyIDLength); //userID 20 - int userIDLength = utf8.encode(userID!).length; + final int userIDLength = utf8.encode(userID!).length; subData.addAll(utf8.encode(userID!)); subData = getFixedLengthList(subData, 20 - userIDLength); @@ -57,7 +57,7 @@ class SenderCancelAddFingerprintCommand extends SenderProtocol { //AuthCodeLen 1 subData.add(0); } else { - List authCodeData = []; + final List authCodeData = []; //KeyID authCodeData.addAll(utf8.encode(keyID!)); @@ -70,7 +70,7 @@ class SenderCancelAddFingerprintCommand extends SenderProtocol { authCodeData.addAll(signKey!); // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode - var authCode = crypto.md5.convert(authCodeData); + final crypto.Digest authCode = crypto.md5.convert(authCodeData); subData.add(authCode.bytes.length); subData.addAll(authCode.bytes); @@ -80,7 +80,7 @@ class SenderCancelAddFingerprintCommand extends SenderProtocol { data.addAll(subData); if ((data.length % 16) != 0) { - int add = (16 - data.length % 16); + final int add = 16 - data.length % 16; for (int i = 0; i < add; i++) { data.add(0); } diff --git a/lib/blue/io_protocol/io_addFingerprintWithTimeCycleCoercion.dart b/lib/blue/io_protocol/io_addFingerprintWithTimeCycleCoercion.dart index d92547b8..7877c625 100755 --- a/lib/blue/io_protocol/io_addFingerprintWithTimeCycleCoercion.dart +++ b/lib/blue/io_protocol/io_addFingerprintWithTimeCycleCoercion.dart @@ -10,31 +10,12 @@ import '../io_sender.dart'; import '../io_type.dart'; import 'package:crypto/crypto.dart' as crypto; -///TODO:添加指纹 +/// 添加指纹 /* 备注: 删除单个指纹规则:UseCountLimit 设置为 0。删除全部指纹规则: UseCountLimit 设置为 0,FingerNo 设置为 255,userId 设置为“Delete All !@#”,只有门锁管理员才有权限 **/ class SenderAddFingerprintWithTimeCycleCoercionCommand extends SenderProtocol { - - String? keyID; - String? userID; - int? fingerNo; - int? useCountLimit; - int? isForce; - int? operate; - int? isAdmin; - List? token; - int? isRound; - int? weekRound; - int? startDate; - int? endDate; - String? startTime; - String? endTime; - int? needAuthor; - List? signKey; - List? privateKey; - SenderAddFingerprintWithTimeCycleCoercionCommand({ this.keyID, this.userID, @@ -55,6 +36,24 @@ class SenderAddFingerprintWithTimeCycleCoercionCommand extends SenderProtocol { this.privateKey, }) : super(CommandType.generalExtendedCommond); + String? keyID; + String? userID; + int? fingerNo; + int? useCountLimit; + int? isForce; + int? operate; + int? isAdmin; + List? token; + int? isRound; + int? weekRound; + int? startDate; + int? endDate; + String? startTime; + String? endTime; + int? needAuthor; + List? signKey; + List? privateKey; + @override String toString() { return 'SenderAddFingerprintWithTimeCycleCoercionCommand{keyID: $keyID, ' @@ -70,7 +69,7 @@ class SenderAddFingerprintWithTimeCycleCoercionCommand extends SenderProtocol { @override List messageDetail() { - List data = []; + final List data = []; List subData = []; List ebcData = []; @@ -81,12 +80,12 @@ class SenderAddFingerprintWithTimeCycleCoercionCommand extends SenderProtocol { data.add(36); // keyID 40 - int keyIDLength = utf8.encode(keyID!).length; + final int keyIDLength = utf8.encode(keyID!).length; subData.addAll(utf8.encode(keyID!)); subData = getFixedLengthList(subData, 40 - keyIDLength); //userID 20 - int userIDLength = utf8.encode(userID!).length; + final int userIDLength = utf8.encode(userID!).length; subData.addAll(utf8.encode(userID!)); subData = getFixedLengthList(subData, 20 - userIDLength); @@ -121,27 +120,27 @@ class SenderAddFingerprintWithTimeCycleCoercionCommand extends SenderProtocol { subData.add((startDate! & 0xff000000) >> 24); subData.add((startDate! & 0xff0000) >> 16); subData.add((startDate! & 0xff00) >> 8); - subData.add((startDate! & 0xff)); + subData.add(startDate! & 0xff); // endDate 4 subData.add((endDate! & 0xff000000) >> 24); subData.add((endDate! & 0xff0000) >> 16); subData.add((endDate! & 0xff00) >> 8); - subData.add((endDate! & 0xff)); + subData.add(endDate! & 0xff); // startTime 4 - List startTimeList = [0,0,0,0]; - if(startTime!.contains(":")){ - List getStartTimeList = startTime!.split(":"); + final List startTimeList = [0,0,0,0]; + if(startTime!.contains(':')){ + final List getStartTimeList = startTime!.split(':'); startTimeList[2] = int.parse(getStartTimeList[0]); startTimeList[3] = int.parse(getStartTimeList[1]); } subData.addAll(startTimeList); // endTime 4 - List endTimeList = [0,0,0,0]; - if(endTime!.contains(":")){ - List getendTimeList = endTime!.split(":"); + final List endTimeList = [0,0,0,0]; + if(endTime!.contains(':')){ + final List getendTimeList = endTime!.split(':'); endTimeList[2] = int.parse(getendTimeList[0]); endTimeList[3] = int.parse(getendTimeList[1]); } @@ -151,7 +150,7 @@ class SenderAddFingerprintWithTimeCycleCoercionCommand extends SenderProtocol { //AuthCodeLen 1 subData.add(0); } else { - List authCodeData = []; + final List authCodeData = []; //KeyID authCodeData.addAll(utf8.encode(keyID!)); @@ -164,7 +163,7 @@ class SenderAddFingerprintWithTimeCycleCoercionCommand extends SenderProtocol { authCodeData.addAll(signKey!); // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode - var authCode = crypto.md5.convert(authCodeData); + final authCode = crypto.md5.convert(authCodeData); subData.add(authCode.bytes.length); subData.addAll(authCode.bytes); @@ -174,7 +173,7 @@ class SenderAddFingerprintWithTimeCycleCoercionCommand extends SenderProtocol { data.addAll(subData); if ((data.length % 16) != 0) { - int add = (16 - data.length % 16); + final int add = 16 - data.length % 16; for (int i = 0; i < add; i++) { data.add(0); } @@ -191,7 +190,7 @@ class SenderAddFingerprintWithTimeCycleCoercionReply extends Reply { SenderAddFingerprintWithTimeCycleCoercionReply.parseData(CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { data = dataDetail; - int status = data[2]; + final int status = data[2]; errorWithStstus(status); } } @@ -200,7 +199,7 @@ class SenderAddFingerprintProcessReply extends Reply { SenderAddFingerprintProcessReply.parseData(CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { data = dataDetail; - int status = data[2]; + final int status = data[2]; errorWithStstus(status); } } @@ -209,7 +208,7 @@ class SenderAddFingerprintConfirmationReply extends Reply { SenderAddFingerprintConfirmationReply.parseData(CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { data = dataDetail; - int status = data[2]; + final int status = data[2]; errorWithStstus(status); } } \ No newline at end of file diff --git a/lib/blue/io_protocol/io_addICCard.dart b/lib/blue/io_protocol/io_addICCard.dart index 740f6515..5fb99222 100755 --- a/lib/blue/io_protocol/io_addICCard.dart +++ b/lib/blue/io_protocol/io_addICCard.dart @@ -1,16 +1,8 @@ -import 'dart:convert'; -import '../io_reply.dart'; -import '../io_sender.dart'; -import '../io_tool/io_tool.dart'; -import '../io_type.dart'; -import 'package:crypto/crypto.dart' as crypto; -import '../sm4Encipher/sm4.dart'; - -///TODO:该协议已弃用 使用新协议SenderAddICCardWithTimeCycleCoercionCommand 2024.4.16 addby 魏少阳 +/// 该协议已弃用 使用新协议SenderAddICCardWithTimeCycleCoercionCommand 2024.4.16 addby 魏少阳 /// -///TODO:设置自定义密码 +/// 设置自定义密码 // /* // 备注: // 删除单个指纹规则:UseCountLimit 设置为 0。删除全部指纹规则: UseCountLimit 设置为 0,FingerNo 设置为 255,userId 设置为“Delete All !@#”,只有门锁管理员才有权限 diff --git a/lib/blue/io_protocol/io_addICCardWithTimeCycleCoercion.dart b/lib/blue/io_protocol/io_addICCardWithTimeCycleCoercion.dart index 173c738e..bab9853b 100755 --- a/lib/blue/io_protocol/io_addICCardWithTimeCycleCoercion.dart +++ b/lib/blue/io_protocol/io_addICCardWithTimeCycleCoercion.dart @@ -10,31 +10,13 @@ import '../io_sender.dart'; import '../io_type.dart'; import 'package:crypto/crypto.dart' as crypto; -///TODO:添加指纹 +/// 添加指纹 /* 备注: 删除单个指纹规则:UseCountLimit 设置为 0。删除全部指纹规则: UseCountLimit 设置为 0,FingerNo 设置为 255,userId 设置为“Delete All !@#”,只有门锁管理员才有权限 **/ class SenderAddICCardWithTimeCycleCoercionCommand extends SenderProtocol { - String? keyID; - String? userID; - int? cardNo; - int? useCountLimit; - int? isForce; - int? operate; - int? isAdmin; - List? token; - int? isRound; - int? weekRound; - int? startDate; - int? endDate; - String? startTime; - String? endTime; - int? needAuthor; - List? signKey; - List? privateKey; - SenderAddICCardWithTimeCycleCoercionCommand({ this.keyID, this.userID, @@ -55,6 +37,24 @@ class SenderAddICCardWithTimeCycleCoercionCommand extends SenderProtocol { this.privateKey, }) : super(CommandType.generalExtendedCommond); + String? keyID; + String? userID; + int? cardNo; + int? useCountLimit; + int? isForce; + int? operate; + int? isAdmin; + List? token; + int? isRound; + int? weekRound; + int? startDate; + int? endDate; + String? startTime; + String? endTime; + int? needAuthor; + List? signKey; + List? privateKey; + @override String toString() { @@ -71,9 +71,9 @@ class SenderAddICCardWithTimeCycleCoercionCommand extends SenderProtocol { @override List messageDetail() { - List data = []; - List subData = []; - List ebcData = []; + final List data = []; + List subData = []; + List ebcData = []; // 指令类型 data.addAll(intChangList(commandType!.typeValue)); @@ -82,12 +82,12 @@ class SenderAddICCardWithTimeCycleCoercionCommand extends SenderProtocol { data.add(24); // keyID 40 - int keyIDLength = utf8.encode(keyID!).length; + final int keyIDLength = utf8.encode(keyID!).length; subData.addAll(utf8.encode(keyID!)); subData = getFixedLengthList(subData, 40 - keyIDLength); //userID 20 - int userIDLength = utf8.encode(userID!).length; + final int userIDLength = utf8.encode(userID!).length; subData.addAll(utf8.encode(userID!)); subData = getFixedLengthList(subData, 20 - userIDLength); @@ -122,27 +122,27 @@ class SenderAddICCardWithTimeCycleCoercionCommand extends SenderProtocol { subData.add((startDate! & 0xff000000) >> 24); subData.add((startDate! & 0xff0000) >> 16); subData.add((startDate! & 0xff00) >> 8); - subData.add((startDate! & 0xff)); + subData.add(startDate! & 0xff); // endDate 4 subData.add((endDate! & 0xff000000) >> 24); subData.add((endDate! & 0xff0000) >> 16); subData.add((endDate! & 0xff00) >> 8); - subData.add((endDate! & 0xff)); + subData.add(endDate! & 0xff); // startTime 4 - List startTimeList = [0,0,0,0]; - if(startTime!.contains(":")){ - List getStartTimeList = startTime!.split(":"); + final List startTimeList = [0,0,0,0]; + if(startTime!.contains(':')){ + final List getStartTimeList = startTime!.split(':'); startTimeList[2] = int.parse(getStartTimeList[0]); startTimeList[3] = int.parse(getStartTimeList[1]); } subData.addAll(startTimeList); // endTime 4 - List endTimeList = [0,0,0,0]; - if(endTime!.contains(":")){ - List getendTimeList = endTime!.split(":"); + final List endTimeList = [0,0,0,0]; + if(endTime!.contains(':')){ + final List getendTimeList = endTime!.split(':'); endTimeList[2] = int.parse(getendTimeList[0]); endTimeList[3] = int.parse(getendTimeList[1]); } @@ -152,7 +152,7 @@ class SenderAddICCardWithTimeCycleCoercionCommand extends SenderProtocol { //AuthCodeLen 1 subData.add(0); } else { - List authCodeData = []; + final List authCodeData = []; //KeyID authCodeData.addAll(utf8.encode(keyID!)); @@ -165,7 +165,7 @@ class SenderAddICCardWithTimeCycleCoercionCommand extends SenderProtocol { authCodeData.addAll(signKey!); // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode - var authCode = crypto.md5.convert(authCodeData); + final crypto.Digest authCode = crypto.md5.convert(authCodeData); subData.add(authCode.bytes.length); subData.addAll(authCode.bytes); @@ -175,7 +175,7 @@ class SenderAddICCardWithTimeCycleCoercionCommand extends SenderProtocol { data.addAll(subData); if ((data.length % 16) != 0) { - int add = (16 - data.length % 16); + final int add = 16 - data.length % 16; for (int i = 0; i < add; i++) { data.add(0); } @@ -192,7 +192,7 @@ class SenderAddICCardWithTimeCycleCoercionReply extends Reply { SenderAddICCardWithTimeCycleCoercionReply.parseData(CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { data = dataDetail; - int status = data[2]; + final int status = data[2]; errorWithStstus(status); } } @@ -201,7 +201,7 @@ class SenderAddICCardConfirmationReply extends Reply { SenderAddICCardConfirmationReply.parseData(CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { data = dataDetail; - int status = data[2]; + final int status = data[2]; errorWithStstus(status); } } diff --git a/lib/blue/io_protocol/io_addPalmCancel.dart b/lib/blue/io_protocol/io_addPalmCancel.dart index 20b5f9a9..021e6ac8 100644 --- a/lib/blue/io_protocol/io_addPalmCancel.dart +++ b/lib/blue/io_protocol/io_addPalmCancel.dart @@ -8,7 +8,7 @@ import '../io_tool/io_tool.dart'; import '../io_type.dart'; import '../sm4Encipher/sm4.dart'; -/// TODO:取消添加掌纹 +/// 取消添加掌纹 class SenderCancelAddPalmCommand extends SenderProtocol { SenderCancelAddPalmCommand({ @@ -34,7 +34,7 @@ class SenderCancelAddPalmCommand extends SenderProtocol { @override List messageDetail() { - List data = []; + final List data = []; List subData = []; List ebcData = []; @@ -45,12 +45,12 @@ class SenderCancelAddPalmCommand extends SenderProtocol { data.add(44); // keyID 40 - int keyIDLength = utf8.encode(keyID!).length; + final int keyIDLength = utf8.encode(keyID!).length; subData.addAll(utf8.encode(keyID!)); subData = getFixedLengthList(subData, 40 - keyIDLength); //userID 20 - int userIDLength = utf8.encode(userID!).length; + final int userIDLength = utf8.encode(userID!).length; subData.addAll(utf8.encode(userID!)); subData = getFixedLengthList(subData, 20 - userIDLength); @@ -58,7 +58,7 @@ class SenderCancelAddPalmCommand extends SenderProtocol { //AuthCodeLen 1 subData.add(0); } else { - List authCodeData = []; + final List authCodeData = []; //KeyID authCodeData.addAll(utf8.encode(keyID!)); @@ -71,7 +71,7 @@ class SenderCancelAddPalmCommand extends SenderProtocol { authCodeData.addAll(signKey!); // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode - var authCode = crypto.md5.convert(authCodeData); + final authCode = crypto.md5.convert(authCodeData); subData.add(authCode.bytes.length); subData.addAll(authCode.bytes); @@ -81,7 +81,7 @@ class SenderCancelAddPalmCommand extends SenderProtocol { data.addAll(subData); if ((data.length % 16) != 0) { - int add = 16 - data.length % 16; + final int add = 16 - data.length % 16; for (int i = 0; i < add; i++) { data.add(0); } diff --git a/lib/blue/io_protocol/io_addPalmWithTimeCycleCoercion.dart b/lib/blue/io_protocol/io_addPalmWithTimeCycleCoercion.dart index 7972aa83..430eb494 100644 --- a/lib/blue/io_protocol/io_addPalmWithTimeCycleCoercion.dart +++ b/lib/blue/io_protocol/io_addPalmWithTimeCycleCoercion.dart @@ -10,7 +10,7 @@ import '../io_tool/io_tool.dart'; import '../io_type.dart'; import '../sm4Encipher/sm4.dart'; -///TODO:添加掌纹 +/// 添加掌纹 class SenderAddPalmWithTimeCycleCoercionCommand extends SenderProtocol { SenderAddPalmWithTimeCycleCoercionCommand({ diff --git a/lib/blue/io_protocol/io_addRemoteControlCancel.dart b/lib/blue/io_protocol/io_addRemoteControlCancel.dart index d09f64a0..46765f6b 100644 --- a/lib/blue/io_protocol/io_addRemoteControlCancel.dart +++ b/lib/blue/io_protocol/io_addRemoteControlCancel.dart @@ -8,7 +8,7 @@ import '../io_tool/io_tool.dart'; import '../io_type.dart'; import '../sm4Encipher/sm4.dart'; -/// TODO:取消添加遥控 +/// 取消添加遥控 class SenderCancelAddRemoteControlCommand extends SenderProtocol { SenderCancelAddRemoteControlCommand({ @@ -34,7 +34,7 @@ class SenderCancelAddRemoteControlCommand extends SenderProtocol { @override List messageDetail() { - List data = []; + final List data = []; List subData = []; List ebcData = []; @@ -45,12 +45,12 @@ class SenderCancelAddRemoteControlCommand extends SenderProtocol { data.add(28); // keyID 40 - int keyIDLength = utf8.encode(keyID!).length; + final int keyIDLength = utf8.encode(keyID!).length; subData.addAll(utf8.encode(keyID!)); subData = getFixedLengthList(subData, 40 - keyIDLength); //userID 20 - int userIDLength = utf8.encode(userID!).length; + final int userIDLength = utf8.encode(userID!).length; subData.addAll(utf8.encode(userID!)); subData = getFixedLengthList(subData, 20 - userIDLength); @@ -58,7 +58,7 @@ class SenderCancelAddRemoteControlCommand extends SenderProtocol { //AuthCodeLen 1 subData.add(0); } else { - List authCodeData = []; + final List authCodeData = []; //KeyID authCodeData.addAll(utf8.encode(keyID!)); @@ -71,7 +71,7 @@ class SenderCancelAddRemoteControlCommand extends SenderProtocol { authCodeData.addAll(signKey!); // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode - var authCode = crypto.md5.convert(authCodeData); + final authCode = crypto.md5.convert(authCodeData); subData.add(authCode.bytes.length); subData.addAll(authCode.bytes); @@ -81,7 +81,7 @@ class SenderCancelAddRemoteControlCommand extends SenderProtocol { data.addAll(subData); if ((data.length % 16) != 0) { - int add = 16 - data.length % 16; + final int add = 16 - data.length % 16; for (int i = 0; i < add; i++) { data.add(0); } diff --git a/lib/blue/io_protocol/io_addRemoteControlWithTimeCycleCoercion.dart b/lib/blue/io_protocol/io_addRemoteControlWithTimeCycleCoercion.dart index 62ff50bf..786f7ad0 100644 --- a/lib/blue/io_protocol/io_addRemoteControlWithTimeCycleCoercion.dart +++ b/lib/blue/io_protocol/io_addRemoteControlWithTimeCycleCoercion.dart @@ -10,7 +10,7 @@ import '../io_sender.dart'; import '../io_type.dart'; import 'package:crypto/crypto.dart' as crypto; -///TODO:添加遥控 +/// 添加遥控 class SenderAddRemoteControlWithTimeCycleCoercionCommand extends SenderProtocol { SenderAddRemoteControlWithTimeCycleCoercionCommand({ diff --git a/lib/blue/io_protocol/io_addStressFingerprint.dart b/lib/blue/io_protocol/io_addStressFingerprint.dart deleted file mode 100755 index 0980e2c8..00000000 --- a/lib/blue/io_protocol/io_addStressFingerprint.dart +++ /dev/null @@ -1,140 +0,0 @@ - -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'; -import 'package:crypto/crypto.dart' as crypto; - -///TODO:添加胁迫指纹 -/* -备注: -删除单个指纹规则: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; -// subData.addAll(utf8.encode(keyID!)); -// subData = getFixedLengthList(subData, 40 - keyIDLength); -// -// //userID 20 -// int userIDLength = utf8.encode(userID!).length; -// 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); -// } -// } -// // 拿到数据之后通过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/lib/blue/io_protocol/io_addStressICCard.dart b/lib/blue/io_protocol/io_addStressICCard.dart deleted file mode 100755 index bd99ff55..00000000 --- a/lib/blue/io_protocol/io_addStressICCard.dart +++ /dev/null @@ -1,143 +0,0 @@ - -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'; -import 'package:crypto/crypto.dart' as crypto; - -///TODO:该协议已弃用 使用新协议SenderAddICCardWithTimeCycleCoercionCommand 2024.4.16 addby 魏少阳 -/// -///TODO:添加胁迫卡片 -/* -备注: -删除单个指纹规则: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; -// subData.addAll(utf8.encode(keyID!)); -// subData = getFixedLengthList(subData, 40 - keyIDLength); -// -// //userID 20 -// int userIDLength = utf8.encode(userID!).length; -// 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); -// } -// } -// // 拿到数据之后通过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/lib/blue/io_protocol/io_addStressPassword.dart b/lib/blue/io_protocol/io_addStressPassword.dart index 8d875f7c..349b6566 100755 --- a/lib/blue/io_protocol/io_addStressPassword.dart +++ b/lib/blue/io_protocol/io_addStressPassword.dart @@ -11,24 +11,13 @@ import '../io_sender.dart'; import '../io_type.dart'; import 'package:crypto/crypto.dart' as crypto; -///TODO:添加胁迫密码 +/// 添加胁迫密码 /* 备注: 删除单个指纹规则:UseCountLimit 设置为 0。删除全部指纹规则: UseCountLimit 设置为 0,FingerNo 设置为 255,userId 设置为“Delete All !@#”,只有门锁管理员才有权限 **/ class SenderAddStressPasswordCommand extends SenderProtocol { - String? keyID; - String? userID; - int? passwordNo; - int? useCountLimit; - List? token; - int? startTime; - int? endTime; - int? needAuthor; - List? publicKey; - List? privateKey; - SenderAddStressPasswordCommand({ this.keyID, this.userID, @@ -42,6 +31,17 @@ class SenderAddStressPasswordCommand extends SenderProtocol { this.privateKey, }) : super(CommandType.generalExtendedCommond); + String? keyID; + String? userID; + int? passwordNo; + int? useCountLimit; + List? token; + int? startTime; + int? endTime; + int? needAuthor; + List? publicKey; + List? privateKey; + @override String toString() { @@ -56,15 +56,15 @@ class SenderAddStressPasswordCommand extends SenderProtocol { @override List messageDetail() { - List data = []; - List subData = []; - List ebcData = []; + final List data = []; + List subData = []; + List ebcData = []; // 指令类型 - int type = commandType!.typeValue; - double typeDouble = type / 256; - int type1 = typeDouble.toInt(); - int type2 = type % 256; + final int type = commandType!.typeValue; + final double typeDouble = type / 256; + final int type1 = typeDouble.toInt(); + final int type2 = type % 256; data.add(type1); data.add(type2); @@ -72,12 +72,12 @@ class SenderAddStressPasswordCommand extends SenderProtocol { data.add(60); // keyID 40 - int keyIDLength = utf8.encode(keyID!).length; + final int keyIDLength = utf8.encode(keyID!).length; subData.addAll(utf8.encode(keyID!)); subData = getFixedLengthList(subData, 40 - keyIDLength); //userID 20 - int userIDLength = utf8.encode(userID!).length; + final int userIDLength = utf8.encode(userID!).length; subData.addAll(utf8.encode(userID!)); subData = getFixedLengthList(subData, 20 - userIDLength); @@ -94,19 +94,19 @@ class SenderAddStressPasswordCommand extends SenderProtocol { subData.add((startTime! & 0xff000000) >> 24); subData.add((startTime! & 0xff0000) >> 16); subData.add((startTime! & 0xff00) >> 8); - subData.add((startTime! & 0xff)); + 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)); + subData.add(endTime! & 0xff); if(needAuthor == 0){ //AuthCodeLen 1 subData.add(0); } else { - List authCodeData = []; + final List authCodeData = []; //authUserID authCodeData.addAll(utf8.encode(userID!)); @@ -120,7 +120,7 @@ class SenderAddStressPasswordCommand extends SenderProtocol { authCodeData.addAll(publicKey!); // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode - var authCode = crypto.md5.convert(authCodeData); + final crypto.Digest authCode = crypto.md5.convert(authCodeData); subData.add(authCode.bytes.length); subData.addAll(authCode.bytes); @@ -130,7 +130,7 @@ class SenderAddStressPasswordCommand extends SenderProtocol { data.addAll(subData); if ((data.length % 16) != 0) { - int add = (16 - data.length % 16); + final int add = 16 - data.length % 16; for (int i = 0; i < add; i++) { data.add(0); } @@ -147,7 +147,7 @@ class SenderAddStressPasswordReply extends Reply { SenderAddStressPasswordReply.parseData(CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { data = dataDetail; - int status = data[2]; + final int status = data[2]; errorWithStstus(status); } } \ No newline at end of file diff --git a/lib/blue/io_protocol/io_addUser.dart b/lib/blue/io_protocol/io_addUser.dart index e54463e6..e5616d1b 100755 --- a/lib/blue/io_protocol/io_addUser.dart +++ b/lib/blue/io_protocol/io_addUser.dart @@ -11,31 +11,8 @@ import '../io_sender.dart'; import '../io_type.dart'; import 'package:crypto/crypto.dart' as crypto; -//TODO:添加用户 +// 添加用户 class AddUserCommand extends SenderProtocol { - String? lockID; - String? authUserID; - String? keyID; - String? userID; - int? openMode; - int? keyType; - int? startDate; - int? expireDate; - - int? useCountLimit; - int? isRound; - int? weekRound; - int? startHour; - int? startMin; - int? endHour; - int? endMin; - - int? role; - String? password; - int? needAuthor; - List? publicKey; - List? privateKey; - List? token; AddUserCommand( {this.lockID, @@ -60,6 +37,29 @@ class AddUserCommand extends SenderProtocol { this.privateKey, this.token}) : super(CommandType.addUser); + String? lockID; + String? authUserID; + String? keyID; + String? userID; + int? openMode; + int? keyType; + int? startDate; + int? expireDate; + + int? useCountLimit; + int? isRound; + int? weekRound; + int? startHour; + int? startMin; + int? endHour; + int? endMin; + + int? role; + String? password; + int? needAuthor; + List? publicKey; + List? privateKey; + List? token; @override String toString() { @@ -78,34 +78,34 @@ class AddUserCommand extends SenderProtocol { @override List messageDetail() { - List data = []; - List ebcData = []; + List data = []; + List ebcData = []; // 指令类型 - int type = commandType!.typeValue; - double typeDouble = type / 256; - int type1 = typeDouble.toInt(); - int type2 = type % 256; + final int type = commandType!.typeValue; + final double typeDouble = type / 256; + final int type1 = typeDouble.toInt(); + final int type2 = type % 256; data.add(type1); data.add(type2); // 锁id 40 - int lockIDLength = utf8.encode(lockID!).length; + final int lockIDLength = utf8.encode(lockID!).length; data.addAll(utf8.encode(lockID!)); data = getFixedLengthList(data, 40 - lockIDLength); //authUserID 20 - int authUserIDLength = utf8.encode(authUserID!).length; + final int authUserIDLength = utf8.encode(authUserID!).length; data.addAll(utf8.encode(authUserID!)); data = getFixedLengthList(data, 20 - authUserIDLength); //KeyID 40 - int keyIDLength = utf8.encode(keyID!).length; + final int keyIDLength = utf8.encode(keyID!).length; data.addAll(utf8.encode(keyID!)); data = getFixedLengthList(data, 40 - keyIDLength); //userID 要接受钥匙的用户的useid 20 - int userIDLength = utf8.encode(userID!).length; + final int userIDLength = utf8.encode(userID!).length; data.addAll(utf8.encode(userID!)); data = getFixedLengthList(data, 20 - userIDLength); @@ -128,18 +128,18 @@ class AddUserCommand extends SenderProtocol { data.add((d1! & 0xff000000) >> 24); data.add((d1 & 0xff0000) >> 16); data.add((d1 & 0xff00) >> 8); - data.add((d1 & 0xff)); + data.add(d1 & 0xff); // expireDate 4 data.add((d2! & 0xff000000) >> 24); data.add((d2 & 0xff0000) >> 16); data.add((d2 & 0xff00) >> 8); - data.add((d2 & 0xff)); + data.add(d2 & 0xff); //useCountLimit 2 - double useCountLimitDouble = useCountLimit! / 256; - int useCountLimit1 = useCountLimitDouble.toInt(); - int useCountLimit2 = useCountLimit! % 256; + final double useCountLimitDouble = useCountLimit! / 256; + final int useCountLimit1 = useCountLimitDouble.toInt(); + final int useCountLimit2 = useCountLimit! % 256; data.add(useCountLimit1); data.add(useCountLimit2); @@ -154,7 +154,7 @@ class AddUserCommand extends SenderProtocol { data.add(role!); //password 超级管理员领锁时需验证该密码 20 - int passwordLength = utf8.encode(password!).length; + final int passwordLength = utf8.encode(password!).length; data.addAll(utf8.encode(password!)); data = getFixedLengthList(data, 20 - passwordLength); @@ -165,7 +165,7 @@ class AddUserCommand extends SenderProtocol { //AuthCodeLen 1 data.add(0); } else { - List authCodeData = []; + final List authCodeData = []; //authUserID authCodeData.addAll(utf8.encode(authUserID!)); @@ -179,14 +179,14 @@ class AddUserCommand extends SenderProtocol { authCodeData.addAll(publicKey!); // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode - var authCode = crypto.md5.convert(authCodeData); + final crypto.Digest authCode = crypto.md5.convert(authCodeData); data.add(authCode.bytes.length); data.addAll(authCode.bytes); } if ((data.length % 16) != 0) { - int add = (16 - data.length % 16); + final int add = 16 - data.length % 16; for (int i = 0; i < add; i++) { data.add(0); } diff --git a/lib/blue/io_protocol/io_automaticPadlock.dart b/lib/blue/io_protocol/io_automaticPadlock.dart deleted file mode 100755 index cce2bfaf..00000000 --- a/lib/blue/io_protocol/io_automaticPadlock.dart +++ /dev/null @@ -1,79 +0,0 @@ - -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'; -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; -// subData.addAll(utf8.encode(userID!)); -// subData = getFixedLengthList(subData, 20 - userIDLength); -// -// // autoLockFlag 0:不自动落锁,1:自动落锁 -// subData.add(autoLockFlag!); -// -// 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); -// } -// } -// 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/lib/blue/io_protocol/io_changeAdministratorPassword.dart b/lib/blue/io_protocol/io_changeAdministratorPassword.dart index 095c15c9..17862cfe 100755 --- a/lib/blue/io_protocol/io_changeAdministratorPassword.dart +++ b/lib/blue/io_protocol/io_changeAdministratorPassword.dart @@ -11,21 +11,9 @@ import '../io_sender.dart'; import '../io_type.dart'; import 'package:crypto/crypto.dart' as crypto; -//TODO:修改管理员密码 +// 修改管理员密码 class ChangeAdministratorPasswordCommand extends SenderProtocol { - String? keyID; - String? userID; - int? pwdNo; - String? pwd; - int? useCountLimit; - List? token; - int? startTime; - int? endTime; - int? needAuthor; - List? signKey; - List? privateKey; - ChangeAdministratorPasswordCommand({ this.keyID, this.userID, @@ -40,6 +28,18 @@ class ChangeAdministratorPasswordCommand extends SenderProtocol { this.privateKey, }) : super(CommandType.generalExtendedCommond); + String? keyID; + String? userID; + int? pwdNo; + String? pwd; + int? useCountLimit; + List? token; + int? startTime; + int? endTime; + int? needAuthor; + List? signKey; + List? privateKey; + @override String toString() { @@ -53,9 +53,9 @@ class ChangeAdministratorPasswordCommand extends SenderProtocol { @override List messageDetail() { - List data = []; - List subData = []; - List ebcData = []; + final List data = []; + List subData = []; + List ebcData = []; // 指令类型 // int type = commandType!.typeValue; @@ -70,21 +70,20 @@ class ChangeAdministratorPasswordCommand extends SenderProtocol { data.add(2); // keyID 40 - int keyIDLength = utf8.encode(keyID!).length; + final int keyIDLength = utf8.encode(keyID!).length; subData.addAll(utf8.encode(keyID!)); subData = getFixedLengthList(subData, 40 - keyIDLength); //userID 20 - int userIDLength = utf8.encode(userID!).length; + final int userIDLength = utf8.encode(userID!).length; subData.addAll(utf8.encode(userID!)); subData = getFixedLengthList(subData, 20 - userIDLength); // PwdNo subData.addAll(intChangList(pwdNo!)); - AppLog.log("pwdNo:$pwdNo"); // pwd 20 - int pwdLength = utf8.encode(pwd!).length; + final int pwdLength = utf8.encode(pwd!).length; subData.addAll(utf8.encode(pwd!)); subData = getFixedLengthList(subData, 20 - pwdLength); @@ -98,19 +97,19 @@ class ChangeAdministratorPasswordCommand extends SenderProtocol { subData.add((startTime! & 0xff000000) >> 24); subData.add((startTime! & 0xff0000) >> 16); subData.add((startTime! & 0xff00) >> 8); - subData.add((startTime! & 0xff)); + 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)); + subData.add(endTime! & 0xff); if(needAuthor == 0){ //AuthCodeLen 1 subData.add(0); } else { - List authCodeData = []; + final List authCodeData = []; //KeyID authCodeData.addAll(utf8.encode(keyID!)); @@ -124,7 +123,7 @@ class ChangeAdministratorPasswordCommand extends SenderProtocol { authCodeData.addAll(signKey!); // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode - var authCode = crypto.md5.convert(authCodeData); + final crypto.Digest authCode = crypto.md5.convert(authCodeData); subData.add(authCode.bytes.length); subData.addAll(authCode.bytes); @@ -134,7 +133,7 @@ class ChangeAdministratorPasswordCommand extends SenderProtocol { data.addAll(subData); if ((data.length % 16) != 0) { - int add = (16 - data.length % 16); + final int add = 16 - data.length % 16; for (int i = 0; i < add; i++) { data.add(0); } @@ -151,7 +150,7 @@ class ChangeAdministratorPasswordReply extends Reply { ChangeAdministratorPasswordReply.parseData(CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { data = dataDetail; - int status = data[2]; + final int status = data[2]; errorWithStstus(status); } } \ No newline at end of file diff --git a/lib/blue/io_protocol/io_checkingCardStatus.dart b/lib/blue/io_protocol/io_checkingCardStatus.dart index 2b774f48..21c2a31e 100755 --- a/lib/blue/io_protocol/io_checkingCardStatus.dart +++ b/lib/blue/io_protocol/io_checkingCardStatus.dart @@ -1,5 +1,5 @@ -//TODO:查询指纹状态 +// 查询指纹状态 import 'dart:convert'; import '../../app_settings/app_settings.dart'; @@ -11,17 +11,6 @@ import '../sm4Encipher/sm4.dart'; import 'package:crypto/crypto.dart' as crypto; class SenderCheckingCardStatusCommand extends SenderProtocol { - - String? keyID; - String? userID; - int? role; - int? cardCount; - int? cardNo; - List? token; - int? needAuthor; - List? publicKey; - List? privateKey; - SenderCheckingCardStatusCommand({ this.keyID, this.userID, @@ -34,6 +23,16 @@ class SenderCheckingCardStatusCommand extends SenderProtocol { this.privateKey, }) : super(CommandType.generalExtendedCommond); + String? keyID; + String? userID; + int? role; + int? cardCount; + int? cardNo; + List? token; + int? needAuthor; + List? publicKey; + List? privateKey; + @override String toString() { @@ -44,15 +43,15 @@ class SenderCheckingCardStatusCommand extends SenderProtocol { @override List messageDetail() { - List data = []; - List subData = []; - List ebcData = []; + final List data = []; + List subData = []; + List ebcData = []; // 指令类型 - int type = commandType!.typeValue; - double typeDouble = type / 256; - int type1 = typeDouble.toInt(); - int type2 = type % 256; + final int type = commandType!.typeValue; + final double typeDouble = type / 256; + final int type1 = typeDouble.toInt(); + final int type2 = type % 256; data.add(type1); data.add(type2); @@ -60,12 +59,12 @@ class SenderCheckingCardStatusCommand extends SenderProtocol { data.add(20); // keyID 40 - int keyIDLength = utf8.encode(keyID!).length; + final int keyIDLength = utf8.encode(keyID!).length; subData.addAll(utf8.encode(keyID!)); subData = getFixedLengthList(subData, 40 - keyIDLength); //userID 20 - int userIDLength = utf8.encode(userID!).length; + final int userIDLength = utf8.encode(userID!).length; subData.addAll(utf8.encode(userID!)); subData = getFixedLengthList(subData, 20 - userIDLength); @@ -82,7 +81,7 @@ class SenderCheckingCardStatusCommand extends SenderProtocol { //AuthCodeLen 1 subData.add(0); } else { - List authCodeData = []; + final List authCodeData = []; //authUserID authCodeData.addAll(utf8.encode(userID!)); @@ -96,7 +95,7 @@ class SenderCheckingCardStatusCommand extends SenderProtocol { authCodeData.addAll(publicKey!); // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode - var authCode = crypto.md5.convert(authCodeData); + final crypto.Digest authCode = crypto.md5.convert(authCodeData); subData.add(authCode.bytes.length); subData.addAll(authCode.bytes); @@ -106,7 +105,7 @@ class SenderCheckingCardStatusCommand extends SenderProtocol { data.addAll(subData); if ((data.length % 16) != 0) { - int add = (16 - data.length % 16); + final int add = 16 - data.length % 16; for (int i = 0; i < add; i++) { data.add(0); } diff --git a/lib/blue/io_protocol/io_checkingUserInfoCount.dart b/lib/blue/io_protocol/io_checkingUserInfoCount.dart index 6d229b46..ac2c5d8b 100755 --- a/lib/blue/io_protocol/io_checkingUserInfoCount.dart +++ b/lib/blue/io_protocol/io_checkingUserInfoCount.dart @@ -1,25 +1,17 @@ -//TODO:查询用户、指纹、密码、卡片数量(用于判断是否同步) +// 查询用户、指纹、密码、卡片数量(用于判断是否同步) import 'dart:convert'; +import 'package:crypto/crypto.dart' as crypto; + import '../io_reply.dart'; import '../io_sender.dart'; import '../io_tool/io_tool.dart'; import '../io_type.dart'; import '../sm4Encipher/sm4.dart'; -import 'package:crypto/crypto.dart' as crypto; class SenderCheckingUserInfoCountCommand extends SenderProtocol { - String? keyID; - String? userID; - int? role; - int? nowTime; - List? token; - int? needAuthor; - List? publicKey; - List? privateKey; - SenderCheckingUserInfoCountCommand({ this.keyID, this.userID, @@ -31,6 +23,15 @@ class SenderCheckingUserInfoCountCommand extends SenderProtocol { this.privateKey, }) : super(CommandType.generalExtendedCommond); + String? keyID; + String? userID; + int? role; + int? nowTime; + List? token; + int? needAuthor; + List? publicKey; + List? privateKey; + @override String toString() { @@ -41,15 +42,15 @@ class SenderCheckingUserInfoCountCommand extends SenderProtocol { @override List messageDetail() { - List data = []; - List subData = []; - List ebcData = []; + final List data = []; + List subData = []; + List ebcData = []; // 指令类型 - int type = commandType!.typeValue; - double typeDouble = type / 256; - int type1 = typeDouble.toInt(); - int type2 = type % 256; + final int type = commandType!.typeValue; + final double typeDouble = type / 256; + final int type1 = typeDouble.toInt(); + final int type2 = type % 256; data.add(type1); data.add(type2); @@ -57,12 +58,12 @@ class SenderCheckingUserInfoCountCommand extends SenderProtocol { data.add(15); // keyID 40 - int keyIDLength = utf8.encode(keyID!).length; + final int keyIDLength = utf8.encode(keyID!).length; subData.addAll(utf8.encode(keyID!)); subData = getFixedLengthList(subData, 40 - keyIDLength); //userID 20 - int userIDLength = utf8.encode(userID!).length; + final int userIDLength = utf8.encode(userID!).length; subData.addAll(utf8.encode(userID!)); subData = getFixedLengthList(subData, 20 - userIDLength); @@ -73,7 +74,7 @@ class SenderCheckingUserInfoCountCommand extends SenderProtocol { subData.add((nowTime! & 0xff000000) >> 24); subData.add((nowTime! & 0xff0000) >> 16); subData.add((nowTime! & 0xff00) >> 8); - subData.add((nowTime! & 0xff)); + subData.add(nowTime! & 0xff); // token // subData.addAll(token!); @@ -82,7 +83,7 @@ class SenderCheckingUserInfoCountCommand extends SenderProtocol { //AuthCodeLen 1 subData.add(0); } else { - List authCodeData = []; + final List authCodeData = []; //authUserID authCodeData.addAll(utf8.encode(userID!)); @@ -96,7 +97,7 @@ class SenderCheckingUserInfoCountCommand extends SenderProtocol { authCodeData.addAll(publicKey!); // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode - var authCode = crypto.md5.convert(authCodeData); + final crypto.Digest authCode = crypto.md5.convert(authCodeData); subData.add(authCode.bytes.length); subData.addAll(authCode.bytes); @@ -106,7 +107,7 @@ class SenderCheckingUserInfoCountCommand extends SenderProtocol { data.addAll(subData); if ((data.length % 16) != 0) { - int add = (16 - data.length % 16); + final int add = 16 - data.length % 16; for (int i = 0; i < add; i++) { data.add(0); } @@ -123,7 +124,7 @@ class SenderCheckingUserInfoCountReply extends Reply { SenderCheckingUserInfoCountReply.parseData(CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { data = dataDetail; - int status = data[2]; + final int status = data[2]; errorWithStstus(status); } } \ No newline at end of file diff --git a/lib/blue/io_protocol/io_cleanUpUsers.dart b/lib/blue/io_protocol/io_cleanUpUsers.dart index 2e8fa383..8394eeab 100755 --- a/lib/blue/io_protocol/io_cleanUpUsers.dart +++ b/lib/blue/io_protocol/io_cleanUpUsers.dart @@ -1,30 +1,16 @@ import 'dart:convert'; import 'dart:typed_data'; -import 'package:get/get.dart'; -import 'package:star_lock/tools/dateTool.dart'; +import 'package:crypto/crypto.dart' as crypto; -import '../../app_settings/app_settings.dart'; -import '../io_tool/io_tool.dart'; -import '../sm4Encipher/sm4.dart'; import '../io_reply.dart'; import '../io_sender.dart'; +import '../io_tool/io_tool.dart'; import '../io_type.dart'; -import 'package:crypto/crypto.dart' as crypto; +import '../sm4Encipher/sm4.dart'; //清理用户 class CleanUpUsersCommand extends SenderProtocol { - String? lockID; - String? authUserID; - String? keyID; - String? userID; - - List? userNoList; - List? token; - - int? needAuthor; - List? publicKey; - List? privateKey; CleanUpUsersCommand({ this.lockID, @@ -37,6 +23,17 @@ class CleanUpUsersCommand extends SenderProtocol { this.userNoList, this.token, }) : super(CommandType.cleanUpUsers); + String? lockID; + String? authUserID; + String? keyID; + String? userID; + + List? userNoList; + List? token; + + int? needAuthor; + List? publicKey; + List? privateKey; @override String toString() { @@ -48,40 +45,40 @@ class CleanUpUsersCommand extends SenderProtocol { @override List messageDetail() { - List data = []; - List ebcData = []; + List data = []; + List ebcData = []; // 指令类型 - int type = commandType!.typeValue; - double typeDouble = type / 256; - int type1 = typeDouble.toInt(); - int type2 = type % 256; + final int type = commandType!.typeValue; + final double typeDouble = type / 256; + final int type1 = typeDouble.toInt(); + final int type2 = type % 256; data.add(type1); data.add(type2); // 锁id 40 - int lockIDLength = utf8.encode(lockID!).length; + final int lockIDLength = utf8.encode(lockID!).length; data.addAll(utf8.encode(lockID!)); data = getFixedLengthList(data, 40 - lockIDLength); //authUserID 20 - int authUserIDLength = utf8.encode(authUserID!).length; + final int authUserIDLength = utf8.encode(authUserID!).length; data.addAll(utf8.encode(authUserID!)); data = getFixedLengthList(data, 20 - authUserIDLength); //KeyID 40 - int keyIDLength = utf8.encode(keyID!).length; + final int keyIDLength = utf8.encode(keyID!).length; data.addAll(utf8.encode(keyID!)); data = getFixedLengthList(data, 40 - keyIDLength); //userID 要接受钥匙的用户的useid 20 - int userIDLength = utf8.encode(userID!).length; + final int userIDLength = utf8.encode(userID!).length; data.addAll(utf8.encode(userID!)); data = getFixedLengthList(data, 20 - userIDLength); - ByteData indexBytes = ByteData(2); // 创建一个长度为2的字节数据 + final ByteData indexBytes = ByteData(2); // 创建一个长度为2的字节数据 indexBytes.setInt16(0, userNoList!.length); - List indexList = indexBytes.buffer.asUint8List(); + final List indexList = indexBytes.buffer.asUint8List(); data.addAll(indexList); data.addAll(userNoList!); @@ -93,7 +90,7 @@ class CleanUpUsersCommand extends SenderProtocol { //AuthCodeLen 1 data.add(0); } else { - List authCodeData = []; + final List authCodeData = []; //authUserID authCodeData.addAll(utf8.encode(authUserID!)); @@ -107,14 +104,14 @@ class CleanUpUsersCommand extends SenderProtocol { authCodeData.addAll(publicKey!); // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode - var authCode = crypto.md5.convert(authCodeData); + final crypto.Digest authCode = crypto.md5.convert(authCodeData); data.add(authCode.bytes.length); data.addAll(authCode.bytes); } if ((data.length % 16) != 0) { - int add = (16 - data.length % 16); + final int add = 16 - data.length % 16; for (int i = 0; i < add; i++) { data.add(0); } diff --git a/lib/blue/io_protocol/io_configuringWifi.dart b/lib/blue/io_protocol/io_configuringWifi.dart index a66d61f4..99ac0e29 100755 --- a/lib/blue/io_protocol/io_configuringWifi.dart +++ b/lib/blue/io_protocol/io_configuringWifi.dart @@ -1,29 +1,17 @@ -//TODO:WIFI配网 +// WIFI配网 import 'dart:convert'; +import 'package:crypto/crypto.dart' as crypto; + import '../io_reply.dart'; import '../io_sender.dart'; import '../io_tool/io_tool.dart'; import '../io_type.dart'; import '../sm4Encipher/sm4.dart'; -import 'package:crypto/crypto.dart' as crypto; class SenderConfiguringWifiCommand extends SenderProtocol { - String? keyID; - String? userID; - String? ssid; - String? password; - int? numberOfServers; - List? listOfServers; - int? numberOfPhone; - List? listOfPhone; - List? token; - int? needAuthor; - List? publicKey; - List? privateKey; - SenderConfiguringWifiCommand({ this.keyID, this.userID, @@ -39,6 +27,19 @@ class SenderConfiguringWifiCommand extends SenderProtocol { this.privateKey, }) : super(CommandType.generalExtendedCommond); + String? keyID; + String? userID; + String? ssid; + String? password; + int? numberOfServers; + List? listOfServers; + int? numberOfPhone; + List? listOfPhone; + List? token; + int? needAuthor; + List? publicKey; + List? privateKey; + @override String toString() { @@ -51,15 +52,15 @@ class SenderConfiguringWifiCommand extends SenderProtocol { @override List messageDetail() { - List data = []; - List subData = []; - List ebcData = []; + final List data = []; + List subData = []; + List ebcData = []; // 指令类型 - int type = commandType!.typeValue; - double typeDouble = type / 256; - int type1 = typeDouble.toInt(); - int type2 = type % 256; + final int type = commandType!.typeValue; + final double typeDouble = type / 256; + final int type1 = typeDouble.toInt(); + final int type2 = type % 256; data.add(type1); data.add(type2); @@ -67,22 +68,22 @@ class SenderConfiguringWifiCommand extends SenderProtocol { data.add(50); // keyID 40 - int keyIDLength = utf8.encode(keyID!).length; + final int keyIDLength = utf8.encode(keyID!).length; subData.addAll(utf8.encode(keyID!)); subData = getFixedLengthList(subData, 40 - keyIDLength); //userID 20 - int userIDLength = utf8.encode(userID!).length; + final int userIDLength = utf8.encode(userID!).length; subData.addAll(utf8.encode(userID!)); subData = getFixedLengthList(subData, 20 - userIDLength); //SSID 30 - int ssidLength = utf8.encode(ssid!).length; + final int ssidLength = utf8.encode(ssid!).length; subData.addAll(utf8.encode(ssid!)); subData = getFixedLengthList(subData, 30 - ssidLength); //Password 20 - int passwordLength = utf8.encode(password!).length; + final int passwordLength = utf8.encode(password!).length; subData.addAll(utf8.encode(password!)); subData = getFixedLengthList(subData, 20 - passwordLength); @@ -96,8 +97,8 @@ class SenderConfiguringWifiCommand extends SenderProtocol { subData.add(numberOfPhone!); // listOfPhone - listOfPhone!.forEach((element) { - int phoneLength = utf8.encode(element).length; + listOfPhone!.forEach((String element) { + final int phoneLength = utf8.encode(element).length; subData.addAll(utf8.encode(element)); subData = getFixedLengthList(subData, 20 - phoneLength); }); @@ -109,7 +110,7 @@ class SenderConfiguringWifiCommand extends SenderProtocol { //AuthCodeLen 1 subData.add(0); } else { - List authCodeData = []; + final List authCodeData = []; //userID authCodeData.addAll(utf8.encode(userID!)); @@ -123,7 +124,7 @@ class SenderConfiguringWifiCommand extends SenderProtocol { authCodeData.addAll(publicKey!); // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode - var authCode = crypto.md5.convert(authCodeData); + final crypto.Digest authCode = crypto.md5.convert(authCodeData); subData.add(authCode.bytes.length); subData.addAll(authCode.bytes); @@ -133,7 +134,7 @@ class SenderConfiguringWifiCommand extends SenderProtocol { data.addAll(subData); if ((data.length % 16) != 0) { - int add = (16 - data.length % 16); + final int add = 16 - data.length % 16; for (int i = 0; i < add; i++) { data.add(0); } @@ -150,7 +151,7 @@ class SenderConfiguringWifiReply extends Reply { SenderConfiguringWifiReply.parseData(CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { data = dataDetail; - int status = data[5]; + final int status = data[5]; errorWithStstus(status); } } \ No newline at end of file diff --git a/lib/blue/io_protocol/io_deletUser.dart b/lib/blue/io_protocol/io_deletUser.dart index 21beb7e6..3db8226e 100755 --- a/lib/blue/io_protocol/io_deletUser.dart +++ b/lib/blue/io_protocol/io_deletUser.dart @@ -1,24 +1,16 @@ -//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'; import 'package:crypto/crypto.dart' as crypto; -class DeletUserCommand extends SenderProtocol { +import '../io_reply.dart'; +import '../io_sender.dart'; +import '../io_tool/io_tool.dart'; +import '../io_type.dart'; +import '../sm4Encipher/sm4.dart'; - String? lockID; - String? authUserID; - String? keyID; - String? delUserID; - int? needAuthor; - List? publicKey; - List? privateKey; - List? token; +class DeletUserCommand extends SenderProtocol { DeletUserCommand({ this.lockID, this.authUserID, @@ -30,6 +22,14 @@ class DeletUserCommand extends SenderProtocol { this.token }) : super(CommandType.deletUser); + String? lockID; + String? authUserID; + String? keyID; + String? delUserID; + int? needAuthor; + List? publicKey; + List? privateKey; + List? token; @override String toString() { @@ -40,34 +40,34 @@ class DeletUserCommand extends SenderProtocol { @override List messageDetail() { - List data = []; - List ebcData = []; + List data = []; + List ebcData = []; // 指令类型 - int type = commandType!.typeValue; - double typeDouble = type / 256; - int type1 = typeDouble.toInt(); - int type2 = type % 256; + final int type = commandType!.typeValue; + final double typeDouble = type / 256; + final int type1 = typeDouble.toInt(); + final int type2 = type % 256; data.add(type1); data.add(type2); // 锁id 40 - int lockIDLength = utf8.encode(lockID!).length; + final int lockIDLength = utf8.encode(lockID!).length; data.addAll(utf8.encode(lockID!)); data = getFixedLengthList(data, 40 - lockIDLength); //authUserID 20 - int authUserIDLength = utf8.encode(authUserID!).length; + final int authUserIDLength = utf8.encode(authUserID!).length; data.addAll(utf8.encode(authUserID!)); data = getFixedLengthList(data, 20 - authUserIDLength); //KeyID 40 - int keyIDLength = utf8.encode(keyID!).length; + final int keyIDLength = utf8.encode(keyID!).length; data.addAll(utf8.encode(keyID!)); data = getFixedLengthList(data, 40 - keyIDLength); //delUserID 20 - int delUserIDLength = utf8.encode(delUserID!).length; + final int delUserIDLength = utf8.encode(delUserID!).length; data.addAll(utf8.encode(delUserID!)); data = getFixedLengthList(data, 20 - delUserIDLength); @@ -78,7 +78,7 @@ class DeletUserCommand extends SenderProtocol { //AuthCodeLen 1 data.add(0); } else { - List authCodeData = []; + final List authCodeData = []; //authUserID authCodeData.addAll(utf8.encode(authUserID!)); @@ -92,14 +92,14 @@ class DeletUserCommand extends SenderProtocol { authCodeData.addAll(publicKey!); // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode - var authCode = crypto.md5.convert(authCodeData); + final crypto.Digest authCode = crypto.md5.convert(authCodeData); data.add(authCode.bytes.length); data.addAll(authCode.bytes); } if ((data.length % 16) != 0) { - int add = (16 - data.length % 16); + final int add = 16 - data.length % 16; for (int i = 0; i < add; i++) { data.add(0); } @@ -116,7 +116,7 @@ class DeletUserReply extends Reply { DeletUserReply.parseData(CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { data = dataDetail; - int status = data[6]; + final int status = data[6]; errorWithStstus(status); } } diff --git a/lib/blue/io_protocol/io_editUser.dart b/lib/blue/io_protocol/io_editUser.dart index 97c3361e..dbf24ba7 100755 --- a/lib/blue/io_protocol/io_editUser.dart +++ b/lib/blue/io_protocol/io_editUser.dart @@ -1,33 +1,18 @@ -//TODO:修改用户 +// 修改用户 import 'dart:convert'; +import 'package:crypto/crypto.dart' as crypto; import 'package:star_lock/tools/dateTool.dart'; -import '../io_tool/io_tool.dart'; -import '../sm4Encipher/sm4.dart'; import '../io_reply.dart'; import '../io_sender.dart'; +import '../io_tool/io_tool.dart'; import '../io_type.dart'; -import 'package:crypto/crypto.dart' as crypto; +import '../sm4Encipher/sm4.dart'; class EditUserCommand extends SenderProtocol { - - String? lockID; - String? authUserID; - String? keyID; - String? userID; - int? openMode; - int? keyType; - int? startDate; - int? expireDate; - int? role; - String? password; - int? needAuthor; - List? publicKey; - List? privateKey; - List? token; EditUserCommand({ this.lockID, this.authUserID, @@ -45,6 +30,20 @@ class EditUserCommand extends SenderProtocol { this.token }) : super(CommandType.editUser); + String? lockID; + String? authUserID; + String? keyID; + String? userID; + int? openMode; + int? keyType; + int? startDate; + int? expireDate; + int? role; + String? password; + int? needAuthor; + List? publicKey; + List? privateKey; + List? token; @override String toString() { @@ -60,34 +59,34 @@ class EditUserCommand extends SenderProtocol { @override List messageDetail() { - List data = []; - List ebcData = []; + List data = []; + List ebcData = []; // 指令类型 - int type = commandType!.typeValue; - double typeDouble = type / 256; - int type1 = typeDouble.toInt(); - int type2 = type % 256; + final int type = commandType!.typeValue; + final double typeDouble = type / 256; + final int type1 = typeDouble.toInt(); + final int type2 = type % 256; data.add(type1); data.add(type2); // 锁id 40 - int lockIDLength = utf8.encode(lockID!).length; + final int lockIDLength = utf8.encode(lockID!).length; data.addAll(utf8.encode(lockID!)); data = getFixedLengthList(data, 40 - lockIDLength); //authUserID 20 - int authUserIDLength = utf8.encode(authUserID!).length; + final int authUserIDLength = utf8.encode(authUserID!).length; data.addAll(utf8.encode(authUserID!)); data = getFixedLengthList(data, 20 - authUserIDLength); //KeyID 40 - int keyIDLength = utf8.encode(keyID!).length; + final int keyIDLength = utf8.encode(keyID!).length; data.addAll(utf8.encode(keyID!)); data = getFixedLengthList(data, 40 - keyIDLength); //userID 要接受钥匙的用户的useid 20 - int userIDLength = utf8.encode(userID!).length; + final int userIDLength = utf8.encode(userID!).length; data.addAll(utf8.encode(userID!)); data = getFixedLengthList(data, 20 - userIDLength); @@ -110,19 +109,19 @@ class EditUserCommand extends SenderProtocol { data.add((d1! & 0xff000000) >> 24); data.add((d1 & 0xff0000) >> 16); data.add((d1 & 0xff00) >> 8); - data.add((d1 & 0xff)); + data.add(d1 & 0xff); // expireDate 4 data.add((d2! & 0xff000000) >> 24); data.add((d2 & 0xff0000) >> 16); data.add((d2 & 0xff00) >> 8); - data.add((d2 & 0xff)); + data.add(d2 & 0xff); // role 长度1 用户角色,0:普通用户,1:管理员,0xff:超级管理员 data.add(role!); //password 超级管理员领锁时需验证该密码 20 - int passwordLength = utf8.encode(password!).length; + final int passwordLength = utf8.encode(password!).length; data.addAll(utf8.encode(password!)); data = getFixedLengthList(data, 20 - passwordLength); @@ -133,7 +132,7 @@ class EditUserCommand extends SenderProtocol { //AuthCodeLen 1 data.add(0); } else { - List authCodeData = []; + final List authCodeData = []; //authUserID authCodeData.addAll(utf8.encode(authUserID!)); @@ -147,14 +146,14 @@ class EditUserCommand extends SenderProtocol { authCodeData.addAll(publicKey!); // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode - var authCode = crypto.md5.convert(authCodeData); + final crypto.Digest authCode = crypto.md5.convert(authCodeData); data.add(authCode.bytes.length); data.addAll(authCode.bytes); } if ((data.length % 16) != 0) { - int add = (16 - data.length % 16); + final int add = 16 - data.length % 16; for (int i = 0; i < add; i++) { data.add(0); } diff --git a/lib/blue/io_protocol/io_factoryDataReset.dart b/lib/blue/io_protocol/io_factoryDataReset.dart index a2108cf8..cf495bbf 100755 --- a/lib/blue/io_protocol/io_factoryDataReset.dart +++ b/lib/blue/io_protocol/io_factoryDataReset.dart @@ -1,5 +1,5 @@ -//TODO:恢复出厂设置 +// 恢复出厂设置 import 'dart:convert'; import 'package:crypto/crypto.dart' as crypto; @@ -11,14 +11,6 @@ import '../io_type.dart'; import '../sm4Encipher/sm4.dart'; class FactoryDataResetCommand extends SenderProtocol { - - String? lockID; - String? userID; - String? keyID; - List? publicKey; - List? privateKey; - List? token; - int? needAuthor; FactoryDataResetCommand({ this.lockID, this.userID, @@ -29,6 +21,13 @@ class FactoryDataResetCommand extends SenderProtocol { this.privateKey, }) : super(CommandType.factoryDataReset); + String? lockID; + String? userID; + String? keyID; + List? publicKey; + List? privateKey; + List? token; + int? needAuthor; @override String toString() { @@ -39,24 +38,24 @@ class FactoryDataResetCommand extends SenderProtocol { @override List messageDetail() { - List data = []; - List ebcData = []; + List data = []; + List ebcData = []; // 指令类型 - int type = commandType!.typeValue; - double typeDouble = type / 256; - int type1 = typeDouble.toInt(); - int type2 = type % 256; + final int type = commandType!.typeValue; + final double typeDouble = type / 256; + final int type1 = typeDouble.toInt(); + final int type2 = type % 256; data.add(type1); data.add(type2); // 锁id 40 - int lockIDLength = utf8.encode(lockID!).length; + final int lockIDLength = utf8.encode(lockID!).length; data.addAll(utf8.encode(lockID!)); data = getFixedLengthList(data, 40 - lockIDLength); //userID 20 - int userIDLength = utf8.encode(userID!).length; + final int userIDLength = utf8.encode(userID!).length; data.addAll(utf8.encode(userID!)); data = getFixedLengthList(data, 20 - userIDLength); @@ -67,7 +66,7 @@ class FactoryDataResetCommand extends SenderProtocol { //AuthCodeLen 1 data.add(0); } else { - List authCodeData = []; + final List authCodeData = []; //userID authCodeData.addAll(utf8.encode(lockID!)); @@ -78,14 +77,14 @@ class FactoryDataResetCommand extends SenderProtocol { authCodeData.addAll(publicKey!); // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode - var authCode = crypto.md5.convert(authCodeData); + final crypto.Digest authCode = crypto.md5.convert(authCodeData); data.add(authCode.bytes.length); data.addAll(authCode.bytes); } if ((data.length % 16) != 0) { - int add = (16 - data.length % 16); + final int add = 16 - data.length % 16; for (int i = 0; i < add; i++) { data.add(0); } @@ -102,7 +101,7 @@ class FactoryDataResetReply extends Reply { FactoryDataResetReply.parseData(CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { data = dataDetail; - int status = data[6]; + final int status = data[6]; errorWithStstus(status); } } \ No newline at end of file diff --git a/lib/blue/io_protocol/io_gateway_configuringWifi.dart b/lib/blue/io_protocol/io_gateway_configuringWifi.dart index 31fbcd96..05d0f518 100644 --- a/lib/blue/io_protocol/io_gateway_configuringWifi.dart +++ b/lib/blue/io_protocol/io_gateway_configuringWifi.dart @@ -6,8 +6,6 @@ import '../io_reply.dart'; import '../io_sender.dart'; import '../io_tool/io_tool.dart'; import '../io_type.dart'; -// import '../sm4Encipher/sm4.dart'; -// import 'package:crypto/crypto.dart' as crypto; class GatewayConfiguringWifiCommand extends SenderProtocol { diff --git a/lib/blue/io_protocol/io_gateway_getStatus.dart b/lib/blue/io_protocol/io_gateway_getStatus.dart index 6b624a65..11b5a6b1 100644 --- a/lib/blue/io_protocol/io_gateway_getStatus.dart +++ b/lib/blue/io_protocol/io_gateway_getStatus.dart @@ -6,8 +6,6 @@ import '../io_reply.dart'; import '../io_sender.dart'; import '../io_tool/io_tool.dart'; import '../io_type.dart'; -// import '../sm4Encipher/sm4.dart'; -// import 'package:crypto/crypto.dart' as crypto; class GatewayGetStatusCommand extends SenderProtocol { diff --git a/lib/blue/io_protocol/io_gateway_getWifiList.dart b/lib/blue/io_protocol/io_gateway_getWifiList.dart index 739a3622..5b200bac 100644 --- a/lib/blue/io_protocol/io_gateway_getWifiList.dart +++ b/lib/blue/io_protocol/io_gateway_getWifiList.dart @@ -8,7 +8,6 @@ import '../io_reply.dart'; import '../io_sender.dart'; import '../io_tool/io_tool.dart'; import '../io_type.dart'; -// import '../sm4Encipher/sm4.dart'; class GatewayGetWifiCommand extends SenderProtocol { diff --git a/lib/blue/io_protocol/io_getLockStatu.dart b/lib/blue/io_protocol/io_getLockStatu.dart deleted file mode 100755 index cbea6f1e..00000000 --- a/lib/blue/io_protocol/io_getLockStatu.dart +++ /dev/null @@ -1,117 +0,0 @@ - -///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; -// data.addAll(utf8.encode(lockID!)); -// data = getFixedLengthList(data, 40 - lockIDLength); -// -// //userID 要接受钥匙的用户的useid 20 -// int userIDLength = utf8.encode(userID!).length; -// 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); -// } -// } -// // 拿到数据之后通过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); -// -// var power = data[7]; -// -// // APP 用户数量 -// var appUserCount = data.sublist(50, 53); -// -// // 黑名单用户数量 -// var blacklistCount = data[53]; -// -// // 蓝牙钥匙数量 -// var bleKeyCount = data[54]; -// -// // 剩余可添加用户数量 -// var remainCount = data.sublist(54, 56); -// -// // 未上传开锁记录数量 -// var notUploadCount = data.sublist(56, 58); -// -// // 已设置开门密码数量 -// var pwdCount = data[58]; -// -// // 已设置开门指纹数量 -// var fingerprintCount = data[59]; -// -// // 锁当前时间 -// var lockTime = data.sublist(60, 64); -// -// // 硬件版本信息,为固件升级提供判断依据 -// var hardVersion = data.sublist(64, 68); -// break; -// case 0x06: -// //无权限 -// -// break; -// case 0x07: -// //无权限 -// -// break; -// case 0x09: -// // 权限校验错误 -// -// break; -// default: -// //失败 -// -// break; -// } -// } -// } \ No newline at end of file diff --git a/lib/blue/io_protocol/io_getPrivateKey.dart b/lib/blue/io_protocol/io_getPrivateKey.dart index 29fde17a..757eb96e 100755 --- a/lib/blue/io_protocol/io_getPrivateKey.dart +++ b/lib/blue/io_protocol/io_getPrivateKey.dart @@ -11,16 +11,9 @@ import '../io_sender.dart'; import '../io_tool/io_tool.dart'; import '../io_type.dart'; -List publicKeyDataList = []; +List publicKeyDataList = []; class GetPrivateKeyCommand extends SenderProtocol { - String? lockID; - String? keyID; // 钥匙ID - String? authUserID; // 钥匙授权人ID - int? nowTime; - int? needAuthor; - List? publicKeyData; - GetPrivateKeyCommand( {this.lockID, this.keyID, @@ -29,6 +22,12 @@ class GetPrivateKeyCommand extends SenderProtocol { this.needAuthor, this.publicKeyData}) : super(CommandType.getLockPrivateKey); + String? lockID; + String? keyID; // 钥匙ID + String? authUserID; // 钥匙授权人ID + int? nowTime; + int? needAuthor; + List? publicKeyData; @override String toString() { @@ -40,8 +39,8 @@ class GetPrivateKeyCommand extends SenderProtocol { @override List messageDetail() { publicKeyDataList = publicKeyData!; - List data = []; - List ebcData = []; + List data = []; + List ebcData = []; // 指令类型 final int type = commandType!.typeValue; @@ -67,9 +66,6 @@ class GetPrivateKeyCommand extends SenderProtocol { data = getFixedLengthList(data, 20 - authUserIDLength); //NowTime 4 - // DateTime now = DateTime.now(); - // int timestamp = now.millisecondsSinceEpoch; - // var d1 = 0x11223344; data.add((nowTime! & 0xff000000) >> 24); data.add((nowTime! & 0xff0000) >> 16); data.add((nowTime! & 0xff00) >> 8); @@ -78,7 +74,7 @@ class GetPrivateKeyCommand extends SenderProtocol { if (needAuthor == 0) { data.add(0); } else { - final List authCodeData = []; + final List authCodeData = []; //authUserID authCodeData.addAll(utf8.encode(authUserID!)); @@ -87,9 +83,6 @@ class GetPrivateKeyCommand extends SenderProtocol { authCodeData.addAll(utf8.encode(keyID!)); //NowTime 4 - // DateTime now = DateTime.now(); - // int timestamp = now.millisecondsSinceEpoch; - // var d1 = 0x11223344; authCodeData.add((nowTime! & 0xff000000) >> 24); authCodeData.add((nowTime! & 0xff0000) >> 16); authCodeData.add((nowTime! & 0xff00) >> 8); @@ -98,7 +91,7 @@ class GetPrivateKeyCommand extends SenderProtocol { authCodeData.addAll(publicKeyData!); // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode - final authCode = crypto.md5.convert(authCodeData); + final crypto.Digest authCode = crypto.md5.convert(authCodeData); data.add(authCode.bytes.length); data.addAll(authCode.bytes); diff --git a/lib/blue/io_protocol/io_getWifiList.dart b/lib/blue/io_protocol/io_getWifiList.dart index 74fe1e0f..b01c9251 100755 --- a/lib/blue/io_protocol/io_getWifiList.dart +++ b/lib/blue/io_protocol/io_getWifiList.dart @@ -10,14 +10,6 @@ import '../io_type.dart'; import '../sm4Encipher/sm4.dart'; class SenderGetWifiCommand extends SenderProtocol { - - String? keyID; - String? userID; - List? token; - int? needAuthor; - List? publicKey; - List? privateKey; - SenderGetWifiCommand({ this.keyID, this.userID, @@ -27,6 +19,12 @@ class SenderGetWifiCommand extends SenderProtocol { this.privateKey, }) : super(CommandType.generalExtendedCommond); + String? keyID; + String? userID; + List? token; + int? needAuthor; + List? publicKey; + List? privateKey; @override String toString() { @@ -37,15 +35,15 @@ class SenderGetWifiCommand extends SenderProtocol { @override List messageDetail() { - List data = []; - List subData = []; - List ebcData = []; + final List data = []; + List subData = []; + List ebcData = []; // 指令类型 - int type = commandType!.typeValue; - double typeDouble = type / 256; - int type1 = typeDouble.toInt(); - int type2 = type % 256; + final int type = commandType!.typeValue; + final double typeDouble = type / 256; + final int type1 = typeDouble.toInt(); + final int type2 = type % 256; data.add(type1); data.add(type2); @@ -53,23 +51,19 @@ class SenderGetWifiCommand extends SenderProtocol { data.add(53); // keyID 40 - int keyIDLength = utf8.encode(keyID!).length; + final int keyIDLength = utf8.encode(keyID!).length; subData.addAll(utf8.encode(keyID!)); subData = getFixedLengthList(subData, 40 - keyIDLength); //userID 20 - int userIDLength = utf8.encode(userID!).length; + final int userIDLength = utf8.encode(userID!).length; subData.addAll(utf8.encode(userID!)); subData = getFixedLengthList(subData, 20 - userIDLength); - // token - // subData.addAll(token!); - if(needAuthor == 0){ - //AuthCodeLen 1 subData.add(0); } else { - List authCodeData = []; + final List authCodeData = []; //userID authCodeData.addAll(utf8.encode(userID!)); @@ -83,7 +77,7 @@ class SenderGetWifiCommand extends SenderProtocol { authCodeData.addAll(publicKey!); // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode - var authCode = crypto.md5.convert(authCodeData); + final crypto.Digest authCode = crypto.md5.convert(authCodeData); subData.add(authCode.bytes.length); subData.addAll(authCode.bytes); @@ -93,7 +87,7 @@ class SenderGetWifiCommand extends SenderProtocol { data.addAll(subData); if ((data.length % 16) != 0) { - int add = (16 - data.length % 16); + final int add = 16 - data.length % 16; for (int i = 0; i < add; i++) { data.add(0); } @@ -110,7 +104,7 @@ class SenderGetWifiReply extends Reply { SenderGetWifiReply.parseData(CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { data = dataDetail; - int status = data[2]; + final int status = data[2]; errorWithStstus(status); } } diff --git a/lib/blue/io_protocol/io_openLock.dart b/lib/blue/io_protocol/io_openLock.dart index a0e89e70..22d914da 100755 --- a/lib/blue/io_protocol/io_openLock.dart +++ b/lib/blue/io_protocol/io_openLock.dart @@ -10,17 +10,8 @@ import '../io_tool/io_tool.dart'; import '../io_type.dart'; import '../sm4Encipher/sm4.dart'; -//TODO:开门 +// 开门 class OpenLockCommand extends SenderProtocol { - String? lockID; - String? userID; - int? openMode; - int? openTime; - String? onlineToken; - List? token; - int? needAuthor; - List? signKey; - List? privateKey; OpenLockCommand({ this.lockID, this.userID, @@ -32,6 +23,15 @@ class OpenLockCommand extends SenderProtocol { this.signKey, this.privateKey }) : super(CommandType.openLock); + String? lockID; + String? userID; + int? openMode; + int? openTime; + String? onlineToken; + List? token; + int? needAuthor; + List? signKey; + List? privateKey; @override @@ -44,8 +44,8 @@ class OpenLockCommand extends SenderProtocol { @override List messageDetail() { - List data = []; - List ebcData = []; + List data = []; + List ebcData = []; // 指令类型 final int type = commandType!.typeValue; @@ -84,7 +84,7 @@ class OpenLockCommand extends SenderProtocol { //AuthCodeLen 1 data.add(0); } else { - final List authCodeData = []; + final List authCodeData = []; //KeyID authCodeData.addAll(utf8.encode(lockID!)); @@ -97,7 +97,7 @@ class OpenLockCommand extends SenderProtocol { authCodeData.addAll(signKey!); // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode - final authCode = crypto.md5.convert(authCodeData); + final crypto.Digest authCode = crypto.md5.convert(authCodeData); data.add(authCode.bytes.length); data.addAll(authCode.bytes); diff --git a/lib/blue/io_protocol/io_otaUpgrade.dart b/lib/blue/io_protocol/io_otaUpgrade.dart index e8341347..deaccf8d 100755 --- a/lib/blue/io_protocol/io_otaUpgrade.dart +++ b/lib/blue/io_protocol/io_otaUpgrade.dart @@ -1,32 +1,17 @@ + import 'dart:convert'; import 'dart:typed_data'; -import 'package:get/get.dart'; +import 'package:crypto/crypto.dart' as crypto; -import '../../app_settings/app_settings.dart'; -import '../io_tool/io_tool.dart'; -import '../sm4Encipher/sm4.dart'; import '../io_reply.dart'; import '../io_sender.dart'; +import '../io_tool/io_tool.dart'; import '../io_type.dart'; -import 'package:crypto/crypto.dart' as crypto; +import '../sm4Encipher/sm4.dart'; //oat升级 class OTAUpgradeCommand extends SenderProtocol { - String? lockID; - String? userID; - String? keyID; - int? platform; - int? product; - String? hwVersion; - String? fwVersion; - int? fwSize; - String? fwMD5; - int? needAuthor; - List? signKey; - List? privateKey; - List? token; - bool encrypt; OTAUpgradeCommand( {this.lockID, @@ -44,6 +29,20 @@ class OTAUpgradeCommand extends SenderProtocol { this.token, this.encrypt = true}) : super(CommandType.startOATUpgrade); + String? lockID; + String? userID; + String? keyID; + int? platform; + int? product; + String? hwVersion; + String? fwVersion; + int? fwSize; + String? fwMD5; + int? needAuthor; + List? signKey; + List? privateKey; + List? token; + bool encrypt; @override String toString() { @@ -93,10 +92,6 @@ class OTAUpgradeCommand extends SenderProtocol { data.add(platform1); //product 2 - // int product0 = (product! & 0xFF00) >> 8; - // int product1 = product! & 0xFF; - // data.add(product0); - // data.add(product1); data.addAll([0, 1]); //先默认是 01 //HwVersion 20 @@ -170,8 +165,6 @@ class OTAUpgradeCommand extends SenderProtocol { } class OTAUpgradeReply extends Reply { - List token = []; - OTAUpgradeReply.parseData(CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { data = dataDetail; @@ -179,4 +172,5 @@ class OTAUpgradeReply extends Reply { status = data[6]; errorWithStstus(status); } + List token = []; } diff --git a/lib/blue/io_protocol/io_processOtaUpgrade.dart b/lib/blue/io_protocol/io_processOtaUpgrade.dart index ded7091a..8bfa74fc 100755 --- a/lib/blue/io_protocol/io_processOtaUpgrade.dart +++ b/lib/blue/io_protocol/io_processOtaUpgrade.dart @@ -1,26 +1,20 @@ -import 'dart:convert'; import 'dart:typed_data'; -import 'package:get/get.dart'; - -import '../io_tool/io_tool.dart'; -import '../sm4Encipher/sm4.dart'; import '../io_reply.dart'; import '../io_sender.dart'; import '../io_type.dart'; -import 'package:crypto/crypto.dart' as crypto; //oat升级 class ProcessOtaUpgradeCommand extends SenderProtocol { - int? index; - int? size; - List? data; ProcessOtaUpgradeCommand({ this.index, this.size, this.data, }) : super(CommandType.processOTAUpgrade); + int? index; + int? size; + List? data; @override @@ -30,26 +24,26 @@ class ProcessOtaUpgradeCommand extends SenderProtocol { @override List messageDetail() { - List data = []; + final List data = []; // 指令类型 - int type = commandType!.typeValue; - double typeDouble = type / 256; - int type1 = typeDouble.toInt(); - int type2 = type % 256; + final int type = commandType!.typeValue; + final double typeDouble = type / 256; + final int type1 = typeDouble.toInt(); + final int type2 = type % 256; data.add(type1); data.add(type2); //index 2 - ByteData indexBytes = ByteData(2); // 创建一个长度为4的字节数据 + final ByteData indexBytes = ByteData(2); // 创建一个长度为4的字节数据 indexBytes.setInt16(0, index!); - List indexList = indexBytes.buffer.asUint8List(); + final List indexList = indexBytes.buffer.asUint8List(); data.addAll(indexList); //size 2 - ByteData bytes = ByteData(2); // 创建一个长度为4的字节数据 + final ByteData bytes = ByteData(2); // 创建一个长度为4的字节数据 bytes.setInt16(0, size!); - List byteList = bytes.buffer.asUint8List(); + final List byteList = bytes.buffer.asUint8List(); data.addAll(byteList); data.addAll(this.data!); diff --git a/lib/blue/io_protocol/io_queryingFaceStatus.dart b/lib/blue/io_protocol/io_queryingFaceStatus.dart index fe2b24eb..82d0869f 100755 --- a/lib/blue/io_protocol/io_queryingFaceStatus.dart +++ b/lib/blue/io_protocol/io_queryingFaceStatus.dart @@ -1,24 +1,16 @@ -//TODO:查询人脸状态 + +// 查询人脸状态 import 'dart:convert'; +import 'package:crypto/crypto.dart' as crypto; import '../io_reply.dart'; import '../io_sender.dart'; import '../io_tool/io_tool.dart'; import '../io_type.dart'; import '../sm4Encipher/sm4.dart'; -import 'package:crypto/crypto.dart' as crypto; class SenderQueryingFaceStatusCommand extends SenderProtocol { - String? keyID; - String? userID; - int? role; - int? faceCount; - int? faceNo; - List? token; - int? needAuthor; - List? publicKey; - List? privateKey; SenderQueryingFaceStatusCommand({ this.keyID, @@ -31,6 +23,15 @@ class SenderQueryingFaceStatusCommand extends SenderProtocol { this.publicKey, this.privateKey, }) : super(CommandType.generalExtendedCommond); + String? keyID; + String? userID; + int? role; + int? faceCount; + int? faceNo; + List? token; + int? needAuthor; + List? publicKey; + List? privateKey; @override @@ -42,15 +43,15 @@ class SenderQueryingFaceStatusCommand extends SenderProtocol { @override List messageDetail() { - List data = []; - List subData = []; - List ebcData = []; + final List data = []; + List subData = []; + List ebcData = []; // 指令类型 - int type = commandType!.typeValue; - double typeDouble = type / 256; - int type1 = typeDouble.toInt(); - int type2 = type % 256; + final int type = commandType!.typeValue; + final double typeDouble = type / 256; + final int type1 = typeDouble.toInt(); + final int type2 = type % 256; data.add(type1); data.add(type2); @@ -58,12 +59,12 @@ class SenderQueryingFaceStatusCommand extends SenderProtocol { data.add(80); // keyID 40 - int keyIDLength = utf8.encode(keyID!).length; + final int keyIDLength = utf8.encode(keyID!).length; subData.addAll(utf8.encode(keyID!)); subData = getFixedLengthList(subData, 40 - keyIDLength); //userID 20 - int userIDLength = utf8.encode(userID!).length; + final int userIDLength = utf8.encode(userID!).length; subData.addAll(utf8.encode(userID!)); subData = getFixedLengthList(subData, 20 - userIDLength); @@ -80,7 +81,7 @@ class SenderQueryingFaceStatusCommand extends SenderProtocol { //AuthCodeLen 1 subData.add(0); } else { - List authCodeData = []; + final List authCodeData = []; //authUserID authCodeData.addAll(utf8.encode(userID!)); @@ -94,7 +95,7 @@ class SenderQueryingFaceStatusCommand extends SenderProtocol { authCodeData.addAll(publicKey!); // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode - var authCode = crypto.md5.convert(authCodeData); + final crypto.Digest authCode = crypto.md5.convert(authCodeData); subData.add(authCode.bytes.length); subData.addAll(authCode.bytes); @@ -104,7 +105,7 @@ class SenderQueryingFaceStatusCommand extends SenderProtocol { data.addAll(subData); if ((data.length % 16) != 0) { - int add = (16 - data.length % 16); + final int add = 16 - data.length % 16; for (int i = 0; i < add; i++) { data.add(0); } @@ -121,7 +122,7 @@ class SenderQueryingFaceStatusReply extends Reply { CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { data = dataDetail; - int status = data[2]; + final int status = data[2]; errorWithStstus(status); } } diff --git a/lib/blue/io_protocol/io_queryingFingerprintStatus.dart b/lib/blue/io_protocol/io_queryingFingerprintStatus.dart index 8e9f546c..f35646f0 100755 --- a/lib/blue/io_protocol/io_queryingFingerprintStatus.dart +++ b/lib/blue/io_protocol/io_queryingFingerprintStatus.dart @@ -1,26 +1,17 @@ -//TODO:查询指纹状态 +// 查询指纹状态 import 'dart:convert'; +import 'package:crypto/crypto.dart' as crypto; + import '../io_reply.dart'; import '../io_sender.dart'; import '../io_tool/io_tool.dart'; import '../io_type.dart'; import '../sm4Encipher/sm4.dart'; -import 'package:crypto/crypto.dart' as crypto; class SenderQueryingFingerprintStatusCommand extends SenderProtocol { - String? keyID; - String? userID; - int? role; - int? fingerCount; - int? fingerNo; - List? token; - int? needAuthor; - List? publicKey; - List? privateKey; - SenderQueryingFingerprintStatusCommand({ this.keyID, this.userID, @@ -33,6 +24,15 @@ class SenderQueryingFingerprintStatusCommand extends SenderProtocol { this.privateKey, }) : super(CommandType.generalExtendedCommond); + String? keyID; + String? userID; + int? role; + int? fingerCount; + int? fingerNo; + List? token; + int? needAuthor; + List? publicKey; + List? privateKey; @override String toString() { @@ -44,15 +44,15 @@ class SenderQueryingFingerprintStatusCommand extends SenderProtocol { @override List messageDetail() { - List data = []; - List subData = []; - List ebcData = []; + final List data = []; + List subData = []; + List ebcData = []; // 指令类型 - int type = commandType!.typeValue; - double typeDouble = type / 256; - int type1 = typeDouble.toInt(); - int type2 = type % 256; + final int type = commandType!.typeValue; + final double typeDouble = type / 256; + final int type1 = typeDouble.toInt(); + final int type2 = type % 256; data.add(type1); data.add(type2); @@ -60,12 +60,12 @@ class SenderQueryingFingerprintStatusCommand extends SenderProtocol { data.add(30); // keyID 40 - int keyIDLength = utf8.encode(keyID!).length; + final int keyIDLength = utf8.encode(keyID!).length; subData.addAll(utf8.encode(keyID!)); subData = getFixedLengthList(subData, 40 - keyIDLength); //userID 20 - int userIDLength = utf8.encode(userID!).length; + final int userIDLength = utf8.encode(userID!).length; subData.addAll(utf8.encode(userID!)); subData = getFixedLengthList(subData, 20 - userIDLength); @@ -82,7 +82,7 @@ class SenderQueryingFingerprintStatusCommand extends SenderProtocol { //AuthCodeLen 1 subData.add(0); } else { - List authCodeData = []; + final List authCodeData = []; //authUserID authCodeData.addAll(utf8.encode(userID!)); @@ -96,7 +96,7 @@ class SenderQueryingFingerprintStatusCommand extends SenderProtocol { authCodeData.addAll(publicKey!); // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode - var authCode = crypto.md5.convert(authCodeData); + final crypto.Digest authCode = crypto.md5.convert(authCodeData); subData.add(authCode.bytes.length); subData.addAll(authCode.bytes); @@ -106,7 +106,7 @@ class SenderQueryingFingerprintStatusCommand extends SenderProtocol { data.addAll(subData); if ((data.length % 16) != 0) { - int add = (16 - data.length % 16); + final int add = 16 - data.length % 16; for (int i = 0; i < add; i++) { data.add(0); } @@ -123,7 +123,7 @@ class SenderQueryingFingerprintStatusReply extends Reply { SenderQueryingFingerprintStatusReply.parseData(CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { data = dataDetail; - int status = data[2]; + final int status = data[2]; errorWithStstus(status); } } \ No newline at end of file diff --git a/lib/blue/io_protocol/io_readAdminPassword.dart b/lib/blue/io_protocol/io_readAdminPassword.dart index 5c020815..62560323 100755 --- a/lib/blue/io_protocol/io_readAdminPassword.dart +++ b/lib/blue/io_protocol/io_readAdminPassword.dart @@ -8,19 +8,8 @@ import '../io_sender.dart'; import '../io_type.dart'; import 'package:crypto/crypto.dart' as crypto; -///TODO:读取管理员密码 +/// 读取管理员密码 class SenderReadAdminPasswordCommand extends SenderProtocol { - - String? keyID; - String? userID; - int? role; - int? pwdNum; - int? pwdNo; - List? token; - int? needAuthor; - List? publicKey; - List? privateKey; - SenderReadAdminPasswordCommand({ this.keyID, this.userID, @@ -33,6 +22,15 @@ class SenderReadAdminPasswordCommand extends SenderProtocol { this.privateKey, }) : super(CommandType.generalExtendedCommond); + String? keyID; + String? userID; + int? role; + int? pwdNum; + int? pwdNo; + List? token; + int? needAuthor; + List? publicKey; + List? privateKey; @override String toString() { @@ -44,15 +42,15 @@ class SenderReadAdminPasswordCommand extends SenderProtocol { @override List messageDetail() { - List data = []; - List subData = []; - List ebcData = []; + final List data = []; + List subData = []; + List ebcData = []; // 指令类型 - int type = commandType!.typeValue; - double typeDouble = type / 256; - int type1 = typeDouble.toInt(); - int type2 = type % 256; + final int type = commandType!.typeValue; + final double typeDouble = type / 256; + final int type1 = typeDouble.toInt(); + final int type2 = type % 256; data.add(type1); data.add(type2); @@ -60,12 +58,12 @@ class SenderReadAdminPasswordCommand extends SenderProtocol { data.add(74); // keyID 40 - int keyIDLength = utf8.encode(keyID!).length; + final int keyIDLength = utf8.encode(keyID!).length; subData.addAll(utf8.encode(keyID!)); subData = getFixedLengthList(subData, 40 - keyIDLength); //userID 20 - int userIDLength = utf8.encode(userID!).length; + final int userIDLength = utf8.encode(userID!).length; subData.addAll(utf8.encode(userID!)); subData = getFixedLengthList(subData, 20 - userIDLength); @@ -82,7 +80,7 @@ class SenderReadAdminPasswordCommand extends SenderProtocol { //AuthCodeLen 1 subData.add(0); } else { - List authCodeData = []; + final List authCodeData = []; //authUserID authCodeData.addAll(utf8.encode(userID!)); @@ -96,7 +94,7 @@ class SenderReadAdminPasswordCommand extends SenderProtocol { authCodeData.addAll(publicKey!); // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode - var authCode = crypto.md5.convert(authCodeData); + final crypto.Digest authCode = crypto.md5.convert(authCodeData); subData.add(authCode.bytes.length); subData.addAll(authCode.bytes); @@ -106,7 +104,7 @@ class SenderReadAdminPasswordCommand extends SenderProtocol { data.addAll(subData); if ((data.length % 16) != 0) { - int add = (16 - data.length % 16); + final int add = 16 - data.length % 16; for (int i = 0; i < add; i++) { data.add(0); } @@ -124,7 +122,7 @@ class SenderReadAdminPasswordReply extends Reply { : super.parseData(commandType, dataDetail) { data = dataDetail; - int status = data[2]; + final int status = data[2]; errorWithStstus(status); } } diff --git a/lib/blue/io_protocol/io_readSupportFunctionsNoParameters.dart b/lib/blue/io_protocol/io_readSupportFunctionsNoParameters.dart index cadd430e..d79cb100 100755 --- a/lib/blue/io_protocol/io_readSupportFunctionsNoParameters.dart +++ b/lib/blue/io_protocol/io_readSupportFunctionsNoParameters.dart @@ -12,17 +12,8 @@ import 'package:crypto/crypto.dart' as crypto; import '../sm4Encipher/sm4.dart'; -///TODO:读取支持功能(不带参数)启用/禁用 +/// 读取支持功能(不带参数)启用/禁用 class ReadSupportFunctionsNoParametersCommand extends SenderProtocol { - - String? keyID; - String? userID; - int? featureBit; - List? token; - int? needAuthor; - List? publicKey; - List? privateKey; - ReadSupportFunctionsNoParametersCommand({ this.keyID, this.userID, @@ -33,6 +24,13 @@ class ReadSupportFunctionsNoParametersCommand extends SenderProtocol { this.privateKey, }) : super(CommandType.generalExtendedCommond); + String? keyID; + String? userID; + int? featureBit; + List? token; + int? needAuthor; + List? publicKey; + List? privateKey; @override String toString() { @@ -44,15 +42,15 @@ class ReadSupportFunctionsNoParametersCommand extends SenderProtocol { @override List messageDetail() { - List data = []; - List subData = []; - List ebcData = []; + final List data = []; + List subData = []; + List ebcData = []; // 指令类型 - int type = commandType!.typeValue; - double typeDouble = type / 256; - int type1 = typeDouble.toInt(); - int type2 = type % 256; + final int type = commandType!.typeValue; + final double typeDouble = type / 256; + final int type1 = typeDouble.toInt(); + final int type2 = type % 256; data.add(type1); data.add(type2); @@ -60,12 +58,12 @@ class ReadSupportFunctionsNoParametersCommand extends SenderProtocol { data.add(71); // keyID 40 - int keyIDLength = utf8.encode(keyID!).length; + final int keyIDLength = utf8.encode(keyID!).length; subData.addAll(utf8.encode(keyID!)); subData = getFixedLengthList(subData, 40 - keyIDLength); //userID 20 - int userIDLength = utf8.encode(userID!).length; + final int userIDLength = utf8.encode(userID!).length; subData.addAll(utf8.encode(userID!)); subData = getFixedLengthList(subData, 20 - userIDLength); @@ -76,7 +74,7 @@ class ReadSupportFunctionsNoParametersCommand extends SenderProtocol { //AuthCodeLen 1 subData.add(0); } else { - List authCodeData = []; + final List authCodeData = []; //authUserID authCodeData.addAll(utf8.encode(userID!)); @@ -90,7 +88,7 @@ class ReadSupportFunctionsNoParametersCommand extends SenderProtocol { authCodeData.addAll(publicKey!); // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode - var authCode = crypto.md5.convert(authCodeData); + final crypto.Digest authCode = crypto.md5.convert(authCodeData); subData.add(authCode.bytes.length); subData.addAll(authCode.bytes); @@ -100,7 +98,7 @@ class ReadSupportFunctionsNoParametersCommand extends SenderProtocol { data.addAll(subData); if ((data.length % 16) != 0) { - int add = (16 - data.length % 16); + final int add = 16 - data.length % 16; for (int i = 0; i < add; i++) { data.add(0); } @@ -117,7 +115,7 @@ class ReadSupportFunctionsNoParametersReply extends Reply { ReadSupportFunctionsNoParametersReply.parseData(CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { data = dataDetail; - int status = data[2]; + final int status = data[2]; errorWithStstus(status); } } \ No newline at end of file diff --git a/lib/blue/io_protocol/io_readSupportFunctionsWithParameters.dart b/lib/blue/io_protocol/io_readSupportFunctionsWithParameters.dart index 56006e4d..3ed378e4 100755 --- a/lib/blue/io_protocol/io_readSupportFunctionsWithParameters.dart +++ b/lib/blue/io_protocol/io_readSupportFunctionsWithParameters.dart @@ -12,17 +12,8 @@ import 'package:crypto/crypto.dart' as crypto; import '../sm4Encipher/sm4.dart'; -///TODO:读取支持功能(带参数)启用/禁用 +// 读取支持功能(带参数)启用/禁用 class ReadSupportFunctionsWithParametersCommand extends SenderProtocol { - - String? keyID; - String? userID; - int? featureBit; - List? token; - int? needAuthor; - List? publicKey; - List? privateKey; - ReadSupportFunctionsWithParametersCommand({ this.keyID, this.userID, @@ -33,6 +24,13 @@ class ReadSupportFunctionsWithParametersCommand extends SenderProtocol { this.privateKey, }) : super(CommandType.generalExtendedCommond); + String? keyID; + String? userID; + int? featureBit; + List? token; + int? needAuthor; + List? publicKey; + List? privateKey; @override String toString() { @@ -44,15 +42,15 @@ class ReadSupportFunctionsWithParametersCommand extends SenderProtocol { @override List messageDetail() { - List data = []; - List subData = []; - List ebcData = []; + final List data = []; + List subData = []; + List ebcData = []; // 指令类型 - int type = commandType!.typeValue; - double typeDouble = type / 256; - int type1 = typeDouble.toInt(); - int type2 = type % 256; + final int type = commandType!.typeValue; + final double typeDouble = type / 256; + final int type1 = typeDouble.toInt(); + final int type2 = type % 256; data.add(type1); data.add(type2); @@ -60,12 +58,12 @@ class ReadSupportFunctionsWithParametersCommand extends SenderProtocol { data.add(73); // keyID 40 - int keyIDLength = utf8.encode(keyID!).length; + final int keyIDLength = utf8.encode(keyID!).length; subData.addAll(utf8.encode(keyID!)); subData = getFixedLengthList(subData, 40 - keyIDLength); //userID 20 - int userIDLength = utf8.encode(userID!).length; + final int userIDLength = utf8.encode(userID!).length; subData.addAll(utf8.encode(userID!)); subData = getFixedLengthList(subData, 20 - userIDLength); @@ -76,7 +74,7 @@ class ReadSupportFunctionsWithParametersCommand extends SenderProtocol { //AuthCodeLen 1 subData.add(0); } else { - List authCodeData = []; + final List authCodeData = []; //authUserID authCodeData.addAll(utf8.encode(userID!)); @@ -90,7 +88,7 @@ class ReadSupportFunctionsWithParametersCommand extends SenderProtocol { authCodeData.addAll(publicKey!); // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode - var authCode = crypto.md5.convert(authCodeData); + final crypto.Digest authCode = crypto.md5.convert(authCodeData); subData.add(authCode.bytes.length); subData.addAll(authCode.bytes); @@ -100,7 +98,7 @@ class ReadSupportFunctionsWithParametersCommand extends SenderProtocol { data.addAll(subData); if ((data.length % 16) != 0) { - int add = (16 - data.length % 16); + final int add = 16 - data.length % 16; for (int i = 0; i < add; i++) { data.add(0); } @@ -117,7 +115,7 @@ class ReadSupportFunctionsWithParametersReply extends Reply { ReadSupportFunctionsWithParametersReply.parseData(CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { data = dataDetail; - int status = data[2]; + final int status = data[2]; errorWithStstus(status); } } \ No newline at end of file diff --git a/lib/blue/io_protocol/io_referEventRecordNumber.dart b/lib/blue/io_protocol/io_referEventRecordNumber.dart index 812f5d6b..757b8433 100755 --- a/lib/blue/io_protocol/io_referEventRecordNumber.dart +++ b/lib/blue/io_protocol/io_referEventRecordNumber.dart @@ -1,25 +1,16 @@ -//TODO:查询事件记录(序号、数量查询) +// 查询事件记录(序号、数量查询) import 'dart:convert'; +import 'package:crypto/crypto.dart' as crypto; + import '../io_reply.dart'; import '../io_sender.dart'; import '../io_tool/io_tool.dart'; import '../io_type.dart'; import '../sm4Encipher/sm4.dart'; -import 'package:crypto/crypto.dart' as crypto; class SenderReferEventRecordNumberCommand extends SenderProtocol { - - String? keyID; - String? userID; - int? logsCount; - int? logsNo; - List? token; - int? needAuthor; - List? publicKey; - List? privateKey; - SenderReferEventRecordNumberCommand({ this.keyID, this.userID, @@ -31,6 +22,15 @@ class SenderReferEventRecordNumberCommand extends SenderProtocol { this.privateKey, }) : super(CommandType.generalExtendedCommond); + String? keyID; + String? userID; + int? logsCount; + int? logsNo; + List? token; + int? needAuthor; + List? publicKey; + List? privateKey; + @override String toString() { @@ -42,15 +42,15 @@ class SenderReferEventRecordNumberCommand extends SenderProtocol { @override List messageDetail() { - List data = []; - List subData = []; - List ebcData = []; + final List data = []; + List subData = []; + List ebcData = []; // 指令类型 - int type = commandType!.typeValue; - double typeDouble = type / 256; - int type1 = typeDouble.toInt(); - int type2 = type % 256; + final int type = commandType!.typeValue; + final double typeDouble = type / 256; + final int type1 = typeDouble.toInt(); + final int type2 = type % 256; data.add(type1); data.add(type2); @@ -58,12 +58,12 @@ class SenderReferEventRecordNumberCommand extends SenderProtocol { data.add(40); // keyID 40 - int keyIDLength = utf8.encode(keyID!).length; + final int keyIDLength = utf8.encode(keyID!).length; subData.addAll(utf8.encode(keyID!)); subData = getFixedLengthList(subData, 40 - keyIDLength); //userID 20 - int userIDLength = utf8.encode(userID!).length; + final int userIDLength = utf8.encode(userID!).length; subData.addAll(utf8.encode(userID!)); subData = getFixedLengthList(subData, 20 - userIDLength); @@ -80,7 +80,7 @@ class SenderReferEventRecordNumberCommand extends SenderProtocol { //AuthCodeLen 1 subData.add(0); } else { - List authCodeData = []; + final List authCodeData = []; //authUserID authCodeData.addAll(utf8.encode(userID!)); @@ -94,7 +94,7 @@ class SenderReferEventRecordNumberCommand extends SenderProtocol { authCodeData.addAll(publicKey!); // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode - var authCode = crypto.md5.convert(authCodeData); + final crypto.Digest authCode = crypto.md5.convert(authCodeData); subData.add(authCode.bytes.length); subData.addAll(authCode.bytes); @@ -104,7 +104,7 @@ class SenderReferEventRecordNumberCommand extends SenderProtocol { data.addAll(subData); if ((data.length % 16) != 0) { - int add = (16 - data.length % 16); + final int add = 16 - data.length % 16; for (int i = 0; i < add; i++) { data.add(0); } @@ -121,7 +121,7 @@ class SenderReferEventRecordNumberReply extends Reply { SenderReferEventRecordNumberReply.parseData(CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { data = dataDetail; - int status = data[2]; + final int status = data[2]; errorWithStstus(status); } } \ No newline at end of file diff --git a/lib/blue/io_protocol/io_referEventRecordTime.dart b/lib/blue/io_protocol/io_referEventRecordTime.dart index 304b433d..e96cbbce 100755 --- a/lib/blue/io_protocol/io_referEventRecordTime.dart +++ b/lib/blue/io_protocol/io_referEventRecordTime.dart @@ -1,6 +1,8 @@ -//TODO:查询事件记录(时间查询) + +// 查询事件记录(时间查询) import 'dart:convert'; +import 'package:crypto/crypto.dart' as crypto; import 'package:star_lock/tools/dateTool.dart'; import '../io_reply.dart'; @@ -8,7 +10,6 @@ import '../io_sender.dart'; import '../io_tool/io_tool.dart'; import '../io_type.dart'; import '../sm4Encipher/sm4.dart'; -import 'package:crypto/crypto.dart' as crypto; class SenderReferEventRecordTimeCommand extends SenderProtocol { @@ -43,9 +44,9 @@ class SenderReferEventRecordTimeCommand extends SenderProtocol { @override List messageDetail() { - List data = []; - List subData = []; - List ebcData = []; + final List data = []; + List subData = []; + List ebcData = []; // 指令类型 // int type = commandType!.typeValue; @@ -60,12 +61,12 @@ class SenderReferEventRecordTimeCommand extends SenderProtocol { data.add(41); // keyID 40 - int keyIDLength = utf8.encode(keyID!).length; + final int keyIDLength = utf8.encode(keyID!).length; subData.addAll(utf8.encode(keyID!)); subData = getFixedLengthList(subData, 40 - keyIDLength); //userID 20 - int userIDLength = utf8.encode(userID!).length; + final int userIDLength = utf8.encode(userID!).length; subData.addAll(utf8.encode(userID!)); subData = getFixedLengthList(subData, 20 - userIDLength); @@ -91,7 +92,7 @@ class SenderReferEventRecordTimeCommand extends SenderProtocol { //AuthCodeLen 1 subData.add(0); } else { - List authCodeData = []; + final List authCodeData = []; //authUserID authCodeData.addAll(utf8.encode(userID!)); @@ -105,7 +106,7 @@ class SenderReferEventRecordTimeCommand extends SenderProtocol { authCodeData.addAll(publicKey!); // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode - var authCode = crypto.md5.convert(authCodeData); + final crypto.Digest authCode = crypto.md5.convert(authCodeData); subData.add(authCode.bytes.length); subData.addAll(authCode.bytes); @@ -115,7 +116,7 @@ class SenderReferEventRecordTimeCommand extends SenderProtocol { data.addAll(subData); if ((data.length % 16) != 0) { - int add = 16 - data.length % 16; + final int add = 16 - data.length % 16; for (int i = 0; i < add; i++) { data.add(0); } @@ -132,7 +133,7 @@ class SenderReferEventRecordTimeReply extends Reply { CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { data = dataDetail; - int status = data[2]; + final int status = data[2]; errorWithStstus(status); } } diff --git a/lib/blue/io_protocol/io_senderCustomPasswords.dart b/lib/blue/io_protocol/io_senderCustomPasswords.dart index 9e0bb8f9..c0a7fbf0 100755 --- a/lib/blue/io_protocol/io_senderCustomPasswords.dart +++ b/lib/blue/io_protocol/io_senderCustomPasswords.dart @@ -1,34 +1,20 @@ import 'dart:convert'; +import 'package:crypto/crypto.dart' as crypto; import 'package:star_lock/tools/dateTool.dart'; import '../../app_settings/app_settings.dart'; -import '../io_tool/io_tool.dart'; -import '../sm4Encipher/sm4.dart'; import '../io_reply.dart'; import '../io_sender.dart'; +import '../io_tool/io_tool.dart'; import '../io_type.dart'; -import 'package:crypto/crypto.dart' as crypto; +import '../sm4Encipher/sm4.dart'; -//TODO:设置开锁密码(备注:先添加管理员密码, 管理员满了后就是开锁密码) /* -备注:删除单个密码规则:pwd 设置为 6 个 0,UseCountLimit 设置为 0。删除全部密码规则:pwd 设置为 6 个 0,UseCountLimit 设置为 0,pwdNo 设置为 255,userId 设置为“DeleteAll !@#”,只有门锁管理员才有权限 + 设置开锁密码(备注:先添加管理员密码, 管理员满了后就是开锁密码) 备注:删除单个密码规则:pwd 设置为 6 个 0,UseCountLimit 设置为 0。删除全部密码规则:pwd 设置为 6 个 0,UseCountLimit 设置为 0,pwdNo 设置为 255,userId 设置为“DeleteAll !@#”,只有门锁管理员才有权限 **/ class SenderCustomPasswordsCommand extends SenderProtocol { - String? keyID; - String? userID; - int? pwdNo; - int? operate; - int? isAdmin; - String? pwd; - int? useCountLimit; - List? token; - int? startTime; - int? endTime; - int? needAuthor; - List? signKey; - List? privateKey; SenderCustomPasswordsCommand({ this.keyID, @@ -45,6 +31,19 @@ class SenderCustomPasswordsCommand extends SenderProtocol { this.signKey, this.privateKey, }) : super(CommandType.generalExtendedCommond); + String? keyID; + String? userID; + int? pwdNo; + int? operate; + int? isAdmin; + String? pwd; + int? useCountLimit; + List? token; + int? startTime; + int? endTime; + int? needAuthor; + List? signKey; + List? privateKey; @override String toString() { diff --git a/lib/blue/io_protocol/io_senderResetPasswords.dart b/lib/blue/io_protocol/io_senderResetPasswords.dart index 30de051e..676eff84 100755 --- a/lib/blue/io_protocol/io_senderResetPasswords.dart +++ b/lib/blue/io_protocol/io_senderResetPasswords.dart @@ -1,21 +1,16 @@ 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'; import 'package:crypto/crypto.dart' as crypto; -//TODO:重置开锁密码(同时重置自定义密码和离线密码,绑定完锁之后第一个管理员密码不重置) +import '../io_reply.dart'; +import '../io_sender.dart'; +import '../io_tool/io_tool.dart'; +import '../io_type.dart'; +import '../sm4Encipher/sm4.dart'; + +// 重置开锁密码(同时重置自定义密码和离线密码,绑定完锁之后第一个管理员密码不重置) class SenderResetPasswordsCommand extends SenderProtocol { - String? keyID; - String? userID; - List? token; - int? needAuthor; - List? signKey; - List? privateKey; SenderResetPasswordsCommand({ this.keyID, @@ -25,6 +20,12 @@ class SenderResetPasswordsCommand extends SenderProtocol { this.signKey, this.privateKey, }) : super(CommandType.generalExtendedCommond); + String? keyID; + String? userID; + List? token; + int? needAuthor; + List? signKey; + List? privateKey; @override String toString() { @@ -35,9 +36,9 @@ class SenderResetPasswordsCommand extends SenderProtocol { @override List messageDetail() { - List data = []; - List subData = []; - List ebcData = []; + final List data = []; + List subData = []; + List ebcData = []; // 指令类型 data.addAll(intChangList(commandType!.typeValue)); @@ -46,12 +47,12 @@ class SenderResetPasswordsCommand extends SenderProtocol { data.add(19); // keyID 40 - int keyIDLength = utf8.encode(keyID!).length; + final int keyIDLength = utf8.encode(keyID!).length; subData.addAll(utf8.encode(keyID!)); subData = getFixedLengthList(subData, 40 - keyIDLength); //userID 20 - int userIDLength = utf8.encode(userID!).length; + final int userIDLength = utf8.encode(userID!).length; subData.addAll(utf8.encode(userID!)); subData = getFixedLengthList(subData, 20 - userIDLength); @@ -62,7 +63,7 @@ class SenderResetPasswordsCommand extends SenderProtocol { //AuthCodeLen 1 subData.add(0); } else { - List authCodeData = []; + final List authCodeData = []; //KeyID authCodeData.addAll(utf8.encode(keyID!)); @@ -76,7 +77,7 @@ class SenderResetPasswordsCommand extends SenderProtocol { authCodeData.addAll(signKey!); // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode - var authCode = crypto.md5.convert(authCodeData); + final crypto.Digest authCode = crypto.md5.convert(authCodeData); subData.add(authCode.bytes.length); subData.addAll(authCode.bytes); @@ -86,7 +87,7 @@ class SenderResetPasswordsCommand extends SenderProtocol { data.addAll(subData); if ((data.length % 16) != 0) { - int add = (16 - data.length % 16); + final int add = 16 - data.length % 16; for (int i = 0; i < add; i++) { data.add(0); } @@ -104,7 +105,7 @@ class SenderResetPasswordsReply extends Reply { CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { data = dataDetail; - int status = data[2]; + final int status = data[2]; errorWithStstus(status); } } diff --git a/lib/blue/io_protocol/io_setSupportFunctionsNoParameters.dart b/lib/blue/io_protocol/io_setSupportFunctionsNoParameters.dart index 67a00718..82a0312d 100755 --- a/lib/blue/io_protocol/io_setSupportFunctionsNoParameters.dart +++ b/lib/blue/io_protocol/io_setSupportFunctionsNoParameters.dart @@ -1,26 +1,17 @@ import 'dart:convert'; +import 'package:crypto/crypto.dart' as crypto; + import '../io_reply.dart'; import '../io_sender.dart'; import '../io_tool/io_tool.dart'; import '../io_type.dart'; -import 'package:crypto/crypto.dart' as crypto; - import '../sm4Encipher/sm4.dart'; -///TODO:设置支持功能(不带参数)启用/禁用 +/// 设置支持功能(不带参数)启用/禁用 class SetSupportFunctionsNoParametersCommand extends SenderProtocol { - String? keyID; - String? userID; - int? featureBit; - int? featureEnable; - List? token; - int? needAuthor; - List? publicKey; - List? privateKey; - SetSupportFunctionsNoParametersCommand({ this.keyID, this.userID, @@ -32,6 +23,14 @@ class SetSupportFunctionsNoParametersCommand extends SenderProtocol { this.privateKey, }) : super(CommandType.generalExtendedCommond); + String? keyID; + String? userID; + int? featureBit; + int? featureEnable; + List? token; + int? needAuthor; + List? publicKey; + List? privateKey; @override String toString() { @@ -44,15 +43,15 @@ class SetSupportFunctionsNoParametersCommand extends SenderProtocol { @override List messageDetail() { - List data = []; - List subData = []; - List ebcData = []; + final List data = []; + List subData = []; + List ebcData = []; // 指令类型 - int type = commandType!.typeValue; - double typeDouble = type / 256; - int type1 = typeDouble.toInt(); - int type2 = type % 256; + final int type = commandType!.typeValue; + final double typeDouble = type / 256; + final int type1 = typeDouble.toInt(); + final int type2 = type % 256; data.add(type1); data.add(type2); @@ -60,12 +59,12 @@ class SetSupportFunctionsNoParametersCommand extends SenderProtocol { data.add(70); // keyID 40 - int keyIDLength = utf8.encode(keyID!).length; + final int keyIDLength = utf8.encode(keyID!).length; subData.addAll(utf8.encode(keyID!)); subData = getFixedLengthList(subData, 40 - keyIDLength); //userID 20 - int userIDLength = utf8.encode(userID!).length; + final int userIDLength = utf8.encode(userID!).length; subData.addAll(utf8.encode(userID!)); subData = getFixedLengthList(subData, 20 - userIDLength); @@ -79,7 +78,7 @@ class SetSupportFunctionsNoParametersCommand extends SenderProtocol { //AuthCodeLen 1 subData.add(0); } else { - List authCodeData = []; + final List authCodeData = []; //authUserID authCodeData.addAll(utf8.encode(userID!)); @@ -93,7 +92,7 @@ class SetSupportFunctionsNoParametersCommand extends SenderProtocol { authCodeData.addAll(publicKey!); // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode - var authCode = crypto.md5.convert(authCodeData); + final crypto.Digest authCode = crypto.md5.convert(authCodeData); subData.add(authCode.bytes.length); subData.addAll(authCode.bytes); @@ -103,7 +102,7 @@ class SetSupportFunctionsNoParametersCommand extends SenderProtocol { data.addAll(subData); if ((data.length % 16) != 0) { - int add = (16 - data.length % 16); + final int add = 16 - data.length % 16; for (int i = 0; i < add; i++) { data.add(0); } @@ -120,7 +119,7 @@ class SetSupportFunctionsNoParametersReply extends Reply { SetSupportFunctionsNoParametersReply.parseData(CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { data = dataDetail; - int status = data[2]; + final int status = data[2]; errorWithStstus(status); } } \ No newline at end of file diff --git a/lib/blue/io_protocol/io_setSupportFunctionsWithParameters.dart b/lib/blue/io_protocol/io_setSupportFunctionsWithParameters.dart index 05e505e8..b34cd868 100755 --- a/lib/blue/io_protocol/io_setSupportFunctionsWithParameters.dart +++ b/lib/blue/io_protocol/io_setSupportFunctionsWithParameters.dart @@ -9,19 +9,8 @@ import 'package:crypto/crypto.dart' as crypto; import '../sm4Encipher/sm4.dart'; -///TODO:设置支持功能(参数) +/// 设置支持功能(参数) class SetSupportFunctionsWithParametersCommand extends SenderProtocol { - - String? keyID; - String? userID; - int? featureBit; - int? featureParaLength; - List? featureData; - List? token; - int? needAuthor; - List? publicKey; - List? privateKey; - SetSupportFunctionsWithParametersCommand({ this.keyID, this.userID, @@ -34,6 +23,15 @@ class SetSupportFunctionsWithParametersCommand extends SenderProtocol { this.privateKey, }) : super(CommandType.generalExtendedCommond); + String? keyID; + String? userID; + int? featureBit; + int? featureParaLength; + List? featureData; + List? token; + int? needAuthor; + List? publicKey; + List? privateKey; @override String toString() { @@ -46,15 +44,15 @@ class SetSupportFunctionsWithParametersCommand extends SenderProtocol { @override List messageDetail() { - List data = []; - List subData = []; - List ebcData = []; + final List data = []; + List subData = []; + List ebcData = []; // 指令类型 - int type = commandType!.typeValue; - double typeDouble = type / 256; - int type1 = typeDouble.toInt(); - int type2 = type % 256; + final int type = commandType!.typeValue; + final double typeDouble = type / 256; + final int type1 = typeDouble.toInt(); + final int type2 = type % 256; data.add(type1); data.add(type2); @@ -62,12 +60,12 @@ class SetSupportFunctionsWithParametersCommand extends SenderProtocol { data.add(72); // keyID 40 - int keyIDLength = utf8.encode(keyID!).length; + final int keyIDLength = utf8.encode(keyID!).length; subData.addAll(utf8.encode(keyID!)); subData = getFixedLengthList(subData, 40 - keyIDLength); //userID 20 - int userIDLength = utf8.encode(userID!).length; + final int userIDLength = utf8.encode(userID!).length; subData.addAll(utf8.encode(userID!)); subData = getFixedLengthList(subData, 20 - userIDLength); @@ -84,7 +82,7 @@ class SetSupportFunctionsWithParametersCommand extends SenderProtocol { //AuthCodeLen 1 subData.add(0); } else { - List authCodeData = []; + final List authCodeData = []; //authUserID authCodeData.addAll(utf8.encode(userID!)); @@ -98,7 +96,7 @@ class SetSupportFunctionsWithParametersCommand extends SenderProtocol { authCodeData.addAll(publicKey!); // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode - var authCode = crypto.md5.convert(authCodeData); + final crypto.Digest authCode = crypto.md5.convert(authCodeData); subData.add(authCode.bytes.length); subData.addAll(authCode.bytes); @@ -108,7 +106,7 @@ class SetSupportFunctionsWithParametersCommand extends SenderProtocol { data.addAll(subData); if ((data.length % 16) != 0) { - int add = (16 - data.length % 16); + final int add = 16 - data.length % 16; for (int i = 0; i < add; i++) { data.add(0); } @@ -125,7 +123,7 @@ class SetSupportFunctionsWithParametersReply extends Reply { SetSupportFunctionsWithParametersReply.parseData(CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { data = dataDetail; - int status = data[2]; + final int status = data[2]; errorWithStstus(status); } } \ No newline at end of file diff --git a/lib/blue/io_protocol/io_timing.dart b/lib/blue/io_protocol/io_timing.dart index e2764299..9574cc46 100755 --- a/lib/blue/io_protocol/io_timing.dart +++ b/lib/blue/io_protocol/io_timing.dart @@ -3,14 +3,13 @@ import 'dart:convert'; import 'package:star_lock/tools/dateTool.dart'; -import '../io_tool/io_tool.dart'; -import '../sm4Encipher/sm4.dart'; import '../io_reply.dart'; import '../io_sender.dart'; +import '../io_tool/io_tool.dart'; import '../io_type.dart'; -import 'package:crypto/crypto.dart' as crypto; +import '../sm4Encipher/sm4.dart'; -//TODO:校时 +// 校时 class TimingCommand extends SenderProtocol { String? lockID; String? userID; @@ -44,32 +43,32 @@ class TimingCommand extends SenderProtocol { List ebcData = []; // 指令类型 - int type = commandType!.typeValue; - double typeDouble = type / 256; - int type1 = typeDouble.toInt(); - int type2 = type % 256; + final int type = commandType!.typeValue; + final double typeDouble = type / 256; + final int type1 = typeDouble.toInt(); + final int type2 = type % 256; data.add(type1); data.add(type2); //lockID 40 - int lockIDLength = utf8.encode(lockID!).length; + final int lockIDLength = utf8.encode(lockID!).length; data.addAll(utf8.encode(lockID!)); data = getFixedLengthList(data, 40 - lockIDLength); //userID 要接受钥匙的用户的useid 20 - int userIDLength = utf8.encode(userID!).length; + final int userIDLength = utf8.encode(userID!).length; data.addAll(utf8.encode(userID!)); data = getFixedLengthList(data, 20 - userIDLength); // nowTime 4 - int? d1 = nowTime; + final int? d1 = nowTime; data.add((d1! & 0xff000000) >> 24); data.add((d1 & 0xff0000) >> 16); data.add((d1 & 0xff00) >> 8); - data.add((d1 & 0xff)); + data.add(d1 & 0xff); if ((data.length % 16) != 0) { - int add = (16 - data.length % 16); + final int add = 16 - data.length % 16; for (int i = 0; i < add; i++) { data.add(0); } @@ -85,7 +84,7 @@ class TimingReply extends Reply { TimingReply.parseData(CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { data = dataDetail; - int status = data[2]; + final int status = data[2]; errorWithStstus(status); } } \ No newline at end of file diff --git a/lib/blue/io_protocol/io_transferPermissions.dart b/lib/blue/io_protocol/io_transferPermissions.dart index 5bbffa0f..d688f4f2 100755 --- a/lib/blue/io_protocol/io_transferPermissions.dart +++ b/lib/blue/io_protocol/io_transferPermissions.dart @@ -1,25 +1,16 @@ 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'; import 'package:crypto/crypto.dart' as crypto; -//TODO:转移权限 -class TransferPermissionsCommand extends SenderProtocol { +import '../io_reply.dart'; +import '../io_sender.dart'; +import '../io_tool/io_tool.dart'; +import '../io_type.dart'; +import '../sm4Encipher/sm4.dart'; - String? lockID; - String? authUserID; - String? keyID; - String? oldUserID; - String? newUserID; - int? needAuthor; - List? publicKey; - List? privateKey; - List? token; +// 转移权限 +class TransferPermissionsCommand extends SenderProtocol { TransferPermissionsCommand({ this.lockID, this.authUserID, @@ -32,6 +23,16 @@ class TransferPermissionsCommand extends SenderProtocol { this.token }) : super(CommandType.transferPermissions); + String? lockID; + String? authUserID; + String? keyID; + String? oldUserID; + String? newUserID; + int? needAuthor; + List? publicKey; + List? privateKey; + List? token; + @override String toString() { @@ -43,39 +44,39 @@ class TransferPermissionsCommand extends SenderProtocol { @override List messageDetail() { - List data = []; - List ebcData = []; + List data = []; + List ebcData = []; // 指令类型 - int type = commandType!.typeValue; - double typeDouble = type / 256; - int type1 = typeDouble.toInt(); - int type2 = type % 256; + final int type = commandType!.typeValue; + final double typeDouble = type / 256; + final int type1 = typeDouble.toInt(); + final int type2 = type % 256; data.add(type1); data.add(type2); // 锁id 40 - int lockIDLength = utf8.encode(lockID!).length; + final int lockIDLength = utf8.encode(lockID!).length; data.addAll(utf8.encode(lockID!)); data = getFixedLengthList(data, 40 - lockIDLength); //authUserID 20 - int authUserIDLength = utf8.encode(authUserID!).length; + final int authUserIDLength = utf8.encode(authUserID!).length; data.addAll(utf8.encode(authUserID!)); data = getFixedLengthList(data, 20 - authUserIDLength); //KeyID 40 - int keyIDLength = utf8.encode(keyID!).length; + final int keyIDLength = utf8.encode(keyID!).length; data.addAll(utf8.encode(keyID!)); data = getFixedLengthList(data, 40 - keyIDLength); //oldUserID 20 - int oldUserIDLength = utf8.encode(oldUserID!).length; + final int oldUserIDLength = utf8.encode(oldUserID!).length; data.addAll(utf8.encode(oldUserID!)); data = getFixedLengthList(data, 20 - oldUserIDLength); //newUserID 20 - int newUserIDLength = utf8.encode(newUserID!).length; + final int newUserIDLength = utf8.encode(newUserID!).length; data.addAll(utf8.encode(newUserID!)); data = getFixedLengthList(data, 20 - newUserIDLength); @@ -86,7 +87,7 @@ class TransferPermissionsCommand extends SenderProtocol { //AuthCodeLen 1 data.add(0); } else { - List authCodeData = []; + final List authCodeData = []; //authUserID authCodeData.addAll(utf8.encode(authUserID!)); @@ -100,14 +101,14 @@ class TransferPermissionsCommand extends SenderProtocol { authCodeData.addAll(publicKey!); // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode - var authCode = crypto.md5.convert(authCodeData); + final crypto.Digest authCode = crypto.md5.convert(authCodeData); data.add(authCode.bytes.length); data.addAll(authCode.bytes); } if ((data.length % 16) != 0) { - int add = (16 - data.length % 16); + final int add = 16 - data.length % 16; for (int i = 0; i < add; i++) { data.add(0); } diff --git a/lib/blue/io_protocol/io_transferSmartLock.dart b/lib/blue/io_protocol/io_transferSmartLock.dart index 2e3960e0..72464de4 100644 --- a/lib/blue/io_protocol/io_transferSmartLock.dart +++ b/lib/blue/io_protocol/io_transferSmartLock.dart @@ -1,5 +1,5 @@ -//TODO:转移智能锁 +// 转移智能锁 import 'dart:convert'; import 'package:crypto/crypto.dart' as crypto; @@ -11,14 +11,6 @@ import '../io_type.dart'; import '../sm4Encipher/sm4.dart'; class TransferSmartLockCommand extends SenderProtocol { - - String? lockID; - String? userID; - String? keyID; - List? publicKey; - List? privateKey; - List? token; - int? needAuthor; TransferSmartLockCommand({ this.lockID, this.userID, @@ -29,6 +21,14 @@ class TransferSmartLockCommand extends SenderProtocol { this.privateKey, }) : super(CommandType.transferSmartLock); + String? lockID; + String? userID; + String? keyID; + List? publicKey; + List? privateKey; + List? token; + int? needAuthor; + @override String toString() { diff --git a/lib/blue/io_protocol/io_updataLockCardList.dart b/lib/blue/io_protocol/io_updataLockCardList.dart index 4f05fb30..8bc090bb 100644 --- a/lib/blue/io_protocol/io_updataLockCardList.dart +++ b/lib/blue/io_protocol/io_updataLockCardList.dart @@ -10,16 +10,6 @@ import '../io_type.dart'; import '../sm4Encipher/sm4.dart'; class UpdataLockCardListCommand extends SenderProtocol { - - String? lockID; - String? keyID; - String? userID; - int? page; - int? countReq; - List? token; - int? needAuthor; - List? signKey; - List? privateKey; UpdataLockCardListCommand({ this.lockID, this.keyID, @@ -32,6 +22,16 @@ class UpdataLockCardListCommand extends SenderProtocol { this.privateKey }) : super(CommandType.updataLockCardList); + String? lockID; + String? keyID; + String? userID; + int? page; + int? countReq; + List? token; + int? needAuthor; + List? signKey; + List? privateKey; + @override String toString() { return 'UpdataLockCardListCommand{lockID: $lockID, keyID:$keyID userID: $userID, ' @@ -41,24 +41,24 @@ class UpdataLockCardListCommand extends SenderProtocol { @override List messageDetail() { - List data = []; - List ebcData = []; + List data = []; + List ebcData = []; // 指令类型 - int type = commandType!.typeValue; - double typeDouble = type / 256; - int type1 = typeDouble.toInt(); - int type2 = type % 256; + final int type = commandType!.typeValue; + final double typeDouble = type / 256; + final int type1 = typeDouble.toInt(); + final int type2 = type % 256; data.add(type1); data.add(type2); // 锁id 40 - int lockIDLength = utf8.encode(lockID!).length; + final int lockIDLength = utf8.encode(lockID!).length; data.addAll(utf8.encode(lockID!)); data = getFixedLengthList(data, 40 - lockIDLength); //userID 要接受钥匙的用户的useid 20 - int userIDLength = utf8.encode(userID!).length; + final int userIDLength = utf8.encode(userID!).length; data.addAll(utf8.encode(userID!)); data = getFixedLengthList(data, 20 - userIDLength); @@ -75,7 +75,7 @@ class UpdataLockCardListCommand extends SenderProtocol { //AuthCodeLen 1 data.add(0); } else { - List authCodeData = []; + final List authCodeData = []; //KeyID authCodeData.addAll(utf8.encode(lockID!)); @@ -88,14 +88,14 @@ class UpdataLockCardListCommand extends SenderProtocol { authCodeData.addAll(signKey!); // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode - var authCode = crypto.md5.convert(authCodeData); + final crypto.Digest authCode = crypto.md5.convert(authCodeData); data.add(authCode.bytes.length); data.addAll(authCode.bytes); } if ((data.length % 16) != 0) { - int add = (16 - data.length % 16); + final int add = 16 - data.length % 16; for (int i = 0; i < add; i++) { data.add(0); } @@ -113,7 +113,7 @@ class UpdataLockCardListReply extends Reply { : super.parseData(commandType, dataDetail) { data = dataDetail; - int status = data[2]; + final int status = data[2]; errorWithStstus(status); } } \ No newline at end of file diff --git a/lib/blue/io_protocol/io_updataLockFaceList.dart b/lib/blue/io_protocol/io_updataLockFaceList.dart index d05003f6..67c13eaa 100644 --- a/lib/blue/io_protocol/io_updataLockFaceList.dart +++ b/lib/blue/io_protocol/io_updataLockFaceList.dart @@ -1,25 +1,15 @@ import 'dart:convert'; +import 'package:crypto/crypto.dart' as crypto; + import '../io_reply.dart'; import '../io_sender.dart'; import '../io_tool/io_tool.dart'; import '../io_type.dart'; -import 'package:crypto/crypto.dart' as crypto; - import '../sm4Encipher/sm4.dart'; class UpdataLockFaceListCommand extends SenderProtocol { - - String? lockID; - String? keyID; - String? userID; - int? page; - int? countReq; - List? token; - int? needAuthor; - List? signKey; - List? privateKey; UpdataLockFaceListCommand({ this.lockID, this.keyID, @@ -32,6 +22,16 @@ class UpdataLockFaceListCommand extends SenderProtocol { this.privateKey }) : super(CommandType.updataLockFaceList); + String? lockID; + String? keyID; + String? userID; + int? page; + int? countReq; + List? token; + int? needAuthor; + List? signKey; + List? privateKey; + @override String toString() { return 'UpdataLockPasswordListCommand{lockID: $lockID, keyID:$keyID userID: $userID, ' @@ -41,24 +41,24 @@ class UpdataLockFaceListCommand extends SenderProtocol { @override List messageDetail() { - List data = []; - List ebcData = []; + List data = []; + List ebcData = []; // 指令类型 - int type = commandType!.typeValue; - double typeDouble = type / 256; - int type1 = typeDouble.toInt(); - int type2 = type % 256; + final int type = commandType!.typeValue; + final double typeDouble = type / 256; + final int type1 = typeDouble.toInt(); + final int type2 = type % 256; data.add(type1); data.add(type2); // 锁id 40 - int lockIDLength = utf8.encode(lockID!).length; + final int lockIDLength = utf8.encode(lockID!).length; data.addAll(utf8.encode(lockID!)); data = getFixedLengthList(data, 40 - lockIDLength); //userID 要接受钥匙的用户的useid 20 - int userIDLength = utf8.encode(userID!).length; + final int userIDLength = utf8.encode(userID!).length; data.addAll(utf8.encode(userID!)); data = getFixedLengthList(data, 20 - userIDLength); @@ -75,7 +75,7 @@ class UpdataLockFaceListCommand extends SenderProtocol { //AuthCodeLen 1 data.add(0); } else { - List authCodeData = []; + final List authCodeData = []; //KeyID authCodeData.addAll(utf8.encode(lockID!)); @@ -88,14 +88,14 @@ class UpdataLockFaceListCommand extends SenderProtocol { authCodeData.addAll(signKey!); // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode - var authCode = crypto.md5.convert(authCodeData); + final crypto.Digest authCode = crypto.md5.convert(authCodeData); data.add(authCode.bytes.length); data.addAll(authCode.bytes); } if ((data.length % 16) != 0) { - int add = (16 - data.length % 16); + final int add = 16 - data.length % 16; for (int i = 0; i < add; i++) { data.add(0); } @@ -113,7 +113,7 @@ class UpdataLockFaceListReply extends Reply { : super.parseData(commandType, dataDetail) { data = dataDetail; - int status = data[2]; + final int status = data[2]; errorWithStstus(status); } } \ No newline at end of file diff --git a/lib/blue/io_protocol/io_updataLockFingerprintList.dart b/lib/blue/io_protocol/io_updataLockFingerprintList.dart index b52835f9..ef656367 100644 --- a/lib/blue/io_protocol/io_updataLockFingerprintList.dart +++ b/lib/blue/io_protocol/io_updataLockFingerprintList.dart @@ -1,25 +1,15 @@ import 'dart:convert'; +import 'package:crypto/crypto.dart' as crypto; + import '../io_reply.dart'; import '../io_sender.dart'; import '../io_tool/io_tool.dart'; import '../io_type.dart'; -import 'package:crypto/crypto.dart' as crypto; - import '../sm4Encipher/sm4.dart'; class UpdataLockFingerprintListCommand extends SenderProtocol { - - String? lockID; - String? keyID; - String? userID; - int? page; - int? countReq; - List? token; - int? needAuthor; - List? signKey; - List? privateKey; UpdataLockFingerprintListCommand({ this.lockID, this.keyID, @@ -32,6 +22,16 @@ class UpdataLockFingerprintListCommand extends SenderProtocol { this.privateKey }) : super(CommandType.updataLockFingerprintList); + String? lockID; + String? keyID; + String? userID; + int? page; + int? countReq; + List? token; + int? needAuthor; + List? signKey; + List? privateKey; + @override String toString() { return 'UpdataLockPasswordListCommand{lockID: $lockID, keyID:$keyID userID: $userID, ' @@ -41,24 +41,24 @@ class UpdataLockFingerprintListCommand extends SenderProtocol { @override List messageDetail() { - List data = []; - List ebcData = []; + List data = []; + List ebcData = []; // 指令类型 - int type = commandType!.typeValue; - double typeDouble = type / 256; - int type1 = typeDouble.toInt(); - int type2 = type % 256; + final int type = commandType!.typeValue; + final double typeDouble = type / 256; + final int type1 = typeDouble.toInt(); + final int type2 = type % 256; data.add(type1); data.add(type2); // 锁id 40 - int lockIDLength = utf8.encode(lockID!).length; + final int lockIDLength = utf8.encode(lockID!).length; data.addAll(utf8.encode(lockID!)); data = getFixedLengthList(data, 40 - lockIDLength); //userID 要接受钥匙的用户的useid 20 - int userIDLength = utf8.encode(userID!).length; + final int userIDLength = utf8.encode(userID!).length; data.addAll(utf8.encode(userID!)); data = getFixedLengthList(data, 20 - userIDLength); @@ -75,7 +75,7 @@ class UpdataLockFingerprintListCommand extends SenderProtocol { //AuthCodeLen 1 data.add(0); } else { - List authCodeData = []; + final List authCodeData = []; //KeyID authCodeData.addAll(utf8.encode(lockID!)); @@ -88,14 +88,14 @@ class UpdataLockFingerprintListCommand extends SenderProtocol { authCodeData.addAll(signKey!); // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode - var authCode = crypto.md5.convert(authCodeData); + final crypto.Digest authCode = crypto.md5.convert(authCodeData); data.add(authCode.bytes.length); data.addAll(authCode.bytes); } if ((data.length % 16) != 0) { - int add = (16 - data.length % 16); + final int add = 16 - data.length % 16; for (int i = 0; i < add; i++) { data.add(0); } @@ -113,7 +113,7 @@ class UpdataLockFingerprintListReply extends Reply { : super.parseData(commandType, dataDetail) { data = dataDetail; - int status = data[2]; + final int status = data[2]; errorWithStstus(status); } } \ No newline at end of file diff --git a/lib/blue/io_protocol/io_updataLockPalmVeinList.dart b/lib/blue/io_protocol/io_updataLockPalmVeinList.dart index 4fe979cd..b0109963 100644 --- a/lib/blue/io_protocol/io_updataLockPalmVeinList.dart +++ b/lib/blue/io_protocol/io_updataLockPalmVeinList.dart @@ -1,24 +1,15 @@ import 'dart:convert'; +import 'package:crypto/crypto.dart' as crypto; + import '../io_reply.dart'; import '../io_sender.dart'; import '../io_tool/io_tool.dart'; import '../io_type.dart'; -import 'package:crypto/crypto.dart' as crypto; - import '../sm4Encipher/sm4.dart'; class UpdataLockPalmVeinListCommand extends SenderProtocol { - - String? lockID; - String? userID; - int? page; - int? countReq; - List? token; - int? needAuthor; - List? signKey; - List? privateKey; UpdataLockPalmVeinListCommand({ this.lockID, this.userID, @@ -30,6 +21,15 @@ class UpdataLockPalmVeinListCommand extends SenderProtocol { this.privateKey }) : super(CommandType.updataLockPalmVeinList); + String? lockID; + String? userID; + int? page; + int? countReq; + List? token; + int? needAuthor; + List? signKey; + List? privateKey; + @override String toString() { return 'UpdataLockPasswordListCommand{lockID: $lockID, userID: $userID, ' @@ -39,24 +39,24 @@ class UpdataLockPalmVeinListCommand extends SenderProtocol { @override List messageDetail() { - List data = []; - List ebcData = []; + List data = []; + List ebcData = []; // 指令类型 - int type = commandType!.typeValue; - double typeDouble = type / 256; - int type1 = typeDouble.toInt(); - int type2 = type % 256; + final int type = commandType!.typeValue; + final double typeDouble = type / 256; + final int type1 = typeDouble.toInt(); + final int type2 = type % 256; data.add(type1); data.add(type2); // 锁id 40 - int lockIDLength = utf8.encode(lockID!).length; + final int lockIDLength = utf8.encode(lockID!).length; data.addAll(utf8.encode(lockID!)); data = getFixedLengthList(data, 40 - lockIDLength); //userID 要接受钥匙的用户的useid 20 - int userIDLength = utf8.encode(userID!).length; + final int userIDLength = utf8.encode(userID!).length; data.addAll(utf8.encode(userID!)); data = getFixedLengthList(data, 20 - userIDLength); @@ -73,7 +73,7 @@ class UpdataLockPalmVeinListCommand extends SenderProtocol { //AuthCodeLen 1 data.add(0); } else { - List authCodeData = []; + final List authCodeData = []; //KeyID authCodeData.addAll(utf8.encode(lockID!)); @@ -86,14 +86,14 @@ class UpdataLockPalmVeinListCommand extends SenderProtocol { authCodeData.addAll(signKey!); // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode - var authCode = crypto.md5.convert(authCodeData); + final crypto.Digest authCode = crypto.md5.convert(authCodeData); data.add(authCode.bytes.length); data.addAll(authCode.bytes); } if ((data.length % 16) != 0) { - int add = (16 - data.length % 16); + final int add = 16 - data.length % 16; for (int i = 0; i < add; i++) { data.add(0); } @@ -111,7 +111,7 @@ class UpdataLockPalmVeinListReply extends Reply { : super.parseData(commandType, dataDetail) { data = dataDetail; - int status = data[2]; + final int status = data[2]; errorWithStstus(status); } } \ No newline at end of file diff --git a/lib/blue/io_protocol/io_updataLockPasswordList.dart b/lib/blue/io_protocol/io_updataLockPasswordList.dart index 0f172347..0eeee8dd 100644 --- a/lib/blue/io_protocol/io_updataLockPasswordList.dart +++ b/lib/blue/io_protocol/io_updataLockPasswordList.dart @@ -10,16 +10,6 @@ import 'package:crypto/crypto.dart' as crypto; import '../sm4Encipher/sm4.dart'; class UpdataLockPasswordListCommand extends SenderProtocol { - - String? lockID; - String? keyID; - String? userID; - int? page; - int? countReq; - List? token; - int? needAuthor; - List? signKey; - List? privateKey; UpdataLockPasswordListCommand({ this.lockID, this.keyID, @@ -32,6 +22,16 @@ class UpdataLockPasswordListCommand extends SenderProtocol { this.privateKey }) : super(CommandType.updataLockPasswordList); + String? lockID; + String? keyID; + String? userID; + int? page; + int? countReq; + List? token; + int? needAuthor; + List? signKey; + List? privateKey; + @override String toString() { return 'UpdataLockPasswordListCommand{lockID: $lockID, keyID:$keyID userID: $userID, ' @@ -41,24 +41,24 @@ class UpdataLockPasswordListCommand extends SenderProtocol { @override List messageDetail() { - List data = []; - List ebcData = []; + List data = []; + List ebcData = []; // 指令类型 - int type = commandType!.typeValue; - double typeDouble = type / 256; - int type1 = typeDouble.toInt(); - int type2 = type % 256; + final int type = commandType!.typeValue; + final double typeDouble = type / 256; + final int type1 = typeDouble.toInt(); + final int type2 = type % 256; data.add(type1); data.add(type2); // 锁id 40 - int lockIDLength = utf8.encode(lockID!).length; + final int lockIDLength = utf8.encode(lockID!).length; data.addAll(utf8.encode(lockID!)); data = getFixedLengthList(data, 40 - lockIDLength); //userID 要接受钥匙的用户的useid 20 - int userIDLength = utf8.encode(userID!).length; + final int userIDLength = utf8.encode(userID!).length; data.addAll(utf8.encode(userID!)); data = getFixedLengthList(data, 20 - userIDLength); @@ -75,7 +75,7 @@ class UpdataLockPasswordListCommand extends SenderProtocol { //AuthCodeLen 1 data.add(0); } else { - List authCodeData = []; + final List authCodeData = []; //KeyID authCodeData.addAll(utf8.encode(lockID!)); @@ -88,14 +88,14 @@ class UpdataLockPasswordListCommand extends SenderProtocol { authCodeData.addAll(signKey!); // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode - var authCode = crypto.md5.convert(authCodeData); + final crypto.Digest authCode = crypto.md5.convert(authCodeData); data.add(authCode.bytes.length); data.addAll(authCode.bytes); } if ((data.length % 16) != 0) { - int add = (16 - data.length % 16); + final int add = 16 - data.length % 16; for (int i = 0; i < add; i++) { data.add(0); } @@ -113,7 +113,7 @@ class UpdataLockPasswordListReply extends Reply { : super.parseData(commandType, dataDetail) { data = dataDetail; - int status = data[2]; + final int status = data[2]; errorWithStstus(status); } } \ No newline at end of file diff --git a/lib/blue/io_protocol/io_updataLockRemoteControlList.dart b/lib/blue/io_protocol/io_updataLockRemoteControlList.dart index 00b94ab8..2e1049a7 100644 --- a/lib/blue/io_protocol/io_updataLockRemoteControlList.dart +++ b/lib/blue/io_protocol/io_updataLockRemoteControlList.dart @@ -41,8 +41,8 @@ class UpdataLockRemoteControlListCommand extends SenderProtocol { @override List messageDetail() { - List data = []; - List ebcData = []; + List data = []; + List ebcData = []; // 指令类型 final int type = commandType!.typeValue; @@ -75,7 +75,7 @@ class UpdataLockRemoteControlListCommand extends SenderProtocol { //AuthCodeLen 1 data.add(0); } else { - final List authCodeData = []; + final List authCodeData = []; //KeyID authCodeData.addAll(utf8.encode(lockID!)); @@ -88,7 +88,7 @@ class UpdataLockRemoteControlListCommand extends SenderProtocol { authCodeData.addAll(signKey!); // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode - final authCode = crypto.md5.convert(authCodeData); + final crypto.Digest authCode = crypto.md5.convert(authCodeData); data.add(authCode.bytes.length); data.addAll(authCode.bytes); diff --git a/lib/blue/io_sender.dart b/lib/blue/io_sender.dart index 7fec2557..cbd1c631 100755 --- a/lib/blue/io_sender.dart +++ b/lib/blue/io_sender.dart @@ -1,16 +1,19 @@ -import 'dart:typed_data'; import 'package:star_lock/app_settings/app_settings.dart'; import 'io_tool/io_manager.dart'; -import 'io_tool/io_tool.dart'; import 'io_type.dart'; abstract class IOData { List messageDetail(); } -abstract class SenderProtocol extends IOData { +abstract class SenderProtocol extends IOData { //数据块 + // final int? tail = 0xFF; //用来校验包的完整性,采用 CRC 校验方法,长度为 2 个字节 + + SenderProtocol(this.commandType) { + _commandIndex = IoManager().commandIndex; + } // var uint8View1 = Uint8List(300); CommandType? commandType; //指令类型 @@ -21,17 +24,12 @@ abstract class SenderProtocol extends IOData { 0X02 ]; //帧头 固定取值 0XEF01EE02,长度 4 字节 final int ask = 0X01; // 包类型:0X01 表示请求包,0X11 表示应答包,长度 1 字节 - int? _commandIndex = 1; //包序号 + int _commandIndex = 1; //包序号 int identifier = 0x20; // 高 4 位表示包版本,低 4 位用来指示后面数据的加密类型,长度为 1 字节,加密类型取值说明,0:明文,1:AES128,2:SM4(事先约定密钥),3:SM4(设备指定密钥) - List? commandData = []; //数据块 - // final int? tail = 0xFF; //用来校验包的完整性,采用 CRC 校验方法,长度为 2 个字节 - - SenderProtocol(this.commandType) { - _commandIndex = IoManager().commandIndex; - } + List? commandData = []; void printLog(List data) { AppLog.log( @@ -39,10 +37,10 @@ abstract class SenderProtocol extends IOData { ? '子命令:${data[3]}' : ''} \n参数是:\n${toString()} \n加密之前数据是:\n$data 长度是:${data.length}"); } - //TODO:拼装数据 + // 拼装数据 List packageData() { commandData = messageDetail(); - List commandList = []; + final List commandList = []; // 帧头 commandList.addAll(header); @@ -51,24 +49,24 @@ abstract class SenderProtocol extends IOData { commandList.add(ask); //包类型 // 包序号 - int commandIndexChange = _commandIndex!; - double commandIndexChangeDouble = commandIndexChange / 256; - int commandIndexChang1 = commandIndexChangeDouble.toInt(); - int commandIndexChang2 = commandIndexChange % 256; + final int commandIndexChange = _commandIndex; + final double commandIndexChangeDouble = commandIndexChange / 256; + final int commandIndexChang1 = commandIndexChangeDouble.toInt(); + final int commandIndexChang2 = commandIndexChange % 256; commandList.add(commandIndexChang1); commandList.add(commandIndexChang2); // 包标识 // 指令类型 高 4 位表示包版本,低 4 位用来指示后面数据的加密类型,长度为 1 字节,加密类型取值说明,0:明文,1:AES128,2:SM4(事先约定密钥),3:SM4(设备指定密钥) - int value = identifierValue(); + final int value = identifierValue(); commandList.add(value); // 数据长度 - int dataLen = dataSourceLength(); + final int dataLen = dataSourceLength(); // commandList.add(dataLength); // var dataLen = 42; - double dataLength = dataLen / 256; + final double dataLength = dataLen / 256; commandList.add(dataLength.toInt()); commandList.add(dataLen % 256); commandList.add(dataLength.toInt()); @@ -78,10 +76,10 @@ abstract class SenderProtocol extends IOData { commandList.addAll(commandData!); //数据块 // 校验位 - int mcrc = crc_16(commandList); - double mcrcDouble = mcrc / 256; - int mcrcDouble1 = mcrcDouble.toInt(); - int mcrcDouble2 = mcrc % 256; + final int mcrc = crc_16(commandList); + final double mcrcDouble = mcrc / 256; + final int mcrcDouble1 = mcrcDouble.toInt(); + final int mcrcDouble2 = mcrc % 256; commandList.add(mcrcDouble1); //帧尾 commandList.add(mcrcDouble2); return commandList; @@ -91,7 +89,7 @@ abstract class SenderProtocol extends IOData { // 指令类型 高 4 位表示包版本,低 4 位用来指示后面数据的加密类型,长度为 1 字节,加密类型取值说明,0:明文,1:AES128,2:SM4(事先约定密钥),3:SM4(设备指定密钥) int identifierValue() => commandType!.identifierValue; - //TODO:长度 + // 长度 int dataSourceLength() => commandData!.length; List crcTable = [ @@ -353,8 +351,7 @@ abstract class SenderProtocol extends IOData { 0x1ef0 ]; - int crc_16(buffer) { - var len = buffer.length; + int crc_16(List buffer) { int value_ = 0x0000; //0xa635; //初始值,根据CRC类型设定 int tmp; for (int i = 0; i < buffer.length; i++) { @@ -366,7 +363,7 @@ abstract class SenderProtocol extends IOData { return value_; } - int reverse8(data) { + int reverse8(int data) { int i; int temp = 0; for (i = 0; i < 8; i++) { @@ -376,7 +373,7 @@ abstract class SenderProtocol extends IOData { return temp; } - int reverse16(data) { + int reverse16(int data) { int i; int temp = 0; for (i = 0; i < 16; i++) { diff --git a/lib/blue/io_tool/io_manager.dart b/lib/blue/io_tool/io_manager.dart index 7b8e51e8..b4d477af 100755 --- a/lib/blue/io_tool/io_manager.dart +++ b/lib/blue/io_tool/io_manager.dart @@ -4,14 +4,14 @@ enum DataTransmissionMode { } class IoManager { + factory IoManager() => share(); + IoManager._init(); static IoManager? _ioManager; - IoManager._init(); static IoManager share(){ _ioManager ??= IoManager._init(); return _ioManager!; } - factory IoManager() => share(); IoManager get manager => share(); //数据传输方式 @@ -23,7 +23,7 @@ class IoManager { ///协议帧序号 int _commandIndex = 1; - configCommandIdx(int idx) => _commandIndex = idx; + int configCommandIdx(int idx) => _commandIndex = idx; Future increaseCommandIndex() async { _commandIndex < 255 ? _commandIndex++ : _commandIndex = 0; } @@ -31,8 +31,8 @@ class IoManager { int get commandIndex => _commandIndex; /// 当前设备连接的lockId - String _currentDeviceLockId = ""; - configCurrentDeviceLockId(String lockId) => _currentDeviceLockId = lockId; + String _currentDeviceLockId = ''; + String configCurrentDeviceLockId(String lockId) => _currentDeviceLockId = lockId; String get getCurrentDeviceLockId => _currentDeviceLockId; void resetAllFlags() { diff --git a/lib/blue/io_tool/io_model.dart b/lib/blue/io_tool/io_model.dart index ccb1dec5..0dc79873 100755 --- a/lib/blue/io_tool/io_model.dart +++ b/lib/blue/io_tool/io_model.dart @@ -19,7 +19,7 @@ class EventSendModel { this.serviceId, this.characteristicId, this.allowLongWrite}); - List data = []; + List data = []; String? topic = ''; DataChannel? sendChannel; diff --git a/lib/blue/io_tool/io_tool.dart b/lib/blue/io_tool/io_tool.dart index e4f311d8..7720ad67 100755 --- a/lib/blue/io_tool/io_tool.dart +++ b/lib/blue/io_tool/io_tool.dart @@ -1,3 +1,4 @@ + import 'dart:convert'; import 'dart:typed_data'; @@ -113,7 +114,7 @@ String uint8ToHex(Uint8List byteArr) { return String.fromCharCodes(result); //Unicode转回为对应字符,生成字符串返回 } -//TODO:int->两个字节 List 低字节在前,高字节在后(大端存储)=>嵌入式小端接收(协议用到) +// int->两个字节 List 低字节在前,高字节在后(大端存储)=>嵌入式小端接收(协议用到) int byteInt8(List dataDetail, int index) => _toInt8(dataDetail[index]); int _toInt8(int value) { @@ -165,7 +166,7 @@ List intToInt8List(int value) => [value]; List intToByte2ListHigh(int value) => [value, value >> 8]; -//TODO:int->4个字节List 低字节在前,高字节在后(大端存储) 1byte = 8bit +// int->4个字节List 低字节在前,高字节在后(大端存储) 1byte = 8bit List intToByte4ListHigh(int value) => [value, value >> 8, value >> 16, value >> 24]; @@ -217,9 +218,6 @@ int _toUInt32(int value) { } bool checkListIndex(List dataDetail, int index, int offsetLength) { - if (dataDetail == null) { - return true; - } final int len = dataDetail.length; final bool result = index + offsetLength > len; if (result) {} @@ -262,7 +260,7 @@ List> splitList(List list, int len) { return result; } -//TODO:int->两个字节 List 高字节在前,低字节在后(小端存储) 本工程只有配置 WiFi用到的!!!! +// int->两个字节 List 高字节在前,低字节在后(小端存储) 本工程只有配置 WiFi用到的!!!! List intToByte2ListLow(int value) => [value >> 8, value]; String radixHex16String(List codeUnits) { diff --git a/lib/blue/io_tool/manager_event_bus.dart b/lib/blue/io_tool/manager_event_bus.dart index d094cff5..f85b9bc7 100755 --- a/lib/blue/io_tool/manager_event_bus.dart +++ b/lib/blue/io_tool/manager_event_bus.dart @@ -3,19 +3,19 @@ import 'package:event_bus/event_bus.dart'; class EventBusManager { - EventBus? eventBus; - static EventBusManager? _manager; + factory EventBusManager() => shareManager(); EventBusManager._init(){ eventBus = EventBus(sync: false); } + EventBus? eventBus; + + static EventBusManager? _manager; static EventBusManager shareManager(){ _manager ??= EventBusManager._init(); return _manager!; } - - factory EventBusManager() => shareManager(); EventBusManager get manager => shareManager(); //发送事件 eventBusFir(dynamic event) { diff --git a/lib/blue/io_type.dart b/lib/blue/io_type.dart index dcf43365..84dc9e86 100755 --- a/lib/blue/io_type.dart +++ b/lib/blue/io_type.dart @@ -1,4 +1,4 @@ -//TODO:发送指令类型 +// 发送指令类型 enum CommandType { addUser, //增加用户 = 0x3001 deletUser, //删除用户 = 0x3002 diff --git a/lib/blue/reciver_data.dart b/lib/blue/reciver_data.dart index b4a11e88..3cb58cad 100755 --- a/lib/blue/reciver_data.dart +++ b/lib/blue/reciver_data.dart @@ -123,8 +123,8 @@ class CommandReciverManager { parseData(oriDataList).then((Reply? value) async { EasyLoading.dismiss(); await EventBusManager().eventBusFir(value); - }).catchError((error) { - AppLog.log('APP解析数据时发生错误: $error'); + }).catchError((Object error) { + AppLog.log('APP解析数据时发生错误: ${error.toString()}'); }); } } diff --git a/lib/blue/sender_beforeDataManage.dart b/lib/blue/sender_beforeDataManage.dart index e34ba60c..79f30b4b 100755 --- a/lib/blue/sender_beforeDataManage.dart +++ b/lib/blue/sender_beforeDataManage.dart @@ -69,9 +69,9 @@ class SenderBeforeDataManage { switch (status) { case 0x00: //成功 - var userNoData = reply.data.sublist(47, 49); - CommonDataManage().currentLockUserNo = listChangInt(userNoData); - CommonDataManage().currentKeyInfo.lockUserNo = CommonDataManage().currentLockUserNo; + final List userNoData = reply.data.sublist(47, 49); + CommonDataManage().currentLockUserNo = listChangInt(userNoData); + CommonDataManage().currentKeyInfo.lockUserNo = CommonDataManage().currentLockUserNo; _updateLockUserNo(userNoData); break; diff --git a/lib/blue/sender_data.dart b/lib/blue/sender_data.dart index 3e4986b1..04ae6da3 100755 --- a/lib/blue/sender_data.dart +++ b/lib/blue/sender_data.dart @@ -21,7 +21,7 @@ class CommandSenderManager { static CommandSenderManager getInstance() => _manager; - init() { + void init() { _initLockAddUserSucceedEvent(); _initTransferSmartLockSucceedEvent(); } @@ -149,7 +149,7 @@ class CommandSenderManager { // bufferList = []; // } - dispose() { + void dispose() { _passCurrentLockInformationEvent?.cancel(); _transferSmartLockEvent?.cancel(); } diff --git a/lib/blue/sm4Encipher/sm4.dart b/lib/blue/sm4Encipher/sm4.dart index d989d07b..38df45db 100755 --- a/lib/blue/sm4Encipher/sm4.dart +++ b/lib/blue/sm4Encipher/sm4.dart @@ -4,7 +4,7 @@ import 'utils/utils.dart'; enum SM4CryptoMode { ECB, CBC } class SM4 { - static const List S_BOX = [ + static const List S_BOX = [ 0xd6, 0x90, 0xe9, @@ -263,9 +263,9 @@ class SM4 { 0x48 ]; - static const List FK = [0xA3B1BAC6, 0x56AA3350, 0x677D9197, 0xB27022DC]; + static const List FK = [0xA3B1BAC6, 0x56AA3350, 0x677D9197, 0xB27022DC]; - static const List CK = [ + static const List CK = [ 0x00070e15, 0x1c232a31, 0x383f464d, @@ -306,8 +306,8 @@ class SM4 { static const int blockSize = 16; - static final _encryptKey = List.filled(32, 0); - static final _decryptKey = List.filled(32, 0); + static final List _encryptKey = List.filled(32, 0); + static final List _decryptKey = List.filled(32, 0); static int _readUint32BE(List b, int i) { return ((b[i] & 0xff) << 24) | @@ -317,20 +317,20 @@ class SM4 { } static void _writeUint32BE(int n, List b, int i) { - b[i] = ((n >> 24) & 0xff); - b[i + 1] = ((n >> 16) & 0xff); - b[i + 2] = ((n >> 8) & 0xff); + b[i] = (n >> 24) & 0xff; + b[i + 1] = (n >> 16) & 0xff; + b[i + 2] = (n >> 8) & 0xff; b[i + 3] = n & 0xff; } static int _Sbox(int inch) => S_BOX[inch & 0xFF]; static int _sm4F(int x0, int x1, int x2, int x3, int rk) { - final x = x1 ^ x2 ^ x3 ^ rk; + final int x = x1 ^ x2 ^ x3 ^ rk; int bb = 0; int c = 0; - List a = List.filled(4, 0); - List b = List.filled(4, 0); + final List a = List.filled(4, 0); + final List b = List.filled(4, 0); _writeUint32BE(x, a, 0); b[0] = _Sbox(a[0]); b[1] = _Sbox(a[1]); @@ -348,20 +348,20 @@ class SM4 { static int _calculateRoundKey(int key) { int roundKey = 0; - List keyBytes = List.filled(4, 0); - List sboxBytes = List.filled(4, 0); + final List keyBytes = List.filled(4, 0); + final List sboxBytes = List.filled(4, 0); _writeUint32BE(key, keyBytes, 0); for (int i = 0; i < 4; i++) { sboxBytes[i] = _Sbox(keyBytes[i]); } - int temp = _readUint32BE(sboxBytes, 0); + final int temp = _readUint32BE(sboxBytes, 0); roundKey = temp ^ SMUtils.leftShift(temp, 13) ^ SMUtils.leftShift(temp, 23); return roundKey; } static void setKey(List key) { - List keyBytes = key; - List intermediateKeys = List.filled(36, 0); + final List keyBytes = key; + final List intermediateKeys = List.filled(36, 0); for (int i = 0; i < 4; i++) { intermediateKeys[i] = _readUint32BE(keyBytes, i * 4) ^ FK[i]; } @@ -375,7 +375,7 @@ class SM4 { } for (int i = 0; i < 16; i++) { - int temp = _encryptKey[i]; + final int temp = _encryptKey[i]; _decryptKey[i] = _encryptKey[31 - i]; _decryptKey[31 - i] = temp; } @@ -383,7 +383,7 @@ class SM4 { static void _round(List sk, List input, List output) { int i = 0; - List ulbuf = List.filled(36, 0); + final List ulbuf = List.filled(36, 0); ulbuf[0] = _readUint32BE(input, 0); ulbuf[1] = _readUint32BE(input, 4); ulbuf[2] = _readUint32BE(input, 8); @@ -404,7 +404,7 @@ class SM4 { final int padLen = blockSize - (input.length % blockSize); if (mode == SM4_ENCRYPT) { - final paddedList = List.filled(input.length + padLen, 0); + final List paddedList = List.filled(input.length + padLen, 0); paddedList.setRange(0, input.length, input); for (int i = input.length; i < paddedList.length; i++) { paddedList[i] = padLen; @@ -423,23 +423,24 @@ class SM4 { List data, int flag, SM4CryptoMode mode, String? iv) { late List lastVector; if (mode == SM4CryptoMode.CBC) { - if (iv == null || iv.length != 32) - throw Exception("IV must be a string of length 16"); - else + if (iv == null || iv.length != 32) { + throw Exception('IV must be a string of length 16'); + } else { lastVector = SMUtils.hexStringToBytes(iv); + } } - final key = (flag == SM4_ENCRYPT) ? _encryptKey : _decryptKey; + final List key = (flag == SM4_ENCRYPT) ? _encryptKey : _decryptKey; if (flag == SM4_ENCRYPT) { data = _padding(data, SM4_ENCRYPT); } - final length = data.length; - final List output = []; + final int length = data.length; + final List output = []; for (int offset = 0; offset < length; offset += blockSize) { - final outData = List.filled(blockSize, 0); - final copyLen = + final List outData = List.filled(blockSize, 0); + final int copyLen = (offset + blockSize <= length) ? blockSize : length - offset; - final input = data.sublist(offset, offset + copyLen); + final List input = data.sublist(offset, offset + copyLen); if (mode == SM4CryptoMode.CBC && flag == SM4_ENCRYPT) { for (int i = 0; i < blockSize; i++) { input[i] = input[i] ^ lastVector[i]; @@ -476,18 +477,18 @@ class SM4 { // /// auto add 0x00 static List _autoAddZero(List list) { /// supplementary list - List supplementList = List.filled(16, 0x00); + final List supplementList = List.filled(16, 0x00); /// complete list - List completeList = [...list, ...supplementList].sublist(0, 16); + final List completeList = [...list, ...supplementList].sublist(0, 16); return completeList; } /// hex byte list to hex string static String _listToHex(List arr) { - String hexString = arr - .map((item) { - String itemHexString = item.toRadixString(16); + final String hexString = arr + .map((int item) { + final String itemHexString = item.toRadixString(16); // The hexadecimal notation is 0123456789ABCDEF //if there is a single one, add 0 if (itemHexString.length == 1) { @@ -504,7 +505,7 @@ class SM4 { static String createHexKey({ required String key, - autoPushZero = true, + bool autoPushZero = true, }) { List keyList = _utf8ToArray(key); @@ -521,9 +522,11 @@ class SM4 { static List encrypt(List data, {List? key, SM4CryptoMode mode = SM4CryptoMode.ECB, String? iv}) { - if (key != null) setKey(key); - List input = data; - List output = _crypto(input, SM4_ENCRYPT, mode, iv); + if (key != null) { + setKey(key); + } + final List input = data; + final List output = _crypto(input, SM4_ENCRYPT, mode, iv); return output; } @@ -535,11 +538,13 @@ class SM4 { // return utf8.decode(output); // } - static decrypt(List data, + static List decrypt(List data, {List? key, SM4CryptoMode mode = SM4CryptoMode.ECB, String? iv}) { - if (key != null) setKey(key); - List input = data; - List output = _crypto(input, SM4_DECRYPT, mode, iv); + if (key != null) { + setKey(key); + } + final List input = data; + final List output = _crypto(input, SM4_DECRYPT, mode, iv); return output; } } diff --git a/lib/blue/sm4Encipher/utils/asn1.dart b/lib/blue/sm4Encipher/utils/asn1.dart index 144578a7..cb38619e 100755 --- a/lib/blue/sm4Encipher/utils/asn1.dart +++ b/lib/blue/sm4Encipher/utils/asn1.dart @@ -1,14 +1,14 @@ class _ASN1Object { - String? tlv; - String t = '00'; - String l = '00'; - String v = ''; _ASN1Object() { tlv = null; } + String? tlv; + String t = '00'; + String l = '00'; + String v = ''; /// 获取 der 编码比特流16进制串 String getEncodedHex() { @@ -84,11 +84,11 @@ class _DERInteger extends _ASN1Object { } class _DERSequence extends _ASN1Object { - List<_ASN1Object> asn1Array; _DERSequence(this.asn1Array) : super() { t = '30'; // 序列标签说明 } + List<_ASN1Object> asn1Array; @override String getValue() { diff --git a/lib/blue/sm4Encipher/utils/ec.dart b/lib/blue/sm4Encipher/utils/ec.dart index 20d15d95..234ecfb8 100755 --- a/lib/blue/sm4Encipher/utils/ec.dart +++ b/lib/blue/sm4Encipher/utils/ec.dart @@ -1,10 +1,10 @@ class ECFieldElementFp { - final BigInt x; - final BigInt q; ECFieldElementFp(this.q, this.x) { - // TODO if (x.compareTo(q) >= 0) error + // if (x.compareTo(q) >= 0) error } + final BigInt x; + final BigInt q; /// 判断相等 bool equals(ECFieldElementFp other) { @@ -51,16 +51,16 @@ class ECFieldElementFp { } class ECPointFp { - final ECCurveFp curve; - late final ECFieldElementFp? x; - late final ECFieldElementFp? y; - late final BigInt z; - BigInt? zinv; ECPointFp(this.curve, this.x, this.y, [BigInt? z]) { this.z = z ?? BigInt.one; zinv = null; } + final ECCurveFp curve; + late final ECFieldElementFp? x; + late final ECFieldElementFp? y; + late final BigInt z; + BigInt? zinv; ECFieldElementFp getX() { zinv ??= z.modInverse(curve.q); @@ -73,19 +73,29 @@ class ECPointFp { } bool equals(ECPointFp other) { - if (other == this) return true; - if (isInfinity()) return other.isInfinity(); - if (other.isInfinity()) return isInfinity(); + if (other == this) { + return true; + } + if (isInfinity()) { + return other.isInfinity(); + } + if (other.isInfinity()) { + return isInfinity(); + } - final u = (other.y!.toBigInteger() * z - y!.toBigInteger() * other.z) % curve.q; - if (u != BigInt.zero) return false; + final BigInt u = (other.y!.toBigInteger() * z - y!.toBigInteger() * other.z) % curve.q; + if (u != BigInt.zero) { + return false; + } - final v = (other.x!.toBigInteger() * z - x!.toBigInteger() * other.z) % curve.q; + final BigInt v = (other.x!.toBigInteger() * z - x!.toBigInteger() * other.z) % curve.q; return v == BigInt.zero; } bool isInfinity() { - if (x == null && y == null) return true; + if (x == null && y == null) { + return true; + } return z == BigInt.zero && y!.toBigInteger() != BigInt.zero; } @@ -94,21 +104,25 @@ class ECPointFp { } ECPointFp add(ECPointFp b) { - if (isInfinity()) return b; - if (b.isInfinity()) return this; - final x1 = x!.toBigInteger(); - final y1 = y!.toBigInteger(); - final z1 = z; - final x2 = b.x!.toBigInteger(); - final y2 = b.y!.toBigInteger(); - final z2 = b.z; - final q = curve.q; - final w1 = (x1 * z2) % q; - final w2 = (x2 * z1) % q; - final w3 = (w1 - w2) % q; - final w4 = (y1 * z2) % q; - final w5 = (y2 * z1) % q; - final w6 = (w4 - w5) % q; + if (isInfinity()) { + return b; + } + if (b.isInfinity()) { + return this; + } + final BigInt x1 = x!.toBigInteger(); + final BigInt y1 = y!.toBigInteger(); + final BigInt z1 = z; + final BigInt x2 = b.x!.toBigInteger(); + final BigInt y2 = b.y!.toBigInteger(); + final BigInt z2 = b.z; + final BigInt q = curve.q; + final BigInt w1 = (x1 * z2) % q; + final BigInt w2 = (x2 * z1) % q; + final BigInt w3 = (w1 - w2) % q; + final BigInt w4 = (y1 * z2) % q; + final BigInt w5 = (y2 * z1) % q; + final BigInt w6 = (w4 - w5) % q; if (w3 == BigInt.zero) { if (w6 == BigInt.zero) { @@ -117,49 +131,57 @@ class ECPointFp { return curve.infinity; } - final w7 = (w1 + w2) % q; - final w8 = (z1 * z2) % q; - final w9 = (w3 * w3) % q; - final w10 = (w3 * w9) % q; - final w11 = (w8 * (w6 * w6) % q - w7 * w9) % q; + final BigInt w7 = (w1 + w2) % q; + final BigInt w8 = (z1 * z2) % q; + final BigInt w9 = (w3 * w3) % q; + final BigInt w10 = (w3 * w9) % q; + final BigInt w11 = (w8 * (w6 * w6) % q - w7 * w9) % q; - final x3 = (w3 * w11) % q; - final y3 = (w6 * (w9 * w1 % q - w11) - w4 * w10) % q; - final z3 = (w10 * w8) % q; + final BigInt x3 = (w3 * w11) % q; + final BigInt y3 = (w6 * (w9 * w1 % q - w11) - w4 * w10) % q; + final BigInt z3 = (w10 * w8) % q; return ECPointFp(curve, curve.fromBigInteger(x3), curve.fromBigInteger(y3), z3); } ECPointFp twice() { - if (isInfinity()) return this; - if (y!.toBigInteger().sign == 0) return curve.infinity; + if (isInfinity()) { + return this; + } + if (y!.toBigInteger().sign == 0) { + return curve.infinity; + } - final x1 = x!.toBigInteger(); - final y1 = y!.toBigInteger(); - final z1 = z; - final q = curve.q; - final a = curve.a.toBigInteger(); + final BigInt x1 = x!.toBigInteger(); + final BigInt y1 = y!.toBigInteger(); + final BigInt z1 = z; + final BigInt q = curve.q; + final BigInt a = curve.a.toBigInteger(); - final w1 = (x1 * x1 * BigInt.from(3) + a * (z1 * z1)) % q; - final w2 = (y1 * BigInt.from(2) * z1) % q; - final w3 = (y1 * y1) % q; - final w4 = (w3 * x1 * z1) % q; - final w5 = (w2 * w2) % q; - final w6 = (w1 * w1 - w4 * BigInt.from(8)) % q; + final BigInt w1 = (x1 * x1 * BigInt.from(3) + a * (z1 * z1)) % q; + final BigInt w2 = (y1 * BigInt.from(2) * z1) % q; + final BigInt w3 = (y1 * y1) % q; + final BigInt w4 = (w3 * x1 * z1) % q; + final BigInt w5 = (w2 * w2) % q; + final BigInt w6 = (w1 * w1 - w4 * BigInt.from(8)) % q; - final x3 = (w2 * w6) % q; - final y3 = (w1 * (w4 * BigInt.from(4) - w6) - w5 * BigInt.from(2) * w3) % q; - final z3 = (w2 * w5) % q; + final BigInt x3 = (w2 * w6) % q; + final BigInt y3 = (w1 * (w4 * BigInt.from(4) - w6) - w5 * BigInt.from(2) * w3) % q; + final BigInt z3 = (w2 * w5) % q; return ECPointFp(curve, curve.fromBigInteger(x3), curve.fromBigInteger(y3), z3); } ECPointFp multiply(BigInt k) { - if (isInfinity()) return this; - if (k.sign == 0) return curve.infinity; + if (isInfinity()) { + return this; + } + if (k.sign == 0) { + return curve.infinity; + } - final k3 = k * BigInt.from(3); - final neg = negate(); + final BigInt k3 = k * BigInt.from(3); + final ECPointFp neg = negate(); ECPointFp Q = this; for (int i = k3.bitLength - 2; i > 0; i--) { @@ -168,9 +190,8 @@ class ECPointFp { /*final k3Bit = (k3 >> i) & BigInt.one == BigInt.one; final kBit = (k >> i) & BigInt.one == BigInt.zero;*/ - final k3Bit = (k3 >> i).isOdd; - ; - final kBit = (k >> i).isOdd; + final bool k3Bit = (k3 >> i).isOdd; + final bool kBit = (k >> i).isOdd; if (k3Bit != kBit) { Q = Q.add(k3Bit ? this : neg); @@ -194,8 +215,12 @@ class ECCurveFp { late ECPointFp infinity; bool equals(Object? other) { - if (identical(this, other)) return true; - if (other is! ECCurveFp) return false; + if (identical(this, other)) { + return true; + } + if (other is! ECCurveFp) { + return false; + } return q == other.q && a == other.a && b == other.b; } @@ -209,8 +234,8 @@ class ECCurveFp { return infinity; case 2: case 3: - final x = fromBigInteger(BigInt.parse(s.substring(2), radix: 16)); - var y = fromBigInteger(x + final ECFieldElementFp x = fromBigInteger(BigInt.parse(s.substring(2), radix: 16)); + ECFieldElementFp y = fromBigInteger(x .multiply(x.square()) .add(x.multiply(a)) .add(b) @@ -230,9 +255,9 @@ class ECCurveFp { case 4: case 6: case 7: - final len = (s.length - 2) ~/ 2; - final xHex = s.substring(2, 2 + len); - final yHex = s.substring(2 + len, 2 + 2 * len); + final int len = (s.length - 2) ~/ 2; + final String xHex = s.substring(2, 2 + len); + final String yHex = s.substring(2 + len, 2 + 2 * len); /*print("xHex: ${BigInt.parse(xHex, radix: 16).toRadixString(16)}"); print("yHex: ${BigInt.parse(yHex, radix: 16).toRadixString(16)}");*/ return ECPointFp(this, fromBigInteger(BigInt.parse(xHex, radix: 16)), @@ -244,7 +269,9 @@ class ECCurveFp { } String leftPad(String input, int num) { - if (input.length >= num) return input; + if (input.length >= num) { + return input; + } return List.filled(num - input.length, '0').join() + input; } diff --git a/lib/common/safetyVerification/safetyVerification_state.dart b/lib/common/safetyVerification/safetyVerification_state.dart index d553bf65..691f62e3 100755 --- a/lib/common/safetyVerification/safetyVerification_state.dart +++ b/lib/common/safetyVerification/safetyVerification_state.dart @@ -4,15 +4,14 @@ import 'package:get/get.dart'; import 'entity/SafetyVerificationEntity.dart'; class SafetyVerificationState{ - - // Rx safetyVerificationEntity = SafetyVerificationEntity().obs; - var sliderXMoved = 0.0.obs; - var getData = {}.obs; - SafetyVerificationState() { getData.value = Get.arguments as Map; } + // Rx safetyVerificationEntity = SafetyVerificationEntity().obs; + RxDouble sliderXMoved = 0.0.obs; + RxMap getData = {}.obs; + void onClose() { } diff --git a/lib/login/forgetPassword/starLock_forgetPassword_page.dart b/lib/login/forgetPassword/starLock_forgetPassword_page.dart index 88af0188..7da46c63 100755 --- a/lib/login/forgetPassword/starLock_forgetPassword_page.dart +++ b/lib/login/forgetPassword/starLock_forgetPassword_page.dart @@ -93,7 +93,7 @@ class _StarLockForgetPasswordPageState ), LoginInput( controller: state.phoneController, - onchangeAction: (v) { + onchangeAction: (dynamic v) { logic.checkNext(state.phoneController); }, leftWidget: Padding( @@ -113,7 +113,7 @@ class _StarLockForgetPasswordPageState SizedBox(height: 10.h), LoginInput( controller: state.pwdController, - onchangeAction: (v) { + onchangeAction: (dynamic v) { logic.checkNext(state.pwdController); }, isPwd: true, @@ -141,7 +141,7 @@ class _StarLockForgetPasswordPageState SizedBox(height: 10.w), LoginInput( controller: state.sureController, - onchangeAction: (v) { + onchangeAction: (dynamic v) { logic.checkNext(state.sureController); }, isPwd: true, @@ -166,7 +166,7 @@ class _StarLockForgetPasswordPageState Expanded( child: LoginInput( controller: state.codeController, - onchangeAction: (v) { + onchangeAction: (dynamic v) { logic.checkNext(state.codeController); }, leftWidget: Padding( diff --git a/lib/login/forgetPassword/starLock_forgetPassword_xhj_page.dart b/lib/login/forgetPassword/starLock_forgetPassword_xhj_page.dart index 8d4c4872..3d55a3d7 100755 --- a/lib/login/forgetPassword/starLock_forgetPassword_xhj_page.dart +++ b/lib/login/forgetPassword/starLock_forgetPassword_xhj_page.dart @@ -81,7 +81,7 @@ class _StarLockForgetPasswordPageState ), LoginInput( controller: state.phoneController, - onchangeAction: (v) { + onchangeAction: (dynamic v) { logic.checkNext(state.phoneController); }, leftWidget: Padding( @@ -94,7 +94,7 @@ class _StarLockForgetPasswordPageState ]), LoginInput( controller: state.pwdController, - onchangeAction: (v) { + onchangeAction: (dynamic v) { logic.checkNext(state.pwdController); }, isPwd: true, @@ -113,7 +113,7 @@ class _StarLockForgetPasswordPageState ), LoginInput( controller: state.sureController, - onchangeAction: (v) { + onchangeAction: (dynamic v) { logic.checkNext(state.sureController); }, isPwd: true, @@ -131,10 +131,10 @@ class _StarLockForgetPasswordPageState Expanded( child: LoginInput( controller: state.codeController, - onchangeAction: (v) { + onchangeAction: (dynamic v) { logic.checkNext(state.codeController); }, - leftWidget: SizedBox(), + leftWidget: const SizedBox(), hintText: '请输入验证码'.tr, inputFormatters: [ diff --git a/lib/login/login/starLock_login_binding.dart b/lib/login/login/starLock_login_binding.dart index 9cba24cc..f017e5c0 100755 --- a/lib/login/login/starLock_login_binding.dart +++ b/lib/login/login/starLock_login_binding.dart @@ -1,9 +1,7 @@ import 'package:get/get.dart'; - import 'starLock_login_logic.dart'; - class StarLockLoginBinding extends Bindings { @override void dependencies() { diff --git a/lib/login/login/starLock_login_page.dart b/lib/login/login/starLock_login_page.dart index d381196c..42f00b78 100755 --- a/lib/login/login/starLock_login_page.dart +++ b/lib/login/login/starLock_login_page.dart @@ -62,7 +62,7 @@ class _StarLockLoginPageState extends State { style: TextStyle(color: Colors.white, fontSize: 24.sp), ), onPressed: () async { - var data = await Get.toNamed(Routers.starLockRegisterPage); + final data = await Get.toNamed(Routers.starLockRegisterPage); if (data != null) { state.emailOrPhoneController.text = data['phoneOrEmailStr']; logic.checkNext(state.emailOrPhoneController); @@ -98,7 +98,7 @@ class _StarLockLoginPageState extends State { fontSize: 22.sp, color: AppColors.darkGrayTextColor), ), action: () async { - var result = + final result = await Get.toNamed(Routers.selectCountryRegionPage); if (result != null) { result as Map; diff --git a/lib/mine/gateway/addGateway/selectGateway/selectGatewayList_logic.dart b/lib/mine/gateway/addGateway/selectGateway/selectGatewayList_logic.dart index a21ad7fc..7a782c42 100644 --- a/lib/mine/gateway/addGateway/selectGateway/selectGatewayList_logic.dart +++ b/lib/mine/gateway/addGateway/selectGateway/selectGatewayList_logic.dart @@ -54,7 +54,7 @@ class SelectGatewayListLogic extends BaseGetXController { // lockInfo['mac'] = macStr; gatewayModel.mac = macStr; index = index + 20; - AppLog.log('网关MAC地址 macList:$macList macStr:$macStr'); + // AppLog.log('网关MAC地址 macList:$macList macStr:$macStr'); // 网关序列号 final List serialNum = reply.data.sublist(index, index + 20); @@ -62,7 +62,7 @@ class SelectGatewayListLogic extends BaseGetXController { // lockInfo['serialNum'] = serialNumStr; gatewayModel.serialNum = serialNumStr; index = index + 20; - AppLog.log('网关序列号 serialNum:$serialNum serialNumStr:$serialNumStr'); + // AppLog.log('网关序列号 serialNum:$serialNum serialNumStr:$serialNumStr'); // 网关版本 final List gatewayVersion = reply.data.sublist(index, index + 20); @@ -70,7 +70,7 @@ class SelectGatewayListLogic extends BaseGetXController { // lockInfo['gatewayVersion'] = gatewayVersionStr; gatewayModel.gatewayVersion = gatewayVersionStr; index = index + 20; - AppLog.log('软件版本 gatewayVersion:$gatewayVersion gatewayVersionStr:$gatewayVersionStr'); + // AppLog.log('软件版本 gatewayVersion:$gatewayVersion gatewayVersionStr:$gatewayVersionStr'); // wifiMac地址 // final List wifiMac = reply.data.sublist(index, index + 20); diff --git a/lib/mine/gateway/gatewayConnectionLock/gatewayConnectionLockList_entity.dart b/lib/mine/gateway/gatewayConnectionLock/gatewayConnectionLockList_entity.dart new file mode 100644 index 00000000..30517dc5 --- /dev/null +++ b/lib/mine/gateway/gatewayConnectionLock/gatewayConnectionLockList_entity.dart @@ -0,0 +1,81 @@ +class GatewayConnectionLockListEntity { + + GatewayConnectionLockListEntity( + {this.errorCode, this.description, this.errorMsg, this.data}); + + GatewayConnectionLockListEntity.fromJson(Map json) { + errorCode = json['errorCode']; + description = json['description']; + errorMsg = json['errorMsg']; + data = json['data'] != null ? Data.fromJson(json['data']) : null; + } + int? errorCode; + String? description; + String? errorMsg; + Data? data; + + Map toJson() { + final Map data = {}; + data['errorCode'] = errorCode; + data['description'] = description; + data['errorMsg'] = errorMsg; + if (this.data != null) { + data['data'] = this.data!.toJson(); + } + return data; + } +} + +class Data { + + Data({this.list, this.total, this.pageNo, this.pageSize}); + + Data.fromJson(Map json) { + if (json['list'] != null) { + list = []; + json['list'].forEach((v) { + list!.add(GatewayConnectionLockItemEntity.fromJson(v)); + }); + } + total = json['total']; + pageNo = json['pageNo']; + pageSize = json['pageSize']; + } + List? list; + int? total; + int? pageNo; + int? pageSize; + + Map toJson() { + final Map data = {}; + if (list != null) { + data['list'] = list!.map((v) => v.toJson()).toList(); + } + data['total'] = total; + data['pageNo'] = pageNo; + data['pageSize'] = pageSize; + return data; + } +} + +class GatewayConnectionLockItemEntity { + + GatewayConnectionLockItemEntity({this.lockId, this.lockAlias, this.rssi}); + + GatewayConnectionLockItemEntity.fromJson(Map json) { + lockId = json['lockId']; + lockAlias = json['lockAlias']; + rssi = json['rssi']; + } + int? lockId; + String? lockAlias; + int? rssi; + + Map toJson() { + final Map data = {}; + data['lockId'] = lockId; + data['lockAlias'] = lockAlias; + data['rssi'] = rssi; + return data; + } +} \ No newline at end of file diff --git a/lib/mine/gateway/gatewayConnectionLock/gatewayConnectionLockList_logic.dart b/lib/mine/gateway/gatewayConnectionLock/gatewayConnectionLockList_logic.dart new file mode 100644 index 00000000..9b11979d --- /dev/null +++ b/lib/mine/gateway/gatewayConnectionLock/gatewayConnectionLockList_logic.dart @@ -0,0 +1,28 @@ + +import 'package:star_lock/tools/baseGetXController.dart'; + +import '../../../network/api_repository.dart'; +import 'gatewayConnectionLockList_entity.dart'; +import 'gatewayConnectionLockList_state.dart'; + +class GatewayConnectionLockListLogic extends BaseGetXController { + GatewayConnectionLockListState state = GatewayConnectionLockListState(); + + // 网关-附近的锁 + Future gatewayConnectionLockListDataRequest() async { + final GatewayConnectionLockListEntity entity = await ApiRepository.to.gatewayConnectionLockLoadData( + gatewayId:state.gatewayId.value + ); + if (entity.errorCode!.codeIsSuccessful) { + state.itemDataList.value = entity.data!.list!; + } + return entity; + } + + @override + void onReady() { + super.onReady(); + + gatewayConnectionLockListDataRequest(); + } +} \ No newline at end of file diff --git a/lib/mine/gateway/gatewayConnectionLock/gatewayConnectionLockList_page.dart b/lib/mine/gateway/gatewayConnectionLock/gatewayConnectionLockList_page.dart index c836f7db..7f6f67aa 100755 --- a/lib/mine/gateway/gatewayConnectionLock/gatewayConnectionLockList_page.dart +++ b/lib/mine/gateway/gatewayConnectionLock/gatewayConnectionLockList_page.dart @@ -4,8 +4,11 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import '../../../app_settings/app_colors.dart'; +import '../../../tools/noData.dart'; import '../../../tools/titleAppBar.dart'; -import '../../../translations/trans_lib.dart'; +import 'gatewayConnectionLockList_entity.dart'; +import 'gatewayConnectionLockList_logic.dart'; +import 'gatewayConnectionLockList_state.dart'; class GatewayConnectionLockListPage extends StatefulWidget { const GatewayConnectionLockListPage({Key? key}) : super(key: key); @@ -15,6 +18,8 @@ class GatewayConnectionLockListPage extends StatefulWidget { } class _GatewayConnectionLockListPageState extends State { + final GatewayConnectionLockListLogic logic = Get.put(GatewayConnectionLockListLogic()); + final GatewayConnectionLockListState state = Get.find().state; @override Widget build(BuildContext context) { @@ -26,23 +31,26 @@ class _GatewayConnectionLockListPageState extends State[ Container( width: 1.sw, color: Colors.grey.shade300, padding: EdgeInsets.all(10.h), child: Text('网关连接的锁'.tr, style: TextStyle(fontSize: 24.sp)) ), - Expanded( - child: ListView.builder( + Obx(() => Expanded( + child: + state.itemDataList.value.isNotEmpty ? + ListView.builder( itemCount:10, - itemBuilder: (c, index){ - return _gatewayConnectionLockListItem('images/mine/icon_mine_gatewaySignal_prompt.png', 'MCBN01 8f3106', '信号强'.tr,(){ + itemBuilder: (BuildContext c, int index){ + final GatewayConnectionLockItemEntity entity = state.itemDataList[index]; + return _gatewayConnectionLockListItem('images/mine/icon_mine_gatewaySignal_prompt.png', entity.lockAlias ?? '', '信号强'.tr,(){ // Navigator.pushNamed(context, Routers.gatewayDetailPage); }); } - ), - ) + ):NoData(), + )) ], ), ); @@ -60,32 +68,27 @@ class _GatewayConnectionLockListPageState extends State[ Image.asset(lockTypeIcon, width: 70.w, height: 70.w,), SizedBox(width: 20.w,), Expanded( child: Column( mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( - // color: Colors.red, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text(gateWayName, style: TextStyle(fontSize: 24.sp, fontWeight: FontWeight.w500)), - ], - ), + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text(gateWayName, style: TextStyle(fontSize: 24.sp, fontWeight: FontWeight.w500)), + ], ), SizedBox(height:5.h), - Container( - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Image.asset('images/mine/icon_mine_gatewaySignal_strong.png', width: 30.w, height: 30.w,), - SizedBox(width: 10.w,), - Text(signalStrength, style: TextStyle(fontSize: 22.sp, fontWeight: FontWeight.w500), ), - ], - ), + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Image.asset('images/mine/icon_mine_gatewaySignal_strong.png', width: 30.w, height: 30.w,), + SizedBox(width: 10.w,), + Text(signalStrength, style: TextStyle(fontSize: 22.sp, fontWeight: FontWeight.w500), ), + ], ), SizedBox(width:20.h), ], diff --git a/lib/mine/gateway/gatewayConnectionLock/gatewayConnectionLockList_state.dart b/lib/mine/gateway/gatewayConnectionLock/gatewayConnectionLockList_state.dart new file mode 100644 index 00000000..5d64b9c7 --- /dev/null +++ b/lib/mine/gateway/gatewayConnectionLock/gatewayConnectionLockList_state.dart @@ -0,0 +1,17 @@ + +import 'package:get/get.dart'; + +import 'gatewayConnectionLockList_entity.dart'; + +class GatewayConnectionLockListState{ + GatewayConnectionLockListState() { + var map = Get.arguments; + if (map['gatewayId'] > 0) { + gatewayId.value = map['gatewayId']; + } + } + + var gatewayId = 0.obs; + + final itemDataList = [].obs; +} \ No newline at end of file diff --git a/lib/mine/gateway/gatewayDetail/gatewayDetail_page.dart b/lib/mine/gateway/gatewayDetail/gatewayDetail_page.dart index 2aed4e7a..14cf2138 100755 --- a/lib/mine/gateway/gatewayDetail/gatewayDetail_page.dart +++ b/lib/mine/gateway/gatewayDetail/gatewayDetail_page.dart @@ -58,7 +58,7 @@ class _GatewayDetailPageState extends State { }), CommonItem( leftTitel: '状态'.tr, - rightTitle: state.getewayItemData.value.isOnline == 1 ? '在线' : '离线', + rightTitle: state.getewayItemData.value.isOnline == 1 ? '在线'.tr : '离线'.tr, isHaveLine: true, isHaveDirection: false), CommonItem( @@ -74,14 +74,16 @@ class _GatewayDetailPageState extends State { SizedBox( height: 10.h, ), - // CommonItem( - // leftTitel: '附近的锁'.tr, - // rightTitle: state.getewayItemData.value.lockNum.toString(), - // isHaveLine: true, - // isHaveDirection: true, - // action: () { - // Navigator.pushNamed(context, Routers.gatewayConnectionLockPage); - // }), + CommonItem( + leftTitel: '附近的锁'.tr, + rightTitle: state.getewayItemData.value.lockNum.toString(), + isHaveLine: true, + isHaveDirection: true, + action: () { + Get.toNamed(Routers.gatewayConnectionLockPage, arguments: { + 'gatewayId':state.getewayItemData.value.gatewayId ?? 0 + }); + }), // CommonItem( // leftTitel: '网关升级'.tr, // rightTitle: '', diff --git a/lib/mine/gateway/gatewayList/gatewayList_logic.dart b/lib/mine/gateway/gatewayList/gatewayList_logic.dart index d38609b5..cb99572f 100644 --- a/lib/mine/gateway/gatewayList/gatewayList_logic.dart +++ b/lib/mine/gateway/gatewayList/gatewayList_logic.dart @@ -1,6 +1,7 @@ import 'package:star_lock/tools/baseGetXController.dart'; +import '../../../login/login/entity/LoginEntity.dart'; import '../../../network/api_repository.dart'; import '../../mineSet/transferGateway/selectGetewayList_entity.dart'; import 'gatewayList_state.dart'; @@ -29,10 +30,28 @@ class GatewayListLogic extends BaseGetXController { return entity; } - @override - void onInit() { - super.onInit(); + // 测试配网成功 + // Future gatewayDistributionNetwork() async{ + // final LoginEntity entity = await ApiRepository.to.gatewayDistributionNetwork( + // gatewayName: '测试网关添加', + // gatewayMac: '48:6F:73:52:A1:C3', + // serialNumber: '1.0.0', + // gatewayType: 2, + // networkName: '测试网关添加WiFi名字', + // networkMac: '48:6F:73:52:A1:C3', + // version: '1.0.0', + // ); + // if(entity.errorCode!.codeIsSuccessful){ + // showToast('配网成功', something:(){ + // + // }); + // } + // } - } + // @override + // void onInit() { + // super.onInit(); + // gatewayDistributionNetwork(); + // } } \ No newline at end of file diff --git a/lib/mine/gateway/gatewayList/gatewayList_page.dart b/lib/mine/gateway/gatewayList/gatewayList_page.dart index 9490ae1f..95b8a9c1 100755 --- a/lib/mine/gateway/gatewayList/gatewayList_page.dart +++ b/lib/mine/gateway/gatewayList/gatewayList_page.dart @@ -1,3 +1,4 @@ + import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; @@ -6,7 +7,6 @@ import 'package:star_lock/tools/noData.dart'; import '../../../appRouters.dart'; import '../../../app_settings/app_colors.dart'; import '../../../tools/EasyRefreshTool.dart'; -import '../../../tools/storage.dart'; import '../../../tools/titleAppBar.dart'; import '../../mineSet/transferGateway/selectGetewayList_entity.dart'; import 'gatewayList_logic.dart'; @@ -49,7 +49,7 @@ class _GatewayListPageState extends State { actionsList: [ GestureDetector( onTap: () { - Get.toNamed(Routers.selectGatewayTypeNextTipPage)!.then((value) => getHttpData(isRefresh: true)); + Get.toNamed(Routers.selectGatewayTypeNextTipPage)!.then((dynamic value) => getHttpData(isRefresh: true)); }, child: Image.asset( 'images/icon_add_white.png', @@ -75,7 +75,7 @@ class _GatewayListPageState extends State { return _gatewatListItem(item, () { Get.toNamed(Routers.gatewayDetailPage, arguments: { 'getewayItemData': item - })!.then((value) => getHttpData(isRefresh: true)); + })!.then((dynamic value) => getHttpData(isRefresh: true)); }); }, separatorBuilder: (BuildContext context, int index) { diff --git a/lib/network/api.dart b/lib/network/api.dart index 22da0a6a..3b456399 100755 --- a/lib/network/api.dart +++ b/lib/network/api.dart @@ -155,6 +155,7 @@ abstract class Api { '/plug/transferPlugConfirm'; // 转移网关确认 final String transferGatewayURL = '/plug/transfer'; // 转移网关 final String updateGatewayURL = '/gateway/update'; // 更新网关 + final String gatewayListByLockURL = '/gateway/listByLock'; // 网关-附近的锁 final String getKeyDetailURL = '/key/get'; //获取单把钥匙详情信息 final String lockUserListURL = '/keyUser/listKeyUser'; //锁用户列表 diff --git a/lib/network/api_provider.dart b/lib/network/api_provider.dart index 272d2e28..aad2a490 100755 --- a/lib/network/api_provider.dart +++ b/lib/network/api_provider.dart @@ -1783,6 +1783,10 @@ class ApiProvider extends BaseProvider { 'countryCode': countryCode })); + Future gatewayConnectionLockListLoadData(int gatewayId) => post( + gatewayListByLockURL.toUrl, + jsonEncode({'gatewayId': gatewayId})); + // 移除坏锁 Future removeBrokenLockData(List lockIdList) => post(removeBadLockURL.toUrl, jsonEncode({'lockIds': lockIdList})); diff --git a/lib/network/api_repository.dart b/lib/network/api_repository.dart index c794a091..d9bf3f0d 100755 --- a/lib/network/api_repository.dart +++ b/lib/network/api_repository.dart @@ -73,6 +73,7 @@ import '../main/lockDetail/palm/addPalm/addPalm_entity.dart'; import '../main/lockDetail/remoteControl/addRemoteControl/addRemoteControl_entity.dart'; import '../main/lockMian/entity/lockListInfo_entity.dart'; import '../mine/addLock/saveLock/entity/SaveLockEntity.dart'; +import '../mine/gateway/gatewayConnectionLock/gatewayConnectionLockList_entity.dart'; import '../mine/message/messageList/messageList_entity.dart'; import '../mine/minePersonInfo/minePersonInfoPage/minePersonGetUploadFileInfo_entity.dart'; import '../mine/mineSet/lockUserManage/expireLockList/expireCard/expireCard_entity.dart'; @@ -1944,6 +1945,13 @@ class ApiRepository { return RecipientInformationEntity.fromJson(res.body); } + // 网关-附近的锁 + Future gatewayConnectionLockLoadData( + {required int gatewayId}) async { + final res = await apiProvider.gatewayConnectionLockListLoadData(gatewayId); + return GatewayConnectionLockListEntity.fromJson(res.body); + } + // 转移智能锁 Future transferGatewayInfoData( {required String receiverUsername,