use bitflags::bitflags;
#[cfg(feature = "serde")]
use super::SerializeUbxPacketFields;
#[cfg(feature = "serde")]
use crate::serde::ser::SerializeMap;
use crate::{
error::ParserError, ubx_checksum, ubx_packets::packets::ScaleBack, MemWriter, MemWriterError,
UbxPacketCreator, UbxPacketMeta, UtcStandardIdentifier,
};
use ublox_derive::{ubx_extend, ubx_extend_bitflags, ubx_packet_recv_send};
#[ubx_packet_recv_send]
#[ubx(
class = 0x06,
id = 0x24,
fixed_payload_len = 36,
flags = "default_for_builder"
)]
struct CfgNav5 {
#[ubx(map_type = CfgNav5Params)]
mask: u16,
#[ubx(map_type = NavDynamicModel, may_fail)]
dyn_model: u8,
#[ubx(map_type = NavFixMode, may_fail)]
fix_mode: u8,
#[ubx(map_type = f64, scale = 0.01)]
fixed_alt: i32,
#[ubx(map_type = f64, scale = 0.0001)]
fixed_alt_var: u32,
min_elev_degrees: i8,
dr_limit: u8,
#[ubx(map_type = f32, scale = 0.1)]
pdop: u16,
#[ubx(map_type = f32, scale = 0.1)]
tdop: u16,
pacc: u16,
tacc: u16,
#[ubx(map_type = f32, scale = 0.01)]
static_hold_thresh: u8,
dgps_time_out: u8,
cno_thresh_num_svs: u8,
cno_thresh: u8,
reserved1: [u8; 2],
static_hold_max_dist: u16,
#[ubx(map_type = UtcStandardIdentifier, may_fail)]
utc_standard: u8,
reserved2: [u8; 5],
}
#[ubx_extend_bitflags]
#[ubx(from, into_raw, rest_reserved)]
bitflags! {
#[derive(Default, Debug, PartialEq, Eq)]
pub struct CfgNav5Params: u16 {
const DYN = 1;
const MIN_EL = 2;
const POS_FIX_MODE = 4;
const DR_LIM = 8;
const POS_MASK_APPLY = 0x10;
const TIME_MASK = 0x20;
const STATIC_HOLD_MASK = 0x40;
const DGPS_MASK = 0x80;
const CNO_THRESHOLD = 0x100;
const UTC = 0x400;
}
}
#[non_exhaustive]
#[derive(Default)]
#[ubx_extend]
#[ubx(from_unchecked, into_raw, rest_error)]
#[repr(u8)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum NavDynamicModel {
#[default]
Portable = 0,
Stationary = 2,
Pedestrian = 3,
Automotive = 4,
Sea = 5,
AirborneWithLess1gAcceleration = 6,
AirborneWithLess2gAcceleration = 7,
AirborneWithLess4gAcceleration = 8,
#[cfg(any(
feature = "ubx_proto27",
feature = "ubx_proto31",
feature = "ubx_proto33",
))]
WristWornWatch = 9,
#[cfg(any(feature = "ubx_proto31", feature = "ubx_proto33"))]
Bike = 10,
#[cfg(feature = "ubx_proto33")]
Mower = 11,
#[cfg(feature = "ubx_proto33")]
EScooter = 12,
#[cfg(feature = "ubx_proto33")]
Rail = 13,
}
#[derive(Default)] #[ubx_extend]
#[ubx(from_unchecked, into_raw, rest_error)]
#[repr(u8)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum NavFixMode {
Only2D = 1,
Only3D = 2,
#[default]
Auto2D3D = 3,
}