diff --git a/lib/main/lockDetail/lockDetail/lockDetail_page.dart b/lib/main/lockDetail/lockDetail/lockDetail_page.dart index 45ef4e18..7615c010 100755 --- a/lib/main/lockDetail/lockDetail/lockDetail_page.dart +++ b/lib/main/lockDetail/lockDetail/lockDetail_page.dart @@ -67,6 +67,8 @@ class _LockDetailPageState extends State logic.loadData( lockListInfoItemEntity: widget.lockListInfoItemEntity, isOnlyOneData: widget.isOnlyOneData); + + _handleLockSettingInfoData(); } @override @@ -1162,25 +1164,10 @@ class _LockDetailPageState extends State showWidgetArr.add( bottomItem('images/main/icon_catEyes.png', '监控'.tr, state.bottomBtnisEable.value, () async { - final lockId = state.keyInfos.value.lockId; - final LockSetInfoEntity entity = - await ApiRepository.to.getLockSettingInfoData( - lockId: lockId.toString(), - ); - if (entity.errorCode!.codeIsSuccessful) { - final LockSetInfoData data = entity.data!; - final mac = data.lockBasicInfo?.mac; - if (mac != null && mac.isNotEmpty) { - final DeviceNetwork deviceNetworkInfo = await ApiRepository.to - .getDeviceNetwork(deviceType: 2, deviceMac: mac); - final peerId = deviceNetworkInfo?.data?.peerId; - if (peerId == null || peerId.isEmpty) { - throw Exception('设备peerId为空'); - } - StartChartManage() - .startCallRequestMessageTimer(ToPeerId: peerId ?? ''); - } - } + _handleLockSettingInfoData(); + // 发送监控id + StartChartManage().startCallRequestMessageTimer( + ToPeerId: StartChartManage().lockPeerId ?? ''); }), ); } @@ -1587,4 +1574,26 @@ class _LockDetailPageState extends State logic.closeLuckStatus(); BlueManage().disconnect(); } + + void _handleLockSettingInfoData() async { + final lockId = state.keyInfos.value.lockId; + final LockSetInfoEntity entity = + await ApiRepository.to.getLockSettingInfoData( + lockId: lockId.toString(), + ); + if (entity.errorCode!.codeIsSuccessful) { + final LockSetInfoData data = entity.data!; + final mac = data.lockBasicInfo?.mac; + if (mac != null && mac.isNotEmpty) { + final DeviceNetwork deviceNetworkInfo = await ApiRepository.to + .getDeviceNetwork(deviceType: 2, deviceMac: mac); + final peerId = deviceNetworkInfo?.data?.peerId; + if (peerId == null || peerId.isEmpty) { + throw Exception('设备peerId为空'); + } + // 设置锁的peerID + StartChartManage().lockPeerId = peerId; + } + } + } } diff --git a/lib/main/lockDetail/lockSet/catEyeSet/catEyeCustomMode/catEyeCustomMode_logic.dart b/lib/main/lockDetail/lockSet/catEyeSet/catEyeCustomMode/catEyeCustomMode_logic.dart index 400edf80..1e066b81 100755 --- a/lib/main/lockDetail/lockSet/catEyeSet/catEyeCustomMode/catEyeCustomMode_logic.dart +++ b/lib/main/lockDetail/lockSet/catEyeSet/catEyeCustomMode/catEyeCustomMode_logic.dart @@ -1,15 +1,23 @@ import 'package:get/get.dart'; +import 'package:star_lock/app_settings/app_settings.dart'; +import 'package:star_lock/blue/blue_manage.dart'; +import 'package:star_lock/blue/io_protocol/io_setSupportFunctionsWithParameters.dart'; +import 'package:star_lock/blue/io_tool/io_tool.dart'; import 'package:star_lock/main/lockDetail/lockSet/catEyeSet/catEyeCustomMode/catEyeCustomMode_state.dart'; +import 'package:star_lock/main/lockDetail/lockSet/catEyeSet/catEyeSet/catEyeSet_state.dart'; import 'package:star_lock/main/lockDetail/lockSet/lockSet/lockSetInfo_entity.dart'; import 'package:star_lock/network/api_repository.dart'; +import 'package:star_lock/talk/startChart/start_chart_manage.dart'; import 'package:star_lock/tools/baseGetXController.dart'; +import 'package:star_lock/tools/storage.dart'; class CatEyeCustomModeLogic extends BaseGetXController { final CatEyeCustomModeState state = CatEyeCustomModeState(); // 获取锁设置信息 Future getLockSettingInfoData() async { - final LockSetInfoEntity entity = await ApiRepository.to.getLockSettingInfoData( + final LockSetInfoEntity entity = + await ApiRepository.to.getLockSettingInfoData( lockId: state.lockSetInfoData.value.lockId.toString(), ); if (entity.errorCode!.codeIsSuccessful) { @@ -34,6 +42,8 @@ class CatEyeCustomModeLogic extends BaseGetXController { state.catEyeConfigData.value.catEyeModeConfig!.realTimeMode == 0 ? '发生事件时查看'.tr : '实时查看'.tr; + _getConfigAndGenerateBleData(); + updateCatEyeSetConfig(); } } } @@ -69,6 +79,250 @@ class CatEyeCustomModeLogic extends BaseGetXController { ); if (entity.errorCode!.codeIsSuccessful) { showToast('设置成功'.tr); + _getConfigAndGenerateBleData(); + updateCatEyeSetConfig(); } } + + _getConfigAndGenerateBleData() { + int originalCatEyeMode = state + .lockSetInfoData.value.lockSettingInfo!.catEyeConfig![0].catEyeMode!; + int recordMode = state.lockSetInfoData.value.lockSettingInfo! + .catEyeConfig![0].catEyeModeConfig!.recordMode == + 0 + ? 1 + : 0; + + int stayWarn = state.lockSetInfoData.value.lockSettingInfo!.stayWarn!; + int abnormalWarn = + state.lockSetInfoData.value.lockSettingInfo!.abnormalWarn!; + int autoLightScreen = + state.lockSetInfoData.value.lockSettingInfo!.autoLightScreen!; + + int recordStartTime = _handleTimeToM(state.lockSetInfoData.value + .lockSettingInfo!.catEyeConfig![0].catEyeModeConfig!.recordStartTime!); + int recordEndTime = _handleTimeToM(state.lockSetInfoData.value + .lockSettingInfo!.catEyeConfig![0].catEyeModeConfig!.recordEndTime!); + + int recordTime = _handleGetIntNumber(state.lockSetInfoData.value + .lockSettingInfo!.catEyeConfig![0].catEyeModeConfig!.recordTime!); + + int detectionDistance = _handleDetectionDistance(state + .lockSetInfoData + .value + .lockSettingInfo! + .catEyeConfig![0] + .catEyeModeConfig! + .detectionDistance!); + int realTimeMode = state.lockSetInfoData.value.lockSettingInfo! + .catEyeConfig![0].catEyeModeConfig!.realTimeMode!; + + // 根据需要调整 catEyeMode 的值 + int adjustedCatEyeMode = + originalCatEyeMode > 0 ? originalCatEyeMode - 1 : originalCatEyeMode; + int brightScreenTime = + state.lockSetInfoData.value.lockSettingInfo!.autoLightScreenTime!; + + /// 对照星锁接口文档v0.2 的猫眼设置接口,获取出猫眼的所有设置 + state.catEyeConfig.value = CatEyeSetEntity( + catEyeMode: adjustedCatEyeMode, + // 猫眼模式 看常量表 + recordMode: recordMode, + //录像时段 0全天 1自定义时间 + recordStartTime: recordStartTime, + //自定义时间需要填:recordStartTime与recordEndTime参数 + recordEndTime: recordEndTime, + //自定义时间需要填:recordStartTime与recordEndTime参数 + realTimeMode: realTimeMode, + autoLightScreenTime: brightScreenTime, + stayWarn: stayWarn, + autoLightScreen: autoLightScreen, + // 打开自动亮屏 + abnormalWarn: abnormalWarn, + // 有人出现时录像时间 + recordTime: recordTime, + // 人体检测距离 + detectionDistance: detectionDistance, + realTimePicture: realTimeMode, + ); + state.catEyeConfig.refresh(); + } + + /// 更新锁板上的猫眼配置 + void updateCatEyeSetConfig() async { + final int operatingMode = state.catEyeConfig.value.catEyeMode ?? 1; // 自定义模式 + final int isAllDay = state.catEyeConfig.value.recordMode ?? 1; // 是否是全天 + final int startTime = + state.catEyeConfig.value.recordStartTime ?? 480; // 8:00 AM + final int endTime = + state.catEyeConfig.value.recordEndTime ?? 1080; // 6:00 PM + final int recordingTime = state.catEyeConfig.value.recordTime ?? 0; // 立即录像 + final int detectionDistance = + state.catEyeConfig.value.detectionDistance ?? 0; //0:0.8米 + final int realTimePicture = + state.catEyeConfig.value.realTimePicture ?? 0; // 实时查看 + final int automaticBrightening = + state.catEyeConfig.value.autoLightScreen ?? 1; // 打开逗留警告 + final int brightScreenTime = + state.catEyeConfig.value.autoLightScreenTime ?? 10; // 亮屏持续时间为15秒 + final int stayWarning = state.catEyeConfig.value.stayWarn ?? 1; // 打开逗留警告 + final int exceptionWarning = + state.catEyeConfig.value.abnormalWarn ?? 1; // 打开逗留警告 + + /// 生成配置,非自定义功能字段默认填充0 + final List config = generateConfig( + operatingMode: operatingMode, + isAllDay: isAllDay, + startTime: startTime, + endTime: endTime, + recordingTime: recordingTime, + detectionDistance: detectionDistance, + realTimePicture: realTimePicture, + automaticBrightening: automaticBrightening, + brightScreenTime: brightScreenTime, + stayWarning: stayWarning, + exceptionWarning: exceptionWarning, + ); + final List? privateKey = + await Storage.getStringList(saveBluePrivateKey); + final List getPrivateKeyList = changeStringListToIntList(privateKey!); + + final List? token = await Storage.getStringList(saveBlueToken); + final List getTokenList = changeStringListToIntList(token!); + + final List? publicKey = + await Storage.getStringList(saveBluePublicKey); + final List getPublicKeyList = changeStringListToIntList(publicKey!); + + final command = SetSupportFunctionsWithParametersCommand( + keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(), + userID: await Storage.getUid(), + featureBit: 64, + featureParaLength: config.length, + featureData: config, + token: getTokenList, + needAuthor: 1, + publicKey: getPublicKeyList, + privateKey: getPrivateKeyList, + ); + final packageData = command.packageData(); + + // 将 List 转换为十六进制字符串 + String hexString = packageData + .map((byte) => byte.toRadixString(16).padLeft(2, '0')) + .join(' '); + + AppLog.log('open lock hexString: $hexString'); + + /// 发送星图 + StartChartManage().sendBleMessage( + bluetoothDeviceName: BlueManage().connectDeviceName, + bleStructData: packageData, + ); + } + + // 根据提供的参数生成配置列表 + List generateConfig({ + required int operatingMode, + required int isAllDay, + required int startTime, + required int endTime, + required int recordingTime, + required int detectionDistance, + required int realTimePicture, + required int automaticBrightening, + required int brightScreenTime, + required int stayWarning, + required int exceptionWarning, + }) { + // 初始化一个空的列表 + List config = []; + + // 添加 operatingMode + config.add(operatingMode); + + // 如果不是自定义模式,则填充0;否则添加对应的值 + if (operatingMode != 3) { + config.addAll( + [0, 0, 0, 0, 0, 0]); // 对应 IsAllDay, StartTime, EndTime, recordingTime + } else { + config.add(isAllDay); + config.addAll(_intToBytes(startTime, 2)); // StartTime 占用2个字节 + config.addAll(_intToBytes(endTime, 2)); // EndTime 占用2个字节 + config.add(recordingTime); + } + + // 如果不是自定义模式,则 detectionDistance 和 realTimePicture 也填充0 + if (operatingMode != 3) { + config.addAll([0, 0]); + } else { + config.add(detectionDistance); + config.add(realTimePicture); + } + + // 自动亮屏、亮屏持续时间、逗留警告、异常警告 + config.add(automaticBrightening); + config.add(brightScreenTime); + config.add(stayWarning); + config.add(exceptionWarning); + + return config; + } + + // 将整数转换为指定长度的字节表示形式 + List _intToBytes(int value, int length) { + List bytes = []; + for (int i = length - 1; i >= 0; i--) { + bytes.add((value >> (8 * i)) & 0xFF); + } + return bytes; + } + + int _handleTimeToM(int recordStartTime) { +// 转换为 DateTime 对象 + DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(recordStartTime); + +// 提取小时和分钟 + int hour = dateTime.hour; + int minute = dateTime.minute; + + print("时: $hour, 分: $minute"); + +// 计算从当天0点开始的分钟数 + int minutesSinceMidnight = dateTime.hour * 60 + dateTime.minute; + return minutesSinceMidnight; + } + + int _handleGetIntNumber(String recordTime) { + if (recordTime == '不录像') { + return 0; + } + if (recordTime == '立即录像') { + return 1; + } + // 使用正则表达式匹配字符串中的数字 + RegExp regExp = RegExp(r'(\d+)秒'); + Match? match = regExp.firstMatch(recordTime); + + if (match != null && match.groupCount >= 1) { + // 提取出的数字是字符串形式,需要转换成整数 + int number = int.parse(match.group(1)!); + return number; + } else { + return 0; + } + } + + int _handleDetectionDistance(String s) { + if (s == '约0.8米') { + return 0; + } + if (s == '约1.5米') { + return 1; + } + if (s == '约3.0米') { + return 2; + } + return 0; + } } diff --git a/lib/main/lockDetail/lockSet/catEyeSet/catEyeCustomMode/catEyeCustomMode_state.dart b/lib/main/lockDetail/lockSet/catEyeSet/catEyeCustomMode/catEyeCustomMode_state.dart index d7c56403..e519aa29 100755 --- a/lib/main/lockDetail/lockSet/catEyeSet/catEyeCustomMode/catEyeCustomMode_state.dart +++ b/lib/main/lockDetail/lockSet/catEyeSet/catEyeCustomMode/catEyeCustomMode_state.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/app_settings/app_colors.dart'; +import 'package:star_lock/main/lockDetail/lockSet/catEyeSet/catEyeSet/catEyeSet_state.dart'; import 'package:star_lock/main/lockDetail/lockSet/lockSet/lockSetInfo_entity.dart'; class CatEyeCustomModeState { //实时画面 0发生事件事查看 1实时查看 @@ -54,4 +55,8 @@ class CatEyeCustomModeState { //实时画面 0发生事件事查看 1实时查 RxString recordTime = ''.obs; //有人出现时录像 RxString detectionDistance = ''.obs; //人体侦测距离 RxString realTimeMode = ''.obs; + + + /// 猫眼配置 + Rx catEyeConfig = CatEyeSetEntity().obs; } diff --git a/lib/main/lockDetail/lockSet/catEyeSet/catEyeSet/catEyeSet_logic.dart b/lib/main/lockDetail/lockSet/catEyeSet/catEyeSet/catEyeSet_logic.dart index 1515133a..e49bf4ca 100755 --- a/lib/main/lockDetail/lockSet/catEyeSet/catEyeSet/catEyeSet_logic.dart +++ b/lib/main/lockDetail/lockSet/catEyeSet/catEyeSet/catEyeSet_logic.dart @@ -120,8 +120,6 @@ class CatEyeSetLogic extends BaseGetXController { if (state .lockSetInfoData.value.lockSettingInfo!.catEyeConfig!.isNotEmpty) { - - if (state.lockSetInfoData.value.lockSettingInfo!.catEyeConfig![0] .catEyeMode == XSConstantMacro.catEyeWorkModePowerSaving) { @@ -139,28 +137,79 @@ class CatEyeSetLogic extends BaseGetXController { XSConstantMacro.catEyeWorkModeCustom) { state.selectCatEyeWorkMode.value = '自定义模式'.tr; } - - - - state.catEyeConfig.value = CatEyeSetEntity( - catEyeMode: state.lockSetInfoData.value.lockSettingInfo! - .catEyeConfig![0].catEyeMode, - recordMode: state.lockSetInfoData.value.lockSettingInfo! - .catEyeConfig![0].catEyeModeConfig?.recordMode, - autoLightScreen: - state.lockSetInfoData.value.lockSettingInfo!.autoLightScreen, - autoLightScreenTime: - state.lockSetInfoData.value.lockSettingInfo!.autoLightScreenTime, - stayWarn: state.lockSetInfoData.value.lockSettingInfo!.stayWarn, - abnormalWarn: - state.lockSetInfoData.value.lockSettingInfo!.abnormalWarn, - ); - state.catEyeConfig.refresh(); + _getConfigAndGenerateBleData(); + updateCatEyeSetConfig(); } } return entity; } + _getConfigAndGenerateBleData() { +// 假设 state.lockSetInfoData.value.lockSettingInfo!.catEyeConfig![0].catEyeMode 是一个整数 + int originalCatEyeMode = state + .lockSetInfoData.value.lockSettingInfo!.catEyeConfig![0].catEyeMode!; + int recordMode = state.lockSetInfoData.value.lockSettingInfo! + .catEyeConfig![0].catEyeModeConfig!.recordMode == + 0 + ? 1 + : 0; + + int stayWarn = state.lockSetInfoData.value.lockSettingInfo!.stayWarn!; + int abnormalWarn = + state.lockSetInfoData.value.lockSettingInfo!.abnormalWarn!; + int autoLightScreen = + state.lockSetInfoData.value.lockSettingInfo!.autoLightScreen!; + + int recordStartTime = _handleTimeToM(state.lockSetInfoData.value + .lockSettingInfo!.catEyeConfig![0].catEyeModeConfig!.recordStartTime!); + int recordEndTime = _handleTimeToM(state.lockSetInfoData.value + .lockSettingInfo!.catEyeConfig![0].catEyeModeConfig!.recordEndTime!); + + int recordTime = _handleGetIntNumber(state.lockSetInfoData.value + .lockSettingInfo!.catEyeConfig![0].catEyeModeConfig!.recordTime!); + + int detectionDistance = _handleDetectionDistance(state + .lockSetInfoData + .value + .lockSettingInfo! + .catEyeConfig![0] + .catEyeModeConfig! + .detectionDistance!); + int realTimeMode = state.lockSetInfoData.value.lockSettingInfo! + .catEyeConfig![0].catEyeModeConfig!.realTimeMode!; + + // 根据需要调整 catEyeMode 的值 + int adjustedCatEyeMode = + originalCatEyeMode > 0 ? originalCatEyeMode - 1 : originalCatEyeMode; + int brightScreenTime = + state.lockSetInfoData.value.lockSettingInfo!.autoLightScreenTime!; + + /// 对照星锁接口文档v0.2 的猫眼设置接口,获取出猫眼的所有设置 + state.catEyeConfig.value = CatEyeSetEntity( + catEyeMode: adjustedCatEyeMode, + // 猫眼模式 看常量表 + recordMode: recordMode, + //录像时段 0全天 1自定义时间 + recordStartTime: recordStartTime, + //自定义时间需要填:recordStartTime与recordEndTime参数 + recordEndTime: recordEndTime, + //自定义时间需要填:recordStartTime与recordEndTime参数 + realTimeMode: realTimeMode, + autoLightScreenTime: brightScreenTime, + stayWarn: stayWarn, + autoLightScreen: autoLightScreen, + // 打开自动亮屏 + abnormalWarn: abnormalWarn, + // 有人出现时录像时间 + recordTime: recordTime, + // 人体检测距离 + detectionDistance: detectionDistance, + realTimePicture: realTimeMode, + ); + state.catEyeConfig.refresh(); + } + + /// 更新锁板上的猫眼配置 void updateCatEyeSetConfig() async { final int operatingMode = state.catEyeConfig.value.catEyeMode ?? 1; // 自定义模式 final int isAllDay = state.catEyeConfig.value.recordMode ?? 1; // 是否是全天 @@ -174,12 +223,12 @@ class CatEyeSetLogic extends BaseGetXController { final int realTimePicture = state.catEyeConfig.value.realTimePicture ?? 0; // 实时查看 final int automaticBrightening = - state.catEyeConfig.value.autoLightScreen ?? 0; // 打开自动亮屏 + state.catEyeConfig.value.autoLightScreen ?? 1; // 打开逗留警告 final int brightScreenTime = - state.catEyeConfig.value.autoLightScreen ?? 15; // 亮屏持续时间为15秒 + state.catEyeConfig.value.autoLightScreenTime ?? 10; // 亮屏持续时间为15秒 final int stayWarning = state.catEyeConfig.value.stayWarn ?? 1; // 打开逗留警告 final int exceptionWarning = - state.catEyeConfig.value.abnormalWarn ?? 1; // 打开异常警告 + state.catEyeConfig.value.abnormalWarn ?? 1; // 打开逗留警告 /// 生成配置,非自定义功能字段默认填充0 final List config = generateConfig( @@ -195,7 +244,6 @@ class CatEyeSetLogic extends BaseGetXController { stayWarning: stayWarning, exceptionWarning: exceptionWarning, ); - final List? privateKey = await Storage.getStringList(saveBluePrivateKey); final List getPrivateKeyList = changeStringListToIntList(privateKey!); @@ -257,7 +305,7 @@ class CatEyeSetLogic extends BaseGetXController { // 如果不是自定义模式,则填充0;否则添加对应的值 if (operatingMode != 3) { config.addAll( - [0, 0, 0, 0]); // 对应 IsAllDay, StartTime, EndTime, recordingTime + [0, 0, 0, 0, 0, 0]); // 对应 IsAllDay, StartTime, EndTime, recordingTime } else { config.add(isAllDay); config.addAll(_intToBytes(startTime, 2)); // StartTime 占用2个字节 @@ -290,4 +338,52 @@ class CatEyeSetLogic extends BaseGetXController { } return bytes; } + + int _handleTimeToM(int recordStartTime) { +// 转换为 DateTime 对象 + DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(recordStartTime); + +// 提取小时和分钟 + int hour = dateTime.hour; + int minute = dateTime.minute; + + print("时: $hour, 分: $minute"); + +// 计算从当天0点开始的分钟数 + int minutesSinceMidnight = dateTime.hour * 60 + dateTime.minute; + return minutesSinceMidnight; + } + + int _handleGetIntNumber(String recordTime) { + if (recordTime == '不录像') { + return 0; + } + if (recordTime == '立即录像') { + return 1; + } + // 使用正则表达式匹配字符串中的数字 + RegExp regExp = RegExp(r'(\d+)秒'); + Match? match = regExp.firstMatch(recordTime); + + if (match != null && match.groupCount >= 1) { + // 提取出的数字是字符串形式,需要转换成整数 + int number = int.parse(match.group(1)!); + return number; + } else { + return 0; + } + } + + int _handleDetectionDistance(String s) { + if (s == '约0.8米') { + return 0; + } + if (s == '约1.5米') { + return 1; + } + if (s == '约3.0米') { + return 2; + } + return 0; + } } diff --git a/lib/main/lockDetail/lockSet/catEyeSet/videoSlot/videoSlot_logic.dart b/lib/main/lockDetail/lockSet/catEyeSet/videoSlot/videoSlot_logic.dart index 32e2f7e4..f1e8c700 100755 --- a/lib/main/lockDetail/lockSet/catEyeSet/videoSlot/videoSlot_logic.dart +++ b/lib/main/lockDetail/lockSet/catEyeSet/videoSlot/videoSlot_logic.dart @@ -1,10 +1,16 @@ - import 'package:get/get.dart'; +import 'package:star_lock/app_settings/app_settings.dart'; +import 'package:star_lock/blue/blue_manage.dart'; +import 'package:star_lock/blue/io_protocol/io_setSupportFunctionsWithParameters.dart'; +import 'package:star_lock/blue/io_tool/io_tool.dart'; +import 'package:star_lock/main/lockDetail/lockSet/catEyeSet/catEyeSet/catEyeSet_state.dart'; import 'package:star_lock/main/lockDetail/lockSet/catEyeSet/videoSlot/videoSlot_state.dart'; import 'package:star_lock/main/lockDetail/lockSet/lockSet/lockSetInfo_entity.dart'; import 'package:star_lock/network/api_repository.dart'; +import 'package:star_lock/talk/startChart/start_chart_manage.dart'; import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/dateTool.dart'; +import 'package:star_lock/tools/storage.dart'; import 'package:star_lock/versionUndate/versionUndate_entity.dart'; class VideoSlotLogic extends BaseGetXController { @@ -12,7 +18,8 @@ class VideoSlotLogic extends BaseGetXController { // 获取锁设置信息 Future getLockSettingInfoData() async { - final LockSetInfoEntity entity = await ApiRepository.to.getLockSettingInfoData( + final LockSetInfoEntity entity = + await ApiRepository.to.getLockSettingInfoData( lockId: state.lockSetInfoData.value.lockId.toString(), ); if (entity.errorCode!.codeIsSuccessful) { @@ -34,6 +41,7 @@ class VideoSlotLogic extends BaseGetXController { state.endDate.value = DateTool().dateToHNString(state .catEyeConfigData.value.catEyeModeConfig!.recordEndTime! .toString()); + _getConfigAndGenerateBleData(); } } } @@ -47,16 +55,35 @@ class VideoSlotLogic extends BaseGetXController { : state.recordMode.value = 1; if (state.recordMode.value == 1) { - state.recordStartTime.value = - DateTool().dateToTimestamp(state.startDate.value, 0); - // 将当前时间加一天 - final DateTime tomorrow = - DateTime(DateTool().dateToTimestamp(state.startDate.value, 0)) - .add(const Duration(days: 1)); + // 获取当前日期 + DateTime now = DateTime.now(); + + // 将时间字符串解析为小时和分钟 + List parts = state.startDate.value.split(":"); + int hour = int.parse(parts[0]); + int minute = int.parse(parts[1]); + + // 创建当天指定时间的 DateTime 对象 + DateTime todayAtTime = + DateTime(now.year, now.month, now.day, hour, minute); + + List partse = state.endDate.value.split(":"); + int houre = int.parse(partse[0]); + int minutee = int.parse(partse[1]); + + // 创建当天指定时间的 DateTime 对象 + DateTime todayAtTimee = + DateTime(now.year, now.month, now.day, houre, minutee); + // 如果需要 UTC 时间戳,请使用 toUtc 方法;这里我们获取本地时间戳 + state.recordStartTime.value = todayAtTime.millisecondsSinceEpoch; + // 获取明天时间的时间戳 - state.recordEndTime.value = tomorrow.millisecondsSinceEpoch; + state.recordEndTime.value = + todayAtTimee.add(Duration(days: 1)).millisecondsSinceEpoch; + print('object'); } - final VersionUndateEntity entity = await ApiRepository.to.updateCatEyeModeConfig( + final VersionUndateEntity entity = + await ApiRepository.to.updateCatEyeModeConfig( lockId: state.lockSetInfoData.value.lockId!, catEyeConfig: [ { @@ -77,7 +104,251 @@ class VideoSlotLogic extends BaseGetXController { ); if (entity.errorCode!.codeIsSuccessful) { showToast('设置成功'.tr); + _getConfigAndGenerateBleData(); + updateCatEyeSetConfig(); Get.back(); } } + + _getConfigAndGenerateBleData() { + int originalCatEyeMode = state + .lockSetInfoData.value.lockSettingInfo!.catEyeConfig![0].catEyeMode!; + int recordMode = state.lockSetInfoData.value.lockSettingInfo! + .catEyeConfig![0].catEyeModeConfig!.recordMode == + 0 + ? 1 + : 0; + + int stayWarn = state.lockSetInfoData.value.lockSettingInfo!.stayWarn!; + int abnormalWarn = + state.lockSetInfoData.value.lockSettingInfo!.abnormalWarn!; + int autoLightScreen = + state.lockSetInfoData.value.lockSettingInfo!.autoLightScreen!; + + int recordStartTime = _handleTimeToM(state.lockSetInfoData.value + .lockSettingInfo!.catEyeConfig![0].catEyeModeConfig!.recordStartTime!); + int recordEndTime = _handleTimeToM(state.lockSetInfoData.value + .lockSettingInfo!.catEyeConfig![0].catEyeModeConfig!.recordEndTime!); + + int recordTime = _handleGetIntNumber(state.lockSetInfoData.value + .lockSettingInfo!.catEyeConfig![0].catEyeModeConfig!.recordTime!); + + int detectionDistance = _handleDetectionDistance(state + .lockSetInfoData + .value + .lockSettingInfo! + .catEyeConfig![0] + .catEyeModeConfig! + .detectionDistance!); + int realTimeMode = state.lockSetInfoData.value.lockSettingInfo! + .catEyeConfig![0].catEyeModeConfig!.realTimeMode!; + + // 根据需要调整 catEyeMode 的值 + int adjustedCatEyeMode = + originalCatEyeMode > 0 ? originalCatEyeMode - 1 : originalCatEyeMode; + int brightScreenTime = + state.lockSetInfoData.value.lockSettingInfo!.autoLightScreenTime!; + + /// 对照星锁接口文档v0.2 的猫眼设置接口,获取出猫眼的所有设置 + state.catEyeConfig.value = CatEyeSetEntity( + catEyeMode: adjustedCatEyeMode, + // 猫眼模式 看常量表 + recordMode: recordMode, + //录像时段 0全天 1自定义时间 + recordStartTime: recordStartTime, + //自定义时间需要填:recordStartTime与recordEndTime参数 + recordEndTime: recordEndTime, + //自定义时间需要填:recordStartTime与recordEndTime参数 + realTimeMode: realTimeMode, + autoLightScreenTime: brightScreenTime, + stayWarn: stayWarn, + autoLightScreen: autoLightScreen, + // 打开自动亮屏 + abnormalWarn: abnormalWarn, + // 有人出现时录像时间 + recordTime: recordTime, + // 人体检测距离 + detectionDistance: detectionDistance, + realTimePicture: realTimeMode, + ); + state.catEyeConfig.refresh(); + } + + /// 更新锁板上的猫眼配置 + void updateCatEyeSetConfig() async { + final int operatingMode = state.catEyeConfig.value.catEyeMode ?? 1; // 自定义模式 + final int isAllDay = state.catEyeConfig.value.recordMode ?? 1; // 是否是全天 + final int startTime = + state.catEyeConfig.value.recordStartTime ?? 480; // 8:00 AM + final int endTime = + state.catEyeConfig.value.recordEndTime ?? 1080; // 6:00 PM + final int recordingTime = state.catEyeConfig.value.recordTime ?? 0; // 立即录像 + final int detectionDistance = + state.catEyeConfig.value.detectionDistance ?? 0; //0:0.8米 + final int realTimePicture = + state.catEyeConfig.value.realTimePicture ?? 0; // 实时查看 + final int automaticBrightening = + state.catEyeConfig.value.autoLightScreen ?? 1; // 打开逗留警告 + final int brightScreenTime = + state.catEyeConfig.value.autoLightScreenTime ?? 10; // 亮屏持续时间为15秒 + final int stayWarning = state.catEyeConfig.value.stayWarn ?? 1; // 打开逗留警告 + final int exceptionWarning = + state.catEyeConfig.value.abnormalWarn ?? 1; // 打开逗留警告 + + /// 生成配置,非自定义功能字段默认填充0 + final List config = generateConfig( + operatingMode: operatingMode, + isAllDay: isAllDay, + startTime: startTime, + endTime: endTime, + recordingTime: recordingTime, + detectionDistance: detectionDistance, + realTimePicture: realTimePicture, + automaticBrightening: automaticBrightening, + brightScreenTime: brightScreenTime, + stayWarning: stayWarning, + exceptionWarning: exceptionWarning, + ); + final List? privateKey = + await Storage.getStringList(saveBluePrivateKey); + final List getPrivateKeyList = changeStringListToIntList(privateKey!); + + final List? token = await Storage.getStringList(saveBlueToken); + final List getTokenList = changeStringListToIntList(token!); + + final List? publicKey = + await Storage.getStringList(saveBluePublicKey); + final List getPublicKeyList = changeStringListToIntList(publicKey!); + + final command = SetSupportFunctionsWithParametersCommand( + keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(), + userID: await Storage.getUid(), + featureBit: 64, + featureParaLength: config.length, + featureData: config, + token: getTokenList, + needAuthor: 1, + publicKey: getPublicKeyList, + privateKey: getPrivateKeyList, + ); + final packageData = command.packageData(); + + // 将 List 转换为十六进制字符串 + String hexString = packageData + .map((byte) => byte.toRadixString(16).padLeft(2, '0')) + .join(' '); + + AppLog.log('open lock hexString: $hexString'); + + /// 发送星图 + StartChartManage().sendBleMessage( + bluetoothDeviceName: BlueManage().connectDeviceName, + bleStructData: packageData, + ); + } + + // 根据提供的参数生成配置列表 + List generateConfig({ + required int operatingMode, + required int isAllDay, + required int startTime, + required int endTime, + required int recordingTime, + required int detectionDistance, + required int realTimePicture, + required int automaticBrightening, + required int brightScreenTime, + required int stayWarning, + required int exceptionWarning, + }) { + // 初始化一个空的列表 + List config = []; + + // 添加 operatingMode + config.add(operatingMode); + + // 如果不是自定义模式,则填充0;否则添加对应的值 + if (operatingMode != 3) { + config.addAll( + [0, 0, 0, 0, 0, 0]); // 对应 IsAllDay, StartTime, EndTime, recordingTime + } else { + config.add(isAllDay); + config.addAll(_intToBytes(startTime, 2)); // StartTime 占用2个字节 + config.addAll(_intToBytes(endTime, 2)); // EndTime 占用2个字节 + config.add(recordingTime); + } + + // 如果不是自定义模式,则 detectionDistance 和 realTimePicture 也填充0 + if (operatingMode != 3) { + config.addAll([0, 0]); + } else { + config.add(detectionDistance); + config.add(realTimePicture); + } + + // 自动亮屏、亮屏持续时间、逗留警告、异常警告 + config.add(automaticBrightening); + config.add(brightScreenTime); + config.add(stayWarning); + config.add(exceptionWarning); + + return config; + } + + // 将整数转换为指定长度的字节表示形式 + List _intToBytes(int value, int length) { + List bytes = []; + for (int i = length - 1; i >= 0; i--) { + bytes.add((value >> (8 * i)) & 0xFF); + } + return bytes; + } + + int _handleTimeToM(int recordStartTime) { +// 转换为 DateTime 对象 + DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(recordStartTime); + +// 提取小时和分钟 + int hour = dateTime.hour; + int minute = dateTime.minute; + + print("时: $hour, 分: $minute"); + +// 计算从当天0点开始的分钟数 + int minutesSinceMidnight = dateTime.hour * 60 + dateTime.minute; + return minutesSinceMidnight; + } + + int _handleGetIntNumber(String recordTime) { + if (recordTime == '不录像') { + return 0; + } + if (recordTime == '立即录像') { + return 1; + } + // 使用正则表达式匹配字符串中的数字 + RegExp regExp = RegExp(r'(\d+)秒'); + Match? match = regExp.firstMatch(recordTime); + + if (match != null && match.groupCount >= 1) { + // 提取出的数字是字符串形式,需要转换成整数 + int number = int.parse(match.group(1)!); + return number; + } else { + return 0; + } + } + + int _handleDetectionDistance(String s) { + if (s == '约0.8米') { + return 0; + } + if (s == '约1.5米') { + return 1; + } + if (s == '约3.0米') { + return 2; + } + return 0; + } } diff --git a/lib/main/lockDetail/lockSet/catEyeSet/videoSlot/videoSlot_state.dart b/lib/main/lockDetail/lockSet/catEyeSet/videoSlot/videoSlot_state.dart index 7ad52496..601fd178 100755 --- a/lib/main/lockDetail/lockSet/catEyeSet/videoSlot/videoSlot_state.dart +++ b/lib/main/lockDetail/lockSet/catEyeSet/videoSlot/videoSlot_state.dart @@ -1,4 +1,5 @@ import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/lockSet/catEyeSet/catEyeSet/catEyeSet_state.dart'; import 'package:star_lock/main/lockDetail/lockSet/lockSet/lockSetInfo_entity.dart'; import 'package:star_lock/tools/dateTool.dart'; @@ -28,4 +29,8 @@ class VideoSlotState { //实时画面 0发生事件事查看 1实时查看 RxString recordTime = ''.obs; //有人出现时录像 RxInt detectionDistance = 0.obs; //人体侦测距离 RxInt realTimeMode = 0.obs; + + + /// 猫眼配置 + Rx catEyeConfig = CatEyeSetEntity().obs; } diff --git a/lib/main/lockDetail/lockSet/liveVideo/liveVideo_logic.dart b/lib/main/lockDetail/lockSet/liveVideo/liveVideo_logic.dart index ebb57c15..b5785515 100755 --- a/lib/main/lockDetail/lockSet/liveVideo/liveVideo_logic.dart +++ b/lib/main/lockDetail/lockSet/liveVideo/liveVideo_logic.dart @@ -1,8 +1,15 @@ import 'package:get/get.dart'; +import 'package:star_lock/app_settings/app_settings.dart'; +import 'package:star_lock/blue/blue_manage.dart'; +import 'package:star_lock/blue/io_protocol/io_setSupportFunctionsWithParameters.dart'; +import 'package:star_lock/blue/io_tool/io_tool.dart'; +import 'package:star_lock/main/lockDetail/lockSet/catEyeSet/catEyeSet/catEyeSet_state.dart'; import 'package:star_lock/main/lockDetail/lockSet/liveVideo/liveVideo_state.dart'; import 'package:star_lock/main/lockDetail/lockSet/lockSet/lockSetInfo_entity.dart'; import 'package:star_lock/network/api_repository.dart'; +import 'package:star_lock/talk/startChart/start_chart_manage.dart'; import 'package:star_lock/tools/baseGetXController.dart'; +import 'package:star_lock/tools/storage.dart'; import 'package:star_lock/versionUndate/versionUndate_entity.dart'; class LiveVideoLogic extends BaseGetXController { @@ -10,7 +17,8 @@ class LiveVideoLogic extends BaseGetXController { // 获取锁设置信息 Future getLockSettingInfoData() async { - final LockSetInfoEntity entity = await ApiRepository.to.getLockSettingInfoData( + final LockSetInfoEntity entity = + await ApiRepository.to.getLockSettingInfoData( lockId: state.lockSetInfoData.value.lockId.toString(), ); if (entity.errorCode!.codeIsSuccessful) { @@ -28,6 +36,8 @@ class LiveVideoLogic extends BaseGetXController { } else { state.isLiveView.value = false; } + _getConfigAndGenerateBleData(); + updateCatEyeSetConfig(); } } } @@ -36,7 +46,8 @@ class LiveVideoLogic extends BaseGetXController { //设置猫眼工作模式 Future updateCatEyeModeConfig() async { - final VersionUndateEntity entity = await ApiRepository.to.updateCatEyeModeConfig( + final VersionUndateEntity entity = + await ApiRepository.to.updateCatEyeModeConfig( lockId: state.lockSetInfoData.value.lockId ?? 0, catEyeConfig: [ { @@ -59,7 +70,251 @@ class LiveVideoLogic extends BaseGetXController { ); if (entity.errorCode!.codeIsSuccessful) { showToast('设置成功'.tr); + _getConfigAndGenerateBleData(); + updateCatEyeSetConfig(); Get.back(); } } + + _getConfigAndGenerateBleData() { + int originalCatEyeMode = state + .lockSetInfoData.value.lockSettingInfo!.catEyeConfig![0].catEyeMode!; + int recordMode = state.lockSetInfoData.value.lockSettingInfo! + .catEyeConfig![0].catEyeModeConfig!.recordMode == + 0 + ? 1 + : 0; + + int stayWarn = state.lockSetInfoData.value.lockSettingInfo!.stayWarn!; + int abnormalWarn = + state.lockSetInfoData.value.lockSettingInfo!.abnormalWarn!; + int autoLightScreen = + state.lockSetInfoData.value.lockSettingInfo!.autoLightScreen!; + + int recordStartTime = _handleTimeToM(state.lockSetInfoData.value + .lockSettingInfo!.catEyeConfig![0].catEyeModeConfig!.recordStartTime!); + int recordEndTime = _handleTimeToM(state.lockSetInfoData.value + .lockSettingInfo!.catEyeConfig![0].catEyeModeConfig!.recordEndTime!); + + int recordTime = _handleGetIntNumber(state.lockSetInfoData.value + .lockSettingInfo!.catEyeConfig![0].catEyeModeConfig!.recordTime!); + + int detectionDistance = _handleDetectionDistance(state + .lockSetInfoData + .value + .lockSettingInfo! + .catEyeConfig![0] + .catEyeModeConfig! + .detectionDistance!); + int realTimeMode = state.lockSetInfoData.value.lockSettingInfo! + .catEyeConfig![0].catEyeModeConfig!.realTimeMode!; + + // 根据需要调整 catEyeMode 的值 + int adjustedCatEyeMode = + originalCatEyeMode > 0 ? originalCatEyeMode - 1 : originalCatEyeMode; + int brightScreenTime = + state.lockSetInfoData.value.lockSettingInfo!.autoLightScreenTime!; + + /// 对照星锁接口文档v0.2 的猫眼设置接口,获取出猫眼的所有设置 + state.catEyeConfig.value = CatEyeSetEntity( + catEyeMode: adjustedCatEyeMode, + // 猫眼模式 看常量表 + recordMode: recordMode, + //录像时段 0全天 1自定义时间 + recordStartTime: recordStartTime, + //自定义时间需要填:recordStartTime与recordEndTime参数 + recordEndTime: recordEndTime, + //自定义时间需要填:recordStartTime与recordEndTime参数 + realTimeMode: realTimeMode, + autoLightScreenTime: brightScreenTime, + stayWarn: stayWarn, + autoLightScreen: autoLightScreen, + // 打开自动亮屏 + abnormalWarn: abnormalWarn, + // 有人出现时录像时间 + recordTime: recordTime, + // 人体检测距离 + detectionDistance: detectionDistance, + realTimePicture: realTimeMode, + ); + state.catEyeConfig.refresh(); + } + + /// 更新锁板上的猫眼配置 + void updateCatEyeSetConfig() async { + final int operatingMode = state.catEyeConfig.value.catEyeMode ?? 1; // 自定义模式 + final int isAllDay = state.catEyeConfig.value.recordMode ?? 1; // 是否是全天 + final int startTime = + state.catEyeConfig.value.recordStartTime ?? 480; // 8:00 AM + final int endTime = + state.catEyeConfig.value.recordEndTime ?? 1080; // 6:00 PM + final int recordingTime = state.catEyeConfig.value.recordTime ?? 0; // 立即录像 + final int detectionDistance = + state.catEyeConfig.value.detectionDistance ?? 0; //0:0.8米 + final int realTimePicture = + state.catEyeConfig.value.realTimePicture ?? 0; // 实时查看 + final int automaticBrightening = + state.catEyeConfig.value.autoLightScreen ?? 1; // 打开逗留警告 + final int brightScreenTime = + state.catEyeConfig.value.autoLightScreenTime ?? 10; // 亮屏持续时间为15秒 + final int stayWarning = state.catEyeConfig.value.stayWarn ?? 1; // 打开逗留警告 + final int exceptionWarning = + state.catEyeConfig.value.abnormalWarn ?? 1; // 打开逗留警告 + + /// 生成配置,非自定义功能字段默认填充0 + final List config = generateConfig( + operatingMode: operatingMode, + isAllDay: isAllDay, + startTime: startTime, + endTime: endTime, + recordingTime: recordingTime, + detectionDistance: detectionDistance, + realTimePicture: realTimePicture, + automaticBrightening: automaticBrightening, + brightScreenTime: brightScreenTime, + stayWarning: stayWarning, + exceptionWarning: exceptionWarning, + ); + final List? privateKey = + await Storage.getStringList(saveBluePrivateKey); + final List getPrivateKeyList = changeStringListToIntList(privateKey!); + + final List? token = await Storage.getStringList(saveBlueToken); + final List getTokenList = changeStringListToIntList(token!); + + final List? publicKey = + await Storage.getStringList(saveBluePublicKey); + final List getPublicKeyList = changeStringListToIntList(publicKey!); + + final command = SetSupportFunctionsWithParametersCommand( + keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(), + userID: await Storage.getUid(), + featureBit: 64, + featureParaLength: config.length, + featureData: config, + token: getTokenList, + needAuthor: 1, + publicKey: getPublicKeyList, + privateKey: getPrivateKeyList, + ); + final packageData = command.packageData(); + + // 将 List 转换为十六进制字符串 + String hexString = packageData + .map((byte) => byte.toRadixString(16).padLeft(2, '0')) + .join(' '); + + AppLog.log('open lock hexString: $hexString'); + + /// 发送星图 + StartChartManage().sendBleMessage( + bluetoothDeviceName: BlueManage().connectDeviceName, + bleStructData: packageData, + ); + } + + // 根据提供的参数生成配置列表 + List generateConfig({ + required int operatingMode, + required int isAllDay, + required int startTime, + required int endTime, + required int recordingTime, + required int detectionDistance, + required int realTimePicture, + required int automaticBrightening, + required int brightScreenTime, + required int stayWarning, + required int exceptionWarning, + }) { + // 初始化一个空的列表 + List config = []; + + // 添加 operatingMode + config.add(operatingMode); + + // 如果不是自定义模式,则填充0;否则添加对应的值 + if (operatingMode != 3) { + config.addAll( + [0, 0, 0, 0, 0, 0]); // 对应 IsAllDay, StartTime, EndTime, recordingTime + } else { + config.add(isAllDay); + config.addAll(_intToBytes(startTime, 2)); // StartTime 占用2个字节 + config.addAll(_intToBytes(endTime, 2)); // EndTime 占用2个字节 + config.add(recordingTime); + } + + // 如果不是自定义模式,则 detectionDistance 和 realTimePicture 也填充0 + if (operatingMode != 3) { + config.addAll([0, 0]); + } else { + config.add(detectionDistance); + config.add(realTimePicture); + } + + // 自动亮屏、亮屏持续时间、逗留警告、异常警告 + config.add(automaticBrightening); + config.add(brightScreenTime); + config.add(stayWarning); + config.add(exceptionWarning); + + return config; + } + + // 将整数转换为指定长度的字节表示形式 + List _intToBytes(int value, int length) { + List bytes = []; + for (int i = length - 1; i >= 0; i--) { + bytes.add((value >> (8 * i)) & 0xFF); + } + return bytes; + } + + int _handleTimeToM(int recordStartTime) { +// 转换为 DateTime 对象 + DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(recordStartTime); + +// 提取小时和分钟 + int hour = dateTime.hour; + int minute = dateTime.minute; + + print("时: $hour, 分: $minute"); + +// 计算从当天0点开始的分钟数 + int minutesSinceMidnight = dateTime.hour * 60 + dateTime.minute; + return minutesSinceMidnight; + } + + int _handleGetIntNumber(String recordTime) { + if (recordTime == '不录像') { + return 0; + } + if (recordTime == '立即录像') { + return 1; + } + // 使用正则表达式匹配字符串中的数字 + RegExp regExp = RegExp(r'(\d+)秒'); + Match? match = regExp.firstMatch(recordTime); + + if (match != null && match.groupCount >= 1) { + // 提取出的数字是字符串形式,需要转换成整数 + int number = int.parse(match.group(1)!); + return number; + } else { + return 0; + } + } + + int _handleDetectionDistance(String s) { + if (s == '约0.8米') { + return 0; + } + if (s == '约1.5米') { + return 1; + } + if (s == '约3.0米') { + return 2; + } + return 0; + } } diff --git a/lib/main/lockDetail/lockSet/liveVideo/liveVideo_state.dart b/lib/main/lockDetail/lockSet/liveVideo/liveVideo_state.dart index f35330d2..52366d35 100755 --- a/lib/main/lockDetail/lockSet/liveVideo/liveVideo_state.dart +++ b/lib/main/lockDetail/lockSet/liveVideo/liveVideo_state.dart @@ -1,4 +1,5 @@ import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/lockSet/catEyeSet/catEyeSet/catEyeSet_state.dart'; import 'package:star_lock/main/lockDetail/lockSet/lockSet/lockSetInfo_entity.dart'; class LiveVideoState { @@ -15,4 +16,7 @@ class LiveVideoState { RxInt realTimeMode = 0.obs; //实时画面 0发生事件事查看 1实时查看 Rx lockSetInfoData = LockSetInfoData().obs; Rx catEyeConfigData = CatEyeConfig().obs; + + /// 猫眼配置 + Rx catEyeConfig = CatEyeSetEntity().obs; } diff --git a/lib/talk/startChart/handle/impl/udp_ble_passthrough_handler.dart b/lib/talk/startChart/handle/impl/udp_ble_passthrough_handler.dart index 42339787..b582f421 100644 --- a/lib/talk/startChart/handle/impl/udp_ble_passthrough_handler.dart +++ b/lib/talk/startChart/handle/impl/udp_ble_passthrough_handler.dart @@ -57,6 +57,8 @@ class UdpBlePassThroughHandler extends ScpMessageBaseHandle AppLog.log('收到开门请求命令回复'); _replyOpenLock(reply); } + + }); } diff --git a/lib/talk/startChart/start_chart_manage.dart b/lib/talk/startChart/start_chart_manage.dart index 78c23aa5..52c91dad 100644 --- a/lib/talk/startChart/start_chart_manage.dart +++ b/lib/talk/startChart/start_chart_manage.dart @@ -942,7 +942,7 @@ class StartChartManage { // 组装上线消息 final message = MessageCommand.bleMessage( FromPeerId: FromPeerId, - ToPeerId: ToPeerId, + ToPeerId: lockPeerId, MessageId: MessageCommand.getNextMessageId(ToPeerId, increment: true), bluetoothDeviceName: bluetoothDeviceName, bleStructData: bleStructData,