Controller B updates from A: link_peer (pairing over the wire, encrypted credential handoff, B status + commands), ESP-NOW receive/unicast, Updates page with two cards; shared header maintenance frames; docs + wiki
Firmware / build (push) Successful in 7m1s
Firmware / build (push) Successful in 7m1s
This commit is contained in:
@@ -84,6 +84,7 @@ 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)
|
||||
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
|
||||
@@ -104,13 +105,14 @@ include/
|
||||
|
||||
**src/main.cpp** (~1530 lines)
|
||||
- Main application logic, event handlers, FreeRTOS task implementations
|
||||
- Console command routing (`cfg`, `diag`, `ota`, `wifi`, `mem`, `perf`), setup order, `loop()` ticks for the three screens
|
||||
- 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).
|
||||
- `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()`
|
||||
- Maintenance frames (2026-09-27, `PACKET_VERSION` unchanged): `STATUS` 0x03 B → A, `PAIR` 0x04 A → B **wire only**, `SECURE` 0x05 A → B (AES-256-GCM, `include/protocol/link_secure.h` - shared and byte-identical too). `PACKET_MAX_PAYLOAD` is 160
|
||||
- Spec: `docs/UART_PROTOCOL.md`
|
||||
- **BMW CAN Bus ID mappings**: 11-bit PT-CAN IDs verified live on the swap bus (evidence: `wiki/pages/can-id-candidates.md`)
|
||||
- UART config: 115200 baud on GPIO 44 (TX) / 43 (RX, unused) — leaves the board via the SP3485 RS485 transceiver
|
||||
@@ -220,14 +222,18 @@ Settings persist across power cycles via ESP32 NVS (Non-Volatile Storage):
|
||||
|
||||
### ESP-NOW link
|
||||
|
||||
`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.
|
||||
`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)
|
||||
|
||||
`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`.
|
||||
|
||||
### 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** (installed vs latest, Check, Install behind a confirm dialog -> `Ota::requestCheck/requestInstall`), **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: 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
|
||||
- **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`)
|
||||
- The System page's "Performance overlay" switch shows LVGL's own perf monitor (real render FPS / CPU) and sets the debug flag sent to B
|
||||
@@ -328,6 +334,7 @@ xTaskCreatePinnedToCore(
|
||||
|
||||
### Build Errors
|
||||
|
||||
- **Build from PowerShell, not Git Bash**: `idf_tools.py` refuses MSYS ("MSys/Mingw is not supported"). The two projects also share one `framework-arduinoespressif32` package directory, so the first `pio run` after building ESP32-S3-LCD-1.3 reinstalls Arduino 3.3.3 and may fail once with `TypeError: expected str, bytes or os.PathLike object, not NoneType` - run it again.
|
||||
- **`Failed to install Python dependencies into penv (exit code: 2)`** at the start of `pio run`: the sibling ESP32-S3-LCD-1.3 project (official espressif32@6 platform) installs newer `urllib3`/`esptool` into the shared PlatformIO penv, and this project's pioarduino platform needs `urllib3<2`; its install step hides the error. Run `. oolsix_penv_deps.ps1`, then build again. Never build the two projects at the same time (shared penv).
|
||||
- **Missing libraries**: Run `pio lib update` then `pio run --target clean`
|
||||
- **Partition table not found**: Ensure `partition_table.csv` exists in project root
|
||||
|
||||
Reference in New Issue
Block a user