Struct WifiController

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

Wi-Fi controller.

Implementations§

Source§

impl WifiController<'_>

Source

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

Set the Wi-Fi 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());
§Note

Calling this function before set_config will return an error.

Source

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

Configures modem power saving.

Source

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

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

Source

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

Starts the Wi-Fi controller.

This method is not blocking. To check if the controller has started, use the Self::is_started method.

Source

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

Stops the Wi-Fi controller.

This method is not blocking. Use the Self::is_started method to see if the controller is still running.

Source

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

Connect Wi-Fi station to the AP.

This method is not blocking. Use the Self::is_connected method to see if the station is connected.

Source

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

Disconnect Wi-Fi station from the AP.

This method is not blocking. Use the Self::is_connected method to see if the station is still connected.

Source

pub fn rssi(&self) -> Result<i32, WifiError>

Get the RSSI information of AP to which the device is associated with. The value is obtained from the last beacon.

  • Use this API only in STA or AP-STA mode.
  • This API should be called after the station has connected to an access point.
§Errors

This function returns WifiError::Unsupported if the STA side isn’t running. For example, when configured for AP only.

Source

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

Get the supported capabilities of the controller.

Source

pub fn set_config(&mut self, conf: &ModeConfig) -> Result<(), WifiError>

Set the configuration.

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

Passing ModeConfig::None will disable both, AP and STA mode.

If you don’t intend to use Wi-Fi anymore at all consider tearing down Wi-Fi completely.

Source

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

Set the Wi-Fi mode.

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

Source

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

Checks if the Wi-Fi controller has started. Returns true if STA and/or AP are started.

This function should be called after the Self::start method to verify if the Wi-Fi controller has started successfully.

Source

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

Checks if the Wi-Fi controller is connected to an AP.

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

Source

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

An async Wi-Fi network scan with caller-provided scanning options.

Source

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

Async version of Self::start.

This function will wait for the Wi-Fi controller to start before returning.

Source

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

Async version of Self::stop.

This function will wait for the Wi-Fi controller to stop before returning.

Source

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

Async version of Self::connect.

This function will wait for the connection to be established before returning.

Source

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

Async version of Self::disconnect.

This function will wait for the connection to be closed before returning.

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.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

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.