Skip to content

Commit

Permalink
Update esp-wifi, tls and reqwless
Browse files Browse the repository at this point in the history
  • Loading branch information
bugadani committed Oct 16, 2023
1 parent 915e3e4 commit 8aeecf1
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 39 deletions.
15 changes: 12 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,17 @@ embedded-graphics = "0.8.0"
embedded-hal = "1.0.0-rc.1"
embedded-hal-async = "1.0.0-rc.1"
embedded-hal-bus = { version = "0.1.0-rc.1", features = ["async"] }
embedded-nal-async = "0.4.0"
embedded-nal-async = "0.6.0"
embedded-io = { version = "0.4", features = ["async"] }
embedded-io-new = { package = "embedded-io", version = "0.6" }
embedded-io-async = { version = "0.6" }
embedded-menu = "0.5.2"
embedded-svc = { version = "0.25", default-features = false }
embassy-net = { version = "0.1.0", features = [
embassy-net = { version = "0.2.0", features = [
"nightly",
"tcp",
"dhcpv4",
"dns",
"unstable-traits",
"medium-ethernet",
] }
embassy-sync = { version = "0.2.0" }
Expand Down Expand Up @@ -56,6 +57,7 @@ embassy-executor = { workspace = true }
embassy-time = { version = "0.1.3", features = ["nightly", "unstable-traits"] }

embedded-hal-old = { package = "embedded-hal", version = "0.2.7" }
embedded-io-async = { workspace = true }

# esp32s2-hal = { version = "0.10.0", optional = true, features = ["rt", "async", "embassy", "embassy-time-systick", "eh1"] }
esp32s3-hal = { version = "0.12.0", optional = true, features = [
Expand Down Expand Up @@ -146,8 +148,15 @@ esp32s3-hal = { git = "https://github.com/esp-rs/esp-hal.git", rev = "44e968f7a8
# embedded-text = { git = "https://github.com/embedded-graphics/embedded-text.git" }
# esp32s3-hal = { path = "../../esp-hal/esp32s3-hal" }
# esp-hal-common = { path = "../../esp-hal/esp-hal-common" }
embedded-tls = { git = "https://github.com/drogue-iot/embedded-tls.git", branch = "old" }
reqwless = { git = "https://github.com/bugadani/reqwless.git", branch = "old" }
buffered-io = { git = "https://github.com/bugadani/buffered-io.git", branch = "old" }
embassy-time = { git = "https://github.com/bugadani/embassy.git", branch = "old" }
embassy-net = { git = "https://github.com/bugadani/embassy.git", branch = "old" }
embassy-net-driver = { git = "https://github.com/bugadani/embassy.git", branch = "old" }

[patch.'https://github.com/esp-rs/esp-wifi.git']
# esp-wifi = { git = "https://github.com/bugadani/esp-wifi.git", branch = "embassy" }
esp-wifi = { path = "../esp-wifi/esp-wifi" }

[features]
Expand Down
3 changes: 2 additions & 1 deletion bad-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ edition = "2021"
async-io = { version = "1", optional = true }
defmt = { workspace = true, optional = true }
embassy-net = { workspace = true, optional = true }
embedded-io = { workspace = true }
embedded-io-new = { workspace = true }
embedded-io-async = { workspace = true }
embedded-svc = { workspace = true }
heapless = { workspace = true, features = ["ufmt-impl"] }
httparse = { version = "1.8", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion bad-server/src/connector.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use core::fmt::Debug;

use embedded_io::asynch::{Read, Write};
use embedded_io_async::{Read, Write};

pub trait Connection: Read + Write {
#[cfg(feature = "defmt")]
Expand Down
2 changes: 1 addition & 1 deletion bad-server/src/error_handler.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use core::marker::PhantomData;

use embedded_io::asynch::Write;
use embedded_io_async::Write;
use ufmt::uwrite;

use crate::{
Expand Down
14 changes: 6 additions & 8 deletions bad-server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ extern crate logger;

use core::{fmt::Debug, marker::PhantomData};

use embedded_io::{
asynch::{Read, Write as _},
Io,
};
use embedded_io_async::{Read, Write as _};
use embedded_io_new::ErrorType;
use httparse::Status;
use object_chain::{Chain, ChainElement, Link};

Expand Down Expand Up @@ -123,23 +121,23 @@ where
}
}

pub enum HandleError<C: Io> {
pub enum HandleError<C: ErrorType> {
Read(ReadError<C>),
Write(C::Error),
TooManyHeaders,
InternalError,
RequestParse(httparse::Error),
}

impl<C: Io> From<ReadError<C>> for HandleError<C> {
impl<C: ErrorType> From<ReadError<C>> for HandleError<C> {
fn from(value: ReadError<C>) -> Self {
HandleError::Read(value)
}
}

impl<C> Debug for HandleError<C>
where
C: Io,
C: ErrorType,
{
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
match self {
Expand All @@ -155,7 +153,7 @@ where
#[cfg(feature = "defmt")]
impl<C> defmt::Format for HandleError<C>
where
C: Io,
C: ErrorType,
C::Error: defmt::Format,
{
fn format(&self, f: defmt::Formatter) {
Expand Down
8 changes: 4 additions & 4 deletions bad-server/src/request_body.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use embedded_io::{blocking::ReadExactError, Io};
use embedded_io_new::{ErrorType, ReadExactError};
use httparse::Header;

use crate::{connector::Connection, response::ResponseStatus};
Expand Down Expand Up @@ -185,7 +185,7 @@ impl<'buf, 's, C: Connection> ContentLengthReader<'buf, 's, C> {

pub enum ReadError<C>
where
C: Io,
C: ErrorType,
{
Io(C::Error),
Encoding,
Expand All @@ -194,7 +194,7 @@ where

impl<C> core::fmt::Debug for ReadError<C>
where
C: Io,
C: ErrorType,
{
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
match self {
Expand All @@ -208,7 +208,7 @@ where
#[cfg(feature = "defmt")]
impl<C> defmt::Format for ReadError<C>
where
C: Io,
C: ErrorType,
C::Error: defmt::Format,
{
fn format(&self, f: defmt::Formatter) {
Expand Down
4 changes: 2 additions & 2 deletions bad-server/src/response.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use core::marker::PhantomData;

use embedded_io::Io;
use embedded_io_new::ErrorType;
use httparse::Header;
use ufmt::uwrite;

Expand Down Expand Up @@ -131,7 +131,7 @@ impl<'s, C: Connection> Response<'s, C, Headers> {
async fn send<C: Connection>(
socket: &mut C,
header: Header<'_>,
) -> Result<(), <C as Io>::Error> {
) -> Result<(), <C as ErrorType>::Error> {
socket.write_all(header.name.as_bytes()).await?;
socket.write_all(b": ").await?;
socket.write_all(header.value).await?;
Expand Down
5 changes: 1 addition & 4 deletions src/board/wifi/ap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,7 @@ async fn ap_task(
info!("Wifi started!");

loop {
if let WifiStackState::ApStart
| WifiStackState::ApStaConnected
| WifiStackState::ApStaDisconnected = esp_wifi::wifi::get_wifi_state()
{
if let WifiStackState::ApStart = esp_wifi::wifi::get_wifi_state() {
let events = controller
.wait_for_events(
WifiEvent::ApStop
Expand Down
13 changes: 1 addition & 12 deletions src/board/wifi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,16 +258,5 @@ impl WifiDriver {

#[cardio::task]
async fn net_task(stack: Rc<StackWrapper>, mut task_control: TaskControlToken<!>) {
task_control
.run_cancellable(|_| async {
select(stack.run(), async {
// HACK: force polling the interface in case some write operation doesn't wake it up
loop {
DelayTimer::after(Duration::from_secs(1)).await;
}
})
.await;
unreachable!()
})
.await;
task_control.run_cancellable(|_| stack.run()).await;
}
2 changes: 1 addition & 1 deletion src/states/firmware_update.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use embassy_time::{Duration, Instant};
use embedded_io::asynch::Read;
use embedded_io_async::Read;
use reqwless::{request::Method, response::Status};
use ufmt::uwrite;

Expand Down
2 changes: 1 addition & 1 deletion src/states/throughput.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use embassy_futures::select::{select, Either};
use embassy_time::{Duration, Instant};
use embedded_io::asynch::Read;
use embedded_io_async::Read;
use reqwless::{request::Method, response::Status};
use ufmt::{uwrite, uwriteln};

Expand Down
2 changes: 1 addition & 1 deletion src/states/upload_or_store_measurement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ impl RequestBody for MeasurementRef<'_> {
Some(self.buffer.len() + 4)
}

async fn write<W: embedded_io::asynch::Write>(&self, writer: &mut W) -> Result<(), W::Error> {
async fn write<W: embedded_io_async::Write>(&self, writer: &mut W) -> Result<(), W::Error> {
writer.write_all(&self.version.to_le_bytes()).await?;
writer.write_all(self.buffer).await?;

Expand Down

0 comments on commit 8aeecf1

Please sign in to comment.