fix:调整锁时间获取

This commit is contained in:
liyi 2025-02-10 13:40:41 +08:00
parent 494a57074e
commit 329989b2ba

View File

@ -1,4 +1,3 @@
import 'dart:async';
import 'package:date_format/date_format.dart';
@ -25,14 +24,16 @@ class LockTimeLogic extends BaseGetXController{
//
late StreamSubscription<Reply> _replySubscription;
void _initReplySubscription() {
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((Reply reply) {
_replySubscription =
EventBusManager().eventBus!.on<Reply>().listen((Reply reply) {
if (reply is TimingReply) {
_replyTiming(reply);
}
//
if(reply is GetStarLockStatuInfoReply && state.ifCurrentScreen.value == true) {
if (reply is GetStarLockStatuInfoReply) {
_replyGetStarLockStatusInfo(reply);
}
});
@ -53,13 +54,16 @@ class LockTimeLogic extends BaseGetXController{
(0xff & indate[1]) << 16 |
(0xff & indate[2]) << 8 |
(0xFF & indate[3]);
AppLog.log('indate:$indate indateValue:$indateValue');
AppLog.log(
'====================indate:$indate indateValue:$indateValue');
state.dateTime.value = DateTool().dateToYMDHNString('$indateValue');
break;
case 0x06:
//
final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
final List<String>? privateKey =
await Storage.getStringList(saveBluePrivateKey);
final List<int> getPrivateKeyList =
changeStringListToIntList(privateKey!);
IoSenderManage.senderGetStarLockStatuInfo(
lockID: BlueManage().connectDeviceName,
@ -82,7 +86,8 @@ class LockTimeLogic extends BaseGetXController{
switch (status) {
case 0x00:
//
final String dataEime = DateTool().dateToYMDHNString('${state.serverTime}');
final String dataEime =
DateTool().dateToYMDHNString('${state.serverTime}');
state.dateTime.value = dataEime;
state.sureBtnState.value = 0;
@ -128,15 +133,19 @@ class LockTimeLogic extends BaseGetXController{
dismissEasyLoading();
state.sureBtnState.value = 0;
});
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
BlueManage().blueSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState connectionState) async {
if (connectionState == BluetoothConnectionState.connected) {
final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
final List<String>? privateKey =
await Storage.getStringList(saveBluePrivateKey);
final List<int> getPrivateKeyList =
changeStringListToIntList(privateKey!);
final List<String>? token = await Storage.getStringList(saveBlueToken);
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!);
IoSenderManage.senderTimingCommand(
@ -152,9 +161,9 @@ class LockTimeLogic extends BaseGetXController{
dismissEasyLoading();
cancelBlueConnetctToastTimer();
state.sureBtnState.value = 0;
if(state.ifCurrentScreen.value == true){
showBlueConnetctToast();
}
// if (state.ifCurrentScreen.value == true) {
// showBlueConnetctToast();
// }
}
});
}
@ -168,8 +177,10 @@ class LockTimeLogic extends BaseGetXController{
BlueManage().blueSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected) {
final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
final List<String>? privateKey =
await Storage.getStringList(saveBluePrivateKey);
final List<int> getPrivateKeyList =
changeStringListToIntList(privateKey!);
IoSenderManage.senderGetStarLockStatuInfo(
lockID: BlueManage().connectDeviceName,
@ -179,29 +190,30 @@ class LockTimeLogic extends BaseGetXController{
isBeforeAddUser: false,
privateKey: getPrivateKeyList,
);
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
} else if (deviceConnectionState ==
BluetoothConnectionState.disconnected) {
dismissEasyLoading();
cancelBlueConnetctToastTimer();
if (state.ifCurrentScreen.value == true) {
showBlueConnetctToast();
}
// if (state.ifCurrentScreen.value == true) {
// showBlueConnetctToast();
// }
}
});
}
//
Future<void> getLockTimeFromGateway() async {
final GetServerDatetimeEntity entity = await ApiRepository.to.getLockTimeFromGateway(
final GetServerDatetimeEntity entity =
await ApiRepository.to.getLockTimeFromGateway(
lockId: state.lockSetInfoData.value.lockId.toString(),
);
if(entity.errorCode!.codeIsSuccessful){
}
if (entity.errorCode!.codeIsSuccessful) {}
}
//
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) {
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}");
@ -229,7 +241,6 @@ class LockTimeLogic extends BaseGetXController{
// getLockTimeFromGateway();
getServerDatetime(false);
}
@override