remote_id/data/
system.rs

1use chrono::{DateTime, Utc};
2
3pub const MESSAGE_TYPE: u8 = 4;
4
5#[derive(Debug, Clone, PartialEq)]
6pub struct System {
7    pub classification_type: ClassificationType,
8    pub operator_location_type: OperatorLocationType,
9    pub operator_latidute: f32,
10    pub operator_longitude: f32,
11    pub area_count: u16,
12    pub area_radius: f32,
13    pub area_ceiling: f32,
14    pub area_floor: f32,
15    pub ua_classification: UaClassification,
16    pub operator_altitude: f32,
17    pub timestamp: DateTime<Utc>,
18}
19
20#[derive(Debug, Copy, Clone, PartialEq)]
21pub enum ClassificationType {
22    Undeclared = 0,
23    EuropeanUnion = 1,
24}
25
26impl From<u8> for ClassificationType {
27    fn from(value: u8) -> Self {
28        match value {
29            0 => ClassificationType::Undeclared,
30            1 => ClassificationType::EuropeanUnion,
31
32            // reserved classifications
33            2.. => ClassificationType::Undeclared,
34        }
35    }
36}
37
38#[derive(Debug, Copy, Clone, PartialEq)]
39pub enum OperatorLocationType {
40    TakeOff = 0,
41    Dynamic = 1,
42    Fixed = 2,
43}
44
45impl From<u8> for OperatorLocationType {
46    fn from(value: u8) -> Self {
47        match value {
48            0 => OperatorLocationType::TakeOff,
49            1 => OperatorLocationType::Dynamic,
50            2 => OperatorLocationType::Fixed,
51
52            3.. => OperatorLocationType::TakeOff,
53        }
54    }
55}
56
57#[derive(Debug, Clone, PartialEq)]
58pub struct UaClassification {
59    pub category: UaCategory,
60    pub class: UaClass,
61}
62
63impl UaClassification {
64    pub const fn undefined() -> Self {
65        Self {
66            category: UaCategory::Undefined,
67            class: UaClass::Undefined,
68        }
69    }
70}
71
72#[derive(Debug, Copy, Clone, PartialEq)]
73pub enum UaCategory {
74    Undefined,
75    Open,
76    Specific,
77    Certified,
78}
79
80impl From<u8> for UaCategory {
81    fn from(value: u8) -> Self {
82        match value {
83            0 => UaCategory::Undefined,
84            1 => UaCategory::Open,
85            2 => UaCategory::Specific,
86            3 => UaCategory::Certified,
87
88            _ => UaCategory::Undefined,
89        }
90    }
91}
92
93impl From<UaCategory> for u8 {
94    fn from(val: UaCategory) -> Self {
95        match val {
96            UaCategory::Undefined => 0,
97            UaCategory::Open => 1,
98            UaCategory::Specific => 2,
99            UaCategory::Certified => 3,
100        }
101    }
102}
103
104#[derive(Debug, Copy, Clone, PartialEq)]
105pub enum UaClass {
106    Undefined,
107    Class0,
108    Class1,
109    Class2,
110    Class3,
111    Class4,
112    Class5,
113    Class6,
114}
115
116impl From<u8> for UaClass {
117    fn from(value: u8) -> Self {
118        match value {
119            0 => UaClass::Undefined,
120            1 => UaClass::Class0,
121            2 => UaClass::Class1,
122            3 => UaClass::Class2,
123            4 => UaClass::Class3,
124            5 => UaClass::Class4,
125            6 => UaClass::Class5,
126            7 => UaClass::Class6,
127
128            _ => UaClass::Undefined,
129        }
130    }
131}
132
133impl From<UaClass> for u8 {
134    fn from(val: UaClass) -> Self {
135        match val {
136            UaClass::Undefined => 0,
137            UaClass::Class0 => 1,
138            UaClass::Class1 => 2,
139            UaClass::Class2 => 3,
140            UaClass::Class3 => 4,
141            UaClass::Class4 => 5,
142            UaClass::Class5 => 6,
143            UaClass::Class6 => 7,
144        }
145    }
146}