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
impl EspNowConfig
Sourcepub fn with_channel(self, channel: u8) -> Self
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.
Sourcepub fn with_phy_rate(self, phy_rate: WifiPhyRate) -> Self
pub fn with_phy_rate(self, phy_rate: WifiPhyRate) -> Self
Force the ESP-NOW TX PHY rate (e.g. RateMcs0Lgi … RateMcs7Lgi, 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.
Sourcepub fn with_peer_mac(self, peer_mac: [u8; 6]) -> Self
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.
Sourcepub fn phy_rate(&self) -> &WifiPhyRate
pub fn phy_rate(&self) -> &WifiPhyRate
Configured PHY rate.
Sourcepub fn peer_mac(&self) -> Option<[u8; 6]>
pub fn peer_mac(&self) -> Option<[u8; 6]>
Configured peer MAC for manual pairing, or None for automatic
magic-prefix pairing.
Sourcepub fn with_ht40(self, secondary: SecondaryChannel) -> Self
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.
Sourcepub fn secondary_channel(&self) -> Option<SecondaryChannel>
pub fn secondary_channel(&self) -> Option<SecondaryChannel>
Configured HT40 secondary channel, or None for HT20.
Sourcepub fn force_phy(&self) -> bool
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).