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

source

pub fn wrap(wifi: T, event_loop: EspSystemEventLoop) -> 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 fn start(&mut self) -> Result<(), EspError>

As per WifiDriver::start(), but as a blocking call that returns once the wifi driver has started.

source

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

As per WifiDriver::stop(), but as a blocking call that returns once the wifi driver has stopped.

source

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

As per WifiDriver::connect(), but as a blocking call that returns once the wifi driver is connected.

source

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

As per WifiDriver::disconnect(), but as a blocking call that returns once the wifi driver has disconnected.

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 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.

source

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,

source

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

source

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

Waits until the underlaying network interface is up.

source

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.

Trait Implementations§

source§

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

source§

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

source§

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

§

type Error = EspError

source§

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

source§

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

source§

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

source§

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

source§

fn is_connected(&self) -> Result<bool, 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>

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

impl<T> UnwindSafe for BlockingWifi<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.