From 80167fd9e558da52861d9c29dd85948006b3da05 Mon Sep 17 00:00:00 2001 From: HVBT Dev Date: Tue, 28 Jul 2026 01:29:12 +0530 Subject: [PATCH] Restore S300 frame parsing for prefix frames --- lib/core/protocol/s300_parser.dart | 8 +++----- lib/core/providers/sensor_provider.dart | 3 --- test/s300_parser_test.dart | 2 +- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/lib/core/protocol/s300_parser.dart b/lib/core/protocol/s300_parser.dart index 99039c6..78187ad 100644 --- a/lib/core/protocol/s300_parser.dart +++ b/lib/core/protocol/s300_parser.dart @@ -6,11 +6,9 @@ import 'neg8.dart'; bool isS300PlaceholderFrame(Uint8List frame) { if (frame.length != 128) return false; - // The S300 Bluetooth stream can interleave a valid-checksum placeholder - // frame that is not the SManager live sensor frame. It has a fixed header - // and zero/overflow values for speed, TPS, injection and ignition, then it - // overwrites the dashboard with stale/empty values. Keep this check near the - // parser so Bluetooth diagnostics can still receive and count raw frames. + // Diagnostic signature observed in the S300 Bluetooth stream. Do not use + // this to drop frames globally; current captures show real changing data can + // still be carried in frames with this prefix. return frame[0] == 0x1B && frame[1] == 0x00 && frame[2] == 0x14 && diff --git a/lib/core/providers/sensor_provider.dart b/lib/core/providers/sensor_provider.dart index e7bc171..8453a39 100644 --- a/lib/core/providers/sensor_provider.dart +++ b/lib/core/providers/sensor_provider.dart @@ -15,9 +15,6 @@ final sensorStateProvider = StreamProvider((ref) async* { await for (final frame in btNotifier.frameStream) { if (ecuType == EcuType.s300) { - if (isS300PlaceholderFrame(frame)) { - continue; - } yield parseS300(frame, validateChecksum: false); } else { yield parseKPro(frame); diff --git a/test/s300_parser_test.dart b/test/s300_parser_test.dart index 50367d4..33af8c2 100644 --- a/test/s300_parser_test.dart +++ b/test/s300_parser_test.dart @@ -161,7 +161,7 @@ void main() { expect(state.rpm, equals(1000.0)); }); - test('detects known S300 placeholder frame', () { + test('detects known S300 prefix signature', () { final frame = Uint8List(128); final signature = [ 0x1B,