Struct esp_idf_svc::wifi::BlockingWifi
source · pub struct BlockingWifi<T> { /* private fields */ }
Expand description
Wraps a WifiDriver
or EspWifi
, and offers strictly synchronous (blocking)
function calls for their functionality.
Implementations§
source§impl<T> BlockingWifi<T>
impl<T> BlockingWifi<T>
pub fn wrap(wifi: T, event_loop: EspSystemEventLoop) -> Result<Self, EspError>
sourcepub fn wifi(&self) -> &T
pub fn wifi(&self) -> &T
Returns the underlying WifiDriver
or EspWifi
sourcepub fn wifi_mut(&mut self) -> &mut T
pub fn wifi_mut(&mut self) -> &mut T
Returns the underlying WifiDriver
or EspWifi
, as mutable
sourcepub fn get_capabilities(&self) -> Result<EnumSet<Capability>, EspError>
pub fn get_capabilities(&self) -> Result<EnumSet<Capability>, EspError>
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 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 start(&mut self) -> Result<(), EspError>
pub fn start(&mut self) -> Result<(), EspError>
As per WifiDriver::start()
, but as a blocking call that returns
once the wifi driver has started.
sourcepub fn stop(&mut self) -> Result<(), EspError>
pub fn stop(&mut self) -> Result<(), EspError>
As per WifiDriver::stop()
, but as a blocking call that returns
once the wifi driver has stopped.
sourcepub fn connect(&mut self) -> Result<(), EspError>
pub fn connect(&mut self) -> Result<(), EspError>
As per WifiDriver::connect()
, but as a blocking call that returns
once the wifi driver is connected.
sourcepub fn disconnect(&mut self) -> Result<(), EspError>
pub fn disconnect(&mut self) -> Result<(), EspError>
As per WifiDriver::disconnect()
, but as a blocking call that returns
once the wifi driver has disconnected.
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 wifi_wait_while<F: Fn() -> Result<bool, EspError>>(
&self,
matcher: F,
timeout: Option<Duration>,
) -> Result<(), EspError>
pub fn wifi_wait_while<F: Fn() -> Result<bool, EspError>>( &self, matcher: F, timeout: Option<Duration>, ) -> Result<(), EspError>
Performs a blocking wait until certain condition provided by the user
in the form of a matcher
callback becomes false. Most often than not
that condition would be related to the state of the Wifi driver. In
other words, whether the driver is started, stopped, (dis)connected and
so on.
Note that the waiting is not done internally using busy-looping and/or
timeouts. Rather, the condition (matcher
) is evaluated initially, and
if it returns true
, it is re-evaluated each time the ESP IDF C Wifi
driver posts a Wifi event on the system event loop. The reasoning behind
this is that changes to the state of the Wifi driver are always
accompanied by posting Wifi events.
sourcepub fn start_wps(
&mut self,
config: &WpsConfig<'_>,
) -> Result<WpsStatus, EspError>
pub fn start_wps( &mut self, config: &WpsConfig<'_>, ) -> Result<WpsStatus, EspError>
Start WPS and perform a blocking wait until it connects, fails or times
out. A WpsStatus
is returned that contains the success status of the
WPS connection. When the credentials of only one access point are
received, the WiFi driver configuration will automatically be set to
that access point. If multiple credentials were received, a
WpsStatus::Success
will be returned with a vector containing those
credentials. The caller must then handle those credentials and set the
configuration manually.
source§impl<T> BlockingWifi<T>where
T: NetifStatus,
impl<T> BlockingWifi<T>where
T: NetifStatus,
sourcepub fn is_up(&self) -> Result<bool, EspError>
pub fn is_up(&self) -> Result<bool, EspError>
As per EspWifi::is_up()
.
sourcepub fn wait_netif_up(&self) -> Result<(), EspError>
pub fn wait_netif_up(&self) -> Result<(), EspError>
Waits until the underlaying network interface is up.
sourcepub fn ip_wait_while<F: Fn() -> Result<bool, EspError>>(
&self,
matcher: F,
timeout: Option<Duration>,
) -> Result<(), EspError>
pub fn ip_wait_while<F: Fn() -> Result<bool, EspError>>( &self, matcher: F, timeout: Option<Duration>, ) -> Result<(), EspError>
As BlockingWifi::wifi_wait_while()
, but for EspWifi
events
related to the IP layer, instead of WifiDriver
events on the data link layer.