feat:优化蓝牙指令的打印,格式化时间
This commit is contained in:
parent
2fbe5fcf51
commit
9476a8f4b5
@ -1,6 +1,8 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:common_utils/common_utils.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/tools/dateTool.dart';
|
||||
|
||||
import '../../app_settings/app_settings.dart';
|
||||
import '../io_tool/io_tool.dart';
|
||||
@ -50,6 +52,20 @@ class SenderAddFaceCommand extends SenderProtocol {
|
||||
this.privateKey,
|
||||
}) : super(CommandType.generalExtendedCommond);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
|
||||
return 'SenderAddFaceCommand{keyID: $keyID, userID: $userID, '
|
||||
'faceNo: $faceNo, useCountLimit: $useCountLimit, '
|
||||
'isForce: $isForce, token: $token, isRound: $isRound, '
|
||||
'weekRound: $weekRound, '
|
||||
'startDate: ${DateTool().dateIntToYMDHNString(startDate)}, '
|
||||
'endDate: ${DateTool().dateIntToYMDHNString(endDate)}, '
|
||||
'startTime: ${DateTool().dateToYMDHNString(startTime)}, '
|
||||
'endTime: ${DateTool().dateToYMDHNString(endTime)}, '
|
||||
'needAuthor: $needAuthor, signKey: $signKey, privateKey: $privateKey}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<int> messageDetail() {
|
||||
List<int> data = [];
|
||||
@ -158,7 +174,7 @@ class SenderAddFaceCommand extends SenderProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
AppLog.log("App发给锁的数据,指令类型是:${commandType!.typeName} 加密之前数据是:$data");
|
||||
printLog(data);
|
||||
// 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864
|
||||
ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB);
|
||||
return ebcData;
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:star_lock/tools/dateTool.dart';
|
||||
|
||||
import '../../app_settings/app_settings.dart';
|
||||
import '../io_tool/io_tool.dart';
|
||||
import '../sm4Encipher/sm4.dart';
|
||||
@ -50,6 +52,20 @@ class SenderAddFingerprintWithTimeCycleCoercionCommand extends SenderProtocol {
|
||||
this.privateKey,
|
||||
}) : super(CommandType.generalExtendedCommond);
|
||||
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'SenderAddFingerprintWithTimeCycleCoercionCommand{keyID: $keyID, '
|
||||
'userID: $userID, fingerNo: $fingerNo, useCountLimit: $useCountLimit, '
|
||||
'isForce: $isForce, token: $token, isRound: $isRound, '
|
||||
'weekRound: $weekRound, '
|
||||
'startDate:${DateTool().dateIntToYMDHNString(startDate)}, '
|
||||
'endDate: ${DateTool().dateIntToYMDHNString(endDate)}, '
|
||||
'startTime: ${DateTool().dateToYMDHNString(startTime)}, '
|
||||
'endTime: ${DateTool().dateToYMDHNString(endTime)}, '
|
||||
'needAuthor: $needAuthor, signKey: $signKey, privateKey: $privateKey}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<int> messageDetail() {
|
||||
List<int> data = [];
|
||||
@ -158,7 +174,7 @@ class SenderAddFingerprintWithTimeCycleCoercionCommand extends SenderProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
AppLog.log("App发给锁的数据,指令类型是:${commandType!.typeName} 加密之前数据是:$data");
|
||||
printLog(data);
|
||||
// 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864
|
||||
ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB);
|
||||
return ebcData;
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:star_lock/tools/dateTool.dart';
|
||||
|
||||
import '../../app_settings/app_settings.dart';
|
||||
import '../io_tool/io_tool.dart';
|
||||
import '../sm4Encipher/sm4.dart';
|
||||
@ -50,6 +52,20 @@ class SenderAddICCardWithTimeCycleCoercionCommand extends SenderProtocol {
|
||||
this.privateKey,
|
||||
}) : super(CommandType.generalExtendedCommond);
|
||||
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'SenderAddICCardWithTimeCycleCoercionCommand{keyID: $keyID, '
|
||||
'userID: $userID, cardNo: $cardNo, useCountLimit: $useCountLimit, '
|
||||
'isForce: $isForce, token: $token, isRound: $isRound, '
|
||||
'weekRound: $weekRound, '
|
||||
'startDate: ${DateTool().dateIntToYMDHNString(startDate)}, '
|
||||
'endDate: ${DateTool().dateIntToYMDHNString(endDate)}, '
|
||||
'startTime: ${DateTool().dateToYMDHNString(startTime)}, '
|
||||
'endTime: ${DateTool().dateToYMDHNString(endTime)}, '
|
||||
'needAuthor: $needAuthor, signKey: $signKey, privateKey: $privateKey}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<int> messageDetail() {
|
||||
List<int> data = [];
|
||||
@ -158,7 +174,7 @@ class SenderAddICCardWithTimeCycleCoercionCommand extends SenderProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
AppLog.log("App发给锁的数据,指令类型是:${commandType!.typeName} 加密之前数据是:$data");
|
||||
printLog(data);
|
||||
// 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864
|
||||
ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB);
|
||||
return ebcData;
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:star_lock/tools/dateTool.dart';
|
||||
|
||||
import '../../app_settings/app_settings.dart';
|
||||
import '../io_tool/io_tool.dart';
|
||||
import '../sm4Encipher/sm4.dart';
|
||||
@ -40,6 +42,18 @@ class SenderAddStressPasswordCommand extends SenderProtocol {
|
||||
this.privateKey,
|
||||
}) : super(CommandType.generalExtendedCommond);
|
||||
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'SenderAddStressPasswordCommand{keyID: $keyID, userID: $userID, '
|
||||
'passwordNo: $passwordNo, useCountLimit: $useCountLimit, '
|
||||
'token: $token, '
|
||||
'startTime: ${DateTool().dateIntToYMDHNString(startTime)}, '
|
||||
'endTime: ${DateTool().dateIntToYMDHNString(endTime)}, '
|
||||
'needAuthor: $needAuthor, publicKey: $publicKey, '
|
||||
'privateKey: $privateKey}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<int> messageDetail() {
|
||||
List<int> data = [];
|
||||
@ -122,7 +136,7 @@ class SenderAddStressPasswordCommand extends SenderProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
AppLog.log("App发给锁的数据,指令类型是:${commandType!.typeName} 加密之前数据是:$data");
|
||||
printLog(data);
|
||||
// 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864
|
||||
ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB);
|
||||
return ebcData;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/tools/dateTool.dart';
|
||||
|
||||
import '../../app_settings/app_settings.dart';
|
||||
import '../io_tool/io_tool.dart';
|
||||
@ -13,7 +13,6 @@ import 'package:crypto/crypto.dart' as crypto;
|
||||
|
||||
//TODO:添加用户
|
||||
class AddUserCommand extends SenderProtocol {
|
||||
|
||||
String? lockID;
|
||||
String? authUserID;
|
||||
String? keyID;
|
||||
@ -28,22 +27,34 @@ class AddUserCommand extends SenderProtocol {
|
||||
List<int>? publicKey;
|
||||
List<int>? privateKey;
|
||||
List<int>? token;
|
||||
AddUserCommand({
|
||||
this.lockID,
|
||||
this.authUserID,
|
||||
this.keyID,
|
||||
this.userID,
|
||||
this.openMode,
|
||||
this.keyType,
|
||||
this.startDate,
|
||||
this.expireDate,
|
||||
this.role,
|
||||
this.password,
|
||||
this.needAuthor,
|
||||
this.publicKey,
|
||||
this.privateKey,
|
||||
this.token
|
||||
}) : super(CommandType.addUser);
|
||||
|
||||
AddUserCommand(
|
||||
{this.lockID,
|
||||
this.authUserID,
|
||||
this.keyID,
|
||||
this.userID,
|
||||
this.openMode,
|
||||
this.keyType,
|
||||
this.startDate,
|
||||
this.expireDate,
|
||||
this.role,
|
||||
this.password,
|
||||
this.needAuthor,
|
||||
this.publicKey,
|
||||
this.privateKey,
|
||||
this.token})
|
||||
: super(CommandType.addUser);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'AddUserCommand{lockID: $lockID, authUserID: $authUserID, '
|
||||
'keyID: $keyID, userID: $userID, openMode: $openMode, '
|
||||
'keyType: $keyType, '
|
||||
'startDate:${DateTool().dateIntToYMDHNString(startDate)} , '
|
||||
'expireDate: ${DateTool().dateIntToYMDHNString(expireDate)} , '
|
||||
'role: $role, password: $password, needAuthor: $needAuthor, '
|
||||
'publicKey: $publicKey, privateKey: $privateKey, token: $token}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<int> messageDetail() {
|
||||
@ -85,10 +96,10 @@ class AddUserCommand extends SenderProtocol {
|
||||
data.add(keyType!);
|
||||
|
||||
int? d1, d2;
|
||||
if(role == 255){
|
||||
d1 = 0;//Date.parse(new Date()) / 1000;
|
||||
d2 = 0xffffffff;//d1 + 86440;
|
||||
}else{
|
||||
if (role == 255) {
|
||||
d1 = 0; //Date.parse(new Date()) / 1000;
|
||||
d2 = 0xffffffff; //d1 + 86440;
|
||||
} else {
|
||||
d1 = startDate;
|
||||
d2 = expireDate;
|
||||
}
|
||||
@ -116,7 +127,7 @@ class AddUserCommand extends SenderProtocol {
|
||||
// token 长度4 首次请求 Token 填 0,如果锁需要鉴权 操作者身份,则会分配动态口令并在应答消息中返回,二次请求时带上。 当token失效或者第一次发送的时候token为0
|
||||
data.addAll(token!);
|
||||
|
||||
if(needAuthor == 0){
|
||||
if (needAuthor == 0) {
|
||||
//AuthCodeLen 1
|
||||
data.add(0);
|
||||
} else {
|
||||
@ -147,7 +158,7 @@ class AddUserCommand extends SenderProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
AppLog.log("App发给锁的数据,指令类型是:${commandType!.typeName} 加密之前数据是:$data");
|
||||
printLog(data);
|
||||
// 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864
|
||||
ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB);
|
||||
return ebcData;
|
||||
@ -161,4 +172,4 @@ class AddUserReply extends Reply {
|
||||
int status = data[46];
|
||||
errorWithStstus(status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:star_lock/tools/dateTool.dart';
|
||||
|
||||
import '../../app_settings/app_settings.dart';
|
||||
import '../io_tool/io_tool.dart';
|
||||
import '../sm4Encipher/sm4.dart';
|
||||
@ -38,6 +40,17 @@ class ChangeAdministratorPasswordCommand extends SenderProtocol {
|
||||
this.privateKey,
|
||||
}) : super(CommandType.generalExtendedCommond);
|
||||
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ChangeAdministratorPasswordCommand{keyID: $keyID, userID: $userID,'
|
||||
' pwdNo: $pwdNo, pwd: $pwd, useCountLimit: $useCountLimit, '
|
||||
'token: $token, '
|
||||
'startTime: ${DateTool().dateIntToYMDHNString(startTime)}, '
|
||||
'endTime: ${DateTool().dateIntToYMDHNString(endTime)}, '
|
||||
'needAuthor: $needAuthor, signKey: $signKey, privateKey: $privateKey}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<int> messageDetail() {
|
||||
List<int> data = [];
|
||||
@ -125,7 +138,7 @@ class ChangeAdministratorPasswordCommand extends SenderProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
AppLog.log("App发给锁的数据,指令类型是:${commandType!.typeName} 加密之前数据是:$data");
|
||||
printLog(data);
|
||||
// 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864
|
||||
ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB);
|
||||
return ebcData;
|
||||
|
||||
@ -34,6 +34,14 @@ class SenderCheckingCardStatusCommand extends SenderProtocol {
|
||||
this.privateKey,
|
||||
}) : super(CommandType.generalExtendedCommond);
|
||||
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'SenderCheckingCardStatusCommand{keyID: $keyID, userID: $userID, '
|
||||
'role: $role, cardCount: $cardCount, cardNo: $cardNo, token: $token, '
|
||||
'needAuthor: $needAuthor, publicKey: $publicKey, privateKey: $privateKey}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<int> messageDetail() {
|
||||
List<int> data = [];
|
||||
@ -104,7 +112,7 @@ class SenderCheckingCardStatusCommand extends SenderProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
AppLog.log("App发给锁的数据,指令类型是:${commandType!.typeName} 加密之前数据是:$data");
|
||||
printLog(data);
|
||||
// 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864
|
||||
ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB);
|
||||
return ebcData;
|
||||
|
||||
@ -32,6 +32,14 @@ class SenderCheckingUserInfoCountCommand extends SenderProtocol {
|
||||
this.privateKey,
|
||||
}) : super(CommandType.generalExtendedCommond);
|
||||
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'SenderCheckingUserInfoCountCommand{keyID: $keyID, userID: $userID,'
|
||||
' role: $role, nowTime: $nowTime, token: $token, '
|
||||
'needAuthor: $needAuthor, publicKey: $publicKey, privateKey: $privateKey}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<int> messageDetail() {
|
||||
List<int> data = [];
|
||||
@ -105,7 +113,7 @@ class SenderCheckingUserInfoCountCommand extends SenderProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
AppLog.log("App发给锁的数据,指令类型是:${commandType!.typeName} 加密之前数据是:$data");
|
||||
printLog(data);
|
||||
// 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864
|
||||
ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB);
|
||||
return ebcData;
|
||||
|
||||
@ -40,6 +40,16 @@ class SenderConfiguringWifiCommand extends SenderProtocol {
|
||||
this.privateKey,
|
||||
}) : super(CommandType.generalExtendedCommond);
|
||||
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'SenderConfiguringWifiCommand{keyID: $keyID, userID: $userID, '
|
||||
'ssid: $ssid, password: $password, numberOfServers: $numberOfServers, '
|
||||
'listOfServers: $listOfServers, numberOfPhone: $numberOfPhone, '
|
||||
'listOfPhone: $listOfPhone, token: $token, needAuthor: $needAuthor, '
|
||||
'publicKey: $publicKey, privateKey: $privateKey}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<int> messageDetail() {
|
||||
List<int> data = [];
|
||||
@ -130,7 +140,7 @@ class SenderConfiguringWifiCommand extends SenderProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
AppLog.log("App发给锁的数据,指令类型是:${commandType!.typeName} 加密之前数据是:$data");
|
||||
printLog(data);
|
||||
// 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864
|
||||
ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB);
|
||||
return ebcData;
|
||||
|
||||
@ -31,6 +31,14 @@ class DeletUserCommand extends SenderProtocol {
|
||||
this.token
|
||||
}) : super(CommandType.deletUser);
|
||||
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'DeletUserCommand{lockID: $lockID, authUserID: $authUserID, '
|
||||
'keyID: $keyID, delUserID: $delUserID, needAuthor: $needAuthor, '
|
||||
'publicKey: $publicKey, privateKey: $privateKey, token: $token}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<int> messageDetail() {
|
||||
List<int> data = [];
|
||||
@ -98,7 +106,7 @@ class DeletUserCommand extends SenderProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
AppLog.log("App发给锁的数据,指令类型是:${commandType!.typeName} 加密之前数据是:$data");
|
||||
printLog(data);
|
||||
// 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864
|
||||
ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB);
|
||||
return ebcData;
|
||||
|
||||
@ -3,6 +3,8 @@
|
||||
//TODO:修改用户
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:star_lock/tools/dateTool.dart';
|
||||
|
||||
import '../../app_settings/app_settings.dart';
|
||||
import '../io_tool/io_tool.dart';
|
||||
import '../sm4Encipher/sm4.dart';
|
||||
@ -44,6 +46,19 @@ class EditUserCommand extends SenderProtocol {
|
||||
this.token
|
||||
}) : super(CommandType.editUser);
|
||||
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'EditUserCommand{lockID: $lockID, authUserID: $authUserID, '
|
||||
'keyID: $keyID, userID: $userID, openMode: $openMode, '
|
||||
'keyType: $keyType, '
|
||||
'startDate: ${DateTool().dateIntToYMDHNString(startDate)}, '
|
||||
'expireDate: ${DateTool().dateIntToYMDHNString(expireDate)}, '
|
||||
'role: $role, password: $password, '
|
||||
'needAuthor: $needAuthor, publicKey: $publicKey, '
|
||||
'privateKey: $privateKey, token: $token}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<int> messageDetail() {
|
||||
List<int> data = [];
|
||||
@ -146,7 +161,7 @@ class EditUserCommand extends SenderProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
AppLog.log("App发给锁的数据,指令类型是:${commandType!.typeName} 加密之前数据是:$data");
|
||||
printLog(data);
|
||||
// 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864
|
||||
ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB);
|
||||
return ebcData;
|
||||
|
||||
@ -35,6 +35,14 @@ class FactoryDataResetCommand extends SenderProtocol {
|
||||
this.privateKey,
|
||||
}) : super(CommandType.factoryDataReset);
|
||||
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'FactoryDataResetCommand{lockID: $lockID, userID: $userID, '
|
||||
'keyID: $keyID, publicKey: $publicKey, privateKey: $privateKey, '
|
||||
'token: $token, needAuthor: $needAuthor}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<int> messageDetail() {
|
||||
List<int> data = [];
|
||||
@ -89,7 +97,7 @@ class FactoryDataResetCommand extends SenderProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
AppLog.log("App发给锁的数据,指令类型是:${commandType!.typeName} 加密之前数据是:$data");
|
||||
printLog(data);
|
||||
// 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864
|
||||
ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB);
|
||||
return ebcData;
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/blue/blue_manage.dart';
|
||||
import 'package:star_lock/blue/sm4Encipher/sm4.dart';
|
||||
import 'package:star_lock/tools/dateTool.dart';
|
||||
|
||||
import '../../app_settings/app_settings.dart';
|
||||
import '../io_tool/io_tool.dart';
|
||||
@ -13,7 +13,7 @@ import '../io_type.dart';
|
||||
|
||||
import 'package:crypto/crypto.dart' as crypto;
|
||||
|
||||
List<int>publicKeyDataList = [];
|
||||
List<int> publicKeyDataList = [];
|
||||
|
||||
class GetPrivateKeyCommand extends SenderProtocol {
|
||||
String? lockID;
|
||||
@ -22,14 +22,22 @@ class GetPrivateKeyCommand extends SenderProtocol {
|
||||
int? nowTime;
|
||||
int? needAuthor;
|
||||
List<int>? publicKeyData;
|
||||
GetPrivateKeyCommand({
|
||||
this.lockID,
|
||||
this.keyID,
|
||||
this.authUserID,
|
||||
this.nowTime,
|
||||
this.needAuthor,
|
||||
this.publicKeyData
|
||||
}) : super(CommandType.getLockPrivateKey);
|
||||
|
||||
GetPrivateKeyCommand(
|
||||
{this.lockID,
|
||||
this.keyID,
|
||||
this.authUserID,
|
||||
this.nowTime,
|
||||
this.needAuthor,
|
||||
this.publicKeyData})
|
||||
: super(CommandType.getLockPrivateKey);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'GetPrivateKeyCommand{lockID: $lockID, keyID: $keyID, '
|
||||
'authUserID: $authUserID, nowTime: ${DateTool().dateIntToYMDHNString(nowTime)}, '
|
||||
'needAuthor: $needAuthor, publicKeyData: $publicKeyData}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<int> messageDetail() {
|
||||
@ -105,9 +113,11 @@ class GetPrivateKeyCommand extends SenderProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
AppLog.log("App发给锁的数据,指令类型是:${commandType!.typeName} 加密之前数据是:$data");
|
||||
printLog(data);
|
||||
// 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864
|
||||
ebcData = SM4.encrypt(data, key: utf8.encode(BlueManage().connectDeviceName), mode: SM4CryptoMode.ECB);
|
||||
ebcData = SM4.encrypt(data,
|
||||
key: utf8.encode(BlueManage().connectDeviceName),
|
||||
mode: SM4CryptoMode.ECB);
|
||||
|
||||
return ebcData;
|
||||
}
|
||||
|
||||
@ -17,6 +17,12 @@ class GetPublicKeyCommand extends SenderProtocol {
|
||||
this.lockID,
|
||||
}) : super(CommandType.getLockPublicKey);
|
||||
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'GetPublicKeyCommand{lockID: $lockID}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<int> messageDetail() {
|
||||
List<int> data = [];
|
||||
@ -32,6 +38,8 @@ class GetPublicKeyCommand extends SenderProtocol {
|
||||
int length = utf8.encode(lockID!).length;
|
||||
data.addAll(utf8.encode(lockID!));
|
||||
data = getFixedLengthList(data, 40 - length);
|
||||
|
||||
printLog(data);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,6 +21,13 @@ class GetStarLockStatuInfoCommand extends SenderProtocol {
|
||||
this.privateKey
|
||||
}) : super(CommandType.readStarLockStatusInfo);
|
||||
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'GetStarLockStatuInfoCommand{lockID: $lockID, '
|
||||
'userID: $userID, privateKey: $privateKey}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<int> messageDetail() {
|
||||
List<int> data = [];
|
||||
@ -51,7 +58,7 @@ class GetStarLockStatuInfoCommand extends SenderProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
AppLog.log("App发给锁的数据,指令类型是:${commandType!.typeName} 加密之前数据是:$data");
|
||||
printLog(data);
|
||||
// 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864
|
||||
ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB);
|
||||
return ebcData;
|
||||
|
||||
@ -30,6 +30,14 @@ class SenderGetWifiCommand extends SenderProtocol {
|
||||
this.privateKey,
|
||||
}) : super(CommandType.generalExtendedCommond);
|
||||
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'SenderGetWifiCommand{keyID: $keyID, userID: $userID, '
|
||||
'token: $token, needAuthor: $needAuthor, '
|
||||
'publicKey: $publicKey, privateKey: $privateKey}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<int> messageDetail() {
|
||||
List<int> data = [];
|
||||
@ -94,7 +102,7 @@ class SenderGetWifiCommand extends SenderProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
AppLog.log("App发给锁的数据,指令类型是:${commandType!.typeName} 加密之前数据是:$data");
|
||||
printLog(data);
|
||||
// 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864
|
||||
ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB);
|
||||
return ebcData;
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
import 'dart:convert';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/app_settings/app_settings.dart';
|
||||
import 'package:star_lock/tools/dateTool.dart';
|
||||
|
||||
import '../io_tool/io_tool.dart';
|
||||
import '../sm4Encipher/sm4.dart';
|
||||
@ -33,6 +34,15 @@ class OpenLockCommand extends SenderProtocol {
|
||||
this.privateKey
|
||||
}) : super(CommandType.openLock);
|
||||
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'OpenLockCommand{keyID: $keyID, userID: $userID, '
|
||||
'openMode: $openMode, openTime: ${DateTool().dateIntToYMDHNString(openTime)}, '
|
||||
'onlineToken: $onlineToken, token: $token, '
|
||||
'needAuthor: $needAuthor, signKey: $signKey, privateKey: $privateKey}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<int> messageDetail() {
|
||||
List<int> data = [];
|
||||
@ -108,7 +118,7 @@ class OpenLockCommand extends SenderProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
AppLog.log("App发给锁的数据,指令类型是:${commandType!.typeName} 加密之前数据是:$data");
|
||||
printLog(data);
|
||||
// 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864
|
||||
ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB);
|
||||
return ebcData;
|
||||
|
||||
@ -43,6 +43,16 @@ class OTAUpgradeCommand extends SenderProtocol {
|
||||
this.token})
|
||||
: super(CommandType.startOATUpgrade);
|
||||
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'OTAUpgradeCommand{lockID: $lockID, userID: $userID, '
|
||||
'keyID: $keyID, platform: $platform, product: $product, '
|
||||
'hwVersion: $hwVersion, fwVersion: $fwVersion, fwSize: $fwSize, '
|
||||
'fwMD5: $fwMD5, needAuthor: $needAuthor, signKey: $signKey, '
|
||||
'privateKey: $privateKey, token: $token}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<int> messageDetail() {
|
||||
List<int> data = [];
|
||||
@ -94,14 +104,12 @@ class OTAUpgradeCommand extends SenderProtocol {
|
||||
data.addAll(utf8.encode(hwVersion!));
|
||||
data = getFixedLengthList(data, 20 - hwVersionLength);
|
||||
|
||||
AppLog.log('---> hwVersion : ${utf8.encode(hwVersion!)}');
|
||||
|
||||
//FwVersion 20
|
||||
int fwVersionLength = utf8.encode(fwVersion!).length;
|
||||
data.addAll(utf8.encode(fwVersion!));
|
||||
data = getFixedLengthList(data, 20 - fwVersionLength);
|
||||
|
||||
AppLog.log('---> FwVersion : ${utf8.encode(fwVersion!)}');
|
||||
|
||||
//fwSize 4
|
||||
ByteData bytes = ByteData(4); // 创建一个长度为4的字节数据
|
||||
@ -109,7 +117,6 @@ class OTAUpgradeCommand extends SenderProtocol {
|
||||
List<int> byteList = bytes.buffer.asUint8List();
|
||||
data.addAll(byteList);
|
||||
|
||||
AppLog.log('---> fwSize : ${byteList}');
|
||||
|
||||
// 创建一个16字节的字节数组
|
||||
Uint8List result = Uint8List(16);
|
||||
@ -120,15 +127,8 @@ class OTAUpgradeCommand extends SenderProtocol {
|
||||
result[i ~/ 2] = byteValue;
|
||||
}
|
||||
data.addAll(result);
|
||||
AppLog.log('---> fwMD5 : $result');
|
||||
|
||||
// token 长度4 首次请求 Token 填 0,如果锁需要鉴权 操作者身份,则会分配动态口令并在应答消息中返回,二次请求时带上。 当token失效或者第一次发送的时候token为0
|
||||
data.addAll(token!);
|
||||
|
||||
AppLog.log('---> token : $token');
|
||||
|
||||
AppLog.log('--->1$data');
|
||||
|
||||
if (needAuthor == 0) {
|
||||
//AuthCodeLen 1
|
||||
data.add(0);
|
||||
@ -162,7 +162,7 @@ class OTAUpgradeCommand extends SenderProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
AppLog.log("App发给锁的数据,指令类型是:${commandType!.typeName} 加密之前数据是:$data");
|
||||
printLog(data);
|
||||
// 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864
|
||||
ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB);
|
||||
return ebcData;
|
||||
|
||||
@ -22,6 +22,12 @@ class ProcessOtaUpgradeCommand extends SenderProtocol {
|
||||
this.data,
|
||||
}) : super(CommandType.processOTAUpgrade);
|
||||
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ProcessOtaUpgradeCommand{index: $index, size: $size, data: $data}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<int> messageDetail() {
|
||||
List<int> data = [];
|
||||
@ -48,6 +54,7 @@ class ProcessOtaUpgradeCommand extends SenderProtocol {
|
||||
|
||||
data.addAll(this.data!);
|
||||
|
||||
printLog(data);
|
||||
//不加密
|
||||
return data;
|
||||
}
|
||||
|
||||
@ -34,6 +34,14 @@ class SenderQueryingFaceStatusCommand extends SenderProtocol {
|
||||
this.privateKey,
|
||||
}) : super(CommandType.generalExtendedCommond);
|
||||
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'SenderQueryingFaceStatusCommand{keyID: $keyID, userID: $userID, '
|
||||
'role: $role, faceCount: $faceCount, faceNo: $faceNo, token: $token, '
|
||||
'needAuthor: $needAuthor, publicKey: $publicKey, privateKey: $privateKey}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<int> messageDetail() {
|
||||
List<int> data = [];
|
||||
@ -104,7 +112,7 @@ class SenderQueryingFaceStatusCommand extends SenderProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
AppLog.log("App发给锁的数据,指令类型是:${commandType!.typeName} 加密之前数据是:$data");
|
||||
printLog(data);
|
||||
ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB);
|
||||
return ebcData;
|
||||
}
|
||||
|
||||
@ -36,6 +36,15 @@ class SenderQueryingFingerprintStatusCommand extends SenderProtocol {
|
||||
this.privateKey,
|
||||
}) : super(CommandType.generalExtendedCommond);
|
||||
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'SenderQueryingFingerprintStatusCommand{keyID: $keyID, '
|
||||
'userID: $userID, role: $role, fingerCount: $fingerCount, '
|
||||
'fingerNo: $fingerNo, token: $token, needAuthor: $needAuthor, '
|
||||
'publicKey: $publicKey, privateKey: $privateKey}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<int> messageDetail() {
|
||||
List<int> data = [];
|
||||
@ -106,7 +115,7 @@ class SenderQueryingFingerprintStatusCommand extends SenderProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
AppLog.log("App发给锁的数据,指令类型是:${commandType!.typeName} 加密之前数据是:$data");
|
||||
printLog(data);
|
||||
// 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864
|
||||
ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB);
|
||||
return ebcData;
|
||||
|
||||
@ -36,6 +36,15 @@ class SenderReadAdminPasswordCommand extends SenderProtocol {
|
||||
this.privateKey,
|
||||
}) : super(CommandType.generalExtendedCommond);
|
||||
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'SenderReadAdminPasswordCommand{keyID: $keyID, userID: $userID, '
|
||||
'role: $role, pwdNum: $pwdNum, pwdNo: $pwdNo, token: $token, '
|
||||
'needAuthor: $needAuthor, publicKey: $publicKey, '
|
||||
'privateKey: $privateKey}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<int> messageDetail() {
|
||||
List<int> data = [];
|
||||
@ -106,7 +115,7 @@ class SenderReadAdminPasswordCommand extends SenderProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
AppLog.log("App发给锁的数据,指令类型是:${commandType!.typeName} 加密之前数据是:$data");
|
||||
printLog(data);
|
||||
// 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864
|
||||
ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB);
|
||||
return ebcData;
|
||||
|
||||
@ -33,6 +33,15 @@ class ReadSupportFunctionsNoParametersCommand extends SenderProtocol {
|
||||
this.privateKey,
|
||||
}) : super(CommandType.generalExtendedCommond);
|
||||
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ReadSupportFunctionsNoParametersCommand{keyID: $keyID, '
|
||||
'userID: $userID, featureBit: $featureBit, token: $token, '
|
||||
'needAuthor: $needAuthor, publicKey: $publicKey, '
|
||||
'privateKey: $privateKey}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<int> messageDetail() {
|
||||
List<int> data = [];
|
||||
@ -97,7 +106,7 @@ class ReadSupportFunctionsNoParametersCommand extends SenderProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
AppLog.log("App发给锁的数据,指令类型是:${commandType!.typeName} 加密之前数据是:$data");
|
||||
printLog(data);
|
||||
// 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864
|
||||
ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB);
|
||||
return ebcData;
|
||||
|
||||
@ -33,6 +33,15 @@ class ReadSupportFunctionsWithParametersCommand extends SenderProtocol {
|
||||
this.privateKey,
|
||||
}) : super(CommandType.generalExtendedCommond);
|
||||
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ReadSupportFunctionsWithParametersCommand{keyID: $keyID, '
|
||||
'userID: $userID, featureBit: $featureBit, token: $token, '
|
||||
'needAuthor: $needAuthor, publicKey: $publicKey, '
|
||||
'privateKey: $privateKey}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<int> messageDetail() {
|
||||
List<int> data = [];
|
||||
@ -97,7 +106,7 @@ class ReadSupportFunctionsWithParametersCommand extends SenderProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
AppLog.log("App发给锁的数据,指令类型是:${commandType!.typeName} 加密之前数据是:$data");
|
||||
printLog(data);
|
||||
// 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864
|
||||
ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB);
|
||||
return ebcData;
|
||||
|
||||
@ -34,6 +34,15 @@ class SenderReferEventRecordNumberCommand extends SenderProtocol {
|
||||
this.privateKey,
|
||||
}) : super(CommandType.generalExtendedCommond);
|
||||
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'SenderReferEventRecordNumberCommand{keyID: $keyID, '
|
||||
'userID: $userID, logsCount: $logsCount, logsNo: $logsNo, '
|
||||
'token: $token, needAuthor: $needAuthor, publicKey: $publicKey, '
|
||||
'privateKey: $privateKey}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<int> messageDetail() {
|
||||
List<int> data = [];
|
||||
@ -104,7 +113,7 @@ class SenderReferEventRecordNumberCommand extends SenderProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
AppLog.log("App发给锁的数据,指令类型是:${commandType!.typeName} 加密之前数据是:$data");
|
||||
printLog(data);
|
||||
// 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864
|
||||
ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB);
|
||||
return ebcData;
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
|
||||
//TODO:查询事件记录(时间查询)
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/tools/dateTool.dart';
|
||||
|
||||
import '../../app_settings/app_settings.dart';
|
||||
import '../io_reply.dart';
|
||||
@ -13,7 +13,6 @@ import '../sm4Encipher/sm4.dart';
|
||||
import 'package:crypto/crypto.dart' as crypto;
|
||||
|
||||
class SenderReferEventRecordTimeCommand extends SenderProtocol {
|
||||
|
||||
String? keyID;
|
||||
String? userID;
|
||||
int? logsCount;
|
||||
@ -34,6 +33,14 @@ class SenderReferEventRecordTimeCommand extends SenderProtocol {
|
||||
this.privateKey,
|
||||
}) : super(CommandType.generalExtendedCommond);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'SenderReferEventRecordTimeCommand{keyID: $keyID, '
|
||||
'userID: $userID, logsCount: $logsCount, time: ${DateTool().dateIntToYMDHNString(time)}, '
|
||||
'token: $token, needAuthor: $needAuthor, publicKey: $publicKey, '
|
||||
'privateKey: $privateKey}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<int> messageDetail() {
|
||||
List<int> data = [];
|
||||
@ -73,7 +80,7 @@ class SenderReferEventRecordTimeCommand extends SenderProtocol {
|
||||
// token
|
||||
// subData.addAll(token!);
|
||||
|
||||
if(needAuthor == 0){
|
||||
if (needAuthor == 0) {
|
||||
//AuthCodeLen 1
|
||||
subData.add(0);
|
||||
} else {
|
||||
@ -106,8 +113,7 @@ class SenderReferEventRecordTimeCommand extends SenderProtocol {
|
||||
data.add(0);
|
||||
}
|
||||
}
|
||||
|
||||
AppLog.log("App发给锁的数据,指令类型是:${commandType!.typeName} 加密之前数据是:$data");
|
||||
printLog(data);
|
||||
// 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864
|
||||
ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB);
|
||||
return ebcData;
|
||||
@ -115,10 +121,11 @@ class SenderReferEventRecordTimeCommand extends SenderProtocol {
|
||||
}
|
||||
|
||||
class SenderReferEventRecordTimeReply extends Reply {
|
||||
SenderReferEventRecordTimeReply.parseData(CommandType commandType, List<int> dataDetail)
|
||||
SenderReferEventRecordTimeReply.parseData(
|
||||
CommandType commandType, List<int> dataDetail)
|
||||
: super.parseData(commandType, dataDetail) {
|
||||
data = dataDetail;
|
||||
int status = data[2];
|
||||
errorWithStstus(status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/tools/dateTool.dart';
|
||||
|
||||
import '../../app_settings/app_settings.dart';
|
||||
import '../io_tool/io_tool.dart';
|
||||
@ -16,7 +16,6 @@ import 'package:crypto/crypto.dart' as crypto;
|
||||
备注:删除单个密码规则:pwd 设置为 6 个 0,UseCountLimit 设置为 0。删除全部密码规则:pwd 设置为 6 个 0,UseCountLimit 设置为 0,pwdNo 设置为 255,userId 设置为“DeleteAll !@#”,只有门锁管理员才有权限
|
||||
**/
|
||||
class SenderCustomPasswordsCommand extends SenderProtocol {
|
||||
|
||||
String? keyID;
|
||||
String? userID;
|
||||
int? pwdNo;
|
||||
@ -43,6 +42,16 @@ class SenderCustomPasswordsCommand extends SenderProtocol {
|
||||
this.privateKey,
|
||||
}) : super(CommandType.generalExtendedCommond);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'SenderCustomPasswordsCommand{keyID: $keyID, userID: $userID, '
|
||||
'pwdNo: $pwdNo, pwd: $pwd, useCountLimit: $useCountLimit, '
|
||||
'token: $token, '
|
||||
'startTime: ${DateTool().dateIntToYMDHNString(startTime)}, '
|
||||
'endTime: ${DateTool().dateIntToYMDHNString(endTime)}, '
|
||||
'needAuthor: $needAuthor, signKey: $signKey, privateKey: $privateKey}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<int> messageDetail() {
|
||||
List<int> data = [];
|
||||
@ -100,7 +109,7 @@ class SenderCustomPasswordsCommand extends SenderProtocol {
|
||||
subData.add((endTime! & 0xff00) >> 8);
|
||||
subData.add((endTime! & 0xff));
|
||||
|
||||
if(needAuthor == 0){
|
||||
if (needAuthor == 0) {
|
||||
//AuthCodeLen 1
|
||||
subData.add(0);
|
||||
} else {
|
||||
@ -134,7 +143,7 @@ class SenderCustomPasswordsCommand extends SenderProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
AppLog.log("App发给锁的数据,指令类型是:${commandType!.typeName} 加密之前数据是:$data");
|
||||
printLog(data);
|
||||
// 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864
|
||||
ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB);
|
||||
return ebcData;
|
||||
@ -142,10 +151,11 @@ class SenderCustomPasswordsCommand extends SenderProtocol {
|
||||
}
|
||||
|
||||
class SenderCustomPasswordsReply extends Reply {
|
||||
SenderCustomPasswordsReply.parseData(CommandType commandType, List<int> dataDetail)
|
||||
SenderCustomPasswordsReply.parseData(
|
||||
CommandType commandType, List<int> dataDetail)
|
||||
: super.parseData(commandType, dataDetail) {
|
||||
data = dataDetail;
|
||||
int status = data[2];
|
||||
errorWithStstus(status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -35,6 +35,16 @@ class SetSupportFunctionsNoParametersCommand extends SenderProtocol {
|
||||
this.privateKey,
|
||||
}) : super(CommandType.generalExtendedCommond);
|
||||
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'SetSupportFunctionsNoParametersCommand{keyID: $keyID, '
|
||||
'userID: $userID, featureBit: $featureBit, '
|
||||
'featureEnable: $featureEnable, token: $token, '
|
||||
'needAuthor: $needAuthor, publicKey: $publicKey, '
|
||||
'privateKey: $privateKey}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<int> messageDetail() {
|
||||
List<int> data = [];
|
||||
@ -102,7 +112,7 @@ class SetSupportFunctionsNoParametersCommand extends SenderProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
AppLog.log("App发给锁的数据,指令类型是:${commandType!.typeName} 加密之前数据是:$data");
|
||||
printLog(data);
|
||||
// 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864
|
||||
ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB);
|
||||
return ebcData;
|
||||
|
||||
@ -37,6 +37,16 @@ class SetSupportFunctionsWithParametersCommand extends SenderProtocol {
|
||||
this.privateKey,
|
||||
}) : super(CommandType.generalExtendedCommond);
|
||||
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'SetSupportFunctionsWithParametersCommand{keyID: $keyID, '
|
||||
'userID: $userID, featureBit: $featureBit, '
|
||||
'featureParaLength: $featureParaLength, featureData: $featureData, '
|
||||
'token: $token, needAuthor: $needAuthor, publicKey: $publicKey, '
|
||||
'privateKey: $privateKey}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<int> messageDetail() {
|
||||
List<int> data = [];
|
||||
@ -107,7 +117,7 @@ class SetSupportFunctionsWithParametersCommand extends SenderProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
AppLog.log("App发给锁的数据,指令类型是:${commandType!.typeName} 加密之前数据是:$data");
|
||||
printLog(data);
|
||||
// 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864
|
||||
ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB);
|
||||
return ebcData;
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
|
||||
import 'dart:convert';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/tools/dateTool.dart';
|
||||
|
||||
import '../../app_settings/app_settings.dart';
|
||||
import '../io_tool/io_tool.dart';
|
||||
@ -29,6 +30,15 @@ class TimingCommand extends SenderProtocol {
|
||||
this.privateKey
|
||||
}) : super(CommandType.calibrationTime);
|
||||
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'TimingCommand{lockID: $lockID, userID: $userID, '
|
||||
'nowTime: ${DateTool().dateIntToYMDHNString(nowTime)}, '
|
||||
'token: $token, needAuthor: $needAuthor, '
|
||||
'signKey: $signKey, privateKey: $privateKey}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<int> messageDetail() {
|
||||
List<int> data = [];
|
||||
@ -66,7 +76,7 @@ class TimingCommand extends SenderProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
AppLog.log("App发给锁的数据,指令类型是:${commandType!.typeName} 加密之前数据是:$data");
|
||||
printLog(data);
|
||||
ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB);
|
||||
return ebcData;
|
||||
}
|
||||
|
||||
@ -35,6 +35,15 @@ class TransferPermissionsCommand extends SenderProtocol {
|
||||
this.token
|
||||
}) : super(CommandType.transferPermissions);
|
||||
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'TransferPermissionsCommand{lockID: $lockID, '
|
||||
'authUserID: $authUserID, keyID: $keyID, oldUserID: $oldUserID, '
|
||||
'newUserID: $newUserID, needAuthor: $needAuthor, '
|
||||
'publicKey: $publicKey, privateKey: $privateKey, token: $token}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<int> messageDetail() {
|
||||
List<int> data = [];
|
||||
@ -107,7 +116,7 @@ class TransferPermissionsCommand extends SenderProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
AppLog.log("App发给锁的数据,指令类型是:${commandType!.typeName} 加密之前数据是:$data");
|
||||
printLog(data);
|
||||
ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB);
|
||||
return ebcData;
|
||||
}
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:star_lock/app_settings/app_settings.dart';
|
||||
|
||||
import 'io_tool/io_manager.dart';
|
||||
import 'io_tool/io_tool.dart';
|
||||
import 'io_type.dart';
|
||||
@ -31,6 +33,10 @@ abstract class SenderProtocol extends IOData {
|
||||
_commandIndex = IoManager().commandIndex;
|
||||
}
|
||||
|
||||
void printLog(List<int> data){
|
||||
AppLog.log("App -> 锁,指令类型:${commandType!.typeName} \n\n参数是:\n${toString()} \n\n加密之前数据是:\n$data");
|
||||
}
|
||||
|
||||
//TODO:拼装数据
|
||||
List<int> packageData() {
|
||||
commandData = messageDetail();
|
||||
|
||||
@ -32,10 +32,11 @@ class CommandSenderManager {
|
||||
|
||||
void initLockAddUserSucceedEvent() {
|
||||
// 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus
|
||||
_passCurrentLockInformationEvent = eventBus.on<LockAddUserSucceedEvent>().listen((event) {
|
||||
if(event.type == 0){
|
||||
_passCurrentLockInformationEvent =
|
||||
eventBus.on<LockAddUserSucceedEvent>().listen((event) {
|
||||
if (event.type == 0) {
|
||||
_sendNormalData(dataBeforeAddTheUser);
|
||||
}else{
|
||||
} else {
|
||||
_sendNormalData(event.dataList);
|
||||
}
|
||||
});
|
||||
@ -45,29 +46,27 @@ class CommandSenderManager {
|
||||
bool canSendControlCommand = false;
|
||||
|
||||
//TODO:发送常规数据
|
||||
Future<void> managerSendData ({required SenderProtocol command, bool isBeforeAddUser = false, CommandSendCallBack? callBack}) async {
|
||||
Future<void> managerSendData(
|
||||
{required SenderProtocol command,
|
||||
bool isBeforeAddUser = false,
|
||||
CommandSendCallBack? callBack}) async {
|
||||
if (callBack != null) {
|
||||
// if (!BluetoothManager().connected) {
|
||||
AppLog.log('❌ 蓝牙断开了');
|
||||
if (callBack != null) {
|
||||
AppLog.log('managerSendData ❌ callBack');
|
||||
// EasyLoading.dismiss();
|
||||
callBack(ErrorType.notConnected);
|
||||
}
|
||||
AppLog.log('managerSendData ❌ callBack');
|
||||
callBack(ErrorType.notConnected);
|
||||
return;
|
||||
}
|
||||
|
||||
List<int> value = command.packageData();
|
||||
if(isBeforeAddUser == true){
|
||||
if (isBeforeAddUser == true) {
|
||||
_sendNormalData(value);
|
||||
}else{
|
||||
if(CommonDataManage().currentLockUserNo == 0){
|
||||
} else {
|
||||
if (CommonDataManage().currentLockUserNo == 0) {
|
||||
// 先添加用户
|
||||
var entity = await SenderBeforeDataManage().getAddUserKeyData();
|
||||
_sendNormalData(entity);
|
||||
dataBeforeAddTheUser = value;
|
||||
return;
|
||||
}else{
|
||||
} else {
|
||||
_sendNormalData(value);
|
||||
}
|
||||
}
|
||||
@ -75,7 +74,8 @@ class CommandSenderManager {
|
||||
|
||||
void _sendNormalData(List<int> data) async {
|
||||
if (data.isNotEmpty) {
|
||||
EventBusManager().eventBusFir(EventSendModel(data: data, sendChannel: DataChannel.ble));
|
||||
EventBusManager().eventBusFir(
|
||||
EventSendModel(data: data, sendChannel: DataChannel.ble));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,13 +1,11 @@
|
||||
|
||||
import 'package:date_format/date_format.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'pickers/time_picker/model/pduration.dart';
|
||||
|
||||
class DateTool {
|
||||
|
||||
/// 获取当前年月日时分秒
|
||||
String getNowDateWithType(int type){
|
||||
String getNowDateWithType(int type) {
|
||||
var dateStr = '';
|
||||
// 获取当前时间对象
|
||||
DateTime now = DateTime.now();
|
||||
@ -24,37 +22,44 @@ class DateTool {
|
||||
//获取当前时间的秒
|
||||
int millisecond = now.millisecond;
|
||||
|
||||
switch(type){
|
||||
switch (type) {
|
||||
case 1:
|
||||
// 年月日时分秒
|
||||
dateStr = '$year-${month.toString().padLeft(2, '0')}-${day.toString().padLeft(2, '0')} ${hour.toString().padLeft(2, '0')}:${minute.toString().padLeft(2, '0')}:${millisecond.toString().padLeft(2, '0')}';
|
||||
dateStr =
|
||||
'$year-${month.toString().padLeft(2, '0')}-${day.toString().padLeft(2, '0')} ${hour.toString().padLeft(2, '0')}:${minute.toString().padLeft(2, '0')}:${millisecond.toString().padLeft(2, '0')}';
|
||||
break;
|
||||
case 2:
|
||||
// 年月日时分
|
||||
dateStr = '$year-${month.toString().padLeft(2, '0')}-${day.toString().padLeft(2, '0')} ${hour.toString().padLeft(2, '0')}:${minute.toString().padLeft(2, '0')}';
|
||||
dateStr =
|
||||
'$year-${month.toString().padLeft(2, '0')}-${day.toString().padLeft(2, '0')} ${hour.toString().padLeft(2, '0')}:${minute.toString().padLeft(2, '0')}';
|
||||
break;
|
||||
case 3:
|
||||
// 年月日时整点
|
||||
dateStr = '$year-${month.toString().padLeft(2, '0')}-${day.toString().padLeft(2, '0')} ${hour.toString().padLeft(2, '0')}:00';
|
||||
dateStr =
|
||||
'$year-${month.toString().padLeft(2, '0')}-${day.toString().padLeft(2, '0')} ${hour.toString().padLeft(2, '0')}:00';
|
||||
break;
|
||||
case 4:
|
||||
// 年月日
|
||||
dateStr = '$year-${month.toString().padLeft(2, '0')}-${day.toString().padLeft(2, '0')}';
|
||||
dateStr =
|
||||
'$year-${month.toString().padLeft(2, '0')}-${day.toString().padLeft(2, '0')}';
|
||||
break;
|
||||
case 5:
|
||||
// 时分秒
|
||||
dateStr = '${hour.toString().padLeft(2, '0')}:${minute.toString().padLeft(2, '0')}:${millisecond.toString().padLeft(2, '0')}';
|
||||
dateStr =
|
||||
'${hour.toString().padLeft(2, '0')}:${minute.toString().padLeft(2, '0')}:${millisecond.toString().padLeft(2, '0')}';
|
||||
break;
|
||||
case 6:
|
||||
// 时分
|
||||
dateStr = '${hour.toString().padLeft(2, '0')}:${minute.toString().padLeft(2, '0')}';
|
||||
dateStr =
|
||||
'${hour.toString().padLeft(2, '0')}:${minute.toString().padLeft(2, '0')}';
|
||||
break;
|
||||
case 7:
|
||||
// 小时整点
|
||||
dateStr = '${hour.toString().padLeft(2, '0')}:00';
|
||||
break;
|
||||
default:
|
||||
dateStr = '$year-${month.toString().padLeft(2, '0')}-${day.toString().padLeft(2, '0')} ${hour.toString().padLeft(2, '0')}:${minute.toString().padLeft(2, '0')}:${millisecond.toString().padLeft(2, '0')}';
|
||||
dateStr =
|
||||
'$year-${month.toString().padLeft(2, '0')}-${day.toString().padLeft(2, '0')} ${hour.toString().padLeft(2, '0')}:${minute.toString().padLeft(2, '0')}:${millisecond.toString().padLeft(2, '0')}';
|
||||
break;
|
||||
}
|
||||
return dateStr;
|
||||
@ -70,7 +75,7 @@ class DateTool {
|
||||
|
||||
/// 根据传入的PDuration及时间类型获取时间字符串
|
||||
/// type 1: 年月日时分(2023-01-01 12:00) 2: 年月日(2023-01-01) 3: 时分(12:00)
|
||||
String getYMDHNDateString(PDuration p, int type){
|
||||
String getYMDHNDateString(PDuration p, int type) {
|
||||
var year = p.year == 0 ? DateTime.now().year : p.year;
|
||||
var month = p.month == 0 ? DateTime.now().month : p.month;
|
||||
var day = p.day == 0 ? DateTime.now().day : p.day;
|
||||
@ -78,29 +83,34 @@ class DateTool {
|
||||
var minute = p.minute == 0 ? DateTime.now().minute : p.minute;
|
||||
|
||||
var dateStr = '';
|
||||
switch(type){
|
||||
switch (type) {
|
||||
case 1:
|
||||
// 年月日时分(2023-01-01 12:48)
|
||||
dateStr = '$year-${month!.toString().padLeft(2, '0')}-${day.toString().padLeft(2, '0')} ${hour.toString().padLeft(2, '0')}:${minute.toString().padLeft(2, '0')}';
|
||||
break;
|
||||
dateStr =
|
||||
'$year-${month!.toString().padLeft(2, '0')}-${day.toString().padLeft(2, '0')} ${hour.toString().padLeft(2, '0')}:${minute.toString().padLeft(2, '0')}';
|
||||
break;
|
||||
case 2:
|
||||
// 年月日(2023-01-01)
|
||||
dateStr = '$year-${month!.toString().padLeft(2, '0')}-${day.toString().padLeft(2, '0')}';
|
||||
dateStr =
|
||||
'$year-${month!.toString().padLeft(2, '0')}-${day.toString().padLeft(2, '0')}';
|
||||
break;
|
||||
case 3:
|
||||
// 时分(12:05)
|
||||
dateStr = '${hour.toString().padLeft(2, '0')}:${minute.toString().padLeft(2, '0')}';
|
||||
dateStr =
|
||||
'${hour.toString().padLeft(2, '0')}:${minute.toString().padLeft(2, '0')}';
|
||||
break;
|
||||
case 4:
|
||||
// 年月日时分(2023-01-01 12:00)整点
|
||||
dateStr = '$year-${month!.toString().padLeft(2, '0')}-${day.toString().padLeft(2, '0')} ${hour.toString().padLeft(2, '0')}:00';
|
||||
dateStr =
|
||||
'$year-${month!.toString().padLeft(2, '0')}-${day.toString().padLeft(2, '0')} ${hour.toString().padLeft(2, '0')}:00';
|
||||
break;
|
||||
case 5:
|
||||
// 时分(12:00)整点
|
||||
// 时分(12:00)整点
|
||||
dateStr = '${hour.toString().padLeft(2, '0')}:00';
|
||||
break;
|
||||
default:
|
||||
dateStr = '$year-${month!.toString().padLeft(2, '0')}-${day.toString().padLeft(2, '0')} ${hour.toString().padLeft(2, '0')}:${minute.toString().padLeft(2, '0')}';
|
||||
dateStr =
|
||||
'$year-${month!.toString().padLeft(2, '0')}-${day.toString().padLeft(2, '0')} ${hour.toString().padLeft(2, '0')}:${minute.toString().padLeft(2, '0')}';
|
||||
break;
|
||||
}
|
||||
return dateStr;
|
||||
@ -108,14 +118,15 @@ class DateTool {
|
||||
|
||||
/// 日期转化为时间戳
|
||||
/// type 0: 12:00 1: 其他
|
||||
int dateToTimestamp(String dateStr, int type){
|
||||
int dateToTimestamp(String dateStr, int type) {
|
||||
int timestamp = 0;
|
||||
if(type == 0){
|
||||
if (type == 0) {
|
||||
List<String> timeParts = dateStr.split(":");
|
||||
DateTime now = DateTime.now();
|
||||
DateTime dateTime = DateTime(now.year, now.month, now.day, int.parse(timeParts[0]), int.parse(timeParts[1]));
|
||||
DateTime dateTime = DateTime(now.year, now.month, now.day,
|
||||
int.parse(timeParts[0]), int.parse(timeParts[1]));
|
||||
timestamp = dateTime.millisecondsSinceEpoch;
|
||||
}else{
|
||||
} else {
|
||||
DateTime dateTime = DateTime.parse(dateStr);
|
||||
timestamp = dateTime.millisecondsSinceEpoch;
|
||||
}
|
||||
@ -123,36 +134,51 @@ class DateTool {
|
||||
}
|
||||
|
||||
/// 将时间戳传化为年月日 (年-月-日 时:分)
|
||||
String dateToYMDHNString(String timestamp){
|
||||
String dateToYMDHNString(String? timestamp) {
|
||||
timestamp ??= '0';
|
||||
int time = int.parse(timestamp);
|
||||
if(timestamp.length == 10){
|
||||
if (timestamp.length == 10) {
|
||||
time = time * 1000;
|
||||
}
|
||||
DateTime nowDate = DateTime.fromMillisecondsSinceEpoch(time);
|
||||
String appointmentDate = formatDate(nowDate, [yyyy,'-',mm,'-',dd,' ',HH,':',nn]);
|
||||
String appointmentDate =
|
||||
formatDate(nowDate, [yyyy, '-', mm, '-', dd, ' ', HH, ':', nn]);
|
||||
return appointmentDate;
|
||||
}
|
||||
|
||||
/// 将时间戳传化为年月日 (年-月-日 时:分)
|
||||
String dateIntToYMDHNString(int? time) {
|
||||
time ??= 0;
|
||||
if (time.toString().length == 10) {
|
||||
time = time * 1000;
|
||||
}
|
||||
DateTime nowDate = DateTime.fromMillisecondsSinceEpoch(time);
|
||||
String appointmentDate =
|
||||
formatDate(nowDate, [yyyy, '-', mm, '-', dd, ' ', HH, ':', nn]);
|
||||
return appointmentDate;
|
||||
}
|
||||
|
||||
/// 将时间戳传化为年月日 (年-月-日)
|
||||
String dateToYMDString(String timestamp){
|
||||
String dateToYMDString(String timestamp) {
|
||||
int time = int.parse(timestamp);
|
||||
DateTime nowDate = DateTime.fromMillisecondsSinceEpoch(time);
|
||||
String appointmentDate = formatDate(nowDate, [yyyy,'-',mm,'-',dd]);
|
||||
String appointmentDate = formatDate(nowDate, [yyyy, '-', mm, '-', dd]);
|
||||
return appointmentDate;
|
||||
}
|
||||
|
||||
/// 将时间戳传化为年月日 (时:分)
|
||||
String dateToHNString(String timestamp){
|
||||
String dateToHNString(String timestamp) {
|
||||
int time = int.parse(timestamp);
|
||||
DateTime nowDate = DateTime.fromMillisecondsSinceEpoch(time);
|
||||
String appointmentDate = formatDate(nowDate, [HH,':',nn]);
|
||||
String appointmentDate = formatDate(nowDate, [HH, ':', nn]);
|
||||
return appointmentDate;
|
||||
}
|
||||
|
||||
/// 获取是否超过现在的时间
|
||||
bool compareTimeIsOvertime(int endTiem){
|
||||
DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(endTiem); // 将时间戳转换为 DateTime
|
||||
DateTime now = DateTime.now(); // 获取当前时间
|
||||
bool compareTimeIsOvertime(int endTiem) {
|
||||
DateTime dateTime =
|
||||
DateTime.fromMillisecondsSinceEpoch(endTiem); // 将时间戳转换为 DateTime
|
||||
DateTime now = DateTime.now(); // 获取当前时间
|
||||
if (now.isAfter(dateTime)) {
|
||||
// 过期
|
||||
return true;
|
||||
@ -162,25 +188,26 @@ class DateTool {
|
||||
}
|
||||
|
||||
/// 获取两个距离当前时间相差几天 1705132260000
|
||||
int compareTimeGetDaysFromNow(int endTiem){
|
||||
DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(endTiem); // 将时间戳转换为 DateTime
|
||||
DateTime now = DateTime.now(); // 获取当前时间
|
||||
Duration difference = dateTime.difference(now); // 计算两个日期之间的差异
|
||||
int days = difference.inDays; // 获取差异的天数
|
||||
int compareTimeGetDaysFromNow(int endTiem) {
|
||||
DateTime dateTime =
|
||||
DateTime.fromMillisecondsSinceEpoch(endTiem); // 将时间戳转换为 DateTime
|
||||
DateTime now = DateTime.now(); // 获取当前时间
|
||||
Duration difference = dateTime.difference(now); // 计算两个日期之间的差异
|
||||
int days = difference.inDays; // 获取差异的天数
|
||||
return days;
|
||||
}
|
||||
|
||||
|
||||
// 根据循环的循环周期转化为对应的整型(Bit0 -- 6 置位分别代表周日 -- 周六)
|
||||
int accordingTheCycleIntoTheCorrespondingNumber(List weekDay){
|
||||
int accordingTheCycleIntoTheCorrespondingNumber(List weekDay) {
|
||||
var weekStr = "00000000";
|
||||
for (var day in weekDay) {
|
||||
int index = day % 7; // 将周日的索引转换为 0
|
||||
weekStr = '${weekStr.substring(0, index)}1${weekStr.substring(index + 1)}';
|
||||
int index = day % 7; // 将周日的索引转换为 0
|
||||
weekStr =
|
||||
'${weekStr.substring(0, index)}1${weekStr.substring(index + 1)}';
|
||||
}
|
||||
// 倒序 weekStr
|
||||
weekStr = weekStr.split('').reversed.join('');
|
||||
int weekRound = int.parse(weekStr, radix: 2);
|
||||
return weekRound;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user