Protocol updates
This commit is contained in:
+48
-1
@@ -60,7 +60,7 @@ pub struct Capture {
|
||||
pub status: CaptureStatus,
|
||||
}
|
||||
|
||||
/// Modulation type used by protocol
|
||||
/// Modulation type used by protocol (encoding: PWM vs Manchester)
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum ModulationType {
|
||||
Unknown,
|
||||
@@ -81,6 +81,28 @@ impl std::fmt::Display for ModulationType {
|
||||
}
|
||||
}
|
||||
|
||||
/// RF modulation (carrier): AM/OOK vs FM/2FSK. From ProtoPirate SubGhzProtocolFlag_AM / _FM.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum RfModulation {
|
||||
AM,
|
||||
FM,
|
||||
/// Protocol used with both AM and FM (e.g. Kia V3/V4)
|
||||
Both,
|
||||
Unknown,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for RfModulation {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
RfModulation::AM => write!(f, "AM"),
|
||||
RfModulation::FM => write!(f, "FM"),
|
||||
RfModulation::Both => write!(f, "AM/FM"),
|
||||
RfModulation::Unknown => write!(f, "—"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Capture {
|
||||
/// Create a new capture from level+duration pairs
|
||||
pub fn from_pairs(id: u32, frequency: u32, pairs: Vec<StoredLevelDuration>) -> Self {
|
||||
@@ -177,6 +199,31 @@ impl Capture {
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the RF modulation (AM/FM) for this protocol. From ProtoPirate SubGhzProtocolFlag_AM / _FM.
|
||||
/// KAT's demodulator is AM/OOK only; FM protocols may still decode if the signal is strong.
|
||||
pub fn rf_modulation(&self) -> RfModulation {
|
||||
match self.protocol_name() {
|
||||
// FM only (ProtoPirate SubGhzProtocolFlag_FM)
|
||||
p if p.starts_with("Kia V0") => RfModulation::FM,
|
||||
p if p.starts_with("Kia V2") => RfModulation::FM,
|
||||
p if p.starts_with("Kia V5") => RfModulation::FM,
|
||||
p if p.starts_with("Kia V6") => RfModulation::FM,
|
||||
"Scher-Khan" => RfModulation::FM,
|
||||
"PSA" => RfModulation::FM,
|
||||
"Fiat V0" => RfModulation::FM,
|
||||
"Ford V0" => RfModulation::FM,
|
||||
// AM only (SubGhzProtocolFlag_AM)
|
||||
p if p.starts_with("Kia V1") => RfModulation::AM,
|
||||
"VAG" => RfModulation::AM,
|
||||
"Subaru" => RfModulation::AM,
|
||||
"Suzuki" => RfModulation::AM,
|
||||
"Star Line" => RfModulation::AM,
|
||||
// Both AM and FM (Kia V3/V4)
|
||||
p if p.starts_with("Kia V3") || p.starts_with("Kia V4") => RfModulation::Both,
|
||||
_ => RfModulation::Unknown,
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the encryption/encoding type based on the protocol
|
||||
pub fn encryption_type(&self) -> &'static str {
|
||||
match self.protocol_name() {
|
||||
|
||||
Reference in New Issue
Block a user