mirror of
https://github.com/janishutz/mqtt-remote-gpio.git
synced 2026-10-08 20:56:22 +02:00
chore: some debugging
This commit is contained in:
1 parent
51c9b2068d
commit
760895bb5c
1 file changed
+4
@@ -12,6 +12,7 @@ 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,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,6 +61,7 @@ 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)
|
||||||
@@ -132,8 +134,10 @@ impl GPIOController {
|
|||||||
instr.push(*c as char)
|
instr.push(*c as char)
|
||||||
}
|
}
|
||||||
if instr == "ON" {
|
if instr == "ON" {
|
||||||
|
println!("Turned ON pin {}", pin.id);
|
||||||
pin.gpio.set_high();
|
pin.gpio.set_high();
|
||||||
} else if instr == "OFF" {
|
} else if instr == "OFF" {
|
||||||
|
println!("Turned OFF pin {}", pin.id);
|
||||||
pin.gpio.set_low();
|
pin.gpio.set_low();
|
||||||
} else {
|
} else {
|
||||||
println!("Received unknown instruction {}", instr);
|
println!("Received unknown instruction {}", instr);
|
||||||
|
|||||||
Reference in new issue
Block a user