1更新无人机的摄像头视频显示的条件为在离线情况下的自动刷新+下拉刷新的机制。

2更新优化去除原有路径规划的初始化阶段的获取设备的接口请求,改为使用新的 targetDevice。
3修改无人机机场的在线状态简化为在线和离线。去掉机场二字。
4.更新同一账号同时段登录,被强制下线的友好提示!
This commit is contained in:
2026-06-17 13:46:30 +08:00
parent 71aea48d9f
commit 443ce601a0
6 changed files with 192 additions and 666 deletions

View File

@@ -6,6 +6,7 @@ import 'dart:typed_data';
import 'package:flutter/cupertino.dart';
import 'package:get_it/get_it.dart';
import 'package:maibu_satabot_v2/features/devices/data/repositories/route_planning_repository_impl.dart';
import 'package:maibu_satabot_v2/features/remote_control/presentation/bloc/remote_control_cubit.dart';
import '../../../features/auth/data/datasources/auth_tcp_datasource.dart';
import '../../../features/devices/data/models/route_plan_send_entity.dart';
@@ -273,11 +274,40 @@ class TcpClient {
return;
}
_reconnectTimer = Timer(const Duration(seconds: 5), () {
_reconnectTimer = Timer(const Duration(seconds: 5), () async {
_reconnectTimer = null;
//debugPrint('⏰ 被动-定时器触发,开始执行重连...');
_logger.logWithLevel('⏰ 被动-定时器触发,开始执行重连...', shouldLog: true);
connectBySwitch(host: _lastHost!, port: _lastPort!, deviceName: devname);
// 🔥 修复:重连时使用 RemoteControlCubit.targetDevice,而不是记住的设备名
try {
final remoteControlCubit = GetIt.I<RemoteControlCubit>();
final targetDevice = remoteControlCubit.state.targetDevice;
if (targetDevice != null) {
_logger.logWithLevel('🔄 [TCP] 重连使用 targetDevice: ${targetDevice.deviceName}', shouldLog: true);
connectBySwitch(
host: _lastHost!,
port: _lastPort!,
deviceName: targetDevice.deviceName,
);
} else {
// 如果 targetDevice 为 null,使用传入的设备名作为兜底
_logger.logWithLevel('⚠️ [TCP] targetDevice 为 null,使用传入的设备名: $devname', shouldLog: true);
connectBySwitch(
host: _lastHost!,
port: _lastPort!,
deviceName: devname,
);
}
} catch (e) {
_logger.logWithLevel('❌ [TCP] 获取 targetDevice 失败,使用传入的设备名: $devname, 错误: $e', shouldLog: true);
connectBySwitch(
host: _lastHost!,
port: _lastPort!,
deviceName: devname,
);
}
});
await _sendAuthPacketBySwitch(devname);
}
@@ -808,11 +838,24 @@ class TcpClient {
_logger.logWithLevel('🔑 被动[TCP] 已发送认证包 (0x03): $authString');
try {
// 1. 获取 Either 结果
await switchDeviceUseCase.deviceRepository.switchDevice(
"app",
deviceName,
);
// 🔥 修复:使用 RemoteControlCubit.targetDevice,而不是传入的 deviceName
final remoteControlCubit = GetIt.I<RemoteControlCubit>();
final targetDevice = remoteControlCubit.state.targetDevice;
if (targetDevice != null) {
debugPrint('🔀 [TCP] 使用 targetDevice 进行切换: ${targetDevice.deviceName}');
await switchDeviceUseCase.deviceRepository.switchDevice(
"app",
targetDevice.deviceName,
);
} else {
// 兜底:如果 targetDevice 为 null,使用传入的 deviceName
debugPrint('⚠️ [TCP] targetDevice 为 null,使用传入的 deviceName: $deviceName');
await switchDeviceUseCase.deviceRepository.switchDevice(
"app",
deviceName,
);
}
} catch (e) {
//debugPrint('❌ 被动[AuthTcp] 设备订阅流程异常:$e');
_logger.logWithLevel('❌ 被动[AuthTcp] 设备订阅流程异常:$e');