OBD-II / ELM327 Vehicle State
Fabrika AI reads the vehicle's current state from an ELM327-compatible adapter and attaches the snapshot to the next vision or acoustic scan. The snapshot is stored with the scan, shown in the report, included in the PDF, and included in support diagnostics.
Supported connections
| Link | Implementation | Notes |
|---|---|---|
| Bluetooth LE | flutter_blue_plus (local Android platform fork) | Scans all BLE advertisements; prefers known OBD names; selects write/notify characteristics including FFE0/FFE1, FFF0/FFF1/FFF2, and 18F0/2AF0. |
| Bluetooth classic SPP | Native Android BluetoothSocket + event channel in MainActivity.kt | Lists paired devices; connect over the standard SPP UUID. Pair the adapter in Android settings first. |
| USB OTG | Native Android USB host bridge over usb-serial-for-android 3.9.0 | Drivers: CDC ACM, FTDI, CP210x, CH34x, PL2303. Requests USB permission on first connect. |
The app requests Android 12+ BLUETOOTH_SCAN / BLUETOOTH_CONNECT; older Android uses legacy Bluetooth and location permissions. USB host support is optional in the manifest.
Diagnostic commands
Elm327Client initializes with ATZ, echo/linefeed/header off, protocol auto (ATSP0), adaptive timing, and a longer timeout. It then reads:
- VIN with
09 02(ISO-TP multi-frame aware) - Live PIDs: load, coolant, fuel trims, RPM, speed, timing, intake/ambient/oil temperature, MAF, throttle/pedal, fuel level, run time, distances, battery/control voltage, fuel rate, torque and more
- Stored, pending, and permanent DTCs (
03,07,0A) - MIL/readiness (
01 01) - Adapter ID, protocol, and
ATRVbattery voltage
Responses are parsed from both spaced and compact hex, with 0: / 1: ISO-TP prefixes. Commands are serialized to avoid overlapping ELM requests. NO DATA, SEARCHING..., ?, and unsupported PIDs are ignored per request.
Attach to the model and reports
ScanRecord.obdstores anObdSnapshot; SQLite schema version 2 addsscans.obd_json.AppState.saveVisionScanandsaveAcousticScanautomatically use a fresh snapshot (under 45 minutes old) fromObdSession.- The snapshot appears in the report detail screen, the generated PDF, and support-diagnostic bundles.
- OBD data is evidence/context, not an independent autonomous diagnosis. The existing precision gates still apply.
Safety and limitations
- Do not clear DTCs without recording them first; clearing resets readiness monitors.
- Adapter clone firmware varies. Unsupported PIDs and multi-frame quirks are handled defensively, but a physical adapter matrix test is still required.
- OBD-II coverage is broad for 2001+ cars in Egypt, but older/protocol-specific vehicles may be partial. The UI explains this rather than promising universal coverage.
- Keep the cable away from hot engine parts and never drive while operating the phone.
- OBD access is local; no vehicle data is uploaded unless the user submits a support bundle or shares a report.