Skip to content

feat(bridge): two-way DSO150 bridge and app-side send - #3

Merged
amd989 merged 2 commits into
mainfrom
claude/dso150-bridge-39bdfd
Nov 18, 2026
Merged

amd989 merged 2 commits into
mainfrom
claude/dso150-bridge-39bdfd

Conversation

@amd989

@amd989 amd989 commented Nov 12, 2026

Copy link
Copy Markdown
Owner

Summary

Phase 2 of the DSO150 plan (DSOShell's docs/READOUT.md): the ESP32 bridge becomes two-way and gets a DSO150 profile, and the app gets a generic way to send bytes to a bridge. The bridge stays a dumb byte pipe; all protocol knowledge stays in Readout.Core and the DSOShell firmware.

Bridge firmware

  • firmware/fs9721-bridge is renamed to firmware/readout-bridge, with the chip picked at build time:
    • FS9721: unchanged behaviour (receive-only, 2400 baud, deep sleep when quiet, optocoupler wiring). Envs are now fs9721-esp32dev, fs9721-esp32dev-vdd, fs9721-esp32c3, fs9721-esp32c3-vdd.
    • DSO150: two-way UART at 115200 8N1, direct 3.3 V wiring, never sleeps. Envs dso150-esp32dev (RX 16, TX 17) and dso150-esp32c3 (RX 20, TX 21).
  • New RX characteristic 3065c3ca-b78a-4b98-96b6-280cf0784ec4 (write and write without response, DSO150 builds only): bytes written to it go straight out the UART.
  • Info characteristic reports chip=, baud=, firmware= (plus symbols= for the FS9721). Advertises as Readout DSO150 XXXX, keeping the layout from f34c649 (name in the advertisement, 128-bit service UUID in the scan response).
  • Throughput for ~1.1 KB waveform frames: MTU 247, notifications sized to the negotiated MTU less 3, flushed on a full chunk or a 3 ms gap. On NimBLE BLE_HS_ENOMEM it waits and retries instead of dropping bytes. DSO150 builds also get twice NimBLE's default buffers, a 4 KB UART RX buffer, a 16-byte RX FIFO threshold, and ask for a 15-30 ms connection interval.
  • deploy-esp.sh defaults to fs9721-esp32dev.

Readout.Core and the app

  • MeterModel.Dso150, MeterCapabilities.Dso150 (no remote keys, no clock, no LCD extras) and a placeholder Dso150Driver that takes bytes and makes no readings (Phase 3 writes the real one).
  • MeterDrivers.For and MeterCapabilities.For now list every model and throw on unknown ones, so a DSO150 can never fall through to the 121GW driver.
  • BridgeBluetooth: RxCharacteristicUuid, PreferredMtu, and ModelFromName recognises DSO150.
  • IMeterConnection.SendAsync(ReadOnlyMemory<byte>, CancellationToken) and MeterSession.SendAsync, implemented in:
    • BleMeterConnection (Plugin.BLE): writes with response to RX, one write at a time, in chunks of at most 512 bytes. Throws NotSupportedException when the meter has no RX (a 121GW, an FS9721 bridge).
    • BlueZMeterConnection (Linux): same rules, via BlueZNames.PickRxCharacteristic.
    • SimulatedMeterConnection: raises DataSent (the demo 121GW ignores the bytes).
  • Bridges ask for MTU 247 after connecting and log the result (RequestMtuAsync; only Android needs the request, iOS and Windows report what they negotiated).
  • DSO150 notifications are logged as text (dso150 rx ...) until the driver decodes them.
  • MCP get_status reports DSO150 as the meter type.

Docs

  • Bridge README: both profiles, DSO150 wiring (PA9 to ESP32 RX, PA10 to ESP32 TX, GND, power from the 9 V input through a buck, not the scope's 3.3 V LDO), a milestone-0 hardware test with nRF Connect and Readout, and throughput notes.
  • CLAUDE.md and docs/FS9721.md point at the renamed folder.

Open decision

SYST:BAUD following is out of scope: the bridge stays at 115200. The README lays out the two options for later: the bridge follows SYST:BAUD (it peeks at the protocol in that one place) or a fixed 921600 link.

Testing

  • pio run for all six envs succeeds, with no warnings from main.cpp
  • dotnet test --project Readout.Tests: 305 passed. New tests cover name parsing, model, capabilities and driver selection, the placeholder driver, session and simulated SendAsync, and the BlueZ RX lookup. The firmware check now also covers the RX UUID, each chip's name and the MTU.
  • Windows app and Linux head build
  • Hardware test on a real ESP32 + DSO150 running DSOShell M0 (steps in firmware/readout-bridge/README.md)
  • FS9721 bridge re-flashed and checked against a meter after the refactor
  • DSO150 throughput settings (connection interval, ENOMEM retry, FIFO threshold) measured on real hardware

Notes for Phase 3

  • Remove the dso150 rx log in BleMeterConnection (or drop it to Debug) once the driver decodes, or waveforms will flood the log.
  • Drivers only receive today. If the DSO150 driver needs to send STRM:MEAS on connect, it needs a hook.
  • LcdDrawable draws the 121GW face for any model that isn't an FS9721.

🤖 Generated with Claude Code

@amd989
amd989 force-pushed the claude/dso150-bridge-39bdfd branch from df65c8e to b7cf1e4 Compare November 16, 2026 12:49
amd989 and others added 2 commits November 18, 2026 07:04
The ESP32 bridge (renamed firmware/readout-bridge) now picks its chip at
build time: FS9721 (unchanged: receive-only, 2400 baud, deep sleep) and
DSO150 (two-way UART at 115200 8N1, direct 3.3 V wiring, never sleeps).
Envs per chip and board: fs9721-esp32dev(-vdd), fs9721-esp32c3(-vdd),
dso150-esp32dev, dso150-esp32c3.

- New RX characteristic (write, write without response) whose bytes go
  out the UART unchanged; info reports chip and baud; advertises as
  "Readout DSO150 XXXX" with the same advertising layout.
- MTU 247, notifications sized to the negotiated MTU less 3, flushed on
  a full chunk or a short gap; retries on NimBLE ENOMEM, 4 KB UART
  buffer and a 15-30 ms connection interval for waveform throughput.
- Core: MeterModel.Dso150, MeterCapabilities.Dso150, a placeholder
  Dso150Driver (no readings yet), and explicit driver and capability
  switches so no model falls through to the 121GW's.
- IMeterConnection.SendAsync (and MeterSession.SendAsync) writes to a
  bridge's RX characteristic: Plugin.BLE, BlueZ and the simulated meter.
- Bridges get MTU 247 after connecting (logged); DSO150 notifications
  are logged as text until its driver decodes them.
- Bridge README: DSO150 wiring and power, a milestone-0 hardware test,
  throughput notes and the open SYST:BAUD vs fixed 921600 decision.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@amd989
amd989 force-pushed the claude/dso150-bridge-39bdfd branch from b7cf1e4 to c91be4c Compare November 18, 2026 12:05
@amd989
amd989 merged commit a91f3f2 into main Nov 18, 2026
2 checks passed
@amd989
amd989 deleted the claude/dso150-bridge-39bdfd branch November 18, 2026 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant