fix:调整锁时间获取
This commit is contained in:
parent
494a57074e
commit
329989b2ba
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:date_format/date_format.dart';
|
import 'package:date_format/date_format.dart';
|
||||||
@ -25,14 +24,16 @@ class LockTimeLogic extends BaseGetXController{
|
|||||||
|
|
||||||
// 获取解析后的数据
|
// 获取解析后的数据
|
||||||
late StreamSubscription<Reply> _replySubscription;
|
late StreamSubscription<Reply> _replySubscription;
|
||||||
|
|
||||||
void _initReplySubscription() {
|
void _initReplySubscription() {
|
||||||
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((Reply reply) {
|
_replySubscription =
|
||||||
|
EventBusManager().eventBus!.on<Reply>().listen((Reply reply) {
|
||||||
if (reply is TimingReply) {
|
if (reply is TimingReply) {
|
||||||
_replyTiming(reply);
|
_replyTiming(reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取锁状态
|
// 获取锁状态
|
||||||
if(reply is GetStarLockStatuInfoReply && state.ifCurrentScreen.value == true) {
|
if (reply is GetStarLockStatuInfoReply) {
|
||||||
_replyGetStarLockStatusInfo(reply);
|
_replyGetStarLockStatusInfo(reply);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -53,13 +54,16 @@ class LockTimeLogic extends BaseGetXController{
|
|||||||
(0xff & indate[1]) << 16 |
|
(0xff & indate[1]) << 16 |
|
||||||
(0xff & indate[2]) << 8 |
|
(0xff & indate[2]) << 8 |
|
||||||
(0xFF & indate[3]);
|
(0xFF & indate[3]);
|
||||||
AppLog.log('indate:$indate indateValue:$indateValue');
|
AppLog.log(
|
||||||
|
'====================indate:$indate indateValue:$indateValue');
|
||||||
state.dateTime.value = DateTool().dateToYMDHNString('$indateValue');
|
state.dateTime.value = DateTool().dateToYMDHNString('$indateValue');
|
||||||
break;
|
break;
|
||||||
case 0x06:
|
case 0x06:
|
||||||
//需要鉴权
|
//需要鉴权
|
||||||
final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
|
final List<String>? privateKey =
|
||||||
final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
await Storage.getStringList(saveBluePrivateKey);
|
||||||
|
final List<int> getPrivateKeyList =
|
||||||
|
changeStringListToIntList(privateKey!);
|
||||||
|
|
||||||
IoSenderManage.senderGetStarLockStatuInfo(
|
IoSenderManage.senderGetStarLockStatuInfo(
|
||||||
lockID: BlueManage().connectDeviceName,
|
lockID: BlueManage().connectDeviceName,
|
||||||
@ -82,7 +86,8 @@ class LockTimeLogic extends BaseGetXController{
|
|||||||
switch (status) {
|
switch (status) {
|
||||||
case 0x00:
|
case 0x00:
|
||||||
//成功
|
//成功
|
||||||
final String dataEime = DateTool().dateToYMDHNString('${state.serverTime}');
|
final String dataEime =
|
||||||
|
DateTool().dateToYMDHNString('${state.serverTime}');
|
||||||
state.dateTime.value = dataEime;
|
state.dateTime.value = dataEime;
|
||||||
|
|
||||||
state.sureBtnState.value = 0;
|
state.sureBtnState.value = 0;
|
||||||
@ -128,15 +133,19 @@ class LockTimeLogic extends BaseGetXController{
|
|||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
state.sureBtnState.value = 0;
|
state.sureBtnState.value = 0;
|
||||||
});
|
});
|
||||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||||
|
(BluetoothConnectionState connectionState) async {
|
||||||
if (connectionState == BluetoothConnectionState.connected) {
|
if (connectionState == BluetoothConnectionState.connected) {
|
||||||
final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
|
final List<String>? privateKey =
|
||||||
final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
await Storage.getStringList(saveBluePrivateKey);
|
||||||
|
final List<int> getPrivateKeyList =
|
||||||
|
changeStringListToIntList(privateKey!);
|
||||||
|
|
||||||
final List<String>? token = await Storage.getStringList(saveBlueToken);
|
final List<String>? token = await Storage.getStringList(saveBlueToken);
|
||||||
final List<int> getTokenList = changeStringListToIntList(token!);
|
final List<int> getTokenList = changeStringListToIntList(token!);
|
||||||
|
|
||||||
final List<String>? signKey = await Storage.getStringList(saveBlueSignKey);
|
final List<String>? signKey =
|
||||||
|
await Storage.getStringList(saveBlueSignKey);
|
||||||
final List<int> getSignKeyList = changeStringListToIntList(signKey!);
|
final List<int> getSignKeyList = changeStringListToIntList(signKey!);
|
||||||
|
|
||||||
IoSenderManage.senderTimingCommand(
|
IoSenderManage.senderTimingCommand(
|
||||||
@ -152,9 +161,9 @@ class LockTimeLogic extends BaseGetXController{
|
|||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
cancelBlueConnetctToastTimer();
|
cancelBlueConnetctToastTimer();
|
||||||
state.sureBtnState.value = 0;
|
state.sureBtnState.value = 0;
|
||||||
if(state.ifCurrentScreen.value == true){
|
// if (state.ifCurrentScreen.value == true) {
|
||||||
showBlueConnetctToast();
|
// showBlueConnetctToast();
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -168,8 +177,10 @@ class LockTimeLogic extends BaseGetXController{
|
|||||||
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||||
(BluetoothConnectionState deviceConnectionState) async {
|
(BluetoothConnectionState deviceConnectionState) async {
|
||||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||||
final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
|
final List<String>? privateKey =
|
||||||
final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
await Storage.getStringList(saveBluePrivateKey);
|
||||||
|
final List<int> getPrivateKeyList =
|
||||||
|
changeStringListToIntList(privateKey!);
|
||||||
|
|
||||||
IoSenderManage.senderGetStarLockStatuInfo(
|
IoSenderManage.senderGetStarLockStatuInfo(
|
||||||
lockID: BlueManage().connectDeviceName,
|
lockID: BlueManage().connectDeviceName,
|
||||||
@ -179,29 +190,30 @@ class LockTimeLogic extends BaseGetXController{
|
|||||||
isBeforeAddUser: false,
|
isBeforeAddUser: false,
|
||||||
privateKey: getPrivateKeyList,
|
privateKey: getPrivateKeyList,
|
||||||
);
|
);
|
||||||
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
|
} else if (deviceConnectionState ==
|
||||||
|
BluetoothConnectionState.disconnected) {
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
cancelBlueConnetctToastTimer();
|
cancelBlueConnetctToastTimer();
|
||||||
if (state.ifCurrentScreen.value == true) {
|
// if (state.ifCurrentScreen.value == true) {
|
||||||
showBlueConnetctToast();
|
// showBlueConnetctToast();
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 从网关获取时间
|
// 从网关获取时间
|
||||||
Future<void> getLockTimeFromGateway() async {
|
Future<void> getLockTimeFromGateway() async {
|
||||||
final GetServerDatetimeEntity entity = await ApiRepository.to.getLockTimeFromGateway(
|
final GetServerDatetimeEntity entity =
|
||||||
|
await ApiRepository.to.getLockTimeFromGateway(
|
||||||
lockId: state.lockSetInfoData.value.lockId.toString(),
|
lockId: state.lockSetInfoData.value.lockId.toString(),
|
||||||
);
|
);
|
||||||
if(entity.errorCode!.codeIsSuccessful){
|
if (entity.errorCode!.codeIsSuccessful) {}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 从服务器获取锁的时间 开锁时传入
|
// 从服务器获取锁的时间 开锁时传入
|
||||||
Future<void> getServerDatetime(bool isSendTime) async {
|
Future<void> getServerDatetime(bool isSendTime) async {
|
||||||
final GetServerDatetimeEntity entity = await ApiRepository.to.getServerDatetimeData(isUnShowLoading:false);
|
final GetServerDatetimeEntity entity =
|
||||||
|
await ApiRepository.to.getServerDatetimeData(isUnShowLoading: false);
|
||||||
if (entity.errorCode!.codeIsSuccessful) {
|
if (entity.errorCode!.codeIsSuccessful) {
|
||||||
state.serverTime = entity.data!.date! ~/ 1000;
|
state.serverTime = entity.data!.date! ~/ 1000;
|
||||||
// AppLog.log("entity.data!.date! ~/ 1000:${entity.data!.date! ~/ 1000} DateTime.now().millisecondsSinceEpoch ~/ 1000:${DateTime.now().millisecondsSinceEpoch ~/ 1000} 服务器时间差:${state.differentialTime}");
|
// AppLog.log("entity.data!.date! ~/ 1000:${entity.data!.date! ~/ 1000} DateTime.now().millisecondsSinceEpoch ~/ 1000:${DateTime.now().millisecondsSinceEpoch ~/ 1000} 服务器时间差:${state.differentialTime}");
|
||||||
@ -229,7 +241,6 @@ class LockTimeLogic extends BaseGetXController{
|
|||||||
// getLockTimeFromGateway();
|
// getLockTimeFromGateway();
|
||||||
|
|
||||||
getServerDatetime(false);
|
getServerDatetime(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user