Skip to content

Commit

Permalink
Add wait for DHCP in rp wifi_tcp_server
Browse files Browse the repository at this point in the history
  • Loading branch information
KingCol13 committed Oct 2, 2023
1 parent a931dfd commit 90ade1b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion examples/rp/src/bin/wifi_tcp_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use embassy_rp::bind_interrupts;
use embassy_rp::gpio::{Level, Output};
use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0};
use embassy_rp::pio::{InterruptHandler, Pio};
use embassy_time::Duration;
use embassy_time::{Duration, Timer};
use embedded_io_async::Write;
use static_cell::make_static;
use {defmt_rtt as _, panic_probe as _};
Expand Down Expand Up @@ -102,6 +102,13 @@ async fn main(spawner: Spawner) {
}
}

// Wait for DHCP, not necessary when using static IP
info!("waiting for DHCP...");
while !stack.is_config_up() {
Timer::after(Duration::from_millis(100)).await;
}
info!("DHCP is now up!");

// And now we can use it!

let mut rx_buffer = [0; 4096];
Expand Down

0 comments on commit 90ade1b

Please sign in to comment.