Merge branch 'master' of gitee.com:starlock-cn/app-starlock
This commit is contained in:
commit
5f0840a9f3
@ -375,7 +375,6 @@ class BlueManage {
|
|||||||
// AppLog.log('bluetoothConnectDevice: $bluetoothConnectDevice');
|
// AppLog.log('bluetoothConnectDevice: $bluetoothConnectDevice');
|
||||||
scanResult = devicesList[knownDeviceIndex];
|
scanResult = devicesList[knownDeviceIndex];
|
||||||
|
|
||||||
|
|
||||||
_initGetMtuSubscription();
|
_initGetMtuSubscription();
|
||||||
_initListenConnectionState();
|
_initListenConnectionState();
|
||||||
}
|
}
|
||||||
@ -478,7 +477,7 @@ class BlueManage {
|
|||||||
// 当包有头时
|
// 当包有头时
|
||||||
// 判断是否需要分包
|
// 判断是否需要分包
|
||||||
dataLen = data[8] * 256 + data[9]; // 高16位用来指示后面数据块内容的长度
|
dataLen = data[8] * 256 + data[9]; // 高16位用来指示后面数据块内容的长度
|
||||||
// AppLog.log("dataLen1111:$dataLen getDataLength:${data.length} data:$data");
|
AppLog.log("dataLen1111:$dataLen getDataLength:${data.length} data:$data");
|
||||||
if (dataLen! + 14 > data.length) {
|
if (dataLen! + 14 > data.length) {
|
||||||
// 当前包的长度小于实际的包时 分包添加 不解析
|
// 当前包的长度小于实际的包时 分包添加 不解析
|
||||||
allData.addAll(data);
|
allData.addAll(data);
|
||||||
@ -494,8 +493,9 @@ class BlueManage {
|
|||||||
// 当包没有头时 是分包的包 直接添加
|
// 当包没有头时 是分包的包 直接添加
|
||||||
allData.addAll(data);
|
allData.addAll(data);
|
||||||
// var len = allData[8] * 256 + allData[9];
|
// var len = allData[8] * 256 + allData[9];
|
||||||
AppLog.log("dataLen3333:$dataLen allData.length:${allData.length} allData:$allData");
|
AppLog.log(
|
||||||
if ((dataLen! + 14) <= allData.length) {
|
"dataLen3333:$dataLen allData.length:${allData.length} allData:$allData");
|
||||||
|
if (((dataLen ?? 0) + 14) <= allData.length) {
|
||||||
// 当长度小于等于当前包的数据时 直接解析数据
|
// 当长度小于等于当前包的数据时 直接解析数据
|
||||||
CommandReciverManager.appDataReceive(allData);
|
CommandReciverManager.appDataReceive(allData);
|
||||||
// 发送完解析初始化数组
|
// 发送完解析初始化数组
|
||||||
|
|||||||
@ -34,8 +34,8 @@ abstract class SenderProtocol extends IOData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void printLog(List<int> data) {
|
void printLog(List<int> data) {
|
||||||
AppLog.log(
|
// AppLog.log(
|
||||||
"App -> 锁,指令类型:${commandType!.typeName} \n参数是:\n${toString()} \n加密之前数据是:\n$data 长度是:${data.length}");
|
// "App -> 锁,指令类型:${commandType!.typeName} \n参数是:\n${toString()} \n加密之前数据是:\n$data 长度是:${data.length}");
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO:拼装数据Ï
|
//TODO:拼装数据Ï
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import 'package:star_lock/app_settings/app_settings.dart';
|
|||||||
import 'package:star_lock/blue/blue_manage.dart';
|
import 'package:star_lock/blue/blue_manage.dart';
|
||||||
import 'package:star_lock/blue/io_protocol/io_addFace.dart';
|
import 'package:star_lock/blue/io_protocol/io_addFace.dart';
|
||||||
import 'package:star_lock/blue/io_protocol/io_changeAdministratorPassword.dart';
|
import 'package:star_lock/blue/io_protocol/io_changeAdministratorPassword.dart';
|
||||||
|
import 'package:star_lock/blue/io_protocol/io_cleanUpUsers.dart';
|
||||||
import 'package:star_lock/blue/io_protocol/io_deletUser.dart';
|
import 'package:star_lock/blue/io_protocol/io_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';
|
||||||
@ -107,8 +108,11 @@ class CommandReciverManager {
|
|||||||
AppLog.log("APP收到的解密后的数据:$oriDataList");
|
AppLog.log("APP收到的解密后的数据:$oriDataList");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
parseData(oriDataList).then((value) async {
|
parseData(oriDataList).then((Reply? value) async {
|
||||||
EasyLoading.dismiss();
|
EasyLoading.dismiss();
|
||||||
|
if (value != null) {
|
||||||
|
AppLog.log("锁 -> App,指令订阅类型 :${value.commandType?.typeName} \n $value");
|
||||||
|
}
|
||||||
await EventBusManager().eventBusFir(value);
|
await EventBusManager().eventBusFir(value);
|
||||||
}).catchError((error) {
|
}).catchError((error) {
|
||||||
AppLog.log("APP解析数据时发生错误: $error");
|
AppLog.log("APP解析数据时发生错误: $error");
|
||||||
@ -195,6 +199,11 @@ class CommandReciverManager {
|
|||||||
reply = ProcessOtaUpgradeReply.parseData(commandType, data);
|
reply = ProcessOtaUpgradeReply.parseData(commandType, data);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case CommandType.cleanUpUsers:
|
||||||
|
{
|
||||||
|
reply = CleanUpUsersReply.parseData(commandType, data);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case CommandType.generalExtendedCommond:
|
case CommandType.generalExtendedCommond:
|
||||||
{
|
{
|
||||||
// 子命令类型
|
// 子命令类型
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import 'dart:async';
|
|||||||
|
|
||||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
import 'package:star_lock/blue/io_protocol/io_cleanUpUsers.dart';
|
||||||
import 'package:star_lock/blue/sender_manage.dart';
|
import 'package:star_lock/blue/sender_manage.dart';
|
||||||
import 'package:star_lock/main/lockMian/entity/lockListInfo_entity.dart';
|
import 'package:star_lock/main/lockMian/entity/lockListInfo_entity.dart';
|
||||||
import 'package:star_lock/network/api_provider.dart';
|
import 'package:star_lock/network/api_provider.dart';
|
||||||
@ -19,6 +20,7 @@ import 'io_protocol/io_addUser.dart';
|
|||||||
import 'io_reply.dart';
|
import 'io_reply.dart';
|
||||||
import 'io_tool/io_tool.dart';
|
import 'io_tool/io_tool.dart';
|
||||||
import 'io_tool/manager_event_bus.dart';
|
import 'io_tool/manager_event_bus.dart';
|
||||||
|
import 'sender_data.dart';
|
||||||
|
|
||||||
class SenderBeforeDataManage {
|
class SenderBeforeDataManage {
|
||||||
static SenderBeforeDataManage? _manager;
|
static SenderBeforeDataManage? _manager;
|
||||||
@ -46,9 +48,13 @@ class SenderBeforeDataManage {
|
|||||||
_replySubscription ??=
|
_replySubscription ??=
|
||||||
EventBusManager().eventBus!.on<Reply>().listen((reply) async {
|
EventBusManager().eventBus!.on<Reply>().listen((reply) async {
|
||||||
// 添加用户
|
// 添加用户
|
||||||
if ((reply is AddUserReply)) {
|
if (reply is AddUserReply) {
|
||||||
_replyAddUserKey(reply);
|
_replyAddUserKey(reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(reply is CleanUpUsersReply){
|
||||||
|
_cleanUpUsersReply(reply);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,8 +95,7 @@ class SenderBeforeDataManage {
|
|||||||
// publicKey: publicKeyDataList,
|
// publicKey: publicKeyDataList,
|
||||||
// privateKey: getPrivateKeyList,
|
// privateKey: getPrivateKeyList,
|
||||||
// token: token);
|
// token: token);
|
||||||
LockListInfoItemEntity currentKeyInfo =
|
LockListInfoItemEntity currentKeyInfo = CommonDataManage().currentKeyInfo;
|
||||||
CommonDataManage().currentKeyInfo;
|
|
||||||
AppLog.log(
|
AppLog.log(
|
||||||
"startDate111:${currentKeyInfo.startDate} endDate:${currentKeyInfo.endDate}");
|
"startDate111:${currentKeyInfo.startDate} endDate:${currentKeyInfo.endDate}");
|
||||||
DateTime startTime = DateTime.fromMillisecondsSinceEpoch(
|
DateTime startTime = DateTime.fromMillisecondsSinceEpoch(
|
||||||
@ -104,7 +109,7 @@ class SenderBeforeDataManage {
|
|||||||
keyID: currentKeyInfo.keyId.toString(),
|
keyID: currentKeyInfo.keyId.toString(),
|
||||||
userID: await Storage.getUid(),
|
userID: await Storage.getUid(),
|
||||||
openMode: 1,
|
openMode: 1,
|
||||||
keyType: 0,
|
keyType: currentKeyInfo.keyType,
|
||||||
startDate: currentKeyInfo.startDate! ~/ 1000,
|
startDate: currentKeyInfo.startDate! ~/ 1000,
|
||||||
expireDate: currentKeyInfo.endDate! ~/ 1000,
|
expireDate: currentKeyInfo.endDate! ~/ 1000,
|
||||||
useCountLimit: 0xFFFF,
|
useCountLimit: 0xFFFF,
|
||||||
@ -144,22 +149,30 @@ class SenderBeforeDataManage {
|
|||||||
List<int> tokenList = changeStringListToIntList(tokenKey!);
|
List<int> tokenList = changeStringListToIntList(tokenKey!);
|
||||||
AppLog.log('---> ${entity.data?.userNos}');
|
AppLog.log('---> ${entity.data?.userNos}');
|
||||||
|
|
||||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
var cleanUpUsersData = CleanUpUsersCommand(
|
||||||
(BluetoothConnectionState connectionState) async {
|
lockID: BlueManage().connectDeviceName,
|
||||||
if (connectionState == BluetoothConnectionState.connected) {
|
authUserID: CommonDataManage().currentKeyInfo.senderUserId!.toString(),
|
||||||
IoSenderManage.senderCleanUpUsersCommand(
|
keyID: CommonDataManage().currentKeyInfo.keyId.toString(),
|
||||||
lockID: BlueManage().connectDeviceName,
|
userID: await Storage.getUid(),
|
||||||
authUserID:
|
needAuthor: 1,
|
||||||
CommonDataManage().currentKeyInfo.senderUserId!.toString(),
|
publicKey: publicKeyDataList,
|
||||||
keyID: CommonDataManage().currentKeyInfo.keyId.toString(),
|
privateKey: getPrivateKeyList,
|
||||||
userID: await Storage.getUid(),
|
userNoList: entity.data!.userNos!,
|
||||||
userNoList: entity.data!.userNos!,
|
token: tokenList,
|
||||||
needAuthor: 1,
|
).packageData();
|
||||||
publicKey: publicKeyDataList,
|
CommandSenderManager().sendNormalData(cleanUpUsersData);
|
||||||
privateKey: getPrivateKeyList,
|
|
||||||
token: tokenList);
|
// IoSenderManage.senderCleanUpUsersCommand(
|
||||||
}
|
// lockID: BlueManage().connectDeviceName,
|
||||||
});
|
// authUserID:
|
||||||
|
// CommonDataManage().currentKeyInfo.senderUserId!.toString(),
|
||||||
|
// keyID: CommonDataManage().currentKeyInfo.keyId.toString(),
|
||||||
|
// userID: await Storage.getUid(),
|
||||||
|
// userNoList: entity.data!.userNos!,
|
||||||
|
// needAuthor: 1,
|
||||||
|
// publicKey: publicKeyDataList,
|
||||||
|
// privateKey: getPrivateKeyList,
|
||||||
|
// token: tokenList);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -168,18 +181,47 @@ class SenderBeforeDataManage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 清理用户
|
||||||
|
Future<void> _cleanUpUsersReply(Reply reply) async {
|
||||||
|
int status = reply.data[6];
|
||||||
|
switch (status) {
|
||||||
|
case 0x00:
|
||||||
|
//成功
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 0x06:
|
||||||
|
//无权限
|
||||||
|
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
|
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||||
|
|
||||||
|
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||||
|
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||||
|
|
||||||
|
var token = reply.data.sublist(42, 46);
|
||||||
|
List<String> strTokenList = changeIntListToStringList(token);
|
||||||
|
Storage.setStringList(saveBlueToken, strTokenList);
|
||||||
|
|
||||||
|
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
//失败
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<List<int>> getAddUserKeyData() async {
|
Future<List<int>> getAddUserKeyData() async {
|
||||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||||
|
|
||||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||||
|
|
||||||
var token = await Storage.getStringList(saveBlueToken);
|
var token = await Storage.getStringList(saveBlueToken);
|
||||||
List<int> getTokenList = changeStringListToIntList(token!);
|
List<int> getTokenList = changeStringListToIntList(token!);
|
||||||
|
|
||||||
LockListInfoItemEntity currentKeyInfo = CommonDataManage().currentKeyInfo;
|
LockListInfoItemEntity currentKeyInfo = CommonDataManage().currentKeyInfo;
|
||||||
DateTime startTime =
|
DateTime startTime = DateTime.fromMillisecondsSinceEpoch(currentKeyInfo.startDate! ~/ 1000);
|
||||||
DateTime.fromMillisecondsSinceEpoch(currentKeyInfo.startDate! ~/ 1000);
|
DateTime endTime = DateTime.fromMillisecondsSinceEpoch(currentKeyInfo.endDate! ~/ 1000);
|
||||||
DateTime endTime =
|
|
||||||
DateTime.fromMillisecondsSinceEpoch(currentKeyInfo.endDate! ~/ 1000);
|
|
||||||
bool isRound = currentKeyInfo.keyType == 2;
|
bool isRound = currentKeyInfo.keyType == 2;
|
||||||
|
|
||||||
var addUserData = AddUserCommand(
|
var addUserData = AddUserCommand(
|
||||||
@ -188,7 +230,7 @@ class SenderBeforeDataManage {
|
|||||||
keyID: currentKeyInfo.keyId.toString(),
|
keyID: currentKeyInfo.keyId.toString(),
|
||||||
userID: await Storage.getUid(),
|
userID: await Storage.getUid(),
|
||||||
openMode: 1,
|
openMode: 1,
|
||||||
keyType: 0,
|
keyType: currentKeyInfo.keyType,
|
||||||
startDate: currentKeyInfo.startDate! ~/ 1000,
|
startDate: currentKeyInfo.startDate! ~/ 1000,
|
||||||
expireDate: currentKeyInfo.endDate! ~/ 1000,
|
expireDate: currentKeyInfo.endDate! ~/ 1000,
|
||||||
useCountLimit: 0xFFFF,
|
useCountLimit: 0xFFFF,
|
||||||
|
|||||||
@ -32,12 +32,11 @@ class CommandSenderManager {
|
|||||||
|
|
||||||
void initLockAddUserSucceedEvent() {
|
void initLockAddUserSucceedEvent() {
|
||||||
// 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus
|
// 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus
|
||||||
_passCurrentLockInformationEvent =
|
_passCurrentLockInformationEvent = eventBus.on<LockAddUserSucceedEvent>().listen((event) {
|
||||||
eventBus.on<LockAddUserSucceedEvent>().listen((event) {
|
|
||||||
if (event.type == 0) {
|
if (event.type == 0) {
|
||||||
_sendNormalData(dataBeforeAddTheUser);
|
sendNormalData(dataBeforeAddTheUser);
|
||||||
} else {
|
} else {
|
||||||
_sendNormalData(event.dataList);
|
sendNormalData(event.dataList);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -58,21 +57,22 @@ class CommandSenderManager {
|
|||||||
|
|
||||||
List<int> value = command.packageData();
|
List<int> value = command.packageData();
|
||||||
if (isBeforeAddUser == true) {
|
if (isBeforeAddUser == true) {
|
||||||
_sendNormalData(value);
|
// 如果是添加用户之前调用协议 直接发送
|
||||||
|
sendNormalData(value);
|
||||||
} else {
|
} else {
|
||||||
|
// 添加用户之后调用协议就要判断是否添加用户
|
||||||
if (CommonDataManage().currentLockUserNo == 0) {
|
if (CommonDataManage().currentLockUserNo == 0) {
|
||||||
// 先添加用户
|
// 如果LockUserNo为0,先添加用户
|
||||||
var entity = await SenderBeforeDataManage().getAddUserKeyData();
|
var entity = await SenderBeforeDataManage().getAddUserKeyData();
|
||||||
_sendNormalData(entity);
|
sendNormalData(entity);
|
||||||
dataBeforeAddTheUser = value;
|
dataBeforeAddTheUser = value;
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
_sendNormalData(value);
|
sendNormalData(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _sendNormalData(List<int> data) async {
|
void sendNormalData(List<int> data) async {
|
||||||
if (data.isNotEmpty) {
|
if (data.isNotEmpty) {
|
||||||
EventBusManager().eventBusFir(
|
EventBusManager().eventBusFir(
|
||||||
EventSendModel(data: data, sendChannel: DataChannel.ble));
|
EventSendModel(data: data, sendChannel: DataChannel.ble));
|
||||||
|
|||||||
@ -170,145 +170,158 @@ class NearbyLockLogic extends BaseGetXController {
|
|||||||
int status = reply.data[2];
|
int status = reply.data[2];
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case 0x00:
|
case 0x00:
|
||||||
//成功
|
//成功
|
||||||
AppLog.log("获取锁状态成功");
|
AppLog.log("获取锁状态成功");
|
||||||
// 厂商名称
|
// 厂商名称
|
||||||
var vendor = reply.data.sublist(3, 23);
|
var index = 3;
|
||||||
|
var vendor = reply.data.sublist(index, index + 20);
|
||||||
var vendorStr = utf8String(vendor);
|
var vendorStr = utf8String(vendor);
|
||||||
state.lockInfo["vendor"] = vendorStr;
|
state.lockInfo["vendor"] = vendorStr;
|
||||||
// state.lockInfo["vendor"] = "XL";
|
// state.lockInfo["vendor"] = "XL";
|
||||||
|
index = index + 20;
|
||||||
AppLog.log("厂商名称 vendorStr:$vendorStr");
|
AppLog.log("厂商名称 vendorStr:$vendorStr");
|
||||||
|
|
||||||
// 锁设备类型
|
// 锁设备类型
|
||||||
var product = reply.data[23];
|
var product = reply.data[index];
|
||||||
state.lockInfo["product"] = product;
|
state.lockInfo["product"] = product;
|
||||||
|
index = index + 1;
|
||||||
AppLog.log("锁设备类型 product:$product");
|
AppLog.log("锁设备类型 product:$product");
|
||||||
|
|
||||||
// 产品名称
|
// 产品名称
|
||||||
var model = reply.data.sublist(24, 44);
|
var model = reply.data.sublist(index, index + 20);
|
||||||
var modelStr = utf8String(model);
|
var modelStr = utf8String(model);
|
||||||
state.lockInfo["model"] = modelStr;
|
state.lockInfo["model"] = modelStr;
|
||||||
// state.lockInfo["model"] = "JL-BLE-01";
|
// state.lockInfo["model"] = "JL-BLE-01";
|
||||||
|
index = index + 20;
|
||||||
AppLog.log("产品名称 mmodelStr:$modelStr");
|
AppLog.log("产品名称 mmodelStr:$modelStr");
|
||||||
|
|
||||||
// 软件版本
|
// 软件版本
|
||||||
var fwVersion = reply.data.sublist(44, 64);
|
var fwVersion = reply.data.sublist(index, index+20);
|
||||||
var fwVersionStr = utf8String(fwVersion);
|
var fwVersionStr = utf8String(fwVersion);
|
||||||
state.lockInfo["fwVersion"] = fwVersionStr;
|
state.lockInfo["fwVersion"] = fwVersionStr;
|
||||||
|
index = index + 20;
|
||||||
AppLog.log("软件版本 fwVersionStr:$fwVersionStr");
|
AppLog.log("软件版本 fwVersionStr:$fwVersionStr");
|
||||||
|
|
||||||
// 硬件版本
|
// 硬件版本
|
||||||
var hwVersion = reply.data.sublist(64, 84);
|
var hwVersion = reply.data.sublist(index, index+20);
|
||||||
var hwVersionStr = utf8String(hwVersion);
|
var hwVersionStr = utf8String(hwVersion);
|
||||||
state.lockInfo["hwVersion"] = hwVersionStr;
|
state.lockInfo["hwVersion"] = hwVersionStr;
|
||||||
|
index = index + 20;
|
||||||
AppLog.log("硬件版本 hwVersionStr:$hwVersionStr");
|
AppLog.log("硬件版本 hwVersionStr:$hwVersionStr");
|
||||||
|
|
||||||
// 厂商序列号
|
// 厂商序列号
|
||||||
var serialNum0 = reply.data.sublist(84, 100);
|
var serialNum0 = reply.data.sublist(index, index + 16);
|
||||||
var serialNum0Str = utf8String(serialNum0);
|
var serialNum0Str = utf8String(serialNum0);
|
||||||
state.lockInfo["serialNum0"] = serialNum0Str;
|
state.lockInfo["serialNum0"] = serialNum0Str;
|
||||||
// state.lockInfo["serialNum0"] = "${DateTime.now().millisecondsSinceEpoch ~/ 10}";
|
// state.lockInfo["serialNum0"] = "${DateTime.now().millisecondsSinceEpoch ~/ 10}";
|
||||||
|
index = index + 16;
|
||||||
AppLog.log("厂商序列号 serialNum0Str:${serialNum0Str.length}");
|
AppLog.log("厂商序列号 serialNum0Str:${serialNum0Str.length}");
|
||||||
|
|
||||||
// 成品商序列号
|
// 成品商序列号
|
||||||
var serialNum1 = reply.data.sublist(100, 116);
|
var serialNum1 = reply.data.sublist(index, index + 16);
|
||||||
var serialNum1Str = utf8String(serialNum1);
|
var serialNum1Str = utf8String(serialNum1);
|
||||||
state.lockInfo["serialNum1"] = serialNum1Str;
|
state.lockInfo["serialNum1"] = serialNum1Str;
|
||||||
|
index = index + 16;
|
||||||
AppLog.log("成品商序列号 serialNum1Str:$serialNum1Str");
|
AppLog.log("成品商序列号 serialNum1Str:$serialNum1Str");
|
||||||
|
|
||||||
// 蓝牙名称
|
// 蓝牙名称
|
||||||
var btDeviceName = reply.data.sublist(116, 132);
|
var btDeviceName = reply.data.sublist(index, index + 16);
|
||||||
var btDeviceNameStr = utf8String(btDeviceName);
|
var btDeviceNameStr = utf8String(btDeviceName);
|
||||||
state.lockInfo["btDeviceName"] = btDeviceNameStr;
|
state.lockInfo["btDeviceName"] = btDeviceNameStr;
|
||||||
|
index = index + 16;
|
||||||
AppLog.log("蓝牙名称 btDeviceNameStr:$btDeviceNameStr");
|
AppLog.log("蓝牙名称 btDeviceNameStr:$btDeviceNameStr");
|
||||||
|
|
||||||
// 电池剩余电量
|
// 电池剩余电量
|
||||||
var battRemCap = reply.data[132];
|
var battRemCap = reply.data[index];
|
||||||
state.lockInfo["electricQuantity"] = battRemCap;
|
state.lockInfo["electricQuantity"] = battRemCap;
|
||||||
|
index = index + 1;
|
||||||
AppLog.log("电池剩余电量 battRemCap:$battRemCap");
|
AppLog.log("电池剩余电量 battRemCap:$battRemCap");
|
||||||
|
|
||||||
// 备用电池剩余电量
|
// 备用电池剩余电量
|
||||||
// var battRemCapStandby = reply.data[133];
|
var battRemCapStandby = reply.data[index];
|
||||||
// state.lockInfo["electricQuantityStandby"] = battRemCapStandby;
|
state.lockInfo["electricQuantityStandby"] = battRemCapStandby;
|
||||||
// AppLog.log("电池剩余电量 battRemCap:$battRemCap");
|
index = index + 1;
|
||||||
|
AppLog.log("电池剩余电量 battRemCap:$battRemCap");
|
||||||
|
|
||||||
// 重置次数
|
// 重置次数
|
||||||
var restoreCounter = reply.data.sublist(134, 136);
|
var restoreCounter = reply.data.sublist(index, index + 2);
|
||||||
state.lockInfo["restoreCount"] =
|
state.lockInfo["restoreCount"] = restoreCounter[0] * 256 + restoreCounter[1];
|
||||||
restoreCounter[0] * 256 + restoreCounter[1];
|
index = index + 2;
|
||||||
AppLog.log(
|
AppLog.log("重置次数 restoreCounter:${restoreCounter[0] * 256 + restoreCounter[1]}");
|
||||||
"重置次数 restoreCounter:${restoreCounter[0] * 256 + restoreCounter[1]}");
|
|
||||||
|
|
||||||
// 重置时间
|
// 重置时间
|
||||||
var restoreDate = reply.data.sublist(136, 140);
|
var restoreDate = reply.data.sublist(index, index + 4);
|
||||||
int restoreDateValue = ((0xff & restoreDate[(0)]) << 24 |
|
int restoreDateValue = ((0xff & restoreDate[(0)]) << 24 |
|
||||||
(0xff & restoreDate[1]) << 16 |
|
(0xff & restoreDate[1]) << 16 |
|
||||||
(0xff & restoreDate[2]) << 8 |
|
(0xff & restoreDate[2]) << 8 |
|
||||||
(0xFF & restoreDate[3]));
|
(0xFF & restoreDate[3]));
|
||||||
// String restoreDateStr = DateTool().dateToYMDHNSString(restoreDateValue.toString());
|
// String restoreDateStr = DateTool().dateToYMDHNSString(restoreDateValue.toString());
|
||||||
state.lockInfo["restoreDate"] = restoreDateValue * 1000;
|
state.lockInfo["restoreDate"] = restoreDateValue * 1000;
|
||||||
|
index = index + 4;
|
||||||
AppLog.log("重置时间 restoreDateValue:$restoreDateValue");
|
AppLog.log("重置时间 restoreDateValue:$restoreDateValue");
|
||||||
|
|
||||||
// 主控芯片型号
|
// 主控芯片型号
|
||||||
var icPartNo = reply.data.sublist(140, 150);
|
var icPartNo = reply.data.sublist(index, index + 10);
|
||||||
var icPartNoStr = utf8String(icPartNo);
|
var icPartNoStr = utf8String(icPartNo);
|
||||||
state.lockInfo["icPartNo"] = icPartNoStr;
|
state.lockInfo["icPartNo"] = icPartNoStr;
|
||||||
|
index = index + 10;
|
||||||
AppLog.log("主控芯片型号 icPartNoStr:$icPartNoStr");
|
AppLog.log("主控芯片型号 icPartNoStr:$icPartNoStr");
|
||||||
|
|
||||||
// 有效时间
|
// 有效时间
|
||||||
var indate = reply.data.sublist(150, 154);
|
var indate = reply.data.sublist(index, index + 4);
|
||||||
int indateValue = ((0xff & indate[(0)]) << 24 |
|
int indateValue = ((0xff & indate[(0)]) << 24 |
|
||||||
(0xff & indate[1]) << 16 |
|
(0xff & indate[1]) << 16 |
|
||||||
(0xff & indate[2]) << 8 |
|
(0xff & indate[2]) << 8 |
|
||||||
(0xFF & indate[3]));
|
(0xFF & indate[3]));
|
||||||
// String indateStr = DateTool().dateToYMDHNSString("$indateValue");
|
// String indateStr = DateTool().dateToYMDHNSString("$indateValue");
|
||||||
state.lockInfo["indate"] = indateValue * 1000;
|
state.lockInfo["indate"] = indateValue * 1000;
|
||||||
|
index = index + 4;
|
||||||
AppLog.log("有效时间 indateValue:$indateValue");
|
AppLog.log("有效时间 indateValue:$indateValue");
|
||||||
|
|
||||||
// mac地址
|
// mac地址
|
||||||
var macAddress = reply.data.sublist(154, 174);
|
var macAddress = reply.data.sublist(index, index + 20);
|
||||||
var macAddressStr = utf8String(macAddress);
|
var macAddressStr = utf8String(macAddress);
|
||||||
state.lockInfo["mac"] = macAddressStr;
|
state.lockInfo["mac"] = macAddressStr;
|
||||||
|
index = index + 20;
|
||||||
AppLog.log("mac地址 macAddressStr:$macAddressStr");
|
AppLog.log("mac地址 macAddressStr:$macAddressStr");
|
||||||
|
|
||||||
var index = 174;
|
|
||||||
// 锁特征值字符串长度
|
// 锁特征值字符串长度
|
||||||
var featureValueLength = reply.data[index];
|
var featureValueLength = reply.data[index];
|
||||||
|
index = index + 1;
|
||||||
AppLog.log("锁特征值字符串长度 featureValueLength:$featureValueLength");
|
AppLog.log("锁特征值字符串长度 featureValueLength:$featureValueLength");
|
||||||
|
|
||||||
// 锁特征值说明(本机能支持的功能)
|
// 锁特征值说明(本机能支持的功能)
|
||||||
// 获取到锁给的字符数组
|
// 获取到锁给的字符数组
|
||||||
var featureNetxLength = index + featureValueLength + 1;
|
var featureNetxLength = index + featureValueLength;
|
||||||
if (reply.data.length < featureNetxLength) {
|
if (reply.data.length < featureNetxLength) {
|
||||||
showToast("锁数据异常,请重试");
|
showToast("锁数据异常,请重试");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var featureValue =
|
var featureValue = reply.data.sublist(index, index + featureValueLength);
|
||||||
reply.data.sublist(index + 1, index + featureValueLength + 1);
|
|
||||||
String featureValueStr = asciiString(featureValue);
|
String featureValueStr = asciiString(featureValue);
|
||||||
state.featureValue = featureValueStr;
|
state.featureValue = featureValueStr;
|
||||||
// List allFeatureValueTwoList = charListChangeIntList(featureValue);
|
// List allFeatureValueTwoList = charListChangeIntList(featureValue);
|
||||||
// AppLog.log("featureValueLength:$featureValueLength featureValue:$featureValue \n featureValueStr:$featureValueStr");
|
// AppLog.log("featureValueLength:$featureValueLength featureValue:$featureValue \n featureValueStr:$featureValueStr");
|
||||||
index = index + featureValueLength + 1;
|
index = index + featureValueLength;
|
||||||
AppLog.log("锁特征值字符串 featureValueStr:$featureValueStr");
|
AppLog.log("锁特征值字符串 featureValueStr:$featureValueStr");
|
||||||
|
|
||||||
// 使能特征值字符串长度
|
// 使能特征值字符串长度
|
||||||
var featureEnValLength = reply.data[index];
|
var featureEnValLength = reply.data[index];
|
||||||
|
index = index + 1;
|
||||||
AppLog.log("使能特征值字符串长度 featureEnValLength:$featureEnValLength");
|
AppLog.log("使能特征值字符串长度 featureEnValLength:$featureEnValLength");
|
||||||
|
|
||||||
// 使能锁特征值说明(本机启用的功能)
|
// 使能锁特征值说明(本机启用的功能)
|
||||||
var featureEnNextLength = index + featureEnValLength + 1;
|
var featureEnNextLength = index + featureEnValLength;
|
||||||
if (reply.data.length < featureEnNextLength) {
|
if (reply.data.length < featureEnNextLength) {
|
||||||
showToast("锁数据异常,请重试");
|
showToast("锁数据异常,请重试");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var featureEnVal =
|
var featureEnVal = reply.data.sublist(index, index + featureEnValLength);
|
||||||
reply.data.sublist(index + 1, index + featureEnValLength + 1);
|
|
||||||
String featureEnValStr = asciiString(featureEnVal);
|
String featureEnValStr = asciiString(featureEnVal);
|
||||||
state.featureSettingValue = featureEnValStr;
|
state.featureSettingValue = featureEnValStr;
|
||||||
// List allFeatureEnValTwoList = charListChangeIntList(featureEnVal);
|
// List allFeatureEnValTwoList = charListChangeIntList(featureEnVal);
|
||||||
// AppLog.log("featureEnValLength:$featureEnValLength featureEnVal:$featureEnVal \n featureEnValStr:$featureEnValStr");
|
// AppLog.log("featureEnValLength:$featureEnValLength featureEnVal:$featureEnVal \n featureEnValStr:$featureEnValStr");
|
||||||
index = index + featureEnValLength + 1;
|
index = index + featureEnValLength;
|
||||||
AppLog.log("使能锁特征值说明 featureEnValStr:$featureEnValStr");
|
AppLog.log("使能锁特征值说明 featureEnValStr:$featureEnValStr");
|
||||||
|
|
||||||
// 支持的带参数特征值的总条目数
|
// 支持的带参数特征值的总条目数
|
||||||
@ -328,7 +341,7 @@ class NearbyLockLogic extends BaseGetXController {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
case 0x06:
|
case 0x06:
|
||||||
//无权限
|
//无权限
|
||||||
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(
|
||||||
@ -346,8 +359,8 @@ class NearbyLockLogic extends BaseGetXController {
|
|||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
//失败
|
//失败
|
||||||
// state.sureBtnState.value = 0;
|
// state.sureBtnState.value = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user