Merge branch 'master' of gitee.com:starlock-cn/app-starlock

This commit is contained in:
Daisy 2024-05-16 18:14:49 +08:00
commit bcecc33796
12 changed files with 89 additions and 27 deletions

View File

@ -853,6 +853,7 @@
"开锁事件":"Unlock event",
"异常事件":"Abnormal event",
"门铃事件":"Doorbell event",
"视频事件":"Video event"
"视频事件":"Video event",
"请开启蓝牙":"Please turn on Bluetooth"
}

View File

@ -881,5 +881,6 @@
"开锁事件":"开锁事件",
"异常事件":"异常事件",
"门铃事件":"门铃事件",
"视频事件":"视频事件"
"视频事件":"视频事件",
"请开启蓝牙":"请开启蓝牙"
}

View File

@ -851,5 +851,6 @@
"开锁事件":"开锁事件",
"异常事件":"异常事件",
"门铃事件":"门铃事件",
"视频事件":"视频事件"
"视频事件":"视频事件",
"请开启蓝牙":"请开启蓝牙"
}

View File

@ -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;

View File

@ -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';
@ -623,7 +627,7 @@ class BlueManage {
}
}
} on Exception catch (e, s) {
AppLog.log('APP写入失败: $e');
AppLog.log('APP写入失败: $e $s');
rethrow;
}
}
@ -654,6 +658,29 @@ class BlueManage {
// }
}
//
Future<void> writeNull() async {
List<BluetoothService> 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<int> valueList = [1];
AppLog.log('APP写入 writeNull ');
await characteristic.write(valueList);
} on Exception catch (e, s) {
AppLog.log('APP写入失败 writeNull : $e $s');
rethrow;
}
}
}
}
}
}
//
// Future<List<int>> _readCharacteristic(QualifiedCharacteristic characteristic) async {
// try {
@ -696,6 +723,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("断开连接成功");
@ -713,7 +742,7 @@ class BlueManage {
await FlutterBluePlus.turnOn();
}
if (Platform.isIOS) {
EasyLoading.showToast("请开启蓝牙", duration: 2000.milliseconds);
EasyLoading.showToast("请开启蓝牙".tr, duration: 2000.milliseconds);
}
}

View File

@ -35,7 +35,8 @@ abstract class SenderProtocol extends IOData {
void printLog(List<int> 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:Ï

View File

@ -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);

View File

@ -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);
// 17
@ -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<int> 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<void> senderReferEventRecordTime() async {
showBlueConnetctToastTimer(
isShowBlueConnetctToast: false,
outTimer: 10,
action: () {
BlueManage().disconnect();
});

View File

@ -403,8 +403,9 @@ class _LockDetailPageState extends State<LockDetailPage>
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<LockDetailPage>
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<LockDetailPage>
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<LockDetailPage>
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<LockDetailPage>
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<LockDetailPage>
onTap: bottomBtnisEable
? onClick
: () {
logic.showToast("请在锁旁边完成第一次开锁".tr);
},
logic.showToast("请在锁旁边完成第一次开锁".tr);
},
child: child,
);
}
@ -1406,7 +1412,7 @@ class _LockDetailPageState extends State<LockDetailPage>
void didPushNext() {
super.didPushNext();
state.ifCurrentScreen.value = false;
logic.cancelBlueConnetctToastTimer();
state.openLockBtnState.value = 0;
logic.closeLuckStatus();
BlueManage().disconnect();
}
}

View File

@ -152,6 +152,7 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage>
Get.toNamed(Routers.lockOperatingRecordPage, arguments: {
'type': 1,
'id': state.itemData.value.keyboardPwdId.toString(),
'recordName': state.itemData.value.keyboardPwdName
});
}),
Visibility(

View File

@ -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();
}

View File

@ -51,9 +51,14 @@ class _SeletKeyCyclicDatePageState extends State<SeletKeyCyclicDatePage> {
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),
)),
],
));