Struct esp_idf_svc::wifi::AsyncWifi
source · pub struct AsyncWifi<T> { /* private fields */ }
Expand description
Wraps a WifiDriver
or EspWifi
, and offers strictly async
(non-blocking) function calls for their functionality.
Implementations§
source§impl<T> AsyncWifi<T>
impl<T> AsyncWifi<T>
pub fn wrap( wifi: T, event_loop: EspSystemEventLoop, timer_service: EspTaskTimerService, ) -> 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 async fn start(&mut self) -> Result<(), EspError>
pub async fn start(&mut self) -> Result<(), EspError>
As per WifiDriver::start()
, but as an async call that awaits until
the wifi driver has started.
sourcepub async fn stop(&mut self) -> Result<(), EspError>
pub async fn stop(&mut self) -> Result<(), EspError>
As per WifiDriver::stop()
, but as an async call that awaits until
the wifi driver has stopped.
sourcepub async fn connect(&mut self) -> Result<(), EspError>
pub async fn connect(&mut self) -> Result<(), EspError>
As per WifiDriver::connect()
, but as an async call that awaits until
the wifi driver has connected.
sourcepub async fn disconnect(&mut self) -> Result<(), EspError>
pub async fn disconnect(&mut self) -> Result<(), EspError>
As per WifiDriver::disconnect()
, but as an async call that awaits until
the wifi driver has disconnected.
sourcepub async fn scan_n<const N: usize>(
&mut self,
) -> Result<(Vec<AccessPointInfo, N>, usize), EspError>
pub async fn scan_n<const N: usize>( &mut self, ) -> Result<(Vec<AccessPointInfo, N>, usize), EspError>
As per WifiDriver::start_scan()
plus WifiDriver::get_scan_result_n()
,
as an async call that awaits until the scan is complete.
sourcepub async fn scan(&mut self) -> Result<Vec<AccessPointInfo>, EspError>
pub async fn scan(&mut self) -> Result<Vec<AccessPointInfo>, EspError>
As per WifiDriver::start_scan()
plus WifiDriver::get_scan_result()
,
as an async call that awaits until the scan is complete.
sourcepub async fn wifi_wait<F: FnMut(&mut Self) -> Result<bool, EspError>>(
&mut self,
matcher: F,
timeout: Option<Duration>,
) -> Result<(), EspError>
pub async fn wifi_wait<F: FnMut(&mut Self) -> Result<bool, EspError>>( &mut self, matcher: F, timeout: Option<Duration>, ) -> Result<(), EspError>
Awaits for a certain condition provided by the user in the form of a
matcher
callback to become 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 async fn start_wps(
&mut self,
config: &WpsConfig<'_>,
) -> Result<WpsStatus, EspError>
pub async fn start_wps( &mut self, config: &WpsConfig<'_>, ) -> Result<WpsStatus, EspError>
Start WPS and perform a wait asynchronously 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> AsyncWifi<T>where
T: NetifStatus,
impl<T> AsyncWifi<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 async fn wait_netif_up(&mut self) -> Result<(), EspError>
pub async fn wait_netif_up(&mut self) -> Result<(), EspError>
Waits until the underlaying network interface is up.
sourcepub async fn ip_wait_while<F: FnMut(&mut Self) -> Result<bool, EspError>>(
&mut self,
matcher: F,
timeout: Option<Duration>,
) -> Result<(), EspError>
pub async fn ip_wait_while<F: FnMut(&mut Self) -> Result<bool, EspError>>( &mut self, matcher: F, timeout: Option<Duration>, ) -> Result<(), EspError>
As AsyncWifi::wifi_wait()
, but for EspWifi
events related to the
IP layer, instead of WifiDriver
events on the data link layer.