feat:新增首次配锁后,静止开锁页面 2 秒防止锁设备未修改完成状态
This commit is contained in:
parent
a097f882e2
commit
a937d0a68b
@ -8,7 +8,9 @@ import 'package:get/get.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_changeAdministratorPassword.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_senderCustomPasswords.dart';
|
||||
import 'package:star_lock/blue/io_type.dart';
|
||||
import 'package:star_lock/main/lockDetail/lockDetail/lockDetail_logic.dart';
|
||||
import 'package:star_lock/main/lockMian/entity/lockListInfo_entity.dart';
|
||||
import 'package:star_lock/mine/addLock/saveLock/entity/SaveLockEntity.dart';
|
||||
import 'package:star_lock/tools/commonDataManage.dart';
|
||||
|
||||
import '../../../app_settings/app_settings.dart';
|
||||
@ -33,7 +35,7 @@ class SaveLockLogic extends BaseGetXController {
|
||||
|
||||
void _initReplySubscription() {
|
||||
_replySubscription =
|
||||
EventBusManager().eventBus!.on<Reply>().listen((reply) {
|
||||
EventBusManager().eventBus!.on<Reply>().listen((Reply reply) {
|
||||
if (reply is AddUserReply && state.ifCurrentScreen.value == true) {
|
||||
_replyAddUserKey(reply);
|
||||
}
|
||||
@ -50,16 +52,16 @@ class SaveLockLogic extends BaseGetXController {
|
||||
|
||||
// 添加用户
|
||||
Future<void> _replyAddUserKey(Reply reply) async {
|
||||
var token = reply.data.sublist(42, 46);
|
||||
List<String> strTokenList = changeIntListToStringList(token);
|
||||
final List<int> token = reply.data.sublist(42, 46);
|
||||
final List<String> strTokenList = changeIntListToStringList(token);
|
||||
Storage.setStringList(saveBlueToken, strTokenList);
|
||||
|
||||
int status = reply.data[46];
|
||||
final int status = reply.data[46];
|
||||
switch (status) {
|
||||
case 0x00:
|
||||
//成功 如果成功保存用户编号
|
||||
state.lockUserNo = listChangInt(reply.data.sublist(47, 49));
|
||||
AppLog.log("state.lockUserNo:${state.lockUserNo}");
|
||||
AppLog.log('state.lockUserNo:${state.lockUserNo}');
|
||||
|
||||
// 关闭超时
|
||||
cancelBlueConnetctToastTimer();
|
||||
@ -67,16 +69,20 @@ class SaveLockLogic extends BaseGetXController {
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
final List<String>? privateKey =
|
||||
await Storage.getStringList(saveBluePrivateKey);
|
||||
final List<int> getPrivateKeyList =
|
||||
changeStringListToIntList(privateKey!);
|
||||
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
final List<String>? publicKey =
|
||||
await Storage.getStringList(saveBluePublicKey);
|
||||
final List<int> publicKeyDataList =
|
||||
changeStringListToIntList(publicKey!);
|
||||
|
||||
IoSenderManage.senderAddUser(
|
||||
lockID: BlueManage().connectDeviceName,
|
||||
authUserID: await Storage.getUid(),
|
||||
keyID: "1",
|
||||
keyID: '1',
|
||||
userID: await Storage.getUid(),
|
||||
openMode: 1,
|
||||
keyType: 1,
|
||||
@ -216,21 +222,25 @@ class SaveLockLogic extends BaseGetXController {
|
||||
(BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
// 私钥
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
final List<String>? privateKey =
|
||||
await Storage.getStringList(saveBluePrivateKey);
|
||||
final List<int> getPrivateKeyList =
|
||||
changeStringListToIntList(privateKey!);
|
||||
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
final List<String>? publicKey =
|
||||
await Storage.getStringList(saveBluePublicKey);
|
||||
final List<int> publicKeyDataList =
|
||||
changeStringListToIntList(publicKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = [0, 0, 0, 0];
|
||||
final List<String>? token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = <int>[0, 0, 0, 0];
|
||||
if (token != null) {
|
||||
getTokenList = changeStringListToIntList(token);
|
||||
}
|
||||
IoSenderManage.senderAddUser(
|
||||
lockID: BlueManage().connectDeviceName,
|
||||
authUserID: await Storage.getUid(),
|
||||
keyID: "1",
|
||||
keyID: '1',
|
||||
userID: await Storage.getUid(),
|
||||
openMode: 1,
|
||||
keyType: 1,
|
||||
@ -356,35 +366,37 @@ class SaveLockLogic extends BaseGetXController {
|
||||
// }
|
||||
|
||||
void bindBlueAdmin() async {
|
||||
state.lockInfo["adminPwd"] = state.adminPassword;
|
||||
state.lockInfo['adminPwd'] = state.adminPassword;
|
||||
|
||||
var positionMap = {};
|
||||
positionMap['longitude'] = state.addressInfo["longitude"];
|
||||
positionMap['latitude'] = state.addressInfo["latitude"];
|
||||
positionMap['country'] = state.addressInfo["country"];
|
||||
positionMap['province'] = state.addressInfo["province"];
|
||||
positionMap['city'] = state.addressInfo["city"];
|
||||
positionMap['district'] = state.addressInfo["district"];
|
||||
positionMap['township'] = state.addressInfo["street"];
|
||||
positionMap['address'] = state.addressInfo["address"];
|
||||
final Map<String, dynamic> positionMap = <String, dynamic>{};
|
||||
positionMap['longitude'] = state.addressInfo['longitude'];
|
||||
positionMap['latitude'] = state.addressInfo['latitude'];
|
||||
positionMap['country'] = state.addressInfo['country'];
|
||||
positionMap['province'] = state.addressInfo['province'];
|
||||
positionMap['city'] = state.addressInfo['city'];
|
||||
positionMap['district'] = state.addressInfo['district'];
|
||||
positionMap['township'] = state.addressInfo['street'];
|
||||
positionMap['address'] = state.addressInfo['address'];
|
||||
|
||||
var bluetooth = {};
|
||||
final Map<String, dynamic> bluetooth = <String, dynamic>{};
|
||||
bluetooth['bluetoothDeviceId'] = BlueManage().connectDeviceMacAddress;
|
||||
bluetooth['bluetoothDeviceName'] = BlueManage().connectDeviceName;
|
||||
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
final List<String>? publicKey =
|
||||
await Storage.getStringList(saveBluePublicKey);
|
||||
final List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
bluetooth['publicKey'] = publicKeyDataList;
|
||||
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
final List<String>? privateKey =
|
||||
await Storage.getStringList(saveBluePrivateKey);
|
||||
final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
bluetooth['privateKey'] = getPrivateKeyList;
|
||||
|
||||
var signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
final List<String>? signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
final List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
bluetooth['signKey'] = signKeyDataList;
|
||||
|
||||
var entity = await ApiRepository.to.bindingBlueAdmin(
|
||||
final SaveLockEntity entity = await ApiRepository.to.bindingBlueAdmin(
|
||||
lockAlias: state.aliName.value,
|
||||
position: positionMap,
|
||||
bluetooth: bluetooth,
|
||||
@ -464,11 +476,18 @@ class SaveLockLogic extends BaseGetXController {
|
||||
eventBus.fire(RefreshLockListInfoDataEvent(clearScanDevices: true));
|
||||
BlueManage().disconnect();
|
||||
Get.close(state.isFromMap == 1 ? 5 : 6);
|
||||
//刚刚配对完,需要对开锁页锁死 2 秒
|
||||
Future<void>.delayed(const Duration(milliseconds: 200), () {
|
||||
if (Get.isRegistered<LockDetailLogic>()) {
|
||||
Get.find<LockDetailLogic>()
|
||||
.functionBlocker
|
||||
.countdownProhibited(duration: const Duration(seconds: 2));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
super.onReady();
|
||||
|
||||
_initReplySubscription();
|
||||
@ -476,13 +495,11 @@ class SaveLockLogic extends BaseGetXController {
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
// TODO: implement onInit
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
// TODO: implement onClose
|
||||
_replySubscription.cancel();
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user