diff options
| author | Ruben De Smet <[email protected]> | 2023-07-28 16:19:24 +0200 |
|---|---|---|
| committer | Ruben De Smet <[email protected]> | 2023-07-28 16:40:15 +0200 |
| commit | 69c0a89aa5d52e048fdd8ddc5d47b767da07e88b (patch) | |
| tree | e8eb364418ae00d46f2b4163b6c0bd8fff6306fc /embassy-net | |
| parent | c3ba08ffb6570589726db44d40ba5b724a8950d4 (diff) | |
Use HardwareAddress in Driver
Diffstat (limited to 'embassy-net')
| -rw-r--r-- | embassy-net/src/lib.rs | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/embassy-net/src/lib.rs b/embassy-net/src/lib.rs index 53693563b..efd820a63 100644 --- a/embassy-net/src/lib.rs +++ b/embassy-net/src/lib.rs | |||
| @@ -243,11 +243,11 @@ impl<D: Driver + 'static> Stack<D> { | |||
| 243 | 243 | ||
| 244 | let hardware_addr = match medium { | 244 | let hardware_addr = match medium { |
| 245 | #[cfg(feature = "medium-ethernet")] | 245 | #[cfg(feature = "medium-ethernet")] |
| 246 | Medium::Ethernet => HardwareAddress::Ethernet(EthernetAddress(device.ethernet_address())), | 246 | Medium::Ethernet => device.hardware_address(), |
| 247 | #[cfg(feature = "medium-ip")] | 247 | #[cfg(feature = "medium-ip")] |
| 248 | Medium::Ip => HardwareAddress::Ip, | 248 | Medium::Ip => HardwareAddress::Ip, |
| 249 | #[cfg(feature = "medium-ieee802154")] | 249 | #[cfg(feature = "medium-ieee802154")] |
| 250 | Medium::Ieee802154 => HardwareAddress::Ieee802154(Ieee802154Address::Extended(device.ieee802154_address())), | 250 | Medium::Ieee802154 => device.hardware_address(), |
| 251 | #[allow(unreachable_patterns)] | 251 | #[allow(unreachable_patterns)] |
| 252 | _ => panic!( | 252 | _ => panic!( |
| 253 | "Unsupported medium {:?}. Make sure to enable it in embassy-net's Cargo features.", | 253 | "Unsupported medium {:?}. Make sure to enable it in embassy-net's Cargo features.", |
| @@ -336,9 +336,9 @@ impl<D: Driver + 'static> Stack<D> { | |||
| 336 | f(&mut *self.socket.borrow_mut(), &mut *self.inner.borrow_mut()) | 336 | f(&mut *self.socket.borrow_mut(), &mut *self.inner.borrow_mut()) |
| 337 | } | 337 | } |
| 338 | 338 | ||
| 339 | /// Get the MAC address of the network interface. | 339 | /// Get the hardware address of the network interface. |
| 340 | pub fn ethernet_address(&self) -> [u8; 6] { | 340 | pub fn hardware_address(&self) -> HardwareAddress { |
| 341 | self.with(|_s, i| i.device.ethernet_address()) | 341 | self.with(|_s, i| i.device.hardware_address()) |
| 342 | } | 342 | } |
| 343 | 343 | ||
| 344 | /// Get whether the link is up. | 344 | /// Get whether the link is up. |
| @@ -740,18 +740,11 @@ impl<D: Driver + 'static> Inner<D> { | |||
| 740 | fn poll(&mut self, cx: &mut Context<'_>, s: &mut SocketStack) { | 740 | fn poll(&mut self, cx: &mut Context<'_>, s: &mut SocketStack) { |
| 741 | s.waker.register(cx.waker()); | 741 | s.waker.register(cx.waker()); |
| 742 | 742 | ||
| 743 | #[cfg(feature = "medium-ethernet")] | 743 | #[cfg(any(feature = "medium-ethernet", feature = "medium-ieee802154"))] |
| 744 | if self.device.capabilities().medium == Medium::Ethernet { | 744 | if self.device.capabilities().medium == Medium::Ethernet |
| 745 | s.iface.set_hardware_addr(HardwareAddress::Ethernet(EthernetAddress( | 745 | || self.device.capabilities().medium == Medium::Ieee802154 |
| 746 | self.device.ethernet_address(), | 746 | { |
| 747 | ))); | 747 | s.iface.set_hardware_addr(self.device.hardware_address()); |
| 748 | } | ||
| 749 | |||
| 750 | #[cfg(feature = "medium-ieee802154")] | ||
| 751 | if self.device.capabilities().medium == Medium::Ieee802154 { | ||
| 752 | s.iface.set_hardware_addr(HardwareAddress::Ieee802154(Ieee802154Address::Extended( | ||
| 753 | self.device.ieee802154_address(), | ||
| 754 | ))); | ||
| 755 | } | 748 | } |
| 756 | 749 | ||
| 757 | let timestamp = instant_to_smoltcp(Instant::now()); | 750 | let timestamp = instant_to_smoltcp(Instant::now()); |
