Struct RadioConfig

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

An object to configure the radio.

This struct follows a builder pattern. Since all fields are private, users should start with the RadioConfig::default constructor, then mutate the object accordingly.

use rf24::radio::RadioConfig;

let mut config = RadioConfig::default();
config = config.with_channel(42);

Implementations§

Source§

impl RadioConfig

Source

pub const fn crc_length(&self) -> CrcLength

Returns the value set by RadioConfig::with_crc_length().

Source

pub fn with_crc_length(self, length: CrcLength) -> Self

The Cyclical Redundancy Checksum (CRC) length.

See EsbCrcLength::set_crc_length().

Source

pub const fn data_rate(&self) -> DataRate

Returns the value set by RadioConfig::with_data_rate().

Source

pub fn with_data_rate(self, data_rate: DataRate) -> Self

The Data Rate (over the air).

See EsbDataRate::set_data_rate().

Source

pub const fn pa_level(&self) -> PaLevel

Returns the value set by RadioConfig::with_pa_level().

Source

pub fn with_pa_level(self, level: PaLevel) -> Self

The Power Amplitude (PA) level.

See EsbPaLevel::set_pa_level().

Source

pub const fn lna_enable(&self) -> bool

Returns the value set by RadioConfig::with_lna_enable().

Source

pub fn with_lna_enable(self, enable: bool) -> Self

Enable or disable the chip’s Low Noise Amplifier (LNA) feature.

This value may not be respected depending on the radio module used. Consult the radio’s manufacturer for accurate details.

Source

pub const fn address_length(&self) -> u8

Returns the value set by RadioConfig::with_address_length().

Source

pub fn with_address_length(self, value: u8) -> Self

The address length.

This value is clamped to range [2, 5].

Source

pub const fn channel(&self) -> u8

Returns the value set by RadioConfig::with_channel().

Source

pub fn with_channel(self, value: u8) -> Self

Set the channel (over the air frequency).

This value is clamped to range [0, 125]. The radio’s frequency can be determined by the following equation:

frequency (in Hz) = channel + 2400
Source

pub const fn auto_retry_delay(&self) -> u8

The auto-retry feature’s delay (set via RadioConfig::with_auto_retries())

Source

pub const fn auto_retry_count(&self) -> u8

The auto-retry feature’s count (set via RadioConfig::with_auto_retries())

Source

pub fn with_auto_retries(self, delay: u8, count: u8) -> Self

Set the auto-retry feature’s delay and count parameters.

See EsbAutoAck::set_auto_retries().

Source

pub const fn rx_dr(&self) -> bool

Get the value set by RadioConfig::rx_dr().

Source

pub fn with_rx_dr(self, enable: bool) -> Self

Enable or disable the “RX Data Ready” event triggering the radio’s IRQ.

See StatusFlags::rx_dr().

Source

pub const fn tx_ds(&self) -> bool

Get the value set by RadioConfig::tx_ds().

Source

pub fn with_tx_ds(self, enable: bool) -> Self

Enable or disable the “TX Data Sent” event triggering the radio’s IRQ.

See StatusFlags::tx_ds().

Source

pub const fn tx_df(&self) -> bool

Get the value set by RadioConfig::tx_df().

Source

pub fn with_tx_df(self, enable: bool) -> Self

Enable or disable the “TX Data Failed” event triggering the radio’s IRQ.

See StatusFlags::tx_df().

Source

pub const fn ask_no_ack(&self) -> bool

Return the value set by RadioConfig::with_ask_no_ack().

Source

pub fn with_ask_no_ack(self, enable: bool) -> Self

Allow disabling auto-ack per payload.

See ask_no_ack parameter for EsbRadio::send() and EsbRadio::write().

Source

pub const fn dynamic_payloads(&self) -> bool

Return the value set by RadioConfig::with_dynamic_payloads().

This feature is enabled automatically when enabling ACK payloads via RadioConfig::with_ack_payloads().

Source

pub fn with_dynamic_payloads(self, enable: bool) -> Self

Enable or disable dynamically sized payloads.

Enabling this feature nullifies the utility of RadioConfig::payload_length().

Source

pub const fn auto_ack(&self) -> u8

Return the value set by RadioConfig::with_auto_ack().

Source

pub fn with_auto_ack(self, enable: u8) -> Self

Enable or disable auto-ACK feature.

The given value (in binary form) is used to control the auto-ack feature for each pipe. Bit 0 controls the feature for pipe 0. Bit 1 controls the feature for pipe 1. And so on.

To enable the feature for pipes 0, 1 and 4:

use rf24::radio::RadioConfig;

let config = RadioConfig::default().with_auto_ack(0b010011);

If enabling the feature for any pipe other than 0, then the pipe 0 should also have the feature enabled because pipe 0 is used to transmit automatic ACK packets in RX mode.

Source

pub const fn ack_payloads(&self) -> bool

Return the value set by RadioConfig::with_ack_payloads().

Source

pub fn with_ack_payloads(self, enable: bool) -> Self

Enable or disable custom ACK payloads for auto-ACK packets.

ACK payloads require the RadioConfig::auto_ack and RadioConfig::dynamic_payloads to be enabled. If ACK payloads are enabled, then this function also enables those features (for all pipes).

Source

pub const fn payload_length(&self) -> u8

Return the value set by RadioConfig::with_payload_length().

The hardware’s maximum payload length is enforced by the hardware specific implementations of EsbPayloadLength::set_payload_length().

Source

pub fn with_payload_length(self, value: u8) -> Self

The payload length for statically sized payloads.

See EsbPayloadLength::set_payload_length().

Source

pub fn close_rx_pipe(self, pipe: u8) -> Self

Source

pub fn is_rx_pipe_enabled(&self, pipe: u8) -> bool

Is a specified RX pipe open (true) or closed (false)?

The value returned here is controlled by RadioConfig::with_rx_address() (to open a pipe) and RadioConfig::close_rx_pipe().

Source

pub fn rx_address(&self, pipe: u8, address: &mut [u8])

Get the address for a specified pipe set by RadioConfig::with_rx_address()

Source

pub fn with_rx_address(self, pipe: u8, address: &[u8]) -> Self

Set the address of a specified RX pipe for receiving data.

This does nothing if the given pipe is greater than 8. For pipes 2 - 5, the 4 LSBytes are used from address set to pipe 1 with the MSByte from the given address.

See also RadioConfig::with_tx_address().

Source

pub fn tx_address(&self, address: &mut [u8])

Get the address set by RadioConfig::with_tx_address()

Source

pub fn with_tx_address(self, address: &[u8]) -> Self

Set the TX address.

Only pipe 0 can be used for TX operations (including auto-ACK packets during RX operations).

Trait Implementations§

Source§

impl Clone for RadioConfig

Source§

fn clone(&self) -> RadioConfig

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 Debug for RadioConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for RadioConfig

Source§

fn default() -> Self

Instantiate a RadioConfig object with library defaults.

§Default RX pipes’ configuration
pipe numberstateaddress
01closed[0xE7; 5]
1open[0xC2; 5]
22closed0xC3
32closed0xC4
42closed0xC5
52closed0xC6

  1. The RX address default value is the same as pipe 0 default TX address. 

  2. Remember, pipes 2 - 5 share the same 4 LSBytes as the address on pipe 1. 

Source§

impl Copy for RadioConfig

Auto Trait Implementations§

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, 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.