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