From 90ade1b311646f0ed83f3f2264537bccca2258d5 Mon Sep 17 00:00:00 2001 From: KingCol13 <48412633+KingCol13@users.noreply.github.com> Date: Mon, 2 Oct 2023 20:10:52 +0100 Subject: [PATCH] Add wait for DHCP in rp wifi_tcp_server --- examples/rp/src/bin/wifi_tcp_server.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/examples/rp/src/bin/wifi_tcp_server.rs b/examples/rp/src/bin/wifi_tcp_server.rs index 20a92b6e..64cf9517 100644 --- a/examples/rp/src/bin/wifi_tcp_server.rs +++ b/examples/rp/src/bin/wifi_tcp_server.rs @@ -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 _}; @@ -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];