firmware: harden XIAO RS485 telemetry

This commit is contained in:
2026-07-26 18:01:58 -06:00
parent 8c2375d402
commit 35c0721b47
6 changed files with 50 additions and 6 deletions
+1
View File
@@ -9,6 +9,7 @@
- Replaced sensor auto-detection with the verified installation settings: BNO086 address `0x4B` and MAX-M10S UART at 38400 baud.
- Added fixed-address BNO086 power-up retries, runtime recovery, and report restoration after sensor resets.
- Expanded telemetry with BNO086 motion/gravity/stability reports and GPS HDOP/data ages.
- Hardened RS485 transmission with local-echo draining, frame-size guards, a larger RX buffer, and boot/frame sequence identifiers.
## Unreleased
+13 -2
View File
@@ -1,12 +1,12 @@
# XIAO ESP32-C6 Sensor Node Protocol
The XIAO sensor node reads the BNO086 and MAX-M10S and publishes vehicle telemetry over half-duplex RS485 at 115200 8-N-1, one JSON object per line. It owns no control state. Cargo remains the controller, HTTP server, and `/api/v1` source of truth; JBD/NimBLE behavior is unchanged.
The XIAO sensor node reads the BNO086 and MAX-M10S and publishes vehicle telemetry over half-duplex RS485 at 115200 8-N-1, one JSON object per line at 4 Hz. It owns no control state. Cargo remains the controller, HTTP server, and `/api/v1` source of truth; JBD/NimBLE behavior is unchanged.
The expansion-board pins are D2 driver enable, D4 TX, and D5 RX. Only physical bus ends should be terminated. Confirm A/B polarity because vendor labels vary.
## Schema version 1
`sensor_status` includes `node_id`, `firmware_version`, `uptime_ms`, and:
`sensor_status` includes `node_id`, `firmware_version`, `boot_id`, monotonically increasing `frame_sequence`, `uptime_ms`, and:
- `imu`: rotation data plus linear acceleration, angular velocity, gravity, stability classification, and per-report accuracy/age.
- `gps`: existing navigation data plus HDOP and location/time ages.
@@ -15,6 +15,17 @@ The expansion-board pins are D2 driver enable, D4 TX, and D5 RX. Only physical b
Consumers must check `valid` or `fix` before displaying measurements and ignore unknown fields. The native breakout coordinate frame is reported initially; installation-specific axis remapping should follow physical calibration.
The receiver should parse only newline-complete JSON objects. A changed `boot_id` indicates a node restart. A gap in `frame_sequence` indicates one or more dropped/corrupt frames. The node refuses to transmit an overflowed frame or one larger than 1900 bytes. At 115200 baud and 4 Hz, the maximum configured frame size consumes about 66% of the bus, leaving receive windows for commands and responses.
## RS485 bench check
1. Connect XIAO A to receiver A, B to B, and share ground. If no valid frames appear, swap A/B once because vendor labels vary.
2. Use 115200 baud, 8-N-1, and read through newline.
3. Confirm every received line parses as JSON with `type: sensor_status`.
4. Confirm `boot_id` stays constant, `frame_sequence` increments by one, and sensor ages remain low.
5. Disconnect/reconnect one bus conductor and verify the receiver detects sequence gaps rather than accepting partial JSON.
6. Terminate only the two physical ends of a long installed bus; a short bench cable normally does not need termination.
This link does not replace dashboard-to-Cargo WiFi/HTTP. A future dashboard receiver may display this telemetry without moving relay, BMS, alarm, or configuration authority away from Cargo.
## Level calibration commands