obd2 0.9.0 copy "obd2: ^0.9.0" to clipboard
obd2: ^0.9.0 copied to clipboard

A production-ready SAE J1979 OBD-II SDK for Flutter with BLE support for ELM327-compatible adapters. Provides real-time telemetry, DTC parsing, and type-safe PID handling.

๐Ÿš— Flutter OBD2 #

Flutter CI pub version

A modern SAE J1979 OBD-II SDK for Flutter.

Flutter OBD2 provides a clean, type-safe, and transport-separated architecture for communicating with ELM327-compatible Bluetooth Low Energy (BLE) adapters using the SAE J1979 (Generic OBD-II) standard.

โš™๏ธ This SDK intentionally supports SAE J1979 only.
It does not implement UDS or manufacturer-specific diagnostic protocols.

๐Ÿ“ฑ Platform Support #

Platform Status
Android โœ… Supported
iOS โš ๏ธ Untested
macOS โŒ Not Supported
Windows โš ๏ธ Untested
Web โŒ Not Supported

๐Ÿ“ฆ Current Release Status #

Version: 0.9.x (Stabilization Phase)

  • โœ… Mode 01 (Live Telemetry) โ€” Fully validated
  • ๐Ÿšง Modes 02โ€“04 โ€” Implemented, limited real-world validation
  • ๐Ÿงช Full unit test coverage with CI integration
  • ๐Ÿ— Architecture finalized for 1.0 milestone

๐Ÿ“Š Example Dashboard #

[Telemetry Dashboard]

โœจ Why Flutter OBD2? #

Most OBD libraries:

  • Mix transport and protocol logic
  • Expose raw hex responses
  • Require manual PID parsing
  • Overload the ECU with unsafe polling

Flutter OBD2 provides:

  • โœ… Clean layered architecture
  • โœ… Strongly typed DetailedPID<T> system
  • โœ… Intelligent, collision-safe polling engine
  • โœ… Formula evaluation engine
  • โœ… Greedy BLE compatibility layer
  • โœ… Strict SAE J1979 implementation

This is a diagnostic SDK, not just a Bluetooth wrapper.

๐Ÿ— Architecture Overview #

BluetoothAdapterOBD2  (BLE Transport)
        โ†“
AdapterOBD2           (Core Engine)
        โ†“
SaeJ1979 Protocol
        โ”œโ”€โ”€ telemetry
        โ”œโ”€โ”€ freezeFrame
        โ”œโ”€โ”€ readCodes
        โ””โ”€โ”€ clearCodes

๐Ÿ”Œ Transport Layer โ€” BluetoothAdapterOBD2 #

Handles:

  • BLE connection
  • GATT discovery
  • Characteristic subscription
  • Raw byte streaming
  • ELM327 initialization

๐Ÿง  Core Engine โ€” AdapterOBD2 #

Handles:

  • ASCII encoding / decoding
  • Command lifecycle
  • Response buffering
  • Formula evaluation
  • PID dispatching

๐ŸŽ SAE J1979 Protocol #

Provides:

  • PID definitions
  • Mode grouping
  • Byte extraction logic
  • Diagnostic parsing rules

๐Ÿš€ Getting Started #

๐Ÿงฐ Requirements #

  • Flutter 3.x
  • Dart 3.x
  • ELM327-compatible BLE adapter (NexLink BLE adapters are recommended)

1๏ธโƒฃ Installation #

dependencies:
  obd2: ^0.9.0
  flutter_blue_plus: ^2.1.0

2๏ธโƒฃ Connect to Adapter #

import 'package:obd2/obd2.dart';
import 'package:flutter_blue_plus/flutter_blue_plus.dart';

final adapter = BluetoothAdapterOBD2();

await adapter.connect(myBluetoothDevice);

The adapter automatically:

  • Connects
  • Discovers services
  • Subscribes to notify/indicate characteristics
  • Selects writable pipe
  • Sends AT initialization commands
  • Negotiates protocol

No protocol injection required.

๐Ÿ“ก Mode 01 โ€” Live Telemetry (Production Ready) #

final telemetry = adapter.protocol.telemetry;

