Struct esp_idf_svc::wifi::EspWifi

source ·
pub struct EspWifi<'d> { /* private fields */ }
Expand description

EspWifi wraps a WifiDriver Data Link layer instance, and binds the OSI Layer 3 (network) facilities of ESP IDF to it. In other words, it connects the ESP IDF AP and STA Netif interfaces to the Wifi driver. This allows users to utilize the Rust STD APIs for working with TCP and UDP sockets.

This struct should be the default option for a Wifi driver in all use cases but the niche one where bypassing the ESP IDF Netif and lwIP stacks is desirable. E.g., using smoltcp or other custom IP stacks on top of the ESP IDF Wifi radio.

Implementations§

source§

impl<'d> EspWifi<'d>

source

pub fn new<M: WifiModemPeripheral>( modem: impl Peripheral<P = M> + 'd, sysloop: EspSystemEventLoop, nvs: Option<EspDefaultNvsPartition>, ) -> Result<Self, EspError>

source

pub fn wrap(driver: WifiDriver<'d>) -> Result<Self, EspError>

source

pub fn wrap_all( driver: WifiDriver<'d>, sta_netif: EspNetif, ap_netif: EspNetif, ) -> Result<Self, EspError>

source

pub fn swap_netif( &mut self, sta_netif: EspNetif, ap_netif: EspNetif, ) -> Result<(EspNetif, EspNetif), EspError>

Replaces the network interfaces with the given ones. Returns the old ones.

source

pub fn swap_netif_sta( &mut self, sta_netif: EspNetif, ) -> Result<EspNetif, EspError>

Replaces the STA network interface with the provided one and returns the existing network interface.

source

pub fn swap_netif_ap( &mut self, ap_netif: EspNetif, ) -> Result<EspNetif, EspError>

Replaces the AP network interface with the provided one and returns the existing network interface.

source

pub fn driver(&self) -> &WifiDriver<'d>

Returns the underlying WifiDriver

source

pub fn driver_mut(&mut self) -> &mut WifiDriver<'d>

Returns the underlying WifiDriver, as mutable

source

pub fn sta_netif(&self) -> &EspNetif

Returns the underlying EspNetif for client mode

source

pub fn sta_netif_mut(&mut self) -> &mut EspNetif

Returns the underlying EspNetif for client mode, as mutable

source

pub fn ap_netif(&self) -> &EspNetif

Returns the underlying EspNetif for AP mode

source

pub fn ap_netif_mut(&mut self) -> &mut EspNetif

Returns the underlying EspNetif for AP mode, as mutable

source

pub fn get_capabilities(&self) -> Result<EnumSet<Capability>, EspError>

source

pub fn is_started(&self) -> Result<bool, EspError>

source

pub fn is_connected(&self) -> Result<bool, EspError>

source

pub fn is_up(&self) -> Result<bool, EspError>

Returns true when the driver has a connection, it has enabled either client or AP mode, and either the client or AP network interface is up.

source

pub fn get_configuration(&self) -> Result<Configuration, EspError>

source

pub fn set_configuration( &mut self, conf: &Configuration, ) -> Result<(), EspError>

source

pub fn start(&mut self) -> Result<(), EspError>

source

pub fn stop(&mut self) -> Result<(), EspError>

source

pub fn connect(&mut self) -> Result<(), EspError>

source

pub fn disconnect(&mut self) -> Result<(), EspError>

source

pub fn is_scan_done(&self) -> Result<bool, EspError>

source

pub fn scan_n<const N: usize>( &mut self, ) -> Result<(Vec<AccessPointInfo, N>, usize), EspError>

source

pub fn scan(&mut self) -> Result<Vec<AccessPointInfo>, EspError>

source

pub fn start_scan( &mut self, scan_config: &ScanConfig, blocking: bool, ) -> Result<(), EspError>

source

pub fn stop_scan(&mut self) -> Result<(), EspError>

source

pub fn get_scan_result_n<const N: usize>( &mut self, ) -> Result<(Vec<AccessPointInfo, N>, usize), EspError>

source

pub fn get_scan_result(&mut self) -> Result<Vec<AccessPointInfo>, EspError>

source

pub fn start_wps(&mut self, config: &WpsConfig<'_>) -> Result<(), EspError>

source

pub fn stop_wps(&mut self) -> Result<WpsStatus, EspError>

source

pub fn is_wps_finished(&self) -> Result<bool, EspError>

source

pub fn get_mac(&self, interface: WifiDeviceId) -> Result<[u8; 6], EspError>

source

pub fn set_mac( &mut self, interface: WifiDeviceId, mac: [u8; 6], ) -> Result<(), EspError>

Trait Implementations§

source§

impl<'d> Drop for EspWifi<'d>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<'d> NetifStatus for EspWifi<'d>

source§

async fn is_up(&self) -> Result<bool, EspError>

source§

impl<'d> NetifStatus for EspWifi<'d>

source§

fn is_up(&self) -> Result<bool, EspError>

source§

impl<'d> NonBlocking for EspWifi<'d>

source§

fn is_scan_done(&self) -> Result<bool, EspError>

source§

fn start_scan( &mut self, scan_config: &ScanConfig, blocking: bool, ) -> Result<(), EspError>

source§

fn stop_scan(&mut self) -> Result<(), EspError>

source§

fn get_scan_result_n<const N: usize>( &mut self, ) -> Result<(Vec<AccessPointInfo, N>, usize), EspError>

source§

fn get_scan_result(&mut self) -> Result<Vec<AccessPointInfo>, EspError>

source§

fn start_wps(&mut self, config: &WpsConfig<'_>) -> Result<(), EspError>

source§

fn stop_wps(&mut self) -> Result<WpsStatus, EspError>

source§

fn is_wps_finished(&self) -> Result<bool, EspError>

source§

impl<'d> Wifi for EspWifi<'d>

§

type Error = EspError

source§

fn get_capabilities(&self) -> Result<EnumSet<Capability>, Self::Error>

source§

fn is_started(&self) -> Result<bool, Self::Error>

source§

fn is_connected(&self) -> Result<bool, Self::Error>

source§

fn get_configuration(&self) -> Result<Configuration, Self::Error>

source§

fn set_configuration(&mut self, conf: &Configuration) -> Result<(), Self::Error>

source§

fn start(&mut self) -> Result<(), Self::Error>

source§

fn stop(&mut self) -> Result<(), Self::Error>

source§

fn connect(&mut self) -> Result<(), Self::Error>

source§

fn disconnect(&mut self) -> Result<(), Self::Error>

source§

fn scan_n<const N: usize>( &mut self, ) -> Result<(Vec<AccessPointInfo, N>, usize), Self::Error>

source§

fn scan(&mut self) -> Result<Vec<AccessPointInfo>, Self::Error>

source§

impl<'d> Send for EspWifi<'d>

Auto Trait Implementations§

§

impl<'d> Freeze for EspWifi<'d>

§

impl<'d> !RefUnwindSafe for EspWifi<'d>

§

impl<'d> !Sync for EspWifi<'d>

§

impl<'d> Unpin for EspWifi<'d>

§

impl<'d> !UnwindSafe for EspWifi<'d>

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.