Tier 2: WiFi + Bluetooth ELM327 transports

- obdcore/transport.py: pluggable byte transports -- SerialTransport,
  TcpTransport (WiFi ELM327, stdlib socket), BleTransport (experimental, via
  optional 'bleak'; background asyncio loop buffering notifications). ble_scan().
- ElmLink refactored onto a transport with .serial()/.tcp()/.ble() factories
  (close/cmd now go through self.io); no behavior change for serial.
- Controller.connect(conn={kind:serial|wifi|ble,...}); GUI connection bar gains
  a transport selector (Serial/USB/BT-SPP | WiFi host:port | Bluetooth LE + Scan).
- Classic-Bluetooth needs no new code (pairs as a serial port); WiFi needs no
  extra deps; BLE is opt-in (bleak not bundled, so CI binaries keep building).
- tests/test_transport.py: drives ElmLink over a fake ELM TCP server end-to-end
  (connect, RPM, readiness, VIN). All suites pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016yT89n4zR4qbrySoSiEyZs
This commit is contained in:
2026-07-01 08:24:51 -04:00
parent 6548cf7fbe
commit 7bda758f88
6 changed files with 417 additions and 31 deletions
+15 -7
View File
@@ -83,15 +83,23 @@ all ship wheels for Windows / macOS (incl. Apple Silicon) / Linux.
## Connecting to a vehicle
Plug an **ELM327 (USB or Bluetooth)** into the OBD-II port, turn the key to RUN,
then pick the port and **Connect**. The CH340 USB adapters need a one-time driver:
Pick the adapter type in the toolbar, then **Connect** (key to RUN). OBDash speaks
to any ELM327 over three transports:
- **Windows** — WCH `CH341SER`; shows as `USB-SERIAL CH340 (COMx)` in Device Manager.
- **macOS** — WCH `CH34xVCPDriver` (Mac App Store / wch.cn); port `/dev/cu.wchusbserial*`.
- **Linux** — `ch341` is in the kernel (no install); port `/dev/ttyUSB0` (add yourself
to the `dialout` group: `sudo usermod -aG dialout $USER`).
- **Serial / USB / classic-Bluetooth** — the port dropdown. USB CH340 adapters need
a one-time driver:
- **Windows** — WCH `CH341SER`; shows as `USB-SERIAL CH340 (COMx)`.
- **macOS** — WCH `CH34xVCPDriver`; port `/dev/cu.wchusbserial*`.
- **Linux** — kernel `ch341` (no install); `/dev/ttyUSB0` (add yourself to `dialout`).
- **Classic-Bluetooth** ELM327 pair as a serial port (COMx / `/dev/cu.*` / `rfcomm`)
— pair in your OS, then pick that port here.
- **WiFi** — for WiFi ELM327 dongles: enter the host/port (default `192.168.0.10:35000`).
Connect to the dongle's WiFi network first. No driver needed.
- **Bluetooth LE** — Scan and pick the device. BLE support needs `pip install bleak`
(optional; not bundled in the prebuilt binaries). BLE dongle GATT layouts vary, so
this is experimental.
Default baud is 38400; the ELM327 auto-negotiates the vehicle's protocol.
Default serial baud is 38400; the ELM327 auto-negotiates the vehicle's protocol.
## Vehicle profiles