use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
pub struct GnssFix {
pub lat: f64,
pub lon: f64,
pub alt: f64,
pub h_acc: f64,
pub ts_ns: u64,
pub fix_type: u8,
}
impl GnssFix {
pub fn is_rtk(&self) -> bool {
self.fix_type >= 3
}
pub fn is_rtk_fixed(&self) -> bool {
self.fix_type == 4
}
}
pub fn open_ublox(_path: &str) {
todo!("open_ublox: requires ublox + serialport crates + hardware");
}
pub fn read_fix() -> GnssFix {
todo!("read_fix: requires ublox + serialport crates + hardware");
}
pub async fn ntrip_connect(
_caster_url: &str,
_mountpoint: &str,
_credentials: &str,
) {
todo!("ntrip_connect: requires HTTP client for NTRIP protocol");
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn gnss_fix_rtk_checks() {
let fix = GnssFix {
lat: 10.7626,
lon: 106.6601,
alt: 5.0,
h_acc: 0.01,
ts_ns: 0,
fix_type: 4,
};
assert!(fix.is_rtk());
assert!(fix.is_rtk_fixed());
let standalone = GnssFix { fix_type: 1, ..fix };
assert!(!standalone.is_rtk());
}
#[test]
#[should_panic(expected = "requires ublox")]
fn open_ublox_panics() {
open_ublox("/dev/ttyACM0");
}
#[test]
#[should_panic(expected = "requires ublox")]
fn read_fix_panics() {
let _ = read_fix();
}
}