Commit Graph
15 Commits
Author SHA1 Message Date
Ashin Walpola 7dd83dba3d Record motion sensors, raw GPS and clocks for sensor fusion, and add Ride settings
Phase 1 of GNSS/IMU sensor fusion: record what the filter needs, so it can
be built and tuned offline against real rides before it changes anything
on air (docs/07-sensor-fusion-logging.md).

Settings > Ride replaces Units, whose metric switch did nothing (the app is
metric throughout). It holds the phone position (handlebar, bag or pocket),
written into every V2X log as meta.phone_mount, and "Record motion
sensors", off by default.

With that switch on when a V2X log starts, the log (schema 2, file name
ending in _imu-<mount>) also records:
- accelerometer, gyroscope and gravity at 100 Hz into a new imu table, each
  sample with its own SensorEvent timestamp, collected on a background
  thread;
- raw GPS_PROVIDER fixes as gnss source phone_gps, next to the fused
  location, and for every phone fix its monotonic time, speed and bearing
  accuracy and provider;
- the monotonic, wall and GNSS clocks once a second into a new clock table,
  to line all timestamps up afterwards and show any phone clock step;
- the sensors' names and rates and the GNSS chip in meta.

Both settings are read once at the start, so one log is one mount and one
mode. The logger screen shows the mount, the motion sensor row count and
the raw GPS fix age while it runs.

tools/fusion_log_check.py checks a recorded log (sensor rates and gaps, both
phone sources, clock alignment and steps) and ends in PASS, WARN or FAIL.
Tested on synthetic logs built from V2xLogWriter's own table definitions;
the bench and ride checks on the Pixel 9 Pro are in TODO.
2026-11-19 15:17:02 +01:00
Ashin Walpola 457ad47521 Update the diagrams, READMEs and spec for the two receive paths
Add data-flow diagrams of both paths (V2X_RX and RAW_FRAME with the app's Receive path
switch) to the app README, the firmware README and docs/06, and bring the draw.io
architecture labels up to station-link revision 2. The spec (revision 2) gains
"V2X_RX and RAW_FRAME: both stay" and "Fragmentation on the host side". Document the corpus
generator in test/host.
2026-11-11 16:25:34 +01:00
Ashin Walpola 1697091d3a 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.
2026-11-11 16:19:32 +01:00
Ashin Walpola 38c21ed2a4 Update the notes, flashing guide and READMEs for the 2026-11-11 bench run
Document the MAC rotation (16-octet STATION_CONFIGURE), the ATT MTU of 517, the battery
reading fix, pairing and bonds with several boards, tools/station_tx_test.py, what was
dropped from the earlier MicrOBU version and what Niklas Dathe's latest firmware added,
and the measured results (BLE adds no transmit loss over USB). Test counts: 40 firmware,
131 app.
2026-11-11 15:32:42 +01:00
Ashin Walpola 37707548ca Rotate the link-layer address with the pseudonym again
The app sends the pseudonym's MAC in the 16-octet STATION_CONFIGURE (address_configuration
0), the station uses it for unsigned frames too, and a different MAC reconfigures the
station. A ride rotates it with the station ID; the bench CAM pinger keeps one. Without a
MAC the station behaves as before (ticket-derived when signed, random when unsigned).

tools/station_tx_test.py plays the phone over USB and reads the station's own raw capture
(source MAC, signed or not, submitted and completed counts). Add the 16-octet form to the
spec (revision 2), a firmware unit test and an app test. Fix the stale Connection texts.
2026-11-11 15:02:39 +01:00
Ashin Walpola 6f99154b23 Add a firmware README and an architecture overview to the app README
obu-firmware/README.md follows Niklas Dathe's microbu-firmware README: station
diagram with the MicrOBU raw receive, unsigned transmit and battery paths, a
summary block, build and flash, BLE pairing, host tests and links.

The app README gets an architecture diagram and a summary block, corrects the
pseudonym description for the 2026-11-10 firmware (the link has no MAC field any
more) and the unit test count (130).
2026-11-11 01:30:47 +01:00
Ashin Walpola fd006192e7 Update the notes for the new firmware and name Niklas Dathe
README, docs/06, TODO and the architecture diagram describe the microbu-firmware
based obu-firmware and station-link revision 2, add the hardware checks for the
new image, and credit Niklas Dathe as the author of the station firmware and its
interface specification. Ignore LaTeX build output next to station-link.tex.
2026-11-11 00:13:58 +01:00
Ashin Walpola 1c3a66e4da Update the README for BLE, signed messages and traffic lights per lane
The README predated the vanetza-idf port. It now describes the ESP32-C5 as
the XIAO running a signing ITS station, the station-link protocol over
USB-C and Bluetooth LE (GATT layout, pairing, reconnect, USB priority),
the raw receive path and its five BTP ports, phone-built CAM or VAM sent
signed or unsigned, traffic lights per lane from SPATEM and MAPEM, the
V2X data logger and the battery display. Architecture, verification,
documentation links, getting started and the known limitations follow
the current code; the version is the build's versionName, 0.1.0.
2026-11-03 15:09:54 +01:00
Ashin Walpola 5ec3619cbe Stop retaining detected manoeuvres; the CAM rate bump is their only consumer
The detector runs to raise the CAM transmit rate through a manoeuvre. Nothing
else read its output once the UI was removed, so keeping the rows was storing
data with no reader on the chance it would one day be analysed.

