esp_wifi::wifi

Struct WifiController

Source
#[non_exhaustive]
pub struct WifiController<'d> { /* private fields */ }

Implementations§

Source§

impl WifiController<'_>

Source

pub fn take_sniffer(&self) -> Option<Sniffer>

Attempts to take the sniffer, returns Some(Sniffer) if successful, otherwise None.

Source

pub fn set_protocol( &mut self, protocols: EnumSet<Protocol>, ) -> Result<(), WifiError>

Set the wifi protocol.

This will set the wifi protocol to the desired protocol, the default for this is: WIFI_PROTOCOL_11B|WIFI_PROTOCOL_11G|WIFI_PROTOCOL_11N

§Arguments:
  • protocols - The desired protocols
§Example:
wifi_controller.set_protocol(Protocol::P802D11BGNLR.into());
Source

pub fn set_power_saving(&mut self, ps: PowerSaveMode) -> Result<(), WifiError>

Configures modem power saving

Source

pub fn scan_with_config_sync<const N: usize>( &mut self, config: ScanConfig<'_>, ) -> Result<(Vec<AccessPointInfo, N>, usize), WifiError>

A blocking wifi network scan with caller-provided scanning options.

Source

pub fn scan_n<const N: usize>( &mut self, ) -> Result<(Vec<AccessPointInfo, N>, usize), WifiError>

A blocking wifi network scan with default scanning options.

Source

pub fn start(&mut self) -> Result<(), WifiError>

Starts the WiFi controller.

Source

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

Stops the WiFi controller.

Source

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

Connect WiFi station to the AP.

  • If station is connected , call Self::disconnect to disconnect.
  • Scanning will not be effective until connection between device and the AP is established.
  • If device is scanning and connecting at the same time, it will abort scanning and return a warning message and error
Source

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

Disconnect WiFi station from the AP.

Source

pub fn capabilities(&self) -> Result<EnumSet<Capability>, WifiError>

Get the supported capabilities of the controller.

Source

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

Set the configuration.

This will set the mode accordingly. You need to use Wifi::connect() for connecting to an AP.

Source

pub fn set_mode(&mut self, mode: WifiMode) -> Result<(), WifiError>

Set the WiFi mode.

This will override the mode inferred by Self::set_configuration.

Source

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

Checks if the WiFi controller has started.

This function should be called after the start method to verify if the WiFi has started successfully.

Source

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

Checks if the WiFi controller is connected to an AP.

This function should be called after the connect method to verify if the connection was successful.

Source

pub async fn scan_n_async<const N: usize>( &mut self, ) -> Result<(Vec<AccessPointInfo, N>, usize), WifiError>

Async version of crate::wifi::WifiController’s scan_n method

Source

pub async fn scan_with_config_async<const N: usize>( &mut self, config: ScanConfig<'_>, ) -> Result<(Vec<AccessPointInfo, N>, usize), WifiError>

An async wifi network scan with caller-provided scanning options.

Source

pub async fn start_async(&mut self) -> Result<(), WifiError>

Async version of crate::wifi::WifiController’s start method

Source

pub async fn stop_async(&mut self) -> Result<(), WifiError>

Async version of crate::wifi::WifiController’s stop method

Source

pub async fn connect_async(&mut self) -> Result<(), WifiError>

Async version of crate::wifi::WifiController’s connect method

Source

pub async fn disconnect_async(&mut self) -> Result<(), WifiError>

Async version of crate::wifi::WifiController’s Disconnect method

Source

pub async fn wait_for_event(&mut self, event: WifiEvent)

Wait for one WifiEvent.

Source

pub async fn wait_for_events( &mut self, events: EnumSet<WifiEvent>, clear_pending: bool, ) -> EnumSet<WifiEvent>

Wait for one of multiple WifiEvents. Returns the events that occurred while waiting.

Source

pub async fn wait_for_all_events( &mut self, events: EnumSet<WifiEvent>, clear_pending: bool, )

Wait for multiple WifiEvents.

Trait Implementations§

Source§

impl Drop for WifiController<'_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'d> !Freeze for WifiController<'d>

§

impl<'d> RefUnwindSafe for WifiController<'d>

§

impl<'d> Send for WifiController<'d>

§

impl<'d> Sync for WifiController<'d>

§

impl<'d> Unpin for WifiController<'d>

§

impl<'d> UnwindSafe for WifiController<'d>

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.