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>
70 lines
3.5 KiB
Dart
70 lines
3.5 KiB
Dart
/// MSP-Befehlsnummern, geprueft gegen den tatsaechlichen iNAV-9.1.0-Quellcode
|
|
/// statt aus dem Gedaechtnis uebernommen (Doku Kommunikationsschicht
|
|
/// Abschnitt 4):
|
|
/// https://github.com/iNavFlight/inav/blob/9.1.0/src/main/msp/msp_protocol.h
|
|
/// https://github.com/iNavFlight/inav/blob/9.1.0/src/main/msp/msp_protocol_v2_inav.h
|
|
///
|
|
/// `MSP_STATUS` und `MSP_ANALOG` sind laut `msp_protocol.h` seit iNAV 9.1
|
|
/// als "DEPRECATED ... use MSP2_INAV_STATUS/MSP2_INAV_ANALOG instead. Will
|
|
/// be removed in INAV 10.0" markiert - deshalb wird hier bewusst die
|
|
/// MSP2_INAV_-Variante verwendet, nicht die MSPv1-Klassiker.
|
|
abstract final class MspCommands {
|
|
/// Response: u8 fixType, u8 numSat, i32 lat(1e-7 deg), i32 lon(1e-7 deg),
|
|
/// u16 alt(m), u16 groundSpeed(cm/s), u16 groundCourse(0.1 deg), u16 hdop.
|
|
/// (`fc_msp.c`, `case MSP_RAW_GPS`)
|
|
static const int rawGps = 106;
|
|
|
|
/// Response (4 Byte): u8 reserved, u8 maxWaypoints (NAV_MAX_WAYPOINTS),
|
|
/// u8 isWaypointListValid (`posControl.waypointListValid`), u8
|
|
/// waypointCount (`getWaypointCount()`) - Grundlage der Upload-
|
|
/// Verifikation (Doku 2.2/4.5: "Upload + verifiziert"), siehe
|
|
/// msp_waypoint_codec.dart. (`fc_msp.c`, `case MSP_WP_GETINFO`)
|
|
static const int wpGetInfo = 20;
|
|
|
|
/// Request-Payload (21 Byte, siehe msp_waypoint_codec.dart
|
|
/// `encodeMspSetWaypoint`): u8 wp_no, u8 action, i32 lat(1e-7 deg),
|
|
/// i32 lon(1e-7 deg), i32 alt(cm), i16 p1, i16 p2, i16 p3, u8 flag. Nur
|
|
/// WP#1..NAV_MAX_WAYPOINTS gueltig; WP#1 setzt die Missionsliste des FC
|
|
/// zurueck (neue Mission), jede weitere WP# muss exakt die naechste sein
|
|
/// (`fc_msp.c` `case MSP_SET_WP`, `navigation.c` `setWaypoint()` - kein
|
|
/// Batch-Kommando, ein Aufruf pro Wegpunkt).
|
|
static const int setWp = 209;
|
|
|
|
/// Response: i32 estAlt(cm), i16 vario(cm/s), i32 baroAlt(cm).
|
|
/// (`fc_msp.c`, `case MSP_ALTITUDE`)
|
|
static const int altitude = 109;
|
|
|
|
/// Response: u8 mode, u8 state, u8 activeWpAction, u8 activeWpNumber,
|
|
/// u8 error, u16 headingHoldTarget. (`fc_msp.c`, `case MSP_NAV_STATUS`)
|
|
static const int navStatus = 121;
|
|
|
|
/// Response: u16 cycleTime, u16 i2cErrors, u16 sensorStatus,
|
|
/// u16 avgSystemLoad%, u8 (batteryProfile<<4|configProfile),
|
|
/// u32 armingFlags, 8 byte boxModeFlags, u8 mixerProfile.
|
|
/// (`fc_msp.c`, `case MSP2_INAV_STATUS`; ID aus
|
|
/// `msp_protocol_v2_inav.h`: `#define MSP2_INAV_STATUS 0x2000`)
|
|
static const int inavStatus = 0x2000;
|
|
|
|
/// Response (24 Byte): u8 flags, u16 batteryVoltage(0.01V),
|
|
/// u16 amperage(0.01A), u32 power, u32 mAhDrawn, u32 mWhDrawn,
|
|
/// u32 remainingCapacity, u8 batteryPercentage(0-100, bereits fertig
|
|
/// berechnet ueber `calculateBatteryPercentage()`), u16 legacyRssi
|
|
/// (0-1023, veraltete Skala - siehe stattdessen [inavLinkStats]).
|
|
/// (`fc_msp.c`, `case MSP2_INAV_ANALOG`; ID aus
|
|
/// `msp_protocol_v2_inav.h`: `#define MSP2_INAV_ANALOG 0x2002`)
|
|
static const int inavAnalog = 0x2002;
|
|
|
|
/// Response (3 Byte): u8 uplinkRssiDbm (negiert gespeichert als
|
|
/// `-rxLinkStatistics.uplinkRSSI`), u8 uplinkLinkQuality (0-100%,
|
|
/// `rxLinkStatistics.uplinkLQ` - das ist die "Receiver Link Quality"),
|
|
/// i8 uplinkSnr. (`fc_msp.c`, `case MSP2_INAV_GET_LINK_STATS`; ID aus
|
|
/// `msp_protocol_v2_inav.h`: `#define MSP2_INAV_GET_LINK_STATS 0x2103`)
|
|
static const int inavLinkStats = 0x2103;
|
|
}
|
|
|
|
/// Bits von `armingFlags` (Doku: `fc/runtime_config.h`, `armingFlags_e`).
|
|
/// Nur das fuer die Telemetrie benoetigte ARMED-Bit ist hier abgebildet.
|
|
abstract final class MspArmingFlags {
|
|
static const int armed = 1 << 2;
|
|
}
|