集成接口 开始执行任务的领域层和数据层和UI层的开发啊(待测试)
集成功能 暂停 取消功能 恢复功能的接口的领域层和数据层的开发 下一步待集成到页面上 优化功能,优化了接口异常和未知异常对页面渲染的影响对用户的体验的不好情况。具体通过弹窗友好提示! 优化更新了tcp指示灯点击出现机器状态中添加选中设备的编号 方便用户使用的明白明了!。 优化更新关闭了tcp重连操作内链条中的获取用户设备和切换设备操作项。 调整了获取无人机状态信息的更新频率 为14秒一次
This commit is contained in:
@@ -61,24 +61,26 @@ class _HomePageState extends State<HomePage> {
|
||||
// 🔥 自动选中第一个设备(保证是最新的)
|
||||
devicesCubit.selectDevice(firstDevice);
|
||||
|
||||
// 🔥 关键修复:首页不再自动连接TCP,改为选择设备时才连接
|
||||
// 连接 TCP
|
||||
final tcpClient = GetIt.instance<TcpClient>();
|
||||
if (!tcpClient.isConnected) {
|
||||
tcpClient.connectBySwitch(host: TCPConsts.TCP_IP, port: TCPConsts.TCP_PORT, deviceName: firstDevice.deviceName).then((_) {
|
||||
debugPrint('✅ [HomePage] TCP 连接成功');
|
||||
tcpClient.startHeartbeat(interval: const Duration(seconds: 4));
|
||||
|
||||
// 🔥 关键:TCP 连接成功后,主动请求权限以激活服务器的推送机制
|
||||
final remoteRepo = GetIt.instance<RemoteControlRepository>();
|
||||
remoteRepo.requestControlPermission(firstDevice.deviceName, "app");
|
||||
debugPrint('✅ [HomePage] 已发送权限请求,激活服务器推送');
|
||||
});
|
||||
} else {
|
||||
// 🔥 TCP 已连接,也要发送权限请求
|
||||
final remoteRepo = GetIt.instance<RemoteControlRepository>();
|
||||
remoteRepo.requestControlPermission(firstDevice.deviceName, "app");
|
||||
debugPrint('✅ [HomePage] TCP 已连接,已发送权限请求');
|
||||
}
|
||||
// final tcpClient = GetIt.instance<TcpClient>();
|
||||
// if (!tcpClient.isConnected) {
|
||||
// tcpClient.connectBySwitch(host: TCPConsts.TCP_IP, port: TCPConsts.TCP_PORT, deviceName: firstDevice.deviceName).then((_) {
|
||||
// debugPrint('✅ [HomePage] TCP 连接成功');
|
||||
// tcpClient.startHeartbeat(interval: const Duration(seconds: 4));
|
||||
//
|
||||
// // 🔥 关键:TCP 连接成功后,主动请求权限以激活服务器的推送机制
|
||||
// final remoteRepo = GetIt.instance<RemoteControlRepository>();
|
||||
// remoteRepo.requestControlPermission(firstDevice.deviceName, "app");
|
||||
// debugPrint('✅ [HomePage] 已发送权限请求,激活服务器推送');
|
||||
// });
|
||||
// } else {
|
||||
// // 🔥 TCP 已连接,也要发送权限请求
|
||||
// final remoteRepo = GetIt.instance<RemoteControlRepository>();
|
||||
// remoteRepo.requestControlPermission(firstDevice.deviceName, "app");
|
||||
// debugPrint('✅ [HomePage] TCP 已连接,已发送权限请求');
|
||||
// }
|
||||
debugPrint('ℹ️ [HomePage] TCP 连接已移至选择设备时执行');
|
||||
}
|
||||
} catch (e) {
|
||||
setState(() => _isDevicesLoading = false);
|
||||
|
||||
Reference in New Issue
Block a user