Skip to content

Commit 295aacf

Browse files
committed
Update smoltcp to 0.12.
1 parent a450be8 commit 295aacf

File tree

6 files changed

+48
-64
lines changed

6 files changed

+48
-64
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 14 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.6", features=["shared-stack"] }
6666
serial-settings = "0.2"
6767
stm32f4xx-hal = {version = "0.22.1", features = ["stm32f407", "usb_fs"] }
6868

@@ -75,11 +75,17 @@ 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.smoltcp-nal]
79+
git = "https://github.com/quartiq/smoltcp-nal"
80+
81+
[patch.crates-io.miniconf]
82+
git = "https://github.com/quartiq/miniconf"
83+
84+
[patch.crates-io.miniconf_mqtt]
85+
git = "https://github.com/quartiq/miniconf"
86+
87+
[patch.crates-io.minireq]
88+
git = "https://github.com/quartiq/minireq"
8389

8490
[dependencies.ads7924]
8591
path = "ads7924"

smoltcp-nal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 801a9178c95fb343ba7cab67645b9368cc8d341c

src/hardware/external_mac.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ pub struct RxToken {
6464
impl smoltcp::phy::RxToken for RxToken {
6565
fn consume<R, F>(mut self, f: F) -> R
6666
where
67-
F: FnOnce(&mut [u8]) -> R,
67+
F: FnOnce(&[u8]) -> R,
6868
{
6969
f(&mut self.frame_buffer[..self.length])
7070
}

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)