diff --git a/config.example.toml b/config.example.toml index e90621d7851eefb5993d738f4c1ab4878b76544a..a662c67e7dc1a891d29ecfd302904aea6ab5ceb2 100644 --- a/config.example.toml +++ b/config.example.toml @@ -1,6 +1,7 @@ # rtl_fm parameters frequency = 430_500_000 # center frequency, Hz device_id = "0" # ID of your RTL-SDR; 0 is default +bias_t = false # gain = 30.0 # dB. Uses AGC when not specified # if set to true: diff --git a/src/config.rs b/src/config.rs index fae5464da07773a2e844fb2d5450ab5fcd22bfd9..7c4a853373366b1ca3ad7e5f68f5f5ac4b5edf95 100644 --- a/src/config.rs +++ b/src/config.rs @@ -37,6 +37,8 @@ pub struct Config { pub frequency: u32, #[serde(default = "default_device_id")] pub device_id: String, + #[serde(default)] + pub bias_t: bool, pub gain: Option<f32>, #[serde(default)] pub use_stdin: bool, diff --git a/src/decoder/mod.rs b/src/decoder/mod.rs index 3457fae0e778b1b112b960b71f046c98e56cdbc6..5f5e8588016f38c894554d48aa1d01b0386ec97b 100644 --- a/src/decoder/mod.rs +++ b/src/decoder/mod.rs @@ -27,7 +27,13 @@ pub fn decode_forever(felinet_send: mpsc::Sender<SemiPacketIn>, config: &Config, Box::new(stdin.bytes().map(|x| x.expect("Could not read from stdin"))) } else { - let rtl = RtlSdr::new(config.frequency, &config.device_id, config.gain).unwrap(); + let rtl = RtlSdr::new( + config.frequency, + &config.device_id, + config.gain, + config.bias_t, + ) + .unwrap(); Box::new(rtl) }; diff --git a/src/decoder/rtl.rs b/src/decoder/rtl.rs index 7e7bb077994ed76cf9f0dec7e43a6d572b8497c8..060cd660bd3d92ccaff98e559efea728a6b6e624 100644 --- a/src/decoder/rtl.rs +++ b/src/decoder/rtl.rs @@ -11,7 +11,12 @@ pub struct RtlSdr { } impl RtlSdr { - pub fn new(freq: u32, device_id: &str, gain: Option<f32>) -> anyhow::Result<Self> { + pub fn new( + freq: u32, + device_id: &str, + gain: Option<f32>, + bias_t: bool, + ) -> anyhow::Result<Self> { let freq = format!("{freq}"); let mut args = vec![ "rtl_fm", "-f", &freq, "-M", "raw", "-F9", "-p", "0", "-d", device_id, "-s", "48000", @@ -22,6 +27,9 @@ impl RtlSdr { gain_s.push_str(&format!("{:.2}", g)); args.push(&gain_s); } + if bias_t { + args.push("-T"); + } let mut process = Popen::create( &args, PopenConfig {