- protocol header v2 copied byte-identical from the 5B repo - uart_receiver: processFrame() shared by the UART framing task and ESP-NOW, version check, dedupe on packet_id+timestamp, per-transport liveness, CONFIG cache with sequence number - espnow_receiver: STA mode, channel hopping while silent, locks on frames - gauge_outputs: tach on IO7 (LEDC ch2, 14-bit), coolant PWM on IO8 (LEDC ch4, 8-bit), config cached in NVS, overrides applied but not saved - main: gear label from lever + engaged/target (pulses while shifting, red on mismatch), icons driven by A's alert bits, gauge update at 5 Hz, link stats - wiki: temp_stage.cfd (user's old CANNY program) decoded as prior art; controller-link, link-redundancy, patrol-gauge-outputs, open-questions updated with the bench-verified v2 results and calibration procedure Co-Authored-By: Claude <noreply@anthropic.com>
4.6 KiB
type, tags, updated
| type | tags | updated | |||||
|---|---|---|---|---|---|---|---|
| concept |
|
2026-09-21 |
Link Redundancy: wired + wireless
Stated goal (user, 2026-09-21): connect B to A "through some serial or BLE, or maybe a combination of both as redundant in case the wired connection is lost." This page is the design space. Status 2026-09-21: ESP-NOW is implemented and bench-verified as the second transport (see below); the RS485 question and BLE remain open. Items are (unverified) unless labelled otherwise.
Why redundancy matters more once B drives gauges
Today a lost link only blanks a secondary display. Once B drives the cluster's tachometer and coolant gauge (patrol-gauge-outputs), a lost link means the driver's primary instruments go dead or, worse, freeze at the last value. The failover policy on B must therefore also define what the gauges do during an outage (drop to zero, hold with a warning, or sweep to a "no data" position).
Transport options
| Transport | Pros | Cons | Notes |
|---|---|---|---|
| UART TTL, direct wire (today) | trivial, 23 bytes @ 5 Hz is nothing | 3.3 V single-ended over a car harness is noise-prone and has no ground-offset tolerance | Fine on the bench; questionable in a vehicle over more than a few cm |
| RS485 pair | differential, automotive-grade noise immunity, tens of metres; A already has an SP3485 on its terminal block | B has no transceiver — needs a 3.3 V MAX3485/SP3485 module on IO1 (+ a free GPIO if the module lacks auto-direction) | This may already be what is wired — see the physical-layer question in controller-link |
| BLE 5 GATT (A = peripheral notifying, B = central) | both boards have BLE 5 (source: waveshare-wiki-esp32-s3-lcd-1-3); connection-oriented, so B gets an explicit disconnect event; notify payload of 23 bytes fits one packet |
connection setup/reconnect takes hundreds of ms to seconds; BLE stack costs RAM on both ends (NimBLE is the lighter choice on Arduino-ESP32); A's Core 0 already runs Wi-Fi scanning + CAN + UART, and Wi-Fi/BLE coexistence on one radio can add jitter | The user's stated candidate |
| ESP-NOW | connectionless, ~ms latency, no pairing state, trivially broadcast the same 23-byte frame; both are ESP32-S3 so it is a one-call API | Wi-Fi-based, so it shares the radio with A's Wi-Fi scanning; no link-layer "disconnected" event — liveness must come from the existing 1 s timeout | Worth benchmarking against BLE before committing; simpler failover semantics |
What was built (2026-09-21, verified on the bench)
- A broadcasts every frame on both UART1 and ESP-NOW (channel 1, broadcast peer, radio held in STA mode; the WiFi manager's "off" no longer powers the radio down).
- B receives on both, hands every frame to one
processFrame(), dedupes DATA onpacket_id+timestamp_ms, and tracks per-transport liveness (uart alive, espnow alive). While ESP-NOW is silent B hops channels 1–13 every 400 ms and locks when frames arrive. - Result on the desk: every frame seen on both paths, all duplicates dropped, zero errors. Pulling either path should leave the other carrying the link — not yet tested by physically pulling the wire
(unverified). - Not built: B talking back, BLE, an on-screen indicator of which path is live (the serial stats line shows it).
Failover design sketch
- B keeps one packet consumer. Every transport (UART, BLE/ESP-NOW) feeds validated
automotive_data_tframes into the same queue, tagged with a source id. - Deduplicate on
packet_id+timestamp_ms(both already in the payload) so a frame arriving on both paths is applied once. - Prefer wired when both are alive; fall to wireless when the wired path has been silent > N ms (N smaller than the display's 1000 ms lost-link threshold, e.g. 400 ms = two missed frames).
- Show the active source on the display (small glyph) so a silently degraded wire is noticed on the bench, not in traffic.
- Gauge behaviour during a total outage is a separate decision → open-questions.
A-side implication: A must transmit on both paths simultaneously, always — not "switch to BLE when UART fails", because A cannot tell that B stopped hearing it (the link is one-way). Simultaneous transmit is cheap at 5 Hz.
Open decisions
- BLE vs ESP-NOW for the wireless leg (latency, reconnect behaviour, RAM on A).
- Whether the wired leg becomes RS485 end-to-end (probably yes if the run is longer than a dash-panel jumper).
- Whether B should ever talk back (ACK/heartbeat) — would let A alarm on a dead B, at the cost of the current one-way simplicity.
Related
controller-link · patrol-gauge-outputs · esp32-s3-lcd-1-3 · open-questions