Skip to content

Commit fc219a1

Browse files
committed
Update smoltcp to 0.12.
1 parent 667923e commit fc219a1

7 files changed

Lines changed: 51 additions & 71 deletions

File tree

Cargo.lock

Lines changed: 20 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@ panic-persist = { version = "0.3", features = ["custom-panic-handler", "utf8"] }
5454
miniconf = { version = "0.18", features = ["json-core", "derive", "postcard"]}
5555
miniconf_mqtt = "0.18"
5656
# Note: Keep `py/pyproject.toml` version in sync with the Minimq version used in FW.
57-
minimq = "0.9.0"
58-
w5500 = "0.5"
57+
minimq = "0.10.0"
58+
w5500 = "0.6"
5959
smlang= "0.8"
6060
minireq = "0.5"
6161
rtt-target = "0.6"
6262
enum-iterator = { version = "2.1", default-features = false }
6363
enc424j600 = "0.4"
6464
embedded-hal = "1"
65-
smoltcp-nal = { version = "0.5", features=["shared-stack"] }
65+
smoltcp-nal = { version = "0.7", features=["shared-stack"] }
6666
serial-settings = "0.2"
6767
stm32f4xx-hal = {version = "0.22.1", features = ["stm32f407", "usb_fs"] }
6868

@@ -75,11 +75,12 @@ built = { version = "0.7", features = ["git2"], default-features = false }
7575
path = "ad5627"
7676
version = "0.2"
7777

78-
[patch.crates-io.smoltcp]
79-
# Locking to a patch where the poll() function no longer loops infinitely during packet floods. This
80-
# can be removed once smoltcp is re-released.
81-
git = "https://github.com/smoltcp-rs/smoltcp"
82-
rev = "53caf70f640d5ccb3cd1492e1cb178bc7dfa3cdd"
78+
[patch.crates-io]
79+
miniconf = { git = "https://github.com/quartiq/miniconf" }
80+
miniconf_mqtt = { git = "https://github.com/quartiq/miniconf" }
81+
minireq = { git = "https://github.com/quartiq/minireq" }
82+
# See https://github.com/quartiq/smoltcp-nal/pull/57.
83+
smoltcp-nal = { git = "https://github.com/reitermarkus/smoltcp-nal", branch = "granular-poll" }
8384

8485
[dependencies.ads7924]
8586
path = "ads7924"

memory.x

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ MEMORY
55
FLASH : ORIGIN = 0x08000000, LENGTH = 768K
66
RAM : ORIGIN = 0x20000000, LENGTH = 126K
77
PANDUMP : ORIGIN = 0x2001FC00, LENGTH = 1K
8-
BOOTFLAG_RAM: ORIGIN = 0x2001F800, LENGTH = 1K
8+
BOOTFLAG_RAM : ORIGIN = 0x2001F800, LENGTH = 1K
99
}
1010

1111
_bootflag = ORIGIN(BOOTFLAG_RAM);

src/hardware/external_mac.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ pub struct RxToken {
6262
}
6363

6464
impl smoltcp::phy::RxToken for RxToken {
65-
fn consume<R, F>(mut self, f: F) -> R
65+
fn consume<R, F>(self, f: F) -> R
6666
where
67-
F: FnOnce(&mut [u8]) -> R,
67+
F: FnOnce(&[u8]) -> R,
6868
{
69-
f(&mut self.frame_buffer[..self.length])
69+
f(&self.frame_buffer[..self.length])
7070
}
7171
}
7272

src/net/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use crate::hardware::{NetworkStack, SystemTimer};
44

5-
use core::fmt::Write;
5+
use core::{fmt::Write, num::NonZero};
66
use heapless::String;
77

88
pub mod mqtt_control;
@@ -139,6 +139,8 @@ impl NetworkDevices {
139139
pub fn process(&mut self) -> bool {
140140
self.telemetry.update();
141141

142-
self.stack.lock(|stack| stack.poll()).unwrap_or(true)
142+
self.stack
143+
.lock(|stack| stack.poll_n(const { NonZero::new(1).unwrap() }))
144+
.unwrap_or(true)
143145
}
144146
}

src/net/mqtt_control.rs

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::{
55
Channel,
66
};
77

8-
use minimq::{DeferredPublication, Publication};
8+
use minimq::Publication;
99

1010
use super::NetworkStackProxy;
1111

@@ -124,12 +124,9 @@ impl TelemetryClient {
124124
// All telemtry is published in a best-effort manner.
125125
self.mqtt
126126
.client()
127-
.publish(
128-
DeferredPublication::new(|buf| serde_json_core::to_slice(telemetry, buf))
129-
.topic(&topic)
130-
.finish()
131-
.unwrap(),
132-
)
127+
.publish(Publication::new(&topic, |buf: &mut [u8]| {
128+
serde_json_core::to_slice(telemetry, buf)
129+
}))
133130
.ok();
134131
}
135132

@@ -155,23 +152,15 @@ impl TelemetryClient {
155152

156153
if mqtt
157154
.client()
158-
.publish(
159-
DeferredPublication::new(|buf| serde_json_core::to_slice(&metadata, buf))
160-
.topic(&topic)
161-
.finish()
162-
.unwrap(),
163-
)
155+
.publish(Publication::new(&topic, |buf: &mut [u8]| {
156+
serde_json_core::to_slice(&metadata, buf)
157+
}))
164158
.is_err()
165159
{
166160
// Note(unwrap): We can guarantee that this message will be sent because we checked
167161
// for ability to publish above.
168162
mqtt.client()
169-
.publish(
170-
Publication::new(DEFAULT_METADATA.as_bytes())
171-
.topic(&topic)
172-
.finish()
173-
.unwrap(),
174-
)
163+
.publish(Publication::new(&topic, DEFAULT_METADATA.as_bytes()))
175164
.unwrap();
176165
}
177166

src/settings/eeprom/main_board.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ fn identifier_is_valid(id: &str) -> bool {
4646
pub struct IpAddr(pub smoltcp_nal::smoltcp::wire::Ipv4Address);
4747

4848
impl IpAddr {
49-
pub fn new(bytes: &[u8]) -> Self {
50-
Self(smoltcp::wire::Ipv4Address::from_bytes(bytes))
49+
pub fn new(a: u8, b: u8, c: u8, d: u8) -> Self {
50+
Self(smoltcp::wire::Ipv4Address::new(a, b, c, d))
5151
}
5252
}
5353

@@ -78,11 +78,11 @@ impl encdec::Encode for IpAddr {
7878
type Error = encdec::Error;
7979

8080
fn encode_len(&self) -> Result<usize, Self::Error> {
81-
Ok(self.0 .0.len())
81+
Ok(self.0.octets().len())
8282
}
8383

8484
fn encode(&self, buff: &mut [u8]) -> Result<usize, Self::Error> {
85-
self.0 .0.encode(buff)
85+
self.0.octets().encode(buff)
8686
}
8787
}
8888

@@ -91,8 +91,8 @@ impl encdec::DecodeOwned for IpAddr {
9191
type Error = encdec::Error;
9292

9393
fn decode_owned(buff: &[u8]) -> Result<(Self::Output, usize), Self::Error> {
94-
let (data, size) = <[u8; 4]>::decode_owned(buff)?;
95-
Ok((Self::new(&data[..]), size))
94+
let ([a, b, c, d], size) = <[u8; 4]>::decode_owned(buff)?;
95+
Ok((Self::new(a, b, c, d), size))
9696
}
9797
}
9898

0 commit comments

Comments
 (0)