Skip to content

Commit

Permalink
Updated to embassy-net 0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
sammhicks committed Dec 6, 2024
1 parent c571572 commit b331742
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 89 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ categories = ["asynchronous", "network-programming", "web-programming::http-serv
const-sha1 = { version = "0.3.0", default-features = false }
data-encoding = { version = "2.4.0", default-features = false }
defmt = { version = "0.3.6", optional = true }
embassy-net = { version = "0.4.0", optional = true, features = ["tcp", "proto-ipv4", "medium-ethernet"] }
embassy-net = { version = "0.5.0", optional = true, features = ["tcp", "proto-ipv4", "medium-ethernet"] }
embassy-time = { version = "0.3.0", optional = true }
embedded-io-async = "0.6.0"
futures-util = { version = "0.3.28", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion examples/embassy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ cyw43 = { version = "0.2.0", features = ["firmware-logs"] }
cyw43-pio = "0.2.0"
embassy-executor = { version = "0.6.3", features = ["arch-cortex-m", "executor-thread", "integrated-timers", "nightly"] }
embassy-futures = "0.1.1"
embassy-net = { version = "0.4.0", features = ["tcp", "proto-ipv4", "medium-ethernet"] }
embassy-net = { version = "0.5.0", features = ["tcp", "proto-ipv4", "medium-ethernet"] }
embassy-rp = { version = "0.2.0", features = ["critical-section-impl", "time-driver"] }
embassy-sync = "0.6.0"
embassy-time = "0.3.1"
Expand Down
36 changes: 15 additions & 21 deletions examples/embassy/hello_world/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async fn wifi_task(
}

#[embassy_executor::task]
async fn net_task(stack: &'static embassy_net::Stack<cyw43::NetDriver<'static>>) -> ! {
async fn net_task(mut stack: embassy_net::Runner<'static, cyw43::NetDriver<'static>>) -> ! {
stack.run().await
}

Expand All @@ -52,7 +52,7 @@ const WEB_TASK_POOL_SIZE: usize = 8;
#[embassy_executor::task(pool_size = WEB_TASK_POOL_SIZE)]
async fn web_task(
id: usize,
stack: &'static embassy_net::Stack<cyw43::NetDriver<'static>>,
stack: embassy_net::Stack<'static>,
app: &'static AppRouter<AppProps>,
config: &'static picoserve::Config<Duration>,
) -> ! {
Expand Down Expand Up @@ -109,27 +109,21 @@ async fn main(spawner: embassy_executor::Spawner) {

control.init(clm).await;

let stack = make_static!(
embassy_net::Stack<cyw43::NetDriver>,
embassy_net::Stack::new(
net_device,
embassy_net::Config::ipv4_static(embassy_net::StaticConfigV4 {
address: embassy_net::Ipv4Cidr::new(
embassy_net::Ipv4Address::new(192, 168, 0, 1),
24
),
gateway: None,
dns_servers: Default::default(),
}),
make_static!(
embassy_net::StackResources<WEB_TASK_POOL_SIZE>,
embassy_net::StackResources::new()
),
embassy_rp::clocks::RoscRng.gen(),
)
let (stack, runner) = embassy_net::new(
net_device,
embassy_net::Config::ipv4_static(embassy_net::StaticConfigV4 {
address: embassy_net::Ipv4Cidr::new(embassy_net::Ipv4Address::new(192, 168, 0, 1), 24),
gateway: None,
dns_servers: Default::default(),
}),
make_static!(
embassy_net::StackResources<WEB_TASK_POOL_SIZE>,
embassy_net::StackResources::new()
),
embassy_rp::clocks::RoscRng.gen(),
);

spawner.must_spawn(net_task(stack));
spawner.must_spawn(net_task(runner));

control
.start_ap_wpa2(
Expand Down
2 changes: 1 addition & 1 deletion examples/embassy/hello_world_defmt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ cyw43-pio = "0.2.0"
defmt-rtt = "0.4.0"
embassy-executor = { version = "0.6.3", features = ["arch-cortex-m", "executor-thread", "integrated-timers", "nightly"] }
embassy-futures = "0.1.1"
embassy-net = { version = "0.4.0", features = ["tcp", "proto-ipv4", "medium-ethernet"] }
embassy-net = { version = "0.5.0", features = ["tcp", "proto-ipv4", "medium-ethernet"] }
embassy-rp = { version = "0.2.0", features = ["critical-section-impl", "time-driver"] }
embassy-sync = "0.6.1"
embassy-time = { version = "0.3.0", features = ["defmt-timestamp-uptime"] }
Expand Down
36 changes: 15 additions & 21 deletions examples/embassy/hello_world_defmt/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ async fn wifi_task(
}

#[embassy_executor::task]
async fn net_task(stack: &'static embassy_net::Stack<cyw43::NetDriver<'static>>) -> ! {
async fn net_task(mut stack: embassy_net::Runner<'static, cyw43::NetDriver<'static>>) -> ! {
stack.run().await
}

Expand All @@ -46,7 +46,7 @@ const WEB_TASK_POOL_SIZE: usize = 8;
#[embassy_executor::task(pool_size = WEB_TASK_POOL_SIZE)]
async fn web_task(
id: usize,
stack: &'static embassy_net::Stack<cyw43::NetDriver<'static>>,
stack: embassy_net::Stack<'static>,
app: &'static AppRouter<AppProps>,
config: &'static picoserve::Config<Duration>,
) -> ! {
Expand Down Expand Up @@ -94,27 +94,21 @@ async fn main(spawner: embassy_executor::Spawner) {

control.init(clm).await;

let stack = make_static!(
embassy_net::Stack::<cyw43::NetDriver>,
embassy_net::Stack::new(
net_device,
embassy_net::Config::ipv4_static(embassy_net::StaticConfigV4 {
address: embassy_net::Ipv4Cidr::new(
embassy_net::Ipv4Address::new(192, 168, 0, 1),
24
),
gateway: None,
dns_servers: Default::default(),
}),
make_static!(
embassy_net::StackResources::<WEB_TASK_POOL_SIZE>,
embassy_net::StackResources::new()
),
embassy_rp::clocks::RoscRng.gen(),
)
let (stack, runner) = embassy_net::new(
net_device,
embassy_net::Config::ipv4_static(embassy_net::StaticConfigV4 {
address: embassy_net::Ipv4Cidr::new(embassy_net::Ipv4Address::new(192, 168, 0, 1), 24),
gateway: None,
dns_servers: Default::default(),
}),
make_static!(
embassy_net::StackResources::<WEB_TASK_POOL_SIZE>,
embassy_net::StackResources::new()
),
embassy_rp::clocks::RoscRng.gen(),
);

spawner.must_spawn(net_task(stack));
spawner.must_spawn(net_task(runner));

control
.start_ap_wpa2(
Expand Down
36 changes: 15 additions & 21 deletions examples/embassy/set_pico_w_led/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async fn wifi_task(
}

#[embassy_executor::task]
async fn net_task(stack: &'static embassy_net::Stack<cyw43::NetDriver<'static>>) -> ! {
async fn net_task(mut stack: embassy_net::Runner<'static, cyw43::NetDriver<'static>>) -> ! {
stack.run().await
}

Expand Down Expand Up @@ -98,7 +98,7 @@ const WEB_TASK_POOL_SIZE: usize = 8;
#[embassy_executor::task(pool_size = WEB_TASK_POOL_SIZE)]
async fn web_task(
id: usize,
stack: &'static embassy_net::Stack<cyw43::NetDriver<'static>>,
stack: embassy_net::Stack<'static>,
app: &'static AppRouter<AppProps>,
config: &'static picoserve::Config<Duration>,
state: AppState,
Expand Down Expand Up @@ -157,27 +157,21 @@ async fn main(spawner: embassy_executor::Spawner) {

control.init(clm).await;

let stack = make_static!(
embassy_net::Stack::<cyw43::NetDriver>,
embassy_net::Stack::new(
net_device,
embassy_net::Config::ipv4_static(embassy_net::StaticConfigV4 {
address: embassy_net::Ipv4Cidr::new(
embassy_net::Ipv4Address::new(192, 168, 0, 1),
24
),
gateway: None,
dns_servers: Default::default(),
}),
make_static!(
embassy_net::StackResources::<WEB_TASK_POOL_SIZE>,
embassy_net::StackResources::new()
),
embassy_rp::clocks::RoscRng.gen(),
)
let (stack, runner) = embassy_net::new(
net_device,
embassy_net::Config::ipv4_static(embassy_net::StaticConfigV4 {
address: embassy_net::Ipv4Cidr::new(embassy_net::Ipv4Address::new(192, 168, 0, 1), 24),
gateway: None,
dns_servers: Default::default(),
}),
make_static!(
embassy_net::StackResources::<WEB_TASK_POOL_SIZE>,
embassy_net::StackResources::new()
),
embassy_rp::clocks::RoscRng.gen(),
);

spawner.must_spawn(net_task(stack));
spawner.must_spawn(net_task(runner));

control
.start_ap_wpa2(
Expand Down
36 changes: 15 additions & 21 deletions examples/embassy/web_sockets/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async fn wifi_task(
}

#[embassy_executor::task]
async fn net_task(stack: &'static embassy_net::Stack<cyw43::NetDriver<'static>>) -> ! {
async fn net_task(mut stack: embassy_net::Runner<'static, cyw43::NetDriver<'static>>) -> ! {
stack.run().await
}

Expand Down Expand Up @@ -76,7 +76,7 @@ const WEB_TASK_POOL_SIZE: usize = 8;
#[embassy_executor::task(pool_size = WEB_TASK_POOL_SIZE)]
async fn web_task(
id: usize,
stack: &'static embassy_net::Stack<cyw43::NetDriver<'static>>,
stack: embassy_net::Stack<'static>,
app: &'static AppRouter<AppProps>,
config: &'static picoserve::Config<Duration>,
) -> ! {
Expand Down Expand Up @@ -176,27 +176,21 @@ async fn main(spawner: embassy_executor::Spawner) {

control.init(clm).await;

let stack = make_static!(
embassy_net::Stack::<cyw43::NetDriver>,
embassy_net::Stack::new(
net_device,
embassy_net::Config::ipv4_static(embassy_net::StaticConfigV4 {
address: embassy_net::Ipv4Cidr::new(
embassy_net::Ipv4Address::new(192, 168, 0, 1),
24
),
gateway: None,
dns_servers: Default::default(),
}),
make_static!(
embassy_net::StackResources::<WEB_TASK_POOL_SIZE>,
embassy_net::StackResources::new()
),
embassy_rp::clocks::RoscRng.gen(),
)
let (stack, runner) = embassy_net::new(
net_device,
embassy_net::Config::ipv4_static(embassy_net::StaticConfigV4 {
address: embassy_net::Ipv4Cidr::new(embassy_net::Ipv4Address::new(192, 168, 0, 1), 24),
gateway: None,
dns_servers: Default::default(),
}),
make_static!(
embassy_net::StackResources::<WEB_TASK_POOL_SIZE>,
embassy_net::StackResources::new()
),
embassy_rp::clocks::RoscRng.gen(),
);

spawner.must_spawn(net_task(stack));
spawner.must_spawn(net_task(runner));

control
.start_ap_wpa2(
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ pub async fn listen_and_serve<P: routing::PathRouter<()>>(
task_id: impl LogDisplay,
app: &Router<P, ()>,
config: &Config<embassy_time::Duration>,
stack: &embassy_net::Stack<impl embassy_net::driver::Driver>,
stack: embassy_net::Stack<'_>,
port: u16,
tcp_rx_buffer: &mut [u8],
tcp_tx_buffer: &mut [u8],
Expand All @@ -367,7 +367,7 @@ pub async fn listen_and_serve_with_state<State, P: routing::PathRouter<State>>(
task_id: impl LogDisplay,
app: &Router<P, State>,
config: &Config<embassy_time::Duration>,
stack: &embassy_net::Stack<impl embassy_net::driver::Driver>,
stack: embassy_net::Stack<'_>,
port: u16,
tcp_rx_buffer: &mut [u8],
tcp_tx_buffer: &mut [u8],
Expand Down

0 comments on commit b331742

Please sign in to comment.