Link protocol v2 receiver, ESP-NOW leg, Patrol gauge outputs, gear pulse

- 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>
This commit is contained in:
2026-09-21 19:12:38 +02:00
parent 3613387d41
commit 5fe313b7fa
18 changed files with 1658 additions and 514 deletions
+14 -6
View File
@@ -10,16 +10,16 @@ The research frontier for Controller B. Answering any of these should trigger up
## Blocking
1. **How is the wired link physically connected today?** The 5B's GPIO 44 only leaves the board as an RS485 A/B pair through an SP3485, yet both wiring guides describe a direct TTL wire into IO1. Is the RS485 A line going straight into IO1, is there an RS485→TTL module on B, or is it soldered to the module? Decides whether the wired leg is trustworthy in the car and what [[link-redundancy]] has to cover. → [[controller-link]]
2. **Which `gear_position_t` enum is correct?** A's and B's protocol headers disagree on values 4–13 (Sport/Manual vs M1–M6). Check what A's CAN parser emits, fix the other side, bump `PACKET_VERSION`. → [[controller-link]]
3. **Which Nissan Patrol cluster, and what does its tach input expect** (signal source, pulses per rev, pull-up voltage)? Fixes the frequency range for the tachometer output. → [[patrol-gauge-outputs]]
1. **Will the bare `485_A` → IO1 link survive the car?** On the bench it works (verified 2026-09-21) because the SP3485's 4.7 kΩ bias holds A high when unterminated. Over a car-length harness with noise and possible termination it may not. Decide: RS485 module on B, or rely on the wireless leg → [[link-redundancy]], [[controller-link]]
3. **Which Nissan Patrol cluster, and what does its tach input expect** (signal source, pull-up voltage)? Pulses per rev stated by the user as **4** (2026-09-21), unverified on the bench. Fixes the frequency range for the tachometer output. → [[patrol-gauge-outputs]]
## Active
4. **Add `engine_rpm` to the packet.** A has RPM verified from CAN 0x0AA `(sibling: 5B wiki → can-id-candidates)` but the protocol carries no RPM field. Needed before the tachometer can be driven. → [[controller-link]]
5. **BLE GATT or ESP-NOW for the wireless leg?** Benchmark reconnect time, latency and RAM cost on A (whose Core 0 already runs Wi-Fi + CAN + UART). → [[link-redundancy]]
5. **Is ESP-NOW enough, or is BLE still wanted?** ESP-NOW is built and works on the bench. Open: behaviour when A joins a Wi-Fi AP (channel follows the AP; B hops — untested), range in the car, and whether BLE's disconnect event is worth its RAM. → [[link-redundancy]]
5b. **Pull-the-wire test.** Both transports carry every frame on the desk; physically removing the UART wire (and separately blocking the radio) to confirm seamless failover has not been done. → [[link-redundancy]]
6. **Gauge behaviour on link loss** — zero, hold + warn, or sweep to a "no data" mark? A safety/UX decision the user must make. → [[link-redundancy]]
7. **Temp sender resistance curve** as seen by the gauge, for the °C → duty lookup. → [[patrol-gauge-outputs]]
7. **Temp gauge °C → duty curve — partly answered.** The user's old CANNY program gives `duty = 1.5·T + 50` on 0–255 ([[temp-stage-cfd]]). Still needed: the old circuit's series resistor / driver and PWM frequency, and a needle check with the new MOSFET stage. Measurement procedure is on [[patrol-gauge-outputs]].
13. **CANNY 5.3 pico details**: what is the HR PWM base clock (period 255 = what frequency), and what sat between the CANNY pin and the gauge wire? The user may still have the unit and harness. → [[temp-stage-cfd]]
8. **Does `engine_oil_temp` stay in the packet?** Its CAN source reads 0xFF on this engine (sensor not fitted). B currently reserves screen space and a warning threshold for it `(repo)`. Drop it, or repurpose the slot.
## Hardware
@@ -31,6 +31,13 @@ The research frontier for Controller B. Answering any of these should trigger up
## Answered
- ~~Which `gear_position_t` enum is correct?~~ → **Moot**: protocol v2 (2026-09-21) sends lever + target/engaged nibbles; header copied byte-identical to B. → [[controller-link]]
- ~~Add `engine_rpm` to the packet.~~ → **Done in v2** (2026-09-21), `valid_flags` bit 6. → [[controller-link]]
- ~~BLE GATT or ESP-NOW for the wireless leg?~~ → **ESP-NOW first**, implemented and bench-verified 2026-09-21; BLE stays optional (#5). → [[link-redundancy]]
- ~~Where do the gauge tunables live?~~ → **On A** (`Tunables`, NVS, `cfg` console), pushed to B in CONFIG frames, cached on B (verified 2026-09-21). → [[patrol-gauge-outputs]]
- ~~How is the wired link physically connected today?~~ → **Bare `485_A` straight into IO1, common GND, no transceiver on B.** Bench-verified 2026-09-21: 0 errors at 5 Hz. Works because of the 5B's SP3485 bias resistors; bench-only until proven in the car (now #1). → [[controller-link]]
- ~~Does the 1.3 have free PWM-capable GPIO?~~ → **Yes, 13 on the headers** (IO1–5, IO7–14), 10 fully free today. (verified from pinout photo, 2026-09-21) → [[esp32-s3-lcd-1-3]]
- ~~Could the 5B drive the gauges itself?~~ → **No.** All native GPIO consumed; its DO terminals go through an I2C expander + optocoupler and cannot carry hardware PWM. (schematic reviewed 2026-09-21) → [[patrol-gauge-outputs]]
- ~~Which GPIO does A transmit on?~~ → **GPIO 44** per A's firmware; the "43" in two docs is stale. `(repo)` → [[controller-link]]
@@ -43,3 +50,4 @@ The research frontier for Controller B. Answering any of these should trigger up
- Nissan Patrol **cluster wiring diagram** for the target generation — tach input and temp sender pins
- Scope capture of the original Patrol tach signal at idle and a known RPM, if the original engine's cluster wiring still exists
- Datasheet or Waveshare note on the board's operating temperature range
- CANNY 5.3 pico datasheet / CannyLab HR PWM documentation (PWM clock, output stage), or a scope trace of the old unit's output