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>
where T: Wifi<Error = EspError> + NonBlocking,

source

pub fn wrap( wifi: T, event_loop: EspSystemEventLoop, timer_service: EspTaskTimerService ) -> Result<Self, EspError>

source

pub fn wifi(&self) -> &T

Returns the underlying WifiDriver or EspWifi

source

pub fn wifi_mut(&mut self) -> &mut T

Returns the underlying WifiDriver or EspWifi, as mutable

source

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

source

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

source

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

source

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

source

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

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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,

source

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

source

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

Waits until the underlaying network interface is up.

source

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.

Trait Implementations§

source§

impl<T> NetifStatus for AsyncWifi<T>
where T: NetifStatus,

source§

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

source§

impl<T> Wifi for AsyncWifi<T>
where T: Wifi<Error = EspError> + NonBlocking,

§

type Error = <T as Wifi>::Error

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for AsyncWifi<T>
where T: RefUnwindSafe,

§

impl<T> Send for AsyncWifi<T>
where T: Send,

§

impl<T> Sync for AsyncWifi<T>
where T: Sync,

§

impl<T> Unpin for AsyncWifi<T>
where T: Unpin,

§

impl<T> UnwindSafe for AsyncWifi<T>
where T: UnwindSafe,

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.