diff --git a/firmware/src/main.rs b/firmware/src/main.rs index 5a5c067..1ddd5b6 100644 --- a/firmware/src/main.rs +++ b/firmware/src/main.rs @@ -115,7 +115,7 @@ async fn main(_spawner: Spawner) { // Initialize Wifi let timg0 = TimerGroup::new(peripherals.TIMG0, &clocks, None); let wifi_timer = PeriodicTimer::new(timg0.timer0.into()); - let mut wifi = match wifi::Wifi::new( + let _wifi = match wifi::Wifi::new( wifi_timer, rng, peripherals.RADIO_CLK, @@ -133,9 +133,6 @@ async fn main(_spawner: Spawner) { display.clear().unwrap(); display.hello().unwrap(); - // Test Wifi - wifi.test().await; - let mut displaying_key = false; loop { led.toggle(); diff --git a/firmware/src/wifi.rs b/firmware/src/wifi.rs index ddb9fd9..25a42b6 100644 --- a/firmware/src/wifi.rs +++ b/firmware/src/wifi.rs @@ -1,9 +1,8 @@ -use core::time::Duration; use esp_hal::clock::Clocks; use esp_hal::peripherals; use esp_hal::rng::Rng; use esp_hal::timer::{ErasedTimer, PeriodicTimer}; -use esp_wifi::wifi::{self, ScanConfig, ScanTypeConfig, WifiController, WifiDevice, WifiStaDevice}; +use esp_wifi::wifi::{self, WifiController, WifiDevice, WifiStaDevice}; use esp_wifi::{EspWifiInitFor, EspWifiInitialization}; use log::{debug, info}; @@ -12,11 +11,9 @@ pub use esp_wifi::wifi::WifiError as Error; /// Wifi interface pub struct Wifi<'d> { - #[allow(dead_code)] - inited: EspWifiInitialization, - #[allow(dead_code)] - device: WifiDevice<'d, WifiStaDevice>, - controller: WifiController<'d>, + _init: EspWifiInitialization, + _device: WifiDevice<'d, WifiStaDevice>, + _controller: WifiController<'d>, } impl<'d> Wifi<'d> { @@ -28,10 +25,11 @@ impl<'d> Wifi<'d> { clocks: &Clocks<'d>, wifi: peripherals::WIFI, ) -> Result { - let inited = esp_wifi::initialize(EspWifiInitFor::Wifi, timer, rng, radio_clocks, clocks) + let init = esp_wifi::initialize(EspWifiInitFor::Wifi, timer, rng, radio_clocks, clocks) .map_err(|_| Error::NotInitialized)?; - let (device, mut controller) = wifi::new_with_mode(&inited, wifi, WifiStaDevice)?; + let (device, mut controller) = wifi::new_with_mode(&init, wifi, WifiStaDevice)?; + debug!("Static Wifi configuration: {:?}", esp_wifi::CONFIG); debug!("Wifi configuration: {:?}", controller.get_configuration()); debug!("Wifi capabilities: {:?}", controller.get_capabilities()); debug!("Wifi state: {:?}", wifi::get_wifi_state()); @@ -41,29 +39,9 @@ impl<'d> Wifi<'d> { debug!("Wifi state: {:?}", wifi::get_wifi_state()); Ok(Wifi { - inited, - device, - controller, + _init: init, + _device: device, + _controller: controller, }) } - - /// Test Wifi interface - pub async fn test(&mut self) { - let scan_config = ScanConfig { - ssid: None, - bssid: None, - channel: None, - show_hidden: true, - scan_type: ScanTypeConfig::Passive(Duration::from_millis(1000)), - }; - info!("Starting Wifi scan..."); - let (aps, count) = self - .controller - .scan_with_config::<10>(scan_config) - .await - .unwrap(); - info!("Wifi scan done."); - info!("Wifi scan returned {} results: {:?}", count, aps); - debug!("Wifi state: {:?}", wifi::get_wifi_state()); - } }