Add UART ACCEL_READ command for on-demand BMA456 samples.

Expose MessageType 24 with protobuf response (success, x, y, z in raw LSB),
firmware handler with mutex-safe I2C read, goTool `accel` CLI, and docs.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-05-28 19:55:02 +02:00
co-authored by Cursor
parent 16c521f71c
commit ba20544762
16 changed files with 479 additions and 99 deletions
+26 -1
View File
@@ -217,6 +217,7 @@ Host and master speak nanopb-encoded `UartMessage` inside UART frames (byte 0 =
| 21 | `OTA_SLAVE_PROGRESS` | Implemented (`cmd/cmd_ota_slave_progress.c`) — query per-slave ESP-NOW OTA progress |
| 22 | `FIND_ME` | Implemented (`cmd/cmd_espnow_find_me.c`) — `client_id=0` local ring, `>0` ESP-NOW to slave |
| 23 | `RESTART` | Implemented (`cmd/cmd_restart.c`) — `client_id=0` reboot master, `>0` ESP-NOW reboot slave |
| 24 | `ACCEL_READ` | Implemented (`cmd/cmd_accel_read.c`) — on-demand BMA456 XYZ (raw LSB) |
Regenerate C code:
@@ -310,6 +311,29 @@ Sets the **software** deadzone used by `bosch456.c` when logging accel (see [BMA
**Response:** `accel_deadzone_response` with applied `deadzone`, `success`, and `slaves_updated` (ESP-NOW count).
### ACCEL_READ command
Read the **current** BMA456 accelerometer sample on this node (master or slave with sensor). Values are raw LSB in the configured **±2g** range; they are **not** filtered by the software deadzone (unlike periodic `ACC X=…` logs in `bosch456.c`).
**Request:** framed `18` (`0x18`) only, or `18` + empty `accel_read_request`.
**Response:** `accel_read_response`:
| Field | Meaning |
|-------|---------|
| `success` | `true` if BMA456 is ready and I2C read succeeded |
| `x`, `y`, `z` | Raw accel LSB (`sint32`; meaningful only when `success`) |
If the sensor was not probed at boot (`bma456_is_ready()` false), `success` is `false` and axes are zero.
Host:
```bash
go run . -port /dev/ttyUSB0 accel
```
Implementation: `bma456_read_accel()` in `bosch456.c` (mutex with the 10 Hz poll task), handler in `cmd/cmd_accel_read.c`.
### ESPNOW_UNICAST_TEST command
Minimal master→slave ESP-NOW unicast check (no BMA456). Use this before debugging `ACCEL_DEADZONE` unicast.
@@ -454,7 +478,8 @@ Target: ESP32-S3. Close serial monitor on the UART adapter port before running `
| `cmd/cmd_version.c/h` | VERSION handler |
| `cmd/cmd_client_info.c/h` | CLIENT_INFO handler |
| `client_registry.c/h` | Registered slave table |
| `bosch456.c/h` | BMA456H I2C driver, accel poll, tap INT, deadzone filter |
| `bosch456.c/h` | BMA456H I2C driver, accel poll, on-demand read, tap INT, deadzone filter |
| `cmd/cmd_accel_read.c` | UART `ACCEL_READ` — current accel XYZ |
| `board_input.c/h` | Taster GPIO12, LiPo ADC on GPIO1 / GPIO12 |
| `pod_settings.c/h` | NVS persistence (accel deadzone, …) |
| `led_ring.c/h` | LED ring (digit display, progress bar) |