add wait_config_up to examples

This commit is contained in:
JuliDi 2023-09-08 17:40:20 +02:00
parent 3e0b752bef
commit cf2d4eca7c
No known key found for this signature in database
GPG Key ID: 0C98FD5D6597BC5B
5 changed files with 18 additions and 6 deletions

View File

@ -79,7 +79,10 @@ async fn main(spawner: Spawner) -> ! {
)); ));
// Launch network task // Launch network task
unwrap!(spawner.spawn(net_task(&stack))); unwrap!(spawner.spawn(net_task(stack)));
// Ensure DHCP configuration is up before trying connect
stack.wait_config_up().await;
info!("Network task initialized"); info!("Network task initialized");

View File

@ -80,7 +80,10 @@ async fn main(spawner: Spawner) -> ! {
)); ));
// Launch network task // Launch network task
unwrap!(spawner.spawn(net_task(&stack))); unwrap!(spawner.spawn(net_task(stack)));
// Ensure DHCP configuration is up before trying connect
stack.wait_config_up().await;
info!("Network task initialized"); info!("Network task initialized");

View File

@ -101,6 +101,9 @@ async fn main(spawner: Spawner) -> ! {
// Launch network task // Launch network task
unwrap!(spawner.spawn(net_task(&stack))); unwrap!(spawner.spawn(net_task(&stack)));
// Ensure DHCP configuration is up before trying connect
stack.wait_config_up().await;
info!("Network task initialized"); info!("Network task initialized");
// Then we can use it! // Then we can use it!

View File

@ -83,6 +83,9 @@ async fn main(spawner: Spawner) -> ! {
// Launch network task // Launch network task
unwrap!(spawner.spawn(net_task(&stack))); unwrap!(spawner.spawn(net_task(&stack)));
// Ensure DHCP configuration is up before trying connect
stack.wait_config_up().await;
info!("Network task initialized"); info!("Network task initialized");
// Then we can use it! // Then we can use it!

View File

@ -82,13 +82,13 @@ async fn main(spawner: Spawner) -> ! {
)); ));
// Launch network task // Launch network task
unwrap!(spawner.spawn(net_task(&stack))); unwrap!(spawner.spawn(net_task(stack)));
// Ensure DHCP configuration is up before trying connect
stack.wait_config_up().await;
info!("Network task initialized"); info!("Network task initialized");
// To ensure DHCP configuration before trying connect
Timer::after(Duration::from_secs(20)).await;
static STATE: TcpClientState<1, 1024, 1024> = TcpClientState::new(); static STATE: TcpClientState<1, 1024, 1024> = TcpClientState::new();
let client = TcpClient::new(&stack, &STATE); let client = TcpClient::new(&stack, &STATE);