Add a receive path switch: V2X_RX or the spec's RAW_FRAME, with fragment reassembly

Settings > Connection > ESP32-C5 > Receive path chooses where received ITS messages come from.
V2X_RX (default) is the MicrOBU extension the board builds with gn_unwrap.c. Raw frames is the
station-link RAW_FRAME debug capture: the app switches RAW_CAPTURE on (mode 3), reassembles
fragmented link messages as the spec defines (LinkReassembly), parses the ITS5 record
(RawFrame) and unwraps the 802.11 frame with GnUnwrap, a Kotlin port of gn_unwrap.c. Both end
as the same V2X_RX frames, so nothing above the link changes, and the firmware keeps both.

GnUnwrapTest checks the port against the C code on 602 recorded, cut and corrupted frames
(corpus from obu-firmware/test/host: make corpus). 145 app tests. Fix the Connection text that
claimed the app picks the strongest micrOBU.
This commit is contained in:
Ashin Walpola
2026-11-11 16:19:32 +01:00
parent c96fd0086f
commit 1697091d3a
20 changed files with 1503 additions and 7 deletions
+13 -2
View File
@@ -42,7 +42,7 @@ hardware_paths:
messages_received: V2X_RX (0x90), signed or not, up to 494 octets
messages_sent: signed or unsigned per setting (Settings > Connection > ESP32-C5)
credentials: throwaway demo chain in app/src/main/assets/demo-chain.vcr
tests: 131 JVM unit tests, no emulator needed (domain/ has no Android imports)
tests: 145 JVM unit tests, no emulator needed (domain/ has no Android imports)
```
## Project goal
@@ -124,7 +124,7 @@ tools/ Bench scripts: STATUS watcher, bench-listener tally, MAPEM
docs/ Requirements traceability, signed ITS / VAM / BLE design, architecture diagrams
```
The `domain/` packages contain no Android imports. That is what makes the 131-test JVM suite possible without an emulator or instrumentation.
The `domain/` packages contain no Android imports. That is what makes the 145-test JVM suite possible without an emulator or instrumentation.
## Connectivity
@@ -156,6 +156,17 @@ Whether an active BLE connection costs 5.9 GHz reception has not been measured y
vanetza-idf verifies strictly and would drop anything unsigned or signed under another root, i.e. the bench car and every RSU. So every captured frame also goes through `gn_unwrap.c`, which strips 802.11, LLC/SNAP, GeoNetworking (single-hop and GeoBroadcast), an IEEE 1609.2 signed envelope if there is one, and BTP, and forwards the ITS payload for BTP ports 2001 CAM, 2002 DENM, 2003 MAPEM, 2004 SPATEM and 2018 VAM. Signatures are not checked on this path; the message is flagged "signed, not verified". A payload over 494 bytes does not fit one link message and is dropped and counted.
**Two receive paths, switchable** (Settings > Connection > ESP32-C5 > Receive path). Both end in the same decoded messages, so nothing above the link changes:
| | V2X_RX (default) | Raw frames |
|---|---|---|
| Source | the MicrOBU extension, opcode 0x90 | the spec's `RAW_FRAME` (0x85), switched on with `RAW_CAPTURE` |
| Who unpacks the frame | the board (`gn_unwrap.c`) | the app (`GnUnwrap.kt`, a port tested frame by frame against the C code) |
| Size | up to 494 octets | not limited: fragments are reassembled (`LinkReassembly`, as the spec defines) |
| Reliability | normal indication | debug copy: can be dropped when the link is busy, more bandwidth, especially over BLE |
The board always sends `V2X_RX`; the app consumes one path and ignores the other. Changing the setting takes effect at once on a configured station (`RAW_CAPTURE` mode 3 = on and broadcast frames only, mode 0 = off). `GnUnwrapTest` checks the Kotlin unwrapper against `obu-firmware/test/host/dump_corpus.c`'s output for 602 recorded, cut and corrupted frames.
## Verification
The app hand-encodes and decodes ETSI messages bit by bit on the ESP32-C5 path, which is the highest-risk code in the project. Round-trip tests through the project's own codecs structurally cannot catch a shared mistake about a field's bit width, and this project shipped exactly that bug three times (`CurvatureCalculationMode`, the GeoNetworking reserved bytes, `yawRateConfidence`). Phone and ESP32 agreed with each other and with nothing else.