Skip to content

Commit

Permalink
manual wait
Browse files Browse the repository at this point in the history
  • Loading branch information
shish committed Nov 16, 2023
1 parent f800b8e commit 5facce2
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use esp_idf_svc::{
eventloop::EspSystemEventLoop,
ipv4::Ipv4Addr,
nvs::EspDefaultNvsPartition,
wifi::{AuthMethod, BlockingWifi, EspWifi},
wifi::{AuthMethod, EspWifi},
};
use esp_idf_sys as _;
use smart_leds::SmartLedsWrite;
Expand Down Expand Up @@ -34,10 +34,7 @@ fn main() -> anyhow::Result<()> {
log::info!("Get NVS partition");
let nvs = EspDefaultNvsPartition::take()?;

let mut wifi = BlockingWifi::wrap(
EspWifi::new(peripherals.modem, sysloop.clone(), Some(nvs))?,
sysloop,
)?;
let mut wifi = EspWifi::new(peripherals.modem, sysloop.clone(), Some(nvs))?;
let wifi_ssid = WIFI_SSID.unwrap_or("Wokwi-GUEST");
let wifi_pass = WIFI_PASS.unwrap_or("");

Expand Down Expand Up @@ -65,11 +62,7 @@ fn main() -> anyhow::Result<()> {
}
}

fn connect_wifi(
wifi: &mut BlockingWifi<EspWifi<'static>>,
ssid: &str,
password: &str,
) -> anyhow::Result<()> {
fn connect_wifi(wifi: &mut EspWifi<'static>, ssid: &str, password: &str) -> anyhow::Result<()> {
log::info!("Wifi starting, target: {}...", ssid);
wifi.start()?;

Expand Down Expand Up @@ -103,11 +96,14 @@ fn connect_wifi(
wifi.connect()?;

log::info!("Waiting for DHCP...");
wifi.wait_netif_up()?;
FreeRtos::delay_ms(60 * 1000);

// log::info!("Wifi netif up");
// self.ip_wait_while(|| self.wifi.is_up().map(|s| !s), Some(CONNECT_TIMEOUT));

log::info!("Wifi OK!");

let ip_info = wifi.wifi().sta_netif().get_ip_info()?;
let ip_info = wifi.sta_netif().get_ip_info()?;
log::info!("Wifi DHCP info: {:?}", ip_info);
Ok(())
}
Expand Down

0 comments on commit 5facce2

Please sign in to comment.