Skip to content

Commit

Permalink
Upgrade smoltcp to 0.12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tlevora committed Dec 17, 2024
1 parent af986ea commit 242751f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ defmt = { version = "0.3", optional = true }
futures = { version = "0.3", default-features = false, features = ["async-await"], optional = true }

[dependencies.smoltcp]
version = "0.11"
version = "0.12"
default-features = false
optional = true

Expand Down Expand Up @@ -73,7 +73,7 @@ fugit = "0.3"
defmt-rtt = "0.4"
panic-probe = { version = "0.3", features = [ "print-defmt" ] }
systick-monotonic = "1.0"
smoltcp = { version = "0.11", features = [ "medium-ethernet", "proto-ipv4", "socket-udp", "socket-tcp", "defmt" ], default-features = false }
smoltcp = { version = "0.12", features = [ "medium-ethernet", "proto-ipv4", "socket-udp", "socket-tcp", "defmt" ], default-features = false }

[dev-dependencies.rtic]
package = "cortex-m-rtic"
Expand Down
2 changes: 1 addition & 1 deletion examples/smoltcp-timesync/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ mod app {
let packet_id = dma.lock(|dma| dma.next_packet_id()).into();

let mut meta: udp::UdpMetadata = IpEndpoint {
addr: IpAddress::Ipv4(Ipv4Address([10, 0, 0, 1])),
addr: IpAddress::Ipv4(Ipv4Address::new(10, 0, 0, 1)),
port: 1337,
}
.into();
Expand Down
2 changes: 1 addition & 1 deletion examples/smoltcp-timesync/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ mod app {
let packet_id = dma.lock(|dma| dma.next_packet_id()).into();

let mut meta: udp::UdpMetadata = IpEndpoint {
addr: IpAddress::Ipv4(Ipv4Address([10, 0, 0, 2])),
addr: IpAddress::Ipv4(Ipv4Address::new(10, 0, 0, 2)),
port: 1337,
}
.into();
Expand Down
16 changes: 11 additions & 5 deletions src/dma/smoltcp_phy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@ use smoltcp::time::Instant;

/// Use this Ethernet driver with [smoltcp](https://github.com/smoltcp-rs/smoltcp)
impl<'a, 'rx, 'tx> Device for &'a mut EthernetDMA<'rx, 'tx> {
type RxToken<'token> = EthRxToken<'token, 'rx> where Self: 'token;
type TxToken<'token> = EthTxToken<'token, 'tx> where Self: 'token;
type RxToken<'token>
= EthRxToken<'token, 'rx>
where
Self: 'token;
type TxToken<'token>
= EthTxToken<'token, 'tx>
where
Self: 'token;

fn capabilities(&self) -> DeviceCapabilities {
let mut caps = DeviceCapabilities::default();
Expand Down Expand Up @@ -72,7 +78,7 @@ pub struct EthRxToken<'a, 'rx> {
impl<'dma, 'rx> RxToken for EthRxToken<'dma, 'rx> {
fn consume<R, F>(self, f: F) -> R
where
F: FnOnce(&mut [u8]) -> R,
F: FnOnce(&[u8]) -> R,
{
#[cfg(feature = "ptp")]
let meta = Some(self.meta.into());
Expand All @@ -81,8 +87,8 @@ impl<'dma, 'rx> RxToken for EthRxToken<'dma, 'rx> {
let meta = None;

// NOTE(unwrap): an `EthRxToken` is only created when `eth.rx_available()`
let mut packet = self.rx_ring.recv_next(meta).ok().unwrap();
let result = f(&mut packet);
let packet = self.rx_ring.recv_next(meta).ok().unwrap();
let result = f(&packet);
packet.free();
result
}
Expand Down

0 comments on commit 242751f

Please sign in to comment.