提交调试蓝牙协议
This commit is contained in:
parent
08e36eee3c
commit
d6fa4edd2e
@ -54,7 +54,7 @@ class SenderAddStressICCardCommand extends SenderProtocol {
|
||||
data.add(type2);
|
||||
|
||||
// 子命令类型
|
||||
data.add(62);
|
||||
data.add(61);
|
||||
|
||||
// keyID 40
|
||||
int keyIDLength = utf8.encode(keyID!).length;
|
||||
|
||||
@ -54,7 +54,7 @@ class SenderAddStressPasswordCommand extends SenderProtocol {
|
||||
data.add(type2);
|
||||
|
||||
// 子命令类型
|
||||
data.add(62);
|
||||
data.add(60);
|
||||
|
||||
// keyID 40
|
||||
int keyIDLength = utf8.encode(keyID!).length;
|
||||
|
||||
@ -65,28 +65,59 @@ class GetStarLockStatuInfoReply extends Reply {
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${commandType.typeValue} 数据解析成功");
|
||||
|
||||
// 厂商名称
|
||||
var vendor = data.sublist(3, 23);
|
||||
// print("softVersion:$softVersion");
|
||||
|
||||
// 锁设备类型
|
||||
var product = data[23];
|
||||
// print("product:product");
|
||||
|
||||
// 产品名称
|
||||
var model = data.sublist(24, 44);
|
||||
// print("model:model");
|
||||
|
||||
// 软件版本
|
||||
var fwVersion = data.sublist(44, 64);
|
||||
// print("fwVersion:fwVersion");
|
||||
|
||||
// 硬件版本
|
||||
var hwVersion = data.sublist(64, 84);
|
||||
// print("hwVersion:hwVersion");
|
||||
// print("${commandType.typeValue} 数据解析成功");
|
||||
|
||||
// // 厂商名称
|
||||
// var vendor = data.sublist(3, 23);
|
||||
// // print("softVersion:$softVersion");
|
||||
//
|
||||
// // 锁设备类型
|
||||
// var product = data[23];
|
||||
// // print("product:product");
|
||||
//
|
||||
// // 产品名称
|
||||
// var model = data.sublist(24, 44);
|
||||
// // print("model:model");
|
||||
//
|
||||
// // 软件版本
|
||||
// var fwVersion = data.sublist(44, 64);
|
||||
// // print("fwVersion:fwVersion");
|
||||
//
|
||||
// // 硬件版本
|
||||
// var hwVersion = data.sublist(64, 84);
|
||||
// // print("hwVersion:hwVersion");
|
||||
//
|
||||
// // 厂商序列号
|
||||
// var serialNum0 = data.sublist(84, 100);
|
||||
// // print("serialNum0:serialNum0");
|
||||
//
|
||||
// // 成品商序列号
|
||||
// var serialNum1 = data.sublist(100, 116);
|
||||
// // print("serialNum1:serialNum1");
|
||||
//
|
||||
// // 蓝牙名称
|
||||
// var btDeviceName = data.sublist(116, 132);
|
||||
// // print("btDeviceName:btDeviceName");
|
||||
//
|
||||
// // 电池剩余电量
|
||||
// var battRemCap = data[132];
|
||||
// // print("battRemCap:battRemCap");
|
||||
//
|
||||
// // 重置次数
|
||||
// var restoreCounter = data.sublist(133, 134);
|
||||
// // print("restoreCounter:restoreCounter");
|
||||
//
|
||||
// // 重置时间
|
||||
// var restoreDate = data.sublist(134, 138);
|
||||
// // print("restoreDate:restoreDate");
|
||||
//
|
||||
// // 主控芯片型号
|
||||
// var icPartNo = data.sublist(138, 148);
|
||||
// // print("icPartNo:icPartNo");
|
||||
//
|
||||
// // 有效时间
|
||||
// var indate = data.sublist(148, 152);
|
||||
// // print("indate:indate");
|
||||
|
||||
break;
|
||||
case 0x06:
|
||||
|
||||
@ -0,0 +1,112 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import '../io_reply.dart';
|
||||
import '../io_sender.dart';
|
||||
import '../io_tool/io_tool.dart';
|
||||
import '../io_type.dart';
|
||||
import 'package:crypto/crypto.dart' as crypto;
|
||||
|
||||
import '../sm4Encipher/sm4.dart';
|
||||
|
||||
///TODO:读取支持功能(不带参数)启用/禁用
|
||||
class ReadSupportFunctionsNoParametersCommand extends SenderProtocol {
|
||||
|
||||
String? keyID;
|
||||
String? userID;
|
||||
int? featureBit;
|
||||
List<int>? token;
|
||||
int? needAuthor;
|
||||
List<int>? publicKey;
|
||||
List<int>? privateKey;
|
||||
|
||||
ReadSupportFunctionsNoParametersCommand({
|
||||
this.keyID,
|
||||
this.userID,
|
||||
this.featureBit,
|
||||
this.token,
|
||||
this.needAuthor,
|
||||
this.publicKey,
|
||||
this.privateKey,
|
||||
}) : super(CommandType.generalExtendedCommond);
|
||||
|
||||
@override
|
||||
List<int> messageDetail() {
|
||||
List<int> data = [];
|
||||
List<int> subData = [];
|
||||
List<int> ebcData = [];
|
||||
|
||||
// 指令类型
|
||||
int type = commandType!.typeValue;
|
||||
double typeDouble = type / 256;
|
||||
int type1 = typeDouble.toInt();
|
||||
int type2 = type % 256;
|
||||
data.add(type1);
|
||||
data.add(type2);
|
||||
|
||||
// 子命令类型
|
||||
data.add(71);
|
||||
|
||||
// keyID 40
|
||||
int keyIDLength = utf8.encode(keyID!).length;
|
||||
// print("${commandType!.typeValue}LockIDLength:$lockIDLength utf8.encode(lockID!)${utf8.encode(lockID!)}");
|
||||
subData.addAll(utf8.encode(keyID!));
|
||||
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
||||
|
||||
//userID 20
|
||||
int userIDLength = utf8.encode(userID!).length;
|
||||
// print("${commandType!.typeValue}IDLength:$authUserIDLength utf8.encode(authUserID!)${utf8.encode(authUserID!)}");
|
||||
subData.addAll(utf8.encode(userID!));
|
||||
subData = getFixedLengthList(subData, 20 - userIDLength);
|
||||
|
||||
// featureBit
|
||||
subData.add(featureBit!);
|
||||
|
||||
if(needAuthor == 0){
|
||||
//AuthCodeLen 1
|
||||
subData.add(0);
|
||||
} else {
|
||||
List<int> authCodeData = [];
|
||||
|
||||
//authUserID
|
||||
authCodeData.addAll(utf8.encode(userID!));
|
||||
|
||||
//KeyID
|
||||
authCodeData.addAll(utf8.encode(keyID!));
|
||||
|
||||
//token 4 首次请求 Token 填 0,如果锁需要鉴权操作者身份,则会分配动态口令并在应答消息中返回,二次请求时带上。
|
||||
authCodeData.addAll(token!);
|
||||
|
||||
authCodeData.addAll(publicKey!);
|
||||
|
||||
print("${commandType!.typeValue}-authCodeData:$authCodeData");
|
||||
|
||||
// 把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);
|
||||
}
|
||||
}
|
||||
print("${commandType!.typeName} SM4Data:$data");
|
||||
// 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864
|
||||
ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB);
|
||||
return ebcData;
|
||||
}
|
||||
}
|
||||
|
||||
class ReadSupportFunctionsNoParametersReply extends Reply {
|
||||
ReadSupportFunctionsNoParametersReply.parseData(CommandType commandType, List<int> dataDetail)
|
||||
: super.parseData(commandType, dataDetail) {
|
||||
data = dataDetail;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,112 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import '../io_reply.dart';
|
||||
import '../io_sender.dart';
|
||||
import '../io_tool/io_tool.dart';
|
||||
import '../io_type.dart';
|
||||
import 'package:crypto/crypto.dart' as crypto;
|
||||
|
||||
import '../sm4Encipher/sm4.dart';
|
||||
|
||||
///TODO:读取支持功能(带参数)启用/禁用
|
||||
class ReadSupportFunctionsWithParametersCommand extends SenderProtocol {
|
||||
|
||||
String? keyID;
|
||||
String? userID;
|
||||
int? featureBit;
|
||||
List<int>? token;
|
||||
int? needAuthor;
|
||||
List<int>? publicKey;
|
||||
List<int>? privateKey;
|
||||
|
||||
ReadSupportFunctionsWithParametersCommand({
|
||||
this.keyID,
|
||||
this.userID,
|
||||
this.featureBit,
|
||||
this.token,
|
||||
this.needAuthor,
|
||||
this.publicKey,
|
||||
this.privateKey,
|
||||
}) : super(CommandType.generalExtendedCommond);
|
||||
|
||||
@override
|
||||
List<int> messageDetail() {
|
||||
List<int> data = [];
|
||||
List<int> subData = [];
|
||||
List<int> ebcData = [];
|
||||
|
||||
// 指令类型
|
||||
int type = commandType!.typeValue;
|
||||
double typeDouble = type / 256;
|
||||
int type1 = typeDouble.toInt();
|
||||
int type2 = type % 256;
|
||||
data.add(type1);
|
||||
data.add(type2);
|
||||
|
||||
// 子命令类型
|
||||
data.add(73);
|
||||
|
||||
// keyID 40
|
||||
int keyIDLength = utf8.encode(keyID!).length;
|
||||
// print("${commandType!.typeValue}LockIDLength:$lockIDLength utf8.encode(lockID!)${utf8.encode(lockID!)}");
|
||||
subData.addAll(utf8.encode(keyID!));
|
||||
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
||||
|
||||
//userID 20
|
||||
int userIDLength = utf8.encode(userID!).length;
|
||||
// print("${commandType!.typeValue}IDLength:$authUserIDLength utf8.encode(authUserID!)${utf8.encode(authUserID!)}");
|
||||
subData.addAll(utf8.encode(userID!));
|
||||
subData = getFixedLengthList(subData, 20 - userIDLength);
|
||||
|
||||
// featureBit
|
||||
subData.add(featureBit!);
|
||||
|
||||
if(needAuthor == 0){
|
||||
//AuthCodeLen 1
|
||||
subData.add(0);
|
||||
} else {
|
||||
List<int> authCodeData = [];
|
||||
|
||||
//authUserID
|
||||
authCodeData.addAll(utf8.encode(userID!));
|
||||
|
||||
//KeyID
|
||||
authCodeData.addAll(utf8.encode(keyID!));
|
||||
|
||||
//token 4 首次请求 Token 填 0,如果锁需要鉴权操作者身份,则会分配动态口令并在应答消息中返回,二次请求时带上。
|
||||
authCodeData.addAll(token!);
|
||||
|
||||
authCodeData.addAll(publicKey!);
|
||||
|
||||
print("${commandType!.typeValue}-authCodeData:$authCodeData");
|
||||
|
||||
// 把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);
|
||||
}
|
||||
}
|
||||
print("${commandType!.typeName} SM4Data:$data");
|
||||
// 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864
|
||||
ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB);
|
||||
return ebcData;
|
||||
}
|
||||
}
|
||||
|
||||
class ReadSupportFunctionsWithParametersReply extends Reply {
|
||||
ReadSupportFunctionsWithParametersReply.parseData(CommandType commandType, List<int> dataDetail)
|
||||
: super.parseData(commandType, dataDetail) {
|
||||
data = dataDetail;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,117 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import '../io_reply.dart';
|
||||
import '../io_sender.dart';
|
||||
import '../io_tool/io_tool.dart';
|
||||
import '../io_type.dart';
|
||||
import 'package:crypto/crypto.dart' as crypto;
|
||||
|
||||
import '../sm4Encipher/sm4.dart';
|
||||
|
||||
///TODO:设置支持功能(不带参数)启用/禁用
|
||||
class SetSupportFunctionsNoParametersCommand extends SenderProtocol {
|
||||
|
||||
String? keyID;
|
||||
String? userID;
|
||||
int? featureBit;
|
||||
int? featureEnable;
|
||||
List<int>? token;
|
||||
int? needAuthor;
|
||||
List<int>? publicKey;
|
||||
List<int>? privateKey;
|
||||
|
||||
SetSupportFunctionsNoParametersCommand({
|
||||
this.keyID,
|
||||
this.userID,
|
||||
this.featureBit,
|
||||
this.featureEnable,
|
||||
this.token,
|
||||
this.needAuthor,
|
||||
this.publicKey,
|
||||
this.privateKey,
|
||||
}) : super(CommandType.generalExtendedCommond);
|
||||
|
||||
@override
|
||||
List<int> messageDetail() {
|
||||
List<int> data = [];
|
||||
List<int> subData = [];
|
||||
List<int> ebcData = [];
|
||||
|
||||
// 指令类型
|
||||
int type = commandType!.typeValue;
|
||||
double typeDouble = type / 256;
|
||||
int type1 = typeDouble.toInt();
|
||||
int type2 = type % 256;
|
||||
data.add(type1);
|
||||
data.add(type2);
|
||||
|
||||
// 子命令类型
|
||||
data.add(70);
|
||||
|
||||
// keyID 40
|
||||
int keyIDLength = utf8.encode(keyID!).length;
|
||||
// print("${commandType!.typeValue}LockIDLength:$lockIDLength utf8.encode(lockID!)${utf8.encode(lockID!)}");
|
||||
subData.addAll(utf8.encode(keyID!));
|
||||
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
||||
|
||||
//userID 20
|
||||
int userIDLength = utf8.encode(userID!).length;
|
||||
// print("${commandType!.typeValue}IDLength:$authUserIDLength utf8.encode(authUserID!)${utf8.encode(authUserID!)}");
|
||||
subData.addAll(utf8.encode(userID!));
|
||||
subData = getFixedLengthList(subData, 20 - userIDLength);
|
||||
|
||||
// featureBit
|
||||
subData.add(featureBit!);
|
||||
|
||||
// featureEnable
|
||||
subData.add(featureEnable!);
|
||||
|
||||
if(needAuthor == 0){
|
||||
//AuthCodeLen 1
|
||||
subData.add(0);
|
||||
} else {
|
||||
List<int> authCodeData = [];
|
||||
|
||||
//authUserID
|
||||
authCodeData.addAll(utf8.encode(userID!));
|
||||
|
||||
//KeyID
|
||||
authCodeData.addAll(utf8.encode(keyID!));
|
||||
|
||||
//token 4 首次请求 Token 填 0,如果锁需要鉴权操作者身份,则会分配动态口令并在应答消息中返回,二次请求时带上。
|
||||
authCodeData.addAll(token!);
|
||||
|
||||
authCodeData.addAll(publicKey!);
|
||||
|
||||
print("${commandType!.typeValue}-authCodeData:$authCodeData");
|
||||
|
||||
// 把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);
|
||||
}
|
||||
}
|
||||
print("${commandType!.typeName} SM4Data:$data");
|
||||
// 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864
|
||||
ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB);
|
||||
return ebcData;
|
||||
}
|
||||
}
|
||||
|
||||
class SetSupportFunctionsNoParametersReply extends Reply {
|
||||
SetSupportFunctionsNoParametersReply.parseData(CommandType commandType, List<int> dataDetail)
|
||||
: super.parseData(commandType, dataDetail) {
|
||||
data = dataDetail;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,122 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import '../io_reply.dart';
|
||||
import '../io_sender.dart';
|
||||
import '../io_tool/io_tool.dart';
|
||||
import '../io_type.dart';
|
||||
import 'package:crypto/crypto.dart' as crypto;
|
||||
|
||||
import '../sm4Encipher/sm4.dart';
|
||||
|
||||
///TODO:设置支持功能(参数)
|
||||
class SetSupportFunctionsWithParametersCommand extends SenderProtocol {
|
||||
|
||||
String? keyID;
|
||||
String? userID;
|
||||
int? featureBit;
|
||||
int? featureParaLength;
|
||||
List<int>? featureData;
|
||||
List<int>? token;
|
||||
int? needAuthor;
|
||||
List<int>? publicKey;
|
||||
List<int>? privateKey;
|
||||
|
||||
SetSupportFunctionsWithParametersCommand({
|
||||
this.keyID,
|
||||
this.userID,
|
||||
this.featureBit,
|
||||
this.featureParaLength,
|
||||
this.featureData,
|
||||
this.token,
|
||||
this.needAuthor,
|
||||
this.publicKey,
|
||||
this.privateKey,
|
||||
}) : super(CommandType.generalExtendedCommond);
|
||||
|
||||
@override
|
||||
List<int> messageDetail() {
|
||||
List<int> data = [];
|
||||
List<int> subData = [];
|
||||
List<int> ebcData = [];
|
||||
|
||||
// 指令类型
|
||||
int type = commandType!.typeValue;
|
||||
double typeDouble = type / 256;
|
||||
int type1 = typeDouble.toInt();
|
||||
int type2 = type % 256;
|
||||
data.add(type1);
|
||||
data.add(type2);
|
||||
|
||||
// 子命令类型
|
||||
data.add(72);
|
||||
|
||||
// keyID 40
|
||||
int keyIDLength = utf8.encode(keyID!).length;
|
||||
// print("${commandType!.typeValue}LockIDLength:$lockIDLength utf8.encode(lockID!)${utf8.encode(lockID!)}");
|
||||
subData.addAll(utf8.encode(keyID!));
|
||||
subData = getFixedLengthList(subData, 40 - keyIDLength);
|
||||
|
||||
//userID 20
|
||||
int userIDLength = utf8.encode(userID!).length;
|
||||
// print("${commandType!.typeValue}IDLength:$authUserIDLength utf8.encode(authUserID!)${utf8.encode(authUserID!)}");
|
||||
subData.addAll(utf8.encode(userID!));
|
||||
subData = getFixedLengthList(subData, 20 - userIDLength);
|
||||
|
||||
// featureBit
|
||||
subData.add(featureBit!);
|
||||
|
||||
// featureEnable
|
||||
subData.add(featureParaLength!);
|
||||
|
||||
// featureEnable
|
||||
subData.addAll(featureData!);
|
||||
|
||||
if(needAuthor == 0){
|
||||
//AuthCodeLen 1
|
||||
subData.add(0);
|
||||
} else {
|
||||
List<int> authCodeData = [];
|
||||
|
||||
//authUserID
|
||||
authCodeData.addAll(utf8.encode(userID!));
|
||||
|
||||
//KeyID
|
||||
authCodeData.addAll(utf8.encode(keyID!));
|
||||
|
||||
//token 4 首次请求 Token 填 0,如果锁需要鉴权操作者身份,则会分配动态口令并在应答消息中返回,二次请求时带上。
|
||||
authCodeData.addAll(token!);
|
||||
|
||||
authCodeData.addAll(publicKey!);
|
||||
|
||||
print("${commandType!.typeValue}-authCodeData:$authCodeData");
|
||||
|
||||
// 把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);
|
||||
}
|
||||
}
|
||||
print("${commandType!.typeName} SM4Data:$data");
|
||||
// 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864
|
||||
ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB);
|
||||
return ebcData;
|
||||
}
|
||||
}
|
||||
|
||||
class SetSupportFunctionsWithParametersReply extends Reply {
|
||||
SetSupportFunctionsWithParametersReply.parseData(CommandType commandType, List<int> dataDetail)
|
||||
: super.parseData(commandType, dataDetail) {
|
||||
data = dataDetail;
|
||||
}
|
||||
}
|
||||
@ -9,5 +9,4 @@ abstract class Reply{
|
||||
List<int> data = [];
|
||||
Reply.parseData(this.commandType, List<int> dataDetail);
|
||||
|
||||
|
||||
}
|
||||
@ -8,7 +8,11 @@ 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_readSupportFunctionsNoParameters.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_readSupportFunctionsWithParameters.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_referEventRecordTime.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_setSupportFunctionsNoParameters.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_setSupportFunctionsWithParameters.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_timing.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_transferPermissions.dart';
|
||||
|
||||
@ -25,6 +29,7 @@ import 'io_protocol/io_checkingUserInfoCount.dart';
|
||||
import 'io_protocol/io_configuringWifi.dart';
|
||||
import 'io_protocol/io_getPrivateKey.dart';
|
||||
import 'io_protocol/io_getPublicKey.dart';
|
||||
import 'io_protocol/io_getStarLockStatusInfo.dart';
|
||||
import 'io_protocol/io_openLock.dart';
|
||||
import 'io_protocol/io_queryingFingerprintStatus.dart';
|
||||
import 'io_protocol/io_referEventRecordNumber.dart';
|
||||
@ -164,6 +169,11 @@ class CommandReciverManager {
|
||||
reply = TimingReply.parseData(commandType, data);
|
||||
}
|
||||
break;
|
||||
case CommandType.readStarLockStatusInfo:
|
||||
{
|
||||
reply = GetStarLockStatuInfoReply.parseData(commandType, data);
|
||||
}
|
||||
break;
|
||||
case CommandType.generalExtendedCommond:
|
||||
{
|
||||
// 子命令类型
|
||||
@ -265,6 +275,30 @@ class CommandReciverManager {
|
||||
reply = SenderAddStressFingerprintReply.parseData(commandType, data);
|
||||
}
|
||||
break;
|
||||
case 70:
|
||||
{
|
||||
// 设置支持功能(不带参数)启用/禁用
|
||||
reply = SetSupportFunctionsNoParametersReply.parseData(commandType, data);
|
||||
}
|
||||
break;
|
||||
case 71:
|
||||
{
|
||||
// 读取支持功能(不带参数)启用/禁用状态
|
||||
reply = ReadSupportFunctionsNoParametersReply.parseData(commandType, data);
|
||||
}
|
||||
break;
|
||||
case 72:
|
||||
{
|
||||
// 设置支持功能(带参数)
|
||||
reply = SetSupportFunctionsWithParametersReply.parseData(commandType, data);
|
||||
}
|
||||
break;
|
||||
case 73:
|
||||
{
|
||||
// 读取支持功能(带参数)参数
|
||||
reply = ReadSupportFunctionsWithParametersReply.parseData(commandType, data);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@ -16,11 +16,16 @@ import 'io_protocol/io_editUser.dart';
|
||||
import 'io_protocol/io_factoryDataReset.dart';
|
||||
import 'io_protocol/io_getPrivateKey.dart';
|
||||
import 'io_protocol/io_getPublicKey.dart';
|
||||
import 'io_protocol/io_getStarLockStatusInfo.dart';
|
||||
import 'io_protocol/io_openLock.dart';
|
||||
import 'io_protocol/io_queryingFingerprintStatus.dart';
|
||||
import 'io_protocol/io_readSupportFunctionsNoParameters.dart';
|
||||
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_setSupportFunctionsNoParameters.dart';
|
||||
import 'io_protocol/io_setSupportFunctionsWithParameters.dart';
|
||||
import 'io_protocol/io_timing.dart';
|
||||
import 'io_protocol/io_transferPermissions.dart';
|
||||
import 'sender_data.dart';
|
||||
@ -187,6 +192,20 @@ class IoSenderManage {
|
||||
), callBack:callBack);
|
||||
}
|
||||
|
||||
//todo:获取星锁状态信息
|
||||
static void senderGetStarLockStatuInfo({
|
||||
String? lockID,
|
||||
String? userID,
|
||||
List<int>? privateKey,
|
||||
CommandSendCallBack? callBack}) {
|
||||
CommandSenderManager().managerSendData(
|
||||
command: GetStarLockStatuInfoCommand(
|
||||
lockID: lockID,
|
||||
userID: userID,
|
||||
privateKey: privateKey,
|
||||
), callBack:callBack);
|
||||
}
|
||||
|
||||
//todo:转移权限
|
||||
static void senderTransferPermissions({
|
||||
required String? lockID,
|
||||
@ -293,7 +312,7 @@ class IoSenderManage {
|
||||
), callBack:callBack);
|
||||
}
|
||||
|
||||
//todo:添加指纹开始
|
||||
//todo:添加卡开始
|
||||
static void senderAddICCardCommand({
|
||||
required String? keyID,
|
||||
required String? userID,
|
||||
@ -343,27 +362,27 @@ class IoSenderManage {
|
||||
), callBack:callBack);
|
||||
}
|
||||
|
||||
//todo:自动落锁
|
||||
static void senderAutomaticPadlockCommand({
|
||||
required String? lockID,
|
||||
required String? userID,
|
||||
required int? autoLockFlag,
|
||||
required List<int>? token,
|
||||
required int? needAuthor,
|
||||
required List<int>? signKey,
|
||||
required List<int>? privateKey,
|
||||
CommandSendCallBack? callBack}) {
|
||||
CommandSenderManager().managerSendData(
|
||||
command: AutomaticPadlockCommand(
|
||||
lockID: lockID,
|
||||
userID: userID,
|
||||
autoLockFlag: autoLockFlag,
|
||||
token: token,
|
||||
needAuthor: needAuthor,
|
||||
signKey: signKey,
|
||||
privateKey: privateKey,
|
||||
), callBack:callBack);
|
||||
}
|
||||
//todo:自动落锁 - 废弃
|
||||
// static void senderAutomaticPadlockCommand({
|
||||
// required String? lockID,
|
||||
// required String? userID,
|
||||
// required int? autoLockFlag,
|
||||
// required List<int>? token,
|
||||
// required int? needAuthor,
|
||||
// required List<int>? signKey,
|
||||
// required List<int>? privateKey,
|
||||
// CommandSendCallBack? callBack}) {
|
||||
// CommandSenderManager().managerSendData(
|
||||
// command: AutomaticPadlockCommand(
|
||||
// lockID: lockID,
|
||||
// userID: userID,
|
||||
// autoLockFlag: autoLockFlag,
|
||||
// token: token,
|
||||
// needAuthor: needAuthor,
|
||||
// signKey: signKey,
|
||||
// privateKey: privateKey,
|
||||
// ), callBack:callBack);
|
||||
// }
|
||||
|
||||
//todo:事件记录(页数查询)
|
||||
static void senderReferEventRecordNumberCommand({
|
||||
@ -601,4 +620,98 @@ class IoSenderManage {
|
||||
), callBack:callBack);
|
||||
}
|
||||
|
||||
//todo:读取支持功能(不带参数)启用/禁用
|
||||
static void readSupportFunctionsNoParametersCommand({
|
||||
required String? keyID,
|
||||
required String? userID,
|
||||
required int? featureBit,
|
||||
required List<int>? token,
|
||||
required int? needAuthor,
|
||||
required List<int>? publicKey,
|
||||
required List<int>? privateKey,
|
||||
CommandSendCallBack? callBack}) {
|
||||
CommandSenderManager().managerSendData(
|
||||
command: ReadSupportFunctionsNoParametersCommand(
|
||||
keyID: keyID,
|
||||
userID: userID,
|
||||
featureBit: featureBit,
|
||||
token: token,
|
||||
needAuthor: needAuthor,
|
||||
publicKey: publicKey,
|
||||
privateKey: privateKey,
|
||||
), callBack:callBack);
|
||||
}
|
||||
|
||||
//todo:设置支持功能(不带参数)启用/禁用
|
||||
static void setSupportFunctionsNoParametersCommand({
|
||||
required String? keyID,
|
||||
required String? userID,
|
||||
required int? featureBit,
|
||||
required int? featureEnable,
|
||||
required List<int>? token,
|
||||
required int? needAuthor,
|
||||
required List<int>? publicKey,
|
||||
required List<int>? privateKey,
|
||||
CommandSendCallBack? callBack}) {
|
||||
CommandSenderManager().managerSendData(
|
||||
command: SetSupportFunctionsNoParametersCommand(
|
||||
keyID: keyID,
|
||||
userID: userID,
|
||||
featureBit: featureBit,
|
||||
featureEnable:featureEnable,
|
||||
token: token,
|
||||
needAuthor: needAuthor,
|
||||
publicKey: publicKey,
|
||||
privateKey: privateKey,
|
||||
), callBack:callBack);
|
||||
}
|
||||
|
||||
//todo:读取支持功能(带参数)启用/禁用
|
||||
static void readSupportFunctionsWithParametersCommand({
|
||||
required String? keyID,
|
||||
required String? userID,
|
||||
required int? featureBit,
|
||||
required List<int>? token,
|
||||
required int? needAuthor,
|
||||
required List<int>? publicKey,
|
||||
required List<int>? privateKey,
|
||||
CommandSendCallBack? callBack}) {
|
||||
CommandSenderManager().managerSendData(
|
||||
command: ReadSupportFunctionsWithParametersCommand(
|
||||
keyID: keyID,
|
||||
userID: userID,
|
||||
featureBit: featureBit,
|
||||
token: token,
|
||||
needAuthor: needAuthor,
|
||||
publicKey: publicKey,
|
||||
privateKey: privateKey,
|
||||
), callBack:callBack);
|
||||
}
|
||||
|
||||
//todo:设置支持功能(带参数)启用/禁用
|
||||
static void setSupportFunctionsWithParametersCommand({
|
||||
required String? keyID,
|
||||
required String? userID,
|
||||
required int? featureBit,
|
||||
required int? featureParaLength,
|
||||
required List<int>? featureData,
|
||||
required List<int>? token,
|
||||
required int? needAuthor,
|
||||
required List<int>? publicKey,
|
||||
required List<int>? privateKey,
|
||||
CommandSendCallBack? callBack}) {
|
||||
CommandSenderManager().managerSendData(
|
||||
command: SetSupportFunctionsWithParametersCommand(
|
||||
keyID: keyID,
|
||||
userID: userID,
|
||||
featureBit: featureBit,
|
||||
featureParaLength:featureParaLength,
|
||||
featureData:featureData,
|
||||
token: token,
|
||||
needAuthor: needAuthor,
|
||||
publicKey: publicKey,
|
||||
privateKey: privateKey,
|
||||
), callBack:callBack);
|
||||
}
|
||||
|
||||
}
|
||||
@ -55,7 +55,9 @@ class StarLockRegisterLogic extends BaseGetXController {
|
||||
state.xWidth.value.toString());
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
_startTimer();
|
||||
} else {}
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void checkNext(TextEditingController controller) {
|
||||
|
||||
@ -2,10 +2,10 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_setSupportFunctionsWithParameters.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import '../../../../blue/blue_manage.dart';
|
||||
import '../../../../blue/io_protocol/io_automaticPadlock.dart';
|
||||
import '../../../../blue/io_protocol/io_getLockStatu.dart';
|
||||
import '../../../../blue/io_protocol/io_readSupportFunctionsWithParameters.dart';
|
||||
import '../../../../blue/io_reply.dart';
|
||||
import '../../../../blue/io_tool/io_manager.dart';
|
||||
import '../../../../blue/io_tool/io_tool.dart';
|
||||
@ -20,12 +20,16 @@ import 'automaticBlocking_state.dart';
|
||||
class AutomaticBlockingLogic extends BaseGetXController{
|
||||
final AutomaticBlockingState state = AutomaticBlockingState();
|
||||
|
||||
void setAutoUnLock() async{
|
||||
void _setAutoUnLock() async{
|
||||
String autoTime;
|
||||
if(state.isOpen.value == false){
|
||||
autoTime = "-1";
|
||||
}else{
|
||||
autoTime = state.autoLockTime.value;
|
||||
if(state.isCustomLockTime.value == true){
|
||||
autoTime = state.timeController.text;
|
||||
}else{
|
||||
autoTime = state.autoLockTime.value;
|
||||
}
|
||||
}
|
||||
|
||||
var entity = await ApiRepository.to.setAutoUnlock(
|
||||
@ -34,6 +38,7 @@ class AutomaticBlockingLogic extends BaseGetXController{
|
||||
type: "1",
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
state.autoLockTime.value = state.isOpen.value == false ? "0" : autoTime;
|
||||
state.getKeyInfosData.value.autoLockTime = int.parse(autoTime);
|
||||
eventBus.fire(RefreshLockListInfoDataEvent());
|
||||
eventBus.fire(PassCurrentLockInformationEvent(state.getKeyInfosData.value));
|
||||
@ -45,24 +50,25 @@ class AutomaticBlockingLogic extends BaseGetXController{
|
||||
late StreamSubscription<Reply> _replySubscription;
|
||||
void _initReplySubscription() {
|
||||
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) {
|
||||
if(reply is AutomaticPadlockReply) {
|
||||
_replyAutomaticPadlock(reply);
|
||||
if(reply is SetSupportFunctionsWithParametersReply) {
|
||||
_replySetSupportFunctionsWithParameters(reply);
|
||||
}
|
||||
|
||||
// 获取锁状态
|
||||
if(reply is GetLockStatuReply) {
|
||||
_replyGetLockStatus(reply);
|
||||
// 读取支持功能(带参数)
|
||||
if(reply is ReadSupportFunctionsWithParametersReply) {
|
||||
_readSupportFunctionsWithParametersReply(reply);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 获取锁状态数据解析
|
||||
Future<void> _replyGetLockStatus(Reply reply) async {
|
||||
// 读取支持功能带参数数据解析
|
||||
Future<void> _readSupportFunctionsWithParametersReply(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
state.autoLockTime.value = reply.data[7].toString();
|
||||
|
||||
break;
|
||||
case 0x06:
|
||||
@ -89,13 +95,13 @@ class AutomaticBlockingLogic extends BaseGetXController{
|
||||
}
|
||||
|
||||
// 设置自动落锁数据解析
|
||||
Future<void> _replyAutomaticPadlock(Reply reply) async {
|
||||
Future<void> _replySetSupportFunctionsWithParameters(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
// _getLockStatus();
|
||||
_setAutoUnLock();
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
@ -120,23 +126,33 @@ class AutomaticBlockingLogic extends BaseGetXController{
|
||||
}
|
||||
}
|
||||
|
||||
// 获取锁状态
|
||||
Future<void> _getLockStatus() async {
|
||||
// 进来之后首先连接
|
||||
// 读取支持功能-带参数
|
||||
Future<void> _readSupportFunctionsWithParameters() async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
if (connectionState == DeviceConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
IoSenderManage.senderGetLockStatu(
|
||||
lockID:BlueManage().connectDeviceName,
|
||||
userID:await Storage.getUid(),
|
||||
privateKey:getPrivateKeyList,
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
||||
|
||||
IoSenderManage.readSupportFunctionsWithParametersCommand(
|
||||
keyID: state.getKeyInfosData.value.keyId.toString(),
|
||||
userID: await Storage.getUid(),
|
||||
featureBit: 29,
|
||||
token: getTokenList,
|
||||
needAuthor: 1,
|
||||
publicKey: getPublicKeyList,
|
||||
privateKey: getPrivateKeyList
|
||||
);
|
||||
}
|
||||
}, isShowLoading: false);
|
||||
}, isShowLoading: true);
|
||||
}
|
||||
|
||||
// 自动落锁
|
||||
// 设置支持功能(带参数)
|
||||
Future<void> sendAutoLock() async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
if (connectionState == DeviceConnectionState.connected) {
|
||||
@ -146,19 +162,30 @@ class AutomaticBlockingLogic extends BaseGetXController{
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
var signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
List<int> getSignKeyList = changeStringListToIntList(signKey!);
|
||||
|
||||
print("automaticBlockingState.isOpen.value:${state.isOpen.value}");
|
||||
IoSenderManage.senderAutomaticPadlockCommand(
|
||||
lockID:BlueManage().connectDeviceName,
|
||||
userID:await Storage.getUid(),
|
||||
autoLockFlag:state.isOpen.value ? 1 : 0,
|
||||
token:getTokenList,
|
||||
needAuthor:1,
|
||||
signKey:getSignKeyList,
|
||||
privateKey:getPrivateKeyList,
|
||||
);
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
||||
|
||||
String autoTime;
|
||||
if(state.isOpen.value == false){
|
||||
autoTime = "0";
|
||||
}else{
|
||||
if(state.isCustomLockTime.value == true){
|
||||
autoTime = state.timeController.text;
|
||||
}else{
|
||||
autoTime = state.autoLockTime.value;
|
||||
}
|
||||
}
|
||||
print("autoTimeautoTimeautoTime:${autoTime}");
|
||||
IoSenderManage.setSupportFunctionsWithParametersCommand(
|
||||
keyID: state.getKeyInfosData.value.keyId.toString(),
|
||||
userID: await Storage.getUid(),
|
||||
featureBit: 29,
|
||||
featureParaLength: 2,
|
||||
featureData: [int.parse(autoTime)],
|
||||
token: getTokenList,
|
||||
needAuthor: 1,
|
||||
publicKey: getPublicKeyList,
|
||||
privateKey: getPrivateKeyList);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -178,7 +205,7 @@ class AutomaticBlockingLogic extends BaseGetXController{
|
||||
super.onInit();
|
||||
print("onInit()");
|
||||
|
||||
_getLockStatus();
|
||||
_readSupportFunctionsWithParameters();
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@ -20,7 +20,6 @@ class AutomaticBlockingPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _AutomaticBlockingPageState extends State<AutomaticBlockingPage> {
|
||||
final TextEditingController _timeController = TextEditingController();
|
||||
final logic = Get.put(AutomaticBlockingLogic());
|
||||
final state = Get.find<AutomaticBlockingLogic>().state;
|
||||
|
||||
@ -39,7 +38,7 @@ class _AutomaticBlockingPageState extends State<AutomaticBlockingPage> {
|
||||
),
|
||||
onPressed: () {
|
||||
// logic.sendAutoLock();
|
||||
logic.setAutoUnLock();
|
||||
logic.sendAutoLock();
|
||||
},
|
||||
),
|
||||
],
|
||||
@ -53,13 +52,11 @@ class _AutomaticBlockingPageState extends State<AutomaticBlockingPage> {
|
||||
isHaveRightWidget: true,
|
||||
rightWidget:
|
||||
SizedBox(width: 60.w, height: 50.h, child: _switch())),),
|
||||
Container(
|
||||
height: 10.h,
|
||||
),
|
||||
Container(height: 10.h,),
|
||||
Builder(builder: (context) {
|
||||
return Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.delayTime!.tr,
|
||||
rightTitle: "${state.autoLockTime.value}s",
|
||||
rightTitle: state.isCustomLockTime.value == true ? "自定义" : "${state.autoLockTime.value}s",
|
||||
isHaveLine: false,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
@ -115,7 +112,7 @@ class _AutomaticBlockingPageState extends State<AutomaticBlockingPage> {
|
||||
TextField(
|
||||
//输入框一行
|
||||
maxLines: 1,
|
||||
controller: _timeController,
|
||||
controller: state.timeController,
|
||||
autofocus: false,
|
||||
decoration: InputDecoration(
|
||||
//输入里面输入文字内边距设置
|
||||
@ -161,6 +158,9 @@ class _AutomaticBlockingPageState extends State<AutomaticBlockingPage> {
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
state.isOpen.value = value;
|
||||
if(state.isOpen.value == false){
|
||||
state.autoLockTime.value = "0";
|
||||
}
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../lockMian/entity/lockInfoEntity.dart';
|
||||
@ -9,11 +10,13 @@ class AutomaticBlockingState {
|
||||
var isOpen = false.obs;// 是否开启自动落锁
|
||||
var autoLockTime = "5".obs;
|
||||
var isCustomLockTime = false.obs;// 自定义
|
||||
final TextEditingController timeController = TextEditingController();
|
||||
|
||||
AutomaticBlockingState() {
|
||||
getKeyInfosData.value = Get.arguments as KeyInfos;
|
||||
isOpen.value = getKeyInfosData.value.autoLockTime! > -1 ? true : false;
|
||||
autoLockTime.value = getKeyInfosData.value.autoLockTime!.toString();
|
||||
|
||||
if((getKeyInfosData.value.autoLockTime! > 0)
|
||||
&& (getKeyInfosData.value.autoLockTime! != 5)
|
||||
&& (getKeyInfosData.value.autoLockTime! != 10)
|
||||
@ -21,6 +24,7 @@ class AutomaticBlockingState {
|
||||
&& (getKeyInfosData.value.autoLockTime! != 30)
|
||||
&& (getKeyInfosData.value.autoLockTime! != 60)){
|
||||
isCustomLockTime.value = true;
|
||||
timeController.text = autoLockTime.value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,7 +1,19 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_readSupportFunctionsNoParameters.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_setSupportFunctionsNoParameters.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import '../../../../blue/blue_manage.dart';
|
||||
import '../../../../blue/io_reply.dart';
|
||||
import '../../../../blue/io_tool/io_manager.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/eventBusEventManage.dart';
|
||||
import '../../../../tools/storage.dart';
|
||||
import '../../../../tools/toast.dart';
|
||||
import 'burglarAlarm_state.dart';
|
||||
|
||||
@ -9,7 +21,7 @@ class BurglarAlarmLogic extends BaseGetXController{
|
||||
BurglarAlarmState state = BurglarAlarmState();
|
||||
|
||||
// 配置锁的常开模式设置 -> 防撬报警
|
||||
Future<void> setLockSetGeneralSetting() async{
|
||||
Future<void> _setLockSetGeneralSetting() async{
|
||||
var entity = await ApiRepository.to.setLockSetGeneralSettingData(
|
||||
lockId: state.getKeyInfosData.value.lockId.toString(),
|
||||
changeType:"1",
|
||||
@ -26,4 +38,156 @@ class BurglarAlarmLogic extends BaseGetXController{
|
||||
}
|
||||
}
|
||||
|
||||
// 获取解析后的数据
|
||||
late StreamSubscription<Reply> _replySubscription;
|
||||
void _initReplySubscription() {
|
||||
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) {
|
||||
if(reply is SetSupportFunctionsNoParametersReply) {
|
||||
_replySetSupportFunctionsWithParameters(reply);
|
||||
}
|
||||
|
||||
// 读取支持功能(带参数)
|
||||
if(reply is ReadSupportFunctionsNoParametersReply) {
|
||||
_readSupportFunctionsWithParametersReply(reply);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 读取支持功能带参数数据解析
|
||||
Future<void> _readSupportFunctionsWithParametersReply(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
state.burglarAlarmEnable.value = reply.data[6];
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
print("${reply.commandType}需要鉴权");
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${reply.commandType}用户无权限");
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType}权限校验错误");
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${reply.commandType}失败");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 设置自动落锁数据解析
|
||||
Future<void> _replySetSupportFunctionsWithParameters(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
_setLockSetGeneralSetting();
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
print("${reply.commandType}需要鉴权");
|
||||
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${reply.commandType}用户无权限");
|
||||
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType}权限校验错误");
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${reply.commandType}失败");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 读取支持功能-带参数
|
||||
Future<void> _readSupportFunctionsNoParameters() async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
if (connectionState == DeviceConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
||||
|
||||
IoSenderManage.readSupportFunctionsNoParametersCommand(
|
||||
keyID: state.getKeyInfosData.value.keyId.toString(),
|
||||
userID: await Storage.getUid(),
|
||||
featureBit: 30,
|
||||
token: getTokenList,
|
||||
needAuthor: 1,
|
||||
publicKey: getPublicKeyList,
|
||||
privateKey: getPrivateKeyList
|
||||
);
|
||||
}
|
||||
}, isShowLoading: true);
|
||||
}
|
||||
|
||||
// 设置支持功能(带参数)
|
||||
Future<void> sendBurglarAlarm() async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
if (connectionState == DeviceConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
||||
|
||||
IoSenderManage.setSupportFunctionsNoParametersCommand(
|
||||
keyID: state.getKeyInfosData.value.keyId.toString(),
|
||||
userID: await Storage.getUid(),
|
||||
featureBit: 30,
|
||||
featureEnable: state.burglarAlarmEnable.value == 1 ? 0 : 1,
|
||||
token: getTokenList,
|
||||
needAuthor: 1,
|
||||
publicKey: getPublicKeyList,
|
||||
privateKey: getPrivateKeyList);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
super.onReady();
|
||||
print("onReady()");
|
||||
|
||||
_initReplySubscription();
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
// TODO: implement onInit
|
||||
super.onInit();
|
||||
print("onInit()");
|
||||
|
||||
_readSupportFunctionsNoParameters();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
// TODO: implement onClose
|
||||
super.onClose();
|
||||
_replySubscription.cancel();
|
||||
}
|
||||
|
||||
}
|
||||
@ -65,7 +65,7 @@ class _BurglarAlarmPageState extends State<BurglarAlarmPage> {
|
||||
// margin: EdgeInsets.only(left: 03.w, right: 30.w, top: 20.w),
|
||||
padding: EdgeInsets.only(top: 20.w, bottom: 20.w),
|
||||
onClick: () {
|
||||
logic.setLockSetGeneralSetting();
|
||||
logic.sendBurglarAlarm();
|
||||
})),
|
||||
],
|
||||
),
|
||||
|
||||
@ -64,10 +64,10 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
||||
'keyInfo': state.getKeyInfosData.value
|
||||
});
|
||||
}),
|
||||
SizedBox(
|
||||
height: 10.h,
|
||||
),
|
||||
CommonItem(
|
||||
SizedBox(height: 10.h,),
|
||||
Visibility(
|
||||
visible: true,
|
||||
child:CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.doorMagnetic!.tr,
|
||||
rightTitle: "",
|
||||
isHaveLine: true,
|
||||
@ -75,32 +75,37 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
||||
action: () {
|
||||
Get.toNamed(Routers.doorMagneticPage);
|
||||
// Toast.show(msg: "功能暂未开放");
|
||||
}),
|
||||
CommonItem(
|
||||
leftTitel:
|
||||
TranslationLoader.lanKeys!.wirelessKeyboard!.tr,
|
||||
rightTitle: "",
|
||||
isHaveLine: false,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Get.toNamed(Routers.wirelessKeyboardPage);
|
||||
// Toast.show(msg: "功能暂未开放");
|
||||
}),
|
||||
SizedBox(
|
||||
height: 10.h,
|
||||
})
|
||||
),
|
||||
Obx(() => CommonItem(
|
||||
leftTitel:
|
||||
Visibility(
|
||||
visible: true,
|
||||
child: CommonItem(
|
||||
leftTitel:
|
||||
TranslationLoader.lanKeys!.wirelessKeyboard!.tr,
|
||||
rightTitle: "",
|
||||
isHaveLine: false,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Get.toNamed(Routers.wirelessKeyboardPage);
|
||||
// Toast.show(msg: "功能暂未开放");
|
||||
})
|
||||
),
|
||||
SizedBox(height: 10.h),
|
||||
Obx(() => Visibility(
|
||||
visible: true,
|
||||
child: CommonItem(
|
||||
leftTitel:
|
||||
TranslationLoader.lanKeys!.automaticBlocking!.tr,
|
||||
rightTitle: state.getKeyInfosData.value.autoLockTime! > -1
|
||||
? "${state.getKeyInfosData.value.autoLockTime!.toString()}s"
|
||||
: TranslationLoader.lanKeys!.closed!.tr,
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Get.toNamed(Routers.automaticBlockingPage,
|
||||
arguments: state.getKeyInfosData.value);
|
||||
})),
|
||||
rightTitle: state.getKeyInfosData.value.autoLockTime! > -1
|
||||
? "${state.getKeyInfosData.value.autoLockTime!.toString()}s"
|
||||
: TranslationLoader.lanKeys!.closed!.tr,
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Get.toNamed(Routers.automaticBlockingPage,
|
||||
arguments: state.getKeyInfosData.value);
|
||||
}))
|
||||
),
|
||||
Obx(() {
|
||||
var titleStr = "";
|
||||
if (state.getKeyInfosData.value.lockSound == 1) {
|
||||
@ -124,17 +129,22 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
||||
} else {
|
||||
titleStr = TranslationLoader.lanKeys!.closed!.tr;
|
||||
}
|
||||
return CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.lockSound!.tr,
|
||||
rightTitle: titleStr,
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Get.toNamed(Routers.lockSoundSetPage,
|
||||
arguments: state.getKeyInfosData.value);
|
||||
});
|
||||
return Visibility(
|
||||
visible: true,
|
||||
child: CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.lockSound!.tr,
|
||||
rightTitle: titleStr,
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Get.toNamed(Routers.lockSoundSetPage,
|
||||
arguments: state.getKeyInfosData.value);
|
||||
})
|
||||
);
|
||||
}),
|
||||
Obx(() => CommonItem(
|
||||
Obx(() => Visibility(
|
||||
visible: true,
|
||||
child: CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.burglarAlarm!.tr,
|
||||
rightTitle: state.getKeyInfosData.value.tamperAlert == 1
|
||||
? TranslationLoader.lanKeys!.opened!.tr
|
||||
@ -144,25 +154,26 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
||||
action: () {
|
||||
Get.toNamed(Routers.burglarAlarmPage,
|
||||
arguments: state.getKeyInfosData.value);
|
||||
})),
|
||||
SizedBox(
|
||||
height: 10.h,
|
||||
}))),
|
||||
SizedBox(height: 10.h),
|
||||
Obx(() => Visibility(
|
||||
visible: true,
|
||||
child: CommonItem(
|
||||
leftTitel:
|
||||
TranslationLoader.lanKeys!.normallyOpenMode!.tr,
|
||||
rightTitle: state.getKeyInfosData.value.passageMode == 1
|
||||
? TranslationLoader.lanKeys!.opened!.tr
|
||||
: TranslationLoader.lanKeys!.closed!.tr,
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Get.toNamed(Routers.normallyOpenModePage,
|
||||
arguments: state.getKeyInfosData.value);
|
||||
}))
|
||||
),
|
||||
Obx(
|
||||
() => CommonItem(
|
||||
leftTitel:
|
||||
TranslationLoader.lanKeys!.normallyOpenMode!.tr,
|
||||
rightTitle: state.getKeyInfosData.value.passageMode == 1
|
||||
? TranslationLoader.lanKeys!.opened!.tr
|
||||
: TranslationLoader.lanKeys!.closed!.tr,
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Get.toNamed(Routers.normallyOpenModePage,
|
||||
arguments: state.getKeyInfosData.value);
|
||||
}),
|
||||
),
|
||||
Obx(() => CommonItem(
|
||||
Obx(() => Visibility(
|
||||
visible:true,
|
||||
child: CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.remoteUnlocking!.tr,
|
||||
rightTitle: state.getKeyInfosData.value.remoteEnable == 1
|
||||
? TranslationLoader.lanKeys!.opened!.tr
|
||||
@ -172,8 +183,11 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
||||
action: () {
|
||||
Get.toNamed(Routers.remoteUnlockingPage,
|
||||
arguments: state.getKeyInfosData.value);
|
||||
})),
|
||||
Obx(() => CommonItem(
|
||||
}))
|
||||
),
|
||||
Obx(() => Visibility(
|
||||
visible: true,
|
||||
child: CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.resetButton!.tr,
|
||||
rightTitle: state.getKeyInfosData.value.resetButton == 1
|
||||
? TranslationLoader.lanKeys!.opened!.tr
|
||||
@ -183,60 +197,85 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
||||
action: () {
|
||||
Get.toNamed(Routers.resetButtonPage,
|
||||
arguments: state.getKeyInfosData.value);
|
||||
})),
|
||||
SizedBox(
|
||||
height: 10.h,
|
||||
}))
|
||||
),
|
||||
SizedBox(height: 10.h),
|
||||
//---田总新增展示
|
||||
CommonItem(
|
||||
// Obx(() =>
|
||||
Visibility(
|
||||
visible: true,
|
||||
child: CommonItem(
|
||||
leftTitel: '面容开锁',
|
||||
rightTitle: "",
|
||||
isHaveLine: true,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget:
|
||||
SizedBox(width: 60.w, child: _openCheckInSwitch())),
|
||||
CommonItem(
|
||||
leftTitel: '感应距离',
|
||||
rightTitle: "远",
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
),
|
||||
CommonItem(
|
||||
leftTitel: '自动亮屏',
|
||||
rightTitle: "",
|
||||
SizedBox(width: 60.w, child: _openCheckInSwitch()))),
|
||||
// ),
|
||||
// Obx(() =>
|
||||
Visibility(
|
||||
visible: true,
|
||||
child: CommonItem(
|
||||
leftTitel: '感应距离',
|
||||
rightTitle: "远",
|
||||
isHaveLine: true,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget:
|
||||
SizedBox(width: 60.w, child: _openCheckInSwitch())),
|
||||
CommonItem(
|
||||
leftTitel: '逗留警告',
|
||||
rightTitle: "",
|
||||
isHaveLine: true,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget:
|
||||
SizedBox(width: 60.w, child: _openCheckInSwitch())),
|
||||
CommonItem(
|
||||
leftTitel: '异常警告',
|
||||
rightTitle: "",
|
||||
isHaveLine: true,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget:
|
||||
SizedBox(width: 60.w, child: _openCheckInSwitch())),
|
||||
CommonItem(
|
||||
leftTitel: '开门方向设置',
|
||||
rightTitle: "右开",
|
||||
isHaveDirection: true,
|
||||
isHaveLine: true,
|
||||
),
|
||||
CommonItem(
|
||||
leftTitel: '电机功率设置',
|
||||
rightTitle: "大",
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
),
|
||||
SizedBox(
|
||||
height: 10.h,
|
||||
),
|
||||
isHaveDirection: true,
|
||||
)),
|
||||
// ),
|
||||
// Obx(() =>
|
||||
Visibility(
|
||||
visible: true,
|
||||
child: CommonItem(
|
||||
leftTitel: '自动亮屏',
|
||||
rightTitle: "",
|
||||
isHaveLine: true,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget:
|
||||
SizedBox(width: 60.w, child: _openCheckInSwitch()))),
|
||||
// ),
|
||||
// Obx(() =>
|
||||
Visibility(
|
||||
visible: true,
|
||||
child: CommonItem(
|
||||
leftTitel: '逗留警告',
|
||||
rightTitle: "",
|
||||
isHaveLine: true,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget:
|
||||
SizedBox(width: 60.w, child: _openCheckInSwitch()))),
|
||||
// ),
|
||||
// Obx(() =>
|
||||
Visibility(
|
||||
visible: true,
|
||||
child: CommonItem(
|
||||
leftTitel: '异常警告',
|
||||
rightTitle: "",
|
||||
isHaveLine: true,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget:
|
||||
SizedBox(width: 60.w, child: _openCheckInSwitch()))),
|
||||
// ),
|
||||
// Obx(() =>
|
||||
Visibility(
|
||||
visible: true,
|
||||
child: CommonItem(
|
||||
leftTitel: '开门方向设置',
|
||||
rightTitle: "右开",
|
||||
isHaveDirection: true,
|
||||
isHaveLine: true,
|
||||
)),
|
||||
// ),
|
||||
// Obx(() =>
|
||||
Visibility(
|
||||
visible: true,
|
||||
child: CommonItem(
|
||||
leftTitel: '电机功率设置',
|
||||
rightTitle: "大",
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
)),
|
||||
// ),
|
||||
SizedBox(height: 10.h),
|
||||
//-----新增至此
|
||||
Obx(() {
|
||||
var title = "";
|
||||
@ -245,44 +284,61 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
||||
} else if (state.getKeyInfosData.value.roomStatus == 2) {
|
||||
title = TranslationLoader.lanKeys!.leisure!.tr;
|
||||
}
|
||||
return CommonItem(
|
||||
leftTitel:
|
||||
return Visibility(
|
||||
visible: true,
|
||||
child: CommonItem(
|
||||
leftTitel:
|
||||
TranslationLoader.lanKeys!.markedHouseState!.tr,
|
||||
rightTitle: title,
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Get.toNamed(Routers.markedHouseStatePage,
|
||||
arguments: state.getKeyInfosData.value);
|
||||
});
|
||||
rightTitle: title,
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Get.toNamed(Routers.markedHouseStatePage,
|
||||
arguments: state.getKeyInfosData.value);
|
||||
})
|
||||
);
|
||||
}),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.checkingIn!.tr,
|
||||
rightTitle: "",
|
||||
isHaveLine: true,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget:
|
||||
SizedBox(width: 60.w, child: _openCheckInSwitch())),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.unlockReminder!.tr,
|
||||
rightTitle: "",
|
||||
isHaveLine: false,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget:
|
||||
SizedBox(width: 60.w, child: _lockRemindSwitch())),
|
||||
SizedBox(
|
||||
height: 10.h,
|
||||
),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader
|
||||
.lanKeys!.wifiDistributionNetwork!.tr,
|
||||
rightTitle: "",
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Get.toNamed(Routers.configuringWifiPage);
|
||||
}),
|
||||
CommonItem(
|
||||
// Obx(() =>
|
||||
Visibility(
|
||||
visible: true,
|
||||
child: CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.checkingIn!.tr,
|
||||
rightTitle: "",
|
||||
isHaveLine: true,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget:
|
||||
SizedBox(width: 60.w, child: _openCheckInSwitch())
|
||||
)),
|
||||
// ),
|
||||
// Obx(() =>
|
||||
Visibility(
|
||||
visible: true,
|
||||
child: CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.unlockReminder!.tr,
|
||||
rightTitle: "",
|
||||
isHaveLine: false,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget:
|
||||
SizedBox(width: 60.w, child: _lockRemindSwitch()))),
|
||||
// ),
|
||||
SizedBox(height: 10.h),
|
||||
// Obx(() =>
|
||||
Visibility(
|
||||
visible: true,
|
||||
child: CommonItem(
|
||||
leftTitel: TranslationLoader
|
||||
.lanKeys!.wifiDistributionNetwork!.tr,
|
||||
rightTitle: "",
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Get.toNamed(Routers.configuringWifiPage);
|
||||
})),
|
||||
// ),
|
||||
// Obx(() =>
|
||||
Visibility(
|
||||
visible: true,
|
||||
child: CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.lockTime!.tr,
|
||||
rightTitle: "",
|
||||
isHaveLine: true,
|
||||
@ -290,44 +346,59 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
||||
action: () {
|
||||
Get.toNamed(Routers.lockTimePage,
|
||||
arguments: state.getKeyInfosData.value);
|
||||
}),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.diagnose!.tr,
|
||||
rightTitle: "",
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Get.toNamed(Routers.diagnosePage,
|
||||
arguments: state.getKeyInfosData.value);
|
||||
}),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.uploadData!.tr,
|
||||
rightTitle: "",
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Get.toNamed(Routers.uploadDataPage);
|
||||
}),
|
||||
CommonItem(
|
||||
leftTitel:
|
||||
})),
|
||||
// ),
|
||||
// Obx(() =>
|
||||
Visibility(
|
||||
visible: true,
|
||||
child: CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.diagnose!.tr,
|
||||
rightTitle: "",
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Get.toNamed(Routers.diagnosePage,
|
||||
arguments: state.getKeyInfosData.value);
|
||||
})),
|
||||
// ),
|
||||
// Obx(() =>
|
||||
Visibility(
|
||||
visible: true,
|
||||
child: CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.uploadData!.tr,
|
||||
rightTitle: "",
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Get.toNamed(Routers.uploadDataPage);
|
||||
})),
|
||||
// ),
|
||||
// Obx(() =>
|
||||
Visibility(
|
||||
visible: true,
|
||||
child: CommonItem(
|
||||
leftTitel:
|
||||
TranslationLoader.lanKeys!.importOtherLockData!.tr,
|
||||
rightTitle: "",
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Get.toNamed(Routers.importOtherLockDataPage);
|
||||
}),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.lockEscalation!.tr,
|
||||
rightTitle: "",
|
||||
isHaveLine: false,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Get.toNamed(Routers.lockEscalationPage);
|
||||
}),
|
||||
SizedBox(
|
||||
height: 30.h,
|
||||
),
|
||||
rightTitle: "",
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Get.toNamed(Routers.importOtherLockDataPage);
|
||||
})),
|
||||
// ),
|
||||
// Obx(() =>
|
||||
Visibility(
|
||||
visible: true,
|
||||
child: CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.lockEscalation!.tr,
|
||||
rightTitle: "",
|
||||
isHaveLine: false,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Get.toNamed(Routers.lockEscalationPage);
|
||||
})),
|
||||
// ),
|
||||
SizedBox(height: 30.h),
|
||||
Container(
|
||||
padding: EdgeInsets.only(left: 20.w, right: 20.w),
|
||||
child: SubmitBtn(
|
||||
|
||||
@ -1,7 +1,19 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
|
||||
import '../../../../blue/blue_manage.dart';
|
||||
import '../../../../blue/io_protocol/io_readSupportFunctionsWithParameters.dart';
|
||||
import '../../../../blue/io_protocol/io_setSupportFunctionsWithParameters.dart';
|
||||
import '../../../../blue/io_reply.dart';
|
||||
import '../../../../blue/io_tool/io_manager.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/eventBusEventManage.dart';
|
||||
import '../../../../tools/storage.dart';
|
||||
import '../../../../tools/toast.dart';
|
||||
import 'lockSoundSet_state.dart';
|
||||
|
||||
@ -9,7 +21,7 @@ class LockSoundSetLogic extends BaseGetXController {
|
||||
LockSoundSetState state = LockSoundSetState();
|
||||
|
||||
// 配置锁的常开模式设置 -> 锁声音设置
|
||||
void setLockSetGeneralSetting() async{
|
||||
void _setLockSetGeneralSetting() async{
|
||||
int isOn;
|
||||
int type;
|
||||
if(state.isOpenLockSound.value == false){
|
||||
@ -25,13 +37,180 @@ class LockSoundSetLogic extends BaseGetXController {
|
||||
isOn:isOn.toString(), // 1-开启、2-关闭; 设置音量:1到5;
|
||||
type:type.toString(), // 6-锁声音开关 8-音量、
|
||||
);
|
||||
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
eventBus.fire(RefreshLockListInfoDataEvent());
|
||||
//
|
||||
state.getKeyInfosData.value.lockSound = state.isOpenLockSound.value == true ? 1 :2;
|
||||
state.getKeyInfosData.value.volume = state.lockSoundLevel.value;
|
||||
eventBus.fire(PassCurrentLockInformationEvent(state.getKeyInfosData.value));
|
||||
Toast.show(msg: "操作成功");
|
||||
}
|
||||
}
|
||||
|
||||
// 获取解析后的数据
|
||||
late StreamSubscription<Reply> _replySubscription;
|
||||
void _initReplySubscription() {
|
||||
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) {
|
||||
if(reply is SetSupportFunctionsWithParametersReply) {
|
||||
_replySetSupportFunctionsWithParameters(reply);
|
||||
}
|
||||
|
||||
// 读取支持功能(带参数)
|
||||
if(reply is ReadSupportFunctionsWithParametersReply) {
|
||||
_readSupportFunctionsWithParametersReply(reply);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 读取支持功能带参数数据解析
|
||||
Future<void> _readSupportFunctionsWithParametersReply(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
// state.autoLockTime.value = reply.data[7].toString();
|
||||
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
print("${reply.commandType}需要鉴权");
|
||||
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${reply.commandType}用户无权限");
|
||||
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType}权限校验错误");
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${reply.commandType}失败");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 设置自动落锁数据解析
|
||||
Future<void> _replySetSupportFunctionsWithParameters(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
_setLockSetGeneralSetting();
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
print("${reply.commandType}需要鉴权");
|
||||
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${reply.commandType}用户无权限");
|
||||
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType}权限校验错误");
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${reply.commandType}失败");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 读取支持功能-带参数
|
||||
Future<void> _readSupportFunctionsWithParameters() async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
if (connectionState == DeviceConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
||||
|
||||
IoSenderManage.readSupportFunctionsWithParametersCommand(
|
||||
keyID: state.getKeyInfosData.value.keyId.toString(),
|
||||
userID: await Storage.getUid(),
|
||||
featureBit: 33,
|
||||
token: getTokenList,
|
||||
needAuthor: 1,
|
||||
publicKey: getPublicKeyList,
|
||||
privateKey: getPrivateKeyList
|
||||
);
|
||||
}
|
||||
}, isShowLoading: true);
|
||||
}
|
||||
|
||||
// 设置支持功能(带参数)
|
||||
Future<void> sendLockSound() async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
if (connectionState == DeviceConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
||||
|
||||
int type;
|
||||
if(state.isOpenLockSound.value == false){
|
||||
// 音量关了的时候
|
||||
type = 0;
|
||||
}else{
|
||||
// 音量开了的时候
|
||||
type = state.lockSoundLevel.value;
|
||||
}
|
||||
IoSenderManage.setSupportFunctionsWithParametersCommand(
|
||||
keyID: state.getKeyInfosData.value.keyId.toString(),
|
||||
userID: await Storage.getUid(),
|
||||
featureBit: 33,
|
||||
featureParaLength: 1,
|
||||
featureData: [type],
|
||||
token: getTokenList,
|
||||
needAuthor: 1,
|
||||
publicKey: getPublicKeyList,
|
||||
privateKey: getPrivateKeyList);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
super.onReady();
|
||||
print("onReady()");
|
||||
|
||||
_initReplySubscription();
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
// TODO: implement onInit
|
||||
super.onInit();
|
||||
print("onInit()");
|
||||
|
||||
_readSupportFunctionsWithParameters();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
// TODO: implement onClose
|
||||
super.onClose();
|
||||
_replySubscription.cancel();
|
||||
}
|
||||
|
||||
}
|
||||
@ -183,7 +183,7 @@ class _LockSoundSetPageState extends State<LockSoundSetPage> {
|
||||
child: SubmitBtn(
|
||||
btnName: TranslationLoader.lanKeys!.save!.tr,
|
||||
onClick: () {
|
||||
logic.setLockSetGeneralSetting();
|
||||
logic.sendLockSound();
|
||||
}),
|
||||
),
|
||||
],
|
||||
|
||||
@ -1,10 +1,22 @@
|
||||
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:date_format/date_format.dart';
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
|
||||
import '../../../../blue/blue_manage.dart';
|
||||
import '../../../../blue/io_protocol/io_readSupportFunctionsWithParameters.dart';
|
||||
import '../../../../blue/io_protocol/io_setSupportFunctionsWithParameters.dart';
|
||||
import '../../../../blue/io_reply.dart';
|
||||
import '../../../../blue/io_tool/io_manager.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/eventBusEventManage.dart';
|
||||
import '../../../../tools/storage.dart';
|
||||
import '../../../../tools/toast.dart';
|
||||
import 'normallyOpenMode_state.dart';
|
||||
|
||||
@ -43,8 +55,8 @@ class NormallyOpenModeLogic extends BaseGetXController{
|
||||
passageMode:state.isOpenNormallyOpenMode.value == true ? "1":"2",
|
||||
autoUnlock:state.isOpenAutomaticUnLock.value == true ? "1":"2",
|
||||
type: "1",
|
||||
startDate: state.beginTimeMinute.toString(),
|
||||
endDate: state.endTimeMinute.toString(),
|
||||
startDate: state.beginTimeMinute.value.toString(),
|
||||
endDate: state.endTimeMinute.value.toString(),
|
||||
isAllDay: state.isAllDay.value == 1 ? "1":"2",
|
||||
weekDays: state.weekDays,
|
||||
);
|
||||
@ -57,6 +69,147 @@ class NormallyOpenModeLogic extends BaseGetXController{
|
||||
}
|
||||
}
|
||||
|
||||
// 获取解析后的数据
|
||||
late StreamSubscription<Reply> _replySubscription;
|
||||
void _initReplySubscription() {
|
||||
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) {
|
||||
if(reply is SetSupportFunctionsWithParametersReply) {
|
||||
_replySetSupportFunctionsWithParameters(reply);
|
||||
}
|
||||
|
||||
// 读取支持功能(带参数)
|
||||
if(reply is ReadSupportFunctionsWithParametersReply) {
|
||||
_readSupportFunctionsWithParametersReply(reply);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 读取支持功能带参数数据解析
|
||||
Future<void> _readSupportFunctionsWithParametersReply(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
state.isOpenNormallyOpenMode.value = reply.data[4] == 0 ? false : true;
|
||||
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
print("${reply.commandType}需要鉴权");
|
||||
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${reply.commandType}用户无权限");
|
||||
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType}权限校验错误");
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${reply.commandType}失败");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 设置自动落锁数据解析
|
||||
Future<void> _replySetSupportFunctionsWithParameters(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
configPassageMode();
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
print("${reply.commandType}需要鉴权");
|
||||
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${reply.commandType}用户无权限");
|
||||
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType}权限校验错误");
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${reply.commandType}失败");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 读取支持功能-带参数
|
||||
Future<void> _readSupportFunctionsWithParameters() async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
if (connectionState == DeviceConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
||||
|
||||
IoSenderManage.readSupportFunctionsWithParametersCommand(
|
||||
keyID: state.getKeyInfosData.value.keyId.toString(),
|
||||
userID: await Storage.getUid(),
|
||||
featureBit: 50,
|
||||
token: getTokenList,
|
||||
needAuthor: 1,
|
||||
publicKey: getPublicKeyList,
|
||||
privateKey: getPrivateKeyList
|
||||
);
|
||||
}
|
||||
}, isShowLoading: true);
|
||||
}
|
||||
|
||||
// 设置支持功能(带参数)
|
||||
Future<void> sendAutoLock() async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
if (connectionState == DeviceConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
||||
|
||||
List<int> list = [];
|
||||
list.add(state.isOpenNormallyOpenMode.value == true ? 1:0);
|
||||
list.add(state.beginTimeMinute.value);
|
||||
list.add(state.endTimeMinute.value);
|
||||
list.add(state.isAllDay.value == 1 ? 1:0);
|
||||
list.add(0);
|
||||
list.add(state.isOpenAutomaticUnLock.value == true ? 1:0);
|
||||
|
||||
IoSenderManage.setSupportFunctionsWithParametersCommand(
|
||||
keyID: state.getKeyInfosData.value.keyId.toString(),
|
||||
userID: await Storage.getUid(),
|
||||
featureBit: 50,
|
||||
featureParaLength: 8,
|
||||
featureData: list,
|
||||
token: getTokenList,
|
||||
needAuthor: 1,
|
||||
publicKey: getPublicKeyList,
|
||||
privateKey: getPrivateKeyList);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
@ -66,6 +219,8 @@ class NormallyOpenModeLogic extends BaseGetXController{
|
||||
if(state.getKeyInfosData.value.passageMode == 1){
|
||||
getNormallyOpenModeConfig();
|
||||
}
|
||||
|
||||
_initReplySubscription();
|
||||
}
|
||||
|
||||
@override
|
||||
@ -73,10 +228,15 @@ class NormallyOpenModeLogic extends BaseGetXController{
|
||||
// TODO: implement onInit
|
||||
super.onInit();
|
||||
print("onInit()");
|
||||
|
||||
_readSupportFunctionsWithParameters();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
// TODO: implement onClose
|
||||
super.onClose();
|
||||
|
||||
_replySubscription.cancel();
|
||||
}
|
||||
}
|
||||
@ -110,7 +110,7 @@ class _NormallyOpenModePageState extends State<NormallyOpenModePage> {
|
||||
child: SubmitBtn(
|
||||
btnName: TranslationLoader.lanKeys!.save!.tr,
|
||||
onClick: () {
|
||||
logic.configPassageMode();
|
||||
logic.sendAutoLock();
|
||||
}),
|
||||
),
|
||||
],
|
||||
@ -262,9 +262,10 @@ class _NormallyOpenModePageState extends State<NormallyOpenModePage> {
|
||||
action: () {
|
||||
Pickers.showDatePicker(context, mode: DateMode.HM,
|
||||
onConfirm: (p) {
|
||||
state.beginTimeMinute.value = p.hour!*60 + p.minute!;
|
||||
state.beginTime.value = "${p.hour}:${p.minute!}";
|
||||
setState(() {});
|
||||
setState(() {
|
||||
state.beginTimeMinute.value = p.hour!*60 + p.minute!;
|
||||
state.beginTime.value = "${p.hour}:${p.minute!}";
|
||||
});
|
||||
});
|
||||
})),
|
||||
Obx(() => CommonItem(
|
||||
@ -275,9 +276,10 @@ class _NormallyOpenModePageState extends State<NormallyOpenModePage> {
|
||||
action: () {
|
||||
Pickers.showDatePicker(context, mode: DateMode.HM,
|
||||
onConfirm: (p) {
|
||||
state.endTimeMinute.value = p.hour!*60 + p.minute!;
|
||||
state.endTime.value = "${p.hour}:${p.minute!}";
|
||||
setState(() {});
|
||||
setState(() {
|
||||
state.endTimeMinute.value = p.hour!*60 + p.minute!;
|
||||
state.endTime.value = "${p.hour}:${p.minute!}";
|
||||
});
|
||||
});
|
||||
})),
|
||||
Container(height: 10.h),
|
||||
|
||||
@ -1,15 +1,26 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import 'package:star_lock/tools/toast.dart';
|
||||
|
||||
import '../../../../blue/blue_manage.dart';
|
||||
import '../../../../blue/io_protocol/io_readSupportFunctionsNoParameters.dart';
|
||||
import '../../../../blue/io_protocol/io_setSupportFunctionsNoParameters.dart';
|
||||
import '../../../../blue/io_reply.dart';
|
||||
import '../../../../blue/io_tool/io_manager.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/eventBusEventManage.dart';
|
||||
import '../../../../tools/storage.dart';
|
||||
import 'remoteUnlocking_state.dart';
|
||||
|
||||
class RemoteUnlockingLogic extends BaseGetXController{
|
||||
RemoteUnlockingState state = RemoteUnlockingState();
|
||||
|
||||
void remoteUnlockingOpenOrClose() async{
|
||||
void _remoteUnlockingOpenOrClose() async{
|
||||
var entity = await ApiRepository.to.remoteUnlockingOpenOrClose(
|
||||
lockId: state.getKeyInfosData.value.lockId.toString(),
|
||||
// featureValue:state.getKeyInfosData.value.featureValue.toString()
|
||||
@ -29,11 +40,140 @@ class RemoteUnlockingLogic extends BaseGetXController{
|
||||
}
|
||||
}
|
||||
|
||||
// 获取解析后的数据
|
||||
late StreamSubscription<Reply> _replySubscription;
|
||||
void _initReplySubscription() {
|
||||
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) {
|
||||
if(reply is SetSupportFunctionsNoParametersReply) {
|
||||
_replySetSupportFunctionsWithParameters(reply);
|
||||
}
|
||||
|
||||
// 读取支持功能(带参数)
|
||||
if(reply is ReadSupportFunctionsNoParametersReply) {
|
||||
_readSupportFunctionsWithParametersReply(reply);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 读取支持功能带参数数据解析
|
||||
Future<void> _readSupportFunctionsWithParametersReply(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
state.remoteEnable.value = reply.data[6];
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
print("${reply.commandType}需要鉴权");
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${reply.commandType}用户无权限");
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType}权限校验错误");
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${reply.commandType}失败");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 设置自动落锁数据解析
|
||||
Future<void> _replySetSupportFunctionsWithParameters(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
_remoteUnlockingOpenOrClose();
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
print("${reply.commandType}需要鉴权");
|
||||
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${reply.commandType}用户无权限");
|
||||
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType}权限校验错误");
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${reply.commandType}失败");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 读取支持功能-带参数
|
||||
Future<void> _readSupportFunctionsNoParameters() async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
if (connectionState == DeviceConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
||||
|
||||
IoSenderManage.readSupportFunctionsNoParametersCommand(
|
||||
keyID: state.getKeyInfosData.value.keyId.toString(),
|
||||
userID: await Storage.getUid(),
|
||||
featureBit: 28,
|
||||
token: getTokenList,
|
||||
needAuthor: 1,
|
||||
publicKey: getPublicKeyList,
|
||||
privateKey: getPrivateKeyList
|
||||
);
|
||||
}
|
||||
}, isShowLoading: true);
|
||||
}
|
||||
|
||||
// 设置支持功能(带参数)
|
||||
Future<void> sendBurglarAlarm() async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
if (connectionState == DeviceConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
||||
|
||||
IoSenderManage.setSupportFunctionsNoParametersCommand(
|
||||
keyID: state.getKeyInfosData.value.keyId.toString(),
|
||||
userID: await Storage.getUid(),
|
||||
featureBit: 28,
|
||||
featureEnable: state.remoteEnable.value == 1 ? 0 : 1,
|
||||
token: getTokenList,
|
||||
needAuthor: 1,
|
||||
publicKey: getPublicKeyList,
|
||||
privateKey: getPrivateKeyList);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
super.onReady();
|
||||
print("onReady()");
|
||||
|
||||
_initReplySubscription();
|
||||
}
|
||||
|
||||
@override
|
||||
@ -41,11 +181,15 @@ class RemoteUnlockingLogic extends BaseGetXController{
|
||||
// TODO: implement onInit
|
||||
super.onInit();
|
||||
print("onInit()");
|
||||
|
||||
_readSupportFunctionsNoParameters();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
// TODO: implement onClose
|
||||
super.onClose();
|
||||
_replySubscription.cancel();
|
||||
}
|
||||
|
||||
}
|
||||
@ -65,7 +65,7 @@ class _RemoteUnlockingPageState extends State<RemoteUnlockingPage> {
|
||||
Obx(() => SubmitBtn(
|
||||
btnName: state.remoteEnable.value == 1 ?TranslationLoader.lanKeys!.close!.tr: TranslationLoader.lanKeys!.open!.tr,
|
||||
onClick: () {
|
||||
logic.remoteUnlockingOpenOrClose();
|
||||
logic.sendBurglarAlarm();
|
||||
})),
|
||||
],
|
||||
),
|
||||
|
||||
@ -1,17 +1,28 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:star_lock/main/lockDetail/lcokSet/resetButton/resetButton_state.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
|
||||
import '../../../../blue/blue_manage.dart';
|
||||
import '../../../../blue/io_protocol/io_readSupportFunctionsNoParameters.dart';
|
||||
import '../../../../blue/io_protocol/io_setSupportFunctionsNoParameters.dart';
|
||||
import '../../../../blue/io_reply.dart';
|
||||
import '../../../../blue/io_tool/io_manager.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/eventBusEventManage.dart';
|
||||
import '../../../../tools/storage.dart';
|
||||
import '../../../../tools/toast.dart';
|
||||
|
||||
class ResetButtonLogic extends BaseGetXController{
|
||||
ResetButtonState state = ResetButtonState();
|
||||
|
||||
|
||||
// 配置锁的常开模式设置 -> 重置开关
|
||||
Future<void> setLockSetGeneralSetting() async{
|
||||
Future<void> _setLockSetGeneralSetting() async{
|
||||
var entity = await ApiRepository.to.setLockSetGeneralSettingData(
|
||||
lockId: state.getKeyInfosData.value.lockId.toString(),
|
||||
changeType:"1",
|
||||
@ -27,4 +38,156 @@ class ResetButtonLogic extends BaseGetXController{
|
||||
Toast.show(msg: "操作成功");
|
||||
}
|
||||
}
|
||||
|
||||
// 获取解析后的数据
|
||||
late StreamSubscription<Reply> _replySubscription;
|
||||
void _initReplySubscription() {
|
||||
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) {
|
||||
if(reply is SetSupportFunctionsNoParametersReply) {
|
||||
_replySetSupportFunctionsWithParameters(reply);
|
||||
}
|
||||
|
||||
// 读取支持功能(带参数)
|
||||
if(reply is ReadSupportFunctionsNoParametersReply) {
|
||||
_readSupportFunctionsWithParametersReply(reply);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 读取支持功能带参数数据解析
|
||||
Future<void> _readSupportFunctionsWithParametersReply(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
state.resetButtonEnable.value = reply.data[6];
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
print("${reply.commandType}需要鉴权");
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${reply.commandType}用户无权限");
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType}权限校验错误");
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${reply.commandType}失败");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 设置自动落锁数据解析
|
||||
Future<void> _replySetSupportFunctionsWithParameters(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
_setLockSetGeneralSetting();
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
print("${reply.commandType}需要鉴权");
|
||||
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${reply.commandType}用户无权限");
|
||||
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType}权限校验错误");
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${reply.commandType}失败");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 读取支持功能-带参数
|
||||
Future<void> _readSupportFunctionsNoParameters() async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
if (connectionState == DeviceConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
||||
|
||||
IoSenderManage.readSupportFunctionsNoParametersCommand(
|
||||
keyID: state.getKeyInfosData.value.keyId.toString(),
|
||||
userID: await Storage.getUid(),
|
||||
featureBit: 31,
|
||||
token: getTokenList,
|
||||
needAuthor: 1,
|
||||
publicKey: getPublicKeyList,
|
||||
privateKey: getPrivateKeyList
|
||||
);
|
||||
}
|
||||
}, isShowLoading: true);
|
||||
}
|
||||
|
||||
// 设置支持功能(带参数)
|
||||
Future<void> sendBurglarAlarm() async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
if (connectionState == DeviceConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
||||
|
||||
IoSenderManage.setSupportFunctionsNoParametersCommand(
|
||||
keyID: state.getKeyInfosData.value.keyId.toString(),
|
||||
userID: await Storage.getUid(),
|
||||
featureBit: 31,
|
||||
featureEnable: state.resetButtonEnable.value == 1 ? 0 : 1,
|
||||
token: getTokenList,
|
||||
needAuthor: 1,
|
||||
publicKey: getPublicKeyList,
|
||||
privateKey: getPrivateKeyList);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
super.onReady();
|
||||
print("onReady()");
|
||||
|
||||
_initReplySubscription();
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
// TODO: implement onInit
|
||||
super.onInit();
|
||||
print("onInit()");
|
||||
|
||||
_readSupportFunctionsNoParameters();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
// TODO: implement onClose
|
||||
super.onClose();
|
||||
_replySubscription.cancel();
|
||||
}
|
||||
}
|
||||
@ -78,7 +78,7 @@ class _ResetButtonPageState extends State<ResetButtonPage> {
|
||||
// margin: EdgeInsets.only(left: 03.w, right: 30.w, top: 20.w),
|
||||
padding: EdgeInsets.only(top: 20.w, bottom: 20.w),
|
||||
onClick: () {
|
||||
logic.setLockSetGeneralSetting();
|
||||
logic.sendBurglarAlarm();
|
||||
})),
|
||||
],
|
||||
),
|
||||
|
||||
@ -9,6 +9,7 @@ import 'package:star_lock/blue/io_protocol/io_getLockStatu.dart';
|
||||
import 'package:star_lock/blue/io_type.dart';
|
||||
|
||||
import '../../../blue/blue_manage.dart';
|
||||
import '../../../blue/io_protocol/io_getStarLockStatusInfo.dart';
|
||||
import '../../../blue/io_protocol/io_openLock.dart';
|
||||
import '../../../blue/io_reply.dart';
|
||||
import '../../../blue/io_tool/io_manager.dart';
|
||||
@ -48,6 +49,11 @@ class LockDetailLogic extends BaseGetXController{
|
||||
if(reply is FactoryDataResetReply){
|
||||
_replyFactoryDataResetKey(reply);
|
||||
}
|
||||
|
||||
// 获取星锁状态信息
|
||||
if(reply is GetStarLockStatuInfoReply){
|
||||
_replyGetStarLockStatusInfo(reply);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -304,6 +310,88 @@ class LockDetailLogic extends BaseGetXController{
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _replyGetStarLockStatusInfo(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
// 厂商名称
|
||||
var vendor = reply.data.sublist(3, 23);
|
||||
print("vendor:$vendor");
|
||||
|
||||
// 锁设备类型
|
||||
var product = reply.data[23];
|
||||
print("product:$product");
|
||||
|
||||
// 产品名称
|
||||
var model = reply.data.sublist(24, 44);
|
||||
print("model:$model");
|
||||
|
||||
// 软件版本
|
||||
var fwVersion = reply.data.sublist(44, 64);
|
||||
print("fwVersion:$fwVersion");
|
||||
|
||||
// 硬件版本
|
||||
var hwVersion = reply.data.sublist(64, 84);
|
||||
print("hwVersion:$hwVersion");
|
||||
|
||||
// 厂商序列号
|
||||
var serialNum0 = reply.data.sublist(84, 100);
|
||||
print("serialNum0:$serialNum0");
|
||||
|
||||
// 成品商序列号
|
||||
var serialNum1 = reply.data.sublist(100, 116);
|
||||
print("serialNum1:$serialNum1");
|
||||
|
||||
// 蓝牙名称
|
||||
var btDeviceName = reply.data.sublist(116, 132);
|
||||
print("btDeviceName:$btDeviceName");
|
||||
|
||||
// 电池剩余电量
|
||||
var battRemCap = reply.data[132];
|
||||
print("battRemCap:$battRemCap");
|
||||
|
||||
// 重置次数
|
||||
var restoreCounter = reply.data.sublist(133, 135);
|
||||
print("restoreCounter:$restoreCounter");
|
||||
|
||||
// 重置时间
|
||||
var restoreDate = reply.data.sublist(135, 139);
|
||||
print("restoreDate:$restoreDate");
|
||||
|
||||
// 主控芯片型号
|
||||
var icPartNo = reply.data.sublist(139, 149);
|
||||
print("icPartNo:$icPartNo");
|
||||
|
||||
// 有效时间
|
||||
var indate = reply.data.sublist(149, 153);
|
||||
print("indate:$indate");
|
||||
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
print("${reply.commandType}需要鉴权");
|
||||
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${reply.commandType}用户无权限");
|
||||
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType}权限校验错误");
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${reply.commandType}失败");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 点击开门事件
|
||||
Future<void> openDoorAction() async {
|
||||
BlueManage().judgeReconnect(state.keyInfos.value.bluetooth!.bluetoothDeviceId!, state.keyInfos.value.bluetooth!.bluetoothDeviceName!, (DeviceConnectionState state) async {
|
||||
@ -401,7 +489,12 @@ class LockDetailLogic extends BaseGetXController{
|
||||
if (state == DeviceConnectionState.connected){
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
IoSenderManage.senderGetLockStatu(
|
||||
// IoSenderManage.senderGetLockStatu(
|
||||
// lockID:BlueManage().connectDeviceName,
|
||||
// userID:await Storage.getUid(),
|
||||
// privateKey:getPrivateKeyList,
|
||||
// );
|
||||
IoSenderManage.senderGetStarLockStatuInfo(
|
||||
lockID:BlueManage().connectDeviceName,
|
||||
userID:await Storage.getUid(),
|
||||
privateKey:getPrivateKeyList,
|
||||
@ -417,9 +510,9 @@ class LockDetailLogic extends BaseGetXController{
|
||||
print("onReady()");
|
||||
_initReplySubscription();
|
||||
|
||||
BlueManage().startScan((v){
|
||||
|
||||
});
|
||||
// BlueManage().startScan((v){
|
||||
//
|
||||
// });
|
||||
}
|
||||
|
||||
@override
|
||||
@ -430,6 +523,7 @@ class LockDetailLogic extends BaseGetXController{
|
||||
|
||||
// 进来获取锁状态
|
||||
// connectBlue();
|
||||
// factoryDataResetAction();
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@ -63,7 +63,7 @@ class _LockDetailPageState extends State<LockDetailPage> with RouteAware {
|
||||
Storage.setStringList(saveBlueSignKey, saveSignKeyList);
|
||||
// print("publicKeyData:$publicKeyData saveStrList:$saveStrList privateKeyData:$privateKeyData savePrivateKeyList:$savePrivateKeyList");
|
||||
|
||||
// logic.connectBlue();
|
||||
logic.connectBlue();
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@ -7,6 +7,7 @@ import 'package:star_lock/blue/io_type.dart';
|
||||
|
||||
import '../../../../../blue/blue_manage.dart';
|
||||
import '../../../../../blue/io_protocol/io_addFingerprint.dart';
|
||||
import '../../../../../blue/io_protocol/io_addStressFingerprint.dart';
|
||||
import '../../../../../blue/io_reply.dart';
|
||||
import '../../../../../blue/io_tool/io_manager.dart';
|
||||
import '../../../../../blue/io_tool/io_tool.dart';
|
||||
@ -40,6 +41,11 @@ class AddFingerprintLogic extends BaseGetXController {
|
||||
if(reply is SenderAddFingerprintConfirmationReply) {
|
||||
_replyAddFingerprintConfirmation(reply);
|
||||
}
|
||||
|
||||
// 添加胁迫指纹
|
||||
if(reply is SenderAddStressFingerprintReply) {
|
||||
_replyAddStressFingerprint(reply);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -112,8 +118,15 @@ class AddFingerprintLogic extends BaseGetXController {
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType!.typeValue} 数据解析成功");
|
||||
state.addFingerprintProcessNumber.value++;
|
||||
print("state.addFingerprintProcessNumber.value:${state.addFingerprintProcessNumber.value}");
|
||||
if(reply.data[5] == 255){
|
||||
// 注册指纹失败
|
||||
print("${reply.commandType!.typeValue} 注册指纹失败");
|
||||
Toast.show(msg: "添加失败");
|
||||
Get.close(3);
|
||||
}else{
|
||||
state.addFingerprintProcessNumber.value++;
|
||||
print("state.addFingerprintProcessNumber.value:${state.addFingerprintProcessNumber.value}");
|
||||
}
|
||||
break;
|
||||
case 0x06:
|
||||
//需要权限
|
||||
@ -138,10 +151,10 @@ class AddFingerprintLogic extends BaseGetXController {
|
||||
}
|
||||
|
||||
Future<void> _replyAddFingerprintConfirmation(Reply reply) async {
|
||||
var token = reply.data.sublist(2, 6);
|
||||
var saveStrList = changeIntListToStringList(token);
|
||||
print("_replyAddFingerprintReplyToken:$token");
|
||||
Storage.setStringList(saveBlueToken, saveStrList);
|
||||
// var token = reply.data.sublist(2, 6);
|
||||
// var saveStrList = changeIntListToStringList(token);
|
||||
// print("_replyAddFingerprintReplyToken:$token");
|
||||
// Storage.setStringList(saveBlueToken, saveStrList);
|
||||
|
||||
int status = reply.data[2];
|
||||
print("status:$status");
|
||||
@ -151,7 +164,13 @@ class AddFingerprintLogic extends BaseGetXController {
|
||||
//成功
|
||||
print("${reply.commandType!.typeValue} 数据解析成功");
|
||||
// print("添加指纹确认成功,调用添加指纹接口");
|
||||
addFingerprintsData();
|
||||
if(state.isCoerced.value == "1"){
|
||||
// 非胁迫指纹
|
||||
addFingerprintsData();
|
||||
}else{
|
||||
// 如果是胁迫指纹在 添加完之后以后再调用添加胁迫指纹的
|
||||
senderAddStressFingerprint();
|
||||
}
|
||||
break;
|
||||
case 0x06:
|
||||
//需要权限
|
||||
@ -175,6 +194,44 @@ class AddFingerprintLogic extends BaseGetXController {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _replyAddStressFingerprint(Reply reply) async {
|
||||
// var token = reply.data.sublist(2, 6);
|
||||
// var saveStrList = changeIntListToStringList(token);
|
||||
// print("_replyAddFingerprintReplyToken:$token");
|
||||
// Storage.setStringList(saveBlueToken, saveStrList);
|
||||
|
||||
int status = reply.data[2];
|
||||
print("status:$status");
|
||||
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType!.typeValue} 数据解析成功");
|
||||
// print("添加指纹确认成功,调用添加指纹接口");
|
||||
addFingerprintsData();
|
||||
break;
|
||||
case 0x06:
|
||||
//需要权限
|
||||
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${reply.commandType!.typeValue} 用户无权限");
|
||||
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType!.typeValue} 权限校验错误");
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${reply.commandType!.typeValue} 失败");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 添加指纹开始
|
||||
Future<void> senderAddFingerprint() async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
||||
@ -205,6 +262,36 @@ class AddFingerprintLogic extends BaseGetXController {
|
||||
});
|
||||
}
|
||||
|
||||
// 添加胁迫指纹
|
||||
Future<void> senderAddStressFingerprint() async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
||||
if (state == DeviceConnectionState.connected){
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
print("openDoorTokenPubToken:$getTokenList");
|
||||
|
||||
IoSenderManage.senderAddStressFingerprintCommand(
|
||||
keyID:"1",
|
||||
userID:await Storage.getUid(),
|
||||
fingerNo:1,
|
||||
useCountLimit:1,
|
||||
startTime:0x11223344,
|
||||
endTime:0x11223344,
|
||||
needAuthor:1,
|
||||
publicKey:publicKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
token: getTokenList,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 添加指纹
|
||||
void addFingerprintsData() async{
|
||||
var entity = await ApiRepository.to.addFingerprintsData(
|
||||
|
||||
@ -8,6 +8,7 @@ import 'package:star_lock/tools/baseGetXController.dart';
|
||||
|
||||
import '../../../../blue/blue_manage.dart';
|
||||
import '../../../../blue/io_protocol/io_addICCard.dart';
|
||||
import '../../../../blue/io_protocol/io_addStressICCard.dart';
|
||||
import '../../../../blue/io_reply.dart';
|
||||
import '../../../../blue/io_tool/io_manager.dart';
|
||||
import '../../../../blue/io_tool/io_tool.dart';
|
||||
@ -35,6 +36,11 @@ class AddICCardLogic extends BaseGetXController{
|
||||
if(reply is SenderAddICCardConfirmationReply) {
|
||||
_replyAddICCardConfirmation(reply);
|
||||
}
|
||||
|
||||
// 添加胁迫卡
|
||||
if(reply is SenderAddStressICCardReply) {
|
||||
_replyAddICStressCard(reply);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -103,6 +109,50 @@ class AddICCardLogic extends BaseGetXController{
|
||||
int status = reply.data[2];
|
||||
print("_replyAddFingerprintstatus:$status");
|
||||
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType!.typeValue} 数据解析成功");
|
||||
// print("添加指纹确认成功,调用添加指纹接口");
|
||||
if(state.isCoerced.value == "1"){
|
||||
// 非胁迫指纹
|
||||
addICCardData();
|
||||
}else{
|
||||
// 如果是胁迫指纹在 添加完之后以后再调用添加胁迫指纹的
|
||||
senderAddStressICCard();
|
||||
}
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${reply.commandType!.typeValue} 用户无权限");
|
||||
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType!.typeValue} 权限校验错误");
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${reply.commandType!.typeValue} 失败");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _replyAddICStressCard(Reply reply) async {
|
||||
var token = reply.data.sublist(2, 6);
|
||||
var saveStrList = changeIntListToStringList(token);
|
||||
print("_replyAddICCardConfirmationReplyToken:$token");
|
||||
Storage.setStringList(saveBlueToken, saveStrList);
|
||||
|
||||
int status = reply.data[2];
|
||||
print("_replyAddFingerprintstatus:$status");
|
||||
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
@ -162,6 +212,36 @@ class AddICCardLogic extends BaseGetXController{
|
||||
});
|
||||
}
|
||||
|
||||
// 添加胁迫卡片
|
||||
Future<void> senderAddStressICCard() async {
|
||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
||||
if (state == DeviceConnectionState.connected){
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
print("openDoorTokenPubToken:$getTokenList");
|
||||
|
||||
IoSenderManage.senderAddStressICCardCommand(
|
||||
keyID:"1",
|
||||
userID:await Storage.getUid(),
|
||||
icCardNo:1,
|
||||
useCountLimit:1,
|
||||
startTime:0x11223344,
|
||||
endTime:0x11223344,
|
||||
needAuthor:1,
|
||||
publicKey:publicKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
token: getTokenList,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void addICCardData() async {
|
||||
var entity = await ApiRepository.to.addICCardData(
|
||||
lockId: state.lockId.value.toString(),
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
@ -10,6 +9,7 @@ import '../../../appRouters.dart';
|
||||
import '../../../blue/blue_manage.dart';
|
||||
import '../../../blue/io_protocol/io_addUser.dart';
|
||||
import '../../../blue/io_protocol/io_getLockStatu.dart';
|
||||
import '../../../blue/io_protocol/io_getStarLockStatusInfo.dart';
|
||||
import '../../../blue/io_reply.dart';
|
||||
import '../../../blue/io_tool/io_manager.dart';
|
||||
import '../../../blue/io_tool/io_tool.dart';
|
||||
@ -38,6 +38,12 @@ class SaveLockLogic extends BaseGetXController {
|
||||
if(reply is GetLockStatuReply) {
|
||||
_replyGetLockStatus(reply);
|
||||
}
|
||||
|
||||
// 获取锁状态信息
|
||||
if(reply is GetStarLockStatuInfoReply) {
|
||||
_replyGetStarLockStatusInfo(reply);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@ -178,6 +184,88 @@ class SaveLockLogic extends BaseGetXController {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _replyGetStarLockStatusInfo(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
// 厂商名称
|
||||
var vendor = reply.data.sublist(3, 23);
|
||||
print("softVersion:$vendor");
|
||||
|
||||
// 锁设备类型
|
||||
var product = reply.data[23];
|
||||
print("product:$product");
|
||||
|
||||
// 产品名称
|
||||
var model = reply.data.sublist(24, 44);
|
||||
print("model:$model");
|
||||
|
||||
// 软件版本
|
||||
var fwVersion = reply.data.sublist(44, 64);
|
||||
print("fwVersion:$fwVersion");
|
||||
|
||||
// 硬件版本
|
||||
var hwVersion = reply.data.sublist(64, 84);
|
||||
print("hwVersion:$hwVersion");
|
||||
|
||||
// 厂商序列号
|
||||
var serialNum0 = reply.data.sublist(84, 100);
|
||||
print("serialNum0:$serialNum0");
|
||||
|
||||
// 成品商序列号
|
||||
var serialNum1 = reply.data.sublist(100, 116);
|
||||
print("serialNum1:$serialNum1");
|
||||
|
||||
// 蓝牙名称
|
||||
var btDeviceName = reply.data.sublist(116, 132);
|
||||
print("btDeviceName:$btDeviceName");
|
||||
|
||||
// 电池剩余电量
|
||||
var battRemCap = reply.data[132];
|
||||
print("battRemCap:$battRemCap");
|
||||
|
||||
// 重置次数
|
||||
var restoreCounter = reply.data.sublist(133, 134);
|
||||
print("restoreCounter:$restoreCounter");
|
||||
|
||||
// 重置时间
|
||||
var restoreDate = reply.data.sublist(134, 138);
|
||||
print("restoreDate:$restoreDate");
|
||||
|
||||
// 主控芯片型号
|
||||
var icPartNo = reply.data.sublist(138, 148);
|
||||
print("icPartNo:$icPartNo");
|
||||
|
||||
// 有效时间
|
||||
var indate = reply.data.sublist(148, 152);
|
||||
print("indate:$indate");
|
||||
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
print("${reply.commandType}需要鉴权");
|
||||
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${reply.commandType}用户无权限");
|
||||
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType}权限校验错误");
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${reply.commandType}失败");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 保存事件,先调用蓝牙,蓝牙调用成功后再调用后台接口
|
||||
saveLockAction(){
|
||||
addUserConnectBlue();
|
||||
@ -224,7 +312,8 @@ class SaveLockLogic extends BaseGetXController {
|
||||
void bindBlueAdmin() async{
|
||||
var lockDataMap = {};
|
||||
lockDataMap['lockName'] = BlueManage().connectDeviceName;
|
||||
lockDataMap['lockMac'] = BlueManage().connectDeviceMacAddress;
|
||||
lockDataMap['lockMac'] = "AB:C1:40:61:54:61";
|
||||
// lockDataMap['lockMac'] = BlueManage().connectDeviceMacAddress;
|
||||
|
||||
var positionMap = {};
|
||||
positionMap['longitude'] = state.addressMap["longitude"];
|
||||
@ -281,7 +370,12 @@ class SaveLockLogic extends BaseGetXController {
|
||||
if (state == DeviceConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
IoSenderManage.senderGetLockStatu(
|
||||
// IoSenderManage.senderGetLockStatu(
|
||||
// lockID:BlueManage().connectDeviceName,
|
||||
// userID:await Storage.getUid(),
|
||||
// privateKey:getPrivateKeyList,
|
||||
// );
|
||||
IoSenderManage.senderGetStarLockStatuInfo(
|
||||
lockID:BlueManage().connectDeviceName,
|
||||
userID:await Storage.getUid(),
|
||||
privateKey:getPrivateKeyList,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user