gate: replace JSON with nanopb (issue #8) #92
Loading…
Reference in a new issue
No description provided.
Delete branch "gate-nanopb/gate-nanopb"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Replaces the newline-delimited JSON gate protocol with length-prefixed binary protobuf (nanopb on the firmware, betterproto on the server). Closes #8.
Bandwidth comparison: JSON → protobuf
Byte-for-byte comparison of identical payloads, old encoding replicated exactly from the pre-protobuf firmware
snprintfpayloads (4c6a673~1), new encoding from the nanopb firmware / betterproto server.Per-message size (same data, both encodings)
I/NET(32-char msg)log_line(embedded 151-char JSONL trigger)Bitrate impact
Steady-state race model — 2 gates, each with 1 Hz heartbeat + 1 log line/s + 2 triggers/min:
Trigger burst (worst case for timing precision, e.g. 6 vehicles/min through the track): each trigger event drops from 130 B to 23 B.
Where the savings come from
"gate_id":"timestamp"...field labels become 1–2 byte protobuf tag prefixesuint32values likebattery_mvare 2 bytes instead of 4 ASCII digitstrue→ 1 byte) instead of 4–5 ASCII charsfw_version,git_sha) and the embedded JSONL inlog_line— those are incompressible in both formats.Framing overhead is comparable (2-byte LE prefix vs 1-byte newline delimiter), so it doesn't change the picture.
Bottom line: ~72–80% bandwidth reduction on the dominant message types, with the biggest absolute win on heartbeats (239 B saved per gate per second) since those are sent most frequently.