#[cfg(feature = "serde")]
use super::SerializeUbxPacketFields;
#[cfg(feature = "serde")]
use crate::serde::ser::SerializeMap;
use crate::{error::ParserError, UbxPacketMeta};
use ublox_derive::{ubx_extend, ubx_packet_recv};
#[ubx_packet_recv]
#[ubx(class = 0x02, id = 0x34, fixed_payload_len = 12)]
struct RxmCor {
version: u8,
#[ubx(map_type = f32, scale = 0.125)]
ebno: u8,
reserved0: [u8; 2],
#[ubx(map_type = RxmCorStatusInfo)]
status_info: u32,
msg_type: u16,
msg_sub_type: u16,
}
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
pub struct RxmCorStatusInfo {
pub protocol: CorrectionProtocol,
pub err_status: CorrectionErrStatus,
pub msg_used: CorrectionMsgUsed,
pub correction_id: u16,
pub msg_type_valid: bool,
pub msg_sub_type_valid: bool,
pub msg_input_handle: MsgInputHandle,
pub msg_encrypted: MsgEncrypted,
pub msg_decrypted: MsgDecrypted,
}
impl From<u32> for RxmCorStatusInfo {
fn from(value: u32) -> Self {
Self {
protocol: CorrectionProtocol::from((value & 0x1f) as u8),
err_status: CorrectionErrStatus::from(((value >> 5) & 0x03) as u8),
msg_used: CorrectionMsgUsed::from(((value >> 7) & 0x03) as u8),
correction_id: ((value >> 9) & 0xffff) as u16,
msg_type_valid: (value & (1 << 25)) != 0,
msg_sub_type_valid: (value & (1 << 26)) != 0,
msg_input_handle: MsgInputHandle::from(((value >> 27) & 0x01) as u8),
msg_encrypted: MsgEncrypted::from(((value >> 28) & 0x03) as u8),
msg_decrypted: MsgDecrypted::from(((value >> 30) & 0x03) as u8),
}
}
}
#[ubx_extend]
#[ubx(from, rest_reserved)]
#[repr(u8)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum CorrectionProtocol {
Unknown = 0,
Rtcm3 = 1,
Spartn = 2,
UbxRxmPmp = 29,
UbxRxmQzssl6 = 30,
}
#[ubx_extend]
#[ubx(from, rest_reserved)]
#[repr(u8)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum CorrectionErrStatus {
Unknown = 0,
ErrorFree = 1,
Erroneous = 2,
}
#[ubx_extend]
#[ubx(from, rest_reserved)]
#[repr(u8)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum CorrectionMsgUsed {
Unknown = 0,
NotUsed = 1,
Used = 2,
}
#[ubx_extend]
#[ubx(from, rest_reserved)]
#[repr(u8)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum MsgInputHandle {
NoSupport = 0,
Supported = 1,
}
#[ubx_extend]
#[ubx(from, rest_reserved)]
#[repr(u8)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum MsgEncrypted {
Unknown = 0,
NotEncrypted = 1,
Encrypted = 2,
}
#[ubx_extend]
#[ubx(from, rest_reserved)]
#[repr(u8)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum MsgDecrypted {
Unknown = 0,
NotDecrypted = 1,
Decrypted = 2,
}