diff --git a/Cargo.lock b/Cargo.lock index 02db9bd37..37355a4e4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -426,6 +426,12 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "const-sha1" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d8a42181e0652c2997ae4d217f25b63c5337a52fd2279736e97b832fa0a3cff" + [[package]] name = "const_panic" version = "0.2.8" @@ -1991,11 +1997,14 @@ dependencies = [ [[package]] name = "picoserve" -version = "0.3.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab20855a694e13dddfd360685e5bc78fb28cef2581237e6c83f91c79a59aa6da" +checksum = "912e6e8713f815d30bb77fa052cc8036a2b6429dc436969311fad47705fe0f2a" dependencies = [ + "const-sha1", "data-encoding", + "embassy-net", + "embassy-time", "embedded-io-async", "futures-util", "heapless 0.8.0", @@ -2235,7 +2244,7 @@ dependencies = [ "coap-message", "coap-numbers", "embedded-graphics", - "embedded-hal 0.2.7", + "embedded-hal 1.0.0", "heapless 0.7.17", "minicbor", "riot-sys", diff --git a/examples/embassy-http-server/Cargo.toml b/examples/embassy-http-server/Cargo.toml index 8300a1fee..6c103f57e 100644 --- a/examples/embassy-http-server/Cargo.toml +++ b/examples/embassy-http-server/Cargo.toml @@ -15,7 +15,7 @@ embassy-net = { workspace = true, features = ["tcp"] } embedded-io-async = "0.6.0" heapless = { workspace = true } httparse = { version = "1.8.0", default-features = false } -picoserve = "0.3.0" +picoserve = { version = "0.8.0", default-features = false, features = ["embassy"] } static_cell = { workspace = true } serde = { version = "1.0", default-features = false } diff --git a/examples/embassy-http-server/laze.yml b/examples/embassy-http-server/laze.yml index ae8ddaa16..7e75a480f 100644 --- a/examples/embassy-http-server/laze.yml +++ b/examples/embassy-http-server/laze.yml @@ -1,5 +1,9 @@ apps: - name: embassy-http-server + env: + global: + CARGO_ENV: + - CONFIG_ISR_STACKSIZE=16384 selects: - ?release - network diff --git a/examples/embassy-http-server/src/main.rs b/examples/embassy-http-server/src/main.rs index db62e85f2..aa53bd713 100644 --- a/examples/embassy-http-server/src/main.rs +++ b/examples/embassy-http-server/src/main.rs @@ -23,21 +23,6 @@ use static_cell::make_static; #[cfg(feature = "button-readings")] use embassy_nrf::gpio::{Input, Pin, Pull}; -struct EmbassyTimer; - -impl picoserve::Timer for EmbassyTimer { - type Duration = embassy_time::Duration; - type TimeoutError = embassy_time::TimeoutError; - - async fn run_with_timeout( - &mut self, - duration: Self::Duration, - future: F, - ) -> Result { - embassy_time::with_timeout(duration, future).await - } -} - struct AppState { #[cfg(feature = "button-readings")] buttons: ButtonInputs, @@ -86,30 +71,15 @@ async fn web_task( continue; } - println!( - "{}: Received connection from {:?}", - id, - socket.remote_endpoint() - ); - - let (socket_rx, socket_tx) = socket.split(); - - match picoserve::serve_with_state( - app, - EmbassyTimer, - config, - &mut [0; 2048], - socket_rx, - socket_tx, - &state, - ) - .await - { + let remote_endpoint = socket.remote_endpoint(); + + println!("{}: Received connection from {:?}", id, remote_endpoint); + + match picoserve::serve_with_state(app, config, &mut [0; 2048], socket, &state).await { Ok(handled_requests_count) => { println!( "{} requests handled from {:?}", - handled_requests_count, - socket.remote_endpoint() + handled_requests_count, remote_endpoint, ); } Err(err) => println!("{:?}", err), @@ -159,11 +129,11 @@ impl Application for WebServer { let app = make_static!(make_app()); - let config = make_static!(picoserve::Config { - start_read_request_timeout: Some(Duration::from_secs(5)), - read_request_timeout: Some(Duration::from_secs(1)), - write_timeout: Some(Duration::from_secs(1)), - }); + let config = make_static!(picoserve::Config::new(picoserve::Timeouts { + start_read_request: Some(Duration::from_secs(5)), + read_request: Some(Duration::from_secs(1)), + write: Some(Duration::from_secs(1)), + })); for id in 0..WEB_TASK_POOL_SIZE { let app_state = AppState {