pub fn new<'d>(
    _inited: &'d EspWifiController<'d>,
    _device: crate::hal::peripherals::WIFI<'d>,
) -> Result<(WifiController<'d>, Interfaces<'d>), WifiError> {
    if crate::is_interrupts_disabled() {
        return Err(WifiError::Unsupported);
    }

    let mut controller = WifiController {
        _phantom: Default::default(),
    };

    crate::wifi::wifi_init()?;

    let mut cntry_code = [0u8; 3];
    cntry_code[..crate::CONFIG.country_code.len()]
        .copy_from_slice(crate::CONFIG.country_code.as_bytes());
    cntry_code[2] = crate::CONFIG.country_code_operating_class;

    unsafe {
        let country = wifi_country_t {
            cc: cntry_code,
            schan: 1,
            nchan: 13,
            max_tx_power: 20,
            policy: wifi_country_policy_t_WIFI_COUNTRY_POLICY_MANUAL,
        };
        esp_wifi_result!(esp_wifi_set_country(&country))?;
    }

    controller.set_power_saving(PowerSaveMode::default())?;

    Ok((
        controller,
        Interfaces {
            sta: WifiDevice {
                _phantom: Default::default(),
                mode: WifiDeviceMode::Sta,
            },
            ap: WifiDevice {
                _phantom: Default::default(),
                mode: WifiDeviceMode::Ap,
            },
            #[cfg(feature = "esp-now")]
            esp_now: crate::esp_now::EspNow::new_internal(),
            #[cfg(feature = "sniffer")]
            sniffer: Sniffer::new(),
        },
    ))
}
Create a WiFi controller and it's associated interfaces.

Dropping the controller will deinitialize / stop WiFi.

Make sure to **not** call this function while interrupts are disabled.
esp-wifi/src/wifi/mod.rs