pub struct EspNowManager { /* private fields */ }esp-now and unstable only.Expand description
Manages the EspNow instance lifecycle while ensuring it remains active.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Implementations§
Source§impl EspNowManager
impl EspNowManager
Sourcepub fn set_channel(&self, channel: u8) -> Result<(), EspNowError>
pub fn set_channel(&self, channel: u8) -> Result<(), EspNowError>
Set primary Wi-Fi channel. When using ESP-NOW with an access point or station, the device cannot switch channels after connecting to Wi-Fi. It can only transmit and receive data on the current Wi-Fi channel.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub fn version(&self) -> Result<u32, EspNowError>
pub fn version(&self) -> Result<u32, EspNowError>
Get the version of ESP-NOW.
ESP-NOW supports two versions: v1.0 and v2.0. v1.0 and v2.0 are capable of talking to each
other, but v1.0 devices may truncate or discard v2.0 messages that exceed the v1.0 maximum
data length (ESP_NOW_MAX_DATA_LEN_V1).
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub fn add_peer(&self, peer: PeerInfo) -> Result<(), EspNowError>
pub fn add_peer(&self, peer: PeerInfo) -> Result<(), EspNowError>
Add a peer to the list of known peers.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub fn set_csi(
&mut self,
csi: CsiConfig,
cb: impl FnMut(WifiCsiInfo<'_>) + Send,
) -> Result<(), WifiError>
pub fn set_csi( &mut self, csi: CsiConfig, cb: impl FnMut(WifiCsiInfo<'_>) + Send, ) -> Result<(), WifiError>
Set CSI configuration and register the receiving callback.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub fn remove_peer(&self, peer_address: &[u8; 6]) -> Result<(), EspNowError>
pub fn remove_peer(&self, peer_address: &[u8; 6]) -> Result<(), EspNowError>
Remove the given peer.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub fn modify_peer(&self, peer: PeerInfo) -> Result<(), EspNowError>
pub fn modify_peer(&self, peer: PeerInfo) -> Result<(), EspNowError>
Modify a peer information.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub fn peer(&self, peer_address: &[u8; 6]) -> Result<PeerInfo, EspNowError>
pub fn peer(&self, peer_address: &[u8; 6]) -> Result<PeerInfo, EspNowError>
Get peer by MAC address.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub fn fetch_peer(&self, from_head: bool) -> Result<PeerInfo, EspNowError>
pub fn fetch_peer(&self, from_head: bool) -> Result<PeerInfo, EspNowError>
Fetch a peer from peer list.
Only returns peers which address is unicast, for multicast/broadcast addresses, the function will skip the entry and find the next in the peer list.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub fn peer_exists(&self, peer_address: &[u8; 6]) -> bool
pub fn peer_exists(&self, peer_address: &[u8; 6]) -> bool
Check is peer is known.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub fn peer_count(&self) -> Result<PeerCount, EspNowError>
pub fn peer_count(&self) -> Result<PeerCount, EspNowError>
Get the number of peers.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub fn set_pmk(&self, pmk: &[u8; 16]) -> Result<(), EspNowError>
pub fn set_pmk(&self, pmk: &[u8; 16]) -> Result<(), EspNowError>
Set the primary master key.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub fn set_wake_window(&self, wake_window: Duration) -> Result<(), EspNowError>
pub fn set_wake_window(&self, wake_window: Duration) -> Result<(), EspNowError>
Set wake window for esp_now to wake up in interval unit.
Window is milliseconds the chip keep waked each interval, from 0 to 65535.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub fn set_peer_rate(
&self,
peer_address: &[u8; 6],
cfg: RateConfig,
) -> Result<(), EspNowError>
pub fn set_peer_rate( &self, peer_address: &[u8; 6], cfg: RateConfig, ) -> Result<(), EspNowError>
Set ESP-NOW rate config for the given peer. You need to add the peer first before setting the rate config.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.