Skip to content

Commit

Permalink
Use patched version of edge-net and embassy-executor
Browse files Browse the repository at this point in the history
- Use the current HEAD of edge-net for the lifetimes fix in edge-http
- Use a patched version for embassy-executor before 0.6.0 was yanked.
  • Loading branch information
AnthonyGrondin committed Nov 4, 2024
1 parent 1873abf commit 88042de
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 30 deletions.
13 changes: 9 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ esp-println = { version = "0.12.0", features = ["log"] }
esp-hal-embassy = { version = "0.4.0", optional = true }

embassy-time = { version = "0.3.0", optional = true }
embassy-executor = { version = "0.6.0", package = "embassy-executor", features = [
embassy-executor = { version = "=0.6.0", package = "embassy-executor", features = [
"nightly",
"integrated-timers",
], optional = true }
Expand Down Expand Up @@ -149,6 +149,11 @@ edge-server = [

# Patch until new release
[patch.crates-io]
edge-http = { git = "https://github.com/ivmarkov/edge-net", rev = "f90468953aec1d476ba52fe3b63f392a07bb9daa" }
edge-nal = { git = "https://github.com/ivmarkov/edge-net", rev = "f90468953aec1d476ba52fe3b63f392a07bb9daa" }
edge-nal-embassy = { git = "https://github.com/ivmarkov/edge-net", rev = "f90468953aec1d476ba52fe3b63f392a07bb9daa" }
edge-http = { git = "https://github.com/ivmarkov/edge-net", rev = "722f92ac0fffd0cb1e1ce76086cca58df6eb49ee" }
edge-nal = { git = "https://github.com/ivmarkov/edge-net", rev = "722f92ac0fffd0cb1e1ce76086cca58df6eb49ee" }
edge-nal-embassy = { git = "https://github.com/ivmarkov/edge-net", rev = "722f92ac0fffd0cb1e1ce76086cca58df6eb49ee" }

# Patch before 0.6.0 got yanked
embassy-executor = { git = "https://github.com/embassy-rs/embassy", rev = "886580179ff250e15b0fad6448e8ebed6cdabf2b" }
embassy-time-driver = { git = "https://github.com/embassy-rs/embassy", rev = "886580179ff250e15b0fad6448e8ebed6cdabf2b" }
embassy-time-queue-driver = { git = "https://github.com/embassy-rs/embassy", rev = "886580179ff250e15b0fad6448e8ebed6cdabf2b" }
43 changes: 17 additions & 26 deletions examples/edge_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use edge_http::io::Error;
use edge_http::Method;
use edge_nal_embassy::{Tcp, TcpBuffers};

use embedded_io_async::{ErrorType, Read, Write};
use embedded_io_async::{Read, Write};

use embassy_net::{Config, Stack, StackResources};

Expand All @@ -34,7 +34,7 @@ use esp_wifi::wifi::{
WifiState,
};
use esp_wifi::{init, EspWifiInitFor};
use hal::{peripherals::SHA, prelude::*, rng::Rng, timer::timg::TimerGroup};
use hal::{prelude::*, rng::Rng, timer::timg::TimerGroup};

// Patch until https://github.com/embassy-rs/static-cell/issues/16 is fixed
macro_rules! mk_static {
Expand Down Expand Up @@ -144,16 +144,10 @@ async fn main(spawner: Spawner) -> ! {

set_debug(0);

let server = mk_static!(HttpsServer, HttpsServer::new());
let buffers = mk_static!(TcpBuffers<SERVER_SOCKETS, TX_SIZE, RX_SIZE>, TcpBuffers::<SERVER_SOCKETS, TX_SIZE, RX_SIZE>::new());
let tls_buffers = mk_static!(
esp_mbedtls::asynch::TlsBuffers::<RX_SIZE, TX_SIZE>,
esp_mbedtls::asynch::TlsBuffers::<RX_SIZE, TX_SIZE>::new()
);
let tcp = mk_static!(
Tcp<'_, WifiDevice<'_, WifiStaDevice>, SERVER_SOCKETS, TX_SIZE, RX_SIZE>,
Tcp::new(stack, buffers)
);
let mut server = HttpsServer::new();
let buffers = TcpBuffers::<SERVER_SOCKETS, TX_SIZE, RX_SIZE>::new();
let tls_buffers = esp_mbedtls::asynch::TlsBuffers::<RX_SIZE, TX_SIZE>::new();
let tcp = Tcp::new(stack, &buffers);

let certificates = Certificates {
// Use self-signed certificates
Expand All @@ -164,16 +158,14 @@ async fn main(spawner: Spawner) -> ! {
..Default::default()
};

let sha = mk_static!(SHA, peripherals.SHA);

loop {
let tls_acceptor = esp_mbedtls::asynch::TlsAcceptor::new(
tcp,
tls_buffers,
&tcp,
&tls_buffers,
443,
TlsVersion::Tls1_2,
certificates,
&mut *sha,
&mut peripherals.SHA,
)
.await
.with_hardware_rsa(&mut peripherals.RSA);
Expand All @@ -198,18 +190,17 @@ async fn main(spawner: Spawner) -> ! {

struct HttpHandler;

impl<'b, T, const N: usize> Handler<'b, T, N> for HttpHandler
where
T: Read + Write,
T::Error: Send + Sync,
{
type Error = Error<<T as ErrorType>::Error>;
impl Handler for HttpHandler {
type Error<E> = Error<E> where E: core::fmt::Debug;

async fn handle(
async fn handle<T, const N: usize>(
&self,
_task_id: impl core::fmt::Display + Copy,
connection: &mut Connection<'b, T, N>,
) -> Result<(), Self::Error> {
connection: &mut Connection<'_, T, N>,
) -> Result<(), Self::Error<T::Error>>
where
T: Read + Write,
{
println!("Got new connection");
let headers = connection.headers()?;

Expand Down

0 comments on commit 88042de

Please sign in to comment.