Skip to content

Commit

Permalink
Remove Wifi test scan
Browse files Browse the repository at this point in the history
  • Loading branch information
zargony committed Aug 10, 2024
1 parent 11e1104 commit d7b9165
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 36 deletions.
5 changes: 1 addition & 4 deletions firmware/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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();
Expand Down
42 changes: 10 additions & 32 deletions firmware/src/wifi.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand All @@ -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> {
Expand All @@ -28,10 +25,11 @@ impl<'d> Wifi<'d> {
clocks: &Clocks<'d>,
wifi: peripherals::WIFI,
) -> Result<Self, Error> {
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());
Expand All @@ -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());
}
}

0 comments on commit d7b9165

Please sign in to comment.