mirror of
https://github.com/janishutz/mqtt-remote-gpio.git
synced 2026-10-09 05:06:21 +02:00
fix: warnings and errors
This commit is contained in:
1 parent
59021bb5a6
commit
51c9b2068d
2 files changed
+2
-6
No files matched your search
+2
-4
@@ -12,7 +12,6 @@ pub struct InputPin {
|
|||||||
pub struct OutputPin {
|
pub struct OutputPin {
|
||||||
gpio: gpio::OutputPin,
|
gpio: gpio::OutputPin,
|
||||||
off_timeout: u64,
|
off_timeout: u64,
|
||||||
pub id: u8,
|
|
||||||
pub topic: String,
|
pub topic: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,7 +60,6 @@ pub fn split_topics_and_configure_pins(topics: Vec<Topic>) -> (Vec<InputPin>, Ve
|
|||||||
.get(topic.pin)
|
.get(topic.pin)
|
||||||
.expect(&format!("Unable to find GPIO pin {}", topic.pin))
|
.expect(&format!("Unable to find GPIO pin {}", topic.pin))
|
||||||
.into_output_low(),
|
.into_output_low(),
|
||||||
id: topic.pin,
|
|
||||||
off_timeout: topic.off_timeout,
|
off_timeout: topic.off_timeout,
|
||||||
});
|
});
|
||||||
out_used.push(topic.pin)
|
out_used.push(topic.pin)
|
||||||
@@ -127,7 +125,7 @@ impl GPIOController {
|
|||||||
if self.topics.contains(&instruction.topic) {
|
if self.topics.contains(&instruction.topic) {
|
||||||
let pin = self
|
let pin = self
|
||||||
.out_pins
|
.out_pins
|
||||||
.get(&instruction.topic)
|
.get_mut(&instruction.topic)
|
||||||
.expect("Failed to load pins data");
|
.expect("Failed to load pins data");
|
||||||
let mut instr = "".to_string();
|
let mut instr = "".to_string();
|
||||||
for c in &instruction.payload {
|
for c in &instruction.payload {
|
||||||
@@ -138,7 +136,7 @@ impl GPIOController {
|
|||||||
} else if instr == "OFF" {
|
} else if instr == "OFF" {
|
||||||
pin.gpio.set_low();
|
pin.gpio.set_low();
|
||||||
} else {
|
} else {
|
||||||
println!("Received unknown instruction", instr);
|
println!("Received unknown instruction {}", instr);
|
||||||
}
|
}
|
||||||
if pin.off_timeout > 0 {
|
if pin.off_timeout > 0 {
|
||||||
self.timeout_topics
|
self.timeout_topics
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
use std::{thread, time::Duration};
|
|
||||||
mod conf;
|
mod conf;
|
||||||
mod gpio_utils;
|
mod gpio_utils;
|
||||||
mod mqtt;
|
mod mqtt;
|
||||||
@@ -13,7 +12,6 @@ fn main() {
|
|||||||
|
|
||||||
// TODO: Remove this when done
|
// TODO: Remove this when done
|
||||||
println!("{:#?}", config);
|
println!("{:#?}", config);
|
||||||
thread::sleep(Duration::from_secs(2));
|
|
||||||
|
|
||||||
mqtt::handler(config);
|
mqtt::handler(config);
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user