Files
dmc/app/lib/ui/widgets/mission_footer_bar.dart
T
Constantin LeueandClaude Sonnet 5 13475cc4f3 Implement waypoint mission upload (MSP_SET_WP) and Fly-mode send button
Fills in MspFlightControllerLink.uploadMission(), which previously just
threw UnimplementedError, plus a new verifyMission() (both now on the
generic FlightControllerLink interface, protocol-neutral by signature -
MAVLink/ArduPilot get their own implementation later without touching
callers).

All iNAV-specific encoding lives in the new msp_waypoint_codec.dart:
- encodeMspSetWaypoint(): the 21-byte MSP_SET_WP payload. Action/P1/P2/P3
  byte layout was checked against the actual iNAV 9.1.0 source
  (navigation.c/navigation.h), not guessed - notably our generic `loiter`
  action has no configurable duration, so it maps to
  NAV_WP_ACTION_HOLD_TIME with the max representable p1 (int16 max, not
  0xFFFF - that would read as -1 and end the hold immediately instead of
  never).
- parseMspWpGetInfo(): decodes MSP_WP_GETINFO's validity/count fields,
  used by verifyMission() to confirm the FC actually accepted the full
  mission (Doku 2.2/4.5 Ready-to-Fly-Gate: "upload + verified").

uploadMission() sends one MSP_SET_WP per waypoint in order (iNAV has no
batch command - WP#1 resets the FC's mission list, every next number must
follow immediately, only the last carries NAV_WP_FLAG_LAST) and rejects
missions above NAV_MAX_WAYPOINTS upfront instead of silently truncating.
MissionSyncService now calls the real verifyMission() instead of always
confirming, throwing MissionVerificationException when the FC doesn't
confirm the mission.

FlyScreen's footer swaps the warnings button for a send button (Doku:
"ersetze den warnings button mit einem wp send button", pink horizontal
PaperPlaneIcon, matching the existing paper-plane drone iconography) -
warnings/event log stay reachable via the drone status pill's Warnings
tab. BottomStatsBar/MissionFooterBar gained onSendTap/sending in place of
the old forceShowWarningsButton.

Verified end to end on the Pixel_10a emulator: tapping send with WLAN as
the active connection type triggers the real WifiNetworkSpecifier flow
through MspFlightControllerLink (correctly reports "no devices found" -
expected, no real mLRS bridge on the emulator); the actual MSP_SET_WP/
MSP_WP_GETINFO wire behavior is covered by tests against a fake FC
responder over LoopbackTransport instead.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-06 09:10:32 +02:00

