diff options
| author | Dario Nieuwenhuis <[email protected]> | 2025-01-12 21:12:04 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-01-12 21:12:04 +0100 |
| commit | dd4f57677c68fbfd53208154d11def4dc4717de9 (patch) | |
| tree | 96db0460097510f22c564a695b602b61bcf96164 | |
| parent | a991cd6a8d4d8a306b225548f4ab31858d6a0535 (diff) | |
| parent | 2ce56e9999287e8dcb9ac8d7a5825f21efba8d21 (diff) | |
Merge pull request #3762 from embassy-rs/net-ppp-release
net ppp release
| -rw-r--r-- | embassy-net-ppp/CHANGELOG.md | 15 | ||||
| -rw-r--r-- | embassy-net-ppp/Cargo.toml | 4 | ||||
| -rw-r--r-- | examples/std/Cargo.toml | 2 | ||||
| -rw-r--r-- | examples/std/src/bin/net_ppp.rs | 52 | ||||
| -rw-r--r-- | examples/std/src/bin/tcp_accept.rs | 17 |
5 files changed, 21 insertions, 69 deletions
diff --git a/embassy-net-ppp/CHANGELOG.md b/embassy-net-ppp/CHANGELOG.md new file mode 100644 index 000000000..6ce64ddcb --- /dev/null +++ b/embassy-net-ppp/CHANGELOG.md | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | # Changelog for embassy-net-ppp | ||
| 2 | |||
| 3 | All notable changes to this project will be documented in this file. | ||
| 4 | |||
| 5 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
| 6 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
| 7 | |||
| 8 | ## 0.2.0 - 2025-01-12 | ||
| 9 | |||
| 10 | - Update `ppproto` to v0.2. | ||
| 11 | - Use `core::net` IP types for IPv4 configuration instead of a custom type. | ||
| 12 | |||
| 13 | ## 0.1.0 - 2024-01-12 | ||
| 14 | |||
| 15 | First release. | ||
diff --git a/embassy-net-ppp/Cargo.toml b/embassy-net-ppp/Cargo.toml index 9c214d5ae..414be5e01 100644 --- a/embassy-net-ppp/Cargo.toml +++ b/embassy-net-ppp/Cargo.toml | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | name = "embassy-net-ppp" | 2 | name = "embassy-net-ppp" |
| 3 | version = "0.1.0" | 3 | version = "0.2.0" |
| 4 | description = "embassy-net driver for PPP over Serial" | 4 | description = "embassy-net driver for PPP over Serial" |
| 5 | keywords = ["embedded", "ppp", "embassy-net", "embedded-hal-async", "async"] | 5 | keywords = ["embedded", "ppp", "embassy-net", "embedded-hal-async", "async"] |
| 6 | categories = ["embedded", "hardware-support", "no-std", "network-programming", "asynchronous"] | 6 | categories = ["embedded", "hardware-support", "no-std", "network-programming", "asynchronous"] |
| @@ -20,7 +20,7 @@ log = { version = "0.4.14", optional = true } | |||
| 20 | embedded-io-async = { version = "0.6.1" } | 20 | embedded-io-async = { version = "0.6.1" } |
| 21 | embassy-net-driver-channel = { version = "0.3.0", path = "../embassy-net-driver-channel" } | 21 | embassy-net-driver-channel = { version = "0.3.0", path = "../embassy-net-driver-channel" } |
| 22 | embassy-futures = { version = "0.1.0", path = "../embassy-futures" } | 22 | embassy-futures = { version = "0.1.0", path = "../embassy-futures" } |
| 23 | ppproto = { version = "0.2.0"} | 23 | ppproto = { version = "0.2.1"} |
| 24 | embassy-sync = { version = "0.6.1", path = "../embassy-sync" } | 24 | embassy-sync = { version = "0.6.1", path = "../embassy-sync" } |
| 25 | 25 | ||
| 26 | [package.metadata.embassy_docs] | 26 | [package.metadata.embassy_docs] |
diff --git a/examples/std/Cargo.toml b/examples/std/Cargo.toml index 44b62a616..3c9b571cd 100644 --- a/examples/std/Cargo.toml +++ b/examples/std/Cargo.toml | |||
| @@ -10,7 +10,7 @@ embassy-executor = { version = "0.7.0", path = "../../embassy-executor", feature | |||
| 10 | embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["log", "std", ] } | 10 | embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["log", "std", ] } |
| 11 | embassy-net = { version = "0.6.0", path = "../../embassy-net", features=[ "log", "medium-ethernet", "medium-ip", "tcp", "udp", "dns", "dhcpv4", "proto-ipv6"] } | 11 | embassy-net = { version = "0.6.0", path = "../../embassy-net", features=[ "log", "medium-ethernet", "medium-ip", "tcp", "udp", "dns", "dhcpv4", "proto-ipv6"] } |
| 12 | embassy-net-tuntap = { version = "0.1.0", path = "../../embassy-net-tuntap" } | 12 | embassy-net-tuntap = { version = "0.1.0", path = "../../embassy-net-tuntap" } |
| 13 | embassy-net-ppp = { version = "0.1.0", path = "../../embassy-net-ppp", features = ["log"]} | 13 | embassy-net-ppp = { version = "0.2.0", path = "../../embassy-net-ppp", features = ["log"]} |
| 14 | embedded-io-async = { version = "0.6.1" } | 14 | embedded-io-async = { version = "0.6.1" } |
| 15 | embedded-io-adapters = { version = "0.6.1", features = ["futures-03"] } | 15 | embedded-io-adapters = { version = "0.6.1", features = ["futures-03"] } |
| 16 | critical-section = { version = "1.1", features = ["std"] } | 16 | critical-section = { version = "1.1", features = ["std"] } |
diff --git a/examples/std/src/bin/net_ppp.rs b/examples/std/src/bin/net_ppp.rs index ea3fbebef..f667e8d4c 100644 --- a/examples/std/src/bin/net_ppp.rs +++ b/examples/std/src/bin/net_ppp.rs | |||
| @@ -45,7 +45,7 @@ async fn net_task(mut runner: embassy_net::Runner<'static, embassy_net_ppp::Devi | |||
| 45 | async fn ppp_task(stack: Stack<'static>, mut runner: Runner<'static>, port: SerialPort) -> ! { | 45 | async fn ppp_task(stack: Stack<'static>, mut runner: Runner<'static>, port: SerialPort) -> ! { |
| 46 | let port = Async::new(port).unwrap(); | 46 | let port = Async::new(port).unwrap(); |
| 47 | let port = BufReader::new(port); | 47 | let port = BufReader::new(port); |
| 48 | let port = adapter::FromFutures::new(port); | 48 | let port = embedded_io_adapters::futures_03::FromFutures::new(port); |
| 49 | 49 | ||
| 50 | let config = embassy_net_ppp::Config { | 50 | let config = embassy_net_ppp::Config { |
| 51 | username: b"myuser", | 51 | username: b"myuser", |
| @@ -163,53 +163,3 @@ fn main() { | |||
| 163 | spawner.spawn(main_task(spawner)).unwrap(); | 163 | spawner.spawn(main_task(spawner)).unwrap(); |
| 164 | }); | 164 | }); |
| 165 | } | 165 | } |
| 166 | |||
| 167 | mod adapter { | ||
| 168 | use core::future::poll_fn; | ||
| 169 | use core::pin::Pin; | ||
| 170 | |||
| 171 | use futures::AsyncBufReadExt; | ||
| 172 | |||
| 173 | /// Adapter from `futures::io` traits. | ||
| 174 | #[derive(Clone)] | ||
| 175 | pub struct FromFutures<T: ?Sized> { | ||
| 176 | inner: T, | ||
| 177 | } | ||
| 178 | |||
| 179 | impl<T> FromFutures<T> { | ||
| 180 | /// Create a new adapter. | ||
| 181 | pub fn new(inner: T) -> Self { | ||
| 182 | Self { inner } | ||
| 183 | } | ||
| 184 | } | ||
| 185 | |||
| 186 | impl<T: ?Sized> embedded_io_async::ErrorType for FromFutures<T> { | ||
| 187 | type Error = std::io::Error; | ||
| 188 | } | ||
| 189 | |||
| 190 | impl<T: futures::io::AsyncRead + Unpin + ?Sized> embedded_io_async::Read for FromFutures<T> { | ||
| 191 | async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> { | ||
| 192 | poll_fn(|cx| Pin::new(&mut self.inner).poll_read(cx, buf)).await | ||
| 193 | } | ||
| 194 | } | ||
| 195 | |||
| 196 | impl<T: futures::io::AsyncBufRead + Unpin + ?Sized> embedded_io_async::BufRead for FromFutures<T> { | ||
| 197 | async fn fill_buf(&mut self) -> Result<&[u8], Self::Error> { | ||
| 198 | self.inner.fill_buf().await | ||
| 199 | } | ||
| 200 | |||
| 201 | fn consume(&mut self, amt: usize) { | ||
| 202 | Pin::new(&mut self.inner).consume(amt) | ||
| 203 | } | ||
| 204 | } | ||
| 205 | |||
| 206 | impl<T: futures::io::AsyncWrite + Unpin + ?Sized> embedded_io_async::Write for FromFutures<T> { | ||
| 207 | async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> { | ||
| 208 | poll_fn(|cx| Pin::new(&mut self.inner).poll_write(cx, buf)).await | ||
| 209 | } | ||
| 210 | |||
| 211 | async fn flush(&mut self) -> Result<(), Self::Error> { | ||
| 212 | poll_fn(|cx| Pin::new(&mut self.inner).poll_flush(cx)).await | ||
| 213 | } | ||
| 214 | } | ||
| 215 | } | ||
diff --git a/examples/std/src/bin/tcp_accept.rs b/examples/std/src/bin/tcp_accept.rs index 5d36b739d..18646a083 100644 --- a/examples/std/src/bin/tcp_accept.rs +++ b/examples/std/src/bin/tcp_accept.rs | |||
| @@ -1,5 +1,3 @@ | |||
| 1 | use core::fmt::Write as _; | ||
| 2 | |||
| 3 | use clap::Parser; | 1 | use clap::Parser; |
| 4 | use embassy_executor::{Executor, Spawner}; | 2 | use embassy_executor::{Executor, Spawner}; |
| 5 | use embassy_net::tcp::TcpSocket; | 3 | use embassy_net::tcp::TcpSocket; |
| @@ -28,16 +26,6 @@ async fn net_task(mut runner: embassy_net::Runner<'static, TunTapDevice>) -> ! { | |||
| 28 | runner.run().await | 26 | runner.run().await |
| 29 | } | 27 | } |
| 30 | 28 | ||
| 31 | #[derive(Default)] | ||
| 32 | struct StrWrite(pub heapless::Vec<u8, 30>); | ||
| 33 | |||
| 34 | impl core::fmt::Write for StrWrite { | ||
| 35 | fn write_str(&mut self, s: &str) -> Result<(), core::fmt::Error> { | ||
| 36 | self.0.extend_from_slice(s.as_bytes()).unwrap(); | ||
| 37 | Ok(()) | ||
| 38 | } | ||
| 39 | } | ||
| 40 | |||
| 41 | #[embassy_executor::task] | 29 | #[embassy_executor::task] |
| 42 | async fn main_task(spawner: Spawner) { | 30 | async fn main_task(spawner: Spawner) { |
| 43 | let opts: Opts = Opts::parse(); | 31 | let opts: Opts = Opts::parse(); |
| @@ -85,9 +73,8 @@ async fn main_task(spawner: Spawner) { | |||
| 85 | 73 | ||
| 86 | // Write some quick output | 74 | // Write some quick output |
| 87 | for i in 1..=5 { | 75 | for i in 1..=5 { |
| 88 | let mut w = StrWrite::default(); | 76 | let s = format!("{}! ", i); |
| 89 | write!(w, "{}! ", i).unwrap(); | 77 | let r = socket.write_all(s.as_bytes()).await; |
| 90 | let r = socket.write_all(&w.0).await; | ||
| 91 | if let Err(e) = r { | 78 | if let Err(e) = r { |
| 92 | warn!("write error: {:?}", e); | 79 | warn!("write error: {:?}", e); |
| 93 | return; | 80 | return; |
