msp over wifi implemented

This commit is contained in:
Constantin Leue
2026-08-02 09:20:05 +02:00
parent 24db38dc33
commit 6cfb82bd77
11 changed files with 155 additions and 13 deletions
@@ -23,6 +23,7 @@ class TelemetryFrame {
required this.lon,
required this.altitudeM,
required this.speedMs,
required this.headingDeg,
required this.armed,
this.activeWaypointIndex,
});
@@ -31,6 +32,10 @@ class TelemetryFrame {
final double lon;
final double altitudeM;
final double speedMs;
/// Kurs ueber Grund in Grad (0 = Norden, im Uhrzeigersinn) - dreht den
/// Drohnen-Marker (Doku 3.10, [DroneMarkerIcon]).
final double headingDeg;
final bool armed;
final int? activeWaypointIndex;
}
@@ -10,6 +10,7 @@ class MockFlightControllerLink implements FlightControllerLink {
int? _activeWaypointIndex;
StreamController<TelemetryFrame>? _telemetryController;
Timer? _ticker;
double _heading = 0;
@override
FcCapabilities get capabilities => const FcCapabilities(
@@ -22,11 +23,17 @@ class MockFlightControllerLink implements FlightControllerLink {
Future<void> connect() async {
_telemetryController = StreamController<TelemetryFrame>.broadcast();
_ticker = Timer.periodic(const Duration(seconds: 1), (_) {
// Kurs dreht sich langsam weiter statt fest zu stehen, damit die
// Rotation des Drohnen-Markers (DroneMarkerIcon) auch ohne Hardware
// sichtbar ueberprueft werden kann (Doku 9: UI-Entwicklung ohne
// Hardware).
_heading = (_heading + 5) % 360;
_telemetryController?.add(TelemetryFrame(
lat: 52.5,
lon: 13.4,
altitudeM: 120,
speedMs: 18,
headingDeg: _heading,
armed: _armed,
activeWaypointIndex: _activeWaypointIndex,
));
@@ -10,6 +10,7 @@ class MspGpsReading {
required this.lat,
required this.lon,
required this.speedMs,
required this.headingDeg,
});
/// 0 = kein Fix (`fc_msp.c`: `gpsSol.fixType`).
@@ -19,6 +20,10 @@ class MspGpsReading {
final double lon;
final double speedMs;
/// Kurs ueber Grund in Grad (0 = Norden, im Uhrzeigersinn), aus
/// `groundCourse` - nur bei [hasFix] aussagekraeftig.
final double headingDeg;
bool get hasFix => fixType != 0;
}
@@ -31,6 +36,7 @@ MspGpsReading parseMspRawGps(Uint8List payload) {
lat: data.getInt32(2, Endian.little) / 1e7,
lon: data.getInt32(6, Endian.little) / 1e7,
speedMs: data.getUint16(12, Endian.little) / 100.0,
headingDeg: data.getUint16(14, Endian.little) / 10.0,
);
}
@@ -90,6 +90,7 @@ class MspTelemetryPoller {
lon: gps.lon,
altitudeM: altitudeM,
speedMs: gps.speedMs,
headingDeg: gps.headingDeg,
armed: _armed,
activeWaypointIndex: _activeWaypointIndex,
));
+9
View File
@@ -101,6 +101,15 @@ class UdpTransport implements LinkTransport {
@override
Future<void> connect() async {
// Idempotent: mehrere Aufrufer koennen unabhaengig voneinander "sorg
// dafuer, dass wir verbunden sind" anfordern (z.B. der Auto-Connect-
// Trigger beim Wechsel in den Fly-Modus UND der MSP-Telemetrie-Consumer,
// der denselben Transport braucht) - ohne diese Sperre wuerde der
// zweite Aufruf eine weitere WifiNetworkSpecifier-Anfrage samt
// Systemdialog auslösen, waehrend die erste noch laeuft.
if (_state == LinkState.connecting || _state == LinkState.connected) {
return;
}
_lastErrorReason = null;
_lastErrorMessage = null;
_setState(LinkState.connecting);