Skip to content

Commit

Permalink
deps: update picoserve to 0.8.0
Browse files Browse the repository at this point in the history
picoserve now seems to require a larger stack.
  • Loading branch information
ROMemories authored and kaspar030 committed Feb 13, 2024
1 parent 4372796 commit c06fdc1
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 45 deletions.
15 changes: 12 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/embassy-http-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down
4 changes: 4 additions & 0 deletions examples/embassy-http-server/laze.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
apps:
- name: embassy-http-server
env:
global:
CARGO_ENV:
- CONFIG_ISR_STACKSIZE=16384
selects:
- ?release
- network
Expand Down
52 changes: 11 additions & 41 deletions examples/embassy-http-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<F: core::future::Future>(
&mut self,
duration: Self::Duration,
future: F,
) -> Result<F::Output, Self::TimeoutError> {
embassy_time::with_timeout(duration, future).await
}
}

struct AppState {
#[cfg(feature = "button-readings")]
buttons: ButtonInputs,
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit c06fdc1

Please sign in to comment.