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
impl RadioConfig
Sourcepub const fn crc_length(&self) -> CrcLength
pub const fn crc_length(&self) -> CrcLength
Returns the value set by RadioConfig::with_crc_length()
.
Sourcepub fn with_crc_length(self, length: CrcLength) -> Self
pub fn with_crc_length(self, length: CrcLength) -> Self
The Cyclical Redundancy Checksum (CRC) length.
Sourcepub const fn data_rate(&self) -> DataRate
pub const fn data_rate(&self) -> DataRate
Returns the value set by RadioConfig::with_data_rate()
.
Sourcepub fn with_data_rate(self, data_rate: DataRate) -> Self
pub fn with_data_rate(self, data_rate: DataRate) -> Self
The Data Rate (over the air).
Sourcepub const fn pa_level(&self) -> PaLevel
pub const fn pa_level(&self) -> PaLevel
Returns the value set by RadioConfig::with_pa_level()
.
Sourcepub fn with_pa_level(self, level: PaLevel) -> Self
pub fn with_pa_level(self, level: PaLevel) -> Self
The Power Amplitude (PA) level.
Sourcepub const fn lna_enable(&self) -> bool
pub const fn lna_enable(&self) -> bool
Returns the value set by RadioConfig::with_lna_enable()
.
Sourcepub fn with_lna_enable(self, enable: bool) -> Self
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.
Sourcepub const fn address_length(&self) -> u8
pub const fn address_length(&self) -> u8
Returns the value set by RadioConfig::with_address_length()
.
Sourcepub fn with_address_length(self, value: u8) -> Self
pub fn with_address_length(self, value: u8) -> Self
The address length.
This value is clamped to range [2, 5].
Sourcepub const fn channel(&self) -> u8
pub const fn channel(&self) -> u8
Returns the value set by RadioConfig::with_channel()
.
Sourcepub fn with_channel(self, value: u8) -> Self
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
Sourcepub const fn auto_retry_delay(&self) -> u8
pub const fn auto_retry_delay(&self) -> u8
The auto-retry feature’s delay
(set via RadioConfig::with_auto_retries()
)
Sourcepub const fn auto_retry_count(&self) -> u8
pub const fn auto_retry_count(&self) -> u8
The auto-retry feature’s count
(set via RadioConfig::with_auto_retries()
)
Sourcepub fn with_auto_retries(self, delay: u8, count: u8) -> Self
pub fn with_auto_retries(self, delay: u8, count: u8) -> Self
Set the auto-retry feature’s delay
and count
parameters.
Sourcepub const fn rx_dr(&self) -> bool
pub const fn rx_dr(&self) -> bool
Get the value set by RadioConfig::rx_dr()
.
Sourcepub fn with_rx_dr(self, enable: bool) -> Self
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()
.
Sourcepub const fn tx_ds(&self) -> bool
pub const fn tx_ds(&self) -> bool
Get the value set by RadioConfig::tx_ds()
.
Sourcepub fn with_tx_ds(self, enable: bool) -> Self
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()
.
Sourcepub const fn tx_df(&self) -> bool
pub const fn tx_df(&self) -> bool
Get the value set by RadioConfig::tx_df()
.
Sourcepub fn with_tx_df(self, enable: bool) -> Self
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()
.
Sourcepub const fn ask_no_ack(&self) -> bool
pub const fn ask_no_ack(&self) -> bool
Return the value set by RadioConfig::with_ask_no_ack()
.
Sourcepub fn with_ask_no_ack(self, enable: bool) -> Self
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()
.
Sourcepub const fn dynamic_payloads(&self) -> bool
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()
.
Sourcepub fn with_dynamic_payloads(self, enable: bool) -> Self
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()
.
Sourcepub const fn auto_ack(&self) -> u8
pub const fn auto_ack(&self) -> u8
Return the value set by RadioConfig::with_auto_ack()
.
Sourcepub fn with_auto_ack(self, enable: u8) -> Self
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.
Sourcepub const fn ack_payloads(&self) -> bool
pub const fn ack_payloads(&self) -> bool
Return the value set by RadioConfig::with_ack_payloads()
.
Sourcepub fn with_ack_payloads(self, enable: bool) -> Self
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).
Sourcepub const fn payload_length(&self) -> u8
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()
.
Sourcepub fn with_payload_length(self, value: u8) -> Self
pub fn with_payload_length(self, value: u8) -> Self
The payload length for statically sized payloads.
pub fn close_rx_pipe(self, pipe: u8) -> Self
Sourcepub fn is_rx_pipe_enabled(&self, pipe: u8) -> bool
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()
.
Sourcepub fn rx_address(&self, pipe: u8, address: &mut [u8])
pub fn rx_address(&self, pipe: u8, address: &mut [u8])
Get the address for a specified pipe
set by RadioConfig::with_rx_address()
Sourcepub fn with_rx_address(self, pipe: u8, address: &[u8]) -> Self
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()
.
Sourcepub fn tx_address(&self, address: &mut [u8])
pub fn tx_address(&self, address: &mut [u8])
Get the address set by RadioConfig::with_tx_address()
Sourcepub fn with_tx_address(self, address: &[u8]) -> Self
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
impl Clone for RadioConfig
Source§fn clone(&self) -> RadioConfig
fn clone(&self) -> RadioConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for RadioConfig
impl Debug for RadioConfig
Source§impl Default for RadioConfig
impl Default for RadioConfig
Source§fn default() -> Self
fn default() -> Self
Instantiate a RadioConfig
object with library defaults.
feature | default value |
---|---|
RadioConfig::channel() | 76 |
RadioConfig::address_length() | 5 |
RadioConfig::pa_level() | PaLevel::Max |
RadioConfig::lna_enable() | true |
RadioConfig::crc_length() | CrcLength::Bit16 |
RadioConfig::data_rate() | DataRate::Mbps1 |
RadioConfig::payload_length() | 32 |
RadioConfig::dynamic_payloads() | false |
RadioConfig::auto_ack() | 0x3F (enabled for pipes 0 - 5) |
RadioConfig::ack_payloads() | false |
RadioConfig::ask_no_ack() | false |
RadioConfig::auto_retry_delay() | 5 |
RadioConfig::auto_retry_count() | 15 |
RadioConfig::tx_address() | [0xE7; 5] |
RadioConfig::rx_address() | See below table about Default RX addresses |
RadioConfig::rx_dr() | true |
RadioConfig::tx_ds() | true |
RadioConfig::tx_df() | true |