feat:优化蓝牙搜索速度
This commit is contained in:
parent
36f872188a
commit
0b9583723e
@ -189,6 +189,8 @@ class BlueManage {
|
||||
FlutterBluePlus.startScan(
|
||||
continuousDivisor: divisor,
|
||||
continuousUpdates: true,
|
||||
// withServiceData:[ServiceDataFilter()],
|
||||
withKeywords: <String>[deviceName],
|
||||
timeout: Duration(seconds: timeout));
|
||||
final Completer<dynamic> completer = Completer<dynamic>();
|
||||
final StreamSubscription<List<ScanResult>> subscription =
|
||||
@ -374,9 +376,7 @@ class BlueManage {
|
||||
connectDeviceName = deviceName;
|
||||
final List<ScanResult> devicesList = scanDevices;
|
||||
|
||||
final bool isExistDevice = scanDevices.any((ScanResult element) =>
|
||||
element.device.platformName == connectDeviceName ||
|
||||
element.advertisementData.advName == connectDeviceName);
|
||||
final bool isExistDevice = isExistScanDevices(connectDeviceName);
|
||||
|
||||
if (isAddEquipment == false && isExistDevice == false) {
|
||||
//取消缓存直接使用,存在配对场景设备信息会更变
|
||||
@ -390,6 +390,15 @@ class BlueManage {
|
||||
}
|
||||
}
|
||||
|
||||
//查找缓存里面是否有设备
|
||||
bool isExistScanDevices(String connectDeviceName){
|
||||
final bool isExistDevice = scanDevices.any((ScanResult element) =>
|
||||
element.device.platformName == connectDeviceName ||
|
||||
element.advertisementData.advName == connectDeviceName);
|
||||
return isExistDevice;
|
||||
}
|
||||
|
||||
|
||||
Future<void> _connectDevice(List<ScanResult> devicesList, String deviceName,
|
||||
ConnectStateCallBack connectStateCallBack,
|
||||
{bool isAddEquipment = false}) async {
|
||||
|
||||
@ -37,17 +37,17 @@ class LockDetailLogic extends BaseGetXController {
|
||||
void initReplySubscription() {
|
||||
state.replySubscription =
|
||||
EventBusManager().eventBus!.on<Reply>().listen((Reply reply) async {
|
||||
// 开门
|
||||
if (reply is OpenDoorReply && state.ifCurrentScreen.value == true) {
|
||||
_replyOpenLock(reply);
|
||||
}
|
||||
// 开门
|
||||
if (reply is OpenDoorReply && state.ifCurrentScreen.value == true) {
|
||||
_replyOpenLock(reply);
|
||||
}
|
||||
|
||||
// 开完锁之后上传记录
|
||||
if (reply is SenderReferEventRecordTimeReply &&
|
||||
state.ifCurrentScreen.value == true) {
|
||||
_replyReferEventRecordTime(reply);
|
||||
}
|
||||
});
|
||||
// 开完锁之后上传记录
|
||||
if (reply is SenderReferEventRecordTimeReply &&
|
||||
state.ifCurrentScreen.value == true) {
|
||||
_replyReferEventRecordTime(reply);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 开门数据解析
|
||||
@ -56,8 +56,8 @@ class LockDetailLogic extends BaseGetXController {
|
||||
|
||||
switch (status) {
|
||||
case 0x00:
|
||||
//成功
|
||||
// _showFullScreenOverlay(Get.context!);
|
||||
//成功
|
||||
// _showFullScreenOverlay(Get.context!);
|
||||
cancelBlueConnetctToastTimer();
|
||||
|
||||
state.iSClosedUnlockSuccessfulPopup.value = true;
|
||||
@ -65,10 +65,10 @@ class LockDetailLogic extends BaseGetXController {
|
||||
// 如果没有点击关闭弹窗,3秒后自动关闭
|
||||
state.closedUnlockSuccessfulTimer =
|
||||
Timer.periodic(3.seconds, (Timer timer) {
|
||||
state.iSClosedUnlockSuccessfulPopup.value = false;
|
||||
timer.cancel();
|
||||
eventBus.fire(RefreshLockDetailInfoDataEvent());
|
||||
});
|
||||
state.iSClosedUnlockSuccessfulPopup.value = false;
|
||||
timer.cancel();
|
||||
eventBus.fire(RefreshLockDetailInfoDataEvent());
|
||||
});
|
||||
|
||||
// 电量
|
||||
final int power = reply.data[7];
|
||||
@ -86,14 +86,14 @@ class LockDetailLogic extends BaseGetXController {
|
||||
resetOpenDoorState();
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
//无权限
|
||||
final List<String>? privateKey =
|
||||
await Storage.getStringList(saveBluePrivateKey);
|
||||
await Storage.getStringList(saveBluePrivateKey);
|
||||
final List<int> getPrivateKeyList =
|
||||
changeStringListToIntList(privateKey!);
|
||||
changeStringListToIntList(privateKey!);
|
||||
|
||||
final List<String>? signKey =
|
||||
await Storage.getStringList(saveBlueSignKey);
|
||||
await Storage.getStringList(saveBlueSignKey);
|
||||
final List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
|
||||
final List<int> tokenData = reply.data.sublist(2, 6);
|
||||
@ -113,14 +113,14 @@ class LockDetailLogic extends BaseGetXController {
|
||||
);
|
||||
break;
|
||||
case 0x16:
|
||||
// 正在开锁中...
|
||||
// 正在开锁中...
|
||||
resetOpenDoorState();
|
||||
showToast('正在开锁中...'.tr, something: () {
|
||||
cancelBlueConnetctToastTimer();
|
||||
});
|
||||
break;
|
||||
case 0x0d:
|
||||
// 钥匙无效
|
||||
// 钥匙无效
|
||||
showToast('钥匙无效'.tr);
|
||||
// state.animationController!.stop();
|
||||
resetOpenDoorState();
|
||||
@ -128,7 +128,7 @@ class LockDetailLogic extends BaseGetXController {
|
||||
BlueManage().disconnect();
|
||||
break;
|
||||
case 0x0b:
|
||||
// 钥匙无效
|
||||
// 钥匙无效
|
||||
showToast('钥匙过期'.tr);
|
||||
resetOpenDoorState();
|
||||
|
||||
@ -136,7 +136,7 @@ class LockDetailLogic extends BaseGetXController {
|
||||
BlueManage().disconnect();
|
||||
break;
|
||||
case 0x0a:
|
||||
// 钥匙不存在
|
||||
// 钥匙不存在
|
||||
showToast('钥匙不存在');
|
||||
resetOpenDoorState();
|
||||
|
||||
@ -144,7 +144,7 @@ class LockDetailLogic extends BaseGetXController {
|
||||
BlueManage().disconnect();
|
||||
break;
|
||||
case 0x0c:
|
||||
// 钥匙数量已到上限
|
||||
// 钥匙数量已到上限
|
||||
showToast('钥匙数量已到上限');
|
||||
resetOpenDoorState();
|
||||
|
||||
@ -152,7 +152,7 @@ class LockDetailLogic extends BaseGetXController {
|
||||
BlueManage().disconnect();
|
||||
break;
|
||||
case 0x0e:
|
||||
// 钥匙已存在
|
||||
// 钥匙已存在
|
||||
showToast('钥匙已存在');
|
||||
resetOpenDoorState();
|
||||
|
||||
@ -160,7 +160,7 @@ class LockDetailLogic extends BaseGetXController {
|
||||
BlueManage().disconnect();
|
||||
break;
|
||||
case 0x0f:
|
||||
// 用户已存在
|
||||
// 用户已存在
|
||||
showToast('用户已存在');
|
||||
resetOpenDoorState();
|
||||
|
||||
@ -168,7 +168,7 @@ class LockDetailLogic extends BaseGetXController {
|
||||
BlueManage().disconnect();
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
//失败
|
||||
AppLog.log('开锁失败');
|
||||
// state.animationController!.stop();
|
||||
resetOpenDoorState();
|
||||
@ -190,67 +190,67 @@ class LockDetailLogic extends BaseGetXController {
|
||||
Future<void> _replyReferEventRecordTime(Reply reply) async {
|
||||
final int status = reply.data[2];
|
||||
switch (status) {
|
||||
case 0x00:
|
||||
//成功
|
||||
final int dataLength = (reply.data[5] << 8) + reply.data[6];
|
||||
// AppLog.log("dataLength:$dataLength");
|
||||
if (dataLength > 0) {
|
||||
reply.data.removeRange(0, 7);
|
||||
// 把得到的数据按17个字节分割成数组 然后塞进一个新的数组里面
|
||||
if (reply.data.length < 17) {
|
||||
return;
|
||||
}
|
||||
final List<List<int>> getList = splitList(reply.data, 17);
|
||||
// AppLog.log("getList:$getList");
|
||||
final List uploadList = [];
|
||||
for (int i = 0; i < getList.length; i++) {
|
||||
final List<int> indexList = getList[i];
|
||||
// AppLog.log("indexList:$indexList");
|
||||
final Map indexMap = {};
|
||||
indexMap['type'] = indexList[0].toString();
|
||||
int operateDate = 0;
|
||||
if (indexList[0] == 2) {
|
||||
final List<int> passwordData = reply.data.sublist(7, 17);
|
||||
final String password = utf8String(passwordData);
|
||||
indexMap['user'] = password.toString();
|
||||
} else {
|
||||
final int userNo = (indexList[1] * 256) + indexList[2];
|
||||
indexMap['user'] = userNo.toString();
|
||||
}
|
||||
case 0x00:
|
||||
//成功
|
||||
final int dataLength = (reply.data[5] << 8) + reply.data[6];
|
||||
// AppLog.log("dataLength:$dataLength");
|
||||
if (dataLength > 0) {
|
||||
reply.data.removeRange(0, 7);
|
||||
// 把得到的数据按17个字节分割成数组 然后塞进一个新的数组里面
|
||||
if (reply.data.length < 17) {
|
||||
return;
|
||||
}
|
||||
final List<List<int>> getList = splitList(reply.data, 17);
|
||||
// AppLog.log("getList:$getList");
|
||||
final List uploadList = [];
|
||||
for (int i = 0; i < getList.length; i++) {
|
||||
final List<int> indexList = getList[i];
|
||||
// AppLog.log("indexList:$indexList");
|
||||
final Map indexMap = {};
|
||||
indexMap['type'] = indexList[0].toString();
|
||||
int operateDate = 0;
|
||||
if (indexList[0] == 2) {
|
||||
final List<int> passwordData = reply.data.sublist(7, 17);
|
||||
final String password = utf8String(passwordData);
|
||||
indexMap['user'] = password.toString();
|
||||
} else {
|
||||
final int userNo = (indexList[1] * 256) + indexList[2];
|
||||
indexMap['user'] = userNo.toString();
|
||||
}
|
||||
|
||||
indexMap['success'] = '1';
|
||||
indexMap['success'] = '1';
|
||||
|
||||
final int time = ((0xff & indexList[(3)]) << 24 |
|
||||
(0xff & indexList[4]) << 16 |
|
||||
(0xff & indexList[5]) << 8 |
|
||||
(0xFF & indexList[6]));
|
||||
operateDate = time * 1000;
|
||||
indexMap['date'] = '$operateDate';
|
||||
uploadList.add(indexMap);
|
||||
final int time = ((0xff & indexList[(3)]) << 24 |
|
||||
(0xff & indexList[4]) << 16 |
|
||||
(0xff & indexList[5]) << 8 |
|
||||
(0xFF & indexList[6]));
|
||||
operateDate = time * 1000;
|
||||
indexMap['date'] = '$operateDate';
|
||||
uploadList.add(indexMap);
|
||||
|
||||
if (i == getList.length - 1) {
|
||||
//设置最后的时间戳
|
||||
state.operateDate = operateDate;
|
||||
}
|
||||
}
|
||||
lockRecordUploadData(uploadList);
|
||||
if (i == getList.length - 1) {
|
||||
//设置最后的时间戳
|
||||
state.operateDate = operateDate;
|
||||
}
|
||||
}
|
||||
lockRecordUploadData(uploadList);
|
||||
|
||||
if (dataLength == state.logCountPage) {
|
||||
senderReferEventRecordTime();
|
||||
} else {
|
||||
await BlueManage().disconnect();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
BlueManage().disconnect();
|
||||
cancelBlueConnetctToastTimer();
|
||||
break;
|
||||
default:
|
||||
BlueManage().disconnect();
|
||||
cancelBlueConnetctToastTimer();
|
||||
break;
|
||||
if (dataLength == state.logCountPage) {
|
||||
senderReferEventRecordTime();
|
||||
} else {
|
||||
await BlueManage().disconnect();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
BlueManage().disconnect();
|
||||
cancelBlueConnetctToastTimer();
|
||||
break;
|
||||
default:
|
||||
BlueManage().disconnect();
|
||||
cancelBlueConnetctToastTimer();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -262,7 +262,7 @@ class LockDetailLogic extends BaseGetXController {
|
||||
BlueManage().disconnect();
|
||||
});
|
||||
final List<String>? privateKey =
|
||||
await Storage.getStringList(saveBluePrivateKey);
|
||||
await Storage.getStringList(saveBluePrivateKey);
|
||||
final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
final List<String>? signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
@ -274,28 +274,28 @@ class LockDetailLogic extends BaseGetXController {
|
||||
BlueManage()
|
||||
.bludSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!,
|
||||
(BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
IoSenderManage.senderOpenLock(
|
||||
keyID: BlueManage().connectDeviceName,
|
||||
userID: await Storage.getUid(),
|
||||
openMode: state.openDoorModel,
|
||||
openTime: getUTCNetTime(),
|
||||
onlineToken: state.lockNetToken,
|
||||
token: getTokenList,
|
||||
needAuthor: 1,
|
||||
signKey: signKeyDataList,
|
||||
privateKey: getPrivateKeyList,
|
||||
);
|
||||
} else if (deviceConnectionState ==
|
||||
BluetoothConnectionState.disconnected) {
|
||||
cancelBlueConnetctToastTimer();
|
||||
if (state.ifCurrentScreen.value == true) {
|
||||
showBlueConnetctToast();
|
||||
}
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
IoSenderManage.senderOpenLock(
|
||||
keyID: BlueManage().connectDeviceName,
|
||||
userID: await Storage.getUid(),
|
||||
openMode: state.openDoorModel,
|
||||
openTime: getUTCNetTime(),
|
||||
onlineToken: state.lockNetToken,
|
||||
token: getTokenList,
|
||||
needAuthor: 1,
|
||||
signKey: signKeyDataList,
|
||||
privateKey: getPrivateKeyList,
|
||||
);
|
||||
} else if (deviceConnectionState ==
|
||||
BluetoothConnectionState.disconnected) {
|
||||
cancelBlueConnetctToastTimer();
|
||||
if (state.ifCurrentScreen.value == true) {
|
||||
showBlueConnetctToast();
|
||||
}
|
||||
|
||||
resetOpenDoorState();
|
||||
}
|
||||
});
|
||||
resetOpenDoorState();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 查询事件记录(时间查询)
|
||||
@ -307,49 +307,54 @@ class LockDetailLogic extends BaseGetXController {
|
||||
BlueManage().disconnect();
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
final List<String>? privateKey =
|
||||
(BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
final List<String>? privateKey =
|
||||
await Storage.getStringList(saveBluePrivateKey);
|
||||
final List<int> getPrivateKeyList =
|
||||
final List<int> getPrivateKeyList =
|
||||
changeStringListToIntList(privateKey!);
|
||||
|
||||
final List<String>? token = await Storage.getStringList(saveBlueToken);
|
||||
final List<int> getTokenList = changeStringListToIntList(token!);
|
||||
final List<String>? token = await Storage.getStringList(
|
||||
saveBlueToken);
|
||||
final List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
final List<String>? publicKey =
|
||||
final List<String>? publicKey =
|
||||
await Storage.getStringList(saveBluePublicKey);
|
||||
final List<int> getPublicKeyList =
|
||||
final List<int> getPublicKeyList =
|
||||
changeStringListToIntList(publicKey!);
|
||||
|
||||
IoSenderManage.senderReferEventRecordTimeCommand(
|
||||
keyID: BlueManage().connectDeviceName,
|
||||
userID: await Storage.getUid(),
|
||||
logsCount: state.logCountPage,
|
||||
// time:DateTime.now().millisecondsSinceEpoch~/1000,
|
||||
time: state.operateDate,
|
||||
token: getTokenList,
|
||||
needAuthor: 1,
|
||||
publicKey: getPublicKeyList,
|
||||
privateKey: getPrivateKeyList,
|
||||
);
|
||||
}
|
||||
});
|
||||
IoSenderManage.senderReferEventRecordTimeCommand(
|
||||
keyID: BlueManage().connectDeviceName,
|
||||
userID: await Storage.getUid(),
|
||||
logsCount: state.logCountPage,
|
||||
// time:DateTime.now().millisecondsSinceEpoch~/1000,
|
||||
time: state.operateDate,
|
||||
token: getTokenList,
|
||||
needAuthor: 1,
|
||||
publicKey: getPublicKeyList,
|
||||
privateKey: getPrivateKeyList,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 从服务器获取锁的时间 开锁时传入
|
||||
void getServerDatetime() async {
|
||||
final GetServerDatetimeEntity entity =
|
||||
await ApiRepository.to.getServerDatetimeData();
|
||||
await ApiRepository.to.getServerDatetimeData();
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
state.differentialTime = entity.data!.date! ~/ 1000 -
|
||||
DateTime.now().millisecondsSinceEpoch ~/ 1000;
|
||||
DateTime
|
||||
.now()
|
||||
.millisecondsSinceEpoch ~/ 1000;
|
||||
// AppLog.log("entity.data!.date! ~/ 1000:${entity.data!.date! ~/ 1000} DateTime.now().millisecondsSinceEpoch ~/ 1000:${DateTime.now().millisecondsSinceEpoch ~/ 1000} 服务器时间差:${state.differentialTime}");
|
||||
}
|
||||
}
|
||||
|
||||
int getUTCNetTime() {
|
||||
return DateTime.now().millisecondsSinceEpoch ~/ 1000 +
|
||||
return DateTime
|
||||
.now()
|
||||
.millisecondsSinceEpoch ~/ 1000 +
|
||||
state.differentialTime;
|
||||
}
|
||||
|
||||
@ -375,11 +380,11 @@ class LockDetailLogic extends BaseGetXController {
|
||||
Future<void> uploadElectricQuantityRequest() async {
|
||||
final KeyOperationRecordEntity entity = await ApiRepository.to
|
||||
.uploadElectricQuantity(
|
||||
electricQuantity: state.electricQuantity.value.toString(),
|
||||
electricQuantityStandby:
|
||||
state.electricQuantityStandby.value.toString(),
|
||||
lockId: state.keyInfos.value.lockId.toString(),
|
||||
isUnShowLoading: true);
|
||||
electricQuantity: state.electricQuantity.value.toString(),
|
||||
electricQuantityStandby:
|
||||
state.electricQuantityStandby.value.toString(),
|
||||
lockId: state.keyInfos.value.lockId.toString(),
|
||||
isUnShowLoading: true);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
SchedulerBinding.instance.addPostFrameCallback((_) {
|
||||
eventBus.fire(RefreshLockListInfoDataEvent(isUnShowLoading: true));
|
||||
@ -390,8 +395,8 @@ class LockDetailLogic extends BaseGetXController {
|
||||
// 查询锁记录最后时间
|
||||
void getLockRecordLastUploadDataTime() async {
|
||||
final LockOperatingRecordGetLastRecordTimeEntity entity =
|
||||
await ApiRepository.to.getLockRecordLastUploadDataTime(
|
||||
lockId: state.keyInfos.value.lockId.toString());
|
||||
await ApiRepository.to.getLockRecordLastUploadDataTime(
|
||||
lockId: state.keyInfos.value.lockId.toString());
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
state.operateDate = entity.data!.operateDate! ~/ 1000;
|
||||
senderReferEventRecordTime();
|
||||
@ -402,7 +407,7 @@ class LockDetailLogic extends BaseGetXController {
|
||||
Future<void> lockRecordUploadData(List list) async {
|
||||
final KeyOperationRecordEntity entity = await ApiRepository.to
|
||||
.lockRecordUploadData(
|
||||
lockId: state.keyInfos.value.lockId.toString(), records: list);
|
||||
lockId: state.keyInfos.value.lockId.toString(), records: list);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
// mockNetworkDataRequest();
|
||||
AppLog.log(
|
||||
@ -418,7 +423,7 @@ class LockDetailLogic extends BaseGetXController {
|
||||
void deletKeyData() async {
|
||||
final ElectronicKeyListEntity entity = await ApiRepository.to
|
||||
.deleteElectronicKey(
|
||||
keyId: state.keyInfos.value.keyId.toString(), includeUnderlings: 0);
|
||||
keyId: state.keyInfos.value.keyId.toString(), includeUnderlings: 0);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
BlueManage().connectDeviceMacAddress = '';
|
||||
SchedulerBinding.instance.addPostFrameCallback((_) {
|
||||
@ -435,50 +440,51 @@ class LockDetailLogic extends BaseGetXController {
|
||||
eventBus
|
||||
.on<LockSetChangeSetRefreshLockDetailWithType>()
|
||||
.listen((LockSetChangeSetRefreshLockDetailWithType event) {
|
||||
if (event.type == 0) {
|
||||
// 0考勤
|
||||
state.isAttendance.value = int.parse(event.setResult);
|
||||
state.keyInfos.value.lockSetting!.attendance =
|
||||
int.parse(event.setResult);
|
||||
} else if (event.type == 1) {
|
||||
// 1 开锁时是否需联网
|
||||
state.isOpenLockNeedOnline.value = int.parse(event.setResult);
|
||||
state.keyInfos.value.lockSetting!.appUnlockOnline =
|
||||
int.parse(event.setResult);
|
||||
state.lockNetToken = ''; // 改变开锁时是否联网状态的时候清空token
|
||||
} else if (event.type == 2) {
|
||||
// 2 常开模式
|
||||
state.isOpenPassageMode.value = int.parse(event.setResult);
|
||||
state.keyInfos.value.passageMode = int.parse(event.setResult);
|
||||
} else if (event.type == 3) {
|
||||
// 3 修改了锁名字
|
||||
state.lockAlias.value = event.setResult;
|
||||
state.keyInfos.value.lockAlias = event.setResult;
|
||||
Storage.setString(saveLockAlias, state.lockAlias.value);
|
||||
} else if (event.type == 4) {
|
||||
// 4 更新了电量
|
||||
state.electricQuantity.value = int.parse(event.setResult);
|
||||
state.keyInfos.value.electricQuantity = int.parse(event.setResult);
|
||||
} else if (event.type == 5) {
|
||||
// 5 远程开锁
|
||||
state.keyInfos.value.lockSetting!.remoteUnlock =
|
||||
int.parse(event.setResult);
|
||||
}
|
||||
CommonDataManage().currentKeyInfo = state.keyInfos.value;
|
||||
eventBus.fire(RefreshLockDetailInfoDataEvent());
|
||||
});
|
||||
if (event.type == 0) {
|
||||
// 0考勤
|
||||
state.isAttendance.value = int.parse(event.setResult);
|
||||
state.keyInfos.value.lockSetting!.attendance =
|
||||
int.parse(event.setResult);
|
||||
} else if (event.type == 1) {
|
||||
// 1 开锁时是否需联网
|
||||
state.isOpenLockNeedOnline.value = int.parse(event.setResult);
|
||||
state.keyInfos.value.lockSetting!.appUnlockOnline =
|
||||
int.parse(event.setResult);
|
||||
state.lockNetToken = ''; // 改变开锁时是否联网状态的时候清空token
|
||||
} else if (event.type == 2) {
|
||||
// 2 常开模式
|
||||
state.isOpenPassageMode.value = int.parse(event.setResult);
|
||||
state.keyInfos.value.passageMode = int.parse(event.setResult);
|
||||
} else if (event.type == 3) {
|
||||
// 3 修改了锁名字
|
||||
state.lockAlias.value = event.setResult;
|
||||
state.keyInfos.value.lockAlias = event.setResult;
|
||||
Storage.setString(saveLockAlias, state.lockAlias.value);
|
||||
} else if (event.type == 4) {
|
||||
// 4 更新了电量
|
||||
state.electricQuantity.value = int.parse(event.setResult);
|
||||
state.keyInfos.value.electricQuantity = int.parse(event.setResult);
|
||||
} else if (event.type == 5) {
|
||||
// 5 远程开锁
|
||||
state.keyInfos.value.lockSetting!.remoteUnlock =
|
||||
int.parse(event.setResult);
|
||||
}
|
||||
CommonDataManage().currentKeyInfo = state.keyInfos.value;
|
||||
eventBus.fire(RefreshLockDetailInfoDataEvent());
|
||||
});
|
||||
}
|
||||
|
||||
String getKeyStatusTextAndShow() {
|
||||
String text = '';
|
||||
if (state.keyInfos.value.keyStatus ==
|
||||
XSConstantMacro.keyStatusWaitIneffective ||
|
||||
XSConstantMacro.keyStatusWaitIneffective ||
|
||||
state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusFrozen ||
|
||||
state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusExpired ||
|
||||
state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusDeleted ||
|
||||
state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusReset) {
|
||||
text =
|
||||
"${"你的钥匙".tr}${XSConstantMacro.getKeyStatusStr(state.keyInfos.value.keyStatus!)}";
|
||||
"${"你的钥匙".tr}${XSConstantMacro.getKeyStatusStr(
|
||||
state.keyInfos.value.keyStatus!)}";
|
||||
} else {
|
||||
text = state.isOpenPassageMode.value == 1
|
||||
? '常开模式启动!长按闭锁'.tr
|
||||
@ -510,5 +516,18 @@ class LockDetailLogic extends BaseGetXController {
|
||||
|
||||
await PermissionDialog.request(Permission.location);
|
||||
await PermissionDialog.requestBluetooth();
|
||||
|
||||
final String connectDeviceName = state.keyInfos.value.bluetooth!
|
||||
.bluetoothDeviceName!;
|
||||
if (!BlueManage().isExistScanDevices(connectDeviceName)) {
|
||||
BlueManage().startScanSingle(
|
||||
connectDeviceName, 15, (List<ScanResult> p0) => null);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,8 +53,9 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
||||
# 1.0.43+2024052001:打包给公司测试
|
||||
# 1.0.44+2024052002:打包给公司测试
|
||||
# 1.0.45+2024052003:打包给公司测试
|
||||
# 1.0.46+2024052004:打包给公司测试
|
||||
|
||||
version: 1.0.45+2024052003
|
||||
version: 1.0.46+2024052004
|
||||
|
||||
environment:
|
||||
sdk: '>=2.12.0 <3.0.0'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user