use std::collections::BTreeMap;
use async_trait::async_trait;
use rmpv::Value;
use super::{Bus, DriverResult, SampleStream};
#[derive(Debug, Clone, PartialEq)]
pub struct GpsCandidate {
pub driver_id: String,
pub device_id: String,
pub label: String,
pub bus: Bus,
pub vid_pid: Option<(u16, u16)>,
pub metadata: BTreeMap<String, Value>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct GpsCapabilities {
pub protocol: String,
pub constellations: Vec<String>,
pub max_update_hz: f32,
pub supports_rtk: bool,
pub supports_dual_band: bool,
pub supports_heading: bool,
}
#[derive(Debug, Clone, PartialEq)]
pub struct GpsFix {
pub timestamp_ns: i64,
pub latitude_deg: f64,
pub longitude_deg: f64,
pub altitude_msl_m: f32,
pub fix_type: u8,
pub satellites_used: u8,
pub hdop: f32,
pub vdop: f32,
pub horizontal_accuracy_m: Option<f32>,
pub vertical_accuracy_m: Option<f32>,
pub speed_mps: Option<f32>,
pub course_deg: Option<f32>,
pub heading_deg: Option<f32>,
pub metadata: BTreeMap<String, Value>,
}
#[async_trait]
pub trait GpsDriver: Send + Sync {
type Session: Send + Sync;
async fn discover(&self) -> DriverResult<Vec<GpsCandidate>>;
async fn open(
&self,
candidate: &GpsCandidate,
config: &BTreeMap<String, Value>,
) -> DriverResult<Self::Session>;
async fn close(&self, session: Self::Session) -> DriverResult<()>;
fn capabilities(&self, session: &Self::Session) -> GpsCapabilities;
async fn fix_iterator(&self, session: &Self::Session) -> DriverResult<SampleStream<GpsFix>>;
async fn inject_rtcm(&self, session: &Self::Session, payload: &[u8]) -> DriverResult<()>;
}