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)}"); } // 拼装数据 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/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 ?? ''); - } } 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/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/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/star_chart_manage.dart b/lib/talk/starChart/star_chart_manage.dart index 4ee12c03..10a94cb8 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, 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,