final session = telemetry.stream(
  detailedPIDs: [
    telemetry.rpm,
    telemetry.speed,
    telemetry.coolantTemperature,
  ],
  onData: (TelemetryData data) {
    final rpm = data.get(telemetry.rpm);

    if (rpm != null) {
      print("RPM: $rpm");
    }
  },
);

// Stop later
session.stop();

Telemetry Engine Features #

  • Respects bestPollingIntervalMs
  • Prevents ECU flooding
  • Collision-safe recursive loop
  • Type-safe PID retrieval
  • Timeout-resilient command handling

๐Ÿ” Supported PID Discovery #

final supported = await adapter.protocol.telemetry
    .detectSupportedTelemetry(validateAccessibility: true);

print("Supported: $supported");

๐ŸงŠ Mode 02 โ€” Freeze Frame #

final freeze = adapter.protocol.freezeFrame;

final snapshot = await freeze.getFrameData(
  detailedPIDs: [
    freeze.rpm,
    freeze.speed,
  ],
);

print(snapshot.get(freeze.rpm));

๐Ÿšจ Mode 03 โ€” Read Diagnostic Trouble Codes #

final codes = await adapter.protocol.readCodes.getDTCs();

print("Fault Codes: $codes");

๐Ÿงน Mode 04 โ€” Clear Diagnostic Trouble Codes #

final success = await adapter.protocol.clearCodes.eraseDTCs();

print("Cleared: $success");

๐Ÿงฌ Type-Safe PID System #

Each PID is defined as:

DetailedPID<T>

Compile-time enforced return types:

Type Example
double RPM
String Fuel Type
List<double> Lambda
List<int> Status Bitmask

No manual casting required.

๐Ÿ”Œ BLE Compatibility Strategy #

BluetoothAdapterOBD2 uses a Greedy Discovery Model:

  1. Connect
  2. Discover all services
  3. Subscribe to every notify/indicate characteristic
  4. Prefer standard ELM327 UUIDs (FFF2 / FFE1)
  5. Initialize adapter

Designed for low-cost ELM327 clones.

๐Ÿง  Public API Overview #

Core #

await adapter.connect(device);
await adapter.disconnect();

SAE J1979 Access #

adapter.protocol.telemetry
adapter.protocol.freezeFrame
adapter.protocol.readCodes
adapter.protocol.clearCodes

๐Ÿงช Testing & CI #

  • Full unit tests
  • dart analyze enforced
  • GitHub Actions CI
  • Mock adapter testing (no hardware required)

โŒ What This Package Is Not #

Flutter OBD2 does not:

  • Flash ECUs
  • Remap fuel maps
  • Modify odometers
  • Access manufacturer-specific modules
  • Implement UDS or ISO 14229

This package strictly implements the SAE J1979 emissions diagnostic standard.

โš ๏ธ Testing Status #

Mode Validation Level
Mode 01 โœ… Fully Tested
Mode 02 ๐Ÿšง Partial
Mode 03 ๐Ÿšง Partial
Mode 04 ๐Ÿšง Partial

Full real-world validation targeted for v1.0.0.

๐ŸŽฏ Road to 1.0 #

Version 1.0.0 will signify:

  • Complete real-world validation
  • Stable API commitment
  • Production-grade diagnostic reliability

๐Ÿงญ Design Philosophy #

Flutter OBD2:

  • Implements SAE J1979 correctly
  • Avoids unnecessary abstraction
  • Separates transport from diagnostics
  • Prioritizes clarity over feature bloat
  • Is engineered for long-term stability

๐Ÿ“„ License #

Licensed under the Mozilla Public License 2.0.

1
likes
0
points
180
downloads

Publisher

unverified uploader

Weekly Downloads

A production-ready SAE J1979 OBD-II SDK for Flutter with BLE support for ELM327-compatible adapters. Provides real-time telemetry, DTC parsing, and type-safe PID handling.

Repository (GitHub)
View/report issues

Topics

#obd2 #automotive #telemetry #bluetooth #elm327

License

unknown (license)

Dependencies

flutter, flutter_blue_plus, math_expressions

More

Packages that depend on obd2