Drops the detected_events table in schema v5, deletes DetectedEventEntity and
the DAO and repository methods behind it, removes the insertEvent call from the
recording service, and removes the per-event rows and their five columns
(event_type, confidence, peak_accel, peak_gyro, duration_ms) from the trip CSV
along with the events parameter threaded through buildTripCsv and shareTripCsv.
A detected manoeuvre now lives for the length of one onDetectedEvent call.

MIGRATION_1_2 still creates the table: a v1 install upgrades 1-2-3-4-5 and so
creates it before v5 drops it. Removing it from the earlier migration would
break that path for anyone who has not upgraded yet.

trips.eventCount is kept. Dropping a SQLite column means recreating the table
and copying every recorded ride across, which is real risk for one unused
integer; the service still writes an accurate count and the CSV header still
reports it. It is the only thing left about detected manoeuvres.

This closes off the route to the false-positive measurement that 11.3 flags as
missing, so 11.3 now says that outright rather than pointing at an export that
no longer carries the data. Docs 11.3/11.4, the user guide, the README and the
traceability matrix updated to match. 55 tests, 0 failures.
2026-09-08 16:29:02 +02:00
Ashin Walpola 1ad123a6f8 Make the event detector a CAM rate input, not a ride-stats readout
The detector's only live consumer is the CAM transmit-rate policy: every
emitted event calls CamTransmitLoop.onDetectedEvent, raising the beacon
rate from 1 Hz to the elevated rate for five seconds so nearby stations
get denser updates through a manoeuvre. Counting one's own braking events
is not a goal of this project, so the display is gone and the detector
stays: the live per-type counters and their notification text, the event
pins and detail sheet on the trip review map, and the event chip on the
history card. Events are still persisted and exported to CSV, which is
the only route to the tuning measurement section 11.3 says is missing.

Fix two defects found while documenting the detector.

TripRecordingService overrode nine of DetectionConfig's twelve parameters
in its constructor, so the tests validated the Phase A defaults while the
phone ran something materially less sensitive. The tuned values are now
the defaults and the override is deleted; the numbers moved location, not
value, so detector sensitivity is unchanged. EventDetectorTest now sets
only windowSize and the sustained-frame counts and inherits every signal
threshold, which cannot drift again. That was not a free change and makes
the same point from the other side: at the real thresholds the old stimuli
triggered nothing. Accel alternating 3.5/0.5 gives a std dev of 1.5 and
never clears 1.8, and the moderate-braking case used a 0.8 m/s drop that
never clears 1.0. Those stimuli are re-derived against the real values.

brakingHighConfidenceRate was documented as a rate but has always been
compared against the peak cumulative drop from the onset speed, which
grows with episode length, so HIGH was assigned more readily than the name
implied. Renamed to brakingHighConfidencePeakDrop rather than changing the
comparison: "lost more than 1.5 m/s in one episode" is coherent, whereas a
rate off a 1 Hz speed signal sampled at 50 Hz spikes on a near-zero
divisor early in an episode. Output is unchanged, so the existing
confidence assertions stay evidence instead of being re-baselined.

Docs 11.3/11.4 updated in place, including the correction of a claim that
detected events do not reach the V2X side; the rate-bump path already
existed when that was written. 55 tests, 0 failures.
2026-09-08 16:20:14 +02:00
Ashin Walpola b6a687982d Update the README for the ESP32-C5 path and the two documents
The README still described the project as it was before Phase 03. Several
claims had become actively wrong rather than merely dated, and the last one
is the kind a reviewer would catch:

- "no ASN.1 encoding in the app" - the app hand-encodes and decodes CAM,
  DENM and SPATEM bit by bit on the ESP32-C5 path. domain/asn1/ is now the
  highest-risk code in the project, and the README denied it existed.
- The phase table listed Phase 03 as Bluetooth BLE. Phase 03 is the
  ESP32-C5; Bluetooth is not implemented and the requirements leave it open.
- "communicates with the OBU exclusively via the consider it MQTT API v6"
  is true of one of the two hardware paths.
- The feature list claimed MAP and CPM display. There is no MAPEM decoder
  and nothing in the tree supports CPM, so both claims are dropped rather
  than carried forward.
- DENM transmission was listed as a headline feature with no indication that
  it is a manual antenna and range test tool, CiT One only, and deliberately
  never triggered by a detected event or a use case alert. That decoupling is
  the project's central architectural rule and the README implied the
  opposite.
- The architecture tree predated domain/asn1, domain/usecase, domain/cam,
  data/cam, the serial transport, obu-firmware/ and asn1/.

Added: the project goal, the two hardware paths and the point where they
converge, a verification section, a documentation index, and a status
section.

The convergence point is worth stating in the README rather than only in the
technical document, because it is what makes the second OBU a drop-in rather
than a fork: both paths normalise into the domain Cam type at
CamUseCaseRepository, and everything above it is shared and
transport-agnostic.

The status section says plainly that requirement 11.6 is not met, that
messages are not signed, and that the detection thresholds are untuned
estimates. Someone arriving at this repository should learn that from the
front page rather than from page forty of a Word document.
2026-09-01 15:07:57 +02:00
Ashin Walpola 4b20820ded docs: add project README 2026-06-08 16:23:08 +02:00
Ashin Walpola baf4853c0f 03,06.2026 change 2026-06-03 15:15:39 +02:00
Ashin Walpola 1dc0286af8 edit 03.06.2026 2026-06-03 14:58:46 +02:00
Maximilian Weltz ee122765e1 add README 2026-06-03 14:44:56 +02:00