use core::time::Duration;
pub const MESSAGE_TYPE: u8 = 1;
#[allow(non_camel_case_types)]
#[derive(Debug, Copy, Clone, PartialEq)]
pub enum VerticalAccuracy {
Unknown,
LessThan_150_m,
LessThan_45_m,
LessThan_25_m,
LessThan_10_m,
LessThan_3_m,
LessThan_1_m,
}
impl From<u8> for VerticalAccuracy {
fn from(value: u8) -> Self {
match value {
0 => Self::Unknown,
1 => Self::LessThan_150_m,
2 => Self::LessThan_45_m,
3 => Self::LessThan_25_m,
4 => Self::LessThan_10_m,
5 => Self::LessThan_3_m,
6 => Self::LessThan_1_m,
7..=u8::MAX => Self::Unknown,
}
}
}
impl From<VerticalAccuracy> for u8 {
fn from(val: VerticalAccuracy) -> Self {
match val {
VerticalAccuracy::Unknown => 0,
VerticalAccuracy::LessThan_150_m => 1,
VerticalAccuracy::LessThan_45_m => 2,
VerticalAccuracy::LessThan_25_m => 3,
VerticalAccuracy::LessThan_10_m => 4,
VerticalAccuracy::LessThan_3_m => 5,
VerticalAccuracy::LessThan_1_m => 6,
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Copy, Clone, PartialEq)]
pub enum HorizontalAccuracy {
Unknown,
LessThan_10_NM,
LessThan_4_NM,
LessThan_2_NM,
LessThan_1_NM,
LessThan_half_NM,
LessThan_third_NM,
LessThan_tenth_NM,
LessThan_twentieth_NM,
LessThan_30_m,
LessThan_10_m,
LessThan_3_m,
LessThan_1_m,
}
impl From<u8> for HorizontalAccuracy {
fn from(value: u8) -> Self {
match value {
0 => Self::Unknown,
1 => Self::LessThan_10_NM,
2 => Self::LessThan_4_NM,
3 => Self::LessThan_2_NM,
4 => Self::LessThan_1_NM,
5 => Self::LessThan_half_NM,
6 => Self::LessThan_third_NM,
7 => Self::LessThan_tenth_NM,
8 => Self::LessThan_twentieth_NM,
9 => Self::LessThan_30_m,
10 => Self::LessThan_10_m,
11 => Self::LessThan_3_m,
12 => Self::LessThan_1_m,
13..=u8::MAX => Self::Unknown,
}
}
}
impl From<HorizontalAccuracy> for u8 {
fn from(val: HorizontalAccuracy) -> Self {
match val {
HorizontalAccuracy::Unknown => 0,
HorizontalAccuracy::LessThan_10_NM => 1,
HorizontalAccuracy::LessThan_4_NM => 2,
HorizontalAccuracy::LessThan_2_NM => 3,
HorizontalAccuracy::LessThan_1_NM => 4,
HorizontalAccuracy::LessThan_half_NM => 5,
HorizontalAccuracy::LessThan_third_NM => 6,
HorizontalAccuracy::LessThan_tenth_NM => 7,
HorizontalAccuracy::LessThan_twentieth_NM => 8,
HorizontalAccuracy::LessThan_30_m => 9,
HorizontalAccuracy::LessThan_10_m => 10,
HorizontalAccuracy::LessThan_3_m => 11,
HorizontalAccuracy::LessThan_1_m => 12,
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Copy, Clone, PartialEq)]
pub enum SpeedAccuracy {
Unknown,
LessThan_10_mps,
LessThan_3_mps,
LessThan_1_mps,
LessThan_third_mps,
}
impl From<u8> for SpeedAccuracy {
fn from(value: u8) -> Self {
match value {
0 => Self::Unknown,
1 => Self::LessThan_10_mps,
2 => Self::LessThan_3_mps,
3 => Self::LessThan_1_mps,
4 => Self::LessThan_third_mps,
5..=u8::MAX => Self::Unknown,
}
}
}
impl From<SpeedAccuracy> for u8 {
fn from(val: SpeedAccuracy) -> Self {
match val {
SpeedAccuracy::Unknown => 0,
SpeedAccuracy::LessThan_10_mps => 1,
SpeedAccuracy::LessThan_3_mps => 2,
SpeedAccuracy::LessThan_1_mps => 3,
SpeedAccuracy::LessThan_third_mps => 4,
}
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct Location {
pub operational_status: OperationalStatus,
pub height_type: HeightType,
pub speed: f32,
pub vertical_speed: f32,
pub pressure_altitude: f32,
pub geodetic_altitude: f32,
pub track_direction: u16,
pub horizontal_accuracy: HorizontalAccuracy,
pub vertical_accuracy: VerticalAccuracy,
pub latidute: f32,
pub longitude: f32,
pub height: f32,
pub baro_altitude_accuracy: VerticalAccuracy,
pub speed_accuracy: SpeedAccuracy,
pub timestamp: f32,
pub timestamp_accuracy: Option<Duration>,
}
#[derive(Debug, Copy, Clone, PartialEq)]
pub enum OperationalStatus {
Undeclared,
Ground,
Airborne,
Emergency,
RemoteIdSystemFailure,
}
impl From<u8> for OperationalStatus {
fn from(value: u8) -> Self {
match value {
1 => OperationalStatus::Ground,
2 => OperationalStatus::Airborne,
3 => OperationalStatus::Emergency,
4 => OperationalStatus::RemoteIdSystemFailure,
_ => OperationalStatus::Undeclared,
}
}
}
impl From<OperationalStatus> for u8 {
fn from(val: OperationalStatus) -> Self {
match val {
OperationalStatus::Ground => 1,
OperationalStatus::Airborne => 2,
OperationalStatus::Emergency => 3,
OperationalStatus::RemoteIdSystemFailure => 4,
OperationalStatus::Undeclared => 0,
}
}
}
#[derive(Debug, Copy, Clone, PartialEq)]
pub enum HeightType {
AboveTakeoff,
AboveGroundLevel,
}
impl From<u8> for HeightType {
fn from(value: u8) -> Self {
match value {
0 => HeightType::AboveTakeoff,
1 => HeightType::AboveGroundLevel,
_ => HeightType::AboveTakeoff,
}
}
}
impl From<HeightType> for u8 {
fn from(val: HeightType) -> Self {
match val {
HeightType::AboveTakeoff => 0,
HeightType::AboveGroundLevel => 1,
}
}
}