Merge branch 'master' of gitee.com:starlock-cn/app-starlock
This commit is contained in:
commit
4837cd58dd
@ -809,6 +809,7 @@
|
||||
"锁上面添加密码已满": "Lock above add password is full",
|
||||
"密码已存在": "Password already exists",
|
||||
"请输入密码": "Please enter password",
|
||||
"暂无密码,无需重置": "No password, no need to reset",
|
||||
|
||||
"真实姓名":"Real name",
|
||||
"身份证号":"ID number",
|
||||
|
||||
@ -836,6 +836,7 @@
|
||||
"锁上面添加密码已满": "锁上面添加密码已满",
|
||||
"密码已存在": "密码已存在",
|
||||
"请输入密码": "请输入密码",
|
||||
"暂无密码,无需重置": "暂无密码,无需重置",
|
||||
|
||||
"真实姓名":"真实姓名",
|
||||
"身份证号":"身份证号",
|
||||
|
||||
@ -839,6 +839,7 @@
|
||||
"锁上面添加密码已满": "锁上面添加密码已满",
|
||||
"密码已存在": "密码已存在",
|
||||
"请输入密码": "请输入密码",
|
||||
"暂无密码,无需重置": "暂无密码,无需重置",
|
||||
|
||||
"真实姓名":"真实姓名",
|
||||
"身份证号":"身份证号",
|
||||
|
||||
@ -306,7 +306,7 @@ SPEC CHECKSUMS:
|
||||
AMapLocation: 5248aec2455ebb5d104b367813c946430a2ee033
|
||||
app_settings: 017320c6a680cdc94c799949d95b84cb69389ebc
|
||||
audio_service: f509d65da41b9521a61f1c404dd58651f265a567
|
||||
audio_session: 4f3e461722055d21515cf3261b64c973c062f345
|
||||
audio_session: 088d2483ebd1dc43f51d253d4a1c517d9a2e7207
|
||||
audioplayers_darwin: 877d9a4d06331c5c374595e46e16453ac7eafa40
|
||||
auto_orientation: 102ed811a5938d52c86520ddd7ecd3a126b5d39d
|
||||
camera_avfoundation: 8b8d780bcfb6a4a02b0fbe2b4bd17b5b71946e68
|
||||
@ -322,7 +322,7 @@ SPEC CHECKSUMS:
|
||||
flutter_native_contact_picker: bd430ba0fbf82768bb50c2c52a69a65759a8f907
|
||||
flutter_pcm_sound: de0572ca4f99091cc2abfcc31601b8a4ddd33c0e
|
||||
flutter_voice_processor: 2b89b93d69b02227ae3fd58589ee0bcfa3ca2a82
|
||||
fluttertoast: fafc4fa4d01a6a9e4f772ecd190ffa525e9e2d9c
|
||||
fluttertoast: 31b00dabfa7fb7bacd9e7dbee580d7a2ff4bf265
|
||||
fluwx: daa284756ce53442b3d0417ceeda66e981906811
|
||||
google_maps_flutter_ios: d1318b4ff711612cab16862d7a87e31a7403d458
|
||||
GoogleMaps: 20d7b12be49a14287f797e88e0e31bc4156aaeb4
|
||||
@ -351,4 +351,4 @@ SPEC CHECKSUMS:
|
||||
|
||||
PODFILE CHECKSUM: 317f9473a5705c6fe4d79d95e81676f248048fdc
|
||||
|
||||
COCOAPODS: 1.12.1
|
||||
COCOAPODS: 1.14.3
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fluwx/fluwx.dart';
|
||||
import 'package:star_lock/flavors.dart';
|
||||
|
||||
class AppColors {
|
||||
|
||||
49
star_lock/lib/blue/entity/lock_user_no_list_entity.dart
Normal file
49
star_lock/lib/blue/entity/lock_user_no_list_entity.dart
Normal file
@ -0,0 +1,49 @@
|
||||
class LockUserNoListEntity {
|
||||
int? errorCode;
|
||||
String? description;
|
||||
String? errorMsg;
|
||||
Data? data;
|
||||
|
||||
LockUserNoListEntity(
|
||||
{this.errorCode, this.description, this.errorMsg, this.data});
|
||||
|
||||
LockUserNoListEntity.fromJson(Map<String, dynamic> json) {
|
||||
errorCode = json['errorCode'];
|
||||
description = json['description'];
|
||||
errorMsg = json['errorMsg'];
|
||||
if (json['data'] is Map) {
|
||||
data = Data.fromJson(json['data']);
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['errorCode'] = errorCode;
|
||||
data['description'] = description;
|
||||
data['errorMsg'] = errorMsg;
|
||||
data['data'] = this.data;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class Data {
|
||||
List<int>? userNos = [];
|
||||
|
||||
Data({
|
||||
this.userNos,
|
||||
});
|
||||
|
||||
Data.fromJson(Map<String, dynamic> json) {
|
||||
if (json['userNos'] is List) {
|
||||
json['userNos'].forEach((element) {
|
||||
userNos?.add(element);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['userNos'] = userNos;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -1,12 +1,9 @@
|
||||
|
||||
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';
|
||||
import '../io_reply.dart';
|
||||
import '../io_sender.dart';
|
||||
import '../io_type.dart';
|
||||
import 'package:crypto/crypto.dart' as crypto;
|
||||
|
||||
@ -1,10 +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';
|
||||
import '../sm4Encipher/sm4.dart';
|
||||
import '../io_reply.dart';
|
||||
|
||||
@ -1,12 +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';
|
||||
import '../io_reply.dart';
|
||||
import '../io_sender.dart';
|
||||
import '../io_type.dart';
|
||||
import 'package:crypto/crypto.dart' as crypto;
|
||||
|
||||
@ -1,12 +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';
|
||||
import '../io_reply.dart';
|
||||
import '../io_sender.dart';
|
||||
import '../io_type.dart';
|
||||
import 'package:crypto/crypto.dart' as crypto;
|
||||
|
||||
@ -3,7 +3,6 @@ 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';
|
||||
import '../io_reply.dart';
|
||||
|
||||
@ -3,7 +3,6 @@ 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';
|
||||
import '../io_reply.dart';
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:get/get.dart';
|
||||
import 'dart:convert';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:star_lock/tools/dateTool.dart';
|
||||
|
||||
import '../../app_settings/app_settings.dart';
|
||||
import '../io_tool/io_tool.dart';
|
||||
import '../sm4Encipher/sm4.dart';
|
||||
import '../io_reply.dart';
|
||||
@ -21,6 +21,15 @@ class AddUserCommand extends SenderProtocol {
|
||||
int? keyType;
|
||||
int? startDate;
|
||||
int? expireDate;
|
||||
|
||||
int? useCountLimit;
|
||||
int? isRound;
|
||||
int? weekRound;
|
||||
int? startHour;
|
||||
int? startMin;
|
||||
int? endHour;
|
||||
int? endMin;
|
||||
|
||||
int? role;
|
||||
String? password;
|
||||
int? needAuthor;
|
||||
@ -37,6 +46,13 @@ class AddUserCommand extends SenderProtocol {
|
||||
this.keyType,
|
||||
this.startDate,
|
||||
this.expireDate,
|
||||
this.useCountLimit,
|
||||
this.isRound,
|
||||
this.weekRound,
|
||||
this.startHour,
|
||||
this.startMin,
|
||||
this.endHour,
|
||||
this.endMin,
|
||||
this.role,
|
||||
this.password,
|
||||
this.needAuthor,
|
||||
@ -47,13 +63,17 @@ class AddUserCommand extends SenderProtocol {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'AddUserCommand{lockID: $lockID, authUserID: $authUserID, '
|
||||
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}';
|
||||
'useCountLimit: $useCountLimit, isRound: $isRound, '
|
||||
'weekRound: $weekRound, startHour: $startHour, '
|
||||
'startMin: $startMin, endHour: $endHour, '
|
||||
'endMin: $endMin, role: $role, password: $password, '
|
||||
'needAuthor: $needAuthor, publicKey: $publicKey, '
|
||||
'privateKey: $privateKey, token: $token}';
|
||||
}
|
||||
|
||||
@override
|
||||
@ -116,6 +136,20 @@ class AddUserCommand extends SenderProtocol {
|
||||
data.add((d2 & 0xff00) >> 8);
|
||||
data.add((d2 & 0xff));
|
||||
|
||||
//useCountLimit 2
|
||||
double useCountLimitDouble = useCountLimit! / 256;
|
||||
int useCountLimit1 = useCountLimitDouble.toInt();
|
||||
int useCountLimit2 = useCountLimit! % 256;
|
||||
data.add(useCountLimit1);
|
||||
data.add(useCountLimit2);
|
||||
|
||||
data.add(isRound!);
|
||||
data.add(weekRound!);
|
||||
data.add(startHour!);
|
||||
data.add(startMin!);
|
||||
data.add(endHour!);
|
||||
data.add(endMin!);
|
||||
|
||||
// role 长度1 用户角色,0:普通用户,1:管理员,0xff:超级管理员
|
||||
data.add(role!);
|
||||
|
||||
@ -169,7 +203,7 @@ class AddUserReply extends Reply {
|
||||
AddUserReply.parseData(CommandType commandType, List<int> dataDetail)
|
||||
: super.parseData(commandType, dataDetail) {
|
||||
data = dataDetail;
|
||||
int status = data[46];
|
||||
status = data[46];
|
||||
errorWithStstus(status);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
//TODO:查询用户、指纹、密码、卡片数量(用于判断是否同步)
|
||||
import 'dart:convert';
|
||||
|
||||
import '../../app_settings/app_settings.dart';
|
||||
import '../io_reply.dart';
|
||||
import '../io_sender.dart';
|
||||
import '../io_tool/io_tool.dart';
|
||||
|
||||
137
star_lock/lib/blue/io_protocol/io_cleanUpUsers.dart
Normal file
137
star_lock/lib/blue/io_protocol/io_cleanUpUsers.dart
Normal file
@ -0,0 +1,137 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/tools/dateTool.dart';
|
||||
|
||||
import '../../app_settings/app_settings.dart';
|
||||
import '../io_tool/io_tool.dart';
|
||||
import '../sm4Encipher/sm4.dart';
|
||||
import '../io_reply.dart';
|
||||
import '../io_sender.dart';
|
||||
import '../io_type.dart';
|
||||
import 'package:crypto/crypto.dart' as crypto;
|
||||
|
||||
//清理用户
|
||||
class CleanUpUsersCommand extends SenderProtocol {
|
||||
String? lockID;
|
||||
String? authUserID;
|
||||
String? keyID;
|
||||
String? userID;
|
||||
|
||||
List<int>? userNoList;
|
||||
List<int>? token;
|
||||
|
||||
int? needAuthor;
|
||||
List<int>? publicKey;
|
||||
List<int>? privateKey;
|
||||
|
||||
CleanUpUsersCommand({
|
||||
this.lockID,
|
||||
this.authUserID,
|
||||
this.keyID,
|
||||
this.userID,
|
||||
this.needAuthor,
|
||||
this.publicKey,
|
||||
this.privateKey,
|
||||
this.userNoList,
|
||||
this.token,
|
||||
}) : super(CommandType.cleanUpUsers);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'CleanUpUsersCommand{lockID: $lockID, authUserID: $authUserID, '
|
||||
'keyID: $keyID, userID: $userID, userNoList: $userNoList, '
|
||||
'token: $token, needAuthor: $needAuthor, publicKey: $publicKey, '
|
||||
'privateKey: $privateKey}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<int> messageDetail() {
|
||||
List<int> data = [];
|
||||
List<int> ebcData = [];
|
||||
|
||||
// 指令类型
|
||||
int type = commandType!.typeValue;
|
||||
double typeDouble = type / 256;
|
||||
int type1 = typeDouble.toInt();
|
||||
int type2 = type % 256;
|
||||
data.add(type1);
|
||||
data.add(type2);
|
||||
|
||||
// 锁id 40
|
||||
int lockIDLength = utf8.encode(lockID!).length;
|
||||
data.addAll(utf8.encode(lockID!));
|
||||
data = getFixedLengthList(data, 40 - lockIDLength);
|
||||
|
||||
//authUserID 20
|
||||
int authUserIDLength = utf8.encode(authUserID!).length;
|
||||
data.addAll(utf8.encode(authUserID!));
|
||||
data = getFixedLengthList(data, 20 - authUserIDLength);
|
||||
|
||||
//KeyID 40
|
||||
int keyIDLength = utf8.encode(keyID!).length;
|
||||
data.addAll(utf8.encode(keyID!));
|
||||
data = getFixedLengthList(data, 40 - keyIDLength);
|
||||
|
||||
//userID 要接受钥匙的用户的useid 20
|
||||
int userIDLength = utf8.encode(userID!).length;
|
||||
data.addAll(utf8.encode(userID!));
|
||||
data = getFixedLengthList(data, 20 - userIDLength);
|
||||
|
||||
ByteData indexBytes = ByteData(2); // 创建一个长度为2的字节数据
|
||||
indexBytes.setInt16(0, userNoList!.length);
|
||||
List<int> indexList = indexBytes.buffer.asUint8List();
|
||||
data.addAll(indexList);
|
||||
|
||||
data.addAll(userNoList!);
|
||||
|
||||
// token 长度4 首次请求 Token 填 0,如果锁需要鉴权 操作者身份,则会分配动态口令并在应答消息中返回,二次请求时带上。 当token失效或者第一次发送的时候token为0
|
||||
data.addAll(token!);
|
||||
|
||||
if (needAuthor == 0) {
|
||||
//AuthCodeLen 1
|
||||
data.add(0);
|
||||
} else {
|
||||
List<int> authCodeData = [];
|
||||
|
||||
//authUserID
|
||||
authCodeData.addAll(utf8.encode(authUserID!));
|
||||
|
||||
//KeyID
|
||||
authCodeData.addAll(utf8.encode(keyID!));
|
||||
|
||||
//token 4 首次请求 Token 填 0,如果锁需要鉴权操作者身份,则会分配动态口令并在应答消息中返回,二次请求时带上。
|
||||
authCodeData.addAll(token!);
|
||||
|
||||
authCodeData.addAll(publicKey!);
|
||||
|
||||
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
||||
var authCode = crypto.md5.convert(authCodeData);
|
||||
|
||||
data.add(authCode.bytes.length);
|
||||
data.addAll(authCode.bytes);
|
||||
}
|
||||
|
||||
if ((data.length % 16) != 0) {
|
||||
int add = (16 - data.length % 16);
|
||||
for (int i = 0; i < add; i++) {
|
||||
data.add(0);
|
||||
}
|
||||
}
|
||||
|
||||
printLog(data);
|
||||
// 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864
|
||||
ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB);
|
||||
return ebcData;
|
||||
}
|
||||
}
|
||||
|
||||
class CleanUpUsersReply extends Reply {
|
||||
CleanUpUsersReply.parseData(CommandType commandType, List<int> dataDetail)
|
||||
: super.parseData(commandType, dataDetail) {
|
||||
data = dataDetail;
|
||||
status = data[6];
|
||||
errorWithStstus(status);
|
||||
}
|
||||
}
|
||||
@ -2,7 +2,6 @@
|
||||
//TODO:WIFI配网
|
||||
import 'dart:convert';
|
||||
|
||||
import '../../app_settings/app_settings.dart';
|
||||
import '../io_reply.dart';
|
||||
import '../io_sender.dart';
|
||||
import '../io_tool/io_tool.dart';
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
//TODO:添加用户
|
||||
import 'dart:convert';
|
||||
|
||||
import '../../app_settings/app_settings.dart';
|
||||
import '../io_tool/io_tool.dart';
|
||||
import '../sm4Encipher/sm4.dart';
|
||||
import '../io_reply.dart';
|
||||
|
||||
@ -5,7 +5,6 @@ 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';
|
||||
import '../io_reply.dart';
|
||||
|
||||
@ -2,14 +2,7 @@
|
||||
//TODO:添加用户
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../app_settings/app_settings.dart';
|
||||
import '../../tools/storage.dart';
|
||||
import '../blue_manage.dart';
|
||||
import '../io_tool/io_manager.dart';
|
||||
import '../io_tool/io_tool.dart';
|
||||
import '../sender_manage.dart';
|
||||
import '../sm4Encipher/sm4.dart';
|
||||
import '../io_reply.dart';
|
||||
import '../io_sender.dart';
|
||||
|
||||
@ -1,11 +1,10 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/blue/blue_manage.dart';
|
||||
import 'package:star_lock/blue/sm4Encipher/sm4.dart';
|
||||
import 'package:star_lock/tools/dateTool.dart';
|
||||
|
||||
import '../../app_settings/app_settings.dart';
|
||||
import '../io_tool/io_tool.dart';
|
||||
import '../io_reply.dart';
|
||||
import '../io_sender.dart';
|
||||
|
||||
@ -1,12 +1,7 @@
|
||||
|
||||
import 'dart:convert';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../tools/storage.dart';
|
||||
import '../io_tool/io_manager.dart';
|
||||
import '../io_tool/io_tool.dart';
|
||||
import '../sender_manage.dart';
|
||||
import '../io_reply.dart';
|
||||
import '../io_sender.dart';
|
||||
import '../io_type.dart';
|
||||
|
||||
@ -1,9 +1,6 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../app_settings/app_settings.dart';
|
||||
import '../io_reply.dart';
|
||||
import '../io_sender.dart';
|
||||
import '../io_tool/io_tool.dart';
|
||||
@ -14,17 +11,21 @@ class GetStarLockStatuInfoCommand extends SenderProtocol {
|
||||
|
||||
String? lockID;
|
||||
String? userID;
|
||||
int? utcTimeStamp;
|
||||
int? unixTimeStamp;
|
||||
List<int>? privateKey;
|
||||
GetStarLockStatuInfoCommand({
|
||||
this.lockID,
|
||||
this.userID,
|
||||
this.utcTimeStamp,
|
||||
this.unixTimeStamp,
|
||||
this.privateKey
|
||||
}) : super(CommandType.readStarLockStatusInfo);
|
||||
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'GetStarLockStatuInfoCommand{lockID: $lockID, '
|
||||
'utcTimeStamp: $utcTimeStamp, unixTimeStamp: $unixTimeStamp, '
|
||||
'userID: $userID, privateKey: $privateKey}';
|
||||
}
|
||||
|
||||
@ -51,6 +52,18 @@ class GetStarLockStatuInfoCommand extends SenderProtocol {
|
||||
data.addAll(utf8.encode(userID!));
|
||||
data = getFixedLengthList(data, 20 - userIDLength);
|
||||
|
||||
// startDate 4
|
||||
data.add((utcTimeStamp! & 0xff000000) >> 24);
|
||||
data.add((utcTimeStamp! & 0xff0000) >> 16);
|
||||
data.add((utcTimeStamp! & 0xff00) >> 8);
|
||||
data.add((utcTimeStamp! & 0xff));
|
||||
|
||||
// endDate 4
|
||||
data.add((unixTimeStamp! & 0xff000000) >> 24);
|
||||
data.add((unixTimeStamp! & 0xff0000) >> 16);
|
||||
data.add((unixTimeStamp! & 0xff00) >> 8);
|
||||
data.add((unixTimeStamp! & 0xff));
|
||||
|
||||
if ((data.length % 16) != 0) {
|
||||
int add = (16 - data.length % 16);
|
||||
for (int i = 0; i < add; i++) {
|
||||
|
||||
@ -1,9 +1,6 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../app_settings/app_settings.dart';
|
||||
import '../io_reply.dart';
|
||||
import '../io_sender.dart';
|
||||
import '../io_tool/io_tool.dart';
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
|
||||
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';
|
||||
|
||||
@ -183,7 +183,7 @@ class OTAUpgradeReply extends Reply {
|
||||
data = dataDetail;
|
||||
token = data.sublist(2, 6);
|
||||
status = data[6];
|
||||
AppLog.log('--->2' + data.toString());
|
||||
// AppLog.log('--->2' + data.toString());
|
||||
errorWithStstus(status);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,9 +1,7 @@
|
||||
//TODO:查询人脸状态
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../app_settings/app_settings.dart';
|
||||
import '../io_reply.dart';
|
||||
import '../io_sender.dart';
|
||||
import '../io_tool/io_tool.dart';
|
||||
|
||||
@ -2,9 +2,6 @@
|
||||
//TODO:查询指纹状态
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../app_settings/app_settings.dart';
|
||||
import '../io_reply.dart';
|
||||
import '../io_sender.dart';
|
||||
import '../io_tool/io_tool.dart';
|
||||
|
||||
@ -1,9 +1,6 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../app_settings/app_settings.dart';
|
||||
import '../io_tool/io_tool.dart';
|
||||
import '../sm4Encipher/sm4.dart';
|
||||
import '../io_reply.dart';
|
||||
|
||||
@ -2,9 +2,6 @@
|
||||
//TODO:查询事件记录(序号、数量查询)
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../app_settings/app_settings.dart';
|
||||
import '../io_reply.dart';
|
||||
import '../io_sender.dart';
|
||||
import '../io_tool/io_tool.dart';
|
||||
|
||||
@ -1,10 +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';
|
||||
import '../io_sender.dart';
|
||||
import '../io_tool/io_tool.dart';
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/tools/dateTool.dart';
|
||||
|
||||
import '../../app_settings/app_settings.dart';
|
||||
|
||||
110
star_lock/lib/blue/io_protocol/io_senderResetPasswords.dart
Normal file
110
star_lock/lib/blue/io_protocol/io_senderResetPasswords.dart
Normal file
@ -0,0 +1,110 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import '../io_tool/io_tool.dart';
|
||||
import '../sm4Encipher/sm4.dart';
|
||||
import '../io_reply.dart';
|
||||
import '../io_sender.dart';
|
||||
import '../io_type.dart';
|
||||
import 'package:crypto/crypto.dart' as crypto;
|
||||
|
||||
//TODO:重置开锁密码(同时重置自定义密码和离线密码,绑定完锁之后第一个管理员密码不重置)
|
||||
class SenderResetPasswordsCommand extends SenderProtocol {
|
||||
String? keyID;
|
||||
String? userID;
|
||||
List<int>? token;
|
||||
int? needAuthor;
|
||||
List<int>? signKey;
|
||||
List<int>? privateKey;
|
||||
|
||||
SenderResetPasswordsCommand({
|
||||
this.keyID,
|
||||
this.userID,
|
||||
this.token,
|
||||
this.needAuthor,
|
||||
this.signKey,
|
||||
this.privateKey,
|
||||
}) : super(CommandType.generalExtendedCommond);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'SenderCustomPasswordsCommand{keyID: $keyID, userID: $userID, '
|
||||
'token: $token, '
|
||||
'needAuthor: $needAuthor, signKey: $signKey, privateKey: $privateKey}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<int> messageDetail() {
|
||||
List<int> data = [];
|
||||
List<int> subData = [];
|
||||
List<int> ebcData = [];
|
||||
|
||||
// 指令类型
|
||||
data.addAll(intChangList(commandType!.typeValue));
|
||||
|
||||
// 子命令类型
|
||||
data.add(19);
|
||||
|
||||
// keyID 40
|
||||
int keyIDLength = utf8.encode(keyID!).length;
|
||||
subData.addAll(utf8.encode(keyID!));
|
||||
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
||||
|
||||
//userID 20
|
||||
int userIDLength = utf8.encode(userID!).length;
|
||||
subData.addAll(utf8.encode(userID!));
|
||||
subData = getFixedLengthList(subData, 20 - userIDLength);
|
||||
|
||||
// token
|
||||
subData.addAll(token!);
|
||||
|
||||
if (needAuthor == 0) {
|
||||
//AuthCodeLen 1
|
||||
subData.add(0);
|
||||
} else {
|
||||
List<int> authCodeData = [];
|
||||
|
||||
//KeyID
|
||||
authCodeData.addAll(utf8.encode(keyID!));
|
||||
|
||||
//authUserID
|
||||
authCodeData.addAll(utf8.encode(userID!));
|
||||
|
||||
//token 4 首次请求 Token 填 0,如果锁需要鉴权操作者身份,则会分配动态口令并在应答消息中返回,二次请求时带上。
|
||||
authCodeData.addAll(token!);
|
||||
|
||||
authCodeData.addAll(signKey!);
|
||||
|
||||
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
||||
var authCode = crypto.md5.convert(authCodeData);
|
||||
|
||||
subData.add(authCode.bytes.length);
|
||||
subData.addAll(authCode.bytes);
|
||||
}
|
||||
|
||||
data.add(subData.length);
|
||||
data.addAll(subData);
|
||||
|
||||
if ((data.length % 16) != 0) {
|
||||
int add = (16 - data.length % 16);
|
||||
for (int i = 0; i < add; i++) {
|
||||
data.add(0);
|
||||
}
|
||||
}
|
||||
|
||||
printLog(data);
|
||||
// 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864
|
||||
ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB);
|
||||
return ebcData;
|
||||
}
|
||||
}
|
||||
|
||||
class SenderResetPasswordsReply extends Reply {
|
||||
SenderResetPasswordsReply.parseData(
|
||||
CommandType commandType, List<int> dataDetail)
|
||||
: super.parseData(commandType, dataDetail) {
|
||||
data = dataDetail;
|
||||
int status = data[2];
|
||||
errorWithStstus(status);
|
||||
}
|
||||
}
|
||||
@ -1,9 +1,6 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../app_settings/app_settings.dart';
|
||||
import '../io_reply.dart';
|
||||
import '../io_sender.dart';
|
||||
import '../io_tool/io_tool.dart';
|
||||
|
||||
@ -1,9 +1,6 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../app_settings/app_settings.dart';
|
||||
import '../io_reply.dart';
|
||||
import '../io_sender.dart';
|
||||
import '../io_tool/io_tool.dart';
|
||||
|
||||
@ -1,9 +1,8 @@
|
||||
|
||||
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';
|
||||
import '../sm4Encipher/sm4.dart';
|
||||
import '../io_reply.dart';
|
||||
|
||||
@ -1,9 +1,6 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../app_settings/app_settings.dart';
|
||||
import '../io_tool/io_tool.dart';
|
||||
import '../sm4Encipher/sm4.dart';
|
||||
import '../io_reply.dart';
|
||||
|
||||
@ -35,7 +35,7 @@ abstract class SenderProtocol extends IOData {
|
||||
|
||||
void printLog(List<int> data) {
|
||||
AppLog.log(
|
||||
"App -> 锁,指令类型:${commandType!.typeName} \n\n参数是:\n${toString()} \n\n加密之前数据是:\n$data");
|
||||
"App -> 锁,指令类型:${commandType!.typeName} \n参数是:\n${toString()} \n加密之前数据是:\n$data 长度是:${data.length}");
|
||||
}
|
||||
|
||||
//TODO:拼装数据Ï
|
||||
|
||||
@ -7,6 +7,7 @@ enum CommandType {
|
||||
openLock, //开门 = 0x3005
|
||||
readLockStatusInfo, //读取锁状态信息 = 0x300A
|
||||
transferPermissions, //转移权限 = 0x300B
|
||||
cleanUpUsers, //转移权限 = 0x300C
|
||||
reportDoorOpenRecord, //开门记录上报 = 0x3020
|
||||
getLockPublicKey, // 获取锁公钥 = 0x3090
|
||||
getLockPrivateKey, // 获取锁私钥 = 0x3091
|
||||
@ -72,6 +73,11 @@ extension ExtensionCommandType on CommandType {
|
||||
type = CommandType.openLock;
|
||||
}
|
||||
break;
|
||||
case 0x300C:
|
||||
{
|
||||
type = CommandType.cleanUpUsers;
|
||||
}
|
||||
break;
|
||||
case 0x300A:
|
||||
{
|
||||
type = CommandType.readLockStatusInfo;
|
||||
@ -154,6 +160,9 @@ extension ExtensionCommandType on CommandType {
|
||||
case CommandType.openLock:
|
||||
type = 0x3005;
|
||||
break;
|
||||
case CommandType.cleanUpUsers:
|
||||
type = 0x300C;
|
||||
break;
|
||||
case CommandType.readLockStatusInfo:
|
||||
type = 0x300A;
|
||||
break;
|
||||
@ -233,6 +242,9 @@ extension ExtensionCommandType on CommandType {
|
||||
case 0x3005:
|
||||
t = '开门';
|
||||
break;
|
||||
case 0x300C:
|
||||
t = '清理用户';
|
||||
break;
|
||||
case 0x300A:
|
||||
t = '读取锁状态信息';
|
||||
break;
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/app_settings/app_settings.dart';
|
||||
import 'package:star_lock/blue/blue_manage.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_addFace.dart';
|
||||
@ -9,7 +8,6 @@ import 'package:star_lock/blue/io_protocol/io_changeAdministratorPassword.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_deletUser.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_editUser.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_factoryDataReset.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_getLockStatu.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_otaUpgrade.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_processOtaUpgrade.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_queryingFaceStatus.dart';
|
||||
@ -24,17 +22,10 @@ import 'package:star_lock/blue/io_protocol/io_transferPermissions.dart';
|
||||
|
||||
import '../tools/storage.dart';
|
||||
|
||||
// import 'io_protocol/io_addFingerprint.dart';
|
||||
import 'io_protocol/io_addFingerprintWithTimeCycleCoercion.dart';
|
||||
|
||||
// import 'io_protocol/io_addICCard.dart';
|
||||
import 'io_protocol/io_addICCardWithTimeCycleCoercion.dart';
|
||||
import 'io_protocol/io_addStressFingerprint.dart';
|
||||
|
||||
// import 'io_protocol/io_addStressICCard.dart';
|
||||
import 'io_protocol/io_addStressPassword.dart';
|
||||
import 'io_protocol/io_addUser.dart';
|
||||
import 'io_protocol/io_automaticPadlock.dart';
|
||||
import 'io_protocol/io_checkingCardStatus.dart';
|
||||
import 'io_protocol/io_checkingUserInfoCount.dart';
|
||||
import 'io_protocol/io_configuringWifi.dart';
|
||||
@ -45,6 +36,7 @@ import 'io_protocol/io_getWifiList.dart';
|
||||
import 'io_protocol/io_openLock.dart';
|
||||
import 'io_protocol/io_queryingFingerprintStatus.dart';
|
||||
import 'io_protocol/io_referEventRecordNumber.dart';
|
||||
import 'io_protocol/io_senderResetPasswords.dart';
|
||||
import 'io_reply.dart';
|
||||
import 'io_protocol/io_senderCustomPasswords.dart';
|
||||
import 'io_type.dart';
|
||||
@ -235,6 +227,13 @@ class CommandReciverManager {
|
||||
commandType, data);
|
||||
}
|
||||
break;
|
||||
case 19:
|
||||
{
|
||||
// 重置开锁密码
|
||||
reply = SenderResetPasswordsReply.parseData(
|
||||
commandType, data);
|
||||
}
|
||||
break;
|
||||
case 20:
|
||||
{
|
||||
// 查询卡片状态
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/blue/sender_manage.dart';
|
||||
import 'package:star_lock/main/lockMian/entity/lockListInfo_entity.dart';
|
||||
import 'package:star_lock/network/api_provider.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import 'package:star_lock/tools/dateTool.dart';
|
||||
import 'package:star_lock/tools/eventBusEventManage.dart';
|
||||
|
||||
import '../app_settings/app_settings.dart';
|
||||
@ -20,6 +22,7 @@ import 'io_tool/manager_event_bus.dart';
|
||||
|
||||
class SenderBeforeDataManage {
|
||||
static SenderBeforeDataManage? _manager;
|
||||
|
||||
SenderBeforeDataManage._init();
|
||||
|
||||
static SenderBeforeDataManage? shareManager() {
|
||||
@ -29,6 +32,7 @@ class SenderBeforeDataManage {
|
||||
}
|
||||
|
||||
factory SenderBeforeDataManage() => shareManager()!;
|
||||
|
||||
SenderBeforeDataManage? get manager => shareManager();
|
||||
|
||||
void _init() {
|
||||
@ -37,9 +41,10 @@ class SenderBeforeDataManage {
|
||||
|
||||
// 监听设备返回的数据
|
||||
StreamSubscription<Reply>? _replySubscription;
|
||||
void _initReplySubscription() {
|
||||
_replySubscription ??= EventBusManager().eventBus!.on<Reply>().listen((reply) async {
|
||||
|
||||
void _initReplySubscription() {
|
||||
_replySubscription ??=
|
||||
EventBusManager().eventBus!.on<Reply>().listen((reply) async {
|
||||
// 添加用户
|
||||
if ((reply is AddUserReply)) {
|
||||
_replyAddUserKey(reply);
|
||||
@ -53,12 +58,12 @@ class SenderBeforeDataManage {
|
||||
switch (status) {
|
||||
case 0x00:
|
||||
//成功
|
||||
CommonDataManage().currentLockUserNo = reply.data[47];
|
||||
CommonDataManage().currentLockUserNo = listChangInt(reply.data.sublist(47, 49));
|
||||
CommonDataManage().currentKeyInfo.lockUserNo = CommonDataManage().currentLockUserNo;
|
||||
_updateLockUserNo();
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
//无权限
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -84,24 +89,78 @@ class SenderBeforeDataManage {
|
||||
// publicKey: publicKeyDataList,
|
||||
// privateKey: getPrivateKeyList,
|
||||
// token: token);
|
||||
AppLog.log("startDate111:${CommonDataManage().currentKeyInfo.startDate} endDate:${CommonDataManage().currentKeyInfo.endDate}");
|
||||
|
||||
LockListInfoItemEntity currentKeyInfo =
|
||||
CommonDataManage().currentKeyInfo;
|
||||
AppLog.log(
|
||||
"startDate111:${currentKeyInfo.startDate} endDate:${currentKeyInfo.endDate}");
|
||||
DateTime startTime = DateTime.fromMillisecondsSinceEpoch(
|
||||
currentKeyInfo.startDate! ~/ 1000);
|
||||
DateTime endTime = DateTime.fromMillisecondsSinceEpoch(
|
||||
currentKeyInfo.endDate! ~/ 1000);
|
||||
bool isRound = currentKeyInfo.keyType == 2;
|
||||
var addUserData = AddUserCommand(
|
||||
lockID: BlueManage().connectDeviceName,
|
||||
authUserID: CommonDataManage().currentKeyInfo.senderUserId!.toString(),
|
||||
keyID: CommonDataManage().currentKeyInfo.keyId.toString(),
|
||||
authUserID: currentKeyInfo.senderUserId!.toString(),
|
||||
keyID: currentKeyInfo.keyId.toString(),
|
||||
userID: await Storage.getUid(),
|
||||
openMode: 1,
|
||||
keyType: 0,
|
||||
startDate: CommonDataManage().currentKeyInfo.startDate!~/1000,
|
||||
expireDate: CommonDataManage().currentKeyInfo.endDate!~/1000,
|
||||
role: CommonDataManage().currentKeyInfo.keyRight == 1 ? 1 : 0,
|
||||
startDate: currentKeyInfo.startDate! ~/ 1000,
|
||||
expireDate: currentKeyInfo.endDate! ~/ 1000,
|
||||
useCountLimit: 0xFFFF,
|
||||
// useCountLimit: 1,
|
||||
isRound: isRound ? 1 : 0,
|
||||
weekRound: isRound
|
||||
? DateTool().accordingTheCycleIntoTheCorrespondingNumber(
|
||||
currentKeyInfo.weekDays!)
|
||||
: 0,
|
||||
startHour: isRound ? startTime.hour : 0,
|
||||
startMin: isRound ? startTime.minute : 0,
|
||||
endHour: isRound ? endTime.hour : 0,
|
||||
endMin: isRound ? endTime.minute : 0,
|
||||
role: currentKeyInfo.keyRight == 1 ? 1 : 0,
|
||||
password: "123456",
|
||||
needAuthor: 1,
|
||||
publicKey: publicKeyDataList,
|
||||
privateKey: getPrivateKeyList,
|
||||
token: token);
|
||||
eventBus.fire(LockAddUserSucceedEvent(addUserData.packageData(), 1));
|
||||
break;
|
||||
case 0x0c:
|
||||
//锁设备用户超过 32个,需要同步锁用户列表刷新
|
||||
var entity = await ApiRepository.to.getLockUserNoList(
|
||||
lockId: CommonDataManage().currentKeyInfo.lockId!);
|
||||
if (!entity.errorCode!.codeIsSuccessful &&
|
||||
(entity.data?.userNos ?? []).isNotEmpty) {
|
||||
return;
|
||||
}
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
var tokenKey = await Storage.getStringList(saveBlueToken);
|
||||
List<int> tokenList = changeStringListToIntList(tokenKey!);
|
||||
AppLog.log('---> ${entity.data?.userNos}');
|
||||
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
IoSenderManage.senderCleanUpUsersCommand(
|
||||
lockID: BlueManage().connectDeviceName,
|
||||
authUserID:
|
||||
CommonDataManage().currentKeyInfo.senderUserId!.toString(),
|
||||
keyID: CommonDataManage().currentKeyInfo.keyId.toString(),
|
||||
userID: await Storage.getUid(),
|
||||
userNoList: entity.data!.userNos!,
|
||||
needAuthor: 1,
|
||||
publicKey: publicKeyDataList,
|
||||
privateKey: getPrivateKeyList,
|
||||
token: tokenList);
|
||||
}
|
||||
});
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
@ -112,23 +171,38 @@ class SenderBeforeDataManage {
|
||||
Future<List<int>> getAddUserKeyData() async {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
LockListInfoItemEntity currentKeyInfo = CommonDataManage().currentKeyInfo;
|
||||
DateTime startTime =
|
||||
DateTime.fromMillisecondsSinceEpoch(currentKeyInfo.startDate! ~/ 1000);
|
||||
DateTime endTime =
|
||||
DateTime.fromMillisecondsSinceEpoch(currentKeyInfo.endDate! ~/ 1000);
|
||||
bool isRound = currentKeyInfo.keyType == 2;
|
||||
|
||||
var addUserData = AddUserCommand(
|
||||
lockID: BlueManage().connectDeviceName,
|
||||
authUserID: CommonDataManage().currentKeyInfo.senderUserId!.toString(),
|
||||
keyID: CommonDataManage().currentKeyInfo.keyId.toString(),
|
||||
authUserID: currentKeyInfo.senderUserId!.toString(),
|
||||
keyID: currentKeyInfo.keyId.toString(),
|
||||
userID: await Storage.getUid(),
|
||||
openMode: 1,
|
||||
keyType: 0,
|
||||
startDate: CommonDataManage().currentKeyInfo.startDate!~/1000,
|
||||
expireDate: CommonDataManage().currentKeyInfo.endDate!~/1000,
|
||||
role: CommonDataManage().currentKeyInfo.keyRight == 1 ? 1 : 0,
|
||||
startDate: currentKeyInfo.startDate! ~/ 1000,
|
||||
expireDate: currentKeyInfo.endDate! ~/ 1000,
|
||||
useCountLimit: 0xFFFF,
|
||||
// useCountLimit: 1,
|
||||
isRound: isRound ? 1 : 0,
|
||||
weekRound: isRound
|
||||
? DateTool().accordingTheCycleIntoTheCorrespondingNumber(
|
||||
currentKeyInfo.weekDays!)
|
||||
: 0,
|
||||
startHour: isRound ? startTime.hour : 0,
|
||||
startMin: isRound ? startTime.minute : 0,
|
||||
endHour: isRound ? endTime.hour : 0,
|
||||
endMin: isRound ? endTime.minute : 0,
|
||||
role: currentKeyInfo.keyRight == 1 ? 1 : 0,
|
||||
password: "123456",
|
||||
needAuthor: 1,
|
||||
publicKey: publicKeyDataList,
|
||||
@ -141,8 +215,7 @@ class SenderBeforeDataManage {
|
||||
void _updateLockUserNo() async {
|
||||
LockNetTokenEntity entity = await ApiRepository.to.updateLockUserNo(
|
||||
keyId: CommonDataManage().currentKeyInfo.keyId.toString(),
|
||||
lockUserNo: CommonDataManage().currentKeyInfo.lockUserNo.toString()
|
||||
);
|
||||
lockUserNo: CommonDataManage().currentKeyInfo.lockUserNo.toString());
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
eventBus.fire(LockAddUserSucceedEvent([0], 0));
|
||||
}
|
||||
@ -151,4 +224,4 @@ class SenderBeforeDataManage {
|
||||
dispose() {
|
||||
_replySubscription!.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,10 +1,8 @@
|
||||
import 'package:star_lock/blue/io_protocol/io_addFace.dart';
|
||||
|
||||
// import 'package:star_lock/blue/io_protocol/io_addICCard.dart';
|
||||
// import 'package:star_lock/blue/io_protocol/io_addStressICCard.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_changeAdministratorPassword.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_cleanUpUsers.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_deletUser.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_getLockStatu.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_otaUpgrade.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_processOtaUpgrade.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_queryingFaceStatus.dart';
|
||||
@ -15,7 +13,6 @@ import 'io_protocol/io_addFaceCancel.dart';
|
||||
import 'io_protocol/io_addFingerprintCancel.dart';
|
||||
import 'io_protocol/io_addFingerprintWithTimeCycleCoercion.dart';
|
||||
import 'io_protocol/io_addICCardWithTimeCycleCoercion.dart';
|
||||
import 'io_protocol/io_addStressFingerprint.dart';
|
||||
import 'io_protocol/io_addStressPassword.dart';
|
||||
import 'io_protocol/io_addUser.dart';
|
||||
import 'io_protocol/io_checkingCardStatus.dart';
|
||||
@ -34,6 +31,7 @@ import 'io_protocol/io_readSupportFunctionsWithParameters.dart';
|
||||
import 'io_protocol/io_referEventRecordNumber.dart';
|
||||
import 'io_protocol/io_referEventRecordTime.dart';
|
||||
import 'io_protocol/io_senderCustomPasswords.dart';
|
||||
import 'io_protocol/io_senderResetPasswords.dart';
|
||||
import 'io_protocol/io_setSupportFunctionsNoParameters.dart';
|
||||
import 'io_protocol/io_setSupportFunctionsWithParameters.dart';
|
||||
import 'io_protocol/io_timing.dart';
|
||||
@ -83,13 +81,20 @@ class IoSenderManage {
|
||||
int? keyType,
|
||||
int? startDate,
|
||||
int? expireDate,
|
||||
int? useCountLimit,
|
||||
int? isRound,
|
||||
int? weekRound,
|
||||
int? startHour,
|
||||
int? startMin,
|
||||
int? endHour,
|
||||
int? endMin,
|
||||
int? role,
|
||||
String? password,
|
||||
int? needAuthor,
|
||||
List<int>? publicKey,
|
||||
List<int>? privateKey,
|
||||
List<int>? token,
|
||||
bool? isBeforeAddUser,
|
||||
bool? isBeforeAddUser,
|
||||
CommandSendCallBack? callBack}) {
|
||||
CommandSenderManager().managerSendData(
|
||||
command: AddUserCommand(
|
||||
@ -101,13 +106,20 @@ class IoSenderManage {
|
||||
keyType: keyType,
|
||||
startDate: startDate,
|
||||
expireDate: expireDate,
|
||||
useCountLimit: useCountLimit,
|
||||
isRound: isRound,
|
||||
weekRound: weekRound,
|
||||
startHour: startHour,
|
||||
startMin: startMin,
|
||||
endHour: endHour,
|
||||
endMin: endMin,
|
||||
role: role,
|
||||
password: password,
|
||||
needAuthor: needAuthor,
|
||||
publicKey: publicKey,
|
||||
privateKey: privateKey,
|
||||
token: token),
|
||||
isBeforeAddUser: isBeforeAddUser!,
|
||||
isBeforeAddUser: isBeforeAddUser ?? false,
|
||||
callBack: callBack);
|
||||
}
|
||||
|
||||
@ -215,15 +227,19 @@ class IoSenderManage {
|
||||
|
||||
//todo:获取星锁状态信息
|
||||
static void senderGetStarLockStatuInfo(
|
||||
{String? lockID,
|
||||
String? userID,
|
||||
List<int>? privateKey,
|
||||
bool? isBeforeAddUser,
|
||||
{required String? lockID,
|
||||
required String? userID,
|
||||
required int? utcTimeStamp,
|
||||
required int? unixTimeStamp,
|
||||
required List<int>? privateKey,
|
||||
required bool? isBeforeAddUser,
|
||||
CommandSendCallBack? callBack}) {
|
||||
CommandSenderManager().managerSendData(
|
||||
command: GetStarLockStatuInfoCommand(
|
||||
lockID: lockID,
|
||||
userID: userID,
|
||||
utcTimeStamp: utcTimeStamp,
|
||||
unixTimeStamp: unixTimeStamp,
|
||||
privateKey: privateKey,
|
||||
),
|
||||
isBeforeAddUser: isBeforeAddUser!,
|
||||
@ -283,7 +299,7 @@ class IoSenderManage {
|
||||
{required String? keyID,
|
||||
required String? userID,
|
||||
required int? pwdNo,
|
||||
required int? operate,
|
||||
required int? operate,
|
||||
required int? isAdmin,
|
||||
required String? pwd,
|
||||
required int? useCountLimit,
|
||||
@ -326,7 +342,7 @@ class IoSenderManage {
|
||||
required int? startTime,
|
||||
required int? endTime,
|
||||
required int? needAuthor,
|
||||
required bool? isBeforeAddUser,
|
||||
required bool? isBeforeAddUser,
|
||||
required List<int>? signKey,
|
||||
required List<int>? privateKey,
|
||||
CommandSendCallBack? callBack}) {
|
||||
@ -348,6 +364,29 @@ class IoSenderManage {
|
||||
callBack: callBack);
|
||||
}
|
||||
|
||||
//todo:重置开锁密码
|
||||
static void senderResetPasswordsCommand(
|
||||
{required String? keyID,
|
||||
required String? userID,
|
||||
required List<int>? token,
|
||||
required int? needAuthor,
|
||||
required bool? isBeforeAddUser,
|
||||
required List<int>? signKey,
|
||||
required List<int>? privateKey,
|
||||
CommandSendCallBack? callBack}) {
|
||||
CommandSenderManager().managerSendData(
|
||||
command: SenderResetPasswordsCommand(
|
||||
keyID: keyID,
|
||||
userID: userID,
|
||||
token: token,
|
||||
needAuthor: needAuthor,
|
||||
signKey: signKey,
|
||||
privateKey: privateKey,
|
||||
),
|
||||
isBeforeAddUser: isBeforeAddUser ?? false,
|
||||
callBack: callBack);
|
||||
}
|
||||
|
||||
//todo:添加指纹开始 弃用
|
||||
// static void senderAddFingerprintCommand(
|
||||
// {required String? keyID,
|
||||
@ -423,12 +462,12 @@ class IoSenderManage {
|
||||
//todo:取消添加指纹
|
||||
static void senderCancelAddFingerprintCommand(
|
||||
{required String? keyID,
|
||||
required String? userID,
|
||||
required List<int>? token,
|
||||
required int? needAuthor,
|
||||
required List<int>? signKey,
|
||||
required List<int>? privateKey,
|
||||
CommandSendCallBack? callBack}) {
|
||||
required String? userID,
|
||||
required List<int>? token,
|
||||
required int? needAuthor,
|
||||
required List<int>? signKey,
|
||||
required List<int>? privateKey,
|
||||
CommandSendCallBack? callBack}) {
|
||||
CommandSenderManager().managerSendData(
|
||||
command: SenderCancelAddFingerprintCommand(
|
||||
keyID: keyID,
|
||||
@ -516,12 +555,12 @@ class IoSenderManage {
|
||||
//todo:取消添加指纹
|
||||
static void senderCancelAddCardCommand(
|
||||
{required String? keyID,
|
||||
required String? userID,
|
||||
required List<int>? token,
|
||||
required int? needAuthor,
|
||||
required List<int>? signKey,
|
||||
required List<int>? privateKey,
|
||||
CommandSendCallBack? callBack}) {
|
||||
required String? userID,
|
||||
required List<int>? token,
|
||||
required int? needAuthor,
|
||||
required List<int>? signKey,
|
||||
required List<int>? privateKey,
|
||||
CommandSendCallBack? callBack}) {
|
||||
CommandSenderManager().managerSendData(
|
||||
command: SenderCancelAddCardCommand(
|
||||
keyID: keyID,
|
||||
@ -580,12 +619,12 @@ class IoSenderManage {
|
||||
//todo:取消添加人脸
|
||||
static void senderCancelAddFaceCommand(
|
||||
{required String? keyID,
|
||||
required String? userID,
|
||||
required List<int>? token,
|
||||
required int? needAuthor,
|
||||
required List<int>? signKey,
|
||||
required List<int>? privateKey,
|
||||
CommandSendCallBack? callBack}) {
|
||||
required String? userID,
|
||||
required List<int>? token,
|
||||
required int? needAuthor,
|
||||
required List<int>? signKey,
|
||||
required List<int>? privateKey,
|
||||
CommandSendCallBack? callBack}) {
|
||||
CommandSenderManager().managerSendData(
|
||||
command: SenderCancelAddFaceCommand(
|
||||
keyID: keyID,
|
||||
@ -1120,4 +1159,31 @@ class IoSenderManage {
|
||||
),
|
||||
callBack: callBack);
|
||||
}
|
||||
|
||||
//清理清理用户
|
||||
static void senderCleanUpUsersCommand(
|
||||
{required String? lockID,
|
||||
required String? userID,
|
||||
required String? keyID,
|
||||
required String? authUserID,
|
||||
required int? needAuthor,
|
||||
required List<int>? userNoList,
|
||||
required List<int>? token,
|
||||
required List<int>? publicKey,
|
||||
required List<int>? privateKey,
|
||||
CommandSendCallBack? callBack}) {
|
||||
CommandSenderManager().managerSendData(
|
||||
command: CleanUpUsersCommand(
|
||||
lockID: lockID,
|
||||
authUserID: authUserID,
|
||||
keyID: keyID,
|
||||
userID: userID,
|
||||
needAuthor: needAuthor,
|
||||
publicKey: publicKey,
|
||||
privateKey: privateKey,
|
||||
userNoList: userNoList,
|
||||
token: token,
|
||||
),
|
||||
callBack: callBack);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,18 +1,33 @@
|
||||
import 'dart:async';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:date_format/date_format.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:rxdart/rxdart.dart';
|
||||
import 'package:star_lock/app_settings/app_colors.dart';
|
||||
import 'package:star_lock/blue/blue_manage.dart';
|
||||
import 'package:star_lock/blue/io_tool/io_tool.dart';
|
||||
import 'package:star_lock/blue/sender_manage.dart';
|
||||
import 'package:star_lock/debug/log.dart';
|
||||
|
||||
import 'package:star_lock/main/lockMian/entity/lockListInfo_entity.dart';
|
||||
import 'package:star_lock/tools/commonDataManage.dart';
|
||||
import 'package:star_lock/tools/dateTool.dart';
|
||||
import 'package:star_lock/tools/storage.dart';
|
||||
|
||||
class DebugConsoleController {
|
||||
final List<DebugConsoleLog> logs;
|
||||
final _streamController = BehaviorSubject<List<DebugConsoleLog>>();
|
||||
|
||||
DebugConsoleController({ List<DebugConsoleLog>? logs }) : logs = logs ?? [];
|
||||
DebugConsoleController({List<DebugConsoleLog>? logs}) : logs = logs ?? [];
|
||||
|
||||
Stream<List<DebugConsoleLog>> get stream => _streamController.stream;
|
||||
|
||||
void close() => _streamController.close();
|
||||
|
||||
void notifyUpdate() => _streamController.add(logs);
|
||||
|
||||
void log(
|
||||
@ -21,14 +36,12 @@ class DebugConsoleController {
|
||||
DateTime? timestamp,
|
||||
StackTrace? stackTrace,
|
||||
}) {
|
||||
logs.add(
|
||||
DebugConsoleLog(
|
||||
message: message,
|
||||
level: level,
|
||||
timestamp: timestamp,
|
||||
stackTrace: stackTrace,
|
||||
)
|
||||
);
|
||||
logs.add(DebugConsoleLog(
|
||||
message: message,
|
||||
level: level,
|
||||
timestamp: timestamp,
|
||||
stackTrace: stackTrace,
|
||||
));
|
||||
notifyUpdate();
|
||||
}
|
||||
|
||||
@ -40,4 +53,106 @@ class DebugConsoleController {
|
||||
logs.clear();
|
||||
notifyUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
void showMore(BuildContext context) {
|
||||
showBottomSheet(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
border: Border.all(width: 1, color: AppColors.btnDisableColor),
|
||||
borderRadius: BorderRadius.circular(30.w),
|
||||
),
|
||||
height: Get.height * 0.7,
|
||||
width: Get.width,
|
||||
padding: EdgeInsets.all(16.w),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text('辅助测试的按钮'),
|
||||
SizedBox(
|
||||
height: 25.h,
|
||||
),
|
||||
Expanded(
|
||||
child: Wrap(
|
||||
children: [
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
EasyLoading.show();
|
||||
randomlyCreate32Users(0, 33)
|
||||
.then((value) => EasyLoading.dismiss())
|
||||
.catchError(EasyLoading.dismiss);
|
||||
},
|
||||
child: const Text('给锁设备创建 32个用户')),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
//随机创建 32个用户
|
||||
Future<void> randomlyCreate32Users(int count, int max) async {
|
||||
if (count >= max) {
|
||||
return;
|
||||
}
|
||||
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> tokenList = changeStringListToIntList(token!);
|
||||
LockListInfoItemEntity currentKeyInfo =
|
||||
CommonDataManage().currentKeyInfo;
|
||||
DateTime startTime = DateTime.fromMillisecondsSinceEpoch(
|
||||
currentKeyInfo.startDate! ~/ 1000);
|
||||
DateTime endTime = DateTime.fromMillisecondsSinceEpoch(
|
||||
currentKeyInfo.endDate! ~/ 1000);
|
||||
|
||||
IoSenderManage.senderAddUser(
|
||||
lockID: BlueManage().connectDeviceName,
|
||||
authUserID:
|
||||
CommonDataManage().currentKeyInfo.senderUserId!.toString(),
|
||||
keyID: CommonDataManage().currentKeyInfo.keyId.toString(),
|
||||
userID: generateRandomString(6),
|
||||
openMode: 1,
|
||||
keyType: 0,
|
||||
startDate: CommonDataManage().currentKeyInfo.startDate! ~/ 1000,
|
||||
expireDate: CommonDataManage().currentKeyInfo.endDate! ~/ 1000,
|
||||
useCountLimit: 0xFFFF,
|
||||
isRound: currentKeyInfo.keyType == 2 ? 1 : 0,
|
||||
weekRound: DateTool().accordingTheCycleIntoTheCorrespondingNumber(
|
||||
currentKeyInfo.weekDays!),
|
||||
startHour: startTime.hour,
|
||||
startMin: startTime.minute,
|
||||
endHour: endTime.hour,
|
||||
endMin: endTime.minute,
|
||||
role: CommonDataManage().currentKeyInfo.keyRight == 1 ? 1 : 0,
|
||||
password: "123456",
|
||||
needAuthor: 1,
|
||||
publicKey: publicKeyDataList,
|
||||
privateKey: getPrivateKeyList,
|
||||
token: tokenList);
|
||||
}
|
||||
});
|
||||
|
||||
await Future.delayed(const Duration(seconds: 2));
|
||||
count++;
|
||||
await randomlyCreate32Users(count, max);
|
||||
}
|
||||
|
||||
//创建指定的随机字符串
|
||||
String generateRandomString(int length) {
|
||||
const chars = 'abcdefghijklmnopqrstuvwxyz0123456789';
|
||||
final random = Random();
|
||||
return List.generate(length, (index) => chars[random.nextInt(chars.length)])
|
||||
.join();
|
||||
}
|
||||
}
|
||||
|
||||
@ -199,15 +199,14 @@ class DebugConsole extends StatefulWidget {
|
||||
static void listen(void Function() body,
|
||||
{DebugConsoleController? controller}) {
|
||||
controller ??= DebugConsole.instance;
|
||||
runZoned(body,
|
||||
zoneSpecification: ZoneSpecification(
|
||||
handleUncaughtError: (Zone self, ZoneDelegate parent, Zone zone,
|
||||
Object error, StackTrace stackTrace) {
|
||||
controller!.log(error,
|
||||
level: DebugConsoleLevel.error, stackTrace: stackTrace);
|
||||
parent.handleUncaughtError(zone, error, stackTrace);
|
||||
},
|
||||
));
|
||||
runZoned(body, zoneSpecification: ZoneSpecification(
|
||||
handleUncaughtError: (Zone self, ZoneDelegate parent, Zone zone,
|
||||
Object error, StackTrace stackTrace) {
|
||||
controller!
|
||||
.log(error, level: DebugConsoleLevel.error, stackTrace: stackTrace);
|
||||
parent.handleUncaughtError(zone, error, stackTrace);
|
||||
},
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@ -318,6 +317,10 @@ class _DebugConsoleState extends State<DebugConsole> {
|
||||
onTap: () => widget.controller.clear(),
|
||||
child: const Text('清除日志'),
|
||||
),
|
||||
PopupMenuItem(
|
||||
onTap: () => widget.controller.showMore(context),
|
||||
child: const Text('更多'),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
|
||||
@ -5,7 +5,6 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../../app_settings/app_colors.dart';
|
||||
import '../../../../blue/blue_manage.dart';
|
||||
import '../../../../tools/appRouteObserver.dart';
|
||||
import '../../../../tools/titleAppBar.dart';
|
||||
import '../../../../translations/trans_lib.dart';
|
||||
|
||||
@ -68,7 +68,7 @@ class DoorLockLogLogic extends BaseGetXController {
|
||||
case 0x00:
|
||||
//成功
|
||||
int dataLength = (reply.data[5] << 8) + reply.data[6];
|
||||
AppLog.log("dataLength:$dataLength");
|
||||
// AppLog.log("dataLength:$dataLength");
|
||||
// var dataLength = reply.data[5];
|
||||
if (dataLength > 0) {
|
||||
reply.data.removeRange(0, 7);
|
||||
|
||||
@ -273,6 +273,8 @@ class AddFaceLogic extends BaseGetXController {
|
||||
featureData: state.featureData.value,
|
||||
addType: state.addType.value,
|
||||
weekDay: state.weekDay.value,
|
||||
startTime: int.parse(state.effectiveDateTime.value),
|
||||
endTime: int.parse(state.failureDateTime.value),
|
||||
faceRight: state.isAdministrator.value == "2" ? 1 : 0,
|
||||
);
|
||||
|
||||
|
||||
@ -12,6 +12,7 @@ class AddFaceTypeState {
|
||||
|
||||
var timeLimitBeginTime = DateTool().dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()).obs;// 限时开始时间
|
||||
var timeLimitEndTime = DateTool().dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()).obs;// 限时结束时间
|
||||
|
||||
var cycleBeginTime = "".obs;// 循环开始时间
|
||||
var cycleEndTime = "".obs;// 循环结束时间
|
||||
var effectiveDateTime = "".obs;// 生效时间
|
||||
|
||||
@ -139,7 +139,7 @@ class _FaceDetailPageState extends State<FaceDetailPage> with RouteAware {
|
||||
child: Obx(() => CommonItem(
|
||||
leftTitel: "有效时间",
|
||||
rightTitle:
|
||||
"${DateTool().dateToHNString(state.startTime.value)}-${DateTool().dateToHNString(state.endTime.value)}",
|
||||
"${DateTool().dateToHNString(state.startDate.value)}-${DateTool().dateToHNString(state.endDate.value)}",
|
||||
isHaveDirection: true,
|
||||
action: () async {
|
||||
var data = await Get.toNamed(
|
||||
@ -169,13 +169,13 @@ class _FaceDetailPageState extends State<FaceDetailPage> with RouteAware {
|
||||
.dateToYMDHNString(state.addTime.value.toString()),
|
||||
)),
|
||||
SizedBox(height: 10.h),
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.stressCard!.tr,
|
||||
rightTitle: "",
|
||||
isTipsImg: false,
|
||||
isHaveRightWidget: true,
|
||||
isHaveLine: true,
|
||||
rightWidget: SizedBox(width: 60.w, height: 50.h, child: _isStressFace()))),
|
||||
// Obx(() => CommonItem(
|
||||
// leftTitel: TranslationLoader.lanKeys!.stressCard!.tr,
|
||||
// rightTitle: "",
|
||||
// isTipsImg: false,
|
||||
// isHaveRightWidget: true,
|
||||
// isHaveLine: true,
|
||||
// rightWidget: SizedBox(width: 60.w, height: 50.h, child: _isStressFace()))),
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: "是否是管理员".tr,
|
||||
rightTitle: "",
|
||||
|
||||
@ -39,7 +39,7 @@ class FaceDetailState {
|
||||
keyType.value = faceItemData.value.faceType!;
|
||||
adder.value = faceItemData.value.senderUsername!;
|
||||
addTime.value = faceItemData.value.createDate!;
|
||||
weekDay.value = faceItemData.value.cyclicConfig!;
|
||||
weekDay.value = faceItemData.value.weekDay!;
|
||||
isStressFace.value = faceItemData.value.isCoerced! == 2 ? true : false;
|
||||
isAdministrator.value = faceItemData.value.faceRight! == 1 ? true : false;
|
||||
}
|
||||
|
||||
@ -116,7 +116,7 @@ class LockDetailLogic extends BaseGetXController {
|
||||
keyID: BlueManage().connectDeviceName,
|
||||
userID: await Storage.getUid(),
|
||||
openMode: state.openDoorModel,
|
||||
openTime: getNetTime(),
|
||||
openTime: getUTCNetTime(),
|
||||
onlineToken: state.lockNetToken,
|
||||
token: tokenData,
|
||||
needAuthor: 1,
|
||||
@ -357,7 +357,7 @@ class LockDetailLogic extends BaseGetXController {
|
||||
keyID: BlueManage().connectDeviceName,
|
||||
userID: await Storage.getUid(),
|
||||
openMode: state.openDoorModel,
|
||||
openTime: getNetTime(),
|
||||
openTime: getUTCNetTime(),
|
||||
onlineToken: state.lockNetToken,
|
||||
token: getTokenList,
|
||||
needAuthor: 1,
|
||||
@ -411,16 +411,14 @@ class LockDetailLogic extends BaseGetXController {
|
||||
|
||||
// 从服务器获取锁的时间 开锁时传入
|
||||
void getServerDatetime() async{
|
||||
var entity = await ApiRepository.to.getServerDatetimeData(
|
||||
lockId: state.keyInfos.value.lockId.toString(),
|
||||
);
|
||||
var entity = await ApiRepository.to.getServerDatetimeData();
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
state.differentialTime = entity.data!.date! ~/ 1000 - DateTime.now().millisecondsSinceEpoch ~/ 1000;
|
||||
// AppLog.log("entity.data!.date! ~/ 1000:${entity.data!.date! ~/ 1000} DateTime.now().millisecondsSinceEpoch ~/ 1000:${DateTime.now().millisecondsSinceEpoch ~/ 1000} 服务器时间差:${state.differentialTime}");
|
||||
}
|
||||
}
|
||||
|
||||
int getNetTime(){
|
||||
int getUTCNetTime(){
|
||||
return DateTime.now().millisecondsSinceEpoch ~/ 1000 + state.differentialTime;
|
||||
}
|
||||
|
||||
|
||||
@ -58,6 +58,8 @@ class UploadElectricQuantityLogic extends BaseGetXController {
|
||||
IoSenderManage.senderGetStarLockStatuInfo(
|
||||
lockID: BlueManage().connectDeviceName,
|
||||
userID: await Storage.getUid(),
|
||||
utcTimeStamp: getUTCNetTime(),
|
||||
unixTimeStamp: getLocalNetTime(),
|
||||
isBeforeAddUser: false,
|
||||
privateKey: getPrivateKeyList,
|
||||
);
|
||||
@ -113,6 +115,8 @@ class UploadElectricQuantityLogic extends BaseGetXController {
|
||||
IoSenderManage.senderGetStarLockStatuInfo(
|
||||
lockID: BlueManage().connectDeviceName,
|
||||
userID: await Storage.getUid(),
|
||||
utcTimeStamp: getUTCNetTime(),
|
||||
unixTimeStamp: getLocalNetTime(),
|
||||
isBeforeAddUser: false,
|
||||
privateKey: getPrivateKeyList,
|
||||
);
|
||||
@ -123,12 +127,37 @@ class UploadElectricQuantityLogic extends BaseGetXController {
|
||||
}
|
||||
}
|
||||
|
||||
// 从服务器获取锁的时间 开锁时传入
|
||||
void getServerDatetime() async{
|
||||
var entity = await ApiRepository.to.getServerDatetimeData();
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
state.differentialTime = entity.data!.date! ~/ 1000 - DateTime.now().millisecondsSinceEpoch ~/ 1000;
|
||||
getLocalNetTime();
|
||||
// AppLog.log("entity.data!.date! ~/ 1000:${entity.data!.date! ~/ 1000} DateTime.now().millisecondsSinceEpoch ~/ 1000:${DateTime.now().millisecondsSinceEpoch ~/ 1000} 服务器时间差:${state.differentialTime}");
|
||||
}
|
||||
}
|
||||
|
||||
int getUTCNetTime(){
|
||||
return DateTime.now().millisecondsSinceEpoch ~/ 1000 + state.differentialTime;
|
||||
}
|
||||
|
||||
int getLocalNetTime(){
|
||||
DateTime utcTime = DateTime.fromMillisecondsSinceEpoch(getUTCNetTime()*1000, isUtc: true);
|
||||
DateTime localTime = utcTime.toLocal();
|
||||
|
||||
// AppLog.log('getUTCNetTime: ${getUTCNetTime()}');
|
||||
// AppLog.log('UTC time: $utcTime');
|
||||
// AppLog.log('Local time: $localTime localTime.millisecondsSinceEpoch ~/ 1000:${localTime.millisecondsSinceEpoch ~/ 1000}');
|
||||
return localTime.millisecondsSinceEpoch ~/ 1000;
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
super.onReady();
|
||||
|
||||
_initReplySubscription();
|
||||
getServerDatetime();
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@ -7,6 +7,7 @@ class UploadElectricQuantityState {
|
||||
var lockSetInfoData = LockSetInfoData().obs;
|
||||
var lockBasicInfo = LockBasicInfo().obs;
|
||||
var uploadElectricQuantityDate = 0.obs;
|
||||
int differentialTime = 0;
|
||||
|
||||
var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示
|
||||
var sureBtnState = 0.obs;// 0普通状态可用 1不可用
|
||||
|
||||
@ -36,38 +36,38 @@ class LockTimeLogic extends BaseGetXController{
|
||||
}
|
||||
|
||||
// 获取锁状态数据解析
|
||||
Future<void> _replyGetStarLockStatusInfo(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
switch (status) {
|
||||
case 0x00:
|
||||
//成功
|
||||
cancelBlueConnetctToastTimer();
|
||||
dismissEasyLoading();
|
||||
|
||||
// 有效时间
|
||||
var indate = reply.data.sublist(149, 153);
|
||||
int indateValue = ((0xff & indate[(0)]) << 24 |
|
||||
(0xff & indate[1]) << 16 |
|
||||
(0xff & indate[2]) << 8 |
|
||||
(0xFF & indate[3]));
|
||||
state.dateTime.value = DateTool().dateToYMDHNString("$indateValue");
|
||||
break;
|
||||
case 0x06:
|
||||
//需要鉴权
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
IoSenderManage.senderGetStarLockStatuInfo(
|
||||
lockID: BlueManage().connectDeviceName,
|
||||
userID: await Storage.getUid(),
|
||||
isBeforeAddUser: false,
|
||||
privateKey: getPrivateKeyList,
|
||||
);
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Future<void> _replyGetStarLockStatusInfo(Reply reply) async {
|
||||
// int status = reply.data[2];
|
||||
// switch (status) {
|
||||
// case 0x00:
|
||||
// //成功
|
||||
// cancelBlueConnetctToastTimer();
|
||||
// dismissEasyLoading();
|
||||
//
|
||||
// // 有效时间
|
||||
// var indate = reply.data.sublist(149, 153);
|
||||
// int indateValue = ((0xff & indate[(0)]) << 24 |
|
||||
// (0xff & indate[1]) << 16 |
|
||||
// (0xff & indate[2]) << 8 |
|
||||
// (0xFF & indate[3]));
|
||||
// state.dateTime.value = DateTool().dateToYMDHNString("$indateValue");
|
||||
// break;
|
||||
// case 0x06:
|
||||
// //需要鉴权
|
||||
// var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
// List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
// IoSenderManage.senderGetStarLockStatuInfo(
|
||||
// lockID: BlueManage().connectDeviceName,
|
||||
// userID: await Storage.getUid(),
|
||||
// isBeforeAddUser: false,
|
||||
// privateKey: getPrivateKeyList,
|
||||
// );
|
||||
// break;
|
||||
// default:
|
||||
// //失败
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
// 校时数据解析
|
||||
Future<void> _replyTiming(Reply reply) async {
|
||||
@ -75,7 +75,7 @@ class LockTimeLogic extends BaseGetXController{
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
String dataEime = DateTool().dateToYMDHNString("${state.dateTimestamp.value}");
|
||||
String dataEime = DateTool().dateToYMDHNString("${getUTCNetTime()}");
|
||||
state.dateTime.value = dataEime;
|
||||
|
||||
state.sureBtnState.value = 0;
|
||||
@ -118,7 +118,7 @@ class LockTimeLogic extends BaseGetXController{
|
||||
lockID:BlueManage().connectDeviceName,
|
||||
userID:await Storage.getUid(),
|
||||
// nowTime:DateTime.now().millisecondsSinceEpoch~/1000,
|
||||
nowTime: state.dateTimestamp.value,
|
||||
nowTime: getUTCNetTime(),
|
||||
token:getTokenList,
|
||||
needAuthor:1,
|
||||
signKey:getSignKeyList,
|
||||
@ -173,19 +173,19 @@ class LockTimeLogic extends BaseGetXController{
|
||||
}
|
||||
}
|
||||
|
||||
// 从服务器获取锁的时间
|
||||
void getServerDatetime(bool isSendBlue) async{
|
||||
var entity = await ApiRepository.to.getServerDatetimeData(
|
||||
lockId: state.lockSetInfoData.value.lockId.toString(),
|
||||
);
|
||||
// 从服务器获取锁的时间 开锁时传入
|
||||
void getServerDatetime() async{
|
||||
var entity = await ApiRepository.to.getServerDatetimeData();
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
state.dateTimestamp.value = entity.data!.date!.toString().length > 10 ? entity.data!.date!~/ 1000 : entity.data!.date!;
|
||||
if(isSendBlue){
|
||||
sendTiming();
|
||||
}
|
||||
state.differentialTime = entity.data!.date! ~/ 1000 - DateTime.now().millisecondsSinceEpoch ~/ 1000;
|
||||
// AppLog.log("entity.data!.date! ~/ 1000:${entity.data!.date! ~/ 1000} DateTime.now().millisecondsSinceEpoch ~/ 1000:${DateTime.now().millisecondsSinceEpoch ~/ 1000} 服务器时间差:${state.differentialTime}");
|
||||
}
|
||||
}
|
||||
|
||||
int getUTCNetTime(){
|
||||
return DateTime.now().millisecondsSinceEpoch ~/ 1000 + state.differentialTime;
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
|
||||
@ -57,7 +57,7 @@ class _LockTimePageState extends State<LockTimePage> with RouteAware{
|
||||
onClick: () {
|
||||
// logic.sendTiming();
|
||||
// logic.getServerDatetime();
|
||||
logic.getServerDatetime(true);
|
||||
logic.getServerDatetime();
|
||||
}),
|
||||
SizedBox(
|
||||
height: 40.h,
|
||||
|
||||
@ -5,7 +5,7 @@ import '../lockSet/lockSetInfo_entity.dart';
|
||||
class LockTimeState{
|
||||
var lockSetInfoData = LockSetInfoData().obs;
|
||||
var dateTime = "".obs;
|
||||
var dateTimestamp = 0.obs;
|
||||
int differentialTime = 0;
|
||||
|
||||
var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示
|
||||
var sureBtnState = 0.obs;// 0普通状态(可用) 1连接中(不可用)
|
||||
|
||||
@ -157,9 +157,9 @@ class PasswordKeyDetailLogic extends BaseGetXController {
|
||||
keyID:state.itemData.value.keyboardPwdId!.toString(),
|
||||
userID:await Storage.getUid(),
|
||||
pwdNo: state.itemData.value.pwdUserNo!,
|
||||
pwd: state.isDeletPasswordKey.value == true ? "0" : state.inputPwdController.text,
|
||||
pwd: state.itemData.value.isCustom == 1 ? state.inputPwdController.text :state.isDeletPasswordKey.value == true ? "0" : state.inputPwdController.text,
|
||||
useCountLimit: 0xffff,
|
||||
operate: state.isDeletPasswordKey.value == true ? 2 : 1,
|
||||
operate: state.itemData.value.isCustom == 1 ? state.isDeletPasswordKey.value == true ? 2 : 1 : 3,
|
||||
isAdmin: state.isAdministrator.value == true ? 1 : 0,
|
||||
startTime:state.itemData.value.startDate! ~/ 1000,
|
||||
endTime:state.itemData.value.endDate! ~/ 1000,
|
||||
|
||||
@ -217,13 +217,7 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> with Rout
|
||||
onClick: () {
|
||||
ShowTipView().showIosTipWithContentDialog("确定要删除吗?".tr, (){
|
||||
state.isDeletPasswordKey.value = true;
|
||||
if(state.itemData.value.isCustom! == 1){
|
||||
// 自定义密码
|
||||
logic.senderCustomPasswords();
|
||||
}else{
|
||||
// 非自定义密码
|
||||
logic.deletePwdRequest();
|
||||
}
|
||||
logic.senderCustomPasswords();
|
||||
});
|
||||
}),
|
||||
],
|
||||
|
||||
@ -9,6 +9,7 @@ import 'package:star_lock/tools/baseGetXController.dart';
|
||||
|
||||
import '../../../../blue/blue_manage.dart';
|
||||
import '../../../../blue/io_protocol/io_senderCustomPasswords.dart';
|
||||
import '../../../../blue/io_protocol/io_senderResetPasswords.dart';
|
||||
import '../../../../blue/io_reply.dart';
|
||||
import '../../../../blue/io_tool/io_tool.dart';
|
||||
import '../../../../blue/io_tool/manager_event_bus.dart';
|
||||
@ -27,24 +28,24 @@ class PasswordKeyListLogic extends BaseGetXController {
|
||||
|
||||
// 添加卡片开始(重置锁里面所有卡)
|
||||
if((reply is SenderCustomPasswordsReply) && (state.ifCurrentScreen.value == true)) {
|
||||
_replyAddICCardBegin(reply);
|
||||
_replyAddPassword(reply);
|
||||
}
|
||||
|
||||
if(reply is SenderResetPasswordsReply){
|
||||
_replyResetPassword(reply);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 添加卡片开始(此处用作删除卡片)
|
||||
Future<void> _replyAddICCardBegin(Reply reply) async {
|
||||
// 添加密码开始(此处用作删除卡片)
|
||||
Future<void> _replyAddPassword(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
cancelBlueConnetctToastTimer();
|
||||
if(state.isDeletAll){
|
||||
resetPasswordKeyListRequest();
|
||||
}else{
|
||||
deletePwdRequest();
|
||||
}
|
||||
deletePwdRequest();
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
@ -54,19 +55,16 @@ class PasswordKeyListLogic extends BaseGetXController {
|
||||
var signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
|
||||
// var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
// List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
var token = reply.data.sublist(5, 9);
|
||||
var saveStrList = changeIntListToStringList(token);
|
||||
Storage.setStringList(saveBlueToken, saveStrList);
|
||||
|
||||
IoSenderManage.senderCustomPasswordsCommand(
|
||||
keyID:state.deletKeyID,
|
||||
keyID:"0",
|
||||
userID:(await Storage.getUid())!,
|
||||
pwdNo:state.pwdNo,
|
||||
pwd:"0",//state.deletPWD,
|
||||
operate: state.isDeletAll ? 3 : 2,
|
||||
operate: 2,
|
||||
isAdmin: 0,
|
||||
useCountLimit: 0xffff,
|
||||
startTime:0x11223344,
|
||||
@ -84,6 +82,130 @@ class PasswordKeyListLogic extends BaseGetXController {
|
||||
}
|
||||
}
|
||||
|
||||
// 重置密码
|
||||
Future<void> _replyResetPassword(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
cancelBlueConnetctToastTimer();
|
||||
state.sureBtnState.value = 0;
|
||||
state.encrpyKey = reply.data.sublist(9, 17);
|
||||
resetPasswordKeyListRequest();
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
|
||||
var token = reply.data.sublist(5, 9);
|
||||
var saveStrList = changeIntListToStringList(token);
|
||||
Storage.setStringList(saveBlueToken, saveStrList);
|
||||
|
||||
IoSenderManage.senderResetPasswordsCommand(
|
||||
keyID:"0",
|
||||
userID:(await Storage.getUid())!,
|
||||
needAuthor: 1,
|
||||
isBeforeAddUser: false,
|
||||
signKey: signKeyDataList,
|
||||
privateKey: getPrivateKeyList,
|
||||
token: token);
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
state.sureBtnState.value = 0;
|
||||
cancelBlueConnetctToastTimer();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 设置自定义密码 这里用作删除密码
|
||||
Future<void> senderCustomPasswords() async {
|
||||
showEasyLoading();
|
||||
showBlueConnetctToastTimer(action: (){
|
||||
dismissEasyLoading();
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
var signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
IoSenderManage.senderCustomPasswordsCommand(
|
||||
keyID:"0",
|
||||
userID:(await Storage.getUid())!,
|
||||
pwdNo:state.pwdNo,
|
||||
pwd:"0",//state.deletPWD,
|
||||
operate: 2,
|
||||
isAdmin: 0,
|
||||
useCountLimit: 0xffff,
|
||||
startTime:0x11223344,
|
||||
endTime:0x11223344,
|
||||
needAuthor: 1,
|
||||
isBeforeAddUser: false,
|
||||
signKey: signKeyDataList,
|
||||
privateKey: getPrivateKeyList,
|
||||
token: getTokenList);
|
||||
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
state.sureBtnState.value = 0;
|
||||
if(state.ifCurrentScreen.value == true){
|
||||
showBlueConnetctToast();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 重置密码
|
||||
Future<void> senderResetPasswords() async {
|
||||
if(state.sureBtnState.value == 1){
|
||||
return;
|
||||
}
|
||||
state.sureBtnState.value = 1;
|
||||
|
||||
showEasyLoading();
|
||||
showBlueConnetctToastTimer(action: (){
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
var signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
IoSenderManage.senderResetPasswordsCommand(
|
||||
keyID:"0",
|
||||
userID:(await Storage.getUid())!,
|
||||
needAuthor: 1,
|
||||
isBeforeAddUser: false,
|
||||
signKey: signKeyDataList,
|
||||
privateKey: getPrivateKeyList,
|
||||
token: getTokenList);
|
||||
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
state.sureBtnState.value = 0;
|
||||
if(state.ifCurrentScreen.value == true){
|
||||
showBlueConnetctToast();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//请求密码钥匙列表
|
||||
Future<PasswordKeyListEntity> mockNetworkDataRequest() async {
|
||||
@ -109,8 +231,10 @@ class PasswordKeyListLogic extends BaseGetXController {
|
||||
|
||||
//密码钥匙重置请求
|
||||
Future<void> resetPasswordKeyListRequest() async {
|
||||
PasswordKeyListEntity entity = await ApiRepository.to
|
||||
.keyboardPwdReset(state.keyInfo.value.lockId.toString());
|
||||
PasswordKeyListEntity entity = await ApiRepository.to.keyboardPwdReset(
|
||||
lockId:state.keyInfo.value.lockId.toString(),
|
||||
passwordKey: state.encrpyKey
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
showToast("重置成功".tr, something: (){
|
||||
pageNo = 1;
|
||||
@ -133,51 +257,6 @@ class PasswordKeyListLogic extends BaseGetXController {
|
||||
}
|
||||
}
|
||||
|
||||
// 设置自定义密码 这里用作删除密码
|
||||
Future<void> senderCustomPasswords() async {
|
||||
|
||||
showEasyLoading();
|
||||
showBlueConnetctToastTimer(action: (){
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
var signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
IoSenderManage.senderCustomPasswordsCommand(
|
||||
keyID:state.deletKeyID,
|
||||
userID:(await Storage.getUid())!,
|
||||
pwdNo:state.pwdNo,
|
||||
pwd:"0",//state.deletPWD,
|
||||
operate: state.isDeletAll ? 3 : 2,
|
||||
isAdmin: 0,
|
||||
useCountLimit: 0xffff,
|
||||
startTime:0x11223344,
|
||||
endTime:0x11223344,
|
||||
needAuthor: 1,
|
||||
isBeforeAddUser: false,
|
||||
signKey: signKeyDataList,
|
||||
privateKey: getPrivateKeyList,
|
||||
token: getTokenList);
|
||||
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
state.sureBtnState.value = 0;
|
||||
if(state.ifCurrentScreen.value == true){
|
||||
showBlueConnetctToast();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//使用期限
|
||||
String getUseDateStr(PasswordKeyListItem indexEntity) {
|
||||
int? getPwdType = indexEntity.keyboardPwdType;
|
||||
|
||||
@ -61,14 +61,12 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage> with RouteAwa
|
||||
onPressed: () async {
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if (isDemoMode == false) {
|
||||
if(state.itemDataList.isEmpty){
|
||||
logic.showToast("暂无密码,无需重置".tr);
|
||||
return;
|
||||
}
|
||||
ShowTipView().showIosTipWithContentDialog('该锁的密码都将被删除'.tr, () {
|
||||
state.isDeletAll = true;
|
||||
state.deletKeyID = "0";
|
||||
state.deletUserID = "0";
|
||||
// state.deletPWD = "";
|
||||
state.pwdNo = 0;
|
||||
|
||||
logic.senderCustomPasswords();
|
||||
logic.senderResetPasswords();
|
||||
});
|
||||
} else {
|
||||
logic.showToast("演示模式".tr);
|
||||
@ -141,10 +139,6 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage> with RouteAwa
|
||||
SlidableAction(
|
||||
onPressed: (BuildContext context){
|
||||
ShowTipView().showIosTipWithContentDialog("确定要删除吗?".tr, () async {
|
||||
state.isDeletAll = false;
|
||||
state.deletUserID = (await Storage.getUid())!;
|
||||
state.deletKeyID = passwordKeyListItem.keyboardPwdId.toString();
|
||||
state.deletPWD = passwordKeyListItem.keyboardPwd!;
|
||||
state.itemData = passwordKeyListItem;
|
||||
state.pwdNo = passwordKeyListItem.pwdUserNo!;
|
||||
logic.senderCustomPasswords();
|
||||
|
||||
@ -13,13 +13,8 @@ class PasswordKeyListState {
|
||||
var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示
|
||||
var sureBtnState = 0.obs;// 0普通状态(可用) 1连接中(不可用)
|
||||
|
||||
// 因为删除跟添加指纹用的同一个协议 所以这里用做判断
|
||||
var isDeletAll = false;
|
||||
var deletKeyID = "";
|
||||
var deletUserID = "DeleteAll!@#";
|
||||
var deletPWD = "";
|
||||
var pwdNo = 0;
|
||||
|
||||
var encrpyKey = <int>[];
|
||||
PasswordKeyListState() {
|
||||
Map map = Get.arguments;
|
||||
keyInfo.value = map["keyInfo"];
|
||||
|
||||
@ -309,7 +309,7 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
|
||||
var endDate = DateTool().dateToTimestamp(state.customEndTime.value, 1);
|
||||
//非永久 须有时限
|
||||
if (state.isPermanent.value == false) {
|
||||
if (startDate <= DateTool().dateToTimestamp(DateTool().getNowDateWithType(2), 1)) {
|
||||
if (startDate < DateTool().dateToTimestamp(DateTool().getNowDateWithType(2), 1)) {
|
||||
showToast("生效时间要大于当前时间");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -25,6 +25,7 @@ import '../../../blue/io_reply.dart';
|
||||
import '../../../blue/io_tool/io_tool.dart';
|
||||
import '../../../blue/io_tool/manager_event_bus.dart';
|
||||
import '../../../blue/sender_manage.dart';
|
||||
import '../../../network/api_repository.dart';
|
||||
import '../../../tools/storage.dart';
|
||||
import 'nearbyLock_state.dart';
|
||||
|
||||
@ -232,14 +233,14 @@ class NearbyLockLogic extends BaseGetXController {
|
||||
// AppLog.log("电池剩余电量 battRemCap:$battRemCap");
|
||||
|
||||
// 重置次数
|
||||
var restoreCounter = reply.data.sublist(133, 135);
|
||||
var restoreCounter = reply.data.sublist(134, 136);
|
||||
state.lockInfo["restoreCount"] =
|
||||
restoreCounter[0] * 256 + restoreCounter[1];
|
||||
AppLog.log(
|
||||
"重置次数 restoreCounter:${restoreCounter[0] * 256 + restoreCounter[1]}");
|
||||
|
||||
// 重置时间
|
||||
var restoreDate = reply.data.sublist(135, 139);
|
||||
var restoreDate = reply.data.sublist(136, 140);
|
||||
int restoreDateValue = ((0xff & restoreDate[(0)]) << 24 |
|
||||
(0xff & restoreDate[1]) << 16 |
|
||||
(0xff & restoreDate[2]) << 8 |
|
||||
@ -249,13 +250,13 @@ class NearbyLockLogic extends BaseGetXController {
|
||||
AppLog.log("重置时间 restoreDateValue:$restoreDateValue");
|
||||
|
||||
// 主控芯片型号
|
||||
var icPartNo = reply.data.sublist(139, 149);
|
||||
var icPartNo = reply.data.sublist(140, 150);
|
||||
var icPartNoStr = utf8String(icPartNo);
|
||||
state.lockInfo["icPartNo"] = icPartNoStr;
|
||||
AppLog.log("主控芯片型号 icPartNoStr:$icPartNoStr");
|
||||
|
||||
// 有效时间
|
||||
var indate = reply.data.sublist(149, 153);
|
||||
var indate = reply.data.sublist(150, 154);
|
||||
int indateValue = ((0xff & indate[(0)]) << 24 |
|
||||
(0xff & indate[1]) << 16 |
|
||||
(0xff & indate[2]) << 8 |
|
||||
@ -265,12 +266,12 @@ class NearbyLockLogic extends BaseGetXController {
|
||||
AppLog.log("有效时间 indateValue:$indateValue");
|
||||
|
||||
// mac地址
|
||||
var macAddress = reply.data.sublist(153, 173);
|
||||
var macAddress = reply.data.sublist(154, 174);
|
||||
var macAddressStr = utf8String(macAddress);
|
||||
state.lockInfo["mac"] = macAddressStr;
|
||||
AppLog.log("mac地址 macAddressStr:$macAddressStr");
|
||||
|
||||
var index = 173;
|
||||
var index = 174;
|
||||
// 锁特征值字符串长度
|
||||
var featureValueLength = reply.data[index];
|
||||
AppLog.log("锁特征值字符串长度 featureValueLength:$featureValueLength");
|
||||
@ -338,10 +339,11 @@ class NearbyLockLogic extends BaseGetXController {
|
||||
IoSenderManage.senderGetStarLockStatuInfo(
|
||||
lockID: BlueManage().connectDeviceName,
|
||||
userID: await Storage.getUid(),
|
||||
utcTimeStamp: getUTCNetTime(),
|
||||
unixTimeStamp: getLocalNetTime(),
|
||||
isBeforeAddUser: true,
|
||||
privateKey: getPrivateKeyList,
|
||||
);
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
@ -360,14 +362,12 @@ class NearbyLockLogic extends BaseGetXController {
|
||||
AppLog.log("开始获取锁状态");
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
// IoSenderManage.senderGetLockStatu(
|
||||
// lockID:BlueManage().connectDeviceName,
|
||||
// userID:await Storage.getUid(),
|
||||
// privateKey:getPrivateKeyList,
|
||||
// );
|
||||
|
||||
IoSenderManage.senderGetStarLockStatuInfo(
|
||||
lockID: BlueManage().connectDeviceName,
|
||||
userID: await Storage.getUid(),
|
||||
utcTimeStamp: getUTCNetTime(),
|
||||
unixTimeStamp: getLocalNetTime(),
|
||||
isBeforeAddUser: true,
|
||||
privateKey: getPrivateKeyList,
|
||||
);
|
||||
@ -598,7 +598,7 @@ class NearbyLockLogic extends BaseGetXController {
|
||||
Uint8List bin = data.sublist(binOffset.toInt(), data.length);
|
||||
//md5 校验有问题,暂时不解析
|
||||
String md5Str = md5.convert(bin).toString().toUpperCase();
|
||||
AppLog.log('---> $md5Str ${meta['fwMd5']}');
|
||||
// AppLog.log('---> $md5Str ${meta['fwMd5']}');
|
||||
if (md5Str != meta['fwMd5']) {
|
||||
showToast('文件校验失败 0x02'.tr);
|
||||
return null;
|
||||
@ -610,11 +610,36 @@ class NearbyLockLogic extends BaseGetXController {
|
||||
return bin;
|
||||
}
|
||||
|
||||
// 从服务器获取锁的时间 开锁时传入
|
||||
void getServerDatetime() async{
|
||||
var entity = await ApiRepository.to.getServerDatetimeData();
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
state.differentialTime = entity.data!.date! ~/ 1000 - DateTime.now().millisecondsSinceEpoch ~/ 1000;
|
||||
getLocalNetTime();
|
||||
// AppLog.log("entity.data!.date! ~/ 1000:${entity.data!.date! ~/ 1000} DateTime.now().millisecondsSinceEpoch ~/ 1000:${DateTime.now().millisecondsSinceEpoch ~/ 1000} 服务器时间差:${state.differentialTime}");
|
||||
}
|
||||
}
|
||||
|
||||
int getUTCNetTime(){
|
||||
return DateTime.now().millisecondsSinceEpoch ~/ 1000 + state.differentialTime;
|
||||
}
|
||||
|
||||
int getLocalNetTime(){
|
||||
DateTime utcTime = DateTime.fromMillisecondsSinceEpoch(getUTCNetTime()*1000, isUtc: true);
|
||||
DateTime localTime = utcTime.toLocal();
|
||||
|
||||
// AppLog.log('getUTCNetTime: ${getUTCNetTime()}');
|
||||
// AppLog.log('UTC time: $utcTime');
|
||||
// AppLog.log('Local time: $localTime localTime.millisecondsSinceEpoch ~/ 1000:${localTime.millisecondsSinceEpoch ~/ 1000}');
|
||||
return localTime.millisecondsSinceEpoch ~/ 1000;
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
super.onReady();
|
||||
_initReplySubscription();
|
||||
state.ifCurrentScreen.value = true;
|
||||
getServerDatetime();
|
||||
startScanBlueList();
|
||||
}
|
||||
|
||||
|
||||
@ -5,6 +5,7 @@ class NearbyLockState {
|
||||
RxList<ScanResult> devices = <ScanResult>[].obs;
|
||||
var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示
|
||||
// var sureBtnState = 0.obs;// 0可点击 1 不可点击
|
||||
int differentialTime = 0;
|
||||
|
||||
var selectLockName = "".obs;
|
||||
|
||||
|
||||
@ -9,6 +9,8 @@ import 'package:get/get.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_changeAdministratorPassword.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_senderCustomPasswords.dart';
|
||||
import 'package:star_lock/blue/io_type.dart';
|
||||
import 'package:star_lock/main/lockMian/entity/lockListInfo_entity.dart';
|
||||
import 'package:star_lock/tools/commonDataManage.dart';
|
||||
|
||||
import '../../../blue/blue_manage.dart';
|
||||
import '../../../blue/io_protocol/io_addUser.dart';
|
||||
@ -56,7 +58,7 @@ class SaveLockLogic extends BaseGetXController {
|
||||
switch (status) {
|
||||
case 0x00:
|
||||
//成功
|
||||
state.lockUserNo = reply.data[47];
|
||||
state.lockUserNo = listChangInt(reply.data.sublist(47, 49));
|
||||
|
||||
cancelBlueConnetctToastTimer();
|
||||
bindBlueAdmin();
|
||||
@ -78,6 +80,13 @@ class SaveLockLogic extends BaseGetXController {
|
||||
keyType: 1,
|
||||
startDate: DateTime.now().millisecondsSinceEpoch,
|
||||
expireDate: 0x11223344,
|
||||
useCountLimit: 0xFFFF,
|
||||
isRound:0,
|
||||
weekRound: 0,
|
||||
startHour: 0,
|
||||
startMin: 0,
|
||||
endHour: 0,
|
||||
endMin: 0,
|
||||
role: 255,
|
||||
password: "123456",
|
||||
needAuthor: 1,
|
||||
@ -207,7 +216,6 @@ class SaveLockLogic extends BaseGetXController {
|
||||
if (token != null) {
|
||||
getTokenList = changeStringListToIntList(token);
|
||||
}
|
||||
|
||||
IoSenderManage.senderAddUser(
|
||||
lockID: BlueManage().connectDeviceName,
|
||||
authUserID:await Storage.getUid(),
|
||||
@ -217,6 +225,13 @@ class SaveLockLogic extends BaseGetXController {
|
||||
keyType:1,
|
||||
startDate:DateTime.now().millisecondsSinceEpoch,
|
||||
expireDate:0x11223344,
|
||||
useCountLimit: 0xFFFF,
|
||||
isRound:0,
|
||||
weekRound: 0,
|
||||
startHour: 0,
|
||||
startMin: 0,
|
||||
endHour: 0,
|
||||
endMin: 0,
|
||||
role:255,
|
||||
password:"123456",
|
||||
needAuthor:1,
|
||||
|
||||
@ -8,9 +8,7 @@ class SelectLockTypeLogic extends BaseGetXController {
|
||||
SelectLockTypeState state = SelectLockTypeState();
|
||||
|
||||
void getServerDatetime() async{
|
||||
var entity = await ApiRepository.to.getServerDatetimeData(
|
||||
lockId: CommonDataManage().currentKeyInfo.lockId.toString(),
|
||||
);
|
||||
var entity = await ApiRepository.to.getServerDatetimeData();
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
}
|
||||
}
|
||||
|
||||
@ -232,4 +232,7 @@ abstract class Api {
|
||||
|
||||
final String getlockCloudStorageListURL = '/lockCloudStorage/list'; //获取云存列表
|
||||
final String deleteLockCloudStorageURL = '/lockCloudStorage/delete'; //删除云存
|
||||
|
||||
final String getUserNoList = '/key/getUserNoList'; //获取指定锁下所有userNo
|
||||
|
||||
}
|
||||
|
||||
@ -810,11 +810,9 @@ class ApiProvider extends BaseProvider {
|
||||
}));
|
||||
|
||||
// 获取服务器当前时间
|
||||
Future<Response> getServerDatetimeLoadData(String lockId) => post(
|
||||
Future<Response> getServerDatetimeLoadData() => post(
|
||||
getServerDatetimeUrl.toUrl,
|
||||
jsonEncode({
|
||||
'lockId': lockId,
|
||||
}),
|
||||
jsonEncode({}),
|
||||
isUnShowLoading: true);
|
||||
|
||||
// 锁诊断
|
||||
@ -1221,6 +1219,8 @@ class ApiProvider extends BaseProvider {
|
||||
String featureData,
|
||||
String addType,
|
||||
List weekDay,
|
||||
int startTime,
|
||||
int endTime,
|
||||
int faceRight,
|
||||
) =>
|
||||
post(
|
||||
@ -1235,6 +1235,8 @@ class ApiProvider extends BaseProvider {
|
||||
'featureData': featureData,
|
||||
'addType': addType,
|
||||
'weekDay': weekDay,
|
||||
'startTime': startTime,
|
||||
'endTime': endTime,
|
||||
'faceRight': faceRight
|
||||
}));
|
||||
|
||||
@ -1610,8 +1612,12 @@ class ApiProvider extends BaseProvider {
|
||||
post(getUserInfoURL.toUrl, jsonEncode({'operatorUid': operatorUid}));
|
||||
|
||||
// 重置密码钥匙
|
||||
Future<Response> keyboardPwdReset(String lockId) =>
|
||||
post(keyboardPwdResetURL.toUrl, jsonEncode({'lockId': lockId}));
|
||||
Future<Response> keyboardPwdReset(String lockId, List passwordKey) =>
|
||||
post(keyboardPwdResetURL.toUrl,
|
||||
jsonEncode({
|
||||
'lockId': lockId,
|
||||
'passwordKey': passwordKey,
|
||||
}));
|
||||
|
||||
//登陆后可使用获取验证码,免图片滑动验证
|
||||
Future<Response> sendValidationCodeAuth(String countryCode, String account,
|
||||
@ -2072,6 +2078,10 @@ class ApiProvider extends BaseProvider {
|
||||
'certifyId': certifyId,
|
||||
'keyId': keyId,
|
||||
}));
|
||||
|
||||
// 获取指定锁下所有userNo
|
||||
Future<Response> getLockUserNoList(int lockId) =>
|
||||
post(getUserNoList.toUrl, jsonEncode({'lockId': lockId}));
|
||||
}
|
||||
|
||||
extension ExtensionString on String {
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/blue/entity/lock_user_no_list_entity.dart';
|
||||
import 'package:star_lock/login/selectCountryRegion/common/countryRegionEntity.dart';
|
||||
import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_entity.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_entity.dart';
|
||||
@ -861,10 +862,8 @@ class ApiRepository {
|
||||
}
|
||||
|
||||
// 获取服务器当前时间
|
||||
Future<GetServerDatetimeEntity> getServerDatetimeData({
|
||||
required String lockId,
|
||||
}) async {
|
||||
final res = await apiProvider.getServerDatetimeLoadData(lockId);
|
||||
Future<GetServerDatetimeEntity> getServerDatetimeData() async {
|
||||
final res = await apiProvider.getServerDatetimeLoadData();
|
||||
return GetServerDatetimeEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
@ -1385,9 +1384,11 @@ class ApiRepository {
|
||||
required String featureData,
|
||||
required String addType,
|
||||
required List weekDay,
|
||||
required int startTime,
|
||||
required int endTime,
|
||||
required int faceRight}) async {
|
||||
final res = await apiProvider.addFaceData(lockId, faceName, faceNumber,
|
||||
faceType, startDate, endDate, featureData, addType, weekDay, faceRight);
|
||||
faceType, startDate, endDate, featureData, addType, weekDay, startTime, endTime, faceRight);
|
||||
return AddFaceEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
@ -1651,8 +1652,11 @@ class ApiRepository {
|
||||
}
|
||||
|
||||
//重置密码钥匙
|
||||
Future<PasswordKeyListEntity> keyboardPwdReset(String lockId) async {
|
||||
final res = await apiProvider.keyboardPwdReset(lockId);
|
||||
Future<PasswordKeyListEntity> keyboardPwdReset({
|
||||
required String lockId,
|
||||
required List passwordKey
|
||||
}) async {
|
||||
final res = await apiProvider.keyboardPwdReset(lockId, passwordKey);
|
||||
return PasswordKeyListEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
@ -2088,4 +2092,12 @@ class ApiRepository {
|
||||
final res = await apiProvider.getServiceCheckCertify(certifyId, keyId);
|
||||
return ServiceAuthResultEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
// 检测certifyId是否完成认证
|
||||
Future<LockUserNoListEntity> getLockUserNoList({
|
||||
required int lockId,
|
||||
}) async {
|
||||
final res = await apiProvider.getLockUserNoList(lockId);
|
||||
return LockUserNoListEntity.fromJson(res.body);
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ class DateTool {
|
||||
var month = p.month == 0 ? DateTime.now().month : p.month;
|
||||
var day = p.day == 0 ? DateTime.now().day : p.day;
|
||||
var hour = p.hour == 0 ? DateTime.now().hour : p.hour;
|
||||
var minute = p.minute == 0 ? DateTime.now().minute : p.minute;
|
||||
var minute = p.minute;
|
||||
|
||||
var dateStr = '';
|
||||
switch (type) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user