Simplifying MQTT handling
This commit is contained in:
parent
36cc423f70
commit
f38e3b9608
3
Cargo.lock
generated
3
Cargo.lock
generated
@ -203,7 +203,6 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "derive_miniconf"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/quartiq/miniconf.git?branch=feature/mqtt-removal#6b6b9d7973ac5b4771c211c775c51f82d4a7727f"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@ -416,10 +415,10 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "miniconf"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/quartiq/miniconf.git?branch=feature/mqtt-removal#6b6b9d7973ac5b4771c211c775c51f82d4a7727f"
|
||||
dependencies = [
|
||||
"derive_miniconf",
|
||||
"heapless 0.6.1",
|
||||
"minimq",
|
||||
"serde",
|
||||
"serde-json-core",
|
||||
]
|
||||
|
11
Cargo.toml
11
Cargo.toml
@ -44,7 +44,7 @@ paste = "1"
|
||||
dsp = { path = "dsp" }
|
||||
ad9959 = { path = "ad9959" }
|
||||
generic-array = "0.14"
|
||||
miniconf = "0.1.0"
|
||||
miniconf = { version = "0.1.0", features = ["minimq-support"] }
|
||||
|
||||
[dependencies.mcp23017]
|
||||
git = "https://github.com/mrd0ll4r/mcp23017.git"
|
||||
@ -55,8 +55,13 @@ features = ["stm32h743v", "rt", "unproven", "ethernet", "quadspi"]
|
||||
version = "0.9.0"
|
||||
|
||||
[patch.crates-io.miniconf]
|
||||
git = "https://github.com/quartiq/miniconf.git"
|
||||
branch = "feature/mqtt-removal"
|
||||
path = "../miniconf"
|
||||
# git = "https://github.com/quartiq/miniconf.git"
|
||||
# branch = "feature/mqtt-removal"
|
||||
|
||||
[patch.crates-io.minimq]
|
||||
git = "https://github.com/quartiq/minimq.git"
|
||||
rev = "933687c2e4b"
|
||||
|
||||
[dependencies.smoltcp-nal]
|
||||
git = "https://github.com/quartiq/smoltcp-nal.git"
|
||||
|
@ -116,31 +116,10 @@ where
|
||||
// Handle any MQTT traffic.
|
||||
match self.mqtt.borrow_mut().poll(
|
||||
|client, topic, message, properties| {
|
||||
// Find correlation-data and response topics.
|
||||
let correlation_data = properties.iter().find_map(|prop| {
|
||||
if let minimq::Property::CorrelationData(data) = prop {
|
||||
Some(*data)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
});
|
||||
let response_topic = properties.iter().find_map(|prop| {
|
||||
if let minimq::Property::ResponseTopic(topic) = prop {
|
||||
Some(*topic)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
});
|
||||
|
||||
let incoming = miniconf::Message {
|
||||
data: message,
|
||||
correlation_data,
|
||||
response_topic,
|
||||
};
|
||||
|
||||
if let Some(response) =
|
||||
self.miniconf.borrow_mut().process(topic, incoming)
|
||||
{
|
||||
if let Some(response) = self.miniconf.borrow_mut().process(
|
||||
topic,
|
||||
miniconf::Message::from(message, properties),
|
||||
) {
|
||||
let mut response_properties: Vec<
|
||||
minimq::Property,
|
||||
consts::U1,
|
||||
|
Loading…
Reference in New Issue
Block a user