From 9ca11199745cf37ee5fb6e8960577543b254b9bd Mon Sep 17 00:00:00 2001 From: liyi Date: Thu, 6 Feb 2025 10:03:18 +0800 Subject: [PATCH 1/4] =?UTF-8?q?fix:=E5=8F=96=E6=B6=88=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=89=93=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/blue/io_sender.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/blue/io_sender.dart b/lib/blue/io_sender.dart index 67a67e7b..d67212e5 100755 --- a/lib/blue/io_sender.dart +++ b/lib/blue/io_sender.dart @@ -35,7 +35,6 @@ abstract class SenderProtocol extends IOData { void printLog(List data) { AppLog.log( "App -> 锁,指令类型:${commandType!.typeName} ${commandType!.typeValue == 0x3030 ? '子命令:${data[3]}' : ''} \n参数是:\n${toString()} \n加密之前数据是:\n$data 长度是:${data.length}"); - AppLog.log("子命令数据是:${data.sublist(66, 79)}"); } // 拼装数据 From 492b2e713d5a5183e82ebfe6ff779918960a2379 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CDaisyWu=E2=80=9D?= <“18682150237@163.com”> Date: Thu, 6 Feb 2025 11:09:03 +0800 Subject: [PATCH 2/4] =?UTF-8?q?fix:=20=E6=98=9F=E5=9B=BE=EF=BC=9A1,?= =?UTF-8?q?=E7=BB=9F=E4=B8=80=E9=A1=B9=E7=9B=AE=E4=B8=AD=E6=98=9F=E5=9B=BE?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E8=8E=B7=E5=8F=96=E9=80=94=E5=BE=84=E5=8F=8A?= =?UTF-8?q?=E6=9C=89=E5=8F=98=E5=8C=96=E6=9B=B4=E6=96=B0loginData2,?= =?UTF-8?q?=E6=98=9F=E5=9B=BE=EF=BC=9A=E5=AE=8C=E6=88=90=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=8F=8A=E9=AA=8C=E8=AF=81APP=E9=A6=96=E6=AC=A1=E6=B3=A8?= =?UTF-8?q?=E5=86=8C=E8=B4=A6=E5=8F=B7=E7=99=BB=E5=BD=95=E5=90=8E=E6=9C=AA?= =?UTF-8?q?=E4=B8=8A=E7=BA=BF=E5=AF=BC=E8=87=B4=E5=91=BC=E5=8F=AB=E5=AF=B9?= =?UTF-8?q?=E8=AE=B2=E6=97=A0=E5=8F=8D=E5=BA=94=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/login/login/entity/LoginData.dart | 10 +++++++ lib/login/login/starLock_login_logic.dart | 19 ++++++++----- .../lockMain/xhj/lockMain_xhj_logic.dart | 4 ++- lib/talk/starChart/star_chart_manage.dart | 27 ++++++++++--------- 4 files changed, 40 insertions(+), 20 deletions(-) diff --git a/lib/login/login/entity/LoginData.dart b/lib/login/login/entity/LoginData.dart index 8c269cf0..fc558401 100755 --- a/lib/login/login/entity/LoginData.dart +++ b/lib/login/login/entity/LoginData.dart @@ -1,4 +1,5 @@ import 'package:star_lock/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_entity.dart'; +import 'package:star_lock/talk/starChart/entity/star_chart_register_node_entity.dart'; class LoginData { LoginData( @@ -63,4 +64,13 @@ class LoginData { } return map; } + + void updateStarchart( + StarChartRegisterNodeEntity starChartRegisterNodeEntity) { + starchart = Starchart( + starchartId: starChartRegisterNodeEntity.peer?.id, + starchartPeerPublicKey: starChartRegisterNodeEntity.peer?.publicKey, + starchartPeerPrivateKey: starChartRegisterNodeEntity.peer?.privateKey, + ); + } } diff --git a/lib/login/login/starLock_login_logic.dart b/lib/login/login/starLock_login_logic.dart index 8518669b..6f7cff26 100755 --- a/lib/login/login/starLock_login_logic.dart +++ b/lib/login/login/starLock_login_logic.dart @@ -58,17 +58,22 @@ class StarLockLoginLogic extends BaseGetXController { 'login_res': '成功', }); - Storage.saveLoginData(entity.data); - Storage.setBool(saveIsVip, entity.data!.isVip == 1); //如已有星图配置则保存 无需重复注册节点及重复绑定 if (entity.data!.starchart != null) { final Starchart starChart = entity.data!.starchart!; - Storage.saveStarChartRegisterNodeInfo(StarChartRegisterNodeEntity( - peer: PeerData( - id: starChart.starchartId, - publicKey: starChart.starchartPeerPublicKey, - privateKey: starChart.starchartPeerPrivateKey))); + final StarChartRegisterNodeEntity starChartRegisterNodeEntity = + StarChartRegisterNodeEntity( + peer: PeerData( + id: starChart.starchartId, + publicKey: starChart.starchartPeerPublicKey, + privateKey: starChart.starchartPeerPrivateKey, + ), + ); + Storage.saveStarChartRegisterNodeInfo(starChartRegisterNodeEntity); + entity.data!.updateStarchart(starChartRegisterNodeEntity); } + Storage.saveLoginData(entity.data); + Storage.setBool(saveIsVip, entity.data!.isVip == 1); eventBus.fire(MineInfoChangeRefreshUI()); if (Get.isRegistered()) { Get.find().getStarLockInfo(isUnShowLoading: true); diff --git a/lib/main/lockMian/lockMain/xhj/lockMain_xhj_logic.dart b/lib/main/lockMian/lockMain/xhj/lockMain_xhj_logic.dart index 0cea9990..e541f82a 100755 --- a/lib/main/lockMian/lockMain/xhj/lockMain_xhj_logic.dart +++ b/lib/main/lockMian/lockMain/xhj/lockMain_xhj_logic.dart @@ -53,9 +53,11 @@ class LockMainXHJLogic extends BaseGetXController { } } if (entity.data!.starchart != null) { - if (entity.data!.starchart!.starchartId!.isEmpty) { + if (entity.data!.starchart!.starchartId == null) { bindStarChart(); } + } else { + StartChartManage().init(); } } } diff --git a/lib/talk/starChart/star_chart_manage.dart b/lib/talk/starChart/star_chart_manage.dart index 095c27ac..ee9c8781 100644 --- a/lib/talk/starChart/star_chart_manage.dart +++ b/lib/talk/starChart/star_chart_manage.dart @@ -146,23 +146,23 @@ class StartChartManage { await _requestStarChartRegisterNode(); await _saveStarChartRegisterNodeToStorage(requestStarChartRegisterNode); FromPeerId = requestStarChartRegisterNode.peer!.id ?? ''; - bindUserStarchart(); + bindUserStarchart(requestStarChartRegisterNode); } } //绑定星图配置 - Future bindUserStarchart() async { + Future bindUserStarchart( + StarChartRegisterNodeEntity requestStarChartRegisterNode) async { try { - final StarChartRegisterNodeEntity? registerNodeEntity = - await Storage.getStarChartRegisterNodeInfo(); - final LoginEntity entity = await ApiRepository.to.bindUserStarchart( - starchartId: registerNodeEntity?.peer?.id ?? '', - starchartPeerPublicKey: registerNodeEntity?.peer?.publicKey ?? '', - starchartPeerPrivateKey: registerNodeEntity?.peer?.privateKey ?? '', + starchartId: requestStarChartRegisterNode.peer?.id ?? '', + starchartPeerPublicKey: + requestStarChartRegisterNode.peer?.publicKey ?? '', + starchartPeerPrivateKey: + requestStarChartRegisterNode.peer?.privateKey ?? '', ); - registerNodeEntity?.peer?.id = entity.data?.starchart?.starchartId; - await Storage.saveStarChartRegisterNodeInfo(registerNodeEntity!); + requestStarChartRegisterNode.peer?.id = + entity.data?.starchart?.starchartId; if (entity.errorCode!.codeIsSuccessful) { AppLog.log('绑定成功'); } else { @@ -762,6 +762,9 @@ class StartChartManage { StarChartRegisterNodeEntity starChartRegisterNodeEntity) async { if (starChartRegisterNodeEntity != null) { await Storage.saveStarChartRegisterNodeInfo(starChartRegisterNodeEntity); + final LoginData? loginData = await Storage.getLoginData(); + loginData?.updateStarchart(starChartRegisterNodeEntity); + Storage.saveLoginData(loginData); } } @@ -779,9 +782,9 @@ class StartChartManage { final RelayInfoEntity? relayInfoEntity = await Storage.getRelayInfo(); // 获取公钥 - final publicKey = await getPublicKey(); + final String publicKey = await getPublicKey(); // 获取私钥 - final privateKey = await getPrivateKey(); + final String privateKey = await getPrivateKey(); // 生成签名 final sign = await DoSign().generateSign( currentTimestamp: relayInfoEntity!.time ?? 0, From 2f00a6280dc7c4cd714a7409c10e408d9ca801ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CDaisyWu=E2=80=9D?= <“18682150237@163.com”> Date: Thu, 6 Feb 2025 18:44:55 +0800 Subject: [PATCH 3/4] =?UTF-8?q?feat:=201=EF=BC=8C=E6=B3=A8=E9=87=8A?= =?UTF-8?q?=E6=8E=89=E6=97=A7=E7=9A=84udp=E6=B5=81=E7=A8=8B2=EF=BC=8C?= =?UTF-8?q?=E6=B3=A8=E9=87=8A=E6=8E=89=E5=AF=B9=E8=AE=B2=E6=94=B6=E5=8F=91?= =?UTF-8?q?=E5=8C=85=E8=B0=83=E8=AF=95=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lockMian/lockMain/lockMain_logic.dart | 2 +- lib/mine/mineSet/mineSet/mineSet_logic.dart | 2 +- .../views/talkView/talk_view_page.dart | 66 +++++++++---------- 3 files changed, 35 insertions(+), 35 deletions(-) diff --git a/lib/main/lockMian/lockMain/lockMain_logic.dart b/lib/main/lockMian/lockMain/lockMain_logic.dart index c2de6a69..75a0701f 100755 --- a/lib/main/lockMian/lockMain/lockMain_logic.dart +++ b/lib/main/lockMian/lockMain/lockMain_logic.dart @@ -313,7 +313,7 @@ class LockMainLogic extends BaseGetXController { // 开启UDP // AppLog.log('onReady() LockMainLogic'); - UdpHelp().openUDP(); + // UdpHelp().openUDP(); BlueManage(); } diff --git a/lib/mine/mineSet/mineSet/mineSet_logic.dart b/lib/mine/mineSet/mineSet/mineSet_logic.dart index 3ee8ced0..04dee223 100755 --- a/lib/mine/mineSet/mineSet/mineSet_logic.dart +++ b/lib/mine/mineSet/mineSet/mineSet_logic.dart @@ -141,7 +141,7 @@ class MineSetLogic extends BaseGetXController { 'logout_result': '成功', }); - UdpHelp().closeUDP(); + // UdpHelp().closeUDP(); logOut(); StoreService.to.saveLanguageCode(''); diff --git a/lib/talk/starChart/views/talkView/talk_view_page.dart b/lib/talk/starChart/views/talkView/talk_view_page.dart index b7a4653a..f4c3bd23 100644 --- a/lib/talk/starChart/views/talkView/talk_view_page.dart +++ b/lib/talk/starChart/views/talkView/talk_view_page.dart @@ -255,39 +255,39 @@ class _TalkViewPageState extends State ) : Container()), //ToDo: 增加对讲调试、正式可删除 - Visibility( - visible: true, - child: Positioned( - top: 20, // 设置在顶部 - left: 20, - right: 20, // 确保调试信息在屏幕宽度内居中 - child: Container( - height: 100, // 设置高度为 100 - color: Colors.black.withOpacity(0.5), // 可选:设置背景颜色和透明度 - padding: const EdgeInsets.all(10), // 可选:设置内边距 - child: Consumer( - builder: (BuildContext context, DebugInfoModel debugInfo, - Widget? child) { - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - 'recv ${debugInfo.recvDataRate}KB/s [${debugInfo.recvPacketCount}]', - style: const TextStyle( - color: Colors.white), // 设置文本颜色为白色 - ), - Text( - 'send ${debugInfo.sendDataRate}KB/s [${debugInfo.sendPacketCount}]', - style: const TextStyle( - color: Colors.white), // 设置文本颜色为白色 - ), - ], - ); - }, - ), - ), - ), - ), + // Visibility( + // visible: true, + // child: Positioned( + // top: 20, // 设置在顶部 + // left: 20, + // right: 20, // 确保调试信息在屏幕宽度内居中 + // child: Container( + // height: 100, // 设置高度为 100 + // color: Colors.black.withOpacity(0.5), // 可选:设置背景颜色和透明度 + // padding: const EdgeInsets.all(10), // 可选:设置内边距 + // child: Consumer( + // builder: (BuildContext context, DebugInfoModel debugInfo, + // Widget? child) { + // return Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // Text( + // 'recv ${debugInfo.recvDataRate}KB/s [${debugInfo.recvPacketCount}]', + // style: const TextStyle( + // color: Colors.white), // 设置文本颜色为白色 + // ), + // Text( + // 'send ${debugInfo.sendDataRate}KB/s [${debugInfo.sendPacketCount}]', + // style: const TextStyle( + // color: Colors.white), // 设置文本颜色为白色 + // ), + // ], + // ); + // }, + // ), + // ), + // ), + // ), // 添加服务器延迟检测 // Positioned( // top: 120, From 72e2e3f57e82bcf86000fa06781bdbcc7f7c9632 Mon Sep 17 00:00:00 2001 From: liyi Date: Fri, 7 Feb 2025 10:05:58 +0800 Subject: [PATCH 4/4] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E8=BF=9B=E5=85=A5?= =?UTF-8?q?=E9=94=81=E8=AF=A6=E6=83=85=E9=A1=B5=E6=8F=90=E7=A4=BA=E2=80=9C?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E4=B8=8D=E5=AD=98=E5=9C=A8=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lockDetail/lockDetail_logic.dart | 29 +++++++++++++++ .../lockDetail/lockDetail_page.dart | 36 ++----------------- 2 files changed, 31 insertions(+), 34 deletions(-) diff --git a/lib/main/lockDetail/lockDetail/lockDetail_logic.dart b/lib/main/lockDetail/lockDetail/lockDetail_logic.dart index 163ded98..b5d3a1aa 100755 --- a/lib/main/lockDetail/lockDetail/lockDetail_logic.dart +++ b/lib/main/lockDetail/lockDetail/lockDetail_logic.dart @@ -10,6 +10,7 @@ import 'package:star_lock/apm/apm_helper.dart'; import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart'; import 'package:star_lock/login/login/entity/LoginEntity.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart'; +import 'package:star_lock/main/lockDetail/lockDetail/device_network_info.dart'; import 'package:star_lock/main/lockDetail/lockSet/lockTime/getServerDatetime_entity.dart'; import 'package:star_lock/main/lockMian/entity/lockListInfo_entity.dart'; import 'package:star_lock/talk/starChart/constant/talk_status.dart'; @@ -744,12 +745,40 @@ class LockDetailLogic extends BaseGetXController { eventBus.fire(RefreshLockDetailInfoDataEvent()); } + /// 请求设备网络信息并设置 + void _requestDeviceNetworkInfo() async { + final DeviceNetwork deviceNetworkInfo = + await ApiRepository.to.getDeviceNetwork( + deviceType: 2, + deviceMac: state.keyInfos.value.mac!, + ); + if (deviceNetworkInfo.data?.wifiName == null || + deviceNetworkInfo.data?.wifiName == '') { + return; + } else { + final peerId = deviceNetworkInfo?.data?.peerId; + if (peerId == null || peerId.isEmpty || peerId == '') { + throw Exception('设备peerId为空'); + } + // 设置锁的peerID + StartChartManage().lockPeerId = peerId; + } + } + + /// 发送监控消息 + void sendMonitorMessage() { + // 发送监控id + StartChartManage().startCallRequestMessageTimer( + ToPeerId: StartChartManage().lockPeerId ?? ''); + } + @override Future onReady() async { super.onReady(); getServerDatetime(); await PermissionDialog.request(Permission.location); await PermissionDialog.requestBluetooth(); + _requestDeviceNetworkInfo(); } @override diff --git a/lib/main/lockDetail/lockDetail/lockDetail_page.dart b/lib/main/lockDetail/lockDetail/lockDetail_page.dart index ee6895aa..c57b3cbf 100755 --- a/lib/main/lockDetail/lockDetail/lockDetail_page.dart +++ b/lib/main/lockDetail/lockDetail/lockDetail_page.dart @@ -68,7 +68,7 @@ class _LockDetailPageState extends State lockListInfoItemEntity: widget.lockListInfoItemEntity, isOnlyOneData: widget.isOnlyOneData); - _handleLockMonitor2(); + } @override @@ -1164,7 +1164,7 @@ class _LockDetailPageState extends State showWidgetArr.add( bottomItem('images/main/icon_catEyes.png', '监控'.tr, state.bottomBtnisEable.value, () async { - await _handleLockMonitor(); + logic.sendMonitorMessage(); }), ); } @@ -1572,36 +1572,4 @@ class _LockDetailPageState extends State BlueManage().disconnect(); } - Future _handleLockMonitor2() 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); - if (deviceNetworkInfo.data?.wifiName == null || - deviceNetworkInfo.data?.wifiName == '') { - return; - } else { - final peerId = deviceNetworkInfo?.data?.peerId; - if (peerId == null || peerId.isEmpty || peerId == '') { - throw Exception('设备peerId为空'); - } - // 设置锁的peerID - StartChartManage().lockPeerId = peerId; - } - } - } - } - - Future _handleLockMonitor() async { - // 发送监控id - StartChartManage().startCallRequestMessageTimer( - ToPeerId: StartChartManage().lockPeerId ?? ''); - } }