Skip to content

Commit dd4f576

Browse files
authored
Merge pull request #3762 from embassy-rs/net-ppp-release
net ppp release
2 parents a991cd6 + 2ce56e9 commit dd4f576

File tree

5 files changed

+21
-69
lines changed

5 files changed

+21
-69
lines changed

embassy-net-ppp/CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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.

embassy-net-ppp/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "embassy-net-ppp"
3-
version = "0.1.0"
3+
version = "0.2.0"
44
description = "embassy-net driver for PPP over Serial"
55
keywords = ["embedded", "ppp", "embassy-net", "embedded-hal-async", "async"]
66
categories = ["embedded", "hardware-support", "no-std", "network-programming", "asynchronous"]
@@ -20,7 +20,7 @@ log = { version = "0.4.14", optional = true }
2020
embedded-io-async = { version = "0.6.1" }
2121
embassy-net-driver-channel = { version = "0.3.0", path = "../embassy-net-driver-channel" }
2222
embassy-futures = { version = "0.1.0", path = "../embassy-futures" }
23-
ppproto = { version = "0.2.0"}
23+
ppproto = { version = "0.2.1"}
2424
embassy-sync = { version = "0.6.1", path = "../embassy-sync" }
2525

2626
[package.metadata.embassy_docs]

examples/std/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ embassy-executor = { version = "0.7.0", path = "../../embassy-executor", feature
1010
embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["log", "std", ] }
1111
embassy-net = { version = "0.6.0", path = "../../embassy-net", features=[ "log", "medium-ethernet", "medium-ip", "tcp", "udp", "dns", "dhcpv4", "proto-ipv6"] }
1212
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"]}
1414
embedded-io-async = { version = "0.6.1" }
1515
embedded-io-adapters = { version = "0.6.1", features = ["futures-03"] }
1616
critical-section = { version = "1.1", features = ["std"] }

examples/std/src/bin/net_ppp.rs

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ async fn net_task(mut runner: embassy_net::Runner<'static, embassy_net_ppp::Devi
4545
async fn ppp_task(stack: Stack<'static>, mut runner: Runner<'static>, port: SerialPort) -> ! {
4646
let port = Async::new(port).unwrap();
4747
let port = BufReader::new(port);
48-
let port = adapter::FromFutures::new(port);
48+
let port = embedded_io_adapters::futures_03::FromFutures::new(port);
4949

5050
let config = embassy_net_ppp::Config {
5151
username: b"myuser",
@@ -163,53 +163,3 @@ fn main() {
163163
spawner.spawn(main_task(spawner)).unwrap();
164164
});
165165
}
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-
}

examples/std/src/bin/tcp_accept.rs

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
use core::fmt::Write as _;
2-
31
use clap::Parser;
42
use embassy_executor::{Executor, Spawner};
53
use embassy_net::tcp::TcpSocket;
@@ -28,16 +26,6 @@ async fn net_task(mut runner: embassy_net::Runner<'static, TunTapDevice>) -> ! {
2826
runner.run().await
2927
}
3028

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-
4129
#[embassy_executor::task]
4230
async fn main_task(spawner: Spawner) {
4331
let opts: Opts = Opts::parse();
@@ -85,9 +73,8 @@ async fn main_task(spawner: Spawner) {
8573

8674
// Write some quick output
8775
for i in 1..=5 {
88-
let mut w = StrWrite::default();
89-
write!(w, "{}! ", i).unwrap();
90-
let r = socket.write_all(&w.0).await;
76+
let s = format!("{}! ", i);
77+
let r = socket.write_all(s.as_bytes()).await;
9178
if let Err(e) = r {
9279
warn!("write error: {:?}", e);
9380
return;

0 commit comments

Comments
 (0)