From b067e8a22ef84eeb2cb9ceb55f075a166da6733a Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Thu, 16 May 2024 17:49:08 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E5=BC=80=E9=94=81?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=8C=E4=BB=A5=E5=8F=8A=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E8=AE=B0=E5=BD=95=E9=87=8D=E5=A4=8D=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- star_lock/lib/app_settings/app_settings.dart | 1 + star_lock/lib/blue/blue_manage.dart | 28 ++++++++++++++++- star_lock/lib/blue/io_sender.dart | 3 +- .../doorLockLog/doorLockLog_logic.dart | 8 ++++- .../lockDetail/lockDetail_logic.dart | 16 +++++++--- .../lockDetail/lockDetail_page.dart | 30 +++++++++++-------- star_lock/lib/tools/baseGetXController.dart | 6 ++-- 7 files changed, 71 insertions(+), 21 deletions(-) diff --git a/star_lock/lib/app_settings/app_settings.dart b/star_lock/lib/app_settings/app_settings.dart index 53f711b5..7998bf68 100644 --- a/star_lock/lib/app_settings/app_settings.dart +++ b/star_lock/lib/app_settings/app_settings.dart @@ -14,6 +14,7 @@ class AppLog { _onlyError = onlyError ?? false; } static log(String msg,{bool? error}){ + msg = '${DateTime.now().toIso8601String()} : $msg'; DebugConsole.info(msg); if(!kDebugMode)return; error = error ?? false; diff --git a/star_lock/lib/blue/blue_manage.dart b/star_lock/lib/blue/blue_manage.dart index 639ff321..9f99375b 100644 --- a/star_lock/lib/blue/blue_manage.dart +++ b/star_lock/lib/blue/blue_manage.dart @@ -623,7 +623,7 @@ class BlueManage { } } } on Exception catch (e, s) { - AppLog.log('APP写入失败: $e'); + AppLog.log('APP写入失败: $e $s'); rethrow; } } @@ -654,6 +654,30 @@ class BlueManage { // } } + // 写入 + Future writeNull() async { + List services = + await bluetoothConnectDevice!.discoverServices(); + for (BluetoothService service in services) { + if (service.uuid == _serviceIdConnect) { + for (BluetoothCharacteristic characteristic + in service.characteristics) { + + if (characteristic.characteristicUuid == _characteristicIdWrite) { + try { + List valueList = [1]; + AppLog.log('APP写入 writeNull '); + await characteristic.write(valueList); + } on Exception catch (e, s) { + AppLog.log('APP写入失败 writeNull : $e $s'); + rethrow; + } + } + } + } + } + } + // 读取 // Future> _readCharacteristic(QualifiedCharacteristic characteristic) async { // try { @@ -696,6 +720,8 @@ class BlueManage { // if(bluetoothConnectDevice != null && bluetoothConnectDevice!.connectionState == BluetoothConnectionState.connected){ connectDeviceMacAddress = ""; if (bluetoothConnectionState == BluetoothConnectionState.connected) { + // await writeNull(); + // await Future.delayed(const Duration(milliseconds: 1000)); //加快蓝牙断连 await bluetoothConnectDevice!.disconnect(timeout: 2); AppLog.log("断开连接成功"); diff --git a/star_lock/lib/blue/io_sender.dart b/star_lock/lib/blue/io_sender.dart index 3d98678d..098f50a5 100644 --- a/star_lock/lib/blue/io_sender.dart +++ b/star_lock/lib/blue/io_sender.dart @@ -35,7 +35,8 @@ abstract class SenderProtocol extends IOData { void printLog(List data) { AppLog.log( - "App -> 锁,指令类型:${commandType!.typeName} \n参数是:\n${toString()} \n加密之前数据是:\n$data 长度是:${data.length}"); + "App -> 锁,指令类型:${commandType!.typeName} ${commandType!.typeValue == 0x3030 + ? '子命令:${data[3]}' : ''} \n参数是:\n${toString()} \n加密之前数据是:\n$data 长度是:${data.length}"); } //TODO:拼装数据Ï diff --git a/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart b/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart index 91e601f5..b3ab0755 100644 --- a/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart +++ b/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart @@ -1,6 +1,7 @@ import 'dart:async'; import 'package:flutter_blue_plus/flutter_blue_plus.dart'; +import 'package:star_lock/app_settings/app_settings.dart'; import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_entity.dart'; import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_state.dart'; @@ -58,7 +59,7 @@ class DoorLockLogLogic extends BaseGetXController { // AppLog.log("indexList:$indexList"); var indexMap = {}; indexMap["type"] = indexList[0].toString(); - + int operateDate = 0; if (indexList[0] == 2) { var passwordData = indexList.sublist(7, 17); var password = utf8String(passwordData); @@ -75,6 +76,11 @@ class DoorLockLogLogic extends BaseGetXController { (0xFF & indexList[6])); indexMap["date"] = "${time * 1000}"; uploadList.add(indexMap); + + if (i == getList.length - 1) { + //设置最后的时间戳 + state.operateDate = operateDate; + } } lockRecordUploadData(uploadList); diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart index 29ebca50..01669d5e 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart @@ -188,7 +188,7 @@ class LockDetailLogic extends BaseGetXController { case 0x00: //成功 int dataLength = (reply.data[5] << 8) + reply.data[6]; - AppLog.log("dataLength:$dataLength"); + // AppLog.log("dataLength:$dataLength"); if (dataLength > 0) { reply.data.removeRange(0, 7); // 把得到的数据按8位分割成数组 然后塞进一个新的数组里面 @@ -203,7 +203,7 @@ class LockDetailLogic extends BaseGetXController { // AppLog.log("indexList:$indexList"); var indexMap = {}; indexMap["type"] = indexList[0].toString(); - + int operateDate = 0; if (indexList[0] == 2) { var passwordData = reply.data.sublist(7, 17); var password = utf8String(passwordData); @@ -219,8 +219,14 @@ class LockDetailLogic extends BaseGetXController { (0xff & indexList[4]) << 16 | (0xff & indexList[5]) << 8 | (0xFF & indexList[6])); - indexMap["date"] = "${time * 1000}"; + operateDate = time * 1000; + indexMap["date"] = "$operateDate"; uploadList.add(indexMap); + + if (i == getList.length - 1) { + //设置最后的时间戳 + state.operateDate = operateDate; + } } lockRecordUploadData(uploadList); @@ -259,7 +265,8 @@ class LockDetailLogic extends BaseGetXController { var token = await Storage.getStringList(saveBlueToken); List getTokenList = changeStringListToIntList(token!); - BlueManage().bludSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!, + BlueManage() + .bludSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected) { IoSenderManage.senderOpenLock( @@ -289,6 +296,7 @@ class LockDetailLogic extends BaseGetXController { Future senderReferEventRecordTime() async { showBlueConnetctToastTimer( isShowBlueConnetctToast: false, + outTimer: 10, action: () { BlueManage().disconnect(); }); diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart index 8986f946..451f629f 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart @@ -403,8 +403,9 @@ class _LockDetailPageState extends State children: [ Visibility( visible: - ((state.keyInfos.value.keyType == XSConstantMacro.keyTypeTime || state.keyInfos.value.keyType == XSConstantMacro.keyTypeLoop) - && // 限时、循环 + ((state.keyInfos.value.keyType == XSConstantMacro.keyTypeTime || + state.keyInfos.value.keyType == + XSConstantMacro.keyTypeLoop) && // 限时、循环 (DateTool().compareTimeGetDaysFromNow( state.keyInfos.value.endDate!) <= 15 && @@ -1023,8 +1024,9 @@ class _LockDetailPageState extends State if (state.keyInfos.value.lockFeature!.isSupportIris == 1) { showWidgetArr.add( - bottomItem('images/main/icon_iris.png', '虹膜'.tr, - state.bottomBtnisEable.value, () { + bottomItem( + 'images/main/icon_iris.png', '虹膜'.tr, state.bottomBtnisEable.value, + () { Get.toNamed(Routers.irisListPage, arguments: { "lockId": state.keyInfos.value.lockId, }); @@ -1034,8 +1036,9 @@ class _LockDetailPageState extends State if (state.keyInfos.value.lockFeature!.palmVein == 1) { showWidgetArr.add( - bottomItem('images/main/icon_palm.png', '手掌'.tr, - state.bottomBtnisEable.value, () { + bottomItem( + 'images/main/icon_palm.png', '手掌'.tr, state.bottomBtnisEable.value, + () { Get.toNamed(Routers.palmListPage, arguments: { "lockId": state.keyInfos.value.lockId, }); @@ -1121,7 +1124,8 @@ class _LockDetailPageState extends State return showWidgetArr; } - Widget bottomItem(String iconUrl, String name, bool bottomBtnisEable, Function() onClick) { + Widget bottomItem( + String iconUrl, String name, bool bottomBtnisEable, Function() onClick) { Widget child = F.sw( defaultCall: () => Container( color: Colors.white, @@ -1147,7 +1151,9 @@ class _LockDetailPageState extends State child: Text(name, style: TextStyle( fontSize: 20.sp, - color: bottomBtnisEable ? AppColors.blackColor : AppColors.lockDetailBottomBtnUneable), + color: bottomBtnisEable + ? AppColors.blackColor + : AppColors.lockDetailBottomBtnUneable), textAlign: TextAlign.center)) ], ), @@ -1189,8 +1195,8 @@ class _LockDetailPageState extends State onTap: bottomBtnisEable ? onClick : () { - logic.showToast("请在锁旁边完成第一次开锁".tr); - }, + logic.showToast("请在锁旁边完成第一次开锁".tr); + }, child: child, ); } @@ -1406,7 +1412,7 @@ class _LockDetailPageState extends State void didPushNext() { super.didPushNext(); state.ifCurrentScreen.value = false; - logic.cancelBlueConnetctToastTimer(); - state.openLockBtnState.value = 0; + logic.closeLuckStatus(); + BlueManage().disconnect(); } } diff --git a/star_lock/lib/tools/baseGetXController.dart b/star_lock/lib/tools/baseGetXController.dart index af626b74..4c04428c 100644 --- a/star_lock/lib/tools/baseGetXController.dart +++ b/star_lock/lib/tools/baseGetXController.dart @@ -66,12 +66,14 @@ class BaseGetXController extends GetxController { // CancelableOperation? _operation; void showBlueConnetctToastTimer( - {bool isShowBlueConnetctToast = true, Function? action}) { + {bool isShowBlueConnetctToast = true, + int outTimer = 15, + Function? action}) { if (_timer != null && _timer!.isActive) { _timer!.cancel(); _timer = null; } - _timer = Timer.periodic(15.seconds, (timer) { + _timer = Timer.periodic(outTimer.seconds, (timer) { if (action != null) { action(); } From 4a7c825640dc00c9f81f0021ecc8f3164036aff6 Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Thu, 16 May 2024 18:05:56 +0800 Subject: [PATCH 2/3] =?UTF-8?q?feat:=E6=B7=BB=E5=8A=A0=E5=9B=BD=E9=99=85?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- star_lock/images/lan/lan_en.json | 3 ++- star_lock/images/lan/lan_keys.json | 3 ++- star_lock/images/lan/lan_zh.json | 3 ++- star_lock/lib/blue/blue_manage.dart | 11 +++++++---- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/star_lock/images/lan/lan_en.json b/star_lock/images/lan/lan_en.json index 42749191..27e1c76e 100644 --- a/star_lock/images/lan/lan_en.json +++ b/star_lock/images/lan/lan_en.json @@ -853,6 +853,7 @@ "开锁事件":"Unlock event", "异常事件":"Abnormal event", "门铃事件":"Doorbell event", - "视频事件":"Video event" + "视频事件":"Video event", + "请开启蓝牙":"Please turn on Bluetooth" } diff --git a/star_lock/images/lan/lan_keys.json b/star_lock/images/lan/lan_keys.json index ddd7610d..3d671b57 100644 --- a/star_lock/images/lan/lan_keys.json +++ b/star_lock/images/lan/lan_keys.json @@ -881,5 +881,6 @@ "开锁事件":"开锁事件", "异常事件":"异常事件", "门铃事件":"门铃事件", - "视频事件":"视频事件" + "视频事件":"视频事件", + "请开启蓝牙":"请开启蓝牙" } diff --git a/star_lock/images/lan/lan_zh.json b/star_lock/images/lan/lan_zh.json index f0ce8aa6..1bd2b742 100644 --- a/star_lock/images/lan/lan_zh.json +++ b/star_lock/images/lan/lan_zh.json @@ -851,5 +851,6 @@ "开锁事件":"开锁事件", "异常事件":"异常事件", "门铃事件":"门铃事件", - "视频事件":"视频事件" + "视频事件":"视频事件", + "请开启蓝牙":"请开启蓝牙" } diff --git a/star_lock/lib/blue/blue_manage.dart b/star_lock/lib/blue/blue_manage.dart index 9f99375b..223fe584 100644 --- a/star_lock/lib/blue/blue_manage.dart +++ b/star_lock/lib/blue/blue_manage.dart @@ -1,9 +1,13 @@ import 'dart:async'; import 'dart:io'; +import 'package:app_settings/app_settings.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:get/get.dart'; import 'package:star_lock/app_settings/app_settings.dart'; +import 'package:star_lock/tools/showTipView.dart'; +import 'package:star_lock/widget/permission/permission_dialog.dart'; +import 'package:url_launcher/url_launcher.dart'; import 'io_tool/io_model.dart'; import 'io_tool/io_tool.dart'; @@ -657,12 +661,11 @@ class BlueManage { // 写入 Future writeNull() async { List services = - await bluetoothConnectDevice!.discoverServices(); + await bluetoothConnectDevice!.discoverServices(); for (BluetoothService service in services) { if (service.uuid == _serviceIdConnect) { for (BluetoothCharacteristic characteristic - in service.characteristics) { - + in service.characteristics) { if (characteristic.characteristicUuid == _characteristicIdWrite) { try { List valueList = [1]; @@ -739,7 +742,7 @@ class BlueManage { await FlutterBluePlus.turnOn(); } if (Platform.isIOS) { - EasyLoading.showToast("请开启蓝牙", duration: 2000.milliseconds); + EasyLoading.showToast("请开启蓝牙".tr, duration: 2000.milliseconds); } } From 16ee07bd1c400b4e485e44550fecc26b310ea7f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=8F=E5=B0=91=E9=98=B3?= <786612630@qq.com> Date: Thu, 16 May 2024 18:08:25 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=8C=87=E7=BA=B9=E5=8D=A1=E4=BA=BA=E8=84=B8=E5=BE=AA=E7=8E=AF?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E6=97=A5=E6=9C=9F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../passwordKeyDetail/passwordKeyDetail_page.dart | 1 + .../seletKeyCyclicDate/seletKeyCyclicDate_page.dart | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_page.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_page.dart index b4bde647..b18f41ed 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_page.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_page.dart @@ -152,6 +152,7 @@ class _PasswordKeyDetailPageState extends State Get.toNamed(Routers.lockOperatingRecordPage, arguments: { 'type': 1, 'id': state.itemData.value.keyboardPwdId.toString(), + 'recordName': state.itemData.value.keyboardPwdName }); }), Visibility( diff --git a/star_lock/lib/tools/seletKeyCyclicDate/seletKeyCyclicDate_page.dart b/star_lock/lib/tools/seletKeyCyclicDate/seletKeyCyclicDate_page.dart index ed86b3b7..0600fc56 100644 --- a/star_lock/lib/tools/seletKeyCyclicDate/seletKeyCyclicDate_page.dart +++ b/star_lock/lib/tools/seletKeyCyclicDate/seletKeyCyclicDate_page.dart @@ -51,9 +51,14 @@ class _SeletKeyCyclicDatePageState extends State { state.starTime.value.isNotEmpty && state.endTime.value.isNotEmpty && state.weekDay.value.isNotEmpty), - onClick: () { + onClick: (state.starDate.value.isNotEmpty && + state.endDate.value.isNotEmpty && + state.starTime.value.isNotEmpty && + state.endTime.value.isNotEmpty && + state.weekDay.value.isNotEmpty) + ? () { logic.subBtnAction(); - }), + } : null), )), ], ));