#[non_exhaustive]pub struct WifiController<'d> { /* private fields */ }Expand description
Wi-Fi controller.
Implementations§
Source§impl WifiController<'_>
impl WifiController<'_>
Sourcepub fn set_protocol(
&mut self,
protocols: EnumSet<Protocol>,
) -> Result<(), WifiError>
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.
Sourcepub fn set_power_saving(&mut self, ps: PowerSaveMode) -> Result<(), WifiError>
pub fn set_power_saving(&mut self, ps: PowerSaveMode) -> Result<(), WifiError>
Configures modem power saving.
Sourcepub fn scan_with_config(
&mut self,
config: ScanConfig<'_>,
) -> Result<Vec<AccessPointInfo>, WifiError>
pub fn scan_with_config( &mut self, config: ScanConfig<'_>, ) -> Result<Vec<AccessPointInfo>, WifiError>
A blocking wifi network scan with caller-provided scanning options.
Sourcepub fn start(&mut self) -> Result<(), WifiError>
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.
Sourcepub fn stop(&mut self) -> Result<(), WifiError>
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.
Sourcepub fn connect(&mut self) -> Result<(), WifiError>
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.
- If station is connected, call
Self::disconnectto disconnect. - Calling
Self::scan_with_configorSelf::scan_with_config_asyncwill 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.
Sourcepub fn disconnect(&mut self) -> Result<(), WifiError>
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.
Sourcepub fn rssi(&self) -> Result<i32, WifiError>
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.
Sourcepub fn capabilities(&self) -> Result<EnumSet<Capability>, WifiError>
pub fn capabilities(&self) -> Result<EnumSet<Capability>, WifiError>
Get the supported capabilities of the controller.
Sourcepub fn set_config(&mut self, conf: &ModeConfig) -> Result<(), WifiError>
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.
Sourcepub fn set_mode(&mut self, mode: WifiMode) -> Result<(), WifiError>
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.
Sourcepub fn is_started(&self) -> Result<bool, WifiError>
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.
Sourcepub fn is_connected(&self) -> Result<bool, WifiError>
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.
Sourcepub async fn scan_with_config_async(
&mut self,
config: ScanConfig<'_>,
) -> Result<Vec<AccessPointInfo>, WifiError>
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.
Sourcepub async fn start_async(&mut self) -> Result<(), WifiError>
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.
Sourcepub async fn stop_async(&mut self) -> Result<(), WifiError>
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.
Sourcepub async fn connect_async(&mut self) -> Result<(), WifiError>
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.
Sourcepub async fn disconnect_async(&mut self) -> Result<(), WifiError>
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.
Sourcepub async fn wait_for_event(&mut self, event: WifiEvent)
pub async fn wait_for_event(&mut self, event: WifiEvent)
Wait for one WifiEvent.
Sourcepub async fn wait_for_events(
&mut self,
events: EnumSet<WifiEvent>,
clear_pending: bool,
) -> EnumSet<WifiEvent>
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.
Sourcepub async fn wait_for_all_events(
&mut self,
events: EnumSet<WifiEvent>,
clear_pending: bool,
)
pub async fn wait_for_all_events( &mut self, events: EnumSet<WifiEvent>, clear_pending: bool, )
Wait for multiple WifiEvents.