Protocols · the seams
NMEA telemetry — beacon to tablets
The beacon forwards the phone's own GNSS NMEA verbatim and adds seven synthesized sentence types. Every tablet on the fleet parses the same stream. There is no rate limiting and no change detection, which is what makes the stream self-healing for a tablet that just joined.
Framing
Every synthesized sentence has exactly this shape:
$<BODY>*<CC>\r\n
$start delimiter<BODY>— the comma-separated sentence, starting with the 5-character sentence identifier*checksum delimiter<CC>— two uppercase hex digits, the XOR of every character of<BODY>(i.e. strictly between$and*)- terminator
\r\n(0x0D 0x0A)
Encoded US-ASCII on the wire. All numeric formatting is pinned to
Locale.US — on a comma-decimal device an unpinned format would emit
12,3 and split the field, taking the whole fleet's telemetry down.
The tablet's parser (NmeaParser) accepts a one or two digit
checksum, a deliberate tolerance for third-party receivers that emit a single digit below
0x10. A sentence with no * fails. Dispatch is on the
last three characters of the identifier, so $GP / $GN /
$GL / $GA / $GB talkers all match the same handler.
Raw GNSS passthrough
The phone's own GNSS NMEA is forwarded verbatim — no filtering by talker
or type, no re-checksumming. The only modification is appending \r\n when the OS
hands over a message with no trailing newline.
The broadcaster also sniffs passing GGA sentences for fix quality and satellite count to
populate $ZBCN, but does not alter them.
While GPS test mode is armed the passthrough is suppressed entirely: no real GNSS sentence is forwarded or sniffed.
What the tablet consumes
| Sentence | Source | Consumed as |
|---|---|---|
GGA | Raw GNSS | Position, fix quality, HDOP → accuracy estimate |
RMC | Raw GNSS | Position, speed, course |
GPHDT | Synthesized | True heading (preferred over course) |
ZTLM | Synthesized | Pitch, roll, speed |
ZAUD ZENV ZSHK ZBCN ZODO | Synthesized | The five sensor channels |
VTG, HDG and HDM are deliberately rejected
VTG carries GPS course, not compass heading. Android chips emit it every
epoch and the beacon forwards raw NMEA verbatim, so treating it as heading would interleave with
$GPHDT in a last-writer-wins race and flip-flop a stopped vehicle's heading —
and it would keep the heading-freshness clock alive, defeating the dead-compass watchdog.
RMC's own course field is the correct course source.
HDG / HDM are magnetic heading; magnetic variation at Black
Rock City is roughly 13° east, so applying them as true heading would
be silently wrong by that much.
GLL, GSA and GSV are simply not parsed.
Standard sentence field use
Only the fields the tablet actually reads are listed.
GGA — minimum 10 fields
| Field | Meaning |
|---|---|
| 2, 3 | Latitude DDMM.MMMM, hemisphere N/S |
| 4, 5 | Longitude DDDMM.MMMM, hemisphere E/W |
| 6 | Fix quality — must be > 0 or the sentence is discarded. Quality 8 = NMEA “Simulation mode”, emitted only by GPS test mode |
| 8 | HDOP → accuracy estimate as hdop × 5.0 metres |
RMC — minimum 9 fields
| Field | Meaning |
|---|---|
| 2 | Status — must be A (valid) |
| 3–6 | Latitude / hemisphere / longitude / hemisphere |
| 7 | Speed over ground in knots → × 1.852 for kph |
| 8 | Course over ground, degrees true, normalised to [0, 360) |
Coordinates are DDMM.MMMM: degrees = integer part / 100, minutes = remainder.
Minutes outside [0, 60) are rejected, latitude is range-checked to
±90 and longitude to ±180, and the
hemisphere letter must be one of the four valid characters. A negative or non-finite speed yields
null rather than zero.
$GPHDT — true compass heading
$GPHDT,<heading>,T*CC
| Field | Type | Range / format |
|---|---|---|
| 1 | Heading, degrees true | %.1f, normalised to [0, 360) |
| 2 | Literal T | Fixed — true, not magnetic |
Example: $GPHDT,123.4,T*31
The only builder that normalises: 365.0 emits 5.0, -90.0 emits 270.0. Emitted every tick (~4 Hz) only when a heading is available — a device with no rotation-vector sensor emits nothing on this channel rather than a fabricated 0.0.
Heading is derived from the rotation vector and corrected to true north with
GeomagneticField, which needs a position. Until the first GPS fix arrives,
$GPHDT carries magnetic heading labelled T.
$ZTLM — IMU tilt and speed
$ZTLM,<pitch>,<roll>,<speedKph>*CC
| Field | Type | Units | Format |
|---|---|---|---|
| 1 | Pitch | degrees, −90…90 | %.1f |
| 2 | Roll | degrees, −180…180 | %.1f |
| 3 | Ground speed | kph | %.1f |
Example: $ZTLM,-2.5,1.0,8.4*2A
No clamping or normalisation is applied by the builder — the ranges come from the sensor. Speed is the GNSS fix's speed × 3.6, and is 0.0 when there is no fix.
Emitted every tick (~4 Hz) unconditionally, so a
device with no rotation-vector sensor broadcasts 0.0 pitch and roll.
Unlike $GPHDT and $ZENV, this channel has no absent-sensor
suppression.
$ZAUD — microphone level
$ZAUD,<rms>,<peak>,<beat>*CC
| Field | Type | Range | Format |
|---|---|---|---|
| 1 | RMS level | 0.0–1.0 | %.3f |
| 2 | Peak level | 0.0–1.0 | %.3f |
| 3 | Beat flag | 0 or 1 | integer |
Examples: $ZAUD,0.125,0.800,1*19 · silence
$ZAUD,0.000,0.000,0*16
Emitted once per captured audio frame — 1024 samples at 16 kHz ≈ 15.6 Hz. Levels are normalised against 16-bit full scale and clamped to 0–1 upstream of the builder. The beat flag compares frame energy against a decaying running average: the first frame never beats (no baseline), and sustained loudness stops beating as the average catches up.
The PCM buffer is a reused coroutine-local array reduced to these three scalars in place. Nothing audio-derived is written to storage. The microphone is optional at every layer — without the permission, or on a background / boot start, this channel is simply silent.
Consumed by :app for the passenger oscilloscope, and by zvision's
audio_bus for the tracker light's idle sound-reactive show.
$ZENV — ambient light
$ZENV,<lux>*CC
| Field | Type | Units | Format |
|---|---|---|---|
| 1 | Illuminance | lux, raw sensor value | %.1f |
Example: $ZENV,315.0*02
Emitted every 8th tick (~2 s), only when a reading
exists — a device with no light sensor emits nothing rather than
0.0, and the tablet shows -- lx (no sensor).
Drives the tablet's automatic screen dimming: a log-10 interpolation between 5 lux (brightness floor 0.05) and 2000 lux (1.0), applied as a ceiling that the burn-in phase backlight can further reduce but never raise. How that arbitration works →
$ZSHK — shock / impact
$ZSHK,<peakG>*CC
| Field | Type | Units | Format |
|---|---|---|---|
| 1 | Peak acceleration | g (1 g = 9.80665 m/s²), gravity removed | %.2f |
Example: $ZSHK,2.35*3C
Event-driven, not periodic. A window opens when linear acceleration magnitude reaches 1.5 g, tracks the peak for 120 ms, then reports the peak of the impulse rather than its onset. A 500 ms refractory period starts when the window closes, so a single bump produces one sentence.
Because every datagram is sent twice (multicast + broadcast), the tablet de-duplicates
byte-identical $ZSHK lines inside a 200 ms window.
Consumers diff a monotonic shockCount rather than watching the value.
$ZBCN — beacon health
$ZBCN,<batteryPct>,<fixQuality>,<satellites>,<uptimeSec>*CC
| Field | Type | Meaning |
|---|---|---|
| 1 | integer | Battery percentage, 0–100 (0 if the battery intent is unavailable) |
| 2 | integer | GNSS fix quality — the GGA field-6 code; 0 = no fix |
| 3 | integer | Satellite count |
| 4 | integer | Service uptime in seconds |
Example: $ZBCN,87,1,9,3600*17
Emitted every 20th tick (~5 s); the same tick persists the lifetime
odometer. Fields 2 and 3 are sniffed from passing GGA sentences. If the most recent GGA is more
than 10 s old the beacon reports 0/0 rather
than stale values, so a GNSS chip that has gone silent reads as “no fix”; before the
first GGA they are 0/0.
The tablet's ops footer flags battery ≤ 20 % and either
fixQuality ≤ 0 or satellites < 5 in red.
$ZODO — odometer
$ZODO,<tripMeters>,<totalMeters>*CC
| Field | Type | Units | Format |
|---|---|---|---|
| 1 | Trip distance since service start | metres | %.1f |
| 2 | Lifetime distance | metres | %.1f |
Example: $ZODO,1234.5,987654.0*1E
Both fields are metres — the on-screen readouts divide by 1000, the sentence does not. The
lifetime total is persisted in the beacon's SharedPreferences and survives restarts.
Emitted every 8th tick (~2 s).
Distance is haversine-accumulated with three fail-closed gates, all of which hold the anchor and add zero rather than guessing:
| Gate | Rule |
|---|---|
| Accuracy | Reported accuracy must be present and ≤ 20 m — applied to the first fix too, so a poor first fix never becomes the anchor |
| Jitter floor | Steps below 5 m are ignored |
| Teleport | Any step implying more than 160 kph is rejected, as are non-positive time deltas |
Recovery is automatic: once enough time has elapsed for a step to be plausible, it is accepted again.
Cadence summary
One 250 ms tick loop drives everything periodic, with integer divisors instead of per-channel timers. Tick 0 satisfies every divisor, so all periodic channels fire on the first tick.
| Channel | Trigger | Effective rate |
|---|---|---|
| Raw GNSS | OS NMEA callback | Whatever the receiver emits (requested ≥ 1 Hz) |
$GPHDT | Every tick, if heading available (the sim heading while GPS test mode is armed) | ~4 Hz |
$GPGGA / $GPRMC (GPS test mode only) | Every 4th tick while armed | ~1 Hz |
$ZTLM | Every tick | ~4 Hz |
$ZENV | Every 8th tick, if lux available | ~0.5 Hz |
$ZODO | Every 8th tick | ~0.5 Hz |
$ZBCN | Every 20th tick | ~0.2 Hz |
$ZAUD | Per audio frame | ~15.6 Hz |
$ZSHK | On impact | Event-driven |
There is no throttling, deduplication or change-detection beyond these divisors. An unchanged value is re-broadcast identically, which is what makes the stream self-healing for a tablet that just joined the network.
GPS test mode
The one sanctioned fabrication, for fleet-wide location testing (GpsSim.kt,
SimGpsReceiver.kt). It is armed and disarmed only over adb: the receiver is registered
by the running service and guarded by android.permission.DUMP, which the adb shell holds
and ordinary apps do not. Every extra is a string, so a malformed number rejects the whole command
instead of silently defaulting.
adb shell am broadcast -a org.pureagave.zodiac.beacon.SIM_GPS --es preset MAN
adb shell am broadcast -a org.pureagave.zodiac.beacon.SIM_GPS --es lat 40.78325 --es lon -119.20788 --es hdg 90 --es spd 8
adb shell am broadcast -a org.pureagave.zodiac.beacon.SIM_GPS --es hdg 180 --es spd 8 # turn from the current sim position
adb shell am broadcast -a org.pureagave.zodiac.beacon.SIM_GPS_OFF
Presets are MAN, TEMPLE and HOME; speed is bounded to
0–160 kph. Position is dead-reckoned as a pure function of elapsed time, so it never
drifts. While armed:
| Channel | Behaviour |
|---|---|
| Raw GNSS | Suppressed: not forwarded, not sniffed into $ZBCN |
$GPGGA | Synthesized every 4th tick (~1 Hz): quality 8, 12 satellites, HDOP 0.8, altitude 1191.0 m (a chosen value, not a measurement) |
$GPRMC | Synthesized on the same tick with the sim speed and heading |
$GPHDT | Every tick, from the sim heading instead of the compass |
$ZTLM | Speed field is the sim speed; pitch and roll stay real |
$ZBCN | Reports quality 8 / 12 satellites, so every tablet can see the fix is simulated |
$ZODO | Unaffected: fed only by real location updates, so it never accumulates simulated metres |
The armed state is memory-only: never persisted and cleared on service start and
stop, so a reboot always restores real GNSS. The beacon's own screen shows a red
⚠ GPS SIMULATED banner while it is armed.
$ZVER — build version
Not on the beacon's tick loop and not on the telemetry group: every node (the beacon, every
tablet and zvision) sends it to 239.7.7.40:10140 every
10 s, so the tablets can show which build each node runs in the log
viewer's FLEET tab. A peer unheard for 35 s reads OFFLINE.
$ZVER,<node>,<name>,<base>,<sha>,<dirty>,<epoch>*CC
e.g. $ZVER,9C1977,SM-X810,0.1.0,8f531e18a,0,1691900000*CC
| Field | Grammar | Meaning |
|---|---|---|
node | [A-Z0-9]{1,8} | Stable per-node key (from ANDROID_ID on Android, /etc/machine-id on the Jetson) |
name | [A-Za-z0-9._-]{1,16} | Human label: device model or hostname |
base | [0-9A-Za-z.+~-]{1,16} | Version name, e.g. 0.1.0 |
sha | [0-9a-f]{7,40} or unknown | Build commit |
dirty | [01] | 1 = modified tree, or unknown |
epoch | [0-9]{1,10} | Commit time, Unix seconds (0 when unknown) |
Same framing as the other $Z* sentences: a two-hex XOR checksum over the body; the
parser accepts one or two hex digits in either case and never throws. Every unknown fails toward
unknown/dirty, so a node that cannot identify its build never reads as current. Three
hand-written implementations (FleetVersion.kt, version_protocol.py and the
beacon's Nmea.zver, emit only) are pinned together by
protocol/version-protocol-golden.json, which all three test suites read.
Converted fromdocs/PROTOCOLS.md §2, §6 · ARCHITECTURE.md §5, §7.1