Rename Controller A/B -> Main CTRL / Inst. Cluster (user); Sleep when the car is off: Settings switch, deep sleep on quiet CAN + idle screen, CAN RX wake, switch mirrored to the cluster; docs
Firmware / build (push) Successful in 7m22s
Firmware / build (push) Successful in 7m22s
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
name: Firmware
|
||||
|
||||
# Controller A firmware, built by PlatformIO on every push. Two outputs:
|
||||
# Main CTRL firmware, built by PlatformIO on every push. Two outputs:
|
||||
#
|
||||
# - push to main -> rolling PRE-release `main-latest` (firmware.bin + .elf),
|
||||
# unsigned, no manifest. For bench testing / USB flashing.
|
||||
@@ -143,12 +143,12 @@ jobs:
|
||||
if [ "${GITHUB_REF#refs/tags/}" != "${GITHUB_REF}" ]; then
|
||||
TAG="${GITHUB_REF_NAME}"
|
||||
PRE=false
|
||||
NAME="Controller A ${TAG}"
|
||||
NAME="Main CTRL ${TAG}"
|
||||
BODY="Signed OTA release. Install on the controller with \`ota install\` (parked, Wi-Fi joined)."
|
||||
else
|
||||
TAG="main-latest"
|
||||
PRE=true
|
||||
NAME="Controller A main build"
|
||||
NAME="Main CTRL main build"
|
||||
BODY="Unsigned build of main @ ${GITHUB_SHA}. Rolling - overwritten each push. Not installable over OTA; flash over USB for bench tests."
|
||||
# Rolling: drop the previous release and its tag, recreate at this commit.
|
||||
OLD=$(curl -sS -H "$auth" "${API}/repos/${REPO}/releases/tags/${TAG}" \
|
||||
|
||||
@@ -4,7 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
||||
|
||||
## Project Overview
|
||||
|
||||
Automotive display controller for **Waveshare ESP32-S3-Touch-LCD-5B** (1024x600 RGB LCD). This is a dual-controller system where Controller A (this ESP32-S3-LCD-5B) communicates automotive sensor data via UART to Controller B (ESP32-S3-LCD-1.3).
|
||||
Automotive display controller for **Waveshare ESP32-S3-Touch-LCD-5B** (1024x600 RGB LCD). This is a dual-controller system where Main CTRL (this ESP32-S3-LCD-5B) communicates automotive sensor data via UART to Inst. Cluster (ESP32-S3-LCD-1.3).
|
||||
|
||||
**Hardware**: ESP32-S3 dual-core @ 240MHz, 16MB Flash, 8MB OPI PSRAM, 5-inch capacitive touch LCD
|
||||
|
||||
@@ -86,8 +86,9 @@ src/
|
||||
diag_probe.cpp # On-demand OBD-II requests ('diag' console) - the ONLY CAN transmitter
|
||||
perf_monitor.cpp # 'perf' console: render fps, flush cost, LVGL/CPU idle, heap (display experiments)
|
||||
ota_update.cpp # Manual firmware updates from Gitea releases ('ota' console)
|
||||
link_peer.cpp # Controller B over the link: its STATUS frames, 'link pair' (key over the wire), encrypted credential handoff, B's updates ('link' console)
|
||||
link_peer.cpp # Inst. Cluster over the link: its STATUS frames, 'link pair' (key over the wire), encrypted credential handoff, B's updates ('link' console)
|
||||
status_overlay.cpp # lv_layer_top() on EVERY screen: Wi-Fi chip top-right, blinking red / steady amber alert banner top-centre
|
||||
power_manager.cpp # 'Sleep when the car is off': deep sleep after 60 s of quiet CAN + idle screen, wake on CAN RX; mirrors the switch to B
|
||||
settings_manager.cpp # NVS persistent storage
|
||||
ui_state_manager.cpp # Debug flag (performance overlay, sent to B)
|
||||
display_init.cpp # Display initialization; boots into DrivelineScreen
|
||||
@@ -111,7 +112,7 @@ include/
|
||||
- Console command routing (`cfg`, `diag`, `ota`, `wifi`, `mem`, `perf`, `link`), setup order, `loop()` ticks for the three screens
|
||||
|
||||
**include/protocol/automotive_data.h**
|
||||
- **Shared with Controller B, must stay byte-identical in both repos.** Protocol v2 (2026-09-21).
|
||||
- **Shared with Inst. Cluster, must stay byte-identical in both repos.** Protocol v2 (2026-09-21).
|
||||
- `automotive_data_t` (DATA payload): gear lever + target/engaged nibbles, rpm, 3 temperatures, battery, alert bitmap, valid flags
|
||||
- `link_config_t` (CONFIG payload): Patrol gauge calibration + alert thresholds, pushed A → B
|
||||
- Frame: `0xAA | version | type | length | payload | XOR | 0x55`; helpers `frame_build()` / `frame_parse()`
|
||||
@@ -227,16 +228,16 @@ Settings persist across power cycles via ESP32 NVS (Non-Volatile Storage):
|
||||
|
||||
`src/modules/espnow_link.cpp` broadcasts every frame on Wi-Fi channel `ESPNOW_CHANNEL` (1). The radio stays in STA mode permanently — `WiFiManager`'s "off" only stops scanning/association. Never call `WiFi.disconnect(true)` or `WiFi.mode(WIFI_OFF)`: powering the radio off de-initialises ESP-NOW (`send()` re-inits it as a safety net). If Wi-Fi joins an AP the channel follows the AP; B hops to find it. Since 2026-09-27 it also receives (`setReceiveHandler()`, runs in the Wi-Fi task - copy and return) and unicasts to one MAC (`sendTo()`, plain peer added on first use); both are used by `LinkPeer` only.
|
||||
|
||||
### Controller B over the link (`link` console)
|
||||
### Inst. Cluster over the link (`link` console)
|
||||
|
||||
`src/modules/link_peer.cpp` keeps B's last `STATUS` frame (version, update phase, progress, flags; "not heard" after 15 s), owns the pairing key (NVS `linkpeer`) and drives B's updater. `link pair` generates a 32-byte key and sends it **three times over UART1 only** (`UARTManager::sendWire()`, never ESP-NOW - both repos are public, this is the one secret); B confirms with `key_fp` in its next STATUS. `tick()` pushes the remembered Wi-Fi network to B in an encrypted `SECURE` frame whenever B lacks it or it changed (hash-compared, ≥ 15 s apart; `WiFiManager::getSavedCredentials()` exists for this alone - never print the password), and a FORGET when A forgets its network. `requestCheck()` / `requestInstall()` (Settings → Updates, Controller B card) require: B heard, paired with *this* key, B has credentials, B not busy, A on Wi-Fi (same AP as B ⇒ same channel ⇒ progress frames arrive), and for install `Ota::isParked()`. Console: `link status | pair | unpair | creds | ota check | ota install [force] | ota rollback`. Design + procedure: B's wiki `controller-b-ota`.
|
||||
`src/modules/link_peer.cpp` keeps B's last `STATUS` frame (version, update phase, progress, flags; "not heard" after 15 s), owns the pairing key (NVS `linkpeer`) and drives B's updater. `link pair` generates a 32-byte key and sends it **three times over UART1 only** (`UARTManager::sendWire()`, never ESP-NOW - both repos are public, this is the one secret); B confirms with `key_fp` in its next STATUS. `tick()` pushes the remembered Wi-Fi network to B in an encrypted `SECURE` frame whenever B lacks it or it changed (hash-compared, ≥ 15 s apart; `WiFiManager::getSavedCredentials()` exists for this alone - never print the password), and a FORGET when A forgets its network. `requestCheck()` / `requestInstall()` (Settings → Updates, Inst. Cluster card) require: B heard, paired with *this* key, B has credentials, B not busy, A on Wi-Fi (same AP as B ⇒ same channel ⇒ progress frames arrive), and for install `Ota::isParked()`. Console: `link status | pair | unpair | creds | ota check | ota install [force] | ota rollback`. Design + procedure: B's wiki `controller-b-ota`.
|
||||
|
||||
### Screens
|
||||
|
||||
All hand-coded in `src/modules`, built once and kept (never deleted - the old generated screens were deleted on leave, which left dangling pointers and caused the 2026-09-27 freezes). Shared look in `ui_kit.cpp` (20/24 px text, >= 56 px touch targets, no shadows/animations, `UiKit::confirm()` modal dialog). Each screen has a `tick()` called from `loop()` that refreshes values under the LVGL lock, only while it is shown, and only re-sets label text that changed.
|
||||
|
||||
- **Driveline** (boot) - swipe left: Settings, swipe right: Gauge Tuning
|
||||
- **Settings** (`settings_screen.cpp`) - sidebar: **Wi-Fi** (switch, status card, networks nearby, full-screen password page), **Updates** (two cards: Controller A -> `Ota::requestCheck/requestInstall`, Controller B -> `LinkPeer::requestCheck/requestInstall`; each Installed / Latest / status line / Check / Install behind a confirm dialog; must fit 484 px, pages don't scroll), **System** (CAN / link to B / performance overlay switches, live ESP-NOW, CAN, memory, uptime). Swipe right or the Driveline button goes back
|
||||
- **Settings** (`settings_screen.cpp`) - sidebar: **Wi-Fi** (switch, status card, networks nearby, full-screen password page), **Updates** (two cards: Main CTRL -> `Ota::requestCheck/requestInstall`, Inst. Cluster -> `LinkPeer::requestCheck/requestInstall`; each Installed / Latest / status line / Check / Install behind a confirm dialog; must fit 484 px, pages don't scroll), **System** (CAN / link to B / performance overlay switches, live ESP-NOW, CAN, memory, uptime). Swipe right or the Driveline button goes back
|
||||
- **Gauge Tuning** (`tuning_screen.cpp`) - tabs Tachometer / Coolant gauge / Alerts / Simulation; -/+ rows with hints (hold to repeat, speeds up), per-tab Reset with confirm, "Saving... / All changes saved" footer, SIMULATION ON chip while an override is active. Swipe left or the Driveline button goes back
|
||||
- Screen switches are instant (`LV_SCR_LOAD_ANIM_NONE`): full-screen fades are software-blended every frame and stutter at 1024x600. The firmware version is a label on `lv_layer_top()` (bottom-right, every screen, `DisplayInit`)
|
||||
- **StatusOverlay** (2026-09-27, `status_overlay.cpp`, also on `lv_layer_top()`): a 150 px Wi-Fi chip top-right (off / not connected / joining / network name) and an alert banner top-centre that blinks red at 2 Hz while any red alert bit is set (coolant hot, gearbox oil hot, gear mismatch, battery low - text names the value) and is steady amber for gearbox cooling; hidden with CAN or ignition off. The top ~56 px of every screen belong to it: `UiKit::header()` puts the back button at x -176, the Driveline chips start at y 60. On the Driveline the crossed value AND its title go red (amber for cooling) and a gear mismatch turns the hero ring + letter red (the old top-right mismatch label is gone). Blinking is a colour toggle from `tick()` every 500 ms, not an lv_anim (a 1024-wide banner animated per frame would cost real render time)
|
||||
|
||||
@@ -5,7 +5,7 @@ Automotive display controller for Waveshare ESP32-S3-Touch-LCD-5B (1024x600 RGB
|
||||
## Features
|
||||
|
||||
- ✅ **CAN bus** - decodes the BMW M57N / ZF 6HP powertrain frames (gear, temperatures, rpm, ...)
|
||||
- ✅ **Link to Controller B** - data + gauge config @ 5 Hz over RS485 (UART1) and ESP-NOW
|
||||
- ✅ **Link to Inst. Cluster** - data + gauge config @ 5 Hz over RS485 (UART1) and ESP-NOW
|
||||
- ✅ **Screens** - Driveline (boot), Settings (Wi-Fi / Updates / System), Gauge Tuning; LVGL 8.4.0, hand-coded
|
||||
- ✅ **Wi-Fi** - one remembered network, joined at boot
|
||||
- ✅ **OTA updates** - signed releases from Gitea, installed from the Settings screen
|
||||
@@ -76,7 +76,7 @@ src/
|
||||
include/
|
||||
config/ # lv_conf.h, ota_config.h, board config
|
||||
display/ # LVGL port
|
||||
protocol/automotive_data.h # link protocol shared with Controller B
|
||||
protocol/automotive_data.h # link protocol shared with Inst. Cluster
|
||||
wiki/ # project knowledge base
|
||||
```
|
||||
|
||||
|
||||
+23
-13
@@ -1,9 +1,9 @@
|
||||
# Commands cheat-sheet — both controllers
|
||||
|
||||
Everything you type to build, flash, watch and drive the two boards. Kept in the
|
||||
Controller A repo (this one); the Controller B repo's README points here.
|
||||
Main CTRL repo (this one); the Inst. Cluster repo's README points here.
|
||||
|
||||
| | Controller A | Controller B |
|
||||
| | Main CTRL | Inst. Cluster |
|
||||
|---|---|---|
|
||||
| Board | Waveshare ESP32-S3-Touch-LCD-5B (5" touch) | Waveshare ESP32-S3-LCD-1.3 (1.3" round) |
|
||||
| Repo / branch | `ESP32-S3-Touch-LCD-5B`, `main` | `ESP32-S3-LCD-1.3`, `master` |
|
||||
@@ -39,7 +39,7 @@ Windows ports move around: `pio device list` shows what is plugged in.
|
||||
|
||||
Run inside the respective repo folder.
|
||||
|
||||
### Controller A
|
||||
### Main CTRL
|
||||
```powershell
|
||||
cd <path>\ESP32-S3-Touch-LCD-5B
|
||||
pio run # build only (dev build, version "dev")
|
||||
@@ -48,7 +48,7 @@ pio run -t clean # wipe the build directory
|
||||
```
|
||||
First build after a `platformio.ini` change rebuilds the ESP-IDF core (~20 min, `custom_sdkconfig`); later builds take 1–3 min.
|
||||
|
||||
### Controller B
|
||||
### Inst. Cluster
|
||||
```powershell
|
||||
cd <path>\ESP32-S3-LCD-1.3
|
||||
pio run
|
||||
@@ -63,8 +63,8 @@ A USB flash writes bootloader, partition table, `boot_app0` and the app into slo
|
||||
## 3. Serial monitor
|
||||
|
||||
```powershell
|
||||
pio device monitor -p COM14 -b 115200 --dtr 0 --rts 0 --echo # Controller A
|
||||
pio device monitor -p COM10 -b 115200 --dtr 0 --rts 0 --echo # Controller B
|
||||
pio device monitor -p COM14 -b 115200 --dtr 0 --rts 0 --echo # Main CTRL
|
||||
pio device monitor -p COM10 -b 115200 --dtr 0 --rts 0 --echo # Inst. Cluster
|
||||
```
|
||||
Type a command, press Enter. `--echo` shows what you type. Ctrl+C leaves.
|
||||
|
||||
@@ -79,7 +79,7 @@ python tools\diag_session.py COM14 "diag pids" "diag vin" # scripted OBD probe
|
||||
|
||||
---
|
||||
|
||||
## 4. Controller A console
|
||||
## 4. Main CTRL console
|
||||
|
||||
Type `help` for the list. Unknown lines are reported.
|
||||
|
||||
@@ -110,7 +110,7 @@ ota install [force] download, verify, flash the idle slot, reboot (parked
|
||||
ota rollback boot the previous slot (parked only)
|
||||
```
|
||||
|
||||
### `link` — Controller B over the link
|
||||
### `link` — Inst. Cluster over the link
|
||||
```
|
||||
link status B's version, pairing, update phase, credentials
|
||||
link pair new shared key → B over the UART WIRE (bench, wire connected)
|
||||
@@ -132,6 +132,14 @@ diag raw on | off CANRAW frame logging
|
||||
diag status
|
||||
```
|
||||
|
||||
### `sleep` — deep sleep when the car is off (Settings → System switch, default OFF)
|
||||
```
|
||||
sleep status enabled?, and what currently keeps the board awake
|
||||
sleep on | off same as the switch; the Inst. Cluster follows through the CONFIG frame
|
||||
sleep now deep sleep immediately - wake = CAN bus activity (GPIO 16) or power cycle
|
||||
```
|
||||
Asleep, the USB port disappears; on the bench only a power cycle or the reset button wakes a Main CTRL that has no CAN bus.
|
||||
|
||||
### Diagnostics
|
||||
```
|
||||
mem internal heap, PSRAM, LVGL pool
|
||||
@@ -141,7 +149,7 @@ perf on [sec] | perf off
|
||||
|
||||
---
|
||||
|
||||
## 5. Controller B console
|
||||
## 5. Inst. Cluster console
|
||||
|
||||
```
|
||||
help
|
||||
@@ -153,6 +161,8 @@ ota status version, slot, rollback state
|
||||
ota check join Wi-Fi, ask Gitea for the latest release, leave
|
||||
ota install [force] download, verify, flash, reboot (parked only)
|
||||
ota rollback
|
||||
sleep status sleep flag received from the Main CTRL, link state
|
||||
sleep now deep sleep now; wakes on the UART wire (IO1) or every 60 s for a 4 s listen
|
||||
```
|
||||
B prints a stats line every 5 s (`applied=… uart … espnow …`) — `uart alive` means the wire works.
|
||||
|
||||
@@ -160,9 +170,9 @@ B prints a stats line every 5 s (`applied=… uart … espnow …`) — `uart al
|
||||
|
||||
## 6. Procedures
|
||||
|
||||
### Pair a Controller B (once per board pair)
|
||||
### Pair a Inst. Cluster (once per board pair)
|
||||
1. Wire: 5B terminal `485_A` → B `IO1`, GND → GND (a real wire, not just the USB hub), 5B's 120 Ω switch OFF. Both powered. B's stats line must say `uart alive`.
|
||||
2. A console: `link pair`. Within 5 s A logs `Controller B confirmed pairing (fingerprint XXXX)`; B logs `PAIRED over the wire`.
|
||||
2. A console: `link pair`. Within 5 s A logs `Inst. Cluster confirmed pairing (fingerprint XXXX)`; B logs `PAIRED over the wire`.
|
||||
3. `link status` on A: `key XXXX (matches)`. About 15 s later `Wi-Fi creds yes` (A pushes them by itself; `link creds` forces it).
|
||||
|
||||
The key lives in NVS on both boards and survives every flash and update. Re-pair only after an NVS erase, `link unpair`, or a board swap.
|
||||
@@ -175,10 +185,10 @@ git push --follow-tags origin main # A (B: origin master)
|
||||
One push, so only the tag build runs. Gitea builds, signs (`BMW_NISSAN_FIRMWARE_SIGNING_KEY`) and publishes `firmware.bin` + `manifest.txt`: A takes 7–20 min, B 2–5 min. Check: `https://git.infra.msai.al/<owner>/<repo>/releases`. Version strings must stay under 16 characters.
|
||||
|
||||
### Update A from the screen
|
||||
Settings → Updates → Controller A → **Check** → **Install vX.Y.Z** (parked, Wi-Fi joined). Progress bar, restart, `A vX.Y.Z` bottom-right. A reset in the first 30 s rolls back.
|
||||
Settings → Updates → Main CTRL → **Check** → **Install vX.Y.Z** (parked, Wi-Fi joined). Progress bar, restart, `A vX.Y.Z` bottom-right. A reset in the first 30 s rolls back.
|
||||
|
||||
### Update B from the screen
|
||||
Settings → Updates → Controller B → **Check** → **Install** (A on Wi-Fi, parked, B paired). B's round screen shows `Updating vX.Y.Z N%`, the card on A shows the percentage, B restarts and confirms itself after 30 s. Console equivalent: `link ota check`, `link ota install`.
|
||||
Settings → Updates → Inst. Cluster → **Check** → **Install** (A on Wi-Fi, parked, B paired). B's round screen shows `Updating vX.Y.Z N%`, the card on A shows the percentage, B restarts and confirms itself after 30 s. Console equivalent: `link ota check`, `link ota install`.
|
||||
|
||||
### Something is wrong after an update
|
||||
`ota rollback` on the affected controller's console (B: `link ota rollback` from A also works). A reset within 30 s of the first boot of a new image rolls back on its own.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
**Version:** 2 (`PACKET_VERSION 0x02`)
|
||||
**Last Updated:** 2026-09-27
|
||||
**Source of truth:** `include/protocol/automotive_data.h` (+ `link_secure.h`) — byte-identical in both repos.
|
||||
**Direction:** gauge data Controller A (ESP32-S3-Touch-LCD-5B) → Controller B (ESP32-S3-LCD-1.3). Since 2026-09-27 B answers with `STATUS` frames over ESP-NOW and A sends B maintenance frames (`PAIR` on the wire, `SECURE` over ESP-NOW) — see *Maintenance frames* below.
|
||||
**Direction:** gauge data Main CTRL (ESP32-S3-Touch-LCD-5B) → Inst. Cluster (ESP32-S3-LCD-1.3). Since 2026-09-27 B answers with `STATUS` frames over ESP-NOW and A sends B maintenance frames (`PAIR` on the wire, `SECURE` over ESP-NOW) — see *Maintenance frames* below.
|
||||
|
||||
---
|
||||
|
||||
@@ -101,7 +101,7 @@ Tach: `f = rpm × tach_ppr / 60 × (1 + trim/100)`, clamped, 50 % duty. Output l
|
||||
|
||||
---
|
||||
|
||||
## Controller A console commands (USB serial)
|
||||
## Main CTRL console commands (USB serial)
|
||||
|
||||
```
|
||||
cfg show
|
||||
@@ -120,13 +120,13 @@ The same console also carries the OBD-II diagnostic probe (`diag pids | pid <hex
|
||||
|
||||
---
|
||||
|
||||
## Maintenance frames (2026-09-27) — for Controller B's firmware updates
|
||||
## Maintenance frames (2026-09-27) — for Inst. Cluster's firmware updates
|
||||
|
||||
`PACKET_VERSION` did not change: DATA and CONFIG are byte-identical, and a B built before these types counts them as type errors and carries on.
|
||||
|
||||
| Type | Direction | Transport | Payload | Purpose |
|
||||
|---|---|---|---|---|
|
||||
| `STATUS` 0x03 | B → A | ESP-NOW unicast to A's MAC (learned from A's data frames) | `link_status_t` (78 B): B's version, OTA phase (`LINK_OTA_*`, same numbering as A's `Ota::phase_t`), progress %, flags (paired / have Wi-Fi / joined / pending verify), `key_fp`, uptime, free heap, latest tag, message | every 5 s and on every phase change; A's Updates page "Controller B" card |
|
||||
| `STATUS` 0x03 | B → A | ESP-NOW unicast to A's MAC (learned from A's data frames) | `link_status_t` (78 B): B's version, OTA phase (`LINK_OTA_*`, same numbering as A's `Ota::phase_t`), progress %, flags (paired / have Wi-Fi / joined / pending verify), `key_fp`, uptime, free heap, latest tag, message | every 5 s and on every phase change; A's Updates page "Inst. Cluster" card |
|
||||
| `PAIR` 0x04 | A → B | **UART wire only** — B drops a PAIR heard by radio | `link_pair_t` (42 B): magic `"PAIR"`, 32-byte random key, A's STA MAC | `link pair` on A's console, sent 3×; both sides keep the key in NVS. The only secret in the system (both repos are public) |
|
||||
| `SECURE` 0x05 | A → B | ESP-NOW unicast | `nonce[12] \| tag[16] \| AES-256-GCM(key, nonce, inner_type \| inner)` — helpers in `link_secure.h` | inner `LINK_INNER_OTA_CMD` 0x11 (`link_ota_cmd_t`: check / install [force] / rollback + random nonce, B ignores a repeat of the last 4) or `LINK_INNER_WIFI_CREDS` 0x12 (`link_wifi_creds_t`: SET/FORGET, ssid, pass). B also requires the sender MAC to be the paired A |
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* ota_config.h - where Controller A looks for firmware updates, and what it trusts.
|
||||
* ota_config.h - where Main CTRL looks for firmware updates, and what it trusts.
|
||||
*
|
||||
* Updates are pulled over HTTPS from this repo's Gitea releases (public repo,
|
||||
* no token). CI (.gitea/workflows/firmware.yml) attaches firmware.bin +
|
||||
@@ -19,7 +19,7 @@
|
||||
#define FW_VERSION "dev"
|
||||
#endif
|
||||
|
||||
// Identity inside the signed statement, so a Controller B image can never be
|
||||
// Identity inside the signed statement, so a Inst. Cluster image can never be
|
||||
// accepted by A (and vice versa) even though both are signed by the same key.
|
||||
#define OTA_TARGET "patrol-a"
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ typedef struct {
|
||||
|
||||
/**
|
||||
* Decoded driveline speeds. Deliberately NOT part of automotive_data_t: that
|
||||
* struct is the wire format for the UART link to Controller B, and widening it
|
||||
* struct is the wire format for the UART link to Inst. Cluster, and widening it
|
||||
* would break the receiver. These live here until there's a reason to spend a
|
||||
* protocol version bump on them.
|
||||
*
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
* automotive_data.h
|
||||
*
|
||||
* Shared wire contract between Controller A (ESP32-S3-Touch-LCD-5B) and
|
||||
* Controller B (ESP32-S3-LCD-1.3).
|
||||
* Shared wire contract between Main CTRL (ESP32-S3-Touch-LCD-5B) and
|
||||
* Inst. Cluster (ESP32-S3-LCD-1.3).
|
||||
*
|
||||
* THIS FILE MUST BE BYTE-IDENTICAL IN BOTH REPOS. Copy it across whenever it
|
||||
* changes and bump PACKET_VERSION; B rejects frames with any other version.
|
||||
@@ -45,8 +45,8 @@
|
||||
// (B hops until it hears A, then locks)
|
||||
|
||||
// NOTE: UART pin assignments are controller-specific:
|
||||
// - Controller A (5B): uart_manager.cpp (TX GPIO 44 -> SP3485 -> 485_A/B)
|
||||
// - Controller B (1.3): platformio.ini (RX IO1)
|
||||
// - Main CTRL (5B): uart_manager.cpp (TX GPIO 44 -> SP3485 -> 485_A/B)
|
||||
// - Inst. Cluster (1.3): platformio.ini (RX IO1)
|
||||
|
||||
// ============================================================================
|
||||
// FRAME FORMAT (identical on UART and ESP-NOW)
|
||||
@@ -90,7 +90,7 @@ typedef enum {
|
||||
LEVER_UNKNOWN = 0xFF
|
||||
} gear_lever_t;
|
||||
|
||||
// Controller A's internal gear enum (CAN decode helpers below use it). Not on
|
||||
// Main CTRL's internal gear enum (CAN decode helpers below use it). Not on
|
||||
// the wire any more - B never sees it.
|
||||
typedef enum {
|
||||
GEAR_PARK = 0,
|
||||
@@ -187,6 +187,10 @@ typedef struct __attribute__((packed)) {
|
||||
|
||||
#define OUT_ENABLE_TACH (1 << 0)
|
||||
#define OUT_ENABLE_TEMP (1 << 1)
|
||||
// Not an output: the Main CTRL's "Sleep when the car is off" switch, carried in
|
||||
// the same byte so the CONFIG layout (and PACKET_VERSION) stay unchanged. The
|
||||
// Inst. Cluster caches CONFIG in NVS, so it knows the setting while A sleeps.
|
||||
#define CFG_SLEEP_WHEN_SILENT (1 << 7)
|
||||
#define OVERRIDE_TACH (1 << 0)
|
||||
#define OVERRIDE_TEMP (1 << 1)
|
||||
|
||||
@@ -216,7 +220,7 @@ static inline void link_config_defaults(link_config_t* c) {
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// LINK MAINTENANCE FRAMES (2026-09-27) - Controller B firmware updates
|
||||
// LINK MAINTENANCE FRAMES (2026-09-27) - Inst. Cluster firmware updates
|
||||
// ============================================================================
|
||||
//
|
||||
// B pulls its own signed release over Wi-Fi; A only hands it the credentials
|
||||
@@ -241,7 +245,7 @@ typedef struct __attribute__((packed)) {
|
||||
} link_pair_t; // 42 bytes
|
||||
|
||||
// --- STATUS (B -> A, ESP-NOW unicast, every LINK_STATUS_PERIOD_MS) ----------
|
||||
// ota_phase mirrors Controller A's Ota::phase_t so one UI renders both.
|
||||
// ota_phase mirrors Main CTRL's Ota::phase_t so one UI renders both.
|
||||
#define LINK_OTA_IDLE 0
|
||||
#define LINK_OTA_CHECKING 1
|
||||
#define LINK_OTA_UP_TO_DATE 2
|
||||
@@ -756,7 +760,7 @@ static inline const char* gear_to_string(gear_position_t gear) {
|
||||
* @return Pointer to buffer
|
||||
*/
|
||||
static inline char* format_temperature(int16_t temp_x10, char* buffer) {
|
||||
// Plain "C": Controller B's UI font has no degree-sign glyph.
|
||||
// Plain "C": Inst. Cluster's UI font has no degree-sign glyph.
|
||||
sprintf(buffer, "%d.%dC", temp_x10 / 10, abs(temp_x10 % 10));
|
||||
return buffer;
|
||||
}
|
||||
@@ -774,6 +778,6 @@ static inline char* format_voltage(uint16_t voltage_x100, char* buffer) {
|
||||
|
||||
// No default / test values: a field is only ever filled from a CAN frame, and
|
||||
// its VALID_FLAG_* bit says so. Removed 2026-09-28 - the bench defaults
|
||||
// (89 / 85 degC, 12.45 V) looked like real readings on Controller B.
|
||||
// (89 / 85 degC, 12.45 V) looked like real readings on Inst. Cluster.
|
||||
|
||||
#endif // _AUTOMOTIVE_DATA_H
|
||||
@@ -5,7 +5,7 @@
|
||||
*
|
||||
* payload = nonce[12] | tag[16] | AES-256-GCM(key, nonce, inner_type | inner)
|
||||
*
|
||||
* Both cores ship mbedtls (2.28 on Controller B's IDF 4.4, 3.x on Controller
|
||||
* Both cores ship mbedtls (2.28 on Inst. Cluster's IDF 4.4, 3.x on Controller
|
||||
* A's IDF 5.5); the GCM calls are the same, only SHA-256's name differs.
|
||||
*/
|
||||
|
||||
|
||||
+8
-4
@@ -14,11 +14,12 @@
|
||||
#include "modules/serial_lock.h" // Global serial write mutex
|
||||
#include "modules/tunables.h" // Gauge calibration + alert thresholds (NVS, serial console)
|
||||
#include "modules/perf_monitor.h" // `perf` console: render fps, flush cost, CPU idle, heap
|
||||
#include "modules/espnow_link.h" // ESP-NOW transmit leg of the link to Controller B
|
||||
#include "modules/espnow_link.h" // ESP-NOW transmit leg of the link to Inst. Cluster
|
||||
#include "modules/diag_probe.h" // On-demand OBD-II requests (`diag` console) - the only CAN transmitter
|
||||
#include "modules/ota_update.h" // Manual firmware updates from Gitea releases (`ota` console)
|
||||
#include "modules/link_peer.h" // Controller B status, pairing, credential handoff, B updates (`link` console)
|
||||
#include "modules/link_peer.h" // Inst. Cluster status, pairing, credential handoff, B updates (`link` console)
|
||||
#include "modules/status_overlay.h" // Every screen: Wi-Fi chip top-right, blinking alert banner top-centre
|
||||
#include "modules/power_manager.h" // Deep sleep when the car is off (Settings switch, `sleep` console)
|
||||
|
||||
// ============================================================================
|
||||
// MINIMAL LVGL + UI SETTINGS + WIFI + UART
|
||||
@@ -61,7 +62,8 @@ static bool memCommand(const char* line) {
|
||||
static bool consoleExtraCommand(const char* line) {
|
||||
return DiagProbe::handleCommand(line) || Ota::handleCommand(line) ||
|
||||
WiFiManager::handleCommand(line) || memCommand(line) ||
|
||||
PerfMon::handleCommand(line) || LinkPeer::handleCommand(line);
|
||||
PerfMon::handleCommand(line) || LinkPeer::handleCommand(line) ||
|
||||
PowerManager::handleCommand(line);
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
@@ -99,6 +101,7 @@ void setup()
|
||||
Tunables::init();
|
||||
DiagProbe::init();
|
||||
Tunables::setExtraCommandHandler(consoleExtraCommand);
|
||||
PowerManager::init(SettingsManager::loadSleepState()); // after Tunables: mirrors the switch into the config
|
||||
PerfMon::init();
|
||||
|
||||
// Load saved switch states from NVS
|
||||
@@ -164,12 +167,13 @@ void loop()
|
||||
PerfMon::tick();
|
||||
DiagProbe::tick();
|
||||
Ota::tick(); // confirms a freshly installed image after healthy uptime
|
||||
LinkPeer::tick(); // Controller B heard/lost, credential sync
|
||||
LinkPeer::tick(); // Inst. Cluster heard/lost, credential sync
|
||||
|
||||
DrivelineScreen::tick();
|
||||
TuningScreen::tick();
|
||||
SettingsScreen::tick();
|
||||
StatusOverlay::tick();
|
||||
PowerManager::tick(); // deep sleep once the bus and the screen have been quiet for a minute
|
||||
|
||||
delay(100); // Check frequently to catch screen changes quickly
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* ESP-NOW Link Module Implementation (Controller A, transmit only)
|
||||
* ESP-NOW Link Module Implementation (Main CTRL, transmit only)
|
||||
*/
|
||||
|
||||
#include "espnow_link.h"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* ESP-NOW Link Module (Controller A side)
|
||||
* ESP-NOW Link Module (Main CTRL side)
|
||||
*
|
||||
* Second transport for the A -> B link: every frame the UART manager builds
|
||||
* is also broadcast over ESP-NOW, so B keeps receiving if the wire is lost.
|
||||
|
||||
+21
-21
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Link Peer Module Implementation (Controller A)
|
||||
* Link Peer Module Implementation (Main CTRL)
|
||||
*
|
||||
* Threading: onFrame() runs in the Wi-Fi task and only copies the STATUS into
|
||||
* g_peer under a mutex. Everything else (NVS, sending, console) is the loop task.
|
||||
@@ -129,9 +129,9 @@ peer_status_t getStatus() {
|
||||
// ---- outbound ---------------------------------------------------------------
|
||||
static bool sendSecure(uint8_t inner_type, const void* inner, size_t inner_len, char* why, size_t n) {
|
||||
peer_status_t p = getStatus();
|
||||
if (!p.heard) { snprintf(why, n, "Controller B not heard"); return false; }
|
||||
if (!p.heard) { snprintf(why, n, "Inst. Cluster not heard"); return false; }
|
||||
if (!p.paired) { snprintf(why, n, "not paired - run `link pair` with the wire connected"); return false; }
|
||||
if (!p.key_match) { snprintf(why, n, "Controller B holds a different key - run `link pair` again"); return false; }
|
||||
if (!p.key_match) { snprintf(why, n, "Inst. Cluster holds a different key - run `link pair` again"); return false; }
|
||||
|
||||
uint8_t payload[PACKET_MAX_PAYLOAD], frame[PACKET_MAX_SIZE];
|
||||
size_t plen = link_secure_seal(g_key, inner_type, inner, inner_len, payload);
|
||||
@@ -175,8 +175,8 @@ static bool pushCredentials(char* why, size_t n, bool log) {
|
||||
if (ok) {
|
||||
g_pushed_hash = have ? hashStr(hashStr(2166136261u, c.ssid), c.pass) : 1;
|
||||
g_last_push_ms = millis();
|
||||
if (log) print(have ? "[link] Wi-Fi credentials for '%s' sent to Controller B (encrypted)"
|
||||
: "[link] told Controller B to forget its Wi-Fi credentials", c.ssid);
|
||||
if (log) print(have ? "[link] Wi-Fi credentials for '%s' sent to Inst. Cluster (encrypted)"
|
||||
: "[link] told Inst. Cluster to forget its Wi-Fi credentials", c.ssid);
|
||||
}
|
||||
memset(&c, 0, sizeof(c));
|
||||
return ok;
|
||||
@@ -204,7 +204,7 @@ static void syncCredentials() {
|
||||
// ---- pairing ----------------------------------------------------------------
|
||||
static bool pair(char* why, size_t n) {
|
||||
if (UARTManager::getState() == UARTManager::UART_STATE_OFF) {
|
||||
snprintf(why, n, "link is off - enable 'Send to Controller B' in Settings first");
|
||||
snprintf(why, n, "link is off - enable 'Send to Inst. Cluster' in Settings first");
|
||||
return false;
|
||||
}
|
||||
link_pair_t pk = {};
|
||||
@@ -229,31 +229,31 @@ static bool pair(char* why, size_t n) {
|
||||
g_pushed_hash = 0; // re-send the credentials under the new key
|
||||
g_last_push_ms = 0;
|
||||
print("[link] PAIR sent over the wire %d time(s); new key fingerprint %04X. "
|
||||
"Controller B confirms in its next STATUS (`link status`).", sent, g_key_fp);
|
||||
"Inst. Cluster confirms in its next STATUS (`link status`).", sent, g_key_fp);
|
||||
return true;
|
||||
}
|
||||
|
||||
// ---- public: requests (UI) --------------------------------------------------
|
||||
static bool bReady(char* why, size_t n, bool need_parked) {
|
||||
peer_status_t p = getStatus();
|
||||
if (!p.heard) { snprintf(why, n, "Controller B not heard - is it powered?"); return false; }
|
||||
if (!p.heard) { snprintf(why, n, "Inst. Cluster not heard - is it powered?"); return false; }
|
||||
if (!p.paired || !p.key_match) {
|
||||
snprintf(why, n, "Controller B is not paired with this controller (console: link pair, wire connected)");
|
||||
snprintf(why, n, "Inst. Cluster is not paired with this controller (console: link pair, wire connected)");
|
||||
return false;
|
||||
}
|
||||
if (!(p.st.flags & LINK_STATUS_HAVE_WIFI)) {
|
||||
snprintf(why, n, "Controller B has no Wi-Fi credentials yet - join a network on this screen first");
|
||||
snprintf(why, n, "Inst. Cluster has no Wi-Fi credentials yet - join a network on this screen first");
|
||||
return false;
|
||||
}
|
||||
if (p.st.ota_phase == LINK_OTA_CHECKING || p.st.ota_phase == LINK_OTA_INSTALLING) {
|
||||
snprintf(why, n, "Controller B is busy (%s)", phaseName(p.st.ota_phase));
|
||||
snprintf(why, n, "Inst. Cluster is busy (%s)", phaseName(p.st.ota_phase));
|
||||
return false;
|
||||
}
|
||||
if (need_parked && !Ota::isParked(why, n)) return false;
|
||||
// Same network as B => same radio channel, so B's STATUS frames (progress)
|
||||
// keep reaching this screen while B is joined.
|
||||
if (WiFiManager::getStatus().link != WiFiManager::LINK_CONNECTED) {
|
||||
snprintf(why, n, "join Wi-Fi on this controller first, so Controller B's progress can be followed");
|
||||
snprintf(why, n, "join Wi-Fi on this controller first, so Inst. Cluster's progress can be followed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -274,7 +274,7 @@ void init() {
|
||||
if (g_mutex == NULL) g_mutex = xSemaphoreCreateMutex();
|
||||
loadKey();
|
||||
EspNowLink::setReceiveHandler(onFrame);
|
||||
print("[link] Controller B: %s", g_paired ? "pairing key loaded" : "NOT paired - `link pair` with the wire connected");
|
||||
print("[link] Inst. Cluster: %s", g_paired ? "pairing key loaded" : "NOT paired - `link pair` with the wire connected");
|
||||
}
|
||||
|
||||
void tick() {
|
||||
@@ -288,18 +288,18 @@ void tick() {
|
||||
peer_status_t p = getStatus();
|
||||
if (p.heard != was_heard) {
|
||||
was_heard = p.heard;
|
||||
if (p.heard) print("[link] Controller B heard: %s, %s, %lu s up", p.st.version,
|
||||
if (p.heard) print("[link] Inst. Cluster heard: %s, %s, %lu s up", p.st.version,
|
||||
p.key_match ? "paired" : (p.st.key_fp ? "paired with ANOTHER key" : "unpaired"),
|
||||
(unsigned long)p.st.uptime_s);
|
||||
else print("[link] Controller B silent for %lu s", (unsigned long)(p.age_ms / 1000));
|
||||
else print("[link] Inst. Cluster silent for %lu s", (unsigned long)(p.age_ms / 1000));
|
||||
}
|
||||
if (p.heard && p.key_match && !was_match) {
|
||||
print("[link] Controller B confirmed pairing (fingerprint %04X)", p.st.key_fp);
|
||||
print("[link] Inst. Cluster confirmed pairing (fingerprint %04X)", p.st.key_fp);
|
||||
}
|
||||
was_match = p.heard && p.key_match;
|
||||
if (p.heard && p.st.ota_phase != last_phase) {
|
||||
if (last_phase != 0xFF || p.st.ota_phase != LINK_OTA_IDLE)
|
||||
print("[link] Controller B update: %s%s%s%s%s", phaseName(p.st.ota_phase),
|
||||
print("[link] Inst. Cluster update: %s%s%s%s%s", phaseName(p.st.ota_phase),
|
||||
p.st.latest[0] ? ", latest " : "", p.st.latest,
|
||||
p.st.ota_phase == LINK_OTA_FAILED ? " - " : "",
|
||||
p.st.ota_phase == LINK_OTA_FAILED ? p.st.message : "");
|
||||
@@ -310,7 +310,7 @@ void tick() {
|
||||
|
||||
// ---- console ----------------------------------------------------------------
|
||||
static void help() {
|
||||
print("link status Controller B: version, pairing, update phase");
|
||||
print("link status Inst. Cluster: version, pairing, update phase");
|
||||
print("link pair new shared key -> B over the UART wire (bench, wire connected)");
|
||||
print("link unpair forget the key here (B keeps its own until re-paired)");
|
||||
print("link creds send the remembered Wi-Fi network to B now");
|
||||
@@ -329,8 +329,8 @@ bool handleCommand(const char* line) {
|
||||
print("[link] this side: %s (fingerprint %04X) | STATUS frames %lu | SECURE sent %lu, failed %lu",
|
||||
p.paired ? "paired" : "NOT paired", p.key_fp, (unsigned long)g_status_count,
|
||||
(unsigned long)g_secure_sent, (unsigned long)g_secure_fail);
|
||||
if (!g_ever_heard) { print("[link] Controller B never heard"); return true; }
|
||||
print("[link] Controller B %02X:%02X:%02X:%02X:%02X:%02X, %s (%lu s ago)",
|
||||
if (!g_ever_heard) { print("[link] Inst. Cluster never heard"); return true; }
|
||||
print("[link] Inst. Cluster %02X:%02X:%02X:%02X:%02X:%02X, %s (%lu s ago)",
|
||||
p.mac[0], p.mac[1], p.mac[2], p.mac[3], p.mac[4], p.mac[5],
|
||||
p.heard ? "alive" : "SILENT", (unsigned long)(p.age_ms / 1000));
|
||||
print("[link] firmware %s | key %04X (%s) | Wi-Fi creds %s%s%s",
|
||||
@@ -360,7 +360,7 @@ bool handleCommand(const char* line) {
|
||||
else if (!strcmp(b, "install force")) ok = bReady(why, sizeof(why), true) && sendOtaCmd(LINK_OTA_CMD_INSTALL, LINK_OTA_FORCE, why, sizeof(why));
|
||||
else if (!strcmp(b, "rollback")) ok = bReady(why, sizeof(why), true) && sendOtaCmd(LINK_OTA_CMD_ROLLBACK, 0, why, sizeof(why));
|
||||
else { help(); return true; }
|
||||
print(ok ? "[link] command sent to Controller B - watch `link status`" : "[link] refused: %s", why);
|
||||
print(ok ? "[link] command sent to Inst. Cluster - watch `link status`" : "[link] refused: %s", why);
|
||||
return true;
|
||||
}
|
||||
help();
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
/*
|
||||
* Link Peer Module (Controller A) - what A knows about Controller B, and the
|
||||
* Link Peer Module (Main CTRL) - what A knows about Inst. Cluster, and the
|
||||
* maintenance traffic that keeps B updatable. See
|
||||
* ESP32-S3-LCD-1.3/wiki/pages/controller-b-ota.md (B's wiki).
|
||||
*
|
||||
* STATUS B -> A ESP-NOW unicast every 5 s: B's version, OTA phase, uptime.
|
||||
* Shown on Settings -> Updates as the "Controller B" card.
|
||||
* Shown on Settings -> Updates as the "Inst. Cluster" card.
|
||||
* PAIR A -> B `link pair` on the console, UART WIRE ONLY: a fresh random
|
||||
* key, kept in NVS on both sides. Both repos are public, so
|
||||
* this is the only secret and it never travels by radio.
|
||||
|
||||
@@ -144,7 +144,7 @@ static const char* stateName(esp_ota_img_states_t s) {
|
||||
|
||||
/**
|
||||
* The vehicle must be parked to update: installing ends in a reboot that blanks
|
||||
* Controller B's gauges. A silent bus (ignition off, or the bench) counts as
|
||||
* Inst. Cluster's gauges. A silent bus (ignition off, or the bench) counts as
|
||||
* parked. Lever UNKNOWN is allowed so a missing gear frame can't block a bench
|
||||
* update; engine and output shaft are the checks that matter.
|
||||
*/
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
* or crash before that makes the bootloader fall back to the old slot.
|
||||
*
|
||||
* Needs Wi-Fi joined to a network with internet (Settings screen). Joining an
|
||||
* AP moves the radio channel; the ESP-NOW link to Controller B follows it.
|
||||
* AP moves the radio channel; the ESP-NOW link to Inst. Cluster follows it.
|
||||
* See wiki/pages/ota-updates.md.
|
||||
*/
|
||||
|
||||
@@ -66,7 +66,7 @@ ui_status_t getStatus();
|
||||
bool requestCheck(char* why, size_t n);
|
||||
bool requestInstall(char* why, size_t n);
|
||||
|
||||
/** The parking gate on its own (Controller B's install is guarded by it too). */
|
||||
/** The parking gate on its own (Inst. Cluster's install is guarded by it too). */
|
||||
bool isParked(char* why, size_t n);
|
||||
|
||||
} // namespace Ota
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
* Power Manager implementation (Main CTRL). See power_manager.h.
|
||||
*/
|
||||
|
||||
#include "power_manager.h"
|
||||
#include "settings_manager.h"
|
||||
#include "tunables.h"
|
||||
#include "ota_update.h"
|
||||
#include "link_peer.h"
|
||||
#include "display_init.h"
|
||||
#include "serial_lock.h"
|
||||
#include "drivers/can_driver.h"
|
||||
#include "display/lvgl_v8_port.h"
|
||||
#include "protocol/automotive_data.h"
|
||||
#include <lvgl.h>
|
||||
#include <esp_sleep.h>
|
||||
#include <driver/rtc_io.h>
|
||||
|
||||
namespace PowerManager {
|
||||
|
||||
static const uint32_t SLEEP_AFTER_MS = 60000; // quiet bus + idle touch + uptime before sleeping
|
||||
|
||||
static bool g_enabled = false;
|
||||
static uint32_t g_last_log = 0;
|
||||
|
||||
static void print(const char* fmt, ...) {
|
||||
char buf[200];
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
vsnprintf(buf, sizeof(buf), fmt, ap);
|
||||
va_end(ap);
|
||||
SerialLock::lock();
|
||||
Serial.println(buf);
|
||||
SerialLock::unlock();
|
||||
}
|
||||
|
||||
static void mirrorToCluster() {
|
||||
link_config_t cfg = Tunables::get();
|
||||
uint8_t want = g_enabled ? (cfg.out_enable | CFG_SLEEP_WHEN_SILENT) : (cfg.out_enable & ~CFG_SLEEP_WHEN_SILENT);
|
||||
if (want == cfg.out_enable) return;
|
||||
cfg.out_enable = want;
|
||||
Tunables::set(cfg); // bumps cfg_version -> CONFIG frame -> Inst. Cluster caches it in NVS
|
||||
}
|
||||
|
||||
void init(bool enabled) {
|
||||
g_enabled = enabled;
|
||||
esp_sleep_wakeup_cause_t why = esp_sleep_get_wakeup_cause();
|
||||
if (why == ESP_SLEEP_WAKEUP_EXT0) print("[sleep] woke up: CAN bus activity");
|
||||
print("[sleep] sleep when the car is off: %s", g_enabled ? "ON (60 s of quiet bus + idle screen)" : "off");
|
||||
mirrorToCluster();
|
||||
}
|
||||
|
||||
void setEnabled(bool on) {
|
||||
if (on == g_enabled) return;
|
||||
g_enabled = on;
|
||||
SettingsManager::saveSleepState(on);
|
||||
mirrorToCluster();
|
||||
print("[sleep] %s", on ? "enabled - both controllers sleep 60 s after the bus goes quiet" : "disabled");
|
||||
}
|
||||
|
||||
bool isEnabled() { return g_enabled; }
|
||||
|
||||
/** Why we are NOT sleeping right now, or NULL if every condition holds. */
|
||||
static const char* blocker() {
|
||||
if (!g_enabled) return "disabled";
|
||||
if (millis() < SLEEP_AFTER_MS) return "just booted";
|
||||
if (!CANDriver::isActive()) return "CAN switched off (no wake source)";
|
||||
can_stats_t s = CANDriver::getStats();
|
||||
if (s.messages_received > 0 && millis() - s.last_receive_time < SLEEP_AFTER_MS) return "bus alive";
|
||||
Ota::ui_status_t o = Ota::getStatus();
|
||||
if (o.phase == Ota::PHASE_CHECKING || o.phase == Ota::PHASE_INSTALLING) return "update running";
|
||||
LinkPeer::peer_status_t p = LinkPeer::getStatus();
|
||||
if (p.heard && (p.st.ota_phase == LINK_OTA_CHECKING || p.st.ota_phase == LINK_OTA_INSTALLING)) return "Inst. Cluster updating";
|
||||
uint32_t idle = 0;
|
||||
if (lvgl_port_lock(50)) { idle = lv_disp_get_inactive_time(NULL); lvgl_port_unlock(); }
|
||||
else return "screen busy";
|
||||
if (idle < SLEEP_AFTER_MS) return "screen in use";
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void goToSleep(const char* reason) {
|
||||
print("[sleep] %s - deep sleep now; the CAN bus wakes me", reason);
|
||||
Tunables::flush();
|
||||
DisplayInit::setBacklight(false);
|
||||
CANDriver::stop(); // frees GPIO 16 from the TWAI peripheral
|
||||
delay(400); // let the CAN task deinit TWAI
|
||||
// CAN RX idles high (recessive); the first bit of any frame pulls it low.
|
||||
rtc_gpio_pulldown_dis((gpio_num_t)CAN_RX_PIN);
|
||||
rtc_gpio_pullup_en((gpio_num_t)CAN_RX_PIN);
|
||||
esp_sleep_enable_ext0_wakeup((gpio_num_t)CAN_RX_PIN, 0);
|
||||
SerialLock::lock();
|
||||
Serial.flush();
|
||||
SerialLock::unlock();
|
||||
esp_deep_sleep_start();
|
||||
}
|
||||
|
||||
void tick() {
|
||||
static uint32_t last = 0;
|
||||
if (millis() - last < 1000) return;
|
||||
last = millis();
|
||||
const char* b = blocker();
|
||||
if (b == NULL) goToSleep("bus quiet and screen idle for 60 s");
|
||||
}
|
||||
|
||||
static void help() {
|
||||
print("sleep status why the board is awake / when it would sleep");
|
||||
print("sleep on | off same as the Settings switch (both controllers)");
|
||||
print("sleep now deep sleep immediately (wake = CAN activity or power cycle)");
|
||||
}
|
||||
|
||||
bool handleCommand(const char* line) {
|
||||
if (strncmp(line, "sleep", 5) != 0 || (line[5] != 0 && line[5] != ' ')) return false;
|
||||
const char* a = line + 5;
|
||||
while (*a == ' ') a++;
|
||||
if (!*a || !strcmp(a, "help")) { help(); return true; }
|
||||
if (!strcmp(a, "status")) {
|
||||
const char* b = blocker();
|
||||
print("[sleep] %s | %s", g_enabled ? "enabled" : "disabled", b ? b : "about to sleep");
|
||||
return true;
|
||||
}
|
||||
if (!strcmp(a, "on")) { setEnabled(true); return true; }
|
||||
if (!strcmp(a, "off")) { setEnabled(false); return true; }
|
||||
if (!strcmp(a, "now")) { goToSleep("console"); return true; }
|
||||
help();
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace PowerManager
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Power Manager (Main CTRL) - deep sleep when the car is off.
|
||||
*
|
||||
* Toggle: Settings -> System -> "Sleep when the car is off" (NVS `sleep_en`,
|
||||
* default OFF). The same switch is mirrored to the Inst. Cluster through the
|
||||
* CONFIG frame (CFG_SLEEP_WHEN_SILENT bit), so one switch rules both boards.
|
||||
*
|
||||
* When enabled, this board goes to DEEP SLEEP once ALL of these hold:
|
||||
* - CAN is switched on but the bus has been quiet for SLEEP_AFTER_MS
|
||||
* (ignition off; a live car never stops talking)
|
||||
* - nobody touched the screen for SLEEP_AFTER_MS
|
||||
* - no update job is running here or on the Inst. Cluster
|
||||
* - the board has been up for at least SLEEP_AFTER_MS
|
||||
*
|
||||
* Wake: the CAN RX pin (GPIO 16, an RTC IO on the S3) goes low with the first
|
||||
* frame after the ignition comes back -> full reboot (~3 s to the Driveline).
|
||||
* Nothing else wakes it: with the CAN wire unplugged, cycle the power.
|
||||
*
|
||||
* Console: sleep status | on | off | now
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
namespace PowerManager {
|
||||
|
||||
void init(bool enabled);
|
||||
void setEnabled(bool on); // persists + mirrors to the Inst. Cluster config
|
||||
bool isEnabled();
|
||||
void tick(); // from loop()
|
||||
bool handleCommand(const char* line);
|
||||
|
||||
} // namespace PowerManager
|
||||
@@ -18,6 +18,7 @@ static const char* NVS_NAMESPACE = "settings";
|
||||
static const char* NVS_KEY_WIFI_ENABLED = "wifi_en";
|
||||
static const char* NVS_KEY_UART_ENABLED = "uart_en";
|
||||
static const char* NVS_KEY_DEBUG_ENABLED = "debug_en";
|
||||
static const char* NVS_KEY_SLEEP_ENABLED = "sleep_en";
|
||||
static const char* NVS_KEY_CAN_ENABLED = "can_en";
|
||||
|
||||
// ============================================================================
|
||||
@@ -66,6 +67,20 @@ void saveDebugState(bool enabled) {
|
||||
Serial.printf("[SettingsManager] Saved Debug state = %s\n", enabled ? "ON" : "OFF");
|
||||
}
|
||||
|
||||
void saveSleepState(bool enabled) {
|
||||
preferences.begin(NVS_NAMESPACE, false);
|
||||
preferences.putBool(NVS_KEY_SLEEP_ENABLED, enabled);
|
||||
preferences.end();
|
||||
Serial.printf("[SettingsManager] Saved Sleep state = %s\n", enabled ? "ON" : "OFF");
|
||||
}
|
||||
|
||||
bool loadSleepState() {
|
||||
preferences.begin(NVS_NAMESPACE, true);
|
||||
bool enabled = preferences.getBool(NVS_KEY_SLEEP_ENABLED, false);
|
||||
preferences.end();
|
||||
return enabled;
|
||||
}
|
||||
|
||||
bool loadDebugState() {
|
||||
preferences.begin(NVS_NAMESPACE, true); // read-only mode
|
||||
bool enabled = preferences.getBool(NVS_KEY_DEBUG_ENABLED, false); // default: OFF
|
||||
|
||||
@@ -60,6 +60,10 @@ bool loadDebugState();
|
||||
*/
|
||||
void saveCANState(bool enabled);
|
||||
|
||||
/** "Sleep when the car is off" (deep sleep after 60 s of quiet CAN bus). Default OFF. */
|
||||
void saveSleepState(bool enabled);
|
||||
bool loadSleepState();
|
||||
|
||||
/**
|
||||
* @brief Load CAN Bus enabled state from NVS
|
||||
* @return bool true if CAN Bus was enabled, false otherwise (default: false)
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "wifi_manager.h"
|
||||
#include "ota_update.h"
|
||||
#include "link_peer.h"
|
||||
#include "power_manager.h"
|
||||
#include "uart_manager.h"
|
||||
#include "espnow_link.h"
|
||||
#include "settings_manager.h"
|
||||
@@ -82,6 +83,7 @@ static Ota::phase_t g_upd_refusal_phase = Ota::PHASE_IDLE;
|
||||
static lv_obj_t* g_sys_can = NULL;
|
||||
static lv_obj_t* g_sys_link = NULL;
|
||||
static lv_obj_t* g_sys_dbg = NULL;
|
||||
static lv_obj_t* g_sys_sleep = NULL;
|
||||
static lv_obj_t* g_sys_info = NULL; // values column; keys are static
|
||||
|
||||
static void refresh(bool force);
|
||||
@@ -208,7 +210,7 @@ static void onForget(lv_event_t* e) {
|
||||
(void)e;
|
||||
WiFiManager::status_t s = WiFiManager::getStatus();
|
||||
char text[128];
|
||||
snprintf(text, sizeof(text), "Controller A will no longer join \"%s\" by itself.", s.saved_ssid);
|
||||
snprintf(text, sizeof(text), "Main CTRL will no longer join \"%s\" by itself.", s.saved_ssid);
|
||||
confirm("Forget this network?", text, "Forget", onForgetConfirmed, NULL);
|
||||
}
|
||||
|
||||
@@ -403,7 +405,7 @@ static void buildWifiPage(lv_obj_t* page) {
|
||||
|
||||
g_wifi_off_note = label(page,
|
||||
"Wi-Fi is off.\n\nTurn it on to join a network for firmware updates. "
|
||||
"The link to Controller B works without it.",
|
||||
"The link to Inst. Cluster works without it.",
|
||||
&lv_font_montserrat_20, UI_COL_MUTED);
|
||||
lv_label_set_long_mode(g_wifi_off_note, LV_LABEL_LONG_WRAP);
|
||||
lv_obj_set_width(g_wifi_off_note, LV_PCT(100));
|
||||
@@ -511,7 +513,7 @@ static void buildPasswordOverlay() {
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// UPDATES PAGE - Controller A (this board) and Controller B (over the link)
|
||||
// UPDATES PAGE - Main CTRL (this board) and Inst. Cluster (over the link)
|
||||
// ============================================================================
|
||||
|
||||
static lv_obj_t* g_b_installed = NULL;
|
||||
@@ -537,9 +539,8 @@ static void onInstall(lv_event_t* e) {
|
||||
char title[64];
|
||||
snprintf(title, sizeof(title), "Install %s?", o.latest);
|
||||
confirm(title,
|
||||
"A progress bar shows while the new firmware downloads (about a minute), "
|
||||
"then Controller A restarts. Controller B's gauges drop out for a few seconds.\n\n"
|
||||
"Do not switch off the ignition until it has restarted. Only while parked with the engine off.",
|
||||
"This Controller will restart after successful update.\n\nInstrument Cluster's gauges will drop out for a few seconds.\n\n"
|
||||
"DO NOT SWITCH OFF THE IGNITION!\n\nOnly while parked with the engine off!",
|
||||
"Install", onInstallConfirmed, NULL);
|
||||
}
|
||||
|
||||
@@ -569,9 +570,9 @@ static void onBInstall(lv_event_t* e) {
|
||||
(void)e;
|
||||
LinkPeer::peer_status_t p = LinkPeer::getStatus();
|
||||
char title[64];
|
||||
snprintf(title, sizeof(title), "Install %s on Controller B?", p.st.latest);
|
||||
snprintf(title, sizeof(title), "Install %s on Inst. Cluster?", p.st.latest);
|
||||
confirm(title,
|
||||
"Controller B joins the Wi-Fi network, downloads its new firmware and restarts; "
|
||||
"Inst. Cluster joins the Wi-Fi network, downloads its new firmware and restarts; "
|
||||
"its gauges hold still meanwhile and this card shows the progress.\n\n"
|
||||
"Only while parked with the engine off.",
|
||||
"Install", onBInstallConfirmed, NULL);
|
||||
@@ -599,7 +600,7 @@ static void refreshUpdatesA() {
|
||||
case Ota::PHASE_AVAILABLE: snprintf(msg, sizeof(msg), "Version %s is available.", o.latest); col = UI_COL_ACCENT; break;
|
||||
case Ota::PHASE_FAILED: snprintf(msg, sizeof(msg), LV_SYMBOL_WARNING " %s", o.message); col = UI_COL_WARN; break;
|
||||
default:
|
||||
snprintf(msg, sizeof(msg), "%s", wifi_ok ? "");
|
||||
snprintf(msg, sizeof(msg), "%s", wifi_ok ? "Tap Check to look for a new version." : "Connect to Wi-Fi to check for updates.");
|
||||
break;
|
||||
}
|
||||
if (g_upd_refusal[0]) {
|
||||
@@ -637,24 +638,24 @@ static void refreshUpdatesB() {
|
||||
char msg[160];
|
||||
lv_color_t col = UI_COL_MUTED;
|
||||
if (!p.heard) {
|
||||
snprintf(msg, sizeof(msg), "Controller B not heard.%s",
|
||||
snprintf(msg, sizeof(msg), "Inst. Cluster not heard.%s",
|
||||
p.paired ? "" : " Not paired yet: connect the wire and run 'link pair' on the console.");
|
||||
} else if (!p.paired || !p.key_match) {
|
||||
snprintf(msg, sizeof(msg), LV_SYMBOL_WARNING " Not paired with this controller. "
|
||||
"Connect the wire and run 'link pair' on the console.");
|
||||
col = UI_COL_AMBER;
|
||||
} else if (!has_wifi) {
|
||||
snprintf(msg, sizeof(msg), "Controller B has no Wi-Fi credentials yet. Join a network here; "
|
||||
snprintf(msg, sizeof(msg), "Inst. Cluster has no Wi-Fi credentials yet. Join a network here; "
|
||||
"they are passed on by themselves.");
|
||||
} else {
|
||||
switch (p.st.ota_phase) {
|
||||
case LINK_OTA_CHECKING: snprintf(msg, sizeof(msg), "Controller B is checking..."); break;
|
||||
case LINK_OTA_INSTALLING: snprintf(msg, sizeof(msg), "Installing %s on Controller B... %u %%",
|
||||
case LINK_OTA_CHECKING: snprintf(msg, sizeof(msg), "Inst. Cluster is checking..."); break;
|
||||
case LINK_OTA_INSTALLING: snprintf(msg, sizeof(msg), "Installing %s on Inst. Cluster... %u %%",
|
||||
p.st.latest, p.st.ota_progress); col = UI_COL_ACCENT; break;
|
||||
case LINK_OTA_UP_TO_DATE: snprintf(msg, sizeof(msg), LV_SYMBOL_OK " Controller B is up to date."); col = UI_COL_OK; break;
|
||||
case LINK_OTA_AVAILABLE: snprintf(msg, sizeof(msg), "Version %s is available for Controller B.", p.st.latest); col = UI_COL_ACCENT; break;
|
||||
case LINK_OTA_UP_TO_DATE: snprintf(msg, sizeof(msg), LV_SYMBOL_OK " Inst. Cluster is up to date."); col = UI_COL_OK; break;
|
||||
case LINK_OTA_AVAILABLE: snprintf(msg, sizeof(msg), "Version %s is available for Inst. Cluster.", p.st.latest); col = UI_COL_ACCENT; break;
|
||||
case LINK_OTA_FAILED: snprintf(msg, sizeof(msg), LV_SYMBOL_WARNING " %s", p.st.message); col = UI_COL_WARN; break;
|
||||
default: snprintf(msg, sizeof(msg), ""); break;
|
||||
default: snprintf(msg, sizeof(msg), "Tap Check to look for a new version"); break;
|
||||
}
|
||||
if (p.st.flags & LINK_STATUS_PENDING_VERIFY) {
|
||||
size_t n = strlen(msg);
|
||||
@@ -726,7 +727,7 @@ static void buildUpdatesPage(lv_obj_t* page) {
|
||||
label(page, "Firmware updates", &lv_font_montserrat_24, UI_COL_TEXT);
|
||||
|
||||
lv_obj_t* installed_a = NULL;
|
||||
lv_obj_t* a = controllerCard(page, "Controller A", FW_VERSION, &installed_a, &g_upd_latest, &g_upd_state);
|
||||
lv_obj_t* a = controllerCard(page, "Main CTRL", FW_VERSION, &installed_a, &g_upd_latest, &g_upd_state);
|
||||
lv_obj_t* btns = box(a, LV_FLEX_FLOW_ROW);
|
||||
lv_obj_set_size(btns, LV_PCT(100), LV_SIZE_CONTENT);
|
||||
lv_obj_set_style_pad_column(btns, 16, 0);
|
||||
@@ -734,7 +735,7 @@ static void buildUpdatesPage(lv_obj_t* page) {
|
||||
g_upd_install = button(btns, "Install", 280, 56, BTN_SUCCESS, onInstall, NULL);
|
||||
g_upd_wifi = button(btns, LV_SYMBOL_WIFI " Wi-Fi settings", 260, 56, BTN_SECONDARY, onGoWifi, NULL);
|
||||
|
||||
lv_obj_t* b = controllerCard(page, "Controller B", "-", &g_b_installed, &g_b_latest, &g_b_state);
|
||||
lv_obj_t* b = controllerCard(page, "Inst. Cluster", "-", &g_b_installed, &g_b_latest, &g_b_state);
|
||||
btns = box(b, LV_FLEX_FLOW_ROW);
|
||||
lv_obj_set_size(btns, LV_PCT(100), LV_SIZE_CONTENT);
|
||||
lv_obj_set_style_pad_column(btns, 16, 0);
|
||||
@@ -742,8 +743,7 @@ static void buildUpdatesPage(lv_obj_t* page) {
|
||||
g_b_install = button(btns, "Install", 280, 56, BTN_SUCCESS, onBInstall, NULL);
|
||||
|
||||
lv_obj_t* note = label(page,
|
||||
"Signed releases from " OTA_SERVER ". Each controller restarts after installing and keeps "
|
||||
"the previous version as a fallback.",
|
||||
"Each controller restarts after updating. DO NOT TURN OFF THE IGNITION DURING THE UPDATE",
|
||||
&lv_font_montserrat_20, UI_COL_MUTED);
|
||||
lv_label_set_long_mode(note, LV_LABEL_LONG_WRAP);
|
||||
lv_obj_set_width(note, LV_PCT(100));
|
||||
@@ -770,7 +770,13 @@ static void onDebugSwitch(lv_event_t* e) {
|
||||
UIStateManager::setDebugEnabled(on);
|
||||
}
|
||||
|
||||
static void onSleepSwitch(lv_event_t* e) {
|
||||
if (g_refreshing) return;
|
||||
PowerManager::setEnabled(lv_obj_has_state(lv_event_get_target(e), LV_STATE_CHECKED));
|
||||
}
|
||||
|
||||
static void refreshSystem(bool force) {
|
||||
setChecked(g_sys_sleep, PowerManager::isEnabled());
|
||||
setChecked(g_sys_can, CANDriver::isActive());
|
||||
setChecked(g_sys_link, UARTManager::getState() != UARTManager::UART_STATE_OFF);
|
||||
setChecked(g_sys_dbg, UIStateManager::isDebugEnabled());
|
||||
@@ -808,10 +814,12 @@ static void buildSystemPage(lv_obj_t* page) {
|
||||
lv_obj_t* right;
|
||||
makeSettingRow(c, "CAN bus", "Read the car's data bus", &right);
|
||||
g_sys_can = toggle(right, onCanSwitch, NULL);
|
||||
makeSettingRow(c, "Send to Controller B", "Gauge data over the wire and ESP-NOW", &right);
|
||||
makeSettingRow(c, "Send to Inst. Cluster", "Gauge data over the wire and ESP-NOW", &right);
|
||||
g_sys_link = toggle(right, onLinkSwitch, NULL);
|
||||
makeSettingRow(c, "Performance overlay", "Frame rate and CPU load in the corner", &right);
|
||||
g_sys_dbg = toggle(right, onDebugSwitch, NULL);
|
||||
makeSettingRow(c, "Sleep when the car is off", "Both controllers sleep 60 s after the CAN bus goes quiet", &right);
|
||||
g_sys_sleep = toggle(right, onSleepSwitch, NULL);
|
||||
|
||||
// two labels side by side, same line spacing, so keys and values line up
|
||||
lv_obj_t* info = card(page);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* entry; the joined network is remembered (WiFiManager)
|
||||
* Updates - installed vs latest release, Check, Install behind a confirm
|
||||
* dialog (Ota)
|
||||
* System - CAN bus / link to Controller B / performance overlay switches,
|
||||
* System - CAN bus / link to Inst. Cluster / performance overlay switches,
|
||||
* live link and memory figures
|
||||
*
|
||||
* Reached by swiping LEFT on the Driveline screen; swipe right or the
|
||||
|
||||
@@ -102,7 +102,7 @@ static void help() {
|
||||
print("cfg override off | rpm <n> | duty <n> | both <rpm> <duty>");
|
||||
print("cfg reset back to defaults");
|
||||
print("diag help OBD-II diagnostic probe (transmits on the bus)");
|
||||
print("link help Controller B: pairing, credentials, its updates");
|
||||
print("link help Inst. Cluster: pairing, credentials, its updates");
|
||||
}
|
||||
|
||||
static bool setField(const char* name, long v) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Tunables Module
|
||||
*
|
||||
* Owns the link_config_t that Controller A pushes to Controller B: Patrol gauge
|
||||
* Owns the link_config_t that Main CTRL pushes to Inst. Cluster: Patrol gauge
|
||||
* calibration (tach pulses/rev, coolant PWM law) and the alert thresholds A
|
||||
* evaluates. Persisted in NVS. Editable at runtime over the USB serial console
|
||||
* ("cfg help") until a settings-screen UI exists.
|
||||
|
||||
@@ -61,9 +61,9 @@ namespace TuningScreen
|
||||
{F_TEMP_OFFSET, TAB_COOLANT, "Offset", "Duty at 0 \xC2\xB0" "C (duty = slope x temp + offset)", 1, -1000, 1000, NULL},
|
||||
{F_TEMP_MIN, TAB_COOLANT, "Minimum temperature", "Needle stays at rest below this", 1, -50, 200, NULL},
|
||||
{F_TEMP_DUTY_MAX, TAB_COOLANT, "Duty limit", "Highest duty sent (255 = full scale)", 5, 0, 255, NULL},
|
||||
{F_COOLANT_HOT, TAB_ALERTS, "Coolant too hot", "Alarm on Controller B at or above this temperature", 1, 0, 200, NULL},
|
||||
{F_GEARBOX_HOT, TAB_ALERTS, "Gearbox oil too hot", "Alarm on Controller B at or above this temperature", 1, 0, 200, NULL},
|
||||
{F_BATT_LOW, TAB_ALERTS, "Battery low", "Alarm on Controller B below this voltage", 10, 0, 3000, NULL},
|
||||
{F_COOLANT_HOT, TAB_ALERTS, "Coolant too hot", "Alarm on Inst. Cluster at or above this temperature", 1, 0, 200, NULL},
|
||||
{F_GEARBOX_HOT, TAB_ALERTS, "Gearbox oil too hot", "Alarm on Inst. Cluster at or above this temperature", 1, 0, 200, NULL},
|
||||
{F_BATT_LOW, TAB_ALERTS, "Battery low", "Alarm on Inst. Cluster below this voltage", 10, 0, 3000, NULL},
|
||||
};
|
||||
|
||||
static const char *TAB_NAMES[TAB_COUNT] = {"Tachometer", "Coolant gauge", "Alerts", "Simulation"};
|
||||
@@ -522,7 +522,7 @@ namespace TuningScreen
|
||||
makeRow(g_tab_page[TAB_TACH], F_TACH_PPR);
|
||||
makeRow(g_tab_page[TAB_TACH], F_TACH_TRIM);
|
||||
makeRow(g_tab_page[TAB_TACH], F_TACH_MAX_HZ);
|
||||
g_tach_en_sw = makeSwitchRow(g_tab_page[TAB_TACH], "Tachometer output", "IO7 on Controller B. Off = no signal",
|
||||
g_tach_en_sw = makeSwitchRow(g_tab_page[TAB_TACH], "Tachometer output", "IO7 on Inst. Cluster. Off = no signal",
|
||||
onEnableSwitch, (void *)(uintptr_t)OUT_ENABLE_TACH);
|
||||
|
||||
// ---- Coolant gauge ----
|
||||
@@ -531,7 +531,7 @@ namespace TuningScreen
|
||||
makeRow(g_tab_page[TAB_COOLANT], F_TEMP_OFFSET);
|
||||
makeRow(g_tab_page[TAB_COOLANT], F_TEMP_MIN);
|
||||
makeRow(g_tab_page[TAB_COOLANT], F_TEMP_DUTY_MAX);
|
||||
g_temp_en_sw = makeSwitchRow(g_tab_page[TAB_COOLANT], "Coolant gauge output", "IO8 on Controller B. Off = no signal",
|
||||
g_temp_en_sw = makeSwitchRow(g_tab_page[TAB_COOLANT], "Coolant gauge output", "IO8 on Inst. Cluster. Off = no signal",
|
||||
onEnableSwitch, (void *)(uintptr_t)OUT_ENABLE_TEMP);
|
||||
|
||||
// ---- Alerts ----
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
* button (top right) goes back. The Simulation sliders don't bubble gestures,
|
||||
* so dragging them never changes screens.
|
||||
* Every change goes through Tunables, so it is saved to NVS (overrides
|
||||
* excepted) and pushed to Controller B in the next CONFIG frame.
|
||||
* excepted) and pushed to Inst. Cluster in the next CONFIG frame.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Builds the v2 frames (DATA at 5 Hz, CONFIG on change + every CONFIG_RESEND_MS)
|
||||
* and sends each one on BOTH transports: UART1 (GPIO 44 -> SP3485 -> 485_A/B)
|
||||
* and ESP-NOW broadcast. Controller B dedupes on packet_id.
|
||||
* and ESP-NOW broadcast. Inst. Cluster dedupes on packet_id.
|
||||
*/
|
||||
|
||||
#include "uart_manager.h"
|
||||
@@ -291,7 +291,7 @@ void setDebugEnabled(bool enabled) {
|
||||
if (xSemaphoreTake(g_data_mutex, pdMS_TO_TICKS(100)) == pdTRUE) {
|
||||
g_automotive_data.debug_enabled = enabled ? 1 : 0;
|
||||
xSemaphoreGive(g_data_mutex);
|
||||
ESP_LOGI("UARTMgr", "Debug flag set to %s (will be transmitted to Controller B)",
|
||||
ESP_LOGI("UARTMgr", "Debug flag set to %s (will be transmitted to Inst. Cluster)",
|
||||
enabled ? "ENABLED" : "DISABLED");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ void setDebugEnabled(bool enabled);
|
||||
void linkToCANState(bool can_active);
|
||||
|
||||
/**
|
||||
* @brief Settings-screen switch: start/stop sending to Controller B (UART1 +
|
||||
* @brief Settings-screen switch: start/stop sending to Inst. Cluster (UART1 +
|
||||
* ESP-NOW) and remember the choice in NVS.
|
||||
*/
|
||||
void setEnabled(bool enabled);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* UI State Manager Module
|
||||
*
|
||||
* Holds the debug flag (sent to Controller B, shows LVGL's performance overlay).
|
||||
* Holds the debug flag (sent to Inst. Cluster, shows LVGL's performance overlay).
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* the request functions, so screen lifetimes can never leave dangling pointers
|
||||
* here.
|
||||
*
|
||||
* Radio rules (the ESP-NOW link to Controller B shares the radio):
|
||||
* Radio rules (the ESP-NOW link to Inst. Cluster shares the radio):
|
||||
* - the radio stays in STA mode forever; "off" only stops association/scans.
|
||||
* Never WiFi.disconnect(true) / WiFi.mode(WIFI_OFF) - that kills ESP-NOW.
|
||||
* - scans only when asked (each one hops every channel);
|
||||
@@ -84,7 +84,7 @@ bool handleCommand(const char* line);
|
||||
|
||||
/**
|
||||
* The remembered network, password included - for LinkPeer, which hands it to
|
||||
* Controller B inside an encrypted frame. Never print the password.
|
||||
* Inst. Cluster inside an encrypted frame. Never print the password.
|
||||
* @return false if no network is saved
|
||||
*/
|
||||
bool getSavedCredentials(char* ssid, size_t ssid_n, char* pass, size_t pass_n);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"""Run the Route A OBD-II diag probe sequence on Controller A and log everything.
|
||||
"""Run the Route A OBD-II diag probe sequence on Main CTRL and log everything.
|
||||
|
||||
Opens the port once (one reboot), waits for boot, then sends each diag command
|
||||
with a generous wait, echoing replies and saving the full console stream
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"""Display-performance session: stream PERF lines from Controller A to a log
|
||||
"""Display-performance session: stream PERF lines from Main CTRL to a log
|
||||
while you provoke symptoms on the touchscreen (wiki open question #13).
|
||||
|
||||
Opens the port WITHOUT resetting the board (DTR/RTS low), turns on `perf on 1`,
|
||||
|
||||
@@ -83,7 +83,7 @@ On BMW PT-CAN (Powertrain CAN) networks, data is divided into two categories: **
|
||||
|
||||
1\. Broadcasted Data (Why you see RPM & Temp)
|
||||
|
||||
The DDE (Engine ECU) continuously loops and broadcasts specific telemetry frames that other modules (like the Instrument Cluster, Transmission Control, and Stability Control) *absolutely need* to function.
|
||||
The DDE (Engine ECU) continuously loops and broadcasts specific telemetry frames that other modules (like the Inst. Cluster, Transmission Control, and Stability Control) *absolutely need* to function.
|
||||
|
||||
Bimmerforums.com +1
|
||||
|
||||
|
||||
+4
-3
@@ -12,15 +12,16 @@ Catalog of every page in the wiki. Read this first when answering questions. Kee
|
||||
- [[patrol-instrument-cluster]] — **what the Patrol cluster expects on its inputs**: tach = 2 pulses/rev (verified by calibration), temp = NTC sender 2.1–2.9 kΩ cold → ~250 Ω at 90 °C; the 1 kHz PWM needle-flutter problem and the mitigation ladder (fixed-duty test → 20 kHz → hardware damping)
|
||||
- [[bmw-m57n-engine]] — the 3.0L BMW diesel whose CAN bus we read; E60/E65 donor (confirmed), DDE ECU, auto box with EGS on bus
|
||||
- [[nissan-patrol-swap]] — the target vehicle: Patrol receiving the M57N + BMW auto; the tapped bus is a BMW island in a Nissan
|
||||
- [[esp32-s3-touch-lcd-5b]] — Waveshare 5" display board (Controller A); onboard TJA1051 CAN transceiver, 7–36 V input, pinout, PSRAM/LCD gotchas — **flash writes flicker the RGB panel, full-screen fades stutter, internal RAM nearly full, opening the serial port resets the board unless DTR/RTS are low; Wi-Fi scans caused the flickering dots; all screens hand-coded since 2026-09-27**
|
||||
- [[esp32-s3-touch-lcd-5b]] — Waveshare 5" display board (Main CTRL); onboard TJA1051 CAN transceiver, 7–36 V input, pinout, PSRAM/LCD gotchas — **flash writes flicker the RGB panel, full-screen fades stutter, internal RAM nearly full, opening the serial port resets the board unless DTR/RTS are low; Wi-Fi scans caused the flickering dots; all screens hand-coded since 2026-09-27**
|
||||
|
||||
## Concepts
|
||||
|
||||
- [[can-bus-integration]] — the core challenge; current firmware ID map flagged as placeholder, verification plan
|
||||
- [[driveline-speed-signals]] — **engine / turbine / output-shaft speeds**: turbine speed as physical proof of gear engagement, and the output-shaft field that is our **only road-speed source** (no DSC on this bus) — the feedback variable for a future cruise-control PoC, with the safety envelope that would require
|
||||
- [[dual-controller-architecture]] — Controller A → UART1 + ESP-NOW, protocol v2 → Controller B (1.3" display + Patrol gauge outputs); A owns alerts and the gauge tunables (`cfg` console)
|
||||
- [[dual-controller-architecture]] — Main CTRL → UART1 + ESP-NOW, protocol v2 → Inst. Cluster (1.3" display + Patrol gauge outputs); A owns alerts and the gauge tunables (`cfg` console)
|
||||
- [[obd-diagnostic-polling]] — **why boost / MAF / rail / injection / DTCs never appear on the sniffer** and how a tester gets them: Route A generic OBD-II mode 01 on `0x7DF` and Route B BMW KWP on `0x6F1` → `0x612` — **BOTH VERIFIED WORKING 2026-09-23** (minimal PID set, no boost PID, mode 09 silent; `1A 86` ident identifies the donor; DTCs read via mode 03), the capture-with-Launch procedure (still wanted for the `22 D1xx` live-data identifiers), and why polling is a transmit-on-the-bus design decision
|
||||
- [[ota-updates]] — **Controller A updates itself from Gitea releases**: tag `v*` → CI builds + signs (ECDSA P-256) → Settings → Updates (confirm dialog) or `ota install` (manual, parked, Wi-Fi) pulls over HTTPS from the public repo, verifies, flashes the idle slot, 30 s confirm-or-rollback; **verified end-to-end, from the screen since 2026-09-27 (now v0.1.5)**, release with `git push --follow-tags origin main`; dual-slot partition table; **Controller B card on the Updates page (2026-09-27)**: B pulls its own release, A pairs over the wire (`link pair`), hands over credentials in encrypted frames and triggers - details in B's wiki `controller-b-ota`
|
||||
- [[sleep-when-parked]] — **2026-09-28**: one Settings switch puts both controllers into deep sleep 60 s after the CAN bus goes quiet; Main CTRL wakes on CAN RX (GPIO 16), Inst. Cluster on the UART wire or a 60 s probe boot; bit 7 of `out_enable` carries the switch to B
|
||||
- [[ota-updates]] — **Main CTRL updates itself from Gitea releases**: tag `v*` → CI builds + signs (ECDSA P-256) → Settings → Updates (confirm dialog) or `ota install` (manual, parked, Wi-Fi) pulls over HTTPS from the public repo, verifies, flashes the idle slot, 30 s confirm-or-rollback; **verified end-to-end, from the screen since 2026-09-27 (now v0.1.5)**, release with `git push --follow-tags origin main`; dual-slot partition table; **Inst. Cluster card on the Updates page (2026-09-27)**: B pulls its own release, A pairs over the wire (`link pair`), hands over credentials in encrypted frames and triggers - details in B's wiki `controller-b-ota`
|
||||
|
||||
## Synthesis
|
||||
|
||||
|
||||
+16
-12
@@ -44,15 +44,15 @@ First real dump off the swap's bus, taken with the board's **own new raw-frame l
|
||||
|
||||
## [2026-09-21] update | .docs folder retired; UART spec moved to docs/; board photo ingested
|
||||
|
||||
The repo's `.docs/` folder was deleted (user decision). `CAN_BUS_INTEGRATION.md` documented the dead placeholder IDs and an external transceiver the board does not need — superseded by [[can-id-candidates]] and [[can-bus-integration]]. `UART_PROTOCOL.md` (the packet spec, shared with Controller B) moved to `docs/UART_PROTOCOL.md` as the single copy; Controller B's duplicate was removed. The annotated board photo moved to `raw/` → [[esp32-s3-touch-lcd-5-intro-photo]]: confirms the terminal-block order, that GPIO 44 exits only as the RS485 A/B pair, and that one 120 Ω switch serves both CAN and RS485. Root `CLAUDE.md` corrected: verified CAN ID list replaces the placeholders, `TWAI_MODE_NORMAL` replaces "LISTEN_ONLY", UART TX is GPIO 44 (was written as 43), dummy-data references removed.
|
||||
The repo's `.docs/` folder was deleted (user decision). `CAN_BUS_INTEGRATION.md` documented the dead placeholder IDs and an external transceiver the board does not need — superseded by [[can-id-candidates]] and [[can-bus-integration]]. `UART_PROTOCOL.md` (the packet spec, shared with Inst. Cluster) moved to `docs/UART_PROTOCOL.md` as the single copy; Inst. Cluster's duplicate was removed. The annotated board photo moved to `raw/` → [[esp32-s3-touch-lcd-5-intro-photo]]: confirms the terminal-block order, that GPIO 44 exits only as the RS485 A/B pair, and that one 120 Ω switch serves both CAN and RS485. Root `CLAUDE.md` corrected: verified CAN ID list replaces the placeholders, `TWAI_MODE_NORMAL` replaces "LISTEN_ONLY", UART TX is GPIO 44 (was written as 43), dummy-data references removed.
|
||||
|
||||
**Missing source**: the schematic PDF (`ESP32-S3-Touch-LCD-5-Sch.pdf`) was in `.docs/` at the start of the 2026-09-21 session and was not on disk by the time of this cleanup (never git-tracked). Its net list was read earlier that session and is reflected in [[esp32-s3-touch-lcd-5b]]; re-download it into `raw/` — still on the sourcing wishlist in [[open-questions]].
|
||||
|
||||
Sibling wiki instantiated today at `../../ESP32-S3-LCD-1.3/wiki/` for Controller B (link, redundancy, gauge outputs). Cross-references from there use the text form `(sibling: 5B wiki → page)`.
|
||||
Sibling wiki instantiated today at `../../ESP32-S3-LCD-1.3/wiki/` for Inst. Cluster (link, redundancy, gauge outputs). Cross-references from there use the text form `(sibling: 5B wiki → page)`.
|
||||
|
||||
## [2026-09-21] update | Link protocol v2: ESP-NOW second transport, gear/rpm/alerts on the wire, tunables console
|
||||
|
||||
Firmware (not yet committed): shared header v2 with typed DATA/CONFIG frames; `Tunables` module (gauge calibration + alert thresholds in NVS, `cfg show|set|override|reset` on the USB console); `EspNowLink` broadcasts every frame alongside UART1 (radio now stays in STA mode — WiFiManager's off no longer calls `WIFI_OFF`); CAN driver publishes lever + target/engaged gear nibbles and rpm, and evaluates coolant/gearbox/battery/cooling-demand alerts against the tunables. Bench-verified with Controller B: both transports alive, every frame deduplicated, `cfg override rpm 2000` drove B's tach output at 133.3 Hz. `docs/UART_PROTOCOL.md` rewritten for v2. [[dual-controller-architecture]] and index updated. Build note: IDF 5.5's ESP-NOW send callback takes `wifi_tx_info_t*`; and the two repos must not be built concurrently (shared penv).
|
||||
Firmware (not yet committed): shared header v2 with typed DATA/CONFIG frames; `Tunables` module (gauge calibration + alert thresholds in NVS, `cfg show|set|override|reset` on the USB console); `EspNowLink` broadcasts every frame alongside UART1 (radio now stays in STA mode — WiFiManager's off no longer calls `WIFI_OFF`); CAN driver publishes lever + target/engaged gear nibbles and rpm, and evaluates coolant/gearbox/battery/cooling-demand alerts against the tunables. Bench-verified with Inst. Cluster: both transports alive, every frame deduplicated, `cfg override rpm 2000` drove B's tach output at 133.3 Hz. `docs/UART_PROTOCOL.md` rewritten for v2. [[dual-controller-architecture]] and index updated. Build note: IDF 5.5's ESP-NOW send callback takes `wifi_tx_info_t*`; and the two repos must not be built concurrently (shared penv).
|
||||
|
||||
## [2026-09-21] update | Gauge Tuning screen
|
||||
|
||||
@@ -70,7 +70,7 @@ User clipped a Google AI Mode conversation into `Clippings/` (Obsidian Web Clipp
|
||||
|
||||
User dropped `raw/BMW 335d.csv` and clipped page 1 of the e90post/6post thread "Extended BMW 335d PIDs for Torque" (DWR, 2009 335d = M57N2 on DDE7.3/EDC17CP09) → [[dwr-335d-torque-pids]]. **Every entry is a generic SAE J1979 mode-01 PID** (DWR says so in post 21; header `Auto` = `0x7DF`); nothing BMW-proprietary, nothing broadcast. Two revisions compared: the CSV in `raw/` is the corrected 2017 one (boost ×0.3125 = the J1979 0.03125 kPa/bit; fuel rate ×0.0938 lb/hr; post-#2's ×0.296 and ×5.64 were wrong); residual typos noted (`000031` for 0.0000305, one `+33`). Decoded his table back to SI with the J1979 byte positions. Consequence for us: the generic route is the **cheapest polling experiment** — one `01 00` supported-PID query on `0x7DF` tells whether our DDE answers EOBD on the PT-CAN and which PIDs it has — but the diesel-specific PIDs he relies on for boost (`70`), exhaust pressure (`73`), EGT (`78`), DPF (`7A`), NOx (`83`) are 2007+ J1979 additions an EDC16 almost certainly lacks `(unverified)`, and PID `0B` clips at 255 kPa. [[obd-diagnostic-polling]] restructured into Route A (generic, PID table, first test) and Route B (BMW `0x6F1`/`0x612`). Wishlist: DWR's Testo parameter list (post 175 of the Testo thread). Updated [[open-questions]] #7 + wishlist, index.
|
||||
|
||||
## [2026-09-21] update | `diag` console probe: Controller A can now send OBD-II requests
|
||||
## [2026-09-21] update | `diag` console probe: Main CTRL can now send OBD-II requests
|
||||
|
||||
User decision: build the Route A probe. New module `src/modules/diag_probe.cpp` and a single sanctioned transmit function `CANDriver::transmit()` (single-shot frames, `CANTX,` console echo mirroring `CANRAW,`). Console: `diag pids` (mode-01 supported-PID bitmap scan, blocks 00/20/40…, per-responder summary with PID names), `diag pid <hex>` (one request, decoded for the Route A table incl. PID 70 boost and 78 EGT), `diag vin`, `diag ecu` (mode 09), `diag status`. ISO-TP single/first/consecutive frames reassembled with a `30 00 00` flow control to the responder's physical ID. Guards: one request in flight, refused for 3 s after any foreign tester frame (`0x7DF`/`0x7E0–7`/`0x6F1`), services 01 and 09 only. Console dispatch chained through `Tunables::setExtraCommandHandler()`. Built (1.49 MB) and flashed to COM11; bench check with no bus attached: `diag pids` sent `02 01 00` on `0x7DF`, the TWAI controller reported the single-shot frame un-ACKed, and the probe reported "not ACKed - no other node saw it" rather than blaming the ECU (the summary distinguishes un-ACKed from ACKed-but-silent). CAN-task warnings now take the serial lock so they no longer splice into `CANTX` lines. The wiki's "firmware never transmits" statements are now qualified on [[can-bus-integration]] and [[obd-diagnostic-polling]] (test-day procedure and the three possible outcomes written there). Root `CLAUDE.md` and `docs/UART_PROTOCOL.md` console section updated. Procedure rewritten as numbered steps with all four outcomes (un-ACKed / ACKed-silent / one responder / two responders) and the log-capture command.
|
||||
|
||||
@@ -80,7 +80,7 @@ First in-car test of the dual-controller rig: A reads the bus fine, B receives f
|
||||
|
||||
## [2026-09-22] query | Patrol cluster signal research - tach 2 ppr verified, temp sender curve, flutter plan
|
||||
|
||||
First day driving the real cluster from Controller B through the 2SK3069 low-side stage. Tach: needle tracked at double with ppr=4; user set ppr=2 -> tracks correctly (verified). 2 ppr matches an ECU-driven 4-cyl-style tach input (ZD30-era Y61 hint, unverified) rather than the TD42 alternator-W-terminal scheme. Temp gauge on IO8: needle flutters at temp_pwm_hz=1 kHz. Researched: stock Patrol sender is an NTC (2.1-2.9k @ 20C, 0.68-1k @ 50C, 236-260R @ 90C; patrol4x4/sensorgal), gauge is current-measuring; community PWM-gauge experience says flutter dies at ~40-50 kHz. Mitigation ladder filed: fixed-duty override test (data vs electrical), cfg set temp_hz 20000 (firmware clamp), then raise clamp / series drain resistor (~100-240R, also bounds full-on beyond-hot short) / gauge-side cap. Temp law must be re-derived after (FET inverts duty sense). Filed [[patrol-instrument-cluster]]; index updated. Earlier same day: [[canny-5-3-pico-gauge-drive]] hypothesis effectively confirmed by the needles moving through the FET; gauge-output disable bits found off during bench test (B console "disabled") - re-enabled via tuning screen.
|
||||
First day driving the real cluster from Inst. Cluster through the 2SK3069 low-side stage. Tach: needle tracked at double with ppr=4; user set ppr=2 -> tracks correctly (verified). 2 ppr matches an ECU-driven 4-cyl-style tach input (ZD30-era Y61 hint, unverified) rather than the TD42 alternator-W-terminal scheme. Temp gauge on IO8: needle flutters at temp_pwm_hz=1 kHz. Researched: stock Patrol sender is an NTC (2.1-2.9k @ 20C, 0.68-1k @ 50C, 236-260R @ 90C; patrol4x4/sensorgal), gauge is current-measuring; community PWM-gauge experience says flutter dies at ~40-50 kHz. Mitigation ladder filed: fixed-duty override test (data vs electrical), cfg set temp_hz 20000 (firmware clamp), then raise clamp / series drain resistor (~100-240R, also bounds full-on beyond-hot short) / gauge-side cap. Temp law must be re-derived after (FET inverts duty sense). Filed [[patrol-instrument-cluster]]; index updated. Earlier same day: [[canny-5-3-pico-gauge-drive]] hypothesis effectively confirmed by the needles moving through the FET; gauge-output disable bits found off during bench test (B console "disabled") - re-enabled via tuning screen.
|
||||
|
||||
## [2026-09-22] update | Temp gauge flutter resolved: temp_hz 1 kHz -> 20 kHz
|
||||
|
||||
@@ -110,9 +110,9 @@ The capture-with-Launch session, finally run (engine idling, our read-only seria
|
||||
|
||||
Tightened the live-data findings after checking the full capture: the Launch used only 1A/2C/22/23 - NO 10 (session), 27 (security), or 3E (tester-present). So self-polling a 2C value (e.g. rail pressure) needs only the 2C 10 15E0 define + 2C 10 00DF poll, no secret; the earlier 21-block NRCs (0x22/0x33) are a different mechanism and do not gate 2C. Corrected the "needs session/define handshake" wording in launch-capture-2026-09-23.md and obd-diagnostic-polling. Recorded the design decision (user, 2026-09-23): active polling, if built, lives behind a password-protected Diagnostics screen (authorized-tech gate, manual, refuses while scan tool connected, read-oriented services) - open-questions #12, and a project memory so the capability is not re-researched later.
|
||||
|
||||
## [2026-09-26] build | OTA updates for Controller A
|
||||
## [2026-09-26] build | OTA updates for Main CTRL
|
||||
|
||||
Repartitioned A to dual OTA slots (2 x 7.9 MB, SPIFFS dropped, nvs/otadata offsets kept - tunables v150 survived the one-time USB flash on COM10, verified). New src/modules/ota_update.cpp + include/config/ota_config.h: manual `ota status|check|install|rollback` console; HTTPS pull from the (now public) Gitea repo's latest release, ECDSA P-256 signature over "patrol-a|version|sha256" checked before download, image hashed while streaming, parked gate before download and before slot switch, rollback via verifyRollbackLater() override + 30 s confirm. TLS trusts ISRG Root X1 + Root YR (both verified against the server chain). CI: .gitea/workflows/firmware.yml (main -> rolling unsigned pre-release main-latest; v* tag -> signed release with manifest.txt). Decisions: manual trigger (future Diagnostics screen), public repos instead of a device token, Controller B to be updated by A over ESP-NOW (wire is one-way). Wrote pages/ota-updates.md. Pending: BMW_NISSAN_FIRMWARE_SIGNING_KEY repo secret, enable repo Actions, first v* tag to test end-to-end.
|
||||
Repartitioned A to dual OTA slots (2 x 7.9 MB, SPIFFS dropped, nvs/otadata offsets kept - tunables v150 survived the one-time USB flash on COM10, verified). New src/modules/ota_update.cpp + include/config/ota_config.h: manual `ota status|check|install|rollback` console; HTTPS pull from the (now public) Gitea repo's latest release, ECDSA P-256 signature over "patrol-a|version|sha256" checked before download, image hashed while streaming, parked gate before download and before slot switch, rollback via verifyRollbackLater() override + 30 s confirm. TLS trusts ISRG Root X1 + Root YR (both verified against the server chain). CI: .gitea/workflows/firmware.yml (main -> rolling unsigned pre-release main-latest; v* tag -> signed release with manifest.txt). Decisions: manual trigger (future Diagnostics screen), public repos instead of a device token, Inst. Cluster to be updated by A over ESP-NOW (wire is one-way). Wrote pages/ota-updates.md. Pending: BMW_NISSAN_FIRMWARE_SIGNING_KEY repo secret, enable repo Actions, first v* tag to test end-to-end.
|
||||
|
||||
## [2026-09-26] build | OTA bring-up: Wi-Fi switch, ESP-NOW, memory
|
||||
|
||||
@@ -148,7 +148,7 @@ User asked to refactor the Settings and Gauge Tuning UX, save the Wi-Fi connecti
|
||||
|
||||
## [2026-09-26] ingest | Schematic re-downloaded; VOUT = H8 solder jumper (3V3 default / 5V)
|
||||
|
||||
User asked whether VOUT becomes 5 V by "unsoldering the resistor". Re-fetched `ESP32-S3-Touch-LCD-5-Sch.pdf` into `raw/` (closes the wishlist item) → [[esp32-s3-touch-lcd-5-schematic]]. Answer: VOUT is net `I2C_VCC`, picked by **`H8`, a 3-pad solder jumper** (1 = 3V3, 2 = VOUT, 3 = 5V; "the default paste is 3V3"): open the 1–2 bridge, bridge 2–3, never all three. The terminal-block I2C lines are level-shifted (NDC7002N, 4.7 k pull-ups to `I2C_VCC`) so they follow the choice. 5 V rail is a SY8293 buck rated 2 A ("run the line at 2A"), screen ≈550 mA, so ≈1 A spare for a load such as Controller B `(unverified estimate)`; not on USB power. Also indexed: SD SPI pins (IO11/12/13, CS EXIO4), CAN IO15/16 and RS485 IO43/44 confirmed. Updated [[esp32-s3-touch-lcd-5b]], [[open-questions]] wishlist, index.
|
||||
User asked whether VOUT becomes 5 V by "unsoldering the resistor". Re-fetched `ESP32-S3-Touch-LCD-5-Sch.pdf` into `raw/` (closes the wishlist item) → [[esp32-s3-touch-lcd-5-schematic]]. Answer: VOUT is net `I2C_VCC`, picked by **`H8`, a 3-pad solder jumper** (1 = 3V3, 2 = VOUT, 3 = 5V; "the default paste is 3V3"): open the 1–2 bridge, bridge 2–3, never all three. The terminal-block I2C lines are level-shifted (NDC7002N, 4.7 k pull-ups to `I2C_VCC`) so they follow the choice. 5 V rail is a SY8293 buck rated 2 A ("run the line at 2A"), screen ≈550 mA, so ≈1 A spare for a load such as Inst. Cluster `(unverified estimate)`; not on USB power. Also indexed: SD SPI pins (IO11/12/13, CS EXIO4), CAN IO15/16 and RS485 IO43/44 confirmed. Updated [[esp32-s3-touch-lcd-5b]], [[open-questions]] wishlist, index.
|
||||
|
||||
## [2026-09-27] query | Open question 13 reviewed with the user: full fix committed, dots not gone
|
||||
|
||||
@@ -195,13 +195,13 @@ Tag build died at the link step: `ModuleNotFoundError: No module named 'SCons.To
|
||||
Second tag build (pioarduino core fork in the workflow) succeeded: release `v0.1.7` on Gitea at 18:28 with `firmware.bin` (1,722,464 B), `firmware.elf`, `manifest.txt` (target patrol-a, sha256 `a2949644…4c09`, ECDSA sig), built from `8e739fa`. Off-device check: downloaded binary's SHA-256 and size match the manifest. The bench board (dev build on COM14) could not `ota check` — Wi-Fi off and no saved network at that moment — so the first on-device install of v0.1.7 is the user's, from Settings → Updates. Expected on the board: "Version v0.1.7 is available", install with the screen lit and the progress bar, restart, `A v0.1.7` bottom-right; the Updates page then says up to date.
|
||||
|
||||
|
||||
## [2026-09-27] update | Controller B updates from A's screen: link_peer, two-way maintenance frames, Updates page with two cards
|
||||
## [2026-09-27] update | Inst. Cluster updates from A's screen: link_peer, two-way maintenance frames, Updates page with two cards
|
||||
|
||||
Implemented A's half of B's OTA (design in B's wiki `controller-b-ota`). Shared `automotive_data.h` (+ new `link_secure.h`, both byte-identical in the two repos): `STATUS` 0x03 B → A, `PAIR` 0x04 A → B wire-only, `SECURE` 0x05 A → B (AES-256-GCM under the pairing key; inner `OTA_CMD` / `WIFI_CREDS`), `PACKET_MAX_PAYLOAD` 64 → 160, `PACKET_VERSION` unchanged (DATA/CONFIG bytes identical). New `src/modules/link_peer.cpp`: pairing key in NVS `linkpeer`, `link pair` sends the key ×3 over UART1 only (`UARTManager::sendWire()`), B's STATUS kept + logged, automatic push of the remembered Wi-Fi network to B (hash-compared, ≥ 15 s apart, FORGET when A forgets), `requestCheck/requestInstall` for the screen behind `Ota::isParked()` + A on Wi-Fi. `EspNowLink` gained a receive callback (IDF 5.5 `esp_now_recv_info_t`) and `sendTo()`; `WiFiManager::getSavedCredentials()` (for LinkPeer only, never printed). Settings → Updates rebuilt as two cards (Controller A / Controller B) that fit the 484 px page without scrolling. Bench: B heard within seconds (`link status`: MAC, `dev`, heap 234 KB), refusals correct; `link pair` cannot be confirmed because **no wire is connected on the bench** (B reports `uart silent`). Build notes: `pio` from PowerShell only (idf_tools refuses MSYS); first build after the B project reinstalls Arduino 3.3.3 and may fail once with a `TypeError` - rerun.
|
||||
Implemented A's half of B's OTA (design in B's wiki `controller-b-ota`). Shared `automotive_data.h` (+ new `link_secure.h`, both byte-identical in the two repos): `STATUS` 0x03 B → A, `PAIR` 0x04 A → B wire-only, `SECURE` 0x05 A → B (AES-256-GCM under the pairing key; inner `OTA_CMD` / `WIFI_CREDS`), `PACKET_MAX_PAYLOAD` 64 → 160, `PACKET_VERSION` unchanged (DATA/CONFIG bytes identical). New `src/modules/link_peer.cpp`: pairing key in NVS `linkpeer`, `link pair` sends the key ×3 over UART1 only (`UARTManager::sendWire()`), B's STATUS kept + logged, automatic push of the remembered Wi-Fi network to B (hash-compared, ≥ 15 s apart, FORGET when A forgets), `requestCheck/requestInstall` for the screen behind `Ota::isParked()` + A on Wi-Fi. `EspNowLink` gained a receive callback (IDF 5.5 `esp_now_recv_info_t`) and `sendTo()`; `WiFiManager::getSavedCredentials()` (for LinkPeer only, never printed). Settings → Updates rebuilt as two cards (Main CTRL / Inst. Cluster) that fit the 484 px page without scrolling. Bench: B heard within seconds (`link status`: MAC, `dev`, heap 234 KB), refusals correct; `link pair` cannot be confirmed because **no wire is connected on the bench** (B reports `uart silent`). Build notes: `pio` from PowerShell only (idf_tools refuses MSYS); first build after the B project reinstalls Arduino 3.3.3 and may fail once with a `TypeError` - rerun.
|
||||
|
||||
## [2026-09-27] verify | Controller B updated from A's console, end to end (details in B's wiki log)
|
||||
## [2026-09-27] verify | Inst. Cluster updated from A's console, end to end (details in B's wiki log)
|
||||
|
||||
With the wire connected: pairing, credential push, check and install of B's first signed release `v0.1.0` all worked from A's `link` console; B rebooted and confirmed. A's side needed one cosmetic fix (missing separator in the "Controller B update: failed - <reason>" log line), rebuilt and flashed COM14. Left for the user: tap Check / Install on the Controller B card of Settings → Updates on the next B release and watch B's progress line.
|
||||
With the wire connected: pairing, credential push, check and install of B's first signed release `v0.1.0` all worked from A's `link` console; B rebooted and confirmed. A's side needed one cosmetic fix (missing separator in the "Inst. Cluster update: failed - <reason>" log line), rebuilt and flashed COM14. Left for the user: tap Check / Install on the Inst. Cluster card of Settings → Updates on the next B release and watch B's progress line.
|
||||
|
||||
## [2026-09-27] update | Wi-Fi chip and blinking alert banner on every screen; Driveline reds
|
||||
|
||||
@@ -210,3 +210,7 @@ User: show Wi-Fi on every screen (top-right) and give a sense of urgency when a
|
||||
## [2026-09-28] update | No invented data: A starts with nothing valid and forgets everything when the bus stops
|
||||
|
||||
User: "if there is no info from CAN bus, no values should be shown". Until now `UARTManager::initializeDefaultData()` seeded 89.0 / 85.0 degC and 12.45 V with their valid flags SET, so a bench B (and a car with CAN off) showed plausible fake readings. Now the shared structure starts zeroed with `valid_flags = 0` and lever UNKNOWN; every field is valid only after a CAN frame filled it. `can_driver.cpp` gained `clearSharedData()`, called on CAN stop and on the bus-silence timeout (which already stopped the link) so stale values never come back marked valid. The `DEFAULT_*` block left the shared header (copied to B, `cmp`-identical). Driveline and B already key everything off the valid flags, so they show `--` / hidden needles. Flashed COM14; B's RX log now shows `Valid:0x00`. Released as v0.1.9 (v0.1.8, tagged minutes earlier, still carries the defaults - do not install it).
|
||||
|
||||
## [2026-09-28] update | Boards renamed Main CTRL / Inst. Cluster; "Sleep when the car is off" switch
|
||||
|
||||
User renamed Controller A → **Main CTRL** and Controller B → **Inst. Cluster** across both repos (comments, UI text, workflow names, wiki) and reworded the Updates page; committed here together with the sleep feature. New `power_manager.cpp` + Settings → System switch (NVS `sleep_en`, default OFF), see [[sleep-when-parked]]: deep sleep after 60 s of quiet CAN bus + idle touch + no update job, wake on CAN RX GPIO 16 (ext0, pull-up, TWAI stopped first). The switch travels to the Inst. Cluster as bit 7 of `out_enable` in CONFIG (no version bump). Console `sleep status | on | off | now`. Bench lesson the same evening: the switch was turned on with CAN on and no bus, so the Main CTRL slept a minute later and its USB-CDC port vanished (a deep-sleeping S3 has no USB) - only the reset button or a power cycle brings it back; touching the screen within the minute keeps it awake. Inst. Cluster side verified (see its log): sleep at 60 s of link silence, timer wake after exactly 60 s, 4 s probe with the panel dark, sleep again.
|
||||
|
||||
@@ -6,7 +6,7 @@ updated: 2026-09-22
|
||||
|
||||
# CANNY 5.3 pico vs ESP32-S3: driving the Patrol cluster
|
||||
|
||||
Why the user's old CANNY-based setup moves the Patrol tach and our ESP32 (Controller B, IO7) does not. Researched 2026-09-22 after the first in-car test of the dual-controller rig: temp needle parked mid-scale, tach dead ([[dual-controller-architecture]]).
|
||||
Why the user's old CANNY-based setup moves the Patrol tach and our ESP32 (Inst. Cluster, IO7) does not. Researched 2026-09-22 after the first in-car test of the dual-controller rig: temp needle parked mid-scale, tach dead ([[dual-controller-architecture]]).
|
||||
|
||||
## The working reference setup `(verified)`
|
||||
|
||||
@@ -48,7 +48,7 @@ ESP32 IOx ──[R ~1k]── G/B N-MOSFET (logic-level, e.g. 2N7002/AO3400) o
|
||||
- If the cluster input turns out to have no internal pull-up, add an external ~4.7–10 kΩ to +12 V.
|
||||
- On hand (2026-09-22): a **2SK3069** (N-ch, 60 V / 75 A, 4 V-drive class) — hugely oversized but suitable; planned for the tach channel with 220 Ω gate series + 10 kΩ gate pulldown `(source: alltransistors.com 2SK3069)`.
|
||||
- **Never** connect the 12 V-pulled gauge line directly to an ESP32 pin, including in open-drain mode — the pin is not 12 V tolerant.
|
||||
- Grounds must be common: cluster GND ↔ Controller B GND.
|
||||
- Grounds must be common: cluster GND ↔ Inst. Cluster GND.
|
||||
|
||||
## Open items
|
||||
|
||||
|
||||
@@ -9,27 +9,27 @@ updated: 2026-09-27
|
||||
The system is two ESP32-S3 boards linked by UART **and ESP-NOW** (repo, protocol v2 since 2026-09-21):
|
||||
|
||||
```
|
||||
BMW M57N CAN bus ──▶ Controller A ──UART1 + ESP-NOW, 5 Hz──▶ Controller B ──▶ Patrol tach + temp gauge
|
||||
BMW M57N CAN bus ──▶ Main CTRL ──UART1 + ESP-NOW, 5 Hz──▶ Inst. Cluster ──▶ Patrol tach + temp gauge
|
||||
(this repo: (ESP32-S3-LCD-1.3,
|
||||
5" 1024×600 display) 1.3" round display, gauge outputs)
|
||||
```
|
||||
|
||||
- **Controller A** — [[esp32-s3-touch-lcd-5b]]: listens to the CAN bus, renders the main UI, and re-broadcasts a compact sensor packet over UART1 (GPIO 43/44, 115200 baud) at 5 Hz.
|
||||
- **Controller B** — ESP32-S3-Touch-LCD-1.3: a secondary display fed purely by that UART stream. Lives in a sibling repo (`bmw-patrol/` parent directory).
|
||||
- **Main CTRL** — [[esp32-s3-touch-lcd-5b]]: listens to the CAN bus, renders the main UI, and re-broadcasts a compact sensor packet over UART1 (GPIO 43/44, 115200 baud) at 5 Hz.
|
||||
- **Inst. Cluster** — ESP32-S3-Touch-LCD-1.3: a secondary display fed purely by that UART stream. Lives in a sibling repo (`bmw-patrol/` parent directory).
|
||||
|
||||
## Link protocol v2 (repo, 2026-09-21)
|
||||
|
||||
`0xAA | 0x02 | type | length | payload | XOR | 0x55`, identical on UART1 (GPIO 44 → SP3485 → `485_A`/`485_B`) and ESP-NOW broadcast (channel 1). DATA frames (lever, target/engaged gear nibbles, rpm, temps, battery, alert bitmap, valid flags) every 200 ms; CONFIG frames (`link_config_t`: Patrol gauge calibration + alert thresholds, edited on A via the `cfg` serial console and stored in NVS) on change and every 5 s. Alerts are decided here; B only renders them. Spec: `docs/UART_PROTOCOL.md`. Bench-verified with both transports live and B deduplicating every frame `(verified 2026-09-21)`.
|
||||
|
||||
**ESP-NOW and Wi-Fi share the radio** `(verified 2026-09-26)`. When A joins a Wi-Fi network (for OTA), its channel follows the AP (seen: 6, 9, 11) and B hops to find it; ESP-NOW kept running (6,410 frames, 0 failed). Until 2026-09-26 the Wi-Fi code powered the radio off on connect/disconnect (`WiFi.disconnect(true)`), which silently killed ESP-NOW and left B on the wire only — fixed, and `EspNowLink::send()` now re-initialises ESP-NOW if the driver drops it. Planned: **Controller B's firmware updates will travel from A over ESP-NOW** (bidirectional, unlike the one-way wire) → [[ota-updates]].
|
||||
**ESP-NOW and Wi-Fi share the radio** `(verified 2026-09-26)`. When A joins a Wi-Fi network (for OTA), its channel follows the AP (seen: 6, 9, 11) and B hops to find it; ESP-NOW kept running (6,410 frames, 0 failed). Until 2026-09-26 the Wi-Fi code powered the radio off on connect/disconnect (`WiFi.disconnect(true)`), which silently killed ESP-NOW and left B on the wire only — fixed, and `EspNowLink::send()` now re-initialises ESP-NOW if the driver drops it. Planned: **Inst. Cluster's firmware updates will travel from A over ESP-NOW** (bidirectional, unlike the one-way wire) → [[ota-updates]].
|
||||
|
||||
**A keeps the ESP-NOW channel stable (v0.1.5, 2026-09-27)** `(repo)`: Wi-Fi auto-reconnect is off. A tries the remembered network once at boot and once after a drop, then parks the radio back on channel 1 — an endless reconnect (e.g. driving away from home Wi-Fi) would keep hopping channels under the link to B. Scans happen only when someone opens the Wi-Fi page or taps Scan.
|
||||
|
||||
Controller B's side of this (receiver, ESP-NOW channel hopping, gauge outputs, bench wiring) is documented in the sibling wiki: `../../ESP32-S3-LCD-1.3/wiki/pages/controller-link.md` and `patrol-gauge-outputs.md`.
|
||||
Inst. Cluster's side of this (receiver, ESP-NOW channel hopping, gauge outputs, bench wiring) is documented in the sibling wiki: `../../ESP32-S3-LCD-1.3/wiki/pages/controller-link.md` and `patrol-gauge-outputs.md`.
|
||||
|
||||
## Why it matters for the wiki
|
||||
|
||||
Any change to what data we extract from the [[can-bus-integration]] ripples into this packet **and** into Controller B's parser — both ends must move together: edit `include/protocol/automotive_data.h` here, bump `PACKET_VERSION`, copy the header byte-identical to B (B rejects other versions).
|
||||
Any change to what data we extract from the [[can-bus-integration]] ripples into this packet **and** into Inst. Cluster's parser — both ends must move together: edit `include/protocol/automotive_data.h` here, bump `PACKET_VERSION`, copy the header byte-identical to B (B rejects other versions).
|
||||
|
||||
## Related
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ updated: 2026-09-27
|
||||
|
||||
# Waveshare ESP32-S3-Touch-LCD-5B
|
||||
|
||||
Controller A of the [[dual-controller-architecture]] — the main in-cabin display. SKU 28151, the 1024×600 capacitive-touch variant of the LCD-5 family. Primary reference: [[esp32-s3-touch-lcd-5b-waveshare-wiki]].
|
||||
Main CTRL of the [[dual-controller-architecture]] — the main in-cabin display. SKU 28151, the 1024×600 capacitive-touch variant of the LCD-5 family. Primary reference: [[esp32-s3-touch-lcd-5b-waveshare-wiki]].
|
||||
|
||||
## Specs (source: waveshare-wiki)
|
||||
|
||||
@@ -22,7 +22,7 @@ Controller A of the [[dual-controller-architecture]] — the main in-cabin displ
|
||||
- Draw: ~450 mA @ 5 V (~2.3 W)
|
||||
- Remaining caveat: automotive transient/load-dump spikes (ISO 7637) can exceed 36 V `(unverified)` → [[open-questions]]
|
||||
- **Power path** (source: [[esp32-s3-touch-lcd-5-schematic]]): VIN → 1N5822 reverse diode + SMAJ36CA TVS → SY8293 buck (2 A, "run the line at 2A") → 5 V rail → 3.3 V LDO. Screen alone ≈550 mA @ 5 V.
|
||||
- **VOUT terminal = `I2C_VCC`, selected by solder jumper `H8`** (pad 1 = 3V3, pad 2 = VOUT, pad 3 = 5V; factory bridge 1–2 = 3.3 V). For 5 V: open 1–2, bridge 2–3, never all three. The external SDA/SCL are level-shifted (NDC7002N + 4.7 kΩ pull-ups to `I2C_VCC`), so the I2C lines follow. Headroom for a load on VOUT@5 V from the 12 V input ≈1 A `(unverified estimate)` — enough to power Controller B. Not on USB-only power.
|
||||
- **VOUT terminal = `I2C_VCC`, selected by solder jumper `H8`** (pad 1 = 3V3, pad 2 = VOUT, pad 3 = 5V; factory bridge 1–2 = 3.3 V). For 5 V: open 1–2, bridge 2–3, never all three. The external SDA/SCL are level-shifted (NDC7002N + 4.7 kΩ pull-ups to `I2C_VCC`), so the I2C lines follow. Headroom for a load on VOUT@5 V from the 12 V input ≈1 A `(unverified estimate)` — enough to power Inst. Cluster. Not on USB-only power.
|
||||
|
||||
> [!warning] Operating temperature 0–65 °C (source: waveshare-wiki)
|
||||
> Tight for a car: sub-zero winters and sun-baked dashboards both fall outside spec. → [[open-questions]]
|
||||
@@ -39,7 +39,7 @@ Controller A of the [[dual-controller-architecture]] — the main in-cabin displ
|
||||
|
||||
| Interface | Details |
|
||||
|-----------|---------|
|
||||
| RS485 | SP3485, auto TX/RX direction; terminal block used for UART1 → Controller B, GPIO 43/44, 115200 baud `(repo)` |
|
||||
| RS485 | SP3485, auto TX/RX direction; terminal block used for UART1 → Inst. Cluster, GPIO 43/44, 115200 baud `(repo)` |
|
||||
| Isolated I/O | Optocoupler digital in 5–36 V (dry/wet contact), open-drain out sinking 450 mA/ch — could read ignition-on or drive a relay later |
|
||||
| I2C | Terminal block SDA/SCL, level-shifted to `I2C_VCC` (= VOUT, 3.3 V or 5 V via `H8`); CH422G expander occupies 0x20–0x27 & 0x30–0x3F, GT911 touch at 0x5D — avoid these addresses |
|
||||
| RTC | PCF85063 + CR927 coin cell |
|
||||
|
||||
@@ -6,7 +6,7 @@ updated: 2026-09-23
|
||||
|
||||
# OBD / Diagnostic Polling
|
||||
|
||||
Why some values never appear on the sniffer, how a scan tool gets them, and what it would take for Controller A to do the same. Several pages have linked here since July ([[can-id-candidates]], [[open-questions]] #7); the page was created on the [[google-ai-dde7m57-pids]] ingest, 2026-09-21.
|
||||
Why some values never appear on the sniffer, how a scan tool gets them, and what it would take for Main CTRL to do the same. Several pages have linked here since July ([[can-id-candidates]], [[open-questions]] #7); the page was created on the [[google-ai-dde7m57-pids]] ingest, 2026-09-21.
|
||||
|
||||
## Broadcast vs polled
|
||||
|
||||
@@ -59,7 +59,7 @@ The [[dwr-335d-torque-pids]] source is a worked, gauge-checked set of J1979 mode
|
||||
| `02 01 73` / `78` / `7A` / `83` | — | exhaust pressure / EGT / DPF ΔP / NOx — same caveat; DPF/SCR rows are meaningless on an M57N anyway |
|
||||
|
||||
- **First test = the `01 00` bitmap query.** One frame on `0x7DF` with the engine running (no scan tool attached) answers both open points at once: does this DDE speak EOBD on the PT-CAN at all, and which PIDs does it offer. No reply → the DDE serves EOBD on K-line (or not on this bus) and only Route B remains.
|
||||
- **Implemented on Controller A (2026-09-21) `(repo)`** as the `diag` console command — see *Firmware: the `diag` probe* below. The whole test is `diag pids` typed on the USB console.
|
||||
- **Implemented on Main CTRL (2026-09-21) `(repo)`** as the `diag` console command — see *Firmware: the `diag` probe* below. The whole test is `diag pids` typed on the USB console.
|
||||
- Route A cannot give fault codes beyond generic mode `03` DTCs (P0xxx) — BMW-specific codes need Route B.
|
||||
|
||||
## Route B — BMW proprietary (KWP2000 on `0x6F1` → `0x612`) — **VERIFIED WORKING (2026-09-23)**
|
||||
@@ -89,7 +89,7 @@ This depends on the DDE variant, which is still open ([[open-questions]] #2, [[b
|
||||
|
||||
## Firmware: the `diag` probe `(repo, 2026-09-21)`
|
||||
|
||||
Controller A now has **one** transmit path onto the PT-CAN: `CANDriver::transmit()`, called only by `src/modules/diag_probe.cpp`. It sends nothing on its own; every frame is typed by a human on the USB console.
|
||||
Main CTRL now has **one** transmit path onto the PT-CAN: `CANDriver::transmit()`, called only by `src/modules/diag_probe.cpp`. It sends nothing on its own; every frame is typed by a human on the USB console.
|
||||
|
||||
| Command | What it sends | What it prints |
|
||||
|---|---|---|
|
||||
@@ -128,7 +128,7 @@ Run via `tools/diag_session.py` (one serial session, logs straight into `wiki/ra
|
||||
- **The decode recipe (proven 2026-09-23):** log `CANRAW` while the Launch shows a live value → find the `2C 10 <id>` / `6C 10 <data>` pair whose data tracks the reading → calibrate scale against the display at two operating points (idle + a blip). One session per parameter. Boost, MAF, injection quantity, EGTs all reachable this way. Worked example: [[launch-capture-2026-09-23]] (rail pressure).
|
||||
- A continuous poller (Route A or B) would reuse the same transmit path with a fixed request list: one request per ≥100 ms, one identifier at a time, only while no scan tool is connected, never a session-control or write service. Still a design decision: a request storm or a malformed frame can disturb the DDE/EGS.
|
||||
- **What Route B self-polling actually requires (settled 2026-09-23):** just the `2C 10 15 E0` define then the `2C 10 <id>` poll — **no diagnostic session (`10`), no security access (`27`), no tester-present (`3E`)**, proven from the full Launch capture ([[launch-capture-2026-09-23]]). The `21`-block NRCs (0x22/0x33) that earlier looked like a session/security wall are a *different mechanism* and do not gate the `2C` path. `2C` is not strictly read-only (it writes a dynamic-identifier definition — harmless), so it stays out of the probe whitelist by policy.
|
||||
- **Design decision — the "Diagnostics" screen (2026-09-23):** if active polling is ever built, it lives behind a **password-protected Diagnostics screen** on Controller A (authorized-technician gate), triggered manually, only while no scan tool is connected, read-oriented services only. This is the deliberate on/off switch for transmit-on-the-bus — not a background poller. Not built yet; captured here so the capability and its guard rails are not re-researched later.
|
||||
- **Design decision — the "Diagnostics" screen (2026-09-23):** if active polling is ever built, it lives behind a **password-protected Diagnostics screen** on Main CTRL (authorized-technician gate), triggered manually, only while no scan tool is connected, read-oriented services only. This is the deliberate on/off switch for transmit-on-the-bus — not a background poller. Not built yet; captured here so the capability and its guard rails are not re-researched later.
|
||||
- Protocol v2 dropped the `fault_codes` field in favour of the alert bitmap ([[dual-controller-architecture]]); polled values would need new DATA fields.
|
||||
- The same request path would also be the only way to read DTCs (service `0x18`/`0x19`, variant-dependent) → [[open-questions]] #7.
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ The research frontier. Answering any of these should trigger updates across the
|
||||
|
||||
## Design decisions (parked, not blocking)
|
||||
|
||||
12. **The "Diagnostics" screen (planned 2026-09-23).** Active diagnostic polling — replaying the `2C` live-data reads we decoded ([[launch-capture-2026-09-23]]) so values like rail pressure appear on Controller A without the Launch — is now technically unblocked (no session/security needed). Intended design when built: a **password-protected Diagnostics screen**, authorized-technician access only, manual trigger, refuses while a scan tool is connected, read-oriented services only. The same gate covers the general transmit-on-the-bus decision. This is deliberately deferred, but the capability, the byte sequences, and these guard rails are recorded so the work resumes from here, not from scratch. OTA check/install was meant to live here too (2026-09-26); **decided otherwise 2026-09-27**: it is on the Settings screen behind a confirm dialog ([[ota-updates]]). Whatever password this screen gets must be stored as a salted hash in NVS because the firmware is public. → [[obd-diagnostic-polling]], [[dual-controller-architecture]], [[ota-updates]]
|
||||
12. **The "Diagnostics" screen (planned 2026-09-23).** Active diagnostic polling — replaying the `2C` live-data reads we decoded ([[launch-capture-2026-09-23]]) so values like rail pressure appear on Main CTRL without the Launch — is now technically unblocked (no session/security needed). Intended design when built: a **password-protected Diagnostics screen**, authorized-technician access only, manual trigger, refuses while a scan tool is connected, read-oriented services only. The same gate covers the general transmit-on-the-bus decision. This is deliberately deferred, but the capability, the byte sequences, and these guard rails are recorded so the work resumes from here, not from scratch. OTA check/install was meant to live here too (2026-09-26); **decided otherwise 2026-09-27**: it is on the Settings screen behind a confirm dialog ([[ota-updates]]). Whatever password this screen gets must be stored as a salted hash in NVS because the firmware is public. → [[obd-diagnostic-polling]], [[dual-controller-architecture]], [[ota-updates]]
|
||||
|
||||
## Project context
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ updated: 2026-09-27
|
||||
|
||||
# OTA Firmware Updates
|
||||
|
||||
How Controller A updates itself from this repo's Gitea releases, why each piece is the way it is, and what is still to do (Controller B). Built 2026-09-26. Design decisions by the user are marked **(decision)**.
|
||||
How Main CTRL updates itself from this repo's Gitea releases, why each piece is the way it is, and what is still to do (Inst. Cluster). Built 2026-09-26. Design decisions by the user are marked **(decision)**.
|
||||
|
||||
## The pipeline
|
||||
|
||||
@@ -16,7 +16,7 @@ git push tag vX.Y.Z ──► Gitea Actions (.gitea/workflows/firmware.yml, runn
|
||||
sign "patrol-a|vX.Y.Z|<sha256>" with secret BMW_NISSAN_FIRMWARE_SIGNING_KEY
|
||||
release vX.Y.Z: firmware.bin + firmware.elf + manifest.txt
|
||||
│ public repo, HTTPS, no token
|
||||
Controller A Settings → Updates → Install ◄──┘ (or `ota install`; parked, Wi-Fi joined)
|
||||
Main CTRL Settings → Updates → Install ◄──┘ (or `ota install`; parked, Wi-Fi joined)
|
||||
GET /api/v1/repos/art/ESP32-S3-Touch-LCD-5B/releases/latest → tag
|
||||
GET /releases/download/<tag>/manifest.txt → verify signature FIRST
|
||||
GET /releases/download/<tag>/firmware.bin → idle slot, hashed while streaming
|
||||
@@ -50,11 +50,11 @@ Known quirk: `ota status` shows the *other* slot's "built" date from the framewo
|
||||
|
||||
## Decisions and why
|
||||
|
||||
- **Manual trigger only (decision, 2026-09-26).** An install ends in a reboot, which blanks Controller B's gauges; nothing checks or installs in the background.
|
||||
- **Manual trigger only (decision, 2026-09-26).** An install ends in a reboot, which blanks Inst. Cluster's gauges; nothing checks or installs in the background.
|
||||
- **On the Settings screen, behind a confirm dialog (decision, 2026-09-27)** — replacing the earlier plan to put it on the password-gated Diagnostics screen. Settings → Updates shows installed vs latest and a **Check for updates** button; **Install vX** appears only when the latest release differs and asks "Install vX? The screen goes dark for about a minute… only while parked". The user chose a confirm dialog over a PIN: the parked gate and the signature already guard the dangerous parts; a PIN can come with the Diagnostics screen ([[open-questions]] #12). The `ota` console stays for bench work and `rollback`.
|
||||
- **Parked gate** `(repo)`: refused if engine rpm > 0 / run state running or starting, output shaft turning, or lever in a drive gear. A silent bus (>2 s no frames: ignition off, bench) counts as parked. Checked before the download **and again** before the slot switch. `ota check` is exempt (read-only).
|
||||
- **HTTPS pull from a public repo (decision).** Both repos were made public 2026-09-26 so the device needs **no token** — the same reasoning as `parking_solution`'s public releases mirror: a read token in shipped firmware leaks with the device. History was scanned before/after going public: no secrets, no full VIN (only the 10-char prefix in ident logs), no SSIDs `(verified 2026-09-26)`.
|
||||
- **Signed images (decision).** HTTPS only proves the file came from the server; the ECDSA P-256 signature proves it came from our CI key. The signed statement is `target|version|sha256`, so a Controller B image can't be installed on A even with a shared key, and the manifest version can't be swapped. The firmware contains no secrets, so public binaries are fine — **keep it that way**: the future Diagnostics-screen password must be a salted hash in NVS, never a literal in source.
|
||||
- **Signed images (decision).** HTTPS only proves the file came from the server; the ECDSA P-256 signature proves it came from our CI key. The signed statement is `target|version|sha256`, so a Inst. Cluster image can't be installed on A even with a shared key, and the manifest version can't be swapped. The firmware contains no secrets, so public binaries are fine — **keep it that way**: the future Diagnostics-screen password must be a salted hash in NVS, never a literal in source.
|
||||
- **TLS trust = Let's Encrypt roots, not the leaf** `(verified 2026-09-26)`: the server chain is leaf (SAN `git.infra.msai.al`) → YR2 → Root YR (cross-signed by ISRG Root X1). Both ISRG Root X1 (to 2035) and Root YR (to 2045) are embedded in `include/config/ota_config.h`, and each verifies the chain alone. Leaf certs rotate ~90 days — never pin them. The framework's mbedtls has `MBEDTLS_HAVE_TIME_DATE` off, so no NTP is needed (and cert dates aren't checked; the signature is the real guarantee).
|
||||
- **Rollback**: the framework bootloader has `CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE=y`, but Arduino's `initArduino()` marks a new image valid *before* `setup()`. `ota_update.cpp` overrides `verifyRollbackLater()` → the image stays PENDING_VERIFY until `Ota::tick()` confirms it after 30 s. Consequence: **power off within 30 s of an update's first boot = back to the old version** (by design).
|
||||
|
||||
@@ -106,9 +106,9 @@ Wi-Fi must be joined first — Settings → Wi-Fi (remembered from then on) or `
|
||||
- **Joining Wi-Fi killed ESP-NOW**: the Wi-Fi task used `WiFi.disconnect(true)` (true = radio off), which drops ESP-NOW; B then ran on the wire only. Now `WiFi.disconnect()`, and `EspNowLink::send()` re-initialises ESP-NOW if the driver ever drops it. Verified: joined Personal1 (channel 9), ESP-NOW 195 sent / 0 failed.
|
||||
- `showConnectionResult()` took the LVGL lock with a 0 ms try-lock, ignored the result, and touched widgets that are NULL off the Settings screen — now waits for the lock and null-checks. It still showed **no success feedback** on screen (user: "a disaster UX") — resolved by the hand-coded Settings screen in v0.1.5 ([[open-questions]] #14).
|
||||
|
||||
## Controller B (implemented 2026-09-27)
|
||||
## Inst. Cluster (implemented 2026-09-27)
|
||||
|
||||
The 2026-09-26 idea (A streams B's image over ESP-NOW) was dropped for a **pull design** the user chose on 2026-09-27: B downloads its own signed release (target `patrol-b`, B's repo, same key) over Wi-Fi; A only hands over the credentials and the trigger. Full design, verification state and the first-pairing procedure live in B's wiki (`../../ESP32-S3-LCD-1.3/wiki/pages/controller-b-ota.md`). A's side: `src/modules/link_peer.cpp` - `link pair` sends a random key over the UART wire once (never by radio; both repos are public), B's `STATUS` frames (version, phase, progress) arrive over ESP-NOW unicast, credentials and OTA commands go to B inside AES-256-GCM `SECURE` frames, and Settings → Updates gained a **Controller B** card (Installed / Latest / Check / Install) next to Controller A's. B's install is behind the same parking gate plus "A must be on Wi-Fi" (same AP ⇒ same channel ⇒ B's progress frames keep arriving). Console: `link status | pair | unpair | creds | ota check | ota install [force] | ota rollback`. **Verified end-to-end on the bench 2026-09-27**: `link pair` over the wire, automatic credential push, `link ota check` / `link ota install` from A's console took B from `dev` to `v0.1.0` (1,248,432 B in ~50 s), B rebooted, reported `v0.1.0` and confirmed itself after 30 s. The Updates-page buttons share the same request functions but have not been tapped yet.
|
||||
The 2026-09-26 idea (A streams B's image over ESP-NOW) was dropped for a **pull design** the user chose on 2026-09-27: B downloads its own signed release (target `patrol-b`, B's repo, same key) over Wi-Fi; A only hands over the credentials and the trigger. Full design, verification state and the first-pairing procedure live in B's wiki (`../../ESP32-S3-LCD-1.3/wiki/pages/controller-b-ota.md`). A's side: `src/modules/link_peer.cpp` - `link pair` sends a random key over the UART wire once (never by radio; both repos are public), B's `STATUS` frames (version, phase, progress) arrive over ESP-NOW unicast, credentials and OTA commands go to B inside AES-256-GCM `SECURE` frames, and Settings → Updates gained a **Inst. Cluster** card (Installed / Latest / Check / Install) next to Main CTRL's. B's install is behind the same parking gate plus "A must be on Wi-Fi" (same AP ⇒ same channel ⇒ B's progress frames keep arriving). Console: `link status | pair | unpair | creds | ota check | ota install [force] | ota rollback`. **Verified end-to-end on the bench 2026-09-27**: `link pair` over the wire, automatic credential push, `link ota check` / `link ota install` from A's console took B from `dev` to `v0.1.0` (1,248,432 B in ~50 s), B rebooted, reported `v0.1.0` and confirmed itself after 30 s. The Updates-page buttons share the same request functions but have not been tapped yet.
|
||||
|
||||
## Related
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ updated: 2026-09-22
|
||||
|
||||
# Patrol instrument cluster — signal expectations
|
||||
|
||||
What the target vehicle's cluster ([[nissan-patrol-swap]]) needs on its tach and temp inputs, from the first day of driving it with Controller B's outputs through the low-side FET stage ([[canny-5-3-pico-gauge-drive]]). Patrol generation still unidentified — Y60/GQ vs Y61/GU matters for gauge internals → [[open-questions]].
|
||||
What the target vehicle's cluster ([[nissan-patrol-swap]]) needs on its tach and temp inputs, from the first day of driving it with Inst. Cluster's outputs through the low-side FET stage ([[canny-5-3-pico-gauge-drive]]). Patrol generation still unidentified — Y60/GQ vs Y61/GU matters for gauge internals → [[open-questions]].
|
||||
|
||||
## Tachometer
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
---
|
||||
type: concept
|
||||
tags: [power, sleep, settings, verified]
|
||||
updated: 2026-09-28
|
||||
---
|
||||
|
||||
# Sleep when the car is off
|
||||
|
||||
User request 2026-09-28: both boards sit on permanent 12 V, so they must stop burning power when the CAN bus goes quiet. One switch, **Settings → System → "Sleep when the car is off"** (NVS `sleep_en`, default OFF), rules both controllers: the Main CTRL mirrors it into the CONFIG frame as `CFG_SLEEP_WHEN_SILENT` (bit 7 of `out_enable`, byte layout unchanged, `PACKET_VERSION` stays 2), and the Inst. Cluster caches CONFIG in NVS, so it knows the setting even after the Main CTRL has gone to sleep.
|
||||
|
||||
## Main CTRL (`src/modules/power_manager.cpp`)
|
||||
|
||||
Deep sleep when **all** of: switch on; CAN switched on but the bus quiet for 60 s (an ignition-on car never stops talking, so "quiet" = key off); nobody touched the screen for 60 s (`lv_disp_get_inactive_time`); no update running here or reported by the Inst. Cluster; up for at least 60 s. Sequence: `Tunables::flush()`, backlight off, `CANDriver::stop()` (frees GPIO 16 from TWAI), pull-up on GPIO 16, `esp_sleep_enable_ext0_wakeup(GPIO 16, low)`, `esp_deep_sleep_start()`. Wake = the first CAN frame pulls RX low → full reboot (~3 s to the Driveline); the boot log says `woke up: CAN bus activity`. Nothing else wakes it: with no bus (bench) only the reset button / a power cycle does, and the USB port is gone while asleep. Console: `sleep status | on | off | now`.
|
||||
|
||||
## Inst. Cluster (`src/modules/power_manager.cpp`)
|
||||
|
||||
Deep sleep when the bit is set, no DATA frame on any transport for 60 s, no update job, up ≥ 60 s. Gauges driven low and backlight off first. Two wake sources: **UART RX IO1 low** (the Main CTRL's first frame on the wire) and a **60 s timer**. A timer wake is a *probe boot*: setup skips its serial waits, the panel stays dark, and after 4 s without a frame the board sleeps again; if the Main CTRL is heard (ESP-NOW or wire) brightness is restored and the boot continues normally. This is what wakes a radio-only installation (no wire in the car).
|
||||
|
||||
## Verified 2026-09-28 (bench)
|
||||
|
||||
See the log entry of the day: switch → CONFIG → Inst. Cluster within a CONFIG period; `sleep now` on the Inst. Cluster and its wake.
|
||||
|
||||
## Not verified
|
||||
|
||||
- The Main CTRL's own sleep and CAN wake need the car (a quiet bus that later talks). Bench boards have no bus, so they would never wake.
|
||||
- Deep-sleep current of either board (Waveshare boards keep their LDO/USB bridge powered).
|
||||
- Whether the TJA1051's RXD idles high with the transceiver powered but the bus off (expected).
|
||||
|
||||
## Related
|
||||
|
||||
[[ota-updates]] · [[esp32-s3-touch-lcd-5b]] · (sibling wiki: controller-link, patrol-gauge-outputs)
|
||||
@@ -6,7 +6,7 @@ updated: 2026-09-23
|
||||
|
||||
# Route A probe — first live run (2026-09-23)
|
||||
|
||||
First execution of the [[obd-diagnostic-polling]] Route A test: the `diag` console probe on Controller A, engine idling, Launch unplugged, tapped PT-CAN. Two sessions, raw console logs (CANRAW + CANTX + diag output interleaved):
|
||||
First execution of the [[obd-diagnostic-polling]] Route A test: the `diag` console probe on Main CTRL, engine idling, Launch unplugged, tapped PT-CAN. Two sessions, raw console logs (CANRAW + CANTX + diag output interleaved):
|
||||
|
||||
- `raw/diag-20260923-111737.log` — `pids`, `pid 0C`, `pid 05`, `pid 0B`, `pid 70`, `vin`, `ecu`, `status`
|
||||
- `raw/diag-20260923-111851.log` — `pid 10`, `pid 04`, `pid 0F`, `pid 0D`, `pid 1C`, `pid 01`, `pid 21`, `status`
|
||||
|
||||
@@ -20,7 +20,7 @@ raw: raw/ESP32-S3-Touch-LCD-5-details-intro.jpg
|
||||
|
||||
## Relevance
|
||||
|
||||
- Confirms the terminal-block signal set and that the RS485 pair is the only UART1 exit → `(sibling: 1.3 wiki → controller-link)` open question #1 on how the wire to Controller B is really made
|
||||
- Confirms the terminal-block signal set and that the RS485 pair is the only UART1 exit → `(sibling: 1.3 wiki → controller-link)` open question #1 on how the wire to Inst. Cluster is really made
|
||||
- Confirms one shared termination switch for CAN and RS485 — keep it **OFF** when tapping the vehicle CAN bus, which also leaves the RS485 link unterminated on this end
|
||||
- Strapping pads IO0/IO3/IO4/IO46 exist as solder points — the only bare GPIO access on the board, and all four are already committed (G3, VSYNC, CTP_IRQ, HSYNC)
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ Raw: `raw/ESP32-S3-Touch-LCD-5-Sch.pdf` (3 sheets, V1.2), re-downloaded 2026-09-
|
||||
## 5 V rail budget (for whatever hangs on VOUT)
|
||||
|
||||
- `VIN` (7–36 V terminal) → `D17` 1N5822 reverse-protection Schottky + `D3` SMAJ36CA TVS → `U1` **SY8293** synchronous buck → **`DC_5V`**, `L3` 4.7 µH 8 A, note *"Run the line at current 2A"*. `DC_5V` feeds the 5 V rail (and VBUS via `Q4` AO3401 ideal-diode-style switch).
|
||||
- Sheet note: *"The screen itself consumes close to 550 mA"*; the wiki's whole-board figure is ~450 mA @ 5 V. Realistic headroom on VOUT@5 V from the 12 V input: **roughly 1 A**, comfortably enough for Controller B (~150–200 mA) `(unverified estimate; the regulator is rated for 2 A total)`.
|
||||
- Sheet note: *"The screen itself consumes close to 550 mA"*; the wiki's whole-board figure is ~450 mA @ 5 V. Realistic headroom on VOUT@5 V from the 12 V input: **roughly 1 A**, comfortably enough for Inst. Cluster (~150–200 mA) `(unverified estimate; the regulator is rated for 2 A total)`.
|
||||
- On USB-only power the 5 V rail is the host's 500 mA — do not load VOUT then.
|
||||
- Caveat for the vehicle: the 36 V TVS is the only transient clamp; the ISO 7637 concern in [[open-questions]] #6 stands.
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ Official product documentation for the ESP32-S3-Touch-LCD-5 family. Covers four
|
||||
- **120 Ω termination resistor switch, OFF by default** — correct setting for tapping into an existing, already-terminated vehicle bus; leave it off.
|
||||
|
||||
**Other onboard peripherals:**
|
||||
- RS485 via SP3485, automatic TX/RX direction switching (this is the terminal block the firmware uses for UART1 → Controller B `(repo)`).
|
||||
- RS485 via SP3485, automatic TX/RX direction switching (this is the terminal block the firmware uses for UART1 → Inst. Cluster `(repo)`).
|
||||
- Optocoupler-isolated digital I/O: inputs 5–36 V (dry/wet contact, NPN or PNP), open-drain outputs sinking up to 450 mA/channel.
|
||||
- PCF85063 RTC with CR927 coin-cell holder.
|
||||
- TF card slot (SD_CS must be driven via CH422G EXIO4).
|
||||
|
||||
@@ -6,7 +6,7 @@ updated: 2026-09-23
|
||||
|
||||
# Launch live-data capture — rail pressure decoded (2026-09-23)
|
||||
|
||||
The capture-with-Launch session that [[obd-diagnostic-polling]] had been pointing at since July, finally run. Engine idling, our read-only logger (`tools/serial_logger.py`) on Controller A's USB recording the full `CANRAW` stream while the Launch polled the DDE; then the user selected **Rail Pressure (actual)** and blipped to 2500 rpm for a second calibration point. Raw: `raw/serial-COM10-20260923-163511.log` (~13 MB, both halves of every exchange).
|
||||
The capture-with-Launch session that [[obd-diagnostic-polling]] had been pointing at since July, finally run. Engine idling, our read-only logger (`tools/serial_logger.py`) on Main CTRL's USB recording the full `CANRAW` stream while the Launch polled the DDE; then the user selected **Rail Pressure (actual)** and blipped to 2500 rpm for a second calibration point. Raw: `raw/serial-COM10-20260923-163511.log` (~13 MB, both halves of every exchange).
|
||||
|
||||
## Headline: rail pressure actual is decoded and VERIFIED
|
||||
|
||||
@@ -41,7 +41,7 @@ This is the key operational finding: **rail pressure is served in the DDE's defa
|
||||
- **The method generalises**: any value the Launch will display can be decoded the same way — capture the `2C`/`6C` pair while its screen shows the number, calibrate scale against the display at two points. Boost, MAF, injection quantity, EGTs are each one session away. See [[obd-diagnostic-polling]] "Beyond the probe".
|
||||
- **Self-poll is feasible without any secret.** To read rail pressure ourselves: send the one-time define `2C 10 15 E0`, then poll `2C 10 00 DF` → parse `6C 10 HHLL`. **No `10` session, no `27` security, no `3E` tester-present required** (proven above). The only barriers are our own choices, not the ECU's — see the two below.
|
||||
- **It is still a transmit-on-the-bus action, and `2C` is not strictly read-only** (it writes a definition into the ECU's dynamic-identifier table — harmless, but a state change). So it stays outside the current probe whitelist by policy.
|
||||
- **Intended home (design decision, 2026-09-23):** any active polling belongs behind a **password-protected "Diagnostics" screen** on Controller A — authorized-technician gate — never a background/automatic poller and never while a scan tool is connected. Records [[open-questions]]; not built yet.
|
||||
- **Intended home (design decision, 2026-09-23):** any active polling belongs behind a **password-protected "Diagnostics" screen** on Main CTRL — authorized-technician gate — never a background/automatic poller and never while a scan tool is connected. Records [[open-questions]]; not built yet.
|
||||
- No EGS traffic (`0x618`) — only the DDE (`0x612`) answered; the Launch was on an engine page.
|
||||
|
||||
## Related
|
||||
|
||||
Reference in New Issue
Block a user