HackRf

Struct HackRf 

Source
pub struct HackRf { /* private fields */ }
Expand description

A HackRf device.

Implementations§

Source§

impl HackRf

Source

pub fn open() -> Result<HackRf>

Connects to a HackRF device.

Source

pub fn device(&self) -> *mut HackrfDevice

Gets the internial representation of the HackRF device. This can be used with unsafe FFI functions if needed.

Source

pub fn get_serial_number(&self) -> Result<SerialNumber>

Gets the device serial number.

Source

pub fn get_device_type(&self) -> Result<DeviceType>

Read hackrf_board_id from a device and convert it to a DeviceType.

Source

pub fn version(&self) -> String

Read HackRF firmware version as a string.

Source

pub fn set_freq(&self, freq: u64) -> Result<()>

Sets the center frequency in Hz.

Source

pub fn set_sample_rate(&self, sample_rate: u32) -> Result<()>

Sets the sample rate in Hz.

Source

pub fn set_amp_enable(&self, enable: bool) -> Result<()>

Sets the state of the externial amplifier.

Source

pub fn set_lna_gain(&self, gain: u32) -> Result<()>

Low noise amplifier gain. Between 0d and 40d in steps of 8dB.

Source

pub fn set_rxvga_gain(&self, gain: u32) -> Result<()>

Variable gain amplifier. Range 0-62 (step 2dB).

Source

pub fn set_txvga_gain(&self, gain: u32) -> Result<()>

Transmit variable gain amplifier. Range 0-47 (step 1dB).

Source

pub fn set_baseband_filter_bandwidth(&self, bandwidth_hz: u32) -> Result<()>

Source

pub fn start_tx( &self, callback: fn(hack_rf: &HackRf, samples: &mut [Complex<i8>], user: &dyn Any), user_data: impl Any, ) -> Result<()>

Starts transmitting samples from the device.

Source

pub fn stop_tx(&self) -> Result<()>

Stops the current transmit operation.

Source

pub fn start_rx( &self, callback: fn(hack_rf: &HackRf, samples: &[Complex<i8>], user: &dyn Any), user_data: impl Any + Sync, ) -> Result<()>

Starts receiving samples from the device.

Source

pub fn stop_rx(&self) -> Result<()>

Stops the current receive operation.

Source

pub fn is_streaming(&self) -> bool

Returns true if the device is currently streaming samples (transmitting or receiving).

Trait Implementations§

Source§

impl Clone for HackRf

Source§

fn clone(&self) -> HackRf

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Drop for HackRf

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl Freeze for HackRf

§

impl RefUnwindSafe for HackRf

§

impl Send for HackRf

§

impl Sync for HackRf

§

impl Unpin for HackRf

§

impl UnwindSafe for HackRf

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.