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]]
|
[[package]]
|
||||||
name = "minimq"
|
name = "minimq"
|
||||||
version = "0.2.0"
|
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 = [
|
dependencies = [
|
||||||
"bit_field",
|
"bit_field",
|
||||||
"embedded-nal",
|
"embedded-nal",
|
||||||
@ -690,7 +690,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "serde-json-core"
|
name = "serde-json-core"
|
||||||
version = "0.2.0"
|
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 = [
|
dependencies = [
|
||||||
"heapless 0.6.1",
|
"heapless 0.6.1",
|
||||||
"ryu",
|
"ryu",
|
||||||
|
@ -64,11 +64,11 @@ rev = "8468f11"
|
|||||||
|
|
||||||
[dependencies.minimq]
|
[dependencies.minimq]
|
||||||
git = "https://github.com/quartiq/minimq.git"
|
git = "https://github.com/quartiq/minimq.git"
|
||||||
branch = "rs/issue-40/copyable-properties"
|
rev = "b3f364d"
|
||||||
|
|
||||||
[patch.crates-io.serde-json-core]
|
[patch.crates-io.serde-json-core]
|
||||||
git = "https://github.com/quartiq/serde-json-core.git"
|
git = "https://github.com/rust-embedded-community/serde-json-core.git"
|
||||||
branch = "feature/dependency-update"
|
rev = "da460d1"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
semihosting = ["panic-semihosting", "cortex-m-log/semihosting"]
|
semihosting = ["panic-semihosting", "cortex-m-log/semihosting"]
|
||||||
|
@ -22,7 +22,7 @@ where
|
|||||||
phy: EthernetPhy,
|
phy: EthernetPhy,
|
||||||
network_was_reset: bool,
|
network_was_reset: bool,
|
||||||
subscribed: bool,
|
subscribed: bool,
|
||||||
id: String<consts::U32>,
|
id: String<consts::U64>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S> MqttInterface<S>
|
impl<S> MqttInterface<S>
|
||||||
@ -99,9 +99,24 @@ where
|
|||||||
self.network_was_reset = false;
|
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,
|
// If we're no longer subscribed to the settings topic, but we are connected to the broker,
|
||||||
// resubscribe.
|
// 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();
|
let mut settings_topic: String<consts::U128> = String::new();
|
||||||
write!(&mut settings_topic, "{}/settings/#", self.id.as_str())
|
write!(&mut settings_topic, "{}/settings/#", self.id.as_str())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
Loading…
Reference in New Issue
Block a user