diff --git a/lib/features/remote_control/domain/repositories/remote_control_repository.dart b/lib/features/remote_control/domain/repositories/remote_control_repository.dart index 6d3fdfc9..c26fa5df 100644 --- a/lib/features/remote_control/domain/repositories/remote_control_repository.dart +++ b/lib/features/remote_control/domain/repositories/remote_control_repository.dart @@ -17,6 +17,7 @@ abstract class RemoteControlRepository { /// 新增:请求控制权限 (发送 0x04 指令) Future requestControlPermission(String deviceName, String deviceId); + /// 新增:响应控制权限 同意和拒绝(发送 0x05 指令) void respondPermission(bool bool, String deviceId); } diff --git a/lib/features/remote_control/presentation/bloc/remote_control_cubit.dart b/lib/features/remote_control/presentation/bloc/remote_control_cubit.dart index e332648b..cd30fc79 100644 --- a/lib/features/remote_control/presentation/bloc/remote_control_cubit.dart +++ b/lib/features/remote_control/presentation/bloc/remote_control_cubit.dart @@ -172,9 +172,6 @@ class RemoteControlCubit extends Cubit { void requestControlPermission() { // 1. 关闭弹窗 emit(state.copyWith(showPermissionRequestDialog: false)); - - // 2. 这里执行你发送 0x12 指令的逻辑 - // _sendProtocolData(0x12, ...); } void toggleLeftPip() => emit(state.copyWith(showLeftPip: !state.showLeftPip)); @@ -244,6 +241,20 @@ class RemoteControlCubit extends Cubit { }, ); } +/// 发送底盘指令 + void sendChassisCommand(int i) { + updateFunction(lift: i); + } +/// 发送割刀指令 + void sendMowerCommand(int i) { + updateFunction(mower: i); + } +/// 发送点火指令 + void sendFireCommand(int i) { + //void updateFunction({int? mower, int? lift, int? ignition, bool? emergency}) + // updateFunction(mower:0, lift: 0, ignition: i, emergency: false); + updateFunction(ignition: i); + } diff --git a/lib/features/remote_control/presentation/widgets/center_control_area.dart b/lib/features/remote_control/presentation/widgets/center_control_area.dart index d06001db..1cb90a34 100644 --- a/lib/features/remote_control/presentation/widgets/center_control_area.dart +++ b/lib/features/remote_control/presentation/widgets/center_control_area.dart @@ -131,17 +131,17 @@ class CenterControlArea extends StatelessWidget { case "start": debugPrint('⬆️ 底盘 - 向上(例如:前进)'); // TODO: 发送底盘前进指令 - // cubit.sendChassisCommand(ChassisCommand.forward); + cubit.sendChassisCommand(1); break; case "center": debugPrint('️ 底盘 - 中间(例如:停止)'); // TODO: 发送底盘停止指令 - // cubit.sendChassisCommand(ChassisCommand.stop); + cubit.sendChassisCommand(0); break; case "end": debugPrint('⬇️ 底盘 - 向下(例如:后退)'); // TODO: 发送底盘后退指令 - // cubit.sendChassisCommand(ChassisCommand.backward); + cubit.sendChassisCommand(2); break; } } @@ -154,17 +154,17 @@ class CenterControlArea extends StatelessWidget { case "start": debugPrint('⬆️ 割刀 - 向上(例如:抬刀)'); // TODO: 发送抬刀指令 - // cubit.sendMowerCommand(MowerCommand.lift); + cubit.sendMowerCommand(1); break; case "center": debugPrint('⏹️ 割刀 - 中间(例如:保持)'); // TODO: 发送保持指令 - // cubit.sendMowerCommand(MowerCommand.hold); + cubit.sendMowerCommand(0); break; case "end": debugPrint('⬇️ 割刀 - 向下(例如:降刀)'); // TODO: 发送降刀指令 - // cubit.sendMowerCommand(MowerCommand.lower); + cubit.sendMowerCommand(2); break; } } diff --git a/lib/features/remote_control/presentation/widgets/top_status_bar.dart b/lib/features/remote_control/presentation/widgets/top_status_bar.dart index 4960210a..b0e25efb 100644 --- a/lib/features/remote_control/presentation/widgets/top_status_bar.dart +++ b/lib/features/remote_control/presentation/widgets/top_status_bar.dart @@ -256,25 +256,25 @@ class TopStatusBar extends StatelessWidget { _handleChassisAction(action, context); } - // 🔥 底盘的业务逻辑(左滑块) + // 🔥 点火的业务逻辑(左滑块) void _handleChassisAction(String action, BuildContext context) { final cubit = context.read(); switch (action) { case "start": - debugPrint('⬆️ 底盘 - 向上(例如:前进)'); - // TODO: 发送底盘前进指令 - // cubit.sendChassisCommand(ChassisCommand.forward); + debugPrint('⬆点火啊'); + // TODO: 发送 🔥点火指令 + cubit.sendFireCommand(1); break; case "center": - debugPrint('️ 底盘 - 中间(例如:停止)'); - // TODO: 发送底盘停止指令 - // cubit.sendChassisCommand(ChassisCommand.stop); + debugPrint('️熄火'); + // TODO: 发送点火停止指令 + cubit.sendFireCommand(0); break; case "end": - debugPrint('⬇️ 底盘 - 向下(例如:后退)'); - // TODO: 发送底盘后退指令 - // cubit.sendChassisCommand(ChassisCommand.backward); + debugPrint('⬇熄火)'); + // TODO: 发送熄火后退指令 + cubit.sendFireCommand(2); break; } }