Powerful SDR toolkit designed in pure Rust for HackRF One
Open usb device as you like with nusb crate
use nusb::{list_devices, MaybeFuture};
use dverf::{Device, VENDOR_ID};
fn open() -> anyhow::Result<Device> {
let device_info = list_devices()
.wait()?
.find(|dev| dev.vendor_id() == VENDOR_ID && dev.product_id() == 0x6089)
.context("device not connected")?;
let device = device_info.open().wait().context("failed to open device")?;
let interface = device.claim_interface(0).wait()?;
let ep = Endpoints::open(interface, 512 * 512, 4)?;
let device = Device::new(ep);
Ok(device)
}
Identical interface to libhackrf
device.set_freq(2412, 0).await?;
device.set_sample_rate(200_000_000, 10).await?;
device.set_baseband_filter_bandwidth(15_000_000).await?;
device.set_lna_gain(40).await?;
device.set_vga_gain(8).await?;
device.set_transceiver_mode(TransceiverMode::Receive).await?;
/// Put the device into receive mode
device.set_transceiver_mode(TransceiverMode::Receive).await?;
/// Allocate buffer
let mut buf = vec![Sample::default(), 512 * 256];
/// Get rx-half and receive requested amount of samples into the buffer
device.rx().read_exact(&mut buf)?;
/// Put the device into transmit mode
device.set_transceiver_mode(TransceiverMode::Transmit).await?;
// Get tx-half
let tx = device.tx();
// Feed chunks
for chunk in samples_iter {
tx.write_all(chunk).await?;
}
// Flush when you finish transmitting
tx.flush().await?;
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.