summaryrefslogtreecommitdiff
path: root/src/devices
diff options
context:
space:
mode:
authorYuval Adam <_@yuv.al>2021-04-16 17:43:32 +0300
committerYuval Adam <_@yuv.al>2021-04-17 10:33:57 +0300
commitcc3a300afcba8fffaee5feb5f56792cfd697bf28 (patch)
treee73c759cc54ba3f59dcd5f765f03cb0f2163d5c6 /src/devices
parent01824ebaa3096d40a962b921ed239241f92e1076 (diff)
Dynamic dispatch of tuner
Diffstat (limited to 'src/devices')
-rw-r--r--src/devices/fc0013.rs22
-rw-r--r--src/devices/r820t.rs4
2 files changed, 16 insertions, 10 deletions
diff --git a/src/devices/fc0013.rs b/src/devices/fc0013.rs
index 7c64758..9eb03f4 100644
--- a/src/devices/fc0013.rs
+++ b/src/devices/fc0013.rs
@@ -1,27 +1,31 @@
use super::{Tuner, TunerInfo};
+use usb::RtlSdrDeviceHandle;
-#[allow(dead_code)]
-pub struct FC0013 {
+pub struct FC0013<'a> {
pub device: TunerInfo,
+ pub handle: &'a RtlSdrDeviceHandle,
}
-#[allow(dead_code)]
+pub const TUNER_ID: &str = "fc0013";
+
pub const TUNER_INFO: TunerInfo = TunerInfo {
- id: "fc0013",
+ id: TUNER_ID,
name: "Fitipower FC0013",
i2c_addr: 0xc6,
check_addr: 0x00,
check_val: 0xa3,
};
-#[allow(dead_code)]
-impl FC0013 {
- pub fn new() -> FC0013 {
- FC0013 { device: TUNER_INFO }
+impl<'a> FC0013<'a> {
+ pub fn new(handle: &'a RtlSdrDeviceHandle) -> FC0013<'a> {
+ FC0013 {
+ device: TUNER_INFO,
+ handle: handle,
+ }
}
}
-impl Tuner for FC0013 {
+impl<'a> Tuner for FC0013<'a> {
fn init(&self) {
println!("Init {}", self.device.name);
}
diff --git a/src/devices/r820t.rs b/src/devices/r820t.rs
index ad4720d..ec0f173 100644
--- a/src/devices/r820t.rs
+++ b/src/devices/r820t.rs
@@ -8,8 +8,10 @@ pub struct R820T<'a> {
pub handle: &'a RtlSdrDeviceHandle,
}
+pub const TUNER_ID: &str = "r820t";
+
pub const TUNER_INFO: TunerInfo = TunerInfo {
- id: "r820t",
+ id: TUNER_ID,
name: "Rafael Micro R820T",
i2c_addr: 0x34,
check_addr: 0x00,