hondavert-dev/lib/core/models/sensor_defs.dart
metatroncubeswdev 9a56baef61 Rework BT poller and S300 decoding after client feedback
Client reported crashes, wrong/frozen data and that the app floods the
adapter MCU. See docs/FIX_2026-10-12.md for the full analysis.

- Poller: strictly one request outstanding; next request only after a valid
  128-byte reply or a 500 ms timeout, then a quiet period + buffer flush.
  Default 100 ms (10 Hz), minimum 80 ms. DTC clear/probe share the same lock.
- BtNotifier: filter the adapter's default (no-ECU-data) frame instead of
  holding last values; EcuDataStatus + status banner; auto-reconnect on link
  loss, stalls or long default-only runs (rate-limited). A reconnect still in
  flight when the user disconnects is discarded.
- S300 offsets corrected by column counting (trims, PA, ERR00-03, Eth, SW5,
  AF); INJ/AIN little-endian; fan = SW5 FANC only. Default-frame detection
  requires bytes 0-16 and 32-36.
- KPro RPM/MAP2/AIN little-endian (RPM still needs a bench check).
- Crash hardening: zone/Flutter/platform error handlers to an in-app log
  (copyable from Debug); permissions requested before listing devices.
- Remove temporary debug prints; graph redraws live; polling options
  100-300 ms, persisted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 21:02:54 -04:00

69 lines
2.8 KiB
Dart

import 'sensor_def.dart';
import 'flag_def.dart';
/// Master list of all analog sensor definitions.
const List<SensorDef> sensorDefs = [
SensorDef(id: 'rpm', displayName: 'RPM', unit: 'revs', min: 0, max: 9000),
SensorDef(id: 'vss', displayName: 'Speed', unit: 'km/h', min: 0, max: 280),
SensorDef(
id: 'map',
displayName: 'Manifold pressure',
unit: 'kPa',
min: 0,
max: 300),
SensorDef(
id: 'tps', displayName: 'Throttle pedal', unit: '%', min: 0, max: 100),
SensorDef(
id: 'inj', displayName: 'Injector duration', unit: 'ms', min: 0, max: 20),
SensorDef(
id: 'ign', displayName: 'Timing advance', unit: 'deg', min: -20, max: 60),
SensorDef(
id: 'ect', displayName: 'Coolant temp', unit: '°C', min: -40, max: 150),
SensorDef(
id: 'iat',
displayName: 'Intake air temp',
unit: '°C',
min: -40,
max: 150),
SensorDef(
id: 'bat', displayName: 'Battery voltage', unit: 'V', min: 0, max: 20),
// O2/AFR/AIN scales not yet bench-verified: shown as raw values.
SensorDef(id: 'o2', displayName: 'O2 sensor', unit: 'raw', min: 0, max: 255),
SensorDef(id: 'gear', displayName: 'Gear', unit: '—', min: 1, max: 6),
SensorDef(id: 'eth', displayName: 'Ethanol', unit: '%', min: 0, max: 100),
SensorDef(
id: 'pa', displayName: 'Baro pressure', unit: 'kPa', min: 0, max: 120),
SensorDef(id: 'afr', displayName: 'AFR', unit: 'raw', min: 0, max: 255),
SensorDef(
id: 'strim', displayName: 'Short trim', unit: '%', min: -30, max: 30),
SensorDef(
id: 'ltrim', displayName: 'Long trim', unit: '%', min: -30, max: 30),
SensorDef(
id: 'ain0', displayName: 'Analog input 0', unit: 'raw', min: 0, max: 1023),
SensorDef(
id: 'ain1', displayName: 'Analog input 1', unit: 'raw', min: 0, max: 1023),
SensorDef(
id: 'ain2', displayName: 'Analog input 2', unit: 'raw', min: 0, max: 1023),
SensorDef(
id: 'ain3', displayName: 'Analog input 3', unit: 'raw', min: 0, max: 1023),
SensorDef(
id: 'ain4', displayName: 'Analog input 4', unit: 'raw', min: 0, max: 1023),
SensorDef(
id: 'ain5', displayName: 'Analog input 5', unit: 'raw', min: 0, max: 1023),
SensorDef(
id: 'ain6', displayName: 'Analog input 6', unit: 'raw', min: 0, max: 1023),
SensorDef(
id: 'ain7', displayName: 'Analog input 7', unit: 'raw', min: 0, max: 1023),
];
/// Master list of boolean flag sensors.
const List<FlagDef> flagDefs = [
FlagDef(id: 'mil', displayName: 'MIL'),
FlagDef(id: 'fuelpump', displayName: 'Fuel Pump'),
FlagDef(id: 'fanout', displayName: 'FAN Out'),
FlagDef(id: 'vtec', displayName: 'VTEC'),
FlagDef(id: 'knock', displayName: 'Knock'),
FlagDef(id: 'revlimit', displayName: 'Rev Limit'),
FlagDef(id: 'launch', displayName: 'Launch'),
];