145 lines
5.4 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../domain/mission/mission_stats.dart';
import '../../domain/mission/mission_warnings.dart';
import '../../domain/telemetry/drone_status.dart';
import '../../domain/waypoint/flat_waypoint_list.dart';
import '../providers/altitude_profile_provider.dart';
import 'battery_indicator_bar.dart';
import 'bottom_stats_bar.dart';
import 'mini_altitude_profile.dart';
/// Gemeinsamer Fusszeilen-Aufbau (Warnungsbanner + Hoehenprofil +
/// BottomStatsBar), geteilt zwischen Plan- und Fly-Modus (Doku 3.9/3.10) -
/// beide zeigen dieselbe Missionsuebersicht, nur Reticle/Draeder gibt es
/// ausschliesslich im Plan-Modus.
class MissionFooterBar extends ConsumerWidget {
const MissionFooterBar({
super.key,
required this.waypoints,
required this.legClimbBad,
required this.vertexBad,
required this.activeIndex,
required this.totalDistanceM,
required this.totalDurationSec,
this.flyMissionStatus,
this.droneStatus,
required this.warnings,
this.showWarningsBanner = true,
this.batteryPercent,
this.onSendTap,
this.sending = false,
required this.onDetailsTap,
required this.onWarningsTap,
required this.onSettingsTap,
});
final List<Waypoint> waypoints;
final List<bool> legClimbBad;
final List<bool> vertexBad;
final int activeIndex;
final double totalDistanceM;
final double totalDurationSec;
/// Nur im Fly-Modus gesetzt (Doku: "Live-Status der Mission in der
/// Details-Pille") - ersetzt dort die statischen Plan-Werte
/// (Wegpunktzahl/Gesamtdistanz/-dauer) durch aktiven Wegpunkt sowie
/// Distanz/Zeit dorthin. Bleibt im Plan-Modus null.
final FlyMissionStatus? flyMissionStatus;
/// Nur im Fly-Modus gesetzt (Doku: "im fly modus zeigt die drone pille
/// den zustand der drohne") - siehe BottomStatsBar.droneStatus. FlyScreen
/// setzt hier immer einen Wert (auch ohne Telemetrie-Frame, siehe dortige
/// Doku), Plan-Modus nie - dient deshalb hier zugleich als Fly/Plan-
/// Unterscheidung fuer die Sichtbarkeit von [batteryPercent], statt dafuer
/// ein eigenes Flag zu fuehren.
final DroneStatus? droneStatus;
final List<MissionWarning> warnings;
/// Blendet das Text-Warnbanner ueber der Fusszeile aus (Doku: "Banner mit
/// Warnungen ueber der Fusszeile im Fly-Modus entfernen") - der runde
/// Warnungsknopf in BottomStatsBar (oeffnet weiterhin WarningsPanel) bleibt
/// davon unberuehrt, nur die staendig sichtbare Textzeile verschwindet.
/// Default true, damit der Plan-Modus unveraendert bleibt.
final bool showWarningsBanner;
/// Nur im Fly-Modus gesetzt (Doku: "Batterieanzeige im Fly-Modus
/// hinzufuegen") - zeigt den Batteriebalken ueber der BottomStatsBar an,
/// unter einem ggf. ausgeklappten Hoehenprofil. Sichtbarkeit haengt an
/// [droneStatus] statt an diesem Wert selbst (siehe dort) - im Fly-Modus
/// bleibt der Balken deshalb auch ohne Telemetrie-Frame sichtbar, nur der
/// Prozentwert ist dann null (BatteryIndicatorBar zeigt dafuer einen
/// neutralen "keine Daten"-Zustand statt 0%, das faelschlich als
/// kritischer Ladestand gelesen werden koennte).
final int? batteryPercent;
/// Siehe BottomStatsBar.onSendTap.
final VoidCallback? onSendTap;
/// Siehe BottomStatsBar.sending.
final bool sending;
final VoidCallback onDetailsTap;
final VoidCallback onWarningsTap;
final VoidCallback onSettingsTap;
@override
Widget build(BuildContext context, WidgetRef ref) {
final isExpanded = ref.watch(altitudeProfileExpandedProvider);
return Column(
mainAxisSize: MainAxisSize.min,
children: [
if (showWarningsBanner && warnings.isNotEmpty)
Container(
width: double.infinity,
color: const Color(0xFF7C2D12),
padding: const EdgeInsets.symmetric(vertical: 4, horizontal: 12),
child: Text(
warnings.map((w) => w.text).join(' · '),
textAlign: TextAlign.center,
style: const TextStyle(color: Color(0xFFFDE3D0), fontSize: 12),
),
),
Container(
width: double.infinity,
color: const Color(0xFF0F0F0F).withValues(alpha: 0.72),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
if (isExpanded)
Padding(
padding: const EdgeInsets.fromLTRB(8, 6, 8, 0),
child: MiniAltitudeProfile(
waypoints: waypoints,
legClimbBad: legClimbBad,
vertexBad: vertexBad,
activeIndex: activeIndex,
),
),
if (droneStatus != null)
Padding(
padding: const EdgeInsets.fromLTRB(0, 4, 0, 0),
child: BatteryIndicatorBar(percent: batteryPercent),
),
BottomStatsBar(
waypointCount: waypoints.length,
totalDistanceM: totalDistanceM,
totalDurationSec: totalDurationSec,
flyMissionStatus: flyMissionStatus,
droneStatus: droneStatus,
onTap: onDetailsTap,
warnings: warnings,
onSendTap: onSendTap,
sending: sending,
onWarningsTap: onWarningsTap,
onSettingsTap: onSettingsTap,
),
],
),
),
],
);
}
}