Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rust-native HackRf Support #10

Merged
merged 16 commits into from
Oct 10, 2024
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "crates/rtl-sdr-rs"]
path = crates/rtl-sdr-rs
url = https://github.com/bastibl/rtl-sdr-rs.git
[submodule "crates/seify-hackrfone"]
path = crates/seify-hackrfone
url = https://github.com/MerchGuardian/seify-hackrfone.git
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ license = "Apache-2.0"
repository = "https://github.com/FutureSDR/seify"

[features]
default = ["soapy"]
# default = ["soapy"]
default = ["hackrfone"]
rtlsdr = ["dep:seify-rtlsdr"]
hackrfone = ["dep:seify-hackrfone"]
aaronia = ["dep:aaronia-rtsa"]
aaronia_http = ["dep:ureq"]
soapy = ["dep:soapysdr"]
Expand All @@ -32,6 +34,7 @@ thiserror = "1.0"
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
once_cell = "1.19"
seify-rtlsdr = { path = "crates/rtl-sdr-rs", version = "0.0.3", optional = true }
seify-hackrfone = { path = "crates/seify-hackrfone", version = "0.1.0", optional = true }
soapysdr = { version = "0.4", optional = true }
ureq = { version = "2.9", features = ["json"], optional = true }

Expand Down
1 change: 1 addition & 0 deletions crates/seify-hackrfone
Submodule seify-hackrfone added at 9f08ce
5 changes: 4 additions & 1 deletion examples/rx_generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
// Get typed reference to device impl
// let r: &seify::impls::RtlSdr = dev.impl_ref().unwrap();

dev.enable_agc(Rx, 0, true)?;
// HackRf doesnt support agc
if dev.supports_agc(Rx, 0)? {
dev.enable_agc(Rx, 0, true)?;
}
dev.set_frequency(Rx, 0, 927e6)?;
dev.set_sample_rate(Rx, 0, 3.2e6)?;

Expand Down
19 changes: 19 additions & 0 deletions src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,25 @@ impl Device<GenericDevice> {
}
}
}
#[cfg(all(feature = "hackrfone", not(target_arch = "wasm32")))]
{
if driver.is_none() || matches!(driver, Some(Driver::HackRf)) {
match crate::impls::HackRfOne::open(&args) {
Ok(d) => {
return Ok(Device {
dev: Arc::new(DeviceWrapper { dev: d }),
})
}
Err(Error::NotFound) => {
if driver.is_some() {
return Err(Error::NotFound);
}
}
Err(e) => return Err(e),
}
}
}

Err(Error::NotFound)
}
}
Expand Down
Loading