1、完成网关模块国际化
2、删除蓝牙协议模块不用的蓝牙协议文件
This commit is contained in:
parent
427503c10b
commit
2368bb631c
@ -1082,5 +1082,7 @@
|
|||||||
"印度尼西亚语": "Indonesian",
|
"印度尼西亚语": "Indonesian",
|
||||||
"芬兰语": "Finnish",
|
"芬兰语": "Finnish",
|
||||||
"丹麦语": "Danish",
|
"丹麦语": "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"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1082,5 +1082,7 @@
|
|||||||
"印度尼西亚语": "印度尼西亚语",
|
"印度尼西亚语": "印度尼西亚语",
|
||||||
"芬兰语": "芬兰语",
|
"芬兰语": "芬兰语",
|
||||||
"丹麦语": "丹麦语",
|
"丹麦语": "丹麦语",
|
||||||
"重置后,该锁的掌静脉都将被删除哦,确认要重置吗?": "重置后,该锁的掌静脉都将被删除哦,确认要重置吗?"
|
"重置后,该锁的掌静脉都将被删除哦,确认要重置吗?": "重置后,该锁的掌静脉都将被删除哦,确认要重置吗?",
|
||||||
|
"在线": "在线",
|
||||||
|
"离线": "离线"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1082,5 +1082,7 @@
|
|||||||
"印度尼西亚语": "印度尼西亚语",
|
"印度尼西亚语": "印度尼西亚语",
|
||||||
"芬兰语": "芬兰语",
|
"芬兰语": "芬兰语",
|
||||||
"丹麦语": "丹麦语",
|
"丹麦语": "丹麦语",
|
||||||
"重置后,该锁的掌静脉都将被删除哦,确认要重置吗?": "重置后,该锁的掌静脉都将被删除哦,确认要重置吗?"
|
"重置后,该锁的掌静脉都将被删除哦,确认要重置吗?": "重置后,该锁的掌静脉都将被删除哦,确认要重置吗?",
|
||||||
|
"在线": "在线",
|
||||||
|
"离线": "离线"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,140 +25,186 @@ class AppStyle {
|
|||||||
|
|
||||||
///textButtonStyle
|
///textButtonStyle
|
||||||
static ButtonStyle get textButtonStyle => ButtonStyle(
|
static ButtonStyle get textButtonStyle => ButtonStyle(
|
||||||
minimumSize: MaterialStateProperty.resolveWith((states) => btnMinSize),
|
minimumSize: MaterialStateProperty.resolveWith((Set<MaterialState> states) => btnMinSize),
|
||||||
shape: MaterialStateProperty.resolveWith((states) => buttonShape_16),
|
shape: MaterialStateProperty.resolveWith((Set<MaterialState> states) => buttonShape_16),
|
||||||
backgroundColor: MaterialStateProperty.resolveWith((states){
|
backgroundColor: MaterialStateProperty.resolveWith((Set<MaterialState> states){
|
||||||
if(states.contains(MaterialState.disabled)) return AppColors.buttonDisableColor;
|
if(states.contains(MaterialState.disabled)) {
|
||||||
|
return AppColors.buttonDisableColor;
|
||||||
|
}
|
||||||
return AppColors.buttonEnableColor;
|
return AppColors.buttonEnableColor;
|
||||||
}),
|
}),
|
||||||
foregroundColor: MaterialStateProperty.resolveWith((states){
|
foregroundColor: MaterialStateProperty.resolveWith((Set<MaterialState> states){
|
||||||
if(states.contains(MaterialState.disabled)) return AppColors.buttonDisableTextColor;
|
if(states.contains(MaterialState.disabled)) {
|
||||||
|
return AppColors.buttonDisableTextColor;
|
||||||
|
}
|
||||||
return AppColors.buttonEnableTextColor;
|
return AppColors.buttonEnableTextColor;
|
||||||
}),
|
}),
|
||||||
textStyle: MaterialStateProperty.resolveWith((states){
|
textStyle: MaterialStateProperty.resolveWith((Set<MaterialState> states){
|
||||||
if(states.contains(MaterialState.disabled)) return textStyle(textColor: AppColors.buttonDisableColor);
|
if(states.contains(MaterialState.disabled)) {
|
||||||
|
return textStyle(textColor: AppColors.buttonDisableColor);
|
||||||
|
}
|
||||||
return textStyle();
|
return textStyle();
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
///textButtonDeleteStyle
|
///textButtonDeleteStyle
|
||||||
static ButtonStyle get textButtonDeleteStyle => ButtonStyle(
|
static ButtonStyle get textButtonDeleteStyle => ButtonStyle(
|
||||||
minimumSize: MaterialStateProperty.resolveWith((states) => btnMinSize),
|
minimumSize: MaterialStateProperty.resolveWith((Set<MaterialState> states) => btnMinSize),
|
||||||
shape: MaterialStateProperty.resolveWith((states) => buttonShape_16),
|
shape: MaterialStateProperty.resolveWith((Set<MaterialState> states) => buttonShape_16),
|
||||||
backgroundColor: MaterialStateProperty.resolveWith((states){
|
backgroundColor: MaterialStateProperty.resolveWith((Set<MaterialState> states){
|
||||||
if(states.contains(MaterialState.disabled)) return AppColors.buttonDisableColor;
|
if(states.contains(MaterialState.disabled)) {
|
||||||
|
return AppColors.buttonDisableColor;
|
||||||
|
}
|
||||||
return AppColors.deleteBtnBgColor;
|
return AppColors.deleteBtnBgColor;
|
||||||
}),
|
}),
|
||||||
foregroundColor: MaterialStateProperty.resolveWith((states){
|
foregroundColor: MaterialStateProperty.resolveWith((Set<MaterialState> states){
|
||||||
if(states.contains(MaterialState.disabled)) return AppColors.buttonDisableTextColor;
|
if(states.contains(MaterialState.disabled)) {
|
||||||
|
return AppColors.buttonDisableTextColor;
|
||||||
|
}
|
||||||
return AppColors.buttonEnableTextColor;
|
return AppColors.buttonEnableTextColor;
|
||||||
}),
|
}),
|
||||||
textStyle: MaterialStateProperty.resolveWith((states){
|
textStyle: MaterialStateProperty.resolveWith((Set<MaterialState> states){
|
||||||
if(states.contains(MaterialState.disabled)) return textStyle(textColor: AppColors.buttonDisableColor);
|
if(states.contains(MaterialState.disabled)) {
|
||||||
|
return textStyle(textColor: AppColors.buttonDisableColor);
|
||||||
|
}
|
||||||
return textStyle();
|
return textStyle();
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
//textButtonStyle2
|
//textButtonStyle2
|
||||||
static ButtonStyle get textButtonStyle2 => ButtonStyle(
|
static ButtonStyle get textButtonStyle2 => ButtonStyle(
|
||||||
minimumSize: MaterialStateProperty.resolveWith((states) => btnMinSize2),
|
minimumSize: MaterialStateProperty.resolveWith((Set<MaterialState> states) => btnMinSize2),
|
||||||
shape: MaterialStateProperty.resolveWith((states) => buttonShape_11),
|
shape: MaterialStateProperty.resolveWith((Set<MaterialState> states) => buttonShape_11),
|
||||||
backgroundColor: MaterialStateProperty.resolveWith((states){
|
backgroundColor: MaterialStateProperty.resolveWith((Set<MaterialState> states){
|
||||||
if(states.contains(MaterialState.disabled)) return AppColors.buttonDisableColor;
|
if(states.contains(MaterialState.disabled)) {
|
||||||
|
return AppColors.buttonDisableColor;
|
||||||
|
}
|
||||||
return AppColors.buttonEnableColor;
|
return AppColors.buttonEnableColor;
|
||||||
}),
|
}),
|
||||||
foregroundColor: MaterialStateProperty.resolveWith((states){
|
foregroundColor: MaterialStateProperty.resolveWith((Set<MaterialState> states){
|
||||||
if(states.contains(MaterialState.disabled)) return AppColors.buttonDisableTextColor;
|
if(states.contains(MaterialState.disabled)) {
|
||||||
|
return AppColors.buttonDisableTextColor;
|
||||||
|
}
|
||||||
return AppColors.buttonEnableTextColor;
|
return AppColors.buttonEnableTextColor;
|
||||||
}),
|
}),
|
||||||
textStyle: MaterialStateProperty.resolveWith((states){
|
textStyle: MaterialStateProperty.resolveWith((Set<MaterialState> states){
|
||||||
if(states.contains(MaterialState.disabled)) return textStyle(textColor: AppColors.buttonDisableColor,fontSize: 11.sp);
|
if(states.contains(MaterialState.disabled)) {
|
||||||
|
return textStyle(textColor: AppColors.buttonDisableColor,fontSize: 11.sp);
|
||||||
|
}
|
||||||
return textStyle(fontSize: 11.sp);
|
return textStyle(fontSize: 11.sp);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
static ButtonStyle get textButtonStyleOthers => ButtonStyle(
|
static ButtonStyle get textButtonStyleOthers => ButtonStyle(
|
||||||
minimumSize: MaterialStateProperty.resolveWith((states) => btnMinSize),
|
minimumSize: MaterialStateProperty.resolveWith((Set<MaterialState> states) => btnMinSize),
|
||||||
shape: MaterialStateProperty.resolveWith((states) => buttonShape_16),
|
shape: MaterialStateProperty.resolveWith((Set<MaterialState> states) => buttonShape_16),
|
||||||
backgroundColor: MaterialStateProperty.resolveWith((states){
|
backgroundColor: MaterialStateProperty.resolveWith((Set<MaterialState> states){
|
||||||
if(states.contains(MaterialState.disabled)) return AppColors.buttonDisableTextColor;
|
if(states.contains(MaterialState.disabled)) {
|
||||||
|
return AppColors.buttonDisableTextColor;
|
||||||
|
}
|
||||||
return AppColors.buttonEnableTextColor;
|
return AppColors.buttonEnableTextColor;
|
||||||
}),
|
}),
|
||||||
foregroundColor: MaterialStateProperty.resolveWith((states){
|
foregroundColor: MaterialStateProperty.resolveWith((Set<MaterialState> states){
|
||||||
if(states.contains(MaterialState.disabled)) return AppColors.buttonDisableColor;
|
if(states.contains(MaterialState.disabled)) {
|
||||||
|
return AppColors.buttonDisableColor;
|
||||||
|
}
|
||||||
return AppColors.buttonEnableColor;
|
return AppColors.buttonEnableColor;
|
||||||
}),
|
}),
|
||||||
textStyle: MaterialStateProperty.resolveWith((states){
|
textStyle: MaterialStateProperty.resolveWith((Set<MaterialState> states){
|
||||||
if(states.contains(MaterialState.disabled)) return textStyle(textColor: AppColors.buttonDisableColor);
|
if(states.contains(MaterialState.disabled)) {
|
||||||
|
return textStyle(textColor: AppColors.buttonDisableColor);
|
||||||
|
}
|
||||||
return textStyle(textColor: AppColors.buttonEnableColor);
|
return textStyle(textColor: AppColors.buttonEnableColor);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
static ButtonStyle get specialButtonStyle => ButtonStyle(
|
static ButtonStyle get specialButtonStyle => ButtonStyle(
|
||||||
minimumSize: MaterialStateProperty.resolveWith((states) => btnMinSize3),
|
minimumSize: MaterialStateProperty.resolveWith((Set<MaterialState> states) => btnMinSize3),
|
||||||
shape: MaterialStateProperty.resolveWith((states) => buttonShape_16),
|
shape: MaterialStateProperty.resolveWith((Set<MaterialState> states) => buttonShape_16),
|
||||||
backgroundColor: MaterialStateProperty.resolveWith((states){
|
backgroundColor: MaterialStateProperty.resolveWith((Set<MaterialState> states){
|
||||||
if(states.contains(MaterialState.disabled)) return AppColors.buttonDisableTextColor;
|
if(states.contains(MaterialState.disabled)) {
|
||||||
|
return AppColors.buttonDisableTextColor;
|
||||||
|
}
|
||||||
return AppColors.deleteBtnBgColor;
|
return AppColors.deleteBtnBgColor;
|
||||||
}),
|
}),
|
||||||
foregroundColor: MaterialStateProperty.resolveWith((states){
|
foregroundColor: MaterialStateProperty.resolveWith((Set<MaterialState> states){
|
||||||
if(states.contains(MaterialState.disabled)) return AppColors.buttonDisableColor;
|
if(states.contains(MaterialState.disabled)) {
|
||||||
|
return AppColors.buttonDisableColor;
|
||||||
|
}
|
||||||
return AppColors.buttonEnableTextColor;
|
return AppColors.buttonEnableTextColor;
|
||||||
}),
|
}),
|
||||||
textStyle: MaterialStateProperty.resolveWith((states){
|
textStyle: MaterialStateProperty.resolveWith((Set<MaterialState> states){
|
||||||
if(states.contains(MaterialState.disabled)) return textStyle(textColor: AppColors.buttonDisableColor);
|
if(states.contains(MaterialState.disabled)) {
|
||||||
|
return textStyle(textColor: AppColors.buttonDisableColor);
|
||||||
|
}
|
||||||
return textStyle(textColor: AppColors.buttonEnableColor);
|
return textStyle(textColor: AppColors.buttonEnableColor);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
static ButtonStyle clearTextButtonStyle({Color? textColor, Color? bgColor, double? fontSize, FontWeight? fontWeight}) => ButtonStyle(
|
static ButtonStyle clearTextButtonStyle({Color? textColor, Color? bgColor, double? fontSize, FontWeight? fontWeight}) => ButtonStyle(
|
||||||
minimumSize: MaterialStateProperty.resolveWith((states) => btnMinSize),
|
minimumSize: MaterialStateProperty.resolveWith((Set<MaterialState> states) => btnMinSize),
|
||||||
shape: MaterialStateProperty.resolveWith((states) => buttonShape_16),
|
shape: MaterialStateProperty.resolveWith((Set<MaterialState> states) => buttonShape_16),
|
||||||
backgroundColor: MaterialStateProperty.resolveWith((states){
|
backgroundColor: MaterialStateProperty.resolveWith((Set<MaterialState> states){
|
||||||
bgColor ??= AppColors.normalTextColor;
|
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;
|
return bgColor;
|
||||||
}),
|
}),
|
||||||
overlayColor: MaterialStateProperty.resolveWith((states){
|
overlayColor: MaterialStateProperty.resolveWith((Set<MaterialState> states){
|
||||||
textColor ??= AppColors.buttonEnableColor;
|
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);
|
return textColor?.withOpacity(0.1);
|
||||||
}),
|
}),
|
||||||
foregroundColor: MaterialStateProperty.resolveWith((states){
|
foregroundColor: MaterialStateProperty.resolveWith((Set<MaterialState> states){
|
||||||
textColor ??= AppColors.buttonEnableColor;
|
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;
|
return textColor;
|
||||||
}),
|
}),
|
||||||
textStyle: MaterialStateProperty.resolveWith((states){
|
textStyle: MaterialStateProperty.resolveWith((Set<MaterialState> states){
|
||||||
if(states.contains(MaterialState.disabled)) return textStyle(fontSize: fontSize,fontWeight: fontWeight);
|
if(states.contains(MaterialState.disabled)) {
|
||||||
|
return textStyle(fontSize: fontSize,fontWeight: fontWeight);
|
||||||
|
}
|
||||||
return textStyle(fontSize: fontSize,fontWeight: fontWeight);
|
return textStyle(fontSize: fontSize,fontWeight: fontWeight);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
///elevatedButtonButtonStyle
|
///elevatedButtonButtonStyle
|
||||||
static ButtonStyle get elevatedButtonButtonStyle => ButtonStyle(
|
static ButtonStyle get elevatedButtonButtonStyle => ButtonStyle(
|
||||||
minimumSize: MaterialStateProperty.resolveWith((states) => btnMinSize),
|
minimumSize: MaterialStateProperty.resolveWith((Set<MaterialState> states) => btnMinSize),
|
||||||
shape: MaterialStateProperty.resolveWith((states) => buttonShape_16),
|
shape: MaterialStateProperty.resolveWith((Set<MaterialState> states) => buttonShape_16),
|
||||||
backgroundColor: MaterialStateProperty.resolveWith((states){
|
backgroundColor: MaterialStateProperty.resolveWith((Set<MaterialState> states){
|
||||||
if(states.contains(MaterialState.disabled)) return AppColors.buttonDisableColor;
|
if(states.contains(MaterialState.disabled)) {
|
||||||
|
return AppColors.buttonDisableColor;
|
||||||
|
}
|
||||||
return AppColors.buttonEnableColor;
|
return AppColors.buttonEnableColor;
|
||||||
}),
|
}),
|
||||||
foregroundColor: MaterialStateProperty.resolveWith((states){
|
foregroundColor: MaterialStateProperty.resolveWith((Set<MaterialState> states){
|
||||||
if(states.contains(MaterialState.disabled)) return AppColors.buttonDisableTextColor;
|
if(states.contains(MaterialState.disabled)) {
|
||||||
|
return AppColors.buttonDisableTextColor;
|
||||||
|
}
|
||||||
return AppColors.buttonEnableTextColor;
|
return AppColors.buttonEnableTextColor;
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
///outlinedButtonButtonStyle
|
///outlinedButtonButtonStyle
|
||||||
static ButtonStyle get outlinedButtonButtonStyle => ButtonStyle(
|
static ButtonStyle get outlinedButtonButtonStyle => ButtonStyle(
|
||||||
minimumSize: MaterialStateProperty.resolveWith((states) => btnMinSize),
|
minimumSize: MaterialStateProperty.resolveWith((Set<MaterialState> states) => btnMinSize),
|
||||||
shape: MaterialStateProperty.resolveWith((states) => buttonShape_16),
|
shape: MaterialStateProperty.resolveWith((Set<MaterialState> states) => buttonShape_16),
|
||||||
backgroundColor: MaterialStateProperty.resolveWith((states){
|
backgroundColor: MaterialStateProperty.resolveWith((Set<MaterialState> states){
|
||||||
if(states.contains(MaterialState.disabled)) return AppColors.buttonDisableColor;
|
if(states.contains(MaterialState.disabled)) {
|
||||||
|
return AppColors.buttonDisableColor;
|
||||||
|
}
|
||||||
return AppColors.buttonEnableColor;
|
return AppColors.buttonEnableColor;
|
||||||
}),
|
}),
|
||||||
foregroundColor: MaterialStateProperty.resolveWith((states){
|
foregroundColor: MaterialStateProperty.resolveWith((Set<MaterialState> states){
|
||||||
if(states.contains(MaterialState.disabled)) return AppColors.buttonDisableTextColor;
|
if(states.contains(MaterialState.disabled)) {
|
||||||
|
return AppColors.buttonDisableTextColor;
|
||||||
|
}
|
||||||
return AppColors.buttonEnableTextColor;
|
return AppColors.buttonEnableTextColor;
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
@ -166,21 +212,25 @@ class AppStyle {
|
|||||||
|
|
||||||
///outlinedButtonButtonStyle2
|
///outlinedButtonButtonStyle2
|
||||||
static ButtonStyle get outlinedButtonButtonStyle2_Selected => ButtonStyle(
|
static ButtonStyle get outlinedButtonButtonStyle2_Selected => ButtonStyle(
|
||||||
minimumSize: MaterialStateProperty.resolveWith((states) => btnMinSize),
|
minimumSize: MaterialStateProperty.resolveWith((Set<MaterialState> states) => btnMinSize),
|
||||||
shape: MaterialStateProperty.resolveWith((states) => buttonShape_11),
|
shape: MaterialStateProperty.resolveWith((Set<MaterialState> states) => buttonShape_11),
|
||||||
backgroundColor: MaterialStateProperty.resolveWith((states){
|
backgroundColor: MaterialStateProperty.resolveWith((Set<MaterialState> states){
|
||||||
if(states.contains(MaterialState.disabled)) return AppColors.buttonDisableColor;
|
if(states.contains(MaterialState.disabled)) {
|
||||||
|
return AppColors.buttonDisableColor;
|
||||||
|
}
|
||||||
return AppColors.buttonEnableColor;
|
return AppColors.buttonEnableColor;
|
||||||
}),
|
}),
|
||||||
foregroundColor: MaterialStateProperty.resolveWith((states){
|
foregroundColor: MaterialStateProperty.resolveWith((Set<MaterialState> states){
|
||||||
if(states.contains(MaterialState.disabled)) return AppColors.buttonDisableTextColor;
|
if(states.contains(MaterialState.disabled)) {
|
||||||
|
return AppColors.buttonDisableTextColor;
|
||||||
|
}
|
||||||
return AppColors.buttonEnableTextColor;
|
return AppColors.buttonEnableTextColor;
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
///outlinedButtonButtonStyle2_Selected
|
///outlinedButtonButtonStyle2_Selected
|
||||||
static ButtonStyle get outlinedButtonButtonStyle2 => ButtonStyle(
|
static ButtonStyle get outlinedButtonButtonStyle2 => ButtonStyle(
|
||||||
shape: MaterialStateProperty.resolveWith((states) => buttonShape_11),
|
shape: MaterialStateProperty.resolveWith((Set<MaterialState> states) => buttonShape_11),
|
||||||
side: MaterialStateProperty.all(BorderSide(
|
side: MaterialStateProperty.all(BorderSide(
|
||||||
width: 1.w,
|
width: 1.w,
|
||||||
color: AppColors.buttonEnableColor.withOpacity(0.5),
|
color: AppColors.buttonEnableColor.withOpacity(0.5),
|
||||||
|
|||||||
@ -122,9 +122,9 @@ class AppTheme {
|
|||||||
|
|
||||||
|
|
||||||
class NoShadowScrollBehavior extends ScrollBehavior {
|
class NoShadowScrollBehavior extends ScrollBehavior {
|
||||||
|
const NoShadowScrollBehavior({this.axisDirection = AxisDirection.up}):super();
|
||||||
|
|
||||||
final AxisDirection axisDirection;
|
final AxisDirection axisDirection;
|
||||||
const NoShadowScrollBehavior({this.axisDirection = AxisDirection.up}):super();
|
|
||||||
@override
|
@override
|
||||||
Widget buildOverscrollIndicator(BuildContext context, Widget child, ScrollableDetails details) {
|
Widget buildOverscrollIndicator(BuildContext context, Widget child, ScrollableDetails details) {
|
||||||
return GlowingOverscrollIndicator(axisDirection: axisDirection, color: Colors.red,showTrailing: false,showLeading: false,child: child,);
|
return GlowingOverscrollIndicator(axisDirection: axisDirection, color: Colors.red,showTrailing: false,showLeading: false,child: child,);
|
||||||
|
|||||||
@ -1,8 +1,4 @@
|
|||||||
class LockUserNoListEntity {
|
class LockUserNoListEntity {
|
||||||
int? errorCode;
|
|
||||||
String? description;
|
|
||||||
String? errorMsg;
|
|
||||||
Data? data;
|
|
||||||
|
|
||||||
LockUserNoListEntity(
|
LockUserNoListEntity(
|
||||||
{this.errorCode, this.description, this.errorMsg, this.data});
|
{this.errorCode, this.description, this.errorMsg, this.data});
|
||||||
@ -15,6 +11,10 @@ class LockUserNoListEntity {
|
|||||||
data = Data.fromJson(json['data']);
|
data = Data.fromJson(json['data']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
int? errorCode;
|
||||||
|
String? description;
|
||||||
|
String? errorMsg;
|
||||||
|
Data? data;
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
Map<String, dynamic> toJson() {
|
||||||
final Map<String, dynamic> data = <String, dynamic>{};
|
final Map<String, dynamic> data = <String, dynamic>{};
|
||||||
@ -27,7 +27,6 @@ class LockUserNoListEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Data {
|
class Data {
|
||||||
List<int>? userNos = [];
|
|
||||||
|
|
||||||
Data({
|
Data({
|
||||||
this.userNos,
|
this.userNos,
|
||||||
@ -40,6 +39,7 @@ class Data {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
List<int>? userNos = [];
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
Map<String, dynamic> toJson() {
|
||||||
final Map<String, dynamic> data = <String, dynamic>{};
|
final Map<String, dynamic> data = <String, dynamic>{};
|
||||||
|
|||||||
@ -1,21 +1,15 @@
|
|||||||
|
|
||||||
import 'dart:convert';
|
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;
|
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 {
|
class SenderCancelAddCardCommand extends SenderProtocol {
|
||||||
String? keyID;
|
|
||||||
String? userID;
|
|
||||||
List<int>? token;
|
|
||||||
int? needAuthor;
|
|
||||||
List<int>? signKey;
|
|
||||||
List<int>? privateKey;
|
|
||||||
|
|
||||||
SenderCancelAddCardCommand({
|
SenderCancelAddCardCommand({
|
||||||
this.keyID,
|
this.keyID,
|
||||||
@ -25,6 +19,12 @@ class SenderCancelAddCardCommand extends SenderProtocol {
|
|||||||
this.signKey,
|
this.signKey,
|
||||||
this.privateKey,
|
this.privateKey,
|
||||||
}) : super(CommandType.generalExtendedCommond);
|
}) : super(CommandType.generalExtendedCommond);
|
||||||
|
String? keyID;
|
||||||
|
String? userID;
|
||||||
|
List<int>? token;
|
||||||
|
int? needAuthor;
|
||||||
|
List<int>? signKey;
|
||||||
|
List<int>? privateKey;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
@ -34,9 +34,9 @@ class SenderCancelAddCardCommand extends SenderProtocol {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
List<int> messageDetail() {
|
List<int> messageDetail() {
|
||||||
List<int> data = [];
|
final List<int> data = <int>[];
|
||||||
List<int> subData = [];
|
List<int> subData = <int>[];
|
||||||
List<int> ebcData = [];
|
List<int> ebcData = <int>[];
|
||||||
|
|
||||||
// 指令类型
|
// 指令类型
|
||||||
data.addAll(intChangList(commandType!.typeValue));
|
data.addAll(intChangList(commandType!.typeValue));
|
||||||
@ -45,12 +45,12 @@ class SenderCancelAddCardCommand extends SenderProtocol {
|
|||||||
data.add(25);
|
data.add(25);
|
||||||
|
|
||||||
// keyID 40
|
// keyID 40
|
||||||
int keyIDLength = utf8.encode(keyID!).length;
|
final int keyIDLength = utf8.encode(keyID!).length;
|
||||||
subData.addAll(utf8.encode(keyID!));
|
subData.addAll(utf8.encode(keyID!));
|
||||||
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
||||||
|
|
||||||
//userID 20
|
//userID 20
|
||||||
int userIDLength = utf8.encode(userID!).length;
|
final int userIDLength = utf8.encode(userID!).length;
|
||||||
subData.addAll(utf8.encode(userID!));
|
subData.addAll(utf8.encode(userID!));
|
||||||
subData = getFixedLengthList(subData, 20 - userIDLength);
|
subData = getFixedLengthList(subData, 20 - userIDLength);
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ class SenderCancelAddCardCommand extends SenderProtocol {
|
|||||||
//AuthCodeLen 1
|
//AuthCodeLen 1
|
||||||
subData.add(0);
|
subData.add(0);
|
||||||
} else {
|
} else {
|
||||||
List<int> authCodeData = [];
|
final List<int> authCodeData = <int>[];
|
||||||
//KeyID
|
//KeyID
|
||||||
authCodeData.addAll(utf8.encode(keyID!));
|
authCodeData.addAll(utf8.encode(keyID!));
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ class SenderCancelAddCardCommand extends SenderProtocol {
|
|||||||
authCodeData.addAll(signKey!);
|
authCodeData.addAll(signKey!);
|
||||||
|
|
||||||
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
||||||
var authCode = crypto.md5.convert(authCodeData);
|
final crypto.Digest authCode = crypto.md5.convert(authCodeData);
|
||||||
|
|
||||||
subData.add(authCode.bytes.length);
|
subData.add(authCode.bytes.length);
|
||||||
subData.addAll(authCode.bytes);
|
subData.addAll(authCode.bytes);
|
||||||
@ -81,7 +81,7 @@ class SenderCancelAddCardCommand extends SenderProtocol {
|
|||||||
data.addAll(subData);
|
data.addAll(subData);
|
||||||
|
|
||||||
if ((data.length % 16) != 0) {
|
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++) {
|
for (int i = 0; i < add; i++) {
|
||||||
data.add(0);
|
data.add(0);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,29 +10,12 @@ import '../io_tool/io_tool.dart';
|
|||||||
import '../io_type.dart';
|
import '../io_type.dart';
|
||||||
import '../sm4Encipher/sm4.dart';
|
import '../sm4Encipher/sm4.dart';
|
||||||
|
|
||||||
///TODO:添加人脸
|
/// 添加人脸
|
||||||
/*
|
/*
|
||||||
备注:
|
备注:
|
||||||
删除单个人脸规则:UseCountLimit 设置为 0。删除全部人脸规则: UseCountLimit 设置为 0,FaceNo 设置为 255,userId 设置为“Delete All !@#”,只有门锁管理员才有权限
|
删除单个人脸规则:UseCountLimit 设置为 0。删除全部人脸规则: UseCountLimit 设置为 0,FaceNo 设置为 255,userId 设置为“Delete All !@#”,只有门锁管理员才有权限
|
||||||
**/
|
**/
|
||||||
class SenderAddFaceCommand extends SenderProtocol {
|
class SenderAddFaceCommand extends SenderProtocol {
|
||||||
String? keyID;
|
|
||||||
String? userID;
|
|
||||||
int? faceNo;
|
|
||||||
int? useCountLimit;
|
|
||||||
int? isForce;
|
|
||||||
int? operate;
|
|
||||||
int? isAdmin;
|
|
||||||
List<int>? token;
|
|
||||||
int? isRound;
|
|
||||||
int? weekRound;
|
|
||||||
int? startDate;
|
|
||||||
int? endDate;
|
|
||||||
String? startTime;
|
|
||||||
String? endTime;
|
|
||||||
int? needAuthor;
|
|
||||||
List<int>? signKey;
|
|
||||||
List<int>? privateKey;
|
|
||||||
|
|
||||||
SenderAddFaceCommand({
|
SenderAddFaceCommand({
|
||||||
this.keyID,
|
this.keyID,
|
||||||
@ -53,6 +36,23 @@ class SenderAddFaceCommand extends SenderProtocol {
|
|||||||
this.signKey,
|
this.signKey,
|
||||||
this.privateKey,
|
this.privateKey,
|
||||||
}) : super(CommandType.generalExtendedCommond);
|
}) : super(CommandType.generalExtendedCommond);
|
||||||
|
String? keyID;
|
||||||
|
String? userID;
|
||||||
|
int? faceNo;
|
||||||
|
int? useCountLimit;
|
||||||
|
int? isForce;
|
||||||
|
int? operate;
|
||||||
|
int? isAdmin;
|
||||||
|
List<int>? token;
|
||||||
|
int? isRound;
|
||||||
|
int? weekRound;
|
||||||
|
int? startDate;
|
||||||
|
int? endDate;
|
||||||
|
String? startTime;
|
||||||
|
String? endTime;
|
||||||
|
int? needAuthor;
|
||||||
|
List<int>? signKey;
|
||||||
|
List<int>? privateKey;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
@ -70,9 +70,9 @@ class SenderAddFaceCommand extends SenderProtocol {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
List<int> messageDetail() {
|
List<int> messageDetail() {
|
||||||
final List<int> data = [];
|
final List<int> data = <int>[];
|
||||||
List<int> subData = [];
|
List<int> subData = <int>[];
|
||||||
List<int> ebcData = [];
|
List<int> ebcData = <int>[];
|
||||||
|
|
||||||
// 指令类型
|
// 指令类型
|
||||||
data.addAll(intChangList(commandType!.typeValue));
|
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())}");
|
// AppLog.log("addFingerprint startDate:${DateTool().dateToYMDHNString(startDate.toString())} endDate:${DateTool().dateToYMDHNString(endDate.toString())}");
|
||||||
|
|
||||||
// startTime 4
|
// startTime 4
|
||||||
final List<int> startTimeList = [0,0,0,0];
|
final List<int> startTimeList = <int>[0,0,0,0];
|
||||||
if(startTime!.contains(':')){
|
if(startTime!.contains(':')){
|
||||||
final List<String> getStartTimeList = startTime!.split(':');
|
final List<String> getStartTimeList = startTime!.split(':');
|
||||||
startTimeList[2] = int.parse(getStartTimeList[0]);
|
startTimeList[2] = int.parse(getStartTimeList[0]);
|
||||||
@ -148,7 +148,7 @@ class SenderAddFaceCommand extends SenderProtocol {
|
|||||||
subData.addAll(startTimeList);
|
subData.addAll(startTimeList);
|
||||||
|
|
||||||
// endTime 4
|
// endTime 4
|
||||||
final List<int> endTimeList = [0,0,0,0];
|
final List<int> endTimeList = <int>[0,0,0,0];
|
||||||
if(endTime!.contains(':')){
|
if(endTime!.contains(':')){
|
||||||
final List<String> getendTimeList = endTime!.split(':');
|
final List<String> getendTimeList = endTime!.split(':');
|
||||||
endTimeList[2] = int.parse(getendTimeList[0]);
|
endTimeList[2] = int.parse(getendTimeList[0]);
|
||||||
@ -160,7 +160,7 @@ class SenderAddFaceCommand extends SenderProtocol {
|
|||||||
//AuthCodeLen 1
|
//AuthCodeLen 1
|
||||||
subData.add(0);
|
subData.add(0);
|
||||||
} else {
|
} else {
|
||||||
final List<int> authCodeData = [];
|
final List<int> authCodeData = <int>[];
|
||||||
//KeyID
|
//KeyID
|
||||||
authCodeData.addAll(utf8.encode(keyID!));
|
authCodeData.addAll(utf8.encode(keyID!));
|
||||||
|
|
||||||
@ -173,7 +173,7 @@ class SenderAddFaceCommand extends SenderProtocol {
|
|||||||
authCodeData.addAll(signKey!);
|
authCodeData.addAll(signKey!);
|
||||||
|
|
||||||
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
||||||
final authCode = crypto.md5.convert(authCodeData);
|
final crypto.Digest authCode = crypto.md5.convert(authCodeData);
|
||||||
|
|
||||||
subData.add(authCode.bytes.length);
|
subData.add(authCode.bytes.length);
|
||||||
subData.addAll(authCode.bytes);
|
subData.addAll(authCode.bytes);
|
||||||
|
|||||||
@ -7,14 +7,8 @@ import '../io_sender.dart';
|
|||||||
import '../io_type.dart';
|
import '../io_type.dart';
|
||||||
import 'package:crypto/crypto.dart' as crypto;
|
import 'package:crypto/crypto.dart' as crypto;
|
||||||
|
|
||||||
///TODO:取消添加人脸
|
/// 取消添加人脸
|
||||||
class SenderCancelAddFaceCommand extends SenderProtocol {
|
class SenderCancelAddFaceCommand extends SenderProtocol {
|
||||||
String? keyID;
|
|
||||||
String? userID;
|
|
||||||
List<int>? token;
|
|
||||||
int? needAuthor;
|
|
||||||
List<int>? signKey;
|
|
||||||
List<int>? privateKey;
|
|
||||||
|
|
||||||
SenderCancelAddFaceCommand({
|
SenderCancelAddFaceCommand({
|
||||||
this.keyID,
|
this.keyID,
|
||||||
@ -24,6 +18,12 @@ class SenderCancelAddFaceCommand extends SenderProtocol {
|
|||||||
this.signKey,
|
this.signKey,
|
||||||
this.privateKey,
|
this.privateKey,
|
||||||
}) : super(CommandType.generalExtendedCommond);
|
}) : super(CommandType.generalExtendedCommond);
|
||||||
|
String? keyID;
|
||||||
|
String? userID;
|
||||||
|
List<int>? token;
|
||||||
|
int? needAuthor;
|
||||||
|
List<int>? signKey;
|
||||||
|
List<int>? privateKey;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
@ -33,7 +33,7 @@ class SenderCancelAddFaceCommand extends SenderProtocol {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
List<int> messageDetail() {
|
List<int> messageDetail() {
|
||||||
List<int> data = [];
|
final List<int> data = [];
|
||||||
List<int> subData = [];
|
List<int> subData = [];
|
||||||
List<int> ebcData = [];
|
List<int> ebcData = [];
|
||||||
|
|
||||||
@ -44,12 +44,12 @@ class SenderCancelAddFaceCommand extends SenderProtocol {
|
|||||||
data.add(86);
|
data.add(86);
|
||||||
|
|
||||||
// keyID 40
|
// keyID 40
|
||||||
int keyIDLength = utf8.encode(keyID!).length;
|
final int keyIDLength = utf8.encode(keyID!).length;
|
||||||
subData.addAll(utf8.encode(keyID!));
|
subData.addAll(utf8.encode(keyID!));
|
||||||
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
||||||
|
|
||||||
//userID 20
|
//userID 20
|
||||||
int userIDLength = utf8.encode(userID!).length;
|
final int userIDLength = utf8.encode(userID!).length;
|
||||||
subData.addAll(utf8.encode(userID!));
|
subData.addAll(utf8.encode(userID!));
|
||||||
subData = getFixedLengthList(subData, 20 - userIDLength);
|
subData = getFixedLengthList(subData, 20 - userIDLength);
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ class SenderCancelAddFaceCommand extends SenderProtocol {
|
|||||||
//AuthCodeLen 1
|
//AuthCodeLen 1
|
||||||
subData.add(0);
|
subData.add(0);
|
||||||
} else {
|
} else {
|
||||||
List<int> authCodeData = [];
|
final List<int> authCodeData = [];
|
||||||
//KeyID
|
//KeyID
|
||||||
authCodeData.addAll(utf8.encode(keyID!));
|
authCodeData.addAll(utf8.encode(keyID!));
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ class SenderCancelAddFaceCommand extends SenderProtocol {
|
|||||||
authCodeData.addAll(signKey!);
|
authCodeData.addAll(signKey!);
|
||||||
|
|
||||||
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
||||||
var authCode = crypto.md5.convert(authCodeData);
|
final authCode = crypto.md5.convert(authCodeData);
|
||||||
|
|
||||||
subData.add(authCode.bytes.length);
|
subData.add(authCode.bytes.length);
|
||||||
subData.addAll(authCode.bytes);
|
subData.addAll(authCode.bytes);
|
||||||
@ -80,7 +80,7 @@ class SenderCancelAddFaceCommand extends SenderProtocol {
|
|||||||
data.addAll(subData);
|
data.addAll(subData);
|
||||||
|
|
||||||
if ((data.length % 16) != 0) {
|
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++) {
|
for (int i = 0; i < add; i++) {
|
||||||
data.add(0);
|
data.add(0);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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<int>? token;
|
|
||||||
// int? isRound;
|
|
||||||
// int? weekRound;
|
|
||||||
// int? startDate;
|
|
||||||
// int? endDate;
|
|
||||||
// String? startTime;
|
|
||||||
// String? endTime;
|
|
||||||
// int? needAuthor;
|
|
||||||
// List<int>? signKey;
|
|
||||||
// List<int>? 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<int> messageDetail() {
|
|
||||||
// List<int> data = [];
|
|
||||||
// List<int> subData = [];
|
|
||||||
// List<int> 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<int> startTimeList = [0,0,0,0];
|
|
||||||
// if(startTime!.contains(":")){
|
|
||||||
// List<String> getStartTimeList = startTime!.split(":");
|
|
||||||
// startTimeList[2] = int.parse(getStartTimeList[0]);
|
|
||||||
// startTimeList[3] = int.parse(getStartTimeList[1]);
|
|
||||||
// }
|
|
||||||
// subData.addAll(startTimeList);
|
|
||||||
//
|
|
||||||
// // endTime 4
|
|
||||||
// List<int> endTimeList = [0,0,0,0];
|
|
||||||
// if(endTime!.contains(":")){
|
|
||||||
// List<String> 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<int> 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<int> dataDetail)
|
|
||||||
// : super.parseData(commandType, dataDetail) {
|
|
||||||
// data = dataDetail;
|
|
||||||
// int status = data[2];
|
|
||||||
// errorWithStstus(status);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// class SenderAddFingerprintProcessReply extends Reply {
|
|
||||||
// SenderAddFingerprintProcessReply.parseData(CommandType commandType, List<int> dataDetail)
|
|
||||||
// : super.parseData(commandType, dataDetail) {
|
|
||||||
// data = dataDetail;
|
|
||||||
// int status = data[2];
|
|
||||||
// errorWithStstus(status);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// class SenderAddFingerprintConfirmationReply extends Reply {
|
|
||||||
// SenderAddFingerprintConfirmationReply.parseData(CommandType commandType, List<int> dataDetail)
|
|
||||||
// : super.parseData(commandType, dataDetail) {
|
|
||||||
// data = dataDetail;
|
|
||||||
// int status = data[2];
|
|
||||||
// errorWithStstus(status);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
@ -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<int>? token;
|
|
||||||
// int? startTime;
|
|
||||||
// int? endTime;
|
|
||||||
// int? needAuthor;
|
|
||||||
// List<int>? signKey;
|
|
||||||
// List<int>? 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<int> messageDetail() {
|
|
||||||
// List<int> data = [];
|
|
||||||
// List<int> subData = [];
|
|
||||||
// List<int> 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<int> 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<int> dataDetail)
|
|
||||||
// : super.parseData(commandType, dataDetail) {
|
|
||||||
// data = dataDetail;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// class SenderAddFingerprintProcessReply extends Reply {
|
|
||||||
// SenderAddFingerprintProcessReply.parseData(CommandType commandType, List<int> dataDetail)
|
|
||||||
// : super.parseData(commandType, dataDetail) {
|
|
||||||
// data = dataDetail;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// class SenderAddFingerprintConfirmationReply extends Reply {
|
|
||||||
// SenderAddFingerprintConfirmationReply.parseData(CommandType commandType, List<int> dataDetail)
|
|
||||||
// : super.parseData(commandType, dataDetail) {
|
|
||||||
// data = dataDetail;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
@ -7,14 +7,8 @@ import '../io_sender.dart';
|
|||||||
import '../io_type.dart';
|
import '../io_type.dart';
|
||||||
import 'package:crypto/crypto.dart' as crypto;
|
import 'package:crypto/crypto.dart' as crypto;
|
||||||
|
|
||||||
///TODO:取消添加指纹
|
/// 取消添加指纹
|
||||||
class SenderCancelAddFingerprintCommand extends SenderProtocol {
|
class SenderCancelAddFingerprintCommand extends SenderProtocol {
|
||||||
String? keyID;
|
|
||||||
String? userID;
|
|
||||||
List<int>? token;
|
|
||||||
int? needAuthor;
|
|
||||||
List<int>? signKey;
|
|
||||||
List<int>? privateKey;
|
|
||||||
|
|
||||||
SenderCancelAddFingerprintCommand({
|
SenderCancelAddFingerprintCommand({
|
||||||
this.keyID,
|
this.keyID,
|
||||||
@ -24,6 +18,12 @@ class SenderCancelAddFingerprintCommand extends SenderProtocol {
|
|||||||
this.signKey,
|
this.signKey,
|
||||||
this.privateKey,
|
this.privateKey,
|
||||||
}) : super(CommandType.generalExtendedCommond);
|
}) : super(CommandType.generalExtendedCommond);
|
||||||
|
String? keyID;
|
||||||
|
String? userID;
|
||||||
|
List<int>? token;
|
||||||
|
int? needAuthor;
|
||||||
|
List<int>? signKey;
|
||||||
|
List<int>? privateKey;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
@ -33,9 +33,9 @@ class SenderCancelAddFingerprintCommand extends SenderProtocol {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
List<int> messageDetail() {
|
List<int> messageDetail() {
|
||||||
List<int> data = [];
|
final List<int> data = <int>[];
|
||||||
List<int> subData = [];
|
List<int> subData = <int>[];
|
||||||
List<int> ebcData = [];
|
List<int> ebcData = <int>[];
|
||||||
|
|
||||||
// 指令类型
|
// 指令类型
|
||||||
data.addAll(intChangList(commandType!.typeValue));
|
data.addAll(intChangList(commandType!.typeValue));
|
||||||
@ -44,12 +44,12 @@ class SenderCancelAddFingerprintCommand extends SenderProtocol {
|
|||||||
data.add(37);
|
data.add(37);
|
||||||
|
|
||||||
// keyID 40
|
// keyID 40
|
||||||
int keyIDLength = utf8.encode(keyID!).length;
|
final int keyIDLength = utf8.encode(keyID!).length;
|
||||||
subData.addAll(utf8.encode(keyID!));
|
subData.addAll(utf8.encode(keyID!));
|
||||||
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
||||||
|
|
||||||
//userID 20
|
//userID 20
|
||||||
int userIDLength = utf8.encode(userID!).length;
|
final int userIDLength = utf8.encode(userID!).length;
|
||||||
subData.addAll(utf8.encode(userID!));
|
subData.addAll(utf8.encode(userID!));
|
||||||
subData = getFixedLengthList(subData, 20 - userIDLength);
|
subData = getFixedLengthList(subData, 20 - userIDLength);
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ class SenderCancelAddFingerprintCommand extends SenderProtocol {
|
|||||||
//AuthCodeLen 1
|
//AuthCodeLen 1
|
||||||
subData.add(0);
|
subData.add(0);
|
||||||
} else {
|
} else {
|
||||||
List<int> authCodeData = [];
|
final List<int> authCodeData = <int>[];
|
||||||
//KeyID
|
//KeyID
|
||||||
authCodeData.addAll(utf8.encode(keyID!));
|
authCodeData.addAll(utf8.encode(keyID!));
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ class SenderCancelAddFingerprintCommand extends SenderProtocol {
|
|||||||
authCodeData.addAll(signKey!);
|
authCodeData.addAll(signKey!);
|
||||||
|
|
||||||
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
||||||
var authCode = crypto.md5.convert(authCodeData);
|
final crypto.Digest authCode = crypto.md5.convert(authCodeData);
|
||||||
|
|
||||||
subData.add(authCode.bytes.length);
|
subData.add(authCode.bytes.length);
|
||||||
subData.addAll(authCode.bytes);
|
subData.addAll(authCode.bytes);
|
||||||
@ -80,7 +80,7 @@ class SenderCancelAddFingerprintCommand extends SenderProtocol {
|
|||||||
data.addAll(subData);
|
data.addAll(subData);
|
||||||
|
|
||||||
if ((data.length % 16) != 0) {
|
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++) {
|
for (int i = 0; i < add; i++) {
|
||||||
data.add(0);
|
data.add(0);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,31 +10,12 @@ import '../io_sender.dart';
|
|||||||
import '../io_type.dart';
|
import '../io_type.dart';
|
||||||
import 'package:crypto/crypto.dart' as crypto;
|
import 'package:crypto/crypto.dart' as crypto;
|
||||||
|
|
||||||
///TODO:添加指纹
|
/// 添加指纹
|
||||||
/*
|
/*
|
||||||
备注:
|
备注:
|
||||||
删除单个指纹规则:UseCountLimit 设置为 0。删除全部指纹规则: UseCountLimit 设置为 0,FingerNo 设置为 255,userId 设置为“Delete All !@#”,只有门锁管理员才有权限
|
删除单个指纹规则:UseCountLimit 设置为 0。删除全部指纹规则: UseCountLimit 设置为 0,FingerNo 设置为 255,userId 设置为“Delete All !@#”,只有门锁管理员才有权限
|
||||||
**/
|
**/
|
||||||
class SenderAddFingerprintWithTimeCycleCoercionCommand extends SenderProtocol {
|
class SenderAddFingerprintWithTimeCycleCoercionCommand extends SenderProtocol {
|
||||||
|
|
||||||
String? keyID;
|
|
||||||
String? userID;
|
|
||||||
int? fingerNo;
|
|
||||||
int? useCountLimit;
|
|
||||||
int? isForce;
|
|
||||||
int? operate;
|
|
||||||
int? isAdmin;
|
|
||||||
List<int>? token;
|
|
||||||
int? isRound;
|
|
||||||
int? weekRound;
|
|
||||||
int? startDate;
|
|
||||||
int? endDate;
|
|
||||||
String? startTime;
|
|
||||||
String? endTime;
|
|
||||||
int? needAuthor;
|
|
||||||
List<int>? signKey;
|
|
||||||
List<int>? privateKey;
|
|
||||||
|
|
||||||
SenderAddFingerprintWithTimeCycleCoercionCommand({
|
SenderAddFingerprintWithTimeCycleCoercionCommand({
|
||||||
this.keyID,
|
this.keyID,
|
||||||
this.userID,
|
this.userID,
|
||||||
@ -55,6 +36,24 @@ class SenderAddFingerprintWithTimeCycleCoercionCommand extends SenderProtocol {
|
|||||||
this.privateKey,
|
this.privateKey,
|
||||||
}) : super(CommandType.generalExtendedCommond);
|
}) : super(CommandType.generalExtendedCommond);
|
||||||
|
|
||||||
|
String? keyID;
|
||||||
|
String? userID;
|
||||||
|
int? fingerNo;
|
||||||
|
int? useCountLimit;
|
||||||
|
int? isForce;
|
||||||
|
int? operate;
|
||||||
|
int? isAdmin;
|
||||||
|
List<int>? token;
|
||||||
|
int? isRound;
|
||||||
|
int? weekRound;
|
||||||
|
int? startDate;
|
||||||
|
int? endDate;
|
||||||
|
String? startTime;
|
||||||
|
String? endTime;
|
||||||
|
int? needAuthor;
|
||||||
|
List<int>? signKey;
|
||||||
|
List<int>? privateKey;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'SenderAddFingerprintWithTimeCycleCoercionCommand{keyID: $keyID, '
|
return 'SenderAddFingerprintWithTimeCycleCoercionCommand{keyID: $keyID, '
|
||||||
@ -70,7 +69,7 @@ class SenderAddFingerprintWithTimeCycleCoercionCommand extends SenderProtocol {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
List<int> messageDetail() {
|
List<int> messageDetail() {
|
||||||
List<int> data = [];
|
final List<int> data = [];
|
||||||
List<int> subData = [];
|
List<int> subData = [];
|
||||||
List<int> ebcData = [];
|
List<int> ebcData = [];
|
||||||
|
|
||||||
@ -81,12 +80,12 @@ class SenderAddFingerprintWithTimeCycleCoercionCommand extends SenderProtocol {
|
|||||||
data.add(36);
|
data.add(36);
|
||||||
|
|
||||||
// keyID 40
|
// keyID 40
|
||||||
int keyIDLength = utf8.encode(keyID!).length;
|
final int keyIDLength = utf8.encode(keyID!).length;
|
||||||
subData.addAll(utf8.encode(keyID!));
|
subData.addAll(utf8.encode(keyID!));
|
||||||
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
||||||
|
|
||||||
//userID 20
|
//userID 20
|
||||||
int userIDLength = utf8.encode(userID!).length;
|
final int userIDLength = utf8.encode(userID!).length;
|
||||||
subData.addAll(utf8.encode(userID!));
|
subData.addAll(utf8.encode(userID!));
|
||||||
subData = getFixedLengthList(subData, 20 - userIDLength);
|
subData = getFixedLengthList(subData, 20 - userIDLength);
|
||||||
|
|
||||||
@ -121,27 +120,27 @@ class SenderAddFingerprintWithTimeCycleCoercionCommand extends SenderProtocol {
|
|||||||
subData.add((startDate! & 0xff000000) >> 24);
|
subData.add((startDate! & 0xff000000) >> 24);
|
||||||
subData.add((startDate! & 0xff0000) >> 16);
|
subData.add((startDate! & 0xff0000) >> 16);
|
||||||
subData.add((startDate! & 0xff00) >> 8);
|
subData.add((startDate! & 0xff00) >> 8);
|
||||||
subData.add((startDate! & 0xff));
|
subData.add(startDate! & 0xff);
|
||||||
|
|
||||||
// endDate 4
|
// endDate 4
|
||||||
subData.add((endDate! & 0xff000000) >> 24);
|
subData.add((endDate! & 0xff000000) >> 24);
|
||||||
subData.add((endDate! & 0xff0000) >> 16);
|
subData.add((endDate! & 0xff0000) >> 16);
|
||||||
subData.add((endDate! & 0xff00) >> 8);
|
subData.add((endDate! & 0xff00) >> 8);
|
||||||
subData.add((endDate! & 0xff));
|
subData.add(endDate! & 0xff);
|
||||||
|
|
||||||
// startTime 4
|
// startTime 4
|
||||||
List<int> startTimeList = [0,0,0,0];
|
final List<int> startTimeList = [0,0,0,0];
|
||||||
if(startTime!.contains(":")){
|
if(startTime!.contains(':')){
|
||||||
List<String> getStartTimeList = startTime!.split(":");
|
final List<String> getStartTimeList = startTime!.split(':');
|
||||||
startTimeList[2] = int.parse(getStartTimeList[0]);
|
startTimeList[2] = int.parse(getStartTimeList[0]);
|
||||||
startTimeList[3] = int.parse(getStartTimeList[1]);
|
startTimeList[3] = int.parse(getStartTimeList[1]);
|
||||||
}
|
}
|
||||||
subData.addAll(startTimeList);
|
subData.addAll(startTimeList);
|
||||||
|
|
||||||
// endTime 4
|
// endTime 4
|
||||||
List<int> endTimeList = [0,0,0,0];
|
final List<int> endTimeList = [0,0,0,0];
|
||||||
if(endTime!.contains(":")){
|
if(endTime!.contains(':')){
|
||||||
List<String> getendTimeList = endTime!.split(":");
|
final List<String> getendTimeList = endTime!.split(':');
|
||||||
endTimeList[2] = int.parse(getendTimeList[0]);
|
endTimeList[2] = int.parse(getendTimeList[0]);
|
||||||
endTimeList[3] = int.parse(getendTimeList[1]);
|
endTimeList[3] = int.parse(getendTimeList[1]);
|
||||||
}
|
}
|
||||||
@ -151,7 +150,7 @@ class SenderAddFingerprintWithTimeCycleCoercionCommand extends SenderProtocol {
|
|||||||
//AuthCodeLen 1
|
//AuthCodeLen 1
|
||||||
subData.add(0);
|
subData.add(0);
|
||||||
} else {
|
} else {
|
||||||
List<int> authCodeData = [];
|
final List<int> authCodeData = [];
|
||||||
//KeyID
|
//KeyID
|
||||||
authCodeData.addAll(utf8.encode(keyID!));
|
authCodeData.addAll(utf8.encode(keyID!));
|
||||||
|
|
||||||
@ -164,7 +163,7 @@ class SenderAddFingerprintWithTimeCycleCoercionCommand extends SenderProtocol {
|
|||||||
authCodeData.addAll(signKey!);
|
authCodeData.addAll(signKey!);
|
||||||
|
|
||||||
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
||||||
var authCode = crypto.md5.convert(authCodeData);
|
final authCode = crypto.md5.convert(authCodeData);
|
||||||
|
|
||||||
subData.add(authCode.bytes.length);
|
subData.add(authCode.bytes.length);
|
||||||
subData.addAll(authCode.bytes);
|
subData.addAll(authCode.bytes);
|
||||||
@ -174,7 +173,7 @@ class SenderAddFingerprintWithTimeCycleCoercionCommand extends SenderProtocol {
|
|||||||
data.addAll(subData);
|
data.addAll(subData);
|
||||||
|
|
||||||
if ((data.length % 16) != 0) {
|
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++) {
|
for (int i = 0; i < add; i++) {
|
||||||
data.add(0);
|
data.add(0);
|
||||||
}
|
}
|
||||||
@ -191,7 +190,7 @@ class SenderAddFingerprintWithTimeCycleCoercionReply extends Reply {
|
|||||||
SenderAddFingerprintWithTimeCycleCoercionReply.parseData(CommandType commandType, List<int> dataDetail)
|
SenderAddFingerprintWithTimeCycleCoercionReply.parseData(CommandType commandType, List<int> dataDetail)
|
||||||
: super.parseData(commandType, dataDetail) {
|
: super.parseData(commandType, dataDetail) {
|
||||||
data = dataDetail;
|
data = dataDetail;
|
||||||
int status = data[2];
|
final int status = data[2];
|
||||||
errorWithStstus(status);
|
errorWithStstus(status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -200,7 +199,7 @@ class SenderAddFingerprintProcessReply extends Reply {
|
|||||||
SenderAddFingerprintProcessReply.parseData(CommandType commandType, List<int> dataDetail)
|
SenderAddFingerprintProcessReply.parseData(CommandType commandType, List<int> dataDetail)
|
||||||
: super.parseData(commandType, dataDetail) {
|
: super.parseData(commandType, dataDetail) {
|
||||||
data = dataDetail;
|
data = dataDetail;
|
||||||
int status = data[2];
|
final int status = data[2];
|
||||||
errorWithStstus(status);
|
errorWithStstus(status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -209,7 +208,7 @@ class SenderAddFingerprintConfirmationReply extends Reply {
|
|||||||
SenderAddFingerprintConfirmationReply.parseData(CommandType commandType, List<int> dataDetail)
|
SenderAddFingerprintConfirmationReply.parseData(CommandType commandType, List<int> dataDetail)
|
||||||
: super.parseData(commandType, dataDetail) {
|
: super.parseData(commandType, dataDetail) {
|
||||||
data = dataDetail;
|
data = dataDetail;
|
||||||
int status = data[2];
|
final int status = data[2];
|
||||||
errorWithStstus(status);
|
errorWithStstus(status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -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';
|
/// 该协议已弃用 使用新协议SenderAddICCardWithTimeCycleCoercionCommand 2024.4.16 addby 魏少阳
|
||||||
|
|
||||||
///TODO:该协议已弃用 使用新协议SenderAddICCardWithTimeCycleCoercionCommand 2024.4.16 addby 魏少阳
|
|
||||||
///
|
///
|
||||||
///TODO:设置自定义密码
|
/// 设置自定义密码
|
||||||
// /*
|
// /*
|
||||||
// 备注:
|
// 备注:
|
||||||
// 删除单个指纹规则:UseCountLimit 设置为 0。删除全部指纹规则: UseCountLimit 设置为 0,FingerNo 设置为 255,userId 设置为“Delete All !@#”,只有门锁管理员才有权限
|
// 删除单个指纹规则:UseCountLimit 设置为 0。删除全部指纹规则: UseCountLimit 设置为 0,FingerNo 设置为 255,userId 设置为“Delete All !@#”,只有门锁管理员才有权限
|
||||||
|
|||||||
@ -10,31 +10,13 @@ import '../io_sender.dart';
|
|||||||
import '../io_type.dart';
|
import '../io_type.dart';
|
||||||
import 'package:crypto/crypto.dart' as crypto;
|
import 'package:crypto/crypto.dart' as crypto;
|
||||||
|
|
||||||
///TODO:添加指纹
|
/// 添加指纹
|
||||||
/*
|
/*
|
||||||
备注:
|
备注:
|
||||||
删除单个指纹规则:UseCountLimit 设置为 0。删除全部指纹规则: UseCountLimit 设置为 0,FingerNo 设置为 255,userId 设置为“Delete All !@#”,只有门锁管理员才有权限
|
删除单个指纹规则:UseCountLimit 设置为 0。删除全部指纹规则: UseCountLimit 设置为 0,FingerNo 设置为 255,userId 设置为“Delete All !@#”,只有门锁管理员才有权限
|
||||||
**/
|
**/
|
||||||
class SenderAddICCardWithTimeCycleCoercionCommand extends SenderProtocol {
|
class SenderAddICCardWithTimeCycleCoercionCommand extends SenderProtocol {
|
||||||
|
|
||||||
String? keyID;
|
|
||||||
String? userID;
|
|
||||||
int? cardNo;
|
|
||||||
int? useCountLimit;
|
|
||||||
int? isForce;
|
|
||||||
int? operate;
|
|
||||||
int? isAdmin;
|
|
||||||
List<int>? token;
|
|
||||||
int? isRound;
|
|
||||||
int? weekRound;
|
|
||||||
int? startDate;
|
|
||||||
int? endDate;
|
|
||||||
String? startTime;
|
|
||||||
String? endTime;
|
|
||||||
int? needAuthor;
|
|
||||||
List<int>? signKey;
|
|
||||||
List<int>? privateKey;
|
|
||||||
|
|
||||||
SenderAddICCardWithTimeCycleCoercionCommand({
|
SenderAddICCardWithTimeCycleCoercionCommand({
|
||||||
this.keyID,
|
this.keyID,
|
||||||
this.userID,
|
this.userID,
|
||||||
@ -55,6 +37,24 @@ class SenderAddICCardWithTimeCycleCoercionCommand extends SenderProtocol {
|
|||||||
this.privateKey,
|
this.privateKey,
|
||||||
}) : super(CommandType.generalExtendedCommond);
|
}) : super(CommandType.generalExtendedCommond);
|
||||||
|
|
||||||
|
String? keyID;
|
||||||
|
String? userID;
|
||||||
|
int? cardNo;
|
||||||
|
int? useCountLimit;
|
||||||
|
int? isForce;
|
||||||
|
int? operate;
|
||||||
|
int? isAdmin;
|
||||||
|
List<int>? token;
|
||||||
|
int? isRound;
|
||||||
|
int? weekRound;
|
||||||
|
int? startDate;
|
||||||
|
int? endDate;
|
||||||
|
String? startTime;
|
||||||
|
String? endTime;
|
||||||
|
int? needAuthor;
|
||||||
|
List<int>? signKey;
|
||||||
|
List<int>? privateKey;
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
@ -71,9 +71,9 @@ class SenderAddICCardWithTimeCycleCoercionCommand extends SenderProtocol {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
List<int> messageDetail() {
|
List<int> messageDetail() {
|
||||||
List<int> data = [];
|
final List<int> data = <int>[];
|
||||||
List<int> subData = [];
|
List<int> subData = <int>[];
|
||||||
List<int> ebcData = [];
|
List<int> ebcData = <int>[];
|
||||||
|
|
||||||
// 指令类型
|
// 指令类型
|
||||||
data.addAll(intChangList(commandType!.typeValue));
|
data.addAll(intChangList(commandType!.typeValue));
|
||||||
@ -82,12 +82,12 @@ class SenderAddICCardWithTimeCycleCoercionCommand extends SenderProtocol {
|
|||||||
data.add(24);
|
data.add(24);
|
||||||
|
|
||||||
// keyID 40
|
// keyID 40
|
||||||
int keyIDLength = utf8.encode(keyID!).length;
|
final int keyIDLength = utf8.encode(keyID!).length;
|
||||||
subData.addAll(utf8.encode(keyID!));
|
subData.addAll(utf8.encode(keyID!));
|
||||||
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
||||||
|
|
||||||
//userID 20
|
//userID 20
|
||||||
int userIDLength = utf8.encode(userID!).length;
|
final int userIDLength = utf8.encode(userID!).length;
|
||||||
subData.addAll(utf8.encode(userID!));
|
subData.addAll(utf8.encode(userID!));
|
||||||
subData = getFixedLengthList(subData, 20 - userIDLength);
|
subData = getFixedLengthList(subData, 20 - userIDLength);
|
||||||
|
|
||||||
@ -122,27 +122,27 @@ class SenderAddICCardWithTimeCycleCoercionCommand extends SenderProtocol {
|
|||||||
subData.add((startDate! & 0xff000000) >> 24);
|
subData.add((startDate! & 0xff000000) >> 24);
|
||||||
subData.add((startDate! & 0xff0000) >> 16);
|
subData.add((startDate! & 0xff0000) >> 16);
|
||||||
subData.add((startDate! & 0xff00) >> 8);
|
subData.add((startDate! & 0xff00) >> 8);
|
||||||
subData.add((startDate! & 0xff));
|
subData.add(startDate! & 0xff);
|
||||||
|
|
||||||
// endDate 4
|
// endDate 4
|
||||||
subData.add((endDate! & 0xff000000) >> 24);
|
subData.add((endDate! & 0xff000000) >> 24);
|
||||||
subData.add((endDate! & 0xff0000) >> 16);
|
subData.add((endDate! & 0xff0000) >> 16);
|
||||||
subData.add((endDate! & 0xff00) >> 8);
|
subData.add((endDate! & 0xff00) >> 8);
|
||||||
subData.add((endDate! & 0xff));
|
subData.add(endDate! & 0xff);
|
||||||
|
|
||||||
// startTime 4
|
// startTime 4
|
||||||
List<int> startTimeList = [0,0,0,0];
|
final List<int> startTimeList = <int>[0,0,0,0];
|
||||||
if(startTime!.contains(":")){
|
if(startTime!.contains(':')){
|
||||||
List<String> getStartTimeList = startTime!.split(":");
|
final List<String> getStartTimeList = startTime!.split(':');
|
||||||
startTimeList[2] = int.parse(getStartTimeList[0]);
|
startTimeList[2] = int.parse(getStartTimeList[0]);
|
||||||
startTimeList[3] = int.parse(getStartTimeList[1]);
|
startTimeList[3] = int.parse(getStartTimeList[1]);
|
||||||
}
|
}
|
||||||
subData.addAll(startTimeList);
|
subData.addAll(startTimeList);
|
||||||
|
|
||||||
// endTime 4
|
// endTime 4
|
||||||
List<int> endTimeList = [0,0,0,0];
|
final List<int> endTimeList = <int>[0,0,0,0];
|
||||||
if(endTime!.contains(":")){
|
if(endTime!.contains(':')){
|
||||||
List<String> getendTimeList = endTime!.split(":");
|
final List<String> getendTimeList = endTime!.split(':');
|
||||||
endTimeList[2] = int.parse(getendTimeList[0]);
|
endTimeList[2] = int.parse(getendTimeList[0]);
|
||||||
endTimeList[3] = int.parse(getendTimeList[1]);
|
endTimeList[3] = int.parse(getendTimeList[1]);
|
||||||
}
|
}
|
||||||
@ -152,7 +152,7 @@ class SenderAddICCardWithTimeCycleCoercionCommand extends SenderProtocol {
|
|||||||
//AuthCodeLen 1
|
//AuthCodeLen 1
|
||||||
subData.add(0);
|
subData.add(0);
|
||||||
} else {
|
} else {
|
||||||
List<int> authCodeData = [];
|
final List<int> authCodeData = <int>[];
|
||||||
//KeyID
|
//KeyID
|
||||||
authCodeData.addAll(utf8.encode(keyID!));
|
authCodeData.addAll(utf8.encode(keyID!));
|
||||||
|
|
||||||
@ -165,7 +165,7 @@ class SenderAddICCardWithTimeCycleCoercionCommand extends SenderProtocol {
|
|||||||
authCodeData.addAll(signKey!);
|
authCodeData.addAll(signKey!);
|
||||||
|
|
||||||
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
||||||
var authCode = crypto.md5.convert(authCodeData);
|
final crypto.Digest authCode = crypto.md5.convert(authCodeData);
|
||||||
|
|
||||||
subData.add(authCode.bytes.length);
|
subData.add(authCode.bytes.length);
|
||||||
subData.addAll(authCode.bytes);
|
subData.addAll(authCode.bytes);
|
||||||
@ -175,7 +175,7 @@ class SenderAddICCardWithTimeCycleCoercionCommand extends SenderProtocol {
|
|||||||
data.addAll(subData);
|
data.addAll(subData);
|
||||||
|
|
||||||
if ((data.length % 16) != 0) {
|
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++) {
|
for (int i = 0; i < add; i++) {
|
||||||
data.add(0);
|
data.add(0);
|
||||||
}
|
}
|
||||||
@ -192,7 +192,7 @@ class SenderAddICCardWithTimeCycleCoercionReply extends Reply {
|
|||||||
SenderAddICCardWithTimeCycleCoercionReply.parseData(CommandType commandType, List<int> dataDetail)
|
SenderAddICCardWithTimeCycleCoercionReply.parseData(CommandType commandType, List<int> dataDetail)
|
||||||
: super.parseData(commandType, dataDetail) {
|
: super.parseData(commandType, dataDetail) {
|
||||||
data = dataDetail;
|
data = dataDetail;
|
||||||
int status = data[2];
|
final int status = data[2];
|
||||||
errorWithStstus(status);
|
errorWithStstus(status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -201,7 +201,7 @@ class SenderAddICCardConfirmationReply extends Reply {
|
|||||||
SenderAddICCardConfirmationReply.parseData(CommandType commandType, List<int> dataDetail)
|
SenderAddICCardConfirmationReply.parseData(CommandType commandType, List<int> dataDetail)
|
||||||
: super.parseData(commandType, dataDetail) {
|
: super.parseData(commandType, dataDetail) {
|
||||||
data = dataDetail;
|
data = dataDetail;
|
||||||
int status = data[2];
|
final int status = data[2];
|
||||||
errorWithStstus(status);
|
errorWithStstus(status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import '../io_tool/io_tool.dart';
|
|||||||
import '../io_type.dart';
|
import '../io_type.dart';
|
||||||
import '../sm4Encipher/sm4.dart';
|
import '../sm4Encipher/sm4.dart';
|
||||||
|
|
||||||
/// TODO:取消添加掌纹
|
/// 取消添加掌纹
|
||||||
class SenderCancelAddPalmCommand extends SenderProtocol {
|
class SenderCancelAddPalmCommand extends SenderProtocol {
|
||||||
|
|
||||||
SenderCancelAddPalmCommand({
|
SenderCancelAddPalmCommand({
|
||||||
@ -34,7 +34,7 @@ class SenderCancelAddPalmCommand extends SenderProtocol {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
List<int> messageDetail() {
|
List<int> messageDetail() {
|
||||||
List<int> data = [];
|
final List<int> data = [];
|
||||||
List<int> subData = [];
|
List<int> subData = [];
|
||||||
List<int> ebcData = [];
|
List<int> ebcData = [];
|
||||||
|
|
||||||
@ -45,12 +45,12 @@ class SenderCancelAddPalmCommand extends SenderProtocol {
|
|||||||
data.add(44);
|
data.add(44);
|
||||||
|
|
||||||
// keyID 40
|
// keyID 40
|
||||||
int keyIDLength = utf8.encode(keyID!).length;
|
final int keyIDLength = utf8.encode(keyID!).length;
|
||||||
subData.addAll(utf8.encode(keyID!));
|
subData.addAll(utf8.encode(keyID!));
|
||||||
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
||||||
|
|
||||||
//userID 20
|
//userID 20
|
||||||
int userIDLength = utf8.encode(userID!).length;
|
final int userIDLength = utf8.encode(userID!).length;
|
||||||
subData.addAll(utf8.encode(userID!));
|
subData.addAll(utf8.encode(userID!));
|
||||||
subData = getFixedLengthList(subData, 20 - userIDLength);
|
subData = getFixedLengthList(subData, 20 - userIDLength);
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ class SenderCancelAddPalmCommand extends SenderProtocol {
|
|||||||
//AuthCodeLen 1
|
//AuthCodeLen 1
|
||||||
subData.add(0);
|
subData.add(0);
|
||||||
} else {
|
} else {
|
||||||
List<int> authCodeData = [];
|
final List<int> authCodeData = [];
|
||||||
//KeyID
|
//KeyID
|
||||||
authCodeData.addAll(utf8.encode(keyID!));
|
authCodeData.addAll(utf8.encode(keyID!));
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ class SenderCancelAddPalmCommand extends SenderProtocol {
|
|||||||
authCodeData.addAll(signKey!);
|
authCodeData.addAll(signKey!);
|
||||||
|
|
||||||
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
||||||
var authCode = crypto.md5.convert(authCodeData);
|
final authCode = crypto.md5.convert(authCodeData);
|
||||||
|
|
||||||
subData.add(authCode.bytes.length);
|
subData.add(authCode.bytes.length);
|
||||||
subData.addAll(authCode.bytes);
|
subData.addAll(authCode.bytes);
|
||||||
@ -81,7 +81,7 @@ class SenderCancelAddPalmCommand extends SenderProtocol {
|
|||||||
data.addAll(subData);
|
data.addAll(subData);
|
||||||
|
|
||||||
if ((data.length % 16) != 0) {
|
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++) {
|
for (int i = 0; i < add; i++) {
|
||||||
data.add(0);
|
data.add(0);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,7 @@ import '../io_tool/io_tool.dart';
|
|||||||
import '../io_type.dart';
|
import '../io_type.dart';
|
||||||
import '../sm4Encipher/sm4.dart';
|
import '../sm4Encipher/sm4.dart';
|
||||||
|
|
||||||
///TODO:添加掌纹
|
/// 添加掌纹
|
||||||
class SenderAddPalmWithTimeCycleCoercionCommand extends SenderProtocol {
|
class SenderAddPalmWithTimeCycleCoercionCommand extends SenderProtocol {
|
||||||
|
|
||||||
SenderAddPalmWithTimeCycleCoercionCommand({
|
SenderAddPalmWithTimeCycleCoercionCommand({
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import '../io_tool/io_tool.dart';
|
|||||||
import '../io_type.dart';
|
import '../io_type.dart';
|
||||||
import '../sm4Encipher/sm4.dart';
|
import '../sm4Encipher/sm4.dart';
|
||||||
|
|
||||||
/// TODO:取消添加遥控
|
/// 取消添加遥控
|
||||||
class SenderCancelAddRemoteControlCommand extends SenderProtocol {
|
class SenderCancelAddRemoteControlCommand extends SenderProtocol {
|
||||||
|
|
||||||
SenderCancelAddRemoteControlCommand({
|
SenderCancelAddRemoteControlCommand({
|
||||||
@ -34,7 +34,7 @@ class SenderCancelAddRemoteControlCommand extends SenderProtocol {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
List<int> messageDetail() {
|
List<int> messageDetail() {
|
||||||
List<int> data = [];
|
final List<int> data = [];
|
||||||
List<int> subData = [];
|
List<int> subData = [];
|
||||||
List<int> ebcData = [];
|
List<int> ebcData = [];
|
||||||
|
|
||||||
@ -45,12 +45,12 @@ class SenderCancelAddRemoteControlCommand extends SenderProtocol {
|
|||||||
data.add(28);
|
data.add(28);
|
||||||
|
|
||||||
// keyID 40
|
// keyID 40
|
||||||
int keyIDLength = utf8.encode(keyID!).length;
|
final int keyIDLength = utf8.encode(keyID!).length;
|
||||||
subData.addAll(utf8.encode(keyID!));
|
subData.addAll(utf8.encode(keyID!));
|
||||||
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
||||||
|
|
||||||
//userID 20
|
//userID 20
|
||||||
int userIDLength = utf8.encode(userID!).length;
|
final int userIDLength = utf8.encode(userID!).length;
|
||||||
subData.addAll(utf8.encode(userID!));
|
subData.addAll(utf8.encode(userID!));
|
||||||
subData = getFixedLengthList(subData, 20 - userIDLength);
|
subData = getFixedLengthList(subData, 20 - userIDLength);
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ class SenderCancelAddRemoteControlCommand extends SenderProtocol {
|
|||||||
//AuthCodeLen 1
|
//AuthCodeLen 1
|
||||||
subData.add(0);
|
subData.add(0);
|
||||||
} else {
|
} else {
|
||||||
List<int> authCodeData = [];
|
final List<int> authCodeData = [];
|
||||||
//KeyID
|
//KeyID
|
||||||
authCodeData.addAll(utf8.encode(keyID!));
|
authCodeData.addAll(utf8.encode(keyID!));
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ class SenderCancelAddRemoteControlCommand extends SenderProtocol {
|
|||||||
authCodeData.addAll(signKey!);
|
authCodeData.addAll(signKey!);
|
||||||
|
|
||||||
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
||||||
var authCode = crypto.md5.convert(authCodeData);
|
final authCode = crypto.md5.convert(authCodeData);
|
||||||
|
|
||||||
subData.add(authCode.bytes.length);
|
subData.add(authCode.bytes.length);
|
||||||
subData.addAll(authCode.bytes);
|
subData.addAll(authCode.bytes);
|
||||||
@ -81,7 +81,7 @@ class SenderCancelAddRemoteControlCommand extends SenderProtocol {
|
|||||||
data.addAll(subData);
|
data.addAll(subData);
|
||||||
|
|
||||||
if ((data.length % 16) != 0) {
|
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++) {
|
for (int i = 0; i < add; i++) {
|
||||||
data.add(0);
|
data.add(0);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,7 @@ import '../io_sender.dart';
|
|||||||
import '../io_type.dart';
|
import '../io_type.dart';
|
||||||
import 'package:crypto/crypto.dart' as crypto;
|
import 'package:crypto/crypto.dart' as crypto;
|
||||||
|
|
||||||
///TODO:添加遥控
|
/// 添加遥控
|
||||||
class SenderAddRemoteControlWithTimeCycleCoercionCommand extends SenderProtocol {
|
class SenderAddRemoteControlWithTimeCycleCoercionCommand extends SenderProtocol {
|
||||||
|
|
||||||
SenderAddRemoteControlWithTimeCycleCoercionCommand({
|
SenderAddRemoteControlWithTimeCycleCoercionCommand({
|
||||||
|
|||||||
@ -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<int>? token;
|
|
||||||
// int? startTime;
|
|
||||||
// int? endTime;
|
|
||||||
// int? needAuthor;
|
|
||||||
// List<int>? publicKey;
|
|
||||||
// List<int>? privateKey;
|
|
||||||
// List<int>? 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<int> messageDetail() {
|
|
||||||
// List<int> data = [];
|
|
||||||
// List<int> subData = [];
|
|
||||||
// List<int> 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<int> 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<int> dataDetail)
|
|
||||||
// : super.parseData(commandType, dataDetail) {
|
|
||||||
// data = dataDetail;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
@ -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<int>? token;
|
|
||||||
// int? startTime;
|
|
||||||
// int? endTime;
|
|
||||||
// int? needAuthor;
|
|
||||||
// List<int>? publicKey;
|
|
||||||
// List<int>? privateKey;
|
|
||||||
// List<int>? 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<int> messageDetail() {
|
|
||||||
// List<int> data = [];
|
|
||||||
// List<int> subData = [];
|
|
||||||
// List<int> 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<int> 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<int> dataDetail)
|
|
||||||
// : super.parseData(commandType, dataDetail) {
|
|
||||||
// data = dataDetail;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
@ -11,24 +11,13 @@ import '../io_sender.dart';
|
|||||||
import '../io_type.dart';
|
import '../io_type.dart';
|
||||||
import 'package:crypto/crypto.dart' as crypto;
|
import 'package:crypto/crypto.dart' as crypto;
|
||||||
|
|
||||||
///TODO:添加胁迫密码
|
/// 添加胁迫密码
|
||||||
/*
|
/*
|
||||||
备注:
|
备注:
|
||||||
删除单个指纹规则:UseCountLimit 设置为 0。删除全部指纹规则: UseCountLimit 设置为 0,FingerNo 设置为 255,userId 设置为“Delete All !@#”,只有门锁管理员才有权限
|
删除单个指纹规则:UseCountLimit 设置为 0。删除全部指纹规则: UseCountLimit 设置为 0,FingerNo 设置为 255,userId 设置为“Delete All !@#”,只有门锁管理员才有权限
|
||||||
**/
|
**/
|
||||||
class SenderAddStressPasswordCommand extends SenderProtocol {
|
class SenderAddStressPasswordCommand extends SenderProtocol {
|
||||||
|
|
||||||
String? keyID;
|
|
||||||
String? userID;
|
|
||||||
int? passwordNo;
|
|
||||||
int? useCountLimit;
|
|
||||||
List<int>? token;
|
|
||||||
int? startTime;
|
|
||||||
int? endTime;
|
|
||||||
int? needAuthor;
|
|
||||||
List<int>? publicKey;
|
|
||||||
List<int>? privateKey;
|
|
||||||
|
|
||||||
SenderAddStressPasswordCommand({
|
SenderAddStressPasswordCommand({
|
||||||
this.keyID,
|
this.keyID,
|
||||||
this.userID,
|
this.userID,
|
||||||
@ -42,6 +31,17 @@ class SenderAddStressPasswordCommand extends SenderProtocol {
|
|||||||
this.privateKey,
|
this.privateKey,
|
||||||
}) : super(CommandType.generalExtendedCommond);
|
}) : super(CommandType.generalExtendedCommond);
|
||||||
|
|
||||||
|
String? keyID;
|
||||||
|
String? userID;
|
||||||
|
int? passwordNo;
|
||||||
|
int? useCountLimit;
|
||||||
|
List<int>? token;
|
||||||
|
int? startTime;
|
||||||
|
int? endTime;
|
||||||
|
int? needAuthor;
|
||||||
|
List<int>? publicKey;
|
||||||
|
List<int>? privateKey;
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
@ -56,15 +56,15 @@ class SenderAddStressPasswordCommand extends SenderProtocol {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
List<int> messageDetail() {
|
List<int> messageDetail() {
|
||||||
List<int> data = [];
|
final List<int> data = <int>[];
|
||||||
List<int> subData = [];
|
List<int> subData = <int>[];
|
||||||
List<int> ebcData = [];
|
List<int> ebcData = <int>[];
|
||||||
|
|
||||||
// 指令类型
|
// 指令类型
|
||||||
int type = commandType!.typeValue;
|
final int type = commandType!.typeValue;
|
||||||
double typeDouble = type / 256;
|
final double typeDouble = type / 256;
|
||||||
int type1 = typeDouble.toInt();
|
final int type1 = typeDouble.toInt();
|
||||||
int type2 = type % 256;
|
final int type2 = type % 256;
|
||||||
data.add(type1);
|
data.add(type1);
|
||||||
data.add(type2);
|
data.add(type2);
|
||||||
|
|
||||||
@ -72,12 +72,12 @@ class SenderAddStressPasswordCommand extends SenderProtocol {
|
|||||||
data.add(60);
|
data.add(60);
|
||||||
|
|
||||||
// keyID 40
|
// keyID 40
|
||||||
int keyIDLength = utf8.encode(keyID!).length;
|
final int keyIDLength = utf8.encode(keyID!).length;
|
||||||
subData.addAll(utf8.encode(keyID!));
|
subData.addAll(utf8.encode(keyID!));
|
||||||
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
||||||
|
|
||||||
//userID 20
|
//userID 20
|
||||||
int userIDLength = utf8.encode(userID!).length;
|
final int userIDLength = utf8.encode(userID!).length;
|
||||||
subData.addAll(utf8.encode(userID!));
|
subData.addAll(utf8.encode(userID!));
|
||||||
subData = getFixedLengthList(subData, 20 - userIDLength);
|
subData = getFixedLengthList(subData, 20 - userIDLength);
|
||||||
|
|
||||||
@ -94,19 +94,19 @@ class SenderAddStressPasswordCommand extends SenderProtocol {
|
|||||||
subData.add((startTime! & 0xff000000) >> 24);
|
subData.add((startTime! & 0xff000000) >> 24);
|
||||||
subData.add((startTime! & 0xff0000) >> 16);
|
subData.add((startTime! & 0xff0000) >> 16);
|
||||||
subData.add((startTime! & 0xff00) >> 8);
|
subData.add((startTime! & 0xff00) >> 8);
|
||||||
subData.add((startTime! & 0xff));
|
subData.add(startTime! & 0xff);
|
||||||
|
|
||||||
// endTime 4
|
// endTime 4
|
||||||
subData.add((endTime! & 0xff000000) >> 24);
|
subData.add((endTime! & 0xff000000) >> 24);
|
||||||
subData.add((endTime! & 0xff0000) >> 16);
|
subData.add((endTime! & 0xff0000) >> 16);
|
||||||
subData.add((endTime! & 0xff00) >> 8);
|
subData.add((endTime! & 0xff00) >> 8);
|
||||||
subData.add((endTime! & 0xff));
|
subData.add(endTime! & 0xff);
|
||||||
|
|
||||||
if(needAuthor == 0){
|
if(needAuthor == 0){
|
||||||
//AuthCodeLen 1
|
//AuthCodeLen 1
|
||||||
subData.add(0);
|
subData.add(0);
|
||||||
} else {
|
} else {
|
||||||
List<int> authCodeData = [];
|
final List<int> authCodeData = <int>[];
|
||||||
|
|
||||||
//authUserID
|
//authUserID
|
||||||
authCodeData.addAll(utf8.encode(userID!));
|
authCodeData.addAll(utf8.encode(userID!));
|
||||||
@ -120,7 +120,7 @@ class SenderAddStressPasswordCommand extends SenderProtocol {
|
|||||||
authCodeData.addAll(publicKey!);
|
authCodeData.addAll(publicKey!);
|
||||||
|
|
||||||
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
||||||
var authCode = crypto.md5.convert(authCodeData);
|
final crypto.Digest authCode = crypto.md5.convert(authCodeData);
|
||||||
|
|
||||||
subData.add(authCode.bytes.length);
|
subData.add(authCode.bytes.length);
|
||||||
subData.addAll(authCode.bytes);
|
subData.addAll(authCode.bytes);
|
||||||
@ -130,7 +130,7 @@ class SenderAddStressPasswordCommand extends SenderProtocol {
|
|||||||
data.addAll(subData);
|
data.addAll(subData);
|
||||||
|
|
||||||
if ((data.length % 16) != 0) {
|
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++) {
|
for (int i = 0; i < add; i++) {
|
||||||
data.add(0);
|
data.add(0);
|
||||||
}
|
}
|
||||||
@ -147,7 +147,7 @@ class SenderAddStressPasswordReply extends Reply {
|
|||||||
SenderAddStressPasswordReply.parseData(CommandType commandType, List<int> dataDetail)
|
SenderAddStressPasswordReply.parseData(CommandType commandType, List<int> dataDetail)
|
||||||
: super.parseData(commandType, dataDetail) {
|
: super.parseData(commandType, dataDetail) {
|
||||||
data = dataDetail;
|
data = dataDetail;
|
||||||
int status = data[2];
|
final int status = data[2];
|
||||||
errorWithStstus(status);
|
errorWithStstus(status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -11,31 +11,8 @@ import '../io_sender.dart';
|
|||||||
import '../io_type.dart';
|
import '../io_type.dart';
|
||||||
import 'package:crypto/crypto.dart' as crypto;
|
import 'package:crypto/crypto.dart' as crypto;
|
||||||
|
|
||||||
//TODO:添加用户
|
// 添加用户
|
||||||
class AddUserCommand extends SenderProtocol {
|
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<int>? publicKey;
|
|
||||||
List<int>? privateKey;
|
|
||||||
List<int>? token;
|
|
||||||
|
|
||||||
AddUserCommand(
|
AddUserCommand(
|
||||||
{this.lockID,
|
{this.lockID,
|
||||||
@ -60,6 +37,29 @@ class AddUserCommand extends SenderProtocol {
|
|||||||
this.privateKey,
|
this.privateKey,
|
||||||
this.token})
|
this.token})
|
||||||
: super(CommandType.addUser);
|
: 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<int>? publicKey;
|
||||||
|
List<int>? privateKey;
|
||||||
|
List<int>? token;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
@ -78,34 +78,34 @@ class AddUserCommand extends SenderProtocol {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
List<int> messageDetail() {
|
List<int> messageDetail() {
|
||||||
List<int> data = [];
|
List<int> data = <int>[];
|
||||||
List<int> ebcData = [];
|
List<int> ebcData = <int>[];
|
||||||
|
|
||||||
// 指令类型
|
// 指令类型
|
||||||
int type = commandType!.typeValue;
|
final int type = commandType!.typeValue;
|
||||||
double typeDouble = type / 256;
|
final double typeDouble = type / 256;
|
||||||
int type1 = typeDouble.toInt();
|
final int type1 = typeDouble.toInt();
|
||||||
int type2 = type % 256;
|
final int type2 = type % 256;
|
||||||
data.add(type1);
|
data.add(type1);
|
||||||
data.add(type2);
|
data.add(type2);
|
||||||
|
|
||||||
// 锁id 40
|
// 锁id 40
|
||||||
int lockIDLength = utf8.encode(lockID!).length;
|
final int lockIDLength = utf8.encode(lockID!).length;
|
||||||
data.addAll(utf8.encode(lockID!));
|
data.addAll(utf8.encode(lockID!));
|
||||||
data = getFixedLengthList(data, 40 - lockIDLength);
|
data = getFixedLengthList(data, 40 - lockIDLength);
|
||||||
|
|
||||||
//authUserID 20
|
//authUserID 20
|
||||||
int authUserIDLength = utf8.encode(authUserID!).length;
|
final int authUserIDLength = utf8.encode(authUserID!).length;
|
||||||
data.addAll(utf8.encode(authUserID!));
|
data.addAll(utf8.encode(authUserID!));
|
||||||
data = getFixedLengthList(data, 20 - authUserIDLength);
|
data = getFixedLengthList(data, 20 - authUserIDLength);
|
||||||
|
|
||||||
//KeyID 40
|
//KeyID 40
|
||||||
int keyIDLength = utf8.encode(keyID!).length;
|
final int keyIDLength = utf8.encode(keyID!).length;
|
||||||
data.addAll(utf8.encode(keyID!));
|
data.addAll(utf8.encode(keyID!));
|
||||||
data = getFixedLengthList(data, 40 - keyIDLength);
|
data = getFixedLengthList(data, 40 - keyIDLength);
|
||||||
|
|
||||||
//userID 要接受钥匙的用户的useid 20
|
//userID 要接受钥匙的用户的useid 20
|
||||||
int userIDLength = utf8.encode(userID!).length;
|
final int userIDLength = utf8.encode(userID!).length;
|
||||||
data.addAll(utf8.encode(userID!));
|
data.addAll(utf8.encode(userID!));
|
||||||
data = getFixedLengthList(data, 20 - userIDLength);
|
data = getFixedLengthList(data, 20 - userIDLength);
|
||||||
|
|
||||||
@ -128,18 +128,18 @@ class AddUserCommand extends SenderProtocol {
|
|||||||
data.add((d1! & 0xff000000) >> 24);
|
data.add((d1! & 0xff000000) >> 24);
|
||||||
data.add((d1 & 0xff0000) >> 16);
|
data.add((d1 & 0xff0000) >> 16);
|
||||||
data.add((d1 & 0xff00) >> 8);
|
data.add((d1 & 0xff00) >> 8);
|
||||||
data.add((d1 & 0xff));
|
data.add(d1 & 0xff);
|
||||||
|
|
||||||
// expireDate 4
|
// expireDate 4
|
||||||
data.add((d2! & 0xff000000) >> 24);
|
data.add((d2! & 0xff000000) >> 24);
|
||||||
data.add((d2 & 0xff0000) >> 16);
|
data.add((d2 & 0xff0000) >> 16);
|
||||||
data.add((d2 & 0xff00) >> 8);
|
data.add((d2 & 0xff00) >> 8);
|
||||||
data.add((d2 & 0xff));
|
data.add(d2 & 0xff);
|
||||||
|
|
||||||
//useCountLimit 2
|
//useCountLimit 2
|
||||||
double useCountLimitDouble = useCountLimit! / 256;
|
final double useCountLimitDouble = useCountLimit! / 256;
|
||||||
int useCountLimit1 = useCountLimitDouble.toInt();
|
final int useCountLimit1 = useCountLimitDouble.toInt();
|
||||||
int useCountLimit2 = useCountLimit! % 256;
|
final int useCountLimit2 = useCountLimit! % 256;
|
||||||
data.add(useCountLimit1);
|
data.add(useCountLimit1);
|
||||||
data.add(useCountLimit2);
|
data.add(useCountLimit2);
|
||||||
|
|
||||||
@ -154,7 +154,7 @@ class AddUserCommand extends SenderProtocol {
|
|||||||
data.add(role!);
|
data.add(role!);
|
||||||
|
|
||||||
//password 超级管理员领锁时需验证该密码 20
|
//password 超级管理员领锁时需验证该密码 20
|
||||||
int passwordLength = utf8.encode(password!).length;
|
final int passwordLength = utf8.encode(password!).length;
|
||||||
data.addAll(utf8.encode(password!));
|
data.addAll(utf8.encode(password!));
|
||||||
data = getFixedLengthList(data, 20 - passwordLength);
|
data = getFixedLengthList(data, 20 - passwordLength);
|
||||||
|
|
||||||
@ -165,7 +165,7 @@ class AddUserCommand extends SenderProtocol {
|
|||||||
//AuthCodeLen 1
|
//AuthCodeLen 1
|
||||||
data.add(0);
|
data.add(0);
|
||||||
} else {
|
} else {
|
||||||
List<int> authCodeData = [];
|
final List<int> authCodeData = <int>[];
|
||||||
|
|
||||||
//authUserID
|
//authUserID
|
||||||
authCodeData.addAll(utf8.encode(authUserID!));
|
authCodeData.addAll(utf8.encode(authUserID!));
|
||||||
@ -179,14 +179,14 @@ class AddUserCommand extends SenderProtocol {
|
|||||||
authCodeData.addAll(publicKey!);
|
authCodeData.addAll(publicKey!);
|
||||||
|
|
||||||
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
||||||
var authCode = crypto.md5.convert(authCodeData);
|
final crypto.Digest authCode = crypto.md5.convert(authCodeData);
|
||||||
|
|
||||||
data.add(authCode.bytes.length);
|
data.add(authCode.bytes.length);
|
||||||
data.addAll(authCode.bytes);
|
data.addAll(authCode.bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((data.length % 16) != 0) {
|
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++) {
|
for (int i = 0; i < add; i++) {
|
||||||
data.add(0);
|
data.add(0);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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<int>? token;
|
|
||||||
// int? needAuthor;
|
|
||||||
// List<int>? signKey;
|
|
||||||
// List<int>? privateKey;
|
|
||||||
// AutomaticPadlockCommand({
|
|
||||||
// this.lockID,
|
|
||||||
// this.userID,
|
|
||||||
// this.autoLockFlag,
|
|
||||||
// this.token,
|
|
||||||
// this.needAuthor,
|
|
||||||
// this.signKey,
|
|
||||||
// this.privateKey
|
|
||||||
// }) : super(CommandType.generalExtendedCommond);
|
|
||||||
//
|
|
||||||
// @override
|
|
||||||
// List<int> messageDetail() {
|
|
||||||
// List<int> data = [];
|
|
||||||
// List<int> subData = [];
|
|
||||||
// List<int> 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<int> dataDetail)
|
|
||||||
// : super.parseData(commandType, dataDetail) {
|
|
||||||
// data = dataDetail;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
@ -11,21 +11,9 @@ import '../io_sender.dart';
|
|||||||
import '../io_type.dart';
|
import '../io_type.dart';
|
||||||
import 'package:crypto/crypto.dart' as crypto;
|
import 'package:crypto/crypto.dart' as crypto;
|
||||||
|
|
||||||
//TODO:修改管理员密码
|
// 修改管理员密码
|
||||||
class ChangeAdministratorPasswordCommand extends SenderProtocol {
|
class ChangeAdministratorPasswordCommand extends SenderProtocol {
|
||||||
|
|
||||||
String? keyID;
|
|
||||||
String? userID;
|
|
||||||
int? pwdNo;
|
|
||||||
String? pwd;
|
|
||||||
int? useCountLimit;
|
|
||||||
List<int>? token;
|
|
||||||
int? startTime;
|
|
||||||
int? endTime;
|
|
||||||
int? needAuthor;
|
|
||||||
List<int>? signKey;
|
|
||||||
List<int>? privateKey;
|
|
||||||
|
|
||||||
ChangeAdministratorPasswordCommand({
|
ChangeAdministratorPasswordCommand({
|
||||||
this.keyID,
|
this.keyID,
|
||||||
this.userID,
|
this.userID,
|
||||||
@ -40,6 +28,18 @@ class ChangeAdministratorPasswordCommand extends SenderProtocol {
|
|||||||
this.privateKey,
|
this.privateKey,
|
||||||
}) : super(CommandType.generalExtendedCommond);
|
}) : super(CommandType.generalExtendedCommond);
|
||||||
|
|
||||||
|
String? keyID;
|
||||||
|
String? userID;
|
||||||
|
int? pwdNo;
|
||||||
|
String? pwd;
|
||||||
|
int? useCountLimit;
|
||||||
|
List<int>? token;
|
||||||
|
int? startTime;
|
||||||
|
int? endTime;
|
||||||
|
int? needAuthor;
|
||||||
|
List<int>? signKey;
|
||||||
|
List<int>? privateKey;
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
@ -53,9 +53,9 @@ class ChangeAdministratorPasswordCommand extends SenderProtocol {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
List<int> messageDetail() {
|
List<int> messageDetail() {
|
||||||
List<int> data = [];
|
final List<int> data = <int>[];
|
||||||
List<int> subData = [];
|
List<int> subData = <int>[];
|
||||||
List<int> ebcData = [];
|
List<int> ebcData = <int>[];
|
||||||
|
|
||||||
// 指令类型
|
// 指令类型
|
||||||
// int type = commandType!.typeValue;
|
// int type = commandType!.typeValue;
|
||||||
@ -70,21 +70,20 @@ class ChangeAdministratorPasswordCommand extends SenderProtocol {
|
|||||||
data.add(2);
|
data.add(2);
|
||||||
|
|
||||||
// keyID 40
|
// keyID 40
|
||||||
int keyIDLength = utf8.encode(keyID!).length;
|
final int keyIDLength = utf8.encode(keyID!).length;
|
||||||
subData.addAll(utf8.encode(keyID!));
|
subData.addAll(utf8.encode(keyID!));
|
||||||
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
||||||
|
|
||||||
//userID 20
|
//userID 20
|
||||||
int userIDLength = utf8.encode(userID!).length;
|
final int userIDLength = utf8.encode(userID!).length;
|
||||||
subData.addAll(utf8.encode(userID!));
|
subData.addAll(utf8.encode(userID!));
|
||||||
subData = getFixedLengthList(subData, 20 - userIDLength);
|
subData = getFixedLengthList(subData, 20 - userIDLength);
|
||||||
|
|
||||||
// PwdNo
|
// PwdNo
|
||||||
subData.addAll(intChangList(pwdNo!));
|
subData.addAll(intChangList(pwdNo!));
|
||||||
AppLog.log("pwdNo:$pwdNo");
|
|
||||||
|
|
||||||
// pwd 20
|
// pwd 20
|
||||||
int pwdLength = utf8.encode(pwd!).length;
|
final int pwdLength = utf8.encode(pwd!).length;
|
||||||
subData.addAll(utf8.encode(pwd!));
|
subData.addAll(utf8.encode(pwd!));
|
||||||
subData = getFixedLengthList(subData, 20 - pwdLength);
|
subData = getFixedLengthList(subData, 20 - pwdLength);
|
||||||
|
|
||||||
@ -98,19 +97,19 @@ class ChangeAdministratorPasswordCommand extends SenderProtocol {
|
|||||||
subData.add((startTime! & 0xff000000) >> 24);
|
subData.add((startTime! & 0xff000000) >> 24);
|
||||||
subData.add((startTime! & 0xff0000) >> 16);
|
subData.add((startTime! & 0xff0000) >> 16);
|
||||||
subData.add((startTime! & 0xff00) >> 8);
|
subData.add((startTime! & 0xff00) >> 8);
|
||||||
subData.add((startTime! & 0xff));
|
subData.add(startTime! & 0xff);
|
||||||
|
|
||||||
// endTime 4
|
// endTime 4
|
||||||
subData.add((endTime! & 0xff000000) >> 24);
|
subData.add((endTime! & 0xff000000) >> 24);
|
||||||
subData.add((endTime! & 0xff0000) >> 16);
|
subData.add((endTime! & 0xff0000) >> 16);
|
||||||
subData.add((endTime! & 0xff00) >> 8);
|
subData.add((endTime! & 0xff00) >> 8);
|
||||||
subData.add((endTime! & 0xff));
|
subData.add(endTime! & 0xff);
|
||||||
|
|
||||||
if(needAuthor == 0){
|
if(needAuthor == 0){
|
||||||
//AuthCodeLen 1
|
//AuthCodeLen 1
|
||||||
subData.add(0);
|
subData.add(0);
|
||||||
} else {
|
} else {
|
||||||
List<int> authCodeData = [];
|
final List<int> authCodeData = <int>[];
|
||||||
|
|
||||||
//KeyID
|
//KeyID
|
||||||
authCodeData.addAll(utf8.encode(keyID!));
|
authCodeData.addAll(utf8.encode(keyID!));
|
||||||
@ -124,7 +123,7 @@ class ChangeAdministratorPasswordCommand extends SenderProtocol {
|
|||||||
authCodeData.addAll(signKey!);
|
authCodeData.addAll(signKey!);
|
||||||
|
|
||||||
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
||||||
var authCode = crypto.md5.convert(authCodeData);
|
final crypto.Digest authCode = crypto.md5.convert(authCodeData);
|
||||||
|
|
||||||
subData.add(authCode.bytes.length);
|
subData.add(authCode.bytes.length);
|
||||||
subData.addAll(authCode.bytes);
|
subData.addAll(authCode.bytes);
|
||||||
@ -134,7 +133,7 @@ class ChangeAdministratorPasswordCommand extends SenderProtocol {
|
|||||||
data.addAll(subData);
|
data.addAll(subData);
|
||||||
|
|
||||||
if ((data.length % 16) != 0) {
|
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++) {
|
for (int i = 0; i < add; i++) {
|
||||||
data.add(0);
|
data.add(0);
|
||||||
}
|
}
|
||||||
@ -151,7 +150,7 @@ class ChangeAdministratorPasswordReply extends Reply {
|
|||||||
ChangeAdministratorPasswordReply.parseData(CommandType commandType, List<int> dataDetail)
|
ChangeAdministratorPasswordReply.parseData(CommandType commandType, List<int> dataDetail)
|
||||||
: super.parseData(commandType, dataDetail) {
|
: super.parseData(commandType, dataDetail) {
|
||||||
data = dataDetail;
|
data = dataDetail;
|
||||||
int status = data[2];
|
final int status = data[2];
|
||||||
errorWithStstus(status);
|
errorWithStstus(status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
//TODO:查询指纹状态
|
// 查询指纹状态
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import '../../app_settings/app_settings.dart';
|
import '../../app_settings/app_settings.dart';
|
||||||
@ -11,17 +11,6 @@ import '../sm4Encipher/sm4.dart';
|
|||||||
import 'package:crypto/crypto.dart' as crypto;
|
import 'package:crypto/crypto.dart' as crypto;
|
||||||
|
|
||||||
class SenderCheckingCardStatusCommand extends SenderProtocol {
|
class SenderCheckingCardStatusCommand extends SenderProtocol {
|
||||||
|
|
||||||
String? keyID;
|
|
||||||
String? userID;
|
|
||||||
int? role;
|
|
||||||
int? cardCount;
|
|
||||||
int? cardNo;
|
|
||||||
List<int>? token;
|
|
||||||
int? needAuthor;
|
|
||||||
List<int>? publicKey;
|
|
||||||
List<int>? privateKey;
|
|
||||||
|
|
||||||
SenderCheckingCardStatusCommand({
|
SenderCheckingCardStatusCommand({
|
||||||
this.keyID,
|
this.keyID,
|
||||||
this.userID,
|
this.userID,
|
||||||
@ -34,6 +23,16 @@ class SenderCheckingCardStatusCommand extends SenderProtocol {
|
|||||||
this.privateKey,
|
this.privateKey,
|
||||||
}) : super(CommandType.generalExtendedCommond);
|
}) : super(CommandType.generalExtendedCommond);
|
||||||
|
|
||||||
|
String? keyID;
|
||||||
|
String? userID;
|
||||||
|
int? role;
|
||||||
|
int? cardCount;
|
||||||
|
int? cardNo;
|
||||||
|
List<int>? token;
|
||||||
|
int? needAuthor;
|
||||||
|
List<int>? publicKey;
|
||||||
|
List<int>? privateKey;
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
@ -44,15 +43,15 @@ class SenderCheckingCardStatusCommand extends SenderProtocol {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
List<int> messageDetail() {
|
List<int> messageDetail() {
|
||||||
List<int> data = [];
|
final List<int> data = <int>[];
|
||||||
List<int> subData = [];
|
List<int> subData = <int>[];
|
||||||
List<int> ebcData = [];
|
List<int> ebcData = <int>[];
|
||||||
|
|
||||||
// 指令类型
|
// 指令类型
|
||||||
int type = commandType!.typeValue;
|
final int type = commandType!.typeValue;
|
||||||
double typeDouble = type / 256;
|
final double typeDouble = type / 256;
|
||||||
int type1 = typeDouble.toInt();
|
final int type1 = typeDouble.toInt();
|
||||||
int type2 = type % 256;
|
final int type2 = type % 256;
|
||||||
data.add(type1);
|
data.add(type1);
|
||||||
data.add(type2);
|
data.add(type2);
|
||||||
|
|
||||||
@ -60,12 +59,12 @@ class SenderCheckingCardStatusCommand extends SenderProtocol {
|
|||||||
data.add(20);
|
data.add(20);
|
||||||
|
|
||||||
// keyID 40
|
// keyID 40
|
||||||
int keyIDLength = utf8.encode(keyID!).length;
|
final int keyIDLength = utf8.encode(keyID!).length;
|
||||||
subData.addAll(utf8.encode(keyID!));
|
subData.addAll(utf8.encode(keyID!));
|
||||||
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
||||||
|
|
||||||
//userID 20
|
//userID 20
|
||||||
int userIDLength = utf8.encode(userID!).length;
|
final int userIDLength = utf8.encode(userID!).length;
|
||||||
subData.addAll(utf8.encode(userID!));
|
subData.addAll(utf8.encode(userID!));
|
||||||
subData = getFixedLengthList(subData, 20 - userIDLength);
|
subData = getFixedLengthList(subData, 20 - userIDLength);
|
||||||
|
|
||||||
@ -82,7 +81,7 @@ class SenderCheckingCardStatusCommand extends SenderProtocol {
|
|||||||
//AuthCodeLen 1
|
//AuthCodeLen 1
|
||||||
subData.add(0);
|
subData.add(0);
|
||||||
} else {
|
} else {
|
||||||
List<int> authCodeData = [];
|
final List<int> authCodeData = <int>[];
|
||||||
|
|
||||||
//authUserID
|
//authUserID
|
||||||
authCodeData.addAll(utf8.encode(userID!));
|
authCodeData.addAll(utf8.encode(userID!));
|
||||||
@ -96,7 +95,7 @@ class SenderCheckingCardStatusCommand extends SenderProtocol {
|
|||||||
authCodeData.addAll(publicKey!);
|
authCodeData.addAll(publicKey!);
|
||||||
|
|
||||||
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
||||||
var authCode = crypto.md5.convert(authCodeData);
|
final crypto.Digest authCode = crypto.md5.convert(authCodeData);
|
||||||
|
|
||||||
subData.add(authCode.bytes.length);
|
subData.add(authCode.bytes.length);
|
||||||
subData.addAll(authCode.bytes);
|
subData.addAll(authCode.bytes);
|
||||||
@ -106,7 +105,7 @@ class SenderCheckingCardStatusCommand extends SenderProtocol {
|
|||||||
data.addAll(subData);
|
data.addAll(subData);
|
||||||
|
|
||||||
if ((data.length % 16) != 0) {
|
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++) {
|
for (int i = 0; i < add; i++) {
|
||||||
data.add(0);
|
data.add(0);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,25 +1,17 @@
|
|||||||
|
|
||||||
//TODO:查询用户、指纹、密码、卡片数量(用于判断是否同步)
|
// 查询用户、指纹、密码、卡片数量(用于判断是否同步)
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:crypto/crypto.dart' as crypto;
|
||||||
|
|
||||||
import '../io_reply.dart';
|
import '../io_reply.dart';
|
||||||
import '../io_sender.dart';
|
import '../io_sender.dart';
|
||||||
import '../io_tool/io_tool.dart';
|
import '../io_tool/io_tool.dart';
|
||||||
import '../io_type.dart';
|
import '../io_type.dart';
|
||||||
import '../sm4Encipher/sm4.dart';
|
import '../sm4Encipher/sm4.dart';
|
||||||
import 'package:crypto/crypto.dart' as crypto;
|
|
||||||
|
|
||||||
class SenderCheckingUserInfoCountCommand extends SenderProtocol {
|
class SenderCheckingUserInfoCountCommand extends SenderProtocol {
|
||||||
|
|
||||||
String? keyID;
|
|
||||||
String? userID;
|
|
||||||
int? role;
|
|
||||||
int? nowTime;
|
|
||||||
List<int>? token;
|
|
||||||
int? needAuthor;
|
|
||||||
List<int>? publicKey;
|
|
||||||
List<int>? privateKey;
|
|
||||||
|
|
||||||
SenderCheckingUserInfoCountCommand({
|
SenderCheckingUserInfoCountCommand({
|
||||||
this.keyID,
|
this.keyID,
|
||||||
this.userID,
|
this.userID,
|
||||||
@ -31,6 +23,15 @@ class SenderCheckingUserInfoCountCommand extends SenderProtocol {
|
|||||||
this.privateKey,
|
this.privateKey,
|
||||||
}) : super(CommandType.generalExtendedCommond);
|
}) : super(CommandType.generalExtendedCommond);
|
||||||
|
|
||||||
|
String? keyID;
|
||||||
|
String? userID;
|
||||||
|
int? role;
|
||||||
|
int? nowTime;
|
||||||
|
List<int>? token;
|
||||||
|
int? needAuthor;
|
||||||
|
List<int>? publicKey;
|
||||||
|
List<int>? privateKey;
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
@ -41,15 +42,15 @@ class SenderCheckingUserInfoCountCommand extends SenderProtocol {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
List<int> messageDetail() {
|
List<int> messageDetail() {
|
||||||
List<int> data = [];
|
final List<int> data = <int>[];
|
||||||
List<int> subData = [];
|
List<int> subData = <int>[];
|
||||||
List<int> ebcData = [];
|
List<int> ebcData = <int>[];
|
||||||
|
|
||||||
// 指令类型
|
// 指令类型
|
||||||
int type = commandType!.typeValue;
|
final int type = commandType!.typeValue;
|
||||||
double typeDouble = type / 256;
|
final double typeDouble = type / 256;
|
||||||
int type1 = typeDouble.toInt();
|
final int type1 = typeDouble.toInt();
|
||||||
int type2 = type % 256;
|
final int type2 = type % 256;
|
||||||
data.add(type1);
|
data.add(type1);
|
||||||
data.add(type2);
|
data.add(type2);
|
||||||
|
|
||||||
@ -57,12 +58,12 @@ class SenderCheckingUserInfoCountCommand extends SenderProtocol {
|
|||||||
data.add(15);
|
data.add(15);
|
||||||
|
|
||||||
// keyID 40
|
// keyID 40
|
||||||
int keyIDLength = utf8.encode(keyID!).length;
|
final int keyIDLength = utf8.encode(keyID!).length;
|
||||||
subData.addAll(utf8.encode(keyID!));
|
subData.addAll(utf8.encode(keyID!));
|
||||||
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
||||||
|
|
||||||
//userID 20
|
//userID 20
|
||||||
int userIDLength = utf8.encode(userID!).length;
|
final int userIDLength = utf8.encode(userID!).length;
|
||||||
subData.addAll(utf8.encode(userID!));
|
subData.addAll(utf8.encode(userID!));
|
||||||
subData = getFixedLengthList(subData, 20 - userIDLength);
|
subData = getFixedLengthList(subData, 20 - userIDLength);
|
||||||
|
|
||||||
@ -73,7 +74,7 @@ class SenderCheckingUserInfoCountCommand extends SenderProtocol {
|
|||||||
subData.add((nowTime! & 0xff000000) >> 24);
|
subData.add((nowTime! & 0xff000000) >> 24);
|
||||||
subData.add((nowTime! & 0xff0000) >> 16);
|
subData.add((nowTime! & 0xff0000) >> 16);
|
||||||
subData.add((nowTime! & 0xff00) >> 8);
|
subData.add((nowTime! & 0xff00) >> 8);
|
||||||
subData.add((nowTime! & 0xff));
|
subData.add(nowTime! & 0xff);
|
||||||
|
|
||||||
// token
|
// token
|
||||||
// subData.addAll(token!);
|
// subData.addAll(token!);
|
||||||
@ -82,7 +83,7 @@ class SenderCheckingUserInfoCountCommand extends SenderProtocol {
|
|||||||
//AuthCodeLen 1
|
//AuthCodeLen 1
|
||||||
subData.add(0);
|
subData.add(0);
|
||||||
} else {
|
} else {
|
||||||
List<int> authCodeData = [];
|
final List<int> authCodeData = <int>[];
|
||||||
|
|
||||||
//authUserID
|
//authUserID
|
||||||
authCodeData.addAll(utf8.encode(userID!));
|
authCodeData.addAll(utf8.encode(userID!));
|
||||||
@ -96,7 +97,7 @@ class SenderCheckingUserInfoCountCommand extends SenderProtocol {
|
|||||||
authCodeData.addAll(publicKey!);
|
authCodeData.addAll(publicKey!);
|
||||||
|
|
||||||
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
||||||
var authCode = crypto.md5.convert(authCodeData);
|
final crypto.Digest authCode = crypto.md5.convert(authCodeData);
|
||||||
|
|
||||||
subData.add(authCode.bytes.length);
|
subData.add(authCode.bytes.length);
|
||||||
subData.addAll(authCode.bytes);
|
subData.addAll(authCode.bytes);
|
||||||
@ -106,7 +107,7 @@ class SenderCheckingUserInfoCountCommand extends SenderProtocol {
|
|||||||
data.addAll(subData);
|
data.addAll(subData);
|
||||||
|
|
||||||
if ((data.length % 16) != 0) {
|
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++) {
|
for (int i = 0; i < add; i++) {
|
||||||
data.add(0);
|
data.add(0);
|
||||||
}
|
}
|
||||||
@ -123,7 +124,7 @@ class SenderCheckingUserInfoCountReply extends Reply {
|
|||||||
SenderCheckingUserInfoCountReply.parseData(CommandType commandType, List<int> dataDetail)
|
SenderCheckingUserInfoCountReply.parseData(CommandType commandType, List<int> dataDetail)
|
||||||
: super.parseData(commandType, dataDetail) {
|
: super.parseData(commandType, dataDetail) {
|
||||||
data = dataDetail;
|
data = dataDetail;
|
||||||
int status = data[2];
|
final int status = data[2];
|
||||||
errorWithStstus(status);
|
errorWithStstus(status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,30 +1,16 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
|
|
||||||
import 'package:get/get.dart';
|
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_reply.dart';
|
||||||
import '../io_sender.dart';
|
import '../io_sender.dart';
|
||||||
|
import '../io_tool/io_tool.dart';
|
||||||
import '../io_type.dart';
|
import '../io_type.dart';
|
||||||
import 'package:crypto/crypto.dart' as crypto;
|
import '../sm4Encipher/sm4.dart';
|
||||||
|
|
||||||
//清理用户
|
//清理用户
|
||||||
class CleanUpUsersCommand extends SenderProtocol {
|
class CleanUpUsersCommand extends SenderProtocol {
|
||||||
String? lockID;
|
|
||||||
String? authUserID;
|
|
||||||
String? keyID;
|
|
||||||
String? userID;
|
|
||||||
|
|
||||||
List<int>? userNoList;
|
|
||||||
List<int>? token;
|
|
||||||
|
|
||||||
int? needAuthor;
|
|
||||||
List<int>? publicKey;
|
|
||||||
List<int>? privateKey;
|
|
||||||
|
|
||||||
CleanUpUsersCommand({
|
CleanUpUsersCommand({
|
||||||
this.lockID,
|
this.lockID,
|
||||||
@ -37,6 +23,17 @@ class CleanUpUsersCommand extends SenderProtocol {
|
|||||||
this.userNoList,
|
this.userNoList,
|
||||||
this.token,
|
this.token,
|
||||||
}) : super(CommandType.cleanUpUsers);
|
}) : super(CommandType.cleanUpUsers);
|
||||||
|
String? lockID;
|
||||||
|
String? authUserID;
|
||||||
|
String? keyID;
|
||||||
|
String? userID;
|
||||||
|
|
||||||
|
List<int>? userNoList;
|
||||||
|
List<int>? token;
|
||||||
|
|
||||||
|
int? needAuthor;
|
||||||
|
List<int>? publicKey;
|
||||||
|
List<int>? privateKey;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
@ -48,40 +45,40 @@ class CleanUpUsersCommand extends SenderProtocol {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
List<int> messageDetail() {
|
List<int> messageDetail() {
|
||||||
List<int> data = [];
|
List<int> data = <int>[];
|
||||||
List<int> ebcData = [];
|
List<int> ebcData = <int>[];
|
||||||
|
|
||||||
// 指令类型
|
// 指令类型
|
||||||
int type = commandType!.typeValue;
|
final int type = commandType!.typeValue;
|
||||||
double typeDouble = type / 256;
|
final double typeDouble = type / 256;
|
||||||
int type1 = typeDouble.toInt();
|
final int type1 = typeDouble.toInt();
|
||||||
int type2 = type % 256;
|
final int type2 = type % 256;
|
||||||
data.add(type1);
|
data.add(type1);
|
||||||
data.add(type2);
|
data.add(type2);
|
||||||
|
|
||||||
// 锁id 40
|
// 锁id 40
|
||||||
int lockIDLength = utf8.encode(lockID!).length;
|
final int lockIDLength = utf8.encode(lockID!).length;
|
||||||
data.addAll(utf8.encode(lockID!));
|
data.addAll(utf8.encode(lockID!));
|
||||||
data = getFixedLengthList(data, 40 - lockIDLength);
|
data = getFixedLengthList(data, 40 - lockIDLength);
|
||||||
|
|
||||||
//authUserID 20
|
//authUserID 20
|
||||||
int authUserIDLength = utf8.encode(authUserID!).length;
|
final int authUserIDLength = utf8.encode(authUserID!).length;
|
||||||
data.addAll(utf8.encode(authUserID!));
|
data.addAll(utf8.encode(authUserID!));
|
||||||
data = getFixedLengthList(data, 20 - authUserIDLength);
|
data = getFixedLengthList(data, 20 - authUserIDLength);
|
||||||
|
|
||||||
//KeyID 40
|
//KeyID 40
|
||||||
int keyIDLength = utf8.encode(keyID!).length;
|
final int keyIDLength = utf8.encode(keyID!).length;
|
||||||
data.addAll(utf8.encode(keyID!));
|
data.addAll(utf8.encode(keyID!));
|
||||||
data = getFixedLengthList(data, 40 - keyIDLength);
|
data = getFixedLengthList(data, 40 - keyIDLength);
|
||||||
|
|
||||||
//userID 要接受钥匙的用户的useid 20
|
//userID 要接受钥匙的用户的useid 20
|
||||||
int userIDLength = utf8.encode(userID!).length;
|
final int userIDLength = utf8.encode(userID!).length;
|
||||||
data.addAll(utf8.encode(userID!));
|
data.addAll(utf8.encode(userID!));
|
||||||
data = getFixedLengthList(data, 20 - userIDLength);
|
data = getFixedLengthList(data, 20 - userIDLength);
|
||||||
|
|
||||||
ByteData indexBytes = ByteData(2); // 创建一个长度为2的字节数据
|
final ByteData indexBytes = ByteData(2); // 创建一个长度为2的字节数据
|
||||||
indexBytes.setInt16(0, userNoList!.length);
|
indexBytes.setInt16(0, userNoList!.length);
|
||||||
List<int> indexList = indexBytes.buffer.asUint8List();
|
final List<int> indexList = indexBytes.buffer.asUint8List();
|
||||||
data.addAll(indexList);
|
data.addAll(indexList);
|
||||||
|
|
||||||
data.addAll(userNoList!);
|
data.addAll(userNoList!);
|
||||||
@ -93,7 +90,7 @@ class CleanUpUsersCommand extends SenderProtocol {
|
|||||||
//AuthCodeLen 1
|
//AuthCodeLen 1
|
||||||
data.add(0);
|
data.add(0);
|
||||||
} else {
|
} else {
|
||||||
List<int> authCodeData = [];
|
final List<int> authCodeData = <int>[];
|
||||||
|
|
||||||
//authUserID
|
//authUserID
|
||||||
authCodeData.addAll(utf8.encode(authUserID!));
|
authCodeData.addAll(utf8.encode(authUserID!));
|
||||||
@ -107,14 +104,14 @@ class CleanUpUsersCommand extends SenderProtocol {
|
|||||||
authCodeData.addAll(publicKey!);
|
authCodeData.addAll(publicKey!);
|
||||||
|
|
||||||
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
||||||
var authCode = crypto.md5.convert(authCodeData);
|
final crypto.Digest authCode = crypto.md5.convert(authCodeData);
|
||||||
|
|
||||||
data.add(authCode.bytes.length);
|
data.add(authCode.bytes.length);
|
||||||
data.addAll(authCode.bytes);
|
data.addAll(authCode.bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((data.length % 16) != 0) {
|
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++) {
|
for (int i = 0; i < add; i++) {
|
||||||
data.add(0);
|
data.add(0);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,29 +1,17 @@
|
|||||||
|
|
||||||
//TODO:WIFI配网
|
// WIFI配网
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:crypto/crypto.dart' as crypto;
|
||||||
|
|
||||||
import '../io_reply.dart';
|
import '../io_reply.dart';
|
||||||
import '../io_sender.dart';
|
import '../io_sender.dart';
|
||||||
import '../io_tool/io_tool.dart';
|
import '../io_tool/io_tool.dart';
|
||||||
import '../io_type.dart';
|
import '../io_type.dart';
|
||||||
import '../sm4Encipher/sm4.dart';
|
import '../sm4Encipher/sm4.dart';
|
||||||
import 'package:crypto/crypto.dart' as crypto;
|
|
||||||
|
|
||||||
class SenderConfiguringWifiCommand extends SenderProtocol {
|
class SenderConfiguringWifiCommand extends SenderProtocol {
|
||||||
|
|
||||||
String? keyID;
|
|
||||||
String? userID;
|
|
||||||
String? ssid;
|
|
||||||
String? password;
|
|
||||||
int? numberOfServers;
|
|
||||||
List<int>? listOfServers;
|
|
||||||
int? numberOfPhone;
|
|
||||||
List<String>? listOfPhone;
|
|
||||||
List<int>? token;
|
|
||||||
int? needAuthor;
|
|
||||||
List<int>? publicKey;
|
|
||||||
List<int>? privateKey;
|
|
||||||
|
|
||||||
SenderConfiguringWifiCommand({
|
SenderConfiguringWifiCommand({
|
||||||
this.keyID,
|
this.keyID,
|
||||||
this.userID,
|
this.userID,
|
||||||
@ -39,6 +27,19 @@ class SenderConfiguringWifiCommand extends SenderProtocol {
|
|||||||
this.privateKey,
|
this.privateKey,
|
||||||
}) : super(CommandType.generalExtendedCommond);
|
}) : super(CommandType.generalExtendedCommond);
|
||||||
|
|
||||||
|
String? keyID;
|
||||||
|
String? userID;
|
||||||
|
String? ssid;
|
||||||
|
String? password;
|
||||||
|
int? numberOfServers;
|
||||||
|
List<int>? listOfServers;
|
||||||
|
int? numberOfPhone;
|
||||||
|
List<String>? listOfPhone;
|
||||||
|
List<int>? token;
|
||||||
|
int? needAuthor;
|
||||||
|
List<int>? publicKey;
|
||||||
|
List<int>? privateKey;
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
@ -51,15 +52,15 @@ class SenderConfiguringWifiCommand extends SenderProtocol {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
List<int> messageDetail() {
|
List<int> messageDetail() {
|
||||||
List<int> data = [];
|
final List<int> data = <int>[];
|
||||||
List<int> subData = [];
|
List<int> subData = <int>[];
|
||||||
List<int> ebcData = [];
|
List<int> ebcData = <int>[];
|
||||||
|
|
||||||
// 指令类型
|
// 指令类型
|
||||||
int type = commandType!.typeValue;
|
final int type = commandType!.typeValue;
|
||||||
double typeDouble = type / 256;
|
final double typeDouble = type / 256;
|
||||||
int type1 = typeDouble.toInt();
|
final int type1 = typeDouble.toInt();
|
||||||
int type2 = type % 256;
|
final int type2 = type % 256;
|
||||||
data.add(type1);
|
data.add(type1);
|
||||||
data.add(type2);
|
data.add(type2);
|
||||||
|
|
||||||
@ -67,22 +68,22 @@ class SenderConfiguringWifiCommand extends SenderProtocol {
|
|||||||
data.add(50);
|
data.add(50);
|
||||||
|
|
||||||
// keyID 40
|
// keyID 40
|
||||||
int keyIDLength = utf8.encode(keyID!).length;
|
final int keyIDLength = utf8.encode(keyID!).length;
|
||||||
subData.addAll(utf8.encode(keyID!));
|
subData.addAll(utf8.encode(keyID!));
|
||||||
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
||||||
|
|
||||||
//userID 20
|
//userID 20
|
||||||
int userIDLength = utf8.encode(userID!).length;
|
final int userIDLength = utf8.encode(userID!).length;
|
||||||
subData.addAll(utf8.encode(userID!));
|
subData.addAll(utf8.encode(userID!));
|
||||||
subData = getFixedLengthList(subData, 20 - userIDLength);
|
subData = getFixedLengthList(subData, 20 - userIDLength);
|
||||||
|
|
||||||
//SSID 30
|
//SSID 30
|
||||||
int ssidLength = utf8.encode(ssid!).length;
|
final int ssidLength = utf8.encode(ssid!).length;
|
||||||
subData.addAll(utf8.encode(ssid!));
|
subData.addAll(utf8.encode(ssid!));
|
||||||
subData = getFixedLengthList(subData, 30 - ssidLength);
|
subData = getFixedLengthList(subData, 30 - ssidLength);
|
||||||
|
|
||||||
//Password 20
|
//Password 20
|
||||||
int passwordLength = utf8.encode(password!).length;
|
final int passwordLength = utf8.encode(password!).length;
|
||||||
subData.addAll(utf8.encode(password!));
|
subData.addAll(utf8.encode(password!));
|
||||||
subData = getFixedLengthList(subData, 20 - passwordLength);
|
subData = getFixedLengthList(subData, 20 - passwordLength);
|
||||||
|
|
||||||
@ -96,8 +97,8 @@ class SenderConfiguringWifiCommand extends SenderProtocol {
|
|||||||
subData.add(numberOfPhone!);
|
subData.add(numberOfPhone!);
|
||||||
|
|
||||||
// listOfPhone
|
// listOfPhone
|
||||||
listOfPhone!.forEach((element) {
|
listOfPhone!.forEach((String element) {
|
||||||
int phoneLength = utf8.encode(element).length;
|
final int phoneLength = utf8.encode(element).length;
|
||||||
subData.addAll(utf8.encode(element));
|
subData.addAll(utf8.encode(element));
|
||||||
subData = getFixedLengthList(subData, 20 - phoneLength);
|
subData = getFixedLengthList(subData, 20 - phoneLength);
|
||||||
});
|
});
|
||||||
@ -109,7 +110,7 @@ class SenderConfiguringWifiCommand extends SenderProtocol {
|
|||||||
//AuthCodeLen 1
|
//AuthCodeLen 1
|
||||||
subData.add(0);
|
subData.add(0);
|
||||||
} else {
|
} else {
|
||||||
List<int> authCodeData = [];
|
final List<int> authCodeData = <int>[];
|
||||||
|
|
||||||
//userID
|
//userID
|
||||||
authCodeData.addAll(utf8.encode(userID!));
|
authCodeData.addAll(utf8.encode(userID!));
|
||||||
@ -123,7 +124,7 @@ class SenderConfiguringWifiCommand extends SenderProtocol {
|
|||||||
authCodeData.addAll(publicKey!);
|
authCodeData.addAll(publicKey!);
|
||||||
|
|
||||||
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
||||||
var authCode = crypto.md5.convert(authCodeData);
|
final crypto.Digest authCode = crypto.md5.convert(authCodeData);
|
||||||
|
|
||||||
subData.add(authCode.bytes.length);
|
subData.add(authCode.bytes.length);
|
||||||
subData.addAll(authCode.bytes);
|
subData.addAll(authCode.bytes);
|
||||||
@ -133,7 +134,7 @@ class SenderConfiguringWifiCommand extends SenderProtocol {
|
|||||||
data.addAll(subData);
|
data.addAll(subData);
|
||||||
|
|
||||||
if ((data.length % 16) != 0) {
|
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++) {
|
for (int i = 0; i < add; i++) {
|
||||||
data.add(0);
|
data.add(0);
|
||||||
}
|
}
|
||||||
@ -150,7 +151,7 @@ class SenderConfiguringWifiReply extends Reply {
|
|||||||
SenderConfiguringWifiReply.parseData(CommandType commandType, List<int> dataDetail)
|
SenderConfiguringWifiReply.parseData(CommandType commandType, List<int> dataDetail)
|
||||||
: super.parseData(commandType, dataDetail) {
|
: super.parseData(commandType, dataDetail) {
|
||||||
data = dataDetail;
|
data = dataDetail;
|
||||||
int status = data[5];
|
final int status = data[5];
|
||||||
errorWithStstus(status);
|
errorWithStstus(status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,24 +1,16 @@
|
|||||||
|
|
||||||
//TODO:添加用户
|
// 添加用户
|
||||||
import 'dart:convert';
|
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;
|
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;
|
class DeletUserCommand extends SenderProtocol {
|
||||||
String? authUserID;
|
|
||||||
String? keyID;
|
|
||||||
String? delUserID;
|
|
||||||
int? needAuthor;
|
|
||||||
List<int>? publicKey;
|
|
||||||
List<int>? privateKey;
|
|
||||||
List<int>? token;
|
|
||||||
DeletUserCommand({
|
DeletUserCommand({
|
||||||
this.lockID,
|
this.lockID,
|
||||||
this.authUserID,
|
this.authUserID,
|
||||||
@ -30,6 +22,14 @@ class DeletUserCommand extends SenderProtocol {
|
|||||||
this.token
|
this.token
|
||||||
}) : super(CommandType.deletUser);
|
}) : super(CommandType.deletUser);
|
||||||
|
|
||||||
|
String? lockID;
|
||||||
|
String? authUserID;
|
||||||
|
String? keyID;
|
||||||
|
String? delUserID;
|
||||||
|
int? needAuthor;
|
||||||
|
List<int>? publicKey;
|
||||||
|
List<int>? privateKey;
|
||||||
|
List<int>? token;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
@ -40,34 +40,34 @@ class DeletUserCommand extends SenderProtocol {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
List<int> messageDetail() {
|
List<int> messageDetail() {
|
||||||
List<int> data = [];
|
List<int> data = <int>[];
|
||||||
List<int> ebcData = [];
|
List<int> ebcData = <int>[];
|
||||||
|
|
||||||
// 指令类型
|
// 指令类型
|
||||||
int type = commandType!.typeValue;
|
final int type = commandType!.typeValue;
|
||||||
double typeDouble = type / 256;
|
final double typeDouble = type / 256;
|
||||||
int type1 = typeDouble.toInt();
|
final int type1 = typeDouble.toInt();
|
||||||
int type2 = type % 256;
|
final int type2 = type % 256;
|
||||||
data.add(type1);
|
data.add(type1);
|
||||||
data.add(type2);
|
data.add(type2);
|
||||||
|
|
||||||
// 锁id 40
|
// 锁id 40
|
||||||
int lockIDLength = utf8.encode(lockID!).length;
|
final int lockIDLength = utf8.encode(lockID!).length;
|
||||||
data.addAll(utf8.encode(lockID!));
|
data.addAll(utf8.encode(lockID!));
|
||||||
data = getFixedLengthList(data, 40 - lockIDLength);
|
data = getFixedLengthList(data, 40 - lockIDLength);
|
||||||
|
|
||||||
//authUserID 20
|
//authUserID 20
|
||||||
int authUserIDLength = utf8.encode(authUserID!).length;
|
final int authUserIDLength = utf8.encode(authUserID!).length;
|
||||||
data.addAll(utf8.encode(authUserID!));
|
data.addAll(utf8.encode(authUserID!));
|
||||||
data = getFixedLengthList(data, 20 - authUserIDLength);
|
data = getFixedLengthList(data, 20 - authUserIDLength);
|
||||||
|
|
||||||
//KeyID 40
|
//KeyID 40
|
||||||
int keyIDLength = utf8.encode(keyID!).length;
|
final int keyIDLength = utf8.encode(keyID!).length;
|
||||||
data.addAll(utf8.encode(keyID!));
|
data.addAll(utf8.encode(keyID!));
|
||||||
data = getFixedLengthList(data, 40 - keyIDLength);
|
data = getFixedLengthList(data, 40 - keyIDLength);
|
||||||
|
|
||||||
//delUserID 20
|
//delUserID 20
|
||||||
int delUserIDLength = utf8.encode(delUserID!).length;
|
final int delUserIDLength = utf8.encode(delUserID!).length;
|
||||||
data.addAll(utf8.encode(delUserID!));
|
data.addAll(utf8.encode(delUserID!));
|
||||||
data = getFixedLengthList(data, 20 - delUserIDLength);
|
data = getFixedLengthList(data, 20 - delUserIDLength);
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ class DeletUserCommand extends SenderProtocol {
|
|||||||
//AuthCodeLen 1
|
//AuthCodeLen 1
|
||||||
data.add(0);
|
data.add(0);
|
||||||
} else {
|
} else {
|
||||||
List<int> authCodeData = [];
|
final List<int> authCodeData = <int>[];
|
||||||
|
|
||||||
//authUserID
|
//authUserID
|
||||||
authCodeData.addAll(utf8.encode(authUserID!));
|
authCodeData.addAll(utf8.encode(authUserID!));
|
||||||
@ -92,14 +92,14 @@ class DeletUserCommand extends SenderProtocol {
|
|||||||
authCodeData.addAll(publicKey!);
|
authCodeData.addAll(publicKey!);
|
||||||
|
|
||||||
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
||||||
var authCode = crypto.md5.convert(authCodeData);
|
final crypto.Digest authCode = crypto.md5.convert(authCodeData);
|
||||||
|
|
||||||
data.add(authCode.bytes.length);
|
data.add(authCode.bytes.length);
|
||||||
data.addAll(authCode.bytes);
|
data.addAll(authCode.bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((data.length % 16) != 0) {
|
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++) {
|
for (int i = 0; i < add; i++) {
|
||||||
data.add(0);
|
data.add(0);
|
||||||
}
|
}
|
||||||
@ -116,7 +116,7 @@ class DeletUserReply extends Reply {
|
|||||||
DeletUserReply.parseData(CommandType commandType, List<int> dataDetail)
|
DeletUserReply.parseData(CommandType commandType, List<int> dataDetail)
|
||||||
: super.parseData(commandType, dataDetail) {
|
: super.parseData(commandType, dataDetail) {
|
||||||
data = dataDetail;
|
data = dataDetail;
|
||||||
int status = data[6];
|
final int status = data[6];
|
||||||
errorWithStstus(status);
|
errorWithStstus(status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,33 +1,18 @@
|
|||||||
|
|
||||||
|
|
||||||
//TODO:修改用户
|
// 修改用户
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:crypto/crypto.dart' as crypto;
|
||||||
import 'package:star_lock/tools/dateTool.dart';
|
import 'package:star_lock/tools/dateTool.dart';
|
||||||
|
|
||||||
import '../io_tool/io_tool.dart';
|
|
||||||
import '../sm4Encipher/sm4.dart';
|
|
||||||
import '../io_reply.dart';
|
import '../io_reply.dart';
|
||||||
import '../io_sender.dart';
|
import '../io_sender.dart';
|
||||||
|
import '../io_tool/io_tool.dart';
|
||||||
import '../io_type.dart';
|
import '../io_type.dart';
|
||||||
import 'package:crypto/crypto.dart' as crypto;
|
import '../sm4Encipher/sm4.dart';
|
||||||
|
|
||||||
class EditUserCommand extends SenderProtocol {
|
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<int>? publicKey;
|
|
||||||
List<int>? privateKey;
|
|
||||||
List<int>? token;
|
|
||||||
EditUserCommand({
|
EditUserCommand({
|
||||||
this.lockID,
|
this.lockID,
|
||||||
this.authUserID,
|
this.authUserID,
|
||||||
@ -45,6 +30,20 @@ class EditUserCommand extends SenderProtocol {
|
|||||||
this.token
|
this.token
|
||||||
}) : super(CommandType.editUser);
|
}) : 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<int>? publicKey;
|
||||||
|
List<int>? privateKey;
|
||||||
|
List<int>? token;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
@ -60,34 +59,34 @@ class EditUserCommand extends SenderProtocol {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
List<int> messageDetail() {
|
List<int> messageDetail() {
|
||||||
List<int> data = [];
|
List<int> data = <int>[];
|
||||||
List<int> ebcData = [];
|
List<int> ebcData = <int>[];
|
||||||
|
|
||||||
// 指令类型
|
// 指令类型
|
||||||
int type = commandType!.typeValue;
|
final int type = commandType!.typeValue;
|
||||||
double typeDouble = type / 256;
|
final double typeDouble = type / 256;
|
||||||
int type1 = typeDouble.toInt();
|
final int type1 = typeDouble.toInt();
|
||||||
int type2 = type % 256;
|
final int type2 = type % 256;
|
||||||
data.add(type1);
|
data.add(type1);
|
||||||
data.add(type2);
|
data.add(type2);
|
||||||
|
|
||||||
// 锁id 40
|
// 锁id 40
|
||||||
int lockIDLength = utf8.encode(lockID!).length;
|
final int lockIDLength = utf8.encode(lockID!).length;
|
||||||
data.addAll(utf8.encode(lockID!));
|
data.addAll(utf8.encode(lockID!));
|
||||||
data = getFixedLengthList(data, 40 - lockIDLength);
|
data = getFixedLengthList(data, 40 - lockIDLength);
|
||||||
|
|
||||||
//authUserID 20
|
//authUserID 20
|
||||||
int authUserIDLength = utf8.encode(authUserID!).length;
|
final int authUserIDLength = utf8.encode(authUserID!).length;
|
||||||
data.addAll(utf8.encode(authUserID!));
|
data.addAll(utf8.encode(authUserID!));
|
||||||
data = getFixedLengthList(data, 20 - authUserIDLength);
|
data = getFixedLengthList(data, 20 - authUserIDLength);
|
||||||
|
|
||||||
//KeyID 40
|
//KeyID 40
|
||||||
int keyIDLength = utf8.encode(keyID!).length;
|
final int keyIDLength = utf8.encode(keyID!).length;
|
||||||
data.addAll(utf8.encode(keyID!));
|
data.addAll(utf8.encode(keyID!));
|
||||||
data = getFixedLengthList(data, 40 - keyIDLength);
|
data = getFixedLengthList(data, 40 - keyIDLength);
|
||||||
|
|
||||||
//userID 要接受钥匙的用户的useid 20
|
//userID 要接受钥匙的用户的useid 20
|
||||||
int userIDLength = utf8.encode(userID!).length;
|
final int userIDLength = utf8.encode(userID!).length;
|
||||||
data.addAll(utf8.encode(userID!));
|
data.addAll(utf8.encode(userID!));
|
||||||
data = getFixedLengthList(data, 20 - userIDLength);
|
data = getFixedLengthList(data, 20 - userIDLength);
|
||||||
|
|
||||||
@ -110,19 +109,19 @@ class EditUserCommand extends SenderProtocol {
|
|||||||
data.add((d1! & 0xff000000) >> 24);
|
data.add((d1! & 0xff000000) >> 24);
|
||||||
data.add((d1 & 0xff0000) >> 16);
|
data.add((d1 & 0xff0000) >> 16);
|
||||||
data.add((d1 & 0xff00) >> 8);
|
data.add((d1 & 0xff00) >> 8);
|
||||||
data.add((d1 & 0xff));
|
data.add(d1 & 0xff);
|
||||||
|
|
||||||
// expireDate 4
|
// expireDate 4
|
||||||
data.add((d2! & 0xff000000) >> 24);
|
data.add((d2! & 0xff000000) >> 24);
|
||||||
data.add((d2 & 0xff0000) >> 16);
|
data.add((d2 & 0xff0000) >> 16);
|
||||||
data.add((d2 & 0xff00) >> 8);
|
data.add((d2 & 0xff00) >> 8);
|
||||||
data.add((d2 & 0xff));
|
data.add(d2 & 0xff);
|
||||||
|
|
||||||
// role 长度1 用户角色,0:普通用户,1:管理员,0xff:超级管理员
|
// role 长度1 用户角色,0:普通用户,1:管理员,0xff:超级管理员
|
||||||
data.add(role!);
|
data.add(role!);
|
||||||
|
|
||||||
//password 超级管理员领锁时需验证该密码 20
|
//password 超级管理员领锁时需验证该密码 20
|
||||||
int passwordLength = utf8.encode(password!).length;
|
final int passwordLength = utf8.encode(password!).length;
|
||||||
data.addAll(utf8.encode(password!));
|
data.addAll(utf8.encode(password!));
|
||||||
data = getFixedLengthList(data, 20 - passwordLength);
|
data = getFixedLengthList(data, 20 - passwordLength);
|
||||||
|
|
||||||
@ -133,7 +132,7 @@ class EditUserCommand extends SenderProtocol {
|
|||||||
//AuthCodeLen 1
|
//AuthCodeLen 1
|
||||||
data.add(0);
|
data.add(0);
|
||||||
} else {
|
} else {
|
||||||
List<int> authCodeData = [];
|
final List<int> authCodeData = <int>[];
|
||||||
|
|
||||||
//authUserID
|
//authUserID
|
||||||
authCodeData.addAll(utf8.encode(authUserID!));
|
authCodeData.addAll(utf8.encode(authUserID!));
|
||||||
@ -147,14 +146,14 @@ class EditUserCommand extends SenderProtocol {
|
|||||||
authCodeData.addAll(publicKey!);
|
authCodeData.addAll(publicKey!);
|
||||||
|
|
||||||
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
||||||
var authCode = crypto.md5.convert(authCodeData);
|
final crypto.Digest authCode = crypto.md5.convert(authCodeData);
|
||||||
|
|
||||||
data.add(authCode.bytes.length);
|
data.add(authCode.bytes.length);
|
||||||
data.addAll(authCode.bytes);
|
data.addAll(authCode.bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((data.length % 16) != 0) {
|
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++) {
|
for (int i = 0; i < add; i++) {
|
||||||
data.add(0);
|
data.add(0);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
//TODO:恢复出厂设置
|
// 恢复出厂设置
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:crypto/crypto.dart' as crypto;
|
import 'package:crypto/crypto.dart' as crypto;
|
||||||
@ -11,14 +11,6 @@ import '../io_type.dart';
|
|||||||
import '../sm4Encipher/sm4.dart';
|
import '../sm4Encipher/sm4.dart';
|
||||||
|
|
||||||
class FactoryDataResetCommand extends SenderProtocol {
|
class FactoryDataResetCommand extends SenderProtocol {
|
||||||
|
|
||||||
String? lockID;
|
|
||||||
String? userID;
|
|
||||||
String? keyID;
|
|
||||||
List<int>? publicKey;
|
|
||||||
List<int>? privateKey;
|
|
||||||
List<int>? token;
|
|
||||||
int? needAuthor;
|
|
||||||
FactoryDataResetCommand({
|
FactoryDataResetCommand({
|
||||||
this.lockID,
|
this.lockID,
|
||||||
this.userID,
|
this.userID,
|
||||||
@ -29,6 +21,13 @@ class FactoryDataResetCommand extends SenderProtocol {
|
|||||||
this.privateKey,
|
this.privateKey,
|
||||||
}) : super(CommandType.factoryDataReset);
|
}) : super(CommandType.factoryDataReset);
|
||||||
|
|
||||||
|
String? lockID;
|
||||||
|
String? userID;
|
||||||
|
String? keyID;
|
||||||
|
List<int>? publicKey;
|
||||||
|
List<int>? privateKey;
|
||||||
|
List<int>? token;
|
||||||
|
int? needAuthor;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
@ -39,24 +38,24 @@ class FactoryDataResetCommand extends SenderProtocol {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
List<int> messageDetail() {
|
List<int> messageDetail() {
|
||||||
List<int> data = [];
|
List<int> data = <int>[];
|
||||||
List<int> ebcData = [];
|
List<int> ebcData = <int>[];
|
||||||
|
|
||||||
// 指令类型
|
// 指令类型
|
||||||
int type = commandType!.typeValue;
|
final int type = commandType!.typeValue;
|
||||||
double typeDouble = type / 256;
|
final double typeDouble = type / 256;
|
||||||
int type1 = typeDouble.toInt();
|
final int type1 = typeDouble.toInt();
|
||||||
int type2 = type % 256;
|
final int type2 = type % 256;
|
||||||
data.add(type1);
|
data.add(type1);
|
||||||
data.add(type2);
|
data.add(type2);
|
||||||
|
|
||||||
// 锁id 40
|
// 锁id 40
|
||||||
int lockIDLength = utf8.encode(lockID!).length;
|
final int lockIDLength = utf8.encode(lockID!).length;
|
||||||
data.addAll(utf8.encode(lockID!));
|
data.addAll(utf8.encode(lockID!));
|
||||||
data = getFixedLengthList(data, 40 - lockIDLength);
|
data = getFixedLengthList(data, 40 - lockIDLength);
|
||||||
|
|
||||||
//userID 20
|
//userID 20
|
||||||
int userIDLength = utf8.encode(userID!).length;
|
final int userIDLength = utf8.encode(userID!).length;
|
||||||
data.addAll(utf8.encode(userID!));
|
data.addAll(utf8.encode(userID!));
|
||||||
data = getFixedLengthList(data, 20 - userIDLength);
|
data = getFixedLengthList(data, 20 - userIDLength);
|
||||||
|
|
||||||
@ -67,7 +66,7 @@ class FactoryDataResetCommand extends SenderProtocol {
|
|||||||
//AuthCodeLen 1
|
//AuthCodeLen 1
|
||||||
data.add(0);
|
data.add(0);
|
||||||
} else {
|
} else {
|
||||||
List<int> authCodeData = [];
|
final List<int> authCodeData = <int>[];
|
||||||
|
|
||||||
//userID
|
//userID
|
||||||
authCodeData.addAll(utf8.encode(lockID!));
|
authCodeData.addAll(utf8.encode(lockID!));
|
||||||
@ -78,14 +77,14 @@ class FactoryDataResetCommand extends SenderProtocol {
|
|||||||
authCodeData.addAll(publicKey!);
|
authCodeData.addAll(publicKey!);
|
||||||
|
|
||||||
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
||||||
var authCode = crypto.md5.convert(authCodeData);
|
final crypto.Digest authCode = crypto.md5.convert(authCodeData);
|
||||||
|
|
||||||
data.add(authCode.bytes.length);
|
data.add(authCode.bytes.length);
|
||||||
data.addAll(authCode.bytes);
|
data.addAll(authCode.bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((data.length % 16) != 0) {
|
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++) {
|
for (int i = 0; i < add; i++) {
|
||||||
data.add(0);
|
data.add(0);
|
||||||
}
|
}
|
||||||
@ -102,7 +101,7 @@ class FactoryDataResetReply extends Reply {
|
|||||||
FactoryDataResetReply.parseData(CommandType commandType, List<int> dataDetail)
|
FactoryDataResetReply.parseData(CommandType commandType, List<int> dataDetail)
|
||||||
: super.parseData(commandType, dataDetail) {
|
: super.parseData(commandType, dataDetail) {
|
||||||
data = dataDetail;
|
data = dataDetail;
|
||||||
int status = data[6];
|
final int status = data[6];
|
||||||
errorWithStstus(status);
|
errorWithStstus(status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -6,8 +6,6 @@ import '../io_reply.dart';
|
|||||||
import '../io_sender.dart';
|
import '../io_sender.dart';
|
||||||
import '../io_tool/io_tool.dart';
|
import '../io_tool/io_tool.dart';
|
||||||
import '../io_type.dart';
|
import '../io_type.dart';
|
||||||
// import '../sm4Encipher/sm4.dart';
|
|
||||||
// import 'package:crypto/crypto.dart' as crypto;
|
|
||||||
|
|
||||||
class GatewayConfiguringWifiCommand extends SenderProtocol {
|
class GatewayConfiguringWifiCommand extends SenderProtocol {
|
||||||
|
|
||||||
|
|||||||
@ -6,8 +6,6 @@ import '../io_reply.dart';
|
|||||||
import '../io_sender.dart';
|
import '../io_sender.dart';
|
||||||
import '../io_tool/io_tool.dart';
|
import '../io_tool/io_tool.dart';
|
||||||
import '../io_type.dart';
|
import '../io_type.dart';
|
||||||
// import '../sm4Encipher/sm4.dart';
|
|
||||||
// import 'package:crypto/crypto.dart' as crypto;
|
|
||||||
|
|
||||||
class GatewayGetStatusCommand extends SenderProtocol {
|
class GatewayGetStatusCommand extends SenderProtocol {
|
||||||
|
|
||||||
|
|||||||
@ -8,7 +8,6 @@ import '../io_reply.dart';
|
|||||||
import '../io_sender.dart';
|
import '../io_sender.dart';
|
||||||
import '../io_tool/io_tool.dart';
|
import '../io_tool/io_tool.dart';
|
||||||
import '../io_type.dart';
|
import '../io_type.dart';
|
||||||
// import '../sm4Encipher/sm4.dart';
|
|
||||||
|
|
||||||
class GatewayGetWifiCommand extends SenderProtocol {
|
class GatewayGetWifiCommand extends SenderProtocol {
|
||||||
|
|
||||||
|
|||||||
@ -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<int>? privateKey;
|
|
||||||
// GetLockStatuCommand({
|
|
||||||
// this.lockID,
|
|
||||||
// this.userID,
|
|
||||||
// this.privateKey
|
|
||||||
// }) : super(CommandType.readLockStatusInfo);
|
|
||||||
//
|
|
||||||
// @override
|
|
||||||
// List<int> messageDetail() {
|
|
||||||
// List<int> data = [];
|
|
||||||
// List<int> 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<int> 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;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
@ -11,16 +11,9 @@ import '../io_sender.dart';
|
|||||||
import '../io_tool/io_tool.dart';
|
import '../io_tool/io_tool.dart';
|
||||||
import '../io_type.dart';
|
import '../io_type.dart';
|
||||||
|
|
||||||
List<int> publicKeyDataList = [];
|
List<int> publicKeyDataList = <int>[];
|
||||||
|
|
||||||
class GetPrivateKeyCommand extends SenderProtocol {
|
class GetPrivateKeyCommand extends SenderProtocol {
|
||||||
String? lockID;
|
|
||||||
String? keyID; // 钥匙ID
|
|
||||||
String? authUserID; // 钥匙授权人ID
|
|
||||||
int? nowTime;
|
|
||||||
int? needAuthor;
|
|
||||||
List<int>? publicKeyData;
|
|
||||||
|
|
||||||
GetPrivateKeyCommand(
|
GetPrivateKeyCommand(
|
||||||
{this.lockID,
|
{this.lockID,
|
||||||
this.keyID,
|
this.keyID,
|
||||||
@ -29,6 +22,12 @@ class GetPrivateKeyCommand extends SenderProtocol {
|
|||||||
this.needAuthor,
|
this.needAuthor,
|
||||||
this.publicKeyData})
|
this.publicKeyData})
|
||||||
: super(CommandType.getLockPrivateKey);
|
: super(CommandType.getLockPrivateKey);
|
||||||
|
String? lockID;
|
||||||
|
String? keyID; // 钥匙ID
|
||||||
|
String? authUserID; // 钥匙授权人ID
|
||||||
|
int? nowTime;
|
||||||
|
int? needAuthor;
|
||||||
|
List<int>? publicKeyData;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
@ -40,8 +39,8 @@ class GetPrivateKeyCommand extends SenderProtocol {
|
|||||||
@override
|
@override
|
||||||
List<int> messageDetail() {
|
List<int> messageDetail() {
|
||||||
publicKeyDataList = publicKeyData!;
|
publicKeyDataList = publicKeyData!;
|
||||||
List<int> data = [];
|
List<int> data = <int>[];
|
||||||
List<int> ebcData = [];
|
List<int> ebcData = <int>[];
|
||||||
|
|
||||||
// 指令类型
|
// 指令类型
|
||||||
final int type = commandType!.typeValue;
|
final int type = commandType!.typeValue;
|
||||||
@ -67,9 +66,6 @@ class GetPrivateKeyCommand extends SenderProtocol {
|
|||||||
data = getFixedLengthList(data, 20 - authUserIDLength);
|
data = getFixedLengthList(data, 20 - authUserIDLength);
|
||||||
|
|
||||||
//NowTime 4
|
//NowTime 4
|
||||||
// DateTime now = DateTime.now();
|
|
||||||
// int timestamp = now.millisecondsSinceEpoch;
|
|
||||||
// var d1 = 0x11223344;
|
|
||||||
data.add((nowTime! & 0xff000000) >> 24);
|
data.add((nowTime! & 0xff000000) >> 24);
|
||||||
data.add((nowTime! & 0xff0000) >> 16);
|
data.add((nowTime! & 0xff0000) >> 16);
|
||||||
data.add((nowTime! & 0xff00) >> 8);
|
data.add((nowTime! & 0xff00) >> 8);
|
||||||
@ -78,7 +74,7 @@ class GetPrivateKeyCommand extends SenderProtocol {
|
|||||||
if (needAuthor == 0) {
|
if (needAuthor == 0) {
|
||||||
data.add(0);
|
data.add(0);
|
||||||
} else {
|
} else {
|
||||||
final List<int> authCodeData = [];
|
final List<int> authCodeData = <int>[];
|
||||||
|
|
||||||
//authUserID
|
//authUserID
|
||||||
authCodeData.addAll(utf8.encode(authUserID!));
|
authCodeData.addAll(utf8.encode(authUserID!));
|
||||||
@ -87,9 +83,6 @@ class GetPrivateKeyCommand extends SenderProtocol {
|
|||||||
authCodeData.addAll(utf8.encode(keyID!));
|
authCodeData.addAll(utf8.encode(keyID!));
|
||||||
|
|
||||||
//NowTime 4
|
//NowTime 4
|
||||||
// DateTime now = DateTime.now();
|
|
||||||
// int timestamp = now.millisecondsSinceEpoch;
|
|
||||||
// var d1 = 0x11223344;
|
|
||||||
authCodeData.add((nowTime! & 0xff000000) >> 24);
|
authCodeData.add((nowTime! & 0xff000000) >> 24);
|
||||||
authCodeData.add((nowTime! & 0xff0000) >> 16);
|
authCodeData.add((nowTime! & 0xff0000) >> 16);
|
||||||
authCodeData.add((nowTime! & 0xff00) >> 8);
|
authCodeData.add((nowTime! & 0xff00) >> 8);
|
||||||
@ -98,7 +91,7 @@ class GetPrivateKeyCommand extends SenderProtocol {
|
|||||||
authCodeData.addAll(publicKeyData!);
|
authCodeData.addAll(publicKeyData!);
|
||||||
|
|
||||||
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
||||||
final authCode = crypto.md5.convert(authCodeData);
|
final crypto.Digest authCode = crypto.md5.convert(authCodeData);
|
||||||
|
|
||||||
data.add(authCode.bytes.length);
|
data.add(authCode.bytes.length);
|
||||||
data.addAll(authCode.bytes);
|
data.addAll(authCode.bytes);
|
||||||
|
|||||||
@ -10,14 +10,6 @@ import '../io_type.dart';
|
|||||||
import '../sm4Encipher/sm4.dart';
|
import '../sm4Encipher/sm4.dart';
|
||||||
|
|
||||||
class SenderGetWifiCommand extends SenderProtocol {
|
class SenderGetWifiCommand extends SenderProtocol {
|
||||||
|
|
||||||
String? keyID;
|
|
||||||
String? userID;
|
|
||||||
List<int>? token;
|
|
||||||
int? needAuthor;
|
|
||||||
List<int>? publicKey;
|
|
||||||
List<int>? privateKey;
|
|
||||||
|
|
||||||
SenderGetWifiCommand({
|
SenderGetWifiCommand({
|
||||||
this.keyID,
|
this.keyID,
|
||||||
this.userID,
|
this.userID,
|
||||||
@ -27,6 +19,12 @@ class SenderGetWifiCommand extends SenderProtocol {
|
|||||||
this.privateKey,
|
this.privateKey,
|
||||||
}) : super(CommandType.generalExtendedCommond);
|
}) : super(CommandType.generalExtendedCommond);
|
||||||
|
|
||||||
|
String? keyID;
|
||||||
|
String? userID;
|
||||||
|
List<int>? token;
|
||||||
|
int? needAuthor;
|
||||||
|
List<int>? publicKey;
|
||||||
|
List<int>? privateKey;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
@ -37,15 +35,15 @@ class SenderGetWifiCommand extends SenderProtocol {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
List<int> messageDetail() {
|
List<int> messageDetail() {
|
||||||
List<int> data = [];
|
final List<int> data = <int>[];
|
||||||
List<int> subData = [];
|
List<int> subData = <int>[];
|
||||||
List<int> ebcData = [];
|
List<int> ebcData = <int>[];
|
||||||
|
|
||||||
// 指令类型
|
// 指令类型
|
||||||
int type = commandType!.typeValue;
|
final int type = commandType!.typeValue;
|
||||||
double typeDouble = type / 256;
|
final double typeDouble = type / 256;
|
||||||
int type1 = typeDouble.toInt();
|
final int type1 = typeDouble.toInt();
|
||||||
int type2 = type % 256;
|
final int type2 = type % 256;
|
||||||
data.add(type1);
|
data.add(type1);
|
||||||
data.add(type2);
|
data.add(type2);
|
||||||
|
|
||||||
@ -53,23 +51,19 @@ class SenderGetWifiCommand extends SenderProtocol {
|
|||||||
data.add(53);
|
data.add(53);
|
||||||
|
|
||||||
// keyID 40
|
// keyID 40
|
||||||
int keyIDLength = utf8.encode(keyID!).length;
|
final int keyIDLength = utf8.encode(keyID!).length;
|
||||||
subData.addAll(utf8.encode(keyID!));
|
subData.addAll(utf8.encode(keyID!));
|
||||||
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
||||||
|
|
||||||
//userID 20
|
//userID 20
|
||||||
int userIDLength = utf8.encode(userID!).length;
|
final int userIDLength = utf8.encode(userID!).length;
|
||||||
subData.addAll(utf8.encode(userID!));
|
subData.addAll(utf8.encode(userID!));
|
||||||
subData = getFixedLengthList(subData, 20 - userIDLength);
|
subData = getFixedLengthList(subData, 20 - userIDLength);
|
||||||
|
|
||||||
// token
|
|
||||||
// subData.addAll(token!);
|
|
||||||
|
|
||||||
if(needAuthor == 0){
|
if(needAuthor == 0){
|
||||||
//AuthCodeLen 1
|
|
||||||
subData.add(0);
|
subData.add(0);
|
||||||
} else {
|
} else {
|
||||||
List<int> authCodeData = [];
|
final List<int> authCodeData = <int>[];
|
||||||
|
|
||||||
//userID
|
//userID
|
||||||
authCodeData.addAll(utf8.encode(userID!));
|
authCodeData.addAll(utf8.encode(userID!));
|
||||||
@ -83,7 +77,7 @@ class SenderGetWifiCommand extends SenderProtocol {
|
|||||||
authCodeData.addAll(publicKey!);
|
authCodeData.addAll(publicKey!);
|
||||||
|
|
||||||
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
||||||
var authCode = crypto.md5.convert(authCodeData);
|
final crypto.Digest authCode = crypto.md5.convert(authCodeData);
|
||||||
|
|
||||||
subData.add(authCode.bytes.length);
|
subData.add(authCode.bytes.length);
|
||||||
subData.addAll(authCode.bytes);
|
subData.addAll(authCode.bytes);
|
||||||
@ -93,7 +87,7 @@ class SenderGetWifiCommand extends SenderProtocol {
|
|||||||
data.addAll(subData);
|
data.addAll(subData);
|
||||||
|
|
||||||
if ((data.length % 16) != 0) {
|
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++) {
|
for (int i = 0; i < add; i++) {
|
||||||
data.add(0);
|
data.add(0);
|
||||||
}
|
}
|
||||||
@ -110,7 +104,7 @@ class SenderGetWifiReply extends Reply {
|
|||||||
SenderGetWifiReply.parseData(CommandType commandType, List<int> dataDetail)
|
SenderGetWifiReply.parseData(CommandType commandType, List<int> dataDetail)
|
||||||
: super.parseData(commandType, dataDetail) {
|
: super.parseData(commandType, dataDetail) {
|
||||||
data = dataDetail;
|
data = dataDetail;
|
||||||
int status = data[2];
|
final int status = data[2];
|
||||||
errorWithStstus(status);
|
errorWithStstus(status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,17 +10,8 @@ import '../io_tool/io_tool.dart';
|
|||||||
import '../io_type.dart';
|
import '../io_type.dart';
|
||||||
import '../sm4Encipher/sm4.dart';
|
import '../sm4Encipher/sm4.dart';
|
||||||
|
|
||||||
//TODO:开门
|
// 开门
|
||||||
class OpenLockCommand extends SenderProtocol {
|
class OpenLockCommand extends SenderProtocol {
|
||||||
String? lockID;
|
|
||||||
String? userID;
|
|
||||||
int? openMode;
|
|
||||||
int? openTime;
|
|
||||||
String? onlineToken;
|
|
||||||
List<int>? token;
|
|
||||||
int? needAuthor;
|
|
||||||
List<int>? signKey;
|
|
||||||
List<int>? privateKey;
|
|
||||||
OpenLockCommand({
|
OpenLockCommand({
|
||||||
this.lockID,
|
this.lockID,
|
||||||
this.userID,
|
this.userID,
|
||||||
@ -32,6 +23,15 @@ class OpenLockCommand extends SenderProtocol {
|
|||||||
this.signKey,
|
this.signKey,
|
||||||
this.privateKey
|
this.privateKey
|
||||||
}) : super(CommandType.openLock);
|
}) : super(CommandType.openLock);
|
||||||
|
String? lockID;
|
||||||
|
String? userID;
|
||||||
|
int? openMode;
|
||||||
|
int? openTime;
|
||||||
|
String? onlineToken;
|
||||||
|
List<int>? token;
|
||||||
|
int? needAuthor;
|
||||||
|
List<int>? signKey;
|
||||||
|
List<int>? privateKey;
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -44,8 +44,8 @@ class OpenLockCommand extends SenderProtocol {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
List<int> messageDetail() {
|
List<int> messageDetail() {
|
||||||
List<int> data = [];
|
List<int> data = <int>[];
|
||||||
List<int> ebcData = [];
|
List<int> ebcData = <int>[];
|
||||||
|
|
||||||
// 指令类型
|
// 指令类型
|
||||||
final int type = commandType!.typeValue;
|
final int type = commandType!.typeValue;
|
||||||
@ -84,7 +84,7 @@ class OpenLockCommand extends SenderProtocol {
|
|||||||
//AuthCodeLen 1
|
//AuthCodeLen 1
|
||||||
data.add(0);
|
data.add(0);
|
||||||
} else {
|
} else {
|
||||||
final List<int> authCodeData = [];
|
final List<int> authCodeData = <int>[];
|
||||||
//KeyID
|
//KeyID
|
||||||
authCodeData.addAll(utf8.encode(lockID!));
|
authCodeData.addAll(utf8.encode(lockID!));
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ class OpenLockCommand extends SenderProtocol {
|
|||||||
authCodeData.addAll(signKey!);
|
authCodeData.addAll(signKey!);
|
||||||
|
|
||||||
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
||||||
final authCode = crypto.md5.convert(authCodeData);
|
final crypto.Digest authCode = crypto.md5.convert(authCodeData);
|
||||||
|
|
||||||
data.add(authCode.bytes.length);
|
data.add(authCode.bytes.length);
|
||||||
data.addAll(authCode.bytes);
|
data.addAll(authCode.bytes);
|
||||||
|
|||||||
@ -1,32 +1,17 @@
|
|||||||
|
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:typed_data';
|
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_reply.dart';
|
||||||
import '../io_sender.dart';
|
import '../io_sender.dart';
|
||||||
|
import '../io_tool/io_tool.dart';
|
||||||
import '../io_type.dart';
|
import '../io_type.dart';
|
||||||
import 'package:crypto/crypto.dart' as crypto;
|
import '../sm4Encipher/sm4.dart';
|
||||||
|
|
||||||
//oat升级
|
//oat升级
|
||||||
class OTAUpgradeCommand extends SenderProtocol {
|
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<int>? signKey;
|
|
||||||
List<int>? privateKey;
|
|
||||||
List<int>? token;
|
|
||||||
bool encrypt;
|
|
||||||
|
|
||||||
OTAUpgradeCommand(
|
OTAUpgradeCommand(
|
||||||
{this.lockID,
|
{this.lockID,
|
||||||
@ -44,6 +29,20 @@ class OTAUpgradeCommand extends SenderProtocol {
|
|||||||
this.token,
|
this.token,
|
||||||
this.encrypt = true})
|
this.encrypt = true})
|
||||||
: super(CommandType.startOATUpgrade);
|
: super(CommandType.startOATUpgrade);
|
||||||
|
String? lockID;
|
||||||
|
String? userID;
|
||||||
|
String? keyID;
|
||||||
|
int? platform;
|
||||||
|
int? product;
|
||||||
|
String? hwVersion;
|
||||||
|
String? fwVersion;
|
||||||
|
int? fwSize;
|
||||||
|
String? fwMD5;
|
||||||
|
int? needAuthor;
|
||||||
|
List<int>? signKey;
|
||||||
|
List<int>? privateKey;
|
||||||
|
List<int>? token;
|
||||||
|
bool encrypt;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
@ -93,10 +92,6 @@ class OTAUpgradeCommand extends SenderProtocol {
|
|||||||
data.add(platform1);
|
data.add(platform1);
|
||||||
|
|
||||||
//product 2
|
//product 2
|
||||||
// int product0 = (product! & 0xFF00) >> 8;
|
|
||||||
// int product1 = product! & 0xFF;
|
|
||||||
// data.add(product0);
|
|
||||||
// data.add(product1);
|
|
||||||
data.addAll(<int>[0, 1]); //先默认是 01
|
data.addAll(<int>[0, 1]); //先默认是 01
|
||||||
|
|
||||||
//HwVersion 20
|
//HwVersion 20
|
||||||
@ -170,8 +165,6 @@ class OTAUpgradeCommand extends SenderProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class OTAUpgradeReply extends Reply {
|
class OTAUpgradeReply extends Reply {
|
||||||
List<int> token = <int>[];
|
|
||||||
|
|
||||||
OTAUpgradeReply.parseData(CommandType commandType, List<int> dataDetail)
|
OTAUpgradeReply.parseData(CommandType commandType, List<int> dataDetail)
|
||||||
: super.parseData(commandType, dataDetail) {
|
: super.parseData(commandType, dataDetail) {
|
||||||
data = dataDetail;
|
data = dataDetail;
|
||||||
@ -179,4 +172,5 @@ class OTAUpgradeReply extends Reply {
|
|||||||
status = data[6];
|
status = data[6];
|
||||||
errorWithStstus(status);
|
errorWithStstus(status);
|
||||||
}
|
}
|
||||||
|
List<int> token = <int>[];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,26 +1,20 @@
|
|||||||
import 'dart:convert';
|
|
||||||
import 'dart:typed_data';
|
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_reply.dart';
|
||||||
import '../io_sender.dart';
|
import '../io_sender.dart';
|
||||||
import '../io_type.dart';
|
import '../io_type.dart';
|
||||||
import 'package:crypto/crypto.dart' as crypto;
|
|
||||||
|
|
||||||
//oat升级
|
//oat升级
|
||||||
class ProcessOtaUpgradeCommand extends SenderProtocol {
|
class ProcessOtaUpgradeCommand extends SenderProtocol {
|
||||||
int? index;
|
|
||||||
int? size;
|
|
||||||
List<int>? data;
|
|
||||||
|
|
||||||
ProcessOtaUpgradeCommand({
|
ProcessOtaUpgradeCommand({
|
||||||
this.index,
|
this.index,
|
||||||
this.size,
|
this.size,
|
||||||
this.data,
|
this.data,
|
||||||
}) : super(CommandType.processOTAUpgrade);
|
}) : super(CommandType.processOTAUpgrade);
|
||||||
|
int? index;
|
||||||
|
int? size;
|
||||||
|
List<int>? data;
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -30,26 +24,26 @@ class ProcessOtaUpgradeCommand extends SenderProtocol {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
List<int> messageDetail() {
|
List<int> messageDetail() {
|
||||||
List<int> data = [];
|
final List<int> data = [];
|
||||||
|
|
||||||
// 指令类型
|
// 指令类型
|
||||||
int type = commandType!.typeValue;
|
final int type = commandType!.typeValue;
|
||||||
double typeDouble = type / 256;
|
final double typeDouble = type / 256;
|
||||||
int type1 = typeDouble.toInt();
|
final int type1 = typeDouble.toInt();
|
||||||
int type2 = type % 256;
|
final int type2 = type % 256;
|
||||||
data.add(type1);
|
data.add(type1);
|
||||||
data.add(type2);
|
data.add(type2);
|
||||||
|
|
||||||
//index 2
|
//index 2
|
||||||
ByteData indexBytes = ByteData(2); // 创建一个长度为4的字节数据
|
final ByteData indexBytes = ByteData(2); // 创建一个长度为4的字节数据
|
||||||
indexBytes.setInt16(0, index!);
|
indexBytes.setInt16(0, index!);
|
||||||
List<int> indexList = indexBytes.buffer.asUint8List();
|
final List<int> indexList = indexBytes.buffer.asUint8List();
|
||||||
data.addAll(indexList);
|
data.addAll(indexList);
|
||||||
|
|
||||||
//size 2
|
//size 2
|
||||||
ByteData bytes = ByteData(2); // 创建一个长度为4的字节数据
|
final ByteData bytes = ByteData(2); // 创建一个长度为4的字节数据
|
||||||
bytes.setInt16(0, size!);
|
bytes.setInt16(0, size!);
|
||||||
List<int> byteList = bytes.buffer.asUint8List();
|
final List<int> byteList = bytes.buffer.asUint8List();
|
||||||
data.addAll(byteList);
|
data.addAll(byteList);
|
||||||
|
|
||||||
data.addAll(this.data!);
|
data.addAll(this.data!);
|
||||||
|
|||||||
@ -1,24 +1,16 @@
|
|||||||
//TODO:查询人脸状态
|
|
||||||
|
// 查询人脸状态
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:crypto/crypto.dart' as crypto;
|
||||||
|
|
||||||
import '../io_reply.dart';
|
import '../io_reply.dart';
|
||||||
import '../io_sender.dart';
|
import '../io_sender.dart';
|
||||||
import '../io_tool/io_tool.dart';
|
import '../io_tool/io_tool.dart';
|
||||||
import '../io_type.dart';
|
import '../io_type.dart';
|
||||||
import '../sm4Encipher/sm4.dart';
|
import '../sm4Encipher/sm4.dart';
|
||||||
import 'package:crypto/crypto.dart' as crypto;
|
|
||||||
|
|
||||||
class SenderQueryingFaceStatusCommand extends SenderProtocol {
|
class SenderQueryingFaceStatusCommand extends SenderProtocol {
|
||||||
String? keyID;
|
|
||||||
String? userID;
|
|
||||||
int? role;
|
|
||||||
int? faceCount;
|
|
||||||
int? faceNo;
|
|
||||||
List<int>? token;
|
|
||||||
int? needAuthor;
|
|
||||||
List<int>? publicKey;
|
|
||||||
List<int>? privateKey;
|
|
||||||
|
|
||||||
SenderQueryingFaceStatusCommand({
|
SenderQueryingFaceStatusCommand({
|
||||||
this.keyID,
|
this.keyID,
|
||||||
@ -31,6 +23,15 @@ class SenderQueryingFaceStatusCommand extends SenderProtocol {
|
|||||||
this.publicKey,
|
this.publicKey,
|
||||||
this.privateKey,
|
this.privateKey,
|
||||||
}) : super(CommandType.generalExtendedCommond);
|
}) : super(CommandType.generalExtendedCommond);
|
||||||
|
String? keyID;
|
||||||
|
String? userID;
|
||||||
|
int? role;
|
||||||
|
int? faceCount;
|
||||||
|
int? faceNo;
|
||||||
|
List<int>? token;
|
||||||
|
int? needAuthor;
|
||||||
|
List<int>? publicKey;
|
||||||
|
List<int>? privateKey;
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -42,15 +43,15 @@ class SenderQueryingFaceStatusCommand extends SenderProtocol {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
List<int> messageDetail() {
|
List<int> messageDetail() {
|
||||||
List<int> data = [];
|
final List<int> data = <int>[];
|
||||||
List<int> subData = [];
|
List<int> subData = <int>[];
|
||||||
List<int> ebcData = [];
|
List<int> ebcData = <int>[];
|
||||||
|
|
||||||
// 指令类型
|
// 指令类型
|
||||||
int type = commandType!.typeValue;
|
final int type = commandType!.typeValue;
|
||||||
double typeDouble = type / 256;
|
final double typeDouble = type / 256;
|
||||||
int type1 = typeDouble.toInt();
|
final int type1 = typeDouble.toInt();
|
||||||
int type2 = type % 256;
|
final int type2 = type % 256;
|
||||||
data.add(type1);
|
data.add(type1);
|
||||||
data.add(type2);
|
data.add(type2);
|
||||||
|
|
||||||
@ -58,12 +59,12 @@ class SenderQueryingFaceStatusCommand extends SenderProtocol {
|
|||||||
data.add(80);
|
data.add(80);
|
||||||
|
|
||||||
// keyID 40
|
// keyID 40
|
||||||
int keyIDLength = utf8.encode(keyID!).length;
|
final int keyIDLength = utf8.encode(keyID!).length;
|
||||||
subData.addAll(utf8.encode(keyID!));
|
subData.addAll(utf8.encode(keyID!));
|
||||||
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
||||||
|
|
||||||
//userID 20
|
//userID 20
|
||||||
int userIDLength = utf8.encode(userID!).length;
|
final int userIDLength = utf8.encode(userID!).length;
|
||||||
subData.addAll(utf8.encode(userID!));
|
subData.addAll(utf8.encode(userID!));
|
||||||
subData = getFixedLengthList(subData, 20 - userIDLength);
|
subData = getFixedLengthList(subData, 20 - userIDLength);
|
||||||
|
|
||||||
@ -80,7 +81,7 @@ class SenderQueryingFaceStatusCommand extends SenderProtocol {
|
|||||||
//AuthCodeLen 1
|
//AuthCodeLen 1
|
||||||
subData.add(0);
|
subData.add(0);
|
||||||
} else {
|
} else {
|
||||||
List<int> authCodeData = [];
|
final List<int> authCodeData = <int>[];
|
||||||
|
|
||||||
//authUserID
|
//authUserID
|
||||||
authCodeData.addAll(utf8.encode(userID!));
|
authCodeData.addAll(utf8.encode(userID!));
|
||||||
@ -94,7 +95,7 @@ class SenderQueryingFaceStatusCommand extends SenderProtocol {
|
|||||||
authCodeData.addAll(publicKey!);
|
authCodeData.addAll(publicKey!);
|
||||||
|
|
||||||
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
||||||
var authCode = crypto.md5.convert(authCodeData);
|
final crypto.Digest authCode = crypto.md5.convert(authCodeData);
|
||||||
|
|
||||||
subData.add(authCode.bytes.length);
|
subData.add(authCode.bytes.length);
|
||||||
subData.addAll(authCode.bytes);
|
subData.addAll(authCode.bytes);
|
||||||
@ -104,7 +105,7 @@ class SenderQueryingFaceStatusCommand extends SenderProtocol {
|
|||||||
data.addAll(subData);
|
data.addAll(subData);
|
||||||
|
|
||||||
if ((data.length % 16) != 0) {
|
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++) {
|
for (int i = 0; i < add; i++) {
|
||||||
data.add(0);
|
data.add(0);
|
||||||
}
|
}
|
||||||
@ -121,7 +122,7 @@ class SenderQueryingFaceStatusReply extends Reply {
|
|||||||
CommandType commandType, List<int> dataDetail)
|
CommandType commandType, List<int> dataDetail)
|
||||||
: super.parseData(commandType, dataDetail) {
|
: super.parseData(commandType, dataDetail) {
|
||||||
data = dataDetail;
|
data = dataDetail;
|
||||||
int status = data[2];
|
final int status = data[2];
|
||||||
errorWithStstus(status);
|
errorWithStstus(status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,26 +1,17 @@
|
|||||||
|
|
||||||
//TODO:查询指纹状态
|
// 查询指纹状态
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:crypto/crypto.dart' as crypto;
|
||||||
|
|
||||||
import '../io_reply.dart';
|
import '../io_reply.dart';
|
||||||
import '../io_sender.dart';
|
import '../io_sender.dart';
|
||||||
import '../io_tool/io_tool.dart';
|
import '../io_tool/io_tool.dart';
|
||||||
import '../io_type.dart';
|
import '../io_type.dart';
|
||||||
import '../sm4Encipher/sm4.dart';
|
import '../sm4Encipher/sm4.dart';
|
||||||
import 'package:crypto/crypto.dart' as crypto;
|
|
||||||
|
|
||||||
class SenderQueryingFingerprintStatusCommand extends SenderProtocol {
|
class SenderQueryingFingerprintStatusCommand extends SenderProtocol {
|
||||||
|
|
||||||
String? keyID;
|
|
||||||
String? userID;
|
|
||||||
int? role;
|
|
||||||
int? fingerCount;
|
|
||||||
int? fingerNo;
|
|
||||||
List<int>? token;
|
|
||||||
int? needAuthor;
|
|
||||||
List<int>? publicKey;
|
|
||||||
List<int>? privateKey;
|
|
||||||
|
|
||||||
SenderQueryingFingerprintStatusCommand({
|
SenderQueryingFingerprintStatusCommand({
|
||||||
this.keyID,
|
this.keyID,
|
||||||
this.userID,
|
this.userID,
|
||||||
@ -33,6 +24,15 @@ class SenderQueryingFingerprintStatusCommand extends SenderProtocol {
|
|||||||
this.privateKey,
|
this.privateKey,
|
||||||
}) : super(CommandType.generalExtendedCommond);
|
}) : super(CommandType.generalExtendedCommond);
|
||||||
|
|
||||||
|
String? keyID;
|
||||||
|
String? userID;
|
||||||
|
int? role;
|
||||||
|
int? fingerCount;
|
||||||
|
int? fingerNo;
|
||||||
|
List<int>? token;
|
||||||
|
int? needAuthor;
|
||||||
|
List<int>? publicKey;
|
||||||
|
List<int>? privateKey;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
@ -44,15 +44,15 @@ class SenderQueryingFingerprintStatusCommand extends SenderProtocol {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
List<int> messageDetail() {
|
List<int> messageDetail() {
|
||||||
List<int> data = [];
|
final List<int> data = <int>[];
|
||||||
List<int> subData = [];
|
List<int> subData = <int>[];
|
||||||
List<int> ebcData = [];
|
List<int> ebcData = <int>[];
|
||||||
|
|
||||||
// 指令类型
|
// 指令类型
|
||||||
int type = commandType!.typeValue;
|
final int type = commandType!.typeValue;
|
||||||
double typeDouble = type / 256;
|
final double typeDouble = type / 256;
|
||||||
int type1 = typeDouble.toInt();
|
final int type1 = typeDouble.toInt();
|
||||||
int type2 = type % 256;
|
final int type2 = type % 256;
|
||||||
data.add(type1);
|
data.add(type1);
|
||||||
data.add(type2);
|
data.add(type2);
|
||||||
|
|
||||||
@ -60,12 +60,12 @@ class SenderQueryingFingerprintStatusCommand extends SenderProtocol {
|
|||||||
data.add(30);
|
data.add(30);
|
||||||
|
|
||||||
// keyID 40
|
// keyID 40
|
||||||
int keyIDLength = utf8.encode(keyID!).length;
|
final int keyIDLength = utf8.encode(keyID!).length;
|
||||||
subData.addAll(utf8.encode(keyID!));
|
subData.addAll(utf8.encode(keyID!));
|
||||||
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
||||||
|
|
||||||
//userID 20
|
//userID 20
|
||||||
int userIDLength = utf8.encode(userID!).length;
|
final int userIDLength = utf8.encode(userID!).length;
|
||||||
subData.addAll(utf8.encode(userID!));
|
subData.addAll(utf8.encode(userID!));
|
||||||
subData = getFixedLengthList(subData, 20 - userIDLength);
|
subData = getFixedLengthList(subData, 20 - userIDLength);
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ class SenderQueryingFingerprintStatusCommand extends SenderProtocol {
|
|||||||
//AuthCodeLen 1
|
//AuthCodeLen 1
|
||||||
subData.add(0);
|
subData.add(0);
|
||||||
} else {
|
} else {
|
||||||
List<int> authCodeData = [];
|
final List<int> authCodeData = <int>[];
|
||||||
|
|
||||||
//authUserID
|
//authUserID
|
||||||
authCodeData.addAll(utf8.encode(userID!));
|
authCodeData.addAll(utf8.encode(userID!));
|
||||||
@ -96,7 +96,7 @@ class SenderQueryingFingerprintStatusCommand extends SenderProtocol {
|
|||||||
authCodeData.addAll(publicKey!);
|
authCodeData.addAll(publicKey!);
|
||||||
|
|
||||||
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
||||||
var authCode = crypto.md5.convert(authCodeData);
|
final crypto.Digest authCode = crypto.md5.convert(authCodeData);
|
||||||
|
|
||||||
subData.add(authCode.bytes.length);
|
subData.add(authCode.bytes.length);
|
||||||
subData.addAll(authCode.bytes);
|
subData.addAll(authCode.bytes);
|
||||||
@ -106,7 +106,7 @@ class SenderQueryingFingerprintStatusCommand extends SenderProtocol {
|
|||||||
data.addAll(subData);
|
data.addAll(subData);
|
||||||
|
|
||||||
if ((data.length % 16) != 0) {
|
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++) {
|
for (int i = 0; i < add; i++) {
|
||||||
data.add(0);
|
data.add(0);
|
||||||
}
|
}
|
||||||
@ -123,7 +123,7 @@ class SenderQueryingFingerprintStatusReply extends Reply {
|
|||||||
SenderQueryingFingerprintStatusReply.parseData(CommandType commandType, List<int> dataDetail)
|
SenderQueryingFingerprintStatusReply.parseData(CommandType commandType, List<int> dataDetail)
|
||||||
: super.parseData(commandType, dataDetail) {
|
: super.parseData(commandType, dataDetail) {
|
||||||
data = dataDetail;
|
data = dataDetail;
|
||||||
int status = data[2];
|
final int status = data[2];
|
||||||
errorWithStstus(status);
|
errorWithStstus(status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -8,19 +8,8 @@ import '../io_sender.dart';
|
|||||||
import '../io_type.dart';
|
import '../io_type.dart';
|
||||||
import 'package:crypto/crypto.dart' as crypto;
|
import 'package:crypto/crypto.dart' as crypto;
|
||||||
|
|
||||||
///TODO:读取管理员密码
|
/// 读取管理员密码
|
||||||
class SenderReadAdminPasswordCommand extends SenderProtocol {
|
class SenderReadAdminPasswordCommand extends SenderProtocol {
|
||||||
|
|
||||||
String? keyID;
|
|
||||||
String? userID;
|
|
||||||
int? role;
|
|
||||||
int? pwdNum;
|
|
||||||
int? pwdNo;
|
|
||||||
List<int>? token;
|
|
||||||
int? needAuthor;
|
|
||||||
List<int>? publicKey;
|
|
||||||
List<int>? privateKey;
|
|
||||||
|
|
||||||
SenderReadAdminPasswordCommand({
|
SenderReadAdminPasswordCommand({
|
||||||
this.keyID,
|
this.keyID,
|
||||||
this.userID,
|
this.userID,
|
||||||
@ -33,6 +22,15 @@ class SenderReadAdminPasswordCommand extends SenderProtocol {
|
|||||||
this.privateKey,
|
this.privateKey,
|
||||||
}) : super(CommandType.generalExtendedCommond);
|
}) : super(CommandType.generalExtendedCommond);
|
||||||
|
|
||||||
|
String? keyID;
|
||||||
|
String? userID;
|
||||||
|
int? role;
|
||||||
|
int? pwdNum;
|
||||||
|
int? pwdNo;
|
||||||
|
List<int>? token;
|
||||||
|
int? needAuthor;
|
||||||
|
List<int>? publicKey;
|
||||||
|
List<int>? privateKey;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
@ -44,15 +42,15 @@ class SenderReadAdminPasswordCommand extends SenderProtocol {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
List<int> messageDetail() {
|
List<int> messageDetail() {
|
||||||
List<int> data = [];
|
final List<int> data = <int>[];
|
||||||
List<int> subData = [];
|
List<int> subData = <int>[];
|
||||||
List<int> ebcData = [];
|
List<int> ebcData = <int>[];
|
||||||
|
|
||||||
// 指令类型
|
// 指令类型
|
||||||
int type = commandType!.typeValue;
|
final int type = commandType!.typeValue;
|
||||||
double typeDouble = type / 256;
|
final double typeDouble = type / 256;
|
||||||
int type1 = typeDouble.toInt();
|
final int type1 = typeDouble.toInt();
|
||||||
int type2 = type % 256;
|
final int type2 = type % 256;
|
||||||
data.add(type1);
|
data.add(type1);
|
||||||
data.add(type2);
|
data.add(type2);
|
||||||
|
|
||||||
@ -60,12 +58,12 @@ class SenderReadAdminPasswordCommand extends SenderProtocol {
|
|||||||
data.add(74);
|
data.add(74);
|
||||||
|
|
||||||
// keyID 40
|
// keyID 40
|
||||||
int keyIDLength = utf8.encode(keyID!).length;
|
final int keyIDLength = utf8.encode(keyID!).length;
|
||||||
subData.addAll(utf8.encode(keyID!));
|
subData.addAll(utf8.encode(keyID!));
|
||||||
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
||||||
|
|
||||||
//userID 20
|
//userID 20
|
||||||
int userIDLength = utf8.encode(userID!).length;
|
final int userIDLength = utf8.encode(userID!).length;
|
||||||
subData.addAll(utf8.encode(userID!));
|
subData.addAll(utf8.encode(userID!));
|
||||||
subData = getFixedLengthList(subData, 20 - userIDLength);
|
subData = getFixedLengthList(subData, 20 - userIDLength);
|
||||||
|
|
||||||
@ -82,7 +80,7 @@ class SenderReadAdminPasswordCommand extends SenderProtocol {
|
|||||||
//AuthCodeLen 1
|
//AuthCodeLen 1
|
||||||
subData.add(0);
|
subData.add(0);
|
||||||
} else {
|
} else {
|
||||||
List<int> authCodeData = [];
|
final List<int> authCodeData = <int>[];
|
||||||
|
|
||||||
//authUserID
|
//authUserID
|
||||||
authCodeData.addAll(utf8.encode(userID!));
|
authCodeData.addAll(utf8.encode(userID!));
|
||||||
@ -96,7 +94,7 @@ class SenderReadAdminPasswordCommand extends SenderProtocol {
|
|||||||
authCodeData.addAll(publicKey!);
|
authCodeData.addAll(publicKey!);
|
||||||
|
|
||||||
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
||||||
var authCode = crypto.md5.convert(authCodeData);
|
final crypto.Digest authCode = crypto.md5.convert(authCodeData);
|
||||||
|
|
||||||
subData.add(authCode.bytes.length);
|
subData.add(authCode.bytes.length);
|
||||||
subData.addAll(authCode.bytes);
|
subData.addAll(authCode.bytes);
|
||||||
@ -106,7 +104,7 @@ class SenderReadAdminPasswordCommand extends SenderProtocol {
|
|||||||
data.addAll(subData);
|
data.addAll(subData);
|
||||||
|
|
||||||
if ((data.length % 16) != 0) {
|
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++) {
|
for (int i = 0; i < add; i++) {
|
||||||
data.add(0);
|
data.add(0);
|
||||||
}
|
}
|
||||||
@ -124,7 +122,7 @@ class SenderReadAdminPasswordReply extends Reply {
|
|||||||
: super.parseData(commandType, dataDetail) {
|
: super.parseData(commandType, dataDetail) {
|
||||||
data = dataDetail;
|
data = dataDetail;
|
||||||
|
|
||||||
int status = data[2];
|
final int status = data[2];
|
||||||
errorWithStstus(status);
|
errorWithStstus(status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,17 +12,8 @@ import 'package:crypto/crypto.dart' as crypto;
|
|||||||
|
|
||||||
import '../sm4Encipher/sm4.dart';
|
import '../sm4Encipher/sm4.dart';
|
||||||
|
|
||||||
///TODO:读取支持功能(不带参数)启用/禁用
|
/// 读取支持功能(不带参数)启用/禁用
|
||||||
class ReadSupportFunctionsNoParametersCommand extends SenderProtocol {
|
class ReadSupportFunctionsNoParametersCommand extends SenderProtocol {
|
||||||
|
|
||||||
String? keyID;
|
|
||||||
String? userID;
|
|
||||||
int? featureBit;
|
|
||||||
List<int>? token;
|
|
||||||
int? needAuthor;
|
|
||||||
List<int>? publicKey;
|
|
||||||
List<int>? privateKey;
|
|
||||||
|
|
||||||
ReadSupportFunctionsNoParametersCommand({
|
ReadSupportFunctionsNoParametersCommand({
|
||||||
this.keyID,
|
this.keyID,
|
||||||
this.userID,
|
this.userID,
|
||||||
@ -33,6 +24,13 @@ class ReadSupportFunctionsNoParametersCommand extends SenderProtocol {
|
|||||||
this.privateKey,
|
this.privateKey,
|
||||||
}) : super(CommandType.generalExtendedCommond);
|
}) : super(CommandType.generalExtendedCommond);
|
||||||
|
|
||||||
|
String? keyID;
|
||||||
|
String? userID;
|
||||||
|
int? featureBit;
|
||||||
|
List<int>? token;
|
||||||
|
int? needAuthor;
|
||||||
|
List<int>? publicKey;
|
||||||
|
List<int>? privateKey;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
@ -44,15 +42,15 @@ class ReadSupportFunctionsNoParametersCommand extends SenderProtocol {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
List<int> messageDetail() {
|
List<int> messageDetail() {
|
||||||
List<int> data = [];
|
final List<int> data = <int>[];
|
||||||
List<int> subData = [];
|
List<int> subData = <int>[];
|
||||||
List<int> ebcData = [];
|
List<int> ebcData = <int>[];
|
||||||
|
|
||||||
// 指令类型
|
// 指令类型
|
||||||
int type = commandType!.typeValue;
|
final int type = commandType!.typeValue;
|
||||||
double typeDouble = type / 256;
|
final double typeDouble = type / 256;
|
||||||
int type1 = typeDouble.toInt();
|
final int type1 = typeDouble.toInt();
|
||||||
int type2 = type % 256;
|
final int type2 = type % 256;
|
||||||
data.add(type1);
|
data.add(type1);
|
||||||
data.add(type2);
|
data.add(type2);
|
||||||
|
|
||||||
@ -60,12 +58,12 @@ class ReadSupportFunctionsNoParametersCommand extends SenderProtocol {
|
|||||||
data.add(71);
|
data.add(71);
|
||||||
|
|
||||||
// keyID 40
|
// keyID 40
|
||||||
int keyIDLength = utf8.encode(keyID!).length;
|
final int keyIDLength = utf8.encode(keyID!).length;
|
||||||
subData.addAll(utf8.encode(keyID!));
|
subData.addAll(utf8.encode(keyID!));
|
||||||
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
||||||
|
|
||||||
//userID 20
|
//userID 20
|
||||||
int userIDLength = utf8.encode(userID!).length;
|
final int userIDLength = utf8.encode(userID!).length;
|
||||||
subData.addAll(utf8.encode(userID!));
|
subData.addAll(utf8.encode(userID!));
|
||||||
subData = getFixedLengthList(subData, 20 - userIDLength);
|
subData = getFixedLengthList(subData, 20 - userIDLength);
|
||||||
|
|
||||||
@ -76,7 +74,7 @@ class ReadSupportFunctionsNoParametersCommand extends SenderProtocol {
|
|||||||
//AuthCodeLen 1
|
//AuthCodeLen 1
|
||||||
subData.add(0);
|
subData.add(0);
|
||||||
} else {
|
} else {
|
||||||
List<int> authCodeData = [];
|
final List<int> authCodeData = <int>[];
|
||||||
|
|
||||||
//authUserID
|
//authUserID
|
||||||
authCodeData.addAll(utf8.encode(userID!));
|
authCodeData.addAll(utf8.encode(userID!));
|
||||||
@ -90,7 +88,7 @@ class ReadSupportFunctionsNoParametersCommand extends SenderProtocol {
|
|||||||
authCodeData.addAll(publicKey!);
|
authCodeData.addAll(publicKey!);
|
||||||
|
|
||||||
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
||||||
var authCode = crypto.md5.convert(authCodeData);
|
final crypto.Digest authCode = crypto.md5.convert(authCodeData);
|
||||||
|
|
||||||
subData.add(authCode.bytes.length);
|
subData.add(authCode.bytes.length);
|
||||||
subData.addAll(authCode.bytes);
|
subData.addAll(authCode.bytes);
|
||||||
@ -100,7 +98,7 @@ class ReadSupportFunctionsNoParametersCommand extends SenderProtocol {
|
|||||||
data.addAll(subData);
|
data.addAll(subData);
|
||||||
|
|
||||||
if ((data.length % 16) != 0) {
|
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++) {
|
for (int i = 0; i < add; i++) {
|
||||||
data.add(0);
|
data.add(0);
|
||||||
}
|
}
|
||||||
@ -117,7 +115,7 @@ class ReadSupportFunctionsNoParametersReply extends Reply {
|
|||||||
ReadSupportFunctionsNoParametersReply.parseData(CommandType commandType, List<int> dataDetail)
|
ReadSupportFunctionsNoParametersReply.parseData(CommandType commandType, List<int> dataDetail)
|
||||||
: super.parseData(commandType, dataDetail) {
|
: super.parseData(commandType, dataDetail) {
|
||||||
data = dataDetail;
|
data = dataDetail;
|
||||||
int status = data[2];
|
final int status = data[2];
|
||||||
errorWithStstus(status);
|
errorWithStstus(status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -12,17 +12,8 @@ import 'package:crypto/crypto.dart' as crypto;
|
|||||||
|
|
||||||
import '../sm4Encipher/sm4.dart';
|
import '../sm4Encipher/sm4.dart';
|
||||||
|
|
||||||
///TODO:读取支持功能(带参数)启用/禁用
|
// 读取支持功能(带参数)启用/禁用
|
||||||
class ReadSupportFunctionsWithParametersCommand extends SenderProtocol {
|
class ReadSupportFunctionsWithParametersCommand extends SenderProtocol {
|
||||||
|
|
||||||
String? keyID;
|
|
||||||
String? userID;
|
|
||||||
int? featureBit;
|
|
||||||
List<int>? token;
|
|
||||||
int? needAuthor;
|
|
||||||
List<int>? publicKey;
|
|
||||||
List<int>? privateKey;
|
|
||||||
|
|
||||||
ReadSupportFunctionsWithParametersCommand({
|
ReadSupportFunctionsWithParametersCommand({
|
||||||
this.keyID,
|
this.keyID,
|
||||||
this.userID,
|
this.userID,
|
||||||
@ -33,6 +24,13 @@ class ReadSupportFunctionsWithParametersCommand extends SenderProtocol {
|
|||||||
this.privateKey,
|
this.privateKey,
|
||||||
}) : super(CommandType.generalExtendedCommond);
|
}) : super(CommandType.generalExtendedCommond);
|
||||||
|
|
||||||
|
String? keyID;
|
||||||
|
String? userID;
|
||||||
|
int? featureBit;
|
||||||
|
List<int>? token;
|
||||||
|
int? needAuthor;
|
||||||
|
List<int>? publicKey;
|
||||||
|
List<int>? privateKey;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
@ -44,15 +42,15 @@ class ReadSupportFunctionsWithParametersCommand extends SenderProtocol {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
List<int> messageDetail() {
|
List<int> messageDetail() {
|
||||||
List<int> data = [];
|
final List<int> data = <int>[];
|
||||||
List<int> subData = [];
|
List<int> subData = <int>[];
|
||||||
List<int> ebcData = [];
|
List<int> ebcData = <int>[];
|
||||||
|
|
||||||
// 指令类型
|
// 指令类型
|
||||||
int type = commandType!.typeValue;
|
final int type = commandType!.typeValue;
|
||||||
double typeDouble = type / 256;
|
final double typeDouble = type / 256;
|
||||||
int type1 = typeDouble.toInt();
|
final int type1 = typeDouble.toInt();
|
||||||
int type2 = type % 256;
|
final int type2 = type % 256;
|
||||||
data.add(type1);
|
data.add(type1);
|
||||||
data.add(type2);
|
data.add(type2);
|
||||||
|
|
||||||
@ -60,12 +58,12 @@ class ReadSupportFunctionsWithParametersCommand extends SenderProtocol {
|
|||||||
data.add(73);
|
data.add(73);
|
||||||
|
|
||||||
// keyID 40
|
// keyID 40
|
||||||
int keyIDLength = utf8.encode(keyID!).length;
|
final int keyIDLength = utf8.encode(keyID!).length;
|
||||||
subData.addAll(utf8.encode(keyID!));
|
subData.addAll(utf8.encode(keyID!));
|
||||||
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
||||||
|
|
||||||
//userID 20
|
//userID 20
|
||||||
int userIDLength = utf8.encode(userID!).length;
|
final int userIDLength = utf8.encode(userID!).length;
|
||||||
subData.addAll(utf8.encode(userID!));
|
subData.addAll(utf8.encode(userID!));
|
||||||
subData = getFixedLengthList(subData, 20 - userIDLength);
|
subData = getFixedLengthList(subData, 20 - userIDLength);
|
||||||
|
|
||||||
@ -76,7 +74,7 @@ class ReadSupportFunctionsWithParametersCommand extends SenderProtocol {
|
|||||||
//AuthCodeLen 1
|
//AuthCodeLen 1
|
||||||
subData.add(0);
|
subData.add(0);
|
||||||
} else {
|
} else {
|
||||||
List<int> authCodeData = [];
|
final List<int> authCodeData = <int>[];
|
||||||
|
|
||||||
//authUserID
|
//authUserID
|
||||||
authCodeData.addAll(utf8.encode(userID!));
|
authCodeData.addAll(utf8.encode(userID!));
|
||||||
@ -90,7 +88,7 @@ class ReadSupportFunctionsWithParametersCommand extends SenderProtocol {
|
|||||||
authCodeData.addAll(publicKey!);
|
authCodeData.addAll(publicKey!);
|
||||||
|
|
||||||
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
||||||
var authCode = crypto.md5.convert(authCodeData);
|
final crypto.Digest authCode = crypto.md5.convert(authCodeData);
|
||||||
|
|
||||||
subData.add(authCode.bytes.length);
|
subData.add(authCode.bytes.length);
|
||||||
subData.addAll(authCode.bytes);
|
subData.addAll(authCode.bytes);
|
||||||
@ -100,7 +98,7 @@ class ReadSupportFunctionsWithParametersCommand extends SenderProtocol {
|
|||||||
data.addAll(subData);
|
data.addAll(subData);
|
||||||
|
|
||||||
if ((data.length % 16) != 0) {
|
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++) {
|
for (int i = 0; i < add; i++) {
|
||||||
data.add(0);
|
data.add(0);
|
||||||
}
|
}
|
||||||
@ -117,7 +115,7 @@ class ReadSupportFunctionsWithParametersReply extends Reply {
|
|||||||
ReadSupportFunctionsWithParametersReply.parseData(CommandType commandType, List<int> dataDetail)
|
ReadSupportFunctionsWithParametersReply.parseData(CommandType commandType, List<int> dataDetail)
|
||||||
: super.parseData(commandType, dataDetail) {
|
: super.parseData(commandType, dataDetail) {
|
||||||
data = dataDetail;
|
data = dataDetail;
|
||||||
int status = data[2];
|
final int status = data[2];
|
||||||
errorWithStstus(status);
|
errorWithStstus(status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,25 +1,16 @@
|
|||||||
|
|
||||||
//TODO:查询事件记录(序号、数量查询)
|
// 查询事件记录(序号、数量查询)
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:crypto/crypto.dart' as crypto;
|
||||||
|
|
||||||
import '../io_reply.dart';
|
import '../io_reply.dart';
|
||||||
import '../io_sender.dart';
|
import '../io_sender.dart';
|
||||||
import '../io_tool/io_tool.dart';
|
import '../io_tool/io_tool.dart';
|
||||||
import '../io_type.dart';
|
import '../io_type.dart';
|
||||||
import '../sm4Encipher/sm4.dart';
|
import '../sm4Encipher/sm4.dart';
|
||||||
import 'package:crypto/crypto.dart' as crypto;
|
|
||||||
|
|
||||||
class SenderReferEventRecordNumberCommand extends SenderProtocol {
|
class SenderReferEventRecordNumberCommand extends SenderProtocol {
|
||||||
|
|
||||||
String? keyID;
|
|
||||||
String? userID;
|
|
||||||
int? logsCount;
|
|
||||||
int? logsNo;
|
|
||||||
List<int>? token;
|
|
||||||
int? needAuthor;
|
|
||||||
List<int>? publicKey;
|
|
||||||
List<int>? privateKey;
|
|
||||||
|
|
||||||
SenderReferEventRecordNumberCommand({
|
SenderReferEventRecordNumberCommand({
|
||||||
this.keyID,
|
this.keyID,
|
||||||
this.userID,
|
this.userID,
|
||||||
@ -31,6 +22,15 @@ class SenderReferEventRecordNumberCommand extends SenderProtocol {
|
|||||||
this.privateKey,
|
this.privateKey,
|
||||||
}) : super(CommandType.generalExtendedCommond);
|
}) : super(CommandType.generalExtendedCommond);
|
||||||
|
|
||||||
|
String? keyID;
|
||||||
|
String? userID;
|
||||||
|
int? logsCount;
|
||||||
|
int? logsNo;
|
||||||
|
List<int>? token;
|
||||||
|
int? needAuthor;
|
||||||
|
List<int>? publicKey;
|
||||||
|
List<int>? privateKey;
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
@ -42,15 +42,15 @@ class SenderReferEventRecordNumberCommand extends SenderProtocol {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
List<int> messageDetail() {
|
List<int> messageDetail() {
|
||||||
List<int> data = [];
|
final List<int> data = <int>[];
|
||||||
List<int> subData = [];
|
List<int> subData = <int>[];
|
||||||
List<int> ebcData = [];
|
List<int> ebcData = <int>[];
|
||||||
|
|
||||||
// 指令类型
|
// 指令类型
|
||||||
int type = commandType!.typeValue;
|
final int type = commandType!.typeValue;
|
||||||
double typeDouble = type / 256;
|
final double typeDouble = type / 256;
|
||||||
int type1 = typeDouble.toInt();
|
final int type1 = typeDouble.toInt();
|
||||||
int type2 = type % 256;
|
final int type2 = type % 256;
|
||||||
data.add(type1);
|
data.add(type1);
|
||||||
data.add(type2);
|
data.add(type2);
|
||||||
|
|
||||||
@ -58,12 +58,12 @@ class SenderReferEventRecordNumberCommand extends SenderProtocol {
|
|||||||
data.add(40);
|
data.add(40);
|
||||||
|
|
||||||
// keyID 40
|
// keyID 40
|
||||||
int keyIDLength = utf8.encode(keyID!).length;
|
final int keyIDLength = utf8.encode(keyID!).length;
|
||||||
subData.addAll(utf8.encode(keyID!));
|
subData.addAll(utf8.encode(keyID!));
|
||||||
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
||||||
|
|
||||||
//userID 20
|
//userID 20
|
||||||
int userIDLength = utf8.encode(userID!).length;
|
final int userIDLength = utf8.encode(userID!).length;
|
||||||
subData.addAll(utf8.encode(userID!));
|
subData.addAll(utf8.encode(userID!));
|
||||||
subData = getFixedLengthList(subData, 20 - userIDLength);
|
subData = getFixedLengthList(subData, 20 - userIDLength);
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ class SenderReferEventRecordNumberCommand extends SenderProtocol {
|
|||||||
//AuthCodeLen 1
|
//AuthCodeLen 1
|
||||||
subData.add(0);
|
subData.add(0);
|
||||||
} else {
|
} else {
|
||||||
List<int> authCodeData = [];
|
final List<int> authCodeData = <int>[];
|
||||||
|
|
||||||
//authUserID
|
//authUserID
|
||||||
authCodeData.addAll(utf8.encode(userID!));
|
authCodeData.addAll(utf8.encode(userID!));
|
||||||
@ -94,7 +94,7 @@ class SenderReferEventRecordNumberCommand extends SenderProtocol {
|
|||||||
authCodeData.addAll(publicKey!);
|
authCodeData.addAll(publicKey!);
|
||||||
|
|
||||||
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
||||||
var authCode = crypto.md5.convert(authCodeData);
|
final crypto.Digest authCode = crypto.md5.convert(authCodeData);
|
||||||
|
|
||||||
subData.add(authCode.bytes.length);
|
subData.add(authCode.bytes.length);
|
||||||
subData.addAll(authCode.bytes);
|
subData.addAll(authCode.bytes);
|
||||||
@ -104,7 +104,7 @@ class SenderReferEventRecordNumberCommand extends SenderProtocol {
|
|||||||
data.addAll(subData);
|
data.addAll(subData);
|
||||||
|
|
||||||
if ((data.length % 16) != 0) {
|
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++) {
|
for (int i = 0; i < add; i++) {
|
||||||
data.add(0);
|
data.add(0);
|
||||||
}
|
}
|
||||||
@ -121,7 +121,7 @@ class SenderReferEventRecordNumberReply extends Reply {
|
|||||||
SenderReferEventRecordNumberReply.parseData(CommandType commandType, List<int> dataDetail)
|
SenderReferEventRecordNumberReply.parseData(CommandType commandType, List<int> dataDetail)
|
||||||
: super.parseData(commandType, dataDetail) {
|
: super.parseData(commandType, dataDetail) {
|
||||||
data = dataDetail;
|
data = dataDetail;
|
||||||
int status = data[2];
|
final int status = data[2];
|
||||||
errorWithStstus(status);
|
errorWithStstus(status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,6 +1,8 @@
|
|||||||
//TODO:查询事件记录(时间查询)
|
|
||||||
|
// 查询事件记录(时间查询)
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:crypto/crypto.dart' as crypto;
|
||||||
import 'package:star_lock/tools/dateTool.dart';
|
import 'package:star_lock/tools/dateTool.dart';
|
||||||
|
|
||||||
import '../io_reply.dart';
|
import '../io_reply.dart';
|
||||||
@ -8,7 +10,6 @@ import '../io_sender.dart';
|
|||||||
import '../io_tool/io_tool.dart';
|
import '../io_tool/io_tool.dart';
|
||||||
import '../io_type.dart';
|
import '../io_type.dart';
|
||||||
import '../sm4Encipher/sm4.dart';
|
import '../sm4Encipher/sm4.dart';
|
||||||
import 'package:crypto/crypto.dart' as crypto;
|
|
||||||
|
|
||||||
class SenderReferEventRecordTimeCommand extends SenderProtocol {
|
class SenderReferEventRecordTimeCommand extends SenderProtocol {
|
||||||
|
|
||||||
@ -43,9 +44,9 @@ class SenderReferEventRecordTimeCommand extends SenderProtocol {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
List<int> messageDetail() {
|
List<int> messageDetail() {
|
||||||
List<int> data = [];
|
final List<int> data = <int>[];
|
||||||
List<int> subData = [];
|
List<int> subData = <int>[];
|
||||||
List<int> ebcData = [];
|
List<int> ebcData = <int>[];
|
||||||
|
|
||||||
// 指令类型
|
// 指令类型
|
||||||
// int type = commandType!.typeValue;
|
// int type = commandType!.typeValue;
|
||||||
@ -60,12 +61,12 @@ class SenderReferEventRecordTimeCommand extends SenderProtocol {
|
|||||||
data.add(41);
|
data.add(41);
|
||||||
|
|
||||||
// keyID 40
|
// keyID 40
|
||||||
int keyIDLength = utf8.encode(keyID!).length;
|
final int keyIDLength = utf8.encode(keyID!).length;
|
||||||
subData.addAll(utf8.encode(keyID!));
|
subData.addAll(utf8.encode(keyID!));
|
||||||
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
||||||
|
|
||||||
//userID 20
|
//userID 20
|
||||||
int userIDLength = utf8.encode(userID!).length;
|
final int userIDLength = utf8.encode(userID!).length;
|
||||||
subData.addAll(utf8.encode(userID!));
|
subData.addAll(utf8.encode(userID!));
|
||||||
subData = getFixedLengthList(subData, 20 - userIDLength);
|
subData = getFixedLengthList(subData, 20 - userIDLength);
|
||||||
|
|
||||||
@ -91,7 +92,7 @@ class SenderReferEventRecordTimeCommand extends SenderProtocol {
|
|||||||
//AuthCodeLen 1
|
//AuthCodeLen 1
|
||||||
subData.add(0);
|
subData.add(0);
|
||||||
} else {
|
} else {
|
||||||
List<int> authCodeData = [];
|
final List<int> authCodeData = <int>[];
|
||||||
|
|
||||||
//authUserID
|
//authUserID
|
||||||
authCodeData.addAll(utf8.encode(userID!));
|
authCodeData.addAll(utf8.encode(userID!));
|
||||||
@ -105,7 +106,7 @@ class SenderReferEventRecordTimeCommand extends SenderProtocol {
|
|||||||
authCodeData.addAll(publicKey!);
|
authCodeData.addAll(publicKey!);
|
||||||
|
|
||||||
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
||||||
var authCode = crypto.md5.convert(authCodeData);
|
final crypto.Digest authCode = crypto.md5.convert(authCodeData);
|
||||||
|
|
||||||
subData.add(authCode.bytes.length);
|
subData.add(authCode.bytes.length);
|
||||||
subData.addAll(authCode.bytes);
|
subData.addAll(authCode.bytes);
|
||||||
@ -115,7 +116,7 @@ class SenderReferEventRecordTimeCommand extends SenderProtocol {
|
|||||||
data.addAll(subData);
|
data.addAll(subData);
|
||||||
|
|
||||||
if ((data.length % 16) != 0) {
|
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++) {
|
for (int i = 0; i < add; i++) {
|
||||||
data.add(0);
|
data.add(0);
|
||||||
}
|
}
|
||||||
@ -132,7 +133,7 @@ class SenderReferEventRecordTimeReply extends Reply {
|
|||||||
CommandType commandType, List<int> dataDetail)
|
CommandType commandType, List<int> dataDetail)
|
||||||
: super.parseData(commandType, dataDetail) {
|
: super.parseData(commandType, dataDetail) {
|
||||||
data = dataDetail;
|
data = dataDetail;
|
||||||
int status = data[2];
|
final int status = data[2];
|
||||||
errorWithStstus(status);
|
errorWithStstus(status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,34 +1,20 @@
|
|||||||
|
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:crypto/crypto.dart' as crypto;
|
||||||
import 'package:star_lock/tools/dateTool.dart';
|
import 'package:star_lock/tools/dateTool.dart';
|
||||||
|
|
||||||
import '../../app_settings/app_settings.dart';
|
import '../../app_settings/app_settings.dart';
|
||||||
import '../io_tool/io_tool.dart';
|
|
||||||
import '../sm4Encipher/sm4.dart';
|
|
||||||
import '../io_reply.dart';
|
import '../io_reply.dart';
|
||||||
import '../io_sender.dart';
|
import '../io_sender.dart';
|
||||||
|
import '../io_tool/io_tool.dart';
|
||||||
import '../io_type.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 {
|
class SenderCustomPasswordsCommand extends SenderProtocol {
|
||||||
String? keyID;
|
|
||||||
String? userID;
|
|
||||||
int? pwdNo;
|
|
||||||
int? operate;
|
|
||||||
int? isAdmin;
|
|
||||||
String? pwd;
|
|
||||||
int? useCountLimit;
|
|
||||||
List<int>? token;
|
|
||||||
int? startTime;
|
|
||||||
int? endTime;
|
|
||||||
int? needAuthor;
|
|
||||||
List<int>? signKey;
|
|
||||||
List<int>? privateKey;
|
|
||||||
|
|
||||||
SenderCustomPasswordsCommand({
|
SenderCustomPasswordsCommand({
|
||||||
this.keyID,
|
this.keyID,
|
||||||
@ -45,6 +31,19 @@ class SenderCustomPasswordsCommand extends SenderProtocol {
|
|||||||
this.signKey,
|
this.signKey,
|
||||||
this.privateKey,
|
this.privateKey,
|
||||||
}) : super(CommandType.generalExtendedCommond);
|
}) : super(CommandType.generalExtendedCommond);
|
||||||
|
String? keyID;
|
||||||
|
String? userID;
|
||||||
|
int? pwdNo;
|
||||||
|
int? operate;
|
||||||
|
int? isAdmin;
|
||||||
|
String? pwd;
|
||||||
|
int? useCountLimit;
|
||||||
|
List<int>? token;
|
||||||
|
int? startTime;
|
||||||
|
int? endTime;
|
||||||
|
int? needAuthor;
|
||||||
|
List<int>? signKey;
|
||||||
|
List<int>? privateKey;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
|
|||||||
@ -1,21 +1,16 @@
|
|||||||
|
|
||||||
import 'dart:convert';
|
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;
|
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 {
|
class SenderResetPasswordsCommand extends SenderProtocol {
|
||||||
String? keyID;
|
|
||||||
String? userID;
|
|
||||||
List<int>? token;
|
|
||||||
int? needAuthor;
|
|
||||||
List<int>? signKey;
|
|
||||||
List<int>? privateKey;
|
|
||||||
|
|
||||||
SenderResetPasswordsCommand({
|
SenderResetPasswordsCommand({
|
||||||
this.keyID,
|
this.keyID,
|
||||||
@ -25,6 +20,12 @@ class SenderResetPasswordsCommand extends SenderProtocol {
|
|||||||
this.signKey,
|
this.signKey,
|
||||||
this.privateKey,
|
this.privateKey,
|
||||||
}) : super(CommandType.generalExtendedCommond);
|
}) : super(CommandType.generalExtendedCommond);
|
||||||
|
String? keyID;
|
||||||
|
String? userID;
|
||||||
|
List<int>? token;
|
||||||
|
int? needAuthor;
|
||||||
|
List<int>? signKey;
|
||||||
|
List<int>? privateKey;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
@ -35,9 +36,9 @@ class SenderResetPasswordsCommand extends SenderProtocol {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
List<int> messageDetail() {
|
List<int> messageDetail() {
|
||||||
List<int> data = [];
|
final List<int> data = <int>[];
|
||||||
List<int> subData = [];
|
List<int> subData = <int>[];
|
||||||
List<int> ebcData = [];
|
List<int> ebcData = <int>[];
|
||||||
|
|
||||||
// 指令类型
|
// 指令类型
|
||||||
data.addAll(intChangList(commandType!.typeValue));
|
data.addAll(intChangList(commandType!.typeValue));
|
||||||
@ -46,12 +47,12 @@ class SenderResetPasswordsCommand extends SenderProtocol {
|
|||||||
data.add(19);
|
data.add(19);
|
||||||
|
|
||||||
// keyID 40
|
// keyID 40
|
||||||
int keyIDLength = utf8.encode(keyID!).length;
|
final int keyIDLength = utf8.encode(keyID!).length;
|
||||||
subData.addAll(utf8.encode(keyID!));
|
subData.addAll(utf8.encode(keyID!));
|
||||||
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
||||||
|
|
||||||
//userID 20
|
//userID 20
|
||||||
int userIDLength = utf8.encode(userID!).length;
|
final int userIDLength = utf8.encode(userID!).length;
|
||||||
subData.addAll(utf8.encode(userID!));
|
subData.addAll(utf8.encode(userID!));
|
||||||
subData = getFixedLengthList(subData, 20 - userIDLength);
|
subData = getFixedLengthList(subData, 20 - userIDLength);
|
||||||
|
|
||||||
@ -62,7 +63,7 @@ class SenderResetPasswordsCommand extends SenderProtocol {
|
|||||||
//AuthCodeLen 1
|
//AuthCodeLen 1
|
||||||
subData.add(0);
|
subData.add(0);
|
||||||
} else {
|
} else {
|
||||||
List<int> authCodeData = [];
|
final List<int> authCodeData = <int>[];
|
||||||
|
|
||||||
//KeyID
|
//KeyID
|
||||||
authCodeData.addAll(utf8.encode(keyID!));
|
authCodeData.addAll(utf8.encode(keyID!));
|
||||||
@ -76,7 +77,7 @@ class SenderResetPasswordsCommand extends SenderProtocol {
|
|||||||
authCodeData.addAll(signKey!);
|
authCodeData.addAll(signKey!);
|
||||||
|
|
||||||
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
||||||
var authCode = crypto.md5.convert(authCodeData);
|
final crypto.Digest authCode = crypto.md5.convert(authCodeData);
|
||||||
|
|
||||||
subData.add(authCode.bytes.length);
|
subData.add(authCode.bytes.length);
|
||||||
subData.addAll(authCode.bytes);
|
subData.addAll(authCode.bytes);
|
||||||
@ -86,7 +87,7 @@ class SenderResetPasswordsCommand extends SenderProtocol {
|
|||||||
data.addAll(subData);
|
data.addAll(subData);
|
||||||
|
|
||||||
if ((data.length % 16) != 0) {
|
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++) {
|
for (int i = 0; i < add; i++) {
|
||||||
data.add(0);
|
data.add(0);
|
||||||
}
|
}
|
||||||
@ -104,7 +105,7 @@ class SenderResetPasswordsReply extends Reply {
|
|||||||
CommandType commandType, List<int> dataDetail)
|
CommandType commandType, List<int> dataDetail)
|
||||||
: super.parseData(commandType, dataDetail) {
|
: super.parseData(commandType, dataDetail) {
|
||||||
data = dataDetail;
|
data = dataDetail;
|
||||||
int status = data[2];
|
final int status = data[2];
|
||||||
errorWithStstus(status);
|
errorWithStstus(status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,26 +1,17 @@
|
|||||||
|
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:crypto/crypto.dart' as crypto;
|
||||||
|
|
||||||
import '../io_reply.dart';
|
import '../io_reply.dart';
|
||||||
import '../io_sender.dart';
|
import '../io_sender.dart';
|
||||||
import '../io_tool/io_tool.dart';
|
import '../io_tool/io_tool.dart';
|
||||||
import '../io_type.dart';
|
import '../io_type.dart';
|
||||||
import 'package:crypto/crypto.dart' as crypto;
|
|
||||||
|
|
||||||
import '../sm4Encipher/sm4.dart';
|
import '../sm4Encipher/sm4.dart';
|
||||||
|
|
||||||
///TODO:设置支持功能(不带参数)启用/禁用
|
/// 设置支持功能(不带参数)启用/禁用
|
||||||
class SetSupportFunctionsNoParametersCommand extends SenderProtocol {
|
class SetSupportFunctionsNoParametersCommand extends SenderProtocol {
|
||||||
|
|
||||||
String? keyID;
|
|
||||||
String? userID;
|
|
||||||
int? featureBit;
|
|
||||||
int? featureEnable;
|
|
||||||
List<int>? token;
|
|
||||||
int? needAuthor;
|
|
||||||
List<int>? publicKey;
|
|
||||||
List<int>? privateKey;
|
|
||||||
|
|
||||||
SetSupportFunctionsNoParametersCommand({
|
SetSupportFunctionsNoParametersCommand({
|
||||||
this.keyID,
|
this.keyID,
|
||||||
this.userID,
|
this.userID,
|
||||||
@ -32,6 +23,14 @@ class SetSupportFunctionsNoParametersCommand extends SenderProtocol {
|
|||||||
this.privateKey,
|
this.privateKey,
|
||||||
}) : super(CommandType.generalExtendedCommond);
|
}) : super(CommandType.generalExtendedCommond);
|
||||||
|
|
||||||
|
String? keyID;
|
||||||
|
String? userID;
|
||||||
|
int? featureBit;
|
||||||
|
int? featureEnable;
|
||||||
|
List<int>? token;
|
||||||
|
int? needAuthor;
|
||||||
|
List<int>? publicKey;
|
||||||
|
List<int>? privateKey;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
@ -44,15 +43,15 @@ class SetSupportFunctionsNoParametersCommand extends SenderProtocol {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
List<int> messageDetail() {
|
List<int> messageDetail() {
|
||||||
List<int> data = [];
|
final List<int> data = <int>[];
|
||||||
List<int> subData = [];
|
List<int> subData = <int>[];
|
||||||
List<int> ebcData = [];
|
List<int> ebcData = <int>[];
|
||||||
|
|
||||||
// 指令类型
|
// 指令类型
|
||||||
int type = commandType!.typeValue;
|
final int type = commandType!.typeValue;
|
||||||
double typeDouble = type / 256;
|
final double typeDouble = type / 256;
|
||||||
int type1 = typeDouble.toInt();
|
final int type1 = typeDouble.toInt();
|
||||||
int type2 = type % 256;
|
final int type2 = type % 256;
|
||||||
data.add(type1);
|
data.add(type1);
|
||||||
data.add(type2);
|
data.add(type2);
|
||||||
|
|
||||||
@ -60,12 +59,12 @@ class SetSupportFunctionsNoParametersCommand extends SenderProtocol {
|
|||||||
data.add(70);
|
data.add(70);
|
||||||
|
|
||||||
// keyID 40
|
// keyID 40
|
||||||
int keyIDLength = utf8.encode(keyID!).length;
|
final int keyIDLength = utf8.encode(keyID!).length;
|
||||||
subData.addAll(utf8.encode(keyID!));
|
subData.addAll(utf8.encode(keyID!));
|
||||||
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
||||||
|
|
||||||
//userID 20
|
//userID 20
|
||||||
int userIDLength = utf8.encode(userID!).length;
|
final int userIDLength = utf8.encode(userID!).length;
|
||||||
subData.addAll(utf8.encode(userID!));
|
subData.addAll(utf8.encode(userID!));
|
||||||
subData = getFixedLengthList(subData, 20 - userIDLength);
|
subData = getFixedLengthList(subData, 20 - userIDLength);
|
||||||
|
|
||||||
@ -79,7 +78,7 @@ class SetSupportFunctionsNoParametersCommand extends SenderProtocol {
|
|||||||
//AuthCodeLen 1
|
//AuthCodeLen 1
|
||||||
subData.add(0);
|
subData.add(0);
|
||||||
} else {
|
} else {
|
||||||
List<int> authCodeData = [];
|
final List<int> authCodeData = <int>[];
|
||||||
|
|
||||||
//authUserID
|
//authUserID
|
||||||
authCodeData.addAll(utf8.encode(userID!));
|
authCodeData.addAll(utf8.encode(userID!));
|
||||||
@ -93,7 +92,7 @@ class SetSupportFunctionsNoParametersCommand extends SenderProtocol {
|
|||||||
authCodeData.addAll(publicKey!);
|
authCodeData.addAll(publicKey!);
|
||||||
|
|
||||||
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
||||||
var authCode = crypto.md5.convert(authCodeData);
|
final crypto.Digest authCode = crypto.md5.convert(authCodeData);
|
||||||
|
|
||||||
subData.add(authCode.bytes.length);
|
subData.add(authCode.bytes.length);
|
||||||
subData.addAll(authCode.bytes);
|
subData.addAll(authCode.bytes);
|
||||||
@ -103,7 +102,7 @@ class SetSupportFunctionsNoParametersCommand extends SenderProtocol {
|
|||||||
data.addAll(subData);
|
data.addAll(subData);
|
||||||
|
|
||||||
if ((data.length % 16) != 0) {
|
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++) {
|
for (int i = 0; i < add; i++) {
|
||||||
data.add(0);
|
data.add(0);
|
||||||
}
|
}
|
||||||
@ -120,7 +119,7 @@ class SetSupportFunctionsNoParametersReply extends Reply {
|
|||||||
SetSupportFunctionsNoParametersReply.parseData(CommandType commandType, List<int> dataDetail)
|
SetSupportFunctionsNoParametersReply.parseData(CommandType commandType, List<int> dataDetail)
|
||||||
: super.parseData(commandType, dataDetail) {
|
: super.parseData(commandType, dataDetail) {
|
||||||
data = dataDetail;
|
data = dataDetail;
|
||||||
int status = data[2];
|
final int status = data[2];
|
||||||
errorWithStstus(status);
|
errorWithStstus(status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -9,19 +9,8 @@ import 'package:crypto/crypto.dart' as crypto;
|
|||||||
|
|
||||||
import '../sm4Encipher/sm4.dart';
|
import '../sm4Encipher/sm4.dart';
|
||||||
|
|
||||||
///TODO:设置支持功能(参数)
|
/// 设置支持功能(参数)
|
||||||
class SetSupportFunctionsWithParametersCommand extends SenderProtocol {
|
class SetSupportFunctionsWithParametersCommand extends SenderProtocol {
|
||||||
|
|
||||||
String? keyID;
|
|
||||||
String? userID;
|
|
||||||
int? featureBit;
|
|
||||||
int? featureParaLength;
|
|
||||||
List<int>? featureData;
|
|
||||||
List<int>? token;
|
|
||||||
int? needAuthor;
|
|
||||||
List<int>? publicKey;
|
|
||||||
List<int>? privateKey;
|
|
||||||
|
|
||||||
SetSupportFunctionsWithParametersCommand({
|
SetSupportFunctionsWithParametersCommand({
|
||||||
this.keyID,
|
this.keyID,
|
||||||
this.userID,
|
this.userID,
|
||||||
@ -34,6 +23,15 @@ class SetSupportFunctionsWithParametersCommand extends SenderProtocol {
|
|||||||
this.privateKey,
|
this.privateKey,
|
||||||
}) : super(CommandType.generalExtendedCommond);
|
}) : super(CommandType.generalExtendedCommond);
|
||||||
|
|
||||||
|
String? keyID;
|
||||||
|
String? userID;
|
||||||
|
int? featureBit;
|
||||||
|
int? featureParaLength;
|
||||||
|
List<int>? featureData;
|
||||||
|
List<int>? token;
|
||||||
|
int? needAuthor;
|
||||||
|
List<int>? publicKey;
|
||||||
|
List<int>? privateKey;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
@ -46,15 +44,15 @@ class SetSupportFunctionsWithParametersCommand extends SenderProtocol {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
List<int> messageDetail() {
|
List<int> messageDetail() {
|
||||||
List<int> data = [];
|
final List<int> data = <int>[];
|
||||||
List<int> subData = [];
|
List<int> subData = <int>[];
|
||||||
List<int> ebcData = [];
|
List<int> ebcData = <int>[];
|
||||||
|
|
||||||
// 指令类型
|
// 指令类型
|
||||||
int type = commandType!.typeValue;
|
final int type = commandType!.typeValue;
|
||||||
double typeDouble = type / 256;
|
final double typeDouble = type / 256;
|
||||||
int type1 = typeDouble.toInt();
|
final int type1 = typeDouble.toInt();
|
||||||
int type2 = type % 256;
|
final int type2 = type % 256;
|
||||||
data.add(type1);
|
data.add(type1);
|
||||||
data.add(type2);
|
data.add(type2);
|
||||||
|
|
||||||
@ -62,12 +60,12 @@ class SetSupportFunctionsWithParametersCommand extends SenderProtocol {
|
|||||||
data.add(72);
|
data.add(72);
|
||||||
|
|
||||||
// keyID 40
|
// keyID 40
|
||||||
int keyIDLength = utf8.encode(keyID!).length;
|
final int keyIDLength = utf8.encode(keyID!).length;
|
||||||
subData.addAll(utf8.encode(keyID!));
|
subData.addAll(utf8.encode(keyID!));
|
||||||
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
||||||
|
|
||||||
//userID 20
|
//userID 20
|
||||||
int userIDLength = utf8.encode(userID!).length;
|
final int userIDLength = utf8.encode(userID!).length;
|
||||||
subData.addAll(utf8.encode(userID!));
|
subData.addAll(utf8.encode(userID!));
|
||||||
subData = getFixedLengthList(subData, 20 - userIDLength);
|
subData = getFixedLengthList(subData, 20 - userIDLength);
|
||||||
|
|
||||||
@ -84,7 +82,7 @@ class SetSupportFunctionsWithParametersCommand extends SenderProtocol {
|
|||||||
//AuthCodeLen 1
|
//AuthCodeLen 1
|
||||||
subData.add(0);
|
subData.add(0);
|
||||||
} else {
|
} else {
|
||||||
List<int> authCodeData = [];
|
final List<int> authCodeData = <int>[];
|
||||||
|
|
||||||
//authUserID
|
//authUserID
|
||||||
authCodeData.addAll(utf8.encode(userID!));
|
authCodeData.addAll(utf8.encode(userID!));
|
||||||
@ -98,7 +96,7 @@ class SetSupportFunctionsWithParametersCommand extends SenderProtocol {
|
|||||||
authCodeData.addAll(publicKey!);
|
authCodeData.addAll(publicKey!);
|
||||||
|
|
||||||
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
||||||
var authCode = crypto.md5.convert(authCodeData);
|
final crypto.Digest authCode = crypto.md5.convert(authCodeData);
|
||||||
|
|
||||||
subData.add(authCode.bytes.length);
|
subData.add(authCode.bytes.length);
|
||||||
subData.addAll(authCode.bytes);
|
subData.addAll(authCode.bytes);
|
||||||
@ -108,7 +106,7 @@ class SetSupportFunctionsWithParametersCommand extends SenderProtocol {
|
|||||||
data.addAll(subData);
|
data.addAll(subData);
|
||||||
|
|
||||||
if ((data.length % 16) != 0) {
|
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++) {
|
for (int i = 0; i < add; i++) {
|
||||||
data.add(0);
|
data.add(0);
|
||||||
}
|
}
|
||||||
@ -125,7 +123,7 @@ class SetSupportFunctionsWithParametersReply extends Reply {
|
|||||||
SetSupportFunctionsWithParametersReply.parseData(CommandType commandType, List<int> dataDetail)
|
SetSupportFunctionsWithParametersReply.parseData(CommandType commandType, List<int> dataDetail)
|
||||||
: super.parseData(commandType, dataDetail) {
|
: super.parseData(commandType, dataDetail) {
|
||||||
data = dataDetail;
|
data = dataDetail;
|
||||||
int status = data[2];
|
final int status = data[2];
|
||||||
errorWithStstus(status);
|
errorWithStstus(status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3,14 +3,13 @@ import 'dart:convert';
|
|||||||
|
|
||||||
import 'package:star_lock/tools/dateTool.dart';
|
import 'package:star_lock/tools/dateTool.dart';
|
||||||
|
|
||||||
import '../io_tool/io_tool.dart';
|
|
||||||
import '../sm4Encipher/sm4.dart';
|
|
||||||
import '../io_reply.dart';
|
import '../io_reply.dart';
|
||||||
import '../io_sender.dart';
|
import '../io_sender.dart';
|
||||||
|
import '../io_tool/io_tool.dart';
|
||||||
import '../io_type.dart';
|
import '../io_type.dart';
|
||||||
import 'package:crypto/crypto.dart' as crypto;
|
import '../sm4Encipher/sm4.dart';
|
||||||
|
|
||||||
//TODO:校时
|
// 校时
|
||||||
class TimingCommand extends SenderProtocol {
|
class TimingCommand extends SenderProtocol {
|
||||||
String? lockID;
|
String? lockID;
|
||||||
String? userID;
|
String? userID;
|
||||||
@ -44,32 +43,32 @@ class TimingCommand extends SenderProtocol {
|
|||||||
List<int> ebcData = [];
|
List<int> ebcData = [];
|
||||||
|
|
||||||
// 指令类型
|
// 指令类型
|
||||||
int type = commandType!.typeValue;
|
final int type = commandType!.typeValue;
|
||||||
double typeDouble = type / 256;
|
final double typeDouble = type / 256;
|
||||||
int type1 = typeDouble.toInt();
|
final int type1 = typeDouble.toInt();
|
||||||
int type2 = type % 256;
|
final int type2 = type % 256;
|
||||||
data.add(type1);
|
data.add(type1);
|
||||||
data.add(type2);
|
data.add(type2);
|
||||||
|
|
||||||
//lockID 40
|
//lockID 40
|
||||||
int lockIDLength = utf8.encode(lockID!).length;
|
final int lockIDLength = utf8.encode(lockID!).length;
|
||||||
data.addAll(utf8.encode(lockID!));
|
data.addAll(utf8.encode(lockID!));
|
||||||
data = getFixedLengthList(data, 40 - lockIDLength);
|
data = getFixedLengthList(data, 40 - lockIDLength);
|
||||||
|
|
||||||
//userID 要接受钥匙的用户的useid 20
|
//userID 要接受钥匙的用户的useid 20
|
||||||
int userIDLength = utf8.encode(userID!).length;
|
final int userIDLength = utf8.encode(userID!).length;
|
||||||
data.addAll(utf8.encode(userID!));
|
data.addAll(utf8.encode(userID!));
|
||||||
data = getFixedLengthList(data, 20 - userIDLength);
|
data = getFixedLengthList(data, 20 - userIDLength);
|
||||||
|
|
||||||
// nowTime 4
|
// nowTime 4
|
||||||
int? d1 = nowTime;
|
final int? d1 = nowTime;
|
||||||
data.add((d1! & 0xff000000) >> 24);
|
data.add((d1! & 0xff000000) >> 24);
|
||||||
data.add((d1 & 0xff0000) >> 16);
|
data.add((d1 & 0xff0000) >> 16);
|
||||||
data.add((d1 & 0xff00) >> 8);
|
data.add((d1 & 0xff00) >> 8);
|
||||||
data.add((d1 & 0xff));
|
data.add(d1 & 0xff);
|
||||||
|
|
||||||
if ((data.length % 16) != 0) {
|
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++) {
|
for (int i = 0; i < add; i++) {
|
||||||
data.add(0);
|
data.add(0);
|
||||||
}
|
}
|
||||||
@ -85,7 +84,7 @@ class TimingReply extends Reply {
|
|||||||
TimingReply.parseData(CommandType commandType, List<int> dataDetail)
|
TimingReply.parseData(CommandType commandType, List<int> dataDetail)
|
||||||
: super.parseData(commandType, dataDetail) {
|
: super.parseData(commandType, dataDetail) {
|
||||||
data = dataDetail;
|
data = dataDetail;
|
||||||
int status = data[2];
|
final int status = data[2];
|
||||||
errorWithStstus(status);
|
errorWithStstus(status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,25 +1,16 @@
|
|||||||
|
|
||||||
import 'dart:convert';
|
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;
|
import 'package:crypto/crypto.dart' as crypto;
|
||||||
|
|
||||||
//TODO:转移权限
|
import '../io_reply.dart';
|
||||||
class TransferPermissionsCommand extends SenderProtocol {
|
import '../io_sender.dart';
|
||||||
|
import '../io_tool/io_tool.dart';
|
||||||
|
import '../io_type.dart';
|
||||||
|
import '../sm4Encipher/sm4.dart';
|
||||||
|
|
||||||
String? lockID;
|
// 转移权限
|
||||||
String? authUserID;
|
class TransferPermissionsCommand extends SenderProtocol {
|
||||||
String? keyID;
|
|
||||||
String? oldUserID;
|
|
||||||
String? newUserID;
|
|
||||||
int? needAuthor;
|
|
||||||
List<int>? publicKey;
|
|
||||||
List<int>? privateKey;
|
|
||||||
List<int>? token;
|
|
||||||
TransferPermissionsCommand({
|
TransferPermissionsCommand({
|
||||||
this.lockID,
|
this.lockID,
|
||||||
this.authUserID,
|
this.authUserID,
|
||||||
@ -32,6 +23,16 @@ class TransferPermissionsCommand extends SenderProtocol {
|
|||||||
this.token
|
this.token
|
||||||
}) : super(CommandType.transferPermissions);
|
}) : super(CommandType.transferPermissions);
|
||||||
|
|
||||||
|
String? lockID;
|
||||||
|
String? authUserID;
|
||||||
|
String? keyID;
|
||||||
|
String? oldUserID;
|
||||||
|
String? newUserID;
|
||||||
|
int? needAuthor;
|
||||||
|
List<int>? publicKey;
|
||||||
|
List<int>? privateKey;
|
||||||
|
List<int>? token;
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
@ -43,39 +44,39 @@ class TransferPermissionsCommand extends SenderProtocol {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
List<int> messageDetail() {
|
List<int> messageDetail() {
|
||||||
List<int> data = [];
|
List<int> data = <int>[];
|
||||||
List<int> ebcData = [];
|
List<int> ebcData = <int>[];
|
||||||
|
|
||||||
// 指令类型
|
// 指令类型
|
||||||
int type = commandType!.typeValue;
|
final int type = commandType!.typeValue;
|
||||||
double typeDouble = type / 256;
|
final double typeDouble = type / 256;
|
||||||
int type1 = typeDouble.toInt();
|
final int type1 = typeDouble.toInt();
|
||||||
int type2 = type % 256;
|
final int type2 = type % 256;
|
||||||
data.add(type1);
|
data.add(type1);
|
||||||
data.add(type2);
|
data.add(type2);
|
||||||
|
|
||||||
// 锁id 40
|
// 锁id 40
|
||||||
int lockIDLength = utf8.encode(lockID!).length;
|
final int lockIDLength = utf8.encode(lockID!).length;
|
||||||
data.addAll(utf8.encode(lockID!));
|
data.addAll(utf8.encode(lockID!));
|
||||||
data = getFixedLengthList(data, 40 - lockIDLength);
|
data = getFixedLengthList(data, 40 - lockIDLength);
|
||||||
|
|
||||||
//authUserID 20
|
//authUserID 20
|
||||||
int authUserIDLength = utf8.encode(authUserID!).length;
|
final int authUserIDLength = utf8.encode(authUserID!).length;
|
||||||
data.addAll(utf8.encode(authUserID!));
|
data.addAll(utf8.encode(authUserID!));
|
||||||
data = getFixedLengthList(data, 20 - authUserIDLength);
|
data = getFixedLengthList(data, 20 - authUserIDLength);
|
||||||
|
|
||||||
//KeyID 40
|
//KeyID 40
|
||||||
int keyIDLength = utf8.encode(keyID!).length;
|
final int keyIDLength = utf8.encode(keyID!).length;
|
||||||
data.addAll(utf8.encode(keyID!));
|
data.addAll(utf8.encode(keyID!));
|
||||||
data = getFixedLengthList(data, 40 - keyIDLength);
|
data = getFixedLengthList(data, 40 - keyIDLength);
|
||||||
|
|
||||||
//oldUserID 20
|
//oldUserID 20
|
||||||
int oldUserIDLength = utf8.encode(oldUserID!).length;
|
final int oldUserIDLength = utf8.encode(oldUserID!).length;
|
||||||
data.addAll(utf8.encode(oldUserID!));
|
data.addAll(utf8.encode(oldUserID!));
|
||||||
data = getFixedLengthList(data, 20 - oldUserIDLength);
|
data = getFixedLengthList(data, 20 - oldUserIDLength);
|
||||||
|
|
||||||
//newUserID 20
|
//newUserID 20
|
||||||
int newUserIDLength = utf8.encode(newUserID!).length;
|
final int newUserIDLength = utf8.encode(newUserID!).length;
|
||||||
data.addAll(utf8.encode(newUserID!));
|
data.addAll(utf8.encode(newUserID!));
|
||||||
data = getFixedLengthList(data, 20 - newUserIDLength);
|
data = getFixedLengthList(data, 20 - newUserIDLength);
|
||||||
|
|
||||||
@ -86,7 +87,7 @@ class TransferPermissionsCommand extends SenderProtocol {
|
|||||||
//AuthCodeLen 1
|
//AuthCodeLen 1
|
||||||
data.add(0);
|
data.add(0);
|
||||||
} else {
|
} else {
|
||||||
List<int> authCodeData = [];
|
final List<int> authCodeData = <int>[];
|
||||||
|
|
||||||
//authUserID
|
//authUserID
|
||||||
authCodeData.addAll(utf8.encode(authUserID!));
|
authCodeData.addAll(utf8.encode(authUserID!));
|
||||||
@ -100,14 +101,14 @@ class TransferPermissionsCommand extends SenderProtocol {
|
|||||||
authCodeData.addAll(publicKey!);
|
authCodeData.addAll(publicKey!);
|
||||||
|
|
||||||
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
||||||
var authCode = crypto.md5.convert(authCodeData);
|
final crypto.Digest authCode = crypto.md5.convert(authCodeData);
|
||||||
|
|
||||||
data.add(authCode.bytes.length);
|
data.add(authCode.bytes.length);
|
||||||
data.addAll(authCode.bytes);
|
data.addAll(authCode.bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((data.length % 16) != 0) {
|
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++) {
|
for (int i = 0; i < add; i++) {
|
||||||
data.add(0);
|
data.add(0);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
//TODO:转移智能锁
|
// 转移智能锁
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:crypto/crypto.dart' as crypto;
|
import 'package:crypto/crypto.dart' as crypto;
|
||||||
@ -11,14 +11,6 @@ import '../io_type.dart';
|
|||||||
import '../sm4Encipher/sm4.dart';
|
import '../sm4Encipher/sm4.dart';
|
||||||
|
|
||||||
class TransferSmartLockCommand extends SenderProtocol {
|
class TransferSmartLockCommand extends SenderProtocol {
|
||||||
|
|
||||||
String? lockID;
|
|
||||||
String? userID;
|
|
||||||
String? keyID;
|
|
||||||
List<int>? publicKey;
|
|
||||||
List<int>? privateKey;
|
|
||||||
List<int>? token;
|
|
||||||
int? needAuthor;
|
|
||||||
TransferSmartLockCommand({
|
TransferSmartLockCommand({
|
||||||
this.lockID,
|
this.lockID,
|
||||||
this.userID,
|
this.userID,
|
||||||
@ -29,6 +21,14 @@ class TransferSmartLockCommand extends SenderProtocol {
|
|||||||
this.privateKey,
|
this.privateKey,
|
||||||
}) : super(CommandType.transferSmartLock);
|
}) : super(CommandType.transferSmartLock);
|
||||||
|
|
||||||
|
String? lockID;
|
||||||
|
String? userID;
|
||||||
|
String? keyID;
|
||||||
|
List<int>? publicKey;
|
||||||
|
List<int>? privateKey;
|
||||||
|
List<int>? token;
|
||||||
|
int? needAuthor;
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
|
|||||||
@ -10,16 +10,6 @@ import '../io_type.dart';
|
|||||||
import '../sm4Encipher/sm4.dart';
|
import '../sm4Encipher/sm4.dart';
|
||||||
|
|
||||||
class UpdataLockCardListCommand extends SenderProtocol {
|
class UpdataLockCardListCommand extends SenderProtocol {
|
||||||
|
|
||||||
String? lockID;
|
|
||||||
String? keyID;
|
|
||||||
String? userID;
|
|
||||||
int? page;
|
|
||||||
int? countReq;
|
|
||||||
List<int>? token;
|
|
||||||
int? needAuthor;
|
|
||||||
List<int>? signKey;
|
|
||||||
List<int>? privateKey;
|
|
||||||
UpdataLockCardListCommand({
|
UpdataLockCardListCommand({
|
||||||
this.lockID,
|
this.lockID,
|
||||||
this.keyID,
|
this.keyID,
|
||||||
@ -32,6 +22,16 @@ class UpdataLockCardListCommand extends SenderProtocol {
|
|||||||
this.privateKey
|
this.privateKey
|
||||||
}) : super(CommandType.updataLockCardList);
|
}) : super(CommandType.updataLockCardList);
|
||||||
|
|
||||||
|
String? lockID;
|
||||||
|
String? keyID;
|
||||||
|
String? userID;
|
||||||
|
int? page;
|
||||||
|
int? countReq;
|
||||||
|
List<int>? token;
|
||||||
|
int? needAuthor;
|
||||||
|
List<int>? signKey;
|
||||||
|
List<int>? privateKey;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'UpdataLockCardListCommand{lockID: $lockID, keyID:$keyID userID: $userID, '
|
return 'UpdataLockCardListCommand{lockID: $lockID, keyID:$keyID userID: $userID, '
|
||||||
@ -41,24 +41,24 @@ class UpdataLockCardListCommand extends SenderProtocol {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
List<int> messageDetail() {
|
List<int> messageDetail() {
|
||||||
List<int> data = [];
|
List<int> data = <int>[];
|
||||||
List<int> ebcData = [];
|
List<int> ebcData = <int>[];
|
||||||
|
|
||||||
// 指令类型
|
// 指令类型
|
||||||
int type = commandType!.typeValue;
|
final int type = commandType!.typeValue;
|
||||||
double typeDouble = type / 256;
|
final double typeDouble = type / 256;
|
||||||
int type1 = typeDouble.toInt();
|
final int type1 = typeDouble.toInt();
|
||||||
int type2 = type % 256;
|
final int type2 = type % 256;
|
||||||
data.add(type1);
|
data.add(type1);
|
||||||
data.add(type2);
|
data.add(type2);
|
||||||
|
|
||||||
// 锁id 40
|
// 锁id 40
|
||||||
int lockIDLength = utf8.encode(lockID!).length;
|
final int lockIDLength = utf8.encode(lockID!).length;
|
||||||
data.addAll(utf8.encode(lockID!));
|
data.addAll(utf8.encode(lockID!));
|
||||||
data = getFixedLengthList(data, 40 - lockIDLength);
|
data = getFixedLengthList(data, 40 - lockIDLength);
|
||||||
|
|
||||||
//userID 要接受钥匙的用户的useid 20
|
//userID 要接受钥匙的用户的useid 20
|
||||||
int userIDLength = utf8.encode(userID!).length;
|
final int userIDLength = utf8.encode(userID!).length;
|
||||||
data.addAll(utf8.encode(userID!));
|
data.addAll(utf8.encode(userID!));
|
||||||
data = getFixedLengthList(data, 20 - userIDLength);
|
data = getFixedLengthList(data, 20 - userIDLength);
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ class UpdataLockCardListCommand extends SenderProtocol {
|
|||||||
//AuthCodeLen 1
|
//AuthCodeLen 1
|
||||||
data.add(0);
|
data.add(0);
|
||||||
} else {
|
} else {
|
||||||
List<int> authCodeData = [];
|
final List<int> authCodeData = <int>[];
|
||||||
//KeyID
|
//KeyID
|
||||||
authCodeData.addAll(utf8.encode(lockID!));
|
authCodeData.addAll(utf8.encode(lockID!));
|
||||||
|
|
||||||
@ -88,14 +88,14 @@ class UpdataLockCardListCommand extends SenderProtocol {
|
|||||||
authCodeData.addAll(signKey!);
|
authCodeData.addAll(signKey!);
|
||||||
|
|
||||||
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
||||||
var authCode = crypto.md5.convert(authCodeData);
|
final crypto.Digest authCode = crypto.md5.convert(authCodeData);
|
||||||
|
|
||||||
data.add(authCode.bytes.length);
|
data.add(authCode.bytes.length);
|
||||||
data.addAll(authCode.bytes);
|
data.addAll(authCode.bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((data.length % 16) != 0) {
|
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++) {
|
for (int i = 0; i < add; i++) {
|
||||||
data.add(0);
|
data.add(0);
|
||||||
}
|
}
|
||||||
@ -113,7 +113,7 @@ class UpdataLockCardListReply extends Reply {
|
|||||||
: super.parseData(commandType, dataDetail) {
|
: super.parseData(commandType, dataDetail) {
|
||||||
data = dataDetail;
|
data = dataDetail;
|
||||||
|
|
||||||
int status = data[2];
|
final int status = data[2];
|
||||||
errorWithStstus(status);
|
errorWithStstus(status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,25 +1,15 @@
|
|||||||
|
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:crypto/crypto.dart' as crypto;
|
||||||
|
|
||||||
import '../io_reply.dart';
|
import '../io_reply.dart';
|
||||||
import '../io_sender.dart';
|
import '../io_sender.dart';
|
||||||
import '../io_tool/io_tool.dart';
|
import '../io_tool/io_tool.dart';
|
||||||
import '../io_type.dart';
|
import '../io_type.dart';
|
||||||
import 'package:crypto/crypto.dart' as crypto;
|
|
||||||
|
|
||||||
import '../sm4Encipher/sm4.dart';
|
import '../sm4Encipher/sm4.dart';
|
||||||
|
|
||||||
class UpdataLockFaceListCommand extends SenderProtocol {
|
class UpdataLockFaceListCommand extends SenderProtocol {
|
||||||
|
|
||||||
String? lockID;
|
|
||||||
String? keyID;
|
|
||||||
String? userID;
|
|
||||||
int? page;
|
|
||||||
int? countReq;
|
|
||||||
List<int>? token;
|
|
||||||
int? needAuthor;
|
|
||||||
List<int>? signKey;
|
|
||||||
List<int>? privateKey;
|
|
||||||
UpdataLockFaceListCommand({
|
UpdataLockFaceListCommand({
|
||||||
this.lockID,
|
this.lockID,
|
||||||
this.keyID,
|
this.keyID,
|
||||||
@ -32,6 +22,16 @@ class UpdataLockFaceListCommand extends SenderProtocol {
|
|||||||
this.privateKey
|
this.privateKey
|
||||||
}) : super(CommandType.updataLockFaceList);
|
}) : super(CommandType.updataLockFaceList);
|
||||||
|
|
||||||
|
String? lockID;
|
||||||
|
String? keyID;
|
||||||
|
String? userID;
|
||||||
|
int? page;
|
||||||
|
int? countReq;
|
||||||
|
List<int>? token;
|
||||||
|
int? needAuthor;
|
||||||
|
List<int>? signKey;
|
||||||
|
List<int>? privateKey;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'UpdataLockPasswordListCommand{lockID: $lockID, keyID:$keyID userID: $userID, '
|
return 'UpdataLockPasswordListCommand{lockID: $lockID, keyID:$keyID userID: $userID, '
|
||||||
@ -41,24 +41,24 @@ class UpdataLockFaceListCommand extends SenderProtocol {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
List<int> messageDetail() {
|
List<int> messageDetail() {
|
||||||
List<int> data = [];
|
List<int> data = <int>[];
|
||||||
List<int> ebcData = [];
|
List<int> ebcData = <int>[];
|
||||||
|
|
||||||
// 指令类型
|
// 指令类型
|
||||||
int type = commandType!.typeValue;
|
final int type = commandType!.typeValue;
|
||||||
double typeDouble = type / 256;
|
final double typeDouble = type / 256;
|
||||||
int type1 = typeDouble.toInt();
|
final int type1 = typeDouble.toInt();
|
||||||
int type2 = type % 256;
|
final int type2 = type % 256;
|
||||||
data.add(type1);
|
data.add(type1);
|
||||||
data.add(type2);
|
data.add(type2);
|
||||||
|
|
||||||
// 锁id 40
|
// 锁id 40
|
||||||
int lockIDLength = utf8.encode(lockID!).length;
|
final int lockIDLength = utf8.encode(lockID!).length;
|
||||||
data.addAll(utf8.encode(lockID!));
|
data.addAll(utf8.encode(lockID!));
|
||||||
data = getFixedLengthList(data, 40 - lockIDLength);
|
data = getFixedLengthList(data, 40 - lockIDLength);
|
||||||
|
|
||||||
//userID 要接受钥匙的用户的useid 20
|
//userID 要接受钥匙的用户的useid 20
|
||||||
int userIDLength = utf8.encode(userID!).length;
|
final int userIDLength = utf8.encode(userID!).length;
|
||||||
data.addAll(utf8.encode(userID!));
|
data.addAll(utf8.encode(userID!));
|
||||||
data = getFixedLengthList(data, 20 - userIDLength);
|
data = getFixedLengthList(data, 20 - userIDLength);
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ class UpdataLockFaceListCommand extends SenderProtocol {
|
|||||||
//AuthCodeLen 1
|
//AuthCodeLen 1
|
||||||
data.add(0);
|
data.add(0);
|
||||||
} else {
|
} else {
|
||||||
List<int> authCodeData = [];
|
final List<int> authCodeData = <int>[];
|
||||||
//KeyID
|
//KeyID
|
||||||
authCodeData.addAll(utf8.encode(lockID!));
|
authCodeData.addAll(utf8.encode(lockID!));
|
||||||
|
|
||||||
@ -88,14 +88,14 @@ class UpdataLockFaceListCommand extends SenderProtocol {
|
|||||||
authCodeData.addAll(signKey!);
|
authCodeData.addAll(signKey!);
|
||||||
|
|
||||||
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
||||||
var authCode = crypto.md5.convert(authCodeData);
|
final crypto.Digest authCode = crypto.md5.convert(authCodeData);
|
||||||
|
|
||||||
data.add(authCode.bytes.length);
|
data.add(authCode.bytes.length);
|
||||||
data.addAll(authCode.bytes);
|
data.addAll(authCode.bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((data.length % 16) != 0) {
|
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++) {
|
for (int i = 0; i < add; i++) {
|
||||||
data.add(0);
|
data.add(0);
|
||||||
}
|
}
|
||||||
@ -113,7 +113,7 @@ class UpdataLockFaceListReply extends Reply {
|
|||||||
: super.parseData(commandType, dataDetail) {
|
: super.parseData(commandType, dataDetail) {
|
||||||
data = dataDetail;
|
data = dataDetail;
|
||||||
|
|
||||||
int status = data[2];
|
final int status = data[2];
|
||||||
errorWithStstus(status);
|
errorWithStstus(status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,25 +1,15 @@
|
|||||||
|
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:crypto/crypto.dart' as crypto;
|
||||||
|
|
||||||
import '../io_reply.dart';
|
import '../io_reply.dart';
|
||||||
import '../io_sender.dart';
|
import '../io_sender.dart';
|
||||||
import '../io_tool/io_tool.dart';
|
import '../io_tool/io_tool.dart';
|
||||||
import '../io_type.dart';
|
import '../io_type.dart';
|
||||||
import 'package:crypto/crypto.dart' as crypto;
|
|
||||||
|
|
||||||
import '../sm4Encipher/sm4.dart';
|
import '../sm4Encipher/sm4.dart';
|
||||||
|
|
||||||
class UpdataLockFingerprintListCommand extends SenderProtocol {
|
class UpdataLockFingerprintListCommand extends SenderProtocol {
|
||||||
|
|
||||||
String? lockID;
|
|
||||||
String? keyID;
|
|
||||||
String? userID;
|
|
||||||
int? page;
|
|
||||||
int? countReq;
|
|
||||||
List<int>? token;
|
|
||||||
int? needAuthor;
|
|
||||||
List<int>? signKey;
|
|
||||||
List<int>? privateKey;
|
|
||||||
UpdataLockFingerprintListCommand({
|
UpdataLockFingerprintListCommand({
|
||||||
this.lockID,
|
this.lockID,
|
||||||
this.keyID,
|
this.keyID,
|
||||||
@ -32,6 +22,16 @@ class UpdataLockFingerprintListCommand extends SenderProtocol {
|
|||||||
this.privateKey
|
this.privateKey
|
||||||
}) : super(CommandType.updataLockFingerprintList);
|
}) : super(CommandType.updataLockFingerprintList);
|
||||||
|
|
||||||
|
String? lockID;
|
||||||
|
String? keyID;
|
||||||
|
String? userID;
|
||||||
|
int? page;
|
||||||
|
int? countReq;
|
||||||
|
List<int>? token;
|
||||||
|
int? needAuthor;
|
||||||
|
List<int>? signKey;
|
||||||
|
List<int>? privateKey;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'UpdataLockPasswordListCommand{lockID: $lockID, keyID:$keyID userID: $userID, '
|
return 'UpdataLockPasswordListCommand{lockID: $lockID, keyID:$keyID userID: $userID, '
|
||||||
@ -41,24 +41,24 @@ class UpdataLockFingerprintListCommand extends SenderProtocol {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
List<int> messageDetail() {
|
List<int> messageDetail() {
|
||||||
List<int> data = [];
|
List<int> data = <int>[];
|
||||||
List<int> ebcData = [];
|
List<int> ebcData = <int>[];
|
||||||
|
|
||||||
// 指令类型
|
// 指令类型
|
||||||
int type = commandType!.typeValue;
|
final int type = commandType!.typeValue;
|
||||||
double typeDouble = type / 256;
|
final double typeDouble = type / 256;
|
||||||
int type1 = typeDouble.toInt();
|
final int type1 = typeDouble.toInt();
|
||||||
int type2 = type % 256;
|
final int type2 = type % 256;
|
||||||
data.add(type1);
|
data.add(type1);
|
||||||
data.add(type2);
|
data.add(type2);
|
||||||
|
|
||||||
// 锁id 40
|
// 锁id 40
|
||||||
int lockIDLength = utf8.encode(lockID!).length;
|
final int lockIDLength = utf8.encode(lockID!).length;
|
||||||
data.addAll(utf8.encode(lockID!));
|
data.addAll(utf8.encode(lockID!));
|
||||||
data = getFixedLengthList(data, 40 - lockIDLength);
|
data = getFixedLengthList(data, 40 - lockIDLength);
|
||||||
|
|
||||||
//userID 要接受钥匙的用户的useid 20
|
//userID 要接受钥匙的用户的useid 20
|
||||||
int userIDLength = utf8.encode(userID!).length;
|
final int userIDLength = utf8.encode(userID!).length;
|
||||||
data.addAll(utf8.encode(userID!));
|
data.addAll(utf8.encode(userID!));
|
||||||
data = getFixedLengthList(data, 20 - userIDLength);
|
data = getFixedLengthList(data, 20 - userIDLength);
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ class UpdataLockFingerprintListCommand extends SenderProtocol {
|
|||||||
//AuthCodeLen 1
|
//AuthCodeLen 1
|
||||||
data.add(0);
|
data.add(0);
|
||||||
} else {
|
} else {
|
||||||
List<int> authCodeData = [];
|
final List<int> authCodeData = <int>[];
|
||||||
//KeyID
|
//KeyID
|
||||||
authCodeData.addAll(utf8.encode(lockID!));
|
authCodeData.addAll(utf8.encode(lockID!));
|
||||||
|
|
||||||
@ -88,14 +88,14 @@ class UpdataLockFingerprintListCommand extends SenderProtocol {
|
|||||||
authCodeData.addAll(signKey!);
|
authCodeData.addAll(signKey!);
|
||||||
|
|
||||||
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
||||||
var authCode = crypto.md5.convert(authCodeData);
|
final crypto.Digest authCode = crypto.md5.convert(authCodeData);
|
||||||
|
|
||||||
data.add(authCode.bytes.length);
|
data.add(authCode.bytes.length);
|
||||||
data.addAll(authCode.bytes);
|
data.addAll(authCode.bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((data.length % 16) != 0) {
|
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++) {
|
for (int i = 0; i < add; i++) {
|
||||||
data.add(0);
|
data.add(0);
|
||||||
}
|
}
|
||||||
@ -113,7 +113,7 @@ class UpdataLockFingerprintListReply extends Reply {
|
|||||||
: super.parseData(commandType, dataDetail) {
|
: super.parseData(commandType, dataDetail) {
|
||||||
data = dataDetail;
|
data = dataDetail;
|
||||||
|
|
||||||
int status = data[2];
|
final int status = data[2];
|
||||||
errorWithStstus(status);
|
errorWithStstus(status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,24 +1,15 @@
|
|||||||
|
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:crypto/crypto.dart' as crypto;
|
||||||
|
|
||||||
import '../io_reply.dart';
|
import '../io_reply.dart';
|
||||||
import '../io_sender.dart';
|
import '../io_sender.dart';
|
||||||
import '../io_tool/io_tool.dart';
|
import '../io_tool/io_tool.dart';
|
||||||
import '../io_type.dart';
|
import '../io_type.dart';
|
||||||
import 'package:crypto/crypto.dart' as crypto;
|
|
||||||
|
|
||||||
import '../sm4Encipher/sm4.dart';
|
import '../sm4Encipher/sm4.dart';
|
||||||
|
|
||||||
class UpdataLockPalmVeinListCommand extends SenderProtocol {
|
class UpdataLockPalmVeinListCommand extends SenderProtocol {
|
||||||
|
|
||||||
String? lockID;
|
|
||||||
String? userID;
|
|
||||||
int? page;
|
|
||||||
int? countReq;
|
|
||||||
List<int>? token;
|
|
||||||
int? needAuthor;
|
|
||||||
List<int>? signKey;
|
|
||||||
List<int>? privateKey;
|
|
||||||
UpdataLockPalmVeinListCommand({
|
UpdataLockPalmVeinListCommand({
|
||||||
this.lockID,
|
this.lockID,
|
||||||
this.userID,
|
this.userID,
|
||||||
@ -30,6 +21,15 @@ class UpdataLockPalmVeinListCommand extends SenderProtocol {
|
|||||||
this.privateKey
|
this.privateKey
|
||||||
}) : super(CommandType.updataLockPalmVeinList);
|
}) : super(CommandType.updataLockPalmVeinList);
|
||||||
|
|
||||||
|
String? lockID;
|
||||||
|
String? userID;
|
||||||
|
int? page;
|
||||||
|
int? countReq;
|
||||||
|
List<int>? token;
|
||||||
|
int? needAuthor;
|
||||||
|
List<int>? signKey;
|
||||||
|
List<int>? privateKey;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'UpdataLockPasswordListCommand{lockID: $lockID, userID: $userID, '
|
return 'UpdataLockPasswordListCommand{lockID: $lockID, userID: $userID, '
|
||||||
@ -39,24 +39,24 @@ class UpdataLockPalmVeinListCommand extends SenderProtocol {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
List<int> messageDetail() {
|
List<int> messageDetail() {
|
||||||
List<int> data = [];
|
List<int> data = <int>[];
|
||||||
List<int> ebcData = [];
|
List<int> ebcData = <int>[];
|
||||||
|
|
||||||
// 指令类型
|
// 指令类型
|
||||||
int type = commandType!.typeValue;
|
final int type = commandType!.typeValue;
|
||||||
double typeDouble = type / 256;
|
final double typeDouble = type / 256;
|
||||||
int type1 = typeDouble.toInt();
|
final int type1 = typeDouble.toInt();
|
||||||
int type2 = type % 256;
|
final int type2 = type % 256;
|
||||||
data.add(type1);
|
data.add(type1);
|
||||||
data.add(type2);
|
data.add(type2);
|
||||||
|
|
||||||
// 锁id 40
|
// 锁id 40
|
||||||
int lockIDLength = utf8.encode(lockID!).length;
|
final int lockIDLength = utf8.encode(lockID!).length;
|
||||||
data.addAll(utf8.encode(lockID!));
|
data.addAll(utf8.encode(lockID!));
|
||||||
data = getFixedLengthList(data, 40 - lockIDLength);
|
data = getFixedLengthList(data, 40 - lockIDLength);
|
||||||
|
|
||||||
//userID 要接受钥匙的用户的useid 20
|
//userID 要接受钥匙的用户的useid 20
|
||||||
int userIDLength = utf8.encode(userID!).length;
|
final int userIDLength = utf8.encode(userID!).length;
|
||||||
data.addAll(utf8.encode(userID!));
|
data.addAll(utf8.encode(userID!));
|
||||||
data = getFixedLengthList(data, 20 - userIDLength);
|
data = getFixedLengthList(data, 20 - userIDLength);
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ class UpdataLockPalmVeinListCommand extends SenderProtocol {
|
|||||||
//AuthCodeLen 1
|
//AuthCodeLen 1
|
||||||
data.add(0);
|
data.add(0);
|
||||||
} else {
|
} else {
|
||||||
List<int> authCodeData = [];
|
final List<int> authCodeData = <int>[];
|
||||||
//KeyID
|
//KeyID
|
||||||
authCodeData.addAll(utf8.encode(lockID!));
|
authCodeData.addAll(utf8.encode(lockID!));
|
||||||
|
|
||||||
@ -86,14 +86,14 @@ class UpdataLockPalmVeinListCommand extends SenderProtocol {
|
|||||||
authCodeData.addAll(signKey!);
|
authCodeData.addAll(signKey!);
|
||||||
|
|
||||||
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
||||||
var authCode = crypto.md5.convert(authCodeData);
|
final crypto.Digest authCode = crypto.md5.convert(authCodeData);
|
||||||
|
|
||||||
data.add(authCode.bytes.length);
|
data.add(authCode.bytes.length);
|
||||||
data.addAll(authCode.bytes);
|
data.addAll(authCode.bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((data.length % 16) != 0) {
|
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++) {
|
for (int i = 0; i < add; i++) {
|
||||||
data.add(0);
|
data.add(0);
|
||||||
}
|
}
|
||||||
@ -111,7 +111,7 @@ class UpdataLockPalmVeinListReply extends Reply {
|
|||||||
: super.parseData(commandType, dataDetail) {
|
: super.parseData(commandType, dataDetail) {
|
||||||
data = dataDetail;
|
data = dataDetail;
|
||||||
|
|
||||||
int status = data[2];
|
final int status = data[2];
|
||||||
errorWithStstus(status);
|
errorWithStstus(status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -10,16 +10,6 @@ import 'package:crypto/crypto.dart' as crypto;
|
|||||||
import '../sm4Encipher/sm4.dart';
|
import '../sm4Encipher/sm4.dart';
|
||||||
|
|
||||||
class UpdataLockPasswordListCommand extends SenderProtocol {
|
class UpdataLockPasswordListCommand extends SenderProtocol {
|
||||||
|
|
||||||
String? lockID;
|
|
||||||
String? keyID;
|
|
||||||
String? userID;
|
|
||||||
int? page;
|
|
||||||
int? countReq;
|
|
||||||
List<int>? token;
|
|
||||||
int? needAuthor;
|
|
||||||
List<int>? signKey;
|
|
||||||
List<int>? privateKey;
|
|
||||||
UpdataLockPasswordListCommand({
|
UpdataLockPasswordListCommand({
|
||||||
this.lockID,
|
this.lockID,
|
||||||
this.keyID,
|
this.keyID,
|
||||||
@ -32,6 +22,16 @@ class UpdataLockPasswordListCommand extends SenderProtocol {
|
|||||||
this.privateKey
|
this.privateKey
|
||||||
}) : super(CommandType.updataLockPasswordList);
|
}) : super(CommandType.updataLockPasswordList);
|
||||||
|
|
||||||
|
String? lockID;
|
||||||
|
String? keyID;
|
||||||
|
String? userID;
|
||||||
|
int? page;
|
||||||
|
int? countReq;
|
||||||
|
List<int>? token;
|
||||||
|
int? needAuthor;
|
||||||
|
List<int>? signKey;
|
||||||
|
List<int>? privateKey;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'UpdataLockPasswordListCommand{lockID: $lockID, keyID:$keyID userID: $userID, '
|
return 'UpdataLockPasswordListCommand{lockID: $lockID, keyID:$keyID userID: $userID, '
|
||||||
@ -41,24 +41,24 @@ class UpdataLockPasswordListCommand extends SenderProtocol {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
List<int> messageDetail() {
|
List<int> messageDetail() {
|
||||||
List<int> data = [];
|
List<int> data = <int>[];
|
||||||
List<int> ebcData = [];
|
List<int> ebcData = <int>[];
|
||||||
|
|
||||||
// 指令类型
|
// 指令类型
|
||||||
int type = commandType!.typeValue;
|
final int type = commandType!.typeValue;
|
||||||
double typeDouble = type / 256;
|
final double typeDouble = type / 256;
|
||||||
int type1 = typeDouble.toInt();
|
final int type1 = typeDouble.toInt();
|
||||||
int type2 = type % 256;
|
final int type2 = type % 256;
|
||||||
data.add(type1);
|
data.add(type1);
|
||||||
data.add(type2);
|
data.add(type2);
|
||||||
|
|
||||||
// 锁id 40
|
// 锁id 40
|
||||||
int lockIDLength = utf8.encode(lockID!).length;
|
final int lockIDLength = utf8.encode(lockID!).length;
|
||||||
data.addAll(utf8.encode(lockID!));
|
data.addAll(utf8.encode(lockID!));
|
||||||
data = getFixedLengthList(data, 40 - lockIDLength);
|
data = getFixedLengthList(data, 40 - lockIDLength);
|
||||||
|
|
||||||
//userID 要接受钥匙的用户的useid 20
|
//userID 要接受钥匙的用户的useid 20
|
||||||
int userIDLength = utf8.encode(userID!).length;
|
final int userIDLength = utf8.encode(userID!).length;
|
||||||
data.addAll(utf8.encode(userID!));
|
data.addAll(utf8.encode(userID!));
|
||||||
data = getFixedLengthList(data, 20 - userIDLength);
|
data = getFixedLengthList(data, 20 - userIDLength);
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ class UpdataLockPasswordListCommand extends SenderProtocol {
|
|||||||
//AuthCodeLen 1
|
//AuthCodeLen 1
|
||||||
data.add(0);
|
data.add(0);
|
||||||
} else {
|
} else {
|
||||||
List<int> authCodeData = [];
|
final List<int> authCodeData = <int>[];
|
||||||
//KeyID
|
//KeyID
|
||||||
authCodeData.addAll(utf8.encode(lockID!));
|
authCodeData.addAll(utf8.encode(lockID!));
|
||||||
|
|
||||||
@ -88,14 +88,14 @@ class UpdataLockPasswordListCommand extends SenderProtocol {
|
|||||||
authCodeData.addAll(signKey!);
|
authCodeData.addAll(signKey!);
|
||||||
|
|
||||||
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
||||||
var authCode = crypto.md5.convert(authCodeData);
|
final crypto.Digest authCode = crypto.md5.convert(authCodeData);
|
||||||
|
|
||||||
data.add(authCode.bytes.length);
|
data.add(authCode.bytes.length);
|
||||||
data.addAll(authCode.bytes);
|
data.addAll(authCode.bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((data.length % 16) != 0) {
|
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++) {
|
for (int i = 0; i < add; i++) {
|
||||||
data.add(0);
|
data.add(0);
|
||||||
}
|
}
|
||||||
@ -113,7 +113,7 @@ class UpdataLockPasswordListReply extends Reply {
|
|||||||
: super.parseData(commandType, dataDetail) {
|
: super.parseData(commandType, dataDetail) {
|
||||||
data = dataDetail;
|
data = dataDetail;
|
||||||
|
|
||||||
int status = data[2];
|
final int status = data[2];
|
||||||
errorWithStstus(status);
|
errorWithStstus(status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -41,8 +41,8 @@ class UpdataLockRemoteControlListCommand extends SenderProtocol {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
List<int> messageDetail() {
|
List<int> messageDetail() {
|
||||||
List<int> data = [];
|
List<int> data = <int>[];
|
||||||
List<int> ebcData = [];
|
List<int> ebcData = <int>[];
|
||||||
|
|
||||||
// 指令类型
|
// 指令类型
|
||||||
final int type = commandType!.typeValue;
|
final int type = commandType!.typeValue;
|
||||||
@ -75,7 +75,7 @@ class UpdataLockRemoteControlListCommand extends SenderProtocol {
|
|||||||
//AuthCodeLen 1
|
//AuthCodeLen 1
|
||||||
data.add(0);
|
data.add(0);
|
||||||
} else {
|
} else {
|
||||||
final List<int> authCodeData = [];
|
final List<int> authCodeData = <int>[];
|
||||||
//KeyID
|
//KeyID
|
||||||
authCodeData.addAll(utf8.encode(lockID!));
|
authCodeData.addAll(utf8.encode(lockID!));
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ class UpdataLockRemoteControlListCommand extends SenderProtocol {
|
|||||||
authCodeData.addAll(signKey!);
|
authCodeData.addAll(signKey!);
|
||||||
|
|
||||||
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
||||||
final authCode = crypto.md5.convert(authCodeData);
|
final crypto.Digest authCode = crypto.md5.convert(authCodeData);
|
||||||
|
|
||||||
data.add(authCode.bytes.length);
|
data.add(authCode.bytes.length);
|
||||||
data.addAll(authCode.bytes);
|
data.addAll(authCode.bytes);
|
||||||
|
|||||||
@ -1,16 +1,19 @@
|
|||||||
import 'dart:typed_data';
|
|
||||||
|
|
||||||
import 'package:star_lock/app_settings/app_settings.dart';
|
import 'package:star_lock/app_settings/app_settings.dart';
|
||||||
|
|
||||||
import 'io_tool/io_manager.dart';
|
import 'io_tool/io_manager.dart';
|
||||||
import 'io_tool/io_tool.dart';
|
|
||||||
import 'io_type.dart';
|
import 'io_type.dart';
|
||||||
|
|
||||||
abstract class IOData {
|
abstract class IOData {
|
||||||
List<int> messageDetail();
|
List<int> 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);
|
// var uint8View1 = Uint8List(300);
|
||||||
|
|
||||||
CommandType? commandType; //指令类型
|
CommandType? commandType; //指令类型
|
||||||
@ -21,17 +24,12 @@ abstract class SenderProtocol extends IOData {
|
|||||||
0X02
|
0X02
|
||||||
]; //帧头 固定取值 0XEF01EE02,长度 4 字节
|
]; //帧头 固定取值 0XEF01EE02,长度 4 字节
|
||||||
final int ask = 0X01; // 包类型:0X01 表示请求包,0X11 表示应答包,长度 1 字节
|
final int ask = 0X01; // 包类型:0X01 表示请求包,0X11 表示应答包,长度 1 字节
|
||||||
int? _commandIndex = 1; //包序号
|
int _commandIndex = 1; //包序号
|
||||||
|
|
||||||
int identifier =
|
int identifier =
|
||||||
0x20; // 高 4 位表示包版本,低 4 位用来指示后面数据的加密类型,长度为 1 字节,加密类型取值说明,0:明文,1:AES128,2:SM4(事先约定密钥),3:SM4(设备指定密钥)
|
0x20; // 高 4 位表示包版本,低 4 位用来指示后面数据的加密类型,长度为 1 字节,加密类型取值说明,0:明文,1:AES128,2:SM4(事先约定密钥),3:SM4(设备指定密钥)
|
||||||
|
|
||||||
List<int>? commandData = <int>[]; //数据块
|
List<int>? commandData = <int>[];
|
||||||
// final int? tail = 0xFF; //用来校验包的完整性,采用 CRC 校验方法,长度为 2 个字节
|
|
||||||
|
|
||||||
SenderProtocol(this.commandType) {
|
|
||||||
_commandIndex = IoManager().commandIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
void printLog(List<int> data) {
|
void printLog(List<int> data) {
|
||||||
AppLog.log(
|
AppLog.log(
|
||||||
@ -39,10 +37,10 @@ abstract class SenderProtocol extends IOData {
|
|||||||
? '子命令:${data[3]}' : ''} \n参数是:\n${toString()} \n加密之前数据是:\n$data 长度是:${data.length}");
|
? '子命令:${data[3]}' : ''} \n参数是:\n${toString()} \n加密之前数据是:\n$data 长度是:${data.length}");
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO:拼装数据
|
// 拼装数据
|
||||||
List<int> packageData() {
|
List<int> packageData() {
|
||||||
commandData = messageDetail();
|
commandData = messageDetail();
|
||||||
List<int> commandList = <int>[];
|
final List<int> commandList = <int>[];
|
||||||
|
|
||||||
// 帧头
|
// 帧头
|
||||||
commandList.addAll(header);
|
commandList.addAll(header);
|
||||||
@ -51,24 +49,24 @@ abstract class SenderProtocol extends IOData {
|
|||||||
commandList.add(ask); //包类型
|
commandList.add(ask); //包类型
|
||||||
|
|
||||||
// 包序号
|
// 包序号
|
||||||
int commandIndexChange = _commandIndex!;
|
final int commandIndexChange = _commandIndex;
|
||||||
double commandIndexChangeDouble = commandIndexChange / 256;
|
final double commandIndexChangeDouble = commandIndexChange / 256;
|
||||||
int commandIndexChang1 = commandIndexChangeDouble.toInt();
|
final int commandIndexChang1 = commandIndexChangeDouble.toInt();
|
||||||
int commandIndexChang2 = commandIndexChange % 256;
|
final int commandIndexChang2 = commandIndexChange % 256;
|
||||||
commandList.add(commandIndexChang1);
|
commandList.add(commandIndexChang1);
|
||||||
commandList.add(commandIndexChang2);
|
commandList.add(commandIndexChang2);
|
||||||
|
|
||||||
// 包标识
|
// 包标识
|
||||||
// 指令类型 高 4 位表示包版本,低 4 位用来指示后面数据的加密类型,长度为 1 字节,加密类型取值说明,0:明文,1:AES128,2:SM4(事先约定密钥),3:SM4(设备指定密钥)
|
// 指令类型 高 4 位表示包版本,低 4 位用来指示后面数据的加密类型,长度为 1 字节,加密类型取值说明,0:明文,1:AES128,2:SM4(事先约定密钥),3:SM4(设备指定密钥)
|
||||||
int value = identifierValue();
|
final int value = identifierValue();
|
||||||
commandList.add(value);
|
commandList.add(value);
|
||||||
|
|
||||||
// 数据长度
|
// 数据长度
|
||||||
int dataLen = dataSourceLength();
|
final int dataLen = dataSourceLength();
|
||||||
// commandList.add(dataLength);
|
// commandList.add(dataLength);
|
||||||
|
|
||||||
// var dataLen = 42;
|
// var dataLen = 42;
|
||||||
double dataLength = dataLen / 256;
|
final double dataLength = dataLen / 256;
|
||||||
commandList.add(dataLength.toInt());
|
commandList.add(dataLength.toInt());
|
||||||
commandList.add(dataLen % 256);
|
commandList.add(dataLen % 256);
|
||||||
commandList.add(dataLength.toInt());
|
commandList.add(dataLength.toInt());
|
||||||
@ -78,10 +76,10 @@ abstract class SenderProtocol extends IOData {
|
|||||||
commandList.addAll(commandData!); //数据块
|
commandList.addAll(commandData!); //数据块
|
||||||
|
|
||||||
// 校验位
|
// 校验位
|
||||||
int mcrc = crc_16(commandList);
|
final int mcrc = crc_16(commandList);
|
||||||
double mcrcDouble = mcrc / 256;
|
final double mcrcDouble = mcrc / 256;
|
||||||
int mcrcDouble1 = mcrcDouble.toInt();
|
final int mcrcDouble1 = mcrcDouble.toInt();
|
||||||
int mcrcDouble2 = mcrc % 256;
|
final int mcrcDouble2 = mcrc % 256;
|
||||||
commandList.add(mcrcDouble1); //帧尾
|
commandList.add(mcrcDouble1); //帧尾
|
||||||
commandList.add(mcrcDouble2);
|
commandList.add(mcrcDouble2);
|
||||||
return commandList;
|
return commandList;
|
||||||
@ -91,7 +89,7 @@ abstract class SenderProtocol extends IOData {
|
|||||||
// 指令类型 高 4 位表示包版本,低 4 位用来指示后面数据的加密类型,长度为 1 字节,加密类型取值说明,0:明文,1:AES128,2:SM4(事先约定密钥),3:SM4(设备指定密钥)
|
// 指令类型 高 4 位表示包版本,低 4 位用来指示后面数据的加密类型,长度为 1 字节,加密类型取值说明,0:明文,1:AES128,2:SM4(事先约定密钥),3:SM4(设备指定密钥)
|
||||||
int identifierValue() => commandType!.identifierValue;
|
int identifierValue() => commandType!.identifierValue;
|
||||||
|
|
||||||
//TODO:长度
|
// 长度
|
||||||
int dataSourceLength() => commandData!.length;
|
int dataSourceLength() => commandData!.length;
|
||||||
|
|
||||||
List<int> crcTable = <int>[
|
List<int> crcTable = <int>[
|
||||||
@ -353,8 +351,7 @@ abstract class SenderProtocol extends IOData {
|
|||||||
0x1ef0
|
0x1ef0
|
||||||
];
|
];
|
||||||
|
|
||||||
int crc_16(buffer) {
|
int crc_16(List<int> buffer) {
|
||||||
var len = buffer.length;
|
|
||||||
int value_ = 0x0000; //0xa635; //初始值,根据CRC类型设定
|
int value_ = 0x0000; //0xa635; //初始值,根据CRC类型设定
|
||||||
int tmp;
|
int tmp;
|
||||||
for (int i = 0; i < buffer.length; i++) {
|
for (int i = 0; i < buffer.length; i++) {
|
||||||
@ -366,7 +363,7 @@ abstract class SenderProtocol extends IOData {
|
|||||||
return value_;
|
return value_;
|
||||||
}
|
}
|
||||||
|
|
||||||
int reverse8(data) {
|
int reverse8(int data) {
|
||||||
int i;
|
int i;
|
||||||
int temp = 0;
|
int temp = 0;
|
||||||
for (i = 0; i < 8; i++) {
|
for (i = 0; i < 8; i++) {
|
||||||
@ -376,7 +373,7 @@ abstract class SenderProtocol extends IOData {
|
|||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
int reverse16(data) {
|
int reverse16(int data) {
|
||||||
int i;
|
int i;
|
||||||
int temp = 0;
|
int temp = 0;
|
||||||
for (i = 0; i < 16; i++) {
|
for (i = 0; i < 16; i++) {
|
||||||
|
|||||||
@ -4,14 +4,14 @@ enum DataTransmissionMode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class IoManager {
|
class IoManager {
|
||||||
|
factory IoManager() => share();
|
||||||
|
IoManager._init();
|
||||||
|
|
||||||
static IoManager? _ioManager;
|
static IoManager? _ioManager;
|
||||||
IoManager._init();
|
|
||||||
static IoManager share(){
|
static IoManager share(){
|
||||||
_ioManager ??= IoManager._init();
|
_ioManager ??= IoManager._init();
|
||||||
return _ioManager!;
|
return _ioManager!;
|
||||||
}
|
}
|
||||||
factory IoManager() => share();
|
|
||||||
IoManager get manager => share();
|
IoManager get manager => share();
|
||||||
|
|
||||||
//数据传输方式
|
//数据传输方式
|
||||||
@ -23,7 +23,7 @@ class IoManager {
|
|||||||
|
|
||||||
///协议帧序号
|
///协议帧序号
|
||||||
int _commandIndex = 1;
|
int _commandIndex = 1;
|
||||||
configCommandIdx(int idx) => _commandIndex = idx;
|
int configCommandIdx(int idx) => _commandIndex = idx;
|
||||||
Future<void> increaseCommandIndex() async {
|
Future<void> increaseCommandIndex() async {
|
||||||
_commandIndex < 255 ? _commandIndex++ : _commandIndex = 0;
|
_commandIndex < 255 ? _commandIndex++ : _commandIndex = 0;
|
||||||
}
|
}
|
||||||
@ -31,8 +31,8 @@ class IoManager {
|
|||||||
int get commandIndex => _commandIndex;
|
int get commandIndex => _commandIndex;
|
||||||
|
|
||||||
/// 当前设备连接的lockId
|
/// 当前设备连接的lockId
|
||||||
String _currentDeviceLockId = "";
|
String _currentDeviceLockId = '';
|
||||||
configCurrentDeviceLockId(String lockId) => _currentDeviceLockId = lockId;
|
String configCurrentDeviceLockId(String lockId) => _currentDeviceLockId = lockId;
|
||||||
String get getCurrentDeviceLockId => _currentDeviceLockId;
|
String get getCurrentDeviceLockId => _currentDeviceLockId;
|
||||||
|
|
||||||
void resetAllFlags() {
|
void resetAllFlags() {
|
||||||
|
|||||||
@ -19,7 +19,7 @@ class EventSendModel {
|
|||||||
this.serviceId,
|
this.serviceId,
|
||||||
this.characteristicId,
|
this.characteristicId,
|
||||||
this.allowLongWrite});
|
this.allowLongWrite});
|
||||||
List<int> data = [];
|
List<int> data = <int>[];
|
||||||
String? topic = '';
|
String? topic = '';
|
||||||
DataChannel? sendChannel;
|
DataChannel? sendChannel;
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
|
|
||||||
@ -113,7 +114,7 @@ String uint8ToHex(Uint8List byteArr) {
|
|||||||
return String.fromCharCodes(result); //Unicode转回为对应字符,生成字符串返回
|
return String.fromCharCodes(result); //Unicode转回为对应字符,生成字符串返回
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO:int->两个字节 List 低字节在前,高字节在后(大端存储)=>嵌入式小端接收(协议用到)
|
// int->两个字节 List 低字节在前,高字节在后(大端存储)=>嵌入式小端接收(协议用到)
|
||||||
|
|
||||||
int byteInt8(List<int> dataDetail, int index) => _toInt8(dataDetail[index]);
|
int byteInt8(List<int> dataDetail, int index) => _toInt8(dataDetail[index]);
|
||||||
int _toInt8(int value) {
|
int _toInt8(int value) {
|
||||||
@ -165,7 +166,7 @@ List<int> intToInt8List(int value) => <int>[value];
|
|||||||
|
|
||||||
List<int> intToByte2ListHigh(int value) => <int>[value, value >> 8];
|
List<int> intToByte2ListHigh(int value) => <int>[value, value >> 8];
|
||||||
|
|
||||||
//TODO:int->4个字节List 低字节在前,高字节在后(大端存储) 1byte = 8bit
|
// int->4个字节List 低字节在前,高字节在后(大端存储) 1byte = 8bit
|
||||||
List<int> intToByte4ListHigh(int value) =>
|
List<int> intToByte4ListHigh(int value) =>
|
||||||
<int>[value, value >> 8, value >> 16, value >> 24];
|
<int>[value, value >> 8, value >> 16, value >> 24];
|
||||||
|
|
||||||
@ -217,9 +218,6 @@ int _toUInt32(int value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool checkListIndex(List<int> dataDetail, int index, int offsetLength) {
|
bool checkListIndex(List<int> dataDetail, int index, int offsetLength) {
|
||||||
if (dataDetail == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
final int len = dataDetail.length;
|
final int len = dataDetail.length;
|
||||||
final bool result = index + offsetLength > len;
|
final bool result = index + offsetLength > len;
|
||||||
if (result) {}
|
if (result) {}
|
||||||
@ -262,7 +260,7 @@ List<List<T>> splitList<T>(List<T> list, int len) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO:int->两个字节 List 高字节在前,低字节在后(小端存储) 本工程只有配置 WiFi用到的!!!!
|
// int->两个字节 List 高字节在前,低字节在后(小端存储) 本工程只有配置 WiFi用到的!!!!
|
||||||
List<int> intToByte2ListLow(int value) => <int>[value >> 8, value];
|
List<int> intToByte2ListLow(int value) => <int>[value >> 8, value];
|
||||||
|
|
||||||
String radixHex16String(List<int> codeUnits) {
|
String radixHex16String(List<int> codeUnits) {
|
||||||
|
|||||||
@ -3,19 +3,19 @@
|
|||||||
import 'package:event_bus/event_bus.dart';
|
import 'package:event_bus/event_bus.dart';
|
||||||
|
|
||||||
class EventBusManager {
|
class EventBusManager {
|
||||||
EventBus? eventBus;
|
|
||||||
|
|
||||||
static EventBusManager? _manager;
|
factory EventBusManager() => shareManager();
|
||||||
EventBusManager._init(){
|
EventBusManager._init(){
|
||||||
eventBus = EventBus(sync: false);
|
eventBus = EventBus(sync: false);
|
||||||
}
|
}
|
||||||
|
EventBus? eventBus;
|
||||||
|
|
||||||
|
static EventBusManager? _manager;
|
||||||
|
|
||||||
static EventBusManager shareManager(){
|
static EventBusManager shareManager(){
|
||||||
_manager ??= EventBusManager._init();
|
_manager ??= EventBusManager._init();
|
||||||
return _manager!;
|
return _manager!;
|
||||||
}
|
}
|
||||||
|
|
||||||
factory EventBusManager() => shareManager();
|
|
||||||
EventBusManager get manager => shareManager();
|
EventBusManager get manager => shareManager();
|
||||||
//发送事件
|
//发送事件
|
||||||
eventBusFir(dynamic event) {
|
eventBusFir(dynamic event) {
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
//TODO:发送指令类型
|
// 发送指令类型
|
||||||
enum CommandType {
|
enum CommandType {
|
||||||
addUser, //增加用户 = 0x3001
|
addUser, //增加用户 = 0x3001
|
||||||
deletUser, //删除用户 = 0x3002
|
deletUser, //删除用户 = 0x3002
|
||||||
|
|||||||
@ -123,8 +123,8 @@ class CommandReciverManager {
|
|||||||
parseData(oriDataList).then((Reply? value) async {
|
parseData(oriDataList).then((Reply? value) async {
|
||||||
EasyLoading.dismiss();
|
EasyLoading.dismiss();
|
||||||
await EventBusManager().eventBusFir(value);
|
await EventBusManager().eventBusFir(value);
|
||||||
}).catchError((error) {
|
}).catchError((Object error) {
|
||||||
AppLog.log('APP解析数据时发生错误: $error');
|
AppLog.log('APP解析数据时发生错误: ${error.toString()}');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -69,9 +69,9 @@ class SenderBeforeDataManage {
|
|||||||
switch (status) {
|
switch (status) {
|
||||||
case 0x00:
|
case 0x00:
|
||||||
//成功
|
//成功
|
||||||
var userNoData = reply.data.sublist(47, 49);
|
final List<int> userNoData = reply.data.sublist(47, 49);
|
||||||
CommonDataManage().currentLockUserNo = listChangInt(userNoData);
|
CommonDataManage().currentLockUserNo = listChangInt(userNoData);
|
||||||
CommonDataManage().currentKeyInfo.lockUserNo = CommonDataManage().currentLockUserNo;
|
CommonDataManage().currentKeyInfo.lockUserNo = CommonDataManage().currentLockUserNo;
|
||||||
|
|
||||||
_updateLockUserNo(userNoData);
|
_updateLockUserNo(userNoData);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -21,7 +21,7 @@ class CommandSenderManager {
|
|||||||
|
|
||||||
static CommandSenderManager getInstance() => _manager;
|
static CommandSenderManager getInstance() => _manager;
|
||||||
|
|
||||||
init() {
|
void init() {
|
||||||
_initLockAddUserSucceedEvent();
|
_initLockAddUserSucceedEvent();
|
||||||
_initTransferSmartLockSucceedEvent();
|
_initTransferSmartLockSucceedEvent();
|
||||||
}
|
}
|
||||||
@ -149,7 +149,7 @@ class CommandSenderManager {
|
|||||||
// bufferList = [];
|
// bufferList = [];
|
||||||
// }
|
// }
|
||||||
|
|
||||||
dispose() {
|
void dispose() {
|
||||||
_passCurrentLockInformationEvent?.cancel();
|
_passCurrentLockInformationEvent?.cancel();
|
||||||
_transferSmartLockEvent?.cancel();
|
_transferSmartLockEvent?.cancel();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import 'utils/utils.dart';
|
|||||||
enum SM4CryptoMode { ECB, CBC }
|
enum SM4CryptoMode { ECB, CBC }
|
||||||
|
|
||||||
class SM4 {
|
class SM4 {
|
||||||
static const List<int> S_BOX = [
|
static const List<int> S_BOX = <int>[
|
||||||
0xd6,
|
0xd6,
|
||||||
0x90,
|
0x90,
|
||||||
0xe9,
|
0xe9,
|
||||||
@ -263,9 +263,9 @@ class SM4 {
|
|||||||
0x48
|
0x48
|
||||||
];
|
];
|
||||||
|
|
||||||
static const List<int> FK = [0xA3B1BAC6, 0x56AA3350, 0x677D9197, 0xB27022DC];
|
static const List<int> FK = <int>[0xA3B1BAC6, 0x56AA3350, 0x677D9197, 0xB27022DC];
|
||||||
|
|
||||||
static const List<int> CK = [
|
static const List<int> CK = <int>[
|
||||||
0x00070e15,
|
0x00070e15,
|
||||||
0x1c232a31,
|
0x1c232a31,
|
||||||
0x383f464d,
|
0x383f464d,
|
||||||
@ -306,8 +306,8 @@ class SM4 {
|
|||||||
|
|
||||||
static const int blockSize = 16;
|
static const int blockSize = 16;
|
||||||
|
|
||||||
static final _encryptKey = List<int>.filled(32, 0);
|
static final List<int> _encryptKey = List<int>.filled(32, 0);
|
||||||
static final _decryptKey = List<int>.filled(32, 0);
|
static final List<int> _decryptKey = List<int>.filled(32, 0);
|
||||||
|
|
||||||
static int _readUint32BE(List<int> b, int i) {
|
static int _readUint32BE(List<int> b, int i) {
|
||||||
return ((b[i] & 0xff) << 24) |
|
return ((b[i] & 0xff) << 24) |
|
||||||
@ -317,20 +317,20 @@ class SM4 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void _writeUint32BE(int n, List<int> b, int i) {
|
static void _writeUint32BE(int n, List<int> b, int i) {
|
||||||
b[i] = ((n >> 24) & 0xff);
|
b[i] = (n >> 24) & 0xff;
|
||||||
b[i + 1] = ((n >> 16) & 0xff);
|
b[i + 1] = (n >> 16) & 0xff;
|
||||||
b[i + 2] = ((n >> 8) & 0xff);
|
b[i + 2] = (n >> 8) & 0xff;
|
||||||
b[i + 3] = n & 0xff;
|
b[i + 3] = n & 0xff;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _Sbox(int inch) => S_BOX[inch & 0xFF];
|
static int _Sbox(int inch) => S_BOX[inch & 0xFF];
|
||||||
|
|
||||||
static int _sm4F(int x0, int x1, int x2, int x3, int rk) {
|
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 bb = 0;
|
||||||
int c = 0;
|
int c = 0;
|
||||||
List<int> a = List<int>.filled(4, 0);
|
final List<int> a = List<int>.filled(4, 0);
|
||||||
List<int> b = List<int>.filled(4, 0);
|
final List<int> b = List<int>.filled(4, 0);
|
||||||
_writeUint32BE(x, a, 0);
|
_writeUint32BE(x, a, 0);
|
||||||
b[0] = _Sbox(a[0]);
|
b[0] = _Sbox(a[0]);
|
||||||
b[1] = _Sbox(a[1]);
|
b[1] = _Sbox(a[1]);
|
||||||
@ -348,20 +348,20 @@ class SM4 {
|
|||||||
|
|
||||||
static int _calculateRoundKey(int key) {
|
static int _calculateRoundKey(int key) {
|
||||||
int roundKey = 0;
|
int roundKey = 0;
|
||||||
List<int> keyBytes = List<int>.filled(4, 0);
|
final List<int> keyBytes = List<int>.filled(4, 0);
|
||||||
List<int> sboxBytes = List<int>.filled(4, 0);
|
final List<int> sboxBytes = List<int>.filled(4, 0);
|
||||||
_writeUint32BE(key, keyBytes, 0);
|
_writeUint32BE(key, keyBytes, 0);
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
sboxBytes[i] = _Sbox(keyBytes[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);
|
roundKey = temp ^ SMUtils.leftShift(temp, 13) ^ SMUtils.leftShift(temp, 23);
|
||||||
return roundKey;
|
return roundKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setKey(List<int> key) {
|
static void setKey(List<int> key) {
|
||||||
List<int> keyBytes = key;
|
final List<int> keyBytes = key;
|
||||||
List<int> intermediateKeys = List<int>.filled(36, 0);
|
final List<int> intermediateKeys = List<int>.filled(36, 0);
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
intermediateKeys[i] = _readUint32BE(keyBytes, i * 4) ^ FK[i];
|
intermediateKeys[i] = _readUint32BE(keyBytes, i * 4) ^ FK[i];
|
||||||
}
|
}
|
||||||
@ -375,7 +375,7 @@ class SM4 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 16; i++) {
|
for (int i = 0; i < 16; i++) {
|
||||||
int temp = _encryptKey[i];
|
final int temp = _encryptKey[i];
|
||||||
_decryptKey[i] = _encryptKey[31 - i];
|
_decryptKey[i] = _encryptKey[31 - i];
|
||||||
_decryptKey[31 - i] = temp;
|
_decryptKey[31 - i] = temp;
|
||||||
}
|
}
|
||||||
@ -383,7 +383,7 @@ class SM4 {
|
|||||||
|
|
||||||
static void _round(List<int> sk, List<int> input, List<int> output) {
|
static void _round(List<int> sk, List<int> input, List<int> output) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
List<int> ulbuf = List<int>.filled(36, 0);
|
final List<int> ulbuf = List<int>.filled(36, 0);
|
||||||
ulbuf[0] = _readUint32BE(input, 0);
|
ulbuf[0] = _readUint32BE(input, 0);
|
||||||
ulbuf[1] = _readUint32BE(input, 4);
|
ulbuf[1] = _readUint32BE(input, 4);
|
||||||
ulbuf[2] = _readUint32BE(input, 8);
|
ulbuf[2] = _readUint32BE(input, 8);
|
||||||
@ -404,7 +404,7 @@ class SM4 {
|
|||||||
final int padLen = blockSize - (input.length % blockSize);
|
final int padLen = blockSize - (input.length % blockSize);
|
||||||
|
|
||||||
if (mode == SM4_ENCRYPT) {
|
if (mode == SM4_ENCRYPT) {
|
||||||
final paddedList = List<int>.filled(input.length + padLen, 0);
|
final List<int> paddedList = List<int>.filled(input.length + padLen, 0);
|
||||||
paddedList.setRange(0, input.length, input);
|
paddedList.setRange(0, input.length, input);
|
||||||
for (int i = input.length; i < paddedList.length; i++) {
|
for (int i = input.length; i < paddedList.length; i++) {
|
||||||
paddedList[i] = padLen;
|
paddedList[i] = padLen;
|
||||||
@ -423,23 +423,24 @@ class SM4 {
|
|||||||
List<int> data, int flag, SM4CryptoMode mode, String? iv) {
|
List<int> data, int flag, SM4CryptoMode mode, String? iv) {
|
||||||
late List<int> lastVector;
|
late List<int> lastVector;
|
||||||
if (mode == SM4CryptoMode.CBC) {
|
if (mode == SM4CryptoMode.CBC) {
|
||||||
if (iv == null || iv.length != 32)
|
if (iv == null || iv.length != 32) {
|
||||||
throw Exception("IV must be a string of length 16");
|
throw Exception('IV must be a string of length 16');
|
||||||
else
|
} else {
|
||||||
lastVector = SMUtils.hexStringToBytes(iv);
|
lastVector = SMUtils.hexStringToBytes(iv);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
final key = (flag == SM4_ENCRYPT) ? _encryptKey : _decryptKey;
|
final List<int> key = (flag == SM4_ENCRYPT) ? _encryptKey : _decryptKey;
|
||||||
if (flag == SM4_ENCRYPT) {
|
if (flag == SM4_ENCRYPT) {
|
||||||
data = _padding(data, SM4_ENCRYPT);
|
data = _padding(data, SM4_ENCRYPT);
|
||||||
}
|
}
|
||||||
final length = data.length;
|
final int length = data.length;
|
||||||
final List<int> output = [];
|
final List<int> output = <int>[];
|
||||||
|
|
||||||
for (int offset = 0; offset < length; offset += blockSize) {
|
for (int offset = 0; offset < length; offset += blockSize) {
|
||||||
final outData = List<int>.filled(blockSize, 0);
|
final List<int> outData = List<int>.filled(blockSize, 0);
|
||||||
final copyLen =
|
final int copyLen =
|
||||||
(offset + blockSize <= length) ? blockSize : length - offset;
|
(offset + blockSize <= length) ? blockSize : length - offset;
|
||||||
final input = data.sublist(offset, offset + copyLen);
|
final List<int> input = data.sublist(offset, offset + copyLen);
|
||||||
if (mode == SM4CryptoMode.CBC && flag == SM4_ENCRYPT) {
|
if (mode == SM4CryptoMode.CBC && flag == SM4_ENCRYPT) {
|
||||||
for (int i = 0; i < blockSize; i++) {
|
for (int i = 0; i < blockSize; i++) {
|
||||||
input[i] = input[i] ^ lastVector[i];
|
input[i] = input[i] ^ lastVector[i];
|
||||||
@ -476,18 +477,18 @@ class SM4 {
|
|||||||
// /// auto add 0x00
|
// /// auto add 0x00
|
||||||
static List<int> _autoAddZero(List<int> list) {
|
static List<int> _autoAddZero(List<int> list) {
|
||||||
/// supplementary list
|
/// supplementary list
|
||||||
List<int> supplementList = List.filled(16, 0x00);
|
final List<int> supplementList = List.filled(16, 0x00);
|
||||||
|
|
||||||
/// complete list
|
/// complete list
|
||||||
List<int> completeList = [...list, ...supplementList].sublist(0, 16);
|
final List<int> completeList = <int>[...list, ...supplementList].sublist(0, 16);
|
||||||
return completeList;
|
return completeList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// hex byte list to hex string
|
/// hex byte list to hex string
|
||||||
static String _listToHex(List<int> arr) {
|
static String _listToHex(List<int> arr) {
|
||||||
String hexString = arr
|
final String hexString = arr
|
||||||
.map((item) {
|
.map((int item) {
|
||||||
String itemHexString = item.toRadixString(16);
|
final String itemHexString = item.toRadixString(16);
|
||||||
// The hexadecimal notation is 0123456789ABCDEF
|
// The hexadecimal notation is 0123456789ABCDEF
|
||||||
//if there is a single one, add 0
|
//if there is a single one, add 0
|
||||||
if (itemHexString.length == 1) {
|
if (itemHexString.length == 1) {
|
||||||
@ -504,7 +505,7 @@ class SM4 {
|
|||||||
|
|
||||||
static String createHexKey({
|
static String createHexKey({
|
||||||
required String key,
|
required String key,
|
||||||
autoPushZero = true,
|
bool autoPushZero = true,
|
||||||
}) {
|
}) {
|
||||||
List<int> keyList = _utf8ToArray(key);
|
List<int> keyList = _utf8ToArray(key);
|
||||||
|
|
||||||
@ -521,9 +522,11 @@ class SM4 {
|
|||||||
|
|
||||||
static List<int> encrypt(List<int> data,
|
static List<int> encrypt(List<int> data,
|
||||||
{List<int>? key, SM4CryptoMode mode = SM4CryptoMode.ECB, String? iv}) {
|
{List<int>? key, SM4CryptoMode mode = SM4CryptoMode.ECB, String? iv}) {
|
||||||
if (key != null) setKey(key);
|
if (key != null) {
|
||||||
List<int> input = data;
|
setKey(key);
|
||||||
List<int> output = _crypto(input, SM4_ENCRYPT, mode, iv);
|
}
|
||||||
|
final List<int> input = data;
|
||||||
|
final List<int> output = _crypto(input, SM4_ENCRYPT, mode, iv);
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -535,11 +538,13 @@ class SM4 {
|
|||||||
// return utf8.decode(output);
|
// return utf8.decode(output);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
static decrypt(List<int> data,
|
static List<int> decrypt(List<int> data,
|
||||||
{List<int>? key, SM4CryptoMode mode = SM4CryptoMode.ECB, String? iv}) {
|
{List<int>? key, SM4CryptoMode mode = SM4CryptoMode.ECB, String? iv}) {
|
||||||
if (key != null) setKey(key);
|
if (key != null) {
|
||||||
List<int> input = data;
|
setKey(key);
|
||||||
List<int> output = _crypto(input, SM4_DECRYPT, mode, iv);
|
}
|
||||||
|
final List<int> input = data;
|
||||||
|
final List<int> output = _crypto(input, SM4_DECRYPT, mode, iv);
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,14 +1,14 @@
|
|||||||
|
|
||||||
|
|
||||||
class _ASN1Object {
|
class _ASN1Object {
|
||||||
String? tlv;
|
|
||||||
String t = '00';
|
|
||||||
String l = '00';
|
|
||||||
String v = '';
|
|
||||||
|
|
||||||
_ASN1Object() {
|
_ASN1Object() {
|
||||||
tlv = null;
|
tlv = null;
|
||||||
}
|
}
|
||||||
|
String? tlv;
|
||||||
|
String t = '00';
|
||||||
|
String l = '00';
|
||||||
|
String v = '';
|
||||||
|
|
||||||
/// 获取 der 编码比特流16进制串
|
/// 获取 der 编码比特流16进制串
|
||||||
String getEncodedHex() {
|
String getEncodedHex() {
|
||||||
@ -84,11 +84,11 @@ class _DERInteger extends _ASN1Object {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _DERSequence extends _ASN1Object {
|
class _DERSequence extends _ASN1Object {
|
||||||
List<_ASN1Object> asn1Array;
|
|
||||||
|
|
||||||
_DERSequence(this.asn1Array) : super() {
|
_DERSequence(this.asn1Array) : super() {
|
||||||
t = '30'; // 序列标签说明
|
t = '30'; // 序列标签说明
|
||||||
}
|
}
|
||||||
|
List<_ASN1Object> asn1Array;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String getValue() {
|
String getValue() {
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
class ECFieldElementFp {
|
class ECFieldElementFp {
|
||||||
final BigInt x;
|
|
||||||
final BigInt q;
|
|
||||||
|
|
||||||
ECFieldElementFp(this.q, this.x) {
|
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) {
|
bool equals(ECFieldElementFp other) {
|
||||||
@ -51,16 +51,16 @@ class ECFieldElementFp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ECPointFp {
|
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]) {
|
ECPointFp(this.curve, this.x, this.y, [BigInt? z]) {
|
||||||
this.z = z ?? BigInt.one;
|
this.z = z ?? BigInt.one;
|
||||||
zinv = null;
|
zinv = null;
|
||||||
}
|
}
|
||||||
|
final ECCurveFp curve;
|
||||||
|
late final ECFieldElementFp? x;
|
||||||
|
late final ECFieldElementFp? y;
|
||||||
|
late final BigInt z;
|
||||||
|
BigInt? zinv;
|
||||||
|
|
||||||
ECFieldElementFp getX() {
|
ECFieldElementFp getX() {
|
||||||
zinv ??= z.modInverse(curve.q);
|
zinv ??= z.modInverse(curve.q);
|
||||||
@ -73,19 +73,29 @@ class ECPointFp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool equals(ECPointFp other) {
|
bool equals(ECPointFp other) {
|
||||||
if (other == this) return true;
|
if (other == this) {
|
||||||
if (isInfinity()) return other.isInfinity();
|
return true;
|
||||||
if (other.isInfinity()) return isInfinity();
|
}
|
||||||
|
if (isInfinity()) {
|
||||||
|
return other.isInfinity();
|
||||||
|
}
|
||||||
|
if (other.isInfinity()) {
|
||||||
|
return isInfinity();
|
||||||
|
}
|
||||||
|
|
||||||
final u = (other.y!.toBigInteger() * z - y!.toBigInteger() * other.z) % curve.q;
|
final BigInt u = (other.y!.toBigInteger() * z - y!.toBigInteger() * other.z) % curve.q;
|
||||||
if (u != BigInt.zero) return false;
|
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;
|
return v == BigInt.zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isInfinity() {
|
bool isInfinity() {
|
||||||
if (x == null && y == null) return true;
|
if (x == null && y == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return z == BigInt.zero && y!.toBigInteger() != BigInt.zero;
|
return z == BigInt.zero && y!.toBigInteger() != BigInt.zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,21 +104,25 @@ class ECPointFp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ECPointFp add(ECPointFp b) {
|
ECPointFp add(ECPointFp b) {
|
||||||
if (isInfinity()) return b;
|
if (isInfinity()) {
|
||||||
if (b.isInfinity()) return this;
|
return b;
|
||||||
final x1 = x!.toBigInteger();
|
}
|
||||||
final y1 = y!.toBigInteger();
|
if (b.isInfinity()) {
|
||||||
final z1 = z;
|
return this;
|
||||||
final x2 = b.x!.toBigInteger();
|
}
|
||||||
final y2 = b.y!.toBigInteger();
|
final BigInt x1 = x!.toBigInteger();
|
||||||
final z2 = b.z;
|
final BigInt y1 = y!.toBigInteger();
|
||||||
final q = curve.q;
|
final BigInt z1 = z;
|
||||||
final w1 = (x1 * z2) % q;
|
final BigInt x2 = b.x!.toBigInteger();
|
||||||
final w2 = (x2 * z1) % q;
|
final BigInt y2 = b.y!.toBigInteger();
|
||||||
final w3 = (w1 - w2) % q;
|
final BigInt z2 = b.z;
|
||||||
final w4 = (y1 * z2) % q;
|
final BigInt q = curve.q;
|
||||||
final w5 = (y2 * z1) % q;
|
final BigInt w1 = (x1 * z2) % q;
|
||||||
final w6 = (w4 - w5) % 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 (w3 == BigInt.zero) {
|
||||||
if (w6 == BigInt.zero) {
|
if (w6 == BigInt.zero) {
|
||||||
@ -117,49 +131,57 @@ class ECPointFp {
|
|||||||
return curve.infinity;
|
return curve.infinity;
|
||||||
}
|
}
|
||||||
|
|
||||||
final w7 = (w1 + w2) % q;
|
final BigInt w7 = (w1 + w2) % q;
|
||||||
final w8 = (z1 * z2) % q;
|
final BigInt w8 = (z1 * z2) % q;
|
||||||
final w9 = (w3 * w3) % q;
|
final BigInt w9 = (w3 * w3) % q;
|
||||||
final w10 = (w3 * w9) % q;
|
final BigInt w10 = (w3 * w9) % q;
|
||||||
final w11 = (w8 * (w6 * w6) % q - w7 * w9) % q;
|
final BigInt w11 = (w8 * (w6 * w6) % q - w7 * w9) % q;
|
||||||
|
|
||||||
final x3 = (w3 * w11) % q;
|
final BigInt x3 = (w3 * w11) % q;
|
||||||
final y3 = (w6 * (w9 * w1 % q - w11) - w4 * w10) % q;
|
final BigInt y3 = (w6 * (w9 * w1 % q - w11) - w4 * w10) % q;
|
||||||
final z3 = (w10 * w8) % q;
|
final BigInt z3 = (w10 * w8) % q;
|
||||||
|
|
||||||
return ECPointFp(curve, curve.fromBigInteger(x3), curve.fromBigInteger(y3), z3);
|
return ECPointFp(curve, curve.fromBigInteger(x3), curve.fromBigInteger(y3), z3);
|
||||||
}
|
}
|
||||||
|
|
||||||
ECPointFp twice() {
|
ECPointFp twice() {
|
||||||
if (isInfinity()) return this;
|
if (isInfinity()) {
|
||||||
if (y!.toBigInteger().sign == 0) return curve.infinity;
|
return this;
|
||||||
|
}
|
||||||
|
if (y!.toBigInteger().sign == 0) {
|
||||||
|
return curve.infinity;
|
||||||
|
}
|
||||||
|
|
||||||
final x1 = x!.toBigInteger();
|
final BigInt x1 = x!.toBigInteger();
|
||||||
final y1 = y!.toBigInteger();
|
final BigInt y1 = y!.toBigInteger();
|
||||||
final z1 = z;
|
final BigInt z1 = z;
|
||||||
final q = curve.q;
|
final BigInt q = curve.q;
|
||||||
final a = curve.a.toBigInteger();
|
final BigInt a = curve.a.toBigInteger();
|
||||||
|
|
||||||
final w1 = (x1 * x1 * BigInt.from(3) + a * (z1 * z1)) % q;
|
final BigInt w1 = (x1 * x1 * BigInt.from(3) + a * (z1 * z1)) % q;
|
||||||
final w2 = (y1 * BigInt.from(2) * z1) % q;
|
final BigInt w2 = (y1 * BigInt.from(2) * z1) % q;
|
||||||
final w3 = (y1 * y1) % q;
|
final BigInt w3 = (y1 * y1) % q;
|
||||||
final w4 = (w3 * x1 * z1) % q;
|
final BigInt w4 = (w3 * x1 * z1) % q;
|
||||||
final w5 = (w2 * w2) % q;
|
final BigInt w5 = (w2 * w2) % q;
|
||||||
final w6 = (w1 * w1 - w4 * BigInt.from(8)) % q;
|
final BigInt w6 = (w1 * w1 - w4 * BigInt.from(8)) % q;
|
||||||
|
|
||||||
final x3 = (w2 * w6) % q;
|
final BigInt x3 = (w2 * w6) % q;
|
||||||
final y3 = (w1 * (w4 * BigInt.from(4) - w6) - w5 * BigInt.from(2) * w3) % q;
|
final BigInt y3 = (w1 * (w4 * BigInt.from(4) - w6) - w5 * BigInt.from(2) * w3) % q;
|
||||||
final z3 = (w2 * w5) % q;
|
final BigInt z3 = (w2 * w5) % q;
|
||||||
|
|
||||||
return ECPointFp(curve, curve.fromBigInteger(x3), curve.fromBigInteger(y3), z3);
|
return ECPointFp(curve, curve.fromBigInteger(x3), curve.fromBigInteger(y3), z3);
|
||||||
}
|
}
|
||||||
|
|
||||||
ECPointFp multiply(BigInt k) {
|
ECPointFp multiply(BigInt k) {
|
||||||
if (isInfinity()) return this;
|
if (isInfinity()) {
|
||||||
if (k.sign == 0) return curve.infinity;
|
return this;
|
||||||
|
}
|
||||||
|
if (k.sign == 0) {
|
||||||
|
return curve.infinity;
|
||||||
|
}
|
||||||
|
|
||||||
final k3 = k * BigInt.from(3);
|
final BigInt k3 = k * BigInt.from(3);
|
||||||
final neg = negate();
|
final ECPointFp neg = negate();
|
||||||
ECPointFp Q = this;
|
ECPointFp Q = this;
|
||||||
|
|
||||||
for (int i = k3.bitLength - 2; i > 0; i--) {
|
for (int i = k3.bitLength - 2; i > 0; i--) {
|
||||||
@ -168,9 +190,8 @@ class ECPointFp {
|
|||||||
/*final k3Bit = (k3 >> i) & BigInt.one == BigInt.one;
|
/*final k3Bit = (k3 >> i) & BigInt.one == BigInt.one;
|
||||||
final kBit = (k >> i) & BigInt.one == BigInt.zero;*/
|
final kBit = (k >> i) & BigInt.one == BigInt.zero;*/
|
||||||
|
|
||||||
final k3Bit = (k3 >> i).isOdd;
|
final bool k3Bit = (k3 >> i).isOdd;
|
||||||
;
|
final bool kBit = (k >> i).isOdd;
|
||||||
final kBit = (k >> i).isOdd;
|
|
||||||
|
|
||||||
if (k3Bit != kBit) {
|
if (k3Bit != kBit) {
|
||||||
Q = Q.add(k3Bit ? this : neg);
|
Q = Q.add(k3Bit ? this : neg);
|
||||||
@ -194,8 +215,12 @@ class ECCurveFp {
|
|||||||
late ECPointFp infinity;
|
late ECPointFp infinity;
|
||||||
|
|
||||||
bool equals(Object? other) {
|
bool equals(Object? other) {
|
||||||
if (identical(this, other)) return true;
|
if (identical(this, other)) {
|
||||||
if (other is! ECCurveFp) return false;
|
return true;
|
||||||
|
}
|
||||||
|
if (other is! ECCurveFp) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return q == other.q && a == other.a && b == other.b;
|
return q == other.q && a == other.a && b == other.b;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,8 +234,8 @@ class ECCurveFp {
|
|||||||
return infinity;
|
return infinity;
|
||||||
case 2:
|
case 2:
|
||||||
case 3:
|
case 3:
|
||||||
final x = fromBigInteger(BigInt.parse(s.substring(2), radix: 16));
|
final ECFieldElementFp x = fromBigInteger(BigInt.parse(s.substring(2), radix: 16));
|
||||||
var y = fromBigInteger(x
|
ECFieldElementFp y = fromBigInteger(x
|
||||||
.multiply(x.square())
|
.multiply(x.square())
|
||||||
.add(x.multiply(a))
|
.add(x.multiply(a))
|
||||||
.add(b)
|
.add(b)
|
||||||
@ -230,9 +255,9 @@ class ECCurveFp {
|
|||||||
case 4:
|
case 4:
|
||||||
case 6:
|
case 6:
|
||||||
case 7:
|
case 7:
|
||||||
final len = (s.length - 2) ~/ 2;
|
final int len = (s.length - 2) ~/ 2;
|
||||||
final xHex = s.substring(2, 2 + len);
|
final String xHex = s.substring(2, 2 + len);
|
||||||
final yHex = s.substring(2 + len, 2 + 2 * len);
|
final String yHex = s.substring(2 + len, 2 + 2 * len);
|
||||||
/*print("xHex: ${BigInt.parse(xHex, radix: 16).toRadixString(16)}");
|
/*print("xHex: ${BigInt.parse(xHex, radix: 16).toRadixString(16)}");
|
||||||
print("yHex: ${BigInt.parse(yHex, radix: 16).toRadixString(16)}");*/
|
print("yHex: ${BigInt.parse(yHex, radix: 16).toRadixString(16)}");*/
|
||||||
return ECPointFp(this, fromBigInteger(BigInt.parse(xHex, radix: 16)),
|
return ECPointFp(this, fromBigInteger(BigInt.parse(xHex, radix: 16)),
|
||||||
@ -244,7 +269,9 @@ class ECCurveFp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String leftPad(String input, int num) {
|
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;
|
return List.filled(num - input.length, '0').join() + input;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4,15 +4,14 @@ import 'package:get/get.dart';
|
|||||||
import 'entity/SafetyVerificationEntity.dart';
|
import 'entity/SafetyVerificationEntity.dart';
|
||||||
|
|
||||||
class SafetyVerificationState{
|
class SafetyVerificationState{
|
||||||
|
|
||||||
// Rx<SafetyVerificationEntity> safetyVerificationEntity = SafetyVerificationEntity().obs;
|
|
||||||
var sliderXMoved = 0.0.obs;
|
|
||||||
var getData = {}.obs;
|
|
||||||
|
|
||||||
SafetyVerificationState() {
|
SafetyVerificationState() {
|
||||||
getData.value = Get.arguments as Map;
|
getData.value = Get.arguments as Map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Rx<SafetyVerificationEntity> safetyVerificationEntity = SafetyVerificationEntity().obs;
|
||||||
|
RxDouble sliderXMoved = 0.0.obs;
|
||||||
|
RxMap getData = {}.obs;
|
||||||
|
|
||||||
void onClose() {
|
void onClose() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -93,7 +93,7 @@ class _StarLockForgetPasswordPageState
|
|||||||
),
|
),
|
||||||
LoginInput(
|
LoginInput(
|
||||||
controller: state.phoneController,
|
controller: state.phoneController,
|
||||||
onchangeAction: (v) {
|
onchangeAction: (dynamic v) {
|
||||||
logic.checkNext(state.phoneController);
|
logic.checkNext(state.phoneController);
|
||||||
},
|
},
|
||||||
leftWidget: Padding(
|
leftWidget: Padding(
|
||||||
@ -113,7 +113,7 @@ class _StarLockForgetPasswordPageState
|
|||||||
SizedBox(height: 10.h),
|
SizedBox(height: 10.h),
|
||||||
LoginInput(
|
LoginInput(
|
||||||
controller: state.pwdController,
|
controller: state.pwdController,
|
||||||
onchangeAction: (v) {
|
onchangeAction: (dynamic v) {
|
||||||
logic.checkNext(state.pwdController);
|
logic.checkNext(state.pwdController);
|
||||||
},
|
},
|
||||||
isPwd: true,
|
isPwd: true,
|
||||||
@ -141,7 +141,7 @@ class _StarLockForgetPasswordPageState
|
|||||||
SizedBox(height: 10.w),
|
SizedBox(height: 10.w),
|
||||||
LoginInput(
|
LoginInput(
|
||||||
controller: state.sureController,
|
controller: state.sureController,
|
||||||
onchangeAction: (v) {
|
onchangeAction: (dynamic v) {
|
||||||
logic.checkNext(state.sureController);
|
logic.checkNext(state.sureController);
|
||||||
},
|
},
|
||||||
isPwd: true,
|
isPwd: true,
|
||||||
@ -166,7 +166,7 @@ class _StarLockForgetPasswordPageState
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: LoginInput(
|
child: LoginInput(
|
||||||
controller: state.codeController,
|
controller: state.codeController,
|
||||||
onchangeAction: (v) {
|
onchangeAction: (dynamic v) {
|
||||||
logic.checkNext(state.codeController);
|
logic.checkNext(state.codeController);
|
||||||
},
|
},
|
||||||
leftWidget: Padding(
|
leftWidget: Padding(
|
||||||
|
|||||||
@ -81,7 +81,7 @@ class _StarLockForgetPasswordPageState
|
|||||||
),
|
),
|
||||||
LoginInput(
|
LoginInput(
|
||||||
controller: state.phoneController,
|
controller: state.phoneController,
|
||||||
onchangeAction: (v) {
|
onchangeAction: (dynamic v) {
|
||||||
logic.checkNext(state.phoneController);
|
logic.checkNext(state.phoneController);
|
||||||
},
|
},
|
||||||
leftWidget: Padding(
|
leftWidget: Padding(
|
||||||
@ -94,7 +94,7 @@ class _StarLockForgetPasswordPageState
|
|||||||
]),
|
]),
|
||||||
LoginInput(
|
LoginInput(
|
||||||
controller: state.pwdController,
|
controller: state.pwdController,
|
||||||
onchangeAction: (v) {
|
onchangeAction: (dynamic v) {
|
||||||
logic.checkNext(state.pwdController);
|
logic.checkNext(state.pwdController);
|
||||||
},
|
},
|
||||||
isPwd: true,
|
isPwd: true,
|
||||||
@ -113,7 +113,7 @@ class _StarLockForgetPasswordPageState
|
|||||||
),
|
),
|
||||||
LoginInput(
|
LoginInput(
|
||||||
controller: state.sureController,
|
controller: state.sureController,
|
||||||
onchangeAction: (v) {
|
onchangeAction: (dynamic v) {
|
||||||
logic.checkNext(state.sureController);
|
logic.checkNext(state.sureController);
|
||||||
},
|
},
|
||||||
isPwd: true,
|
isPwd: true,
|
||||||
@ -131,10 +131,10 @@ class _StarLockForgetPasswordPageState
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: LoginInput(
|
child: LoginInput(
|
||||||
controller: state.codeController,
|
controller: state.codeController,
|
||||||
onchangeAction: (v) {
|
onchangeAction: (dynamic v) {
|
||||||
logic.checkNext(state.codeController);
|
logic.checkNext(state.codeController);
|
||||||
},
|
},
|
||||||
leftWidget: SizedBox(),
|
leftWidget: const SizedBox(),
|
||||||
hintText:
|
hintText:
|
||||||
'请输入验证码'.tr,
|
'请输入验证码'.tr,
|
||||||
inputFormatters: <TextInputFormatter>[
|
inputFormatters: <TextInputFormatter>[
|
||||||
|
|||||||
@ -1,9 +1,7 @@
|
|||||||
|
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
import 'starLock_login_logic.dart';
|
import 'starLock_login_logic.dart';
|
||||||
|
|
||||||
|
|
||||||
class StarLockLoginBinding extends Bindings {
|
class StarLockLoginBinding extends Bindings {
|
||||||
@override
|
@override
|
||||||
void dependencies() {
|
void dependencies() {
|
||||||
|
|||||||
@ -62,7 +62,7 @@ class _StarLockLoginPageState extends State<StarLockLoginPage> {
|
|||||||
style: TextStyle(color: Colors.white, fontSize: 24.sp),
|
style: TextStyle(color: Colors.white, fontSize: 24.sp),
|
||||||
),
|
),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
var data = await Get.toNamed(Routers.starLockRegisterPage);
|
final data = await Get.toNamed(Routers.starLockRegisterPage);
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
state.emailOrPhoneController.text = data['phoneOrEmailStr'];
|
state.emailOrPhoneController.text = data['phoneOrEmailStr'];
|
||||||
logic.checkNext(state.emailOrPhoneController);
|
logic.checkNext(state.emailOrPhoneController);
|
||||||
@ -98,7 +98,7 @@ class _StarLockLoginPageState extends State<StarLockLoginPage> {
|
|||||||
fontSize: 22.sp, color: AppColors.darkGrayTextColor),
|
fontSize: 22.sp, color: AppColors.darkGrayTextColor),
|
||||||
),
|
),
|
||||||
action: () async {
|
action: () async {
|
||||||
var result =
|
final result =
|
||||||
await Get.toNamed(Routers.selectCountryRegionPage);
|
await Get.toNamed(Routers.selectCountryRegionPage);
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
result as Map<String, dynamic>;
|
result as Map<String, dynamic>;
|
||||||
|
|||||||
@ -54,7 +54,7 @@ class SelectGatewayListLogic extends BaseGetXController {
|
|||||||
// lockInfo['mac'] = macStr;
|
// lockInfo['mac'] = macStr;
|
||||||
gatewayModel.mac = macStr;
|
gatewayModel.mac = macStr;
|
||||||
index = index + 20;
|
index = index + 20;
|
||||||
AppLog.log('网关MAC地址 macList:$macList macStr:$macStr');
|
// AppLog.log('网关MAC地址 macList:$macList macStr:$macStr');
|
||||||
|
|
||||||
// 网关序列号
|
// 网关序列号
|
||||||
final List<int> serialNum = reply.data.sublist(index, index + 20);
|
final List<int> serialNum = reply.data.sublist(index, index + 20);
|
||||||
@ -62,7 +62,7 @@ class SelectGatewayListLogic extends BaseGetXController {
|
|||||||
// lockInfo['serialNum'] = serialNumStr;
|
// lockInfo['serialNum'] = serialNumStr;
|
||||||
gatewayModel.serialNum = serialNumStr;
|
gatewayModel.serialNum = serialNumStr;
|
||||||
index = index + 20;
|
index = index + 20;
|
||||||
AppLog.log('网关序列号 serialNum:$serialNum serialNumStr:$serialNumStr');
|
// AppLog.log('网关序列号 serialNum:$serialNum serialNumStr:$serialNumStr');
|
||||||
|
|
||||||
// 网关版本
|
// 网关版本
|
||||||
final List<int> gatewayVersion = reply.data.sublist(index, index + 20);
|
final List<int> gatewayVersion = reply.data.sublist(index, index + 20);
|
||||||
@ -70,7 +70,7 @@ class SelectGatewayListLogic extends BaseGetXController {
|
|||||||
// lockInfo['gatewayVersion'] = gatewayVersionStr;
|
// lockInfo['gatewayVersion'] = gatewayVersionStr;
|
||||||
gatewayModel.gatewayVersion = gatewayVersionStr;
|
gatewayModel.gatewayVersion = gatewayVersionStr;
|
||||||
index = index + 20;
|
index = index + 20;
|
||||||
AppLog.log('软件版本 gatewayVersion:$gatewayVersion gatewayVersionStr:$gatewayVersionStr');
|
// AppLog.log('软件版本 gatewayVersion:$gatewayVersion gatewayVersionStr:$gatewayVersionStr');
|
||||||
|
|
||||||
// wifiMac地址
|
// wifiMac地址
|
||||||
// final List<int> wifiMac = reply.data.sublist(index, index + 20);
|
// final List<int> wifiMac = reply.data.sublist(index, index + 20);
|
||||||
|
|||||||
@ -0,0 +1,81 @@
|
|||||||
|
class GatewayConnectionLockListEntity {
|
||||||
|
|
||||||
|
GatewayConnectionLockListEntity(
|
||||||
|
{this.errorCode, this.description, this.errorMsg, this.data});
|
||||||
|
|
||||||
|
GatewayConnectionLockListEntity.fromJson(Map<String, dynamic> 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<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = <String, dynamic>{};
|
||||||
|
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<String, dynamic> json) {
|
||||||
|
if (json['list'] != null) {
|
||||||
|
list = <GatewayConnectionLockItemEntity>[];
|
||||||
|
json['list'].forEach((v) {
|
||||||
|
list!.add(GatewayConnectionLockItemEntity.fromJson(v));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
total = json['total'];
|
||||||
|
pageNo = json['pageNo'];
|
||||||
|
pageSize = json['pageSize'];
|
||||||
|
}
|
||||||
|
List<GatewayConnectionLockItemEntity>? list;
|
||||||
|
int? total;
|
||||||
|
int? pageNo;
|
||||||
|
int? pageSize;
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = <String, dynamic>{};
|
||||||
|
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<String, dynamic> json) {
|
||||||
|
lockId = json['lockId'];
|
||||||
|
lockAlias = json['lockAlias'];
|
||||||
|
rssi = json['rssi'];
|
||||||
|
}
|
||||||
|
int? lockId;
|
||||||
|
String? lockAlias;
|
||||||
|
int? rssi;
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = <String, dynamic>{};
|
||||||
|
data['lockId'] = lockId;
|
||||||
|
data['lockAlias'] = lockAlias;
|
||||||
|
data['rssi'] = rssi;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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<GatewayConnectionLockListEntity> 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -4,8 +4,11 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
import '../../../app_settings/app_colors.dart';
|
import '../../../app_settings/app_colors.dart';
|
||||||
|
import '../../../tools/noData.dart';
|
||||||
import '../../../tools/titleAppBar.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 {
|
class GatewayConnectionLockListPage extends StatefulWidget {
|
||||||
const GatewayConnectionLockListPage({Key? key}) : super(key: key);
|
const GatewayConnectionLockListPage({Key? key}) : super(key: key);
|
||||||
@ -15,6 +18,8 @@ class GatewayConnectionLockListPage extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _GatewayConnectionLockListPageState extends State<GatewayConnectionLockListPage> {
|
class _GatewayConnectionLockListPageState extends State<GatewayConnectionLockListPage> {
|
||||||
|
final GatewayConnectionLockListLogic logic = Get.put(GatewayConnectionLockListLogic());
|
||||||
|
final GatewayConnectionLockListState state = Get.find<GatewayConnectionLockListLogic>().state;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -26,23 +31,26 @@ class _GatewayConnectionLockListPageState extends State<GatewayConnectionLockLis
|
|||||||
backgroundColor: AppColors.mainColor
|
backgroundColor: AppColors.mainColor
|
||||||
),
|
),
|
||||||
body: Column(
|
body: Column(
|
||||||
children: [
|
children: <Widget>[
|
||||||
Container(
|
Container(
|
||||||
width: 1.sw,
|
width: 1.sw,
|
||||||
color: Colors.grey.shade300,
|
color: Colors.grey.shade300,
|
||||||
padding: EdgeInsets.all(10.h),
|
padding: EdgeInsets.all(10.h),
|
||||||
child: Text('网关连接的锁'.tr, style: TextStyle(fontSize: 24.sp))
|
child: Text('网关连接的锁'.tr, style: TextStyle(fontSize: 24.sp))
|
||||||
),
|
),
|
||||||
Expanded(
|
Obx(() => Expanded(
|
||||||
child: ListView.builder(
|
child:
|
||||||
|
state.itemDataList.value.isNotEmpty ?
|
||||||
|
ListView.builder(
|
||||||
itemCount:10,
|
itemCount:10,
|
||||||
itemBuilder: (c, index){
|
itemBuilder: (BuildContext c, int index){
|
||||||
return _gatewayConnectionLockListItem('images/mine/icon_mine_gatewaySignal_prompt.png', 'MCBN01 8f3106', '信号强'.tr,(){
|
final GatewayConnectionLockItemEntity entity = state.itemDataList[index];
|
||||||
|
return _gatewayConnectionLockListItem('images/mine/icon_mine_gatewaySignal_prompt.png', entity.lockAlias ?? '', '信号强'.tr,(){
|
||||||
// Navigator.pushNamed(context, Routers.gatewayDetailPage);
|
// Navigator.pushNamed(context, Routers.gatewayDetailPage);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
),
|
):NoData(),
|
||||||
)
|
))
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -60,32 +68,27 @@ class _GatewayConnectionLockListPageState extends State<GatewayConnectionLockLis
|
|||||||
borderRadius: BorderRadius.circular(10.w),
|
borderRadius: BorderRadius.circular(10.w),
|
||||||
),
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: <Widget>[
|
||||||
Image.asset(lockTypeIcon, width: 70.w, height: 70.w,),
|
Image.asset(lockTypeIcon, width: 70.w, height: 70.w,),
|
||||||
SizedBox(width: 20.w,),
|
SizedBox(width: 20.w,),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: <Widget>[
|
||||||
Container(
|
Row(
|
||||||
// color: Colors.red,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
child: Row(
|
children: <Widget>[
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
Text(gateWayName, style: TextStyle(fontSize: 24.sp, fontWeight: FontWeight.w500)),
|
||||||
children: [
|
],
|
||||||
Text(gateWayName, style: TextStyle(fontSize: 24.sp, fontWeight: FontWeight.w500)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
SizedBox(height:5.h),
|
SizedBox(height:5.h),
|
||||||
Container(
|
Row(
|
||||||
child: Row(
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
children: <Widget>[
|
||||||
children: [
|
Image.asset('images/mine/icon_mine_gatewaySignal_strong.png', width: 30.w, height: 30.w,),
|
||||||
Image.asset('images/mine/icon_mine_gatewaySignal_strong.png', width: 30.w, height: 30.w,),
|
SizedBox(width: 10.w,),
|
||||||
SizedBox(width: 10.w,),
|
Text(signalStrength, style: TextStyle(fontSize: 22.sp, fontWeight: FontWeight.w500), ),
|
||||||
Text(signalStrength, style: TextStyle(fontSize: 22.sp, fontWeight: FontWeight.w500), ),
|
],
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
SizedBox(width:20.h),
|
SizedBox(width:20.h),
|
||||||
],
|
],
|
||||||
|
|||||||
@ -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 = <GatewayConnectionLockItemEntity>[].obs;
|
||||||
|
}
|
||||||
@ -58,7 +58,7 @@ class _GatewayDetailPageState extends State<GatewayDetailPage> {
|
|||||||
}),
|
}),
|
||||||
CommonItem(
|
CommonItem(
|
||||||
leftTitel: '状态'.tr,
|
leftTitel: '状态'.tr,
|
||||||
rightTitle: state.getewayItemData.value.isOnline == 1 ? '在线' : '离线',
|
rightTitle: state.getewayItemData.value.isOnline == 1 ? '在线'.tr : '离线'.tr,
|
||||||
isHaveLine: true,
|
isHaveLine: true,
|
||||||
isHaveDirection: false),
|
isHaveDirection: false),
|
||||||
CommonItem(
|
CommonItem(
|
||||||
@ -74,14 +74,16 @@ class _GatewayDetailPageState extends State<GatewayDetailPage> {
|
|||||||
SizedBox(
|
SizedBox(
|
||||||
height: 10.h,
|
height: 10.h,
|
||||||
),
|
),
|
||||||
// CommonItem(
|
CommonItem(
|
||||||
// leftTitel: '附近的锁'.tr,
|
leftTitel: '附近的锁'.tr,
|
||||||
// rightTitle: state.getewayItemData.value.lockNum.toString(),
|
rightTitle: state.getewayItemData.value.lockNum.toString(),
|
||||||
// isHaveLine: true,
|
isHaveLine: true,
|
||||||
// isHaveDirection: true,
|
isHaveDirection: true,
|
||||||
// action: () {
|
action: () {
|
||||||
// Navigator.pushNamed(context, Routers.gatewayConnectionLockPage);
|
Get.toNamed(Routers.gatewayConnectionLockPage, arguments: {
|
||||||
// }),
|
'gatewayId':state.getewayItemData.value.gatewayId ?? 0
|
||||||
|
});
|
||||||
|
}),
|
||||||
// CommonItem(
|
// CommonItem(
|
||||||
// leftTitel: '网关升级'.tr,
|
// leftTitel: '网关升级'.tr,
|
||||||
// rightTitle: '',
|
// rightTitle: '',
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
import 'package:star_lock/tools/baseGetXController.dart';
|
import 'package:star_lock/tools/baseGetXController.dart';
|
||||||
|
|
||||||
|
import '../../../login/login/entity/LoginEntity.dart';
|
||||||
import '../../../network/api_repository.dart';
|
import '../../../network/api_repository.dart';
|
||||||
import '../../mineSet/transferGateway/selectGetewayList_entity.dart';
|
import '../../mineSet/transferGateway/selectGetewayList_entity.dart';
|
||||||
import 'gatewayList_state.dart';
|
import 'gatewayList_state.dart';
|
||||||
@ -29,10 +30,28 @@ class GatewayListLogic extends BaseGetXController {
|
|||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
// 测试配网成功
|
||||||
void onInit() {
|
// Future<void> gatewayDistributionNetwork() async{
|
||||||
super.onInit();
|
// 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();
|
||||||
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
@ -6,7 +7,6 @@ import 'package:star_lock/tools/noData.dart';
|
|||||||
import '../../../appRouters.dart';
|
import '../../../appRouters.dart';
|
||||||
import '../../../app_settings/app_colors.dart';
|
import '../../../app_settings/app_colors.dart';
|
||||||
import '../../../tools/EasyRefreshTool.dart';
|
import '../../../tools/EasyRefreshTool.dart';
|
||||||
import '../../../tools/storage.dart';
|
|
||||||
import '../../../tools/titleAppBar.dart';
|
import '../../../tools/titleAppBar.dart';
|
||||||
import '../../mineSet/transferGateway/selectGetewayList_entity.dart';
|
import '../../mineSet/transferGateway/selectGetewayList_entity.dart';
|
||||||
import 'gatewayList_logic.dart';
|
import 'gatewayList_logic.dart';
|
||||||
@ -49,7 +49,7 @@ class _GatewayListPageState extends State<GatewayListPage> {
|
|||||||
actionsList: <Widget>[
|
actionsList: <Widget>[
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Get.toNamed(Routers.selectGatewayTypeNextTipPage)!.then((value) => getHttpData(isRefresh: true));
|
Get.toNamed(Routers.selectGatewayTypeNextTipPage)!.then((dynamic value) => getHttpData(isRefresh: true));
|
||||||
},
|
},
|
||||||
child: Image.asset(
|
child: Image.asset(
|
||||||
'images/icon_add_white.png',
|
'images/icon_add_white.png',
|
||||||
@ -75,7 +75,7 @@ class _GatewayListPageState extends State<GatewayListPage> {
|
|||||||
return _gatewatListItem(item, () {
|
return _gatewatListItem(item, () {
|
||||||
Get.toNamed(Routers.gatewayDetailPage, arguments: {
|
Get.toNamed(Routers.gatewayDetailPage, arguments: {
|
||||||
'getewayItemData': item
|
'getewayItemData': item
|
||||||
})!.then((value) => getHttpData(isRefresh: true));
|
})!.then((dynamic value) => getHttpData(isRefresh: true));
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
separatorBuilder: (BuildContext context, int index) {
|
separatorBuilder: (BuildContext context, int index) {
|
||||||
|
|||||||
@ -155,6 +155,7 @@ abstract class Api {
|
|||||||
'/plug/transferPlugConfirm'; // 转移网关确认
|
'/plug/transferPlugConfirm'; // 转移网关确认
|
||||||
final String transferGatewayURL = '/plug/transfer'; // 转移网关
|
final String transferGatewayURL = '/plug/transfer'; // 转移网关
|
||||||
final String updateGatewayURL = '/gateway/update'; // 更新网关
|
final String updateGatewayURL = '/gateway/update'; // 更新网关
|
||||||
|
final String gatewayListByLockURL = '/gateway/listByLock'; // 网关-附近的锁
|
||||||
|
|
||||||
final String getKeyDetailURL = '/key/get'; //获取单把钥匙详情信息
|
final String getKeyDetailURL = '/key/get'; //获取单把钥匙详情信息
|
||||||
final String lockUserListURL = '/keyUser/listKeyUser'; //锁用户列表
|
final String lockUserListURL = '/keyUser/listKeyUser'; //锁用户列表
|
||||||
|
|||||||
@ -1783,6 +1783,10 @@ class ApiProvider extends BaseProvider {
|
|||||||
'countryCode': countryCode
|
'countryCode': countryCode
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
Future<Response> gatewayConnectionLockListLoadData(int gatewayId) => post(
|
||||||
|
gatewayListByLockURL.toUrl,
|
||||||
|
jsonEncode({'gatewayId': gatewayId}));
|
||||||
|
|
||||||
// 移除坏锁
|
// 移除坏锁
|
||||||
Future<Response> removeBrokenLockData(List lockIdList) =>
|
Future<Response> removeBrokenLockData(List lockIdList) =>
|
||||||
post(removeBadLockURL.toUrl, jsonEncode({'lockIds': lockIdList}));
|
post(removeBadLockURL.toUrl, jsonEncode({'lockIds': lockIdList}));
|
||||||
|
|||||||
@ -73,6 +73,7 @@ import '../main/lockDetail/palm/addPalm/addPalm_entity.dart';
|
|||||||
import '../main/lockDetail/remoteControl/addRemoteControl/addRemoteControl_entity.dart';
|
import '../main/lockDetail/remoteControl/addRemoteControl/addRemoteControl_entity.dart';
|
||||||
import '../main/lockMian/entity/lockListInfo_entity.dart';
|
import '../main/lockMian/entity/lockListInfo_entity.dart';
|
||||||
import '../mine/addLock/saveLock/entity/SaveLockEntity.dart';
|
import '../mine/addLock/saveLock/entity/SaveLockEntity.dart';
|
||||||
|
import '../mine/gateway/gatewayConnectionLock/gatewayConnectionLockList_entity.dart';
|
||||||
import '../mine/message/messageList/messageList_entity.dart';
|
import '../mine/message/messageList/messageList_entity.dart';
|
||||||
import '../mine/minePersonInfo/minePersonInfoPage/minePersonGetUploadFileInfo_entity.dart';
|
import '../mine/minePersonInfo/minePersonInfoPage/minePersonGetUploadFileInfo_entity.dart';
|
||||||
import '../mine/mineSet/lockUserManage/expireLockList/expireCard/expireCard_entity.dart';
|
import '../mine/mineSet/lockUserManage/expireLockList/expireCard/expireCard_entity.dart';
|
||||||
@ -1944,6 +1945,13 @@ class ApiRepository {
|
|||||||
return RecipientInformationEntity.fromJson(res.body);
|
return RecipientInformationEntity.fromJson(res.body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 网关-附近的锁
|
||||||
|
Future<GatewayConnectionLockListEntity> gatewayConnectionLockLoadData(
|
||||||
|
{required int gatewayId}) async {
|
||||||
|
final res = await apiProvider.gatewayConnectionLockListLoadData(gatewayId);
|
||||||
|
return GatewayConnectionLockListEntity.fromJson(res.body);
|
||||||
|
}
|
||||||
|
|
||||||
// 转移智能锁
|
// 转移智能锁
|
||||||
Future<RecipientInformationEntity> transferGatewayInfoData(
|
Future<RecipientInformationEntity> transferGatewayInfoData(
|
||||||
{required String receiverUsername,
|
{required String receiverUsername,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user