diff options
| author | KingCol13 <[email protected]> | 2023-10-02 20:10:52 +0100 |
|---|---|---|
| committer | KingCol13 <[email protected]> | 2023-10-02 20:10:52 +0100 |
| commit | 90ade1b311646f0ed83f3f2264537bccca2258d5 (patch) | |
| tree | 22b4a61e65b9c4ff46be7399686fc99114de7f41 | |
| parent | a931dfd9ad67ef68b47ffa334910e550e84fb35f (diff) | |
Add wait for DHCP in rp wifi_tcp_server
| -rw-r--r-- | examples/rp/src/bin/wifi_tcp_server.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/examples/rp/src/bin/wifi_tcp_server.rs b/examples/rp/src/bin/wifi_tcp_server.rs index 20a92b6ed..64cf95171 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; | |||
| 18 | use embassy_rp::gpio::{Level, Output}; | 18 | use embassy_rp::gpio::{Level, Output}; |
| 19 | use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0}; | 19 | use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0}; |
| 20 | use embassy_rp::pio::{InterruptHandler, Pio}; | 20 | use embassy_rp::pio::{InterruptHandler, Pio}; |
| 21 | use embassy_time::Duration; | 21 | use embassy_time::{Duration, Timer}; |
| 22 | use embedded_io_async::Write; | 22 | use embedded_io_async::Write; |
| 23 | use static_cell::make_static; | 23 | use static_cell::make_static; |
| 24 | use {defmt_rtt as _, panic_probe as _}; | 24 | use {defmt_rtt as _, panic_probe as _}; |
| @@ -102,6 +102,13 @@ async fn main(spawner: Spawner) { | |||
| 102 | } | 102 | } |
| 103 | } | 103 | } |
| 104 | 104 | ||
| 105 | // Wait for DHCP, not necessary when using static IP | ||
| 106 | info!("waiting for DHCP..."); | ||
| 107 | while !stack.is_config_up() { | ||
| 108 | Timer::after(Duration::from_millis(100)).await; | ||
| 109 | } | ||
| 110 | info!("DHCP is now up!"); | ||
| 111 | |||
| 105 | // And now we can use it! | 112 | // And now we can use it! |
| 106 | 113 | ||
| 107 | let mut rx_buffer = [0; 4096]; | 114 | let mut rx_buffer = [0; 4096]; |
