提交调试蓝牙协议
This commit is contained in:
parent
08e36eee3c
commit
d6fa4edd2e
@ -54,7 +54,7 @@ class SenderAddStressICCardCommand extends SenderProtocol {
|
|||||||
data.add(type2);
|
data.add(type2);
|
||||||
|
|
||||||
// 子命令类型
|
// 子命令类型
|
||||||
data.add(62);
|
data.add(61);
|
||||||
|
|
||||||
// keyID 40
|
// keyID 40
|
||||||
int keyIDLength = utf8.encode(keyID!).length;
|
int keyIDLength = utf8.encode(keyID!).length;
|
||||||
|
|||||||
@ -54,7 +54,7 @@ class SenderAddStressPasswordCommand extends SenderProtocol {
|
|||||||
data.add(type2);
|
data.add(type2);
|
||||||
|
|
||||||
// 子命令类型
|
// 子命令类型
|
||||||
data.add(62);
|
data.add(60);
|
||||||
|
|
||||||
// keyID 40
|
// keyID 40
|
||||||
int keyIDLength = utf8.encode(keyID!).length;
|
int keyIDLength = utf8.encode(keyID!).length;
|
||||||
|
|||||||
@ -65,28 +65,59 @@ class GetStarLockStatuInfoReply extends Reply {
|
|||||||
switch(status){
|
switch(status){
|
||||||
case 0x00:
|
case 0x00:
|
||||||
//成功
|
//成功
|
||||||
print("${commandType.typeValue} 数据解析成功");
|
// 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 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;
|
break;
|
||||||
case 0x06:
|
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 = [];
|
List<int> data = [];
|
||||||
Reply.parseData(this.commandType, List<int> dataDetail);
|
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_editUser.dart';
|
||||||
import 'package:star_lock/blue/io_protocol/io_factoryDataReset.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_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_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_timing.dart';
|
||||||
import 'package:star_lock/blue/io_protocol/io_transferPermissions.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_configuringWifi.dart';
|
||||||
import 'io_protocol/io_getPrivateKey.dart';
|
import 'io_protocol/io_getPrivateKey.dart';
|
||||||
import 'io_protocol/io_getPublicKey.dart';
|
import 'io_protocol/io_getPublicKey.dart';
|
||||||
|
import 'io_protocol/io_getStarLockStatusInfo.dart';
|
||||||
import 'io_protocol/io_openLock.dart';
|
import 'io_protocol/io_openLock.dart';
|
||||||
import 'io_protocol/io_queryingFingerprintStatus.dart';
|
import 'io_protocol/io_queryingFingerprintStatus.dart';
|
||||||
import 'io_protocol/io_referEventRecordNumber.dart';
|
import 'io_protocol/io_referEventRecordNumber.dart';
|
||||||
@ -164,6 +169,11 @@ class CommandReciverManager {
|
|||||||
reply = TimingReply.parseData(commandType, data);
|
reply = TimingReply.parseData(commandType, data);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case CommandType.readStarLockStatusInfo:
|
||||||
|
{
|
||||||
|
reply = GetStarLockStatuInfoReply.parseData(commandType, data);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case CommandType.generalExtendedCommond:
|
case CommandType.generalExtendedCommond:
|
||||||
{
|
{
|
||||||
// 子命令类型
|
// 子命令类型
|
||||||
@ -265,6 +275,30 @@ class CommandReciverManager {
|
|||||||
reply = SenderAddStressFingerprintReply.parseData(commandType, data);
|
reply = SenderAddStressFingerprintReply.parseData(commandType, data);
|
||||||
}
|
}
|
||||||
break;
|
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;
|
break;
|
||||||
|
|||||||
@ -16,11 +16,16 @@ import 'io_protocol/io_editUser.dart';
|
|||||||
import 'io_protocol/io_factoryDataReset.dart';
|
import 'io_protocol/io_factoryDataReset.dart';
|
||||||
import 'io_protocol/io_getPrivateKey.dart';
|
import 'io_protocol/io_getPrivateKey.dart';
|
||||||
import 'io_protocol/io_getPublicKey.dart';
|
import 'io_protocol/io_getPublicKey.dart';
|
||||||
|
import 'io_protocol/io_getStarLockStatusInfo.dart';
|
||||||
import 'io_protocol/io_openLock.dart';
|
import 'io_protocol/io_openLock.dart';
|
||||||
import 'io_protocol/io_queryingFingerprintStatus.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_referEventRecordNumber.dart';
|
||||||
import 'io_protocol/io_referEventRecordTime.dart';
|
import 'io_protocol/io_referEventRecordTime.dart';
|
||||||
import 'io_protocol/io_senderCustomPasswords.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_timing.dart';
|
||||||
import 'io_protocol/io_transferPermissions.dart';
|
import 'io_protocol/io_transferPermissions.dart';
|
||||||
import 'sender_data.dart';
|
import 'sender_data.dart';
|
||||||
@ -187,6 +192,20 @@ class IoSenderManage {
|
|||||||
), callBack:callBack);
|
), 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:转移权限
|
//todo:转移权限
|
||||||
static void senderTransferPermissions({
|
static void senderTransferPermissions({
|
||||||
required String? lockID,
|
required String? lockID,
|
||||||
@ -293,7 +312,7 @@ class IoSenderManage {
|
|||||||
), callBack:callBack);
|
), callBack:callBack);
|
||||||
}
|
}
|
||||||
|
|
||||||
//todo:添加指纹开始
|
//todo:添加卡开始
|
||||||
static void senderAddICCardCommand({
|
static void senderAddICCardCommand({
|
||||||
required String? keyID,
|
required String? keyID,
|
||||||
required String? userID,
|
required String? userID,
|
||||||
@ -343,27 +362,27 @@ class IoSenderManage {
|
|||||||
), callBack:callBack);
|
), callBack:callBack);
|
||||||
}
|
}
|
||||||
|
|
||||||
//todo:自动落锁
|
//todo:自动落锁 - 废弃
|
||||||
static void senderAutomaticPadlockCommand({
|
// static void senderAutomaticPadlockCommand({
|
||||||
required String? lockID,
|
// required String? lockID,
|
||||||
required String? userID,
|
// required String? userID,
|
||||||
required int? autoLockFlag,
|
// required int? autoLockFlag,
|
||||||
required List<int>? token,
|
// required List<int>? token,
|
||||||
required int? needAuthor,
|
// required int? needAuthor,
|
||||||
required List<int>? signKey,
|
// required List<int>? signKey,
|
||||||
required List<int>? privateKey,
|
// required List<int>? privateKey,
|
||||||
CommandSendCallBack? callBack}) {
|
// CommandSendCallBack? callBack}) {
|
||||||
CommandSenderManager().managerSendData(
|
// CommandSenderManager().managerSendData(
|
||||||
command: AutomaticPadlockCommand(
|
// command: AutomaticPadlockCommand(
|
||||||
lockID: lockID,
|
// lockID: lockID,
|
||||||
userID: userID,
|
// userID: userID,
|
||||||
autoLockFlag: autoLockFlag,
|
// autoLockFlag: autoLockFlag,
|
||||||
token: token,
|
// token: token,
|
||||||
needAuthor: needAuthor,
|
// needAuthor: needAuthor,
|
||||||
signKey: signKey,
|
// signKey: signKey,
|
||||||
privateKey: privateKey,
|
// privateKey: privateKey,
|
||||||
), callBack:callBack);
|
// ), callBack:callBack);
|
||||||
}
|
// }
|
||||||
|
|
||||||
//todo:事件记录(页数查询)
|
//todo:事件记录(页数查询)
|
||||||
static void senderReferEventRecordNumberCommand({
|
static void senderReferEventRecordNumberCommand({
|
||||||
@ -601,4 +620,98 @@ class IoSenderManage {
|
|||||||
), callBack:callBack);
|
), 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());
|
state.xWidth.value.toString());
|
||||||
if (entity.errorCode!.codeIsSuccessful) {
|
if (entity.errorCode!.codeIsSuccessful) {
|
||||||
_startTimer();
|
_startTimer();
|
||||||
} else {}
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void checkNext(TextEditingController controller) {
|
void checkNext(TextEditingController controller) {
|
||||||
|
|||||||
@ -2,10 +2,10 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
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 'package:star_lock/tools/baseGetXController.dart';
|
||||||
import '../../../../blue/blue_manage.dart';
|
import '../../../../blue/blue_manage.dart';
|
||||||
import '../../../../blue/io_protocol/io_automaticPadlock.dart';
|
import '../../../../blue/io_protocol/io_readSupportFunctionsWithParameters.dart';
|
||||||
import '../../../../blue/io_protocol/io_getLockStatu.dart';
|
|
||||||
import '../../../../blue/io_reply.dart';
|
import '../../../../blue/io_reply.dart';
|
||||||
import '../../../../blue/io_tool/io_manager.dart';
|
import '../../../../blue/io_tool/io_manager.dart';
|
||||||
import '../../../../blue/io_tool/io_tool.dart';
|
import '../../../../blue/io_tool/io_tool.dart';
|
||||||
@ -20,12 +20,16 @@ import 'automaticBlocking_state.dart';
|
|||||||
class AutomaticBlockingLogic extends BaseGetXController{
|
class AutomaticBlockingLogic extends BaseGetXController{
|
||||||
final AutomaticBlockingState state = AutomaticBlockingState();
|
final AutomaticBlockingState state = AutomaticBlockingState();
|
||||||
|
|
||||||
void setAutoUnLock() async{
|
void _setAutoUnLock() async{
|
||||||
String autoTime;
|
String autoTime;
|
||||||
if(state.isOpen.value == false){
|
if(state.isOpen.value == false){
|
||||||
autoTime = "-1";
|
autoTime = "-1";
|
||||||
}else{
|
}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(
|
var entity = await ApiRepository.to.setAutoUnlock(
|
||||||
@ -34,6 +38,7 @@ class AutomaticBlockingLogic extends BaseGetXController{
|
|||||||
type: "1",
|
type: "1",
|
||||||
);
|
);
|
||||||
if(entity.errorCode!.codeIsSuccessful){
|
if(entity.errorCode!.codeIsSuccessful){
|
||||||
|
state.autoLockTime.value = state.isOpen.value == false ? "0" : autoTime;
|
||||||
state.getKeyInfosData.value.autoLockTime = int.parse(autoTime);
|
state.getKeyInfosData.value.autoLockTime = int.parse(autoTime);
|
||||||
eventBus.fire(RefreshLockListInfoDataEvent());
|
eventBus.fire(RefreshLockListInfoDataEvent());
|
||||||
eventBus.fire(PassCurrentLockInformationEvent(state.getKeyInfosData.value));
|
eventBus.fire(PassCurrentLockInformationEvent(state.getKeyInfosData.value));
|
||||||
@ -45,24 +50,25 @@ class AutomaticBlockingLogic extends BaseGetXController{
|
|||||||
late StreamSubscription<Reply> _replySubscription;
|
late StreamSubscription<Reply> _replySubscription;
|
||||||
void _initReplySubscription() {
|
void _initReplySubscription() {
|
||||||
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) {
|
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) {
|
||||||
if(reply is AutomaticPadlockReply) {
|
if(reply is SetSupportFunctionsWithParametersReply) {
|
||||||
_replyAutomaticPadlock(reply);
|
_replySetSupportFunctionsWithParameters(reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取锁状态
|
// 读取支持功能(带参数)
|
||||||
if(reply is GetLockStatuReply) {
|
if(reply is ReadSupportFunctionsWithParametersReply) {
|
||||||
_replyGetLockStatus(reply);
|
_readSupportFunctionsWithParametersReply(reply);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取锁状态数据解析
|
// 读取支持功能带参数数据解析
|
||||||
Future<void> _replyGetLockStatus(Reply reply) async {
|
Future<void> _readSupportFunctionsWithParametersReply(Reply reply) async {
|
||||||
int status = reply.data[2];
|
int status = reply.data[2];
|
||||||
switch(status){
|
switch(status){
|
||||||
case 0x00:
|
case 0x00:
|
||||||
//成功
|
//成功
|
||||||
print("${reply.commandType}数据解析成功");
|
print("${reply.commandType}数据解析成功");
|
||||||
|
state.autoLockTime.value = reply.data[7].toString();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 0x06:
|
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];
|
int status = reply.data[2];
|
||||||
switch(status){
|
switch(status){
|
||||||
case 0x00:
|
case 0x00:
|
||||||
//成功
|
//成功
|
||||||
print("${reply.commandType}数据解析成功");
|
print("${reply.commandType}数据解析成功");
|
||||||
// _getLockStatus();
|
_setAutoUnLock();
|
||||||
break;
|
break;
|
||||||
case 0x06:
|
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 {
|
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||||
if (connectionState == DeviceConnectionState.connected) {
|
if (connectionState == DeviceConnectionState.connected) {
|
||||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||||
IoSenderManage.senderGetLockStatu(
|
|
||||||
lockID:BlueManage().connectDeviceName,
|
var token = await Storage.getStringList(saveBlueToken);
|
||||||
userID:await Storage.getUid(),
|
List<int> getTokenList = changeStringListToIntList(token!);
|
||||||
privateKey:getPrivateKeyList,
|
|
||||||
|
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 {
|
Future<void> sendAutoLock() async {
|
||||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||||
if (connectionState == DeviceConnectionState.connected) {
|
if (connectionState == DeviceConnectionState.connected) {
|
||||||
@ -146,19 +162,30 @@ class AutomaticBlockingLogic extends BaseGetXController{
|
|||||||
var token = await Storage.getStringList(saveBlueToken);
|
var token = await Storage.getStringList(saveBlueToken);
|
||||||
List<int> getTokenList = changeStringListToIntList(token!);
|
List<int> getTokenList = changeStringListToIntList(token!);
|
||||||
|
|
||||||
var signKey = await Storage.getStringList(saveBlueSignKey);
|
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||||
List<int> getSignKeyList = changeStringListToIntList(signKey!);
|
List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
||||||
|
|
||||||
print("automaticBlockingState.isOpen.value:${state.isOpen.value}");
|
String autoTime;
|
||||||
IoSenderManage.senderAutomaticPadlockCommand(
|
if(state.isOpen.value == false){
|
||||||
lockID:BlueManage().connectDeviceName,
|
autoTime = "0";
|
||||||
userID:await Storage.getUid(),
|
}else{
|
||||||
autoLockFlag:state.isOpen.value ? 1 : 0,
|
if(state.isCustomLockTime.value == true){
|
||||||
token:getTokenList,
|
autoTime = state.timeController.text;
|
||||||
needAuthor:1,
|
}else{
|
||||||
signKey:getSignKeyList,
|
autoTime = state.autoLockTime.value;
|
||||||
privateKey:getPrivateKeyList,
|
}
|
||||||
);
|
}
|
||||||
|
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();
|
super.onInit();
|
||||||
print("onInit()");
|
print("onInit()");
|
||||||
|
|
||||||
_getLockStatus();
|
_readSupportFunctionsWithParameters();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@ -20,7 +20,6 @@ class AutomaticBlockingPage extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _AutomaticBlockingPageState extends State<AutomaticBlockingPage> {
|
class _AutomaticBlockingPageState extends State<AutomaticBlockingPage> {
|
||||||
final TextEditingController _timeController = TextEditingController();
|
|
||||||
final logic = Get.put(AutomaticBlockingLogic());
|
final logic = Get.put(AutomaticBlockingLogic());
|
||||||
final state = Get.find<AutomaticBlockingLogic>().state;
|
final state = Get.find<AutomaticBlockingLogic>().state;
|
||||||
|
|
||||||
@ -39,7 +38,7 @@ class _AutomaticBlockingPageState extends State<AutomaticBlockingPage> {
|
|||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
// logic.sendAutoLock();
|
// logic.sendAutoLock();
|
||||||
logic.setAutoUnLock();
|
logic.sendAutoLock();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -53,13 +52,11 @@ class _AutomaticBlockingPageState extends State<AutomaticBlockingPage> {
|
|||||||
isHaveRightWidget: true,
|
isHaveRightWidget: true,
|
||||||
rightWidget:
|
rightWidget:
|
||||||
SizedBox(width: 60.w, height: 50.h, child: _switch())),),
|
SizedBox(width: 60.w, height: 50.h, child: _switch())),),
|
||||||
Container(
|
Container(height: 10.h,),
|
||||||
height: 10.h,
|
|
||||||
),
|
|
||||||
Builder(builder: (context) {
|
Builder(builder: (context) {
|
||||||
return Obx(() => CommonItem(
|
return Obx(() => CommonItem(
|
||||||
leftTitel: TranslationLoader.lanKeys!.delayTime!.tr,
|
leftTitel: TranslationLoader.lanKeys!.delayTime!.tr,
|
||||||
rightTitle: "${state.autoLockTime.value}s",
|
rightTitle: state.isCustomLockTime.value == true ? "自定义" : "${state.autoLockTime.value}s",
|
||||||
isHaveLine: false,
|
isHaveLine: false,
|
||||||
isHaveDirection: true,
|
isHaveDirection: true,
|
||||||
action: () {
|
action: () {
|
||||||
@ -115,7 +112,7 @@ class _AutomaticBlockingPageState extends State<AutomaticBlockingPage> {
|
|||||||
TextField(
|
TextField(
|
||||||
//输入框一行
|
//输入框一行
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
controller: _timeController,
|
controller: state.timeController,
|
||||||
autofocus: false,
|
autofocus: false,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
//输入里面输入文字内边距设置
|
//输入里面输入文字内边距设置
|
||||||
@ -161,6 +158,9 @@ class _AutomaticBlockingPageState extends State<AutomaticBlockingPage> {
|
|||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
setState(() {
|
setState(() {
|
||||||
state.isOpen.value = value;
|
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 'package:get/get.dart';
|
||||||
|
|
||||||
import '../../../lockMian/entity/lockInfoEntity.dart';
|
import '../../../lockMian/entity/lockInfoEntity.dart';
|
||||||
@ -9,11 +10,13 @@ class AutomaticBlockingState {
|
|||||||
var isOpen = false.obs;// 是否开启自动落锁
|
var isOpen = false.obs;// 是否开启自动落锁
|
||||||
var autoLockTime = "5".obs;
|
var autoLockTime = "5".obs;
|
||||||
var isCustomLockTime = false.obs;// 自定义
|
var isCustomLockTime = false.obs;// 自定义
|
||||||
|
final TextEditingController timeController = TextEditingController();
|
||||||
|
|
||||||
AutomaticBlockingState() {
|
AutomaticBlockingState() {
|
||||||
getKeyInfosData.value = Get.arguments as KeyInfos;
|
getKeyInfosData.value = Get.arguments as KeyInfos;
|
||||||
isOpen.value = getKeyInfosData.value.autoLockTime! > -1 ? true : false;
|
isOpen.value = getKeyInfosData.value.autoLockTime! > -1 ? true : false;
|
||||||
autoLockTime.value = getKeyInfosData.value.autoLockTime!.toString();
|
autoLockTime.value = getKeyInfosData.value.autoLockTime!.toString();
|
||||||
|
|
||||||
if((getKeyInfosData.value.autoLockTime! > 0)
|
if((getKeyInfosData.value.autoLockTime! > 0)
|
||||||
&& (getKeyInfosData.value.autoLockTime! != 5)
|
&& (getKeyInfosData.value.autoLockTime! != 5)
|
||||||
&& (getKeyInfosData.value.autoLockTime! != 10)
|
&& (getKeyInfosData.value.autoLockTime! != 10)
|
||||||
@ -21,6 +24,7 @@ class AutomaticBlockingState {
|
|||||||
&& (getKeyInfosData.value.autoLockTime! != 30)
|
&& (getKeyInfosData.value.autoLockTime! != 30)
|
||||||
&& (getKeyInfosData.value.autoLockTime! != 60)){
|
&& (getKeyInfosData.value.autoLockTime! != 60)){
|
||||||
isCustomLockTime.value = true;
|
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 '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 '../../../../network/api_repository.dart';
|
||||||
import '../../../../tools/eventBusEventManage.dart';
|
import '../../../../tools/eventBusEventManage.dart';
|
||||||
|
import '../../../../tools/storage.dart';
|
||||||
import '../../../../tools/toast.dart';
|
import '../../../../tools/toast.dart';
|
||||||
import 'burglarAlarm_state.dart';
|
import 'burglarAlarm_state.dart';
|
||||||
|
|
||||||
@ -9,7 +21,7 @@ class BurglarAlarmLogic extends BaseGetXController{
|
|||||||
BurglarAlarmState state = BurglarAlarmState();
|
BurglarAlarmState state = BurglarAlarmState();
|
||||||
|
|
||||||
// 配置锁的常开模式设置 -> 防撬报警
|
// 配置锁的常开模式设置 -> 防撬报警
|
||||||
Future<void> setLockSetGeneralSetting() async{
|
Future<void> _setLockSetGeneralSetting() async{
|
||||||
var entity = await ApiRepository.to.setLockSetGeneralSettingData(
|
var entity = await ApiRepository.to.setLockSetGeneralSettingData(
|
||||||
lockId: state.getKeyInfosData.value.lockId.toString(),
|
lockId: state.getKeyInfosData.value.lockId.toString(),
|
||||||
changeType:"1",
|
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),
|
// margin: EdgeInsets.only(left: 03.w, right: 30.w, top: 20.w),
|
||||||
padding: EdgeInsets.only(top: 20.w, bottom: 20.w),
|
padding: EdgeInsets.only(top: 20.w, bottom: 20.w),
|
||||||
onClick: () {
|
onClick: () {
|
||||||
logic.setLockSetGeneralSetting();
|
logic.sendBurglarAlarm();
|
||||||
})),
|
})),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@ -64,10 +64,10 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
|||||||
'keyInfo': state.getKeyInfosData.value
|
'keyInfo': state.getKeyInfosData.value
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
SizedBox(
|
SizedBox(height: 10.h,),
|
||||||
height: 10.h,
|
Visibility(
|
||||||
),
|
visible: true,
|
||||||
CommonItem(
|
child:CommonItem(
|
||||||
leftTitel: TranslationLoader.lanKeys!.doorMagnetic!.tr,
|
leftTitel: TranslationLoader.lanKeys!.doorMagnetic!.tr,
|
||||||
rightTitle: "",
|
rightTitle: "",
|
||||||
isHaveLine: true,
|
isHaveLine: true,
|
||||||
@ -75,32 +75,37 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
|||||||
action: () {
|
action: () {
|
||||||
Get.toNamed(Routers.doorMagneticPage);
|
Get.toNamed(Routers.doorMagneticPage);
|
||||||
// Toast.show(msg: "功能暂未开放");
|
// 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(
|
Visibility(
|
||||||
leftTitel:
|
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,
|
TranslationLoader.lanKeys!.automaticBlocking!.tr,
|
||||||
rightTitle: state.getKeyInfosData.value.autoLockTime! > -1
|
rightTitle: state.getKeyInfosData.value.autoLockTime! > -1
|
||||||
? "${state.getKeyInfosData.value.autoLockTime!.toString()}s"
|
? "${state.getKeyInfosData.value.autoLockTime!.toString()}s"
|
||||||
: TranslationLoader.lanKeys!.closed!.tr,
|
: TranslationLoader.lanKeys!.closed!.tr,
|
||||||
isHaveLine: true,
|
isHaveLine: true,
|
||||||
isHaveDirection: true,
|
isHaveDirection: true,
|
||||||
action: () {
|
action: () {
|
||||||
Get.toNamed(Routers.automaticBlockingPage,
|
Get.toNamed(Routers.automaticBlockingPage,
|
||||||
arguments: state.getKeyInfosData.value);
|
arguments: state.getKeyInfosData.value);
|
||||||
})),
|
}))
|
||||||
|
),
|
||||||
Obx(() {
|
Obx(() {
|
||||||
var titleStr = "";
|
var titleStr = "";
|
||||||
if (state.getKeyInfosData.value.lockSound == 1) {
|
if (state.getKeyInfosData.value.lockSound == 1) {
|
||||||
@ -124,17 +129,22 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
|||||||
} else {
|
} else {
|
||||||
titleStr = TranslationLoader.lanKeys!.closed!.tr;
|
titleStr = TranslationLoader.lanKeys!.closed!.tr;
|
||||||
}
|
}
|
||||||
return CommonItem(
|
return Visibility(
|
||||||
leftTitel: TranslationLoader.lanKeys!.lockSound!.tr,
|
visible: true,
|
||||||
rightTitle: titleStr,
|
child: CommonItem(
|
||||||
isHaveLine: true,
|
leftTitel: TranslationLoader.lanKeys!.lockSound!.tr,
|
||||||
isHaveDirection: true,
|
rightTitle: titleStr,
|
||||||
action: () {
|
isHaveLine: true,
|
||||||
Get.toNamed(Routers.lockSoundSetPage,
|
isHaveDirection: true,
|
||||||
arguments: state.getKeyInfosData.value);
|
action: () {
|
||||||
});
|
Get.toNamed(Routers.lockSoundSetPage,
|
||||||
|
arguments: state.getKeyInfosData.value);
|
||||||
|
})
|
||||||
|
);
|
||||||
}),
|
}),
|
||||||
Obx(() => CommonItem(
|
Obx(() => Visibility(
|
||||||
|
visible: true,
|
||||||
|
child: CommonItem(
|
||||||
leftTitel: TranslationLoader.lanKeys!.burglarAlarm!.tr,
|
leftTitel: TranslationLoader.lanKeys!.burglarAlarm!.tr,
|
||||||
rightTitle: state.getKeyInfosData.value.tamperAlert == 1
|
rightTitle: state.getKeyInfosData.value.tamperAlert == 1
|
||||||
? TranslationLoader.lanKeys!.opened!.tr
|
? TranslationLoader.lanKeys!.opened!.tr
|
||||||
@ -144,25 +154,26 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
|||||||
action: () {
|
action: () {
|
||||||
Get.toNamed(Routers.burglarAlarmPage,
|
Get.toNamed(Routers.burglarAlarmPage,
|
||||||
arguments: state.getKeyInfosData.value);
|
arguments: state.getKeyInfosData.value);
|
||||||
})),
|
}))),
|
||||||
SizedBox(
|
SizedBox(height: 10.h),
|
||||||
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(
|
Obx(() => Visibility(
|
||||||
() => CommonItem(
|
visible:true,
|
||||||
leftTitel:
|
child: CommonItem(
|
||||||
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!.remoteUnlocking!.tr,
|
leftTitel: TranslationLoader.lanKeys!.remoteUnlocking!.tr,
|
||||||
rightTitle: state.getKeyInfosData.value.remoteEnable == 1
|
rightTitle: state.getKeyInfosData.value.remoteEnable == 1
|
||||||
? TranslationLoader.lanKeys!.opened!.tr
|
? TranslationLoader.lanKeys!.opened!.tr
|
||||||
@ -172,8 +183,11 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
|||||||
action: () {
|
action: () {
|
||||||
Get.toNamed(Routers.remoteUnlockingPage,
|
Get.toNamed(Routers.remoteUnlockingPage,
|
||||||
arguments: state.getKeyInfosData.value);
|
arguments: state.getKeyInfosData.value);
|
||||||
})),
|
}))
|
||||||
Obx(() => CommonItem(
|
),
|
||||||
|
Obx(() => Visibility(
|
||||||
|
visible: true,
|
||||||
|
child: CommonItem(
|
||||||
leftTitel: TranslationLoader.lanKeys!.resetButton!.tr,
|
leftTitel: TranslationLoader.lanKeys!.resetButton!.tr,
|
||||||
rightTitle: state.getKeyInfosData.value.resetButton == 1
|
rightTitle: state.getKeyInfosData.value.resetButton == 1
|
||||||
? TranslationLoader.lanKeys!.opened!.tr
|
? TranslationLoader.lanKeys!.opened!.tr
|
||||||
@ -183,60 +197,85 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
|||||||
action: () {
|
action: () {
|
||||||
Get.toNamed(Routers.resetButtonPage,
|
Get.toNamed(Routers.resetButtonPage,
|
||||||
arguments: state.getKeyInfosData.value);
|
arguments: state.getKeyInfosData.value);
|
||||||
})),
|
}))
|
||||||
SizedBox(
|
|
||||||
height: 10.h,
|
|
||||||
),
|
),
|
||||||
|
SizedBox(height: 10.h),
|
||||||
//---田总新增展示
|
//---田总新增展示
|
||||||
CommonItem(
|
// Obx(() =>
|
||||||
|
Visibility(
|
||||||
|
visible: true,
|
||||||
|
child: CommonItem(
|
||||||
leftTitel: '面容开锁',
|
leftTitel: '面容开锁',
|
||||||
rightTitle: "",
|
rightTitle: "",
|
||||||
isHaveLine: true,
|
isHaveLine: true,
|
||||||
isHaveRightWidget: true,
|
isHaveRightWidget: true,
|
||||||
rightWidget:
|
rightWidget:
|
||||||
SizedBox(width: 60.w, child: _openCheckInSwitch())),
|
SizedBox(width: 60.w, child: _openCheckInSwitch()))),
|
||||||
CommonItem(
|
// ),
|
||||||
leftTitel: '感应距离',
|
// Obx(() =>
|
||||||
rightTitle: "远",
|
Visibility(
|
||||||
isHaveLine: true,
|
visible: true,
|
||||||
isHaveDirection: true,
|
child: CommonItem(
|
||||||
),
|
leftTitel: '感应距离',
|
||||||
CommonItem(
|
rightTitle: "远",
|
||||||
leftTitel: '自动亮屏',
|
|
||||||
rightTitle: "",
|
|
||||||
isHaveLine: true,
|
isHaveLine: true,
|
||||||
isHaveRightWidget: true,
|
isHaveDirection: true,
|
||||||
rightWidget:
|
)),
|
||||||
SizedBox(width: 60.w, child: _openCheckInSwitch())),
|
// ),
|
||||||
CommonItem(
|
// Obx(() =>
|
||||||
leftTitel: '逗留警告',
|
Visibility(
|
||||||
rightTitle: "",
|
visible: true,
|
||||||
isHaveLine: true,
|
child: CommonItem(
|
||||||
isHaveRightWidget: true,
|
leftTitel: '自动亮屏',
|
||||||
rightWidget:
|
rightTitle: "",
|
||||||
SizedBox(width: 60.w, child: _openCheckInSwitch())),
|
isHaveLine: true,
|
||||||
CommonItem(
|
isHaveRightWidget: true,
|
||||||
leftTitel: '异常警告',
|
rightWidget:
|
||||||
rightTitle: "",
|
SizedBox(width: 60.w, child: _openCheckInSwitch()))),
|
||||||
isHaveLine: true,
|
// ),
|
||||||
isHaveRightWidget: true,
|
// Obx(() =>
|
||||||
rightWidget:
|
Visibility(
|
||||||
SizedBox(width: 60.w, child: _openCheckInSwitch())),
|
visible: true,
|
||||||
CommonItem(
|
child: CommonItem(
|
||||||
leftTitel: '开门方向设置',
|
leftTitel: '逗留警告',
|
||||||
rightTitle: "右开",
|
rightTitle: "",
|
||||||
isHaveDirection: true,
|
isHaveLine: true,
|
||||||
isHaveLine: true,
|
isHaveRightWidget: true,
|
||||||
),
|
rightWidget:
|
||||||
CommonItem(
|
SizedBox(width: 60.w, child: _openCheckInSwitch()))),
|
||||||
leftTitel: '电机功率设置',
|
// ),
|
||||||
rightTitle: "大",
|
// Obx(() =>
|
||||||
isHaveLine: true,
|
Visibility(
|
||||||
isHaveDirection: true,
|
visible: true,
|
||||||
),
|
child: CommonItem(
|
||||||
SizedBox(
|
leftTitel: '异常警告',
|
||||||
height: 10.h,
|
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(() {
|
Obx(() {
|
||||||
var title = "";
|
var title = "";
|
||||||
@ -245,44 +284,61 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
|||||||
} else if (state.getKeyInfosData.value.roomStatus == 2) {
|
} else if (state.getKeyInfosData.value.roomStatus == 2) {
|
||||||
title = TranslationLoader.lanKeys!.leisure!.tr;
|
title = TranslationLoader.lanKeys!.leisure!.tr;
|
||||||
}
|
}
|
||||||
return CommonItem(
|
return Visibility(
|
||||||
leftTitel:
|
visible: true,
|
||||||
|
child: CommonItem(
|
||||||
|
leftTitel:
|
||||||
TranslationLoader.lanKeys!.markedHouseState!.tr,
|
TranslationLoader.lanKeys!.markedHouseState!.tr,
|
||||||
rightTitle: title,
|
rightTitle: title,
|
||||||
isHaveLine: true,
|
isHaveLine: true,
|
||||||
isHaveDirection: true,
|
isHaveDirection: true,
|
||||||
action: () {
|
action: () {
|
||||||
Get.toNamed(Routers.markedHouseStatePage,
|
Get.toNamed(Routers.markedHouseStatePage,
|
||||||
arguments: state.getKeyInfosData.value);
|
arguments: state.getKeyInfosData.value);
|
||||||
});
|
})
|
||||||
|
);
|
||||||
}),
|
}),
|
||||||
CommonItem(
|
// Obx(() =>
|
||||||
leftTitel: TranslationLoader.lanKeys!.checkingIn!.tr,
|
Visibility(
|
||||||
rightTitle: "",
|
visible: true,
|
||||||
isHaveLine: true,
|
child: CommonItem(
|
||||||
isHaveRightWidget: true,
|
leftTitel: TranslationLoader.lanKeys!.checkingIn!.tr,
|
||||||
rightWidget:
|
rightTitle: "",
|
||||||
SizedBox(width: 60.w, child: _openCheckInSwitch())),
|
isHaveLine: true,
|
||||||
CommonItem(
|
isHaveRightWidget: true,
|
||||||
leftTitel: TranslationLoader.lanKeys!.unlockReminder!.tr,
|
rightWidget:
|
||||||
rightTitle: "",
|
SizedBox(width: 60.w, child: _openCheckInSwitch())
|
||||||
isHaveLine: false,
|
)),
|
||||||
isHaveRightWidget: true,
|
// ),
|
||||||
rightWidget:
|
// Obx(() =>
|
||||||
SizedBox(width: 60.w, child: _lockRemindSwitch())),
|
Visibility(
|
||||||
SizedBox(
|
visible: true,
|
||||||
height: 10.h,
|
child: CommonItem(
|
||||||
),
|
leftTitel: TranslationLoader.lanKeys!.unlockReminder!.tr,
|
||||||
CommonItem(
|
rightTitle: "",
|
||||||
leftTitel: TranslationLoader
|
isHaveLine: false,
|
||||||
.lanKeys!.wifiDistributionNetwork!.tr,
|
isHaveRightWidget: true,
|
||||||
rightTitle: "",
|
rightWidget:
|
||||||
isHaveLine: true,
|
SizedBox(width: 60.w, child: _lockRemindSwitch()))),
|
||||||
isHaveDirection: true,
|
// ),
|
||||||
action: () {
|
SizedBox(height: 10.h),
|
||||||
Get.toNamed(Routers.configuringWifiPage);
|
// Obx(() =>
|
||||||
}),
|
Visibility(
|
||||||
CommonItem(
|
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,
|
leftTitel: TranslationLoader.lanKeys!.lockTime!.tr,
|
||||||
rightTitle: "",
|
rightTitle: "",
|
||||||
isHaveLine: true,
|
isHaveLine: true,
|
||||||
@ -290,44 +346,59 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
|||||||
action: () {
|
action: () {
|
||||||
Get.toNamed(Routers.lockTimePage,
|
Get.toNamed(Routers.lockTimePage,
|
||||||
arguments: state.getKeyInfosData.value);
|
arguments: state.getKeyInfosData.value);
|
||||||
}),
|
})),
|
||||||
CommonItem(
|
// ),
|
||||||
leftTitel: TranslationLoader.lanKeys!.diagnose!.tr,
|
// Obx(() =>
|
||||||
rightTitle: "",
|
Visibility(
|
||||||
isHaveLine: true,
|
visible: true,
|
||||||
isHaveDirection: true,
|
child: CommonItem(
|
||||||
action: () {
|
leftTitel: TranslationLoader.lanKeys!.diagnose!.tr,
|
||||||
Get.toNamed(Routers.diagnosePage,
|
rightTitle: "",
|
||||||
arguments: state.getKeyInfosData.value);
|
isHaveLine: true,
|
||||||
}),
|
isHaveDirection: true,
|
||||||
CommonItem(
|
action: () {
|
||||||
leftTitel: TranslationLoader.lanKeys!.uploadData!.tr,
|
Get.toNamed(Routers.diagnosePage,
|
||||||
rightTitle: "",
|
arguments: state.getKeyInfosData.value);
|
||||||
isHaveLine: true,
|
})),
|
||||||
isHaveDirection: true,
|
// ),
|
||||||
action: () {
|
// Obx(() =>
|
||||||
Get.toNamed(Routers.uploadDataPage);
|
Visibility(
|
||||||
}),
|
visible: true,
|
||||||
CommonItem(
|
child: CommonItem(
|
||||||
leftTitel:
|
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,
|
TranslationLoader.lanKeys!.importOtherLockData!.tr,
|
||||||
rightTitle: "",
|
rightTitle: "",
|
||||||
isHaveLine: true,
|
isHaveLine: true,
|
||||||
isHaveDirection: true,
|
isHaveDirection: true,
|
||||||
action: () {
|
action: () {
|
||||||
Get.toNamed(Routers.importOtherLockDataPage);
|
Get.toNamed(Routers.importOtherLockDataPage);
|
||||||
}),
|
})),
|
||||||
CommonItem(
|
// ),
|
||||||
leftTitel: TranslationLoader.lanKeys!.lockEscalation!.tr,
|
// Obx(() =>
|
||||||
rightTitle: "",
|
Visibility(
|
||||||
isHaveLine: false,
|
visible: true,
|
||||||
isHaveDirection: true,
|
child: CommonItem(
|
||||||
action: () {
|
leftTitel: TranslationLoader.lanKeys!.lockEscalation!.tr,
|
||||||
Get.toNamed(Routers.lockEscalationPage);
|
rightTitle: "",
|
||||||
}),
|
isHaveLine: false,
|
||||||
SizedBox(
|
isHaveDirection: true,
|
||||||
height: 30.h,
|
action: () {
|
||||||
),
|
Get.toNamed(Routers.lockEscalationPage);
|
||||||
|
})),
|
||||||
|
// ),
|
||||||
|
SizedBox(height: 30.h),
|
||||||
Container(
|
Container(
|
||||||
padding: EdgeInsets.only(left: 20.w, right: 20.w),
|
padding: EdgeInsets.only(left: 20.w, right: 20.w),
|
||||||
child: SubmitBtn(
|
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 '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 '../../../../network/api_repository.dart';
|
||||||
import '../../../../tools/eventBusEventManage.dart';
|
import '../../../../tools/eventBusEventManage.dart';
|
||||||
|
import '../../../../tools/storage.dart';
|
||||||
import '../../../../tools/toast.dart';
|
import '../../../../tools/toast.dart';
|
||||||
import 'lockSoundSet_state.dart';
|
import 'lockSoundSet_state.dart';
|
||||||
|
|
||||||
@ -9,7 +21,7 @@ class LockSoundSetLogic extends BaseGetXController {
|
|||||||
LockSoundSetState state = LockSoundSetState();
|
LockSoundSetState state = LockSoundSetState();
|
||||||
|
|
||||||
// 配置锁的常开模式设置 -> 锁声音设置
|
// 配置锁的常开模式设置 -> 锁声音设置
|
||||||
void setLockSetGeneralSetting() async{
|
void _setLockSetGeneralSetting() async{
|
||||||
int isOn;
|
int isOn;
|
||||||
int type;
|
int type;
|
||||||
if(state.isOpenLockSound.value == false){
|
if(state.isOpenLockSound.value == false){
|
||||||
@ -25,13 +37,180 @@ class LockSoundSetLogic extends BaseGetXController {
|
|||||||
isOn:isOn.toString(), // 1-开启、2-关闭; 设置音量:1到5;
|
isOn:isOn.toString(), // 1-开启、2-关闭; 设置音量:1到5;
|
||||||
type:type.toString(), // 6-锁声音开关 8-音量、
|
type:type.toString(), // 6-锁声音开关 8-音量、
|
||||||
);
|
);
|
||||||
|
|
||||||
if(entity.errorCode!.codeIsSuccessful){
|
if(entity.errorCode!.codeIsSuccessful){
|
||||||
eventBus.fire(RefreshLockListInfoDataEvent());
|
eventBus.fire(RefreshLockListInfoDataEvent());
|
||||||
//
|
|
||||||
state.getKeyInfosData.value.lockSound = state.isOpenLockSound.value == true ? 1 :2;
|
state.getKeyInfosData.value.lockSound = state.isOpenLockSound.value == true ? 1 :2;
|
||||||
state.getKeyInfosData.value.volume = state.lockSoundLevel.value;
|
state.getKeyInfosData.value.volume = state.lockSoundLevel.value;
|
||||||
eventBus.fire(PassCurrentLockInformationEvent(state.getKeyInfosData.value));
|
eventBus.fire(PassCurrentLockInformationEvent(state.getKeyInfosData.value));
|
||||||
Toast.show(msg: "操作成功");
|
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(
|
child: SubmitBtn(
|
||||||
btnName: TranslationLoader.lanKeys!.save!.tr,
|
btnName: TranslationLoader.lanKeys!.save!.tr,
|
||||||
onClick: () {
|
onClick: () {
|
||||||
logic.setLockSetGeneralSetting();
|
logic.sendLockSound();
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@ -1,10 +1,22 @@
|
|||||||
|
|
||||||
|
|
||||||
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:date_format/date_format.dart';
|
import 'package:date_format/date_format.dart';
|
||||||
|
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||||
import 'package:star_lock/tools/baseGetXController.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 '../../../../network/api_repository.dart';
|
||||||
import '../../../../tools/eventBusEventManage.dart';
|
import '../../../../tools/eventBusEventManage.dart';
|
||||||
|
import '../../../../tools/storage.dart';
|
||||||
import '../../../../tools/toast.dart';
|
import '../../../../tools/toast.dart';
|
||||||
import 'normallyOpenMode_state.dart';
|
import 'normallyOpenMode_state.dart';
|
||||||
|
|
||||||
@ -43,8 +55,8 @@ class NormallyOpenModeLogic extends BaseGetXController{
|
|||||||
passageMode:state.isOpenNormallyOpenMode.value == true ? "1":"2",
|
passageMode:state.isOpenNormallyOpenMode.value == true ? "1":"2",
|
||||||
autoUnlock:state.isOpenAutomaticUnLock.value == true ? "1":"2",
|
autoUnlock:state.isOpenAutomaticUnLock.value == true ? "1":"2",
|
||||||
type: "1",
|
type: "1",
|
||||||
startDate: state.beginTimeMinute.toString(),
|
startDate: state.beginTimeMinute.value.toString(),
|
||||||
endDate: state.endTimeMinute.toString(),
|
endDate: state.endTimeMinute.value.toString(),
|
||||||
isAllDay: state.isAllDay.value == 1 ? "1":"2",
|
isAllDay: state.isAllDay.value == 1 ? "1":"2",
|
||||||
weekDays: state.weekDays,
|
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
|
@override
|
||||||
void onReady() {
|
void onReady() {
|
||||||
// TODO: implement onReady
|
// TODO: implement onReady
|
||||||
@ -66,6 +219,8 @@ class NormallyOpenModeLogic extends BaseGetXController{
|
|||||||
if(state.getKeyInfosData.value.passageMode == 1){
|
if(state.getKeyInfosData.value.passageMode == 1){
|
||||||
getNormallyOpenModeConfig();
|
getNormallyOpenModeConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_initReplySubscription();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -73,10 +228,15 @@ class NormallyOpenModeLogic extends BaseGetXController{
|
|||||||
// TODO: implement onInit
|
// TODO: implement onInit
|
||||||
super.onInit();
|
super.onInit();
|
||||||
print("onInit()");
|
print("onInit()");
|
||||||
|
|
||||||
|
_readSupportFunctionsWithParameters();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onClose() {
|
void onClose() {
|
||||||
// TODO: implement onClose
|
// TODO: implement onClose
|
||||||
|
super.onClose();
|
||||||
|
|
||||||
|
_replySubscription.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -110,7 +110,7 @@ class _NormallyOpenModePageState extends State<NormallyOpenModePage> {
|
|||||||
child: SubmitBtn(
|
child: SubmitBtn(
|
||||||
btnName: TranslationLoader.lanKeys!.save!.tr,
|
btnName: TranslationLoader.lanKeys!.save!.tr,
|
||||||
onClick: () {
|
onClick: () {
|
||||||
logic.configPassageMode();
|
logic.sendAutoLock();
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -262,9 +262,10 @@ class _NormallyOpenModePageState extends State<NormallyOpenModePage> {
|
|||||||
action: () {
|
action: () {
|
||||||
Pickers.showDatePicker(context, mode: DateMode.HM,
|
Pickers.showDatePicker(context, mode: DateMode.HM,
|
||||||
onConfirm: (p) {
|
onConfirm: (p) {
|
||||||
state.beginTimeMinute.value = p.hour!*60 + p.minute!;
|
setState(() {
|
||||||
state.beginTime.value = "${p.hour}:${p.minute!}";
|
state.beginTimeMinute.value = p.hour!*60 + p.minute!;
|
||||||
setState(() {});
|
state.beginTime.value = "${p.hour}:${p.minute!}";
|
||||||
|
});
|
||||||
});
|
});
|
||||||
})),
|
})),
|
||||||
Obx(() => CommonItem(
|
Obx(() => CommonItem(
|
||||||
@ -275,9 +276,10 @@ class _NormallyOpenModePageState extends State<NormallyOpenModePage> {
|
|||||||
action: () {
|
action: () {
|
||||||
Pickers.showDatePicker(context, mode: DateMode.HM,
|
Pickers.showDatePicker(context, mode: DateMode.HM,
|
||||||
onConfirm: (p) {
|
onConfirm: (p) {
|
||||||
state.endTimeMinute.value = p.hour!*60 + p.minute!;
|
setState(() {
|
||||||
state.endTime.value = "${p.hour}:${p.minute!}";
|
state.endTimeMinute.value = p.hour!*60 + p.minute!;
|
||||||
setState(() {});
|
state.endTime.value = "${p.hour}:${p.minute!}";
|
||||||
|
});
|
||||||
});
|
});
|
||||||
})),
|
})),
|
||||||
Container(height: 10.h),
|
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/baseGetXController.dart';
|
||||||
import 'package:star_lock/tools/toast.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/io_tool/manager_event_bus.dart';
|
||||||
|
import '../../../../blue/sender_manage.dart';
|
||||||
import '../../../../network/api_repository.dart';
|
import '../../../../network/api_repository.dart';
|
||||||
import '../../../../tools/eventBusEventManage.dart';
|
import '../../../../tools/eventBusEventManage.dart';
|
||||||
|
import '../../../../tools/storage.dart';
|
||||||
import 'remoteUnlocking_state.dart';
|
import 'remoteUnlocking_state.dart';
|
||||||
|
|
||||||
class RemoteUnlockingLogic extends BaseGetXController{
|
class RemoteUnlockingLogic extends BaseGetXController{
|
||||||
RemoteUnlockingState state = RemoteUnlockingState();
|
RemoteUnlockingState state = RemoteUnlockingState();
|
||||||
|
|
||||||
void remoteUnlockingOpenOrClose() async{
|
void _remoteUnlockingOpenOrClose() async{
|
||||||
var entity = await ApiRepository.to.remoteUnlockingOpenOrClose(
|
var entity = await ApiRepository.to.remoteUnlockingOpenOrClose(
|
||||||
lockId: state.getKeyInfosData.value.lockId.toString(),
|
lockId: state.getKeyInfosData.value.lockId.toString(),
|
||||||
// featureValue:state.getKeyInfosData.value.featureValue.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
|
@override
|
||||||
void onReady() {
|
void onReady() {
|
||||||
// TODO: implement onReady
|
// TODO: implement onReady
|
||||||
super.onReady();
|
super.onReady();
|
||||||
print("onReady()");
|
print("onReady()");
|
||||||
|
|
||||||
|
_initReplySubscription();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -41,11 +181,15 @@ class RemoteUnlockingLogic extends BaseGetXController{
|
|||||||
// TODO: implement onInit
|
// TODO: implement onInit
|
||||||
super.onInit();
|
super.onInit();
|
||||||
print("onInit()");
|
print("onInit()");
|
||||||
|
|
||||||
|
_readSupportFunctionsNoParameters();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onClose() {
|
void onClose() {
|
||||||
// TODO: implement onClose
|
// TODO: implement onClose
|
||||||
|
super.onClose();
|
||||||
|
_replySubscription.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -65,7 +65,7 @@ class _RemoteUnlockingPageState extends State<RemoteUnlockingPage> {
|
|||||||
Obx(() => SubmitBtn(
|
Obx(() => SubmitBtn(
|
||||||
btnName: state.remoteEnable.value == 1 ?TranslationLoader.lanKeys!.close!.tr: TranslationLoader.lanKeys!.open!.tr,
|
btnName: state.remoteEnable.value == 1 ?TranslationLoader.lanKeys!.close!.tr: TranslationLoader.lanKeys!.open!.tr,
|
||||||
onClick: () {
|
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/main/lockDetail/lcokSet/resetButton/resetButton_state.dart';
|
||||||
import 'package:star_lock/tools/baseGetXController.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 '../../../../network/api_repository.dart';
|
||||||
import '../../../../tools/eventBusEventManage.dart';
|
import '../../../../tools/eventBusEventManage.dart';
|
||||||
|
import '../../../../tools/storage.dart';
|
||||||
import '../../../../tools/toast.dart';
|
import '../../../../tools/toast.dart';
|
||||||
|
|
||||||
class ResetButtonLogic extends BaseGetXController{
|
class ResetButtonLogic extends BaseGetXController{
|
||||||
ResetButtonState state = ResetButtonState();
|
ResetButtonState state = ResetButtonState();
|
||||||
|
|
||||||
|
|
||||||
// 配置锁的常开模式设置 -> 重置开关
|
// 配置锁的常开模式设置 -> 重置开关
|
||||||
Future<void> setLockSetGeneralSetting() async{
|
Future<void> _setLockSetGeneralSetting() async{
|
||||||
var entity = await ApiRepository.to.setLockSetGeneralSettingData(
|
var entity = await ApiRepository.to.setLockSetGeneralSettingData(
|
||||||
lockId: state.getKeyInfosData.value.lockId.toString(),
|
lockId: state.getKeyInfosData.value.lockId.toString(),
|
||||||
changeType:"1",
|
changeType:"1",
|
||||||
@ -27,4 +38,156 @@ class ResetButtonLogic extends BaseGetXController{
|
|||||||
Toast.show(msg: "操作成功");
|
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),
|
// margin: EdgeInsets.only(left: 03.w, right: 30.w, top: 20.w),
|
||||||
padding: EdgeInsets.only(top: 20.w, bottom: 20.w),
|
padding: EdgeInsets.only(top: 20.w, bottom: 20.w),
|
||||||
onClick: () {
|
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 'package:star_lock/blue/io_type.dart';
|
||||||
|
|
||||||
import '../../../blue/blue_manage.dart';
|
import '../../../blue/blue_manage.dart';
|
||||||
|
import '../../../blue/io_protocol/io_getStarLockStatusInfo.dart';
|
||||||
import '../../../blue/io_protocol/io_openLock.dart';
|
import '../../../blue/io_protocol/io_openLock.dart';
|
||||||
import '../../../blue/io_reply.dart';
|
import '../../../blue/io_reply.dart';
|
||||||
import '../../../blue/io_tool/io_manager.dart';
|
import '../../../blue/io_tool/io_manager.dart';
|
||||||
@ -48,6 +49,11 @@ class LockDetailLogic extends BaseGetXController{
|
|||||||
if(reply is FactoryDataResetReply){
|
if(reply is FactoryDataResetReply){
|
||||||
_replyFactoryDataResetKey(reply);
|
_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 {
|
Future<void> openDoorAction() async {
|
||||||
BlueManage().judgeReconnect(state.keyInfos.value.bluetooth!.bluetoothDeviceId!, state.keyInfos.value.bluetooth!.bluetoothDeviceName!, (DeviceConnectionState state) 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){
|
if (state == DeviceConnectionState.connected){
|
||||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||||
IoSenderManage.senderGetLockStatu(
|
// IoSenderManage.senderGetLockStatu(
|
||||||
|
// lockID:BlueManage().connectDeviceName,
|
||||||
|
// userID:await Storage.getUid(),
|
||||||
|
// privateKey:getPrivateKeyList,
|
||||||
|
// );
|
||||||
|
IoSenderManage.senderGetStarLockStatuInfo(
|
||||||
lockID:BlueManage().connectDeviceName,
|
lockID:BlueManage().connectDeviceName,
|
||||||
userID:await Storage.getUid(),
|
userID:await Storage.getUid(),
|
||||||
privateKey:getPrivateKeyList,
|
privateKey:getPrivateKeyList,
|
||||||
@ -417,9 +510,9 @@ class LockDetailLogic extends BaseGetXController{
|
|||||||
print("onReady()");
|
print("onReady()");
|
||||||
_initReplySubscription();
|
_initReplySubscription();
|
||||||
|
|
||||||
BlueManage().startScan((v){
|
// BlueManage().startScan((v){
|
||||||
|
//
|
||||||
});
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -430,6 +523,7 @@ class LockDetailLogic extends BaseGetXController{
|
|||||||
|
|
||||||
// 进来获取锁状态
|
// 进来获取锁状态
|
||||||
// connectBlue();
|
// connectBlue();
|
||||||
|
// factoryDataResetAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@ -63,7 +63,7 @@ class _LockDetailPageState extends State<LockDetailPage> with RouteAware {
|
|||||||
Storage.setStringList(saveBlueSignKey, saveSignKeyList);
|
Storage.setStringList(saveBlueSignKey, saveSignKeyList);
|
||||||
// print("publicKeyData:$publicKeyData saveStrList:$saveStrList privateKeyData:$privateKeyData savePrivateKeyList:$savePrivateKeyList");
|
// print("publicKeyData:$publicKeyData saveStrList:$saveStrList privateKeyData:$privateKeyData savePrivateKeyList:$savePrivateKeyList");
|
||||||
|
|
||||||
// logic.connectBlue();
|
logic.connectBlue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import 'package:star_lock/blue/io_type.dart';
|
|||||||
|
|
||||||
import '../../../../../blue/blue_manage.dart';
|
import '../../../../../blue/blue_manage.dart';
|
||||||
import '../../../../../blue/io_protocol/io_addFingerprint.dart';
|
import '../../../../../blue/io_protocol/io_addFingerprint.dart';
|
||||||
|
import '../../../../../blue/io_protocol/io_addStressFingerprint.dart';
|
||||||
import '../../../../../blue/io_reply.dart';
|
import '../../../../../blue/io_reply.dart';
|
||||||
import '../../../../../blue/io_tool/io_manager.dart';
|
import '../../../../../blue/io_tool/io_manager.dart';
|
||||||
import '../../../../../blue/io_tool/io_tool.dart';
|
import '../../../../../blue/io_tool/io_tool.dart';
|
||||||
@ -40,6 +41,11 @@ class AddFingerprintLogic extends BaseGetXController {
|
|||||||
if(reply is SenderAddFingerprintConfirmationReply) {
|
if(reply is SenderAddFingerprintConfirmationReply) {
|
||||||
_replyAddFingerprintConfirmation(reply);
|
_replyAddFingerprintConfirmation(reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 添加胁迫指纹
|
||||||
|
if(reply is SenderAddStressFingerprintReply) {
|
||||||
|
_replyAddStressFingerprint(reply);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,8 +118,15 @@ class AddFingerprintLogic extends BaseGetXController {
|
|||||||
case 0x00:
|
case 0x00:
|
||||||
//成功
|
//成功
|
||||||
print("${reply.commandType!.typeValue} 数据解析成功");
|
print("${reply.commandType!.typeValue} 数据解析成功");
|
||||||
state.addFingerprintProcessNumber.value++;
|
if(reply.data[5] == 255){
|
||||||
print("state.addFingerprintProcessNumber.value:${state.addFingerprintProcessNumber.value}");
|
// 注册指纹失败
|
||||||
|
print("${reply.commandType!.typeValue} 注册指纹失败");
|
||||||
|
Toast.show(msg: "添加失败");
|
||||||
|
Get.close(3);
|
||||||
|
}else{
|
||||||
|
state.addFingerprintProcessNumber.value++;
|
||||||
|
print("state.addFingerprintProcessNumber.value:${state.addFingerprintProcessNumber.value}");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 0x06:
|
case 0x06:
|
||||||
//需要权限
|
//需要权限
|
||||||
@ -138,10 +151,10 @@ class AddFingerprintLogic extends BaseGetXController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _replyAddFingerprintConfirmation(Reply reply) async {
|
Future<void> _replyAddFingerprintConfirmation(Reply reply) async {
|
||||||
var token = reply.data.sublist(2, 6);
|
// var token = reply.data.sublist(2, 6);
|
||||||
var saveStrList = changeIntListToStringList(token);
|
// var saveStrList = changeIntListToStringList(token);
|
||||||
print("_replyAddFingerprintReplyToken:$token");
|
// print("_replyAddFingerprintReplyToken:$token");
|
||||||
Storage.setStringList(saveBlueToken, saveStrList);
|
// Storage.setStringList(saveBlueToken, saveStrList);
|
||||||
|
|
||||||
int status = reply.data[2];
|
int status = reply.data[2];
|
||||||
print("status:$status");
|
print("status:$status");
|
||||||
@ -151,7 +164,13 @@ class AddFingerprintLogic extends BaseGetXController {
|
|||||||
//成功
|
//成功
|
||||||
print("${reply.commandType!.typeValue} 数据解析成功");
|
print("${reply.commandType!.typeValue} 数据解析成功");
|
||||||
// print("添加指纹确认成功,调用添加指纹接口");
|
// print("添加指纹确认成功,调用添加指纹接口");
|
||||||
addFingerprintsData();
|
if(state.isCoerced.value == "1"){
|
||||||
|
// 非胁迫指纹
|
||||||
|
addFingerprintsData();
|
||||||
|
}else{
|
||||||
|
// 如果是胁迫指纹在 添加完之后以后再调用添加胁迫指纹的
|
||||||
|
senderAddStressFingerprint();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 0x06:
|
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 {
|
Future<void> senderAddFingerprint() async {
|
||||||
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) 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{
|
void addFingerprintsData() async{
|
||||||
var entity = await ApiRepository.to.addFingerprintsData(
|
var entity = await ApiRepository.to.addFingerprintsData(
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import 'package:star_lock/tools/baseGetXController.dart';
|
|||||||
|
|
||||||
import '../../../../blue/blue_manage.dart';
|
import '../../../../blue/blue_manage.dart';
|
||||||
import '../../../../blue/io_protocol/io_addICCard.dart';
|
import '../../../../blue/io_protocol/io_addICCard.dart';
|
||||||
|
import '../../../../blue/io_protocol/io_addStressICCard.dart';
|
||||||
import '../../../../blue/io_reply.dart';
|
import '../../../../blue/io_reply.dart';
|
||||||
import '../../../../blue/io_tool/io_manager.dart';
|
import '../../../../blue/io_tool/io_manager.dart';
|
||||||
import '../../../../blue/io_tool/io_tool.dart';
|
import '../../../../blue/io_tool/io_tool.dart';
|
||||||
@ -35,6 +36,11 @@ class AddICCardLogic extends BaseGetXController{
|
|||||||
if(reply is SenderAddICCardConfirmationReply) {
|
if(reply is SenderAddICCardConfirmationReply) {
|
||||||
_replyAddICCardConfirmation(reply);
|
_replyAddICCardConfirmation(reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 添加胁迫卡
|
||||||
|
if(reply is SenderAddStressICCardReply) {
|
||||||
|
_replyAddICStressCard(reply);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,6 +109,50 @@ class AddICCardLogic extends BaseGetXController{
|
|||||||
int status = reply.data[2];
|
int status = reply.data[2];
|
||||||
print("_replyAddFingerprintstatus:$status");
|
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){
|
switch(status){
|
||||||
case 0x00:
|
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 {
|
void addICCardData() async {
|
||||||
var entity = await ApiRepository.to.addICCardData(
|
var entity = await ApiRepository.to.addICCardData(
|
||||||
lockId: state.lockId.value.toString(),
|
lockId: state.lockId.value.toString(),
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
|
|
||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
@ -10,6 +9,7 @@ import '../../../appRouters.dart';
|
|||||||
import '../../../blue/blue_manage.dart';
|
import '../../../blue/blue_manage.dart';
|
||||||
import '../../../blue/io_protocol/io_addUser.dart';
|
import '../../../blue/io_protocol/io_addUser.dart';
|
||||||
import '../../../blue/io_protocol/io_getLockStatu.dart';
|
import '../../../blue/io_protocol/io_getLockStatu.dart';
|
||||||
|
import '../../../blue/io_protocol/io_getStarLockStatusInfo.dart';
|
||||||
import '../../../blue/io_reply.dart';
|
import '../../../blue/io_reply.dart';
|
||||||
import '../../../blue/io_tool/io_manager.dart';
|
import '../../../blue/io_tool/io_manager.dart';
|
||||||
import '../../../blue/io_tool/io_tool.dart';
|
import '../../../blue/io_tool/io_tool.dart';
|
||||||
@ -38,6 +38,12 @@ class SaveLockLogic extends BaseGetXController {
|
|||||||
if(reply is GetLockStatuReply) {
|
if(reply is GetLockStatuReply) {
|
||||||
_replyGetLockStatus(reply);
|
_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(){
|
saveLockAction(){
|
||||||
addUserConnectBlue();
|
addUserConnectBlue();
|
||||||
@ -224,7 +312,8 @@ class SaveLockLogic extends BaseGetXController {
|
|||||||
void bindBlueAdmin() async{
|
void bindBlueAdmin() async{
|
||||||
var lockDataMap = {};
|
var lockDataMap = {};
|
||||||
lockDataMap['lockName'] = BlueManage().connectDeviceName;
|
lockDataMap['lockName'] = BlueManage().connectDeviceName;
|
||||||
lockDataMap['lockMac'] = BlueManage().connectDeviceMacAddress;
|
lockDataMap['lockMac'] = "AB:C1:40:61:54:61";
|
||||||
|
// lockDataMap['lockMac'] = BlueManage().connectDeviceMacAddress;
|
||||||
|
|
||||||
var positionMap = {};
|
var positionMap = {};
|
||||||
positionMap['longitude'] = state.addressMap["longitude"];
|
positionMap['longitude'] = state.addressMap["longitude"];
|
||||||
@ -281,7 +370,12 @@ class SaveLockLogic extends BaseGetXController {
|
|||||||
if (state == DeviceConnectionState.connected) {
|
if (state == DeviceConnectionState.connected) {
|
||||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||||
IoSenderManage.senderGetLockStatu(
|
// IoSenderManage.senderGetLockStatu(
|
||||||
|
// lockID:BlueManage().connectDeviceName,
|
||||||
|
// userID:await Storage.getUid(),
|
||||||
|
// privateKey:getPrivateKeyList,
|
||||||
|
// );
|
||||||
|
IoSenderManage.senderGetStarLockStatuInfo(
|
||||||
lockID:BlueManage().connectDeviceName,
|
lockID:BlueManage().connectDeviceName,
|
||||||
userID:await Storage.getUid(),
|
userID:await Storage.getUid(),
|
||||||
privateKey:getPrivateKeyList,
|
privateKey:getPrivateKeyList,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user