Skip to content

Commit d4027e2

Browse files
committed
update smoltcp from 0.7.0 to 0.8.0
1 parent cd09880 commit d4027e2

File tree

3 files changed

+40
-48
lines changed

3 files changed

+40
-48
lines changed

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ synopsys-usb-otg = { version = "^0.2.4", features = ["cortex-m"], optional = tru
4141
embedded-display-controller = { version = "^0.1.0", optional = true }
4242

4343
[dependencies.smoltcp]
44-
version = "0.7.0"
44+
version = "0.8.0"
4545
default-features = false
46-
features = ["ethernet", "proto-ipv4", "socket-raw"]
46+
features = ["medium-ethernet", "proto-ipv4", "socket-raw"]
4747
optional = true
4848

4949
[dependencies.chrono]
@@ -73,9 +73,9 @@ usb-device = "0.2.5"
7373
usbd-serial = "0.1.0"
7474

7575
[dev-dependencies.smoltcp]
76-
version = "0.7.0"
76+
version = "0.8.0"
7777
default-features = false
78-
features = ["ethernet", "proto-ipv4", "proto-ipv6", "socket-raw"]
78+
features = ["medium-ethernet", "proto-ipv4", "proto-ipv6", "socket-raw"]
7979

8080
[features]
8181
default = ["unproven", "rt"]

examples/ethernet-rtic-stm32h735g-dk.rs

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,11 @@ mod utilities;
2020
use log::info;
2121

2222
use smoltcp::iface::{
23-
EthernetInterface, EthernetInterfaceBuilder, Neighbor, NeighborCache,
24-
Route, Routes,
23+
Interface, InterfaceBuilder, Neighbor, NeighborCache, Route, Routes,
24+
SocketStorage,
2525
};
26-
use smoltcp::socket::{SocketSet, SocketSetItem};
2726
use smoltcp::time::Instant;
28-
use smoltcp::wire::{EthernetAddress, IpAddress, IpCidr, Ipv6Cidr};
27+
use smoltcp::wire::{HardwareAddress, IpAddress, IpCidr, Ipv6Cidr};
2928

3029
use stm32h7xx_hal::gpio;
3130
use stm32h7xx_hal::hal::digital::v2::OutputPin;
@@ -60,27 +59,26 @@ static mut DES_RING: ethernet::DesRing<4, 4> = ethernet::DesRing::new();
6059
/// Net storage with static initialisation - another global singleton
6160
pub struct NetStorageStatic<'a> {
6261
ip_addrs: [IpCidr; 1],
63-
socket_set_entries: [Option<SocketSetItem<'a>>; 8],
62+
socket_storage: [SocketStorage<'a>; 8],
6463
neighbor_cache_storage: [Option<(IpAddress, Neighbor)>; 8],
6564
routes_storage: [Option<(IpCidr, Route)>; 1],
6665
}
6766
static mut STORE: NetStorageStatic = NetStorageStatic {
6867
// Garbage
6968
ip_addrs: [IpCidr::Ipv6(Ipv6Cidr::SOLICITED_NODE_PREFIX)],
70-
socket_set_entries: [None, None, None, None, None, None, None, None],
69+
socket_storage: [SocketStorage::EMPTY; 8],
7170
neighbor_cache_storage: [None; 8],
7271
routes_storage: [None; 1],
7372
};
7473

7574
pub struct Net<'a> {
76-
iface: EthernetInterface<'a, ethernet::EthernetDMA<'a, 4, 4>>,
77-
sockets: SocketSet<'a>,
75+
iface: Interface<'a, ethernet::EthernetDMA<'a, 4, 4>>,
7876
}
7977
impl<'a> Net<'a> {
8078
pub fn new(
8179
store: &'static mut NetStorageStatic<'a>,
8280
ethdev: ethernet::EthernetDMA<'a, 4, 4>,
83-
ethernet_addr: EthernetAddress,
81+
ethernet_addr: HardwareAddress,
8482
) -> Self {
8583
// Set IP address
8684
store.ip_addrs =
@@ -90,15 +88,15 @@ impl<'a> Net<'a> {
9088
NeighborCache::new(&mut store.neighbor_cache_storage[..]);
9189
let routes = Routes::new(&mut store.routes_storage[..]);
9290

93-
let iface = EthernetInterfaceBuilder::new(ethdev)
94-
.ethernet_addr(ethernet_addr)
95-
.neighbor_cache(neighbor_cache)
96-
.ip_addrs(&mut store.ip_addrs[..])
97-
.routes(routes)
98-
.finalize();
99-
let sockets = SocketSet::new(&mut store.socket_set_entries[..]);
91+
let iface =
92+
InterfaceBuilder::new(ethdev, &mut store.socket_storage[..])
93+
.hardware_addr(ethernet_addr)
94+
.neighbor_cache(neighbor_cache)
95+
.ip_addrs(&mut store.ip_addrs[..])
96+
.routes(routes)
97+
.finalize();
10098

101-
return Net { iface, sockets };
99+
return Net { iface };
102100
}
103101

104102
/// Polls on the ethernet interface. You should refer to the smoltcp
@@ -107,7 +105,7 @@ impl<'a> Net<'a> {
107105
let timestamp = Instant::from_millis(now);
108106

109107
self.iface
110-
.poll(&mut self.sockets, timestamp)
108+
.poll(timestamp)
111109
.map(|_| ())
112110
.unwrap_or_else(|e| info!("Poll: {:?}", e));
113111
}
@@ -195,13 +193,11 @@ const APP: () = {
195193
lan8742a.phy_init();
196194
// The eth_dma should not be used until the PHY reports the link is up
197195

198-
unsafe {
199-
ethernet::enable_interrupt();
200-
}
196+
unsafe { ethernet::enable_interrupt() };
201197

202198
// unsafe: mutable reference to static storage, we only do this once
203199
let store = unsafe { &mut STORE };
204-
let net = Net::new(store, eth_dma, mac_addr);
200+
let net = Net::new(store, eth_dma, mac_addr.into());
205201

206202
// 1ms tick
207203
systick_init(ctx.core.SYST, ccdr.clocks);

examples/ethernet-rtic-stm32h747i-disco.rs

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,11 @@ mod utilities;
2020
use log::info;
2121

2222
use smoltcp::iface::{
23-
EthernetInterface, EthernetInterfaceBuilder, Neighbor, NeighborCache,
24-
Route, Routes,
23+
Interface, InterfaceBuilder, Neighbor, NeighborCache, Route, Routes,
24+
SocketStorage,
2525
};
26-
use smoltcp::socket::{SocketSet, SocketSetItem};
2726
use smoltcp::time::Instant;
28-
use smoltcp::wire::{EthernetAddress, IpAddress, IpCidr, Ipv6Cidr};
27+
use smoltcp::wire::{HardwareAddress, IpAddress, IpCidr, Ipv6Cidr};
2928

3029
use stm32h7xx_hal::gpio;
3130
use stm32h7xx_hal::hal::digital::v2::OutputPin;
@@ -60,27 +59,26 @@ static mut DES_RING: ethernet::DesRing<4, 4> = ethernet::DesRing::new();
6059
/// Net storage with static initialisation - another global singleton
6160
pub struct NetStorageStatic<'a> {
6261
ip_addrs: [IpCidr; 1],
63-
socket_set_entries: [Option<SocketSetItem<'a>>; 8],
62+
socket_storage: [SocketStorage<'a>; 8],
6463
neighbor_cache_storage: [Option<(IpAddress, Neighbor)>; 8],
6564
routes_storage: [Option<(IpCidr, Route)>; 1],
6665
}
6766
static mut STORE: NetStorageStatic = NetStorageStatic {
6867
// Garbage
6968
ip_addrs: [IpCidr::Ipv6(Ipv6Cidr::SOLICITED_NODE_PREFIX)],
70-
socket_set_entries: [None, None, None, None, None, None, None, None],
69+
socket_storage: [SocketStorage::EMPTY; 8],
7170
neighbor_cache_storage: [None; 8],
7271
routes_storage: [None; 1],
7372
};
7473

7574
pub struct Net<'a> {
76-
iface: EthernetInterface<'a, ethernet::EthernetDMA<'a, 4, 4>>,
77-
sockets: SocketSet<'a>,
75+
iface: Interface<'a, ethernet::EthernetDMA<'a, 4, 4>>,
7876
}
7977
impl<'a> Net<'a> {
8078
pub fn new(
8179
store: &'static mut NetStorageStatic<'a>,
8280
ethdev: ethernet::EthernetDMA<'a, 4, 4>,
83-
ethernet_addr: EthernetAddress,
81+
ethernet_addr: HardwareAddress,
8482
) -> Self {
8583
// Set IP address
8684
store.ip_addrs =
@@ -90,15 +88,15 @@ impl<'a> Net<'a> {
9088
NeighborCache::new(&mut store.neighbor_cache_storage[..]);
9189
let routes = Routes::new(&mut store.routes_storage[..]);
9290

93-
let iface = EthernetInterfaceBuilder::new(ethdev)
94-
.ethernet_addr(ethernet_addr)
95-
.neighbor_cache(neighbor_cache)
96-
.ip_addrs(&mut store.ip_addrs[..])
97-
.routes(routes)
98-
.finalize();
99-
let sockets = SocketSet::new(&mut store.socket_set_entries[..]);
91+
let iface =
92+
InterfaceBuilder::new(ethdev, &mut store.socket_storage[..])
93+
.hardware_addr(ethernet_addr)
94+
.neighbor_cache(neighbor_cache)
95+
.ip_addrs(&mut store.ip_addrs[..])
96+
.routes(routes)
97+
.finalize();
10098

101-
return Net { iface, sockets };
99+
return Net { iface };
102100
}
103101

104102
/// Polls on the ethernet interface. You should refer to the smoltcp
@@ -107,7 +105,7 @@ impl<'a> Net<'a> {
107105
let timestamp = Instant::from_millis(now);
108106

109107
self.iface
110-
.poll(&mut self.sockets, timestamp)
108+
.poll(timestamp)
111109
.map(|_| ())
112110
.unwrap_or_else(|e| info!("Poll: {:?}", e));
113111
}
@@ -198,13 +196,11 @@ const APP: () = {
198196
lan8742a.phy_init();
199197
// The eth_dma should not be used until the PHY reports the link is up
200198

201-
unsafe {
202-
ethernet::enable_interrupt();
203-
}
199+
unsafe { ethernet::enable_interrupt() };
204200

205201
// unsafe: mutable reference to static storage, we only do this once
206202
let store = unsafe { &mut STORE };
207-
let net = Net::new(store, eth_dma, mac_addr);
203+
let net = Net::new(store, eth_dma, mac_addr.into());
208204

209205
// 1ms tick
210206
systick_init(ctx.core.SYST, ccdr.clocks);

0 commit comments

Comments
 (0)