pub fn set_configuration(&mut self, conf: &Configuration) -> Result<(), WifiError> {
        conf.validate()?;

        let mode = match conf {
            Configuration::None => wifi_mode_t_WIFI_MODE_NULL,
            Configuration::Client(_) => wifi_mode_t_WIFI_MODE_STA,
            Configuration::AccessPoint(_) => wifi_mode_t_WIFI_MODE_AP,
            Configuration::Mixed(_, _) => wifi_mode_t_WIFI_MODE_APSTA,
            Configuration::EapClient(_) => wifi_mode_t_WIFI_MODE_STA,
        };

        esp_wifi_result!(unsafe { esp_wifi_set_mode(mode) })?;

        match conf {
            Configuration::None => Ok::<(), WifiError>(()),
            Configuration::Client(config) => apply_sta_config(config),
            Configuration::AccessPoint(config) => apply_ap_config(config),
            Configuration::Mixed(sta_config, ap_config) => {
                apply_ap_config(ap_config).and_then(|()| apply_sta_config(sta_config))
            }
            Configuration::EapClient(config) => apply_sta_eap_config(config),
        }
        .inspect_err(|_| {
            // we/the driver might have applied a partial configuration
            // so we better disable AP/STA just in case the caller ignores the error we
            // return here - they will run into futher errors this way
            unsafe { esp_wifi_set_mode(wifi_mode_t_WIFI_MODE_NULL) };
        })?;

        Ok(())
    }
Set the configuration.

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

Passing [Configuration::None] will disable both, AP and STA mode.

If you don't intent to use WiFi anymore at all consider tearing down
WiFi completely.
esp-wifi/src/wifi/mod.rs