Refactoring to support DHCP
This commit is contained in:
parent
01349a39b3
commit
aad026161f
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -427,7 +427,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "minimq"
|
||||
version = "0.2.0"
|
||||
source = "git+https://github.com/quartiq/minimq.git?branch=rs/issue-40/copyable-properties#c95c758b620ee98752852bb643df8557a7200f3f"
|
||||
source = "git+https://github.com/quartiq/minimq.git?rev=b3f364d#b3f364d55dea35da6572f78ddb91c87bfbb453bf"
|
||||
dependencies = [
|
||||
"bit_field",
|
||||
"embedded-nal",
|
||||
@ -690,7 +690,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "serde-json-core"
|
||||
version = "0.2.0"
|
||||
source = "git+https://github.com/quartiq/serde-json-core.git?branch=feature/dependency-update#a304506a1efb4a90a6ef3faf71ec3ef5f8433fb4"
|
||||
source = "git+https://github.com/rust-embedded-community/serde-json-core.git?rev=da460d1#da460d123e217f0e822a3977eb2170ed5d279d5e"
|
||||
dependencies = [
|
||||
"heapless 0.6.1",
|
||||
"ryu",
|
||||
|
@ -64,11 +64,11 @@ rev = "8468f11"
|
||||
|
||||
[dependencies.minimq]
|
||||
git = "https://github.com/quartiq/minimq.git"
|
||||
branch = "rs/issue-40/copyable-properties"
|
||||
rev = "b3f364d"
|
||||
|
||||
[patch.crates-io.serde-json-core]
|
||||
git = "https://github.com/quartiq/serde-json-core.git"
|
||||
branch = "feature/dependency-update"
|
||||
git = "https://github.com/rust-embedded-community/serde-json-core.git"
|
||||
rev = "da460d1"
|
||||
|
||||
[features]
|
||||
semihosting = ["panic-semihosting", "cortex-m-log/semihosting"]
|
||||
|
@ -22,7 +22,7 @@ where
|
||||
phy: EthernetPhy,
|
||||
network_was_reset: bool,
|
||||
subscribed: bool,
|
||||
id: String<consts::U32>,
|
||||
id: String<consts::U64>,
|
||||
}
|
||||
|
||||
impl<S> MqttInterface<S>
|
||||
@ -99,9 +99,24 @@ where
|
||||
self.network_was_reset = false;
|
||||
}
|
||||
|
||||
let mqtt_connected = match self.mqtt.borrow_mut().is_connected() {
|
||||
Ok(connected) => connected,
|
||||
Err(minimq::Error::Network(
|
||||
smoltcp_nal::NetworkError::NoIpAddress,
|
||||
)) => false,
|
||||
Err(minimq::Error::Network(error)) => {
|
||||
log::info!("Unexpected network error: {:?}", error);
|
||||
false
|
||||
}
|
||||
Err(error) => {
|
||||
log::warn!("Unexpected MQTT error: {:?}", error);
|
||||
false
|
||||
}
|
||||
};
|
||||
|
||||
// If we're no longer subscribed to the settings topic, but we are connected to the broker,
|
||||
// resubscribe.
|
||||
if !self.subscribed && self.mqtt.borrow_mut().is_connected().unwrap() {
|
||||
if !self.subscribed && mqtt_connected {
|
||||
let mut settings_topic: String<consts::U128> = String::new();
|
||||
write!(&mut settings_topic, "{}/settings/#", self.id.as_str())
|
||||
.unwrap();
|
||||
|
Loading…
Reference in New Issue
Block a user