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>
impl<'d> EspWifi<'d>
pub fn new<M: WifiModemPeripheral>( modem: impl Peripheral<P = M> + 'd, sysloop: EspSystemEventLoop, nvs: Option<EspDefaultNvsPartition>, ) -> Result<Self, EspError>
pub fn wrap(driver: WifiDriver<'d>) -> Result<Self, EspError>
pub fn wrap_all( driver: WifiDriver<'d>, sta_netif: EspNetif, ap_netif: EspNetif, ) -> Result<Self, EspError>
sourcepub fn swap_netif(
&mut self,
sta_netif: EspNetif,
ap_netif: EspNetif,
) -> Result<(EspNetif, EspNetif), EspError>
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.
sourcepub fn swap_netif_sta(
&mut self,
sta_netif: EspNetif,
) -> Result<EspNetif, EspError>
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.
sourcepub fn swap_netif_ap(
&mut self,
ap_netif: EspNetif,
) -> Result<EspNetif, EspError>
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.
sourcepub fn driver(&self) -> &WifiDriver<'d>
pub fn driver(&self) -> &WifiDriver<'d>
Returns the underlying WifiDriver
sourcepub fn driver_mut(&mut self) -> &mut WifiDriver<'d>
pub fn driver_mut(&mut self) -> &mut WifiDriver<'d>
Returns the underlying WifiDriver
, as mutable
sourcepub fn sta_netif_mut(&mut self) -> &mut EspNetif
pub fn sta_netif_mut(&mut self) -> &mut EspNetif
Returns the underlying EspNetif
for client mode, as mutable
sourcepub fn ap_netif_mut(&mut self) -> &mut EspNetif
pub fn ap_netif_mut(&mut self) -> &mut EspNetif
Returns the underlying EspNetif
for AP mode, as mutable
sourcepub fn get_capabilities(&self) -> Result<EnumSet<Capability>, EspError>
pub fn get_capabilities(&self) -> Result<EnumSet<Capability>, EspError>
sourcepub fn is_started(&self) -> Result<bool, EspError>
pub fn is_started(&self) -> Result<bool, EspError>
As per WifiDriver::is_started()
sourcepub fn is_connected(&self) -> Result<bool, EspError>
pub fn is_connected(&self) -> Result<bool, EspError>
As per WifiDriver::is_connected()
sourcepub fn is_up(&self) -> Result<bool, EspError>
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.
sourcepub fn get_configuration(&self) -> Result<Configuration, EspError>
pub fn get_configuration(&self) -> Result<Configuration, EspError>
sourcepub fn set_configuration(
&mut self,
conf: &Configuration,
) -> Result<(), EspError>
pub fn set_configuration( &mut self, conf: &Configuration, ) -> Result<(), EspError>
sourcepub fn start(&mut self) -> Result<(), EspError>
pub fn start(&mut self) -> Result<(), EspError>
As per WifiDriver::start()
sourcepub fn stop(&mut self) -> Result<(), EspError>
pub fn stop(&mut self) -> Result<(), EspError>
As per WifiDriver::stop()
sourcepub fn connect(&mut self) -> Result<(), EspError>
pub fn connect(&mut self) -> Result<(), EspError>
As per WifiDriver::connect()
sourcepub fn disconnect(&mut self) -> Result<(), EspError>
pub fn disconnect(&mut self) -> Result<(), EspError>
As per WifiDriver::disconnect()
sourcepub fn is_scan_done(&self) -> Result<bool, EspError>
pub fn is_scan_done(&self) -> Result<bool, EspError>
As per WifiDriver::is_scan_done()
sourcepub fn scan_n<const N: usize>(
&mut self,
) -> Result<(Vec<AccessPointInfo, N>, usize), EspError>
pub fn scan_n<const N: usize>( &mut self, ) -> Result<(Vec<AccessPointInfo, N>, usize), EspError>
As per WifiDriver::scan_n()
sourcepub fn scan(&mut self) -> Result<Vec<AccessPointInfo>, EspError>
pub fn scan(&mut self) -> Result<Vec<AccessPointInfo>, EspError>
As per WifiDriver::scan()
sourcepub fn start_scan(
&mut self,
scan_config: &ScanConfig,
blocking: bool,
) -> Result<(), EspError>
pub fn start_scan( &mut self, scan_config: &ScanConfig, blocking: bool, ) -> Result<(), EspError>
As per WifiDriver::start_scan()
.
sourcepub fn stop_scan(&mut self) -> Result<(), EspError>
pub fn stop_scan(&mut self) -> Result<(), EspError>
As per WifiDriver::stop_scan()
.
sourcepub fn get_scan_result_n<const N: usize>(
&mut self,
) -> Result<(Vec<AccessPointInfo, N>, usize), EspError>
pub fn get_scan_result_n<const N: usize>( &mut self, ) -> Result<(Vec<AccessPointInfo, N>, usize), EspError>
As per WifiDriver::get_scan_result_n()
.
sourcepub fn get_scan_result(&mut self) -> Result<Vec<AccessPointInfo>, EspError>
pub fn get_scan_result(&mut self) -> Result<Vec<AccessPointInfo>, EspError>
As per WifiDriver::get_scan_result()
.
sourcepub fn start_wps(&mut self, config: &WpsConfig<'_>) -> Result<(), EspError>
pub fn start_wps(&mut self, config: &WpsConfig<'_>) -> Result<(), EspError>
As per WifiDriver::start_wps()
pub fn stop_wps(&mut self) -> Result<WpsStatus, EspError>
pub fn is_wps_finished(&self) -> Result<bool, EspError>
sourcepub fn get_mac(&self, interface: WifiDeviceId) -> Result<[u8; 6], EspError>
pub fn get_mac(&self, interface: WifiDeviceId) -> Result<[u8; 6], EspError>
As per WifiDriver::get_mac()
.
sourcepub fn set_mac(
&mut self,
interface: WifiDeviceId,
mac: [u8; 6],
) -> Result<(), EspError>
pub fn set_mac( &mut self, interface: WifiDeviceId, mac: [u8; 6], ) -> Result<(), EspError>
As per WifiDriver::set_mac()
.