Skip to main content

EspNowConfig

Struct EspNowConfig 

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

Configuration for ESP-NOW traffic generation.

Used by both Central and Peripheral nodes when operating in ESP-NOW mode. Construct with EspNowConfig::default() then chain with_channel / with_phy_rate to override defaults — both nodes must agree on the channel for ESP-NOW frames to be received.

Implementations§

Source§

impl EspNowConfig

Source

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

Override the 2.4 GHz channel (1–14). Both central and peripheral must be configured with the same channel.

Source

pub fn with_phy_rate(self, phy_rate: WifiPhyRate) -> Self

Force the ESP-NOW TX PHY rate (e.g. RateMcs0LgiRateMcs7Lgi, or a legacy rate). Applied per-peer via esp_now_set_peer_rate_config, which brings the radio up in started STA mode. Combine with with_ht40 for a 40 MHz bandwidth; without it the rate is sent at HT20 (for MCS rates) or the matching legacy mode. Without calling this (or with_ht40) the PHY is left at the driver default.

Source

pub fn with_peer_mac(self, peer_mac: [u8; 6]) -> Self

Pre-configure the peer’s MAC address for manual pairing.

Switches off automatic magic-prefix pairing: no magic is sent, and each node accepts frames only from the configured peer MAC (source-MAC filtering applies from the first frame). The central must be given the peripheral’s MAC and vice-versa, and both nodes must use the same pairing mode for frames to parse.

Source

pub fn channel(&self) -> u8

Configured 2.4 GHz channel.

Source

pub fn phy_rate(&self) -> &WifiPhyRate

Configured PHY rate.

Source

pub fn peer_mac(&self) -> Option<[u8; 6]>

Configured peer MAC for manual pairing, or None for automatic magic-prefix pairing.

Source

pub fn with_ht40(self, secondary: SecondaryChannel) -> Self

Run the ESP-NOW TX at HT40 (40 MHz) with secondary as the HT40 secondary channel, using the configured with_phy_rate (default RateMcs0Lgi). Implies force_phy. Without this the PHY is HT20 (if a rate is forced) or the driver default. Verify on-air (CSI bandwidth field) that HT40 actually engaged.

Source

pub fn secondary_channel(&self) -> Option<SecondaryChannel>

Configured HT40 secondary channel, or None for HT20.

Source

pub fn force_phy(&self) -> bool

Whether the ESP-NOW TX PHY (rate + bandwidth) is forced via a per-peer rate config (set by with_phy_rate / with_ht40).

Trait Implementations§

Source§

impl Default for EspNowConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> 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> Same for T

Source§

type Output = T

Should always be Self
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.