Skip to main content

Module gpsd_location_service

Module gpsd_location_service 

Source
Expand description

GPSD-backed Location Service.

GpsdLocationService connects to a running gpsd daemon over its JSON TCP protocol and publishes real GPS fixes to every subscriber, exactly like super::location_service::LocationService but sourcing data from a real GNSS receiver instead of software-injected fixes.

§Usage

use rustflexstack::facilities::gpsd_location_service::GpsdLocationService;

let mut svc = GpsdLocationService::new("127.0.0.1:2947");
let rx = svc.subscribe();

svc.start();  // spawns background thread

while let Ok(fix) = rx.recv() {
    println!("lat={:.6} lon={:.6} speed={:.1} m/s",
             fix.latitude, fix.longitude, fix.speed_mps);
}

§gpsd JSON protocol (subset used)

After connecting we send ?WATCH={"enable":true,"json":true}\n and then read newline-delimited JSON objects. We only care about objects whose "class" field is "TPV" (Time-Position-Velocity).

Structs§

GpsdLocationService
A location service that reads real positions from a gpsd daemon.