diff options
Diffstat (limited to 'embassy-net/src/lib.rs')
| -rw-r--r-- | embassy-net/src/lib.rs | 17 |
1 files changed, 8 insertions, 9 deletions
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 | }; |
