diff options
| author | Dario Nieuwenhuis <[email protected]> | 2022-12-26 03:33:49 +0100 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2022-12-26 04:49:08 +0100 |
| commit | 1f033d509afb4e590a81896de66af683fda4e706 (patch) | |
| tree | 5c10000e08d00de221a770c81fb9127a35dd0343 /embassy-net | |
| parent | 639b3f1d5b4b2897b326edc52f66f18caaa3bd3e (diff) | |
net: split driver trait to a separate crate.
Diffstat (limited to 'embassy-net')
| -rw-r--r-- | embassy-net/Cargo.toml | 3 | ||||
| -rw-r--r-- | embassy-net/src/device.rs | 117 | ||||
| -rw-r--r-- | embassy-net/src/lib.rs | 17 | ||||
| -rw-r--r-- | embassy-net/src/tcp.rs | 12 | ||||
| -rw-r--r-- | embassy-net/src/udp.rs | 5 |
5 files changed, 57 insertions, 97 deletions
diff --git a/embassy-net/Cargo.toml b/embassy-net/Cargo.toml index 357f87922..9214fd17e 100644 --- a/embassy-net/Cargo.toml +++ b/embassy-net/Cargo.toml | |||
| @@ -15,7 +15,7 @@ target = "thumbv7em-none-eabi" | |||
| 15 | default = [] | 15 | default = [] |
| 16 | std = [] | 16 | std = [] |
| 17 | 17 | ||
| 18 | defmt = ["dep:defmt", "smoltcp/defmt"] | 18 | defmt = ["dep:defmt", "smoltcp/defmt", "embassy-net-driver/defmt"] |
| 19 | 19 | ||
| 20 | nightly = ["dep:embedded-io", "embedded-io?/async", "dep:embedded-nal-async"] | 20 | nightly = ["dep:embedded-io", "embedded-io?/async", "dep:embedded-nal-async"] |
| 21 | unstable-traits = [] | 21 | unstable-traits = [] |
| @@ -33,6 +33,7 @@ medium-ip = ["smoltcp/medium-ip"] | |||
| 33 | defmt = { version = "0.3", optional = true } | 33 | defmt = { version = "0.3", optional = true } |
| 34 | log = { version = "0.4.14", optional = true } | 34 | log = { version = "0.4.14", optional = true } |
| 35 | 35 | ||
| 36 | embassy-net-driver = { version = "0.1.0", path = "../embassy-net-driver" } | ||
| 36 | embassy-time = { version = "0.1.0", path = "../embassy-time" } | 37 | embassy-time = { version = "0.1.0", path = "../embassy-time" } |
| 37 | embassy-sync = { version = "0.1.0", path = "../embassy-sync" } | 38 | embassy-sync = { version = "0.1.0", path = "../embassy-sync" } |
| 38 | embedded-io = { version = "0.4.0", optional = true } | 39 | embedded-io = { version = "0.4.0", optional = true } |
diff --git a/embassy-net/src/device.rs b/embassy-net/src/device.rs index 5d86ca91e..44f7dc7bd 100644 --- a/embassy-net/src/device.rs +++ b/embassy-net/src/device.rs | |||
| @@ -1,93 +1,20 @@ | |||
| 1 | use core::task::Context; | 1 | use core::task::Context; |
| 2 | 2 | ||
| 3 | use embassy_net_driver::{Capabilities, Checksum, Driver, Medium, RxToken, TxToken}; | ||
| 3 | use smoltcp::phy; | 4 | use smoltcp::phy; |
| 4 | pub use smoltcp::phy::{Checksum, ChecksumCapabilities, DeviceCapabilities, Medium}; | ||
| 5 | 5 | ||
| 6 | #[derive(PartialEq, Eq, Clone, Copy)] | 6 | pub(crate) struct DriverAdapter<'d, 'c, T> |
| 7 | pub enum LinkState { | ||
| 8 | Down, | ||
| 9 | Up, | ||
| 10 | } | ||
| 11 | |||
| 12 | pub trait Device { | ||
| 13 | type RxToken<'a>: RxToken | ||
| 14 | where | ||
| 15 | Self: 'a; | ||
| 16 | type TxToken<'a>: TxToken | ||
| 17 | where | ||
| 18 | Self: 'a; | ||
| 19 | |||
| 20 | fn receive(&mut self, cx: &mut Context) -> Option<(Self::RxToken<'_>, Self::TxToken<'_>)>; | ||
| 21 | fn transmit(&mut self, cx: &mut Context) -> Option<Self::TxToken<'_>>; | ||
| 22 | fn link_state(&mut self, cx: &mut Context) -> LinkState; | ||
| 23 | |||
| 24 | fn capabilities(&self) -> phy::DeviceCapabilities; | ||
| 25 | fn ethernet_address(&self) -> [u8; 6]; | ||
| 26 | } | ||
| 27 | |||
| 28 | impl<T: ?Sized + Device> Device for &mut T { | ||
| 29 | type RxToken<'a> = T::RxToken<'a> | ||
| 30 | where | ||
| 31 | Self: 'a; | ||
| 32 | type TxToken<'a> = T::TxToken<'a> | ||
| 33 | where | ||
| 34 | Self: 'a; | ||
| 35 | |||
| 36 | fn transmit(&mut self, cx: &mut Context) -> Option<Self::TxToken<'_>> { | ||
| 37 | T::transmit(self, cx) | ||
| 38 | } | ||
| 39 | fn receive(&mut self, cx: &mut Context) -> Option<(Self::RxToken<'_>, Self::TxToken<'_>)> { | ||
| 40 | T::receive(self, cx) | ||
| 41 | } | ||
| 42 | fn capabilities(&self) -> phy::DeviceCapabilities { | ||
| 43 | T::capabilities(self) | ||
| 44 | } | ||
| 45 | fn link_state(&mut self, cx: &mut Context) -> LinkState { | ||
| 46 | T::link_state(self, cx) | ||
| 47 | } | ||
| 48 | fn ethernet_address(&self) -> [u8; 6] { | ||
| 49 | T::ethernet_address(self) | ||
| 50 | } | ||
| 51 | } | ||
| 52 | |||
| 53 | /// A token to receive a single network packet. | ||
| 54 | pub trait RxToken { | ||
| 55 | /// Consumes the token to receive a single network packet. | ||
| 56 | /// | ||
| 57 | /// This method receives a packet and then calls the given closure `f` with the raw | ||
| 58 | /// packet bytes as argument. | ||
| 59 | fn consume<R, F>(self, f: F) -> R | ||
| 60 | where | ||
| 61 | F: FnOnce(&mut [u8]) -> R; | ||
| 62 | } | ||
| 63 | |||
| 64 | /// A token to transmit a single network packet. | ||
| 65 | pub trait TxToken { | ||
| 66 | /// Consumes the token to send a single network packet. | ||
| 67 | /// | ||
| 68 | /// This method constructs a transmit buffer of size `len` and calls the passed | ||
| 69 | /// closure `f` with a mutable reference to that buffer. The closure should construct | ||
| 70 | /// a valid network packet (e.g. an ethernet packet) in the buffer. When the closure | ||
| 71 | /// returns, the transmit buffer is sent out. | ||
| 72 | fn consume<R, F>(self, len: usize, f: F) -> R | ||
| 73 | where | ||
| 74 | F: FnOnce(&mut [u8]) -> R; | ||
| 75 | } | ||
| 76 | |||
| 77 | /////////////////////////// | ||
| 78 | |||
| 79 | pub(crate) struct DeviceAdapter<'d, 'c, T> | ||
| 80 | where | 7 | where |
| 81 | T: Device, | 8 | T: Driver, |
| 82 | { | 9 | { |
| 83 | // must be Some when actually using this to rx/tx | 10 | // must be Some when actually using this to rx/tx |
| 84 | pub cx: Option<&'d mut Context<'c>>, | 11 | pub cx: Option<&'d mut Context<'c>>, |
| 85 | pub inner: &'d mut T, | 12 | pub inner: &'d mut T, |
| 86 | } | 13 | } |
| 87 | 14 | ||
| 88 | impl<'d, 'c, T> phy::Device for DeviceAdapter<'d, 'c, T> | 15 | impl<'d, 'c, T> phy::Device for DriverAdapter<'d, 'c, T> |
| 89 | where | 16 | where |
| 90 | T: Device, | 17 | T: Driver, |
| 91 | { | 18 | { |
| 92 | type RxToken<'a> = RxTokenAdapter<T::RxToken<'a>> where Self: 'a; | 19 | type RxToken<'a> = RxTokenAdapter<T::RxToken<'a>> where Self: 'a; |
| 93 | type TxToken<'a> = TxTokenAdapter<T::TxToken<'a>> where Self: 'a; | 20 | type TxToken<'a> = TxTokenAdapter<T::TxToken<'a>> where Self: 'a; |
| @@ -105,7 +32,39 @@ where | |||
| 105 | 32 | ||
| 106 | /// Get a description of device capabilities. | 33 | /// Get a description of device capabilities. |
| 107 | fn capabilities(&self) -> phy::DeviceCapabilities { | 34 | fn capabilities(&self) -> phy::DeviceCapabilities { |
| 108 | self.inner.capabilities() | 35 | fn convert(c: Checksum) -> phy::Checksum { |
| 36 | match c { | ||
| 37 | Checksum::Both => phy::Checksum::Both, | ||
| 38 | Checksum::Tx => phy::Checksum::Tx, | ||
| 39 | Checksum::Rx => phy::Checksum::Rx, | ||
| 40 | Checksum::None => phy::Checksum::None, | ||
| 41 | } | ||
| 42 | } | ||
| 43 | let caps: Capabilities = self.inner.capabilities(); | ||
| 44 | let mut smolcaps = phy::DeviceCapabilities::default(); | ||
| 45 | |||
| 46 | smolcaps.max_transmission_unit = caps.max_transmission_unit; | ||
| 47 | smolcaps.max_burst_size = caps.max_burst_size; | ||
| 48 | smolcaps.medium = match caps.medium { | ||
| 49 | #[cfg(feature = "medium-ethernet")] | ||
| 50 | Medium::Ethernet => phy::Medium::Ethernet, | ||
| 51 | #[cfg(feature = "medium-ip")] | ||
| 52 | Medium::Ip => phy::Medium::Ip, | ||
| 53 | _ => panic!( | ||
| 54 | "Unsupported medium {:?}. MAke sure to enable it in embassy-net's Cargo features.", | ||
| 55 | caps.medium | ||
| 56 | ), | ||
| 57 | }; | ||
| 58 | smolcaps.checksum.ipv4 = convert(caps.checksum.ipv4); | ||
| 59 | #[cfg(feature = "proto-ipv6")] | ||
| 60 | { | ||
| 61 | smolcaps.checksum.ipv6 = convert(caps.checksum.ipv6); | ||
| 62 | } | ||
| 63 | smolcaps.checksum.tcp = convert(caps.checksum.tcp); | ||
| 64 | smolcaps.checksum.udp = convert(caps.checksum.udp); | ||
| 65 | smolcaps.checksum.icmpv4 = convert(caps.checksum.icmpv4); | ||
| 66 | |||
| 67 | smolcaps | ||
| 109 | } | 68 | } |
| 110 | } | 69 | } |
| 111 | 70 | ||
diff --git a/embassy-net/src/lib.rs b/embassy-net/src/lib.rs index afe0d6da0..b58c9cf36 100644 --- a/embassy-net/src/lib.rs +++ b/embassy-net/src/lib.rs | |||
| @@ -18,6 +18,7 @@ use core::cell::RefCell; | |||
| 18 | use core::future::{poll_fn, Future}; | 18 | use core::future::{poll_fn, Future}; |
| 19 | use core::task::{Context, Poll}; | 19 | use core::task::{Context, Poll}; |
| 20 | 20 | ||
| 21 | use embassy_net_driver::{Driver, LinkState, Medium}; | ||
| 21 | use embassy_sync::waitqueue::WakerRegistration; | 22 | use embassy_sync::waitqueue::WakerRegistration; |
| 22 | use embassy_time::{Instant, Timer}; | 23 | use embassy_time::{Instant, Timer}; |
| 23 | use futures::pin_mut; | 24 | use futures::pin_mut; |
| @@ -27,8 +28,6 @@ use smoltcp::iface::SocketHandle; | |||
| 27 | use smoltcp::iface::{Interface, InterfaceBuilder, SocketSet, SocketStorage}; | 28 | use smoltcp::iface::{Interface, InterfaceBuilder, SocketSet, SocketStorage}; |
| 28 | #[cfg(feature = "medium-ethernet")] | 29 | #[cfg(feature = "medium-ethernet")] |
| 29 | use smoltcp::iface::{Neighbor, NeighborCache, Route, Routes}; | 30 | use smoltcp::iface::{Neighbor, NeighborCache, Route, Routes}; |
| 30 | #[cfg(feature = "medium-ethernet")] | ||
| 31 | use smoltcp::phy::Medium; | ||
| 32 | #[cfg(feature = "dhcpv4")] | 31 | #[cfg(feature = "dhcpv4")] |
| 33 | use smoltcp::socket::dhcpv4; | 32 | use smoltcp::socket::dhcpv4; |
| 34 | // smoltcp reexports | 33 | // smoltcp reexports |
| @@ -41,7 +40,7 @@ pub use smoltcp::wire::{Ipv6Address, Ipv6Cidr}; | |||
| 41 | #[cfg(feature = "udp")] | 40 | #[cfg(feature = "udp")] |
| 42 | pub use smoltcp::{socket::udp::PacketMetadata, wire::IpListenEndpoint}; | 41 | pub use smoltcp::{socket::udp::PacketMetadata, wire::IpListenEndpoint}; |
| 43 | 42 | ||
| 44 | use crate::device::{Device, DeviceAdapter, LinkState}; | 43 | use crate::device::DriverAdapter; |
| 45 | 44 | ||
| 46 | const LOCAL_PORT_MIN: u16 = 1025; | 45 | const LOCAL_PORT_MIN: u16 = 1025; |
| 47 | const LOCAL_PORT_MAX: u16 = 65535; | 46 | const LOCAL_PORT_MAX: u16 = 65535; |
| @@ -82,12 +81,12 @@ pub enum ConfigStrategy { | |||
| 82 | Dhcp, | 81 | Dhcp, |
| 83 | } | 82 | } |
| 84 | 83 | ||
| 85 | pub struct Stack<D: Device> { | 84 | pub struct Stack<D: Driver> { |
| 86 | pub(crate) socket: RefCell<SocketStack>, | 85 | pub(crate) socket: RefCell<SocketStack>, |
| 87 | inner: RefCell<Inner<D>>, | 86 | inner: RefCell<Inner<D>>, |
| 88 | } | 87 | } |
| 89 | 88 | ||
| 90 | struct Inner<D: Device> { | 89 | struct Inner<D: Driver> { |
| 91 | device: D, | 90 | device: D, |
| 92 | link_up: bool, | 91 | link_up: bool, |
| 93 | config: Option<Config>, | 92 | config: Option<Config>, |
| @@ -102,7 +101,7 @@ pub(crate) struct SocketStack { | |||
| 102 | next_local_port: u16, | 101 | next_local_port: u16, |
| 103 | } | 102 | } |
| 104 | 103 | ||
| 105 | impl<D: Device + 'static> Stack<D> { | 104 | impl<D: Driver + 'static> Stack<D> { |
| 106 | pub fn new<const ADDR: usize, const SOCK: usize, const NEIGH: usize>( | 105 | pub fn new<const ADDR: usize, const SOCK: usize, const NEIGH: usize>( |
| 107 | mut device: D, | 106 | mut device: D, |
| 108 | config: ConfigStrategy, | 107 | config: ConfigStrategy, |
| @@ -130,7 +129,7 @@ impl<D: Device + 'static> Stack<D> { | |||
| 130 | b = b.routes(Routes::new(&mut resources.routes[..])); | 129 | b = b.routes(Routes::new(&mut resources.routes[..])); |
| 131 | } | 130 | } |
| 132 | 131 | ||
| 133 | let iface = b.finalize(&mut DeviceAdapter { | 132 | let iface = b.finalize(&mut DriverAdapter { |
| 134 | inner: &mut device, | 133 | inner: &mut device, |
| 135 | cx: None, | 134 | cx: None, |
| 136 | }); | 135 | }); |
| @@ -211,7 +210,7 @@ impl SocketStack { | |||
| 211 | } | 210 | } |
| 212 | } | 211 | } |
| 213 | 212 | ||
| 214 | impl<D: Device + 'static> Inner<D> { | 213 | impl<D: Driver + 'static> Inner<D> { |
| 215 | fn apply_config(&mut self, s: &mut SocketStack, config: Config) { | 214 | fn apply_config(&mut self, s: &mut SocketStack, config: Config) { |
| 216 | #[cfg(feature = "medium-ethernet")] | 215 | #[cfg(feature = "medium-ethernet")] |
| 217 | let medium = self.device.capabilities().medium; | 216 | let medium = self.device.capabilities().medium; |
| @@ -263,7 +262,7 @@ impl<D: Device + 'static> Inner<D> { | |||
| 263 | s.waker.register(cx.waker()); | 262 | s.waker.register(cx.waker()); |
| 264 | 263 | ||
| 265 | let timestamp = instant_to_smoltcp(Instant::now()); | 264 | let timestamp = instant_to_smoltcp(Instant::now()); |
| 266 | let mut smoldev = DeviceAdapter { | 265 | let mut smoldev = DriverAdapter { |
| 267 | cx: Some(cx), | 266 | cx: Some(cx), |
| 268 | inner: &mut self.device, | 267 | inner: &mut self.device, |
| 269 | }; | 268 | }; |
diff --git a/embassy-net/src/tcp.rs b/embassy-net/src/tcp.rs index 0dc8da73a..0fbf0c91b 100644 --- a/embassy-net/src/tcp.rs +++ b/embassy-net/src/tcp.rs | |||
| @@ -3,12 +3,12 @@ use core::future::poll_fn; | |||
| 3 | use core::mem; | 3 | use core::mem; |
| 4 | use core::task::Poll; | 4 | use core::task::Poll; |
| 5 | 5 | ||
| 6 | use embassy_net_driver::Driver; | ||
| 6 | use smoltcp::iface::{Interface, SocketHandle}; | 7 | use smoltcp::iface::{Interface, SocketHandle}; |
| 7 | use smoltcp::socket::tcp; | 8 | use smoltcp::socket::tcp; |
| 8 | use smoltcp::time::Duration; | 9 | use smoltcp::time::Duration; |
| 9 | use smoltcp::wire::{IpEndpoint, IpListenEndpoint}; | 10 | use smoltcp::wire::{IpEndpoint, IpListenEndpoint}; |
| 10 | 11 | ||
| 11 | use crate::device::Device; | ||
| 12 | use crate::{SocketStack, Stack}; | 12 | use crate::{SocketStack, Stack}; |
| 13 | 13 | ||
| 14 | #[derive(PartialEq, Eq, Clone, Copy, Debug)] | 14 | #[derive(PartialEq, Eq, Clone, Copy, Debug)] |
| @@ -66,7 +66,7 @@ impl<'a> TcpWriter<'a> { | |||
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | impl<'a> TcpSocket<'a> { | 68 | impl<'a> TcpSocket<'a> { |
| 69 | pub fn new<D: Device>(stack: &'a Stack<D>, rx_buffer: &'a mut [u8], tx_buffer: &'a mut [u8]) -> Self { | 69 | pub fn new<D: Driver>(stack: &'a Stack<D>, rx_buffer: &'a mut [u8], tx_buffer: &'a mut [u8]) -> Self { |
| 70 | let s = &mut *stack.socket.borrow_mut(); | 70 | let s = &mut *stack.socket.borrow_mut(); |
| 71 | let rx_buffer: &'static mut [u8] = unsafe { mem::transmute(rx_buffer) }; | 71 | let rx_buffer: &'static mut [u8] = unsafe { mem::transmute(rx_buffer) }; |
| 72 | let tx_buffer: &'static mut [u8] = unsafe { mem::transmute(tx_buffer) }; | 72 | let tx_buffer: &'static mut [u8] = unsafe { mem::transmute(tx_buffer) }; |
| @@ -336,19 +336,19 @@ pub mod client { | |||
| 336 | use super::*; | 336 | use super::*; |
| 337 | 337 | ||
| 338 | /// TCP client capable of creating up to N multiple connections with tx and rx buffers according to TX_SZ and RX_SZ. | 338 | /// TCP client capable of creating up to N multiple connections with tx and rx buffers according to TX_SZ and RX_SZ. |
| 339 | pub struct TcpClient<'d, D: Device, const N: usize, const TX_SZ: usize = 1024, const RX_SZ: usize = 1024> { | 339 | pub struct TcpClient<'d, D: Driver, const N: usize, const TX_SZ: usize = 1024, const RX_SZ: usize = 1024> { |
| 340 | stack: &'d Stack<D>, | 340 | stack: &'d Stack<D>, |
| 341 | state: &'d TcpClientState<N, TX_SZ, RX_SZ>, | 341 | state: &'d TcpClientState<N, TX_SZ, RX_SZ>, |
| 342 | } | 342 | } |
| 343 | 343 | ||
| 344 | impl<'d, D: Device, const N: usize, const TX_SZ: usize, const RX_SZ: usize> TcpClient<'d, D, N, TX_SZ, RX_SZ> { | 344 | impl<'d, D: Driver, const N: usize, const TX_SZ: usize, const RX_SZ: usize> TcpClient<'d, D, N, TX_SZ, RX_SZ> { |
| 345 | /// Create a new TcpClient | 345 | /// Create a new TcpClient |
| 346 | pub fn new(stack: &'d Stack<D>, state: &'d TcpClientState<N, TX_SZ, RX_SZ>) -> Self { | 346 | pub fn new(stack: &'d Stack<D>, state: &'d TcpClientState<N, TX_SZ, RX_SZ>) -> Self { |
| 347 | Self { stack, state } | 347 | Self { stack, state } |
| 348 | } | 348 | } |
| 349 | } | 349 | } |
| 350 | 350 | ||
| 351 | impl<'d, D: Device, const N: usize, const TX_SZ: usize, const RX_SZ: usize> embedded_nal_async::TcpConnect | 351 | impl<'d, D: Driver, const N: usize, const TX_SZ: usize, const RX_SZ: usize> embedded_nal_async::TcpConnect |
| 352 | for TcpClient<'d, D, N, TX_SZ, RX_SZ> | 352 | for TcpClient<'d, D, N, TX_SZ, RX_SZ> |
| 353 | { | 353 | { |
| 354 | type Error = Error; | 354 | type Error = Error; |
| @@ -386,7 +386,7 @@ pub mod client { | |||
| 386 | } | 386 | } |
| 387 | 387 | ||
| 388 | impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize> TcpConnection<'d, N, TX_SZ, RX_SZ> { | 388 | impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize> TcpConnection<'d, N, TX_SZ, RX_SZ> { |
| 389 | fn new<D: Device>(stack: &'d Stack<D>, state: &'d TcpClientState<N, TX_SZ, RX_SZ>) -> Result<Self, Error> { | 389 | fn new<D: Driver>(stack: &'d Stack<D>, state: &'d TcpClientState<N, TX_SZ, RX_SZ>) -> Result<Self, Error> { |
| 390 | let mut bufs = state.pool.alloc().ok_or(Error::ConnectionReset)?; | 390 | let mut bufs = state.pool.alloc().ok_or(Error::ConnectionReset)?; |
| 391 | Ok(Self { | 391 | Ok(Self { |
| 392 | socket: unsafe { TcpSocket::new(stack, &mut bufs.as_mut().0, &mut bufs.as_mut().1) }, | 392 | socket: unsafe { TcpSocket::new(stack, &mut bufs.as_mut().0, &mut bufs.as_mut().1) }, |
diff --git a/embassy-net/src/udp.rs b/embassy-net/src/udp.rs index 2f5334df3..0ee8c6e19 100644 --- a/embassy-net/src/udp.rs +++ b/embassy-net/src/udp.rs | |||
| @@ -3,11 +3,12 @@ use core::future::poll_fn; | |||
| 3 | use core::mem; | 3 | use core::mem; |
| 4 | use core::task::Poll; | 4 | use core::task::Poll; |
| 5 | 5 | ||
| 6 | use embassy_net_driver::Driver; | ||
| 6 | use smoltcp::iface::{Interface, SocketHandle}; | 7 | use smoltcp::iface::{Interface, SocketHandle}; |
| 7 | use smoltcp::socket::udp::{self, PacketMetadata}; | 8 | use smoltcp::socket::udp::{self, PacketMetadata}; |
| 8 | use smoltcp::wire::{IpEndpoint, IpListenEndpoint}; | 9 | use smoltcp::wire::{IpEndpoint, IpListenEndpoint}; |
| 9 | 10 | ||
| 10 | use crate::{Device, SocketStack, Stack}; | 11 | use crate::{SocketStack, Stack}; |
| 11 | 12 | ||
| 12 | #[derive(PartialEq, Eq, Clone, Copy, Debug)] | 13 | #[derive(PartialEq, Eq, Clone, Copy, Debug)] |
| 13 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | 14 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] |
| @@ -31,7 +32,7 @@ pub struct UdpSocket<'a> { | |||
| 31 | } | 32 | } |
| 32 | 33 | ||
| 33 | impl<'a> UdpSocket<'a> { | 34 | impl<'a> UdpSocket<'a> { |
| 34 | pub fn new<D: Device>( | 35 | pub fn new<D: Driver>( |
| 35 | stack: &'a Stack<D>, | 36 | stack: &'a Stack<D>, |
| 36 | rx_meta: &'a mut [PacketMetadata], | 37 | rx_meta: &'a mut [PacketMetadata], |
| 37 | rx_buffer: &'a mut [u8], | 38 | rx_buffer: &'a mut [u8], |
