From f31c0e997f9b33a3b691c48c27afb4731fc02e0c Mon Sep 17 00:00:00 2001 From: chrysn Date: Thu, 30 Jan 2025 12:18:08 +0100 Subject: [PATCH] feat(coap): delay startup until network is ready This unbreaks the coap-client example in DHCP configurations. --- src/ariel-os-coap/src/lib.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/ariel-os-coap/src/lib.rs b/src/ariel-os-coap/src/lib.rs index ac3f7cb3b..7388a9f05 100644 --- a/src/ariel-os-coap/src/lib.rs +++ b/src/ariel-os-coap/src/lib.rs @@ -75,6 +75,13 @@ async fn coap_run_impl(handler: impl coap_handler::Handler + coap_handler::Repor let stack = ariel_os_embassy::net::network_stack().await.unwrap(); + // There's no strong need to wait this early (it matters that we wait before populating + // CLIENT), but this is a convenient place in the code (we have a `stack` now, to populate + // CLIENT after the server, we'd have to poll the server and `wait_config_up` in parallel), and + // it's not like we'd expect requests to come in before everything is up. (Not even a loopback + // request, because we shouldn't hand out a client early). + stack.wait_config_up().await; + // FIXME trim to CoAP requirements let mut rx_meta = [PacketMetadata::EMPTY; 16]; let mut rx_buffer = [0; 4096];