telemetry fix gate for telemetry stream removed

This commit is contained in:
Constantin Leue
2026-08-02 20:44:20 +02:00
parent f42d997d4c
commit 11f894919b
6 changed files with 59 additions and 15 deletions
@@ -12,7 +12,10 @@ import 'package:dmc_app/transport/msp/msp_frame_decoder.dart';
/// Beantwortet jede ueber [transport] gesendete MSP-Anfrage sofort mit einer
/// synthetischen Antwort - simuliert den Flightcontroller, ohne echte
/// Hardware (Doku Kommunikationsschicht Abschnitt 9).
Timer _startFakeFlightController(LoopbackTransport transport) {
Timer _startFakeFlightController(
LoopbackTransport transport, {
int fixType = 3,
}) {
var answered = 0;
return Timer.periodic(const Duration(milliseconds: 5), (_) {
while (answered < transport.sentData.length) {
@@ -24,7 +27,7 @@ Timer _startFakeFlightController(LoopbackTransport transport) {
switch (request.function) {
case MspCommands.rawGps:
final d = ByteData(18);
d.setUint8(0, 3); // fixType: 3D-Fix
d.setUint8(0, fixType); // fixType: 3 = 3D-Fix, 0 = kein Fix
d.setUint8(1, 11);
d.setInt32(2, 525200000, Endian.little); // lat 52.52
d.setInt32(6, 134050000, Endian.little); // lon 13.405
@@ -66,6 +69,8 @@ void main() {
expect(frame.lat, closeTo(52.52, 1e-6));
expect(frame.lon, closeTo(13.405, 1e-6));
expect(frame.hasFix, isTrue);
expect(frame.numSat, 11);
expect(frame.altitudeM, closeTo(50.0, 1e-6));
expect(frame.speedMs, closeTo(5.0, 1e-6));
expect(frame.headingDeg, closeTo(270.0, 1e-6));
@@ -76,6 +81,25 @@ void main() {
timeout: const Timeout(Duration(seconds: 5)),
);
test(
'subscribeTelemetry() liefert auch ohne GPS-Fix ein Frame (Strom wird '
'nicht auf einen Fix gegated)',
() async {
final transport = LoopbackTransport();
final responder = _startFakeFlightController(transport, fixType: 0);
final link = MspFlightControllerLink(transport: transport);
await link.connect();
final frame = await link.subscribeTelemetry().first;
expect(frame.hasFix, isFalse);
await link.disconnect();
responder.cancel();
},
timeout: const Timeout(Duration(seconds: 5)),
);
test('readActiveWaypointIndex() fragt MSP_NAV_STATUS direkt ab', () async {
final transport = LoopbackTransport();
final responder = _startFakeFlightController(transport);