Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ jobs:
- name: Build | Fmt Check
run: cargo fmt -- --check
- name: Build | Clippy
run: cargo clippy --features std,embedded-svc,edge-nal-embassy --examples --no-deps -- -Dwarnings
run: cargo clippy --features std,embedded-svc,edge-nal-embassy/all --examples --no-deps -- -Dwarnings
- name: Build | Clippy - defmt
run: cargo clippy --features std,embedded-svc,edge-nal-embassy,defmt --no-deps -- -Dwarnings
run: cargo clippy --features std,embedded-svc,edge-nal-embassy/all,defmt --no-deps -- -Dwarnings
- name: Build | Clippy - log
run: cargo clippy --features std,embedded-svc,edge-nal-embassy,log --examples --no-deps -- -Dwarnings
run: cargo clippy --features std,embedded-svc,edge-nal-embassy/all,log --examples --no-deps -- -Dwarnings
- name: Build | Default
run: cargo build --features log
- name: Build | Non-default
Expand Down
22 changes: 11 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "edge-net"
version = "0.10.1"
version = "0.11.0"
authors = ["Ivan Markov <[email protected]>"]
edition = "2021"
categories = ["embedded", "hardware-support", "network-programming", "asynchronous"]
Expand All @@ -15,7 +15,7 @@ rust-version = "1.83"
default = ["io"]
async-io-mini = ["std", "edge-nal-std/async-io-mini"]
std = ["io", "edge-captive/std", "edge-dhcp/std", "edge-http/std", "edge-mdns/std", "edge-raw/std", "edge-mqtt", "edge-ws/std", "edge-nal-std"]
embassy = ["io", "edge-nal-embassy"]
embassy = ["io", "edge-nal-embassy/all"]
io = ["edge-captive/io", "edge-dhcp/io", "edge-http/io", "edge-mdns/io", "edge-raw/io", "edge-ws/io", "edge-nal"]
log = ["edge-captive/log", "edge-dhcp/log", "edge-http/log", "edge-mdns/log", "edge-raw/log", "edge-ws/log", "edge-nal-embassy?/log"]
defmt = ["edge-captive/defmt", "edge-dhcp/defmt", "edge-http/defmt", "edge-mdns/defmt", "edge-raw/defmt", "edge-ws/defmt", "edge-nal-embassy?/defmt"]
Expand All @@ -40,7 +40,7 @@ anyhow = "1"
env_logger = "0.10"
embedded-io-async = "0.6"
embassy-time = { version = "0.4", features = ["std", "generic-queue-64"] }
embassy-sync = "0.6"
embassy-sync = "0.7"
embassy-futures = "0.1"
embedded-svc = { version = "0.28", features = ["std"] }
futures-lite = "2"
Expand Down Expand Up @@ -109,20 +109,20 @@ members = [

[workspace.dependencies]
embassy-futures = { version = "0.1", default-features = false }
embassy-sync = { version = "0.6", default-features = false }
embassy-sync = { version = "0.7", default-features = false }
embassy-time = { version = "0.4", default-features = false }
embedded-io-async = { version = "0.6", default-features = false }
embedded-svc = { version = "0.28", default-features = false }
heapless = { version = "0.8", default-features = false }
domain = { version = "0.10", default-features = false, features = ["heapless"] }

edge-captive = { version = "0.5.0", path = "edge-captive", default-features = false }
edge-dhcp = { version = "0.5.0", path = "edge-dhcp", default-features = false }
edge-http = { version = "0.5.1", path = "edge-http", default-features = false }
edge-mdns = { version = "0.5.0", path = "edge-mdns", default-features = false }
edge-captive = { version = "0.6.0", path = "edge-captive", default-features = false }
edge-dhcp = { version = "0.6.0", path = "edge-dhcp", default-features = false }
edge-http = { version = "0.6.0", path = "edge-http", default-features = false }
edge-mdns = { version = "0.6.0", path = "edge-mdns", default-features = false }
edge-mqtt = { version = "0.4.0", path = "edge-mqtt", default-features = false }
edge-nal = { version = "0.5.0", path = "edge-nal", default-features = false }
edge-raw = { version = "0.5.0", path = "edge-raw", default-features = false }
edge-ws = { version = "0.4.0", path = "edge-ws", default-features = false }
edge-raw = { version = "0.6.0", path = "edge-raw", default-features = false }
edge-ws = { version = "0.5.0", path = "edge-ws", default-features = false }
edge-nal-std = { version = "0.5.0", path = "edge-nal-std", default-features = false }
edge-nal-embassy = { version = "0.5.0", path = "edge-nal-embassy", default-features = false }
edge-nal-embassy = { version = "0.6.0", path = "edge-nal-embassy", default-features = false }
2 changes: 1 addition & 1 deletion edge-captive/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [0.6.0] - 2025-05-29
* Optional `defmt` support via two new features (one has to specify one, or the other, or neither, but not both):
* `log` - uses the `log` crate for all logging
* `defmt` - uses the `defmt` crate for all logging, and implements `defmt::Format` for all library types that otherwise implement `Debug` and/or `Display`
Expand Down
2 changes: 1 addition & 1 deletion edge-captive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "edge-captive"
version = "0.5.0"
version = "0.6.0"
edition = "2021"
rust-version = "1.83"
description = "Async + `no_std` + no-alloc implementation of a Captive Portal DNS"
Expand Down
2 changes: 2 additions & 0 deletions edge-captive/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![warn(clippy::large_futures)]
#![allow(clippy::uninlined_format_args)]
#![allow(unknown_lints)]

use core::fmt::Display;
use core::time::Duration;
Expand Down
2 changes: 1 addition & 1 deletion edge-dhcp/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [0.6.0] - 2025-05-29
* Optional `defmt` support via two new features (one has to specify one, or the other, or neither, but not both):
* `log` - uses the `log` crate for all logging
* `defmt` - uses the `defmt` crate for all logging, and implements `defmt::Format` for all library types that otherwise implement `Debug` and/or `Display`
Expand Down
2 changes: 1 addition & 1 deletion edge-dhcp/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "edge-dhcp"
version = "0.5.0"
version = "0.6.0"
edition = "2021"
rust-version = "1.83"
description = "Async + `no_std` + no-alloc implementation of the DHCP protocol"
Expand Down
2 changes: 2 additions & 0 deletions edge-dhcp/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![warn(clippy::large_futures)]
#![allow(clippy::uninlined_format_args)]
#![allow(unknown_lints)]

/// This code is a `no_std` and no-alloc modification of https://github.com/krolaw/dhcp4r
use core::str::Utf8Error;
Expand Down
2 changes: 1 addition & 1 deletion edge-http/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [0.6.0] - 2025-05-29
* Optional `defmt` support via two new features (one has to specify one, or the other, or neither, but not both):
* `log` - uses the `log` crate for all logging
* `defmt` - uses the `defmt` crate for all logging, and implements `defmt::Format` for all library types that otherwise implement `Debug` and/or `Display`
Expand Down
2 changes: 1 addition & 1 deletion edge-http/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "edge-http"
version = "0.5.1"
version = "0.6.0"
edition = "2021"
rust-version = "1.83"
description = "Async + `no_std` + no-alloc implementation of the HTTP protocol"
Expand Down
2 changes: 2 additions & 0 deletions edge-http/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![allow(async_fn_in_trait)]
#![warn(clippy::large_futures)]
#![allow(clippy::uninlined_format_args)]
#![allow(unknown_lints)]

use core::fmt::Display;
use core::str;
Expand Down
2 changes: 1 addition & 1 deletion edge-mdns/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [0.6.0] - 2025-05-29
* Optional `defmt` support via two new features (one has to specify one, or the other, or neither, but not both):
* `log` - uses the `log` crate for all logging
* `defmt` - uses the `defmt` crate for all logging, and implements `defmt::Format` for all library types that otherwise implement `Debug` and/or `Display`
Expand Down
2 changes: 1 addition & 1 deletion edge-mdns/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "edge-mdns"
version = "0.5.0"
version = "0.6.0"
edition = "2021"
description = "Async + `no_std` + no-alloc implementation of an mDNS responder"
repository = "https://github.com/ivmarkov/edge-net"
Expand Down
2 changes: 2 additions & 0 deletions edge-mdns/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![warn(clippy::large_futures)]
#![allow(async_fn_in_trait)]
#![allow(clippy::uninlined_format_args)]
#![allow(unknown_lints)]

use core::cmp::Ordering;
use core::fmt::Display;
Expand Down
2 changes: 2 additions & 0 deletions edge-mqtt/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![warn(clippy::large_futures)]
#![allow(clippy::uninlined_format_args)]
#![allow(unknown_lints)]

pub mod io;
4 changes: 3 additions & 1 deletion edge-nal-embassy/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [0.6.0] - 2025-05-29
* Optional `defmt` support via two new features (one has to specify one, or the other, or neither, but not both):
* `log` - uses the `log` crate for all logging
* `defmt` - uses the `defmt` crate for all logging, and implements `defmt::Format` for all library types that otherwise implement `Debug` and/or `Display`
* Updated to `embassy-net` 0.7
* Re-export all `embassy-net` features as `edge-nal-embassy` features; `all` feature that enables all features of `embassy-net`

## [0.5.0] - 2025-01-15
* Updated dependencies for compatibility with `embassy-time-driver` v0.2
Expand Down
26 changes: 15 additions & 11 deletions edge-nal-embassy/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "edge-nal-embassy"
version = "0.5.0"
version = "0.6.0"
edition = "2021"
rust-version = "1.83"
description = "An implementation of edge-nal based on `embassy-net`"
Expand All @@ -15,22 +15,26 @@ categories = [
]

[features]
default = ["all"]
all = ["proto-ipv4", "proto-ipv6", "medium-ethernet", "medium-ip", "dns", "udp", "tcp", "multicast", "icmp", "dhcpv4", "dhcpv4-hostname"]
defmt = ["dep:defmt", "heapless/defmt-03", "embassy-net/defmt"]
proto-ipv4 = ["embassy-net/proto-ipv4"]
proto-ipv6 = ["embassy-net/proto-ipv6"]
medium-ethernet = ["embassy-net/medium-ethernet"]
medium-ip = ["embassy-net/medium-ip"]
dns = ["embassy-net/dns"]
udp = ["embassy-net/udp"]
tcp = ["embassy-net/tcp"]
icmp = ["embassy-net/icmp"]
multicast = ["embassy-net/multicast"]
dhcpv4 = ["embassy-net/dhcpv4"]
dhcpv4-hostname = ["embassy-net/dhcpv4-hostname"]

[dependencies]
log = { version = "0.4", default-features = false, optional = true }
defmt = { version = "0.3", optional = true }
embedded-io-async = { workspace = true }
edge-nal = { workspace = true }
heapless = { workspace = true }
# Do not require these features and conditionalize the code instead
embassy-net = { version = "0.6", features = [
"tcp",
"udp",
"dns",
"proto-ipv6",
"medium-ethernet",
"proto-ipv4",
"multicast",
] }
embassy-net = "0.7"
embassy-futures = { workspace = true }
53 changes: 34 additions & 19 deletions edge-nal-embassy/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
#![no_std]
#![allow(async_fn_in_trait)]
#![warn(clippy::large_futures)]
#![allow(clippy::uninlined_format_args)]
#![allow(unknown_lints)]

use core::cell::{Cell, UnsafeCell};
use core::mem::MaybeUninit;
use core::net::SocketAddr;
use core::net::{IpAddr, SocketAddr};
use core::ptr::NonNull;

use embassy_net::{IpEndpoint, IpListenEndpoint};
use embassy_net::{IpAddress, IpEndpoint, IpListenEndpoint};

#[cfg(feature = "dns")]
pub use dns::*;
#[cfg(feature = "tcp")]
pub use tcp::*;
#[cfg(feature = "udp")]
pub use udp::*;

// This mod MUST go first, so that the others see its macros.
pub(crate) mod fmt;

#[cfg(feature = "dns")]
mod dns;
#[cfg(feature = "tcp")]
mod tcp;
#[cfg(feature = "udp")]
mod udp;

pub(crate) struct Pool<T, const N: usize> {
Expand Down Expand Up @@ -66,26 +74,33 @@ pub(crate) fn to_net_socket(socket: IpEndpoint) -> SocketAddr {
SocketAddr::new(socket.addr.into(), socket.port)
}

// pub(crate) fn to_net_socket2(socket: IpListenEndpoint) -> SocketAddr {
// SocketAddr::new(
// socket
// .addr
// .map(to_net_addr)
// .unwrap_or(IpAddr::V6(Ipv6Addr::UNSPECIFIED)),
// socket.port,
// )
// }

pub(crate) fn to_emb_socket(socket: SocketAddr) -> IpEndpoint {
IpEndpoint {
addr: socket.ip().into(),
pub(crate) fn to_emb_socket(socket: SocketAddr) -> Option<IpEndpoint> {
Some(IpEndpoint {
addr: to_emb_addr(socket.ip())?,
port: socket.port(),
}
})
}

pub(crate) fn to_emb_bind_socket(socket: SocketAddr) -> IpListenEndpoint {
IpListenEndpoint {
addr: (!socket.ip().is_unspecified()).then(|| socket.ip().into()),
pub(crate) fn to_emb_bind_socket(socket: SocketAddr) -> Option<IpListenEndpoint> {
let addr = if socket.ip().is_unspecified() {
None
} else {
Some(to_emb_addr(socket.ip())?)
};

Some(IpListenEndpoint {
addr,
port: socket.port(),
})
}

pub(crate) fn to_emb_addr(addr: IpAddr) -> Option<IpAddress> {
match addr {
#[cfg(feature = "proto-ipv4")]
IpAddr::V4(addr) => Some(addr.into()),
#[cfg(feature = "proto-ipv6")]
IpAddr::V6(addr) => Some(addr.into()),
#[allow(unreachable_patterns)]
_ => None,
}
}
12 changes: 10 additions & 2 deletions edge-nal-embassy/src/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ impl<const N: usize, const TX_SZ: usize, const RX_SZ: usize> TcpConnect
async fn connect(&self, remote: SocketAddr) -> Result<Self::Socket<'_>, Self::Error> {
let mut socket = TcpSocket::new(self.stack, self.buffers)?;

socket.socket.connect(to_emb_socket(remote)).await?;
socket
.socket
.connect(to_emb_socket(remote).ok_or(TcpError::UnsupportedProto)?)
.await?;

Ok(socket)
}
Expand Down Expand Up @@ -82,7 +85,10 @@ impl<const N: usize, const TX_SZ: usize, const RX_SZ: usize> edge_nal::TcpAccept
async fn accept(&self) -> Result<(SocketAddr, Self::Socket<'_>), Self::Error> {
let mut socket = TcpSocket::new(self.stack.stack, self.stack.buffers)?;

socket.socket.accept(to_emb_bind_socket(self.local)).await?;
socket
.socket
.accept(to_emb_bind_socket(self.local).ok_or(TcpError::UnsupportedProto)?)
.await?;

let local_endpoint = unwrap!(socket.socket.local_endpoint());

Expand Down Expand Up @@ -286,6 +292,7 @@ pub enum TcpError {
Connect(ConnectError),
Accept(AcceptError),
NoBuffers,
UnsupportedProto,
}

impl From<Error> for TcpError {
Expand Down Expand Up @@ -314,6 +321,7 @@ impl embedded_io_async::Error for TcpError {
TcpError::Connect(_) => ErrorKind::Other,
TcpError::Accept(_) => ErrorKind::Other,
TcpError::NoBuffers => ErrorKind::OutOfMemory,
TcpError::UnsupportedProto => ErrorKind::InvalidInput,
}
}
}
Expand Down
Loading
Loading