flightrelay
Rust SDK for the Flight Relay Protocol (FRP) — golf launch monitor event streaming over WebSocket.
What's in the box
- Message types — strongly typed Rust representations of every FRP message, event, and command
- Unit-tagged values —
DistanceandVelocitytypes that serialize as unit-tagged strings ("180.5m","67.2mps") with full unit conversion - Shot accumulator —
ShotAggregatorcollects lifecycle events (shot_trigger→ball_flight+club_path+face_impact→shot_finished) and yields a composedCompletedShot - WebSocket transport —
FrpClientandFrpListener/FrpConnectionhandle the FRP handshake and provide synchronous send/recv
Features
| Feature | Description |
|---|---|
| (default) | Message types, parsing, unit-tagged values |
controller |
ShotAggregator for accumulating shot lifecycle events |
device |
Reserved for future device-side helpers |
client |
FrpClient — WebSocket client (connects to a device) |
server |
FrpListener / FrpConnection — WebSocket server (accepts controllers) |
The client and server features add a dependency on tungstenite.
Usage
Controller (receiving shots)
use ;
// Connect to a device and perform the FRP handshake
let mut client = connect?;
let mut shots = new;
loop
[]
= { = "0.1", = ["client", "controller"] }
Device (emitting shots)
use ;
// Listen for controllers
// Bind to the default FRP port (clients connect to ws://host:5880/frp)
let listener = bind?;
let mut conn = listener.accept?;
// Send a shot
let key = new;
conn.send_envelope?;
conn.send_envelope?;
conn.send_envelope?;
[]
= { = "0.1", = ["server"] }
Messages only (no WebSocket)
use ;
let msg = parse?;
let json = msg.to_json?;
// Unit conversion
let d = meters;
assert_eq!; // approximate
[]
= "0.0.1"
Protocol
FRP is a minimal WebSocket protocol. After a start/init handshake, the device streams JSON events for each shot lifecycle stage:
shot_trigger → ball_flight + club_path + face_impact (any order) → shot_finished
Events arrive as they become available — ball flight data may arrive immediately while club and face impact data take longer to process. Controllers accumulate events by shot_id until shot_finished.
See the full spec for details.
License
Licensed under either of Apache License, Version 2.0 or MIT License, at your option.